launchdarkly-js-sdk-common
Advanced tools
Comparing version 3.6.0 to 3.7.0
@@ -5,2 +5,9 @@ # Change log | ||
## [3.7.0] - 2022-10-03 | ||
### Removed: | ||
- Removed `seenRequests` cache. This cache was used to de-duplicate events, but it has been supplanted with summary events. | ||
### Deprecated: | ||
- The `allowFrequentDuplicateEvents` configuration has been deprecated because it controlled the behavior of the `seenRequests` cache. | ||
## [3.6.0] - 2022-04-21 | ||
@@ -7,0 +14,0 @@ ### Added: |
@@ -1,2 +0,2 @@ | ||
"use strict";function ownKeys(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function _objectSpread2(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(n="Object"===n&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function createCustomError(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return(t.prototype=new Error).name=e,t.prototype.constructor=t}Object.defineProperty(exports,"__esModule",{value:!0});var LDUnexpectedResponseError=createCustomError("LaunchDarklyUnexpectedResponseError"),LDInvalidEnvironmentIdError=createCustomError("LaunchDarklyInvalidEnvironmentIdError"),LDInvalidUserError=createCustomError("LaunchDarklyInvalidUserError"),LDInvalidEventKeyError=createCustomError("LaunchDarklyInvalidEventKeyError"),LDInvalidArgumentError=createCustomError("LaunchDarklyInvalidArgumentError"),LDFlagFetchError=createCustomError("LaunchDarklyFlagFetchError"),LDInvalidDataError=createCustomError("LaunchDarklyInvalidDataError");function isHttpErrorRecoverable(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({__proto__:null,LDUnexpectedResponseError:LDUnexpectedResponseError,LDInvalidEnvironmentIdError:LDInvalidEnvironmentIdError,LDInvalidUserError:LDInvalidUserError,LDInvalidEventKeyError:LDInvalidEventKeyError,LDInvalidArgumentError:LDInvalidArgumentError,LDFlagFetchError:LDFlagFetchError,LDInvalidDataError:LDInvalidDataError,isHttpErrorRecoverable:isHttpErrorRecoverable}),fromByteArray_1=fromByteArray,lookup=[],revLookup=[],code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,t,n){for(var r,o=[],i=t;i<n;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(r));return o.join("")}function fromByteArray(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(encodeChunk(e,a,s<a+i?s:a+i));return 1==r?(t=e[n-1],o.push(lookup[t>>2]+lookup[t<<4&63]+"==")):2==r&&(t=(e[n-2]<<8)+e[n-1],o.push(lookup[t>>10]+lookup[t>>4&63]+lookup[t<<2&63]+"=")),o.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63;var isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i=isArray(t),a=isArray(n);if(i&&a){if((s=t.length)!=n.length)return!1;for(r=s;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(i!=a)return!1;i=t instanceof Date,a=n instanceof Date;if(i!=a)return!1;if(i&&a)return t.getTime()==n.getTime();i=t instanceof RegExp,a=n instanceof RegExp;if(i!=a)return!1;if(i&&a)return t.toString()==n.toString();var s,u=keyList(t);if((s=u.length)!==keyList(n).length)return!1;for(r=s;0!=r--;)if(!hasProp.call(n,u[r]))return!1;for(r=s;0!=r--;)if(!e(t[o=u[r]],n[o]))return!1;return!0}return t!=t&&n!=n},userAttrsToStringify=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function appendUrlPath(e,t){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(t.startsWith("/")?"":"/")+t}function btoa(e){e=unescape(encodeURIComponent(e));return fromByteArray_1(stringToBytes(e))}function stringToBytes(e){for(var t=[],n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}function base64URLEncode(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function clone(e){return JSON.parse(JSON.stringify(e))}function deepEquals(e,t){return fastDeepEqual(e,t)}function onNextTick(e){setTimeout(e,0)}function wrapPromiseCallback(e,t){e=e.then(function(e){return t&&setTimeout(function(){t(null,e)},0),e},function(e){if(!t)return Promise.reject(e);setTimeout(function(){t(e,null)},0)});return t?void 0:e}function transformValuesToVersionedValues(e){var t,n={};for(t in e)objectHasOwnProperty(e,t)&&(n[t]={value:e[t],version:0});return n}function transformVersionedValuesToValues(e){var t,n={};for(t in e)objectHasOwnProperty(e,t)&&(n[t]=e[t].value);return n}function chunkUserEventsForUrl(e,t){for(var n,r=t.slice(0),o=[],i=e;0<r.length;){for(n=[];0<i;){var a=r.shift();if(!a)break;(i-=base64URLEncode(JSON.stringify(a)).length)<0&&0<n.length?r.unshift(a):n.push(a)}i=e,o.push(n)}return o}function getLDUserAgentString(e){var t=e.version||"3.6.0";return e.userAgent+"/"+t}function extend(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce(function(e,t){return _objectSpread2(_objectSpread2({},e),t)},{})}function objectHasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function sanitizeUser(e){if(!e)return e;var t,n;for(n in userAttrsToStringify){var r=userAttrsToStringify[n],o=e[r];void 0!==o&&"string"!=typeof o&&((t=t||_objectSpread2({},e))[r]=String(o))}return t||e}var utils=Object.freeze({__proto__:null,appendUrlPath:appendUrlPath,btoa:btoa,base64URLEncode:base64URLEncode,clone:clone,deepEquals:deepEquals,onNextTick:onNextTick,wrapPromiseCallback:wrapPromiseCallback,transformValuesToVersionedValues:transformValuesToVersionedValues,transformVersionedValuesToValues:transformVersionedValuesToValues,chunkUserEventsForUrl:chunkUserEventsForUrl,getLDUserAgentString:getLDUserAgentString,extend:extend,objectHasOwnProperty:objectHasOwnProperty,sanitizeUser:sanitizeUser});function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}for(var rngBrowser=createCommonjsModule(function(e){var t,n,r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);r?(t=new Uint8Array(16),e.exports=function(){return r(t),t}):(n=new Array(16),e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),n[t]=e>>>((3&t)<<3)&255;return n})}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,t){var t=t||0,n=byteToHex;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[+t]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,t,n){var r=t&&n||0,o=t||[],i=(e=e||{}).node||_nodeId,n=void 0!==e.clockseq?e.clockseq:_clockseq,a=(null!=i&&null!=n||(a=rngBrowser(),null==i&&(i=_nodeId=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==n&&(n=_clockseq=16383&(a[6]<<8|a[7]))),void 0!==e.msecs?e.msecs:(new Date).getTime()),s=void 0!==e.nsecs?e.nsecs:_lastNSecs+1,u=a-_lastMSecs+(s-_lastNSecs)/1e4;if(u<0&&void 0===e.clockseq&&(n=n+1&16383),1e4<=(s=(u<0||_lastMSecs<a)&&void 0===e.nsecs?0:s))throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=a,_clockseq=n;u=(1e4*(268435455&(a+=122192928e5))+(_lastNSecs=s))%4294967296,o[r++]=u>>>24&255,o[r++]=u>>>16&255,o[r++]=u>>>8&255,o[r++]=255&u,e=a/4294967296*1e4&268435455;o[r++]=e>>>8&255,o[r++]=255&e,o[r++]=e>>>24&15|16,o[r++]=e>>>16&255,o[r++]=n>>>8|128,o[r++]=255&n;for(var c=0;c<6;++c)o[r+c]=i[c];return t||bytesToUuid_1(o)}var v1_1=v1,logLevels=["debug","info","warn","error","none"];function commonBasicLogger(e,s){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function t(t){return function(e){console&&console[t]&&console[t].call(console,e)}}var u=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[t("log"),t("info"),t("warn"),t("error")],c=!(!e||!e.destination),l=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",n=1;if(e&&e.level)for(var r=0;r<logLevels.length;r++)logLevels[r]===e.level&&(n=r);for(var o={},i=function(e){var i,a=logLevels[e];"none"!==a&&(e<n?o[a]=function(){}:(i=e,o[a]=function(){var e=i,t=a,n=arguments;if(!(n.length<1)){var r=c?t+": "+l:l,o=1!==n.length&&s?((o=_toConsumableArray(n))[0]=r+o[0],s.apply(void 0,_toConsumableArray(o))):r+n[0];try{u[e](o)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+t+" method threw an exception: "+e)}}}))},a=0;a<logLevels.length;a++)i(a);return o}function validateLogger(t){logLevels.forEach(function(e){if("none"!==e&&(!t[e]||"function"!=typeof t[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")})}function createConsoleLogger(e,t){return commonBasicLogger({level:e,prefix:t})}function errorString(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var clientInitialized=function(){return"LaunchDarkly client initialized"},docLink=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",clientNotReady=function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutUser=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},invalidContentType=function(e){return'Expected application/json content type but got "'+e+'"'},invalidKey=function(){return"Event key must be a string"},localStorageUnavailable=function(e){return"local storage is unavailable: "+errorString(e)},networkError=function(e){return"network error"+(e?" ("+e+")":"")},unknownCustomEventKey=function(e){return'Custom event "'+e+'" does not exist'},environmentNotFound=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+docLink},environmentNotSpecified=function(){return"No environment/client-side ID was specified."+docLink},errorFetchingFlags=function(e){return"Error fetching flag settings: "+errorString(e)},userNotSpecified=function(){return"No user specified."+docLink},invalidUser=function(){return"Invalid user specified."+docLink},invalidData=function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},bootstrapOldFormat=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+docLink},bootstrapInvalid=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated=function(e,t){return t?'"'+e+'" is deprecated, please use "'+t+'"':'"'+e+'" is deprecated'},httpErrorMessage=function(e,t,n){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+t+" - "+(isHttpErrorRecoverable(e)?n:"giving up permanently")},httpUnavailable=function(){return"Cannot make HTTP requests in this environment."+docLink},identifyDisabled=function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing=function(){return"Closing stream connection"},streamConnecting=function(e){return"Opening stream connection to "+e},streamError=function(e,t){return"Error on stream connection: "+errorString(e)+", will continue retrying every "+t+" milliseconds."},unknownOption=function(e){return'Ignoring unknown config option "'+e+'"'},wrongOptionType=function(e,t,n){return'Config option "'+e+'" should be of type '+t+", got "+n+", using default value"},wrongOptionTypeBoolean=function(e,t){return'Config option "'+e+'" should be a boolean, got '+t+", converting to boolean"},optionBelowMinimum=function(e,t,n){return'Config option "'+e+'" was set to '+t+", changing to minimum value of "+n},debugPolling=function(e){return"polling for feature flags at "+e},debugStreamPing=function(){return"received ping message from stream"},debugStreamPut=function(){return"received streaming update for all flags"},debugStreamPatch=function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamDelete=function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugEnqueueingEvent=function(e){return'enqueueing "'+e+'" event'},debugPostingEvents=function(e){return"sending "+e+" events"},debugPostingDiagnosticEvent=function(e){return"sending diagnostic event ("+e.kind+")"},invalidTagValue=function(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')},messages=Object.freeze({__proto__:null,clientInitialized:clientInitialized,clientNotReady:clientNotReady,eventCapacityExceeded:eventCapacityExceeded,eventWithoutUser:eventWithoutUser,invalidContentType:invalidContentType,invalidKey:invalidKey,localStorageUnavailable:localStorageUnavailable,networkError:networkError,unknownCustomEventKey:unknownCustomEventKey,environmentNotFound:environmentNotFound,environmentNotSpecified:environmentNotSpecified,errorFetchingFlags:errorFetchingFlags,userNotSpecified:userNotSpecified,invalidUser:invalidUser,invalidData:invalidData,bootstrapOldFormat:bootstrapOldFormat,bootstrapInvalid:bootstrapInvalid,deprecated:deprecated,httpErrorMessage:httpErrorMessage,httpUnavailable:httpUnavailable,identifyDisabled:identifyDisabled,streamClosing:streamClosing,streamConnecting:streamConnecting,streamError:streamError,unknownOption:unknownOption,wrongOptionType:wrongOptionType,wrongOptionTypeBoolean:wrongOptionTypeBoolean,optionBelowMinimum:optionBelowMinimum,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents,debugPostingDiagnosticEvent:debugPostingDiagnosticEvent,invalidTagValue:invalidTagValue}),baseOptionDefs={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:applicationConfigValidator}},allowedTagCharacters=/^(\w|\.|-)+$/;function validateTagValue(e,t,n,r){if("string"==typeof n&&n.match(allowedTagCharacters))return n;r.warn(invalidTagValue(e))}function applicationConfigValidator(e,t,n,r){var o={};return n.id&&(o.id=validateTagValue("".concat(e,".id"),t,n.id,r)),n.version&&(o.version=validateTagValue("".concat(e,".version"),t,n.version,r)),o}function validate(e,t,n,a){var s=extend({logger:{default:a}},baseOptionDefs,n),r={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){onNextTick(function(){t&&t.maybeReportError(new LDInvalidArgumentError(e))})}var o,i,c,l,n=extend({},e||{});function d(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";e=_typeof(e);return"boolean"===e||"string"===e||"number"===e||"function"===e?e:"object"}}return o=n,Object.keys(r).forEach(function(e){var t;void 0!==o[e]&&(t=r[e],a&&a.warn(deprecated(e,t)),t&&(void 0===o[t]&&(o[t]=o[e]),delete o[e]))}),i=extend({},n),Object.keys(s).forEach(function(e){void 0!==i[e]&&null!==i[e]||(i[e]=s[e]&&s[e].default)}),l=extend({},c=n=i),Object.keys(c).forEach(function(e){var t,n,r,o,i=c[e];null!=i&&(void 0===(t=s[e])?u(unknownOption(e)):(n=t.type||d(t.default),(r=t.validator)?void 0!==(r=r(e,c,c[e],a))?l[e]=r:delete l[e]:"any"!==n&&(r=n.split("|"),o=d(i),r.indexOf(o)<0?"boolean"===n?(l[e]=!!i,u(wrongOptionTypeBoolean(e,o))):(u(wrongOptionType(e,n,o)),l[e]=t.default):"number"===o&&void 0!==t.minimum&&i<t.minimum&&(u(optionBelowMinimum(e,i,t.minimum)),l[e]=t.minimum))))}),validateLogger((n=l).logger),n}function getTags(e){var t={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(t["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(t["application-version"]=[e.application.version])),t}var configuration=Object.freeze({__proto__:null,baseOptionDefs:baseOptionDefs,validate:validate,getTags:getTags});function getLDHeaders(e,t){if(t&&!t.sendLDHeaders)return{};var e={"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)},n=(t&&t.wrapperName&&(e["X-LaunchDarkly-Wrapper"]=t.wrapperVersion?t.wrapperName+"/"+t.wrapperVersion:t.wrapperName),getTags(t)),t=Object.keys(n);return t.length&&(e["x-launchdarkly-tags"]=t.sort().flatMap(function(t){return Array.isArray(n[t])?n[t].sort().map(function(e){return"".concat(t,"/").concat(e)}):["".concat(t,"/").concat(n[t])]}).join(" ")),e}function transformHeaders(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform(_objectSpread2({},e)):e}var MAX_URL_LENGTH=2e3;function EventSender(s,e,u){var c="/a/"+e+".gif",l=extend({"Content-Type":"application/json"},getLDHeaders(s,u)),d=s.httpFallbackPing,f={};return f.sendChunk=function(e,t,r,n){var o=JSON.stringify(e),i=r?null:v1_1();function a(n){var e=r?l:extend({},l,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":i});return s.httpRequest("POST",t,transformHeaders(e,u),o).promise.then(function(e){var t;if(e)return 400<=e.status&&isHttpErrorRecoverable(e.status)&&n?a(!1):(t={status:(e=e).status},(e=e.header("date"))&&(e=Date.parse(e))&&(t.serverTime=e),t)}).catch(function(){return n?a(!1):Promise.reject()})}return n?a(!0).catch(function(){}):(d&&d(t+c+"?d="+base64URLEncode(o)),Promise.resolve())},f.sendEvents=function(e,t,n){if(!s.httpRequest)return Promise.resolve();for(var r=s.httpAllowsPost(),o=r?[e]:chunkUserEventsForUrl(MAX_URL_LENGTH-t.length,e),i=[],a=0;a<o.length;a++)i.push(f.sendChunk(o[a],t,n,r));return Promise.all(i)},f}function EventSummarizer(){var e={},a=0,s=0,u={};return e.summarizeEvent=function(e){var t,n;"feature"===e.kind&&(t=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),(n=u[t])?n.count=n.count+1:u[t]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>s&&(s=e.creationDate))},e.getSummary=function(){var e,t={},n=!0;for(e in u){var r=u[e],o=t[r.key],i=(o||(o={default:r.default,counters:[]},t[r.key]=o),{value:r.value,count:r.count});void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),n=!1}return n?null:{startDate:a,endDate:s,features:t}},e.clearSummary=function(){s=a=0,u={}},e}function UserFilter(e){var t={},a=e.allAttributesPrivate,s=e.privateAttributeNames||[],u={key:!0,custom:!0,anonymous:!0},c={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return t.filterUser=function(e){if(!e)return null;function t(n,r){return Object.keys(n).reduce(function(e,t){return r(t)&&(o(t)?e[1][t]=!0:e[0][t]=n[t]),e},[{},{}])}var n=e.privateAttributeNames||[],o=function(e){return!u[e]&&(a||-1!==n.indexOf(e)||-1!==s.indexOf(e))},r=t(e,function(e){return c[e]}),i=r[0],r=r[1],e=(e.custom&&(e=t(e.custom,function(){return 1}),i.custom=e[0],r=extend({},r,e[1])),Object.keys(r));return e.length&&(e.sort(),i.privateAttrs=e),i},t}function EventProcessor(e,t,n){var r,o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,a={},s=(5<arguments.length&&void 0!==arguments[5]?arguments[5]:null)||EventSender(e,n,t),u=appendUrlPath(t.eventsUrl,"/events/bulk/"+n),c=EventSummarizer(),l=UserFilter(t),d=t.inlineUsersInEvents,f=t.samplingInterval,v=t.eventCapacity,g=t.flushInterval,p=t.logger,m=[],y=0,h=!1,b=!1;function E(){return 0===f||0===Math.floor(Math.random()*f)}function k(e){m.length<v?(m.push(e),b=!1):(b||(b=!0,p.warn(eventCapacityExceeded())),o&&o.incrementDroppedEvents())}return a.enqueue=function(e){var t,n,r;h||(t=r=!1,c.summarizeEvent(e),"feature"===e.kind?E()&&(r=!!e.trackEvents,t=!!(n=e).debugEventsUntilDate&&(n.debugEventsUntilDate>y&&n.debugEventsUntilDate>(new Date).getTime())):r=E(),r&&k((r=extend({},n=e),"alias"!==n.kind&&(d||"identify"===n.kind?r.user=l.filterUser(n.user):(r.userKey=n.user.key,delete r.user),"feature"===n.kind&&(delete r.trackEvents,delete r.debugEventsUntilDate)),r)),t&&((r=extend({},e,{kind:"debug"})).user=l.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,k(r)))},a.flush=function(){if(h)return Promise.resolve();var e=m,t=c.getSummary();return c.clearSummary(),t&&(t.kind="summary",e.push(t)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(m=[],p.debug(debugPostingEvents(e.length)),s.sendEvents(e,u).then(function(e){e&&(e.serverTime&&(y=e.serverTime),isHttpErrorRecoverable(e.status)||(h=!0),400<=e.status&&onNextTick(function(){i.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},a.start=function(){r=setTimeout(function e(){a.flush(),r=setTimeout(e,g)},g)},a.stop=function(){clearTimeout(r)},a}function EventEmitter(t){var e={},o={};return e.on=function(e,t,n){o[e]=o[e]||[],o[e]=o[e].concat({handler:t,context:n})},e.off=function(e,t,n){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===t&&o[e][r].context===n&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var t=o[e].slice(0),n=0;n<t.length;n++)t[n].handler.apply(t[n].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(o["error"]?this.emit("error",e):(t||console).error(e.message))},e}var readyEvent="ready",successEvent="initialized",failureEvent="failed";function InitializationStateTracker(o){var t=!1,n=!1,r=null,e=null,i=new Promise(function(t){o.on(readyEvent,function e(){o.off(readyEvent,e),t()})}).catch(function(){});return{getInitializationPromise:function(){return e||(t?Promise.resolve():n?Promise.reject(r):e=new Promise(function(t,n){function r(e){o.off(failureEvent,r),n(e)}o.on(successEvent,function e(){o.off(successEvent,e),t()}),o.on(failureEvent,r)}))},getReadyPromise:function(){return i},signalSuccess:function(){t||n||(t=!0,o.emit(successEvent),o.emit(readyEvent))},signalFailure:function(e){t||n||(n=!0,r=e,o.emit(failureEvent,e),o.emit(readyEvent)),o.maybeReportError(e)}}}var InitializationState=InitializationStateTracker;function PersistentFlagStore(t,n,r,o){var i={};function a(){var e="",t=o.getUser();return t&&(e=r||btoa(JSON.stringify(t))),"ld:"+n+":"+e}return i.loadFlags=function(){return t.get(a()).then(function(e){if(null==e)return null;try{var t,n=JSON.parse(e);return n&&(void 0===(t=n.$schema)||t<1?n=transformValuesToVersionedValues(n):delete n.$schema),n}catch(e){return i.clearFlags().then(function(){return null})}})},i.saveFlags=function(e){e=extend({},e,{$schema:1});return t.set(a(),JSON.stringify(e))},i.clearFlags=function(){return t.clear(a())},i}function PersistentStorage(r,t){function o(e){n||(n=!0,t.warn(localStorageUnavailable(e)))}var e={},n=!1;return e.isEnabled=function(){return!!r},e.get=function(e){return new Promise(function(t){r?r.get(e).then(t).catch(function(e){o(e),t(void 0)}):t(void 0)})},e.set=function(e,n){return new Promise(function(t){r?r.set(e,n).then(function(){return t(!0)}).catch(function(e){o(e),t(!1)}):t(!1)})},e.clear=function(e){return new Promise(function(t){r?r.clear(e).then(function(){return t(!0)}).catch(function(e){o(e),t(!1)}):t(!1)})},e}var streamReadTimeoutMillis=3e5;function Stream(o,i,a,t){var s,u=i.streamUrl,c=i.logger,e={},l=appendUrlPath(u,"/eval/"+a),d=i.useReport,f=i.evaluationReasons,n=i.streamReconnectDelay,v=getLDHeaders(o,i),g=!1,p=null,m=null,y=null,h=null,b=null;function E(e){g||(c.warn(streamError(e,n)),g=!0),S(!1),D(),k(n)}function k(e){m||(e?m=setTimeout(r,e):r())}function r(){m=null;var e,t="",n={headers:v,readTimeoutMillis:streamReadTimeoutMillis};if(o.eventSourceFactory){for(var r in null!=h&&(t="h="+h),d?o.eventSourceAllowsReport?(e=l,n.method="REPORT",n.headers["Content-Type"]="application/json",n.body=JSON.stringify(y)):(e=appendUrlPath(u,"/ping/"+a),t=""):e=l+"/"+base64URLEncode(JSON.stringify(y)),n.headers=transformHeaders(n.headers,i),e=e+((t=f?t+(t?"&":"")+"withReasons=true":t)?"?":"")+t,D(),c.info(streamConnecting(e)),s=(new Date).getTime(),p=o.eventSourceFactory(e,n),b)objectHasOwnProperty(b,r)&&p.addEventListener(r,b[r]);p.onerror=E}}function D(){p&&(c.info(streamClosing()),p.close(),p=null)}function S(e){s&&t&&t.recordStreamInit(s,!e,(new Date).getTime()-s),s=null}return e.connect=function(e,t,n){y=e,h=t,b={};for(var r in n||{})!function(t){b[t]=function(e){S(!(g=!1)),n[t]&&n[t](e)}}(r);k()},e.disconnect=function(){clearTimeout(m),m=null,D()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function promiseCoalescer(n){var r,o,i,a,e={addPromise:function(t,e){r=t,o&&o(),o=e,t.then(function(e){r===t&&(i(e),n&&n())},function(e){r===t&&(a(e),n&&n())})}};return e.resultPromise=new Promise(function(e,t){i=e,a=t}),e}var jsonContentType="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(a,s,i){var u=s.baseUrl,c=s.useReport,l=s.evaluationReasons,d=s.logger,e={},f={};function v(e,t){if(!a.httpRequest)return new Promise(function(e,t){t(new LDFlagFetchError(httpUnavailable()))});var n=t?"REPORT":"GET",r=getLDHeaders(a,s),o=(t&&(r["Content-Type"]=jsonContentType),f[e]),i=(o||(o=promiseCoalescer(function(){delete f[e]}),f[e]=o),a.httpRequest(n,e,transformHeaders(r,s),t)),n=i.promise.then(function(e){var t;return 200===e.status?e.header("content-type")&&e.header("content-type").substring(0,jsonContentType.length)===jsonContentType?JSON.parse(e.body):(t=invalidContentType(e.header("content-type")||""),Promise.reject(new LDFlagFetchError(t))):Promise.reject(getResponseError(e))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return o.addPromise(n,function(){i.cancel&&i.cancel()}),o.resultPromise}return e.fetchJSON=function(e){return v(appendUrlPath(u,e),null)},e.fetchFlagSettings=function(e,t){var n,r,o="";return c?(n=[u,"/sdk/evalx/",i,"/user"].join(""),r=JSON.stringify(e)):(e=base64URLEncode(JSON.stringify(e)),n=[u,"/sdk/evalx/",i,"/users/",e].join("")),t&&(o="h="+t),d.debug(debugPolling(n=n+((o=l?o+(o?"&":"")+"withReasons=true":o)?"?":"")+o)),v(n,r)},e}function Identity(e,n){var r,t={setUser:function(e){var t=r&&clone(r);(r=sanitizeUser(e))&&n&&n(clone(r),t)},getUser:function(){return r?clone(r):null}};return e&&t.setUser(e),t}var ldUserIdKey="ld:$anonUserId";function UserValidator(n){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var t=clone(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?n.get(ldUserIdKey).then(function(e){return e?(t.key=e,t):(e=v1_1(),t.key=e,n.set(ldUserIdKey,e).then(function(){return t}))}):Promise.reject(new LDInvalidUserError(invalidUser()))},e}var baseOptionDefs$1=configuration.baseOptionDefs,appendUrlPath$1=utils.appendUrlPath;function DiagnosticId(e){var t={diagnosticId:v1_1()};return e&&(t.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),t}function DiagnosticsAccumulator(e){var t,n,r,o;function i(e){t=e,r=n=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:t,droppedEvents:n,eventsInLastBatch:r,streamInits:o}},setProps:function(e){t=e.dataSinceDate,n=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){n++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,t,n){o.push({timestamp:e,failed:t,durationMillis:n})},reset:i}}function DiagnosticsManager(t,r,e,n,o,i,a){var s,u,c=!!t.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",d=appendUrlPath$1(i.eventsUrl,"/events/diagnostic/"+o),f=i.diagnosticRecordingInterval,v=e,g=!!i.streaming,o={};function p(){return{sdk:function(){var e=_objectSpread2({},t.diagnosticSdkData);i.wrapperName&&(e.wrapperName=i.wrapperName);i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion);return e}(),configuration:{customBaseURI:i.baseUrl!==baseOptionDefs$1.baseUrl.default,customStreamURI:i.streamUrl!==baseOptionDefs$1.streamUrl.default,customEventsURI:i.eventsUrl!==baseOptionDefs$1.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation,autoAliasingOptOut:!!i.autoAliasingOptOut},platform:t.diagnosticPlatformData}}function m(e){i.logger&&i.logger.debug(messages.debugPostingDiagnosticEvent(e)),n.sendEvents(e,d,!0).then(function(){}).catch(function(){})}function y(){var e,t;m((t=(new Date).getTime(),e=_objectSpread2({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:t},v.getProps()),c&&(e=_objectSpread2(_objectSpread2({},e),p())),v.reset(t),e)),u=setTimeout(y,f),s=(new Date).getTime(),c&&r.isEnabled()&&(t=_objectSpread2({},v.getProps()),r.set(l,JSON.stringify(t)))}return o.start=function(){var n;c?(n=function(e){var t;e?(e=(s||0)+f)<=(t=(new Date).getTime())?y():u=setTimeout(y,e-t):0===Math.floor(4*Math.random())?y():u=setTimeout(y,f)},r.isEnabled()?r.get(l).then(function(e){if(e)try{var t=JSON.parse(e);v.setProps(t),s=t.dataSinceDate}catch(e){}n(!0)}).catch(function(){n(!1)}):n(!1)):(m(_objectSpread2({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},p())),u=setTimeout(y,f))},o.stop=function(){u&&clearTimeout(u)},o.setStreaming=function(e){g=e},o}var diagnosticEvents={DiagnosticId:DiagnosticId,DiagnosticsAccumulator:DiagnosticsAccumulator,DiagnosticsManager:DiagnosticsManager},diagnosticEvents_1=diagnosticEvents.DiagnosticId,diagnosticEvents_2=diagnosticEvents.DiagnosticsAccumulator,diagnosticEvents_3=diagnosticEvents.DiagnosticsManager,changeEvent="change",internalChangeEvent="internal-change";function initialize(A,x,e,o,t){var n,i,r,a,N,s,u,c=function(){if(e&&e.logger)return e.logger;return t&&t.logger&&t.logger.default||createConsoleLogger("warn")}(),l=EventEmitter(c),d=InitializationState(l),f=validate(e,l,t,c),v=f.sendEvents,g=A,p=f.hash,m=PersistentStorage(o.localStorage,c),V=EventSender(o,g,f),y=f.sendEvents&&!f.diagnosticOptOut,h=y?diagnosticEvents_1(g):null,b=y?diagnosticEvents_2((new Date).getTime()):null,E=y?diagnosticEvents_3(o,m,b,V,g,f,h):null,q=Stream(o,f,g,b),k=f.eventProcessor||EventProcessor(o,f,g,b,l,V),D=Requestor(o,f,g),M={},S={},w=f.streaming,H=!1,P=!1,U=!0,T=f.stateProvider,O=Identity(null,function(e,t){(function(e){T||e&&I({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!f.autoAliasingOptOut&&t&&t.anonymous&&e&&!e.anonymous&&B(e,t)}),z=UserValidator(m),L=m.isEnabled()?new PersistentFlagStore(m,g,p,O,c):null;function I(e){if(g&&!(T&&T.enqueueEvent&&T.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(U&&(c.warn(eventWithoutUser()),U=!1));U=!1}!v||P||o.isDoNotTrack()||(c.debug(debugEnqueueingEvent(e.kind)),k.enqueue(e))}}function K(e,t,n,r){var o=O.getUser(),i=new Date,a=t?t.value:null;if(!f.allowFrequentDuplicateEvents){var s=JSON.stringify(a)+(o&&o.key?o.key:"")+e,u=M[s];if(u&&i-u<3e5)return;M[s]=i}u={kind:"feature",key:e,user:o,value:a,variation:t?t.variationIndex:null,default:n,creationDate:i.getTime()},o&&o.anonymous&&(u.contextKind=j(o)),s=S[e];s&&(u.version=s.flagVersion||s.version,u.trackEvents=s.trackEvents,u.debugEventsUntilDate=s.debugEventsUntilDate),(r||s&&s.trackReason)&&t&&(u.reason=t.reason),I(u)}function C(e,t,n,r){var o,i;return S&&objectHasOwnProperty(S,e)&&S[e]&&!S[e].deleted?(i=_(o=S[e]),null!==o.value&&void 0!==o.value||(i.value=t)):i={value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}},n&&K(e,i,t,r),i}function _(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function j(e){return e.anonymous?"anonymousUser":"user"}function B(e,t){T||e&&t&&I({kind:"alias",key:e.key,contextKind:j(e),previousKey:t.key,previousContextKind:j(t),creationDate:(new Date).getTime()})}function $(){var o;i=!0,O.getUser()&&(o=function(e){try{return JSON.parse(e)}catch(e){return void l.maybeReportError(new LDInvalidDataError(invalidData()))}},q.connect(O.getUser(),p,{ping:function(){c.debug(debugStreamPing());var t=O.getUser();D.fetchFlagSettings(t,p).then(function(e){deepEquals(t,O.getUser())&&F(e||{})}).catch(function(e){l.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){e=o(e.data);e&&(c.debug(debugStreamPut()),F(e))},patch:function(e){var t,n,r,e=o(e.data);e&&(!(t=S[e.key])||!t.version||!e.version||t.version<e.version?(c.debug(debugStreamPatch(e.key)),n={},delete(r=extend({},e)).key,r=_(S[e.key]=r),n[e.key]=t?{previous:t.value,current:r}:{current:r},W(n)):c.debug(debugStreamPatchIgnored(e.key)))},delete:function(e){var t,e=o(e.data);e&&(!S[e.key]||S[e.key].version<e.version?(c.debug(debugStreamDelete(e.key)),t={},S[e.key]&&!S[e.key].deleted&&(t[e.key]={previous:S[e.key].value}),S[e.key]={version:e.version,deleted:!0},W(t)):c.debug(debugStreamDeleteIgnored(e.key)))}}))}function J(){i&&(q.disconnect(),i=!1)}function F(e){var t,n,r={};if(!e)return Promise.resolve();for(t in S)objectHasOwnProperty(S,t)&&S[t]&&(e[t]&&!deepEquals(e[t].value,S[t].value)?r[t]={previous:S[t].value,current:_(e[t])}:e[t]&&!e[t].deleted||(r[t]={previous:S[t].value}));for(n in e)objectHasOwnProperty(e,n)&&e[n]&&(!S[n]||S[n].deleted)&&(r[n]={current:_(e[n])});return S=_objectSpread2({},e),W(r).catch(function(){})}function W(o){var i,e=Object.keys(o);return 0<e.length&&(i={},e.forEach(function(e){var t=o[e].current,n=t?t.value:void 0,r=o[e].previous;l.emit(changeEvent+":"+e,n,r),i[e]=t?{current:n,previous:r}:{previous:r}}),l.emit(changeEvent,i),l.emit(internalChangeEvent,S),f.sendEventsOnlyForVariation||T||e.forEach(function(e){K(e,o[e].current)})),n&&L?L.saveFlags(S):Promise.resolve()}function G(){var e=w||r&&void 0===w;e&&!i?$():!e&&i&&J(),E&&E.setStreaming(e)}function X(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}function Q(e){g=e.environment,O.setUser(e.user),S=_objectSpread2({},e.flags),onNextTick(R)}function R(){c.info(clientInitialized()),H=!0,G(),d.signalSuccess()}function Y(e){d.signalFailure(e)}return"string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(L?n=!0:c.warn(localStorageUnavailable())),"object"===_typeof(f.bootstrap)&&(a=f.bootstrap,y=Object.keys(a),!(s=a[N="$flagsState"])&&y.length&&c.warn(bootstrapOldFormat()),!1===a.$valid&&c.warn(bootstrapInvalid()),u={},y.forEach(function(e){var t;e!==N&&"$valid"!==e&&(t={value:a[e]},s&&s[e]?t=extend(t,s[e]):t.version=0,u[e]=t)}),S=u),T?((h=T.getInitialState())?Q(h):T.on("init",Q),T.on("update",function(e){e.user&&O.setUser(e.user);e.flags&&F(e.flags)})):(A?z.validateUser(x).then(function(e){return O.setUser(e),"object"===_typeof(f.bootstrap)?R():n?L.loadFlags().then(function(e){return null==e?(S={},D.fetchFlagSettings(O.getUser(),p).then(function(e){return F(e||{})}).then(R).catch(function(e){Y(new LDFlagFetchError(errorFetchingFlags(e)))})):(S=e,onNextTick(R),D.fetchFlagSettings(O.getUser(),p).then(F).catch(function(e){return l.maybeReportError(e)}))}):D.fetchFlagSettings(O.getUser(),p).then(function(e){S=e||{},R()}).catch(function(e){S={},Y(e)})}):Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()))).catch(Y),{client:{waitForInitialization:function(){return d.getInitializationPromise()},waitUntilReady:function(){return d.getReadyPromise()},identify:function(e,r,t){return P?wrapPromiseCallback(Promise.resolve({}),t):T?(c.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(S)),t)):wrapPromiseCallback((n&&L?L.clearFlags():Promise.resolve()).then(function(){return z.validateUser(e)}).then(function(n){return D.fetchFlagSettings(n,r).then(function(e){var t=transformVersionedValuesToValues(e);return O.setUser(n),p=r,e?F(e).then(function(){return t}):t})}).then(function(e){return i&&$(),e}).catch(function(e){return l.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return O.getUser()},variation:function(e,t){return C(e,t,!0,!1).value},variationDetail:function(e,t){return C(e,t,!0,!0)},track:function(e,t,n){var r;"string"!=typeof e?l.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e))):(o.customEventFilter&&!o.customEventFilter(e)&&c.warn(unknownCustomEventKey(e)),r={kind:"custom",key:e,user:e=O.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()},e&&e.anonymous&&(r.contextKind=j(e)),null!=t&&(r.data=t),null!=n&&(r.metricValue=n),I(r))},alias:B,on:function(e,t,n){X(e)?(r=!0,H&&G(),l.on(e,t,n)):l.on.apply(l,arguments)},off:function(e){var t;l.off.apply(l,arguments),X(e)&&(t=!1,l.getEvents().forEach(function(e){X(e)&&0<l.getEventListenerCount(e)&&(t=!0)}),t||(r=!1,i&&void 0===w&&J()))},setStreaming:function(e){(e=null===e?void 0:e)!==w&&(w=e,G())},flush:function(e){return wrapPromiseCallback(v?k.flush():Promise.resolve(),e)},allFlags:function(){var e,t={};if(!S)return t;for(e in S)objectHasOwnProperty(S,e)&&(t[e]=C(e,null,!f.sendEventsOnlyForVariation).value);return t},close:function(e){return wrapPromiseCallback(P?Promise.resolve():Promise.resolve().then(function(){if(J(),E&&E.stop(),v)return k.stop(),k.flush()}).then(t).catch(t),e);function t(){P=!0,S={}}}},options:f,emitter:l,ident:O,logger:c,requestor:D,start:function(){v&&(E&&E.start(),k.start())},enqueueEvent:I,getFlagsInternal:function(){return S},getEnvironmentId:function(){return g},internalChangeEventName:internalChangeEvent}}var version="3.6.0";exports.commonBasicLogger=commonBasicLogger,exports.createConsoleLogger=createConsoleLogger,exports.errors=errors,exports.initialize=initialize,exports.messages=messages,exports.utils=utils,exports.version=version; | ||
"use strict";function ownKeys(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function _objectSpread2(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function createCustomError(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return(t.prototype=new Error).name=e,t.prototype.constructor=t}Object.defineProperty(exports,"__esModule",{value:!0});var LDUnexpectedResponseError=createCustomError("LaunchDarklyUnexpectedResponseError"),LDInvalidEnvironmentIdError=createCustomError("LaunchDarklyInvalidEnvironmentIdError"),LDInvalidUserError=createCustomError("LaunchDarklyInvalidUserError"),LDInvalidEventKeyError=createCustomError("LaunchDarklyInvalidEventKeyError"),LDInvalidArgumentError=createCustomError("LaunchDarklyInvalidArgumentError"),LDFlagFetchError=createCustomError("LaunchDarklyFlagFetchError"),LDInvalidDataError=createCustomError("LaunchDarklyInvalidDataError");function isHttpErrorRecoverable(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({__proto__:null,LDUnexpectedResponseError:LDUnexpectedResponseError,LDInvalidEnvironmentIdError:LDInvalidEnvironmentIdError,LDInvalidUserError:LDInvalidUserError,LDInvalidEventKeyError:LDInvalidEventKeyError,LDInvalidArgumentError:LDInvalidArgumentError,LDFlagFetchError:LDFlagFetchError,LDInvalidDataError:LDInvalidDataError,isHttpErrorRecoverable:isHttpErrorRecoverable}),fromByteArray_1=fromByteArray,lookup=[],revLookup=[],code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,t,n){for(var r,o=[],i=t;i<n;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(r));return o.join("")}function fromByteArray(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(encodeChunk(e,a,s<a+i?s:a+i));return 1==r?(t=e[n-1],o.push(lookup[t>>2]+lookup[t<<4&63]+"==")):2==r&&(t=(e[n-2]<<8)+e[n-1],o.push(lookup[t>>10]+lookup[t>>4&63]+lookup[t<<2&63]+"=")),o.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63;var isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i=isArray(t),a=isArray(n);if(i&&a){if((s=t.length)!=n.length)return!1;for(r=s;0!=r--;)if(!e(t[r],n[r]))return!1}else{if(i!=a)return!1;i=t instanceof Date,a=n instanceof Date;if(i!=a)return!1;if(i&&a)return t.getTime()==n.getTime();i=t instanceof RegExp,a=n instanceof RegExp;if(i!=a)return!1;if(i&&a)return t.toString()==n.toString();var s,u=keyList(t);if((s=u.length)!==keyList(n).length)return!1;for(r=s;0!=r--;)if(!hasProp.call(n,u[r]))return!1;for(r=s;0!=r--;)if(!e(t[o=u[r]],n[o]))return!1}return!0}return t!=t&&n!=n},userAttrsToStringify=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function appendUrlPath(e,t){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(t.startsWith("/")?"":"/")+t}function btoa(e){e=unescape(encodeURIComponent(e));return fromByteArray_1(stringToBytes(e))}function stringToBytes(e){for(var t=[],n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}function base64URLEncode(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function clone(e){return JSON.parse(JSON.stringify(e))}function deepEquals(e,t){return fastDeepEqual(e,t)}function onNextTick(e){setTimeout(e,0)}function wrapPromiseCallback(e,t){e=e.then(function(e){return t&&setTimeout(function(){t(null,e)},0),e},function(e){if(!t)return Promise.reject(e);setTimeout(function(){t(e,null)},0)});return t?void 0:e}function transformValuesToVersionedValues(e){var t,n={};for(t in e)objectHasOwnProperty(e,t)&&(n[t]={value:e[t],version:0});return n}function transformVersionedValuesToValues(e){var t,n={};for(t in e)objectHasOwnProperty(e,t)&&(n[t]=e[t].value);return n}function chunkUserEventsForUrl(e,t){for(var n,r=t.slice(0),o=[],i=e;0<r.length;){for(n=[];0<i;){var a=r.shift();if(!a)break;(i-=base64URLEncode(JSON.stringify(a)).length)<0&&0<n.length?r.unshift(a):n.push(a)}i=e,o.push(n)}return o}function getLDUserAgentString(e){var t=e.version||"3.7.0";return e.userAgent+"/"+t}function extend(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce(function(e,t){return _objectSpread2(_objectSpread2({},e),t)},{})}function objectHasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function sanitizeUser(e){if(!e)return e;var t,n;for(n in userAttrsToStringify){var r=userAttrsToStringify[n],o=e[r];void 0!==o&&"string"!=typeof o&&((t=t||_objectSpread2({},e))[r]=String(o))}return t||e}var utils=Object.freeze({__proto__:null,appendUrlPath:appendUrlPath,btoa:btoa,base64URLEncode:base64URLEncode,clone:clone,deepEquals:deepEquals,onNextTick:onNextTick,wrapPromiseCallback:wrapPromiseCallback,transformValuesToVersionedValues:transformValuesToVersionedValues,transformVersionedValuesToValues:transformVersionedValuesToValues,chunkUserEventsForUrl:chunkUserEventsForUrl,getLDUserAgentString:getLDUserAgentString,extend:extend,objectHasOwnProperty:objectHasOwnProperty,sanitizeUser:sanitizeUser});function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}for(var rngBrowser=createCommonjsModule(function(e){var t,n,r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);r?(t=new Uint8Array(16),e.exports=function(){return r(t),t}):(n=new Array(16),e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),n[t]=e>>>((3&t)<<3)&255;return n})}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,t){var t=t||0,n=byteToHex;return[n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],"-",n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[t++]],n[e[+t]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,t,n){var r=t&&n||0,o=t||[],i=(e=e||{}).node||_nodeId,n=void 0!==e.clockseq?e.clockseq:_clockseq,a=(null!=i&&null!=n||(a=rngBrowser(),null==i&&(i=_nodeId=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==n&&(n=_clockseq=16383&(a[6]<<8|a[7]))),void 0!==e.msecs?e.msecs:(new Date).getTime()),s=void 0!==e.nsecs?e.nsecs:_lastNSecs+1,u=a-_lastMSecs+(s-_lastNSecs)/1e4;if(u<0&&void 0===e.clockseq&&(n=n+1&16383),1e4<=(s=(u<0||_lastMSecs<a)&&void 0===e.nsecs?0:s))throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=a,_clockseq=n;u=(1e4*(268435455&(a+=122192928e5))+(_lastNSecs=s))%4294967296,o[r++]=u>>>24&255,o[r++]=u>>>16&255,o[r++]=u>>>8&255,o[r++]=255&u,e=a/4294967296*1e4&268435455;o[r++]=e>>>8&255,o[r++]=255&e,o[r++]=e>>>24&15|16,o[r++]=e>>>16&255,o[r++]=n>>>8|128,o[r++]=255&n;for(var c=0;c<6;++c)o[r+c]=i[c];return t||bytesToUuid_1(o)}var v1_1=v1,logLevels=["debug","info","warn","error","none"];function commonBasicLogger(e,s){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function t(t){return function(e){console&&console[t]&&console[t].call(console,e)}}var u=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[t("log"),t("info"),t("warn"),t("error")],c=!(!e||!e.destination),l=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",n=1;if(e&&e.level)for(var r=0;r<logLevels.length;r++)logLevels[r]===e.level&&(n=r);for(var o={},i=function(e){var i,a=logLevels[e];"none"!==a&&(e<n?o[a]=function(){}:(i=e,o[a]=function(){var e=i,t=a,n=arguments;if(!(n.length<1)){var r=c?t+": "+l:l,o=1!==n.length&&s?((o=_toConsumableArray(n))[0]=r+o[0],s.apply(void 0,_toConsumableArray(o))):r+n[0];try{u[e](o)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+t+" method threw an exception: "+e)}}}))},a=0;a<logLevels.length;a++)i(a);return o}function validateLogger(t){logLevels.forEach(function(e){if("none"!==e&&(!t[e]||"function"!=typeof t[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")})}function createConsoleLogger(e,t){return commonBasicLogger({level:e,prefix:t})}function errorString(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var clientInitialized=function(){return"LaunchDarkly client initialized"},docLink=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",clientNotReady=function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutUser=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},invalidContentType=function(e){return'Expected application/json content type but got "'+e+'"'},invalidKey=function(){return"Event key must be a string"},localStorageUnavailable=function(e){return"local storage is unavailable: "+errorString(e)},networkError=function(e){return"network error"+(e?" ("+e+")":"")},unknownCustomEventKey=function(e){return'Custom event "'+e+'" does not exist'},environmentNotFound=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+docLink},environmentNotSpecified=function(){return"No environment/client-side ID was specified."+docLink},errorFetchingFlags=function(e){return"Error fetching flag settings: "+errorString(e)},userNotSpecified=function(){return"No user specified."+docLink},invalidUser=function(){return"Invalid user specified."+docLink},invalidData=function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},bootstrapOldFormat=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+docLink},bootstrapInvalid=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated=function(e,t){return t?'"'+e+'" is deprecated, please use "'+t+'"':'"'+e+'" is deprecated'},httpErrorMessage=function(e,t,n){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+t+" - "+(isHttpErrorRecoverable(e)?n:"giving up permanently")},httpUnavailable=function(){return"Cannot make HTTP requests in this environment."+docLink},identifyDisabled=function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing=function(){return"Closing stream connection"},streamConnecting=function(e){return"Opening stream connection to "+e},streamError=function(e,t){return"Error on stream connection: "+errorString(e)+", will continue retrying every "+t+" milliseconds."},unknownOption=function(e){return'Ignoring unknown config option "'+e+'"'},wrongOptionType=function(e,t,n){return'Config option "'+e+'" should be of type '+t+", got "+n+", using default value"},wrongOptionTypeBoolean=function(e,t){return'Config option "'+e+'" should be a boolean, got '+t+", converting to boolean"},optionBelowMinimum=function(e,t,n){return'Config option "'+e+'" was set to '+t+", changing to minimum value of "+n},debugPolling=function(e){return"polling for feature flags at "+e},debugStreamPing=function(){return"received ping message from stream"},debugStreamPut=function(){return"received streaming update for all flags"},debugStreamPatch=function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamDelete=function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugEnqueueingEvent=function(e){return'enqueueing "'+e+'" event'},debugPostingEvents=function(e){return"sending "+e+" events"},debugPostingDiagnosticEvent=function(e){return"sending diagnostic event ("+e.kind+")"},invalidTagValue=function(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')},messages=Object.freeze({__proto__:null,clientInitialized:clientInitialized,clientNotReady:clientNotReady,eventCapacityExceeded:eventCapacityExceeded,eventWithoutUser:eventWithoutUser,invalidContentType:invalidContentType,invalidKey:invalidKey,localStorageUnavailable:localStorageUnavailable,networkError:networkError,unknownCustomEventKey:unknownCustomEventKey,environmentNotFound:environmentNotFound,environmentNotSpecified:environmentNotSpecified,errorFetchingFlags:errorFetchingFlags,userNotSpecified:userNotSpecified,invalidUser:invalidUser,invalidData:invalidData,bootstrapOldFormat:bootstrapOldFormat,bootstrapInvalid:bootstrapInvalid,deprecated:deprecated,httpErrorMessage:httpErrorMessage,httpUnavailable:httpUnavailable,identifyDisabled:identifyDisabled,streamClosing:streamClosing,streamConnecting:streamConnecting,streamError:streamError,unknownOption:unknownOption,wrongOptionType:wrongOptionType,wrongOptionTypeBoolean:wrongOptionTypeBoolean,optionBelowMinimum:optionBelowMinimum,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents,debugPostingDiagnosticEvent:debugPostingDiagnosticEvent,invalidTagValue:invalidTagValue}),baseOptionDefs={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:applicationConfigValidator}},allowedTagCharacters=/^(\w|\.|-)+$/;function validateTagValue(e,t,n,r){if("string"==typeof n&&n.match(allowedTagCharacters))return n;r.warn(invalidTagValue(e))}function applicationConfigValidator(e,t,n,r){var o={};return n.id&&(o.id=validateTagValue("".concat(e,".id"),t,n.id,r)),n.version&&(o.version=validateTagValue("".concat(e,".version"),t,n.version,r)),o}function validate(e,t,n,a){var s=extend({logger:{default:a}},baseOptionDefs,n),r={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null,allowFrequentDuplicateEvents:void 0};function u(e){onNextTick(function(){t&&t.maybeReportError(new LDInvalidArgumentError(e))})}var o,i,c,l,n=extend({},e||{});function d(e){return null===e?"any":void 0!==e?Array.isArray(e)?"array":"boolean"===(e=_typeof(e))||"string"===e||"number"===e||"function"===e?e:"object":void 0}return o=n,Object.keys(r).forEach(function(e){var t;void 0!==o[e]&&(t=r[e],a&&a.warn(deprecated(e,t)),t&&(void 0===o[t]&&(o[t]=o[e]),delete o[e]))}),i=extend({},n),Object.keys(s).forEach(function(e){void 0!==i[e]&&null!==i[e]||(i[e]=s[e]&&s[e].default)}),l=extend({},c=n=i),Object.keys(c).forEach(function(e){var t,n,r,o,i=c[e];null!=i&&(void 0===(t=s[e])?u(unknownOption(e)):(n=t.type||d(t.default),(r=t.validator)?void 0!==(r=r(e,c,c[e],a))?l[e]=r:delete l[e]:"any"!==n&&(r=n.split("|"),o=d(i),r.indexOf(o)<0?"boolean"===n?(l[e]=!!i,u(wrongOptionTypeBoolean(e,o))):(u(wrongOptionType(e,n,o)),l[e]=t.default):"number"===o&&void 0!==t.minimum&&i<t.minimum&&(u(optionBelowMinimum(e,i,t.minimum)),l[e]=t.minimum))))}),validateLogger((n=l).logger),n}function getTags(e){var t={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(t["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(t["application-version"]=[e.application.version])),t}var configuration=Object.freeze({__proto__:null,baseOptionDefs:baseOptionDefs,validate:validate,getTags:getTags});function getLDHeaders(e,t){var n;return t&&!t.sendLDHeaders?{}:(e={"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)},t&&t.wrapperName&&(e["X-LaunchDarkly-Wrapper"]=t.wrapperVersion?t.wrapperName+"/"+t.wrapperVersion:t.wrapperName),n=getTags(t),(t=Object.keys(n)).length&&(e["x-launchdarkly-tags"]=t.sort().flatMap(function(t){return Array.isArray(n[t])?n[t].sort().map(function(e){return"".concat(t,"/").concat(e)}):["".concat(t,"/").concat(n[t])]}).join(" ")),e)}function transformHeaders(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform(_objectSpread2({},e)):e}var MAX_URL_LENGTH=2e3;function EventSender(s,e,u){var c="/a/"+e+".gif",l=extend({"Content-Type":"application/json"},getLDHeaders(s,u)),d=s.httpFallbackPing,f={};return f.sendChunk=function(e,t,r,n){var o=JSON.stringify(e),i=r?null:v1_1();function a(n){var e=r?l:extend({},l,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":i});return s.httpRequest("POST",t,transformHeaders(e,u),o).promise.then(function(e){var t;if(e)return 400<=e.status&&isHttpErrorRecoverable(e.status)&&n?a(!1):(t={status:(e=e).status},(e=e.header("date"))&&(e=Date.parse(e))&&(t.serverTime=e),t)}).catch(function(){return n?a(!1):Promise.reject()})}return n?a(!0).catch(function(){}):(d&&d(t+c+"?d="+base64URLEncode(o)),Promise.resolve())},f.sendEvents=function(e,t,n){if(!s.httpRequest)return Promise.resolve();for(var r=s.httpAllowsPost(),o=r?[e]:chunkUserEventsForUrl(MAX_URL_LENGTH-t.length,e),i=[],a=0;a<o.length;a++)i.push(f.sendChunk(o[a],t,n,r));return Promise.all(i)},f}function EventSummarizer(){var e={},a=0,s=0,u={};return e.summarizeEvent=function(e){var t,n;"feature"===e.kind&&(t=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),(n=u[t])?n.count=n.count+1:u[t]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>s&&(s=e.creationDate))},e.getSummary=function(){var e,t={},n=!0;for(e in u){var r=u[e],o=t[r.key],i=(o||(o={default:r.default,counters:[]},t[r.key]=o),{value:r.value,count:r.count});void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),n=!1}return n?null:{startDate:a,endDate:s,features:t}},e.clearSummary=function(){s=a=0,u={}},e}function UserFilter(e){var t={},a=e.allAttributesPrivate,s=e.privateAttributeNames||[],u={key:!0,custom:!0,anonymous:!0},c={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return t.filterUser=function(e){var t,o,n,r,i;return e?(t=e.privateAttributeNames||[],o=function(e){return!u[e]&&(a||-1!==t.indexOf(e)||-1!==s.indexOf(e))},n=(r=(i=function(n,r){return Object.keys(n).reduce(function(e,t){return r(t)&&(o(t)?e[1][t]=!0:e[0][t]=n[t]),e},[{},{}])})(e,function(e){return c[e]}))[0],r=r[1],e.custom&&(i=i(e.custom,function(){return 1}),n.custom=i[0],r=extend({},r,i[1])),(e=Object.keys(r)).length&&(e.sort(),n.privateAttrs=e),n):null},t}function EventProcessor(e,t,n){var r,o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,a={},s=(5<arguments.length&&void 0!==arguments[5]?arguments[5]:null)||EventSender(e,n,t),u=appendUrlPath(t.eventsUrl,"/events/bulk/"+n),c=EventSummarizer(),l=UserFilter(t),d=t.inlineUsersInEvents,f=t.samplingInterval,v=t.eventCapacity,g=t.flushInterval,p=t.logger,m=[],y=0,h=!1,b=!1;function E(){return 0===f||0===Math.floor(Math.random()*f)}function k(e){m.length<v?(m.push(e),b=!1):(b||(b=!0,p.warn(eventCapacityExceeded())),o&&o.incrementDroppedEvents())}return a.enqueue=function(e){var t,n,r;h||(t=r=!1,c.summarizeEvent(e),"feature"===e.kind?E()&&(r=!!e.trackEvents,t=!!(n=e).debugEventsUntilDate&&(n.debugEventsUntilDate>y&&n.debugEventsUntilDate>(new Date).getTime())):r=E(),r&&k((r=extend({},n=e),"alias"!==n.kind&&(d||"identify"===n.kind?r.user=l.filterUser(n.user):(r.userKey=n.user.key,delete r.user),"feature"===n.kind&&(delete r.trackEvents,delete r.debugEventsUntilDate)),r)),t&&((r=extend({},e,{kind:"debug"})).user=l.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,k(r)))},a.flush=function(){var e,t;return h||(e=m,t=c.getSummary(),c.clearSummary(),t&&(t.kind="summary",e.push(t)),o&&o.setEventsInLastBatch(e.length),0===e.length)?Promise.resolve():(m=[],p.debug(debugPostingEvents(e.length)),s.sendEvents(e,u).then(function(e){e&&(e.serverTime&&(y=e.serverTime),isHttpErrorRecoverable(e.status)||(h=!0),400<=e.status&&onNextTick(function(){i.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},a.start=function(){r=setTimeout(function e(){a.flush(),r=setTimeout(e,g)},g)},a.stop=function(){clearTimeout(r)},a}function EventEmitter(t){var e={},o={};return e.on=function(e,t,n){o[e]=o[e]||[],o[e]=o[e].concat({handler:t,context:n})},e.off=function(e,t,n){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===t&&o[e][r].context===n&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var t=o[e].slice(0),n=0;n<t.length;n++)t[n].handler.apply(t[n].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(o["error"]?this.emit("error",e):(t||console).error(e.message))},e}var readyEvent="ready",successEvent="initialized",failureEvent="failed";function InitializationStateTracker(o){var t=!1,n=!1,r=null,e=null,i=new Promise(function(t){o.on(readyEvent,function e(){o.off(readyEvent,e),t()})}).catch(function(){});return{getInitializationPromise:function(){if(!e){if(t)return Promise.resolve();if(n)return Promise.reject(r);e=new Promise(function(t,n){function r(e){o.off(failureEvent,r),n(e)}o.on(successEvent,function e(){o.off(successEvent,e),t()}),o.on(failureEvent,r)})}return e},getReadyPromise:function(){return i},signalSuccess:function(){t||n||(t=!0,o.emit(successEvent),o.emit(readyEvent))},signalFailure:function(e){t||n||(n=!0,r=e,o.emit(failureEvent,e),o.emit(readyEvent)),o.maybeReportError(e)}}}var InitializationState=InitializationStateTracker;function PersistentFlagStore(t,n,r,o){var i={};function a(){var e="",t=o.getUser();return t&&(e=r||btoa(JSON.stringify(t))),"ld:"+n+":"+e}return i.loadFlags=function(){return t.get(a()).then(function(e){if(null==e)return null;try{var t,n=JSON.parse(e);return n&&(void 0===(t=n.$schema)||t<1?n=transformValuesToVersionedValues(n):delete n.$schema),n}catch(e){return i.clearFlags().then(function(){return null})}})},i.saveFlags=function(e){e=extend({},e,{$schema:1});return t.set(a(),JSON.stringify(e))},i.clearFlags=function(){return t.clear(a())},i}function PersistentStorage(r,t){function o(e){n||(n=!0,t.warn(localStorageUnavailable(e)))}var e={},n=!1;return e.isEnabled=function(){return!!r},e.get=function(e){return new Promise(function(t){r?r.get(e).then(t).catch(function(e){o(e),t(void 0)}):t(void 0)})},e.set=function(e,n){return new Promise(function(t){r?r.set(e,n).then(function(){return t(!0)}).catch(function(e){o(e),t(!1)}):t(!1)})},e.clear=function(e){return new Promise(function(t){r?r.clear(e).then(function(){return t(!0)}).catch(function(e){o(e),t(!1)}):t(!1)})},e}var streamReadTimeoutMillis=3e5;function Stream(o,i,a,t){var s,u=i.streamUrl,c=i.logger,e={},l=appendUrlPath(u,"/eval/"+a),d=i.useReport,f=i.evaluationReasons,n=i.streamReconnectDelay,v=getLDHeaders(o,i),g=!1,p=null,m=null,y=null,h=null,b=null;function E(e){g||(c.warn(streamError(e,n)),g=!0),S(!1),D(),k(n)}function k(e){m||(e?m=setTimeout(r,e):r())}function r(){m=null;var e,t="",n={headers:v,readTimeoutMillis:streamReadTimeoutMillis};if(o.eventSourceFactory){for(var r in null!=h&&(t="h="+h),d?o.eventSourceAllowsReport?(e=l,n.method="REPORT",n.headers["Content-Type"]="application/json",n.body=JSON.stringify(y)):(e=appendUrlPath(u,"/ping/"+a),t=""):e=l+"/"+base64URLEncode(JSON.stringify(y)),n.headers=transformHeaders(n.headers,i),e=e+((t=f?t+(t?"&":"")+"withReasons=true":t)?"?":"")+t,D(),c.info(streamConnecting(e)),s=(new Date).getTime(),p=o.eventSourceFactory(e,n),b)objectHasOwnProperty(b,r)&&p.addEventListener(r,b[r]);p.onerror=E}}function D(){p&&(c.info(streamClosing()),p.close(),p=null)}function S(e){s&&t&&t.recordStreamInit(s,!e,(new Date).getTime()-s),s=null}return e.connect=function(e,t,n){y=e,h=t,b={};for(var r in n||{})!function(t){b[t]=function(e){S(!(g=!1)),n[t]&&n[t](e)}}(r);k()},e.disconnect=function(){clearTimeout(m),m=null,D()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function promiseCoalescer(n){var r,o,i,a,e={addPromise:function(t,e){r=t,o&&o(),o=e,t.then(function(e){r===t&&(i(e),n&&n())},function(e){r===t&&(a(e),n&&n())})}};return e.resultPromise=new Promise(function(e,t){i=e,a=t}),e}var jsonContentType="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(a,s,i){var u=s.baseUrl,c=s.useReport,l=s.evaluationReasons,d=s.logger,e={},f={};function v(e,t){var n,r,o,i;return a.httpRequest?(i=t?"REPORT":"GET",n=getLDHeaders(a,s),t&&(n["Content-Type"]=jsonContentType),(r=f[e])||(r=promiseCoalescer(function(){delete f[e]}),f[e]=r),i=(o=a.httpRequest(i,e,transformHeaders(n,s),t)).promise.then(function(e){var t;return 200===e.status?e.header("content-type")&&e.header("content-type").substring(0,jsonContentType.length)===jsonContentType?JSON.parse(e.body):(t=invalidContentType(e.header("content-type")||""),Promise.reject(new LDFlagFetchError(t))):Promise.reject(getResponseError(e))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))}),r.addPromise(i,function(){o.cancel&&o.cancel()}),r.resultPromise):new Promise(function(e,t){t(new LDFlagFetchError(httpUnavailable()))})}return e.fetchJSON=function(e){return v(appendUrlPath(u,e),null)},e.fetchFlagSettings=function(e,t){var n,r,o="";return c?(n=[u,"/sdk/evalx/",i,"/user"].join(""),r=JSON.stringify(e)):(e=base64URLEncode(JSON.stringify(e)),n=[u,"/sdk/evalx/",i,"/users/",e].join("")),t&&(o="h="+t),d.debug(debugPolling(n=n+((o=l?o+(o?"&":"")+"withReasons=true":o)?"?":"")+o)),v(n,r)},e}function Identity(e,n){var r,t={setUser:function(e){var t=r&&clone(r);(r=sanitizeUser(e))&&n&&n(clone(r),t)},getUser:function(){return r?clone(r):null}};return e&&t.setUser(e),t}var ldUserIdKey="ld:$anonUserId";function UserValidator(n){var e={};return e.validateUser=function(e){var t;return e?null!==(t=clone(e)).key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?n.get(ldUserIdKey).then(function(e){return e?(t.key=e,t):(e=v1_1(),t.key=e,n.set(ldUserIdKey,e).then(function(){return t}))}):Promise.reject(new LDInvalidUserError(invalidUser())):Promise.reject(new LDInvalidUserError(userNotSpecified()))},e}var baseOptionDefs$1=configuration.baseOptionDefs,appendUrlPath$1=utils.appendUrlPath;function DiagnosticId(e){var t={diagnosticId:v1_1()};return e&&(t.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),t}function DiagnosticsAccumulator(e){var t,n,r,o;function i(e){t=e,r=n=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:t,droppedEvents:n,eventsInLastBatch:r,streamInits:o}},setProps:function(e){t=e.dataSinceDate,n=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){n++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,t,n){o.push({timestamp:e,failed:t,durationMillis:n})},reset:i}}function DiagnosticsManager(t,r,e,n,o,i,a){var s,u,c=!!t.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",d=appendUrlPath$1(i.eventsUrl,"/events/diagnostic/"+o),f=i.diagnosticRecordingInterval,v=e,g=!!i.streaming,o={};function p(){return{sdk:function(){var e=_objectSpread2({},t.diagnosticSdkData);i.wrapperName&&(e.wrapperName=i.wrapperName);i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion);return e}(),configuration:{customBaseURI:i.baseUrl!==baseOptionDefs$1.baseUrl.default,customStreamURI:i.streamUrl!==baseOptionDefs$1.streamUrl.default,customEventsURI:i.eventsUrl!==baseOptionDefs$1.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation,autoAliasingOptOut:!!i.autoAliasingOptOut},platform:t.diagnosticPlatformData}}function m(e){i.logger&&i.logger.debug(messages.debugPostingDiagnosticEvent(e)),n.sendEvents(e,d,!0).then(function(){}).catch(function(){})}function y(){var e,t;m((t=(new Date).getTime(),e=_objectSpread2({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:t},v.getProps()),c&&(e=_objectSpread2(_objectSpread2({},e),p())),v.reset(t),e)),u=setTimeout(y,f),s=(new Date).getTime(),c&&r.isEnabled()&&(t=_objectSpread2({},v.getProps()),r.set(l,JSON.stringify(t)))}return o.start=function(){var n;c?(n=function(e){var t;e?(e=(s||0)+f)<=(t=(new Date).getTime())?y():u=setTimeout(y,e-t):0===Math.floor(4*Math.random())?y():u=setTimeout(y,f)},r.isEnabled()?r.get(l).then(function(e){if(e)try{var t=JSON.parse(e);v.setProps(t),s=t.dataSinceDate}catch(e){}n(!0)}).catch(function(){n(!1)}):n(!1)):(m(_objectSpread2({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},p())),u=setTimeout(y,f))},o.stop=function(){u&&clearTimeout(u)},o.setStreaming=function(e){g=e},o}var diagnosticEvents={DiagnosticId:DiagnosticId,DiagnosticsAccumulator:DiagnosticsAccumulator,DiagnosticsManager:DiagnosticsManager},diagnosticEvents_1=diagnosticEvents.DiagnosticId,diagnosticEvents_2=diagnosticEvents.DiagnosticsAccumulator,diagnosticEvents_3=diagnosticEvents.DiagnosticsManager,changeEvent="change",internalChangeEvent="internal-change";function initialize(A,x,e,o,t){var n,i,r,a,N,s,u,c=function(){if(e&&e.logger)return e.logger;return t&&t.logger&&t.logger.default||createConsoleLogger("warn")}(),l=EventEmitter(c),d=InitializationState(l),f=validate(e,l,t,c),v=f.sendEvents,g=A,p=f.hash,m=PersistentStorage(o.localStorage,c),V=EventSender(o,g,f),y=f.sendEvents&&!f.diagnosticOptOut,h=y?diagnosticEvents_1(g):null,b=y?diagnosticEvents_2((new Date).getTime()):null,E=y?diagnosticEvents_3(o,m,b,V,g,f,h):null,q=Stream(o,f,g,b),k=f.eventProcessor||EventProcessor(o,f,g,b,l,V),D=Requestor(o,f,g),S={},w=f.streaming,M=!1,P=!1,U=!0,T=f.stateProvider,L=Identity(null,function(e,t){(function(e){T||e&&I({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!f.autoAliasingOptOut&&t&&t.anonymous&&e&&!e.anonymous&&K(e,t)}),H=UserValidator(m),O=m.isEnabled()?new PersistentFlagStore(m,g,p,L,c):null;function I(e){if(g&&!(T&&T.enqueueEvent&&T.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(U&&(c.warn(eventWithoutUser()),U=!1));U=!1}!v||P||o.isDoNotTrack()||(c.debug(debugEnqueueingEvent(e.kind)),k.enqueue(e))}}function z(e,t,n,r){var o=L.getUser(),i=new Date,n={kind:"feature",key:e,user:o,value:t?t.value:null,variation:t?t.variationIndex:null,default:n,creationDate:i.getTime()},i=(o&&o.anonymous&&(n.contextKind=j(o)),S[e]);i&&(n.version=i.flagVersion||i.version,n.trackEvents=i.trackEvents,n.debugEventsUntilDate=i.debugEventsUntilDate),(r||i&&i.trackReason)&&t&&(n.reason=t.reason),I(n)}function C(e,t,n,r){var o,i;return S&&objectHasOwnProperty(S,e)&&S[e]&&!S[e].deleted?(i=_(o=S[e]),null!==o.value&&void 0!==o.value||(i.value=t)):i={value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}},n&&z(e,i,t,r),i}function _(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function j(e){return e.anonymous?"anonymousUser":"user"}function K(e,t){T||e&&t&&I({kind:"alias",key:e.key,contextKind:j(e),previousKey:t.key,previousContextKind:j(t),creationDate:(new Date).getTime()})}function B(){var o;i=!0,L.getUser()&&(o=function(e){try{return JSON.parse(e)}catch(e){l.maybeReportError(new LDInvalidDataError(invalidData()))}},q.connect(L.getUser(),p,{ping:function(){c.debug(debugStreamPing());var t=L.getUser();D.fetchFlagSettings(t,p).then(function(e){deepEquals(t,L.getUser())&&F(e||{})}).catch(function(e){l.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){e=o(e.data);e&&(c.debug(debugStreamPut()),F(e))},patch:function(e){var t,n,r,e=o(e.data);e&&(!(t=S[e.key])||!t.version||!e.version||t.version<e.version?(c.debug(debugStreamPatch(e.key)),n={},delete(r=extend({},e)).key,r=_(S[e.key]=r),n[e.key]=t?{previous:t.value,current:r}:{current:r},J(n)):c.debug(debugStreamPatchIgnored(e.key)))},delete:function(e){var t,e=o(e.data);e&&(!S[e.key]||S[e.key].version<e.version?(c.debug(debugStreamDelete(e.key)),t={},S[e.key]&&!S[e.key].deleted&&(t[e.key]={previous:S[e.key].value}),S[e.key]={version:e.version,deleted:!0},J(t)):c.debug(debugStreamDeleteIgnored(e.key)))}}))}function $(){i&&(q.disconnect(),i=!1)}function F(e){var t,n,r={};if(!e)return Promise.resolve();for(t in S)objectHasOwnProperty(S,t)&&S[t]&&(e[t]&&!deepEquals(e[t].value,S[t].value)?r[t]={previous:S[t].value,current:_(e[t])}:e[t]&&!e[t].deleted||(r[t]={previous:S[t].value}));for(n in e)objectHasOwnProperty(e,n)&&e[n]&&(!S[n]||S[n].deleted)&&(r[n]={current:_(e[n])});return S=_objectSpread2({},e),J(r).catch(function(){})}function J(o){var i,e=Object.keys(o);return 0<e.length&&(i={},e.forEach(function(e){var t=o[e].current,n=t?t.value:void 0,r=o[e].previous;l.emit(changeEvent+":"+e,n,r),i[e]=t?{current:n,previous:r}:{previous:r}}),l.emit(changeEvent,i),l.emit(internalChangeEvent,S),f.sendEventsOnlyForVariation||T||e.forEach(function(e){z(e,o[e].current)})),n&&O?O.saveFlags(S):Promise.resolve()}function W(){var e=w||r&&void 0===w;e&&!i?B():!e&&i&&$(),E&&E.setStreaming(e)}function G(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}function X(e){g=e.environment,L.setUser(e.user),S=_objectSpread2({},e.flags),onNextTick(R)}function R(){c.info(clientInitialized()),M=!0,W(),d.signalSuccess()}function Q(e){d.signalFailure(e)}return"string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(O?n=!0:c.warn(localStorageUnavailable())),"object"===_typeof(f.bootstrap)&&(a=f.bootstrap,y=Object.keys(a),!(s=a[N="$flagsState"])&&y.length&&c.warn(bootstrapOldFormat()),!1===a.$valid&&c.warn(bootstrapInvalid()),u={},y.forEach(function(e){var t;e!==N&&"$valid"!==e&&(t={value:a[e]},s&&s[e]?t=extend(t,s[e]):t.version=0,u[e]=t)}),S=u),T?((h=T.getInitialState())?X(h):T.on("init",X),T.on("update",function(e){e.user&&L.setUser(e.user);e.flags&&F(e.flags)})):(A?H.validateUser(x).then(function(e){return L.setUser(e),"object"===_typeof(f.bootstrap)?R():n?O.loadFlags().then(function(e){return null==e?(S={},D.fetchFlagSettings(L.getUser(),p).then(function(e){return F(e||{})}).then(R).catch(function(e){Q(new LDFlagFetchError(errorFetchingFlags(e)))})):(S=e,onNextTick(R),D.fetchFlagSettings(L.getUser(),p).then(F).catch(function(e){return l.maybeReportError(e)}))}):D.fetchFlagSettings(L.getUser(),p).then(function(e){S=e||{},R()}).catch(function(e){S={},Q(e)})}):Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()))).catch(Q),{client:{waitForInitialization:function(){return d.getInitializationPromise()},waitUntilReady:function(){return d.getReadyPromise()},identify:function(e,r,t){return P?wrapPromiseCallback(Promise.resolve({}),t):T?(c.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(S)),t)):wrapPromiseCallback((n&&O?O.clearFlags():Promise.resolve()).then(function(){return H.validateUser(e)}).then(function(n){return D.fetchFlagSettings(n,r).then(function(e){var t=transformVersionedValuesToValues(e);return L.setUser(n),p=r,e?F(e).then(function(){return t}):t})}).then(function(e){return i&&B(),e}).catch(function(e){return l.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return L.getUser()},variation:function(e,t){return C(e,t,!0,!1).value},variationDetail:function(e,t){return C(e,t,!0,!0)},track:function(e,t,n){var r;"string"!=typeof e?l.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e))):(o.customEventFilter&&!o.customEventFilter(e)&&c.warn(unknownCustomEventKey(e)),r={kind:"custom",key:e,user:e=L.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()},e&&e.anonymous&&(r.contextKind=j(e)),null!=t&&(r.data=t),null!=n&&(r.metricValue=n),I(r))},alias:K,on:function(e,t,n){G(e)?(r=!0,M&&W(),l.on(e,t,n)):l.on.apply(l,arguments)},off:function(e){var t;l.off.apply(l,arguments),G(e)&&(t=!1,l.getEvents().forEach(function(e){G(e)&&0<l.getEventListenerCount(e)&&(t=!0)}),t||(r=!1,i&&void 0===w&&$()))},setStreaming:function(e){(e=null===e?void 0:e)!==w&&(w=e,W())},flush:function(e){return wrapPromiseCallback(v?k.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(S)for(var t in S)objectHasOwnProperty(S,t)&&!S[t].deleted&&(e[t]=C(t,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){var t;return P?wrapPromiseCallback(Promise.resolve(),e):(t=function(){P=!0,S={}},wrapPromiseCallback(Promise.resolve().then(function(){if($(),E&&E.stop(),v)return k.stop(),k.flush()}).then(t).catch(t),e))}},options:f,emitter:l,ident:L,logger:c,requestor:D,start:function(){v&&(E&&E.start(),k.start())},enqueueEvent:I,getFlagsInternal:function(){return S},getEnvironmentId:function(){return g},internalChangeEventName:internalChangeEvent}}var version="3.7.0";exports.commonBasicLogger=commonBasicLogger,exports.createConsoleLogger=createConsoleLogger,exports.errors=errors,exports.initialize=initialize,exports.messages=messages,exports.utils=utils,exports.version=version; | ||
//# sourceMappingURL=ldclient-common.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
function e(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function n(n){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?e(Object(i),!0).forEach((function(e){r(n,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}))}return n}function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(!e)return;if("string"==typeof e)return o(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return o(e,n)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function a(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 u=a("LaunchDarklyUnexpectedResponseError"),s=a("LaunchDarklyInvalidEnvironmentIdError"),c=a("LaunchDarklyInvalidUserError"),l=a("LaunchDarklyInvalidEventKeyError"),f=a("LaunchDarklyInvalidArgumentError"),v=a("LaunchDarklyFlagFetchError"),d=a("LaunchDarklyInvalidDataError");function g(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var p=Object.freeze({__proto__:null,LDUnexpectedResponseError:u,LDInvalidEnvironmentIdError:s,LDInvalidUserError:c,LDInvalidEventKeyError:l,LDInvalidArgumentError:f,LDFlagFetchError:v,LDInvalidDataError:d,isHttpErrorRecoverable:g}),m=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(w(e,o,o+16383>a?a:o+16383));1===r?(n=e[t-1],i.push(y[n>>2]+y[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],i.push(y[n>>10]+y[n>>4&63]+y[n<<2&63]+"="));return i.join("")},y=[],h=[],b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k=0,E=b.length;k<E;++k)y[k]=b[k],h[b.charCodeAt(k)]=k;function w(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(y[(i=r)>>18&63]+y[i>>12&63]+y[i>>6&63]+y[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63;var D=Array.isArray,O=Object.keys,S=Object.prototype.hasOwnProperty,P=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function U(e,n){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(n.startsWith("/")?"":"/")+n}function I(e){var n=unescape(encodeURIComponent(e));return m(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function j(e){return I(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function T(e){return JSON.parse(JSON.stringify(e))}function R(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=D(n),u=D(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=O(n);if((i=v.length)!==O(t).length)return!1;for(r=i;0!=r--;)if(!S.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t}(e,n)}function A(e){setTimeout(e,0)}function L(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 C(e){var n={};for(var t in e)V(e,t)&&(n[t]={value:e[t],version:0});return n}function F(e){var n={};for(var t in e)V(e,t)&&(n[t]=e[t].value);return n}function N(e,n){for(var t,r=n.slice(0),i=[],o=e;r.length>0;){for(t=[];o>0;){var a=r.shift();if(!a)break;(o-=j(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function x(e){var n=e.version||"3.6.0";return e.userAgent+"/"+n}function q(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.reduce((function(e,t){return n(n({},e),t)}),{})}function V(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function _(e){if(!e)return e;var t;for(var r in P){var i=P[r],o=e[i];void 0!==o&&"string"!=typeof o&&((t=t||n({},e))[i]=String(o))}return t||e}var z=Object.freeze({__proto__:null,appendUrlPath:U,btoa:I,base64URLEncode:j,clone:T,deepEquals:R,onNextTick:A,wrapPromiseCallback:L,transformValuesToVersionedValues:C,transformVersionedValuesToValues:F,chunkUserEventsForUrl:N,getLDUserAgentString:x,extend:q,objectHasOwnProperty:V,sanitizeUser:_});for(var J=function(e,n){return e(n={exports:{}},n.exports),n.exports}((function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}})),M=[],K=0;K<256;++K)M[K]=(K+256).toString(16).substr(1);var $,B,H=function(e,n){var t=n||0,r=M;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("")},G=0,W=0;var X=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||$,a=void 0!==e.clockseq?e.clockseq:B;if(null==o||null==a){var u=J();null==o&&(o=$=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=B=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:W+1,l=s-G+(c-W)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>G)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");G=s,W=c,B=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var v=s/4294967296*1e4&268435455;i[r++]=v>>>8&255,i[r++]=255&v,i[r++]=v>>>24&15|16,i[r++]=v>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var d=0;d<6;++d)i[r+d]=o[d];return n||H(i)},Q=["debug","info","warn","error","none"];function Y(e,n){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function t(e){return function(n){console&&console[e]&&console[e].call(console,n)}}var r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[t("log"),t("info"),t("warn"),t("error")],o=!(!e||!e.destination),a=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",u=1;if(e&&e.level)for(var s=0;s<Q.length;s++)Q[s]===e.level&&(u=s);function c(e,t,u){if(!(u.length<1)){var s,c=o?t+": "+a:a;if(1!==u.length&&n){var l=i(u);l[0]=c+l[0],s=n.apply(void 0,i(l))}else s=c+u[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+t+" method threw an exception: "+e)}}}for(var l={},f=function(e){var n=Q[e];if("none"!==n)if(e<u)l[n]=function(){};else{var t=e;l[n]=function(){c(t,n,arguments)}}},v=0;v<Q.length;v++)f(v);return l}function Z(e,n){return Y({level:e,prefix:n})}function ee(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var ne=function(){return"LaunchDarkly client initialized"},te=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",re=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},ie=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},oe=function(e){return'Expected application/json content type but got "'+e+'"'},ae=function(e){return"local storage is unavailable: "+ee(e)},ue=function(e){return"network error"+(e?" ("+e+")":"")},se=function(e){return'Custom event "'+e+'" does not exist'},ce=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+te},le=function(){return"No environment/client-side ID was specified."+te},fe=function(e){return"Error fetching flag settings: "+ee(e)},ve=function(){return"No user specified."+te},de=function(){return"Invalid user specified."+te},ge=function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},pe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+te},me=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},ye=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},he=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(g(e)?t:"giving up permanently")},be=function(){return"Cannot make HTTP requests in this environment."+te},ke=function(){return"identify() has no effect here; it must be called on the main client instance"},Ee=function(){return"Closing stream connection"},we=function(e){return"Opening stream connection to "+e},De=function(e,n){return"Error on stream connection: "+ee(e)+", will continue retrying every "+n+" milliseconds."},Oe=function(e){return'Ignoring unknown config option "'+e+'"'},Se=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Pe=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Ue=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Ie=function(e){return"polling for feature flags at "+e},je=function(){return"received ping message from stream"},Te=function(){return"received streaming update for all flags"},Re=function(e){return'received streaming update for flag "'+e+'"'},Ae=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Le=function(e){return'received streaming deletion for flag "'+e+'"'},Ce=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Fe=function(e){return'enqueueing "'+e+'" event'},Ne=function(e){return"sending "+e+" events"},xe=function(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')},qe=Object.freeze({__proto__:null,clientInitialized:ne,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:re,eventWithoutUser:ie,invalidContentType:oe,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ae,networkError:ue,unknownCustomEventKey:se,environmentNotFound:ce,environmentNotSpecified:le,errorFetchingFlags:fe,userNotSpecified:ve,invalidUser:de,invalidData:ge,bootstrapOldFormat:pe,bootstrapInvalid:me,deprecated:ye,httpErrorMessage:he,httpUnavailable:be,identifyDisabled:ke,streamClosing:Ee,streamConnecting:we,streamError:De,unknownOption:Oe,wrongOptionType:Se,wrongOptionTypeBoolean:Pe,optionBelowMinimum:Ue,debugPolling:Ie,debugStreamPing:je,debugStreamPut:Te,debugStreamPatch:Re,debugStreamPatchIgnored:Ae,debugStreamDelete:Le,debugStreamDeleteIgnored:Ce,debugEnqueueingEvent:Fe,debugPostingEvents:Ne,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},invalidTagValue:xe}),Ve={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:function(e,n,t,r){var i={};t.id&&(i.id=ze("".concat(e,".id"),n,t.id,r));t.version&&(i.version=ze("".concat(e,".version"),n,t.version,r));return i}}},_e=/^(\w|\.|-)+$/;function ze(e,n,t,r){if("string"==typeof t&&t.match(_e))return t;r.warn(xe(e))}function Je(e,n,r,i){var o=q({logger:{default:i}},Ve,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){A((function(){n&&n.maybeReportError(new f(e))}))}var s=q({},e||{});return function(e){var n=e;Object.keys(a).forEach((function(e){if(void 0!==n[e]){var t=a[e];i&&i.warn(ye(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),function(e){Q.forEach((function(n){if("none"!==n&&(!e[n]||"function"!=typeof e[n]))throw new Error("Provided logger instance must support logger."+n+"(...) method")}))}((s=function(e){var n=q({},e),r=function(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=t(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}};return Object.keys(e).forEach((function(t){var a=e[t];if(null!=a){var s=o[t];if(void 0===s)u(Oe(t));else{var c=s.type||r(s.default),l=s.validator;if(l){var f=l(t,e,e[t],i);void 0!==f?n[t]=f:delete n[t]}else if("any"!==c){var v=c.split("|"),d=r(a);v.indexOf(d)<0?"boolean"===c?(n[t]=!!a,u(Pe(t,d))):(u(Se(t,c,d)),n[t]=s.default):"number"===d&&void 0!==s.minimum&&a<s.minimum&&(u(Ue(t,a,s.minimum)),n[t]=s.minimum)}}}})),n}(s=function(e){var n=q({},e);return Object.keys(o).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=o[e]&&o[e].default)})),n}(s))).logger),s}function Me(e){var n={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(n["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(n["application-version"]=[e.application.version])),n}function Ke(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":x(e)};n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName);var r=Me(n),i=Object.keys(r);return i.length&&(t["x-launchdarkly-tags"]=i.sort().flatMap((function(e){return Array.isArray(r[e])?r[e].sort().map((function(n){return"".concat(e,"/").concat(n)})):["".concat(e,"/").concat(r[e])]})).join(" ")),t}function $e(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform(n({},e)):e}function Be(e,n,t){var r="/a/"+n+".gif",i=q({"Content-Type":"application/json"},Ke(e,t)),o=e.httpFallbackPing,a={};return a.sendChunk=function(n,a,u,s){var c=JSON.stringify(n),l=u?null:X();return s?function n(r){var o=u?i:q({},i,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":l});return e.httpRequest("POST",a,$e(o,t),c).promise.then((function(e){if(e)return e.status>=400&&g(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(o&&o(a+r+"?d="+j(c)),Promise.resolve())},a.sendEvents=function(n,t,r){if(!e.httpRequest)return Promise.resolve();var i,o=e.httpAllowsPost();i=o?[n]:N(2e3-t.length,n);for(var u=[],s=0;s<i.length;s++)u.push(a.sendChunk(i[s],t,r,o));return Promise.all(u)},a}function He(){var e={},n=0,t=0,r={};return e.summarizeEvent=function(e){if("feature"===e.kind){var i=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),o=r[i];o?o.count=o.count+1:r[i]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>t&&(t=e.creationDate)}},e.getSummary=function(){var e={},i=!0;for(var o in r){var a=r[o],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),i=!1}return i?null:{startDate:n,endDate:t,features:e}},e.clearSummary=function(){n=0,t=0,r={}},e}function Ge(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],i={key:!0,custom:!0,anonymous:!0},o={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,o){return Object.keys(e).reduce((function(a,u){var s=a;return o(u)&&(!function(e){return!i[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[0][u]=e[u]:s[1][u]=!0),s}),[{},{}])},u=a(e,(function(e){return o[e]})),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,(function(){return!0}));s.custom=l[0],c=q({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function We(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var i=0;i<t[e].length;i++)t[e][i].handler===n&&t[e][i].context===r&&(t[e]=t[e].slice(0,i).concat(t[e].slice(i+1)))},n.emit=function(e){if(t[e])for(var n=t[e].slice(0),r=0;r<n.length;r++)n[r].handler.apply(n[r].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t["error"]?this.emit("error",n):(e||console).error(n.message))},n}var Xe=function(e){var n=!1,t=!1,r=null,i=null,o=new Promise((function(n){e.on("ready",(function t(){e.off("ready",t),n()}))})).catch((function(){}));return{getInitializationPromise:function(){return i||(n?Promise.resolve():t?Promise.reject(r):i=new Promise((function(n,t){e.on("initialized",(function t(){e.off("initialized",t),n()})),e.on("failed",(function n(r){e.off("failed",n),t(r)}))})))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,e.emit("initialized"),e.emit("ready"))},signalFailure:function(i){n||t||(t=!0,r=i,e.emit("failed",i),e.emit("ready")),e.maybeReportError(i)}}};function Qe(e,n,t,r){var i={};function o(){var e="",i=r.getUser();return i&&(e=t||I(JSON.stringify(i))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(o()).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=C(n):delete n.$schema}return n}catch(e){return i.clearFlags().then((function(){return null}))}}))},i.saveFlags=function(n){var t=q({},n,{$schema:1});return e.set(o(),JSON.stringify(t))},i.clearFlags=function(){return e.clear(o())},i}function Ye(e,n,t,r){var i,o=n.streamUrl,a=n.logger,u={},s=U(o,"/eval/"+t),c=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,v=Ke(e,n),d=!1,g=null,p=null,m=null,y=null,h=null;function b(e){d||(a.warn(De(e,f)),d=!0),D(!1),w(),k(f)}function k(e){p||(e?p=setTimeout(E,e):E())}function E(){var r;p=null;var u="",f={headers:v,readTimeoutMillis:3e5};if(e.eventSourceFactory){for(var d in null!=y&&(u="h="+y),c?e.eventSourceAllowsReport?(r=s,f.method="REPORT",f.headers["Content-Type"]="application/json",f.body=JSON.stringify(m)):(r=U(o,"/ping/"+t),u=""):r=s+"/"+j(JSON.stringify(m)),f.headers=$e(f.headers,n),l&&(u=u+(u?"&":"")+"withReasons=true"),r=r+(u?"?":"")+u,w(),a.info(we(r)),i=(new Date).getTime(),g=e.eventSourceFactory(r,f),h)V(h,d)&&g.addEventListener(d,h[d]);g.onerror=b}}function w(){g&&(a.info("Closing stream connection"),g.close(),g=null)}function D(e){i&&r&&r.recordStreamInit(i,!e,(new Date).getTime()-i),i=null}return u.connect=function(e,n,t){m=e,y=n,h={};var r=function(e){h[e]=function(n){d=!1,D(!0),t[e]&&t[e](n)}};for(var i in t||{})r(i);k()},u.disconnect=function(){clearTimeout(p),p=null,w()},u.isConnected=function(){return!!(g&&e.eventSourceIsActive&&e.eventSourceIsActive(g))},u}function Ze(e,n,t){var r=n.baseUrl,i=n.useReport,o=n.evaluationReasons,a=n.logger,u={},c={};function l(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new v(be()))}));var i=r?"REPORT":"GET",o=Ke(e,n);r&&(o["Content-Type"]="application/json");var a=c[t];a||(a=function(e){var n,t,r,i,o={addPromise:function(o,a){n=o,t&&t(),t=a,o.then((function(t){n===o&&(r(t),e&&e())}),(function(t){n===o&&(i(t),e&&e())}))}};return o.resultPromise=new Promise((function(e,n){r=e,i=n})),o}((function(){delete c[t]})),c[t]=a);var u=e.httpRequest(i,t,$e(o,n),r),l=u.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n=oe(e.header("content-type")||"");return Promise.reject(new v(n))}return Promise.reject(function(e){return 404===e.status?new s(ce()):new v(fe(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new v(ue(e)))}));return a.addPromise(l,(function(){u.cancel&&u.cancel()})),a.resultPromise}return u.fetchJSON=function(e){return l(U(r,e),null)},u.fetchFlagSettings=function(e,n){var u,s,c,f="";return i?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(u=j(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",u].join("")),n&&(f="h="+n),o&&(f=f+(f?"&":"")+"withReasons=true"),s=s+(f?"?":"")+f,a.debug(Ie(s)),l(s,c)},u}function en(e){var n={};return n.validateUser=function(n){if(!n)return Promise.reject(new c(ve()));var t=T(n);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?e.get("ld:$anonUserId").then((function(n){if(n)return t.key=n,t;var r=X();return t.key=r,function(n){return e.set("ld:$anonUserId",n)}(r).then((function(){return t}))})):Promise.reject(new c(de()))},n}var nn=Object.freeze({__proto__:null,baseOptionDefs:Ve,validate:Je,getTags:Me}).baseOptionDefs,tn=z.appendUrlPath;var rn=function(e){var n={diagnosticId:X()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n},on=function(e){var n,t,r,i;function o(e){n=e,t=0,r=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},an=function(e,t,r,i,o,a,u){var s,c,l=!!e.diagnosticUseCombinedEvent,f="ld:"+o+":$diagnostics",v=tn(a.eventsUrl,"/events/diagnostic/"+o),d=a.diagnosticRecordingInterval,g=r,p=!!a.streaming,m={};function y(){return{sdk:k(),configuration:(n={customBaseURI:a.baseUrl!==nn.baseUrl.default,customStreamURI:a.streamUrl!==nn.streamUrl.default,customEventsURI:a.eventsUrl!==nn.eventsUrl.default,eventsCapacity:a.eventCapacity,eventsFlushIntervalMillis:a.flushInterval,reconnectTimeMillis:a.streamReconnectDelay,streamingDisabled:!p,allAttributesPrivate:!!a.allAttributesPrivate,inlineUsersInEvents:!!a.inlineUsersInEvents,diagnosticRecordingIntervalMillis:a.diagnosticRecordingInterval,usingSecureMode:!!a.hash,bootstrapMode:!!a.bootstrap,fetchGoalsDisabled:!a.fetchGoals,allowFrequentDuplicateEvents:!!a.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!a.sendEventsOnlyForVariation,autoAliasingOptOut:!!a.autoAliasingOptOut},n),platform:e.diagnosticPlatformData};var n}function h(e){a.logger&&a.logger.debug(qe.debugPostingDiagnosticEvent(e)),i.sendEvents(e,v,!0).then((function(){})).catch((function(){}))}function b(){var e,r;h((e=(new Date).getTime(),r=n({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:e},g.getProps()),l&&(r=n(n({},r),y())),g.reset(e),r)),c=setTimeout(b,d),s=(new Date).getTime(),l&&function(){if(t.isEnabled()){var e=n({},g.getProps());t.set(f,JSON.stringify(e))}}()}function k(){var t=n({},e.diagnosticSdkData);return a.wrapperName&&(t.wrapperName=a.wrapperName),a.wrapperVersion&&(t.wrapperVersion=a.wrapperVersion),t}return m.start=function(){l?function(e){if(!t.isEnabled())return e(!1);t.get(f).then((function(n){if(n)try{var t=JSON.parse(n);g.setProps(t),s=t.dataSinceDate}catch(e){}e(!0)})).catch((function(){e(!1)}))}((function(e){if(e){var n=(s||0)+d,t=(new Date).getTime();t>=n?b():c=setTimeout(b,n-t)}else 0===Math.floor(4*Math.random())?b():c=setTimeout(b,d)})):(h(n({kind:"diagnostic-init",id:u,creationDate:g.getProps().dataSinceDate},y())),c=setTimeout(b,d))},m.stop=function(){c&&clearTimeout(c)},m.setStreaming=function(e){p=e},m};function un(e,r,i,o,a){var c,f,p,m=function(){if(i&&i.logger)return i.logger;return a&&a.logger&&a.logger.default||Z("warn")}(),y=We(m),h=Xe(y),b=Je(i,y,a,m),k=b.sendEvents,E=e,w=b.hash,D=function(e,n){var t={},r=!1,i=function(e){r||(r=!0,n.warn(ae(e)))};return t.isEnabled=function(){return!!e},t.get=function(n){return new Promise((function(t){e?e.get(n).then(t).catch((function(e){i(e),t(void 0)})):t(void 0)}))},t.set=function(n,t){return new Promise((function(r){e?e.set(n,t).then((function(){return r(!0)})).catch((function(e){i(e),r(!1)})):r(!1)}))},t.clear=function(n){return new Promise((function(t){e?e.clear(n).then((function(){return t(!0)})).catch((function(e){i(e),t(!1)})):t(!1)}))},t}(o.localStorage,m),O=Be(o,E,b),S=b.sendEvents&&!b.diagnosticOptOut,P=S?rn(E):null,I=S?on((new Date).getTime()):null,j=S?an(o,D,I,O,E,b,P):null,C=Ye(o,b,E,I),N=b.eventProcessor||function(e,n,t){var r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=a||Be(e,t,n),l=U(n.eventsUrl,"/events/bulk/"+t),f=He(),v=Ge(n),d=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,y=n.flushInterval,h=n.logger,b=[],k=0,E=!1,w=!1;function D(){return 0===p||0===Math.floor(Math.random()*p)}function O(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}function S(e){var n=q({},e);return"alias"===e.kind||(d||"identify"===e.kind?n.user=v.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}function P(e){b.length<m?(b.push(e),w=!1):(w||(w=!0,h.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),i&&i.incrementDroppedEvents())}return s.enqueue=function(e){if(!E){var n=!1,t=!1;if(f.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=O(e)):n=D(),n&&P(S(e)),t){var r=q({},e,{kind:"debug"});r.user=v.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,P(r)}}},s.flush=function(){if(E)return Promise.resolve();var e=b,n=f.getSummary();return f.clearSummary(),n&&(n.kind="summary",e.push(n)),i&&i.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],h.debug(Ne(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(k=e.serverTime),g(e.status)||(E=!0),e.status>=400&&A((function(){o.maybeReportError(new u(he(e.status,"event posting","some events were dropped")))})))})))},s.start=function(){r=setTimeout((function e(){s.flush(),r=setTimeout(e,y)}),y)},s.stop=function(){clearTimeout(r)},s}(o,b,E,I,y,O),x=Ze(o,b,E),z={},J={},M=b.streaming,K=!1,$=!1,B=!0,H=b.stateProvider,G=function(e,n){var t,r={};return r.setUser=function(e){var r=t&&T(t);(t=_(e))&&n&&n(T(t),r)},r.getUser=function(){return t?T(t):null},e&&r.setUser(e),r}(null,(function(e,n){(function(e){if(H)return;e&&Q({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!b.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&re(e,n)})),W=en(D),X=D.isEnabled()?new Qe(D,E,w,G,m):null;function Q(e){if(E&&!(H&&H.enqueueEvent&&H.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(B&&(m.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),B=!1));B=!1}!k||$||o.isDoNotTrack()||(m.debug(Fe(e.kind)),N.enqueue(e))}}function Y(e,n,t,r){var i=G.getUser(),o=new Date,a=n?n.value:null;if(!b.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=z[u];if(s&&o-s<3e5)return;z[u]=o}var c={kind:"feature",key:e,user:i,value:a,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()};i&&i.anonymous&&(c.contextKind=te(i));var l=J[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),Q(c)}function ee(e,n,t,r){var i;if(J&&V(J,e)&&J[e]&&!J[e].deleted){var o=J[e];i=ne(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&Y(e,i,n,r),i}function ne(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function te(e){return e.anonymous?"anonymousUser":"user"}function re(e,n){H||e&&n&&Q({kind:"alias",key:e.key,contextKind:te(e),previousKey:n.key,previousContextKind:te(n),creationDate:(new Date).getTime()})}function ie(){if(f=!0,G.getUser()){var e=function(e){try{return JSON.parse(e)}catch(e){return void y.maybeReportError(new d("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};C.connect(G.getUser(),w,{ping:function(){m.debug("received ping message from stream");var e=G.getUser();x.fetchFlagSettings(e,w).then((function(n){R(e,G.getUser())&&ue(n||{})})).catch((function(e){y.maybeReportError(new v(fe(e)))}))},put:function(n){var t=e(n.data);t&&(m.debug("received streaming update for all flags"),ue(t))},patch:function(n){var t=e(n.data);if(t){var r=J[t.key];if(!r||!r.version||!t.version||r.version<t.version){m.debug(Re(t.key));var i={},o=q({},t);delete o.key,J[t.key]=o;var a=ne(o);i[t.key]=r?{previous:r.value,current:a}:{current:a},ce(i)}else m.debug(Ae(t.key))}},delete:function(n){var t=e(n.data);if(t)if(!J[t.key]||J[t.key].version<t.version){m.debug(Le(t.key));var r={};J[t.key]&&!J[t.key].deleted&&(r[t.key]={previous:J[t.key].value}),J[t.key]={version:t.version,deleted:!0},ce(r)}else m.debug(Ce(t.key))}})}}function oe(){f&&(C.disconnect(),f=!1)}function ue(e){var t={};if(!e)return Promise.resolve();for(var r in J)V(J,r)&&J[r]&&(e[r]&&!R(e[r].value,J[r].value)?t[r]={previous:J[r].value,current:ne(e[r])}:e[r]&&!e[r].deleted||(t[r]={previous:J[r].value}));for(var i in e)V(e,i)&&e[i]&&(!J[i]||J[i].deleted)&&(t[i]={current:ne(e[i])});return J=n({},e),ce(t).catch((function(){}))}function ce(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,i=r?r.value:void 0,o=e[n].previous;y.emit("change:"+n,i,o),t[n]=r?{current:i,previous:o}:{previous:o}})),y.emit("change",t),y.emit("internal-change",J),b.sendEventsOnlyForVariation||H||n.forEach((function(n){Y(n,e[n].current)}))}return c&&X?X.saveFlags(J):Promise.resolve()}function ve(){var e=M||p&&void 0===M;e&&!f?ie():!e&&f&&oe(),j&&j.setStreaming(e)}function de(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof b.bootstrap&&"LOCALSTORAGE"===b.bootstrap.toUpperCase()&&(X?c=!0:m.warn(ae())),"object"===t(b.bootstrap)&&(J=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&m.warn(pe()),!1===e.$valid&&m.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var i={value:e[n]};t&&t[n]?i=q(i,t[n]):i.version=0,r[n]=i}})),r}(b.bootstrap)),H){var ge=H.getInitialState();ge?me(ge):H.on("init",me),H.on("update",(function(e){e.user&&G.setUser(e.user);e.flags&&ue(e.flags)}))}else(function(){if(!e)return Promise.reject(new s(le()));return W.validateUser(r).then((function(e){return G.setUser(e),"object"===t(b.bootstrap)?ye():c?X.loadFlags().then((function(e){return null==e?(J={},x.fetchFlagSettings(G.getUser(),w).then((function(e){return ue(e||{})})).then(ye).catch((function(e){be(new v(fe(e)))}))):(J=e,A(ye),x.fetchFlagSettings(G.getUser(),w).then((function(e){return ue(e)})).catch((function(e){return y.maybeReportError(e)})))})):x.fetchFlagSettings(G.getUser(),w).then((function(e){J=e||{},ye()})).catch((function(e){J={},be(e)}))}))})().catch(be);function me(e){E=e.environment,G.setUser(e.user),J=n({},e.flags),A(ye)}function ye(){m.info("LaunchDarkly client initialized"),K=!0,ve(),h.signalSuccess()}function be(e){h.signalFailure(e)}return{client:{waitForInitialization:function(){return h.getInitializationPromise()},waitUntilReady:function(){return h.getReadyPromise()},identify:function(e,n,t){return $?L(Promise.resolve({}),t):H?(m.warn("identify() has no effect here; it must be called on the main client instance"),L(Promise.resolve(F(J)),t)):L((c&&X?X.clearFlags():Promise.resolve()).then((function(){return W.validateUser(e)})).then((function(e){return x.fetchFlagSettings(e,n).then((function(t){var r=F(t);return G.setUser(e),w=n,t?ue(t).then((function(){return r})):r}))})).then((function(e){return f&&ie(),e})).catch((function(e){return y.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return G.getUser()},variation:function(e,n){return ee(e,n,!0,!1).value},variationDetail:function(e,n){return ee(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&m.warn(se(e));var r=G.getUser(),i={kind:"custom",key:e,user:r,url:o.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(i.contextKind=te(r)),null!=n&&(i.data=n),null!=t&&(i.metricValue=t),Q(i)}else y.maybeReportError(new l(se(e)))},alias:re,on:function(e,n,t){de(e)?(p=!0,K&&ve(),y.on(e,n,t)):y.on.apply(y,arguments)},off:function(e){if(y.off.apply(y,arguments),de(e)){var n=!1;y.getEvents().forEach((function(e){de(e)&&y.getEventListenerCount(e)>0&&(n=!0)})),n||(p=!1,f&&void 0===M&&oe())}},setStreaming:function(e){var n=null===e?void 0:e;n!==M&&(M=n,ve())},flush:function(e){return L(k?N.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!J)return e;for(var n in J)V(J,n)&&(e[n]=ee(n,null,!b.sendEventsOnlyForVariation).value);return e},close:function(e){if($)return L(Promise.resolve(),e);var n=function(){$=!0,J={}};return L(Promise.resolve().then((function(){if(oe(),j&&j.stop(),k)return N.stop(),N.flush()})).then(n).catch(n),e)}},options:b,emitter:y,ident:G,logger:m,requestor:x,start:function(){k&&(j&&j.start(),N.start())},enqueueEvent:Q,getFlagsInternal:function(){return J},getEnvironmentId:function(){return E},internalChangeEventName:"internal-change"}}var sn="3.6.0";export{Y as commonBasicLogger,Z as createConsoleLogger,p as errors,un as initialize,qe as messages,z as utils,sn as version}; | ||
function e(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function n(n){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?e(Object(i),!0).forEach((function(e){r(n,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}))}return n}function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(!e)return;if("string"==typeof e)return o(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return o(e,n)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function a(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 u=a("LaunchDarklyUnexpectedResponseError"),s=a("LaunchDarklyInvalidEnvironmentIdError"),c=a("LaunchDarklyInvalidUserError"),l=a("LaunchDarklyInvalidEventKeyError"),f=a("LaunchDarklyInvalidArgumentError"),v=a("LaunchDarklyFlagFetchError"),d=a("LaunchDarklyInvalidDataError");function g(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var p=Object.freeze({__proto__:null,LDUnexpectedResponseError:u,LDInvalidEnvironmentIdError:s,LDInvalidUserError:c,LDInvalidEventKeyError:l,LDInvalidArgumentError:f,LDFlagFetchError:v,LDInvalidDataError:d,isHttpErrorRecoverable:g}),m=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(w(e,o,o+16383>a?a:o+16383));1===r?(n=e[t-1],i.push(y[n>>2]+y[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],i.push(y[n>>10]+y[n>>4&63]+y[n<<2&63]+"="));return i.join("")},y=[],h=[],b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k=0,E=b.length;k<E;++k)y[k]=b[k],h[b.charCodeAt(k)]=k;function w(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(y[(i=r)>>18&63]+y[i>>12&63]+y[i>>6&63]+y[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63;var D=Array.isArray,O=Object.keys,P=Object.prototype.hasOwnProperty,S=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function U(e,n){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(n.startsWith("/")?"":"/")+n}function I(e){var n=unescape(encodeURIComponent(e));return m(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function j(e){return I(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function T(e){return JSON.parse(JSON.stringify(e))}function R(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=D(n),u=D(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=O(n);if((i=v.length)!==O(t).length)return!1;for(r=i;0!=r--;)if(!P.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t}(e,n)}function A(e){setTimeout(e,0)}function L(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 C(e){var n={};for(var t in e)q(e,t)&&(n[t]={value:e[t],version:0});return n}function N(e){var n={};for(var t in e)q(e,t)&&(n[t]=e[t].value);return n}function F(e,n){for(var t,r=n.slice(0),i=[],o=e;r.length>0;){for(t=[];o>0;){var a=r.shift();if(!a)break;(o-=j(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function x(e){var n=e.version||"3.7.0";return e.userAgent+"/"+n}function V(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.reduce((function(e,t){return n(n({},e),t)}),{})}function q(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function _(e){if(!e)return e;var t;for(var r in S){var i=S[r],o=e[i];void 0!==o&&"string"!=typeof o&&((t=t||n({},e))[i]=String(o))}return t||e}var z=Object.freeze({__proto__:null,appendUrlPath:U,btoa:I,base64URLEncode:j,clone:T,deepEquals:R,onNextTick:A,wrapPromiseCallback:L,transformValuesToVersionedValues:C,transformVersionedValuesToValues:N,chunkUserEventsForUrl:F,getLDUserAgentString:x,extend:V,objectHasOwnProperty:q,sanitizeUser:_});for(var J=function(e,n){return e(n={exports:{}},n.exports),n.exports}((function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}})),M=[],K=0;K<256;++K)M[K]=(K+256).toString(16).substr(1);var $,B,H=function(e,n){var t=n||0,r=M;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("")},G=0,W=0;var X=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||$,a=void 0!==e.clockseq?e.clockseq:B;if(null==o||null==a){var u=J();null==o&&(o=$=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=B=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:W+1,l=s-G+(c-W)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>G)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");G=s,W=c,B=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var v=s/4294967296*1e4&268435455;i[r++]=v>>>8&255,i[r++]=255&v,i[r++]=v>>>24&15|16,i[r++]=v>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var d=0;d<6;++d)i[r+d]=o[d];return n||H(i)},Q=["debug","info","warn","error","none"];function Y(e,n){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function t(e){return function(n){console&&console[e]&&console[e].call(console,n)}}var r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[t("log"),t("info"),t("warn"),t("error")],o=!(!e||!e.destination),a=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",u=1;if(e&&e.level)for(var s=0;s<Q.length;s++)Q[s]===e.level&&(u=s);function c(e,t,u){if(!(u.length<1)){var s,c=o?t+": "+a:a;if(1!==u.length&&n){var l=i(u);l[0]=c+l[0],s=n.apply(void 0,i(l))}else s=c+u[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+t+" method threw an exception: "+e)}}}for(var l={},f=function(e){var n=Q[e];if("none"!==n)if(e<u)l[n]=function(){};else{var t=e;l[n]=function(){c(t,n,arguments)}}},v=0;v<Q.length;v++)f(v);return l}function Z(e,n){return Y({level:e,prefix:n})}function ee(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var ne=function(){return"LaunchDarkly client initialized"},te=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",re=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},ie=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},oe=function(e){return'Expected application/json content type but got "'+e+'"'},ae=function(e){return"local storage is unavailable: "+ee(e)},ue=function(e){return"network error"+(e?" ("+e+")":"")},se=function(e){return'Custom event "'+e+'" does not exist'},ce=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+te},le=function(){return"No environment/client-side ID was specified."+te},fe=function(e){return"Error fetching flag settings: "+ee(e)},ve=function(){return"No user specified."+te},de=function(){return"Invalid user specified."+te},ge=function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},pe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+te},me=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},ye=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},he=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(g(e)?t:"giving up permanently")},be=function(){return"Cannot make HTTP requests in this environment."+te},ke=function(){return"identify() has no effect here; it must be called on the main client instance"},Ee=function(){return"Closing stream connection"},we=function(e){return"Opening stream connection to "+e},De=function(e,n){return"Error on stream connection: "+ee(e)+", will continue retrying every "+n+" milliseconds."},Oe=function(e){return'Ignoring unknown config option "'+e+'"'},Pe=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Se=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Ue=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Ie=function(e){return"polling for feature flags at "+e},je=function(){return"received ping message from stream"},Te=function(){return"received streaming update for all flags"},Re=function(e){return'received streaming update for flag "'+e+'"'},Ae=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Le=function(e){return'received streaming deletion for flag "'+e+'"'},Ce=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Ne=function(e){return'enqueueing "'+e+'" event'},Fe=function(e){return"sending "+e+" events"},xe=function(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')},Ve=Object.freeze({__proto__:null,clientInitialized:ne,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:re,eventWithoutUser:ie,invalidContentType:oe,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ae,networkError:ue,unknownCustomEventKey:se,environmentNotFound:ce,environmentNotSpecified:le,errorFetchingFlags:fe,userNotSpecified:ve,invalidUser:de,invalidData:ge,bootstrapOldFormat:pe,bootstrapInvalid:me,deprecated:ye,httpErrorMessage:he,httpUnavailable:be,identifyDisabled:ke,streamClosing:Ee,streamConnecting:we,streamError:De,unknownOption:Oe,wrongOptionType:Pe,wrongOptionTypeBoolean:Se,optionBelowMinimum:Ue,debugPolling:Ie,debugStreamPing:je,debugStreamPut:Te,debugStreamPatch:Re,debugStreamPatchIgnored:Ae,debugStreamDelete:Le,debugStreamDeleteIgnored:Ce,debugEnqueueingEvent:Ne,debugPostingEvents:Fe,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},invalidTagValue:xe}),qe={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:function(e,n,t,r){var i={};t.id&&(i.id=ze("".concat(e,".id"),n,t.id,r));t.version&&(i.version=ze("".concat(e,".version"),n,t.version,r));return i}}},_e=/^(\w|\.|-)+$/;function ze(e,n,t,r){if("string"==typeof t&&t.match(_e))return t;r.warn(xe(e))}function Je(e,n,r,i){var o=V({logger:{default:i}},qe,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null,allowFrequentDuplicateEvents:void 0};function u(e){A((function(){n&&n.maybeReportError(new f(e))}))}var s=V({},e||{});return function(e){var n=e;Object.keys(a).forEach((function(e){if(void 0!==n[e]){var t=a[e];i&&i.warn(ye(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),function(e){Q.forEach((function(n){if("none"!==n&&(!e[n]||"function"!=typeof e[n]))throw new Error("Provided logger instance must support logger."+n+"(...) method")}))}((s=function(e){var n=V({},e),r=function(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=t(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}};return Object.keys(e).forEach((function(t){var a=e[t];if(null!=a){var s=o[t];if(void 0===s)u(Oe(t));else{var c=s.type||r(s.default),l=s.validator;if(l){var f=l(t,e,e[t],i);void 0!==f?n[t]=f:delete n[t]}else if("any"!==c){var v=c.split("|"),d=r(a);v.indexOf(d)<0?"boolean"===c?(n[t]=!!a,u(Se(t,d))):(u(Pe(t,c,d)),n[t]=s.default):"number"===d&&void 0!==s.minimum&&a<s.minimum&&(u(Ue(t,a,s.minimum)),n[t]=s.minimum)}}}})),n}(s=function(e){var n=V({},e);return Object.keys(o).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=o[e]&&o[e].default)})),n}(s))).logger),s}function Me(e){var n={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(n["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(n["application-version"]=[e.application.version])),n}function Ke(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":x(e)};n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName);var r=Me(n),i=Object.keys(r);return i.length&&(t["x-launchdarkly-tags"]=i.sort().flatMap((function(e){return Array.isArray(r[e])?r[e].sort().map((function(n){return"".concat(e,"/").concat(n)})):["".concat(e,"/").concat(r[e])]})).join(" ")),t}function $e(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform(n({},e)):e}function Be(e,n,t){var r="/a/"+n+".gif",i=V({"Content-Type":"application/json"},Ke(e,t)),o=e.httpFallbackPing,a={};return a.sendChunk=function(n,a,u,s){var c=JSON.stringify(n),l=u?null:X();return s?function n(r){var o=u?i:V({},i,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":l});return e.httpRequest("POST",a,$e(o,t),c).promise.then((function(e){if(e)return e.status>=400&&g(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(o&&o(a+r+"?d="+j(c)),Promise.resolve())},a.sendEvents=function(n,t,r){if(!e.httpRequest)return Promise.resolve();var i,o=e.httpAllowsPost();i=o?[n]:F(2e3-t.length,n);for(var u=[],s=0;s<i.length;s++)u.push(a.sendChunk(i[s],t,r,o));return Promise.all(u)},a}function He(){var e={},n=0,t=0,r={};return e.summarizeEvent=function(e){if("feature"===e.kind){var i=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),o=r[i];o?o.count=o.count+1:r[i]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>t&&(t=e.creationDate)}},e.getSummary=function(){var e={},i=!0;for(var o in r){var a=r[o],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),i=!1}return i?null:{startDate:n,endDate:t,features:e}},e.clearSummary=function(){n=0,t=0,r={}},e}function Ge(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],i={key:!0,custom:!0,anonymous:!0},o={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,o){return Object.keys(e).reduce((function(a,u){var s=a;return o(u)&&(!function(e){return!i[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[0][u]=e[u]:s[1][u]=!0),s}),[{},{}])},u=a(e,(function(e){return o[e]})),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,(function(){return!0}));s.custom=l[0],c=V({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function We(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var i=0;i<t[e].length;i++)t[e][i].handler===n&&t[e][i].context===r&&(t[e]=t[e].slice(0,i).concat(t[e].slice(i+1)))},n.emit=function(e){if(t[e])for(var n=t[e].slice(0),r=0;r<n.length;r++)n[r].handler.apply(n[r].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t["error"]?this.emit("error",n):(e||console).error(n.message))},n}var Xe=function(e){var n=!1,t=!1,r=null,i=null,o=new Promise((function(n){e.on("ready",(function t(){e.off("ready",t),n()}))})).catch((function(){}));return{getInitializationPromise:function(){return i||(n?Promise.resolve():t?Promise.reject(r):i=new Promise((function(n,t){e.on("initialized",(function t(){e.off("initialized",t),n()})),e.on("failed",(function n(r){e.off("failed",n),t(r)}))})))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,e.emit("initialized"),e.emit("ready"))},signalFailure:function(i){n||t||(t=!0,r=i,e.emit("failed",i),e.emit("ready")),e.maybeReportError(i)}}};function Qe(e,n,t,r){var i={};function o(){var e="",i=r.getUser();return i&&(e=t||I(JSON.stringify(i))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(o()).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=C(n):delete n.$schema}return n}catch(e){return i.clearFlags().then((function(){return null}))}}))},i.saveFlags=function(n){var t=V({},n,{$schema:1});return e.set(o(),JSON.stringify(t))},i.clearFlags=function(){return e.clear(o())},i}function Ye(e,n,t,r){var i,o=n.streamUrl,a=n.logger,u={},s=U(o,"/eval/"+t),c=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,v=Ke(e,n),d=!1,g=null,p=null,m=null,y=null,h=null;function b(e){d||(a.warn(De(e,f)),d=!0),D(!1),w(),k(f)}function k(e){p||(e?p=setTimeout(E,e):E())}function E(){var r;p=null;var u="",f={headers:v,readTimeoutMillis:3e5};if(e.eventSourceFactory){for(var d in null!=y&&(u="h="+y),c?e.eventSourceAllowsReport?(r=s,f.method="REPORT",f.headers["Content-Type"]="application/json",f.body=JSON.stringify(m)):(r=U(o,"/ping/"+t),u=""):r=s+"/"+j(JSON.stringify(m)),f.headers=$e(f.headers,n),l&&(u=u+(u?"&":"")+"withReasons=true"),r=r+(u?"?":"")+u,w(),a.info(we(r)),i=(new Date).getTime(),g=e.eventSourceFactory(r,f),h)q(h,d)&&g.addEventListener(d,h[d]);g.onerror=b}}function w(){g&&(a.info("Closing stream connection"),g.close(),g=null)}function D(e){i&&r&&r.recordStreamInit(i,!e,(new Date).getTime()-i),i=null}return u.connect=function(e,n,t){m=e,y=n,h={};var r=function(e){h[e]=function(n){d=!1,D(!0),t[e]&&t[e](n)}};for(var i in t||{})r(i);k()},u.disconnect=function(){clearTimeout(p),p=null,w()},u.isConnected=function(){return!!(g&&e.eventSourceIsActive&&e.eventSourceIsActive(g))},u}function Ze(e,n,t){var r=n.baseUrl,i=n.useReport,o=n.evaluationReasons,a=n.logger,u={},c={};function l(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new v(be()))}));var i=r?"REPORT":"GET",o=Ke(e,n);r&&(o["Content-Type"]="application/json");var a=c[t];a||(a=function(e){var n,t,r,i,o={addPromise:function(o,a){n=o,t&&t(),t=a,o.then((function(t){n===o&&(r(t),e&&e())}),(function(t){n===o&&(i(t),e&&e())}))}};return o.resultPromise=new Promise((function(e,n){r=e,i=n})),o}((function(){delete c[t]})),c[t]=a);var u=e.httpRequest(i,t,$e(o,n),r),l=u.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n=oe(e.header("content-type")||"");return Promise.reject(new v(n))}return Promise.reject(function(e){return 404===e.status?new s(ce()):new v(fe(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new v(ue(e)))}));return a.addPromise(l,(function(){u.cancel&&u.cancel()})),a.resultPromise}return u.fetchJSON=function(e){return l(U(r,e),null)},u.fetchFlagSettings=function(e,n){var u,s,c,f="";return i?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(u=j(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",u].join("")),n&&(f="h="+n),o&&(f=f+(f?"&":"")+"withReasons=true"),s=s+(f?"?":"")+f,a.debug(Ie(s)),l(s,c)},u}function en(e){var n={};return n.validateUser=function(n){if(!n)return Promise.reject(new c(ve()));var t=T(n);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?e.get("ld:$anonUserId").then((function(n){if(n)return t.key=n,t;var r=X();return t.key=r,function(n){return e.set("ld:$anonUserId",n)}(r).then((function(){return t}))})):Promise.reject(new c(de()))},n}var nn=Object.freeze({__proto__:null,baseOptionDefs:qe,validate:Je,getTags:Me}).baseOptionDefs,tn=z.appendUrlPath;var rn=function(e){var n={diagnosticId:X()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n},on=function(e){var n,t,r,i;function o(e){n=e,t=0,r=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},an=function(e,t,r,i,o,a,u){var s,c,l=!!e.diagnosticUseCombinedEvent,f="ld:"+o+":$diagnostics",v=tn(a.eventsUrl,"/events/diagnostic/"+o),d=a.diagnosticRecordingInterval,g=r,p=!!a.streaming,m={};function y(){return{sdk:k(),configuration:(n={customBaseURI:a.baseUrl!==nn.baseUrl.default,customStreamURI:a.streamUrl!==nn.streamUrl.default,customEventsURI:a.eventsUrl!==nn.eventsUrl.default,eventsCapacity:a.eventCapacity,eventsFlushIntervalMillis:a.flushInterval,reconnectTimeMillis:a.streamReconnectDelay,streamingDisabled:!p,allAttributesPrivate:!!a.allAttributesPrivate,inlineUsersInEvents:!!a.inlineUsersInEvents,diagnosticRecordingIntervalMillis:a.diagnosticRecordingInterval,usingSecureMode:!!a.hash,bootstrapMode:!!a.bootstrap,fetchGoalsDisabled:!a.fetchGoals,sendEventsOnlyForVariation:!!a.sendEventsOnlyForVariation,autoAliasingOptOut:!!a.autoAliasingOptOut},n),platform:e.diagnosticPlatformData};var n}function h(e){a.logger&&a.logger.debug(Ve.debugPostingDiagnosticEvent(e)),i.sendEvents(e,v,!0).then((function(){})).catch((function(){}))}function b(){var e,r;h((e=(new Date).getTime(),r=n({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:e},g.getProps()),l&&(r=n(n({},r),y())),g.reset(e),r)),c=setTimeout(b,d),s=(new Date).getTime(),l&&function(){if(t.isEnabled()){var e=n({},g.getProps());t.set(f,JSON.stringify(e))}}()}function k(){var t=n({},e.diagnosticSdkData);return a.wrapperName&&(t.wrapperName=a.wrapperName),a.wrapperVersion&&(t.wrapperVersion=a.wrapperVersion),t}return m.start=function(){l?function(e){if(!t.isEnabled())return e(!1);t.get(f).then((function(n){if(n)try{var t=JSON.parse(n);g.setProps(t),s=t.dataSinceDate}catch(e){}e(!0)})).catch((function(){e(!1)}))}((function(e){if(e){var n=(s||0)+d,t=(new Date).getTime();t>=n?b():c=setTimeout(b,n-t)}else 0===Math.floor(4*Math.random())?b():c=setTimeout(b,d)})):(h(n({kind:"diagnostic-init",id:u,creationDate:g.getProps().dataSinceDate},y())),c=setTimeout(b,d))},m.stop=function(){c&&clearTimeout(c)},m.setStreaming=function(e){p=e},m};function un(e,r,i,o,a){var c,f,p,m=function(){if(i&&i.logger)return i.logger;return a&&a.logger&&a.logger.default||Z("warn")}(),y=We(m),h=Xe(y),b=Je(i,y,a,m),k=b.sendEvents,E=e,w=b.hash,D=function(e,n){var t={},r=!1,i=function(e){r||(r=!0,n.warn(ae(e)))};return t.isEnabled=function(){return!!e},t.get=function(n){return new Promise((function(t){e?e.get(n).then(t).catch((function(e){i(e),t(void 0)})):t(void 0)}))},t.set=function(n,t){return new Promise((function(r){e?e.set(n,t).then((function(){return r(!0)})).catch((function(e){i(e),r(!1)})):r(!1)}))},t.clear=function(n){return new Promise((function(t){e?e.clear(n).then((function(){return t(!0)})).catch((function(e){i(e),t(!1)})):t(!1)}))},t}(o.localStorage,m),O=Be(o,E,b),P=b.sendEvents&&!b.diagnosticOptOut,S=P?rn(E):null,I=P?on((new Date).getTime()):null,j=P?an(o,D,I,O,E,b,S):null,C=Ye(o,b,E,I),F=b.eventProcessor||function(e,n,t){var r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=a||Be(e,t,n),l=U(n.eventsUrl,"/events/bulk/"+t),f=He(),v=Ge(n),d=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,y=n.flushInterval,h=n.logger,b=[],k=0,E=!1,w=!1;function D(){return 0===p||0===Math.floor(Math.random()*p)}function O(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}function P(e){var n=V({},e);return"alias"===e.kind||(d||"identify"===e.kind?n.user=v.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}function S(e){b.length<m?(b.push(e),w=!1):(w||(w=!0,h.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),i&&i.incrementDroppedEvents())}return s.enqueue=function(e){if(!E){var n=!1,t=!1;if(f.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=O(e)):n=D(),n&&S(P(e)),t){var r=V({},e,{kind:"debug"});r.user=v.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,S(r)}}},s.flush=function(){if(E)return Promise.resolve();var e=b,n=f.getSummary();return f.clearSummary(),n&&(n.kind="summary",e.push(n)),i&&i.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],h.debug(Fe(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(k=e.serverTime),g(e.status)||(E=!0),e.status>=400&&A((function(){o.maybeReportError(new u(he(e.status,"event posting","some events were dropped")))})))})))},s.start=function(){r=setTimeout((function e(){s.flush(),r=setTimeout(e,y)}),y)},s.stop=function(){clearTimeout(r)},s}(o,b,E,I,y,O),x=Ze(o,b,E),z={},J=b.streaming,M=!1,K=!1,$=!0,B=b.stateProvider,H=function(e,n){var t,r={};return r.setUser=function(e){var r=t&&T(t);(t=_(e))&&n&&n(T(t),r)},r.getUser=function(){return t?T(t):null},e&&r.setUser(e),r}(null,(function(e,n){(function(e){if(B)return;e&&X({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!b.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&te(e,n)})),G=en(D),W=D.isEnabled()?new Qe(D,E,w,H,m):null;function X(e){if(E&&!(B&&B.enqueueEvent&&B.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void($&&(m.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),$=!1));$=!1}!k||K||o.isDoNotTrack()||(m.debug(Ne(e.kind)),F.enqueue(e))}}function Q(e,n,t,r){var i=H.getUser(),o=new Date,a={kind:"feature",key:e,user:i,value:n?n.value:null,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()};i&&i.anonymous&&(a.contextKind=ne(i));var u=z[e];u&&(a.version=u.flagVersion?u.flagVersion:u.version,a.trackEvents=u.trackEvents,a.debugEventsUntilDate=u.debugEventsUntilDate),(r||u&&u.trackReason)&&n&&(a.reason=n.reason),X(a)}function Y(e,n,t,r){var i;if(z&&q(z,e)&&z[e]&&!z[e].deleted){var o=z[e];i=ee(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&Q(e,i,n,r),i}function ee(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function ne(e){return e.anonymous?"anonymousUser":"user"}function te(e,n){B||e&&n&&X({kind:"alias",key:e.key,contextKind:ne(e),previousKey:n.key,previousContextKind:ne(n),creationDate:(new Date).getTime()})}function re(){if(f=!0,H.getUser()){var e=function(e){try{return JSON.parse(e)}catch(e){return void y.maybeReportError(new d("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};C.connect(H.getUser(),w,{ping:function(){m.debug("received ping message from stream");var e=H.getUser();x.fetchFlagSettings(e,w).then((function(n){R(e,H.getUser())&&oe(n||{})})).catch((function(e){y.maybeReportError(new v(fe(e)))}))},put:function(n){var t=e(n.data);t&&(m.debug("received streaming update for all flags"),oe(t))},patch:function(n){var t=e(n.data);if(t){var r=z[t.key];if(!r||!r.version||!t.version||r.version<t.version){m.debug(Re(t.key));var i={},o=V({},t);delete o.key,z[t.key]=o;var a=ee(o);i[t.key]=r?{previous:r.value,current:a}:{current:a},ue(i)}else m.debug(Ae(t.key))}},delete:function(n){var t=e(n.data);if(t)if(!z[t.key]||z[t.key].version<t.version){m.debug(Le(t.key));var r={};z[t.key]&&!z[t.key].deleted&&(r[t.key]={previous:z[t.key].value}),z[t.key]={version:t.version,deleted:!0},ue(r)}else m.debug(Ce(t.key))}})}}function ie(){f&&(C.disconnect(),f=!1)}function oe(e){var t={};if(!e)return Promise.resolve();for(var r in z)q(z,r)&&z[r]&&(e[r]&&!R(e[r].value,z[r].value)?t[r]={previous:z[r].value,current:ee(e[r])}:e[r]&&!e[r].deleted||(t[r]={previous:z[r].value}));for(var i in e)q(e,i)&&e[i]&&(!z[i]||z[i].deleted)&&(t[i]={current:ee(e[i])});return z=n({},e),ue(t).catch((function(){}))}function ue(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,i=r?r.value:void 0,o=e[n].previous;y.emit("change:"+n,i,o),t[n]=r?{current:i,previous:o}:{previous:o}})),y.emit("change",t),y.emit("internal-change",z),b.sendEventsOnlyForVariation||B||n.forEach((function(n){Q(n,e[n].current)}))}return c&&W?W.saveFlags(z):Promise.resolve()}function ce(){var e=J||p&&void 0===J;e&&!f?re():!e&&f&&ie(),j&&j.setStreaming(e)}function ve(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof b.bootstrap&&"LOCALSTORAGE"===b.bootstrap.toUpperCase()&&(W?c=!0:m.warn(ae())),"object"===t(b.bootstrap)&&(z=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&m.warn(pe()),!1===e.$valid&&m.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var i={value:e[n]};t&&t[n]?i=V(i,t[n]):i.version=0,r[n]=i}})),r}(b.bootstrap)),B){var de=B.getInitialState();de?ge(de):B.on("init",ge),B.on("update",(function(e){e.user&&H.setUser(e.user);e.flags&&oe(e.flags)}))}else(function(){if(!e)return Promise.reject(new s(le()));return G.validateUser(r).then((function(e){return H.setUser(e),"object"===t(b.bootstrap)?me():c?W.loadFlags().then((function(e){return null==e?(z={},x.fetchFlagSettings(H.getUser(),w).then((function(e){return oe(e||{})})).then(me).catch((function(e){ye(new v(fe(e)))}))):(z=e,A(me),x.fetchFlagSettings(H.getUser(),w).then((function(e){return oe(e)})).catch((function(e){return y.maybeReportError(e)})))})):x.fetchFlagSettings(H.getUser(),w).then((function(e){z=e||{},me()})).catch((function(e){z={},ye(e)}))}))})().catch(ye);function ge(e){E=e.environment,H.setUser(e.user),z=n({},e.flags),A(me)}function me(){m.info("LaunchDarkly client initialized"),M=!0,ce(),h.signalSuccess()}function ye(e){h.signalFailure(e)}return{client:{waitForInitialization:function(){return h.getInitializationPromise()},waitUntilReady:function(){return h.getReadyPromise()},identify:function(e,n,t){return K?L(Promise.resolve({}),t):B?(m.warn("identify() has no effect here; it must be called on the main client instance"),L(Promise.resolve(N(z)),t)):L((c&&W?W.clearFlags():Promise.resolve()).then((function(){return G.validateUser(e)})).then((function(e){return x.fetchFlagSettings(e,n).then((function(t){var r=N(t);return H.setUser(e),w=n,t?oe(t).then((function(){return r})):r}))})).then((function(e){return f&&re(),e})).catch((function(e){return y.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return H.getUser()},variation:function(e,n){return Y(e,n,!0,!1).value},variationDetail:function(e,n){return Y(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&m.warn(se(e));var r=H.getUser(),i={kind:"custom",key:e,user:r,url:o.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(i.contextKind=ne(r)),null!=n&&(i.data=n),null!=t&&(i.metricValue=t),X(i)}else y.maybeReportError(new l(se(e)))},alias:te,on:function(e,n,t){ve(e)?(p=!0,M&&ce(),y.on(e,n,t)):y.on.apply(y,arguments)},off:function(e){if(y.off.apply(y,arguments),ve(e)){var n=!1;y.getEvents().forEach((function(e){ve(e)&&y.getEventListenerCount(e)>0&&(n=!0)})),n||(p=!1,f&&void 0===J&&ie())}},setStreaming:function(e){var n=null===e?void 0:e;n!==J&&(J=n,ce())},flush:function(e){return L(k?F.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!z)return e;for(var n in z)q(z,n)&&!z[n].deleted&&(e[n]=Y(n,null,!b.sendEventsOnlyForVariation).value);return e},close:function(e){if(K)return L(Promise.resolve(),e);var n=function(){K=!0,z={}};return L(Promise.resolve().then((function(){if(ie(),j&&j.stop(),k)return F.stop(),F.flush()})).then(n).catch(n),e)}},options:b,emitter:y,ident:H,logger:m,requestor:x,start:function(){k&&(j&&j.start(),F.start())},enqueueEvent:X,getFlagsInternal:function(){return z},getEnvironmentId:function(){return E},internalChangeEventName:"internal-change"}}var sn="3.7.0";export{Y as commonBasicLogger,Z as createConsoleLogger,p as errors,un as initialize,Ve as messages,z as utils,sn as version}; | ||
//# sourceMappingURL=ldclient-common.es.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self)["LDClient-Common"]={})}(this,function(e){"use strict";function b(n,e){var t,r=Object.keys(n);return Object.getOwnPropertySymbols&&(t=Object.getOwnPropertySymbols(n),e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),r.push.apply(r,t)),r}function ne(r){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?b(Object(i),!0).forEach(function(e){var n,t;n=r,t=i[e=e],e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):b(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function te(e){return(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})(e)}function k(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return r(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(t="Object"===t&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}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).name=e,n.prototype.constructor=n}var T=n("LaunchDarklyUnexpectedResponseError"),re=n("LaunchDarklyInvalidEnvironmentIdError"),i=n("LaunchDarklyInvalidUserError"),pe=n("LaunchDarklyInvalidEventKeyError"),E=n("LaunchDarklyInvalidArgumentError"),ie=n("LaunchDarklyFlagFetchError"),me=n("LaunchDarklyInvalidDataError");function I(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var w=Object.freeze({__proto__:null,LDUnexpectedResponseError:T,LDInvalidEnvironmentIdError:re,LDInvalidUserError:i,LDInvalidEventKeyError:pe,LDInvalidArgumentError:E,LDFlagFetchError:ie,LDInvalidDataError:me,isHttpErrorRecoverable:I}),D=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(function(e,n,t){for(var r,i=[],o=n;o<t;o+=3)r=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),i.push(function(e){return u[e>>18&63]+u[e>>12&63]+u[e>>6&63]+u[63&e]}(r));return i.join("")}(e,o,a<o+16383?a:o+16383));1==r?(n=e[t-1],i.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],i.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"="));return i.join("")},u=[],t=[],o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,P=o.length;a<P;++a)u[a]=o[a],t[o.charCodeAt(a)]=a;t["-".charCodeAt(0)]=62,t["_".charCodeAt(0)]=63;function s(e,n){if(e===n)return!0;if(e&&n&&"object"==typeof e&&"object"==typeof n){var t,r,i=S(e),o=S(n);if(i&&o){if((a=e.length)!=n.length)return!1;for(t=a;0!=t--;)if(!s(e[t],n[t]))return!1;return!0}if(i!=o)return!1;i=e instanceof Date,o=n instanceof Date;if(i!=o)return!1;if(i&&o)return e.getTime()==n.getTime();i=e instanceof RegExp,o=n instanceof RegExp;if(i!=o)return!1;if(i&&o)return e.toString()==n.toString();var a,u=U(e);if((a=u.length)!==U(n).length)return!1;for(t=a;0!=t--;)if(!R.call(n,u[t]))return!1;for(t=a;0!=t--;)if(!s(e[r=u[t]],n[r]))return!1;return!0}return e!=e&&n!=n}var S=Array.isArray,U=Object.keys,R=Object.prototype.hasOwnProperty,A=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function j(e,n){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(n.startsWith("/")?"":"/")+n}function c(e){e=unescape(encodeURIComponent(e));return D(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(e))}function O(e){return c(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function oe(e){return JSON.parse(JSON.stringify(e))}function ae(e,n){return s(e,n)}function ue(e){setTimeout(e,0)}function se(e,n){e=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:e}function C(e){var n,t={};for(n in e)fe(e,n)&&(t[n]={value:e[n],version:0});return t}function ce(e){var n,t={};for(n in e)fe(e,n)&&(t[n]=e[n].value);return t}function F(e,n){for(var t,r=n.slice(0),i=[],o=e;0<r.length;){for(t=[];0<o;){var a=r.shift();if(!a)break;(o-=O(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function L(e){var n=e.version||"3.6.0";return e.userAgent+"/"+n}function le(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return ne(ne({},e),n)},{})}function fe(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function ye(e){if(!e)return e;var n,t;for(t in A){var r=A[t],i=e[r];void 0!==i&&"string"!=typeof i&&((n=n||ne({},e))[r]=String(i))}return n||e}var N=Object.freeze({__proto__:null,appendUrlPath:j,btoa:c,base64URLEncode:O,clone:oe,deepEquals:ae,onNextTick:ue,wrapPromiseCallback:se,transformValuesToVersionedValues:C,transformVersionedValuesToValues:ce,chunkUserEventsForUrl:F,getLDUserAgentString:L,extend:le,objectHasOwnProperty:fe,sanitizeUser:ye});(function(e){var n,t,r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);r?(n=new Uint8Array(16),e.exports=function(){return r(n),n}):(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})})(x={exports:{}});for(var x,_=x.exports,q=[],l=0;l<256;++l)q[l]=(l+256).toString(16).substr(1);var V,f,J=function(e,n){var n=n||0,t=q;return[t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],t[e[+n]]].join("")},d=0,v=0;var g=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||V,t=void 0!==e.clockseq?e.clockseq:f,a=(null!=o&&null!=t||(a=_(),null==o&&(o=V=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==t&&(t=f=16383&(a[6]<<8|a[7]))),void 0!==e.msecs?e.msecs:(new Date).getTime()),u=void 0!==e.nsecs?e.nsecs:v+1,s=a-d+(u-v)/1e4;if(s<0&&void 0===e.clockseq&&(t=t+1&16383),1e4<=(u=(s<0||d<a)&&void 0===e.nsecs?0:u))throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");d=a,f=t,s=(1e4*(268435455&(a+=122192928e5))+(v=u))%4294967296,i[r++]=s>>>24&255,i[r++]=s>>>16&255,i[r++]=s>>>8&255,i[r++]=255&s,e=a/4294967296*1e4&268435455,i[r++]=e>>>8&255,i[r++]=255&e,i[r++]=e>>>24&15|16,i[r++]=e>>>16&255,i[r++]=t>>>8|128,i[r++]=255&t;for(var c=0;c<6;++c)i[r+c]=o[c];return n||J(i)},p=["debug","info","warn","error","none"];function M(e,u){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var s=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],c=!(!e||!e.destination),l=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",t=1;if(e&&e.level)for(var r=0;r<p.length;r++)p[r]===e.level&&(t=r);for(var i={},o=function(e){var o,a=p[e];"none"!==a&&(e<t?i[a]=function(){}:(o=e,i[a]=function(){var e=o,n=a,t=arguments;if(!(t.length<1)){var r=c?n+": "+l:l,i=1!==t.length&&u?((i=k(t))[0]=r+i[0],u.apply(void 0,k(i))):r+t[0];try{s[e](i)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}))},a=0;a<p.length;a++)o(a);return i}function he(e,n){return M({level:e,prefix:n})}function m(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}function be(){return"LaunchDarkly client initialized"}function ke(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"}function de(e){return'Custom event "'+e+'" does not exist'}function z(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+y}function Ee(){return"No environment/client-side ID was specified."+y}function ve(e){return"Error fetching flag settings: "+m(e)}function we(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"}function De(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+y}function Oe(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."}function K(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'}function Pe(){return"identify() has no effect here; it must be called on the main client instance"}function B(e){return'Ignoring unknown config option "'+e+'"'}function $(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"}function H(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"}function G(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t}function Se(){return"received ping message from stream"}function Ue(){return"received streaming update for all flags"}function Ie(e){return'received streaming update for flag "'+e+'"'}function je(e){return'received streaming update for flag "'+e+'" but ignored due to version check'}function Te(e){return'received streaming deletion for flag "'+e+'"'}function Re(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'}function Ae(e){return'enqueueing "'+e+'" event'}var y=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",W=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},X=function(e){return'Expected application/json content type but got "'+e+'"'},Ce=function(e){return"local storage is unavailable: "+m(e)},Q=function(e){return"network error"+(e?" ("+e+")":"")},Y=function(){return"No user specified."+y},Z=function(){return"Invalid user specified."+y},ee=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(I(e)?t:"giving up permanently")},Fe=function(){return"Cannot make HTTP requests in this environment."+y},Le=function(){return"Closing stream connection"},Ne=function(e){return"Opening stream connection to "+e},xe=function(e,n){return"Error on stream connection: "+m(e)+", will continue retrying every "+n+" milliseconds."},_e=function(e){return"polling for feature flags at "+e},qe=function(e){return"sending "+e+" events"},Ve=function(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')},Je=Object.freeze({__proto__:null,clientInitialized:be,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:W,eventWithoutUser:ke,invalidContentType:X,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:Ce,networkError:Q,unknownCustomEventKey:de,environmentNotFound:z,environmentNotSpecified:Ee,errorFetchingFlags:ve,userNotSpecified:Y,invalidUser:Z,invalidData:we,bootstrapOldFormat:De,bootstrapInvalid:Oe,deprecated:K,httpErrorMessage:ee,httpUnavailable:Fe,identifyDisabled:Pe,streamClosing:Le,streamConnecting:Ne,streamError:xe,unknownOption:B,wrongOptionType:$,wrongOptionTypeBoolean:H,optionBelowMinimum:G,debugPolling:_e,debugStreamPing:Se,debugStreamPut:Ue,debugStreamPatch:Ie,debugStreamPatchIgnored:je,debugStreamDelete:Te,debugStreamDeleteIgnored:Re,debugEnqueueingEvent:Ae,debugPostingEvents:qe,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},invalidTagValue:Ve}),Me={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:function(e,n,t,r){var i={};t.id&&(i.id=Ke("".concat(e,".id"),0,t.id,r));t.version&&(i.version=Ke("".concat(e,".version"),0,t.version,r));return i}}},ze=/^(\w|\.|-)+$/;function Ke(e,n,t,r){if("string"==typeof t&&t.match(ze))return t;r.warn(Ve(e))}function Be(e,n,t,a){var u=le({logger:{default:a}},Me,t),r={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function s(e){ue(function(){n&&n.maybeReportError(new E(e))})}var i,o,c,l,f,t=le({},e||{});function d(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";e=te(e);return"boolean"===e||"string"===e||"number"===e||"function"===e?e:"object"}}return i=t,Object.keys(r).forEach(function(e){var n;void 0!==i[e]&&(n=r[e],a&&a.warn(K(e,n)),n&&(void 0===i[n]&&(i[n]=i[e]),delete i[e]))}),o=le({},t),Object.keys(u).forEach(function(e){void 0!==o[e]&&null!==o[e]||(o[e]=u[e]&&u[e].default)}),l=le({},c=t=o),Object.keys(c).forEach(function(e){var n,t,r,i,o=c[e];null!=o&&(void 0===(n=u[e])?s(B(e)):(t=n.type||d(n.default),(r=n.validator)?void 0!==(r=r(e,c,c[e],a))?l[e]=r:delete l[e]:"any"!==t&&(r=t.split("|"),i=d(o),r.indexOf(i)<0?"boolean"===t?(l[e]=!!o,s(H(e,i))):(s($(e,t,i)),l[e]=n.default):"number"===i&&void 0!==n.minimum&&o<n.minimum&&(s(G(e,o,n.minimum)),l[e]=n.minimum))))}),f=(t=l).logger,p.forEach(function(e){if("none"!==e&&(!f[e]||"function"!=typeof f[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")}),t}function $e(e){var n={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(n["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(n["application-version"]=[e.application.version])),n}function He(e,n){if(n&&!n.sendLDHeaders)return{};var e={"X-LaunchDarkly-User-Agent":L(e)},t=(n&&n.wrapperName&&(e["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),$e(n)),n=Object.keys(t);return n.length&&(e["x-launchdarkly-tags"]=n.sort().flatMap(function(n){return Array.isArray(t[n])?t[n].sort().map(function(e){return"".concat(n,"/").concat(e)}):["".concat(n,"/").concat(t[n])]}).join(" ")),e}function Ge(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(ne({},e)):e}var We=2e3;function Xe(u,e,s){var c="/a/"+e+".gif",l=le({"Content-Type":"application/json"},He(u,s)),f=u.httpFallbackPing,d={};return d.sendChunk=function(e,n,r,t){var i=JSON.stringify(e),o=r?null:g();function a(t){var e=r?l:le({},l,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":o});return u.httpRequest("POST",n,Ge(e,s),i).promise.then(function(e){var n;if(e)return 400<=e.status&&I(e.status)&&t?a(!1):(n={status:(e=e).status},(e=e.header("date"))&&(e=Date.parse(e))&&(n.serverTime=e),n)}).catch(function(){return t?a(!1):Promise.reject()})}return t?a(!0).catch(function(){}):(f&&f(n+c+"?d="+O(i)),Promise.resolve())},d.sendEvents=function(e,n,t){if(!u.httpRequest)return Promise.resolve();for(var r=u.httpAllowsPost(),i=r?[e]:F(We-n.length,e),o=[],a=0;a<i.length;a++)o.push(d.sendChunk(i[a],n,t,r));return Promise.all(o)},d}function Qe(e){var n={},a=e.allAttributesPrivate,u=e.privateAttributeNames||[],s={key:!0,custom:!0,anonymous:!0},c={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(t,r){return Object.keys(t).reduce(function(e,n){return r(n)&&(i(n)?e[1][n]=!0:e[0][n]=t[n]),e},[{},{}])}var t=e.privateAttributeNames||[],i=function(e){return!s[e]&&(a||-1!==t.indexOf(e)||-1!==u.indexOf(e))},r=n(e,function(e){return c[e]}),o=r[0],r=r[1],e=(e.custom&&(e=n(e.custom,function(){return 1}),o.custom=e[0],r=le({},r,e[1])),Object.keys(r));return e.length&&(e.sort(),o.privateAttrs=e),o},n}function Ye(e,n,t,r,i,o){var a,u,s,c,l=3<arguments.length&&void 0!==r?r:null,f=4<arguments.length&&void 0!==i?i:null,d={},v=(5<arguments.length&&void 0!==o?o:null)||Xe(e,t,n),g=j(n.eventsUrl,"/events/bulk/"+t),p=(u=a=0,s={},(r={}).summarizeEvent=function(e){var n,t;"feature"===e.kind&&(n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),(t=s[n])?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate))},r.getSummary=function(){var e,n={},t=!0;for(e in s){var r=s[e],i=n[r.key],o=(i||(i={default:r.default,counters:[]},n[r.key]=i),{value:r.value,count:r.count});void 0!==r.variation&&null!==r.variation&&(o.variation=r.variation),r.version?o.version=r.version:o.unknown=!0,i.counters.push(o),t=!1}return t?null:{startDate:a,endDate:u,features:n}},r.clearSummary=function(){u=a=0,s={}},r),m=Qe(n),y=n.inlineUsersInEvents,h=n.samplingInterval,b=n.eventCapacity,k=n.flushInterval,E=n.logger,w=[],D=0,O=!1,P=!1;function S(){return 0===h||0===Math.floor(Math.random()*h)}function U(e){w.length<b?(w.push(e),P=!1):(P||(P=!0,E.warn(W())),l&&l.incrementDroppedEvents())}return d.enqueue=function(e){var n,t,r;O||(n=r=!1,p.summarizeEvent(e),"feature"===e.kind?S()&&(r=!!e.trackEvents,n=!!(t=e).debugEventsUntilDate&&(t.debugEventsUntilDate>D&&t.debugEventsUntilDate>(new Date).getTime())):r=S(),r&&U((r=le({},t=e),"alias"!==t.kind&&(y||"identify"===t.kind?r.user=m.filterUser(t.user):(r.userKey=t.user.key,delete r.user),"feature"===t.kind&&(delete r.trackEvents,delete r.debugEventsUntilDate)),r)),n&&((r=le({},e,{kind:"debug"})).user=m.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,U(r)))},d.flush=function(){if(O)return Promise.resolve();var e=w,n=p.getSummary();return p.clearSummary(),n&&(n.kind="summary",e.push(n)),l&&l.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],E.debug(qe(e.length)),v.sendEvents(e,g).then(function(e){e&&(e.serverTime&&(D=e.serverTime),I(e.status)||(O=!0),400<=e.status&&ue(function(){f.maybeReportError(new T(ee(e.status,"event posting","some events were dropped")))}))}))},d.start=function(){c=setTimeout(function e(){d.flush(),c=setTimeout(e,k)},k)},d.stop=function(){clearTimeout(c)},d}function Ze(n){var e={},i={};return e.on=function(e,n,t){i[e]=i[e]||[],i[e]=i[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(i[e])for(var r=0;r<i[e].length;r++)i[e][r].handler===n&&i[e][r].context===t&&(i[e]=i[e].slice(0,r).concat(i[e].slice(r+1)))},e.emit=function(e){if(i[e])for(var n=i[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(i)},e.getEventListenerCount=function(e){return i[e]?i[e].length:0},e.maybeReportError=function(e){e&&(i["error"]?this.emit("error",e):(n||console).error(e.message))},e}var h="ready",en="initialized",nn="failed";var tn=function(i){var n=!1,t=!1,r=null,e=null,o=new Promise(function(n){i.on(h,function e(){i.off(h,e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(r):e=new Promise(function(n,t){function r(e){i.off(nn,r),t(e)}i.on(en,function e(){i.off(en,e),n()}),i.on(nn,r)}))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,i.emit(en),i.emit(h))},signalFailure:function(e){n||t||(t=!0,r=e,i.emit(nn,e),i.emit(h)),i.maybeReportError(e)}}};function rn(n,t,r,i){var o={};function a(){var e="",n=i.getUser();return n&&(e=r||c(JSON.stringify(n))),"ld:"+t+":"+e}return o.loadFlags=function(){return n.get(a()).then(function(e){if(null==e)return null;try{var n,t=JSON.parse(e);return t&&(void 0===(n=t.$schema)||n<1?t=C(t):delete t.$schema),t}catch(e){return o.clearFlags().then(function(){return null})}})},o.saveFlags=function(e){e=le({},e,{$schema:1});return n.set(a(),JSON.stringify(e))},o.clearFlags=function(){return n.clear(a())},o}function on(r,n){function i(e){t||(t=!0,n.warn(Ce(e)))}var e={},t=!1;return e.isEnabled=function(){return!!r},e.get=function(e){return new Promise(function(n){r?r.get(e).then(n).catch(function(e){i(e),n(void 0)}):n(void 0)})},e.set=function(e,t){return new Promise(function(n){r?r.set(e,t).then(function(){return n(!0)}).catch(function(e){i(e),n(!1)}):n(!1)})},e.clear=function(e){return new Promise(function(n){r?r.clear(e).then(function(){return n(!0)}).catch(function(e){i(e),n(!1)}):n(!1)})},e}var an=3e5;function un(i,o,a,n){var u,s=o.streamUrl,c=o.logger,e={},l=j(s,"/eval/"+a),f=o.useReport,d=o.evaluationReasons,t=o.streamReconnectDelay,v=He(i,o),g=!1,p=null,m=null,y=null,h=null,b=null;function k(e){g||(c.warn(xe(e,t)),g=!0),D(!1),w(),E(t)}function E(e){m||(e?m=setTimeout(r,e):r())}function r(){m=null;var e,n="",t={headers:v,readTimeoutMillis:an};if(i.eventSourceFactory){for(var r in null!=h&&(n="h="+h),f?i.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(y)):(e=j(s,"/ping/"+a),n=""):e=l+"/"+O(JSON.stringify(y)),t.headers=Ge(t.headers,o),e=e+((n=d?n+(n?"&":"")+"withReasons=true":n)?"?":"")+n,w(),c.info(Ne(e)),u=(new Date).getTime(),p=i.eventSourceFactory(e,t),b)fe(b,r)&&p.addEventListener(r,b[r]);p.onerror=k}}function w(){p&&(c.info(Le()),p.close(),p=null)}function D(e){u&&n&&n.recordStreamInit(u,!e,(new Date).getTime()-u),u=null}return e.connect=function(e,n,t){y=e,h=n,b={};for(var r in t||{})!function(n){b[n]=function(e){D(!(g=!1)),t[n]&&t[n](e)}}(r);E()},e.disconnect=function(){clearTimeout(m),m=null,w()},e.isConnected=function(){return!!(p&&i.eventSourceIsActive&&i.eventSourceIsActive(p))},e}var sn="application/json";function cn(d,v,o){var a=v.baseUrl,u=v.useReport,s=v.evaluationReasons,c=v.logger,e={},g={};function l(e,n){if(!d.httpRequest)return new Promise(function(e,n){n(new ie(Fe()))});var t,r,i,o,a,u=n?"REPORT":"GET",s=He(d,v),c=(n&&(s["Content-Type"]=sn),g[e]),l=(c||(t=function(){delete g[e]},(f={addPromise:function(n,e){r=n,i&&i(),i=e,n.then(function(e){r===n&&(o(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}}).resultPromise=new Promise(function(e,n){o=e,a=n}),c=f,g[e]=c),d.httpRequest(u,e,Ge(s,v),n)),f=l.promise.then(function(e){var n;return 200===e.status?e.header("content-type")&&e.header("content-type").substring(0,sn.length)===sn?JSON.parse(e.body):(n=X(e.header("content-type")||""),Promise.reject(new ie(n))):Promise.reject(404===(n=e).status?new re(z()):new ie(ve(n.statusText||String(n.status))))},function(e){return Promise.reject(new ie(Q(e)))});return c.addPromise(f,function(){l.cancel&&l.cancel()}),c.resultPromise}return e.fetchJSON=function(e){return l(j(a,e),null)},e.fetchFlagSettings=function(e,n){var t,r,i="";return u?(t=[a,"/sdk/evalx/",o,"/user"].join(""),r=JSON.stringify(e)):(e=O(JSON.stringify(e)),t=[a,"/sdk/evalx/",o,"/users/",e].join("")),n&&(i="h="+n),c.debug(_e(t=t+((i=s?i+(i?"&":"")+"withReasons=true":i)?"?":"")+i)),l(t,r)},e}var ln="ld:$anonUserId";function fn(t){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new i(Y()));var n=oe(e);return null!==n.key&&void 0!==n.key?(n.key=n.key.toString(),Promise.resolve(n)):n.anonymous?t.get(ln).then(function(e){return e?(n.key=e,n):(e=g(),n.key=e,t.set(ln,e).then(function(){return n}))}):Promise.reject(new i(Z()))},e}var dn=Object.freeze({__proto__:null,baseOptionDefs:Me,validate:Be,getTags:$e}).baseOptionDefs,vn=N.appendUrlPath;var gn=function(e){var n={diagnosticId:g()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},pn=function(e){var n,t,r,i;function o(e){n=e,r=t=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){i.push({timestamp:e,failed:n,durationMillis:t})},reset:o}},mn=function(n,r,e,t,i,o,a){var u,s,c=!!n.diagnosticUseCombinedEvent,l="ld:"+i+":$diagnostics",f=vn(o.eventsUrl,"/events/diagnostic/"+i),d=o.diagnosticRecordingInterval,v=e,g=!!o.streaming;function p(){return{sdk:function(){var e=ne({},n.diagnosticSdkData);o.wrapperName&&(e.wrapperName=o.wrapperName);o.wrapperVersion&&(e.wrapperVersion=o.wrapperVersion);return e}(),configuration:{customBaseURI:o.baseUrl!==dn.baseUrl.default,customStreamURI:o.streamUrl!==dn.streamUrl.default,customEventsURI:o.eventsUrl!==dn.eventsUrl.default,eventsCapacity:o.eventCapacity,eventsFlushIntervalMillis:o.flushInterval,reconnectTimeMillis:o.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!o.allAttributesPrivate,inlineUsersInEvents:!!o.inlineUsersInEvents,diagnosticRecordingIntervalMillis:o.diagnosticRecordingInterval,usingSecureMode:!!o.hash,bootstrapMode:!!o.bootstrap,fetchGoalsDisabled:!o.fetchGoals,allowFrequentDuplicateEvents:!!o.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!o.sendEventsOnlyForVariation,autoAliasingOptOut:!!o.autoAliasingOptOut},platform:n.diagnosticPlatformData}}function m(e){o.logger&&o.logger.debug(Je.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function y(){var e,n;m((n=(new Date).getTime(),e=ne({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:n},v.getProps()),c&&(e=ne(ne({},e),p())),v.reset(n),e)),s=setTimeout(y,d),u=(new Date).getTime(),c&&r.isEnabled()&&(n=ne({},v.getProps()),r.set(l,JSON.stringify(n)))}return(i={}).start=function(){var t;c?(t=function(e){var n;e?(e=(u||0)+d)<=(n=(new Date).getTime())?y():s=setTimeout(y,e-n):0===Math.floor(4*Math.random())?y():s=setTimeout(y,d)},r.isEnabled()?r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)}):t(!1)):(m(ne({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},p())),s=setTimeout(y,d))},i.stop=function(){s&&clearTimeout(s)},i.setStreaming=function(e){g=e},i},ge="change",yn="internal-change";e.commonBasicLogger=M,e.createConsoleLogger=he,e.errors=w,e.initialize=function(N,x,e,i,n){var t,o,r,a,u,s,_,c,l,f=function(){if(e&&e.logger)return e.logger;return n&&n.logger&&n.logger.default||he("warn")}(),d=Ze(f),v=tn(d),g=Be(e,d,n,f),p=g.sendEvents,m=N,y=g.hash,h=on(i.localStorage,f),b=Xe(i,m,g),k=g.sendEvents&&!g.diagnosticOptOut,q=k?gn(m):null,E=k?pn((new Date).getTime()):null,w=k?mn(i,h,E,b,m,g,q):null,V=un(i,g,m,E),D=g.eventProcessor||Ye(i,g,m,E,d,b),O=cn(i,g,m),J={},P={},S=g.streaming,M=!1,U=!1,z=!0,I=g.stateProvider,j=(a=function(e,n){(function(e){I||e&&R({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!g.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&H(e,n)},k={setUser:function(e){var n=u&&oe(u);(u=ye(e))&&a&&a(oe(u),n)},getUser:function(){return u?oe(u):null}},(q=null)&&k.setUser(q),k),K=fn(h),T=h.isEnabled()?new rn(h,m,y,j):null;function R(e){if(m&&!(I&&I.enqueueEvent&&I.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(z&&(f.warn(ke()),z=!1));z=!1}!p||U||i.isDoNotTrack()||(f.debug(Ae(e.kind)),D.enqueue(e))}}function B(e,n,t,r){var i=j.getUser(),o=new Date,a=n?n.value:null;if(!g.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=J[u];if(s&&o-s<3e5)return;J[u]=o}s={kind:"feature",key:e,user:i,value:a,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()},i&&i.anonymous&&(s.contextKind=C(i)),u=P[e];u&&(s.version=u.flagVersion||u.version,s.trackEvents=u.trackEvents,s.debugEventsUntilDate=u.debugEventsUntilDate),(r||u&&u.trackReason)&&n&&(s.reason=n.reason),R(s)}function $(e,n,t,r){var i,o;return P&&fe(P,e)&&P[e]&&!P[e].deleted?(o=A(i=P[e]),null!==i.value&&void 0!==i.value||(o.value=n)):o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}},t&&B(e,o,n,r),o}function A(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function C(e){return e.anonymous?"anonymousUser":"user"}function H(e,n){I||e&&n&&R({kind:"alias",key:e.key,contextKind:C(e),previousKey:n.key,previousContextKind:C(n),creationDate:(new Date).getTime()})}function G(){var i;o=!0,j.getUser()&&(i=function(e){try{return JSON.parse(e)}catch(e){return void d.maybeReportError(new me(we()))}},V.connect(j.getUser(),y,{ping:function(){f.debug(Se());var n=j.getUser();O.fetchFlagSettings(n,y).then(function(e){ae(n,j.getUser())&&F(e||{})}).catch(function(e){d.maybeReportError(new ie(ve(e)))})},put:function(e){e=i(e.data);e&&(f.debug(Ue()),F(e))},patch:function(e){var n,t,r,e=i(e.data);e&&(!(n=P[e.key])||!n.version||!e.version||n.version<e.version?(f.debug(Ie(e.key)),t={},delete(r=le({},e)).key,r=A(P[e.key]=r),t[e.key]=n?{previous:n.value,current:r}:{current:r},X(t)):f.debug(je(e.key)))},delete:function(e){var n,e=i(e.data);e&&(!P[e.key]||P[e.key].version<e.version?(f.debug(Te(e.key)),n={},P[e.key]&&!P[e.key].deleted&&(n[e.key]={previous:P[e.key].value}),P[e.key]={version:e.version,deleted:!0},X(n)):f.debug(Re(e.key)))}}))}function W(){o&&(V.disconnect(),o=!1)}function F(e){var n,t,r={};if(!e)return Promise.resolve();for(n in P)fe(P,n)&&P[n]&&(e[n]&&!ae(e[n].value,P[n].value)?r[n]={previous:P[n].value,current:A(e[n])}:e[n]&&!e[n].deleted||(r[n]={previous:P[n].value}));for(t in e)fe(e,t)&&e[t]&&(!P[t]||P[t].deleted)&&(r[t]={current:A(e[t])});return P=ne({},e),X(r).catch(function(){})}function X(i){var o,e=Object.keys(i);return 0<e.length&&(o={},e.forEach(function(e){var n=i[e].current,t=n?n.value:void 0,r=i[e].previous;d.emit(ge+":"+e,t,r),o[e]=n?{current:t,previous:r}:{previous:r}}),d.emit(ge,o),d.emit(yn,P),g.sendEventsOnlyForVariation||I||e.forEach(function(e){B(e,i[e].current)})),t&&T?T.saveFlags(P):Promise.resolve()}function Q(){var e=S||r&&void 0===S;e&&!o?G():!e&&o&&W(),w&&w.setStreaming(e)}function Y(e){return e===ge||e.substr(0,ge.length+1)===ge+":"}function Z(e){m=e.environment,j.setUser(e.user),P=ne({},e.flags),ue(L)}function L(){f.info(be()),M=!0,Q(),v.signalSuccess()}function ee(e){v.signalFailure(e)}return"string"==typeof g.bootstrap&&"LOCALSTORAGE"===g.bootstrap.toUpperCase()&&(T?t=!0:f.warn(Ce())),"object"===te(g.bootstrap)&&(s=g.bootstrap,E=Object.keys(s),!(c=s[_="$flagsState"])&&E.length&&f.warn(De()),!1===s.$valid&&f.warn(Oe()),l={},E.forEach(function(e){var n;e!==_&&"$valid"!==e&&(n={value:s[e]},c&&c[e]?n=le(n,c[e]):n.version=0,l[e]=n)}),P=l),I?((b=I.getInitialState())?Z(b):I.on("init",Z),I.on("update",function(e){e.user&&j.setUser(e.user);e.flags&&F(e.flags)})):(N?K.validateUser(x).then(function(e){return j.setUser(e),"object"===te(g.bootstrap)?L():t?T.loadFlags().then(function(e){return null==e?(P={},O.fetchFlagSettings(j.getUser(),y).then(function(e){return F(e||{})}).then(L).catch(function(e){ee(new ie(ve(e)))})):(P=e,ue(L),O.fetchFlagSettings(j.getUser(),y).then(F).catch(function(e){return d.maybeReportError(e)}))}):O.fetchFlagSettings(j.getUser(),y).then(function(e){P=e||{},L()}).catch(function(e){P={},ee(e)})}):Promise.reject(new re(Ee()))).catch(ee),{client:{waitForInitialization:function(){return v.getInitializationPromise()},waitUntilReady:function(){return v.getReadyPromise()},identify:function(e,r,n){return U?se(Promise.resolve({}),n):I?(f.warn(Pe()),se(Promise.resolve(ce(P)),n)):se((t&&T?T.clearFlags():Promise.resolve()).then(function(){return K.validateUser(e)}).then(function(t){return O.fetchFlagSettings(t,r).then(function(e){var n=ce(e);return j.setUser(t),y=r,e?F(e).then(function(){return n}):n})}).then(function(e){return o&&G(),e}).catch(function(e){return d.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return j.getUser()},variation:function(e,n){return $(e,n,!0,!1).value},variationDetail:function(e,n){return $(e,n,!0,!0)},track:function(e,n,t){var r;"string"!=typeof e?d.maybeReportError(new pe(de(e))):(i.customEventFilter&&!i.customEventFilter(e)&&f.warn(de(e)),r={kind:"custom",key:e,user:e=j.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()},e&&e.anonymous&&(r.contextKind=C(e)),null!=n&&(r.data=n),null!=t&&(r.metricValue=t),R(r))},alias:H,on:function(e,n,t){Y(e)?(r=!0,M&&Q(),d.on(e,n,t)):d.on.apply(d,arguments)},off:function(e){var n;d.off.apply(d,arguments),Y(e)&&(n=!1,d.getEvents().forEach(function(e){Y(e)&&0<d.getEventListenerCount(e)&&(n=!0)}),n||(r=!1,o&&void 0===S&&W()))},setStreaming:function(e){(e=null===e?void 0:e)!==S&&(S=e,Q())},flush:function(e){return se(p?D.flush():Promise.resolve(),e)},allFlags:function(){var e,n={};if(!P)return n;for(e in P)fe(P,e)&&(n[e]=$(e,null,!g.sendEventsOnlyForVariation).value);return n},close:function(e){return se(U?Promise.resolve():Promise.resolve().then(function(){if(W(),w&&w.stop(),p)return D.stop(),D.flush()}).then(n).catch(n),e);function n(){U=!0,P={}}}},options:g,emitter:d,ident:j,logger:f,requestor:O,start:function(){p&&(w&&w.start(),D.start())},enqueueEvent:R,getFlagsInternal:function(){return P},getEnvironmentId:function(){return m},internalChangeEventName:yn}},e.messages=Je,e.utils=N,e.version="3.6.0",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self)["LDClient-Common"]={})}(this,function(e){"use strict";function h(n,e){var t,r=Object.keys(n);return Object.getOwnPropertySymbols&&(t=Object.getOwnPropertySymbols(n),e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),r.push.apply(r,t)),r}function ee(r){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?h(Object(i),!0).forEach(function(e){var n,t;n=r,t=i[e=e],e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):h(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function ne(e){return(ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function b(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){var t;if(e)return"string"==typeof e?r(e,n):"Map"===(t="Object"===(t=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(e,n):void 0}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}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).name=e,n.prototype.constructor=n}var L=n("LaunchDarklyUnexpectedResponseError"),te=n("LaunchDarklyInvalidEnvironmentIdError"),i=n("LaunchDarklyInvalidUserError"),pe=n("LaunchDarklyInvalidEventKeyError"),k=n("LaunchDarklyInvalidArgumentError"),re=n("LaunchDarklyFlagFetchError"),me=n("LaunchDarklyInvalidDataError");function A(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var E=Object.freeze({__proto__:null,LDUnexpectedResponseError:L,LDInvalidEnvironmentIdError:te,LDInvalidUserError:i,LDInvalidEventKeyError:pe,LDInvalidArgumentError:k,LDFlagFetchError:re,LDInvalidDataError:me,isHttpErrorRecoverable:A}),w=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(function(e,n,t){for(var r,i=[],o=n;o<t;o+=3)r=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),i.push(function(e){return u[e>>18&63]+u[e>>12&63]+u[e>>6&63]+u[63&e]}(r));return i.join("")}(e,o,a<o+16383?a:o+16383));1==r?(n=e[t-1],i.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],i.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"="));return i.join("")},u=[],t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,D=t.length;o<D;++o)u[o]=t[o],t.charCodeAt(o),o;"-".charCodeAt(0),"_".charCodeAt(0);function s(e,n){if(e===n)return!0;if(e&&n&&"object"==typeof e&&"object"==typeof n){var t,r,i=P(e),o=P(n);if(i&&o){if((a=e.length)!=n.length)return!1;for(t=a;0!=t--;)if(!s(e[t],n[t]))return!1}else{if(i!=o)return!1;i=e instanceof Date,o=n instanceof Date;if(i!=o)return!1;if(i&&o)return e.getTime()==n.getTime();i=e instanceof RegExp,o=n instanceof RegExp;if(i!=o)return!1;if(i&&o)return e.toString()==n.toString();var a,u=S(e);if((a=u.length)!==S(n).length)return!1;for(t=a;0!=t--;)if(!U.call(n,u[t]))return!1;for(t=a;0!=t--;)if(!s(e[r=u[t]],n[r]))return!1}return!0}return e!=e&&n!=n}var P=Array.isArray,S=Object.keys,U=Object.prototype.hasOwnProperty,I=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function C(e,n){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(n.startsWith("/")?"":"/")+n}function c(e){e=unescape(encodeURIComponent(e));return w(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(e))}function O(e){return c(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function ie(e){return JSON.parse(JSON.stringify(e))}function oe(e,n){return s(e,n)}function ae(e){setTimeout(e,0)}function ue(e,n){e=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:e}function j(e){var n,t={};for(n in e)le(e,n)&&(t[n]={value:e[n],version:0});return t}function se(e){var n,t={};for(n in e)le(e,n)&&(t[n]=e[n].value);return t}function T(e,n){for(var t,r=n.slice(0),i=[],o=e;0<r.length;){for(t=[];0<o;){var a=r.shift();if(!a)break;(o-=O(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function R(e){var n=e.version||"3.7.0";return e.userAgent+"/"+n}function ce(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return ee(ee({},e),n)},{})}function le(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function ye(e){if(!e)return e;var n,t;for(t in I){var r=I[t],i=e[r];void 0!==i&&"string"!=typeof i&&((n=n||ee({},e))[r]=String(i))}return n||e}var N=Object.freeze({__proto__:null,appendUrlPath:C,btoa:c,base64URLEncode:O,clone:ie,deepEquals:oe,onNextTick:ae,wrapPromiseCallback:ue,transformValuesToVersionedValues:j,transformVersionedValuesToValues:se,chunkUserEventsForUrl:T,getLDUserAgentString:R,extend:ce,objectHasOwnProperty:le,sanitizeUser:ye});(function(e){var n,t,r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);r?(n=new Uint8Array(16),e.exports=function(){return r(n),n}):(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})})(F={exports:{}});for(var F,x=F.exports,_=[],a=0;a<256;++a)_[a]=(a+256).toString(16).substr(1);var V,l,q=function(e,n){var n=n||0,t=_;return[t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],t[e[+n]]].join("")},f=0,d=0;var v=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||V,t=void 0!==e.clockseq?e.clockseq:l,a=(null!=o&&null!=t||(a=x(),null==o&&(o=V=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==t&&(t=l=16383&(a[6]<<8|a[7]))),void 0!==e.msecs?e.msecs:(new Date).getTime()),u=void 0!==e.nsecs?e.nsecs:d+1,s=a-f+(u-d)/1e4;if(s<0&&void 0===e.clockseq&&(t=t+1&16383),1e4<=(u=(s<0||f<a)&&void 0===e.nsecs?0:u))throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");f=a,l=t,s=(1e4*(268435455&(a+=122192928e5))+(d=u))%4294967296,i[r++]=s>>>24&255,i[r++]=s>>>16&255,i[r++]=s>>>8&255,i[r++]=255&s,e=a/4294967296*1e4&268435455,i[r++]=e>>>8&255,i[r++]=255&e,i[r++]=e>>>24&15|16,i[r++]=e>>>16&255,i[r++]=t>>>8|128,i[r++]=255&t;for(var c=0;c<6;++c)i[r+c]=o[c];return n||q(i)},g=["debug","info","warn","error","none"];function M(e,u){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var s=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],c=!(!e||!e.destination),l=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",t=1;if(e&&e.level)for(var r=0;r<g.length;r++)g[r]===e.level&&(t=r);for(var i={},o=function(e){var o,a=g[e];"none"!==a&&(e<t?i[a]=function(){}:(o=e,i[a]=function(){var e=o,n=a,t=arguments;if(!(t.length<1)){var r=c?n+": "+l:l,i=1!==t.length&&u?((i=b(t))[0]=r+i[0],u.apply(void 0,b(i))):r+t[0];try{s[e](i)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}))},a=0;a<g.length;a++)o(a);return i}function he(e,n){return M({level:e,prefix:n})}function p(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}function be(){return"LaunchDarkly client initialized"}function ke(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"}function fe(e){return'Custom event "'+e+'" does not exist'}function z(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+m}function Ee(){return"No environment/client-side ID was specified."+m}function de(e){return"Error fetching flag settings: "+p(e)}function we(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"}function De(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+m}function Oe(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."}function J(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'}function Pe(){return"identify() has no effect here; it must be called on the main client instance"}function K(e){return'Ignoring unknown config option "'+e+'"'}function B(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"}function $(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"}function H(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t}function Se(){return"received ping message from stream"}function Ue(){return"received streaming update for all flags"}function Ie(e){return'received streaming update for flag "'+e+'"'}function je(e){return'received streaming update for flag "'+e+'" but ignored due to version check'}function Te(e){return'received streaming deletion for flag "'+e+'"'}function Re(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'}function Ae(e){return'enqueueing "'+e+'" event'}var m=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",G=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},W=function(e){return'Expected application/json content type but got "'+e+'"'},ve=function(e){return"local storage is unavailable: "+p(e)},X=function(e){return"network error"+(e?" ("+e+")":"")},Q=function(){return"No user specified."+m},Y=function(){return"Invalid user specified."+m},Z=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(A(e)?t:"giving up permanently")},Ce=function(){return"Cannot make HTTP requests in this environment."+m},Le=function(){return"Closing stream connection"},Ne=function(e){return"Opening stream connection to "+e},Fe=function(e,n){return"Error on stream connection: "+p(e)+", will continue retrying every "+n+" milliseconds."},xe=function(e){return"polling for feature flags at "+e},_e=function(e){return"sending "+e+" events"},Ve=function(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')},qe=Object.freeze({__proto__:null,clientInitialized:be,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:G,eventWithoutUser:ke,invalidContentType:W,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ve,networkError:X,unknownCustomEventKey:fe,environmentNotFound:z,environmentNotSpecified:Ee,errorFetchingFlags:de,userNotSpecified:Q,invalidUser:Y,invalidData:we,bootstrapOldFormat:De,bootstrapInvalid:Oe,deprecated:J,httpErrorMessage:Z,httpUnavailable:Ce,identifyDisabled:Pe,streamClosing:Le,streamConnecting:Ne,streamError:Fe,unknownOption:K,wrongOptionType:B,wrongOptionTypeBoolean:$,optionBelowMinimum:H,debugPolling:xe,debugStreamPing:Se,debugStreamPut:Ue,debugStreamPatch:Ie,debugStreamPatchIgnored:je,debugStreamDelete:Te,debugStreamDeleteIgnored:Re,debugEnqueueingEvent:Ae,debugPostingEvents:_e,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},invalidTagValue:Ve}),Me={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:function(e,n,t,r){var i={};t.id&&(i.id=Je("".concat(e,".id"),0,t.id,r));t.version&&(i.version=Je("".concat(e,".version"),0,t.version,r));return i}}},ze=/^(\w|\.|-)+$/;function Je(e,n,t,r){if("string"==typeof t&&t.match(ze))return t;r.warn(Ve(e))}function Ke(e,n,t,a){var u=ce({logger:{default:a}},Me,t),r={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null,allowFrequentDuplicateEvents:void 0};function s(e){ae(function(){n&&n.maybeReportError(new k(e))})}var i,o,c,l,f,t=ce({},e||{});function d(e){return null===e?"any":void 0!==e?Array.isArray(e)?"array":"boolean"===(e=ne(e))||"string"===e||"number"===e||"function"===e?e:"object":void 0}return i=t,Object.keys(r).forEach(function(e){var n;void 0!==i[e]&&(n=r[e],a&&a.warn(J(e,n)),n&&(void 0===i[n]&&(i[n]=i[e]),delete i[e]))}),o=ce({},t),Object.keys(u).forEach(function(e){void 0!==o[e]&&null!==o[e]||(o[e]=u[e]&&u[e].default)}),l=ce({},c=t=o),Object.keys(c).forEach(function(e){var n,t,r,i,o=c[e];null!=o&&(void 0===(n=u[e])?s(K(e)):(t=n.type||d(n.default),(r=n.validator)?void 0!==(r=r(e,c,c[e],a))?l[e]=r:delete l[e]:"any"!==t&&(r=t.split("|"),i=d(o),r.indexOf(i)<0?"boolean"===t?(l[e]=!!o,s($(e,i))):(s(B(e,t,i)),l[e]=n.default):"number"===i&&void 0!==n.minimum&&o<n.minimum&&(s(H(e,o,n.minimum)),l[e]=n.minimum))))}),f=(t=l).logger,g.forEach(function(e){if("none"!==e&&(!f[e]||"function"!=typeof f[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")}),t}function Be(e){var n={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(n["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(n["application-version"]=[e.application.version])),n}function $e(e,n){var t;return n&&!n.sendLDHeaders?{}:(e={"X-LaunchDarkly-User-Agent":R(e)},n&&n.wrapperName&&(e["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t=Be(n),(n=Object.keys(t)).length&&(e["x-launchdarkly-tags"]=n.sort().flatMap(function(n){return Array.isArray(t[n])?t[n].sort().map(function(e){return"".concat(n,"/").concat(e)}):["".concat(n,"/").concat(t[n])]}).join(" ")),e)}function He(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(ee({},e)):e}var Ge=2e3;function We(u,e,s){var c="/a/"+e+".gif",l=ce({"Content-Type":"application/json"},$e(u,s)),f=u.httpFallbackPing,d={};return d.sendChunk=function(e,n,r,t){var i=JSON.stringify(e),o=r?null:v();function a(t){var e=r?l:ce({},l,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":o});return u.httpRequest("POST",n,He(e,s),i).promise.then(function(e){var n;if(e)return 400<=e.status&&A(e.status)&&t?a(!1):(n={status:(e=e).status},(e=e.header("date"))&&(e=Date.parse(e))&&(n.serverTime=e),n)}).catch(function(){return t?a(!1):Promise.reject()})}return t?a(!0).catch(function(){}):(f&&f(n+c+"?d="+O(i)),Promise.resolve())},d.sendEvents=function(e,n,t){if(!u.httpRequest)return Promise.resolve();for(var r=u.httpAllowsPost(),i=r?[e]:T(Ge-n.length,e),o=[],a=0;a<i.length;a++)o.push(d.sendChunk(i[a],n,t,r));return Promise.all(o)},d}function Xe(e,n,t,r,i,o){var a,u,s,c,l,f,d,v,g=3<arguments.length&&void 0!==r?r:null,p=4<arguments.length&&void 0!==i?i:null,m={},y=(5<arguments.length&&void 0!==o?o:null)||We(e,t,n),h=C(n.eventsUrl,"/events/bulk/"+t),b=(u=a=0,s={},(r={}).summarizeEvent=function(e){var n,t;"feature"===e.kind&&(n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),(t=s[n])?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate))},r.getSummary=function(){var e,n={},t=!0;for(e in s){var r=s[e],i=n[r.key],o=(i||(i={default:r.default,counters:[]},n[r.key]=i),{value:r.value,count:r.count});void 0!==r.variation&&null!==r.variation&&(o.variation=r.variation),r.version?o.version=r.version:o.unknown=!0,i.counters.push(o),t=!1}return t?null:{startDate:a,endDate:u,features:n}},r.clearSummary=function(){u=a=0,s={}},r),k=(i={},c=(o=n).allAttributesPrivate,l=o.privateAttributeNames||[],f={key:!0,custom:!0,anonymous:!0},d={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0},i.filterUser=function(e){var n,i,t,r,o;return e?(n=e.privateAttributeNames||[],i=function(e){return!f[e]&&(c||-1!==n.indexOf(e)||-1!==l.indexOf(e))},t=(r=(o=function(t,r){return Object.keys(t).reduce(function(e,n){return r(n)&&(i(n)?e[1][n]=!0:e[0][n]=t[n]),e},[{},{}])})(e,function(e){return d[e]}))[0],r=r[1],e.custom&&(o=o(e.custom,function(){return 1}),t.custom=o[0],r=ce({},r,o[1])),(e=Object.keys(r)).length&&(e.sort(),t.privateAttrs=e),t):null},i),E=n.inlineUsersInEvents,w=n.samplingInterval,D=n.eventCapacity,O=n.flushInterval,P=n.logger,S=[],U=0,I=!1,j=!1;function T(){return 0===w||0===Math.floor(Math.random()*w)}function R(e){S.length<D?(S.push(e),j=!1):(j||(j=!0,P.warn(G())),g&&g.incrementDroppedEvents())}return m.enqueue=function(e){var n,t,r;I||(n=r=!1,b.summarizeEvent(e),"feature"===e.kind?T()&&(r=!!e.trackEvents,n=!!(t=e).debugEventsUntilDate&&(t.debugEventsUntilDate>U&&t.debugEventsUntilDate>(new Date).getTime())):r=T(),r&&R((r=ce({},t=e),"alias"!==t.kind&&(E||"identify"===t.kind?r.user=k.filterUser(t.user):(r.userKey=t.user.key,delete r.user),"feature"===t.kind&&(delete r.trackEvents,delete r.debugEventsUntilDate)),r)),n&&((r=ce({},e,{kind:"debug"})).user=k.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,R(r)))},m.flush=function(){var e,n;return I||(e=S,n=b.getSummary(),b.clearSummary(),n&&(n.kind="summary",e.push(n)),g&&g.setEventsInLastBatch(e.length),0===e.length)?Promise.resolve():(S=[],P.debug(_e(e.length)),y.sendEvents(e,h).then(function(e){e&&(e.serverTime&&(U=e.serverTime),A(e.status)||(I=!0),400<=e.status&&ae(function(){p.maybeReportError(new L(Z(e.status,"event posting","some events were dropped")))}))}))},m.start=function(){v=setTimeout(function e(){m.flush(),v=setTimeout(e,O)},O)},m.stop=function(){clearTimeout(v)},m}function Qe(n){var e={},i={};return e.on=function(e,n,t){i[e]=i[e]||[],i[e]=i[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(i[e])for(var r=0;r<i[e].length;r++)i[e][r].handler===n&&i[e][r].context===t&&(i[e]=i[e].slice(0,r).concat(i[e].slice(r+1)))},e.emit=function(e){if(i[e])for(var n=i[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(i)},e.getEventListenerCount=function(e){return i[e]?i[e].length:0},e.maybeReportError=function(e){e&&(i["error"]?this.emit("error",e):(n||console).error(e.message))},e}var y="ready",Ye="initialized",Ze="failed";var en=function(i){var n=!1,t=!1,r=null,e=null,o=new Promise(function(n){i.on(y,function e(){i.off(y,e),n()})}).catch(function(){});return{getInitializationPromise:function(){if(!e){if(n)return Promise.resolve();if(t)return Promise.reject(r);e=new Promise(function(n,t){function r(e){i.off(Ze,r),t(e)}i.on(Ye,function e(){i.off(Ye,e),n()}),i.on(Ze,r)})}return e},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,i.emit(Ye),i.emit(y))},signalFailure:function(e){n||t||(t=!0,r=e,i.emit(Ze,e),i.emit(y)),i.maybeReportError(e)}}};function nn(n,t,r,i){var o={};function a(){var e="",n=i.getUser();return n&&(e=r||c(JSON.stringify(n))),"ld:"+t+":"+e}return o.loadFlags=function(){return n.get(a()).then(function(e){if(null==e)return null;try{var n,t=JSON.parse(e);return t&&(void 0===(n=t.$schema)||n<1?t=j(t):delete t.$schema),t}catch(e){return o.clearFlags().then(function(){return null})}})},o.saveFlags=function(e){e=ce({},e,{$schema:1});return n.set(a(),JSON.stringify(e))},o.clearFlags=function(){return n.clear(a())},o}function tn(r,n){function i(e){t||(t=!0,n.warn(ve(e)))}var e={},t=!1;return e.isEnabled=function(){return!!r},e.get=function(e){return new Promise(function(n){r?r.get(e).then(n).catch(function(e){i(e),n(void 0)}):n(void 0)})},e.set=function(e,t){return new Promise(function(n){r?r.set(e,t).then(function(){return n(!0)}).catch(function(e){i(e),n(!1)}):n(!1)})},e.clear=function(e){return new Promise(function(n){r?r.clear(e).then(function(){return n(!0)}).catch(function(e){i(e),n(!1)}):n(!1)})},e}var rn=3e5;function on(i,o,a,n){var u,s=o.streamUrl,c=o.logger,e={},l=C(s,"/eval/"+a),f=o.useReport,d=o.evaluationReasons,t=o.streamReconnectDelay,v=$e(i,o),g=!1,p=null,m=null,y=null,h=null,b=null;function k(e){g||(c.warn(Fe(e,t)),g=!0),D(!1),w(),E(t)}function E(e){m||(e?m=setTimeout(r,e):r())}function r(){m=null;var e,n="",t={headers:v,readTimeoutMillis:rn};if(i.eventSourceFactory){for(var r in null!=h&&(n="h="+h),f?i.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(y)):(e=C(s,"/ping/"+a),n=""):e=l+"/"+O(JSON.stringify(y)),t.headers=He(t.headers,o),e=e+((n=d?n+(n?"&":"")+"withReasons=true":n)?"?":"")+n,w(),c.info(Ne(e)),u=(new Date).getTime(),p=i.eventSourceFactory(e,t),b)le(b,r)&&p.addEventListener(r,b[r]);p.onerror=k}}function w(){p&&(c.info(Le()),p.close(),p=null)}function D(e){u&&n&&n.recordStreamInit(u,!e,(new Date).getTime()-u),u=null}return e.connect=function(e,n,t){y=e,h=n,b={};for(var r in t||{})!function(n){b[n]=function(e){D(!(g=!1)),t[n]&&t[n](e)}}(r);E()},e.disconnect=function(){clearTimeout(m),m=null,w()},e.isConnected=function(){return!!(p&&i.eventSourceIsActive&&i.eventSourceIsActive(p))},e}var an="application/json";function un(d,v,o){var a=v.baseUrl,u=v.useReport,s=v.evaluationReasons,c=v.logger,e={},g={};function l(e,n){var t,r,i,o,a,u,s,c,l,f;return d.httpRequest?(t=n?"REPORT":"GET",r=$e(d,v),n&&(r["Content-Type"]=an),(i=g[e])||(o=function(){delete g[e]},(f={addPromise:function(n,e){a=n,u&&u(),u=e,n.then(function(e){a===n&&(s(e),o&&o())},function(e){a===n&&(c(e),o&&o())})}}).resultPromise=new Promise(function(e,n){s=e,c=n}),i=f,g[e]=i),f=(l=d.httpRequest(t,e,He(r,v),n)).promise.then(function(e){var n;return 200===e.status?e.header("content-type")&&e.header("content-type").substring(0,an.length)===an?JSON.parse(e.body):(n=W(e.header("content-type")||""),Promise.reject(new re(n))):Promise.reject(404===(n=e).status?new te(z()):new re(de(n.statusText||String(n.status))))},function(e){return Promise.reject(new re(X(e)))}),i.addPromise(f,function(){l.cancel&&l.cancel()}),i.resultPromise):new Promise(function(e,n){n(new re(Ce()))})}return e.fetchJSON=function(e){return l(C(a,e),null)},e.fetchFlagSettings=function(e,n){var t,r,i="";return u?(t=[a,"/sdk/evalx/",o,"/user"].join(""),r=JSON.stringify(e)):(e=O(JSON.stringify(e)),t=[a,"/sdk/evalx/",o,"/users/",e].join("")),n&&(i="h="+n),c.debug(xe(t=t+((i=s?i+(i?"&":"")+"withReasons=true":i)?"?":"")+i)),l(t,r)},e}var sn="ld:$anonUserId";function cn(t){var e={};return e.validateUser=function(e){var n;return e?null!==(n=ie(e)).key&&void 0!==n.key?(n.key=n.key.toString(),Promise.resolve(n)):n.anonymous?t.get(sn).then(function(e){return e?(n.key=e,n):(e=v(),n.key=e,t.set(sn,e).then(function(){return n}))}):Promise.reject(new i(Y())):Promise.reject(new i(Q()))},e}var ln=Object.freeze({__proto__:null,baseOptionDefs:Me,validate:Ke,getTags:Be}).baseOptionDefs,fn=N.appendUrlPath;var dn=function(e){var n={diagnosticId:v()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},vn=function(e){var n,t,r,i;function o(e){n=e,r=t=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){i.push({timestamp:e,failed:n,durationMillis:t})},reset:o}},gn=function(n,r,e,t,i,o,a){var u,s,c=!!n.diagnosticUseCombinedEvent,l="ld:"+i+":$diagnostics",f=fn(o.eventsUrl,"/events/diagnostic/"+i),d=o.diagnosticRecordingInterval,v=e,g=!!o.streaming;function p(){return{sdk:function(){var e=ee({},n.diagnosticSdkData);o.wrapperName&&(e.wrapperName=o.wrapperName);o.wrapperVersion&&(e.wrapperVersion=o.wrapperVersion);return e}(),configuration:{customBaseURI:o.baseUrl!==ln.baseUrl.default,customStreamURI:o.streamUrl!==ln.streamUrl.default,customEventsURI:o.eventsUrl!==ln.eventsUrl.default,eventsCapacity:o.eventCapacity,eventsFlushIntervalMillis:o.flushInterval,reconnectTimeMillis:o.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!o.allAttributesPrivate,inlineUsersInEvents:!!o.inlineUsersInEvents,diagnosticRecordingIntervalMillis:o.diagnosticRecordingInterval,usingSecureMode:!!o.hash,bootstrapMode:!!o.bootstrap,fetchGoalsDisabled:!o.fetchGoals,sendEventsOnlyForVariation:!!o.sendEventsOnlyForVariation,autoAliasingOptOut:!!o.autoAliasingOptOut},platform:n.diagnosticPlatformData}}function m(e){o.logger&&o.logger.debug(qe.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function y(){var e,n;m((n=(new Date).getTime(),e=ee({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:n},v.getProps()),c&&(e=ee(ee({},e),p())),v.reset(n),e)),s=setTimeout(y,d),u=(new Date).getTime(),c&&r.isEnabled()&&(n=ee({},v.getProps()),r.set(l,JSON.stringify(n)))}return(i={}).start=function(){var t;c?(t=function(e){var n;e?(e=(u||0)+d)<=(n=(new Date).getTime())?y():s=setTimeout(y,e-n):0===Math.floor(4*Math.random())?y():s=setTimeout(y,d)},r.isEnabled()?r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)}):t(!1)):(m(ee({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},p())),s=setTimeout(y,d))},i.stop=function(){s&&clearTimeout(s)},i.setStreaming=function(e){g=e},i},ge="change",pn="internal-change";e.commonBasicLogger=M,e.createConsoleLogger=he,e.errors=E,e.initialize=function(F,x,e,i,n){var t,o,r,a,u,s,_,c,l,f=function(){if(e&&e.logger)return e.logger;return n&&n.logger&&n.logger.default||he("warn")}(),d=Qe(f),v=en(d),g=Ke(e,d,n,f),p=g.sendEvents,m=F,y=g.hash,h=tn(i.localStorage,f),b=We(i,m,g),k=g.sendEvents&&!g.diagnosticOptOut,V=k?dn(m):null,E=k?vn((new Date).getTime()):null,w=k?gn(i,h,E,b,m,g,V):null,q=on(i,g,m,E),D=g.eventProcessor||Xe(i,g,m,E,d,b),O=un(i,g,m),P={},S=g.streaming,M=!1,U=!1,z=!0,I=g.stateProvider,j=(a=function(e,n){(function(e){I||e&&R({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!g.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&$(e,n)},k={setUser:function(e){var n=u&&ie(u);(u=ye(e))&&a&&a(ie(u),n)},getUser:function(){return u?ie(u):null}},(V=null)&&k.setUser(V),k),J=cn(h),T=h.isEnabled()?new nn(h,m,y,j):null;function R(e){if(m&&!(I&&I.enqueueEvent&&I.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(z&&(f.warn(ke()),z=!1));z=!1}!p||U||i.isDoNotTrack()||(f.debug(Ae(e.kind)),D.enqueue(e))}}function K(e,n,t,r){var i=j.getUser(),o=new Date,t={kind:"feature",key:e,user:i,value:n?n.value:null,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()},o=(i&&i.anonymous&&(t.contextKind=C(i)),P[e]);o&&(t.version=o.flagVersion||o.version,t.trackEvents=o.trackEvents,t.debugEventsUntilDate=o.debugEventsUntilDate),(r||o&&o.trackReason)&&n&&(t.reason=n.reason),R(t)}function B(e,n,t,r){var i,o;return P&&le(P,e)&&P[e]&&!P[e].deleted?(o=A(i=P[e]),null!==i.value&&void 0!==i.value||(o.value=n)):o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}},t&&K(e,o,n,r),o}function A(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function C(e){return e.anonymous?"anonymousUser":"user"}function $(e,n){I||e&&n&&R({kind:"alias",key:e.key,contextKind:C(e),previousKey:n.key,previousContextKind:C(n),creationDate:(new Date).getTime()})}function H(){var i;o=!0,j.getUser()&&(i=function(e){try{return JSON.parse(e)}catch(e){d.maybeReportError(new me(we()))}},q.connect(j.getUser(),y,{ping:function(){f.debug(Se());var n=j.getUser();O.fetchFlagSettings(n,y).then(function(e){oe(n,j.getUser())&&L(e||{})}).catch(function(e){d.maybeReportError(new re(de(e)))})},put:function(e){e=i(e.data);e&&(f.debug(Ue()),L(e))},patch:function(e){var n,t,r,e=i(e.data);e&&(!(n=P[e.key])||!n.version||!e.version||n.version<e.version?(f.debug(Ie(e.key)),t={},delete(r=ce({},e)).key,r=A(P[e.key]=r),t[e.key]=n?{previous:n.value,current:r}:{current:r},W(t)):f.debug(je(e.key)))},delete:function(e){var n,e=i(e.data);e&&(!P[e.key]||P[e.key].version<e.version?(f.debug(Te(e.key)),n={},P[e.key]&&!P[e.key].deleted&&(n[e.key]={previous:P[e.key].value}),P[e.key]={version:e.version,deleted:!0},W(n)):f.debug(Re(e.key)))}}))}function G(){o&&(q.disconnect(),o=!1)}function L(e){var n,t,r={};if(!e)return Promise.resolve();for(n in P)le(P,n)&&P[n]&&(e[n]&&!oe(e[n].value,P[n].value)?r[n]={previous:P[n].value,current:A(e[n])}:e[n]&&!e[n].deleted||(r[n]={previous:P[n].value}));for(t in e)le(e,t)&&e[t]&&(!P[t]||P[t].deleted)&&(r[t]={current:A(e[t])});return P=ee({},e),W(r).catch(function(){})}function W(i){var o,e=Object.keys(i);return 0<e.length&&(o={},e.forEach(function(e){var n=i[e].current,t=n?n.value:void 0,r=i[e].previous;d.emit(ge+":"+e,t,r),o[e]=n?{current:t,previous:r}:{previous:r}}),d.emit(ge,o),d.emit(pn,P),g.sendEventsOnlyForVariation||I||e.forEach(function(e){K(e,i[e].current)})),t&&T?T.saveFlags(P):Promise.resolve()}function X(){var e=S||r&&void 0===S;e&&!o?H():!e&&o&&G(),w&&w.setStreaming(e)}function Q(e){return e===ge||e.substr(0,ge.length+1)===ge+":"}function Y(e){m=e.environment,j.setUser(e.user),P=ee({},e.flags),ae(N)}function N(){f.info(be()),M=!0,X(),v.signalSuccess()}function Z(e){v.signalFailure(e)}return"string"==typeof g.bootstrap&&"LOCALSTORAGE"===g.bootstrap.toUpperCase()&&(T?t=!0:f.warn(ve())),"object"===ne(g.bootstrap)&&(s=g.bootstrap,E=Object.keys(s),!(c=s[_="$flagsState"])&&E.length&&f.warn(De()),!1===s.$valid&&f.warn(Oe()),l={},E.forEach(function(e){var n;e!==_&&"$valid"!==e&&(n={value:s[e]},c&&c[e]?n=ce(n,c[e]):n.version=0,l[e]=n)}),P=l),I?((b=I.getInitialState())?Y(b):I.on("init",Y),I.on("update",function(e){e.user&&j.setUser(e.user);e.flags&&L(e.flags)})):(F?J.validateUser(x).then(function(e){return j.setUser(e),"object"===ne(g.bootstrap)?N():t?T.loadFlags().then(function(e){return null==e?(P={},O.fetchFlagSettings(j.getUser(),y).then(function(e){return L(e||{})}).then(N).catch(function(e){Z(new re(de(e)))})):(P=e,ae(N),O.fetchFlagSettings(j.getUser(),y).then(L).catch(function(e){return d.maybeReportError(e)}))}):O.fetchFlagSettings(j.getUser(),y).then(function(e){P=e||{},N()}).catch(function(e){P={},Z(e)})}):Promise.reject(new te(Ee()))).catch(Z),{client:{waitForInitialization:function(){return v.getInitializationPromise()},waitUntilReady:function(){return v.getReadyPromise()},identify:function(e,r,n){return U?ue(Promise.resolve({}),n):I?(f.warn(Pe()),ue(Promise.resolve(se(P)),n)):ue((t&&T?T.clearFlags():Promise.resolve()).then(function(){return J.validateUser(e)}).then(function(t){return O.fetchFlagSettings(t,r).then(function(e){var n=se(e);return j.setUser(t),y=r,e?L(e).then(function(){return n}):n})}).then(function(e){return o&&H(),e}).catch(function(e){return d.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return j.getUser()},variation:function(e,n){return B(e,n,!0,!1).value},variationDetail:function(e,n){return B(e,n,!0,!0)},track:function(e,n,t){var r;"string"!=typeof e?d.maybeReportError(new pe(fe(e))):(i.customEventFilter&&!i.customEventFilter(e)&&f.warn(fe(e)),r={kind:"custom",key:e,user:e=j.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()},e&&e.anonymous&&(r.contextKind=C(e)),null!=n&&(r.data=n),null!=t&&(r.metricValue=t),R(r))},alias:$,on:function(e,n,t){Q(e)?(r=!0,M&&X(),d.on(e,n,t)):d.on.apply(d,arguments)},off:function(e){var n;d.off.apply(d,arguments),Q(e)&&(n=!1,d.getEvents().forEach(function(e){Q(e)&&0<d.getEventListenerCount(e)&&(n=!0)}),n||(r=!1,o&&void 0===S&&G()))},setStreaming:function(e){(e=null===e?void 0:e)!==S&&(S=e,X())},flush:function(e){return ue(p?D.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(P)for(var n in P)le(P,n)&&!P[n].deleted&&(e[n]=B(n,null,!g.sendEventsOnlyForVariation).value);return e},close:function(e){var n;return U?ue(Promise.resolve(),e):(n=function(){U=!0,P={}},ue(Promise.resolve().then(function(){if(G(),w&&w.stop(),p)return D.stop(),D.flush()}).then(n).catch(n),e))}},options:g,emitter:d,ident:j,logger:f,requestor:O,start:function(){p&&(w&&w.start(),D.start())},enqueueEvent:R,getFlagsInternal:function(){return P},getEnvironmentId:function(){return m},internalChangeEventName:pn}},e.messages=qe,e.utils=N,e.version="3.7.0",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=ldclient-common.min.js.map |
{ | ||
"name": "launchdarkly-js-sdk-common", | ||
"version": "3.6.0", | ||
"version": "3.7.0", | ||
"description": "LaunchDarkly SDK for JavaScript - common code", | ||
@@ -5,0 +5,0 @@ "author": "LaunchDarkly <team@launchdarkly.com>", |
@@ -194,6 +194,9 @@ /** | ||
/** | ||
* Whether or not to send an analytics event for a flag evaluation even if the same flag was | ||
* evaluated with the same value within the last five minutes. | ||
* This option is deprecated, and setting it has no effect. | ||
* | ||
* By default, this is false (duplicate events within five minutes will be dropped). | ||
* The behavior is now to allow frequent duplicate events. | ||
* | ||
* This is not a problem because most events will be summarized, and | ||
* events which are not summarized are important to the operation of features such as | ||
* experimentation. | ||
*/ | ||
@@ -200,0 +203,0 @@ allowFrequentDuplicateEvents?: boolean; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
641326