launchdarkly-js-sdk-common
Advanced tools
Comparing version 3.4.0 to 3.5.0
@@ -5,2 +5,9 @@ # Change log | ||
## [3.5.0] - 2022-01-14 | ||
### Added: | ||
- New configurable logger factory `commonBasicLogger` and `BasicLoggerOptions`. The `commonBasicLogger` method is not intended to be exported directly in the SDKs, but wrapped to provide platform-specific behavior. | ||
### Fixed: | ||
- Any exceptions thrown by the platform-specific local storage implementation (for instance, if we are in a browser and `window.localstorage` is available but disabled) are now consistently caught, and will only be logged the first time to avoid repetitive logging. | ||
## [3.4.0] - 2021-10-15 | ||
@@ -7,0 +14,0 @@ ### Added: |
@@ -1,2 +0,2 @@ | ||
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function _objectSpread2(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(n,!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(n).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function createCustomError(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return(t.prototype=new Error).name=e,t.prototype.constructor=t}Object.defineProperty(exports,"__esModule",{value:!0});var LDUnexpectedResponseError=createCustomError("LaunchDarklyUnexpectedResponseError"),LDInvalidEnvironmentIdError=createCustomError("LaunchDarklyInvalidEnvironmentIdError"),LDInvalidUserError=createCustomError("LaunchDarklyInvalidUserError"),LDInvalidEventKeyError=createCustomError("LaunchDarklyInvalidEventKeyError"),LDInvalidArgumentError=createCustomError("LaunchDarklyInvalidArgumentError"),LDFlagFetchError=createCustomError("LaunchDarklyFlagFetchError");function isHttpErrorRecoverable(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({__proto__:null,LDUnexpectedResponseError:LDUnexpectedResponseError,LDInvalidEnvironmentIdError:LDInvalidEnvironmentIdError,LDInvalidUserError:LDInvalidUserError,LDInvalidEventKeyError:LDInvalidEventKeyError,LDInvalidArgumentError:LDInvalidArgumentError,LDFlagFetchError:LDFlagFetchError,isHttpErrorRecoverable:isHttpErrorRecoverable}),fromByteArray_1=fromByteArray,lookup=[],revLookup=[],code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,t,n){for(var r,o=[],i=t;i<n;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(r));return o.join("")}function fromByteArray(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(encodeChunk(e,a,s<a+i?s:a+i));return 1==r?(t=e[n-1],o.push(lookup[t>>2]+lookup[t<<4&63]+"==")):2==r&&(t=(e[n-2]<<8)+e[n-1],o.push(lookup[t>>10]+lookup[t>>4&63]+lookup[t<<2&63]+"=")),o.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63;var isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i,a=isArray(t),s=isArray(n);if(a&&s){if((o=t.length)!=n.length)return!1;for(r=o;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(a!=s)return!1;var u=t instanceof Date,c=n instanceof Date;if(u!=c)return!1;if(u&&c)return t.getTime()==n.getTime();var l=t instanceof RegExp,f=n instanceof RegExp;if(l!=f)return!1;if(l&&f)return t.toString()==n.toString();var d=keyList(t);if((o=d.length)!==keyList(n).length)return!1;for(r=o;0!=r--;)if(!hasProp.call(n,d[r]))return!1;for(r=o;0!=r--;)if(!e(t[i=d[r]],n[i]))return!1;return!0}return t!=t&&n!=n},userAttrsToStringify=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function btoa(e){var t=unescape(encodeURIComponent(e));return fromByteArray_1(stringToBytes(t))}function stringToBytes(e){for(var t=[],n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}function base64URLEncode(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function clone(e){return JSON.parse(JSON.stringify(e))}function deepEquals(e,t){return fastDeepEqual(e,t)}function onNextTick(e){setTimeout(e,0)}function wrapPromiseCallback(e,t){var n=e.then(function(e){return t&&setTimeout(function(){t(null,e)},0),e},function(e){if(!t)return Promise.reject(e);setTimeout(function(){t(e,null)},0)});return t?void 0:n}function transformValuesToVersionedValues(e){var t={};for(var n in e)objectHasOwnProperty(e,n)&&(t[n]={value:e[n],version:0});return t}function transformVersionedValuesToValues(e){var t={};for(var n in e)objectHasOwnProperty(e,n)&&(t[n]=e[n].value);return t}function chunkUserEventsForUrl(e,t){for(var n,r=t.slice(0),o=[],i=e;0<r.length;){for(n=[];0<i;){var a=r.shift();if(!a)break;(i-=base64URLEncode(JSON.stringify(a)).length)<0&&0<n.length?r.unshift(a):n.push(a)}i=e,o.push(n)}return o}function getLDUserAgentString(e){var t=e.version||"3.4.0";return e.userAgent+"/"+t}function getLDHeaders(e,t){if(t&&!t.sendLDHeaders)return{};var n={"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)};return t&&t.wrapperName&&(n["X-LaunchDarkly-Wrapper"]=t.wrapperVersion?t.wrapperName+"/"+t.wrapperVersion:t.wrapperName),n}function transformHeaders(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform(_objectSpread2({},e)):e}function extend(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce(function(e,t){return _objectSpread2({},e,{},t)},{})}function objectHasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function sanitizeUser(e){if(!e)return e;var t;for(var n in userAttrsToStringify){var r=userAttrsToStringify[n],o=e[r];void 0!==o&&"string"!=typeof o&&((t=t||_objectSpread2({},e))[r]=String(o))}return t||e}var utils=Object.freeze({__proto__:null,btoa:btoa,base64URLEncode:base64URLEncode,clone:clone,deepEquals:deepEquals,onNextTick:onNextTick,wrapPromiseCallback:wrapPromiseCallback,transformValuesToVersionedValues:transformValuesToVersionedValues,transformVersionedValuesToValues:transformVersionedValuesToValues,chunkUserEventsForUrl:chunkUserEventsForUrl,getLDUserAgentString:getLDUserAgentString,getLDHeaders:getLDHeaders,transformHeaders:transformHeaders,extend:extend,objectHasOwnProperty:objectHasOwnProperty,sanitizeUser:sanitizeUser});function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}for(var rngBrowser=createCommonjsModule(function(e){var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var n=new Uint8Array(16);e.exports=function(){return t(n),n}}else{var r=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}}}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,t){var n=t||0,r=byteToHex;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,t,n){var r=t&&n||0,o=t||[],i=(e=e||{}).node||_nodeId,a=void 0!==e.clockseq?e.clockseq:_clockseq;if(null==i||null==a){var s=rngBrowser();null==i&&(i=_nodeId=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==a&&(a=_clockseq=16383&(s[6]<<8|s[7]))}var u=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:_lastNSecs+1,l=u-_lastMSecs+(c-_lastNSecs)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||_lastMSecs<u)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=u,_clockseq=a;var f=(1e4*(268435455&(u+=122192928e5))+(_lastNSecs=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var d=u/4294967296*1e4&268435455;o[r++]=d>>>8&255,o[r++]=255&d,o[r++]=d>>>24&15|16,o[r++]=d>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var v=0;v<6;++v)o[r+v]=i[v];return t||bytesToUuid_1(o)}var v1_1=v1,MAX_URL_LENGTH=2e3;function EventSender(s,e,u){var n="/a/"+e+".gif",c=extend({"Content-Type":"application/json"},getLDHeaders(s,u)),l=s.httpFallbackPing,f={};return f.sendChunk=function(e,r,o,t){var i=JSON.stringify(e),a=o?null:v1_1();return t?function t(n){var e=o?c:extend({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return s.httpRequest("POST",r,transformHeaders(e,u),i).promise.then(function(e){if(e)return 400<=e.status&&isHttpErrorRecoverable(e.status)&&n?t(!1):function(e){var t={status:e.status},n=e.header("date");if(n){var r=Date.parse(n);r&&(t.serverTime=r)}return t}(e)}).catch(function(){return n?t(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(r+n+"?d="+base64URLEncode(i)),Promise.resolve())},f.sendEvents=function(e,t,n){if(!s.httpRequest)return Promise.resolve();var r,o=s.httpAllowsPost();r=o?[e]:chunkUserEventsForUrl(MAX_URL_LENGTH-t.length,e);for(var i=[],a=0;a<r.length;a++)i.push(f.sendChunk(r[a],t,n,o));return Promise.all(i)},f}function EventSummarizer(){var e={},a=0,s=0,u={};return e.summarizeEvent=function(e){if("feature"===e.kind){var t=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),n=u[t];n?n.count=n.count+1:u[t]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>s&&(s=e.creationDate)}},e.getSummary=function(){var e={},t=!0;for(var n in u){var r=u[n],o=e[r.key];o||(o={default:r.default,counters:[]},e[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),t=!1}return t?null:{startDate:a,endDate:s,features:e}},e.clearSummary=function(){s=a=0,u={}},e}function UserFilter(e){var t={},u=e.allAttributesPrivate,c=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return t.filterUser=function(e){if(!e)return null;function t(r,o){return Object.keys(r).reduce(function(e,t){var n=e;return o(t)&&(!function(e){return!l[e]&&(u||-1!==i.indexOf(e)||-1!==c.indexOf(e))}(t)?n[0][t]=r[t]:n[1][t]=!0),n},[{},{}])}var i=e.privateAttributeNames||[],n=t(e,function(e){return f[e]}),r=n[0],o=n[1];if(e.custom){var a=t(e.custom,function(){return!0});r.custom=a[0],o=extend({},o,a[1])}var s=Object.keys(o);return s.length&&(s.sort(),r.privateAttrs=s),r},t}function errorString(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var clientInitialized=function(){return"LaunchDarkly client initialized"},docLink=" Please see https://docs.launchdarkly.com/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(){return"localStorage is unavailable"},localStorageUnavailableForUserId=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},networkError=function(e){return"network error"+(e?" ("+e+")":"")},unknownCustomEventKey=function(e){return'Custom event "'+e+'" does not exist'},environmentNotFound=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+docLink},environmentNotSpecified=function(){return"No environment/client-side ID was specified."+docLink},errorFetchingFlags=function(e){return"Error fetching flag settings: "+errorString(e)},userNotSpecified=function(){return"No user specified."+docLink},invalidUser=function(){return"Invalid user specified."+docLink},bootstrapOldFormat=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+docLink},bootstrapInvalid=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated=function(e,t){return t?'"'+e+'" is deprecated, please use "'+t+'"':'"'+e+'" is deprecated'},httpErrorMessage=function(e,t,n){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+t+" - "+(isHttpErrorRecoverable(e)?n:"giving up permanently")},httpUnavailable=function(){return"Cannot make HTTP requests in this environment."+docLink},identifyDisabled=function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing=function(){return"Closing stream connection"},streamConnecting=function(e){return"Opening stream connection to "+e},streamError=function(e,t){return"Error on stream connection: "+errorString(e)+", will continue retrying every "+t+" milliseconds."},unknownOption=function(e){return'Ignoring unknown config option "'+e+'"'},wrongOptionType=function(e,t,n){return'Config option "'+e+'" should be of type '+t+", got "+n+", using default value"},wrongOptionTypeBoolean=function(e,t){return'Config option "'+e+'" should be a boolean, got '+t+", converting to boolean"},optionBelowMinimum=function(e,t,n){return'Config option "'+e+'" was set to '+t+", changing to minimum value of "+n},debugPolling=function(e){return"polling for feature flags at "+e},debugStreamPing=function(){return"received ping message from stream"},debugStreamPut=function(){return"received streaming update for all flags"},debugStreamPatch=function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamDelete=function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugEnqueueingEvent=function(e){return'enqueueing "'+e+'" event'},debugPostingEvents=function(e){return"sending "+e+" events"},debugPostingDiagnosticEvent=function(e){return"sending diagnostic event ("+e.kind+")"},messages=Object.freeze({__proto__:null,clientInitialized:clientInitialized,clientNotReady:clientNotReady,eventCapacityExceeded:eventCapacityExceeded,eventWithoutUser:eventWithoutUser,invalidContentType:invalidContentType,invalidKey:invalidKey,localStorageUnavailable:localStorageUnavailable,localStorageUnavailableForUserId:localStorageUnavailableForUserId,networkError:networkError,unknownCustomEventKey:unknownCustomEventKey,environmentNotFound:environmentNotFound,environmentNotSpecified:environmentNotSpecified,errorFetchingFlags:errorFetchingFlags,userNotSpecified:userNotSpecified,invalidUser:invalidUser,bootstrapOldFormat:bootstrapOldFormat,bootstrapInvalid:bootstrapInvalid,deprecated:deprecated,httpErrorMessage:httpErrorMessage,httpUnavailable:httpUnavailable,identifyDisabled:identifyDisabled,streamClosing:streamClosing,streamConnecting:streamConnecting,streamError:streamError,unknownOption:unknownOption,wrongOptionType:wrongOptionType,wrongOptionTypeBoolean:wrongOptionTypeBoolean,optionBelowMinimum:optionBelowMinimum,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents,debugPostingDiagnosticEvent:debugPostingDiagnosticEvent});function EventProcessor(e,t,n){var r,o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,a={},s=(5<arguments.length&&void 0!==arguments[5]?arguments[5]:null)||EventSender(e,n,t),u=t.eventsUrl+"/events/bulk/"+n,c=EventSummarizer(),l=UserFilter(t),f=t.inlineUsersInEvents,d=t.samplingInterval,v=t.eventCapacity,g=t.flushInterval,p=t.logger,m=[],y=0,h=!1,b=!1;function E(){return 0===d||0===Math.floor(Math.random()*d)}function k(e){m.length<v?(m.push(e),b=!1):(b||(b=!0,p.warn(eventCapacityExceeded())),o&&o.incrementDroppedEvents())}return a.enqueue=function(e){if(!h){var t=!1,n=!1;if(c.summarizeEvent(e),"feature"===e.kind?E()&&(t=!!e.trackEvents,n=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>y&&e.debugEventsUntilDate>(new Date).getTime())}(e)):t=E(),t&&k(function(e){var t=extend({},e);return"alias"===e.kind||(f||"identify"===e.kind?t.user=l.filterUser(e.user):(t.userKey=e.user.key,delete t.user),"feature"===e.kind&&(delete t.trackEvents,delete t.debugEventsUntilDate)),t}(e)),n){var r=extend({},e,{kind:"debug"});r.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&&(!function(e){return!!o[e]}("error")?(t||console).error(e.message):this.emit("error",e))},e}var readyEvent="ready",successEvent="initialized",failureEvent="failed";function InitializationStateTracker(r){var t=!1,n=!1,o=null,e=null,i=new Promise(function(t){r.on(readyEvent,function e(){r.off(readyEvent,e),t()})}).catch(function(){});return{getInitializationPromise:function(){return e||(t?Promise.resolve():n?Promise.reject(o):e=new Promise(function(t,n){r.on(successEvent,function e(){r.off(successEvent,e),t()}),r.on(failureEvent,function e(t){r.off(failureEvent,e),n(t)})}))},getReadyPromise:function(){return i},signalSuccess:function(){t||n||(t=!0,r.emit(successEvent),r.emit(readyEvent))},signalFailure:function(e){t||n||(n=!0,o=e,r.emit(failureEvent,e),r.emit(readyEvent)),r.maybeReportError(e)}}}var InitializationState=InitializationStateTracker;function Store(n,r,o,i,a){var s={};function u(){var e="",t=i.getUser();return t&&(e=o||btoa(JSON.stringify(t))),"ld:"+r+":"+e}return s.loadFlags=function(){return n.get(u()).then(function(e){if(null==e)return null;try{var t=JSON.parse(e);if(t){var n=t.$schema;void 0===n||n<1?t=transformValuesToVersionedValues(t):delete t.$schema}return t}catch(e){return s.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},s.saveFlags=function(e){var t=extend({},e,{$schema:1});return n.set(u(),JSON.stringify(t)).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},s.clearFlags=function(){return n.clear(u()).catch(function(e){return a.warn(localStorageUnavailable()),Promise.reject(e)})},s}var streamReadTimeoutMillis=3e5;function Stream(o,i,a,t){var s,u=i.streamUrl,c=i.logger,e={},l=u+"/eval/"+a,f=i.useReport,d=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),D(!1),S(),k(n)}function k(e){m||(e?m=setTimeout(r,e):r())}function r(){var e;m=null;var t="",n={headers:v,readTimeoutMillis:streamReadTimeoutMillis};if(o.eventSourceFactory){for(var r in null!=h&&(t="h="+h),f?o.eventSourceAllowsReport?(e=l,n.method="REPORT",n.headers["Content-Type"]="application/json",n.body=JSON.stringify(y)):(e=u+"/ping/"+a,t=""):e=l+"/"+base64URLEncode(JSON.stringify(y)),n.headers=transformHeaders(n.headers,i),d&&(t=t+(t?"&":"")+"withReasons=true"),e=e+(t?"?":"")+t,S(),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 S(){p&&(c.info(streamClosing()),p.close(),p=null)}function D(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={};function r(t){b[t]=function(e){D(!(g=!1)),n[t]&&n[t](e)}}for(var o in n||{})r(o);k()},e.disconnect=function(){clearTimeout(m),m=null,S()},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(s,u,a){var c=u.baseUrl,l=u.useReport,f=u.evaluationReasons,d=u.logger,e={},v={};function g(e,t){if(!s.httpRequest)return new Promise(function(e,t){t(new LDFlagFetchError(httpUnavailable()))});var n=t?"REPORT":"GET",r=getLDHeaders(s,u);t&&(r["Content-Type"]=jsonContentType);var o=v[e];o||(o=promiseCoalescer(function(){delete v[e]}),v[e]=o);var i=s.httpRequest(n,e,transformHeaders(r,u),t),a=i.promise.then(function(e){if(200!==e.status)return Promise.reject(getResponseError(e));if(e.header("content-type")&&e.header("content-type").substring(0,jsonContentType.length)===jsonContentType)return JSON.parse(e.body);var t=invalidContentType(e.header("content-type")||"");return Promise.reject(new LDFlagFetchError(t))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return o.addPromise(a,function(){i.cancel&&i.cancel()}),o.resultPromise}return e.fetchJSON=function(e){return g(c+e,null)},e.fetchFlagSettings=function(e,t){var n,r,o,i="";return l?(r=[c,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(n=base64URLEncode(JSON.stringify(e)),r=[c,"/sdk/evalx/",a,"/users/",n].join("")),t&&(i="h="+t),f&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,d.debug(debugPolling(r)),g(r,o)},e}function Identity(e,n){var r,t={};return t.setUser=function(e){var t=r&&clone(r);(r=sanitizeUser(e))&&n&&n(clone(r),t)},t.getUser=function(){return r?clone(r):null},e&&t.setUser(e),t}var ldUserIdKey="ld:$anonUserId";function UserValidator(r,o){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var n=clone(e);return null!==n.key&&void 0!==n.key?(n.key=n.key.toString(),Promise.resolve(n)):n.anonymous?(r?r.get(ldUserIdKey).catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return n.key=e,n;var t=v1_1();return function(e){return r?r.set(ldUserIdKey,e).catch(function(){o.warn(localStorageUnavailableForUserId())}):Promise.resolve()}(n.key=t).then(function(){return n})}):Promise.reject(new LDInvalidUserError(invalidUser()))},e}var baseOptionDefs={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},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}};function validate(e,t,n,r){var a=extend({logger:{default:r}},baseOptionDefs,n),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function s(e){onNextTick(function(){t&&t.maybeReportError(new LDInvalidArgumentError(e))})}var i,u,c,l,f=extend({},e||{});function d(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var t=_typeof(e);return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"}}return i=f,Object.keys(o).forEach(function(e){if(void 0!==i[e]){var t=o[e];r&&r.warn(deprecated(e,t)),t&&(void 0===i[t]&&(i[t]=i[e]),delete i[e])}}),u=extend({},f),Object.keys(a).forEach(function(e){void 0!==u[e]&&null!==u[e]||(u[e]=a[e]&&a[e].default)}),l=extend({},c=f=u),Object.keys(c).forEach(function(e){var t=c[e];if(null!=t){var n=a[e];if(void 0===n)s(unknownOption(e));else{var r=n.type||d(n.default);if("any"!==r){var o=r.split("|"),i=d(t);o.indexOf(i)<0?"boolean"===r?(l[e]=!!t,s(wrongOptionTypeBoolean(e,i))):(s(wrongOptionType(e,r,i)),l[e]=n.default):"number"===i&&void 0!==n.minimum&&t<n.minimum&&(s(optionBelowMinimum(e,t,n.minimum)),l[e]=n.minimum)}}}}),f=l}var configuration=Object.freeze({__proto__:null,baseOptionDefs:baseOptionDefs,validate:validate}),baseOptionDefs$1=configuration.baseOptionDefs;function DiagnosticId(e){var t={diagnosticId:v1_1()};return e&&(t.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),t}function DiagnosticsAccumulator(e){var t,n,r,o;function i(e){t=e,r=n=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:t,droppedEvents:n,eventsInLastBatch:r,streamInits:o}},setProps:function(e){t=e.dataSinceDate,n=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){n++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,t,n){var r={timestamp:e,failed:t,durationMillis:n};o.push(r)},reset:i}}function DiagnosticsManager(t,e,n,r,o,i){var a,s,u=!!t.diagnosticUseCombinedEvent,c="ld:"+r+":$diagnostics",l=o.eventsUrl+"/events/diagnostic/"+r,f=o.diagnosticRecordingInterval,d=e,v=!!o.streaming,g={};function p(){return{sdk:function(){var e=_objectSpread2({},t.diagnosticSdkData);o.wrapperName&&(e.wrapperName=o.wrapperName);o.wrapperVersion&&(e.wrapperVersion=o.wrapperVersion);return e}(),configuration:{customBaseURI:o.baseUrl!==baseOptionDefs$1.baseUrl.default,customStreamURI:o.streamUrl!==baseOptionDefs$1.streamUrl.default,customEventsURI:o.eventsUrl!==baseOptionDefs$1.eventsUrl.default,eventsCapacity:o.eventCapacity,eventsFlushIntervalMillis:o.flushInterval,reconnectTimeMillis:o.streamReconnectDelay,streamingDisabled:!v,allAttributesPrivate:!!o.allAttributesPrivate,inlineUsersInEvents:!!o.inlineUsersInEvents,diagnosticRecordingIntervalMillis:o.diagnosticRecordingInterval,usingSecureMode:!!o.hash,bootstrapMode:!!o.bootstrap,fetchGoalsDisabled:!o.fetchGoals,allowFrequentDuplicateEvents:!!o.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!o.sendEventsOnlyForVariation,autoAliasingOptOut:!!o.autoAliasingOptOut},platform:t.diagnosticPlatformData}}function m(e){o.logger&&o.logger.debug(messages.debugPostingDiagnosticEvent(e)),n.sendEvents(e,l,!0).then(function(){}).catch(function(){})}function y(){m(function(){var e=(new Date).getTime(),t=_objectSpread2({kind:u?"diagnostic-combined":"diagnostic",id:i,creationDate:e},d.getProps());return u&&(t=_objectSpread2({},t,{},p())),d.reset(e),t}()),s=setTimeout(y,f),a=(new Date).getTime(),u&&function(){if(t.localStorage){var e=_objectSpread2({},d.getProps());t.localStorage.set(c,JSON.stringify(e),function(){})}}()}return g.start=function(){u?function(n){if(!t.localStorage)return n(!1);t.localStorage.get(c).then(function(e){if(e)try{var t=JSON.parse(e);d.setProps(t),a=t.dataSinceDate}catch(e){}n(!0)}).catch(function(){n(!1)})}(function(e){if(e){var t=(a||0)+f,n=(new Date).getTime();t<=n?y():s=setTimeout(y,t-n)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,f)}):(m(_objectSpread2({kind:"diagnostic-init",id:i,creationDate:d.getProps().dataSinceDate},p())),s=setTimeout(y,f))},g.stop=function(){s&&clearTimeout(s)},g.setStreaming=function(e){v=e},g}var diagnosticEvents={DiagnosticId:DiagnosticId,DiagnosticsAccumulator:DiagnosticsAccumulator,DiagnosticsManager:DiagnosticsManager},diagnosticEvents_1=diagnosticEvents.DiagnosticId,diagnosticEvents_2=diagnosticEvents.DiagnosticsAccumulator,diagnosticEvents_3=diagnosticEvents.DiagnosticsManager;function createConsoleLogger(e,t){var i,a=["debug","info","warn","error"];i=null!=t?""===t?"":t+" ":"LD: ";var s=0;e&&(s="none"===e?100:a.indexOf(e));var n={};function r(e,t,n){if(s<=e&&console){var r=console[t];if(r){var o=e<a.length?a[e]:"?";r.call(console,i+"["+o+"] "+n)}}}return n.debug=function(e){return r(0,"log",e)},n.info=function(e){return r(1,"info",e)},n.warn=function(e){return r(2,"warn",e)},n.error=function(e){return r(3,"error",e)},n}var changeEvent="change",internalChangeEvent="internal-change";function initialize(e,t,n,i,r){var a,o,s,u,c=function(){if(n&&n.logger)return n.logger;return r&&r.logger&&r.logger.default||createConsoleLogger("warn")}(),l=EventEmitter(c),f=InitializationState(l),d=validate(n,l,r,c),v=d.sendEvents,g=e,p=d.hash,m=EventSender(i,g,d),y=d.sendEvents&&!d.diagnosticOptOut,h=y?diagnosticEvents_1(g):null,b=y?diagnosticEvents_2((new Date).getTime()):null,E=y?diagnosticEvents_3(i,b,m,g,d,h):null,k=Stream(i,d,g,b),S=d.eventProcessor||EventProcessor(i,d,g,b,l,m),D=Requestor(i,d,g),w={},U={},P=d.streaming,O=!1,I=!1,T=!0,L=d.stateProvider,C=Identity(null,function(e,t){(function(e){if(L)return;e&&F({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!d.autoAliasingOptOut&&t&&t.anonymous&&e&&!e.anonymous&&A(e,t)}),j=UserValidator(i.localStorage,c);function F(e){if(g&&!(L&&L.enqueueEvent&&L.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(T&&(c.warn(eventWithoutUser()),T=!1));T=!1}!v||I||i.isDoNotTrack()||(c.debug(debugEnqueueingEvent(e.kind)),S.enqueue(e))}}function R(e,t,n,r){var o=C.getUser(),i=new Date,a=t?t.value:null;if(!d.allowFrequentDuplicateEvents){var s=JSON.stringify(a)+(o&&o.key?o.key:"")+e,u=w[s];if(u&&i-u<3e5)return;w[s]=i}var c={kind:"feature",key:e,user:o,value:a,variation:t?t.variationIndex:null,default:n,creationDate:i.getTime()};o&&o.anonymous&&(c.contextKind=N(o));var l=U[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&t&&(c.reason=t.reason),F(c)}function _(e,t,n,r){var o;if(U&&objectHasOwnProperty(U,e)&&U[e]&&!U[e].deleted){var i=U[e];o=x(i),null!==i.value&&void 0!==i.value||(o.value=t)}else o={value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return n&&R(e,o,t,r),o}function x(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function N(e){return e.anonymous?"anonymousUser":"user"}function A(e,t){L||e&&t&&F({kind:"alias",key:e.key,contextKind:N(e),previousKey:t.key,previousContextKind:N(t),creationDate:(new Date).getTime()})}function V(){o=!0,C.getUser()&&k.connect(C.getUser(),p,{ping:function(){c.debug(debugStreamPing());var t=C.getUser();D.fetchFlagSettings(t,p).then(function(e){deepEquals(t,C.getUser())&&H(e||{})}).catch(function(e){l.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){var t=JSON.parse(e.data);c.debug(debugStreamPut()),H(t)},patch:function(e){var t=JSON.parse(e.data),n=U[t.key];if(!n||!n.version||!t.version||n.version<t.version){c.debug(debugStreamPatch(t.key));var r={},o=extend({},t);delete o.key;var i=x(U[t.key]=o);r[t.key]=n?{previous:n.value,current:i}:{current:i},M(r)}else c.debug(debugStreamPatchIgnored(t.key))},delete:function(e){var t=JSON.parse(e.data);if(!U[t.key]||U[t.key].version<t.version){c.debug(debugStreamDelete(t.key));var n={};U[t.key]&&!U[t.key].deleted&&(n[t.key]={previous:U[t.key].value}),U[t.key]={version:t.version,deleted:!0},M(n)}else c.debug(debugStreamDeleteIgnored(t.key))}})}function q(){o&&(k.disconnect(),o=!1)}function H(e){var t={};if(!e)return Promise.resolve();for(var n in U)objectHasOwnProperty(U,n)&&U[n]&&(e[n]&&!deepEquals(e[n].value,U[n].value)?t[n]={previous:U[n].value,current:x(e[n])}:e[n]&&!e[n].deleted||(t[n]={previous:U[n].value}));for(var r in e)objectHasOwnProperty(e,r)&&e[r]&&(!U[r]||U[r].deleted)&&(t[r]={current:x(e[r])});return U=_objectSpread2({},e),M(t).catch(function(){})}function M(o){var e=Object.keys(o);if(0<e.length){var i={};e.forEach(function(e){var t=o[e].current,n=t?t.value:void 0,r=o[e].previous;l.emit(changeEvent+":"+e,n,r),i[e]=t?{current:n,previous:r}:{previous:r}}),l.emit(changeEvent,i),l.emit(internalChangeEvent,U),d.sendEventsOnlyForVariation||L||e.forEach(function(e){R(e,o[e].current)})}return a&&u?u.saveFlags(U).catch(function(){return null}):Promise.resolve()}function z(){var e=P||s&&void 0===P;e&&!o?V():!e&&o&&q(),E&&E.setStreaming(e)}function K(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}if(i.localStorage&&(u=new Store(i.localStorage,g,p,C,c)),"string"==typeof d.bootstrap&&"LOCALSTORAGE"===d.bootstrap.toUpperCase()&&(u?a=!0:c.warn(localStorageUnavailable())),"object"===_typeof(d.bootstrap)&&(U=function(n){var e=Object.keys(n),r="$flagsState",o=n[r];!o&&e.length&&c.warn(bootstrapOldFormat()),!1===n.$valid&&c.warn(bootstrapInvalid());var i={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var t={value:n[e]};o&&o[e]?t=extend(t,o[e]):t.version=0,i[e]=t}}),i}(d.bootstrap)),L){var B=L.getInitialState();B?J(B):L.on("init",J),L.on("update",function(e){e.user&&C.setUser(e.user);e.flags&&H(e.flags)})}else(e?j.validateUser(t).then(function(e){return C.setUser(e),"object"===_typeof(d.bootstrap)?$():a?u.loadFlags().catch(function(){return null}).then(function(e){return null==e?(U={},D.fetchFlagSettings(C.getUser(),p).then(function(e){return H(e||{})}).then($).catch(function(e){G(new LDFlagFetchError(errorFetchingFlags(e)))})):(U=e,onNextTick($),D.fetchFlagSettings(C.getUser(),p).then(function(e){return H(e)}).catch(function(e){return l.maybeReportError(e)}))}):D.fetchFlagSettings(C.getUser(),p).then(function(e){U=e||{},$()}).catch(function(e){U={},G(e)})}):Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()))).catch(G);function J(e){g=e.environment,C.setUser(e.user),U=_objectSpread2({},e.flags),onNextTick($)}function $(){c.info(clientInitialized()),O=!0,z(),f.signalSuccess()}function G(e){f.signalFailure(e)}return{client:{waitForInitialization:function(){return f.getInitializationPromise()},waitUntilReady:function(){return f.getReadyPromise()},identify:function(e,r,t){return I?wrapPromiseCallback(Promise.resolve({}),t):L?(c.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(U)),t)):wrapPromiseCallback((a&&u?u.clearFlags():Promise.resolve()).then(function(){return j.validateUser(e)}).then(function(n){return D.fetchFlagSettings(n,r).then(function(e){var t=transformVersionedValuesToValues(e);return C.setUser(n),p=r,e?H(e).then(function(){return t}):t})}).then(function(e){return o&&V(),e}).catch(function(e){return l.maybeReportError(e),Promise.reject(e)}),t)},getUser:function(){return C.getUser()},variation:function(e,t){return _(e,t,!0,!1).value},variationDetail:function(e,t){return _(e,t,!0,!0)},track:function(e,t,n){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&c.warn(unknownCustomEventKey(e));var r=C.getUser(),o={kind:"custom",key:e,user:r,url:i.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=N(r)),null!=t&&(o.data=t),null!=n&&(o.metricValue=n),F(o)}else l.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},alias:A,on:function(e,t,n){K(e)?(s=!0,O&&z(),l.on(e,t,n)):l.on.apply(l,arguments)},off:function(e){if(l.off.apply(l,arguments),K(e)){var t=!1;l.getEvents().forEach(function(e){K(e)&&0<l.getEventListenerCount(e)&&(t=!0)}),t||(s=!1,o&&void 0===P&&q())}},setStreaming:function(e){var t=null===e?void 0:e;t!==P&&(P=t,z())},flush:function(e){return wrapPromiseCallback(v?S.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!U)return e;for(var t in U)objectHasOwnProperty(U,t)&&(e[t]=_(t,null,!d.sendEventsOnlyForVariation).value);return e},close:function(e){if(I)return wrapPromiseCallback(Promise.resolve(),e);function t(){I=!0,U={}}return wrapPromiseCallback(Promise.resolve().then(function(){if(q(),E&&E.stop(),v)return S.stop(),S.flush()}).then(t).catch(t),e)}},options:d,emitter:l,ident:C,logger:c,requestor:D,start:function(){v&&(E&&E.start(),S.start())},enqueueEvent:F,getFlagsInternal:function(){return U},getEnvironmentId:function(){return g},internalChangeEventName:internalChangeEvent}}var version="3.4.0";exports.createConsoleLogger=createConsoleLogger,exports.errors=errors,exports.initialize=initialize,exports.messages=messages,exports.utils=utils,exports.version=version; | ||
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function ownKeys(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function _objectSpread2(n){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(t,!0).forEach(function(e){_defineProperty(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):ownKeys(t).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}function _iterableToArray(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function createCustomError(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}Object.defineProperty(exports,"__esModule",{value:!0});var LDUnexpectedResponseError=createCustomError("LaunchDarklyUnexpectedResponseError"),LDInvalidEnvironmentIdError=createCustomError("LaunchDarklyInvalidEnvironmentIdError"),LDInvalidUserError=createCustomError("LaunchDarklyInvalidUserError"),LDInvalidEventKeyError=createCustomError("LaunchDarklyInvalidEventKeyError"),LDInvalidArgumentError=createCustomError("LaunchDarklyInvalidArgumentError"),LDFlagFetchError=createCustomError("LaunchDarklyFlagFetchError");function isHttpErrorRecoverable(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var errors=Object.freeze({__proto__:null,LDUnexpectedResponseError:LDUnexpectedResponseError,LDInvalidEnvironmentIdError:LDInvalidEnvironmentIdError,LDInvalidUserError:LDInvalidUserError,LDInvalidEventKeyError:LDInvalidEventKeyError,LDInvalidArgumentError:LDInvalidArgumentError,LDFlagFetchError:LDFlagFetchError,isHttpErrorRecoverable:isHttpErrorRecoverable}),fromByteArray_1=fromByteArray,lookup=[],revLookup=[],code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,n,t){for(var r,o=[],i=n;i<t;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(tripletToBase64(r));return o.join("")}function fromByteArray(e){for(var n,t=e.length,r=t%3,o=[],i=16383,a=0,s=t-r;a<s;a+=i)o.push(encodeChunk(e,a,s<a+i?s:a+i));return 1==r?(n=e[t-1],o.push(lookup[n>>2]+lookup[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(lookup[n>>10]+lookup[n>>4&63]+lookup[n<<2&63]+"=")),o.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63;var isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=isArray(n),s=isArray(t);if(a&&s){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=s)return!1;var u=n instanceof Date,c=t instanceof Date;if(u!=c)return!1;if(u&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var d=keyList(n);if((o=d.length)!==keyList(t).length)return!1;for(r=o;0!=r--;)if(!hasProp.call(t,d[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=d[r]],t[i]))return!1;return!0}return n!=n&&t!=t},userAttrsToStringify=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function btoa(e){var n=unescape(encodeURIComponent(e));return fromByteArray_1(stringToBytes(n))}function stringToBytes(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}function base64URLEncode(e){return btoa(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function clone(e){return JSON.parse(JSON.stringify(e))}function deepEquals(e,n){return fastDeepEqual(e,n)}function onNextTick(e){setTimeout(e,0)}function wrapPromiseCallback(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function transformValuesToVersionedValues(e){var n={};for(var t in e)objectHasOwnProperty(e,t)&&(n[t]={value:e[t],version:0});return n}function transformVersionedValuesToValues(e){var n={};for(var t in e)objectHasOwnProperty(e,t)&&(n[t]=e[t].value);return n}function chunkUserEventsForUrl(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=base64URLEncode(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function getLDUserAgentString(e){var n=e.version||"3.5.0";return e.userAgent+"/"+n}function getLDHeaders(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":getLDUserAgentString(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function transformHeaders(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(_objectSpread2({},e)):e}function extend(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return _objectSpread2({},e,{},n)},{})}function objectHasOwnProperty(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function sanitizeUser(e){if(!e)return e;var n;for(var t in userAttrsToStringify){var r=userAttrsToStringify[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||_objectSpread2({},e))[r]=String(o))}return n||e}var utils=Object.freeze({__proto__:null,btoa:btoa,base64URLEncode:base64URLEncode,clone:clone,deepEquals:deepEquals,onNextTick:onNextTick,wrapPromiseCallback:wrapPromiseCallback,transformValuesToVersionedValues:transformValuesToVersionedValues,transformVersionedValuesToValues:transformVersionedValuesToValues,chunkUserEventsForUrl:chunkUserEventsForUrl,getLDUserAgentString:getLDUserAgentString,getLDHeaders:getLDHeaders,transformHeaders:transformHeaders,extend:extend,objectHasOwnProperty:objectHasOwnProperty,sanitizeUser:sanitizeUser});function createCommonjsModule(e,n){return e(n={exports:{}},n.exports),n.exports}for(var rngBrowser=createCommonjsModule(function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}),byteToHex=[],i$1=0;i$1<256;++i$1)byteToHex[i$1]=(i$1+256).toString(16).substr(1);function bytesToUuid(e,n){var t=n||0,r=byteToHex;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}var _nodeId,_clockseq,bytesToUuid_1=bytesToUuid,_lastMSecs=0,_lastNSecs=0;function v1(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||_nodeId,a=void 0!==e.clockseq?e.clockseq:_clockseq;if(null==i||null==a){var s=rngBrowser();null==i&&(i=_nodeId=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==a&&(a=_clockseq=16383&(s[6]<<8|s[7]))}var u=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:_lastNSecs+1,l=u-_lastMSecs+(c-_lastNSecs)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||_lastMSecs<u)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=u,_clockseq=a;var f=(1e4*(268435455&(u+=122192928e5))+(_lastNSecs=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var d=u/4294967296*1e4&268435455;o[r++]=d>>>8&255,o[r++]=255&d,o[r++]=d>>>24&15|16,o[r++]=d>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var v=0;v<6;++v)o[r+v]=i[v];return n||bytesToUuid_1(o)}var v1_1=v1,MAX_URL_LENGTH=2e3;function EventSender(s,e,u){var t="/a/"+e+".gif",c=extend({"Content-Type":"application/json"},getLDHeaders(s,u)),l=s.httpFallbackPing,f={};return f.sendChunk=function(e,r,o,n){var i=JSON.stringify(e),a=o?null:v1_1();return n?function n(t){var e=o?c:extend({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return s.httpRequest("POST",r,transformHeaders(e,u),i).promise.then(function(e){if(e)return 400<=e.status&&isHttpErrorRecoverable(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(r+t+"?d="+base64URLEncode(i)),Promise.resolve())},f.sendEvents=function(e,n,t){if(!s.httpRequest)return Promise.resolve();var r,o=s.httpAllowsPost();r=o?[e]:chunkUserEventsForUrl(MAX_URL_LENGTH-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(f.sendChunk(r[a],n,t,o));return Promise.all(i)},f}function EventSummarizer(){var e={},a=0,s=0,u={};return e.summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=u[n];t?t.count=t.count+1:u[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>s&&(s=e.creationDate)}},e.getSummary=function(){var e={},n=!0;for(var t in u){var r=u[t],o=e[r.key];o||(o={default:r.default,counters:[]},e[r.key]=o);var i={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),n=!1}return n?null:{startDate:a,endDate:s,features:e}},e.clearSummary=function(){s=a=0,u={}},e}function UserFilter(e){var n={},u=e.allAttributesPrivate,c=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(r,o){return Object.keys(r).reduce(function(e,n){var t=e;return o(n)&&(!function(e){return!l[e]&&(u||-1!==i.indexOf(e)||-1!==c.indexOf(e))}(n)?t[0][n]=r[n]:t[1][n]=!0),t},[{},{}])}var i=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],o=t[1];if(e.custom){var a=n(e.custom,function(){return!0});r.custom=a[0],o=extend({},o,a[1])}var s=Object.keys(o);return s.length&&(s.sort(),r.privateAttrs=s),r},n}function errorString(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var clientInitialized=function(){return"LaunchDarkly client initialized"},docLink=" Please see https://docs.launchdarkly.com/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},bootstrapOldFormat=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+docLink},bootstrapInvalid=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},httpErrorMessage=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(isHttpErrorRecoverable(e)?t:"giving up permanently")},httpUnavailable=function(){return"Cannot make HTTP requests in this environment."+docLink},identifyDisabled=function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing=function(){return"Closing stream connection"},streamConnecting=function(e){return"Opening stream connection to "+e},streamError=function(e,n){return"Error on stream connection: "+errorString(e)+", will continue retrying every "+n+" milliseconds."},unknownOption=function(e){return'Ignoring unknown config option "'+e+'"'},wrongOptionType=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},wrongOptionTypeBoolean=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},optionBelowMinimum=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},debugPolling=function(e){return"polling for feature flags at "+e},debugStreamPing=function(){return"received ping message from stream"},debugStreamPut=function(){return"received streaming update for all flags"},debugStreamPatch=function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamDelete=function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugEnqueueingEvent=function(e){return'enqueueing "'+e+'" event'},debugPostingEvents=function(e){return"sending "+e+" events"},debugPostingDiagnosticEvent=function(e){return"sending diagnostic event ("+e.kind+")"},messages=Object.freeze({__proto__:null,clientInitialized:clientInitialized,clientNotReady:clientNotReady,eventCapacityExceeded:eventCapacityExceeded,eventWithoutUser:eventWithoutUser,invalidContentType:invalidContentType,invalidKey:invalidKey,localStorageUnavailable:localStorageUnavailable,networkError:networkError,unknownCustomEventKey:unknownCustomEventKey,environmentNotFound:environmentNotFound,environmentNotSpecified:environmentNotSpecified,errorFetchingFlags:errorFetchingFlags,userNotSpecified:userNotSpecified,invalidUser:invalidUser,bootstrapOldFormat:bootstrapOldFormat,bootstrapInvalid:bootstrapInvalid,deprecated:deprecated,httpErrorMessage:httpErrorMessage,httpUnavailable:httpUnavailable,identifyDisabled:identifyDisabled,streamClosing:streamClosing,streamConnecting:streamConnecting,streamError:streamError,unknownOption:unknownOption,wrongOptionType:wrongOptionType,wrongOptionTypeBoolean:wrongOptionTypeBoolean,optionBelowMinimum:optionBelowMinimum,debugPolling:debugPolling,debugStreamPing:debugStreamPing,debugStreamPut:debugStreamPut,debugStreamPatch:debugStreamPatch,debugStreamPatchIgnored:debugStreamPatchIgnored,debugStreamDelete:debugStreamDelete,debugStreamDeleteIgnored:debugStreamDeleteIgnored,debugEnqueueingEvent:debugEnqueueingEvent,debugPostingEvents:debugPostingEvents,debugPostingDiagnosticEvent:debugPostingDiagnosticEvent});function EventProcessor(e,n,t){var r,o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null,a={},s=(5<arguments.length&&void 0!==arguments[5]?arguments[5]:null)||EventSender(e,t,n),u=n.eventsUrl+"/events/bulk/"+t,c=EventSummarizer(),l=UserFilter(n),f=n.inlineUsersInEvents,d=n.samplingInterval,v=n.eventCapacity,g=n.flushInterval,p=n.logger,m=[],y=0,h=!1,b=!1;function E(){return 0===d||0===Math.floor(Math.random()*d)}function k(e){m.length<v?(m.push(e),b=!1):(b||(b=!0,p.warn(eventCapacityExceeded())),o&&o.incrementDroppedEvents())}return a.enqueue=function(e){if(!h){var n=!1,t=!1;if(c.summarizeEvent(e),"feature"===e.kind?E()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>y&&e.debugEventsUntilDate>(new Date).getTime())}(e)):n=E(),n&&k(function(e){var n=extend({},e);return"alias"===e.kind||(f||"identify"===e.kind?n.user=l.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}(e)),t){var r=extend({},e,{kind:"debug"});r.user=l.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,k(r)}}},a.flush=function(){if(h)return Promise.resolve();var e=m,n=c.getSummary();return c.clearSummary(),n&&(n.kind="summary",e.push(n)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(m=[],p.debug(debugPostingEvents(e.length)),s.sendEvents(e,u).then(function(e){e&&(e.serverTime&&(y=e.serverTime),isHttpErrorRecoverable(e.status)||(h=!0),400<=e.status&&onNextTick(function(){i.maybeReportError(new LDUnexpectedResponseError(httpErrorMessage(e.status,"event posting","some events were dropped")))}))}))},a.start=function(){r=setTimeout(function e(){a.flush(),r=setTimeout(e,g)},g)},a.stop=function(){clearTimeout(r)},a}function EventEmitter(n){var e={},o={};return e.on=function(e,n,t){o[e]=o[e]||[],o[e]=o[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===n&&o[e][r].context===t&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var n=o[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(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(!function(e){return!!o[e]}("error")?(n||console).error(e.message):this.emit("error",e))},e}var readyEvent="ready",successEvent="initialized",failureEvent="failed";function InitializationStateTracker(r){var n=!1,t=!1,o=null,e=null,i=new Promise(function(n){r.on(readyEvent,function e(){r.off(readyEvent,e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(o):e=new Promise(function(n,t){r.on(successEvent,function e(){r.off(successEvent,e),n()}),r.on(failureEvent,function e(n){r.off(failureEvent,e),t(n)})}))},getReadyPromise:function(){return i},signalSuccess:function(){n||t||(n=!0,r.emit(successEvent),r.emit(readyEvent))},signalFailure:function(e){n||t||(t=!0,o=e,r.emit(failureEvent,e),r.emit(readyEvent)),r.maybeReportError(e)}}}var InitializationState=InitializationStateTracker;function PersistentFlagStore(t,r,o,i){var a={};function s(){var e="",n=i.getUser();return n&&(e=o||btoa(JSON.stringify(n))),"ld:"+r+":"+e}return a.loadFlags=function(){return t.get(s()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=transformValuesToVersionedValues(n):delete n.$schema}return n}catch(e){return a.clearFlags().then(function(){return null})}})},a.saveFlags=function(e){var n=extend({},e,{$schema:1});return t.set(s(),JSON.stringify(n))},a.clearFlags=function(){return t.clear(s())},a}function PersistentStorage(r,n){function o(e){t||(t=!0,n.warn(localStorageUnavailable(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){o(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){o(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){o(e),n(!1)}):n(!1)})},e}var streamReadTimeoutMillis=3e5;function Stream(o,i,a,n){var s,u=i.streamUrl,c=i.logger,e={},l=u+"/eval/"+a,f=i.useReport,d=i.evaluationReasons,t=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,t)),g=!0),S(!1),D(),k(t)}function k(e){m||(e?m=setTimeout(r,e):r())}function r(){var e;m=null;var n="",t={headers:v,readTimeoutMillis:streamReadTimeoutMillis};if(o.eventSourceFactory){for(var r in null!=h&&(n="h="+h),f?o.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(y)):(e=u+"/ping/"+a,n=""):e=l+"/"+base64URLEncode(JSON.stringify(y)),t.headers=transformHeaders(t.headers,i),d&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,D(),c.info(streamConnecting(e)),s=(new Date).getTime(),p=o.eventSourceFactory(e,t),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&&n&&n.recordStreamInit(s,!e,(new Date).getTime()-s),s=null}return e.connect=function(e,n,t){y=e,h=n,b={};function r(n){b[n]=function(e){S(!(g=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);k()},e.disconnect=function(){clearTimeout(m),m=null,D()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function promiseCoalescer(t){var r,o,i,a,e={addPromise:function(n,e){r=n,o&&o(),o=e,n.then(function(e){r===n&&(i(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}};return e.resultPromise=new Promise(function(e,n){i=e,a=n}),e}var jsonContentType="application/json";function getResponseError(e){return 404===e.status?new LDInvalidEnvironmentIdError(environmentNotFound()):new LDFlagFetchError(errorFetchingFlags(e.statusText||String(e.status)))}function Requestor(s,u,a){var c=u.baseUrl,l=u.useReport,f=u.evaluationReasons,d=u.logger,e={},v={};function g(e,n){if(!s.httpRequest)return new Promise(function(e,n){n(new LDFlagFetchError(httpUnavailable()))});var t=n?"REPORT":"GET",r=getLDHeaders(s,u);n&&(r["Content-Type"]=jsonContentType);var o=v[e];o||(o=promiseCoalescer(function(){delete v[e]}),v[e]=o);var i=s.httpRequest(t,e,transformHeaders(r,u),n),a=i.promise.then(function(e){if(200!==e.status)return Promise.reject(getResponseError(e));if(e.header("content-type")&&e.header("content-type").substring(0,jsonContentType.length)===jsonContentType)return JSON.parse(e.body);var n=invalidContentType(e.header("content-type")||"");return Promise.reject(new LDFlagFetchError(n))},function(e){return Promise.reject(new LDFlagFetchError(networkError(e)))});return o.addPromise(a,function(){i.cancel&&i.cancel()}),o.resultPromise}return e.fetchJSON=function(e){return g(c+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return l?(r=[c,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=base64URLEncode(JSON.stringify(e)),r=[c,"/sdk/evalx/",a,"/users/",t].join("")),n&&(i="h="+n),f&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,d.debug(debugPolling(r)),g(r,o)},e}function Identity(e,t){var r,n={};return n.setUser=function(e){var n=r&&clone(r);(r=sanitizeUser(e))&&t&&t(clone(r),n)},n.getUser=function(){return r?clone(r):null},e&&n.setUser(e),n}var ldUserIdKey="ld:$anonUserId";function UserValidator(r){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new LDInvalidUserError(userNotSpecified()));var t=clone(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?r.get(ldUserIdKey).then(function(e){if(e)return t.key=e,t;var n=v1_1();return function(e){return r.set(ldUserIdKey,e)}(t.key=n).then(function(){return t})}):Promise.reject(new LDInvalidUserError(invalidUser()))},e}var logLevels=["debug","info","warn","error","none"];function commonBasicLogger(e,a){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")],u=!(!e||!e.destination),c=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",r=1;if(e&&e.level)for(var t=0;t<logLevels.length;t++)logLevels[t]===e.level&&(r=t);for(var o={},i=function(e){var n=logLevels[e];if("none"!==n)if(e<r)o[n]=function(){};else{var t=e;o[n]=function(){!function(e,n,t){if(!(t.length<1)){var r,o=u?n+": "+c:c;if(1!==t.length&&a){var i=_toConsumableArray(t);i[0]=o+i[0],r=a.apply(void 0,_toConsumableArray(i))}else r=o+t[0];try{s[e](r)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}(t,n,arguments)}}},l=0;l<logLevels.length;l++)i(l);return o}function validateLogger(n){logLevels.forEach(function(e){if("none"!==e&&(!n[e]||"function"!=typeof n[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")})}function createConsoleLogger(e,n){return commonBasicLogger({level:e,prefix:n})}var baseOptionDefs={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},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}};function validate(e,n,t,r){var a=extend({logger:{default:r}},baseOptionDefs,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function s(e){onNextTick(function(){n&&n.maybeReportError(new LDInvalidArgumentError(e))})}var i,u,c,l,f=extend({},e||{});function d(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=_typeof(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}return i=f,Object.keys(o).forEach(function(e){if(void 0!==i[e]){var n=o[e];r&&r.warn(deprecated(e,n)),n&&(void 0===i[n]&&(i[n]=i[e]),delete i[e])}}),u=extend({},f),Object.keys(a).forEach(function(e){void 0!==u[e]&&null!==u[e]||(u[e]=a[e]&&a[e].default)}),l=extend({},c=f=u),Object.keys(c).forEach(function(e){var n=c[e];if(null!=n){var t=a[e];if(void 0===t)s(unknownOption(e));else{var r=t.type||d(t.default);if("any"!==r){var o=r.split("|"),i=d(n);o.indexOf(i)<0?"boolean"===r?(l[e]=!!n,s(wrongOptionTypeBoolean(e,i))):(s(wrongOptionType(e,r,i)),l[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(s(optionBelowMinimum(e,n,t.minimum)),l[e]=t.minimum)}}}}),validateLogger((f=l).logger),f}var configuration=Object.freeze({__proto__:null,baseOptionDefs:baseOptionDefs,validate:validate}),baseOptionDefs$1=configuration.baseOptionDefs;function DiagnosticId(e){var n={diagnosticId:v1_1()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n}function DiagnosticsAccumulator(e){var n,t,r,o;function i(e){n=e,r=t=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:o}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};o.push(r)},reset:i}}function DiagnosticsManager(n,r,e,t,o,i,a){var s,u,c=!!n.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+o,d=i.diagnosticRecordingInterval,v=e,g=!!i.streaming,p={};function m(){return{sdk:function(){var e=_objectSpread2({},n.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:n.diagnosticPlatformData}}function y(e){i.logger&&i.logger.debug(messages.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function h(){y(function(){var e=(new Date).getTime(),n=_objectSpread2({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},v.getProps());return c&&(n=_objectSpread2({},n,{},m())),v.reset(e),n}()),u=setTimeout(h,d),s=(new Date).getTime(),c&&function(){if(r.isEnabled()){var e=_objectSpread2({},v.getProps());r.set(l,JSON.stringify(e))}}()}return p.start=function(){c?function(t){if(!r.isEnabled())return t(!1);r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),s=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(s||0)+d,t=(new Date).getTime();n<=t?h():u=setTimeout(h,n-t)}else 0===Math.floor(4*Math.random())?h():u=setTimeout(h,d)}):(y(_objectSpread2({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},m())),u=setTimeout(h,d))},p.stop=function(){u&&clearTimeout(u)},p.setStreaming=function(e){g=e},p}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(e,n,t,i,r){var a,o,s,u=function(){if(t&&t.logger)return t.logger;return r&&r.logger&&r.logger.default||createConsoleLogger("warn")}(),c=EventEmitter(u),l=InitializationState(c),f=validate(t,c,r,u),d=f.sendEvents,v=e,g=f.hash,p=PersistentStorage(i.localStorage,u),m=EventSender(i,v,f),y=f.sendEvents&&!f.diagnosticOptOut,h=y?diagnosticEvents_1(v):null,b=y?diagnosticEvents_2((new Date).getTime()):null,E=y?diagnosticEvents_3(i,p,b,m,v,f,h):null,k=Stream(i,f,v,b),D=f.eventProcessor||EventProcessor(i,f,v,b,c,m),S=Requestor(i,f,v),w={},P={},U=f.streaming,O=!1,L=!1,I=!0,T=f.stateProvider,C=Identity(null,function(e,n){(function(e){if(T)return;e&&F({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!f.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&V(e,n)}),_=UserValidator(p),j=p.isEnabled()?new PersistentFlagStore(p,v,g,C,u):null;function F(e){if(v&&!(T&&T.enqueueEvent&&T.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(I&&(u.warn(eventWithoutUser()),I=!1));I=!1}!d||L||i.isDoNotTrack()||(u.debug(debugEnqueueingEvent(e.kind)),D.enqueue(e))}}function R(e,n,t,r){var o=C.getUser(),i=new Date,a=n?n.value:null;if(!f.allowFrequentDuplicateEvents){var s=JSON.stringify(a)+(o&&o.key?o.key:"")+e,u=w[s];if(u&&i-u<3e5)return;w[s]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()};o&&o.anonymous&&(c.contextKind=N(o));var l=P[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),F(c)}function x(e,n,t,r){var o;if(P&&objectHasOwnProperty(P,e)&&P[e]&&!P[e].deleted){var i=P[e];o=A(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&R(e,o,n,r),o}function A(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function N(e){return e.anonymous?"anonymousUser":"user"}function V(e,n){T||e&&n&&F({kind:"alias",key:e.key,contextKind:N(e),previousKey:n.key,previousContextKind:N(n),creationDate:(new Date).getTime()})}function H(){o=!0,C.getUser()&&k.connect(C.getUser(),g,{ping:function(){u.debug(debugStreamPing());var n=C.getUser();S.fetchFlagSettings(n,g).then(function(e){deepEquals(n,C.getUser())&&M(e||{})}).catch(function(e){c.maybeReportError(new LDFlagFetchError(errorFetchingFlags(e)))})},put:function(e){var n=JSON.parse(e.data);u.debug(debugStreamPut()),M(n)},patch:function(e){var n=JSON.parse(e.data),t=P[n.key];if(!t||!t.version||!n.version||t.version<n.version){u.debug(debugStreamPatch(n.key));var r={},o=extend({},n);delete o.key;var i=A(P[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},z(r)}else u.debug(debugStreamPatchIgnored(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!P[n.key]||P[n.key].version<n.version){u.debug(debugStreamDelete(n.key));var t={};P[n.key]&&!P[n.key].deleted&&(t[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},z(t)}else u.debug(debugStreamDeleteIgnored(n.key))}})}function q(){o&&(k.disconnect(),o=!1)}function M(e){var n={};if(!e)return Promise.resolve();for(var t in P)objectHasOwnProperty(P,t)&&P[t]&&(e[t]&&!deepEquals(e[t].value,P[t].value)?n[t]={previous:P[t].value,current:A(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:P[t].value}));for(var r in e)objectHasOwnProperty(e,r)&&e[r]&&(!P[r]||P[r].deleted)&&(n[r]={current:A(e[r])});return P=_objectSpread2({},e),z(n).catch(function(){})}function z(o){var e=Object.keys(o);if(0<e.length){var i={};e.forEach(function(e){var n=o[e].current,t=n?n.value:void 0,r=o[e].previous;c.emit(changeEvent+":"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),c.emit(changeEvent,i),c.emit(internalChangeEvent,P),f.sendEventsOnlyForVariation||T||e.forEach(function(e){R(e,o[e].current)})}return a&&j?j.saveFlags(P):Promise.resolve()}function K(){var e=U||s&&void 0===U;e&&!o?H():!e&&o&&q(),E&&E.setStreaming(e)}function B(e){return e===changeEvent||e.substr(0,changeEvent.length+1)===changeEvent+":"}if("string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(j?a=!0:u.warn(localStorageUnavailable())),"object"===_typeof(f.bootstrap)&&(P=function(t){var e=Object.keys(t),r="$flagsState",o=t[r];!o&&e.length&&u.warn(bootstrapOldFormat()),!1===t.$valid&&u.warn(bootstrapInvalid());var i={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var n={value:t[e]};o&&o[e]?n=extend(n,o[e]):n.version=0,i[e]=n}}),i}(f.bootstrap)),T){var J=T.getInitialState();J?$(J):T.on("init",$),T.on("update",function(e){e.user&&C.setUser(e.user);e.flags&&M(e.flags)})}else(e?_.validateUser(n).then(function(e){return C.setUser(e),"object"===_typeof(f.bootstrap)?G():a?j.loadFlags().then(function(e){return null==e?(P={},S.fetchFlagSettings(C.getUser(),g).then(function(e){return M(e||{})}).then(G).catch(function(e){W(new LDFlagFetchError(errorFetchingFlags(e)))})):(P=e,onNextTick(G),S.fetchFlagSettings(C.getUser(),g).then(function(e){return M(e)}).catch(function(e){return c.maybeReportError(e)}))}):S.fetchFlagSettings(C.getUser(),g).then(function(e){P=e||{},G()}).catch(function(e){P={},W(e)})}):Promise.reject(new LDInvalidEnvironmentIdError(environmentNotSpecified()))).catch(W);function $(e){v=e.environment,C.setUser(e.user),P=_objectSpread2({},e.flags),onNextTick(G)}function G(){u.info(clientInitialized()),O=!0,K(),l.signalSuccess()}function W(e){l.signalFailure(e)}return{client:{waitForInitialization:function(){return l.getInitializationPromise()},waitUntilReady:function(){return l.getReadyPromise()},identify:function(e,r,n){return L?wrapPromiseCallback(Promise.resolve({}),n):T?(u.warn(identifyDisabled()),wrapPromiseCallback(Promise.resolve(transformVersionedValuesToValues(P)),n)):wrapPromiseCallback((a&&j?j.clearFlags():Promise.resolve()).then(function(){return _.validateUser(e)}).then(function(t){return S.fetchFlagSettings(t,r).then(function(e){var n=transformVersionedValuesToValues(e);return C.setUser(t),g=r,e?M(e).then(function(){return n}):n})}).then(function(e){return o&&H(),e}).catch(function(e){return c.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return C.getUser()},variation:function(e,n){return x(e,n,!0,!1).value},variationDetail:function(e,n){return x(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&u.warn(unknownCustomEventKey(e));var r=C.getUser(),o={kind:"custom",key:e,user:r,url:i.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=N(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),F(o)}else c.maybeReportError(new LDInvalidEventKeyError(unknownCustomEventKey(e)))},alias:V,on:function(e,n,t){B(e)?(s=!0,O&&K(),c.on(e,n,t)):c.on.apply(c,arguments)},off:function(e){if(c.off.apply(c,arguments),B(e)){var n=!1;c.getEvents().forEach(function(e){B(e)&&0<c.getEventListenerCount(e)&&(n=!0)}),n||(s=!1,o&&void 0===U&&q())}},setStreaming:function(e){var n=null===e?void 0:e;n!==U&&(U=n,K())},flush:function(e){return wrapPromiseCallback(d?D.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!P)return e;for(var n in P)objectHasOwnProperty(P,n)&&(e[n]=x(n,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){if(L)return wrapPromiseCallback(Promise.resolve(),e);function n(){L=!0,P={}}return wrapPromiseCallback(Promise.resolve().then(function(){if(q(),E&&E.stop(),d)return D.stop(),D.flush()}).then(n).catch(n),e)}},options:f,emitter:c,ident:C,logger:u,requestor:S,start:function(){d&&(E&&E.start(),D.start())},enqueueEvent:F,getFlagsInternal:function(){return P},getEnvironmentId:function(){return v},internalChangeEventName:internalChangeEvent}}var version="3.5.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(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function r(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?t(i,!0).forEach((function(t){n(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):t(i).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(i,n))}))}return e}function i(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var o=i("LaunchDarklyUnexpectedResponseError"),a=i("LaunchDarklyInvalidEnvironmentIdError"),u=i("LaunchDarklyInvalidUserError"),s=i("LaunchDarklyInvalidEventKeyError"),c=i("LaunchDarklyInvalidArgumentError"),l=i("LaunchDarklyFlagFetchError");function f(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:o,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:s,LDInvalidArgumentError:c,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(b(e,o,o+16383>a?a:o+16383));1===r?(n=e[t-1],i.push(g[n>>2]+g[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],i.push(g[n>>10]+g[n>>4&63]+g[n<<2&63]+"="));return i.join("")},g=[],m=[],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",y=0,h=p.length;y<h;++y)g[y]=p[y],m[p.charCodeAt(y)]=y;function b(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(g[(i=r)>>18&63]+g[i>>12&63]+g[i>>6&63]+g[63&i]);return o.join("")}m["-".charCodeAt(0)]=62,m["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,w=Object.prototype.hasOwnProperty,D=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function S(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function O(e){return S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function P(e){return JSON.parse(JSON.stringify(e))}function U(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=k(n),u=k(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=E(n);if((i=v.length)!==E(t).length)return!1;for(r=i;0!=r--;)if(!w.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t}(e,n)}function I(e){setTimeout(e,0)}function j(e,n){var t=e.then((function(e){return n&&setTimeout((function(){n(null,e)}),0),e}),(function(e){if(!n)return Promise.reject(e);setTimeout((function(){n(e,null)}),0)}));return n?void 0:t}function R(e){var n={};for(var t in e)x(e,t)&&(n[t]={value:e[t],version:0});return n}function T(e){var n={};for(var t in e)x(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-=O(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function F(e){var n=e.version||"3.4.0";return e.userAgent+"/"+n}function C(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":F(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function L(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(r({},e)):e}function A(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return r({},e,{},n)}),{})}function x(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function q(e){if(!e)return e;var n;for(var t in D){var i=D[t],o=e[i];void 0!==o&&"string"!=typeof o&&((n=n||r({},e))[i]=String(o))}return n||e}var V=Object.freeze({__proto__:null,btoa:S,base64URLEncode:O,clone:P,deepEquals:U,onNextTick:I,wrapPromiseCallback:j,transformValuesToVersionedValues:R,transformVersionedValuesToValues:T,chunkUserEventsForUrl:N,getLDUserAgentString:F,getLDHeaders:C,transformHeaders:L,extend:A,objectHasOwnProperty:x,sanitizeUser:q});for(var _=function(e,n){return e(n={exports:{}},n.exports),n.exports}((function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}})),J=[],z=0;z<256;++z)J[z]=(z+256).toString(16).substr(1);var M,K,H=function(e,n){var t=n||0,r=J;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},B=0,$=0;var G=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||M,a=void 0!==e.clockseq?e.clockseq:K;if(null==o||null==a){var u=_();null==o&&(o=M=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=K=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:$+1,l=s-B+(c-$)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>B)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");B=s,$=c,K=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)};function X(e,n,t){var r="/a/"+n+".gif",i=A({"Content-Type":"application/json"},C(e,t)),o=e.httpFallbackPing,a={};return a.sendChunk=function(n,a,u,s){var c=JSON.stringify(n),l=u?null:G();return s?function n(r){var o=u?i:A({},i,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":l});return e.httpRequest("POST",a,L(o,t),c).promise.then((function(e){if(e)return e.status>=400&&f(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(o&&o(a+r+"?d="+O(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 W(){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 Q(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=A({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function Y(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var Z=function(){return"LaunchDarkly client initialized"},ee=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",ne=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},te=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},re=function(e){return'Expected application/json content type but got "'+e+'"'},ie=function(){return"localStorage is unavailable"},oe=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},ae=function(e){return"network error"+(e?" ("+e+")":"")},ue=function(e){return'Custom event "'+e+'" does not exist'},se=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+ee},ce=function(){return"No environment/client-side ID was specified."+ee},le=function(e){return"Error fetching flag settings: "+Y(e)},fe=function(){return"No user specified."+ee},ve=function(){return"Invalid user specified."+ee},de=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+ee},ge=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},me=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},pe=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},ye=function(){return"Cannot make HTTP requests in this environment."+ee},he=function(){return"identify() has no effect here; it must be called on the main client instance"},be=function(){return"Closing stream connection"},ke=function(e){return"Opening stream connection to "+e},Ee=function(e,n){return"Error on stream connection: "+Y(e)+", will continue retrying every "+n+" milliseconds."},we=function(e){return'Ignoring unknown config option "'+e+'"'},De=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Se=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Oe=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Pe=function(e){return"polling for feature flags at "+e},Ue=function(){return"received ping message from stream"},Ie=function(){return"received streaming update for all flags"},je=function(e){return'received streaming update for flag "'+e+'"'},Re=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Te=function(e){return'received streaming deletion for flag "'+e+'"'},Ne=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Fe=function(e){return'enqueueing "'+e+'" event'},Ce=function(e){return"sending "+e+" events"},Le=Object.freeze({__proto__:null,clientInitialized:Z,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:ne,eventWithoutUser:te,invalidContentType:re,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ie,localStorageUnavailableForUserId:oe,networkError:ae,unknownCustomEventKey:ue,environmentNotFound:se,environmentNotSpecified:ce,errorFetchingFlags:le,userNotSpecified:fe,invalidUser:ve,bootstrapOldFormat:de,bootstrapInvalid:ge,deprecated:me,httpErrorMessage:pe,httpUnavailable:ye,identifyDisabled:he,streamClosing:be,streamConnecting:ke,streamError:Ee,unknownOption:we,wrongOptionType:De,wrongOptionTypeBoolean:Se,optionBelowMinimum:Oe,debugPolling:Pe,debugStreamPing:Ue,debugStreamPut:Ie,debugStreamPatch:je,debugStreamPatchIgnored:Re,debugStreamDelete:Te,debugStreamDeleteIgnored:Ne,debugEnqueueingEvent:Fe,debugPostingEvents:Ce,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function Ae(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,i){var o={};function a(){var e="",i=r.getUser();return i&&(e=t||S(JSON.stringify(i))),"ld:"+n+":"+e}return o.loadFlags=function(){return e.get(a()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=R(n):delete n.$schema}return n}catch(e){return o.clearFlags().then((function(){return Promise.reject(e)}))}})).catch((function(e){return i.warn("localStorage is unavailable"),Promise.reject(e)}))},o.saveFlags=function(n){var t=A({},n,{$schema:1});return e.set(a(),JSON.stringify(t)).catch((function(e){return i.warn("localStorage is unavailable"),Promise.reject(e)}))},o.clearFlags=function(){return e.clear(a()).catch((function(e){return i.warn("localStorage is unavailable"),Promise.reject(e)}))},o}function Ve(e,n,t,r){var i,o=n.streamUrl,a=n.logger,u={},s=o+"/eval/"+t,c=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,v=C(e,n),d=!1,g=null,m=null,p=null,y=null,h=null;function b(e){d||(a.warn(Ee(e,f)),d=!0),D(!1),w(),k(f)}function k(e){m||(e?m=setTimeout(E,e):E())}function E(){var r;m=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(p)):(r=o+"/ping/"+t,u=""):r=s+"/"+O(JSON.stringify(p)),f.headers=L(f.headers,n),l&&(u=u+(u?"&":"")+"withReasons=true"),r=r+(u?"?":"")+u,w(),a.info(ke(r)),i=(new Date).getTime(),g=e.eventSourceFactory(r,f),h)x(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){p=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(m),m=null,w()},u.isConnected=function(){return!!(g&&e.eventSourceIsActive&&e.eventSourceIsActive(g))},u}function _e(e,n,t){var r=n.baseUrl,i=n.useReport,o=n.evaluationReasons,u=n.logger,s={},c={};function f(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new l(ye()))}));var i=r?"REPORT":"GET",o=C(e,n);r&&(o["Content-Type"]="application/json");var u=c[t];u||(u=function(e){var n,t,r,i,o={addPromise:function(o,a){n=o,t&&t(),t=a,o.then((function(t){n===o&&(r(t),e&&e())}),(function(t){n===o&&(i(t),e&&e())}))}};return o.resultPromise=new Promise((function(e,n){r=e,i=n})),o}((function(){delete c[t]})),c[t]=u);var s=e.httpRequest(i,t,L(o,n),r),f=s.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=re(e.header("content-type")||"");return Promise.reject(new l(n))}return Promise.reject(function(e){return 404===e.status?new a(se()):new l(le(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new l(ae(e)))}));return u.addPromise(f,(function(){s.cancel&&s.cancel()})),u.resultPromise}return s.fetchJSON=function(e){return f(r+e,null)},s.fetchFlagSettings=function(e,n){var a,s,c,l="";return i?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(a=O(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(l="h="+n),o&&(l=l+(l?"&":"")+"withReasons=true"),s=s+(l?"?":"")+l,u.debug(Pe(s)),f(s,c)},s}function Je(e,n){var t={};return t.validateUser=function(t){if(!t)return Promise.reject(new u(fe()));var r=P(t);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(e?e.get("ld:$anonUserId").catch((function(){return null})):Promise.resolve(null)).then((function(t){if(t)return r.key=t,r;var i=G();return r.key=i,function(t){return e?e.set("ld:$anonUserId",t).catch((function(){n.warn("localStorage is unavailable, so anonymous user ID cannot be cached")})):Promise.resolve()}(i).then((function(){return r}))})):Promise.reject(new u(ve()))},t}var ze={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}};function Me(n,t,r,i){var o=A({logger:{default:i}},ze,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){I((function(){t&&t.maybeReportError(new c(e))}))}var s=A({},n||{});return function(e){var n=e;Object.keys(a).forEach((function(e){if(void 0!==n[e]){var t=a[e];i&&i.warn(me(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),s=function(n){var t=A({},n),r=function(n){if(null===n)return"any";if(void 0!==n){if(Array.isArray(n))return"array";var t=e(n);return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"}};return Object.keys(n).forEach((function(e){var i=n[e];if(null!=i){var a=o[e];if(void 0===a)u(we(e));else{var s=a.type||r(a.default);if("any"!==s){var c=s.split("|"),l=r(i);c.indexOf(l)<0?"boolean"===s?(t[e]=!!i,u(Se(e,l))):(u(De(e,s,l)),t[e]=a.default):"number"===l&&void 0!==a.minimum&&i<a.minimum&&(u(Oe(e,i,a.minimum)),t[e]=a.minimum)}}}})),t}(s=function(e){var n=A({},e);return Object.keys(o).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=o[e]&&o[e].default)})),n}(s))}var Ke=Object.freeze({__proto__:null,baseOptionDefs:ze,validate:Me}).baseOptionDefs;var He=function(e){var n={diagnosticId:G()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n},Be=function(e){var n,t,r,i;function o(e){n=e,t=0,r=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},$e=function(e,n,t,i,o,a){var u,s,c=!!e.diagnosticUseCombinedEvent,l="ld:"+i+":$diagnostics",f=o.eventsUrl+"/events/diagnostic/"+i,v=o.diagnosticRecordingInterval,d=n,g=!!o.streaming,m={};function p(){return{sdk:b(),configuration:(n={customBaseURI:o.baseUrl!==Ke.baseUrl.default,customStreamURI:o.streamUrl!==Ke.streamUrl.default,customEventsURI:o.eventsUrl!==Ke.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},n),platform:e.diagnosticPlatformData};var n}function y(e){o.logger&&o.logger.debug(Le.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then((function(){})).catch((function(){}))}function h(){var n,t;y((n=(new Date).getTime(),t=r({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:n},d.getProps()),c&&(t=r({},t,{},p())),d.reset(n),t)),s=setTimeout(h,v),u=(new Date).getTime(),c&&function(){if(e.localStorage){var n=r({},d.getProps());e.localStorage.set(l,JSON.stringify(n),(function(){}))}}()}function b(){var n=r({},e.diagnosticSdkData);return o.wrapperName&&(n.wrapperName=o.wrapperName),o.wrapperVersion&&(n.wrapperVersion=o.wrapperVersion),n}return m.start=function(){c?function(n){if(!e.localStorage)return n(!1);e.localStorage.get(l).then((function(e){if(e)try{var t=JSON.parse(e);d.setProps(t),u=t.dataSinceDate}catch(e){}n(!0)})).catch((function(){n(!1)}))}((function(e){if(e){var n=(u||0)+v,t=(new Date).getTime();t>=n?h():s=setTimeout(h,n-t)}else 0===Math.floor(4*Math.random())?h():s=setTimeout(h,v)})):(y(r({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate},p())),s=setTimeout(h,v))},m.stop=function(){s&&clearTimeout(s)},m.setStreaming=function(e){g=e},m};function Ge(e,n){var t,r=["debug","info","warn","error"];t=null!=n?""===n?"":n+" ":"LD: ";var i=0;e&&(i="none"===e?100:r.indexOf(e));var o={};function a(e,n,o){if(e>=i&&console){var a=console[n];if(a){var u=e<r.length?r[e]:"?";a.call(console,t+"["+u+"] "+o)}}}return o.debug=function(e){return a(0,"log",e)},o.info=function(e){return a(1,"info",e)},o.warn=function(e){return a(2,"warn",e)},o.error=function(e){return a(3,"error",e)},o}function Xe(n,t,i,u,c){var v,d,g,m,p=function(){if(i&&i.logger)return i.logger;return c&&c.logger&&c.logger.default||Ge("warn")}(),y=Ae(p),h=xe(y),b=Me(i,y,c,p),k=b.sendEvents,E=n,w=b.hash,D=X(u,E,b),S=b.sendEvents&&!b.diagnosticOptOut,O=S?He(E):null,R=S?Be((new Date).getTime()):null,N=S?$e(u,R,D,E,b,O):null,F=Ve(u,b,E,R),C=b.eventProcessor||function(e,n,t){var r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=u||X(e,t,n),l=n.eventsUrl+"/events/bulk/"+t,v=W(),d=Q(n),g=n.inlineUsersInEvents,m=n.samplingInterval,p=n.eventCapacity,y=n.flushInterval,h=n.logger,b=[],k=0,E=!1,w=!1;function D(){return 0===m||0===Math.floor(Math.random()*m)}function S(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}function O(e){var n=A({},e);return"alias"===e.kind?n:(g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n)}function P(e){b.length<p?(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(v.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=S(e)):n=D(),n&&P(O(e)),t){var r=A({},e,{kind:"debug"});r.user=d.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,P(r)}}},s.flush=function(){if(E)return Promise.resolve();var e=b,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),i&&i.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],h.debug(Ce(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(k=e.serverTime),f(e.status)||(E=!0),e.status>=400&&I((function(){a.maybeReportError(new o(pe(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}(u,b,E,R,y,D),L=_e(u,b,E),V={},_={},J=b.streaming,z=!1,M=!1,K=!0,H=b.stateProvider,B=function(e,n){var t,r={};return r.setUser=function(e){var r=t&&P(t);(t=q(e))&&n&&n(P(t),r)},r.getUser=function(){return t?P(t):null},e&&r.setUser(e),r}(null,(function(e,n){(function(e){if(H)return;e&&G({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!b.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&te(e,n)})),$=Je(u.localStorage,p);function G(e){if(E&&!(H&&H.enqueueEvent&&H.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(K&&(p.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),K=!1));K=!1}!k||M||u.isDoNotTrack()||(p.debug(Fe(e.kind)),C.enqueue(e))}}function Y(e,n,t,r){var i=B.getUser(),o=new Date,a=n?n.value:null;if(!b.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=V[u];if(s&&o-s<3e5)return;V[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=ne(i));var l=_[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),G(c)}function Z(e,n,t,r){var i;if(_&&x(_,e)&&_[e]&&!_[e].deleted){var o=_[e];i=ee(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&Y(e,i,n,r),i}function ee(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function ne(e){return e.anonymous?"anonymousUser":"user"}function te(e,n){H||e&&n&&G({kind:"alias",key:e.key,contextKind:ne(e),previousKey:n.key,previousContextKind:ne(n),creationDate:(new Date).getTime()})}function re(){d=!0,B.getUser()&&F.connect(B.getUser(),w,{ping:function(){p.debug("received ping message from stream");var e=B.getUser();L.fetchFlagSettings(e,w).then((function(n){U(e,B.getUser())&&oe(n||{})})).catch((function(e){y.maybeReportError(new l(le(e)))}))},put:function(e){var n=JSON.parse(e.data);p.debug("received streaming update for all flags"),oe(n)},patch:function(e){var n=JSON.parse(e.data),t=_[n.key];if(!t||!t.version||!n.version||t.version<n.version){p.debug(je(n.key));var r={},i=A({},n);delete i.key,_[n.key]=i;var o=ee(i);r[n.key]=t?{previous:t.value,current:o}:{current:o},ae(r)}else p.debug(Re(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!_[n.key]||_[n.key].version<n.version){p.debug(Te(n.key));var t={};_[n.key]&&!_[n.key].deleted&&(t[n.key]={previous:_[n.key].value}),_[n.key]={version:n.version,deleted:!0},ae(t)}else p.debug(Ne(n.key))}})}function ie(){d&&(F.disconnect(),d=!1)}function oe(e){var n={};if(!e)return Promise.resolve();for(var t in _)x(_,t)&&_[t]&&(e[t]&&!U(e[t].value,_[t].value)?n[t]={previous:_[t].value,current:ee(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:_[t].value}));for(var i in e)x(e,i)&&e[i]&&(!_[i]||_[i].deleted)&&(n[i]={current:ee(e[i])});return _=r({},e),ae(n).catch((function(){}))}function ae(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,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",_),b.sendEventsOnlyForVariation||H||n.forEach((function(n){Y(n,e[n].current)}))}return v&&m?m.saveFlags(_).catch((function(){return null})):Promise.resolve()}function se(){var e=J||g&&void 0===J;e&&!d?re():!e&&d&&ie(),N&&N.setStreaming(e)}function fe(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if(u.localStorage&&(m=new qe(u.localStorage,E,w,B,p)),"string"==typeof b.bootstrap&&"LOCALSTORAGE"===b.bootstrap.toUpperCase()&&(m?v=!0:p.warn("localStorage is unavailable")),"object"===e(b.bootstrap)&&(_=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&p.warn(de()),!1===e.$valid&&p.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var i={value:e[n]};t&&t[n]?i=A(i,t[n]):i.version=0,r[n]=i}})),r}(b.bootstrap)),H){var ve=H.getInitialState();ve?ge(ve):H.on("init",ge),H.on("update",(function(e){e.user&&B.setUser(e.user);e.flags&&oe(e.flags)}))}else(function(){if(!n)return Promise.reject(new a(ce()));return $.validateUser(t).then((function(n){return B.setUser(n),"object"===e(b.bootstrap)?me():v?m.loadFlags().catch((function(){return null})).then((function(e){return null==e?(_={},L.fetchFlagSettings(B.getUser(),w).then((function(e){return oe(e||{})})).then(me).catch((function(e){ye(new l(le(e)))}))):(_=e,I(me),L.fetchFlagSettings(B.getUser(),w).then((function(e){return oe(e)})).catch((function(e){return y.maybeReportError(e)})))})):L.fetchFlagSettings(B.getUser(),w).then((function(e){_=e||{},me()})).catch((function(e){_={},ye(e)}))}))})().catch(ye);function ge(e){E=e.environment,B.setUser(e.user),_=r({},e.flags),I(me)}function me(){p.info("LaunchDarkly client initialized"),z=!0,se(),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 M?j(Promise.resolve({}),t):H?(p.warn("identify() has no effect here; it must be called on the main client instance"),j(Promise.resolve(T(_)),t)):j((v&&m?m.clearFlags():Promise.resolve()).then((function(){return $.validateUser(e)})).then((function(e){return L.fetchFlagSettings(e,n).then((function(t){var r=T(t);return B.setUser(e),w=n,t?oe(t).then((function(){return r})):r}))})).then((function(e){return d&&re(),e})).catch((function(e){return y.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return B.getUser()},variation:function(e,n){return Z(e,n,!0,!1).value},variationDetail:function(e,n){return Z(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){u.customEventFilter&&!u.customEventFilter(e)&&p.warn(ue(e));var r=B.getUser(),i={kind:"custom",key:e,user:r,url:u.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(i.contextKind=ne(r)),null!=n&&(i.data=n),null!=t&&(i.metricValue=t),G(i)}else y.maybeReportError(new s(ue(e)))},alias:te,on:function(e,n,t){fe(e)?(g=!0,z&&se(),y.on(e,n,t)):y.on.apply(y,arguments)},off:function(e){if(y.off.apply(y,arguments),fe(e)){var n=!1;y.getEvents().forEach((function(e){fe(e)&&y.getEventListenerCount(e)>0&&(n=!0)})),n||(g=!1,d&&void 0===J&&ie())}},setStreaming:function(e){var n=null===e?void 0:e;n!==J&&(J=n,se())},flush:function(e){return j(k?C.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!_)return e;for(var n in _)x(_,n)&&(e[n]=Z(n,null,!b.sendEventsOnlyForVariation).value);return e},close:function(e){if(M)return j(Promise.resolve(),e);var n=function(){M=!0,_={}};return j(Promise.resolve().then((function(){if(ie(),N&&N.stop(),k)return C.stop(),C.flush()})).then(n).catch(n),e)}},options:b,emitter:y,ident:B,logger:p,requestor:L,start:function(){k&&(N&&N.start(),C.start())},enqueueEvent:G,getFlagsInternal:function(){return _},getEnvironmentId:function(){return E},internalChangeEventName:"internal-change"}}var We="3.4.0";export{Ge as createConsoleLogger,v as errors,Xe as initialize,Le as messages,V as utils,We as version}; | ||
function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function r(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?t(i,!0).forEach((function(t){n(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):t(i).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(i,n))}))}return e}function i(e){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var a=o("LaunchDarklyUnexpectedResponseError"),u=o("LaunchDarklyInvalidEnvironmentIdError"),s=o("LaunchDarklyInvalidUserError"),c=o("LaunchDarklyInvalidEventKeyError"),l=o("LaunchDarklyInvalidArgumentError"),f=o("LaunchDarklyFlagFetchError");function v(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}for(var d=Object.freeze({__proto__:null,LDUnexpectedResponseError:a,LDInvalidEnvironmentIdError:u,LDInvalidUserError:s,LDInvalidEventKeyError:c,LDInvalidArgumentError:l,LDFlagFetchError:f,isHttpErrorRecoverable:v}),g=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(k(e,o,o+16383>a?a:o+16383));1===r?(n=e[t-1],i.push(p[n>>2]+p[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],i.push(p[n>>10]+p[n>>4&63]+p[n<<2&63]+"="));return i.join("")},p=[],m=[],y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,b=y.length;h<b;++h)p[h]=y[h],m[y.charCodeAt(h)]=h;function k(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(p[(i=r)>>18&63]+p[i>>12&63]+p[i>>6&63]+p[63&i]);return o.join("")}m["-".charCodeAt(0)]=62,m["_".charCodeAt(0)]=63;var E=Array.isArray,w=Object.keys,D=Object.prototype.hasOwnProperty,O=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function S(e){var n=unescape(encodeURIComponent(e));return g(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function P(e){return S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function U(e){return JSON.parse(JSON.stringify(e))}function I(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=E(n),u=E(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=w(n);if((i=v.length)!==w(t).length)return!1;for(r=i;0!=r--;)if(!D.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 j(e){setTimeout(e,0)}function T(e,n){var t=e.then((function(e){return n&&setTimeout((function(){n(null,e)}),0),e}),(function(e){if(!n)return Promise.reject(e);setTimeout((function(){n(e,null)}),0)}));return n?void 0:t}function R(e){var n={};for(var t in e)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-=P(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function A(e){var n=e.version||"3.5.0";return e.userAgent+"/"+n}function C(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":A(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function L(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(r({},e)):e}function x(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return r({},e,{},n)}),{})}function q(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function V(e){if(!e)return e;var n;for(var t in O){var i=O[t],o=e[i];void 0!==o&&"string"!=typeof o&&((n=n||r({},e))[i]=String(o))}return n||e}var _=Object.freeze({__proto__:null,btoa:S,base64URLEncode:P,clone:U,deepEquals:I,onNextTick:j,wrapPromiseCallback:T,transformValuesToVersionedValues:R,transformVersionedValuesToValues:N,chunkUserEventsForUrl:F,getLDUserAgentString:A,getLDHeaders:C,transformHeaders:L,extend:x,objectHasOwnProperty:q,sanitizeUser:V});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}}})),z=[],M=0;M<256;++M)z[M]=(M+256).toString(16).substr(1);var K,H,B=function(e,n){var t=n||0,r=z;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("")},$=0,G=0;var X=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||K,a=void 0!==e.clockseq?e.clockseq:H;if(null==o||null==a){var u=J();null==o&&(o=K=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=H=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:G+1,l=s-$+(c-G)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>$)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");$=s,G=c,H=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var v=s/4294967296*1e4&268435455;i[r++]=v>>>8&255,i[r++]=255&v,i[r++]=v>>>24&15|16,i[r++]=v>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var d=0;d<6;++d)i[r+d]=o[d];return n||B(i)};function W(e,n,t){var r="/a/"+n+".gif",i=x({"Content-Type":"application/json"},C(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:x({},i,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":l});return e.httpRequest("POST",a,L(o,t),c).promise.then((function(e){if(e)return e.status>=400&&v(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="+P(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 Q(){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 Y(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=x({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function Z(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var ee=function(){return"LaunchDarkly client initialized"},ne=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",te=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},re=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},ie=function(e){return'Expected application/json content type but got "'+e+'"'},oe=function(e){return"local storage is unavailable: "+Z(e)},ae=function(e){return"network error"+(e?" ("+e+")":"")},ue=function(e){return'Custom event "'+e+'" does not exist'},se=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+ne},ce=function(){return"No environment/client-side ID was specified."+ne},le=function(e){return"Error fetching flag settings: "+Z(e)},fe=function(){return"No user specified."+ne},ve=function(){return"Invalid user specified."+ne},de=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+ne},ge=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},pe=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},me=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(v(e)?t:"giving up permanently")},ye=function(){return"Cannot make HTTP requests in this environment."+ne},he=function(){return"identify() has no effect here; it must be called on the main client instance"},be=function(){return"Closing stream connection"},ke=function(e){return"Opening stream connection to "+e},Ee=function(e,n){return"Error on stream connection: "+Z(e)+", will continue retrying every "+n+" milliseconds."},we=function(e){return'Ignoring unknown config option "'+e+'"'},De=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Oe=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Se=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Pe=function(e){return"polling for feature flags at "+e},Ue=function(){return"received ping message from stream"},Ie=function(){return"received streaming update for all flags"},je=function(e){return'received streaming update for flag "'+e+'"'},Te=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Re=function(e){return'received streaming deletion for flag "'+e+'"'},Ne=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Fe=function(e){return'enqueueing "'+e+'" event'},Ae=function(e){return"sending "+e+" events"},Ce=Object.freeze({__proto__:null,clientInitialized:ee,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:te,eventWithoutUser:re,invalidContentType:ie,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:oe,networkError:ae,unknownCustomEventKey:ue,environmentNotFound:se,environmentNotSpecified:ce,errorFetchingFlags:le,userNotSpecified:fe,invalidUser:ve,bootstrapOldFormat:de,bootstrapInvalid:ge,deprecated:pe,httpErrorMessage:me,httpUnavailable:ye,identifyDisabled:he,streamClosing:be,streamConnecting:ke,streamError:Ee,unknownOption:we,wrongOptionType:De,wrongOptionTypeBoolean:Oe,optionBelowMinimum:Se,debugPolling:Pe,debugStreamPing:Ue,debugStreamPut:Ie,debugStreamPatch:je,debugStreamPatchIgnored:Te,debugStreamDelete:Re,debugStreamDeleteIgnored:Ne,debugEnqueueingEvent:Fe,debugPostingEvents:Ae,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function Le(e){var n={},t={};return n.on=function(e,n,r){t[e]=t[e]||[],t[e]=t[e].concat({handler:n,context:r})},n.off=function(e,n,r){if(t[e])for(var i=0;i<t[e].length;i++)t[e][i].handler===n&&t[e][i].context===r&&(t[e]=t[e].slice(0,i).concat(t[e].slice(i+1)))},n.emit=function(e){if(t[e])for(var n=t[e].slice(0),r=0;r<n.length;r++)n[r].handler.apply(n[r].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t["error"]?this.emit("error",n):(e||console).error(n.message))},n}var 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||S(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=R(n):delete n.$schema}return n}catch(e){return i.clearFlags().then((function(){return null}))}}))},i.saveFlags=function(n){var t=x({},n,{$schema:1});return e.set(o(),JSON.stringify(t))},i.clearFlags=function(){return e.clear(o())},i}function Ve(e,n,t,r){var i,o=n.streamUrl,a=n.logger,u={},s=o+"/eval/"+t,c=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,v=C(e,n),d=!1,g=null,p=null,m=null,y=null,h=null;function b(e){d||(a.warn(Ee(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=o+"/ping/"+t,u=""):r=s+"/"+P(JSON.stringify(m)),f.headers=L(f.headers,n),l&&(u=u+(u?"&":"")+"withReasons=true"),r=r+(u?"?":"")+u,w(),a.info(ke(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 _e(e,n,t){var r=n.baseUrl,i=n.useReport,o=n.evaluationReasons,a=n.logger,s={},c={};function l(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new f(ye()))}));var i=r?"REPORT":"GET",o=C(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 s=e.httpRequest(i,t,L(o,n),r),l=s.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=ie(e.header("content-type")||"");return Promise.reject(new f(n))}return Promise.reject(function(e){return 404===e.status?new u(se()):new f(le(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new f(ae(e)))}));return a.addPromise(l,(function(){s.cancel&&s.cancel()})),a.resultPromise}return s.fetchJSON=function(e){return l(r+e,null)},s.fetchFlagSettings=function(e,n){var u,s,c,f="";return i?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(u=P(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(Pe(s)),l(s,c)},s}function Je(e){var n={};return n.validateUser=function(n){if(!n)return Promise.reject(new s(fe()));var t=U(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 s(ve()))},n}var ze=["debug","info","warn","error","none"];function Me(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<ze.length;s++)ze[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=ze[e];if("none"!==n)if(e<u)l[n]=function(){};else{var t=e;l[n]=function(){c(t,n,arguments)}}},v=0;v<ze.length;v++)f(v);return l}function Ke(e,n){return Me({level:e,prefix:n})}var He={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}};function Be(n,t,r,i){var o=x({logger:{default:i}},He,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){j((function(){t&&t.maybeReportError(new l(e))}))}var s=x({},n||{});return function(e){var n=e;Object.keys(a).forEach((function(e){if(void 0!==n[e]){var t=a[e];i&&i.warn(pe(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),function(e){ze.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(n){var t=x({},n),r=function(n){if(null===n)return"any";if(void 0!==n){if(Array.isArray(n))return"array";var t=e(n);return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"}};return Object.keys(n).forEach((function(e){var i=n[e];if(null!=i){var a=o[e];if(void 0===a)u(we(e));else{var s=a.type||r(a.default);if("any"!==s){var c=s.split("|"),l=r(i);c.indexOf(l)<0?"boolean"===s?(t[e]=!!i,u(Oe(e,l))):(u(De(e,s,l)),t[e]=a.default):"number"===l&&void 0!==a.minimum&&i<a.minimum&&(u(Se(e,i,a.minimum)),t[e]=a.minimum)}}}})),t}(s=function(e){var n=x({},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}var $e=Object.freeze({__proto__:null,baseOptionDefs:He,validate:Be}).baseOptionDefs;var Ge=function(e){var n={diagnosticId:X()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n},Xe=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}},We=function(e,n,t,i,o,a,u){var s,c,l=!!e.diagnosticUseCombinedEvent,f="ld:"+o+":$diagnostics",v=a.eventsUrl+"/events/diagnostic/"+o,d=a.diagnosticRecordingInterval,g=t,p=!!a.streaming,m={};function y(){return{sdk:k(),configuration:(n={customBaseURI:a.baseUrl!==$e.baseUrl.default,customStreamURI:a.streamUrl!==$e.streamUrl.default,customEventsURI:a.eventsUrl!==$e.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(Ce.debugPostingDiagnosticEvent(e)),i.sendEvents(e,v,!0).then((function(){})).catch((function(){}))}function b(){var e,t;h((e=(new Date).getTime(),t=r({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:e},g.getProps()),l&&(t=r({},t,{},y())),g.reset(e),t)),c=setTimeout(b,d),s=(new Date).getTime(),l&&function(){if(n.isEnabled()){var e=r({},g.getProps());n.set(f,JSON.stringify(e))}}()}function k(){var n=r({},e.diagnosticSdkData);return a.wrapperName&&(n.wrapperName=a.wrapperName),a.wrapperVersion&&(n.wrapperVersion=a.wrapperVersion),n}return m.start=function(){l?function(e){if(!n.isEnabled())return e(!1);n.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(r({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 Qe(n,t,i,o,s){var l,d,g,p=function(){if(i&&i.logger)return i.logger;return s&&s.logger&&s.logger.default||Ke("warn")}(),m=Le(p),y=xe(m),h=Be(i,m,s,p),b=h.sendEvents,k=n,E=h.hash,w=function(e,n){var t={},r=!1,i=function(e){r||(r=!0,n.warn(oe(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,p),D=W(o,k,h),O=h.sendEvents&&!h.diagnosticOptOut,S=O?Ge(k):null,P=O?Xe((new Date).getTime()):null,R=O?We(o,w,P,D,k,h,S):null,F=Ve(o,h,k,P),A=h.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,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=u||W(e,t,n),l=n.eventsUrl+"/events/bulk/"+t,f=Q(),d=Y(n),g=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=x({},e);return"alias"===e.kind?n:(g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n)}function 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=x({},e,{kind:"debug"});r.user=d.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(Ae(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(k=e.serverTime),v(e.status)||(E=!0),e.status>=400&&j((function(){o.maybeReportError(new a(me(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,h,k,P,m,D),C=_e(o,h,k),L={},_={},J=h.streaming,z=!1,M=!1,K=!0,H=h.stateProvider,B=function(e,n){var t,r={};return r.setUser=function(e){var r=t&&U(t);(t=V(e))&&n&&n(U(t),r)},r.getUser=function(){return t?U(t):null},e&&r.setUser(e),r}(null,(function(e,n){(function(e){if(H)return;e&&X({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!h.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&re(e,n)})),$=Je(w),G=w.isEnabled()?new qe(w,k,E,B,p):null;function X(e){if(k&&!(H&&H.enqueueEvent&&H.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(K&&(p.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),K=!1));K=!1}!b||M||o.isDoNotTrack()||(p.debug(Fe(e.kind)),A.enqueue(e))}}function Z(e,n,t,r){var i=B.getUser(),o=new Date,a=n?n.value:null;if(!h.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=L[u];if(s&&o-s<3e5)return;L[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=_[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),X(c)}function ee(e,n,t,r){var i;if(_&&q(_,e)&&_[e]&&!_[e].deleted){var o=_[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&&Z(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&&X({kind:"alias",key:e.key,contextKind:te(e),previousKey:n.key,previousContextKind:te(n),creationDate:(new Date).getTime()})}function ie(){d=!0,B.getUser()&&F.connect(B.getUser(),E,{ping:function(){p.debug("received ping message from stream");var e=B.getUser();C.fetchFlagSettings(e,E).then((function(n){I(e,B.getUser())&&se(n||{})})).catch((function(e){m.maybeReportError(new f(le(e)))}))},put:function(e){var n=JSON.parse(e.data);p.debug("received streaming update for all flags"),se(n)},patch:function(e){var n=JSON.parse(e.data),t=_[n.key];if(!t||!t.version||!n.version||t.version<n.version){p.debug(je(n.key));var r={},i=x({},n);delete i.key,_[n.key]=i;var o=ne(i);r[n.key]=t?{previous:t.value,current:o}:{current:o},fe(r)}else p.debug(Te(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!_[n.key]||_[n.key].version<n.version){p.debug(Re(n.key));var t={};_[n.key]&&!_[n.key].deleted&&(t[n.key]={previous:_[n.key].value}),_[n.key]={version:n.version,deleted:!0},fe(t)}else p.debug(Ne(n.key))}})}function ae(){d&&(F.disconnect(),d=!1)}function se(e){var n={};if(!e)return Promise.resolve();for(var t in _)q(_,t)&&_[t]&&(e[t]&&!I(e[t].value,_[t].value)?n[t]={previous:_[t].value,current:ne(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:_[t].value}));for(var i in e)q(e,i)&&e[i]&&(!_[i]||_[i].deleted)&&(n[i]={current:ne(e[i])});return _=r({},e),fe(n).catch((function(){}))}function fe(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;m.emit("change:"+n,i,o),t[n]=r?{current:i,previous:o}:{previous:o}})),m.emit("change",t),m.emit("internal-change",_),h.sendEventsOnlyForVariation||H||n.forEach((function(n){Z(n,e[n].current)}))}return l&&G?G.saveFlags(_):Promise.resolve()}function ve(){var e=J||g&&void 0===J;e&&!d?ie():!e&&d&&ae(),R&&R.setStreaming(e)}function ge(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof h.bootstrap&&"LOCALSTORAGE"===h.bootstrap.toUpperCase()&&(G?l=!0:p.warn(oe())),"object"===e(h.bootstrap)&&(_=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&p.warn(de()),!1===e.$valid&&p.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var i={value:e[n]};t&&t[n]?i=x(i,t[n]):i.version=0,r[n]=i}})),r}(h.bootstrap)),H){var pe=H.getInitialState();pe?ye(pe):H.on("init",ye),H.on("update",(function(e){e.user&&B.setUser(e.user);e.flags&&se(e.flags)}))}else(function(){if(!n)return Promise.reject(new u(ce()));return $.validateUser(t).then((function(n){return B.setUser(n),"object"===e(h.bootstrap)?he():l?G.loadFlags().then((function(e){return null==e?(_={},C.fetchFlagSettings(B.getUser(),E).then((function(e){return se(e||{})})).then(he).catch((function(e){be(new f(le(e)))}))):(_=e,j(he),C.fetchFlagSettings(B.getUser(),E).then((function(e){return se(e)})).catch((function(e){return m.maybeReportError(e)})))})):C.fetchFlagSettings(B.getUser(),E).then((function(e){_=e||{},he()})).catch((function(e){_={},be(e)}))}))})().catch(be);function ye(e){k=e.environment,B.setUser(e.user),_=r({},e.flags),j(he)}function he(){p.info("LaunchDarkly client initialized"),z=!0,ve(),y.signalSuccess()}function be(e){y.signalFailure(e)}return{client:{waitForInitialization:function(){return y.getInitializationPromise()},waitUntilReady:function(){return y.getReadyPromise()},identify:function(e,n,t){return M?T(Promise.resolve({}),t):H?(p.warn("identify() has no effect here; it must be called on the main client instance"),T(Promise.resolve(N(_)),t)):T((l&&G?G.clearFlags():Promise.resolve()).then((function(){return $.validateUser(e)})).then((function(e){return C.fetchFlagSettings(e,n).then((function(t){var r=N(t);return B.setUser(e),E=n,t?se(t).then((function(){return r})):r}))})).then((function(e){return d&&ie(),e})).catch((function(e){return m.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return B.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)&&p.warn(ue(e));var r=B.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),X(i)}else m.maybeReportError(new c(ue(e)))},alias:re,on:function(e,n,t){ge(e)?(g=!0,z&&ve(),m.on(e,n,t)):m.on.apply(m,arguments)},off:function(e){if(m.off.apply(m,arguments),ge(e)){var n=!1;m.getEvents().forEach((function(e){ge(e)&&m.getEventListenerCount(e)>0&&(n=!0)})),n||(g=!1,d&&void 0===J&&ae())}},setStreaming:function(e){var n=null===e?void 0:e;n!==J&&(J=n,ve())},flush:function(e){return T(b?A.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!_)return e;for(var n in _)q(_,n)&&(e[n]=ee(n,null,!h.sendEventsOnlyForVariation).value);return e},close:function(e){if(M)return T(Promise.resolve(),e);var n=function(){M=!0,_={}};return T(Promise.resolve().then((function(){if(ae(),R&&R.stop(),b)return A.stop(),A.flush()})).then(n).catch(n),e)}},options:h,emitter:m,ident:B,logger:p,requestor:C,start:function(){b&&(R&&R.start(),A.start())},enqueueEvent:X,getFlagsInternal:function(){return _},getEnvironmentId:function(){return k},internalChangeEventName:"internal-change"}}var Ye="3.5.0";export{Me as commonBasicLogger,Ke as createConsoleLogger,d as errors,Qe as initialize,Ce as messages,_ as utils,Ye 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 X(e){return(X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function W(i){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?n(o,!0).forEach(function(e){var n,t,r;n=i,r=o[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(o)):n(o).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(o,e))})}return i}function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var O=t("LaunchDarklyUnexpectedResponseError"),Q=t("LaunchDarklyInvalidEnvironmentIdError"),o=t("LaunchDarklyInvalidUserError"),Y=t("LaunchDarklyInvalidEventKeyError"),d=t("LaunchDarklyInvalidArgumentError"),Z=t("LaunchDarklyFlagFetchError");function P(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var r=Object.freeze({__proto__:null,LDUnexpectedResponseError:O,LDInvalidEnvironmentIdError:Q,LDInvalidUserError:o,LDInvalidEventKeyError:Y,LDInvalidArgumentError:d,LDFlagFetchError:Z,isHttpErrorRecoverable:P}),i=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(f(e,o,a<o+16383?a:o+16383));1==r?(n=e[t-1],i.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],i.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"="));return i.join("")},u=[],a=[],s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=s.length;c<l;++c)u[c]=s[c],a[s.charCodeAt(c)]=c;function f(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(u[(i=r)>>18&63]+u[i>>12&63]+u[i>>6&63]+u[63&i]);return o.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63;var g=Array.isArray,m=Object.keys,p=Object.prototype.hasOwnProperty,v=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=g(n),u=g(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=m(n);if((i=v.length)!==m(t).length)return!1;for(r=i;0!=r--;)if(!p.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t},y=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function h(e){var n=unescape(encodeURIComponent(e));return i(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function S(e){return h(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function ee(e){return JSON.parse(JSON.stringify(e))}function ne(e,n){return v(e,n)}function te(e){setTimeout(e,0)}function re(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function b(e){var n={};for(var t in e)ae(e,t)&&(n[t]={value:e[t],version:0});return n}function ie(e){var n={};for(var t in e)ae(e,t)&&(n[t]=e[t].value);return n}function k(e,n){for(var t,r=n.slice(0),i=[],o=e;0<r.length;){for(t=[];0<o;){var a=r.shift();if(!a)break;(o-=S(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}o=e,i.push(t)}return i}function E(e){var n=e.version||"3.4.0";return e.userAgent+"/"+n}function U(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":E(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function I(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(W({},e)):e}function oe(){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 W({},e,{},n)},{})}function ae(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function ue(e){if(!e)return e;var n;for(var t in y){var r=y[t],i=e[r];void 0!==i&&"string"!=typeof i&&((n=n||W({},e))[r]=String(i))}return n||e}var w=Object.freeze({__proto__:null,btoa:h,base64URLEncode:S,clone:ee,deepEquals:ne,onNextTick:te,wrapPromiseCallback:re,transformValuesToVersionedValues:b,transformVersionedValuesToValues:ie,chunkUserEventsForUrl:k,getLDUserAgentString:E,getLDHeaders:U,transformHeaders:I,extend:oe,objectHasOwnProperty:ae,sanitizeUser:ue});for(var D,j=(function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}(D={exports:{}},D.exports),D.exports),R=[],T=0;T<256;++T)R[T]=(T+256).toString(16).substr(1);var N,F,C=function(e,n){var t=n||0,r=R;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},L=0,A=0;var x=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||N,a=void 0!==e.clockseq?e.clockseq:F;if(null==o||null==a){var u=j();null==o&&(o=N=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=F=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:A+1,l=s-L+(c-A)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||L<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");L=s,F=a;var f=(1e4*(268435455&(s+=122192928e5))+(A=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||C(i)},q=2e3;function se(u,e,s){var t="/a/"+e+".gif",c=oe({"Content-Type":"application/json"},U(u,s)),l=u.httpFallbackPing,f={};return f.sendChunk=function(e,r,i,n){var o=JSON.stringify(e),a=i?null:x();return n?function n(t){var e=i?c:oe({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,I(e,s),o).promise.then(function(e){if(e)return 400<=e.status&&P(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(r+t+"?d="+S(o)),Promise.resolve())},f.sendEvents=function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,i=u.httpAllowsPost();r=i?[e]:k(q-n.length,e);for(var o=[],a=0;a<r.length;a++)o.push(f.sendChunk(r[a],n,t,i));return Promise.all(o)},f}function _(e){var n={},s=e.allAttributesPrivate,c=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(r,i){return Object.keys(r).reduce(function(e,n){var t=e;return i(n)&&(!function(e){return!l[e]&&(s||-1!==o.indexOf(e)||-1!==c.indexOf(e))}(n)?t[0][n]=r[n]:t[1][n]=!0),t},[{},{}])}var o=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],i=t[1];if(e.custom){var a=n(e.custom,function(){return!0});r.custom=a[0],i=oe({},i,a[1])}var u=Object.keys(i);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function V(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}function J(){return"LaunchDarkly client initialized"}function z(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"}function ce(e){return'Custom event "'+e+'" does not exist'}function le(){return"No environment/client-side ID was specified."+$}function fe(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+$}function M(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."}function K(){return"identify() has no effect here; it must be called on the main client instance"}function H(){return"received ping message from stream"}function B(){return"received streaming update for all flags"}function ve(e){return'received streaming update for flag "'+e+'"'}function de(e){return'received streaming update for flag "'+e+'" but ignored due to version check'}function ge(e){return'received streaming deletion for flag "'+e+'"'}function me(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'}function pe(e){return'enqueueing "'+e+'" event'}var $=" 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."},ye=function(e){return'Expected application/json content type but got "'+e+'"'},he=function(){return"localStorage is unavailable"},be=function(){return"localStorage is unavailable, so anonymous user ID cannot be cached"},ke=function(e){return"network error"+(e?" ("+e+")":"")},Ee=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+$},we=function(e){return"Error fetching flag settings: "+V(e)},De=function(){return"No user specified."+$},Se=function(){return"Invalid user specified."+$},Oe=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},Pe=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(P(e)?t:"giving up permanently")},Ue=function(){return"Cannot make HTTP requests in this environment."+$},Ie=function(){return"Closing stream connection"},je=function(e){return"Opening stream connection to "+e},Re=function(e,n){return"Error on stream connection: "+V(e)+", will continue retrying every "+n+" milliseconds."},Te=function(e){return'Ignoring unknown config option "'+e+'"'},Ne=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Fe=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Ce=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Le=function(e){return"polling for feature flags at "+e},Ae=function(e){return"sending "+e+" events"},xe=Object.freeze({__proto__:null,clientInitialized:J,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:G,eventWithoutUser:z,invalidContentType:ye,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:he,localStorageUnavailableForUserId:be,networkError:ke,unknownCustomEventKey:ce,environmentNotFound:Ee,environmentNotSpecified:le,errorFetchingFlags:we,userNotSpecified:De,invalidUser:Se,bootstrapOldFormat:fe,bootstrapInvalid:M,deprecated:Oe,httpErrorMessage:Pe,httpUnavailable:Ue,identifyDisabled:K,streamClosing:Ie,streamConnecting:je,streamError:Re,unknownOption:Te,wrongOptionType:Ne,wrongOptionTypeBoolean:Fe,optionBelowMinimum:Ce,debugPolling:Le,debugStreamPing:H,debugStreamPut:B,debugStreamPatch:ve,debugStreamPatchIgnored:de,debugStreamDelete:ge,debugStreamDeleteIgnored:me,debugEnqueueingEvent:pe,debugPostingEvents:Ae,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function qe(e,n,t,r,i,o){var a,u=3<arguments.length&&void 0!==r?r:null,s=4<arguments.length&&void 0!==i?i:null,c={},l=(5<arguments.length&&void 0!==o?o:null)||se(e,t,n),f=n.eventsUrl+"/events/bulk/"+t,v=function(){var e={},a=0,u=0,s={};return e.summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=s[n];t?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate)}},e.getSummary=function(){var e={},n=!0;for(var t in s){var r=s[t],i=e[r.key];i||(i={default:r.default,counters:[]},e[r.key]=i);var o={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(o.variation=r.variation),r.version?o.version=r.version:o.unknown=!0,i.counters.push(o),n=!1}return n?null:{startDate:a,endDate:u,features:e}},e.clearSummary=function(){u=a=0,s={}},e}(),d=_(n),g=n.inlineUsersInEvents,m=n.samplingInterval,p=n.eventCapacity,y=n.flushInterval,h=n.logger,b=[],k=0,E=!1,w=!1;function D(){return 0===m||0===Math.floor(Math.random()*m)}function S(e){b.length<p?(b.push(e),w=!1):(w||(w=!0,h.warn(G())),u&&u.incrementDroppedEvents())}return c.enqueue=function(e){if(!E){var n=!1,t=!1;if(v.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}(e)):n=D(),n&&S(function(e){var n=oe({},e);return"alias"===e.kind||(g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}(e)),t){var r=oe({},e,{kind:"debug"});r.user=d.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,S(r)}}},c.flush=function(){if(E)return Promise.resolve();var e=b,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),u&&u.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],h.debug(Ae(e.length)),l.sendEvents(e,f).then(function(e){e&&(e.serverTime&&(k=e.serverTime),P(e.status)||(E=!0),400<=e.status&&te(function(){s.maybeReportError(new O(Pe(e.status,"event posting","some events were dropped")))}))}))},c.start=function(){a=setTimeout(function e(){c.flush(),a=setTimeout(e,y)},y)},c.stop=function(){clearTimeout(a)},c}function _e(n){var e={},i={};return e.on=function(e,n,t){i[e]=i[e]||[],i[e]=i[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(i[e])for(var r=0;r<i[e].length;r++)i[e][r].handler===n&&i[e][r].context===t&&(i[e]=i[e].slice(0,r).concat(i[e].slice(r+1)))},e.emit=function(e){if(i[e])for(var n=i[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(i)},e.getEventListenerCount=function(e){return i[e]?i[e].length:0},e.maybeReportError=function(e){e&&(!function(e){return!!i[e]}("error")?(n||console).error(e.message):this.emit("error",e))},e}var Ve="ready",Je="initialized",ze="failed";var Me=function(r){var n=!1,t=!1,i=null,e=null,o=new Promise(function(n){r.on(Ve,function e(){r.off(Ve,e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(i):e=new Promise(function(n,t){r.on(Je,function e(){r.off(Je,e),n()}),r.on(ze,function e(n){r.off(ze,e),t(n)})}))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,r.emit(Je),r.emit(Ve))},signalFailure:function(e){n||t||(t=!0,i=e,r.emit(ze,e),r.emit(Ve)),r.maybeReportError(e)}}};function Ke(t,r,i,o,a){var u={};function s(){var e="",n=o.getUser();return n&&(e=i||h(JSON.stringify(n))),"ld:"+r+":"+e}return u.loadFlags=function(){return t.get(s()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=b(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn(he()),Promise.reject(e)})},u.saveFlags=function(e){var n=oe({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn(he()),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn(he()),Promise.reject(e)})},u}var He=3e5;function Be(i,o,a,n){var u,s=o.streamUrl,c=o.logger,e={},l=s+"/eval/"+a,f=o.useReport,v=o.evaluationReasons,t=o.streamReconnectDelay,d=U(i,o),g=!1,m=null,p=null,y=null,h=null,b=null;function k(e){g||(c.warn(Re(e,t)),g=!0),D(!1),w(),E(t)}function E(e){p||(e?p=setTimeout(r,e):r())}function r(){var e;p=null;var n="",t={headers:d,readTimeoutMillis:He};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=s+"/ping/"+a,n=""):e=l+"/"+S(JSON.stringify(y)),t.headers=I(t.headers,o),v&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,w(),c.info(je(e)),u=(new Date).getTime(),m=i.eventSourceFactory(e,t),b)ae(b,r)&&m.addEventListener(r,b[r]);m.onerror=k}}function w(){m&&(c.info(Ie()),m.close(),m=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={};function r(n){b[n]=function(e){D(!(g=!1)),t[n]&&t[n](e)}}for(var i in t||{})r(i);E()},e.disconnect=function(){clearTimeout(p),p=null,w()},e.isConnected=function(){return!!(m&&i.eventSourceIsActive&&i.eventSourceIsActive(m))},e}var $e="application/json";function Ge(u,s,a){var c=s.baseUrl,l=s.useReport,f=s.evaluationReasons,v=s.logger,e={},d={};function g(e,n){if(!u.httpRequest)return new Promise(function(e,n){n(new Z(Ue()))});var t=n?"REPORT":"GET",r=U(u,s);n&&(r["Content-Type"]=$e);var i=d[e];i||(i=function(t){var r,i,o,a,e={addPromise:function(n,e){r=n,i&&i(),i=e,n.then(function(e){r===n&&(o(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}};return e.resultPromise=new Promise(function(e,n){o=e,a=n}),e}(function(){delete d[e]}),d[e]=i);var o=u.httpRequest(t,e,I(r,s),n),a=o.promise.then(function(e){if(200!==e.status)return Promise.reject(function(e){return 404===e.status?new Q(Ee()):new Z(we(e.statusText||String(e.status)))}(e));if(e.header("content-type")&&e.header("content-type").substring(0,$e.length)===$e)return JSON.parse(e.body);var n=ye(e.header("content-type")||"");return Promise.reject(new Z(n))},function(e){return Promise.reject(new Z(ke(e)))});return i.addPromise(a,function(){o.cancel&&o.cancel()}),i.resultPromise}return e.fetchJSON=function(e){return g(c+e,null)},e.fetchFlagSettings=function(e,n){var t,r,i,o="";return l?(r=[c,"/sdk/evalx/",a,"/user"].join(""),i=JSON.stringify(e)):(t=S(JSON.stringify(e)),r=[c,"/sdk/evalx/",a,"/users/",t].join("")),n&&(o="h="+n),f&&(o=o+(o?"&":"")+"withReasons=true"),r=r+(o?"?":"")+o,v.debug(Le(r)),g(r,i)},e}var Xe="ld:$anonUserId";function We(r,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new o(De()));var t=ee(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?(r?r.get(Xe).catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return t.key=e,t;var n=x();return function(e){return r?r.set(Xe,e).catch(function(){i.warn(be())}):Promise.resolve()}(t.key=n).then(function(){return t})}):Promise.reject(new o(Se()))},e}var 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}};function Ye(e,n,t,r){var a=oe({logger:{default:r}},Qe,t),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){te(function(){n&&n.maybeReportError(new d(e))})}var o,s,c,l,f=oe({},e||{});function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=X(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}return o=f,Object.keys(i).forEach(function(e){if(void 0!==o[e]){var n=i[e];r&&r.warn(Oe(e,n)),n&&(void 0===o[n]&&(o[n]=o[e]),delete o[e])}}),s=oe({},f),Object.keys(a).forEach(function(e){void 0!==s[e]&&null!==s[e]||(s[e]=a[e]&&a[e].default)}),l=oe({},c=f=s),Object.keys(c).forEach(function(e){var n=c[e];if(null!=n){var t=a[e];if(void 0===t)u(Te(e));else{var r=t.type||v(t.default);if("any"!==r){var i=r.split("|"),o=v(n);i.indexOf(o)<0?"boolean"===r?(l[e]=!!n,u(Fe(e,o))):(u(Ne(e,r,o)),l[e]=t.default):"number"===o&&void 0!==t.minimum&&n<t.minimum&&(u(Ce(e,n,t.minimum)),l[e]=t.minimum)}}}}),f=l}var Ze=Object.freeze({__proto__:null,baseOptionDefs:Qe,validate:Ye}).baseOptionDefs;var en=function(e){var n={diagnosticId:x()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},nn=function(e){var n,t,r,i;function o(e){n=e,r=t=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},tn=function(n,e,t,r,i,o){var a,u,s=!!n.diagnosticUseCombinedEvent,c="ld:"+r+":$diagnostics",l=i.eventsUrl+"/events/diagnostic/"+r,f=i.diagnosticRecordingInterval,v=e,d=!!i.streaming,g={};function m(){return{sdk:function(){var e=W({},n.diagnosticSdkData);i.wrapperName&&(e.wrapperName=i.wrapperName);i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion);return e}(),configuration:{customBaseURI:i.baseUrl!==Ze.baseUrl.default,customStreamURI:i.streamUrl!==Ze.streamUrl.default,customEventsURI:i.eventsUrl!==Ze.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!d,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation,autoAliasingOptOut:!!i.autoAliasingOptOut},platform:n.diagnosticPlatformData}}function p(e){i.logger&&i.logger.debug(xe.debugPostingDiagnosticEvent(e)),t.sendEvents(e,l,!0).then(function(){}).catch(function(){})}function y(){p(function(){var e=(new Date).getTime(),n=W({kind:s?"diagnostic-combined":"diagnostic",id:o,creationDate:e},v.getProps());return s&&(n=W({},n,{},m())),v.reset(e),n}()),u=setTimeout(y,f),a=(new Date).getTime(),s&&function(){if(n.localStorage){var e=W({},v.getProps());n.localStorage.set(c,JSON.stringify(e),function(){})}}()}return g.start=function(){s?function(t){if(!n.localStorage)return t(!1);n.localStorage.get(c).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),a=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(a||0)+f,t=(new Date).getTime();n<=t?y():u=setTimeout(y,n-t)}else 0===Math.floor(4*Math.random())?y():u=setTimeout(y,f)}):(p(W({kind:"diagnostic-init",id:o,creationDate:v.getProps().dataSinceDate},m())),u=setTimeout(y,f))},g.stop=function(){u&&clearTimeout(u)},g.setStreaming=function(e){d=e},g};function rn(e,n){var o,a=["debug","info","warn","error"];o=null!=n?""===n?"":n+" ":"LD: ";var u=0;e&&(u="none"===e?100:a.indexOf(e));var t={};function r(e,n,t){if(u<=e&&console){var r=console[n];if(r){var i=e<a.length?a[e]:"?";r.call(console,o+"["+i+"] "+t)}}}return t.debug=function(e){return r(0,"log",e)},t.info=function(e){return r(1,"info",e)},t.warn=function(e){return r(2,"warn",e)},t.error=function(e){return r(3,"error",e)},t}var on="change",an="internal-change";e.createConsoleLogger=rn,e.errors=r,e.initialize=function(e,n,t,o,r){var a,i,u,s,c=function(){if(t&&t.logger)return t.logger;return r&&r.logger&&r.logger.default||rn("warn")}(),l=_e(c),f=Me(l),v=Ye(t,l,r,c),d=v.sendEvents,g=e,m=v.hash,p=se(o,g,v),y=v.sendEvents&&!v.diagnosticOptOut,h=y?en(g):null,b=y?nn((new Date).getTime()):null,k=y?tn(o,b,p,g,v,h):null,E=Be(o,v,g,b),w=v.eventProcessor||qe(o,v,g,b,l,p),D=Ge(o,v,g),S={},O={},P=v.streaming,U=!1,I=!1,j=!0,R=v.stateProvider,T=function(e,t){var r,n={};return n.setUser=function(e){var n=r&&ee(r);(r=ue(e))&&t&&t(ee(r),n)},n.getUser=function(){return r?ee(r):null},e&&n.setUser(e),n}(null,function(e,n){(function(e){if(R)return;e&&F({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!v.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&q(e,n)}),N=We(o.localStorage,c);function F(e){if(g&&!(R&&R.enqueueEvent&&R.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(j&&(c.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),j=!1));j=!1}!d||I||o.isDoNotTrack()||(c.debug(pe(e.kind)),w.enqueue(e))}}function C(e,n,t,r){var i=T.getUser(),o=new Date,a=n?n.value:null;if(!v.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=S[u];if(s&&o-s<3e5)return;S[u]=o}var c={kind:"feature",key:e,user:i,value:a,variation:n?n.variationIndex:null,default:t,creationDate:o.getTime()};i&&i.anonymous&&(c.contextKind=x(i));var l=O[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),F(c)}function L(e,n,t,r){var i;if(O&&ae(O,e)&&O[e]&&!O[e].deleted){var o=O[e];i=A(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&C(e,i,n,r),i}function A(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function x(e){return e.anonymous?"anonymousUser":"user"}function q(e,n){R||e&&n&&F({kind:"alias",key:e.key,contextKind:x(e),previousKey:n.key,previousContextKind:x(n),creationDate:(new Date).getTime()})}function _(){i=!0,T.getUser()&&E.connect(T.getUser(),m,{ping:function(){c.debug("received ping message from stream");var n=T.getUser();D.fetchFlagSettings(n,m).then(function(e){ne(n,T.getUser())&&J(e||{})}).catch(function(e){l.maybeReportError(new Z(we(e)))})},put:function(e){var n=JSON.parse(e.data);c.debug("received streaming update for all flags"),J(n)},patch:function(e){var n=JSON.parse(e.data),t=O[n.key];if(!t||!t.version||!n.version||t.version<n.version){c.debug(ve(n.key));var r={},i=oe({},n);delete i.key;var o=A(O[n.key]=i);r[n.key]=t?{previous:t.value,current:o}:{current:o},z(r)}else c.debug(de(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!O[n.key]||O[n.key].version<n.version){c.debug(ge(n.key));var t={};O[n.key]&&!O[n.key].deleted&&(t[n.key]={previous:O[n.key].value}),O[n.key]={version:n.version,deleted:!0},z(t)}else c.debug(me(n.key))}})}function V(){i&&(E.disconnect(),i=!1)}function J(e){var n={};if(!e)return Promise.resolve();for(var t in O)ae(O,t)&&O[t]&&(e[t]&&!ne(e[t].value,O[t].value)?n[t]={previous:O[t].value,current:A(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:O[t].value}));for(var r in e)ae(e,r)&&e[r]&&(!O[r]||O[r].deleted)&&(n[r]={current:A(e[r])});return O=W({},e),z(n).catch(function(){})}function z(i){var e=Object.keys(i);if(0<e.length){var o={};e.forEach(function(e){var n=i[e].current,t=n?n.value:void 0,r=i[e].previous;l.emit(on+":"+e,t,r),o[e]=n?{current:t,previous:r}:{previous:r}}),l.emit(on,o),l.emit(an,O),v.sendEventsOnlyForVariation||R||e.forEach(function(e){C(e,i[e].current)})}return a&&s?s.saveFlags(O).catch(function(){return null}):Promise.resolve()}function M(){var e=P||u&&void 0===P;e&&!i?_():!e&&i&&V(),k&&k.setStreaming(e)}function K(e){return e===on||e.substr(0,on.length+1)===on+":"}if(o.localStorage&&(s=new Ke(o.localStorage,g,m,T,c)),"string"==typeof v.bootstrap&&"LOCALSTORAGE"===v.bootstrap.toUpperCase()&&(s?a=!0:c.warn(he())),"object"===X(v.bootstrap)&&(O=function(t){var e=Object.keys(t),r="$flagsState",i=t[r];!i&&e.length&&c.warn(fe()),!1===t.$valid&&c.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var o={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var n={value:t[e]};i&&i[e]?n=oe(n,i[e]):n.version=0,o[e]=n}}),o}(v.bootstrap)),R){var H=R.getInitialState();H?B(H):R.on("init",B),R.on("update",function(e){e.user&&T.setUser(e.user);e.flags&&J(e.flags)})}else(e?N.validateUser(n).then(function(e){return T.setUser(e),"object"===X(v.bootstrap)?$():a?s.loadFlags().catch(function(){return null}).then(function(e){return null==e?(O={},D.fetchFlagSettings(T.getUser(),m).then(function(e){return J(e||{})}).then($).catch(function(e){G(new Z(we(e)))})):(O=e,te($),D.fetchFlagSettings(T.getUser(),m).then(function(e){return J(e)}).catch(function(e){return l.maybeReportError(e)}))}):D.fetchFlagSettings(T.getUser(),m).then(function(e){O=e||{},$()}).catch(function(e){O={},G(e)})}):Promise.reject(new Q(le()))).catch(G);function B(e){g=e.environment,T.setUser(e.user),O=W({},e.flags),te($)}function $(){c.info("LaunchDarkly client initialized"),U=!0,M(),f.signalSuccess()}function G(e){f.signalFailure(e)}return{client:{waitForInitialization:function(){return f.getInitializationPromise()},waitUntilReady:function(){return f.getReadyPromise()},identify:function(e,r,n){return I?re(Promise.resolve({}),n):R?(c.warn("identify() has no effect here; it must be called on the main client instance"),re(Promise.resolve(ie(O)),n)):re((a&&s?s.clearFlags():Promise.resolve()).then(function(){return N.validateUser(e)}).then(function(t){return D.fetchFlagSettings(t,r).then(function(e){var n=ie(e);return T.setUser(t),m=r,e?J(e).then(function(){return n}):n})}).then(function(e){return i&&_(),e}).catch(function(e){return l.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return T.getUser()},variation:function(e,n){return L(e,n,!0,!1).value},variationDetail:function(e,n){return L(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&c.warn(ce(e));var r=T.getUser(),i={kind:"custom",key:e,user:r,url:o.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(i.contextKind=x(r)),null!=n&&(i.data=n),null!=t&&(i.metricValue=t),F(i)}else l.maybeReportError(new Y(ce(e)))},alias:q,on:function(e,n,t){K(e)?(u=!0,U&&M(),l.on(e,n,t)):l.on.apply(l,arguments)},off:function(e){if(l.off.apply(l,arguments),K(e)){var n=!1;l.getEvents().forEach(function(e){K(e)&&0<l.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,i&&void 0===P&&V())}},setStreaming:function(e){var n=null===e?void 0:e;n!==P&&(P=n,M())},flush:function(e){return re(d?w.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!O)return e;for(var n in O)ae(O,n)&&(e[n]=L(n,null,!v.sendEventsOnlyForVariation).value);return e},close:function(e){if(I)return re(Promise.resolve(),e);function n(){I=!0,O={}}return re(Promise.resolve().then(function(){if(V(),k&&k.stop(),d)return w.stop(),w.flush()}).then(n).catch(n),e)}},options:v,emitter:l,ident:T,logger:c,requestor:D,start:function(){d&&(k&&k.start(),w.start())},enqueueEvent:F,getFlagsInternal:function(){return O},getEnvironmentId:function(){return g},internalChangeEventName:an}},e.messages=xe,e.utils=w,e.version="3.4.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 W(e){return(W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function Q(i){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?n(o,!0).forEach(function(e){var n,t,r;n=i,r=o[t=e],t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(o)):n(o).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(o,e))})}return i}function f(e){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var P=t("LaunchDarklyUnexpectedResponseError"),Y=t("LaunchDarklyInvalidEnvironmentIdError"),i=t("LaunchDarklyInvalidUserError"),Z=t("LaunchDarklyInvalidEventKeyError"),d=t("LaunchDarklyInvalidArgumentError"),ee=t("LaunchDarklyFlagFetchError");function S(e){return!(400<=e&&e<500)||(400===e||408===e||429===e)}for(var r=Object.freeze({__proto__:null,LDUnexpectedResponseError:P,LDInvalidEnvironmentIdError:Y,LDInvalidUserError:i,LDInvalidEventKeyError:Z,LDInvalidArgumentError:d,LDFlagFetchError:ee,isHttpErrorRecoverable:S}),o=function(e){for(var n,t=e.length,r=t%3,i=[],o=0,a=t-r;o<a;o+=16383)i.push(v(e,o,a<o+16383?a:o+16383));1==r?(n=e[t-1],i.push(u[n>>2]+u[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],i.push(u[n>>10]+u[n>>4&63]+u[n<<2&63]+"="));return i.join("")},u=[],a=[],s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=s.length;c<l;++c)u[c]=s[c],a[s.charCodeAt(c)]=c;function v(e,n,t){for(var r,i,o=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(u[(i=r)>>18&63]+u[i>>12&63]+u[i>>6&63]+u[63&i]);return o.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63;var g=Array.isArray,p=Object.keys,m=Object.prototype.hasOwnProperty,y=function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,i,o,a=g(n),u=g(t);if(a&&u){if((i=n.length)!=t.length)return!1;for(r=i;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=p(n);if((i=v.length)!==p(t).length)return!1;for(r=i;0!=r--;)if(!m.call(t,v[r]))return!1;for(r=i;0!=r--;)if(!e(n[o=v[r]],t[o]))return!1;return!0}return n!=n&&t!=t},h=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function b(e){var n=unescape(encodeURIComponent(e));return o(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function O(e){return b(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function ne(e){return JSON.parse(JSON.stringify(e))}function te(e,n){return y(e,n)}function re(e){setTimeout(e,0)}function ie(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 k(e){var n={};for(var t in e)ue(e,t)&&(n[t]={value:e[t],version:0});return n}function oe(e){var n={};for(var t in e)ue(e,t)&&(n[t]=e[t].value);return n}function E(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 w(e){var n=e.version||"3.5.0";return e.userAgent+"/"+n}function U(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":w(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function I(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(Q({},e)):e}function ae(){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 Q({},e,{},n)},{})}function ue(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function se(e){if(!e)return e;var n;for(var t in h){var r=h[t],i=e[r];void 0!==i&&"string"!=typeof i&&((n=n||Q({},e))[r]=String(i))}return n||e}var D=Object.freeze({__proto__:null,btoa:b,base64URLEncode:O,clone:ne,deepEquals:te,onNextTick:re,wrapPromiseCallback:ie,transformValuesToVersionedValues:k,transformVersionedValuesToValues:oe,chunkUserEventsForUrl:E,getLDUserAgentString:w,getLDHeaders:U,transformHeaders:I,extend:ae,objectHasOwnProperty:ue,sanitizeUser:se});for(var j,T=(function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}(j={exports:{}},j.exports),j.exports),R=[],N=0;N<256;++N)R[N]=(N+256).toString(16).substr(1);var L,C,F=function(e,n){var t=n||0,r=R;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},A=0,x=0;var q=function(e,n,t){var r=n&&t||0,i=n||[],o=(e=e||{}).node||L,a=void 0!==e.clockseq?e.clockseq:C;if(null==o||null==a){var u=T();null==o&&(o=L=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=C=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:x+1,l=s-A+(c-x)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||A<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");A=s,C=a;var f=(1e4*(268435455&(s+=122192928e5))+(x=c))%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var v=s/4294967296*1e4&268435455;i[r++]=v>>>8&255,i[r++]=255&v,i[r++]=v>>>24&15|16,i[r++]=v>>>16&255,i[r++]=a>>>8|128,i[r++]=255&a;for(var d=0;d<6;++d)i[r+d]=o[d];return n||F(i)},_=2e3;function ce(u,e,s){var t="/a/"+e+".gif",c=ae({"Content-Type":"application/json"},U(u,s)),l=u.httpFallbackPing,f={};return f.sendChunk=function(e,r,i,n){var o=JSON.stringify(e),a=i?null:q();return n?function n(t){var e=i?c:ae({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,I(e,s),o).promise.then(function(e){if(e)return 400<=e.status&&S(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(r+t+"?d="+O(o)),Promise.resolve())},f.sendEvents=function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,i=u.httpAllowsPost();r=i?[e]:E(_-n.length,e);for(var o=[],a=0;a<r.length;a++)o.push(f.sendChunk(r[a],n,t,i));return Promise.all(o)},f}function V(e){var n={},s=e.allAttributesPrivate,c=e.privateAttributeNames||[],l={key:!0,custom:!0,anonymous:!0},f={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(r,i){return Object.keys(r).reduce(function(e,n){var t=e;return i(n)&&(!function(e){return!l[e]&&(s||-1!==o.indexOf(e)||-1!==c.indexOf(e))}(n)?t[0][n]=r[n]:t[1][n]=!0),t},[{},{}])}var o=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],i=t[1];if(e.custom){var a=n(e.custom,function(){return!0});r.custom=a[0],i=ae({},i,a[1])}var u=Object.keys(i);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function J(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}function z(){return"LaunchDarkly client initialized"}function M(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"}function le(e){return'Custom event "'+e+'" does not exist'}function fe(){return"No environment/client-side ID was specified."+G}function ve(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+G}function K(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."}function B(){return"identify() has no effect here; it must be called on the main client instance"}function H(){return"received ping message from stream"}function $(){return"received streaming update for all flags"}function de(e){return'received streaming update for flag "'+e+'"'}function ge(e){return'received streaming update for flag "'+e+'" but ignored due to version check'}function pe(e){return'received streaming deletion for flag "'+e+'"'}function me(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'}function ye(e){return'enqueueing "'+e+'" event'}var G=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",X=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},he=function(e){return'Expected application/json content type but got "'+e+'"'},be=function(e){return"local storage is unavailable: "+J(e)},ke=function(e){return"network error"+(e?" ("+e+")":"")},Ee=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+G},we=function(e){return"Error fetching flag settings: "+J(e)},De=function(){return"No user specified."+G},Oe=function(){return"Invalid user specified."+G},Pe=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},Se=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(S(e)?t:"giving up permanently")},Ue=function(){return"Cannot make HTTP requests in this environment."+G},Ie=function(){return"Closing stream connection"},je=function(e){return"Opening stream connection to "+e},Te=function(e,n){return"Error on stream connection: "+J(e)+", will continue retrying every "+n+" milliseconds."},Re=function(e){return'Ignoring unknown config option "'+e+'"'},Ne=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Le=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Ce=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Fe=function(e){return"polling for feature flags at "+e},Ae=function(e){return"sending "+e+" events"},xe=Object.freeze({__proto__:null,clientInitialized:z,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:X,eventWithoutUser:M,invalidContentType:he,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:be,networkError:ke,unknownCustomEventKey:le,environmentNotFound:Ee,environmentNotSpecified:fe,errorFetchingFlags:we,userNotSpecified:De,invalidUser:Oe,bootstrapOldFormat:ve,bootstrapInvalid:K,deprecated:Pe,httpErrorMessage:Se,httpUnavailable:Ue,identifyDisabled:B,streamClosing:Ie,streamConnecting:je,streamError:Te,unknownOption:Re,wrongOptionType:Ne,wrongOptionTypeBoolean:Le,optionBelowMinimum:Ce,debugPolling:Fe,debugStreamPing:H,debugStreamPut:$,debugStreamPatch:de,debugStreamPatchIgnored:ge,debugStreamDelete:pe,debugStreamDeleteIgnored:me,debugEnqueueingEvent:ye,debugPostingEvents:Ae,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function qe(e,n,t,r,i,o){var a,u=3<arguments.length&&void 0!==r?r:null,s=4<arguments.length&&void 0!==i?i:null,c={},l=(5<arguments.length&&void 0!==o?o:null)||ce(e,t,n),f=n.eventsUrl+"/events/bulk/"+t,v=function(){var e={},a=0,u=0,s={};return e.summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=s[n];t?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate)}},e.getSummary=function(){var e={},n=!0;for(var t in s){var r=s[t],i=e[r.key];i||(i={default:r.default,counters:[]},e[r.key]=i);var o={value:r.value,count:r.count};void 0!==r.variation&&null!==r.variation&&(o.variation=r.variation),r.version?o.version=r.version:o.unknown=!0,i.counters.push(o),n=!1}return n?null:{startDate:a,endDate:u,features:e}},e.clearSummary=function(){u=a=0,s={}},e}(),d=V(n),g=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){b.length<m?(b.push(e),w=!1):(w||(w=!0,h.warn(X())),u&&u.incrementDroppedEvents())}return c.enqueue=function(e){if(!E){var n=!1,t=!1;if(v.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&(e.debugEventsUntilDate>k&&e.debugEventsUntilDate>(new Date).getTime())}(e)):n=D(),n&&O(function(e){var n=ae({},e);return"alias"===e.kind||(g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}(e)),t){var r=ae({},e,{kind:"debug"});r.user=d.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,O(r)}}},c.flush=function(){if(E)return Promise.resolve();var e=b,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),u&&u.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(b=[],h.debug(Ae(e.length)),l.sendEvents(e,f).then(function(e){e&&(e.serverTime&&(k=e.serverTime),S(e.status)||(E=!0),400<=e.status&&re(function(){s.maybeReportError(new P(Se(e.status,"event posting","some events were dropped")))}))}))},c.start=function(){a=setTimeout(function e(){c.flush(),a=setTimeout(e,y)},y)},c.stop=function(){clearTimeout(a)},c}function _e(n){var e={},i={};return e.on=function(e,n,t){i[e]=i[e]||[],i[e]=i[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(i[e])for(var r=0;r<i[e].length;r++)i[e][r].handler===n&&i[e][r].context===t&&(i[e]=i[e].slice(0,r).concat(i[e].slice(r+1)))},e.emit=function(e){if(i[e])for(var n=i[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(i)},e.getEventListenerCount=function(e){return i[e]?i[e].length:0},e.maybeReportError=function(e){e&&(!function(e){return!!i[e]}("error")?(n||console).error(e.message):this.emit("error",e))},e}var Ve="ready",Je="initialized",ze="failed";var Me=function(r){var n=!1,t=!1,i=null,e=null,o=new Promise(function(n){r.on(Ve,function e(){r.off(Ve,e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(i):e=new Promise(function(n,t){r.on(Je,function e(){r.off(Je,e),n()}),r.on(ze,function e(n){r.off(ze,e),t(n)})}))},getReadyPromise:function(){return o},signalSuccess:function(){n||t||(n=!0,r.emit(Je),r.emit(Ve))},signalFailure:function(e){n||t||(t=!0,i=e,r.emit(ze,e),r.emit(Ve)),r.maybeReportError(e)}}};function Ke(t,r,i,o){var a={};function u(){var e="",n=o.getUser();return n&&(e=i||b(JSON.stringify(n))),"ld:"+r+":"+e}return a.loadFlags=function(){return t.get(u()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=k(n):delete n.$schema}return n}catch(e){return a.clearFlags().then(function(){return null})}})},a.saveFlags=function(e){var n=ae({},e,{$schema:1});return t.set(u(),JSON.stringify(n))},a.clearFlags=function(){return t.clear(u())},a}function Be(r,n){function i(e){t||(t=!0,n.warn(be(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 He=3e5;function $e(i,o,a,n){var u,s=o.streamUrl,c=o.logger,e={},l=s+"/eval/"+a,f=o.useReport,v=o.evaluationReasons,t=o.streamReconnectDelay,d=U(i,o),g=!1,p=null,m=null,y=null,h=null,b=null;function k(e){g||(c.warn(Te(e,t)),g=!0),D(!1),w(),E(t)}function E(e){m||(e?m=setTimeout(r,e):r())}function r(){var e;m=null;var n="",t={headers:d,readTimeoutMillis:He};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=s+"/ping/"+a,n=""):e=l+"/"+O(JSON.stringify(y)),t.headers=I(t.headers,o),v&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,w(),c.info(je(e)),u=(new Date).getTime(),p=i.eventSourceFactory(e,t),b)ue(b,r)&&p.addEventListener(r,b[r]);p.onerror=k}}function w(){p&&(c.info(Ie()),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={};function r(n){b[n]=function(e){D(!(g=!1)),t[n]&&t[n](e)}}for(var i in t||{})r(i);E()},e.disconnect=function(){clearTimeout(m),m=null,w()},e.isConnected=function(){return!!(p&&i.eventSourceIsActive&&i.eventSourceIsActive(p))},e}var Ge="application/json";function Xe(u,s,a){var c=s.baseUrl,l=s.useReport,f=s.evaluationReasons,v=s.logger,e={},d={};function g(e,n){if(!u.httpRequest)return new Promise(function(e,n){n(new ee(Ue()))});var t=n?"REPORT":"GET",r=U(u,s);n&&(r["Content-Type"]=Ge);var i=d[e];i||(i=function(t){var r,i,o,a,e={addPromise:function(n,e){r=n,i&&i(),i=e,n.then(function(e){r===n&&(o(e),t&&t())},function(e){r===n&&(a(e),t&&t())})}};return e.resultPromise=new Promise(function(e,n){o=e,a=n}),e}(function(){delete d[e]}),d[e]=i);var o=u.httpRequest(t,e,I(r,s),n),a=o.promise.then(function(e){if(200!==e.status)return Promise.reject(function(e){return 404===e.status?new Y(Ee()):new ee(we(e.statusText||String(e.status)))}(e));if(e.header("content-type")&&e.header("content-type").substring(0,Ge.length)===Ge)return JSON.parse(e.body);var n=he(e.header("content-type")||"");return Promise.reject(new ee(n))},function(e){return Promise.reject(new ee(ke(e)))});return i.addPromise(a,function(){o.cancel&&o.cancel()}),i.resultPromise}return e.fetchJSON=function(e){return g(c+e,null)},e.fetchFlagSettings=function(e,n){var t,r,i,o="";return l?(r=[c,"/sdk/evalx/",a,"/user"].join(""),i=JSON.stringify(e)):(t=O(JSON.stringify(e)),r=[c,"/sdk/evalx/",a,"/users/",t].join("")),n&&(o="h="+n),f&&(o=o+(o?"&":"")+"withReasons=true"),r=r+(o?"?":"")+o,v.debug(Fe(r)),g(r,i)},e}var We="ld:$anonUserId";function Qe(r){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new i(De()));var t=ne(e);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?r.get(We).then(function(e){if(e)return t.key=e,t;var n=q();return function(e){return r.set(We,e)}(t.key=n).then(function(){return t})}):Promise.reject(new i(Oe()))},e}var Ye=["debug","info","warn","error","none"];function Ze(e,a){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 u=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],s=!(!e||!e.destination),c=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",r=1;if(e&&e.level)for(var t=0;t<Ye.length;t++)Ye[t]===e.level&&(r=t);for(var i={},o=function(e){var n=Ye[e];if("none"!==n)if(e<r)i[n]=function(){};else{var t=e;i[n]=function(){!function(e,n,t){if(!(t.length<1)){var r,i=s?n+": "+c:c;if(1!==t.length&&a){var o=f(t);o[0]=i+o[0],r=a.apply(void 0,f(o))}else r=i+t[0];try{u[e](r)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}(t,n,arguments)}}},l=0;l<Ye.length;l++)o(l);return i}function en(e,n){return Ze({level:e,prefix:n})}var nn={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}};function tn(e,n,t,r){var a=ae({logger:{default:r}},nn,t),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){re(function(){n&&n.maybeReportError(new d(e))})}var o,s,c,l,f=ae({},e||{});function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=W(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}return o=f,Object.keys(i).forEach(function(e){if(void 0!==o[e]){var n=i[e];r&&r.warn(Pe(e,n)),n&&(void 0===o[n]&&(o[n]=o[e]),delete o[e])}}),s=ae({},f),Object.keys(a).forEach(function(e){void 0!==s[e]&&null!==s[e]||(s[e]=a[e]&&a[e].default)}),l=ae({},c=f=s),Object.keys(c).forEach(function(e){var n=c[e];if(null!=n){var t=a[e];if(void 0===t)u(Re(e));else{var r=t.type||v(t.default);if("any"!==r){var i=r.split("|"),o=v(n);i.indexOf(o)<0?"boolean"===r?(l[e]=!!n,u(Le(e,o))):(u(Ne(e,r,o)),l[e]=t.default):"number"===o&&void 0!==t.minimum&&n<t.minimum&&(u(Ce(e,n,t.minimum)),l[e]=t.minimum)}}}}),function(n){Ye.forEach(function(e){if("none"!==e&&(!n[e]||"function"!=typeof n[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")})}((f=l).logger),f}var rn=Object.freeze({__proto__:null,baseOptionDefs:nn,validate:tn}).baseOptionDefs;var on=function(e){var n={diagnosticId:q()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},an=function(e){var n,t,r,i;function o(e){n=e,r=t=0,i=[]}return o(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:i}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,i=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};i.push(r)},reset:o}},un=function(n,r,e,t,i,o,a){var u,s,c=!!n.diagnosticUseCombinedEvent,l="ld:"+i+":$diagnostics",f=o.eventsUrl+"/events/diagnostic/"+i,v=o.diagnosticRecordingInterval,d=e,g=!!o.streaming,p={};function m(){return{sdk:function(){var e=Q({},n.diagnosticSdkData);o.wrapperName&&(e.wrapperName=o.wrapperName);o.wrapperVersion&&(e.wrapperVersion=o.wrapperVersion);return e}(),configuration:{customBaseURI:o.baseUrl!==rn.baseUrl.default,customStreamURI:o.streamUrl!==rn.streamUrl.default,customEventsURI:o.eventsUrl!==rn.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 y(e){o.logger&&o.logger.debug(xe.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function h(){y(function(){var e=(new Date).getTime(),n=Q({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},d.getProps());return c&&(n=Q({},n,{},m())),d.reset(e),n}()),s=setTimeout(h,v),u=(new Date).getTime(),c&&function(){if(r.isEnabled()){var e=Q({},d.getProps());r.set(l,JSON.stringify(e))}}()}return p.start=function(){c?function(t){if(!r.isEnabled())return t(!1);r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);d.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(u||0)+v,t=(new Date).getTime();n<=t?h():s=setTimeout(h,n-t)}else 0===Math.floor(4*Math.random())?h():s=setTimeout(h,v)}):(y(Q({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate},m())),s=setTimeout(h,v))},p.stop=function(){s&&clearTimeout(s)},p.setStreaming=function(e){g=e},p},sn="change",cn="internal-change";e.commonBasicLogger=Ze,e.createConsoleLogger=en,e.errors=r,e.initialize=function(e,n,t,o,r){var a,i,u,s=function(){if(t&&t.logger)return t.logger;return r&&r.logger&&r.logger.default||en("warn")}(),c=_e(s),l=Me(c),f=tn(t,c,r,s),v=f.sendEvents,d=e,g=f.hash,p=Be(o.localStorage,s),m=ce(o,d,f),y=f.sendEvents&&!f.diagnosticOptOut,h=y?on(d):null,b=y?an((new Date).getTime()):null,k=y?un(o,p,b,m,d,f,h):null,E=$e(o,f,d,b),w=f.eventProcessor||qe(o,f,d,b,c,m),D=Xe(o,f,d),O={},P={},S=f.streaming,U=!1,I=!1,j=!0,T=f.stateProvider,R=function(e,t){var r,n={};return n.setUser=function(e){var n=r&&ne(r);(r=se(e))&&t&&t(ne(r),n)},n.getUser=function(){return r?ne(r):null},e&&n.setUser(e),n}(null,function(e,n){(function(e){if(T)return;e&&C({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!f.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&_(e,n)}),N=Qe(p),L=p.isEnabled()?new Ke(p,d,g,R,s):null;function C(e){if(d&&!(T&&T.enqueueEvent&&T.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(j&&(s.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),j=!1));j=!1}!v||I||o.isDoNotTrack()||(s.debug(ye(e.kind)),w.enqueue(e))}}function F(e,n,t,r){var i=R.getUser(),o=new Date,a=n?n.value:null;if(!f.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(i&&i.key?i.key:"")+e,s=O[u];if(s&&o-s<3e5)return;O[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=q(i));var l=P[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),C(c)}function A(e,n,t,r){var i;if(P&&ue(P,e)&&P[e]&&!P[e].deleted){var o=P[e];i=x(o),null!==o.value&&void 0!==o.value||(i.value=n)}else i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&F(e,i,n,r),i}function x(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function q(e){return e.anonymous?"anonymousUser":"user"}function _(e,n){T||e&&n&&C({kind:"alias",key:e.key,contextKind:q(e),previousKey:n.key,previousContextKind:q(n),creationDate:(new Date).getTime()})}function V(){i=!0,R.getUser()&&E.connect(R.getUser(),g,{ping:function(){s.debug("received ping message from stream");var n=R.getUser();D.fetchFlagSettings(n,g).then(function(e){te(n,R.getUser())&&z(e||{})}).catch(function(e){c.maybeReportError(new ee(we(e)))})},put:function(e){var n=JSON.parse(e.data);s.debug("received streaming update for all flags"),z(n)},patch:function(e){var n=JSON.parse(e.data),t=P[n.key];if(!t||!t.version||!n.version||t.version<n.version){s.debug(de(n.key));var r={},i=ae({},n);delete i.key;var o=x(P[n.key]=i);r[n.key]=t?{previous:t.value,current:o}:{current:o},M(r)}else s.debug(ge(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!P[n.key]||P[n.key].version<n.version){s.debug(pe(n.key));var t={};P[n.key]&&!P[n.key].deleted&&(t[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},M(t)}else s.debug(me(n.key))}})}function J(){i&&(E.disconnect(),i=!1)}function z(e){var n={};if(!e)return Promise.resolve();for(var t in P)ue(P,t)&&P[t]&&(e[t]&&!te(e[t].value,P[t].value)?n[t]={previous:P[t].value,current:x(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:P[t].value}));for(var r in e)ue(e,r)&&e[r]&&(!P[r]||P[r].deleted)&&(n[r]={current:x(e[r])});return P=Q({},e),M(n).catch(function(){})}function M(i){var e=Object.keys(i);if(0<e.length){var o={};e.forEach(function(e){var n=i[e].current,t=n?n.value:void 0,r=i[e].previous;c.emit(sn+":"+e,t,r),o[e]=n?{current:t,previous:r}:{previous:r}}),c.emit(sn,o),c.emit(cn,P),f.sendEventsOnlyForVariation||T||e.forEach(function(e){F(e,i[e].current)})}return a&&L?L.saveFlags(P):Promise.resolve()}function K(){var e=S||u&&void 0===S;e&&!i?V():!e&&i&&J(),k&&k.setStreaming(e)}function B(e){return e===sn||e.substr(0,sn.length+1)===sn+":"}if("string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(L?a=!0:s.warn(be())),"object"===W(f.bootstrap)&&(P=function(t){var e=Object.keys(t),r="$flagsState",i=t[r];!i&&e.length&&s.warn(ve()),!1===t.$valid&&s.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var o={};return e.forEach(function(e){if(e!==r&&"$valid"!==e){var n={value:t[e]};i&&i[e]?n=ae(n,i[e]):n.version=0,o[e]=n}}),o}(f.bootstrap)),T){var H=T.getInitialState();H?$(H):T.on("init",$),T.on("update",function(e){e.user&&R.setUser(e.user);e.flags&&z(e.flags)})}else(e?N.validateUser(n).then(function(e){return R.setUser(e),"object"===W(f.bootstrap)?G():a?L.loadFlags().then(function(e){return null==e?(P={},D.fetchFlagSettings(R.getUser(),g).then(function(e){return z(e||{})}).then(G).catch(function(e){X(new ee(we(e)))})):(P=e,re(G),D.fetchFlagSettings(R.getUser(),g).then(function(e){return z(e)}).catch(function(e){return c.maybeReportError(e)}))}):D.fetchFlagSettings(R.getUser(),g).then(function(e){P=e||{},G()}).catch(function(e){P={},X(e)})}):Promise.reject(new Y(fe()))).catch(X);function $(e){d=e.environment,R.setUser(e.user),P=Q({},e.flags),re(G)}function G(){s.info("LaunchDarkly client initialized"),U=!0,K(),l.signalSuccess()}function X(e){l.signalFailure(e)}return{client:{waitForInitialization:function(){return l.getInitializationPromise()},waitUntilReady:function(){return l.getReadyPromise()},identify:function(e,r,n){return I?ie(Promise.resolve({}),n):T?(s.warn("identify() has no effect here; it must be called on the main client instance"),ie(Promise.resolve(oe(P)),n)):ie((a&&L?L.clearFlags():Promise.resolve()).then(function(){return N.validateUser(e)}).then(function(t){return D.fetchFlagSettings(t,r).then(function(e){var n=oe(e);return R.setUser(t),g=r,e?z(e).then(function(){return n}):n})}).then(function(e){return i&&V(),e}).catch(function(e){return c.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return R.getUser()},variation:function(e,n){return A(e,n,!0,!1).value},variationDetail:function(e,n){return A(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&s.warn(le(e));var r=R.getUser(),i={kind:"custom",key:e,user:r,url:o.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(i.contextKind=q(r)),null!=n&&(i.data=n),null!=t&&(i.metricValue=t),C(i)}else c.maybeReportError(new Z(le(e)))},alias:_,on:function(e,n,t){B(e)?(u=!0,U&&K(),c.on(e,n,t)):c.on.apply(c,arguments)},off:function(e){if(c.off.apply(c,arguments),B(e)){var n=!1;c.getEvents().forEach(function(e){B(e)&&0<c.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,i&&void 0===S&&J())}},setStreaming:function(e){var n=null===e?void 0:e;n!==S&&(S=n,K())},flush:function(e){return ie(v?w.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!P)return e;for(var n in P)ue(P,n)&&(e[n]=A(n,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){if(I)return ie(Promise.resolve(),e);function n(){I=!0,P={}}return ie(Promise.resolve().then(function(){if(J(),k&&k.stop(),v)return w.stop(),w.flush()}).then(n).catch(n),e)}},options:f,emitter:c,ident:R,logger:s,requestor:D,start:function(){v&&(k&&k.start(),w.start())},enqueueEvent:C,getFlagsInternal:function(){return P},getEnvironmentId:function(){return d},internalChangeEventName:cn}},e.messages=xe,e.utils=D,e.version="3.5.0",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=ldclient-common.min.js.map |
{ | ||
"name": "launchdarkly-js-sdk-common", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"description": "LaunchDarkly SDK for JavaScript - common code", | ||
@@ -71,3 +71,3 @@ "author": "LaunchDarkly <team@launchdarkly.com>", | ||
"semver-compare": "^1.0.0", | ||
"typescript": "^3.7.5" | ||
"typescript": "~4.4.4" | ||
}, | ||
@@ -74,0 +74,0 @@ "dependencies": { |
100
typings.d.ts
@@ -56,2 +56,4 @@ /** | ||
* To make LDClient use this logger, put it in the `logger` property of [[LDOptions]]. | ||
* | ||
* @deprecated Please use `basicLogger` instead. | ||
*/ | ||
@@ -70,4 +72,3 @@ export function createConsoleLogger(minimumLevel: string): LDLogger; | ||
* | ||
* If not specified, the default is [[createConsoleLogger]] in the browser SDK, or a logger | ||
* from the `winston` package in Electron. | ||
* If not specified, the default is to use `basicLogger`. | ||
*/ | ||
@@ -455,4 +456,3 @@ logger?: LDLogger; | ||
/** | ||
* The basic interface for the LaunchDarkly client. The browser SDK and the Electron SDK both | ||
* use this, but may add some methods of their own. | ||
* The basic interface for the LaunchDarkly client. Platform-specific SDKs may add some methods of their own. | ||
* | ||
@@ -741,2 +741,94 @@ * @see https://docs.launchdarkly.com/sdk/client-side/javascript | ||
} | ||
/** | ||
* Provides a simple [[LDLogger]] implementation. | ||
* | ||
* This logging implementation uses a simple format that includes only the log level | ||
* and the message text. Output is written to the console unless otherwise specified. | ||
* You can filter by log level as described in [[BasicLoggerOptions.level]]. | ||
* | ||
* To use the logger created by this function, put it into [[LDOptions.logger]]. If | ||
* you do not set [[LDOptions.logger]] to anything, the SDK uses a default logger | ||
* that is equivalent to `ld.basicLogger({ level: 'info' })`. | ||
* | ||
* @param options Configuration for the logger. If no options are specified, the | ||
* logger uses `{ level: 'info' }`. | ||
* | ||
* @param formatter An optional function equivalent to Node's util.format, allowing | ||
* for parameter substitution in log messages. If this is omitted, parameter | ||
* substitution is not available. | ||
* | ||
* @example | ||
* This example shows how to use `basicLogger` in your SDK options to enable console | ||
* logging only at `warn` and `error` levels. | ||
* ```javascript | ||
* const ldOptions = { | ||
* logger: ld.basicLogger({ level: 'warn' }), | ||
* }; | ||
* ``` | ||
* | ||
* @example | ||
* This example shows how to use `basicLogger` in your SDK options to cause log | ||
* output to always go to `console.error` instead of `console.log`. | ||
* ```javascript | ||
* const ldOptions = { | ||
* logger: ld.basicLogger({ destination: console.error }), | ||
* }; | ||
* ``` | ||
* | ||
* @ignore (don't need to show this separately in TypeDoc output; each SDK should provide its own | ||
* basicLogger function that delegates to this and sets the formatter parameter) | ||
*/ | ||
export function commonBasicLogger( | ||
options?: BasicLoggerOptions, | ||
formatter?: (format: string, ...args: any[]) => void | ||
): LDLogger; | ||
/** | ||
* Configuration for [[basicLogger]]. | ||
*/ | ||
export interface BasicLoggerOptions { | ||
/** | ||
* The lowest level of log message to enable. | ||
* | ||
* See [[LDLogLevel]] for a list of possible levels. Setting a level here causes | ||
* all lower-importance levels to be disabled: for instance, if you specify | ||
* `'warn'`, then `'debug'` and `'info'` are disabled. | ||
* | ||
* If not specified, the default is `'info'` (meaning that `'debug'` is disabled). | ||
*/ | ||
level?: LDLogLevel; | ||
/** | ||
* A string to prepend to all log output. If not specified, the default is | ||
* "[LaunchDarkly] ". | ||
*/ | ||
prefix?: string; | ||
/** | ||
* An optional function to use to print each log line. | ||
* | ||
* If this is specified, `basicLogger` calls it to write each line of output. The | ||
* argument is a fully formatted log line, not including a linefeed. The function | ||
* is only called for log levels that are enabled. | ||
* | ||
* If not specified, the default in browsers is to use `console.log`, `console.info`, | ||
* `console.warn`, or `console.error` according to the level; the default in | ||
* Node.js and Electron is to always use `console.log`. | ||
* | ||
* Setting this property to anything other than a function will cause SDK | ||
* initialization to fail. | ||
*/ | ||
destination?: (line: string) => void, | ||
} | ||
/** | ||
* Logging levels that can be used with [[basicLogger]]. | ||
* | ||
* Set [[BasicLoggerOptions.level]] to one of these values to control what levels | ||
* of log messages are enabled. Going from lowest importance (and most verbose) | ||
* to most importance, the levels are `'debug'`, `'info'`, `'warn'`, and `'error'`. | ||
* You can also specify `'none'` instead to disable all logging. | ||
*/ | ||
export type LDLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none'; | ||
} |
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
605479
1169