@statsig/js-client
Advanced tools
Comparing version 0.0.1-beta.25 to 0.0.1-beta.26
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Statsig=e():t.Statsig=e()}(this,()=>(()=>{"use strict";var n={496:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var e="undefined"!=typeof window?window:{},n=void 0!==n.g?n.g:{},i="undefined"!=typeof globalThis?globalThis:{},o=null!=(o=null!=(o=null!=(o=e.__STATSIG__)?o:n.__STATSIG__)?o:i.__STATSIG__)?o:{};e.__STATSIG__=o,n.__STATSIG__=o,i.__STATSIG__=o},856:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},320:function(t,e,n){var s=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.DataAdapterCore=void 0;const i=n(512),o=n(780),r=n(104),u=n(283),l=n(296),a=n(444),c=n(412);e.DataAdapterCore=class{constructor(t,e){this.i=t,this.o=e,this.u=null,this.l=null,this.h={},this.v="statsig.last_modified_time."+e}attach(t,e){this.l=t,this.u=new i.ErrorBoundary(t),(0,r.monitorClass)(this.u,this)}getDataSync(t){var t=this._(t),e=this.h[t];return e||((e=this.m(t))?(this.p(t,e),this.h[t]):null)}getDataAsync(n,i){var o;return s(this,void 0,void 0,function*(){var t=null!=n?n:this.getDataSync(i),t=yield this.O(null!=(o=null==t?void 0:t.data)?o:null,i),e=this._(i);return t&&this.p(e,t),"Network"!==(null==t?void 0:t.source)&&"NetworkNotModified"!==(null==t?void 0:t.source)||(yield this.S(e,t)),t})}prefetchData(n){return s(this,void 0,void 0,function*(){var t=this._(n),e=yield this.getDataAsync(null,n);e&&this.p(t,Object.assign(Object.assign({},e),{source:"Prefetch"}))})}setData(t,e){e=this._(e);this.p(e,{source:"Bootstrap",data:t,receivedAt:Date.now()})}__primeInMemoryCache(t){this.h=Object.assign(Object.assign({},this.h),t)}O(n,i){return s(this,void 0,void 0,function*(){var t,e=yield this.j(n,i);return e?(t=(0,c.typedJsonParse)(e,"has_updates","Failure while attempting to persist latest value"),n&&!1===(null==t?void 0:t.has_updates)?{source:"NetworkNotModified",data:n,receivedAt:Date.now()}:!0!==(null==t?void 0:t.has_updates)?null:{source:"Network",data:e,receivedAt:Date.now()}):(o.Log.debug("No response returned for latest value"),null)})}T(){return null!=this.l?this.l:(o.Log.error(this.i+" is not attached to a Client"),"")}_(t){t=(0,l.getUserStorageKey)(this.T(),t);return`${u.DataAdapterCachePrefix}.${this.o}.`+t}p(t,e){var n=Object.entries(this.h);n.length<10||([n]=n.reduce((t,e)=>e[1]<t[1]?e:t),delete this.h[n]),this.h[t]=e}m(t){var e=null==(e=a.Storage.getItemSync)?void 0:e.call(a.Storage,t);return null!=e&&(t=(0,c.typedJsonParse)(e,"source","Failed to parse cached result"))?Object.assign(Object.assign({},t),{source:"Cache"}):null}S(t,e){return s(this,void 0,void 0,function*(){yield a.Storage.setItem(t,JSON.stringify(e)),yield this.I(t)})}I(n){var i;return s(this,void 0,void 0,function*(){var t=null!=(i=yield(0,a.getObjectFromStorage)(this.v))?i:{},e=(t[n]=Date.now(),Object.entries(t));e.length<=10||(delete t[(e=e.reduce((t,e)=>e[1]<t[1]?e:t))[0]],yield a.Storage.removeItem(e[0])),yield(0,a.setObjectInStorage)(this.v,t)})}}},280:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Diagnostics=e.captureDiagnostics=void 0;const i=n(780),o="undefined"!=typeof performance&&void 0!==performance.mark;let s=[];e.captureDiagnostics=function(t,e){r.mark(t+":start"),e=e();const n=()=>{r.mark(t+":end"),(t+":end").startsWith("initialize:")&&r.flush()};return e&&e instanceof Promise?e.finally(()=>n()):(n(),e)};class r{static mark(t,e){o&&(t=performance.mark(t,{detail:e}),s.push(t))}static flush(){var t=performance.getEntriesByType("resource").filter(t=>t.name.startsWith("https://api.statsig.com")),t={markers:s,resources:t};i.Log.debug("Diagnostics",t,JSON.stringify(t)),s=[]}}e.Diagnostics=r},512:function(t,u,e){var n=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(u,"__esModule",{value:!0}),u.ErrorBoundary=u.EXCEPTION_ENDPOINT=void 0;const i=e(780),l=e(972);u.EXCEPTION_ENDPOINT="https://statsigapi.net/v1/sdk_exception";u.ErrorBoundary=class{constructor(t){this.l=t,this.A=new Set}capture(e,t,n){try{var i=t();return i&&i instanceof Promise?i.catch(t=>this.D(e,t,n)):i}catch(t){return this.D(e,t,n),null}}logError(t,e){this.D(t,e)}D(o,s,r){try{i.Log.warn("Caught error in "+o,{error:s});n(this,void 0,void 0,function*(){var t,e=null!=s?s:Error("[Statsig] Error was empty"),n=e instanceof Error,i=n?e.name:"No Name";this.A.has(i)||(this.A.add(i),t=l.StatsigMetadataProvider.get(),n=n?e.stack:function(t){try{return JSON.stringify(t)}catch(t){return"[Statsig] Failed to get string for error."}}(e),e=JSON.stringify(Object.assign({tag:o,exception:i,info:n},t)),yield fetch(u.EXCEPTION_ENDPOINT,{method:"POST",headers:{"STATSIG-API-KEY":this.l,"STATSIG-SDK-TYPE":String(t.sdkType),"STATSIG-SDK-VERSION":String(t.sdkVersion),"Content-Type":"application/json"},body:e}),null!=r&&r({name:"error",error:s}))}).then(()=>{}).catch(()=>{})}catch(t){}}}},500:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},788:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},728:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.EventLogger=void 0;const o=n(832),s=n(780),r=n(876),u=n(972),l=n(444),a=n(412),c=n(84),d=n(408),h="https://api.statsig.com/v1";e.EventLogger=class{constructor(t,e,n,i){this.l=t,this.M=e,this.N=n,this.P=i,this.C=[],this.G={},this.F={},this.R=!1,this.L=Date.now(),this.U=!0===(null==i?void 0:i.disableLogging),this.V=null!=(t=null==i?void 0:i.loggingBufferMaxSize)?t:50;n=null!=(e=null==i?void 0:i.loggingIntervalMs)?e:1e4;this.J=setInterval(()=>this.K(),n),this.q=(0,c.$)(null==i?void 0:i.logEventUrl,null==i?void 0:i.api,"/rgstr",h),this.B=(0,c.$)(null==i?void 0:i.logEventBeaconUrl,null==i?void 0:i.api,"/log_event_beacon",h),d.VisibilityChangeObserver.add(this),this.W()}setLoggingDisabled(t){this.U=t}enqueue(t){this.H(t)&&(this.Y(t),this.X(),this.C.length>this.V)&&this.K()}incrementNonExposureCount(t){var e=null!=(e=this.F[t])?e:0;this.F[t]=e+1}reset(){this.G={}}onVisibilityChanged(t){"background"===t&&this.K()}shutdown(){return i(this,void 0,void 0,function*(){this.J&&(clearInterval(this.J),this.J=null),yield this.flush()})}flush(){return i(this,void 0,void 0,function*(){var t;this.Z(),0!==this.C.length&&(t=this.C,this.C=[],yield this.tt(t))})}X(){this.R||(this.R=!0,200<Date.now()-this.L)||setTimeout(()=>this.K(),200)}H(t){if((0,r.isExposureEvent)(t)){var t=[t.eventName,null==(e=t.user)?void 0:e.userID,null==(e=t.metadata)?void 0:e.gate,null==(e=t.metadata)?void 0:e.config,null==(e=t.metadata)?void 0:e.ruleID].join("|"),e=this.G[t],n=Date.now();if(e&&n-e<6e4)return!1;1e3<Object.keys(this.G).length&&(this.G={}),this.G[t]=n}return!0}K(){this.flush().catch(()=>{})}tt(t){return i(this,void 0,void 0,function*(){if(this.U)this.et(t);else try{(!d.VisibilityChangeObserver.isCurrentlyVisible()&&this.N.isBeaconSupported()?yield this.nt(t):yield this.it(t)).success?this.M({name:"logs_flushed",events:t}):this.et(t)}catch(t){s.Log.warn("Failed to flush events.")}})}it(e){return i(this,void 0,void 0,function*(){var t=yield this.N.post({sdkKey:this.l,data:{events:e},url:this.q,retries:3,params:{ec:String(e.length)}}),t=null!=t&&t.body?(0,a.typedJsonParse)(t.body,"success","Failed to parse SendEventsResponse"):null;return{success:!0===(null==t?void 0:t.success)}})}nt(t){return i(this,void 0,void 0,function*(){return{success:yield this.N.beacon({sdkKey:this.l,data:{events:t},url:this.B})}})}et(t){for(;500<t.length;)t.shift();var e=this.ot();(0,l.setObjectInStorage)(e,t).catch(()=>{s.Log.warn("Unable to save failed logs to storage")})}W(){const e=this.ot();i(this,void 0,void 0,function*(){var t=yield(0,l.getObjectFromStorage)(e);t&&(yield l.Storage.removeItem(e),yield this.tt(t))}).catch(()=>{s.Log.warn("Failed to flush stored logs")})}ot(){return"statsig.failed_logs."+(0,o.DJB2)(this.l)}Y(t){t.user&&(t.user=Object.assign({},t.user),delete t.user.privateAttributes);var{sdkType:e,sdkVersion:n}=u.StatsigMetadataProvider.get();this.C.push(Object.assign(Object.assign({},t),{statsigMetadata:{sdkType:e,sdkVersion:n}}))}Z(){0!==Object.keys(this.F).length&&(this.Y({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:Object.assign({},this.F)}}),this.F={})}}},832:(t,e)=>{function n(e){let n=0;for(let t=0;t<e.length;t++){var i=e.charCodeAt(t);n=(n<<5)-n+i,n&=n}return String(n>>>0)}Object.defineProperty(e,"__esModule",{value:!0}),e.DJB2Object=e.DJB2=void 0,e.DJB2=n,e.DJB2Object=function(t){return n(JSON.stringify(function n(i){if(null==i)return null;const t=Object.keys(i).sort();const o={};t.forEach(t=>{let e=i[t];e instanceof Object&&(e=n(e)),o[t]=e});return o}(t)))}},664:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},780:(t,e)=>{function n(t){return t.unshift("[Statsig]"),t}var i,o;Object.defineProperty(e,"__esModule",{value:!0}),e.Log=e.LogLevel=void 0,(o=i||(e.LogLevel=i={}))[o.None=0]="None",o[o.Error=1]="Error",o[o.Warn=2]="Warn",o[o.Info=3]="Info",o[o.Debug=4]="Debug";class s{static info(...t){this.level>=i.Info&&console.info(...n(t))}static debug(...t){this.level>=i.Debug&&console.debug(...n(t))}static warn(...t){this.level>=i.Warn&&console.warn(...n(t))}static error(...t){this.level>=i.Error&&console.error(...n(t))}}(e.Log=s).level=i.Error},104:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.monitorClass=void 0;const s=n(280),r=n(688);function c(t,e,n,i){var o=i instanceof r.StatsigClientBase?i.rt.bind(i):void 0;return t.capture(e,()=>(0,s.captureDiagnostics)(e,()=>n.apply(i)),o)}function d(t){return"object"==typeof t&&(t=Object.getPrototypeOf(t))&&"object"==typeof t?t:null}e.monitorClass=function(e,t){try{{var n=e;var i=t;var o;const s=i;for(const r of function(t){const e=new Set;let n=d(t);for(;n&&n!==Object.prototype;)Object.getOwnPropertyNames(n).filter(t=>"function"==typeof(null===n||void 0===n?void 0:n[t])).forEach(t=>e.add(t)),n=Object.getPrototypeOf(n);return Array.from(e)}(s))if("constructor"!==r){const u=s[r];s[r]=function(...t){return c(n,r,()=>u.apply(this,t),i)}}for(const l of function(t){const e=new Set,n=d(t);return Object.getOwnPropertyNames((null===n||void 0===n?void 0:n.constructor)||{}).filter(t=>{var e;return"caller"!==t&&"arguments"!==t&&"callee"!==t&&"function"==typeof(null==(e=null===n||void 0===n?void 0:n.constructor)?void 0:e[t])}).forEach(t=>e.add(t)),Array.from(e)}(s)){const a=null==(o=null===s||void 0===s?void 0:s.constructor)?void 0:o[l];(null===s||void 0===s?void 0:s.constructor)[l]=function(...t){return c(n,s.constructor.name+"."+l,()=>a.apply(s.constructor,t),i)}}return}}catch(t){e.logError("monitorClass",t)}}},188:function(t,e,n){var o=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.NetworkCore=void 0;const h=n(280),v=n(780),s=n(612),r=n(604),u=n(972);e.NetworkCore=class{constructor(t,e){this.P=t,this.M=e,this.ut=null!=(e=null==t?void 0:t.networkTimeoutMs)?e:1e4}post(e){return o(this,void 0,void 0,function*(){var t=yield this.lt(e);return this.ct(Object.assign({method:"POST",body:t},e))})}get(t){return o(this,void 0,void 0,function*(){return this.ct(Object.assign({method:"GET"},t))})}isBeaconSupported(){return"undefined"!=typeof navigator&&"function"==typeof(null===navigator||void 0===navigator?void 0:navigator.sendBeacon)}beacon(n){return o(this,void 0,void 0,function*(){var t=yield this.dt(n),e=yield this.lt(n);return navigator.sendBeacon(t,e)})}ct(c){var d;return o(this,void 0,void 0,function*(){var{method:e,body:n,retries:i}=c;const o=new AbortController;var t,s,r,u=setTimeout(()=>o.abort(`Timeout of ${this.ut}ms expired.`),this.ut),l=yield this.dt(c);let a=null;try{if(a=yield fetch(l,{method:e,body:n,headers:Object.assign({},c.headers),signal:o.signal}),clearTimeout(u),a.ok)return r=yield a.text(),h.Diagnostics.mark("_sendRequest:response-received",{status:a.status,contentLength:a.headers.get("content-length")}),{body:r,code:a.status};throw t=yield a.text().catch(()=>"No Text"),(s=new Error(`Failed to fetch: ${l} `+t)).name="NetworkError",s}catch(t){n=function(t,e){if(t.signal.aborted&&"string"==typeof t.signal.reason)return t.signal.reason;if("string"==typeof e)return e;if(e instanceof Error)return e.name+": "+e.message;return null}(o,t);return h.Diagnostics.mark("_sendRequest:error",{error:n,status:null===a||void 0===a?void 0:a.status,contentLength:null===a||void 0===a?void 0:a.headers.get("content-length")}),!i||i<=0?(null!=(d=this.M)&&d.call(this,{name:"error",error:t}),v.Log.error(`A networking error occured during ${e} request to ${l}.`,n,t),null):this.ct(Object.assign(Object.assign({},c),{retries:i-1}))}})}dt(e){return o(this,void 0,void 0,function*(){var t=u.StatsigMetadataProvider.get(),t=Object.assign({k:e.sdkKey,st:t.sdkType,sv:t.sdkVersion,t:String(Date.now()),sid:yield s.SessionID.get(e.sdkKey)},e.params),t=Object.entries(t).map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e)).join("&");return e.url+(t?"?"+t:"")})}lt(i){return o(this,void 0,void 0,function*(){var t=i["data"],e=yield r.StableID.get(i.sdkKey),n=yield s.SessionID.get(i.sdkKey);return JSON.stringify(Object.assign(Object.assign({},t),{statsigMetadata:Object.assign(Object.assign({},u.StatsigMetadataProvider.get()),{stableID:e,sessionID:n})}))})}}},264:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CombinationOverrideAdapter=void 0;e.CombinationOverrideAdapter=class{constructor(t){this.providers=t}getGateOverride(n,i){return this.ht(t=>{var e;return null!=(e=null==(e=t.getGateOverride)?void 0:e.call(t,n,i))?e:null})}getDynamicConfigOverride(n,i){return this.ht(t=>{var e;return null!=(e=null==(e=t.getDynamicConfigOverride)?void 0:e.call(t,n,i))?e:null})}ht(t){for(const n of this.providers){var e=t(n);if(e)return e}return null}}},612:function(t,r,e){var n=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(r,"__esModule",{value:!0}),r.SessionID=void 0;const i=e(832),u=e(780),l=e(444),a=e(556),c={},d={},h={};function v(t){return"statsig.session_id."+(0,i.DJB2)(t)}r.SessionID={get:t=>n(void 0,void 0,void 0,function*(){return null!=h[t]?h[t]:h[t]=r.SessionID.we(t)}),we:s=>n(void 0,void 0,void 0,function*(){let e=c[s];var n=Date.now();let i=!1;if(null==e){let t=yield function(t){t=v(t);return(0,l.getObjectFromStorage)(t)}(s);null==t&&(t={sessionID:(0,a.getUUID)(),startTime:n,lastUpdate:n},i=!0),e=t,c[s]=e}var t=null!=(t=d[s])?t:{ageTimeoutID:null,idleTimeoutID:null,emitFunction:()=>{}},n=((144e5<n-e.startTime||18e5<n-e.lastUpdate)&&(e.sessionID=(0,a.getUUID)(),e.startTime=n,i=!0),e.lastUpdate=n,e),o=s;return o=v(s),(0,l.setObjectInStorage)(o,n).catch(()=>{u.Log.warn("Failed to save SessionID")}),t.idleTimeoutID=r.SessionID.xe(t,t.idleTimeoutID,18e5),i&&(t.ageTimeoutID=r.SessionID.xe(t,t.ageTimeoutID,144e5)),c[s]=e,d[s]=t,h[s]=null,e.sessionID}),Te:(t,e)=>{var n=null!=(n=d[e])?n:{ageTimeoutID:null,idleTimeoutID:null,emitFunction:t};n.emitFunction=t,d[e]=n},xe:(t,e,n)=>(clearTimeout(null!=e?e:void 0),setTimeout(t.emitFunction,n))}},604:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.StableID=void 0;const o=n(832),s=n(780),r=n(444),u=n(556),l={};function a(t){return"statsig.stable_id."+(0,o.DJB2)(t)}function c(t,e){e=a(e);(0,r.setObjectInStorage)(e,t).catch(()=>{s.Log.warn("Failed to save StableID")})}e.StableID={get:e=>i(void 0,void 0,void 0,function*(){return null==l[e]&&(l[e]=function(t){t=a(t);return(0,r.getObjectFromStorage)(t)}(e).then(t=>{return null!=t||c(t=(0,u.getUUID)(),e),t})),l[e]}),setOverride:(t,e)=>{l[e]=Promise.resolve(t),c(t,e)}}},688:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigClientBase=void 0,n(496);const s=n(512),r=n(728),u=n(780),l=n(612),a=n(604),c=n(444);e.StatsigClientBase=class{constructor(t,e,n,i){this.loadingStatus="Uninitialized",this.vt={},this.l=t,this.P=null!=i?i:{},null!=i&&i.disableStorage&&c.Storage.setDisabled(!0),null!=i&&i.overrideStableID&&a.StableID.setOverride(i.overrideStableID,t),u.Log.level=null!=(o=null==i?void 0:i.logLevel)?o:u.LogLevel.Warn,this.ft=null!=(o=null==i?void 0:i.overrideAdapter)?o:null,this._t=new r.EventLogger(t,this.rt.bind(this),n,i),l.SessionID.Te(()=>{this.rt({name:"session_expired"})},t),this.u=new s.ErrorBoundary(t);var o,n=null!=(o=(__STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}).instances)?o:{};n[t]=this,__STATSIG__.instances=n,(__STATSIG__.lastInstance=this).dataAdapter=e,this.dataAdapter.attach(t,i)}updateRuntimeOptions(t){null!=t.disableLogging&&(this.P.disableLogging=t.disableLogging,this._t.setLoggingDisabled(t.disableLogging)),null!=t.disableStorage&&(this.P.disableStorage=t.disableStorage,c.Storage.setDisabled(t.disableStorage))}flush(){return this._t.flush()}shutdown(){return i(this,void 0,void 0,function*(){this.rt({name:"pre_shutdown"}),yield this._t.shutdown()})}on(t,e){this.vt[t]||(this.vt[t]=[]),this.vt[t].push(e)}off(t,e){this.vt[t]&&-1!==(e=this.vt[t].indexOf(e))&&this.vt[t].splice(e,1)}rt(e){var t;const n=t=>{try{t(e)}catch(t){u.Log.error("An error occurred in a StatsigClientEvent listener. This is not an issue with Statsig.",e)}};this.vt[e.name]&&this.vt[e.name].forEach(t=>n(t)),null!=(t=this.vt["*"])&&t.forEach(n)}gt(t,e){this.loadingStatus=t,this.rt({name:"values_updated",status:t,values:e})}yt(t,e,n){!0===(null==n?void 0:n.disableExposureLog)?this._t.incrementNonExposureCount(t):this._t.enqueue(e)}}},808:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},283:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DataAdapterCachePrefix=void 0,e.DataAdapterCachePrefix="statsig.cached"},876:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createLayerParameterExposure=e.createConfigExposure=e.createGateExposure=e.isExposureEvent=void 0;const n="statsig::config_exposure",i="statsig::gate_exposure";function l(t,e,n,i,o){return{eventName:t,user:e,value:null,metadata:function(t,e){e.reason=t.reason,t.lcut&&(e.lcut=String(t.lcut));t.receivedAt&&(e.receivedAt=String(t.receivedAt));return e}(n,i),secondaryExposures:o,time:Date.now()}}e.isExposureEvent=function({eventName:t}){return t===i||t===n},e.createGateExposure=function(t,e){return l(i,t,e.details,{gate:e.name,gateValue:String(e.value),ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])},e.createConfigExposure=function(t,e){return l(n,t,e.details,{config:e.name,ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])},e.createLayerParameterExposure=function(t,e,n){var i,o=e.__evaluation,s=!0===(null==(s=null==o?void 0:o.explicit_parameters)?void 0:s.includes(n));let r="",u=null!=(i=null==o?void 0:o.undelegated_secondary_exposures)?i:[];return s&&(r=null!=(i=o.allocated_experiment_name)?i:"",u=o.secondary_exposures),l("statsig::layer_exposure",t,e.details,{config:e.name,parameterName:n,ruleID:e.ruleID,allocatedExperiment:r,isExplicitParameter:String(s)},u)}},972:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigMetadataProvider=void 0;let n={sdkVersion:"0.0.1-beta.25",sdkType:"js-mono"};e.StatsigMetadataProvider={get:()=>n,add:t=>{n=Object.assign(Object.assign({},n),t)}}},384:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},136:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.makeLayer=e.makeDynamicConfig=e.makeFeatureGate=void 0;const o="default";e.makeFeatureGate=function(t,e,n){return{name:t,details:e,ruleID:null!=(t=null==n?void 0:n.rule_id)?t:o,value:!0===(null==n?void 0:n.value),__evaluation:n}},e.makeDynamicConfig=function(t,e,n){return{name:t,details:e,ruleID:null!=(t=null==n?void 0:n.rule_id)?t:o,value:null!=(e=null==n?void 0:n.value)?e:{},__evaluation:n}},e.makeLayer=function(t,e,n,i){return{name:t,details:e,getValue:null!=i?i:()=>{},ruleID:null!=(t=null==n?void 0:n.rule_id)?t:o,bt:null!=(e=null==n?void 0:n.value)?e:{},__evaluation:n}}},296:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getUnitIDFromUser=e.getUserStorageKey=e.normalizeUser=void 0;const i=n(832);e.normalizeUser=function(t,e){try{var n=JSON.parse(JSON.stringify(t));return null!=e&&(n.statsigEnvironment=e),n}catch(t){throw new Error("User object must be convertable to JSON string.")}},e.getUserStorageKey=function(t,e){return(0,i.DJB2Object)({sdkKey:t,user:e})},e.getUnitIDFromUser=function(t,e){var n;return"string"==typeof e&&"userid"!==e.toLowerCase()?null!=(n=null==(n=t.customIDs)?void 0:n[e])?n:null==(n=null==t?void 0:t.customIDs)?void 0:n[e.toLowerCase()]:t.userID}},444:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})},n=(Object.defineProperty(e,"__esModule",{value:!0}),e.setObjectInStorage=e.getObjectFromStorage=e.Storage=void 0,n(780));const o={},s={getProviderName:()=>"InMemory",getItemSync(t){return null!=(t=o[t])?t:null},getItem(t){return Promise.resolve(null!=(t=o[t])?t:null)},setItem(t,e){return o[t]=e,Promise.resolve()},removeItem(t){return delete o[t],Promise.resolve()},getAllKeys(){return Promise.resolve(Object.keys(o))}};let r=null;try{"undefined"!=typeof window&&"localStorage"in window&&(r={getProviderName:()=>"LocalStorage",getItemSync(t){return localStorage.getItem(t)},getItem(t){return Promise.resolve(localStorage.getItem(t))},setItem(t,e){return localStorage.setItem(t,e),Promise.resolve()},removeItem(t){return localStorage.removeItem(t),Promise.resolve()},getAllKeys(){var t=Object.keys(localStorage);return Promise.resolve(t)}})}catch(t){n.Log.warn("Failed to setup localStorageProvider.")}let u=null!==r&&void 0!==r?r:s,l=u;e.Storage={getProviderName:()=>l.getProviderName(),getItem:t=>l.getItem(t),setItem:(t,e)=>l.setItem(t,e),removeItem:t=>l.removeItem(t),getAllKeys:()=>l.getAllKeys(),getItemSync:t=>{var e;return null!=(e=null==(e=l.getItemSync)?void 0:e.call(l,t))?e:null},setProvider:t=>{u=t,l=t},setDisabled:t=>{l=t?s:u}},e.getObjectFromStorage=function(e){return i(this,void 0,void 0,function*(){var t=yield l.getItem(e);return JSON.parse(null!=t?t:"null")})},e.setObjectInStorage=function(t,e){return i(this,void 0,void 0,function*(){yield l.setItem(t,JSON.stringify(e))})}},412:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.typedJsonParse=void 0;const o=n(780);e.typedJsonParse=function(t,e,n){try{var i=JSON.parse(t);return"object"==typeof i&&0 in i,i}catch(t){}return o.Log.error(n),null}},556:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getUUID=void 0,e.getUUID=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();let n=(new Date).getTime(),i="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return`xxxxxxxx-xxxx-4xxx-${"89ab"[Math.floor(4*Math.random())]}xxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let e=16*Math.random();return 0<n?(e=(n+e)%16|0,n=Math.floor(n/16)):(e=(i+e)%16|0,i=Math.floor(i/16)),("x"===t?e:7&e|8).toString(16)})}},84:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.$=void 0,e.$=function(t,e,n,i){return t||(e?""+e+n:""+i+n)}},539:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},408:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VisibilityChangeObserver=void 0;class n{static isCurrentlyVisible(){return"foreground"===this.wt}static add(t){this.vt.push(t)}static remove(t){t=this.vt.indexOf(t);-1!==t&&this.vt.splice(t,1)}static notify(e){e!==this.wt&&(this.wt=e,this.vt.forEach(t=>t.onVisibilityChanged(e)))}}(e.VisibilityChangeObserver=n).vt=[],n.wt="foreground","undefined"!=typeof window&&"function"==typeof window.addEventListener&&(window.addEventListener("focus",()=>n.notify("foreground")),window.addEventListener("blur",()=>n.notify("background")),window.addEventListener("beforeunload",()=>n.notify("background"))),"undefined"!=typeof document&&"function"==typeof document.addEventListener&&document.addEventListener("visibilitychange",()=>{n.notify("visible"===document.visibilityState?"foreground":"background")})},464:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&("get"in o?e.__esModule:!o.writable&&!o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.Log=e.Storage=e.EventLogger=void 0,n(496);const s=n(728),r=(Object.defineProperty(e,"EventLogger",{enumerable:!0,get:function(){return s.EventLogger}}),n(780)),u=(Object.defineProperty(e,"Log",{enumerable:!0,get:function(){return r.Log}}),n(444));Object.defineProperty(e,"Storage",{enumerable:!0,get:function(){return u.Storage}});var l=n(556);o(n(496),e),o(n(856),e),o(n(320),e),o(n(512),e),o(n(500),e),o(n(788),e),o(n(832),e),o(n(664),e),o(n(780),e),o(n(104),e),o(n(188),e),o(n(264),e),o(n(612),e),o(n(604),e),o(n(688),e),o(n(808),e),o(n(283),e),o(n(876),e),o(n(972),e),o(n(384),e),o(n(136),e),o(n(296),e),o(n(444),e),o(n(412),e),o(n(84),e),o(n(539),e),o(n(556),e),o(n(408),e),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{EventLogger:s.EventLogger,Log:r.Log,getUUID:l.getUUID,Storage:u.Storage})},696:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&("get"in o?e.__esModule:!o.writable&&!o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),o(n(208),e),e.default=__STATSIG__},96:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveDeltasResponse=void 0;const i=n(464);function o(t,e){null!=t&&t.forEach(t=>{delete e[t]})}e.resolveDeltasResponse=function(t,e){var n;return(e=(0,i.typedJsonParse)(e,"checksum","Failed to parse DeltasEvaluationResponse"))?(t=t,n=e,t=Object.assign(Object.assign(Object.assign({},t),n),{feature_gates:Object.assign(Object.assign({},t.feature_gates),n.feature_gates),layer_configs:Object.assign(Object.assign({},t.layer_configs),n.layer_configs),dynamic_configs:Object.assign(Object.assign({},t.dynamic_configs),n.dynamic_configs)}),o((t=n=t).deleted_gates,t.feature_gates),delete t.deleted_gates,o(n.deleted_configs,t.dynamic_configs),delete t.deleted_configs,o(n.deleted_layers,t.layer_configs),delete t.deleted_layers,n=t,(t=(0,i.DJB2Object)({feature_gates:n.feature_gates,dynamic_configs:n.dynamic_configs,layer_configs:n.layer_configs}))===e.checksum?JSON.stringify(n):{hadBadDeltaChecksum:!0,badChecksum:t,badMergedConfigs:n,badFullResponse:e.deltas_full_response}):{hadBadDeltaChecksum:!0}}},536:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=n(464);e.default=class{constructor(){this.Ot=null,this.St=null,this.jt="Uninitialized",this.Tt=0,this.It=0}getValues(){return this.Ot?(0,i.typedJsonParse)(this.Ot,"has_updates","Failed to parse EvaluationStoreValues"):null}reset(){this.St=null,this.Ot=null,this.jt="Loading",this.Tt=0,this.It=0}finalize(){this.St||(this.jt="NoValues")}setValuesFromDataAdapter(t){var e;t&&!0===(null==(e=(0,i.typedJsonParse)(t.data,"has_updates","Failed to parse EvaluationResponse"))?void 0:e.has_updates)&&(this.Ot=t.data,this.Tt=e.time,this.It=t.receivedAt,this.jt=t.source,this.St=e)}getGate(t){var e,t=null!=(e=null==(e=this.St)?void 0:e.feature_gates[t])?e:null;return this.At(t)}getConfig(t){var e,t=null!=(e=null==(e=this.St)?void 0:e.dynamic_configs[t])?e:null;return this.At(t)}getLayer(t){var e,t=null!=(e=null==(e=this.St)?void 0:e.layer_configs[t])?e:null;return this.At(t)}At(t){return{evaluation:t,details:this.xt(null==t)}}xt(t){return"Uninitialized"===this.jt||"NoValues"===this.jt?{reason:this.jt}:{reason:this.jt+":"+(t?"Unrecognized":"Recognized"),lcut:this.Tt,receivedAt:this.It}}}},400:function(t,e,n){var s=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(464),u=n(96);class i extends r.NetworkCore{constructor(t,e){super(t,e),this.Dt=(0,r.$)(null==t?void 0:t.initializeUrl,null==t?void 0:t.api,"/initialize","https://api.statsig.com/v1")}fetchEvaluations(n,i,o){return s(this,void 0,void 0,function*(){var t=i?(0,r.typedJsonParse)(i,"has_updates","Failed to parse cached EvaluationResponse"):null;let e={user:o,hash:"djb2",deltasResponseRequested:!1};return null!=t&&t.has_updates&&(e=Object.assign(Object.assign({},e),{sinceTime:t.time,previousDerivedFields:"derived_fields"in t?t.derived_fields:{},deltasResponseRequested:!0})),this.Mt(n,t,e)})}Mt(e,n,i){var o;return s(this,void 0,void 0,function*(){var t=yield this.post({sdkKey:e,url:this.Dt,data:i,retries:2});return 204===(null==t?void 0:t.code)?'{"has_updates": false}':200!==(null==t?void 0:t.code)?null!=(o=null==t?void 0:t.body)?o:null:!0!==(null==n?void 0:n.has_updates)||!0!==(null==(o=t.body)?void 0:o.includes('"is_delta":true'))?t.body:"string"==typeof(t=(0,u.resolveDeltasResponse)(n,t.body))?t:this.Mt(e,n,Object.assign(Object.assign(Object.assign({},i),t),{deltasResponseRequested:!1}))})}}e.default=i},520:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(464),o=n(536),s=n(400),u=n(364);n(807);class l extends r.StatsigClientBase{constructor(t,e,n=null){var i=new s.default(n,t=>{this.rt(t)});super(t,null!=(t=null==n?void 0:n.dataAdapter)?t:new u.StatsigEvaluationsDataAdapter,i,n),(0,r.monitorClass)(this.u,this),(0,r.monitorClass)(this.u,i),this.Et=new o.default,this.Nt=e}static instance(t){var e;return __STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{},null==t?__STATSIG__.lastInstance:null==(e=__STATSIG__.instances)?void 0:e[t]}initializeSync(){this.updateUserSync(this.Nt)}initializeAsync(){return this.updateUserAsync(this.Nt)}updateUserSync(t){this.kt(t);t=this.dataAdapter.getDataSync(this.Nt);this.Et.setValuesFromDataAdapter(t),this.Et.finalize(),this.gt("Ready",t),this.Pt(null!=t?t:null,this.Nt)}updateUserAsync(n){return i(this,void 0,void 0,function*(){this.kt(n);var t=this.Nt,e=this.dataAdapter.getDataSync(t);this.gt("Loading",e),this.Et.setValuesFromDataAdapter(e),e=yield this.dataAdapter.getDataAsync(e,t),t===this.Nt&&this.Et.setValuesFromDataAdapter(e),this.Et.finalize(),this.gt("Ready",e)})}checkGate(t,e){return this.getFeatureGate(t,e).value}getContext(){return{sdkKey:this.l,options:this.P,values:this.Et.getValues(),user:JSON.parse(JSON.stringify(this.Nt))}}getAsyncContext(){return i(this,void 0,void 0,function*(){return Object.assign(Object.assign({},this.getContext()),{sessionID:yield r.SessionID.get(this.l),stableID:yield r.StableID.get(this.l)})})}getFeatureGate(t,e){var n=(0,r.DJB2)(t),{evaluation:n,details:i}=this.Et.getGate(n),i=(0,r.makeFeatureGate)(t,i,n),o=null==(o=null==(n=this.ft)?void 0:n.getGateOverride)?void 0:o.call(n,i,this.Nt,e),n=null!=o?o:i;return this.yt(t,(0,r.createGateExposure)(this.Nt,n),e),this.rt({name:"gate_evaluation",gate:n}),n}getDynamicConfig(t,e){t=this.Ct("dynamic_config",t,e);return this.rt({name:"dynamic_config_evaluation",dynamicConfig:t}),t}getExperiment(t,e){t=this.Ct("experiment",t,e);return this.rt({name:"experiment_evaluation",experiment:t}),t}getLayer(n,i){var t=(0,r.DJB2)(n),{evaluation:t,details:e}=this.Et.getLayer(t),e=(0,r.makeLayer)(n,e,t),o=null==(o=null==(t=this.ft)?void 0:t.getLayerOverride)?void 0:o.call(t,e,this.Nt,i);const s=null!=o?o:e;return this.rt({name:"layer_evaluation",layer:s}),Object.assign(Object.assign({},s),{getValue:t=>{var e;return t in s.bt&&(e=(0,r.createLayerParameterExposure)(this.Nt,s,t),this.yt(n,e,i),null!=(e=s.bt[t]))?e:null}})}logEvent(t){this._t.enqueue(Object.assign(Object.assign({},t),{user:this.Nt,time:Date.now()}))}Pt(t,e){this.dataAdapter.getDataAsync(t,e).catch(t=>{r.Log.error("An error occurred after update.",t)})}kt(t){this._t.reset(),this.Et.reset(),this.Nt=(0,r.normalizeUser)(t,this.P.environment)}Ct(t,e,n){var i=(0,r.DJB2)(e),{evaluation:i,details:o}=this.Et.getConfig(i),o=(0,r.makeDynamicConfig)(e,o,i),i="experiment"===t?null==(t=null==(i=this.ft)?void 0:i.getExperimentOverride)?void 0:t.call(i,o,this.Nt,n):null==(i=null==(t=this.ft)?void 0:t.getDynamicConfigOverride)?void 0:i.call(t,o,this.Nt,n),t=null!=i?i:o;return this.yt(e,(0,r.createConfigExposure)(this.Nt,t),n),t}}e.default=l},364:function(t,e,n){var o=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})},i=(Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigEvaluationsDataAdapter=void 0,n(464));const s=n(400);class r extends i.DataAdapterCore{constructor(){super("EvaluationsDataAdapter","evaluations"),this.N=null}attach(t,e){super.attach(t,e),this.N=new s.default(null!=e?e:{})}j(e,n){var i;return o(this,void 0,void 0,function*(){var t=yield null==(i=this.N)?void 0:i.fetchEvaluations(this.T(),e,n);return null!=t?t:null})}}e.StatsigEvaluationsDataAdapter=r},807:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SDK_TYPE=void 0;n=n(464);e.SDK_TYPE="javascript-client",n.StatsigMetadataProvider.add({sdkType:e.SDK_TYPE})},208:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigClient=e.StatsigEvaluationsDataAdapter=void 0;var i=n(520);e.StatsigClient=i.default;const o=n(364);Object.defineProperty(e,"StatsigEvaluationsDataAdapter",{enumerable:!0,get:function(){return o.StatsigEvaluationsDataAdapter}}),n(807),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{StatsigEvaluationsDataAdapter:o.StatsigEvaluationsDataAdapter,StatsigClient:i.default}),e.default=__STATSIG__}},i={};function o(t){var e=i[t];return void 0!==e||(e=i[t]={exports:{}},n[t].call(e.exports,e,e.exports,o)),e.exports}return o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o(696).default})()); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Statsig=e():t.Statsig=e()}(this,()=>(()=>{"use strict";var n={496:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var e="undefined"!=typeof window?window:{},n=void 0!==n.g?n.g:{},i="undefined"!=typeof globalThis?globalThis:{},o=null!=(o=null!=(o=null!=(o=e.__STATSIG__)?o:n.__STATSIG__)?o:i.__STATSIG__)?o:{};e.__STATSIG__=o,n.__STATSIG__=o,i.__STATSIG__=o},856:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},320:function(t,e,n){var s=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.DataAdapterCore=void 0;const i=n(512),o=n(780),r=n(104),u=n(283),l=n(296),a=n(444),c=n(412);e.DataAdapterCore=class{constructor(t,e){this.i=t,this.o=e,this.u=null,this.l=null,this.h={},this.v="statsig.last_modified_time."+e}attach(t,e){this.l=t,this.u=new i.ErrorBoundary(t),(0,r.monitorClass)(this.u,this)}getDataSync(t){var t=this._(t),e=this.h[t];return e||((e=this.m(t))?(this.p(t,e),this.h[t]):null)}getDataAsync(n,i){var o;return s(this,void 0,void 0,function*(){var t=null!=n?n:this.getDataSync(i),t=yield this.S(null!=(o=null==t?void 0:t.data)?o:null,i),e=this._(i);return t&&this.p(e,t),"Network"!==(null==t?void 0:t.source)&&"NetworkNotModified"!==(null==t?void 0:t.source)||(yield this.O(e,t)),t})}prefetchData(n){return s(this,void 0,void 0,function*(){var t=this._(n),e=yield this.getDataAsync(null,n);e&&this.p(t,Object.assign(Object.assign({},e),{source:"Prefetch"}))})}setData(t,e){e=this._(e);this.p(e,{source:"Bootstrap",data:t,receivedAt:Date.now()})}__primeInMemoryCache(t){this.h=Object.assign(Object.assign({},this.h),t)}S(n,i){return s(this,void 0,void 0,function*(){var t,e=yield this.j(n,i);return e?(t=(0,c.typedJsonParse)(e,"has_updates","Failure while attempting to persist latest value"),n&&!1===(null==t?void 0:t.has_updates)?{source:"NetworkNotModified",data:n,receivedAt:Date.now()}:!0!==(null==t?void 0:t.has_updates)?null:{source:"Network",data:e,receivedAt:Date.now()}):(o.Log.debug("No response returned for latest value"),null)})}T(){return null!=this.l?this.l:(o.Log.error(this.i+" is not attached to a Client"),"")}_(t){t=(0,l.getUserStorageKey)(this.T(),t);return`${u.DataAdapterCachePrefix}.${this.o}.`+t}p(t,e){var n=Object.entries(this.h);n.length<10||([n]=n.reduce((t,e)=>e[1]<t[1]?e:t),delete this.h[n]),this.h[t]=e}m(t){var e=null==(e=a.Storage.getItemSync)?void 0:e.call(a.Storage,t);return null!=e&&(t=(0,c.typedJsonParse)(e,"source","Failed to parse cached result"))?Object.assign(Object.assign({},t),{source:"Cache"}):null}O(t,e){return s(this,void 0,void 0,function*(){yield a.Storage.setItem(t,JSON.stringify(e)),yield this.I(t)})}I(n){var i;return s(this,void 0,void 0,function*(){var t=null!=(i=yield(0,a.getObjectFromStorage)(this.v))?i:{},e=(t[n]=Date.now(),Object.entries(t));e.length<=10||(delete t[(e=e.reduce((t,e)=>e[1]<t[1]?e:t))[0]],yield a.Storage.removeItem(e[0])),yield(0,a.setObjectInStorage)(this.v,t)})}}},280:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Diagnostics=e.captureDiagnostics=void 0;const i=n(780),o="undefined"!=typeof performance&&void 0!==performance.mark;let s=[];e.captureDiagnostics=function(t,e){r.mark(t+":start"),e=e();const n=()=>{r.mark(t+":end"),(t+":end").startsWith("initialize:")&&r.flush()};return e&&e instanceof Promise?e.finally(()=>n()):(n(),e)};class r{static mark(t,e){o&&(t=performance.mark(t,{detail:e}),s.push(t))}static flush(){var t=performance.getEntriesByType("resource").filter(t=>t.name.startsWith("https://api.statsig.com")),t={markers:s,resources:t};i.Log.debug("Diagnostics",t,JSON.stringify(t)),s=[]}}e.Diagnostics=r},512:function(t,u,e){var n=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(u,"__esModule",{value:!0}),u.ErrorBoundary=u.EXCEPTION_ENDPOINT=void 0;const i=e(780),l=e(972);u.EXCEPTION_ENDPOINT="https://statsigapi.net/v1/sdk_exception";u.ErrorBoundary=class{constructor(t){this.l=t,this.A=new Set}capture(e,t,n){try{var i=t();return i&&i instanceof Promise?i.catch(t=>this.D(e,t,n)):i}catch(t){return this.D(e,t,n),null}}logError(t,e){this.D(t,e)}D(o,s,r){try{i.Log.warn("Caught error in "+o,{error:s});n(this,void 0,void 0,function*(){var t,e=null!=s?s:Error("[Statsig] Error was empty"),n=e instanceof Error,i=n?e.name:"No Name";this.A.has(i)||(this.A.add(i),t=l.StatsigMetadataProvider.get(),n=n?e.stack:function(t){try{return JSON.stringify(t)}catch(t){return"[Statsig] Failed to get string for error."}}(e),e=JSON.stringify(Object.assign({tag:o,exception:i,info:n},t)),yield fetch(u.EXCEPTION_ENDPOINT,{method:"POST",headers:{"STATSIG-API-KEY":this.l,"STATSIG-SDK-TYPE":String(t.sdkType),"STATSIG-SDK-VERSION":String(t.sdkVersion),"Content-Type":"application/json"},body:e}),null!=r&&r({name:"error",error:s}))}).then(()=>{}).catch(()=>{})}catch(t){}}}},500:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},788:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},728:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.EventLogger=void 0;const o=n(832),s=n(780),r=n(876),u=n(444),l=n(412),a=n(84),c=n(408),d="https://api.statsig.com/v1";e.EventLogger=class{constructor(t,e,n,i){this.l=t,this.M=e,this.N=n,this.P=i,this.G=[],this.C={},this.F={},this.R=!1,this.L=Date.now(),this.U=!0===(null==i?void 0:i.disableLogging),this.J=null!=(t=null==i?void 0:i.loggingBufferMaxSize)?t:50;n=null!=(e=null==i?void 0:i.loggingIntervalMs)?e:1e4;this.K=setInterval(()=>this.V(),n),this.q=(0,a.$)(null==i?void 0:i.logEventUrl,null==i?void 0:i.api,"/rgstr",d),this.B=(0,a.$)(null==i?void 0:i.logEventBeaconUrl,null==i?void 0:i.api,"/log_event_beacon",d),c.VisibilityChangeObserver.add(this),this.H()}setLoggingDisabled(t){this.U=t}enqueue(t){this.W(t)&&(this.Y(t),this.X(),this.G.length>this.J)&&this.V()}incrementNonExposureCount(t){var e=null!=(e=this.F[t])?e:0;this.F[t]=e+1}reset(){this.C={}}onVisibilityChanged(t){"background"===t&&this.V()}shutdown(){return i(this,void 0,void 0,function*(){this.K&&(clearInterval(this.K),this.K=null),yield this.flush()})}flush(){return i(this,void 0,void 0,function*(){var t;this.Z(),0!==this.G.length&&(t=this.G,this.G=[],yield this.tt(t))})}X(){this.R||(this.R=!0,200<Date.now()-this.L)||setTimeout(()=>this.V(),200)}W(t){if((0,r.isExposureEvent)(t)){var t=[t.eventName,null==(e=t.user)?void 0:e.userID,null==(e=t.metadata)?void 0:e.gate,null==(e=t.metadata)?void 0:e.config,null==(e=t.metadata)?void 0:e.ruleID].join("|"),e=this.C[t],n=Date.now();if(e&&n-e<6e4)return!1;1e3<Object.keys(this.C).length&&(this.C={}),this.C[t]=n}return!0}V(){this.flush().catch(()=>{})}tt(t){return i(this,void 0,void 0,function*(){if(this.U)this.et(t);else try{(!c.VisibilityChangeObserver.isCurrentlyVisible()&&this.N.isBeaconSupported()?yield this.nt(t):yield this.it(t)).success?this.M({name:"logs_flushed",events:t}):this.et(t)}catch(t){s.Log.warn("Failed to flush events.")}})}it(e){return i(this,void 0,void 0,function*(){var t=yield this.N.post({sdkKey:this.l,data:{events:e},url:this.q,retries:3,params:{ec:String(e.length)}}),t=null!=t&&t.body?(0,l.typedJsonParse)(t.body,"success","Failed to parse SendEventsResponse"):null;return{success:!0===(null==t?void 0:t.success)}})}nt(t){return i(this,void 0,void 0,function*(){return{success:yield this.N.beacon({sdkKey:this.l,data:{events:t},url:this.B})}})}et(t){for(;500<t.length;)t.shift();var e=this.ot();(0,u.setObjectInStorage)(e,t).catch(()=>{s.Log.warn("Unable to save failed logs to storage")})}H(){const e=this.ot();i(this,void 0,void 0,function*(){var t=yield(0,u.getObjectFromStorage)(e);t&&(yield u.Storage.removeItem(e),yield this.tt(t))}).catch(()=>{s.Log.warn("Failed to flush stored logs")})}ot(){return"statsig.failed_logs."+(0,o.DJB2)(this.l)}Y(t){t.user&&(t.user=Object.assign({},t.user),delete t.user.privateAttributes);var e={},n=this.rt();n&&(e.statsigMetadata={currentPage:n}),this.G.push(Object.assign(Object.assign({},t),e))}Z(){0!==Object.keys(this.F).length&&(this.Y({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:Object.assign({},this.F)}}),this.F={})}rt(){var t;if(!1!==(null==(t=this.P)?void 0:t.includeCurrentPageUrlWithEvents)&&"undefined"!=typeof window&&"object"==typeof window.location)try{return window.location.href.split(/[?#]/)[0]}catch(t){}}}},832:(t,e)=>{function n(e){let n=0;for(let t=0;t<e.length;t++){var i=e.charCodeAt(t);n=(n<<5)-n+i,n&=n}return String(n>>>0)}Object.defineProperty(e,"__esModule",{value:!0}),e.DJB2Object=e.DJB2=void 0,e.DJB2=n,e.DJB2Object=function(t){return n(JSON.stringify(function n(i){if(null==i)return null;const t=Object.keys(i).sort();const o={};t.forEach(t=>{let e=i[t];e instanceof Object&&(e=n(e)),o[t]=e});return o}(t)))}},664:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},780:(t,e)=>{function n(t){return t.unshift("[Statsig]"),t}var i,o;Object.defineProperty(e,"__esModule",{value:!0}),e.Log=e.LogLevel=void 0,(o=i||(e.LogLevel=i={}))[o.None=0]="None",o[o.Error=1]="Error",o[o.Warn=2]="Warn",o[o.Info=3]="Info",o[o.Debug=4]="Debug";class s{static info(...t){this.level>=i.Info&&console.info(...n(t))}static debug(...t){this.level>=i.Debug&&console.debug(...n(t))}static warn(...t){this.level>=i.Warn&&console.warn(...n(t))}static error(...t){this.level>=i.Error&&console.error(...n(t))}}(e.Log=s).level=i.Error},104:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.monitorClass=void 0;const s=n(280),r=n(688);function c(t,e,n,i){var o=i instanceof r.StatsigClientBase?i.ut.bind(i):void 0;return t.capture(e,()=>(0,s.captureDiagnostics)(e,()=>n.apply(i)),o)}function d(t){return"object"==typeof t&&(t=Object.getPrototypeOf(t))&&"object"==typeof t?t:null}e.monitorClass=function(e,t){try{{var n=e;var i=t;var o;const s=i;for(const r of function(t){const e=new Set;let n=d(t);for(;n&&n!==Object.prototype;)Object.getOwnPropertyNames(n).filter(t=>"function"==typeof(null===n||void 0===n?void 0:n[t])).forEach(t=>e.add(t)),n=Object.getPrototypeOf(n);return Array.from(e)}(s))if("constructor"!==r){const u=s[r];s[r]=function(...t){return c(n,r,()=>u.apply(this,t),i)}}for(const l of function(t){const e=new Set,n=d(t);return Object.getOwnPropertyNames((null===n||void 0===n?void 0:n.constructor)||{}).filter(t=>{var e;return"caller"!==t&&"arguments"!==t&&"callee"!==t&&"function"==typeof(null==(e=null===n||void 0===n?void 0:n.constructor)?void 0:e[t])}).forEach(t=>e.add(t)),Array.from(e)}(s)){const a=null==(o=null===s||void 0===s?void 0:s.constructor)?void 0:o[l];(null===s||void 0===s?void 0:s.constructor)[l]=function(...t){return c(n,s.constructor.name+"."+l,()=>a.apply(s.constructor,t),i)}}return}}catch(t){e.logError("monitorClass",t)}}},188:function(t,e,n){var o=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.NetworkCore=void 0;const h=n(280),v=n(780),s=n(612),r=n(604),u=n(972);e.NetworkCore=class{constructor(t,e){this.P=t,this.M=e,this.lt=null!=(e=null==t?void 0:t.networkTimeoutMs)?e:1e4}post(e){return o(this,void 0,void 0,function*(){var t=yield this.ct(e);return this.dt(Object.assign({method:"POST",body:t},e))})}get(t){return o(this,void 0,void 0,function*(){return this.dt(Object.assign({method:"GET"},t))})}isBeaconSupported(){return"undefined"!=typeof navigator&&"function"==typeof(null===navigator||void 0===navigator?void 0:navigator.sendBeacon)}beacon(n){return o(this,void 0,void 0,function*(){var t=yield this.ht(n),e=yield this.ct(n);return navigator.sendBeacon(t,e)})}dt(c){var d;return o(this,void 0,void 0,function*(){var{method:e,body:n,retries:i}=c;const o=new AbortController;var t,s,r,u=setTimeout(()=>o.abort(`Timeout of ${this.lt}ms expired.`),this.lt),l=yield this.ht(c);let a=null;try{if(a=yield fetch(l,{method:e,body:n,headers:Object.assign({},c.headers),signal:o.signal}),clearTimeout(u),a.ok)return r=yield a.text(),h.Diagnostics.mark("_sendRequest:response-received",{status:a.status,contentLength:a.headers.get("content-length")}),{body:r,code:a.status};throw t=yield a.text().catch(()=>"No Text"),(s=new Error(`Failed to fetch: ${l} `+t)).name="NetworkError",s}catch(t){n=function(t,e){if(t.signal.aborted&&"string"==typeof t.signal.reason)return t.signal.reason;if("string"==typeof e)return e;if(e instanceof Error)return e.name+": "+e.message;return null}(o,t);return h.Diagnostics.mark("_sendRequest:error",{error:n,status:null===a||void 0===a?void 0:a.status,contentLength:null===a||void 0===a?void 0:a.headers.get("content-length")}),!i||i<=0?(null!=(d=this.M)&&d.call(this,{name:"error",error:t}),v.Log.error(`A networking error occured during ${e} request to ${l}.`,n,t),null):this.dt(Object.assign(Object.assign({},c),{retries:i-1}))}})}ht(e){return o(this,void 0,void 0,function*(){var t=u.StatsigMetadataProvider.get(),t=Object.assign({k:e.sdkKey,st:t.sdkType,sv:t.sdkVersion,t:String(Date.now()),sid:yield s.SessionID.get(e.sdkKey)},e.params),t=Object.entries(t).map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e)).join("&");return e.url+(t?"?"+t:"")})}ct(i){return o(this,void 0,void 0,function*(){var t=i["data"],e=yield r.StableID.get(i.sdkKey),n=yield s.SessionID.get(i.sdkKey);return JSON.stringify(Object.assign(Object.assign({},t),{statsigMetadata:Object.assign(Object.assign({},u.StatsigMetadataProvider.get()),{stableID:e,sessionID:n})}))})}}},264:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CombinationOverrideAdapter=void 0;e.CombinationOverrideAdapter=class{constructor(t){this.providers=t}getGateOverride(n,i){return this.vt(t=>{var e;return null!=(e=null==(e=t.getGateOverride)?void 0:e.call(t,n,i))?e:null})}getDynamicConfigOverride(n,i){return this.vt(t=>{var e;return null!=(e=null==(e=t.getDynamicConfigOverride)?void 0:e.call(t,n,i))?e:null})}vt(t){for(const n of this.providers){var e=t(n);if(e)return e}return null}}},612:function(t,r,e){var n=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(r,"__esModule",{value:!0}),r.SessionID=void 0;const i=e(832),u=e(780),l=e(444),a=e(556),c={},d={},h={};function v(t){return"statsig.session_id."+(0,i.DJB2)(t)}r.SessionID={get:t=>n(void 0,void 0,void 0,function*(){return null!=h[t]?h[t]:h[t]=r.SessionID.ft(t)}),ft:s=>n(void 0,void 0,void 0,function*(){let e=c[s];var n=Date.now();let i=!1;if(null==e){let t=yield function(t){t=v(t);return(0,l.getObjectFromStorage)(t)}(s);null==t&&(t={sessionID:(0,a.getUUID)(),startTime:n,lastUpdate:n},i=!0),e=t,c[s]=e}var t=null!=(t=d[s])?t:{ageTimeoutID:null,idleTimeoutID:null,emitFunction:()=>{}},n=((144e5<n-e.startTime||18e5<n-e.lastUpdate)&&(e.sessionID=(0,a.getUUID)(),e.startTime=n,i=!0),e.lastUpdate=n,e),o=s;return o=v(s),(0,l.setObjectInStorage)(o,n).catch(()=>{u.Log.warn("Failed to save SessionID")}),t.idleTimeoutID=r.SessionID._t(t,t.idleTimeoutID,18e5),i&&(t.ageTimeoutID=r.SessionID._t(t,t.ageTimeoutID,144e5)),c[s]=e,d[s]=t,h[s]=null,e.sessionID}),gt:(t,e)=>{var n=null!=(n=d[e])?n:{ageTimeoutID:null,idleTimeoutID:null,emitFunction:t};n.emitFunction=t,d[e]=n},_t:(t,e,n)=>(clearTimeout(null!=e?e:void 0),setTimeout(t.emitFunction,n))}},604:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.StableID=void 0;const o=n(832),s=n(780),r=n(444),u=n(556),l={};function a(t){return"statsig.stable_id."+(0,o.DJB2)(t)}function c(t,e){e=a(e);(0,r.setObjectInStorage)(e,t).catch(()=>{s.Log.warn("Failed to save StableID")})}e.StableID={get:e=>i(void 0,void 0,void 0,function*(){return null==l[e]&&(l[e]=function(t){t=a(t);return(0,r.getObjectFromStorage)(t)}(e).then(t=>{return null!=t||c(t=(0,u.getUUID)(),e),t})),l[e]}),setOverride:(t,e)=>{l[e]=Promise.resolve(t),c(t,e)}}},688:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigClientBase=void 0,n(496);const s=n(512),r=n(728),u=n(780),l=n(612),a=n(604),c=n(444);e.StatsigClientBase=class{constructor(t,e,n,i){this.loadingStatus="Uninitialized",this.yt={},this.l=t,this.P=null!=i?i:{},null!=i&&i.disableStorage&&c.Storage.setDisabled(!0),null!=i&&i.overrideStableID&&a.StableID.setOverride(i.overrideStableID,t),u.Log.level=null!=(o=null==i?void 0:i.logLevel)?o:u.LogLevel.Warn,this.bt=null!=(o=null==i?void 0:i.overrideAdapter)?o:null,this.wt=new r.EventLogger(t,this.ut.bind(this),n,i),l.SessionID.gt(()=>{this.ut({name:"session_expired"})},t),this.u=new s.ErrorBoundary(t);var o,n=null!=(o=(__STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}).instances)?o:{};n[t]=this,__STATSIG__.instances=n,(__STATSIG__.lastInstance=this).dataAdapter=e,this.dataAdapter.attach(t,i)}updateRuntimeOptions(t){null!=t.disableLogging&&(this.P.disableLogging=t.disableLogging,this.wt.setLoggingDisabled(t.disableLogging)),null!=t.disableStorage&&(this.P.disableStorage=t.disableStorage,c.Storage.setDisabled(t.disableStorage))}flush(){return this.wt.flush()}shutdown(){return i(this,void 0,void 0,function*(){this.ut({name:"pre_shutdown"}),yield this.wt.shutdown()})}on(t,e){this.yt[t]||(this.yt[t]=[]),this.yt[t].push(e)}off(t,e){this.yt[t]&&-1!==(e=this.yt[t].indexOf(e))&&this.yt[t].splice(e,1)}ut(e){var t;const n=t=>{try{t(e)}catch(t){u.Log.error("An error occurred in a StatsigClientEvent listener. This is not an issue with Statsig.",e)}};this.yt[e.name]&&this.yt[e.name].forEach(t=>n(t)),null!=(t=this.yt["*"])&&t.forEach(n)}St(t,e){this.loadingStatus=t,this.ut({name:"values_updated",status:t,values:e})}Ot(t,e,n){!0===(null==n?void 0:n.disableExposureLog)?this.wt.incrementNonExposureCount(t):this.wt.enqueue(e)}}},808:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},283:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DataAdapterCachePrefix=void 0,e.DataAdapterCachePrefix="statsig.cached"},876:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createLayerParameterExposure=e.createConfigExposure=e.createGateExposure=e.isExposureEvent=void 0;const n="statsig::config_exposure",i="statsig::gate_exposure";function l(t,e,n,i,o){return{eventName:t,user:e,value:null,metadata:function(t,e){e.reason=t.reason,t.lcut&&(e.lcut=String(t.lcut));t.receivedAt&&(e.receivedAt=String(t.receivedAt));return e}(n,i),secondaryExposures:o,time:Date.now()}}e.isExposureEvent=function({eventName:t}){return t===i||t===n},e.createGateExposure=function(t,e){return l(i,t,e.details,{gate:e.name,gateValue:String(e.value),ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])},e.createConfigExposure=function(t,e){return l(n,t,e.details,{config:e.name,ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])},e.createLayerParameterExposure=function(t,e,n){var i,o=e.__evaluation,s=!0===(null==(s=null==o?void 0:o.explicit_parameters)?void 0:s.includes(n));let r="",u=null!=(i=null==o?void 0:o.undelegated_secondary_exposures)?i:[];return s&&(r=null!=(i=o.allocated_experiment_name)?i:"",u=o.secondary_exposures),l("statsig::layer_exposure",t,e.details,{config:e.name,parameterName:n,ruleID:e.ruleID,allocatedExperiment:r,isExplicitParameter:String(s)},u)}},972:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigMetadataProvider=void 0;let n={sdkVersion:"0.0.1-beta.26",sdkType:"js-mono"};e.StatsigMetadataProvider={get:()=>n,add:t=>{n=Object.assign(Object.assign({},n),t)}}},384:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},396:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.jt=e.Tt=e.It=e.At=void 0;const o="default";function s(s,r){return(t,e)=>{var n,i,o=null!=(o=null==s?void 0:s[t])?o:null;return null==o||null!=e&&(n=e,(i=t=>Array.isArray(t)?"array":typeof t)(o)!==i(n))?null!=e?e:null:(null!=r&&r(t),o)}}e.At=function(t,e,n){return{name:t,details:e,ruleID:null!=(t=null==n?void 0:n.rule_id)?t:o,value:!0===(null==n?void 0:n.value),__evaluation:n}},e.It=function(t,e,n){return{name:t,details:e,value:null!=(t=null==n?void 0:n.value)?t:{},ruleID:null!=(e=null==n?void 0:n.rule_id)?e:o,groupName:null,get:s(null==n?void 0:n.value),__evaluation:n}},e.Tt=function(t,e,n,i){return{name:t,details:e,get:s(null==n?void 0:n.value,i),ruleID:null!=(t=null==n?void 0:n.rule_id)?t:o,groupName:null!=(e=null==n?void 0:n.group_name)?e:null,__value:null!=(i=null==n?void 0:n.value)?i:{},__evaluation:n}},e.jt=function(t,e,n,i){return Object.assign(Object.assign(Object.assign({},t),e),{get:s(n,i)})}},136:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},296:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getUnitIDFromUser=e.getUserStorageKey=e.normalizeUser=void 0;const i=n(832);e.normalizeUser=function(t,e){try{var n=JSON.parse(JSON.stringify(t));return null!=e&&(n.statsigEnvironment=e),n}catch(t){throw new Error("User object must be convertable to JSON string.")}},e.getUserStorageKey=function(t,e){return(0,i.DJB2Object)({sdkKey:t,user:e})},e.getUnitIDFromUser=function(t,e){var n;return"string"==typeof e&&"userid"!==e.toLowerCase()?null!=(n=null==(n=t.customIDs)?void 0:n[e])?n:null==(n=null==t?void 0:t.customIDs)?void 0:n[e.toLowerCase()]:t.userID}},444:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})},n=(Object.defineProperty(e,"__esModule",{value:!0}),e.setObjectInStorage=e.getObjectFromStorage=e.Storage=void 0,n(780));const o={},s={getProviderName:()=>"InMemory",getItemSync(t){return null!=(t=o[t])?t:null},getItem(t){return Promise.resolve(null!=(t=o[t])?t:null)},setItem(t,e){return o[t]=e,Promise.resolve()},removeItem(t){return delete o[t],Promise.resolve()},getAllKeys(){return Promise.resolve(Object.keys(o))}};let r=null;try{"undefined"!=typeof window&&"localStorage"in window&&(r={getProviderName:()=>"LocalStorage",getItemSync(t){return localStorage.getItem(t)},getItem(t){return Promise.resolve(localStorage.getItem(t))},setItem(t,e){return localStorage.setItem(t,e),Promise.resolve()},removeItem(t){return localStorage.removeItem(t),Promise.resolve()},getAllKeys(){var t=Object.keys(localStorage);return Promise.resolve(t)}})}catch(t){n.Log.warn("Failed to setup localStorageProvider.")}let u=null!==r&&void 0!==r?r:s,l=u;e.Storage={getProviderName:()=>l.getProviderName(),getItem:t=>l.getItem(t),setItem:(t,e)=>l.setItem(t,e),removeItem:t=>l.removeItem(t),getAllKeys:()=>l.getAllKeys(),getItemSync:t=>{var e;return null!=(e=null==(e=l.getItemSync)?void 0:e.call(l,t))?e:null},setProvider:t=>{u=t,l=t},setDisabled:t=>{l=t?s:u}},e.getObjectFromStorage=function(e){return i(this,void 0,void 0,function*(){var t=yield l.getItem(e);return JSON.parse(null!=t?t:"null")})},e.setObjectInStorage=function(t,e){return i(this,void 0,void 0,function*(){yield l.setItem(t,JSON.stringify(e))})}},412:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.typedJsonParse=void 0;const o=n(780);e.typedJsonParse=function(t,e,n){try{var i=JSON.parse(t);return"object"==typeof i&&0 in i,i}catch(t){}return o.Log.error(n),null}},556:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getUUID=void 0,e.getUUID=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();let n=(new Date).getTime(),i="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return`xxxxxxxx-xxxx-4xxx-${"89ab"[Math.floor(4*Math.random())]}xxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let e=16*Math.random();return 0<n?(e=(n+e)%16|0,n=Math.floor(n/16)):(e=(i+e)%16|0,i=Math.floor(i/16)),("x"===t?e:7&e|8).toString(16)})}},84:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.$=void 0,e.$=function(t,e,n,i){return t||(e?""+e+n:""+i+n)}},539:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},408:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VisibilityChangeObserver=void 0;class n{static isCurrentlyVisible(){return"foreground"===this.xt}static add(t){this.yt.push(t)}static remove(t){t=this.yt.indexOf(t);-1!==t&&this.yt.splice(t,1)}static notify(e){e!==this.xt&&(this.xt=e,this.yt.forEach(t=>t.onVisibilityChanged(e)))}}(e.VisibilityChangeObserver=n).yt=[],n.xt="foreground","undefined"!=typeof window&&"function"==typeof window.addEventListener&&(window.addEventListener("focus",()=>n.notify("foreground")),window.addEventListener("blur",()=>n.notify("background")),window.addEventListener("beforeunload",()=>n.notify("background"))),"undefined"!=typeof document&&"function"==typeof document.addEventListener&&document.addEventListener("visibilitychange",()=>{n.notify("visible"===document.visibilityState?"foreground":"background")})},464:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&("get"in o?e.__esModule:!o.writable&&!o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.Log=e.Storage=e.EventLogger=void 0,n(496);const s=n(728),r=(Object.defineProperty(e,"EventLogger",{enumerable:!0,get:function(){return s.EventLogger}}),n(780)),u=(Object.defineProperty(e,"Log",{enumerable:!0,get:function(){return r.Log}}),n(444));Object.defineProperty(e,"Storage",{enumerable:!0,get:function(){return u.Storage}});var l=n(556);o(n(496),e),o(n(856),e),o(n(320),e),o(n(512),e),o(n(500),e),o(n(788),e),o(n(832),e),o(n(664),e),o(n(780),e),o(n(104),e),o(n(188),e),o(n(264),e),o(n(612),e),o(n(604),e),o(n(688),e),o(n(808),e),o(n(283),e),o(n(876),e),o(n(972),e),o(n(384),e),o(n(396),e),o(n(136),e),o(n(296),e),o(n(444),e),o(n(412),e),o(n(84),e),o(n(539),e),o(n(556),e),o(n(408),e),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{EventLogger:s.EventLogger,Log:r.Log,getUUID:l.getUUID,Storage:u.Storage})},696:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&("get"in o?e.__esModule:!o.writable&&!o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),o(n(208),e),e.default=__STATSIG__},96:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveDeltasResponse=void 0;const i=n(464);function o(t,e){null!=t&&t.forEach(t=>{delete e[t]})}e.resolveDeltasResponse=function(t,e){var n;return(e=(0,i.typedJsonParse)(e,"checksum","Failed to parse DeltasEvaluationResponse"))?(t=t,n=e,t=Object.assign(Object.assign(Object.assign({},t),n),{feature_gates:Object.assign(Object.assign({},t.feature_gates),n.feature_gates),layer_configs:Object.assign(Object.assign({},t.layer_configs),n.layer_configs),dynamic_configs:Object.assign(Object.assign({},t.dynamic_configs),n.dynamic_configs)}),o((t=n=t).deleted_gates,t.feature_gates),delete t.deleted_gates,o(n.deleted_configs,t.dynamic_configs),delete t.deleted_configs,o(n.deleted_layers,t.layer_configs),delete t.deleted_layers,n=t,(t=(0,i.DJB2Object)({feature_gates:n.feature_gates,dynamic_configs:n.dynamic_configs,layer_configs:n.layer_configs}))===e.checksum?JSON.stringify(n):{hadBadDeltaChecksum:!0,badChecksum:t,badMergedConfigs:n,badFullResponse:e.deltas_full_response}):{hadBadDeltaChecksum:!0}}},536:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=n(464);e.default=class{constructor(){this.Dt=null,this.Mt=null,this.Et="Uninitialized",this.Nt=0,this.Pt=0}getValues(){return this.Dt?(0,i.typedJsonParse)(this.Dt,"has_updates","Failed to parse EvaluationStoreValues"):null}reset(){this.Mt=null,this.Dt=null,this.Et="Loading",this.Nt=0,this.Pt=0}finalize(){this.Mt||(this.Et="NoValues")}setValuesFromDataAdapter(t){var e;t&&!0===(null==(e=(0,i.typedJsonParse)(t.data,"has_updates","Failed to parse EvaluationResponse"))?void 0:e.has_updates)&&(this.Dt=t.data,this.Nt=e.time,this.Pt=t.receivedAt,this.Et=t.source,this.Mt=e)}getGate(t){var e,t=null!=(e=null==(e=this.Mt)?void 0:e.feature_gates[t])?e:null;return this.Gt(t)}getConfig(t){var e,t=null!=(e=null==(e=this.Mt)?void 0:e.dynamic_configs[t])?e:null;return this.Gt(t)}getLayer(t){var e,t=null!=(e=null==(e=this.Mt)?void 0:e.layer_configs[t])?e:null;return this.Gt(t)}Gt(t){return{evaluation:t,details:this.kt(null==t)}}kt(t){return"Uninitialized"===this.Et||"NoValues"===this.Et?{reason:this.Et}:{reason:this.Et+":"+(t?"Unrecognized":"Recognized"),lcut:this.Nt,receivedAt:this.Pt}}}},400:function(t,e,n){var s=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(464),u=n(96);class i extends r.NetworkCore{constructor(t,e){super(t,e),this.Ct=(0,r.$)(null==t?void 0:t.initializeUrl,null==t?void 0:t.api,"/initialize","https://api.statsig.com/v1")}fetchEvaluations(n,i,o){return s(this,void 0,void 0,function*(){var t=i?(0,r.typedJsonParse)(i,"has_updates","Failed to parse cached EvaluationResponse"):null;let e={user:o,hash:"djb2",deltasResponseRequested:!1};return null!=t&&t.has_updates&&(e=Object.assign(Object.assign({},e),{sinceTime:t.time,previousDerivedFields:"derived_fields"in t?t.derived_fields:{},deltasResponseRequested:!0})),this.Ft(n,t,e)})}Ft(e,n,i){var o;return s(this,void 0,void 0,function*(){var t=yield this.post({sdkKey:e,url:this.Ct,data:i,retries:2});return 204===(null==t?void 0:t.code)?'{"has_updates": false}':200!==(null==t?void 0:t.code)?null!=(o=null==t?void 0:t.body)?o:null:!0!==(null==n?void 0:n.has_updates)||!0!==(null==(o=t.body)?void 0:o.includes('"is_delta":true'))?t.body:"string"==typeof(t=(0,u.resolveDeltasResponse)(n,t.body))?t:this.Ft(e,n,Object.assign(Object.assign(Object.assign({},i),t),{deltasResponseRequested:!1}))})}}e.default=i},520:function(t,e,n){var i=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(464),o=n(536),s=n(400),u=n(364);n(807);class l extends r.StatsigClientBase{constructor(t,e,n=null){var i=new s.default(n,t=>{this.ut(t)});super(t,null!=(t=null==n?void 0:n.dataAdapter)?t:new u.StatsigEvaluationsDataAdapter,i,n),(0,r.monitorClass)(this.u,this),(0,r.monitorClass)(this.u,i),this.Rt=new o.default,this.Lt=e}static instance(t){var e;return __STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{},null==t?__STATSIG__.lastInstance:null==(e=__STATSIG__.instances)?void 0:e[t]}initializeSync(){this.updateUserSync(this.Lt)}initializeAsync(){return this.updateUserAsync(this.Lt)}updateUserSync(t){this.Ut(t);t=this.dataAdapter.getDataSync(this.Lt);this.Rt.setValuesFromDataAdapter(t),this.Rt.finalize(),this.St("Ready",t),this.Jt(null!=t?t:null,this.Lt)}updateUserAsync(n){return i(this,void 0,void 0,function*(){this.Ut(n);var t=this.Lt,e=this.dataAdapter.getDataSync(t);this.St("Loading",e),this.Rt.setValuesFromDataAdapter(e),e=yield this.dataAdapter.getDataAsync(e,t),t===this.Lt&&this.Rt.setValuesFromDataAdapter(e),this.Rt.finalize(),this.St("Ready",e)})}getContext(){return{sdkKey:this.l,options:this.P,values:this.Rt.getValues(),user:JSON.parse(JSON.stringify(this.Lt))}}getAsyncContext(){return i(this,void 0,void 0,function*(){return Object.assign(Object.assign({},this.getContext()),{sessionID:yield r.SessionID.get(this.l),stableID:yield r.StableID.get(this.l)})})}checkGate(t,e){return this.getFeatureGate(t,e).value}getFeatureGate(t,e){var n=(0,r.DJB2)(t),{evaluation:n,details:i}=this.Rt.getGate(n),i=(0,r.At)(t,i,n),o=null==(o=null==(n=this.bt)?void 0:n.getGateOverride)?void 0:o.call(n,i,this.Lt,e),n=null!=o?o:i;return this.Ot(t,(0,r.createGateExposure)(this.Lt,n),e),this.ut({name:"gate_evaluation",gate:n}),n}getDynamicConfig(t,e){t=this.Kt("dynamic_config",t,e);return this.ut({name:"dynamic_config_evaluation",dynamicConfig:t}),t}getExperiment(t,e){t=this.Kt("experiment",t,e);return this.ut({name:"experiment_evaluation",experiment:t}),t}getLayer(e,n){var t=(0,r.DJB2)(e),{evaluation:t,details:i}=this.Rt.getLayer(t),i=(0,r.Tt)(e,i,t),o=null==(o=null==(t=this.bt)?void 0:t.getLayerOverride)?void 0:o.call(t,i,this.Lt,n);const s=(0,r.jt)(i,o,null!=(t=null==o?void 0:o.__value)?t:i.__value,t=>{this.Ot(e,(0,r.createLayerParameterExposure)(this.Lt,s,t),n)});return this.ut({name:"layer_evaluation",layer:s}),s}logEvent(t,e,n){this.wt.enqueue(Object.assign(Object.assign({},"string"==typeof t?{eventName:t,value:e,metadata:n}:t),{user:this.Lt,time:Date.now()}))}Jt(t,e){this.dataAdapter.getDataAsync(t,e).catch(t=>{r.Log.error("An error occurred after update.",t)})}Ut(t){this.wt.reset(),this.Rt.reset(),this.Lt=(0,r.normalizeUser)(t,this.P.environment)}Kt(t,e,n){var i=(0,r.DJB2)(e),{evaluation:i,details:o}=this.Rt.getConfig(i),o=(0,r.It)(e,o,i),i="experiment"===t?null==(t=null==(i=this.bt)?void 0:i.getExperimentOverride)?void 0:t.call(i,o,this.Lt,n):null==(i=null==(t=this.bt)?void 0:t.getDynamicConfigOverride)?void 0:i.call(t,o,this.Lt,n),t=null!=i?i:o;return this.Ot(e,(0,r.createConfigExposure)(this.Lt,t),n),t}}e.default=l},364:function(t,e,n){var o=this&&this.__awaiter||function(t,r,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}s((l=l.apply(t,r||[])).next())})},i=(Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigEvaluationsDataAdapter=void 0,n(464));const s=n(400);class r extends i.DataAdapterCore{constructor(){super("EvaluationsDataAdapter","evaluations"),this.N=null}attach(t,e){super.attach(t,e),this.N=new s.default(null!=e?e:{})}j(e,n){var i;return o(this,void 0,void 0,function*(){var t=yield null==(i=this.N)?void 0:i.fetchEvaluations(this.T(),e,n);return null!=t?t:null})}}e.StatsigEvaluationsDataAdapter=r},807:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SDK_TYPE=void 0;n=n(464);e.SDK_TYPE="javascript-client",n.StatsigMetadataProvider.add({sdkType:e.SDK_TYPE})},208:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigClient=e.StatsigEvaluationsDataAdapter=void 0;var i=n(520);e.StatsigClient=i.default;const o=n(364);Object.defineProperty(e,"StatsigEvaluationsDataAdapter",{enumerable:!0,get:function(){return o.StatsigEvaluationsDataAdapter}}),n(807),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{StatsigEvaluationsDataAdapter:o.StatsigEvaluationsDataAdapter,StatsigClient:i.default}),e.default=__STATSIG__}},i={};function o(t){var e=i[t];return void 0!==e||(e=i[t]={exports:{}},n[t].call(e.exports,e,e.exports,o)),e.exports}return o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o(696).default})()); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Statsig=e():t.Statsig=e()}(this,()=>(()=>{"use strict";var n={496:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var e="undefined"!=typeof window?window:{},n=void 0!==n.g?n.g:{},i="undefined"!=typeof globalThis?globalThis:{},o=null!=(o=null!=(o=null!=(o=e.__STATSIG__)?o:n.__STATSIG__)?o:i.__STATSIG__)?o:{};e.__STATSIG__=o,n.__STATSIG__=o,i.__STATSIG__=o},856:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},320:function(t,e,n){var r=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.DataAdapterCore=void 0;const i=n(512),o=n(780),s=n(104),u=n(283),l=n(296),a=n(444),c=n(412);e.DataAdapterCore=class{constructor(t,e){this.i=t,this.o=e,this.u=null,this.l=null,this.h={},this.v="statsig.last_modified_time."+e}attach(t,e){this.l=t,this.u=new i.ErrorBoundary(t),(0,s.monitorClass)(this.u,this)}getDataSync(t){var t=this._(t),e=this.h[t];return e||((e=this.m(t))?(this.p(t,e),this.h[t]):null)}getDataAsync(n,i){var o;return r(this,void 0,void 0,function*(){var t=null!=n?n:this.getDataSync(i),t=yield this.O(null!=(o=null==t?void 0:t.data)?o:null,i),e=this._(i);return t&&this.p(e,t),"Network"!==(null==t?void 0:t.source)&&"NetworkNotModified"!==(null==t?void 0:t.source)||(yield this.S(e,t)),t})}prefetchData(n){return r(this,void 0,void 0,function*(){var t=this._(n),e=yield this.getDataAsync(null,n);e&&this.p(t,Object.assign(Object.assign({},e),{source:"Prefetch"}))})}setData(t,e){e=this._(e);this.p(e,{source:"Bootstrap",data:t,receivedAt:Date.now()})}__primeInMemoryCache(t){this.h=Object.assign(Object.assign({},this.h),t)}O(n,i){return r(this,void 0,void 0,function*(){var t,e=yield this.j(n,i);return e?(t=(0,c.typedJsonParse)(e,"has_updates","Failure while attempting to persist latest value"),n&&!1===(null==t?void 0:t.has_updates)?{source:"NetworkNotModified",data:n,receivedAt:Date.now()}:!0!==(null==t?void 0:t.has_updates)?null:{source:"Network",data:e,receivedAt:Date.now()}):(o.Log.debug("No response returned for latest value"),null)})}T(){return null!=this.l?this.l:(o.Log.error(this.i+" is not attached to a Client"),"")}_(t){t=(0,l.getUserStorageKey)(this.T(),t);return`${u.DataAdapterCachePrefix}.${this.o}.`+t}p(t,e){var n=Object.entries(this.h);n.length<10||([n]=n.reduce((t,e)=>e[1]<t[1]?e:t),delete this.h[n]),this.h[t]=e}m(t){var e=null==(e=a.Storage.getItemSync)?void 0:e.call(a.Storage,t);return null!=e&&(t=(0,c.typedJsonParse)(e,"source","Failed to parse cached result"))?Object.assign(Object.assign({},t),{source:"Cache"}):null}S(t,e){return r(this,void 0,void 0,function*(){yield a.Storage.setItem(t,JSON.stringify(e)),yield this.I(t)})}I(n){var i;return r(this,void 0,void 0,function*(){var t=null!=(i=yield(0,a.getObjectFromStorage)(this.v))?i:{},e=(t[n]=Date.now(),Object.entries(t));e.length<=10||(delete t[(e=e.reduce((t,e)=>e[1]<t[1]?e:t))[0]],yield a.Storage.removeItem(e[0])),yield(0,a.setObjectInStorage)(this.v,t)})}}},280:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Diagnostics=e.captureDiagnostics=void 0;const i=n(780),o="undefined"!=typeof performance&&void 0!==performance.mark;let r=[];e.captureDiagnostics=function(t,e){s.mark(t+":start"),e=e();const n=()=>{s.mark(t+":end"),(t+":end").startsWith("initialize:")&&s.flush()};return e&&e instanceof Promise?e.finally(()=>n()):(n(),e)};class s{static mark(t,e){o&&(t=performance.mark(t,{detail:e}),r.push(t))}static flush(){var t=performance.getEntriesByType("resource").filter(t=>t.name.startsWith("https://api.statsig.com")),t={markers:r,resources:t};i.Log.debug("Diagnostics",t,JSON.stringify(t)),r=[]}}e.Diagnostics=s},512:function(t,u,e){var n=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(u,"__esModule",{value:!0}),u.ErrorBoundary=u.EXCEPTION_ENDPOINT=void 0;const i=e(780),l=e(972);u.EXCEPTION_ENDPOINT="https://statsigapi.net/v1/sdk_exception";u.ErrorBoundary=class{constructor(t){this.l=t,this.A=new Set}capture(e,t,n){try{var i=t();return i&&i instanceof Promise?i.catch(t=>this.D(e,t,n)):i}catch(t){return this.D(e,t,n),null}}logError(t,e){this.D(t,e)}D(o,r,s){try{i.Log.warn("Caught error in "+o,{error:r});n(this,void 0,void 0,function*(){var t,e=null!=r?r:Error("[Statsig] Error was empty"),n=e instanceof Error,i=n?e.name:"No Name";this.A.has(i)||(this.A.add(i),t=l.StatsigMetadataProvider.get(),n=n?e.stack:function(t){try{return JSON.stringify(t)}catch(t){return"[Statsig] Failed to get string for error."}}(e),e=JSON.stringify(Object.assign({tag:o,exception:i,info:n},t)),yield fetch(u.EXCEPTION_ENDPOINT,{method:"POST",headers:{"STATSIG-API-KEY":this.l,"STATSIG-SDK-TYPE":String(t.sdkType),"STATSIG-SDK-VERSION":String(t.sdkVersion),"Content-Type":"application/json"},body:e}),null!=s&&s({name:"error",error:r}))}).then(()=>{}).catch(()=>{})}catch(t){}}}},500:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},788:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},728:function(t,e,n){var i=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.EventLogger=void 0;const o=n(832),r=n(780),s=n(876),u=n(972),l=n(444),a=n(412),c=n(84),d=n(408),h="https://api.statsig.com/v1";e.EventLogger=class{constructor(t,e,n,i){this.l=t,this.M=e,this.N=n,this.P=i,this.C=[],this.G={},this.F={},this.R=!1,this.L=Date.now(),this.U=!0===(null==i?void 0:i.disableLogging),this.V=null!=(t=null==i?void 0:i.loggingBufferMaxSize)?t:50;n=null!=(e=null==i?void 0:i.loggingIntervalMs)?e:1e4;this.J=setInterval(()=>this.K(),n),this.q=(0,c.$)(null==i?void 0:i.logEventUrl,null==i?void 0:i.api,"/rgstr",h),this.B=(0,c.$)(null==i?void 0:i.logEventBeaconUrl,null==i?void 0:i.api,"/log_event_beacon",h),d.VisibilityChangeObserver.add(this),this.W()}setLoggingDisabled(t){this.U=t}enqueue(t){this.H(t)&&(this.Y(t),this.X(),this.C.length>this.V)&&this.K()}incrementNonExposureCount(t){var e=null!=(e=this.F[t])?e:0;this.F[t]=e+1}reset(){this.G={}}onVisibilityChanged(t){"background"===t&&this.K()}shutdown(){return i(this,void 0,void 0,function*(){this.J&&(clearInterval(this.J),this.J=null),yield this.flush()})}flush(){return i(this,void 0,void 0,function*(){var t;this.Z(),0!==this.C.length&&(t=this.C,this.C=[],yield this.tt(t))})}X(){this.R||(this.R=!0,200<Date.now()-this.L)||setTimeout(()=>this.K(),200)}H(t){if((0,s.isExposureEvent)(t)){var t=[t.eventName,null==(e=t.user)?void 0:e.userID,null==(e=t.metadata)?void 0:e.gate,null==(e=t.metadata)?void 0:e.config,null==(e=t.metadata)?void 0:e.ruleID].join("|"),e=this.G[t],n=Date.now();if(e&&n-e<6e4)return!1;1e3<Object.keys(this.G).length&&(this.G={}),this.G[t]=n}return!0}K(){this.flush().catch(()=>{})}tt(t){return i(this,void 0,void 0,function*(){if(this.U)this.et(t);else try{(!d.VisibilityChangeObserver.isCurrentlyVisible()&&this.N.isBeaconSupported()?yield this.nt(t):yield this.it(t)).success?this.M({name:"logs_flushed",events:t}):this.et(t)}catch(t){r.Log.warn("Failed to flush events.")}})}it(e){return i(this,void 0,void 0,function*(){var t=yield this.N.post({sdkKey:this.l,data:{events:e},url:this.q,retries:3,params:{ec:String(e.length)}}),t=null!=t&&t.body?(0,a.typedJsonParse)(t.body,"success","Failed to parse SendEventsResponse"):null;return{success:!0===(null==t?void 0:t.success)}})}nt(t){return i(this,void 0,void 0,function*(){return{success:yield this.N.beacon({sdkKey:this.l,data:{events:t},url:this.B})}})}et(t){for(;500<t.length;)t.shift();var e=this.ot();(0,l.setObjectInStorage)(e,t).catch(()=>{r.Log.warn("Unable to save failed logs to storage")})}W(){const e=this.ot();i(this,void 0,void 0,function*(){var t=yield(0,l.getObjectFromStorage)(e);t&&(yield l.Storage.removeItem(e),yield this.tt(t))}).catch(()=>{r.Log.warn("Failed to flush stored logs")})}ot(){return"statsig.failed_logs."+(0,o.DJB2)(this.l)}Y(t){t.user&&(t.user=Object.assign({},t.user),delete t.user.privateAttributes);var{sdkType:e,sdkVersion:n}=u.StatsigMetadataProvider.get();this.C.push(Object.assign(Object.assign({},t),{statsigMetadata:{sdkType:e,sdkVersion:n}}))}Z(){0!==Object.keys(this.F).length&&(this.Y({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:Object.assign({},this.F)}}),this.F={})}}},832:(t,e)=>{function n(e){let n=0;for(let t=0;t<e.length;t++){var i=e.charCodeAt(t);n=(n<<5)-n+i,n&=n}return String(n>>>0)}Object.defineProperty(e,"__esModule",{value:!0}),e.DJB2Object=e.DJB2=void 0,e.DJB2=n,e.DJB2Object=function(t){return n(JSON.stringify(function n(i){if(null==i)return null;const t=Object.keys(i).sort();const o={};t.forEach(t=>{let e=i[t];e instanceof Object&&(e=n(e)),o[t]=e});return o}(t)))}},664:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},780:(t,e)=>{function n(t){return t.unshift("[Statsig]"),t}var i,o;Object.defineProperty(e,"__esModule",{value:!0}),e.Log=e.LogLevel=void 0,(o=i||(e.LogLevel=i={}))[o.None=0]="None",o[o.Error=1]="Error",o[o.Warn=2]="Warn",o[o.Info=3]="Info",o[o.Debug=4]="Debug";class r{static info(...t){this.level>=i.Info&&console.info(...n(t))}static debug(...t){this.level>=i.Debug&&console.debug(...n(t))}static warn(...t){this.level>=i.Warn&&console.warn(...n(t))}static error(...t){this.level>=i.Error&&console.error(...n(t))}}(e.Log=r).level=i.Error},104:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.monitorClass=void 0;const r=n(280),s=n(688);function c(t,e,n,i){var o=i instanceof s.StatsigClientBase?i.rt.bind(i):void 0;return t.capture(e,()=>(0,r.captureDiagnostics)(e,()=>n.apply(i)),o)}function d(t){return"object"==typeof t&&(t=Object.getPrototypeOf(t))&&"object"==typeof t?t:null}e.monitorClass=function(e,t){try{{var n=e;var i=t;var o;const r=i;for(const s of function(t){const e=new Set;let n=d(t);for(;n&&n!==Object.prototype;)Object.getOwnPropertyNames(n).filter(t=>"function"==typeof(null===n||void 0===n?void 0:n[t])).forEach(t=>e.add(t)),n=Object.getPrototypeOf(n);return Array.from(e)}(r))if("constructor"!==s){const u=r[s];r[s]=function(...t){return c(n,s,()=>u.apply(this,t),i)}}for(const l of function(t){const e=new Set,n=d(t);return Object.getOwnPropertyNames((null===n||void 0===n?void 0:n.constructor)||{}).filter(t=>{var e;return"caller"!==t&&"arguments"!==t&&"callee"!==t&&"function"==typeof(null==(e=null===n||void 0===n?void 0:n.constructor)?void 0:e[t])}).forEach(t=>e.add(t)),Array.from(e)}(r)){const a=null==(o=null===r||void 0===r?void 0:r.constructor)?void 0:o[l];(null===r||void 0===r?void 0:r.constructor)[l]=function(...t){return c(n,r.constructor.name+"."+l,()=>a.apply(r.constructor,t),i)}}return}}catch(t){e.logError("monitorClass",t)}}},188:function(t,e,n){var o=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.NetworkCore=void 0;const h=n(280),v=n(780),r=n(612),s=n(604),u=n(972);e.NetworkCore=class{constructor(t,e){this.P=t,this.M=e,this.ut=null!=(e=null==t?void 0:t.networkTimeoutMs)?e:1e4}post(e){return o(this,void 0,void 0,function*(){var t=yield this.lt(e);return this.ct(Object.assign({method:"POST",body:t},e))})}get(t){return o(this,void 0,void 0,function*(){return this.ct(Object.assign({method:"GET"},t))})}isBeaconSupported(){return"undefined"!=typeof navigator&&"function"==typeof(null===navigator||void 0===navigator?void 0:navigator.sendBeacon)}beacon(n){return o(this,void 0,void 0,function*(){var t=yield this.dt(n),e=yield this.lt(n);return navigator.sendBeacon(t,e)})}ct(c){var d;return o(this,void 0,void 0,function*(){var{method:e,body:n,retries:i}=c;const o=new AbortController;var t,r,s,u=setTimeout(()=>o.abort(`Timeout of ${this.ut}ms expired.`),this.ut),l=yield this.dt(c);let a=null;try{if(a=yield fetch(l,{method:e,body:n,headers:Object.assign({},c.headers),signal:o.signal}),clearTimeout(u),a.ok)return s=yield a.text(),h.Diagnostics.mark("_sendRequest:response-received",{status:a.status,contentLength:a.headers.get("content-length")}),{body:s,code:a.status};throw t=yield a.text().catch(()=>"No Text"),(r=new Error(`Failed to fetch: ${l} `+t)).name="NetworkError",r}catch(t){n=function(t,e){if(t.signal.aborted&&"string"==typeof t.signal.reason)return t.signal.reason;if("string"==typeof e)return e;if(e instanceof Error)return e.name+": "+e.message;return null}(o,t);return h.Diagnostics.mark("_sendRequest:error",{error:n,status:null===a||void 0===a?void 0:a.status,contentLength:null===a||void 0===a?void 0:a.headers.get("content-length")}),!i||i<=0?(null!=(d=this.M)&&d.call(this,{name:"error",error:t}),v.Log.error(`A networking error occured during ${e} request to ${l}.`,n,t),null):this.ct(Object.assign(Object.assign({},c),{retries:i-1}))}})}dt(e){return o(this,void 0,void 0,function*(){var t=u.StatsigMetadataProvider.get(),t=Object.assign({k:e.sdkKey,st:t.sdkType,sv:t.sdkVersion,t:String(Date.now()),sid:yield r.SessionID.get(e.sdkKey)},e.params),t=Object.entries(t).map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e)).join("&");return e.url+(t?"?"+t:"")})}lt(i){return o(this,void 0,void 0,function*(){var t=i["data"],e=yield s.StableID.get(i.sdkKey),n=yield r.SessionID.get(i.sdkKey);return JSON.stringify(Object.assign(Object.assign({},t),{statsigMetadata:Object.assign(Object.assign({},u.StatsigMetadataProvider.get()),{stableID:e,sessionID:n})}))})}}},264:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CombinationOverrideAdapter=void 0;e.CombinationOverrideAdapter=class{constructor(t){this.providers=t}getGateOverride(n,i){return this.ht(t=>{var e;return null!=(e=null==(e=t.getGateOverride)?void 0:e.call(t,n,i))?e:null})}getDynamicConfigOverride(n,i){return this.ht(t=>{var e;return null!=(e=null==(e=t.getDynamicConfigOverride)?void 0:e.call(t,n,i))?e:null})}ht(t){for(const n of this.providers){var e=t(n);if(e)return e}return null}}},612:function(t,s,e){var n=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(s,"__esModule",{value:!0}),s.SessionID=void 0;const i=e(832),u=e(780),l=e(444),a=e(556),c={},d={},h={};function v(t){return"statsig.session_id."+(0,i.DJB2)(t)}s.SessionID={get:t=>n(void 0,void 0,void 0,function*(){return null!=h[t]?h[t]:h[t]=s.SessionID.we(t)}),we:r=>n(void 0,void 0,void 0,function*(){let e=c[r];var n=Date.now();let i=!1;if(null==e){let t=yield function(t){t=v(t);return(0,l.getObjectFromStorage)(t)}(r);null==t&&(t={sessionID:(0,a.getUUID)(),startTime:n,lastUpdate:n},i=!0),e=t,c[r]=e}var t=null!=(t=d[r])?t:{ageTimeoutID:null,idleTimeoutID:null,emitFunction:()=>{}},n=((144e5<n-e.startTime||18e5<n-e.lastUpdate)&&(e.sessionID=(0,a.getUUID)(),e.startTime=n,i=!0),e.lastUpdate=n,e),o=r;return o=v(r),(0,l.setObjectInStorage)(o,n).catch(()=>{u.Log.warn("Failed to save SessionID")}),t.idleTimeoutID=s.SessionID.xe(t,t.idleTimeoutID,18e5),i&&(t.ageTimeoutID=s.SessionID.xe(t,t.ageTimeoutID,144e5)),c[r]=e,d[r]=t,h[r]=null,e.sessionID}),Te:(t,e)=>{var n=null!=(n=d[e])?n:{ageTimeoutID:null,idleTimeoutID:null,emitFunction:t};n.emitFunction=t,d[e]=n},xe:(t,e,n)=>(clearTimeout(null!=e?e:void 0),setTimeout(t.emitFunction,n))}},604:function(t,e,n){var i=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.StableID=void 0;const o=n(832),r=n(780),s=n(444),u=n(556),l={};function a(t){return"statsig.stable_id."+(0,o.DJB2)(t)}function c(t,e){e=a(e);(0,s.setObjectInStorage)(e,t).catch(()=>{r.Log.warn("Failed to save StableID")})}e.StableID={get:e=>i(void 0,void 0,void 0,function*(){return null==l[e]&&(l[e]=function(t){t=a(t);return(0,s.getObjectFromStorage)(t)}(e).then(t=>{return null!=t||c(t=(0,u.getUUID)(),e),t})),l[e]}),setOverride:(t,e)=>{l[e]=Promise.resolve(t),c(t,e)}}},688:function(t,e,n){var i=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigClientBase=void 0,n(496);const r=n(512),s=n(728),u=n(780),l=n(612),a=n(604),c=n(444);e.StatsigClientBase=class{constructor(t,e,n,i){this.loadingStatus="Uninitialized",this.vt={},this.l=t,this.P=null!=i?i:{},null!=i&&i.disableStorage&&c.Storage.setDisabled(!0),null!=i&&i.overrideStableID&&a.StableID.setOverride(i.overrideStableID,t),u.Log.level=null!=(o=null==i?void 0:i.logLevel)?o:u.LogLevel.Warn,this.ft=null!=(o=null==i?void 0:i.overrideAdapter)?o:null,this._t=new s.EventLogger(t,this.rt.bind(this),n,i),l.SessionID.Te(()=>{this.rt({name:"session_expired"})},t),this.u=new r.ErrorBoundary(t);var o,n=null!=(o=(__STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}).instances)?o:{};n[t]=this,__STATSIG__.instances=n,(__STATSIG__.lastInstance=this).dataAdapter=e,this.dataAdapter.attach(t,i)}updateRuntimeOptions(t){null!=t.disableLogging&&(this.P.disableLogging=t.disableLogging,this._t.setLoggingDisabled(t.disableLogging)),null!=t.disableStorage&&(this.P.disableStorage=t.disableStorage,c.Storage.setDisabled(t.disableStorage))}flush(){return this._t.flush()}shutdown(){return i(this,void 0,void 0,function*(){this.rt({name:"pre_shutdown"}),yield this._t.shutdown()})}on(t,e){this.vt[t]||(this.vt[t]=[]),this.vt[t].push(e)}off(t,e){this.vt[t]&&-1!==(e=this.vt[t].indexOf(e))&&this.vt[t].splice(e,1)}rt(e){var t;const n=t=>{try{t(e)}catch(t){u.Log.error("An error occurred in a StatsigClientEvent listener. This is not an issue with Statsig.",e)}};this.vt[e.name]&&this.vt[e.name].forEach(t=>n(t)),null!=(t=this.vt["*"])&&t.forEach(n)}gt(t,e){this.loadingStatus=t,this.rt({name:"values_updated",status:t,values:e})}yt(t,e,n){!0===(null==n?void 0:n.disableExposureLog)?this._t.incrementNonExposureCount(t):this._t.enqueue(e)}}},808:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},283:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DataAdapterCachePrefix=void 0,e.DataAdapterCachePrefix="statsig.cached"},876:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createLayerParameterExposure=e.createConfigExposure=e.createGateExposure=e.isExposureEvent=void 0;const n="statsig::config_exposure",i="statsig::gate_exposure";function l(t,e,n,i,o){return{eventName:t,user:e,value:null,metadata:function(t,e){e.reason=t.reason,t.lcut&&(e.lcut=String(t.lcut));t.receivedAt&&(e.receivedAt=String(t.receivedAt));return e}(n,i),secondaryExposures:o,time:Date.now()}}e.isExposureEvent=function({eventName:t}){return t===i||t===n},e.createGateExposure=function(t,e){return l(i,t,e.details,{gate:e.name,gateValue:String(e.value),ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])},e.createConfigExposure=function(t,e){return l(n,t,e.details,{config:e.name,ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])},e.createLayerParameterExposure=function(t,e,n){var i,o=e.__evaluation,r=!0===(null==(r=null==o?void 0:o.explicit_parameters)?void 0:r.includes(n));let s="",u=null!=(i=null==o?void 0:o.undelegated_secondary_exposures)?i:[];return r&&(s=null!=(i=o.allocated_experiment_name)?i:"",u=o.secondary_exposures),l("statsig::layer_exposure",t,e.details,{config:e.name,parameterName:n,ruleID:e.ruleID,allocatedExperiment:s,isExplicitParameter:String(r)},u)}},972:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigMetadataProvider=void 0;let n={sdkVersion:"0.0.1-beta.25",sdkType:"js-mono"};e.StatsigMetadataProvider={get:()=>n,add:t=>{n=Object.assign(Object.assign({},n),t)}}},384:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},136:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.makeLayer=e.makeDynamicConfig=e.makeFeatureGate=void 0;const o="default";e.makeFeatureGate=function(t,e,n){return{name:t,details:e,ruleID:null!=(t=null==n?void 0:n.rule_id)?t:o,value:!0===(null==n?void 0:n.value),__evaluation:n}},e.makeDynamicConfig=function(t,e,n){return{name:t,details:e,ruleID:null!=(t=null==n?void 0:n.rule_id)?t:o,value:null!=(e=null==n?void 0:n.value)?e:{},__evaluation:n}},e.makeLayer=function(t,e,n,i){return{name:t,details:e,getValue:null!=i?i:()=>{},ruleID:null!=(t=null==n?void 0:n.rule_id)?t:o,bt:null!=(e=null==n?void 0:n.value)?e:{},__evaluation:n}}},296:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getUnitIDFromUser=e.getUserStorageKey=e.normalizeUser=void 0;const i=n(832);e.normalizeUser=function(t,e){try{var n=JSON.parse(JSON.stringify(t));return null!=e&&(n.statsigEnvironment=e),n}catch(t){throw new Error("User object must be convertable to JSON string.")}},e.getUserStorageKey=function(t,e){return(0,i.DJB2Object)({sdkKey:t,user:e})},e.getUnitIDFromUser=function(t,e){var n;return"string"==typeof e&&"userid"!==e.toLowerCase()?null!=(n=null==(n=t.customIDs)?void 0:n[e])?n:null==(n=null==t?void 0:t.customIDs)?void 0:n[e.toLowerCase()]:t.userID}},444:function(t,e,n){var i=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})},n=(Object.defineProperty(e,"__esModule",{value:!0}),e.setObjectInStorage=e.getObjectFromStorage=e.Storage=void 0,n(780));const o={},r={getProviderName:()=>"InMemory",getItemSync(t){return null!=(t=o[t])?t:null},getItem(t){return Promise.resolve(null!=(t=o[t])?t:null)},setItem(t,e){return o[t]=e,Promise.resolve()},removeItem(t){return delete o[t],Promise.resolve()},getAllKeys(){return Promise.resolve(Object.keys(o))}};let s=null;try{"undefined"!=typeof window&&"localStorage"in window&&(s={getProviderName:()=>"LocalStorage",getItemSync(t){return localStorage.getItem(t)},getItem(t){return Promise.resolve(localStorage.getItem(t))},setItem(t,e){return localStorage.setItem(t,e),Promise.resolve()},removeItem(t){return localStorage.removeItem(t),Promise.resolve()},getAllKeys(){var t=Object.keys(localStorage);return Promise.resolve(t)}})}catch(t){n.Log.warn("Failed to setup localStorageProvider.")}let u=null!==s&&void 0!==s?s:r,l=u;e.Storage={getProviderName:()=>l.getProviderName(),getItem:t=>l.getItem(t),setItem:(t,e)=>l.setItem(t,e),removeItem:t=>l.removeItem(t),getAllKeys:()=>l.getAllKeys(),getItemSync:t=>{var e;return null!=(e=null==(e=l.getItemSync)?void 0:e.call(l,t))?e:null},setProvider:t=>{u=t,l=t},setDisabled:t=>{l=t?r:u}},e.getObjectFromStorage=function(e){return i(this,void 0,void 0,function*(){var t=yield l.getItem(e);return JSON.parse(null!=t?t:"null")})},e.setObjectInStorage=function(t,e){return i(this,void 0,void 0,function*(){yield l.setItem(t,JSON.stringify(e))})}},412:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.typedJsonParse=void 0;const o=n(780);e.typedJsonParse=function(t,e,n){try{var i=JSON.parse(t);return"object"==typeof i&&0 in i,i}catch(t){}return o.Log.error(n),null}},556:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getUUID=void 0,e.getUUID=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();let n=(new Date).getTime(),i="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return`xxxxxxxx-xxxx-4xxx-${"89ab"[Math.floor(4*Math.random())]}xxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let e=16*Math.random();return 0<n?(e=(n+e)%16|0,n=Math.floor(n/16)):(e=(i+e)%16|0,i=Math.floor(i/16)),("x"===t?e:7&e|8).toString(16)})}},84:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.$=void 0,e.$=function(t,e,n,i){return t||(e?""+e+n:""+i+n)}},539:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},408:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VisibilityChangeObserver=void 0;class n{static isCurrentlyVisible(){return"foreground"===this.wt}static add(t){this.vt.push(t)}static remove(t){t=this.vt.indexOf(t);-1!==t&&this.vt.splice(t,1)}static notify(e){e!==this.wt&&(this.wt=e,this.vt.forEach(t=>t.onVisibilityChanged(e)))}}(e.VisibilityChangeObserver=n).vt=[],n.wt="foreground","undefined"!=typeof window&&"function"==typeof window.addEventListener&&(window.addEventListener("focus",()=>n.notify("foreground")),window.addEventListener("blur",()=>n.notify("background")),window.addEventListener("beforeunload",()=>n.notify("background"))),"undefined"!=typeof document&&"function"==typeof document.addEventListener&&document.addEventListener("visibilitychange",()=>{n.notify("visible"===document.visibilityState?"foreground":"background")})},464:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&("get"in o?e.__esModule:!o.writable&&!o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.Log=e.Storage=e.EventLogger=void 0,n(496);const r=n(728),s=(Object.defineProperty(e,"EventLogger",{enumerable:!0,get:function(){return r.EventLogger}}),n(780)),u=(Object.defineProperty(e,"Log",{enumerable:!0,get:function(){return s.Log}}),n(444));Object.defineProperty(e,"Storage",{enumerable:!0,get:function(){return u.Storage}});var l=n(556);o(n(496),e),o(n(856),e),o(n(320),e),o(n(512),e),o(n(500),e),o(n(788),e),o(n(832),e),o(n(664),e),o(n(780),e),o(n(104),e),o(n(188),e),o(n(264),e),o(n(612),e),o(n(604),e),o(n(688),e),o(n(808),e),o(n(283),e),o(n(876),e),o(n(972),e),o(n(384),e),o(n(136),e),o(n(296),e),o(n(444),e),o(n(412),e),o(n(84),e),o(n(539),e),o(n(556),e),o(n(408),e),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{EventLogger:r.EventLogger,Log:s.Log,getUUID:l.getUUID,Storage:u.Storage})},920:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AutoInit=void 0;const s=n(464);e.AutoInit=class{static attempt(e){var n;if("undefined"!=typeof window&&"undefined"!=typeof document&&document.currentScript){var i=document.currentScript.getAttribute("src"),o=null==(o=null===window||void 0===window?void 0:window.location)?void 0:o.href;if(i&&o){let t=null;try{var r=new URL(i,o).searchParams;t=null!=(n=r.get("sdkkey"))?n:r.get("sdkKey")}catch(t){s.Log.error("Invalid source URL")}t&&e({sdkKey:t})}}}}},96:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveDeltasResponse=void 0;const i=n(464);function o(t,e){null!=t&&t.forEach(t=>{delete e[t]})}e.resolveDeltasResponse=function(t,e){var n;return(e=(0,i.typedJsonParse)(e,"checksum","Failed to parse DeltasEvaluationResponse"))?(t=t,n=e,t=Object.assign(Object.assign(Object.assign({},t),n),{feature_gates:Object.assign(Object.assign({},t.feature_gates),n.feature_gates),layer_configs:Object.assign(Object.assign({},t.layer_configs),n.layer_configs),dynamic_configs:Object.assign(Object.assign({},t.dynamic_configs),n.dynamic_configs)}),o((t=n=t).deleted_gates,t.feature_gates),delete t.deleted_gates,o(n.deleted_configs,t.dynamic_configs),delete t.deleted_configs,o(n.deleted_layers,t.layer_configs),delete t.deleted_layers,n=t,(t=(0,i.DJB2Object)({feature_gates:n.feature_gates,dynamic_configs:n.dynamic_configs,layer_configs:n.layer_configs}))===e.checksum?JSON.stringify(n):{hadBadDeltaChecksum:!0,badChecksum:t,badMergedConfigs:n,badFullResponse:e.deltas_full_response}):{hadBadDeltaChecksum:!0}}},536:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=n(464);e.default=class{constructor(){this.Ot=null,this.St=null,this.jt="Uninitialized",this.Tt=0,this.It=0}getValues(){return this.Ot?(0,i.typedJsonParse)(this.Ot,"has_updates","Failed to parse EvaluationStoreValues"):null}reset(){this.St=null,this.Ot=null,this.jt="Loading",this.Tt=0,this.It=0}finalize(){this.St||(this.jt="NoValues")}setValuesFromDataAdapter(t){var e;t&&!0===(null==(e=(0,i.typedJsonParse)(t.data,"has_updates","Failed to parse EvaluationResponse"))?void 0:e.has_updates)&&(this.Ot=t.data,this.Tt=e.time,this.It=t.receivedAt,this.jt=t.source,this.St=e)}getGate(t){var e,t=null!=(e=null==(e=this.St)?void 0:e.feature_gates[t])?e:null;return this.At(t)}getConfig(t){var e,t=null!=(e=null==(e=this.St)?void 0:e.dynamic_configs[t])?e:null;return this.At(t)}getLayer(t){var e,t=null!=(e=null==(e=this.St)?void 0:e.layer_configs[t])?e:null;return this.At(t)}At(t){return{evaluation:t,details:this.xt(null==t)}}xt(t){return"Uninitialized"===this.jt||"NoValues"===this.jt?{reason:this.jt}:{reason:this.jt+":"+(t?"Unrecognized":"Recognized"),lcut:this.Tt,receivedAt:this.It}}}},400:function(t,e,n){var r=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const s=n(464),u=n(96);class i extends s.NetworkCore{constructor(t,e){super(t,e),this.Dt=(0,s.$)(null==t?void 0:t.initializeUrl,null==t?void 0:t.api,"/initialize","https://api.statsig.com/v1")}fetchEvaluations(n,i,o){return r(this,void 0,void 0,function*(){var t=i?(0,s.typedJsonParse)(i,"has_updates","Failed to parse cached EvaluationResponse"):null;let e={user:o,hash:"djb2",deltasResponseRequested:!1};return null!=t&&t.has_updates&&(e=Object.assign(Object.assign({},e),{sinceTime:t.time,previousDerivedFields:"derived_fields"in t?t.derived_fields:{},deltasResponseRequested:!0})),this.Mt(n,t,e)})}Mt(e,n,i){var o;return r(this,void 0,void 0,function*(){var t=yield this.post({sdkKey:e,url:this.Dt,data:i,retries:2});return 204===(null==t?void 0:t.code)?'{"has_updates": false}':200!==(null==t?void 0:t.code)?null!=(o=null==t?void 0:t.body)?o:null:!0!==(null==n?void 0:n.has_updates)||!0!==(null==(o=t.body)?void 0:o.includes('"is_delta":true'))?t.body:"string"==typeof(t=(0,u.resolveDeltasResponse)(n,t.body))?t:this.Mt(e,n,Object.assign(Object.assign(Object.assign({},i),t),{deltasResponseRequested:!1}))})}}e.default=i},520:function(t,e,n){var i=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const s=n(464),o=n(536),r=n(400),u=n(364);n(807);class l extends s.StatsigClientBase{constructor(t,e,n=null){var i=new r.default(n,t=>{this.rt(t)});super(t,null!=(t=null==n?void 0:n.dataAdapter)?t:new u.StatsigEvaluationsDataAdapter,i,n),(0,s.monitorClass)(this.u,this),(0,s.monitorClass)(this.u,i),this.Et=new o.default,this.Nt=e}static instance(t){var e;return __STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{},null==t?__STATSIG__.lastInstance:null==(e=__STATSIG__.instances)?void 0:e[t]}initializeSync(){this.updateUserSync(this.Nt)}initializeAsync(){return this.updateUserAsync(this.Nt)}updateUserSync(t){this.kt(t);t=this.dataAdapter.getDataSync(this.Nt);this.Et.setValuesFromDataAdapter(t),this.Et.finalize(),this.gt("Ready",t),this.Pt(null!=t?t:null,this.Nt)}updateUserAsync(n){return i(this,void 0,void 0,function*(){this.kt(n);var t=this.Nt,e=this.dataAdapter.getDataSync(t);this.gt("Loading",e),this.Et.setValuesFromDataAdapter(e),e=yield this.dataAdapter.getDataAsync(e,t),t===this.Nt&&this.Et.setValuesFromDataAdapter(e),this.Et.finalize(),this.gt("Ready",e)})}checkGate(t,e){return this.getFeatureGate(t,e).value}getContext(){return{sdkKey:this.l,options:this.P,values:this.Et.getValues(),user:JSON.parse(JSON.stringify(this.Nt))}}getAsyncContext(){return i(this,void 0,void 0,function*(){return Object.assign(Object.assign({},this.getContext()),{sessionID:yield s.SessionID.get(this.l),stableID:yield s.StableID.get(this.l)})})}getFeatureGate(t,e){var n=(0,s.DJB2)(t),{evaluation:n,details:i}=this.Et.getGate(n),i=(0,s.makeFeatureGate)(t,i,n),o=null==(o=null==(n=this.ft)?void 0:n.getGateOverride)?void 0:o.call(n,i,this.Nt,e),n=null!=o?o:i;return this.yt(t,(0,s.createGateExposure)(this.Nt,n),e),this.rt({name:"gate_evaluation",gate:n}),n}getDynamicConfig(t,e){t=this.Ct("dynamic_config",t,e);return this.rt({name:"dynamic_config_evaluation",dynamicConfig:t}),t}getExperiment(t,e){t=this.Ct("experiment",t,e);return this.rt({name:"experiment_evaluation",experiment:t}),t}getLayer(n,i){var t=(0,s.DJB2)(n),{evaluation:t,details:e}=this.Et.getLayer(t),e=(0,s.makeLayer)(n,e,t),o=null==(o=null==(t=this.ft)?void 0:t.getLayerOverride)?void 0:o.call(t,e,this.Nt,i);const r=null!=o?o:e;return this.rt({name:"layer_evaluation",layer:r}),Object.assign(Object.assign({},r),{getValue:t=>{var e;return t in r.bt&&(e=(0,s.createLayerParameterExposure)(this.Nt,r,t),this.yt(n,e,i),null!=(e=r.bt[t]))?e:null}})}logEvent(t){this._t.enqueue(Object.assign(Object.assign({},t),{user:this.Nt,time:Date.now()}))}Pt(t,e){this.dataAdapter.getDataAsync(t,e).catch(t=>{s.Log.error("An error occurred after update.",t)})}kt(t){this._t.reset(),this.Et.reset(),this.Nt=(0,s.normalizeUser)(t,this.P.environment)}Ct(t,e,n){var i=(0,s.DJB2)(e),{evaluation:i,details:o}=this.Et.getConfig(i),o=(0,s.makeDynamicConfig)(e,o,i),i="experiment"===t?null==(t=null==(i=this.ft)?void 0:i.getExperimentOverride)?void 0:t.call(i,o,this.Nt,n):null==(i=null==(t=this.ft)?void 0:t.getDynamicConfigOverride)?void 0:i.call(t,o,this.Nt,n),t=null!=i?i:o;return this.yt(e,(0,s.createConfigExposure)(this.Nt,t),n),t}}e.default=l},364:function(t,e,n){var o=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})},i=(Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigEvaluationsDataAdapter=void 0,n(464));const r=n(400);class s extends i.DataAdapterCore{constructor(){super("EvaluationsDataAdapter","evaluations"),this.N=null}attach(t,e){super.attach(t,e),this.N=new r.default(null!=e?e:{})}j(e,n){var i;return o(this,void 0,void 0,function*(){var t=yield null==(i=this.N)?void 0:i.fetchEvaluations(this.T(),e,n);return null!=t?t:null})}}e.StatsigEvaluationsDataAdapter=s},807:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SDK_TYPE=void 0;n=n(464);e.SDK_TYPE="javascript-client",n.StatsigMetadataProvider.add({sdkType:e.SDK_TYPE})},208:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigClient=e.StatsigEvaluationsDataAdapter=void 0;var i=n(520);e.StatsigClient=i.default;const o=n(364);Object.defineProperty(e,"StatsigEvaluationsDataAdapter",{enumerable:!0,get:function(){return o.StatsigEvaluationsDataAdapter}}),n(807),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{StatsigEvaluationsDataAdapter:o.StatsigEvaluationsDataAdapter,StatsigClient:i.default}),e.default=__STATSIG__},156:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AutoCapture=void 0;const i=n(464),o=n(76);e.AutoCapture=class{constructor(t){this.Gt=t,this.Ft=Date.now(),this.Rt=0,"undefined"!=typeof document&&"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>this.Lt()):this.Lt()}Ut(){var t;"undefined"!=typeof window&&"undefined"!=typeof document&&(t=t=>{this.Vt(t||window.event)},(0,o.registerEventHandler)(document,"click",t),(0,o.registerEventHandler)(document,"submit",t),(0,o.registerEventHandler)(window,"error",t),(0,o.registerEventHandler)(window,"beforeunload",()=>this.Jt()),(0,o.registerEventHandler)(window,"scroll",()=>this.Kt()))}Vt(t){var e;let n=null==(e=t.type)?void 0:e.toLowerCase();"error"===n&&t instanceof ErrorEvent?this.qt(t):(e=(0,o.getTargetNode)(t))&&(0,o.shouldLogEvent)(t,e)&&("submit"===n&&(n="form_submit"),{value:t,metadata:e}=(0,o.gatherEventData)(e),this.zt(n,t,e))}Lt(){this.Ut(),this.$t(),this.Bt()}qt(t){var e=(null==t?void 0:t.error)||{};let n=e;if("object"==typeof e)try{n=JSON.stringify(e)}catch(t){n="function"==typeof(null==e?void 0:e.toString)?e.toString():"Unknown Error"}this.zt("error",t.message,{message:t.message,filename:t.filename,lineno:t.lineno,colno:t.colno,error_str:n})}$t(){setTimeout(()=>{var t=(0,o.getSafeUrl)();this.Wt("page_view",(0,o.getSanitizedPageUrl)(),{title:null===document||void 0===document?void 0:document.title,queryParams:Object.fromEntries(t.searchParams)})},1)}Bt(){"undefined"!=typeof window&&void 0!==window.performance&&"function"==typeof window.performance.getEntriesByType&&"function"==typeof window.performance.getEntriesByName&&setTimeout(()=>{var t={},e=window.performance.getEntriesByType("navigation"),e=(e&&0<e.length&&e[0]instanceof PerformanceNavigationTiming&&(e=e[0],t.load_time_ms=e.duration,t.dom_interactive_time_ms=e.domInteractive-e.startTime,t.redirect_count=e.redirectCount,t.transfer_bytes=e.transferSize),window.performance.getEntriesByName("first-contentful-paint"));e&&0<e.length&&e[0]instanceof PerformancePaintTiming&&(t.first_contentful_paint_time_ms=e[0].startTime),this.zt("performance",(0,o.getSanitizedPageUrl)(),t)},1)}Jt(){this.Wt("page_view_end",(0,o.getSanitizedPageUrl)(),{scrollDepth:this.Rt,pageViewLength:Date.now()-this.Ft})}zt(t,e,n){e={eventName:"auto_capture::"+t,value:e,metadata:Object.assign({sessionId:(0,o.getWebSessionId)(this.Gt.getContext().sdkKey),page_url:(null==(t=null===window||void 0===window?void 0:window.location)?void 0:t.href)||""},n)};this.Gt.logEvent(e),i.Log.debug("Enqueued Event",e)}Wt(t,e,n){this.zt(t,e,n),this.Gt.flush().catch(t=>{i.Log.error(t)})}Kt(){var t=document.body.scrollHeight||1;this.Rt=Math.max(this.Rt,Math.min(100,Math.round((window.scrollY+window.innerHeight)/t*100)))}}},76:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.registerEventHandler=e.getSanitizedPageUrl=e.getWebSessionId=e.getSafeUrl=e.shouldLogEvent=e.getTargetNode=e.gatherEventData=void 0;const o=n(464),r={};function s(e){if(e){let t=e;for(;t;){var n=t.tagName.toLowerCase();if(["body","document"].includes(n))return null;if("a"===t.tagName.toLowerCase())return t;t=t.parentElement}}return null}e.gatherEventData=function(t){var e=t.tagName.toLowerCase(),n={},i=e,o=("form"===e&&(n.action=t.getAttribute("action"),n.method=null!=(o=t.getAttribute("method"))?o:"GET",n.formName=t.getAttribute("name"),n.formId=t.getAttribute("id")),["input","select","textarea"].includes(e)&&"password"!==t.getAttribute("type")&&(n.content=t.value,n.inputName=t.getAttribute("name")),"button"===e&&(n.content=(t.textContent||"").trim()),s(t));return o&&(n.href=o.getAttribute("href")),{value:i,metadata:n}},e.getTargetNode=function(t){if(!t)return null;let e=t.target||t.srcElement;return e&&e instanceof Element?e=3===e.nodeType?e.parentNode||null:e:null},e.shouldLogEvent=function(t,e){if(!t||!e||1!==e.nodeType)return!1;var n=e.tagName.toLowerCase(),i=t.type.toLowerCase();switch(n){case"html":return!1;case"form":return"submit"===i;case"input":case"select":case"textarea":return["change"].includes(i);default:if("click"===i){if("button"===n)return!0;if(s(e))return!0}return!1}},e.getSafeUrl=function(){var t=(null==(t=null===window||void 0===window?void 0:window.location)?void 0:t.href)||"";let e;try{e=new URL(t)}catch(t){e=new URL("error:")}return e},e.getWebSessionId=function(t){var e=function(t){if(window&&window.localStorage)return window.localStorage.getItem(t);return r[t]}(t="statsig.web_analytics.session."+(0,o.DJB2)(t)),n=Date.now();let i=e?(0,o.typedJsonParse)(e,"lastAccessedTime","Failed to parse WebSession"):null;return(i=!i||144e5<n-i.startTime||6e5<n-i.lastAccessedTime?(e=Date.now(),{id:(0,o.getUUID)(),startTime:e,lastAccessedTime:e}):i).lastAccessedTime=n,e=t,n=JSON.stringify(i),window&&window.localStorage?window.localStorage.setItem(e,n):(r[e]=n,o.Log.error("Statsig Web AutoCapture: No window.localStorage")),i.id},e.getSanitizedPageUrl=function(){var t;return(null==(t=null==(t=null===window||void 0===window?void 0:window.location)?void 0:t.href)?void 0:t.split(/[?#]/)[0])||""},e.registerEventHandler=function(t,e,n){t&&t.addEventListener&&t.addEventListener(e,n,!0)}},824:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AutoCapture=void 0;const i=n(156);Object.defineProperty(e,"AutoCapture",{enumerable:!0,get:function(){return i.AutoCapture}}),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{AutoCapture:i.AutoCapture}),e.default=__STATSIG__}},i={};function o(t){var e=i[t];return void 0!==e||(e=i[t]={exports:{}},n[t].call(e.exports,e,e.exports,o)),e.exports}o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}();var t={};{var e=t;const s=o(464),u=o(208),l=o(824);var r=o(920);e.default=__STATSIG__,r.AutoInit.attempt(({sdkKey:t})=>{var e=null==(e=null===__STATSIG__||void 0===__STATSIG__?void 0:__STATSIG__.instances)?void 0:e[t];let n=null;n=(n=e instanceof u.StatsigClient?e:n)||new u.StatsigClient(t,{userID:""}),new l.AutoCapture(n),n.initializeAsync().catch(t=>{s.Log.error(t)})})}return t.default})()); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Statsig=e():t.Statsig=e()}(this,()=>(()=>{"use strict";var n={496:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var e="undefined"!=typeof window?window:{},n=void 0!==n.g?n.g:{},i="undefined"!=typeof globalThis?globalThis:{},o=null!=(o=null!=(o=null!=(o=e.__STATSIG__)?o:n.__STATSIG__)?o:i.__STATSIG__)?o:{};e.__STATSIG__=o,n.__STATSIG__=o,i.__STATSIG__=o},856:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},320:function(t,e,n){var r=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.DataAdapterCore=void 0;const i=n(512),o=n(780),s=n(104),u=n(283),l=n(296),a=n(444),c=n(412);e.DataAdapterCore=class{constructor(t,e){this.i=t,this.o=e,this.u=null,this.l=null,this.h={},this.v="statsig.last_modified_time."+e}attach(t,e){this.l=t,this.u=new i.ErrorBoundary(t),(0,s.monitorClass)(this.u,this)}getDataSync(t){var t=this._(t),e=this.h[t];return e||((e=this.m(t))?(this.p(t,e),this.h[t]):null)}getDataAsync(n,i){var o;return r(this,void 0,void 0,function*(){var t=null!=n?n:this.getDataSync(i),t=yield this.S(null!=(o=null==t?void 0:t.data)?o:null,i),e=this._(i);return t&&this.p(e,t),"Network"!==(null==t?void 0:t.source)&&"NetworkNotModified"!==(null==t?void 0:t.source)||(yield this.O(e,t)),t})}prefetchData(n){return r(this,void 0,void 0,function*(){var t=this._(n),e=yield this.getDataAsync(null,n);e&&this.p(t,Object.assign(Object.assign({},e),{source:"Prefetch"}))})}setData(t,e){e=this._(e);this.p(e,{source:"Bootstrap",data:t,receivedAt:Date.now()})}__primeInMemoryCache(t){this.h=Object.assign(Object.assign({},this.h),t)}S(n,i){return r(this,void 0,void 0,function*(){var t,e=yield this.j(n,i);return e?(t=(0,c.typedJsonParse)(e,"has_updates","Failure while attempting to persist latest value"),n&&!1===(null==t?void 0:t.has_updates)?{source:"NetworkNotModified",data:n,receivedAt:Date.now()}:!0!==(null==t?void 0:t.has_updates)?null:{source:"Network",data:e,receivedAt:Date.now()}):(o.Log.debug("No response returned for latest value"),null)})}T(){return null!=this.l?this.l:(o.Log.error(this.i+" is not attached to a Client"),"")}_(t){t=(0,l.getUserStorageKey)(this.T(),t);return`${u.DataAdapterCachePrefix}.${this.o}.`+t}p(t,e){var n=Object.entries(this.h);n.length<10||([n]=n.reduce((t,e)=>e[1]<t[1]?e:t),delete this.h[n]),this.h[t]=e}m(t){var e=null==(e=a.Storage.getItemSync)?void 0:e.call(a.Storage,t);return null!=e&&(t=(0,c.typedJsonParse)(e,"source","Failed to parse cached result"))?Object.assign(Object.assign({},t),{source:"Cache"}):null}O(t,e){return r(this,void 0,void 0,function*(){yield a.Storage.setItem(t,JSON.stringify(e)),yield this.I(t)})}I(n){var i;return r(this,void 0,void 0,function*(){var t=null!=(i=yield(0,a.getObjectFromStorage)(this.v))?i:{},e=(t[n]=Date.now(),Object.entries(t));e.length<=10||(delete t[(e=e.reduce((t,e)=>e[1]<t[1]?e:t))[0]],yield a.Storage.removeItem(e[0])),yield(0,a.setObjectInStorage)(this.v,t)})}}},280:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Diagnostics=e.captureDiagnostics=void 0;const i=n(780),o="undefined"!=typeof performance&&void 0!==performance.mark;let r=[];e.captureDiagnostics=function(t,e){s.mark(t+":start"),e=e();const n=()=>{s.mark(t+":end"),(t+":end").startsWith("initialize:")&&s.flush()};return e&&e instanceof Promise?e.finally(()=>n()):(n(),e)};class s{static mark(t,e){o&&(t=performance.mark(t,{detail:e}),r.push(t))}static flush(){var t=performance.getEntriesByType("resource").filter(t=>t.name.startsWith("https://api.statsig.com")),t={markers:r,resources:t};i.Log.debug("Diagnostics",t,JSON.stringify(t)),r=[]}}e.Diagnostics=s},512:function(t,u,e){var n=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(u,"__esModule",{value:!0}),u.ErrorBoundary=u.EXCEPTION_ENDPOINT=void 0;const i=e(780),l=e(972);u.EXCEPTION_ENDPOINT="https://statsigapi.net/v1/sdk_exception";u.ErrorBoundary=class{constructor(t){this.l=t,this.A=new Set}capture(e,t,n){try{var i=t();return i&&i instanceof Promise?i.catch(t=>this.D(e,t,n)):i}catch(t){return this.D(e,t,n),null}}logError(t,e){this.D(t,e)}D(o,r,s){try{i.Log.warn("Caught error in "+o,{error:r});n(this,void 0,void 0,function*(){var t,e=null!=r?r:Error("[Statsig] Error was empty"),n=e instanceof Error,i=n?e.name:"No Name";this.A.has(i)||(this.A.add(i),t=l.StatsigMetadataProvider.get(),n=n?e.stack:function(t){try{return JSON.stringify(t)}catch(t){return"[Statsig] Failed to get string for error."}}(e),e=JSON.stringify(Object.assign({tag:o,exception:i,info:n},t)),yield fetch(u.EXCEPTION_ENDPOINT,{method:"POST",headers:{"STATSIG-API-KEY":this.l,"STATSIG-SDK-TYPE":String(t.sdkType),"STATSIG-SDK-VERSION":String(t.sdkVersion),"Content-Type":"application/json"},body:e}),null!=s&&s({name:"error",error:r}))}).then(()=>{}).catch(()=>{})}catch(t){}}}},500:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},788:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},728:function(t,e,n){var i=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.EventLogger=void 0;const o=n(832),r=n(780),s=n(876),u=n(444),l=n(412),a=n(84),c=n(408),d="https://api.statsig.com/v1";e.EventLogger=class{constructor(t,e,n,i){this.l=t,this.M=e,this.N=n,this.P=i,this.G=[],this.C={},this.F={},this.R=!1,this.L=Date.now(),this.U=!0===(null==i?void 0:i.disableLogging),this.J=null!=(t=null==i?void 0:i.loggingBufferMaxSize)?t:50;n=null!=(e=null==i?void 0:i.loggingIntervalMs)?e:1e4;this.K=setInterval(()=>this.V(),n),this.q=(0,a.$)(null==i?void 0:i.logEventUrl,null==i?void 0:i.api,"/rgstr",d),this.B=(0,a.$)(null==i?void 0:i.logEventBeaconUrl,null==i?void 0:i.api,"/log_event_beacon",d),c.VisibilityChangeObserver.add(this),this.H()}setLoggingDisabled(t){this.U=t}enqueue(t){this.W(t)&&(this.Y(t),this.X(),this.G.length>this.J)&&this.V()}incrementNonExposureCount(t){var e=null!=(e=this.F[t])?e:0;this.F[t]=e+1}reset(){this.C={}}onVisibilityChanged(t){"background"===t&&this.V()}shutdown(){return i(this,void 0,void 0,function*(){this.K&&(clearInterval(this.K),this.K=null),yield this.flush()})}flush(){return i(this,void 0,void 0,function*(){var t;this.Z(),0!==this.G.length&&(t=this.G,this.G=[],yield this.tt(t))})}X(){this.R||(this.R=!0,200<Date.now()-this.L)||setTimeout(()=>this.V(),200)}W(t){if((0,s.isExposureEvent)(t)){var t=[t.eventName,null==(e=t.user)?void 0:e.userID,null==(e=t.metadata)?void 0:e.gate,null==(e=t.metadata)?void 0:e.config,null==(e=t.metadata)?void 0:e.ruleID].join("|"),e=this.C[t],n=Date.now();if(e&&n-e<6e4)return!1;1e3<Object.keys(this.C).length&&(this.C={}),this.C[t]=n}return!0}V(){this.flush().catch(()=>{})}tt(t){return i(this,void 0,void 0,function*(){if(this.U)this.et(t);else try{(!c.VisibilityChangeObserver.isCurrentlyVisible()&&this.N.isBeaconSupported()?yield this.nt(t):yield this.it(t)).success?this.M({name:"logs_flushed",events:t}):this.et(t)}catch(t){r.Log.warn("Failed to flush events.")}})}it(e){return i(this,void 0,void 0,function*(){var t=yield this.N.post({sdkKey:this.l,data:{events:e},url:this.q,retries:3,params:{ec:String(e.length)}}),t=null!=t&&t.body?(0,l.typedJsonParse)(t.body,"success","Failed to parse SendEventsResponse"):null;return{success:!0===(null==t?void 0:t.success)}})}nt(t){return i(this,void 0,void 0,function*(){return{success:yield this.N.beacon({sdkKey:this.l,data:{events:t},url:this.B})}})}et(t){for(;500<t.length;)t.shift();var e=this.ot();(0,u.setObjectInStorage)(e,t).catch(()=>{r.Log.warn("Unable to save failed logs to storage")})}H(){const e=this.ot();i(this,void 0,void 0,function*(){var t=yield(0,u.getObjectFromStorage)(e);t&&(yield u.Storage.removeItem(e),yield this.tt(t))}).catch(()=>{r.Log.warn("Failed to flush stored logs")})}ot(){return"statsig.failed_logs."+(0,o.DJB2)(this.l)}Y(t){t.user&&(t.user=Object.assign({},t.user),delete t.user.privateAttributes);var e={},n=this.rt();n&&(e.statsigMetadata={currentPage:n}),this.G.push(Object.assign(Object.assign({},t),e))}Z(){0!==Object.keys(this.F).length&&(this.Y({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:Object.assign({},this.F)}}),this.F={})}rt(){var t;if(!1!==(null==(t=this.P)?void 0:t.includeCurrentPageUrlWithEvents)&&"undefined"!=typeof window&&"object"==typeof window.location)try{return window.location.href.split(/[?#]/)[0]}catch(t){}}}},832:(t,e)=>{function n(e){let n=0;for(let t=0;t<e.length;t++){var i=e.charCodeAt(t);n=(n<<5)-n+i,n&=n}return String(n>>>0)}Object.defineProperty(e,"__esModule",{value:!0}),e.DJB2Object=e.DJB2=void 0,e.DJB2=n,e.DJB2Object=function(t){return n(JSON.stringify(function n(i){if(null==i)return null;const t=Object.keys(i).sort();const o={};t.forEach(t=>{let e=i[t];e instanceof Object&&(e=n(e)),o[t]=e});return o}(t)))}},664:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},780:(t,e)=>{function n(t){return t.unshift("[Statsig]"),t}var i,o;Object.defineProperty(e,"__esModule",{value:!0}),e.Log=e.LogLevel=void 0,(o=i||(e.LogLevel=i={}))[o.None=0]="None",o[o.Error=1]="Error",o[o.Warn=2]="Warn",o[o.Info=3]="Info",o[o.Debug=4]="Debug";class r{static info(...t){this.level>=i.Info&&console.info(...n(t))}static debug(...t){this.level>=i.Debug&&console.debug(...n(t))}static warn(...t){this.level>=i.Warn&&console.warn(...n(t))}static error(...t){this.level>=i.Error&&console.error(...n(t))}}(e.Log=r).level=i.Error},104:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.monitorClass=void 0;const r=n(280),s=n(688);function c(t,e,n,i){var o=i instanceof s.StatsigClientBase?i.ut.bind(i):void 0;return t.capture(e,()=>(0,r.captureDiagnostics)(e,()=>n.apply(i)),o)}function d(t){return"object"==typeof t&&(t=Object.getPrototypeOf(t))&&"object"==typeof t?t:null}e.monitorClass=function(e,t){try{{var n=e;var i=t;var o;const r=i;for(const s of function(t){const e=new Set;let n=d(t);for(;n&&n!==Object.prototype;)Object.getOwnPropertyNames(n).filter(t=>"function"==typeof(null===n||void 0===n?void 0:n[t])).forEach(t=>e.add(t)),n=Object.getPrototypeOf(n);return Array.from(e)}(r))if("constructor"!==s){const u=r[s];r[s]=function(...t){return c(n,s,()=>u.apply(this,t),i)}}for(const l of function(t){const e=new Set,n=d(t);return Object.getOwnPropertyNames((null===n||void 0===n?void 0:n.constructor)||{}).filter(t=>{var e;return"caller"!==t&&"arguments"!==t&&"callee"!==t&&"function"==typeof(null==(e=null===n||void 0===n?void 0:n.constructor)?void 0:e[t])}).forEach(t=>e.add(t)),Array.from(e)}(r)){const a=null==(o=null===r||void 0===r?void 0:r.constructor)?void 0:o[l];(null===r||void 0===r?void 0:r.constructor)[l]=function(...t){return c(n,r.constructor.name+"."+l,()=>a.apply(r.constructor,t),i)}}return}}catch(t){e.logError("monitorClass",t)}}},188:function(t,e,n){var o=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.NetworkCore=void 0;const h=n(280),v=n(780),r=n(612),s=n(604),u=n(972);e.NetworkCore=class{constructor(t,e){this.P=t,this.M=e,this.lt=null!=(e=null==t?void 0:t.networkTimeoutMs)?e:1e4}post(e){return o(this,void 0,void 0,function*(){var t=yield this.ct(e);return this.dt(Object.assign({method:"POST",body:t},e))})}get(t){return o(this,void 0,void 0,function*(){return this.dt(Object.assign({method:"GET"},t))})}isBeaconSupported(){return"undefined"!=typeof navigator&&"function"==typeof(null===navigator||void 0===navigator?void 0:navigator.sendBeacon)}beacon(n){return o(this,void 0,void 0,function*(){var t=yield this.ht(n),e=yield this.ct(n);return navigator.sendBeacon(t,e)})}dt(c){var d;return o(this,void 0,void 0,function*(){var{method:e,body:n,retries:i}=c;const o=new AbortController;var t,r,s,u=setTimeout(()=>o.abort(`Timeout of ${this.lt}ms expired.`),this.lt),l=yield this.ht(c);let a=null;try{if(a=yield fetch(l,{method:e,body:n,headers:Object.assign({},c.headers),signal:o.signal}),clearTimeout(u),a.ok)return s=yield a.text(),h.Diagnostics.mark("_sendRequest:response-received",{status:a.status,contentLength:a.headers.get("content-length")}),{body:s,code:a.status};throw t=yield a.text().catch(()=>"No Text"),(r=new Error(`Failed to fetch: ${l} `+t)).name="NetworkError",r}catch(t){n=function(t,e){if(t.signal.aborted&&"string"==typeof t.signal.reason)return t.signal.reason;if("string"==typeof e)return e;if(e instanceof Error)return e.name+": "+e.message;return null}(o,t);return h.Diagnostics.mark("_sendRequest:error",{error:n,status:null===a||void 0===a?void 0:a.status,contentLength:null===a||void 0===a?void 0:a.headers.get("content-length")}),!i||i<=0?(null!=(d=this.M)&&d.call(this,{name:"error",error:t}),v.Log.error(`A networking error occured during ${e} request to ${l}.`,n,t),null):this.dt(Object.assign(Object.assign({},c),{retries:i-1}))}})}ht(e){return o(this,void 0,void 0,function*(){var t=u.StatsigMetadataProvider.get(),t=Object.assign({k:e.sdkKey,st:t.sdkType,sv:t.sdkVersion,t:String(Date.now()),sid:yield r.SessionID.get(e.sdkKey)},e.params),t=Object.entries(t).map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e)).join("&");return e.url+(t?"?"+t:"")})}ct(i){return o(this,void 0,void 0,function*(){var t=i["data"],e=yield s.StableID.get(i.sdkKey),n=yield r.SessionID.get(i.sdkKey);return JSON.stringify(Object.assign(Object.assign({},t),{statsigMetadata:Object.assign(Object.assign({},u.StatsigMetadataProvider.get()),{stableID:e,sessionID:n})}))})}}},264:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CombinationOverrideAdapter=void 0;e.CombinationOverrideAdapter=class{constructor(t){this.providers=t}getGateOverride(n,i){return this.vt(t=>{var e;return null!=(e=null==(e=t.getGateOverride)?void 0:e.call(t,n,i))?e:null})}getDynamicConfigOverride(n,i){return this.vt(t=>{var e;return null!=(e=null==(e=t.getDynamicConfigOverride)?void 0:e.call(t,n,i))?e:null})}vt(t){for(const n of this.providers){var e=t(n);if(e)return e}return null}}},612:function(t,s,e){var n=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(s,"__esModule",{value:!0}),s.SessionID=void 0;const i=e(832),u=e(780),l=e(444),a=e(556),c={},d={},h={};function v(t){return"statsig.session_id."+(0,i.DJB2)(t)}s.SessionID={get:t=>n(void 0,void 0,void 0,function*(){return null!=h[t]?h[t]:h[t]=s.SessionID.ft(t)}),ft:r=>n(void 0,void 0,void 0,function*(){let e=c[r];var n=Date.now();let i=!1;if(null==e){let t=yield function(t){t=v(t);return(0,l.getObjectFromStorage)(t)}(r);null==t&&(t={sessionID:(0,a.getUUID)(),startTime:n,lastUpdate:n},i=!0),e=t,c[r]=e}var t=null!=(t=d[r])?t:{ageTimeoutID:null,idleTimeoutID:null,emitFunction:()=>{}},n=((144e5<n-e.startTime||18e5<n-e.lastUpdate)&&(e.sessionID=(0,a.getUUID)(),e.startTime=n,i=!0),e.lastUpdate=n,e),o=r;return o=v(r),(0,l.setObjectInStorage)(o,n).catch(()=>{u.Log.warn("Failed to save SessionID")}),t.idleTimeoutID=s.SessionID._t(t,t.idleTimeoutID,18e5),i&&(t.ageTimeoutID=s.SessionID._t(t,t.ageTimeoutID,144e5)),c[r]=e,d[r]=t,h[r]=null,e.sessionID}),gt:(t,e)=>{var n=null!=(n=d[e])?n:{ageTimeoutID:null,idleTimeoutID:null,emitFunction:t};n.emitFunction=t,d[e]=n},_t:(t,e,n)=>(clearTimeout(null!=e?e:void 0),setTimeout(t.emitFunction,n))}},604:function(t,e,n){var i=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.StableID=void 0;const o=n(832),r=n(780),s=n(444),u=n(556),l={};function a(t){return"statsig.stable_id."+(0,o.DJB2)(t)}function c(t,e){e=a(e);(0,s.setObjectInStorage)(e,t).catch(()=>{r.Log.warn("Failed to save StableID")})}e.StableID={get:e=>i(void 0,void 0,void 0,function*(){return null==l[e]&&(l[e]=function(t){t=a(t);return(0,s.getObjectFromStorage)(t)}(e).then(t=>{return null!=t||c(t=(0,u.getUUID)(),e),t})),l[e]}),setOverride:(t,e)=>{l[e]=Promise.resolve(t),c(t,e)}}},688:function(t,e,n){var i=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigClientBase=void 0,n(496);const r=n(512),s=n(728),u=n(780),l=n(612),a=n(604),c=n(444);e.StatsigClientBase=class{constructor(t,e,n,i){this.loadingStatus="Uninitialized",this.yt={},this.l=t,this.P=null!=i?i:{},null!=i&&i.disableStorage&&c.Storage.setDisabled(!0),null!=i&&i.overrideStableID&&a.StableID.setOverride(i.overrideStableID,t),u.Log.level=null!=(o=null==i?void 0:i.logLevel)?o:u.LogLevel.Warn,this.bt=null!=(o=null==i?void 0:i.overrideAdapter)?o:null,this.wt=new s.EventLogger(t,this.ut.bind(this),n,i),l.SessionID.gt(()=>{this.ut({name:"session_expired"})},t),this.u=new r.ErrorBoundary(t);var o,n=null!=(o=(__STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}).instances)?o:{};n[t]=this,__STATSIG__.instances=n,(__STATSIG__.lastInstance=this).dataAdapter=e,this.dataAdapter.attach(t,i)}updateRuntimeOptions(t){null!=t.disableLogging&&(this.P.disableLogging=t.disableLogging,this.wt.setLoggingDisabled(t.disableLogging)),null!=t.disableStorage&&(this.P.disableStorage=t.disableStorage,c.Storage.setDisabled(t.disableStorage))}flush(){return this.wt.flush()}shutdown(){return i(this,void 0,void 0,function*(){this.ut({name:"pre_shutdown"}),yield this.wt.shutdown()})}on(t,e){this.yt[t]||(this.yt[t]=[]),this.yt[t].push(e)}off(t,e){this.yt[t]&&-1!==(e=this.yt[t].indexOf(e))&&this.yt[t].splice(e,1)}ut(e){var t;const n=t=>{try{t(e)}catch(t){u.Log.error("An error occurred in a StatsigClientEvent listener. This is not an issue with Statsig.",e)}};this.yt[e.name]&&this.yt[e.name].forEach(t=>n(t)),null!=(t=this.yt["*"])&&t.forEach(n)}St(t,e){this.loadingStatus=t,this.ut({name:"values_updated",status:t,values:e})}Ot(t,e,n){!0===(null==n?void 0:n.disableExposureLog)?this.wt.incrementNonExposureCount(t):this.wt.enqueue(e)}}},808:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},283:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DataAdapterCachePrefix=void 0,e.DataAdapterCachePrefix="statsig.cached"},876:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createLayerParameterExposure=e.createConfigExposure=e.createGateExposure=e.isExposureEvent=void 0;const n="statsig::config_exposure",i="statsig::gate_exposure";function l(t,e,n,i,o){return{eventName:t,user:e,value:null,metadata:function(t,e){e.reason=t.reason,t.lcut&&(e.lcut=String(t.lcut));t.receivedAt&&(e.receivedAt=String(t.receivedAt));return e}(n,i),secondaryExposures:o,time:Date.now()}}e.isExposureEvent=function({eventName:t}){return t===i||t===n},e.createGateExposure=function(t,e){return l(i,t,e.details,{gate:e.name,gateValue:String(e.value),ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])},e.createConfigExposure=function(t,e){return l(n,t,e.details,{config:e.name,ruleID:e.ruleID},null!=(e=null==(t=e.__evaluation)?void 0:t.secondary_exposures)?e:[])},e.createLayerParameterExposure=function(t,e,n){var i,o=e.__evaluation,r=!0===(null==(r=null==o?void 0:o.explicit_parameters)?void 0:r.includes(n));let s="",u=null!=(i=null==o?void 0:o.undelegated_secondary_exposures)?i:[];return r&&(s=null!=(i=o.allocated_experiment_name)?i:"",u=o.secondary_exposures),l("statsig::layer_exposure",t,e.details,{config:e.name,parameterName:n,ruleID:e.ruleID,allocatedExperiment:s,isExplicitParameter:String(r)},u)}},972:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigMetadataProvider=void 0;let n={sdkVersion:"0.0.1-beta.26",sdkType:"js-mono"};e.StatsigMetadataProvider={get:()=>n,add:t=>{n=Object.assign(Object.assign({},n),t)}}},384:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},396:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.jt=e.Tt=e.It=e.At=void 0;const o="default";function r(r,s){return(t,e)=>{var n,i,o=null!=(o=null==r?void 0:r[t])?o:null;return null==o||null!=e&&(n=e,(i=t=>Array.isArray(t)?"array":typeof t)(o)!==i(n))?null!=e?e:null:(null!=s&&s(t),o)}}e.At=function(t,e,n){return{name:t,details:e,ruleID:null!=(t=null==n?void 0:n.rule_id)?t:o,value:!0===(null==n?void 0:n.value),__evaluation:n}},e.It=function(t,e,n){return{name:t,details:e,value:null!=(t=null==n?void 0:n.value)?t:{},ruleID:null!=(e=null==n?void 0:n.rule_id)?e:o,groupName:null,get:r(null==n?void 0:n.value),__evaluation:n}},e.Tt=function(t,e,n,i){return{name:t,details:e,get:r(null==n?void 0:n.value,i),ruleID:null!=(t=null==n?void 0:n.rule_id)?t:o,groupName:null!=(e=null==n?void 0:n.group_name)?e:null,__value:null!=(i=null==n?void 0:n.value)?i:{},__evaluation:n}},e.jt=function(t,e,n,i){return Object.assign(Object.assign(Object.assign({},t),e),{get:r(n,i)})}},136:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},296:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getUnitIDFromUser=e.getUserStorageKey=e.normalizeUser=void 0;const i=n(832);e.normalizeUser=function(t,e){try{var n=JSON.parse(JSON.stringify(t));return null!=e&&(n.statsigEnvironment=e),n}catch(t){throw new Error("User object must be convertable to JSON string.")}},e.getUserStorageKey=function(t,e){return(0,i.DJB2Object)({sdkKey:t,user:e})},e.getUnitIDFromUser=function(t,e){var n;return"string"==typeof e&&"userid"!==e.toLowerCase()?null!=(n=null==(n=t.customIDs)?void 0:n[e])?n:null==(n=null==t?void 0:t.customIDs)?void 0:n[e.toLowerCase()]:t.userID}},444:function(t,e,n){var i=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})},n=(Object.defineProperty(e,"__esModule",{value:!0}),e.setObjectInStorage=e.getObjectFromStorage=e.Storage=void 0,n(780));const o={},r={getProviderName:()=>"InMemory",getItemSync(t){return null!=(t=o[t])?t:null},getItem(t){return Promise.resolve(null!=(t=o[t])?t:null)},setItem(t,e){return o[t]=e,Promise.resolve()},removeItem(t){return delete o[t],Promise.resolve()},getAllKeys(){return Promise.resolve(Object.keys(o))}};let s=null;try{"undefined"!=typeof window&&"localStorage"in window&&(s={getProviderName:()=>"LocalStorage",getItemSync(t){return localStorage.getItem(t)},getItem(t){return Promise.resolve(localStorage.getItem(t))},setItem(t,e){return localStorage.setItem(t,e),Promise.resolve()},removeItem(t){return localStorage.removeItem(t),Promise.resolve()},getAllKeys(){var t=Object.keys(localStorage);return Promise.resolve(t)}})}catch(t){n.Log.warn("Failed to setup localStorageProvider.")}let u=null!==s&&void 0!==s?s:r,l=u;e.Storage={getProviderName:()=>l.getProviderName(),getItem:t=>l.getItem(t),setItem:(t,e)=>l.setItem(t,e),removeItem:t=>l.removeItem(t),getAllKeys:()=>l.getAllKeys(),getItemSync:t=>{var e;return null!=(e=null==(e=l.getItemSync)?void 0:e.call(l,t))?e:null},setProvider:t=>{u=t,l=t},setDisabled:t=>{l=t?r:u}},e.getObjectFromStorage=function(e){return i(this,void 0,void 0,function*(){var t=yield l.getItem(e);return JSON.parse(null!=t?t:"null")})},e.setObjectInStorage=function(t,e){return i(this,void 0,void 0,function*(){yield l.setItem(t,JSON.stringify(e))})}},412:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.typedJsonParse=void 0;const o=n(780);e.typedJsonParse=function(t,e,n){try{var i=JSON.parse(t);return"object"==typeof i&&0 in i,i}catch(t){}return o.Log.error(n),null}},556:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getUUID=void 0,e.getUUID=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();let n=(new Date).getTime(),i="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return`xxxxxxxx-xxxx-4xxx-${"89ab"[Math.floor(4*Math.random())]}xxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let e=16*Math.random();return 0<n?(e=(n+e)%16|0,n=Math.floor(n/16)):(e=(i+e)%16|0,i=Math.floor(i/16)),("x"===t?e:7&e|8).toString(16)})}},84:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.$=void 0,e.$=function(t,e,n,i){return t||(e?""+e+n:""+i+n)}},539:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},408:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VisibilityChangeObserver=void 0;class n{static isCurrentlyVisible(){return"foreground"===this.xt}static add(t){this.yt.push(t)}static remove(t){t=this.yt.indexOf(t);-1!==t&&this.yt.splice(t,1)}static notify(e){e!==this.xt&&(this.xt=e,this.yt.forEach(t=>t.onVisibilityChanged(e)))}}(e.VisibilityChangeObserver=n).yt=[],n.xt="foreground","undefined"!=typeof window&&"function"==typeof window.addEventListener&&(window.addEventListener("focus",()=>n.notify("foreground")),window.addEventListener("blur",()=>n.notify("background")),window.addEventListener("beforeunload",()=>n.notify("background"))),"undefined"!=typeof document&&"function"==typeof document.addEventListener&&document.addEventListener("visibilitychange",()=>{n.notify("visible"===document.visibilityState?"foreground":"background")})},464:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&("get"in o?e.__esModule:!o.writable&&!o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,o)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.Log=e.Storage=e.EventLogger=void 0,n(496);const r=n(728),s=(Object.defineProperty(e,"EventLogger",{enumerable:!0,get:function(){return r.EventLogger}}),n(780)),u=(Object.defineProperty(e,"Log",{enumerable:!0,get:function(){return s.Log}}),n(444));Object.defineProperty(e,"Storage",{enumerable:!0,get:function(){return u.Storage}});var l=n(556);o(n(496),e),o(n(856),e),o(n(320),e),o(n(512),e),o(n(500),e),o(n(788),e),o(n(832),e),o(n(664),e),o(n(780),e),o(n(104),e),o(n(188),e),o(n(264),e),o(n(612),e),o(n(604),e),o(n(688),e),o(n(808),e),o(n(283),e),o(n(876),e),o(n(972),e),o(n(384),e),o(n(396),e),o(n(136),e),o(n(296),e),o(n(444),e),o(n(412),e),o(n(84),e),o(n(539),e),o(n(556),e),o(n(408),e),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{EventLogger:r.EventLogger,Log:s.Log,getUUID:l.getUUID,Storage:u.Storage})},920:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AutoInit=void 0;const s=n(464);e.AutoInit=class{static attempt(e){var n;if("undefined"!=typeof window&&"undefined"!=typeof document&&document.currentScript){var i=document.currentScript.getAttribute("src"),o=null==(o=null===window||void 0===window?void 0:window.location)?void 0:o.href;if(i&&o){let t=null;try{var r=new URL(i,o).searchParams;t=null!=(n=r.get("sdkkey"))?n:r.get("sdkKey")}catch(t){s.Log.error("Invalid source URL")}t&&e({sdkKey:t})}}}}},96:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveDeltasResponse=void 0;const i=n(464);function o(t,e){null!=t&&t.forEach(t=>{delete e[t]})}e.resolveDeltasResponse=function(t,e){var n;return(e=(0,i.typedJsonParse)(e,"checksum","Failed to parse DeltasEvaluationResponse"))?(t=t,n=e,t=Object.assign(Object.assign(Object.assign({},t),n),{feature_gates:Object.assign(Object.assign({},t.feature_gates),n.feature_gates),layer_configs:Object.assign(Object.assign({},t.layer_configs),n.layer_configs),dynamic_configs:Object.assign(Object.assign({},t.dynamic_configs),n.dynamic_configs)}),o((t=n=t).deleted_gates,t.feature_gates),delete t.deleted_gates,o(n.deleted_configs,t.dynamic_configs),delete t.deleted_configs,o(n.deleted_layers,t.layer_configs),delete t.deleted_layers,n=t,(t=(0,i.DJB2Object)({feature_gates:n.feature_gates,dynamic_configs:n.dynamic_configs,layer_configs:n.layer_configs}))===e.checksum?JSON.stringify(n):{hadBadDeltaChecksum:!0,badChecksum:t,badMergedConfigs:n,badFullResponse:e.deltas_full_response}):{hadBadDeltaChecksum:!0}}},536:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=n(464);e.default=class{constructor(){this.Dt=null,this.Mt=null,this.Et="Uninitialized",this.Nt=0,this.Pt=0}getValues(){return this.Dt?(0,i.typedJsonParse)(this.Dt,"has_updates","Failed to parse EvaluationStoreValues"):null}reset(){this.Mt=null,this.Dt=null,this.Et="Loading",this.Nt=0,this.Pt=0}finalize(){this.Mt||(this.Et="NoValues")}setValuesFromDataAdapter(t){var e;t&&!0===(null==(e=(0,i.typedJsonParse)(t.data,"has_updates","Failed to parse EvaluationResponse"))?void 0:e.has_updates)&&(this.Dt=t.data,this.Nt=e.time,this.Pt=t.receivedAt,this.Et=t.source,this.Mt=e)}getGate(t){var e,t=null!=(e=null==(e=this.Mt)?void 0:e.feature_gates[t])?e:null;return this.Gt(t)}getConfig(t){var e,t=null!=(e=null==(e=this.Mt)?void 0:e.dynamic_configs[t])?e:null;return this.Gt(t)}getLayer(t){var e,t=null!=(e=null==(e=this.Mt)?void 0:e.layer_configs[t])?e:null;return this.Gt(t)}Gt(t){return{evaluation:t,details:this.kt(null==t)}}kt(t){return"Uninitialized"===this.Et||"NoValues"===this.Et?{reason:this.Et}:{reason:this.Et+":"+(t?"Unrecognized":"Recognized"),lcut:this.Nt,receivedAt:this.Pt}}}},400:function(t,e,n){var r=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const s=n(464),u=n(96);class i extends s.NetworkCore{constructor(t,e){super(t,e),this.Ct=(0,s.$)(null==t?void 0:t.initializeUrl,null==t?void 0:t.api,"/initialize","https://api.statsig.com/v1")}fetchEvaluations(n,i,o){return r(this,void 0,void 0,function*(){var t=i?(0,s.typedJsonParse)(i,"has_updates","Failed to parse cached EvaluationResponse"):null;let e={user:o,hash:"djb2",deltasResponseRequested:!1};return null!=t&&t.has_updates&&(e=Object.assign(Object.assign({},e),{sinceTime:t.time,previousDerivedFields:"derived_fields"in t?t.derived_fields:{},deltasResponseRequested:!0})),this.Ft(n,t,e)})}Ft(e,n,i){var o;return r(this,void 0,void 0,function*(){var t=yield this.post({sdkKey:e,url:this.Ct,data:i,retries:2});return 204===(null==t?void 0:t.code)?'{"has_updates": false}':200!==(null==t?void 0:t.code)?null!=(o=null==t?void 0:t.body)?o:null:!0!==(null==n?void 0:n.has_updates)||!0!==(null==(o=t.body)?void 0:o.includes('"is_delta":true'))?t.body:"string"==typeof(t=(0,u.resolveDeltasResponse)(n,t.body))?t:this.Ft(e,n,Object.assign(Object.assign(Object.assign({},i),t),{deltasResponseRequested:!1}))})}}e.default=i},520:function(t,e,n){var i=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const s=n(464),o=n(536),r=n(400),u=n(364);n(807);class l extends s.StatsigClientBase{constructor(t,e,n=null){var i=new r.default(n,t=>{this.ut(t)});super(t,null!=(t=null==n?void 0:n.dataAdapter)?t:new u.StatsigEvaluationsDataAdapter,i,n),(0,s.monitorClass)(this.u,this),(0,s.monitorClass)(this.u,i),this.Rt=new o.default,this.Lt=e}static instance(t){var e;return __STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{},null==t?__STATSIG__.lastInstance:null==(e=__STATSIG__.instances)?void 0:e[t]}initializeSync(){this.updateUserSync(this.Lt)}initializeAsync(){return this.updateUserAsync(this.Lt)}updateUserSync(t){this.Ut(t);t=this.dataAdapter.getDataSync(this.Lt);this.Rt.setValuesFromDataAdapter(t),this.Rt.finalize(),this.St("Ready",t),this.Jt(null!=t?t:null,this.Lt)}updateUserAsync(n){return i(this,void 0,void 0,function*(){this.Ut(n);var t=this.Lt,e=this.dataAdapter.getDataSync(t);this.St("Loading",e),this.Rt.setValuesFromDataAdapter(e),e=yield this.dataAdapter.getDataAsync(e,t),t===this.Lt&&this.Rt.setValuesFromDataAdapter(e),this.Rt.finalize(),this.St("Ready",e)})}getContext(){return{sdkKey:this.l,options:this.P,values:this.Rt.getValues(),user:JSON.parse(JSON.stringify(this.Lt))}}getAsyncContext(){return i(this,void 0,void 0,function*(){return Object.assign(Object.assign({},this.getContext()),{sessionID:yield s.SessionID.get(this.l),stableID:yield s.StableID.get(this.l)})})}checkGate(t,e){return this.getFeatureGate(t,e).value}getFeatureGate(t,e){var n=(0,s.DJB2)(t),{evaluation:n,details:i}=this.Rt.getGate(n),i=(0,s.At)(t,i,n),o=null==(o=null==(n=this.bt)?void 0:n.getGateOverride)?void 0:o.call(n,i,this.Lt,e),n=null!=o?o:i;return this.Ot(t,(0,s.createGateExposure)(this.Lt,n),e),this.ut({name:"gate_evaluation",gate:n}),n}getDynamicConfig(t,e){t=this.Kt("dynamic_config",t,e);return this.ut({name:"dynamic_config_evaluation",dynamicConfig:t}),t}getExperiment(t,e){t=this.Kt("experiment",t,e);return this.ut({name:"experiment_evaluation",experiment:t}),t}getLayer(e,n){var t=(0,s.DJB2)(e),{evaluation:t,details:i}=this.Rt.getLayer(t),i=(0,s.Tt)(e,i,t),o=null==(o=null==(t=this.bt)?void 0:t.getLayerOverride)?void 0:o.call(t,i,this.Lt,n);const r=(0,s.jt)(i,o,null!=(t=null==o?void 0:o.__value)?t:i.__value,t=>{this.Ot(e,(0,s.createLayerParameterExposure)(this.Lt,r,t),n)});return this.ut({name:"layer_evaluation",layer:r}),r}logEvent(t,e,n){this.wt.enqueue(Object.assign(Object.assign({},"string"==typeof t?{eventName:t,value:e,metadata:n}:t),{user:this.Lt,time:Date.now()}))}Jt(t,e){this.dataAdapter.getDataAsync(t,e).catch(t=>{s.Log.error("An error occurred after update.",t)})}Ut(t){this.wt.reset(),this.Rt.reset(),this.Lt=(0,s.normalizeUser)(t,this.P.environment)}Kt(t,e,n){var i=(0,s.DJB2)(e),{evaluation:i,details:o}=this.Rt.getConfig(i),o=(0,s.It)(e,o,i),i="experiment"===t?null==(t=null==(i=this.bt)?void 0:i.getExperimentOverride)?void 0:t.call(i,o,this.Lt,n):null==(i=null==(t=this.bt)?void 0:t.getDynamicConfigOverride)?void 0:i.call(t,o,this.Lt,n),t=null!=i?i:o;return this.Ot(e,(0,s.createConfigExposure)(this.Lt,t),n),t}}e.default=l},364:function(t,e,n){var o=this&&this.__awaiter||function(t,s,u,l){return new(u=u||Promise)(function(n,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function o(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(i,o)}r((l=l.apply(t,s||[])).next())})},i=(Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigEvaluationsDataAdapter=void 0,n(464));const r=n(400);class s extends i.DataAdapterCore{constructor(){super("EvaluationsDataAdapter","evaluations"),this.N=null}attach(t,e){super.attach(t,e),this.N=new r.default(null!=e?e:{})}j(e,n){var i;return o(this,void 0,void 0,function*(){var t=yield null==(i=this.N)?void 0:i.fetchEvaluations(this.T(),e,n);return null!=t?t:null})}}e.StatsigEvaluationsDataAdapter=s},807:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SDK_TYPE=void 0;n=n(464);e.SDK_TYPE="javascript-client",n.StatsigMetadataProvider.add({sdkType:e.SDK_TYPE})},208:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigClient=e.StatsigEvaluationsDataAdapter=void 0;var i=n(520);e.StatsigClient=i.default;const o=n(364);Object.defineProperty(e,"StatsigEvaluationsDataAdapter",{enumerable:!0,get:function(){return o.StatsigEvaluationsDataAdapter}}),n(807),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{StatsigEvaluationsDataAdapter:o.StatsigEvaluationsDataAdapter,StatsigClient:i.default}),e.default=__STATSIG__},156:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AutoCapture=e.runStatsigAutoCapture=void 0;const i=n(464),o=n(76);e.runStatsigAutoCapture=function(t){new r(t)};class r{constructor(t){var t=(this.Vt=t,this.qt=Date.now(),this.zt=0,t.getContext())["sdkKey"],e=null!=(e=(__STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}).acInstances)?e:{};e[t]=this,__STATSIG__.acInstances=e,"undefined"!=typeof document&&"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>this.$t()):this.$t()}Bt(){var t;"undefined"!=typeof window&&"undefined"!=typeof document&&(t=t=>{this.Ht(t||window.event)},(0,o.registerEventHandler)(document,"click",t),(0,o.registerEventHandler)(document,"submit",t),(0,o.registerEventHandler)(window,"error",t),(0,o.registerEventHandler)(window,"beforeunload",()=>this.Wt()),(0,o.registerEventHandler)(window,"scroll",()=>this.Yt()))}Ht(t){var e;let n=null==(e=t.type)?void 0:e.toLowerCase();"error"===n&&t instanceof ErrorEvent?this.Qt(t):(e=(0,o.getTargetNode)(t))&&(0,o.shouldLogEvent)(t,e)&&("submit"===n&&(n="form_submit"),{value:t,metadata:e}=(0,o.gatherEventData)(e),this.Xt(n,t,e))}$t(){this.Bt(),this.Zt(),this.te()}Qt(t){var e=(null==t?void 0:t.error)||{};let n=e;if("object"==typeof e)try{n=JSON.stringify(e)}catch(t){n="function"==typeof(null==e?void 0:e.toString)?e.toString():"Unknown Error"}this.Xt("error",t.message,{message:t.message,filename:t.filename,lineno:t.lineno,colno:t.colno,error_str:n})}Zt(){setTimeout(()=>{var t=(0,o.getSafeUrl)();this.ee("page_view",(0,o.getSanitizedPageUrl)(),{title:null===document||void 0===document?void 0:document.title,queryParams:Object.fromEntries(t.searchParams)})},1)}te(){"undefined"!=typeof window&&void 0!==window.performance&&"function"==typeof window.performance.getEntriesByType&&"function"==typeof window.performance.getEntriesByName&&setTimeout(()=>{var t={},e=window.performance.getEntriesByType("navigation"),e=(e&&0<e.length&&e[0]instanceof PerformanceNavigationTiming&&(e=e[0],t.load_time_ms=e.duration,t.dom_interactive_time_ms=e.domInteractive-e.startTime,t.redirect_count=e.redirectCount,t.transfer_bytes=e.transferSize),window.performance.getEntriesByName("first-contentful-paint"));e&&0<e.length&&e[0]instanceof PerformancePaintTiming&&(t.first_contentful_paint_time_ms=e[0].startTime),this.Xt("performance",(0,o.getSanitizedPageUrl)(),t)},1)}Wt(){this.ee("page_view_end",(0,o.getSanitizedPageUrl)(),{scrollDepth:this.zt,pageViewLength:Date.now()-this.qt})}Xt(t,e,n){e={eventName:"auto_capture::"+t,value:e,metadata:Object.assign({sessionId:(0,o.getWebSessionId)(this.Vt.getContext().sdkKey),page_url:(null==(t=null===window||void 0===window?void 0:window.location)?void 0:t.href)||""},n)};this.Vt.logEvent(e),i.Log.debug("Enqueued Event",e)}ee(t,e,n){this.Xt(t,e,n),this.Vt.flush().catch(t=>{i.Log.error(t)})}Yt(){var t=document.body.scrollHeight||1;this.zt=Math.max(this.zt,Math.min(100,Math.round((window.scrollY+window.innerHeight)/t*100)))}}e.AutoCapture=r},76:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.registerEventHandler=e.getSanitizedPageUrl=e.getWebSessionId=e.getSafeUrl=e.shouldLogEvent=e.getTargetNode=e.gatherEventData=void 0;const o=n(464),r={};function s(e){if(e){let t=e;for(;t;){var n=t.tagName.toLowerCase();if(["body","document"].includes(n))return null;if("a"===t.tagName.toLowerCase())return t;t=t.parentElement}}return null}e.gatherEventData=function(t){var e=t.tagName.toLowerCase(),n={},i=e,o=("form"===e&&(n.action=t.getAttribute("action"),n.method=null!=(o=t.getAttribute("method"))?o:"GET",n.formName=t.getAttribute("name"),n.formId=t.getAttribute("id")),["input","select","textarea"].includes(e)&&"password"!==t.getAttribute("type")&&(n.content=t.value,n.inputName=t.getAttribute("name")),"button"===e&&(n.content=(t.textContent||"").trim()),s(t));return o&&(n.href=o.getAttribute("href")),{value:i,metadata:n}},e.getTargetNode=function(t){if(!t)return null;let e=t.target||t.srcElement;return e&&e instanceof Element?e=3===e.nodeType?e.parentNode||null:e:null},e.shouldLogEvent=function(t,e){if(!t||!e||1!==e.nodeType)return!1;var n=e.tagName.toLowerCase(),i=t.type.toLowerCase();switch(n){case"html":return!1;case"form":return"submit"===i;case"input":case"select":case"textarea":return["change"].includes(i);default:if("click"===i){if("button"===n)return!0;if(s(e))return!0}return!1}},e.getSafeUrl=function(){var t=(null==(t=null===window||void 0===window?void 0:window.location)?void 0:t.href)||"";let e;try{e=new URL(t)}catch(t){e=new URL("error:")}return e},e.getWebSessionId=function(t){var e=function(t){if(window&&window.localStorage)return window.localStorage.getItem(t);return r[t]}(t="statsig.web_analytics.session."+(0,o.DJB2)(t)),n=Date.now();let i=e?(0,o.typedJsonParse)(e,"lastAccessedTime","Failed to parse WebSession"):null;return(i=!i||144e5<n-i.startTime||6e5<n-i.lastAccessedTime?(e=Date.now(),{id:(0,o.getUUID)(),startTime:e,lastAccessedTime:e}):i).lastAccessedTime=n,e=t,n=JSON.stringify(i),window&&window.localStorage?window.localStorage.setItem(e,n):(r[e]=n,o.Log.error("Statsig Web AutoCapture: No window.localStorage")),i.id},e.getSanitizedPageUrl=function(){var t;return(null==(t=null==(t=null===window||void 0===window?void 0:window.location)?void 0:t.href)?void 0:t.split(/[?#]/)[0])||""},e.registerEventHandler=function(t,e,n){t&&t.addEventListener&&t.addEventListener(e,n,!0)}},824:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.runStatsigAutoCapture=e.AutoCapture=void 0;const i=n(156);Object.defineProperty(e,"AutoCapture",{enumerable:!0,get:function(){return i.AutoCapture}}),Object.defineProperty(e,"runStatsigAutoCapture",{enumerable:!0,get:function(){return i.runStatsigAutoCapture}}),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{AutoCapture:i.AutoCapture,runStatsigAutoCapture:i.runStatsigAutoCapture}),e.default=__STATSIG__}},i={};function o(t){var e=i[t];return void 0!==e||(e=i[t]={exports:{}},n[t].call(e.exports,e,e.exports,o)),e.exports}o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}();var t={};{var e=t;const s=o(464),u=o(208),l=o(824);var r=o(920);e.default=__STATSIG__,r.AutoInit.attempt(({sdkKey:t})=>{var e=null==(e=null===__STATSIG__||void 0===__STATSIG__?void 0:__STATSIG__.instances)?void 0:e[t];let n=null;n=(n=e instanceof u.StatsigClient?e:n)||new u.StatsigClient(t,{userID:""}),new l.AutoCapture(n),n.initializeAsync().catch(t=>{s.Log.error(t)})})}return t.default})()); |
{ | ||
"name": "@statsig/js-client", | ||
"version": "0.0.1-beta.25", | ||
"version": "0.0.1-beta.26", | ||
"dependencies": { | ||
"@statsig/client-core": "0.0.1-beta.25" | ||
"@statsig/client-core": "0.0.1-beta.26" | ||
}, | ||
@@ -7,0 +7,0 @@ "jsdelivr": "./build/statsig-js-client.min.js", |
@@ -7,16 +7,119 @@ import { DynamicConfig, DynamicConfigEvaluationOptions, EvaluationsDataAdapter, Experiment, ExperimentEvaluationOptions, FeatureGate, FeatureGateEvaluationOptions, Layer, LayerEvaluationOptions, PrecomputedEvaluationsAsyncContext, PrecomputedEvaluationsContext, PrecomputedEvaluationsInterface, StatsigClientBase, StatsigEvent, StatsigUser } from '@statsig/client-core'; | ||
private _user; | ||
/** | ||
* StatsigClient constuctor | ||
* | ||
* @param {string} sdkKey A Statsig client SDK key. eg "client-xyz123..." | ||
* @param {StatsigUser} user StatsigUser object containing various attributes related to a user. | ||
* @param {StatsigOptions | null} options StatsigOptions, used to customize the behavior of the SDK. | ||
*/ | ||
constructor(sdkKey: string, user: StatsigUser, options?: StatsigOptions | null); | ||
/** | ||
* Retrieves an instance of the StatsigClient based on the provided SDK key. | ||
* If no SDK key is provided, the method returns the most recently created instance of the StatsigClient. | ||
* The method ensures that each unique SDK key corresponds to a single instance of StatsigClient, effectively implementing a singleton pattern for each key. | ||
* | ||
* @param {string} [sdkKey] - Optional. The SDK key used to identify a specific instance of the StatsigClient. If omitted, the method returns the last created instance. | ||
* @returns {StatsigClient|undefined} Returns the StatsigClient instance associated with the given SDK key, or undefined if no instance is associated with the key or if no key is provided and no instances exist. | ||
*/ | ||
static instance(sdkKey?: string): StatsigClient | undefined; | ||
/** | ||
* Initializes the StatsigClient using cached values. This method sets up the client synchronously by utilizing previously cached values. | ||
* After initialization, cache values are updated in the background for future use, either in subsequent sessions or when `updateUser` is called. | ||
* This is useful for quickly starting with the last-known-good configurations while refreshing data to keep settings up-to-date. | ||
* | ||
* @see {@link initializeAsync} for the asynchronous version of this method. | ||
*/ | ||
initializeSync(): void; | ||
/** | ||
* Initializes the StatsigClient asynchronously by first using cached values and then updating to the latest values from the network. | ||
* Once the network values are fetched, they replace the existing cached values. If this method's promise is not awaited, | ||
* there might be a transition from cached to network values during the session, which can affect consistency. | ||
* This method is useful when it's acceptable to begin with potentially stale data and switch to the latest configuration as it becomes available. | ||
* | ||
* @returns {Promise<void>} A promise that resolves once the client is fully initialized with the latest values from the network. | ||
* @see {@link initializeSync} for the synchronous version of this method. | ||
*/ | ||
initializeAsync(): Promise<void>; | ||
/** | ||
* Synchronously updates the user in the Statsig client and switches the internal state to use cached values for the newly specified user. | ||
* After the initial switch to cached values, this method updates these values in the background, preparing them for future sessions or subsequent calls to updateUser. | ||
* This method ensures the client is quickly ready with available data. | ||
* | ||
* @param {StatsigUser} user - The new StatsigUser for which the client should update its internal state. | ||
* @see {@link updateUserAsync} for the asynchronous version of this method. | ||
*/ | ||
updateUserSync(user: StatsigUser): void; | ||
/** | ||
* Asynchronously updates the user in the Statsig client by initially using cached values and then fetching the latest values from the network. | ||
* When the latest values are fetched, they replace the cached values. If the promise returned by this method is not awaited, | ||
* the client's state may shift from cached to updated network values during the session, potentially affecting consistency. | ||
* This method is best used in scenarios where up-to-date configuration is critical and initial delays are acceptable. | ||
* | ||
* @param {StatsigUser} user - The new StatsigUser for which the client should update its internal state. | ||
* @returns {Promise<void>} A promise that resolves once the client is fully updated with the latest network values. | ||
* @see {@link updateUserSync} for the synchronous version of this method. | ||
*/ | ||
updateUserAsync(user: StatsigUser): Promise<void>; | ||
checkGate(name: string, options?: FeatureGateEvaluationOptions): boolean; | ||
/** | ||
* Retrieves a synchronous context containing data currently being used by the SDK. Represented as a {@link PrecomputedEvaluationsContext} object. | ||
* | ||
* @returns {PrecomputedEvaluationsContext} The current synchronous context for the this StatsigClient instance. | ||
* @see {@link getAsyncContext} for the asynchronous version of the context that includes more information. | ||
*/ | ||
getContext(): PrecomputedEvaluationsContext; | ||
/** | ||
* Asynchronously retrieves a context similar to that provided by {@link getContext}, but with additional properties fetched asynchronously, such as session and stable IDs. This is useful for situations where these IDs are required and are not immediately available. | ||
* | ||
* @returns {PrecomputedEvaluationsAsyncContext} An object containing the current values. | ||
* @see {@link getContext} for the synchronous version of the context that this function extends. | ||
*/ | ||
getAsyncContext(): Promise<PrecomputedEvaluationsAsyncContext>; | ||
/** | ||
* Retrieves the value of a feature gate for the current user, represented as a simple boolean. | ||
* | ||
* @param {string} name - The name of the feature gate to retrieve. | ||
* @param {FeatureGateEvaluationOptions} [options] - Optional. Additional options to customize the method call. | ||
* @returns {boolean} - The boolean value representing the gate's current evaluation results for the user. | ||
*/ | ||
checkGate(name: string, options?: FeatureGateEvaluationOptions): boolean; | ||
/** | ||
* Retrieves the value of a feature gate for the current user, represented as a {@link FeatureGate} object. | ||
* | ||
* @param {string} name - The name of the feature gate to retrieve. | ||
* @param {FeatureGateEvaluationOptions} [options] - Optional. Additional options to customize the method call. | ||
* @returns {FeatureGate} - The {@link FeatureGate} object representing the gate's current evaluation results for the user. | ||
*/ | ||
getFeatureGate(name: string, options?: FeatureGateEvaluationOptions): FeatureGate; | ||
/** | ||
* Retrieves the value of a dynamic config for the current user. | ||
* | ||
* @param {string} name The name of the dynamic config to get. | ||
* @param {DynamicConfigEvaluationOptions} [options] - Optional. Additional options to customize the method call. | ||
* @returns {DynamicConfig} - The {@link DynamicConfig} object representing the dynamic configs's current evaluation results for the user. | ||
*/ | ||
getDynamicConfig(name: string, options?: DynamicConfigEvaluationOptions): DynamicConfig; | ||
/** | ||
* Retrieves the value of a experiment for the current user. | ||
* | ||
* @param {string} name The name of the experiment to get. | ||
* @param {ExperimentEvaluationOptions} [options] - Optional. Additional options to customize the method call. | ||
* @returns {Experiment} - The {@link Experiment} object representing the experiments's current evaluation results for the user. | ||
*/ | ||
getExperiment(name: string, options?: ExperimentEvaluationOptions): Experiment; | ||
/** | ||
* Retrieves the value of a layer for the current user. | ||
* | ||
* @param {string} name The name of the layer to get. | ||
* @param {LayerEvaluationOptions} [options] - Optional. Additional options to customize the method call. | ||
* @returns {Layer} - The {@link Layer} object representing the layers's current evaluation results for the user. | ||
*/ | ||
getLayer(name: string, options?: LayerEvaluationOptions): Layer; | ||
logEvent(event: StatsigEvent): void; | ||
/** | ||
* Logs an event to the internal logging system. This function allows logging by either passing a fully formed event object or by specifying the event name with optional value and metadata. | ||
* | ||
* @param {StatsigEvent|string} eventOrName - The event object conforming to the StatsigEvent interface, or the name of the event as a string. | ||
* @param {string|number} value - Optional. The value associated with the event, which can be a string or a number. This parameter is ignored if the first parameter is a StatsigEvent object. | ||
* @param {Record<string, string>} metadata - Optional. A key-value record containing metadata about the event. This is also ignored if the first parameter is an event object. | ||
*/ | ||
logEvent(eventOrName: StatsigEvent | string, value?: string | number, metadata?: Record<string, string>): void; | ||
private _runPostUpdate; | ||
@@ -23,0 +126,0 @@ private _resetForUser; |
@@ -18,2 +18,9 @@ "use strict"; | ||
class StatsigClient extends client_core_1.StatsigClientBase { | ||
/** | ||
* StatsigClient constuctor | ||
* | ||
* @param {string} sdkKey A Statsig client SDK key. eg "client-xyz123..." | ||
* @param {StatsigUser} user StatsigUser object containing various attributes related to a user. | ||
* @param {StatsigOptions | null} options StatsigOptions, used to customize the behavior of the SDK. | ||
*/ | ||
constructor(sdkKey, user, options = null) { | ||
@@ -30,2 +37,10 @@ var _a; | ||
} | ||
/** | ||
* Retrieves an instance of the StatsigClient based on the provided SDK key. | ||
* If no SDK key is provided, the method returns the most recently created instance of the StatsigClient. | ||
* The method ensures that each unique SDK key corresponds to a single instance of StatsigClient, effectively implementing a singleton pattern for each key. | ||
* | ||
* @param {string} [sdkKey] - Optional. The SDK key used to identify a specific instance of the StatsigClient. If omitted, the method returns the last created instance. | ||
* @returns {StatsigClient|undefined} Returns the StatsigClient instance associated with the given SDK key, or undefined if no instance is associated with the key or if no key is provided and no instances exist. | ||
*/ | ||
static instance(sdkKey) { | ||
@@ -39,8 +54,32 @@ var _a; | ||
} | ||
/** | ||
* Initializes the StatsigClient using cached values. This method sets up the client synchronously by utilizing previously cached values. | ||
* After initialization, cache values are updated in the background for future use, either in subsequent sessions or when `updateUser` is called. | ||
* This is useful for quickly starting with the last-known-good configurations while refreshing data to keep settings up-to-date. | ||
* | ||
* @see {@link initializeAsync} for the asynchronous version of this method. | ||
*/ | ||
initializeSync() { | ||
this.updateUserSync(this._user); | ||
} | ||
/** | ||
* Initializes the StatsigClient asynchronously by first using cached values and then updating to the latest values from the network. | ||
* Once the network values are fetched, they replace the existing cached values. If this method's promise is not awaited, | ||
* there might be a transition from cached to network values during the session, which can affect consistency. | ||
* This method is useful when it's acceptable to begin with potentially stale data and switch to the latest configuration as it becomes available. | ||
* | ||
* @returns {Promise<void>} A promise that resolves once the client is fully initialized with the latest values from the network. | ||
* @see {@link initializeSync} for the synchronous version of this method. | ||
*/ | ||
initializeAsync() { | ||
return this.updateUserAsync(this._user); | ||
} | ||
/** | ||
* Synchronously updates the user in the Statsig client and switches the internal state to use cached values for the newly specified user. | ||
* After the initial switch to cached values, this method updates these values in the background, preparing them for future sessions or subsequent calls to updateUser. | ||
* This method ensures the client is quickly ready with available data. | ||
* | ||
* @param {StatsigUser} user - The new StatsigUser for which the client should update its internal state. | ||
* @see {@link updateUserAsync} for the asynchronous version of this method. | ||
*/ | ||
updateUserSync(user) { | ||
@@ -54,2 +93,12 @@ this._resetForUser(user); | ||
} | ||
/** | ||
* Asynchronously updates the user in the Statsig client by initially using cached values and then fetching the latest values from the network. | ||
* When the latest values are fetched, they replace the cached values. If the promise returned by this method is not awaited, | ||
* the client's state may shift from cached to updated network values during the session, potentially affecting consistency. | ||
* This method is best used in scenarios where up-to-date configuration is critical and initial delays are acceptable. | ||
* | ||
* @param {StatsigUser} user - The new StatsigUser for which the client should update its internal state. | ||
* @returns {Promise<void>} A promise that resolves once the client is fully updated with the latest network values. | ||
* @see {@link updateUserSync} for the synchronous version of this method. | ||
*/ | ||
updateUserAsync(user) { | ||
@@ -71,5 +120,8 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
checkGate(name, options) { | ||
return this.getFeatureGate(name, options).value; | ||
} | ||
/** | ||
* Retrieves a synchronous context containing data currently being used by the SDK. Represented as a {@link PrecomputedEvaluationsContext} object. | ||
* | ||
* @returns {PrecomputedEvaluationsContext} The current synchronous context for the this StatsigClient instance. | ||
* @see {@link getAsyncContext} for the asynchronous version of the context that includes more information. | ||
*/ | ||
getContext() { | ||
@@ -83,2 +135,8 @@ return { | ||
} | ||
/** | ||
* Asynchronously retrieves a context similar to that provided by {@link getContext}, but with additional properties fetched asynchronously, such as session and stable IDs. This is useful for situations where these IDs are required and are not immediately available. | ||
* | ||
* @returns {PrecomputedEvaluationsAsyncContext} An object containing the current values. | ||
* @see {@link getContext} for the synchronous version of the context that this function extends. | ||
*/ | ||
getAsyncContext() { | ||
@@ -89,2 +147,19 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
/** | ||
* Retrieves the value of a feature gate for the current user, represented as a simple boolean. | ||
* | ||
* @param {string} name - The name of the feature gate to retrieve. | ||
* @param {FeatureGateEvaluationOptions} [options] - Optional. Additional options to customize the method call. | ||
* @returns {boolean} - The boolean value representing the gate's current evaluation results for the user. | ||
*/ | ||
checkGate(name, options) { | ||
return this.getFeatureGate(name, options).value; | ||
} | ||
/** | ||
* Retrieves the value of a feature gate for the current user, represented as a {@link FeatureGate} object. | ||
* | ||
* @param {string} name - The name of the feature gate to retrieve. | ||
* @param {FeatureGateEvaluationOptions} [options] - Optional. Additional options to customize the method call. | ||
* @returns {FeatureGate} - The {@link FeatureGate} object representing the gate's current evaluation results for the user. | ||
*/ | ||
getFeatureGate(name, options) { | ||
@@ -94,3 +169,3 @@ var _a, _b; | ||
const { evaluation, details } = this._store.getGate(hash); | ||
const gate = (0, client_core_1.makeFeatureGate)(name, details, evaluation); | ||
const gate = (0, client_core_1._makeFeatureGate)(name, details, evaluation); | ||
const overridden = (_b = (_a = this._overrideAdapter) === null || _a === void 0 ? void 0 : _a.getGateOverride) === null || _b === void 0 ? void 0 : _b.call(_a, gate, this._user, options); | ||
@@ -102,2 +177,9 @@ const result = overridden !== null && overridden !== void 0 ? overridden : gate; | ||
} | ||
/** | ||
* Retrieves the value of a dynamic config for the current user. | ||
* | ||
* @param {string} name The name of the dynamic config to get. | ||
* @param {DynamicConfigEvaluationOptions} [options] - Optional. Additional options to customize the method call. | ||
* @returns {DynamicConfig} - The {@link DynamicConfig} object representing the dynamic configs's current evaluation results for the user. | ||
*/ | ||
getDynamicConfig(name, options) { | ||
@@ -108,2 +190,9 @@ const dynamicConfig = this._getConfigImpl('dynamic_config', name, options); | ||
} | ||
/** | ||
* Retrieves the value of a experiment for the current user. | ||
* | ||
* @param {string} name The name of the experiment to get. | ||
* @param {ExperimentEvaluationOptions} [options] - Optional. Additional options to customize the method call. | ||
* @returns {Experiment} - The {@link Experiment} object representing the experiments's current evaluation results for the user. | ||
*/ | ||
getExperiment(name, options) { | ||
@@ -114,21 +203,36 @@ const experiment = this._getConfigImpl('experiment', name, options); | ||
} | ||
/** | ||
* Retrieves the value of a layer for the current user. | ||
* | ||
* @param {string} name The name of the layer to get. | ||
* @param {LayerEvaluationOptions} [options] - Optional. Additional options to customize the method call. | ||
* @returns {Layer} - The {@link Layer} object representing the layers's current evaluation results for the user. | ||
*/ | ||
getLayer(name, options) { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
const hash = (0, client_core_1.DJB2)(name); | ||
const { evaluation, details } = this._store.getLayer(hash); | ||
const layer = (0, client_core_1.makeLayer)(name, details, evaluation); | ||
const layer = (0, client_core_1._makeLayer)(name, details, evaluation); | ||
const overridden = (_b = (_a = this._overrideAdapter) === null || _a === void 0 ? void 0 : _a.getLayerOverride) === null || _b === void 0 ? void 0 : _b.call(_a, layer, this._user, options); | ||
const result = overridden !== null && overridden !== void 0 ? overridden : layer; | ||
const result = (0, client_core_1._mergeOverride)(layer, overridden, (_c = overridden === null || overridden === void 0 ? void 0 : overridden.__value) !== null && _c !== void 0 ? _c : layer.__value, (param) => { | ||
this._enqueueExposure(name, (0, client_core_1.createLayerParameterExposure)(this._user, result, param), options); | ||
}); | ||
this._emit({ name: 'layer_evaluation', layer: result }); | ||
return Object.assign(Object.assign({}, result), { getValue: (param) => { | ||
var _a; | ||
if (!(param in result._value)) { | ||
return null; | ||
} | ||
const exposure = (0, client_core_1.createLayerParameterExposure)(this._user, result, param); | ||
this._enqueueExposure(name, exposure, options); | ||
return (_a = result._value[param]) !== null && _a !== void 0 ? _a : null; | ||
} }); | ||
return result; | ||
} | ||
logEvent(event) { | ||
/** | ||
* Logs an event to the internal logging system. This function allows logging by either passing a fully formed event object or by specifying the event name with optional value and metadata. | ||
* | ||
* @param {StatsigEvent|string} eventOrName - The event object conforming to the StatsigEvent interface, or the name of the event as a string. | ||
* @param {string|number} value - Optional. The value associated with the event, which can be a string or a number. This parameter is ignored if the first parameter is a StatsigEvent object. | ||
* @param {Record<string, string>} metadata - Optional. A key-value record containing metadata about the event. This is also ignored if the first parameter is an event object. | ||
*/ | ||
logEvent(eventOrName, value, metadata) { | ||
const event = typeof eventOrName === 'string' | ||
? { | ||
eventName: eventOrName, | ||
value, | ||
metadata, | ||
} | ||
: eventOrName; | ||
this._logger.enqueue(Object.assign(Object.assign({}, event), { user: this._user, time: Date.now() })); | ||
@@ -150,3 +254,3 @@ } | ||
const { evaluation, details } = this._store.getConfig(hash); | ||
const config = (0, client_core_1.makeDynamicConfig)(name, details, evaluation); | ||
const config = (0, client_core_1._makeDynamicConfig)(name, details, evaluation); | ||
const overridden = kind === 'experiment' | ||
@@ -153,0 +257,0 @@ ? (_b = (_a = this._overrideAdapter) === null || _a === void 0 ? void 0 : _a.getExperimentOverride) === null || _b === void 0 ? void 0 : _b.call(_a, config, this._user, options) |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
326819
692
21
7
+ Added@statsig/client-core@0.0.1-beta.26(transitive)
- Removed@statsig/client-core@0.0.1-beta.25(transitive)