Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

launchdarkly-js-client-sdk

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

launchdarkly-js-client-sdk - npm Package Compare versions

Comparing version 3.1.1 to 3.1.2

4

CHANGELOG.md

@@ -5,2 +5,6 @@ # Change log

## [3.1.1] - 2023-02-15
### Changed:
- Upgrade to `js-sdk-common` version `5.0.2`. This removes usage of optional chaining (`?.`) to allow for use with older transpilers.
## [3.1.0] - 2023-01-18

@@ -7,0 +11,0 @@ ### Changed:

2

dist/ldclient.cjs.js

@@ -1,2 +0,2 @@

"use strict";function e(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return t.prototype=new Error,t.prototype.name=e,t.prototype.constructor=t,t}Object.defineProperty(exports,"__esModule",{value:!0});const t=e("LaunchDarklyUnexpectedResponseError"),n=e("LaunchDarklyInvalidEnvironmentIdError"),r=e("LaunchDarklyInvalidUserError"),o=e("LaunchDarklyInvalidEventKeyError"),i=e("LaunchDarklyInvalidArgumentError"),a=e("LaunchDarklyFlagFetchError");for(var s={LDUnexpectedResponseError:t,LDInvalidEnvironmentIdError:n,LDInvalidUserError:r,LDInvalidEventKeyError:o,LDInvalidArgumentError:i,LDInvalidDataError:e("LaunchDarklyInvalidDataError"),LDFlagFetchError:a,isHttpErrorRecoverable:function(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}},c=function(e){var t=h(e),n=t[0],r=t[1];return 3*(n+r)/4-r},u=function(e){var t,n,r=h(e),o=r[0],i=r[1],a=new g(function(e,t,n){return 3*(t+n)/4-n}(0,o,i)),s=0,c=i>0?o-4:o;for(n=0;n<c;n+=4)t=f[e.charCodeAt(n)]<<18|f[e.charCodeAt(n+1)]<<12|f[e.charCodeAt(n+2)]<<6|f[e.charCodeAt(n+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=255&t;2===i&&(t=f[e.charCodeAt(n)]<<2|f[e.charCodeAt(n+1)]>>4,a[s++]=255&t);1===i&&(t=f[e.charCodeAt(n)]<<10|f[e.charCodeAt(n+1)]<<4|f[e.charCodeAt(n+2)]>>2,a[s++]=t>>8&255,a[s++]=255&t);return a},l=function(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(y(e,a,a+i>s?s:a+i));1===r?(t=e[n-1],o.push(d[t>>2]+d[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],o.push(d[t>>10]+d[t>>4&63]+d[t<<2&63]+"="));return o.join("")},d=[],f=[],g="undefined"!=typeof Uint8Array?Uint8Array:Array,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,m=v.length;p<m;++p)d[p]=v[p],f[v.charCodeAt(p)]=p;function h(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function y(e,t,n){for(var r,o,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(d[(o=r)>>18&63]+d[o>>12&63]+d[o>>6&63]+d[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63;var w={byteLength:c,toByteArray:u,fromByteArray:l},b=Array.isArray,k=Object.keys,E=Object.prototype.hasOwnProperty,D=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i,a=b(t),s=b(n);if(a&&s){if((o=t.length)!=n.length)return!1;for(r=o;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(a!=s)return!1;var c=t instanceof Date,u=n instanceof Date;if(c!=u)return!1;if(c&&u)return t.getTime()==n.getTime();var l=t instanceof RegExp,d=n instanceof RegExp;if(l!=d)return!1;if(l&&d)return t.toString()==n.toString();var f=k(t);if((o=f.length)!==k(n).length)return!1;for(r=o;0!=r--;)if(!E.call(n,f[r]))return!1;for(r=o;0!=r--;)if(!e(t[i=f[r]],n[i]))return!1;return!0}return t!=t&&n!=n};const x=["key","ip","country","email","firstName","lastName","avatar","name"];function C(e){const t=unescape(encodeURIComponent(e));return w.fromByteArray(function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}(t))}function P(e){return C(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function S(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var I,O={appendUrlPath:function(e,t){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(t.startsWith("/")?"":"/")+t},base64URLEncode:P,btoa:C,chunkEventsForUrl:function(e,t){const n=t.slice(0),r=[];let o,i=e;for(;n.length>0;){for(o=[];i>0;){const e=n.shift();if(!e)break;i-=P(JSON.stringify(e)).length,i<0&&o.length>0?n.unshift(e):o.push(e)}i=e,r.push(o)}return r},clone:function(e){return JSON.parse(JSON.stringify(e))},deepEquals:function(e,t){return D(e,t)},extend:function(...e){return e.reduce(((e,t)=>({...e,...t})),{})},getLDUserAgentString:function(e){const t=e.version||"?";return e.userAgent+"/"+t},objectHasOwnProperty:S,onNextTick:function(e){setTimeout(e,0)},sanitizeContext:function(e){if(!e)return e;let t;return null!==e.kind&&void 0!==e.kind||x.forEach((n=>{const r=e[n];void 0!==r&&"string"!=typeof r&&(t=t||{...e},t[n]=String(r))})),t||e},transformValuesToVersionedValues:function(e){const t={};for(const n in e)S(e,n)&&(t[n]={value:e[n],version:0});return t},transformVersionedValuesToValues:function(e){const t={};for(const n in e)S(e,n)&&(t[n]=e[n].value);return t},wrapPromiseCallback:function(e,t){const n=e.then((e=>(t&&setTimeout((()=>{t(null,e)}),0),e)),(e=>{if(!t)return Promise.reject(e);setTimeout((()=>{t(e,null)}),0)}));return t?void 0:n}},L=new Uint8Array(16);function U(){if(!I&&!(I="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return I(L)}var T=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function R(e){return"string"==typeof e&&T.test(e)}for(var A,j,F=[],N=0;N<256;++N)F.push((N+256).toString(16).substr(1));function $(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(F[e[t+0]]+F[e[t+1]]+F[e[t+2]]+F[e[t+3]]+"-"+F[e[t+4]]+F[e[t+5]]+"-"+F[e[t+6]]+F[e[t+7]]+"-"+F[e[t+8]]+F[e[t+9]]+"-"+F[e[t+10]]+F[e[t+11]]+F[e[t+12]]+F[e[t+13]]+F[e[t+14]]+F[e[t+15]]).toLowerCase();if(!R(n))throw TypeError("Stringified UUID is invalid");return n}var V=0,H=0;function M(e){if(!R(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}var q="6ba7b810-9dad-11d1-80b4-00c04fd430c8",K="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function _(e,t,n){function r(e,r,o,i){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=M(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+e.length);if(a.set(r),a.set(e,r.length),(a=n(a))[6]=15&a[6]|t,a[8]=63&a[8]|128,o){i=i||0;for(var s=0;s<16;++s)o[i+s]=a[s];return o}return $(a)}try{r.name=e}catch(e){}return r.DNS=q,r.URL=K,r}function z(e){return 14+(e+64>>>9<<4)+1}function J(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function B(e,t,n,r,o,i){return J((a=J(J(t,e),J(r,i)))<<(s=o)|a>>>32-s,n);var a,s}function G(e,t,n,r,o,i,a){return B(t&n|~t&r,e,t,o,i,a)}function W(e,t,n,r,o,i,a){return B(t&r|n&~r,e,t,o,i,a)}function X(e,t,n,r,o,i,a){return B(t^n^r,e,t,o,i,a)}function Q(e,t,n,r,o,i,a){return B(n^(t|~r),e,t,o,i,a)}var Y=_("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,r="0123456789abcdef",o=0;o<n;o+=8){var i=e[o>>5]>>>o%32&255,a=parseInt(r.charAt(i>>>4&15)+r.charAt(15&i),16);t.push(a)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[z(t)-1]=t;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,a=0;a<e.length;a+=16){var s=n,c=r,u=o,l=i;n=G(n,r,o,i,e[a],7,-680876936),i=G(i,n,r,o,e[a+1],12,-389564586),o=G(o,i,n,r,e[a+2],17,606105819),r=G(r,o,i,n,e[a+3],22,-1044525330),n=G(n,r,o,i,e[a+4],7,-176418897),i=G(i,n,r,o,e[a+5],12,1200080426),o=G(o,i,n,r,e[a+6],17,-1473231341),r=G(r,o,i,n,e[a+7],22,-45705983),n=G(n,r,o,i,e[a+8],7,1770035416),i=G(i,n,r,o,e[a+9],12,-1958414417),o=G(o,i,n,r,e[a+10],17,-42063),r=G(r,o,i,n,e[a+11],22,-1990404162),n=G(n,r,o,i,e[a+12],7,1804603682),i=G(i,n,r,o,e[a+13],12,-40341101),o=G(o,i,n,r,e[a+14],17,-1502002290),n=W(n,r=G(r,o,i,n,e[a+15],22,1236535329),o,i,e[a+1],5,-165796510),i=W(i,n,r,o,e[a+6],9,-1069501632),o=W(o,i,n,r,e[a+11],14,643717713),r=W(r,o,i,n,e[a],20,-373897302),n=W(n,r,o,i,e[a+5],5,-701558691),i=W(i,n,r,o,e[a+10],9,38016083),o=W(o,i,n,r,e[a+15],14,-660478335),r=W(r,o,i,n,e[a+4],20,-405537848),n=W(n,r,o,i,e[a+9],5,568446438),i=W(i,n,r,o,e[a+14],9,-1019803690),o=W(o,i,n,r,e[a+3],14,-187363961),r=W(r,o,i,n,e[a+8],20,1163531501),n=W(n,r,o,i,e[a+13],5,-1444681467),i=W(i,n,r,o,e[a+2],9,-51403784),o=W(o,i,n,r,e[a+7],14,1735328473),n=X(n,r=W(r,o,i,n,e[a+12],20,-1926607734),o,i,e[a+5],4,-378558),i=X(i,n,r,o,e[a+8],11,-2022574463),o=X(o,i,n,r,e[a+11],16,1839030562),r=X(r,o,i,n,e[a+14],23,-35309556),n=X(n,r,o,i,e[a+1],4,-1530992060),i=X(i,n,r,o,e[a+4],11,1272893353),o=X(o,i,n,r,e[a+7],16,-155497632),r=X(r,o,i,n,e[a+10],23,-1094730640),n=X(n,r,o,i,e[a+13],4,681279174),i=X(i,n,r,o,e[a],11,-358537222),o=X(o,i,n,r,e[a+3],16,-722521979),r=X(r,o,i,n,e[a+6],23,76029189),n=X(n,r,o,i,e[a+9],4,-640364487),i=X(i,n,r,o,e[a+12],11,-421815835),o=X(o,i,n,r,e[a+15],16,530742520),n=Q(n,r=X(r,o,i,n,e[a+2],23,-995338651),o,i,e[a],6,-198630844),i=Q(i,n,r,o,e[a+7],10,1126891415),o=Q(o,i,n,r,e[a+14],15,-1416354905),r=Q(r,o,i,n,e[a+5],21,-57434055),n=Q(n,r,o,i,e[a+12],6,1700485571),i=Q(i,n,r,o,e[a+3],10,-1894986606),o=Q(o,i,n,r,e[a+10],15,-1051523),r=Q(r,o,i,n,e[a+1],21,-2054922799),n=Q(n,r,o,i,e[a+8],6,1873313359),i=Q(i,n,r,o,e[a+15],10,-30611744),o=Q(o,i,n,r,e[a+6],15,-1560198380),r=Q(r,o,i,n,e[a+13],21,1309151649),n=Q(n,r,o,i,e[a+4],6,-145523070),i=Q(i,n,r,o,e[a+11],10,-1120210379),o=Q(o,i,n,r,e[a+2],15,718787259),r=Q(r,o,i,n,e[a+9],21,-343485551),n=J(n,s),r=J(r,c),o=J(o,u),i=J(i,l)}return[n,r,o,i]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(z(t)),r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))})),Z=Y;function ee(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function te(e,t){return e<<t|e>>>32-t}var ne=_("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var o=0;o<r.length;++o)e.push(r.charCodeAt(o))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var i=e.length/4+2,a=Math.ceil(i/16),s=new Array(a),c=0;c<a;++c){for(var u=new Uint32Array(16),l=0;l<16;++l)u[l]=e[64*c+4*l]<<24|e[64*c+4*l+1]<<16|e[64*c+4*l+2]<<8|e[64*c+4*l+3];s[c]=u}s[a-1][14]=8*(e.length-1)/Math.pow(2,32),s[a-1][14]=Math.floor(s[a-1][14]),s[a-1][15]=8*(e.length-1)&4294967295;for(var d=0;d<a;++d){for(var f=new Uint32Array(80),g=0;g<16;++g)f[g]=s[d][g];for(var v=16;v<80;++v)f[v]=te(f[v-3]^f[v-8]^f[v-14]^f[v-16],1);for(var p=n[0],m=n[1],h=n[2],y=n[3],w=n[4],b=0;b<80;++b){var k=Math.floor(b/20),E=te(p,5)+ee(k,m,h,y)+w+t[k]+f[b]>>>0;w=y,y=h,h=te(m,30)>>>0,m=p,p=E}n[0]=n[0]+p>>>0,n[1]=n[1]+m>>>0,n[2]=n[2]+h>>>0,n[3]=n[3]+y>>>0,n[4]=n[4]+w>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]})),re=ne;var oe=Object.freeze({__proto__:null,v1:function(e,t,n){var r=t&&n||0,o=t||new Array(16),i=(e=e||{}).node||A,a=void 0!==e.clockseq?e.clockseq:j;if(null==i||null==a){var s=e.random||(e.rng||U)();null==i&&(i=A=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==a&&(a=j=16383&(s[6]<<8|s[7]))}var c=void 0!==e.msecs?e.msecs:Date.now(),u=void 0!==e.nsecs?e.nsecs:H+1,l=c-V+(u-H)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||c>V)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");V=c,H=u,j=a;var d=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;o[r++]=d>>>24&255,o[r++]=d>>>16&255,o[r++]=d>>>8&255,o[r++]=255&d;var f=c/4294967296*1e4&268435455;o[r++]=f>>>8&255,o[r++]=255&f,o[r++]=f>>>24&15|16,o[r++]=f>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var g=0;g<6;++g)o[r+g]=i[g];return t||$(o)},v3:Z,v4:function(e,t,n){var r=(e=e||{}).random||(e.rng||U)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=r[o];return t}return $(r)},v5:re,NIL:"00000000-0000-0000-0000-000000000000",version:function(e){if(!R(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)},validate:R,stringify:$,parse:M});const ie=["debug","info","warn","error","none"];var ae={commonBasicLogger:function(e,t){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(e){return function(t){console&&console[e]&&console[e].call(console,t)}}const r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],o=!(!e||!e.destination),i=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ";let a=1;if(e&&e.level)for(let t=0;t<ie.length;t++)ie[t]===e.level&&(a=t);function s(e,n,a){if(a.length<1)return;let s;const c=o?n+": "+i:i;if(1!==a.length&&t){const e=[...a];e[0]=c+e[0],s=t(...e)}else s=c+a[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}const c={};for(let e=0;e<ie.length;e++){const t=ie[e];if("none"!==t)if(e<a)c[t]=()=>{};else{const n=e;c[t]=function(){s(n,t,arguments)}}}return c},validateLogger:function(e){ie.forEach((t=>{if("none"!==t&&(!e[t]||"function"!=typeof e[t]))throw new Error("Provided logger instance must support logger."+t+"(...) method")}))}};function se(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}const ce=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.";var ue={bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},bootstrapOldFormat:function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+ce},clientInitialized:function(){return"LaunchDarkly client initialized"},clientNotReady:function(){return"LaunchDarkly client is not ready"},debugEnqueueingEvent:function(e){return'enqueueing "'+e+'" event'},debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},debugPostingEvents:function(e){return"sending "+e+" events"},debugStreamDelete:function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored:function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugStreamPatch:function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored:function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamPing:function(){return"received ping message from stream"},debugPolling:function(e){return"polling for feature flags at "+e},debugStreamPut:function(){return"received streaming update for all flags"},deprecated:function(e,t){return t?'"'+e+'" is deprecated, please use "'+t+'"':'"'+e+'" is deprecated'},environmentNotFound:function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+ce},environmentNotSpecified:function(){return"No environment/client-side ID was specified."+ce},errorFetchingFlags:function(e){return"Error fetching flag settings: "+se(e)},eventCapacityExceeded:function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutContext:function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},httpErrorMessage:function(e,t,n){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+t+" - "+(s.isHttpErrorRecoverable(e)?n:"giving up permanently")},httpUnavailable:function(){return"Cannot make HTTP requests in this environment."+ce},identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},inspectorMethodError:(e,t)=>`an inspector: "${t}" of type: "${e}" generated an exception`,invalidContentType:function(e){return'Expected application/json content type but got "'+e+'"'},invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},invalidInspector:(e,t)=>`an inspector: "${t}" of an invalid type (${e}) was configured`,invalidKey:function(){return"Event key must be a string"},invalidContext:function(){return"Invalid context specified."+ce},invalidTagValue:e=>`Config option "${e}" must only contain letters, numbers, ., _ or -.`,localStorageUnavailable:function(e){return"local storage is unavailable: "+se(e)},networkError:e=>"network error"+(e?" ("+e+")":""),optionBelowMinimum:(e,t,n)=>'Config option "'+e+'" was set to '+t+", changing to minimum value of "+n,streamClosing:function(){return"Closing stream connection"},streamConnecting:function(e){return"Opening stream connection to "+e},streamError:function(e,t){return"Error on stream connection: "+se(e)+", will continue retrying after "+t+" milliseconds."},tagValueTooLong:e=>`Value of "${e}" was longer than 64 characters and was discarded.`,unknownCustomEventKey:function(e){return'Custom event "'+e+'" does not exist'},unknownOption:e=>'Ignoring unknown config option "'+e+'"',contextNotSpecified:function(){return"No context specified."+ce},unrecoverableStreamError:e=>`Error on stream connection ${se(e)}, giving up permanently`,wrongOptionType:(e,t,n)=>'Config option "'+e+'" should be of type '+t+", got "+n+", using default value",wrongOptionTypeBoolean:(e,t)=>'Config option "'+e+'" should be a boolean, got '+t+", converting to boolean"};const{validateLogger:le}=ae,de={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"},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},privateAttributes:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},application:{validator:function(e,t,n){const r={};t.id&&(r.id=ve(`${e}.id`,t.id,n));t.version&&(r.version=ve(`${e}.version`,t.version,n));return r}},inspectors:{default:[]}},fe=/^(\w|\.|-)+$/;function ge(e){return e&&e.replace(/\/+$/,"")}function ve(e,t,n){if("string"==typeof t&&t.match(fe)){if(!(t.length>64))return t;n.warn(ue.tagValueTooLong(e))}else n.warn(ue.invalidTagValue(e))}var pe={baseOptionDefs:de,validate:function(e,t,n,r){const o=O.extend({logger:{default:r}},de,n),i={};function a(e){O.onNextTick((()=>{t&&t.maybeReportError(new s.LDInvalidArgumentError(e))}))}let c=O.extend({},e||{});return function(e){const t=e;Object.keys(i).forEach((e=>{if(void 0!==t[e]){const n=i[e];r&&r.warn(ue.deprecated(e,n)),n&&(void 0===t[n]&&(t[n]=t[e]),delete t[e])}}))}(c),c=function(e){const t=O.extend({},e);return Object.keys(o).forEach((e=>{void 0!==t[e]&&null!==t[e]||(t[e]=o[e]&&o[e].default)})),t}(c),c=function(e){const t=O.extend({},e),n=e=>{if(null===e)return"any";if(void 0===e)return;if(Array.isArray(e))return"array";const t=typeof e;return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"};return Object.keys(e).forEach((i=>{const s=e[i];if(null!=s){const c=o[i];if(void 0===c)a(ue.unknownOption(i));else{const o=c.type||n(c.default),u=c.validator;if(u){const n=u(i,e[i],r);void 0!==n?t[i]=n:delete t[i]}else if("any"!==o){const e=o.split("|"),r=n(s);e.indexOf(r)<0?"boolean"===o?(t[i]=!!s,a(ue.wrongOptionTypeBoolean(i,r))):(a(ue.wrongOptionType(i,o,r)),t[i]=c.default):"number"===r&&void 0!==c.minimum&&s<c.minimum&&(a(ue.optionBelowMinimum(i,s,c.minimum)),t[i]=c.minimum)}}}})),t.baseUrl=ge(t.baseUrl),t.streamUrl=ge(t.streamUrl),t.eventsUrl=ge(t.eventsUrl),t}(c),le(c.logger),c},getTags:function(e){const t={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(t["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(t["application-version"]=[e.application.version])),t}};const{getLDUserAgentString:me}=O;var he={getLDHeaders:function(e,t){if(t&&!t.sendLDHeaders)return{};const n={};n[e.userAgentHeaderName||"User-Agent"]=me(e),t&&t.wrapperName&&(n["X-LaunchDarkly-Wrapper"]=t.wrapperVersion?t.wrapperName+"/"+t.wrapperVersion:t.wrapperName);const r=pe.getTags(t),o=Object.keys(r);return o.length&&(n["x-launchdarkly-tags"]=o.sort().map((e=>Array.isArray(r[e])?r[e].sort().map((t=>`${e}/${t}`)):[`${e}/${r[e]}`])).reduce(((e,t)=>e.concat(t)),[]).join(" ")),n},transformHeaders:function(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform({...e}):e}};const{v1:ye}=oe,{getLDHeaders:we,transformHeaders:be}=he,ke=2e3;var Ee=function(e,t,n){const r="/a/"+t+".gif",o=O.extend({"Content-Type":"application/json"},we(e,n)),i=e.httpFallbackPing,a={};return a.sendChunk=(t,a,c,u)=>{const l=JSON.stringify(t),d=c?null:ye();return u?function t(r){const i=c?o:O.extend({},o,{"X-LaunchDarkly-Event-Schema":"4","X-LaunchDarkly-Payload-ID":d});return e.httpRequest("POST",a,be(i,n),l).promise.then((e=>{if(e)return e.status>=400&&s.isHttpErrorRecoverable(e.status)&&r?t(!1):function(e){const t={status:e.status},n=e.header("date");if(n){const e=Date.parse(n);e&&(t.serverTime=e)}return t}(e)})).catch((()=>r?t(!1):Promise.reject()))}(!0).catch((()=>{})):(i&&i(a+r+"?d="+O.base64URLEncode(l)),Promise.resolve())},a.sendEvents=function(t,n,r){if(!e.httpRequest)return Promise.resolve();const o=e.httpAllowsPost();let i;i=o?[t]:O.chunkEventsForUrl(ke-n.length,t);const s=[];for(let e=0;e<i.length;e++)s.push(a.sendChunk(i[e],n,r,o));return Promise.all(s)},a};const{commonBasicLogger:De}=ae;function xe(e){return"string"==typeof e&&"kind"!==e&&e.match(/^(\w|\.|-)+$/)}function Ce(e){return e.includes("%")||e.includes(":")?e.replace(/%/g,"%25").replace(/:/g,"%3A"):e}var Pe={checkContext:function(e,t){if(e){if(t&&(void 0===e.kind||null===e.kind))return void 0!==e.key&&null!==e.key;const n=e.key,r=void 0===e.kind?"user":e.kind,o=xe(r),i="multi"===r||null!=n&&""!==n;if("multi"===r){const t=Object.keys(e).filter((e=>"kind"!==e));return i&&t.every((e=>xe(e)))&&t.every((t=>{const n=e[t].key;return null!=n&&""!==n}))}return i&&o}return!1},getContextKeys:function(e,t=De()){if(!e)return;const n={},{kind:r,key:o}=e;switch(r){case void 0:n.user=`${o}`;break;case"multi":Object.entries(e).filter((([e])=>"kind"!==e)).forEach((([e,t])=>{t&&t.key&&(n[e]=t.key)}));break;case null:t.warn(`null is not a valid context kind: ${e}`);break;case"":t.warn(`'' is not a valid context kind: ${e}`);break;default:n[r]=`${o}`}return n},getContextKinds:function(e){return e?null===e.kind||void 0===e.kind?["user"]:"multi"!==e.kind?[e.kind]:Object.keys(e).filter((e=>"kind"!==e)):[]},getCanonicalKey:function(e){if(e){if((void 0===e.kind||null===e.kind||"user"===e.kind)&&e.key)return e.key;if("multi"!==e.kind&&e.key)return`${e.kind}:${Ce(e.key)}`;if("multi"===e.kind)return Object.keys(e).sort().filter((e=>"kind"!==e)).map((t=>`${t}:${Ce(e[t].key)}`)).join(":")}}};const{getContextKinds:Se}=Pe;var Ie=function(){const e={};let t=0,n=0,r={},o={};return e.summarizeEvent=e=>{if("feature"===e.kind){const i=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),a=r[i];let s=o[e.key];s||(s=new Set,o[e.key]=s),function(e){return e.context?Se(e.context):e.contextKeys?Object.keys(e.contextKeys):[]}(e).forEach((e=>s.add(e))),a?a.count=a.count+1:r[i]={count:1,key:e.key,version:e.version,variation:e.variation,value:e.value,default:e.default},(0===t||e.creationDate<t)&&(t=e.creationDate),e.creationDate>n&&(n=e.creationDate)}},e.getSummary=()=>{const e={};let i=!0;for(const t of Object.values(r)){let n=e[t.key];n||(n={default:t.default,counters:[],contextKinds:[...o[t.key]]},e[t.key]=n);const r={value:t.value,count:t.count};void 0!==t.variation&&null!==t.variation&&(r.variation=t.variation),void 0!==t.version&&null!==t.version?r.version=t.version:r.unknown=!0,n.counters.push(r),i=!1}return i?null:{startDate:t,endDate:n,features:e}},e.clearSummary=()=>{t=0,n=0,r={},o={}},e};function Oe(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Le(e){return(e.startsWith("/")?e.substring(1):e).split("/").map((e=>e.indexOf("~")>=0?e.replace(/~1/g,"/").replace(/~0/g,"~"):e))}function Ue(e){return!e.startsWith("/")}function Te(e,t){const n=Ue(e),r=Ue(t);if(n&&r)return e===t;if(n){const n=Le(t);return 1===n.length&&e===n[0]}if(r){const n=Le(e);return 1===n.length&&t===n[0]}return e===t}function Re(e){return`/${Oe(e)}`}var Ae={cloneExcluding:function(e,t){const n=[],r={},o=[];for(n.push(...Object.keys(e).map((t=>({key:t,ptr:Re(t),source:e,parent:r,visited:[e]}))));n.length;){const e=n.pop();if(t.some((t=>Te(t,e.ptr))))o.push(e.ptr);else{const t=e.source[e.key];if(null===t)e.parent[e.key]=t;else if(Array.isArray(t))e.parent[e.key]=[...t];else if("object"==typeof t){if(e.visited.includes(t))continue;e.parent[e.key]={},n.push(...Object.keys(t).map((n=>{return{key:n,ptr:(r=e.ptr,o=Oe(n),`${r}/${o}`),source:t,parent:e.parent[e.key],visited:[...e.visited,t]};var r,o})))}else e.parent[e.key]=t}}return{cloned:r,excluded:o.sort()}},compare:Te,literalToReference:Re};var je=function(e){const t={},n=e.allAttributesPrivate,r=e.privateAttributes||[],o=["key","kind","_meta","anonymous"],i=["name","ip","firstName","lastName","email","avatar","country"],a=e=>{if("object"!=typeof e||null===e||Array.isArray(e))return;const{cloned:t,excluded:i}=Ae.cloneExcluding(e,(e=>(n?Object.keys(e):[...r,...e._meta&&e._meta.privateAttributes||[]]).filter((e=>!o.some((t=>Ae.compare(e,t))))))(e));return t.key=String(t.key),i.length&&(t._meta||(t._meta={}),t._meta.redactedAttributes=i),t._meta&&(delete t._meta.privateAttributes,0===Object.keys(t._meta).length&&delete t._meta),void 0!==t.anonymous&&(t.anonymous=!!t.anonymous),t};return t.filter=e=>void 0===e.kind||null===e.kind?a((e=>{const t={...e.custom||{},kind:"user",key:e.key};void 0!==e.anonymous&&(t.anonymous=!!e.anonymous);for(const n of i)delete t[n],void 0!==e[n]&&null!==e[n]&&(t[n]=String(e[n]));return void 0!==e.privateAttributeNames&&null!==e.privateAttributeNames&&(t._meta=t._meta||{},t._meta.privateAttributes=e.privateAttributeNames.map((e=>e.startsWith("/")?Ae.literalToReference(e):e))),t})(e)):"multi"===e.kind?(e=>{const t={kind:e.kind},n=Object.keys(e);for(const r of n)if("kind"!==r){const n=a(e[r]);n&&(t[r]=n)}return t})(e):a(e),t};const{getContextKeys:Fe}=Pe;var Ne=function(e,t,n,r=null,o=null,i=null){const a={},c=i||Ee(e,n,t),u=O.appendUrlPath(t.eventsUrl,"/events/bulk/"+n),l=Ie(),d=je(t),f=t.samplingInterval,g=t.eventCapacity,v=t.flushInterval,p=t.logger;let m,h=[],y=0,w=!1,b=!1;function k(){return 0===f||0===Math.floor(Math.random()*f)}function E(e){const t=O.extend({},e);return"identify"===e.kind?t.context=d.filter(e.context):(t.contextKeys=Fe(e.context,p),delete t.context),"feature"===e.kind&&(delete t.trackEvents,delete t.debugEventsUntilDate),t}function D(e){h.length<g?(h.push(e),b=!1):(b||(b=!0,p.warn(ue.eventCapacityExceeded())),r&&r.incrementDroppedEvents())}return a.enqueue=function(e){if(w)return;let t=!1,n=!1;var r;if(l.summarizeEvent(e),"feature"===e.kind?k()&&(t=!!e.trackEvents,n=!!(r=e).debugEventsUntilDate&&r.debugEventsUntilDate>y&&r.debugEventsUntilDate>(new Date).getTime()):t=k(),t&&D(E(e)),n){const t=O.extend({},e,{kind:"debug"});t.context=d.filter(t.context),delete t.trackEvents,delete t.debugEventsUntilDate,D(t)}},a.flush=function(){if(w)return Promise.resolve();const e=h,t=l.getSummary();return l.clearSummary(),t&&(t.kind="summary",e.push(t)),r&&r.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(h=[],p.debug(ue.debugPostingEvents(e.length)),c.sendEvents(e,u).then((e=>{const t=e&&e[0];t&&(t.serverTime&&(y=t.serverTime),s.isHttpErrorRecoverable(t.status)||(w=!0),t.status>=400&&O.onNextTick((()=>{o.maybeReportError(new s.LDUnexpectedResponseError(ue.httpErrorMessage(t.status,"event posting","some events were dropped")))})))})))},a.start=function(){const e=()=>{a.flush(),m=setTimeout(e,v)};m=setTimeout(e,v)},a.stop=function(){clearTimeout(m)},a};var $e=function(e){const t={},n={};return t.on=function(e,t,r){n[e]=n[e]||[],n[e]=n[e].concat({handler:t,context:r})},t.off=function(e,t,r){if(n[e])for(let o=0;o<n[e].length;o++)n[e][o].handler===t&&n[e][o].context===r&&(n[e]=n[e].slice(0,o).concat(n[e].slice(o+1)))},t.emit=function(e){if(!n[e])return;const t=n[e].slice(0);for(let e=0;e<t.length;e++)t[e].handler.apply(t[e].context,Array.prototype.slice.call(arguments,1))},t.getEvents=function(){return Object.keys(n)},t.getEventListenerCount=function(e){return n[e]?n[e].length:0},t.maybeReportError=function(t){t&&(n["error"]?this.emit("error",t):(e||console).error(t.message))},t};const Ve="ready",He="initialized",Me="failed";var qe=function(e){let t=!1,n=!1,r=null,o=null;const i=new Promise((t=>{const n=()=>{e.off(Ve,n),t()};e.on(Ve,n)})).catch((()=>{}));return{getInitializationPromise:()=>o||(t?Promise.resolve():n?Promise.reject(r):(o=new Promise(((t,n)=>{const r=()=>{e.off(He,r),t()},o=t=>{e.off(Me,o),n(t)};e.on(He,r),e.on(Me,o)})),o)),getReadyPromise:()=>i,signalSuccess:()=>{t||n||(t=!0,e.emit(He),e.emit(Ve))},signalFailure:o=>{t||n||(n=!0,r=o,e.emit(Me,o),e.emit(Ve)),e.maybeReportError(o)}}};var Ke=function(e,t,n,r){const o={};function i(){let e="";const o=r.getContext();return o&&(e=n||O.btoa(JSON.stringify(o))),"ld:"+t+":"+e}return o.loadFlags=()=>e.get(i()).then((e=>{if(null==e)return null;try{let t=JSON.parse(e);if(t){const e=t.$schema;void 0===e||e<1?t=O.transformValuesToVersionedValues(t):delete t.$schema}return t}catch(e){return o.clearFlags().then((()=>null))}})),o.saveFlags=t=>{const n=O.extend({},t,{$schema:1});return e.set(i(),JSON.stringify(n))},o.clearFlags=()=>e.clear(i()),o};var _e=function(e,t){const n={};let r=!1;const o=e=>{r||(r=!0,t.warn(ue.localStorageUnavailable(e)))};return n.isEnabled=()=>!!e,n.get=t=>new Promise((n=>{e?e.get(t).then(n).catch((e=>{o(e),n(void 0)})):n(void 0)})),n.set=(t,n)=>new Promise((r=>{e?e.set(t,n).then((()=>r(!0))).catch((e=>{o(e),r(!1)})):r(!1)})),n.clear=t=>new Promise((n=>{e?e.clear(t).then((()=>n(!0))).catch((e=>{o(e),n(!1)})):n(!1)})),n};const{appendUrlPath:ze,base64URLEncode:Je,objectHasOwnProperty:Be}=O,{getLDHeaders:Ge,transformHeaders:We}=he,{isHttpErrorRecoverable:Xe}=s,Qe=3e5,Ye=3e4,Ze=.5;var et=function(e,t,n,r){const o=t.streamUrl,i=t.logger,a={},s=ze(o,"/eval/"+n),c=t.useReport,u=t.evaluationReasons,l=t.streamReconnectDelay,d=Ge(e,t);let f,g=!1,v=null,p=null,m=null,h=null,y=null,w=0;function b(){const e=(t=function(){const e=l*Math.pow(2,w);return e>Ye?Ye:e}(),t-Math.trunc(Math.random()*Ze*t));var t;return w+=1,e}function k(e){if(e.status&&"number"==typeof e.status&&!Xe(e.status))return x(),i.error(ue.unrecoverableStreamError(e)),void(p&&(clearTimeout(p),p=null));const t=b();g||(i.warn(ue.streamError(e,t)),g=!0),C(!1),x(),E(t)}function E(e){p||(e?p=setTimeout(D,e):D())}function D(){let r;p=null;let a="";const l={headers:d,readTimeoutMillis:Qe};if(e.eventSourceFactory){null!=h&&(a="h="+h),c?e.eventSourceAllowsReport?(r=s,l.method="REPORT",l.headers["Content-Type"]="application/json",l.body=JSON.stringify(m)):(r=ze(o,"/ping/"+n),a=""):r=s+"/"+Je(JSON.stringify(m)),l.headers=We(l.headers,t),u&&(a=a+(a?"&":"")+"withReasons=true"),r=r+(a?"?":"")+a,x(),i.info(ue.streamConnecting(r)),f=(new Date).getTime(),v=e.eventSourceFactory(r,l);for(const e in y)Be(y,e)&&v.addEventListener(e,y[e]);v.onerror=k,v.onopen=()=>{w=0}}}function x(){v&&(i.info(ue.streamClosing()),v.close(),v=null)}function C(e){f&&r&&r.recordStreamInit(f,!e,(new Date).getTime()-f),f=null}return a.connect=function(e,t,n){m=e,h=t,y={};for(const e in n||{})y[e]=function(t){g=!1,C(!0),n[e]&&n[e](t)};E()},a.disconnect=function(){clearTimeout(p),p=null,x()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a};var tt=function(e){let t,n,r,o;const i={addPromise:(i,a)=>{t=i,n&&n(),n=a,i.then((n=>{t===i&&(r(n),e&&e())}),(n=>{t===i&&(o(n),e&&e())}))}};return i.resultPromise=new Promise(((e,t)=>{r=e,o=t})),i};const{transformHeaders:nt,getLDHeaders:rt}=he,ot="application/json";var it=function(e,t,n){const r=t.baseUrl,o=t.useReport,i=t.evaluationReasons,a=t.logger,c={},u={};function l(n,r){if(!e.httpRequest)return new Promise(((e,t)=>{t(new s.LDFlagFetchError(ue.httpUnavailable()))}));const o=r?"REPORT":"GET",i=rt(e,t);r&&(i["Content-Type"]=ot);let a=u[n];a||(a=tt((()=>{delete u[n]})),u[n]=a);const c=e.httpRequest(o,n,nt(i,t),r),l=c.promise.then((e=>{if(200===e.status){if(e.header("content-type")&&e.header("content-type").substring(0,ot.length)===ot)return JSON.parse(e.body);{const t=ue.invalidContentType(e.header("content-type")||"");return Promise.reject(new s.LDFlagFetchError(t))}}return Promise.reject(function(e){return 404===e.status?new s.LDInvalidEnvironmentIdError(ue.environmentNotFound()):new s.LDFlagFetchError(ue.errorFetchingFlags(e.statusText||String(e.status)))}(e))}),(e=>Promise.reject(new s.LDFlagFetchError(ue.networkError(e)))));return a.addPromise(l,(()=>{c.cancel&&c.cancel()})),a.resultPromise}return c.fetchJSON=function(e){return l(O.appendUrlPath(r,e),null)},c.fetchFlagSettings=function(e,t){let s,c,u,d="";return o?(c=[r,"/sdk/evalx/",n,"/context"].join(""),u=JSON.stringify(e)):(s=O.base64URLEncode(JSON.stringify(e)),c=[r,"/sdk/evalx/",n,"/contexts/",s].join("")),t&&(d="h="+t),i&&(d=d+(d?"&":"")+"withReasons=true"),c=c+(d?"?":"")+d,a.debug(ue.debugPolling(c)),l(c,u)},c};var at=function(e,t){const n={};let r;return n.setContext=function(e){r=O.sanitizeContext(e),r&&t&&t(O.clone(r))},n.getContext=function(){return r?O.clone(r):null},e&&n.setContext(e),n};const{v1:st}=oe,{getContextKinds:ct}=Pe,ut="ld:$anonUserId";var lt=function(e){function t(e){return null==e||"user"===e?ut:`ld:$contextKey:${e}`}function n(n,r){return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?function(n){return e.get(t(n))}(n).then((o=>{if(o)return r.key=o,r;{const o=st();return r.key=o,function(n,r){return e.set(t(r),n)}(o,n).then((()=>r))}})):Promise.reject(new s.LDInvalidUserError(ue.invalidContext()))}this.processContext=e=>{if(!e)return Promise.reject(new s.LDInvalidUserError(ue.contextNotSpecified()));const t=O.clone(e);if("multi"===e.kind){const e=ct(t);return Promise.all(e.map((e=>n(e,t[e])))).then((()=>t))}return n(e.kind,t)}};const{v1:dt}=oe,{baseOptionDefs:ft}=pe,{appendUrlPath:gt}=O;var vt={DiagnosticId:function(e){const t={diagnosticId:dt()};return e&&(t.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),t},DiagnosticsAccumulator:function(e){let t,n,r,o;function i(e){t=e,n=0,r=0,o=[]}return i(e),{getProps:()=>({dataSinceDate:t,droppedEvents:n,eventsInLastBatch:r,streamInits:o}),setProps:e=>{t=e.dataSinceDate,n=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:()=>{n++},setEventsInLastBatch:e=>{r=e},recordStreamInit:(e,t,n)=>{const r={timestamp:e,failed:t,durationMillis:n};o.push(r)},reset:i}},DiagnosticsManager:function(e,t,n,r,o,i,a){const s=!!e.diagnosticUseCombinedEvent,c="ld:"+o+":$diagnostics",u=gt(i.eventsUrl,"/events/diagnostic/"+o),l=i.diagnosticRecordingInterval,d=n;let f,g,v=!!i.streaming;const p={};function m(){return{sdk:w(),configuration:b(),platform:e.diagnosticPlatformData}}function h(e){i.logger&&i.logger.debug(ue.debugPostingDiagnosticEvent(e)),r.sendEvents(e,u,!0).then((()=>{})).catch((()=>{}))}function y(){h(function(){const e=(new Date).getTime();let t={kind:s?"diagnostic-combined":"diagnostic",id:a,creationDate:e,...d.getProps()};return s&&(t={...t,...m()}),d.reset(e),t}()),g=setTimeout(y,l),f=(new Date).getTime(),s&&function(){if(t.isEnabled()){const e={...d.getProps()};t.set(c,JSON.stringify(e))}}()}function w(){const t={...e.diagnosticSdkData};return i.wrapperName&&(t.wrapperName=i.wrapperName),i.wrapperVersion&&(t.wrapperVersion=i.wrapperVersion),t}function b(){return{customBaseURI:i.baseUrl!==ft.baseUrl.default,customStreamURI:i.streamUrl!==ft.streamUrl.default,customEventsURI:i.eventsUrl!==ft.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!v,allAttributesPrivate:!!i.allAttributesPrivate,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation}}return p.start=()=>{s?function(e){if(!t.isEnabled())return e(!1);t.get(c).then((t=>{if(t)try{const e=JSON.parse(t);d.setProps(e),f=e.dataSinceDate}catch(e){}e(!0)})).catch((()=>{e(!1)}))}((e=>{if(e){const e=(f||0)+l,t=(new Date).getTime();t>=e?y():g=setTimeout(y,e-t)}else 0===Math.floor(4*Math.random())?y():g=setTimeout(y,l)})):(h({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate,...m()}),g=setTimeout(y,l))},p.stop=()=>{g&&clearTimeout(g)},p.setStreaming=e=>{v=e},p}};var pt=function(e,t){let n=!1;const r={type:e.type,name:e.name,method:(...o)=>{try{e.method(...o)}catch{n||(n=!0,t.warn(ue.inspectorMethodError(r.type,r.name)))}}};return r};const{onNextTick:mt}=O,ht={flagUsed:"flag-used",flagDetailsChanged:"flag-details-changed",flagDetailChanged:"flag-detail-changed",clientIdentityChanged:"client-identity-changed"};Object.freeze(ht);var yt={InspectorTypes:ht,InspectorManager:function(e,t){const n={},r={[ht.flagUsed]:[],[ht.flagDetailsChanged]:[],[ht.flagDetailChanged]:[],[ht.clientIdentityChanged]:[]},o=e&&e.map((e=>pt(e,t)));return o&&o.forEach((e=>{Object.prototype.hasOwnProperty.call(r,e.type)?r[e.type].push(e):t.warn(ue.invalidInspector(e.type,e.name))})),n.hasListeners=e=>r[e]&&r[e].length,n.onFlagUsed=(e,t,n)=>{r[ht.flagUsed].length&&mt((()=>{r[ht.flagUsed].forEach((r=>r.method(e,t,n)))}))},n.onFlags=e=>{r[ht.flagDetailsChanged].length&&mt((()=>{r[ht.flagDetailsChanged].forEach((t=>t.method(e)))}))},n.onFlagChanged=(e,t)=>{r[ht.flagDetailChanged].length&&mt((()=>{r[ht.flagDetailChanged].forEach((n=>n.method(e,t)))}))},n.onIdentityChanged=e=>{r[ht.clientIdentityChanged].length&&mt((()=>{r[ht.clientIdentityChanged].forEach((t=>t.method(e)))}))},n}};const{commonBasicLogger:wt}=ae,{checkContext:bt,getContextKeys:kt}=Pe,{InspectorTypes:Et,InspectorManager:Dt}=yt,xt="change",Ct="internal-change";var Pt={initialize:function(e,t,n,r,o){const i=function(){if(n&&n.logger)return n.logger;return o&&o.logger&&o.logger.default||wt("warn")}(),a=$e(i),c=qe(a),u=pe.validate(n,a,o,i),l=Dt(u.inspectors,i),d=u.sendEvents;let f=e,g=u.hash;const v=_e(r.localStorage,i),p=Ee(r,f,u),m=u.sendEvents&&!u.diagnosticOptOut,h=m?vt.DiagnosticId(f):null,y=m?vt.DiagnosticsAccumulator((new Date).getTime()):null,w=m?vt.DiagnosticsManager(r,v,y,p,f,u,h):null,b=et(r,u,f,y),k=u.eventProcessor||Ne(r,u,f,y,a,p),E=it(r,u,f);let D,x,C,P={},S=u.streaming,I=!1,L=!1,U=!0;const T=u.stateProvider,R=at(null,(function(e){(function(e){if(T)return;e&&F({kind:"identify",context:e,creationDate:(new Date).getTime()})})(e),l.hasListeners(Et.clientIdentityChanged)&&l.onIdentityChanged(R.getContext())})),A=new lt(v),j=v.isEnabled()?Ke(v,f,g,R):null;function F(e){f&&(T&&T.enqueueEvent&&T.enqueueEvent(e)||(e.context?(U=!1,!d||L||r.isDoNotTrack()||(i.debug(ue.debugEnqueueingEvent(e.kind)),k.enqueue(e))):U&&(i.warn(ue.eventWithoutContext()),U=!1)))}function N(e,t){l.hasListeners(Et.flagDetailChanged)&&l.onFlagChanged(e.key,q(t))}function $(){l.hasListeners(Et.flagDetailsChanged)&&l.onFlags(Object.entries(P).map((([e,t])=>({key:e,detail:q(t)}))).reduce(((e,t)=>(e[t.key]=t.detail,e)),{}))}function V(e,t,n,r){const o=R.getContext(),i=new Date,a={kind:"feature",key:e,context:o,value:t?t.value:null,variation:t?t.variationIndex:null,default:n,creationDate:i.getTime()},s=P[e];s&&(a.version=s.flagVersion?s.flagVersion:s.version,a.trackEvents=s.trackEvents,a.debugEventsUntilDate=s.debugEventsUntilDate),(r||s&&s.trackReason)&&t&&(a.reason=t.reason),F(a)}function H(e){return bt(e,!1)?Promise.resolve(e):Promise.reject(new s.LDInvalidUserError(ue.invalidContext()))}function M(e,t,n,r,o){let i;if(P&&O.objectHasOwnProperty(P,e)&&P[e]&&!P[e].deleted){const n=P[e];i=q(n),null!==n.value&&void 0!==n.value||(i.value=t)}else i={value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return n&&V(e,i,t,r),o||function(e,t){l.hasListeners(Et.flagUsed)&&l.onFlagUsed(e,t,R.getContext())}(e,i),i}function q(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function K(){if(x=!0,!R.getContext())return;const e=e=>{try{return JSON.parse(e)}catch(e){return void a.maybeReportError(new s.LDInvalidDataError(ue.invalidData()))}};b.connect(R.getContext(),g,{ping:function(){i.debug(ue.debugStreamPing());const e=R.getContext();E.fetchFlagSettings(e,g).then((t=>{O.deepEquals(e,R.getContext())&&z(t||{})})).catch((e=>{a.maybeReportError(new s.LDFlagFetchError(ue.errorFetchingFlags(e)))}))},put:function(t){const n=e(t.data);n&&(i.debug(ue.debugStreamPut()),z(n))},patch:function(t){const n=e(t.data);if(!n)return;const r=P[n.key];if(!r||!r.version||!n.version||r.version<n.version){i.debug(ue.debugStreamPatch(n.key));const e={},t=O.extend({},n);delete t.key,P[n.key]=t;const o=q(t);e[n.key]=r?{previous:r.value,current:o}:{current:o},J(e),N(n,t)}else i.debug(ue.debugStreamPatchIgnored(n.key))},delete:function(t){const n=e(t.data);if(n)if(!P[n.key]||P[n.key].version<n.version){i.debug(ue.debugStreamDelete(n.key));const e={};P[n.key]&&!P[n.key].deleted&&(e[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},N(n,P[n.key]),J(e)}else i.debug(ue.debugStreamDeleteIgnored(n.key))}})}function _(){x&&(b.disconnect(),x=!1)}function z(e){const t={};if(!e)return Promise.resolve();for(const n in P)O.objectHasOwnProperty(P,n)&&P[n]&&(e[n]&&!O.deepEquals(e[n].value,P[n].value)?t[n]={previous:P[n].value,current:q(e[n])}:e[n]&&!e[n].deleted||(t[n]={previous:P[n].value}));for(const n in e)O.objectHasOwnProperty(e,n)&&e[n]&&(!P[n]||P[n].deleted)&&(t[n]={current:q(e[n])});return P={...e},$(),J(t).catch((()=>{}))}function J(e){const t=Object.keys(e);if(t.length>0){const n={};t.forEach((t=>{const r=e[t].current,o=r?r.value:void 0,i=e[t].previous;a.emit(xt+":"+t,o,i),n[t]=r?{current:o,previous:i}:{previous:i}})),a.emit(xt,n),a.emit(Ct,P),u.sendEventsOnlyForVariation||T||t.forEach((t=>{V(t,e[t].current)}))}return D&&j?j.saveFlags(P):Promise.resolve()}function B(){const e=S||C&&void 0===S;e&&!x?K():!e&&x&&_(),w&&w.setStreaming(e)}function G(e){return e===xt||e.substr(0,xt.length+1)===xt+":"}if("string"==typeof u.bootstrap&&"LOCALSTORAGE"===u.bootstrap.toUpperCase()&&(j?D=!0:i.warn(ue.localStorageUnavailable())),"object"==typeof u.bootstrap&&(P=function(e){const t=Object.keys(e),n="$flagsState",r="$valid",o=e[n];!o&&t.length&&i.warn(ue.bootstrapOldFormat()),!1===e[r]&&i.warn(ue.bootstrapInvalid());const a={};return t.forEach((t=>{if(t!==n&&t!==r){let n={value:e[t]};o&&o[t]?n=O.extend(n,o[t]):n.version=0,a[t]=n}})),a}(u.bootstrap)),T){const e=T.getInitialState();e?W(e):T.on("init",W),T.on("update",(function(e){e.context&&R.setContext(e.context);e.flags&&z(e.flags)}))}else(function(){if(!e)return Promise.reject(new s.LDInvalidEnvironmentIdError(ue.environmentNotSpecified()));return A.processContext(t).then(H).then((e=>(R.setContext(e),"object"==typeof u.bootstrap?X():D?j.loadFlags().then((e=>null==e?(P={},E.fetchFlagSettings(R.getContext(),g).then((e=>z(e||{}))).then(X).catch((e=>{Q(new s.LDFlagFetchError(ue.errorFetchingFlags(e)))}))):(P=e,O.onNextTick(X),E.fetchFlagSettings(R.getContext(),g).then((e=>z(e))).catch((e=>a.maybeReportError(e)))))):E.fetchFlagSettings(R.getContext(),g).then((e=>{P=e||{},$(),X()})).catch((e=>{P={},Q(e)})))))})().catch(Q);function W(e){f=e.environment,R.setContext(e.context),P={...e.flags},O.onNextTick(X)}function X(){i.info(ue.clientInitialized()),I=!0,B(),c.signalSuccess()}function Q(e){c.signalFailure(e)}const Y={waitForInitialization:()=>c.getInitializationPromise(),waitUntilReady:()=>c.getReadyPromise(),identify:function(e,t,n){if(L)return O.wrapPromiseCallback(Promise.resolve({}),n);if(T)return i.warn(ue.identifyDisabled()),O.wrapPromiseCallback(Promise.resolve(O.transformVersionedValuesToValues(P)),n);const r=D&&j?j.clearFlags():Promise.resolve();return O.wrapPromiseCallback(r.then((()=>A.processContext(e))).then(H).then((e=>E.fetchFlagSettings(e,t).then((n=>{const r=O.transformVersionedValuesToValues(n);return R.setContext(e),g=t,n?z(n).then((()=>r)):r})))).then((e=>(x&&K(),e))).catch((e=>(a.maybeReportError(e),Promise.reject(e)))),n)},getContext:function(){return R.getContext()},variation:function(e,t){return M(e,t,!0,!1,!1).value},variationDetail:function(e,t){return M(e,t,!0,!0,!1)},track:function(e,t,n){if("string"!=typeof e)return void a.maybeReportError(new s.LDInvalidEventKeyError(ue.unknownCustomEventKey(e)));r.customEventFilter&&!r.customEventFilter(e)&&i.warn(ue.unknownCustomEventKey(e));const o=R.getContext(),c={kind:"custom",key:e,context:o,url:r.getCurrentUrl(),creationDate:(new Date).getTime()};o&&o.anonymous&&(c.contextKind=o.anonymous?"anonymousUser":"user"),null!=t&&(c.data=t),null!=n&&(c.metricValue=n),F(c)},on:function(e,t,n){G(e)?(C=!0,I&&B(),a.on(e,t,n)):a.on(...arguments)},off:function(e){if(a.off(...arguments),G(e)){let e=!1;a.getEvents().forEach((t=>{G(t)&&a.getEventListenerCount(t)>0&&(e=!0)})),e||(C=!1,x&&void 0===S&&_())}},setStreaming:function(e){const t=null===e?void 0:e;t!==S&&(S=t,B())},flush:function(e){return O.wrapPromiseCallback(d?k.flush():Promise.resolve(),e)},allFlags:function(){const e={};if(!P)return e;for(const t in P)O.objectHasOwnProperty(P,t)&&!P[t].deleted&&(e[t]=M(t,null,!u.sendEventsOnlyForVariation,!1,!0).value);return e},close:function(e){if(L)return O.wrapPromiseCallback(Promise.resolve(),e);const t=()=>{L=!0,P={}},n=Promise.resolve().then((()=>{if(_(),w&&w.stop(),d)return k.stop(),k.flush()})).then(t).catch(t);return O.wrapPromiseCallback(n,e)}};return{client:Y,options:u,emitter:a,ident:R,logger:i,requestor:E,start:function(){d&&(w&&w.start(),k.start())},enqueueEvent:F,getFlagsInternal:function(){return P},getEnvironmentId:()=>f,internalChangeEventName:Ct}},commonBasicLogger:wt,errors:s,messages:ue,utils:O,getContextKeys:kt},St=Pt.initialize,It=Pt.errors,Ot=Pt.messages,Lt=Pt.getContextKeys;function Ut(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Tt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ut(Object(n),!0).forEach((function(t){Rt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ut(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Rt(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var At=Pt.commonBasicLogger;var jt=function(e){return At(Tt({destination:console.log},e))};var Ft={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Nt(e,t,n,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var t=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(t)return parseInt(t[2],10)<73}return!0}())return Ft;var i=new window.XMLHttpRequest;for(var a in i.open(e,t,!o),n||{})Object.prototype.hasOwnProperty.call(n,a)&&i.setRequestHeader(a,n[a]);if(o)return i.send(r),Ft;var s,c=new Promise((function(e,t){i.addEventListener("load",(function(){s||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})})),i.addEventListener("error",(function(){s||t(new Error)})),i.send(r)}));return{promise:c,cancel:function(){s=!0,i.abort()}}}var $t=e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")};function Vt(e,t,n,r){var o,i,a=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?t:t.replace(r,"")).replace(n,"");switch(e.kind){case"exact":i=t,o=new RegExp("^"+$t(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+$t(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+$t(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Ht(e,t){for(var n={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],s=a.urls||[],c=0;c<s.length;c++)if(Vt(s[c],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?t("pageview",a):(o.push(a),t("click_pageview",a));break}return o.length>0&&(r=function(e){for(var n=function(e,t){for(var n=[],r=0;r<t.length;r++)for(var o=e.target,i=t[r],a=i.selector,s=document.querySelectorAll(a);o&&s.length>0;){for(var c=0;c<s.length;c++)o===s[c]&&n.push(i);o=o.parentNode}return n}(e,o),r=0;r<n.length;r++)t("click",n[r])},document.addEventListener("click",r)),n.dispose=function(){document.removeEventListener("click",r)},n}var Mt=300;function qt(e,t){var n,r;function o(){r&&r.dispose(),n&&n.length&&(r=Ht(n,i))}function i(t,n){var r=e.ident.getContext(),o={kind:t,key:n.key,data:null,url:window.location.href,creationDate:(new Date).getTime(),contextKeys:Lt(r)};return"click"===t&&(o.selector=n.selector),e.enqueueEvent(o)}return e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=Ht(n=e,i),function(e,t){var n,r=window.location.href;function o(){(n=window.location.href)!==r&&(r=n,t())}!function e(t,n){t(),setTimeout((function(){e(t,n)}),n)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(Mt,o)),t()})).catch((function(n){e.emitter.maybeReportError(new It.LDUnexpectedResponseError((n&&n.message,n.message))),t()})),{}}var Kt="goalsReady",_t={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function zt(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var t,n={userAgentHeaderName:"X-LaunchDarkly-User-Agent",synchronousFlush:!1};if(window.XMLHttpRequest){var r=e&&e.disableSyncEventPost;n.httpRequest=function(e,t,o,i){var a=n.synchronousFlush&!r;return n.synchronousFlush=!1,Nt(e,t,o,i,a)}}n.httpAllowsPost=function(){return void 0===t&&(t=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),t},n.httpFallbackPing=function(e){(new window.Image).src=e};var o,i=e&&e.eventUrlTransformer;n.getCurrentUrl=function(){return i?i(window.location.href):window.location.href},n.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&&(n.localStorage={get:function(e){return new Promise((function(t){t(window.localStorage.getItem(e))}))},set:function(e,t){return new Promise((function(n){window.localStorage.setItem(e,t),n()}))},clear:function(e){return new Promise((function(t){window.localStorage.removeItem(e),t()}))}})}catch(e){n.localStorage=null}if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(n.eventSourceAllowsReport=!0,o=window.EventSourcePolyfill):(n.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource){var a=3e5;n.eventSourceFactory=function(e,t){var n=Tt(Tt({},{heartbeatTimeout:a,silentTimeout:a,skipDefaultHeaders:!0}),t);return new o(e,n)},n.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return n.userAgent="JSClient",n.version="3.1.1",n.diagnosticSdkData={name:"js-client-sdk",version:"3.1.1"},n.diagnosticPlatformData={name:"JS"},n.diagnosticUseCombinedEvent=!0,n}(n),o=St(e,t,n,r,_t),i=o.client,a=o.options,s=o.emitter,c=new Promise((function(e){var t=s.on(Kt,(function(){s.off(Kt,t),e()}))}));i.waitUntilGoalsReady=function(){return c},a.fetchGoals?qt(o,(function(){return s.emit(Kt)})):s.emit(Kt),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var u=function(){r.synchronousFlush=!0,i.flush().catch((function(){})),r.synchronousFlush=!1};return document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&u()})),window.addEventListener("pagehide",u),i}var Jt=jt,Bt="3.1.1";var Gt={initialize:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Ot.deprecated("default export","named LDClient export")),zt(e,t,n)},version:Bt};exports.basicLogger=Jt,exports.createConsoleLogger=undefined,exports.default=Gt,exports.initialize=zt,exports.version=Bt;
"use strict";function e(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return t.prototype=new Error,t.prototype.name=e,t.prototype.constructor=t,t}Object.defineProperty(exports,"__esModule",{value:!0});const t=e("LaunchDarklyUnexpectedResponseError"),n=e("LaunchDarklyInvalidEnvironmentIdError"),r=e("LaunchDarklyInvalidUserError"),o=e("LaunchDarklyInvalidEventKeyError"),i=e("LaunchDarklyInvalidArgumentError"),a=e("LaunchDarklyFlagFetchError");for(var s={LDUnexpectedResponseError:t,LDInvalidEnvironmentIdError:n,LDInvalidUserError:r,LDInvalidEventKeyError:o,LDInvalidArgumentError:i,LDInvalidDataError:e("LaunchDarklyInvalidDataError"),LDFlagFetchError:a,isHttpErrorRecoverable:function(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}},c=function(e){var t=h(e),n=t[0],r=t[1];return 3*(n+r)/4-r},u=function(e){var t,n,r=h(e),o=r[0],i=r[1],a=new g(function(e,t,n){return 3*(t+n)/4-n}(0,o,i)),s=0,c=i>0?o-4:o;for(n=0;n<c;n+=4)t=f[e.charCodeAt(n)]<<18|f[e.charCodeAt(n+1)]<<12|f[e.charCodeAt(n+2)]<<6|f[e.charCodeAt(n+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=255&t;2===i&&(t=f[e.charCodeAt(n)]<<2|f[e.charCodeAt(n+1)]>>4,a[s++]=255&t);1===i&&(t=f[e.charCodeAt(n)]<<10|f[e.charCodeAt(n+1)]<<4|f[e.charCodeAt(n+2)]>>2,a[s++]=t>>8&255,a[s++]=255&t);return a},l=function(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(y(e,a,a+i>s?s:a+i));1===r?(t=e[n-1],o.push(d[t>>2]+d[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],o.push(d[t>>10]+d[t>>4&63]+d[t<<2&63]+"="));return o.join("")},d=[],f=[],g="undefined"!=typeof Uint8Array?Uint8Array:Array,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,m=v.length;p<m;++p)d[p]=v[p],f[v.charCodeAt(p)]=p;function h(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function y(e,t,n){for(var r,o,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(d[(o=r)>>18&63]+d[o>>12&63]+d[o>>6&63]+d[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63;var w={byteLength:c,toByteArray:u,fromByteArray:l},b=Array.isArray,k=Object.keys,E=Object.prototype.hasOwnProperty,D=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i,a=b(t),s=b(n);if(a&&s){if((o=t.length)!=n.length)return!1;for(r=o;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(a!=s)return!1;var c=t instanceof Date,u=n instanceof Date;if(c!=u)return!1;if(c&&u)return t.getTime()==n.getTime();var l=t instanceof RegExp,d=n instanceof RegExp;if(l!=d)return!1;if(l&&d)return t.toString()==n.toString();var f=k(t);if((o=f.length)!==k(n).length)return!1;for(r=o;0!=r--;)if(!E.call(n,f[r]))return!1;for(r=o;0!=r--;)if(!e(t[i=f[r]],n[i]))return!1;return!0}return t!=t&&n!=n};const x=["key","ip","country","email","firstName","lastName","avatar","name"];function C(e){const t=unescape(encodeURIComponent(e));return w.fromByteArray(function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}(t))}function P(e){return C(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function S(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var I,O={appendUrlPath:function(e,t){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(t.startsWith("/")?"":"/")+t},base64URLEncode:P,btoa:C,chunkEventsForUrl:function(e,t){const n=t.slice(0),r=[];let o,i=e;for(;n.length>0;){for(o=[];i>0;){const e=n.shift();if(!e)break;i-=P(JSON.stringify(e)).length,i<0&&o.length>0?n.unshift(e):o.push(e)}i=e,r.push(o)}return r},clone:function(e){return JSON.parse(JSON.stringify(e))},deepEquals:function(e,t){return D(e,t)},extend:function(...e){return e.reduce(((e,t)=>({...e,...t})),{})},getLDUserAgentString:function(e){const t=e.version||"?";return e.userAgent+"/"+t},objectHasOwnProperty:S,onNextTick:function(e){setTimeout(e,0)},sanitizeContext:function(e){if(!e)return e;let t;return null!==e.kind&&void 0!==e.kind||x.forEach((n=>{const r=e[n];void 0!==r&&"string"!=typeof r&&(t=t||{...e},t[n]=String(r))})),t||e},transformValuesToVersionedValues:function(e){const t={};for(const n in e)S(e,n)&&(t[n]={value:e[n],version:0});return t},transformVersionedValuesToValues:function(e){const t={};for(const n in e)S(e,n)&&(t[n]=e[n].value);return t},wrapPromiseCallback:function(e,t){const n=e.then((e=>(t&&setTimeout((()=>{t(null,e)}),0),e)),(e=>{if(!t)return Promise.reject(e);setTimeout((()=>{t(e,null)}),0)}));return t?void 0:n}},L=new Uint8Array(16);function U(){if(!I&&!(I="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return I(L)}var T=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function R(e){return"string"==typeof e&&T.test(e)}for(var A,j,F=[],N=0;N<256;++N)F.push((N+256).toString(16).substr(1));function $(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(F[e[t+0]]+F[e[t+1]]+F[e[t+2]]+F[e[t+3]]+"-"+F[e[t+4]]+F[e[t+5]]+"-"+F[e[t+6]]+F[e[t+7]]+"-"+F[e[t+8]]+F[e[t+9]]+"-"+F[e[t+10]]+F[e[t+11]]+F[e[t+12]]+F[e[t+13]]+F[e[t+14]]+F[e[t+15]]).toLowerCase();if(!R(n))throw TypeError("Stringified UUID is invalid");return n}var V=0,H=0;function M(e){if(!R(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}var q="6ba7b810-9dad-11d1-80b4-00c04fd430c8",K="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function _(e,t,n){function r(e,r,o,i){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=M(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+e.length);if(a.set(r),a.set(e,r.length),(a=n(a))[6]=15&a[6]|t,a[8]=63&a[8]|128,o){i=i||0;for(var s=0;s<16;++s)o[i+s]=a[s];return o}return $(a)}try{r.name=e}catch(e){}return r.DNS=q,r.URL=K,r}function z(e){return 14+(e+64>>>9<<4)+1}function J(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function B(e,t,n,r,o,i){return J((a=J(J(t,e),J(r,i)))<<(s=o)|a>>>32-s,n);var a,s}function G(e,t,n,r,o,i,a){return B(t&n|~t&r,e,t,o,i,a)}function W(e,t,n,r,o,i,a){return B(t&r|n&~r,e,t,o,i,a)}function X(e,t,n,r,o,i,a){return B(t^n^r,e,t,o,i,a)}function Q(e,t,n,r,o,i,a){return B(n^(t|~r),e,t,o,i,a)}var Y=_("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,r="0123456789abcdef",o=0;o<n;o+=8){var i=e[o>>5]>>>o%32&255,a=parseInt(r.charAt(i>>>4&15)+r.charAt(15&i),16);t.push(a)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[z(t)-1]=t;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,a=0;a<e.length;a+=16){var s=n,c=r,u=o,l=i;n=G(n,r,o,i,e[a],7,-680876936),i=G(i,n,r,o,e[a+1],12,-389564586),o=G(o,i,n,r,e[a+2],17,606105819),r=G(r,o,i,n,e[a+3],22,-1044525330),n=G(n,r,o,i,e[a+4],7,-176418897),i=G(i,n,r,o,e[a+5],12,1200080426),o=G(o,i,n,r,e[a+6],17,-1473231341),r=G(r,o,i,n,e[a+7],22,-45705983),n=G(n,r,o,i,e[a+8],7,1770035416),i=G(i,n,r,o,e[a+9],12,-1958414417),o=G(o,i,n,r,e[a+10],17,-42063),r=G(r,o,i,n,e[a+11],22,-1990404162),n=G(n,r,o,i,e[a+12],7,1804603682),i=G(i,n,r,o,e[a+13],12,-40341101),o=G(o,i,n,r,e[a+14],17,-1502002290),n=W(n,r=G(r,o,i,n,e[a+15],22,1236535329),o,i,e[a+1],5,-165796510),i=W(i,n,r,o,e[a+6],9,-1069501632),o=W(o,i,n,r,e[a+11],14,643717713),r=W(r,o,i,n,e[a],20,-373897302),n=W(n,r,o,i,e[a+5],5,-701558691),i=W(i,n,r,o,e[a+10],9,38016083),o=W(o,i,n,r,e[a+15],14,-660478335),r=W(r,o,i,n,e[a+4],20,-405537848),n=W(n,r,o,i,e[a+9],5,568446438),i=W(i,n,r,o,e[a+14],9,-1019803690),o=W(o,i,n,r,e[a+3],14,-187363961),r=W(r,o,i,n,e[a+8],20,1163531501),n=W(n,r,o,i,e[a+13],5,-1444681467),i=W(i,n,r,o,e[a+2],9,-51403784),o=W(o,i,n,r,e[a+7],14,1735328473),n=X(n,r=W(r,o,i,n,e[a+12],20,-1926607734),o,i,e[a+5],4,-378558),i=X(i,n,r,o,e[a+8],11,-2022574463),o=X(o,i,n,r,e[a+11],16,1839030562),r=X(r,o,i,n,e[a+14],23,-35309556),n=X(n,r,o,i,e[a+1],4,-1530992060),i=X(i,n,r,o,e[a+4],11,1272893353),o=X(o,i,n,r,e[a+7],16,-155497632),r=X(r,o,i,n,e[a+10],23,-1094730640),n=X(n,r,o,i,e[a+13],4,681279174),i=X(i,n,r,o,e[a],11,-358537222),o=X(o,i,n,r,e[a+3],16,-722521979),r=X(r,o,i,n,e[a+6],23,76029189),n=X(n,r,o,i,e[a+9],4,-640364487),i=X(i,n,r,o,e[a+12],11,-421815835),o=X(o,i,n,r,e[a+15],16,530742520),n=Q(n,r=X(r,o,i,n,e[a+2],23,-995338651),o,i,e[a],6,-198630844),i=Q(i,n,r,o,e[a+7],10,1126891415),o=Q(o,i,n,r,e[a+14],15,-1416354905),r=Q(r,o,i,n,e[a+5],21,-57434055),n=Q(n,r,o,i,e[a+12],6,1700485571),i=Q(i,n,r,o,e[a+3],10,-1894986606),o=Q(o,i,n,r,e[a+10],15,-1051523),r=Q(r,o,i,n,e[a+1],21,-2054922799),n=Q(n,r,o,i,e[a+8],6,1873313359),i=Q(i,n,r,o,e[a+15],10,-30611744),o=Q(o,i,n,r,e[a+6],15,-1560198380),r=Q(r,o,i,n,e[a+13],21,1309151649),n=Q(n,r,o,i,e[a+4],6,-145523070),i=Q(i,n,r,o,e[a+11],10,-1120210379),o=Q(o,i,n,r,e[a+2],15,718787259),r=Q(r,o,i,n,e[a+9],21,-343485551),n=J(n,s),r=J(r,c),o=J(o,u),i=J(i,l)}return[n,r,o,i]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(z(t)),r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))})),Z=Y;function ee(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function te(e,t){return e<<t|e>>>32-t}var ne=_("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var o=0;o<r.length;++o)e.push(r.charCodeAt(o))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var i=e.length/4+2,a=Math.ceil(i/16),s=new Array(a),c=0;c<a;++c){for(var u=new Uint32Array(16),l=0;l<16;++l)u[l]=e[64*c+4*l]<<24|e[64*c+4*l+1]<<16|e[64*c+4*l+2]<<8|e[64*c+4*l+3];s[c]=u}s[a-1][14]=8*(e.length-1)/Math.pow(2,32),s[a-1][14]=Math.floor(s[a-1][14]),s[a-1][15]=8*(e.length-1)&4294967295;for(var d=0;d<a;++d){for(var f=new Uint32Array(80),g=0;g<16;++g)f[g]=s[d][g];for(var v=16;v<80;++v)f[v]=te(f[v-3]^f[v-8]^f[v-14]^f[v-16],1);for(var p=n[0],m=n[1],h=n[2],y=n[3],w=n[4],b=0;b<80;++b){var k=Math.floor(b/20),E=te(p,5)+ee(k,m,h,y)+w+t[k]+f[b]>>>0;w=y,y=h,h=te(m,30)>>>0,m=p,p=E}n[0]=n[0]+p>>>0,n[1]=n[1]+m>>>0,n[2]=n[2]+h>>>0,n[3]=n[3]+y>>>0,n[4]=n[4]+w>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]})),re=ne;var oe=Object.freeze({__proto__:null,v1:function(e,t,n){var r=t&&n||0,o=t||new Array(16),i=(e=e||{}).node||A,a=void 0!==e.clockseq?e.clockseq:j;if(null==i||null==a){var s=e.random||(e.rng||U)();null==i&&(i=A=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==a&&(a=j=16383&(s[6]<<8|s[7]))}var c=void 0!==e.msecs?e.msecs:Date.now(),u=void 0!==e.nsecs?e.nsecs:H+1,l=c-V+(u-H)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||c>V)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");V=c,H=u,j=a;var d=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;o[r++]=d>>>24&255,o[r++]=d>>>16&255,o[r++]=d>>>8&255,o[r++]=255&d;var f=c/4294967296*1e4&268435455;o[r++]=f>>>8&255,o[r++]=255&f,o[r++]=f>>>24&15|16,o[r++]=f>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var g=0;g<6;++g)o[r+g]=i[g];return t||$(o)},v3:Z,v4:function(e,t,n){var r=(e=e||{}).random||(e.rng||U)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=r[o];return t}return $(r)},v5:re,NIL:"00000000-0000-0000-0000-000000000000",version:function(e){if(!R(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)},validate:R,stringify:$,parse:M});const ie=["debug","info","warn","error","none"];var ae={commonBasicLogger:function(e,t){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(e){return function(t){console&&console[e]&&console[e].call(console,t)}}const r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],o=!(!e||!e.destination),i=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ";let a=1;if(e&&e.level)for(let t=0;t<ie.length;t++)ie[t]===e.level&&(a=t);function s(e,n,a){if(a.length<1)return;let s;const c=o?n+": "+i:i;if(1!==a.length&&t){const e=[...a];e[0]=c+e[0],s=t(...e)}else s=c+a[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}const c={};for(let e=0;e<ie.length;e++){const t=ie[e];if("none"!==t)if(e<a)c[t]=()=>{};else{const n=e;c[t]=function(){s(n,t,arguments)}}}return c},validateLogger:function(e){ie.forEach((t=>{if("none"!==t&&(!e[t]||"function"!=typeof e[t]))throw new Error("Provided logger instance must support logger."+t+"(...) method")}))}};function se(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}const ce=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.";var ue={bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},bootstrapOldFormat:function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+ce},clientInitialized:function(){return"LaunchDarkly client initialized"},clientNotReady:function(){return"LaunchDarkly client is not ready"},debugEnqueueingEvent:function(e){return'enqueueing "'+e+'" event'},debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},debugPostingEvents:function(e){return"sending "+e+" events"},debugStreamDelete:function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored:function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugStreamPatch:function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored:function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamPing:function(){return"received ping message from stream"},debugPolling:function(e){return"polling for feature flags at "+e},debugStreamPut:function(){return"received streaming update for all flags"},deprecated:function(e,t){return t?'"'+e+'" is deprecated, please use "'+t+'"':'"'+e+'" is deprecated'},environmentNotFound:function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+ce},environmentNotSpecified:function(){return"No environment/client-side ID was specified."+ce},errorFetchingFlags:function(e){return"Error fetching flag settings: "+se(e)},eventCapacityExceeded:function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutContext:function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},httpErrorMessage:function(e,t,n){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+t+" - "+(s.isHttpErrorRecoverable(e)?n:"giving up permanently")},httpUnavailable:function(){return"Cannot make HTTP requests in this environment."+ce},identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},inspectorMethodError:(e,t)=>`an inspector: "${t}" of type: "${e}" generated an exception`,invalidContentType:function(e){return'Expected application/json content type but got "'+e+'"'},invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},invalidInspector:(e,t)=>`an inspector: "${t}" of an invalid type (${e}) was configured`,invalidKey:function(){return"Event key must be a string"},invalidContext:function(){return"Invalid context specified."+ce},invalidTagValue:e=>`Config option "${e}" must only contain letters, numbers, ., _ or -.`,localStorageUnavailable:function(e){return"local storage is unavailable: "+se(e)},networkError:e=>"network error"+(e?" ("+e+")":""),optionBelowMinimum:(e,t,n)=>'Config option "'+e+'" was set to '+t+", changing to minimum value of "+n,streamClosing:function(){return"Closing stream connection"},streamConnecting:function(e){return"Opening stream connection to "+e},streamError:function(e,t){return"Error on stream connection: "+se(e)+", will continue retrying after "+t+" milliseconds."},tagValueTooLong:e=>`Value of "${e}" was longer than 64 characters and was discarded.`,unknownCustomEventKey:function(e){return'Custom event "'+e+'" does not exist'},unknownOption:e=>'Ignoring unknown config option "'+e+'"',contextNotSpecified:function(){return"No context specified."+ce},unrecoverableStreamError:e=>`Error on stream connection ${se(e)}, giving up permanently`,wrongOptionType:(e,t,n)=>'Config option "'+e+'" should be of type '+t+", got "+n+", using default value",wrongOptionTypeBoolean:(e,t)=>'Config option "'+e+'" should be a boolean, got '+t+", converting to boolean"};const{validateLogger:le}=ae,de={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"},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},privateAttributes:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},application:{validator:function(e,t,n){const r={};t.id&&(r.id=ve(`${e}.id`,t.id,n));t.version&&(r.version=ve(`${e}.version`,t.version,n));return r}},inspectors:{default:[]}},fe=/^(\w|\.|-)+$/;function ge(e){return e&&e.replace(/\/+$/,"")}function ve(e,t,n){if("string"==typeof t&&t.match(fe)){if(!(t.length>64))return t;n.warn(ue.tagValueTooLong(e))}else n.warn(ue.invalidTagValue(e))}var pe={baseOptionDefs:de,validate:function(e,t,n,r){const o=O.extend({logger:{default:r}},de,n),i={};function a(e){O.onNextTick((()=>{t&&t.maybeReportError(new s.LDInvalidArgumentError(e))}))}let c=O.extend({},e||{});return function(e){const t=e;Object.keys(i).forEach((e=>{if(void 0!==t[e]){const n=i[e];r&&r.warn(ue.deprecated(e,n)),n&&(void 0===t[n]&&(t[n]=t[e]),delete t[e])}}))}(c),c=function(e){const t=O.extend({},e);return Object.keys(o).forEach((e=>{void 0!==t[e]&&null!==t[e]||(t[e]=o[e]&&o[e].default)})),t}(c),c=function(e){const t=O.extend({},e),n=e=>{if(null===e)return"any";if(void 0===e)return;if(Array.isArray(e))return"array";const t=typeof e;return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"};return Object.keys(e).forEach((i=>{const s=e[i];if(null!=s){const c=o[i];if(void 0===c)a(ue.unknownOption(i));else{const o=c.type||n(c.default),u=c.validator;if(u){const n=u(i,e[i],r);void 0!==n?t[i]=n:delete t[i]}else if("any"!==o){const e=o.split("|"),r=n(s);e.indexOf(r)<0?"boolean"===o?(t[i]=!!s,a(ue.wrongOptionTypeBoolean(i,r))):(a(ue.wrongOptionType(i,o,r)),t[i]=c.default):"number"===r&&void 0!==c.minimum&&s<c.minimum&&(a(ue.optionBelowMinimum(i,s,c.minimum)),t[i]=c.minimum)}}}})),t.baseUrl=ge(t.baseUrl),t.streamUrl=ge(t.streamUrl),t.eventsUrl=ge(t.eventsUrl),t}(c),le(c.logger),c},getTags:function(e){const t={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(t["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(t["application-version"]=[e.application.version])),t}};const{getLDUserAgentString:me}=O;var he={getLDHeaders:function(e,t){if(t&&!t.sendLDHeaders)return{};const n={};n[e.userAgentHeaderName||"User-Agent"]=me(e),t&&t.wrapperName&&(n["X-LaunchDarkly-Wrapper"]=t.wrapperVersion?t.wrapperName+"/"+t.wrapperVersion:t.wrapperName);const r=pe.getTags(t),o=Object.keys(r);return o.length&&(n["x-launchdarkly-tags"]=o.sort().map((e=>Array.isArray(r[e])?r[e].sort().map((t=>`${e}/${t}`)):[`${e}/${r[e]}`])).reduce(((e,t)=>e.concat(t)),[]).join(" ")),n},transformHeaders:function(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform({...e}):e}};const{v1:ye}=oe,{getLDHeaders:we,transformHeaders:be}=he,ke=2e3;var Ee=function(e,t,n){const r="/a/"+t+".gif",o=O.extend({"Content-Type":"application/json"},we(e,n)),i=e.httpFallbackPing,a={};return a.sendChunk=(t,a,c,u)=>{const l=JSON.stringify(t),d=c?null:ye();return u?function t(r){const i=c?o:O.extend({},o,{"X-LaunchDarkly-Event-Schema":"4","X-LaunchDarkly-Payload-ID":d});return e.httpRequest("POST",a,be(i,n),l).promise.then((e=>{if(e)return e.status>=400&&s.isHttpErrorRecoverable(e.status)&&r?t(!1):function(e){const t={status:e.status},n=e.header("date");if(n){const e=Date.parse(n);e&&(t.serverTime=e)}return t}(e)})).catch((()=>r?t(!1):Promise.reject()))}(!0).catch((()=>{})):(i&&i(a+r+"?d="+O.base64URLEncode(l)),Promise.resolve())},a.sendEvents=function(t,n,r){if(!e.httpRequest)return Promise.resolve();const o=e.httpAllowsPost();let i;i=o?[t]:O.chunkEventsForUrl(ke-n.length,t);const s=[];for(let e=0;e<i.length;e++)s.push(a.sendChunk(i[e],n,r,o));return Promise.all(s)},a};const{commonBasicLogger:De}=ae;function xe(e){return"string"==typeof e&&"kind"!==e&&e.match(/^(\w|\.|-)+$/)}function Ce(e){return e.includes("%")||e.includes(":")?e.replace(/%/g,"%25").replace(/:/g,"%3A"):e}var Pe={checkContext:function(e,t){if(e){if(t&&(void 0===e.kind||null===e.kind))return void 0!==e.key&&null!==e.key;const n=e.key,r=void 0===e.kind?"user":e.kind,o=xe(r),i="multi"===r||null!=n&&""!==n;if("multi"===r){const t=Object.keys(e).filter((e=>"kind"!==e));return i&&t.every((e=>xe(e)))&&t.every((t=>{const n=e[t].key;return null!=n&&""!==n}))}return i&&o}return!1},getContextKeys:function(e,t=De()){if(!e)return;const n={},{kind:r,key:o}=e;switch(r){case void 0:n.user=`${o}`;break;case"multi":Object.entries(e).filter((([e])=>"kind"!==e)).forEach((([e,t])=>{t&&t.key&&(n[e]=t.key)}));break;case null:t.warn(`null is not a valid context kind: ${e}`);break;case"":t.warn(`'' is not a valid context kind: ${e}`);break;default:n[r]=`${o}`}return n},getContextKinds:function(e){return e?null===e.kind||void 0===e.kind?["user"]:"multi"!==e.kind?[e.kind]:Object.keys(e).filter((e=>"kind"!==e)):[]},getCanonicalKey:function(e){if(e){if((void 0===e.kind||null===e.kind||"user"===e.kind)&&e.key)return e.key;if("multi"!==e.kind&&e.key)return`${e.kind}:${Ce(e.key)}`;if("multi"===e.kind)return Object.keys(e).sort().filter((e=>"kind"!==e)).map((t=>`${t}:${Ce(e[t].key)}`)).join(":")}}};const{getContextKinds:Se}=Pe;var Ie=function(){const e={};let t=0,n=0,r={},o={};return e.summarizeEvent=e=>{if("feature"===e.kind){const i=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),a=r[i];let s=o[e.key];s||(s=new Set,o[e.key]=s),function(e){return e.context?Se(e.context):e.contextKeys?Object.keys(e.contextKeys):[]}(e).forEach((e=>s.add(e))),a?a.count=a.count+1:r[i]={count:1,key:e.key,version:e.version,variation:e.variation,value:e.value,default:e.default},(0===t||e.creationDate<t)&&(t=e.creationDate),e.creationDate>n&&(n=e.creationDate)}},e.getSummary=()=>{const e={};let i=!0;for(const t of Object.values(r)){let n=e[t.key];n||(n={default:t.default,counters:[],contextKinds:[...o[t.key]]},e[t.key]=n);const r={value:t.value,count:t.count};void 0!==t.variation&&null!==t.variation&&(r.variation=t.variation),void 0!==t.version&&null!==t.version?r.version=t.version:r.unknown=!0,n.counters.push(r),i=!1}return i?null:{startDate:t,endDate:n,features:e}},e.clearSummary=()=>{t=0,n=0,r={},o={}},e};function Oe(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Le(e){return(e.startsWith("/")?e.substring(1):e).split("/").map((e=>e.indexOf("~")>=0?e.replace(/~1/g,"/").replace(/~0/g,"~"):e))}function Ue(e){return!e.startsWith("/")}function Te(e,t){const n=Ue(e),r=Ue(t);if(n&&r)return e===t;if(n){const n=Le(t);return 1===n.length&&e===n[0]}if(r){const n=Le(e);return 1===n.length&&t===n[0]}return e===t}function Re(e){return`/${Oe(e)}`}var Ae={cloneExcluding:function(e,t){const n=[],r={},o=[];for(n.push(...Object.keys(e).map((t=>({key:t,ptr:Re(t),source:e,parent:r,visited:[e]}))));n.length;){const e=n.pop();if(t.some((t=>Te(t,e.ptr))))o.push(e.ptr);else{const t=e.source[e.key];if(null===t)e.parent[e.key]=t;else if(Array.isArray(t))e.parent[e.key]=[...t];else if("object"==typeof t){if(e.visited.includes(t))continue;e.parent[e.key]={},n.push(...Object.keys(t).map((n=>{return{key:n,ptr:(r=e.ptr,o=Oe(n),`${r}/${o}`),source:t,parent:e.parent[e.key],visited:[...e.visited,t]};var r,o})))}else e.parent[e.key]=t}}return{cloned:r,excluded:o.sort()}},compare:Te,literalToReference:Re};var je=function(e){const t={},n=e.allAttributesPrivate,r=e.privateAttributes||[],o=["key","kind","_meta","anonymous"],i=["name","ip","firstName","lastName","email","avatar","country"],a=e=>{if("object"!=typeof e||null===e||Array.isArray(e))return;const{cloned:t,excluded:i}=Ae.cloneExcluding(e,(e=>(n?Object.keys(e):[...r,...e._meta&&e._meta.privateAttributes||[]]).filter((e=>!o.some((t=>Ae.compare(e,t))))))(e));return t.key=String(t.key),i.length&&(t._meta||(t._meta={}),t._meta.redactedAttributes=i),t._meta&&(delete t._meta.privateAttributes,0===Object.keys(t._meta).length&&delete t._meta),void 0!==t.anonymous&&(t.anonymous=!!t.anonymous),t};return t.filter=e=>void 0===e.kind||null===e.kind?a((e=>{const t={...e.custom||{},kind:"user",key:e.key};void 0!==e.anonymous&&(t.anonymous=!!e.anonymous);for(const n of i)delete t[n],void 0!==e[n]&&null!==e[n]&&(t[n]=String(e[n]));return void 0!==e.privateAttributeNames&&null!==e.privateAttributeNames&&(t._meta=t._meta||{},t._meta.privateAttributes=e.privateAttributeNames.map((e=>e.startsWith("/")?Ae.literalToReference(e):e))),t})(e)):"multi"===e.kind?(e=>{const t={kind:e.kind},n=Object.keys(e);for(const r of n)if("kind"!==r){const n=a(e[r]);n&&(t[r]=n)}return t})(e):a(e),t};const{getContextKeys:Fe}=Pe;var Ne=function(e,t,n,r=null,o=null,i=null){const a={},c=i||Ee(e,n,t),u=O.appendUrlPath(t.eventsUrl,"/events/bulk/"+n),l=Ie(),d=je(t),f=t.samplingInterval,g=t.eventCapacity,v=t.flushInterval,p=t.logger;let m,h=[],y=0,w=!1,b=!1;function k(){return 0===f||0===Math.floor(Math.random()*f)}function E(e){const t=O.extend({},e);return"identify"===e.kind?t.context=d.filter(e.context):(t.contextKeys=Fe(e.context,p),delete t.context),"feature"===e.kind&&(delete t.trackEvents,delete t.debugEventsUntilDate),t}function D(e){h.length<g?(h.push(e),b=!1):(b||(b=!0,p.warn(ue.eventCapacityExceeded())),r&&r.incrementDroppedEvents())}return a.enqueue=function(e){if(w)return;let t=!1,n=!1;var r;if(l.summarizeEvent(e),"feature"===e.kind?k()&&(t=!!e.trackEvents,n=!!(r=e).debugEventsUntilDate&&r.debugEventsUntilDate>y&&r.debugEventsUntilDate>(new Date).getTime()):t=k(),t&&D(E(e)),n){const t=O.extend({},e,{kind:"debug"});t.context=d.filter(t.context),delete t.trackEvents,delete t.debugEventsUntilDate,D(t)}},a.flush=function(){if(w)return Promise.resolve();const e=h,t=l.getSummary();return l.clearSummary(),t&&(t.kind="summary",e.push(t)),r&&r.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(h=[],p.debug(ue.debugPostingEvents(e.length)),c.sendEvents(e,u).then((e=>{const t=e&&e[0];t&&(t.serverTime&&(y=t.serverTime),s.isHttpErrorRecoverable(t.status)||(w=!0),t.status>=400&&O.onNextTick((()=>{o.maybeReportError(new s.LDUnexpectedResponseError(ue.httpErrorMessage(t.status,"event posting","some events were dropped")))})))})))},a.start=function(){const e=()=>{a.flush(),m=setTimeout(e,v)};m=setTimeout(e,v)},a.stop=function(){clearTimeout(m)},a};var $e=function(e){const t={},n={};return t.on=function(e,t,r){n[e]=n[e]||[],n[e]=n[e].concat({handler:t,context:r})},t.off=function(e,t,r){if(n[e])for(let o=0;o<n[e].length;o++)n[e][o].handler===t&&n[e][o].context===r&&(n[e]=n[e].slice(0,o).concat(n[e].slice(o+1)))},t.emit=function(e){if(!n[e])return;const t=n[e].slice(0);for(let e=0;e<t.length;e++)t[e].handler.apply(t[e].context,Array.prototype.slice.call(arguments,1))},t.getEvents=function(){return Object.keys(n)},t.getEventListenerCount=function(e){return n[e]?n[e].length:0},t.maybeReportError=function(t){t&&(n["error"]?this.emit("error",t):(e||console).error(t.message))},t};const Ve="ready",He="initialized",Me="failed";var qe=function(e){let t=!1,n=!1,r=null,o=null;const i=new Promise((t=>{const n=()=>{e.off(Ve,n),t()};e.on(Ve,n)})).catch((()=>{}));return{getInitializationPromise:()=>o||(t?Promise.resolve():n?Promise.reject(r):(o=new Promise(((t,n)=>{const r=()=>{e.off(He,r),t()},o=t=>{e.off(Me,o),n(t)};e.on(He,r),e.on(Me,o)})),o)),getReadyPromise:()=>i,signalSuccess:()=>{t||n||(t=!0,e.emit(He),e.emit(Ve))},signalFailure:o=>{t||n||(n=!0,r=o,e.emit(Me,o),e.emit(Ve)),e.maybeReportError(o)}}};var Ke=function(e,t,n,r){const o={};function i(){let e="";const o=r.getContext();return o&&(e=n||O.btoa(JSON.stringify(o))),"ld:"+t+":"+e}return o.loadFlags=()=>e.get(i()).then((e=>{if(null==e)return null;try{let t=JSON.parse(e);if(t){const e=t.$schema;void 0===e||e<1?t=O.transformValuesToVersionedValues(t):delete t.$schema}return t}catch(e){return o.clearFlags().then((()=>null))}})),o.saveFlags=t=>{const n=O.extend({},t,{$schema:1});return e.set(i(),JSON.stringify(n))},o.clearFlags=()=>e.clear(i()),o};var _e=function(e,t){const n={};let r=!1;const o=e=>{r||(r=!0,t.warn(ue.localStorageUnavailable(e)))};return n.isEnabled=()=>!!e,n.get=t=>new Promise((n=>{e?e.get(t).then(n).catch((e=>{o(e),n(void 0)})):n(void 0)})),n.set=(t,n)=>new Promise((r=>{e?e.set(t,n).then((()=>r(!0))).catch((e=>{o(e),r(!1)})):r(!1)})),n.clear=t=>new Promise((n=>{e?e.clear(t).then((()=>n(!0))).catch((e=>{o(e),n(!1)})):n(!1)})),n};const{appendUrlPath:ze,base64URLEncode:Je,objectHasOwnProperty:Be}=O,{getLDHeaders:Ge,transformHeaders:We}=he,{isHttpErrorRecoverable:Xe}=s,Qe=3e5,Ye=3e4,Ze=.5;var et=function(e,t,n,r){const o=t.streamUrl,i=t.logger,a={},s=ze(o,"/eval/"+n),c=t.useReport,u=t.evaluationReasons,l=t.streamReconnectDelay,d=Ge(e,t);let f,g=!1,v=null,p=null,m=null,h=null,y=null,w=0;function b(){const e=(t=function(){const e=l*Math.pow(2,w);return e>Ye?Ye:e}(),t-Math.trunc(Math.random()*Ze*t));var t;return w+=1,e}function k(e){if(e.status&&"number"==typeof e.status&&!Xe(e.status))return x(),i.error(ue.unrecoverableStreamError(e)),void(p&&(clearTimeout(p),p=null));const t=b();g||(i.warn(ue.streamError(e,t)),g=!0),C(!1),x(),E(t)}function E(e){p||(e?p=setTimeout(D,e):D())}function D(){let r;p=null;let a="";const l={headers:d,readTimeoutMillis:Qe};if(e.eventSourceFactory){null!=h&&(a="h="+h),c?e.eventSourceAllowsReport?(r=s,l.method="REPORT",l.headers["Content-Type"]="application/json",l.body=JSON.stringify(m)):(r=ze(o,"/ping/"+n),a=""):r=s+"/"+Je(JSON.stringify(m)),l.headers=We(l.headers,t),u&&(a=a+(a?"&":"")+"withReasons=true"),r=r+(a?"?":"")+a,x(),i.info(ue.streamConnecting(r)),f=(new Date).getTime(),v=e.eventSourceFactory(r,l);for(const e in y)Be(y,e)&&v.addEventListener(e,y[e]);v.onerror=k,v.onopen=()=>{w=0}}}function x(){v&&(i.info(ue.streamClosing()),v.close(),v=null)}function C(e){f&&r&&r.recordStreamInit(f,!e,(new Date).getTime()-f),f=null}return a.connect=function(e,t,n){m=e,h=t,y={};for(const e in n||{})y[e]=function(t){g=!1,C(!0),n[e]&&n[e](t)};E()},a.disconnect=function(){clearTimeout(p),p=null,x()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a};var tt=function(e){let t,n,r,o;const i={addPromise:(i,a)=>{t=i,n&&n(),n=a,i.then((n=>{t===i&&(r(n),e&&e())}),(n=>{t===i&&(o(n),e&&e())}))}};return i.resultPromise=new Promise(((e,t)=>{r=e,o=t})),i};const{transformHeaders:nt,getLDHeaders:rt}=he,ot="application/json";var it=function(e,t,n){const r=t.baseUrl,o=t.useReport,i=t.evaluationReasons,a=t.logger,c={},u={};function l(n,r){if(!e.httpRequest)return new Promise(((e,t)=>{t(new s.LDFlagFetchError(ue.httpUnavailable()))}));const o=r?"REPORT":"GET",i=rt(e,t);r&&(i["Content-Type"]=ot);let a=u[n];a||(a=tt((()=>{delete u[n]})),u[n]=a);const c=e.httpRequest(o,n,nt(i,t),r),l=c.promise.then((e=>{if(200===e.status){if(e.header("content-type")&&e.header("content-type").substring(0,ot.length)===ot)return JSON.parse(e.body);{const t=ue.invalidContentType(e.header("content-type")||"");return Promise.reject(new s.LDFlagFetchError(t))}}return Promise.reject(function(e){return 404===e.status?new s.LDInvalidEnvironmentIdError(ue.environmentNotFound()):new s.LDFlagFetchError(ue.errorFetchingFlags(e.statusText||String(e.status)))}(e))}),(e=>Promise.reject(new s.LDFlagFetchError(ue.networkError(e)))));return a.addPromise(l,(()=>{c.cancel&&c.cancel()})),a.resultPromise}return c.fetchJSON=function(e){return l(O.appendUrlPath(r,e),null)},c.fetchFlagSettings=function(e,t){let s,c,u,d="";return o?(c=[r,"/sdk/evalx/",n,"/context"].join(""),u=JSON.stringify(e)):(s=O.base64URLEncode(JSON.stringify(e)),c=[r,"/sdk/evalx/",n,"/contexts/",s].join("")),t&&(d="h="+t),i&&(d=d+(d?"&":"")+"withReasons=true"),c=c+(d?"?":"")+d,a.debug(ue.debugPolling(c)),l(c,u)},c};var at=function(e,t){const n={};let r;return n.setContext=function(e){r=O.sanitizeContext(e),r&&t&&t(O.clone(r))},n.getContext=function(){return r?O.clone(r):null},e&&n.setContext(e),n};const{v1:st}=oe,{getContextKinds:ct}=Pe,ut="ld:$anonUserId";var lt=function(e){function t(e){return null==e||"user"===e?ut:`ld:$contextKey:${e}`}function n(n,r){return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?function(n){return e.get(t(n))}(n).then((o=>{if(o)return r.key=o,r;{const o=st();return r.key=o,function(n,r){return e.set(t(r),n)}(o,n).then((()=>r))}})):Promise.reject(new s.LDInvalidUserError(ue.invalidContext()))}this.processContext=e=>{if(!e)return Promise.reject(new s.LDInvalidUserError(ue.contextNotSpecified()));const t=O.clone(e);if("multi"===e.kind){const e=ct(t);return Promise.all(e.map((e=>n(e,t[e])))).then((()=>t))}return n(e.kind,t)}};const{v1:dt}=oe,{baseOptionDefs:ft}=pe,{appendUrlPath:gt}=O;var vt={DiagnosticId:function(e){const t={diagnosticId:dt()};return e&&(t.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),t},DiagnosticsAccumulator:function(e){let t,n,r,o;function i(e){t=e,n=0,r=0,o=[]}return i(e),{getProps:()=>({dataSinceDate:t,droppedEvents:n,eventsInLastBatch:r,streamInits:o}),setProps:e=>{t=e.dataSinceDate,n=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:()=>{n++},setEventsInLastBatch:e=>{r=e},recordStreamInit:(e,t,n)=>{const r={timestamp:e,failed:t,durationMillis:n};o.push(r)},reset:i}},DiagnosticsManager:function(e,t,n,r,o,i,a){const s=!!e.diagnosticUseCombinedEvent,c="ld:"+o+":$diagnostics",u=gt(i.eventsUrl,"/events/diagnostic/"+o),l=i.diagnosticRecordingInterval,d=n;let f,g,v=!!i.streaming;const p={};function m(){return{sdk:w(),configuration:b(),platform:e.diagnosticPlatformData}}function h(e){i.logger&&i.logger.debug(ue.debugPostingDiagnosticEvent(e)),r.sendEvents(e,u,!0).then((()=>{})).catch((()=>{}))}function y(){h(function(){const e=(new Date).getTime();let t={kind:s?"diagnostic-combined":"diagnostic",id:a,creationDate:e,...d.getProps()};return s&&(t={...t,...m()}),d.reset(e),t}()),g=setTimeout(y,l),f=(new Date).getTime(),s&&function(){if(t.isEnabled()){const e={...d.getProps()};t.set(c,JSON.stringify(e))}}()}function w(){const t={...e.diagnosticSdkData};return i.wrapperName&&(t.wrapperName=i.wrapperName),i.wrapperVersion&&(t.wrapperVersion=i.wrapperVersion),t}function b(){return{customBaseURI:i.baseUrl!==ft.baseUrl.default,customStreamURI:i.streamUrl!==ft.streamUrl.default,customEventsURI:i.eventsUrl!==ft.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!v,allAttributesPrivate:!!i.allAttributesPrivate,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation}}return p.start=()=>{s?function(e){if(!t.isEnabled())return e(!1);t.get(c).then((t=>{if(t)try{const e=JSON.parse(t);d.setProps(e),f=e.dataSinceDate}catch(e){}e(!0)})).catch((()=>{e(!1)}))}((e=>{if(e){const e=(f||0)+l,t=(new Date).getTime();t>=e?y():g=setTimeout(y,e-t)}else 0===Math.floor(4*Math.random())?y():g=setTimeout(y,l)})):(h({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate,...m()}),g=setTimeout(y,l))},p.stop=()=>{g&&clearTimeout(g)},p.setStreaming=e=>{v=e},p}};var pt=function(e,t){let n=!1;const r={type:e.type,name:e.name,method:(...o)=>{try{e.method(...o)}catch{n||(n=!0,t.warn(ue.inspectorMethodError(r.type,r.name)))}}};return r};const{onNextTick:mt}=O,ht={flagUsed:"flag-used",flagDetailsChanged:"flag-details-changed",flagDetailChanged:"flag-detail-changed",clientIdentityChanged:"client-identity-changed"};Object.freeze(ht);var yt={InspectorTypes:ht,InspectorManager:function(e,t){const n={},r={[ht.flagUsed]:[],[ht.flagDetailsChanged]:[],[ht.flagDetailChanged]:[],[ht.clientIdentityChanged]:[]},o=e&&e.map((e=>pt(e,t)));return o&&o.forEach((e=>{Object.prototype.hasOwnProperty.call(r,e.type)?r[e.type].push(e):t.warn(ue.invalidInspector(e.type,e.name))})),n.hasListeners=e=>r[e]&&r[e].length,n.onFlagUsed=(e,t,n)=>{r[ht.flagUsed].length&&mt((()=>{r[ht.flagUsed].forEach((r=>r.method(e,t,n)))}))},n.onFlags=e=>{r[ht.flagDetailsChanged].length&&mt((()=>{r[ht.flagDetailsChanged].forEach((t=>t.method(e)))}))},n.onFlagChanged=(e,t)=>{r[ht.flagDetailChanged].length&&mt((()=>{r[ht.flagDetailChanged].forEach((n=>n.method(e,t)))}))},n.onIdentityChanged=e=>{r[ht.clientIdentityChanged].length&&mt((()=>{r[ht.clientIdentityChanged].forEach((t=>t.method(e)))}))},n}};const{commonBasicLogger:wt}=ae,{checkContext:bt,getContextKeys:kt}=Pe,{InspectorTypes:Et,InspectorManager:Dt}=yt,xt="change",Ct="internal-change";var Pt={initialize:function(e,t,n,r,o){const i=function(){if(n&&n.logger)return n.logger;return o&&o.logger&&o.logger.default||wt("warn")}(),a=$e(i),c=qe(a),u=pe.validate(n,a,o,i),l=Dt(u.inspectors,i),d=u.sendEvents;let f=e,g=u.hash;const v=_e(r.localStorage,i),p=Ee(r,f,u),m=u.sendEvents&&!u.diagnosticOptOut,h=m?vt.DiagnosticId(f):null,y=m?vt.DiagnosticsAccumulator((new Date).getTime()):null,w=m?vt.DiagnosticsManager(r,v,y,p,f,u,h):null,b=et(r,u,f,y),k=u.eventProcessor||Ne(r,u,f,y,a,p),E=it(r,u,f);let D,x,C,P={},S=u.streaming,I=!1,L=!1,U=!0;const T=u.stateProvider,R=at(null,(function(e){(function(e){if(T)return;e&&F({kind:"identify",context:e,creationDate:(new Date).getTime()})})(e),l.hasListeners(Et.clientIdentityChanged)&&l.onIdentityChanged(R.getContext())})),A=new lt(v),j=v.isEnabled()?Ke(v,f,g,R):null;function F(e){f&&(T&&T.enqueueEvent&&T.enqueueEvent(e)||(e.context?(U=!1,!d||L||r.isDoNotTrack()||(i.debug(ue.debugEnqueueingEvent(e.kind)),k.enqueue(e))):U&&(i.warn(ue.eventWithoutContext()),U=!1)))}function N(e,t){l.hasListeners(Et.flagDetailChanged)&&l.onFlagChanged(e.key,q(t))}function $(){l.hasListeners(Et.flagDetailsChanged)&&l.onFlags(Object.entries(P).map((([e,t])=>({key:e,detail:q(t)}))).reduce(((e,t)=>(e[t.key]=t.detail,e)),{}))}function V(e,t,n,r){const o=R.getContext(),i=new Date,a={kind:"feature",key:e,context:o,value:t?t.value:null,variation:t?t.variationIndex:null,default:n,creationDate:i.getTime()},s=P[e];s&&(a.version=s.flagVersion?s.flagVersion:s.version,a.trackEvents=s.trackEvents,a.debugEventsUntilDate=s.debugEventsUntilDate),(r||s&&s.trackReason)&&t&&(a.reason=t.reason),F(a)}function H(e){return bt(e,!1)?Promise.resolve(e):Promise.reject(new s.LDInvalidUserError(ue.invalidContext()))}function M(e,t,n,r,o){let i;if(P&&O.objectHasOwnProperty(P,e)&&P[e]&&!P[e].deleted){const n=P[e];i=q(n),null!==n.value&&void 0!==n.value||(i.value=t)}else i={value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return n&&V(e,i,t,r),o||function(e,t){l.hasListeners(Et.flagUsed)&&l.onFlagUsed(e,t,R.getContext())}(e,i),i}function q(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function K(){if(x=!0,!R.getContext())return;const e=e=>{try{return JSON.parse(e)}catch(e){return void a.maybeReportError(new s.LDInvalidDataError(ue.invalidData()))}};b.connect(R.getContext(),g,{ping:function(){i.debug(ue.debugStreamPing());const e=R.getContext();E.fetchFlagSettings(e,g).then((t=>{O.deepEquals(e,R.getContext())&&z(t||{})})).catch((e=>{a.maybeReportError(new s.LDFlagFetchError(ue.errorFetchingFlags(e)))}))},put:function(t){const n=e(t.data);n&&(i.debug(ue.debugStreamPut()),z(n))},patch:function(t){const n=e(t.data);if(!n)return;const r=P[n.key];if(!r||!r.version||!n.version||r.version<n.version){i.debug(ue.debugStreamPatch(n.key));const e={},t=O.extend({},n);delete t.key,P[n.key]=t;const o=q(t);e[n.key]=r?{previous:r.value,current:o}:{current:o},J(e),N(n,t)}else i.debug(ue.debugStreamPatchIgnored(n.key))},delete:function(t){const n=e(t.data);if(n)if(!P[n.key]||P[n.key].version<n.version){i.debug(ue.debugStreamDelete(n.key));const e={};P[n.key]&&!P[n.key].deleted&&(e[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},N(n,P[n.key]),J(e)}else i.debug(ue.debugStreamDeleteIgnored(n.key))}})}function _(){x&&(b.disconnect(),x=!1)}function z(e){const t={};if(!e)return Promise.resolve();for(const n in P)O.objectHasOwnProperty(P,n)&&P[n]&&(e[n]&&!O.deepEquals(e[n].value,P[n].value)?t[n]={previous:P[n].value,current:q(e[n])}:e[n]&&!e[n].deleted||(t[n]={previous:P[n].value}));for(const n in e)O.objectHasOwnProperty(e,n)&&e[n]&&(!P[n]||P[n].deleted)&&(t[n]={current:q(e[n])});return P={...e},$(),J(t).catch((()=>{}))}function J(e){const t=Object.keys(e);if(t.length>0){const n={};t.forEach((t=>{const r=e[t].current,o=r?r.value:void 0,i=e[t].previous;a.emit(xt+":"+t,o,i),n[t]=r?{current:o,previous:i}:{previous:i}})),a.emit(xt,n),a.emit(Ct,P),u.sendEventsOnlyForVariation||T||t.forEach((t=>{V(t,e[t].current)}))}return D&&j?j.saveFlags(P):Promise.resolve()}function B(){const e=S||C&&void 0===S;e&&!x?K():!e&&x&&_(),w&&w.setStreaming(e)}function G(e){return e===xt||e.substr(0,xt.length+1)===xt+":"}if("string"==typeof u.bootstrap&&"LOCALSTORAGE"===u.bootstrap.toUpperCase()&&(j?D=!0:i.warn(ue.localStorageUnavailable())),"object"==typeof u.bootstrap&&(P=function(e){const t=Object.keys(e),n="$flagsState",r="$valid",o=e[n];!o&&t.length&&i.warn(ue.bootstrapOldFormat()),!1===e[r]&&i.warn(ue.bootstrapInvalid());const a={};return t.forEach((t=>{if(t!==n&&t!==r){let n={value:e[t]};o&&o[t]?n=O.extend(n,o[t]):n.version=0,a[t]=n}})),a}(u.bootstrap)),T){const e=T.getInitialState();e?W(e):T.on("init",W),T.on("update",(function(e){e.context&&R.setContext(e.context);e.flags&&z(e.flags)}))}else(function(){if(!e)return Promise.reject(new s.LDInvalidEnvironmentIdError(ue.environmentNotSpecified()));return A.processContext(t).then(H).then((e=>(R.setContext(e),"object"==typeof u.bootstrap?X():D?j.loadFlags().then((e=>null==e?(P={},E.fetchFlagSettings(R.getContext(),g).then((e=>z(e||{}))).then(X).catch((e=>{Q(new s.LDFlagFetchError(ue.errorFetchingFlags(e)))}))):(P=e,O.onNextTick(X),E.fetchFlagSettings(R.getContext(),g).then((e=>z(e))).catch((e=>a.maybeReportError(e)))))):E.fetchFlagSettings(R.getContext(),g).then((e=>{P=e||{},$(),X()})).catch((e=>{P={},Q(e)})))))})().catch(Q);function W(e){f=e.environment,R.setContext(e.context),P={...e.flags},O.onNextTick(X)}function X(){i.info(ue.clientInitialized()),I=!0,B(),c.signalSuccess()}function Q(e){c.signalFailure(e)}const Y={waitForInitialization:()=>c.getInitializationPromise(),waitUntilReady:()=>c.getReadyPromise(),identify:function(e,t,n){if(L)return O.wrapPromiseCallback(Promise.resolve({}),n);if(T)return i.warn(ue.identifyDisabled()),O.wrapPromiseCallback(Promise.resolve(O.transformVersionedValuesToValues(P)),n);const r=D&&j?j.clearFlags():Promise.resolve();return O.wrapPromiseCallback(r.then((()=>A.processContext(e))).then(H).then((e=>E.fetchFlagSettings(e,t).then((n=>{const r=O.transformVersionedValuesToValues(n);return R.setContext(e),g=t,n?z(n).then((()=>r)):r})))).then((e=>(x&&K(),e))).catch((e=>(a.maybeReportError(e),Promise.reject(e)))),n)},getContext:function(){return R.getContext()},variation:function(e,t){return M(e,t,!0,!1,!1).value},variationDetail:function(e,t){return M(e,t,!0,!0,!1)},track:function(e,t,n){if("string"!=typeof e)return void a.maybeReportError(new s.LDInvalidEventKeyError(ue.unknownCustomEventKey(e)));r.customEventFilter&&!r.customEventFilter(e)&&i.warn(ue.unknownCustomEventKey(e));const o=R.getContext(),c={kind:"custom",key:e,context:o,url:r.getCurrentUrl(),creationDate:(new Date).getTime()};o&&o.anonymous&&(c.contextKind=o.anonymous?"anonymousUser":"user"),null!=t&&(c.data=t),null!=n&&(c.metricValue=n),F(c)},on:function(e,t,n){G(e)?(C=!0,I&&B(),a.on(e,t,n)):a.on(...arguments)},off:function(e){if(a.off(...arguments),G(e)){let e=!1;a.getEvents().forEach((t=>{G(t)&&a.getEventListenerCount(t)>0&&(e=!0)})),e||(C=!1,x&&void 0===S&&_())}},setStreaming:function(e){const t=null===e?void 0:e;t!==S&&(S=t,B())},flush:function(e){return O.wrapPromiseCallback(d?k.flush():Promise.resolve(),e)},allFlags:function(){const e={};if(!P)return e;for(const t in P)O.objectHasOwnProperty(P,t)&&!P[t].deleted&&(e[t]=M(t,null,!u.sendEventsOnlyForVariation,!1,!0).value);return e},close:function(e){if(L)return O.wrapPromiseCallback(Promise.resolve(),e);const t=()=>{L=!0,P={}},n=Promise.resolve().then((()=>{if(_(),w&&w.stop(),d)return k.stop(),k.flush()})).then(t).catch(t);return O.wrapPromiseCallback(n,e)}};return{client:Y,options:u,emitter:a,ident:R,logger:i,requestor:E,start:function(){d&&(w&&w.start(),k.start())},enqueueEvent:F,getFlagsInternal:function(){return P},getEnvironmentId:()=>f,internalChangeEventName:Ct}},commonBasicLogger:wt,errors:s,messages:ue,utils:O,getContextKeys:kt},St=Pt.initialize,It=Pt.errors,Ot=Pt.messages,Lt=Pt.getContextKeys;function Ut(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Tt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ut(Object(n),!0).forEach((function(t){Rt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ut(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Rt(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var At=Pt.commonBasicLogger;var jt=function(e){return At(Tt({destination:console.log},e))};var Ft={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Nt(e,t,n,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var t=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(t)return parseInt(t[2],10)<73}return!0}())return Ft;var i=new window.XMLHttpRequest;for(var a in i.open(e,t,!o),n||{})Object.prototype.hasOwnProperty.call(n,a)&&i.setRequestHeader(a,n[a]);if(o)return i.send(r),Ft;var s,c=new Promise((function(e,t){i.addEventListener("load",(function(){s||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})})),i.addEventListener("error",(function(){s||t(new Error)})),i.send(r)}));return{promise:c,cancel:function(){s=!0,i.abort()}}}var $t=e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")};function Vt(e,t,n,r){var o,i,a=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?t:t.replace(r,"")).replace(n,"");switch(e.kind){case"exact":i=t,o=new RegExp("^"+$t(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+$t(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+$t(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Ht(e,t){for(var n={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],s=a.urls||[],c=0;c<s.length;c++)if(Vt(s[c],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?t("pageview",a):(o.push(a),t("click_pageview",a));break}return o.length>0&&(r=function(e){for(var n=function(e,t){for(var n=[],r=0;r<t.length;r++)for(var o=e.target,i=t[r],a=i.selector,s=document.querySelectorAll(a);o&&s.length>0;){for(var c=0;c<s.length;c++)o===s[c]&&n.push(i);o=o.parentNode}return n}(e,o),r=0;r<n.length;r++)t("click",n[r])},document.addEventListener("click",r)),n.dispose=function(){document.removeEventListener("click",r)},n}var Mt=300;function qt(e,t){var n,r;function o(){r&&r.dispose(),n&&n.length&&(r=Ht(n,i))}function i(t,n){var r=e.ident.getContext(),o={kind:t,key:n.key,data:null,url:window.location.href,creationDate:(new Date).getTime(),contextKeys:Lt(r)};return"click"===t&&(o.selector=n.selector),e.enqueueEvent(o)}return e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=Ht(n=e,i),function(e,t){var n,r=window.location.href;function o(){(n=window.location.href)!==r&&(r=n,t())}!function e(t,n){t(),setTimeout((function(){e(t,n)}),n)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(Mt,o)),t()})).catch((function(n){e.emitter.maybeReportError(new It.LDUnexpectedResponseError((n&&n.message,n.message))),t()})),{}}var Kt="goalsReady",_t={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function zt(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var t,n={userAgentHeaderName:"X-LaunchDarkly-User-Agent",synchronousFlush:!1};if(window.XMLHttpRequest){var r=e&&e.disableSyncEventPost;n.httpRequest=function(e,t,o,i){var a=n.synchronousFlush&!r;return n.synchronousFlush=!1,Nt(e,t,o,i,a)}}n.httpAllowsPost=function(){return void 0===t&&(t=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),t},n.httpFallbackPing=function(e){(new window.Image).src=e};var o,i=e&&e.eventUrlTransformer;n.getCurrentUrl=function(){return i?i(window.location.href):window.location.href},n.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&&(n.localStorage={get:function(e){return new Promise((function(t){t(window.localStorage.getItem(e))}))},set:function(e,t){return new Promise((function(n){window.localStorage.setItem(e,t),n()}))},clear:function(e){return new Promise((function(t){window.localStorage.removeItem(e),t()}))}})}catch(e){n.localStorage=null}if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(n.eventSourceAllowsReport=!0,o=window.EventSourcePolyfill):(n.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource){var a=3e5;n.eventSourceFactory=function(e,t){var n=Tt(Tt({},{heartbeatTimeout:a,silentTimeout:a,skipDefaultHeaders:!0}),t);return new o(e,n)},n.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return n.userAgent="JSClient",n.version="3.1.2",n.diagnosticSdkData={name:"js-client-sdk",version:"3.1.2"},n.diagnosticPlatformData={name:"JS"},n.diagnosticUseCombinedEvent=!0,n}(n),o=St(e,t,n,r,_t),i=o.client,a=o.options,s=o.emitter,c=new Promise((function(e){var t=s.on(Kt,(function(){s.off(Kt,t),e()}))}));i.waitUntilGoalsReady=function(){return c},a.fetchGoals?qt(o,(function(){return s.emit(Kt)})):s.emit(Kt),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var u=function(){r.synchronousFlush=!0,i.flush().catch((function(){})),r.synchronousFlush=!1};return document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&u()})),window.addEventListener("pagehide",u),i}var Jt=jt,Bt="3.1.2";var Gt={initialize:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Ot.deprecated("default export","named LDClient export")),zt(e,t,n)},version:Bt};exports.basicLogger=Jt,exports.createConsoleLogger=undefined,exports.default=Gt,exports.initialize=zt,exports.version=Bt;
//# sourceMappingURL=ldclient.cjs.js.map

@@ -1,2 +0,2 @@

function e(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return t.prototype=new Error,t.prototype.name=e,t.prototype.constructor=t,t}const t=e("LaunchDarklyUnexpectedResponseError"),n=e("LaunchDarklyInvalidEnvironmentIdError"),r=e("LaunchDarklyInvalidUserError"),o=e("LaunchDarklyInvalidEventKeyError"),i=e("LaunchDarklyInvalidArgumentError"),a=e("LaunchDarklyFlagFetchError");for(var s={LDUnexpectedResponseError:t,LDInvalidEnvironmentIdError:n,LDInvalidUserError:r,LDInvalidEventKeyError:o,LDInvalidArgumentError:i,LDInvalidDataError:e("LaunchDarklyInvalidDataError"),LDFlagFetchError:a,isHttpErrorRecoverable:function(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}},c=function(e){var t=h(e),n=t[0],r=t[1];return 3*(n+r)/4-r},u=function(e){var t,n,r=h(e),o=r[0],i=r[1],a=new g(function(e,t,n){return 3*(t+n)/4-n}(0,o,i)),s=0,c=i>0?o-4:o;for(n=0;n<c;n+=4)t=f[e.charCodeAt(n)]<<18|f[e.charCodeAt(n+1)]<<12|f[e.charCodeAt(n+2)]<<6|f[e.charCodeAt(n+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=255&t;2===i&&(t=f[e.charCodeAt(n)]<<2|f[e.charCodeAt(n+1)]>>4,a[s++]=255&t);1===i&&(t=f[e.charCodeAt(n)]<<10|f[e.charCodeAt(n+1)]<<4|f[e.charCodeAt(n+2)]>>2,a[s++]=t>>8&255,a[s++]=255&t);return a},l=function(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(y(e,a,a+i>s?s:a+i));1===r?(t=e[n-1],o.push(d[t>>2]+d[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],o.push(d[t>>10]+d[t>>4&63]+d[t<<2&63]+"="));return o.join("")},d=[],f=[],g="undefined"!=typeof Uint8Array?Uint8Array:Array,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,m=v.length;p<m;++p)d[p]=v[p],f[v.charCodeAt(p)]=p;function h(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function y(e,t,n){for(var r,o,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(d[(o=r)>>18&63]+d[o>>12&63]+d[o>>6&63]+d[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63;var w={byteLength:c,toByteArray:u,fromByteArray:l},b=Array.isArray,k=Object.keys,E=Object.prototype.hasOwnProperty,D=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i,a=b(t),s=b(n);if(a&&s){if((o=t.length)!=n.length)return!1;for(r=o;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(a!=s)return!1;var c=t instanceof Date,u=n instanceof Date;if(c!=u)return!1;if(c&&u)return t.getTime()==n.getTime();var l=t instanceof RegExp,d=n instanceof RegExp;if(l!=d)return!1;if(l&&d)return t.toString()==n.toString();var f=k(t);if((o=f.length)!==k(n).length)return!1;for(r=o;0!=r--;)if(!E.call(n,f[r]))return!1;for(r=o;0!=r--;)if(!e(t[i=f[r]],n[i]))return!1;return!0}return t!=t&&n!=n};const C=["key","ip","country","email","firstName","lastName","avatar","name"];function x(e){const t=unescape(encodeURIComponent(e));return w.fromByteArray(function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}(t))}function P(e){return x(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function S(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var I,O={appendUrlPath:function(e,t){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(t.startsWith("/")?"":"/")+t},base64URLEncode:P,btoa:x,chunkEventsForUrl:function(e,t){const n=t.slice(0),r=[];let o,i=e;for(;n.length>0;){for(o=[];i>0;){const e=n.shift();if(!e)break;i-=P(JSON.stringify(e)).length,i<0&&o.length>0?n.unshift(e):o.push(e)}i=e,r.push(o)}return r},clone:function(e){return JSON.parse(JSON.stringify(e))},deepEquals:function(e,t){return D(e,t)},extend:function(...e){return e.reduce(((e,t)=>({...e,...t})),{})},getLDUserAgentString:function(e){const t=e.version||"?";return e.userAgent+"/"+t},objectHasOwnProperty:S,onNextTick:function(e){setTimeout(e,0)},sanitizeContext:function(e){if(!e)return e;let t;return null!==e.kind&&void 0!==e.kind||C.forEach((n=>{const r=e[n];void 0!==r&&"string"!=typeof r&&(t=t||{...e},t[n]=String(r))})),t||e},transformValuesToVersionedValues:function(e){const t={};for(const n in e)S(e,n)&&(t[n]={value:e[n],version:0});return t},transformVersionedValuesToValues:function(e){const t={};for(const n in e)S(e,n)&&(t[n]=e[n].value);return t},wrapPromiseCallback:function(e,t){const n=e.then((e=>(t&&setTimeout((()=>{t(null,e)}),0),e)),(e=>{if(!t)return Promise.reject(e);setTimeout((()=>{t(e,null)}),0)}));return t?void 0:n}},L=new Uint8Array(16);function U(){if(!I&&!(I="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return I(L)}var T=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function R(e){return"string"==typeof e&&T.test(e)}for(var A,j,F=[],N=0;N<256;++N)F.push((N+256).toString(16).substr(1));function $(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(F[e[t+0]]+F[e[t+1]]+F[e[t+2]]+F[e[t+3]]+"-"+F[e[t+4]]+F[e[t+5]]+"-"+F[e[t+6]]+F[e[t+7]]+"-"+F[e[t+8]]+F[e[t+9]]+"-"+F[e[t+10]]+F[e[t+11]]+F[e[t+12]]+F[e[t+13]]+F[e[t+14]]+F[e[t+15]]).toLowerCase();if(!R(n))throw TypeError("Stringified UUID is invalid");return n}var V=0,H=0;function q(e){if(!R(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}var M="6ba7b810-9dad-11d1-80b4-00c04fd430c8",K="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function _(e,t,n){function r(e,r,o,i){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=q(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+e.length);if(a.set(r),a.set(e,r.length),(a=n(a))[6]=15&a[6]|t,a[8]=63&a[8]|128,o){i=i||0;for(var s=0;s<16;++s)o[i+s]=a[s];return o}return $(a)}try{r.name=e}catch(e){}return r.DNS=M,r.URL=K,r}function J(e){return 14+(e+64>>>9<<4)+1}function z(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function B(e,t,n,r,o,i){return z((a=z(z(t,e),z(r,i)))<<(s=o)|a>>>32-s,n);var a,s}function G(e,t,n,r,o,i,a){return B(t&n|~t&r,e,t,o,i,a)}function W(e,t,n,r,o,i,a){return B(t&r|n&~r,e,t,o,i,a)}function X(e,t,n,r,o,i,a){return B(t^n^r,e,t,o,i,a)}function Q(e,t,n,r,o,i,a){return B(n^(t|~r),e,t,o,i,a)}var Y=_("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,r="0123456789abcdef",o=0;o<n;o+=8){var i=e[o>>5]>>>o%32&255,a=parseInt(r.charAt(i>>>4&15)+r.charAt(15&i),16);t.push(a)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[J(t)-1]=t;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,a=0;a<e.length;a+=16){var s=n,c=r,u=o,l=i;n=G(n,r,o,i,e[a],7,-680876936),i=G(i,n,r,o,e[a+1],12,-389564586),o=G(o,i,n,r,e[a+2],17,606105819),r=G(r,o,i,n,e[a+3],22,-1044525330),n=G(n,r,o,i,e[a+4],7,-176418897),i=G(i,n,r,o,e[a+5],12,1200080426),o=G(o,i,n,r,e[a+6],17,-1473231341),r=G(r,o,i,n,e[a+7],22,-45705983),n=G(n,r,o,i,e[a+8],7,1770035416),i=G(i,n,r,o,e[a+9],12,-1958414417),o=G(o,i,n,r,e[a+10],17,-42063),r=G(r,o,i,n,e[a+11],22,-1990404162),n=G(n,r,o,i,e[a+12],7,1804603682),i=G(i,n,r,o,e[a+13],12,-40341101),o=G(o,i,n,r,e[a+14],17,-1502002290),n=W(n,r=G(r,o,i,n,e[a+15],22,1236535329),o,i,e[a+1],5,-165796510),i=W(i,n,r,o,e[a+6],9,-1069501632),o=W(o,i,n,r,e[a+11],14,643717713),r=W(r,o,i,n,e[a],20,-373897302),n=W(n,r,o,i,e[a+5],5,-701558691),i=W(i,n,r,o,e[a+10],9,38016083),o=W(o,i,n,r,e[a+15],14,-660478335),r=W(r,o,i,n,e[a+4],20,-405537848),n=W(n,r,o,i,e[a+9],5,568446438),i=W(i,n,r,o,e[a+14],9,-1019803690),o=W(o,i,n,r,e[a+3],14,-187363961),r=W(r,o,i,n,e[a+8],20,1163531501),n=W(n,r,o,i,e[a+13],5,-1444681467),i=W(i,n,r,o,e[a+2],9,-51403784),o=W(o,i,n,r,e[a+7],14,1735328473),n=X(n,r=W(r,o,i,n,e[a+12],20,-1926607734),o,i,e[a+5],4,-378558),i=X(i,n,r,o,e[a+8],11,-2022574463),o=X(o,i,n,r,e[a+11],16,1839030562),r=X(r,o,i,n,e[a+14],23,-35309556),n=X(n,r,o,i,e[a+1],4,-1530992060),i=X(i,n,r,o,e[a+4],11,1272893353),o=X(o,i,n,r,e[a+7],16,-155497632),r=X(r,o,i,n,e[a+10],23,-1094730640),n=X(n,r,o,i,e[a+13],4,681279174),i=X(i,n,r,o,e[a],11,-358537222),o=X(o,i,n,r,e[a+3],16,-722521979),r=X(r,o,i,n,e[a+6],23,76029189),n=X(n,r,o,i,e[a+9],4,-640364487),i=X(i,n,r,o,e[a+12],11,-421815835),o=X(o,i,n,r,e[a+15],16,530742520),n=Q(n,r=X(r,o,i,n,e[a+2],23,-995338651),o,i,e[a],6,-198630844),i=Q(i,n,r,o,e[a+7],10,1126891415),o=Q(o,i,n,r,e[a+14],15,-1416354905),r=Q(r,o,i,n,e[a+5],21,-57434055),n=Q(n,r,o,i,e[a+12],6,1700485571),i=Q(i,n,r,o,e[a+3],10,-1894986606),o=Q(o,i,n,r,e[a+10],15,-1051523),r=Q(r,o,i,n,e[a+1],21,-2054922799),n=Q(n,r,o,i,e[a+8],6,1873313359),i=Q(i,n,r,o,e[a+15],10,-30611744),o=Q(o,i,n,r,e[a+6],15,-1560198380),r=Q(r,o,i,n,e[a+13],21,1309151649),n=Q(n,r,o,i,e[a+4],6,-145523070),i=Q(i,n,r,o,e[a+11],10,-1120210379),o=Q(o,i,n,r,e[a+2],15,718787259),r=Q(r,o,i,n,e[a+9],21,-343485551),n=z(n,s),r=z(r,c),o=z(o,u),i=z(i,l)}return[n,r,o,i]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(J(t)),r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))})),Z=Y;function ee(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function te(e,t){return e<<t|e>>>32-t}var ne=_("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var o=0;o<r.length;++o)e.push(r.charCodeAt(o))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var i=e.length/4+2,a=Math.ceil(i/16),s=new Array(a),c=0;c<a;++c){for(var u=new Uint32Array(16),l=0;l<16;++l)u[l]=e[64*c+4*l]<<24|e[64*c+4*l+1]<<16|e[64*c+4*l+2]<<8|e[64*c+4*l+3];s[c]=u}s[a-1][14]=8*(e.length-1)/Math.pow(2,32),s[a-1][14]=Math.floor(s[a-1][14]),s[a-1][15]=8*(e.length-1)&4294967295;for(var d=0;d<a;++d){for(var f=new Uint32Array(80),g=0;g<16;++g)f[g]=s[d][g];for(var v=16;v<80;++v)f[v]=te(f[v-3]^f[v-8]^f[v-14]^f[v-16],1);for(var p=n[0],m=n[1],h=n[2],y=n[3],w=n[4],b=0;b<80;++b){var k=Math.floor(b/20),E=te(p,5)+ee(k,m,h,y)+w+t[k]+f[b]>>>0;w=y,y=h,h=te(m,30)>>>0,m=p,p=E}n[0]=n[0]+p>>>0,n[1]=n[1]+m>>>0,n[2]=n[2]+h>>>0,n[3]=n[3]+y>>>0,n[4]=n[4]+w>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]})),re=ne;var oe=Object.freeze({__proto__:null,v1:function(e,t,n){var r=t&&n||0,o=t||new Array(16),i=(e=e||{}).node||A,a=void 0!==e.clockseq?e.clockseq:j;if(null==i||null==a){var s=e.random||(e.rng||U)();null==i&&(i=A=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==a&&(a=j=16383&(s[6]<<8|s[7]))}var c=void 0!==e.msecs?e.msecs:Date.now(),u=void 0!==e.nsecs?e.nsecs:H+1,l=c-V+(u-H)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||c>V)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");V=c,H=u,j=a;var d=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;o[r++]=d>>>24&255,o[r++]=d>>>16&255,o[r++]=d>>>8&255,o[r++]=255&d;var f=c/4294967296*1e4&268435455;o[r++]=f>>>8&255,o[r++]=255&f,o[r++]=f>>>24&15|16,o[r++]=f>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var g=0;g<6;++g)o[r+g]=i[g];return t||$(o)},v3:Z,v4:function(e,t,n){var r=(e=e||{}).random||(e.rng||U)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=r[o];return t}return $(r)},v5:re,NIL:"00000000-0000-0000-0000-000000000000",version:function(e){if(!R(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)},validate:R,stringify:$,parse:q});const ie=["debug","info","warn","error","none"];var ae={commonBasicLogger:function(e,t){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(e){return function(t){console&&console[e]&&console[e].call(console,t)}}const r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],o=!(!e||!e.destination),i=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ";let a=1;if(e&&e.level)for(let t=0;t<ie.length;t++)ie[t]===e.level&&(a=t);function s(e,n,a){if(a.length<1)return;let s;const c=o?n+": "+i:i;if(1!==a.length&&t){const e=[...a];e[0]=c+e[0],s=t(...e)}else s=c+a[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}const c={};for(let e=0;e<ie.length;e++){const t=ie[e];if("none"!==t)if(e<a)c[t]=()=>{};else{const n=e;c[t]=function(){s(n,t,arguments)}}}return c},validateLogger:function(e){ie.forEach((t=>{if("none"!==t&&(!e[t]||"function"!=typeof e[t]))throw new Error("Provided logger instance must support logger."+t+"(...) method")}))}};function se(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}const ce=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.";var ue={bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},bootstrapOldFormat:function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+ce},clientInitialized:function(){return"LaunchDarkly client initialized"},clientNotReady:function(){return"LaunchDarkly client is not ready"},debugEnqueueingEvent:function(e){return'enqueueing "'+e+'" event'},debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},debugPostingEvents:function(e){return"sending "+e+" events"},debugStreamDelete:function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored:function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugStreamPatch:function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored:function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamPing:function(){return"received ping message from stream"},debugPolling:function(e){return"polling for feature flags at "+e},debugStreamPut:function(){return"received streaming update for all flags"},deprecated:function(e,t){return t?'"'+e+'" is deprecated, please use "'+t+'"':'"'+e+'" is deprecated'},environmentNotFound:function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+ce},environmentNotSpecified:function(){return"No environment/client-side ID was specified."+ce},errorFetchingFlags:function(e){return"Error fetching flag settings: "+se(e)},eventCapacityExceeded:function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutContext:function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},httpErrorMessage:function(e,t,n){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+t+" - "+(s.isHttpErrorRecoverable(e)?n:"giving up permanently")},httpUnavailable:function(){return"Cannot make HTTP requests in this environment."+ce},identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},inspectorMethodError:(e,t)=>`an inspector: "${t}" of type: "${e}" generated an exception`,invalidContentType:function(e){return'Expected application/json content type but got "'+e+'"'},invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},invalidInspector:(e,t)=>`an inspector: "${t}" of an invalid type (${e}) was configured`,invalidKey:function(){return"Event key must be a string"},invalidContext:function(){return"Invalid context specified."+ce},invalidTagValue:e=>`Config option "${e}" must only contain letters, numbers, ., _ or -.`,localStorageUnavailable:function(e){return"local storage is unavailable: "+se(e)},networkError:e=>"network error"+(e?" ("+e+")":""),optionBelowMinimum:(e,t,n)=>'Config option "'+e+'" was set to '+t+", changing to minimum value of "+n,streamClosing:function(){return"Closing stream connection"},streamConnecting:function(e){return"Opening stream connection to "+e},streamError:function(e,t){return"Error on stream connection: "+se(e)+", will continue retrying after "+t+" milliseconds."},tagValueTooLong:e=>`Value of "${e}" was longer than 64 characters and was discarded.`,unknownCustomEventKey:function(e){return'Custom event "'+e+'" does not exist'},unknownOption:e=>'Ignoring unknown config option "'+e+'"',contextNotSpecified:function(){return"No context specified."+ce},unrecoverableStreamError:e=>`Error on stream connection ${se(e)}, giving up permanently`,wrongOptionType:(e,t,n)=>'Config option "'+e+'" should be of type '+t+", got "+n+", using default value",wrongOptionTypeBoolean:(e,t)=>'Config option "'+e+'" should be a boolean, got '+t+", converting to boolean"};const{validateLogger:le}=ae,de={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"},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},privateAttributes:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},application:{validator:function(e,t,n){const r={};t.id&&(r.id=ve(`${e}.id`,t.id,n));t.version&&(r.version=ve(`${e}.version`,t.version,n));return r}},inspectors:{default:[]}},fe=/^(\w|\.|-)+$/;function ge(e){return e&&e.replace(/\/+$/,"")}function ve(e,t,n){if("string"==typeof t&&t.match(fe)){if(!(t.length>64))return t;n.warn(ue.tagValueTooLong(e))}else n.warn(ue.invalidTagValue(e))}var pe={baseOptionDefs:de,validate:function(e,t,n,r){const o=O.extend({logger:{default:r}},de,n),i={};function a(e){O.onNextTick((()=>{t&&t.maybeReportError(new s.LDInvalidArgumentError(e))}))}let c=O.extend({},e||{});return function(e){const t=e;Object.keys(i).forEach((e=>{if(void 0!==t[e]){const n=i[e];r&&r.warn(ue.deprecated(e,n)),n&&(void 0===t[n]&&(t[n]=t[e]),delete t[e])}}))}(c),c=function(e){const t=O.extend({},e);return Object.keys(o).forEach((e=>{void 0!==t[e]&&null!==t[e]||(t[e]=o[e]&&o[e].default)})),t}(c),c=function(e){const t=O.extend({},e),n=e=>{if(null===e)return"any";if(void 0===e)return;if(Array.isArray(e))return"array";const t=typeof e;return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"};return Object.keys(e).forEach((i=>{const s=e[i];if(null!=s){const c=o[i];if(void 0===c)a(ue.unknownOption(i));else{const o=c.type||n(c.default),u=c.validator;if(u){const n=u(i,e[i],r);void 0!==n?t[i]=n:delete t[i]}else if("any"!==o){const e=o.split("|"),r=n(s);e.indexOf(r)<0?"boolean"===o?(t[i]=!!s,a(ue.wrongOptionTypeBoolean(i,r))):(a(ue.wrongOptionType(i,o,r)),t[i]=c.default):"number"===r&&void 0!==c.minimum&&s<c.minimum&&(a(ue.optionBelowMinimum(i,s,c.minimum)),t[i]=c.minimum)}}}})),t.baseUrl=ge(t.baseUrl),t.streamUrl=ge(t.streamUrl),t.eventsUrl=ge(t.eventsUrl),t}(c),le(c.logger),c},getTags:function(e){const t={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(t["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(t["application-version"]=[e.application.version])),t}};const{getLDUserAgentString:me}=O;var he={getLDHeaders:function(e,t){if(t&&!t.sendLDHeaders)return{};const n={};n[e.userAgentHeaderName||"User-Agent"]=me(e),t&&t.wrapperName&&(n["X-LaunchDarkly-Wrapper"]=t.wrapperVersion?t.wrapperName+"/"+t.wrapperVersion:t.wrapperName);const r=pe.getTags(t),o=Object.keys(r);return o.length&&(n["x-launchdarkly-tags"]=o.sort().map((e=>Array.isArray(r[e])?r[e].sort().map((t=>`${e}/${t}`)):[`${e}/${r[e]}`])).reduce(((e,t)=>e.concat(t)),[]).join(" ")),n},transformHeaders:function(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform({...e}):e}};const{v1:ye}=oe,{getLDHeaders:we,transformHeaders:be}=he,ke=2e3;var Ee=function(e,t,n){const r="/a/"+t+".gif",o=O.extend({"Content-Type":"application/json"},we(e,n)),i=e.httpFallbackPing,a={};return a.sendChunk=(t,a,c,u)=>{const l=JSON.stringify(t),d=c?null:ye();return u?function t(r){const i=c?o:O.extend({},o,{"X-LaunchDarkly-Event-Schema":"4","X-LaunchDarkly-Payload-ID":d});return e.httpRequest("POST",a,be(i,n),l).promise.then((e=>{if(e)return e.status>=400&&s.isHttpErrorRecoverable(e.status)&&r?t(!1):function(e){const t={status:e.status},n=e.header("date");if(n){const e=Date.parse(n);e&&(t.serverTime=e)}return t}(e)})).catch((()=>r?t(!1):Promise.reject()))}(!0).catch((()=>{})):(i&&i(a+r+"?d="+O.base64URLEncode(l)),Promise.resolve())},a.sendEvents=function(t,n,r){if(!e.httpRequest)return Promise.resolve();const o=e.httpAllowsPost();let i;i=o?[t]:O.chunkEventsForUrl(ke-n.length,t);const s=[];for(let e=0;e<i.length;e++)s.push(a.sendChunk(i[e],n,r,o));return Promise.all(s)},a};const{commonBasicLogger:De}=ae;function Ce(e){return"string"==typeof e&&"kind"!==e&&e.match(/^(\w|\.|-)+$/)}function xe(e){return e.includes("%")||e.includes(":")?e.replace(/%/g,"%25").replace(/:/g,"%3A"):e}var Pe={checkContext:function(e,t){if(e){if(t&&(void 0===e.kind||null===e.kind))return void 0!==e.key&&null!==e.key;const n=e.key,r=void 0===e.kind?"user":e.kind,o=Ce(r),i="multi"===r||null!=n&&""!==n;if("multi"===r){const t=Object.keys(e).filter((e=>"kind"!==e));return i&&t.every((e=>Ce(e)))&&t.every((t=>{const n=e[t].key;return null!=n&&""!==n}))}return i&&o}return!1},getContextKeys:function(e,t=De()){if(!e)return;const n={},{kind:r,key:o}=e;switch(r){case void 0:n.user=`${o}`;break;case"multi":Object.entries(e).filter((([e])=>"kind"!==e)).forEach((([e,t])=>{t&&t.key&&(n[e]=t.key)}));break;case null:t.warn(`null is not a valid context kind: ${e}`);break;case"":t.warn(`'' is not a valid context kind: ${e}`);break;default:n[r]=`${o}`}return n},getContextKinds:function(e){return e?null===e.kind||void 0===e.kind?["user"]:"multi"!==e.kind?[e.kind]:Object.keys(e).filter((e=>"kind"!==e)):[]},getCanonicalKey:function(e){if(e){if((void 0===e.kind||null===e.kind||"user"===e.kind)&&e.key)return e.key;if("multi"!==e.kind&&e.key)return`${e.kind}:${xe(e.key)}`;if("multi"===e.kind)return Object.keys(e).sort().filter((e=>"kind"!==e)).map((t=>`${t}:${xe(e[t].key)}`)).join(":")}}};const{getContextKinds:Se}=Pe;var Ie=function(){const e={};let t=0,n=0,r={},o={};return e.summarizeEvent=e=>{if("feature"===e.kind){const i=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),a=r[i];let s=o[e.key];s||(s=new Set,o[e.key]=s),function(e){return e.context?Se(e.context):e.contextKeys?Object.keys(e.contextKeys):[]}(e).forEach((e=>s.add(e))),a?a.count=a.count+1:r[i]={count:1,key:e.key,version:e.version,variation:e.variation,value:e.value,default:e.default},(0===t||e.creationDate<t)&&(t=e.creationDate),e.creationDate>n&&(n=e.creationDate)}},e.getSummary=()=>{const e={};let i=!0;for(const t of Object.values(r)){let n=e[t.key];n||(n={default:t.default,counters:[],contextKinds:[...o[t.key]]},e[t.key]=n);const r={value:t.value,count:t.count};void 0!==t.variation&&null!==t.variation&&(r.variation=t.variation),void 0!==t.version&&null!==t.version?r.version=t.version:r.unknown=!0,n.counters.push(r),i=!1}return i?null:{startDate:t,endDate:n,features:e}},e.clearSummary=()=>{t=0,n=0,r={},o={}},e};function Oe(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Le(e){return(e.startsWith("/")?e.substring(1):e).split("/").map((e=>e.indexOf("~")>=0?e.replace(/~1/g,"/").replace(/~0/g,"~"):e))}function Ue(e){return!e.startsWith("/")}function Te(e,t){const n=Ue(e),r=Ue(t);if(n&&r)return e===t;if(n){const n=Le(t);return 1===n.length&&e===n[0]}if(r){const n=Le(e);return 1===n.length&&t===n[0]}return e===t}function Re(e){return`/${Oe(e)}`}var Ae={cloneExcluding:function(e,t){const n=[],r={},o=[];for(n.push(...Object.keys(e).map((t=>({key:t,ptr:Re(t),source:e,parent:r,visited:[e]}))));n.length;){const e=n.pop();if(t.some((t=>Te(t,e.ptr))))o.push(e.ptr);else{const t=e.source[e.key];if(null===t)e.parent[e.key]=t;else if(Array.isArray(t))e.parent[e.key]=[...t];else if("object"==typeof t){if(e.visited.includes(t))continue;e.parent[e.key]={},n.push(...Object.keys(t).map((n=>{return{key:n,ptr:(r=e.ptr,o=Oe(n),`${r}/${o}`),source:t,parent:e.parent[e.key],visited:[...e.visited,t]};var r,o})))}else e.parent[e.key]=t}}return{cloned:r,excluded:o.sort()}},compare:Te,literalToReference:Re};var je=function(e){const t={},n=e.allAttributesPrivate,r=e.privateAttributes||[],o=["key","kind","_meta","anonymous"],i=["name","ip","firstName","lastName","email","avatar","country"],a=e=>{if("object"!=typeof e||null===e||Array.isArray(e))return;const{cloned:t,excluded:i}=Ae.cloneExcluding(e,(e=>(n?Object.keys(e):[...r,...e._meta&&e._meta.privateAttributes||[]]).filter((e=>!o.some((t=>Ae.compare(e,t))))))(e));return t.key=String(t.key),i.length&&(t._meta||(t._meta={}),t._meta.redactedAttributes=i),t._meta&&(delete t._meta.privateAttributes,0===Object.keys(t._meta).length&&delete t._meta),void 0!==t.anonymous&&(t.anonymous=!!t.anonymous),t};return t.filter=e=>void 0===e.kind||null===e.kind?a((e=>{const t={...e.custom||{},kind:"user",key:e.key};void 0!==e.anonymous&&(t.anonymous=!!e.anonymous);for(const n of i)delete t[n],void 0!==e[n]&&null!==e[n]&&(t[n]=String(e[n]));return void 0!==e.privateAttributeNames&&null!==e.privateAttributeNames&&(t._meta=t._meta||{},t._meta.privateAttributes=e.privateAttributeNames.map((e=>e.startsWith("/")?Ae.literalToReference(e):e))),t})(e)):"multi"===e.kind?(e=>{const t={kind:e.kind},n=Object.keys(e);for(const r of n)if("kind"!==r){const n=a(e[r]);n&&(t[r]=n)}return t})(e):a(e),t};const{getContextKeys:Fe}=Pe;var Ne=function(e,t,n,r=null,o=null,i=null){const a={},c=i||Ee(e,n,t),u=O.appendUrlPath(t.eventsUrl,"/events/bulk/"+n),l=Ie(),d=je(t),f=t.samplingInterval,g=t.eventCapacity,v=t.flushInterval,p=t.logger;let m,h=[],y=0,w=!1,b=!1;function k(){return 0===f||0===Math.floor(Math.random()*f)}function E(e){const t=O.extend({},e);return"identify"===e.kind?t.context=d.filter(e.context):(t.contextKeys=Fe(e.context,p),delete t.context),"feature"===e.kind&&(delete t.trackEvents,delete t.debugEventsUntilDate),t}function D(e){h.length<g?(h.push(e),b=!1):(b||(b=!0,p.warn(ue.eventCapacityExceeded())),r&&r.incrementDroppedEvents())}return a.enqueue=function(e){if(w)return;let t=!1,n=!1;var r;if(l.summarizeEvent(e),"feature"===e.kind?k()&&(t=!!e.trackEvents,n=!!(r=e).debugEventsUntilDate&&r.debugEventsUntilDate>y&&r.debugEventsUntilDate>(new Date).getTime()):t=k(),t&&D(E(e)),n){const t=O.extend({},e,{kind:"debug"});t.context=d.filter(t.context),delete t.trackEvents,delete t.debugEventsUntilDate,D(t)}},a.flush=function(){if(w)return Promise.resolve();const e=h,t=l.getSummary();return l.clearSummary(),t&&(t.kind="summary",e.push(t)),r&&r.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(h=[],p.debug(ue.debugPostingEvents(e.length)),c.sendEvents(e,u).then((e=>{const t=e&&e[0];t&&(t.serverTime&&(y=t.serverTime),s.isHttpErrorRecoverable(t.status)||(w=!0),t.status>=400&&O.onNextTick((()=>{o.maybeReportError(new s.LDUnexpectedResponseError(ue.httpErrorMessage(t.status,"event posting","some events were dropped")))})))})))},a.start=function(){const e=()=>{a.flush(),m=setTimeout(e,v)};m=setTimeout(e,v)},a.stop=function(){clearTimeout(m)},a};var $e=function(e){const t={},n={};return t.on=function(e,t,r){n[e]=n[e]||[],n[e]=n[e].concat({handler:t,context:r})},t.off=function(e,t,r){if(n[e])for(let o=0;o<n[e].length;o++)n[e][o].handler===t&&n[e][o].context===r&&(n[e]=n[e].slice(0,o).concat(n[e].slice(o+1)))},t.emit=function(e){if(!n[e])return;const t=n[e].slice(0);for(let e=0;e<t.length;e++)t[e].handler.apply(t[e].context,Array.prototype.slice.call(arguments,1))},t.getEvents=function(){return Object.keys(n)},t.getEventListenerCount=function(e){return n[e]?n[e].length:0},t.maybeReportError=function(t){t&&(n["error"]?this.emit("error",t):(e||console).error(t.message))},t};const Ve="ready",He="initialized",qe="failed";var Me=function(e){let t=!1,n=!1,r=null,o=null;const i=new Promise((t=>{const n=()=>{e.off(Ve,n),t()};e.on(Ve,n)})).catch((()=>{}));return{getInitializationPromise:()=>o||(t?Promise.resolve():n?Promise.reject(r):(o=new Promise(((t,n)=>{const r=()=>{e.off(He,r),t()},o=t=>{e.off(qe,o),n(t)};e.on(He,r),e.on(qe,o)})),o)),getReadyPromise:()=>i,signalSuccess:()=>{t||n||(t=!0,e.emit(He),e.emit(Ve))},signalFailure:o=>{t||n||(n=!0,r=o,e.emit(qe,o),e.emit(Ve)),e.maybeReportError(o)}}};var Ke=function(e,t,n,r){const o={};function i(){let e="";const o=r.getContext();return o&&(e=n||O.btoa(JSON.stringify(o))),"ld:"+t+":"+e}return o.loadFlags=()=>e.get(i()).then((e=>{if(null==e)return null;try{let t=JSON.parse(e);if(t){const e=t.$schema;void 0===e||e<1?t=O.transformValuesToVersionedValues(t):delete t.$schema}return t}catch(e){return o.clearFlags().then((()=>null))}})),o.saveFlags=t=>{const n=O.extend({},t,{$schema:1});return e.set(i(),JSON.stringify(n))},o.clearFlags=()=>e.clear(i()),o};var _e=function(e,t){const n={};let r=!1;const o=e=>{r||(r=!0,t.warn(ue.localStorageUnavailable(e)))};return n.isEnabled=()=>!!e,n.get=t=>new Promise((n=>{e?e.get(t).then(n).catch((e=>{o(e),n(void 0)})):n(void 0)})),n.set=(t,n)=>new Promise((r=>{e?e.set(t,n).then((()=>r(!0))).catch((e=>{o(e),r(!1)})):r(!1)})),n.clear=t=>new Promise((n=>{e?e.clear(t).then((()=>n(!0))).catch((e=>{o(e),n(!1)})):n(!1)})),n};const{appendUrlPath:Je,base64URLEncode:ze,objectHasOwnProperty:Be}=O,{getLDHeaders:Ge,transformHeaders:We}=he,{isHttpErrorRecoverable:Xe}=s,Qe=3e5,Ye=3e4,Ze=.5;var et=function(e,t,n,r){const o=t.streamUrl,i=t.logger,a={},s=Je(o,"/eval/"+n),c=t.useReport,u=t.evaluationReasons,l=t.streamReconnectDelay,d=Ge(e,t);let f,g=!1,v=null,p=null,m=null,h=null,y=null,w=0;function b(){const e=(t=function(){const e=l*Math.pow(2,w);return e>Ye?Ye:e}(),t-Math.trunc(Math.random()*Ze*t));var t;return w+=1,e}function k(e){if(e.status&&"number"==typeof e.status&&!Xe(e.status))return C(),i.error(ue.unrecoverableStreamError(e)),void(p&&(clearTimeout(p),p=null));const t=b();g||(i.warn(ue.streamError(e,t)),g=!0),x(!1),C(),E(t)}function E(e){p||(e?p=setTimeout(D,e):D())}function D(){let r;p=null;let a="";const l={headers:d,readTimeoutMillis:Qe};if(e.eventSourceFactory){null!=h&&(a="h="+h),c?e.eventSourceAllowsReport?(r=s,l.method="REPORT",l.headers["Content-Type"]="application/json",l.body=JSON.stringify(m)):(r=Je(o,"/ping/"+n),a=""):r=s+"/"+ze(JSON.stringify(m)),l.headers=We(l.headers,t),u&&(a=a+(a?"&":"")+"withReasons=true"),r=r+(a?"?":"")+a,C(),i.info(ue.streamConnecting(r)),f=(new Date).getTime(),v=e.eventSourceFactory(r,l);for(const e in y)Be(y,e)&&v.addEventListener(e,y[e]);v.onerror=k,v.onopen=()=>{w=0}}}function C(){v&&(i.info(ue.streamClosing()),v.close(),v=null)}function x(e){f&&r&&r.recordStreamInit(f,!e,(new Date).getTime()-f),f=null}return a.connect=function(e,t,n){m=e,h=t,y={};for(const e in n||{})y[e]=function(t){g=!1,x(!0),n[e]&&n[e](t)};E()},a.disconnect=function(){clearTimeout(p),p=null,C()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a};var tt=function(e){let t,n,r,o;const i={addPromise:(i,a)=>{t=i,n&&n(),n=a,i.then((n=>{t===i&&(r(n),e&&e())}),(n=>{t===i&&(o(n),e&&e())}))}};return i.resultPromise=new Promise(((e,t)=>{r=e,o=t})),i};const{transformHeaders:nt,getLDHeaders:rt}=he,ot="application/json";var it=function(e,t,n){const r=t.baseUrl,o=t.useReport,i=t.evaluationReasons,a=t.logger,c={},u={};function l(n,r){if(!e.httpRequest)return new Promise(((e,t)=>{t(new s.LDFlagFetchError(ue.httpUnavailable()))}));const o=r?"REPORT":"GET",i=rt(e,t);r&&(i["Content-Type"]=ot);let a=u[n];a||(a=tt((()=>{delete u[n]})),u[n]=a);const c=e.httpRequest(o,n,nt(i,t),r),l=c.promise.then((e=>{if(200===e.status){if(e.header("content-type")&&e.header("content-type").substring(0,ot.length)===ot)return JSON.parse(e.body);{const t=ue.invalidContentType(e.header("content-type")||"");return Promise.reject(new s.LDFlagFetchError(t))}}return Promise.reject(function(e){return 404===e.status?new s.LDInvalidEnvironmentIdError(ue.environmentNotFound()):new s.LDFlagFetchError(ue.errorFetchingFlags(e.statusText||String(e.status)))}(e))}),(e=>Promise.reject(new s.LDFlagFetchError(ue.networkError(e)))));return a.addPromise(l,(()=>{c.cancel&&c.cancel()})),a.resultPromise}return c.fetchJSON=function(e){return l(O.appendUrlPath(r,e),null)},c.fetchFlagSettings=function(e,t){let s,c,u,d="";return o?(c=[r,"/sdk/evalx/",n,"/context"].join(""),u=JSON.stringify(e)):(s=O.base64URLEncode(JSON.stringify(e)),c=[r,"/sdk/evalx/",n,"/contexts/",s].join("")),t&&(d="h="+t),i&&(d=d+(d?"&":"")+"withReasons=true"),c=c+(d?"?":"")+d,a.debug(ue.debugPolling(c)),l(c,u)},c};var at=function(e,t){const n={};let r;return n.setContext=function(e){r=O.sanitizeContext(e),r&&t&&t(O.clone(r))},n.getContext=function(){return r?O.clone(r):null},e&&n.setContext(e),n};const{v1:st}=oe,{getContextKinds:ct}=Pe,ut="ld:$anonUserId";var lt=function(e){function t(e){return null==e||"user"===e?ut:`ld:$contextKey:${e}`}function n(n,r){return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?function(n){return e.get(t(n))}(n).then((o=>{if(o)return r.key=o,r;{const o=st();return r.key=o,function(n,r){return e.set(t(r),n)}(o,n).then((()=>r))}})):Promise.reject(new s.LDInvalidUserError(ue.invalidContext()))}this.processContext=e=>{if(!e)return Promise.reject(new s.LDInvalidUserError(ue.contextNotSpecified()));const t=O.clone(e);if("multi"===e.kind){const e=ct(t);return Promise.all(e.map((e=>n(e,t[e])))).then((()=>t))}return n(e.kind,t)}};const{v1:dt}=oe,{baseOptionDefs:ft}=pe,{appendUrlPath:gt}=O;var vt={DiagnosticId:function(e){const t={diagnosticId:dt()};return e&&(t.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),t},DiagnosticsAccumulator:function(e){let t,n,r,o;function i(e){t=e,n=0,r=0,o=[]}return i(e),{getProps:()=>({dataSinceDate:t,droppedEvents:n,eventsInLastBatch:r,streamInits:o}),setProps:e=>{t=e.dataSinceDate,n=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:()=>{n++},setEventsInLastBatch:e=>{r=e},recordStreamInit:(e,t,n)=>{const r={timestamp:e,failed:t,durationMillis:n};o.push(r)},reset:i}},DiagnosticsManager:function(e,t,n,r,o,i,a){const s=!!e.diagnosticUseCombinedEvent,c="ld:"+o+":$diagnostics",u=gt(i.eventsUrl,"/events/diagnostic/"+o),l=i.diagnosticRecordingInterval,d=n;let f,g,v=!!i.streaming;const p={};function m(){return{sdk:w(),configuration:b(),platform:e.diagnosticPlatformData}}function h(e){i.logger&&i.logger.debug(ue.debugPostingDiagnosticEvent(e)),r.sendEvents(e,u,!0).then((()=>{})).catch((()=>{}))}function y(){h(function(){const e=(new Date).getTime();let t={kind:s?"diagnostic-combined":"diagnostic",id:a,creationDate:e,...d.getProps()};return s&&(t={...t,...m()}),d.reset(e),t}()),g=setTimeout(y,l),f=(new Date).getTime(),s&&function(){if(t.isEnabled()){const e={...d.getProps()};t.set(c,JSON.stringify(e))}}()}function w(){const t={...e.diagnosticSdkData};return i.wrapperName&&(t.wrapperName=i.wrapperName),i.wrapperVersion&&(t.wrapperVersion=i.wrapperVersion),t}function b(){return{customBaseURI:i.baseUrl!==ft.baseUrl.default,customStreamURI:i.streamUrl!==ft.streamUrl.default,customEventsURI:i.eventsUrl!==ft.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!v,allAttributesPrivate:!!i.allAttributesPrivate,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation}}return p.start=()=>{s?function(e){if(!t.isEnabled())return e(!1);t.get(c).then((t=>{if(t)try{const e=JSON.parse(t);d.setProps(e),f=e.dataSinceDate}catch(e){}e(!0)})).catch((()=>{e(!1)}))}((e=>{if(e){const e=(f||0)+l,t=(new Date).getTime();t>=e?y():g=setTimeout(y,e-t)}else 0===Math.floor(4*Math.random())?y():g=setTimeout(y,l)})):(h({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate,...m()}),g=setTimeout(y,l))},p.stop=()=>{g&&clearTimeout(g)},p.setStreaming=e=>{v=e},p}};var pt=function(e,t){let n=!1;const r={type:e.type,name:e.name,method:(...o)=>{try{e.method(...o)}catch{n||(n=!0,t.warn(ue.inspectorMethodError(r.type,r.name)))}}};return r};const{onNextTick:mt}=O,ht={flagUsed:"flag-used",flagDetailsChanged:"flag-details-changed",flagDetailChanged:"flag-detail-changed",clientIdentityChanged:"client-identity-changed"};Object.freeze(ht);var yt={InspectorTypes:ht,InspectorManager:function(e,t){const n={},r={[ht.flagUsed]:[],[ht.flagDetailsChanged]:[],[ht.flagDetailChanged]:[],[ht.clientIdentityChanged]:[]},o=e&&e.map((e=>pt(e,t)));return o&&o.forEach((e=>{Object.prototype.hasOwnProperty.call(r,e.type)?r[e.type].push(e):t.warn(ue.invalidInspector(e.type,e.name))})),n.hasListeners=e=>r[e]&&r[e].length,n.onFlagUsed=(e,t,n)=>{r[ht.flagUsed].length&&mt((()=>{r[ht.flagUsed].forEach((r=>r.method(e,t,n)))}))},n.onFlags=e=>{r[ht.flagDetailsChanged].length&&mt((()=>{r[ht.flagDetailsChanged].forEach((t=>t.method(e)))}))},n.onFlagChanged=(e,t)=>{r[ht.flagDetailChanged].length&&mt((()=>{r[ht.flagDetailChanged].forEach((n=>n.method(e,t)))}))},n.onIdentityChanged=e=>{r[ht.clientIdentityChanged].length&&mt((()=>{r[ht.clientIdentityChanged].forEach((t=>t.method(e)))}))},n}};const{commonBasicLogger:wt}=ae,{checkContext:bt,getContextKeys:kt}=Pe,{InspectorTypes:Et,InspectorManager:Dt}=yt,Ct="change",xt="internal-change";var Pt={initialize:function(e,t,n,r,o){const i=function(){if(n&&n.logger)return n.logger;return o&&o.logger&&o.logger.default||wt("warn")}(),a=$e(i),c=Me(a),u=pe.validate(n,a,o,i),l=Dt(u.inspectors,i),d=u.sendEvents;let f=e,g=u.hash;const v=_e(r.localStorage,i),p=Ee(r,f,u),m=u.sendEvents&&!u.diagnosticOptOut,h=m?vt.DiagnosticId(f):null,y=m?vt.DiagnosticsAccumulator((new Date).getTime()):null,w=m?vt.DiagnosticsManager(r,v,y,p,f,u,h):null,b=et(r,u,f,y),k=u.eventProcessor||Ne(r,u,f,y,a,p),E=it(r,u,f);let D,C,x,P={},S=u.streaming,I=!1,L=!1,U=!0;const T=u.stateProvider,R=at(null,(function(e){(function(e){if(T)return;e&&F({kind:"identify",context:e,creationDate:(new Date).getTime()})})(e),l.hasListeners(Et.clientIdentityChanged)&&l.onIdentityChanged(R.getContext())})),A=new lt(v),j=v.isEnabled()?Ke(v,f,g,R):null;function F(e){f&&(T&&T.enqueueEvent&&T.enqueueEvent(e)||(e.context?(U=!1,!d||L||r.isDoNotTrack()||(i.debug(ue.debugEnqueueingEvent(e.kind)),k.enqueue(e))):U&&(i.warn(ue.eventWithoutContext()),U=!1)))}function N(e,t){l.hasListeners(Et.flagDetailChanged)&&l.onFlagChanged(e.key,M(t))}function $(){l.hasListeners(Et.flagDetailsChanged)&&l.onFlags(Object.entries(P).map((([e,t])=>({key:e,detail:M(t)}))).reduce(((e,t)=>(e[t.key]=t.detail,e)),{}))}function V(e,t,n,r){const o=R.getContext(),i=new Date,a={kind:"feature",key:e,context:o,value:t?t.value:null,variation:t?t.variationIndex:null,default:n,creationDate:i.getTime()},s=P[e];s&&(a.version=s.flagVersion?s.flagVersion:s.version,a.trackEvents=s.trackEvents,a.debugEventsUntilDate=s.debugEventsUntilDate),(r||s&&s.trackReason)&&t&&(a.reason=t.reason),F(a)}function H(e){return bt(e,!1)?Promise.resolve(e):Promise.reject(new s.LDInvalidUserError(ue.invalidContext()))}function q(e,t,n,r,o){let i;if(P&&O.objectHasOwnProperty(P,e)&&P[e]&&!P[e].deleted){const n=P[e];i=M(n),null!==n.value&&void 0!==n.value||(i.value=t)}else i={value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return n&&V(e,i,t,r),o||function(e,t){l.hasListeners(Et.flagUsed)&&l.onFlagUsed(e,t,R.getContext())}(e,i),i}function M(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function K(){if(C=!0,!R.getContext())return;const e=e=>{try{return JSON.parse(e)}catch(e){return void a.maybeReportError(new s.LDInvalidDataError(ue.invalidData()))}};b.connect(R.getContext(),g,{ping:function(){i.debug(ue.debugStreamPing());const e=R.getContext();E.fetchFlagSettings(e,g).then((t=>{O.deepEquals(e,R.getContext())&&J(t||{})})).catch((e=>{a.maybeReportError(new s.LDFlagFetchError(ue.errorFetchingFlags(e)))}))},put:function(t){const n=e(t.data);n&&(i.debug(ue.debugStreamPut()),J(n))},patch:function(t){const n=e(t.data);if(!n)return;const r=P[n.key];if(!r||!r.version||!n.version||r.version<n.version){i.debug(ue.debugStreamPatch(n.key));const e={},t=O.extend({},n);delete t.key,P[n.key]=t;const o=M(t);e[n.key]=r?{previous:r.value,current:o}:{current:o},z(e),N(n,t)}else i.debug(ue.debugStreamPatchIgnored(n.key))},delete:function(t){const n=e(t.data);if(n)if(!P[n.key]||P[n.key].version<n.version){i.debug(ue.debugStreamDelete(n.key));const e={};P[n.key]&&!P[n.key].deleted&&(e[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},N(n,P[n.key]),z(e)}else i.debug(ue.debugStreamDeleteIgnored(n.key))}})}function _(){C&&(b.disconnect(),C=!1)}function J(e){const t={};if(!e)return Promise.resolve();for(const n in P)O.objectHasOwnProperty(P,n)&&P[n]&&(e[n]&&!O.deepEquals(e[n].value,P[n].value)?t[n]={previous:P[n].value,current:M(e[n])}:e[n]&&!e[n].deleted||(t[n]={previous:P[n].value}));for(const n in e)O.objectHasOwnProperty(e,n)&&e[n]&&(!P[n]||P[n].deleted)&&(t[n]={current:M(e[n])});return P={...e},$(),z(t).catch((()=>{}))}function z(e){const t=Object.keys(e);if(t.length>0){const n={};t.forEach((t=>{const r=e[t].current,o=r?r.value:void 0,i=e[t].previous;a.emit(Ct+":"+t,o,i),n[t]=r?{current:o,previous:i}:{previous:i}})),a.emit(Ct,n),a.emit(xt,P),u.sendEventsOnlyForVariation||T||t.forEach((t=>{V(t,e[t].current)}))}return D&&j?j.saveFlags(P):Promise.resolve()}function B(){const e=S||x&&void 0===S;e&&!C?K():!e&&C&&_(),w&&w.setStreaming(e)}function G(e){return e===Ct||e.substr(0,Ct.length+1)===Ct+":"}if("string"==typeof u.bootstrap&&"LOCALSTORAGE"===u.bootstrap.toUpperCase()&&(j?D=!0:i.warn(ue.localStorageUnavailable())),"object"==typeof u.bootstrap&&(P=function(e){const t=Object.keys(e),n="$flagsState",r="$valid",o=e[n];!o&&t.length&&i.warn(ue.bootstrapOldFormat()),!1===e[r]&&i.warn(ue.bootstrapInvalid());const a={};return t.forEach((t=>{if(t!==n&&t!==r){let n={value:e[t]};o&&o[t]?n=O.extend(n,o[t]):n.version=0,a[t]=n}})),a}(u.bootstrap)),T){const e=T.getInitialState();e?W(e):T.on("init",W),T.on("update",(function(e){e.context&&R.setContext(e.context);e.flags&&J(e.flags)}))}else(function(){if(!e)return Promise.reject(new s.LDInvalidEnvironmentIdError(ue.environmentNotSpecified()));return A.processContext(t).then(H).then((e=>(R.setContext(e),"object"==typeof u.bootstrap?X():D?j.loadFlags().then((e=>null==e?(P={},E.fetchFlagSettings(R.getContext(),g).then((e=>J(e||{}))).then(X).catch((e=>{Q(new s.LDFlagFetchError(ue.errorFetchingFlags(e)))}))):(P=e,O.onNextTick(X),E.fetchFlagSettings(R.getContext(),g).then((e=>J(e))).catch((e=>a.maybeReportError(e)))))):E.fetchFlagSettings(R.getContext(),g).then((e=>{P=e||{},$(),X()})).catch((e=>{P={},Q(e)})))))})().catch(Q);function W(e){f=e.environment,R.setContext(e.context),P={...e.flags},O.onNextTick(X)}function X(){i.info(ue.clientInitialized()),I=!0,B(),c.signalSuccess()}function Q(e){c.signalFailure(e)}const Y={waitForInitialization:()=>c.getInitializationPromise(),waitUntilReady:()=>c.getReadyPromise(),identify:function(e,t,n){if(L)return O.wrapPromiseCallback(Promise.resolve({}),n);if(T)return i.warn(ue.identifyDisabled()),O.wrapPromiseCallback(Promise.resolve(O.transformVersionedValuesToValues(P)),n);const r=D&&j?j.clearFlags():Promise.resolve();return O.wrapPromiseCallback(r.then((()=>A.processContext(e))).then(H).then((e=>E.fetchFlagSettings(e,t).then((n=>{const r=O.transformVersionedValuesToValues(n);return R.setContext(e),g=t,n?J(n).then((()=>r)):r})))).then((e=>(C&&K(),e))).catch((e=>(a.maybeReportError(e),Promise.reject(e)))),n)},getContext:function(){return R.getContext()},variation:function(e,t){return q(e,t,!0,!1,!1).value},variationDetail:function(e,t){return q(e,t,!0,!0,!1)},track:function(e,t,n){if("string"!=typeof e)return void a.maybeReportError(new s.LDInvalidEventKeyError(ue.unknownCustomEventKey(e)));r.customEventFilter&&!r.customEventFilter(e)&&i.warn(ue.unknownCustomEventKey(e));const o=R.getContext(),c={kind:"custom",key:e,context:o,url:r.getCurrentUrl(),creationDate:(new Date).getTime()};o&&o.anonymous&&(c.contextKind=o.anonymous?"anonymousUser":"user"),null!=t&&(c.data=t),null!=n&&(c.metricValue=n),F(c)},on:function(e,t,n){G(e)?(x=!0,I&&B(),a.on(e,t,n)):a.on(...arguments)},off:function(e){if(a.off(...arguments),G(e)){let e=!1;a.getEvents().forEach((t=>{G(t)&&a.getEventListenerCount(t)>0&&(e=!0)})),e||(x=!1,C&&void 0===S&&_())}},setStreaming:function(e){const t=null===e?void 0:e;t!==S&&(S=t,B())},flush:function(e){return O.wrapPromiseCallback(d?k.flush():Promise.resolve(),e)},allFlags:function(){const e={};if(!P)return e;for(const t in P)O.objectHasOwnProperty(P,t)&&!P[t].deleted&&(e[t]=q(t,null,!u.sendEventsOnlyForVariation,!1,!0).value);return e},close:function(e){if(L)return O.wrapPromiseCallback(Promise.resolve(),e);const t=()=>{L=!0,P={}},n=Promise.resolve().then((()=>{if(_(),w&&w.stop(),d)return k.stop(),k.flush()})).then(t).catch(t);return O.wrapPromiseCallback(n,e)}};return{client:Y,options:u,emitter:a,ident:R,logger:i,requestor:E,start:function(){d&&(w&&w.start(),k.start())},enqueueEvent:F,getFlagsInternal:function(){return P},getEnvironmentId:()=>f,internalChangeEventName:xt}},commonBasicLogger:wt,errors:s,messages:ue,utils:O,getContextKeys:kt},St=Pt.initialize,It=Pt.errors,Ot=Pt.messages,Lt=Pt.getContextKeys;function Ut(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Tt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ut(Object(n),!0).forEach((function(t){Rt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ut(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Rt(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var At=Pt.commonBasicLogger;var jt=function(e){return At(Tt({destination:console.log},e))};var Ft={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Nt(e,t,n,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var t=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(t)return parseInt(t[2],10)<73}return!0}())return Ft;var i=new window.XMLHttpRequest;for(var a in i.open(e,t,!o),n||{})Object.prototype.hasOwnProperty.call(n,a)&&i.setRequestHeader(a,n[a]);if(o)return i.send(r),Ft;var s,c=new Promise((function(e,t){i.addEventListener("load",(function(){s||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})})),i.addEventListener("error",(function(){s||t(new Error)})),i.send(r)}));return{promise:c,cancel:function(){s=!0,i.abort()}}}var $t=e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")};function Vt(e,t,n,r){var o,i,a=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?t:t.replace(r,"")).replace(n,"");switch(e.kind){case"exact":i=t,o=new RegExp("^"+$t(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+$t(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+$t(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Ht(e,t){for(var n={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],s=a.urls||[],c=0;c<s.length;c++)if(Vt(s[c],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?t("pageview",a):(o.push(a),t("click_pageview",a));break}return o.length>0&&(r=function(e){for(var n=function(e,t){for(var n=[],r=0;r<t.length;r++)for(var o=e.target,i=t[r],a=i.selector,s=document.querySelectorAll(a);o&&s.length>0;){for(var c=0;c<s.length;c++)o===s[c]&&n.push(i);o=o.parentNode}return n}(e,o),r=0;r<n.length;r++)t("click",n[r])},document.addEventListener("click",r)),n.dispose=function(){document.removeEventListener("click",r)},n}var qt=300;function Mt(e,t){var n,r;function o(){r&&r.dispose(),n&&n.length&&(r=Ht(n,i))}function i(t,n){var r=e.ident.getContext(),o={kind:t,key:n.key,data:null,url:window.location.href,creationDate:(new Date).getTime(),contextKeys:Lt(r)};return"click"===t&&(o.selector=n.selector),e.enqueueEvent(o)}return e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=Ht(n=e,i),function(e,t){var n,r=window.location.href;function o(){(n=window.location.href)!==r&&(r=n,t())}!function e(t,n){t(),setTimeout((function(){e(t,n)}),n)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(qt,o)),t()})).catch((function(n){e.emitter.maybeReportError(new It.LDUnexpectedResponseError((n&&n.message,n.message))),t()})),{}}var Kt="goalsReady",_t={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function Jt(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var t,n={userAgentHeaderName:"X-LaunchDarkly-User-Agent",synchronousFlush:!1};if(window.XMLHttpRequest){var r=e&&e.disableSyncEventPost;n.httpRequest=function(e,t,o,i){var a=n.synchronousFlush&!r;return n.synchronousFlush=!1,Nt(e,t,o,i,a)}}n.httpAllowsPost=function(){return void 0===t&&(t=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),t},n.httpFallbackPing=function(e){(new window.Image).src=e};var o,i=e&&e.eventUrlTransformer;n.getCurrentUrl=function(){return i?i(window.location.href):window.location.href},n.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&&(n.localStorage={get:function(e){return new Promise((function(t){t(window.localStorage.getItem(e))}))},set:function(e,t){return new Promise((function(n){window.localStorage.setItem(e,t),n()}))},clear:function(e){return new Promise((function(t){window.localStorage.removeItem(e),t()}))}})}catch(e){n.localStorage=null}if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(n.eventSourceAllowsReport=!0,o=window.EventSourcePolyfill):(n.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource){var a=3e5;n.eventSourceFactory=function(e,t){var n=Tt(Tt({},{heartbeatTimeout:a,silentTimeout:a,skipDefaultHeaders:!0}),t);return new o(e,n)},n.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return n.userAgent="JSClient",n.version="3.1.1",n.diagnosticSdkData={name:"js-client-sdk",version:"3.1.1"},n.diagnosticPlatformData={name:"JS"},n.diagnosticUseCombinedEvent=!0,n}(n),o=St(e,t,n,r,_t),i=o.client,a=o.options,s=o.emitter,c=new Promise((function(e){var t=s.on(Kt,(function(){s.off(Kt,t),e()}))}));i.waitUntilGoalsReady=function(){return c},a.fetchGoals?Mt(o,(function(){return s.emit(Kt)})):s.emit(Kt),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var u=function(){r.synchronousFlush=!0,i.flush().catch((function(){})),r.synchronousFlush=!1};return document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&u()})),window.addEventListener("pagehide",u),i}var zt=jt,Bt=void 0,Gt="3.1.1";var Wt={initialize:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Ot.deprecated("default export","named LDClient export")),Jt(e,t,n)},version:Gt};export{zt as basicLogger,Bt as createConsoleLogger,Wt as default,Jt as initialize,Gt as version};
function e(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return t.prototype=new Error,t.prototype.name=e,t.prototype.constructor=t,t}const t=e("LaunchDarklyUnexpectedResponseError"),n=e("LaunchDarklyInvalidEnvironmentIdError"),r=e("LaunchDarklyInvalidUserError"),o=e("LaunchDarklyInvalidEventKeyError"),i=e("LaunchDarklyInvalidArgumentError"),a=e("LaunchDarklyFlagFetchError");for(var s={LDUnexpectedResponseError:t,LDInvalidEnvironmentIdError:n,LDInvalidUserError:r,LDInvalidEventKeyError:o,LDInvalidArgumentError:i,LDInvalidDataError:e("LaunchDarklyInvalidDataError"),LDFlagFetchError:a,isHttpErrorRecoverable:function(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}},c=function(e){var t=h(e),n=t[0],r=t[1];return 3*(n+r)/4-r},u=function(e){var t,n,r=h(e),o=r[0],i=r[1],a=new g(function(e,t,n){return 3*(t+n)/4-n}(0,o,i)),s=0,c=i>0?o-4:o;for(n=0;n<c;n+=4)t=f[e.charCodeAt(n)]<<18|f[e.charCodeAt(n+1)]<<12|f[e.charCodeAt(n+2)]<<6|f[e.charCodeAt(n+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=255&t;2===i&&(t=f[e.charCodeAt(n)]<<2|f[e.charCodeAt(n+1)]>>4,a[s++]=255&t);1===i&&(t=f[e.charCodeAt(n)]<<10|f[e.charCodeAt(n+1)]<<4|f[e.charCodeAt(n+2)]>>2,a[s++]=t>>8&255,a[s++]=255&t);return a},l=function(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(y(e,a,a+i>s?s:a+i));1===r?(t=e[n-1],o.push(d[t>>2]+d[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],o.push(d[t>>10]+d[t>>4&63]+d[t<<2&63]+"="));return o.join("")},d=[],f=[],g="undefined"!=typeof Uint8Array?Uint8Array:Array,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,m=v.length;p<m;++p)d[p]=v[p],f[v.charCodeAt(p)]=p;function h(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function y(e,t,n){for(var r,o,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(d[(o=r)>>18&63]+d[o>>12&63]+d[o>>6&63]+d[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63;var w={byteLength:c,toByteArray:u,fromByteArray:l},b=Array.isArray,k=Object.keys,E=Object.prototype.hasOwnProperty,D=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i,a=b(t),s=b(n);if(a&&s){if((o=t.length)!=n.length)return!1;for(r=o;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(a!=s)return!1;var c=t instanceof Date,u=n instanceof Date;if(c!=u)return!1;if(c&&u)return t.getTime()==n.getTime();var l=t instanceof RegExp,d=n instanceof RegExp;if(l!=d)return!1;if(l&&d)return t.toString()==n.toString();var f=k(t);if((o=f.length)!==k(n).length)return!1;for(r=o;0!=r--;)if(!E.call(n,f[r]))return!1;for(r=o;0!=r--;)if(!e(t[i=f[r]],n[i]))return!1;return!0}return t!=t&&n!=n};const C=["key","ip","country","email","firstName","lastName","avatar","name"];function x(e){const t=unescape(encodeURIComponent(e));return w.fromByteArray(function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}(t))}function P(e){return x(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function S(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var I,O={appendUrlPath:function(e,t){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(t.startsWith("/")?"":"/")+t},base64URLEncode:P,btoa:x,chunkEventsForUrl:function(e,t){const n=t.slice(0),r=[];let o,i=e;for(;n.length>0;){for(o=[];i>0;){const e=n.shift();if(!e)break;i-=P(JSON.stringify(e)).length,i<0&&o.length>0?n.unshift(e):o.push(e)}i=e,r.push(o)}return r},clone:function(e){return JSON.parse(JSON.stringify(e))},deepEquals:function(e,t){return D(e,t)},extend:function(...e){return e.reduce(((e,t)=>({...e,...t})),{})},getLDUserAgentString:function(e){const t=e.version||"?";return e.userAgent+"/"+t},objectHasOwnProperty:S,onNextTick:function(e){setTimeout(e,0)},sanitizeContext:function(e){if(!e)return e;let t;return null!==e.kind&&void 0!==e.kind||C.forEach((n=>{const r=e[n];void 0!==r&&"string"!=typeof r&&(t=t||{...e},t[n]=String(r))})),t||e},transformValuesToVersionedValues:function(e){const t={};for(const n in e)S(e,n)&&(t[n]={value:e[n],version:0});return t},transformVersionedValuesToValues:function(e){const t={};for(const n in e)S(e,n)&&(t[n]=e[n].value);return t},wrapPromiseCallback:function(e,t){const n=e.then((e=>(t&&setTimeout((()=>{t(null,e)}),0),e)),(e=>{if(!t)return Promise.reject(e);setTimeout((()=>{t(e,null)}),0)}));return t?void 0:n}},L=new Uint8Array(16);function U(){if(!I&&!(I="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return I(L)}var T=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function R(e){return"string"==typeof e&&T.test(e)}for(var A,j,F=[],N=0;N<256;++N)F.push((N+256).toString(16).substr(1));function $(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(F[e[t+0]]+F[e[t+1]]+F[e[t+2]]+F[e[t+3]]+"-"+F[e[t+4]]+F[e[t+5]]+"-"+F[e[t+6]]+F[e[t+7]]+"-"+F[e[t+8]]+F[e[t+9]]+"-"+F[e[t+10]]+F[e[t+11]]+F[e[t+12]]+F[e[t+13]]+F[e[t+14]]+F[e[t+15]]).toLowerCase();if(!R(n))throw TypeError("Stringified UUID is invalid");return n}var V=0,H=0;function q(e){if(!R(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}var M="6ba7b810-9dad-11d1-80b4-00c04fd430c8",K="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function _(e,t,n){function r(e,r,o,i){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=q(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+e.length);if(a.set(r),a.set(e,r.length),(a=n(a))[6]=15&a[6]|t,a[8]=63&a[8]|128,o){i=i||0;for(var s=0;s<16;++s)o[i+s]=a[s];return o}return $(a)}try{r.name=e}catch(e){}return r.DNS=M,r.URL=K,r}function J(e){return 14+(e+64>>>9<<4)+1}function z(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function B(e,t,n,r,o,i){return z((a=z(z(t,e),z(r,i)))<<(s=o)|a>>>32-s,n);var a,s}function G(e,t,n,r,o,i,a){return B(t&n|~t&r,e,t,o,i,a)}function W(e,t,n,r,o,i,a){return B(t&r|n&~r,e,t,o,i,a)}function X(e,t,n,r,o,i,a){return B(t^n^r,e,t,o,i,a)}function Q(e,t,n,r,o,i,a){return B(n^(t|~r),e,t,o,i,a)}var Y=_("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,r="0123456789abcdef",o=0;o<n;o+=8){var i=e[o>>5]>>>o%32&255,a=parseInt(r.charAt(i>>>4&15)+r.charAt(15&i),16);t.push(a)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[J(t)-1]=t;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,a=0;a<e.length;a+=16){var s=n,c=r,u=o,l=i;n=G(n,r,o,i,e[a],7,-680876936),i=G(i,n,r,o,e[a+1],12,-389564586),o=G(o,i,n,r,e[a+2],17,606105819),r=G(r,o,i,n,e[a+3],22,-1044525330),n=G(n,r,o,i,e[a+4],7,-176418897),i=G(i,n,r,o,e[a+5],12,1200080426),o=G(o,i,n,r,e[a+6],17,-1473231341),r=G(r,o,i,n,e[a+7],22,-45705983),n=G(n,r,o,i,e[a+8],7,1770035416),i=G(i,n,r,o,e[a+9],12,-1958414417),o=G(o,i,n,r,e[a+10],17,-42063),r=G(r,o,i,n,e[a+11],22,-1990404162),n=G(n,r,o,i,e[a+12],7,1804603682),i=G(i,n,r,o,e[a+13],12,-40341101),o=G(o,i,n,r,e[a+14],17,-1502002290),n=W(n,r=G(r,o,i,n,e[a+15],22,1236535329),o,i,e[a+1],5,-165796510),i=W(i,n,r,o,e[a+6],9,-1069501632),o=W(o,i,n,r,e[a+11],14,643717713),r=W(r,o,i,n,e[a],20,-373897302),n=W(n,r,o,i,e[a+5],5,-701558691),i=W(i,n,r,o,e[a+10],9,38016083),o=W(o,i,n,r,e[a+15],14,-660478335),r=W(r,o,i,n,e[a+4],20,-405537848),n=W(n,r,o,i,e[a+9],5,568446438),i=W(i,n,r,o,e[a+14],9,-1019803690),o=W(o,i,n,r,e[a+3],14,-187363961),r=W(r,o,i,n,e[a+8],20,1163531501),n=W(n,r,o,i,e[a+13],5,-1444681467),i=W(i,n,r,o,e[a+2],9,-51403784),o=W(o,i,n,r,e[a+7],14,1735328473),n=X(n,r=W(r,o,i,n,e[a+12],20,-1926607734),o,i,e[a+5],4,-378558),i=X(i,n,r,o,e[a+8],11,-2022574463),o=X(o,i,n,r,e[a+11],16,1839030562),r=X(r,o,i,n,e[a+14],23,-35309556),n=X(n,r,o,i,e[a+1],4,-1530992060),i=X(i,n,r,o,e[a+4],11,1272893353),o=X(o,i,n,r,e[a+7],16,-155497632),r=X(r,o,i,n,e[a+10],23,-1094730640),n=X(n,r,o,i,e[a+13],4,681279174),i=X(i,n,r,o,e[a],11,-358537222),o=X(o,i,n,r,e[a+3],16,-722521979),r=X(r,o,i,n,e[a+6],23,76029189),n=X(n,r,o,i,e[a+9],4,-640364487),i=X(i,n,r,o,e[a+12],11,-421815835),o=X(o,i,n,r,e[a+15],16,530742520),n=Q(n,r=X(r,o,i,n,e[a+2],23,-995338651),o,i,e[a],6,-198630844),i=Q(i,n,r,o,e[a+7],10,1126891415),o=Q(o,i,n,r,e[a+14],15,-1416354905),r=Q(r,o,i,n,e[a+5],21,-57434055),n=Q(n,r,o,i,e[a+12],6,1700485571),i=Q(i,n,r,o,e[a+3],10,-1894986606),o=Q(o,i,n,r,e[a+10],15,-1051523),r=Q(r,o,i,n,e[a+1],21,-2054922799),n=Q(n,r,o,i,e[a+8],6,1873313359),i=Q(i,n,r,o,e[a+15],10,-30611744),o=Q(o,i,n,r,e[a+6],15,-1560198380),r=Q(r,o,i,n,e[a+13],21,1309151649),n=Q(n,r,o,i,e[a+4],6,-145523070),i=Q(i,n,r,o,e[a+11],10,-1120210379),o=Q(o,i,n,r,e[a+2],15,718787259),r=Q(r,o,i,n,e[a+9],21,-343485551),n=z(n,s),r=z(r,c),o=z(o,u),i=z(i,l)}return[n,r,o,i]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(J(t)),r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))})),Z=Y;function ee(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function te(e,t){return e<<t|e>>>32-t}var ne=_("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var o=0;o<r.length;++o)e.push(r.charCodeAt(o))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var i=e.length/4+2,a=Math.ceil(i/16),s=new Array(a),c=0;c<a;++c){for(var u=new Uint32Array(16),l=0;l<16;++l)u[l]=e[64*c+4*l]<<24|e[64*c+4*l+1]<<16|e[64*c+4*l+2]<<8|e[64*c+4*l+3];s[c]=u}s[a-1][14]=8*(e.length-1)/Math.pow(2,32),s[a-1][14]=Math.floor(s[a-1][14]),s[a-1][15]=8*(e.length-1)&4294967295;for(var d=0;d<a;++d){for(var f=new Uint32Array(80),g=0;g<16;++g)f[g]=s[d][g];for(var v=16;v<80;++v)f[v]=te(f[v-3]^f[v-8]^f[v-14]^f[v-16],1);for(var p=n[0],m=n[1],h=n[2],y=n[3],w=n[4],b=0;b<80;++b){var k=Math.floor(b/20),E=te(p,5)+ee(k,m,h,y)+w+t[k]+f[b]>>>0;w=y,y=h,h=te(m,30)>>>0,m=p,p=E}n[0]=n[0]+p>>>0,n[1]=n[1]+m>>>0,n[2]=n[2]+h>>>0,n[3]=n[3]+y>>>0,n[4]=n[4]+w>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]})),re=ne;var oe=Object.freeze({__proto__:null,v1:function(e,t,n){var r=t&&n||0,o=t||new Array(16),i=(e=e||{}).node||A,a=void 0!==e.clockseq?e.clockseq:j;if(null==i||null==a){var s=e.random||(e.rng||U)();null==i&&(i=A=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==a&&(a=j=16383&(s[6]<<8|s[7]))}var c=void 0!==e.msecs?e.msecs:Date.now(),u=void 0!==e.nsecs?e.nsecs:H+1,l=c-V+(u-H)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||c>V)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");V=c,H=u,j=a;var d=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;o[r++]=d>>>24&255,o[r++]=d>>>16&255,o[r++]=d>>>8&255,o[r++]=255&d;var f=c/4294967296*1e4&268435455;o[r++]=f>>>8&255,o[r++]=255&f,o[r++]=f>>>24&15|16,o[r++]=f>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var g=0;g<6;++g)o[r+g]=i[g];return t||$(o)},v3:Z,v4:function(e,t,n){var r=(e=e||{}).random||(e.rng||U)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=r[o];return t}return $(r)},v5:re,NIL:"00000000-0000-0000-0000-000000000000",version:function(e){if(!R(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)},validate:R,stringify:$,parse:q});const ie=["debug","info","warn","error","none"];var ae={commonBasicLogger:function(e,t){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(e){return function(t){console&&console[e]&&console[e].call(console,t)}}const r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],o=!(!e||!e.destination),i=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ";let a=1;if(e&&e.level)for(let t=0;t<ie.length;t++)ie[t]===e.level&&(a=t);function s(e,n,a){if(a.length<1)return;let s;const c=o?n+": "+i:i;if(1!==a.length&&t){const e=[...a];e[0]=c+e[0],s=t(...e)}else s=c+a[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}const c={};for(let e=0;e<ie.length;e++){const t=ie[e];if("none"!==t)if(e<a)c[t]=()=>{};else{const n=e;c[t]=function(){s(n,t,arguments)}}}return c},validateLogger:function(e){ie.forEach((t=>{if("none"!==t&&(!e[t]||"function"!=typeof e[t]))throw new Error("Provided logger instance must support logger."+t+"(...) method")}))}};function se(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}const ce=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.";var ue={bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},bootstrapOldFormat:function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+ce},clientInitialized:function(){return"LaunchDarkly client initialized"},clientNotReady:function(){return"LaunchDarkly client is not ready"},debugEnqueueingEvent:function(e){return'enqueueing "'+e+'" event'},debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},debugPostingEvents:function(e){return"sending "+e+" events"},debugStreamDelete:function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored:function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugStreamPatch:function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored:function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamPing:function(){return"received ping message from stream"},debugPolling:function(e){return"polling for feature flags at "+e},debugStreamPut:function(){return"received streaming update for all flags"},deprecated:function(e,t){return t?'"'+e+'" is deprecated, please use "'+t+'"':'"'+e+'" is deprecated'},environmentNotFound:function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+ce},environmentNotSpecified:function(){return"No environment/client-side ID was specified."+ce},errorFetchingFlags:function(e){return"Error fetching flag settings: "+se(e)},eventCapacityExceeded:function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutContext:function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},httpErrorMessage:function(e,t,n){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+t+" - "+(s.isHttpErrorRecoverable(e)?n:"giving up permanently")},httpUnavailable:function(){return"Cannot make HTTP requests in this environment."+ce},identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},inspectorMethodError:(e,t)=>`an inspector: "${t}" of type: "${e}" generated an exception`,invalidContentType:function(e){return'Expected application/json content type but got "'+e+'"'},invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},invalidInspector:(e,t)=>`an inspector: "${t}" of an invalid type (${e}) was configured`,invalidKey:function(){return"Event key must be a string"},invalidContext:function(){return"Invalid context specified."+ce},invalidTagValue:e=>`Config option "${e}" must only contain letters, numbers, ., _ or -.`,localStorageUnavailable:function(e){return"local storage is unavailable: "+se(e)},networkError:e=>"network error"+(e?" ("+e+")":""),optionBelowMinimum:(e,t,n)=>'Config option "'+e+'" was set to '+t+", changing to minimum value of "+n,streamClosing:function(){return"Closing stream connection"},streamConnecting:function(e){return"Opening stream connection to "+e},streamError:function(e,t){return"Error on stream connection: "+se(e)+", will continue retrying after "+t+" milliseconds."},tagValueTooLong:e=>`Value of "${e}" was longer than 64 characters and was discarded.`,unknownCustomEventKey:function(e){return'Custom event "'+e+'" does not exist'},unknownOption:e=>'Ignoring unknown config option "'+e+'"',contextNotSpecified:function(){return"No context specified."+ce},unrecoverableStreamError:e=>`Error on stream connection ${se(e)}, giving up permanently`,wrongOptionType:(e,t,n)=>'Config option "'+e+'" should be of type '+t+", got "+n+", using default value",wrongOptionTypeBoolean:(e,t)=>'Config option "'+e+'" should be a boolean, got '+t+", converting to boolean"};const{validateLogger:le}=ae,de={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"},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},privateAttributes:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},application:{validator:function(e,t,n){const r={};t.id&&(r.id=ve(`${e}.id`,t.id,n));t.version&&(r.version=ve(`${e}.version`,t.version,n));return r}},inspectors:{default:[]}},fe=/^(\w|\.|-)+$/;function ge(e){return e&&e.replace(/\/+$/,"")}function ve(e,t,n){if("string"==typeof t&&t.match(fe)){if(!(t.length>64))return t;n.warn(ue.tagValueTooLong(e))}else n.warn(ue.invalidTagValue(e))}var pe={baseOptionDefs:de,validate:function(e,t,n,r){const o=O.extend({logger:{default:r}},de,n),i={};function a(e){O.onNextTick((()=>{t&&t.maybeReportError(new s.LDInvalidArgumentError(e))}))}let c=O.extend({},e||{});return function(e){const t=e;Object.keys(i).forEach((e=>{if(void 0!==t[e]){const n=i[e];r&&r.warn(ue.deprecated(e,n)),n&&(void 0===t[n]&&(t[n]=t[e]),delete t[e])}}))}(c),c=function(e){const t=O.extend({},e);return Object.keys(o).forEach((e=>{void 0!==t[e]&&null!==t[e]||(t[e]=o[e]&&o[e].default)})),t}(c),c=function(e){const t=O.extend({},e),n=e=>{if(null===e)return"any";if(void 0===e)return;if(Array.isArray(e))return"array";const t=typeof e;return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"};return Object.keys(e).forEach((i=>{const s=e[i];if(null!=s){const c=o[i];if(void 0===c)a(ue.unknownOption(i));else{const o=c.type||n(c.default),u=c.validator;if(u){const n=u(i,e[i],r);void 0!==n?t[i]=n:delete t[i]}else if("any"!==o){const e=o.split("|"),r=n(s);e.indexOf(r)<0?"boolean"===o?(t[i]=!!s,a(ue.wrongOptionTypeBoolean(i,r))):(a(ue.wrongOptionType(i,o,r)),t[i]=c.default):"number"===r&&void 0!==c.minimum&&s<c.minimum&&(a(ue.optionBelowMinimum(i,s,c.minimum)),t[i]=c.minimum)}}}})),t.baseUrl=ge(t.baseUrl),t.streamUrl=ge(t.streamUrl),t.eventsUrl=ge(t.eventsUrl),t}(c),le(c.logger),c},getTags:function(e){const t={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(t["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(t["application-version"]=[e.application.version])),t}};const{getLDUserAgentString:me}=O;var he={getLDHeaders:function(e,t){if(t&&!t.sendLDHeaders)return{};const n={};n[e.userAgentHeaderName||"User-Agent"]=me(e),t&&t.wrapperName&&(n["X-LaunchDarkly-Wrapper"]=t.wrapperVersion?t.wrapperName+"/"+t.wrapperVersion:t.wrapperName);const r=pe.getTags(t),o=Object.keys(r);return o.length&&(n["x-launchdarkly-tags"]=o.sort().map((e=>Array.isArray(r[e])?r[e].sort().map((t=>`${e}/${t}`)):[`${e}/${r[e]}`])).reduce(((e,t)=>e.concat(t)),[]).join(" ")),n},transformHeaders:function(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform({...e}):e}};const{v1:ye}=oe,{getLDHeaders:we,transformHeaders:be}=he,ke=2e3;var Ee=function(e,t,n){const r="/a/"+t+".gif",o=O.extend({"Content-Type":"application/json"},we(e,n)),i=e.httpFallbackPing,a={};return a.sendChunk=(t,a,c,u)=>{const l=JSON.stringify(t),d=c?null:ye();return u?function t(r){const i=c?o:O.extend({},o,{"X-LaunchDarkly-Event-Schema":"4","X-LaunchDarkly-Payload-ID":d});return e.httpRequest("POST",a,be(i,n),l).promise.then((e=>{if(e)return e.status>=400&&s.isHttpErrorRecoverable(e.status)&&r?t(!1):function(e){const t={status:e.status},n=e.header("date");if(n){const e=Date.parse(n);e&&(t.serverTime=e)}return t}(e)})).catch((()=>r?t(!1):Promise.reject()))}(!0).catch((()=>{})):(i&&i(a+r+"?d="+O.base64URLEncode(l)),Promise.resolve())},a.sendEvents=function(t,n,r){if(!e.httpRequest)return Promise.resolve();const o=e.httpAllowsPost();let i;i=o?[t]:O.chunkEventsForUrl(ke-n.length,t);const s=[];for(let e=0;e<i.length;e++)s.push(a.sendChunk(i[e],n,r,o));return Promise.all(s)},a};const{commonBasicLogger:De}=ae;function Ce(e){return"string"==typeof e&&"kind"!==e&&e.match(/^(\w|\.|-)+$/)}function xe(e){return e.includes("%")||e.includes(":")?e.replace(/%/g,"%25").replace(/:/g,"%3A"):e}var Pe={checkContext:function(e,t){if(e){if(t&&(void 0===e.kind||null===e.kind))return void 0!==e.key&&null!==e.key;const n=e.key,r=void 0===e.kind?"user":e.kind,o=Ce(r),i="multi"===r||null!=n&&""!==n;if("multi"===r){const t=Object.keys(e).filter((e=>"kind"!==e));return i&&t.every((e=>Ce(e)))&&t.every((t=>{const n=e[t].key;return null!=n&&""!==n}))}return i&&o}return!1},getContextKeys:function(e,t=De()){if(!e)return;const n={},{kind:r,key:o}=e;switch(r){case void 0:n.user=`${o}`;break;case"multi":Object.entries(e).filter((([e])=>"kind"!==e)).forEach((([e,t])=>{t&&t.key&&(n[e]=t.key)}));break;case null:t.warn(`null is not a valid context kind: ${e}`);break;case"":t.warn(`'' is not a valid context kind: ${e}`);break;default:n[r]=`${o}`}return n},getContextKinds:function(e){return e?null===e.kind||void 0===e.kind?["user"]:"multi"!==e.kind?[e.kind]:Object.keys(e).filter((e=>"kind"!==e)):[]},getCanonicalKey:function(e){if(e){if((void 0===e.kind||null===e.kind||"user"===e.kind)&&e.key)return e.key;if("multi"!==e.kind&&e.key)return`${e.kind}:${xe(e.key)}`;if("multi"===e.kind)return Object.keys(e).sort().filter((e=>"kind"!==e)).map((t=>`${t}:${xe(e[t].key)}`)).join(":")}}};const{getContextKinds:Se}=Pe;var Ie=function(){const e={};let t=0,n=0,r={},o={};return e.summarizeEvent=e=>{if("feature"===e.kind){const i=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),a=r[i];let s=o[e.key];s||(s=new Set,o[e.key]=s),function(e){return e.context?Se(e.context):e.contextKeys?Object.keys(e.contextKeys):[]}(e).forEach((e=>s.add(e))),a?a.count=a.count+1:r[i]={count:1,key:e.key,version:e.version,variation:e.variation,value:e.value,default:e.default},(0===t||e.creationDate<t)&&(t=e.creationDate),e.creationDate>n&&(n=e.creationDate)}},e.getSummary=()=>{const e={};let i=!0;for(const t of Object.values(r)){let n=e[t.key];n||(n={default:t.default,counters:[],contextKinds:[...o[t.key]]},e[t.key]=n);const r={value:t.value,count:t.count};void 0!==t.variation&&null!==t.variation&&(r.variation=t.variation),void 0!==t.version&&null!==t.version?r.version=t.version:r.unknown=!0,n.counters.push(r),i=!1}return i?null:{startDate:t,endDate:n,features:e}},e.clearSummary=()=>{t=0,n=0,r={},o={}},e};function Oe(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Le(e){return(e.startsWith("/")?e.substring(1):e).split("/").map((e=>e.indexOf("~")>=0?e.replace(/~1/g,"/").replace(/~0/g,"~"):e))}function Ue(e){return!e.startsWith("/")}function Te(e,t){const n=Ue(e),r=Ue(t);if(n&&r)return e===t;if(n){const n=Le(t);return 1===n.length&&e===n[0]}if(r){const n=Le(e);return 1===n.length&&t===n[0]}return e===t}function Re(e){return`/${Oe(e)}`}var Ae={cloneExcluding:function(e,t){const n=[],r={},o=[];for(n.push(...Object.keys(e).map((t=>({key:t,ptr:Re(t),source:e,parent:r,visited:[e]}))));n.length;){const e=n.pop();if(t.some((t=>Te(t,e.ptr))))o.push(e.ptr);else{const t=e.source[e.key];if(null===t)e.parent[e.key]=t;else if(Array.isArray(t))e.parent[e.key]=[...t];else if("object"==typeof t){if(e.visited.includes(t))continue;e.parent[e.key]={},n.push(...Object.keys(t).map((n=>{return{key:n,ptr:(r=e.ptr,o=Oe(n),`${r}/${o}`),source:t,parent:e.parent[e.key],visited:[...e.visited,t]};var r,o})))}else e.parent[e.key]=t}}return{cloned:r,excluded:o.sort()}},compare:Te,literalToReference:Re};var je=function(e){const t={},n=e.allAttributesPrivate,r=e.privateAttributes||[],o=["key","kind","_meta","anonymous"],i=["name","ip","firstName","lastName","email","avatar","country"],a=e=>{if("object"!=typeof e||null===e||Array.isArray(e))return;const{cloned:t,excluded:i}=Ae.cloneExcluding(e,(e=>(n?Object.keys(e):[...r,...e._meta&&e._meta.privateAttributes||[]]).filter((e=>!o.some((t=>Ae.compare(e,t))))))(e));return t.key=String(t.key),i.length&&(t._meta||(t._meta={}),t._meta.redactedAttributes=i),t._meta&&(delete t._meta.privateAttributes,0===Object.keys(t._meta).length&&delete t._meta),void 0!==t.anonymous&&(t.anonymous=!!t.anonymous),t};return t.filter=e=>void 0===e.kind||null===e.kind?a((e=>{const t={...e.custom||{},kind:"user",key:e.key};void 0!==e.anonymous&&(t.anonymous=!!e.anonymous);for(const n of i)delete t[n],void 0!==e[n]&&null!==e[n]&&(t[n]=String(e[n]));return void 0!==e.privateAttributeNames&&null!==e.privateAttributeNames&&(t._meta=t._meta||{},t._meta.privateAttributes=e.privateAttributeNames.map((e=>e.startsWith("/")?Ae.literalToReference(e):e))),t})(e)):"multi"===e.kind?(e=>{const t={kind:e.kind},n=Object.keys(e);for(const r of n)if("kind"!==r){const n=a(e[r]);n&&(t[r]=n)}return t})(e):a(e),t};const{getContextKeys:Fe}=Pe;var Ne=function(e,t,n,r=null,o=null,i=null){const a={},c=i||Ee(e,n,t),u=O.appendUrlPath(t.eventsUrl,"/events/bulk/"+n),l=Ie(),d=je(t),f=t.samplingInterval,g=t.eventCapacity,v=t.flushInterval,p=t.logger;let m,h=[],y=0,w=!1,b=!1;function k(){return 0===f||0===Math.floor(Math.random()*f)}function E(e){const t=O.extend({},e);return"identify"===e.kind?t.context=d.filter(e.context):(t.contextKeys=Fe(e.context,p),delete t.context),"feature"===e.kind&&(delete t.trackEvents,delete t.debugEventsUntilDate),t}function D(e){h.length<g?(h.push(e),b=!1):(b||(b=!0,p.warn(ue.eventCapacityExceeded())),r&&r.incrementDroppedEvents())}return a.enqueue=function(e){if(w)return;let t=!1,n=!1;var r;if(l.summarizeEvent(e),"feature"===e.kind?k()&&(t=!!e.trackEvents,n=!!(r=e).debugEventsUntilDate&&r.debugEventsUntilDate>y&&r.debugEventsUntilDate>(new Date).getTime()):t=k(),t&&D(E(e)),n){const t=O.extend({},e,{kind:"debug"});t.context=d.filter(t.context),delete t.trackEvents,delete t.debugEventsUntilDate,D(t)}},a.flush=function(){if(w)return Promise.resolve();const e=h,t=l.getSummary();return l.clearSummary(),t&&(t.kind="summary",e.push(t)),r&&r.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(h=[],p.debug(ue.debugPostingEvents(e.length)),c.sendEvents(e,u).then((e=>{const t=e&&e[0];t&&(t.serverTime&&(y=t.serverTime),s.isHttpErrorRecoverable(t.status)||(w=!0),t.status>=400&&O.onNextTick((()=>{o.maybeReportError(new s.LDUnexpectedResponseError(ue.httpErrorMessage(t.status,"event posting","some events were dropped")))})))})))},a.start=function(){const e=()=>{a.flush(),m=setTimeout(e,v)};m=setTimeout(e,v)},a.stop=function(){clearTimeout(m)},a};var $e=function(e){const t={},n={};return t.on=function(e,t,r){n[e]=n[e]||[],n[e]=n[e].concat({handler:t,context:r})},t.off=function(e,t,r){if(n[e])for(let o=0;o<n[e].length;o++)n[e][o].handler===t&&n[e][o].context===r&&(n[e]=n[e].slice(0,o).concat(n[e].slice(o+1)))},t.emit=function(e){if(!n[e])return;const t=n[e].slice(0);for(let e=0;e<t.length;e++)t[e].handler.apply(t[e].context,Array.prototype.slice.call(arguments,1))},t.getEvents=function(){return Object.keys(n)},t.getEventListenerCount=function(e){return n[e]?n[e].length:0},t.maybeReportError=function(t){t&&(n["error"]?this.emit("error",t):(e||console).error(t.message))},t};const Ve="ready",He="initialized",qe="failed";var Me=function(e){let t=!1,n=!1,r=null,o=null;const i=new Promise((t=>{const n=()=>{e.off(Ve,n),t()};e.on(Ve,n)})).catch((()=>{}));return{getInitializationPromise:()=>o||(t?Promise.resolve():n?Promise.reject(r):(o=new Promise(((t,n)=>{const r=()=>{e.off(He,r),t()},o=t=>{e.off(qe,o),n(t)};e.on(He,r),e.on(qe,o)})),o)),getReadyPromise:()=>i,signalSuccess:()=>{t||n||(t=!0,e.emit(He),e.emit(Ve))},signalFailure:o=>{t||n||(n=!0,r=o,e.emit(qe,o),e.emit(Ve)),e.maybeReportError(o)}}};var Ke=function(e,t,n,r){const o={};function i(){let e="";const o=r.getContext();return o&&(e=n||O.btoa(JSON.stringify(o))),"ld:"+t+":"+e}return o.loadFlags=()=>e.get(i()).then((e=>{if(null==e)return null;try{let t=JSON.parse(e);if(t){const e=t.$schema;void 0===e||e<1?t=O.transformValuesToVersionedValues(t):delete t.$schema}return t}catch(e){return o.clearFlags().then((()=>null))}})),o.saveFlags=t=>{const n=O.extend({},t,{$schema:1});return e.set(i(),JSON.stringify(n))},o.clearFlags=()=>e.clear(i()),o};var _e=function(e,t){const n={};let r=!1;const o=e=>{r||(r=!0,t.warn(ue.localStorageUnavailable(e)))};return n.isEnabled=()=>!!e,n.get=t=>new Promise((n=>{e?e.get(t).then(n).catch((e=>{o(e),n(void 0)})):n(void 0)})),n.set=(t,n)=>new Promise((r=>{e?e.set(t,n).then((()=>r(!0))).catch((e=>{o(e),r(!1)})):r(!1)})),n.clear=t=>new Promise((n=>{e?e.clear(t).then((()=>n(!0))).catch((e=>{o(e),n(!1)})):n(!1)})),n};const{appendUrlPath:Je,base64URLEncode:ze,objectHasOwnProperty:Be}=O,{getLDHeaders:Ge,transformHeaders:We}=he,{isHttpErrorRecoverable:Xe}=s,Qe=3e5,Ye=3e4,Ze=.5;var et=function(e,t,n,r){const o=t.streamUrl,i=t.logger,a={},s=Je(o,"/eval/"+n),c=t.useReport,u=t.evaluationReasons,l=t.streamReconnectDelay,d=Ge(e,t);let f,g=!1,v=null,p=null,m=null,h=null,y=null,w=0;function b(){const e=(t=function(){const e=l*Math.pow(2,w);return e>Ye?Ye:e}(),t-Math.trunc(Math.random()*Ze*t));var t;return w+=1,e}function k(e){if(e.status&&"number"==typeof e.status&&!Xe(e.status))return C(),i.error(ue.unrecoverableStreamError(e)),void(p&&(clearTimeout(p),p=null));const t=b();g||(i.warn(ue.streamError(e,t)),g=!0),x(!1),C(),E(t)}function E(e){p||(e?p=setTimeout(D,e):D())}function D(){let r;p=null;let a="";const l={headers:d,readTimeoutMillis:Qe};if(e.eventSourceFactory){null!=h&&(a="h="+h),c?e.eventSourceAllowsReport?(r=s,l.method="REPORT",l.headers["Content-Type"]="application/json",l.body=JSON.stringify(m)):(r=Je(o,"/ping/"+n),a=""):r=s+"/"+ze(JSON.stringify(m)),l.headers=We(l.headers,t),u&&(a=a+(a?"&":"")+"withReasons=true"),r=r+(a?"?":"")+a,C(),i.info(ue.streamConnecting(r)),f=(new Date).getTime(),v=e.eventSourceFactory(r,l);for(const e in y)Be(y,e)&&v.addEventListener(e,y[e]);v.onerror=k,v.onopen=()=>{w=0}}}function C(){v&&(i.info(ue.streamClosing()),v.close(),v=null)}function x(e){f&&r&&r.recordStreamInit(f,!e,(new Date).getTime()-f),f=null}return a.connect=function(e,t,n){m=e,h=t,y={};for(const e in n||{})y[e]=function(t){g=!1,x(!0),n[e]&&n[e](t)};E()},a.disconnect=function(){clearTimeout(p),p=null,C()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a};var tt=function(e){let t,n,r,o;const i={addPromise:(i,a)=>{t=i,n&&n(),n=a,i.then((n=>{t===i&&(r(n),e&&e())}),(n=>{t===i&&(o(n),e&&e())}))}};return i.resultPromise=new Promise(((e,t)=>{r=e,o=t})),i};const{transformHeaders:nt,getLDHeaders:rt}=he,ot="application/json";var it=function(e,t,n){const r=t.baseUrl,o=t.useReport,i=t.evaluationReasons,a=t.logger,c={},u={};function l(n,r){if(!e.httpRequest)return new Promise(((e,t)=>{t(new s.LDFlagFetchError(ue.httpUnavailable()))}));const o=r?"REPORT":"GET",i=rt(e,t);r&&(i["Content-Type"]=ot);let a=u[n];a||(a=tt((()=>{delete u[n]})),u[n]=a);const c=e.httpRequest(o,n,nt(i,t),r),l=c.promise.then((e=>{if(200===e.status){if(e.header("content-type")&&e.header("content-type").substring(0,ot.length)===ot)return JSON.parse(e.body);{const t=ue.invalidContentType(e.header("content-type")||"");return Promise.reject(new s.LDFlagFetchError(t))}}return Promise.reject(function(e){return 404===e.status?new s.LDInvalidEnvironmentIdError(ue.environmentNotFound()):new s.LDFlagFetchError(ue.errorFetchingFlags(e.statusText||String(e.status)))}(e))}),(e=>Promise.reject(new s.LDFlagFetchError(ue.networkError(e)))));return a.addPromise(l,(()=>{c.cancel&&c.cancel()})),a.resultPromise}return c.fetchJSON=function(e){return l(O.appendUrlPath(r,e),null)},c.fetchFlagSettings=function(e,t){let s,c,u,d="";return o?(c=[r,"/sdk/evalx/",n,"/context"].join(""),u=JSON.stringify(e)):(s=O.base64URLEncode(JSON.stringify(e)),c=[r,"/sdk/evalx/",n,"/contexts/",s].join("")),t&&(d="h="+t),i&&(d=d+(d?"&":"")+"withReasons=true"),c=c+(d?"?":"")+d,a.debug(ue.debugPolling(c)),l(c,u)},c};var at=function(e,t){const n={};let r;return n.setContext=function(e){r=O.sanitizeContext(e),r&&t&&t(O.clone(r))},n.getContext=function(){return r?O.clone(r):null},e&&n.setContext(e),n};const{v1:st}=oe,{getContextKinds:ct}=Pe,ut="ld:$anonUserId";var lt=function(e){function t(e){return null==e||"user"===e?ut:`ld:$contextKey:${e}`}function n(n,r){return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?function(n){return e.get(t(n))}(n).then((o=>{if(o)return r.key=o,r;{const o=st();return r.key=o,function(n,r){return e.set(t(r),n)}(o,n).then((()=>r))}})):Promise.reject(new s.LDInvalidUserError(ue.invalidContext()))}this.processContext=e=>{if(!e)return Promise.reject(new s.LDInvalidUserError(ue.contextNotSpecified()));const t=O.clone(e);if("multi"===e.kind){const e=ct(t);return Promise.all(e.map((e=>n(e,t[e])))).then((()=>t))}return n(e.kind,t)}};const{v1:dt}=oe,{baseOptionDefs:ft}=pe,{appendUrlPath:gt}=O;var vt={DiagnosticId:function(e){const t={diagnosticId:dt()};return e&&(t.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),t},DiagnosticsAccumulator:function(e){let t,n,r,o;function i(e){t=e,n=0,r=0,o=[]}return i(e),{getProps:()=>({dataSinceDate:t,droppedEvents:n,eventsInLastBatch:r,streamInits:o}),setProps:e=>{t=e.dataSinceDate,n=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:()=>{n++},setEventsInLastBatch:e=>{r=e},recordStreamInit:(e,t,n)=>{const r={timestamp:e,failed:t,durationMillis:n};o.push(r)},reset:i}},DiagnosticsManager:function(e,t,n,r,o,i,a){const s=!!e.diagnosticUseCombinedEvent,c="ld:"+o+":$diagnostics",u=gt(i.eventsUrl,"/events/diagnostic/"+o),l=i.diagnosticRecordingInterval,d=n;let f,g,v=!!i.streaming;const p={};function m(){return{sdk:w(),configuration:b(),platform:e.diagnosticPlatformData}}function h(e){i.logger&&i.logger.debug(ue.debugPostingDiagnosticEvent(e)),r.sendEvents(e,u,!0).then((()=>{})).catch((()=>{}))}function y(){h(function(){const e=(new Date).getTime();let t={kind:s?"diagnostic-combined":"diagnostic",id:a,creationDate:e,...d.getProps()};return s&&(t={...t,...m()}),d.reset(e),t}()),g=setTimeout(y,l),f=(new Date).getTime(),s&&function(){if(t.isEnabled()){const e={...d.getProps()};t.set(c,JSON.stringify(e))}}()}function w(){const t={...e.diagnosticSdkData};return i.wrapperName&&(t.wrapperName=i.wrapperName),i.wrapperVersion&&(t.wrapperVersion=i.wrapperVersion),t}function b(){return{customBaseURI:i.baseUrl!==ft.baseUrl.default,customStreamURI:i.streamUrl!==ft.streamUrl.default,customEventsURI:i.eventsUrl!==ft.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!v,allAttributesPrivate:!!i.allAttributesPrivate,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation}}return p.start=()=>{s?function(e){if(!t.isEnabled())return e(!1);t.get(c).then((t=>{if(t)try{const e=JSON.parse(t);d.setProps(e),f=e.dataSinceDate}catch(e){}e(!0)})).catch((()=>{e(!1)}))}((e=>{if(e){const e=(f||0)+l,t=(new Date).getTime();t>=e?y():g=setTimeout(y,e-t)}else 0===Math.floor(4*Math.random())?y():g=setTimeout(y,l)})):(h({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate,...m()}),g=setTimeout(y,l))},p.stop=()=>{g&&clearTimeout(g)},p.setStreaming=e=>{v=e},p}};var pt=function(e,t){let n=!1;const r={type:e.type,name:e.name,method:(...o)=>{try{e.method(...o)}catch{n||(n=!0,t.warn(ue.inspectorMethodError(r.type,r.name)))}}};return r};const{onNextTick:mt}=O,ht={flagUsed:"flag-used",flagDetailsChanged:"flag-details-changed",flagDetailChanged:"flag-detail-changed",clientIdentityChanged:"client-identity-changed"};Object.freeze(ht);var yt={InspectorTypes:ht,InspectorManager:function(e,t){const n={},r={[ht.flagUsed]:[],[ht.flagDetailsChanged]:[],[ht.flagDetailChanged]:[],[ht.clientIdentityChanged]:[]},o=e&&e.map((e=>pt(e,t)));return o&&o.forEach((e=>{Object.prototype.hasOwnProperty.call(r,e.type)?r[e.type].push(e):t.warn(ue.invalidInspector(e.type,e.name))})),n.hasListeners=e=>r[e]&&r[e].length,n.onFlagUsed=(e,t,n)=>{r[ht.flagUsed].length&&mt((()=>{r[ht.flagUsed].forEach((r=>r.method(e,t,n)))}))},n.onFlags=e=>{r[ht.flagDetailsChanged].length&&mt((()=>{r[ht.flagDetailsChanged].forEach((t=>t.method(e)))}))},n.onFlagChanged=(e,t)=>{r[ht.flagDetailChanged].length&&mt((()=>{r[ht.flagDetailChanged].forEach((n=>n.method(e,t)))}))},n.onIdentityChanged=e=>{r[ht.clientIdentityChanged].length&&mt((()=>{r[ht.clientIdentityChanged].forEach((t=>t.method(e)))}))},n}};const{commonBasicLogger:wt}=ae,{checkContext:bt,getContextKeys:kt}=Pe,{InspectorTypes:Et,InspectorManager:Dt}=yt,Ct="change",xt="internal-change";var Pt={initialize:function(e,t,n,r,o){const i=function(){if(n&&n.logger)return n.logger;return o&&o.logger&&o.logger.default||wt("warn")}(),a=$e(i),c=Me(a),u=pe.validate(n,a,o,i),l=Dt(u.inspectors,i),d=u.sendEvents;let f=e,g=u.hash;const v=_e(r.localStorage,i),p=Ee(r,f,u),m=u.sendEvents&&!u.diagnosticOptOut,h=m?vt.DiagnosticId(f):null,y=m?vt.DiagnosticsAccumulator((new Date).getTime()):null,w=m?vt.DiagnosticsManager(r,v,y,p,f,u,h):null,b=et(r,u,f,y),k=u.eventProcessor||Ne(r,u,f,y,a,p),E=it(r,u,f);let D,C,x,P={},S=u.streaming,I=!1,L=!1,U=!0;const T=u.stateProvider,R=at(null,(function(e){(function(e){if(T)return;e&&F({kind:"identify",context:e,creationDate:(new Date).getTime()})})(e),l.hasListeners(Et.clientIdentityChanged)&&l.onIdentityChanged(R.getContext())})),A=new lt(v),j=v.isEnabled()?Ke(v,f,g,R):null;function F(e){f&&(T&&T.enqueueEvent&&T.enqueueEvent(e)||(e.context?(U=!1,!d||L||r.isDoNotTrack()||(i.debug(ue.debugEnqueueingEvent(e.kind)),k.enqueue(e))):U&&(i.warn(ue.eventWithoutContext()),U=!1)))}function N(e,t){l.hasListeners(Et.flagDetailChanged)&&l.onFlagChanged(e.key,M(t))}function $(){l.hasListeners(Et.flagDetailsChanged)&&l.onFlags(Object.entries(P).map((([e,t])=>({key:e,detail:M(t)}))).reduce(((e,t)=>(e[t.key]=t.detail,e)),{}))}function V(e,t,n,r){const o=R.getContext(),i=new Date,a={kind:"feature",key:e,context:o,value:t?t.value:null,variation:t?t.variationIndex:null,default:n,creationDate:i.getTime()},s=P[e];s&&(a.version=s.flagVersion?s.flagVersion:s.version,a.trackEvents=s.trackEvents,a.debugEventsUntilDate=s.debugEventsUntilDate),(r||s&&s.trackReason)&&t&&(a.reason=t.reason),F(a)}function H(e){return bt(e,!1)?Promise.resolve(e):Promise.reject(new s.LDInvalidUserError(ue.invalidContext()))}function q(e,t,n,r,o){let i;if(P&&O.objectHasOwnProperty(P,e)&&P[e]&&!P[e].deleted){const n=P[e];i=M(n),null!==n.value&&void 0!==n.value||(i.value=t)}else i={value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return n&&V(e,i,t,r),o||function(e,t){l.hasListeners(Et.flagUsed)&&l.onFlagUsed(e,t,R.getContext())}(e,i),i}function M(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function K(){if(C=!0,!R.getContext())return;const e=e=>{try{return JSON.parse(e)}catch(e){return void a.maybeReportError(new s.LDInvalidDataError(ue.invalidData()))}};b.connect(R.getContext(),g,{ping:function(){i.debug(ue.debugStreamPing());const e=R.getContext();E.fetchFlagSettings(e,g).then((t=>{O.deepEquals(e,R.getContext())&&J(t||{})})).catch((e=>{a.maybeReportError(new s.LDFlagFetchError(ue.errorFetchingFlags(e)))}))},put:function(t){const n=e(t.data);n&&(i.debug(ue.debugStreamPut()),J(n))},patch:function(t){const n=e(t.data);if(!n)return;const r=P[n.key];if(!r||!r.version||!n.version||r.version<n.version){i.debug(ue.debugStreamPatch(n.key));const e={},t=O.extend({},n);delete t.key,P[n.key]=t;const o=M(t);e[n.key]=r?{previous:r.value,current:o}:{current:o},z(e),N(n,t)}else i.debug(ue.debugStreamPatchIgnored(n.key))},delete:function(t){const n=e(t.data);if(n)if(!P[n.key]||P[n.key].version<n.version){i.debug(ue.debugStreamDelete(n.key));const e={};P[n.key]&&!P[n.key].deleted&&(e[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},N(n,P[n.key]),z(e)}else i.debug(ue.debugStreamDeleteIgnored(n.key))}})}function _(){C&&(b.disconnect(),C=!1)}function J(e){const t={};if(!e)return Promise.resolve();for(const n in P)O.objectHasOwnProperty(P,n)&&P[n]&&(e[n]&&!O.deepEquals(e[n].value,P[n].value)?t[n]={previous:P[n].value,current:M(e[n])}:e[n]&&!e[n].deleted||(t[n]={previous:P[n].value}));for(const n in e)O.objectHasOwnProperty(e,n)&&e[n]&&(!P[n]||P[n].deleted)&&(t[n]={current:M(e[n])});return P={...e},$(),z(t).catch((()=>{}))}function z(e){const t=Object.keys(e);if(t.length>0){const n={};t.forEach((t=>{const r=e[t].current,o=r?r.value:void 0,i=e[t].previous;a.emit(Ct+":"+t,o,i),n[t]=r?{current:o,previous:i}:{previous:i}})),a.emit(Ct,n),a.emit(xt,P),u.sendEventsOnlyForVariation||T||t.forEach((t=>{V(t,e[t].current)}))}return D&&j?j.saveFlags(P):Promise.resolve()}function B(){const e=S||x&&void 0===S;e&&!C?K():!e&&C&&_(),w&&w.setStreaming(e)}function G(e){return e===Ct||e.substr(0,Ct.length+1)===Ct+":"}if("string"==typeof u.bootstrap&&"LOCALSTORAGE"===u.bootstrap.toUpperCase()&&(j?D=!0:i.warn(ue.localStorageUnavailable())),"object"==typeof u.bootstrap&&(P=function(e){const t=Object.keys(e),n="$flagsState",r="$valid",o=e[n];!o&&t.length&&i.warn(ue.bootstrapOldFormat()),!1===e[r]&&i.warn(ue.bootstrapInvalid());const a={};return t.forEach((t=>{if(t!==n&&t!==r){let n={value:e[t]};o&&o[t]?n=O.extend(n,o[t]):n.version=0,a[t]=n}})),a}(u.bootstrap)),T){const e=T.getInitialState();e?W(e):T.on("init",W),T.on("update",(function(e){e.context&&R.setContext(e.context);e.flags&&J(e.flags)}))}else(function(){if(!e)return Promise.reject(new s.LDInvalidEnvironmentIdError(ue.environmentNotSpecified()));return A.processContext(t).then(H).then((e=>(R.setContext(e),"object"==typeof u.bootstrap?X():D?j.loadFlags().then((e=>null==e?(P={},E.fetchFlagSettings(R.getContext(),g).then((e=>J(e||{}))).then(X).catch((e=>{Q(new s.LDFlagFetchError(ue.errorFetchingFlags(e)))}))):(P=e,O.onNextTick(X),E.fetchFlagSettings(R.getContext(),g).then((e=>J(e))).catch((e=>a.maybeReportError(e)))))):E.fetchFlagSettings(R.getContext(),g).then((e=>{P=e||{},$(),X()})).catch((e=>{P={},Q(e)})))))})().catch(Q);function W(e){f=e.environment,R.setContext(e.context),P={...e.flags},O.onNextTick(X)}function X(){i.info(ue.clientInitialized()),I=!0,B(),c.signalSuccess()}function Q(e){c.signalFailure(e)}const Y={waitForInitialization:()=>c.getInitializationPromise(),waitUntilReady:()=>c.getReadyPromise(),identify:function(e,t,n){if(L)return O.wrapPromiseCallback(Promise.resolve({}),n);if(T)return i.warn(ue.identifyDisabled()),O.wrapPromiseCallback(Promise.resolve(O.transformVersionedValuesToValues(P)),n);const r=D&&j?j.clearFlags():Promise.resolve();return O.wrapPromiseCallback(r.then((()=>A.processContext(e))).then(H).then((e=>E.fetchFlagSettings(e,t).then((n=>{const r=O.transformVersionedValuesToValues(n);return R.setContext(e),g=t,n?J(n).then((()=>r)):r})))).then((e=>(C&&K(),e))).catch((e=>(a.maybeReportError(e),Promise.reject(e)))),n)},getContext:function(){return R.getContext()},variation:function(e,t){return q(e,t,!0,!1,!1).value},variationDetail:function(e,t){return q(e,t,!0,!0,!1)},track:function(e,t,n){if("string"!=typeof e)return void a.maybeReportError(new s.LDInvalidEventKeyError(ue.unknownCustomEventKey(e)));r.customEventFilter&&!r.customEventFilter(e)&&i.warn(ue.unknownCustomEventKey(e));const o=R.getContext(),c={kind:"custom",key:e,context:o,url:r.getCurrentUrl(),creationDate:(new Date).getTime()};o&&o.anonymous&&(c.contextKind=o.anonymous?"anonymousUser":"user"),null!=t&&(c.data=t),null!=n&&(c.metricValue=n),F(c)},on:function(e,t,n){G(e)?(x=!0,I&&B(),a.on(e,t,n)):a.on(...arguments)},off:function(e){if(a.off(...arguments),G(e)){let e=!1;a.getEvents().forEach((t=>{G(t)&&a.getEventListenerCount(t)>0&&(e=!0)})),e||(x=!1,C&&void 0===S&&_())}},setStreaming:function(e){const t=null===e?void 0:e;t!==S&&(S=t,B())},flush:function(e){return O.wrapPromiseCallback(d?k.flush():Promise.resolve(),e)},allFlags:function(){const e={};if(!P)return e;for(const t in P)O.objectHasOwnProperty(P,t)&&!P[t].deleted&&(e[t]=q(t,null,!u.sendEventsOnlyForVariation,!1,!0).value);return e},close:function(e){if(L)return O.wrapPromiseCallback(Promise.resolve(),e);const t=()=>{L=!0,P={}},n=Promise.resolve().then((()=>{if(_(),w&&w.stop(),d)return k.stop(),k.flush()})).then(t).catch(t);return O.wrapPromiseCallback(n,e)}};return{client:Y,options:u,emitter:a,ident:R,logger:i,requestor:E,start:function(){d&&(w&&w.start(),k.start())},enqueueEvent:F,getFlagsInternal:function(){return P},getEnvironmentId:()=>f,internalChangeEventName:xt}},commonBasicLogger:wt,errors:s,messages:ue,utils:O,getContextKeys:kt},St=Pt.initialize,It=Pt.errors,Ot=Pt.messages,Lt=Pt.getContextKeys;function Ut(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Tt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ut(Object(n),!0).forEach((function(t){Rt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ut(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Rt(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var At=Pt.commonBasicLogger;var jt=function(e){return At(Tt({destination:console.log},e))};var Ft={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function Nt(e,t,n,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var t=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(t)return parseInt(t[2],10)<73}return!0}())return Ft;var i=new window.XMLHttpRequest;for(var a in i.open(e,t,!o),n||{})Object.prototype.hasOwnProperty.call(n,a)&&i.setRequestHeader(a,n[a]);if(o)return i.send(r),Ft;var s,c=new Promise((function(e,t){i.addEventListener("load",(function(){s||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})})),i.addEventListener("error",(function(){s||t(new Error)})),i.send(r)}));return{promise:c,cancel:function(){s=!0,i.abort()}}}var $t=e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")};function Vt(e,t,n,r){var o,i,a=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?t:t.replace(r,"")).replace(n,"");switch(e.kind){case"exact":i=t,o=new RegExp("^"+$t(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+$t(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+$t(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Ht(e,t){for(var n={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],s=a.urls||[],c=0;c<s.length;c++)if(Vt(s[c],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?t("pageview",a):(o.push(a),t("click_pageview",a));break}return o.length>0&&(r=function(e){for(var n=function(e,t){for(var n=[],r=0;r<t.length;r++)for(var o=e.target,i=t[r],a=i.selector,s=document.querySelectorAll(a);o&&s.length>0;){for(var c=0;c<s.length;c++)o===s[c]&&n.push(i);o=o.parentNode}return n}(e,o),r=0;r<n.length;r++)t("click",n[r])},document.addEventListener("click",r)),n.dispose=function(){document.removeEventListener("click",r)},n}var qt=300;function Mt(e,t){var n,r;function o(){r&&r.dispose(),n&&n.length&&(r=Ht(n,i))}function i(t,n){var r=e.ident.getContext(),o={kind:t,key:n.key,data:null,url:window.location.href,creationDate:(new Date).getTime(),contextKeys:Lt(r)};return"click"===t&&(o.selector=n.selector),e.enqueueEvent(o)}return e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=Ht(n=e,i),function(e,t){var n,r=window.location.href;function o(){(n=window.location.href)!==r&&(r=n,t())}!function e(t,n){t(),setTimeout((function(){e(t,n)}),n)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(qt,o)),t()})).catch((function(n){e.emitter.maybeReportError(new It.LDUnexpectedResponseError((n&&n.message,n.message))),t()})),{}}var Kt="goalsReady",_t={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function Jt(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var t,n={userAgentHeaderName:"X-LaunchDarkly-User-Agent",synchronousFlush:!1};if(window.XMLHttpRequest){var r=e&&e.disableSyncEventPost;n.httpRequest=function(e,t,o,i){var a=n.synchronousFlush&!r;return n.synchronousFlush=!1,Nt(e,t,o,i,a)}}n.httpAllowsPost=function(){return void 0===t&&(t=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),t},n.httpFallbackPing=function(e){(new window.Image).src=e};var o,i=e&&e.eventUrlTransformer;n.getCurrentUrl=function(){return i?i(window.location.href):window.location.href},n.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&&(n.localStorage={get:function(e){return new Promise((function(t){t(window.localStorage.getItem(e))}))},set:function(e,t){return new Promise((function(n){window.localStorage.setItem(e,t),n()}))},clear:function(e){return new Promise((function(t){window.localStorage.removeItem(e),t()}))}})}catch(e){n.localStorage=null}if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(n.eventSourceAllowsReport=!0,o=window.EventSourcePolyfill):(n.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource){var a=3e5;n.eventSourceFactory=function(e,t){var n=Tt(Tt({},{heartbeatTimeout:a,silentTimeout:a,skipDefaultHeaders:!0}),t);return new o(e,n)},n.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return n.userAgent="JSClient",n.version="3.1.2",n.diagnosticSdkData={name:"js-client-sdk",version:"3.1.2"},n.diagnosticPlatformData={name:"JS"},n.diagnosticUseCombinedEvent=!0,n}(n),o=St(e,t,n,r,_t),i=o.client,a=o.options,s=o.emitter,c=new Promise((function(e){var t=s.on(Kt,(function(){s.off(Kt,t),e()}))}));i.waitUntilGoalsReady=function(){return c},a.fetchGoals?Mt(o,(function(){return s.emit(Kt)})):s.emit(Kt),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var u=function(){r.synchronousFlush=!0,i.flush().catch((function(){})),r.synchronousFlush=!1};return document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&u()})),window.addEventListener("pagehide",u),i}var zt=jt,Bt=void 0,Gt="3.1.2";var Wt={initialize:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Ot.deprecated("default export","named LDClient export")),Jt(e,t,n)},version:Gt};export{zt as basicLogger,Bt as createConsoleLogger,Wt as default,Jt as initialize,Gt as version};
//# sourceMappingURL=ldclient.es.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LDClient={})}(this,(function(e){"use strict";function t(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return t.prototype=new Error,t.prototype.name=e,t.prototype.constructor=t,t}const n=t("LaunchDarklyUnexpectedResponseError"),r=t("LaunchDarklyInvalidEnvironmentIdError"),o=t("LaunchDarklyInvalidUserError"),i=t("LaunchDarklyInvalidEventKeyError"),a=t("LaunchDarklyInvalidArgumentError"),s=t("LaunchDarklyFlagFetchError");for(var c={LDUnexpectedResponseError:n,LDInvalidEnvironmentIdError:r,LDInvalidUserError:o,LDInvalidEventKeyError:i,LDInvalidArgumentError:a,LDInvalidDataError:t("LaunchDarklyInvalidDataError"),LDFlagFetchError:s,isHttpErrorRecoverable:function(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}},u=function(e){var t=y(e),n=t[0],r=t[1];return 3*(n+r)/4-r},l=function(e){var t,n,r=y(e),o=r[0],i=r[1],a=new v(function(e,t,n){return 3*(t+n)/4-n}(0,o,i)),s=0,c=i>0?o-4:o;for(n=0;n<c;n+=4)t=g[e.charCodeAt(n)]<<18|g[e.charCodeAt(n+1)]<<12|g[e.charCodeAt(n+2)]<<6|g[e.charCodeAt(n+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=255&t;2===i&&(t=g[e.charCodeAt(n)]<<2|g[e.charCodeAt(n+1)]>>4,a[s++]=255&t);1===i&&(t=g[e.charCodeAt(n)]<<10|g[e.charCodeAt(n+1)]<<4|g[e.charCodeAt(n+2)]>>2,a[s++]=t>>8&255,a[s++]=255&t);return a},d=function(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(w(e,a,a+i>s?s:a+i));1===r?(t=e[n-1],o.push(f[t>>2]+f[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],o.push(f[t>>10]+f[t>>4&63]+f[t<<2&63]+"="));return o.join("")},f=[],g=[],v="undefined"!=typeof Uint8Array?Uint8Array:Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m=0,h=p.length;m<h;++m)f[m]=p[m],g[p.charCodeAt(m)]=m;function y(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function w(e,t,n){for(var r,o,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(f[(o=r)>>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}g["-".charCodeAt(0)]=62,g["_".charCodeAt(0)]=63;var b={byteLength:u,toByteArray:l,fromByteArray:d},k=Array.isArray,E=Object.keys,D=Object.prototype.hasOwnProperty,C=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i,a=k(t),s=k(n);if(a&&s){if((o=t.length)!=n.length)return!1;for(r=o;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(a!=s)return!1;var c=t instanceof Date,u=n instanceof Date;if(c!=u)return!1;if(c&&u)return t.getTime()==n.getTime();var l=t instanceof RegExp,d=n instanceof RegExp;if(l!=d)return!1;if(l&&d)return t.toString()==n.toString();var f=E(t);if((o=f.length)!==E(n).length)return!1;for(r=o;0!=r--;)if(!D.call(n,f[r]))return!1;for(r=o;0!=r--;)if(!e(t[i=f[r]],n[i]))return!1;return!0}return t!=t&&n!=n};const x=["key","ip","country","email","firstName","lastName","avatar","name"];function P(e){const t=unescape(encodeURIComponent(e));return b.fromByteArray(function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}(t))}function S(e){return P(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function I(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var O,L={appendUrlPath:function(e,t){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(t.startsWith("/")?"":"/")+t},base64URLEncode:S,btoa:P,chunkEventsForUrl:function(e,t){const n=t.slice(0),r=[];let o,i=e;for(;n.length>0;){for(o=[];i>0;){const e=n.shift();if(!e)break;i-=S(JSON.stringify(e)).length,i<0&&o.length>0?n.unshift(e):o.push(e)}i=e,r.push(o)}return r},clone:function(e){return JSON.parse(JSON.stringify(e))},deepEquals:function(e,t){return C(e,t)},extend:function(...e){return e.reduce(((e,t)=>({...e,...t})),{})},getLDUserAgentString:function(e){const t=e.version||"?";return e.userAgent+"/"+t},objectHasOwnProperty:I,onNextTick:function(e){setTimeout(e,0)},sanitizeContext:function(e){if(!e)return e;let t;return null!==e.kind&&void 0!==e.kind||x.forEach((n=>{const r=e[n];void 0!==r&&"string"!=typeof r&&(t=t||{...e},t[n]=String(r))})),t||e},transformValuesToVersionedValues:function(e){const t={};for(const n in e)I(e,n)&&(t[n]={value:e[n],version:0});return t},transformVersionedValuesToValues:function(e){const t={};for(const n in e)I(e,n)&&(t[n]=e[n].value);return t},wrapPromiseCallback:function(e,t){const n=e.then((e=>(t&&setTimeout((()=>{t(null,e)}),0),e)),(e=>{if(!t)return Promise.reject(e);setTimeout((()=>{t(e,null)}),0)}));return t?void 0:n}},T=new Uint8Array(16);function U(){if(!O&&!(O="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return O(T)}var R=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function A(e){return"string"==typeof e&&R.test(e)}for(var j,F,N=[],$=0;$<256;++$)N.push(($+256).toString(16).substr(1));function V(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(N[e[t+0]]+N[e[t+1]]+N[e[t+2]]+N[e[t+3]]+"-"+N[e[t+4]]+N[e[t+5]]+"-"+N[e[t+6]]+N[e[t+7]]+"-"+N[e[t+8]]+N[e[t+9]]+"-"+N[e[t+10]]+N[e[t+11]]+N[e[t+12]]+N[e[t+13]]+N[e[t+14]]+N[e[t+15]]).toLowerCase();if(!A(n))throw TypeError("Stringified UUID is invalid");return n}var H=0,M=0;function q(e){if(!A(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}var K="6ba7b810-9dad-11d1-80b4-00c04fd430c8",_="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function z(e,t,n){function r(e,r,o,i){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=q(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+e.length);if(a.set(r),a.set(e,r.length),(a=n(a))[6]=15&a[6]|t,a[8]=63&a[8]|128,o){i=i||0;for(var s=0;s<16;++s)o[i+s]=a[s];return o}return V(a)}try{r.name=e}catch(e){}return r.DNS=K,r.URL=_,r}function J(e){return 14+(e+64>>>9<<4)+1}function B(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function G(e,t,n,r,o,i){return B((a=B(B(t,e),B(r,i)))<<(s=o)|a>>>32-s,n);var a,s}function W(e,t,n,r,o,i,a){return G(t&n|~t&r,e,t,o,i,a)}function X(e,t,n,r,o,i,a){return G(t&r|n&~r,e,t,o,i,a)}function Q(e,t,n,r,o,i,a){return G(t^n^r,e,t,o,i,a)}function Y(e,t,n,r,o,i,a){return G(n^(t|~r),e,t,o,i,a)}var Z=z("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,r="0123456789abcdef",o=0;o<n;o+=8){var i=e[o>>5]>>>o%32&255,a=parseInt(r.charAt(i>>>4&15)+r.charAt(15&i),16);t.push(a)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[J(t)-1]=t;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,a=0;a<e.length;a+=16){var s=n,c=r,u=o,l=i;n=W(n,r,o,i,e[a],7,-680876936),i=W(i,n,r,o,e[a+1],12,-389564586),o=W(o,i,n,r,e[a+2],17,606105819),r=W(r,o,i,n,e[a+3],22,-1044525330),n=W(n,r,o,i,e[a+4],7,-176418897),i=W(i,n,r,o,e[a+5],12,1200080426),o=W(o,i,n,r,e[a+6],17,-1473231341),r=W(r,o,i,n,e[a+7],22,-45705983),n=W(n,r,o,i,e[a+8],7,1770035416),i=W(i,n,r,o,e[a+9],12,-1958414417),o=W(o,i,n,r,e[a+10],17,-42063),r=W(r,o,i,n,e[a+11],22,-1990404162),n=W(n,r,o,i,e[a+12],7,1804603682),i=W(i,n,r,o,e[a+13],12,-40341101),o=W(o,i,n,r,e[a+14],17,-1502002290),n=X(n,r=W(r,o,i,n,e[a+15],22,1236535329),o,i,e[a+1],5,-165796510),i=X(i,n,r,o,e[a+6],9,-1069501632),o=X(o,i,n,r,e[a+11],14,643717713),r=X(r,o,i,n,e[a],20,-373897302),n=X(n,r,o,i,e[a+5],5,-701558691),i=X(i,n,r,o,e[a+10],9,38016083),o=X(o,i,n,r,e[a+15],14,-660478335),r=X(r,o,i,n,e[a+4],20,-405537848),n=X(n,r,o,i,e[a+9],5,568446438),i=X(i,n,r,o,e[a+14],9,-1019803690),o=X(o,i,n,r,e[a+3],14,-187363961),r=X(r,o,i,n,e[a+8],20,1163531501),n=X(n,r,o,i,e[a+13],5,-1444681467),i=X(i,n,r,o,e[a+2],9,-51403784),o=X(o,i,n,r,e[a+7],14,1735328473),n=Q(n,r=X(r,o,i,n,e[a+12],20,-1926607734),o,i,e[a+5],4,-378558),i=Q(i,n,r,o,e[a+8],11,-2022574463),o=Q(o,i,n,r,e[a+11],16,1839030562),r=Q(r,o,i,n,e[a+14],23,-35309556),n=Q(n,r,o,i,e[a+1],4,-1530992060),i=Q(i,n,r,o,e[a+4],11,1272893353),o=Q(o,i,n,r,e[a+7],16,-155497632),r=Q(r,o,i,n,e[a+10],23,-1094730640),n=Q(n,r,o,i,e[a+13],4,681279174),i=Q(i,n,r,o,e[a],11,-358537222),o=Q(o,i,n,r,e[a+3],16,-722521979),r=Q(r,o,i,n,e[a+6],23,76029189),n=Q(n,r,o,i,e[a+9],4,-640364487),i=Q(i,n,r,o,e[a+12],11,-421815835),o=Q(o,i,n,r,e[a+15],16,530742520),n=Y(n,r=Q(r,o,i,n,e[a+2],23,-995338651),o,i,e[a],6,-198630844),i=Y(i,n,r,o,e[a+7],10,1126891415),o=Y(o,i,n,r,e[a+14],15,-1416354905),r=Y(r,o,i,n,e[a+5],21,-57434055),n=Y(n,r,o,i,e[a+12],6,1700485571),i=Y(i,n,r,o,e[a+3],10,-1894986606),o=Y(o,i,n,r,e[a+10],15,-1051523),r=Y(r,o,i,n,e[a+1],21,-2054922799),n=Y(n,r,o,i,e[a+8],6,1873313359),i=Y(i,n,r,o,e[a+15],10,-30611744),o=Y(o,i,n,r,e[a+6],15,-1560198380),r=Y(r,o,i,n,e[a+13],21,1309151649),n=Y(n,r,o,i,e[a+4],6,-145523070),i=Y(i,n,r,o,e[a+11],10,-1120210379),o=Y(o,i,n,r,e[a+2],15,718787259),r=Y(r,o,i,n,e[a+9],21,-343485551),n=B(n,s),r=B(r,c),o=B(o,u),i=B(i,l)}return[n,r,o,i]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(J(t)),r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))})),ee=Z;function te(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function ne(e,t){return e<<t|e>>>32-t}var re=z("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var o=0;o<r.length;++o)e.push(r.charCodeAt(o))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var i=e.length/4+2,a=Math.ceil(i/16),s=new Array(a),c=0;c<a;++c){for(var u=new Uint32Array(16),l=0;l<16;++l)u[l]=e[64*c+4*l]<<24|e[64*c+4*l+1]<<16|e[64*c+4*l+2]<<8|e[64*c+4*l+3];s[c]=u}s[a-1][14]=8*(e.length-1)/Math.pow(2,32),s[a-1][14]=Math.floor(s[a-1][14]),s[a-1][15]=8*(e.length-1)&4294967295;for(var d=0;d<a;++d){for(var f=new Uint32Array(80),g=0;g<16;++g)f[g]=s[d][g];for(var v=16;v<80;++v)f[v]=ne(f[v-3]^f[v-8]^f[v-14]^f[v-16],1);for(var p=n[0],m=n[1],h=n[2],y=n[3],w=n[4],b=0;b<80;++b){var k=Math.floor(b/20),E=ne(p,5)+te(k,m,h,y)+w+t[k]+f[b]>>>0;w=y,y=h,h=ne(m,30)>>>0,m=p,p=E}n[0]=n[0]+p>>>0,n[1]=n[1]+m>>>0,n[2]=n[2]+h>>>0,n[3]=n[3]+y>>>0,n[4]=n[4]+w>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]})),oe=re;var ie=Object.freeze({__proto__:null,v1:function(e,t,n){var r=t&&n||0,o=t||new Array(16),i=(e=e||{}).node||j,a=void 0!==e.clockseq?e.clockseq:F;if(null==i||null==a){var s=e.random||(e.rng||U)();null==i&&(i=j=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==a&&(a=F=16383&(s[6]<<8|s[7]))}var c=void 0!==e.msecs?e.msecs:Date.now(),u=void 0!==e.nsecs?e.nsecs:M+1,l=c-H+(u-M)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||c>H)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");H=c,M=u,F=a;var d=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;o[r++]=d>>>24&255,o[r++]=d>>>16&255,o[r++]=d>>>8&255,o[r++]=255&d;var f=c/4294967296*1e4&268435455;o[r++]=f>>>8&255,o[r++]=255&f,o[r++]=f>>>24&15|16,o[r++]=f>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var g=0;g<6;++g)o[r+g]=i[g];return t||V(o)},v3:ee,v4:function(e,t,n){var r=(e=e||{}).random||(e.rng||U)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=r[o];return t}return V(r)},v5:oe,NIL:"00000000-0000-0000-0000-000000000000",version:function(e){if(!A(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)},validate:A,stringify:V,parse:q});const ae=["debug","info","warn","error","none"];var se={commonBasicLogger:function(e,t){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(e){return function(t){console&&console[e]&&console[e].call(console,t)}}const r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],o=!(!e||!e.destination),i=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ";let a=1;if(e&&e.level)for(let t=0;t<ae.length;t++)ae[t]===e.level&&(a=t);function s(e,n,a){if(a.length<1)return;let s;const c=o?n+": "+i:i;if(1!==a.length&&t){const e=[...a];e[0]=c+e[0],s=t(...e)}else s=c+a[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}const c={};for(let e=0;e<ae.length;e++){const t=ae[e];if("none"!==t)if(e<a)c[t]=()=>{};else{const n=e;c[t]=function(){s(n,t,arguments)}}}return c},validateLogger:function(e){ae.forEach((t=>{if("none"!==t&&(!e[t]||"function"!=typeof e[t]))throw new Error("Provided logger instance must support logger."+t+"(...) method")}))}};function ce(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}const ue=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.";var le={bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},bootstrapOldFormat:function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+ue},clientInitialized:function(){return"LaunchDarkly client initialized"},clientNotReady:function(){return"LaunchDarkly client is not ready"},debugEnqueueingEvent:function(e){return'enqueueing "'+e+'" event'},debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},debugPostingEvents:function(e){return"sending "+e+" events"},debugStreamDelete:function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored:function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugStreamPatch:function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored:function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamPing:function(){return"received ping message from stream"},debugPolling:function(e){return"polling for feature flags at "+e},debugStreamPut:function(){return"received streaming update for all flags"},deprecated:function(e,t){return t?'"'+e+'" is deprecated, please use "'+t+'"':'"'+e+'" is deprecated'},environmentNotFound:function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+ue},environmentNotSpecified:function(){return"No environment/client-side ID was specified."+ue},errorFetchingFlags:function(e){return"Error fetching flag settings: "+ce(e)},eventCapacityExceeded:function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutContext:function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},httpErrorMessage:function(e,t,n){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+t+" - "+(c.isHttpErrorRecoverable(e)?n:"giving up permanently")},httpUnavailable:function(){return"Cannot make HTTP requests in this environment."+ue},identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},inspectorMethodError:(e,t)=>`an inspector: "${t}" of type: "${e}" generated an exception`,invalidContentType:function(e){return'Expected application/json content type but got "'+e+'"'},invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},invalidInspector:(e,t)=>`an inspector: "${t}" of an invalid type (${e}) was configured`,invalidKey:function(){return"Event key must be a string"},invalidContext:function(){return"Invalid context specified."+ue},invalidTagValue:e=>`Config option "${e}" must only contain letters, numbers, ., _ or -.`,localStorageUnavailable:function(e){return"local storage is unavailable: "+ce(e)},networkError:e=>"network error"+(e?" ("+e+")":""),optionBelowMinimum:(e,t,n)=>'Config option "'+e+'" was set to '+t+", changing to minimum value of "+n,streamClosing:function(){return"Closing stream connection"},streamConnecting:function(e){return"Opening stream connection to "+e},streamError:function(e,t){return"Error on stream connection: "+ce(e)+", will continue retrying after "+t+" milliseconds."},tagValueTooLong:e=>`Value of "${e}" was longer than 64 characters and was discarded.`,unknownCustomEventKey:function(e){return'Custom event "'+e+'" does not exist'},unknownOption:e=>'Ignoring unknown config option "'+e+'"',contextNotSpecified:function(){return"No context specified."+ue},unrecoverableStreamError:e=>`Error on stream connection ${ce(e)}, giving up permanently`,wrongOptionType:(e,t,n)=>'Config option "'+e+'" should be of type '+t+", got "+n+", using default value",wrongOptionTypeBoolean:(e,t)=>'Config option "'+e+'" should be a boolean, got '+t+", converting to boolean"};const{validateLogger:de}=se,fe={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"},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},privateAttributes:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},application:{validator:function(e,t,n){const r={};t.id&&(r.id=pe(`${e}.id`,t.id,n));t.version&&(r.version=pe(`${e}.version`,t.version,n));return r}},inspectors:{default:[]}},ge=/^(\w|\.|-)+$/;function ve(e){return e&&e.replace(/\/+$/,"")}function pe(e,t,n){if("string"==typeof t&&t.match(ge)){if(!(t.length>64))return t;n.warn(le.tagValueTooLong(e))}else n.warn(le.invalidTagValue(e))}var me={baseOptionDefs:fe,validate:function(e,t,n,r){const o=L.extend({logger:{default:r}},fe,n),i={};function a(e){L.onNextTick((()=>{t&&t.maybeReportError(new c.LDInvalidArgumentError(e))}))}let s=L.extend({},e||{});return function(e){const t=e;Object.keys(i).forEach((e=>{if(void 0!==t[e]){const n=i[e];r&&r.warn(le.deprecated(e,n)),n&&(void 0===t[n]&&(t[n]=t[e]),delete t[e])}}))}(s),s=function(e){const t=L.extend({},e);return Object.keys(o).forEach((e=>{void 0!==t[e]&&null!==t[e]||(t[e]=o[e]&&o[e].default)})),t}(s),s=function(e){const t=L.extend({},e),n=e=>{if(null===e)return"any";if(void 0===e)return;if(Array.isArray(e))return"array";const t=typeof e;return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"};return Object.keys(e).forEach((i=>{const s=e[i];if(null!=s){const c=o[i];if(void 0===c)a(le.unknownOption(i));else{const o=c.type||n(c.default),u=c.validator;if(u){const n=u(i,e[i],r);void 0!==n?t[i]=n:delete t[i]}else if("any"!==o){const e=o.split("|"),r=n(s);e.indexOf(r)<0?"boolean"===o?(t[i]=!!s,a(le.wrongOptionTypeBoolean(i,r))):(a(le.wrongOptionType(i,o,r)),t[i]=c.default):"number"===r&&void 0!==c.minimum&&s<c.minimum&&(a(le.optionBelowMinimum(i,s,c.minimum)),t[i]=c.minimum)}}}})),t.baseUrl=ve(t.baseUrl),t.streamUrl=ve(t.streamUrl),t.eventsUrl=ve(t.eventsUrl),t}(s),de(s.logger),s},getTags:function(e){const t={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(t["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(t["application-version"]=[e.application.version])),t}};const{getLDUserAgentString:he}=L;var ye={getLDHeaders:function(e,t){if(t&&!t.sendLDHeaders)return{};const n={};n[e.userAgentHeaderName||"User-Agent"]=he(e),t&&t.wrapperName&&(n["X-LaunchDarkly-Wrapper"]=t.wrapperVersion?t.wrapperName+"/"+t.wrapperVersion:t.wrapperName);const r=me.getTags(t),o=Object.keys(r);return o.length&&(n["x-launchdarkly-tags"]=o.sort().map((e=>Array.isArray(r[e])?r[e].sort().map((t=>`${e}/${t}`)):[`${e}/${r[e]}`])).reduce(((e,t)=>e.concat(t)),[]).join(" ")),n},transformHeaders:function(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform({...e}):e}};const{v1:we}=ie,{getLDHeaders:be,transformHeaders:ke}=ye,Ee=2e3;var De=function(e,t,n){const r="/a/"+t+".gif",o=L.extend({"Content-Type":"application/json"},be(e,n)),i=e.httpFallbackPing,a={};return a.sendChunk=(t,a,s,u)=>{const l=JSON.stringify(t),d=s?null:we();return u?function t(r){const i=s?o:L.extend({},o,{"X-LaunchDarkly-Event-Schema":"4","X-LaunchDarkly-Payload-ID":d});return e.httpRequest("POST",a,ke(i,n),l).promise.then((e=>{if(e)return e.status>=400&&c.isHttpErrorRecoverable(e.status)&&r?t(!1):function(e){const t={status:e.status},n=e.header("date");if(n){const e=Date.parse(n);e&&(t.serverTime=e)}return t}(e)})).catch((()=>r?t(!1):Promise.reject()))}(!0).catch((()=>{})):(i&&i(a+r+"?d="+L.base64URLEncode(l)),Promise.resolve())},a.sendEvents=function(t,n,r){if(!e.httpRequest)return Promise.resolve();const o=e.httpAllowsPost();let i;i=o?[t]:L.chunkEventsForUrl(Ee-n.length,t);const s=[];for(let e=0;e<i.length;e++)s.push(a.sendChunk(i[e],n,r,o));return Promise.all(s)},a};const{commonBasicLogger:Ce}=se;function xe(e){return"string"==typeof e&&"kind"!==e&&e.match(/^(\w|\.|-)+$/)}function Pe(e){return e.includes("%")||e.includes(":")?e.replace(/%/g,"%25").replace(/:/g,"%3A"):e}var Se={checkContext:function(e,t){if(e){if(t&&(void 0===e.kind||null===e.kind))return void 0!==e.key&&null!==e.key;const n=e.key,r=void 0===e.kind?"user":e.kind,o=xe(r),i="multi"===r||null!=n&&""!==n;if("multi"===r){const t=Object.keys(e).filter((e=>"kind"!==e));return i&&t.every((e=>xe(e)))&&t.every((t=>{const n=e[t].key;return null!=n&&""!==n}))}return i&&o}return!1},getContextKeys:function(e,t=Ce()){if(!e)return;const n={},{kind:r,key:o}=e;switch(r){case void 0:n.user=`${o}`;break;case"multi":Object.entries(e).filter((([e])=>"kind"!==e)).forEach((([e,t])=>{t&&t.key&&(n[e]=t.key)}));break;case null:t.warn(`null is not a valid context kind: ${e}`);break;case"":t.warn(`'' is not a valid context kind: ${e}`);break;default:n[r]=`${o}`}return n},getContextKinds:function(e){return e?null===e.kind||void 0===e.kind?["user"]:"multi"!==e.kind?[e.kind]:Object.keys(e).filter((e=>"kind"!==e)):[]},getCanonicalKey:function(e){if(e){if((void 0===e.kind||null===e.kind||"user"===e.kind)&&e.key)return e.key;if("multi"!==e.kind&&e.key)return`${e.kind}:${Pe(e.key)}`;if("multi"===e.kind)return Object.keys(e).sort().filter((e=>"kind"!==e)).map((t=>`${t}:${Pe(e[t].key)}`)).join(":")}}};const{getContextKinds:Ie}=Se;var Oe=function(){const e={};let t=0,n=0,r={},o={};return e.summarizeEvent=e=>{if("feature"===e.kind){const i=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),a=r[i];let s=o[e.key];s||(s=new Set,o[e.key]=s),function(e){return e.context?Ie(e.context):e.contextKeys?Object.keys(e.contextKeys):[]}(e).forEach((e=>s.add(e))),a?a.count=a.count+1:r[i]={count:1,key:e.key,version:e.version,variation:e.variation,value:e.value,default:e.default},(0===t||e.creationDate<t)&&(t=e.creationDate),e.creationDate>n&&(n=e.creationDate)}},e.getSummary=()=>{const e={};let i=!0;for(const t of Object.values(r)){let n=e[t.key];n||(n={default:t.default,counters:[],contextKinds:[...o[t.key]]},e[t.key]=n);const r={value:t.value,count:t.count};void 0!==t.variation&&null!==t.variation&&(r.variation=t.variation),void 0!==t.version&&null!==t.version?r.version=t.version:r.unknown=!0,n.counters.push(r),i=!1}return i?null:{startDate:t,endDate:n,features:e}},e.clearSummary=()=>{t=0,n=0,r={},o={}},e};function Le(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Te(e){return(e.startsWith("/")?e.substring(1):e).split("/").map((e=>e.indexOf("~")>=0?e.replace(/~1/g,"/").replace(/~0/g,"~"):e))}function Ue(e){return!e.startsWith("/")}function Re(e,t){const n=Ue(e),r=Ue(t);if(n&&r)return e===t;if(n){const n=Te(t);return 1===n.length&&e===n[0]}if(r){const n=Te(e);return 1===n.length&&t===n[0]}return e===t}function Ae(e){return`/${Le(e)}`}var je={cloneExcluding:function(e,t){const n=[],r={},o=[];for(n.push(...Object.keys(e).map((t=>({key:t,ptr:Ae(t),source:e,parent:r,visited:[e]}))));n.length;){const e=n.pop();if(t.some((t=>Re(t,e.ptr))))o.push(e.ptr);else{const t=e.source[e.key];if(null===t)e.parent[e.key]=t;else if(Array.isArray(t))e.parent[e.key]=[...t];else if("object"==typeof t){if(e.visited.includes(t))continue;e.parent[e.key]={},n.push(...Object.keys(t).map((n=>{return{key:n,ptr:(r=e.ptr,o=Le(n),`${r}/${o}`),source:t,parent:e.parent[e.key],visited:[...e.visited,t]};var r,o})))}else e.parent[e.key]=t}}return{cloned:r,excluded:o.sort()}},compare:Re,literalToReference:Ae};var Fe=function(e){const t={},n=e.allAttributesPrivate,r=e.privateAttributes||[],o=["key","kind","_meta","anonymous"],i=["name","ip","firstName","lastName","email","avatar","country"],a=e=>{if("object"!=typeof e||null===e||Array.isArray(e))return;const{cloned:t,excluded:i}=je.cloneExcluding(e,(e=>(n?Object.keys(e):[...r,...e._meta&&e._meta.privateAttributes||[]]).filter((e=>!o.some((t=>je.compare(e,t))))))(e));return t.key=String(t.key),i.length&&(t._meta||(t._meta={}),t._meta.redactedAttributes=i),t._meta&&(delete t._meta.privateAttributes,0===Object.keys(t._meta).length&&delete t._meta),void 0!==t.anonymous&&(t.anonymous=!!t.anonymous),t};return t.filter=e=>void 0===e.kind||null===e.kind?a((e=>{const t={...e.custom||{},kind:"user",key:e.key};void 0!==e.anonymous&&(t.anonymous=!!e.anonymous);for(const n of i)delete t[n],void 0!==e[n]&&null!==e[n]&&(t[n]=String(e[n]));return void 0!==e.privateAttributeNames&&null!==e.privateAttributeNames&&(t._meta=t._meta||{},t._meta.privateAttributes=e.privateAttributeNames.map((e=>e.startsWith("/")?je.literalToReference(e):e))),t})(e)):"multi"===e.kind?(e=>{const t={kind:e.kind},n=Object.keys(e);for(const r of n)if("kind"!==r){const n=a(e[r]);n&&(t[r]=n)}return t})(e):a(e),t};const{getContextKeys:Ne}=Se;var $e=function(e,t,n,r=null,o=null,i=null){const a={},s=i||De(e,n,t),u=L.appendUrlPath(t.eventsUrl,"/events/bulk/"+n),l=Oe(),d=Fe(t),f=t.samplingInterval,g=t.eventCapacity,v=t.flushInterval,p=t.logger;let m,h=[],y=0,w=!1,b=!1;function k(){return 0===f||0===Math.floor(Math.random()*f)}function E(e){const t=L.extend({},e);return"identify"===e.kind?t.context=d.filter(e.context):(t.contextKeys=Ne(e.context,p),delete t.context),"feature"===e.kind&&(delete t.trackEvents,delete t.debugEventsUntilDate),t}function D(e){h.length<g?(h.push(e),b=!1):(b||(b=!0,p.warn(le.eventCapacityExceeded())),r&&r.incrementDroppedEvents())}return a.enqueue=function(e){if(w)return;let t=!1,n=!1;var r;if(l.summarizeEvent(e),"feature"===e.kind?k()&&(t=!!e.trackEvents,n=!!(r=e).debugEventsUntilDate&&r.debugEventsUntilDate>y&&r.debugEventsUntilDate>(new Date).getTime()):t=k(),t&&D(E(e)),n){const t=L.extend({},e,{kind:"debug"});t.context=d.filter(t.context),delete t.trackEvents,delete t.debugEventsUntilDate,D(t)}},a.flush=function(){if(w)return Promise.resolve();const e=h,t=l.getSummary();return l.clearSummary(),t&&(t.kind="summary",e.push(t)),r&&r.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(h=[],p.debug(le.debugPostingEvents(e.length)),s.sendEvents(e,u).then((e=>{const t=e&&e[0];t&&(t.serverTime&&(y=t.serverTime),c.isHttpErrorRecoverable(t.status)||(w=!0),t.status>=400&&L.onNextTick((()=>{o.maybeReportError(new c.LDUnexpectedResponseError(le.httpErrorMessage(t.status,"event posting","some events were dropped")))})))})))},a.start=function(){const e=()=>{a.flush(),m=setTimeout(e,v)};m=setTimeout(e,v)},a.stop=function(){clearTimeout(m)},a};var Ve=function(e){const t={},n={};return t.on=function(e,t,r){n[e]=n[e]||[],n[e]=n[e].concat({handler:t,context:r})},t.off=function(e,t,r){if(n[e])for(let o=0;o<n[e].length;o++)n[e][o].handler===t&&n[e][o].context===r&&(n[e]=n[e].slice(0,o).concat(n[e].slice(o+1)))},t.emit=function(e){if(!n[e])return;const t=n[e].slice(0);for(let e=0;e<t.length;e++)t[e].handler.apply(t[e].context,Array.prototype.slice.call(arguments,1))},t.getEvents=function(){return Object.keys(n)},t.getEventListenerCount=function(e){return n[e]?n[e].length:0},t.maybeReportError=function(t){t&&(n["error"]?this.emit("error",t):(e||console).error(t.message))},t};const He="ready",Me="initialized",qe="failed";var Ke=function(e){let t=!1,n=!1,r=null,o=null;const i=new Promise((t=>{const n=()=>{e.off(He,n),t()};e.on(He,n)})).catch((()=>{}));return{getInitializationPromise:()=>o||(t?Promise.resolve():n?Promise.reject(r):(o=new Promise(((t,n)=>{const r=()=>{e.off(Me,r),t()},o=t=>{e.off(qe,o),n(t)};e.on(Me,r),e.on(qe,o)})),o)),getReadyPromise:()=>i,signalSuccess:()=>{t||n||(t=!0,e.emit(Me),e.emit(He))},signalFailure:o=>{t||n||(n=!0,r=o,e.emit(qe,o),e.emit(He)),e.maybeReportError(o)}}};var _e=function(e,t,n,r){const o={};function i(){let e="";const o=r.getContext();return o&&(e=n||L.btoa(JSON.stringify(o))),"ld:"+t+":"+e}return o.loadFlags=()=>e.get(i()).then((e=>{if(null==e)return null;try{let t=JSON.parse(e);if(t){const e=t.$schema;void 0===e||e<1?t=L.transformValuesToVersionedValues(t):delete t.$schema}return t}catch(e){return o.clearFlags().then((()=>null))}})),o.saveFlags=t=>{const n=L.extend({},t,{$schema:1});return e.set(i(),JSON.stringify(n))},o.clearFlags=()=>e.clear(i()),o};var ze=function(e,t){const n={};let r=!1;const o=e=>{r||(r=!0,t.warn(le.localStorageUnavailable(e)))};return n.isEnabled=()=>!!e,n.get=t=>new Promise((n=>{e?e.get(t).then(n).catch((e=>{o(e),n(void 0)})):n(void 0)})),n.set=(t,n)=>new Promise((r=>{e?e.set(t,n).then((()=>r(!0))).catch((e=>{o(e),r(!1)})):r(!1)})),n.clear=t=>new Promise((n=>{e?e.clear(t).then((()=>n(!0))).catch((e=>{o(e),n(!1)})):n(!1)})),n};const{appendUrlPath:Je,base64URLEncode:Be,objectHasOwnProperty:Ge}=L,{getLDHeaders:We,transformHeaders:Xe}=ye,{isHttpErrorRecoverable:Qe}=c,Ye=3e5,Ze=3e4,et=.5;var tt=function(e,t,n,r){const o=t.streamUrl,i=t.logger,a={},s=Je(o,"/eval/"+n),c=t.useReport,u=t.evaluationReasons,l=t.streamReconnectDelay,d=We(e,t);let f,g=!1,v=null,p=null,m=null,h=null,y=null,w=0;function b(){const e=(t=function(){const e=l*Math.pow(2,w);return e>Ze?Ze:e}(),t-Math.trunc(Math.random()*et*t));var t;return w+=1,e}function k(e){if(e.status&&"number"==typeof e.status&&!Qe(e.status))return C(),i.error(le.unrecoverableStreamError(e)),void(p&&(clearTimeout(p),p=null));const t=b();g||(i.warn(le.streamError(e,t)),g=!0),x(!1),C(),E(t)}function E(e){p||(e?p=setTimeout(D,e):D())}function D(){let r;p=null;let a="";const l={headers:d,readTimeoutMillis:Ye};if(e.eventSourceFactory){null!=h&&(a="h="+h),c?e.eventSourceAllowsReport?(r=s,l.method="REPORT",l.headers["Content-Type"]="application/json",l.body=JSON.stringify(m)):(r=Je(o,"/ping/"+n),a=""):r=s+"/"+Be(JSON.stringify(m)),l.headers=Xe(l.headers,t),u&&(a=a+(a?"&":"")+"withReasons=true"),r=r+(a?"?":"")+a,C(),i.info(le.streamConnecting(r)),f=(new Date).getTime(),v=e.eventSourceFactory(r,l);for(const e in y)Ge(y,e)&&v.addEventListener(e,y[e]);v.onerror=k,v.onopen=()=>{w=0}}}function C(){v&&(i.info(le.streamClosing()),v.close(),v=null)}function x(e){f&&r&&r.recordStreamInit(f,!e,(new Date).getTime()-f),f=null}return a.connect=function(e,t,n){m=e,h=t,y={};for(const e in n||{})y[e]=function(t){g=!1,x(!0),n[e]&&n[e](t)};E()},a.disconnect=function(){clearTimeout(p),p=null,C()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a};var nt=function(e){let t,n,r,o;const i={addPromise:(i,a)=>{t=i,n&&n(),n=a,i.then((n=>{t===i&&(r(n),e&&e())}),(n=>{t===i&&(o(n),e&&e())}))}};return i.resultPromise=new Promise(((e,t)=>{r=e,o=t})),i};const{transformHeaders:rt,getLDHeaders:ot}=ye,it="application/json";var at=function(e,t,n){const r=t.baseUrl,o=t.useReport,i=t.evaluationReasons,a=t.logger,s={},u={};function l(n,r){if(!e.httpRequest)return new Promise(((e,t)=>{t(new c.LDFlagFetchError(le.httpUnavailable()))}));const o=r?"REPORT":"GET",i=ot(e,t);r&&(i["Content-Type"]=it);let a=u[n];a||(a=nt((()=>{delete u[n]})),u[n]=a);const s=e.httpRequest(o,n,rt(i,t),r),l=s.promise.then((e=>{if(200===e.status){if(e.header("content-type")&&e.header("content-type").substring(0,it.length)===it)return JSON.parse(e.body);{const t=le.invalidContentType(e.header("content-type")||"");return Promise.reject(new c.LDFlagFetchError(t))}}return Promise.reject(function(e){return 404===e.status?new c.LDInvalidEnvironmentIdError(le.environmentNotFound()):new c.LDFlagFetchError(le.errorFetchingFlags(e.statusText||String(e.status)))}(e))}),(e=>Promise.reject(new c.LDFlagFetchError(le.networkError(e)))));return a.addPromise(l,(()=>{s.cancel&&s.cancel()})),a.resultPromise}return s.fetchJSON=function(e){return l(L.appendUrlPath(r,e),null)},s.fetchFlagSettings=function(e,t){let s,c,u,d="";return o?(c=[r,"/sdk/evalx/",n,"/context"].join(""),u=JSON.stringify(e)):(s=L.base64URLEncode(JSON.stringify(e)),c=[r,"/sdk/evalx/",n,"/contexts/",s].join("")),t&&(d="h="+t),i&&(d=d+(d?"&":"")+"withReasons=true"),c=c+(d?"?":"")+d,a.debug(le.debugPolling(c)),l(c,u)},s};var st=function(e,t){const n={};let r;return n.setContext=function(e){r=L.sanitizeContext(e),r&&t&&t(L.clone(r))},n.getContext=function(){return r?L.clone(r):null},e&&n.setContext(e),n};const{v1:ct}=ie,{getContextKinds:ut}=Se,lt="ld:$anonUserId";var dt=function(e){function t(e){return null==e||"user"===e?lt:`ld:$contextKey:${e}`}function n(n,r){return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?function(n){return e.get(t(n))}(n).then((o=>{if(o)return r.key=o,r;{const o=ct();return r.key=o,function(n,r){return e.set(t(r),n)}(o,n).then((()=>r))}})):Promise.reject(new c.LDInvalidUserError(le.invalidContext()))}this.processContext=e=>{if(!e)return Promise.reject(new c.LDInvalidUserError(le.contextNotSpecified()));const t=L.clone(e);if("multi"===e.kind){const e=ut(t);return Promise.all(e.map((e=>n(e,t[e])))).then((()=>t))}return n(e.kind,t)}};const{v1:ft}=ie,{baseOptionDefs:gt}=me,{appendUrlPath:vt}=L;var pt={DiagnosticId:function(e){const t={diagnosticId:ft()};return e&&(t.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),t},DiagnosticsAccumulator:function(e){let t,n,r,o;function i(e){t=e,n=0,r=0,o=[]}return i(e),{getProps:()=>({dataSinceDate:t,droppedEvents:n,eventsInLastBatch:r,streamInits:o}),setProps:e=>{t=e.dataSinceDate,n=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:()=>{n++},setEventsInLastBatch:e=>{r=e},recordStreamInit:(e,t,n)=>{const r={timestamp:e,failed:t,durationMillis:n};o.push(r)},reset:i}},DiagnosticsManager:function(e,t,n,r,o,i,a){const s=!!e.diagnosticUseCombinedEvent,c="ld:"+o+":$diagnostics",u=vt(i.eventsUrl,"/events/diagnostic/"+o),l=i.diagnosticRecordingInterval,d=n;let f,g,v=!!i.streaming;const p={};function m(){return{sdk:w(),configuration:b(),platform:e.diagnosticPlatformData}}function h(e){i.logger&&i.logger.debug(le.debugPostingDiagnosticEvent(e)),r.sendEvents(e,u,!0).then((()=>{})).catch((()=>{}))}function y(){h(function(){const e=(new Date).getTime();let t={kind:s?"diagnostic-combined":"diagnostic",id:a,creationDate:e,...d.getProps()};return s&&(t={...t,...m()}),d.reset(e),t}()),g=setTimeout(y,l),f=(new Date).getTime(),s&&function(){if(t.isEnabled()){const e={...d.getProps()};t.set(c,JSON.stringify(e))}}()}function w(){const t={...e.diagnosticSdkData};return i.wrapperName&&(t.wrapperName=i.wrapperName),i.wrapperVersion&&(t.wrapperVersion=i.wrapperVersion),t}function b(){return{customBaseURI:i.baseUrl!==gt.baseUrl.default,customStreamURI:i.streamUrl!==gt.streamUrl.default,customEventsURI:i.eventsUrl!==gt.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!v,allAttributesPrivate:!!i.allAttributesPrivate,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation}}return p.start=()=>{s?function(e){if(!t.isEnabled())return e(!1);t.get(c).then((t=>{if(t)try{const e=JSON.parse(t);d.setProps(e),f=e.dataSinceDate}catch(e){}e(!0)})).catch((()=>{e(!1)}))}((e=>{if(e){const e=(f||0)+l,t=(new Date).getTime();t>=e?y():g=setTimeout(y,e-t)}else 0===Math.floor(4*Math.random())?y():g=setTimeout(y,l)})):(h({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate,...m()}),g=setTimeout(y,l))},p.stop=()=>{g&&clearTimeout(g)},p.setStreaming=e=>{v=e},p}};var mt=function(e,t){let n=!1;const r={type:e.type,name:e.name,method:(...o)=>{try{e.method(...o)}catch{n||(n=!0,t.warn(le.inspectorMethodError(r.type,r.name)))}}};return r};const{onNextTick:ht}=L,yt={flagUsed:"flag-used",flagDetailsChanged:"flag-details-changed",flagDetailChanged:"flag-detail-changed",clientIdentityChanged:"client-identity-changed"};Object.freeze(yt);var wt={InspectorTypes:yt,InspectorManager:function(e,t){const n={},r={[yt.flagUsed]:[],[yt.flagDetailsChanged]:[],[yt.flagDetailChanged]:[],[yt.clientIdentityChanged]:[]},o=e&&e.map((e=>mt(e,t)));return o&&o.forEach((e=>{Object.prototype.hasOwnProperty.call(r,e.type)?r[e.type].push(e):t.warn(le.invalidInspector(e.type,e.name))})),n.hasListeners=e=>r[e]&&r[e].length,n.onFlagUsed=(e,t,n)=>{r[yt.flagUsed].length&&ht((()=>{r[yt.flagUsed].forEach((r=>r.method(e,t,n)))}))},n.onFlags=e=>{r[yt.flagDetailsChanged].length&&ht((()=>{r[yt.flagDetailsChanged].forEach((t=>t.method(e)))}))},n.onFlagChanged=(e,t)=>{r[yt.flagDetailChanged].length&&ht((()=>{r[yt.flagDetailChanged].forEach((n=>n.method(e,t)))}))},n.onIdentityChanged=e=>{r[yt.clientIdentityChanged].length&&ht((()=>{r[yt.clientIdentityChanged].forEach((t=>t.method(e)))}))},n}};const{commonBasicLogger:bt}=se,{checkContext:kt,getContextKeys:Et}=Se,{InspectorTypes:Dt,InspectorManager:Ct}=wt,xt="change",Pt="internal-change";var St={initialize:function(e,t,n,r,o){const i=function(){if(n&&n.logger)return n.logger;return o&&o.logger&&o.logger.default||bt("warn")}(),a=Ve(i),s=Ke(a),u=me.validate(n,a,o,i),l=Ct(u.inspectors,i),d=u.sendEvents;let f=e,g=u.hash;const v=ze(r.localStorage,i),p=De(r,f,u),m=u.sendEvents&&!u.diagnosticOptOut,h=m?pt.DiagnosticId(f):null,y=m?pt.DiagnosticsAccumulator((new Date).getTime()):null,w=m?pt.DiagnosticsManager(r,v,y,p,f,u,h):null,b=tt(r,u,f,y),k=u.eventProcessor||$e(r,u,f,y,a,p),E=at(r,u,f);let D,C,x,P={},S=u.streaming,I=!1,O=!1,T=!0;const U=u.stateProvider,R=st(null,(function(e){(function(e){if(U)return;e&&F({kind:"identify",context:e,creationDate:(new Date).getTime()})})(e),l.hasListeners(Dt.clientIdentityChanged)&&l.onIdentityChanged(R.getContext())})),A=new dt(v),j=v.isEnabled()?_e(v,f,g,R):null;function F(e){f&&(U&&U.enqueueEvent&&U.enqueueEvent(e)||(e.context?(T=!1,!d||O||r.isDoNotTrack()||(i.debug(le.debugEnqueueingEvent(e.kind)),k.enqueue(e))):T&&(i.warn(le.eventWithoutContext()),T=!1)))}function N(e,t){l.hasListeners(Dt.flagDetailChanged)&&l.onFlagChanged(e.key,q(t))}function $(){l.hasListeners(Dt.flagDetailsChanged)&&l.onFlags(Object.entries(P).map((([e,t])=>({key:e,detail:q(t)}))).reduce(((e,t)=>(e[t.key]=t.detail,e)),{}))}function V(e,t,n,r){const o=R.getContext(),i=new Date,a={kind:"feature",key:e,context:o,value:t?t.value:null,variation:t?t.variationIndex:null,default:n,creationDate:i.getTime()},s=P[e];s&&(a.version=s.flagVersion?s.flagVersion:s.version,a.trackEvents=s.trackEvents,a.debugEventsUntilDate=s.debugEventsUntilDate),(r||s&&s.trackReason)&&t&&(a.reason=t.reason),F(a)}function H(e){return kt(e,!1)?Promise.resolve(e):Promise.reject(new c.LDInvalidUserError(le.invalidContext()))}function M(e,t,n,r,o){let i;if(P&&L.objectHasOwnProperty(P,e)&&P[e]&&!P[e].deleted){const n=P[e];i=q(n),null!==n.value&&void 0!==n.value||(i.value=t)}else i={value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return n&&V(e,i,t,r),o||function(e,t){l.hasListeners(Dt.flagUsed)&&l.onFlagUsed(e,t,R.getContext())}(e,i),i}function q(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function K(){if(C=!0,!R.getContext())return;const e=e=>{try{return JSON.parse(e)}catch(e){return void a.maybeReportError(new c.LDInvalidDataError(le.invalidData()))}};b.connect(R.getContext(),g,{ping:function(){i.debug(le.debugStreamPing());const e=R.getContext();E.fetchFlagSettings(e,g).then((t=>{L.deepEquals(e,R.getContext())&&z(t||{})})).catch((e=>{a.maybeReportError(new c.LDFlagFetchError(le.errorFetchingFlags(e)))}))},put:function(t){const n=e(t.data);n&&(i.debug(le.debugStreamPut()),z(n))},patch:function(t){const n=e(t.data);if(!n)return;const r=P[n.key];if(!r||!r.version||!n.version||r.version<n.version){i.debug(le.debugStreamPatch(n.key));const e={},t=L.extend({},n);delete t.key,P[n.key]=t;const o=q(t);e[n.key]=r?{previous:r.value,current:o}:{current:o},J(e),N(n,t)}else i.debug(le.debugStreamPatchIgnored(n.key))},delete:function(t){const n=e(t.data);if(n)if(!P[n.key]||P[n.key].version<n.version){i.debug(le.debugStreamDelete(n.key));const e={};P[n.key]&&!P[n.key].deleted&&(e[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},N(n,P[n.key]),J(e)}else i.debug(le.debugStreamDeleteIgnored(n.key))}})}function _(){C&&(b.disconnect(),C=!1)}function z(e){const t={};if(!e)return Promise.resolve();for(const n in P)L.objectHasOwnProperty(P,n)&&P[n]&&(e[n]&&!L.deepEquals(e[n].value,P[n].value)?t[n]={previous:P[n].value,current:q(e[n])}:e[n]&&!e[n].deleted||(t[n]={previous:P[n].value}));for(const n in e)L.objectHasOwnProperty(e,n)&&e[n]&&(!P[n]||P[n].deleted)&&(t[n]={current:q(e[n])});return P={...e},$(),J(t).catch((()=>{}))}function J(e){const t=Object.keys(e);if(t.length>0){const n={};t.forEach((t=>{const r=e[t].current,o=r?r.value:void 0,i=e[t].previous;a.emit(xt+":"+t,o,i),n[t]=r?{current:o,previous:i}:{previous:i}})),a.emit(xt,n),a.emit(Pt,P),u.sendEventsOnlyForVariation||U||t.forEach((t=>{V(t,e[t].current)}))}return D&&j?j.saveFlags(P):Promise.resolve()}function B(){const e=S||x&&void 0===S;e&&!C?K():!e&&C&&_(),w&&w.setStreaming(e)}function G(e){return e===xt||e.substr(0,xt.length+1)===xt+":"}if("string"==typeof u.bootstrap&&"LOCALSTORAGE"===u.bootstrap.toUpperCase()&&(j?D=!0:i.warn(le.localStorageUnavailable())),"object"==typeof u.bootstrap&&(P=function(e){const t=Object.keys(e),n="$flagsState",r="$valid",o=e[n];!o&&t.length&&i.warn(le.bootstrapOldFormat()),!1===e[r]&&i.warn(le.bootstrapInvalid());const a={};return t.forEach((t=>{if(t!==n&&t!==r){let n={value:e[t]};o&&o[t]?n=L.extend(n,o[t]):n.version=0,a[t]=n}})),a}(u.bootstrap)),U){const e=U.getInitialState();e?W(e):U.on("init",W),U.on("update",(function(e){e.context&&R.setContext(e.context);e.flags&&z(e.flags)}))}else(function(){if(!e)return Promise.reject(new c.LDInvalidEnvironmentIdError(le.environmentNotSpecified()));return A.processContext(t).then(H).then((e=>(R.setContext(e),"object"==typeof u.bootstrap?X():D?j.loadFlags().then((e=>null==e?(P={},E.fetchFlagSettings(R.getContext(),g).then((e=>z(e||{}))).then(X).catch((e=>{Q(new c.LDFlagFetchError(le.errorFetchingFlags(e)))}))):(P=e,L.onNextTick(X),E.fetchFlagSettings(R.getContext(),g).then((e=>z(e))).catch((e=>a.maybeReportError(e)))))):E.fetchFlagSettings(R.getContext(),g).then((e=>{P=e||{},$(),X()})).catch((e=>{P={},Q(e)})))))})().catch(Q);function W(e){f=e.environment,R.setContext(e.context),P={...e.flags},L.onNextTick(X)}function X(){i.info(le.clientInitialized()),I=!0,B(),s.signalSuccess()}function Q(e){s.signalFailure(e)}const Y={waitForInitialization:()=>s.getInitializationPromise(),waitUntilReady:()=>s.getReadyPromise(),identify:function(e,t,n){if(O)return L.wrapPromiseCallback(Promise.resolve({}),n);if(U)return i.warn(le.identifyDisabled()),L.wrapPromiseCallback(Promise.resolve(L.transformVersionedValuesToValues(P)),n);const r=D&&j?j.clearFlags():Promise.resolve();return L.wrapPromiseCallback(r.then((()=>A.processContext(e))).then(H).then((e=>E.fetchFlagSettings(e,t).then((n=>{const r=L.transformVersionedValuesToValues(n);return R.setContext(e),g=t,n?z(n).then((()=>r)):r})))).then((e=>(C&&K(),e))).catch((e=>(a.maybeReportError(e),Promise.reject(e)))),n)},getContext:function(){return R.getContext()},variation:function(e,t){return M(e,t,!0,!1,!1).value},variationDetail:function(e,t){return M(e,t,!0,!0,!1)},track:function(e,t,n){if("string"!=typeof e)return void a.maybeReportError(new c.LDInvalidEventKeyError(le.unknownCustomEventKey(e)));r.customEventFilter&&!r.customEventFilter(e)&&i.warn(le.unknownCustomEventKey(e));const o=R.getContext(),s={kind:"custom",key:e,context:o,url:r.getCurrentUrl(),creationDate:(new Date).getTime()};o&&o.anonymous&&(s.contextKind=o.anonymous?"anonymousUser":"user"),null!=t&&(s.data=t),null!=n&&(s.metricValue=n),F(s)},on:function(e,t,n){G(e)?(x=!0,I&&B(),a.on(e,t,n)):a.on(...arguments)},off:function(e){if(a.off(...arguments),G(e)){let e=!1;a.getEvents().forEach((t=>{G(t)&&a.getEventListenerCount(t)>0&&(e=!0)})),e||(x=!1,C&&void 0===S&&_())}},setStreaming:function(e){const t=null===e?void 0:e;t!==S&&(S=t,B())},flush:function(e){return L.wrapPromiseCallback(d?k.flush():Promise.resolve(),e)},allFlags:function(){const e={};if(!P)return e;for(const t in P)L.objectHasOwnProperty(P,t)&&!P[t].deleted&&(e[t]=M(t,null,!u.sendEventsOnlyForVariation,!1,!0).value);return e},close:function(e){if(O)return L.wrapPromiseCallback(Promise.resolve(),e);const t=()=>{O=!0,P={}},n=Promise.resolve().then((()=>{if(_(),w&&w.stop(),d)return k.stop(),k.flush()})).then(t).catch(t);return L.wrapPromiseCallback(n,e)}};return{client:Y,options:u,emitter:a,ident:R,logger:i,requestor:E,start:function(){d&&(w&&w.start(),k.start())},enqueueEvent:F,getFlagsInternal:function(){return P},getEnvironmentId:()=>f,internalChangeEventName:Pt}},commonBasicLogger:bt,errors:c,messages:le,utils:L,getContextKeys:Et},It=St.initialize,Ot=St.errors,Lt=St.messages,Tt=St.getContextKeys;function Ut(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Rt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ut(Object(n),!0).forEach((function(t){At(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ut(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function At(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var jt=St.commonBasicLogger;var Ft=function(e){return jt(Rt({destination:console.log},e))};var Nt={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function $t(e,t,n,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var t=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(t)return parseInt(t[2],10)<73}return!0}())return Nt;var i=new window.XMLHttpRequest;for(var a in i.open(e,t,!o),n||{})Object.prototype.hasOwnProperty.call(n,a)&&i.setRequestHeader(a,n[a]);if(o)return i.send(r),Nt;var s,c=new Promise((function(e,t){i.addEventListener("load",(function(){s||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})})),i.addEventListener("error",(function(){s||t(new Error)})),i.send(r)}));return{promise:c,cancel:function(){s=!0,i.abort()}}}var Vt=e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")};function Ht(e,t,n,r){var o,i,a=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?t:t.replace(r,"")).replace(n,"");switch(e.kind){case"exact":i=t,o=new RegExp("^"+Vt(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+Vt(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+Vt(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Mt(e,t){for(var n={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],s=a.urls||[],c=0;c<s.length;c++)if(Ht(s[c],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?t("pageview",a):(o.push(a),t("click_pageview",a));break}return o.length>0&&(r=function(e){for(var n=function(e,t){for(var n=[],r=0;r<t.length;r++)for(var o=e.target,i=t[r],a=i.selector,s=document.querySelectorAll(a);o&&s.length>0;){for(var c=0;c<s.length;c++)o===s[c]&&n.push(i);o=o.parentNode}return n}(e,o),r=0;r<n.length;r++)t("click",n[r])},document.addEventListener("click",r)),n.dispose=function(){document.removeEventListener("click",r)},n}var qt=300;function Kt(e,t){var n,r;function o(){r&&r.dispose(),n&&n.length&&(r=Mt(n,i))}function i(t,n){var r=e.ident.getContext(),o={kind:t,key:n.key,data:null,url:window.location.href,creationDate:(new Date).getTime(),contextKeys:Tt(r)};return"click"===t&&(o.selector=n.selector),e.enqueueEvent(o)}return e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=Mt(n=e,i),function(e,t){var n,r=window.location.href;function o(){(n=window.location.href)!==r&&(r=n,t())}!function e(t,n){t(),setTimeout((function(){e(t,n)}),n)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(qt,o)),t()})).catch((function(n){e.emitter.maybeReportError(new Ot.LDUnexpectedResponseError((n&&n.message,n.message))),t()})),{}}var _t="goalsReady",zt={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function Jt(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var t,n={userAgentHeaderName:"X-LaunchDarkly-User-Agent",synchronousFlush:!1};if(window.XMLHttpRequest){var r=e&&e.disableSyncEventPost;n.httpRequest=function(e,t,o,i){var a=n.synchronousFlush&!r;return n.synchronousFlush=!1,$t(e,t,o,i,a)}}n.httpAllowsPost=function(){return void 0===t&&(t=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),t},n.httpFallbackPing=function(e){(new window.Image).src=e};var o,i=e&&e.eventUrlTransformer;n.getCurrentUrl=function(){return i?i(window.location.href):window.location.href},n.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&&(n.localStorage={get:function(e){return new Promise((function(t){t(window.localStorage.getItem(e))}))},set:function(e,t){return new Promise((function(n){window.localStorage.setItem(e,t),n()}))},clear:function(e){return new Promise((function(t){window.localStorage.removeItem(e),t()}))}})}catch(e){n.localStorage=null}if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(n.eventSourceAllowsReport=!0,o=window.EventSourcePolyfill):(n.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource){var a=3e5;n.eventSourceFactory=function(e,t){var n=Rt(Rt({},{heartbeatTimeout:a,silentTimeout:a,skipDefaultHeaders:!0}),t);return new o(e,n)},n.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return n.userAgent="JSClient",n.version="3.1.1",n.diagnosticSdkData={name:"js-client-sdk",version:"3.1.1"},n.diagnosticPlatformData={name:"JS"},n.diagnosticUseCombinedEvent=!0,n}(n),o=It(e,t,n,r,zt),i=o.client,a=o.options,s=o.emitter,c=new Promise((function(e){var t=s.on(_t,(function(){s.off(_t,t),e()}))}));i.waitUntilGoalsReady=function(){return c},a.fetchGoals?Kt(o,(function(){return s.emit(_t)})):s.emit(_t),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var u=function(){r.synchronousFlush=!0,i.flush().catch((function(){})),r.synchronousFlush=!1};return document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&u()})),window.addEventListener("pagehide",u),i}var Bt=Ft,Gt="3.1.1";var Wt={initialize:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Lt.deprecated("default export","named LDClient export")),Jt(e,t,n)},version:Gt};e.basicLogger=Bt,e.createConsoleLogger=undefined,e.default=Wt,e.initialize=Jt,e.version=Gt,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LDClient={})}(this,(function(e){"use strict";function t(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return t.prototype=new Error,t.prototype.name=e,t.prototype.constructor=t,t}const n=t("LaunchDarklyUnexpectedResponseError"),r=t("LaunchDarklyInvalidEnvironmentIdError"),o=t("LaunchDarklyInvalidUserError"),i=t("LaunchDarklyInvalidEventKeyError"),a=t("LaunchDarklyInvalidArgumentError"),s=t("LaunchDarklyFlagFetchError");for(var c={LDUnexpectedResponseError:n,LDInvalidEnvironmentIdError:r,LDInvalidUserError:o,LDInvalidEventKeyError:i,LDInvalidArgumentError:a,LDInvalidDataError:t("LaunchDarklyInvalidDataError"),LDFlagFetchError:s,isHttpErrorRecoverable:function(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}},u=function(e){var t=y(e),n=t[0],r=t[1];return 3*(n+r)/4-r},l=function(e){var t,n,r=y(e),o=r[0],i=r[1],a=new v(function(e,t,n){return 3*(t+n)/4-n}(0,o,i)),s=0,c=i>0?o-4:o;for(n=0;n<c;n+=4)t=g[e.charCodeAt(n)]<<18|g[e.charCodeAt(n+1)]<<12|g[e.charCodeAt(n+2)]<<6|g[e.charCodeAt(n+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=255&t;2===i&&(t=g[e.charCodeAt(n)]<<2|g[e.charCodeAt(n+1)]>>4,a[s++]=255&t);1===i&&(t=g[e.charCodeAt(n)]<<10|g[e.charCodeAt(n+1)]<<4|g[e.charCodeAt(n+2)]>>2,a[s++]=t>>8&255,a[s++]=255&t);return a},d=function(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(w(e,a,a+i>s?s:a+i));1===r?(t=e[n-1],o.push(f[t>>2]+f[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],o.push(f[t>>10]+f[t>>4&63]+f[t<<2&63]+"="));return o.join("")},f=[],g=[],v="undefined"!=typeof Uint8Array?Uint8Array:Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m=0,h=p.length;m<h;++m)f[m]=p[m],g[p.charCodeAt(m)]=m;function y(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function w(e,t,n){for(var r,o,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(f[(o=r)>>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}g["-".charCodeAt(0)]=62,g["_".charCodeAt(0)]=63;var b={byteLength:u,toByteArray:l,fromByteArray:d},k=Array.isArray,E=Object.keys,D=Object.prototype.hasOwnProperty,C=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i,a=k(t),s=k(n);if(a&&s){if((o=t.length)!=n.length)return!1;for(r=o;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(a!=s)return!1;var c=t instanceof Date,u=n instanceof Date;if(c!=u)return!1;if(c&&u)return t.getTime()==n.getTime();var l=t instanceof RegExp,d=n instanceof RegExp;if(l!=d)return!1;if(l&&d)return t.toString()==n.toString();var f=E(t);if((o=f.length)!==E(n).length)return!1;for(r=o;0!=r--;)if(!D.call(n,f[r]))return!1;for(r=o;0!=r--;)if(!e(t[i=f[r]],n[i]))return!1;return!0}return t!=t&&n!=n};const x=["key","ip","country","email","firstName","lastName","avatar","name"];function P(e){const t=unescape(encodeURIComponent(e));return b.fromByteArray(function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}(t))}function S(e){return P(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function I(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var O,L={appendUrlPath:function(e,t){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(t.startsWith("/")?"":"/")+t},base64URLEncode:S,btoa:P,chunkEventsForUrl:function(e,t){const n=t.slice(0),r=[];let o,i=e;for(;n.length>0;){for(o=[];i>0;){const e=n.shift();if(!e)break;i-=S(JSON.stringify(e)).length,i<0&&o.length>0?n.unshift(e):o.push(e)}i=e,r.push(o)}return r},clone:function(e){return JSON.parse(JSON.stringify(e))},deepEquals:function(e,t){return C(e,t)},extend:function(...e){return e.reduce(((e,t)=>({...e,...t})),{})},getLDUserAgentString:function(e){const t=e.version||"?";return e.userAgent+"/"+t},objectHasOwnProperty:I,onNextTick:function(e){setTimeout(e,0)},sanitizeContext:function(e){if(!e)return e;let t;return null!==e.kind&&void 0!==e.kind||x.forEach((n=>{const r=e[n];void 0!==r&&"string"!=typeof r&&(t=t||{...e},t[n]=String(r))})),t||e},transformValuesToVersionedValues:function(e){const t={};for(const n in e)I(e,n)&&(t[n]={value:e[n],version:0});return t},transformVersionedValuesToValues:function(e){const t={};for(const n in e)I(e,n)&&(t[n]=e[n].value);return t},wrapPromiseCallback:function(e,t){const n=e.then((e=>(t&&setTimeout((()=>{t(null,e)}),0),e)),(e=>{if(!t)return Promise.reject(e);setTimeout((()=>{t(e,null)}),0)}));return t?void 0:n}},T=new Uint8Array(16);function U(){if(!O&&!(O="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return O(T)}var R=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function A(e){return"string"==typeof e&&R.test(e)}for(var j,F,N=[],$=0;$<256;++$)N.push(($+256).toString(16).substr(1));function V(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(N[e[t+0]]+N[e[t+1]]+N[e[t+2]]+N[e[t+3]]+"-"+N[e[t+4]]+N[e[t+5]]+"-"+N[e[t+6]]+N[e[t+7]]+"-"+N[e[t+8]]+N[e[t+9]]+"-"+N[e[t+10]]+N[e[t+11]]+N[e[t+12]]+N[e[t+13]]+N[e[t+14]]+N[e[t+15]]).toLowerCase();if(!A(n))throw TypeError("Stringified UUID is invalid");return n}var H=0,M=0;function q(e){if(!A(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}var K="6ba7b810-9dad-11d1-80b4-00c04fd430c8",_="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function z(e,t,n){function r(e,r,o,i){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=q(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+e.length);if(a.set(r),a.set(e,r.length),(a=n(a))[6]=15&a[6]|t,a[8]=63&a[8]|128,o){i=i||0;for(var s=0;s<16;++s)o[i+s]=a[s];return o}return V(a)}try{r.name=e}catch(e){}return r.DNS=K,r.URL=_,r}function J(e){return 14+(e+64>>>9<<4)+1}function B(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function G(e,t,n,r,o,i){return B((a=B(B(t,e),B(r,i)))<<(s=o)|a>>>32-s,n);var a,s}function W(e,t,n,r,o,i,a){return G(t&n|~t&r,e,t,o,i,a)}function X(e,t,n,r,o,i,a){return G(t&r|n&~r,e,t,o,i,a)}function Q(e,t,n,r,o,i,a){return G(t^n^r,e,t,o,i,a)}function Y(e,t,n,r,o,i,a){return G(n^(t|~r),e,t,o,i,a)}var Z=z("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,r="0123456789abcdef",o=0;o<n;o+=8){var i=e[o>>5]>>>o%32&255,a=parseInt(r.charAt(i>>>4&15)+r.charAt(15&i),16);t.push(a)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[J(t)-1]=t;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,a=0;a<e.length;a+=16){var s=n,c=r,u=o,l=i;n=W(n,r,o,i,e[a],7,-680876936),i=W(i,n,r,o,e[a+1],12,-389564586),o=W(o,i,n,r,e[a+2],17,606105819),r=W(r,o,i,n,e[a+3],22,-1044525330),n=W(n,r,o,i,e[a+4],7,-176418897),i=W(i,n,r,o,e[a+5],12,1200080426),o=W(o,i,n,r,e[a+6],17,-1473231341),r=W(r,o,i,n,e[a+7],22,-45705983),n=W(n,r,o,i,e[a+8],7,1770035416),i=W(i,n,r,o,e[a+9],12,-1958414417),o=W(o,i,n,r,e[a+10],17,-42063),r=W(r,o,i,n,e[a+11],22,-1990404162),n=W(n,r,o,i,e[a+12],7,1804603682),i=W(i,n,r,o,e[a+13],12,-40341101),o=W(o,i,n,r,e[a+14],17,-1502002290),n=X(n,r=W(r,o,i,n,e[a+15],22,1236535329),o,i,e[a+1],5,-165796510),i=X(i,n,r,o,e[a+6],9,-1069501632),o=X(o,i,n,r,e[a+11],14,643717713),r=X(r,o,i,n,e[a],20,-373897302),n=X(n,r,o,i,e[a+5],5,-701558691),i=X(i,n,r,o,e[a+10],9,38016083),o=X(o,i,n,r,e[a+15],14,-660478335),r=X(r,o,i,n,e[a+4],20,-405537848),n=X(n,r,o,i,e[a+9],5,568446438),i=X(i,n,r,o,e[a+14],9,-1019803690),o=X(o,i,n,r,e[a+3],14,-187363961),r=X(r,o,i,n,e[a+8],20,1163531501),n=X(n,r,o,i,e[a+13],5,-1444681467),i=X(i,n,r,o,e[a+2],9,-51403784),o=X(o,i,n,r,e[a+7],14,1735328473),n=Q(n,r=X(r,o,i,n,e[a+12],20,-1926607734),o,i,e[a+5],4,-378558),i=Q(i,n,r,o,e[a+8],11,-2022574463),o=Q(o,i,n,r,e[a+11],16,1839030562),r=Q(r,o,i,n,e[a+14],23,-35309556),n=Q(n,r,o,i,e[a+1],4,-1530992060),i=Q(i,n,r,o,e[a+4],11,1272893353),o=Q(o,i,n,r,e[a+7],16,-155497632),r=Q(r,o,i,n,e[a+10],23,-1094730640),n=Q(n,r,o,i,e[a+13],4,681279174),i=Q(i,n,r,o,e[a],11,-358537222),o=Q(o,i,n,r,e[a+3],16,-722521979),r=Q(r,o,i,n,e[a+6],23,76029189),n=Q(n,r,o,i,e[a+9],4,-640364487),i=Q(i,n,r,o,e[a+12],11,-421815835),o=Q(o,i,n,r,e[a+15],16,530742520),n=Y(n,r=Q(r,o,i,n,e[a+2],23,-995338651),o,i,e[a],6,-198630844),i=Y(i,n,r,o,e[a+7],10,1126891415),o=Y(o,i,n,r,e[a+14],15,-1416354905),r=Y(r,o,i,n,e[a+5],21,-57434055),n=Y(n,r,o,i,e[a+12],6,1700485571),i=Y(i,n,r,o,e[a+3],10,-1894986606),o=Y(o,i,n,r,e[a+10],15,-1051523),r=Y(r,o,i,n,e[a+1],21,-2054922799),n=Y(n,r,o,i,e[a+8],6,1873313359),i=Y(i,n,r,o,e[a+15],10,-30611744),o=Y(o,i,n,r,e[a+6],15,-1560198380),r=Y(r,o,i,n,e[a+13],21,1309151649),n=Y(n,r,o,i,e[a+4],6,-145523070),i=Y(i,n,r,o,e[a+11],10,-1120210379),o=Y(o,i,n,r,e[a+2],15,718787259),r=Y(r,o,i,n,e[a+9],21,-343485551),n=B(n,s),r=B(r,c),o=B(o,u),i=B(i,l)}return[n,r,o,i]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(J(t)),r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))})),ee=Z;function te(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function ne(e,t){return e<<t|e>>>32-t}var re=z("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var o=0;o<r.length;++o)e.push(r.charCodeAt(o))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var i=e.length/4+2,a=Math.ceil(i/16),s=new Array(a),c=0;c<a;++c){for(var u=new Uint32Array(16),l=0;l<16;++l)u[l]=e[64*c+4*l]<<24|e[64*c+4*l+1]<<16|e[64*c+4*l+2]<<8|e[64*c+4*l+3];s[c]=u}s[a-1][14]=8*(e.length-1)/Math.pow(2,32),s[a-1][14]=Math.floor(s[a-1][14]),s[a-1][15]=8*(e.length-1)&4294967295;for(var d=0;d<a;++d){for(var f=new Uint32Array(80),g=0;g<16;++g)f[g]=s[d][g];for(var v=16;v<80;++v)f[v]=ne(f[v-3]^f[v-8]^f[v-14]^f[v-16],1);for(var p=n[0],m=n[1],h=n[2],y=n[3],w=n[4],b=0;b<80;++b){var k=Math.floor(b/20),E=ne(p,5)+te(k,m,h,y)+w+t[k]+f[b]>>>0;w=y,y=h,h=ne(m,30)>>>0,m=p,p=E}n[0]=n[0]+p>>>0,n[1]=n[1]+m>>>0,n[2]=n[2]+h>>>0,n[3]=n[3]+y>>>0,n[4]=n[4]+w>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]})),oe=re;var ie=Object.freeze({__proto__:null,v1:function(e,t,n){var r=t&&n||0,o=t||new Array(16),i=(e=e||{}).node||j,a=void 0!==e.clockseq?e.clockseq:F;if(null==i||null==a){var s=e.random||(e.rng||U)();null==i&&(i=j=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==a&&(a=F=16383&(s[6]<<8|s[7]))}var c=void 0!==e.msecs?e.msecs:Date.now(),u=void 0!==e.nsecs?e.nsecs:M+1,l=c-H+(u-M)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||c>H)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");H=c,M=u,F=a;var d=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;o[r++]=d>>>24&255,o[r++]=d>>>16&255,o[r++]=d>>>8&255,o[r++]=255&d;var f=c/4294967296*1e4&268435455;o[r++]=f>>>8&255,o[r++]=255&f,o[r++]=f>>>24&15|16,o[r++]=f>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var g=0;g<6;++g)o[r+g]=i[g];return t||V(o)},v3:ee,v4:function(e,t,n){var r=(e=e||{}).random||(e.rng||U)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=r[o];return t}return V(r)},v5:oe,NIL:"00000000-0000-0000-0000-000000000000",version:function(e){if(!A(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)},validate:A,stringify:V,parse:q});const ae=["debug","info","warn","error","none"];var se={commonBasicLogger:function(e,t){if(e&&e.destination&&"function"!=typeof e.destination)throw new Error("destination for basicLogger was set to a non-function");function n(e){return function(t){console&&console[e]&&console[e].call(console,t)}}const r=e&&e.destination?[e.destination,e.destination,e.destination,e.destination]:[n("log"),n("info"),n("warn"),n("error")],o=!(!e||!e.destination),i=e&&void 0!==e.prefix&&null!==e.prefix?e.prefix:"[LaunchDarkly] ";let a=1;if(e&&e.level)for(let t=0;t<ae.length;t++)ae[t]===e.level&&(a=t);function s(e,n,a){if(a.length<1)return;let s;const c=o?n+": "+i:i;if(1!==a.length&&t){const e=[...a];e[0]=c+e[0],s=t(...e)}else s=c+a[0];try{r[e](s)}catch(e){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+n+" method threw an exception: "+e)}}const c={};for(let e=0;e<ae.length;e++){const t=ae[e];if("none"!==t)if(e<a)c[t]=()=>{};else{const n=e;c[t]=function(){s(n,t,arguments)}}}return c},validateLogger:function(e){ae.forEach((t=>{if("none"!==t&&(!e[t]||"function"!=typeof e[t]))throw new Error("Provided logger instance must support logger."+t+"(...) method")}))}};function ce(e){return e&&e.message?e.message:"string"==typeof e||e instanceof String?e:JSON.stringify(e)}const ue=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initializing-the-client for instructions on SDK initialization.";var le={bootstrapInvalid:function(){return"LaunchDarkly bootstrap data is not available because the back end could not read the flags."},bootstrapOldFormat:function(){return"LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly."+ue},clientInitialized:function(){return"LaunchDarkly client initialized"},clientNotReady:function(){return"LaunchDarkly client is not ready"},debugEnqueueingEvent:function(e){return'enqueueing "'+e+'" event'},debugPostingDiagnosticEvent:function(e){return"sending diagnostic event ("+e.kind+")"},debugPostingEvents:function(e){return"sending "+e+" events"},debugStreamDelete:function(e){return'received streaming deletion for flag "'+e+'"'},debugStreamDeleteIgnored:function(e){return'received streaming deletion for flag "'+e+'" but ignored due to version check'},debugStreamPatch:function(e){return'received streaming update for flag "'+e+'"'},debugStreamPatchIgnored:function(e){return'received streaming update for flag "'+e+'" but ignored due to version check'},debugStreamPing:function(){return"received ping message from stream"},debugPolling:function(e){return"polling for feature flags at "+e},debugStreamPut:function(){return"received streaming update for all flags"},deprecated:function(e,t){return t?'"'+e+'" is deprecated, please use "'+t+'"':'"'+e+'" is deprecated'},environmentNotFound:function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+ue},environmentNotSpecified:function(){return"No environment/client-side ID was specified."+ue},errorFetchingFlags:function(e){return"Error fetching flag settings: "+ce(e)},eventCapacityExceeded:function(){return"Exceeded event queue capacity. Increase capacity to avoid dropping events."},eventWithoutContext:function(){return"Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/sdk/features/identify#javascript"},httpErrorMessage:function(e,t,n){return"Received error "+e+(401===e?" (invalid SDK key)":"")+" for "+t+" - "+(c.isHttpErrorRecoverable(e)?n:"giving up permanently")},httpUnavailable:function(){return"Cannot make HTTP requests in this environment."+ue},identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},inspectorMethodError:(e,t)=>`an inspector: "${t}" of type: "${e}" generated an exception`,invalidContentType:function(e){return'Expected application/json content type but got "'+e+'"'},invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},invalidInspector:(e,t)=>`an inspector: "${t}" of an invalid type (${e}) was configured`,invalidKey:function(){return"Event key must be a string"},invalidContext:function(){return"Invalid context specified."+ue},invalidTagValue:e=>`Config option "${e}" must only contain letters, numbers, ., _ or -.`,localStorageUnavailable:function(e){return"local storage is unavailable: "+ce(e)},networkError:e=>"network error"+(e?" ("+e+")":""),optionBelowMinimum:(e,t,n)=>'Config option "'+e+'" was set to '+t+", changing to minimum value of "+n,streamClosing:function(){return"Closing stream connection"},streamConnecting:function(e){return"Opening stream connection to "+e},streamError:function(e,t){return"Error on stream connection: "+ce(e)+", will continue retrying after "+t+" milliseconds."},tagValueTooLong:e=>`Value of "${e}" was longer than 64 characters and was discarded.`,unknownCustomEventKey:function(e){return'Custom event "'+e+'" does not exist'},unknownOption:e=>'Ignoring unknown config option "'+e+'"',contextNotSpecified:function(){return"No context specified."+ue},unrecoverableStreamError:e=>`Error on stream connection ${ce(e)}, giving up permanently`,wrongOptionType:(e,t,n)=>'Config option "'+e+'" should be of type '+t+", got "+n+", using default value",wrongOptionTypeBoolean:(e,t)=>'Config option "'+e+'" should be a boolean, got '+t+", converting to boolean"};const{validateLogger:de}=se,fe={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"},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},privateAttributes:{default:[]},bootstrap:{type:"string|object"},diagnosticRecordingInterval:{default:9e5,minimum:2e3},diagnosticOptOut:{default:!1},wrapperName:{type:"string"},wrapperVersion:{type:"string"},stateProvider:{type:"object"},application:{validator:function(e,t,n){const r={};t.id&&(r.id=pe(`${e}.id`,t.id,n));t.version&&(r.version=pe(`${e}.version`,t.version,n));return r}},inspectors:{default:[]}},ge=/^(\w|\.|-)+$/;function ve(e){return e&&e.replace(/\/+$/,"")}function pe(e,t,n){if("string"==typeof t&&t.match(ge)){if(!(t.length>64))return t;n.warn(le.tagValueTooLong(e))}else n.warn(le.invalidTagValue(e))}var me={baseOptionDefs:fe,validate:function(e,t,n,r){const o=L.extend({logger:{default:r}},fe,n),i={};function a(e){L.onNextTick((()=>{t&&t.maybeReportError(new c.LDInvalidArgumentError(e))}))}let s=L.extend({},e||{});return function(e){const t=e;Object.keys(i).forEach((e=>{if(void 0!==t[e]){const n=i[e];r&&r.warn(le.deprecated(e,n)),n&&(void 0===t[n]&&(t[n]=t[e]),delete t[e])}}))}(s),s=function(e){const t=L.extend({},e);return Object.keys(o).forEach((e=>{void 0!==t[e]&&null!==t[e]||(t[e]=o[e]&&o[e].default)})),t}(s),s=function(e){const t=L.extend({},e),n=e=>{if(null===e)return"any";if(void 0===e)return;if(Array.isArray(e))return"array";const t=typeof e;return"boolean"===t||"string"===t||"number"===t||"function"===t?t:"object"};return Object.keys(e).forEach((i=>{const s=e[i];if(null!=s){const c=o[i];if(void 0===c)a(le.unknownOption(i));else{const o=c.type||n(c.default),u=c.validator;if(u){const n=u(i,e[i],r);void 0!==n?t[i]=n:delete t[i]}else if("any"!==o){const e=o.split("|"),r=n(s);e.indexOf(r)<0?"boolean"===o?(t[i]=!!s,a(le.wrongOptionTypeBoolean(i,r))):(a(le.wrongOptionType(i,o,r)),t[i]=c.default):"number"===r&&void 0!==c.minimum&&s<c.minimum&&(a(le.optionBelowMinimum(i,s,c.minimum)),t[i]=c.minimum)}}}})),t.baseUrl=ve(t.baseUrl),t.streamUrl=ve(t.streamUrl),t.eventsUrl=ve(t.eventsUrl),t}(s),de(s.logger),s},getTags:function(e){const t={};return e&&(e.application&&void 0!==e.application.id&&null!==e.application.id&&(t["application-id"]=[e.application.id]),e.application&&void 0!==e.application.version&&null!==e.application.id&&(t["application-version"]=[e.application.version])),t}};const{getLDUserAgentString:he}=L;var ye={getLDHeaders:function(e,t){if(t&&!t.sendLDHeaders)return{};const n={};n[e.userAgentHeaderName||"User-Agent"]=he(e),t&&t.wrapperName&&(n["X-LaunchDarkly-Wrapper"]=t.wrapperVersion?t.wrapperName+"/"+t.wrapperVersion:t.wrapperName);const r=me.getTags(t),o=Object.keys(r);return o.length&&(n["x-launchdarkly-tags"]=o.sort().map((e=>Array.isArray(r[e])?r[e].sort().map((t=>`${e}/${t}`)):[`${e}/${r[e]}`])).reduce(((e,t)=>e.concat(t)),[]).join(" ")),n},transformHeaders:function(e,t){return t&&t.requestHeaderTransform?t.requestHeaderTransform({...e}):e}};const{v1:we}=ie,{getLDHeaders:be,transformHeaders:ke}=ye,Ee=2e3;var De=function(e,t,n){const r="/a/"+t+".gif",o=L.extend({"Content-Type":"application/json"},be(e,n)),i=e.httpFallbackPing,a={};return a.sendChunk=(t,a,s,u)=>{const l=JSON.stringify(t),d=s?null:we();return u?function t(r){const i=s?o:L.extend({},o,{"X-LaunchDarkly-Event-Schema":"4","X-LaunchDarkly-Payload-ID":d});return e.httpRequest("POST",a,ke(i,n),l).promise.then((e=>{if(e)return e.status>=400&&c.isHttpErrorRecoverable(e.status)&&r?t(!1):function(e){const t={status:e.status},n=e.header("date");if(n){const e=Date.parse(n);e&&(t.serverTime=e)}return t}(e)})).catch((()=>r?t(!1):Promise.reject()))}(!0).catch((()=>{})):(i&&i(a+r+"?d="+L.base64URLEncode(l)),Promise.resolve())},a.sendEvents=function(t,n,r){if(!e.httpRequest)return Promise.resolve();const o=e.httpAllowsPost();let i;i=o?[t]:L.chunkEventsForUrl(Ee-n.length,t);const s=[];for(let e=0;e<i.length;e++)s.push(a.sendChunk(i[e],n,r,o));return Promise.all(s)},a};const{commonBasicLogger:Ce}=se;function xe(e){return"string"==typeof e&&"kind"!==e&&e.match(/^(\w|\.|-)+$/)}function Pe(e){return e.includes("%")||e.includes(":")?e.replace(/%/g,"%25").replace(/:/g,"%3A"):e}var Se={checkContext:function(e,t){if(e){if(t&&(void 0===e.kind||null===e.kind))return void 0!==e.key&&null!==e.key;const n=e.key,r=void 0===e.kind?"user":e.kind,o=xe(r),i="multi"===r||null!=n&&""!==n;if("multi"===r){const t=Object.keys(e).filter((e=>"kind"!==e));return i&&t.every((e=>xe(e)))&&t.every((t=>{const n=e[t].key;return null!=n&&""!==n}))}return i&&o}return!1},getContextKeys:function(e,t=Ce()){if(!e)return;const n={},{kind:r,key:o}=e;switch(r){case void 0:n.user=`${o}`;break;case"multi":Object.entries(e).filter((([e])=>"kind"!==e)).forEach((([e,t])=>{t&&t.key&&(n[e]=t.key)}));break;case null:t.warn(`null is not a valid context kind: ${e}`);break;case"":t.warn(`'' is not a valid context kind: ${e}`);break;default:n[r]=`${o}`}return n},getContextKinds:function(e){return e?null===e.kind||void 0===e.kind?["user"]:"multi"!==e.kind?[e.kind]:Object.keys(e).filter((e=>"kind"!==e)):[]},getCanonicalKey:function(e){if(e){if((void 0===e.kind||null===e.kind||"user"===e.kind)&&e.key)return e.key;if("multi"!==e.kind&&e.key)return`${e.kind}:${Pe(e.key)}`;if("multi"===e.kind)return Object.keys(e).sort().filter((e=>"kind"!==e)).map((t=>`${t}:${Pe(e[t].key)}`)).join(":")}}};const{getContextKinds:Ie}=Se;var Oe=function(){const e={};let t=0,n=0,r={},o={};return e.summarizeEvent=e=>{if("feature"===e.kind){const i=e.key+":"+(null!==e.variation&&void 0!==e.variation?e.variation:"")+":"+(null!==e.version&&void 0!==e.version?e.version:""),a=r[i];let s=o[e.key];s||(s=new Set,o[e.key]=s),function(e){return e.context?Ie(e.context):e.contextKeys?Object.keys(e.contextKeys):[]}(e).forEach((e=>s.add(e))),a?a.count=a.count+1:r[i]={count:1,key:e.key,version:e.version,variation:e.variation,value:e.value,default:e.default},(0===t||e.creationDate<t)&&(t=e.creationDate),e.creationDate>n&&(n=e.creationDate)}},e.getSummary=()=>{const e={};let i=!0;for(const t of Object.values(r)){let n=e[t.key];n||(n={default:t.default,counters:[],contextKinds:[...o[t.key]]},e[t.key]=n);const r={value:t.value,count:t.count};void 0!==t.variation&&null!==t.variation&&(r.variation=t.variation),void 0!==t.version&&null!==t.version?r.version=t.version:r.unknown=!0,n.counters.push(r),i=!1}return i?null:{startDate:t,endDate:n,features:e}},e.clearSummary=()=>{t=0,n=0,r={},o={}},e};function Le(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Te(e){return(e.startsWith("/")?e.substring(1):e).split("/").map((e=>e.indexOf("~")>=0?e.replace(/~1/g,"/").replace(/~0/g,"~"):e))}function Ue(e){return!e.startsWith("/")}function Re(e,t){const n=Ue(e),r=Ue(t);if(n&&r)return e===t;if(n){const n=Te(t);return 1===n.length&&e===n[0]}if(r){const n=Te(e);return 1===n.length&&t===n[0]}return e===t}function Ae(e){return`/${Le(e)}`}var je={cloneExcluding:function(e,t){const n=[],r={},o=[];for(n.push(...Object.keys(e).map((t=>({key:t,ptr:Ae(t),source:e,parent:r,visited:[e]}))));n.length;){const e=n.pop();if(t.some((t=>Re(t,e.ptr))))o.push(e.ptr);else{const t=e.source[e.key];if(null===t)e.parent[e.key]=t;else if(Array.isArray(t))e.parent[e.key]=[...t];else if("object"==typeof t){if(e.visited.includes(t))continue;e.parent[e.key]={},n.push(...Object.keys(t).map((n=>{return{key:n,ptr:(r=e.ptr,o=Le(n),`${r}/${o}`),source:t,parent:e.parent[e.key],visited:[...e.visited,t]};var r,o})))}else e.parent[e.key]=t}}return{cloned:r,excluded:o.sort()}},compare:Re,literalToReference:Ae};var Fe=function(e){const t={},n=e.allAttributesPrivate,r=e.privateAttributes||[],o=["key","kind","_meta","anonymous"],i=["name","ip","firstName","lastName","email","avatar","country"],a=e=>{if("object"!=typeof e||null===e||Array.isArray(e))return;const{cloned:t,excluded:i}=je.cloneExcluding(e,(e=>(n?Object.keys(e):[...r,...e._meta&&e._meta.privateAttributes||[]]).filter((e=>!o.some((t=>je.compare(e,t))))))(e));return t.key=String(t.key),i.length&&(t._meta||(t._meta={}),t._meta.redactedAttributes=i),t._meta&&(delete t._meta.privateAttributes,0===Object.keys(t._meta).length&&delete t._meta),void 0!==t.anonymous&&(t.anonymous=!!t.anonymous),t};return t.filter=e=>void 0===e.kind||null===e.kind?a((e=>{const t={...e.custom||{},kind:"user",key:e.key};void 0!==e.anonymous&&(t.anonymous=!!e.anonymous);for(const n of i)delete t[n],void 0!==e[n]&&null!==e[n]&&(t[n]=String(e[n]));return void 0!==e.privateAttributeNames&&null!==e.privateAttributeNames&&(t._meta=t._meta||{},t._meta.privateAttributes=e.privateAttributeNames.map((e=>e.startsWith("/")?je.literalToReference(e):e))),t})(e)):"multi"===e.kind?(e=>{const t={kind:e.kind},n=Object.keys(e);for(const r of n)if("kind"!==r){const n=a(e[r]);n&&(t[r]=n)}return t})(e):a(e),t};const{getContextKeys:Ne}=Se;var $e=function(e,t,n,r=null,o=null,i=null){const a={},s=i||De(e,n,t),u=L.appendUrlPath(t.eventsUrl,"/events/bulk/"+n),l=Oe(),d=Fe(t),f=t.samplingInterval,g=t.eventCapacity,v=t.flushInterval,p=t.logger;let m,h=[],y=0,w=!1,b=!1;function k(){return 0===f||0===Math.floor(Math.random()*f)}function E(e){const t=L.extend({},e);return"identify"===e.kind?t.context=d.filter(e.context):(t.contextKeys=Ne(e.context,p),delete t.context),"feature"===e.kind&&(delete t.trackEvents,delete t.debugEventsUntilDate),t}function D(e){h.length<g?(h.push(e),b=!1):(b||(b=!0,p.warn(le.eventCapacityExceeded())),r&&r.incrementDroppedEvents())}return a.enqueue=function(e){if(w)return;let t=!1,n=!1;var r;if(l.summarizeEvent(e),"feature"===e.kind?k()&&(t=!!e.trackEvents,n=!!(r=e).debugEventsUntilDate&&r.debugEventsUntilDate>y&&r.debugEventsUntilDate>(new Date).getTime()):t=k(),t&&D(E(e)),n){const t=L.extend({},e,{kind:"debug"});t.context=d.filter(t.context),delete t.trackEvents,delete t.debugEventsUntilDate,D(t)}},a.flush=function(){if(w)return Promise.resolve();const e=h,t=l.getSummary();return l.clearSummary(),t&&(t.kind="summary",e.push(t)),r&&r.setEventsInLastBatch(e.length),0===e.length?Promise.resolve():(h=[],p.debug(le.debugPostingEvents(e.length)),s.sendEvents(e,u).then((e=>{const t=e&&e[0];t&&(t.serverTime&&(y=t.serverTime),c.isHttpErrorRecoverable(t.status)||(w=!0),t.status>=400&&L.onNextTick((()=>{o.maybeReportError(new c.LDUnexpectedResponseError(le.httpErrorMessage(t.status,"event posting","some events were dropped")))})))})))},a.start=function(){const e=()=>{a.flush(),m=setTimeout(e,v)};m=setTimeout(e,v)},a.stop=function(){clearTimeout(m)},a};var Ve=function(e){const t={},n={};return t.on=function(e,t,r){n[e]=n[e]||[],n[e]=n[e].concat({handler:t,context:r})},t.off=function(e,t,r){if(n[e])for(let o=0;o<n[e].length;o++)n[e][o].handler===t&&n[e][o].context===r&&(n[e]=n[e].slice(0,o).concat(n[e].slice(o+1)))},t.emit=function(e){if(!n[e])return;const t=n[e].slice(0);for(let e=0;e<t.length;e++)t[e].handler.apply(t[e].context,Array.prototype.slice.call(arguments,1))},t.getEvents=function(){return Object.keys(n)},t.getEventListenerCount=function(e){return n[e]?n[e].length:0},t.maybeReportError=function(t){t&&(n["error"]?this.emit("error",t):(e||console).error(t.message))},t};const He="ready",Me="initialized",qe="failed";var Ke=function(e){let t=!1,n=!1,r=null,o=null;const i=new Promise((t=>{const n=()=>{e.off(He,n),t()};e.on(He,n)})).catch((()=>{}));return{getInitializationPromise:()=>o||(t?Promise.resolve():n?Promise.reject(r):(o=new Promise(((t,n)=>{const r=()=>{e.off(Me,r),t()},o=t=>{e.off(qe,o),n(t)};e.on(Me,r),e.on(qe,o)})),o)),getReadyPromise:()=>i,signalSuccess:()=>{t||n||(t=!0,e.emit(Me),e.emit(He))},signalFailure:o=>{t||n||(n=!0,r=o,e.emit(qe,o),e.emit(He)),e.maybeReportError(o)}}};var _e=function(e,t,n,r){const o={};function i(){let e="";const o=r.getContext();return o&&(e=n||L.btoa(JSON.stringify(o))),"ld:"+t+":"+e}return o.loadFlags=()=>e.get(i()).then((e=>{if(null==e)return null;try{let t=JSON.parse(e);if(t){const e=t.$schema;void 0===e||e<1?t=L.transformValuesToVersionedValues(t):delete t.$schema}return t}catch(e){return o.clearFlags().then((()=>null))}})),o.saveFlags=t=>{const n=L.extend({},t,{$schema:1});return e.set(i(),JSON.stringify(n))},o.clearFlags=()=>e.clear(i()),o};var ze=function(e,t){const n={};let r=!1;const o=e=>{r||(r=!0,t.warn(le.localStorageUnavailable(e)))};return n.isEnabled=()=>!!e,n.get=t=>new Promise((n=>{e?e.get(t).then(n).catch((e=>{o(e),n(void 0)})):n(void 0)})),n.set=(t,n)=>new Promise((r=>{e?e.set(t,n).then((()=>r(!0))).catch((e=>{o(e),r(!1)})):r(!1)})),n.clear=t=>new Promise((n=>{e?e.clear(t).then((()=>n(!0))).catch((e=>{o(e),n(!1)})):n(!1)})),n};const{appendUrlPath:Je,base64URLEncode:Be,objectHasOwnProperty:Ge}=L,{getLDHeaders:We,transformHeaders:Xe}=ye,{isHttpErrorRecoverable:Qe}=c,Ye=3e5,Ze=3e4,et=.5;var tt=function(e,t,n,r){const o=t.streamUrl,i=t.logger,a={},s=Je(o,"/eval/"+n),c=t.useReport,u=t.evaluationReasons,l=t.streamReconnectDelay,d=We(e,t);let f,g=!1,v=null,p=null,m=null,h=null,y=null,w=0;function b(){const e=(t=function(){const e=l*Math.pow(2,w);return e>Ze?Ze:e}(),t-Math.trunc(Math.random()*et*t));var t;return w+=1,e}function k(e){if(e.status&&"number"==typeof e.status&&!Qe(e.status))return C(),i.error(le.unrecoverableStreamError(e)),void(p&&(clearTimeout(p),p=null));const t=b();g||(i.warn(le.streamError(e,t)),g=!0),x(!1),C(),E(t)}function E(e){p||(e?p=setTimeout(D,e):D())}function D(){let r;p=null;let a="";const l={headers:d,readTimeoutMillis:Ye};if(e.eventSourceFactory){null!=h&&(a="h="+h),c?e.eventSourceAllowsReport?(r=s,l.method="REPORT",l.headers["Content-Type"]="application/json",l.body=JSON.stringify(m)):(r=Je(o,"/ping/"+n),a=""):r=s+"/"+Be(JSON.stringify(m)),l.headers=Xe(l.headers,t),u&&(a=a+(a?"&":"")+"withReasons=true"),r=r+(a?"?":"")+a,C(),i.info(le.streamConnecting(r)),f=(new Date).getTime(),v=e.eventSourceFactory(r,l);for(const e in y)Ge(y,e)&&v.addEventListener(e,y[e]);v.onerror=k,v.onopen=()=>{w=0}}}function C(){v&&(i.info(le.streamClosing()),v.close(),v=null)}function x(e){f&&r&&r.recordStreamInit(f,!e,(new Date).getTime()-f),f=null}return a.connect=function(e,t,n){m=e,h=t,y={};for(const e in n||{})y[e]=function(t){g=!1,x(!0),n[e]&&n[e](t)};E()},a.disconnect=function(){clearTimeout(p),p=null,C()},a.isConnected=function(){return!!(v&&e.eventSourceIsActive&&e.eventSourceIsActive(v))},a};var nt=function(e){let t,n,r,o;const i={addPromise:(i,a)=>{t=i,n&&n(),n=a,i.then((n=>{t===i&&(r(n),e&&e())}),(n=>{t===i&&(o(n),e&&e())}))}};return i.resultPromise=new Promise(((e,t)=>{r=e,o=t})),i};const{transformHeaders:rt,getLDHeaders:ot}=ye,it="application/json";var at=function(e,t,n){const r=t.baseUrl,o=t.useReport,i=t.evaluationReasons,a=t.logger,s={},u={};function l(n,r){if(!e.httpRequest)return new Promise(((e,t)=>{t(new c.LDFlagFetchError(le.httpUnavailable()))}));const o=r?"REPORT":"GET",i=ot(e,t);r&&(i["Content-Type"]=it);let a=u[n];a||(a=nt((()=>{delete u[n]})),u[n]=a);const s=e.httpRequest(o,n,rt(i,t),r),l=s.promise.then((e=>{if(200===e.status){if(e.header("content-type")&&e.header("content-type").substring(0,it.length)===it)return JSON.parse(e.body);{const t=le.invalidContentType(e.header("content-type")||"");return Promise.reject(new c.LDFlagFetchError(t))}}return Promise.reject(function(e){return 404===e.status?new c.LDInvalidEnvironmentIdError(le.environmentNotFound()):new c.LDFlagFetchError(le.errorFetchingFlags(e.statusText||String(e.status)))}(e))}),(e=>Promise.reject(new c.LDFlagFetchError(le.networkError(e)))));return a.addPromise(l,(()=>{s.cancel&&s.cancel()})),a.resultPromise}return s.fetchJSON=function(e){return l(L.appendUrlPath(r,e),null)},s.fetchFlagSettings=function(e,t){let s,c,u,d="";return o?(c=[r,"/sdk/evalx/",n,"/context"].join(""),u=JSON.stringify(e)):(s=L.base64URLEncode(JSON.stringify(e)),c=[r,"/sdk/evalx/",n,"/contexts/",s].join("")),t&&(d="h="+t),i&&(d=d+(d?"&":"")+"withReasons=true"),c=c+(d?"?":"")+d,a.debug(le.debugPolling(c)),l(c,u)},s};var st=function(e,t){const n={};let r;return n.setContext=function(e){r=L.sanitizeContext(e),r&&t&&t(L.clone(r))},n.getContext=function(){return r?L.clone(r):null},e&&n.setContext(e),n};const{v1:ct}=ie,{getContextKinds:ut}=Se,lt="ld:$anonUserId";var dt=function(e){function t(e){return null==e||"user"===e?lt:`ld:$contextKey:${e}`}function n(n,r){return null!==r.key&&void 0!==r.key?(r.key=r.key.toString(),Promise.resolve(r)):r.anonymous?function(n){return e.get(t(n))}(n).then((o=>{if(o)return r.key=o,r;{const o=ct();return r.key=o,function(n,r){return e.set(t(r),n)}(o,n).then((()=>r))}})):Promise.reject(new c.LDInvalidUserError(le.invalidContext()))}this.processContext=e=>{if(!e)return Promise.reject(new c.LDInvalidUserError(le.contextNotSpecified()));const t=L.clone(e);if("multi"===e.kind){const e=ut(t);return Promise.all(e.map((e=>n(e,t[e])))).then((()=>t))}return n(e.kind,t)}};const{v1:ft}=ie,{baseOptionDefs:gt}=me,{appendUrlPath:vt}=L;var pt={DiagnosticId:function(e){const t={diagnosticId:ft()};return e&&(t.sdkKeySuffix=e.length>6?e.substring(e.length-6):e),t},DiagnosticsAccumulator:function(e){let t,n,r,o;function i(e){t=e,n=0,r=0,o=[]}return i(e),{getProps:()=>({dataSinceDate:t,droppedEvents:n,eventsInLastBatch:r,streamInits:o}),setProps:e=>{t=e.dataSinceDate,n=e.droppedEvents||0,r=e.eventsInLastBatch||0,o=e.streamInits||[]},incrementDroppedEvents:()=>{n++},setEventsInLastBatch:e=>{r=e},recordStreamInit:(e,t,n)=>{const r={timestamp:e,failed:t,durationMillis:n};o.push(r)},reset:i}},DiagnosticsManager:function(e,t,n,r,o,i,a){const s=!!e.diagnosticUseCombinedEvent,c="ld:"+o+":$diagnostics",u=vt(i.eventsUrl,"/events/diagnostic/"+o),l=i.diagnosticRecordingInterval,d=n;let f,g,v=!!i.streaming;const p={};function m(){return{sdk:w(),configuration:b(),platform:e.diagnosticPlatformData}}function h(e){i.logger&&i.logger.debug(le.debugPostingDiagnosticEvent(e)),r.sendEvents(e,u,!0).then((()=>{})).catch((()=>{}))}function y(){h(function(){const e=(new Date).getTime();let t={kind:s?"diagnostic-combined":"diagnostic",id:a,creationDate:e,...d.getProps()};return s&&(t={...t,...m()}),d.reset(e),t}()),g=setTimeout(y,l),f=(new Date).getTime(),s&&function(){if(t.isEnabled()){const e={...d.getProps()};t.set(c,JSON.stringify(e))}}()}function w(){const t={...e.diagnosticSdkData};return i.wrapperName&&(t.wrapperName=i.wrapperName),i.wrapperVersion&&(t.wrapperVersion=i.wrapperVersion),t}function b(){return{customBaseURI:i.baseUrl!==gt.baseUrl.default,customStreamURI:i.streamUrl!==gt.streamUrl.default,customEventsURI:i.eventsUrl!==gt.eventsUrl.default,eventsCapacity:i.eventCapacity,eventsFlushIntervalMillis:i.flushInterval,reconnectTimeMillis:i.streamReconnectDelay,streamingDisabled:!v,allAttributesPrivate:!!i.allAttributesPrivate,diagnosticRecordingIntervalMillis:i.diagnosticRecordingInterval,usingSecureMode:!!i.hash,bootstrapMode:!!i.bootstrap,fetchGoalsDisabled:!i.fetchGoals,sendEventsOnlyForVariation:!!i.sendEventsOnlyForVariation}}return p.start=()=>{s?function(e){if(!t.isEnabled())return e(!1);t.get(c).then((t=>{if(t)try{const e=JSON.parse(t);d.setProps(e),f=e.dataSinceDate}catch(e){}e(!0)})).catch((()=>{e(!1)}))}((e=>{if(e){const e=(f||0)+l,t=(new Date).getTime();t>=e?y():g=setTimeout(y,e-t)}else 0===Math.floor(4*Math.random())?y():g=setTimeout(y,l)})):(h({kind:"diagnostic-init",id:a,creationDate:d.getProps().dataSinceDate,...m()}),g=setTimeout(y,l))},p.stop=()=>{g&&clearTimeout(g)},p.setStreaming=e=>{v=e},p}};var mt=function(e,t){let n=!1;const r={type:e.type,name:e.name,method:(...o)=>{try{e.method(...o)}catch{n||(n=!0,t.warn(le.inspectorMethodError(r.type,r.name)))}}};return r};const{onNextTick:ht}=L,yt={flagUsed:"flag-used",flagDetailsChanged:"flag-details-changed",flagDetailChanged:"flag-detail-changed",clientIdentityChanged:"client-identity-changed"};Object.freeze(yt);var wt={InspectorTypes:yt,InspectorManager:function(e,t){const n={},r={[yt.flagUsed]:[],[yt.flagDetailsChanged]:[],[yt.flagDetailChanged]:[],[yt.clientIdentityChanged]:[]},o=e&&e.map((e=>mt(e,t)));return o&&o.forEach((e=>{Object.prototype.hasOwnProperty.call(r,e.type)?r[e.type].push(e):t.warn(le.invalidInspector(e.type,e.name))})),n.hasListeners=e=>r[e]&&r[e].length,n.onFlagUsed=(e,t,n)=>{r[yt.flagUsed].length&&ht((()=>{r[yt.flagUsed].forEach((r=>r.method(e,t,n)))}))},n.onFlags=e=>{r[yt.flagDetailsChanged].length&&ht((()=>{r[yt.flagDetailsChanged].forEach((t=>t.method(e)))}))},n.onFlagChanged=(e,t)=>{r[yt.flagDetailChanged].length&&ht((()=>{r[yt.flagDetailChanged].forEach((n=>n.method(e,t)))}))},n.onIdentityChanged=e=>{r[yt.clientIdentityChanged].length&&ht((()=>{r[yt.clientIdentityChanged].forEach((t=>t.method(e)))}))},n}};const{commonBasicLogger:bt}=se,{checkContext:kt,getContextKeys:Et}=Se,{InspectorTypes:Dt,InspectorManager:Ct}=wt,xt="change",Pt="internal-change";var St={initialize:function(e,t,n,r,o){const i=function(){if(n&&n.logger)return n.logger;return o&&o.logger&&o.logger.default||bt("warn")}(),a=Ve(i),s=Ke(a),u=me.validate(n,a,o,i),l=Ct(u.inspectors,i),d=u.sendEvents;let f=e,g=u.hash;const v=ze(r.localStorage,i),p=De(r,f,u),m=u.sendEvents&&!u.diagnosticOptOut,h=m?pt.DiagnosticId(f):null,y=m?pt.DiagnosticsAccumulator((new Date).getTime()):null,w=m?pt.DiagnosticsManager(r,v,y,p,f,u,h):null,b=tt(r,u,f,y),k=u.eventProcessor||$e(r,u,f,y,a,p),E=at(r,u,f);let D,C,x,P={},S=u.streaming,I=!1,O=!1,T=!0;const U=u.stateProvider,R=st(null,(function(e){(function(e){if(U)return;e&&F({kind:"identify",context:e,creationDate:(new Date).getTime()})})(e),l.hasListeners(Dt.clientIdentityChanged)&&l.onIdentityChanged(R.getContext())})),A=new dt(v),j=v.isEnabled()?_e(v,f,g,R):null;function F(e){f&&(U&&U.enqueueEvent&&U.enqueueEvent(e)||(e.context?(T=!1,!d||O||r.isDoNotTrack()||(i.debug(le.debugEnqueueingEvent(e.kind)),k.enqueue(e))):T&&(i.warn(le.eventWithoutContext()),T=!1)))}function N(e,t){l.hasListeners(Dt.flagDetailChanged)&&l.onFlagChanged(e.key,q(t))}function $(){l.hasListeners(Dt.flagDetailsChanged)&&l.onFlags(Object.entries(P).map((([e,t])=>({key:e,detail:q(t)}))).reduce(((e,t)=>(e[t.key]=t.detail,e)),{}))}function V(e,t,n,r){const o=R.getContext(),i=new Date,a={kind:"feature",key:e,context:o,value:t?t.value:null,variation:t?t.variationIndex:null,default:n,creationDate:i.getTime()},s=P[e];s&&(a.version=s.flagVersion?s.flagVersion:s.version,a.trackEvents=s.trackEvents,a.debugEventsUntilDate=s.debugEventsUntilDate),(r||s&&s.trackReason)&&t&&(a.reason=t.reason),F(a)}function H(e){return kt(e,!1)?Promise.resolve(e):Promise.reject(new c.LDInvalidUserError(le.invalidContext()))}function M(e,t,n,r,o){let i;if(P&&L.objectHasOwnProperty(P,e)&&P[e]&&!P[e].deleted){const n=P[e];i=q(n),null!==n.value&&void 0!==n.value||(i.value=t)}else i={value:t,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}};return n&&V(e,i,t,r),o||function(e,t){l.hasListeners(Dt.flagUsed)&&l.onFlagUsed(e,t,R.getContext())}(e,i),i}function q(e){return{value:e.value,variationIndex:void 0===e.variation?null:e.variation,reason:e.reason||null}}function K(){if(C=!0,!R.getContext())return;const e=e=>{try{return JSON.parse(e)}catch(e){return void a.maybeReportError(new c.LDInvalidDataError(le.invalidData()))}};b.connect(R.getContext(),g,{ping:function(){i.debug(le.debugStreamPing());const e=R.getContext();E.fetchFlagSettings(e,g).then((t=>{L.deepEquals(e,R.getContext())&&z(t||{})})).catch((e=>{a.maybeReportError(new c.LDFlagFetchError(le.errorFetchingFlags(e)))}))},put:function(t){const n=e(t.data);n&&(i.debug(le.debugStreamPut()),z(n))},patch:function(t){const n=e(t.data);if(!n)return;const r=P[n.key];if(!r||!r.version||!n.version||r.version<n.version){i.debug(le.debugStreamPatch(n.key));const e={},t=L.extend({},n);delete t.key,P[n.key]=t;const o=q(t);e[n.key]=r?{previous:r.value,current:o}:{current:o},J(e),N(n,t)}else i.debug(le.debugStreamPatchIgnored(n.key))},delete:function(t){const n=e(t.data);if(n)if(!P[n.key]||P[n.key].version<n.version){i.debug(le.debugStreamDelete(n.key));const e={};P[n.key]&&!P[n.key].deleted&&(e[n.key]={previous:P[n.key].value}),P[n.key]={version:n.version,deleted:!0},N(n,P[n.key]),J(e)}else i.debug(le.debugStreamDeleteIgnored(n.key))}})}function _(){C&&(b.disconnect(),C=!1)}function z(e){const t={};if(!e)return Promise.resolve();for(const n in P)L.objectHasOwnProperty(P,n)&&P[n]&&(e[n]&&!L.deepEquals(e[n].value,P[n].value)?t[n]={previous:P[n].value,current:q(e[n])}:e[n]&&!e[n].deleted||(t[n]={previous:P[n].value}));for(const n in e)L.objectHasOwnProperty(e,n)&&e[n]&&(!P[n]||P[n].deleted)&&(t[n]={current:q(e[n])});return P={...e},$(),J(t).catch((()=>{}))}function J(e){const t=Object.keys(e);if(t.length>0){const n={};t.forEach((t=>{const r=e[t].current,o=r?r.value:void 0,i=e[t].previous;a.emit(xt+":"+t,o,i),n[t]=r?{current:o,previous:i}:{previous:i}})),a.emit(xt,n),a.emit(Pt,P),u.sendEventsOnlyForVariation||U||t.forEach((t=>{V(t,e[t].current)}))}return D&&j?j.saveFlags(P):Promise.resolve()}function B(){const e=S||x&&void 0===S;e&&!C?K():!e&&C&&_(),w&&w.setStreaming(e)}function G(e){return e===xt||e.substr(0,xt.length+1)===xt+":"}if("string"==typeof u.bootstrap&&"LOCALSTORAGE"===u.bootstrap.toUpperCase()&&(j?D=!0:i.warn(le.localStorageUnavailable())),"object"==typeof u.bootstrap&&(P=function(e){const t=Object.keys(e),n="$flagsState",r="$valid",o=e[n];!o&&t.length&&i.warn(le.bootstrapOldFormat()),!1===e[r]&&i.warn(le.bootstrapInvalid());const a={};return t.forEach((t=>{if(t!==n&&t!==r){let n={value:e[t]};o&&o[t]?n=L.extend(n,o[t]):n.version=0,a[t]=n}})),a}(u.bootstrap)),U){const e=U.getInitialState();e?W(e):U.on("init",W),U.on("update",(function(e){e.context&&R.setContext(e.context);e.flags&&z(e.flags)}))}else(function(){if(!e)return Promise.reject(new c.LDInvalidEnvironmentIdError(le.environmentNotSpecified()));return A.processContext(t).then(H).then((e=>(R.setContext(e),"object"==typeof u.bootstrap?X():D?j.loadFlags().then((e=>null==e?(P={},E.fetchFlagSettings(R.getContext(),g).then((e=>z(e||{}))).then(X).catch((e=>{Q(new c.LDFlagFetchError(le.errorFetchingFlags(e)))}))):(P=e,L.onNextTick(X),E.fetchFlagSettings(R.getContext(),g).then((e=>z(e))).catch((e=>a.maybeReportError(e)))))):E.fetchFlagSettings(R.getContext(),g).then((e=>{P=e||{},$(),X()})).catch((e=>{P={},Q(e)})))))})().catch(Q);function W(e){f=e.environment,R.setContext(e.context),P={...e.flags},L.onNextTick(X)}function X(){i.info(le.clientInitialized()),I=!0,B(),s.signalSuccess()}function Q(e){s.signalFailure(e)}const Y={waitForInitialization:()=>s.getInitializationPromise(),waitUntilReady:()=>s.getReadyPromise(),identify:function(e,t,n){if(O)return L.wrapPromiseCallback(Promise.resolve({}),n);if(U)return i.warn(le.identifyDisabled()),L.wrapPromiseCallback(Promise.resolve(L.transformVersionedValuesToValues(P)),n);const r=D&&j?j.clearFlags():Promise.resolve();return L.wrapPromiseCallback(r.then((()=>A.processContext(e))).then(H).then((e=>E.fetchFlagSettings(e,t).then((n=>{const r=L.transformVersionedValuesToValues(n);return R.setContext(e),g=t,n?z(n).then((()=>r)):r})))).then((e=>(C&&K(),e))).catch((e=>(a.maybeReportError(e),Promise.reject(e)))),n)},getContext:function(){return R.getContext()},variation:function(e,t){return M(e,t,!0,!1,!1).value},variationDetail:function(e,t){return M(e,t,!0,!0,!1)},track:function(e,t,n){if("string"!=typeof e)return void a.maybeReportError(new c.LDInvalidEventKeyError(le.unknownCustomEventKey(e)));r.customEventFilter&&!r.customEventFilter(e)&&i.warn(le.unknownCustomEventKey(e));const o=R.getContext(),s={kind:"custom",key:e,context:o,url:r.getCurrentUrl(),creationDate:(new Date).getTime()};o&&o.anonymous&&(s.contextKind=o.anonymous?"anonymousUser":"user"),null!=t&&(s.data=t),null!=n&&(s.metricValue=n),F(s)},on:function(e,t,n){G(e)?(x=!0,I&&B(),a.on(e,t,n)):a.on(...arguments)},off:function(e){if(a.off(...arguments),G(e)){let e=!1;a.getEvents().forEach((t=>{G(t)&&a.getEventListenerCount(t)>0&&(e=!0)})),e||(x=!1,C&&void 0===S&&_())}},setStreaming:function(e){const t=null===e?void 0:e;t!==S&&(S=t,B())},flush:function(e){return L.wrapPromiseCallback(d?k.flush():Promise.resolve(),e)},allFlags:function(){const e={};if(!P)return e;for(const t in P)L.objectHasOwnProperty(P,t)&&!P[t].deleted&&(e[t]=M(t,null,!u.sendEventsOnlyForVariation,!1,!0).value);return e},close:function(e){if(O)return L.wrapPromiseCallback(Promise.resolve(),e);const t=()=>{O=!0,P={}},n=Promise.resolve().then((()=>{if(_(),w&&w.stop(),d)return k.stop(),k.flush()})).then(t).catch(t);return L.wrapPromiseCallback(n,e)}};return{client:Y,options:u,emitter:a,ident:R,logger:i,requestor:E,start:function(){d&&(w&&w.start(),k.start())},enqueueEvent:F,getFlagsInternal:function(){return P},getEnvironmentId:()=>f,internalChangeEventName:Pt}},commonBasicLogger:bt,errors:c,messages:le,utils:L,getContextKeys:Et},It=St.initialize,Ot=St.errors,Lt=St.messages,Tt=St.getContextKeys;function Ut(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Rt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ut(Object(n),!0).forEach((function(t){At(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ut(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function At(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var jt=St.commonBasicLogger;var Ft=function(e){return jt(Rt({destination:console.log},e))};var Nt={promise:Promise.resolve({status:200,header:function(){return null},body:null})};function $t(e,t,n,r,o){if(o&&!function(){var e=window.navigator&&window.navigator.userAgent;if(e){var t=e.match(/Chrom(e|ium)\/([0-9]+)\./);if(t)return parseInt(t[2],10)<73}return!0}())return Nt;var i=new window.XMLHttpRequest;for(var a in i.open(e,t,!o),n||{})Object.prototype.hasOwnProperty.call(n,a)&&i.setRequestHeader(a,n[a]);if(o)return i.send(r),Nt;var s,c=new Promise((function(e,t){i.addEventListener("load",(function(){s||e({status:i.status,header:function(e){return i.getResponseHeader(e)},body:i.responseText})})),i.addEventListener("error",(function(){s||t(new Error)})),i.send(r)}));return{promise:c,cancel:function(){s=!0,i.abort()}}}var Vt=e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")};function Ht(e,t,n,r){var o,i,a=(("substring"===e.kind||"regex"===e.kind)&&r.includes("/")?t:t.replace(r,"")).replace(n,"");switch(e.kind){case"exact":i=t,o=new RegExp("^"+Vt(e.url)+"/?$");break;case"canonical":i=a,o=new RegExp("^"+Vt(e.url)+"/?$");break;case"substring":i=a,o=new RegExp(".*"+Vt(e.substring)+".*$");break;case"regex":i=a,o=new RegExp(e.pattern);break;default:return!1}return o.test(i)}function Mt(e,t){for(var n={},r=null,o=[],i=0;i<e.length;i++)for(var a=e[i],s=a.urls||[],c=0;c<s.length;c++)if(Ht(s[c],window.location.href,window.location.search,window.location.hash)){"pageview"===a.kind?t("pageview",a):(o.push(a),t("click_pageview",a));break}return o.length>0&&(r=function(e){for(var n=function(e,t){for(var n=[],r=0;r<t.length;r++)for(var o=e.target,i=t[r],a=i.selector,s=document.querySelectorAll(a);o&&s.length>0;){for(var c=0;c<s.length;c++)o===s[c]&&n.push(i);o=o.parentNode}return n}(e,o),r=0;r<n.length;r++)t("click",n[r])},document.addEventListener("click",r)),n.dispose=function(){document.removeEventListener("click",r)},n}var qt=300;function Kt(e,t){var n,r;function o(){r&&r.dispose(),n&&n.length&&(r=Mt(n,i))}function i(t,n){var r=e.ident.getContext(),o={kind:t,key:n.key,data:null,url:window.location.href,creationDate:(new Date).getTime(),contextKeys:Tt(r)};return"click"===t&&(o.selector=n.selector),e.enqueueEvent(o)}return e.requestor.fetchJSON("/sdk/goals/"+e.getEnvironmentId()).then((function(e){e&&e.length>0&&(r=Mt(n=e,i),function(e,t){var n,r=window.location.href;function o(){(n=window.location.href)!==r&&(r=n,t())}!function e(t,n){t(),setTimeout((function(){e(t,n)}),n)}(o,e),window.history&&window.history.pushState?window.addEventListener("popstate",o):window.addEventListener("hashchange",o)}(qt,o)),t()})).catch((function(n){e.emitter.maybeReportError(new Ot.LDUnexpectedResponseError((n&&n.message,n.message))),t()})),{}}var _t="goalsReady",zt={fetchGoals:{default:!0},hash:{type:"string"},eventProcessor:{type:"object"},eventUrlTransformer:{type:"function"},disableSyncEventPost:{default:!1}};function Jt(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var t,n={userAgentHeaderName:"X-LaunchDarkly-User-Agent",synchronousFlush:!1};if(window.XMLHttpRequest){var r=e&&e.disableSyncEventPost;n.httpRequest=function(e,t,o,i){var a=n.synchronousFlush&!r;return n.synchronousFlush=!1,$t(e,t,o,i,a)}}n.httpAllowsPost=function(){return void 0===t&&(t=!!window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest),t},n.httpFallbackPing=function(e){(new window.Image).src=e};var o,i=e&&e.eventUrlTransformer;n.getCurrentUrl=function(){return i?i(window.location.href):window.location.href},n.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&&(n.localStorage={get:function(e){return new Promise((function(t){t(window.localStorage.getItem(e))}))},set:function(e,t){return new Promise((function(n){window.localStorage.setItem(e,t),n()}))},clear:function(e){return new Promise((function(t){window.localStorage.removeItem(e),t()}))}})}catch(e){n.localStorage=null}if(e&&e.useReport&&"function"==typeof window.EventSourcePolyfill&&window.EventSourcePolyfill.supportedOptions&&window.EventSourcePolyfill.supportedOptions.method?(n.eventSourceAllowsReport=!0,o=window.EventSourcePolyfill):(n.eventSourceAllowsReport=!1,o=window.EventSource),window.EventSource){var a=3e5;n.eventSourceFactory=function(e,t){var n=Rt(Rt({},{heartbeatTimeout:a,silentTimeout:a,skipDefaultHeaders:!0}),t);return new o(e,n)},n.eventSourceIsActive=function(e){return e.readyState===window.EventSource.OPEN||e.readyState===window.EventSource.CONNECTING}}return n.userAgent="JSClient",n.version="3.1.2",n.diagnosticSdkData={name:"js-client-sdk",version:"3.1.2"},n.diagnosticPlatformData={name:"JS"},n.diagnosticUseCombinedEvent=!0,n}(n),o=It(e,t,n,r,zt),i=o.client,a=o.options,s=o.emitter,c=new Promise((function(e){var t=s.on(_t,(function(){s.off(_t,t),e()}))}));i.waitUntilGoalsReady=function(){return c},a.fetchGoals?Kt(o,(function(){return s.emit(_t)})):s.emit(_t),"complete"!==document.readyState?window.addEventListener("load",o.start):o.start();var u=function(){r.synchronousFlush=!0,i.flush().catch((function(){})),r.synchronousFlush=!1};return document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&u()})),window.addEventListener("pagehide",u),i}var Bt=Ft,Gt="3.1.2";var Wt={initialize:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return console&&console.warn&&console.warn(Lt.deprecated("default export","named LDClient export")),Jt(e,t,n)},version:Gt};e.basicLogger=Bt,e.createConsoleLogger=undefined,e.default=Wt,e.initialize=Jt,e.version=Gt,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ldclient.min.js.map
{
"name": "launchdarkly-js-client-sdk",
"version": "3.1.1",
"version": "3.1.2",
"description": "LaunchDarkly SDK for JavaScript",

@@ -80,3 +80,3 @@ "author": "LaunchDarkly <team@launchdarkly.com>",

"escape-string-regexp": "^4.0.0",
"launchdarkly-js-sdk-common": "5.0.2"
"launchdarkly-js-sdk-common": "5.0.3"
},

@@ -83,0 +83,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc