launchdarkly-js-client-sdk
Advanced tools
Comparing version 2.17.0 to 2.17.1
@@ -5,2 +5,7 @@ # Change log | ||
## [2.17.1] - 2020-03-06 | ||
### Fixed: | ||
- At client initialization time, if the initial flag polling request failed, it would cause an unhandled promise rejection unless the application had called `waitForInitialization()` and provided an error handler for the promise that was returned by that method. While that is correct behavior if the application did call `waitForInitialization()` (any promise that might be rejected should have an error handler attached), it is inappropriate if the application did not call `waitForInitialization()` at all-- which is not mandatory, since the application could use events instead, or `waitUntilReady()`, or might simply not care about waiting for initialization. This has been fixed so that no such promise is created until the first time the application calls `waitForInitialization()`; subsequent calls to the same method will return the same promise (since initialization can only happen once). | ||
- A bug in the event emitter made its behavior unpredictable if an event handler called `on` or `off` while handling an event. This has been fixed so that all event handlers that were defined _at the time the event was fired_ will be called; any changes made will not take effect until the next event. | ||
## [2.17.0] - 2020-02-14 | ||
@@ -7,0 +12,0 @@ Note: if you are using the LaunchDarkly Relay Proxy to forward events, update the Relay to version 5.10.0 or later before updating to this Node SDK version. |
@@ -1,2 +0,2 @@ | ||
"use strict";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(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 r(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?t(o,!0).forEach(function(e){n(r,e,o[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(o).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}function i(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}Object.defineProperty(exports,"__esModule",{value:!0});var o=i("LaunchDarklyUnexpectedResponseError"),a=i("LaunchDarklyInvalidEnvironmentIdError"),u=i("LaunchDarklyInvalidUserError"),s=i("LaunchDarklyInvalidEventKeyError"),c=i("LaunchDarklyInvalidArgumentError"),l=i("LaunchDarklyFlagFetchError");function f(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:o,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:s,LDInvalidArgumentError:c,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(b(e,i,a<i+16383?a:i+16383));return 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]+"=")),o.join("")},g=[],p=[],m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,y=m.length;h<y;++h)g[h]=m[h],p[m.charCodeAt(h)]=h;function b(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(g[(o=r)>>18&63]+g[o>>12&63]+g[o>>6&63]+g[63&o]);return i.join("")}p["-".charCodeAt(0)]=62,p["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,w=Object.prototype.hasOwnProperty,D=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function S(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function O(e){return S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function P(e){return JSON.parse(JSON.stringify(e))}function U(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=k(n),u=k(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=E(n);if((o=v.length)!==E(t).length)return!1;for(r=o;0!=r--;)if(!w.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function I(e){setTimeout(e,0)}function j(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function R(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function T(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function N(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=O(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function F(e){var n=e.version||"3.2.2";return e.userAgent+"/"+n}function C(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":F(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function L(){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 D){var o=D[t],i=e[o];void 0!==i&&"string"!=typeof i&&((n=n||r({},e))[o]=String(i))}return n||e}for(var x=Object.freeze({__proto__:null,btoa:S,base64URLEncode:O,clone:P,deepEquals:U,onNextTick:I,wrapPromiseCallback:j,transformValuesToVersionedValues:R,transformVersionedValuesToValues:T,chunkUserEventsForUrl:N,getLDUserAgentString:F,getLDHeaders:C,extend:L,sanitizeUser:A}),V=function(e,n){return 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}}}(n={exports:{}}),n.exports}(),q=[],_=0;_<256;++_)q[_]=(_+256).toString(16).substr(1);var J,z,M=function(e,n){var t=n||0,r=q;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},B=0,K=0,$=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=V();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 s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:K+1,l=s-B+(c-K)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||B<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");B=s,z=a;var f=(1e4*(268435455&(s+=122192928e5))+(K=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||M(o)};function G(u,e,n){var t="/a/"+e+".gif",s=L({"Content-Type":"application/json"},C(u,n)),c=u.httpFallbackPing,l={sendChunk:function(e,r,o,n){var i=JSON.stringify(e),a=o?null:$();return n?function n(t){var e=o?s:L({},s,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,e,i).promise.then(function(e){if(e)return 400<=e.status&&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(){}):(c&&c(r+t+"?d="+O(i)),Promise.resolve())},sendEvents:function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,o=u.httpAllowsPost();r=o?[e]:N(2e3-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(l.sendChunk(r[a],n,t,o));return Promise.all(i)}};return l}function H(){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 X(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(o,i){return Object.keys(o).reduce(function(e,n){var t,r=e;return i(n)&&(l[t=n]||!s&&-1===a.indexOf(t)&&-1===c.indexOf(t)?r[0][n]=o[n]:r[1][n]=!0),r},[{},{}])}var a=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],o=t[1];if(e.custom){var i=n(e.custom,function(){return!0});r.custom=i[0],o=L({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},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"},ie=function(e){return"network error"+(e?" ("+e+")":"")},oe=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},se=function(e){return"Error fetching flag settings: "+W(e)},ce=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"},he=function(){return"Closing stream connection"},ye=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"},De=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Se=function(e){return"polling for feature flags at "+e},Oe=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+'"'},Ie=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},je=function(e){return'received streaming deletion for flag "'+e+'"'},Re=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Te=function(e){return'enqueueing "'+e+'" event'},Ne=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:ie,unknownCustomEventKey:oe,environmentNotFound:ae,environmentNotSpecified:ue,errorFetchingFlags:se,userNotSpecified:ce,invalidUser:le,bootstrapOldFormat:fe,bootstrapInvalid:ve,deprecated:de,httpErrorMessage:ge,httpUnavailable:pe,identifyDisabled:me,streamClosing:he,streamConnecting:ye,streamError:be,unknownOption:ke,wrongOptionType:Ee,wrongOptionTypeBoolean:we,optionBelowMinimum:De,debugPolling:Se,debugStreamPing:Oe,debugStreamPut:Pe,debugStreamPatch:Ue,debugStreamPatchIgnored:Ie,debugStreamDelete:je,debugStreamDeleteIgnored:Re,debugEnqueueingEvent:Te,debugPostingEvents:Ne,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function Ce(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&&(o.error?this.emit("error",e):(n||console).error(e.message))},e}function Le(t,r,o,i,a){var u={};function s(){var e="",n=i.getUser();return n&&(e=o||S(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=R(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.saveFlags=function(e){var n=L({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u}function Ae(o,e,i,n){var a,u=e.streamUrl,s=e.logger,t={},c=u+"/eval/"+i,l=e.useReport,f=e.evaluationReasons,r=e.streamReconnectDelay,v=C(o,e),d=!1,g=null,p=null,m=null,h=null,y=null;function w(e){d||(s.warn(be(e,r)),d=!0),S(!1),E(),b(r)}function b(e){p||(e?p=setTimeout(k,e):k())}function k(){var e;p=null;var n="",t={headers:v};if(o.eventSourceFactory){for(var r in null!=h&&(n="h="+h),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+"/"+O(JSON.stringify(m)),f&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,E(),s.info(ye(e)),a=(new Date).getTime(),g=o.eventSourceFactory(e,t),y)y.hasOwnProperty(r)&&g.addEventListener(r,y[r]);g.onerror=w}}function E(){g&&(s.info("Closing stream connection"),g.close(),g=null)}function S(e){a&&n&&n.recordStreamInit(a,!e,(new Date).getTime()-a),a=null}return t.connect=function(e,n,t){m=e,h=n,y={};function r(n){y[n]=function(e){S(!(d=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);b()},t.disconnect=function(){clearTimeout(p),p=null,E()},t.isConnected=function(){return!!(g&&o.eventSourceIsActive&&o.eventSourceIsActive(g))},t}function xe(p,m,u){var s=m.baseUrl,c=m.useReport,f=m.evaluationReasons,v=m.logger,e={},h={};function d(e,n){if(!p.httpRequest)return new Promise(function(e,n){n(new l(pe()))});var t=n?"REPORT":"GET",r=C(p,m);n&&(r["Content-Type"]="application/json");var o,i,u,s,c,f,v=h[e];v||(o=function(){delete h[e]},(f={addPromise:function(n,e){i=n,u&&u(),u=e,n.then(function(e){i===n&&(s(e),o())},function(e){i===n&&(c(e),o())})}}).resultPromise=new Promise(function(e,n){s=e,c=n}),v=f,h[e]=v);var d=p.httpRequest(t,e,r,n),g=d.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new a(ae()):new l(se(n.statusText||String(n.status))));if(e.header("content-type")&&0===e.header("content-type").lastIndexOf("application/json"))return JSON.parse(e.body);var n,t=ne(e.header("content-type")||"");return Promise.reject(new l(t))},function(e){return Promise.reject(new l(ie(e)))});return v.addPromise(g,function(){d.cancel&&d.cancel()}),v.resultPromise}return e.fetchJSON=function(e){return d(s+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return c?(r=[s,"/sdk/evalx/",u,"/user"].join(""),o=JSON.stringify(e)):(t=O(JSON.stringify(e)),r=[s,"/sdk/evalx/",u,"/users/",t].join("")),n&&(i="h="+n),f&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,v.debug(Se(r)),d(r,o)},e}function Ve(o,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new u(ce()));var r=P(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(o?o.get("ld:$anonUserId").catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return r.key=e,r;var n,t=$();return r.key=t,(n=t,o?o.set("ld:$anonUserId",n).catch(function(){i.warn("localStorage is unavailable, so anonymous user ID cannot be cached")}):Promise.resolve()).then(function(){return r})}):Promise.reject(new u(le()))},e}var qe={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function _e(n,t,r,o){var a=L({logger:{default:o}},qe,r),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){I(function(){t&&t.maybeReportError(new c(e))})}var s,l,f,v,d=L({},n||{});return v=d,Object.keys(i).forEach(function(e){if(void 0!==v[e]){var n=i[e];o&&o.warn(de(e,n)),n&&(void 0===v[n]&&(v[n]=v[e]),delete v[e])}}),f=L({},d),Object.keys(a).forEach(function(e){void 0!==f[e]&&null!==f[e]||(f[e]=a[e]&&a[e].default)}),s=d=f,l=L({},s),Object.keys(s).forEach(function(e){var n=s[e];if(null!=n){var t=a[e];if(void 0===t)u(ke(e));else{var r=t.type||g(t.default);if("any"!==r){var o=r.split("|"),i=g(n);o.indexOf(i)<0?"boolean"===r?(l[e]=!!n,u(we(e,i))):(u(Ee(e,r,i)),l[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(De(e,n,t.minimum)),l[e]=t.minimum)}}}}),l;function g(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"}}}var Je=Object.freeze({__proto__:null,baseOptionDefs:qe,validate:_e}).baseOptionDefs,ze=function(e){var n={diagnosticId:$()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},Me=function(e){var n,t,r,o;function i(e){n=e,r=t=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:o}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};o.push(r)},reset:i}},Be=function(o,e,n,t,i,a){var u,s,c=!!o.diagnosticUseCombinedEvent,l="ld:"+t+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+t,v=i.diagnosticRecordingInterval,d=e,g=!!i.streaming,p={};function m(){return{sdk:function(){var e=r({},o.diagnosticSdkData);return i.wrapperName&&(e.wrapperName=i.wrapperName),i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion),e}(),configuration:(e={customBaseURI:i.baseUrl!==Je.baseUrl.default,customStreamURI:i.streamUrl!==Je.streamUrl.default,customEventsURI:i.eventsUrl!==Je.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation},e),platform:o.diagnosticPlatformData};var e}function h(e){i.logger&&i.logger.debug(Fe.debugPostingDiagnosticEvent(e)),n.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function y(){var e,n;h((e=(new Date).getTime(),n=r({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},d.getProps()),c&&(n=r({},n,{},m())),d.reset(e),n)),s=setTimeout(y,v),u=(new Date).getTime(),c&&function(){if(o.localStorage){var e=r({},d.getProps());o.localStorage.set(l,JSON.stringify(e),function(){})}}()}return p.start=function(){c?function(t){if(!o.localStorage)return t(!1);o.localStorage.get(l).then(function(e){if(e)try{var n=JSON.parse(e);d.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(u||0)+v,t=(new Date).getTime();n<=t?y():s=setTimeout(y,n-t)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,v)}):(h(r({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate},m())),s=setTimeout(y,v))},p.stop=function(){s&&clearTimeout(s)},p.setStreaming=function(e){g=e},p};function Ke(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}function $e(n,t,i,u,c){var v=i&&i.logger?i.logger:c&&c.logger&&c.logger.default||Ke("warn"),d=Ce(v),g=_e(i,d,c,v),p=g.sendEvents,m=n,h=g.hash,y=G(u,m,g),w=g.sendEvents&&!g.diagnosticOptOut,b=w?ze(m):null,k=w?Me((new Date).getTime()):null,E=w?Be(u,k,y,m,g,b):null;E&&E.start();var S,D,O,R,N,C,x=Ae(u,g,m,k),F=g.eventProcessor||function(e,n,t,r,i,a){var u,s=3<arguments.length&&void 0!==r?r:null,c=4<arguments.length&&void 0!==i?i:null,l={},v=(5<arguments.length&&void 0!==a?a:null)||G(e,t,n),d=n.eventsUrl+"/events/bulk/"+t,g=H(),p=X(n),m=n.inlineUsersInEvents,h=n.samplingInterval,y=n.eventCapacity,w=n.flushInterval,b=n.logger,k=[],E=0,S=!1,P=!1;function D(){return 0===h||0===Math.floor(Math.random()*h)}function O(e){k.length<y?(k.push(e),P=!1):(P||(P=!0,b.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),s&&s.incrementDroppedEvents())}return l.enqueue=function(e){if(!S){var n=!1,t=!1;if(g.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>E&&e.debugEventsUntilDate>(new Date).getTime()}(e)):n=D(),n&&O(function(e){var n=L({},e);return m||"identify"===e.kind?n.user=p.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=L({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,O(r)}}},l.flush=function(){if(S)return Promise.resolve();var e=k,n=g.getSummary();return g.clearSummary(),n&&(n.kind="summary",e.push(n)),s&&s.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(k=[],b.debug(Ne(e.length)),v.sendEvents(e,d).then(function(e){e&&(e.serverTime&&(E=e.serverTime),f(e.status)||(S=!0),400<=e.status&&I(function(){c.maybeReportError(new o(ge(e.status,"event posting","some events were dropped")))}))}))},l.start=function(){u=setTimeout(function e(){l.flush(),u=setTimeout(e,w)},w)},l.stop=function(){clearTimeout(u)},l}(u,g,m,k,d,y),q=xe(u,g,m),_={},z={},J=g.streaming,V=!1,M=!1,K=!0,$=g.stateProvider,B=(N=function(e){$||e&&Y({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})},{setUser:function(e){(C=A(e))&&N&&N(P(C))},getUser:function(){return C?P(C):null}}),W=Ve(u.localStorage,v);function Y(e){m&&($&&$.enqueueEvent&&$.enqueueEvent(e)||(e.user?(K=!1,!p||M||u.isDoNotTrack()||(v.debug(Te(e.kind)),F.enqueue(e))):K&&(v.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),K=!1)))}function Q(e,n,t,r){var o=B.getUser(),i=new Date,a=n?n.value:null;if(!g.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=_[u];if(s&&i-s<3e5)return;_[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=z[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),Y(c)}function Z(e,n,t,r){var o;if(z&&z.hasOwnProperty(e)&&z[e]&&!z[e].deleted){var i=z[e];o=ee(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&&Q(e,o,n,r),o}function ee(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function ne(){D=!0,B.getUser()&&x.connect(B.getUser(),h,{ping:function(){v.debug("received ping message from stream"),q.fetchFlagSettings(B.getUser(),h).then(function(e){return re(e||{})}).catch(function(e){d.maybeReportError(new l(se(e)))})},put:function(e){var n=JSON.parse(e.data);v.debug("received streaming update for all flags"),re(n)},patch:function(e){var n=JSON.parse(e.data),t=z[n.key];if(!t||!t.version||!n.version||t.version<n.version){v.debug(Ue(n.key));var r={},o=L({},n);delete o.key;var i=ee(z[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ie(r)}else v.debug(Ie(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!z[n.key]||z[n.key].version<n.version){v.debug(je(n.key));var t={};z[n.key]&&!z[n.key].deleted&&(t[n.key]={previous:z[n.key].value}),z[n.key]={version:n.version,deleted:!0},ie(t)}else v.debug(Re(n.key))}})}function te(){D&&(x.disconnect(),D=!1)}function re(e){var n={};if(!e)return Promise.resolve();for(var t in z)z.hasOwnProperty(t)&&z[t]&&(e[t]&&!U(e[t].value,z[t].value)?n[t]={previous:z[t].value,current:ee(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:z[t].value}));for(var o in e)e.hasOwnProperty(o)&&e[o]&&(!z[o]||z[o].deleted)&&(n[o]={current:ee(e[o])});return z=r({},e),ie(n).catch(function(){})}function ie(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;d.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),d.emit("change",i),d.emit("internal-change",z),g.sendEventsOnlyForVariation||$||e.forEach(function(e){Q(e,o[e].current)})}return S&&R?R.saveFlags(z).catch(function(){return null}):Promise.resolve()}function ae(){var e=J||O&&void 0===J;e&&!D?ne():!e&&D&&te(),E&&E.setStreaming(e)}function ce(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}u.localStorage&&(R=new Le(u.localStorage,m,h,B,v));var le=new Promise(function(e){var n=d.on("ready",function(){d.off("ready",n),e()})}),ve=new Promise(function(e,n){var t=d.on("initialized",function(){d.off("initialized",t),e()}),r=d.on("failed",function(e){d.off("failed",r),n(e)})});if("string"==typeof g.bootstrap&&"LOCALSTORAGE"===g.bootstrap.toUpperCase()&&(R?S=!0:v.warn("localStorage is unavailable")),"object"===e(g.bootstrap)&&(z=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&v.warn(fe()),!1===t.$valid&&v.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var o={};return e.forEach(function(e){if("$flagsState"!==e&&"$valid"!==e){var n={value:t[e]};r&&r[e]?n=L(n,r[e]):n.version=0,o[e]=n}}),o}(g.bootstrap)),$){var de=$.getInitialState();de?pe(de):$.on("init",pe),$.on("update",function(e){e.user&&B.setUser(e.user),e.flags&&re(e.flags)})}else(n?W.validateUser(t).then(function(n){return B.setUser(n),"object"===e(g.bootstrap)?me():S?R.loadFlags().catch(function(){return null}).then(function(e){return null==e?(z={},q.fetchFlagSettings(B.getUser(),h).then(function(e){return re(e||{})}).then(me).catch(function(e){he(new l(se(e)))})):(z=e,I(me),q.fetchFlagSettings(B.getUser(),h).then(function(e){return re(e)}).catch(function(e){return d.maybeReportError(e)}))}):q.fetchFlagSettings(B.getUser(),h).then(function(e){z=e||{},me()}).catch(function(e){z={},he(e)})}):Promise.reject(new a(ue()))).catch(function(e){return d.maybeReportError(e)});function pe(e){m=e.environment,B.setUser(e.user),z=r({},e.flags),I(me)}function me(){v.info("LaunchDarkly client initialized"),V=!0,ae(),d.emit("ready"),d.emit("initialized")}function he(e){d.maybeReportError(e),d.emit("failed",e),d.emit("ready")}return{client:{waitForInitialization:function(){return ve},waitUntilReady:function(){return le},identify:function(e,r,n){return M?j(Promise.resolve({}),n):$?(v.warn("identify() has no effect here; it must be called on the main client instance"),j(Promise.resolve(T(z)),n)):j((S&&R?R.clearFlags():Promise.resolve()).then(function(){return W.validateUser(e)}).then(function(t){return q.fetchFlagSettings(t,r).then(function(e){var n=T(e);return B.setUser(t),h=r,e?re(e).then(function(){return n}):n})}).then(function(e){return D&&ne(),e}).catch(function(e){return d.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return B.getUser()},variation:function(e,n){return Z(e,n,!0,!1).value},variationDetail:function(e,n){return Z(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){u.customEventFilter&&!u.customEventFilter(e)&&v.warn(oe(e));var r={kind:"custom",key:e,user:B.getUser(),url:u.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),Y(r)}else d.maybeReportError(new s(oe(e)))},on:function(e,n,t){ce(e)?(O=!0,V&&ae(),d.on(e,n,t)):d.on.apply(d,arguments)},off:function(e){if(d.off.apply(d,arguments),ce(e)){var n=!1;d.getEvents().forEach(function(e){ce(e)&&0<d.getEventListenerCount(e)&&(n=!0)}),n||(O=!1,D&&void 0===J&&te())}},setStreaming:function(e){var n=null===e?void 0:e;n!==J&&(J=n,ae())},flush:function(e){return j(p?F.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!z)return e;for(var n in z)z.hasOwnProperty(n)&&(e[n]=Z(n,null,!g.sendEventsOnlyForVariation).value);return e},close:function(e){if(M)return j(Promise.resolve(),e);function n(){M=!0,z={}}return j(Promise.resolve().then(function(){if(te(),E&&E.stop(),p)return F.stop(),F.flush()}).then(n).catch(n),e)}},options:g,emitter:d,ident:B,logger:v,requestor:q,start:function(){p&&(E&&E.start(),F.start())},enqueueEvent:Y,getFlagsInternal:function(){return z},getEnvironmentId:function(){return m},internalChangeEventName:"internal-change"}}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 isSyncXhrSupported(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}var emptyResult={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function newHttpRequest(e,n,t,r,o){if(o&&!isSyncXhrSupported())return emptyResult;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),emptyResult;var u;return{promise:new Promise(function(e,n){i.addEventListener("load",function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})}),i.addEventListener("error",function(){u||n(new Error)}),i.send(r)}),cancel:function(){u=!0,i.abort()}}}function makeBrowserPlatform(e){var n,i={};i.synchronousFlush=!1,window.XMLHttpRequest&&(i.httpRequest=function(e,n,t,r){var o=i.synchronousFlush;return i.synchronousFlush=!1,newHttpRequest(e,n,t,r,o)}),i.httpAllowsPost=function(){return void 0===n&&(n=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),n},i.httpFallbackPing=function(e){(new window.Image).src=e};var r,t=e&&e.eventUrlTransformer;i.getCurrentUrl=function(){return t?t(window.location.href):window.location.href},i.isDoNotTrack=function(){var e;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(i.localStorage={get:function(n){return new Promise(function(e){e(window.localStorage.getItem(n))})},set:function(n,t){return new Promise(function(e){window.localStorage.setItem(n,t),e()})},clear:function(n){return new Promise(function(e){window.localStorage.removeItem(n),e()})}})}catch(e){i.localStorage=null}var o=e&&e.useReport;if(r=o&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(i.eventSourceAllowsReport=!0,window.EventSourcePolyfill):(i.eventSourceAllowsReport=!1,window.EventSource),window.EventSource){i.eventSourceFactory=function(e,n){var t=_objectSpread2({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},{},n);return new r(e,t)},i.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return i.userAgent="JSClient",i.version="2.17.0",i.diagnosticSdkData={name:"js-client-sdk",version:"2.17.0"},i.diagnosticPlatformData={name:"JS"},i.diagnosticUseCombinedEvent=!0,i}var matchOperatorsRe=/[|\\{}()[\]^$+*?.]/g,escapeStringRegexp=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(matchOperatorsRe,"\\$&")};function doesUrlMatch(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+escapeStringRegexp(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function findGoalsForClick(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&0<u.length;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}function GoalTracker(e,r){for(var n={},t=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(doesUrlMatch(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?r("pageview",a):(o.push(a),r("click_pageview",a));break}return 0<o.length&&(t=function(e){for(var n=findGoalsForClick(e,o),t=0;t<n.length;t++)r("click",n[t])},document.addEventListener("click",t)),n.dispose=function(){document.removeEventListener("click",t)},n}var locationWatcherInterval=300;function GoalManager(r,n){var t,o,e={};function i(){o&&o.dispose(),t&&t.length&&(o=GoalTracker(t,a))}function a(e,n){var t={kind:e,key:n.key,data:null,url:window.location.href,user:r.ident.getUser(),creationDate:(new Date).getTime()};return"click"===e&&(t.selector=n.selector),r.enqueueEvent(t)}function u(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}return e.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},r.requestor.fetchJSON("/sdk/goals/"+r.getEnvironmentId()).then(function(e){e&&0<e.length&&(o=GoalTracker(t=e,a),u(locationWatcherInterval,i)),n()}).catch(function(e){r.emitter.maybeReportError(new v.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),e}var goalsEvent="goalsReady",extraOptionDefs={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"}};function initialize(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=makeBrowserPlatform(t),o=$e(e,n,t,r,extraOptionDefs),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(goalsEvent,function(){u.off(goalsEvent,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=GoalManager(o,function(){return u.emit(goalsEvent)});r.customEventFilter=c.goalKeyExists}else u.emit(goalsEvent);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function l(){r.synchronousFlush=!0,i.flush().catch(function(){}),r.synchronousFlush=!1}return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var createConsoleLogger=Ke,version="2.17.0";function deprecatedInitialize(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Fe.deprecated("default export","named LDClient export")),initialize(e,n,t)}var index={initialize:deprecatedInitialize,version:version};exports.createConsoleLogger=createConsoleLogger,exports.default=index,exports.initialize=initialize,exports.version=version; | ||
"use strict";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(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 r(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?t(o,!0).forEach(function(e){n(r,e,o[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(o).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}function i(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}Object.defineProperty(exports,"__esModule",{value:!0});var o=i("LaunchDarklyUnexpectedResponseError"),a=i("LaunchDarklyInvalidEnvironmentIdError"),u=i("LaunchDarklyInvalidUserError"),s=i("LaunchDarklyInvalidEventKeyError"),c=i("LaunchDarklyInvalidArgumentError"),l=i("LaunchDarklyFlagFetchError");function f(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:o,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:s,LDInvalidArgumentError:c,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(b(e,i,a<i+16383?a:i+16383));return 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]+"=")),o.join("")},g=[],p=[],m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,y=m.length;h<y;++h)g[h]=m[h],p[m.charCodeAt(h)]=h;function b(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(g[(o=r)>>18&63]+g[o>>12&63]+g[o>>6&63]+g[63&o]);return i.join("")}p["-".charCodeAt(0)]=62,p["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,w=Object.prototype.hasOwnProperty,D=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function S(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function P(e){return S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function O(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 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 d=E(n);if((o=d.length)!==E(t).length)return!1;for(r=o;0!=r--;)if(!w.call(t,d[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=d[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function I(e){setTimeout(e,0)}function j(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function R(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function T(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function N(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=P(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function F(e){var n=e.version||"3.2.3";return e.userAgent+"/"+n}function C(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":F(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function L(){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 D){var o=D[t],i=e[o];void 0!==i&&"string"!=typeof i&&((n=n||r({},e))[o]=String(i))}return n||e}for(var x=Object.freeze({__proto__:null,btoa:S,base64URLEncode:P,clone:O,deepEquals:U,onNextTick:I,wrapPromiseCallback:j,transformValuesToVersionedValues:R,transformVersionedValuesToValues:T,chunkUserEventsForUrl:N,getLDUserAgentString:F,getLDHeaders:C,extend:L,sanitizeUser:A}),V=function(e,n){return 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}}}(n={exports:{}}),n.exports}(),q=[],_=0;_<256;++_)q[_]=(_+256).toString(16).substr(1);var J,z,M=function(e,n){var t=n||0,r=q;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},B=0,K=0,$=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=V();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 s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:K+1,l=s-B+(c-K)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||B<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");B=s,z=a;var f=(1e4*(268435455&(s+=122192928e5))+(K=c))%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var d=s/4294967296*1e4&268435455;o[r++]=d>>>8&255,o[r++]=255&d,o[r++]=d>>>24&15|16,o[r++]=d>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var v=0;v<6;++v)o[r+v]=i[v];return n||M(o)};function G(u,e,n){var t="/a/"+e+".gif",s=L({"Content-Type":"application/json"},C(u,n)),c=u.httpFallbackPing,l={sendChunk:function(e,r,o,n){var i=JSON.stringify(e),a=o?null:$();return n?function n(t){var e=o?s:L({},s,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,e,i).promise.then(function(e){if(e)return 400<=e.status&&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(){}):(c&&c(r+t+"?d="+P(i)),Promise.resolve())},sendEvents:function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,o=u.httpAllowsPost();r=o?[e]:N(2e3-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(l.sendChunk(r[a],n,t,o));return Promise.all(i)}};return l}function H(){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 X(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(o,i){return Object.keys(o).reduce(function(e,n){var t,r=e;return i(n)&&(l[t=n]||!s&&-1===a.indexOf(t)&&-1===c.indexOf(t)?r[0][n]=o[n]:r[1][n]=!0),r},[{},{}])}var a=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],o=t[1];if(e.custom){var i=n(e.custom,function(){return!0});r.custom=i[0],o=L({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},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"},ie=function(e){return"network error"+(e?" ("+e+")":"")},oe=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},se=function(e){return"Error fetching flag settings: "+W(e)},ce=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"},he=function(){return"Closing stream connection"},ye=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"},De=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Se=function(e){return"polling for feature flags at "+e},Pe=function(){return"received ping message from stream"},Oe=function(){return"received streaming update for all flags"},Ue=function(e){return'received streaming update for flag "'+e+'"'},Ie=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},je=function(e){return'received streaming deletion for flag "'+e+'"'},Re=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Te=function(e){return'enqueueing "'+e+'" event'},Ne=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:ie,unknownCustomEventKey:oe,environmentNotFound:ae,environmentNotSpecified:ue,errorFetchingFlags:se,userNotSpecified:ce,invalidUser:le,bootstrapOldFormat:fe,bootstrapInvalid:ve,deprecated:de,httpErrorMessage:ge,httpUnavailable:pe,identifyDisabled:me,streamClosing:he,streamConnecting:ye,streamError:be,unknownOption:ke,wrongOptionType:Ee,wrongOptionTypeBoolean:we,optionBelowMinimum:De,debugPolling:Se,debugStreamPing:Pe,debugStreamPut:Oe,debugStreamPatch:Ue,debugStreamPatchIgnored:Ie,debugStreamDelete:je,debugStreamDeleteIgnored:Re,debugEnqueueingEvent:Te,debugPostingEvents:Ne,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function Ce(n){var e={},o={};return e.on=function(e,n,t){o[e]=o[e]||[],o[e]=o[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===n&&o[e][r].context===t&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var n=o[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(o.error?this.emit("error",e):(n||console).error(e.message))},e}var Le=function(r){var n=!1,t=!1,o=null,e=null,i=new Promise(function(n){r.on("ready",function e(){r.off("ready",e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(o):e=new Promise(function(n,t){r.on("initialized",function e(){r.off("initialized",e),n()}),r.on("failed",function e(n){r.off("failed",e),t(n)})}))},getReadyPromise:function(){return i},signalSuccess:function(){n||t||(n=!0,r.emit("initialized"),r.emit("ready"))},signalFailure:function(e){n||t||(t=!0,o=e,r.emit("failed",e),r.emit("ready")),r.maybeReportError(e)}}};function Ae(t,r,o,i,a){var u={};function s(){var e="",n=i.getUser();return n&&(e=o||S(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=R(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.saveFlags=function(e){var n=L({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u}function xe(o,e,i,n){var a,u=e.streamUrl,s=e.logger,t={},c=u+"/eval/"+i,l=e.useReport,f=e.evaluationReasons,r=e.streamReconnectDelay,d=C(o,e),v=!1,g=null,p=null,m=null,h=null,y=null;function w(e){v||(s.warn(be(e,r)),v=!0),S(!1),E(),b(r)}function b(e){p||(e?p=setTimeout(k,e):k())}function k(){var e;p=null;var n="",t={headers:d};if(o.eventSourceFactory){for(var r in null!=h&&(n="h="+h),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+"/"+P(JSON.stringify(m)),f&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,E(),s.info(ye(e)),a=(new Date).getTime(),g=o.eventSourceFactory(e,t),y)y.hasOwnProperty(r)&&g.addEventListener(r,y[r]);g.onerror=w}}function E(){g&&(s.info("Closing stream connection"),g.close(),g=null)}function S(e){a&&n&&n.recordStreamInit(a,!e,(new Date).getTime()-a),a=null}return t.connect=function(e,n,t){m=e,h=n,y={};function r(n){y[n]=function(e){S(!(v=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);b()},t.disconnect=function(){clearTimeout(p),p=null,E()},t.isConnected=function(){return!!(g&&o.eventSourceIsActive&&o.eventSourceIsActive(g))},t}function Ve(p,m,u){var s=m.baseUrl,c=m.useReport,f=m.evaluationReasons,d=m.logger,e={},h={};function v(e,n){if(!p.httpRequest)return new Promise(function(e,n){n(new l(pe()))});var t=n?"REPORT":"GET",r=C(p,m);n&&(r["Content-Type"]="application/json");var o,i,u,s,c,f,d=h[e];d||(o=function(){delete h[e]},(f={addPromise:function(n,e){i=n,u&&u(),u=e,n.then(function(e){i===n&&(s(e),o())},function(e){i===n&&(c(e),o())})}}).resultPromise=new Promise(function(e,n){s=e,c=n}),d=f,h[e]=d);var v=p.httpRequest(t,e,r,n),g=v.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new a(ae()):new l(se(n.statusText||String(n.status))));if(e.header("content-type")&&0===e.header("content-type").lastIndexOf("application/json"))return JSON.parse(e.body);var n,t=ne(e.header("content-type")||"");return Promise.reject(new l(t))},function(e){return Promise.reject(new l(ie(e)))});return d.addPromise(g,function(){v.cancel&&v.cancel()}),d.resultPromise}return e.fetchJSON=function(e){return v(s+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return c?(r=[s,"/sdk/evalx/",u,"/user"].join(""),o=JSON.stringify(e)):(t=P(JSON.stringify(e)),r=[s,"/sdk/evalx/",u,"/users/",t].join("")),n&&(i="h="+n),f&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,d.debug(Se(r)),v(r,o)},e}function qe(o,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new u(ce()));var r=O(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(o?o.get("ld:$anonUserId").catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return r.key=e,r;var n,t=$();return r.key=t,(n=t,o?o.set("ld:$anonUserId",n).catch(function(){i.warn("localStorage is unavailable, so anonymous user ID cannot be cached")}):Promise.resolve()).then(function(){return r})}):Promise.reject(new u(le()))},e}var _e={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"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function Je(n,t,r,o){var a=L({logger:{default:o}},_e,r),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){I(function(){t&&t.maybeReportError(new c(e))})}var s,l,f,d,v=L({},n||{});return d=v,Object.keys(i).forEach(function(e){if(void 0!==d[e]){var n=i[e];o&&o.warn(de(e,n)),n&&(void 0===d[n]&&(d[n]=d[e]),delete d[e])}}),f=L({},v),Object.keys(a).forEach(function(e){void 0!==f[e]&&null!==f[e]||(f[e]=a[e]&&a[e].default)}),s=v=f,l=L({},s),Object.keys(s).forEach(function(e){var n=s[e];if(null!=n){var t=a[e];if(void 0===t)u(ke(e));else{var r=t.type||g(t.default);if("any"!==r){var o=r.split("|"),i=g(n);o.indexOf(i)<0?"boolean"===r?(l[e]=!!n,u(we(e,i))):(u(Ee(e,r,i)),l[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(De(e,n,t.minimum)),l[e]=t.minimum)}}}}),l;function g(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"}}}var ze=Object.freeze({__proto__:null,baseOptionDefs:_e,validate:Je}).baseOptionDefs,Me=function(e){var n={diagnosticId:$()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},Be=function(e){var n,t,r,o;function i(e){n=e,r=t=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:o}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};o.push(r)},reset:i}},Ke=function(o,e,n,t,i,a){var u,s,c=!!o.diagnosticUseCombinedEvent,l="ld:"+t+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+t,d=i.diagnosticRecordingInterval,v=e,g=!!i.streaming,p={};function m(){return{sdk:function(){var e=r({},o.diagnosticSdkData);return i.wrapperName&&(e.wrapperName=i.wrapperName),i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion),e}(),configuration:(e={customBaseURI:i.baseUrl!==ze.baseUrl.default,customStreamURI:i.streamUrl!==ze.streamUrl.default,customEventsURI:i.eventsUrl!==ze.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation},e),platform:o.diagnosticPlatformData};var e}function h(e){i.logger&&i.logger.debug(Fe.debugPostingDiagnosticEvent(e)),n.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function y(){var e,n;h((e=(new Date).getTime(),n=r({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},v.getProps()),c&&(n=r({},n,{},m())),v.reset(e),n)),s=setTimeout(y,d),u=(new Date).getTime(),c&&function(){if(o.localStorage){var e=r({},v.getProps());o.localStorage.set(l,JSON.stringify(e),function(){})}}()}return p.start=function(){c?function(t){if(!o.localStorage)return t(!1);o.localStorage.get(l).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(u||0)+d,t=(new Date).getTime();n<=t?y():s=setTimeout(y,n-t)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,d)}):(h(r({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},m())),s=setTimeout(y,d))},p.stop=function(){s&&clearTimeout(s)},p.setStreaming=function(e){g=e},p};function $e(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}function Ge(n,t,i,u,c){var d=i&&i.logger?i.logger:c&&c.logger&&c.logger.default||$e("warn"),v=Ce(d),g=Le(v),p=Je(i,v,c,d),m=p.sendEvents,h=n,y=p.hash,w=G(u,h,p),b=p.sendEvents&&!p.diagnosticOptOut,k=b?Me(h):null,E=b?Be((new Date).getTime()):null,S=b?Ke(u,E,w,h,p,k):null;S&&S.start();var P,D,R,N,F,C,x=xe(u,p,h,E),q=p.eventProcessor||function(e,n,t,r,i,a){var u,s=3<arguments.length&&void 0!==r?r:null,c=4<arguments.length&&void 0!==i?i:null,l={},d=(5<arguments.length&&void 0!==a?a:null)||G(e,t,n),v=n.eventsUrl+"/events/bulk/"+t,g=H(),p=X(n),m=n.inlineUsersInEvents,h=n.samplingInterval,y=n.eventCapacity,w=n.flushInterval,b=n.logger,k=[],E=0,S=!1,P=!1;function D(){return 0===h||0===Math.floor(Math.random()*h)}function O(e){k.length<y?(k.push(e),P=!1):(P||(P=!0,b.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),s&&s.incrementDroppedEvents())}return l.enqueue=function(e){if(!S){var n=!1,t=!1;if(g.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>E&&e.debugEventsUntilDate>(new Date).getTime()}(e)):n=D(),n&&O(function(e){var n=L({},e);return m||"identify"===e.kind?n.user=p.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=L({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,O(r)}}},l.flush=function(){if(S)return Promise.resolve();var e=k,n=g.getSummary();return g.clearSummary(),n&&(n.kind="summary",e.push(n)),s&&s.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(k=[],b.debug(Ne(e.length)),d.sendEvents(e,v).then(function(e){e&&(e.serverTime&&(E=e.serverTime),f(e.status)||(S=!0),400<=e.status&&I(function(){c.maybeReportError(new o(ge(e.status,"event posting","some events were dropped")))}))}))},l.start=function(){u=setTimeout(function e(){l.flush(),u=setTimeout(e,w)},w)},l.stop=function(){clearTimeout(u)},l}(u,p,h,E,v,w),_=Ve(u,p,h),z={},J={},V=p.streaming,M=!1,$=!1,K=!0,B=p.stateProvider,W=(F=function(e){B||e&&Q({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})},{setUser:function(e){(C=A(e))&&F&&F(O(C))},getUser:function(){return C?O(C):null}}),Y=qe(u.localStorage,d);function Q(e){h&&(B&&B.enqueueEvent&&B.enqueueEvent(e)||(e.user?(K=!1,!m||$||u.isDoNotTrack()||(d.debug(Te(e.kind)),q.enqueue(e))):K&&(d.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),K=!1)))}function Z(e,n,t,r){var o=W.getUser(),i=new Date,a=n?n.value:null;if(!p.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=z[u];if(s&&i-s<3e5)return;z[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=J[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),Q(c)}function ee(e,n,t,r){var o;if(J&&J.hasOwnProperty(e)&&J[e]&&!J[e].deleted){var i=J[e];o=ne(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&Z(e,o,n,r),o}function ne(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function te(){D=!0,W.getUser()&&x.connect(W.getUser(),y,{ping:function(){d.debug("received ping message from stream"),_.fetchFlagSettings(W.getUser(),y).then(function(e){return ie(e||{})}).catch(function(e){v.maybeReportError(new l(se(e)))})},put:function(e){var n=JSON.parse(e.data);d.debug("received streaming update for all flags"),ie(n)},patch:function(e){var n=JSON.parse(e.data),t=J[n.key];if(!t||!t.version||!n.version||t.version<n.version){d.debug(Ue(n.key));var r={},o=L({},n);delete o.key;var i=ne(J[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ae(r)}else d.debug(Ie(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!J[n.key]||J[n.key].version<n.version){d.debug(je(n.key));var t={};J[n.key]&&!J[n.key].deleted&&(t[n.key]={previous:J[n.key].value}),J[n.key]={version:n.version,deleted:!0},ae(t)}else d.debug(Re(n.key))}})}function re(){D&&(x.disconnect(),D=!1)}function ie(e){var n={};if(!e)return Promise.resolve();for(var t in J)J.hasOwnProperty(t)&&J[t]&&(e[t]&&!U(e[t].value,J[t].value)?n[t]={previous:J[t].value,current:ne(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:J[t].value}));for(var o in e)e.hasOwnProperty(o)&&e[o]&&(!J[o]||J[o].deleted)&&(n[o]={current:ne(e[o])});return J=r({},e),ae(n).catch(function(){})}function ae(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;v.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),v.emit("change",i),v.emit("internal-change",J),p.sendEventsOnlyForVariation||B||e.forEach(function(e){Z(e,o[e].current)})}return P&&N?N.saveFlags(J).catch(function(){return null}):Promise.resolve()}function ce(){var e=V||R&&void 0===V;e&&!D?te():!e&&D&&re(),S&&S.setStreaming(e)}function le(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if(u.localStorage&&(N=new Ae(u.localStorage,h,y,W,d)),"string"==typeof p.bootstrap&&"LOCALSTORAGE"===p.bootstrap.toUpperCase()&&(N?P=!0:d.warn("localStorage is unavailable")),"object"===e(p.bootstrap)&&(J=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&d.warn(fe()),!1===t.$valid&&d.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var o={};return e.forEach(function(e){if("$flagsState"!==e&&"$valid"!==e){var n={value:t[e]};r&&r[e]?n=L(n,r[e]):n.version=0,o[e]=n}}),o}(p.bootstrap)),B){var de=B.getInitialState();de?ve(de):B.on("init",ve),B.on("update",function(e){e.user&&W.setUser(e.user),e.flags&&ie(e.flags)})}else(n?Y.validateUser(t).then(function(n){return W.setUser(n),"object"===e(p.bootstrap)?pe():P?N.loadFlags().catch(function(){return null}).then(function(e){return null==e?(J={},_.fetchFlagSettings(W.getUser(),y).then(function(e){return ie(e||{})}).then(pe).catch(function(e){me(new l(se(e)))})):(J=e,I(pe),_.fetchFlagSettings(W.getUser(),y).then(function(e){return ie(e)}).catch(function(e){return v.maybeReportError(e)}))}):_.fetchFlagSettings(W.getUser(),y).then(function(e){J=e||{},pe()}).catch(function(e){J={},me(e)})}):Promise.reject(new a(ue()))).catch(me);function ve(e){h=e.environment,W.setUser(e.user),J=r({},e.flags),I(pe)}function pe(){d.info("LaunchDarkly client initialized"),M=!0,ce(),g.signalSuccess()}function me(e){g.signalFailure(e)}return{client:{waitForInitialization:function(){return g.getInitializationPromise()},waitUntilReady:function(){return g.getReadyPromise()},identify:function(e,r,n){return $?j(Promise.resolve({}),n):B?(d.warn("identify() has no effect here; it must be called on the main client instance"),j(Promise.resolve(T(J)),n)):j((P&&N?N.clearFlags():Promise.resolve()).then(function(){return Y.validateUser(e)}).then(function(t){return _.fetchFlagSettings(t,r).then(function(e){var n=T(e);return W.setUser(t),y=r,e?ie(e).then(function(){return n}):n})}).then(function(e){return D&&te(),e}).catch(function(e){return v.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return W.getUser()},variation:function(e,n){return ee(e,n,!0,!1).value},variationDetail:function(e,n){return ee(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){u.customEventFilter&&!u.customEventFilter(e)&&d.warn(oe(e));var r={kind:"custom",key:e,user:W.getUser(),url:u.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),Q(r)}else v.maybeReportError(new s(oe(e)))},on:function(e,n,t){le(e)?(R=!0,M&&ce(),v.on(e,n,t)):v.on.apply(v,arguments)},off:function(e){if(v.off.apply(v,arguments),le(e)){var n=!1;v.getEvents().forEach(function(e){le(e)&&0<v.getEventListenerCount(e)&&(n=!0)}),n||(R=!1,D&&void 0===V&&re())}},setStreaming:function(e){var n=null===e?void 0:e;n!==V&&(V=n,ce())},flush:function(e){return j(m?q.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!J)return e;for(var n in J)J.hasOwnProperty(n)&&(e[n]=ee(n,null,!p.sendEventsOnlyForVariation).value);return e},close:function(e){if($)return j(Promise.resolve(),e);function n(){$=!0,J={}}return j(Promise.resolve().then(function(){if(re(),S&&S.stop(),m)return q.stop(),q.flush()}).then(n).catch(n),e)}},options:p,emitter:v,ident:W,logger:d,requestor:_,start:function(){m&&(S&&S.start(),q.start())},enqueueEvent:Q,getFlagsInternal:function(){return J},getEnvironmentId:function(){return h},internalChangeEventName:"internal-change"}}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 isSyncXhrSupported(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}var emptyResult={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function newHttpRequest(e,n,t,r,o){if(o&&!isSyncXhrSupported())return emptyResult;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),emptyResult;var u;return{promise:new Promise(function(e,n){i.addEventListener("load",function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})}),i.addEventListener("error",function(){u||n(new Error)}),i.send(r)}),cancel:function(){u=!0,i.abort()}}}function makeBrowserPlatform(e){var n,i={};i.synchronousFlush=!1,window.XMLHttpRequest&&(i.httpRequest=function(e,n,t,r){var o=i.synchronousFlush;return i.synchronousFlush=!1,newHttpRequest(e,n,t,r,o)}),i.httpAllowsPost=function(){return void 0===n&&(n=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),n},i.httpFallbackPing=function(e){(new window.Image).src=e};var r,t=e&&e.eventUrlTransformer;i.getCurrentUrl=function(){return t?t(window.location.href):window.location.href},i.isDoNotTrack=function(){var e;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(i.localStorage={get:function(n){return new Promise(function(e){e(window.localStorage.getItem(n))})},set:function(n,t){return new Promise(function(e){window.localStorage.setItem(n,t),e()})},clear:function(n){return new Promise(function(e){window.localStorage.removeItem(n),e()})}})}catch(e){i.localStorage=null}var o=e&&e.useReport;if(r=o&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(i.eventSourceAllowsReport=!0,window.EventSourcePolyfill):(i.eventSourceAllowsReport=!1,window.EventSource),window.EventSource){i.eventSourceFactory=function(e,n){var t=_objectSpread2({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},{},n);return new r(e,t)},i.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return i.userAgent="JSClient",i.version="2.17.1",i.diagnosticSdkData={name:"js-client-sdk",version:"2.17.1"},i.diagnosticPlatformData={name:"JS"},i.diagnosticUseCombinedEvent=!0,i}var matchOperatorsRe=/[|\\{}()[\]^$+*?.]/g,escapeStringRegexp=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(matchOperatorsRe,"\\$&")};function doesUrlMatch(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+escapeStringRegexp(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+escapeStringRegexp(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function findGoalsForClick(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&0<u.length;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}function GoalTracker(e,r){for(var n={},t=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(doesUrlMatch(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?r("pageview",a):(o.push(a),r("click_pageview",a));break}return 0<o.length&&(t=function(e){for(var n=findGoalsForClick(e,o),t=0;t<n.length;t++)r("click",n[t])},document.addEventListener("click",t)),n.dispose=function(){document.removeEventListener("click",t)},n}var locationWatcherInterval=300;function GoalManager(r,n){var t,o,e={};function i(){o&&o.dispose(),t&&t.length&&(o=GoalTracker(t,a))}function a(e,n){var t={kind:e,key:n.key,data:null,url:window.location.href,user:r.ident.getUser(),creationDate:(new Date).getTime()};return"click"===e&&(t.selector=n.selector),r.enqueueEvent(t)}function u(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}return e.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},r.requestor.fetchJSON("/sdk/goals/"+r.getEnvironmentId()).then(function(e){e&&0<e.length&&(o=GoalTracker(t=e,a),u(locationWatcherInterval,i)),n()}).catch(function(e){r.emitter.maybeReportError(new v.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),e}var goalsEvent="goalsReady",extraOptionDefs={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"}};function initialize(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=makeBrowserPlatform(t),o=Ge(e,n,t,r,extraOptionDefs),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(goalsEvent,function(){u.off(goalsEvent,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=GoalManager(o,function(){return u.emit(goalsEvent)});r.customEventFilter=c.goalKeyExists}else u.emit(goalsEvent);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function l(){r.synchronousFlush=!0,i.flush().catch(function(){}),r.synchronousFlush=!1}return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var createConsoleLogger=$e,version="2.17.1";function deprecatedInitialize(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Fe.deprecated("default export","named LDClient export")),initialize(e,n,t)}var index={initialize:deprecatedInitialize,version:version};exports.createConsoleLogger=createConsoleLogger,exports.default=index,exports.initialize=initialize,exports.version=version; | ||
//# sourceMappingURL=ldclient.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?t(o,!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(o).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var i=o("LaunchDarklyUnexpectedResponseError"),a=o("LaunchDarklyInvalidEnvironmentIdError"),u=o("LaunchDarklyInvalidUserError"),s=o("LaunchDarklyInvalidEventKeyError"),c=o("LaunchDarklyInvalidArgumentError"),l=o("LaunchDarklyFlagFetchError");function f(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:i,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:s,LDInvalidArgumentError:c,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(w(e,i,i+16383>a?a:i+16383));return 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]+"=")),o.join("")},g=[],p=[],m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,y=m.length;h<y;++h)g[h]=m[h],p[m.charCodeAt(h)]=h;function w(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 b=Array.isArray,E=Object.keys,k=Object.prototype.hasOwnProperty,S=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function D(e){var n=unescape(encodeURIComponent(e));return d(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function P(e){return D(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function O(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=b(n),u=b(t);if(a&&u){if((o=n.length)!=t.length)return!1;for(r=o;0!=r--;)if(!e(n[r],t[r]))return!1;return!0}if(a!=u)return!1;var s=n instanceof Date,c=t instanceof Date;if(s!=c)return!1;if(s&&c)return n.getTime()==t.getTime();var l=n instanceof RegExp,f=t instanceof RegExp;if(l!=f)return!1;if(l&&f)return n.toString()==t.toString();var v=E(n);if((o=v.length)!==E(t).length)return!1;for(r=o;0!=r--;)if(!k.call(t,v[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=v[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function R(e){setTimeout(e,0)}function I(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 j(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function T(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function N(e,n){for(var t,r=n.slice(0),o=[],i=e;r.length>0;){for(t=[];i>0;){var a=r.shift();if(!a)break;(i-=P(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function L(e){var n=e.version||"3.2.2";return e.userAgent+"/"+n}function F(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":L(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 x(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}Object.freeze({__proto__:null,btoa:D,base64URLEncode:P,clone:O,deepEquals:U,onNextTick:R,wrapPromiseCallback:I,transformValuesToVersionedValues:j,transformVersionedValuesToValues:T,chunkUserEventsForUrl:N,getLDUserAgentString:L,getLDHeaders:F,extend:C,sanitizeUser:x});for(var A=function(e,n){return 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}}}(n={exports:{}}),n.exports}(),q=[],V=0;V<256;++V)q[V]=(V+256).toString(16).substr(1);var _,J,z=0,M=0,$=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||_,a=void 0!==e.clockseq?e.clockseq:J;if(null==i||null==a){var u=A();null==i&&(i=_=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=J=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:M+1,l=s-z+(c-M)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>z)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");z=s,M=c,J=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||function(e,n){var t=n||0,r=q;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("")}(o)};function H(e,n,t){var r="/a/"+n+".gif",o=C({"Content-Type":"application/json"},F(e,t)),i=e.httpFallbackPing,a={sendChunk:function(n,t,a,u){var s=JSON.stringify(n),c=a?null:$();return u?function n(r){var i=a?o:C({},o,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":c});return e.httpRequest("POST",t,i,s).promise.then((function(e){if(e)return e.status>=400&&f(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(i&&i(t+r+"?d="+P(s)),Promise.resolve())},sendEvents:function(n,t,r){if(!e.httpRequest)return Promise.resolve();var o,i=e.httpAllowsPost();o=i?[n]:N(2e3-t.length,n);for(var u=[],s=0;s<o.length;s++)u.push(a.sendChunk(o[s],t,r,i));return Promise.all(u)}};return a}function K(){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 s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),o=!1}return o?null:{startDate:n,endDate:t,features:e}},e.clearSummary=function(){n=0,t=0,r={}},e}function B(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],o={key:!0,custom:!0,anonymous:!0},i={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,i){return Object.keys(e).reduce((function(a,u){var s=a;return i(u)&&(function(e){return!o[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[1][u]=!0:s[0][u]=e[u]),s}),[{},{}])},u=a(e,(function(e){return i[e]})),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,(function(){return!0}));s.custom=l[0],c=C({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function G(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var X=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",W=function(e){return'Expected application/json content type but got "'+e+'"'},Q=function(e){return"network error"+(e?" ("+e+")":"")},Y=function(e){return'Custom event "'+e+'" does not exist'},Z=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+X},ee=function(){return"No environment/client-side ID was specified."+X},ne=function(e){return"Error fetching flag settings: "+G(e)},te=function(){return"No user specified."+X},re=function(){return"Invalid user specified."+X},oe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+X},ie=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},ae=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},ue=function(){return"Cannot make HTTP requests in this environment."+X},se=function(e){return"Opening stream connection to "+e},ce=function(e,n){return"Error on stream connection: "+G(e)+", will continue retrying every "+n+" milliseconds."},le=function(e){return'Ignoring unknown config option "'+e+'"'},fe=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},ve=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},de=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},ge=function(e){return"polling for feature flags at "+e},pe=function(e){return'received streaming update for flag "'+e+'"'},me=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},he=function(e){return'received streaming deletion for flag "'+e+'"'},ye=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},we=function(e){return'enqueueing "'+e+'" event'},be=function(e){return"sending "+e+" events"},Ee=Object.freeze({__proto__:null,clientInitialized:function(){return"LaunchDarkly client initialized"},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:W,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:Q,unknownCustomEventKey:Y,environmentNotFound:Z,environmentNotSpecified:ee,errorFetchingFlags:ne,userNotSpecified:te,invalidUser:re,bootstrapOldFormat:oe,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:ie,httpErrorMessage:ae,httpUnavailable:ue,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:se,streamError:ce,unknownOption:le,wrongOptionType:fe,wrongOptionTypeBoolean:ve,optionBelowMinimum:de,debugPolling:ge,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:pe,debugStreamPatchIgnored:me,debugStreamDelete:he,debugStreamDeleteIgnored:ye,debugEnqueueingEvent:we,debugPostingEvents:be,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function ke(e,n,t,r,o){var i={};function a(){var e="",o=r.getUser();return o&&(e=t||D(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=j(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 Se(e,n,t,r){var o,i=n.streamUrl,a=n.logger,u={},s=i+"/eval/"+t,c=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,v=F(e,n),d=!1,g=null,p=null,m=null,h=null,y=null;function w(e){d||(a.warn(ce(e,f)),d=!0),S(!1),k(),b(f)}function b(e){p||(e?p=setTimeout(E,e):E())}function E(){var n;p=null;var r="",u={headers:v};if(e.eventSourceFactory){for(var f in null!=h&&(r="h="+h),c?e.eventSourceAllowsReport?(n=s,u.method="REPORT",u.headers["Content-Type"]="application/json",u.body=JSON.stringify(m)):(n=i+"/ping/"+t,r=""):n=s+"/"+P(JSON.stringify(m)),l&&(r=r+(r?"&":"")+"withReasons=true"),n=n+(r?"?":"")+r,k(),a.info(se(n)),o=(new Date).getTime(),g=e.eventSourceFactory(n,u),y)y.hasOwnProperty(f)&&g.addEventListener(f,y[f]);g.onerror=w}}function k(){g&&(a.info("Closing stream connection"),g.close(),g=null)}function S(e){o&&r&&r.recordStreamInit(o,!e,(new Date).getTime()-o),o=null}return u.connect=function(e,n,t){m=e,h=n,y={};var r=function(e){y[e]=function(n){d=!1,S(!0),t[e]&&t[e](n)}};for(var o in t||{})r(o);b()},u.disconnect=function(){clearTimeout(p),p=null,k()},u.isConnected=function(){return!!(g&&e.eventSourceIsActive&&e.eventSourceIsActive(g))},u}function De(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,u=n.logger,s={},c={};function f(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new l(ue()))}));var o=r?"REPORT":"GET",i=F(e,n);r&&(i["Content-Type"]="application/json");var u=c[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 c[t]})),c[t]=u);var s=e.httpRequest(o,t,i,r),f=s.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=W(e.header("content-type")||"");return Promise.reject(new l(n))}return Promise.reject(function(e){return 404===e.status?new a(Z()):new l(ne(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new l(Q(e)))}));return u.addPromise(f,(function(){s.cancel&&s.cancel()})),u.resultPromise}return s.fetchJSON=function(e){return f(r+e,null)},s.fetchFlagSettings=function(e,n){var a,s,c,l="";return o?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(a=P(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(l="h="+n),i&&(l=l+(l?"&":"")+"withReasons=true"),s=s+(l?"?":"")+l,u.debug(ge(s)),f(s,c)},s}function Pe(e,n){var t={validateUser:function(t){if(!t)return Promise.reject(new u(te()));var r=O(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=$();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(re()))}};return t}var Oe={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"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function Ue(n,t,r,o){var i=C({logger:{default:o}},Oe,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){R((function(){t&&t.maybeReportError(new c(e))}))}var s=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(ie(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),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(le(e));else{var s=a.type||r(a.default);if("any"!==s){var c=s.split("|"),l=r(o);c.indexOf(l)<0?"boolean"===s?(t[e]=!!o,u(ve(e,l))):(u(fe(e,s,l)),t[e]=a.default):"number"===l&&void 0!==a.minimum&&o<a.minimum&&(u(de(e,o,a.minimum)),t[e]=a.minimum)}}}})),t}(s=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}(s))}var Re=Object.freeze({__proto__:null,baseOptionDefs:Oe,validate:Ue}).baseOptionDefs,Ie=function(e){var n={diagnosticId:$()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n},je=function(e){var n,t,r,o;function i(e){n=e,t=0,r=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:o}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};o.push(r)},reset:i}},Te=function(e,n,t,o,i,a){var u,s,c=!!e.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+o,v=i.diagnosticRecordingInterval,d=n,g=!!i.streaming,p={};function m(){return{sdk:w(),configuration:(n={customBaseURI:i.baseUrl!==Re.baseUrl.default,customStreamURI:i.streamUrl!==Re.streamUrl.default,customEventsURI:i.eventsUrl!==Re.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation},n),platform:e.diagnosticPlatformData};var n}function h(e){i.logger&&i.logger.debug(Ee.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then((function(){})).catch((function(){}))}function y(){var n,t;h((n=(new Date).getTime(),t=r({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:n},d.getProps()),c&&(t=r({},t,{},m())),d.reset(n),t)),s=setTimeout(y,v),u=(new Date).getTime(),c&&function(){if(e.localStorage){var n=r({},d.getProps());e.localStorage.set(l,JSON.stringify(n),(function(){}))}}()}function w(){var n=r({},e.diagnosticSdkData);return i.wrapperName&&(n.wrapperName=i.wrapperName),i.wrapperVersion&&(n.wrapperVersion=i.wrapperVersion),n}return p.start=function(){c?function(n){if(!e.localStorage)return n(!1);e.localStorage.get(l).then((function(e){if(e)try{var t=JSON.parse(e);d.setProps(t),u=t.dataSinceDate}catch(e){}n(!0)})).catch((function(){n(!1)}))}((function(e){if(e){var n=(u||0)+v,t=(new Date).getTime();t>=n?y():s=setTimeout(y,n-t)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,v)})):(h(r({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate},m())),s=setTimeout(y,v))},p.stop=function(){s&&clearTimeout(s)},p.setStreaming=function(e){g=e},p};function Ne(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 Le(n,t,o,u,c){var v=o&&o.logger?o.logger:c&&c.logger&&c.logger.default||Ne("warn"),d=function(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}(v),g=Ue(o,d,c,v),p=g.sendEvents,m=n,h=g.hash,y=H(u,m,g),w=g.sendEvents&&!g.diagnosticOptOut,b=w?Ie(m):null,E=w?je((new Date).getTime()):null,k=w?Te(u,E,y,m,g,b):null;k&&k.start();var S,D,P,j,N=Se(u,g,m,E),L=g.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=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=u||H(e,t,n),l=n.eventsUrl+"/events/bulk/"+t,v=K(),d=B(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,E=!1,k=!1;function S(){return 0===p||0===Math.floor(Math.random()*p)}function D(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>b&&e.debugEventsUntilDate>(new Date).getTime()}function P(e){var n=C({},e);return g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}function O(e){w.length<m?(w.push(e),k=!1):(k||(k=!0,y.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),o&&o.incrementDroppedEvents())}return s.enqueue=function(e){if(!E){var n=!1,t=!1;if(v.summarizeEvent(e),"feature"===e.kind?S()&&(n=!!e.trackEvents,t=D(e)):n=S(),n&&O(P(e)),t){var r=C({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,O(r)}}},s.flush=function(){if(E)return Promise.resolve();var e=w,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(be(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(b=e.serverTime),f(e.status)||(E=!0),e.status>=400&&R((function(){a.maybeReportError(new i(ae(e.status,"event posting","some events were dropped")))})))})))},s.start=function(){r=setTimeout((function e(){s.flush(),r=setTimeout(e,h)}),h)},s.stop=function(){clearTimeout(r)},s}(u,g,m,E,d,y),F=De(u,g,m),A={},q={},V=g.streaming,_=!1,J=!1,z=!0,M=g.stateProvider,$=function(e,n){var t,r={setUser:function(e){(t=x(e))&&n&&n(O(t))},getUser:function(){return t?O(t):null}};return r}(0,(function(e){M||e&&X({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})),G=Pe(u.localStorage,v);function X(e){m&&(M&&M.enqueueEvent&&M.enqueueEvent(e)||(e.user?(z=!1,!p||J||u.isDoNotTrack()||(v.debug(we(e.kind)),L.enqueue(e))):z&&(v.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),z=!1)))}function W(e,n,t,r){var o=$.getUser(),i=new Date,a=n?n.value:null;if(!g.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=A[u];if(s&&i-s<3e5)return;A[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=q[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),X(c)}function Q(e,n,t,r){var o;if(q&&q.hasOwnProperty(e)&&q[e]&&!q[e].deleted){var i=q[e];o=Z(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&&W(e,o,n,r),o}function Z(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function te(){D=!0,$.getUser()&&N.connect($.getUser(),h,{ping:function(){v.debug("received ping message from stream"),F.fetchFlagSettings($.getUser(),h).then((function(e){return ie(e||{})})).catch((function(e){d.maybeReportError(new l(ne(e)))}))},put:function(e){var n=JSON.parse(e.data);v.debug("received streaming update for all flags"),ie(n)},patch:function(e){var n=JSON.parse(e.data),t=q[n.key];if(!t||!t.version||!n.version||t.version<n.version){v.debug(pe(n.key));var r={},o=C({},n);delete o.key,q[n.key]=o;var i=Z(o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ue(r)}else v.debug(me(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!q[n.key]||q[n.key].version<n.version){v.debug(he(n.key));var t={};q[n.key]&&!q[n.key].deleted&&(t[n.key]={previous:q[n.key].value}),q[n.key]={version:n.version,deleted:!0},ue(t)}else v.debug(ye(n.key))}})}function re(){D&&(N.disconnect(),D=!1)}function ie(e){var n={};if(!e)return Promise.resolve();for(var t in q)q.hasOwnProperty(t)&&q[t]&&(e[t]&&!U(e[t].value,q[t].value)?n[t]={previous:q[t].value,current:Z(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:q[t].value}));for(var o in e)e.hasOwnProperty(o)&&e[o]&&(!q[o]||q[o].deleted)&&(n[o]={current:Z(e[o])});return q=r({},e),ue(n).catch((function(){}))}function ue(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,o=r?r.value:void 0,i=e[n].previous;d.emit("change:"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}})),d.emit("change",t),d.emit("internal-change",q),g.sendEventsOnlyForVariation||M||n.forEach((function(n){W(n,e[n].current)}))}return S&&j?j.saveFlags(q).catch((function(){return null})):Promise.resolve()}function se(){var e=V||P&&void 0===V;e&&!D?te():!e&&D&&re(),k&&k.setStreaming(e)}function ce(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}u.localStorage&&(j=new ke(u.localStorage,m,h,$,v));var le=new Promise((function(e){var n=d.on("ready",(function(){d.off("ready",n),e()}))})),fe=new Promise((function(e,n){var t=d.on("initialized",(function(){d.off("initialized",t),e()})),r=d.on("failed",(function(e){d.off("failed",r),n(e)}))}));if("string"==typeof g.bootstrap&&"LOCALSTORAGE"===g.bootstrap.toUpperCase()&&(j?S=!0:v.warn("localStorage is unavailable")),"object"===e(g.bootstrap)&&(q=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&v.warn(oe()),!1===e.$valid&&v.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}(g.bootstrap)),M){var ve=M.getInitialState();ve?de(ve):M.on("init",de),M.on("update",(function(e){e.user&&$.setUser(e.user),e.flags&&ie(e.flags)}))}else(n?G.validateUser(t).then((function(n){return $.setUser(n),"object"===e(g.bootstrap)?ge():S?j.loadFlags().catch((function(){return null})).then((function(e){return null==e?(q={},F.fetchFlagSettings($.getUser(),h).then((function(e){return ie(e||{})})).then(ge).catch((function(e){Ee(new l(ne(e)))}))):(q=e,R(ge),F.fetchFlagSettings($.getUser(),h).then((function(e){return ie(e)})).catch((function(e){return d.maybeReportError(e)})))})):F.fetchFlagSettings($.getUser(),h).then((function(e){q=e||{},ge()})).catch((function(e){q={},Ee(e)}))})):Promise.reject(new a(ee()))).catch((function(e){return d.maybeReportError(e)}));function de(e){m=e.environment,$.setUser(e.user),q=r({},e.flags),R(ge)}function ge(){v.info("LaunchDarkly client initialized"),_=!0,se(),d.emit("ready"),d.emit("initialized")}function Ee(e){d.maybeReportError(e),d.emit("failed",e),d.emit("ready")}return{client:{waitForInitialization:function(){return fe},waitUntilReady:function(){return le},identify:function(e,n,t){return J?I(Promise.resolve({}),t):M?(v.warn("identify() has no effect here; it must be called on the main client instance"),I(Promise.resolve(T(q)),t)):I((S&&j?j.clearFlags():Promise.resolve()).then((function(){return G.validateUser(e)})).then((function(e){return F.fetchFlagSettings(e,n).then((function(t){var r=T(t);return $.setUser(e),h=n,t?ie(t).then((function(){return r})):r}))})).then((function(e){return D&&te(),e})).catch((function(e){return d.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return $.getUser()},variation:function(e,n){return Q(e,n,!0,!1).value},variationDetail:function(e,n){return Q(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){u.customEventFilter&&!u.customEventFilter(e)&&v.warn(Y(e));var r={kind:"custom",key:e,user:$.getUser(),url:u.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),X(r)}else d.maybeReportError(new s(Y(e)))},on:function(e,n,t){ce(e)?(P=!0,_&&se(),d.on(e,n,t)):d.on.apply(d,arguments)},off:function(e){if(d.off.apply(d,arguments),ce(e)){var n=!1;d.getEvents().forEach((function(e){ce(e)&&d.getEventListenerCount(e)>0&&(n=!0)})),n||(P=!1,D&&void 0===V&&re())}},setStreaming:function(e){var n=null===e?void 0:e;n!==V&&(V=n,se())},flush:function(e){return I(p?L.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!q)return e;for(var n in q)q.hasOwnProperty(n)&&(e[n]=Q(n,null,!g.sendEventsOnlyForVariation).value);return e},close:function(e){if(J)return I(Promise.resolve(),e);var n=function(){J=!0,q={}};return I(Promise.resolve().then((function(){if(re(),k&&k.stop(),p)return L.stop(),L.flush()})).then(n).catch(n),e)}},options:g,emitter:d,ident:$,logger:v,requestor:F,start:function(){p&&(k&&k.start(),L.start())},enqueueEvent:X,getFlagsInternal:function(){return q},getEnvironmentId:function(){return m},internalChangeEventName:"internal-change"}}function Fe(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function Ce(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}var xe={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Ae(e,n,t,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}())return xe;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),xe;var u;return{promise:new Promise((function(e,n){i.addEventListener("load",(function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})})),i.addEventListener("error",(function(){u||n(new Error)})),i.send(r)})),cancel:function(){u=!0,i.abort()}}}function qe(e){var n,t={};t.synchronousFlush=!1,window.XMLHttpRequest&&(t.httpRequest=function(e,n,r,o){var i=t.synchronousFlush;return t.synchronousFlush=!1,Ae(e,n,r,o,i)}),t.httpAllowsPost=function(){return void 0===n&&(n=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),n},t.httpFallbackPing=function(e){(new window.Image).src=e};var r,o=e&&e.eventUrlTransformer;t.getCurrentUrl=function(){return o?o(window.location.href):window.location.href},t.isDoNotTrack=function(){var e;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(t.localStorage={get:function(e){return new Promise((function(n){n(window.localStorage.getItem(e))}))},set:function(e,n){return new Promise((function(t){window.localStorage.setItem(e,n),t()}))},clear:function(e){return new Promise((function(n){window.localStorage.removeItem(e),n()}))}})}catch(e){t.localStorage=null}if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(t.eventSourceAllowsReport=!0,r=window.EventSourcePolyfill):(t.eventSourceAllowsReport=!1,r=window.EventSource),window.EventSource){t.eventSourceFactory=function(e,n){var t=function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Ce(t,!0).forEach((function(n){Fe(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Ce(t).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},{},n);return new r(e,t)},t.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return t.userAgent="JSClient",t.version="2.17.0",t.diagnosticSdkData={name:"js-client-sdk",version:"2.17.0"},t.diagnosticPlatformData={name:"JS"},t.diagnosticUseCombinedEvent=!0,t}var Ve=/[|\\{}()[\]^$+*?.]/g,_e=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(Ve,"\\$&")};function Je(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+_e(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+_e(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+_e(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function ze(e,n){for(var t={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(Je(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?n("pageview",a):(o.push(a),n("click_pageview",a));break}return o.length>0&&(r=function(e){for(var t=function(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&u.length>0;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}(e,o),r=0;r<t.length;r++)n("click",t[r])},document.addEventListener("click",r)),t.dispose=function(){document.removeEventListener("click",r)},t}var Me=300;function $e(e,n){var t,r,o={};function i(){r&&r.dispose(),t&&t.length&&(r=ze(t,a))}function a(n,t){var r={kind:n,key:t.key,data:null,url:window.location.href,user:e.ident.getUser(),creationDate:(new Date).getTime()};return"click"===n&&(r.selector=t.selector),e.enqueueEvent(r)}return o.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=ze(t=e,a),function(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout((function(){e(n,t)}),t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(Me,i)),n()})).catch((function(t){e.emitter.maybeReportError(new v.LDUnexpectedResponseError((t&&t.message,t.message))),n()})),o}var He="goalsReady",Ke={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"}};function Be(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=qe(t),o=Le(e,n,t,r,Ke),i=o.client,a=o.options,u=o.emitter,s=new Promise((function(e){var n=u.on(He,(function(){u.off(He,n),e()}))}));if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=$e(o,(function(){return u.emit(He)}));r.customEventFilter=c.goalKeyExists}else u.emit(He);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var l=function(){r.synchronousFlush=!0,i.flush().catch((function(){})),r.synchronousFlush=!1};return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var Ge=Ne,Xe="2.17.0";var We={initialize:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Ee.deprecated("default export","named LDClient export")),Be(e,n,t)},version:"2.17.0"};export default We;export{Ge as createConsoleLogger,Be as initialize,Xe as version}; | ||
function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?t(o,!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(o).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var i=o("LaunchDarklyUnexpectedResponseError"),a=o("LaunchDarklyInvalidEnvironmentIdError"),u=o("LaunchDarklyInvalidUserError"),s=o("LaunchDarklyInvalidEventKeyError"),c=o("LaunchDarklyInvalidArgumentError"),l=o("LaunchDarklyFlagFetchError");function f(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var v=Object.freeze({__proto__:null,LDUnexpectedResponseError:i,LDInvalidEnvironmentIdError:a,LDInvalidUserError:u,LDInvalidEventKeyError:s,LDInvalidArgumentError:c,LDFlagFetchError:l,isHttpErrorRecoverable:f}),d=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(w(e,i,i+16383>a?a:i+16383));return 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]+"=")),o.join("")},g=[],p=[],m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,y=m.length;h<y;++h)g[h]=m[h],p[m.charCodeAt(h)]=h;function w(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 b=Array.isArray,k=Object.keys,E=Object.prototype.hasOwnProperty,S=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function P(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 P(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function O(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=b(n),u=b(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=k(n);if((o=v.length)!==k(t).length)return!1;for(r=o;0!=r--;)if(!E.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 I(e){setTimeout(e,0)}function R(e,n){var t=e.then((function(e){return n&&setTimeout((function(){n(null,e)}),0),e}),(function(e){if(!n)return Promise.reject(e);setTimeout((function(){n(e,null)}),0)}));return n?void 0:t}function j(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function T(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function N(e,n){for(var t,r=n.slice(0),o=[],i=e;r.length>0;){for(t=[];i>0;){var a=r.shift();if(!a)break;(i-=D(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function L(e){var n=e.version||"3.2.3";return e.userAgent+"/"+n}function F(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":L(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 x(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}Object.freeze({__proto__:null,btoa:P,base64URLEncode:D,clone:O,deepEquals:U,onNextTick:I,wrapPromiseCallback:R,transformValuesToVersionedValues:j,transformVersionedValuesToValues:T,chunkUserEventsForUrl:N,getLDUserAgentString:L,getLDHeaders:F,extend:C,sanitizeUser:x});for(var A=function(e,n){return 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}}}(n={exports:{}}),n.exports}(),q=[],V=0;V<256;++V)q[V]=(V+256).toString(16).substr(1);var _,J,z=0,M=0,$=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||_,a=void 0!==e.clockseq?e.clockseq:J;if(null==i||null==a){var u=A();null==i&&(i=_=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=J=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:M+1,l=s-z+(c-M)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>z)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");z=s,M=c,J=a;var f=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;o[r++]=f>>>24&255,o[r++]=f>>>16&255,o[r++]=f>>>8&255,o[r++]=255&f;var v=s/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var d=0;d<6;++d)o[r+d]=i[d];return n||function(e,n){var t=n||0,r=q;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("")}(o)};function H(e,n,t){var r="/a/"+n+".gif",o=C({"Content-Type":"application/json"},F(e,t)),i=e.httpFallbackPing,a={sendChunk:function(n,t,a,u){var s=JSON.stringify(n),c=a?null:$();return u?function n(r){var i=a?o:C({},o,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":c});return e.httpRequest("POST",t,i,s).promise.then((function(e){if(e)return e.status>=400&&f(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(i&&i(t+r+"?d="+D(s)),Promise.resolve())},sendEvents:function(n,t,r){if(!e.httpRequest)return Promise.resolve();var o,i=e.httpAllowsPost();o=i?[n]:N(2e3-t.length,n);for(var u=[],s=0;s<o.length;s++)u.push(a.sendChunk(o[s],t,r,i));return Promise.all(u)}};return a}function K(){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 s={value:a.value,count:a.count};void 0!==a.variation&&null!==a.variation&&(s.variation=a.variation),a.version?s.version=a.version:s.unknown=!0,u.counters.push(s),o=!1}return o?null:{startDate:n,endDate:t,features:e}},e.clearSummary=function(){n=0,t=0,r={}},e}function B(e){var n={},t=e.allAttributesPrivate,r=e.privateAttributeNames||[],o={key:!0,custom:!0,anonymous:!0},i={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;var n=e.privateAttributeNames||[],a=function(e,i){return Object.keys(e).reduce((function(a,u){var s=a;return i(u)&&(function(e){return!o[e]&&(t||-1!==n.indexOf(e)||-1!==r.indexOf(e))}(u)?s[1][u]=!0:s[0][u]=e[u]),s}),[{},{}])},u=a(e,(function(e){return i[e]})),s=u[0],c=u[1];if(e.custom){var l=a(e.custom,(function(){return!0}));s.custom=l[0],c=C({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function G(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var X=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",W=function(e){return'Expected application/json content type but got "'+e+'"'},Q=function(e){return"network error"+(e?" ("+e+")":"")},Y=function(e){return'Custom event "'+e+'" does not exist'},Z=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+X},ee=function(){return"No environment/client-side ID was specified."+X},ne=function(e){return"Error fetching flag settings: "+G(e)},te=function(){return"No user specified."+X},re=function(){return"Invalid user specified."+X},oe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+X},ie=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},ae=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(f(e)?t:"giving up permanently")},ue=function(){return"Cannot make HTTP requests in this environment."+X},se=function(e){return"Opening stream connection to "+e},ce=function(e,n){return"Error on stream connection: "+G(e)+", will continue retrying every "+n+" milliseconds."},le=function(e){return'Ignoring unknown config option "'+e+'"'},fe=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},ve=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},de=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},ge=function(e){return"polling for feature flags at "+e},pe=function(e){return'received streaming update for flag "'+e+'"'},me=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},he=function(e){return'received streaming deletion for flag "'+e+'"'},ye=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},we=function(e){return'enqueueing "'+e+'" event'},be=function(e){return"sending "+e+" events"},ke=Object.freeze({__proto__:null,clientInitialized:function(){return"LaunchDarkly client initialized"},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:W,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:Q,unknownCustomEventKey:Y,environmentNotFound:Z,environmentNotSpecified:ee,errorFetchingFlags:ne,userNotSpecified:te,invalidUser:re,bootstrapOldFormat:oe,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:ie,httpErrorMessage:ae,httpUnavailable:ue,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:se,streamError:ce,unknownOption:le,wrongOptionType:fe,wrongOptionTypeBoolean:ve,optionBelowMinimum:de,debugPolling:ge,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:pe,debugStreamPatchIgnored:me,debugStreamDelete:he,debugStreamDeleteIgnored:ye,debugEnqueueingEvent:we,debugPostingEvents:be,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});var Ee=function(e){var n=!1,t=!1,r=null,o=null,i=new Promise((function(n){e.on("ready",(function t(){e.off("ready",t),n()}))})).catch((function(){}));return{getInitializationPromise:function(){return o||(n?Promise.resolve():t?Promise.reject(r):o=new Promise((function(n,t){e.on("initialized",(function t(){e.off("initialized",t),n()})),e.on("failed",(function n(r){e.off("failed",n),t(r)}))})))},getReadyPromise:function(){return i},signalSuccess:function(){n||t||(n=!0,e.emit("initialized"),e.emit("ready"))},signalFailure:function(o){n||t||(t=!0,r=o,e.emit("failed",o),e.emit("ready")),e.maybeReportError(o)}}};function Se(e,n,t,r,o){var i={};function a(){var e="",o=r.getUser();return o&&(e=t||P(JSON.stringify(o))),"ld:"+n+":"+e}return i.loadFlags=function(){return e.get(a()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=j(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 Pe(e,n,t,r){var o,i=n.streamUrl,a=n.logger,u={},s=i+"/eval/"+t,c=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,v=F(e,n),d=!1,g=null,p=null,m=null,h=null,y=null;function w(e){d||(a.warn(ce(e,f)),d=!0),S(!1),E(),b(f)}function b(e){p||(e?p=setTimeout(k,e):k())}function k(){var n;p=null;var r="",u={headers:v};if(e.eventSourceFactory){for(var f in null!=h&&(r="h="+h),c?e.eventSourceAllowsReport?(n=s,u.method="REPORT",u.headers["Content-Type"]="application/json",u.body=JSON.stringify(m)):(n=i+"/ping/"+t,r=""):n=s+"/"+D(JSON.stringify(m)),l&&(r=r+(r?"&":"")+"withReasons=true"),n=n+(r?"?":"")+r,E(),a.info(se(n)),o=(new Date).getTime(),g=e.eventSourceFactory(n,u),y)y.hasOwnProperty(f)&&g.addEventListener(f,y[f]);g.onerror=w}}function E(){g&&(a.info("Closing stream connection"),g.close(),g=null)}function S(e){o&&r&&r.recordStreamInit(o,!e,(new Date).getTime()-o),o=null}return u.connect=function(e,n,t){m=e,h=n,y={};var r=function(e){y[e]=function(n){d=!1,S(!0),t[e]&&t[e](n)}};for(var o in t||{})r(o);b()},u.disconnect=function(){clearTimeout(p),p=null,E()},u.isConnected=function(){return!!(g&&e.eventSourceIsActive&&e.eventSourceIsActive(g))},u}function De(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,u=n.logger,s={},c={};function f(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new l(ue()))}));var o=r?"REPORT":"GET",i=F(e,n);r&&(i["Content-Type"]="application/json");var u=c[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 c[t]})),c[t]=u);var s=e.httpRequest(o,t,i,r),f=s.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=W(e.header("content-type")||"");return Promise.reject(new l(n))}return Promise.reject(function(e){return 404===e.status?new a(Z()):new l(ne(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new l(Q(e)))}));return u.addPromise(f,(function(){s.cancel&&s.cancel()})),u.resultPromise}return s.fetchJSON=function(e){return f(r+e,null)},s.fetchFlagSettings=function(e,n){var a,s,c,l="";return o?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(a=D(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",a].join("")),n&&(l="h="+n),i&&(l=l+(l?"&":"")+"withReasons=true"),s=s+(l?"?":"")+l,u.debug(ge(s)),f(s,c)},s}function Oe(e,n){var t={validateUser:function(t){if(!t)return Promise.reject(new u(te()));var r=O(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=$();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(re()))}};return t}var Ue={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"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function Ie(n,t,r,o){var i=C({logger:{default:o}},Ue,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){I((function(){t&&t.maybeReportError(new c(e))}))}var s=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(ie(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),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(le(e));else{var s=a.type||r(a.default);if("any"!==s){var c=s.split("|"),l=r(o);c.indexOf(l)<0?"boolean"===s?(t[e]=!!o,u(ve(e,l))):(u(fe(e,s,l)),t[e]=a.default):"number"===l&&void 0!==a.minimum&&o<a.minimum&&(u(de(e,o,a.minimum)),t[e]=a.minimum)}}}})),t}(s=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}(s))}var Re=Object.freeze({__proto__:null,baseOptionDefs:Ue,validate:Ie}).baseOptionDefs,je=function(e){var n={diagnosticId:$()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n},Te=function(e){var n,t,r,o;function i(e){n=e,t=0,r=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:o}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};o.push(r)},reset:i}},Ne=function(e,n,t,o,i,a){var u,s,c=!!e.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+o,v=i.diagnosticRecordingInterval,d=n,g=!!i.streaming,p={};function m(){return{sdk:w(),configuration:(n={customBaseURI:i.baseUrl!==Re.baseUrl.default,customStreamURI:i.streamUrl!==Re.streamUrl.default,customEventsURI:i.eventsUrl!==Re.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation},n),platform:e.diagnosticPlatformData};var n}function h(e){i.logger&&i.logger.debug(ke.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then((function(){})).catch((function(){}))}function y(){var n,t;h((n=(new Date).getTime(),t=r({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:n},d.getProps()),c&&(t=r({},t,{},m())),d.reset(n),t)),s=setTimeout(y,v),u=(new Date).getTime(),c&&function(){if(e.localStorage){var n=r({},d.getProps());e.localStorage.set(l,JSON.stringify(n),(function(){}))}}()}function w(){var n=r({},e.diagnosticSdkData);return i.wrapperName&&(n.wrapperName=i.wrapperName),i.wrapperVersion&&(n.wrapperVersion=i.wrapperVersion),n}return p.start=function(){c?function(n){if(!e.localStorage)return n(!1);e.localStorage.get(l).then((function(e){if(e)try{var t=JSON.parse(e);d.setProps(t),u=t.dataSinceDate}catch(e){}n(!0)})).catch((function(){n(!1)}))}((function(e){if(e){var n=(u||0)+v,t=(new Date).getTime();t>=n?y():s=setTimeout(y,n-t)}else 0===Math.floor(4*Math.random())?y():s=setTimeout(y,v)})):(h(r({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate},m())),s=setTimeout(y,v))},p.stop=function(){s&&clearTimeout(s)},p.setStreaming=function(e){g=e},p};function Le(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 Fe(n,t,o,u,c){var v=o&&o.logger?o.logger:c&&c.logger&&c.logger.default||Le("warn"),d=function(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=t[e].slice(0),r=0;r<n.length;r++)n[r].handler.apply(n[r].context,Array.prototype.slice.call(arguments,1))},n.getEvents=function(){return Object.keys(t)},n.getEventListenerCount=function(e){return t[e]?t[e].length:0},n.maybeReportError=function(n){n&&(t.error?this.emit("error",n):(e||console).error(n.message))},n}(v),g=Ee(d),p=Ie(o,d,c,v),m=p.sendEvents,h=n,y=p.hash,w=H(u,h,p),b=p.sendEvents&&!p.diagnosticOptOut,k=b?je(h):null,E=b?Te((new Date).getTime()):null,S=b?Ne(u,E,w,h,p,k):null;S&&S.start();var P,D,j,N,L=Pe(u,p,h,E),F=p.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=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=u||H(e,t,n),l=n.eventsUrl+"/events/bulk/"+t,v=K(),d=B(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,k=!1,E=!1;function S(){return 0===p||0===Math.floor(Math.random()*p)}function P(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>b&&e.debugEventsUntilDate>(new Date).getTime()}function D(e){var n=C({},e);return g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}function O(e){w.length<m?(w.push(e),E=!1):(E||(E=!0,y.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),o&&o.incrementDroppedEvents())}return s.enqueue=function(e){if(!k){var n=!1,t=!1;if(v.summarizeEvent(e),"feature"===e.kind?S()&&(n=!!e.trackEvents,t=P(e)):n=S(),n&&O(D(e)),t){var r=C({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,O(r)}}},s.flush=function(){if(k)return Promise.resolve();var e=w,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(be(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(b=e.serverTime),f(e.status)||(k=!0),e.status>=400&&I((function(){a.maybeReportError(new i(ae(e.status,"event posting","some events were dropped")))})))})))},s.start=function(){r=setTimeout((function e(){s.flush(),r=setTimeout(e,h)}),h)},s.stop=function(){clearTimeout(r)},s}(u,p,h,E,d,w),A=De(u,p,h),q={},V={},_=p.streaming,J=!1,z=!1,M=!0,$=p.stateProvider,G=function(e,n){var t,r={setUser:function(e){(t=x(e))&&n&&n(O(t))},getUser:function(){return t?O(t):null}};return r}(0,(function(e){$||e&&W({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})),X=Oe(u.localStorage,v);function W(e){h&&($&&$.enqueueEvent&&$.enqueueEvent(e)||(e.user?(M=!1,!m||z||u.isDoNotTrack()||(v.debug(we(e.kind)),F.enqueue(e))):M&&(v.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),M=!1)))}function Q(e,n,t,r){var o=G.getUser(),i=new Date,a=n?n.value:null;if(!p.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=q[u];if(s&&i-s<3e5)return;q[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=V[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),W(c)}function Z(e,n,t,r){var o;if(V&&V.hasOwnProperty(e)&&V[e]&&!V[e].deleted){var i=V[e];o=te(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&&Q(e,o,n,r),o}function te(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function re(){D=!0,G.getUser()&&L.connect(G.getUser(),y,{ping:function(){v.debug("received ping message from stream"),A.fetchFlagSettings(G.getUser(),y).then((function(e){return ue(e||{})})).catch((function(e){d.maybeReportError(new l(ne(e)))}))},put:function(e){var n=JSON.parse(e.data);v.debug("received streaming update for all flags"),ue(n)},patch:function(e){var n=JSON.parse(e.data),t=V[n.key];if(!t||!t.version||!n.version||t.version<n.version){v.debug(pe(n.key));var r={},o=C({},n);delete o.key,V[n.key]=o;var i=te(o);r[n.key]=t?{previous:t.value,current:i}:{current:i},se(r)}else v.debug(me(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!V[n.key]||V[n.key].version<n.version){v.debug(he(n.key));var t={};V[n.key]&&!V[n.key].deleted&&(t[n.key]={previous:V[n.key].value}),V[n.key]={version:n.version,deleted:!0},se(t)}else v.debug(ye(n.key))}})}function ie(){D&&(L.disconnect(),D=!1)}function ue(e){var n={};if(!e)return Promise.resolve();for(var t in V)V.hasOwnProperty(t)&&V[t]&&(e[t]&&!U(e[t].value,V[t].value)?n[t]={previous:V[t].value,current:te(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:V[t].value}));for(var o in e)e.hasOwnProperty(o)&&e[o]&&(!V[o]||V[o].deleted)&&(n[o]={current:te(e[o])});return V=r({},e),se(n).catch((function(){}))}function se(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;d.emit("change:"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}})),d.emit("change",t),d.emit("internal-change",V),p.sendEventsOnlyForVariation||$||n.forEach((function(n){Q(n,e[n].current)}))}return P&&N?N.saveFlags(V).catch((function(){return null})):Promise.resolve()}function ce(){var e=_||j&&void 0===_;e&&!D?re():!e&&D&&ie(),S&&S.setStreaming(e)}function le(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if(u.localStorage&&(N=new Se(u.localStorage,h,y,G,v)),"string"==typeof p.bootstrap&&"LOCALSTORAGE"===p.bootstrap.toUpperCase()&&(N?P=!0:v.warn("localStorage is unavailable")),"object"===e(p.bootstrap)&&(V=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&v.warn(oe()),!1===e.$valid&&v.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}(p.bootstrap)),$){var fe=$.getInitialState();fe?ve(fe):$.on("init",ve),$.on("update",(function(e){e.user&&G.setUser(e.user),e.flags&&ue(e.flags)}))}else(n?X.validateUser(t).then((function(n){return G.setUser(n),"object"===e(p.bootstrap)?de():P?N.loadFlags().catch((function(){return null})).then((function(e){return null==e?(V={},A.fetchFlagSettings(G.getUser(),y).then((function(e){return ue(e||{})})).then(de).catch((function(e){ge(new l(ne(e)))}))):(V=e,I(de),A.fetchFlagSettings(G.getUser(),y).then((function(e){return ue(e)})).catch((function(e){return d.maybeReportError(e)})))})):A.fetchFlagSettings(G.getUser(),y).then((function(e){V=e||{},de()})).catch((function(e){V={},ge(e)}))})):Promise.reject(new a(ee()))).catch(ge);function ve(e){h=e.environment,G.setUser(e.user),V=r({},e.flags),I(de)}function de(){v.info("LaunchDarkly client initialized"),J=!0,ce(),g.signalSuccess()}function ge(e){g.signalFailure(e)}return{client:{waitForInitialization:function(){return g.getInitializationPromise()},waitUntilReady:function(){return g.getReadyPromise()},identify:function(e,n,t){return z?R(Promise.resolve({}),t):$?(v.warn("identify() has no effect here; it must be called on the main client instance"),R(Promise.resolve(T(V)),t)):R((P&&N?N.clearFlags():Promise.resolve()).then((function(){return X.validateUser(e)})).then((function(e){return A.fetchFlagSettings(e,n).then((function(t){var r=T(t);return G.setUser(e),y=n,t?ue(t).then((function(){return r})):r}))})).then((function(e){return D&&re(),e})).catch((function(e){return d.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return G.getUser()},variation:function(e,n){return Z(e,n,!0,!1).value},variationDetail:function(e,n){return Z(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){u.customEventFilter&&!u.customEventFilter(e)&&v.warn(Y(e));var r={kind:"custom",key:e,user:G.getUser(),url:u.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),W(r)}else d.maybeReportError(new s(Y(e)))},on:function(e,n,t){le(e)?(j=!0,J&&ce(),d.on(e,n,t)):d.on.apply(d,arguments)},off:function(e){if(d.off.apply(d,arguments),le(e)){var n=!1;d.getEvents().forEach((function(e){le(e)&&d.getEventListenerCount(e)>0&&(n=!0)})),n||(j=!1,D&&void 0===_&&ie())}},setStreaming:function(e){var n=null===e?void 0:e;n!==_&&(_=n,ce())},flush:function(e){return R(m?F.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!V)return e;for(var n in V)V.hasOwnProperty(n)&&(e[n]=Z(n,null,!p.sendEventsOnlyForVariation).value);return e},close:function(e){if(z)return R(Promise.resolve(),e);var n=function(){z=!0,V={}};return R(Promise.resolve().then((function(){if(ie(),S&&S.stop(),m)return F.stop(),F.flush()})).then(n).catch(n),e)}},options:p,emitter:d,ident:G,logger:v,requestor:A,start:function(){m&&(S&&S.start(),F.start())},enqueueEvent:W,getFlagsInternal:function(){return V},getEnvironmentId:function(){return h},internalChangeEventName:"internal-change"}}function Ce(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function xe(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}var Ae={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function qe(e,n,t,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}())return Ae;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),Ae;var u;return{promise:new Promise((function(e,n){i.addEventListener("load",(function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})})),i.addEventListener("error",(function(){u||n(new Error)})),i.send(r)})),cancel:function(){u=!0,i.abort()}}}function Ve(e){var n,t={};t.synchronousFlush=!1,window.XMLHttpRequest&&(t.httpRequest=function(e,n,r,o){var i=t.synchronousFlush;return t.synchronousFlush=!1,qe(e,n,r,o,i)}),t.httpAllowsPost=function(){return void 0===n&&(n=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),n},t.httpFallbackPing=function(e){(new window.Image).src=e};var r,o=e&&e.eventUrlTransformer;t.getCurrentUrl=function(){return o?o(window.location.href):window.location.href},t.isDoNotTrack=function(){var e;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(t.localStorage={get:function(e){return new Promise((function(n){n(window.localStorage.getItem(e))}))},set:function(e,n){return new Promise((function(t){window.localStorage.setItem(e,n),t()}))},clear:function(e){return new Promise((function(n){window.localStorage.removeItem(e),n()}))}})}catch(e){t.localStorage=null}if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(t.eventSourceAllowsReport=!0,r=window.EventSourcePolyfill):(t.eventSourceAllowsReport=!1,r=window.EventSource),window.EventSource){t.eventSourceFactory=function(e,n){var t=function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?xe(t,!0).forEach((function(n){Ce(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):xe(t).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},{},n);return new r(e,t)},t.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return t.userAgent="JSClient",t.version="2.17.1",t.diagnosticSdkData={name:"js-client-sdk",version:"2.17.1"},t.diagnosticPlatformData={name:"JS"},t.diagnosticUseCombinedEvent=!0,t}var _e=/[|\\{}()[\]^$+*?.]/g,Je=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(_e,"\\$&")};function ze(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+Je(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+Je(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+Je(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Me(e,n){for(var t={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(ze(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?n("pageview",a):(o.push(a),n("click_pageview",a));break}return o.length>0&&(r=function(e){for(var t=function(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&u.length>0;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}(e,o),r=0;r<t.length;r++)n("click",t[r])},document.addEventListener("click",r)),t.dispose=function(){document.removeEventListener("click",r)},t}var $e=300;function He(e,n){var t,r,o={};function i(){r&&r.dispose(),t&&t.length&&(r=Me(t,a))}function a(n,t){var r={kind:n,key:t.key,data:null,url:window.location.href,user:e.ident.getUser(),creationDate:(new Date).getTime()};return"click"===n&&(r.selector=t.selector),e.enqueueEvent(r)}return o.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=Me(t=e,a),function(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout((function(){e(n,t)}),t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}($e,i)),n()})).catch((function(t){e.emitter.maybeReportError(new v.LDUnexpectedResponseError((t&&t.message,t.message))),n()})),o}var Ke="goalsReady",Be={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"}};function Ge(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Ve(t),o=Fe(e,n,t,r,Be),i=o.client,a=o.options,u=o.emitter,s=new Promise((function(e){var n=u.on(Ke,(function(){u.off(Ke,n),e()}))}));if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=He(o,(function(){return u.emit(Ke)}));r.customEventFilter=c.goalKeyExists}else u.emit(Ke);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var l=function(){r.synchronousFlush=!0,i.flush().catch((function(){})),r.synchronousFlush=!1};return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var Xe=Le,We="2.17.1";var Qe={initialize:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(ke.deprecated("default export","named LDClient export")),Ge(e,n,t)},version:"2.17.1"};export default Qe;export{Xe as createConsoleLogger,Ge as initialize,We as version}; | ||
//# sourceMappingURL=ldclient.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={})}(this,function(e){"use strict";function W(e){return(W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function Q(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 Y=t("LaunchDarklyUnexpectedResponseError"),Z=t("LaunchDarklyInvalidEnvironmentIdError"),a=t("LaunchDarklyInvalidUserError"),ee=t("LaunchDarklyInvalidEventKeyError"),d=t("LaunchDarklyInvalidArgumentError"),ne=t("LaunchDarklyFlagFetchError");function te(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var s=Object.freeze({__proto__:null,LDUnexpectedResponseError:Y,LDInvalidEnvironmentIdError:Z,LDInvalidUserError:a,LDInvalidEventKeyError:ee,LDInvalidArgumentError:d,LDFlagFetchError:ne,isHttpErrorRecoverable:te}),r=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));return 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]+"=")),o.join("")},u=[],o=[],i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=i.length;c<l;++c)u[c]=i[c],o[i.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("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63;var g=Array.isArray,p=Object.keys,m=Object.prototype.hasOwnProperty,v=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function h(e){var n=unescape(encodeURIComponent(e));return r(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function D(e){return h(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function re(e){return JSON.parse(JSON.stringify(e))}function oe(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=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}(e,n)}function ie(e){setTimeout(e,0)}function ae(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 y(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function ue(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function w(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-=D(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function b(e){var n=e.version||"3.2.2";return e.userAgent+"/"+n}function P(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":b(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function se(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return Q({},e,{},n)},{})}function ce(e){if(!e)return e;var n;for(var t in v){var r=v[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||Q({},e))[r]=String(o))}return n||e}Object.freeze({__proto__:null,btoa:h,base64URLEncode:D,clone:re,deepEquals:oe,onNextTick:ie,wrapPromiseCallback:ae,transformValuesToVersionedValues:y,transformVersionedValuesToValues:ue,chunkUserEventsForUrl:w,getLDUserAgentString:b,getLDHeaders:P,extend:se,sanitizeUser:ce});for(var E,k=(E=void 0,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}}}(E={exports:{}}),E.exports),S=[],O=0;O<256;++O)S[O]=(O+256).toString(16).substr(1);var U,R,I=0,j=0,T=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||U,a=void 0!==e.clockseq?e.clockseq:R;if(null==i||null==a){var u=k();null==i&&(i=U=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=R=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:j+1,l=s-I+(c-j)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||I<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");I=s,R=a;var f=(1e4*(268435455&(s+=122192928e5))+(j=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||function(e,n){var t=n||0,r=S;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("")}(o)};function le(u,e,n){var t="/a/"+e+".gif",s=se({"Content-Type":"application/json"},P(u,n)),c=u.httpFallbackPing,l={sendChunk:function(e,r,o,n){var i=JSON.stringify(e),a=o?null:T();return n?function n(t){var e=o?s:se({},s,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,e,i).promise.then(function(e){if(e)return 400<=e.status&&te(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(r+t+"?d="+D(i)),Promise.resolve())},sendEvents:function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,o=u.httpAllowsPost();r=o?[e]:w(2e3-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(l.sendChunk(r[a],n,t,o));return Promise.all(i)}};return l}function fe(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(o,i){return Object.keys(o).reduce(function(e,n){var t,r=e;return i(n)&&(l[t=n]||!s&&-1===a.indexOf(t)&&-1===c.indexOf(t)?r[0][n]=o[n]:r[1][n]=!0),r},[{},{}])}var a=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],o=t[1];if(e.custom){var i=n(e.custom,function(){return!0});r.custom=i[0],o=se({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function N(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var L=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",F=function(e){return'Expected application/json content type but got "'+e+'"'},C=function(e){return"network error"+(e?" ("+e+")":"")},ve=function(e){return'Custom event "'+e+'" does not exist'},x=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+L},de=function(){return"No environment/client-side ID was specified."+L},ge=function(e){return"Error fetching flag settings: "+N(e)},A=function(){return"No user specified."+L},q=function(){return"Invalid user specified."+L},pe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+L},_=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},me=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(te(e)?t:"giving up permanently")},V=function(){return"Cannot make HTTP requests in this environment."+L},J=function(e){return"Opening stream connection to "+e},z=function(e,n){return"Error on stream connection: "+N(e)+", will continue retrying every "+n+" milliseconds."},M=function(e){return'Ignoring unknown config option "'+e+'"'},$=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},H=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},K=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},B=function(e){return"polling for feature flags at "+e},he=function(e){return'received streaming update for flag "'+e+'"'},ye=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},we=function(e){return'received streaming deletion for flag "'+e+'"'},be=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Ee=function(e){return'enqueueing "'+e+'" event'},ke=function(e){return"sending "+e+" events"},G=Object.freeze({__proto__:null,clientInitialized:function(){return"LaunchDarkly client initialized"},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:F,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:C,unknownCustomEventKey:ve,environmentNotFound:x,environmentNotSpecified:de,errorFetchingFlags:ge,userNotSpecified:A,invalidUser:q,bootstrapOldFormat:pe,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:_,httpErrorMessage:me,httpUnavailable:V,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:J,streamError:z,unknownOption:M,wrongOptionType:$,wrongOptionTypeBoolean:H,optionBelowMinimum:K,debugPolling:B,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:he,debugStreamPatchIgnored:ye,debugStreamDelete:we,debugStreamDeleteIgnored:be,debugEnqueueingEvent:Ee,debugPostingEvents:ke,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function Se(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=y(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.saveFlags=function(e){var n=se({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u}function De(o,e,i,n){var a,u=e.streamUrl,s=e.logger,t={},c=u+"/eval/"+i,l=e.useReport,f=e.evaluationReasons,r=e.streamReconnectDelay,v=P(o,e),d=!1,g=null,p=null,m=null,h=null,y=null;function w(e){d||(s.warn(z(e,r)),d=!0),S(!1),k(),b(r)}function b(e){p||(e?p=setTimeout(E,e):E())}function E(){var e;p=null;var n="",t={headers:v};if(o.eventSourceFactory){for(var r in null!=h&&(n="h="+h),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+"/"+D(JSON.stringify(m)),f&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,k(),s.info(J(e)),a=(new Date).getTime(),g=o.eventSourceFactory(e,t),y)y.hasOwnProperty(r)&&g.addEventListener(r,y[r]);g.onerror=w}}function k(){g&&(s.info("Closing stream connection"),g.close(),g=null)}function S(e){a&&n&&n.recordStreamInit(a,!e,(new Date).getTime()-a),a=null}return t.connect=function(e,n,t){m=e,h=n,y={};function r(n){y[n]=function(e){S(!(d=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);b()},t.disconnect=function(){clearTimeout(p),p=null,k()},t.isConnected=function(){return!!(g&&o.eventSourceIsActive&&o.eventSourceIsActive(g))},t}function Pe(d,g,a){var u=g.baseUrl,s=g.useReport,c=g.evaluationReasons,l=g.logger,e={},p={};function f(e,n){if(!d.httpRequest)return new Promise(function(e,n){n(new ne(V()))});var t=n?"REPORT":"GET",r=P(d,g);n&&(r["Content-Type"]="application/json");var o,i,a,u,s,c,l=p[e];l||(o=function(){delete p[e]},(c={addPromise:function(n,e){i=n,a&&a(),a=e,n.then(function(e){i===n&&(u(e),o())},function(e){i===n&&(s(e),o())})}}).resultPromise=new Promise(function(e,n){u=e,s=n}),l=c,p[e]=l);var f=d.httpRequest(t,e,r,n),v=f.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new Z(x()):new ne(ge(n.statusText||String(n.status))));if(e.header("content-type")&&0===e.header("content-type").lastIndexOf("application/json"))return JSON.parse(e.body);var n,t=F(e.header("content-type")||"");return Promise.reject(new ne(t))},function(e){return Promise.reject(new ne(C(e)))});return l.addPromise(v,function(){f.cancel&&f.cancel()}),l.resultPromise}return e.fetchJSON=function(e){return f(u+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return s?(r=[u,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=D(JSON.stringify(e)),r=[u,"/sdk/evalx/",a,"/users/",t].join("")),n&&(i="h="+n),c&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,l.debug(B(r)),f(r,o)},e}function Oe(o,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new a(A()));var r=re(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(o?o.get("ld:$anonUserId").catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return r.key=e,r;var n,t=T();return r.key=t,(n=t,o?o.set("ld:$anonUserId",n).catch(function(){i.warn("localStorage is unavailable, so anonymous user ID cannot be cached")}):Promise.resolve()).then(function(){return r})}):Promise.reject(new a(q()))},e}var X={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"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function Ue(e,n,t,r){var a=se({logger:{default:r}},X,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){ie(function(){n&&n.maybeReportError(new d(e))})}var s,c,i,l,f=se({},e||{});return l=f,Object.keys(o).forEach(function(e){if(void 0!==l[e]){var n=o[e];r&&r.warn(_(e,n)),n&&(void 0===l[n]&&(l[n]=l[e]),delete l[e])}}),i=se({},f),Object.keys(a).forEach(function(e){void 0!==i[e]&&null!==i[e]||(i[e]=a[e]&&a[e].default)}),s=f=i,c=se({},s),Object.keys(s).forEach(function(e){var n=s[e];if(null!=n){var t=a[e];if(void 0===t)u(M(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?(c[e]=!!n,u(H(e,i))):(u($(e,r,i)),c[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(K(e,n,t.minimum)),c[e]=t.minimum)}}}}),c;function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=W(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}}var Re=Object.freeze({__proto__:null,baseOptionDefs:X,validate:Ue}).baseOptionDefs,Ie=function(e){var n={diagnosticId:T()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},je=function(e){var n,t,r,o;function i(e){n=e,r=t=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:o}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};o.push(r)},reset:i}},Te=function(r,e,n,t,o,i){var a,u,s=!!r.diagnosticUseCombinedEvent,c="ld:"+t+":$diagnostics",l=o.eventsUrl+"/events/diagnostic/"+t,f=o.diagnosticRecordingInterval,v=e,d=!!o.streaming,g={};function p(){return{sdk:function(){var e=Q({},r.diagnosticSdkData);return o.wrapperName&&(e.wrapperName=o.wrapperName),o.wrapperVersion&&(e.wrapperVersion=o.wrapperVersion),e}(),configuration:(e={customBaseURI:o.baseUrl!==Re.baseUrl.default,customStreamURI:o.streamUrl!==Re.streamUrl.default,customEventsURI:o.eventsUrl!==Re.eventsUrl.default,eventsCapacity:o.eventCapacity,eventsFlushIntervalMillis:o.flushInterval,reconnectTimeMillis:o.streamReconnectDelay,streamingDisabled:!d,allAttributesPrivate:!!o.allAttributesPrivate,inlineUsersInEvents:!!o.inlineUsersInEvents,diagnosticRecordingIntervalMillis:o.diagnosticRecordingInterval,usingSecureMode:!!o.hash,bootstrapMode:!!o.bootstrap,fetchGoalsDisabled:!o.fetchGoals,allowFrequentDuplicateEvents:!!o.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!o.sendEventsOnlyForVariation},e),platform:r.diagnosticPlatformData};var e}function m(e){o.logger&&o.logger.debug(G.debugPostingDiagnosticEvent(e)),n.sendEvents(e,l,!0).then(function(){}).catch(function(){})}function h(){var e,n;m((e=(new Date).getTime(),n=Q({kind:s?"diagnostic-combined":"diagnostic",id:i,creationDate:e},v.getProps()),s&&(n=Q({},n,{},p())),v.reset(e),n)),u=setTimeout(h,f),a=(new Date).getTime(),s&&function(){if(r.localStorage){var e=Q({},v.getProps());r.localStorage.set(c,JSON.stringify(e),function(){})}}()}return g.start=function(){s?function(t){if(!r.localStorage)return t(!1);r.localStorage.get(c).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),a=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(a||0)+f,t=(new Date).getTime();n<=t?h():u=setTimeout(h,n-t)}else 0===Math.floor(4*Math.random())?h():u=setTimeout(h,f)}):(m(Q({kind:"diagnostic-init",id:i,creationDate:v.getProps().dataSinceDate},p())),u=setTimeout(h,f))},g.stop=function(){u&&clearTimeout(u)},g.setStreaming=function(e){d=e},g};function Ne(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}function Le(e,n,t,o,r){var a=t&&t.logger?t.logger:r&&r.logger&&r.logger.default||Ne("warn"),u=function(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&&(o.error?this.emit("error",e):(n||console).error(e.message))},e}(a),f=Ue(t,u,r,a),i=f.sendEvents,s=e,c=f.hash,l=le(o,s,f),v=f.sendEvents&&!f.diagnosticOptOut,d=v?Ie(s):null,g=v?je((new Date).getTime()):null,p=v?Te(o,g,l,s,f,d):null;p&&p.start();var m,h,y,w,b,E,k=De(o,f,s,g),S=f.eventProcessor||function(e,n,t,r,o,i){var a,u=3<arguments.length&&void 0!==r?r:null,s=4<arguments.length&&void 0!==o?o:null,c={},l=(5<arguments.length&&void 0!==i?i:null)||le(e,t,n),f=n.eventsUrl+"/events/bulk/"+t,v=function(){var e={},a=0,u=0,s={};return e.summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=s[n];t?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate)}},e.getSummary=function(){var e={},n=!0;for(var t in s){var r=s[t],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}(),d=fe(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,E=!1,k=!1;function S(){return 0===p||0===Math.floor(Math.random()*p)}function D(e){w.length<m?(w.push(e),k=!1):(k||(k=!0,y.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),u&&u.incrementDroppedEvents())}return c.enqueue=function(e){if(!E){var n=!1,t=!1;if(v.summarizeEvent(e),"feature"===e.kind?S()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>b&&e.debugEventsUntilDate>(new Date).getTime()}(e)):n=S(),n&&D(function(e){var n=se({},e);return g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),t){var r=se({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,D(r)}}},c.flush=function(){if(E)return Promise.resolve();var e=w,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),u&&u.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(ke(e.length)),l.sendEvents(e,f).then(function(e){e&&(e.serverTime&&(b=e.serverTime),te(e.status)||(E=!0),400<=e.status&&ie(function(){s.maybeReportError(new Y(me(e.status,"event posting","some events were dropped")))}))}))},c.start=function(){a=setTimeout(function e(){c.flush(),a=setTimeout(e,h)},h)},c.stop=function(){clearTimeout(a)},c}(o,f,s,g,u,l),D=Pe(o,f,s),P={},O={},U=f.streaming,R=!1,I=!1,j=!0,T=f.stateProvider,N=(b=function(e){T||e&&F({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})},{setUser:function(e){(E=ce(e))&&b&&b(re(E))},getUser:function(){return E?re(E):null}}),L=Oe(o.localStorage,a);function F(e){s&&(T&&T.enqueueEvent&&T.enqueueEvent(e)||(e.user?(j=!1,!i||I||o.isDoNotTrack()||(a.debug(Ee(e.kind)),S.enqueue(e))):j&&(a.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),j=!1)))}function C(e,n,t,r){var o=N.getUser(),i=new Date,a=n?n.value:null;if(!f.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=P[u];if(s&&i-s<3e5)return;P[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=O[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),F(c)}function x(e,n,t,r){var o;if(O&&O.hasOwnProperty(e)&&O[e]&&!O[e].deleted){var i=O[e];o=A(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&C(e,o,n,r),o}function A(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function q(){h=!0,N.getUser()&&k.connect(N.getUser(),c,{ping:function(){a.debug("received ping message from stream"),D.fetchFlagSettings(N.getUser(),c).then(function(e){return V(e||{})}).catch(function(e){u.maybeReportError(new ne(ge(e)))})},put:function(e){var n=JSON.parse(e.data);a.debug("received streaming update for all flags"),V(n)},patch:function(e){var n=JSON.parse(e.data),t=O[n.key];if(!t||!t.version||!n.version||t.version<n.version){a.debug(he(n.key));var r={},o=se({},n);delete o.key;var i=A(O[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},J(r)}else a.debug(ye(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!O[n.key]||O[n.key].version<n.version){a.debug(we(n.key));var t={};O[n.key]&&!O[n.key].deleted&&(t[n.key]={previous:O[n.key].value}),O[n.key]={version:n.version,deleted:!0},J(t)}else a.debug(be(n.key))}})}function _(){h&&(k.disconnect(),h=!1)}function V(e){var n={};if(!e)return Promise.resolve();for(var t in O)O.hasOwnProperty(t)&&O[t]&&(e[t]&&!oe(e[t].value,O[t].value)?n[t]={previous:O[t].value,current:A(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:O[t].value}));for(var r in e)e.hasOwnProperty(r)&&e[r]&&(!O[r]||O[r].deleted)&&(n[r]={current:A(e[r])});return O=Q({},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;u.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),u.emit("change",i),u.emit("internal-change",O),f.sendEventsOnlyForVariation||T||e.forEach(function(e){C(e,o[e].current)})}return m&&w?w.saveFlags(O).catch(function(){return null}):Promise.resolve()}function z(){var e=U||y&&void 0===U;e&&!h?q():!e&&h&&_(),p&&p.setStreaming(e)}function M(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}o.localStorage&&(w=new Se(o.localStorage,s,c,N,a));var $=new Promise(function(e){var n=u.on("ready",function(){u.off("ready",n),e()})}),H=new Promise(function(e,n){var t=u.on("initialized",function(){u.off("initialized",t),e()}),r=u.on("failed",function(e){u.off("failed",r),n(e)})});if("string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(w?m=!0:a.warn("localStorage is unavailable")),"object"===W(f.bootstrap)&&(O=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&a.warn(pe()),!1===t.$valid&&a.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var o={};return e.forEach(function(e){if("$flagsState"!==e&&"$valid"!==e){var n={value:t[e]};r&&r[e]?n=se(n,r[e]):n.version=0,o[e]=n}}),o}(f.bootstrap)),T){var K=T.getInitialState();K?B(K):T.on("init",B),T.on("update",function(e){e.user&&N.setUser(e.user),e.flags&&V(e.flags)})}else(e?L.validateUser(n).then(function(e){return N.setUser(e),"object"===W(f.bootstrap)?G():m?w.loadFlags().catch(function(){return null}).then(function(e){return null==e?(O={},D.fetchFlagSettings(N.getUser(),c).then(function(e){return V(e||{})}).then(G).catch(function(e){X(new ne(ge(e)))})):(O=e,ie(G),D.fetchFlagSettings(N.getUser(),c).then(function(e){return V(e)}).catch(function(e){return u.maybeReportError(e)}))}):D.fetchFlagSettings(N.getUser(),c).then(function(e){O=e||{},G()}).catch(function(e){O={},X(e)})}):Promise.reject(new Z(de()))).catch(function(e){return u.maybeReportError(e)});function B(e){s=e.environment,N.setUser(e.user),O=Q({},e.flags),ie(G)}function G(){a.info("LaunchDarkly client initialized"),R=!0,z(),u.emit("ready"),u.emit("initialized")}function X(e){u.maybeReportError(e),u.emit("failed",e),u.emit("ready")}return{client:{waitForInitialization:function(){return H},waitUntilReady:function(){return $},identify:function(e,r,n){return I?ae(Promise.resolve({}),n):T?(a.warn("identify() has no effect here; it must be called on the main client instance"),ae(Promise.resolve(ue(O)),n)):ae((m&&w?w.clearFlags():Promise.resolve()).then(function(){return L.validateUser(e)}).then(function(t){return D.fetchFlagSettings(t,r).then(function(e){var n=ue(e);return N.setUser(t),c=r,e?V(e).then(function(){return n}):n})}).then(function(e){return h&&q(),e}).catch(function(e){return u.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return N.getUser()},variation:function(e,n){return x(e,n,!0,!1).value},variationDetail:function(e,n){return x(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&a.warn(ve(e));var r={kind:"custom",key:e,user:N.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),F(r)}else u.maybeReportError(new ee(ve(e)))},on:function(e,n,t){M(e)?(y=!0,R&&z(),u.on(e,n,t)):u.on.apply(u,arguments)},off:function(e){if(u.off.apply(u,arguments),M(e)){var n=!1;u.getEvents().forEach(function(e){M(e)&&0<u.getEventListenerCount(e)&&(n=!0)}),n||(y=!1,h&&void 0===U&&_())}},setStreaming:function(e){var n=null===e?void 0:e;n!==U&&(U=n,z())},flush:function(e){return ae(i?S.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!O)return e;for(var n in O)O.hasOwnProperty(n)&&(e[n]=x(n,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){if(I)return ae(Promise.resolve(),e);function n(){I=!0,O={}}return ae(Promise.resolve().then(function(){if(_(),p&&p.stop(),i)return S.stop(),S.flush()}).then(n).catch(n),e)}},options:f,emitter:u,ident:N,logger:a,requestor:D,start:function(){i&&(p&&p.start(),S.start())},enqueueEvent:F,getFlagsInternal:function(){return O},getEnvironmentId:function(){return s},internalChangeEventName:"internal-change"}}function Fe(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 Ce(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Fe(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)):Fe(i).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}var xe={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Ae(e,n,t,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}())return xe;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),xe;var u;return{promise:new Promise(function(e,n){i.addEventListener("load",function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})}),i.addEventListener("error",function(){u||n(new Error)}),i.send(r)}),cancel:function(){u=!0,i.abort()}}}var qe=/[|\\{}()[\]^$+*?.]/g,_e=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(qe,"\\$&")};function Ve(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+_e(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+_e(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+_e(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Je(e,r){for(var n={},t=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(Ve(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?r("pageview",a):(o.push(a),r("click_pageview",a));break}return 0<o.length&&(t=function(e){for(var n=function(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&0<u.length;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}(e,o),t=0;t<n.length;t++)r("click",n[t])},document.addEventListener("click",t)),n.dispose=function(){document.removeEventListener("click",t)},n}var ze=300;function Me(r,n){var t,o,e={};function i(){o&&o.dispose(),t&&t.length&&(o=Je(t,a))}function a(e,n){var t={kind:e,key:n.key,data:null,url:window.location.href,user:r.ident.getUser(),creationDate:(new Date).getTime()};return"click"===e&&(t.selector=n.selector),r.enqueueEvent(t)}function u(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}return e.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},r.requestor.fetchJSON("/sdk/goals/"+r.getEnvironmentId()).then(function(e){e&&0<e.length&&(o=Je(t=e,a),u(ze,i)),n()}).catch(function(e){r.emitter.maybeReportError(new s.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),e}var $e="goalsReady",He={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"}};function Ke(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var n,i={synchronousFlush:!1};window.XMLHttpRequest&&(i.httpRequest=function(e,n,t,r){var o=i.synchronousFlush;return i.synchronousFlush=!1,Ae(e,n,t,r,o)}),i.httpAllowsPost=function(){return void 0===n&&(n=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),n},i.httpFallbackPing=function(e){(new window.Image).src=e};var r,t=e&&e.eventUrlTransformer;i.getCurrentUrl=function(){return t?t(window.location.href):window.location.href},i.isDoNotTrack=function(){var e;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(i.localStorage={get:function(n){return new Promise(function(e){e(window.localStorage.getItem(n))})},set:function(n,t){return new Promise(function(e){window.localStorage.setItem(n,t),e()})},clear:function(n){return new Promise(function(e){window.localStorage.removeItem(n),e()})}})}catch(e){i.localStorage=null}var o=e&&e.useReport;if(r=o&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(i.eventSourceAllowsReport=!0,window.EventSourcePolyfill):(i.eventSourceAllowsReport=!1,window.EventSource),window.EventSource){i.eventSourceFactory=function(e,n){var t=Ce({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},{},n);return new r(e,t)},i.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return i.userAgent="JSClient",i.version="2.17.0",i.diagnosticSdkData={name:"js-client-sdk",version:"2.17.0"},i.diagnosticPlatformData={name:"JS"},i.diagnosticUseCombinedEvent=!0,i}(t),o=Le(e,n,t,r,He),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on($e,function(){u.off($e,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=Me(o,function(){return u.emit($e)});r.customEventFilter=c.goalKeyExists}else u.emit($e);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function l(){r.synchronousFlush=!0,i.flush().catch(function(){}),r.synchronousFlush=!1}return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var Be=Ne;var Ge={initialize:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(G.deprecated("default export","named LDClient export")),Ke(e,n,t)},version:"2.17.0"};e.createConsoleLogger=Be,e.default=Ge,e.initialize=Ke,e.version="2.17.0",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).LDClient={})}(this,function(e){"use strict";function X(e){return(X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,r)}return t}function W(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 Q=t("LaunchDarklyUnexpectedResponseError"),Y=t("LaunchDarklyInvalidEnvironmentIdError"),a=t("LaunchDarklyInvalidUserError"),Z=t("LaunchDarklyInvalidEventKeyError"),d=t("LaunchDarklyInvalidArgumentError"),ee=t("LaunchDarklyFlagFetchError");function ne(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var s=Object.freeze({__proto__:null,LDUnexpectedResponseError:Q,LDInvalidEnvironmentIdError:Y,LDInvalidUserError:a,LDInvalidEventKeyError:Z,LDInvalidArgumentError:d,LDFlagFetchError:ee,isHttpErrorRecoverable:ne}),r=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));return 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]+"=")),o.join("")},u=[],o=[],i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=i.length;c<l;++c)u[c]=i[c],o[i.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("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63;var g=Array.isArray,p=Object.keys,m=Object.prototype.hasOwnProperty,v=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function h(e){var n=unescape(encodeURIComponent(e));return r(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function P(e){return h(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function te(e){return JSON.parse(JSON.stringify(e))}function re(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=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}(e,n)}function oe(e){setTimeout(e,0)}function ie(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function y(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]={value:e[t],version:0});return n}function ae(e){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t].value);return n}function w(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-=P(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function b(e){var n=e.version||"3.2.3";return e.userAgent+"/"+n}function D(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":b(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function ue(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce(function(e,n){return W({},e,{},n)},{})}function se(e){if(!e)return e;var n;for(var t in v){var r=v[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||W({},e))[r]=String(o))}return n||e}Object.freeze({__proto__:null,btoa:h,base64URLEncode:P,clone:te,deepEquals:re,onNextTick:oe,wrapPromiseCallback:ie,transformValuesToVersionedValues:y,transformVersionedValuesToValues:ae,chunkUserEventsForUrl:w,getLDUserAgentString:b,getLDHeaders:D,extend:ue,sanitizeUser:se});for(var k,E=(k=void 0,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}}}(k={exports:{}}),k.exports),S=[],O=0;O<256;++O)S[O]=(O+256).toString(16).substr(1);var U,I,R=0,j=0,T=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||U,a=void 0!==e.clockseq?e.clockseq:I;if(null==i||null==a){var u=E();null==i&&(i=U=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=I=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:j+1,l=s-R+(c-j)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||R<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");R=s,I=a;var f=(1e4*(268435455&(s+=122192928e5))+(j=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||function(e,n){var t=n||0,r=S;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("")}(o)};function ce(u,e,n){var t="/a/"+e+".gif",s=ue({"Content-Type":"application/json"},D(u,n)),c=u.httpFallbackPing,l={sendChunk:function(e,r,o,n){var i=JSON.stringify(e),a=o?null:T();return n?function n(t){var e=o?s:ue({},s,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,e,i).promise.then(function(e){if(e)return 400<=e.status&&ne(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(r+t+"?d="+P(i)),Promise.resolve())},sendEvents:function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,o=u.httpAllowsPost();r=o?[e]:w(2e3-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(l.sendChunk(r[a],n,t,o));return Promise.all(i)}};return l}function le(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(o,i){return Object.keys(o).reduce(function(e,n){var t,r=e;return i(n)&&(l[t=n]||!s&&-1===a.indexOf(t)&&-1===c.indexOf(t)?r[0][n]=o[n]:r[1][n]=!0),r},[{},{}])}var a=e.privateAttributeNames||[],t=n(e,function(e){return f[e]}),r=t[0],o=t[1];if(e.custom){var i=n(e.custom,function(){return!0});r.custom=i[0],o=ue({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function N(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var L=" Please see https://docs.launchdarkly.com/docs/js-sdk-reference#section-initializing-the-client for instructions on SDK initialization.",F=function(e){return'Expected application/json content type but got "'+e+'"'},C=function(e){return"network error"+(e?" ("+e+")":"")},fe=function(e){return'Custom event "'+e+'" does not exist'},x=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+L},ve=function(){return"No environment/client-side ID was specified."+L},de=function(e){return"Error fetching flag settings: "+N(e)},A=function(){return"No user specified."+L},q=function(){return"Invalid user specified."+L},ge=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+L},_=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+" - "+(ne(e)?t:"giving up permanently")},V=function(){return"Cannot make HTTP requests in this environment."+L},J=function(e){return"Opening stream connection to "+e},z=function(e,n){return"Error on stream connection: "+N(e)+", will continue retrying every "+n+" milliseconds."},M=function(e){return'Ignoring unknown config option "'+e+'"'},$=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},H=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},K=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},B=function(e){return"polling for feature flags at "+e},me=function(e){return'received streaming update for flag "'+e+'"'},he=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},ye=function(e){return'received streaming deletion for flag "'+e+'"'},we=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},be=function(e){return'enqueueing "'+e+'" event'},ke=function(e){return"sending "+e+" events"},G=Object.freeze({__proto__:null,clientInitialized:function(){return"LaunchDarkly client initialized"},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:F,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:C,unknownCustomEventKey:fe,environmentNotFound:x,environmentNotSpecified:ve,errorFetchingFlags:de,userNotSpecified:A,invalidUser:q,bootstrapOldFormat:ge,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:_,httpErrorMessage:pe,httpUnavailable:V,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:J,streamError:z,unknownOption:M,wrongOptionType:$,wrongOptionTypeBoolean:H,optionBelowMinimum:K,debugPolling:B,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:me,debugStreamPatchIgnored:he,debugStreamDelete:ye,debugStreamDeleteIgnored:we,debugEnqueueingEvent:be,debugPostingEvents:ke,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});var Ee=function(r){var n=!1,t=!1,o=null,e=null,i=new Promise(function(n){r.on("ready",function e(){r.off("ready",e),n()})}).catch(function(){});return{getInitializationPromise:function(){return e||(n?Promise.resolve():t?Promise.reject(o):e=new Promise(function(n,t){r.on("initialized",function e(){r.off("initialized",e),n()}),r.on("failed",function e(n){r.off("failed",e),t(n)})}))},getReadyPromise:function(){return i},signalSuccess:function(){n||t||(n=!0,r.emit("initialized"),r.emit("ready"))},signalFailure:function(e){n||t||(t=!0,o=e,r.emit("failed",e),r.emit("ready")),r.maybeReportError(e)}}};function Se(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=y(n):delete n.$schema}return n}catch(e){return u.clearFlags().then(function(){return Promise.reject(e)})}}).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.saveFlags=function(e){var n=ue({},e,{$schema:1});return t.set(s(),JSON.stringify(n)).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u.clearFlags=function(){return t.clear(s()).catch(function(e){return a.warn("localStorage is unavailable"),Promise.reject(e)})},u}function Pe(o,e,i,n){var a,u=e.streamUrl,s=e.logger,t={},c=u+"/eval/"+i,l=e.useReport,f=e.evaluationReasons,r=e.streamReconnectDelay,v=D(o,e),d=!1,g=null,p=null,m=null,h=null,y=null;function w(e){d||(s.warn(z(e,r)),d=!0),S(!1),E(),b(r)}function b(e){p||(e?p=setTimeout(k,e):k())}function k(){var e;p=null;var n="",t={headers:v};if(o.eventSourceFactory){for(var r in null!=h&&(n="h="+h),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+"/"+P(JSON.stringify(m)),f&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,E(),s.info(J(e)),a=(new Date).getTime(),g=o.eventSourceFactory(e,t),y)y.hasOwnProperty(r)&&g.addEventListener(r,y[r]);g.onerror=w}}function E(){g&&(s.info("Closing stream connection"),g.close(),g=null)}function S(e){a&&n&&n.recordStreamInit(a,!e,(new Date).getTime()-a),a=null}return t.connect=function(e,n,t){m=e,h=n,y={};function r(n){y[n]=function(e){S(!(d=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);b()},t.disconnect=function(){clearTimeout(p),p=null,E()},t.isConnected=function(){return!!(g&&o.eventSourceIsActive&&o.eventSourceIsActive(g))},t}function De(d,g,a){var u=g.baseUrl,s=g.useReport,c=g.evaluationReasons,l=g.logger,e={},p={};function f(e,n){if(!d.httpRequest)return new Promise(function(e,n){n(new ee(V()))});var t=n?"REPORT":"GET",r=D(d,g);n&&(r["Content-Type"]="application/json");var o,i,a,u,s,c,l=p[e];l||(o=function(){delete p[e]},(c={addPromise:function(n,e){i=n,a&&a(),a=e,n.then(function(e){i===n&&(u(e),o())},function(e){i===n&&(s(e),o())})}}).resultPromise=new Promise(function(e,n){u=e,s=n}),l=c,p[e]=l);var f=d.httpRequest(t,e,r,n),v=f.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new Y(x()):new ee(de(n.statusText||String(n.status))));if(e.header("content-type")&&0===e.header("content-type").lastIndexOf("application/json"))return JSON.parse(e.body);var n,t=F(e.header("content-type")||"");return Promise.reject(new ee(t))},function(e){return Promise.reject(new ee(C(e)))});return l.addPromise(v,function(){f.cancel&&f.cancel()}),l.resultPromise}return e.fetchJSON=function(e){return f(u+e,null)},e.fetchFlagSettings=function(e,n){var t,r,o,i="";return s?(r=[u,"/sdk/evalx/",a,"/user"].join(""),o=JSON.stringify(e)):(t=P(JSON.stringify(e)),r=[u,"/sdk/evalx/",a,"/users/",t].join("")),n&&(i="h="+n),c&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,l.debug(B(r)),f(r,o)},e}function Oe(o,i){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new a(A()));var r=te(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?(o?o.get("ld:$anonUserId").catch(function(){return null}):Promise.resolve(null)).then(function(e){if(e)return r.key=e,r;var n,t=T();return r.key=t,(n=t,o?o.set("ld:$anonUserId",n).catch(function(){i.warn("localStorage is unavailable, so anonymous user ID cannot be cached")}):Promise.resolve()).then(function(){return r})}):Promise.reject(new a(q()))},e}var Ue={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"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"}};function Ie(e,n,t,r){var a=ue({logger:{default:r}},Ue,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){oe(function(){n&&n.maybeReportError(new d(e))})}var s,c,i,l,f=ue({},e||{});return l=f,Object.keys(o).forEach(function(e){if(void 0!==l[e]){var n=o[e];r&&r.warn(_(e,n)),n&&(void 0===l[n]&&(l[n]=l[e]),delete l[e])}}),i=ue({},f),Object.keys(a).forEach(function(e){void 0!==i[e]&&null!==i[e]||(i[e]=a[e]&&a[e].default)}),s=f=i,c=ue({},s),Object.keys(s).forEach(function(e){var n=s[e];if(null!=n){var t=a[e];if(void 0===t)u(M(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?(c[e]=!!n,u(H(e,i))):(u($(e,r,i)),c[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(K(e,n,t.minimum)),c[e]=t.minimum)}}}}),c;function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=X(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}}var Re=Object.freeze({__proto__:null,baseOptionDefs:Ue,validate:Ie}).baseOptionDefs,je=function(e){var n={diagnosticId:T()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},Te=function(e){var n,t,r,o;function i(e){n=e,r=t=0,o=[]}return i(e),{getProps:function(){return{dataSinceDate:n,droppedEvents:t,eventsInLastBatch:r,streamInits:o}},setProps:function(e){n=e.dataSinceDate,t=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:function(){t++},setEventsInLastBatch:function(e){r=e},recordStreamInit:function(e,n,t){var r={timestamp:e,failed:n,durationMillis:t};o.push(r)},reset:i}},Ne=function(r,e,n,t,o,i){var a,u,s=!!r.diagnosticUseCombinedEvent,c="ld:"+t+":$diagnostics",l=o.eventsUrl+"/events/diagnostic/"+t,f=o.diagnosticRecordingInterval,v=e,d=!!o.streaming,g={};function p(){return{sdk:function(){var e=W({},r.diagnosticSdkData);return o.wrapperName&&(e.wrapperName=o.wrapperName),o.wrapperVersion&&(e.wrapperVersion=o.wrapperVersion),e}(),configuration:(e={customBaseURI:o.baseUrl!==Re.baseUrl.default,customStreamURI:o.streamUrl!==Re.streamUrl.default,customEventsURI:o.eventsUrl!==Re.eventsUrl.default,eventsCapacity:o.eventCapacity,eventsFlushIntervalMillis:o.flushInterval,reconnectTimeMillis:o.streamReconnectDelay,streamingDisabled:!d,allAttributesPrivate:!!o.allAttributesPrivate,inlineUsersInEvents:!!o.inlineUsersInEvents,diagnosticRecordingIntervalMillis:o.diagnosticRecordingInterval,usingSecureMode:!!o.hash,bootstrapMode:!!o.bootstrap,fetchGoalsDisabled:!o.fetchGoals,allowFrequentDuplicateEvents:!!o.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!o.sendEventsOnlyForVariation},e),platform:r.diagnosticPlatformData};var e}function m(e){o.logger&&o.logger.debug(G.debugPostingDiagnosticEvent(e)),n.sendEvents(e,l,!0).then(function(){}).catch(function(){})}function h(){var e,n;m((e=(new Date).getTime(),n=W({kind:s?"diagnostic-combined":"diagnostic",id:i,creationDate:e},v.getProps()),s&&(n=W({},n,{},p())),v.reset(e),n)),u=setTimeout(h,f),a=(new Date).getTime(),s&&function(){if(r.localStorage){var e=W({},v.getProps());r.localStorage.set(c,JSON.stringify(e),function(){})}}()}return g.start=function(){s?function(t){if(!r.localStorage)return t(!1);r.localStorage.get(c).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),a=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(a||0)+f,t=(new Date).getTime();n<=t?h():u=setTimeout(h,n-t)}else 0===Math.floor(4*Math.random())?h():u=setTimeout(h,f)}):(m(W({kind:"diagnostic-init",id:i,creationDate:v.getProps().dataSinceDate},p())),u=setTimeout(h,f))},g.stop=function(){u&&clearTimeout(u)},g.setStreaming=function(e){d=e},g};function Le(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}function Fe(e,n,t,o,r){var a=t&&t.logger?t.logger:r&&r.logger&&r.logger.default||Le("warn"),u=function(n){var e={},o={};return e.on=function(e,n,t){o[e]=o[e]||[],o[e]=o[e].concat({handler:n,context:t})},e.off=function(e,n,t){if(o[e])for(var r=0;r<o[e].length;r++)o[e][r].handler===n&&o[e][r].context===t&&(o[e]=o[e].slice(0,r).concat(o[e].slice(r+1)))},e.emit=function(e){if(o[e])for(var n=o[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(o)},e.getEventListenerCount=function(e){return o[e]?o[e].length:0},e.maybeReportError=function(e){e&&(o.error?this.emit("error",e):(n||console).error(e.message))},e}(a),i=Ee(u),f=Ie(t,u,r,a),s=f.sendEvents,c=e,l=f.hash,v=ce(o,c,f),d=f.sendEvents&&!f.diagnosticOptOut,g=d?je(c):null,p=d?Te((new Date).getTime()):null,m=d?Ne(o,p,v,c,f,g):null;m&&m.start();var h,y,w,b,k,E,S=Pe(o,f,c,p),P=f.eventProcessor||function(e,n,t,r,o,i){var a,u=3<arguments.length&&void 0!==r?r:null,s=4<arguments.length&&void 0!==o?o:null,c={},l=(5<arguments.length&&void 0!==i?i:null)||ce(e,t,n),f=n.eventsUrl+"/events/bulk/"+t,v=function(){var e={},a=0,u=0,s={};return e.summarizeEvent=function(e){if("feature"===e.kind){var n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),t=s[n];t?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate)}},e.getSummary=function(){var e={},n=!0;for(var t in s){var r=s[t],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}(),d=le(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,k=!1,E=!1;function S(){return 0===p||0===Math.floor(Math.random()*p)}function P(e){w.length<m?(w.push(e),E=!1):(E||(E=!0,y.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),u&&u.incrementDroppedEvents())}return c.enqueue=function(e){if(!k){var n=!1,t=!1;if(v.summarizeEvent(e),"feature"===e.kind?S()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>b&&e.debugEventsUntilDate>(new Date).getTime()}(e)):n=S(),n&&P(function(e){var n=ue({},e);return g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate),n}(e)),t){var r=ue({},e,{kind:"debug"});delete r.trackEvents,delete r.debugEventsUntilDate,delete r.variation,P(r)}}},c.flush=function(){if(k)return Promise.resolve();var e=w,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),u&&u.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(ke(e.length)),l.sendEvents(e,f).then(function(e){e&&(e.serverTime&&(b=e.serverTime),ne(e.status)||(k=!0),400<=e.status&&oe(function(){s.maybeReportError(new Q(pe(e.status,"event posting","some events were dropped")))}))}))},c.start=function(){a=setTimeout(function e(){c.flush(),a=setTimeout(e,h)},h)},c.stop=function(){clearTimeout(a)},c}(o,f,c,p,u,v),D=De(o,f,c),O={},U={},I=f.streaming,R=!1,j=!1,T=!0,N=f.stateProvider,L=(k=function(e){N||e&&C({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})},{setUser:function(e){(E=se(e))&&k&&k(te(E))},getUser:function(){return E?te(E):null}}),F=Oe(o.localStorage,a);function C(e){c&&(N&&N.enqueueEvent&&N.enqueueEvent(e)||(e.user?(T=!1,!s||j||o.isDoNotTrack()||(a.debug(be(e.kind)),P.enqueue(e))):T&&(a.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events"),T=!1)))}function x(e,n,t,r){var o=L.getUser(),i=new Date,a=n?n.value:null;if(!f.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=O[u];if(s&&i-s<3e5)return;O[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},l=U[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),C(c)}function A(e,n,t,r){var o;if(U&&U.hasOwnProperty(e)&&U[e]&&!U[e].deleted){var i=U[e];o=q(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&x(e,o,n,r),o}function q(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function _(){y=!0,L.getUser()&&S.connect(L.getUser(),l,{ping:function(){a.debug("received ping message from stream"),D.fetchFlagSettings(L.getUser(),l).then(function(e){return J(e||{})}).catch(function(e){u.maybeReportError(new ee(de(e)))})},put:function(e){var n=JSON.parse(e.data);a.debug("received streaming update for all flags"),J(n)},patch:function(e){var n=JSON.parse(e.data),t=U[n.key];if(!t||!t.version||!n.version||t.version<n.version){a.debug(me(n.key));var r={},o=ue({},n);delete o.key;var i=q(U[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},z(r)}else a.debug(he(n.key))},delete:function(e){var n=JSON.parse(e.data);if(!U[n.key]||U[n.key].version<n.version){a.debug(ye(n.key));var t={};U[n.key]&&!U[n.key].deleted&&(t[n.key]={previous:U[n.key].value}),U[n.key]={version:n.version,deleted:!0},z(t)}else a.debug(we(n.key))}})}function V(){y&&(S.disconnect(),y=!1)}function J(e){var n={};if(!e)return Promise.resolve();for(var t in U)U.hasOwnProperty(t)&&U[t]&&(e[t]&&!re(e[t].value,U[t].value)?n[t]={previous:U[t].value,current:q(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:U[t].value}));for(var r in e)e.hasOwnProperty(r)&&e[r]&&(!U[r]||U[r].deleted)&&(n[r]={current:q(e[r])});return U=W({},e),z(n).catch(function(){})}function z(o){var e=Object.keys(o);if(0<e.length){var i={};e.forEach(function(e){var n=o[e].current,t=n?n.value:void 0,r=o[e].previous;u.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),u.emit("change",i),u.emit("internal-change",U),f.sendEventsOnlyForVariation||N||e.forEach(function(e){x(e,o[e].current)})}return h&&b?b.saveFlags(U).catch(function(){return null}):Promise.resolve()}function M(){var e=I||w&&void 0===I;e&&!y?_():!e&&y&&V(),m&&m.setStreaming(e)}function $(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if(o.localStorage&&(b=new Se(o.localStorage,c,l,L,a)),"string"==typeof f.bootstrap&&"LOCALSTORAGE"===f.bootstrap.toUpperCase()&&(b?h=!0:a.warn("localStorage is unavailable")),"object"===X(f.bootstrap)&&(U=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&a.warn(ge()),!1===t.$valid&&a.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var o={};return e.forEach(function(e){if("$flagsState"!==e&&"$valid"!==e){var n={value:t[e]};r&&r[e]?n=ue(n,r[e]):n.version=0,o[e]=n}}),o}(f.bootstrap)),N){var H=N.getInitialState();H?K(H):N.on("init",K),N.on("update",function(e){e.user&&L.setUser(e.user),e.flags&&J(e.flags)})}else(e?F.validateUser(n).then(function(e){return L.setUser(e),"object"===X(f.bootstrap)?B():h?b.loadFlags().catch(function(){return null}).then(function(e){return null==e?(U={},D.fetchFlagSettings(L.getUser(),l).then(function(e){return J(e||{})}).then(B).catch(function(e){G(new ee(de(e)))})):(U=e,oe(B),D.fetchFlagSettings(L.getUser(),l).then(function(e){return J(e)}).catch(function(e){return u.maybeReportError(e)}))}):D.fetchFlagSettings(L.getUser(),l).then(function(e){U=e||{},B()}).catch(function(e){U={},G(e)})}):Promise.reject(new Y(ve()))).catch(G);function K(e){c=e.environment,L.setUser(e.user),U=W({},e.flags),oe(B)}function B(){a.info("LaunchDarkly client initialized"),R=!0,M(),i.signalSuccess()}function G(e){i.signalFailure(e)}return{client:{waitForInitialization:function(){return i.getInitializationPromise()},waitUntilReady:function(){return i.getReadyPromise()},identify:function(e,r,n){return j?ie(Promise.resolve({}),n):N?(a.warn("identify() has no effect here; it must be called on the main client instance"),ie(Promise.resolve(ae(U)),n)):ie((h&&b?b.clearFlags():Promise.resolve()).then(function(){return F.validateUser(e)}).then(function(t){return D.fetchFlagSettings(t,r).then(function(e){var n=ae(e);return L.setUser(t),l=r,e?J(e).then(function(){return n}):n})}).then(function(e){return y&&_(),e}).catch(function(e){return u.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return L.getUser()},variation:function(e,n){return A(e,n,!0,!1).value},variationDetail:function(e,n){return A(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){o.customEventFilter&&!o.customEventFilter(e)&&a.warn(fe(e));var r={kind:"custom",key:e,user:L.getUser(),url:o.getCurrentUrl(),creationDate:(new Date).getTime()};null!=n&&(r.data=n),null!=t&&(r.metricValue=t),C(r)}else u.maybeReportError(new Z(fe(e)))},on:function(e,n,t){$(e)?(w=!0,R&&M(),u.on(e,n,t)):u.on.apply(u,arguments)},off:function(e){if(u.off.apply(u,arguments),$(e)){var n=!1;u.getEvents().forEach(function(e){$(e)&&0<u.getEventListenerCount(e)&&(n=!0)}),n||(w=!1,y&&void 0===I&&V())}},setStreaming:function(e){var n=null===e?void 0:e;n!==I&&(I=n,M())},flush:function(e){return ie(s?P.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!U)return e;for(var n in U)U.hasOwnProperty(n)&&(e[n]=A(n,null,!f.sendEventsOnlyForVariation).value);return e},close:function(e){if(j)return ie(Promise.resolve(),e);function n(){j=!0,U={}}return ie(Promise.resolve().then(function(){if(V(),m&&m.stop(),s)return P.stop(),P.flush()}).then(n).catch(n),e)}},options:f,emitter:u,ident:L,logger:a,requestor:D,start:function(){s&&(m&&m.start(),P.start())},enqueueEvent:C,getFlagsInternal:function(){return U},getEnvironmentId:function(){return c},internalChangeEventName:"internal-change"}}function Ce(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 xe(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Ce(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)):Ce(i).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}var Ae={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function qe(e,n,t,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var n=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(n)return parseInt(n[2],10)<73}return!0}())return Ae;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})t.hasOwnProperty(a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),Ae;var u;return{promise:new Promise(function(e,n){i.addEventListener("load",function(){u||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})}),i.addEventListener("error",function(){u||n(new Error)}),i.send(r)}),cancel:function(){u=!0,i.abort()}}}var _e=/[|\\{}()[\]^$+*?.]/g,Ve=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(_e,"\\$&")};function Je(e,n,t,r){var o,i,a=n.replace(t,"").replace(r,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+Ve(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+Ve(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+Ve(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function ze(e,r){for(var n={},t=null,o=[],i=0;i<e.length;i++)for(var a=e[i],u=a.urls||[],s=0;s<u.length;s++)if(Je(u[s],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?r("pageview",a):(o.push(a),r("click_pageview",a));break}return 0<o.length&&(t=function(e){for(var n=function(e,n){for(var t=[],r=0;r<n.length;r++)for(var o=e.target,i=n[r],a=i.selector,u=document.querySelectorAll(a);o&&0<u.length;){for(var s=0;s<u.length;s++)o===u[s]&&t.push(i);o=o.parentNode}return t}(e,o),t=0;t<n.length;t++)r("click",n[t])},document.addEventListener("click",t)),n.dispose=function(){document.removeEventListener("click",t)},n}var Me=300;function $e(r,n){var t,o,e={};function i(){o&&o.dispose(),t&&t.length&&(o=ze(t,a))}function a(e,n){var t={kind:e,key:n.key,data:null,url:window.location.href,user:r.ident.getUser(),creationDate:(new Date).getTime()};return"click"===e&&(t.selector=n.selector),r.enqueueEvent(t)}function u(e,n){var t,r=window.location.href;function o(){(t=window.location.href)!==r&&(r=t,n())}!function e(n,t){n(),setTimeout(function(){e(n,t)},t)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}return e.goalKeyExists=function(e){if(!t)return!0;for(var n=0;n<t.length;n++)if("custom"===t[n].kind&&t[n].key===e)return!0;return!1},r.requestor.fetchJSON("/sdk/goals/"+r.getEnvironmentId()).then(function(e){e&&0<e.length&&(o=ze(t=e,a),u(Me,i)),n()}).catch(function(e){r.emitter.maybeReportError(new s.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),e}var He="goalsReady",Ke={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"}};function Be(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var n,i={synchronousFlush:!1};window.XMLHttpRequest&&(i.httpRequest=function(e,n,t,r){var o=i.synchronousFlush;return i.synchronousFlush=!1,qe(e,n,t,r,o)}),i.httpAllowsPost=function(){return void 0===n&&(n=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),n},i.httpFallbackPing=function(e){(new window.Image).src=e};var r,t=e&&e.eventUrlTransformer;i.getCurrentUrl=function(){return t?t(window.location.href):window.location.href},i.isDoNotTrack=function(){var e;return 1===(e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack)||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(i.localStorage={get:function(n){return new Promise(function(e){e(window.localStorage.getItem(n))})},set:function(n,t){return new Promise(function(e){window.localStorage.setItem(n,t),e()})},clear:function(n){return new Promise(function(e){window.localStorage.removeItem(n),e()})}})}catch(e){i.localStorage=null}var o=e&&e.useReport;if(r=o&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(i.eventSourceAllowsReport=!0,window.EventSourcePolyfill):(i.eventSourceAllowsReport=!1,window.EventSource),window.EventSource){i.eventSourceFactory=function(e,n){var t=xe({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0},{},n);return new r(e,t)},i.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return i.userAgent="JSClient",i.version="2.17.1",i.diagnosticSdkData={name:"js-client-sdk",version:"2.17.1"},i.diagnosticPlatformData={name:"JS"},i.diagnosticUseCombinedEvent=!0,i}(t),o=Fe(e,n,t,r,Ke),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(He,function(){u.off(He,n),e()})});if(i.waitUntilGoalsReady=function(){return s},a.fetchGoals){var c=$e(o,function(){return u.emit(He)});r.customEventFilter=c.goalKeyExists}else u.emit(He);"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function l(){r.synchronousFlush=!0,i.flush().catch(function(){}),r.synchronousFlush=!1}return window.addEventListener("beforeunload",l),window.addEventListener("unload",l),i}var Ge=Le;var Xe={initialize:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(G.deprecated("default export","named LDClient export")),Be(e,n,t)},version:"2.17.1"};e.createConsoleLogger=Ge,e.default=Xe,e.initialize=Be,e.version="2.17.1",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=ldclient.min.js.map |
{ | ||
"name": "launchdarkly-js-client-sdk", | ||
"version": "2.17.0", | ||
"version": "2.17.1", | ||
"description": "LaunchDarkly SDK for JavaScript", | ||
@@ -56,8 +56,8 @@ "author": "LaunchDarkly <team@launchdarkly.com>", | ||
"cross-env": "5.1.4", | ||
"eslint": "4.19.1", | ||
"eslint-config-prettier": "2.9.0", | ||
"eslint-config-xo": "0.20.1", | ||
"eslint-formatter-pretty": "1.3.0", | ||
"eslint-plugin-babel": "5.0.0", | ||
"eslint-plugin-prettier": "2.6.0", | ||
"eslint": "^4.19.1", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-config-xo": "^0.20.1", | ||
"eslint-formatter-pretty": "^1.3.0", | ||
"eslint-plugin-babel": "^5.0.0", | ||
"eslint-plugin-prettier": "^2.6.0", | ||
"jest": "^24.9.0", | ||
@@ -84,3 +84,3 @@ "jest-junit": "^9.0.0", | ||
"escape-string-regexp": "^1.0.5", | ||
"launchdarkly-js-sdk-common": "3.2.2" | ||
"launchdarkly-js-sdk-common": "3.2.3" | ||
}, | ||
@@ -87,0 +87,0 @@ "repository": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
456159
542
+ Addedlaunchdarkly-js-sdk-common@3.2.3(transitive)
- Removedlaunchdarkly-js-sdk-common@3.2.2(transitive)