launchdarkly-js-client-sdk
Advanced tools
Comparing version 2.22.0 to 2.22.1
@@ -5,2 +5,12 @@ # Change log | ||
## [2.22.0] - 2022-04-26 | ||
### Added: | ||
- `LDOptions.application`, for configuration of application metadata that may be used in LaunchDarkly analytics or other product features. This does not affect feature flag evaluations. | ||
### Fixed: | ||
- The `baseUrl`, `streamUrl`, and `eventsUrl` properties now work properly regardless of whether the URL string has a trailing slash. Previously, a trailing slash would cause request URL paths to have double slashes. | ||
### Removed: | ||
- The `package-lock.json` file is no longer in source control. As this is a library project, the lockfile never affected application code that used the SDK, but only affected the SDK's CI build. It is preferable for the CI build to refer only to `package.json` so that it resolves dependencies the same way an application using the SDK would, rather than using pinned dependencies that an application would not use. | ||
## [2.21.0] - 2022-03-21 | ||
@@ -7,0 +17,0 @@ ### Added: |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(n,e){var t,r=Object.keys(n);return Object.getOwnPropertySymbols&&(t=Object.getOwnPropertySymbols(n),e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),r.push.apply(r,t)),r}function n(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?e(Object(o),!0).forEach(function(e){r(n,e,o[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))})}return n}function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||function(e){if(e){if("string"==typeof e)return o(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(n="Object"===n&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,void 0):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function a(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}Object.defineProperty(exports,"__esModule",{value:!0});var u=a("LaunchDarklyUnexpectedResponseError"),s=a("LaunchDarklyInvalidEnvironmentIdError"),c=a("LaunchDarklyInvalidUserError"),l=a("LaunchDarklyInvalidEventKeyError"),f=a("LaunchDarklyInvalidArgumentError"),v=a("LaunchDarklyFlagFetchError"),d=a("LaunchDarklyInvalidDataError");function g(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var p=Object.freeze({__proto__:null,LDUnexpectedResponseError:u,LDInvalidEnvironmentIdError:s,LDInvalidUserError:c,LDInvalidEventKeyError:l,LDInvalidArgumentError:f,LDFlagFetchError:v,LDInvalidDataError:d,isHttpErrorRecoverable:g}),m=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(w(e,i,a<i+16383?a:i+16383));return 1==r?(n=e[t-1],o.push(y[n>>2]+y[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(y[n>>10]+y[n>>4&63]+y[n<<2&63]+"=")),o.join("")},y=[],h=[],b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k=0,E=b.length;k<E;++k)y[k]=b[k],h[b.charCodeAt(k)]=k;function w(e,n,t){for(var r,o=[],i=n;i<t;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(y[(r=r)>>18&63]+y[r>>12&63]+y[r>>6&63]+y[63&r]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63;var D=Array.isArray,O=Object.keys,S=Object.prototype.hasOwnProperty,P=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function U(e,n){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(n.startsWith("/")?"":"/")+n}function I(e){e=unescape(encodeURIComponent(e));return m(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(e))}function j(e){return I(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function T(e){return JSON.parse(JSON.stringify(e))}function R(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=D(n),u=D(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;a=n instanceof Date,u=t instanceof Date;if(a!=u)return!1;if(a&&u)return n.getTime()==t.getTime();a=n instanceof RegExp,u=t instanceof RegExp;if(a!=u)return!1;if(a&&u)return n.toString()==t.toString();var s=O(n);if((o=s.length)!==O(t).length)return!1;for(r=o;0!=r--;)if(!S.call(t,s[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=s[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function A(e){setTimeout(e,0)}function L(e,n){e=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:e}function C(e){var n,t={};for(n in e)V(e,n)&&(t[n]={value:e[n],version:0});return t}function F(e){var n,t={};for(n in e)V(e,n)&&(t[n]=e[n].value);return t}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-=j(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function x(e){var n=e.version||"3.6.0";return e.userAgent+"/"+n}function q(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.reduce(function(e,t){return n(n({},e),t)},{})}function V(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function _(e){if(!e)return e;var t,r;for(r in P){var o=P[r],i=e[o];void 0!==i&&"string"!=typeof i&&((t=t||n({},e))[o]=String(i))}return t||e}for(var z=Object.freeze({__proto__:null,appendUrlPath:U,btoa:I,base64URLEncode:j,clone:T,deepEquals:R,onNextTick:A,wrapPromiseCallback:L,transformValuesToVersionedValues:C,transformVersionedValuesToValues:F,chunkUserEventsForUrl:N,getLDUserAgentString:x,extend:q,objectHasOwnProperty:V,sanitizeUser:_}),J=function(e){var n=e={exports:{}},t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);{var r,o;t?(r=new Uint8Array(16),n.exports=function(){return t(r),r}):(o=new Array(16),n.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),o[n]=e>>>((3&n)<<3)&255;return o})}return e.exports}(),M=[],K=0;K<256;++K)M[K]=(K+256).toString(16).substr(1);var $,B,H=function(e,n){var n=n||0,t=M;return[t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],t[e[+n]]].join("")},G=0,W=0,X=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||$,t=void 0!==e.clockseq?e.clockseq:B,a=(null!=i&&null!=t||(a=J(),null==i&&(i=$=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==t&&(t=B=16383&(a[6]<<8|a[7]))),void 0!==e.msecs?e.msecs:(new Date).getTime()),u=void 0!==e.nsecs?e.nsecs:W+1,s=a-G+(u-W)/1e4;if(s<0&&void 0===e.clockseq&&(t=t+1&16383),1e4<=(u=(s<0||G<a)&&void 0===e.nsecs?0:u))throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");G=a,B=t;s=(1e4*(268435455&(a+=122192928e5))+(W=u))%4294967296,o[r++]=s>>>24&255,o[r++]=s>>>16&255,o[r++]=s>>>8&255,o[r++]=255&s,e=a/4294967296*1e4&268435455;o[r++]=e>>>8&255,o[r++]=255&e,o[r++]=e>>>24&15|16,o[r++]=e>>>16&255,o[r++]=t>>>8|128,o[r++]=255&t;for(var c=0;c<6;++c)o[r+c]=i[c];return n||H(o)},Q=["debug","info","warn","error","none"];function Y(e,s){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 c=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],l=!(!e||!e.destination),f=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",t=1;if(e&&e.level)for(var r=0;r<Q.length;r++)Q[r]===e.level&&(t=r);for(var o={},a=function(e){var a,u=Q[e];"none"!==u&&(e<t?o[u]=function(){}:(a=e,o[u]=function(){var e=a,n=u,t=arguments;if(!(t.length<1)){var r=l?n+": "+f:f,o=1!==t.length&&s?((o=i(t))[0]=r+o[0],s.apply(void 0,i(o))):r+t[0];try{c[e](o)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}))},u=0;u<Q.length;u++)a(u);return o}function Z(e,n){return Y({level:e,prefix:n})}function ee(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var ne=function(){return"LaunchDarkly client initialized"},te=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",re=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},ie=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},oe=function(e){return'Expected application/json content type but got "'+e+'"'},ae=function(e){return"local storage is unavailable: "+ee(e)},ue=function(e){return"network error"+(e?" ("+e+")":"")},se=function(e){return'Custom event "'+e+'" does not exist'},ce=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+te},le=function(){return"No environment/client-side ID was specified."+te},fe=function(e){return"Error fetching flag settings: "+ee(e)},ve=function(){return"No user specified."+te},de=function(){return"Invalid user specified."+te},ge=function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},pe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+te},me=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},ye=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},he=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(g(e)?t:"giving up permanently")},be=function(){return"Cannot make HTTP requests in this environment."+te},ke=function(){return"identify() has no effect here; it must be called on the main client instance"},Ee=function(){return"Closing stream connection"},we=function(e){return"Opening stream connection to "+e},De=function(e,n){return"Error on stream connection: "+ee(e)+", will continue retrying every "+n+" milliseconds."},Oe=function(e){return'Ignoring unknown config option "'+e+'"'},Se=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Pe=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Ue=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Ie=function(e){return"polling for feature flags at "+e},je=function(){return"received ping message from stream"},Te=function(){return"received streaming update for all flags"},Re=function(e){return'received streaming update for flag "'+e+'"'},Ae=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Le=function(e){return'received streaming deletion for flag "'+e+'"'},Ce=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Fe=function(e){return'enqueueing "'+e+'" event'},Ne=function(e){return"sending "+e+" events"},xe=function(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')},qe=Object.freeze({__proto__:null,clientInitialized:ne,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:re,eventWithoutUser:ie,invalidContentType:oe,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ae,networkError:ue,unknownCustomEventKey:se,environmentNotFound:ce,environmentNotSpecified:le,errorFetchingFlags:fe,userNotSpecified:ve,invalidUser:de,invalidData:ge,bootstrapOldFormat:pe,bootstrapInvalid:me,deprecated:ye,httpErrorMessage:he,httpUnavailable:be,identifyDisabled:ke,streamClosing:Ee,streamConnecting:we,streamError:De,unknownOption:Oe,wrongOptionType:Se,wrongOptionTypeBoolean:Pe,optionBelowMinimum:Ue,debugPolling:Ie,debugStreamPing:je,debugStreamPut:Te,debugStreamPatch:Re,debugStreamPatchIgnored:Ae,debugStreamDelete:Le,debugStreamDeleteIgnored:Ce,debugEnqueueingEvent:Fe,debugPostingEvents:Ne,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},invalidTagValue:xe}),Ve={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:function(e,n,t,r){var o={};return t.id&&(o.id=ze("".concat(e,".id"),n,t.id,r)),t.version&&(o.version=ze("".concat(e,".version"),n,t.version,r)),o}}},_e=/^(\w|\.|-)+$/;function ze(e,n,t,r){if("string"==typeof t&&t.match(_e))return t;r.warn(xe(e))}function Je(e,n,r,a){var u=q({logger:{default:a}},Ve,r),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function s(e){A(function(){n&&n.maybeReportError(new f(e))})}var i,c,l,d,v,r=q({},e||{});return v=r,Object.keys(o).forEach(function(e){var n;void 0!==v[e]&&(n=o[e],a&&a.warn(ye(e,n)),n&&(void 0===v[n]&&(v[n]=v[e]),delete v[e]))}),i=(d=q({},r),Object.keys(u).forEach(function(e){void 0!==d[e]&&null!==d[e]||(d[e]=u[e]&&u[e].default)}),c=r=d,l=q({},c),Object.keys(c).forEach(function(e){var n,t,r,o,i=c[e];null!=i&&(void 0===(n=u[e])?s(Oe(e)):(t=n.type||g(n.default),(r=n.validator)?void 0!==(r=r(e,c,c[e],a))?l[e]=r:delete l[e]:"any"!==t&&(r=t.split("|"),o=g(i),r.indexOf(o)<0?"boolean"===t?(l[e]=!!i,s(Pe(e,o))):(s(Se(e,t,o)),l[e]=n.default):"number"===o&&void 0!==n.minimum&&i<n.minimum&&(s(Ue(e,i,n.minimum)),l[e]=n.minimum))))}),r=l).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")}),r;function g(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";e=t(e);return"boolean"===e||"string"===e||"number"===e||"function"===e?e:"object"}}}function Me(e){var n={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(n["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(n["application-version"]=[e.application.version])),n}function Ke(e,n){if(n&&!n.sendLDHeaders)return{};var e={"X-LaunchDarkly-User-Agent":x(e)},t=(n&&n.wrapperName&&(e["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),Me(n)),n=Object.keys(t);return n.length&&(e["x-launchdarkly-tags"]=n.sort().flatMap(function(n){return Array.isArray(t[n])?t[n].sort().map(function(e){return"".concat(n,"/").concat(e)}):["".concat(n,"/").concat(t[n])]}).join(" ")),e}function $e(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform(n({},e)):e}function Be(u,e,s){var r="/a/"+e+".gif",c=q({"Content-Type":"application/json"},Ke(u,s)),l=u.httpFallbackPing,f={};return f.sendChunk=function(e,n,o,t){var i=JSON.stringify(e),a=o?null:X();return t?function t(r){var e=o?c:q({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",n,$e(e,s),i).promise.then(function(e){if(e)return 400<=e.status&&g(e.status)&&r?t(!1):(n={status:(e=e).status},(e=(e=e.header("date"))&&Date.parse(e))&&(n.serverTime=e),n);var n}).catch(function(){return r?t(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(n+r+"?d="+j(i)),Promise.resolve())},f.sendEvents=function(e,n,t){if(!u.httpRequest)return Promise.resolve();for(var r=u.httpAllowsPost(),o=r?[e]:N(2e3-n.length,e),i=[],a=0;a<o.length;a++)i.push(f.sendChunk(o[a],n,t,r));return Promise.all(i)},f}function He(){var e={},a=0,u=0,s={};return e.summarizeEvent=function(e){var n,t;"feature"===e.kind&&(n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),(t=s[n])?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate))},e.getSummary=function(){var e,n={},t=!0;for(e in s){var r=s[e],o=n[r.key],i=(o||(o={default:r.default,counters:[]},n[r.key]=o),{value:r.value,count:r.count});void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),t=!1}return t?null:{startDate:a,endDate:u,features:n}},e.clearSummary=function(){u=a=0,s={}},e}function Ge(e){var n={},a=e.allAttributesPrivate,u=e.privateAttributeNames||[],s={key:!0,custom:!0,anonymous:!0},o={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(r,o){return Object.keys(r).reduce(function(e,n){var t;return o(n)&&(s[t=n]||!a&&-1===i.indexOf(t)&&-1===u.indexOf(t)?e[0][n]=r[n]:e[1][n]=!0),e},[{},{}])}var i=e.privateAttributeNames||[],t=n(e,function(e){return o[e]}),r=t[0],t=t[1],e=(e.custom&&(e=n(e.custom,function(){return 1}),r.custom=e[0],t=q({},t,e[1])),Object.keys(t));return e.length&&(e.sort(),r.privateAttrs=e),r},n}function We(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 Xe=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 Qe(n,t,r,o){var i={};function a(){var e="",n=o.getUser();return n&&(e=r||I(JSON.stringify(n))),"ld:"+t+":"+e}return i.loadFlags=function(){return n.get(a()).then(function(e){if(null==e)return null;try{var n,t=JSON.parse(e);return t&&(void 0===(n=t.$schema)||n<1?t=C(t):delete t.$schema),t}catch(e){return i.clearFlags().then(function(){return null})}})},i.saveFlags=function(e){e=q({},e,{$schema:1});return n.set(a(),JSON.stringify(e))},i.clearFlags=function(){return n.clear(a())},i}function Ye(o,i,a,n){var u,s=i.streamUrl,c=i.logger,e={},l=U(s,"/eval/"+a),f=i.useReport,d=i.evaluationReasons,t=i.streamReconnectDelay,v=Ke(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(){m=null;var e,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=U(s,"/ping/"+a),n=""):e=l+"/"+j(JSON.stringify(h)),t.headers=$e(t.headers,i),e=e+((n=d?n+(n?"&":"")+"withReasons=true":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={};for(var r in t||{})!function(n){w[n]=function(e){S(!(g=!1)),t[n]&&t[n](e)}}(r);k()},e.disconnect=function(){clearTimeout(m),m=null,E()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function Ze(g,p,i){var a=p.baseUrl,u=p.useReport,c=p.evaluationReasons,l=p.logger,e={},m={};function f(e,n){if(!g.httpRequest)return new Promise(function(e,n){n(new v(be()))});var t,r,o,i,a,u=n?"REPORT":"GET",c=Ke(g,p),l=(n&&(c["Content-Type"]="application/json"),m[e]),f=(l||(t=function(){delete m[e]},(d={addPromise:function(n,e){r=n,o&&o(),o=e,n.then(function(e){r===n&&(i(e),t())},function(e){r===n&&(a(e),t())})}}).resultPromise=new Promise(function(e,n){i=e,a=n}),l=d,m[e]=l),g.httpRequest(u,e,$e(c,p),n)),d=f.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new s(ce()):new v(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=oe(e.header("content-type")||"");return Promise.reject(new v(n))},function(e){return Promise.reject(new v(ue(e)))});return l.addPromise(d,function(){f.cancel&&f.cancel()}),l.resultPromise}return e.fetchJSON=function(e){return f(U(a,e),null)},e.fetchFlagSettings=function(e,n){var t,r,o="";return u?(t=[a,"/sdk/evalx/",i,"/user"].join(""),r=JSON.stringify(e)):(e=j(JSON.stringify(e)),t=[a,"/sdk/evalx/",i,"/users/",e].join("")),n&&(o="h="+n),l.debug(Ie(t=t+((o=c?o+(o?"&":"")+"withReasons=true":o)?"?":"")+o)),f(t,r)},e}function en(t){var e={validateUser:function(e){if(!e)return Promise.reject(new c(ve()));var n=T(e);return null!==n.key&&void 0!==n.key?(n.key=n.key.toString(),Promise.resolve(n)):n.anonymous?t.get("ld:$anonUserId").then(function(e){if(e)return n.key=e,n;e=X();return n.key=e,t.set("ld:$anonUserId",e).then(function(){return n})}):Promise.reject(new c(de()))}};return e}var nn=Object.freeze({__proto__:null,baseOptionDefs:Ve,validate:Je,getTags:Me}).baseOptionDefs,tn=z.appendUrlPath,rn=function(e){var n={diagnosticId:X()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},on=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){o.push({timestamp:e,failed:n,durationMillis:t})},reset:i}},an=function(t,r,e,o,i,a,u){var s,c,l=!!t.diagnosticUseCombinedEvent,f="ld:"+i+":$diagnostics",d=tn(a.eventsUrl,"/events/diagnostic/"+i),v=a.diagnosticRecordingInterval,g=e,p=!!a.streaming,i={};function m(){return{sdk:(e=n({},t.diagnosticSdkData),a.wrapperName&&(e.wrapperName=a.wrapperName),a.wrapperVersion&&(e.wrapperVersion=a.wrapperVersion),e),configuration:{customBaseURI:a.baseUrl!==nn.baseUrl.default,customStreamURI:a.streamUrl!==nn.streamUrl.default,customEventsURI:a.eventsUrl!==nn.eventsUrl.default,eventsCapacity:a.eventCapacity,eventsFlushIntervalMillis:a.flushInterval,reconnectTimeMillis:a.streamReconnectDelay,streamingDisabled:!p,allAttributesPrivate:!!a.allAttributesPrivate,inlineUsersInEvents:!!a.inlineUsersInEvents,diagnosticRecordingIntervalMillis:a.diagnosticRecordingInterval,usingSecureMode:!!a.hash,bootstrapMode:!!a.bootstrap,fetchGoalsDisabled:!a.fetchGoals,allowFrequentDuplicateEvents:!!a.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!a.sendEventsOnlyForVariation,autoAliasingOptOut:!!a.autoAliasingOptOut},platform:t.diagnosticPlatformData};var e}function h(e){a.logger&&a.logger.debug(qe.debugPostingDiagnosticEvent(e)),o.sendEvents(e,d,!0).then(function(){}).catch(function(){})}function y(){var e,t;h((t=(new Date).getTime(),e=n({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:t},g.getProps()),l&&(e=n(n({},e),m())),g.reset(t),e)),c=setTimeout(y,v),s=(new Date).getTime(),l&&r.isEnabled()&&(t=n({},g.getProps()),r.set(f,JSON.stringify(t)))}return i.start=function(){var t;l?(t=function(e){var n;e?(e=(s||0)+v)<=(n=(new Date).getTime())?y():c=setTimeout(y,e-n):0===Math.floor(4*Math.random())?y():c=setTimeout(y,v)},r.isEnabled()?r.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)}):t(!1)):(h(n({kind:"diagnostic-init",id:u,creationDate:g.getProps().dataSinceDate},m())),c=setTimeout(y,v))},i.stop=function(){c&&clearTimeout(c)},i.setStreaming=function(e){p=e},i};function un(ee,ne,e,i,r){var a,c,o,f,p,m,te,h,y,w,b,k=e&&e.logger?e.logger:r&&r.logger&&r.logger.default||Z("warn"),E=We(k),S=Xe(E),D=Je(e,E,r,k),O=D.sendEvents,P=ee,j=D.hash,r=(m=i.localStorage,te=k,h=!(e={}),e.isEnabled=function(){return!!m},e.get=function(e){return new Promise(function(n){m?m.get(e).then(n).catch(function(e){ve(e),n(void 0)}):n(void 0)})},e.set=function(e,t){return new Promise(function(n){m?m.set(e,t).then(function(){return n(!0)}).catch(function(e){ve(e),n(!1)}):n(!1)})},e.clear=function(e){return new Promise(function(n){m?m.clear(e).then(function(){return n(!0)}).catch(function(e){ve(e),n(!1)}):n(!1)})},e),e=Be(i,P,D),I=D.sendEvents&&!D.diagnosticOptOut,x=I?rn(P):null,re=I?on((new Date).getTime()):null,C=I?an(i,r,re,e,P,D,x):null,oe=Ye(i,D,P,re),N=D.eventProcessor||function(e,n,t,r,o,i){var a,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)||Be(e,t,n),d=U(n.eventsUrl,"/events/bulk/"+t),v=He(),p=Ge(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){var n,t,r;S||(n=t=!1,v.summarizeEvent(e),"feature"===e.kind?O()&&(t=!!e.trackEvents,n=!!(r=e).debugEventsUntilDate&&r.debugEventsUntilDate>E&&r.debugEventsUntilDate>(new Date).getTime()):t=O(),t&&P((t=q({},r=e),"alias"!==r.kind&&(m||"identify"===r.kind?t.user=p.filterUser(r.user):(t.userKey=r.user.key,delete t.user),"feature"===r.kind&&(delete t.trackEvents,delete t.debugEventsUntilDate)),t)),n&&((t=q({},e,{kind:"debug"})).user=p.filterUser(t.user),delete t.trackEvents,delete t.debugEventsUntilDate,P(t)))},l.flush=function(){if(S)return Promise.resolve();var e=k,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),s&&s.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(k=[],b.debug(Ne(e.length)),f.sendEvents(e,d).then(function(e){e&&(e.serverTime&&(E=e.serverTime),g(e.status)||(S=!0),400<=e.status&&A(function(){c.maybeReportError(new u(he(e.status,"event posting","some events were dropped")))}))}))},l.start=function(){a=setTimeout(function e(){l.flush(),a=setTimeout(e,w)},w)},l.stop=function(){clearTimeout(a)},l}(i,D,P,re,E,e),z=Ze(i,D,P),ie={},M={},K=D.streaming,ue=!1,J=!1,ce=!0,$=D.stateProvider,B=(f=function(e,n){$||e&&H({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()}),!D.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&ye(e,n)},{setUser:function(e){var n=p&&T(p);(p=_(e))&&f&&f(T(p),n)},getUser:function(){return p?T(p):null}}),de=en(r),G=r.isEnabled()?new Qe(r,P,j,B,k):null;function ve(e){h||(h=!0,te.warn(ae(e)))}function H(e){if(P&&!($&&$.enqueueEvent&&$.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(ce&&(k.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),ce=!1));ce=!1}!O||J||i.isDoNotTrack()||(k.debug(Fe(e.kind)),N.enqueue(e))}}function ge(e,n,t,r){var o=B.getUser(),i=new Date,a=n?n.value:null;if(!D.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=ie[u];if(s&&i-s<3e5)return;ie[u]=i}s={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},o&&o.anonymous&&(s.contextKind=W(o)),u=M[e];u&&(s.version=u.flagVersion||u.version,s.trackEvents=u.trackEvents,s.debugEventsUntilDate=u.debugEventsUntilDate),(r||u&&u.trackReason)&&n&&(s.reason=n.reason),H(s)}function me(e,n,t,r){var o,i;return M&&V(M,e)&&M[e]&&!M[e].deleted?(i=X(o=M[e]),null!==o.value&&void 0!==o.value||(i.value=n)):i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}},t&&ge(e,i,n,r),i}function X(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function W(e){return e.anonymous?"anonymousUser":"user"}function ye(e,n){$||e&&n&&H({kind:"alias",key:e.key,contextKind:W(e),previousKey:n.key,previousContextKind:W(n),creationDate:(new Date).getTime()})}function we(){var o;c=!0,B.getUser()&&(o=function(e){try{return JSON.parse(e)}catch(e){return void E.maybeReportError(new d("Invalid data received from LaunchDarkly; connection may have been interrupted"))}},oe.connect(B.getUser(),j,{ping:function(){k.debug("received ping message from stream");var n=B.getUser();z.fetchFlagSettings(n,j).then(function(e){R(n,B.getUser())&&Q(e||{})}).catch(function(e){E.maybeReportError(new v(fe(e)))})},put:function(e){e=o(e.data);e&&(k.debug("received streaming update for all flags"),Q(e))},patch:function(e){var n,t,r,e=o(e.data);e&&(!(n=M[e.key])||!n.version||!e.version||n.version<e.version?(k.debug(Re(e.key)),t={},delete(r=q({},e)).key,r=X(M[e.key]=r),t[e.key]=n?{previous:n.value,current:r}:{current:r},ke(t)):k.debug(Ae(e.key)))},delete:function(e){var n,e=o(e.data);e&&(!M[e.key]||M[e.key].version<e.version?(k.debug(Le(e.key)),n={},M[e.key]&&!M[e.key].deleted&&(n[e.key]={previous:M[e.key].value}),M[e.key]={version:e.version,deleted:!0},ke(n)):k.debug(Ce(e.key)))}}))}function be(){c&&(oe.disconnect(),c=!1)}function Q(e){var t,r,o={};if(!e)return Promise.resolve();for(t in M)V(M,t)&&M[t]&&(e[t]&&!R(e[t].value,M[t].value)?o[t]={previous:M[t].value,current:X(e[t])}:e[t]&&!e[t].deleted||(o[t]={previous:M[t].value}));for(r in e)V(e,r)&&e[r]&&(!M[r]||M[r].deleted)&&(o[r]={current:X(e[r])});return M=n({},e),ke(o).catch(function(){})}function ke(o){var i,e=Object.keys(o);return 0<e.length&&(i={},e.forEach(function(e){var n=o[e].current,t=n?n.value:void 0,r=o[e].previous;E.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),E.emit("change",i),E.emit("internal-change",M),D.sendEventsOnlyForVariation||$||e.forEach(function(e){ge(e,o[e].current)})),a&&G?G.saveFlags(M):Promise.resolve()}function Ee(){var e=K||o&&void 0===K;e&&!c?we():!e&&c&&be(),C&&C.setStreaming(e)}function Se(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}function De(e){P=e.environment,B.setUser(e.user),M=n({},e.flags),A(Y)}function Y(){k.info("LaunchDarkly client initialized"),ue=!0,Ee(),S.signalSuccess()}function Oe(e){S.signalFailure(e)}return"string"==typeof D.bootstrap&&"LOCALSTORAGE"===D.bootstrap.toUpperCase()&&(G?a=!0:k.warn(ae())),"object"===t(D.bootstrap)&&(y=D.bootstrap,I=Object.keys(y),!(w=y.$flagsState)&&I.length&&k.warn(pe()),!1===y.$valid&&k.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags."),b={},I.forEach(function(e){var n;"$flagsState"!==e&&"$valid"!==e&&(n={value:y[e]},w&&w[e]?n=q(n,w[e]):n.version=0,b[e]=n)}),M=b),$?((x=$.getInitialState())?De(x):$.on("init",De),$.on("update",function(e){e.user&&B.setUser(e.user),e.flags&&Q(e.flags)})):(ee?de.validateUser(ne).then(function(e){return B.setUser(e),"object"===t(D.bootstrap)?Y():a?G.loadFlags().then(function(e){return null==e?(M={},z.fetchFlagSettings(B.getUser(),j).then(function(e){return Q(e||{})}).then(Y).catch(function(e){Oe(new v(fe(e)))})):(M=e,A(Y),z.fetchFlagSettings(B.getUser(),j).then(Q).catch(function(e){return E.maybeReportError(e)}))}):z.fetchFlagSettings(B.getUser(),j).then(function(e){M=e||{},Y()}).catch(function(e){M={},Oe(e)})}):Promise.reject(new s(le()))).catch(Oe),{client:{waitForInitialization:function(){return S.getInitializationPromise()},waitUntilReady:function(){return S.getReadyPromise()},identify:function(e,r,n){return J?L(Promise.resolve({}),n):$?(k.warn("identify() has no effect here; it must be called on the main client instance"),L(Promise.resolve(F(M)),n)):L((a&&G?G.clearFlags():Promise.resolve()).then(function(){return de.validateUser(e)}).then(function(t){return z.fetchFlagSettings(t,r).then(function(e){var n=F(e);return B.setUser(t),j=r,e?Q(e).then(function(){return n}):n})}).then(function(e){return c&&we(),e}).catch(function(e){return E.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return B.getUser()},variation:function(e,n){return me(e,n,!0,!1).value},variationDetail:function(e,n){return me(e,n,!0,!0)},track:function(e,n,t){var r,o;"string"==typeof e?(i.customEventFilter&&!i.customEventFilter(e)&&k.warn(se(e)),o={kind:"custom",key:e,user:r=B.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()},r&&r.anonymous&&(o.contextKind=W(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),H(o)):E.maybeReportError(new l(se(e)))},alias:ye,on:function(e,n,t){Se(e)?(o=!0,ue&&Ee(),E.on(e,n,t)):E.on.apply(E,arguments)},off:function(e){var n;E.off.apply(E,arguments),Se(e)&&(n=!1,E.getEvents().forEach(function(e){Se(e)&&0<E.getEventListenerCount(e)&&(n=!0)}),n||(o=!1,c&&void 0===K&&be()))},setStreaming:function(e){e=null===e?void 0:e;e!==K&&(K=e,Ee())},flush:function(e){return L(O?N.flush():Promise.resolve(),e)},allFlags:function(){var e,n={};if(!M)return n;for(e in M)V(M,e)&&(n[e]=me(e,null,!D.sendEventsOnlyForVariation).value);return n},close:function(e){if(J)return L(Promise.resolve(),e);function n(){J=!0,M={}}return L(Promise.resolve().then(function(){if(be(),C&&C.stop(),O)return N.stop(),N.flush()}).then(n).catch(n),e)}},options:D,emitter:E,ident:B,logger:k,requestor:z,start:function(){O&&(C&&C.start(),N.start())},enqueueEvent:H,getFlagsInternal:function(){return M},getEnvironmentId:function(){return P},internalChangeEventName:"internal-change"}}var sn="3.6.0",ldclientCommon_es=Object.freeze({__proto__:null,commonBasicLogger:Y,createConsoleLogger:Z,errors:p,initialize:un,messages:qe,utils:z,version:sn});function ownKeys(n,e){var t,r=Object.keys(n);return Object.getOwnPropertySymbols&&(t=Object.getOwnPropertySymbols(n),e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),r.push.apply(r,t)),r}function _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 _defineProperty(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}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){e=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(e)return parseInt(e[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,a,u=new window.XMLHttpRequest;for(i in u.open(e,n,!o),t||{})Object.prototype.hasOwnProperty.call(t,i)&&u.setRequestHeader(i,t[i]);return o?(u.send(r),emptyResult):{promise:new Promise(function(e,n){u.addEventListener("load",function(){a||e({status:u.status,header:function(e){return u.getResponseHeader(e)},body:u.responseText})}),u.addEventListener("error",function(){a||n(new Error)}),u.send(r)}),cancel:function(){a=!0,u.abort()}}}function makeBrowserPlatform(e){var i,n,a={synchronousFlush:!1},t=(window.XMLHttpRequest&&(i=e&&e.disableSyncEventPost,a.httpRequest=function(e,n,t,r){var o=a.synchronousFlush&!i;return a.synchronousFlush=!1,newHttpRequest(e,n,t,r,o)}),a.httpAllowsPost=function(){return n=void 0===n?!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest:n},a.httpFallbackPing=function(e){(new window.Image).src=e},e&&e.eventUrlTransformer);a.getCurrentUrl=function(){return t?t(window.location.href):window.location.href},a.isDoNotTrack=function(){var e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack;return 1===e||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(a.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){a.localStorage=null}var r=e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(a.eventSourceAllowsReport=!0,window.EventSourcePolyfill):(a.eventSourceAllowsReport=!1,window.EventSource);return window.EventSource&&(a.eventSourceFactory=function(e,n){n=_objectSpread2(_objectSpread2({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0}),n);return new r(e,n)},a.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}),a.userAgent="JSClient",a.version="2.22.0",a.diagnosticSdkData={name:"js-client-sdk",version:"2.22.0"},a.diagnosticPlatformData={name:"JS"},a.diagnosticUseCombinedEvent=!0,a}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 p.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){function t(){o.synchronousFlush=!0,i.flush().catch(function(){}),o.synchronousFlush=!1}var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},o=makeBrowserPlatform(r),e=un(e,n,r,o,extraOptionDefs),i=e.client,n=e.options,a=e.emitter,u=new Promise(function(e){var n=a.on(goalsEvent,function(){a.off(goalsEvent,n),e()})});i.waitUntilGoalsReady=function(){return u},n.fetchGoals?GoalManager(e,function(){return a.emit(goalsEvent)}):a.emit(goalsEvent),"complete"!==document.readyState?window.addEventListener("load",e.start):e.start();return window.addEventListener("beforeunload",t),window.addEventListener("unload",t),i}var basicLogger$1=basicLogger_2,createConsoleLogger=Z,version="2.22.0";function deprecatedInitialize(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(qe.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; | ||
"use strict";function e(n,e){var t,r=Object.keys(n);return Object.getOwnPropertySymbols&&(t=Object.getOwnPropertySymbols(n),e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),r.push.apply(r,t)),r}function n(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?e(Object(o),!0).forEach(function(e){r(n,e,o[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))})}return n}function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||function(e){if(e){if("string"==typeof e)return o(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(n="Object"===n&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,void 0):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function a(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}Object.defineProperty(exports,"__esModule",{value:!0});var u=a("LaunchDarklyUnexpectedResponseError"),s=a("LaunchDarklyInvalidEnvironmentIdError"),c=a("LaunchDarklyInvalidUserError"),l=a("LaunchDarklyInvalidEventKeyError"),f=a("LaunchDarklyInvalidArgumentError"),v=a("LaunchDarklyFlagFetchError"),d=a("LaunchDarklyInvalidDataError");function g(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var p=Object.freeze({__proto__:null,LDUnexpectedResponseError:u,LDInvalidEnvironmentIdError:s,LDInvalidUserError:c,LDInvalidEventKeyError:l,LDInvalidArgumentError:f,LDFlagFetchError:v,LDInvalidDataError:d,isHttpErrorRecoverable:g}),m=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(w(e,i,a<i+16383?a:i+16383));return 1==r?(n=e[t-1],o.push(y[n>>2]+y[n<<4&63]+"==")):2==r&&(n=(e[t-2]<<8)+e[t-1],o.push(y[n>>10]+y[n>>4&63]+y[n<<2&63]+"=")),o.join("")},y=[],h=[],b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k=0,E=b.length;k<E;++k)y[k]=b[k],h[b.charCodeAt(k)]=k;function w(e,n,t){for(var r,o=[],i=n;i<t;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(y[(r=r)>>18&63]+y[r>>12&63]+y[r>>6&63]+y[63&r]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63;var D=Array.isArray,O=Object.keys,S=Object.prototype.hasOwnProperty,P=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function U(e,n){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(n.startsWith("/")?"":"/")+n}function I(e){e=unescape(encodeURIComponent(e));return m(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(e))}function j(e){return I(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function T(e){return JSON.parse(JSON.stringify(e))}function R(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=D(n),u=D(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;a=n instanceof Date,u=t instanceof Date;if(a!=u)return!1;if(a&&u)return n.getTime()==t.getTime();a=n instanceof RegExp,u=t instanceof RegExp;if(a!=u)return!1;if(a&&u)return n.toString()==t.toString();var s=O(n);if((o=s.length)!==O(t).length)return!1;for(r=o;0!=r--;)if(!S.call(t,s[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=s[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function A(e){setTimeout(e,0)}function L(e,n){e=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:e}function C(e){var n,t={};for(n in e)V(e,n)&&(t[n]={value:e[n],version:0});return t}function F(e){var n,t={};for(n in e)V(e,n)&&(t[n]=e[n].value);return t}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-=j(JSON.stringify(a)).length)<0&&0<t.length?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function x(e){var n=e.version||"3.6.0";return e.userAgent+"/"+n}function q(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.reduce(function(e,t){return n(n({},e),t)},{})}function V(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function _(e){if(!e)return e;var t,r;for(r in P){var o=P[r],i=e[o];void 0!==i&&"string"!=typeof i&&((t=t||n({},e))[o]=String(i))}return t||e}for(var z=Object.freeze({__proto__:null,appendUrlPath:U,btoa:I,base64URLEncode:j,clone:T,deepEquals:R,onNextTick:A,wrapPromiseCallback:L,transformValuesToVersionedValues:C,transformVersionedValuesToValues:F,chunkUserEventsForUrl:N,getLDUserAgentString:x,extend:q,objectHasOwnProperty:V,sanitizeUser:_}),J=function(e){var n=e={exports:{}},t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);{var r,o;t?(r=new Uint8Array(16),n.exports=function(){return t(r),r}):(o=new Array(16),n.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),o[n]=e>>>((3&n)<<3)&255;return o})}return e.exports}(),M=[],K=0;K<256;++K)M[K]=(K+256).toString(16).substr(1);var $,B,H=function(e,n){var n=n||0,t=M;return[t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],"-",t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],t[e[n++]],t[e[+n]]].join("")},G=0,W=0,X=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||$,t=void 0!==e.clockseq?e.clockseq:B,a=(null!=i&&null!=t||(a=J(),null==i&&(i=$=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==t&&(t=B=16383&(a[6]<<8|a[7]))),void 0!==e.msecs?e.msecs:(new Date).getTime()),u=void 0!==e.nsecs?e.nsecs:W+1,s=a-G+(u-W)/1e4;if(s<0&&void 0===e.clockseq&&(t=t+1&16383),1e4<=(u=(s<0||G<a)&&void 0===e.nsecs?0:u))throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");G=a,B=t;s=(1e4*(268435455&(a+=122192928e5))+(W=u))%4294967296,o[r++]=s>>>24&255,o[r++]=s>>>16&255,o[r++]=s>>>8&255,o[r++]=255&s,e=a/4294967296*1e4&268435455;o[r++]=e>>>8&255,o[r++]=255&e,o[r++]=e>>>24&15|16,o[r++]=e>>>16&255,o[r++]=t>>>8|128,o[r++]=255&t;for(var c=0;c<6;++c)o[r+c]=i[c];return n||H(o)},Q=["debug","info","warn","error","none"];function Y(e,s){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 c=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],l=!(!e||!e.destination),f=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",t=1;if(e&&e.level)for(var r=0;r<Q.length;r++)Q[r]===e.level&&(t=r);for(var o={},a=function(e){var a,u=Q[e];"none"!==u&&(e<t?o[u]=function(){}:(a=e,o[u]=function(){var e=a,n=u,t=arguments;if(!(t.length<1)){var r=l?n+": "+f:f,o=1!==t.length&&s?((o=i(t))[0]=r+o[0],s.apply(void 0,i(o))):r+t[0];try{c[e](o)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}))},u=0;u<Q.length;u++)a(u);return o}function Z(e,n){return Y({level:e,prefix:n})}function ee(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}var ne=function(){return"LaunchDarkly client initialized"},te=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.",re=function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},ie=function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},oe=function(e){return'Expected application/json content type but got "'+e+'"'},ae=function(e){return"local storage is unavailable: "+ee(e)},ue=function(e){return"network error"+(e?" ("+e+")":"")},se=function(e){return'Custom event "'+e+'" does not exist'},ce=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+te},le=function(){return"No environment/client-side ID was specified."+te},fe=function(e){return"Error fetching flag settings: "+ee(e)},ve=function(){return"No user specified."+te},de=function(){return"Invalid user specified."+te},ge=function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},pe=function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+te},me=function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},ye=function(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'},he=function(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(g(e)?t:"giving up permanently")},be=function(){return"Cannot make HTTP requests in this environment."+te},ke=function(){return"identify() has no effect here; it must be called on the main client instance"},Ee=function(){return"Closing stream connection"},we=function(e){return"Opening stream connection to "+e},De=function(e,n){return"Error on stream connection: "+ee(e)+", will continue retrying every "+n+" milliseconds."},Oe=function(e){return'Ignoring unknown config option "'+e+'"'},Se=function(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"},Pe=function(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"},Ue=function(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t},Ie=function(e){return"polling for feature flags at "+e},je=function(){return"received ping message from stream"},Te=function(){return"received streaming update for all flags"},Re=function(e){return'received streaming update for flag "'+e+'"'},Ae=function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},Le=function(e){return'received streaming deletion for flag "'+e+'"'},Ce=function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},Fe=function(e){return'enqueueing "'+e+'" event'},Ne=function(e){return"sending "+e+" events"},xe=function(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')},qe=Object.freeze({__proto__:null,clientInitialized:ne,clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:re,eventWithoutUser:ie,invalidContentType:oe,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:ae,networkError:ue,unknownCustomEventKey:se,environmentNotFound:ce,environmentNotSpecified:le,errorFetchingFlags:fe,userNotSpecified:ve,invalidUser:de,invalidData:ge,bootstrapOldFormat:pe,bootstrapInvalid:me,deprecated:ye,httpErrorMessage:he,httpUnavailable:be,identifyDisabled:ke,streamClosing:Ee,streamConnecting:we,streamError:De,unknownOption:Oe,wrongOptionType:Se,wrongOptionTypeBoolean:Pe,optionBelowMinimum:Ue,debugPolling:Ie,debugStreamPing:je,debugStreamPut:Te,debugStreamPatch:Re,debugStreamPatchIgnored:Ae,debugStreamDelete:Le,debugStreamDeleteIgnored:Ce,debugEnqueueingEvent:Fe,debugPostingEvents:Ne,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},invalidTagValue:xe}),Ve={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:function(e,n,t,r){var o={};return t.id&&(o.id=ze("".concat(e,".id"),n,t.id,r)),t.version&&(o.version=ze("".concat(e,".version"),n,t.version,r)),o}}},_e=/^(\w|\.|-)+$/;function ze(e,n,t,r){if("string"==typeof t&&t.match(_e))return t;r.warn(xe(e))}function Je(e,n,r,a){var u=q({logger:{default:a}},Ve,r),o={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function s(e){A(function(){n&&n.maybeReportError(new f(e))})}var i,c,l,d,v,r=q({},e||{});return v=r,Object.keys(o).forEach(function(e){var n;void 0!==v[e]&&(n=o[e],a&&a.warn(ye(e,n)),n&&(void 0===v[n]&&(v[n]=v[e]),delete v[e]))}),i=(d=q({},r),Object.keys(u).forEach(function(e){void 0!==d[e]&&null!==d[e]||(d[e]=u[e]&&u[e].default)}),c=r=d,l=q({},c),Object.keys(c).forEach(function(e){var n,t,r,o,i=c[e];null!=i&&(void 0===(n=u[e])?s(Oe(e)):(t=n.type||g(n.default),(r=n.validator)?void 0!==(r=r(e,c,c[e],a))?l[e]=r:delete l[e]:"any"!==t&&(r=t.split("|"),o=g(i),r.indexOf(o)<0?"boolean"===t?(l[e]=!!i,s(Pe(e,o))):(s(Se(e,t,o)),l[e]=n.default):"number"===o&&void 0!==n.minimum&&i<n.minimum&&(s(Ue(e,i,n.minimum)),l[e]=n.minimum))))}),r=l).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")}),r;function g(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";e=t(e);return"boolean"===e||"string"===e||"number"===e||"function"===e?e:"object"}}}function Me(e){var n={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(n["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(n["application-version"]=[e.application.version])),n}function Ke(e,n){if(n&&!n.sendLDHeaders)return{};var e={"X-LaunchDarkly-User-Agent":x(e)},t=(n&&n.wrapperName&&(e["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),Me(n)),n=Object.keys(t);return n.length&&(e["x-launchdarkly-tags"]=n.sort().flatMap(function(n){return Array.isArray(t[n])?t[n].sort().map(function(e){return"".concat(n,"/").concat(e)}):["".concat(n,"/").concat(t[n])]}).join(" ")),e}function $e(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform(n({},e)):e}function Be(u,e,s){var r="/a/"+e+".gif",c=q({"Content-Type":"application/json"},Ke(u,s)),l=u.httpFallbackPing,f={};return f.sendChunk=function(e,n,o,t){var i=JSON.stringify(e),a=o?null:X();return t?function t(r){var e=o?c:q({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",n,$e(e,s),i).promise.then(function(e){if(e)return 400<=e.status&&g(e.status)&&r?t(!1):(n={status:(e=e).status},(e=(e=e.header("date"))&&Date.parse(e))&&(n.serverTime=e),n);var n}).catch(function(){return r?t(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(n+r+"?d="+j(i)),Promise.resolve())},f.sendEvents=function(e,n,t){if(!u.httpRequest)return Promise.resolve();for(var r=u.httpAllowsPost(),o=r?[e]:N(2e3-n.length,e),i=[],a=0;a<o.length;a++)i.push(f.sendChunk(o[a],n,t,r));return Promise.all(i)},f}function He(){var e={},a=0,u=0,s={};return e.summarizeEvent=function(e){var n,t;"feature"===e.kind&&(n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),(t=s[n])?t.count=t.count+1:s[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===a||e.creationDate<a)&&(a=e.creationDate),e.creationDate>u&&(u=e.creationDate))},e.getSummary=function(){var e,n={},t=!0;for(e in s){var r=s[e],o=n[r.key],i=(o||(o={default:r.default,counters:[]},n[r.key]=o),{value:r.value,count:r.count});void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),t=!1}return t?null:{startDate:a,endDate:u,features:n}},e.clearSummary=function(){u=a=0,s={}},e}function Ge(e){var n={},a=e.allAttributesPrivate,u=e.privateAttributeNames||[],s={key:!0,custom:!0,anonymous:!0},o={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(r,o){return Object.keys(r).reduce(function(e,n){var t;return o(n)&&(s[t=n]||!a&&-1===i.indexOf(t)&&-1===u.indexOf(t)?e[0][n]=r[n]:e[1][n]=!0),e},[{},{}])}var i=e.privateAttributeNames||[],t=n(e,function(e){return o[e]}),r=t[0],t=t[1],e=(e.custom&&(e=n(e.custom,function(){return 1}),r.custom=e[0],t=q({},t,e[1])),Object.keys(t));return e.length&&(e.sort(),r.privateAttrs=e),r},n}function We(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 Xe=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 Qe(n,t,r,o){var i={};function a(){var e="",n=o.getUser();return n&&(e=r||I(JSON.stringify(n))),"ld:"+t+":"+e}return i.loadFlags=function(){return n.get(a()).then(function(e){if(null==e)return null;try{var n,t=JSON.parse(e);return t&&(void 0===(n=t.$schema)||n<1?t=C(t):delete t.$schema),t}catch(e){return i.clearFlags().then(function(){return null})}})},i.saveFlags=function(e){e=q({},e,{$schema:1});return n.set(a(),JSON.stringify(e))},i.clearFlags=function(){return n.clear(a())},i}function Ye(o,i,a,n){var u,s=i.streamUrl,c=i.logger,e={},l=U(s,"/eval/"+a),f=i.useReport,d=i.evaluationReasons,t=i.streamReconnectDelay,v=Ke(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(){m=null;var e,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=U(s,"/ping/"+a),n=""):e=l+"/"+j(JSON.stringify(h)),t.headers=$e(t.headers,i),e=e+((n=d?n+(n?"&":"")+"withReasons=true":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={};for(var r in t||{})!function(n){w[n]=function(e){S(!(g=!1)),t[n]&&t[n](e)}}(r);k()},e.disconnect=function(){clearTimeout(m),m=null,E()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function Ze(g,p,i){var a=p.baseUrl,u=p.useReport,c=p.evaluationReasons,l=p.logger,e={},m={};function f(e,n){if(!g.httpRequest)return new Promise(function(e,n){n(new v(be()))});var t,r,o,i,a,u=n?"REPORT":"GET",c=Ke(g,p),l=(n&&(c["Content-Type"]="application/json"),m[e]),f=(l||(t=function(){delete m[e]},(d={addPromise:function(n,e){r=n,o&&o(),o=e,n.then(function(e){r===n&&(i(e),t())},function(e){r===n&&(a(e),t())})}}).resultPromise=new Promise(function(e,n){i=e,a=n}),l=d,m[e]=l),g.httpRequest(u,e,$e(c,p),n)),d=f.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new s(ce()):new v(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=oe(e.header("content-type")||"");return Promise.reject(new v(n))},function(e){return Promise.reject(new v(ue(e)))});return l.addPromise(d,function(){f.cancel&&f.cancel()}),l.resultPromise}return e.fetchJSON=function(e){return f(U(a,e),null)},e.fetchFlagSettings=function(e,n){var t,r,o="";return u?(t=[a,"/sdk/evalx/",i,"/user"].join(""),r=JSON.stringify(e)):(e=j(JSON.stringify(e)),t=[a,"/sdk/evalx/",i,"/users/",e].join("")),n&&(o="h="+n),l.debug(Ie(t=t+((o=c?o+(o?"&":"")+"withReasons=true":o)?"?":"")+o)),f(t,r)},e}function en(t){var e={validateUser:function(e){if(!e)return Promise.reject(new c(ve()));var n=T(e);return null!==n.key&&void 0!==n.key?(n.key=n.key.toString(),Promise.resolve(n)):n.anonymous?t.get("ld:$anonUserId").then(function(e){if(e)return n.key=e,n;e=X();return n.key=e,t.set("ld:$anonUserId",e).then(function(){return n})}):Promise.reject(new c(de()))}};return e}var nn=Object.freeze({__proto__:null,baseOptionDefs:Ve,validate:Je,getTags:Me}).baseOptionDefs,tn=z.appendUrlPath,rn=function(e){var n={diagnosticId:X()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n},on=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){o.push({timestamp:e,failed:n,durationMillis:t})},reset:i}},an=function(t,r,e,o,i,a,u){var s,c,l=!!t.diagnosticUseCombinedEvent,f="ld:"+i+":$diagnostics",d=tn(a.eventsUrl,"/events/diagnostic/"+i),v=a.diagnosticRecordingInterval,g=e,p=!!a.streaming,i={};function m(){return{sdk:(e=n({},t.diagnosticSdkData),a.wrapperName&&(e.wrapperName=a.wrapperName),a.wrapperVersion&&(e.wrapperVersion=a.wrapperVersion),e),configuration:{customBaseURI:a.baseUrl!==nn.baseUrl.default,customStreamURI:a.streamUrl!==nn.streamUrl.default,customEventsURI:a.eventsUrl!==nn.eventsUrl.default,eventsCapacity:a.eventCapacity,eventsFlushIntervalMillis:a.flushInterval,reconnectTimeMillis:a.streamReconnectDelay,streamingDisabled:!p,allAttributesPrivate:!!a.allAttributesPrivate,inlineUsersInEvents:!!a.inlineUsersInEvents,diagnosticRecordingIntervalMillis:a.diagnosticRecordingInterval,usingSecureMode:!!a.hash,bootstrapMode:!!a.bootstrap,fetchGoalsDisabled:!a.fetchGoals,allowFrequentDuplicateEvents:!!a.allowFrequentDuplicateEvents,sendEventsOnlyForVariation:!!a.sendEventsOnlyForVariation,autoAliasingOptOut:!!a.autoAliasingOptOut},platform:t.diagnosticPlatformData};var e}function h(e){a.logger&&a.logger.debug(qe.debugPostingDiagnosticEvent(e)),o.sendEvents(e,d,!0).then(function(){}).catch(function(){})}function y(){var e,t;h((t=(new Date).getTime(),e=n({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:t},g.getProps()),l&&(e=n(n({},e),m())),g.reset(t),e)),c=setTimeout(y,v),s=(new Date).getTime(),l&&r.isEnabled()&&(t=n({},g.getProps()),r.set(f,JSON.stringify(t)))}return i.start=function(){var t;l?(t=function(e){var n;e?(e=(s||0)+v)<=(n=(new Date).getTime())?y():c=setTimeout(y,e-n):0===Math.floor(4*Math.random())?y():c=setTimeout(y,v)},r.isEnabled()?r.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)}):t(!1)):(h(n({kind:"diagnostic-init",id:u,creationDate:g.getProps().dataSinceDate},m())),c=setTimeout(y,v))},i.stop=function(){c&&clearTimeout(c)},i.setStreaming=function(e){p=e},i};function un(ee,ne,e,i,r){var a,c,o,f,p,m,te,h,y,w,b,k=e&&e.logger?e.logger:r&&r.logger&&r.logger.default||Z("warn"),E=We(k),S=Xe(E),D=Je(e,E,r,k),O=D.sendEvents,P=ee,j=D.hash,r=(m=i.localStorage,te=k,h=!(e={}),e.isEnabled=function(){return!!m},e.get=function(e){return new Promise(function(n){m?m.get(e).then(n).catch(function(e){ve(e),n(void 0)}):n(void 0)})},e.set=function(e,t){return new Promise(function(n){m?m.set(e,t).then(function(){return n(!0)}).catch(function(e){ve(e),n(!1)}):n(!1)})},e.clear=function(e){return new Promise(function(n){m?m.clear(e).then(function(){return n(!0)}).catch(function(e){ve(e),n(!1)}):n(!1)})},e),e=Be(i,P,D),I=D.sendEvents&&!D.diagnosticOptOut,x=I?rn(P):null,re=I?on((new Date).getTime()):null,C=I?an(i,r,re,e,P,D,x):null,oe=Ye(i,D,P,re),N=D.eventProcessor||function(e,n,t,r,o,i){var a,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)||Be(e,t,n),d=U(n.eventsUrl,"/events/bulk/"+t),v=He(),p=Ge(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){var n,t,r;S||(n=t=!1,v.summarizeEvent(e),"feature"===e.kind?O()&&(t=!!e.trackEvents,n=!!(r=e).debugEventsUntilDate&&r.debugEventsUntilDate>E&&r.debugEventsUntilDate>(new Date).getTime()):t=O(),t&&P((t=q({},r=e),"alias"!==r.kind&&(m||"identify"===r.kind?t.user=p.filterUser(r.user):(t.userKey=r.user.key,delete t.user),"feature"===r.kind&&(delete t.trackEvents,delete t.debugEventsUntilDate)),t)),n&&((t=q({},e,{kind:"debug"})).user=p.filterUser(t.user),delete t.trackEvents,delete t.debugEventsUntilDate,P(t)))},l.flush=function(){if(S)return Promise.resolve();var e=k,n=v.getSummary();return v.clearSummary(),n&&(n.kind="summary",e.push(n)),s&&s.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(k=[],b.debug(Ne(e.length)),f.sendEvents(e,d).then(function(e){e&&(e.serverTime&&(E=e.serverTime),g(e.status)||(S=!0),400<=e.status&&A(function(){c.maybeReportError(new u(he(e.status,"event posting","some events were dropped")))}))}))},l.start=function(){a=setTimeout(function e(){l.flush(),a=setTimeout(e,w)},w)},l.stop=function(){clearTimeout(a)},l}(i,D,P,re,E,e),z=Ze(i,D,P),ie={},M={},K=D.streaming,ue=!1,J=!1,ce=!0,$=D.stateProvider,B=(f=function(e,n){$||e&&H({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()}),!D.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&ye(e,n)},{setUser:function(e){var n=p&&T(p);(p=_(e))&&f&&f(T(p),n)},getUser:function(){return p?T(p):null}}),de=en(r),G=r.isEnabled()?new Qe(r,P,j,B,k):null;function ve(e){h||(h=!0,te.warn(ae(e)))}function H(e){if(P&&!($&&$.enqueueEvent&&$.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(ce&&(k.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),ce=!1));ce=!1}!O||J||i.isDoNotTrack()||(k.debug(Fe(e.kind)),N.enqueue(e))}}function ge(e,n,t,r){var o=B.getUser(),i=new Date,a=n?n.value:null;if(!D.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=ie[u];if(s&&i-s<3e5)return;ie[u]=i}s={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},o&&o.anonymous&&(s.contextKind=W(o)),u=M[e];u&&(s.version=u.flagVersion||u.version,s.trackEvents=u.trackEvents,s.debugEventsUntilDate=u.debugEventsUntilDate),(r||u&&u.trackReason)&&n&&(s.reason=n.reason),H(s)}function me(e,n,t,r){var o,i;return M&&V(M,e)&&M[e]&&!M[e].deleted?(i=X(o=M[e]),null!==o.value&&void 0!==o.value||(i.value=n)):i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}},t&&ge(e,i,n,r),i}function X(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function W(e){return e.anonymous?"anonymousUser":"user"}function ye(e,n){$||e&&n&&H({kind:"alias",key:e.key,contextKind:W(e),previousKey:n.key,previousContextKind:W(n),creationDate:(new Date).getTime()})}function we(){var o;c=!0,B.getUser()&&(o=function(e){try{return JSON.parse(e)}catch(e){return void E.maybeReportError(new d("Invalid data received from LaunchDarkly; connection may have been interrupted"))}},oe.connect(B.getUser(),j,{ping:function(){k.debug("received ping message from stream");var n=B.getUser();z.fetchFlagSettings(n,j).then(function(e){R(n,B.getUser())&&Q(e||{})}).catch(function(e){E.maybeReportError(new v(fe(e)))})},put:function(e){e=o(e.data);e&&(k.debug("received streaming update for all flags"),Q(e))},patch:function(e){var n,t,r,e=o(e.data);e&&(!(n=M[e.key])||!n.version||!e.version||n.version<e.version?(k.debug(Re(e.key)),t={},delete(r=q({},e)).key,r=X(M[e.key]=r),t[e.key]=n?{previous:n.value,current:r}:{current:r},ke(t)):k.debug(Ae(e.key)))},delete:function(e){var n,e=o(e.data);e&&(!M[e.key]||M[e.key].version<e.version?(k.debug(Le(e.key)),n={},M[e.key]&&!M[e.key].deleted&&(n[e.key]={previous:M[e.key].value}),M[e.key]={version:e.version,deleted:!0},ke(n)):k.debug(Ce(e.key)))}}))}function be(){c&&(oe.disconnect(),c=!1)}function Q(e){var t,r,o={};if(!e)return Promise.resolve();for(t in M)V(M,t)&&M[t]&&(e[t]&&!R(e[t].value,M[t].value)?o[t]={previous:M[t].value,current:X(e[t])}:e[t]&&!e[t].deleted||(o[t]={previous:M[t].value}));for(r in e)V(e,r)&&e[r]&&(!M[r]||M[r].deleted)&&(o[r]={current:X(e[r])});return M=n({},e),ke(o).catch(function(){})}function ke(o){var i,e=Object.keys(o);return 0<e.length&&(i={},e.forEach(function(e){var n=o[e].current,t=n?n.value:void 0,r=o[e].previous;E.emit("change:"+e,t,r),i[e]=n?{current:t,previous:r}:{previous:r}}),E.emit("change",i),E.emit("internal-change",M),D.sendEventsOnlyForVariation||$||e.forEach(function(e){ge(e,o[e].current)})),a&&G?G.saveFlags(M):Promise.resolve()}function Ee(){var e=K||o&&void 0===K;e&&!c?we():!e&&c&&be(),C&&C.setStreaming(e)}function Se(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}function De(e){P=e.environment,B.setUser(e.user),M=n({},e.flags),A(Y)}function Y(){k.info("LaunchDarkly client initialized"),ue=!0,Ee(),S.signalSuccess()}function Oe(e){S.signalFailure(e)}return"string"==typeof D.bootstrap&&"LOCALSTORAGE"===D.bootstrap.toUpperCase()&&(G?a=!0:k.warn(ae())),"object"===t(D.bootstrap)&&(y=D.bootstrap,I=Object.keys(y),!(w=y.$flagsState)&&I.length&&k.warn(pe()),!1===y.$valid&&k.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags."),b={},I.forEach(function(e){var n;"$flagsState"!==e&&"$valid"!==e&&(n={value:y[e]},w&&w[e]?n=q(n,w[e]):n.version=0,b[e]=n)}),M=b),$?((x=$.getInitialState())?De(x):$.on("init",De),$.on("update",function(e){e.user&&B.setUser(e.user),e.flags&&Q(e.flags)})):(ee?de.validateUser(ne).then(function(e){return B.setUser(e),"object"===t(D.bootstrap)?Y():a?G.loadFlags().then(function(e){return null==e?(M={},z.fetchFlagSettings(B.getUser(),j).then(function(e){return Q(e||{})}).then(Y).catch(function(e){Oe(new v(fe(e)))})):(M=e,A(Y),z.fetchFlagSettings(B.getUser(),j).then(Q).catch(function(e){return E.maybeReportError(e)}))}):z.fetchFlagSettings(B.getUser(),j).then(function(e){M=e||{},Y()}).catch(function(e){M={},Oe(e)})}):Promise.reject(new s(le()))).catch(Oe),{client:{waitForInitialization:function(){return S.getInitializationPromise()},waitUntilReady:function(){return S.getReadyPromise()},identify:function(e,r,n){return J?L(Promise.resolve({}),n):$?(k.warn("identify() has no effect here; it must be called on the main client instance"),L(Promise.resolve(F(M)),n)):L((a&&G?G.clearFlags():Promise.resolve()).then(function(){return de.validateUser(e)}).then(function(t){return z.fetchFlagSettings(t,r).then(function(e){var n=F(e);return B.setUser(t),j=r,e?Q(e).then(function(){return n}):n})}).then(function(e){return c&&we(),e}).catch(function(e){return E.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return B.getUser()},variation:function(e,n){return me(e,n,!0,!1).value},variationDetail:function(e,n){return me(e,n,!0,!0)},track:function(e,n,t){var r,o;"string"==typeof e?(i.customEventFilter&&!i.customEventFilter(e)&&k.warn(se(e)),o={kind:"custom",key:e,user:r=B.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()},r&&r.anonymous&&(o.contextKind=W(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),H(o)):E.maybeReportError(new l(se(e)))},alias:ye,on:function(e,n,t){Se(e)?(o=!0,ue&&Ee(),E.on(e,n,t)):E.on.apply(E,arguments)},off:function(e){var n;E.off.apply(E,arguments),Se(e)&&(n=!1,E.getEvents().forEach(function(e){Se(e)&&0<E.getEventListenerCount(e)&&(n=!0)}),n||(o=!1,c&&void 0===K&&be()))},setStreaming:function(e){e=null===e?void 0:e;e!==K&&(K=e,Ee())},flush:function(e){return L(O?N.flush():Promise.resolve(),e)},allFlags:function(){var e,n={};if(!M)return n;for(e in M)V(M,e)&&(n[e]=me(e,null,!D.sendEventsOnlyForVariation).value);return n},close:function(e){if(J)return L(Promise.resolve(),e);function n(){J=!0,M={}}return L(Promise.resolve().then(function(){if(be(),C&&C.stop(),O)return N.stop(),N.flush()}).then(n).catch(n),e)}},options:D,emitter:E,ident:B,logger:k,requestor:z,start:function(){O&&(C&&C.start(),N.start())},enqueueEvent:H,getFlagsInternal:function(){return M},getEnvironmentId:function(){return P},internalChangeEventName:"internal-change"}}var sn="3.6.0",ldclientCommon_es=Object.freeze({__proto__:null,commonBasicLogger:Y,createConsoleLogger:Z,errors:p,initialize:un,messages:qe,utils:z,version:sn});function ownKeys(n,e){var t,r=Object.keys(n);return Object.getOwnPropertySymbols&&(t=Object.getOwnPropertySymbols(n),e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),r.push.apply(r,t)),r}function _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 _defineProperty(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}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){e=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(e)return parseInt(e[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,a,u=new window.XMLHttpRequest;for(i in u.open(e,n,!o),t||{})Object.prototype.hasOwnProperty.call(t,i)&&u.setRequestHeader(i,t[i]);return o?(u.send(r),emptyResult):{promise:new Promise(function(e,n){u.addEventListener("load",function(){a||e({status:u.status,header:function(e){return u.getResponseHeader(e)},body:u.responseText})}),u.addEventListener("error",function(){a||n(new Error)}),u.send(r)}),cancel:function(){a=!0,u.abort()}}}function makeBrowserPlatform(e){var i,n,a={synchronousFlush:!1},t=(window.XMLHttpRequest&&(i=e&&e.disableSyncEventPost,a.httpRequest=function(e,n,t,r){var o=a.synchronousFlush&!i;return a.synchronousFlush=!1,newHttpRequest(e,n,t,r,o)}),a.httpAllowsPost=function(){return n=void 0===n?!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest:n},a.httpFallbackPing=function(e){(new window.Image).src=e},e&&e.eventUrlTransformer);a.getCurrentUrl=function(){return t?t(window.location.href):window.location.href},a.isDoNotTrack=function(){var e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack;return 1===e||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(a.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){a.localStorage=null}var r=e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(a.eventSourceAllowsReport=!0,window.EventSourcePolyfill):(a.eventSourceAllowsReport=!1,window.EventSource);return window.EventSource&&(a.eventSourceFactory=function(e,n){n=_objectSpread2(_objectSpread2({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0}),n);return new r(e,n)},a.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}),a.userAgent="JSClient",a.version="2.22.1",a.diagnosticSdkData={name:"js-client-sdk",version:"2.22.1"},a.diagnosticPlatformData={name:"JS"},a.diagnosticUseCombinedEvent=!0,a}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 p.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){function t(){o.synchronousFlush=!0,i.flush().catch(function(){}),o.synchronousFlush=!1}var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},o=makeBrowserPlatform(r),e=un(e,n,r,o,extraOptionDefs),i=e.client,n=e.options,a=e.emitter,u=new Promise(function(e){var n=a.on(goalsEvent,function(){a.off(goalsEvent,n),e()})});i.waitUntilGoalsReady=function(){return u},n.fetchGoals?GoalManager(e,function(){return a.emit(goalsEvent)}):a.emit(goalsEvent),"complete"!==document.readyState?window.addEventListener("load",e.start):e.start();return window.addEventListener("beforeunload",t),window.addEventListener("unload",t),i}var basicLogger$1=basicLogger_2,createConsoleLogger=Z,version="2.22.1";function deprecatedInitialize(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(qe.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(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function n(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?e(Object(o),!0).forEach((function(e){r(n,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}))}return n}function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return i(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function a(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var u=a("LaunchDarklyUnexpectedResponseError"),s=a("LaunchDarklyInvalidEnvironmentIdError"),c=a("LaunchDarklyInvalidUserError"),l=a("LaunchDarklyInvalidEventKeyError"),f=a("LaunchDarklyInvalidArgumentError"),d=a("LaunchDarklyFlagFetchError"),v=a("LaunchDarklyInvalidDataError");function g(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var p=Object.freeze({__proto__:null,LDUnexpectedResponseError:u,LDInvalidEnvironmentIdError:s,LDInvalidUserError:c,LDInvalidEventKeyError:l,LDInvalidArgumentError:f,LDFlagFetchError:d,LDInvalidDataError:v,isHttpErrorRecoverable:g}),m=[],h=[],y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",w=0,b=y.length;w<b;++w)m[w]=y[w],h[y.charCodeAt(w)]=w;function k(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("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63;var E=Array.isArray,D=Object.keys,S=Object.prototype.hasOwnProperty,O=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function P(e,n){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(n.startsWith("/")?"":"/")+n}function U(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(k(e,i,i+16383>a?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("")}(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(unescape(encodeURIComponent(e))))}function j(e){return U(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function R(e){return JSON.parse(JSON.stringify(e))}function I(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=E(n),u=E(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(!S.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 T(e){setTimeout(e,0)}function L(e,n){var t=e.then((function(e){return n&&setTimeout((function(){n(null,e)}),0),e}),(function(e){if(!n)return Promise.reject(e);setTimeout((function(){n(e,null)}),0)}));return n?void 0:t}function N(e){var n={};for(var t in e)q(e,t)&&(n[t]={value:e[t],version:0});return n}function A(e){var n={};for(var t in e)q(e,t)&&(n[t]=e[t].value);return n}function x(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-=j(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function C(e){var n=e.version||"3.6.0";return e.userAgent+"/"+n}function F(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.reduce((function(e,t){return n(n({},e),t)}),{})}function q(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function _(e){if(!e)return e;var t;for(var r in O){var o=O[r],i=e[o];void 0!==i&&"string"!=typeof i&&((t=t||n({},e))[o]=String(i))}return t||e}for(var V=Object.freeze({__proto__:null,appendUrlPath:P,btoa:U,base64URLEncode:j,clone:R,deepEquals:I,onNextTick:T,wrapPromiseCallback:L,transformValuesToVersionedValues:N,transformVersionedValuesToValues:A,chunkUserEventsForUrl:x,getLDUserAgentString:C,extend:F,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||$,a=void 0!==e.clockseq?e.clockseq:H;if(null==i||null==a){var u=z();null==i&&(i=$=[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:B+1,l=s-K+(c-B)/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,B=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)},X=["debug","info","warn","error","none"];function W(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<X.length;s++)X[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=X[e];if("none"!==n)if(e<u)l[n]=function(){};else{var t=e;l[n]=function(){c(t,n,arguments)}}},d=0;d<X.length;d++)f(d);return l}function Q(e,n){return W({level:e,prefix: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+" - "+(g(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=function(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')},Ue=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+")"},invalidTagValue:Pe}),je={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:function(e,n,t,r){var o={};return t.id&&(o.id=Ie("".concat(e,".id"),n,t.id,r)),t.version&&(o.version=Ie("".concat(e,".version"),n,t.version,r)),o}}},Re=/^(\w|\.|-)+$/;function Ie(e,n,t,r){if("string"==typeof t&&t.match(Re))return t;r.warn(Pe(e))}function Te(e,n,r,o){var i=F({logger:{default:o}},je,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){T((function(){n&&n.maybeReportError(new f(e))}))}var s=F({},e||{});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){X.forEach((function(n){if("none"!==n&&(!e[n]||"function"!=typeof e[n]))throw new Error("Provided logger instance must support logger."+n+"(...) method")}))}((s=function(e){var n=F({},e),r=function(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=t(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}};return Object.keys(e).forEach((function(t){var a=e[t];if(null!=a){var s=i[t];if(void 0===s)u(pe(t));else{var c=s.type||r(s.default),l=s.validator;if(l){var f=l(t,e,e[t],o);void 0!==f?n[t]=f:delete n[t]}else if("any"!==c){var d=c.split("|"),v=r(a);d.indexOf(v)<0?"boolean"===c?(n[t]=!!a,u(he(t,v))):(u(me(t,c,v)),n[t]=s.default):"number"===v&&void 0!==s.minimum&&a<s.minimum&&(u(ye(t,a,s.minimum)),n[t]=s.minimum)}}}})),n}(s=function(e){var n=F({},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}function Le(e){var n={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(n["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(n["application-version"]=[e.application.version])),n}function Ne(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":C(e)};n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName);var r=Le(n),o=Object.keys(r);return o.length&&(t["x-launchdarkly-tags"]=o.sort().flatMap((function(e){return Array.isArray(r[e])?r[e].sort().map((function(n){return"".concat(e,"/").concat(n)})):["".concat(e,"/").concat(r[e])]})).join(" ")),t}function Ae(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform(n({},e)):e}function xe(e,n,t){var r="/a/"+n+".gif",o=F({"Content-Type":"application/json"},Ne(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:F({},o,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":l});return e.httpRequest("POST",a,Ae(i,t),c).promise.then((function(e){if(e)return e.status>=400&&g(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(i&&i(a+r+"?d="+j(c)),Promise.resolve())},sendEvents:function(n,t,r){if(!e.httpRequest)return Promise.resolve();var o,i=e.httpAllowsPost();o=i?[n]:x(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 Ce(){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 Fe(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=F({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function qe(e,n,t,r){var o={};function i(){var e="",o=r.getUser();return o&&(e=t||U(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=N(n):delete n.$schema}return n}catch(e){return o.clearFlags().then((function(){return null}))}}))},o.saveFlags=function(n){var t=F({},n,{$schema:1});return e.set(i(),JSON.stringify(t))},o.clearFlags=function(){return e.clear(i())},o}function _e(e,n,t,r){var o,i=n.streamUrl,a=n.logger,u={},s=P(i,"/eval/"+t),c=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,d=Ne(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=P(i,"/ping/"+t),u=""):r=s+"/"+j(JSON.stringify(m)),f.headers=Ae(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 Ve(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,a=n.logger,u={},c={};function l(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new d(de()))}));var o=r?"REPORT":"GET",i=Ne(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 u=e.httpRequest(o,t,Ae(i,n),r),l=u.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n=ee(e.header("content-type")||"");return Promise.reject(new d(n))}return Promise.reject(function(e){return 404===e.status?new s(oe()):new d(ae(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new d(te(e)))}));return a.addPromise(l,(function(){u.cancel&&u.cancel()})),a.resultPromise}return u.fetchJSON=function(e){return l(P(r,e),null)},u.fetchFlagSettings=function(e,n){var u,s,c,f="";return o?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(u=j(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",u].join("")),n&&(f="h="+n),i&&(f=f+(f?"&":"")+"withReasons=true"),s=s+(f?"?":"")+f,a.debug(we(s)),l(s,c)},u}function ze(e){var n={validateUser:function(n){if(!n)return Promise.reject(new c(ue()));var t=R(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 c(se()))}};return n}var Je=Object.freeze({__proto__:null,baseOptionDefs:je,validate:Te,getTags:Le}).baseOptionDefs,Me=V.appendUrlPath,$e=function(e){var n={diagnosticId:G()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n};function He(e,r,o,i,a){var c,f,p,m=o&&o.logger?o.logger:a&&a.logger&&a.logger.default||Q("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=Te(o,h,a,m),b=w.sendEvents,k=e,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=xe(i,k,w),O=w.sendEvents&&!w.diagnosticOptOut,U=O?$e(k):null,j=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,t,r,o,i,a,u){var s,c,l=!!e.diagnosticUseCombinedEvent,f="ld:"+i+":$diagnostics",d=Me(a.eventsUrl,"/events/diagnostic/"+i),v=a.diagnosticRecordingInterval,g=r,p=!!a.streaming,m={};function h(){return{sdk:b(),configuration:(n={customBaseURI:a.baseUrl!==Je.baseUrl.default,customStreamURI:a.streamUrl!==Je.streamUrl.default,customEventsURI:a.eventsUrl!==Je.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(Ue.debugPostingDiagnosticEvent(e)),o.sendEvents(e,d,!0).then((function(){})).catch((function(){}))}function w(){var e,r;y((e=(new Date).getTime(),r=n({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:e},g.getProps()),l&&(r=n(n({},r),h())),g.reset(e),r)),c=setTimeout(w,v),s=(new Date).getTime(),l&&function(){if(t.isEnabled()){var e=n({},g.getProps());t.set(f,JSON.stringify(e))}}()}function b(){var t=n({},e.diagnosticSdkData);return a.wrapperName&&(t.wrapperName=a.wrapperName),a.wrapperVersion&&(t.wrapperVersion=a.wrapperVersion),t}return m.start=function(){l?function(e){if(!t.isEnabled())return e(!1);t.get(f).then((function(n){if(n)try{var t=JSON.parse(n);g.setProps(t),s=t.dataSinceDate}catch(e){}e(!0)})).catch((function(){e(!1)}))}((function(e){if(e){var n=(s||0)+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(n({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,j,S,k,w,U):null,x=_e(i,w,k,j),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,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=a||xe(e,t,n),l=P(n.eventsUrl,"/events/bulk/"+t),f=Ce(),d=Fe(n),v=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=F({},e);return"alias"===e.kind||(v||"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 U(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&&U(O(e)),t){var r=F({},e,{kind:"debug"});r.user=d.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,U(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),g(e.status)||(k=!0),e.status>=400&&T((function(){i.maybeReportError(new u(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,j,h,S),V=Ve(i,w,k),z={},J={},M=w.streaming,$=!1,H=!1,K=!0,B=w.stateProvider,G=function(e,n){var t,r={setUser:function(e){var r=t&&R(t);(t=_(e))&&n&&n(R(t),r)},getUser:function(){return t?R(t):null}};return r}(0,(function(e,n){(function(e){B||e&&Y({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!w.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&ue(e,n)})),X=ze(D),W=D.isEnabled()?new qe(D,k,E,G,m):null;function Y(e){if(k&&!(B&&B.enqueueEvent&&B.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 Z(e,n,t,r){var o=G.getUser(),i=new Date,a=n?n.value:null;if(!w.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=z[u];if(s&&i-s<3e5)return;z[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()};o&&o.anonymous&&(c.contextKind=oe(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),Y(c)}function ee(e,n,t,r){var o;if(J&&q(J,e)&&J[e]&&!J[e].deleted){var i=J[e];o=te(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&Z(e,o,n,r),o}function te(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function oe(e){return e.anonymous?"anonymousUser":"user"}function ue(e,n){B||e&&n&&Y({kind:"alias",key:e.key,contextKind:oe(e),previousKey:n.key,previousContextKind:oe(n),creationDate:(new Date).getTime()})}function se(){if(f=!0,G.getUser()){var e=function(e){try{return JSON.parse(e)}catch(e){return void h.maybeReportError(new v("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};x.connect(G.getUser(),E,{ping:function(){m.debug("received ping message from stream");var e=G.getUser();V.fetchFlagSettings(e,E).then((function(n){I(e,G.getUser())&&de(n||{})})).catch((function(e){h.maybeReportError(new d(ae(e)))}))},put:function(n){var t=e(n.data);t&&(m.debug("received streaming update for all flags"),de(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(be(t.key));var o={},i=F({},t);delete i.key,J[t.key]=i;var a=te(i);o[t.key]=r?{previous:r.value,current:a}:{current:a},ve(o)}else m.debug(ke(t.key))}},delete:function(n){var t=e(n.data);if(t)if(!J[t.key]||J[t.key].version<t.version){m.debug(Ee(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},ve(r)}else m.debug(De(t.key))}})}}function le(){f&&(x.disconnect(),f=!1)}function de(e){var t={};if(!e)return Promise.resolve();for(var r in J)q(J,r)&&J[r]&&(e[r]&&!I(e[r].value,J[r].value)?t[r]={previous:J[r].value,current:te(e[r])}:e[r]&&!e[r].deleted||(t[r]={previous:J[r].value}));for(var o in e)q(e,o)&&e[o]&&(!J[o]||J[o].deleted)&&(t[o]={current:te(e[o])});return J=n({},e),ve(t).catch((function(){}))}function ve(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||B||n.forEach((function(n){Z(n,e[n].current)}))}return c&&W?W.saveFlags(J):Promise.resolve()}function ge(){var e=M||p&&void 0===M;e&&!f?se():!e&&f&&le(),N&&N.setStreaming(e)}function pe(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof w.bootstrap&&"LOCALSTORAGE"===w.bootstrap.toUpperCase()&&(W?c=!0:m.warn(ne())),"object"===t(w.bootstrap)&&(J=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=F(o,t[n]):o.version=0,r[n]=o}})),r}(w.bootstrap)),B){var me=B.getInitialState();me?he(me):B.on("init",he),B.on("update",(function(e){e.user&&G.setUser(e.user),e.flags&&de(e.flags)}))}else(e?X.validateUser(r).then((function(e){return G.setUser(e),"object"===t(w.bootstrap)?ye():c?W.loadFlags().then((function(e){return null==e?(J={},V.fetchFlagSettings(G.getUser(),E).then((function(e){return de(e||{})})).then(ye).catch((function(e){we(new d(ae(e)))}))):(J=e,T(ye),V.fetchFlagSettings(G.getUser(),E).then((function(e){return de(e)})).catch((function(e){return h.maybeReportError(e)})))})):V.fetchFlagSettings(G.getUser(),E).then((function(e){J=e||{},ye()})).catch((function(e){J={},we(e)}))})):Promise.reject(new s(ie()))).catch(we);function he(e){k=e.environment,G.setUser(e.user),J=n({},e.flags),T(ye)}function ye(){m.info("LaunchDarkly client initialized"),$=!0,ge(),y.signalSuccess()}function we(e){y.signalFailure(e)}return{client:{waitForInitialization:function(){return y.getInitializationPromise()},waitUntilReady:function(){return y.getReadyPromise()},identify:function(e,n,t){return H?L(Promise.resolve({}),t):B?(m.warn("identify() has no effect here; it must be called on the main client instance"),L(Promise.resolve(A(J)),t)):L((c&&W?W.clearFlags():Promise.resolve()).then((function(){return X.validateUser(e)})).then((function(e){return V.fetchFlagSettings(e,n).then((function(t){var r=A(t);return G.setUser(e),E=n,t?de(t).then((function(){return r})):r}))})).then((function(e){return f&&se(),e})).catch((function(e){return h.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return G.getUser()},variation:function(e,n){return ee(e,n,!0,!1).value},variationDetail:function(e,n){return ee(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&m.warn(re(e));var r=G.getUser(),o={kind:"custom",key:e,user:r,url:i.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=oe(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),Y(o)}else h.maybeReportError(new l(re(e)))},alias:ue,on:function(e,n,t){pe(e)?(p=!0,$&&ge(),h.on(e,n,t)):h.on.apply(h,arguments)},off:function(e){if(h.off.apply(h,arguments),pe(e)){var n=!1;h.getEvents().forEach((function(e){pe(e)&&h.getEventListenerCount(e)>0&&(n=!0)})),n||(p=!1,f&&void 0===M&&le())}},setStreaming:function(e){var n=null===e?void 0:e;n!==M&&(M=n,ge())},flush:function(e){return L(b?C.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!J)return e;for(var n in J)q(J,n)&&(e[n]=ee(n,null,!w.sendEventsOnlyForVariation).value);return e},close:function(e){if(H)return L(Promise.resolve(),e);var n=function(){H=!0,J={}};return L(Promise.resolve().then((function(){if(le(),N&&N.stop(),b)return C.stop(),C.flush()})).then(n).catch(n),e)}},options:w,emitter:h,ident:G,logger:m,requestor:V,start:function(){b&&(N&&N.start(),C.start())},enqueueEvent:Y,getFlagsInternal:function(){return J},getEnvironmentId:function(){return k},internalChangeEventName:"internal-change"}}function Ke(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 Be(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Ke(Object(t),!0).forEach((function(n){Ge(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Ke(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function Ge(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var Xe=Object.freeze({__proto__:null,commonBasicLogger:W,createConsoleLogger:Q,errors:p,initialize:He,messages:Ue,utils:V,version:"3.6.0"}).commonBasicLogger;var We=function(e){return Xe(Be({destination:console.log},e))};var Qe={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Ye(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 Qe;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),Qe;var u,s=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)}));return{promise:s,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,Ye(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=Be(Be({},{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.22.0",t.diagnosticSdkData={name:"js-client-sdk",version:"2.22.0"},t.diagnosticPlatformData={name:"JS"},t.diagnosticUseCombinedEvent=!0,t}var en=/[|\\{}()[\]^$+*?.]/g,nn=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(en,"\\$&")};function tn(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("^"+nn(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+nn(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+nn(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function rn(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(tn(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 on(e,n){var t,r;function o(){r&&r.dispose(),t&&t.length&&(r=rn(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=rn(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 p.LDUnexpectedResponseError((t&&t.message,t.message))),n()})),{}}var an={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function un(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Ze(t),o=He(e,n,t,r,an),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?on(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 sn=We,cn=Q,ln="2.22.0";var fn={initialize:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Ue.deprecated("default export","named LDClient export")),un(e,n,t)},version:"2.22.0"};export default fn;export{sn as basicLogger,cn as createConsoleLogger,un as initialize,ln as version}; | ||
function e(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function n(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?e(Object(o),!0).forEach((function(e){r(n,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}))}return n}function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return i(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function a(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return n.prototype=new Error,n.prototype.name=e,n.prototype.constructor=n,n}var u=a("LaunchDarklyUnexpectedResponseError"),s=a("LaunchDarklyInvalidEnvironmentIdError"),c=a("LaunchDarklyInvalidUserError"),l=a("LaunchDarklyInvalidEventKeyError"),f=a("LaunchDarklyInvalidArgumentError"),d=a("LaunchDarklyFlagFetchError"),v=a("LaunchDarklyInvalidDataError");function g(e){return!(e>=400&&e<500)||400===e||408===e||429===e}for(var p=Object.freeze({__proto__:null,LDUnexpectedResponseError:u,LDInvalidEnvironmentIdError:s,LDInvalidUserError:c,LDInvalidEventKeyError:l,LDInvalidArgumentError:f,LDFlagFetchError:d,LDInvalidDataError:v,isHttpErrorRecoverable:g}),m=[],h=[],y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",w=0,b=y.length;w<b;++w)m[w]=y[w],h[y.charCodeAt(w)]=w;function k(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("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63;var E=Array.isArray,D=Object.keys,S=Object.prototype.hasOwnProperty,O=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function P(e,n){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(n.startsWith("/")?"":"/")+n}function U(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(k(e,i,i+16383>a?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("")}(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(unescape(encodeURIComponent(e))))}function j(e){return U(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function R(e){return JSON.parse(JSON.stringify(e))}function I(e,n){return function e(n,t){if(n===t)return!0;if(n&&t&&"object"==typeof n&&"object"==typeof t){var r,o,i,a=E(n),u=E(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(!S.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 T(e){setTimeout(e,0)}function L(e,n){var t=e.then((function(e){return n&&setTimeout((function(){n(null,e)}),0),e}),(function(e){if(!n)return Promise.reject(e);setTimeout((function(){n(e,null)}),0)}));return n?void 0:t}function N(e){var n={};for(var t in e)q(e,t)&&(n[t]={value:e[t],version:0});return n}function A(e){var n={};for(var t in e)q(e,t)&&(n[t]=e[t].value);return n}function x(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-=j(JSON.stringify(a)).length)<0&&t.length>0?r.unshift(a):t.push(a)}i=e,o.push(t)}return o}function C(e){var n=e.version||"3.6.0";return e.userAgent+"/"+n}function F(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.reduce((function(e,t){return n(n({},e),t)}),{})}function q(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function _(e){if(!e)return e;var t;for(var r in O){var o=O[r],i=e[o];void 0!==i&&"string"!=typeof i&&((t=t||n({},e))[o]=String(i))}return t||e}for(var V=Object.freeze({__proto__:null,appendUrlPath:P,btoa:U,base64URLEncode:j,clone:R,deepEquals:I,onNextTick:T,wrapPromiseCallback:L,transformValuesToVersionedValues:N,transformVersionedValuesToValues:A,chunkUserEventsForUrl:x,getLDUserAgentString:C,extend:F,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||$,a=void 0!==e.clockseq?e.clockseq:H;if(null==i||null==a){var u=z();null==i&&(i=$=[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:B+1,l=s-K+(c-B)/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,B=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)},X=["debug","info","warn","error","none"];function W(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<X.length;s++)X[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=X[e];if("none"!==n)if(e<u)l[n]=function(){};else{var t=e;l[n]=function(){c(t,n,arguments)}}},d=0;d<X.length;d++)f(d);return l}function Q(e,n){return W({level:e,prefix: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+" - "+(g(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=function(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')},Ue=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+")"},invalidTagValue:Pe}),je={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:function(e,n,t,r){var o={};return t.id&&(o.id=Ie("".concat(e,".id"),n,t.id,r)),t.version&&(o.version=Ie("".concat(e,".version"),n,t.version,r)),o}}},Re=/^(\w|\.|-)+$/;function Ie(e,n,t,r){if("string"==typeof t&&t.match(Re))return t;r.warn(Pe(e))}function Te(e,n,r,o){var i=F({logger:{default:o}},je,r),a={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function u(e){T((function(){n&&n.maybeReportError(new f(e))}))}var s=F({},e||{});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){X.forEach((function(n){if("none"!==n&&(!e[n]||"function"!=typeof e[n]))throw new Error("Provided logger instance must support logger."+n+"(...) method")}))}((s=function(e){var n=F({},e),r=function(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";var n=t(e);return"boolean"===n||"string"===n||"number"===n||"function"===n?n:"object"}};return Object.keys(e).forEach((function(t){var a=e[t];if(null!=a){var s=i[t];if(void 0===s)u(pe(t));else{var c=s.type||r(s.default),l=s.validator;if(l){var f=l(t,e,e[t],o);void 0!==f?n[t]=f:delete n[t]}else if("any"!==c){var d=c.split("|"),v=r(a);d.indexOf(v)<0?"boolean"===c?(n[t]=!!a,u(he(t,v))):(u(me(t,c,v)),n[t]=s.default):"number"===v&&void 0!==s.minimum&&a<s.minimum&&(u(ye(t,a,s.minimum)),n[t]=s.minimum)}}}})),n}(s=function(e){var n=F({},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}function Le(e){var n={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(n["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(n["application-version"]=[e.application.version])),n}function Ne(e,n){if(n&&!n.sendLDHeaders)return{};var t={"X-LaunchDarkly-User-Agent":C(e)};n&&n.wrapperName&&(t["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName);var r=Le(n),o=Object.keys(r);return o.length&&(t["x-launchdarkly-tags"]=o.sort().flatMap((function(e){return Array.isArray(r[e])?r[e].sort().map((function(n){return"".concat(e,"/").concat(n)})):["".concat(e,"/").concat(r[e])]})).join(" ")),t}function Ae(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform(n({},e)):e}function xe(e,n,t){var r="/a/"+n+".gif",o=F({"Content-Type":"application/json"},Ne(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:F({},o,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":l});return e.httpRequest("POST",a,Ae(i,t),c).promise.then((function(e){if(e)return e.status>=400&&g(e.status)&&r?n(!1):function(e){var n={status:e.status},t=e.header("date");if(t){var r=Date.parse(t);r&&(n.serverTime=r)}return n}(e)})).catch((function(){return r?n(!1):Promise.reject()}))}(!0).catch((function(){})):(i&&i(a+r+"?d="+j(c)),Promise.resolve())},sendEvents:function(n,t,r){if(!e.httpRequest)return Promise.resolve();var o,i=e.httpAllowsPost();o=i?[n]:x(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 Ce(){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 Fe(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=F({},c,l[1])}var f=Object.keys(c);return f.length&&(f.sort(),s.privateAttrs=f),s},n}function qe(e,n,t,r){var o={};function i(){var e="",o=r.getUser();return o&&(e=t||U(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=N(n):delete n.$schema}return n}catch(e){return o.clearFlags().then((function(){return null}))}}))},o.saveFlags=function(n){var t=F({},n,{$schema:1});return e.set(i(),JSON.stringify(t))},o.clearFlags=function(){return e.clear(i())},o}function _e(e,n,t,r){var o,i=n.streamUrl,a=n.logger,u={},s=P(i,"/eval/"+t),c=n.useReport,l=n.evaluationReasons,f=n.streamReconnectDelay,d=Ne(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=P(i,"/ping/"+t),u=""):r=s+"/"+j(JSON.stringify(m)),f.headers=Ae(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 Ve(e,n,t){var r=n.baseUrl,o=n.useReport,i=n.evaluationReasons,a=n.logger,u={},c={};function l(t,r){if(!e.httpRequest)return new Promise((function(e,n){n(new d(de()))}));var o=r?"REPORT":"GET",i=Ne(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 u=e.httpRequest(o,t,Ae(i,n),r),l=u.promise.then((function(e){if(200===e.status){if(e.header("content-type")&&"application/json"===e.header("content-type").substring(0,"application/json".length))return JSON.parse(e.body);var n=ee(e.header("content-type")||"");return Promise.reject(new d(n))}return Promise.reject(function(e){return 404===e.status?new s(oe()):new d(ae(e.statusText||String(e.status)))}(e))}),(function(e){return Promise.reject(new d(te(e)))}));return a.addPromise(l,(function(){u.cancel&&u.cancel()})),a.resultPromise}return u.fetchJSON=function(e){return l(P(r,e),null)},u.fetchFlagSettings=function(e,n){var u,s,c,f="";return o?(s=[r,"/sdk/evalx/",t,"/user"].join(""),c=JSON.stringify(e)):(u=j(JSON.stringify(e)),s=[r,"/sdk/evalx/",t,"/users/",u].join("")),n&&(f="h="+n),i&&(f=f+(f?"&":"")+"withReasons=true"),s=s+(f?"?":"")+f,a.debug(we(s)),l(s,c)},u}function ze(e){var n={validateUser:function(n){if(!n)return Promise.reject(new c(ue()));var t=R(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 c(se()))}};return n}var Je=Object.freeze({__proto__:null,baseOptionDefs:je,validate:Te,getTags:Le}).baseOptionDefs,Me=V.appendUrlPath,$e=function(e){var n={diagnosticId:G()};return e&&(n.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),n};function He(e,r,o,i,a){var c,f,p,m=o&&o.logger?o.logger:a&&a.logger&&a.logger.default||Q("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=Te(o,h,a,m),b=w.sendEvents,k=e,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=xe(i,k,w),O=w.sendEvents&&!w.diagnosticOptOut,U=O?$e(k):null,j=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,t,r,o,i,a,u){var s,c,l=!!e.diagnosticUseCombinedEvent,f="ld:"+i+":$diagnostics",d=Me(a.eventsUrl,"/events/diagnostic/"+i),v=a.diagnosticRecordingInterval,g=r,p=!!a.streaming,m={};function h(){return{sdk:b(),configuration:(n={customBaseURI:a.baseUrl!==Je.baseUrl.default,customStreamURI:a.streamUrl!==Je.streamUrl.default,customEventsURI:a.eventsUrl!==Je.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(Ue.debugPostingDiagnosticEvent(e)),o.sendEvents(e,d,!0).then((function(){})).catch((function(){}))}function w(){var e,r;y((e=(new Date).getTime(),r=n({kind:l?"diagnostic-combined":"diagnostic",id:u,creationDate:e},g.getProps()),l&&(r=n(n({},r),h())),g.reset(e),r)),c=setTimeout(w,v),s=(new Date).getTime(),l&&function(){if(t.isEnabled()){var e=n({},g.getProps());t.set(f,JSON.stringify(e))}}()}function b(){var t=n({},e.diagnosticSdkData);return a.wrapperName&&(t.wrapperName=a.wrapperName),a.wrapperVersion&&(t.wrapperVersion=a.wrapperVersion),t}return m.start=function(){l?function(e){if(!t.isEnabled())return e(!1);t.get(f).then((function(n){if(n)try{var t=JSON.parse(n);g.setProps(t),s=t.dataSinceDate}catch(e){}e(!0)})).catch((function(){e(!1)}))}((function(e){if(e){var n=(s||0)+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(n({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,j,S,k,w,U):null,x=_e(i,w,k,j),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,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s={},c=a||xe(e,t,n),l=P(n.eventsUrl,"/events/bulk/"+t),f=Ce(),d=Fe(n),v=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=F({},e);return"alias"===e.kind||(v||"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 U(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&&U(O(e)),t){var r=F({},e,{kind:"debug"});r.user=d.filterUser(r.user),delete r.trackEvents,delete r.debugEventsUntilDate,U(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),g(e.status)||(k=!0),e.status>=400&&T((function(){i.maybeReportError(new u(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,j,h,S),V=Ve(i,w,k),z={},J={},M=w.streaming,$=!1,H=!1,K=!0,B=w.stateProvider,G=function(e,n){var t,r={setUser:function(e){var r=t&&R(t);(t=_(e))&&n&&n(R(t),r)},getUser:function(){return t?R(t):null}};return r}(0,(function(e,n){(function(e){B||e&&Y({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()})})(e),!w.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&ue(e,n)})),X=ze(D),W=D.isEnabled()?new qe(D,k,E,G,m):null;function Y(e){if(k&&!(B&&B.enqueueEvent&&B.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 Z(e,n,t,r){var o=G.getUser(),i=new Date,a=n?n.value:null;if(!w.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=z[u];if(s&&i-s<3e5)return;z[u]=i}var c={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()};o&&o.anonymous&&(c.contextKind=oe(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),Y(c)}function ee(e,n,t,r){var o;if(J&&q(J,e)&&J[e]&&!J[e].deleted){var i=J[e];o=te(i),null!==i.value&&void 0!==i.value||(o.value=n)}else o={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return t&&Z(e,o,n,r),o}function te(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function oe(e){return e.anonymous?"anonymousUser":"user"}function ue(e,n){B||e&&n&&Y({kind:"alias",key:e.key,contextKind:oe(e),previousKey:n.key,previousContextKind:oe(n),creationDate:(new Date).getTime()})}function se(){if(f=!0,G.getUser()){var e=function(e){try{return JSON.parse(e)}catch(e){return void h.maybeReportError(new v("Invalid data received from LaunchDarkly; connection may have been interrupted"))}};x.connect(G.getUser(),E,{ping:function(){m.debug("received ping message from stream");var e=G.getUser();V.fetchFlagSettings(e,E).then((function(n){I(e,G.getUser())&&de(n||{})})).catch((function(e){h.maybeReportError(new d(ae(e)))}))},put:function(n){var t=e(n.data);t&&(m.debug("received streaming update for all flags"),de(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(be(t.key));var o={},i=F({},t);delete i.key,J[t.key]=i;var a=te(i);o[t.key]=r?{previous:r.value,current:a}:{current:a},ve(o)}else m.debug(ke(t.key))}},delete:function(n){var t=e(n.data);if(t)if(!J[t.key]||J[t.key].version<t.version){m.debug(Ee(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},ve(r)}else m.debug(De(t.key))}})}}function le(){f&&(x.disconnect(),f=!1)}function de(e){var t={};if(!e)return Promise.resolve();for(var r in J)q(J,r)&&J[r]&&(e[r]&&!I(e[r].value,J[r].value)?t[r]={previous:J[r].value,current:te(e[r])}:e[r]&&!e[r].deleted||(t[r]={previous:J[r].value}));for(var o in e)q(e,o)&&e[o]&&(!J[o]||J[o].deleted)&&(t[o]={current:te(e[o])});return J=n({},e),ve(t).catch((function(){}))}function ve(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||B||n.forEach((function(n){Z(n,e[n].current)}))}return c&&W?W.saveFlags(J):Promise.resolve()}function ge(){var e=M||p&&void 0===M;e&&!f?se():!e&&f&&le(),N&&N.setStreaming(e)}function pe(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}if("string"==typeof w.bootstrap&&"LOCALSTORAGE"===w.bootstrap.toUpperCase()&&(W?c=!0:m.warn(ne())),"object"===t(w.bootstrap)&&(J=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=F(o,t[n]):o.version=0,r[n]=o}})),r}(w.bootstrap)),B){var me=B.getInitialState();me?he(me):B.on("init",he),B.on("update",(function(e){e.user&&G.setUser(e.user),e.flags&&de(e.flags)}))}else(e?X.validateUser(r).then((function(e){return G.setUser(e),"object"===t(w.bootstrap)?ye():c?W.loadFlags().then((function(e){return null==e?(J={},V.fetchFlagSettings(G.getUser(),E).then((function(e){return de(e||{})})).then(ye).catch((function(e){we(new d(ae(e)))}))):(J=e,T(ye),V.fetchFlagSettings(G.getUser(),E).then((function(e){return de(e)})).catch((function(e){return h.maybeReportError(e)})))})):V.fetchFlagSettings(G.getUser(),E).then((function(e){J=e||{},ye()})).catch((function(e){J={},we(e)}))})):Promise.reject(new s(ie()))).catch(we);function he(e){k=e.environment,G.setUser(e.user),J=n({},e.flags),T(ye)}function ye(){m.info("LaunchDarkly client initialized"),$=!0,ge(),y.signalSuccess()}function we(e){y.signalFailure(e)}return{client:{waitForInitialization:function(){return y.getInitializationPromise()},waitUntilReady:function(){return y.getReadyPromise()},identify:function(e,n,t){return H?L(Promise.resolve({}),t):B?(m.warn("identify() has no effect here; it must be called on the main client instance"),L(Promise.resolve(A(J)),t)):L((c&&W?W.clearFlags():Promise.resolve()).then((function(){return X.validateUser(e)})).then((function(e){return V.fetchFlagSettings(e,n).then((function(t){var r=A(t);return G.setUser(e),E=n,t?de(t).then((function(){return r})):r}))})).then((function(e){return f&&se(),e})).catch((function(e){return h.maybeReportError(e),Promise.reject(e)})),t)},getUser:function(){return G.getUser()},variation:function(e,n){return ee(e,n,!0,!1).value},variationDetail:function(e,n){return ee(e,n,!0,!0)},track:function(e,n,t){if("string"==typeof e){i.customEventFilter&&!i.customEventFilter(e)&&m.warn(re(e));var r=G.getUser(),o={kind:"custom",key:e,user:r,url:i.getCurrentUrl(),creationDate:(new Date).getTime()};r&&r.anonymous&&(o.contextKind=oe(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),Y(o)}else h.maybeReportError(new l(re(e)))},alias:ue,on:function(e,n,t){pe(e)?(p=!0,$&&ge(),h.on(e,n,t)):h.on.apply(h,arguments)},off:function(e){if(h.off.apply(h,arguments),pe(e)){var n=!1;h.getEvents().forEach((function(e){pe(e)&&h.getEventListenerCount(e)>0&&(n=!0)})),n||(p=!1,f&&void 0===M&&le())}},setStreaming:function(e){var n=null===e?void 0:e;n!==M&&(M=n,ge())},flush:function(e){return L(b?C.flush():Promise.resolve(),e)},allFlags:function(){var e={};if(!J)return e;for(var n in J)q(J,n)&&(e[n]=ee(n,null,!w.sendEventsOnlyForVariation).value);return e},close:function(e){if(H)return L(Promise.resolve(),e);var n=function(){H=!0,J={}};return L(Promise.resolve().then((function(){if(le(),N&&N.stop(),b)return C.stop(),C.flush()})).then(n).catch(n),e)}},options:w,emitter:h,ident:G,logger:m,requestor:V,start:function(){b&&(N&&N.start(),C.start())},enqueueEvent:Y,getFlagsInternal:function(){return J},getEnvironmentId:function(){return k},internalChangeEventName:"internal-change"}}function Ke(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 Be(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Ke(Object(t),!0).forEach((function(n){Ge(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Ke(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function Ge(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var Xe=Object.freeze({__proto__:null,commonBasicLogger:W,createConsoleLogger:Q,errors:p,initialize:He,messages:Ue,utils:V,version:"3.6.0"}).commonBasicLogger;var We=function(e){return Xe(Be({destination:console.log},e))};var Qe={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Ye(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 Qe;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),Qe;var u,s=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)}));return{promise:s,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,Ye(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=Be(Be({},{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.22.1",t.diagnosticSdkData={name:"js-client-sdk",version:"2.22.1"},t.diagnosticPlatformData={name:"JS"},t.diagnosticUseCombinedEvent=!0,t}var en=/[|\\{}()[\]^$+*?.]/g,nn=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(en,"\\$&")};function tn(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("^"+nn(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+nn(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+nn(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function rn(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(tn(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 on(e,n){var t,r;function o(){r&&r.dispose(),t&&t.length&&(r=rn(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=rn(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 p.LDUnexpectedResponseError((t&&t.message,t.message))),n()})),{}}var an={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function un(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Ze(t),o=He(e,n,t,r,an),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?on(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 sn=We,cn=Q,ln="2.22.1";var fn={initialize:function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Ue.deprecated("default export","named LDClient export")),un(e,n,t)},version:"2.22.1"};export default fn;export{sn as basicLogger,cn as createConsoleLogger,un as initialize,ln 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 y(n,e){var t,r=Object.keys(n);return Object.getOwnPropertySymbols&&(t=Object.getOwnPropertySymbols(n),e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),r.push.apply(r,t)),r}function ie(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?y(Object(o),!0).forEach(function(e){var n,t;n=r,t=o[e=e],e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):y(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}function ae(e){return(ae="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 w(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||function(e){if(e){if("string"==typeof e)return t(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(n="Object"===n&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,void 0):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function n(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var Ee=n("LaunchDarklyUnexpectedResponseError"),ue=n("LaunchDarklyInvalidEnvironmentIdError"),se=n("LaunchDarklyInvalidUserError"),De=n("LaunchDarklyInvalidEventKeyError"),b=n("LaunchDarklyInvalidArgumentError"),ce=n("LaunchDarklyFlagFetchError"),Oe=n("LaunchDarklyInvalidDataError");function le(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var k=Object.freeze({__proto__:null,LDUnexpectedResponseError:Ee,LDInvalidEnvironmentIdError:ue,LDInvalidUserError:se,LDInvalidEventKeyError:De,LDInvalidArgumentError:b,LDFlagFetchError:ce,LDInvalidDataError:Oe,isHttpErrorRecoverable:le}),E=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(function(e,n,t){for(var r,o=[],i=n;i<t;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(u[(r=r)>>18&63]+u[r>>12&63]+u[r>>6&63]+u[63&r]);return o.join("")}(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=[],r=[],o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,D=o.length;i<D;++i)u[i]=o[i],r[o.charCodeAt(i)]=i;r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63;var S=Array.isArray,P=Object.keys,U=Object.prototype.hasOwnProperty,j=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function fe(e,n){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(n.startsWith("/")?"":"/")+n}function s(e){e=unescape(encodeURIComponent(e));return E(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(e))}function O(e){return s(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function de(e){return JSON.parse(JSON.stringify(e))}function ve(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=S(n),u=S(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;a=n instanceof Date,u=t instanceof Date;if(a!=u)return!1;if(a&&u)return n.getTime()==t.getTime();a=n instanceof RegExp,u=t instanceof RegExp;if(a!=u)return!1;if(a&&u)return n.toString()==t.toString();var s=P(n);if((o=s.length)!==P(t).length)return!1;for(r=o;0!=r--;)if(!U.call(t,s[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=s[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function ge(e){setTimeout(e,0)}function pe(e,n){e=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:e}function I(e){var n,t={};for(n in e)ye(e,n)&&(t[n]={value:e[n],version:0});return t}function me(e){var n,t={};for(n in e)ye(e,n)&&(t[n]=e[n].value);return t}function R(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 T(e){var n=e.version||"3.6.0";return e.userAgent+"/"+n}function he(){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 ie(ie({},e),n)},{})}function ye(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function Se(e){if(!e)return e;var n,t;for(t in j){var r=j[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||ie({},e))[r]=String(o))}return n||e}for(var a=Object.freeze({__proto__:null,appendUrlPath:fe,btoa:s,base64URLEncode:O,clone:de,deepEquals:ve,onNextTick:ge,wrapPromiseCallback:pe,transformValuesToVersionedValues:I,transformVersionedValuesToValues:me,chunkUserEventsForUrl:R,getLDUserAgentString:T,extend:he,objectHasOwnProperty:ye,sanitizeUser:Se}),L=function(e){var n=e={exports:{}},t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);{var r,o;t?(r=new Uint8Array(16),n.exports=function(){return t(r),r}):(o=new Array(16),n.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),o[n]=e>>>((3&n)<<3)&255;return o})}return e.exports}(),f=[],c=0;c<256;++c)f[c]=(c+256).toString(16).substr(1);var N,d,v=0,g=0,we=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||N,t=void 0!==e.clockseq?e.clockseq:d,a=(null!=i&&null!=t||(a=L(),null==i&&(i=N=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==t&&(t=d=16383&(a[6]<<8|a[7]))),void 0!==e.msecs?e.msecs:(new Date).getTime()),u=void 0!==e.nsecs?e.nsecs:g+1,s=a-v+(u-g)/1e4;if(s<0&&void 0===e.clockseq&&(t=t+1&16383),1e4<=(u=(s<0||v<a)&&void 0===e.nsecs?0:u))throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");v=a,d=t;s=(1e4*(268435455&(a+=122192928e5))+(g=u))%4294967296,o[r++]=s>>>24&255,o[r++]=s>>>16&255,o[r++]=s>>>8&255,o[r++]=255&s,e=a/4294967296*1e4&268435455;o[r++]=e>>>8&255,o[r++]=255&e,o[r++]=e>>>24&15|16,o[r++]=e>>>16&255,o[r++]=t>>>8|128,o[r++]=255&t;for(var c,l=0;l<6;++l)o[r+l]=i[l];return n||(c=c||0,[f[o[c++]],f[o[c++]],f[o[c++]],f[o[c++]],"-",f[o[c++]],f[o[c++]],"-",f[o[c++]],f[o[c++]],"-",f[o[c++]],f[o[c++]],"-",f[o[c++]],f[o[c++]],f[o[c++]],f[o[c++]],f[o[c++]],f[o[+c]]].join(""))},p=["debug","info","warn","error","none"];function C(e,u){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var s=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],c=!(!e||!e.destination),l=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",t=1;if(e&&e.level)for(var r=0;r<p.length;r++)p[r]===e.level&&(t=r);for(var o={},i=function(e){var i,a=p[e];"none"!==a&&(e<t?o[a]=function(){}:(i=e,o[a]=function(){var e=i,n=a,t=arguments;if(!(t.length<1)){var r=c?n+": "+l:l,o=1!==t.length&&u?((o=w(t))[0]=r+o[0],u.apply(void 0,w(o))):r+t[0];try{s[e](o)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}))},a=0;a<p.length;a++)i(a);return o}function be(e,n){return C({level:e,prefix:n})}function l(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}function Pe(e){return"local storage is unavailable: "+l(e)}function Ue(e){return'Custom event "'+e+'" does not exist'}function je(){return"No environment/client-side ID was specified."+m}function Ie(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+m}function x(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'}function Re(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(le(e)?t:"giving up permanently")}function A(e){return'Ignoring unknown config option "'+e+'"'}function F(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"}function q(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"}function _(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t}function Te(e){return'received streaming update for flag "'+e+'"'}function Le(e){return'received streaming update for flag "'+e+'" but ignored due to version check'}function Ne(e){return'received streaming deletion for flag "'+e+'"'}function Ce(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'}function xe(e){return'enqueueing "'+e+'" event'}function Ae(e){return"sending "+e+" events"}function V(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')}var m=" 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+'"'},M=function(e){return"network error"+(e?" ("+e+")":"")},J=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+m},ke=function(e){return"Error fetching flag settings: "+l(e)},Fe=function(){return"No user specified."+m},qe=function(){return"Invalid user specified."+m},$=function(){return"Cannot make HTTP requests in this environment."+m},H=function(e){return"Opening stream connection to "+e},K=function(e,n){return"Error on stream connection: "+l(e)+", will continue retrying every "+n+" milliseconds."},B=function(e){return"polling for feature flags at "+e},G=Object.freeze({__proto__:null,clientInitialized:function(){return"LaunchDarkly client initialized"},clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutUser:function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},invalidContentType:z,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:Pe,networkError:M,unknownCustomEventKey:Ue,environmentNotFound:J,environmentNotSpecified:je,errorFetchingFlags:ke,userNotSpecified:Fe,invalidUser:qe,invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},bootstrapOldFormat:Ie,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:x,httpErrorMessage:Re,httpUnavailable:$,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:A,wrongOptionType:F,wrongOptionTypeBoolean:q,optionBelowMinimum:_,debugPolling:B,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:Te,debugStreamPatchIgnored:Le,debugStreamDelete:Ne,debugStreamDeleteIgnored:Ce,debugEnqueueingEvent:xe,debugPostingEvents:Ae,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},invalidTagValue:V}),X={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:function(e,n,t,r){var o={};return t.id&&(o.id=Q("".concat(e,".id"),0,t.id,r)),t.version&&(o.version=Q("".concat(e,".version"),0,t.version,r)),o}}},W=/^(\w|\.|-)+$/;function Q(e,n,t,r){if("string"==typeof t&&t.match(W))return t;r.warn(V(e))}function _e(e,n,t,a){var u=he({logger:{default:a}},X,t),r={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function s(e){ge(function(){n&&n.maybeReportError(new b(e))})}var o,c,l,i,f,t=he({},e||{});return f=t,Object.keys(r).forEach(function(e){var n;void 0!==f[e]&&(n=r[e],a&&a.warn(x(e,n)),n&&(void 0===f[n]&&(f[n]=f[e]),delete f[e]))}),o=(i=he({},t),Object.keys(u).forEach(function(e){void 0!==i[e]&&null!==i[e]||(i[e]=u[e]&&u[e].default)}),c=t=i,l=he({},c),Object.keys(c).forEach(function(e){var n,t,r,o,i=c[e];null!=i&&(void 0===(n=u[e])?s(A(e)):(t=n.type||d(n.default),(r=n.validator)?void 0!==(r=r(e,c,c[e],a))?l[e]=r:delete l[e]:"any"!==t&&(r=t.split("|"),o=d(i),r.indexOf(o)<0?"boolean"===t?(l[e]=!!i,s(q(e,o))):(s(F(e,t,o)),l[e]=n.default):"number"===o&&void 0!==n.minimum&&i<n.minimum&&(s(_(e,i,n.minimum)),l[e]=n.minimum))))}),t=l).logger,p.forEach(function(e){if("none"!==e&&(!o[e]||"function"!=typeof o[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")}),t;function d(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";e=ae(e);return"boolean"===e||"string"===e||"number"===e||"function"===e?e:"object"}}}function Y(e){var n={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(n["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(n["application-version"]=[e.application.version])),n}function Z(e,n){if(n&&!n.sendLDHeaders)return{};var e={"X-LaunchDarkly-User-Agent":T(e)},t=(n&&n.wrapperName&&(e["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),Y(n)),n=Object.keys(t);return n.length&&(e["x-launchdarkly-tags"]=n.sort().flatMap(function(n){return Array.isArray(t[n])?t[n].sort().map(function(e){return"".concat(n,"/").concat(e)}):["".concat(n,"/").concat(t[n])]}).join(" ")),e}function ee(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(ie({},e)):e}function Ve(u,e,s){var r="/a/"+e+".gif",c=he({"Content-Type":"application/json"},Z(u,s)),l=u.httpFallbackPing,f={};return f.sendChunk=function(e,n,o,t){var i=JSON.stringify(e),a=o?null:we();return t?function t(r){var e=o?c:he({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",n,ee(e,s),i).promise.then(function(e){if(e)return 400<=e.status&&le(e.status)&&r?t(!1):(n={status:(e=e).status},(e=(e=e.header("date"))&&Date.parse(e))&&(n.serverTime=e),n);var n}).catch(function(){return r?t(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(n+r+"?d="+O(i)),Promise.resolve())},f.sendEvents=function(e,n,t){if(!u.httpRequest)return Promise.resolve();for(var r=u.httpAllowsPost(),o=r?[e]:R(2e3-n.length,e),i=[],a=0;a<o.length;a++)i.push(f.sendChunk(o[a],n,t,r));return Promise.all(i)},f}function ze(e){var n={},a=e.allAttributesPrivate,u=e.privateAttributeNames||[],s={key:!0,custom:!0,anonymous:!0},o={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(r,o){return Object.keys(r).reduce(function(e,n){var t;return o(n)&&(s[t=n]||!a&&-1===i.indexOf(t)&&-1===u.indexOf(t)?e[0][n]=r[n]:e[1][n]=!0),e},[{},{}])}var i=e.privateAttributeNames||[],t=n(e,function(e){return o[e]}),r=t[0],t=t[1],e=(e.custom&&(e=n(e.custom,function(){return 1}),r.custom=e[0],t=he({},t,e[1])),Object.keys(t));return e.length&&(e.sort(),r.privateAttrs=e),r},n}function Me(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 Je(n,t,r,o){var i={};function a(){var e="",n=o.getUser();return n&&(e=r||s(JSON.stringify(n))),"ld:"+t+":"+e}return i.loadFlags=function(){return n.get(a()).then(function(e){if(null==e)return null;try{var n,t=JSON.parse(e);return t&&(void 0===(n=t.$schema)||n<1?t=I(t):delete t.$schema),t}catch(e){return i.clearFlags().then(function(){return null})}})},i.saveFlags=function(e){e=he({},e,{$schema:1});return n.set(a(),JSON.stringify(e))},i.clearFlags=function(){return n.clear(a())},i}function $e(o,i,a,n){var u,s=i.streamUrl,c=i.logger,e={},l=fe(s,"/eval/"+a),f=i.useReport,d=i.evaluationReasons,t=i.streamReconnectDelay,v=Z(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(){m=null;var e,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=fe(s,"/ping/"+a),n=""):e=l+"/"+O(JSON.stringify(h)),t.headers=ee(t.headers,i),e=e+((n=d?n+(n?"&":"")+"withReasons=true":n)?"?":"")+n,E(),c.info(H(e)),u=(new Date).getTime(),p=o.eventSourceFactory(e,t),w)ye(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={};for(var r in t||{})!function(n){w[n]=function(e){D(!(g=!1)),t[n]&&t[n](e)}}(r);k()},e.disconnect=function(){clearTimeout(m),m=null,E()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function He(d,v,i){var a=v.baseUrl,u=v.useReport,s=v.evaluationReasons,c=v.logger,e={},g={};function l(e,n){if(!d.httpRequest)return new Promise(function(e,n){n(new ce($()))});var t,r,o,i,a,u=n?"REPORT":"GET",s=Z(d,v),c=(n&&(s["Content-Type"]="application/json"),g[e]),l=(c||(t=function(){delete g[e]},(f={addPromise:function(n,e){r=n,o&&o(),o=e,n.then(function(e){r===n&&(i(e),t())},function(e){r===n&&(a(e),t())})}}).resultPromise=new Promise(function(e,n){i=e,a=n}),c=f,g[e]=c),d.httpRequest(u,e,ee(s,v),n)),f=l.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new ue(J()):new ce(ke(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=z(e.header("content-type")||"");return Promise.reject(new ce(n))},function(e){return Promise.reject(new ce(M(e)))});return c.addPromise(f,function(){l.cancel&&l.cancel()}),c.resultPromise}return e.fetchJSON=function(e){return l(fe(a,e),null)},e.fetchFlagSettings=function(e,n){var t,r,o="";return u?(t=[a,"/sdk/evalx/",i,"/user"].join(""),r=JSON.stringify(e)):(e=O(JSON.stringify(e)),t=[a,"/sdk/evalx/",i,"/users/",e].join("")),n&&(o="h="+n),c.debug(B(t=t+((o=s?o+(o?"&":"")+"withReasons=true":o)?"?":"")+o)),l(t,r)},e}function Ke(e){var n={diagnosticId:we()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n}function Be(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){o.push({timestamp:e,failed:n,durationMillis:t})},reset:i}}function Ge(n,r,e,t,o,i,a){var u,s,c=!!n.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",f=te(i.eventsUrl,"/events/diagnostic/"+o),d=i.diagnosticRecordingInterval,v=e,g=!!i.streaming;function p(){return{sdk:(e=ie({},n.diagnosticSdkData),i.wrapperName&&(e.wrapperName=i.wrapperName),i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion),e),configuration:{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},platform:n.diagnosticPlatformData};var e}function m(e){i.logger&&i.logger.debug(G.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function h(){var e,n;m((n=(new Date).getTime(),e=ie({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:n},v.getProps()),c&&(e=ie(ie({},e),p())),v.reset(n),e)),s=setTimeout(h,d),u=(new Date).getTime(),c&&r.isEnabled()&&(n=ie({},v.getProps()),r.set(l,JSON.stringify(n)))}return o={start:function(){var t;c?(t=function(e){var n;e?(e=(u||0)+d)<=(n=(new Date).getTime())?h():s=setTimeout(h,e-n):0===Math.floor(4*Math.random())?h():s=setTimeout(h,d)},r.isEnabled()?r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)}):t(!1)):(m(ie({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},p())),s=setTimeout(h,d))},stop:function(){s&&clearTimeout(s)},setStreaming:function(e){g=e}}}var ne=Object.freeze({__proto__:null,baseOptionDefs:X,validate:_e,getTags:Y}).baseOptionDefs,te=a.appendUrlPath;function re(A,F,e,i,n){var t,a,r,o,u,s,c,q,l,_,f,d,v,V,g=e&&e.logger?e.logger:n&&n.logger&&n.logger.default||be("warn"),p=(_=g,f={},(k={}).on=function(e,n,t){f[e]=f[e]||[],f[e]=f[e].concat({handler:n,context:t})},k.off=function(e,n,t){if(f[e])for(var r=0;r<f[e].length;r++)f[e][r].handler===n&&f[e][r].context===t&&(f[e]=f[e].slice(0,r).concat(f[e].slice(r+1)))},k.emit=function(e){if(f[e])for(var n=f[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},k.getEvents=function(){return Object.keys(f)},k.getEventListenerCount=function(e){return f[e]?f[e].length:0},k.maybeReportError=function(e){e&&(f.error?this.emit("error",e):(_||console).error(e.message))},k),m=Me(p),h=_e(e,p,n,g),y=h.sendEvents,w=A,b=h.hash,e=(c=i.localStorage,q=g,l=!(k={}),k.isEnabled=function(){return!!c},k.get=function(e){return new Promise(function(n){c?c.get(e).then(n).catch(function(e){G(e),n(void 0)}):n(void 0)})},k.set=function(e,t){return new Promise(function(n){c?c.set(e,t).then(function(){return n(!0)}).catch(function(e){G(e),n(!1)}):n(!1)})},k.clear=function(e){return new Promise(function(n){c?c.clear(e).then(function(){return n(!0)}).catch(function(e){G(e),n(!1)}):n(!1)})},k),n=Ve(i,w,h),k=h.sendEvents&&!h.diagnosticOptOut,z=k?Ke(w):null,M=k?Be((new Date).getTime()):null,E=k?Ge(i,e,M,n,w,h,z):null,J=$e(i,h,w,M),D=h.eventProcessor||function(e,n,t,r,o,i){var a,u,s,c,l=3<arguments.length&&void 0!==r?r:null,f=4<arguments.length&&void 0!==o?o:null,d={},v=(5<arguments.length&&void 0!==i?i:null)||Ve(e,t,n),g=fe(n.eventsUrl,"/events/bulk/"+t),p=(s=u=0,c={},(r={}).summarizeEvent=function(e){var n,t;"feature"===e.kind&&(n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),(t=c[n])?t.count=t.count+1:c[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===u||e.creationDate<u)&&(u=e.creationDate),e.creationDate>s&&(s=e.creationDate))},r.getSummary=function(){var e,n={},t=!0;for(e in c){var r=c[e],o=n[r.key],i=(o||(o={default:r.default,counters:[]},n[r.key]=o),{value:r.value,count:r.count});void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),t=!1}return t?null:{startDate:u,endDate:s,features:n}},r.clearSummary=function(){s=u=0,c={}},r),m=ze(n),h=n.inlineUsersInEvents,y=n.samplingInterval,w=n.eventCapacity,b=n.flushInterval,k=n.logger,E=[],D=0,O=!1,S=!1;function P(){return 0===y||0===Math.floor(Math.random()*y)}function U(e){E.length<w?(E.push(e),S=!1):(S||(S=!0,k.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),l&&l.incrementDroppedEvents())}return d.enqueue=function(e){var n,t,r;O||(n=t=!1,p.summarizeEvent(e),"feature"===e.kind?P()&&(t=!!e.trackEvents,n=!!(r=e).debugEventsUntilDate&&r.debugEventsUntilDate>D&&r.debugEventsUntilDate>(new Date).getTime()):t=P(),t&&U((t=he({},r=e),"alias"!==r.kind&&(h||"identify"===r.kind?t.user=m.filterUser(r.user):(t.userKey=r.user.key,delete t.user),"feature"===r.kind&&(delete t.trackEvents,delete t.debugEventsUntilDate)),t)),n&&((t=he({},e,{kind:"debug"})).user=m.filterUser(t.user),delete t.trackEvents,delete t.debugEventsUntilDate,U(t)))},d.flush=function(){if(O)return Promise.resolve();var e=E,n=p.getSummary();return p.clearSummary(),n&&(n.kind="summary",e.push(n)),l&&l.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(E=[],k.debug(Ae(e.length)),v.sendEvents(e,g).then(function(e){e&&(e.serverTime&&(D=e.serverTime),le(e.status)||(O=!0),400<=e.status&&ge(function(){f.maybeReportError(new Ee(Re(e.status,"event posting","some events were dropped")))}))}))},d.start=function(){a=setTimeout(function e(){d.flush(),a=setTimeout(e,b)},b)},d.stop=function(){clearTimeout(a)},d}(i,h,w,M,p,n),O=He(i,h,w),$={},S={},P=h.streaming,H=!1,U=!1,K=!0,j=h.stateProvider,I=(u=function(e,n){j||e&&T({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()}),!h.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&Q(e,n)},{setUser:function(e){var n=s&&de(s);(s=Se(e))&&u&&u(de(s),n)},getUser:function(){return s?de(s):null}}),B={validateUser:function(e){if(!e)return Promise.reject(new se(Fe()));var n=de(e);return null!==n.key&&void 0!==n.key?(n.key=n.key.toString(),Promise.resolve(n)):n.anonymous?o.get("ld:$anonUserId").then(function(e){if(e)return n.key=e,n;e=we();return n.key=e,o.set("ld:$anonUserId",e).then(function(){return n})}):Promise.reject(new se(qe()))}},R=(o=e).isEnabled()?new Je(e,w,b,I):null;function G(e){l||(l=!0,q.warn(Pe(e)))}function T(e){if(w&&!(j&&j.enqueueEvent&&j.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(K&&(g.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),K=!1));K=!1}!y||U||i.isDoNotTrack()||(g.debug(xe(e.kind)),D.enqueue(e))}}function X(e,n,t,r){var o=I.getUser(),i=new Date,a=n?n.value:null;if(!h.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=$[u];if(s&&i-s<3e5)return;$[u]=i}s={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},o&&o.anonymous&&(s.contextKind=N(o)),u=S[e];u&&(s.version=u.flagVersion||u.version,s.trackEvents=u.trackEvents,s.debugEventsUntilDate=u.debugEventsUntilDate),(r||u&&u.trackReason)&&n&&(s.reason=n.reason),T(s)}function W(e,n,t,r){var o,i;return S&&ye(S,e)&&S[e]&&!S[e].deleted?(i=L(o=S[e]),null!==o.value&&void 0!==o.value||(i.value=n)):i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}},t&&X(e,i,n,r),i}function L(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function N(e){return e.anonymous?"anonymousUser":"user"}function Q(e,n){j||e&&n&&T({kind:"alias",key:e.key,contextKind:N(e),previousKey:n.key,previousContextKind:N(n),creationDate:(new Date).getTime()})}function Y(){var o;a=!0,I.getUser()&&(o=function(e){try{return JSON.parse(e)}catch(e){return void p.maybeReportError(new Oe("Invalid data received from LaunchDarkly; connection may have been interrupted"))}},J.connect(I.getUser(),b,{ping:function(){g.debug("received ping message from stream");var n=I.getUser();O.fetchFlagSettings(n,b).then(function(e){ve(n,I.getUser())&&C(e||{})}).catch(function(e){p.maybeReportError(new ce(ke(e)))})},put:function(e){e=o(e.data);e&&(g.debug("received streaming update for all flags"),C(e))},patch:function(e){var n,t,r,e=o(e.data);e&&(!(n=S[e.key])||!n.version||!e.version||n.version<e.version?(g.debug(Te(e.key)),t={},delete(r=he({},e)).key,r=L(S[e.key]=r),t[e.key]=n?{previous:n.value,current:r}:{current:r},ee(t)):g.debug(Le(e.key)))},delete:function(e){var n,e=o(e.data);e&&(!S[e.key]||S[e.key].version<e.version?(g.debug(Ne(e.key)),n={},S[e.key]&&!S[e.key].deleted&&(n[e.key]={previous:S[e.key].value}),S[e.key]={version:e.version,deleted:!0},ee(n)):g.debug(Ce(e.key)))}}))}function Z(){a&&(J.disconnect(),a=!1)}function C(e){var n,t,r={};if(!e)return Promise.resolve();for(n in S)ye(S,n)&&S[n]&&(e[n]&&!ve(e[n].value,S[n].value)?r[n]={previous:S[n].value,current:L(e[n])}:e[n]&&!e[n].deleted||(r[n]={previous:S[n].value}));for(t in e)ye(e,t)&&e[t]&&(!S[t]||S[t].deleted)&&(r[t]={current:L(e[t])});return S=ie({},e),ee(r).catch(function(){})}function ee(o){var i,e=Object.keys(o);return 0<e.length&&(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",S),h.sendEventsOnlyForVariation||j||e.forEach(function(e){X(e,o[e].current)})),t&&R?R.saveFlags(S):Promise.resolve()}function ne(){var e=P||r&&void 0===P;e&&!a?Y():!e&&a&&Z(),E&&E.setStreaming(e)}function te(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}function re(e){w=e.environment,I.setUser(e.user),S=ie({},e.flags),ge(x)}function x(){g.info("LaunchDarkly client initialized"),H=!0,ne(),m.signalSuccess()}function oe(e){m.signalFailure(e)}return"string"==typeof h.bootstrap&&"LOCALSTORAGE"===h.bootstrap.toUpperCase()&&(R?t=!0:g.warn(Pe())),"object"===ae(h.bootstrap)&&(d=h.bootstrap,k=Object.keys(d),!(v=d.$flagsState)&&k.length&&g.warn(Ie()),!1===d.$valid&&g.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags."),V={},k.forEach(function(e){var n;"$flagsState"!==e&&"$valid"!==e&&(n={value:d[e]},v&&v[e]?n=he(n,v[e]):n.version=0,V[e]=n)}),S=V),j?((z=j.getInitialState())?re(z):j.on("init",re),j.on("update",function(e){e.user&&I.setUser(e.user),e.flags&&C(e.flags)})):(A?B.validateUser(F).then(function(e){return I.setUser(e),"object"===ae(h.bootstrap)?x():t?R.loadFlags().then(function(e){return null==e?(S={},O.fetchFlagSettings(I.getUser(),b).then(function(e){return C(e||{})}).then(x).catch(function(e){oe(new ce(ke(e)))})):(S=e,ge(x),O.fetchFlagSettings(I.getUser(),b).then(C).catch(function(e){return p.maybeReportError(e)}))}):O.fetchFlagSettings(I.getUser(),b).then(function(e){S=e||{},x()}).catch(function(e){S={},oe(e)})}):Promise.reject(new ue(je()))).catch(oe),{client:{waitForInitialization:function(){return m.getInitializationPromise()},waitUntilReady:function(){return m.getReadyPromise()},identify:function(e,r,n){return U?pe(Promise.resolve({}),n):j?(g.warn("identify() has no effect here; it must be called on the main client instance"),pe(Promise.resolve(me(S)),n)):pe((t&&R?R.clearFlags():Promise.resolve()).then(function(){return B.validateUser(e)}).then(function(t){return O.fetchFlagSettings(t,r).then(function(e){var n=me(e);return I.setUser(t),b=r,e?C(e).then(function(){return n}):n})}).then(function(e){return a&&Y(),e}).catch(function(e){return p.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return I.getUser()},variation:function(e,n){return W(e,n,!0,!1).value},variationDetail:function(e,n){return W(e,n,!0,!0)},track:function(e,n,t){var r,o;"string"==typeof e?(i.customEventFilter&&!i.customEventFilter(e)&&g.warn(Ue(e)),o={kind:"custom",key:e,user:r=I.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()},r&&r.anonymous&&(o.contextKind=N(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),T(o)):p.maybeReportError(new De(Ue(e)))},alias:Q,on:function(e,n,t){te(e)?(r=!0,H&&ne(),p.on(e,n,t)):p.on.apply(p,arguments)},off:function(e){var n;p.off.apply(p,arguments),te(e)&&(n=!1,p.getEvents().forEach(function(e){te(e)&&0<p.getEventListenerCount(e)&&(n=!0)}),n||(r=!1,a&&void 0===P&&Z()))},setStreaming:function(e){e=null===e?void 0:e;e!==P&&(P=e,ne())},flush:function(e){return pe(y?D.flush():Promise.resolve(),e)},allFlags:function(){var e,n={};if(!S)return n;for(e in S)ye(S,e)&&(n[e]=W(e,null,!h.sendEventsOnlyForVariation).value);return n},close:function(e){if(U)return pe(Promise.resolve(),e);function n(){U=!0,S={}}return pe(Promise.resolve().then(function(){if(Z(),E&&E.stop(),y)return D.stop(),D.flush()}).then(n).catch(n),e)}},options:h,emitter:p,ident:I,logger:g,requestor:O,start:function(){y&&(E&&E.start(),D.start())},enqueueEvent:T,getFlagsInternal:function(){return S},getEnvironmentId:function(){return w},internalChangeEventName:"internal-change"}}function oe(n,e){var t,r=Object.keys(n);return Object.getOwnPropertySymbols&&(t=Object.getOwnPropertySymbols(n),e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),r.push.apply(r,t)),r}function Xe(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?oe(Object(o),!0).forEach(function(e){var n,t;n=r,t=o[e=e],e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):oe(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}var We=Object.freeze({__proto__:null,commonBasicLogger:C,createConsoleLogger:be,errors:k,initialize:re,messages:G,utils:a,version:"3.6.0"}).commonBasicLogger;function Qe(e){return We(Xe({destination:console.log},e))}var Ye={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Ze(e,n,t,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){e=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(e)return parseInt(e[2],10)<73}return 1}())return Ye;var i,a,u=new window.XMLHttpRequest;for(i in u.open(e,n,!o),t||{})Object.prototype.hasOwnProperty.call(t,i)&&u.setRequestHeader(i,t[i]);return o?(u.send(r),Ye):{promise:new Promise(function(e,n){u.addEventListener("load",function(){a||e({status:u.status,header:function(e){return u.getResponseHeader(e)},body:u.responseText})}),u.addEventListener("error",function(){a||n(new Error)}),u.send(r)}),cancel:function(){a=!0,u.abort()}}}function en(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(nn,"\\$&")}var nn=/[|\\{}()[\]^$+*?.]/g;function tn(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(function(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("^"+en(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+en(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+en(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return}return o.test(i)}(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 rn=300;function on(o,n){var t,r;function i(){r&&r.dispose(),t&&t.length&&(r=tn(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)}o.requestor.fetchJSON("/sdk/goals/"+o.getEnvironmentId()).then(function(e){e&&0<e.length&&(r=tn(t=e,a),u(rn,i)),n()}).catch(function(e){o.emitter.maybeReportError(new k.LDUnexpectedResponseError((e&&e.message,e.message))),n()})}var h="goalsReady",an={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function un(e,n){function t(){o.synchronousFlush=!0,i.flush().catch(function(){}),o.synchronousFlush=!1}var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},o=function(e){var i,n,a={synchronousFlush:!1},t=(window.XMLHttpRequest&&(i=e&&e.disableSyncEventPost,a.httpRequest=function(e,n,t,r){var o=a.synchronousFlush&!i;return a.synchronousFlush=!1,Ze(e,n,t,r,o)}),a.httpAllowsPost=function(){return n=void 0===n?!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest:n},a.httpFallbackPing=function(e){(new window.Image).src=e},e&&e.eventUrlTransformer);a.getCurrentUrl=function(){return t?t(window.location.href):window.location.href},a.isDoNotTrack=function(){var e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack;return 1===e||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(a.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){a.localStorage=null}var r=e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(a.eventSourceAllowsReport=!0,window.EventSourcePolyfill):(a.eventSourceAllowsReport=!1,window.EventSource);return window.EventSource&&(a.eventSourceFactory=function(e,n){n=Xe(Xe({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0}),n);return new r(e,n)},a.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}),a.userAgent="JSClient",a.version="2.22.0",a.diagnosticSdkData={name:"js-client-sdk",version:"2.22.0"},a.diagnosticPlatformData={name:"JS"},a.diagnosticUseCombinedEvent=!0,a}(r),e=re(e,n,r,o,an),i=e.client,n=e.options,a=e.emitter,u=new Promise(function(e){var n=a.on(h,function(){a.off(h,n),e()})});i.waitUntilGoalsReady=function(){return u},n.fetchGoals?on(e,function(){a.emit(h)}):a.emit(h),"complete"!==document.readyState?window.addEventListener("load",e.start):e.start();return window.addEventListener("beforeunload",t),window.addEventListener("unload",t),i}a=be;var sn={initialize:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(G.deprecated("default export","named LDClient export")),un(e,n,t)},version:"2.22.0"};e.basicLogger=Qe,e.createConsoleLogger=a,e.default=sn,e.initialize=un,e.version="2.22.0",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).LDClient={})}(this,function(e){"use strict";function y(n,e){var t,r=Object.keys(n);return Object.getOwnPropertySymbols&&(t=Object.getOwnPropertySymbols(n),e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),r.push.apply(r,t)),r}function ie(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?y(Object(o),!0).forEach(function(e){var n,t;n=r,t=o[e=e],e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):y(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}function ae(e){return(ae="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 w(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||function(e){if(e){if("string"==typeof e)return t(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(n="Object"===n&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,void 0):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function n(e){function n(e,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=n}return(n.prototype=new Error).name=e,n.prototype.constructor=n}var Ee=n("LaunchDarklyUnexpectedResponseError"),ue=n("LaunchDarklyInvalidEnvironmentIdError"),se=n("LaunchDarklyInvalidUserError"),De=n("LaunchDarklyInvalidEventKeyError"),b=n("LaunchDarklyInvalidArgumentError"),ce=n("LaunchDarklyFlagFetchError"),Oe=n("LaunchDarklyInvalidDataError");function le(e){return!(400<=e&&e<500)||400===e||408===e||429===e}for(var k=Object.freeze({__proto__:null,LDUnexpectedResponseError:Ee,LDInvalidEnvironmentIdError:ue,LDInvalidUserError:se,LDInvalidEventKeyError:De,LDInvalidArgumentError:b,LDFlagFetchError:ce,LDInvalidDataError:Oe,isHttpErrorRecoverable:le}),E=function(e){for(var n,t=e.length,r=t%3,o=[],i=0,a=t-r;i<a;i+=16383)o.push(function(e,n,t){for(var r,o=[],i=n;i<t;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(u[(r=r)>>18&63]+u[r>>12&63]+u[r>>6&63]+u[63&r]);return o.join("")}(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=[],r=[],o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,D=o.length;i<D;++i)u[i]=o[i],r[o.charCodeAt(i)]=i;r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63;var S=Array.isArray,P=Object.keys,U=Object.prototype.hasOwnProperty,j=["key","secondary","ip","country","email","firstName","lastName","avatar","name"];function fe(e,n){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(n.startsWith("/")?"":"/")+n}function s(e){e=unescape(encodeURIComponent(e));return E(function(e){for(var n=[],t=0;t<e.length;t++)n.push(e.charCodeAt(t));return n}(e))}function O(e){return s(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function de(e){return JSON.parse(JSON.stringify(e))}function ve(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=S(n),u=S(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;a=n instanceof Date,u=t instanceof Date;if(a!=u)return!1;if(a&&u)return n.getTime()==t.getTime();a=n instanceof RegExp,u=t instanceof RegExp;if(a!=u)return!1;if(a&&u)return n.toString()==t.toString();var s=P(n);if((o=s.length)!==P(t).length)return!1;for(r=o;0!=r--;)if(!U.call(t,s[r]))return!1;for(r=o;0!=r--;)if(!e(n[i=s[r]],t[i]))return!1;return!0}return n!=n&&t!=t}(e,n)}function ge(e){setTimeout(e,0)}function pe(e,n){e=e.then(function(e){return n&&setTimeout(function(){n(null,e)},0),e},function(e){if(!n)return Promise.reject(e);setTimeout(function(){n(e,null)},0)});return n?void 0:e}function I(e){var n,t={};for(n in e)ye(e,n)&&(t[n]={value:e[n],version:0});return t}function me(e){var n,t={};for(n in e)ye(e,n)&&(t[n]=e[n].value);return t}function R(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 T(e){var n=e.version||"3.6.0";return e.userAgent+"/"+n}function he(){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 ie(ie({},e),n)},{})}function ye(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function Se(e){if(!e)return e;var n,t;for(t in j){var r=j[t],o=e[r];void 0!==o&&"string"!=typeof o&&((n=n||ie({},e))[r]=String(o))}return n||e}for(var a=Object.freeze({__proto__:null,appendUrlPath:fe,btoa:s,base64URLEncode:O,clone:de,deepEquals:ve,onNextTick:ge,wrapPromiseCallback:pe,transformValuesToVersionedValues:I,transformVersionedValuesToValues:me,chunkUserEventsForUrl:R,getLDUserAgentString:T,extend:he,objectHasOwnProperty:ye,sanitizeUser:Se}),L=function(e){var n=e={exports:{}},t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);{var r,o;t?(r=new Uint8Array(16),n.exports=function(){return t(r),r}):(o=new Array(16),n.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),o[n]=e>>>((3&n)<<3)&255;return o})}return e.exports}(),f=[],c=0;c<256;++c)f[c]=(c+256).toString(16).substr(1);var N,d,v=0,g=0,we=function(e,n,t){var r=n&&t||0,o=n||[],i=(e=e||{}).node||N,t=void 0!==e.clockseq?e.clockseq:d,a=(null!=i&&null!=t||(a=L(),null==i&&(i=N=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==t&&(t=d=16383&(a[6]<<8|a[7]))),void 0!==e.msecs?e.msecs:(new Date).getTime()),u=void 0!==e.nsecs?e.nsecs:g+1,s=a-v+(u-g)/1e4;if(s<0&&void 0===e.clockseq&&(t=t+1&16383),1e4<=(u=(s<0||v<a)&&void 0===e.nsecs?0:u))throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");v=a,d=t;s=(1e4*(268435455&(a+=122192928e5))+(g=u))%4294967296,o[r++]=s>>>24&255,o[r++]=s>>>16&255,o[r++]=s>>>8&255,o[r++]=255&s,e=a/4294967296*1e4&268435455;o[r++]=e>>>8&255,o[r++]=255&e,o[r++]=e>>>24&15|16,o[r++]=e>>>16&255,o[r++]=t>>>8|128,o[r++]=255&t;for(var c,l=0;l<6;++l)o[r+l]=i[l];return n||(c=c||0,[f[o[c++]],f[o[c++]],f[o[c++]],f[o[c++]],"-",f[o[c++]],f[o[c++]],"-",f[o[c++]],f[o[c++]],"-",f[o[c++]],f[o[c++]],"-",f[o[c++]],f[o[c++]],f[o[c++]],f[o[c++]],f[o[c++]],f[o[+c]]].join(""))},p=["debug","info","warn","error","none"];function C(e,u){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(n){return function(e){console&&console[n]&&console[n].call(console,e)}}var s=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],c=!(!e||!e.destination),l=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ",t=1;if(e&&e.level)for(var r=0;r<p.length;r++)p[r]===e.level&&(t=r);for(var o={},i=function(e){var i,a=p[e];"none"!==a&&(e<t?o[a]=function(){}:(i=e,o[a]=function(){var e=i,n=a,t=arguments;if(!(t.length<1)){var r=c?n+": "+l:l,o=1!==t.length&&u?((o=w(t))[0]=r+o[0],u.apply(void 0,w(o))):r+t[0];try{s[e](o)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}}))},a=0;a<p.length;a++)i(a);return o}function be(e,n){return C({level:e,prefix:n})}function l(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}function Pe(e){return"local storage is unavailable: "+l(e)}function Ue(e){return'Custom event "'+e+'" does not exist'}function je(){return"No environment/client-side ID was specified."+m}function Ie(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+m}function x(e,n){return n?'"'+e+'" is deprecated, please use "'+n+'"':'"'+e+'" is deprecated'}function Re(e,n,t){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+n+" - "+(le(e)?t:"giving up permanently")}function A(e){return'Ignoring unknown config option "'+e+'"'}function F(e,n,t){return'Config option "'+e+'" should be of type '+n+", got "+t+", using default value"}function q(e,n){return'Config option "'+e+'" should be a boolean, got '+n+", converting to boolean"}function _(e,n,t){return'Config option "'+e+'" was set to '+n+", changing to minimum value of "+t}function Te(e){return'received streaming update for flag "'+e+'"'}function Le(e){return'received streaming update for flag "'+e+'" but ignored due to version check'}function Ne(e){return'received streaming deletion for flag "'+e+'"'}function Ce(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'}function xe(e){return'enqueueing "'+e+'" event'}function Ae(e){return"sending "+e+" events"}function V(e){return'Config option "'.concat(e,'" must only contain letters, numbers, ., _ or -.')}var m=" 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+'"'},M=function(e){return"network error"+(e?" ("+e+")":"")},J=function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+m},ke=function(e){return"Error fetching flag settings: "+l(e)},Fe=function(){return"No user specified."+m},qe=function(){return"Invalid user specified."+m},$=function(){return"Cannot make HTTP requests in this environment."+m},H=function(e){return"Opening stream connection to "+e},K=function(e,n){return"Error on stream connection: "+l(e)+", will continue retrying every "+n+" milliseconds."},B=function(e){return"polling for feature flags at "+e},G=Object.freeze({__proto__:null,clientInitialized:function(){return"LaunchDarkly client initialized"},clientNotReady:function(){return"LaunchDarkly client is not ready"},eventCapacityExceeded:function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutUser:function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},invalidContentType:z,invalidKey:function(){return"Event key must be a string"},localStorageUnavailable:Pe,networkError:M,unknownCustomEventKey:Ue,environmentNotFound:J,environmentNotSpecified:je,errorFetchingFlags:ke,userNotSpecified:Fe,invalidUser:qe,invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},bootstrapOldFormat:Ie,bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},deprecated:x,httpErrorMessage:Re,httpUnavailable:$,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:A,wrongOptionType:F,wrongOptionTypeBoolean:q,optionBelowMinimum:_,debugPolling:B,debugStreamPing:function(){return"received ping message from stream"},debugStreamPut:function(){return"received streaming update for all flags"},debugStreamPatch:Te,debugStreamPatchIgnored:Le,debugStreamDelete:Ne,debugStreamDeleteIgnored:Ce,debugEnqueueingEvent:xe,debugPostingEvents:Ae,debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},invalidTagValue:V}),X={baseUrl:{default:"https://app.launchdarkly.com"},streamUrl:{default:"https://clientstream.launchdarkly.com"},eventsUrl:{default:"https://events.launchdarkly.com"},sendEvents:{default:!0},streaming:{type:"boolean"},sendLDHeaders:{default:!0},requestHeaderTransform:{type:"function"},inlineUsersInEvents:{default:!1},allowFrequentDuplicateEvents:{default:!1},sendEventsOnlyForVariation:{default:!1},useReport:{default:!1},evaluationReasons:{default:!1},eventCapacity:{default:100,minimum:1},flushInterval:{default:2e3,minimum:2e3},samplingInterval:{default:0,minimum:0},streamReconnectDelay:{default:1e3,minimum:0},allAttributesPrivate:{default:!1},privateAttributeNames:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},autoAliasingOptOut:{default:!1},application:{validator:function(e,n,t,r){var o={};return t.id&&(o.id=Q("".concat(e,".id"),0,t.id,r)),t.version&&(o.version=Q("".concat(e,".version"),0,t.version,r)),o}}},W=/^(\w|\.|-)+$/;function Q(e,n,t,r){if("string"==typeof t&&t.match(W))return t;r.warn(V(e))}function _e(e,n,t,a){var u=he({logger:{default:a}},X,t),r={all_attributes_private:"allAttributesPrivate",private_attribute_names:"privateAttributeNames",samplingInterval:null};function s(e){ge(function(){n&&n.maybeReportError(new b(e))})}var o,c,l,i,f,t=he({},e||{});return f=t,Object.keys(r).forEach(function(e){var n;void 0!==f[e]&&(n=r[e],a&&a.warn(x(e,n)),n&&(void 0===f[n]&&(f[n]=f[e]),delete f[e]))}),o=(i=he({},t),Object.keys(u).forEach(function(e){void 0!==i[e]&&null!==i[e]||(i[e]=u[e]&&u[e].default)}),c=t=i,l=he({},c),Object.keys(c).forEach(function(e){var n,t,r,o,i=c[e];null!=i&&(void 0===(n=u[e])?s(A(e)):(t=n.type||d(n.default),(r=n.validator)?void 0!==(r=r(e,c,c[e],a))?l[e]=r:delete l[e]:"any"!==t&&(r=t.split("|"),o=d(i),r.indexOf(o)<0?"boolean"===t?(l[e]=!!i,s(q(e,o))):(s(F(e,t,o)),l[e]=n.default):"number"===o&&void 0!==n.minimum&&i<n.minimum&&(s(_(e,i,n.minimum)),l[e]=n.minimum))))}),t=l).logger,p.forEach(function(e){if("none"!==e&&(!o[e]||"function"!=typeof o[e]))throw new Error("Provided logger instance must support logger."+e+"(...) method")}),t;function d(e){if(null===e)return"any";if(void 0!==e){if(Array.isArray(e))return"array";e=ae(e);return"boolean"===e||"string"===e||"number"===e||"function"===e?e:"object"}}}function Y(e){var n={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(n["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(n["application-version"]=[e.application.version])),n}function Z(e,n){if(n&&!n.sendLDHeaders)return{};var e={"X-LaunchDarkly-User-Agent":T(e)},t=(n&&n.wrapperName&&(e["X-LaunchDarkly-Wrapper"]=n.wrapperVersion?n.wrapperName+"/"+n.wrapperVersion:n.wrapperName),Y(n)),n=Object.keys(t);return n.length&&(e["x-launchdarkly-tags"]=n.sort().flatMap(function(n){return Array.isArray(t[n])?t[n].sort().map(function(e){return"".concat(n,"/").concat(e)}):["".concat(n,"/").concat(t[n])]}).join(" ")),e}function ee(e,n){return n&&n.requestHeaderTransform?n.requestHeaderTransform(ie({},e)):e}function Ve(u,e,s){var r="/a/"+e+".gif",c=he({"Content-Type":"application/json"},Z(u,s)),l=u.httpFallbackPing,f={};return f.sendChunk=function(e,n,o,t){var i=JSON.stringify(e),a=o?null:we();return t?function t(r){var e=o?c:he({},c,{"X-LaunchDarkly-Event-Schema":"3","X-LaunchDarkly-Payload-ID":a});return u.httpRequest("POST",n,ee(e,s),i).promise.then(function(e){if(e)return 400<=e.status&&le(e.status)&&r?t(!1):(n={status:(e=e).status},(e=(e=e.header("date"))&&Date.parse(e))&&(n.serverTime=e),n);var n}).catch(function(){return r?t(!1):Promise.reject()})}(!0).catch(function(){}):(l&&l(n+r+"?d="+O(i)),Promise.resolve())},f.sendEvents=function(e,n,t){if(!u.httpRequest)return Promise.resolve();for(var r=u.httpAllowsPost(),o=r?[e]:R(2e3-n.length,e),i=[],a=0;a<o.length;a++)i.push(f.sendChunk(o[a],n,t,r));return Promise.all(i)},f}function ze(e){var n={},a=e.allAttributesPrivate,u=e.privateAttributeNames||[],s={key:!0,custom:!0,anonymous:!0},o={key:!0,secondary:!0,ip:!0,country:!0,email:!0,firstName:!0,lastName:!0,avatar:!0,name:!0,anonymous:!0,custom:!0};return n.filterUser=function(e){if(!e)return null;function n(r,o){return Object.keys(r).reduce(function(e,n){var t;return o(n)&&(s[t=n]||!a&&-1===i.indexOf(t)&&-1===u.indexOf(t)?e[0][n]=r[n]:e[1][n]=!0),e},[{},{}])}var i=e.privateAttributeNames||[],t=n(e,function(e){return o[e]}),r=t[0],t=t[1],e=(e.custom&&(e=n(e.custom,function(){return 1}),r.custom=e[0],t=he({},t,e[1])),Object.keys(t));return e.length&&(e.sort(),r.privateAttrs=e),r},n}function Me(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 Je(n,t,r,o){var i={};function a(){var e="",n=o.getUser();return n&&(e=r||s(JSON.stringify(n))),"ld:"+t+":"+e}return i.loadFlags=function(){return n.get(a()).then(function(e){if(null==e)return null;try{var n,t=JSON.parse(e);return t&&(void 0===(n=t.$schema)||n<1?t=I(t):delete t.$schema),t}catch(e){return i.clearFlags().then(function(){return null})}})},i.saveFlags=function(e){e=he({},e,{$schema:1});return n.set(a(),JSON.stringify(e))},i.clearFlags=function(){return n.clear(a())},i}function $e(o,i,a,n){var u,s=i.streamUrl,c=i.logger,e={},l=fe(s,"/eval/"+a),f=i.useReport,d=i.evaluationReasons,t=i.streamReconnectDelay,v=Z(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(){m=null;var e,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=fe(s,"/ping/"+a),n=""):e=l+"/"+O(JSON.stringify(h)),t.headers=ee(t.headers,i),e=e+((n=d?n+(n?"&":"")+"withReasons=true":n)?"?":"")+n,E(),c.info(H(e)),u=(new Date).getTime(),p=o.eventSourceFactory(e,t),w)ye(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={};for(var r in t||{})!function(n){w[n]=function(e){D(!(g=!1)),t[n]&&t[n](e)}}(r);k()},e.disconnect=function(){clearTimeout(m),m=null,E()},e.isConnected=function(){return!!(p&&o.eventSourceIsActive&&o.eventSourceIsActive(p))},e}function He(d,v,i){var a=v.baseUrl,u=v.useReport,s=v.evaluationReasons,c=v.logger,e={},g={};function l(e,n){if(!d.httpRequest)return new Promise(function(e,n){n(new ce($()))});var t,r,o,i,a,u=n?"REPORT":"GET",s=Z(d,v),c=(n&&(s["Content-Type"]="application/json"),g[e]),l=(c||(t=function(){delete g[e]},(f={addPromise:function(n,e){r=n,o&&o(),o=e,n.then(function(e){r===n&&(i(e),t())},function(e){r===n&&(a(e),t())})}}).resultPromise=new Promise(function(e,n){i=e,a=n}),c=f,g[e]=c),d.httpRequest(u,e,ee(s,v),n)),f=l.promise.then(function(e){if(200!==e.status)return Promise.reject(404===(n=e).status?new ue(J()):new ce(ke(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=z(e.header("content-type")||"");return Promise.reject(new ce(n))},function(e){return Promise.reject(new ce(M(e)))});return c.addPromise(f,function(){l.cancel&&l.cancel()}),c.resultPromise}return e.fetchJSON=function(e){return l(fe(a,e),null)},e.fetchFlagSettings=function(e,n){var t,r,o="";return u?(t=[a,"/sdk/evalx/",i,"/user"].join(""),r=JSON.stringify(e)):(e=O(JSON.stringify(e)),t=[a,"/sdk/evalx/",i,"/users/",e].join("")),n&&(o="h="+n),c.debug(B(t=t+((o=s?o+(o?"&":"")+"withReasons=true":o)?"?":"")+o)),l(t,r)},e}function Ke(e){var n={diagnosticId:we()};return e&&(n.sdkKeySuffix=6<e.length?e.substring(e.length-6):e),n}function Be(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){o.push({timestamp:e,failed:n,durationMillis:t})},reset:i}}function Ge(n,r,e,t,o,i,a){var u,s,c=!!n.diagnosticUseCombinedEvent,l="ld:"+o+":$diagnostics",f=te(i.eventsUrl,"/events/diagnostic/"+o),d=i.diagnosticRecordingInterval,v=e,g=!!i.streaming;function p(){return{sdk:(e=ie({},n.diagnosticSdkData),i.wrapperName&&(e.wrapperName=i.wrapperName),i.wrapperVersion&&(e.wrapperVersion=i.wrapperVersion),e),configuration:{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},platform:n.diagnosticPlatformData};var e}function m(e){i.logger&&i.logger.debug(G.debugPostingDiagnosticEvent(e)),t.sendEvents(e,f,!0).then(function(){}).catch(function(){})}function h(){var e,n;m((n=(new Date).getTime(),e=ie({kind:c?"diagnostic-combined":"diagnostic",id:a,creationDate:n},v.getProps()),c&&(e=ie(ie({},e),p())),v.reset(n),e)),s=setTimeout(h,d),u=(new Date).getTime(),c&&r.isEnabled()&&(n=ie({},v.getProps()),r.set(l,JSON.stringify(n)))}return o={start:function(){var t;c?(t=function(e){var n;e?(e=(u||0)+d)<=(n=(new Date).getTime())?h():s=setTimeout(h,e-n):0===Math.floor(4*Math.random())?h():s=setTimeout(h,d)},r.isEnabled()?r.get(l).then(function(e){if(e)try{var n=JSON.parse(e);v.setProps(n),u=n.dataSinceDate}catch(e){}t(!0)}).catch(function(){t(!1)}):t(!1)):(m(ie({kind:"diagnostic-init",id:a,creationDate:v.getProps().dataSinceDate},p())),s=setTimeout(h,d))},stop:function(){s&&clearTimeout(s)},setStreaming:function(e){g=e}}}var ne=Object.freeze({__proto__:null,baseOptionDefs:X,validate:_e,getTags:Y}).baseOptionDefs,te=a.appendUrlPath;function re(A,F,e,i,n){var t,a,r,o,u,s,c,q,l,_,f,d,v,V,g=e&&e.logger?e.logger:n&&n.logger&&n.logger.default||be("warn"),p=(_=g,f={},(k={}).on=function(e,n,t){f[e]=f[e]||[],f[e]=f[e].concat({handler:n,context:t})},k.off=function(e,n,t){if(f[e])for(var r=0;r<f[e].length;r++)f[e][r].handler===n&&f[e][r].context===t&&(f[e]=f[e].slice(0,r).concat(f[e].slice(r+1)))},k.emit=function(e){if(f[e])for(var n=f[e].slice(0),t=0;t<n.length;t++)n[t].handler.apply(n[t].context,Array.prototype.slice.call(arguments,1))},k.getEvents=function(){return Object.keys(f)},k.getEventListenerCount=function(e){return f[e]?f[e].length:0},k.maybeReportError=function(e){e&&(f.error?this.emit("error",e):(_||console).error(e.message))},k),m=Me(p),h=_e(e,p,n,g),y=h.sendEvents,w=A,b=h.hash,e=(c=i.localStorage,q=g,l=!(k={}),k.isEnabled=function(){return!!c},k.get=function(e){return new Promise(function(n){c?c.get(e).then(n).catch(function(e){G(e),n(void 0)}):n(void 0)})},k.set=function(e,t){return new Promise(function(n){c?c.set(e,t).then(function(){return n(!0)}).catch(function(e){G(e),n(!1)}):n(!1)})},k.clear=function(e){return new Promise(function(n){c?c.clear(e).then(function(){return n(!0)}).catch(function(e){G(e),n(!1)}):n(!1)})},k),n=Ve(i,w,h),k=h.sendEvents&&!h.diagnosticOptOut,z=k?Ke(w):null,M=k?Be((new Date).getTime()):null,E=k?Ge(i,e,M,n,w,h,z):null,J=$e(i,h,w,M),D=h.eventProcessor||function(e,n,t,r,o,i){var a,u,s,c,l=3<arguments.length&&void 0!==r?r:null,f=4<arguments.length&&void 0!==o?o:null,d={},v=(5<arguments.length&&void 0!==i?i:null)||Ve(e,t,n),g=fe(n.eventsUrl,"/events/bulk/"+t),p=(s=u=0,c={},(r={}).summarizeEvent=function(e){var n,t;"feature"===e.kind&&(n=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),(t=c[n])?t.count=t.count+1:c[n]={count:1,key:e.key,variation:e.variation,version:e.version,value:e.value,default:e.default},(0===u||e.creationDate<u)&&(u=e.creationDate),e.creationDate>s&&(s=e.creationDate))},r.getSummary=function(){var e,n={},t=!0;for(e in c){var r=c[e],o=n[r.key],i=(o||(o={default:r.default,counters:[]},n[r.key]=o),{value:r.value,count:r.count});void 0!==r.variation&&null!==r.variation&&(i.variation=r.variation),r.version?i.version=r.version:i.unknown=!0,o.counters.push(i),t=!1}return t?null:{startDate:u,endDate:s,features:n}},r.clearSummary=function(){s=u=0,c={}},r),m=ze(n),h=n.inlineUsersInEvents,y=n.samplingInterval,w=n.eventCapacity,b=n.flushInterval,k=n.logger,E=[],D=0,O=!1,S=!1;function P(){return 0===y||0===Math.floor(Math.random()*y)}function U(e){E.length<w?(E.push(e),S=!1):(S||(S=!0,k.warn("Exceeded event queue capacity. Increase capacity to avoid dropping events.")),l&&l.incrementDroppedEvents())}return d.enqueue=function(e){var n,t,r;O||(n=t=!1,p.summarizeEvent(e),"feature"===e.kind?P()&&(t=!!e.trackEvents,n=!!(r=e).debugEventsUntilDate&&r.debugEventsUntilDate>D&&r.debugEventsUntilDate>(new Date).getTime()):t=P(),t&&U((t=he({},r=e),"alias"!==r.kind&&(h||"identify"===r.kind?t.user=m.filterUser(r.user):(t.userKey=r.user.key,delete t.user),"feature"===r.kind&&(delete t.trackEvents,delete t.debugEventsUntilDate)),t)),n&&((t=he({},e,{kind:"debug"})).user=m.filterUser(t.user),delete t.trackEvents,delete t.debugEventsUntilDate,U(t)))},d.flush=function(){if(O)return Promise.resolve();var e=E,n=p.getSummary();return p.clearSummary(),n&&(n.kind="summary",e.push(n)),l&&l.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(E=[],k.debug(Ae(e.length)),v.sendEvents(e,g).then(function(e){e&&(e.serverTime&&(D=e.serverTime),le(e.status)||(O=!0),400<=e.status&&ge(function(){f.maybeReportError(new Ee(Re(e.status,"event posting","some events were dropped")))}))}))},d.start=function(){a=setTimeout(function e(){d.flush(),a=setTimeout(e,b)},b)},d.stop=function(){clearTimeout(a)},d}(i,h,w,M,p,n),O=He(i,h,w),$={},S={},P=h.streaming,H=!1,U=!1,K=!0,j=h.stateProvider,I=(u=function(e,n){j||e&&T({kind:"identify",key:e.key,user:e,creationDate:(new Date).getTime()}),!h.autoAliasingOptOut&&n&&n.anonymous&&e&&!e.anonymous&&Q(e,n)},{setUser:function(e){var n=s&&de(s);(s=Se(e))&&u&&u(de(s),n)},getUser:function(){return s?de(s):null}}),B={validateUser:function(e){if(!e)return Promise.reject(new se(Fe()));var n=de(e);return null!==n.key&&void 0!==n.key?(n.key=n.key.toString(),Promise.resolve(n)):n.anonymous?o.get("ld:$anonUserId").then(function(e){if(e)return n.key=e,n;e=we();return n.key=e,o.set("ld:$anonUserId",e).then(function(){return n})}):Promise.reject(new se(qe()))}},R=(o=e).isEnabled()?new Je(e,w,b,I):null;function G(e){l||(l=!0,q.warn(Pe(e)))}function T(e){if(w&&!(j&&j.enqueueEvent&&j.enqueueEvent(e))){if("alias"!==e.kind){if(!e.user)return void(K&&(g.warn("Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"),K=!1));K=!1}!y||U||i.isDoNotTrack()||(g.debug(xe(e.kind)),D.enqueue(e))}}function X(e,n,t,r){var o=I.getUser(),i=new Date,a=n?n.value:null;if(!h.allowFrequentDuplicateEvents){var u=JSON.stringify(a)+(o&&o.key?o.key:"")+e,s=$[u];if(s&&i-s<3e5)return;$[u]=i}s={kind:"feature",key:e,user:o,value:a,variation:n?n.variationIndex:null,default:t,creationDate:i.getTime()},o&&o.anonymous&&(s.contextKind=N(o)),u=S[e];u&&(s.version=u.flagVersion||u.version,s.trackEvents=u.trackEvents,s.debugEventsUntilDate=u.debugEventsUntilDate),(r||u&&u.trackReason)&&n&&(s.reason=n.reason),T(s)}function W(e,n,t,r){var o,i;return S&&ye(S,e)&&S[e]&&!S[e].deleted?(i=L(o=S[e]),null!==o.value&&void 0!==o.value||(i.value=n)):i={value:n,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}},t&&X(e,i,n,r),i}function L(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function N(e){return e.anonymous?"anonymousUser":"user"}function Q(e,n){j||e&&n&&T({kind:"alias",key:e.key,contextKind:N(e),previousKey:n.key,previousContextKind:N(n),creationDate:(new Date).getTime()})}function Y(){var o;a=!0,I.getUser()&&(o=function(e){try{return JSON.parse(e)}catch(e){return void p.maybeReportError(new Oe("Invalid data received from LaunchDarkly; connection may have been interrupted"))}},J.connect(I.getUser(),b,{ping:function(){g.debug("received ping message from stream");var n=I.getUser();O.fetchFlagSettings(n,b).then(function(e){ve(n,I.getUser())&&C(e||{})}).catch(function(e){p.maybeReportError(new ce(ke(e)))})},put:function(e){e=o(e.data);e&&(g.debug("received streaming update for all flags"),C(e))},patch:function(e){var n,t,r,e=o(e.data);e&&(!(n=S[e.key])||!n.version||!e.version||n.version<e.version?(g.debug(Te(e.key)),t={},delete(r=he({},e)).key,r=L(S[e.key]=r),t[e.key]=n?{previous:n.value,current:r}:{current:r},ee(t)):g.debug(Le(e.key)))},delete:function(e){var n,e=o(e.data);e&&(!S[e.key]||S[e.key].version<e.version?(g.debug(Ne(e.key)),n={},S[e.key]&&!S[e.key].deleted&&(n[e.key]={previous:S[e.key].value}),S[e.key]={version:e.version,deleted:!0},ee(n)):g.debug(Ce(e.key)))}}))}function Z(){a&&(J.disconnect(),a=!1)}function C(e){var n,t,r={};if(!e)return Promise.resolve();for(n in S)ye(S,n)&&S[n]&&(e[n]&&!ve(e[n].value,S[n].value)?r[n]={previous:S[n].value,current:L(e[n])}:e[n]&&!e[n].deleted||(r[n]={previous:S[n].value}));for(t in e)ye(e,t)&&e[t]&&(!S[t]||S[t].deleted)&&(r[t]={current:L(e[t])});return S=ie({},e),ee(r).catch(function(){})}function ee(o){var i,e=Object.keys(o);return 0<e.length&&(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",S),h.sendEventsOnlyForVariation||j||e.forEach(function(e){X(e,o[e].current)})),t&&R?R.saveFlags(S):Promise.resolve()}function ne(){var e=P||r&&void 0===P;e&&!a?Y():!e&&a&&Z(),E&&E.setStreaming(e)}function te(e){return"change"===e||"change:"===e.substr(0,"change".length+1)}function re(e){w=e.environment,I.setUser(e.user),S=ie({},e.flags),ge(x)}function x(){g.info("LaunchDarkly client initialized"),H=!0,ne(),m.signalSuccess()}function oe(e){m.signalFailure(e)}return"string"==typeof h.bootstrap&&"LOCALSTORAGE"===h.bootstrap.toUpperCase()&&(R?t=!0:g.warn(Pe())),"object"===ae(h.bootstrap)&&(d=h.bootstrap,k=Object.keys(d),!(v=d.$flagsState)&&k.length&&g.warn(Ie()),!1===d.$valid&&g.warn("LaunchDarkly bootstrap data is not available because the back end could not read the flags."),V={},k.forEach(function(e){var n;"$flagsState"!==e&&"$valid"!==e&&(n={value:d[e]},v&&v[e]?n=he(n,v[e]):n.version=0,V[e]=n)}),S=V),j?((z=j.getInitialState())?re(z):j.on("init",re),j.on("update",function(e){e.user&&I.setUser(e.user),e.flags&&C(e.flags)})):(A?B.validateUser(F).then(function(e){return I.setUser(e),"object"===ae(h.bootstrap)?x():t?R.loadFlags().then(function(e){return null==e?(S={},O.fetchFlagSettings(I.getUser(),b).then(function(e){return C(e||{})}).then(x).catch(function(e){oe(new ce(ke(e)))})):(S=e,ge(x),O.fetchFlagSettings(I.getUser(),b).then(C).catch(function(e){return p.maybeReportError(e)}))}):O.fetchFlagSettings(I.getUser(),b).then(function(e){S=e||{},x()}).catch(function(e){S={},oe(e)})}):Promise.reject(new ue(je()))).catch(oe),{client:{waitForInitialization:function(){return m.getInitializationPromise()},waitUntilReady:function(){return m.getReadyPromise()},identify:function(e,r,n){return U?pe(Promise.resolve({}),n):j?(g.warn("identify() has no effect here; it must be called on the main client instance"),pe(Promise.resolve(me(S)),n)):pe((t&&R?R.clearFlags():Promise.resolve()).then(function(){return B.validateUser(e)}).then(function(t){return O.fetchFlagSettings(t,r).then(function(e){var n=me(e);return I.setUser(t),b=r,e?C(e).then(function(){return n}):n})}).then(function(e){return a&&Y(),e}).catch(function(e){return p.maybeReportError(e),Promise.reject(e)}),n)},getUser:function(){return I.getUser()},variation:function(e,n){return W(e,n,!0,!1).value},variationDetail:function(e,n){return W(e,n,!0,!0)},track:function(e,n,t){var r,o;"string"==typeof e?(i.customEventFilter&&!i.customEventFilter(e)&&g.warn(Ue(e)),o={kind:"custom",key:e,user:r=I.getUser(),url:i.getCurrentUrl(),creationDate:(new Date).getTime()},r&&r.anonymous&&(o.contextKind=N(r)),null!=n&&(o.data=n),null!=t&&(o.metricValue=t),T(o)):p.maybeReportError(new De(Ue(e)))},alias:Q,on:function(e,n,t){te(e)?(r=!0,H&&ne(),p.on(e,n,t)):p.on.apply(p,arguments)},off:function(e){var n;p.off.apply(p,arguments),te(e)&&(n=!1,p.getEvents().forEach(function(e){te(e)&&0<p.getEventListenerCount(e)&&(n=!0)}),n||(r=!1,a&&void 0===P&&Z()))},setStreaming:function(e){e=null===e?void 0:e;e!==P&&(P=e,ne())},flush:function(e){return pe(y?D.flush():Promise.resolve(),e)},allFlags:function(){var e,n={};if(!S)return n;for(e in S)ye(S,e)&&(n[e]=W(e,null,!h.sendEventsOnlyForVariation).value);return n},close:function(e){if(U)return pe(Promise.resolve(),e);function n(){U=!0,S={}}return pe(Promise.resolve().then(function(){if(Z(),E&&E.stop(),y)return D.stop(),D.flush()}).then(n).catch(n),e)}},options:h,emitter:p,ident:I,logger:g,requestor:O,start:function(){y&&(E&&E.start(),D.start())},enqueueEvent:T,getFlagsInternal:function(){return S},getEnvironmentId:function(){return w},internalChangeEventName:"internal-change"}}function oe(n,e){var t,r=Object.keys(n);return Object.getOwnPropertySymbols&&(t=Object.getOwnPropertySymbols(n),e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),r.push.apply(r,t)),r}function Xe(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?oe(Object(o),!0).forEach(function(e){var n,t;n=r,t=o[e=e],e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):oe(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}var We=Object.freeze({__proto__:null,commonBasicLogger:C,createConsoleLogger:be,errors:k,initialize:re,messages:G,utils:a,version:"3.6.0"}).commonBasicLogger;function Qe(e){return We(Xe({destination:console.log},e))}var Ye={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Ze(e,n,t,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){e=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(e)return parseInt(e[2],10)<73}return 1}())return Ye;var i,a,u=new window.XMLHttpRequest;for(i in u.open(e,n,!o),t||{})Object.prototype.hasOwnProperty.call(t,i)&&u.setRequestHeader(i,t[i]);return o?(u.send(r),Ye):{promise:new Promise(function(e,n){u.addEventListener("load",function(){a||e({status:u.status,header:function(e){return u.getResponseHeader(e)},body:u.responseText})}),u.addEventListener("error",function(){a||n(new Error)}),u.send(r)}),cancel:function(){a=!0,u.abort()}}}function en(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(nn,"\\$&")}var nn=/[|\\{}()[\]^$+*?.]/g;function tn(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(function(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("^"+en(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+en(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+en(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return}return o.test(i)}(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 rn=300;function on(o,n){var t,r;function i(){r&&r.dispose(),t&&t.length&&(r=tn(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)}o.requestor.fetchJSON("/sdk/goals/"+o.getEnvironmentId()).then(function(e){e&&0<e.length&&(r=tn(t=e,a),u(rn,i)),n()}).catch(function(e){o.emitter.maybeReportError(new k.LDUnexpectedResponseError((e&&e.message,e.message))),n()})}var h="goalsReady",an={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function un(e,n){function t(){o.synchronousFlush=!0,i.flush().catch(function(){}),o.synchronousFlush=!1}var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},o=function(e){var i,n,a={synchronousFlush:!1},t=(window.XMLHttpRequest&&(i=e&&e.disableSyncEventPost,a.httpRequest=function(e,n,t,r){var o=a.synchronousFlush&!i;return a.synchronousFlush=!1,Ze(e,n,t,r,o)}),a.httpAllowsPost=function(){return n=void 0===n?!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest:n},a.httpFallbackPing=function(e){(new window.Image).src=e},e&&e.eventUrlTransformer);a.getCurrentUrl=function(){return t?t(window.location.href):window.location.href},a.isDoNotTrack=function(){var e=window.navigator&&void 0!==window.navigator.doNotTrack?window.navigator.doNotTrack:window.navigator&&void 0!==window.navigator.msDoNotTrack?window.navigator.msDoNotTrack:window.doNotTrack;return 1===e||!0===e||"1"===e||"yes"===e};try{window.localStorage&&(a.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){a.localStorage=null}var r=e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(a.eventSourceAllowsReport=!0,window.EventSourcePolyfill):(a.eventSourceAllowsReport=!1,window.EventSource);return window.EventSource&&(a.eventSourceFactory=function(e,n){n=Xe(Xe({},{heartbeatTimeout:3e5,silentTimeout:3e5,skipDefaultHeaders:!0}),n);return new r(e,n)},a.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}),a.userAgent="JSClient",a.version="2.22.1",a.diagnosticSdkData={name:"js-client-sdk",version:"2.22.1"},a.diagnosticPlatformData={name:"JS"},a.diagnosticUseCombinedEvent=!0,a}(r),e=re(e,n,r,o,an),i=e.client,n=e.options,a=e.emitter,u=new Promise(function(e){var n=a.on(h,function(){a.off(h,n),e()})});i.waitUntilGoalsReady=function(){return u},n.fetchGoals?on(e,function(){a.emit(h)}):a.emit(h),"complete"!==document.readyState?window.addEventListener("load",e.start):e.start();return window.addEventListener("beforeunload",t),window.addEventListener("unload",t),i}a=be;var sn={initialize:function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(G.deprecated("default export","named LDClient export")),un(e,n,t)},version:"2.22.1"};e.basicLogger=Qe,e.createConsoleLogger=a,e.default=sn,e.initialize=un,e.version="2.22.1",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=ldclient.min.js.map |
{ | ||
"name": "launchdarkly-js-client-sdk", | ||
"version": "2.22.0", | ||
"version": "2.22.1", | ||
"description": "LaunchDarkly SDK for JavaScript", | ||
@@ -5,0 +5,0 @@ "author": "LaunchDarkly <team@launchdarkly.com>", |
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
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
501612