1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[58521],{83060:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r(41400),i=function(){function e(){this.errorCount=0}return e.prototype.getDelay=function(){return 0===this.errorCount?0:1e3*n.BACKOFF_BASE_WAIT_SECONDS_BY_ERROR_COUNT[Math.min(n.BACKOFF_BASE_WAIT_SECONDS_BY_ERROR_COUNT.length-1,this.errorCount)]+Math.round(1e3*Math.random())},e.prototype.countError=function(){this.errorCount<n.BACKOFF_BASE_WAIT_SECONDS_BY_ERROR_COUNT.length-1&&this.errorCount++},e.prototype.reset=function(){this.errorCount=0},e}();t.default=i},59818:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var a=r(78854),s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.makeGetRequest=function(e,t){return a.makeGetRequest(e,t)},t.prototype.getConfigDefaults=function(){return{autoUpdate:!1}},t}(o(r(11647)).default);t.default=s},78854:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r(41400),i=r(1359).getLogger("DatafileManager");t.makeGetRequest=function(e,t){var r=new XMLHttpRequest;return{responsePromise:new Promise(function(o,a){r.open("GET",e,!0),function(e,t){Object.keys(e).forEach(function(r){var n=e[r];t.setRequestHeader(r,n)})}(t,r),r.onreadystatechange=function(){if(4===r.readyState){if(0===r.status){a(Error("Request error"));return}var e=function(e){var t=e.getAllResponseHeaders();if(null===t)return{};var r=t.split("\r\n"),n={};return r.forEach(function(e){var t=e.indexOf(": ");if(t>-1){var r=e.slice(0,t),i=e.slice(t+2);i.length>0&&(n[r]=i)}}),n}(r);o({statusCode:r.status,body:r.responseText,headers:e})}},r.timeout=n.REQUEST_TIMEOUT_MS,r.ontimeout=function(){i.error("Request timed out")},r.send()}),abort:function(){r.abort()}}}},41400:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_UPDATE_INTERVAL=3e5,t.MIN_UPDATE_INTERVAL=1e3,t.DEFAULT_URL_TEMPLATE="https://cdn.optimizely.com/datafiles/%s.json",t.DEFAULT_AUTHENTICATED_URL_TEMPLATE="https://config.optimizely.com/datafiles/auth/%s.json",t.BACKOFF_BASE_WAIT_SECONDS_BY_ERROR_COUNT=[0,8,16,32,64,128,256,512],t.REQUEST_TIMEOUT_MS=6e4},80113:function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this.listeners={},this.listenerId=1}return e.prototype.on=function(e,t){var r=this;this.listeners[e]||(this.listeners[e]={});var n=String(this.listenerId);return this.listenerId++,this.listeners[e][n]=t,function(){r.listeners[e]&&delete r.listeners[e][n]}},e.prototype.emit=function(e,t){var r=this.listeners[e];r&&Object.keys(r).forEach(function(e){(0,r[e])(t)})},e.prototype.removeAllListeners=function(){this.listeners={}},e}();t.default=r},11647:function(e,t,r){var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(1359),a=r(84426),s=i(r(80113)),u=r(41400),l=i(r(83060)),c=o.getLogger("DatafileManager");function E(e){return e>=200&&e<400}var f={get:function(){return Promise.resolve("")},set:function(){return Promise.resolve()},contains:function(){return Promise.resolve(!1)},remove:function(){return Promise.resolve()}},d=function(){function e(e){var t=this,r=n(n({},this.getConfigDefaults()),e),i=r.datafile,o=r.autoUpdate,E=r.sdkKey,d=r.updateInterval,p=void 0===d?u.DEFAULT_UPDATE_INTERVAL:d,g=r.urlTemplate,I=void 0===g?u.DEFAULT_URL_TEMPLATE:g,_=r.cache;(this.cache=void 0===_?f:_,this.cacheKey="opt-datafile-"+E,this.isReadyPromiseSettled=!1,this.readyPromiseResolver=function(){},this.readyPromiseRejecter=function(){},this.readyPromise=new Promise(function(e,r){t.readyPromiseResolver=e,t.readyPromiseRejecter=r}),i?(this.currentDatafile=i,E||this.resolveReadyPromise()):this.currentDatafile="",this.isStarted=!1,this.datafileUrl=a.sprintf(I,E),this.emitter=new s.default,this.autoUpdate=void 0!==o&&o,p>=u.MIN_UPDATE_INTERVAL)?this.updateInterval=p:(c.warn("Invalid updateInterval %s, defaulting to %s",p,u.DEFAULT_UPDATE_INTERVAL),this.updateInterval=u.DEFAULT_UPDATE_INTERVAL),this.currentTimeout=null,this.currentRequest=null,this.backoffController=new l.default,this.syncOnCurrentRequestComplete=!1}return e.prototype.get=function(){return this.currentDatafile},e.prototype.start=function(){this.isStarted||(c.debug("Datafile manager started"),this.isStarted=!0,this.backoffController.reset(),this.setDatafileFromCacheIfAvailable(),this.syncDatafile())},e.prototype.stop=function(){return c.debug("Datafile manager stopped"),this.isStarted=!1,this.currentTimeout&&(clearTimeout(this.currentTimeout),this.currentTimeout=null),this.emitter.removeAllListeners(),this.currentRequest&&(this.currentRequest.abort(),this.currentRequest=null),Promise.resolve()},e.prototype.onReady=function(){return this.readyPromise},e.prototype.on=function(e,t){return this.emitter.on(e,t)},e.prototype.onRequestRejected=function(e){this.isStarted&&(this.backoffController.countError(),e instanceof Error?c.error("Error fetching datafile: %s",e.message,e):"string"==typeof e?c.error("Error fetching datafile: %s",e):c.error("Error fetching datafile"))},e.prototype.onRequestResolved=function(e){if(this.isStarted){void 0!==e.statusCode&&E(e.statusCode)?this.backoffController.reset():this.backoffController.countError(),this.trySavingLastModified(e.headers);var t=this.getNextDatafileFromResponse(e);""!==t&&(c.info("Updating datafile from response"),this.currentDatafile=t,this.cache.set(this.cacheKey,t),this.isReadyPromiseSettled?this.emitter.emit("update",{datafile:t}):this.resolveReadyPromise())}},e.prototype.onRequestComplete=function(){this.isStarted&&(this.currentRequest=null,this.isReadyPromiseSettled||this.autoUpdate||this.rejectReadyPromise(Error("Failed to become ready")),this.autoUpdate&&this.syncOnCurrentRequestComplete&&this.syncDatafile(),this.syncOnCurrentRequestComplete=!1)},e.prototype.syncDatafile=function(){var e=this,t={};this.lastResponseLastModified&&(t["if-modified-since"]=this.lastResponseLastModified),c.debug("Making datafile request to url %s with headers: %s",this.datafileUrl,function(){return JSON.stringify(t)}
1),this.currentRequest=this.makeGetRequest(this.datafileUrl,t);var r=function(){e.onRequestComplete()};this.currentRequest.responsePromise.then(function(t){e.onRequestResolved(t)},function(t){e.onRequestRejected(t)}).then(r,r),this.autoUpdate&&this.scheduleNextUpdate()},e.prototype.resolveReadyPromise=function(){this.readyPromiseResolver(),this.isReadyPromiseSettled=!0},e.prototype.rejectReadyPromise=function(e){this.readyPromiseRejecter(e),this.isReadyPromiseSettled=!0},e.prototype.scheduleNextUpdate=function(){var e=this,t=Math.max(this.backoffController.getDelay(),this.updateInterval);c.debug("Scheduling sync in %s ms",t),this.currentTimeout=setTimeout(function(){e.currentRequest?e.syncOnCurrentRequestComplete=!0:e.syncDatafile()},t)},e.prototype.getNextDatafileFromResponse=function(e){return(c.debug("Response status code: %s",e.statusCode),void 0===e.statusCode||304===e.statusCode)?"":E(e.statusCode)?e.body:""},e.prototype.trySavingLastModified=function(e){var t=e["last-modified"]||e["Last-Modified"];void 0!==t&&(this.lastResponseLastModified=t,c.debug("Saved last modified header value from response: %s",this.lastResponseLastModified))},e.prototype.setDatafileFromCacheIfAvailable=function(){var e=this;this.cache.get(this.cacheKey).then(function(t){e.isStarted&&!e.isReadyPromiseSettled&&""!==t&&(c.debug("Using datafile from cache"),e.currentDatafile=t,e.resolveReadyPromise())})},e}();t.default=d},34148:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r(59818);t.HttpPollingDatafileManager=n.default},63456:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},74661:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.sendEventNotification=t.getQueue=t.validateAndGetBatchSize=t.validateAndGetFlushInterval=t.DEFAULT_BATCH_SIZE=t.DEFAULT_FLUSH_INTERVAL=void 0;var n=r(83349),i=r(1359),o=r(84426);t.DEFAULT_FLUSH_INTERVAL=3e4,t.DEFAULT_BATCH_SIZE=10;var a=i.getLogger("EventProcessor");t.validateAndGetFlushInterval=function(e){return e<=0&&(a.warn("Invalid flushInterval "+e+", defaulting to "+t.DEFAULT_FLUSH_INTERVAL),e=t.DEFAULT_FLUSH_INTERVAL),e},t.validateAndGetBatchSize=function(e){return(e=Math.floor(e))<1&&(a.warn("Invalid batchSize "+e+", defaulting to "+t.DEFAULT_BATCH_SIZE),e=t.DEFAULT_BATCH_SIZE),e=Math.max(1,e)},t.getQueue=function(e,t,r,i,o){return e>1?new n.DefaultEventQueue({flushInterval:t,maxQueueSize:e,batchComparator:r,sink:i,closingSink:o}):new n.SingleEventQueue({sink:i})},t.sendEventNotification=function(e,t){e&&e.sendNotifications(o.NOTIFICATION_TYPES.LOG_EVENT,t)}},83349:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultEventQueue=t.SingleEventQueue=void 0;var n=r(1359).getLogger("EventProcessor"),i=function(){function e(e){var t=e.timeout,r=e.callback;this.timeout=Math.max(t,0),this.callback=r}return e.prototype.start=function(){this.timeoutId=setTimeout(this.callback,this.timeout)},e.prototype.refresh=function(){this.stop(),this.start()},e.prototype.stop=function(){this.timeoutId&&clearTimeout(this.timeoutId)},e}(),o=function(){function e(e){var t=e.sink;this.sink=t}return e.prototype.start=function(){},e.prototype.stop=function(){return Promise.resolve()},e.prototype.enqueue=function(e){this.sink([e])},e}();t.SingleEventQueue=o;var a=function(){function e(e){var t=e.flushInterval,r=e.maxQueueSize,n=e.sink,o=e.closingSink,a=e.batchComparator;this.buffer=[],this.maxQueueSize=Math.max(r,1),this.sink=n,this.closingSink=o,this.batchComparator=a,this.timer=new i({callback:this.flush.bind(this),timeout:t}),this.started=!1}return e.prototype.start=function(){this.started=!0},e.prototype.stop=function(){this.started=!1;var e=this.closingSink?this.closingSink(this.buffer):this.sink(this.buffer);return this.buffer=[],this.timer.stop(),e},e.prototype.enqueue=function(e){if(!this.started){n.warn("Queue is stopped, not accepting event");return}var t=this.buffer[0];t&&!this.batchComparator(t,e)&&this.flush(),0===this.buffer.length&&this.timer.refresh(),this.buffer.push(e),this.buffer.length>=this.maxQueueSize&&this.flush()},e.prototype.flush=function(){this.sink(this.buffer),this.buffer=[],this.timer.stop()},e}();t.DefaultEventQueue=a}
1,2736:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.areEventContextsEqual=void 0,t.areEventContextsEqual=function(e,t){var r=e.context,n=t.context;return r.accountId===n.accountId&&r.projectId===n.projectId&&r.clientName===n.clientName&&r.clientVersion===n.clientVersion&&r.revision===n.revision&&r.anonymizeIP===n.anonymizeIP&&r.botFiltering===n.botFiltering}},4549:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(2736),t),i(r(74661),t),i(r(63456),t),i(r(71165),t),i(r(71816),t),i(r(86405),t),i(r(1588),t)},71165:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},71816:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.LocalStoragePendingEventsDispatcher=t.PendingEventsDispatcher=void 0;var o=r(1359),a=r(19259),s=r(84426),u=o.getLogger("EventProcessor"),l=function(){function e(e){var t=e.eventDispatcher,r=e.store;this.dispatcher=t,this.store=r}return e.prototype.dispatchEvent=function(e,t){this.send({uuid:s.generateUUID(),timestamp:s.getTimestamp(),request:e},t)},e.prototype.sendPendingEvents=function(){var e=this,t=this.store.values();u.debug("Sending %s pending events from previous page",t.length),t.forEach(function(t){try{e.send(t,function(){})}catch(e){}})},e.prototype.send=function(e,t){var r=this;this.store.set(e.uuid,e),this.dispatcher.dispatchEvent(e.request,function(n){r.store.remove(e.uuid),t(n)})},e}();t.PendingEventsDispatcher=l;var c=function(e){function t(t){var r=t.eventDispatcher;return e.call(this,{eventDispatcher:r,store:new a.LocalStorageStore({maxValues:100,key:"fs_optly_pending_events"})})||this}return i(t,e),t}(l);t.LocalStoragePendingEventsDispatcher=c},19259:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.LocalStorageStore=void 0;var n=r(84426),i=r(1359).getLogger("EventProcessor"),o=function(){function e(e){var t=e.key,r=e.maxValues;this.LS_KEY=t,this.maxValues=void 0===r?1e3:r}return e.prototype.get=function(e){return this.getMap()[e]||null},e.prototype.set=function(e,t){var r=this.getMap();r[e]=t,this.replace(r)},e.prototype.remove=function(e){var t=this.getMap();delete t[e],this.replace(t)},e.prototype.values=function(){return n.objectValues(this.getMap())},e.prototype.clear=function(){this.replace({})},e.prototype.replace=function(e){try{window.localStorage&&localStorage.setItem(this.LS_KEY,JSON.stringify(e)),this.clean()}catch(e){i.error(e)}},e.prototype.clean=function(){var e=this.getMap(),t=Object.keys(e),r=t.length-this.maxValues;if(!(r<1)){var n=t.map(function(t){return{key:t,value:e[t]}});n.sort(function(e,t){return e.value.timestamp-t.value.timestamp});for(var i=0;i<r;i++)delete e[n[i].key];this.replace(e)}},e.prototype.getMap=function(){try{var e=window.localStorage&&localStorage.getItem(this.LS_KEY);if(e)return JSON.parse(e)||{}}catch(e){i.error(e)}return{}},e}();t.LocalStorageStore=o},44116:function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this.reqsInFlightCount=0,this.reqsCompleteResolvers=[]}return e.prototype.trackRequest=function(e){var t=this;this.reqsInFlightCount++;var r=function(){t.reqsInFlightCount--,0===t.reqsInFlightCount&&(t.reqsCompleteResolvers.forEach(function(e){return e()}),t.reqsCompleteResolvers=[])};e.then(r,r)},e.prototype.onRequestsComplete=function(){var e=this;return new Promise(function(t){0===e.reqsInFlightCount?t():e.reqsCompleteResolvers.push(t)})},e}();t.default=r},86405:function(e,t){var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};
1Object.defineProperty(t,"__esModule",{value:!0}),t.formatEvents=t.buildConversionEventV1=t.buildImpressionEventV1=t.makeBatchedEventV1=void 0;var n="$opt_bot_filtering";function i(e){var t=[],r=e[0];return e.forEach(function(e){if("conversion"===e.type||"impression"===e.type){var r=s(e);"impression"===e.type?r.snapshots.push(a(e)):"conversion"===e.type&&r.snapshots.push(o(e)),t.push(r)}}),{client_name:r.context.clientName,client_version:r.context.clientVersion,account_id:r.context.accountId,project_id:r.context.projectId,revision:r.context.revision,anonymize_ip:r.context.anonymizeIP,enrich_decisions:!0,visitors:t}}function o(e){var t=r({},e.tags);delete t.revenue,delete t.value;var n={entity_id:e.event.id,key:e.event.key,timestamp:e.timestamp,uuid:e.uuid};return e.tags&&(n.tags=e.tags),null!=e.value&&(n.value=e.value),null!=e.revenue&&(n.revenue=e.revenue),{events:[n]}}function a(e){var t,r,n=e.layer,i=e.experiment,o=e.variation,a=e.ruleKey,s=e.flagKey,u=e.ruleType,l=e.enabled,c=n?n.id:null;return{decisions:[{campaign_id:c,experiment_id:null!==(t=null==i?void 0:i.id)&&void 0!==t?t:"",variation_id:null!==(r=null==o?void 0:o.id)&&void 0!==r?r:"",metadata:{flag_key:s,rule_key:a,rule_type:u,variation_key:o?o.key:"",enabled:l}}],events:[{entity_id:c,timestamp:e.timestamp,key:"campaign_activated",uuid:e.uuid}]}}function s(e){var t={snapshots:[],visitor_id:e.user.id,attributes:[]};return e.user.attributes.forEach(function(e){t.attributes.push({entity_id:e.entityId,key:e.key,type:"custom",value:e.value})}),"boolean"==typeof e.context.botFiltering&&t.attributes.push({entity_id:n,key:n,type:"custom",value:e.context.botFiltering}),t}t.makeBatchedEventV1=i,t.buildImpressionEventV1=function(e){var t=s(e);return t.snapshots.push(a(e)),{client_name:e.context.clientName,client_version:e.context.clientVersion,account_id:e.context.accountId,project_id:e.context.projectId,revision:e.context.revision,anonymize_ip:e.context.anonymizeIP,enrich_decisions:!0,visitors:[t]}},t.buildConversionEventV1=function(e){var t=s(e);return t.snapshots.push(o(e)),{client_name:e.context.clientName,client_version:e.context.clientVersion,account_id:e.context.accountId,project_id:e.context.projectId,revision:e.context.revision,anonymize_ip:e.context.anonymizeIP,enrich_decisions:!0,visitors:[t]}},t.formatEvents=function(e){return{url:"https://logx.optimizely.com/v1/events",httpVerb:"POST",params:i(e)}}},1588:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(a,s)}u((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogTierV1EventProcessor=void 0;var a=r(1359),s=r(74661),u=o(r(44116)),l=r(2736),c=r(86405),E=a.getLogger("LogTierV1EventProcessor"),f=function(){function e(e){var t=e.dis
1patcher,r=e.closingDispatcher,n=e.flushInterval,i=void 0===n?s.DEFAULT_FLUSH_INTERVAL:n,o=e.batchSize,a=void 0===o?s.DEFAULT_BATCH_SIZE:o,c=e.notificationCenter;this.dispatcher=t,this.closingDispatcher=r,this.notificationCenter=c,this.requestTracker=new u.default,i=s.validateAndGetFlushInterval(i),a=s.validateAndGetBatchSize(a),this.queue=s.getQueue(a,i,l.areEventContextsEqual,this.drainQueue.bind(this,!1),this.drainQueue.bind(this,!0))}return e.prototype.drainQueue=function(e,t){var r=this,n=new Promise(function(n){if(E.debug("draining queue with %s events",t.length),0===t.length){n();return}var i=c.formatEvents(t);(e&&r.closingDispatcher?r.closingDispatcher:r.dispatcher).dispatchEvent(i,function(){n()}),s.sendEventNotification(r.notificationCenter,i)});return this.requestTracker.trackRequest(n),n},e.prototype.process=function(e){this.queue.enqueue(e)},e.prototype.stop=function(){try{return this.queue.stop(),this.requestTracker.onRequestsComplete()}catch(e){E.error('Error stopping EventProcessor: "%s"',e.message,e)}return Promise.resolve()},e.prototype.start=function(){return n(this,void 0,void 0,function(){return i(this,function(e){return this.queue.start(),[2]})})},e}();t.LogTierV1EventProcessor=f},93074:function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){}return e.prototype.handleError=function(e){},e}();t.NoopErrorHandler=r;var n=new r;t.setErrorHandler=function(e){n=e},t.getErrorHandler=function(){return n},t.resetErrorHandler=function(){n=new r}},1359:function(e,t,r){function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(93074)),n(r(45750)),n(r(1315))},1315:function(e,t,r){var n=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),i=0,t=0;t<r;t++)for(var o=arguments[t],a=0,s=o.length;a<s;a++,i++)n[i]=o[a];return n};Object.defineProperty(t,"__esModule",{value:!0});var i=r(93074),o=r(84426),a=r(45750),s={NOTSET:0,DEBUG:1,INFO:2,WARNING:3,ERROR:4};function u(e){return"string"!=typeof e?e:("WARN"===(e=e.toUpperCase())&&(e="WARNING"),s[e])?s[e]:e}var l=function(){function e(){this.defaultLoggerFacade=new d,this.loggers={}}return e.prototype.getLogger=function(e){return e?(this.loggers[e]||(this.loggers[e]=new d({messagePrefix:e})),this.loggers[e]):this.defaultLoggerFacade},e}(),c=function(){function e(e){void 0===e&&(e={}),this.logLevel=a.LogLevel.NOTSET,void 0!==e.logLevel&&o.isValidEnum(a.LogLevel,e.logLevel)&&this.setLogLevel(e.logLevel),this.logToConsole=void 0===e.logToConsole||!!e.logToConsole,this.prefix=void 0!==e.prefix?e.prefix:"[OPTIMIZELY]"}return e.prototype.log=function(e,t){if(this.shouldLog(e)&&this.logToConsole){var r=this.prefix+" - "+this.getLogLevelName(e)+" "+this.getTime()+" "+t;this.consoleLog(e,[r])}},e.prototype.setLogLevel=function(e){e=u(e),o.isValidEnum(a.LogLevel,e)&&void 0!==e?this.logLevel=e:this.logLevel=a.LogLevel.ERROR},e.prototype.getTime=function(){return new Date().toISOString()},e.prototype.shouldLog=function(e){return e>=this.logLevel},e.prototype.getLogLevelName=function(e){switch(e){case a.LogLevel.DEBUG:return"DEBUG";case a.LogLevel.INFO:return"INFO ";case a.LogLevel.WARNING:return"WARN ";case a.LogLevel.ERROR:return"ERROR";default:return"NOTSET"}},e.prototype.consoleLog=function(e,t){switch(e){case a.LogLevel.DEBUG:console.log.apply(console,t);break;case a.LogLevel.INFO:console.info.apply(console,t);break;case a.LogLevel.WARNING:console.warn.apply(console,t);break;case a.LogLevel.ERROR:console.error.apply(console,t);break;default:console.log.apply(console,t)}},e}();t.ConsoleLogHandler=c;var E=a.LogLevel.NOTSET,f=null,d=function(){function e(e){void 0===e&&(e={}),this.messagePrefix="",e.messagePrefix&&(this.messagePrefix=e.messagePrefix)}return e.prototype.log=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];this.internalLog(u(e),{message:t,splat:r})},e.prototype.info=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.namedLog(a.LogLevel.INFO,e,t)},e.prototype.debug=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.namedLog(a.LogLevel.DEBUG,e,t)},e.prototype.warn=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.namedLog(a.LogLevel.WARNING,e,t)},e.prototype.error=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.namedLog(a.LogLevel.ERROR,e,t)},e.prototype.format=function(e){return(this.messagePrefix?this.messagePrefix+": ":"")+o.sprintf.apply(void 0,n([e.message],e.splat))},e.prototype.internalLog=function(e,t){f&&!(e<E)&&(f.log(e,this.format(t)),t.error&&t.error instanceof Error&&i.getErrorHandler().handleError(t.error))},e.prototype.namedLog=function(e,t,r){if(t instanceof Error){t=(n=t).message,this.internalLog(e,{error:n,message:t,splat:r});return}if(0===r.length){this.internalLog(e,{message:t,splat:r});return}var n,i=r[r.length-1];i instanceof Error&&(n=i,r.splice(-1)),this.internalLog(e,{message:t,error:n,splat:r})},e}(),p=new l;t.getLogger=function(e){return p.getLogger(e)},t.setLogHandler=function(e){f=e},t.setLogLevel=function(e){e=u(e),E=o.isValidEnum(a.LogLevel,e)&&void 0!==e?e:a.LogLevel.ERROR},t.getLogLevel=function(){return E},t.resetLogger=function(){p=new l,E=a.LogLevel.NOTSET}},45750:function(e,t){var r;
1Object.defineProperty(t,"__esModule",{value:!0}),(r=t.LogLevel||(t.LogLevel={}))[r.NOTSET=0]="NOTSET",r[r.DEBUG=1]="DEBUG",r[r.INFO=2]="INFO",r[r.WARNING=3]="WARNING",r[r.ERROR=4]="ERROR"},84426:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n,i=r(41925);function o(e){return Object.keys(e).map(function(t){return e[t]})}t.generateUUID=function(){return i.v4()},t.getTimestamp=function(){return new Date().getTime()},t.isValidEnum=function(e,t){for(var r=!1,n=Object.keys(e),i=0;i<n.length;i++)if(t===e[n[i]]){r=!0;break}return r},t.groupBy=function(e,t){var r={};return e.forEach(function(e){var n=t(e);r[n]=r[n]||[],r[n].push(e)}),o(r)},t.objectValues=o,t.objectEntries=function(e){return Object.keys(e).map(function(t){return[t,e[t]]})},t.find=function(e,t){for(var r,n=0;n<e.length;n++){var i=e[n];if(t(i)){r=i;break}}return r},t.keyBy=function(e,t){var r={};return e.forEach(function(e){r[t(e)]=e}),r},t.sprintf=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=0;return e.replace(/%s/g,function(){var e=t[n++],r=typeof e;return"function"===r?e():"string"===r?e:String(e)})},(n=t.NOTIFICATION_TYPES||(t.NOTIFICATION_TYPES={})).ACTIVATE="ACTIVATE:experiment, user_id,attributes, variation, event",n.DECISION="DECISION:type, userId, attributes, decisionInfo",n.LOG_EVENT="LOG_EVENT:logEvent",n.OPTIMIZELY_CONFIG_UPDATE="OPTIMIZELY_CONFIG_UPDATE",n.TRACK="TRACK:event_key, user_id, attributes, event_tags, event"},44799:function(e,t,r){function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var i,o,a,s,u=r(1359),l=r(4549),c=n(r(41925)),E=n(r(17751)),f=r(34148),d=function(){return(d=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function p(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),i=0;for(t=0;t<r;t++)for(var o=arguments[t],a=0,s=o.length;a<s;a++,i++)n[i]=o[a];return n}function g(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(!e)return{};if("function"==typeof Object.assign)return Object.assign.apply(Object,p([e],t));for(var n=Object(e),i=0;i<t.length;i++){var o=t[i];if(null!=o)for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(n[a]=o[a])}return n}function I(e,t){var r,n,i;return e?(r=e,n=function(e){return e[t]},i={},r.forEach(function(e){i[n(e)]=e}),i):{}}function _(e){return Object.keys(e).map(function(t){return e[t]})}function h(e,t){for(var r,n=0;n<e.length;n++){var i=e[n];if(t(i)){r=i;break}}return r}function v(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=0;return e.replace(/%s/g,function(){var e=t[n++],r=typeof e;return"function"===r?e():"string"===r?e:String(e)})}var R,O={assign:g,currentTimestamp:function(){return Math.round((new Date).getTime())},isSafeInteger:function(e){return"number"==typeof e&&9007199254740992>=Math.abs(e)},uuid:function(){return c.v4()},isNumber:function(e){return"number"==typeof e}},N={NOTSET:0,DEBUG:1,INFO:2,WARNING:3,ERROR:4},T={CONDITION_EVALUATOR_ERROR:"%s: Error evaluating audience condition of type %s: %s",DATAFILE_AND_SDK_KEY_MISSING:"%s: You must provide at least one of sdkKey or datafile. Cannot start Optimizely",EXPERIMENT_KEY_NOT_IN_DATAFILE:"%s: Experiment key %s is not in datafile.",FEATURE_NOT_IN_DATAFILE:"%s: Feature key %s is not in datafile.",IMPROPERLY_FORMATTED_EXPERIMENT:"%s: Experiment key %s is improperly formatted.",INVALID_ATTRIBUTES:"%s: Provided attributes are in an invalid format.",INVALID_BUCKETING_ID:"%s: Unable to generate hash for bucketing ID %s: %s",INVALID_DATAFILE:"%s: Datafile is invalid - property %s: %s",INVALID_DATAFILE_MALFORMED:"%s: Datafile is invalid because it is malformed.",INVALID_CONFIG:"%s: Provided Optimizely config is in an invalid format.",INVALID_JSON:"%s: JSON object is not valid.",INVALID_ERROR_HANDLER:'%s: Provided "errorHandler" is in an invalid format.',INVALID_EVENT_DISPATCHER:'%s: Provided "eventDispatcher" is in an invalid format.',INVALID_EVENT_TAGS:"%s: Provided event tags are in an invali
1d format.",INVALID_EXPERIMENT_KEY:"%s: Experiment key %s is not in datafile. It is either invalid, paused, or archived.",INVALID_EXPERIMENT_ID:"%s: Experiment ID %s is not in datafile.",INVALID_GROUP_ID:"%s: Group ID %s is not in datafile.",INVALID_LOGGER:'%s: Provided "logger" is in an invalid format.',INVALID_ROLLOUT_ID:"%s: Invalid rollout ID %s attached to feature %s",INVALID_USER_ID:"%s: Provided user ID is in an invalid format.",INVALID_USER_PROFILE_SERVICE:"%s: Provided user profile service instance is in an invalid format: %s.",NO_DATAFILE_SPECIFIED:"%s: No datafile specified. Cannot start optimizely.",NO_JSON_PROVIDED:"%s: No JSON object to validate against schema.",NO_VARIATION_FOR_EXPERIMENT_KEY:"%s: No variation key %s defined in datafile for experiment %s.",UNDEFINED_ATTRIBUTE:"%s: Provided attribute: %s has an undefined value.",UNRECOGNIZED_ATTRIBUTE:"%s: Unrecognized attribute %s provided. Pruning before sending event to Optimizely.",UNABLE_TO_CAST_VALUE:"%s: Unable to cast value %s to type %s, returning null.",USER_NOT_IN_FORCED_VARIATION:"%s: User %s is not in the forced variation map. Cannot remove their forced variation.",USER_PROFILE_LOOKUP_ERROR:'%s: Error while looking up user profile for user ID "%s": %s.',USER_PROFILE_SAVE_ERROR:'%s: Error while saving user profile for user ID "%s": %s.',VARIABLE_KEY_NOT_IN_DATAFILE:'%s: Variable with key "%s" associated with feature with key "%s" is not in datafile.',VARIATION_ID_NOT_IN_DATAFILE:"%s: No variation ID %s defined in datafile for experiment %s.",VARIATION_ID_NOT_IN_DATAFILE_NO_EXPERIMENT:"%s: Variation ID %s is not in the datafile.",INVALID_INPUT_FORMAT:"%s: Provided %s is in an invalid format.",INVALID_DATAFILE_VERSION:"%s: This version of the JavaScript SDK does not support the given datafile version: %s",INVALID_VARIATION_KEY:"%s: Provided variation key is in an invalid format."},y={ACTIVATE_USER:"%s: Activating user %s in experiment %s.",DISPATCH_CONVERSION_EVENT:"%s: Dispatching conversion event to URL %s with params %s.",DISPATCH_IMPRESSION_EVENT:"%s: Dispatching impression event to URL %s with params %s.",DEPRECATED_EVENT_VALUE:"%s: Event value is deprecated in %s call.",EVENT_KEY_NOT_FOUND:"%s: Event key %s is not in datafile.",EXPERIMENT_NOT_RUNNING:"%s: Experiment %s is not running.",FEATURE_ENABLED_FOR_USER:"%s: Feature %s is enabled for user %s.",FEATURE_NOT_ENABLED_FOR_USER:"%s: Feature %s is not enabled for user %s.",FEATURE_HAS_NO_EXPERIMENTS:"%s: Feature %s is not attached to any experiments.",FAILED_TO_PARSE_VALUE:'%s: Failed to parse event value "%s" from event tags.',FAILED_TO_PARSE_REVENUE:'%s: Failed to parse revenue value "%s" from event tags.',FORCED_BUCKETING_FAILED:"%s: Variation key %s is not in datafile. Not activating user %s.",INVALID_OBJECT:"%s: Optimizely object is not valid. Failing %s.",INVALID_CLIENT_ENGINE:"%s: Invalid client engine passed: %s. Defaulting to node-sdk.",INVALID_DEFAULT_DECIDE_OPTIONS:"%s: Provided default decide options is not an array.",INVALID_DECIDE_OPTIONS:"%s: Provided decide options is not an array. Using default decide options.",INVALID_VARIATION_ID:"%s: Bucketed into an invalid variation ID. Returning null.",NOTIFICATION_LISTENER_EXCEPTION:"%s: Notification listener for (%s) threw exception: %s",NO_ROLLOUT_EXISTS:"%s: There is no rollout of feature %s.",NOT_ACTIVATING_USER:"%s: Not activating user %s for experiment %s.",NOT_TRACKING_USER:"%s: Not tracking user %s.",PARSED_REVENUE_VALUE:'%s: Parsed revenue value "%s" from event tags.',PARSED_NUMERIC_VALUE:'%s: Parsed event value "%s" from event tags.',RETURNING_STORED_VARIATION:'%s: Returning previously activated variation "%s" of experiment "%s" for user "%s" from user profile.',ROLLOUT_HAS_NO_EXPERIMENTS:"%s: Rollout of feature %s has no experiments",SAVED_VARIATION:'%s: Saved variation "%s" of experiment "%s" for user "%s".',SAVED_VARIATION_NOT_FOUND:"%s: User %s was previously bucketed into variation with ID %s for experiment %s, but no matching variation was found.",SHOULD_NOT_DISPATCH_ACTIVATE:'%s: Experiment %s is not in "Running" state. Not activating user.',SKIPPING_JSON_VALIDATION:"%s: Skipping JSON schema validation.",TRACK_EVENT:"%s: Tracking event %s for user %s.",UNRECOGNIZED_DECIDE_OPTION:"%s: Unrecognized decide option %s provided.",USER_ASSIGNED_TO_EXPERIMENT_BUCKET:"%s: Assigned bucket %s to user with bucketing ID %s.",USER_BUCKET
1ED_INTO_EXPERIMENT_IN_GROUP:"%s: User %s is in experiment %s of group %s.",USER_BUCKETED_INTO_TARGETING_RULE:"%s: User %s bucketed into targeting rule %s.",USER_IN_FEATURE_EXPERIMENT:"%s: User %s is in variation %s of experiment %s on the feature %s.",USER_IN_ROLLOUT:"%s: User %s is in rollout of feature %s.",USER_NOT_BUCKETED_INTO_EVERYONE_TARGETING_RULE:"%s: User %s not bucketed into everyone targeting rule due to traffic allocation.",USER_NOT_BUCKETED_INTO_EXPERIMENT_IN_GROUP:"%s: User %s is not in experiment %s of group %s.",USER_NOT_BUCKETED_INTO_ANY_EXPERIMENT_IN_GROUP:"%s: User %s is not in any experiment of group %s.",USER_NOT_BUCKETED_INTO_TARGETING_RULE:"%s User %s not bucketed into targeting rule %s due to traffic allocation. Trying everyone rule.",USER_NOT_IN_FEATURE_EXPERIMENT:"%s: User %s is not in any experiment on the feature %s.",USER_NOT_IN_ROLLOUT:"%s: User %s is not in rollout of feature %s.",USER_FORCED_IN_VARIATION:"%s: User %s is forced in variation %s.",USER_MAPPED_TO_FORCED_VARIATION:"%s: Set variation %s for experiment %s and user %s in the forced variation map.",USER_DOESNT_MEET_CONDITIONS_FOR_TARGETING_RULE:"%s: User %s does not meet conditions for targeting rule %s.",USER_MEETS_CONDITIONS_FOR_TARGETING_RULE:"%s: User %s meets conditions for targeting rule %s.",USER_HAS_VARIATION:"%s: User %s is in variation %s of experiment %s.",USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED:"Variation (%s) is mapped to flag (%s), rule (%s) and user (%s) in the forced decision map.",USER_HAS_FORCED_DECISION_WITH_NO_RULE_SPECIFIED:"Variation (%s) is mapped to flag (%s) and user (%s) in the forced decision map.",USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED_BUT_INVALID:"Invalid variation is mapped to flag (%s), rule (%s) and user (%s) in the forced decision map.",USER_HAS_FORCED_DECISION_WITH_NO_RULE_SPECIFIED_BUT_INVALID:"Invalid variation is mapped to flag (%s) and user (%s) in the forced decision map.",USER_HAS_FORCED_VARIATION:"%s: Variation %s is mapped to experiment %s and user %s in the forced variation map.",USER_HAS_NO_VARIATION:"%s: User %s is in no variation of experiment %s.",USER_HAS_NO_FORCED_VARIATION:"%s: User %s is not in the forced variation map.",USER_HAS_NO_FORCED_VARIATION_FOR_EXPERIMENT:"%s: No experiment %s mapped to user %s in the forced variation map.",USER_NOT_IN_ANY_EXPERIMENT:"%s: User %s is not in any experiment of group %s.",USER_NOT_IN_EXPERIMENT:"%s: User %s does not meet conditions to be in experiment %s.",USER_RECEIVED_DEFAULT_VARIABLE_VALUE:'%s: User "%s" is not in any variation or rollout rule. Returning default value for variable "%s" of feature flag "%s".',FEATURE_NOT_ENABLED_RETURN_DEFAULT_VARIABLE_VALUE:'%s: Feature "%s" is not enabled for user %s. Returning the default variable value "%s".',VARIABLE_NOT_USED_RETURN_DEFAULT_VARIABLE_VALUE:'%s: Variable "%s" is not used in variation "%s". Returning default value.',USER_RECEIVED_VARIABLE_VALUE:'%s: Got variable value "%s" for variable "%s" of feature flag "%s"',VALID_DATAFILE:"%s: Datafile is valid.",VALID_USER_PROFILE_SERVICE:"%s: Valid user profile service provided.",VARIATION_REMOVED_FOR_USER:"%s: Variation mapped to experiment %s has been removed for user %s.",VARIABLE_REQUESTED_WITH_WRONG_TYPE:'%s: Requested variable type "%s", but variable is of type "%s". Use correct API to retrieve value. Returning None.',VALID_BUCKETING_ID:'%s: BucketingId is valid: "%s"',BUCKETING_ID_NOT_STRING:"%s: BucketingID attribute is not a string. Defaulted to userId",EVALUATING_AUDIENCE:'%s: Starting to evaluate audience "%s" with conditions: %s.',EVALUATING_AUDIENCES_COMBINED:'%s: Evaluating audiences for %s "%s": %s.',AUDIENCE_EVALUATION_RESULT:'%s: Audience "%s" evaluated to %s.',AUDIENCE_EVALUATION_RESULT_COMBINED:"%s: Audiences for %s %s collectively evaluated to %s.",MISSING_ATTRIBUTE_VALUE:'%s: Audience condition %s evaluated to UNKNOWN because no value was passed for user attribute "%s".',UNEXPECTED_CONDITION_VALUE:"%s: Audience condition %s evaluated to UNKNOWN because the condition value is not supported.",UNEXPECTED_TYPE:'%s: Audience condition %s evaluated to UNKNOWN because a value of type "%s" was passed for user attribute "%s".',UNEXPECTED_TYPE_NULL:'%s: Audience condition %s evaluated to UNKNOWN because a null value was passed for user attribute "%s".',UNKNOWN_CONDITION_TYPE:"%s: Audience condition %s has an unknown condition type. You may need to upgrade to a newer release of the Optimizely SDK.",UNKNOWN_MATCH_TYPE:"%s: Audience condition %s uses an unknown match type. You may need to upgrade to a newer release of the Optimizely SDK.",UPDATED_OPTIMIZELY_CONFIG:"%s: Updated Optimizely config to revision %s (project id %s)",OUT_OF_BOUNDS:'%s: Audience condition %s evaluated to UNKNOWN because the number value for user attribute "%s" is not in the range [-2^53, +2^53].',UNABLE_TO_ATTACH_UNLOAD:'%s: unable to bind optimizely.close() to page unload event: "%s"'},A={BOT_FILTERING:"$opt_bot_filtering",BUCKETING_ID:"$opt_bucketing_id",STICKY_BUCKETING_KEY:"$opt_experiment_bucket_map",USER_AGENT:"$opt_user_agent",FORCED_DECISION_NULL_RULE_KEY:"$opt_null_rule_key"},L={AB_TEST:"ab-test",FEATURE:"feature",FEATURE_TEST:"feature-test",FEATURE_VARIABLE:"feature-variable",ALL_FEATURE_VARIABLES:"all-feature-variables",FLAG:"flag"},m={FEATURE_TEST:"feature-test",ROLLOUT:"rollout",EXPERIMENT:"experiment"},U={RULE:"rule",EXPERIMENT:"experiment"},D={BOOLEAN:"boolean",DOUBLE:"double",INTEGER:"integer",STRING:"string",JSON:"json"},S={V2:"2",V3:"3",V4:"4"},C={SDK_NOT_READY:"Optimizely SDK not configured properly yet.",FLAG_KEY_INVALID:'No flag was found for key "%s".',VARIABLE_VALUE_INVALID:'Variable value for key "%s" is invali
1d or wrong type.'};(i=R||(R={})).ACTIVATE="ACTIVATE:experiment, user_id,attributes, variation, event",i.DECISION="DECISION:type, userId, attributes, decisionInfo",i.LOG_EVENT="LOG_EVENT:logEvent",i.OPTIMIZELY_CONFIG_UPDATE="OPTIMIZELY_CONFIG_UPDATE",i.TRACK="TRACK:event_key, user_id, attributes, event_tags, event",Object.freeze({__proto__:null,LOG_LEVEL:N,ERROR_MESSAGES:T,LOG_MESSAGES:y,CONTROL_ATTRIBUTES:A,JAVASCRIPT_CLIENT_ENGINE:"javascript-sdk",NODE_CLIENT_ENGINE:"node-sdk",REACT_CLIENT_ENGINE:"react-sdk",REACT_NATIVE_CLIENT_ENGINE:"react-native-sdk",REACT_NATIVE_JS_CLIENT_ENGINE:"react-native-js-sdk",BROWSER_CLIENT_VERSION:"4.10.1",NODE_CLIENT_VERSION:"4.10.1",DECISION_NOTIFICATION_TYPES:L,DECISION_SOURCES:m,AUDIENCE_EVALUATION_TYPES:U,FEATURE_VARIABLE_TYPES:D,DATAFILE_VERSIONS:S,DECISION_MESSAGES:C,get NOTIFICATION_TYPES(){return R}});var V="CONFIG_VALIDATOR",P=[S.V2,S.V3,S.V4],b=function(e){if("object"==typeof e&&null!==e){var t=e.errorHandler,r=e.eventDispatcher,n=e.logger;if(t&&"function"!=typeof t.handleError)throw Error(v(T.INVALID_ERROR_HANDLER,V));if(r&&"function"!=typeof r.dispatchEvent)throw Error(v(T.INVALID_EVENT_DISPATCHER,V));if(n&&"function"!=typeof n.log)throw Error(v(T.INVALID_LOGGER,V));return!0}throw Error(v(T.INVALID_CONFIG,V))},F=function(e){if(!e)throw Error(v(T.NO_DATAFILE_SPECIFIED,V));if("string"==typeof e)try{e=JSON.parse(e)}catch(e){throw Error(v(T.INVALID_DATAFILE_MALFORMED,V))}if("object"==typeof e&&!Array.isArray(e)&&null!==e&&-1===P.indexOf(e.version))throw Error(v(T.INVALID_DATAFILE_VERSION,V,e.version));return e},M={dispatchEvent:function(e,t){var r,n=e.params,i=e.url;"POST"===e.httpVerb?((r=new XMLHttpRequest).open("POST",i,!0),r.setRequestHeader("Content-Type","application/json"),r.onreadystatechange=function(){if(4===r.readyState&&t&&"function"==typeof t)try{t({statusCode:r.status})}catch(e){}},r.send(JSON.stringify(n))):(i+="?wxhr=true",n&&(i+="&"+Object.keys(n).map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(n[e])}).join("&")),(r=new XMLHttpRequest).open("GET",i,!0),r.onreadystatechange=function(){if(4===r.readyState&&t&&"function"==typeof t)try{t({statusCode:r.status})}catch(e){}},r.send())}},k={dispatchEvent:function(e,t){var r=e.params,n=e.url,i=new Blob([JSON.stringify(r)],{type:"application/json"});t({statusCode:navigator.sendBeacon(n,i)?200:500})}},x=function(){function e(){}return e.prototype.log=function(){},e}();function B(e){return new u.ConsoleLogHandler(e)}function K(e,t,r){return{variationKey:null,enabled:!1,variables:{},ruleKey:null,flagKey:e,userContext:t,reasons:r}}Object.freeze({__proto__:null,NoOpLogger:x,createLogger:B,createNoOpLogger:function(){return new x}}),(s=o||(o={})).BOOLEAN="boolean",s.DOUBLE="double",s.INTEGER="integer",s.STRING="string",s.JSON="json",(a=t.N1||(t.N1={})).DISABLE_DECISION_EVENT="DISABLE_DECISION_EVENT",a.ENABLED_FLAGS_ONLY="ENABLED_FLAGS_ONLY",a.IGNORE_USER_PROFILE_SERVICE="IGNORE_USER_PROFILE_SERVICE",a.INCLUDE_REASONS="INCLUDE_REASONS",a.EXCLUDE_VARIABLES="EXCLUDE_VARIABLES";var G=function(){function e(e){var t,r=e.optimizely,n=e.userId,i=e.attributes;this.optimizely=r,this.userId=n,this.attributes=null!==(t=d({},i))&&void 0!==t?t:{},this.forcedDecisionsMap={}}return e.prototype.setAttribute=function(e,t){this.attributes[e]=t},e.prototype.getUserId=function(){return this.userId},e.prototype.getAttributes=function(){return d({},this.attributes)},e.prototype.getOptimizely=function(){return this.optimizely},e.prototype.decide=function(e,t){return void 0===t&&(t=[]),this.optimizely.decide(this.cloneUserContext(),e,t)},e.prototype.decideForKeys=function(e,t){return void 0===t&&(t=[]),this.optimizely.decideForKeys(this.cloneUserContext(),e,t)},e.prototype.decideAll=function(e){return void 0===e&&(e=[]),this.optimizely.decideAll(this.cloneUserContext(),e)},e.prototype.trackEvent=function(e,t){this.optimizely.track(e,this.userId,this.attributes,t)},e.prototype.setForcedDecision=function(e,t){var r,n=e.flagKey,i=null!==(r=e.ruleKey)&&void 0!==r?r:A.FORCED_DECISION_NULL_RULE_KEY,o={variationKey:t.variationKey};return this.forcedDecisionsMap[n]||(this.forcedDecisionsMap[n]={}),this.forcedDecisionsMap[n][i]=o,!0},e.prototype.getForcedDecision=function(e){return this.findForcedDecision(e)},e.prototype.removeForcedDecision=function(e){var t,r=null!==(t=e.ruleKey)&&void 0!==t?t:A.FORCED_DECISION_NULL_RULE_KEY,n=e.flagKey,i=!1;return this.forcedDecisionsMap.hasOwnProperty(n)&&(this.forcedDecisionsMap[n].hasOwnProperty(r)&&(delete this.forcedDecisionsMap[n][r],i=!0),0===Object.keys(this.forcedDecisionsMap[n]).length&&delete this.forcedDecisionsMap[n]),i},e.prototype.removeAllForcedDecisions=function(){return this.forcedDecisionsMap={},!0},e.prototype.findForcedDecision=function(e){var t,r=null!==(t=e.ruleKey)&&void 0!==t?t:A.FORCED_DECISION_NULL_RULE_KEY,n=e.flagKey;if(this.forcedDecisionsMap.hasOwnProperty(e.flagKey)){var i=this.forcedDecisionsMap[n];if(i.hasOwnProperty(r))return{variationKey:i[r].variationKey}}return null},e.prototype.cloneUserContext=function(){var t=new e({optimizely:this.getOptimizely(),userId:this.getUserId(),attributes:this.getAttributes()});return Object.keys(this.forcedDecisionsMap).length>0&&(t.forcedDecisionsMap=d({},this.forcedDecisionsMap)),t},e}(),w=["and","or","not"];function j(e,t){if(Array.isArray(e)){var r=e[0],n=e.slice(1);switch("string"==typeof r&&-1===w.indexOf(r)&&(r="or",n=e),r){case"and":return function(e,t){var r=!1;if(Array.isArray(e)){for(var n=0;n<e.length;n++){var i=j(e[n],t);
1if(!1===i)return!1;null===i&&(r=!0)}return!r||null}return null}(n,t);case"not":return function(e,t){if(Array.isArray(e)&&e.length>0){var r=j(e[0],t);return null===r?null:!r}return null}(n,t);default:return function(e,t){var r=!1;if(Array.isArray(e)){for(var n=0;n<e.length;n++){var i=j(e[n],t);if(!0===i)return!0;null===i&&(r=!0)}return!!r&&null}return null}(n,t)}}return t(e)}var H=function(){function e(t,r){this.sdkKey=null!==(n=t.sdkKey)&&void 0!==n?n:"",this.environmentKey=null!==(i=t.environmentKey)&&void 0!==i?i:"",this.attributes=t.attributes,this.audiences=e.getAudiences(t),this.events=t.events,this.revision=t.revision;var n,i,o=(t.featureFlags||[]).reduce(function(e,t){return e[t.id]=t.variables,e},{}),a=e.getVariableIdMap(t),s=e.getExperimentsMapById(t,o,a);this.experimentsMap=e.getExperimentsKeyMap(s),this.featuresMap=e.getFeaturesMap(t,o,s,a),this.datafile=r}return e.prototype.getDatafile=function(){return this.datafile},e.getAudiences=function(e){var t=[],r=[];return(e.typedAudiences||[]).forEach(function(e){t.push({id:e.id,conditions:JSON.stringify(e.conditions),name:e.name}),r.push(e.id)}),(e.audiences||[]).forEach(function(e){-1===r.indexOf(e.id)&&"$opt_dummy_audience"!=e.id&&t.push({id:e.id,conditions:JSON.stringify(e.conditions),name:e.name})}),t},e.getSerializedAudiences=function(t,r){var n="";if(t){var i="";t.forEach(function(t){var o="";if(t instanceof Array)o="("+(o=e.getSerializedAudiences(t,r))+")";else if(w.indexOf(t)>-1)i=t.toUpperCase();else{var a=r[t]?r[t].name:t;n||"NOT"===i?(i=""===i?"OR":i,n=""===n?i+' "'+r[t].name+'"':n.concat(" "+i+' "'+a+'"')):n='"'+a+'"'}""!==o&&(""!==n||"NOT"===i?(i=""===i?"OR":i,n=""===n?i+" "+o:n.concat(" "+i+" "+o)):n=n.concat(o))})}return n},e.getExperimentAudiences=function(t,r){return t.audienceConditions?e.getSerializedAudiences(t.audienceConditions,r.audiencesById):""},e.mergeFeatureVariables=function(e,t,r,n,i){var o=(e[r]||[]).reduce(function(e,t){return e[t.key]={id:t.id,key:t.key,type:t.type,value:t.defaultValue},e},{});return(n||[]).forEach(function(e){var r=t[e.id],n={id:e.id,key:r.key,type:r.type,value:i?e.value:r.defaultValue};o[r.key]=n}),o},e.getVariationsMap=function(t,r,n,i){return t.reduce(function(t,o){var a=e.mergeFeatureVariables(r,n,i,o.variables,o.featureEnabled);return t[o.key]={id:o.id,key:o.key,featureEnabled:o.featureEnabled,variablesMap:a},t},{})},e.getVariableIdMap=function(e){return(e.featureFlags||[]).reduce(function(e,t){return t.variables.forEac
1h(function(t){e[t.id]=t}),e},{})},e.getDeliveryRules=function(t,r,n,i,o){return i.map(function(i){return{id:i.id,key:i.key,audiences:e.getExperimentAudiences(i,t),variationsMap:e.getVariationsMap(i.variations,r,o,n)}})},e.getRolloutExperimentIds=function(e){var t=[];return(e||[]).forEach(function(e){e.experiments.forEach(function(e){t.push(e.id)})}),t},e.getExperimentsMapById=function(t,r,n){var i=this.getRolloutExperimentIds(t.rollouts);return(t.experiments||[]).reduce(function(o,a){if(-1===i.indexOf(a.id)){var s=t.experimentFeatureMap[a.id],u="";s&&s.length>0&&(u=s[0]);var l=e.getVariationsMap(a.variations,r,n,u.toString());o[a.id]={id:a.id,key:a.key,audiences:e.getExperimentAudiences(a,t),variationsMap:l}}return o},{})},e.getExperimentsKeyMap=function(e){var t={};for(var r in e){var n=e[r];t[n.key]=n}return t},e.getFeaturesMap=function(t,r,n,i){var o={};return t.featureFlags.forEach(function(a){var s={},u=[];a.experimentIds.forEach(function(e){var t=n[e];t&&(s[t.key]=t),u.push(n[e])});var l=(a.variables||[]).reduce(function(e,t){return e[t.key]={id:t.id,key:t.key,type:t.type,value:t.defaultValue},e},{}),c=[],E=t.rolloutIdMap[a.rolloutId];E&&(c=e.getDeliveryRules(t,r,a.id,E.experiments,i)),o[a.key]={id:a.id,key:a.key,experimentRules:u,deliveryRules:c,experimentsMap:s,variablesMap:l}}),o},e}(),Y="PROJECT_CONFIG",X=function(e,t){void 0===t&&(t=null);var r,n,i,o,a=((o=g({},e)).audiences=(e.audiences||[]).map(function(e){return g({},e)}),o.experiments=(e.experiments||[]).map(function(e){return g({},e)}),o.featureFlags=(e.featureFlags||[]).map(function(e){return g({},e)}),o.groups=(e.groups||[]).map(function(e){var t=g({},e);return t.experiments=(e.experiments||[]).map(function(e){return g({},e)}),t}),o.rollouts=(e.rollouts||[]).map(function(e){var t=g({},e);return t.experiments=(e.experiments||[]).map(function(e){return g({},e)}),t}),o.environmentKey=null!==(n=e.environmentKey)&&void 0!==n?n:"",o.sdkKey=null!==(i=e.sdkKey)&&void 0!==i?i:"",o);return a.__datafileStr=null===t?JSON.stringify(e):t,(a.audiences||[]).forEach(function(e){e.conditions=JSON.parse(e.conditions)}),a.audiencesById=I(a.audiences,"id"),g(a.audiencesById,I(a.typedAudiences,"id")),a.attributeKeyMap=I(a.attributes,"key"),a.eventKeyMap=I(a.events,"key"),a.groupIdMap=I(a.groups,"id"),Object.keys(a.groupIdMap||{}).forEach(function(e){(a.groupIdMap[e].experiments||[]).forEach(function(t){a.experiments.push(g(t,{groupId:e}))})}),a.rolloutIdMap=I(a.rollouts||[],"id"),_(a.rolloutIdMap||{}).forEach(function(e){(e.experiments||[]).forEach(function(e){a.experiments.push(e),e.variationKeyMap=I(e.variations,"key")})}),a.experimentKeyMap=I(a.experiments,"key"),a.experimentIdMap=I(a.experiments,"id"),a.variationIdMap={},a.variationVariableUsageMap={},(a.experiments||[]).forEach(function(e){e.variationKeyMap=I(e.variations,"key"),g(a.variationIdMap,I(e.variations,"id")),_(e.variationKeyMap||{}).forEach(function(e){e.variables&&(a.variationVariableUsageMap[e.id]=I(e.variables,"id"))})}),a.experimentFeatureMap={},a.featureKeyMap=I(a.featureFlags||[],"key"),_(a.featureKeyMap||{}
1).forEach(function(e){e.variables.forEach(function(e){e.type===D.STRING&&e.subType===D.JSON&&(e.type=D.JSON,delete e.subType)}),e.variableKeyMap=I(e.variables,"key"),(e.experimentIds||[]).forEach(function(t){a.experimentFeatureMap[t]?a.experimentFeatureMap[t].push(e.id):a.experimentFeatureMap[t]=[e.id]})}),a.flagRulesMap={},(a.featureFlags||[]).forEach(function(e){var t=[];e.experimentIds.forEach(function(e){var r=a.experimentIdMap[e];r&&t.push(r)});var r=a.rolloutIdMap[e.rolloutId];r&&t.push.apply(t,r.experiments),a.flagRulesMap[e.key]=t}),a.flagVariationsMap={},Object.keys(r=a.flagRulesMap||{}).map(function(e){return[e,r[e]]}).forEach(function(e){var t=e[0],r=e[1],n=[];r.forEach(function(e){e.variations.forEach(function(e){h(n,function(t){return t.id===e.id})||n.push(e)})}),a.flagVariationsMap[t]=n}),a},z=function(e,t){var r=e.experimentIdMap[t];if(!r)throw Error(v(T.INVALID_EXPERIMENT_ID,Y,t));return r.layerId},J=function(e,t,r){var n=e.attributeKeyMap[t],i=0===t.indexOf("$opt_");return n?(i&&r.log(N.WARNING,"Attribute %s unexpectedly has reserved prefix %s; using attribute ID instead of reserved attribute name.",t,"$opt_"),n.id):i?t:(r.log(N.DEBUG,T.UNRECOGNIZED_ATTRIBUTE,Y,t),null)},q=function(e,t){var r=e.eventKeyMap[t];return r?r.id:null},W=function(e,t){var r=e.experimentKeyMap[t];if(!r)throw Error(v(T.INVALID_EXPERIMENT_KEY,Y,t));return r.status},Z=function(e,t){return e.variationIdMap.hasOwnProperty(t)?e.variationIdMap[t].key:null},Q=function(e,t){if(e.experimentKeyMap.hasOwnProperty(t)){var r=e.experimentKeyMap[t];if(r)return r}throw Error(v(T.EXPERIMENT_KEY_NOT_IN_DATAFILE,Y,t))},$=function(e,t){var r=e.experimentIdMap[t];if(!r)throw Error(v(T.INVALID_EXPERIMENT_ID,Y,t));return r.trafficAllocation},ee=function(e,t,r){if(e.experimentIdMap.hasOwnProperty(t)){var n=e.experimentIdMap[t];if(n)return n}return r.log(N.ERROR,T.INVALID_EXPERIMENT_ID,Y,t),null},et=function(e,t,r){return e&&h(e.flagVariationsMap[t],function(e){return e.key===r})||null},er=function(e,t,r){if(e.featureKeyMap.hasOwnProperty(t)){var n=e.featureKeyMap[t];if(n)return n}return r.log(N.ERROR,T.FEATURE_NOT_IN_DATAFILE,Y,t),null},en=function(e){return e.__datafileStr},ei=function(e){try{t=F(e.datafile)}catch(e){return{configObj:null,error:e}}if(e.jsonSchemaValidator)try{e.jsonSchemaValidator.validate(t),e.logger.log(N.INFO,y.VALID_DATAFILE,Y)}catch(e){return{configObj:null,error:e}}else e.logger.log(N.INFO,y.SKIPPING_JSON_VALIDATION,Y);var t,r=[t];return"string"==typeof e.datafile&&r.push(e.datafile),{configObj:X.apply(void 0,r),error:null}},eo=function(e){return!!e.sendFlagDecisions},ea=u.getLogger();function es(e,t){return e instanceof Error?e.message:t||"Unknown error"}var eu=function(){function e(e){this.updateListeners=[],this.configObj=null,this.optimizelyConfigObj=null,this.datafileManager=null;try{if(this.jsonSchemaValidator=e.jsonSchemaValidator,!e.datafile&&!e.sdkKey){var t=Error(v(T.DATAFILE_AND_SDK_KEY_MISSING,"PROJECT_CONFIG_MANAGER"));return this.readyPromise=Promise.resolve({success:!1,reason:es(t)}),void ea.error(t)}var r=null;e.datafile&&(r=this.handleNewDatafile(e.datafile)),e.sdkKey&&e.datafileManager?(this.datafileManager=e.datafileManager,this.datafileManager.start(),this.readyPromise=this.datafileManager.onReady().then(this.onDatafileManagerReadyFulfill.bind(this),this.onDatafileManagerReadyReject.bind(this)),this.datafileManager.on("update",this.onDatafileManagerUpdate.bind(this))):this.configObj?this.readyPromise=Promise.resolve({success:!0}):this.readyPromise=Promise.resolve({success:!1,reason:es(r,"Invalid datafile")})}catch(e){ea.error(e),this.readyPromise=Promise.resolve({success:!1,reason:es(e,"Error in initialize")})}}return e.prototype.onDatafileManagerReadyFulfill=function(){if(this.datafileManager){var e=this.handleNewDatafile(this.datafileManager.get());return e?{success:!1,reason:es(e)}:{success:!0}}return{success:!1,reason:es(null,"Datafile manager is not provided")}},e.prototype.onDatafileManagerReadyReject=function(e){return{success:!1,reason:es(e,"Failed to become ready")}},e.prototype.onDatafileManagerUpdate=function(){this.datafileManager&&this.handleNewDatafile(this.datafileManager.get())},e.prototype.handleNewDatafile=function(e){var t=ei({datafile:e,jsonSchemaValidator:this.jsonSchemaValidator,logger:ea}),r=t.configObj,n=t.error;if(n)ea.error(n);else{var i=this.configObj?this.configObj.revision:"null";r&&i!==r.revision&&(this.configObj=r,this.optimizelyConfigObj=null,this.updateListeners.forEac
1h(function(e){return e(r)}))}return n},e.prototype.getConfig=function(){return this.configObj},e.prototype.getOptimizelyConfig=function(){return!this.optimizelyConfigObj&&this.configObj&&(this.optimizelyConfigObj=new H(this.configObj,en(this.configObj))),this.optimizelyConfigObj},e.prototype.onReady=function(){return this.readyPromise},e.prototype.onUpdate=function(e){var t=this;return this.updateListeners.push(e),function(){var r=t.updateListeners.indexOf(e);r>-1&&t.updateListeners.splice(r,1)}},e.prototype.stop=function(){this.datafileManager&&this.datafileManager.stop(),this.updateListeners=[]},e}(),el=function(e){var t=[],r=e.experimentIdMap[e.experimentId].groupId;if(r){var n=e.groupIdMap[r];if(!n)throw Error(v(T.INVALID_GROUP_ID,"BUCKETER",r));if("random"===n.policy){var i=ec(n,e.bucketingId,e.userId,e.logger);if(null===i)return e.logger.log(N.INFO,y.USER_NOT_IN_ANY_EXPERIMENT,"BUCKETER",e.userId,r),t.push([y.USER_NOT_IN_ANY_EXPERIMENT,"BUCKETER",e.userId,r]),{result:null,reasons:t};if(i!==e.experimentId)return e.logger.log(N.INFO,y.USER_NOT_BUCKETED_INTO_EXPERIMENT_IN_GROUP,"BUCKETER",e.userId,e.experimentKey,r),t.push([y.USER_NOT_BUCKETED_INTO_EXPERIMENT_IN_GROUP,"BUCKETER",e.userId,e.experimentKey,r]),{result:null,reasons:t};e.logger.log(N.INFO,y.USER_BUCKETED_INTO_EXPERIMENT_IN_GROUP,"BUCKETER",e.userId,e.experimentKey,r),t.push([y.USER_BUCKETED_INTO_EXPERIMENT_IN_GROUP,"BUCKETER",e.userId,e.experimentKey,r])}}var o=ef(""+e.bucketingId+e.experimentId);e.logger.log(N.DEBUG,y.USER_ASSIGNED_TO_EXPERIMENT_BUCKET,"BUCKETER",o,e.userId),t.push([y.USER_ASSIGNED_TO_EXPERIMENT_BUCKET,"BUCKETER",o,e.userId]);var a=eE(o,e.trafficAllocationConfig);return null===a||e.variationIdMap[a]?{result:a,reasons:t}:(a&&(e.logger.log(N.WARNING,y.INVALID_VARIATION_ID,"BUCKETER"),t.push([y.INVALID_VARIATION_ID,"BUCKETER"])),{result:null,reasons:t})},ec=function(e,t,r,n){var i=ef(""+t+e.id);return n.log(N.DEBUG,y.USER_ASSIGNED_TO_EXPERIMENT_BUCKET,"BUCKETER",i,r),eE(i,e.trafficAllocation)},eE=function(e,t){for(var r=0;r<t.length;r++)if(e<t[r].endOfRange)return t[r].entityId;return null},ef=function(e){try{var t=E.v3(e,1)/4294967296;return Math.floor(1e4*t)}catch(t){throw Error(v(T.INVALID_BUCKETING_ID,"BUCKETER",e,t.message))}},ed=u.getLogger();function ep(e){return/^\d+$/.test(e)}function eg(e){var t=e.indexOf("-"),r=e.indexOf("+");return!(t<0)&&(r<0||t<r)}function eI(e){var t=e.indexOf("-"),r=e.indexOf("+");return!(r<0)&&(t<0||r<t)}function e_(e){var t=e,r="";if(/\s/.test(e))return ed.warn(y.UNKNOWN_MATCH_TYPE,"SEMANTIC VERSION",e),null;if(eg(e)?(t=e.substring(0,e.indexOf("-")),r=e.substring(e.indexOf("-")+1)):eI(e)&&(t=e.substring(0,e.indexOf("+")),r=e.substring(e.indexOf("+")+1)),"string"!=typeof t||"string"!=typeof r)return null;var n=t.split(".").length-1;if(n>2)return ed.warn(y.UNKNOWN_MATCH_TYPE,"SEMANTIC VERSION",e),null;var i=t.split(".");if(i.length!=n+1)return ed.warn(y.UNKNOWN_MATCH_TYPE,"SEMANTIC VERSION",e),null;for(var o=0;o<i.length;o++)if(!ep(i[o]))return ed.warn(y.UNKNOWN_MATCH_TYPE,"SEMANTIC VERSION",e),null;return r&&i.push(r),i}var eh="CUSTOM_ATTRIBUTE_CONDITION_EVALUATOR",ev=u.getLogger(),eR=["exact","exists","gt","ge","lt","le","substring","semver_eq","semver_lt","semver_le","semver_gt","semver_ge"],eO={};function eN(e){return"string"==typeof e||"boolean"==typeof e||O.isNumber(e)}function eT(e,t){var r=e.value,n=typeof r,i=e.name,o=t[i],a=typeof o;return!eN(r)||O.isNumber(r)&&!O.isSafeInteger(r)?(ev.warn(y.UNEXPECTED_CONDITION_VALUE,eh,JSON.stringify(e)),null):null===o?(ev.debug(y.UNEXPECTED_TYPE_NULL,eh,JSON.stringify(e),i),null):eN(o)&&n===a?O.isNumber(o)&&!O.isSafeInteger(o)?(ev.warn(y.OUT_OF_BOUNDS,eh,JSON.stringify(e),i),null):r===o:(ev.warn(y.UNEXPECTED_TYPE,eh,JSON.stringify(e),a,i),null)}function ey(e,t){var r=e.name,n=t[r],i=typeof n,o=e.value;return null!==o&&O.isSafeInteger(o)?null===n?(ev.debug(y.UNEXPECTED_TYPE_NULL,eh,JSON.stringify(e),r),!1):O.isNumber(n)?!!O.isSafeInteger(n)||(ev.warn(y.OUT_OF_BOUNDS,eh,JSON.stringify(e),r),!1):(ev.warn(y.UNEXPECTED_TYPE,eh,JSON.stringify(e),i,r),!1):(ev.warn(y.UNEXPECTED_CONDITION_VALUE,eh,JSON.stringify(e)),!1)}function eA(e,t){var r=e.name,n=t[r],i=e.value;return"string"!=typeof i?(ev.warn(y.UNEXPECTED_CONDITION_VALUE,eh,JSON.stringify(e)),null):null===n?(ev.debug(y.UNEXPECTED_TYPE_NULL,eh,JSON.stringify(e),r),null):"string"!=typeof n?(ev.warn(y.UNEXPECTED_TYPE,eh,JSON.stringify(e),typeof n,r),null):function(e,t){var r=e_(t),n=e_(e);
1if(!r||!n)return null;for(var i=r.length,o=0;o<n.length;o++){if(i<=o)return eg(e)||eI(e)?1:-1;if(ep(r[o])){var a=parseInt(r[o]),s=parseInt(n[o]);if(a>s)return 1;if(a<s)return -1}else{if(r[o]<n[o])return eg(e)&&!eg(t)?1:-1;if(r[o]>n[o])return!eg(e)&&eg(t)?-1:1}}return eg(t)&&!eg(e)?-1:0}(i,n)}eO.exact=eT,eO.exists=function(e,t){return null!=t[e.name]},eO.gt=function(e,t){var r=t[e.name],n=e.value;return ey(e,t)&&null!==n?r>n:null},eO.ge=function(e,t){var r=t[e.name],n=e.value;return ey(e,t)&&null!==n?r>=n:null},eO.lt=function(e,t){var r=t[e.name],n=e.value;return ey(e,t)&&null!==n?r<n:null},eO.le=function(e,t){var r=t[e.name],n=e.value;return ey(e,t)&&null!==n?r<=n:null},eO.substring=function(e,t){var r=e.name,n=t[e.name],i=e.value;return"string"!=typeof i?(ev.warn(y.UNEXPECTED_CONDITION_VALUE,eh,JSON.stringify(e)),null):null===n?(ev.debug(y.UNEXPECTED_TYPE_NULL,eh,JSON.stringify(e),r),null):"string"!=typeof n?(ev.warn(y.UNEXPECTED_TYPE,eh,JSON.stringify(e),typeof n,r),null):-1!==n.indexOf(i)},eO.semver_eq=function(e,t){var r=eA(e,t);return null===r?null:0===r},eO.semver_gt=function(e,t){var r=eA(e,t);return null===r?null:r>0},eO.semver_ge=function(e,t){var r=eA(e,t);return null===r?null:r>=0},eO.semver_lt=function(e,t){var r=eA(e,t);return null===r?null:r<0},eO.semver_le=function(e,t){var r=eA(e,t);return null===r?null:r<=0};var eL=Object.freeze({__proto__:null,evaluate:function(e,t){var r=e.match;if(void 0!==r&&-1===eR.indexOf(r))return ev.warn(y.UNKNOWN_MATCH_TYPE,eh,JSON.stringify(e)),null;var n=e.name;return t.hasOwnProperty(n)||"exists"==r?(r&&eO[r]||eT)(e,t):(ev.debug(y.MISSING_ATTRIBUTE_VALUE,eh,JSON.stringify(e),n),null)}}),em=u.getLogger(),eU=function(){function e(e){this.typeToEvaluatorMap=O.assign({},e,{custom_attribute:eL})}return e.prototype.evaluate=function(e,t,r){var n=this;return void 0===r&&(r={}),!e||0===e.length||!!j(e,function(e){var i=t[e];if(i){em.log(N.DEBUG,y.EVALUATING_AUDIENCE,"AUDIENCE_EVALUATOR",e,JSON.stringify(i.conditions));var o=j(i.conditions,n.evaluateConditionWithUserAttributes.bind(n,r)),a=null===o?"UNKNOWN":o.toString().toUpperCase();return em.log(N.DEBUG,y.AUDIENCE_EVALUATION_RESULT,"AUDIENCE_EVALUATOR",e,a),o}return null})},e.prototype.evaluateConditionWithUserAttributes=function(e,t){var r=this.typeToEvaluatorMap[t.type];if(!r)return em.log(N.WARNING,y.UNKNOWN_CONDITION_TYPE,"AUDIENCE_EVALUATOR",JSON.stringify(t)),null;try{return r.evaluate(t,e)}catch(e){em.log(N.ERROR,T.CONDITION_EVALUATOR_ERROR,"AUDIENCE_EVALUATOR",t.type,e.message)}return null},e}();function eD(e){return"string"==typeof e&&""!==e}var eS="DECISION_SERVICE",eC=function(){function e(e){this.audienceEvaluator=new eU(e.UNSTABLE_conditionEvaluators),this.forcedVariationMap={},this.logger=e.logger,this.userProfileService=e.userProfileService||null}return e.prototype.getVariation=function(e,r,n,i){void 0===i&&(i={});var o=n.getUserId(),a=n.getAttributes(),s=this.getBucketingId(o,a),u=[],l=r.key;if(!this.checkIfExperimentIsActive(e,l))return this.logger.log(N.INFO,y.EXPERIMENT_NOT_RUNNING,eS,l),u.push([y.EXPERIMENT_NOT_RUNNING,eS,l]),{result:null,reasons:u};var c=this.getForcedVariation(e,l,o);u.push.apply(u,c.reasons);var E=c.result;if(E)return{result:E,reasons:u};var f=this.getWhitelistedVariation(r,o);u.push.apply(u,f.reasons);var d=f.result;if(d)return{result:d.key,reasons:u};var p=i[t.N1.IGNORE_USER_PROFILE_SERVICE],g=this.resolveExperimentBucketMap(o,a);if(!p&&(d=this.getStoredVariation(e,r,o,g)))return this.logger.log(N.INFO,y.RETURNING_STORED_VARIATION,eS,d.key,l,o),u.push([y.RETURNING_STORED_VARIATION,eS,d.key,l,o]),{result:d.key,reasons:u};var I=this.checkIfUserIsInAudience(e,r,U.EXPERIMENT,a,"");if(u.push.apply(u,I.reasons),!I.result)return this.logger.log(N.INFO,y.USER_NOT_IN_EXPERIMENT,eS,o,l),u.push([y.USER_NOT_IN_EXPERIMENT,eS,o,l]),{result:null,reasons:u};var _=el(this.buildBucketerParams(e,r,s,o));u.push.apply(u,_.reasons);var h=_.result;return h&&(d=e.variationIdMap[h]),d?(this.logger.log(N.INFO,y.USER_HAS_VARIATION,eS,o,d.key,l),u.push([y.USER_HAS_VARIATION,eS,o,d.key,l]),p||this.saveUserProfile(r,d,o,g),{result:d.key,reasons:u}):(this.logger.log(N.DEBUG,y.USER_HAS_NO_VARIATION,eS,o,l),u.push([y.USER_HAS_NO_VARIATION,eS,o,l]),{result:null,reasons:u})},e.prototype.resolveExperimentBucketMap=function(e,t){t=t||{};var r=this.getUserProfile(e)||{},n=t[A.STICKY_BUCKETING_KEY];return O.assign({},r.experiment_bucket_map,n)},e.prototype.checkIfExperimentIsActive=function(e,t){return"Running"===W(e,t)},e.prototype.getWhitelistedVariation=function(e,t){var r=[];if(e.forcedVariations&&e.forcedVariations.hasOwnProperty(t)){var n=e.forcedVariations[t];return e.variationKeyMap.hasOwnProperty(n)?(this.logger.log(N.INFO,y.USER_FORCED_IN_VARIATION,eS,t,n),r.push([y.USER_FORCED_IN_VARIATION,eS,t,n]),{result:e.variationKeyMap[n],reasons:r}):(this.logger.log(N.ERROR,y.FORCED_BUCKETING_FAILED,eS,n,t),r.push([y.FORCED_BUCKETING_FAILED,eS,n,t]),{result:null,reasons:r})}return{result:null,reasons:r}},e.prototype.checkIfUserIsInAudience=function(e,t,r,n,i){var o=[],a=function(e,t){var r=e.experimentIdMap[t];if(!r)throw Error(v(T.INVALID_EXPERIMENT_ID,Y,t));return r.audienceConditions||r.audienceIds}(e,t.id),s=e.audiencesById;this.logger.log(N.DEBUG,y.EVALUATING_AUDIENCES_COMBINED,eS,r,i||t.key,JSON.stringify(a)),o.push([y.EVALUATING_AUDIENCES_COMBINED,eS,r,i||t.key,JSON.stringify(a)]);var u=this.audienceEvaluator.evaluate(a,s,n);return this.logger.log(N.INFO,y.AUDIENCE_EVALUATION_RESULT_COMBINED,eS,r,i||t.key,u.toString().toUpperCase()),o.push([y.AUDIENCE_EVALUATION_RESULT_COMBINED,eS,r,i||t.key,u.toString().toUpperCase()]),{result:u,reasons:o}},e.prototype.buildBucketerParams=function(e,t,r,n){return{bucketingId:r,experimentId:t.id,experimentKey:t.key,experimentIdMap:e.experimentIdMap,experimentKeyMap:e.experimentKeyMap,groupIdMap:e.groupIdMap,logger:this.logger,trafficAllocationConfig:$(e,t.id),userId:n,variationIdMap:e.variationIdMap}},e.prototype.getStoredVariation=function(e,t,r,n){if(n.hasOwnProperty(t.id)){var i=n[t.id],o=i.variation_id;if(e.variationIdMap.hasOwnProperty(o))return e.variationIdMap[i.variation_id];this.logger.log(N.INFO,y.SAVED_VARIATION_NOT_FOUND,eS,r,o,t.key)}return null},e.prototype.getUserProfile=function(e){if(!this.userProfileService)return{user_id:e,experiment_bucket_map:{}};try{return this.userProfileService.lookup(e)}catch(t){this.logger.log(N.ERROR,T.USER_PROFILE_LOOKUP_ERROR,eS,e,t.message)}return null},e.prototype.saveUserProfile=function(e,t,r,n){if(this.userProfileService)try{n[e.id]={variation_id:t.
1id},this.userProfileService.save({user_id:r,experiment_bucket_map:n}),this.logger.log(N.INFO,y.SAVED_VARIATION,eS,t.key,e.key,r)}catch(e){this.logger.log(N.ERROR,T.USER_PROFILE_SAVE_ERROR,eS,r,e.message)}},e.prototype.getVariationForFeature=function(e,t,r,n){void 0===n&&(n={});var i=[],o=this.getVariationForFeatureExperiment(e,t,r,n);i.push.apply(i,o.reasons);var a=o.result;if(null!==a.variation)return{result:a,reasons:i};var s=this.getVariationForRollout(e,t,r);i.push.apply(i,s.reasons);var u=s.result,l=r.getUserId();return u.variation?(this.logger.log(N.DEBUG,y.USER_IN_ROLLOUT,eS,l,t.key),i.push([y.USER_IN_ROLLOUT,eS,l,t.key])):(this.logger.log(N.DEBUG,y.USER_NOT_IN_ROLLOUT,eS,l,t.key),i.push([y.USER_NOT_IN_ROLLOUT,eS,l,t.key])),{result:u,reasons:i}},e.prototype.getVariationForFeatureExperiment=function(e,t,r,n){void 0===n&&(n={});var i,o,a=[],s=null;if(t.experimentIds.length>0)for(o=0;o<t.experimentIds.length;o++){var u=ee(e,t.experimentIds[o],this.logger);if(u&&(i=this.getVariationFromExperimentRule(e,t.key,u,r,n),a.push.apply(a,i.reasons),s=i.result)){var l=null;return(l=u.variationKeyMap[s])||(l=et(e,t.key,s)),{result:{experiment:u,variation:l,decisionSource:m.FEATURE_TEST},reasons:a}}}else this.logger.log(N.DEBUG,y.FEATURE_HAS_NO_EXPERIMENTS,eS,t.key),a.push([y.FEATURE_HAS_NO_EXPERIMENTS,eS,t.key]);return{result:{experiment:null,variation:null,decisionSource:m.FEATURE_TEST},reasons:a}},e.prototype.getVariationForRollout=function(e,t,r){var n=[];if(!t.rolloutId)return this.logger.log(N.DEBUG,y.NO_ROLLOUT_EXISTS,eS,t.key),n.push([y.NO_ROLLOUT_EXISTS,eS,t.key]),{result:{experiment:null,variation:null,decisionSource:m.ROLLOUT},reasons:n};var i=e.rolloutIdMap[t.rolloutId];if(!i)return this.logger.log(N.ERROR,T.INVALID_ROLLOUT_ID,eS,t.rolloutId,t.key),n.push([T.INVALID_ROLLOUT_ID,eS,t.rolloutId,t.key]),{result:{experiment:null,variation:null,decisionSource:m.ROLLOUT},reasons:n};var o,a,s,u=i.experiments;if(0===u.length)return this.logger.log(N.ERROR,y.ROLLOUT_HAS_NO_EXPERIMENTS,eS,t.rolloutId),n.push([y.ROLLOUT_HAS_NO_EXPERIMENTS,eS,t.rolloutId]),{result:{experiment:null,variation:null,decisionSource:m.ROLLOUT},reasons:n};for(var l=0;l<u.length;){if(o=this.getVariationFromDeliveryRule(e,t.key,u,l,r),n.push.apply(n,o.reasons),s=o.result,a=o.skipToEveryoneElse,s)return{result:{experiment:e.experimentIdMap[u[l].id],variation:s,decisionSource:m.ROLLOUT},reasons:n};l=a?u.length-1:l+1}return{result:{experiment:null,variation:null,decisionSource:m.ROLLOUT},reasons:n}},e.prototype.getBucketingId=function(e,t){var r=e;return null!=t&&"object"==typeof t&&t.hasOwnProperty(A.BUCKETING_ID)&&("string"==typeof t[A.BUCKETING_ID]?(r=t[A.BUCKETING_ID],this.logger.log(N.DEBUG,y.VALID_BUCKETING_ID,eS,r)):this.logger.log(N.WARNING,y.BUCKETING_ID_NOT_STRING,eS)),r},e.prototype.findValidatedForcedDecision=function(e,t,r,n){var i,o=[],a=t.getForcedDecision({flagKey:r,ruleKey:n}),s=null,u=t.getUserId();return e&&a&&((s=et(e,r,i=a.variationKey))?n?(this.logger.log(N.INFO,y.USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED,i,r,n,u),o.push([y.USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED,i,r,n,u])):(this.logger.log(N.INFO,y.USER_HAS_FORCED_DECISION_WITH_NO_RULE_SPECIFIED,i,r,u),o.push([y.USER_HAS_FORCED_DECISION_WITH_NO_RULE_SPECIFIED,i,r,u])):n?(this.logger.log(N.INFO,y.USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED_BUT_INVALID,r,n,u),o.push([y.USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED_BUT_INVALID,r,n,u])):(this.logger.log(N.INFO,y.USER_HAS_FORCED_DECISION_WITH_NO_RULE_SPECIFIED_BUT_INVALID,r,u),o.push([y.USER_HAS_FORCED_DECISION_WITH_NO_RULE_SPECIFIED_BUT_INVALID,r,u]))),{result:s,reasons:o}},e.prototype.removeForcedVariation=function(e,t,r){if(!e)throw Error(v(T.INVALID_USER_ID,eS));if(!this.forcedVariationMap.hasOwnProperty(e))throw Error(v(T.USER_NOT_IN_FORCED_VARIATION,eS,e));delete this.forcedVariationMap[e][t],this.logger.log(N.DEBUG,y.VARIATION_REMOVED_FOR_USER,eS,r,e)},e.prototype.setInForcedVariationMap=function(e,t,r){this.forcedVariationMap.hasOwnProperty(e)||(this.forcedVariationMap[e]={}),this.forcedVariationMap[e][t]=r,this.logger.log(N.DEBUG,y.USER_MAPPED_TO_FORCED_VARIATION,eS,r,t,e)},e.prototype.getForcedVariation=function(e,t,r){var n,i=[],o=this.forcedVariationMap[r];if(!o)return this.logger.log(N.DEBUG,y.USER_HAS_NO_FORCED_VARIATION,eS,r),{result:null,reasons:i};try{var a=Q(e,t);if(!a.hasOwnProperty("id"))return this.logger.log(N.ERROR,T.IMPROPERLY_FORMATTED_EXPERIMENT,eS,t),i.push([T.IMPROPERLY_FORMATTED_EXPERIMENT,eS,t]),{result:null,reasons:i};n=a.id}catch(e){return this.logger.log(N.ERROR,e.message),i.push(e.message),{result:null,reasons:i}}var s=o[n];if(!s)return this.logger.log(N.DEBUG,y.USER_HAS_NO_FORCED_VARIATION_FOR_EXPERIMENT,eS,t,r),{result:null,reasons:i};var u=Z(e,s);return u?(this.logger.log(N.DEBUG,y.USER_HAS_FORCED_VARIATION,eS,u,t,r),i.push([y.USER_HAS_FORCED_VARIATION,eS,u,t,r])):this.logger.log(N.DEBUG,y.USER_HAS_NO_FORCED_VARIATION_FOR_EXPERIMENT,eS,t,r),{result:u,reasons:i}},e.prototype.setForcedVariation=function(e,t,r,n){if(null!=n&&!eD(n))return this.logger.log(N.ERROR,T.INVALID_VARIATION_KEY,eS),!1;try{var i,o,a=Q(e,t);if(!a.hasOwnProperty("id"))return this.logger.log(N.ERROR,T.IMPROPERLY_FORMATTED_EXPERIMENT,eS,t),!1;o=a.id}catch(e){return this.logger.log(N.ERROR,e.message),!1}if(null==n)try{return this.removeForcedVariation(r,o,t),!0}catch(e){return this.logger.log(N.ERROR,e.message),!1}var s=(i=e.experimentKeyMap[t]).variationKeyMap.hasOwnProperty(n)?i.variationKeyMap[n].id:null;if(!s)return this.logger.log(N.ERROR,T.NO_VARIATION_FOR_EXPERIMENT_KEY,eS,n,t),!1;try{return this.setInForcedVariationMap(r,o,s),!0}catch(e){return this.logger.log(N.ERROR,e.message),!1}},e.prototype.getVariationFromExperimentRule=function(e,t,r,n,i){void 0===i&&(i={});var o=[],a=this.findValidatedForcedDecision(e,n,t,r.key);o.push.apply(o,a.reasons);var s=a.result;if(s)return{result:s.key,reasons:o};var u=this.getVariation(e,r,n,i);return o.push.apply(o,u.reasons),{result:u.result,reasons:o}},e.prototype.getVariationFromDeliveryRule=function(e,t,r,n,i){var o=[],a=!1,s=r[n],u=this.findValidatedForcedDecision(e,i,t,s.key);o.push.apply(o,u.reasons);var l=u.result;if(l)return{result:l,reasons:o,skipToEveryoneElse:a};var c,E,f=i.getUserId(),d=i.getAttributes(),p=this.getBucketingId(f,d),g=n===r.length-1,I=g?"Everyone Else":n+1,_=null,h=this.checkIfUserIsInAudience(e,s,U.RULE,d,I);return o.push.apply(o,h.reasons),h.result?(this.logger.log(N.DEBUG,y.USER_MEETS_CONDITIONS_FOR_TARGETING_RULE,eS,f,I),o.push([y.USER_MEETS_CONDITIONS_FOR_TARGETING_RULE,eS,f,I]),E=el(this.buildBucketerParams(e,s,p,f)),o.push.apply(o,E.reasons),(c=E.result)&&(_=e.variationIdMap.hasOwnProperty(c)?e.variationIdMap[c]:null),_?(this.logger.log(N.DEBUG,y.USER_BUCKET
1ED_INTO_TARGETING_RULE,eS,f,I),o.push([y.USER_BUCKETED_INTO_TARGETING_RULE,eS,f,I])):g||(this.logger.log(N.DEBUG,y.USER_NOT_BUCKETED_INTO_TARGETING_RULE,eS,f,I),o.push([y.USER_NOT_BUCKETED_INTO_TARGETING_RULE,eS,f,I]),a=!0)):(this.logger.log(N.DEBUG,y.USER_DOESNT_MEET_CONDITIONS_FOR_TARGETING_RULE,eS,f,I),o.push([y.USER_DOESNT_MEET_CONDITIONS_FOR_TARGETING_RULE,eS,f,I])),{result:_,reasons:o,skipToEveryoneElse:a}},e}();function eV(e,t){if(e.hasOwnProperty("revenue")){var r=e.revenue,n=void 0;return"string"==typeof r?isNaN(n=parseInt(r))?(t.log(N.INFO,y.FAILED_TO_PARSE_REVENUE,"EVENT_TAG_UTILS",r),null):(t.log(N.INFO,y.PARSED_REVENUE_VALUE,"EVENT_TAG_UTILS",n),n):"number"==typeof r?(n=r,t.log(N.INFO,y.PARSED_REVENUE_VALUE,"EVENT_TAG_UTILS",n),n):null}return null}function eP(e,t){if(e.hasOwnProperty("value")){var r=e.value,n=void 0;return"string"==typeof r?isNaN(n=parseFloat(r))?(t.log(N.INFO,y.FAILED_TO_PARSE_VALUE,"EVENT_TAG_UTILS",r),null):(t.log(N.INFO,y.PARSED_NUMERIC_VALUE,"EVENT_TAG_UTILS",n),n):"number"==typeof r?(n=r,t.log(N.INFO,y.PARSED_NUMERIC_VALUE,"EVENT_TAG_UTILS",n),n):null}return null}function eb(e,t){return"string"==typeof e&&("string"==typeof t||"boolean"==typeof t||O.isNumber(t)&&O.isSafeInteger(t))}var eF="https://logx.optimizely.com/v1/events";function eM(e){var t=e.attributes,r=e.userId,n=e.clientEngine,i=e.clientVersion,o=e.configObj,a=e.logger,s=!!o.anonymizeIP&&o.anonymizeIP,u=o.botFiltering,l={account_id:o.accountId,project_id:o.projectId,visitors:[{snapshots:[],visitor_id:r,attributes:[]}],revision:o.revision,client_name:n,client_version:i,anonymize_ip:s,enrich_decisions:!0};return t&&Object.keys(t||{}).forEach(function(e){if(eb(e,t[e])){var r=J(o,e,a);r&&l.visitors[0].attributes.push({entity_id:r,key:e,type:"custom",value:t[e]})}}),"boolean"==typeof u&&l.visitors[0].attributes.push({entity_id:A.BOT_FILTERING,key:A.BOT_FILTERING,type:"custom",value:u}),l}function ek(e){var t,r;return null!==(r=null===(t=e.experiment)||void 0===t?void 0:t.key)&&void 0!==r?r:""}function ex(e){var t,r;return null!==(r=null===(t=e.variation)||void 0===t?void 0:t.key)&&void 0!==r?r:""}function eB(e){var t,r;return null!==(r=null===(t=e.variation)||void 0===t?void 0:t.featureEnabled)&&void 0!==r&&r}function eK(e){var t,r;return null!==(r=null===(t=e.experiment)||void 0===t?void 0:t.id)&&void 0!==r?r:null}function eG(e){var t,r;return null!==(r=null===(t=e.variation)||void 0===t?void 0:t.id)&&void 0!==r?r:null}var ew=u.getLogger("EVENT_BUILDER");function ej(e,t){var r=[];return t&&Object.keys(t||{}).forEach(function(n){if(eb(n,t[n])){var i=J(e,n,ew);i&&r.push({entityId:i,key:n,value:t[n]})}}),r}var eH="USER_PROFILE_SERVICE_VALIDATOR",eY=function(){function e(e){var r,n=this,i=e.clientEngine;i||(e.logger.log(N.INFO,y.INVALID_CLIENT_ENGINE,"OPTIMIZELY",i),i="node-sdk"),this.clientEngine=i,this.clientVersion=e.clientVersion||"4.10.1",this.errorHandler=e.errorHandler,this.isOptimizelyConfigValid=e.isValidInstance,this.logger=e.logger;var o=null!==(r=e.defaultDecideOptions)&&void 0!==r?r:[];Array.isArray(o)||(this.logger.log(N.DEBUG,y.INVALID_DEFAULT_DECIDE_OPTIONS,"OPTIMIZELY"),o=[]);var a={};o.forEach(function(e){t.N1[e]?a[e]=!0:n.logger.log(N.WARNING,y.UNRECOGNIZED_DECIDE_OPTION,"OPTIMIZELY",e)}),this.defaultDecideOptions=a,this.projectConfigManager=new eu({datafile:e.datafile,jsonSchemaValidator:e.jsonSchemaValidator,sdkKey:e.sdkKey,datafileManager:e.datafileManager}),this.disposeOnUpdate=this.projectConfigManager.onUpdate(function(e){n.logger.log(N.INFO,y.UPDATED_OPTIMIZELY_CONFIG,"OPTIMIZELY",e.revision,e.projectId),n.notificationCenter.sendNotifications(R.OPTIMIZELY_CONFIG_UPDATE)});var s=this.projectConfigManager.onReady(),u=null;if(e.userProfileService)try{(function(e){if("object"==typeof e&&null!==e){if("function"!=typeof e.lookup)throw Error(v(T.INVALID_USER_PROFILE_SERVICE,eH,"Missing function 'lookup'"));if("function"!=typeof e.save)throw Error(v(T.INVALID_USER_PROFILE_SERVICE,eH,"Missing function 'save'"));return!0}throw Error(v(T.INVALID_USER_PROFILE_SERVICE,eH))})(e.userProfileService)&&(u=e.userProfileService,this.logger.log(N.INFO,y.VALID_USER_PROFILE_SERVICE,"OPTIMIZELY"))}catch(e){this.logger.log(N.WARNING,e.message)}this.decisionService=new eC({userProfileService:u,logger:this.logger,UNSTABLE_conditionEvaluators:e.UNSTABLE_conditionEvaluators}),this.notificationCenter=e.notificationCenter,this.eventProcessor=e.eventProcessor;var l=this.eventProcessor.start();this.readyPromise=Promise.all([s,l]).then(function(e){return e[0]}),this.readyTimeouts={},this.nextReadyTimeoutId=0}return e.prototype.isValidInstance=function(){return this.isOptimizelyConfigValid&&!!this.projectConfigManager.getConfig()},e.prototype.activate=function(e,t,r){try{if(!this.isValidInstance())return this.logger.log(N.ERROR,y.INVALID_OBJECT,"OPTIMIZELY","activate"),null;if(!this.validateInputs({experiment_key:e,user_id:t},r))return this.notActivatingExperiment(e,t);var n=this.projectConfigManager.getConfig();if(!n)return null;try{var i=this.getVariation(e,t,r);if(null===i)return this.notActivatingExperiment(e,t);if("Running"!==W(n,e))return this.logger.log(N.DEBUG,y.SHOULD_NOT_DISPATCH_ACTIVATE,"OPTIMIZELY",e),i;var o=Q(n,e),a={experiment:o,variation:o.variationKeyMap[i],decisionSource:m.EXPERIMENT};return this.sendImpressionEvent(a,"",t,!0,r),i}catch(r){return this.logger.log(N.ERROR,r.message),this.logger.log(N.INFO,y.NOT_ACTIVATING_USER,"OPTIMIZELY",t,e),this.errorHandler.handleError(r),null}}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),null}},e.prototype.sendImpressionEvent=function(e,t,r,n,i){var o=this.projectConfigManager.getConfig();if(o){var a,s,u,l,c,E,f,d,p,g,I,_,h,v,R,N=(s=(a={decisionObj:e,flagKey:t,enabled:n,userId:r,userAttributes:i,clientEngine:this.clientEngine,clientVersion:this.clientVersion,configObj:o}).configObj,u=a.decisionObj,l=a.userId,c=a.flagKey,E=a.enabled,f=a.userAttributes,d=a.clientEngine,p=a.clientVersion,g=u.decisionSource,I=ek(u),_=eK(u),h=ex(u),v=eG(u),R=null!==_?z(s,_):null,{type:"impression",timestamp:O.currentTimestamp(),uuid:O.uuid(),user:{id:l,attributes:ej(s,f)},context:{accountId:s.accountId,projectId:s.projectId,revision:s.revision,clientName:d,clientVersion:p,anonymizeIP:s.anonymizeIP||!1,botFiltering:s.botFiltering},layer:{id:R},experiment:{id:_,key:I},variation:{id:v,key:h},ruleKey:I,flagKey:c,ruleType:g,enabled:E});this.eventProcessor.process(N),this.emitNotificationCenterActivate(e,t,r,n,i)}},e.prototype.emitNotificationCenterActivate=function(e,t,r,n,i){var o=this.projectConfigManager.getConfig();if(o){var a,s=e.decisionSource,u=ek(e),l=eK(e),c=ex(e),E=eG(e);null!==l&&""!==c&&(a=o.experimentIdMap[l]);var f,d,p,g,I,_,h,v,N,T,y,A,L,m=(y=eM(f={attributes:i,clientEngine:this.clientEngine,clientVersion:this.clientVersion,configObj:o,experimentId:l,ruleKey:u,flagKey:t,ruleType:s,userId:r,enabled:n,variationId:E,logger:this.logger}),d=f.configObj,p=f.experimentId,g=f.variationId,I=f.ruleKey,_=f.ruleType,h=f.flagKey,v=f.enabled,N=p?z(d,p):null,T=g?Z(d,g):null,A={decisions:[{campaign_id:N,experiment_id:p,variation_id:g,metadata:{flag_key:h,rule_key:I,rule_type:_,variation_key:T=T||"",enabled:v}}],events:[{entity_id:N,timestamp:O.currentTimestamp(),key:"campaign_activated",uuid:O.uuid()}]},y.visitors[0].snapshots.push(A),{httpVerb:"POST",url:eF,params:y});a&&a.variationKeyMap&&""!==c&&(L=a.variationKeyMap[c]),this.notificationCenter.sendNotifications(R.ACTIVATE,{experiment:a,userId:r,attributes:i,variation:L,logEvent:m})}},e.prototype.track=function(e,t,r,n){try{if(!this.isValidInstance())return void this.logger.log(N.ERROR,y.INVALID_OBJECT,"OPTIMIZELY","track");if(!this.validateInputs({user_id:t,event_key:e},r,n))return;var i,o,a,s,u,l,c,E,f,d,p,g=this.projectConfigManager.getConfig();if(!g)return;
1if(!g.eventKeyMap.hasOwnProperty(e))return this.logger.log(N.WARNING,y.EVENT_KEY_NOT_FOUND,"OPTIMIZELY",e),void this.logger.log(N.WARNING,y.NOT_TRACKING_USER,"OPTIMIZELY",t);var I=(o=(i={eventKey:e,eventTags:n=this.filterEmptyValues(n),userId:t,userAttributes:r,clientEngine:this.clientEngine,clientVersion:this.clientVersion,configObj:g}).configObj,a=i.userId,s=i.userAttributes,u=i.clientEngine,l=i.clientVersion,c=i.eventKey,E=i.eventTags,f=q(o,c),d=E?eV(E,ew):null,p=E?eP(E,ew):null,{type:"conversion",timestamp:O.currentTimestamp(),uuid:O.uuid(),user:{id:a,attributes:ej(o,s)},context:{accountId:o.accountId,projectId:o.projectId,revision:o.revision,clientName:u,clientVersion:l,anonymizeIP:o.anonymizeIP||!1,botFiltering:o.botFiltering},event:{id:f,key:c},revenue:d,value:p,tags:E});this.logger.log(N.INFO,y.TRACK_EVENT,"OPTIMIZELY",e,t),this.eventProcessor.process(I),this.emitNotificationCenterTrack(e,t,r,n)}catch(e){this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),this.logger.log(N.ERROR,y.NOT_TRACKING_USER,"OPTIMIZELY",t)}},e.prototype.emitNotificationCenterTrack=function(e,t,r,n){try{var i,o,a,s=this.projectConfigManager.getConfig();if(!s)return;var u=(i={attributes:r,clientEngine:this.clientEngine,clientVersion:this.clientVersion,configObj:s,eventKey:e,eventTags:n,logger:this.logger,userId:t},o=eM(i),a=function(e,t,r,n){var i={events:[]},o={entity_id:q(e,t),timestamp:O.currentTimestamp(),uuid:O.uuid(),key:t};if(n){var a=eV(n,r);null!==a&&(o.revenue=a);var s=eP(n,r);null!==s&&(o.value=s),o.tags=n}return i.events.push(o),i}(i.configObj,i.eventKey,i.logger,i.eventTags),o.visitors[0].snapshots=[a],{httpVerb:"POST",url:eF,params:o});this.notificationCenter.sendNotifications(R.TRACK,{eventKey:e,userId:t,attributes:r,eventTags:n,logEvent:u})}catch(e){this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e)}},e.prototype.getVariation=function(e,t,r){try{if(!this.isValidInstance())return this.logger.log(N.ERROR,y.INVALID_OBJECT,"OPTIMIZELY","getVariation"),null;try{if(!this.validateInputs({experiment_key:e,user_id:t},r))return null;var n,i=this.projectConfigManager.getConfig();if(!i)return null;var o=i.experimentKeyMap[e];if(!o)return this.logger.log(N.DEBUG,T.INVALID_EXPERIMENT_KEY,"OPTIMIZELY",e),null;var a=this.decisionService.getVariation(i,o,this.createUserContext(t,r)).result,s=(n=o.id,i.experimentFeatureMap.hasOwnProperty(n)?L.FEATURE_TEST:L.AB_TEST);return this.notificationCenter.sendNotifications(R.DECISION,{type:s,userId:t,attributes:r||{},decisionInfo:{experimentKey:e,variationKey:a}}),a}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),null}}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),null}},e.prototype.setForcedVariation=function(e,t,r){if(!this.validateInputs({experiment_key:e,user_id:t}))return!1;var n=this.projectConfigManager.getConfig();if(!n)return!1;try{return this.decisionService.setForcedVariation(n,e,t,r)}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),!1}},e.prototype.getForcedVariation=function(e,t){if(!this.validateInputs({experiment_key:e,user_id:t}))return null;var r=this.projectConfigManager.getConfig();if(!r)return null;try{return this.decisionService.getForcedVariation(r,e,t).result}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),null}},e.prototype.validateInputs=function(e,t,r){try{if(e.hasOwnProperty("user_id")){var n=e.user_id;if("string"!=typeof n||null===n||"undefined"===n)throw Error(v(T.INVALID_INPUT_FORMAT,"OPTIMIZELY","user_id"));delete e.user_id}return Object.keys(e).forEach(function(t){if(!eD(e[t]))throw Error(v(T.INVALID_INPUT_FORMAT,"OPTIMIZELY",t))}),t&&function(e){if("object"!=typeof e||Array.isArray(e)||null===e)throw Error(v(T.INVALID_ATTRIBUTES,"ATTRIBUTES_VALIDATOR"));Object.keys(e).forEach(function(t){if(void 0===e[t])throw Error(v(T.UNDEFINED_ATTRIBUTE,"ATTRIBUTES_VALIDATOR",t))})}(t),r&&function(e){if("object"!=typeof e||Array.isArray(e)||null===e)throw Error(v(T.INVALID_EVENT_TAGS,"EVENT_TAGS_VALIDATOR"))}(r),!0}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),!1}},e.prototype.notActivatingExperiment=function(e,t){return this.logger.log(N.INFO,y.NOT_ACTIVATING_USER,"OPTIMIZELY",t,e),null},e.prototype.filterEmptyValues=function(e){for(var t in e)e.hasOwnProperty(t)&&(null===e[t]||void 0===e[t])&&delete e[t];return e},e.prototype.isFeatureEnabled=function(e,t,r){try{if(!this.isValidInstance())return this.logger.log(N.ERROR,y.INVALID_OBJECT,"OPTIMIZELY","isFeatureEnabled"),!1;if(!this.validateInputs({feature_key:e,user_id:t},r))return!1;var n=this.projectConfigManager.getConfig();if(!n)return!1;var i=er(n,e,this.logger);if(!i)return!1;var o={},a=this.createUserContext(t,r),s=this.decisionService.getVariationForFeature
1(n,i,a).result,u=s.decisionSource,l=ek(s),c=ex(s),E=eB(s);u===m.FEATURE_TEST&&(o={experimentKey:l,variationKey:c}),(u===m.FEATURE_TEST||u===m.ROLLOUT&&eo(n))&&this.sendImpressionEvent(s,i.key,t,E,r),!0===E?this.logger.log(N.INFO,y.FEATURE_ENABLED_FOR_USER,"OPTIMIZELY",e,t):(this.logger.log(N.INFO,y.FEATURE_NOT_ENABLED_FOR_USER,"OPTIMIZELY",e,t),E=!1);var f={featureKey:e,featureEnabled:E,source:s.decisionSource,sourceInfo:o};return this.notificationCenter.sendNotifications(R.DECISION,{type:L.FEATURE,userId:t,attributes:r||{},decisionInfo:f}),E}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),!1}},e.prototype.getEnabledFeatures=function(e,t){var r=this;try{var n=[];if(!this.isValidInstance())return this.logger.log(N.ERROR,y.INVALID_OBJECT,"OPTIMIZELY","getEnabledFeatures"),n;if(!this.validateInputs({user_id:e}))return n;var i=this.projectConfigManager.getConfig();return i&&_(i.featureKeyMap).forEach(function(i){r.isFeatureEnabled(i.key,e,t)&&n.push(i.key)}),n}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),[]}},e.prototype.getFeatureVariable=function(e,t,r,n){try{return this.isValidInstance()?this.getFeatureVariableForType(e,t,null,r,n):(this.logger.log(N.ERROR,y.INVALID_OBJECT,"OPTIMIZELY","getFeatureVariable"),null)}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),null}},e.prototype.getFeatureVariableForType=function(e,t,r,n,i){if(!this.validateInputs({feature_key:e,variable_key:t,user_id:n},i))return null;var o,a,s=this.projectConfigManager.getConfig();if(!s)return null;var u=er(s,e,this.logger);if(!u)return null;var l=(o=this.logger,(a=s.featureKeyMap[e])?a.variableKeyMap[t]||(o.log(N.ERROR,T.VARIABLE_KEY_NOT_IN_DATAFILE,Y,t,e),null):(o.log(N.ERROR,T.FEATURE_NOT_IN_DATAFILE,Y,e),null));if(!l)return null;if(r&&l.type!==r)return this.logger.log(N.WARNING,y.VARIABLE_REQUESTED_WITH_WRONG_TYPE,"OPTIMIZELY",r,l.type),null;var c=this.createUserContext(n,i),E=this.decisionService.getVariationForFeature(s,u,c).result,f=eB(E),d=this.getFeatureVariableValueFromVariation(e,f,E.variation,l,n),p={};return E.decisionSource===m.FEATURE_TEST&&null!==E.experiment&&null!==E.variation&&(p={experimentKey:E.experiment.key,variationKey:E.variation.key}),this.notificationCenter.sendNotifications(R.DECISION,{type:L.FEATURE_VARIABLE,userId:n,attributes:i||{},decisionInfo:{featureKey:e,featureEnabled:f,source:E.decisionSource,variableKey:t,variableValue:d,variableType:l.type,sourceInfo:p}}),d},e.prototype.getFeatureVariableValueFromVariation=function(e,t,r,n,i){var o=this.projectConfigManager.getConfig();if(!o)return null;var a=n.defaultValue;if(null!==r){var s=function(e,t,r,n){if(!t||!r)return null;if(!e.variationVariableUsageMap.hasOwnProperty(r.id))return n.log(N.ERROR,T.VARIATION_ID_NOT_IN_DATAFILE_NO_EXPERIMENT,Y,r.id),null;var i=e.variationVariableUsageMap[r.id][t.id];return i?i.value:null}(o,n,r,this.logger);null!==s?t?(a=s,this.logger.log(N.INFO,y.USER_RECEIVED_VARIABLE_VALUE,"OPTIMIZELY",a,n.key,e)):this.logger.log(N.INFO,y.FEATURE_NOT_ENABLED_RETURN_DEFAULT_VARIABLE_VALUE,"OPTIMIZELY",e,i,a):this.logger.log(N.INFO,y.VARIABLE_NOT_USED_RETURN_DEFAULT_VARIABLE_VALUE,"OPTIMIZELY",n.key,r.key)}else this.logger.log(N.INFO,y.USER_RECEIVED_DEFAULT_VARIABLE_VALUE,"OPTIMIZELY",i,n.key,e);return function(e,t,r){var n;switch(t){case D.BOOLEAN:"true"!==e&&"false"!==e?(r.log(N.ERROR,T.UNABLE_TO_CAST_VALUE,Y,e,t),n=null):n="true"===e;break;case D.INTEGER:isNaN(n=parseInt(e,10))&&(r.log(N.ERROR,T.UNABLE_TO_CAST_VALUE,Y,e,t),n=null);break;case D.DOUBLE:isNaN(n=parseFloat(e))&&(r.log(N.ERROR,T.UNABLE_TO_CAST_VALUE,Y,e,t),n=null);break;case D.JSON:try{n=JSON.parse(e)}catch(i){r.log(N.ERROR,T.UNABLE_TO_CAST_VALUE,Y,e,t),n=null}break;default:n=e}return n}(a,n.type,this.logger)},e.prototype.getFeatureVariableBoolean=function(e,t,r,n){try{return this.isValidInstance()?this.getFeatureVariableForType(e,t,D.BOOLEAN,r,n):(this.logger.log(N.ERROR,y.INVALID_OBJECT,"OPTIMIZELY","getFeatureVariableBoolean"),null)}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),null}},e.prototype.getFeatureVariableDouble=function(e,t,r,n){try{return this.isValidInstance()?this.getFeatureVariableForType(e,t,D.DOUBLE,r,n):(this.logger.log(N.ERROR,y.INVALID_OBJECT,"OPTIMIZELY","getFeatureVariableDouble"),null)}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),null}},e.prototype.getFeatureVariableInteger=function(e,t,r,n){try{return this.isValidInstance()?this.getFeatureVariableForType(e,t,D.INTEGER,r,n):(this.logger.log(N.ERROR,y.INVALID_OBJECT,"OPTIMIZELY","getFeatureVariableInteger"),null)}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),null}},e.prototype.getFeatureVariableString=function(e,t,r,n){try{return this.isValidInstance()?this.getFeatureVariableForType(e,t,D.STRING,r,n):(this.logger.log(N.ERROR,y.INVALID_OBJECT,"OPTIMIZELY","getFeatureVariableString"),null)}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),null}},e.prototype.getFeatureVariableJSON=function(e,t,r,n){try{return this.isValidInstance()?this.getFeatureVariableForType(e,t,D.JSON,r,n):(this.logger.log(N.ERROR,y.INVALID_OBJECT,"OPTIMIZELY","getFeatureVariableJSON"),null)}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),null}},e.prototype.getAllFeatureVariables=function(e,t,r){var n=this;try{if(!this.isValidInstance())return this.logger.log(N.ERROR,y.INVALID_OBJECT,"OPTIMIZELY","getAllFeatureVariables"),null;if(!this.validateInputs({feature_key:e,user_id:t},r))return null;var i=this.projectConfigManager.getConfig();if(!i)return null;var o=er(i,e,this.logger);if(!o)return null;var a=this.createUserContext(t,r),s=this.decisionService.getVariationForFeature
1(i,o,a).result,u=eB(s),l={};o.variables.forEach(function(r){l[r.key]=n.getFeatureVariableValueFromVariation(e,u,s.variation,r,t)});var c={};return s.decisionSource===m.FEATURE_TEST&&null!==s.experiment&&null!==s.variation&&(c={experimentKey:s.experiment.key,variationKey:s.variation.key}),this.notificationCenter.sendNotifications(R.DECISION,{type:L.ALL_FEATURE_VARIABLES,userId:t,attributes:r||{},decisionInfo:{featureKey:e,featureEnabled:u,source:s.decisionSource,variableValues:l,sourceInfo:c}}),l}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),null}},e.prototype.getOptimizelyConfig=function(){try{return this.projectConfigManager.getConfig()?this.projectConfigManager.getOptimizelyConfig():null}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),null}},e.prototype.close=function(){var e=this;try{var t=this.eventProcessor.stop();return this.disposeOnUpdate&&(this.disposeOnUpdate(),this.disposeOnUpdate=null),this.projectConfigManager&&this.projectConfigManager.stop(),Object.keys(this.readyTimeouts).forEach(function(t){var r=e.readyTimeouts[t];clearTimeout(r.readyTimeout),r.onClose()}),this.readyTimeouts={},t.then(function(){return{success:!0}},function(e){return{success:!1,reason:String(e)}})}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),Promise.resolve({success:!1,reason:String(e)})}},e.prototype.onReady=function(e){var t,r,n=this;"object"==typeof e&&null!==e&&void 0!==e.timeout&&(t=e.timeout),O.isSafeInteger(t)||(t=3e4);var i=new Promise(function(e){r=e}),o=this.nextReadyTimeoutId;this.nextReadyTimeoutId++;var a=setTimeout(function(){delete n.readyTimeouts[o],r({success:!1,reason:v("onReady timeout expired after %s ms",t)})},t);return this.readyTimeouts[o]={readyTimeout:a,onClose:function(){r({success:!1,reason:"Instance closed"})}},this.readyPromise.then(function(){clearTimeout(a),delete n.readyTimeouts[o],r({success:!0})}),Promise.race([this.readyPromise,i])},e.prototype.createUserContext=function(e,t){return this.validateInputs({user_id:e},t)?new G({optimizely:this,userId:e,attributes:t}):null},e.prototype.decide=function(e,r,n){var i,o,a,s,u=this;void 0===n&&(n=[]);var l,c=e.getUserId(),E=e.getAttributes(),f=this.projectConfigManager.getConfig(),d=[];if(!this.isValidInstance()||!f)return this.logger.log(N.INFO,y.INVALID_OBJECT,"OPTIMIZELY","decide"),K(r,e,[C.SDK_NOT_READY]);var g=f.featureKeyMap[r];if(!g)return this.logger.log(N.ERROR,T.FEATURE_NOT_IN_DATAFILE,"OPTIMIZELY",r),K(r,e,[v(C.FLAG_KEY_INVALID,r)]);var I=this.getAllDecideOptions(n),_=this.decisionService.findValidatedForcedDecision(f,e,r);d.push.apply(d,_.reasons);var h=_.result;if(h)l={experiment:null,variation:h,decisionSource:m.FEATURE_TEST};else{var O=this.decisionService.getVariationForFeature(f,g,e,I);d.push.apply(d,O.reasons),l=O.result}var A=l.decisionSource,U=null!==(o=null===(i=l.experiment)||void 0===i?void 0:i.key)&&void 0!==o?o:null,D=null!==(s=null===(a=l.variation)||void 0===a?void 0:a.key)&&void 0!==s?s:null,S=eB(l);!0===S?this.logger.log(N.INFO,y.FEATURE_ENABLED_FOR_USER,"OPTIMIZELY",r,c):this.logger.log(N.INFO,y.FEATURE_NOT_ENABLED_FOR_USER,"OPTIMIZELY",r,c);var V={},P=!1;
1I[t.N1.EXCLUDE_VARIABLES]||g.variables.forEach(function(e){V[e.key]=u.getFeatureVariableValueFromVariation(r,S,l.variation,e,c)}),!I[t.N1.DISABLE_DECISION_EVENT]&&(A===m.FEATURE_TEST||A===m.ROLLOUT&&eo(f))&&(this.sendImpressionEvent(l,r,c,S,E),P=!0);var b=[];I[t.N1.INCLUDE_REASONS]&&(b=d.map(function(e){return v.apply(void 0,p([e[0]],e.slice(1)))}));var F={flagKey:r,enabled:S,variationKey:D,ruleKey:U,variables:V,reasons:b,decisionEventDispatched:P};return this.notificationCenter.sendNotifications(R.DECISION,{type:L.FLAG,userId:c,attributes:E,decisionInfo:F}),{variationKey:D,enabled:S,variables:V,ruleKey:U,flagKey:r,userContext:e,reasons:b}},e.prototype.getAllDecideOptions=function(e){var r=this,n=d({},this.defaultDecideOptions);return Array.isArray(e)?e.forEach(function(e){t.N1[e]?n[e]=!0:r.logger.log(N.WARNING,y.UNRECOGNIZED_DECIDE_OPTION,"OPTIMIZELY",e)}):this.logger.log(N.DEBUG,y.INVALID_DECIDE_OPTIONS,"OPTIMIZELY"),n},e.prototype.decideForKeys=function(e,r,n){var i=this;void 0===n&&(n=[]);var o={};if(!this.isValidInstance())return this.logger.log(N.ERROR,y.INVALID_OBJECT,"OPTIMIZELY","decideForKeys"),o;if(0===r.length)return o;var a=this.getAllDecideOptions(n);return r.forEach(function(r){var s=i.decide(e,r,n);a[t.N1.ENABLED_FLAGS_ONLY]&&!s.enabled||(o[r]=s)}),o},e.prototype.decideAll=function(e,t){void 0===t&&(t=[]);var r=this.projectConfigManager.getConfig();if(!this.isValidInstance()||!r)return this.logger.log(N.ERROR,y.INVALID_OBJECT,"OPTIMIZELY","decideAll"),{};var n=Object.keys(r.featureKeyMap);return this.decideForKeys(e,n,t)},e}(),eX=function(){function e(e){var t=this;this.logger=e.logger,this.errorHandler=e.errorHandler,this.notificationListeners={},_(R).forEach(function(e){t.notificationListeners[e]=[]}),this.listenerId=1}return e.prototype.addNotificationListener=function(e,t){try{if(!(_(R).indexOf(e)>-1))return -1;this.notificationListeners[e]||(this.notificationListeners[e]=[]);var r=!1;if((this.notificationListeners[e]||[]).forEach(function(e){e.callback!==t||(r=!0)}),r)return -1;this.notificationListeners[e].push({id:this.listenerId,callback:t});var n=this.listenerId;return this.listenerId+=1,n}catch(e){return this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e),-1}},e.prototype.removeNotificationListener=function(e){var t,r,n=this;try{if(Object.keys(this.notificationListeners).some(function(i){return(n.notificationListeners[i]||[]).every(function(n,o){return n.id!==e||(t=o,r=i,!1)}),void 0!==t&&void 0!==r}),void 0!==t&&void 0!==r)return this.notificationListeners[r].splice(t,1),!0}catch(e){this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e)}return!1},e.prototype.clearAllNotificationListeners=function(){var e=this;try{_(R).forEach(function(t){e.notificationListeners[t]=[]})}catch(e){this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e)}},e.prototype.clearNotificationListeners=function(e){try{this.notificationListeners[e]=[]}catch(e){this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e)}},e.prototype.sendNotifications=function(e,t){var r=this;try{(this.notificationListeners[e]||[]).forEach(function(n){var i=n.callback;try{i(t)}catch(t){r.logger.log(N.ERROR,y.NOTIFICATION_LISTENER_EXCEPTION,"NOTIFICATION_CENTER",e,t.message)}})}catch(e){this.logger.log(N.ERROR,e.message),this.errorHandler.handleError(e)}},e}(),ez={createEventProcessor:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return new(l.LogTierV1EventProcessor.bind.apply(l.LogTierV1EventProcessor,p([void 0],e)))},LocalStoragePendingEventsDispatcher:l.LocalStoragePendingEventsDispatcher},eJ=u.getLogger();u.setLogHandler(B()),u.setLogLevel(u.LogLevel.INFO);var eq=!1;u.setLogHandler,u.setLogLevel,t.N1,t.Fs=function(e){try{var t,r,n=!1;e.errorHandler&&u.setErrorHandler(e.errorHandler),e.logger&&(u.setLogHandler(e.logger),u.setLogLevel(u.LogLevel.NOTSET)),void 0!==e.logLevel&&u.setLogLevel(e.logLevel);try{b(e),n=!0}catch(e){eJ.error(e)}var i=void 0;null==e.eventDispatcher?(i=new l.LocalStoragePendingEventsDispatcher({eventDispatcher:M}),eq||(i.sendPendingEvents(),eq=!0)):i=e.eventDispatcher;var o=e.closingEventDispatcher;
1!e.eventDispatcher&&!o&&window.navigator&&"sendBeacon"in window.navigator&&(o=k);var a=e.eventBatchSize,s=e.eventFlushInterval;t=e.eventBatchSize,!("number"!=typeof t||!O.isSafeInteger(t))&&t>=1||(eJ.warn("Invalid eventBatchSize %s, defaulting to %s",e.eventBatchSize,10),a=10),r=e.eventFlushInterval,!("number"!=typeof r||!O.isSafeInteger(r))&&r>0||(eJ.warn("Invalid eventFlushInterval %s, defaulting to %s",e.eventFlushInterval,1e3),s=1e3);var c=u.getErrorHandler(),E=new eX({logger:eJ,errorHandler:c}),p={dispatcher:i,closingDispatcher:o,flushInterval:s,batchSize:a,maxQueueSize:e.eventMaxQueueSize||1e4,notificationCenter:E},g=d(d({clientEngine:"javascript-sdk"},e),{eventProcessor:ez.createEventProcessor(p),logger:eJ,errorHandler:c,datafileManager:e.sdkKey?function(e,t,r,n){var i={sdkKey:e};if((void 0===n||"object"==typeof n&&null!==n)&&O.assign(i,n),r){var o=ei({datafile:r,jsonSchemaValidator:void 0,logger:t}),a=o.configObj,s=o.error;s&&t.error(s),a&&(i.datafile=en(a))}return new f.HttpPollingDatafileManager(i)}(e.sdkKey,eJ,e.datafile,e.datafileOptions):void 0,notificationCenter:E,isValidInstance:n}),I=new eY(g);try{if("function"==typeof window.addEventListener){var _="onpagehide"in window?"pagehide":"unload";window.addEventListener(_,function(){I.close()},!1)}}catch(e){eJ.error(y.UNABLE_TO_ATTACH_UNLOAD,"INDEX_BROWSER",e.message)}return I}catch(e){return eJ.error(e),null}}}}]); 2//# [email protected]
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.