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.12.0 to 2.12.1

2

dist/ldclient-common.cjs.js

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

"use strict";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,n.prototype.name=e,n.prototype.constructor=n,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!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({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=[],i=n;i<r;i+=3)t=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(t));return o.join("")}function fromByteArray(e){for(var n,r=e.length,t=r%3,o=[],i=0,a=r-t;i<a;i+=16383)o.push(encodeChunk(e,i,i+16383>a?a:i+16383));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 _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},isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(n,r){if(n===r)return!0;if(n&&r&&"object"==(void 0===n?"undefined":_typeof(n))&&"object"==(void 0===r?"undefined":_typeof(r))){var t,o,i,a=isArray(n),u=isArray(r);if(a&&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(a!=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,v=r instanceof RegExp;if(l!=v)return!1;if(l&&v)return n.toString()==r.toString();var f=keyList(n);if((o=f.length)!==keyList(r).length)return!1;for(t=o;0!=t--;)if(!hasProp.call(r,f[t]))return!1;for(t=o;0!=t--;)if(!e(n[i=f[t]],r[i]))return!1;return!0}return n!=n&&r!=r},_extends=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},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=n.slice(0),t=[],o=e,i=void 0;r.length>0;){for(i=[];o>0;){var a=r.shift();if(!a)break;(o-=base64URLEncode(JSON.stringify(a)).length)<0&&i.length>0?r.unshift(a):i.push(a)}o=e,t.push(i)}return t}function getLDUserAgentString(e){var n=e.version||"2.12.0";return e.userAgent+"/"+n}function getLDHeaders(e){return{"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)}}function extend(){for(var e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];return n.reduce(function(e,n){return _extends({},e,n)},{})}function sanitizeUser(e){if(!e)return e;var n=void 0;for(var r in userAttrsToStringify){var t=userAttrsToStringify[r],o=e[t];void 0!==o&&"string"!=typeof o&&((n=n||Object.assign({},e))[t]=String(o))}return n||e}var utils=Object.freeze({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(e,n,r,t){var o=n+"/events/bulk/"+r,i=n+"/a/"+r+".gif",a={};function u(e){(new window.Image).src=e}function s(n,r){var a=t||u,s=JSON.stringify(n);return r?function n(r){var t=extend({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},getLDHeaders(e));return e.httpRequest("POST",o,t,s).promise.then(function(e){if(e)return e.status>=400&&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(){}):(a(i+"?d="+base64URLEncode(s)),Promise.resolve())}return a.sendEvents=function(r){if(!e.httpRequest)return Promise.resolve();var t=e.httpAllowsPost(),o=void 0;o=t?[r]:chunkUserEventsForUrl(MAX_URL_LENGTH-n.length,r);for(var i=[],a=0;a<o.length;a++)i.push(s(o[a],t));return Promise.all(i)},a}function EventSummarizer(){var e={},n=0,r=0,t={};return e.summarizeEvent=function(e){if("feature"===e.kind){var o=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),i=t[o];i?i.count=i.count+1:t[o]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>r&&(r=e.creationDate)}},e.getSummary=function(){var e={},o=!0;for(var i in t){var a=t[i],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),o=!1}return o?null:{startDate:n,endDate:r,features:e}},e.clearSummary=function(){n=0,r=0,t={}},e}function UserFilter(e){var n={},r=e.allAttributesPrivate,t=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]&&(r||-1!==n.indexOf(e)||-1!==t.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=extend({},c,l[1])}var v=Object.keys(c);return v.length&&(v.sort(),s.privateAttrs=v),s},n}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: http://docs.launchdarkly.com/docs/running-an-ab-test#include-the-client-side-snippet"},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."+docLink},environmentNotSpecified=function(){return"No environment specified."+docLink},errorFetchingFlags=function(e){return"Error fetching flag settings: "+(e.message||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'[LaunchDarkly] "'+e+'" is deprecated, please use "'+n+'"'},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"},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({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,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents});function EventProcessor(e,n,r,t){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,a={},u=i||EventSender(e,n.eventsUrl,r),s=EventSummarizer(),c=UserFilter(n),l=n.inlineUsersInEvents,v=n.samplingInterval,f=n.flushInterval,d=[],g=0,m=!1,p=void 0;function y(){return 0===v||0===Math.floor(Math.random()*v)}return a.enqueue=function(e){if(!m){var n,r=!1,t=!1;if(s.summarizeEvent(e),"feature"===e.kind?y()&&(r=!!e.trackEvents,t=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>g&&n.debugEventsUntilDate>(new Date).getTime()):r=y(),r&&d.push(function(e){var n=extend({},e);return l||"identify"===e.kind?n.user=c.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),t){var o=extend({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,d.push(o)}}},a.flush=function(){if(m)return Promise.resolve();var e=d,n=s.getSummary();return s.clearSummary(),n&&(n.kind="summary",e.push(n)),0===e.length?Promise.resolve():(d=[],t.debug(debugPostingEvents(e.length)),u.sendEvents(e).then(function(e){e&&(e.serverTime&&(g=e.serverTime),isHttpErrorRecoverable(e.status)||(m=!0),e.status>=400&&onNextTick(function(){o.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},a.start=function(){p=setTimeout(function e(){a.flush(),p=setTimeout(e,f)},f)},a.stop=function(){clearTimeout(p)},a}function EventEmitter(e){var n={},r={};return n.on=function(e,n,t){r[e]=r[e]||[],r[e]=r[e].concat({handler:n,context:t})},n.off=function(e,n,t){if(r[e])for(var o=0;o<r[e].length;o++)r[e][o].handler===n&&r[e][o].context===t&&(r[e]=r[e].slice(0,o).concat(r[e].slice(o+1)))},n.emit=function(e){if(r[e])for(var n=0;n<r[e].length;n++)r[e][n].handler.apply(r[e][n].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(r)},n.getEventListenerCount=function(e){return r[e]?r[e].length:0},n.maybeReportError=function(n){n&&(r["error"]?this.emit("error",n):(e||console).error(n.message))},n}function Store(e,n,r,t,o){var i={};function a(){var e="",o=t.getUser();return o&&(e=r||btoa(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 r=n.$schema;void 0===r||r<1?n=transformValuesToVersionedValues(n):delete n.$schema}return n}catch(e){return i.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i.saveFlags=function(n){var r=extend({},n,{$schema:1});return e.set(a(),JSON.stringify(r)).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i.clearFlags=function(){return e.clear(a()).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i}function Stream(e,n,r,t){var o=n.streamUrl,i={},a=o+"/eval/"+r,u=n.useReport,s=n.evaluationReasons,c=n.streamReconnectDelay,l=null,v=null,f=null,d=null;function g(){y(),m(c)}function m(e){v||(e?v=setTimeout(p,e):p())}function p(){var n=void 0,i="",c={};if(e.eventSourceFactory){for(var v in null!=t&&(i="h="+t),u?e.eventSourceAllowsReport?(n=a,c.method="REPORT",c.headers={"Content-Type":"application/json"},c.body=JSON.stringify(f)):(n=o+"/ping/"+r,i=""):n=a+"/"+base64URLEncode(JSON.stringify(f)),s&&(i=i+(i?"&":"")+"withReasons=true"),n=n+(i?"?":"")+i,y(),l=e.eventSourceFactory(n,c),d)d.hasOwnProperty(v)&&l.addEventListener(v,d[v]);l.onerror=g}}function y(){l&&(l.close(),l=null)}return i.connect=function(e,n){f=e,d=n,m()},i.disconnect=function(){clearTimeout(v),v=null,y()},i.isConnected=function(){return l&&e.eventSourceIsActive&&e.eventSourceIsActive(l)},i}function promiseCoalescer(e){var n=void 0,r=void 0,t=void 0,o=void 0,i={addPromise:function(i,a){n=i,r&&r(),r=a,i.then(function(r){n===i&&(t(r),e&&e())},function(r){n===i&&(o(r),e&&e())})}};return i.resultPromise=new Promise(function(e,n){t=e,o=n}),i}var json="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(e,n,r,t){var o=n.baseUrl,i=n.useReport,a=n.evaluationReasons,u=n.sendLDHeaders,s={},c={};function l(n,r){if(!e.httpRequest)return new Promise(function(e,n){n(new LDFlagFetchError(httpUnavailable()))});var t=r?"REPORT":"GET",o=u?getLDHeaders(e):{};r&&(o["Content-Type"]="application/json");var i=c[n];i||(i=promiseCoalescer(function(){delete c[n]}),c[n]=i);var a=e.httpRequest(t,n,o,r),s=a.promise.then(function(e){if(200===e.status){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))}return Promise.reject(getResponseError(e))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return i.addPromise(s,function(){a.cancel&&a.cancel()}),i.resultPromise}return s.fetchJSON=function(e){return l(o+e,null)},s.fetchFlagSettings=function(e,n){var u=void 0,s=void 0,c="",v=void 0;return i?(s=[o,"/sdk/evalx/",r,"/user"].join(""),v=JSON.stringify(e)):(u=base64URLEncode(JSON.stringify(e)),s=[o,"/sdk/evalx/",r,"/users/",u].join("")),n&&(c="h="+n),a&&(c=c+(c?"&":"")+"withReasons=true"),s=s+(c?"?":"")+c,t.debug(debugPolling(s)),l(s,v)},s}function Identity(e,n){var r={},t=void 0;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 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||[],i=(e=e||{}).node||_nodeId,a=void 0!==e.clockseq?e.clockseq:_clockseq;if(null==i||null==a){var u=rngBrowser();null==i&&(i=_nodeId=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=_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&&(a=a+1&16383),(l<0||s>_lastMSecs)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=s,_lastNSecs=c,_clockseq=a;var v=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;o[t++]=v>>>24&255,o[t++]=v>>>16&255,o[t++]=v>>>8&255,o[t++]=255&v;var f=s/4294967296*1e4&268435455;o[t++]=f>>>8&255,o[t++]=255&f,o[t++]=f>>>24&15|16,o[t++]=f>>>16&255,o[t++]=a>>>8|128,o[t++]=255&a;for(var d=0;d<6;++d)o[t+d]=i[d];return n||bytesToUuid_1(o)}var v1_1=v1,ldUserIdKey="ld:$anonUserId";function UserValidator(e,n){var r={};return r.validateUser=function(r){if(!r)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var t=clone(r);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?(e?e.get(ldUserIdKey).catch(function(){return null}):Promise.resolve(null)).then(function(r){if(r)return t.key=r,t;var o=v1_1();return t.key=o,function(r){return e?e.set(ldUserIdKey,r).catch(function(){n.warn(localStorageUnavailableForUserId())}):Promise.resolve()}(o).then(function(){return t})}):Promise.reject(new LDInvalidUserError(invalidUser()))},r}function validate(e,n,r,t){var o=extend({},{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),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames"};function a(e){onNextTick(function(){n&&n.maybeReportError(new LDInvalidArgumentError(e))})}var u=extend({},e||{});return function(e){var n=e;Object.keys(i).forEach(function(e){if(void 0!==n[e]){var r=i[e];t.warn(deprecated(e,r)),void 0===n[r]&&(n[r]=n[e]),delete n[e]}})}(u),u=function(e,n){var r=extend({},e);return Object.keys(n).forEach(function(e){void 0!==r[e]&&null!==r[e]||(r[e]=n[e])}),r}(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}function createConsoleLogger(e){var n=0;e&&(n="none"===e?100:["debug","info","warn","error"].indexOf(e));var r={};function t(e,r,t){e>=n&&r(t)}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 _typeof$1="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},readyEvent="ready",successEvent="initialized",failedEvent="failed",changeEvent="change",internalChangeEvent="internal-change";function initialize(e,n,r,t,o){var i=function(){if(r&&r.logger)return r.logger;return o&&o.logger||createConsoleLogger("warn")}(),a=EventEmitter(i),u=validate(r,a,o,i),s=u.hash,c=u.sendEvents,l=e,v=Stream(t,u,l,s),f=u.eventProcessor||EventProcessor(t,u,l,i,a),d=Requestor(t,u,l,i),g={},m={},p=void 0,y=void 0,h=u.streaming,E=void 0,b=!1,k=!1,S=!0,U=u.stateProvider,D=Identity(null,function(e){if(U)return;e&&w({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),P=UserValidator(t.localStorage,i),L=void 0;function w(e){l&&(U&&U.enqueueEvent&&U.enqueueEvent(e)||(e.user?(S=!1,!c||k||t.isDoNotTrack()||(i.debug(debugEnqueueingEvent(e.kind)),f.enqueue(e))):S&&(i.warn(eventWithoutUser()),S=!1)))}function I(e,n,r){var t=D.getUser(),o=new Date,i=n?n.value:null;if(!u.allowFrequentDuplicateEvents){var a=JSON.stringify(i)+(t&&t.key?t.key:"")+e,s=g[a];if(s&&o-s<3e5)return;g[a]=o}var c={kind:"feature",key:e,user:t,value:i,variation:n?n.variationIndex:null,default:r,creationDate:o.getTime(),reason:n?n.reason:null},l=m[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),w(c)}function F(e,n,r){var t=void 0;if(m&&m.hasOwnProperty(e)&&m[e]&&!m[e].deleted){var o=m[e];t=T(o),null!==o.value&&void 0!==o.value||(t.value=n)}else t={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return r&&I(e,t,n),t}function T(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function R(){y=!0,D.getUser()&&v.connect(D.getUser(),{ping:function(){i.debug(debugStreamPing()),d.fetchFlagSettings(D.getUser(),s).then(function(e){return O(e||{})}).catch(function(e){a.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){var n=JSON.parse(e.data);i.debug(debugStreamPut()),O(n)},patch:function(e){var n=JSON.parse(e.data),r=m[n.key];if(!r||!r.version||!n.version||r.version<n.version){i.debug(debugStreamPatch(n.key));var t={},o=extend({},n);delete o.key,m[n.key]=o;var a=T(o);t[n.key]=r?{previous:r.value,current:a}:{current:a},C(t)}else i.debug(debugStreamPatchIgnored(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!m[n.key]||m[n.key].version<n.version){i.debug(debugStreamDelete(n.key));var r={};m[n.key]&&!m[n.key].deleted&&(r[n.key]={previous:m[n.key].value}),m[n.key]={version:n.version,deleted:!0},C(r)}else i.debug(debugStreamDeleteIgnored(n.key))}})}function N(){y&&(v.disconnect(),y=!1)}function O(e){var n={};if(!e)return Promise.resolve();for(var r in m)m.hasOwnProperty(r)&&m[r]&&(e[r]&&!deepEquals(e[r].value,m[r].value)?n[r]={previous:m[r].value,current:T(e[r])}:e[r]&&!e[r].deleted||(n[r]={previous:m[r].value}));for(var t in e)e.hasOwnProperty(t)&&e[t]&&(!m[t]||m[t].deleted)&&(n[t]={current:T(e[t])});return m=e,C(n).catch(function(){})}function C(e){var n=Object.keys(e);if(n.length>0){var r={};n.forEach(function(n){var t=e[n].current,o=t?t.value:void 0,i=e[n].previous;a.emit(changeEvent+":"+n,o,i),r[n]=t?{current:o,previous:i}:{previous:i}}),a.emit(changeEvent,r),a.emit(internalChangeEvent,m),u.sendEventsOnlyForVariation||U||n.forEach(function(n){I(n,e[n].current)})}return p&&L?L.saveFlags(m).catch(function(){return null}):Promise.resolve()}function x(){var e=h||E&&void 0===h;e&&!y?R():!e&&y&&N()}function A(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}t.localStorage&&(L=new Store(t.localStorage,l,s,D,i));var j=new Promise(function(e){var n=a.on(readyEvent,function(){a.off(readyEvent,n),e()})}),_=new Promise(function(e,n){var r=a.on(successEvent,function(){a.off(successEvent,r),e()}),t=a.on(failedEvent,function(e){a.off(failedEvent,t),n(e)})});if("string"==typeof u.bootstrap&&"LOCALSTORAGE"===u.bootstrap.toUpperCase()&&(L?p=!0:i.warn(localStorageUnavailable())),U){var V=U.getInitialState();V?q(V):U.on("init",q),U.on("update",function(e){e.user&&D.setUser(e.user);e.flags&&O(e.flags)})}else(function(){if(!e)return Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()));return P.validateUser(n).then(function(e){return D.setUser(e),"object"===_typeof$1(u.bootstrap)?(m=function(e){var n=Object.keys(e),r=e.$flagsState;!r&&n.length&&i.warn(bootstrapOldFormat()),!1===e.$valid&&i.warn(bootstrapInvalid());var t={};return n.forEach(function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};r&&r[n]?o=extend(o,r[n]):o.version=0,t[n]=o}}),t}(u.bootstrap),z()):p?L.loadFlags().catch(function(){return null}).then(function(e){return null==e?(m={},d.fetchFlagSettings(D.getUser(),s).then(function(e){return O(e||{})}).then(z).catch(function(e){var n=new LDFlagFetchError(errorFetchingFlags(e));K(n)})):(m=e,onNextTick(z),d.fetchFlagSettings(D.getUser(),s).then(function(e){return O(e)}).catch(function(e){return a.maybeReportError(e)}))}):d.fetchFlagSettings(D.getUser(),s).then(function(e){m=e||{},z()}).catch(function(e){m={},K(e)})})})().catch(function(e){return a.maybeReportError(e)});function q(e){l=e.environment,D.setUser(e.user),m=e.flags,onNextTick(z)}function z(){i.info(clientInitialized()),b=!0,x(),a.emit(readyEvent),a.emit(successEvent)}function K(e){a.maybeReportError(e),a.emit(failedEvent,e),a.emit(readyEvent)}return{client:{waitForInitialization:function(){return _},waitUntilReady:function(){return j},identify:function(e,n,r){return k?wrapPromiseCallback(Promise.resolve({}),r):U?(i.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(m)),r)):wrapPromiseCallback((p&&L?L.clearFlags():Promise.resolve()).then(function(){return P.validateUser(e)}).then(function(e){return D.setUser(e)}).then(function(){return d.fetchFlagSettings(D.getUser(),n)}).then(function(e){var n=transformVersionedValuesToValues(e);return e?O(e).then(function(){return n}):n}).then(function(e){return y&&R(),e}).catch(function(e){return a.maybeReportError(e),Promise.reject(e)}),r)},getUser:function(){return D.getUser()},variation:function(e,n){return F(e,n,!0).value},variationDetail:function(e,n){return F(e,n,!0)},track:function(e,n){"string"==typeof e?(t.customEventFilter&&!t.customEventFilter(e)&&i.warn(unknownCustomEventKey(e)),w({kind:"custom",key:e,data:n,user:D.getUser(),url:t.getCurrentUrl(),creationDate:(new Date).getTime()})):a.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},on:function(e,n,r){A(e)?(E=!0,b&&x(),a.on(e,n,r)):a.on.apply(a,arguments)},off:function(e){if(a.off.apply(a,arguments),A(e)){var n=!1;a.getEvents().forEach(function(e){A(e)&&a.getEventListenerCount(e)>0&&(n=!0)}),n||(E=!1,y&&void 0===h&&N())}},setStreaming:function(e){var n=null===e?void 0:e;n!==h&&(h=n,x())},flush:function(e){return wrapPromiseCallback(c?f.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!m)return e;for(var n in m)m.hasOwnProperty(n)&&(e[n]=F(n,null,!u.sendEventsOnlyForVariation).value);return e},close:function(e){if(k)return wrapPromiseCallback(Promise.resolve(),e);var n=function(){k=!0,m={}};return wrapPromiseCallback(Promise.resolve().then(function(){if(N(),c)return f.stop(),f.flush()}).then(n).catch(n),e)}},options:u,emitter:a,ident:D,logger:i,requestor:d,start:function(){c&&f.start()},enqueueEvent:w,getFlagsInternal:function(){return m},getEnvironmentId:function(){return l},internalChangeEventName:internalChangeEvent}}var version="2.12.0";exports.initialize=initialize,exports.version=version,exports.createConsoleLogger=createConsoleLogger,exports.errors=errors,exports.messages=messages,exports.utils=utils;
"use strict";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,n.prototype.name=e,n.prototype.constructor=n,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!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({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=[],i=n;i<r;i+=3)t=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(t));return o.join("")}function fromByteArray(e){for(var n,r=e.length,t=r%3,o=[],i=0,a=r-t;i<a;i+=16383)o.push(encodeChunk(e,i,i+16383>a?a:i+16383));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 _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},isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(n,r){if(n===r)return!0;if(n&&r&&"object"==(void 0===n?"undefined":_typeof(n))&&"object"==(void 0===r?"undefined":_typeof(r))){var t,o,i,a=isArray(n),u=isArray(r);if(a&&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(a!=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,v=r instanceof RegExp;if(l!=v)return!1;if(l&&v)return n.toString()==r.toString();var f=keyList(n);if((o=f.length)!==keyList(r).length)return!1;for(t=o;0!=t--;)if(!hasProp.call(r,f[t]))return!1;for(t=o;0!=t--;)if(!e(n[i=f[t]],r[i]))return!1;return!0}return n!=n&&r!=r},_extends=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},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=n.slice(0),t=[],o=e,i=void 0;r.length>0;){for(i=[];o>0;){var a=r.shift();if(!a)break;(o-=base64URLEncode(JSON.stringify(a)).length)<0&&i.length>0?r.unshift(a):i.push(a)}o=e,t.push(i)}return t}function getLDUserAgentString(e){var n=e.version||"2.12.1";return e.userAgent+"/"+n}function getLDHeaders(e){return{"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)}}function extend(){for(var e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];return n.reduce(function(e,n){return _extends({},e,n)},{})}function sanitizeUser(e){if(!e)return e;var n=void 0;for(var r in userAttrsToStringify){var t=userAttrsToStringify[r],o=e[t];void 0!==o&&"string"!=typeof o&&((n=n||Object.assign({},e))[t]=String(o))}return n||e}var utils=Object.freeze({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(e,n,r,t){var o=n+"/events/bulk/"+r,i=n+"/a/"+r+".gif",a={};function u(e){(new window.Image).src=e}function s(n,r){var a=t||u,s=JSON.stringify(n);return r?function n(r){var t=extend({"Content-Type":"application/json","X-LaunchDarkly-Event-Schema":"3"},getLDHeaders(e));return e.httpRequest("POST",o,t,s).promise.then(function(e){if(e)return e.status>=400&&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(){}):(a(i+"?d="+base64URLEncode(s)),Promise.resolve())}return a.sendEvents=function(r){if(!e.httpRequest)return Promise.resolve();var t=e.httpAllowsPost(),o=void 0;o=t?[r]:chunkUserEventsForUrl(MAX_URL_LENGTH-n.length,r);for(var i=[],a=0;a<o.length;a++)i.push(s(o[a],t));return Promise.all(i)},a}function EventSummarizer(){var e={},n=0,r=0,t={};return e.summarizeEvent=function(e){if("feature"===e.kind){var o=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),i=t[o];i?i.count=i.count+1:t[o]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>r&&(r=e.creationDate)}},e.getSummary=function(){var e={},o=!0;for(var i in t){var a=t[i],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),o=!1}return o?null:{startDate:n,endDate:r,features:e}},e.clearSummary=function(){n=0,r=0,t={}},e}function UserFilter(e){var n={},r=e.allAttributesPrivate,t=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]&&(r||-1!==n.indexOf(e)||-1!==t.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=extend({},c,l[1])}var v=Object.keys(c);return v.length&&(v.sort(),s.privateAttrs=v),s},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: http://docs.launchdarkly.com/docs/running-an-ab-test#include-the-client-side-snippet"},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."+docLink},environmentNotSpecified=function(){return"No environment 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'[LaunchDarkly] "'+e+'" is deprecated, please use "'+n+'"'},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){return"Error on stream connection: "+errorString(e)},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({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=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i={},a=o||EventSender(e,n.eventsUrl,r),u=EventSummarizer(),s=UserFilter(n),c=n.inlineUsersInEvents,l=n.samplingInterval,v=n.flushInterval,f=n.logger,d=[],g=0,m=!1,p=void 0;function y(){return 0===l||0===Math.floor(Math.random()*l)}return i.enqueue=function(e){if(!m){var n,r=!1,t=!1;if(u.summarizeEvent(e),"feature"===e.kind?y()&&(r=!!e.trackEvents,t=!!(n=e).debugEventsUntilDate&&n.debugEventsUntilDate>g&&n.debugEventsUntilDate>(new Date).getTime()):r=y(),r&&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)),t){var o=extend({},e,{kind:"debug"});delete o.trackEvents,delete o.debugEventsUntilDate,delete o.variation,d.push(o)}}},i.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=[],f.debug(debugPostingEvents(e.length)),a.sendEvents(e).then(function(e){e&&(e.serverTime&&(g=e.serverTime),isHttpErrorRecoverable(e.status)||(m=!0),e.status>=400&&onNextTick(function(){t.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},i.start=function(){p=setTimeout(function e(){i.flush(),p=setTimeout(e,v)},v)},i.stop=function(){clearTimeout(p)},i}function EventEmitter(e){var n={},r={};return n.on=function(e,n,t){r[e]=r[e]||[],r[e]=r[e].concat({handler:n,context:t})},n.off=function(e,n,t){if(r[e])for(var o=0;o<r[e].length;o++)r[e][o].handler===n&&r[e][o].context===t&&(r[e]=r[e].slice(0,o).concat(r[e].slice(o+1)))},n.emit=function(e){if(r[e])for(var n=0;n<r[e].length;n++)r[e][n].handler.apply(r[e][n].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(r)},n.getEventListenerCount=function(e){return r[e]?r[e].length:0},n.maybeReportError=function(n){n&&(r["error"]?this.emit("error",n):(e||console).error(n.message))},n}function Store(e,n,r,t,o){var i={};function a(){var e="",o=t.getUser();return o&&(e=r||btoa(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 r=n.$schema;void 0===r||r<1?n=transformValuesToVersionedValues(n):delete n.$schema}return n}catch(e){return i.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i.saveFlags=function(n){var r=extend({},n,{$schema:1});return e.set(a(),JSON.stringify(r)).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i.clearFlags=function(){return e.clear(a()).catch(function(e){return o.warn(localStorageUnavailable()),Promise.reject(e)})},i}function Stream(e,n,r,t){var o=n.streamUrl,i=n.logger,a={},u=o+"/eval/"+r,s=n.useReport,c=n.evaluationReasons,l=n.streamReconnectDelay,v=null,f=null,d=null,g=null;function m(e){i.warn(streamError(e)),h(),p(l)}function p(e){f||(e?f=setTimeout(y,e):y())}function y(){f=null;var n=void 0,a="",l={};if(e.eventSourceFactory){for(var p in null!=t&&(a="h="+t),s?e.eventSourceAllowsReport?(n=u,l.method="REPORT",l.headers={"Content-Type":"application/json"},l.body=JSON.stringify(d)):(n=o+"/ping/"+r,a=""):n=u+"/"+base64URLEncode(JSON.stringify(d)),c&&(a=a+(a?"&":"")+"withReasons=true"),n=n+(a?"?":"")+a,h(),i.info(streamConnecting(n)),v=e.eventSourceFactory(n,l),g)g.hasOwnProperty(p)&&v.addEventListener(p,g[p]);v.onerror=m}}function h(){v&&(i.info(streamClosing()),v.close(),v=null)}return a.connect=function(e,n){d=e,g=n,p()},a.disconnect=function(){clearTimeout(f),f=null,h()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a}function promiseCoalescer(e){var n=void 0,r=void 0,t=void 0,o=void 0,i={addPromise:function(i,a){n=i,r&&r(),r=a,i.then(function(r){n===i&&(t(r),e&&e())},function(r){n===i&&(o(r),e&&e())})}};return i.resultPromise=new Promise(function(e,n){t=e,o=n}),i}var json="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(e,n,r){var t=n.baseUrl,o=n.useReport,i=n.evaluationReasons,a=n.sendLDHeaders,u=n.logger,s={},c={};function l(n,r){if(!e.httpRequest)return new Promise(function(e,n){n(new LDFlagFetchError(httpUnavailable()))});var t=r?"REPORT":"GET",o=a?getLDHeaders(e):{};r&&(o["Content-Type"]="application/json");var i=c[n];i||(i=promiseCoalescer(function(){delete c[n]}),c[n]=i);var u=e.httpRequest(t,n,o,r),s=u.promise.then(function(e){if(200===e.status){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))}return Promise.reject(getResponseError(e))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return i.addPromise(s,function(){u.cancel&&u.cancel()}),i.resultPromise}return s.fetchJSON=function(e){return l(t+e,null)},s.fetchFlagSettings=function(e,n){var a=void 0,s=void 0,c="",v=void 0;return o?(s=[t,"/sdk/evalx/",r,"/user"].join(""),v=JSON.stringify(e)):(a=base64URLEncode(JSON.stringify(e)),s=[t,"/sdk/evalx/",r,"/users/",a].join("")),n&&(c="h="+n),i&&(c=c+(c?"&":"")+"withReasons=true"),s=s+(c?"?":"")+c,u.debug(debugPolling(s)),l(s,v)},s}function Identity(e,n){var r={},t=void 0;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 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||[],i=(e=e||{}).node||_nodeId,a=void 0!==e.clockseq?e.clockseq:_clockseq;if(null==i||null==a){var u=rngBrowser();null==i&&(i=_nodeId=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=_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&&(a=a+1&16383),(l<0||s>_lastMSecs)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=s,_lastNSecs=c,_clockseq=a;var v=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;o[t++]=v>>>24&255,o[t++]=v>>>16&255,o[t++]=v>>>8&255,o[t++]=255&v;var f=s/4294967296*1e4&268435455;o[t++]=f>>>8&255,o[t++]=255&f,o[t++]=f>>>24&15|16,o[t++]=f>>>16&255,o[t++]=a>>>8|128,o[t++]=255&a;for(var d=0;d<6;++d)o[t+d]=i[d];return n||bytesToUuid_1(o)}var v1_1=v1,ldUserIdKey="ld:$anonUserId";function UserValidator(e,n){var r={};return r.validateUser=function(r){if(!r)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var t=clone(r);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?(e?e.get(ldUserIdKey).catch(function(){return null}):Promise.resolve(null)).then(function(r){if(r)return t.key=r,t;var o=v1_1();return t.key=o,function(r){return e?e.set(ldUserIdKey,r).catch(function(){n.warn(localStorageUnavailableForUserId())}):Promise.resolve()}(o).then(function(){return t})}):Promise.reject(new LDInvalidUserError(invalidUser()))},r}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),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames"};function a(e){onNextTick(function(){n&&n.maybeReportError(new LDInvalidArgumentError(e))})}var u=extend({},e||{});return function(e){var n=e;Object.keys(i).forEach(function(e){if(void 0!==n[e]){var r=i[e];t.warn(deprecated(e,r)),void 0===n[r]&&(n[r]=n[e]),delete n[e]}})}(u),u=function(e,n){var r=extend({},e);return Object.keys(n).forEach(function(e){void 0!==r[e]&&null!==r[e]||(r[e]=n[e])}),r}(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}function createConsoleLogger(e){var n=0;e&&(n="none"===e?100:["debug","info","warn","error"].indexOf(e));var r={};function t(e,r,t){e>=n&&r(t)}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 _typeof$1="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},readyEvent="ready",successEvent="initialized",failedEvent="failed",changeEvent="change",internalChangeEvent="internal-change";function initialize(e,n,r,t,o){var i=function(){if(r&&r.logger)return r.logger;return o&&o.logger||createConsoleLogger("warn")}(),a=EventEmitter(i),u=validate(r,a,o,i),s=u.hash,c=u.sendEvents,l=e,v=Stream(t,u,l,s),f=u.eventProcessor||EventProcessor(t,u,l,a),d=Requestor(t,u,l),g={},m={},p=void 0,y=void 0,h=u.streaming,E=void 0,b=!1,k=!1,S=!0,U=u.stateProvider,D=Identity(null,function(e){if(U)return;e&&L({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})}),P=UserValidator(t.localStorage,i),w=void 0;function L(e){l&&(U&&U.enqueueEvent&&U.enqueueEvent(e)||(e.user?(S=!1,!c||k||t.isDoNotTrack()||(i.debug(debugEnqueueingEvent(e.kind)),f.enqueue(e))):S&&(i.warn(eventWithoutUser()),S=!1)))}function I(e,n,r){var t=D.getUser(),o=new Date,i=n?n.value:null;if(!u.allowFrequentDuplicateEvents){var a=JSON.stringify(i)+(t&&t.key?t.key:"")+e,s=g[a];if(s&&o-s<3e5)return;g[a]=o}var c={kind:"feature",key:e,user:t,value:i,variation:n?n.variationIndex:null,default:r,creationDate:o.getTime(),reason:n?n.reason:null},l=m[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),L(c)}function F(e,n,r){var t=void 0;if(m&&m.hasOwnProperty(e)&&m[e]&&!m[e].deleted){var o=m[e];t=C(o),null!==o.value&&void 0!==o.value||(t.value=n)}else t={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return r&&I(e,t,n),t}function C(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function T(){y=!0,D.getUser()&&v.connect(D.getUser(),{ping:function(){i.debug(debugStreamPing()),d.fetchFlagSettings(D.getUser(),s).then(function(e){return N(e||{})}).catch(function(e){a.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){var n=JSON.parse(e.data);i.debug(debugStreamPut()),N(n)},patch:function(e){var n=JSON.parse(e.data),r=m[n.key];if(!r||!r.version||!n.version||r.version<n.version){i.debug(debugStreamPatch(n.key));var t={},o=extend({},n);delete o.key,m[n.key]=o;var a=C(o);t[n.key]=r?{previous:r.value,current:a}:{current:a},O(t)}else i.debug(debugStreamPatchIgnored(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!m[n.key]||m[n.key].version<n.version){i.debug(debugStreamDelete(n.key));var r={};m[n.key]&&!m[n.key].deleted&&(r[n.key]={previous:m[n.key].value}),m[n.key]={version:n.version,deleted:!0},O(r)}else i.debug(debugStreamDeleteIgnored(n.key))}})}function R(){y&&(v.disconnect(),y=!1)}function N(e){var n={};if(!e)return Promise.resolve();for(var r in m)m.hasOwnProperty(r)&&m[r]&&(e[r]&&!deepEquals(e[r].value,m[r].value)?n[r]={previous:m[r].value,current:C(e[r])}:e[r]&&!e[r].deleted||(n[r]={previous:m[r].value}));for(var t in e)e.hasOwnProperty(t)&&e[t]&&(!m[t]||m[t].deleted)&&(n[t]={current:C(e[t])});return m=e,O(n).catch(function(){})}function O(e){var n=Object.keys(e);if(n.length>0){var r={};n.forEach(function(n){var t=e[n].current,o=t?t.value:void 0,i=e[n].previous;a.emit(changeEvent+":"+n,o,i),r[n]=t?{current:o,previous:i}:{previous:i}}),a.emit(changeEvent,r),a.emit(internalChangeEvent,m),u.sendEventsOnlyForVariation||U||n.forEach(function(n){I(n,e[n].current)})}return p&&w?w.saveFlags(m).catch(function(){return null}):Promise.resolve()}function x(){var e=h||E&&void 0===h;e&&!y?T():!e&&y&&R()}function A(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}t.localStorage&&(w=new Store(t.localStorage,l,s,D,i));var j=new Promise(function(e){var n=a.on(readyEvent,function(){a.off(readyEvent,n),e()})}),_=new Promise(function(e,n){var r=a.on(successEvent,function(){a.off(successEvent,r),e()}),t=a.on(failedEvent,function(e){a.off(failedEvent,t),n(e)})});if("string"==typeof u.bootstrap&&"LOCALSTORAGE"===u.bootstrap.toUpperCase()&&(w?p=!0:i.warn(localStorageUnavailable())),U){var V=U.getInitialState();V?q(V):U.on("init",q),U.on("update",function(e){e.user&&D.setUser(e.user);e.flags&&N(e.flags)})}else(function(){if(!e)return Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()));return P.validateUser(n).then(function(e){return D.setUser(e),"object"===_typeof$1(u.bootstrap)?(m=function(e){var n=Object.keys(e),r=e.$flagsState;!r&&n.length&&i.warn(bootstrapOldFormat()),!1===e.$valid&&i.warn(bootstrapInvalid());var t={};return n.forEach(function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};r&&r[n]?o=extend(o,r[n]):o.version=0,t[n]=o}}),t}(u.bootstrap),z()):p?w.loadFlags().catch(function(){return null}).then(function(e){return null==e?(m={},d.fetchFlagSettings(D.getUser(),s).then(function(e){return N(e||{})}).then(z).catch(function(e){var n=new LDFlagFetchError(errorFetchingFlags(e));K(n)})):(m=e,onNextTick(z),d.fetchFlagSettings(D.getUser(),s).then(function(e){return N(e)}).catch(function(e){return a.maybeReportError(e)}))}):d.fetchFlagSettings(D.getUser(),s).then(function(e){m=e||{},z()}).catch(function(e){m={},K(e)})})})().catch(function(e){return a.maybeReportError(e)});function q(e){l=e.environment,D.setUser(e.user),m=e.flags,onNextTick(z)}function z(){i.info(clientInitialized()),b=!0,x(),a.emit(readyEvent),a.emit(successEvent)}function K(e){a.maybeReportError(e),a.emit(failedEvent,e),a.emit(readyEvent)}return{client:{waitForInitialization:function(){return _},waitUntilReady:function(){return j},identify:function(e,n,r){return k?wrapPromiseCallback(Promise.resolve({}),r):U?(i.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(m)),r)):wrapPromiseCallback((p&&w?w.clearFlags():Promise.resolve()).then(function(){return P.validateUser(e)}).then(function(e){return D.setUser(e)}).then(function(){return d.fetchFlagSettings(D.getUser(),n)}).then(function(e){var n=transformVersionedValuesToValues(e);return e?N(e).then(function(){return n}):n}).then(function(e){return y&&T(),e}).catch(function(e){return a.maybeReportError(e),Promise.reject(e)}),r)},getUser:function(){return D.getUser()},variation:function(e,n){return F(e,n,!0).value},variationDetail:function(e,n){return F(e,n,!0)},track:function(e,n){"string"==typeof e?(t.customEventFilter&&!t.customEventFilter(e)&&i.warn(unknownCustomEventKey(e)),L({kind:"custom",key:e,data:n,user:D.getUser(),url:t.getCurrentUrl(),creationDate:(new Date).getTime()})):a.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},on:function(e,n,r){A(e)?(E=!0,b&&x(),a.on(e,n,r)):a.on.apply(a,arguments)},off:function(e){if(a.off.apply(a,arguments),A(e)){var n=!1;a.getEvents().forEach(function(e){A(e)&&a.getEventListenerCount(e)>0&&(n=!0)}),n||(E=!1,y&&void 0===h&&R())}},setStreaming:function(e){var n=null===e?void 0:e;n!==h&&(h=n,x())},flush:function(e){return wrapPromiseCallback(c?f.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!m)return e;for(var n in m)m.hasOwnProperty(n)&&(e[n]=F(n,null,!u.sendEventsOnlyForVariation).value);return e},close:function(e){if(k)return wrapPromiseCallback(Promise.resolve(),e);var n=function(){k=!0,m={}};return wrapPromiseCallback(Promise.resolve().then(function(){if(R(),c)return f.stop(),f.flush()}).then(n).catch(n),e)}},options:u,emitter:a,ident:D,logger:i,requestor:d,start:function(){c&&f.start()},enqueueEvent:L,getFlagsInternal:function(){return m},getEnvironmentId:function(){return l},internalChangeEventName:internalChangeEvent}}var version="2.12.1";exports.initialize=initialize,exports.version=version,exports.createConsoleLogger=createConsoleLogger,exports.errors=errors,exports.messages=messages,exports.utils=utils;
//# sourceMappingURL=ldclient-common.cjs.js.map

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc