statsig-js
Version:
Statsig JavaScript client SDK for single user environments.
1 lines • 124 kB
JavaScript
!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={23:(e,t,r)=>{var n;!function(){"use strict";var t="input is invalid type",i="object"==typeof window,o=i?window:{};o.JS_SHA256_NO_WINDOW&&(i=!1);var s=!i&&"object"==typeof self,a=!o.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;a?o=r.g:s&&(o=self);var u=!o.JS_SHA256_NO_COMMON_JS&&e.exports,l=r.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(r){return new b(t,!0).update(r)[e]()}},m=function(e){var t=y("hex",e);a&&(t=E(t,e)),t.create=function(){return new b(e)},t.update=function(e){return t.create().update(e)};for(var r=0;r<g.length;++r){var n=g[r];t[n]=y(n,e)}return t},E=function(e,n){var i,s=r(127),a=r(371).Buffer,u=n?"sha224":"sha256";i=a.from&&!o.JS_SHA256_NO_BUFFER_FROM?a.from:function(e){return new a(e)};return function(r){if("string"==typeof r)return s.createHash(u).update(r,"utf8").digest("hex");if(null==r)throw new Error(t);return r.constructor===ArrayBuffer&&(r=new Uint8Array(r)),Array.isArray(r)||ArrayBuffer.isView(r)||r.constructor===a?s.createHash(u).update(i(r)).digest("hex"):e(r)}},S=function(e,t){return function(r,n){return new I(r,t,!0).update(n)[e]()}},_=function(e){var t=S("hex",e);t.create=function(t){return new I(t,e)},t.update=function(e,r){return t.create(e).update(r)};for(var r=0;r<g.length;++r){var n=g[r];t[n]=S(n,e)}return t};function b(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,r,n){var i,o=typeof e;if("string"===o){var s,a=[],u=e.length,l=0;for(i=0;i<u;++i)(s=e.charCodeAt(i))<128?a[l++]=s:s<2048?(a[l++]=192|s>>6,a[l++]=128|63&s):s<55296||s>=57344?(a[l++]=224|s>>12,a[l++]=128|s>>6&63,a[l++]=128|63&s):(s=65536+((1023&s)<<10|1023&e.charCodeAt(++i)),a[l++]=240|s>>18,a[l++]=128|s>>12&63,a[l++]=128|s>>6&63,a[l++]=128|63&s);e=a}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 b(r,!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}b.call(this,r,n),this.update(h),this.oKeyPad=d,this.inner=!0,this.sharedMemory=n}b.prototype.update=function(e){if(!this.finalized){var r,n=typeof e;if("string"!==n){if("object"!==n)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);r=!0}for(var i,o,s=0,a=e.length,u=this.blocks;s<a;){if(this.hashed&&(this.hashed=!1,u[0]=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),r)for(o=this.start;s<a&&o<64;++s)u[o>>2]|=e[s]<<f[3&o++];else for(o=this.start;s<a&&o<64;++s)(i=e.charCodeAt(s))<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(++s)),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}},b.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()}},b.prototype.hash=function(){var e,t,r,n,i,o,s,a,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,r=((i=m[e-2])>>>17|i<<15)^(i>>>19|i<<13)^i>>>10,m[e]=m[e-16]+t+m[e-7]+r<<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),n=(o=l&c)^l&d^u,y=h+(i=y+(r=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(f&g^~f&v)+p[e]+m[e])<<0,h=i+(t+n)<<0),t=(h>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),n=(s=h&l)^h&c^o,v=d+(i=v+(r=(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+n)<<0)>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),n=(a=d&h)^d&l^s,g=c+(i=g+(r=(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+n)<<0)>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),n=(u=c&d)^c&h^a,f=l+(i=f+(r=(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+n)<<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},b.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,o=this.h5,s=this.h6,a=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[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[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[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[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];return this.is224||(u+=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]),u},b.prototype.toString=b.prototype.hex,b.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,o=this.h5,s=this.h6,a=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,r>>24&255,r>>16&255,r>>8&255,255&r,n>>24&255,n>>16&255,n>>8&255,255&n,i>>24&255,i>>16&255,i>>8&255,255&i,o>>24&255,o>>16&255,o>>8&255,255&o,s>>24&255,s>>16&255,s>>8&255,255&s];return this.is224||u.push(a>>24&255,a>>16&255,a>>8&255,255&a),u},b.prototype.array=b.prototype.digest,b.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 b,I.prototype.finalize=function(){if(b.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();b.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),b.prototype.finalize.call(this)}};var w=m();w.sha256=w,w.sha224=m(!0),w.sha256.hmac=_(),w.sha224.hmac=_(!0),u?e.exports=w:(o.sha256=w.sha256,o.sha224=w.sha224,l&&(void 0===(n=function(){return w}.call(w,r,w,e))||(e.exports=n)))}()},825:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t,r,n,i,o,s,a,u,l){void 0===i&&(i=[]),void 0===o&&(o=""),void 0===s&&(s=null),void 0===a&&(a=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!=r?r:"",this.secondaryExposures=i,this.allocatedExperimentName=o,this.evaluationDetails=n,this.onDefaultValueFallback=s,this.groupName=a,this.idType=u,this.isExperimentActive=l}return e.prototype.get=function(e,t,r){var n,i,o=this.getValue(e,t);if(null==o)return t;var s=Array.isArray(t)?"array":typeof t,a=Array.isArray(o)?"array":typeof o;return r?r(o)?o:(null===(n=this.onDefaultValueFallback)||void 0===n||n.call(this,this,e,s,a),t):null==t||s===a?o:(null===(i=this.onDefaultValueFallback)||void 0===i||i.call(this,this,e,s,a),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=r},742:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ExceptionEndpoint=void 0;var s=r(614),a=r(187),u=o(r(860)),l=o(r(139));t.ExceptionEndpoint="https://statsigapi.net/v1/sdk_exception";var c=function(){function e(e,t){this.sdkKey=e,this.sdkOptions=t,this.seen=new Set;var r=Math.floor(1e4*Math.random());this.setupDiagnostics(0===r?30:0)}return e.prototype.setStatsigMetadata=function(e){this.statsigMetadata=e},e.prototype.swallow=function(e,t,r){void 0===r&&(r={}),this.capture(e,t,(function(){}),r)},e.prototype.capture=function(e,t,r,n){var i=this;void 0===n&&(n={});var o=null;try{o=this.beginMarker(e);var s=t(),a=!0;return s instanceof Promise?s.catch((function(t){return a=!1,i.onCaught(e,t,r,n)})).then((function(t){return i.endMarker(e,a,o),t})):(this.endMarker(e,!0,o,n.configName),s)}catch(t){return this.endMarker(e,!1,o,n.configName),this.onCaught(e,t,r,n)}},e.prototype.logError=function(e,r,o){var a=this,u=void 0===o?{}:o,c=u.getExtraData,d=u.configName;this.sdkOptions.isAllLoggingDisabled()||n(a,void 0,void 0,(function(){var n,o,a,u,h,f,p,g;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),"function"!=typeof c?[3,2]:[4,c()];case 1:return o=i.sent(),[3,3];case 2:o={},i.label=3;case 3:return n=o,a=(0,l.default)(r),u=a.name,h=a.trace,n.configName=d,this.seen.has(u)?[2]:(this.seen.add(u),null==(f=null!==(g=this.statsigMetadata)&&void 0!==g?g:{}).sessionID&&(f.sessionID=(0,s.v4)()),p=JSON.stringify({tag:e,exception:u,info:h,statsigMetadata:f,statsigOptions:this.sdkOptions.getLoggingCopy(),extra:n}),[2,fetch(t.ExceptionEndpoint,{method:"POST",headers:{"STATSIG-API-KEY":this.sdkKey,"STATSIG-SDK-TYPE":String(f.sdkType),"STATSIG-SDK-VERSION":String(f.sdkVersion),"Content-Type":"application/json; charset=UTF-8"},body:p})]);case 4:return i.sent(),[3,5];case 5: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 r=e+"_"+u.default.getMarkerCount("api_call");return t.start({markerID:r},"api_call")?r:null},e.prototype.endMarker=function(e,t,r,n){var i=u.default.mark.api_call(e);r&&i&&i.end({markerID:r,success:t,configName:n},"api_call")},e.prototype.onCaught=function(e,t,r,n){if(void 0===n&&(n={}),t instanceof a.StatsigUninitializedError||t instanceof a.StatsigInvalidArgumentError)throw t;return t instanceof a.StatsigInitializationTimeoutError?(console.error("[Statsig] Timeout occured.",t),r()):(console.error("[Statsig] An unexpected exception occurred.",t),this.logError(e,t,n),r())},e}();t.default=c},187:function(e,t){"use strict";var r,n=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},r(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 n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.StatsigInitializationTimeoutError=t.StatsigSDKKeyMismatchError=t.StatsigInvalidArgumentError=t.StatsigUninitializedError=void 0;var i=function(e){function t(r){var n=e.call(this,null!=r?r:"Call and wait for initialize() to finish first.")||this;return Object.setPrototypeOf(n,t.prototype),n}return n(t,e),t}(Error);t.StatsigUninitializedError=i;var o=function(e){function t(r){var n=e.call(this,r)||this;return Object.setPrototypeOf(n,t.prototype),n}return n(t,e),t}(Error);t.StatsigInvalidArgumentError=o;var s=function(e){function t(r){var n=e.call(this,r)||this;return Object.setPrototypeOf(n,t.prototype),n}return n(t,e),t}(Error);t.StatsigSDKKeyMismatchError=s;var a=function(e){function t(r){var n=e.call(this,"The initialization timeout of "+r+"ms has been hit before the network request has completed.")||this;return Object.setPrototypeOf(n,t.prototype),n}return n(t,e),t}(Error);t.StatsigInitializationTimeoutError=a},857:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t,r,n,i,o,s,a,u,l){void 0===i&&(i=null),void 0===o&&(o=[]),void 0===s&&(s=[]),void 0===a&&(a=""),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!=r?r:"",this.evaluationDetails=n,this.secondaryExposures=o,this.undelegatedSecondaryExposures=s,this.allocatedExperimentName=a,this.explicitParameters=u,this.groupName=l}return e._create=function(t,r,n,i,o,s,a,u,l,c){return void 0===o&&(o=null),void 0===s&&(s=[]),void 0===a&&(a=[]),void 0===u&&(u=""),void 0===l&&(l=[]),void 0===c&&(c=null),new e(t,r,n,i,o,s,a,u,l,c)},e.prototype.get=function(e,t,r){var n=this,i=this.value[e];if(null==i)return t;var o=function(){return n.logLayerParameterExposure(e),i};return r?r(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 r=this.value[e];return null!=r&&this.logLayerParameterExposure(e),null!=r?r: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=r},820:function(e,t){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var n=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=r({},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=n},888:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version=void 0,t.version="4.47.0"},793:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var a=s(r(825)),u=s(r(742)),l=r(187),c=s(r(857)),d=s(r(820)),h=s(r(578)),f=s(r(332)),p=s(r(69)),g=s(r(574)),v=s(r(567)),y=r(433),m=r(898),E=s(r(31)),S=s(r(682)),_=s(r(860)),b=s(r(709)),I=r(28),w=r(645),D=64,k=2048,C=function(){function e(t,r,n){var i=this;if(this.appState=null,this.currentAppState=null,this.onCacheLoadedForReact=null,this.initCalled=!1,this.pendingInitPromise=null,this.optionalLoggingSetup=!1,this.prefetchedUsersByCacheKey={},this.logLayerParameterExposureForLayer=function(e,t,r){void 0===r&&(r=!1);var n="",o=e._getUndelegatedSecondaryExposures(),s=e._getExplicitParameters().includes(t);s&&(n=e._getAllocatedExperimentName(),o=e._getSecondaryExposures()),i.logger.logLayerExposure(i.getCurrentUser(),e.getName(),e.getRuleID(),o,n,t,s,e._getEvaluationDetails(),r)},!0!==(null==n?void 0:n.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,I.now)(),this.options=new g.default(n),this.logger=new f.default(this),_.default.initialize({options:this.options}),this.errorBoundary=new u.default(t,this.options),this.ready=!1,this.sdkKey=t,this.consoleLogger=new b.default(this.options.getLogLevel()),S.default.disabled=this.options.getDisableLocalStorage(),this.identity=new h.default(this.normalizeUser(null!=r?r:null),this.options.getOverrideStableID(),e.reactNativeUUID),this.network=new p.default(this),this.store=new v.default(this,this.options.getInitializeValues()),this.errorBoundary.setStatsigMetadata(this.getStatsigMetadata()),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,I.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,m.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 r,n,i;return e?"userid"===t.toLowerCase()?null!==(n=null===(r=e.userID)||void 0===r?void 0:r.toString())&&void 0!==n?n: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.getConsoleLogger=function(){return this.consoleLogger},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 r=null;t.ready||(t.ready=!0,t.initCalled=!0,r=t.options.getInitCompletionCallback()),t.handleOptionalLogging(),t.logger.sendSavedRequests().catch((function(e){return t.errorBoundary.logError("sendSavedRequests:setInitializeValues",e)})),r&&r((0,I.now)()-t.startTime,!0,null)}),(function(){t.ready=!0,t.initCalled=!0;var e=t.options.getInitCompletionCallback();e&&e((0,I.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,r=this;return o(this,(function(n){switch(n.label){case 0:return null!=this.pendingInitPromise?[2,this.pendingInitPromise]:this.ready?[2,Promise.resolve()]:(_.default.mark.overall.start({}),this.initCalled=!0,E.default.asyncStorage?[4,this.identity.initAsync()]:[3,3]);case 1:return n.sent(),[4,this.store.loadAsync()];case 2:n.sent(),n.label=3;case 3:return null===(t=this.onCacheLoadedForReact)||void 0===t||t.call(this),this.appState&&this.appState.addEventListener&&"function"==typeof this.appState.addEventListener&&(this.currentAppState=this.appState.currentState,this.appState.addEventListener("change",this.handleAppStateChange.bind(this))),this.options.getLocalModeEnabled()?[2,Promise.resolve()]:(e=this.identity.getUser(),this.pendingInitPromise=this.fetchAndSaveValues({user:e,prefetchUsers:this.options.getPrefetchUsers(),timeout:this.options.getInitTimeoutMs()}).then((function(){return _.default.mark.overall.end({success:!0,evaluationDetails:r.store.getGlobalEvaluationDetails()}),{success:!0,message:null}})).catch((function(e){var t;return r.errorBoundary.logError("initializeAsync:fetchAndSaveValues",e),_.default.mark.overall.end({success:!1,error:_.default.formatError(e),evaluationDetails:r.store.getGlobalEvaluationDetails()}),{success:!1,message:null!==(t=e.message)&&void 0!==t?t:null}})).then((function(e){var t=e.success,n=e.message,i=r.options.getInitCompletionCallback();i&&i((0,I.now)()-r.startTime,t,n)})).finally((function(){return i(r,void 0,void 0,(function(){return o(this,(function(t){return this.pendingInitPromise=null,this.ready=!0,this.delayedSetup(),this.logger.logDiagnostics(e,"initialize"),[2]}))}))})),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(r){return[2,this.errorBoundary.capture("prefetchUsers",(function(){if(e&&0!=e.length)return t.fetchAndSaveValues({user:null,prefetchUsers:e,timeout:0})}),(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:y.EvaluationReason.Error}}))},e.prototype.checkGate=function(e,t){var r=this;return void 0===t&&(t=!1),this.errorBoundary.capture("checkGate",(function(){var n=r.checkGateImpl(e,t);r.logGateExposureImpl(e,n);var i=r.options.getGateEvaluationCallback();return i&&i(e,n.gate.value,{withExposureLoggingDisabled:!1}),!0===n.gate.value}),(function(){return!1}),{configName:e})},e.prototype.checkGateWithExposureLoggingDisabled=function(e,t){var r=this;return void 0===t&&(t=!1),this.errorBoundary.capture("checkGateWithExposureLoggingDisabled",(function(){var n=r.checkGateImpl(e,t),i=r.options.getGateEvaluationCallback();return i&&i(e,n.gate.value,{withExposureLoggingDisabled:!0}),!0===n.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 r=this;return void 0===t&&(t=!1),this.errorBoundary.capture("getConfig",(function(){var n=r.getConfigImpl(e,t);return r.logConfigExposureImpl(e,n),n}),(function(){return r.getEmptyConfig(e)}),{configName:e})},e.prototype.getConfigWithExposureLoggingDisabled=function(e,t){var r=this;return void 0===t&&(t=!1),this.errorBoundary.capture("getConfig",(function(){return r.getConfigImpl(e,t)}),(function(){return r.getEmptyConfig(e)}))},e.prototype.logConfigExposure=function(e){var t=this;this.errorBoundary.swallow("logConfigExposure",(function(){t.logConfigExposureImpl(e)}))},e.prototype.getExperiment=function(e,t,r){var n=this;return void 0===t&&(t=!1),void 0===r&&(r=!1),this.errorBoundary.capture("getExperiment",(function(){var i=n.getExperimentImpl(e,t,r);return n.logExperimentExposureImpl(e,t,i),i}),(function(){return n.getEmptyConfig(e)}),{configName:e})},e.prototype.getExperimentWithExposureLoggingDisabled=function(e,t,r){var n=this;return void 0===t&&(t=!1),void 0===r&&(r=!1),this.errorBoundary.capture("getExperimentWithExposureLoggingDisabled",(function(){return n.getExperimentImpl(e,t,r)}),(function(){return n.getEmptyConfig(e)}))},e.prototype.logExperimentExposure=function(e,t){var r=this;this.errorBoundary.swallow("logExperimentExposure",(function(){r.logExperimentExposureImpl(e,t)}))},e.prototype.getLayer=function(e,t){var r=this;return void 0===t&&(t=!1),this.errorBoundary.capture("getLayer",(function(){return r.getLayerImpl(r.logLayerParameterExposureForLayer,e,t)}),(function(){return c.default._create(e,{},"",r.getEvalutionDetailsForError())}),{configName:e})},e.prototype.getLayerWithExposureLoggingDisabled=function(e,t){var r=this;return void 0===t&&(t=!1),this.errorBoundary.capture("getLayerWithExposureLoggingDisabled",(function(){return r.getLayerImpl(null,e,t)}),(function(){return c.default._create(e,{},"",r.getEvalutionDetailsForError())}))},e.prototype.logLayerParameterExposure=function(e,t,r){var n=this;void 0===r&&(r=!1),this.errorBoundary.swallow("logLayerParameterExposure",(function(){var i=n.getLayerImpl(null,e,r);n.logLayerParameterExposureForLayer(i,t,!0)}))},e.prototype.logEvent=function(e,t,r){var n=this;void 0===t&&(t=null),void 0===r&&(r=null),this.errorBoundary.swallow("logEvent",(function(){if(!n.logger||!n.sdkKey)throw new l.StatsigUninitializedError("Must initialize() before logging events.");if("string"==typeof e&&0!==e.length){n.shouldTrimParam(e,D)&&(n.consoleLogger.info("eventName is too long, trimming to 64 characters."),e=e.substring(0,D)),"string"==typeof t&&n.shouldTrimParam(t,D)&&(n.consoleLogger.info("value is too long, trimming to 64."),t=t.substring(0,D)),n.shouldTrimParam(r,k)&&(n.consoleLogger.info("metadata is too big. Dropping the metadata."),r={error:"not logged due to size too large"});var i=new d.default(e);i.setValue(t),i.setMetadata(r),i.setUser(n.getCurrentUser()),n.logger.log(i)}else n.consoleLogger.error("Event not logged. No valid eventName passed.")}))},e.prototype.updateUserWithValues=function(e,t){var r,n=this;return this.errorBoundary.capture("updateUserWithValues",(function(){var i=Date.now();if(!n.initializeCalled())throw new l.StatsigUninitializedError("Call initialize() first.");return r=function(e,t){var r=n.options.getUpdateUserCompletionCallback();null==r||r(Date.now()-i,e,t)},n.identity.updateUser(n.normalizeUser(e)),n.store.bootstrap(t),r(!0,null),!0}),(function(){return null==r||r(!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,r=this;return o(this,(function(n){return[2,this.errorBoundary.capture("updateUser",(function(){return i(r,void 0,void 0,(function(){var r,n,i,s,a,u,c=this;return o(this,(function(o){switch(o.label){case 0:if(r=Date.now(),!this.initializeCalled())throw new l.StatsigUninitializedError("Call initialize() first.");return t=function(e,t){var n=c.options.getUpdateUserCompletionCallback();null==n||n(Date.now()-r,e,t)},E.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)),n=this.getCurrentUserCacheKey(),i=Boolean(this.prefetchedUsersByCacheKey[n.v3]),s=this.store.updateUser(i),_.default.clearContext("api_call"),this.logger.resetDedupeKeys(),null!=s&&(i||this.isCacheValidForFetchMode(s))?(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)]):(a=this.identity.getUser(),this.pendingInitPromise=this.fetchAndSaveValues({user:a,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: "+e),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(){e.logger.shutdown(),e.appState&&e.appState.removeEventListener&&"function"==typeof e.appState.removeEventListener&&e.appState.removeEventListener("change",e.handleAppStateChange.bind(e)),S.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:y.EvaluationReason.Uninitialized,time:0}}}),(function(){var t;return{values:"",evaluationDetails:null!==(t=e.getEvaluationDetails())&&void 0!==t?t:{reason:y.EvaluationReason.Uninitialized,time:0}}}))},e.prototype.overrideGate=function(e,t){var r=this;this.errorBoundary.swallow("overrideGate",(function(){r.ensureStoreLoaded(),r.store.overrideGate(e,t)}))},e.prototype.overrideConfig=function(e,t){var r=this;this.errorBoundary.swallow("overrideConfig",(function(){r.ensureStoreLoaded(),r.store.overrideConfig(e,t)}))},e.prototype.overrideLayer=function(e,t){var r=this;this.errorBoundary.swallow("overrideLayer",(function(){r.ensureStoreLoaded(),r.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.setAsyncStorage=function(e){null!=e&&(E.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(),r=this.options.getDisableAutoMetricsLogging();if((!t||!r)&&!this.optionalLoggingSetup&&"undefined"!=typeof window&&window&&window.addEventListener){var n=this.identity.getUser();if(t||window.addEventListener("error",(function(t){var r,i=t.error;if(null!=i&&"object"==typeof i)try{i=JSON.stringify(i)}catch(t){i="Failed to stringify Error"}e.logger.logAppError(n,null!==(r=t.message)&&void 0!==r?r:"",{filename:t.filename,lineno:t.lineno,colno:t.colno,error_obj:i})})),!r){if("undefined"==typeof document||!document||"undefined"==typeof setTimeout||!setTimeout)return;var i=function(){setTimeout((function(){e.logger.logAppMetrics(n)}),1e3)};"complete"===document.readyState?i():window.addEventListener("load",(function(){return i()}))}this.optionalLoggingSetup=!0}},e.prototype.handleAppStateChange=function(e){var t,r=this;"active"===this.currentAppState&&e.match(/inactive|background/)?this.logger.flush(!0):(null===(t=this.currentAppState)||void 0===t?void 0:t.match(/inactive|background/))&&"active"===e&&this.logger.sendSavedRequests().catch((function(e){return r.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,r;return null==e?{}:(this.shouldTrimParam(null!==(t=e.userID)&&void 0!==t?t:null,D)&&(this.consoleLogger.info("User ID is too large, trimming to 64characters"),e.userID=null===(r=e.userID)||void 0===r?void 0:r.toString().substring(0,D)),this.shouldTrimParam(e,k)&&(e.custom={},this.shouldTrimParam(e,k)?(this.consoleLogger.info("User object is too large, only keeping the user ID."),e={userID:e.userID}):this.consoleLogger.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:y.EvaluationReason.Error}},e.prototype.fetchAndSaveValues=function(e){var t,r,s,a,u,l;return i(this,void 0,void 0,(function(){var c,d,h,f,p,g,v=this;return o(this,(function(E){return c=e.user,d=null!==(t=e.prefetchUsers)&&void 0!==t?t:[],h=null!==(r=e.timeout)&&void 0!==r?r:this.options.getInitTimeoutMs(),d.length>5&&this.consoleLogger.info("Cannot prefetch more than 5 users."),f=this.normalizePrefetchUsers(d).slice(0,5).reduce((function(e,t){return e[(0,m.getUserCacheKey)(v.getStableID(),t,v.getSDKKey()).v3]=t,e}),{}),p=null,0===d.length&&(p=this.store.getLastUpdateTime(c,String(null!==(a=null===(s=this.getStatsigMetadata())||void 0===s?void 0:s.stableID)&&void 0!==a?a:""))),g=this.store.getPreviousDerivedFields(c,String(null!==(l=null===(u=this.getStatsigMetadata())||void 0===u?void 0:u.stableID)&&void 0!==l?l:"")),[2,this.network.fetchValues({user:c,sinceTime:p,timeout:h,useDeltas:null!=p,prefetchUsers:d.length>0?f:void 0,previousDerivedFields:g}).eventually((function(e){var t;(0,w.verifySDKKeyUsed)(e,null!==(t=v.sdkKey)&&void 0!==t?t:"",v.errorBoundary)&&(null==e?void 0:e.has_updates)&&v.store.saveWithoutUpdatingClientState(c,e,d.length>0?f:void 0).catch((function(e){return v.errorBoundary.logError("fetchAndSaveValues:eventually",e)}))})).then((function(e){return i(v,void 0,void 0,(function(){var t=this;return o(this,(function(r){return[2,this.errorBoundary.swallow("fetchAndSaveValues",(function(){return i(t,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return _.default.mark.initialize.process.start({}),(0,w.verifySDKKeyUsed)(e,null!==(t=this.sdkKey)&&void 0!==t?t:"",this.errorBoundary)?(null==e?void 0:e.has_updates)?[4,this.store.save(c,e,d.length>0?f:void 0)]:[3,2]:(_.default.mark.initialize.process.end({success:!1}),[2]);case 1:return r.sent(),[3,3];case 2:(null==e?void 0:e.is_no_content)&&this.store.setEvaluationReason(y.EvaluationReason.NetworkNotModified),r.label=3;case 3:return this.prefetchedUsersByCacheKey=n(n({},this.prefetchedUsersByCacheKey),f),_.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 r=!t,n=null!=t?t:this.checkGateImpl(e,!1),i=n.gate;this.logger.logGateExposure(this.getCurrentUser(),e,i.value,i.rule_id,i.secondary_exposures,n.evaluationDetails,r)},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 r=!t,n=null!=t?t:this.getConfigImpl(e,!1);this.logger.logConfigExposure(this.getCurrentUser(),e,n.getRuleID(),n._getSecondaryExposures(),n.getEvaluationDetails(),r)},e.prototype.getExperimentImpl=function(e,t,r){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,r)},e.prototype.logExperimentExposureImpl=function(e,t,r){var n=!r,i=null!=r?r:this.getExperimentImpl(e,t,!1);this.logger.logConfigExposure(this.getCurrentUser(),e,i.getRuleID(),i._getSecondaryExposures(),i.getEvaluationDetails(),n)},e.prototype.getLayerImpl=function(e,t,r){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,r)},e.prototype.getEmptyConfig=function(e){return new a.default(e,{},"",this.getEvalutionDetailsForError())},e.prototype.fireAndForgetPrefechUsers=function(){this.prefetchUsers(this.options.getPrefetchUsers()).catch((function(){}))},e}();t.default=C},578:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var s=r(614),a=r(652),u=o(r(31)),l=o(r(682)),c=r(888),d=function(){function e(e,t,r){var n;this.platform=null,this.nativeModules=null,this.sdkType="js-client",this.reactNativeUUID=r,this.user=e,this.sdkVersion=c.version,this.statsigMetadata={sdkType:this.sdkType,sdkVersion:this.sdkVersion};var i=t;u.default.asyncStorage||(i=null!==(n=null!=i?i:l.default.getItem(a.STATSIG_STABLE_ID_KEY))&&void 0!==n?n:this.getUUID()),i&&(this.statsigMetadata.stableID=i)}return e.prototype.saveStableID=function(){null!=this.statsigMetadata.stableID&&l.default.setItem(a.STATSIG_STABLE_ID_KEY,this.statsigMetadata.stableID)},e.prototype.initAsync=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return(e=this.statsigMetadata.stableID)?[3,2]:[4,u.default.getItemAsync(a.STATSIG_STABLE_ID_KEY)];case 1:e=null!=(e=t.sent())?e:this.getUUID(),t.label=2;case 2:return this.statsigMetadata.stableID=e,u.default.setItemAsync(a.STATSIG_STABLE_ID_KEY,e).catch((function(){})),[2,this]}}))}))},e.prototype.getSDKType=function(){return this.sdkType},e.prototype.getSDKVersion=function(){return this.sdkVersion},e.prototype.getStatsigMetadata=function(){return this.statsigMetadata.sdkType=this.sdkType,this.statsigMetadata.sdkVersion=this.sdkVersion,this.statsigMetadata},e.prototype.getUser=function(){return this.user},e.prototype.updateUser=function(e){this.user=e},e.prototype.setSDKPackageInfo=function(e){this.sdkType=e.sdkType,this.sdkVersion=e.sdkVersion},e.prototype.setPlatform=function(e){this.platform=e,this.updateMetadataFromNativeModules()},e.prototype.setNativeModules=function(e){this.nativeModules=e,this.updateMetadataFromNativeModules()},e.prototype.updateMetadataFromNativeModules=function(){var e,t,r,n,i,o,s;null!=this.platform&&null!=this.nativeModules&&("android"===(null===(e=this.platform.OS)||void 0===e?void 0:e.toLocaleLowerCase())?this.statsigMetadata.locale=null===(t=this.nativeModules.I18nManager)||void 0===t?void 0:t.localeIdentifier:"ios"===(null===(r=this.platform.OS)||void 0===r?void 0:r.toLocaleLowerCase())&&(this.statsigMetadata.locale=(null===(i=null===(n=this.nativeModules.SettingsManager)||void 0===n?void 0:n.settings)||void 0===i?void 0:i.AppleLocale)||(null===(s=null===(o=this.nativeModules.SettingsManager)||void 0===o?void 0:o.settings)||void 0===s?void 0:s.AppleLanguages[0])))},e.prototype.getUUID=function(){var e,t;return null!==(t=null===(e=this.reactNativeUUID)||void 0===e?void 0:e.v4())&&void 0!==t?t:(0,s.v4)()},e.prototype.setRNDeviceInfo=function(e){var t,r,n,i,o;this.statsigMetadata.appVersion=null!==(t=e.getVersion())&&void 0!==t?t:"",this.statsigMetadata.systemVersion=null!==(r=e.getSystemVersion())&&void 0!==r?r:"",this.statsigMetadata.systemName=null!==(n=e.getSystemName())&&void 0!==n?n:"",this.statsigMetadata.deviceModelName=null!==(i=e.getModel())&&void 0!==i?i:"",this.statsigMetadata.deviceModel=null!==(o=e.getDeviceId())&&void 0!==o?o:""},e.prototype.setExpoConstants=function(e){var t,r;this.statsigMetadata.appVersion=null!==(r=null!==(t=e.nativeAppVersion)&&void 0!==t?t:e.nativeBuildVersion)&&void 0!==r?r:""},e.prototype.setExpoDevice=function(e){var t,r,n,i;this.statsigMetadata.systemVersion=null!==(t=e.osVersion)&&void 0!==t?t:"",this.statsigMetadata.systemName=null!==(r=e.osName)&&void 0!==r?r:"",this.statsigMetadata.deviceModelName=null!==(n=e.modelName)&&void 0!==n?n:"",this.statsigMetadata.deviceModel=null!==(i=e.modelId)&&void 0!==i?i:""},e}();t.default=d},332:funct