UNPKG

launchdarkly-vue-client-sdk

Version:
1 lines 59.5 kB
(function(K,X){typeof exports=="object"&&typeof module<"u"?X(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],X):(K=typeof globalThis<"u"?globalThis:K||self,X(K["launchdarkly-vue-client-sdk"]={},K.Vue))})(this,function(K,X){"use strict";function Z(t){function e(i,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=i,this.code=n}return e.prototype=new Error,e.prototype.name=t,e.prototype.constructor=e,e}const Me=Z("LaunchDarklyUnexpectedResponseError"),qe=Z("LaunchDarklyInvalidEnvironmentIdError"),_e=Z("LaunchDarklyInvalidUserError"),ze=Z("LaunchDarklyInvalidEventKeyError"),Je=Z("LaunchDarklyInvalidArgumentError"),Ke=Z("LaunchDarklyFlagFetchError");for(var j={LDUnexpectedResponseError:Me,LDInvalidEnvironmentIdError:qe,LDInvalidUserError:_e,LDInvalidEventKeyError:ze,LDInvalidArgumentError:Je,LDInvalidDataError:Z("LaunchDarklyInvalidDataError"),LDFlagFetchError:Ke,LDTimeoutError:Z("LaunchDarklyTimeoutError"),isHttpErrorRecoverable:function(t){return!(t>=400&&t<500)||t===400||t===408||t===429}},Be=function(t){var e=ne(t),i=e[0],n=e[1];return 3*(i+n)/4-n},Ge=function(t){var e,i,n=ne(t),u=n[0],r=n[1],o=new Xe(function(c,f,l){return 3*(f+l)/4-l}(0,u,r)),a=0,s=r>0?u-4:u;for(i=0;i<s;i+=4)e=G[t.charCodeAt(i)]<<18|G[t.charCodeAt(i+1)]<<12|G[t.charCodeAt(i+2)]<<6|G[t.charCodeAt(i+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return r===2&&(e=G[t.charCodeAt(i)]<<2|G[t.charCodeAt(i+1)]>>4,o[a++]=255&e),r===1&&(e=G[t.charCodeAt(i)]<<10|G[t.charCodeAt(i+1)]<<4|G[t.charCodeAt(i+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},We=function(t){for(var e,i=t.length,n=i%3,u=[],r=16383,o=0,a=i-n;o<a;o+=r)u.push(Ye(t,o,o+r>a?a:o+r));return n===1?(e=t[i-1],u.push(Y[e>>2]+Y[e<<4&63]+"==")):n===2&&(e=(t[i-2]<<8)+t[i-1],u.push(Y[e>>10]+Y[e>>4&63]+Y[e<<2&63]+"=")),u.join("")},Y=[],G=[],Xe=typeof Uint8Array<"u"?Uint8Array:Array,ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",nt=0;nt<64;++nt)Y[nt]=ee[nt],G[ee.charCodeAt(nt)]=nt;function ne(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return i===-1&&(i=e),[i,i===e?0:4-i%4]}function Ye(t,e,i){for(var n,u,r=[],o=e;o<i;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),r.push(Y[(u=n)>>18&63]+Y[u>>12&63]+Y[u>>6&63]+Y[63&u]);return r.join("")}G[45]=62,G[95]=63;var Qe={byteLength:Be,toByteArray:Ge,fromByteArray:We},re=Array.isArray,oe=Object.keys,Ze=Object.prototype.hasOwnProperty,tn=function t(e,i){if(e===i)return!0;if(e&&i&&typeof e=="object"&&typeof i=="object"){var n,u,r,o=re(e),a=re(i);if(o&&a){if((u=e.length)!=i.length)return!1;for(n=u;n--!==0;)if(!t(e[n],i[n]))return!1;return!0}if(o!=a)return!1;var s=e instanceof Date,c=i instanceof Date;if(s!=c)return!1;if(s&&c)return e.getTime()==i.getTime();var f=e instanceof RegExp,l=i instanceof RegExp;if(f!=l)return!1;if(f&&l)return e.toString()==i.toString();var g=oe(e);if((u=g.length)!==oe(i).length)return!1;for(n=u;n--!==0;)if(!Ze.call(i,g[n]))return!1;for(n=u;n--!==0;)if(!t(e[r=g[n]],i[r]))return!1;return!0}return e!=e&&i!=i};const en=["key","ip","country","email","firstName","lastName","avatar","name"];function ie(t){const e=unescape(encodeURIComponent(t));return Qe.fromByteArray(function(i){const n=[];for(let u=0;u<i.length;u++)n.push(i.charCodeAt(u));return n}(e))}function St(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var xt,S={appendUrlPath:function(t,e){return(t.endsWith("/")?t.substring(0,t.length-1):t)+(e.startsWith("/")?"":"/")+e},base64URLEncode:function(t){return ie(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},btoa:ie,clone:function(t){return JSON.parse(JSON.stringify(t))},deepEquals:function(t,e){return tn(t,e)},extend:function(...t){return t.reduce((e,i)=>({...e,...i}),{})},getLDUserAgentString:function(t){const e=t.version||"?";return t.userAgent+"/"+e},objectHasOwnProperty:St,onNextTick:function(t){setTimeout(t,0)},sanitizeContext:function(t){if(!t)return t;let e;return t.kind!==null&&t.kind!==void 0||en.forEach(i=>{const n=t[i];n!==void 0&&typeof n!="string"&&(e=e||{...t},e[i]=String(n))}),e||t},transformValuesToVersionedValues:function(t){const e={};for(const i in t)St(t,i)&&(e[i]={value:t[i],version:0});return e},transformVersionedValuesToValues:function(t){const e={};for(const i in t)St(t,i)&&(e[i]=t[i].value);return e},wrapPromiseCallback:function(t,e){const i=t.then(n=>(e&&setTimeout(()=>{e(null,n)},0),n),n=>{if(!e)return Promise.reject(n);setTimeout(()=>{e(n,null)},0)});return e?void 0:i},once:function(t){let e,i=!1;return function(...n){return i||(i=!0,e=t.apply(this,n)),e}}},nn=new Uint8Array(16);function ae(){if(!xt&&!(xt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return xt(nn)}var rn=/^(?:[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 ft(t){return typeof t=="string"&&rn.test(t)}for(var se,Pt,H=[],Ct=0;Ct<256;++Ct)H.push((Ct+256).toString(16).substr(1));function dt(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=(H[t[e+0]]+H[t[e+1]]+H[t[e+2]]+H[t[e+3]]+"-"+H[t[e+4]]+H[t[e+5]]+"-"+H[t[e+6]]+H[t[e+7]]+"-"+H[t[e+8]]+H[t[e+9]]+"-"+H[t[e+10]]+H[t[e+11]]+H[t[e+12]]+H[t[e+13]]+H[t[e+14]]+H[t[e+15]]).toLowerCase();if(!ft(i))throw TypeError("Stringified UUID is invalid");return i}var Lt=0,Tt=0;function ue(t){if(!ft(t))throw TypeError("Invalid UUID");var e,i=new Uint8Array(16);return i[0]=(e=parseInt(t.slice(0,8),16))>>>24,i[1]=e>>>16&255,i[2]=e>>>8&255,i[3]=255&e,i[4]=(e=parseInt(t.slice(9,13),16))>>>8,i[5]=255&e,i[6]=(e=parseInt(t.slice(14,18),16))>>>8,i[7]=255&e,i[8]=(e=parseInt(t.slice(19,23),16))>>>8,i[9]=255&e,i[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,i[11]=e/4294967296&255,i[12]=e>>>24&255,i[13]=e>>>16&255,i[14]=e>>>8&255,i[15]=255&e,i}function ce(t,e,i){function n(u,r,o,a){if(typeof u=="string"&&(u=function(f){f=unescape(encodeURIComponent(f));for(var l=[],g=0;g<f.length;++g)l.push(f.charCodeAt(g));return l}(u)),typeof r=="string"&&(r=ue(r)),r.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var s=new Uint8Array(16+u.length);if(s.set(r),s.set(u,r.length),(s=i(s))[6]=15&s[6]|e,s[8]=63&s[8]|128,o){a=a||0;for(var c=0;c<16;++c)o[a+c]=s[c];return o}return dt(s)}try{n.name=t}catch{}return n.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",n.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",n}function le(t){return 14+(t+64>>>9<<4)+1}function tt(t,e){var i=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(i>>16)<<16|65535&i}function gt(t,e,i,n,u,r){return tt((o=tt(tt(e,t),tt(n,r)))<<(a=u)|o>>>32-a,i);var o,a}function q(t,e,i,n,u,r,o){return gt(e&i|~e&n,t,e,u,r,o)}function _(t,e,i,n,u,r,o){return gt(e&n|i&~n,t,e,u,r,o)}function z(t,e,i,n,u,r,o){return gt(e^i^n,t,e,u,r,o)}function J(t,e,i,n,u,r,o){return gt(i^(e|~n),t,e,u,r,o)}var on=ce("v3",48,function(t){if(typeof t=="string"){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var i=0;i<e.length;++i)t[i]=e.charCodeAt(i)}return function(n){for(var u=[],r=32*n.length,o="0123456789abcdef",a=0;a<r;a+=8){var s=n[a>>5]>>>a%32&255,c=parseInt(o.charAt(s>>>4&15)+o.charAt(15&s),16);u.push(c)}return u}(function(n,u){n[u>>5]|=128<<u%32,n[le(u)-1]=u;for(var r=1732584193,o=-271733879,a=-1732584194,s=271733878,c=0;c<n.length;c+=16){var f=r,l=o,g=a,h=s;r=q(r,o,a,s,n[c],7,-680876936),s=q(s,r,o,a,n[c+1],12,-389564586),a=q(a,s,r,o,n[c+2],17,606105819),o=q(o,a,s,r,n[c+3],22,-1044525330),r=q(r,o,a,s,n[c+4],7,-176418897),s=q(s,r,o,a,n[c+5],12,1200080426),a=q(a,s,r,o,n[c+6],17,-1473231341),o=q(o,a,s,r,n[c+7],22,-45705983),r=q(r,o,a,s,n[c+8],7,1770035416),s=q(s,r,o,a,n[c+9],12,-1958414417),a=q(a,s,r,o,n[c+10],17,-42063),o=q(o,a,s,r,n[c+11],22,-1990404162),r=q(r,o,a,s,n[c+12],7,1804603682),s=q(s,r,o,a,n[c+13],12,-40341101),a=q(a,s,r,o,n[c+14],17,-1502002290),r=_(r,o=q(o,a,s,r,n[c+15],22,1236535329),a,s,n[c+1],5,-165796510),s=_(s,r,o,a,n[c+6],9,-1069501632),a=_(a,s,r,o,n[c+11],14,643717713),o=_(o,a,s,r,n[c],20,-373897302),r=_(r,o,a,s,n[c+5],5,-701558691),s=_(s,r,o,a,n[c+10],9,38016083),a=_(a,s,r,o,n[c+15],14,-660478335),o=_(o,a,s,r,n[c+4],20,-405537848),r=_(r,o,a,s,n[c+9],5,568446438),s=_(s,r,o,a,n[c+14],9,-1019803690),a=_(a,s,r,o,n[c+3],14,-187363961),o=_(o,a,s,r,n[c+8],20,1163531501),r=_(r,o,a,s,n[c+13],5,-1444681467),s=_(s,r,o,a,n[c+2],9,-51403784),a=_(a,s,r,o,n[c+7],14,1735328473),r=z(r,o=_(o,a,s,r,n[c+12],20,-1926607734),a,s,n[c+5],4,-378558),s=z(s,r,o,a,n[c+8],11,-2022574463),a=z(a,s,r,o,n[c+11],16,1839030562),o=z(o,a,s,r,n[c+14],23,-35309556),r=z(r,o,a,s,n[c+1],4,-1530992060),s=z(s,r,o,a,n[c+4],11,1272893353),a=z(a,s,r,o,n[c+7],16,-155497632),o=z(o,a,s,r,n[c+10],23,-1094730640),r=z(r,o,a,s,n[c+13],4,681279174),s=z(s,r,o,a,n[c],11,-358537222),a=z(a,s,r,o,n[c+3],16,-722521979),o=z(o,a,s,r,n[c+6],23,76029189),r=z(r,o,a,s,n[c+9],4,-640364487),s=z(s,r,o,a,n[c+12],11,-421815835),a=z(a,s,r,o,n[c+15],16,530742520),r=J(r,o=z(o,a,s,r,n[c+2],23,-995338651),a,s,n[c],6,-198630844),s=J(s,r,o,a,n[c+7],10,1126891415),a=J(a,s,r,o,n[c+14],15,-1416354905),o=J(o,a,s,r,n[c+5],21,-57434055),r=J(r,o,a,s,n[c+12],6,1700485571),s=J(s,r,o,a,n[c+3],10,-1894986606),a=J(a,s,r,o,n[c+10],15,-1051523),o=J(o,a,s,r,n[c+1],21,-2054922799),r=J(r,o,a,s,n[c+8],6,1873313359),s=J(s,r,o,a,n[c+15],10,-30611744),a=J(a,s,r,o,n[c+6],15,-1560198380),o=J(o,a,s,r,n[c+13],21,1309151649),r=J(r,o,a,s,n[c+4],6,-145523070),s=J(s,r,o,a,n[c+11],10,-1120210379),a=J(a,s,r,o,n[c+2],15,718787259),o=J(o,a,s,r,n[c+9],21,-343485551),r=tt(r,f),o=tt(o,l),a=tt(a,g),s=tt(s,h)}return[r,o,a,s]}(function(n){if(n.length===0)return[];for(var u=8*n.length,r=new Uint32Array(le(u)),o=0;o<u;o+=8)r[o>>5]|=(255&n[o/8])<<o%32;return r}(t),8*t.length))}),an=on;function sn(t,e,i,n){switch(t){case 0:return e&i^~e&n;case 1:case 3:return e^i^n;case 2:return e&i^e&n^i&n}}function Ot(t,e){return t<<e|t>>>32-e}var un=ce("v5",80,function(t){var e=[1518500249,1859775393,2400959708,3395469782],i=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){var n=unescape(encodeURIComponent(t));t=[];for(var u=0;u<n.length;++u)t.push(n.charCodeAt(u))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var r=t.length/4+2,o=Math.ceil(r/16),a=new Array(o),s=0;s<o;++s){for(var c=new Uint32Array(16),f=0;f<16;++f)c[f]=t[64*s+4*f]<<24|t[64*s+4*f+1]<<16|t[64*s+4*f+2]<<8|t[64*s+4*f+3];a[s]=c}a[o-1][14]=8*(t.length-1)/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=8*(t.length-1)&4294967295;for(var l=0;l<o;++l){for(var g=new Uint32Array(80),h=0;h<16;++h)g[h]=a[l][h];for(var m=16;m<80;++m)g[m]=Ot(g[m-3]^g[m-8]^g[m-14]^g[m-16],1);for(var w=i[0],b=i[1],y=i[2],I=i[3],T=i[4],V=0;V<80;++V){var P=Math.floor(V/20),F=Ot(w,5)+sn(P,b,y,I)+T+e[P]+g[V]>>>0;T=I,I=y,y=Ot(b,30)>>>0,b=w,w=F}i[0]=i[0]+w>>>0,i[1]=i[1]+b>>>0,i[2]=i[2]+y>>>0,i[3]=i[3]+I>>>0,i[4]=i[4]+T>>>0}return[i[0]>>24&255,i[0]>>16&255,i[0]>>8&255,255&i[0],i[1]>>24&255,i[1]>>16&255,i[1]>>8&255,255&i[1],i[2]>>24&255,i[2]>>16&255,i[2]>>8&255,255&i[2],i[3]>>24&255,i[3]>>16&255,i[3]>>8&255,255&i[3],i[4]>>24&255,i[4]>>16&255,i[4]>>8&255,255&i[4]]}),cn=un,Ut=Object.freeze({__proto__:null,v1:function(t,e,i){var n=e&&i||0,u=e||new Array(16),r=(t=t||{}).node||se,o=t.clockseq!==void 0?t.clockseq:Pt;if(r==null||o==null){var a=t.random||(t.rng||ae)();r==null&&(r=se=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=Pt=16383&(a[6]<<8|a[7]))}var s=t.msecs!==void 0?t.msecs:Date.now(),c=t.nsecs!==void 0?t.nsecs:Tt+1,f=s-Lt+(c-Tt)/1e4;if(f<0&&t.clockseq===void 0&&(o=o+1&16383),(f<0||s>Lt)&&t.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Lt=s,Tt=c,Pt=o;var l=(1e4*(268435455&(s+=122192928e5))+c)%4294967296;u[n++]=l>>>24&255,u[n++]=l>>>16&255,u[n++]=l>>>8&255,u[n++]=255&l;var g=s/4294967296*1e4&268435455;u[n++]=g>>>8&255,u[n++]=255&g,u[n++]=g>>>24&15|16,u[n++]=g>>>16&255,u[n++]=o>>>8|128,u[n++]=255&o;for(var h=0;h<6;++h)u[n+h]=r[h];return e||dt(u)},v3:an,v4:function(t,e,i){var n=(t=t||{}).random||(t.rng||ae)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){i=i||0;for(var u=0;u<16;++u)e[i+u]=n[u];return e}return dt(n)},v5:cn,NIL:"00000000-0000-0000-0000-000000000000",version:function(t){if(!ft(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)},validate:ft,stringify:dt,parse:ue});const st=["debug","info","warn","error","none"];var Rt={commonBasicLogger:function(t,e){if(t&&t.destination&&typeof t.destination!="function")throw new Error("destination for basicLogger was set to a non-function");function i(c){return function(f){console&&console[c]&&console[c].call(console,f)}}const n=t&&t.destination?[t.destination,t.destination,t.destination,t.destination]:[i("log"),i("info"),i("warn"),i("error")],u=!(!t||!t.destination),r=t&&t.prefix!==void 0&&t.prefix!==null?t.prefix:"[LaunchDarkly] ";let o=1;if(t&&t.level)for(let c=0;c<st.length;c++)st[c]===t.level&&(o=c);function a(c,f,l){if(l.length<1)return;let g;const h=u?f+": "+r:r;if(l.length!==1&&e){const m=[...l];m[0]=h+m[0],g=e(...m)}else g=h+l[0];try{n[c](g)}catch(m){console&&console.log&&console.log("[LaunchDarkly] Configured logger's "+f+" method threw an exception: "+m)}}const s={};for(let c=0;c<st.length;c++){const f=st[c];if(f!=="none")if(c<o)s[f]=()=>{};else{const l=c;s[f]=function(){a(l,f,arguments)}}}return s},validateLogger:function(t){st.forEach(e=>{if(e!=="none"&&(!t[e]||typeof t[e]!="function"))throw new Error("Provided logger instance must support logger."+e+"(...) method")})}};function vt(t){return t&&t.message?t.message:typeof t=="string"||t instanceof String?t:JSON.stringify(t)}const rt=" Please see https://docs.launchdarkly.com/sdk/client-side/javascript#initialize-the-client for instructions on SDK initialization.";var E={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."+rt},clientInitialized:function(){return"LaunchDarkly client initialized"},clientNotReady:function(){return"LaunchDarkly client is not ready"},debugEnqueueingEvent:function(t){return'enqueueing "'+t+'" event'},debugPostingDiagnosticEvent:function(t){return"sending diagnostic event ("+t.kind+")"},debugPostingEvents:function(t){return"sending "+t+" events"},debugStreamDelete:function(t){return'received streaming deletion for flag "'+t+'"'},debugStreamDeleteIgnored:function(t){return'received streaming deletion for flag "'+t+'" but ignored due to version check'},debugStreamPatch:function(t){return'received streaming update for flag "'+t+'"'},debugStreamPatchIgnored:function(t){return'received streaming update for flag "'+t+'" but ignored due to version check'},debugStreamPing:function(){return"received ping message from stream"},debugPolling:function(t){return"polling for feature flags at "+t},debugStreamPut:function(){return"received streaming update for all flags"},deprecated:function(t,e){return e?'"'+t+'" is deprecated, please use "'+e+'"':'"'+t+'" is deprecated'},environmentNotFound:function(){return"Environment not found. Double check that you specified a valid environment/client-side ID."+rt},environmentNotSpecified:function(){return"No environment/client-side ID was specified."+rt},errorFetchingFlags:function(t){return"Error fetching flag settings: "+vt(t)},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(t,e,i){return"Received error "+t+(t===401?" (invalid SDK key)":"")+" for "+e+" - "+(j.isHttpErrorRecoverable(t)?i:"giving up permanently")},httpUnavailable:function(){return"Cannot make HTTP requests in this environment."+rt},identifyDisabled:function(){return"identify() has no effect here; it must be called on the main client instance"},inspectorMethodError:(t,e)=>`an inspector: "${e}" of type: "${t}" generated an exception`,invalidContentType:function(t){return'Expected application/json content type but got "'+t+'"'},invalidData:function(){return"Invalid data received from LaunchDarkly; connection may have been interrupted"},invalidInspector:(t,e)=>`an inspector: "${e}" of an invalid type (${t}) was configured`,invalidKey:function(){return"Event key must be a string"},invalidMetricValue:t=>`The track function was called with a non-numeric "metricValue" (${t}), only numeric metric values are supported.`,invalidContext:function(){return"Invalid context specified."+rt},invalidTagValue:t=>`Config option "${t}" must only contain letters, numbers, ., _ or -.`,localStorageUnavailable:function(t){return"local storage is unavailable: "+vt(t)},networkError:t=>"network error"+(t?" ("+t+")":""),optionBelowMinimum:(t,e,i)=>'Config option "'+t+'" was set to '+e+", changing to minimum value of "+i,streamClosing:function(){return"Closing stream connection"},streamConnecting:function(t){return"Opening stream connection to "+t},streamError:function(t,e){return"Error on stream connection: "+vt(t)+", will continue retrying after "+e+" milliseconds."},tagValueTooLong:t=>`Value of "${t}" was longer than 64 characters and was discarded.`,unknownCustomEventKey:function(t){return'Custom event "'+t+'" does not exist'},unknownOption:t=>'Ignoring unknown config option "'+t+'"',contextNotSpecified:function(){return"No context specified."+rt},unrecoverableStreamError:t=>`Error on stream connection ${vt(t)}, giving up permanently`,wrongOptionType:(t,e,i)=>'Config option "'+t+'" should be of type '+e+", got "+i+", using default value",wrongOptionTypeBoolean:(t,e)=>'Config option "'+t+'" should be a boolean, got '+e+", converting to boolean"};const{validateLogger:ln}=Rt,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(t,e,i){const n={};return e.id&&(n.id=de(`${t}.id`,e.id,i)),e.version&&(n.version=de(`${t}.version`,e.version,i)),n}},inspectors:{default:[]},hooks:{default:[]},plugins:{default:[]}},fn=/^(\w|\.|-)+$/;function At(t){return t&&t.replace(/\/+$/,"")}function de(t,e,i){if(typeof e=="string"&&e.match(fn)){if(!(e.length>64))return e;i.warn(E.tagValueTooLong(t))}else i.warn(E.invalidTagValue(t))}var Ft={baseOptionDefs:fe,validate:function(t,e,i,n){const u=S.extend({logger:{default:n}},fe,i),r={};function o(s){S.onNextTick(()=>{e&&e.maybeReportError(new j.LDInvalidArgumentError(s))})}let a=S.extend({},t||{});return function(s){const c=s;Object.keys(r).forEach(f=>{if(c[f]!==void 0){const l=r[f];n&&n.warn(E.deprecated(f,l)),l&&(c[l]===void 0&&(c[l]=c[f]),delete c[f])}})}(a),a=function(s){const c=S.extend({},s);return Object.keys(u).forEach(f=>{c[f]!==void 0&&c[f]!==null||(c[f]=u[f]&&u[f].default)}),c}(a),a=function(s){const c=S.extend({},s),f=l=>{if(l===null)return"any";if(l===void 0)return;if(Array.isArray(l))return"array";const g=typeof l;return g==="boolean"||g==="string"||g==="number"||g==="function"?g:"object"};return Object.keys(s).forEach(l=>{const g=s[l];if(g!=null){const h=u[l];if(h===void 0)o(E.unknownOption(l));else{const m=h.type||f(h.default),w=h.validator;if(w){const b=w(l,s[l],n);b!==void 0?c[l]=b:delete c[l]}else if(m!=="any"){const b=m.split("|"),y=f(g);b.indexOf(y)<0?m==="boolean"?(c[l]=!!g,o(E.wrongOptionTypeBoolean(l,y))):(o(E.wrongOptionType(l,m,y)),c[l]=h.default):y==="number"&&h.minimum!==void 0&&g<h.minimum&&(o(E.optionBelowMinimum(l,g,h.minimum)),c[l]=h.minimum)}}}}),c.baseUrl=At(c.baseUrl),c.streamUrl=At(c.streamUrl),c.eventsUrl=At(c.eventsUrl),c}(a),ln(a.logger),a},getTags:function(t){const e={};return t&&(t.application&&t.application.id!==void 0&&t.application.id!==null&&(e["application-id"]=[t.application.id]),t.application&&t.application.version!==void 0&&t.application.id!==null&&(e["application-version"]=[t.application.version])),e}};const{getLDUserAgentString:dn}=S;var Nt={getLDHeaders:function(t,e){if(e&&!e.sendLDHeaders)return{};const i={};i[t.userAgentHeaderName||"User-Agent"]=dn(t),e&&e.wrapperName&&(i["X-LaunchDarkly-Wrapper"]=e.wrapperVersion?e.wrapperName+"/"+e.wrapperVersion:e.wrapperName);const n=Ft.getTags(e),u=Object.keys(n);return u.length&&(i["x-launchdarkly-tags"]=u.sort().map(r=>Array.isArray(n[r])?n[r].sort().map(o=>`${r}/${o}`):[`${r}/${n[r]}`]).reduce((r,o)=>r.concat(o),[]).join(" ")),i},transformHeaders:function(t,e){return e&&e.requestHeaderTransform?e.requestHeaderTransform({...t}):t}};const{v1:gn}=Ut,{getLDHeaders:vn,transformHeaders:pn}=Nt;var ge=function(t,e,i){const n=S.extend({"Content-Type":"application/json"},vn(t,i)),u={};return u.sendEvents=(r,o,a)=>{if(!t.httpRequest)return Promise.resolve();const s=JSON.stringify(r),c=a?null:gn();return function f(l){const g=a?n:S.extend({},n,{"X-LaunchDarkly-Event-Schema":"4","X-LaunchDarkly-Payload-ID":c});return t.httpRequest("POST",o,pn(g,i),s).promise.then(h=>{if(h)return h.status>=400&&j.isHttpErrorRecoverable(h.status)&&l?f(!1):function(m){const w={status:m.status},b=m.header("date");if(b){const y=Date.parse(b);y&&(w.serverTime=y)}return w}(h)}).catch(()=>l?f(!1):Promise.reject())}(!0).catch(()=>{})},u},mn=function t(e,i=[]){if(e===null||typeof e!="object")return JSON.stringify(e);if(i.includes(e))throw new Error("Cycle detected");return Array.isArray(e)?`[${e.map(n=>t(n,[...i,e])).map(n=>n===void 0?"null":n).join(",")}]`:`{${Object.keys(e).sort().map(n=>{const u=t(e[n],[...i,e]);if(u!==void 0)return`${JSON.stringify(n)}:${u}`}).filter(n=>n!==void 0).join(",")}}`};const{commonBasicLogger:hn}=Rt;function ve(t){return typeof t=="string"&&t!=="kind"&&t.match(/^(\w|\.|-)+$/)}var pt={checkContext:function(t,e){if(t){if(e&&(t.kind===void 0||t.kind===null))return t.key!==void 0&&t.key!==null;const i=t.key,n=t.kind===void 0?"user":t.kind,u=ve(n),r=n==="multi"||i!=null&&i!=="";if(n==="multi"){const o=Object.keys(t).filter(a=>a!=="kind");return r&&o.every(a=>ve(a))&&o.every(a=>{const s=t[a].key;return s!=null&&s!==""})}return r&&u}return!1},getContextKeys:function(t,e=hn()){if(!t)return;const i={},{kind:n,key:u}=t;switch(n){case void 0:i.user=`${u}`;break;case"multi":Object.entries(t).filter(([r])=>r!=="kind").forEach(([r,o])=>{o&&o.key&&(i[r]=o.key)});break;case null:e.warn(`null is not a valid context kind: ${t}`);break;case"":e.warn(`'' is not a valid context kind: ${t}`);break;default:i[n]=`${u}`}return i},getContextKinds:function(t){return t?t.kind===null||t.kind===void 0?["user"]:t.kind!=="multi"?[t.kind]:Object.keys(t).filter(e=>e!=="kind"):[]}};const{getContextKinds:yn}=pt;var wn=function(){const t={};let e=0,i=0,n={},u={};return t.summarizeEvent=r=>{if(r.kind==="feature"){const o=r.key+":"+(r.variation!==null&&r.variation!==void 0?r.variation:"")+":"+(r.version!==null&&r.version!==void 0?r.version:""),a=n[o];let s=u[r.key];s||(s=new Set,u[r.key]=s),function(c){return c.context?yn(c.context):c.contextKeys?Object.keys(c.contextKeys):[]}(r).forEach(c=>s.add(c)),a?a.count=a.count+1:n[o]={count:1,key:r.key,version:r.version,variation:r.variation,value:r.value,default:r.default},(e===0||r.creationDate<e)&&(e=r.creationDate),r.creationDate>i&&(i=r.creationDate)}},t.getSummary=()=>{const r={};let o=!0;for(const a of Object.values(n)){let s=r[a.key];s||(s={default:a.default,counters:[],contextKinds:[...u[a.key]]},r[a.key]=s);const c={value:a.value,count:a.count};a.variation!==void 0&&a.variation!==null&&(c.variation=a.variation),a.version!==void 0&&a.version!==null?c.version=a.version:c.unknown=!0,s.counters.push(c),o=!1}return o?null:{startDate:e,endDate:i,features:r,kind:"summary"}},t.clearSummary=()=>{e=0,i=0,n={},u={}},t},bn=function(t){let e={},i={};return{summarizeEvent:function(n){if(n.kind==="feature"){const u=mn(n.context);if(!u)return;let r=e[u];r||(e[u]=wn(),r=e[u],i[u]=n.context),r.summarizeEvent(n)}},getSummaries:function(){const n=e,u=i;return e={},i={},Object.entries(n).map(([r,o])=>{const a=o.getSummary();return a.context=t.filter(u[r]),a})}}};function pe(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function me(t){return(t.startsWith("/")?t.substring(1):t).split("/").map(e=>e.indexOf("~")>=0?e.replace(/~1/g,"/").replace(/~0/g,"~"):e)}function he(t){return!t.startsWith("/")}function ye(t,e){const i=he(t),n=he(e);if(i&&n)return t===e;if(i){const u=me(e);return u.length===1&&t===u[0]}if(n){const u=me(t);return u.length===1&&e===u[0]}return t===e}function we(t){return`/${pe(t)}`}var jt={cloneExcluding:function(t,e){const i=[],n={},u=[];for(i.push(...Object.keys(t).map(r=>({key:r,ptr:we(r),source:t,parent:n,visited:[t]})));i.length;){const r=i.pop();if(e.some(o=>ye(o,r.ptr)))u.push(r.ptr);else{const o=r.source[r.key];if(o===null)r.parent[r.key]=o;else if(Array.isArray(o))r.parent[r.key]=[...o];else if(typeof o=="object"){if(r.visited.includes(o))continue;r.parent[r.key]={},i.push(...Object.keys(o).map(a=>{return{key:a,ptr:(s=r.ptr,c=pe(a),`${s}/${c}`),source:o,parent:r.parent[r.key],visited:[...r.visited,o]};var s,c}))}else r.parent[r.key]=o}}return{cloned:n,excluded:u.sort()}},compare:ye,literalToReference:we},kn=function(t){const e={},i=t.allAttributesPrivate,n=t.privateAttributes||[],u=["key","kind","_meta","anonymous"],r=["name","ip","firstName","lastName","email","avatar","country"],o=(a,s)=>{if(typeof a!="object"||a===null||Array.isArray(a))return;const{cloned:c,excluded:f}=jt.cloneExcluding(a,((l,g)=>(i||g&&l.anonymous?Object.keys(l):[...n,...l._meta&&l._meta.privateAttributes||[]]).filter(h=>!u.some(m=>jt.compare(h,m))))(a,s));return c.key=String(c.key),f.length&&(c._meta||(c._meta={}),c._meta.redactedAttributes=f),c._meta&&(delete c._meta.privateAttributes,Object.keys(c._meta).length===0&&delete c._meta),c.anonymous!==void 0&&(c.anonymous=!!c.anonymous),c};return e.filter=(a,s=!1)=>a.kind===void 0||a.kind===null?o((c=>{const f={...c.custom||{},kind:"user",key:c.key};c.anonymous!==void 0&&(f.anonymous=!!c.anonymous);for(const l of r)delete f[l],c[l]!==void 0&&c[l]!==null&&(f[l]=String(c[l]));return c.privateAttributeNames!==void 0&&c.privateAttributeNames!==null&&(f._meta=f._meta||{},f._meta.privateAttributes=c.privateAttributeNames.map(l=>l.startsWith("/")?jt.literalToReference(l):l)),f})(a),s):a.kind==="multi"?((c,f)=>{const l={kind:c.kind},g=Object.keys(c);for(const h of g)if(h!=="kind"){const m=o(c[h],f);m&&(l[h]=m)}return l})(a,s):o(a,s),e};const{getContextKeys:En}=pt;var Dn=function(t,e,i,n=null,u=null,r=null){const o={},a=r||ge(t,i,e),s=S.appendUrlPath(e.eventsUrl,"/events/bulk/"+i),c=kn(e),f=bn(c),l=e.samplingInterval,g=e.eventCapacity,h=e.flushInterval,m=e.logger;let w,b=[],y=0,I=!1,T=!1;function V(){return l===0||Math.floor(Math.random()*l)===0}function P(x){const C=S.extend({},x);return x.kind==="identify"||x.kind==="feature"||x.kind==="custom"?C.context=c.filter(x.context):(C.contextKeys=En(x.context,m),delete C.context),x.kind==="feature"&&(delete C.trackEvents,delete C.debugEventsUntilDate),C}function F(x){b.length<g?(b.push(x),T=!1):(T||(T=!0,m.warn(E.eventCapacityExceeded())),n&&n.incrementDroppedEvents())}return o.enqueue=function(x){if(I)return;let C=!1,W=!1;var L;if(f.summarizeEvent(x),x.kind==="feature"?V()&&(C=!!x.trackEvents,W=!!(L=x).debugEventsUntilDate&&L.debugEventsUntilDate>y&&L.debugEventsUntilDate>new Date().getTime()):C=V(),C&&F(P(x)),W){const O=S.extend({},x,{kind:"debug"});O.context=c.filter(O.context),delete O.trackEvents,delete O.debugEventsUntilDate,F(O)}},o.flush=async function(){if(I)return Promise.resolve();const x=b;return f.getSummaries().forEach(C=>{Object.keys(C.features).length&&x.push(C)}),n&&n.setEventsInLastBatch(x.length),x.length===0?Promise.resolve():(b=[],m.debug(E.debugPostingEvents(x.length)),a.sendEvents(x,s).then(C=>{C&&(C.serverTime&&(y=C.serverTime),j.isHttpErrorRecoverable(C.status)||(I=!0),C.status>=400&&S.onNextTick(()=>{u.maybeReportError(new j.LDUnexpectedResponseError(E.httpErrorMessage(C.status,"event posting","some events were dropped")))}))}))},o.start=function(){const x=()=>{o.flush(),w=setTimeout(x,h)};w=setTimeout(x,h)},o.stop=function(){clearTimeout(w)},o},In=function(t){const e={},i={};return e.on=function(n,u,r){i[n]=i[n]||[],i[n]=i[n].concat({handler:u,context:r})},e.off=function(n,u,r){if(i[n])for(let o=0;o<i[n].length;o++)i[n][o].handler===u&&i[n][o].context===r&&(i[n]=i[n].slice(0,o).concat(i[n].slice(o+1)))},e.emit=function(n){if(!i[n])return;const u=i[n].slice(0);for(let r=0;r<u.length;r++)u[r].handler.apply(u[r].context,Array.prototype.slice.call(arguments,1))},e.getEvents=function(){return Object.keys(i)},e.getEventListenerCount=function(n){return i[n]?i[n].length:0},e.maybeReportError=function(n){n&&(i.error?this.emit("error",n):(t||console).error(n.message))},e};const mt="ready",$t="initialized",Vt="failed";var Sn=function(t){let e=!1,i=!1,n=null,u=null;const r=new Promise(o=>{const a=()=>{t.off(mt,a),o()};t.on(mt,a)}).catch(()=>{});return{getInitializationPromise:()=>u||(e?Promise.resolve():i?Promise.reject(n):(u=new Promise((o,a)=>{const s=()=>{t.off($t,s),o()},c=f=>{t.off(Vt,c),a(f)};t.on($t,s),t.on(Vt,c)}),u)),getReadyPromise:()=>r,signalSuccess:()=>{e||i||(e=!0,t.emit($t),t.emit(mt))},signalFailure:o=>{e||i||(i=!0,n=o,t.emit(Vt,o),t.emit(mt)),t.maybeReportError(o)}}},xn=function(t,e,i,n){const u={};function r(){let o="";const a=n.getContext();return a&&(o=i||S.btoa(JSON.stringify(a))),"ld:"+e+":"+o}return u.loadFlags=()=>t.get(r()).then(o=>{if(o==null)return null;try{let a=JSON.parse(o);if(a){const s=a.$schema;s===void 0||s<1?a=S.transformValuesToVersionedValues(a):delete a.$schema}return a}catch{return u.clearFlags().then(()=>null)}}),u.saveFlags=o=>{const a=S.extend({},o,{$schema:1});return t.set(r(),JSON.stringify(a))},u.clearFlags=()=>t.clear(r()),u},Pn=function(t,e){const i={};let n=!1;const u=r=>{n||(n=!0,e.warn(E.localStorageUnavailable(r)))};return i.isEnabled=()=>!!t,i.get=r=>new Promise(o=>{t?t.get(r).then(o).catch(a=>{u(a),o(void 0)}):o(void 0)}),i.set=(r,o)=>new Promise(a=>{t?t.set(r,o).then(()=>a(!0)).catch(s=>{u(s),a(!1)}):a(!1)}),i.clear=r=>new Promise(o=>{t?t.clear(r).then(()=>o(!0)).catch(a=>{u(a),o(!1)}):o(!1)}),i};const{appendUrlPath:be,base64URLEncode:Cn,objectHasOwnProperty:Ln}=S,{getLDHeaders:Tn,transformHeaders:On}=Nt,{isHttpErrorRecoverable:Un}=j;var Rn=function(t,e,i,n){const u=e.streamUrl,r=e.logger,o={},a=be(u,"/eval/"+i),s=e.useReport,c=e.evaluationReasons,f=e.streamReconnectDelay,l=Tn(t,e);let g,h=!1,m=null,w=null,b=null,y=null,I=null,T=0;function V(){const L=(O=function(){const M=f*Math.pow(2,T);return M>3e4?3e4:M}(),O-Math.trunc(.5*Math.random()*O));var O;return T+=1,L}function P(L){if(L.status&&typeof L.status=="number"&&!Un(L.status))return C(),r.error(E.unrecoverableStreamError(L)),void(w&&(clearTimeout(w),w=null));const O=V();h||(r.warn(E.streamError(L,O)),h=!0),W(!1),C(),F(O)}function F(L){w||(L?w=setTimeout(x,L):x())}function x(){let L;w=null;let O="";const M={headers:l,readTimeoutMillis:3e5};if(t.eventSourceFactory){y!=null&&(O="h="+y),s?t.eventSourceAllowsReport?(L=a,M.method="REPORT",M.headers["Content-Type"]="application/json",M.body=JSON.stringify(b)):(L=be(u,"/ping/"+i),O=""):L=a+"/"+Cn(JSON.stringify(b)),M.headers=On(M.headers,e),c&&(O=O+(O?"&":"")+"withReasons=true"),L=L+(O?"?":"")+O,C(),r.info(E.streamConnecting(L)),g=new Date().getTime(),m=t.eventSourceFactory(L,M);for(const k in I)Ln(I,k)&&m.addEventListener(k,I[k]);m.onerror=P,m.onopen=()=>{T=0}}}function C(){m&&(r.info(E.streamClosing()),m.close(),m=null)}function W(L){g&&n&&n.recordStreamInit(g,!L,new Date().getTime()-g),g=null}return o.connect=function(L,O,M){b=L,y=O,I={};for(const k in M||{})I[k]=function(et){h=!1,W(!0),M[k]&&M[k](et)};F()},o.disconnect=function(){clearTimeout(w),w=null,C()},o.isConnected=function(){return!!(m&&t.eventSourceIsActive&&t.eventSourceIsActive(m))},o},An=function(t){let e,i,n,u;const r={addPromise:(o,a)=>{e=o,i&&i(),i=a,o.then(s=>{e===o&&(n(s),t&&t())},s=>{e===o&&(u(s),t&&t())})}};return r.resultPromise=new Promise((o,a)=>{n=o,u=a}),r};const{transformHeaders:Fn,getLDHeaders:Nn}=Nt,ke="application/json";var jn=function(t,e,i){const n=e.baseUrl,u=e.useReport,r=e.evaluationReasons,o=e.logger,a={},s={};function c(f,l){if(!t.httpRequest)return new Promise((y,I)=>{I(new j.LDFlagFetchError(E.httpUnavailable()))});const g=l?"REPORT":"GET",h=Nn(t,e);l&&(h["Content-Type"]=ke);let m=s[f];m||(m=An(()=>{delete s[f]}),s[f]=m);const w=t.httpRequest(g,f,Fn(h,e),l),b=w.promise.then(y=>{if(y.status===200){if(y.header("content-type")&&y.header("content-type").substring(0,16)===ke)return JSON.parse(y.body);{const I=E.invalidContentType(y.header("content-type")||"");return Promise.reject(new j.LDFlagFetchError(I))}}return Promise.reject(function(I){return I.status===404?new j.LDInvalidEnvironmentIdError(E.environmentNotFound()):new j.LDFlagFetchError(E.errorFetchingFlags(I.statusText||String(I.status)))}(y))},y=>Promise.reject(new j.LDFlagFetchError(E.networkError(y))));return m.addPromise(b,()=>{w.cancel&&w.cancel()}),m.resultPromise}return a.fetchJSON=function(f){return c(S.appendUrlPath(n,f),null)},a.fetchFlagSettings=function(f,l){let g,h,m,w="";return u?(h=[n,"/sdk/evalx/",i,"/context"].join(""),m=JSON.stringify(f)):(g=S.base64URLEncode(JSON.stringify(f)),h=[n,"/sdk/evalx/",i,"/contexts/",g].join("")),l&&(w="h="+l),r&&(w=w+(w?"&":"")+"withReasons=true"),h=h+(w?"?":"")+w,o.debug(E.debugPolling(h)),c(h,m)},a},$n=function(t,e){const i={};let n;return i.setContext=function(u){n=S.sanitizeContext(u),n&&e&&e(S.clone(n))},i.getContext=function(){return n?S.clone(n):null},i};const{v1:Vn}=Ut,{getContextKinds:Hn}=pt;var Mn=function(t){function e(n){return n==null||n==="user"?"ld:$anonUserId":`ld:$contextKey:${n}`}function i(n,u){return u.key!==null&&u.key!==void 0?(u.key=u.key.toString(),Promise.resolve(u)):u.anonymous?function(r){return t.get(e(r))}(n).then(r=>{if(r)return u.key=r,u;{const o=Vn();return u.key=o,function(a,s){return t.set(e(s),a)}(o,n).then(()=>u)}}):Promise.reject(new j.LDInvalidUserError(E.invalidContext()))}this.processContext=n=>{if(!n)return Promise.reject(new j.LDInvalidUserError(E.contextNotSpecified()));const u=S.clone(n);if(n.kind==="multi"){const r=Hn(u);return Promise.all(r.map(o=>i(o,u[o]))).then(()=>u)}return i(n.kind,u)}};const{v1:qn}=Ut,{baseOptionDefs:Ht}=Ft,{appendUrlPath:_n}=S;var Mt={DiagnosticId:function(t){const e={diagnosticId:qn()};return t&&(e.sdkKeySuffix=t.length>6?t.substring(t.length-6):t),e},DiagnosticsAccumulator:function(t){let e,i,n,u;function r(o){e=o,i=0,n=0,u=[]}return r(t),{getProps:()=>({dataSinceDate:e,droppedEvents:i,eventsInLastBatch:n,streamInits:u}),setProps:o=>{e=o.dataSinceDate,i=o.droppedEvents||0,n=o.eventsInLastBatch||0,u=o.streamInits||[]},incrementDroppedEvents:()=>{i++},setEventsInLastBatch:o=>{n=o},recordStreamInit:(o,a,s)=>{const c={timestamp:o,failed:a,durationMillis:s};u.push(c)},reset:r}},DiagnosticsManager:function(t,e,i,n,u,r,o){const a=!!t.diagnosticUseCombinedEvent,s="ld:"+u+":$diagnostics",c=_n(r.eventsUrl,"/events/diagnostic/"+u),f=r.diagnosticRecordingInterval,l=i;let g,h,m=!!r.streaming;const w={};function b(){return{sdk:T(),configuration:V(),platform:t.diagnosticPlatformData}}function y(P){r.logger&&r.logger.debug(E.debugPostingDiagnosticEvent(P)),n.sendEvents(P,c,!0).then(()=>{}).catch(()=>{})}function I(){y(function(){const P=new Date().getTime();let F={kind:a?"diagnostic-combined":"diagnostic",id:o,creationDate:P,...l.getProps()};return a&&(F={...F,...b()}),l.reset(P),F}()),h=setTimeout(I,f),g=new Date().getTime(),a&&function(){if(e.isEnabled()){const P={...l.getProps()};e.set(s,JSON.stringify(P))}}()}function T(){const P={...t.diagnosticSdkData};return r.wrapperName&&(P.wrapperName=r.wrapperName),r.wrapperVersion&&(P.wrapperVersion=r.wrapperVersion),P}function V(){return{customBaseURI:r.baseUrl!==Ht.baseUrl.default,customStreamURI:r.streamUrl!==Ht.streamUrl.default,customEventsURI:r.eventsUrl!==Ht.eventsUrl.default,eventsCapacity:r.eventCapacity,eventsFlushIntervalMillis:r.flushInterval,reconnectTimeMillis:r.streamReconnectDelay,streamingDisabled:!m,allAttributesPrivate:!!r.allAttributesPrivate,diagnosticRecordingIntervalMillis:r.diagnosticRecordingInterval,usingSecureMode:!!r.hash,bootstrapMode:!!r.bootstrap,fetchGoalsDisabled:!r.fetchGoals,sendEventsOnlyForVariation:!!r.sendEventsOnlyForVariation}}return w.start=()=>{a?function(P){if(!e.isEnabled())return P(!1);e.get(s).then(F=>{if(F)try{const x=JSON.parse(F);l.setProps(x),g=x.dataSinceDate}catch{}P(!0)}).catch(()=>{P(!1)})}(P=>{if(P){const F=(g||0)+f,x=new Date().getTime();x>=F?I():h=setTimeout(I,F-x)}else Math.floor(4*Math.random())===0?I():h=setTimeout(I,f)}):(y({kind:"diagnostic-init",id:o,creationDate:l.getProps().dataSinceDate,...b()}),h=setTimeout(I,f))},w.stop=()=>{h&&clearTimeout(h)},w.setStreaming=P=>{m=P},w}},zn=function(t,e){let i=!1;const n={type:t.type,name:t.name,synchronous:t.synchronous,method:(...u)=>{try{t.method(...u)}catch{i||(i=!0,e.warn(E.inspectorMethodError(n.type,n.name)))}}};return n};const{onNextTick:ht}=S,B={flagUsed:"flag-used",flagDetailsChanged:"flag-details-changed",flagDetailChanged:"flag-detail-changed",clientIdentityChanged:"client-identity-changed"};Object.freeze(B);var Jn={InspectorTypes:B,InspectorManager:function(t,e){const i={},n={[B.flagUsed]:[],[B.flagDetailsChanged]:[],[B.flagDetailChanged]:[],[B.clientIdentityChanged]:[]},u={[B.flagUsed]:[],[B.flagDetailsChanged]:[],[B.flagDetailChanged]:[],[B.clientIdentityChanged]:[]},r=t&&t.map(o=>zn(o,e));return r&&r.forEach(o=>{Object.prototype.hasOwnProperty.call(n,o.type)&&!o.synchronous?n[o.type].push(o):Object.prototype.hasOwnProperty.call(u,o.type)&&o.synchronous?u[o.type].push(o):e.warn(E.invalidInspector(o.type,o.name))}),i.hasListeners=o=>n[o]&&n[o].length||u[o]&&u[o].length,i.onFlagUsed=(o,a,s)=>{const c=B.flagUsed;u[c].length&&u[c].forEach(f=>f.method(o,a,s)),n[c].length&&ht(()=>{n[c].forEach(f=>f.method(o,a,s))})},i.onFlags=o=>{const a=B.flagDetailsChanged;u[a].length&&u[a].forEach(s=>s.method(o)),n[a].length&&ht(()=>{n[a].forEach(s=>s.method(o))})},i.onFlagChanged=(o,a)=>{const s=B.flagDetailChanged;u[s].length&&u[s].forEach(c=>c.method(o,a)),n[s].length&&ht(()=>{n[s].forEach(c=>c.method(o,a))})},i.onIdentityChanged=o=>{const a=B.clientIdentityChanged;u[a].length&&u[a].forEach(s=>s.method(o)),n[a].length&&ht(()=>{n[a].forEach(s=>s.method(o))})},i}};const{LDTimeoutError:Kn}=j;var Bn=function(t,e){return new Promise((i,n)=>{setTimeout(()=>{n(new Kn(`${e} timed out after ${t} seconds.`))},1e3*t)})};const Ee="unknown hook";function ut(t,e,i,n,u){try{return n()}catch(r){return t==null||t.error(`An error was encountered in "${e}" of the "${i}" hook: ${r}`),u}}function ct(t,e){try{return e.getMetadata().name||Ee}catch{return t.error("Exception thrown getting metadata for hook. Unable to get hook name."),Ee}}var Gn=function(t,e){const i=e?[...e]:[];return{withEvaluation:function(n,u,r,o){if(i.length===0)return o();const a=[...i],s={flagKey:n,context:u,defaultValue:r},c=function(l,g,h){return g.map(m=>ut(l,"beforeEvaluation",ct(l,m),()=>{var w;return((w=m==null?void 0:m.beforeEvaluation)==null?void 0:w.call(m,h,{}))??{}},{}))}(t,a,s),f=o();return function(l,g,h,m,w){for(let b=g.length-1;b>=0;b-=1){const y=g[b],I=m[b];ut(l,"afterEvaluation",ct(l,y),()=>{var T;return((T=y==null?void 0:y.afterEvaluation)==null?void 0:T.call(y,h,I,w))??{}},{})}}(t,a,s,c,f),f},identify:function(n,u){const r=[...i],o={context:n,timeout:u},a=function(s,c,f){return c.map(l=>ut(s,"beforeIdentify",ct(s,l),()=>{var g;return((g=l==null?void 0:l.beforeIdentify)==null?void 0:g.call(l,f,{}))??{}},{}))}(t,r,o);return s=>{(function(c,f,l,g,h){for(let m=f.length-1;m>=0;m-=1){const w=f[m],b=g[m];ut(c,"afterIdentify",ct(c,w),()=>{var y;return((y=w==null?void 0:w.afterIdentify)==null?void 0:y.call(w,l,b,h))??{}},{})}})(t,r,o,a,s)}},addHook:function(n){i.push(n)},afterTrack:function(n){if(i.length===0)return;const u=[...i];(function(r,o,a){for(let s=o.length-1;s>=0;s-=1){const c=o[s];ut(r,"afterTrack",ct(r,c),()=>{var f;return(f=c==null?void 0:c.afterTrack)==null?void 0:f.call(c,a)},void 0)}})(t,u,n)}}};const De="unknown plugin";function qt(t,e){try{return e.getMetadata().name||De}catch{return t.error("Exception thrown getting metadata for plugin. Unable to get plugin name."),De}}var Wn={getPluginHooks:function(t,e,i){const n=[];return i.forEach(u=>{var r;try{const o=(r=u.getHooks)==null?void 0:r.call(u,e);o===void 0?t.error(`Plugin ${qt(t,u)} returned undefined from getHooks.`):o&&o.length>0&&n.push(...o)}catch{t.error(`Exception thrown getting hooks for plugin ${qt(t,u)}. Unable to get hooks.`)}}),n},registerPlugins:function(t,e,i,n){n.forEach(u=>{try{u.register(i,e)}catch{t.error(`Exception thrown registering plugin ${qt(t,u)}.`)}})},createPluginEnvironment:function(t,e,i){const n={};t.userAgent&&(n.name=t.userAgent),t.version&&(n.version=t.version),i.wrapperName&&(n.wrapperName=i.wrapperName),i.wrapperVersion&&(n.wrapperVersion=i.wrapperVersion);const u={};i.application&&(i.application.name&&(u.name=i.application.name),i.application.version&&(u.version=i.application.version));const r={sdk:n,clientSideId:e};return Object.keys(u).length>0&&(r.application=u),r}};const{commonBasicLogger:Xn}=Rt,{checkContext:Yn}=pt,{InspectorTypes:yt,InspectorManager:Qn}=Jn,{getPluginHooks:Zn,registerPlugins:tr,createPluginEnvironment:er}=Wn,wt="change",Ie="internal-change";var Se={initialize:function(t,e,i,n,u){const r=function(){return i&&i.logger?i.logger:u&&u.logger&&u.logger.default||Xn("warn")}(),o=In(r),a=Sn(o),s=Ft.validate(i,o,u,r),c=Qn(s.inspectors,r),f=s.sendEvents;let l=t,g=s.hash;const h=[...s.plugins],m=er(n,t,s),w=Zn(r,m,h),b=Gn(r,[...s.hooks,...w]),y=Pn(n.localStorage,r),I=ge(n,l,s),T=s.sendEvents&&!s.diagnosticOptOut,V=T?Mt.DiagnosticId(l):null,P=T?Mt.DiagnosticsAccumulator(new Date().getTime()):null,F=T?Mt.DiagnosticsManager(n,y,P,I,l,s,V):null,x=Rn(n,s,l,P),C=s.eventProcessor||Dn(n,s,l,P,o,I),W=jn(n,s,l);let L,O,M,k={},et=s.streaming,Oe=!1,Et=!1,Gt=!0;const Q=s.stateProvider,$=$n(null,function(d){(function(p){Q||p&&Dt({kind:"identify",context:p,creationDate:new Date().getTime()})})(d),c.hasListeners(yt.clientIdentityChanged)&&c.onIdentityChanged($.getContext())}),Ue=new Mn(y),ot=y.isEnabled()?xn(y,l,g,$):null;function Dt(d){l&&(Q&&Q.enqueueEvent&&Q.enqueueEvent(d)||(d.context?(Gt=!1,!f||Et||n.isDoNotTrack()||(r.debug(E.debugEnqueueingEvent(d.kind)),C.enqueue(d))):Gt&&(r.warn(E.eventWithoutContext()),Gt=!1)))}function Re(d,p){c.hasListeners(yt.flagDetailChanged)&&c.onFlagChanged(d.key,it(p))}function Ae(){c.hasListeners(yt.flagDetailsChanged)&&c.onFlags(Object.entries(k).map(([d,p])=>({key:d,detail:it(p)})).reduce((d,p)=>(d[p.key]=p.detail,d),{}))}function Fe(d,p,v,D){const R=$.getContext(),A=new Date,U={kind:"feature",key:d,context:R,value:p?p.value:null,variation:p?p.variationIndex:null,default:v,creationDate:A.getTime()},N=k[d];N&&(U.version=N.flagVersion?N.flagVersion:N.version,U.trackEvents=N.trackEvents,U.debugEventsUntilDate=N.debugEventsUntilDate),(D||N&&N.trackReason)&&p&&(U.reason=p.reason),Dt(U)}function Ne(d){return Yn(d,!1)?Promise.resolve(d):Promise.reject(new j.LDInvalidUserError(E.invalidContext()))}function It(d,p,v,D,R,A){var He;let U,N;return k&&S.objectHasOwnProperty(k,d)&&k[d]&&!k[d].deleted?(N=k[d],U=it(N),N.value!==null&&N.value!==void 0||(U.value=p)):U={value:p,variationIndex:null,reason:{kind:"ERROR",errorKind:"FLAG_NOT_FOUND"}},v&&(R||((He=N==null?void 0:N.prerequisites)==null||He.forEach(te=>{It(te,void 0,v,!1,!1,!1)})),Fe(d,U,p,D)),!R&&A&&function(te,hr){c.hasListeners(yt.flagUsed)&&c.onFlagUsed(te,hr,$.getContext())}(d,U),U}function it(d){return{value:d.value,variationIndex:d.variation===void 0?null:d.variation,reason:d.reason||null}}function je(){if(O=!0,!$.getContext())return;const d=p=>{try{return JSON.parse(p)}catch{return void o.maybeReportError(new j.LDInvalidDataError(E.invalidData()))}};x.connect($.getContext(),g,{ping:function(){r.debug(E.debugStreamPing());const p=$.getContext();W.fetchFlagSettings(p,g).then(v=>{S.deepEquals(p,$.getContext())&&at(v||{})}).catch(v=>{o.maybeReportError(new j.LDFlagFetchError(E.errorFetchingFlags(v)))})},put:function(p){const v=d(p.data);v&&(r.debug(E.debugStreamPut()),at(v))},patch:function(p){const v=d(p.data);if(!v)return;const D=k[v.key];if(!D||!D.version||!v.version||D.version<v.version){r.debug(E.debugStreamPatch(v.key));const R={},A=S.extend({},v);delete A.key,k[v.key]=A;const U=it(A);R[v.key]=D?{previous:D.value,current:U}:{current:U},Re(v,A),Xt(R)}else r.debug(E.debugStreamPatchIgnored(v.key))},delete:function(p){const v=d(p.data);if(v)if(!k[v.key]||k[v.key].version<v.version){r.debug(E.debugStreamDelete(v.key));const D={};k[v.key]&&!k[v.key].deleted&&(D[v.key]={previous:k[v.key].value}),k[v.key]={version:v.version,deleted:!0},Re(v,k[v.key]),Xt(D)}else r.debug(E.debugStreamDeleteIgnored(v.key))}})}function Wt(){O&&(x.disconnect(),O=!1)}function at(d){const p={};if(!d)return Promise.resolve();for(const v in k)S.objectHasOwnProperty(k,v)&&k[v]&&(d[v]&&!S.deepEquals(d[v].value,k[v].value)?p[v]={previous:k[v].value,current:it(d[v])}:d[v]&&!d[v].deleted||(p[v]={previous:k[v].value}));for(const v in d)S.objectHasOwnProperty(d,v)&&d[v]&&(!k[v]||k[v].deleted)&&(p[v]={current:it(d[v])});return k={...d},Ae(),Xt(p).catch(()=>{})}function Xt(d){const p=Object.keys(d);if(p.length>0){const v={};p.forEach(D=>{const R=d[D].current,A=R?R.value:void 0,U=d[D].previous;o.emit(wt+":"+D,A,U),v[D]=R?{current:A,previous:U}:{previous:U}}),o.emit(wt,v),o.emit(Ie,k),s.sendEventsOnlyForVariation||Q||p.forEach(D=>{Fe(D,d[D].current)})}return L&&ot?ot.saveFlags(k):Promise.resolve()}function Yt(){const d=et||M&&et===void 0;d&&!O?je():!d&&O&&Wt(),F&&F.setStreaming(d)}function Qt(d){return d===wt||d.substr(0,7)===wt+":"}if(typeof s.bootstrap=="string"&&s.bootstrap.toUpperCase()==="LOCALSTORAGE"&&(ot?L=!0:r.warn(E.localStorageUnavailable())),typeof s.bootstrap=="object"&&(k=function(d){const p=Object.keys(d),v="$flagsState",D="$valid",R=d[v];!R&&p.length&&r.warn(E.bootstrapOldFormat()),d[D]===!1&&r.warn(E.bootstrapInvalid());const A={};return p.forEach(U=>{if(U!==v&&U!==D){let N={value:d[U]};R&&R[U]?N=S.extend(N,R[U]):N.version=0,A[U]=N}}),A}(s.bootstrap)),Q){const d=Q.getInitialState();d?$e(d):Q.on("init",$e),Q.on("update",function(p){p.context&&$.setContext(p.context),p.flags&&at(p.flags)})}else(function(){if(!t)return Promise.reject(new j.LDInvalidEnvironmentIdError(E.environmentNotSpecified()));let d;return Ue.processContext(e).then(Ne).then(p=>(d=S.once(b.identify(p,void 0)),p)).then(p=>(d==null||d({status:"completed"}),$.setContext(p),typeof s.bootstrap=="object"?lt():L?ot.loadFlags().then(v=>v==null?(k={},W.fetchFlagSettings($.getContext(),g).then(D=>at(D||{})).then(lt).catch(D=>{Zt(new j.LDFlagFetchError(E.errorFetchingFlags(D)))})):(k=v,S.onNextTick(lt),W.fetchFlagSettings($.getContext(),g).then(D=>at(D)).catch(D=>o.maybeReportError(D)))):W.fetchFlagSettings($.getContext(),g).then(v=>{k=v||{},Ae(),lt()}).catch(v=>{k={},Zt(v)}))).catch(p=>{throw d==null||d({status:"error"}),p})})().catch(Zt);function $e(d){l=d.environment,$.setContext(d.context),k={...d.flags},S.onNextTick(lt)}function lt(){r.info(E.clientInitialized()),Oe=!0,Yt(),a.signalSuccess()}function Zt(d){a.signalFailure(d)}const Ve={waitForInitialization:function(d=void 0){if(d!=null){if(typeof d=="number")return function(p){p>5&&r.warn("The waitForInitialization function was called with a timeout greater than 5 seconds. We recommend a timeout of 5 seconds or less.");const v=a.getInitializationPromise(),D=Bn(p,"waitForInitialization");return Promise.race([D,v]).catch(R=>{throw R instanceof j.LDTimeoutError&&r.error(`waitForInitialization error: ${R}`),R})}(d);r.warn("The waitForInitialization method was provided with a non-numeric timeout.")}return r.warn("The waitForInitialization function was called without a timeout specified. In a future version a default timeout will be applied."),a.getInitializationPromise()},waitUntilReady:()=>a.getReadyPromise(),identify:function(d,p,v){if(Et)return S.wrapPromiseCallback(Promise.resolve({}),v);if(Q)return r.warn(E.identifyDisabled()),S.wrapPromiseCallback(Promise.resolve(S.transformVersionedValuesToValues(k)),v);let D;const R=L&&ot?ot.clearFlags():Promise.resolve();return S.wrapPromiseCallback(R.then(()=>Ue.processContext(d)).then(Ne).then(A=>(D=S.once(b.identify(A,void 0)),A)).then(A=>W.fetchFlagSettings(A,p).then(U=>{const N=S.transformVersionedValuesToValues(U);return $.setContext(A),g=p,U?at(U).then(()=>N):N})).then(A=>(D==null||D({status:"completed"}),O&&je(),A)).catch(A=>(D==null||D({status:"error"}),o.maybeReportError(A),Promise.reject(A))),v)},getContext:function(){return $.getContext()},variation:function(d,p){const{value:v}=b.withEvaluation(d,$.getContext(),p,()=>It(d,p,!0,!1,!1,!0));return v},variationDetail:function(d,p){return b.withEvaluation(d,$.getContext(),p,()=>It(d,p,!0,!0,!1,!0))},track:function(d,p,v){if(typeof d!="string")return void o.maybeReportEr