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

launchdarkly-js-sdk-common

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

launchdarkly-js-sdk-common - npm Package Compare versions

Comparing version 3.2.6 to 3.2.7

4

CHANGELOG.md

@@ -5,2 +5,6 @@ # Change log

## [3.2.7] - 2020-04-30
### Fixed:
- Some diagnostic event data was being sent twice, resulting in extra HTTP requests. This did not affect analytics events, so customer data on the dashboard and in data export would still be correct.
## [3.2.6] - 2020-03-31

@@ -7,0 +11,0 @@ ### Fixed:

2

dist/ldclient-common.cjs.js

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

"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function _objectSpread2(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(n,!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(n).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function createCustomError(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return(t.prototype=new Error).name=e,t.prototype.constructor=t}Object.defineProperty(exports,"__esModule",{value:!0});var LDUnexpectedResponseError=createCustomError("LaunchDarklyUnexpectedResponseError"),LDInvalidEnvironmentIdError=createCustomError("LaunchDarklyInvalidEnvironmentIdError"),LDInvalidUserError=createCustomError("LaunchDarklyInvalidUserError"),LDInvalidEventKeyError=createCustomError("LaunchDarklyInvalidEventKeyError"),LDInvalidArgumentError=createCustomError("LaunchDarklyInvalidArgumentError"),LDFlagFetchError=createCustomError("LaunchDarklyFlagFetchError");function isHttpErrorRecoverable(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({__proto__:null,LDUnexpectedResponseError:LDUnexpectedResponseError,LDInvalidEnvironmentIdError:LDInvalidEnvironmentIdError,LDInvalidUserError:LDInvalidUserError,LDInvalidEventKeyError:LDInvalidEventKeyError,LDInvalidArgumentError:LDInvalidArgumentError,LDFlagFetchError:LDFlagFetchError,isHttpErrorRecoverable:isHttpErrorRecoverable}),fromByteArray_1=fromByteArray,lookup=[],revLookup=[],code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,t,n){for(var r,o=[],i=t;i<n;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(r));return o.join("")}function fromByteArray(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(encodeChunk(e,a,s<a+i?s:a+i));return 1==r?(t=e[n-1],o.push(lookup[t>>2]+lookup[t<<4&63]+"==")):2==r&&(t=(e[n-2]<<8)+e[n-1],o.push(lookup[t>>10]+lookup[t>>4&63]+lookup[t<<2&63]+"=")),o.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63;var isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i,a=isArray(t),s=isArray(n);if(a&&s){if((o=t.length)!=n.length)return!1;for(r=o;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(a!=s)return!1;var u=t instanceof Date,c=n instanceof Date;if(u!=c)return!1;if(u&&c)return t.getTime()==n.getTime();var l=t instanceof RegExp,f=n instanceof RegExp;if(l!=f)return!1;if(l&&f)return t.toString()==n.toString();var d=keyList(t);if((o=d.length)!==keyList(n).length)return!1;for(r=o;0!=r--;)if(!hasProp.call(n,d[r]))return!1;for(r=o;0!=r--;)if(!e(t[i=d[r]],n[i]))return!1;return!0}return t!=t&&n!=n},userAttrsToStringify=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function btoa(e){var t=unescape(encodeURIComponent(e));return fromByteArray_1(stringToBytes(t))}function stringToBytes(e){for(var t=[],n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}function base64URLEncode(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function clone(e){return JSON.parse(JSON.stringify(e))}function deepEquals(e,t){return fastDeepEqual(e,t)}function onNextTick(e){setTimeout(e,0)}function wrapPromiseCallback(e,t){var n=e.then(function(e){return t&&setTimeout(function(){t(null,e)},0),e},function(e){if(!t)return Promise.reject(e);setTimeout(function(){t(e,null)},0)});return t?void 0:n}function transformValuesToVersionedValues(e){var t={};for(var n in e)objectHasOwnProperty(e,n)&&(t[n]={value:e[n],version:0});return t}function transformVersionedValuesToValues(e){var t={};for(var n in e)objectHasOwnProperty(e,n)&&(t[n]=e[n].value);return t}function chunkUserEventsForUrl(e,t){for(var n,r=t.slice(0),o=[],i=e;0<r.length;){for(n=[];0<i;){var a=r.shift();if(!a)break;(i-=base64URLEncode(JSON.stringify(a)).length)<0&&0<n.length?r.unshift(a):n.push(a)}i=e,o.push(n)}return o}function getLDUserAgentString(e){var t=e.version||"3.2.6";return e.userAgent+"/"+t}function getLDHeaders(e,t){if(t&&!t.sendLDHeaders)return{};var n={"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)};return t&&t.wrapperName&&(n["X-LaunchDarkly-Wrapper"]=t.wrapperVersion?t.wrapperName+"/"+t.wrapperVersion:t.wrapperName),n}function extend(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce(function(e,t){return _objectSpread2({},e,{},t)},{})}function objectHasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function sanitizeUser(e){if(!e)return e;var t;for(var n in userAttrsToStringify){var r=userAttrsToStringify[n],o=e[r];void 0!==o&&"string"!=typeof o&&((t=t||_objectSpread2({},e))[r]=String(o))}return t||e}var utils=Object.freeze({__proto__:null,btoa:btoa,base64URLEncode:base64URLEncode,clone:clone,deepEquals:deepEquals,onNextTick:onNextTick,wrapPromiseCallback:wrapPromiseCallback,transformValuesToVersionedValues:transformValuesToVersionedValues,transformVersionedValuesToValues:transformVersionedValuesToValues,chunkUserEventsForUrl:chunkUserEventsForUrl,getLDUserAgentString:getLDUserAgentString,getLDHeaders:getLDHeaders,extend:extend,objectHasOwnProperty:objectHasOwnProperty,sanitizeUser:sanitizeUser});function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}for(var rngBrowser=createCommonjsModule(function(e){var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var n=new Uint8Array(16);e.exports=function(){return t(n),n}}else{var r=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}}}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,t){var n=t||0,r=byteToHex;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,t,n){var r=t&&n||0,o=t||[],i=(e=e||{}).node||_nodeId,a=void 0!==e.clockseq?e.clockseq:_clockseq;if(null==i||null==a){var s=rngBrowser();null==i&&(i=_nodeId=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==a&&(a=_clockseq=16383&(s[6]<<8|s[7]))}var u=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:_lastNSecs+1,l=u-_lastMSecs+(c-_lastNSecs)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||_lastMSecs<u)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=u,_clockseq=a;var f=(1e4*(268435455&(u+=122192928e5))+(_lastNSecs=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var d=u/4294967296*1e4&268435455;o[r++]=d>>>8&255,o[r++]=255&d,o[r++]=d>>>24&15|16,o[r++]=d>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var v=0;v<6;++v)o[r+v]=i[v];return t||bytesToUuid_1(o)}var v1_1=v1,MAX_URL_LENGTH=2e3;function EventSender(s,e,t){var n="/a/"+e+".gif",u=extend({"Content-Type":"application/json"},getLDHeaders(s,t)),c=s.httpFallbackPing,l={};return l.sendChunk=function(e,r,o,t){var i=JSON.stringify(e),a=o?null:v1_1();return t?function t(n){var e=o?u:extend({},u,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return s.httpRequest("POST",r,e,i).promise.then(function(e){if(e)return 400<=e.status&&isHttpErrorRecoverable(e.status)&&n?t(!1):function(e){var t={status:e.status},n=e.header("date");if(n){var r=Date.parse(n);r&&(t.serverTime=r)}return t}(e)}).catch(function(){return n?t(!1):Promise.reject()})}(!0).catch(function(){}):(c&&c(r+n+"?d="+base64URLEncode(i)),Promise.resolve())},l.sendEvents=function(e,t,n){if(!s.httpRequest)return Promise.resolve();var r,o=s.httpAllowsPost();r=o?[e]:chunkUserEventsForUrl(MAX_URL_LENGTH-t.length,e);for(var i=[],a=0;a<r.length;a++)i.push(l.sendChunk(r[a],t,n,o));return Promise.all(i)},l}function EventSummarizer(){var e={},a=0,s=0,u={};return e.summarizeEvent=function(e){if("feature"===e.kind){var t=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),n=u[t];n?n.count=n.count+1:u[t]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>s&&(s=e.creationDate)}},e.getSummary=function(){var e={},t=!0;for(var n in u){var r=u[n],o=e[r.key];o||(o={default:r.default,counters:[]},e[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),t=!1}return t?null:{startDate:a,endDate:s,features:e}},e.clearSummary=function(){s=a=0,u={}},e}function UserFilter(e){var t={},u=e.allAttributesPrivate,c=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return t.filterUser=function(e){if(!e)return null;function t(r,o){return Object.keys(r).reduce(function(e,t){var n=e;return o(t)&&(!function(e){return!l[e]&&(u||-1!==i.indexOf(e)||-1!==c.indexOf(e))}(t)?n[0][t]=r[t]:n[1][t]=!0),n},[{},{}])}var i=e.privateAttributeNames||[],n=t(e,function(e){return f[e]}),r=n[0],o=n[1];if(e.custom){var a=t(e.custom,function(){return!0});r.custom=a[0],o=extend({},o,a[1])}var s=Object.keys(o);return s.length&&(s.sort(),r.privateAttrs=s),r},t}function errorString(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var clientInitialized=function(){return"LaunchDarkly client initialized"},docLink=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",clientNotReady=function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutUser=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},invalidContentType=function(e){return'Expected application/json content type but got "'+e+'"'},invalidKey=function(){return"Event key must be a string"},localStorageUnavailable=function(){return"localStorage is unavailable"},localStorageUnavailableForUserId=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},networkError=function(e){return"network error"+(e?" ("+e+")":"")},unknownCustomEventKey=function(e){return'Custom event "'+e+'" does not exist'},environmentNotFound=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+docLink},environmentNotSpecified=function(){return"No environment/client-side ID was specified."+docLink},errorFetchingFlags=function(e){return"Error fetching flag settings: "+errorString(e)},userNotSpecified=function(){return"No user specified."+docLink},invalidUser=function(){return"Invalid user specified."+docLink},bootstrapOldFormat=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+docLink},bootstrapInvalid=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated=function(e,t){return t?'"'+e+'" is deprecated, please use "'+t+'"':'"'+e+'" is deprecated'},httpErrorMessage=function(e,t,n){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+t+" - "+(isHttpErrorRecoverable(e)?n:"giving up permanently")},httpUnavailable=function(){return"Cannot make HTTP requests in this environment."+docLink},identifyDisabled=function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing=function(){return"Closing stream connection"},streamConnecting=function(e){return"Opening stream connection to "+e},streamError=function(e,t){return"Error on stream connection: "+errorString(e)+", will continue retrying every "+t+" milliseconds."},unknownOption=function(e){return'Ignoring unknown config option "'+e+'"'},wrongOptionType=function(e,t,n){return'Config option "'+e+'" should be of type '+t+", got "+n+", using default value"},wrongOptionTypeBoolean=function(e,t){return'Config option "'+e+'" should be a boolean, got '+t+", converting to boolean"},optionBelowMinimum=function(e,t,n){return'Config option "'+e+'" was set to '+t+", changing to minimum value of "+n},debugPolling=function(e){return"polling for feature flags at "+e},debugStreamPing=function(){return"received ping message from stream"},debugStreamPut=function(){return"received streaming update for all flags"},debugStreamPatch=function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamDelete=function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugEnqueueingEvent=function(e){return'enqueueing "'+e+'" event'},debugPostingEvents=function(e){return"sending "+e+" events"},debugPostingDiagnosticEvent=function(e){return"sending diagnostic event ("+e.kind+")"},messages=Object.freeze({__proto__:null,clientInitialized:clientInitialized,clientNotReady:clientNotReady,eventCapacityExceeded:eventCapacityExceeded,eventWithoutUser:eventWithoutUser,invalidContentType:invalidContentType,invalidKey:invalidKey,localStorageUnavailable:localStorageUnavailable,localStorageUnavailableForUserId:localStorageUnavailableForUserId,networkError:networkError,unknownCustomEventKey:unknownCustomEventKey,environmentNotFound:environmentNotFound,environmentNotSpecified:environmentNotSpecified,errorFetchingFlags:errorFetchingFlags,userNotSpecified:userNotSpecified,invalidUser:invalidUser,bootstrapOldFormat:bootstrapOldFormat,bootstrapInvalid:bootstrapInvalid,deprecated:deprecated,httpErrorMessage:httpErrorMessage,httpUnavailable:httpUnavailable,identifyDisabled:identifyDisabled,streamClosing:streamClosing,streamConnecting:streamConnecting,streamError:streamError,unknownOption:unknownOption,wrongOptionType:wrongOptionType,wrongOptionTypeBoolean:wrongOptionTypeBoolean,optionBelowMinimum:optionBelowMinimum,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents,debugPostingDiagnosticEvent:debugPostingDiagnosticEvent});function EventProcessor(e,t,n){var r,o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,a={},s=(5<arguments.length&&void 0!==arguments[5]?arguments[5]:null)||EventSender(e,n,t),u=t.eventsUrl+"/events/bulk/"+n,c=EventSummarizer(),l=UserFilter(t),f=t.inlineUsersInEvents,d=t.samplingInterval,v=t.eventCapacity,g=t.flushInterval,p=t.logger,m=[],y=0,h=!1,b=!1;function E(){return 0===d||0===Math.floor(Math.random()*d)}function k(e){m.length<v?(m.push(e),b=!1):(b||(b=!0,p.warn(eventCapacityExceeded())),o&&o.incrementDroppedEvents())}return a.enqueue=function(e){if(!h){var t=!1,n=!1;if(c.summarizeEvent(e),"feature"===e.kind?E()&&(t=!!e.trackEvents,n=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>y&&e.debugEventsUntilDate>(new Date).getTime())}(e)):t=E(),t&&k(function(e){var t=extend({},e);return f||"identify"===e.kind?t.user=l.filterUser(e.user):(t.userKey=e.user.key,delete t.user),"feature"===e.kind&&(delete t.trackEvents,delete t.debugEventsUntilDate),t}(e)),n){var r=extend({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,k(r)}}},a.flush=function(){if(h)return Promise.resolve();var e=m,t=c.getSummary();return c.clearSummary(),t&&(t.kind="summary",e.push(t)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(m=[],p.debug(debugPostingEvents(e.length)),s.sendEvents(e,u).then(function(e){e&&(e.serverTime&&(y=e.serverTime),isHttpErrorRecoverable(e.status)||(h=!0),400<=e.status&&onNextTick(function(){i.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},a.start=function(){r=setTimeout(function e(){a.flush(),r=setTimeout(e,g)},g)},a.stop=function(){clearTimeout(r)},a}function EventEmitter(t){var e={},o={};return e.on=function(e,t,n){o[e]=o[e]||[],o[e]=o[e].concat({handler:t,context:n})},e.off=function(e,t,n){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===t&&o[e][r].context===n&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var t=o[e].slice(0),n=0;n<t.length;n++)t[n].handler.apply(t[n].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(!function(e){return!!o[e]}("error")?(t||console).error(e.message):this.emit("error",e))},e}var readyEvent="ready",successEvent="initialized",failureEvent="failed";function InitializationStateTracker(r){var t=!1,n=!1,o=null,e=null,i=new Promise(function(t){r.on(readyEvent,function e(){r.off(readyEvent,e),t()})}).catch(function(){});return{getInitializationPromise:function(){return e||(t?Promise.resolve():n?Promise.reject(o):e=new Promise(function(t,n){r.on(successEvent,function e(){r.off(successEvent,e),t()}),r.on(failureEvent,function e(t){r.off(failureEvent,e),n(t)})}))},getReadyPromise:function(){return i},signalSuccess:function(){t||n||(t=!0,r.emit(successEvent),r.emit(readyEvent))},signalFailure:function(e){t||n||(n=!0,o=e,r.emit(failureEvent,e),r.emit(readyEvent)),r.maybeReportError(e)}}}var InitializationState=InitializationStateTracker;function Store(n,r,o,i,a){var s={};function u(){var e="",t=i.getUser();return t&&(e=o||btoa(JSON.stringify(t))),"ld:"+r+":"+e}return s.loadFlags=function(){return n.get(u()).then(function(e){if(null==e)return null;try{var t=JSON.parse(e);if(t){var n=t.$schema;void 0===n||n<1?t=transformValuesToVersionedValues(t):delete t.$schema}return t}catch(e){return s.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},s.saveFlags=function(e){var t=extend({},e,{$schema:1});return n.set(u(),JSON.stringify(t)).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},s.clearFlags=function(){return n.clear(u()).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},s}function Stream(o,e,i,t){var a,s=e.streamUrl,u=e.logger,n={},c=s+"/eval/"+i,l=e.useReport,f=e.evaluationReasons,r=e.streamReconnectDelay,d=getLDHeaders(o,e),v=!1,g=null,p=null,m=null,y=null,h=null;function b(e){v||(u.warn(streamError(e,r)),v=!0),D(!1),S(),E(r)}function E(e){p||(e?p=setTimeout(k,e):k())}function k(){var e;p=null;var t="",n={headers:d};if(o.eventSourceFactory){for(var r in null!=y&&(t="h="+y),l?o.eventSourceAllowsReport?(e=c,n.method="REPORT",n.headers["Content-Type"]="application/json",n.body=JSON.stringify(m)):(e=s+"/ping/"+i,t=""):e=c+"/"+base64URLEncode(JSON.stringify(m)),f&&(t=t+(t?"&":"")+"withReasons=true"),e=e+(t?"?":"")+t,S(),u.info(streamConnecting(e)),a=(new Date).getTime(),g=o.eventSourceFactory(e,n),h)objectHasOwnProperty(h,r)&&g.addEventListener(r,h[r]);g.onerror=b}}function S(){g&&(u.info(streamClosing()),g.close(),g=null)}function D(e){a&&t&&t.recordStreamInit(a,!e,(new Date).getTime()-a),a=null}return n.connect=function(e,t,n){m=e,y=t,h={};function r(t){h[t]=function(e){D(!(v=!1)),n[t]&&n[t](e)}}for(var o in n||{})r(o);E()},n.disconnect=function(){clearTimeout(p),p=null,S()},n.isConnected=function(){return!!(g&&o.eventSourceIsActive&&o.eventSourceIsActive(g))},n}function promiseCoalescer(n){var r,o,i,a,e={addPromise:function(t,e){r=t,o&&o(),o=e,t.then(function(e){r===t&&(i(e),n&&n())},function(e){r===t&&(a(e),n&&n())})}};return e.resultPromise=new Promise(function(e,t){i=e,a=t}),e}var jsonContentType="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(s,u,a){var c=u.baseUrl,l=u.useReport,f=u.evaluationReasons,d=u.logger,e={},v={};function g(e,t){if(!s.httpRequest)return new Promise(function(e,t){t(new LDFlagFetchError(httpUnavailable()))});var n=t?"REPORT":"GET",r=getLDHeaders(s,u);t&&(r["Content-Type"]=jsonContentType);var o=v[e];o||(o=promiseCoalescer(function(){delete v[e]}),v[e]=o);var i=s.httpRequest(n,e,r,t),a=i.promise.then(function(e){if(200!==e.status)return Promise.reject(getResponseError(e));if(e.header("content-type")&&e.header("content-type").startsWith(jsonContentType))return JSON.parse(e.body);var t=invalidContentType(e.header("content-type")||"");return Promise.reject(new LDFlagFetchError(t))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return o.addPromise(a,function(){i.cancel&&i.cancel()}),o.resultPromise}return e.fetchJSON=function(e){return g(c+e,null)},e.fetchFlagSettings=function(e,t){var n,r,o,i="";return l?(r=[c,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(n=base64URLEncode(JSON.stringify(e)),r=[c,"/sdk/evalx/",a,"/users/",n].join("")),t&&(i="h="+t),f&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,d.debug(debugPolling(r)),g(r,o)},e}function Identity(e,t){var n,r={};return r.setUser=function(e){(n=sanitizeUser(e))&&t&&t(clone(n))},r.getUser=function(){return n?clone(n):null},e&&r.setUser(e),r}var ldUserIdKey="ld:$anonUserId";function UserValidator(r,o){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var n=clone(e);return null!==n.key&&void 0!==n.key?(n.key=n.key.toString(),Promise.resolve(n)):n.anonymous?(r?r.get(ldUserIdKey).catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return n.key=e,n;var t=v1_1();return function(e){return r?r.set(ldUserIdKey,e).catch(function(){o.warn(localStorageUnavailableForUserId())}):Promise.resolve()}(n.key=t).then(function(){return n})}):Promise.reject(new LDInvalidUserError(invalidUser()))},e}var baseOptionDefs={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function validate(e,t,n,r){var a=extend({logger:{default:r}},baseOptionDefs,n),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function s(e){onNextTick(function(){t&&t.maybeReportError(new LDInvalidArgumentError(e))})}var i,u,c,l,f=extend({},e||{});function d(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var t=_typeof(e);return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"}}return i=f,Object.keys(o).forEach(function(e){if(void 0!==i[e]){var t=o[e];r&&r.warn(deprecated(e,t)),t&&(void 0===i[t]&&(i[t]=i[e]),delete i[e])}}),u=extend({},f),Object.keys(a).forEach(function(e){void 0!==u[e]&&null!==u[e]||(u[e]=a[e]&&a[e].default)}),l=extend({},c=f=u),Object.keys(c).forEach(function(e){var t=c[e];if(null!=t){var n=a[e];if(void 0===n)s(unknownOption(e));else{var r=n.type||d(n.default);if("any"!==r){var o=r.split("|"),i=d(t);o.indexOf(i)<0?"boolean"===r?(l[e]=!!t,s(wrongOptionTypeBoolean(e,i))):(s(wrongOptionType(e,r,i)),l[e]=n.default):"number"===i&&void 0!==n.minimum&&t<n.minimum&&(s(optionBelowMinimum(e,t,n.minimum)),l[e]=n.minimum)}}}}),f=l}var configuration=Object.freeze({__proto__:null,baseOptionDefs:baseOptionDefs,validate:validate}),baseOptionDefs$1=configuration.baseOptionDefs;function DiagnosticId(e){var t={diagnosticId:v1_1()};return e&&(t.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),t}function DiagnosticsAccumulator(e){var t,n,r,o;function i(e){t=e,r=n=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:t,droppedEvents:n,eventsInLastBatch:r,streamInits:o}},setProps:function(e){t=e.dataSinceDate,n=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){n++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,t,n){var r={timestamp:e,failed:t,durationMillis:n};o.push(r)},reset:i}}function DiagnosticsManager(t,e,n,r,o,i){var a,s,u=!!t.diagnosticUseCombinedEvent,c="ld:"+r+":$diagnostics",l=o.eventsUrl+"/events/diagnostic/"+r,f=o.diagnosticRecordingInterval,d=e,v=!!o.streaming,g={};function p(){return{sdk:function(){var e=_objectSpread2({},t.diagnosticSdkData);o.wrapperName&&(e.wrapperName=o.wrapperName);o.wrapperVersion&&(e.wrapperVersion=o.wrapperVersion);return e}(),configuration:{customBaseURI:o.baseUrl!==baseOptionDefs$1.baseUrl.default,customStreamURI:o.streamUrl!==baseOptionDefs$1.streamUrl.default,customEventsURI:o.eventsUrl!==baseOptionDefs$1.eventsUrl.default,eventsCapacity:o.eventCapacity,eventsFlushIntervalMillis:o.flushInterval,reconnectTimeMillis:o.streamReconnectDelay,streamingDisabled:!v,allAttributesPrivate:!!o.allAttributesPrivate,inlineUsersInEvents:!!o.inlineUsersInEvents,diagnosticRecordingIntervalMillis:o.diagnosticRecordingInterval,usingSecureMode:!!o.hash,bootstrapMode:!!o.bootstrap,fetchGoalsDisabled:!o.fetchGoals,allowFrequentDuplicateEvents:!!o.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!o.sendEventsOnlyForVariation},platform:t.diagnosticPlatformData}}function m(e){o.logger&&o.logger.debug(messages.debugPostingDiagnosticEvent(e)),n.sendEvents(e,l,!0).then(function(){}).catch(function(){})}function y(){m(function(){var e=(new Date).getTime(),t=_objectSpread2({kind:u?"diagnostic-combined":"diagnostic",id:i,creationDate:e},d.getProps());return u&&(t=_objectSpread2({},t,{},p())),d.reset(e),t}()),s=setTimeout(y,f),a=(new Date).getTime(),u&&function(){if(t.localStorage){var e=_objectSpread2({},d.getProps());t.localStorage.set(c,JSON.stringify(e),function(){})}}()}return g.start=function(){u?function(n){if(!t.localStorage)return n(!1);t.localStorage.get(c).then(function(e){if(e)try{var t=JSON.parse(e);d.setProps(t),a=t.dataSinceDate}catch(e){}n(!0)}).catch(function(){n(!1)})}(function(e){if(e){var t=(a||0)+f,n=(new Date).getTime();t<=n?y():s=setTimeout(y,t-n)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,f)}):(m(_objectSpread2({kind:"diagnostic-init",id:i,creationDate:d.getProps().dataSinceDate},p())),s=setTimeout(y,f))},g.stop=function(){s&&clearTimeout(s)},g.setStreaming=function(e){v=e},g}var diagnosticEvents={DiagnosticId:DiagnosticId,DiagnosticsAccumulator:DiagnosticsAccumulator,DiagnosticsManager:DiagnosticsManager},diagnosticEvents_1=diagnosticEvents.DiagnosticId,diagnosticEvents_2=diagnosticEvents.DiagnosticsAccumulator,diagnosticEvents_3=diagnosticEvents.DiagnosticsManager;function createConsoleLogger(e,t){var i,a=["debug","info","warn","error"];i=null!=t?""===t?"":t+" ":"LD: ";var s=0;e&&(s="none"===e?100:a.indexOf(e));var n={};function r(e,t,n){if(s<=e&&console){var r=console[t];if(r){var o=e<a.length?a[e]:"?";r.call(console,i+"["+o+"] "+n)}}}return n.debug=function(e){return r(0,"log",e)},n.info=function(e){return r(1,"info",e)},n.warn=function(e){return r(2,"warn",e)},n.error=function(e){return r(3,"error",e)},n}var changeEvent="change",internalChangeEvent="internal-change";function initialize(e,t,n,o,r){var a=function(){if(n&&n.logger)return n.logger;return r&&r.logger&&r.logger.default||createConsoleLogger("warn")}(),s=EventEmitter(a),i=InitializationState(s),f=validate(n,s,r,a),u=f.sendEvents,c=e,l=f.hash,d=EventSender(o,c,f),v=f.sendEvents&&!f.diagnosticOptOut,g=v?diagnosticEvents_1(c):null,p=v?diagnosticEvents_2((new Date).getTime()):null,m=v?diagnosticEvents_3(o,p,d,c,f,g):null;m&&m.start();var y,h,b,E,k=Stream(o,f,c,p),S=f.eventProcessor||EventProcessor(o,f,c,p,s,d),D=Requestor(o,f,c),w={},U={},P=f.streaming,I=!1,O=!1,L=!0,T=f.stateProvider,C=Identity(null,function(e){if(T)return;e&&j({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),F=UserValidator(o.localStorage,a);function j(e){c&&(T&&T.enqueueEvent&&T.enqueueEvent(e)||(e.user?(L=!1,!u||O||o.isDoNotTrack()||(a.debug(debugEnqueueingEvent(e.kind)),S.enqueue(e))):L&&(a.warn(eventWithoutUser()),L=!1)))}function R(e,t,n,r){var o=C.getUser(),i=new Date,a=t?t.value:null;if(!f.allowFrequentDuplicateEvents){var s=JSON.stringify(a)+(o&&o.key?o.key:"")+e,u=w[s];if(u&&i-u<3e5)return;w[s]=i}var c={kind:"feature",key:e,user:o,value:a,variation:t?t.variationIndex:null,default:n,creationDate:i.getTime()},l=U[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&t&&(c.reason=t.reason),j(c)}function _(e,t,n,r){var o;if(U&&objectHasOwnProperty(U,e)&&U[e]&&!U[e].deleted){var i=U[e];o=N(i),null!==i.value&&void 0!==i.value||(o.value=t)}else o={value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return n&&R(e,o,t,r),o}function N(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function x(){h=!0,C.getUser()&&k.connect(C.getUser(),l,{ping:function(){a.debug(debugStreamPing()),D.fetchFlagSettings(C.getUser(),l).then(function(e){return V(e||{})}).catch(function(e){s.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){var t=JSON.parse(e.data);a.debug(debugStreamPut()),V(t)},patch:function(e){var t=JSON.parse(e.data),n=U[t.key];if(!n||!n.version||!t.version||n.version<t.version){a.debug(debugStreamPatch(t.key));var r={},o=extend({},t);delete o.key;var i=N(U[t.key]=o);r[t.key]=n?{previous:n.value,current:i}:{current:i},q(r)}else a.debug(debugStreamPatchIgnored(t.key))},delete:function(e){var t=JSON.parse(e.data);if(!U[t.key]||U[t.key].version<t.version){a.debug(debugStreamDelete(t.key));var n={};U[t.key]&&!U[t.key].deleted&&(n[t.key]={previous:U[t.key].value}),U[t.key]={version:t.version,deleted:!0},q(n)}else a.debug(debugStreamDeleteIgnored(t.key))}})}function A(){h&&(k.disconnect(),h=!1)}function V(e){var t={};if(!e)return Promise.resolve();for(var n in U)objectHasOwnProperty(U,n)&&U[n]&&(e[n]&&!deepEquals(e[n].value,U[n].value)?t[n]={previous:U[n].value,current:N(e[n])}:e[n]&&!e[n].deleted||(t[n]={previous:U[n].value}));for(var r in e)objectHasOwnProperty(e,r)&&e[r]&&(!U[r]||U[r].deleted)&&(t[r]={current:N(e[r])});return U=_objectSpread2({},e),q(t).catch(function(){})}function q(o){var e=Object.keys(o);if(0<e.length){var i={};e.forEach(function(e){var t=o[e].current,n=t?t.value:void 0,r=o[e].previous;s.emit(changeEvent+":"+e,n,r),i[e]=t?{current:n,previous:r}:{previous:r}}),s.emit(changeEvent,i),s.emit(internalChangeEvent,U),f.sendEventsOnlyForVariation||T||e.forEach(function(e){R(e,o[e].current)})}return y&&E?E.saveFlags(U).catch(function(){return null}):Promise.resolve()}function M(){var e=P||b&&void 0===P;e&&!h?x():!e&&h&&A(),m&&m.setStreaming(e)}function z(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}if(o.localStorage&&(E=new Store(o.localStorage,c,l,C,a)),"string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(E?y=!0:a.warn(localStorageUnavailable())),"object"===_typeof(f.bootstrap)&&(U=function(n){var e=Object.keys(n),r="$flagsState",o=n[r];!o&&e.length&&a.warn(bootstrapOldFormat()),!1===n.$valid&&a.warn(bootstrapInvalid());var i={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var t={value:n[e]};o&&o[e]?t=extend(t,o[e]):t.version=0,i[e]=t}}),i}(f.bootstrap)),T){var H=T.getInitialState();H?B(H):T.on("init",B),T.on("update",function(e){e.user&&C.setUser(e.user);e.flags&&V(e.flags)})}else(e?F.validateUser(t).then(function(e){return C.setUser(e),"object"===_typeof(f.bootstrap)?K():y?E.loadFlags().catch(function(){return null}).then(function(e){return null==e?(U={},D.fetchFlagSettings(C.getUser(),l).then(function(e){return V(e||{})}).then(K).catch(function(e){J(new LDFlagFetchError(errorFetchingFlags(e)))})):(U=e,onNextTick(K),D.fetchFlagSettings(C.getUser(),l).then(function(e){return V(e)}).catch(function(e){return s.maybeReportError(e)}))}):D.fetchFlagSettings(C.getUser(),l).then(function(e){U=e||{},K()}).catch(function(e){U={},J(e)})}):Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()))).catch(J);function B(e){c=e.environment,C.setUser(e.user),U=_objectSpread2({},e.flags),onNextTick(K)}function K(){a.info(clientInitialized()),I=!0,M(),i.signalSuccess()}function J(e){i.signalFailure(e)}return{client:{waitForInitialization:function(){return i.getInitializationPromise()},waitUntilReady:function(){return i.getReadyPromise()},identify:function(e,r,t){return O?wrapPromiseCallback(Promise.resolve({}),t):T?(a.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(U)),t)):wrapPromiseCallback((y&&E?E.clearFlags():Promise.resolve()).then(function(){return F.validateUser(e)}).then(function(n){return D.fetchFlagSettings(n,r).then(function(e){var t=transformVersionedValuesToValues(e);return C.setUser(n),l=r,e?V(e).then(function(){return t}):t})}).then(function(e){return h&&x(),e}).catch(function(e){return s.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return C.getUser()},variation:function(e,t){return _(e,t,!0,!1).value},variationDetail:function(e,t){return _(e,t,!0,!0)},track:function(e,t,n){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&a.warn(unknownCustomEventKey(e));var r={kind:"custom",key:e,user:C.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()};null!=t&&(r.data=t),null!=n&&(r.metricValue=n),j(r)}else s.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},on:function(e,t,n){z(e)?(b=!0,I&&M(),s.on(e,t,n)):s.on.apply(s,arguments)},off:function(e){if(s.off.apply(s,arguments),z(e)){var t=!1;s.getEvents().forEach(function(e){z(e)&&0<s.getEventListenerCount(e)&&(t=!0)}),t||(b=!1,h&&void 0===P&&A())}},setStreaming:function(e){var t=null===e?void 0:e;t!==P&&(P=t,M())},flush:function(e){return wrapPromiseCallback(u?S.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!U)return e;for(var t in U)objectHasOwnProperty(U,t)&&(e[t]=_(t,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){if(O)return wrapPromiseCallback(Promise.resolve(),e);function t(){O=!0,U={}}return wrapPromiseCallback(Promise.resolve().then(function(){if(A(),m&&m.stop(),u)return S.stop(),S.flush()}).then(t).catch(t),e)}},options:f,emitter:s,ident:C,logger:a,requestor:D,start:function(){u&&(m&&m.start(),S.start())},enqueueEvent:j,getFlagsInternal:function(){return U},getEnvironmentId:function(){return c},internalChangeEventName:internalChangeEvent}}var version="3.2.6";exports.createConsoleLogger=createConsoleLogger,exports.errors=errors,exports.initialize=initialize,exports.messages=messages,exports.utils=utils,exports.version=version;
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function _objectSpread2(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(n,!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(n).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function createCustomError(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return(t.prototype=new Error).name=e,t.prototype.constructor=t}Object.defineProperty(exports,"__esModule",{value:!0});var LDUnexpectedResponseError=createCustomError("LaunchDarklyUnexpectedResponseError"),LDInvalidEnvironmentIdError=createCustomError("LaunchDarklyInvalidEnvironmentIdError"),LDInvalidUserError=createCustomError("LaunchDarklyInvalidUserError"),LDInvalidEventKeyError=createCustomError("LaunchDarklyInvalidEventKeyError"),LDInvalidArgumentError=createCustomError("LaunchDarklyInvalidArgumentError"),LDFlagFetchError=createCustomError("LaunchDarklyFlagFetchError");function isHttpErrorRecoverable(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({__proto__:null,LDUnexpectedResponseError:LDUnexpectedResponseError,LDInvalidEnvironmentIdError:LDInvalidEnvironmentIdError,LDInvalidUserError:LDInvalidUserError,LDInvalidEventKeyError:LDInvalidEventKeyError,LDInvalidArgumentError:LDInvalidArgumentError,LDFlagFetchError:LDFlagFetchError,isHttpErrorRecoverable:isHttpErrorRecoverable}),fromByteArray_1=fromByteArray,lookup=[],revLookup=[],code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,t,n){for(var r,o=[],i=t;i<n;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(r));return o.join("")}function fromByteArray(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(encodeChunk(e,a,s<a+i?s:a+i));return 1==r?(t=e[n-1],o.push(lookup[t>>2]+lookup[t<<4&63]+"==")):2==r&&(t=(e[n-2]<<8)+e[n-1],o.push(lookup[t>>10]+lookup[t>>4&63]+lookup[t<<2&63]+"=")),o.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63;var isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i,a=isArray(t),s=isArray(n);if(a&&s){if((o=t.length)!=n.length)return!1;for(r=o;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(a!=s)return!1;var u=t instanceof Date,c=n instanceof Date;if(u!=c)return!1;if(u&&c)return t.getTime()==n.getTime();var l=t instanceof RegExp,f=n instanceof RegExp;if(l!=f)return!1;if(l&&f)return t.toString()==n.toString();var d=keyList(t);if((o=d.length)!==keyList(n).length)return!1;for(r=o;0!=r--;)if(!hasProp.call(n,d[r]))return!1;for(r=o;0!=r--;)if(!e(t[i=d[r]],n[i]))return!1;return!0}return t!=t&&n!=n},userAttrsToStringify=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function btoa(e){var t=unescape(encodeURIComponent(e));return fromByteArray_1(stringToBytes(t))}function stringToBytes(e){for(var t=[],n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}function base64URLEncode(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function clone(e){return JSON.parse(JSON.stringify(e))}function deepEquals(e,t){return fastDeepEqual(e,t)}function onNextTick(e){setTimeout(e,0)}function wrapPromiseCallback(e,t){var n=e.then(function(e){return t&&setTimeout(function(){t(null,e)},0),e},function(e){if(!t)return Promise.reject(e);setTimeout(function(){t(e,null)},0)});return t?void 0:n}function transformValuesToVersionedValues(e){var t={};for(var n in e)objectHasOwnProperty(e,n)&&(t[n]={value:e[n],version:0});return t}function transformVersionedValuesToValues(e){var t={};for(var n in e)objectHasOwnProperty(e,n)&&(t[n]=e[n].value);return t}function chunkUserEventsForUrl(e,t){for(var n,r=t.slice(0),o=[],i=e;0<r.length;){for(n=[];0<i;){var a=r.shift();if(!a)break;(i-=base64URLEncode(JSON.stringify(a)).length)<0&&0<n.length?r.unshift(a):n.push(a)}i=e,o.push(n)}return o}function getLDUserAgentString(e){var t=e.version||"3.2.7";return e.userAgent+"/"+t}function getLDHeaders(e,t){if(t&&!t.sendLDHeaders)return{};var n={"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)};return t&&t.wrapperName&&(n["X-LaunchDarkly-Wrapper"]=t.wrapperVersion?t.wrapperName+"/"+t.wrapperVersion:t.wrapperName),n}function extend(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce(function(e,t){return _objectSpread2({},e,{},t)},{})}function objectHasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function sanitizeUser(e){if(!e)return e;var t;for(var n in userAttrsToStringify){var r=userAttrsToStringify[n],o=e[r];void 0!==o&&"string"!=typeof o&&((t=t||_objectSpread2({},e))[r]=String(o))}return t||e}var utils=Object.freeze({__proto__:null,btoa:btoa,base64URLEncode:base64URLEncode,clone:clone,deepEquals:deepEquals,onNextTick:onNextTick,wrapPromiseCallback:wrapPromiseCallback,transformValuesToVersionedValues:transformValuesToVersionedValues,transformVersionedValuesToValues:transformVersionedValuesToValues,chunkUserEventsForUrl:chunkUserEventsForUrl,getLDUserAgentString:getLDUserAgentString,getLDHeaders:getLDHeaders,extend:extend,objectHasOwnProperty:objectHasOwnProperty,sanitizeUser:sanitizeUser});function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}for(var rngBrowser=createCommonjsModule(function(e){var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var n=new Uint8Array(16);e.exports=function(){return t(n),n}}else{var r=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}}}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,t){var n=t||0,r=byteToHex;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,t,n){var r=t&&n||0,o=t||[],i=(e=e||{}).node||_nodeId,a=void 0!==e.clockseq?e.clockseq:_clockseq;if(null==i||null==a){var s=rngBrowser();null==i&&(i=_nodeId=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==a&&(a=_clockseq=16383&(s[6]<<8|s[7]))}var u=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:_lastNSecs+1,l=u-_lastMSecs+(c-_lastNSecs)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||_lastMSecs<u)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=u,_clockseq=a;var f=(1e4*(268435455&(u+=122192928e5))+(_lastNSecs=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var d=u/4294967296*1e4&268435455;o[r++]=d>>>8&255,o[r++]=255&d,o[r++]=d>>>24&15|16,o[r++]=d>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var v=0;v<6;++v)o[r+v]=i[v];return t||bytesToUuid_1(o)}var v1_1=v1,MAX_URL_LENGTH=2e3;function EventSender(s,e,t){var n="/a/"+e+".gif",u=extend({"Content-Type":"application/json"},getLDHeaders(s,t)),c=s.httpFallbackPing,l={};return l.sendChunk=function(e,r,o,t){var i=JSON.stringify(e),a=o?null:v1_1();return t?function t(n){var e=o?u:extend({},u,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return s.httpRequest("POST",r,e,i).promise.then(function(e){if(e)return 400<=e.status&&isHttpErrorRecoverable(e.status)&&n?t(!1):function(e){var t={status:e.status},n=e.header("date");if(n){var r=Date.parse(n);r&&(t.serverTime=r)}return t}(e)}).catch(function(){return n?t(!1):Promise.reject()})}(!0).catch(function(){}):(c&&c(r+n+"?d="+base64URLEncode(i)),Promise.resolve())},l.sendEvents=function(e,t,n){if(!s.httpRequest)return Promise.resolve();var r,o=s.httpAllowsPost();r=o?[e]:chunkUserEventsForUrl(MAX_URL_LENGTH-t.length,e);for(var i=[],a=0;a<r.length;a++)i.push(l.sendChunk(r[a],t,n,o));return Promise.all(i)},l}function EventSummarizer(){var e={},a=0,s=0,u={};return e.summarizeEvent=function(e){if("feature"===e.kind){var t=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),n=u[t];n?n.count=n.count+1:u[t]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>s&&(s=e.creationDate)}},e.getSummary=function(){var e={},t=!0;for(var n in u){var r=u[n],o=e[r.key];o||(o={default:r.default,counters:[]},e[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),t=!1}return t?null:{startDate:a,endDate:s,features:e}},e.clearSummary=function(){s=a=0,u={}},e}function UserFilter(e){var t={},u=e.allAttributesPrivate,c=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return t.filterUser=function(e){if(!e)return null;function t(r,o){return Object.keys(r).reduce(function(e,t){var n=e;return o(t)&&(!function(e){return!l[e]&&(u||-1!==i.indexOf(e)||-1!==c.indexOf(e))}(t)?n[0][t]=r[t]:n[1][t]=!0),n},[{},{}])}var i=e.privateAttributeNames||[],n=t(e,function(e){return f[e]}),r=n[0],o=n[1];if(e.custom){var a=t(e.custom,function(){return!0});r.custom=a[0],o=extend({},o,a[1])}var s=Object.keys(o);return s.length&&(s.sort(),r.privateAttrs=s),r},t}function errorString(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var clientInitialized=function(){return"LaunchDarkly client initialized"},docLink=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",clientNotReady=function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutUser=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},invalidContentType=function(e){return'Expected application/json content type but got "'+e+'"'},invalidKey=function(){return"Event key must be a string"},localStorageUnavailable=function(){return"localStorage is unavailable"},localStorageUnavailableForUserId=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},networkError=function(e){return"network error"+(e?" ("+e+")":"")},unknownCustomEventKey=function(e){return'Custom event "'+e+'" does not exist'},environmentNotFound=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+docLink},environmentNotSpecified=function(){return"No environment/client-side ID was specified."+docLink},errorFetchingFlags=function(e){return"Error fetching flag settings: "+errorString(e)},userNotSpecified=function(){return"No user specified."+docLink},invalidUser=function(){return"Invalid user specified."+docLink},bootstrapOldFormat=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+docLink},bootstrapInvalid=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated=function(e,t){return t?'"'+e+'" is deprecated, please use "'+t+'"':'"'+e+'" is deprecated'},httpErrorMessage=function(e,t,n){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+t+" - "+(isHttpErrorRecoverable(e)?n:"giving up permanently")},httpUnavailable=function(){return"Cannot make HTTP requests in this environment."+docLink},identifyDisabled=function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing=function(){return"Closing stream connection"},streamConnecting=function(e){return"Opening stream connection to "+e},streamError=function(e,t){return"Error on stream connection: "+errorString(e)+", will continue retrying every "+t+" milliseconds."},unknownOption=function(e){return'Ignoring unknown config option "'+e+'"'},wrongOptionType=function(e,t,n){return'Config option "'+e+'" should be of type '+t+", got "+n+", using default value"},wrongOptionTypeBoolean=function(e,t){return'Config option "'+e+'" should be a boolean, got '+t+", converting to boolean"},optionBelowMinimum=function(e,t,n){return'Config option "'+e+'" was set to '+t+", changing to minimum value of "+n},debugPolling=function(e){return"polling for feature flags at "+e},debugStreamPing=function(){return"received ping message from stream"},debugStreamPut=function(){return"received streaming update for all flags"},debugStreamPatch=function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamDelete=function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugEnqueueingEvent=function(e){return'enqueueing "'+e+'" event'},debugPostingEvents=function(e){return"sending "+e+" events"},debugPostingDiagnosticEvent=function(e){return"sending diagnostic event ("+e.kind+")"},messages=Object.freeze({__proto__:null,clientInitialized:clientInitialized,clientNotReady:clientNotReady,eventCapacityExceeded:eventCapacityExceeded,eventWithoutUser:eventWithoutUser,invalidContentType:invalidContentType,invalidKey:invalidKey,localStorageUnavailable:localStorageUnavailable,localStorageUnavailableForUserId:localStorageUnavailableForUserId,networkError:networkError,unknownCustomEventKey:unknownCustomEventKey,environmentNotFound:environmentNotFound,environmentNotSpecified:environmentNotSpecified,errorFetchingFlags:errorFetchingFlags,userNotSpecified:userNotSpecified,invalidUser:invalidUser,bootstrapOldFormat:bootstrapOldFormat,bootstrapInvalid:bootstrapInvalid,deprecated:deprecated,httpErrorMessage:httpErrorMessage,httpUnavailable:httpUnavailable,identifyDisabled:identifyDisabled,streamClosing:streamClosing,streamConnecting:streamConnecting,streamError:streamError,unknownOption:unknownOption,wrongOptionType:wrongOptionType,wrongOptionTypeBoolean:wrongOptionTypeBoolean,optionBelowMinimum:optionBelowMinimum,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents,debugPostingDiagnosticEvent:debugPostingDiagnosticEvent});function EventProcessor(e,t,n){var r,o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,a={},s=(5<arguments.length&&void 0!==arguments[5]?arguments[5]:null)||EventSender(e,n,t),u=t.eventsUrl+"/events/bulk/"+n,c=EventSummarizer(),l=UserFilter(t),f=t.inlineUsersInEvents,d=t.samplingInterval,v=t.eventCapacity,g=t.flushInterval,p=t.logger,m=[],y=0,h=!1,b=!1;function E(){return 0===d||0===Math.floor(Math.random()*d)}function k(e){m.length<v?(m.push(e),b=!1):(b||(b=!0,p.warn(eventCapacityExceeded())),o&&o.incrementDroppedEvents())}return a.enqueue=function(e){if(!h){var t=!1,n=!1;if(c.summarizeEvent(e),"feature"===e.kind?E()&&(t=!!e.trackEvents,n=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>y&&e.debugEventsUntilDate>(new Date).getTime())}(e)):t=E(),t&&k(function(e){var t=extend({},e);return f||"identify"===e.kind?t.user=l.filterUser(e.user):(t.userKey=e.user.key,delete t.user),"feature"===e.kind&&(delete t.trackEvents,delete t.debugEventsUntilDate),t}(e)),n){var r=extend({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,k(r)}}},a.flush=function(){if(h)return Promise.resolve();var e=m,t=c.getSummary();return c.clearSummary(),t&&(t.kind="summary",e.push(t)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(m=[],p.debug(debugPostingEvents(e.length)),s.sendEvents(e,u).then(function(e){e&&(e.serverTime&&(y=e.serverTime),isHttpErrorRecoverable(e.status)||(h=!0),400<=e.status&&onNextTick(function(){i.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},a.start=function(){r=setTimeout(function e(){a.flush(),r=setTimeout(e,g)},g)},a.stop=function(){clearTimeout(r)},a}function EventEmitter(t){var e={},o={};return e.on=function(e,t,n){o[e]=o[e]||[],o[e]=o[e].concat({handler:t,context:n})},e.off=function(e,t,n){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===t&&o[e][r].context===n&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var t=o[e].slice(0),n=0;n<t.length;n++)t[n].handler.apply(t[n].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(!function(e){return!!o[e]}("error")?(t||console).error(e.message):this.emit("error",e))},e}var readyEvent="ready",successEvent="initialized",failureEvent="failed";function InitializationStateTracker(r){var t=!1,n=!1,o=null,e=null,i=new Promise(function(t){r.on(readyEvent,function e(){r.off(readyEvent,e),t()})}).catch(function(){});return{getInitializationPromise:function(){return e||(t?Promise.resolve():n?Promise.reject(o):e=new Promise(function(t,n){r.on(successEvent,function e(){r.off(successEvent,e),t()}),r.on(failureEvent,function e(t){r.off(failureEvent,e),n(t)})}))},getReadyPromise:function(){return i},signalSuccess:function(){t||n||(t=!0,r.emit(successEvent),r.emit(readyEvent))},signalFailure:function(e){t||n||(n=!0,o=e,r.emit(failureEvent,e),r.emit(readyEvent)),r.maybeReportError(e)}}}var InitializationState=InitializationStateTracker;function Store(n,r,o,i,a){var s={};function u(){var e="",t=i.getUser();return t&&(e=o||btoa(JSON.stringify(t))),"ld:"+r+":"+e}return s.loadFlags=function(){return n.get(u()).then(function(e){if(null==e)return null;try{var t=JSON.parse(e);if(t){var n=t.$schema;void 0===n||n<1?t=transformValuesToVersionedValues(t):delete t.$schema}return t}catch(e){return s.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},s.saveFlags=function(e){var t=extend({},e,{$schema:1});return n.set(u(),JSON.stringify(t)).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},s.clearFlags=function(){return n.clear(u()).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},s}function Stream(o,e,i,t){var a,s=e.streamUrl,u=e.logger,n={},c=s+"/eval/"+i,l=e.useReport,f=e.evaluationReasons,r=e.streamReconnectDelay,d=getLDHeaders(o,e),v=!1,g=null,p=null,m=null,y=null,h=null;function b(e){v||(u.warn(streamError(e,r)),v=!0),D(!1),S(),E(r)}function E(e){p||(e?p=setTimeout(k,e):k())}function k(){var e;p=null;var t="",n={headers:d};if(o.eventSourceFactory){for(var r in null!=y&&(t="h="+y),l?o.eventSourceAllowsReport?(e=c,n.method="REPORT",n.headers["Content-Type"]="application/json",n.body=JSON.stringify(m)):(e=s+"/ping/"+i,t=""):e=c+"/"+base64URLEncode(JSON.stringify(m)),f&&(t=t+(t?"&":"")+"withReasons=true"),e=e+(t?"?":"")+t,S(),u.info(streamConnecting(e)),a=(new Date).getTime(),g=o.eventSourceFactory(e,n),h)objectHasOwnProperty(h,r)&&g.addEventListener(r,h[r]);g.onerror=b}}function S(){g&&(u.info(streamClosing()),g.close(),g=null)}function D(e){a&&t&&t.recordStreamInit(a,!e,(new Date).getTime()-a),a=null}return n.connect=function(e,t,n){m=e,y=t,h={};function r(t){h[t]=function(e){D(!(v=!1)),n[t]&&n[t](e)}}for(var o in n||{})r(o);E()},n.disconnect=function(){clearTimeout(p),p=null,S()},n.isConnected=function(){return!!(g&&o.eventSourceIsActive&&o.eventSourceIsActive(g))},n}function promiseCoalescer(n){var r,o,i,a,e={addPromise:function(t,e){r=t,o&&o(),o=e,t.then(function(e){r===t&&(i(e),n&&n())},function(e){r===t&&(a(e),n&&n())})}};return e.resultPromise=new Promise(function(e,t){i=e,a=t}),e}var jsonContentType="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(s,u,a){var c=u.baseUrl,l=u.useReport,f=u.evaluationReasons,d=u.logger,e={},v={};function g(e,t){if(!s.httpRequest)return new Promise(function(e,t){t(new LDFlagFetchError(httpUnavailable()))});var n=t?"REPORT":"GET",r=getLDHeaders(s,u);t&&(r["Content-Type"]=jsonContentType);var o=v[e];o||(o=promiseCoalescer(function(){delete v[e]}),v[e]=o);var i=s.httpRequest(n,e,r,t),a=i.promise.then(function(e){if(200!==e.status)return Promise.reject(getResponseError(e));if(e.header("content-type")&&e.header("content-type").startsWith(jsonContentType))return JSON.parse(e.body);var t=invalidContentType(e.header("content-type")||"");return Promise.reject(new LDFlagFetchError(t))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return o.addPromise(a,function(){i.cancel&&i.cancel()}),o.resultPromise}return e.fetchJSON=function(e){return g(c+e,null)},e.fetchFlagSettings=function(e,t){var n,r,o,i="";return l?(r=[c,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(n=base64URLEncode(JSON.stringify(e)),r=[c,"/sdk/evalx/",a,"/users/",n].join("")),t&&(i="h="+t),f&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,d.debug(debugPolling(r)),g(r,o)},e}function Identity(e,t){var n,r={};return r.setUser=function(e){(n=sanitizeUser(e))&&t&&t(clone(n))},r.getUser=function(){return n?clone(n):null},e&&r.setUser(e),r}var ldUserIdKey="ld:$anonUserId";function UserValidator(r,o){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var n=clone(e);return null!==n.key&&void 0!==n.key?(n.key=n.key.toString(),Promise.resolve(n)):n.anonymous?(r?r.get(ldUserIdKey).catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return n.key=e,n;var t=v1_1();return function(e){return r?r.set(ldUserIdKey,e).catch(function(){o.warn(localStorageUnavailableForUserId())}):Promise.resolve()}(n.key=t).then(function(){return n})}):Promise.reject(new LDInvalidUserError(invalidUser()))},e}var baseOptionDefs={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function validate(e,t,n,r){var a=extend({logger:{default:r}},baseOptionDefs,n),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function s(e){onNextTick(function(){t&&t.maybeReportError(new LDInvalidArgumentError(e))})}var i,u,c,l,f=extend({},e||{});function d(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var t=_typeof(e);return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"}}return i=f,Object.keys(o).forEach(function(e){if(void 0!==i[e]){var t=o[e];r&&r.warn(deprecated(e,t)),t&&(void 0===i[t]&&(i[t]=i[e]),delete i[e])}}),u=extend({},f),Object.keys(a).forEach(function(e){void 0!==u[e]&&null!==u[e]||(u[e]=a[e]&&a[e].default)}),l=extend({},c=f=u),Object.keys(c).forEach(function(e){var t=c[e];if(null!=t){var n=a[e];if(void 0===n)s(unknownOption(e));else{var r=n.type||d(n.default);if("any"!==r){var o=r.split("|"),i=d(t);o.indexOf(i)<0?"boolean"===r?(l[e]=!!t,s(wrongOptionTypeBoolean(e,i))):(s(wrongOptionType(e,r,i)),l[e]=n.default):"number"===i&&void 0!==n.minimum&&t<n.minimum&&(s(optionBelowMinimum(e,t,n.minimum)),l[e]=n.minimum)}}}}),f=l}var configuration=Object.freeze({__proto__:null,baseOptionDefs:baseOptionDefs,validate:validate}),baseOptionDefs$1=configuration.baseOptionDefs;function DiagnosticId(e){var t={diagnosticId:v1_1()};return e&&(t.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),t}function DiagnosticsAccumulator(e){var t,n,r,o;function i(e){t=e,r=n=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:t,droppedEvents:n,eventsInLastBatch:r,streamInits:o}},setProps:function(e){t=e.dataSinceDate,n=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){n++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,t,n){var r={timestamp:e,failed:t,durationMillis:n};o.push(r)},reset:i}}function DiagnosticsManager(t,e,n,r,o,i){var a,s,u=!!t.diagnosticUseCombinedEvent,c="ld:"+r+":$diagnostics",l=o.eventsUrl+"/events/diagnostic/"+r,f=o.diagnosticRecordingInterval,d=e,v=!!o.streaming,g={};function p(){return{sdk:function(){var e=_objectSpread2({},t.diagnosticSdkData);o.wrapperName&&(e.wrapperName=o.wrapperName);o.wrapperVersion&&(e.wrapperVersion=o.wrapperVersion);return e}(),configuration:{customBaseURI:o.baseUrl!==baseOptionDefs$1.baseUrl.default,customStreamURI:o.streamUrl!==baseOptionDefs$1.streamUrl.default,customEventsURI:o.eventsUrl!==baseOptionDefs$1.eventsUrl.default,eventsCapacity:o.eventCapacity,eventsFlushIntervalMillis:o.flushInterval,reconnectTimeMillis:o.streamReconnectDelay,streamingDisabled:!v,allAttributesPrivate:!!o.allAttributesPrivate,inlineUsersInEvents:!!o.inlineUsersInEvents,diagnosticRecordingIntervalMillis:o.diagnosticRecordingInterval,usingSecureMode:!!o.hash,bootstrapMode:!!o.bootstrap,fetchGoalsDisabled:!o.fetchGoals,allowFrequentDuplicateEvents:!!o.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!o.sendEventsOnlyForVariation},platform:t.diagnosticPlatformData}}function m(e){o.logger&&o.logger.debug(messages.debugPostingDiagnosticEvent(e)),n.sendEvents(e,l,!0).then(function(){}).catch(function(){})}function y(){m(function(){var e=(new Date).getTime(),t=_objectSpread2({kind:u?"diagnostic-combined":"diagnostic",id:i,creationDate:e},d.getProps());return u&&(t=_objectSpread2({},t,{},p())),d.reset(e),t}()),s=setTimeout(y,f),a=(new Date).getTime(),u&&function(){if(t.localStorage){var e=_objectSpread2({},d.getProps());t.localStorage.set(c,JSON.stringify(e),function(){})}}()}return g.start=function(){u?function(n){if(!t.localStorage)return n(!1);t.localStorage.get(c).then(function(e){if(e)try{var t=JSON.parse(e);d.setProps(t),a=t.dataSinceDate}catch(e){}n(!0)}).catch(function(){n(!1)})}(function(e){if(e){var t=(a||0)+f,n=(new Date).getTime();t<=n?y():s=setTimeout(y,t-n)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,f)}):(m(_objectSpread2({kind:"diagnostic-init",id:i,creationDate:d.getProps().dataSinceDate},p())),s=setTimeout(y,f))},g.stop=function(){s&&clearTimeout(s)},g.setStreaming=function(e){v=e},g}var diagnosticEvents={DiagnosticId:DiagnosticId,DiagnosticsAccumulator:DiagnosticsAccumulator,DiagnosticsManager:DiagnosticsManager},diagnosticEvents_1=diagnosticEvents.DiagnosticId,diagnosticEvents_2=diagnosticEvents.DiagnosticsAccumulator,diagnosticEvents_3=diagnosticEvents.DiagnosticsManager;function createConsoleLogger(e,t){var i,a=["debug","info","warn","error"];i=null!=t?""===t?"":t+" ":"LD: ";var s=0;e&&(s="none"===e?100:a.indexOf(e));var n={};function r(e,t,n){if(s<=e&&console){var r=console[t];if(r){var o=e<a.length?a[e]:"?";r.call(console,i+"["+o+"] "+n)}}}return n.debug=function(e){return r(0,"log",e)},n.info=function(e){return r(1,"info",e)},n.warn=function(e){return r(2,"warn",e)},n.error=function(e){return r(3,"error",e)},n}var changeEvent="change",internalChangeEvent="internal-change";function initialize(e,t,n,o,r){var a,i,s,u,c=function(){if(n&&n.logger)return n.logger;return r&&r.logger&&r.logger.default||createConsoleLogger("warn")}(),l=EventEmitter(c),f=InitializationState(l),d=validate(n,l,r,c),v=d.sendEvents,g=e,p=d.hash,m=EventSender(o,g,d),y=d.sendEvents&&!d.diagnosticOptOut,h=y?diagnosticEvents_1(g):null,b=y?diagnosticEvents_2((new Date).getTime()):null,E=y?diagnosticEvents_3(o,b,m,g,d,h):null,k=Stream(o,d,g,b),S=d.eventProcessor||EventProcessor(o,d,g,b,l,m),D=Requestor(o,d,g),w={},U={},P=d.streaming,I=!1,O=!1,L=!0,T=d.stateProvider,C=Identity(null,function(e){if(T)return;e&&j({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),F=UserValidator(o.localStorage,c);function j(e){g&&(T&&T.enqueueEvent&&T.enqueueEvent(e)||(e.user?(L=!1,!v||O||o.isDoNotTrack()||(c.debug(debugEnqueueingEvent(e.kind)),S.enqueue(e))):L&&(c.warn(eventWithoutUser()),L=!1)))}function R(e,t,n,r){var o=C.getUser(),i=new Date,a=t?t.value:null;if(!d.allowFrequentDuplicateEvents){var s=JSON.stringify(a)+(o&&o.key?o.key:"")+e,u=w[s];if(u&&i-u<3e5)return;w[s]=i}var c={kind:"feature",key:e,user:o,value:a,variation:t?t.variationIndex:null,default:n,creationDate:i.getTime()},l=U[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&t&&(c.reason=t.reason),j(c)}function _(e,t,n,r){var o;if(U&&objectHasOwnProperty(U,e)&&U[e]&&!U[e].deleted){var i=U[e];o=N(i),null!==i.value&&void 0!==i.value||(o.value=t)}else o={value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return n&&R(e,o,t,r),o}function N(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function x(){i=!0,C.getUser()&&k.connect(C.getUser(),p,{ping:function(){c.debug(debugStreamPing()),D.fetchFlagSettings(C.getUser(),p).then(function(e){return V(e||{})}).catch(function(e){l.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){var t=JSON.parse(e.data);c.debug(debugStreamPut()),V(t)},patch:function(e){var t=JSON.parse(e.data),n=U[t.key];if(!n||!n.version||!t.version||n.version<t.version){c.debug(debugStreamPatch(t.key));var r={},o=extend({},t);delete o.key;var i=N(U[t.key]=o);r[t.key]=n?{previous:n.value,current:i}:{current:i},q(r)}else c.debug(debugStreamPatchIgnored(t.key))},delete:function(e){var t=JSON.parse(e.data);if(!U[t.key]||U[t.key].version<t.version){c.debug(debugStreamDelete(t.key));var n={};U[t.key]&&!U[t.key].deleted&&(n[t.key]={previous:U[t.key].value}),U[t.key]={version:t.version,deleted:!0},q(n)}else c.debug(debugStreamDeleteIgnored(t.key))}})}function A(){i&&(k.disconnect(),i=!1)}function V(e){var t={};if(!e)return Promise.resolve();for(var n in U)objectHasOwnProperty(U,n)&&U[n]&&(e[n]&&!deepEquals(e[n].value,U[n].value)?t[n]={previous:U[n].value,current:N(e[n])}:e[n]&&!e[n].deleted||(t[n]={previous:U[n].value}));for(var r in e)objectHasOwnProperty(e,r)&&e[r]&&(!U[r]||U[r].deleted)&&(t[r]={current:N(e[r])});return U=_objectSpread2({},e),q(t).catch(function(){})}function q(o){var e=Object.keys(o);if(0<e.length){var i={};e.forEach(function(e){var t=o[e].current,n=t?t.value:void 0,r=o[e].previous;l.emit(changeEvent+":"+e,n,r),i[e]=t?{current:n,previous:r}:{previous:r}}),l.emit(changeEvent,i),l.emit(internalChangeEvent,U),d.sendEventsOnlyForVariation||T||e.forEach(function(e){R(e,o[e].current)})}return a&&u?u.saveFlags(U).catch(function(){return null}):Promise.resolve()}function M(){var e=P||s&&void 0===P;e&&!i?x():!e&&i&&A(),E&&E.setStreaming(e)}function z(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}if(o.localStorage&&(u=new Store(o.localStorage,g,p,C,c)),"string"==typeof d.bootstrap&&"LOCALSTORAGE"===d.bootstrap.toUpperCase()&&(u?a=!0:c.warn(localStorageUnavailable())),"object"===_typeof(d.bootstrap)&&(U=function(n){var e=Object.keys(n),r="$flagsState",o=n[r];!o&&e.length&&c.warn(bootstrapOldFormat()),!1===n.$valid&&c.warn(bootstrapInvalid());var i={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var t={value:n[e]};o&&o[e]?t=extend(t,o[e]):t.version=0,i[e]=t}}),i}(d.bootstrap)),T){var H=T.getInitialState();H?B(H):T.on("init",B),T.on("update",function(e){e.user&&C.setUser(e.user);e.flags&&V(e.flags)})}else(e?F.validateUser(t).then(function(e){return C.setUser(e),"object"===_typeof(d.bootstrap)?K():a?u.loadFlags().catch(function(){return null}).then(function(e){return null==e?(U={},D.fetchFlagSettings(C.getUser(),p).then(function(e){return V(e||{})}).then(K).catch(function(e){J(new LDFlagFetchError(errorFetchingFlags(e)))})):(U=e,onNextTick(K),D.fetchFlagSettings(C.getUser(),p).then(function(e){return V(e)}).catch(function(e){return l.maybeReportError(e)}))}):D.fetchFlagSettings(C.getUser(),p).then(function(e){U=e||{},K()}).catch(function(e){U={},J(e)})}):Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()))).catch(J);function B(e){g=e.environment,C.setUser(e.user),U=_objectSpread2({},e.flags),onNextTick(K)}function K(){c.info(clientInitialized()),I=!0,M(),f.signalSuccess()}function J(e){f.signalFailure(e)}return{client:{waitForInitialization:function(){return f.getInitializationPromise()},waitUntilReady:function(){return f.getReadyPromise()},identify:function(e,r,t){return O?wrapPromiseCallback(Promise.resolve({}),t):T?(c.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(U)),t)):wrapPromiseCallback((a&&u?u.clearFlags():Promise.resolve()).then(function(){return F.validateUser(e)}).then(function(n){return D.fetchFlagSettings(n,r).then(function(e){var t=transformVersionedValuesToValues(e);return C.setUser(n),p=r,e?V(e).then(function(){return t}):t})}).then(function(e){return i&&x(),e}).catch(function(e){return l.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return C.getUser()},variation:function(e,t){return _(e,t,!0,!1).value},variationDetail:function(e,t){return _(e,t,!0,!0)},track:function(e,t,n){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&c.warn(unknownCustomEventKey(e));var r={kind:"custom",key:e,user:C.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()};null!=t&&(r.data=t),null!=n&&(r.metricValue=n),j(r)}else l.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},on:function(e,t,n){z(e)?(s=!0,I&&M(),l.on(e,t,n)):l.on.apply(l,arguments)},off:function(e){if(l.off.apply(l,arguments),z(e)){var t=!1;l.getEvents().forEach(function(e){z(e)&&0<l.getEventListenerCount(e)&&(t=!0)}),t||(s=!1,i&&void 0===P&&A())}},setStreaming:function(e){var t=null===e?void 0:e;t!==P&&(P=t,M())},flush:function(e){return wrapPromiseCallback(v?S.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!U)return e;for(var t in U)objectHasOwnProperty(U,t)&&(e[t]=_(t,null,!d.sendEventsOnlyForVariation).value);return e},close:function(e){if(O)return wrapPromiseCallback(Promise.resolve(),e);function t(){O=!0,U={}}return wrapPromiseCallback(Promise.resolve().then(function(){if(A(),E&&E.stop(),v)return S.stop(),S.flush()}).then(t).catch(t),e)}},options:d,emitter:l,ident:C,logger:c,requestor:D,start:function(){v&&(E&&E.start(),S.start())},enqueueEvent:j,getFlagsInternal:function(){return U},getEnvironmentId:function(){return g},internalChangeEventName:internalChangeEvent}}var version="3.2.7";exports.createConsoleLogger=createConsoleLogger,exports.errors=errors,exports.initialize=initialize,exports.messages=messages,exports.utils=utils,exports.version=version;
//# sourceMappingURL=ldclient-common.cjs.js.map

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

function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function r(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?t(i,!0).forEach((function(t){n(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):t(i).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(i,n))}))}return e}function i(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var o=i("LaunchDarklyUnexpectedResponseError"),a=i("LaunchDarklyInvalidEnvironmentIdError"),u=i("LaunchDarklyInvalidUserError"),s=i("LaunchDarklyInvalidEventKeyError"),c=i("LaunchDarklyInvalidArgumentError"),l=i("LaunchDarklyFlagFetchError");function f(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:o,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:s,LDInvalidArgumentError:c,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(b(e,o,o+16383>a?a:o+16383));1===r?(n=e[t-1],i.push(g[n>>2]+g[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],i.push(g[n>>10]+g[n>>4&63]+g[n<<2&63]+"="));return i.join("")},g=[],m=[],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,y=p.length;h<y;++h)g[h]=p[h],m[p.charCodeAt(h)]=h;function b(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(g[(i=r)>>18&63]+g[i>>12&63]+g[i>>6&63]+g[63&i]);return o.join("")}m["-".charCodeAt(0)]=62,m["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,w=Object.prototype.hasOwnProperty,D=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function S(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function P(e){return S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function O(e){return JSON.parse(JSON.stringify(e))}function U(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=k(n),u=k(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=E(n);if((i=v.length)!==E(t).length)return!1;for(r=i;0!=r--;)if(!w.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t}(e,n)}function I(e){setTimeout(e,0)}function j(e,n){var t=e.then((function(e){return n&&setTimeout((function(){n(null,e)}),0),e}),(function(e){if(!n)return Promise.reject(e);setTimeout((function(){n(e,null)}),0)}));return n?void 0:t}function R(e){var n={};for(var t in e)A(e,t)&&(n[t]={value:e[t],version:0});return n}function T(e){var n={};for(var t in e)A(e,t)&&(n[t]=e[t].value);return n}function N(e,n){for(var t,r=n.slice(0),i=[],o=e;r.length>0;){for(t=[];o>0;){var a=r.shift();if(!a)break;(o-=P(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function F(e){var n=e.version||"3.2.6";return e.userAgent+"/"+n}function C(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":F(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function L(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return r({},e,{},n)}),{})}function A(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function x(e){if(!e)return e;var n;for(var t in D){var i=D[t],o=e[i];void 0!==o&&"string"!=typeof o&&((n=n||r({},e))[i]=String(o))}return n||e}var V=Object.freeze({__proto__:null,btoa:S,base64URLEncode:P,clone:O,deepEquals:U,onNextTick:I,wrapPromiseCallback:j,transformValuesToVersionedValues:R,transformVersionedValuesToValues:T,chunkUserEventsForUrl:N,getLDUserAgentString:F,getLDHeaders:C,extend:L,objectHasOwnProperty:A,sanitizeUser:x});for(var q=function(e,n){return e(n={exports:{}},n.exports),n.exports}((function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}})),_=[],J=0;J<256;++J)_[J]=(J+256).toString(16).substr(1);var z,M,B=function(e,n){var t=n||0,r=_;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},K=0,$=0;var H=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||z,a=void 0!==e.clockseq?e.clockseq:M;if(null==o||null==a){var u=q();null==o&&(o=z=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=M=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:$+1,l=s-K+(c-$)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>K)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");K=s,$=c,M=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var v=s/4294967296*1e4&268435455;i[r++]=v>>>8&255,i[r++]=255&v,i[r++]=v>>>24&15|16,i[r++]=v>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var d=0;d<6;++d)i[r+d]=o[d];return n||B(i)};function G(e,n,t){var r="/a/"+n+".gif",i=L({"Content-Type":"application/json"},C(e,t)),o=e.httpFallbackPing,a={};return a.sendChunk=function(n,t,a,u){var s=JSON.stringify(n),c=a?null:H();return u?function n(r){var o=a?i:L({},i,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":c});return e.httpRequest("POST",t,o,s).promise.then((function(e){if(e)return e.status>=400&&f(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(o&&o(t+r+"?d="+P(s)),Promise.resolve())},a.sendEvents=function(n,t,r){if(!e.httpRequest)return Promise.resolve();var i,o=e.httpAllowsPost();i=o?[n]:N(2e3-t.length,n);for(var u=[],s=0;s<i.length;s++)u.push(a.sendChunk(i[s],t,r,o));return Promise.all(u)},a}function X(){var e={},n=0,t=0,r={};return e.summarizeEvent=function(e){if("feature"===e.kind){var i=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),o=r[i];o?o.count=o.count+1:r[i]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>t&&(t=e.creationDate)}},e.getSummary=function(){var e={},i=!0;for(var o in r){var a=r[o],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),i=!1}return i?null:{startDate:n,endDate:t,features:e}},e.clearSummary=function(){n=0,t=0,r={}},e}function W(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],i={key:!0,custom:!0,anonymous:!0},o={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,o){return Object.keys(e).reduce((function(a,u){var s=a;return o(u)&&(!function(e){return!i[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[0][u]=e[u]:s[1][u]=!0),s}),[{},{}])},u=a(e,(function(e){return o[e]})),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,(function(){return!0}));s.custom=l[0],c=L({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function Q(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var Y=function(){return"LaunchDarkly client initialized"},Z=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",ee=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},ne=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},te=function(e){return'Expected application/json content type but got "'+e+'"'},re=function(){return"localStorage is unavailable"},ie=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},oe=function(e){return"network error"+(e?" ("+e+")":"")},ae=function(e){return'Custom event "'+e+'" does not exist'},ue=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+Z},se=function(){return"No environment/client-side ID was specified."+Z},ce=function(e){return"Error fetching flag settings: "+Q(e)},le=function(){return"No user specified."+Z},fe=function(){return"Invalid user specified."+Z},ve=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+Z},de=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},ge=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},me=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},pe=function(){return"Cannot make HTTP requests in this environment."+Z},he=function(){return"identify() has no effect here; it must be called on the main client instance"},ye=function(){return"Closing stream connection"},be=function(e){return"Opening stream connection to "+e},ke=function(e,n){return"Error on stream connection: "+Q(e)+", will continue retrying every "+n+" milliseconds."},Ee=function(e){return'Ignoring unknown config option "'+e+'"'},we=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},De=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Se=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Pe=function(e){return"polling for feature flags at "+e},Oe=function(){return"received ping message from stream"},Ue=function(){return"received streaming update for all flags"},Ie=function(e){return'received streaming update for flag "'+e+'"'},je=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Re=function(e){return'received streaming deletion for flag "'+e+'"'},Te=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Ne=function(e){return'enqueueing "'+e+'" event'},Fe=function(e){return"sending "+e+" events"},Ce=Object.freeze({__proto__:null,clientInitialized:Y,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:ee,eventWithoutUser:ne,invalidContentType:te,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:re,localStorageUnavailableForUserId:ie,networkError:oe,unknownCustomEventKey:ae,environmentNotFound:ue,environmentNotSpecified:se,errorFetchingFlags:ce,userNotSpecified:le,invalidUser:fe,bootstrapOldFormat:ve,bootstrapInvalid:de,deprecated:ge,httpErrorMessage:me,httpUnavailable:pe,identifyDisabled:he,streamClosing:ye,streamConnecting:be,streamError:ke,unknownOption:Ee,wrongOptionType:we,wrongOptionTypeBoolean:De,optionBelowMinimum:Se,debugPolling:Pe,debugStreamPing:Oe,debugStreamPut:Ue,debugStreamPatch:Ie,debugStreamPatchIgnored:je,debugStreamDelete:Re,debugStreamDeleteIgnored:Te,debugEnqueueingEvent:Ne,debugPostingEvents:Fe,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function Le(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var i=0;i<t[e].length;i++)t[e][i].handler===n&&t[e][i].context===r&&(t[e]=t[e].slice(0,i).concat(t[e].slice(i+1)))},n.emit=function(e){if(t[e])for(var n=t[e].slice(0),r=0;r<n.length;r++)n[r].handler.apply(n[r].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t["error"]?this.emit("error",n):(e||console).error(n.message))},n}var Ae=function(e){var n=!1,t=!1,r=null,i=null,o=new Promise((function(n){e.on("ready",(function t(){e.off("ready",t),n()}))})).catch((function(){}));return{getInitializationPromise:function(){return i||(n?Promise.resolve():t?Promise.reject(r):i=new Promise((function(n,t){e.on("initialized",(function t(){e.off("initialized",t),n()})),e.on("failed",(function n(r){e.off("failed",n),t(r)}))})))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,e.emit("initialized"),e.emit("ready"))},signalFailure:function(i){n||t||(t=!0,r=i,e.emit("failed",i),e.emit("ready")),e.maybeReportError(i)}}};function xe(e,n,t,r,i){var o={};function a(){var e="",i=r.getUser();return i&&(e=t||S(JSON.stringify(i))),"ld:"+n+":"+e}return o.loadFlags=function(){return e.get(a()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=R(n):delete n.$schema}return n}catch(e){return o.clearFlags().then((function(){return Promise.reject(e)}))}})).catch((function(e){return i.warn("localStorage is unavailable"),Promise.reject(e)}))},o.saveFlags=function(n){var t=L({},n,{$schema:1});return e.set(a(),JSON.stringify(t)).catch((function(e){return i.warn("localStorage is unavailable"),Promise.reject(e)}))},o.clearFlags=function(){return e.clear(a()).catch((function(e){return i.warn("localStorage is unavailable"),Promise.reject(e)}))},o}function Ve(e,n,t,r){var i,o=n.streamUrl,a=n.logger,u={},s=o+"/eval/"+t,c=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,v=C(e,n),d=!1,g=null,m=null,p=null,h=null,y=null;function b(e){d||(a.warn(ke(e,f)),d=!0),D(!1),w(),k(f)}function k(e){m||(e?m=setTimeout(E,e):E())}function E(){var n;m=null;var r="",u={headers:v};if(e.eventSourceFactory){for(var f in null!=h&&(r="h="+h),c?e.eventSourceAllowsReport?(n=s,u.method="REPORT",u.headers["Content-Type"]="application/json",u.body=JSON.stringify(p)):(n=o+"/ping/"+t,r=""):n=s+"/"+P(JSON.stringify(p)),l&&(r=r+(r?"&":"")+"withReasons=true"),n=n+(r?"?":"")+r,w(),a.info(be(n)),i=(new Date).getTime(),g=e.eventSourceFactory(n,u),y)A(y,f)&&g.addEventListener(f,y[f]);g.onerror=b}}function w(){g&&(a.info("Closing stream connection"),g.close(),g=null)}function D(e){i&&r&&r.recordStreamInit(i,!e,(new Date).getTime()-i),i=null}return u.connect=function(e,n,t){p=e,h=n,y={};var r=function(e){y[e]=function(n){d=!1,D(!0),t[e]&&t[e](n)}};for(var i in t||{})r(i);k()},u.disconnect=function(){clearTimeout(m),m=null,w()},u.isConnected=function(){return!!(g&&e.eventSourceIsActive&&e.eventSourceIsActive(g))},u}function qe(e,n,t){var r=n.baseUrl,i=n.useReport,o=n.evaluationReasons,u=n.logger,s={},c={};function f(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new l(pe()))}));var i=r?"REPORT":"GET",o=C(e,n);r&&(o["Content-Type"]="application/json");var u=c[t];u||(u=function(e){var n,t,r,i,o={addPromise:function(o,a){n=o,t&&t(),t=a,o.then((function(t){n===o&&(r(t),e&&e())}),(function(t){n===o&&(i(t),e&&e())}))}};return o.resultPromise=new Promise((function(e,n){r=e,i=n})),o}((function(){delete c[t]})),c[t]=u);var s=e.httpRequest(i,t,o,r),f=s.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&e.header("content-type").startsWith("application/json"))return JSON.parse(e.body);var n=te(e.header("content-type")||"");return Promise.reject(new l(n))}return Promise.reject(function(e){return 404===e.status?new a(ue()):new l(ce(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new l(oe(e)))}));return u.addPromise(f,(function(){s.cancel&&s.cancel()})),u.resultPromise}return s.fetchJSON=function(e){return f(r+e,null)},s.fetchFlagSettings=function(e,n){var a,s,c,l="";return i?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(a=P(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(l="h="+n),o&&(l=l+(l?"&":"")+"withReasons=true"),s=s+(l?"?":"")+l,u.debug(Pe(s)),f(s,c)},s}function _e(e,n){var t={};return t.validateUser=function(t){if(!t)return Promise.reject(new u(le()));var r=O(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get("ld:$anonUserId").catch((function(){return null})):Promise.resolve(null)).then((function(t){if(t)return r.key=t,r;var i=H();return r.key=i,function(t){return e?e.set("ld:$anonUserId",t).catch((function(){n.warn("localStorage is unavailable, so anonymous user ID cannot be cached")})):Promise.resolve()}(i).then((function(){return r}))})):Promise.reject(new u(fe()))},t}var Je={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function ze(n,t,r,i){var o=L({logger:{default:i}},Je,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){I((function(){t&&t.maybeReportError(new c(e))}))}var s=L({},n||{});return function(e){var n=e;Object.keys(a).forEach((function(e){if(void 0!==n[e]){var t=a[e];i&&i.warn(ge(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),s=function(n){var t=L({},n),r=function(n){if(null===n)return"any";if(void 0!==n){if(Array.isArray(n))return"array";var t=e(n);return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"}};return Object.keys(n).forEach((function(e){var i=n[e];if(null!=i){var a=o[e];if(void 0===a)u(Ee(e));else{var s=a.type||r(a.default);if("any"!==s){var c=s.split("|"),l=r(i);c.indexOf(l)<0?"boolean"===s?(t[e]=!!i,u(De(e,l))):(u(we(e,s,l)),t[e]=a.default):"number"===l&&void 0!==a.minimum&&i<a.minimum&&(u(Se(e,i,a.minimum)),t[e]=a.minimum)}}}})),t}(s=function(e){var n=L({},e);return Object.keys(o).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=o[e]&&o[e].default)})),n}(s))}var Me=Object.freeze({__proto__:null,baseOptionDefs:Je,validate:ze}).baseOptionDefs;var Be=function(e){var n={diagnosticId:H()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n},Ke=function(e){var n,t,r,i;function o(e){n=e,t=0,r=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},$e=function(e,n,t,i,o,a){var u,s,c=!!e.diagnosticUseCombinedEvent,l="ld:"+i+":$diagnostics",f=o.eventsUrl+"/events/diagnostic/"+i,v=o.diagnosticRecordingInterval,d=n,g=!!o.streaming,m={};function p(){return{sdk:b(),configuration:(n={customBaseURI:o.baseUrl!==Me.baseUrl.default,customStreamURI:o.streamUrl!==Me.streamUrl.default,customEventsURI:o.eventsUrl!==Me.eventsUrl.default,eventsCapacity:o.eventCapacity,eventsFlushIntervalMillis:o.flushInterval,reconnectTimeMillis:o.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!o.allAttributesPrivate,inlineUsersInEvents:!!o.inlineUsersInEvents,diagnosticRecordingIntervalMillis:o.diagnosticRecordingInterval,usingSecureMode:!!o.hash,bootstrapMode:!!o.bootstrap,fetchGoalsDisabled:!o.fetchGoals,allowFrequentDuplicateEvents:!!o.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!o.sendEventsOnlyForVariation},n),platform:e.diagnosticPlatformData};var n}function h(e){o.logger&&o.logger.debug(Ce.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then((function(){})).catch((function(){}))}function y(){var n,t;h((n=(new Date).getTime(),t=r({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:n},d.getProps()),c&&(t=r({},t,{},p())),d.reset(n),t)),s=setTimeout(y,v),u=(new Date).getTime(),c&&function(){if(e.localStorage){var n=r({},d.getProps());e.localStorage.set(l,JSON.stringify(n),(function(){}))}}()}function b(){var n=r({},e.diagnosticSdkData);return o.wrapperName&&(n.wrapperName=o.wrapperName),o.wrapperVersion&&(n.wrapperVersion=o.wrapperVersion),n}return m.start=function(){c?function(n){if(!e.localStorage)return n(!1);e.localStorage.get(l).then((function(e){if(e)try{var t=JSON.parse(e);d.setProps(t),u=t.dataSinceDate}catch(e){}n(!0)})).catch((function(){n(!1)}))}((function(e){if(e){var n=(u||0)+v,t=(new Date).getTime();t>=n?y():s=setTimeout(y,n-t)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,v)})):(h(r({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate},p())),s=setTimeout(y,v))},m.stop=function(){s&&clearTimeout(s)},m.setStreaming=function(e){g=e},m};function He(e,n){var t,r=["debug","info","warn","error"];t=null!=n?""===n?"":n+" ":"LD: ";var i=0;e&&(i="none"===e?100:r.indexOf(e));var o={};function a(e,n,o){if(e>=i&&console){var a=console[n];if(a){var u=e<r.length?r[e]:"?";a.call(console,t+"["+u+"] "+o)}}}return o.debug=function(e){return a(0,"log",e)},o.info=function(e){return a(1,"info",e)},o.warn=function(e){return a(2,"warn",e)},o.error=function(e){return a(3,"error",e)},o}function Ge(n,t,i,u,c){var v=function(){if(i&&i.logger)return i.logger;return c&&c.logger&&c.logger.default||He("warn")}(),d=Le(v),g=Ae(d),m=ze(i,d,c,v),p=m.sendEvents,h=n,y=m.hash,b=G(u,h,m),k=m.sendEvents&&!m.diagnosticOptOut,E=k?Be(h):null,w=k?Ke((new Date).getTime()):null,D=k?$e(u,w,b,h,m,E):null;D&&D.start();var S,P,R,N,F=Ve(u,m,h,w),C=m.eventProcessor||function(e,n,t){var r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=u||G(e,t,n),l=n.eventsUrl+"/events/bulk/"+t,v=X(),d=W(n),g=n.inlineUsersInEvents,m=n.samplingInterval,p=n.eventCapacity,h=n.flushInterval,y=n.logger,b=[],k=0,E=!1,w=!1;function D(){return 0===m||0===Math.floor(Math.random()*m)}function S(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}function P(e){var n=L({},e);return g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}function O(e){b.length<p?(b.push(e),w=!1):(w||(w=!0,y.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),i&&i.incrementDroppedEvents())}return s.enqueue=function(e){if(!E){var n=!1,t=!1;if(v.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=S(e)):n=D(),n&&O(P(e)),t){var r=L({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,O(r)}}},s.flush=function(){if(E)return Promise.resolve();var e=b,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),i&&i.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],y.debug(Fe(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(k=e.serverTime),f(e.status)||(E=!0),e.status>=400&&I((function(){a.maybeReportError(new o(me(e.status,"event posting","some events were dropped")))})))})))},s.start=function(){r=setTimeout((function e(){s.flush(),r=setTimeout(e,h)}),h)},s.stop=function(){clearTimeout(r)},s}(u,m,h,w,d,b),V=qe(u,m,h),q={},_={},J=m.streaming,z=!1,M=!1,B=!0,K=m.stateProvider,$=function(e,n){var t,r={};return r.setUser=function(e){(t=x(e))&&n&&n(O(t))},r.getUser=function(){return t?O(t):null},e&&r.setUser(e),r}(null,(function(e){if(K)return;e&&Q({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})),H=_e(u.localStorage,v);function Q(e){h&&(K&&K.enqueueEvent&&K.enqueueEvent(e)||(e.user?(B=!1,!p||M||u.isDoNotTrack()||(v.debug(Ne(e.kind)),C.enqueue(e))):B&&(v.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),B=!1)))}function Y(e,n,t,r){var i=$.getUser(),o=new Date,a=n?n.value:null;if(!m.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=q[u];if(s&&o-s<3e5)return;q[u]=o}var c={kind:"feature",key:e,user:i,value:a,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()},l=_[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),Q(c)}function Z(e,n,t,r){var i;if(_&&A(_,e)&&_[e]&&!_[e].deleted){var o=_[e];i=ee(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&Y(e,i,n,r),i}function ee(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function ne(){P=!0,$.getUser()&&F.connect($.getUser(),y,{ping:function(){v.debug("received ping message from stream"),V.fetchFlagSettings($.getUser(),y).then((function(e){return re(e||{})})).catch((function(e){d.maybeReportError(new l(ce(e)))}))},put:function(e){var n=JSON.parse(e.data);v.debug("received streaming update for all flags"),re(n)},patch:function(e){var n=JSON.parse(e.data),t=_[n.key];if(!t||!t.version||!n.version||t.version<n.version){v.debug(Ie(n.key));var r={},i=L({},n);delete i.key,_[n.key]=i;var o=ee(i);r[n.key]=t?{previous:t.value,current:o}:{current:o},ie(r)}else v.debug(je(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!_[n.key]||_[n.key].version<n.version){v.debug(Re(n.key));var t={};_[n.key]&&!_[n.key].deleted&&(t[n.key]={previous:_[n.key].value}),_[n.key]={version:n.version,deleted:!0},ie(t)}else v.debug(Te(n.key))}})}function te(){P&&(F.disconnect(),P=!1)}function re(e){var n={};if(!e)return Promise.resolve();for(var t in _)A(_,t)&&_[t]&&(e[t]&&!U(e[t].value,_[t].value)?n[t]={previous:_[t].value,current:ee(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:_[t].value}));for(var i in e)A(e,i)&&e[i]&&(!_[i]||_[i].deleted)&&(n[i]={current:ee(e[i])});return _=r({},e),ie(n).catch((function(){}))}function ie(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,i=r?r.value:void 0,o=e[n].previous;d.emit("change:"+n,i,o),t[n]=r?{current:i,previous:o}:{previous:o}})),d.emit("change",t),d.emit("internal-change",_),m.sendEventsOnlyForVariation||K||n.forEach((function(n){Y(n,e[n].current)}))}return S&&N?N.saveFlags(_).catch((function(){return null})):Promise.resolve()}function oe(){var e=J||R&&void 0===J;e&&!P?ne():!e&&P&&te(),D&&D.setStreaming(e)}function ue(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if(u.localStorage&&(N=new xe(u.localStorage,h,y,$,v)),"string"==typeof m.bootstrap&&"LOCALSTORAGE"===m.bootstrap.toUpperCase()&&(N?S=!0:v.warn("localStorage is unavailable")),"object"===e(m.bootstrap)&&(_=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&v.warn(ve()),!1===e.$valid&&v.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var i={value:e[n]};t&&t[n]?i=L(i,t[n]):i.version=0,r[n]=i}})),r}(m.bootstrap)),K){var le=K.getInitialState();le?fe(le):K.on("init",fe),K.on("update",(function(e){e.user&&$.setUser(e.user);e.flags&&re(e.flags)}))}else(function(){if(!n)return Promise.reject(new a(se()));return H.validateUser(t).then((function(n){return $.setUser(n),"object"===e(m.bootstrap)?de():S?N.loadFlags().catch((function(){return null})).then((function(e){return null==e?(_={},V.fetchFlagSettings($.getUser(),y).then((function(e){return re(e||{})})).then(de).catch((function(e){ge(new l(ce(e)))}))):(_=e,I(de),V.fetchFlagSettings($.getUser(),y).then((function(e){return re(e)})).catch((function(e){return d.maybeReportError(e)})))})):V.fetchFlagSettings($.getUser(),y).then((function(e){_=e||{},de()})).catch((function(e){_={},ge(e)}))}))})().catch(ge);function fe(e){h=e.environment,$.setUser(e.user),_=r({},e.flags),I(de)}function de(){v.info("LaunchDarkly client initialized"),z=!0,oe(),g.signalSuccess()}function ge(e){g.signalFailure(e)}return{client:{waitForInitialization:function(){return g.getInitializationPromise()},waitUntilReady:function(){return g.getReadyPromise()},identify:function(e,n,t){return M?j(Promise.resolve({}),t):K?(v.warn("identify() has no effect here; it must be called on the main client instance"),j(Promise.resolve(T(_)),t)):j((S&&N?N.clearFlags():Promise.resolve()).then((function(){return H.validateUser(e)})).then((function(e){return V.fetchFlagSettings(e,n).then((function(t){var r=T(t);return $.setUser(e),y=n,t?re(t).then((function(){return r})):r}))})).then((function(e){return P&&ne(),e})).catch((function(e){return d.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return $.getUser()},variation:function(e,n){return Z(e,n,!0,!1).value},variationDetail:function(e,n){return Z(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){u.customEventFilter&&!u.customEventFilter(e)&&v.warn(ae(e));var r={kind:"custom",key:e,user:$.getUser(),url:u.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),Q(r)}else d.maybeReportError(new s(ae(e)))},on:function(e,n,t){ue(e)?(R=!0,z&&oe(),d.on(e,n,t)):d.on.apply(d,arguments)},off:function(e){if(d.off.apply(d,arguments),ue(e)){var n=!1;d.getEvents().forEach((function(e){ue(e)&&d.getEventListenerCount(e)>0&&(n=!0)})),n||(R=!1,P&&void 0===J&&te())}},setStreaming:function(e){var n=null===e?void 0:e;n!==J&&(J=n,oe())},flush:function(e){return j(p?C.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!_)return e;for(var n in _)A(_,n)&&(e[n]=Z(n,null,!m.sendEventsOnlyForVariation).value);return e},close:function(e){if(M)return j(Promise.resolve(),e);var n=function(){M=!0,_={}};return j(Promise.resolve().then((function(){if(te(),D&&D.stop(),p)return C.stop(),C.flush()})).then(n).catch(n),e)}},options:m,emitter:d,ident:$,logger:v,requestor:V,start:function(){p&&(D&&D.start(),C.start())},enqueueEvent:Q,getFlagsInternal:function(){return _},getEnvironmentId:function(){return h},internalChangeEventName:"internal-change"}}var Xe="3.2.6";export{He as createConsoleLogger,v as errors,Ge as initialize,Ce as messages,V as utils,Xe as version};
function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function r(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?t(i,!0).forEach((function(t){n(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):t(i).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(i,n))}))}return e}function i(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var o=i("LaunchDarklyUnexpectedResponseError"),a=i("LaunchDarklyInvalidEnvironmentIdError"),u=i("LaunchDarklyInvalidUserError"),s=i("LaunchDarklyInvalidEventKeyError"),c=i("LaunchDarklyInvalidArgumentError"),l=i("LaunchDarklyFlagFetchError");function f(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:o,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:s,LDInvalidArgumentError:c,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(b(e,o,o+16383>a?a:o+16383));1===r?(n=e[t-1],i.push(g[n>>2]+g[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],i.push(g[n>>10]+g[n>>4&63]+g[n<<2&63]+"="));return i.join("")},g=[],m=[],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,y=p.length;h<y;++h)g[h]=p[h],m[p.charCodeAt(h)]=h;function b(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(g[(i=r)>>18&63]+g[i>>12&63]+g[i>>6&63]+g[63&i]);return o.join("")}m["-".charCodeAt(0)]=62,m["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,w=Object.prototype.hasOwnProperty,D=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function S(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function P(e){return S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function O(e){return JSON.parse(JSON.stringify(e))}function U(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=k(n),u=k(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=E(n);if((i=v.length)!==E(t).length)return!1;for(r=i;0!=r--;)if(!w.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t}(e,n)}function I(e){setTimeout(e,0)}function j(e,n){var t=e.then((function(e){return n&&setTimeout((function(){n(null,e)}),0),e}),(function(e){if(!n)return Promise.reject(e);setTimeout((function(){n(e,null)}),0)}));return n?void 0:t}function R(e){var n={};for(var t in e)A(e,t)&&(n[t]={value:e[t],version:0});return n}function T(e){var n={};for(var t in e)A(e,t)&&(n[t]=e[t].value);return n}function N(e,n){for(var t,r=n.slice(0),i=[],o=e;r.length>0;){for(t=[];o>0;){var a=r.shift();if(!a)break;(o-=P(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function F(e){var n=e.version||"3.2.7";return e.userAgent+"/"+n}function C(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":F(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function L(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return r({},e,{},n)}),{})}function A(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function x(e){if(!e)return e;var n;for(var t in D){var i=D[t],o=e[i];void 0!==o&&"string"!=typeof o&&((n=n||r({},e))[i]=String(o))}return n||e}var V=Object.freeze({__proto__:null,btoa:S,base64URLEncode:P,clone:O,deepEquals:U,onNextTick:I,wrapPromiseCallback:j,transformValuesToVersionedValues:R,transformVersionedValuesToValues:T,chunkUserEventsForUrl:N,getLDUserAgentString:F,getLDHeaders:C,extend:L,objectHasOwnProperty:A,sanitizeUser:x});for(var q=function(e,n){return e(n={exports:{}},n.exports),n.exports}((function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}})),_=[],J=0;J<256;++J)_[J]=(J+256).toString(16).substr(1);var z,M,B=function(e,n){var t=n||0,r=_;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},K=0,$=0;var H=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||z,a=void 0!==e.clockseq?e.clockseq:M;if(null==o||null==a){var u=q();null==o&&(o=z=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=M=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:$+1,l=s-K+(c-$)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>K)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");K=s,$=c,M=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var v=s/4294967296*1e4&268435455;i[r++]=v>>>8&255,i[r++]=255&v,i[r++]=v>>>24&15|16,i[r++]=v>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var d=0;d<6;++d)i[r+d]=o[d];return n||B(i)};function G(e,n,t){var r="/a/"+n+".gif",i=L({"Content-Type":"application/json"},C(e,t)),o=e.httpFallbackPing,a={};return a.sendChunk=function(n,t,a,u){var s=JSON.stringify(n),c=a?null:H();return u?function n(r){var o=a?i:L({},i,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":c});return e.httpRequest("POST",t,o,s).promise.then((function(e){if(e)return e.status>=400&&f(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(o&&o(t+r+"?d="+P(s)),Promise.resolve())},a.sendEvents=function(n,t,r){if(!e.httpRequest)return Promise.resolve();var i,o=e.httpAllowsPost();i=o?[n]:N(2e3-t.length,n);for(var u=[],s=0;s<i.length;s++)u.push(a.sendChunk(i[s],t,r,o));return Promise.all(u)},a}function X(){var e={},n=0,t=0,r={};return e.summarizeEvent=function(e){if("feature"===e.kind){var i=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),o=r[i];o?o.count=o.count+1:r[i]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>t&&(t=e.creationDate)}},e.getSummary=function(){var e={},i=!0;for(var o in r){var a=r[o],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),i=!1}return i?null:{startDate:n,endDate:t,features:e}},e.clearSummary=function(){n=0,t=0,r={}},e}function W(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],i={key:!0,custom:!0,anonymous:!0},o={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,o){return Object.keys(e).reduce((function(a,u){var s=a;return o(u)&&(!function(e){return!i[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[0][u]=e[u]:s[1][u]=!0),s}),[{},{}])},u=a(e,(function(e){return o[e]})),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,(function(){return!0}));s.custom=l[0],c=L({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function Q(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var Y=function(){return"LaunchDarkly client initialized"},Z=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",ee=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},ne=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"},te=function(e){return'Expected application/json content type but got "'+e+'"'},re=function(){return"localStorage is unavailable"},ie=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},oe=function(e){return"network error"+(e?" ("+e+")":"")},ae=function(e){return'Custom event "'+e+'" does not exist'},ue=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+Z},se=function(){return"No environment/client-side ID was specified."+Z},ce=function(e){return"Error fetching flag settings: "+Q(e)},le=function(){return"No user specified."+Z},fe=function(){return"Invalid user specified."+Z},ve=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+Z},de=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},ge=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},me=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},pe=function(){return"Cannot make HTTP requests in this environment."+Z},he=function(){return"identify() has no effect here; it must be called on the main client instance"},ye=function(){return"Closing stream connection"},be=function(e){return"Opening stream connection to "+e},ke=function(e,n){return"Error on stream connection: "+Q(e)+", will continue retrying every "+n+" milliseconds."},Ee=function(e){return'Ignoring unknown config option "'+e+'"'},we=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},De=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Se=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Pe=function(e){return"polling for feature flags at "+e},Oe=function(){return"received ping message from stream"},Ue=function(){return"received streaming update for all flags"},Ie=function(e){return'received streaming update for flag "'+e+'"'},je=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Re=function(e){return'received streaming deletion for flag "'+e+'"'},Te=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Ne=function(e){return'enqueueing "'+e+'" event'},Fe=function(e){return"sending "+e+" events"},Ce=Object.freeze({__proto__:null,clientInitialized:Y,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:ee,eventWithoutUser:ne,invalidContentType:te,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:re,localStorageUnavailableForUserId:ie,networkError:oe,unknownCustomEventKey:ae,environmentNotFound:ue,environmentNotSpecified:se,errorFetchingFlags:ce,userNotSpecified:le,invalidUser:fe,bootstrapOldFormat:ve,bootstrapInvalid:de,deprecated:ge,httpErrorMessage:me,httpUnavailable:pe,identifyDisabled:he,streamClosing:ye,streamConnecting:be,streamError:ke,unknownOption:Ee,wrongOptionType:we,wrongOptionTypeBoolean:De,optionBelowMinimum:Se,debugPolling:Pe,debugStreamPing:Oe,debugStreamPut:Ue,debugStreamPatch:Ie,debugStreamPatchIgnored:je,debugStreamDelete:Re,debugStreamDeleteIgnored:Te,debugEnqueueingEvent:Ne,debugPostingEvents:Fe,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function Le(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var i=0;i<t[e].length;i++)t[e][i].handler===n&&t[e][i].context===r&&(t[e]=t[e].slice(0,i).concat(t[e].slice(i+1)))},n.emit=function(e){if(t[e])for(var n=t[e].slice(0),r=0;r<n.length;r++)n[r].handler.apply(n[r].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t["error"]?this.emit("error",n):(e||console).error(n.message))},n}var Ae=function(e){var n=!1,t=!1,r=null,i=null,o=new Promise((function(n){e.on("ready",(function t(){e.off("ready",t),n()}))})).catch((function(){}));return{getInitializationPromise:function(){return i||(n?Promise.resolve():t?Promise.reject(r):i=new Promise((function(n,t){e.on("initialized",(function t(){e.off("initialized",t),n()})),e.on("failed",(function n(r){e.off("failed",n),t(r)}))})))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,e.emit("initialized"),e.emit("ready"))},signalFailure:function(i){n||t||(t=!0,r=i,e.emit("failed",i),e.emit("ready")),e.maybeReportError(i)}}};function xe(e,n,t,r,i){var o={};function a(){var e="",i=r.getUser();return i&&(e=t||S(JSON.stringify(i))),"ld:"+n+":"+e}return o.loadFlags=function(){return e.get(a()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=R(n):delete n.$schema}return n}catch(e){return o.clearFlags().then((function(){return Promise.reject(e)}))}})).catch((function(e){return i.warn("localStorage is unavailable"),Promise.reject(e)}))},o.saveFlags=function(n){var t=L({},n,{$schema:1});return e.set(a(),JSON.stringify(t)).catch((function(e){return i.warn("localStorage is unavailable"),Promise.reject(e)}))},o.clearFlags=function(){return e.clear(a()).catch((function(e){return i.warn("localStorage is unavailable"),Promise.reject(e)}))},o}function Ve(e,n,t,r){var i,o=n.streamUrl,a=n.logger,u={},s=o+"/eval/"+t,c=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,v=C(e,n),d=!1,g=null,m=null,p=null,h=null,y=null;function b(e){d||(a.warn(ke(e,f)),d=!0),D(!1),w(),k(f)}function k(e){m||(e?m=setTimeout(E,e):E())}function E(){var n;m=null;var r="",u={headers:v};if(e.eventSourceFactory){for(var f in null!=h&&(r="h="+h),c?e.eventSourceAllowsReport?(n=s,u.method="REPORT",u.headers["Content-Type"]="application/json",u.body=JSON.stringify(p)):(n=o+"/ping/"+t,r=""):n=s+"/"+P(JSON.stringify(p)),l&&(r=r+(r?"&":"")+"withReasons=true"),n=n+(r?"?":"")+r,w(),a.info(be(n)),i=(new Date).getTime(),g=e.eventSourceFactory(n,u),y)A(y,f)&&g.addEventListener(f,y[f]);g.onerror=b}}function w(){g&&(a.info("Closing stream connection"),g.close(),g=null)}function D(e){i&&r&&r.recordStreamInit(i,!e,(new Date).getTime()-i),i=null}return u.connect=function(e,n,t){p=e,h=n,y={};var r=function(e){y[e]=function(n){d=!1,D(!0),t[e]&&t[e](n)}};for(var i in t||{})r(i);k()},u.disconnect=function(){clearTimeout(m),m=null,w()},u.isConnected=function(){return!!(g&&e.eventSourceIsActive&&e.eventSourceIsActive(g))},u}function qe(e,n,t){var r=n.baseUrl,i=n.useReport,o=n.evaluationReasons,u=n.logger,s={},c={};function f(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new l(pe()))}));var i=r?"REPORT":"GET",o=C(e,n);r&&(o["Content-Type"]="application/json");var u=c[t];u||(u=function(e){var n,t,r,i,o={addPromise:function(o,a){n=o,t&&t(),t=a,o.then((function(t){n===o&&(r(t),e&&e())}),(function(t){n===o&&(i(t),e&&e())}))}};return o.resultPromise=new Promise((function(e,n){r=e,i=n})),o}((function(){delete c[t]})),c[t]=u);var s=e.httpRequest(i,t,o,r),f=s.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&e.header("content-type").startsWith("application/json"))return JSON.parse(e.body);var n=te(e.header("content-type")||"");return Promise.reject(new l(n))}return Promise.reject(function(e){return 404===e.status?new a(ue()):new l(ce(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new l(oe(e)))}));return u.addPromise(f,(function(){s.cancel&&s.cancel()})),u.resultPromise}return s.fetchJSON=function(e){return f(r+e,null)},s.fetchFlagSettings=function(e,n){var a,s,c,l="";return i?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(a=P(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(l="h="+n),o&&(l=l+(l?"&":"")+"withReasons=true"),s=s+(l?"?":"")+l,u.debug(Pe(s)),f(s,c)},s}function _e(e,n){var t={};return t.validateUser=function(t){if(!t)return Promise.reject(new u(le()));var r=O(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get("ld:$anonUserId").catch((function(){return null})):Promise.resolve(null)).then((function(t){if(t)return r.key=t,r;var i=H();return r.key=i,function(t){return e?e.set("ld:$anonUserId",t).catch((function(){n.warn("localStorage is unavailable, so anonymous user ID cannot be cached")})):Promise.resolve()}(i).then((function(){return r}))})):Promise.reject(new u(fe()))},t}var Je={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function ze(n,t,r,i){var o=L({logger:{default:i}},Je,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){I((function(){t&&t.maybeReportError(new c(e))}))}var s=L({},n||{});return function(e){var n=e;Object.keys(a).forEach((function(e){if(void 0!==n[e]){var t=a[e];i&&i.warn(ge(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),s=function(n){var t=L({},n),r=function(n){if(null===n)return"any";if(void 0!==n){if(Array.isArray(n))return"array";var t=e(n);return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"}};return Object.keys(n).forEach((function(e){var i=n[e];if(null!=i){var a=o[e];if(void 0===a)u(Ee(e));else{var s=a.type||r(a.default);if("any"!==s){var c=s.split("|"),l=r(i);c.indexOf(l)<0?"boolean"===s?(t[e]=!!i,u(De(e,l))):(u(we(e,s,l)),t[e]=a.default):"number"===l&&void 0!==a.minimum&&i<a.minimum&&(u(Se(e,i,a.minimum)),t[e]=a.minimum)}}}})),t}(s=function(e){var n=L({},e);return Object.keys(o).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=o[e]&&o[e].default)})),n}(s))}var Me=Object.freeze({__proto__:null,baseOptionDefs:Je,validate:ze}).baseOptionDefs;var Be=function(e){var n={diagnosticId:H()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n},Ke=function(e){var n,t,r,i;function o(e){n=e,t=0,r=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},$e=function(e,n,t,i,o,a){var u,s,c=!!e.diagnosticUseCombinedEvent,l="ld:"+i+":$diagnostics",f=o.eventsUrl+"/events/diagnostic/"+i,v=o.diagnosticRecordingInterval,d=n,g=!!o.streaming,m={};function p(){return{sdk:b(),configuration:(n={customBaseURI:o.baseUrl!==Me.baseUrl.default,customStreamURI:o.streamUrl!==Me.streamUrl.default,customEventsURI:o.eventsUrl!==Me.eventsUrl.default,eventsCapacity:o.eventCapacity,eventsFlushIntervalMillis:o.flushInterval,reconnectTimeMillis:o.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!o.allAttributesPrivate,inlineUsersInEvents:!!o.inlineUsersInEvents,diagnosticRecordingIntervalMillis:o.diagnosticRecordingInterval,usingSecureMode:!!o.hash,bootstrapMode:!!o.bootstrap,fetchGoalsDisabled:!o.fetchGoals,allowFrequentDuplicateEvents:!!o.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!o.sendEventsOnlyForVariation},n),platform:e.diagnosticPlatformData};var n}function h(e){o.logger&&o.logger.debug(Ce.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then((function(){})).catch((function(){}))}function y(){var n,t;h((n=(new Date).getTime(),t=r({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:n},d.getProps()),c&&(t=r({},t,{},p())),d.reset(n),t)),s=setTimeout(y,v),u=(new Date).getTime(),c&&function(){if(e.localStorage){var n=r({},d.getProps());e.localStorage.set(l,JSON.stringify(n),(function(){}))}}()}function b(){var n=r({},e.diagnosticSdkData);return o.wrapperName&&(n.wrapperName=o.wrapperName),o.wrapperVersion&&(n.wrapperVersion=o.wrapperVersion),n}return m.start=function(){c?function(n){if(!e.localStorage)return n(!1);e.localStorage.get(l).then((function(e){if(e)try{var t=JSON.parse(e);d.setProps(t),u=t.dataSinceDate}catch(e){}n(!0)})).catch((function(){n(!1)}))}((function(e){if(e){var n=(u||0)+v,t=(new Date).getTime();t>=n?y():s=setTimeout(y,n-t)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,v)})):(h(r({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate},p())),s=setTimeout(y,v))},m.stop=function(){s&&clearTimeout(s)},m.setStreaming=function(e){g=e},m};function He(e,n){var t,r=["debug","info","warn","error"];t=null!=n?""===n?"":n+" ":"LD: ";var i=0;e&&(i="none"===e?100:r.indexOf(e));var o={};function a(e,n,o){if(e>=i&&console){var a=console[n];if(a){var u=e<r.length?r[e]:"?";a.call(console,t+"["+u+"] "+o)}}}return o.debug=function(e){return a(0,"log",e)},o.info=function(e){return a(1,"info",e)},o.warn=function(e){return a(2,"warn",e)},o.error=function(e){return a(3,"error",e)},o}function Ge(n,t,i,u,c){var v,d,g,m,p=function(){if(i&&i.logger)return i.logger;return c&&c.logger&&c.logger.default||He("warn")}(),h=Le(p),y=Ae(h),b=ze(i,h,c,p),k=b.sendEvents,E=n,w=b.hash,D=G(u,E,b),S=b.sendEvents&&!b.diagnosticOptOut,P=S?Be(E):null,R=S?Ke((new Date).getTime()):null,N=S?$e(u,R,D,E,b,P):null,F=Ve(u,b,E,R),C=b.eventProcessor||function(e,n,t){var r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=u||G(e,t,n),l=n.eventsUrl+"/events/bulk/"+t,v=X(),d=W(n),g=n.inlineUsersInEvents,m=n.samplingInterval,p=n.eventCapacity,h=n.flushInterval,y=n.logger,b=[],k=0,E=!1,w=!1;function D(){return 0===m||0===Math.floor(Math.random()*m)}function S(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}function P(e){var n=L({},e);return g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}function O(e){b.length<p?(b.push(e),w=!1):(w||(w=!0,y.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),i&&i.incrementDroppedEvents())}return s.enqueue=function(e){if(!E){var n=!1,t=!1;if(v.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=S(e)):n=D(),n&&O(P(e)),t){var r=L({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,O(r)}}},s.flush=function(){if(E)return Promise.resolve();var e=b,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),i&&i.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],y.debug(Fe(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(k=e.serverTime),f(e.status)||(E=!0),e.status>=400&&I((function(){a.maybeReportError(new o(me(e.status,"event posting","some events were dropped")))})))})))},s.start=function(){r=setTimeout((function e(){s.flush(),r=setTimeout(e,h)}),h)},s.stop=function(){clearTimeout(r)},s}(u,b,E,R,h,D),V=qe(u,b,E),q={},_={},J=b.streaming,z=!1,M=!1,B=!0,K=b.stateProvider,$=function(e,n){var t,r={};return r.setUser=function(e){(t=x(e))&&n&&n(O(t))},r.getUser=function(){return t?O(t):null},e&&r.setUser(e),r}(null,(function(e){if(K)return;e&&Q({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})),H=_e(u.localStorage,p);function Q(e){E&&(K&&K.enqueueEvent&&K.enqueueEvent(e)||(e.user?(B=!1,!k||M||u.isDoNotTrack()||(p.debug(Ne(e.kind)),C.enqueue(e))):B&&(p.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),B=!1)))}function Y(e,n,t,r){var i=$.getUser(),o=new Date,a=n?n.value:null;if(!b.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=q[u];if(s&&o-s<3e5)return;q[u]=o}var c={kind:"feature",key:e,user:i,value:a,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()},l=_[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),Q(c)}function Z(e,n,t,r){var i;if(_&&A(_,e)&&_[e]&&!_[e].deleted){var o=_[e];i=ee(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&Y(e,i,n,r),i}function ee(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function ne(){d=!0,$.getUser()&&F.connect($.getUser(),w,{ping:function(){p.debug("received ping message from stream"),V.fetchFlagSettings($.getUser(),w).then((function(e){return re(e||{})})).catch((function(e){h.maybeReportError(new l(ce(e)))}))},put:function(e){var n=JSON.parse(e.data);p.debug("received streaming update for all flags"),re(n)},patch:function(e){var n=JSON.parse(e.data),t=_[n.key];if(!t||!t.version||!n.version||t.version<n.version){p.debug(Ie(n.key));var r={},i=L({},n);delete i.key,_[n.key]=i;var o=ee(i);r[n.key]=t?{previous:t.value,current:o}:{current:o},ie(r)}else p.debug(je(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!_[n.key]||_[n.key].version<n.version){p.debug(Re(n.key));var t={};_[n.key]&&!_[n.key].deleted&&(t[n.key]={previous:_[n.key].value}),_[n.key]={version:n.version,deleted:!0},ie(t)}else p.debug(Te(n.key))}})}function te(){d&&(F.disconnect(),d=!1)}function re(e){var n={};if(!e)return Promise.resolve();for(var t in _)A(_,t)&&_[t]&&(e[t]&&!U(e[t].value,_[t].value)?n[t]={previous:_[t].value,current:ee(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:_[t].value}));for(var i in e)A(e,i)&&e[i]&&(!_[i]||_[i].deleted)&&(n[i]={current:ee(e[i])});return _=r({},e),ie(n).catch((function(){}))}function ie(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,i=r?r.value:void 0,o=e[n].previous;h.emit("change:"+n,i,o),t[n]=r?{current:i,previous:o}:{previous:o}})),h.emit("change",t),h.emit("internal-change",_),b.sendEventsOnlyForVariation||K||n.forEach((function(n){Y(n,e[n].current)}))}return v&&m?m.saveFlags(_).catch((function(){return null})):Promise.resolve()}function oe(){var e=J||g&&void 0===J;e&&!d?ne():!e&&d&&te(),N&&N.setStreaming(e)}function ue(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if(u.localStorage&&(m=new xe(u.localStorage,E,w,$,p)),"string"==typeof b.bootstrap&&"LOCALSTORAGE"===b.bootstrap.toUpperCase()&&(m?v=!0:p.warn("localStorage is unavailable")),"object"===e(b.bootstrap)&&(_=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&p.warn(ve()),!1===e.$valid&&p.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var i={value:e[n]};t&&t[n]?i=L(i,t[n]):i.version=0,r[n]=i}})),r}(b.bootstrap)),K){var le=K.getInitialState();le?fe(le):K.on("init",fe),K.on("update",(function(e){e.user&&$.setUser(e.user);e.flags&&re(e.flags)}))}else(function(){if(!n)return Promise.reject(new a(se()));return H.validateUser(t).then((function(n){return $.setUser(n),"object"===e(b.bootstrap)?de():v?m.loadFlags().catch((function(){return null})).then((function(e){return null==e?(_={},V.fetchFlagSettings($.getUser(),w).then((function(e){return re(e||{})})).then(de).catch((function(e){ge(new l(ce(e)))}))):(_=e,I(de),V.fetchFlagSettings($.getUser(),w).then((function(e){return re(e)})).catch((function(e){return h.maybeReportError(e)})))})):V.fetchFlagSettings($.getUser(),w).then((function(e){_=e||{},de()})).catch((function(e){_={},ge(e)}))}))})().catch(ge);function fe(e){E=e.environment,$.setUser(e.user),_=r({},e.flags),I(de)}function de(){p.info("LaunchDarkly client initialized"),z=!0,oe(),y.signalSuccess()}function ge(e){y.signalFailure(e)}return{client:{waitForInitialization:function(){return y.getInitializationPromise()},waitUntilReady:function(){return y.getReadyPromise()},identify:function(e,n,t){return M?j(Promise.resolve({}),t):K?(p.warn("identify() has no effect here; it must be called on the main client instance"),j(Promise.resolve(T(_)),t)):j((v&&m?m.clearFlags():Promise.resolve()).then((function(){return H.validateUser(e)})).then((function(e){return V.fetchFlagSettings(e,n).then((function(t){var r=T(t);return $.setUser(e),w=n,t?re(t).then((function(){return r})):r}))})).then((function(e){return d&&ne(),e})).catch((function(e){return h.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return $.getUser()},variation:function(e,n){return Z(e,n,!0,!1).value},variationDetail:function(e,n){return Z(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){u.customEventFilter&&!u.customEventFilter(e)&&p.warn(ae(e));var r={kind:"custom",key:e,user:$.getUser(),url:u.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),Q(r)}else h.maybeReportError(new s(ae(e)))},on:function(e,n,t){ue(e)?(g=!0,z&&oe(),h.on(e,n,t)):h.on.apply(h,arguments)},off:function(e){if(h.off.apply(h,arguments),ue(e)){var n=!1;h.getEvents().forEach((function(e){ue(e)&&h.getEventListenerCount(e)>0&&(n=!0)})),n||(g=!1,d&&void 0===J&&te())}},setStreaming:function(e){var n=null===e?void 0:e;n!==J&&(J=n,oe())},flush:function(e){return j(k?C.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!_)return e;for(var n in _)A(_,n)&&(e[n]=Z(n,null,!b.sendEventsOnlyForVariation).value);return e},close:function(e){if(M)return j(Promise.resolve(),e);var n=function(){M=!0,_={}};return j(Promise.resolve().then((function(){if(te(),N&&N.stop(),k)return C.stop(),C.flush()})).then(n).catch(n),e)}},options:b,emitter:h,ident:$,logger:p,requestor:V,start:function(){k&&(N&&N.start(),C.start())},enqueueEvent:Q,getFlagsInternal:function(){return _},getEnvironmentId:function(){return E},internalChangeEventName:"internal-change"}}var Xe="3.2.7";export{He as createConsoleLogger,v as errors,Ge as initialize,Ce as messages,V as utils,Xe as version};
//# sourceMappingURL=ldclient-common.es.js.map

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self)["LDClient-Common"]={})}(this,function(e){"use strict";function H(e){return(H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function G(i){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?n(o,!0).forEach(function(e){var n,t,r;n=i,r=o[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(o)):n(o).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(o,e))})}return i}function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var P=t("LaunchDarklyUnexpectedResponseError"),X=t("LaunchDarklyInvalidEnvironmentIdError"),o=t("LaunchDarklyInvalidUserError"),W=t("LaunchDarklyInvalidEventKeyError"),d=t("LaunchDarklyInvalidArgumentError"),Q=t("LaunchDarklyFlagFetchError");function O(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var r=Object.freeze({__proto__:null,LDUnexpectedResponseError:P,LDInvalidEnvironmentIdError:X,LDInvalidUserError:o,LDInvalidEventKeyError:W,LDInvalidArgumentError:d,LDFlagFetchError:Q,isHttpErrorRecoverable:O}),i=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(f(e,o,a<o+16383?a:o+16383));1==r?(n=e[t-1],i.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],i.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"="));return i.join("")},u=[],a=[],s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=s.length;c<l;++c)u[c]=s[c],a[s.charCodeAt(c)]=c;function f(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(u[(i=r)>>18&63]+u[i>>12&63]+u[i>>6&63]+u[63&i]);return o.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63;var g=Array.isArray,m=Object.keys,p=Object.prototype.hasOwnProperty,v=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=g(n),u=g(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=m(n);if((i=v.length)!==m(t).length)return!1;for(r=i;0!=r--;)if(!p.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t},h=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function y(e){var n=unescape(encodeURIComponent(e));return i(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function S(e){return y(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Y(e){return JSON.parse(JSON.stringify(e))}function Z(e,n){return v(e,n)}function ee(e){setTimeout(e,0)}function ne(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function b(e){var n={};for(var t in e)ie(e,t)&&(n[t]={value:e[t],version:0});return n}function te(e){var n={};for(var t in e)ie(e,t)&&(n[t]=e[t].value);return n}function k(e,n){for(var t,r=n.slice(0),i=[],o=e;0<r.length;){for(t=[];0<o;){var a=r.shift();if(!a)break;(o-=S(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function E(e){var n=e.version||"3.2.6";return e.userAgent+"/"+n}function U(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":E(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function re(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return G({},e,{},n)},{})}function ie(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function oe(e){if(!e)return e;var n;for(var t in h){var r=h[t],i=e[r];void 0!==i&&"string"!=typeof i&&((n=n||G({},e))[r]=String(i))}return n||e}var w=Object.freeze({__proto__:null,btoa:y,base64URLEncode:S,clone:Y,deepEquals:Z,onNextTick:ee,wrapPromiseCallback:ne,transformValuesToVersionedValues:b,transformVersionedValuesToValues:te,chunkUserEventsForUrl:k,getLDUserAgentString:E,getLDHeaders:U,extend:re,objectHasOwnProperty:ie,sanitizeUser:oe});for(var D,I=(function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}(D={exports:{}},D.exports),D.exports),j=[],R=0;R<256;++R)j[R]=(R+256).toString(16).substr(1);var T,N,F=function(e,n){var t=n||0,r=j;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},C=0,L=0;var A=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||T,a=void 0!==e.clockseq?e.clockseq:N;if(null==o||null==a){var u=I();null==o&&(o=T=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=N=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:L+1,l=s-C+(c-L)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||C<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");C=s,N=a;var f=(1e4*(268435455&(s+=122192928e5))+(L=c))%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var v=s/4294967296*1e4&268435455;i[r++]=v>>>8&255,i[r++]=255&v,i[r++]=v>>>24&15|16,i[r++]=v>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var d=0;d<6;++d)i[r+d]=o[d];return n||F(i)},x=2e3;function ae(u,e,n){var t="/a/"+e+".gif",s=re({"Content-Type":"application/json"},U(u,n)),c=u.httpFallbackPing,l={};return l.sendChunk=function(e,r,i,n){var o=JSON.stringify(e),a=i?null:A();return n?function n(t){var e=i?s:re({},s,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,e,o).promise.then(function(e){if(e)return 400<=e.status&&O(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(c&&c(r+t+"?d="+S(o)),Promise.resolve())},l.sendEvents=function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,i=u.httpAllowsPost();r=i?[e]:k(x-n.length,e);for(var o=[],a=0;a<r.length;a++)o.push(l.sendChunk(r[a],n,t,i));return Promise.all(o)},l}function _(e){var n={},s=e.allAttributesPrivate,c=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(r,i){return Object.keys(r).reduce(function(e,n){var t=e;return i(n)&&(!function(e){return!l[e]&&(s||-1!==o.indexOf(e)||-1!==c.indexOf(e))}(n)?t[0][n]=r[n]:t[1][n]=!0),t},[{},{}])}var o=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],i=t[1];if(e.custom){var a=n(e.custom,function(){return!0});r.custom=a[0],i=re({},i,a[1])}var u=Object.keys(i);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function V(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}function q(){return"LaunchDarkly client initialized"}function J(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"}function ue(e){return'Custom event "'+e+'" does not exist'}function se(){return"No environment/client-side ID was specified."+$}function ce(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+$}function z(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."}function M(){return"identify() has no effect here; it must be called on the main client instance"}function B(){return"received ping message from stream"}function K(){return"received streaming update for all flags"}function le(e){return'received streaming update for flag "'+e+'"'}function fe(e){return'received streaming update for flag "'+e+'" but ignored due to version check'}function ve(e){return'received streaming deletion for flag "'+e+'"'}function de(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'}function ge(e){return'enqueueing "'+e+'" event'}var $=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",me=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},pe=function(e){return'Expected application/json content type but got "'+e+'"'},he=function(){return"localStorage is unavailable"},ye=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},be=function(e){return"network error"+(e?" ("+e+")":"")},ke=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+$},Ee=function(e){return"Error fetching flag settings: "+V(e)},we=function(){return"No user specified."+$},De=function(){return"Invalid user specified."+$},Se=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},Pe=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(O(e)?t:"giving up permanently")},Oe=function(){return"Cannot make HTTP requests in this environment."+$},Ue=function(){return"Closing stream connection"},Ie=function(e){return"Opening stream connection to "+e},je=function(e,n){return"Error on stream connection: "+V(e)+", will continue retrying every "+n+" milliseconds."},Re=function(e){return'Ignoring unknown config option "'+e+'"'},Te=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Ne=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Fe=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Ce=function(e){return"polling for feature flags at "+e},Le=function(e){return"sending "+e+" events"},Ae=Object.freeze({__proto__:null,clientInitialized:q,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:me,eventWithoutUser:J,invalidContentType:pe,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:he,localStorageUnavailableForUserId:ye,networkError:be,unknownCustomEventKey:ue,environmentNotFound:ke,environmentNotSpecified:se,errorFetchingFlags:Ee,userNotSpecified:we,invalidUser:De,bootstrapOldFormat:ce,bootstrapInvalid:z,deprecated:Se,httpErrorMessage:Pe,httpUnavailable:Oe,identifyDisabled:M,streamClosing:Ue,streamConnecting:Ie,streamError:je,unknownOption:Re,wrongOptionType:Te,wrongOptionTypeBoolean:Ne,optionBelowMinimum:Fe,debugPolling:Ce,debugStreamPing:B,debugStreamPut:K,debugStreamPatch:le,debugStreamPatchIgnored:fe,debugStreamDelete:ve,debugStreamDeleteIgnored:de,debugEnqueueingEvent:ge,debugPostingEvents:Le,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function xe(e,n,t,r,i,o){var a,u=3<arguments.length&&void 0!==r?r:null,s=4<arguments.length&&void 0!==i?i:null,c={},l=(5<arguments.length&&void 0!==o?o:null)||ae(e,t,n),f=n.eventsUrl+"/events/bulk/"+t,v=function(){var e={},a=0,u=0,s={};return e.summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=s[n];t?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate)}},e.getSummary=function(){var e={},n=!0;for(var t in s){var r=s[t],i=e[r.key];i||(i={default:r.default,counters:[]},e[r.key]=i);var o={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(o.variation=r.variation),r.version?o.version=r.version:o.unknown=!0,i.counters.push(o),n=!1}return n?null:{startDate:a,endDate:u,features:e}},e.clearSummary=function(){u=a=0,s={}},e}(),d=_(n),g=n.inlineUsersInEvents,m=n.samplingInterval,p=n.eventCapacity,h=n.flushInterval,y=n.logger,b=[],k=0,E=!1,w=!1;function D(){return 0===m||0===Math.floor(Math.random()*m)}function S(e){b.length<p?(b.push(e),w=!1):(w||(w=!0,y.warn(me())),u&&u.incrementDroppedEvents())}return c.enqueue=function(e){if(!E){var n=!1,t=!1;if(v.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}(e)):n=D(),n&&S(function(e){var n=re({},e);return g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),t){var r=re({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,S(r)}}},c.flush=function(){if(E)return Promise.resolve();var e=b,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),u&&u.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],y.debug(Le(e.length)),l.sendEvents(e,f).then(function(e){e&&(e.serverTime&&(k=e.serverTime),O(e.status)||(E=!0),400<=e.status&&ee(function(){s.maybeReportError(new P(Pe(e.status,"event posting","some events were dropped")))}))}))},c.start=function(){a=setTimeout(function e(){c.flush(),a=setTimeout(e,h)},h)},c.stop=function(){clearTimeout(a)},c}function _e(n){var e={},i={};return e.on=function(e,n,t){i[e]=i[e]||[],i[e]=i[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(i[e])for(var r=0;r<i[e].length;r++)i[e][r].handler===n&&i[e][r].context===t&&(i[e]=i[e].slice(0,r).concat(i[e].slice(r+1)))},e.emit=function(e){if(i[e])for(var n=i[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(i)},e.getEventListenerCount=function(e){return i[e]?i[e].length:0},e.maybeReportError=function(e){e&&(!function(e){return!!i[e]}("error")?(n||console).error(e.message):this.emit("error",e))},e}var Ve="ready",qe="initialized",Je="failed";var ze=function(r){var n=!1,t=!1,i=null,e=null,o=new Promise(function(n){r.on(Ve,function e(){r.off(Ve,e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(i):e=new Promise(function(n,t){r.on(qe,function e(){r.off(qe,e),n()}),r.on(Je,function e(n){r.off(Je,e),t(n)})}))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,r.emit(qe),r.emit(Ve))},signalFailure:function(e){n||t||(t=!0,i=e,r.emit(Je,e),r.emit(Ve)),r.maybeReportError(e)}}};function Me(t,r,i,o,a){var u={};function s(){var e="",n=o.getUser();return n&&(e=i||y(JSON.stringify(n))),"ld:"+r+":"+e}return u.loadFlags=function(){return t.get(s()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=b(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn(he()),Promise.reject(e)})},u.saveFlags=function(e){var n=re({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn(he()),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn(he()),Promise.reject(e)})},u}function Be(i,e,o,n){var a,u=e.streamUrl,s=e.logger,t={},c=u+"/eval/"+o,l=e.useReport,f=e.evaluationReasons,r=e.streamReconnectDelay,v=U(i,e),d=!1,g=null,m=null,p=null,h=null,y=null;function b(e){d||(s.warn(je(e,r)),d=!0),D(!1),w(),k(r)}function k(e){m||(e?m=setTimeout(E,e):E())}function E(){var e;m=null;var n="",t={headers:v};if(i.eventSourceFactory){for(var r in null!=h&&(n="h="+h),l?i.eventSourceAllowsReport?(e=c,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(p)):(e=u+"/ping/"+o,n=""):e=c+"/"+S(JSON.stringify(p)),f&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,w(),s.info(Ie(e)),a=(new Date).getTime(),g=i.eventSourceFactory(e,t),y)ie(y,r)&&g.addEventListener(r,y[r]);g.onerror=b}}function w(){g&&(s.info(Ue()),g.close(),g=null)}function D(e){a&&n&&n.recordStreamInit(a,!e,(new Date).getTime()-a),a=null}return t.connect=function(e,n,t){p=e,h=n,y={};function r(n){y[n]=function(e){D(!(d=!1)),t[n]&&t[n](e)}}for(var i in t||{})r(i);k()},t.disconnect=function(){clearTimeout(m),m=null,w()},t.isConnected=function(){return!!(g&&i.eventSourceIsActive&&i.eventSourceIsActive(g))},t}var Ke="application/json";function $e(u,s,a){var c=s.baseUrl,l=s.useReport,f=s.evaluationReasons,v=s.logger,e={},d={};function g(e,n){if(!u.httpRequest)return new Promise(function(e,n){n(new Q(Oe()))});var t=n?"REPORT":"GET",r=U(u,s);n&&(r["Content-Type"]=Ke);var i=d[e];i||(i=function(t){var r,i,o,a,e={addPromise:function(n,e){r=n,i&&i(),i=e,n.then(function(e){r===n&&(o(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}};return e.resultPromise=new Promise(function(e,n){o=e,a=n}),e}(function(){delete d[e]}),d[e]=i);var o=u.httpRequest(t,e,r,n),a=o.promise.then(function(e){if(200!==e.status)return Promise.reject(function(e){return 404===e.status?new X(ke()):new Q(Ee(e.statusText||String(e.status)))}(e));if(e.header("content-type")&&e.header("content-type").startsWith(Ke))return JSON.parse(e.body);var n=pe(e.header("content-type")||"");return Promise.reject(new Q(n))},function(e){return Promise.reject(new Q(be(e)))});return i.addPromise(a,function(){o.cancel&&o.cancel()}),i.resultPromise}return e.fetchJSON=function(e){return g(c+e,null)},e.fetchFlagSettings=function(e,n){var t,r,i,o="";return l?(r=[c,"/sdk/evalx/",a,"/user"].join(""),i=JSON.stringify(e)):(t=S(JSON.stringify(e)),r=[c,"/sdk/evalx/",a,"/users/",t].join("")),n&&(o="h="+n),f&&(o=o+(o?"&":"")+"withReasons=true"),r=r+(o?"?":"")+o,v.debug(Ce(r)),g(r,i)},e}var He="ld:$anonUserId";function Ge(r,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new o(we()));var t=Y(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?(r?r.get(He).catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return t.key=e,t;var n=A();return function(e){return r?r.set(He,e).catch(function(){i.warn(ye())}):Promise.resolve()}(t.key=n).then(function(){return t})}):Promise.reject(new o(De()))},e}var Xe={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function We(e,n,t,r){var a=re({logger:{default:r}},Xe,t),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){ee(function(){n&&n.maybeReportError(new d(e))})}var o,s,c,l,f=re({},e||{});function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=H(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}return o=f,Object.keys(i).forEach(function(e){if(void 0!==o[e]){var n=i[e];r&&r.warn(Se(e,n)),n&&(void 0===o[n]&&(o[n]=o[e]),delete o[e])}}),s=re({},f),Object.keys(a).forEach(function(e){void 0!==s[e]&&null!==s[e]||(s[e]=a[e]&&a[e].default)}),l=re({},c=f=s),Object.keys(c).forEach(function(e){var n=c[e];if(null!=n){var t=a[e];if(void 0===t)u(Re(e));else{var r=t.type||v(t.default);if("any"!==r){var i=r.split("|"),o=v(n);i.indexOf(o)<0?"boolean"===r?(l[e]=!!n,u(Ne(e,o))):(u(Te(e,r,o)),l[e]=t.default):"number"===o&&void 0!==t.minimum&&n<t.minimum&&(u(Fe(e,n,t.minimum)),l[e]=t.minimum)}}}}),f=l}var Qe=Object.freeze({__proto__:null,baseOptionDefs:Xe,validate:We}).baseOptionDefs;var Ye=function(e){var n={diagnosticId:A()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},Ze=function(e){var n,t,r,i;function o(e){n=e,r=t=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},en=function(n,e,t,r,i,o){var a,u,s=!!n.diagnosticUseCombinedEvent,c="ld:"+r+":$diagnostics",l=i.eventsUrl+"/events/diagnostic/"+r,f=i.diagnosticRecordingInterval,v=e,d=!!i.streaming,g={};function m(){return{sdk:function(){var e=G({},n.diagnosticSdkData);i.wrapperName&&(e.wrapperName=i.wrapperName);i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion);return e}(),configuration:{customBaseURI:i.baseUrl!==Qe.baseUrl.default,customStreamURI:i.streamUrl!==Qe.streamUrl.default,customEventsURI:i.eventsUrl!==Qe.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!d,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation},platform:n.diagnosticPlatformData}}function p(e){i.logger&&i.logger.debug(Ae.debugPostingDiagnosticEvent(e)),t.sendEvents(e,l,!0).then(function(){}).catch(function(){})}function h(){p(function(){var e=(new Date).getTime(),n=G({kind:s?"diagnostic-combined":"diagnostic",id:o,creationDate:e},v.getProps());return s&&(n=G({},n,{},m())),v.reset(e),n}()),u=setTimeout(h,f),a=(new Date).getTime(),s&&function(){if(n.localStorage){var e=G({},v.getProps());n.localStorage.set(c,JSON.stringify(e),function(){})}}()}return g.start=function(){s?function(t){if(!n.localStorage)return t(!1);n.localStorage.get(c).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),a=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(a||0)+f,t=(new Date).getTime();n<=t?h():u=setTimeout(h,n-t)}else 0===Math.floor(4*Math.random())?h():u=setTimeout(h,f)}):(p(G({kind:"diagnostic-init",id:o,creationDate:v.getProps().dataSinceDate},m())),u=setTimeout(h,f))},g.stop=function(){u&&clearTimeout(u)},g.setStreaming=function(e){d=e},g};function nn(e,n){var o,a=["debug","info","warn","error"];o=null!=n?""===n?"":n+" ":"LD: ";var u=0;e&&(u="none"===e?100:a.indexOf(e));var t={};function r(e,n,t){if(u<=e&&console){var r=console[n];if(r){var i=e<a.length?a[e]:"?";r.call(console,o+"["+i+"] "+t)}}}return t.debug=function(e){return r(0,"log",e)},t.info=function(e){return r(1,"info",e)},t.warn=function(e){return r(2,"warn",e)},t.error=function(e){return r(3,"error",e)},t}var tn="change",rn="internal-change";e.createConsoleLogger=nn,e.errors=r,e.initialize=function(e,n,t,i,r){var a=function(){if(t&&t.logger)return t.logger;return r&&r.logger&&r.logger.default||nn("warn")}(),u=_e(a),o=ze(u),f=We(t,u,r,a),s=f.sendEvents,c=e,l=f.hash,v=ae(i,c,f),d=f.sendEvents&&!f.diagnosticOptOut,g=d?Ye(c):null,m=d?Ze((new Date).getTime()):null,p=d?en(i,m,v,c,f,g):null;p&&p.start();var h,y,b,k,E=Be(i,f,c,m),w=f.eventProcessor||xe(i,f,c,m,u,v),D=$e(i,f,c),S={},P={},O=f.streaming,U=!1,I=!1,j=!0,R=f.stateProvider,T=function(e,n){var t,r={};return r.setUser=function(e){(t=oe(e))&&n&&n(Y(t))},r.getUser=function(){return t?Y(t):null},e&&r.setUser(e),r}(null,function(e){if(R)return;e&&F({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),N=Ge(i.localStorage,a);function F(e){c&&(R&&R.enqueueEvent&&R.enqueueEvent(e)||(e.user?(j=!1,!s||I||i.isDoNotTrack()||(a.debug(ge(e.kind)),w.enqueue(e))):j&&(a.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),j=!1)))}function C(e,n,t,r){var i=T.getUser(),o=new Date,a=n?n.value:null;if(!f.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=S[u];if(s&&o-s<3e5)return;S[u]=o}var c={kind:"feature",key:e,user:i,value:a,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()},l=P[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),F(c)}function L(e,n,t,r){var i;if(P&&ie(P,e)&&P[e]&&!P[e].deleted){var o=P[e];i=A(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&C(e,i,n,r),i}function A(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function x(){y=!0,T.getUser()&&E.connect(T.getUser(),l,{ping:function(){a.debug("received ping message from stream"),D.fetchFlagSettings(T.getUser(),l).then(function(e){return V(e||{})}).catch(function(e){u.maybeReportError(new Q(Ee(e)))})},put:function(e){var n=JSON.parse(e.data);a.debug("received streaming update for all flags"),V(n)},patch:function(e){var n=JSON.parse(e.data),t=P[n.key];if(!t||!t.version||!n.version||t.version<n.version){a.debug(le(n.key));var r={},i=re({},n);delete i.key;var o=A(P[n.key]=i);r[n.key]=t?{previous:t.value,current:o}:{current:o},q(r)}else a.debug(fe(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!P[n.key]||P[n.key].version<n.version){a.debug(ve(n.key));var t={};P[n.key]&&!P[n.key].deleted&&(t[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},q(t)}else a.debug(de(n.key))}})}function _(){y&&(E.disconnect(),y=!1)}function V(e){var n={};if(!e)return Promise.resolve();for(var t in P)ie(P,t)&&P[t]&&(e[t]&&!Z(e[t].value,P[t].value)?n[t]={previous:P[t].value,current:A(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:P[t].value}));for(var r in e)ie(e,r)&&e[r]&&(!P[r]||P[r].deleted)&&(n[r]={current:A(e[r])});return P=G({},e),q(n).catch(function(){})}function q(i){var e=Object.keys(i);if(0<e.length){var o={};e.forEach(function(e){var n=i[e].current,t=n?n.value:void 0,r=i[e].previous;u.emit(tn+":"+e,t,r),o[e]=n?{current:t,previous:r}:{previous:r}}),u.emit(tn,o),u.emit(rn,P),f.sendEventsOnlyForVariation||R||e.forEach(function(e){C(e,i[e].current)})}return h&&k?k.saveFlags(P).catch(function(){return null}):Promise.resolve()}function J(){var e=O||b&&void 0===O;e&&!y?x():!e&&y&&_(),p&&p.setStreaming(e)}function z(e){return e===tn||e.substr(0,tn.length+1)===tn+":"}if(i.localStorage&&(k=new Me(i.localStorage,c,l,T,a)),"string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(k?h=!0:a.warn(he())),"object"===H(f.bootstrap)&&(P=function(t){var e=Object.keys(t),r="$flagsState",i=t[r];!i&&e.length&&a.warn(ce()),!1===t.$valid&&a.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var o={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var n={value:t[e]};i&&i[e]?n=re(n,i[e]):n.version=0,o[e]=n}}),o}(f.bootstrap)),R){var M=R.getInitialState();M?B(M):R.on("init",B),R.on("update",function(e){e.user&&T.setUser(e.user);e.flags&&V(e.flags)})}else(e?N.validateUser(n).then(function(e){return T.setUser(e),"object"===H(f.bootstrap)?K():h?k.loadFlags().catch(function(){return null}).then(function(e){return null==e?(P={},D.fetchFlagSettings(T.getUser(),l).then(function(e){return V(e||{})}).then(K).catch(function(e){$(new Q(Ee(e)))})):(P=e,ee(K),D.fetchFlagSettings(T.getUser(),l).then(function(e){return V(e)}).catch(function(e){return u.maybeReportError(e)}))}):D.fetchFlagSettings(T.getUser(),l).then(function(e){P=e||{},K()}).catch(function(e){P={},$(e)})}):Promise.reject(new X(se()))).catch($);function B(e){c=e.environment,T.setUser(e.user),P=G({},e.flags),ee(K)}function K(){a.info("LaunchDarkly client initialized"),U=!0,J(),o.signalSuccess()}function $(e){o.signalFailure(e)}return{client:{waitForInitialization:function(){return o.getInitializationPromise()},waitUntilReady:function(){return o.getReadyPromise()},identify:function(e,r,n){return I?ne(Promise.resolve({}),n):R?(a.warn("identify() has no effect here; it must be called on the main client instance"),ne(Promise.resolve(te(P)),n)):ne((h&&k?k.clearFlags():Promise.resolve()).then(function(){return N.validateUser(e)}).then(function(t){return D.fetchFlagSettings(t,r).then(function(e){var n=te(e);return T.setUser(t),l=r,e?V(e).then(function(){return n}):n})}).then(function(e){return y&&x(),e}).catch(function(e){return u.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return T.getUser()},variation:function(e,n){return L(e,n,!0,!1).value},variationDetail:function(e,n){return L(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&a.warn(ue(e));var r={kind:"custom",key:e,user:T.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),F(r)}else u.maybeReportError(new W(ue(e)))},on:function(e,n,t){z(e)?(b=!0,U&&J(),u.on(e,n,t)):u.on.apply(u,arguments)},off:function(e){if(u.off.apply(u,arguments),z(e)){var n=!1;u.getEvents().forEach(function(e){z(e)&&0<u.getEventListenerCount(e)&&(n=!0)}),n||(b=!1,y&&void 0===O&&_())}},setStreaming:function(e){var n=null===e?void 0:e;n!==O&&(O=n,J())},flush:function(e){return ne(s?w.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!P)return e;for(var n in P)ie(P,n)&&(e[n]=L(n,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){if(I)return ne(Promise.resolve(),e);function n(){I=!0,P={}}return ne(Promise.resolve().then(function(){if(_(),p&&p.stop(),s)return w.stop(),w.flush()}).then(n).catch(n),e)}},options:f,emitter:u,ident:T,logger:a,requestor:D,start:function(){s&&(p&&p.start(),w.start())},enqueueEvent:F,getFlagsInternal:function(){return P},getEnvironmentId:function(){return c},internalChangeEventName:rn}},e.messages=Ae,e.utils=w,e.version="3.2.6",Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self)["LDClient-Common"]={})}(this,function(e){"use strict";function H(e){return(H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function G(i){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?n(o,!0).forEach(function(e){var n,t,r;n=i,r=o[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(o)):n(o).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(o,e))})}return i}function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var P=t("LaunchDarklyUnexpectedResponseError"),X=t("LaunchDarklyInvalidEnvironmentIdError"),o=t("LaunchDarklyInvalidUserError"),W=t("LaunchDarklyInvalidEventKeyError"),d=t("LaunchDarklyInvalidArgumentError"),Q=t("LaunchDarklyFlagFetchError");function O(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var r=Object.freeze({__proto__:null,LDUnexpectedResponseError:P,LDInvalidEnvironmentIdError:X,LDInvalidUserError:o,LDInvalidEventKeyError:W,LDInvalidArgumentError:d,LDFlagFetchError:Q,isHttpErrorRecoverable:O}),i=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(f(e,o,a<o+16383?a:o+16383));1==r?(n=e[t-1],i.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],i.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"="));return i.join("")},u=[],a=[],s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=s.length;c<l;++c)u[c]=s[c],a[s.charCodeAt(c)]=c;function f(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(u[(i=r)>>18&63]+u[i>>12&63]+u[i>>6&63]+u[63&i]);return o.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63;var g=Array.isArray,m=Object.keys,p=Object.prototype.hasOwnProperty,v=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=g(n),u=g(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=m(n);if((i=v.length)!==m(t).length)return!1;for(r=i;0!=r--;)if(!p.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t},h=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function y(e){var n=unescape(encodeURIComponent(e));return i(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function S(e){return y(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Y(e){return JSON.parse(JSON.stringify(e))}function Z(e,n){return v(e,n)}function ee(e){setTimeout(e,0)}function ne(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function b(e){var n={};for(var t in e)ie(e,t)&&(n[t]={value:e[t],version:0});return n}function te(e){var n={};for(var t in e)ie(e,t)&&(n[t]=e[t].value);return n}function k(e,n){for(var t,r=n.slice(0),i=[],o=e;0<r.length;){for(t=[];0<o;){var a=r.shift();if(!a)break;(o-=S(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function E(e){var n=e.version||"3.2.7";return e.userAgent+"/"+n}function U(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":E(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function re(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return G({},e,{},n)},{})}function ie(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function oe(e){if(!e)return e;var n;for(var t in h){var r=h[t],i=e[r];void 0!==i&&"string"!=typeof i&&((n=n||G({},e))[r]=String(i))}return n||e}var w=Object.freeze({__proto__:null,btoa:y,base64URLEncode:S,clone:Y,deepEquals:Z,onNextTick:ee,wrapPromiseCallback:ne,transformValuesToVersionedValues:b,transformVersionedValuesToValues:te,chunkUserEventsForUrl:k,getLDUserAgentString:E,getLDHeaders:U,extend:re,objectHasOwnProperty:ie,sanitizeUser:oe});for(var D,I=(function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}(D={exports:{}},D.exports),D.exports),j=[],R=0;R<256;++R)j[R]=(R+256).toString(16).substr(1);var T,N,F=function(e,n){var t=n||0,r=j;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},C=0,L=0;var A=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||T,a=void 0!==e.clockseq?e.clockseq:N;if(null==o||null==a){var u=I();null==o&&(o=T=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=N=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:L+1,l=s-C+(c-L)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||C<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");C=s,N=a;var f=(1e4*(268435455&(s+=122192928e5))+(L=c))%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var v=s/4294967296*1e4&268435455;i[r++]=v>>>8&255,i[r++]=255&v,i[r++]=v>>>24&15|16,i[r++]=v>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var d=0;d<6;++d)i[r+d]=o[d];return n||F(i)},x=2e3;function ae(u,e,n){var t="/a/"+e+".gif",s=re({"Content-Type":"application/json"},U(u,n)),c=u.httpFallbackPing,l={};return l.sendChunk=function(e,r,i,n){var o=JSON.stringify(e),a=i?null:A();return n?function n(t){var e=i?s:re({},s,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,e,o).promise.then(function(e){if(e)return 400<=e.status&&O(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(c&&c(r+t+"?d="+S(o)),Promise.resolve())},l.sendEvents=function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,i=u.httpAllowsPost();r=i?[e]:k(x-n.length,e);for(var o=[],a=0;a<r.length;a++)o.push(l.sendChunk(r[a],n,t,i));return Promise.all(o)},l}function _(e){var n={},s=e.allAttributesPrivate,c=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(r,i){return Object.keys(r).reduce(function(e,n){var t=e;return i(n)&&(!function(e){return!l[e]&&(s||-1!==o.indexOf(e)||-1!==c.indexOf(e))}(n)?t[0][n]=r[n]:t[1][n]=!0),t},[{},{}])}var o=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],i=t[1];if(e.custom){var a=n(e.custom,function(){return!0});r.custom=a[0],i=re({},i,a[1])}var u=Object.keys(i);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function V(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}function q(){return"LaunchDarkly client initialized"}function J(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"}function ue(e){return'Custom event "'+e+'" does not exist'}function se(){return"No environment/client-side ID was specified."+$}function ce(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+$}function z(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."}function M(){return"identify() has no effect here; it must be called on the main client instance"}function B(){return"received ping message from stream"}function K(){return"received streaming update for all flags"}function le(e){return'received streaming update for flag "'+e+'"'}function fe(e){return'received streaming update for flag "'+e+'" but ignored due to version check'}function ve(e){return'received streaming deletion for flag "'+e+'"'}function de(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'}function ge(e){return'enqueueing "'+e+'" event'}var $=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",me=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},pe=function(e){return'Expected application/json content type but got "'+e+'"'},he=function(){return"localStorage is unavailable"},ye=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},be=function(e){return"network error"+(e?" ("+e+")":"")},ke=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+$},Ee=function(e){return"Error fetching flag settings: "+V(e)},we=function(){return"No user specified."+$},De=function(){return"Invalid user specified."+$},Se=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},Pe=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(O(e)?t:"giving up permanently")},Oe=function(){return"Cannot make HTTP requests in this environment."+$},Ue=function(){return"Closing stream connection"},Ie=function(e){return"Opening stream connection to "+e},je=function(e,n){return"Error on stream connection: "+V(e)+", will continue retrying every "+n+" milliseconds."},Re=function(e){return'Ignoring unknown config option "'+e+'"'},Te=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Ne=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Fe=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Ce=function(e){return"polling for feature flags at "+e},Le=function(e){return"sending "+e+" events"},Ae=Object.freeze({__proto__:null,clientInitialized:q,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:me,eventWithoutUser:J,invalidContentType:pe,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:he,localStorageUnavailableForUserId:ye,networkError:be,unknownCustomEventKey:ue,environmentNotFound:ke,environmentNotSpecified:se,errorFetchingFlags:Ee,userNotSpecified:we,invalidUser:De,bootstrapOldFormat:ce,bootstrapInvalid:z,deprecated:Se,httpErrorMessage:Pe,httpUnavailable:Oe,identifyDisabled:M,streamClosing:Ue,streamConnecting:Ie,streamError:je,unknownOption:Re,wrongOptionType:Te,wrongOptionTypeBoolean:Ne,optionBelowMinimum:Fe,debugPolling:Ce,debugStreamPing:B,debugStreamPut:K,debugStreamPatch:le,debugStreamPatchIgnored:fe,debugStreamDelete:ve,debugStreamDeleteIgnored:de,debugEnqueueingEvent:ge,debugPostingEvents:Le,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function xe(e,n,t,r,i,o){var a,u=3<arguments.length&&void 0!==r?r:null,s=4<arguments.length&&void 0!==i?i:null,c={},l=(5<arguments.length&&void 0!==o?o:null)||ae(e,t,n),f=n.eventsUrl+"/events/bulk/"+t,v=function(){var e={},a=0,u=0,s={};return e.summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=s[n];t?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate)}},e.getSummary=function(){var e={},n=!0;for(var t in s){var r=s[t],i=e[r.key];i||(i={default:r.default,counters:[]},e[r.key]=i);var o={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(o.variation=r.variation),r.version?o.version=r.version:o.unknown=!0,i.counters.push(o),n=!1}return n?null:{startDate:a,endDate:u,features:e}},e.clearSummary=function(){u=a=0,s={}},e}(),d=_(n),g=n.inlineUsersInEvents,m=n.samplingInterval,p=n.eventCapacity,h=n.flushInterval,y=n.logger,b=[],k=0,E=!1,w=!1;function D(){return 0===m||0===Math.floor(Math.random()*m)}function S(e){b.length<p?(b.push(e),w=!1):(w||(w=!0,y.warn(me())),u&&u.incrementDroppedEvents())}return c.enqueue=function(e){if(!E){var n=!1,t=!1;if(v.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}(e)):n=D(),n&&S(function(e){var n=re({},e);return g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),t){var r=re({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,S(r)}}},c.flush=function(){if(E)return Promise.resolve();var e=b,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),u&&u.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],y.debug(Le(e.length)),l.sendEvents(e,f).then(function(e){e&&(e.serverTime&&(k=e.serverTime),O(e.status)||(E=!0),400<=e.status&&ee(function(){s.maybeReportError(new P(Pe(e.status,"event posting","some events were dropped")))}))}))},c.start=function(){a=setTimeout(function e(){c.flush(),a=setTimeout(e,h)},h)},c.stop=function(){clearTimeout(a)},c}function _e(n){var e={},i={};return e.on=function(e,n,t){i[e]=i[e]||[],i[e]=i[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(i[e])for(var r=0;r<i[e].length;r++)i[e][r].handler===n&&i[e][r].context===t&&(i[e]=i[e].slice(0,r).concat(i[e].slice(r+1)))},e.emit=function(e){if(i[e])for(var n=i[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(i)},e.getEventListenerCount=function(e){return i[e]?i[e].length:0},e.maybeReportError=function(e){e&&(!function(e){return!!i[e]}("error")?(n||console).error(e.message):this.emit("error",e))},e}var Ve="ready",qe="initialized",Je="failed";var ze=function(r){var n=!1,t=!1,i=null,e=null,o=new Promise(function(n){r.on(Ve,function e(){r.off(Ve,e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(i):e=new Promise(function(n,t){r.on(qe,function e(){r.off(qe,e),n()}),r.on(Je,function e(n){r.off(Je,e),t(n)})}))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,r.emit(qe),r.emit(Ve))},signalFailure:function(e){n||t||(t=!0,i=e,r.emit(Je,e),r.emit(Ve)),r.maybeReportError(e)}}};function Me(t,r,i,o,a){var u={};function s(){var e="",n=o.getUser();return n&&(e=i||y(JSON.stringify(n))),"ld:"+r+":"+e}return u.loadFlags=function(){return t.get(s()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=b(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn(he()),Promise.reject(e)})},u.saveFlags=function(e){var n=re({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn(he()),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn(he()),Promise.reject(e)})},u}function Be(i,e,o,n){var a,u=e.streamUrl,s=e.logger,t={},c=u+"/eval/"+o,l=e.useReport,f=e.evaluationReasons,r=e.streamReconnectDelay,v=U(i,e),d=!1,g=null,m=null,p=null,h=null,y=null;function b(e){d||(s.warn(je(e,r)),d=!0),D(!1),w(),k(r)}function k(e){m||(e?m=setTimeout(E,e):E())}function E(){var e;m=null;var n="",t={headers:v};if(i.eventSourceFactory){for(var r in null!=h&&(n="h="+h),l?i.eventSourceAllowsReport?(e=c,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(p)):(e=u+"/ping/"+o,n=""):e=c+"/"+S(JSON.stringify(p)),f&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,w(),s.info(Ie(e)),a=(new Date).getTime(),g=i.eventSourceFactory(e,t),y)ie(y,r)&&g.addEventListener(r,y[r]);g.onerror=b}}function w(){g&&(s.info(Ue()),g.close(),g=null)}function D(e){a&&n&&n.recordStreamInit(a,!e,(new Date).getTime()-a),a=null}return t.connect=function(e,n,t){p=e,h=n,y={};function r(n){y[n]=function(e){D(!(d=!1)),t[n]&&t[n](e)}}for(var i in t||{})r(i);k()},t.disconnect=function(){clearTimeout(m),m=null,w()},t.isConnected=function(){return!!(g&&i.eventSourceIsActive&&i.eventSourceIsActive(g))},t}var Ke="application/json";function $e(u,s,a){var c=s.baseUrl,l=s.useReport,f=s.evaluationReasons,v=s.logger,e={},d={};function g(e,n){if(!u.httpRequest)return new Promise(function(e,n){n(new Q(Oe()))});var t=n?"REPORT":"GET",r=U(u,s);n&&(r["Content-Type"]=Ke);var i=d[e];i||(i=function(t){var r,i,o,a,e={addPromise:function(n,e){r=n,i&&i(),i=e,n.then(function(e){r===n&&(o(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}};return e.resultPromise=new Promise(function(e,n){o=e,a=n}),e}(function(){delete d[e]}),d[e]=i);var o=u.httpRequest(t,e,r,n),a=o.promise.then(function(e){if(200!==e.status)return Promise.reject(function(e){return 404===e.status?new X(ke()):new Q(Ee(e.statusText||String(e.status)))}(e));if(e.header("content-type")&&e.header("content-type").startsWith(Ke))return JSON.parse(e.body);var n=pe(e.header("content-type")||"");return Promise.reject(new Q(n))},function(e){return Promise.reject(new Q(be(e)))});return i.addPromise(a,function(){o.cancel&&o.cancel()}),i.resultPromise}return e.fetchJSON=function(e){return g(c+e,null)},e.fetchFlagSettings=function(e,n){var t,r,i,o="";return l?(r=[c,"/sdk/evalx/",a,"/user"].join(""),i=JSON.stringify(e)):(t=S(JSON.stringify(e)),r=[c,"/sdk/evalx/",a,"/users/",t].join("")),n&&(o="h="+n),f&&(o=o+(o?"&":"")+"withReasons=true"),r=r+(o?"?":"")+o,v.debug(Ce(r)),g(r,i)},e}var He="ld:$anonUserId";function Ge(r,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new o(we()));var t=Y(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?(r?r.get(He).catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return t.key=e,t;var n=A();return function(e){return r?r.set(He,e).catch(function(){i.warn(ye())}):Promise.resolve()}(t.key=n).then(function(){return t})}):Promise.reject(new o(De()))},e}var Xe={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function We(e,n,t,r){var a=re({logger:{default:r}},Xe,t),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){ee(function(){n&&n.maybeReportError(new d(e))})}var o,s,c,l,f=re({},e||{});function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=H(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}return o=f,Object.keys(i).forEach(function(e){if(void 0!==o[e]){var n=i[e];r&&r.warn(Se(e,n)),n&&(void 0===o[n]&&(o[n]=o[e]),delete o[e])}}),s=re({},f),Object.keys(a).forEach(function(e){void 0!==s[e]&&null!==s[e]||(s[e]=a[e]&&a[e].default)}),l=re({},c=f=s),Object.keys(c).forEach(function(e){var n=c[e];if(null!=n){var t=a[e];if(void 0===t)u(Re(e));else{var r=t.type||v(t.default);if("any"!==r){var i=r.split("|"),o=v(n);i.indexOf(o)<0?"boolean"===r?(l[e]=!!n,u(Ne(e,o))):(u(Te(e,r,o)),l[e]=t.default):"number"===o&&void 0!==t.minimum&&n<t.minimum&&(u(Fe(e,n,t.minimum)),l[e]=t.minimum)}}}}),f=l}var Qe=Object.freeze({__proto__:null,baseOptionDefs:Xe,validate:We}).baseOptionDefs;var Ye=function(e){var n={diagnosticId:A()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},Ze=function(e){var n,t,r,i;function o(e){n=e,r=t=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},en=function(n,e,t,r,i,o){var a,u,s=!!n.diagnosticUseCombinedEvent,c="ld:"+r+":$diagnostics",l=i.eventsUrl+"/events/diagnostic/"+r,f=i.diagnosticRecordingInterval,v=e,d=!!i.streaming,g={};function m(){return{sdk:function(){var e=G({},n.diagnosticSdkData);i.wrapperName&&(e.wrapperName=i.wrapperName);i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion);return e}(),configuration:{customBaseURI:i.baseUrl!==Qe.baseUrl.default,customStreamURI:i.streamUrl!==Qe.streamUrl.default,customEventsURI:i.eventsUrl!==Qe.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!d,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation},platform:n.diagnosticPlatformData}}function p(e){i.logger&&i.logger.debug(Ae.debugPostingDiagnosticEvent(e)),t.sendEvents(e,l,!0).then(function(){}).catch(function(){})}function h(){p(function(){var e=(new Date).getTime(),n=G({kind:s?"diagnostic-combined":"diagnostic",id:o,creationDate:e},v.getProps());return s&&(n=G({},n,{},m())),v.reset(e),n}()),u=setTimeout(h,f),a=(new Date).getTime(),s&&function(){if(n.localStorage){var e=G({},v.getProps());n.localStorage.set(c,JSON.stringify(e),function(){})}}()}return g.start=function(){s?function(t){if(!n.localStorage)return t(!1);n.localStorage.get(c).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),a=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(a||0)+f,t=(new Date).getTime();n<=t?h():u=setTimeout(h,n-t)}else 0===Math.floor(4*Math.random())?h():u=setTimeout(h,f)}):(p(G({kind:"diagnostic-init",id:o,creationDate:v.getProps().dataSinceDate},m())),u=setTimeout(h,f))},g.stop=function(){u&&clearTimeout(u)},g.setStreaming=function(e){d=e},g};function nn(e,n){var o,a=["debug","info","warn","error"];o=null!=n?""===n?"":n+" ":"LD: ";var u=0;e&&(u="none"===e?100:a.indexOf(e));var t={};function r(e,n,t){if(u<=e&&console){var r=console[n];if(r){var i=e<a.length?a[e]:"?";r.call(console,o+"["+i+"] "+t)}}}return t.debug=function(e){return r(0,"log",e)},t.info=function(e){return r(1,"info",e)},t.warn=function(e){return r(2,"warn",e)},t.error=function(e){return r(3,"error",e)},t}var tn="change",rn="internal-change";e.createConsoleLogger=nn,e.errors=r,e.initialize=function(e,n,t,i,r){var a,o,u,s,c=function(){if(t&&t.logger)return t.logger;return r&&r.logger&&r.logger.default||nn("warn")}(),l=_e(c),f=ze(l),v=We(t,l,r,c),d=v.sendEvents,g=e,m=v.hash,p=ae(i,g,v),h=v.sendEvents&&!v.diagnosticOptOut,y=h?Ye(g):null,b=h?Ze((new Date).getTime()):null,k=h?en(i,b,p,g,v,y):null,E=Be(i,v,g,b),w=v.eventProcessor||xe(i,v,g,b,l,p),D=$e(i,v,g),S={},P={},O=v.streaming,U=!1,I=!1,j=!0,R=v.stateProvider,T=function(e,n){var t,r={};return r.setUser=function(e){(t=oe(e))&&n&&n(Y(t))},r.getUser=function(){return t?Y(t):null},e&&r.setUser(e),r}(null,function(e){if(R)return;e&&F({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),N=Ge(i.localStorage,c);function F(e){g&&(R&&R.enqueueEvent&&R.enqueueEvent(e)||(e.user?(j=!1,!d||I||i.isDoNotTrack()||(c.debug(ge(e.kind)),w.enqueue(e))):j&&(c.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),j=!1)))}function C(e,n,t,r){var i=T.getUser(),o=new Date,a=n?n.value:null;if(!v.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=S[u];if(s&&o-s<3e5)return;S[u]=o}var c={kind:"feature",key:e,user:i,value:a,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()},l=P[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),F(c)}function L(e,n,t,r){var i;if(P&&ie(P,e)&&P[e]&&!P[e].deleted){var o=P[e];i=A(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&C(e,i,n,r),i}function A(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function x(){o=!0,T.getUser()&&E.connect(T.getUser(),m,{ping:function(){c.debug("received ping message from stream"),D.fetchFlagSettings(T.getUser(),m).then(function(e){return V(e||{})}).catch(function(e){l.maybeReportError(new Q(Ee(e)))})},put:function(e){var n=JSON.parse(e.data);c.debug("received streaming update for all flags"),V(n)},patch:function(e){var n=JSON.parse(e.data),t=P[n.key];if(!t||!t.version||!n.version||t.version<n.version){c.debug(le(n.key));var r={},i=re({},n);delete i.key;var o=A(P[n.key]=i);r[n.key]=t?{previous:t.value,current:o}:{current:o},q(r)}else c.debug(fe(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!P[n.key]||P[n.key].version<n.version){c.debug(ve(n.key));var t={};P[n.key]&&!P[n.key].deleted&&(t[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},q(t)}else c.debug(de(n.key))}})}function _(){o&&(E.disconnect(),o=!1)}function V(e){var n={};if(!e)return Promise.resolve();for(var t in P)ie(P,t)&&P[t]&&(e[t]&&!Z(e[t].value,P[t].value)?n[t]={previous:P[t].value,current:A(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:P[t].value}));for(var r in e)ie(e,r)&&e[r]&&(!P[r]||P[r].deleted)&&(n[r]={current:A(e[r])});return P=G({},e),q(n).catch(function(){})}function q(i){var e=Object.keys(i);if(0<e.length){var o={};e.forEach(function(e){var n=i[e].current,t=n?n.value:void 0,r=i[e].previous;l.emit(tn+":"+e,t,r),o[e]=n?{current:t,previous:r}:{previous:r}}),l.emit(tn,o),l.emit(rn,P),v.sendEventsOnlyForVariation||R||e.forEach(function(e){C(e,i[e].current)})}return a&&s?s.saveFlags(P).catch(function(){return null}):Promise.resolve()}function J(){var e=O||u&&void 0===O;e&&!o?x():!e&&o&&_(),k&&k.setStreaming(e)}function z(e){return e===tn||e.substr(0,tn.length+1)===tn+":"}if(i.localStorage&&(s=new Me(i.localStorage,g,m,T,c)),"string"==typeof v.bootstrap&&"LOCALSTORAGE"===v.bootstrap.toUpperCase()&&(s?a=!0:c.warn(he())),"object"===H(v.bootstrap)&&(P=function(t){var e=Object.keys(t),r="$flagsState",i=t[r];!i&&e.length&&c.warn(ce()),!1===t.$valid&&c.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var o={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var n={value:t[e]};i&&i[e]?n=re(n,i[e]):n.version=0,o[e]=n}}),o}(v.bootstrap)),R){var M=R.getInitialState();M?B(M):R.on("init",B),R.on("update",function(e){e.user&&T.setUser(e.user);e.flags&&V(e.flags)})}else(e?N.validateUser(n).then(function(e){return T.setUser(e),"object"===H(v.bootstrap)?K():a?s.loadFlags().catch(function(){return null}).then(function(e){return null==e?(P={},D.fetchFlagSettings(T.getUser(),m).then(function(e){return V(e||{})}).then(K).catch(function(e){$(new Q(Ee(e)))})):(P=e,ee(K),D.fetchFlagSettings(T.getUser(),m).then(function(e){return V(e)}).catch(function(e){return l.maybeReportError(e)}))}):D.fetchFlagSettings(T.getUser(),m).then(function(e){P=e||{},K()}).catch(function(e){P={},$(e)})}):Promise.reject(new X(se()))).catch($);function B(e){g=e.environment,T.setUser(e.user),P=G({},e.flags),ee(K)}function K(){c.info("LaunchDarkly client initialized"),U=!0,J(),f.signalSuccess()}function $(e){f.signalFailure(e)}return{client:{waitForInitialization:function(){return f.getInitializationPromise()},waitUntilReady:function(){return f.getReadyPromise()},identify:function(e,r,n){return I?ne(Promise.resolve({}),n):R?(c.warn("identify() has no effect here; it must be called on the main client instance"),ne(Promise.resolve(te(P)),n)):ne((a&&s?s.clearFlags():Promise.resolve()).then(function(){return N.validateUser(e)}).then(function(t){return D.fetchFlagSettings(t,r).then(function(e){var n=te(e);return T.setUser(t),m=r,e?V(e).then(function(){return n}):n})}).then(function(e){return o&&x(),e}).catch(function(e){return l.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return T.getUser()},variation:function(e,n){return L(e,n,!0,!1).value},variationDetail:function(e,n){return L(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&c.warn(ue(e));var r={kind:"custom",key:e,user:T.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),F(r)}else l.maybeReportError(new W(ue(e)))},on:function(e,n,t){z(e)?(u=!0,U&&J(),l.on(e,n,t)):l.on.apply(l,arguments)},off:function(e){if(l.off.apply(l,arguments),z(e)){var n=!1;l.getEvents().forEach(function(e){z(e)&&0<l.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,o&&void 0===O&&_())}},setStreaming:function(e){var n=null===e?void 0:e;n!==O&&(O=n,J())},flush:function(e){return ne(d?w.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!P)return e;for(var n in P)ie(P,n)&&(e[n]=L(n,null,!v.sendEventsOnlyForVariation).value);return e},close:function(e){if(I)return ne(Promise.resolve(),e);function n(){I=!0,P={}}return ne(Promise.resolve().then(function(){if(_(),k&&k.stop(),d)return w.stop(),w.flush()}).then(n).catch(n),e)}},options:v,emitter:l,ident:T,logger:c,requestor:D,start:function(){d&&(k&&k.start(),w.start())},enqueueEvent:F,getFlagsInternal:function(){return P},getEnvironmentId:function(){return g},internalChangeEventName:rn}},e.messages=Ae,e.utils=w,e.version="3.2.7",Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ldclient-common.min.js.map
{
"name": "launchdarkly-js-sdk-common",
"version": "3.2.6",
"version": "3.2.7",
"description": "LaunchDarkly SDK for JavaScript - common code",

@@ -5,0 +5,0 @@ "author": "LaunchDarkly <team@launchdarkly.com>",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc