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