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 2.14.1 to 3.1.0-beta1-diag

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

@@ -45,2 +45,3 @@ "author": "LaunchDarkly <team@launchdarkly.com>",

"@babel/runtime": "7.6.3",
"@rollup/plugin-node-resolve": "^6.0.0",
"@rollup/plugin-replace": "^2.2.0",

@@ -59,2 +60,3 @@ "babel-eslint": "10.0.3",

"jsdom": "^11.11.0",
"launchdarkly-js-test-helpers": "1.1.0",
"prettier": "1.11.1",

@@ -67,5 +69,2 @@ "readline-sync": "1.4.9",

"rollup-plugin-filesize": "^6.2.1",
"rollup-plugin-includepaths": "^0.2.3",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^5.1.2",

@@ -75,3 +74,2 @@ "rollup-plugin-uglify": "^6.0.3",

"semver-compare": "1.0.0",
"sinon": "7.2.7",
"typescript": "3.0.1"

@@ -78,0 +76,0 @@ },

@@ -189,2 +189,16 @@ /**

/**
* The capacity of the analytics events queue.
*
* The client buffers up to this many events in memory before flushing. If the capacity is exceeded
* before the queue is flushed, events will be discarded. Increasing the capacity means that events
* are less likely to be discarded, at the cost of consuming more memory. Note that in regular usage
* flag evaluations do not produce individual events, only summary counts, so you only need a large
* capacity if you are generating a large number of click, pageview, or identify events (or if you
* are using the event debugger).
*
* The default value is 100.
*/
eventCapacity?: number;
/**
* The interval in between flushes of the analytics events queue, in milliseconds.

@@ -202,2 +216,4 @@ *

* sent: for example, a value of 20 means that on average 1 in 20, or 5%, of all events will be sent.
*
* @deprecated This feature will be removed in a future version.
*/

@@ -214,2 +230,21 @@ samplingInterval?: number;

streamReconnectDelay?: number;
/**
* Set to true to opt out of sending diagnostics data.
*
* Unless `diagnosticOptOut` is set to true, the client will send some diagnostics data to the LaunchDarkly
* servers in order to assist in the development of future SDK improvements. These diagnostics consist of
* an initial payload containing some details of SDK in use, the SDK's configuration, and the platform the
* SDK is being run on, as well as payloads sent periodically with information on irregular occurrences such
* as dropped events.
*/
diagnosticOptOut?: boolean;
/**
* The interval at which periodic diagnostic data is sent, in milliseconds.
*
* The default is 900000 (every 15 minutes) and the minimum value is 6000. See [[diagnosticOptOut]]
* for more information on the diagnostics data being sent.
*/
diagnosticRecordingInterval?: number;
}

@@ -216,0 +251,0 @@

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