vwo-fme-node-sdk
Version:
VWO Node/JavaScript SDK for Feature Management and Experimentation
25 lines • 170 kB
JavaScript
/*!
* vwo-fme-node-sdk - v1.21.0
* URL - https://github.com/wingify/vwo-node-sdk
*
* Copyright 2024-2025 Wingify Software Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Dependencies used -
* 1. murmurhash - ^2.0.1
* 2. superstruct - ^0.14.x
* 3. uuid - ^9.0.1
* 4. vwo-fme-sdk-log-messages - ^1.*.*
*/
(()=>{"use strict";var e={119:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.NetworkManager=void 0;var o=n(5576),a=n(9717),i=n(7666),s=n(477),u=n(7173),c=n(7623),l=n(2974),g=n(5076),p=function(){function e(){}return e.prototype.validateRetryConfig=function(e){var t=r({},e),n=!1;return(0,u.isBoolean)(t.shouldRetry)||(t.shouldRetry=s.Constants.DEFAULT_RETRY_CONFIG.shouldRetry,n=!0),(!(0,u.isNumber)(t.maxRetries)||!Number.isInteger(t.maxRetries)||t.maxRetries<1)&&(t.maxRetries=s.Constants.DEFAULT_RETRY_CONFIG.maxRetries,n=!0),(!(0,u.isNumber)(t.initialDelay)||!Number.isInteger(t.initialDelay)||t.initialDelay<1)&&(t.initialDelay=s.Constants.DEFAULT_RETRY_CONFIG.initialDelay,n=!0),(!(0,u.isNumber)(t.backoffMultiplier)||!Number.isInteger(t.backoffMultiplier)||t.backoffMultiplier<2)&&(t.backoffMultiplier=s.Constants.DEFAULT_RETRY_CONFIG.backoffMultiplier,n=!0),n&&c.LogManager.Instance.error((0,g.buildMessage)(l.ErrorLogMessagesEnum.RETRY_CONFIG_INVALID,{retryConfig:JSON.stringify(t)})),n?s.Constants.DEFAULT_RETRY_CONFIG:t},e.prototype.attachClient=function(e,t){if(!this.retryConfig||t){var o=s.Constants.DEFAULT_RETRY_CONFIG,a=r(r({},o),t||{});this.retryConfig=this.validateRetryConfig(a)}if(void 0===process.env)if("undefined"==typeof XMLHttpRequest){var u=n(8341).w;this.client=e||new u}else{var c=n(7005).o;this.client=e||new c}else{var l=n(6787)._;this.client=e||new l}this.config=new i.GlobalRequestModel(null,null,null,null)},e.prototype.getRetryConfig=function(){return r({},this.retryConfig)},Object.defineProperty(e,"Instance",{get:function(){return this.instance=this.instance||new e,this.instance},enumerable:!1,configurable:!0}),e.prototype.setConfig=function(e){this.config=e},e.prototype.getConfig=function(){return this.config},e.prototype.createRequest=function(e){return(new a.RequestHandler).createRequest(e,this.config)},e.prototype.get=function(e){var t=new o.Deferred,n=this.createRequest(e);return n.getUrl()?this.client.GET(n).then((function(e){t.resolve(e)})).catch((function(e){t.reject(e)})):t.reject(new Error("no url found")),t.promise},e.prototype.post=function(e){var t=new o.Deferred,n=this.createRequest(e);return n.getUrl()?this.client.POST(n).then((function(e){t.resolve(e)})).catch((function(e){t.reject(e)})):t.reject(new Error("no url found")),t.promise},e}();t.NetworkManager=p},477:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Constants=void 0;var r,o,a=n(2550),i=n(3388);void 0===process.env?(r={name:"vwo-fme-javascript-sdk",version:SDK_VERSION},o=a.PlatformEnum.CLIENT):(r=n(6089),o=a.PlatformEnum.SERVER),t.Constants={SDK_NAME:r.name,SDK_VERSION:r.version,PLATFORM:o,MAX_TRAFFIC_PERCENT:100,MAX_TRAFFIC_VALUE:1e4,STATUS_RUNNING:"RUNNING",SEED_VALUE:1,MAX_EVENTS_PER_REQUEST:5e3,DEFAULT_REQUEST_TIME_INTERVAL:600,DEFAULT_EVENTS_PER_REQUEST:100,SEED_URL:i.SEED_URL,HTTP_PROTOCOL:i.HTTP_PROTOCOL,HTTPS_PROTOCOL:i.HTTPS_PROTOCOL,SETTINGS:"settings",SETTINGS_EXPIRY:1e7,SETTINGS_TIMEOUT:5e4,SETTINGS_TTL:72e5,MIN_TTL_MS:6e4,HOST_NAME:"dev.visualwebsiteoptimizer.com",SETTINTS_ENDPOINT:"/server-side/v2-settings",WEBHOOK_SETTINTS_ENDPOINT:"/server-side/v2-pull",LOCATION_ENDPOINT:"/getLocation",VWO_FS_ENVIRONMENT:"vwo_fs_environment",RANDOM_ALGO:1,API_VERSION:"1",VWO_META_MEG_KEY:"_vwo_meta_meg_",DEFAULT_RETRY_CONFIG:{shouldRetry:!0,initialDelay:2,maxRetries:3,backoffMultiplier:2},DEFAULT_LOCAL_STORAGE_KEY:"vwo_fme_data",DEFAULT_SETTINGS_STORAGE_KEY:"vwo_fme_settings"}},596:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.getFromGatewayService=function(e,t){return r(this,void 0,void 0,(function(){var n,r,a,d;return o(this,(function(o){if(n=new g.Deferred,r=c.NetworkManager.Instance,a=r.getRetryConfig(),!l.SettingsService.Instance.isGatewayServiceProvided)return u.LogManager.Instance.error(s.ErrorLogMessagesEnum.GATEWAY_URL_ERROR),n.resolve(!1),[2,n.promise];e.accountId=l.SettingsService.Instance.accountId;try{return d=new c.RequestModel(p.UrlUtil.getBaseUrl(),i.HttpMethodEnum.GET,t,e,null,null,l.SettingsService.Instance.protocol,l.SettingsService.Instance.port,a),r.get(d).then((function(e){n.resolve(e.getData())})).catch((function(e){n.reject(e)})),[2,n.promise]}catch(e){return n.resolve(!1),[2,n.promise]}return[2]}))}))},t.getQueryParams=function(e){for(var t={},n=0,r=Object.entries(e);n<r.length;n++){var o=r[n],a=o[0],i=o[1],s=encodeURIComponent(String(i));t[a]=s}return t},t.addIsGatewayServiceRequiredFlag=function(e){for(var t=/\b(?<!"custom_variable"[^}]*)(country|region|city|os|device_type|browser_string|ua)\b|(?<="custom_variable"\s*:\s*{\s*"name"\s*:\s*")inlist\([^)]*\)(?=")/g,n=0,r=e.getFeatures();n<r.length;n++)for(var o=r[n],i=0,s=o.getRulesLinkedCampaign();i<s.length;i++){var u,c=s[i];if(u=c.getType()===a.CampaignTypeEnum.PERSONALIZE||c.getType()===a.CampaignTypeEnum.ROLLOUT?c.getVariations()[0].getSegments():c.getSegments()){var l=JSON.stringify(u).match(t);if(l&&l.length>0){o.setIsGatewayServiceRequired(!0);break}}}};var a=n(6947),i=n(5212),s=n(2974),u=n(6178),c=n(4464),l=n(9600),g=n(5576),p=n(6096)},689:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateRule=void 0;var a=n(7173),i=n(9455),s=n(1943),u=n(9284);t.evaluateRule=function(e,t,n,c,l,g,p,d){return r(void 0,void 0,void 0,(function(){var r,f,h;return o(this,(function(o){switch(o.label){case 0:return[4,(0,i.checkWhitelistingAndPreSeg)(e,t,n,c,l,g,p,d)];case 1:return r=o.sent(),f=r[0],h=r[1],f&&(0,a.isObject)(h)&&Object.keys(h).length>0?(Object.assign(d,{experimentId:n.getId(),experimentKey:n.getKey(),experimentVariationId:h.variationId}),(0,s.getShouldWaitForTrackingCalls)()?[4,(0,u.createAndSendImpressionForVariationShown)(e,n.getId(),h.variation.id,c)]:[3,3]):[3,4];case 2:return o.sent(),[3,4];case 3:(0,u.createAndSendImpressionForVariationShown)(e,n.getId(),h.variation.id,c),o.label=4;case 4:return[2,{preSegmentationResult:f,whitelistedObject:h,updatedDecision:d}]}}))}))}},834:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.StorageDecorator=void 0;var a=n(6178),i=n(1522),s=n(2974),u=n(5076),c=n(5576),l=function(){function e(){}return e.prototype.getFeatureFromStorage=function(e,t,n){return r(this,void 0,void 0,(function(){var r;return o(this,(function(o){return r=new c.Deferred,n.getDataInStorage(e,t).then((function(e){switch(e){case i.StorageEnum.STORAGE_UNDEFINED:case i.StorageEnum.NO_DATA_FOUND:r.resolve(null);break;case i.StorageEnum.INCORRECT_DATA:r.resolve(i.StorageEnum.INCORRECT_DATA);break;case i.StorageEnum.CAMPAIGN_PAUSED:r.resolve(null);break;case i.StorageEnum.VARIATION_NOT_FOUND:r.resolve(i.StorageEnum.VARIATION_NOT_FOUND);break;case i.StorageEnum.WHITELISTED_VARIATION:r.resolve(null);break;default:r.resolve(e)}})),[2,r.promise]}))}))},e.prototype.setDataInStorage=function(e,t){var n=new c.Deferred,r=e.featureKey,o=e.context,i=e.rolloutId,l=e.rolloutKey,g=e.rolloutVariationId,p=e.experimentId,d=e.experimentKey,f=e.experimentVariationId;return r?o.id?!l||d||g?d&&!f?(a.LogManager.Instance.error((0,u.buildMessage)(s.ErrorLogMessagesEnum.STORING_DATA_ERROR,{key:"Variation:(experimentKey or rolloutVariationId)"})),void n.reject()):(t.setDataInStorage({featureKey:r,userId:o.id,rolloutId:i,rolloutKey:l,rolloutVariationId:g,experimentId:p,experimentKey:d,experimentVariationId:f}),n.resolve(),n.promise):(a.LogManager.Instance.error((0,u.buildMessage)(s.ErrorLogMessagesEnum.STORING_DATA_ERROR,{key:"Variation:(rolloutKey, experimentKey or rolloutVariationId)"})),void n.reject()):(a.LogManager.Instance.error((0,u.buildMessage)(s.ErrorLogMessagesEnum.STORING_DATA_ERROR,{key:"Context or Context.id"})),void n.reject()):(a.LogManager.Instance.error((0,u.buildMessage)(s.ErrorLogMessagesEnum.STORING_DATA_ERROR,{key:"featureKey"})),void n.reject())},e}();t.StorageDecorator=l},976:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetricModel=void 0;var n=function(){function e(){}return e.prototype.modelFromDictionary=function(e){return this.identifier=e.identifier||e.key,this.id=e.i||e.id,this.type=e.t||e.type,this},e.prototype.getId=function(){return this.id},e.prototype.getIdentifier=function(){return this.identifier},e.prototype.getType=function(){return this.type},e}();t.MetricModel=n},1007:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserStorageConnector=void 0;var i=n(477),s=n(5576),u=n(6178),c=n(9600),l=n(5600),g=n(7173),p=function(){function e(e){this.SETTINGS_KEY=i.Constants.DEFAULT_SETTINGS_STORAGE_KEY,this.storageKey=(null==e?void 0:e.key)||i.Constants.DEFAULT_LOCAL_STORAGE_KEY,this.storage=(null==e?void 0:e.provider)||window.localStorage,this.isDisabled=(null==e?void 0:e.isDisabled)||!1,this.alwaysUseCachedSettings=(null==e?void 0:e.alwaysUseCachedSettings)||!1,!(0,g.isNumber)(null==e?void 0:e.ttl)||e.ttl<i.Constants.MIN_TTL_MS?(u.LogManager.Instance.debug("TTL is not passed or invalid (less than 1 minute), using default value of 2 hours"),this.ttl=i.Constants.SETTINGS_TTL):this.ttl=(null==e?void 0:e.ttl)||i.Constants.SETTINGS_TTL,(0,g.isBoolean)(null==e?void 0:e.alwaysUseCachedSettings)?this.alwaysUseCachedSettings=(null==e?void 0:e.alwaysUseCachedSettings)||!1:(u.LogManager.Instance.debug("AlwaysUseCachedSettings is not passed or invalid, using default value of false"),this.alwaysUseCachedSettings=!1)}return e.prototype.getStoredData=function(){if(this.isDisabled)return{};try{var e=this.storage.getItem(this.storageKey);return e?JSON.parse(e):{}}catch(e){return u.LogManager.Instance.error("Error reading from storage: ".concat(e)),{}}},e.prototype.storeData=function(e){if(!this.isDisabled)try{var t=JSON.stringify(e);this.storage.setItem(this.storageKey,t)}catch(e){u.LogManager.Instance.error("Error writing to storage: ".concat(e))}},e.prototype.set=function(e){var t=new s.Deferred;if(this.isDisabled)t.resolve();else try{var n=this.getStoredData(),r="".concat(e.featureKey,"_").concat(e.userId);n[r]=e,this.storeData(n),u.LogManager.Instance.info("Stored data in storage for key: ".concat(r)),t.resolve()}catch(e){u.LogManager.Instance.error("Error storing data: ".concat(e)),t.reject(e)}return t.promise},e.prototype.get=function(e,t){var n,r=new s.Deferred;if(this.isDisabled)r.resolve({});else try{var o=this.getStoredData(),a="".concat(e,"_").concat(t),i=null!==(n=o[a])&&void 0!==n?n:{};u.LogManager.Instance.info("Retrieved data from storage for key: ".concat(a)),r.resolve(i)}catch(e){u.LogManager.Instance.error("Error retrieving data: ".concat(e)),r.resolve({})}return r.promise},e.prototype.getSettingsFromStorage=function(e,t){var n,r=new s.Deferred;if(this.isDisabled)r.resolve(null);else try{var o=this.getStoredData()[this.SETTINGS_KEY];if(!o)return r.resolve(null),r.promise;var a=o.data,i=o.timestamp,c=Date.now();if(a&&a.sdkKey)try{a.sdkKey=atob(a.sdkKey)}catch(e){u.LogManager.Instance.error("Failed to decode sdkKey from storage")}if(!a||a.sdkKey!==e||String(null!==(n=a.accountId)&&void 0!==n?n:a.a)!==String(t))return u.LogManager.Instance.info("Cached settings do not match sdkKey/accountId, treating as cache miss"),r.resolve(null),r.promise;if(this.alwaysUseCachedSettings)return u.LogManager.Instance.info("Using cached settings as alwaysUseCachedSettings is enabled"),r.resolve(a),r.promise;if(c-i>this.ttl)u.LogManager.Instance.info("Settings have expired, need to fetch new settings"),r.resolve(null);else{if(u.LogManager.Instance.info("Retrieved valid settings from storage"),this.setFreshSettingsInStorage(),a&&a.sdkKey)try{a.sdkKey=atob(a.sdkKey)}catch(e){u.LogManager.Instance.error("Failed to decode sdkKey from storage")}r.resolve(a)}}catch(e){u.LogManager.Instance.error("Error retrieving settings: ".concat(e)),r.resolve(null)}return r.promise},e.prototype.setFreshSettingsInStorage=function(){var e=this,t=c.SettingsService.Instance;t&&t.fetchSettings().then((function(t){return o(e,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t&&(new l.SettingsSchema).isSettingsValid(t)?[4,this.setSettingsInStorage(t)]:[3,2];case 1:e.sent(),u.LogManager.Instance.info("Settings updated with fresh data from server"),e.label=2;case 2:return[2]}}))}))})).catch((function(e){u.LogManager.Instance.error("Error fetching fresh settings: ".concat(e))}))},e.prototype.setSettingsInStorage=function(e){var t=new s.Deferred;if(this.isDisabled)t.resolve();else try{var n=this.getStoredData(),o=r({},e);o.sdkKey&&(o.sdkKey=btoa(o.sdkKey)),n[this.SETTINGS_KEY]={data:o,timestamp:Date.now()},this.storeData(n),u.LogManager.Instance.info("Settings stored successfully in storage"),t.resolve()}catch(e){u.LogManager.Instance.error("Error storing settings: ".concat(e)),t.reject(e)}return t.promise},e}();t.BrowserStorageConnector=p},1155:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.StatusEnum=void 0,function(e){e.PASSED="passed",e.FAILED="failed"}(n||(t.StatusEnum=n={}))},1202:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LogTransportManager=t.LogLevelNumberEnum=void 0;var r,o=n(8858),a=n(7846),i=n(7173);!function(e){e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR"}(r||(t.LogLevelNumberEnum=r={}));var s=function(){function e(e){this.transports=[],this.config=e}return e.prototype.addTransport=function(e){this.transports.push(e)},e.prototype.shouldLog=function(e,t){return r[e.toUpperCase()]>=r[(t||this.config.level).toUpperCase()]},e.prototype.trace=function(e){this.log(o.LogLevelEnum.TRACE,e)},e.prototype.debug=function(e){this.log(o.LogLevelEnum.DEBUG,e)},e.prototype.info=function(e){this.log(o.LogLevelEnum.INFO,e)},e.prototype.warn=function(e){this.log(o.LogLevelEnum.WARN,e)},e.prototype.error=function(e){this.log(o.LogLevelEnum.ERROR,e)},e.prototype.log=function(e,t){for(var n=0;n<this.transports.length;n++){var r=new a.LogMessageBuilder(this.config,this.transports[n]).formatMessage(e,t);this.shouldLog(e,this.transports[n].level)&&(this.transports[n].log&&(0,i.isFunction)(this.transports[n].log)?this.transports[n].log(e,t):this.transports[n][e](r))}},e}();t.LogTransportManager=s},1463:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.VariationModel=void 0;var r=n(2160),o=function(){function e(){this.variables=[],this.variations=[]}return e.prototype.modelFromDictionary=function(t){var n=this;return this.id=t.i||t.id,this.key=t.n||t.key||t.name,this.weight=t.w||t.weight,this.ruleKey=t.ruleKey,this.salt=t.salt,this.type=t.type,this.setStartRange(t.startRangeVariation),this.setEndRange(t.endRangeVariation),(t.seg||t.segments)&&(this.segments=t.seg||t.segments),t.variables&&(t.variables.constructor==={}.constructor?this.variables=[]:t.variables.forEach((function(e){n.variables.push(r.VariableModel.modelFromDictionary(e))}))),t.variations&&(t.variations.constructor==={}.constructor?this.variations=[]:t.variations.forEach((function(t){n.variations.push((new e).modelFromDictionary(t))}))),this},e.prototype.setStartRange=function(e){this.startRangeVariation=e},e.prototype.setEndRange=function(e){this.endRangeVariation=e},e.prototype.setWeight=function(e){this.weight=e},e.prototype.getId=function(){return this.id},e.prototype.getKey=function(){return this.key},e.prototype.getRuleKey=function(){return this.ruleKey},e.prototype.getWeight=function(){return this.weight},e.prototype.getSegments=function(){return this.segments},e.prototype.getStartRangeVariation=function(){return this.startRangeVariation},e.prototype.getEndRangeVariation=function(){return this.endRangeVariation},e.prototype.getVariables=function(){return this.variables},e.prototype.getVariations=function(){return this.variations},e.prototype.getType=function(){return this.type},e.prototype.getSalt=function(){return this.salt},e}();t.VariationModel=o},1522:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.StorageEnum=void 0,function(e){e[e.STORAGE_UNDEFINED=0]="STORAGE_UNDEFINED",e[e.INCORRECT_DATA=1]="INCORRECT_DATA",e[e.NO_DATA_FOUND=2]="NO_DATA_FOUND",e[e.CAMPAIGN_PAUSED=3]="CAMPAIGN_PAUSED",e[e.VARIATION_NOT_FOUND=4]="VARIATION_NOT_FOUND",e[e.WHITELISTED_VARIATION=5]="WHITELISTED_VARIATION"}(n||(t.StorageEnum=n={}))},1566:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.StorageService=void 0;var a=n(1522),i=n(4059),s=n(2974),u=n(6178),c=n(7173),l=n(5076),g=n(5576),p=function(){function e(){this.storageData={}}return e.prototype.getDataInStorage=function(e,t){return r(this,void 0,void 0,(function(){var n,r;return o(this,(function(o){return n=new g.Deferred,r=i.Storage.Instance.getConnector(),(0,c.isNull)(r)||(0,c.isUndefined)(r)?n.resolve(a.StorageEnum.STORAGE_UNDEFINED):r.get(e,t.getId()).then((function(e){n.resolve(e)})).catch((function(e){u.LogManager.Instance.error((0,l.buildMessage)(s.ErrorLogMessagesEnum.STORED_DATA_ERROR,{err:e})),n.resolve(a.StorageEnum.NO_DATA_FOUND)})),[2,n.promise]}))}))},e.prototype.setDataInStorage=function(e){return r(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){return t=new g.Deferred,null==(n=i.Storage.Instance.getConnector())?t.resolve(!1):n.set(e).then((function(){t.resolve(!0)})).catch((function(){t.resolve(!1)})),[2,t.promise]}))}))},e}();t.StorageService=p},1913:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sendGetCall=function(e){return a(r.HttpMethodEnum.GET,e)},t.sendPostCall=function(e){return a(r.HttpMethodEnum.POST,e)};var r=n(5212),o=n(8470);function a(e,t){var n="".concat(t.scheme,"://").concat(t.hostname).concat(t.path);return new Promise((function(a,i){e===r.HttpMethodEnum.POST&&(t.body=JSON.stringify(t.body)),fetch(n,t).then((function(t){return t.text().then((function(n){var s={};try{s=e===r.HttpMethodEnum.GET?JSON.parse(n):n}catch(e){console.info("VWO-SDK - [INFO]: ".concat((0,o.getCurrentTime)()," VWO didn't send JSON response which is expected: ").concat(e))}if(200===t.status)a(s);else{var u="";e===r.HttpMethodEnum.GET?u="VWO-SDK - [ERROR]: ".concat((0,o.getCurrentTime)()," Request failed for fetching account settings. Got Status Code: ").concat(t.status):e===r.HttpMethodEnum.POST&&(u="VWO-SDK - [ERROR]: ".concat((0,o.getCurrentTime)()," Request failed while making a POST request. Got Status Code: ").concat(t.status)),console.error(u),i(u)}}))})).catch((function(t){var n="";e===r.HttpMethodEnum.GET?n="VWO-SDK - [ERROR]: ".concat((0,o.getCurrentTime)()," GET request failed for fetching account settings. Error: ").concat(t):e===r.HttpMethodEnum.POST&&(n="VWO-SDK - [ERROR]: ".concat((0,o.getCurrentTime)()," POST request failed while sending data. Error: ").concat(t)),console.error(n),i(n)}))}))}},1943:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSettingsPath=function(e,t){return{i:"".concat(e),r:Math.random(),a:t}},t.getTrackEventPath=function(e,t,n){return{event_type:e,account_id:t,uId:n,u:(0,i.getUUID)(n,t),sdk:s.Constants.SDK_NAME,"sdk-v":s.Constants.SDK_VERSION,random:(0,a.getRandomNumber)(),ap:s.Constants.PLATFORM,sId:(0,a.getCurrentUnixTimestamp)(),ed:JSON.stringify({p:"server"})}},t.getEventsBaseProperties=function(e,t,n){void 0===t&&(t=""),void 0===n&&(n="");var r=f.SettingsService.Instance.sdkKey,o=Object.assign({en:e,a:f.SettingsService.Instance.accountId,env:r,eTime:(0,a.getCurrentUnixTimestampInMillis)(),random:(0,a.getRandomNumber)(),p:"FS",visitor_ua:t,visitor_ip:n});return o.url=s.Constants.HTTPS_PROTOCOL+y.UrlUtil.getBaseUrl()+l.UrlEnum.EVENTS,o},t._getEventBasePayload=I,t.getTrackUserPayloadData=function(e,t,n,r,o,a,i){void 0===a&&(a=""),void 0===i&&(i="");var s=I(0,t,n,a,i);return s.d.event.props.id=r,s.d.event.props.variation=o,s.d.event.props.isFirst=1,Object.keys(b.UsageStatsUtil.getInstance().getUsageStats()).length>0&&(s.d.event.props.vwoMeta=b.UsageStatsUtil.getInstance().getUsageStats()),p.LogManager.Instance.debug((0,v.buildMessage)(g.DebugLogMessagesEnum.IMPRESSION_FOR_TRACK_USER,{accountId:e.getAccountId(),userId:t,campaignId:r})),s},t.getTrackGoalPayloadData=function(e,t,n,r,o,a){void 0===o&&(o=""),void 0===a&&(a="");var i=I(0,t,n,o,a);if(i.d.event.props.isCustomEvent=!0,i.d.event.props.variation=1,i.d.event.props.id=1,r&&(0,h.isObject)(r)&&Object.keys(r).length>0)for(var s in r)i.d.event.props[s]=r[s];return p.LogManager.Instance.debug((0,v.buildMessage)(g.DebugLogMessagesEnum.IMPRESSION_FOR_TRACK_GOAL,{eventName:n,accountId:e.getAccountId(),userId:t})),i},t.getAttributePayloadData=function(e,t,n,r,o,a){void 0===o&&(o=""),void 0===a&&(a="");var i=I(0,t,n,o,a);i.d.event.props.isCustomEvent=!0,i.d.event.props[s.Constants.VWO_FS_ENVIRONMENT]=e.getSdkkey();for(var u=0,c=Object.entries(r);u<c.length;u++){var l=c[u],d=l[0],f=l[1];i.d.visitor.props[d]=f}return p.LogManager.Instance.debug((0,v.buildMessage)(g.DebugLogMessagesEnum.IMPRESSION_FOR_SYNC_VISITOR_PROP,{eventName:n,accountId:e.getAccountId(),userId:t})),i},t.sendPostApiRequest=function(e,t,n){return r(this,void 0,void 0,(function(){var r,a,i,s,m,E,I;return o(this,(function(o){switch(o.label){case 0:return(r=d.NetworkManager.Instance).attachClient(),a=r.getRetryConfig(),i={},s=t.d.visitor_ua,m=t.d.visitor_ip,s&&(i[u.HeadersEnum.USER_AGENT]=s),m&&(i[u.HeadersEnum.IP]=m),E=y.UrlUtil.getBaseUrl(),E=y.UrlUtil.getUpdatedBaseUrl(E),I=new d.RequestModel(E,c.HttpMethodEnum.POST,l.UrlEnum.EVENTS,e,t,i,f.SettingsService.Instance.protocol,f.SettingsService.Instance.port,a),[4,d.NetworkManager.Instance.post(I).then((function(){Object.keys(b.UsageStatsUtil.getInstance().getUsageStats()).length>0&&b.UsageStatsUtil.getInstance().clearUsageStats(),p.LogManager.Instance.info((0,v.buildMessage)(g.InfoLogMessagesEnum.NETWORK_CALL_SUCCESS,{event:e.en,endPoint:l.UrlEnum.EVENTS,accountId:f.SettingsService.Instance.accountId,userId:n,uuid:t.d.visId}))})).catch((function(e){p.LogManager.Instance.error((0,v.buildMessage)(g.ErrorLogMessagesEnum.NETWORK_CALL_FAILED,{method:c.HttpMethodEnum.POST,err:(0,h.isObject)(e)?JSON.stringify(e):e}))}))];case 1:return o.sent(),[2]}}))}))},t.getShouldWaitForTrackingCalls=function(){return S},t.setShouldWaitForTrackingCalls=function(e){S=e},t.getMessagingEventPayload=function(e,t,n){var r=I(0,f.SettingsService.Instance.accountId+"_"+f.SettingsService.Instance.sdkKey,n,null,null);r.d.event.props[s.Constants.VWO_FS_ENVIRONMENT]=f.SettingsService.Instance.sdkKey,r.d.event.props.product="fme";var o={type:e,content:{title:t,dateTime:(0,a.getCurrentUnixTimestampInMillis)()}};return r.d.event.props.data=o,r},t.sendMessagingEvent=function(e,t){return r(this,void 0,void 0,(function(){var n,r,a,i,s;return o(this,(function(o){n=new m.Deferred,r=d.NetworkManager.Instance,(a=r.getRetryConfig()).shouldRetry=!1,i=y.UrlUtil.getBaseUrl(),i=y.UrlUtil.getUpdatedBaseUrl(i);try{return s=new d.RequestModel(i,c.HttpMethodEnum.POST,l.UrlEnum.EVENTS,e,t,null,E.HTTPS,null,a),r.post(s).then((function(e){n.resolve(e.getData())})).catch((function(e){n.reject(e)})),[2,n.promise]}catch(e){return n.resolve(!1),[2,n.promise]}return[2]}))}))};var a=n(8470),i=n(4334),s=n(477),u=n(2209),c=n(5212),l=n(2478),g=n(2974),p=n(6178),d=n(4464),f=n(9600),h=n(7173),v=n(5076),y=n(6096),m=n(5576),E=n(3388),b=n(5291);function I(e,t,n,r,o){void 0===r&&(r=""),void 0===o&&(o="");var u=(0,i.getUUID)(t.toString(),f.SettingsService.Instance.accountId.toString()),c=f.SettingsService.Instance.sdkKey,l={vwo_sdkName:s.Constants.SDK_NAME,vwo_sdkVersion:s.Constants.SDK_VERSION,vwo_envKey:c};return{d:{msgId:"".concat(u,"-").concat((0,a.getCurrentUnixTimestampInMillis)()),visId:u,sessionId:(0,a.getCurrentUnixTimestamp)(),visitor_ua:r,visitor_ip:o,event:{props:l,name:n,time:(0,a.getCurrentUnixTimestampInMillis)()},visitor:{props:{vwo_fs_environment:c}}}}}var S=!1},1946:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Storage=void 0;var n=function(){function e(){}return e.prototype.attachConnector=function(e){var t,n,r,o;return"class"===(null===(o=null===(r=null===(n=null===(t=null==e?void 0:e.prototype)||void 0===t?void 0:t.constructor)||void 0===n?void 0:n.toString())||void 0===r?void 0:r.trim())||void 0===o?void 0:o.substring(0,5))?this.connector=new e:this.connector=e,this.connector},Object.defineProperty(e,"Instance",{get:function(){return this.instance=this.instance||new e,this.instance},enumerable:!1,configurable:!0}),e.prototype.getConnector=function(){return this.connector},e}();t.Storage=n},2106:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SegmentOperatorValueEnum=void 0,function(e){e.AND="and",e.NOT="not",e.OR="or",e.CUSTOM_VARIABLE="custom_variable",e.USER="user",e.COUNTRY="country",e.REGION="region",e.CITY="city",e.OPERATING_SYSTEM="os",e.DEVICE_TYPE="device_type",e.DEVICE="device",e.BROWSER_AGENT="browser_string",e.UA="ua",e.FEATURE_ID="featureId"}(n||(t.SegmentOperatorValueEnum=n={}))},2160:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.VariableModel=void 0;var n=function(){function e(e,t,n,r){this.value=r,this.type=t,this.key=n,this.id=e}return e.modelFromDictionary=function(t){var n,r,o;return new e(null!==(n=t.i)&&void 0!==n?n:t.id,t.type,null!==(r=t.k)&&void 0!==r?r:t.key,null!==(o=t.val)&&void 0!==o?o:t.value)},e.prototype.setValue=function(e){this.value=e},e.prototype.setKey=function(e){this.key=e},e.prototype.setType=function(e){this.type=e},e.prototype.getId=function(){return this.id},e.prototype.getValue=function(){return this.value},e.prototype.getType=function(){return this.type},e.prototype.getKey=function(){return this.key},e}();t.VariableModel=n},2209:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.HeadersEnum=void 0,function(e){e.USER_AGENT="X-Device-User-Agent",e.IP="VWO-X-Forwarded-For"}(n||(t.HeadersEnum=n={}))},2258:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RuleModel=void 0;var n=function(){function e(){}return e.prototype.modelFromDictionary=function(e){return this.type=e.type,this.status=e.status,this.variationId=e.variationId,this.campaignId=e.campaignId,this.ruleKey=e.ruleKey,this},e.prototype.getCampaignId=function(){return this.campaignId},e.prototype.getVariationId=function(){return this.variationId},e.prototype.getStatus=function(){return this.status},e.prototype.getType=function(){return this.type},e.prototype.getRuleKey=function(){return this.ruleKey},e}();t.RuleModel=n},2404:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.SegmentationManager=void 0;var a=n(7385),i=n(596),s=n(2478),u=n(6178),c=n(3166),l=n(9600),g=n(7173),p=function(){function e(){}return Object.defineProperty(e,"Instance",{get:function(){return this.instance=this.instance||new e,this.instance},enumerable:!1,configurable:!0}),e.prototype.attachEvaluator=function(e){this.evaluator=e||new a.SegmentEvaluator},e.prototype.setContextualData=function(e,t,n){return r(this,void 0,void 0,(function(){var r,a,p,d;return o(this,(function(o){switch(o.label){case 0:if(this.attachEvaluator(),this.evaluator.settings=e,this.evaluator.context=n,this.evaluator.feature=t,null===(null==n?void 0:n.getUserAgent())&&null===(null==n?void 0:n.getIpAddress()))return[2];if(!0!==t.getIsGatewayServiceRequired())return[3,4];if(!l.SettingsService.Instance.isGatewayServiceProvided||!(0,g.isUndefined)(n.getVwo())&&null!==n.getVwo())return[3,4];r={},(null==n?void 0:n.getUserAgent())&&(r.userAgent=n.getUserAgent()),(null==n?void 0:n.getIpAddress())&&(r.ipAddress=n.getIpAddress()),o.label=1;case 1:return o.trys.push([1,3,,4]),a=(0,i.getQueryParams)(r),[4,(0,i.getFromGatewayService)(a,s.UrlEnum.GET_USER_DATA)];case 2:return p=o.sent(),n.setVwo((new c.ContextVWOModel).modelFromDictionary(p)),this.evaluator.context=n,[3,4];case 3:return d=o.sent(),u.LogManager.Instance.error("Error in setting contextual data for segmentation. Got error: ".concat(d.error)),[3,4];case 4:return[2]}}))}))},e.prototype.validateSegmentation=function(e,t){return r(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,this.evaluator.isSegmentationValid(e,t)];case 1:return[2,n.sent()]}}))}))},e}();t.SegmentationManager=p},2478:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.UrlEnum=void 0,function(e){e.EVENTS="/events/t",e.ATTRIBUTE_CHECK="/check-attribute",e.GET_USER_DATA="/get-user-details",e.BATCH_EVENTS="/server-side/batch-events-v2"}(n||(t.UrlEnum=n={}))},2550:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformEnum=void 0,function(e){e.CLIENT="client",e.SERVER="server"}(n||(t.PlatformEnum=n={}))},2676:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.VWOBuilder=void 0;var o=n(6178),a=n(4464),i=n(4988),s=n(4059),u=n(3860),c=n(9600),l=n(2974),g=n(7173),p=n(8470),d=n(5076),f=n(5576),h=n(7788),v=n(4334),y=n(5946),m=n(6977),E=n(5291),b=function(){function e(e){this.options=e}return e.prototype.setNetworkManager=function(){var e,t,n,r,i=a.NetworkManager.Instance;return i.attachClient(null===(t=null===(e=this.options)||void 0===e?void 0:e.network)||void 0===t?void 0:t.client,null===(n=this.options)||void 0===n?void 0:n.retryConfig),o.LogManager.Instance.debug((0,d.buildMessage)(l.DebugLogMessagesEnum.SERVICE_INITIALIZED,{service:"Network Layer"})),i.getConfig().setDevelopmentMode(null===(r=this.options)||void 0===r?void 0:r.isDevelopmentMode),this},e.prototype.initBatching=function(){var e=this;if(this.options.batchEventData){if(this.settingFileManager.isGatewayServiceProvided)return o.LogManager.Instance.info((0,d.buildMessage)(l.InfoLogMessagesEnum.GATEWAY_AND_BATCH_EVENTS_CONFIG_MISMATCH)),this;if((!(0,g.isNumber)(this.options.batchEventData.eventsPerRequest)||this.options.batchEventData.eventsPerRequest<=0)&&(!(0,g.isNumber)(this.options.batchEventData.requestTimeInterval)||this.options.batchEventData.requestTimeInterval<=0))return o.LogManager.Instance.error("Invalid batch events config, should be an object, eventsPerRequest should be a number greater than 0 and requestTimeInterval should be a number greater than 0"),this;this.batchEventsQueue=new y.BatchEventsQueue(Object.assign({},this.options.batchEventData,{dispatcher:function(t,n){return m.BatchEventsDispatcher.dispatch({ev:t},n,Object.assign({},{a:e.options.accountId,env:e.options.sdkKey}))}})),this.batchEventsQueue.flushAndClearTimer.bind(this.batchEventsQueue)}return this},e.prototype.setSegmentation=function(){var e;return i.SegmentationManager.Instance.attachEvaluator(null===(e=this.options)||void 0===e?void 0:e.segmentation),o.LogManager.Instance.debug((0,d.buildMessage)(l.DebugLogMessagesEnum.SERVICE_INITIALIZED,{service:"Segmentation Evaluator"})),this},e.prototype.fetchSettings=function(e){var t=this,n=new f.Deferred;return this.isSettingsFetchInProgress?this.fetchSettings(e):(this.isSettingsFetchInProgress=!0,this.settingFileManager.getSettings(e).then((function(r){e||(t.originalSettings=r),t.isSettingsFetchInProgress=!1,n.resolve(r)})),n.promise)},e.prototype.getSettings=function(e){var t=new f.Deferred;try{!e&&this.settings?(o.LogManager.Instance.info("Using already fetched and cached settings"),t.resolve(this.settings)):this.fetchSettings(e).then((function(e){t.resolve(e)}))}catch(e){o.LogManager.Instance.error("Failed to fetch settings. Error: "+e),t.resolve({})}return t.promise},e.prototype.setStorage=function(){var e,t,a,i;if(this.options.storage)this.storage=s.Storage.Instance.attachConnector(this.options.storage);else if(void 0===process.env&&"undefined"!=typeof window&&window.localStorage){var u=n(1007).BrowserStorageConnector;this.storage=s.Storage.Instance.attachConnector(new u(r(r({},this.options.clientStorage),{alwaysUseCachedSettings:null===(e=this.options.clientStorage)||void 0===e?void 0:e.alwaysUseCachedSettings,ttl:null===(t=this.options.clientStorage)||void 0===t?void 0:t.ttl}))),o.LogManager.Instance.debug((0,d.buildMessage)(l.DebugLogMessagesEnum.SERVICE_INITIALIZED,{service:(null===(i=null===(a=this.options)||void 0===a?void 0:a.clientStorage)||void 0===i?void 0:i.provider)===sessionStorage?"Session Storage":"Local Storage"}))}else this.storage=null;return this},e.prototype.setSettingsService=function(){return this.settingFileManager=new c.SettingsService(this.options),this},e.prototype.setLogger=function(){return this.logManager=new o.LogManager(this.options.logger||{}),o.LogManager.Instance.debug((0,d.buildMessage)(l.DebugLogMessagesEnum.SERVICE_INITIALIZED,{service:"Logger"})),this},e.prototype.getRandomUserId=function(){var e="getRandomUserId";try{return o.LogManager.Instance.debug((0,d.buildMessage)(l.DebugLogMessagesEnum.API_CALLED,{apiName:e})),(0,v.getRandomUUID)(this.options.sdkKey)}catch(t){o.LogManager.Instance.error((0,d.buildMessage)(l.ErrorLogMessagesEnum.API_THROW_ERROR,{apiName:e,err:t}))}},e.prototype.initPolling=function(){return this.options.pollInterval?this.options.pollInterval&&!(0,g.isNumber)(this.options.pollInterval)||this.options.pollInterval&&this.options.pollInterval<1e3?(o.LogManager.Instance.error((0,d.buildMessage)(l.ErrorLogMessagesEnum.INIT_OPTIONS_INVALID,{key:"pollInterval",correctType:"number"})),this):(this.checkAndPoll(),this):this},e.prototype.initUsageStats=function(){return this.options.isUsageStatsDisabled||E.UsageStatsUtil.getInstance().setUsageStats(this.options),this},e.prototype.build=function(e){return this.vwoInstance=new u.VWOClient(e,this.options),this.vwoInstance},e.prototype.checkAndPoll=function(){var e=this,t=this.options.pollInterval;setInterval((function(){e.getSettings(!0).then((function(t){var n=JSON.stringify(e.originalSettings);if(JSON.stringify(t)!==n){e.originalSettings=t;var r=(0,p.cloneObject)(t);o.LogManager.Instance.info(l.InfoLogMessagesEnum.POLLING_SET_SETTINGS),(0,h.setSettingsAndAddCampaignsToRules)(r,e.vwoInstance)}else o.LogManager.Instance.info(l.InfoLogMessagesEnum.POLLING_NO_CHANGE_IN_SETTINGS)})).catch((function(){o.LogManager.Instance.error(l.ErrorLogMessagesEnum.POLLING_FETCH_SETTINGS_FAILED)}))}),t)},e}();t.VWOBuilder=b},2974:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorLogMessagesEnum=t.InfoLogMessagesEnum=t.DebugLogMessagesEnum=void 0;var r=n(6826),o=r.debugMessages;t.DebugLogMessagesEnum=o;var a=r.infoMessages;t.InfoLogMessagesEnum=a;var i=r.errorMessages;t.ErrorLogMessagesEnum=i},3090:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.FlagApi=t.Flag=void 0;var i=n(834),s=n(6167),u=n(6947),c=n(2974),l=n(8198),g=n(2160),p=n(1463),d=n(6178),f=n(4988),h=n(1566),v=n(5479),y=n(7173),m=n(9455),E=n(8470),b=n(9284),I=n(5076),S=n(5576),T=n(689),_=n(1943),O=function(){function e(e,t){this.enabled=e,this.variation=t}return e.prototype.isEnabled=function(){return this.enabled},e.prototype.getVariables=function(){var e;return(null===(e=this.variation)||void 0===e?void 0:e.getVariables())||[]},e.prototype.getVariable=function(e,t){var n,r,o=null===(r=null===(n=this.variation)||void 0===n?void 0:n.getVariables().find((function(t){return g.VariableModel.modelFromDictionary(t).getKey()===e})))||void 0===r?void 0:r.getValue();return void 0!==o?o:t},e}();t.Flag=O;var M=function(){function e(){}return e.get=function(e,t,n,g){return o(this,void 0,void 0,(function(){var o,M,R,L,A,C,N,V,P,D,k,U,j,x,G,F,K,H,B,W,q,Q,Y,X,J,Z,z,$,ee,te,ne,re,oe,ae;return a(this,(function(a){switch(a.label){case 0:return o=!1,M=null,R=null,L=!1,A={},C=new S.Deferred,N=new Map,V=(0,E.getFeatureFromKey)(t,e),P={featureName:null==V?void 0:V.getName(),featureId:null==V?void 0:V.getId(),featureKey:null==V?void 0:V.getKey(),userId:null==n?void 0:n.getId(),api:s.ApiEnum.GET_FLAG},D=new h.StorageService,[4,(new i.StorageDecorator).getFeatureFromStorage(e,n,D)];case 1:if(null==(k=a.sent())?void 0:k.experimentVariationId){if(k.experimentKey&&(te=(0,v.getVariationFromCampaignKey)(t,k.experimentKey,k.experimentVariationId)))return d.LogManager.Instance.info((0,I.buildMessage)(c.InfoLogMessagesEnum.STORED_VARIATION_FOUND,{variationKey:te.getKey(),userId:n.getId(),experimentType:"experiment",experimentKey:k.experimentKey})),C.resolve(new O(!0,te)),[2,C.promise]}else(null==k?void 0:k.rolloutKey)&&(null==k?void 0:k.rolloutId)&&(te=(0,v.getVariationFromCampaignKey)(t,k.rolloutKey,k.rolloutVariationId))&&(d.LogManager.Instance.info((0,I.buildMessage)(c.InfoLogMessagesEnum.STORED_VARIATION_FOUND,{variationKey:te.getKey(),userId:n.getId(),experimentType:"rollout",experimentKey:k.rolloutKey})),d.LogManager.Instance.debug((0,I.buildMessage)(c.DebugLogMessagesEnum.EXPERIMENTS_EVALUATION_WHEN_ROLLOUT_PASSED,{userId:n.getId()})),o=!0,L=!0,M=te,U={rollout