UNPKG

statsig-js

Version:

Statsig JavaScript client SDK for single user environments.

1 lines 133 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.statsig=t():e.statsig=t()}(this,(()=>(()=>{var e={312:(e,t,n)=>{var r;!function(){"use strict";var t="input is invalid type",i="object"==typeof window,o=i?window:{};o.JS_SHA256_NO_WINDOW&&(i=!1);var a=!i&&"object"==typeof self,s=!o.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;s?o=n.g:a&&(o=self);var u=!o.JS_SHA256_NO_COMMON_JS&&e.exports,l=n.amdO,c=!o.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,d="0123456789abcdef".split(""),h=[-2147483648,8388608,32768,128],f=[24,16,8,0],p=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],g=["hex","array","digest","arrayBuffer"],v=[];!o.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!c||!o.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var y=function(e,t){return function(n){return new S(t,!0).update(n)[e]()}},m=function(e){var t=y("hex",e);s&&(t=E(t,e)),t.create=function(){return new S(e)},t.update=function(e){return t.create().update(e)};for(var n=0;n<g.length;++n){var r=g[n];t[r]=y(r,e)}return t},E=function(e,r){var i,a=n(394),s=n(903).Buffer,u=r?"sha224":"sha256";i=s.from&&!o.JS_SHA256_NO_BUFFER_FROM?s.from:function(e){return new s(e)};return function(n){if("string"==typeof n)return a.createHash(u).update(n,"utf8").digest("hex");if(null==n)throw new Error(t);return n.constructor===ArrayBuffer&&(n=new Uint8Array(n)),Array.isArray(n)||ArrayBuffer.isView(n)||n.constructor===s?a.createHash(u).update(i(n)).digest("hex"):e(n)}},_=function(e,t){return function(n,r){return new I(n,t,!0).update(r)[e]()}},b=function(e){var t=_("hex",e);t.create=function(t){return new I(t,e)},t.update=function(e,n){return t.create(e).update(n)};for(var n=0;n<g.length;++n){var r=g[n];t[r]=_(r,e)}return t};function S(e,t){t?(v[0]=v[16]=v[1]=v[2]=v[3]=v[4]=v[5]=v[6]=v[7]=v[8]=v[9]=v[10]=v[11]=v[12]=v[13]=v[14]=v[15]=0,this.blocks=v):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}function I(e,n,r){var i,o=typeof e;if("string"===o){var a,s=[],u=e.length,l=0;for(i=0;i<u;++i)(a=e.charCodeAt(i))<128?s[l++]=a:a<2048?(s[l++]=192|a>>>6,s[l++]=128|63&a):a<55296||a>=57344?(s[l++]=224|a>>>12,s[l++]=128|a>>>6&63,s[l++]=128|63&a):(a=65536+((1023&a)<<10|1023&e.charCodeAt(++i)),s[l++]=240|a>>>18,s[l++]=128|a>>>12&63,s[l++]=128|a>>>6&63,s[l++]=128|63&a);e=s}else{if("object"!==o)throw new Error(t);if(null===e)throw new Error(t);if(c&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||c&&ArrayBuffer.isView(e)))throw new Error(t)}e.length>64&&(e=new S(n,!0).update(e).array());var d=[],h=[];for(i=0;i<64;++i){var f=e[i]||0;d[i]=92^f,h[i]=54^f}S.call(this,n,r),this.update(h),this.oKeyPad=d,this.inner=!0,this.sharedMemory=r}S.prototype.update=function(e){if(!this.finalized){var n,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(t);if(null===e)throw new Error(t);if(c&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||c&&ArrayBuffer.isView(e)))throw new Error(t);n=!0}for(var i,o,a=0,s=e.length,u=this.blocks;a<s;){if(this.hashed&&(this.hashed=!1,u[0]=this.block,this.block=u[16]=u[1]=u[2]=u[3]=u[4]=u[5]=u[6]=u[7]=u[8]=u[9]=u[10]=u[11]=u[12]=u[13]=u[14]=u[15]=0),n)for(o=this.start;a<s&&o<64;++a)u[o>>>2]|=e[a]<<f[3&o++];else for(o=this.start;a<s&&o<64;++a)(i=e.charCodeAt(a))<128?u[o>>>2]|=i<<f[3&o++]:i<2048?(u[o>>>2]|=(192|i>>>6)<<f[3&o++],u[o>>>2]|=(128|63&i)<<f[3&o++]):i<55296||i>=57344?(u[o>>>2]|=(224|i>>>12)<<f[3&o++],u[o>>>2]|=(128|i>>>6&63)<<f[3&o++],u[o>>>2]|=(128|63&i)<<f[3&o++]):(i=65536+((1023&i)<<10|1023&e.charCodeAt(++a)),u[o>>>2]|=(240|i>>>18)<<f[3&o++],u[o>>>2]|=(128|i>>>12&63)<<f[3&o++],u[o>>>2]|=(128|i>>>6&63)<<f[3&o++],u[o>>>2]|=(128|63&i)<<f[3&o++]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.block=u[16],this.start=o-64,this.hash(),this.hashed=!0):this.start=o}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},S.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=h[3&t],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}},S.prototype.hash=function(){var e,t,n,r,i,o,a,s,u,l=this.h0,c=this.h1,d=this.h2,h=this.h3,f=this.h4,g=this.h5,v=this.h6,y=this.h7,m=this.blocks;for(e=16;e<64;++e)t=((i=m[e-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,n=((i=m[e-2])>>>17|i<<15)^(i>>>19|i<<13)^i>>>10,m[e]=m[e-16]+t+m[e-7]+n|0;for(u=c&d,e=0;e<64;e+=4)this.first?(this.is224?(o=300032,y=(i=m[0]-1413257819)-150054599|0,h=i+24177077|0):(o=704751109,y=(i=m[0]-210244248)-1521486534|0,h=i+143694565|0),this.first=!1):(t=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),r=(o=l&c)^l&d^u,y=h+(i=y+(n=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(f&g^~f&v)+p[e]+m[e])|0,h=i+(t+r)|0),t=(h>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),r=(a=h&l)^h&c^o,v=d+(i=v+(n=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7))+(y&f^~y&g)+p[e+1]+m[e+1])|0,t=((d=i+(t+r)|0)>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),r=(s=d&h)^d&l^a,g=c+(i=g+(n=(v>>>6|v<<26)^(v>>>11|v<<21)^(v>>>25|v<<7))+(v&y^~v&f)+p[e+2]+m[e+2])|0,t=((c=i+(t+r)|0)>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),r=(u=c&d)^c&h^s,f=l+(i=f+(n=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7))+(g&v^~g&y)+p[e+3]+m[e+3])|0,l=i+(t+r)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+l|0,this.h1=this.h1+c|0,this.h2=this.h2+d|0,this.h3=this.h3+h|0,this.h4=this.h4+f|0,this.h5=this.h5+g|0,this.h6=this.h6+v|0,this.h7=this.h7+y|0},S.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,i=this.h4,o=this.h5,a=this.h6,s=this.h7,u=d[e>>>28&15]+d[e>>>24&15]+d[e>>>20&15]+d[e>>>16&15]+d[e>>>12&15]+d[e>>>8&15]+d[e>>>4&15]+d[15&e]+d[t>>>28&15]+d[t>>>24&15]+d[t>>>20&15]+d[t>>>16&15]+d[t>>>12&15]+d[t>>>8&15]+d[t>>>4&15]+d[15&t]+d[n>>>28&15]+d[n>>>24&15]+d[n>>>20&15]+d[n>>>16&15]+d[n>>>12&15]+d[n>>>8&15]+d[n>>>4&15]+d[15&n]+d[r>>>28&15]+d[r>>>24&15]+d[r>>>20&15]+d[r>>>16&15]+d[r>>>12&15]+d[r>>>8&15]+d[r>>>4&15]+d[15&r]+d[i>>>28&15]+d[i>>>24&15]+d[i>>>20&15]+d[i>>>16&15]+d[i>>>12&15]+d[i>>>8&15]+d[i>>>4&15]+d[15&i]+d[o>>>28&15]+d[o>>>24&15]+d[o>>>20&15]+d[o>>>16&15]+d[o>>>12&15]+d[o>>>8&15]+d[o>>>4&15]+d[15&o]+d[a>>>28&15]+d[a>>>24&15]+d[a>>>20&15]+d[a>>>16&15]+d[a>>>12&15]+d[a>>>8&15]+d[a>>>4&15]+d[15&a];return this.is224||(u+=d[s>>>28&15]+d[s>>>24&15]+d[s>>>20&15]+d[s>>>16&15]+d[s>>>12&15]+d[s>>>8&15]+d[s>>>4&15]+d[15&s]),u},S.prototype.toString=S.prototype.hex,S.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,i=this.h4,o=this.h5,a=this.h6,s=this.h7,u=[e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r,i>>>24&255,i>>>16&255,i>>>8&255,255&i,o>>>24&255,o>>>16&255,o>>>8&255,255&o,a>>>24&255,a>>>16&255,a>>>8&255,255&a];return this.is224||u.push(s>>>24&255,s>>>16&255,s>>>8&255,255&s),u},S.prototype.array=S.prototype.digest,S.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e},I.prototype=new S,I.prototype.finalize=function(){if(S.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();S.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),S.prototype.finalize.call(this)}};var w=m();w.sha256=w,w.sha224=m(!0),w.sha256.hmac=b(),w.sha224.hmac=b(!0),u?e.exports=w:(o.sha256=w.sha256,o.sha224=w.sha224,l&&(void 0===(r=function(){return w}.call(w,n,w,e))||(e.exports=r)))}()},331:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t,n,r,i,o,a,s,u,l){void 0===i&&(i=[]),void 0===o&&(o=""),void 0===a&&(a=null),void 0===s&&(s=null),void 0===u&&(u=null),void 0===l&&(l=null),this.onDefaultValueFallback=null,this.name=e,this.value=JSON.parse(JSON.stringify(null!=t?t:{})),this.ruleID=null!=n?n:"",this.secondaryExposures=i,this.allocatedExperimentName=o,this.evaluationDetails=r,this.onDefaultValueFallback=a,this.groupName=s,this.idType=u,this.isExperimentActive=l}return e.prototype.get=function(e,t,n){var r,i,o=this.getValue(e,t);if(null==o)return t;var a=Array.isArray(t)?"array":typeof t,s=Array.isArray(o)?"array":typeof o;return n?n(o)?o:(null===(r=this.onDefaultValueFallback)||void 0===r||r.call(this,this,e,a,s),t):null==t||a===s?o:(null===(i=this.onDefaultValueFallback)||void 0===i||i.call(this,this,e,a,s),t)},e.prototype.getValue=function(e,t){return null==e?this.value:(null==t&&(t=null),null==this.value[e]?t:this.value[e])},e.prototype.getRuleID=function(){return this.ruleID},e.prototype.getGroupName=function(){return this.groupName},e.prototype.getIDType=function(){return this.idType},e.prototype.getName=function(){return this.name},e.prototype.getEvaluationDetails=function(){return this.evaluationDetails},e.prototype._getSecondaryExposures=function(){return this.secondaryExposures},e.prototype._getAllocatedExperimentName=function(){return this.allocatedExperimentName},e.prototype.getIsExperimentActive=function(){return this.isExperimentActive},e}();t.default=n},144:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ExceptionEndpoint=void 0;var a=n(831),s=n(741),u=o(n(742)),l=o(n(505)),c=o(n(235));t.ExceptionEndpoint="https://prodregistryv2.org/v1/rgstr_e";var d=function(){function e(e,t){this.sdkKey=e,this.sdkOptions=t,this.seen=new Set;var n=Math.floor(1e4*Math.random());this.setupDiagnostics(0===n?30:0)}return e.prototype.setStatsigMetadata=function(e){this.statsigMetadata=e},e.prototype.swallow=function(e,t,n){void 0===n&&(n={}),this.capture(e,t,(function(){}),n)},e.prototype.capture=function(e,t,n,r){var i=this;void 0===r&&(r={});var o=null;try{o=this.beginMarker(e);var a=t(),s=!0;return a instanceof Promise?a.catch((function(t){return s=!1,i.onCaught(e,t,n,r)})).then((function(t){return i.endMarker(e,s,o),t})):(this.endMarker(e,!0,o,r.configName),a)}catch(t){return this.endMarker(e,!1,o,r.configName),this.onCaught(e,t,n,r)}},e.prototype.logError=function(e,n,o){var s=this,u=void 0===o?{}:o,l=u.getExtraData,d=u.configName;this.sdkOptions.isAllLoggingDisabled()||r(s,void 0,void 0,(function(){var r,o,s,u,h,f,p;return i(this,(function(i){try{return r="function"==typeof l?l():{},o=(0,c.default)(n),s=o.name,u=o.trace,r.configName=d,this.seen.has(s)?[2]:(this.seen.add(s),null==(h=null!==(p=this.statsigMetadata)&&void 0!==p?p:{}).sessionID&&(h.sessionID=(0,a.v4)()),f=JSON.stringify({tag:e,exception:s,info:u,statsigMetadata:h,statsigOptions:this.sdkOptions.getLoggingCopy(),extra:r}),[2,fetch(t.ExceptionEndpoint,{method:"POST",headers:{"STATSIG-API-KEY":this.sdkKey,"STATSIG-SDK-TYPE":String(h.sdkType),"STATSIG-SDK-VERSION":String(h.sdkVersion),"Content-Type":"application/json; charset=UTF-8"},body:f})])}catch(e){}return[2]}))})).catch((function(){}))},e.prototype.setupDiagnostics=function(e){u.default.setMaxMarkers("api_call",e)},e.prototype.beginMarker=function(e){var t=u.default.mark.api_call(e);if(!t)return null;var n=u.default.getMarkerCount("api_call"),r="".concat(e,"_").concat(n);return t.start({markerID:r},"api_call")?r:null},e.prototype.endMarker=function(e,t,n,r){var i=u.default.mark.api_call(e);n&&i&&i.end({markerID:n,success:t,configName:r},"api_call")},e.prototype.onCaught=function(e,t,n,r){if(void 0===r&&(r={}),t instanceof s.StatsigUninitializedError||t instanceof s.StatsigInvalidArgumentError)throw t;return t instanceof s.StatsigInitializationTimeoutError?(l.default.error("Timeout occured.",t),n()):(l.default.error("An unexpected exception occurred.",t),this.logError(e,t,r),n())},e}();t.default=d},741:function(e,t){"use strict";var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.StatsigInitializationTimeoutError=t.StatsigSDKKeyMismatchError=t.StatsigInvalidArgumentError=t.StatsigUninitializedError=void 0;var i=function(e){function t(n){var r=e.call(this,null!=n?n:"Call and wait for initialize() to finish first.")||this;return Object.setPrototypeOf(r,t.prototype),r}return r(t,e),t}(Error);t.StatsigUninitializedError=i;var o=function(e){function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return r(t,e),t}(Error);t.StatsigInvalidArgumentError=o;var a=function(e){function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return r(t,e),t}(Error);t.StatsigSDKKeyMismatchError=a;var s=function(e){function t(n){var r=e.call(this,"The initialization timeout of ".concat(n,"ms has been hit before the network request has completed."))||this;return Object.setPrototypeOf(r,t.prototype),r}return r(t,e),t}(Error);t.StatsigInitializationTimeoutError=s},685:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t,n,r,i,o,a){void 0===i&&(i=null),void 0===o&&(o=null),void 0===a&&(a=[]),this.name=e,this.value=t,this.ruleID=null!=n?n:"",this.evaluationDetails=r,this.groupName=i,this.idType=o,this.secondaryExposures=a}return e.prototype.getRuleID=function(){return this.ruleID},e.prototype.getGroupName=function(){return this.groupName},e.prototype.getIDType=function(){return this.idType},e.prototype.getName=function(){return this.name},e.prototype.getValue=function(){return this.value},e.prototype.getEvaluationDetails=function(){return this.evaluationDetails},e.prototype.getSecondaryExposures=function(){return this.secondaryExposures},e}();t.default=n},513:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t,n,r,i,o,a,s,u,l){void 0===i&&(i=null),void 0===o&&(o=[]),void 0===a&&(a=[]),void 0===s&&(s=""),void 0===u&&(u=[]),void 0===l&&(l=null),this.logParameterFunction=i,this.name=e,this.value=JSON.parse(JSON.stringify(null!=t?t:{})),this.ruleID=null!=n?n:"",this.evaluationDetails=r,this.secondaryExposures=o,this.undelegatedSecondaryExposures=a,this.allocatedExperimentName=s,this.explicitParameters=u,this.groupName=l}return e._create=function(t,n,r,i,o,a,s,u,l,c){return void 0===o&&(o=null),void 0===a&&(a=[]),void 0===s&&(s=[]),void 0===u&&(u=""),void 0===l&&(l=[]),void 0===c&&(c=null),new e(t,n,r,i,o,a,s,u,l,c)},e.prototype.get=function(e,t,n){var r=this,i=this.value[e];if(null==i)return t;var o=function(){return r.logLayerParameterExposure(e),i};return n?n(i)?o():t:null==t||typeof i==typeof t&&Array.isArray(t)===Array.isArray(i)?o():t},e.prototype.getValue=function(e,t){null==t&&(t=null);var n=this.value[e];return null!=n&&this.logLayerParameterExposure(e),null!=n?n:t},e.prototype.getRuleID=function(){return this.ruleID},e.prototype.getGroupName=function(){return this.groupName},e.prototype.getName=function(){return this.name},e.prototype.getEvaluationDetails=function(){return this.evaluationDetails},e.prototype._getSecondaryExposures=function(){return this.secondaryExposures},e.prototype._getUndelegatedSecondaryExposures=function(){return this.undelegatedSecondaryExposures},e.prototype._getAllocatedExperimentName=function(){return this.allocatedExperimentName},e.prototype._getExplicitParameters=function(){return this.explicitParameters},e.prototype._getEvaluationDetails=function(){return this.evaluationDetails},e.prototype.logLayerParameterExposure=function(e){var t;null===(t=this.logParameterFunction)||void 0===t||t.call(this,this,e)},e}();t.default=n},564:function(e,t){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){this.user=null,this.value=null,this.metadata=null,this.eventName=e,this.statsigMetadata={},this.time=Date.now()}return e.prototype.getName=function(){return this.eventName},e.prototype.setValue=function(e){this.value=e},e.prototype.setMetadata=function(e){this.metadata=e},e.prototype.addStatsigMetadata=function(e,t){this.statsigMetadata[e]=t},e.prototype.setUser=function(e){this.user=n({},e),delete this.user.privateAttributes},e.prototype.setSecondaryExposures=function(e){void 0===e&&(e=[]),this.secondaryExposures=e},e.prototype.toJsonObject=function(){var e;return{eventName:this.eventName,user:this.user,value:this.value,metadata:this.metadata,time:this.time,statsigMetadata:this.statsigMetadata,secondaryExposures:null!==(e=this.secondaryExposures)&&void 0!==e?e:void 0}},e}();t.default=r},474:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version=void 0,t.version="5.1.0"},616:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)},i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var s=a(n(331)),u=a(n(144)),l=n(741),c=a(n(685)),d=a(n(513)),h=a(n(564)),f=a(n(833)),p=a(n(959)),g=a(n(377)),v=a(n(525)),y=a(n(770)),m=a(n(742)),E=n(762),_=n(526),b=a(n(505)),S=n(776),I=a(n(996)),w=a(n(985)),k=n(502),D=64,O=2048,C=function(){function e(t,n,r){var i=this;if(this.appState=null,this.currentAppState=null,this.appStateChangeSubscription=null,this.onCacheLoadedForReact=null,this.initCalled=!1,this.pendingInitPromise=null,this.optionalLoggingSetup=!1,this.prefetchedUsersByCacheKey={},this.logLayerParameterExposureForLayer=function(e,t,n){void 0===n&&(n=!1);var r="",o=e._getUndelegatedSecondaryExposures(),a=e._getExplicitParameters().includes(t);a&&(r=e._getAllocatedExperimentName(),o=e._getSecondaryExposures()),i.logger.logLayerExposure(i.getCurrentUser(),e.getName(),e.getRuleID(),o,r,t,a,e._getEvaluationDetails(),n,i.store.getBootstrapMetadata())},!0!==(null==r?void 0:r.localMode)&&("string"!=typeof t||!t.startsWith("client-")))throw new l.StatsigInvalidArgumentError("Invalid key provided. You must use a Client SDK Key from the Statsig console to initialize the sdk");if(this.startTime=(0,k.now)(),this.options=new v.default(r),this.logger=new p.default(this),m.default.initialize({options:this.options}),this.errorBoundary=new u.default(t,this.options),this.ready=!1,this.sdkKey=t,b.default.setLogger(this.options.getOutputLogger()),b.default.setLogLevel(this.options.getLogLevel()),w.default.disabled=this.options.getDisableLocalStorage(),this.identity=new f.default(this.normalizeUser(null!=n?n:null),this.options.getOverrideStableID(),e.reactNativeUUID),this.errorBoundary.setStatsigMetadata(this.getStatsigMetadata()),this.network=new g.default(this),this.store=new y.default(this,this.options.getInitializeValues()),null!=this.options.getInitializeValues()){var o=this.options.getInitCompletionCallback();this.ready=!0,this.initCalled=!0,setTimeout((function(){return i.delayedSetup()}),20),this.handleOptionalLogging(),o&&o((0,k.now)()-this.startTime,!0,null)}}return e.prototype.getErrorBoundary=function(){return this.errorBoundary},e.prototype.getNetwork=function(){return this.network},e.prototype.getStore=function(){return this.store},e.prototype.getLogger=function(){return this.logger},e.prototype.getOptions=function(){return this.options},e.prototype.getSDKKey=function(){var e=this;return this.errorBoundary.capture("getSDKKey",(function(){var t;return null!==(t=e.sdkKey)&&void 0!==t?t:""}),(function(){return""}))},e.prototype.getCurrentUser=function(){var e=this;return this.errorBoundary.capture("getCurrentUser",(function(){return e.identity.getUser()}),(function(){return null}))},e.prototype.getCurrentUserCacheKey=function(){var e=this;return this.errorBoundary.capture("getCurrentUserCacheKey",(function(){return(0,_.getUserCacheKey)(e.getStableID(),e.getCurrentUser(),e.getSDKKey())}),(function(){return{v1:"",v2:"",v3:""}}))},e.prototype.getCurrentUserUnitID=function(e){var t=this;return this.errorBoundary.capture("getCurrentUserUnitID",(function(){return t.getUnitID(t.getCurrentUser(),e)}),(function(){return""}))},e.prototype.getCurrentUserID=function(){var e=this;return this.errorBoundary.capture("getCurrentUserID",(function(){return e.getUnitID(e.getCurrentUser(),"userid")}),(function(){return""}))},e.prototype.getUnitID=function(e,t){var n,r,i;return e?"userid"===t.toLowerCase()?null!==(r=null===(n=e.userID)||void 0===n?void 0:n.toString())&&void 0!==r?r:null:e.customIDs?null!==(i=e.customIDs[t])&&void 0!==i?i:e.customIDs[t.toLowerCase()]:null:null},e.prototype.getStatsigMetadata=function(){var e=this;return this.errorBoundary.capture("getStatsigMetadata",(function(){return e.identity.getStatsigMetadata()}),(function(){return{}}))},e.prototype.getSDKType=function(){var e=this;return this.errorBoundary.capture("getSDKType",(function(){return e.identity.getSDKType()}),(function(){return""}))},e.prototype.getSDKVersion=function(){var e=this;return this.errorBoundary.capture("getSDKVersion",(function(){return e.identity.getSDKVersion()}),(function(){return""}))},e.prototype.delayedSetup=function(){var e=this;this.errorBoundary.swallow("delayedSetup",(function(){null!=e.options.getInitializeValues()&&e.fireAndForgetPrefechUsers(),e.identity.saveStableID(),e.logger.sendSavedRequests().catch((function(t){return e.errorBoundary.logError("sendSavedRequests:delayedSetup",t)}))}))},e.prototype.setInitializeValues=function(e){var t=this;this.errorBoundary.capture("setInitializeValues",(function(){t.store.bootstrap(e);var n=null;t.ready||(t.ready=!0,t.initCalled=!0,n=t.options.getInitCompletionCallback()),t.handleOptionalLogging(),t.logger.sendSavedRequests().catch((function(e){return t.errorBoundary.logError("sendSavedRequests:setInitializeValues",e)})),n&&n((0,k.now)()-t.startTime,!0,null)}),(function(){t.ready=!0,t.initCalled=!0;var e=t.options.getInitCompletionCallback();e&&e((0,k.now)()-t.startTime,!1,"Caught an exception during setInitializeValues")}))},e.prototype.initializeAsync=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,this.errorBoundary.capture("initializeAsync",(function(){return i(e,void 0,void 0,(function(){var e,t,n,r,i=this;return o(this,(function(o){switch(o.label){case 0:return null!=this.pendingInitPromise?[2,this.pendingInitPromise]:this.ready?[2,Promise.resolve()]:(m.default.mark.overall.start({}),this.initCalled=!0,I.default.asyncStorage?[4,this.identity.initAsync()]:[3,3]);case 1:return o.sent(),[4,this.store.loadAsync()];case 2:o.sent(),o.label=3;case 3:return null===(r=this.onCacheLoadedForReact)||void 0===r||r.call(this),null!=this.appState&&(e=this.appState).addEventListener&&"function"==typeof e.addEventListener&&(this.currentAppState=e.currentState,t=e.addEventListener("change",this.handleAppStateChange.bind(this)),this.appStateChangeSubscription=t),this.options.getLocalModeEnabled()?[2,Promise.resolve()]:(n=this.identity.getUser(),this.pendingInitPromise=this.fetchAndSaveValues({user:n,prefetchUsers:this.options.getPrefetchUsers(),timeout:this.options.getInitTimeoutMs()}).then((function(){return m.default.mark.overall.end({success:!0,evaluationDetails:i.store.getGlobalEvaluationDetails()}),{success:!0,message:null}})).catch((function(e){var t;return m.default.mark.overall.end({success:!1,error:m.default.formatError(e),evaluationDetails:i.store.getGlobalEvaluationDetails()}),{success:!1,message:null!==(t=e.message)&&void 0!==t?t:null}})).then((function(e){var t=e.success,n=e.message,r=i.options.getInitCompletionCallback();r&&r((0,k.now)()-i.startTime,t,n)})).finally((function(){i.pendingInitPromise=null,i.ready=!0,i.delayedSetup(),i.logger.logDiagnostics(n,"initialize")})),this.handleOptionalLogging(),[2,this.pendingInitPromise])}}))}))}),(function(){return e.ready=!0,e.initCalled=!0,Promise.resolve()}))]}))}))},e.prototype.prefetchUsers=function(e){return i(this,void 0,void 0,(function(){var t=this;return o(this,(function(n){return[2,this.errorBoundary.capture("prefetchUsers",(function(){return e&&0!=e.length?t.options.getLocalModeEnabled()?Promise.resolve():t.fetchAndSaveValues({user:null,prefetchUsers:e,timeout:0}):Promise.resolve()}),(function(){return Promise.resolve()}))]}))}))},e.prototype.getEvaluationDetails=function(){var e=this;return this.errorBoundary.capture("getEvaluationDetails",(function(){return e.store.getGlobalEvaluationDetails()}),(function(){return{time:Date.now(),reason:E.EvaluationReason.Error}}))},e.prototype.checkGate=function(e,t){var n=this;return void 0===t&&(t=!1),this.errorBoundary.capture("checkGate",(function(){var r,i,o,a=n.checkGateImpl(e,t);n.logGateExposureImpl(e,a);var s=n.options.getGateEvaluationCallback();s&&s(e,a.gate.value,{withExposureLoggingDisabled:!1});var u=n.options.getEvaluationCallback();u&&u({type:"gate",gate:new c.default(e,a.gate.value,a.gate.rule_id,a.evaluationDetails,null!==(r=a.gate.group_name)&&void 0!==r?r:null,null!==(i=a.gate.id_type)&&void 0!==i?i:null,null!==(o=a.gate.secondary_exposures)&&void 0!==o?o:[])});return!0===a.gate.value}),(function(){return!1}),{configName:e})},e.prototype.getFeatureGate=function(e,t){var n=this;return void 0===t&&(t=null),this.errorBoundary.capture("getFeatureGate",(function(){var r,i,o,a,s,u=n.checkGateImpl(e,null!==(r=null==t?void 0:t.ignoreOverrides)&&void 0!==r&&r);(null==t?void 0:t.disableExposureLogging)?n.logger.addNonExposedCheck(e):n.logGateExposureImpl(e,u);var l=n.options.getGateEvaluationCallback();l&&l(e,u.gate.value,{withExposureLoggingDisabled:null!==(i=null==t?void 0:t.disableExposureLogging)&&void 0!==i&&i});var d=new c.default(e,u.gate.value,u.gate.rule_id,u.evaluationDetails,null!==(o=u.gate.group_name)&&void 0!==o?o:null,null!==(a=u.gate.id_type)&&void 0!==a?a:null,null!==(s=u.gate.secondary_exposures)&&void 0!==s?s:[]),h=n.options.getEvaluationCallback();return h&&h({type:"gate",gate:d}),d}),(function(){return new c.default(e,!1,"",{reason:E.EvaluationReason.Error,time:Date.now()})}),{configName:e})},e.prototype.checkGateWithExposureLoggingDisabled=function(e,t){var n=this;return void 0===t&&(t=!1),this.errorBoundary.capture("checkGateWithExposureLoggingDisabled",(function(){var r,i,o;n.logger.addNonExposedCheck(e);var a=n.checkGateImpl(e,t),s=n.options.getGateEvaluationCallback();s&&s(e,a.gate.value,{withExposureLoggingDisabled:!0});var u=n.options.getEvaluationCallback();u&&u({type:"gate",gate:new c.default(e,a.gate.value,a.gate.rule_id,a.evaluationDetails,null!==(r=a.gate.group_name)&&void 0!==r?r:null,null!==(i=a.gate.id_type)&&void 0!==i?i:null,null!==(o=a.gate.secondary_exposures)&&void 0!==o?o:[])});return!0===a.gate.value}),(function(){return!1}))},e.prototype.logGateExposure=function(e){var t=this;this.errorBoundary.swallow("logGateExposure",(function(){t.logGateExposureImpl(e)}))},e.prototype.getConfig=function(e,t){var n=this;return void 0===t&&(t=!1),this.errorBoundary.capture("getConfig",(function(){var r=n.getConfigImpl(e,t);n.logConfigExposureImpl(e,r);var i=n.options.getEvaluationCallback();return i&&i({type:"config",config:r}),r}),(function(){return n.getEmptyConfig(e)}),{configName:e})},e.prototype.getConfigWithExposureLoggingDisabled=function(e,t){var n=this;return void 0===t&&(t=!1),this.errorBoundary.capture("getConfig",(function(){n.logger.addNonExposedCheck(e);var r=n.getConfigImpl(e,t),i=n.options.getEvaluationCallback();return i&&i({type:"config",config:r}),r}),(function(){return n.getEmptyConfig(e)}))},e.prototype.logConfigExposure=function(e){var t=this;this.errorBoundary.swallow("logConfigExposure",(function(){t.logConfigExposureImpl(e)}))},e.prototype.getExperiment=function(e,t,n){var r=this;return void 0===t&&(t=!1),void 0===n&&(n=!1),this.errorBoundary.capture("getExperiment",(function(){var i=r.getExperimentImpl(e,t,n);r.logExperimentExposureImpl(e,t,i);var o=r.options.getEvaluationCallback();return o&&o({type:"experiment",config:i}),i}),(function(){return r.getEmptyConfig(e)}),{configName:e})},e.prototype.getExperimentWithExposureLoggingDisabled=function(e,t,n){var r=this;return void 0===t&&(t=!1),void 0===n&&(n=!1),this.errorBoundary.capture("getExperimentWithExposureLoggingDisabled",(function(){r.logger.addNonExposedCheck(e);var i=r.getExperimentImpl(e,t,n),o=r.options.getEvaluationCallback();return o&&o({type:"experiment",config:i}),i}),(function(){return r.getEmptyConfig(e)}))},e.prototype.logExperimentExposure=function(e,t){var n=this;this.errorBoundary.swallow("logExperimentExposure",(function(){n.logExperimentExposureImpl(e,t)}))},e.prototype.getLayer=function(e,t){var n=this;return void 0===t&&(t=!1),this.errorBoundary.capture("getLayer",(function(){var r=n.getLayerImpl(n.logLayerParameterExposureForLayer,e,t),i=n.options.getEvaluationCallback();return i&&i({type:"layer",layer:r}),r}),(function(){return d.default._create(e,{},"",n.getEvalutionDetailsForError())}),{configName:e})},e.prototype.getLayerWithExposureLoggingDisabled=function(e,t){var n=this;return void 0===t&&(t=!1),this.errorBoundary.capture("getLayerWithExposureLoggingDisabled",(function(){n.logger.addNonExposedCheck(e);var r=n.getLayerImpl(null,e,t),i=n.options.getEvaluationCallback();return i&&i({type:"layer",layer:r}),r}),(function(){return d.default._create(e,{},"",n.getEvalutionDetailsForError())}))},e.prototype.logLayerParameterExposure=function(e,t,n){var r=this;void 0===n&&(n=!1),this.errorBoundary.swallow("logLayerParameterExposure",(function(){var i=r.getLayerImpl(null,e,n);r.logLayerParameterExposureForLayer(i,t,!0)}))},e.prototype.logEvent=function(e,t,n){var r=this;void 0===t&&(t=null),void 0===n&&(n=null),this.errorBoundary.swallow("logEvent",(function(){if(!r.logger||!r.sdkKey)throw new l.StatsigUninitializedError("Must initialize() before logging events.");if("string"==typeof e&&0!==e.length){r.shouldTrimParam(e,D)&&(b.default.info("eventName is too long, trimming to 64 characters."),e=e.substring(0,D)),"string"==typeof t&&r.shouldTrimParam(t,D)&&(b.default.info("value is too long, trimming to 64."),t=t.substring(0,D)),r.shouldTrimParam(n,O)&&(b.default.info("metadata is too big. Dropping the metadata."),n={error:"not logged due to size too large"});var i=new h.default(e);i.setValue(t),i.setMetadata(n),i.setUser(r.getCurrentUser()),r.logger.log(i)}else b.default.error("Event not logged. No valid eventName passed.")}))},e.prototype.updateUserWithValues=function(e,t){var n,r=this;return this.errorBoundary.capture("updateUserWithValues",(function(){var i=Date.now();if(!r.initializeCalled())throw new l.StatsigUninitializedError("Call initialize() first.");return n=function(e,t){var n=r.options.getUpdateUserCompletionCallback();null==n||n(Date.now()-i,e,t)},r.identity.updateUser(r.normalizeUser(e)),r.store.bootstrap(t),r.logger.resetDedupeKeys(),n(!0,null),!0}),(function(){return null==n||n(!1,"Failed to update user. An unexpected error occured."),!1}))},e.prototype.updateUser=function(e){return i(this,void 0,void 0,(function(){var t,n=this;return o(this,(function(r){return[2,this.errorBoundary.capture("updateUser",(function(){return i(n,void 0,void 0,(function(){var n,r,i,a,s,u,c=this;return o(this,(function(o){switch(o.label){case 0:if(n=Date.now(),!this.initializeCalled())throw new l.StatsigUninitializedError("Call initialize() first.");return t=function(e,t){var r=c.options.getUpdateUserCompletionCallback();null==r||r(Date.now()-n,e,t)},I.default.asyncStorage&&""==(null!==(u=this.identity.getStatsigMetadata().stableID)&&void 0!==u?u:"")?[4,this.identity.initAsync()]:[3,2];case 1:o.sent(),o.label=2;case 2:return this.identity.updateUser(this.normalizeUser(e)),r=this.getCurrentUserCacheKey(),i=Boolean(this.prefetchedUsersByCacheKey[r.v3]),a=this.store.updateUser(i),m.default.clearContext("api_call"),this.logger.resetDedupeKeys(),null!=a&&(i||this.isCacheValidForFetchMode(a))?(t(!0,null),[2,Promise.resolve(!0)]):null==this.pendingInitPromise?[3,4]:[4,this.pendingInitPromise];case 3:o.sent(),o.label=4;case 4:return this.options.getLocalModeEnabled()?(t(!0,null),[2,Promise.resolve(!0)]):(s=this.identity.getUser(),this.pendingInitPromise=this.fetchAndSaveValues({user:s,prefetchUsers:[],timeout:void 0}).finally((function(){c.pendingInitPromise=null})),[2,this.pendingInitPromise.then((function(){return t(!0,null),Promise.resolve(!0)})).catch((function(e){return t(!1,"Failed to update user: ".concat(e.message)),Promise.resolve(!1)}))])}}))}))}),(function(){return null==t||t(!1,"Failed to update user. An unexpected error occured."),Promise.resolve(!1)}))]}))}))},e.prototype.shutdown=function(){var e=this;this.errorBoundary.swallow("shutdown",(function(){if(e.logger.shutdown(),null!=e.appStateChangeSubscription){var t=e.appStateChangeSubscription;"function"==typeof t.remove&&t.remove()}w.default.cleanup()}))},e.prototype.getInitializeResponseJson=function(){var e=this;return this.errorBoundary.capture("getInitializeResponseJson",(function(){var t;return{values:e.store.getInitializeResponseJson(),evaluationDetails:null!==(t=e.getEvaluationDetails())&&void 0!==t?t:{reason:E.EvaluationReason.Uninitialized,time:0}}}),(function(){var t;return{values:"",evaluationDetails:null!==(t=e.getEvaluationDetails())&&void 0!==t?t:{reason:E.EvaluationReason.Uninitialized,time:0}}}))},e.prototype.overrideGate=function(e,t){var n=this;this.errorBoundary.swallow("overrideGate",(function(){n.ensureStoreLoaded(),n.store.overrideGate(e,t)}))},e.prototype.overrideConfig=function(e,t){var n=this;this.errorBoundary.swallow("overrideConfig",(function(){n.ensureStoreLoaded(),n.store.overrideConfig(e,t)}))},e.prototype.overrideLayer=function(e,t){var n=this;this.errorBoundary.swallow("overrideLayer",(function(){n.ensureStoreLoaded(),n.store.overrideLayer(e,t)}))},e.prototype.removeGateOverride=function(e){var t=this;this.errorBoundary.swallow("removeGateOverride",(function(){t.ensureStoreLoaded(),t.store.removeGateOverride(e)}))},e.prototype.removeConfigOverride=function(e){var t=this;this.errorBoundary.swallow("removeConfigOverride",(function(){t.ensureStoreLoaded(),t.store.removeConfigOverride(e)}))},e.prototype.removeLayerOverride=function(e){var t=this;this.errorBoundary.swallow("removeLayerOverride",(function(){t.ensureStoreLoaded(),t.store.removeLayerOverride(e)}))},e.prototype.removeOverride=function(e){var t=this;this.errorBoundary.swallow("removeOverride",(function(){t.ensureStoreLoaded(),t.store.removeGateOverride(e)}))},e.prototype.getOverrides=function(){var e=this;return this.errorBoundary.capture("getOverrides",(function(){return e.ensureStoreLoaded(),e.store.getAllOverrides().gates}),(function(){return{}}))},e.prototype.getAllOverrides=function(){var e=this;return this.errorBoundary.capture("getAllOverrides",(function(){return e.ensureStoreLoaded(),e.store.getAllOverrides()}),(function(){return{gates:{},configs:{},layers:{}}}))},e.prototype.getStableID=function(){var e=this;return this.errorBoundary.capture("getStableID",(function(){return e.identity.getStatsigMetadata().stableID}),(function(){return""}))},e.prototype.initializeCalled=function(){return this.initCalled},e.prototype.setSDKPackageInfo=function(e){null!=e&&(this.identity.setSDKPackageInfo(e),this.errorBoundary.setStatsigMetadata(this.getStatsigMetadata()))},e.prototype.setDebugInfo=function(e){var t=this;this.errorBoundary.capture("setDebuggingInfo",(function(){if(!t.initializeCalled())throw new l.StatsigUninitializedError("Call initialize() first.");t.logger.setDebugInfo(e)}),(function(){}))},e.setAsyncStorage=function(e){null!=e&&(I.default.asyncStorage=e)},e.prototype.setOnCacheLoadedReactCallback=function(e){this.onCacheLoadedForReact=null!=e?e:null},e.setReactNativeUUID=function(t){null!=t&&(e.reactNativeUUID=t)},e.prototype.setAppState=function(e){null!=e&&(this.appState=e)},e.prototype.setNativeModules=function(e){null!=e&&this.identity.setNativeModules(e)},e.prototype.setPlatform=function(e){null!=e&&this.identity.setPlatform(e)},e.prototype.setRNDeviceInfo=function(e){null!=e&&this.identity.setRNDeviceInfo(e)},e.prototype.setExpoConstants=function(e){null!=e&&this.identity.setExpoConstants(e)},e.prototype.setExpoDevice=function(e){null!=e&&this.identity.setExpoDevice(e)},e.prototype.flushEvents=function(){this.logger.flush()},e.prototype.reenableAllLogging=function(){this.getOptions().reenableAllLogging()},e.prototype.isCacheValidForFetchMode=function(e){return"cache-or-network"===this.options.getFetchMode()&&e>this.startTime},e.prototype.handleOptionalLogging=function(){var e=this,t=this.options.getDisableErrorLogging(),n=this.options.getDisableAutoMetricsLogging();if((!t||!n)&&!this.optionalLoggingSetup&&"undefined"!=typeof window&&window&&window.addEventListener){var r=this.identity.getUser();if(t||window.addEventListener("error",(function(t){var n,i=t.error;if(null!=i&&"object"==typeof i)try{i=JSON.stringify(i)}catch(t){i="Failed to stringify Error"}e.logger.logAppError(r,null!==(n=t.message)&&void 0!==n?n:"",{filename:t.filename,lineno:t.lineno,colno:t.colno,error_obj:i})})),!n){if("undefined"==typeof document||!document||"undefined"==typeof setTimeout||!setTimeout)return;var i=function(){setTimeout((function(){e.logger.logAppMetrics(r)}),1e3)};"complete"===document.readyState?i():window.addEventListener("load",(function(){return i()}))}this.optionalLoggingSetup=!0}},e.prototype.handleAppStateChange=function(e){var t=this;"active"===this.currentAppState&&e.match(/inactive|background/)?this.logger.flush(!0):null!=this.currentAppState&&this.currentAppState.match(/inactive|background/)&&"active"===e&&this.logger.sendSavedRequests().catch((function(e){return t.errorBoundary.logError("sendSavedRequests:handleAppStateChange",e)})),this.currentAppState=e},e.prototype.shouldTrimParam=function(e,t){return null!=e&&("string"==typeof e?e.length>t:"object"==typeof e?JSON.stringify(e).length>t:"number"==typeof e&&e.toString().length>t)},e.prototype.normalizePrefetchUsers=function(e){var t=this;return null==e?[]:e.map((function(e){return t.normalizeUser(e)}))},e.prototype.normalizeUser=function(e){var t={};try{t=JSON.parse(JSON.stringify(e))}catch(e){throw new l.StatsigInvalidArgumentError("User object must be convertable to JSON string.")}return t=this.trimUserObjIfNeeded(t),null!=this.options.getEnvironment()&&(t.statsigEnvironment=this.options.getEnvironment()),t},e.prototype.trimUserObjIfNeeded=function(e){var t,n;return null==e?{}:(this.shouldTrimParam(null!==(t=e.userID)&&void 0!==t?t:null,D)&&(b.default.info("User ID is too large, trimming to 64characters"),e.userID=null===(n=e.userID)||void 0===n?void 0:n.toString().substring(0,D)),this.shouldTrimParam(e,O)&&(e.custom={},this.shouldTrimParam(e,O)?(b.default.info("User object is too large, only keeping the user ID."),e={userID:e.userID}):b.default.info("User object is too large, dropping the custom property.")),e)},e.prototype.ensureStoreLoaded=function(){if(!this.store.isLoaded())throw new l.StatsigUninitializedError("Call and wait for initialize() to finish first.")},e.prototype.getEvalutionDetailsForError=function(){return{time:Date.now(),reason:E.EvaluationReason.Error}},e.prototype.fetchAndSaveValues=function(e){var t,n,a,s;return i(this,void 0,void 0,(function(){var u,l,c,d,h,f,p,g,v=this;return o(this,(function(y){return u=e.user,l=null!==(t=e.prefetchUsers)&&void 0!==t?t:[],c=null!==(n=e.timeout)&&void 0!==n?n:this.options.getInitTimeoutMs(),l.length>5&&b.default.info("Cannot prefetch more than 5 users."),d=this.normalizePrefetchUsers(l).slice(0,5).reduce((function(e,t){return e[(0,_.getUserCacheKey)(v.getStableID(),t,v.getSDKKey()).v3]=t,e}),{}),h=String(null!==(s=null===(a=this.getStatsigMetadata())||void 0===a?void 0:a.stableID)&&void 0!==s?s:""),f=null,0===l.length&&(f=this.store.getLastUpdateTime(u,h)),p=this.store.getPreviousHashUsed(u,h),g=this.store.getPreviousDerivedFields(u,h),[2,this.network.fetchValues({user:u,sinceTime:f,timeout:c,useDeltas:null!=f&&p===(this.getOptions().getDisableHashing()?"none":"djb2"),prefetchUsers:l.length>0?d:void 0,previousDerivedFields:g}).eventually((function(e){var t;(0,S.verifySDKKeyUsed)(e,null!==(t=v.sdkKey)&&void 0!==t?t:"",v.errorBoundary)&&(null==e?void 0:e.has_updates)&&v.store.saveWithoutUpdatingClientState(u,e,h,l.length>0?d:void 0).catch((function(e){return v.errorBoundary.logError("fetchAndSaveValues:eventually",e)}))})).then((function(e){return v.errorBoundary.swallow("fetchAndSaveValues",(function(){return i(v,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return m.default.mark.initialize.process.start({}),(0,S.verifySDKKeyUsed)(e,null!==(t=this.sdkKey)&&void 0!==t?t:"",this.errorBoundary)?(null==e?void 0:e.has_updates)?[4,this.store.save(u,e,h,l.length>0?d:void 0)]:[3,2]:(m.default.mark.initialize.process.end({success:!1}),[2]);case 1:return n.sent(),[3,3];case 2:(null==e?void 0:e.is_no_content)&&this.store.setEvaluationReason(E.EvaluationReason.NetworkNotModified),n.label=3;case 3:return this.prefetchedUsersByCacheKey=r(r({},this.prefetchedUsersByCacheKey),d),m.default.mark.initialize.process.end({success:!0}),[2]}}))}))}))}))]}))}))},e.prototype.checkGateImpl=function(e,t){if(this.ensureStoreLoaded(),"string"!=typeof e||0===e.length)throw new l.StatsigInvalidArgumentError("Must pass a valid string as the gateName.");return this.store.checkGate(e,t)},e.prototype.logGateExposureImpl=function(e,t){var n=!t,r=null!=t?t:this.checkGateImpl(e,!1),i=r.gate;this.logger.logGateExposure(this.getCurrentUser(),e,i.value,i.rule_id,i.secondary_exposures,r.evaluationDetails,n,this.store.getBootstrapMetadata())},e.prototype.getConfigImpl=function(e,t){if(this.ensureStoreLoaded(),"string"!=typeof e||0===e.length)throw new l.StatsigInvalidArgumentError("Must pass a valid string as the configName.");return this.store.getConfig(e,t)},e.prototype.logConfigExposureImpl=function(e,t){var n=!t,r=null!=t?t:this.getConfigImpl(e,!1);this.logger.logConfigExposure(this.getCurrentUser(),e,r.getRuleID(),r._getSecondaryExposures(),r.getEvaluationDetails(),n,this.store.getBootstrapMetadata())},e.prototype.getExperimentImpl=function(e,t,n){if(this.ensureStoreLoaded(),"string"!=typeof e||0===e.length)throw new l.StatsigInvalidArgumentError("Must pass a valid string as the experimentName.");return this.store.getExperiment(e,t,n)},e.prototype.logExperimentExposureImpl=function(e,t,n){var r=!n,i=null!=n?n:this.getExperimentImpl(e,t,!1);this.logger.logConfigExposure(this.getCurrentUser(),e,i.getRuleID(),i._getSecondaryExposures(),i.getEvaluationDetails(),r,this.store.getBootstrapMetadata())},e.prototype.getLayerImpl=function(e,t,n){if(this.ensureStoreLoaded(),"string"!=typeof t||0===t.length)throw new l.StatsigInvalidArgumentError("Must pass a valid string as the layerName.");return this.store.getLayer(e,t,n)},e.prototype.getEmptyConfig=function(e){return new s.default(e,{},"",this.getEvalutionDetailsForError())},e.prototype.fireAndForgetPrefechUsers=function(){this.prefetchUsers(this.options.getPrefetchUsers()).catch((function(){}))},e}();t.default=C},833:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var a=n(831),s=n(474),u=n(115),l=o(n(996)),c=o(n(985)),d=function(){function e(e,t,n){var r;this.platform=null,this.nativeModules=null,this.sdkType="js-client",this.reactNativeUUID=n,this.user=e,this.sdkVersion=s.version,this.statsigMetadata={sdkType:this.sdkType,sdkVersion:this.sdkVersion};var i=t;l.default.asyncStorage||(i=null!==(r=null!=i?i:c.default.getItem(u.STATSIG_STABLE_ID_KEY))&&void 0!==r?r:this.getUUID()),i&&(this.statsigMetadata.stableID=i)}return e.prototype.saveStableID=function(){null!=this.stats