launchdarkly-js-client-sdk
Advanced tools
Comparing version 2.20.2 to 2.21.0
@@ -5,2 +5,6 @@ # Change log | ||
## [2.20.2] - 2022-02-18 | ||
### Fixed: | ||
- If the SDK receives invalid JSON data from a streaming connection (possibly as a result of the connection being cut off), it now uses its regular error-handling logic: the error is emitted as an `error` event or, if there are no `error` event listeners, it is logged. Previously, the error would be thrown as an unhandled exception. | ||
## [2.20.1] - 2022-02-02 | ||
@@ -7,0 +11,0 @@ ### Fixed: |
@@ -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){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}Object.defineProperty(exports,"__esModule",{value:!0});var a=o("LaunchDarklyUnexpectedResponseError"),u=o("LaunchDarklyInvalidEnvironmentIdError"),s=o("LaunchDarklyInvalidUserError"),c=o("LaunchDarklyInvalidEventKeyError"),l=o("LaunchDarklyInvalidArgumentError"),f=o("LaunchDarklyFlagFetchError"),v=o("LaunchDarklyInvalidDataError");function d(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var g=Object.freeze({__proto__:null,LDUnexpectedResponseError:a,LDInvalidEnvironmentIdError:u,LDInvalidUserError:s,LDInvalidEventKeyError:c,LDInvalidArgumentError:l,LDFlagFetchError:f,LDInvalidDataError:v,isHttpErrorRecoverable:d}),p=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(E(e,i,a<i+16383?a:i+16383));return 1==r?(n=e[t-1],o.push(m[n>>2]+m[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(m[n>>10]+m[n>>4&63]+m[n<<2&63]+"=")),o.join("")},m=[],y=[],h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b=0,k=h.length;b<k;++b)m[b]=h[b],y[h.charCodeAt(b)]=b;function E(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(m[(o=r)>>18&63]+m[o>>12&63]+m[o>>6&63]+m[63&o]);return i.join("")}y["-".charCodeAt(0)]=62,y["_".charCodeAt(0)]=63;var w=Array.isArray,D=Object.keys,O=Object.prototype.hasOwnProperty,P=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function S(e){var n=unescape(encodeURIComponent(e));return p(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function U(e){return S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function I(e){return JSON.parse(JSON.stringify(e))}function j(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=w(n),u=w(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=D(n);if((o=d.length)!==D(t).length)return!1;for(r=o;0!=r--;)if(!O.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 R(e){setTimeout(e,0)}function T(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function L(e){var n={};for(var t in e)V(e,t)&&(n[t]={value:e[t],version:0});return n}function F(e){var n={};for(var t in e)V(e,t)&&(n[t]=e[t].value);return n}function N(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=U(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function A(e){var n=e.version||"3.5.1";return e.userAgent+"/"+n}function C(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":A(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function x(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(r({},e)):e}function q(){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 V(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function _(e){if(!e)return e;var n;for(var t in P){var o=P[t],i=e[o];void 0!==i&&"string"!=typeof i&&((n=n||r({},e))[o]=String(i))}return n||e}for(var z=Object.freeze({__proto__:null,btoa:S,base64URLEncode:U,clone:I,deepEquals:j,onNextTick:R,wrapPromiseCallback:T,transformValuesToVersionedValues:L,transformVersionedValuesToValues:F,chunkUserEventsForUrl:N,getLDUserAgentString:A,getLDHeaders:C,transformHeaders:x,extend:q,objectHasOwnProperty:V,sanitizeUser:_}),J=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}(),M=[],K=0;K<256;++K)M[K]=(K+256).toString(16).substr(1);var H,B,$=function(e,n){var t=n||0,r=M;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},G=0,X=0,W=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||H,a=void 0!==e.clockseq?e.clockseq:B;if(null==i||null==a){var u=J();null==i&&(i=H=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=B=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:X+1,l=s-G+(c-X)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||G<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");G=s,B=a;var f=(1e4*(268435455&(s+=122192928e5))+(X=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||$(o)};function Q(u,e,s){var t="/a/"+e+".gif",c=q({"Content-Type":"application/json"},C(u,s)),l=u.httpFallbackPing,f={sendChunk:function(e,r,o,n){var i=JSON.stringify(e),a=o?null:W();return n?function n(t){var e=o?c:q({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,x(e,s),i).promise.then(function(e){if(e)return 400<=e.status&&d(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(r+t+"?d="+U(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(f.sendChunk(r[a],n,t,o));return Promise.all(i)}};return f}function Y(){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 Z(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=q({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function ee(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var ne=function(){return"LaunchDarkly client initialized"},te=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",re=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},ie=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},oe=function(e){return'Expected application/json content type but got "'+e+'"'},ae=function(e){return"local storage is unavailable: "+ee(e)},ue=function(e){return"network error"+(e?" ("+e+")":"")},se=function(e){return'Custom event "'+e+'" does not exist'},ce=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+te},le=function(){return"No environment/client-side ID was specified."+te},fe=function(e){return"Error fetching flag settings: "+ee(e)},ve=function(){return"No user specified."+te},de=function(){return"Invalid user specified."+te},ge=function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},pe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+te},me=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},ye=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},he=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(d(e)?t:"giving up permanently")},be=function(){return"Cannot make HTTP requests in this environment."+te},ke=function(){return"identify() has no effect here; it must be called on the main client instance"},Ee=function(){return"Closing stream connection"},we=function(e){return"Opening stream connection to "+e},De=function(e,n){return"Error on stream connection: "+ee(e)+", will continue retrying every "+n+" milliseconds."},Oe=function(e){return'Ignoring unknown config option "'+e+'"'},Pe=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Se=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Ue=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Ie=function(e){return"polling for feature flags at "+e},je=function(){return"received ping message from stream"},Re=function(){return"received streaming update for all flags"},Te=function(e){return'received streaming update for flag "'+e+'"'},Le=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Fe=function(e){return'received streaming deletion for flag "'+e+'"'},Ne=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Ae=function(e){return'enqueueing "'+e+'" event'},Ce=function(e){return"sending "+e+" events"},xe=Object.freeze({__proto__:null,clientInitialized:ne,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:re,eventWithoutUser:ie,invalidContentType:oe,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ae,networkError:ue,unknownCustomEventKey:se,environmentNotFound:ce,environmentNotSpecified:le,errorFetchingFlags:fe,userNotSpecified:ve,invalidUser:de,invalidData:ge,bootstrapOldFormat:pe,bootstrapInvalid:me,deprecated:ye,httpErrorMessage:he,httpUnavailable:be,identifyDisabled:ke,streamClosing:Ee,streamConnecting:we,streamError:De,unknownOption:Oe,wrongOptionType:Pe,wrongOptionTypeBoolean:Se,optionBelowMinimum:Ue,debugPolling:Ie,debugStreamPing:je,debugStreamPut:Re,debugStreamPatch:Te,debugStreamPatchIgnored:Le,debugStreamDelete:Fe,debugStreamDeleteIgnored:Ne,debugEnqueueingEvent:Ae,debugPostingEvents:Ce,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function qe(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 Ve=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 _e(t,r,o,i){var a={};function u(){var e="",n=i.getUser();return n&&(e=o||S(JSON.stringify(n))),"ld:"+r+":"+e}return a.loadFlags=function(){return t.get(u()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=L(n):delete n.$schema}return n}catch(e){return a.clearFlags().then(function(){return null})}})},a.saveFlags=function(e){var n=q({},e,{$schema:1});return t.set(u(),JSON.stringify(n))},a.clearFlags=function(){return t.clear(u())},a}function ze(o,i,a,n){var u,s=i.streamUrl,c=i.logger,e={},l=s+"/eval/"+a,f=i.useReport,d=i.evaluationReasons,t=i.streamReconnectDelay,v=C(o,i),g=!1,p=null,m=null,h=null,y=null,w=null;function b(e){g||(c.warn(De(e,t)),g=!0),S(!1),E(),k(t)}function k(e){m||(e?m=setTimeout(r,e):r())}function r(){var e;m=null;var n="",t={headers:v,readTimeoutMillis:3e5};if(o.eventSourceFactory){for(var r in null!=y&&(n="h="+y),f?o.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(h)):(e=s+"/ping/"+a,n=""):e=l+"/"+U(JSON.stringify(h)),t.headers=x(t.headers,i),d&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,E(),c.info(we(e)),u=(new Date).getTime(),p=o.eventSourceFactory(e,t),w)V(w,r)&&p.addEventListener(r,w[r]);p.onerror=b}}function E(){p&&(c.info("Closing stream connection"),p.close(),p=null)}function S(e){u&&n&&n.recordStreamInit(u,!e,(new Date).getTime()-u),u=null}return e.connect=function(e,n,t){h=e,y=n,w={};function r(n){w[n]=function(e){S(!(g=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);k()},e.disconnect=function(){clearTimeout(m),m=null,E()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function Je(p,m,a){var s=m.baseUrl,c=m.useReport,l=m.evaluationReasons,d=m.logger,e={},h={};function v(e,n){if(!p.httpRequest)return new Promise(function(e,n){n(new f(be()))});var t=n?"REPORT":"GET",r=C(p,m);n&&(r["Content-Type"]="application/json");var o,i,a,s,c,l,d=h[e];d||(o=function(){delete h[e]},(l={addPromise:function(n,e){i=n,a&&a(),a=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=l,h[e]=d);var v=p.httpRequest(t,e,x(r,m),n),g=v.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new u(ce()):new f(fe(n.statusText||String(n.status))));if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n,t=oe(e.header("content-type")||"");return Promise.reject(new f(t))},function(e){return Promise.reject(new f(ue(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/",a,"/user"].join(""),o=JSON.stringify(e)):(t=U(JSON.stringify(e)),r=[s,"/sdk/evalx/",a,"/users/",t].join("")),n&&(i="h="+n),l&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,d.debug(Ie(r)),v(r,o)},e}function Me(o){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new s(ve()));var r=I(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?o.get("ld:$anonUserId").then(function(e){if(e)return r.key=e,r;var n,t=W();return r.key=t,(n=t,o.set("ld:$anonUserId",n)).then(function(){return r})}):Promise.reject(new s(de()))},e}var Ke=["debug","info","warn","error","none"];function He(e,u){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var s=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],c=!(!e||!e.destination),l=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",r=1;if(e&&e.level)for(var t=0;t<Ke.length;t++)Ke[t]===e.level&&(r=t);for(var o={},a=function(e){var n=Ke[e];if("none"!==n)if(e<r)o[n]=function(){};else{var t=e;o[n]=function(){!function(e,n,t){if(!(t.length<1)){var r,o=c?n+": "+l:l;if(1!==t.length&&u){var a=i(t);a[0]=o+a[0],r=u.apply(void 0,i(a))}else r=o+t[0];try{s[e](r)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}(t,n,arguments)}}},f=0;f<Ke.length;f++)a(f);return o}function Be(e,n){return He({level:e,prefix:n})}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},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function Ge(n,t,r,o){var a=q({logger:{default:o}},$e,r),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){R(function(){t&&t.maybeReportError(new l(e))})}var s,c,f,d,v,g=q({},n||{});return v=g,Object.keys(i).forEach(function(e){if(void 0!==v[e]){var n=i[e];o&&o.warn(ye(e,n)),n&&(void 0===v[n]&&(v[n]=v[e]),delete v[e])}}),s=(d=q({},g),Object.keys(a).forEach(function(e){void 0!==d[e]&&null!==d[e]||(d[e]=a[e]&&a[e].default)}),c=g=d,f=q({},c),Object.keys(c).forEach(function(e){var n=c[e];if(null!=n){var t=a[e];if(void 0===t)u(Oe(e));else{var r=t.type||p(t.default);if("any"!==r){var o=r.split("|"),i=p(n);o.indexOf(i)<0?"boolean"===r?(f[e]=!!n,u(Se(e,i))):(u(Pe(e,r,i)),f[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(Ue(e,n,t.minimum)),f[e]=t.minimum)}}}}),g=f).logger,Ke.forEach(function(e){if("none"!==e&&(!s[e]||"function"!=typeof s[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")}),g;function p(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 Xe=Object.freeze({__proto__:null,baseOptionDefs:$e,validate:Ge}).baseOptionDefs,We=function(e){var n={diagnosticId:W()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},Qe=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}},Ye=function(n,o,e,t,i,a,u){var s,c,l=!!n.diagnosticUseCombinedEvent,f="ld:"+i+":$diagnostics",d=a.eventsUrl+"/events/diagnostic/"+i,v=a.diagnosticRecordingInterval,g=e,p=!!a.streaming,m={};function h(){return{sdk:function(){var e=r({},n.diagnosticSdkData);return a.wrapperName&&(e.wrapperName=a.wrapperName),a.wrapperVersion&&(e.wrapperVersion=a.wrapperVersion),e}(),configuration:(e={customBaseURI:a.baseUrl!==Xe.baseUrl.default,customStreamURI:a.streamUrl!==Xe.streamUrl.default,customEventsURI:a.eventsUrl!==Xe.eventsUrl.default,eventsCapacity:a.eventCapacity,eventsFlushIntervalMillis:a.flushInterval,reconnectTimeMillis:a.streamReconnectDelay,streamingDisabled:!p,allAttributesPrivate:!!a.allAttributesPrivate,inlineUsersInEvents:!!a.inlineUsersInEvents,diagnosticRecordingIntervalMillis:a.diagnosticRecordingInterval,usingSecureMode:!!a.hash,bootstrapMode:!!a.bootstrap,fetchGoalsDisabled:!a.fetchGoals,allowFrequentDuplicateEvents:!!a.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!a.sendEventsOnlyForVariation,autoAliasingOptOut:!!a.autoAliasingOptOut},e),platform:n.diagnosticPlatformData};var e}function y(e){a.logger&&a.logger.debug(xe.debugPostingDiagnosticEvent(e)),t.sendEvents(e,d,!0).then(function(){}).catch(function(){})}function w(){var e,n;y((e=(new Date).getTime(),n=r({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:e},g.getProps()),l&&(n=r({},n,{},h())),g.reset(e),n)),c=setTimeout(w,v),s=(new Date).getTime(),l&&function(){if(o.isEnabled()){var e=r({},g.getProps());o.set(f,JSON.stringify(e))}}()}return m.start=function(){l?function(t){if(!o.isEnabled())return t(!1);o.get(f).then(function(e){if(e)try{var n=JSON.parse(e);g.setProps(n),s=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(s||0)+v,t=(new Date).getTime();n<=t?w():c=setTimeout(w,n-t)}else 0===Math.floor(4*Math.random())?w():c=setTimeout(w,v)}):(y(r({kind:"diagnostic-init",id:u,creationDate:g.getProps().dataSinceDate},h())),c=setTimeout(w,v))},m.stop=function(){c&&clearTimeout(c)},m.setStreaming=function(e){p=e},m};function Ze(n,t,o,i,s){var l,g,p,m,h,y,w,b,k,E=o&&o.logger?o.logger:s&&s.logger&&s.logger.default||Be("warn"),S=qe(E),D=Ve(S),O=Ge(o,S,s,E),P=O.sendEvents,U=n,x=O.hash,L=(y=i.localStorage,w=E,k=!(b={}),b.isEnabled=function(){return!!y},b.get=function(e){return new Promise(function(n){y?y.get(e).then(n).catch(function(e){ie(e),n(void 0)}):n(void 0)})},b.set=function(e,t){return new Promise(function(n){y?y.set(e,t).then(function(){return n(!0)}).catch(function(e){ie(e),n(!1)}):n(!1)})},b.clear=function(e){return new Promise(function(n){y?y.clear(e).then(function(){return n(!0)}).catch(function(e){ie(e),n(!1)}):n(!1)})},b),C=Q(i,U,O),N=O.sendEvents&&!O.diagnosticOptOut,A=N?We(U):null,z=N?Qe((new Date).getTime()):null,K=N?Ye(i,L,z,C,U,O,A):null,M=ze(i,O,U,z),J=O.eventProcessor||function(e,n,t,r,o,i){var u,s=3<arguments.length&&void 0!==r?r:null,c=4<arguments.length&&void 0!==o?o:null,l={},f=(5<arguments.length&&void 0!==i?i:null)||Q(e,t,n),v=n.eventsUrl+"/events/bulk/"+t,g=Y(),p=Z(n),m=n.inlineUsersInEvents,h=n.samplingInterval,y=n.eventCapacity,w=n.flushInterval,b=n.logger,k=[],E=0,S=!1,D=!1;function O(){return 0===h||0===Math.floor(Math.random()*h)}function P(e){k.length<y?(k.push(e),D=!1):(D||(D=!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?O()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>E&&e.debugEventsUntilDate>(new Date).getTime()}(e)):n=O(),n&&P(function(e){var n=q({},e);return"alias"===e.kind||(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=q({},e,{kind:"debug"});r.user=p.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,P(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(Ce(e.length)),f.sendEvents(e,v).then(function(e){e&&(e.serverTime&&(E=e.serverTime),d(e.status)||(S=!0),400<=e.status&&R(function(){c.maybeReportError(new a(he(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}(i,O,U,z,S,C),H=Je(i,O,U),G={},$={},B=O.streaming,X=!1,W=!1,ee=!0,ne=O.stateProvider,te=(m=function(e,n){var t;t=e,ne||t&&ue({kind:"identify",key:t.key,user:t,creationDate:(new Date).getTime()}),!O.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&me(e,n)},{setUser:function(e){var n=h&&I(h);(h=_(e))&&m&&m(I(h),n)},getUser:function(){return h?I(h):null}}),re=Me(L),oe=L.isEnabled()?new _e(L,U,x,te,E):null;function ie(e){k||(k=!0,w.warn(ae(e)))}function ue(e){if(U&&!(ne&&ne.enqueueEvent&&ne.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(ee&&(E.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),ee=!1));ee=!1}!P||W||i.isDoNotTrack()||(E.debug(Ae(e.kind)),J.enqueue(e))}}function ce(e,n,t,r){var o=te.getUser(),i=new Date,a=n?n.value:null;if(!O.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=G[u];if(s&&i-s<3e5)return;G[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()};o&&o.anonymous&&(c.contextKind=ge(o));var l=$[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),ue(c)}function de(e,n,t,r){var o;if($&&V($,e)&&$[e]&&!$[e].deleted){var i=$[e];o=ve(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&&ce(e,o,n,r),o}function ve(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function ge(e){return e.anonymous?"anonymousUser":"user"}function me(e,n){ne||e&&n&&ue({kind:"alias",key:e.key,contextKind:ge(e),previousKey:n.key,previousContextKind:ge(n),creationDate:(new Date).getTime()})}function ye(){if(g=!0,te.getUser()){var a=function(e){try{return JSON.parse(e)}catch(e){return void S.maybeReportError(new v("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};M.connect(te.getUser(),x,{ping:function(){E.debug("received ping message from stream");var n=te.getUser();H.fetchFlagSettings(n,x).then(function(e){j(n,te.getUser())&&be(e||{})}).catch(function(e){S.maybeReportError(new f(fe(e)))})},put:function(e){var n=a(e.data);n&&(E.debug("received streaming update for all flags"),be(n))},patch:function(e){var n=a(e.data);if(n){var t=$[n.key];if(!t||!t.version||!n.version||t.version<n.version){E.debug(Te(n.key));var r={},o=q({},n);delete o.key;var i=ve($[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ke(r)}else E.debug(Le(n.key))}},delete:function(e){var n=a(e.data);if(n)if(!$[n.key]||$[n.key].version<n.version){E.debug(Fe(n.key));var t={};$[n.key]&&!$[n.key].deleted&&(t[n.key]={previous:$[n.key].value}),$[n.key]={version:n.version,deleted:!0},ke(t)}else E.debug(Ne(n.key))}})}}function we(){g&&(M.disconnect(),g=!1)}function be(e){var n={};if(!e)return Promise.resolve();for(var t in $)V($,t)&&$[t]&&(e[t]&&!j(e[t].value,$[t].value)?n[t]={previous:$[t].value,current:ve(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:$[t].value}));for(var o in e)V(e,o)&&e[o]&&(!$[o]||$[o].deleted)&&(n[o]={current:ve(e[o])});return $=r({},e),ke(n).catch(function(){})}function ke(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;S.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),S.emit("change",i),S.emit("internal-change",$),O.sendEventsOnlyForVariation||ne||e.forEach(function(e){ce(e,o[e].current)})}return l&&oe?oe.saveFlags($):Promise.resolve()}function Ee(){var e=B||p&&void 0===B;e&&!g?ye():!e&&g&&we(),K&&K.setStreaming(e)}function Se(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof O.bootstrap&&"LOCALSTORAGE"===O.bootstrap.toUpperCase()&&(oe?l=!0:E.warn(ae())),"object"===e(O.bootstrap)&&($=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&E.warn(pe()),!1===t.$valid&&E.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=q(n,r[e]):n.version=0,o[e]=n}}),o}(O.bootstrap)),ne){var De=ne.getInitialState();De?Oe(De):ne.on("init",Oe),ne.on("update",function(e){e.user&&te.setUser(e.user),e.flags&&be(e.flags)})}else(n?re.validateUser(t).then(function(n){return te.setUser(n),"object"===e(O.bootstrap)?Pe():l?oe.loadFlags().then(function(e){return null==e?($={},H.fetchFlagSettings(te.getUser(),x).then(function(e){return be(e||{})}).then(Pe).catch(function(e){Re(new f(fe(e)))})):($=e,R(Pe),H.fetchFlagSettings(te.getUser(),x).then(function(e){return be(e)}).catch(function(e){return S.maybeReportError(e)}))}):H.fetchFlagSettings(te.getUser(),x).then(function(e){$=e||{},Pe()}).catch(function(e){$={},Re(e)})}):Promise.reject(new u(le()))).catch(Re);function Oe(e){U=e.environment,te.setUser(e.user),$=r({},e.flags),R(Pe)}function Pe(){E.info("LaunchDarkly client initialized"),X=!0,Ee(),D.signalSuccess()}function Re(e){D.signalFailure(e)}return{client:{waitForInitialization:function(){return D.getInitializationPromise()},waitUntilReady:function(){return D.getReadyPromise()},identify:function(e,r,n){return W?T(Promise.resolve({}),n):ne?(E.warn("identify() has no effect here; it must be called on the main client instance"),T(Promise.resolve(F($)),n)):T((l&&oe?oe.clearFlags():Promise.resolve()).then(function(){return re.validateUser(e)}).then(function(t){return H.fetchFlagSettings(t,r).then(function(e){var n=F(e);return te.setUser(t),x=r,e?be(e).then(function(){return n}):n})}).then(function(e){return g&&ye(),e}).catch(function(e){return S.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return te.getUser()},variation:function(e,n){return de(e,n,!0,!1).value},variationDetail:function(e,n){return de(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&E.warn(se(e));var r=te.getUser(),o={kind:"custom",key:e,user:r,url:i.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=ge(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),ue(o)}else S.maybeReportError(new c(se(e)))},alias:me,on:function(e,n,t){Se(e)?(p=!0,X&&Ee(),S.on(e,n,t)):S.on.apply(S,arguments)},off:function(e){if(S.off.apply(S,arguments),Se(e)){var n=!1;S.getEvents().forEach(function(e){Se(e)&&0<S.getEventListenerCount(e)&&(n=!0)}),n||(p=!1,g&&void 0===B&&we())}},setStreaming:function(e){var n=null===e?void 0:e;n!==B&&(B=n,Ee())},flush:function(e){return T(P?J.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!$)return e;for(var n in $)V($,n)&&(e[n]=de(n,null,!O.sendEventsOnlyForVariation).value);return e},close:function(e){if(W)return T(Promise.resolve(),e);function n(){W=!0,$={}}return T(Promise.resolve().then(function(){if(we(),K&&K.stop(),P)return J.stop(),J.flush()}).then(n).catch(n),e)}},options:O,emitter:S,ident:te,logger:E,requestor:H,start:function(){P&&(K&&K.start(),J.start())},enqueueEvent:ue,getFlagsInternal:function(){return $},getEnvironmentId:function(){return U},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(Object(t),!0).forEach(function(e){_defineProperty(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(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||{})Object.prototype.hasOwnProperty.call(t,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={synchronousFlush:!1};if(window.XMLHttpRequest){var a=e&&e.disableSyncEventPost;i.httpRequest=function(e,n,t,r){var o=i.synchronousFlush&!a;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(_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.20.2",i.diagnosticSdkData={name:"js-client-sdk",version:"2.20.2"},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=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?n:n.replace(r,"")).replace(t,"");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(o,n){var t,r;function i(){r&&r.dispose(),t&&t.length&&(r=GoalTracker(t,a))}function a(e,n){var t=o.ident.getUser(),r={kind:e,key:n.key,data:null,url:window.location.href,user:t,creationDate:(new Date).getTime()};return t&&t.anonymous&&(r.contextKind="anonymousUser"),"click"===e&&(r.selector=n.selector),o.enqueueEvent(r)}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 o.requestor.fetchJSON("/sdk/goals/"+o.getEnvironmentId()).then(function(e){e&&0<e.length&&(r=GoalTracker(t=e,a),u(locationWatcherInterval,i)),n()}).catch(function(e){o.emitter.maybeReportError(new g.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),{}}var goalsEvent="goalsReady",extraOptionDefs={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function initialize(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=makeBrowserPlatform(t),o=Ze(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()})});i.waitUntilGoalsReady=function(){return s},a.fetchGoals?GoalManager(o,function(){return u.emit(goalsEvent)}):u.emit(goalsEvent),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function c(){r.synchronousFlush=!0,i.flush().catch(function(){}),r.synchronousFlush=!1}return window.addEventListener("beforeunload",c),window.addEventListener("unload",c),i}var createConsoleLogger=Be,version="2.20.2";function deprecatedInitialize(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(xe.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){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function o(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}Object.defineProperty(exports,"__esModule",{value:!0});var a=o("LaunchDarklyUnexpectedResponseError"),u=o("LaunchDarklyInvalidEnvironmentIdError"),s=o("LaunchDarklyInvalidUserError"),c=o("LaunchDarklyInvalidEventKeyError"),l=o("LaunchDarklyInvalidArgumentError"),f=o("LaunchDarklyFlagFetchError"),v=o("LaunchDarklyInvalidDataError");function d(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var g=Object.freeze({__proto__:null,LDUnexpectedResponseError:a,LDInvalidEnvironmentIdError:u,LDInvalidUserError:s,LDInvalidEventKeyError:c,LDInvalidArgumentError:l,LDFlagFetchError:f,LDInvalidDataError:v,isHttpErrorRecoverable:d}),p=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(E(e,i,a<i+16383?a:i+16383));return 1==r?(n=e[t-1],o.push(m[n>>2]+m[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(m[n>>10]+m[n>>4&63]+m[n<<2&63]+"=")),o.join("")},m=[],y=[],h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b=0,k=h.length;b<k;++b)m[b]=h[b],y[h.charCodeAt(b)]=b;function E(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(m[(o=r)>>18&63]+m[o>>12&63]+m[o>>6&63]+m[63&o]);return i.join("")}y["-".charCodeAt(0)]=62,y["_".charCodeAt(0)]=63;var w=Array.isArray,D=Object.keys,O=Object.prototype.hasOwnProperty,P=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function S(e){var n=unescape(encodeURIComponent(e));return p(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(n))}function U(e){return S(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function I(e){return JSON.parse(JSON.stringify(e))}function j(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=w(n),u=w(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=D(n);if((o=d.length)!==D(t).length)return!1;for(r=o;0!=r--;)if(!O.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 R(e){setTimeout(e,0)}function T(e,n){var t=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:t}function L(e){var n={};for(var t in e)V(e,t)&&(n[t]={value:e[t],version:0});return n}function F(e){var n={};for(var t in e)V(e,t)&&(n[t]=e[t].value);return n}function N(e,n){for(var t,r=n.slice(0),o=[],i=e;0<r.length;){for(t=[];0<i;){var a=r.shift();if(!a)break;(i-=U(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function A(e){var n=e.version||"3.5.1";return e.userAgent+"/"+n}function C(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":A(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function x(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(r({},e)):e}function q(){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 V(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function _(e){if(!e)return e;var n;for(var t in P){var o=P[t],i=e[o];void 0!==i&&"string"!=typeof i&&((n=n||r({},e))[o]=String(i))}return n||e}for(var z=Object.freeze({__proto__:null,btoa:S,base64URLEncode:U,clone:I,deepEquals:j,onNextTick:R,wrapPromiseCallback:T,transformValuesToVersionedValues:L,transformVersionedValuesToValues:F,chunkUserEventsForUrl:N,getLDUserAgentString:A,getLDHeaders:C,transformHeaders:x,extend:q,objectHasOwnProperty:V,sanitizeUser:_}),J=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}(),M=[],K=0;K<256;++K)M[K]=(K+256).toString(16).substr(1);var H,B,$=function(e,n){var t=n||0,r=M;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")},G=0,X=0,W=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||H,a=void 0!==e.clockseq?e.clockseq:B;if(null==i||null==a){var u=J();null==i&&(i=H=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=B=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:X+1,l=s-G+(c-X)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||G<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");G=s,B=a;var f=(1e4*(268435455&(s+=122192928e5))+(X=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||$(o)};function Q(u,e,s){var t="/a/"+e+".gif",c=q({"Content-Type":"application/json"},C(u,s)),l=u.httpFallbackPing,f={sendChunk:function(e,r,o,n){var i=JSON.stringify(e),a=o?null:W();return n?function n(t){var e=o?c:q({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,x(e,s),i).promise.then(function(e){if(e)return 400<=e.status&&d(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(r+t+"?d="+U(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(f.sendChunk(r[a],n,t,o));return Promise.all(i)}};return f}function Y(){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 Z(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=q({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function ee(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var ne=function(){return"LaunchDarkly client initialized"},te=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",re=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},ie=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},oe=function(e){return'Expected application/json content type but got "'+e+'"'},ae=function(e){return"local storage is unavailable: "+ee(e)},ue=function(e){return"network error"+(e?" ("+e+")":"")},se=function(e){return'Custom event "'+e+'" does not exist'},ce=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+te},le=function(){return"No environment/client-side ID was specified."+te},fe=function(e){return"Error fetching flag settings: "+ee(e)},ve=function(){return"No user specified."+te},de=function(){return"Invalid user specified."+te},ge=function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},pe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+te},me=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},ye=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},he=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(d(e)?t:"giving up permanently")},be=function(){return"Cannot make HTTP requests in this environment."+te},ke=function(){return"identify() has no effect here; it must be called on the main client instance"},Ee=function(){return"Closing stream connection"},we=function(e){return"Opening stream connection to "+e},De=function(e,n){return"Error on stream connection: "+ee(e)+", will continue retrying every "+n+" milliseconds."},Oe=function(e){return'Ignoring unknown config option "'+e+'"'},Pe=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Se=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Ue=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Ie=function(e){return"polling for feature flags at "+e},je=function(){return"received ping message from stream"},Re=function(){return"received streaming update for all flags"},Te=function(e){return'received streaming update for flag "'+e+'"'},Le=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Fe=function(e){return'received streaming deletion for flag "'+e+'"'},Ne=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Ae=function(e){return'enqueueing "'+e+'" event'},Ce=function(e){return"sending "+e+" events"},xe=Object.freeze({__proto__:null,clientInitialized:ne,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:re,eventWithoutUser:ie,invalidContentType:oe,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ae,networkError:ue,unknownCustomEventKey:se,environmentNotFound:ce,environmentNotSpecified:le,errorFetchingFlags:fe,userNotSpecified:ve,invalidUser:de,invalidData:ge,bootstrapOldFormat:pe,bootstrapInvalid:me,deprecated:ye,httpErrorMessage:he,httpUnavailable:be,identifyDisabled:ke,streamClosing:Ee,streamConnecting:we,streamError:De,unknownOption:Oe,wrongOptionType:Pe,wrongOptionTypeBoolean:Se,optionBelowMinimum:Ue,debugPolling:Ie,debugStreamPing:je,debugStreamPut:Re,debugStreamPatch:Te,debugStreamPatchIgnored:Le,debugStreamDelete:Fe,debugStreamDeleteIgnored:Ne,debugEnqueueingEvent:Ae,debugPostingEvents:Ce,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function qe(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 Ve=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 _e(t,r,o,i){var a={};function u(){var e="",n=i.getUser();return n&&(e=o||S(JSON.stringify(n))),"ld:"+r+":"+e}return a.loadFlags=function(){return t.get(u()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=L(n):delete n.$schema}return n}catch(e){return a.clearFlags().then(function(){return null})}})},a.saveFlags=function(e){var n=q({},e,{$schema:1});return t.set(u(),JSON.stringify(n))},a.clearFlags=function(){return t.clear(u())},a}function ze(o,i,a,n){var u,s=i.streamUrl,c=i.logger,e={},l=s+"/eval/"+a,f=i.useReport,d=i.evaluationReasons,t=i.streamReconnectDelay,v=C(o,i),g=!1,p=null,m=null,h=null,y=null,w=null;function b(e){g||(c.warn(De(e,t)),g=!0),S(!1),E(),k(t)}function k(e){m||(e?m=setTimeout(r,e):r())}function r(){var e;m=null;var n="",t={headers:v,readTimeoutMillis:3e5};if(o.eventSourceFactory){for(var r in null!=y&&(n="h="+y),f?o.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(h)):(e=s+"/ping/"+a,n=""):e=l+"/"+U(JSON.stringify(h)),t.headers=x(t.headers,i),d&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,E(),c.info(we(e)),u=(new Date).getTime(),p=o.eventSourceFactory(e,t),w)V(w,r)&&p.addEventListener(r,w[r]);p.onerror=b}}function E(){p&&(c.info("Closing stream connection"),p.close(),p=null)}function S(e){u&&n&&n.recordStreamInit(u,!e,(new Date).getTime()-u),u=null}return e.connect=function(e,n,t){h=e,y=n,w={};function r(n){w[n]=function(e){S(!(g=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);k()},e.disconnect=function(){clearTimeout(m),m=null,E()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function Je(p,m,a){var s=m.baseUrl,c=m.useReport,l=m.evaluationReasons,d=m.logger,e={},h={};function v(e,n){if(!p.httpRequest)return new Promise(function(e,n){n(new f(be()))});var t=n?"REPORT":"GET",r=C(p,m);n&&(r["Content-Type"]="application/json");var o,i,a,s,c,l,d=h[e];d||(o=function(){delete h[e]},(l={addPromise:function(n,e){i=n,a&&a(),a=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=l,h[e]=d);var v=p.httpRequest(t,e,x(r,m),n),g=v.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new u(ce()):new f(fe(n.statusText||String(n.status))));if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n,t=oe(e.header("content-type")||"");return Promise.reject(new f(t))},function(e){return Promise.reject(new f(ue(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/",a,"/user"].join(""),o=JSON.stringify(e)):(t=U(JSON.stringify(e)),r=[s,"/sdk/evalx/",a,"/users/",t].join("")),n&&(i="h="+n),l&&(i=i+(i?"&":"")+"withReasons=true"),r=r+(i?"?":"")+i,d.debug(Ie(r)),v(r,o)},e}function Me(o){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new s(ve()));var r=I(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?o.get("ld:$anonUserId").then(function(e){if(e)return r.key=e,r;var n,t=W();return r.key=t,(n=t,o.set("ld:$anonUserId",n)).then(function(){return r})}):Promise.reject(new s(de()))},e}var Ke=["debug","info","warn","error","none"];function He(e,u){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var s=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],c=!(!e||!e.destination),l=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",r=1;if(e&&e.level)for(var t=0;t<Ke.length;t++)Ke[t]===e.level&&(r=t);for(var o={},a=function(e){var n=Ke[e];if("none"!==n)if(e<r)o[n]=function(){};else{var t=e;o[n]=function(){!function(e,n,t){if(!(t.length<1)){var r,o=c?n+": "+l:l;if(1!==t.length&&u){var a=i(t);a[0]=o+a[0],r=u.apply(void 0,i(a))}else r=o+t[0];try{s[e](r)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}(t,n,arguments)}}},f=0;f<Ke.length;f++)a(f);return o}function Be(e,n){return He({level:e,prefix:n})}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},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function Ge(n,t,r,o){var a=q({logger:{default:o}},$e,r),i={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){R(function(){t&&t.maybeReportError(new l(e))})}var s,c,f,d,v,g=q({},n||{});return v=g,Object.keys(i).forEach(function(e){if(void 0!==v[e]){var n=i[e];o&&o.warn(ye(e,n)),n&&(void 0===v[n]&&(v[n]=v[e]),delete v[e])}}),s=(d=q({},g),Object.keys(a).forEach(function(e){void 0!==d[e]&&null!==d[e]||(d[e]=a[e]&&a[e].default)}),c=g=d,f=q({},c),Object.keys(c).forEach(function(e){var n=c[e];if(null!=n){var t=a[e];if(void 0===t)u(Oe(e));else{var r=t.type||p(t.default);if("any"!==r){var o=r.split("|"),i=p(n);o.indexOf(i)<0?"boolean"===r?(f[e]=!!n,u(Se(e,i))):(u(Pe(e,r,i)),f[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(Ue(e,n,t.minimum)),f[e]=t.minimum)}}}}),g=f).logger,Ke.forEach(function(e){if("none"!==e&&(!s[e]||"function"!=typeof s[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")}),g;function p(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 Xe=Object.freeze({__proto__:null,baseOptionDefs:$e,validate:Ge}).baseOptionDefs,We=function(e){var n={diagnosticId:W()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},Qe=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}},Ye=function(n,o,e,t,i,a,u){var s,c,l=!!n.diagnosticUseCombinedEvent,f="ld:"+i+":$diagnostics",d=a.eventsUrl+"/events/diagnostic/"+i,v=a.diagnosticRecordingInterval,g=e,p=!!a.streaming,m={};function h(){return{sdk:function(){var e=r({},n.diagnosticSdkData);return a.wrapperName&&(e.wrapperName=a.wrapperName),a.wrapperVersion&&(e.wrapperVersion=a.wrapperVersion),e}(),configuration:(e={customBaseURI:a.baseUrl!==Xe.baseUrl.default,customStreamURI:a.streamUrl!==Xe.streamUrl.default,customEventsURI:a.eventsUrl!==Xe.eventsUrl.default,eventsCapacity:a.eventCapacity,eventsFlushIntervalMillis:a.flushInterval,reconnectTimeMillis:a.streamReconnectDelay,streamingDisabled:!p,allAttributesPrivate:!!a.allAttributesPrivate,inlineUsersInEvents:!!a.inlineUsersInEvents,diagnosticRecordingIntervalMillis:a.diagnosticRecordingInterval,usingSecureMode:!!a.hash,bootstrapMode:!!a.bootstrap,fetchGoalsDisabled:!a.fetchGoals,allowFrequentDuplicateEvents:!!a.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!a.sendEventsOnlyForVariation,autoAliasingOptOut:!!a.autoAliasingOptOut},e),platform:n.diagnosticPlatformData};var e}function y(e){a.logger&&a.logger.debug(xe.debugPostingDiagnosticEvent(e)),t.sendEvents(e,d,!0).then(function(){}).catch(function(){})}function w(){var e,n;y((e=(new Date).getTime(),n=r({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:e},g.getProps()),l&&(n=r({},n,{},h())),g.reset(e),n)),c=setTimeout(w,v),s=(new Date).getTime(),l&&function(){if(o.isEnabled()){var e=r({},g.getProps());o.set(f,JSON.stringify(e))}}()}return m.start=function(){l?function(t){if(!o.isEnabled())return t(!1);o.get(f).then(function(e){if(e)try{var n=JSON.parse(e);g.setProps(n),s=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)})}(function(e){if(e){var n=(s||0)+v,t=(new Date).getTime();n<=t?w():c=setTimeout(w,n-t)}else 0===Math.floor(4*Math.random())?w():c=setTimeout(w,v)}):(y(r({kind:"diagnostic-init",id:u,creationDate:g.getProps().dataSinceDate},h())),c=setTimeout(w,v))},m.stop=function(){c&&clearTimeout(c)},m.setStreaming=function(e){p=e},m};function Ze(n,t,o,i,s){var l,g,p,m,h,y,w,b,k,E=o&&o.logger?o.logger:s&&s.logger&&s.logger.default||Be("warn"),S=qe(E),D=Ve(S),O=Ge(o,S,s,E),P=O.sendEvents,U=n,L=O.hash,x=(y=i.localStorage,w=E,k=!(b={}),b.isEnabled=function(){return!!y},b.get=function(e){return new Promise(function(n){y?y.get(e).then(n).catch(function(e){ie(e),n(void 0)}):n(void 0)})},b.set=function(e,t){return new Promise(function(n){y?y.set(e,t).then(function(){return n(!0)}).catch(function(e){ie(e),n(!1)}):n(!1)})},b.clear=function(e){return new Promise(function(n){y?y.clear(e).then(function(){return n(!0)}).catch(function(e){ie(e),n(!1)}):n(!1)})},b),C=Q(i,U,O),N=O.sendEvents&&!O.diagnosticOptOut,A=N?We(U):null,z=N?Qe((new Date).getTime()):null,K=N?Ye(i,x,z,C,U,O,A):null,M=ze(i,O,U,z),H=O.eventProcessor||function(e,n,t,r,o,i){var u,s=3<arguments.length&&void 0!==r?r:null,c=4<arguments.length&&void 0!==o?o:null,l={},f=(5<arguments.length&&void 0!==i?i:null)||Q(e,t,n),v=n.eventsUrl+"/events/bulk/"+t,g=Y(),p=Z(n),m=n.inlineUsersInEvents,h=n.samplingInterval,y=n.eventCapacity,w=n.flushInterval,b=n.logger,k=[],E=0,S=!1,D=!1;function O(){return 0===h||0===Math.floor(Math.random()*h)}function P(e){k.length<y?(k.push(e),D=!1):(D||(D=!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?O()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>E&&e.debugEventsUntilDate>(new Date).getTime()}(e)):n=O(),n&&P(function(e){var n=q({},e);return"alias"===e.kind||(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=q({},e,{kind:"debug"});r.user=p.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,P(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(Ce(e.length)),f.sendEvents(e,v).then(function(e){e&&(e.serverTime&&(E=e.serverTime),d(e.status)||(S=!0),400<=e.status&&R(function(){c.maybeReportError(new a(he(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}(i,O,U,z,S,C),J=Je(i,O,U),B={},G={},$=O.streaming,X=!1,W=!1,ee=!0,ne=O.stateProvider,te=(m=function(e,n){var t;t=e,ne||t&&ue({kind:"identify",key:t.key,user:t,creationDate:(new Date).getTime()}),!O.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&me(e,n)},{setUser:function(e){var n=h&&I(h);(h=_(e))&&m&&m(I(h),n)},getUser:function(){return h?I(h):null}}),re=Me(x),oe=x.isEnabled()?new _e(x,U,L,te,E):null;function ie(e){k||(k=!0,w.warn(ae(e)))}function ue(e){if(U&&!(ne&&ne.enqueueEvent&&ne.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(ee&&(E.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),ee=!1));ee=!1}!P||W||i.isDoNotTrack()||(E.debug(Ae(e.kind)),H.enqueue(e))}}function ce(e,n,t,r){var o=te.getUser(),i=new Date,a=n?n.value:null;if(!O.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=B[u];if(s&&i-s<3e5)return;B[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()};o&&o.anonymous&&(c.contextKind=ge(o));var l=G[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),ue(c)}function de(e,n,t,r){var o;if(G&&V(G,e)&&G[e]&&!G[e].deleted){var i=G[e];o=ve(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&&ce(e,o,n,r),o}function ve(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function ge(e){return e.anonymous?"anonymousUser":"user"}function me(e,n){ne||e&&n&&ue({kind:"alias",key:e.key,contextKind:ge(e),previousKey:n.key,previousContextKind:ge(n),creationDate:(new Date).getTime()})}function ye(){if(g=!0,te.getUser()){var a=function(e){try{return JSON.parse(e)}catch(e){return void S.maybeReportError(new v("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};M.connect(te.getUser(),L,{ping:function(){E.debug("received ping message from stream");var n=te.getUser();J.fetchFlagSettings(n,L).then(function(e){j(n,te.getUser())&&be(e||{})}).catch(function(e){S.maybeReportError(new f(fe(e)))})},put:function(e){var n=a(e.data);n&&(E.debug("received streaming update for all flags"),be(n))},patch:function(e){var n=a(e.data);if(n){var t=G[n.key];if(!t||!t.version||!n.version||t.version<n.version){E.debug(Te(n.key));var r={},o=q({},n);delete o.key;var i=ve(G[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},ke(r)}else E.debug(Le(n.key))}},delete:function(e){var n=a(e.data);if(n)if(!G[n.key]||G[n.key].version<n.version){E.debug(Fe(n.key));var t={};G[n.key]&&!G[n.key].deleted&&(t[n.key]={previous:G[n.key].value}),G[n.key]={version:n.version,deleted:!0},ke(t)}else E.debug(Ne(n.key))}})}}function we(){g&&(M.disconnect(),g=!1)}function be(e){var n={};if(!e)return Promise.resolve();for(var t in G)V(G,t)&&G[t]&&(e[t]&&!j(e[t].value,G[t].value)?n[t]={previous:G[t].value,current:ve(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:G[t].value}));for(var o in e)V(e,o)&&e[o]&&(!G[o]||G[o].deleted)&&(n[o]={current:ve(e[o])});return G=r({},e),ke(n).catch(function(){})}function ke(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;S.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),S.emit("change",i),S.emit("internal-change",G),O.sendEventsOnlyForVariation||ne||e.forEach(function(e){ce(e,o[e].current)})}return l&&oe?oe.saveFlags(G):Promise.resolve()}function Ee(){var e=$||p&&void 0===$;e&&!g?ye():!e&&g&&we(),K&&K.setStreaming(e)}function Se(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof O.bootstrap&&"LOCALSTORAGE"===O.bootstrap.toUpperCase()&&(oe?l=!0:E.warn(ae())),"object"===e(O.bootstrap)&&(G=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&E.warn(pe()),!1===t.$valid&&E.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=q(n,r[e]):n.version=0,o[e]=n}}),o}(O.bootstrap)),ne){var De=ne.getInitialState();De?Oe(De):ne.on("init",Oe),ne.on("update",function(e){e.user&&te.setUser(e.user),e.flags&&be(e.flags)})}else(n?re.validateUser(t).then(function(n){return te.setUser(n),"object"===e(O.bootstrap)?Pe():l?oe.loadFlags().then(function(e){return null==e?(G={},J.fetchFlagSettings(te.getUser(),L).then(function(e){return be(e||{})}).then(Pe).catch(function(e){Re(new f(fe(e)))})):(G=e,R(Pe),J.fetchFlagSettings(te.getUser(),L).then(function(e){return be(e)}).catch(function(e){return S.maybeReportError(e)}))}):J.fetchFlagSettings(te.getUser(),L).then(function(e){G=e||{},Pe()}).catch(function(e){G={},Re(e)})}):Promise.reject(new u(le()))).catch(Re);function Oe(e){U=e.environment,te.setUser(e.user),G=r({},e.flags),R(Pe)}function Pe(){E.info("LaunchDarkly client initialized"),X=!0,Ee(),D.signalSuccess()}function Re(e){D.signalFailure(e)}return{client:{waitForInitialization:function(){return D.getInitializationPromise()},waitUntilReady:function(){return D.getReadyPromise()},identify:function(e,r,n){return W?T(Promise.resolve({}),n):ne?(E.warn("identify() has no effect here; it must be called on the main client instance"),T(Promise.resolve(F(G)),n)):T((l&&oe?oe.clearFlags():Promise.resolve()).then(function(){return re.validateUser(e)}).then(function(t){return J.fetchFlagSettings(t,r).then(function(e){var n=F(e);return te.setUser(t),L=r,e?be(e).then(function(){return n}):n})}).then(function(e){return g&&ye(),e}).catch(function(e){return S.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return te.getUser()},variation:function(e,n){return de(e,n,!0,!1).value},variationDetail:function(e,n){return de(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&E.warn(se(e));var r=te.getUser(),o={kind:"custom",key:e,user:r,url:i.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=ge(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),ue(o)}else S.maybeReportError(new c(se(e)))},alias:me,on:function(e,n,t){Se(e)?(p=!0,X&&Ee(),S.on(e,n,t)):S.on.apply(S,arguments)},off:function(e){if(S.off.apply(S,arguments),Se(e)){var n=!1;S.getEvents().forEach(function(e){Se(e)&&0<S.getEventListenerCount(e)&&(n=!0)}),n||(p=!1,g&&void 0===$&&we())}},setStreaming:function(e){var n=null===e?void 0:e;n!==$&&($=n,Ee())},flush:function(e){return T(P?H.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!G)return e;for(var n in G)V(G,n)&&(e[n]=de(n,null,!O.sendEventsOnlyForVariation).value);return e},close:function(e){if(W)return T(Promise.resolve(),e);function n(){W=!0,G={}}return T(Promise.resolve().then(function(){if(we(),K&&K.stop(),P)return H.stop(),H.flush()}).then(n).catch(n),e)}},options:O,emitter:S,ident:te,logger:E,requestor:J,start:function(){P&&(K&&K.start(),H.start())},enqueueEvent:ue,getFlagsInternal:function(){return G},getEnvironmentId:function(){return U},internalChangeEventName:"internal-change"}}var en="3.5.1",ldclientCommon_es=Object.freeze({__proto__:null,commonBasicLogger:He,createConsoleLogger:Be,errors:g,initialize:Ze,messages:xe,utils:z,version:en});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(Object(t),!0).forEach(function(e){_defineProperty(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}var commonBasicLogger=ldclientCommon_es.commonBasicLogger;function basicLogger(e){return commonBasicLogger(_objectSpread2({destination:console.log},e))}var basicLogger_1={basicLogger:basicLogger},basicLogger_2=basicLogger_1.basicLogger;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||{})Object.prototype.hasOwnProperty.call(t,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={synchronousFlush:!1};if(window.XMLHttpRequest){var a=e&&e.disableSyncEventPost;i.httpRequest=function(e,n,t,r){var o=i.synchronousFlush&!a;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(_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.21.0",i.diagnosticSdkData={name:"js-client-sdk",version:"2.21.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=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?n:n.replace(r,"")).replace(t,"");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(o,n){var t,r;function i(){r&&r.dispose(),t&&t.length&&(r=GoalTracker(t,a))}function a(e,n){var t=o.ident.getUser(),r={kind:e,key:n.key,data:null,url:window.location.href,user:t,creationDate:(new Date).getTime()};return t&&t.anonymous&&(r.contextKind="anonymousUser"),"click"===e&&(r.selector=n.selector),o.enqueueEvent(r)}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 o.requestor.fetchJSON("/sdk/goals/"+o.getEnvironmentId()).then(function(e){e&&0<e.length&&(r=GoalTracker(t=e,a),u(locationWatcherInterval,i)),n()}).catch(function(e){o.emitter.maybeReportError(new g.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),{}}var goalsEvent="goalsReady",extraOptionDefs={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function initialize(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=makeBrowserPlatform(t),o=Ze(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()})});i.waitUntilGoalsReady=function(){return s},a.fetchGoals?GoalManager(o,function(){return u.emit(goalsEvent)}):u.emit(goalsEvent),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function c(){r.synchronousFlush=!0,i.flush().catch(function(){}),r.synchronousFlush=!1}return window.addEventListener("beforeunload",c),window.addEventListener("unload",c),i}var basicLogger$1=basicLogger_2,createConsoleLogger=Be,version="2.21.0";function deprecatedInitialize(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(xe.deprecated("default export","named LDClient export")),initialize(e,n,t)}var index={initialize:deprecatedInitialize,version:version};exports.basicLogger=basicLogger$1,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){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function i(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var a=i("LaunchDarklyUnexpectedResponseError"),u=i("LaunchDarklyInvalidEnvironmentIdError"),s=i("LaunchDarklyInvalidUserError"),c=i("LaunchDarklyInvalidEventKeyError"),l=i("LaunchDarklyInvalidArgumentError"),f=i("LaunchDarklyFlagFetchError"),d=i("LaunchDarklyInvalidDataError");function v(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var g=Object.freeze({__proto__:null,LDUnexpectedResponseError:a,LDInvalidEnvironmentIdError:u,LDInvalidUserError:s,LDInvalidEventKeyError:c,LDInvalidArgumentError:l,LDFlagFetchError:f,LDInvalidDataError:d,isHttpErrorRecoverable:v}),p=[],m=[],h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",y=0,w=h.length;y<w;++y)p[y]=h[y],m[h.charCodeAt(y)]=y;function b(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(p[(o=r)>>18&63]+p[o>>12&63]+p[o>>6&63]+p[63&o]);return i.join("")}m["-".charCodeAt(0)]=62,m["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,D=Object.prototype.hasOwnProperty,S=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function O(e){return function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(b(e,i,i+16383>a?a:i+16383));return 1===r?(n=e[t-1],o.push(p[n>>2]+p[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],o.push(p[n>>10]+p[n>>4&63]+p[n<<2&63]+"=")),o.join("")}(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(unescape(encodeURIComponent(e))))}function P(e){return O(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function U(e){return JSON.parse(JSON.stringify(e))}function R(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,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(!D.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 j(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 T(e){var n={};for(var t in e)q(e,t)&&(n[t]={value:e[t],version:0});return n}function L(e){var n={};for(var t in e)q(e,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 x(e){var n=e.version||"3.5.1";return e.userAgent+"/"+n}function F(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":x(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function A(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(r({},e)):e}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 q(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function V(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:O,base64URLEncode:P,clone:U,deepEquals:R,onNextTick:j,wrapPromiseCallback:I,transformValuesToVersionedValues:T,transformVersionedValuesToValues:L,chunkUserEventsForUrl:N,getLDUserAgentString:x,getLDHeaders:F,transformHeaders:A,extend:C,objectHasOwnProperty:q,sanitizeUser:V});for(var _=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}(),J=[],z=0;z<256;++z)J[z]=(z+256).toString(16).substr(1);var M,H,K=0,$=0,B=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||M,a=void 0!==e.clockseq?e.clockseq:H;if(null==i||null==a){var u=_();null==i&&(i=M=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=H=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:$+1,l=s-K+(c-$)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>K)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");K=s,$=c,H=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 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||function(e,n){var t=n||0,r=J;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}(o)};function G(e,n,t){var r="/a/"+n+".gif",o=C({"Content-Type":"application/json"},F(e,t)),i=e.httpFallbackPing,a={sendChunk:function(n,a,u,s){var c=JSON.stringify(n),l=u?null:B();return s?function n(r){var i=u?o:C({},o,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":l});return e.httpRequest("POST",a,A(i,t),c).promise.then((function(e){if(e)return e.status>=400&&v(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(i&&i(a+r+"?d="+P(c)),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 X(){var e={},n=0,t=0,r={};return e.summarizeEvent=function(e){if("feature"===e.kind){var o=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),i=r[o];i?i.count=i.count+1:r[o]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===n||e.creationDate<n)&&(n=e.creationDate),e.creationDate>t&&(t=e.creationDate)}},e.getSummary=function(){var e={},o=!0;for(var i in r){var a=r[i],u=e[a.key];u||(u={default:a.default,counters:[]},e[a.key]=u);var 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 W(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 Q(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var Y=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",Z=function(e){return'Expected application/json content type but got "'+e+'"'},ee=function(e){return"local storage is unavailable: "+Q(e)},ne=function(e){return"network error"+(e?" ("+e+")":"")},te=function(e){return'Custom event "'+e+'" does not exist'},re=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+Y},oe=function(){return"No environment/client-side ID was specified."+Y},ie=function(e){return"Error fetching flag settings: "+Q(e)},ae=function(){return"No user specified."+Y},ue=function(){return"Invalid user specified."+Y},se=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+Y},ce=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},le=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(v(e)?t:"giving up permanently")},fe=function(){return"Cannot make HTTP requests in this environment."+Y},de=function(e){return"Opening stream connection to "+e},ve=function(e,n){return"Error on stream connection: "+Q(e)+", will continue retrying every "+n+" milliseconds."},ge=function(e){return'Ignoring unknown config option "'+e+'"'},pe=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},me=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},he=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},ye=function(e){return"polling for feature flags at "+e},we=function(e){return'received streaming update for flag "'+e+'"'},be=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},ke=function(e){return'received streaming deletion for flag "'+e+'"'},Ee=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},De=function(e){return'enqueueing "'+e+'" event'},Se=function(e){return"sending "+e+" events"},Oe=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/sdk/features/identify#javascript"},invalidContentType:Z,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ee,networkError:ne,unknownCustomEventKey:te,environmentNotFound:re,environmentNotSpecified:oe,errorFetchingFlags:ie,userNotSpecified:ae,invalidUser:ue,invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},bootstrapOldFormat:se,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:ce,httpErrorMessage:le,httpUnavailable:fe,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:de,streamError:ve,unknownOption:ge,wrongOptionType:pe,wrongOptionTypeBoolean:me,optionBelowMinimum:he,debugPolling:ye,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:we,debugStreamPatchIgnored:be,debugStreamDelete:ke,debugStreamDeleteIgnored:Ee,debugEnqueueingEvent:De,debugPostingEvents:Se,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function Pe(e,n,t,r){var o={};function i(){var e="",o=r.getUser();return o&&(e=t||O(JSON.stringify(o))),"ld:"+n+":"+e}return o.loadFlags=function(){return e.get(i()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=T(n):delete n.$schema}return n}catch(e){return o.clearFlags().then((function(){return null}))}}))},o.saveFlags=function(n){var t=C({},n,{$schema:1});return e.set(i(),JSON.stringify(t))},o.clearFlags=function(){return e.clear(i())},o}function Ue(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,d=F(e,n),v=!1,g=null,p=null,m=null,h=null,y=null;function w(e){v||(a.warn(ve(e,f)),v=!0),D(!1),E(),b(f)}function b(e){p||(e?p=setTimeout(k,e):k())}function k(){var r;p=null;var u="",f={headers:d,readTimeoutMillis:3e5};if(e.eventSourceFactory){for(var v in null!=h&&(u="h="+h),c?e.eventSourceAllowsReport?(r=s,f.method="REPORT",f.headers["Content-Type"]="application/json",f.body=JSON.stringify(m)):(r=i+"/ping/"+t,u=""):r=s+"/"+P(JSON.stringify(m)),f.headers=A(f.headers,n),l&&(u=u+(u?"&":"")+"withReasons=true"),r=r+(u?"?":"")+u,E(),a.info(de(r)),o=(new Date).getTime(),g=e.eventSourceFactory(r,f),y)q(y,v)&&g.addEventListener(v,y[v]);g.onerror=w}}function E(){g&&(a.info("Closing stream connection"),g.close(),g=null)}function D(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){v=!1,D(!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 Re(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,a=n.logger,s={},c={};function l(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new f(fe()))}));var o=r?"REPORT":"GET",i=F(e,n);r&&(i["Content-Type"]="application/json");var a=c[t];a||(a=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]=a);var s=e.httpRequest(o,t,A(i,n),r),l=s.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n=Z(e.header("content-type")||"");return Promise.reject(new f(n))}return Promise.reject(function(e){return 404===e.status?new u(re()):new f(ie(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new f(ne(e)))}));return a.addPromise(l,(function(){s.cancel&&s.cancel()})),a.resultPromise}return s.fetchJSON=function(e){return l(r+e,null)},s.fetchFlagSettings=function(e,n){var u,s,c,f="";return o?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(u=P(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",u].join("")),n&&(f="h="+n),i&&(f=f+(f?"&":"")+"withReasons=true"),s=s+(f?"?":"")+f,a.debug(ye(s)),l(s,c)},s}function je(e){var n={validateUser:function(n){if(!n)return Promise.reject(new s(ae()));var t=U(n);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?e.get("ld:$anonUserId").then((function(n){if(n)return t.key=n,t;var r=B();return t.key=r,function(n){return e.set("ld:$anonUserId",n)}(r).then((function(){return t}))})):Promise.reject(new s(ue()))}};return n}var Ie=["debug","info","warn","error","none"];function Te(e,n){return function(e,n){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function t(e){return function(n){console&&console[e]&&console[e].call(console,n)}}var r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[t("log"),t("info"),t("warn"),t("error")],i=!(!e||!e.destination),a=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",u=1;if(e&&e.level)for(var s=0;s<Ie.length;s++)Ie[s]===e.level&&(u=s);function c(e,t,u){if(!(u.length<1)){var s,c=i?t+": "+a:a;if(1!==u.length&&n){var l=o(u);l[0]=c+l[0],s=n.apply(void 0,o(l))}else s=c+u[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+t+" method threw an exception: "+e)}}}for(var l={},f=function(e){var n=Ie[e];if("none"!==n)if(e<u)l[n]=function(){};else{var t=e;l[n]=function(){c(t,n,arguments)}}},d=0;d<Ie.length;d++)f(d);return l}({level:e,prefix:n})}var Le={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function Ne(n,t,r,o){var i=C({logger:{default:o}},Le,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){j((function(){t&&t.maybeReportError(new l(e))}))}var s=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(ce(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),function(e){Ie.forEach((function(n){if("none"!==n&&(!e[n]||"function"!=typeof e[n]))throw new Error("Provided logger instance must support logger."+n+"(...) method")}))}((s=function(n){var t=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(ge(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(me(e,l))):(u(pe(e,s,l)),t[e]=a.default):"number"===l&&void 0!==a.minimum&&o<a.minimum&&(u(he(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))).logger),s}var xe=Object.freeze({__proto__:null,baseOptionDefs:Le,validate:Ne}).baseOptionDefs,Fe=function(e){var n={diagnosticId:B()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n};function Ae(n,t,o,i,s){var l,g,p,m=o&&o.logger?o.logger:s&&s.logger&&s.logger.default||Te("warn"),h=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}(m),y=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)}}}(h),w=Ne(o,h,s,m),b=w.sendEvents,k=n,E=w.hash,D=function(e,n){var t={},r=!1,o=function(e){r||(r=!0,n.warn(ee(e)))};return t.isEnabled=function(){return!!e},t.get=function(n){return new Promise((function(t){e?e.get(n).then(t).catch((function(e){o(e),t(void 0)})):t(void 0)}))},t.set=function(n,t){return new Promise((function(r){e?e.set(n,t).then((function(){return r(!0)})).catch((function(e){o(e),r(!1)})):r(!1)}))},t.clear=function(n){return new Promise((function(t){e?e.clear(n).then((function(){return t(!0)})).catch((function(e){o(e),t(!1)})):t(!1)}))},t}(i.localStorage,m),S=G(i,k,w),O=w.sendEvents&&!w.diagnosticOptOut,P=O?Fe(k):null,T=O?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}}((new Date).getTime()):null,N=O?function(e,n,t,o,i,a,u){var s,c,l=!!e.diagnosticUseCombinedEvent,f="ld:"+i+":$diagnostics",d=a.eventsUrl+"/events/diagnostic/"+i,v=a.diagnosticRecordingInterval,g=t,p=!!a.streaming,m={};function h(){return{sdk:b(),configuration:(n={customBaseURI:a.baseUrl!==xe.baseUrl.default,customStreamURI:a.streamUrl!==xe.streamUrl.default,customEventsURI:a.eventsUrl!==xe.eventsUrl.default,eventsCapacity:a.eventCapacity,eventsFlushIntervalMillis:a.flushInterval,reconnectTimeMillis:a.streamReconnectDelay,streamingDisabled:!p,allAttributesPrivate:!!a.allAttributesPrivate,inlineUsersInEvents:!!a.inlineUsersInEvents,diagnosticRecordingIntervalMillis:a.diagnosticRecordingInterval,usingSecureMode:!!a.hash,bootstrapMode:!!a.bootstrap,fetchGoalsDisabled:!a.fetchGoals,allowFrequentDuplicateEvents:!!a.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!a.sendEventsOnlyForVariation,autoAliasingOptOut:!!a.autoAliasingOptOut},n),platform:e.diagnosticPlatformData};var n}function y(e){a.logger&&a.logger.debug(Oe.debugPostingDiagnosticEvent(e)),o.sendEvents(e,d,!0).then((function(){})).catch((function(){}))}function w(){var e,t;y((e=(new Date).getTime(),t=r({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:e},g.getProps()),l&&(t=r({},t,{},h())),g.reset(e),t)),c=setTimeout(w,v),s=(new Date).getTime(),l&&function(){if(n.isEnabled()){var e=r({},g.getProps());n.set(f,JSON.stringify(e))}}()}function b(){var n=r({},e.diagnosticSdkData);return a.wrapperName&&(n.wrapperName=a.wrapperName),a.wrapperVersion&&(n.wrapperVersion=a.wrapperVersion),n}return m.start=function(){l?function(e){if(!n.isEnabled())return e(!1);n.get(f).then((function(n){if(n)try{var t=JSON.parse(n);g.setProps(t),s=t.dataSinceDate}catch(e){}e(!0)})).catch((function(){e(!1)}))}((function(e){if(e){var n=(s||0)+v,t=(new Date).getTime();t>=n?w():c=setTimeout(w,n-t)}else 0===Math.floor(4*Math.random())?w():c=setTimeout(w,v)})):(y(r({kind:"diagnostic-init",id:u,creationDate:g.getProps().dataSinceDate},h())),c=setTimeout(w,v))},m.stop=function(){c&&clearTimeout(c)},m.setStreaming=function(e){p=e},m}(i,D,T,S,k,w,P):null,x=Ue(i,w,k,T),F=w.eventProcessor||function(e,n,t){var r,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=u||G(e,t,n),l=n.eventsUrl+"/events/bulk/"+t,f=X(),d=W(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,k=!1,E=!1;function D(){return 0===p||0===Math.floor(Math.random()*p)}function S(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>b&&e.debugEventsUntilDate>(new Date).getTime()}function O(e){var n=C({},e);return"alias"===e.kind||(g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}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.")),o&&o.incrementDroppedEvents())}return s.enqueue=function(e){if(!k){var n=!1,t=!1;if(f.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=S(e)):n=D(),n&&P(O(e)),t){var r=C({},e,{kind:"debug"});r.user=d.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,P(r)}}},s.flush=function(){if(k)return Promise.resolve();var e=w,n=f.getSummary();return f.clearSummary(),n&&(n.kind="summary",e.push(n)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(Se(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(b=e.serverTime),v(e.status)||(k=!0),e.status>=400&&j((function(){i.maybeReportError(new a(le(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}(i,w,k,T,h,S),A=Re(i,w,k),_={},J={},z=w.streaming,M=!1,H=!1,K=!0,$=w.stateProvider,B=function(e,n){var t,r={setUser:function(e){var r=t&&U(t);(t=V(e))&&n&&n(U(t),r)},getUser:function(){return t?U(t):null}};return r}(0,(function(e,n){(function(e){$||e&&Z({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!w.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&ce(e,n)})),Q=je(D),Y=D.isEnabled()?new Pe(D,k,E,B,m):null;function Z(e){if(k&&!($&&$.enqueueEvent&&$.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(K&&(m.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),K=!1));K=!1}!b||H||i.isDoNotTrack()||(m.debug(De(e.kind)),F.enqueue(e))}}function ne(e,n,t,r){var o=B.getUser(),i=new Date,a=n?n.value:null;if(!w.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()};o&&o.anonymous&&(c.contextKind=ue(o));var l=J[e];l&&(c.version=l.flagVersion?l.flagVersion:l.version,c.trackEvents=l.trackEvents,c.debugEventsUntilDate=l.debugEventsUntilDate),(r||l&&l.trackReason)&&n&&(c.reason=n.reason),Z(c)}function re(e,n,t,r){var o;if(J&&q(J,e)&&J[e]&&!J[e].deleted){var i=J[e];o=ae(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&&ne(e,o,n,r),o}function ae(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function ue(e){return e.anonymous?"anonymousUser":"user"}function ce(e,n){$||e&&n&&Z({kind:"alias",key:e.key,contextKind:ue(e),previousKey:n.key,previousContextKind:ue(n),creationDate:(new Date).getTime()})}function fe(){if(g=!0,B.getUser()){var e=function(e){try{return JSON.parse(e)}catch(e){return void h.maybeReportError(new d("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};x.connect(B.getUser(),E,{ping:function(){m.debug("received ping message from stream");var e=B.getUser();A.fetchFlagSettings(e,E).then((function(n){R(e,B.getUser())&&ve(n||{})})).catch((function(e){h.maybeReportError(new f(ie(e)))}))},put:function(n){var t=e(n.data);t&&(m.debug("received streaming update for all flags"),ve(t))},patch:function(n){var t=e(n.data);if(t){var r=J[t.key];if(!r||!r.version||!t.version||r.version<t.version){m.debug(we(t.key));var o={},i=C({},t);delete i.key,J[t.key]=i;var a=ae(i);o[t.key]=r?{previous:r.value,current:a}:{current:a},ge(o)}else m.debug(be(t.key))}},delete:function(n){var t=e(n.data);if(t)if(!J[t.key]||J[t.key].version<t.version){m.debug(ke(t.key));var r={};J[t.key]&&!J[t.key].deleted&&(r[t.key]={previous:J[t.key].value}),J[t.key]={version:t.version,deleted:!0},ge(r)}else m.debug(Ee(t.key))}})}}function de(){g&&(x.disconnect(),g=!1)}function ve(e){var n={};if(!e)return Promise.resolve();for(var t in J)q(J,t)&&J[t]&&(e[t]&&!R(e[t].value,J[t].value)?n[t]={previous:J[t].value,current:ae(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:J[t].value}));for(var o in e)q(e,o)&&e[o]&&(!J[o]||J[o].deleted)&&(n[o]={current:ae(e[o])});return J=r({},e),ge(n).catch((function(){}))}function ge(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,o=r?r.value:void 0,i=e[n].previous;h.emit("change:"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}})),h.emit("change",t),h.emit("internal-change",J),w.sendEventsOnlyForVariation||$||n.forEach((function(n){ne(n,e[n].current)}))}return l&&Y?Y.saveFlags(J):Promise.resolve()}function pe(){var e=z||p&&void 0===z;e&&!g?fe():!e&&g&&de(),N&&N.setStreaming(e)}function me(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof w.bootstrap&&"LOCALSTORAGE"===w.bootstrap.toUpperCase()&&(Y?l=!0:m.warn(ee())),"object"===e(w.bootstrap)&&(J=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&m.warn(se()),!1===e.$valid&&m.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};t&&t[n]?o=C(o,t[n]):o.version=0,r[n]=o}})),r}(w.bootstrap)),$){var he=$.getInitialState();he?ye(he):$.on("init",ye),$.on("update",(function(e){e.user&&B.setUser(e.user),e.flags&&ve(e.flags)}))}else(n?Q.validateUser(t).then((function(n){return B.setUser(n),"object"===e(w.bootstrap)?Ie():l?Y.loadFlags().then((function(e){return null==e?(J={},A.fetchFlagSettings(B.getUser(),E).then((function(e){return ve(e||{})})).then(Ie).catch((function(e){Le(new f(ie(e)))}))):(J=e,j(Ie),A.fetchFlagSettings(B.getUser(),E).then((function(e){return ve(e)})).catch((function(e){return h.maybeReportError(e)})))})):A.fetchFlagSettings(B.getUser(),E).then((function(e){J=e||{},Ie()})).catch((function(e){J={},Le(e)}))})):Promise.reject(new u(oe()))).catch(Le);function ye(e){k=e.environment,B.setUser(e.user),J=r({},e.flags),j(Ie)}function Ie(){m.info("LaunchDarkly client initialized"),M=!0,pe(),y.signalSuccess()}function Le(e){y.signalFailure(e)}return{client:{waitForInitialization:function(){return y.getInitializationPromise()},waitUntilReady:function(){return y.getReadyPromise()},identify:function(e,n,t){return H?I(Promise.resolve({}),t):$?(m.warn("identify() has no effect here; it must be called on the main client instance"),I(Promise.resolve(L(J)),t)):I((l&&Y?Y.clearFlags():Promise.resolve()).then((function(){return Q.validateUser(e)})).then((function(e){return A.fetchFlagSettings(e,n).then((function(t){var r=L(t);return B.setUser(e),E=n,t?ve(t).then((function(){return r})):r}))})).then((function(e){return g&&fe(),e})).catch((function(e){return h.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return B.getUser()},variation:function(e,n){return re(e,n,!0,!1).value},variationDetail:function(e,n){return re(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&m.warn(te(e));var r=B.getUser(),o={kind:"custom",key:e,user:r,url:i.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=ue(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),Z(o)}else h.maybeReportError(new c(te(e)))},alias:ce,on:function(e,n,t){me(e)?(p=!0,M&&pe(),h.on(e,n,t)):h.on.apply(h,arguments)},off:function(e){if(h.off.apply(h,arguments),me(e)){var n=!1;h.getEvents().forEach((function(e){me(e)&&h.getEventListenerCount(e)>0&&(n=!0)})),n||(p=!1,g&&void 0===z&&de())}},setStreaming:function(e){var n=null===e?void 0:e;n!==z&&(z=n,pe())},flush:function(e){return I(b?F.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!J)return e;for(var n in J)q(J,n)&&(e[n]=re(n,null,!w.sendEventsOnlyForVariation).value);return e},close:function(e){if(H)return I(Promise.resolve(),e);var n=function(){H=!0,J={}};return I(Promise.resolve().then((function(){if(de(),N&&N.stop(),b)return F.stop(),F.flush()})).then(n).catch(n),e)}},options:w,emitter:h,ident:B,logger:m,requestor:A,start:function(){b&&(N&&N.start(),F.start())},enqueueEvent:Z,getFlagsInternal:function(){return J},getEnvironmentId:function(){return k},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 qe(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 Ve(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?qe(Object(t),!0).forEach((function(n){Ce(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):qe(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var _e={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Je(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 _e;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})Object.prototype.hasOwnProperty.call(t,a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),_e;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 ze(e){var n,t={synchronousFlush:!1};if(window.XMLHttpRequest){var r=e&&e.disableSyncEventPost;t.httpRequest=function(e,n,o,i){var a=t.synchronousFlush&!r;return t.synchronousFlush=!1,Je(e,n,o,i,a)}}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 o,i=e&&e.eventUrlTransformer;t.getCurrentUrl=function(){return i?i(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,o=window.EventSourcePolyfill):(t.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource){var a=3e5;t.eventSourceFactory=function(e,n){var t=Ve(Ve({},{heartbeatTimeout:a,silentTimeout:a,skipDefaultHeaders:!0}),n);return new o(e,t)},t.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return t.userAgent="JSClient",t.version="2.20.2",t.diagnosticSdkData={name:"js-client-sdk",version:"2.20.2"},t.diagnosticPlatformData={name:"JS"},t.diagnosticUseCombinedEvent=!0,t}var Me=/[|\\{}()[\]^$+*?.]/g,He=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(Me,"\\$&")};function Ke(e,n,t,r){var o,i,a=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?n:n.replace(r,"")).replace(t,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+He(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+He(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+He(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function $e(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(Ke(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}function Be(e,n){var t,r;function o(){r&&r.dispose(),t&&t.length&&(r=$e(t,i))}function i(n,t){var r=e.ident.getUser(),o={kind:n,key:t.key,data:null,url:window.location.href,user:r,creationDate:(new Date).getTime()};return r&&r.anonymous&&(o.contextKind="anonymousUser"),"click"===n&&(o.selector=t.selector),e.enqueueEvent(o)}return e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=$e(t=e,i),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)}(300,o)),n()})).catch((function(t){e.emitter.maybeReportError(new g.LDUnexpectedResponseError((t&&t.message,t.message))),n()})),{}}var Ge={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function Xe(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=ze(t),o=Ae(e,n,t,r,Ge),i=o.client,a=o.options,u=o.emitter,s=new Promise((function(e){var n=u.on("goalsReady",(function(){u.off("goalsReady",n),e()}))}));i.waitUntilGoalsReady=function(){return s},a.fetchGoals?Be(o,(function(){return u.emit("goalsReady")})):u.emit("goalsReady"),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var c=function(){r.synchronousFlush=!0,i.flush().catch((function(){})),r.synchronousFlush=!1};return window.addEventListener("beforeunload",c),window.addEventListener("unload",c),i}var We=Te,Qe="2.20.2";var Ye={initialize:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Oe.deprecated("default export","named LDClient export")),Xe(e,n,t)},version:"2.20.2"};export default Ye;export{We as createConsoleLogger,Xe as initialize,Qe 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){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function i(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var a=i("LaunchDarklyUnexpectedResponseError"),u=i("LaunchDarklyInvalidEnvironmentIdError"),s=i("LaunchDarklyInvalidUserError"),c=i("LaunchDarklyInvalidEventKeyError"),l=i("LaunchDarklyInvalidArgumentError"),f=i("LaunchDarklyFlagFetchError"),d=i("LaunchDarklyInvalidDataError");function v(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var g=Object.freeze({__proto__:null,LDUnexpectedResponseError:a,LDInvalidEnvironmentIdError:u,LDInvalidUserError:s,LDInvalidEventKeyError:c,LDInvalidArgumentError:l,LDFlagFetchError:f,LDInvalidDataError:d,isHttpErrorRecoverable:v}),p=[],m=[],h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",y=0,w=h.length;y<w;++y)p[y]=h[y],m[h.charCodeAt(y)]=y;function b(e,n,t){for(var r,o,i=[],a=n;a<t;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(p[(o=r)>>18&63]+p[o>>12&63]+p[o>>6&63]+p[63&o]);return i.join("")}m["-".charCodeAt(0)]=62,m["_".charCodeAt(0)]=63;var k=Array.isArray,E=Object.keys,D=Object.prototype.hasOwnProperty,S=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function O(e){return function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(b(e,i,i+16383>a?a:i+16383));return 1===r?(n=e[t-1],o.push(p[n>>2]+p[n<<4&63]+"==")):2===r&&(n=(e[t-2]<<8)+e[t-1],o.push(p[n>>10]+p[n>>4&63]+p[n<<2&63]+"=")),o.join("")}(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(unescape(encodeURIComponent(e))))}function P(e){return O(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function U(e){return JSON.parse(JSON.stringify(e))}function R(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,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(!D.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 j(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 T(e){var n={};for(var t in e)q(e,t)&&(n[t]={value:e[t],version:0});return n}function L(e){var n={};for(var t in e)q(e,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 x(e){var n=e.version||"3.5.1";return e.userAgent+"/"+n}function C(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":x(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function F(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(r({},e)):e}function A(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return r({},e,{},n)}),{})}function q(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function _(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}for(var V=Object.freeze({__proto__:null,btoa:O,base64URLEncode:P,clone:U,deepEquals:R,onNextTick:j,wrapPromiseCallback:I,transformValuesToVersionedValues:T,transformVersionedValuesToValues:L,chunkUserEventsForUrl:N,getLDUserAgentString:x,getLDHeaders:C,transformHeaders:F,extend:A,objectHasOwnProperty:q,sanitizeUser:_}),z=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}(),J=[],M=0;M<256;++M)J[M]=(M+256).toString(16).substr(1);var H,K,$=0,B=0,G=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||H,a=void 0!==e.clockseq?e.clockseq:K;if(null==i||null==a){var u=z();null==i&&(i=H=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=K=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:B+1,l=s-$+(c-B)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||s>$)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");$=s,B=c,K=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 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||function(e,n){var t=n||0,r=J;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}(o)};function X(e,n,t){var r="/a/"+n+".gif",o=A({"Content-Type":"application/json"},C(e,t)),i=e.httpFallbackPing,a={sendChunk:function(n,a,u,s){var c=JSON.stringify(n),l=u?null:G();return s?function n(r){var i=u?o:A({},o,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":l});return e.httpRequest("POST",a,F(i,t),c).promise.then((function(e){if(e)return e.status>=400&&v(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(i&&i(a+r+"?d="+P(c)),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 W(){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 Q(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=A({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function Y(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var Z=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",ee=function(e){return'Expected application/json content type but got "'+e+'"'},ne=function(e){return"local storage is unavailable: "+Y(e)},te=function(e){return"network error"+(e?" ("+e+")":"")},re=function(e){return'Custom event "'+e+'" does not exist'},oe=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+Z},ie=function(){return"No environment/client-side ID was specified."+Z},ae=function(e){return"Error fetching flag settings: "+Y(e)},ue=function(){return"No user specified."+Z},se=function(){return"Invalid user specified."+Z},ce=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+Z},le=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},fe=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(v(e)?t:"giving up permanently")},de=function(){return"Cannot make HTTP requests in this environment."+Z},ve=function(e){return"Opening stream connection to "+e},ge=function(e,n){return"Error on stream connection: "+Y(e)+", will continue retrying every "+n+" milliseconds."},pe=function(e){return'Ignoring unknown config option "'+e+'"'},me=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},he=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},ye=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},we=function(e){return"polling for feature flags at "+e},be=function(e){return'received streaming update for flag "'+e+'"'},ke=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Ee=function(e){return'received streaming deletion for flag "'+e+'"'},De=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Se=function(e){return'enqueueing "'+e+'" event'},Oe=function(e){return"sending "+e+" events"},Pe=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/sdk/features/identify#javascript"},invalidContentType:ee,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ne,networkError:te,unknownCustomEventKey:re,environmentNotFound:oe,environmentNotSpecified:ie,errorFetchingFlags:ae,userNotSpecified:ue,invalidUser:se,invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},bootstrapOldFormat:ce,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:le,httpErrorMessage:fe,httpUnavailable:de,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:ve,streamError:ge,unknownOption:pe,wrongOptionType:me,wrongOptionTypeBoolean:he,optionBelowMinimum:ye,debugPolling:we,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:be,debugStreamPatchIgnored:ke,debugStreamDelete:Ee,debugStreamDeleteIgnored:De,debugEnqueueingEvent:Se,debugPostingEvents:Oe,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});function Ue(e,n,t,r){var o={};function i(){var e="",o=r.getUser();return o&&(e=t||O(JSON.stringify(o))),"ld:"+n+":"+e}return o.loadFlags=function(){return e.get(i()).then((function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=T(n):delete n.$schema}return n}catch(e){return o.clearFlags().then((function(){return null}))}}))},o.saveFlags=function(n){var t=A({},n,{$schema:1});return e.set(i(),JSON.stringify(t))},o.clearFlags=function(){return e.clear(i())},o}function Re(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,d=C(e,n),v=!1,g=null,p=null,m=null,h=null,y=null;function w(e){v||(a.warn(ge(e,f)),v=!0),D(!1),E(),b(f)}function b(e){p||(e?p=setTimeout(k,e):k())}function k(){var r;p=null;var u="",f={headers:d,readTimeoutMillis:3e5};if(e.eventSourceFactory){for(var v in null!=h&&(u="h="+h),c?e.eventSourceAllowsReport?(r=s,f.method="REPORT",f.headers["Content-Type"]="application/json",f.body=JSON.stringify(m)):(r=i+"/ping/"+t,u=""):r=s+"/"+P(JSON.stringify(m)),f.headers=F(f.headers,n),l&&(u=u+(u?"&":"")+"withReasons=true"),r=r+(u?"?":"")+u,E(),a.info(ve(r)),o=(new Date).getTime(),g=e.eventSourceFactory(r,f),y)q(y,v)&&g.addEventListener(v,y[v]);g.onerror=w}}function E(){g&&(a.info("Closing stream connection"),g.close(),g=null)}function D(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){v=!1,D(!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 je(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,a=n.logger,s={},c={};function l(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new f(de()))}));var o=r?"REPORT":"GET",i=C(e,n);r&&(i["Content-Type"]="application/json");var a=c[t];a||(a=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]=a);var s=e.httpRequest(o,t,F(i,n),r),l=s.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n=ee(e.header("content-type")||"");return Promise.reject(new f(n))}return Promise.reject(function(e){return 404===e.status?new u(oe()):new f(ae(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new f(te(e)))}));return a.addPromise(l,(function(){s.cancel&&s.cancel()})),a.resultPromise}return s.fetchJSON=function(e){return l(r+e,null)},s.fetchFlagSettings=function(e,n){var u,s,c,f="";return o?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(u=P(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",u].join("")),n&&(f="h="+n),i&&(f=f+(f?"&":"")+"withReasons=true"),s=s+(f?"?":"")+f,a.debug(we(s)),l(s,c)},s}function Ie(e){var n={validateUser:function(n){if(!n)return Promise.reject(new s(ue()));var t=U(n);return null!==t.key&&void 0!==t.key?(t.key=t.key.toString(),Promise.resolve(t)):t.anonymous?e.get("ld:$anonUserId").then((function(n){if(n)return t.key=n,t;var r=G();return t.key=r,function(n){return e.set("ld:$anonUserId",n)}(r).then((function(){return t}))})):Promise.reject(new s(se()))}};return n}var Te=["debug","info","warn","error","none"];function Le(e,n){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function t(e){return function(n){console&&console[e]&&console[e].call(console,n)}}var r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[t("log"),t("info"),t("warn"),t("error")],i=!(!e||!e.destination),a=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",u=1;if(e&&e.level)for(var s=0;s<Te.length;s++)Te[s]===e.level&&(u=s);function c(e,t,u){if(!(u.length<1)){var s,c=i?t+": "+a:a;if(1!==u.length&&n){var l=o(u);l[0]=c+l[0],s=n.apply(void 0,o(l))}else s=c+u[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+t+" method threw an exception: "+e)}}}for(var l={},f=function(e){var n=Te[e];if("none"!==n)if(e<u)l[n]=function(){};else{var t=e;l[n]=function(){c(t,n,arguments)}}},d=0;d<Te.length;d++)f(d);return l}function Ne(e,n){return Le({level:e,prefix:n})}var xe={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function Ce(n,t,r,o){var i=A({logger:{default:o}},xe,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){j((function(){t&&t.maybeReportError(new l(e))}))}var s=A({},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(le(e,t)),t&&(void 0===n[t]&&(n[t]=n[e]),delete n[e])}}))}(s),function(e){Te.forEach((function(n){if("none"!==n&&(!e[n]||"function"!=typeof e[n]))throw new Error("Provided logger instance must support logger."+n+"(...) method")}))}((s=function(n){var t=A({},n),r=function(n){if(null===n)return"any";if(void 0!==n){if(Array.isArray(n))return"array";var t=e(n);return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"}};return Object.keys(n).forEach((function(e){var o=n[e];if(null!=o){var a=i[e];if(void 0===a)u(pe(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(he(e,l))):(u(me(e,s,l)),t[e]=a.default):"number"===l&&void 0!==a.minimum&&o<a.minimum&&(u(ye(e,o,a.minimum)),t[e]=a.minimum)}}}})),t}(s=function(e){var n=A({},e);return Object.keys(i).forEach((function(e){void 0!==n[e]&&null!==n[e]||(n[e]=i[e]&&i[e].default)})),n}(s))).logger),s}var Fe=Object.freeze({__proto__:null,baseOptionDefs:xe,validate:Ce}).baseOptionDefs,Ae=function(e){var n={diagnosticId:G()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n};function qe(n,t,o,i,s){var l,g,p,m=o&&o.logger?o.logger:s&&s.logger&&s.logger.default||Ne("warn"),h=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}(m),y=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)}}}(h),w=Ce(o,h,s,m),b=w.sendEvents,k=n,E=w.hash,D=function(e,n){var t={},r=!1,o=function(e){r||(r=!0,n.warn(ne(e)))};return t.isEnabled=function(){return!!e},t.get=function(n){return new Promise((function(t){e?e.get(n).then(t).catch((function(e){o(e),t(void 0)})):t(void 0)}))},t.set=function(n,t){return new Promise((function(r){e?e.set(n,t).then((function(){return r(!0)})).catch((function(e){o(e),r(!1)})):r(!1)}))},t.clear=function(n){return new Promise((function(t){e?e.clear(n).then((function(){return t(!0)})).catch((function(e){o(e),t(!1)})):t(!1)}))},t}(i.localStorage,m),S=X(i,k,w),O=w.sendEvents&&!w.diagnosticOptOut,P=O?Ae(k):null,T=O?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}}((new Date).getTime()):null,N=O?function(e,n,t,o,i,a,u){var s,c,l=!!e.diagnosticUseCombinedEvent,f="ld:"+i+":$diagnostics",d=a.eventsUrl+"/events/diagnostic/"+i,v=a.diagnosticRecordingInterval,g=t,p=!!a.streaming,m={};function h(){return{sdk:b(),configuration:(n={customBaseURI:a.baseUrl!==Fe.baseUrl.default,customStreamURI:a.streamUrl!==Fe.streamUrl.default,customEventsURI:a.eventsUrl!==Fe.eventsUrl.default,eventsCapacity:a.eventCapacity,eventsFlushIntervalMillis:a.flushInterval,reconnectTimeMillis:a.streamReconnectDelay,streamingDisabled:!p,allAttributesPrivate:!!a.allAttributesPrivate,inlineUsersInEvents:!!a.inlineUsersInEvents,diagnosticRecordingIntervalMillis:a.diagnosticRecordingInterval,usingSecureMode:!!a.hash,bootstrapMode:!!a.bootstrap,fetchGoalsDisabled:!a.fetchGoals,allowFrequentDuplicateEvents:!!a.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!a.sendEventsOnlyForVariation,autoAliasingOptOut:!!a.autoAliasingOptOut},n),platform:e.diagnosticPlatformData};var n}function y(e){a.logger&&a.logger.debug(Pe.debugPostingDiagnosticEvent(e)),o.sendEvents(e,d,!0).then((function(){})).catch((function(){}))}function w(){var e,t;y((e=(new Date).getTime(),t=r({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:e},g.getProps()),l&&(t=r({},t,{},h())),g.reset(e),t)),c=setTimeout(w,v),s=(new Date).getTime(),l&&function(){if(n.isEnabled()){var e=r({},g.getProps());n.set(f,JSON.stringify(e))}}()}function b(){var n=r({},e.diagnosticSdkData);return a.wrapperName&&(n.wrapperName=a.wrapperName),a.wrapperVersion&&(n.wrapperVersion=a.wrapperVersion),n}return m.start=function(){l?function(e){if(!n.isEnabled())return e(!1);n.get(f).then((function(n){if(n)try{var t=JSON.parse(n);g.setProps(t),s=t.dataSinceDate}catch(e){}e(!0)})).catch((function(){e(!1)}))}((function(e){if(e){var n=(s||0)+v,t=(new Date).getTime();t>=n?w():c=setTimeout(w,n-t)}else 0===Math.floor(4*Math.random())?w():c=setTimeout(w,v)})):(y(r({kind:"diagnostic-init",id:u,creationDate:g.getProps().dataSinceDate},h())),c=setTimeout(w,v))},m.stop=function(){c&&clearTimeout(c)},m.setStreaming=function(e){p=e},m}(i,D,T,S,k,w,P):null,x=Re(i,w,k,T),C=w.eventProcessor||function(e,n,t){var r,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=u||X(e,t,n),l=n.eventsUrl+"/events/bulk/"+t,f=W(),d=Q(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,k=!1,E=!1;function D(){return 0===p||0===Math.floor(Math.random()*p)}function S(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>b&&e.debugEventsUntilDate>(new Date).getTime()}function O(e){var n=A({},e);return"alias"===e.kind||(g||"identify"===e.kind?n.user=d.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}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.")),o&&o.incrementDroppedEvents())}return s.enqueue=function(e){if(!k){var n=!1,t=!1;if(f.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=S(e)):n=D(),n&&P(O(e)),t){var r=A({},e,{kind:"debug"});r.user=d.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,P(r)}}},s.flush=function(){if(k)return Promise.resolve();var e=w,n=f.getSummary();return f.clearSummary(),n&&(n.kind="summary",e.push(n)),o&&o.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(Oe(e.length)),c.sendEvents(e,l).then((function(e){e&&(e.serverTime&&(b=e.serverTime),v(e.status)||(k=!0),e.status>=400&&j((function(){i.maybeReportError(new a(fe(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}(i,w,k,T,h,S),F=je(i,w,k),V={},z={},J=w.streaming,M=!1,H=!1,K=!0,$=w.stateProvider,B=function(e,n){var t,r={setUser:function(e){var r=t&&U(t);(t=_(e))&&n&&n(U(t),r)},getUser:function(){return t?U(t):null}};return r}(0,(function(e,n){(function(e){$||e&&Z({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!w.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&se(e,n)})),G=Ie(D),Y=D.isEnabled()?new Ue(D,k,E,B,m):null;function Z(e){if(k&&!($&&$.enqueueEvent&&$.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(K&&(m.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),K=!1));K=!1}!b||H||i.isDoNotTrack()||(m.debug(Se(e.kind)),C.enqueue(e))}}function ee(e,n,t,r){var o=B.getUser(),i=new Date,a=n?n.value:null;if(!w.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=V[u];if(s&&i-s<3e5)return;V[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()};o&&o.anonymous&&(c.contextKind=ue(o));var 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),Z(c)}function te(e,n,t,r){var o;if(z&&q(z,e)&&z[e]&&!z[e].deleted){var i=z[e];o=oe(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&&ee(e,o,n,r),o}function oe(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function ue(e){return e.anonymous?"anonymousUser":"user"}function se(e,n){$||e&&n&&Z({kind:"alias",key:e.key,contextKind:ue(e),previousKey:n.key,previousContextKind:ue(n),creationDate:(new Date).getTime()})}function le(){if(g=!0,B.getUser()){var e=function(e){try{return JSON.parse(e)}catch(e){return void h.maybeReportError(new d("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};x.connect(B.getUser(),E,{ping:function(){m.debug("received ping message from stream");var e=B.getUser();F.fetchFlagSettings(e,E).then((function(n){R(e,B.getUser())&&ve(n||{})})).catch((function(e){h.maybeReportError(new f(ae(e)))}))},put:function(n){var t=e(n.data);t&&(m.debug("received streaming update for all flags"),ve(t))},patch:function(n){var t=e(n.data);if(t){var r=z[t.key];if(!r||!r.version||!t.version||r.version<t.version){m.debug(be(t.key));var o={},i=A({},t);delete i.key,z[t.key]=i;var a=oe(i);o[t.key]=r?{previous:r.value,current:a}:{current:a},ge(o)}else m.debug(ke(t.key))}},delete:function(n){var t=e(n.data);if(t)if(!z[t.key]||z[t.key].version<t.version){m.debug(Ee(t.key));var r={};z[t.key]&&!z[t.key].deleted&&(r[t.key]={previous:z[t.key].value}),z[t.key]={version:t.version,deleted:!0},ge(r)}else m.debug(De(t.key))}})}}function de(){g&&(x.disconnect(),g=!1)}function ve(e){var n={};if(!e)return Promise.resolve();for(var t in z)q(z,t)&&z[t]&&(e[t]&&!R(e[t].value,z[t].value)?n[t]={previous:z[t].value,current:oe(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:z[t].value}));for(var o in e)q(e,o)&&e[o]&&(!z[o]||z[o].deleted)&&(n[o]={current:oe(e[o])});return z=r({},e),ge(n).catch((function(){}))}function ge(e){var n=Object.keys(e);if(n.length>0){var t={};n.forEach((function(n){var r=e[n].current,o=r?r.value:void 0,i=e[n].previous;h.emit("change:"+n,o,i),t[n]=r?{current:o,previous:i}:{previous:i}})),h.emit("change",t),h.emit("internal-change",z),w.sendEventsOnlyForVariation||$||n.forEach((function(n){ee(n,e[n].current)}))}return l&&Y?Y.saveFlags(z):Promise.resolve()}function pe(){var e=J||p&&void 0===J;e&&!g?le():!e&&g&&de(),N&&N.setStreaming(e)}function me(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof w.bootstrap&&"LOCALSTORAGE"===w.bootstrap.toUpperCase()&&(Y?l=!0:m.warn(ne())),"object"===e(w.bootstrap)&&(z=function(e){var n=Object.keys(e),t=e.$flagsState;!t&&n.length&&m.warn(ce()),!1===e.$valid&&m.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags.");var r={};return n.forEach((function(n){if("$flagsState"!==n&&"$valid"!==n){var o={value:e[n]};t&&t[n]?o=A(o,t[n]):o.version=0,r[n]=o}})),r}(w.bootstrap)),$){var he=$.getInitialState();he?ye(he):$.on("init",ye),$.on("update",(function(e){e.user&&B.setUser(e.user),e.flags&&ve(e.flags)}))}else(n?G.validateUser(t).then((function(n){return B.setUser(n),"object"===e(w.bootstrap)?we():l?Y.loadFlags().then((function(e){return null==e?(z={},F.fetchFlagSettings(B.getUser(),E).then((function(e){return ve(e||{})})).then(we).catch((function(e){Te(new f(ae(e)))}))):(z=e,j(we),F.fetchFlagSettings(B.getUser(),E).then((function(e){return ve(e)})).catch((function(e){return h.maybeReportError(e)})))})):F.fetchFlagSettings(B.getUser(),E).then((function(e){z=e||{},we()})).catch((function(e){z={},Te(e)}))})):Promise.reject(new u(ie()))).catch(Te);function ye(e){k=e.environment,B.setUser(e.user),z=r({},e.flags),j(we)}function we(){m.info("LaunchDarkly client initialized"),M=!0,pe(),y.signalSuccess()}function Te(e){y.signalFailure(e)}return{client:{waitForInitialization:function(){return y.getInitializationPromise()},waitUntilReady:function(){return y.getReadyPromise()},identify:function(e,n,t){return H?I(Promise.resolve({}),t):$?(m.warn("identify() has no effect here; it must be called on the main client instance"),I(Promise.resolve(L(z)),t)):I((l&&Y?Y.clearFlags():Promise.resolve()).then((function(){return G.validateUser(e)})).then((function(e){return F.fetchFlagSettings(e,n).then((function(t){var r=L(t);return B.setUser(e),E=n,t?ve(t).then((function(){return r})):r}))})).then((function(e){return g&&le(),e})).catch((function(e){return h.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return B.getUser()},variation:function(e,n){return te(e,n,!0,!1).value},variationDetail:function(e,n){return te(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&m.warn(re(e));var r=B.getUser(),o={kind:"custom",key:e,user:r,url:i.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=ue(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),Z(o)}else h.maybeReportError(new c(re(e)))},alias:se,on:function(e,n,t){me(e)?(p=!0,M&&pe(),h.on(e,n,t)):h.on.apply(h,arguments)},off:function(e){if(h.off.apply(h,arguments),me(e)){var n=!1;h.getEvents().forEach((function(e){me(e)&&h.getEventListenerCount(e)>0&&(n=!0)})),n||(p=!1,g&&void 0===J&&de())}},setStreaming:function(e){var n=null===e?void 0:e;n!==J&&(J=n,pe())},flush:function(e){return I(b?C.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!z)return e;for(var n in z)q(z,n)&&(e[n]=te(n,null,!w.sendEventsOnlyForVariation).value);return e},close:function(e){if(H)return I(Promise.resolve(),e);var n=function(){H=!0,z={}};return I(Promise.resolve().then((function(){if(de(),N&&N.stop(),b)return C.stop(),C.flush()})).then(n).catch(n),e)}},options:w,emitter:h,ident:B,logger:m,requestor:F,start:function(){b&&(N&&N.start(),C.start())},enqueueEvent:Z,getFlagsInternal:function(){return z},getEnvironmentId:function(){return k},internalChangeEventName:"internal-change"}}function _e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function Ve(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 ze(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Ve(Object(t),!0).forEach((function(n){_e(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Ve(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var Je=Object.freeze({__proto__:null,commonBasicLogger:Le,createConsoleLogger:Ne,errors:g,initialize:qe,messages:Pe,utils:V,version:"3.5.1"}).commonBasicLogger;var Me=function(e){return Je(ze({destination:console.log},e))};var He={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Ke(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 He;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})Object.prototype.hasOwnProperty.call(t,a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),He;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 $e(e){var n,t={synchronousFlush:!1};if(window.XMLHttpRequest){var r=e&&e.disableSyncEventPost;t.httpRequest=function(e,n,o,i){var a=t.synchronousFlush&!r;return t.synchronousFlush=!1,Ke(e,n,o,i,a)}}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 o,i=e&&e.eventUrlTransformer;t.getCurrentUrl=function(){return i?i(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,o=window.EventSourcePolyfill):(t.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource){var a=3e5;t.eventSourceFactory=function(e,n){var t=ze(ze({},{heartbeatTimeout:a,silentTimeout:a,skipDefaultHeaders:!0}),n);return new o(e,t)},t.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return t.userAgent="JSClient",t.version="2.21.0",t.diagnosticSdkData={name:"js-client-sdk",version:"2.21.0"},t.diagnosticPlatformData={name:"JS"},t.diagnosticUseCombinedEvent=!0,t}var Be=/[|\\{}()[\]^$+*?.]/g,Ge=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(Be,"\\$&")};function Xe(e,n,t,r){var o,i,a=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?n:n.replace(r,"")).replace(t,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+Ge(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+Ge(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+Ge(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function We(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(Xe(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}function Qe(e,n){var t,r;function o(){r&&r.dispose(),t&&t.length&&(r=We(t,i))}function i(n,t){var r=e.ident.getUser(),o={kind:n,key:t.key,data:null,url:window.location.href,user:r,creationDate:(new Date).getTime()};return r&&r.anonymous&&(o.contextKind="anonymousUser"),"click"===n&&(o.selector=t.selector),e.enqueueEvent(o)}return e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=We(t=e,i),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)}(300,o)),n()})).catch((function(t){e.emitter.maybeReportError(new g.LDUnexpectedResponseError((t&&t.message,t.message))),n()})),{}}var Ye={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function Ze(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=$e(t),o=qe(e,n,t,r,Ye),i=o.client,a=o.options,u=o.emitter,s=new Promise((function(e){var n=u.on("goalsReady",(function(){u.off("goalsReady",n),e()}))}));i.waitUntilGoalsReady=function(){return s},a.fetchGoals?Qe(o,(function(){return u.emit("goalsReady")})):u.emit("goalsReady"),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var c=function(){r.synchronousFlush=!0,i.flush().catch((function(){})),r.synchronousFlush=!1};return window.addEventListener("beforeunload",c),window.addEventListener("unload",c),i}var en=Me,nn=Ne,tn="2.21.0";var rn={initialize:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Pe.deprecated("default export","named LDClient export")),Ze(e,n,t)},version:"2.21.0"};export default rn;export{en as basicLogger,nn as createConsoleLogger,Ze as initialize,tn 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 re(e){return(re="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 oe(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 f(e){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var ie=t("LaunchDarklyUnexpectedResponseError"),ae=t("LaunchDarklyInvalidEnvironmentIdError"),i=t("LaunchDarklyInvalidUserError"),ue=t("LaunchDarklyInvalidEventKeyError"),g=t("LaunchDarklyInvalidArgumentError"),se=t("LaunchDarklyFlagFetchError"),ce=t("LaunchDarklyInvalidDataError");function le(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var s=Object.freeze({__proto__:null,LDUnexpectedResponseError:ie,LDInvalidEnvironmentIdError:ae,LDInvalidUserError:i,LDInvalidEventKeyError:ue,LDInvalidArgumentError:g,LDFlagFetchError:se,LDInvalidDataError:ce,isHttpErrorRecoverable:le}),r=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(d(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=[],a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=a.length;c<l;++c)u[c]=a[c],o[a.charCodeAt(c)]=c;function d(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 v=Array.isArray,p=Object.keys,m=Object.prototype.hasOwnProperty,h=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function y(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 S(e){return y(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function fe(e){return JSON.parse(JSON.stringify(e))}function de(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=v(n),u=v(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=p(n);if((o=d.length)!==p(t).length)return!1;for(r=o;0!=r--;)if(!m.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 ve(e){setTimeout(e,0)}function ge(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 w(e){var n={};for(var t in e)he(e,t)&&(n[t]={value:e[t],version:0});return n}function pe(e){var n={};for(var t in e)he(e,t)&&(n[t]=e[t].value);return n}function b(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-=S(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function k(e){var n=e.version||"3.5.1";return e.userAgent+"/"+n}function O(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":k(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function P(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(oe({},e)):e}function me(){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 oe({},e,{},n)},{})}function he(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function ye(e){if(!e)return e;var n;for(var t in h){var r=h[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||oe({},e))[r]=String(o))}return n||e}Object.freeze({__proto__:null,btoa:y,base64URLEncode:S,clone:fe,deepEquals:de,onNextTick:ve,wrapPromiseCallback:ge,transformValuesToVersionedValues:w,transformVersionedValuesToValues:pe,chunkUserEventsForUrl:b,getLDUserAgentString:k,getLDHeaders:O,transformHeaders:P,extend:me,objectHasOwnProperty:he,sanitizeUser:ye});for(var E,D=(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),U=[],j=0;j<256;++j)U[j]=(j+256).toString(16).substr(1);var I,R,T=0,L=0,N=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||I,a=void 0!==e.clockseq?e.clockseq:R;if(null==i||null==a){var u=D();null==i&&(i=I=[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:L+1,l=s-T+(c-L)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||T<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");T=s,R=a;var f=(1e4*(268435455&(s+=122192928e5))+(L=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||function(e,n){var t=n||0,r=U;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 we(u,e,s){var t="/a/"+e+".gif",c=me({"Content-Type":"application/json"},O(u,s)),l=u.httpFallbackPing,f={sendChunk:function(e,r,o,n){var i=JSON.stringify(e),a=o?null:N();return n?function n(t){var e=o?c:me({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,P(e,s),i).promise.then(function(e){if(e)return 400<=e.status&&le(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(r+t+"?d="+S(i)),Promise.resolve())},sendEvents:function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,o=u.httpAllowsPost();r=o?[e]:b(2e3-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(f.sendChunk(r[a],n,t,o));return Promise.all(i)}};return f}function be(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=me({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function x(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var C=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",F=function(e){return'Expected application/json content type but got "'+e+'"'},ke=function(e){return"local storage is unavailable: "+x(e)},A=function(e){return"network error"+(e?" ("+e+")":"")},Ee=function(e){return'Custom event "'+e+'" does not exist'},q=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+C},De=function(){return"No environment/client-side ID was specified."+C},Se=function(e){return"Error fetching flag settings: "+x(e)},_=function(){return"No user specified."+C},V=function(){return"Invalid user specified."+C},Oe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+C},z=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+" - "+(le(e)?t:"giving up permanently")},J=function(){return"Cannot make HTTP requests in this environment."+C},M=function(e){return"Opening stream connection to "+e},H=function(e,n){return"Error on stream connection: "+x(e)+", will continue retrying every "+n+" milliseconds."},K=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"},B=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},G=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},X=function(e){return"polling for feature flags at "+e},Ue=function(e){return'received streaming update for flag "'+e+'"'},je=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Ie=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'},Le=function(e){return"sending "+e+" events"},W=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/sdk/features/identify#javascript"},invalidContentType:F,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ke,networkError:A,unknownCustomEventKey:Ee,environmentNotFound:q,environmentNotSpecified:De,errorFetchingFlags:Se,userNotSpecified:_,invalidUser:V,invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},bootstrapOldFormat:Oe,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:z,httpErrorMessage:Pe,httpUnavailable:J,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:M,streamError:H,unknownOption:K,wrongOptionType:$,wrongOptionTypeBoolean:B,optionBelowMinimum:G,debugPolling:X,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:Ue,debugStreamPatchIgnored:je,debugStreamDelete:Ie,debugStreamDeleteIgnored:Re,debugEnqueueingEvent:Te,debugPostingEvents:Le,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});var Ne=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 xe(t,r,o,i){var a={};function u(){var e="",n=i.getUser();return n&&(e=o||y(JSON.stringify(n))),"ld:"+r+":"+e}return a.loadFlags=function(){return t.get(u()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=w(n):delete n.$schema}return n}catch(e){return a.clearFlags().then(function(){return null})}})},a.saveFlags=function(e){var n=me({},e,{$schema:1});return t.set(u(),JSON.stringify(n))},a.clearFlags=function(){return t.clear(u())},a}function Ce(o,i,a,n){var u,s=i.streamUrl,c=i.logger,e={},l=s+"/eval/"+a,f=i.useReport,d=i.evaluationReasons,t=i.streamReconnectDelay,v=O(o,i),g=!1,p=null,m=null,h=null,y=null,w=null;function b(e){g||(c.warn(H(e,t)),g=!0),D(!1),E(),k(t)}function k(e){m||(e?m=setTimeout(r,e):r())}function r(){var e;m=null;var n="",t={headers:v,readTimeoutMillis:3e5};if(o.eventSourceFactory){for(var r in null!=y&&(n="h="+y),f?o.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(h)):(e=s+"/ping/"+a,n=""):e=l+"/"+S(JSON.stringify(h)),t.headers=P(t.headers,i),d&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,E(),c.info(M(e)),u=(new Date).getTime(),p=o.eventSourceFactory(e,t),w)he(w,r)&&p.addEventListener(r,w[r]);p.onerror=b}}function E(){p&&(c.info("Closing stream connection"),p.close(),p=null)}function D(e){u&&n&&n.recordStreamInit(u,!e,(new Date).getTime()-u),u=null}return e.connect=function(e,n,t){h=e,y=n,w={};function r(n){w[n]=function(e){D(!(g=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);k()},e.disconnect=function(){clearTimeout(m),m=null,E()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function Fe(v,g,a){var u=g.baseUrl,s=g.useReport,c=g.evaluationReasons,l=g.logger,e={},p={};function f(e,n){if(!v.httpRequest)return new Promise(function(e,n){n(new se(J()))});var t=n?"REPORT":"GET",r=O(v,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=v.httpRequest(t,e,P(r,g),n),d=f.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new ae(q()):new se(Se(n.statusText||String(n.status))));if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n,t=F(e.header("content-type")||"");return Promise.reject(new se(t))},function(e){return Promise.reject(new se(A(e)))});return l.addPromise(d,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=S(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(X(r)),f(r,o)},e}function Ae(o){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new i(_()));var r=fe(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?o.get("ld:$anonUserId").then(function(e){if(e)return r.key=e,r;var n,t=N();return r.key=t,(n=t,o.set("ld:$anonUserId",n)).then(function(){return r})}):Promise.reject(new i(V()))},e}var Q=["debug","info","warn","error","none"];function Y(e,a){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var u=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],s=!(!e||!e.destination),c=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",r=1;if(e&&e.level)for(var t=0;t<Q.length;t++)Q[t]===e.level&&(r=t);for(var o={},i=function(e){var n=Q[e];if("none"!==n)if(e<r)o[n]=function(){};else{var t=e;o[n]=function(){!function(e,n,t){if(!(t.length<1)){var r,o=s?n+": "+c:c;if(1!==t.length&&a){var i=f(t);i[0]=o+i[0],r=a.apply(void 0,f(i))}else r=o+t[0];try{u[e](r)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}(t,n,arguments)}}},l=0;l<Q.length;l++)i(l);return o}function qe(e,n){return Y({level:e,prefix:n})}var Z={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function _e(e,n,t,r){var a=me({logger:{default:r}},Z,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){ve(function(){n&&n.maybeReportError(new g(e))})}var i,s,c,l,f,d=me({},e||{});return f=d,Object.keys(o).forEach(function(e){if(void 0!==f[e]){var n=o[e];r&&r.warn(z(e,n)),n&&(void 0===f[n]&&(f[n]=f[e]),delete f[e])}}),i=(l=me({},d),Object.keys(a).forEach(function(e){void 0!==l[e]&&null!==l[e]||(l[e]=a[e]&&a[e].default)}),s=d=l,c=me({},s),Object.keys(s).forEach(function(e){var n=s[e];if(null!=n){var t=a[e];if(void 0===t)u(K(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(B(e,i))):(u($(e,r,i)),c[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(G(e,n,t.minimum)),c[e]=t.minimum)}}}}),d=c).logger,Q.forEach(function(e){if("none"!==e&&(!i[e]||"function"!=typeof i[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")}),d;function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=re(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}}var ee=Object.freeze({__proto__:null,baseOptionDefs:Z,validate:_e}).baseOptionDefs,Ve=function(e){var n={diagnosticId:N()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},ze=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}},Je=function(n,r,e,t,o,i,a){var u,s,c=!!n.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+o,d=i.diagnosticRecordingInterval,v=e,g=!!i.streaming,p={};function m(){return{sdk:function(){var e=oe({},n.diagnosticSdkData);return i.wrapperName&&(e.wrapperName=i.wrapperName),i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion),e}(),configuration:(e={customBaseURI:i.baseUrl!==ee.baseUrl.default,customStreamURI:i.streamUrl!==ee.streamUrl.default,customEventsURI:i.eventsUrl!==ee.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation,autoAliasingOptOut:!!i.autoAliasingOptOut},e),platform:n.diagnosticPlatformData};var e}function h(e){i.logger&&i.logger.debug(W.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function y(){var e,n;h((e=(new Date).getTime(),n=oe({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},v.getProps()),c&&(n=oe({},n,{},m())),v.reset(e),n)),s=setTimeout(y,d),u=(new Date).getTime(),c&&function(){if(r.isEnabled()){var e=oe({},v.getProps());r.set(l,JSON.stringify(e))}}()}return p.start=function(){c?function(t){if(!r.isEnabled())return t(!1);r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),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(oe({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 ne(e,n,t,i,r){var a,o,u,s,c,l,f,d,v,g=t&&t.logger?t.logger:r&&r.logger&&r.logger.default||qe("warn"),p=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}(g),m=Ne(p),h=_e(t,p,r,g),y=h.sendEvents,w=e,b=h.hash,k=(l=i.localStorage,f=g,v=!(d={}),d.isEnabled=function(){return!!l},d.get=function(e){return new Promise(function(n){l?l.get(e).then(n).catch(function(e){V(e),n(void 0)}):n(void 0)})},d.set=function(e,t){return new Promise(function(n){l?l.set(e,t).then(function(){return n(!0)}).catch(function(e){V(e),n(!1)}):n(!1)})},d.clear=function(e){return new Promise(function(n){l?l.clear(e).then(function(){return n(!0)}).catch(function(e){V(e),n(!1)}):n(!1)})},d),E=we(i,w,h),D=h.sendEvents&&!h.diagnosticOptOut,S=D?Ve(w):null,O=D?ze((new Date).getTime()):null,P=D?Je(i,k,O,E,w,h,S):null,U=Ce(i,h,w,O),j=h.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)||we(e,t,n),f=n.eventsUrl+"/events/bulk/"+t,d=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}(),v=be(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,k=!1,E=!1;function D(){return 0===p||0===Math.floor(Math.random()*p)}function S(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(d.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>b&&e.debugEventsUntilDate>(new Date).getTime()}(e)):n=D(),n&&S(function(e){var n=me({},e);return"alias"===e.kind||(g||"identify"===e.kind?n.user=v.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}(e)),t){var r=me({},e,{kind:"debug"});r.user=v.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,S(r)}}},c.flush=function(){if(k)return Promise.resolve();var e=w,n=d.getSummary();return d.clearSummary(),n&&(n.kind="summary",e.push(n)),u&&u.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(Le(e.length)),l.sendEvents(e,f).then(function(e){e&&(e.serverTime&&(b=e.serverTime),le(e.status)||(k=!0),400<=e.status&&ve(function(){s.maybeReportError(new ie(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}(i,h,w,O,p,E),I=Fe(i,h,w),R={},T={},L=h.streaming,N=!1,x=!1,C=!0,F=h.stateProvider,A=(s=function(e,n){var t;t=e,F||t&&z({kind:"identify",key:t.key,user:t,creationDate:(new Date).getTime()}),!h.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&$(e,n)},{setUser:function(e){var n=c&&fe(c);(c=ye(e))&&s&&s(fe(c),n)},getUser:function(){return c?fe(c):null}}),q=Ae(k),_=k.isEnabled()?new xe(k,w,b,A,g):null;function V(e){v||(v=!0,f.warn(ke(e)))}function z(e){if(w&&!(F&&F.enqueueEvent&&F.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(C&&(g.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),C=!1));C=!1}!y||x||i.isDoNotTrack()||(g.debug(Te(e.kind)),j.enqueue(e))}}function J(e,n,t,r){var o=A.getUser(),i=new Date,a=n?n.value:null;if(!h.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=R[u];if(s&&i-s<3e5)return;R[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()};o&&o.anonymous&&(c.contextKind=K(o));var l=T[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),z(c)}function M(e,n,t,r){var o;if(T&&he(T,e)&&T[e]&&!T[e].deleted){var i=T[e];o=H(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&J(e,o,n,r),o}function H(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function K(e){return e.anonymous?"anonymousUser":"user"}function $(e,n){F||e&&n&&z({kind:"alias",key:e.key,contextKind:K(e),previousKey:n.key,previousContextKind:K(n),creationDate:(new Date).getTime()})}function B(){if(o=!0,A.getUser()){var a=function(e){try{return JSON.parse(e)}catch(e){return void p.maybeReportError(new ce("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};U.connect(A.getUser(),b,{ping:function(){g.debug("received ping message from stream");var n=A.getUser();I.fetchFlagSettings(n,b).then(function(e){de(n,A.getUser())&&X(e||{})}).catch(function(e){p.maybeReportError(new se(Se(e)))})},put:function(e){var n=a(e.data);n&&(g.debug("received streaming update for all flags"),X(n))},patch:function(e){var n=a(e.data);if(n){var t=T[n.key];if(!t||!t.version||!n.version||t.version<n.version){g.debug(Ue(n.key));var r={},o=me({},n);delete o.key;var i=H(T[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},W(r)}else g.debug(je(n.key))}},delete:function(e){var n=a(e.data);if(n)if(!T[n.key]||T[n.key].version<n.version){g.debug(Ie(n.key));var t={};T[n.key]&&!T[n.key].deleted&&(t[n.key]={previous:T[n.key].value}),T[n.key]={version:n.version,deleted:!0},W(t)}else g.debug(Re(n.key))}})}}function G(){o&&(U.disconnect(),o=!1)}function X(e){var n={};if(!e)return Promise.resolve();for(var t in T)he(T,t)&&T[t]&&(e[t]&&!de(e[t].value,T[t].value)?n[t]={previous:T[t].value,current:H(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:T[t].value}));for(var r in e)he(e,r)&&e[r]&&(!T[r]||T[r].deleted)&&(n[r]={current:H(e[r])});return T=oe({},e),W(n).catch(function(){})}function W(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;p.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),p.emit("change",i),p.emit("internal-change",T),h.sendEventsOnlyForVariation||F||e.forEach(function(e){J(e,o[e].current)})}return a&&_?_.saveFlags(T):Promise.resolve()}function Q(){var e=L||u&&void 0===L;e&&!o?B():!e&&o&&G(),P&&P.setStreaming(e)}function Y(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof h.bootstrap&&"LOCALSTORAGE"===h.bootstrap.toUpperCase()&&(_?a=!0:g.warn(ke())),"object"===re(h.bootstrap)&&(T=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&g.warn(Oe()),!1===t.$valid&&g.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=me(n,r[e]):n.version=0,o[e]=n}}),o}(h.bootstrap)),F){var Z=F.getInitialState();Z?ee(Z):F.on("init",ee),F.on("update",function(e){e.user&&A.setUser(e.user),e.flags&&X(e.flags)})}else(e?q.validateUser(n).then(function(e){return A.setUser(e),"object"===re(h.bootstrap)?ne():a?_.loadFlags().then(function(e){return null==e?(T={},I.fetchFlagSettings(A.getUser(),b).then(function(e){return X(e||{})}).then(ne).catch(function(e){te(new se(Se(e)))})):(T=e,ve(ne),I.fetchFlagSettings(A.getUser(),b).then(function(e){return X(e)}).catch(function(e){return p.maybeReportError(e)}))}):I.fetchFlagSettings(A.getUser(),b).then(function(e){T=e||{},ne()}).catch(function(e){T={},te(e)})}):Promise.reject(new ae(De()))).catch(te);function ee(e){w=e.environment,A.setUser(e.user),T=oe({},e.flags),ve(ne)}function ne(){g.info("LaunchDarkly client initialized"),N=!0,Q(),m.signalSuccess()}function te(e){m.signalFailure(e)}return{client:{waitForInitialization:function(){return m.getInitializationPromise()},waitUntilReady:function(){return m.getReadyPromise()},identify:function(e,r,n){return x?ge(Promise.resolve({}),n):F?(g.warn("identify() has no effect here; it must be called on the main client instance"),ge(Promise.resolve(pe(T)),n)):ge((a&&_?_.clearFlags():Promise.resolve()).then(function(){return q.validateUser(e)}).then(function(t){return I.fetchFlagSettings(t,r).then(function(e){var n=pe(e);return A.setUser(t),b=r,e?X(e).then(function(){return n}):n})}).then(function(e){return o&&B(),e}).catch(function(e){return p.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return A.getUser()},variation:function(e,n){return M(e,n,!0,!1).value},variationDetail:function(e,n){return M(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&g.warn(Ee(e));var r=A.getUser(),o={kind:"custom",key:e,user:r,url:i.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=K(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),z(o)}else p.maybeReportError(new ue(Ee(e)))},alias:$,on:function(e,n,t){Y(e)?(u=!0,N&&Q(),p.on(e,n,t)):p.on.apply(p,arguments)},off:function(e){if(p.off.apply(p,arguments),Y(e)){var n=!1;p.getEvents().forEach(function(e){Y(e)&&0<p.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,o&&void 0===L&&G())}},setStreaming:function(e){var n=null===e?void 0:e;n!==L&&(L=n,Q())},flush:function(e){return ge(y?j.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!T)return e;for(var n in T)he(T,n)&&(e[n]=M(n,null,!h.sendEventsOnlyForVariation).value);return e},close:function(e){if(x)return ge(Promise.resolve(),e);function n(){x=!0,T={}}return ge(Promise.resolve().then(function(){if(G(),P&&P.stop(),y)return j.stop(),j.flush()}).then(n).catch(n),e)}},options:h,emitter:p,ident:A,logger:g,requestor:I,start:function(){y&&(P&&P.start(),j.start())},enqueueEvent:z,getFlagsInternal:function(){return T},getEnvironmentId:function(){return w},internalChangeEventName:"internal-change"}}function te(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 Me(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?te(Object(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)):te(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}var He={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Ke(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 He;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})Object.prototype.hasOwnProperty.call(t,a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),He;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,Be=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace($e,"\\$&")};function Ge(e,n,t,r){var o,i,a=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?n:n.replace(r,"")).replace(t,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+Be(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+Be(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+Be(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Xe(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(Ge(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 We=300;function Qe(o,n){var t,r;function i(){r&&r.dispose(),t&&t.length&&(r=Xe(t,a))}function a(e,n){var t=o.ident.getUser(),r={kind:e,key:n.key,data:null,url:window.location.href,user:t,creationDate:(new Date).getTime()};return t&&t.anonymous&&(r.contextKind="anonymousUser"),"click"===e&&(r.selector=n.selector),o.enqueueEvent(r)}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 o.requestor.fetchJSON("/sdk/goals/"+o.getEnvironmentId()).then(function(e){e&&0<e.length&&(r=Xe(t=e,a),u(We,i)),n()}).catch(function(e){o.emitter.maybeReportError(new s.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),{}}var Ye="goalsReady",Ze={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function en(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var n,i={synchronousFlush:!1};if(window.XMLHttpRequest){var a=e&&e.disableSyncEventPost;i.httpRequest=function(e,n,t,r){var o=i.synchronousFlush&!a;return i.synchronousFlush=!1,Ke(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=Me(Me({},{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.20.2",i.diagnosticSdkData={name:"js-client-sdk",version:"2.20.2"},i.diagnosticPlatformData={name:"JS"},i.diagnosticUseCombinedEvent=!0,i}(t),o=ne(e,n,t,r,Ze),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(Ye,function(){u.off(Ye,n),e()})});i.waitUntilGoalsReady=function(){return s},a.fetchGoals?Qe(o,function(){return u.emit(Ye)}):u.emit(Ye),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function c(){r.synchronousFlush=!0,i.flush().catch(function(){}),r.synchronousFlush=!1}return window.addEventListener("beforeunload",c),window.addEventListener("unload",c),i}var nn=qe;var tn={initialize:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(W.deprecated("default export","named LDClient export")),en(e,n,t)},version:"2.20.2"};e.createConsoleLogger=nn,e.default=tn,e.initialize=en,e.version="2.20.2",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).LDClient={})}(this,function(e){"use strict";function re(e){return(re="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 oe(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 f(e){return function(e){if(Array.isArray(e)){for(var n=0,t=new Array(e.length);n<e.length;n++)t[n]=e[n];return t}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function t(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var ie=t("LaunchDarklyUnexpectedResponseError"),ae=t("LaunchDarklyInvalidEnvironmentIdError"),i=t("LaunchDarklyInvalidUserError"),ue=t("LaunchDarklyInvalidEventKeyError"),g=t("LaunchDarklyInvalidArgumentError"),se=t("LaunchDarklyFlagFetchError"),ce=t("LaunchDarklyInvalidDataError");function le(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var s=Object.freeze({__proto__:null,LDUnexpectedResponseError:ie,LDInvalidEnvironmentIdError:ae,LDInvalidUserError:i,LDInvalidEventKeyError:ue,LDInvalidArgumentError:g,LDFlagFetchError:se,LDInvalidDataError:ce,isHttpErrorRecoverable:le}),r=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(d(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=[],a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=a.length;c<l;++c)u[c]=a[c],o[a.charCodeAt(c)]=c;function d(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 v=Array.isArray,p=Object.keys,m=Object.prototype.hasOwnProperty,h=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function y(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 O(e){return y(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function fe(e){return JSON.parse(JSON.stringify(e))}function de(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=v(n),u=v(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=p(n);if((o=d.length)!==p(t).length)return!1;for(r=o;0!=r--;)if(!m.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 ve(e){setTimeout(e,0)}function ge(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 w(e){var n={};for(var t in e)he(e,t)&&(n[t]={value:e[t],version:0});return n}function pe(e){var n={};for(var t in e)he(e,t)&&(n[t]=e[t].value);return n}function b(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 k(e){var n=e.version||"3.5.1";return e.userAgent+"/"+n}function S(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":k(e)};return n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),t}function P(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(oe({},e)):e}function me(){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 oe({},e,{},n)},{})}function he(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function ye(e){if(!e)return e;var n;for(var t in h){var r=h[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||oe({},e))[r]=String(o))}return n||e}for(var E,D=Object.freeze({__proto__:null,btoa:y,base64URLEncode:O,clone:fe,deepEquals:de,onNextTick:ve,wrapPromiseCallback:ge,transformValuesToVersionedValues:w,transformVersionedValuesToValues:pe,chunkUserEventsForUrl:b,getLDUserAgentString:k,getLDHeaders:S,transformHeaders:P,extend:me,objectHasOwnProperty:he,sanitizeUser:ye}),U=(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),j=[],I=0;I<256;++I)j[I]=(I+256).toString(16).substr(1);var R,T,L=0,N=0,x=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||R,a=void 0!==e.clockseq?e.clockseq:T;if(null==i||null==a){var u=U();null==i&&(i=R=[1|u[0],u[1],u[2],u[3],u[4],u[5]]),null==a&&(a=T=16383&(u[6]<<8|u[7]))}var s=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:N+1,l=s-L+(c-N)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||L<s)&&void 0===e.nsecs&&(c=0),1e4<=c)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");L=s,T=a;var f=(1e4*(268435455&(s+=122192928e5))+(N=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||function(e,n){var t=n||0,r=j;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}(o)};function we(u,e,s){var t="/a/"+e+".gif",c=me({"Content-Type":"application/json"},S(u,s)),l=u.httpFallbackPing,f={sendChunk:function(e,r,o,n){var i=JSON.stringify(e),a=o?null:x();return n?function n(t){var e=o?c:me({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",r,P(e,s),i).promise.then(function(e){if(e)return 400<=e.status&&le(e.status)&&t?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)}).catch(function(){return t?n(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(r+t+"?d="+O(i)),Promise.resolve())},sendEvents:function(e,n,t){if(!u.httpRequest)return Promise.resolve();var r,o=u.httpAllowsPost();r=o?[e]:b(2e3-n.length,e);for(var i=[],a=0;a<r.length;a++)i.push(f.sendChunk(r[a],n,t,o));return Promise.all(i)}};return f}function be(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=me({},o,i[1])}var u=Object.keys(o);return u.length&&(u.sort(),r.privateAttrs=u),r},n}function C(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var F=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",A=function(e){return'Expected application/json content type but got "'+e+'"'},ke=function(e){return"local storage is unavailable: "+C(e)},q=function(e){return"network error"+(e?" ("+e+")":"")},Ee=function(e){return'Custom event "'+e+'" does not exist'},_=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+F},De=function(){return"No environment/client-side ID was specified."+F},Oe=function(e){return"Error fetching flag settings: "+C(e)},V=function(){return"No user specified."+F},z=function(){return"Invalid user specified."+F},Se=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+F},J=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+" - "+(le(e)?t:"giving up permanently")},M=function(){return"Cannot make HTTP requests in this environment."+F},H=function(e){return"Opening stream connection to "+e},K=function(e,n){return"Error on stream connection: "+C(e)+", will continue retrying every "+n+" milliseconds."},$=function(e){return'Ignoring unknown config option "'+e+'"'},B=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},G=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},X=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},W=function(e){return"polling for feature flags at "+e},Ue=function(e){return'received streaming update for flag "'+e+'"'},je=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Ie=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'},Le=function(e){return"sending "+e+" events"},Q=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/sdk/features/identify#javascript"},invalidContentType:A,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ke,networkError:q,unknownCustomEventKey:Ee,environmentNotFound:_,environmentNotSpecified:De,errorFetchingFlags:Oe,userNotSpecified:V,invalidUser:z,invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},bootstrapOldFormat:Se,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:J,httpErrorMessage:Pe,httpUnavailable:M,identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},streamClosing:function(){return"Closing stream connection"},streamConnecting:H,streamError:K,unknownOption:$,wrongOptionType:B,wrongOptionTypeBoolean:G,optionBelowMinimum:X,debugPolling:W,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:Ue,debugStreamPatchIgnored:je,debugStreamDelete:Ie,debugStreamDeleteIgnored:Re,debugEnqueueingEvent:Te,debugPostingEvents:Le,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"}});var Ne=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 xe(t,r,o,i){var a={};function u(){var e="",n=i.getUser();return n&&(e=o||y(JSON.stringify(n))),"ld:"+r+":"+e}return a.loadFlags=function(){return t.get(u()).then(function(e){if(null==e)return null;try{var n=JSON.parse(e);if(n){var t=n.$schema;void 0===t||t<1?n=w(n):delete n.$schema}return n}catch(e){return a.clearFlags().then(function(){return null})}})},a.saveFlags=function(e){var n=me({},e,{$schema:1});return t.set(u(),JSON.stringify(n))},a.clearFlags=function(){return t.clear(u())},a}function Ce(o,i,a,n){var u,s=i.streamUrl,c=i.logger,e={},l=s+"/eval/"+a,f=i.useReport,d=i.evaluationReasons,t=i.streamReconnectDelay,v=S(o,i),g=!1,p=null,m=null,h=null,y=null,w=null;function b(e){g||(c.warn(K(e,t)),g=!0),D(!1),E(),k(t)}function k(e){m||(e?m=setTimeout(r,e):r())}function r(){var e;m=null;var n="",t={headers:v,readTimeoutMillis:3e5};if(o.eventSourceFactory){for(var r in null!=y&&(n="h="+y),f?o.eventSourceAllowsReport?(e=l,t.method="REPORT",t.headers["Content-Type"]="application/json",t.body=JSON.stringify(h)):(e=s+"/ping/"+a,n=""):e=l+"/"+O(JSON.stringify(h)),t.headers=P(t.headers,i),d&&(n=n+(n?"&":"")+"withReasons=true"),e=e+(n?"?":"")+n,E(),c.info(H(e)),u=(new Date).getTime(),p=o.eventSourceFactory(e,t),w)he(w,r)&&p.addEventListener(r,w[r]);p.onerror=b}}function E(){p&&(c.info("Closing stream connection"),p.close(),p=null)}function D(e){u&&n&&n.recordStreamInit(u,!e,(new Date).getTime()-u),u=null}return e.connect=function(e,n,t){h=e,y=n,w={};function r(n){w[n]=function(e){D(!(g=!1)),t[n]&&t[n](e)}}for(var o in t||{})r(o);k()},e.disconnect=function(){clearTimeout(m),m=null,E()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function Fe(v,g,a){var u=g.baseUrl,s=g.useReport,c=g.evaluationReasons,l=g.logger,e={},p={};function f(e,n){if(!v.httpRequest)return new Promise(function(e,n){n(new se(M()))});var t=n?"REPORT":"GET",r=S(v,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=v.httpRequest(t,e,P(r,g),n),d=f.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new ae(_()):new se(Oe(n.statusText||String(n.status))));if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n,t=A(e.header("content-type")||"");return Promise.reject(new se(t))},function(e){return Promise.reject(new se(q(e)))});return l.addPromise(d,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=O(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(W(r)),f(r,o)},e}function Ae(o){var e={};return e.validateUser=function(e){if(!e)return Promise.reject(new i(V()));var r=fe(e);return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?o.get("ld:$anonUserId").then(function(e){if(e)return r.key=e,r;var n,t=x();return r.key=t,(n=t,o.set("ld:$anonUserId",n)).then(function(){return r})}):Promise.reject(new i(z()))},e}var Y=["debug","info","warn","error","none"];function Z(e,a){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var u=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],s=!(!e||!e.destination),c=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",r=1;if(e&&e.level)for(var t=0;t<Y.length;t++)Y[t]===e.level&&(r=t);for(var o={},i=function(e){var n=Y[e];if("none"!==n)if(e<r)o[n]=function(){};else{var t=e;o[n]=function(){!function(e,n,t){if(!(t.length<1)){var r,o=s?n+": "+c:c;if(1!==t.length&&a){var i=f(t);i[0]=o+i[0],r=a.apply(void 0,f(i))}else r=o+t[0];try{u[e](r)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}(t,n,arguments)}}},l=0;l<Y.length;l++)i(l);return o}function qe(e,n){return Z({level:e,prefix:n})}var ee={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1}};function _e(e,n,t,r){var a=me({logger:{default:r}},ee,t),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){ve(function(){n&&n.maybeReportError(new g(e))})}var i,s,c,l,f,d=me({},e||{});return f=d,Object.keys(o).forEach(function(e){if(void 0!==f[e]){var n=o[e];r&&r.warn(J(e,n)),n&&(void 0===f[n]&&(f[n]=f[e]),delete f[e])}}),i=(l=me({},d),Object.keys(a).forEach(function(e){void 0!==l[e]&&null!==l[e]||(l[e]=a[e]&&a[e].default)}),s=d=l,c=me({},s),Object.keys(s).forEach(function(e){var n=s[e];if(null!=n){var t=a[e];if(void 0===t)u($(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(G(e,i))):(u(B(e,r,i)),c[e]=t.default):"number"===i&&void 0!==t.minimum&&n<t.minimum&&(u(X(e,n,t.minimum)),c[e]=t.minimum)}}}}),d=c).logger,Y.forEach(function(e){if("none"!==e&&(!i[e]||"function"!=typeof i[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")}),d;function v(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=re(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}}}var ne=Object.freeze({__proto__:null,baseOptionDefs:ee,validate:_e}).baseOptionDefs,Ve=function(e){var n={diagnosticId:x()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},ze=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}},Je=function(n,r,e,t,o,i,a){var u,s,c=!!n.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",f=i.eventsUrl+"/events/diagnostic/"+o,d=i.diagnosticRecordingInterval,v=e,g=!!i.streaming,p={};function m(){return{sdk:function(){var e=oe({},n.diagnosticSdkData);return i.wrapperName&&(e.wrapperName=i.wrapperName),i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion),e}(),configuration:(e={customBaseURI:i.baseUrl!==ne.baseUrl.default,customStreamURI:i.streamUrl!==ne.streamUrl.default,customEventsURI:i.eventsUrl!==ne.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!g,allAttributesPrivate:!!i.allAttributesPrivate,inlineUsersInEvents:!!i.inlineUsersInEvents,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,allowFrequentDuplicateEvents:!!i.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation,autoAliasingOptOut:!!i.autoAliasingOptOut},e),platform:n.diagnosticPlatformData};var e}function h(e){i.logger&&i.logger.debug(Q.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function y(){var e,n;h((e=(new Date).getTime(),n=oe({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:e},v.getProps()),c&&(n=oe({},n,{},m())),v.reset(e),n)),s=setTimeout(y,d),u=(new Date).getTime(),c&&function(){if(r.isEnabled()){var e=oe({},v.getProps());r.set(l,JSON.stringify(e))}}()}return p.start=function(){c?function(t){if(!r.isEnabled())return t(!1);r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),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(oe({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 te(e,n,t,i,r){var a,o,u,s,c,l,f,d,v,g=t&&t.logger?t.logger:r&&r.logger&&r.logger.default||qe("warn"),p=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}(g),m=Ne(p),h=_e(t,p,r,g),y=h.sendEvents,w=e,b=h.hash,k=(l=i.localStorage,f=g,v=!(d={}),d.isEnabled=function(){return!!l},d.get=function(e){return new Promise(function(n){l?l.get(e).then(n).catch(function(e){V(e),n(void 0)}):n(void 0)})},d.set=function(e,t){return new Promise(function(n){l?l.set(e,t).then(function(){return n(!0)}).catch(function(e){V(e),n(!1)}):n(!1)})},d.clear=function(e){return new Promise(function(n){l?l.clear(e).then(function(){return n(!0)}).catch(function(e){V(e),n(!1)}):n(!1)})},d),E=we(i,w,h),D=h.sendEvents&&!h.diagnosticOptOut,O=D?Ve(w):null,S=D?ze((new Date).getTime()):null,P=D?Je(i,k,S,E,w,h,O):null,U=Ce(i,h,w,S),j=h.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)||we(e,t,n),f=n.eventsUrl+"/events/bulk/"+t,d=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}(),v=be(n),g=n.inlineUsersInEvents,p=n.samplingInterval,m=n.eventCapacity,h=n.flushInterval,y=n.logger,w=[],b=0,k=!1,E=!1;function D(){return 0===p||0===Math.floor(Math.random()*p)}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.")),u&&u.incrementDroppedEvents())}return c.enqueue=function(e){if(!k){var n=!1,t=!1;if(d.summarizeEvent(e),"feature"===e.kind?D()&&(n=!!e.trackEvents,t=function(e){return!!e.debugEventsUntilDate&&e.debugEventsUntilDate>b&&e.debugEventsUntilDate>(new Date).getTime()}(e)):n=D(),n&&O(function(e){var n=me({},e);return"alias"===e.kind||(g||"identify"===e.kind?n.user=v.filterUser(e.user):(n.userKey=e.user.key,delete n.user),"feature"===e.kind&&(delete n.trackEvents,delete n.debugEventsUntilDate)),n}(e)),t){var r=me({},e,{kind:"debug"});r.user=v.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,O(r)}}},c.flush=function(){if(k)return Promise.resolve();var e=w,n=d.getSummary();return d.clearSummary(),n&&(n.kind="summary",e.push(n)),u&&u.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(w=[],y.debug(Le(e.length)),l.sendEvents(e,f).then(function(e){e&&(e.serverTime&&(b=e.serverTime),le(e.status)||(k=!0),400<=e.status&&ve(function(){s.maybeReportError(new ie(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}(i,h,w,S,p,E),I=Fe(i,h,w),R={},T={},L=h.streaming,N=!1,x=!1,C=!0,F=h.stateProvider,A=(s=function(e,n){var t;t=e,F||t&&z({kind:"identify",key:t.key,user:t,creationDate:(new Date).getTime()}),!h.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&$(e,n)},{setUser:function(e){var n=c&&fe(c);(c=ye(e))&&s&&s(fe(c),n)},getUser:function(){return c?fe(c):null}}),q=Ae(k),_=k.isEnabled()?new xe(k,w,b,A,g):null;function V(e){v||(v=!0,f.warn(ke(e)))}function z(e){if(w&&!(F&&F.enqueueEvent&&F.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(C&&(g.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),C=!1));C=!1}!y||x||i.isDoNotTrack()||(g.debug(Te(e.kind)),j.enqueue(e))}}function J(e,n,t,r){var o=A.getUser(),i=new Date,a=n?n.value:null;if(!h.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=R[u];if(s&&i-s<3e5)return;R[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()};o&&o.anonymous&&(c.contextKind=K(o));var l=T[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),z(c)}function M(e,n,t,r){var o;if(T&&he(T,e)&&T[e]&&!T[e].deleted){var i=T[e];o=H(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&J(e,o,n,r),o}function H(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function K(e){return e.anonymous?"anonymousUser":"user"}function $(e,n){F||e&&n&&z({kind:"alias",key:e.key,contextKind:K(e),previousKey:n.key,previousContextKind:K(n),creationDate:(new Date).getTime()})}function B(){if(o=!0,A.getUser()){var a=function(e){try{return JSON.parse(e)}catch(e){return void p.maybeReportError(new ce("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};U.connect(A.getUser(),b,{ping:function(){g.debug("received ping message from stream");var n=A.getUser();I.fetchFlagSettings(n,b).then(function(e){de(n,A.getUser())&&X(e||{})}).catch(function(e){p.maybeReportError(new se(Oe(e)))})},put:function(e){var n=a(e.data);n&&(g.debug("received streaming update for all flags"),X(n))},patch:function(e){var n=a(e.data);if(n){var t=T[n.key];if(!t||!t.version||!n.version||t.version<n.version){g.debug(Ue(n.key));var r={},o=me({},n);delete o.key;var i=H(T[n.key]=o);r[n.key]=t?{previous:t.value,current:i}:{current:i},W(r)}else g.debug(je(n.key))}},delete:function(e){var n=a(e.data);if(n)if(!T[n.key]||T[n.key].version<n.version){g.debug(Ie(n.key));var t={};T[n.key]&&!T[n.key].deleted&&(t[n.key]={previous:T[n.key].value}),T[n.key]={version:n.version,deleted:!0},W(t)}else g.debug(Re(n.key))}})}}function G(){o&&(U.disconnect(),o=!1)}function X(e){var n={};if(!e)return Promise.resolve();for(var t in T)he(T,t)&&T[t]&&(e[t]&&!de(e[t].value,T[t].value)?n[t]={previous:T[t].value,current:H(e[t])}:e[t]&&!e[t].deleted||(n[t]={previous:T[t].value}));for(var r in e)he(e,r)&&e[r]&&(!T[r]||T[r].deleted)&&(n[r]={current:H(e[r])});return T=oe({},e),W(n).catch(function(){})}function W(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;p.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),p.emit("change",i),p.emit("internal-change",T),h.sendEventsOnlyForVariation||F||e.forEach(function(e){J(e,o[e].current)})}return a&&_?_.saveFlags(T):Promise.resolve()}function Q(){var e=L||u&&void 0===L;e&&!o?B():!e&&o&&G(),P&&P.setStreaming(e)}function Y(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof h.bootstrap&&"LOCALSTORAGE"===h.bootstrap.toUpperCase()&&(_?a=!0:g.warn(ke())),"object"===re(h.bootstrap)&&(T=function(t){var e=Object.keys(t),r=t.$flagsState;!r&&e.length&&g.warn(Se()),!1===t.$valid&&g.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=me(n,r[e]):n.version=0,o[e]=n}}),o}(h.bootstrap)),F){var Z=F.getInitialState();Z?ee(Z):F.on("init",ee),F.on("update",function(e){e.user&&A.setUser(e.user),e.flags&&X(e.flags)})}else(e?q.validateUser(n).then(function(e){return A.setUser(e),"object"===re(h.bootstrap)?ne():a?_.loadFlags().then(function(e){return null==e?(T={},I.fetchFlagSettings(A.getUser(),b).then(function(e){return X(e||{})}).then(ne).catch(function(e){te(new se(Oe(e)))})):(T=e,ve(ne),I.fetchFlagSettings(A.getUser(),b).then(function(e){return X(e)}).catch(function(e){return p.maybeReportError(e)}))}):I.fetchFlagSettings(A.getUser(),b).then(function(e){T=e||{},ne()}).catch(function(e){T={},te(e)})}):Promise.reject(new ae(De()))).catch(te);function ee(e){w=e.environment,A.setUser(e.user),T=oe({},e.flags),ve(ne)}function ne(){g.info("LaunchDarkly client initialized"),N=!0,Q(),m.signalSuccess()}function te(e){m.signalFailure(e)}return{client:{waitForInitialization:function(){return m.getInitializationPromise()},waitUntilReady:function(){return m.getReadyPromise()},identify:function(e,r,n){return x?ge(Promise.resolve({}),n):F?(g.warn("identify() has no effect here; it must be called on the main client instance"),ge(Promise.resolve(pe(T)),n)):ge((a&&_?_.clearFlags():Promise.resolve()).then(function(){return q.validateUser(e)}).then(function(t){return I.fetchFlagSettings(t,r).then(function(e){var n=pe(e);return A.setUser(t),b=r,e?X(e).then(function(){return n}):n})}).then(function(e){return o&&B(),e}).catch(function(e){return p.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return A.getUser()},variation:function(e,n){return M(e,n,!0,!1).value},variationDetail:function(e,n){return M(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&g.warn(Ee(e));var r=A.getUser(),o={kind:"custom",key:e,user:r,url:i.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=K(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),z(o)}else p.maybeReportError(new ue(Ee(e)))},alias:$,on:function(e,n,t){Y(e)?(u=!0,N&&Q(),p.on(e,n,t)):p.on.apply(p,arguments)},off:function(e){if(p.off.apply(p,arguments),Y(e)){var n=!1;p.getEvents().forEach(function(e){Y(e)&&0<p.getEventListenerCount(e)&&(n=!0)}),n||(u=!1,o&&void 0===L&&G())}},setStreaming:function(e){var n=null===e?void 0:e;n!==L&&(L=n,Q())},flush:function(e){return ge(y?j.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!T)return e;for(var n in T)he(T,n)&&(e[n]=M(n,null,!h.sendEventsOnlyForVariation).value);return e},close:function(e){if(x)return ge(Promise.resolve(),e);function n(){x=!0,T={}}return ge(Promise.resolve().then(function(){if(G(),P&&P.stop(),y)return j.stop(),j.flush()}).then(n).catch(n),e)}},options:h,emitter:p,ident:A,logger:g,requestor:I,start:function(){y&&(P&&P.start(),j.start())},enqueueEvent:z,getFlagsInternal:function(){return T},getEnvironmentId:function(){return w},internalChangeEventName:"internal-change"}}function Me(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 He(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Me(Object(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)):Me(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}var Ke=Object.freeze({__proto__:null,commonBasicLogger:Z,createConsoleLogger:qe,errors:s,initialize:te,messages:Q,utils:D,version:"3.5.1"}).commonBasicLogger;function $e(e){return Ke(He({destination:console.log},e))}var Be={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Ge(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 Be;var i=new window.XMLHttpRequest;for(var a in i.open(e,n,!o),t||{})Object.prototype.hasOwnProperty.call(t,a)&&i.setRequestHeader(a,t[a]);if(o)return i.send(r),Be;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 Xe=/[|\\{}()[\]^$+*?.]/g,We=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(Xe,"\\$&")};function Qe(e,n,t,r){var o,i,a=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?n:n.replace(r,"")).replace(t,"");switch(e.kind){case"exact":i=n,o=new RegExp("^"+We(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+We(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+We(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Ye(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(Qe(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 en(o,n){var t,r;function i(){r&&r.dispose(),t&&t.length&&(r=Ye(t,a))}function a(e,n){var t=o.ident.getUser(),r={kind:e,key:n.key,data:null,url:window.location.href,user:t,creationDate:(new Date).getTime()};return t&&t.anonymous&&(r.contextKind="anonymousUser"),"click"===e&&(r.selector=n.selector),o.enqueueEvent(r)}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 o.requestor.fetchJSON("/sdk/goals/"+o.getEnvironmentId()).then(function(e){e&&0<e.length&&(r=Ye(t=e,a),u(Ze,i)),n()}).catch(function(e){o.emitter.maybeReportError(new s.LDUnexpectedResponseError((e&&e.message,e.message))),n()}),{}}var nn="goalsReady",tn={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function rn(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var n,i={synchronousFlush:!1};if(window.XMLHttpRequest){var a=e&&e.disableSyncEventPost;i.httpRequest=function(e,n,t,r){var o=i.synchronousFlush&!a;return i.synchronousFlush=!1,Ge(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=He(He({},{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.21.0",i.diagnosticSdkData={name:"js-client-sdk",version:"2.21.0"},i.diagnosticPlatformData={name:"JS"},i.diagnosticUseCombinedEvent=!0,i}(t),o=te(e,n,t,r,tn),i=o.client,a=o.options,u=o.emitter,s=new Promise(function(e){var n=u.on(nn,function(){u.off(nn,n),e()})});i.waitUntilGoalsReady=function(){return s},a.fetchGoals?en(o,function(){return u.emit(nn)}):u.emit(nn),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();function c(){r.synchronousFlush=!0,i.flush().catch(function(){}),r.synchronousFlush=!1}return window.addEventListener("beforeunload",c),window.addEventListener("unload",c),i}var on=$e,an=qe;var un={initialize:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Q.deprecated("default export","named LDClient export")),rn(e,n,t)},version:"2.21.0"};e.basicLogger=on,e.createConsoleLogger=an,e.default=un,e.initialize=rn,e.version="2.21.0",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=ldclient.min.js.map |
{ | ||
"name": "launchdarkly-js-client-sdk", | ||
"version": "2.20.2", | ||
"version": "2.21.0", | ||
"description": "LaunchDarkly SDK for JavaScript", | ||
@@ -5,0 +5,0 @@ "author": "LaunchDarkly <team@launchdarkly.com>", |
@@ -13,3 +13,9 @@ /** | ||
export * from 'launchdarkly-js-sdk-common'; | ||
import { LDClientBase, LDOptionsBase, LDUser } from 'launchdarkly-js-sdk-common'; | ||
import { | ||
BasicLoggerOptions, | ||
LDClientBase, | ||
LDLogger, | ||
LDOptionsBase, | ||
LDUser | ||
} from 'launchdarkly-js-sdk-common'; | ||
//// DOCBUILD-END-REPLACE | ||
@@ -121,2 +127,32 @@ | ||
} | ||
/** | ||
* Provides a simple [[LDLogger]] implementation. | ||
* | ||
* This logging implementation uses a simple format that includes only the log level | ||
* and the message text. By default, output is written to `console` methods (`console.info` | ||
* for normal informational messages, `console.warn` for warnings, `console.error` for | ||
* errors, and `console.log` for debug output) and the default minimum level is `info` | ||
* (that is, debug output is suppressed). You can filter by log level or change the output | ||
* destination with [[BasicLoggerOptions]]. | ||
* | ||
* To use the logger created by this function, put it into [[LDOptions.logger]]. If | ||
* you do not set [[LDOptions.logger]] to anything, the SDK uses a default logger | ||
* that is equivalent to `ld.basicLogger({ level: 'info' })`. | ||
* | ||
* @param options Configuration for the logger. If no options are specified, the | ||
* logger uses `{ level: 'info' }`. | ||
* | ||
* @example | ||
* This example shows how to use `basicLogger` in your SDK options to enable console | ||
* logging only at `warn` and `error` levels. | ||
* ```javascript | ||
* const ldOptions = { | ||
* logger: ld.basicLogger({ level: 'warn' }), | ||
* }; | ||
* ``` | ||
*/ | ||
export function basicLogger( | ||
options?: BasicLoggerOptions | ||
): LDLogger; | ||
} |
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
488958
613