From 769239a79f29ffac8f4148255e26b8fcf4ddb09b Mon Sep 17 00:00:00 2001 From: Daniel <95646168+daniel-statsig@users.noreply.github.com> Date: Fri, 22 Mar 2024 11:19:10 +1100 Subject: [PATCH] Better rn samples (#84) * chore: add shared RN sample lib * feat: add more samples for expo --- packages/client-core/src/DataAdapterCore.ts | 7 +- .../client-core/src/StatsigDataAdapter.ts | 4 +- .../src/NoopEvaluationsClient.ts | 2 +- .../src/AsyncStorageWarming.ts | 2 +- samples/expo/src/app/App.tsx | 43 +- samples/expo/src/app/__tests__/App.test.tsx | 6 +- samples/rn-shared/.babelrc.js | 23 + samples/rn-shared/.eslintrc.json | 18 + samples/rn-shared/jest.config.ts | 22 + samples/rn-shared/project.json | 19 + samples/rn-shared/src/Constants.ts | 2 + samples/rn-shared/src/DummyAuthService.ts | 44 ++ samples/rn-shared/src/SampleListView.tsx | 56 ++ samples/rn-shared/src/dcs_response.json | 484 ++++++++++++++++++ .../src/examples/RNBootstrapExample.tsx | 56 ++ .../rn-shared/src/examples/RNLoginExample.tsx | 97 ++++ samples/rn-shared/src/index.ts | 1 + samples/rn-shared/test-setup.ts | 1 + samples/rn-shared/tsconfig.json | 19 + samples/rn-shared/tsconfig.lib.json | 14 + samples/rn-shared/tsconfig.spec.json | 20 + .../src/assets/statsig-js-client.min.js | 2 +- .../statsig-js-on-device-eval-client.min.js | 2 +- samples/web-minified/src/main.js | 6 + tsconfig.base.json | 1 + 25 files changed, 897 insertions(+), 54 deletions(-) create mode 100644 samples/rn-shared/.babelrc.js create mode 100644 samples/rn-shared/.eslintrc.json create mode 100644 samples/rn-shared/jest.config.ts create mode 100644 samples/rn-shared/project.json create mode 100644 samples/rn-shared/src/Constants.ts create mode 100644 samples/rn-shared/src/DummyAuthService.ts create mode 100644 samples/rn-shared/src/SampleListView.tsx create mode 100644 samples/rn-shared/src/dcs_response.json create mode 100644 samples/rn-shared/src/examples/RNBootstrapExample.tsx create mode 100644 samples/rn-shared/src/examples/RNLoginExample.tsx create mode 100644 samples/rn-shared/src/index.ts create mode 100644 samples/rn-shared/test-setup.ts create mode 100644 samples/rn-shared/tsconfig.json create mode 100644 samples/rn-shared/tsconfig.lib.json create mode 100644 samples/rn-shared/tsconfig.spec.json diff --git a/packages/client-core/src/DataAdapterCore.ts b/packages/client-core/src/DataAdapterCore.ts index ccb0a570..dfc15fe8 100644 --- a/packages/client-core/src/DataAdapterCore.ts +++ b/packages/client-core/src/DataAdapterCore.ts @@ -95,10 +95,10 @@ export abstract class DataAdapterCore { /** * (Internal Use Only) - Used by \@statsig/react-native-bindings to prime the cache from AsyncStorage * - * @param {Record} cache The values to set for _inMemoryCache + * @param {Record} cache The values to merge into _inMemoryCache */ - __setInMemoryCache(cache: Record): void { - this._inMemoryCache = cache; + __primeInMemoryCache(cache: Record): void { + this._inMemoryCache = { ...this._inMemoryCache, ...cache }; } protected abstract _fetchFromNetwork( @@ -111,7 +111,6 @@ export abstract class DataAdapterCore { user?: StatsigUser, ): Promise { const latest = await this._fetchFromNetwork(current, user); - if (!latest) { Log.debug('No response returned for latest value'); return null; diff --git a/packages/client-core/src/StatsigDataAdapter.ts b/packages/client-core/src/StatsigDataAdapter.ts index 3188bc72..fa7b30b8 100644 --- a/packages/client-core/src/StatsigDataAdapter.ts +++ b/packages/client-core/src/StatsigDataAdapter.ts @@ -45,9 +45,9 @@ type DataAdapterCommon = { /** * (Internal Use Only) - Used by \@statsig/react-native-bindings to prime the cache from AsyncStorage * - * @param {Record} cache The values to set for _inMemoryCache + * @param {Record} cache The values to merge into _inMemoryCache */ - readonly __setInMemoryCache: ( + readonly __primeInMemoryCache: ( cache: Record, ) => void; }; diff --git a/packages/react-bindings/src/NoopEvaluationsClient.ts b/packages/react-bindings/src/NoopEvaluationsClient.ts index 27e6e7aa..bc6c5ba2 100644 --- a/packages/react-bindings/src/NoopEvaluationsClient.ts +++ b/packages/react-bindings/src/NoopEvaluationsClient.ts @@ -36,7 +36,7 @@ const _defaultEvaluation = (type: 'gate' | 'config' | 'layer') => { }; const _noopDataAdapter: EvaluationsDataAdapter & SpecsDataAdapter = { - __setInMemoryCache: _noop, + __primeInMemoryCache: _noop, attach: _noop, getDataSync: () => null, getDataAsync: () => Promise.resolve(null), diff --git a/packages/react-native-bindings/src/AsyncStorageWarming.ts b/packages/react-native-bindings/src/AsyncStorageWarming.ts index f8d3220c..537b4b88 100644 --- a/packages/react-native-bindings/src/AsyncStorageWarming.ts +++ b/packages/react-native-bindings/src/AsyncStorageWarming.ts @@ -48,5 +48,5 @@ async function _loadCacheAsync( }), ); - adapter.__setInMemoryCache(results); + adapter.__primeInMemoryCache(results); } diff --git a/samples/expo/src/app/App.tsx b/samples/expo/src/app/App.tsx index a9b317c6..de419ec3 100644 --- a/samples/expo/src/app/App.tsx +++ b/samples/expo/src/app/App.tsx @@ -1,45 +1,6 @@ import React from 'react'; -import { SafeAreaView, StatusBar, Text } from 'react-native'; - -import { LogLevel } from '@statsig/client-core'; -import { - StatsigProviderExpo, - useGate, - warmCachingFromAsyncStorage, -} from '@statsig/expo-bindings'; -import { StatsigOnDeviceEvalClient } from '@statsig/js-on-device-eval-client'; - -export const DEMO_CLIENT_KEY = - 'client-rfLvYGag3eyU0jYW5zcIJTQip7GXxSrhOFN69IGMjvq'; - -const client = new StatsigOnDeviceEvalClient(DEMO_CLIENT_KEY, { - logLevel: LogLevel.Debug, -}); -const warming = warmCachingFromAsyncStorage(client); - -function Content(): React.ReactNode { - const gate = useGate('a_gate', { user: { userID: 'a-user' } }); - - return ( - <> - - - - a_gate: {gate.value ? 'Pass' : 'Fail'} ({gate.details.reason}) - - - - ); -} +import { SampleListView } from 'statsig-rn-shared'; export default function App(): React.ReactNode { - return ( - - - - ); + return ; } diff --git a/samples/expo/src/app/__tests__/App.test.tsx b/samples/expo/src/app/__tests__/App.test.tsx index 78a947e9..84e3520c 100644 --- a/samples/expo/src/app/__tests__/App.test.tsx +++ b/samples/expo/src/app/__tests__/App.test.tsx @@ -42,10 +42,10 @@ describe('App', () => { test( 'renders correctly', async () => { - const { getByTestId } = render(); + const { getByText } = render(); - const result = await waitFor(() => getByTestId('test-text')); - expect(result).toHaveTextContent('a_gate: Pass'); + const result = await waitFor(() => getByText('Bootstrapping')); + expect(result).toBeDefined(); }, 1000 * 10, ); diff --git a/samples/rn-shared/.babelrc.js b/samples/rn-shared/.babelrc.js new file mode 100644 index 00000000..886b6c56 --- /dev/null +++ b/samples/rn-shared/.babelrc.js @@ -0,0 +1,23 @@ +module.exports = function (api) { + api.cache(true); + + return { + presets: [ + [ + '@nx/react/babel', + { + runtime: 'automatic', + useBuiltIns: 'usage', + }, + ], + ], + plugins: [], + env: { + test: { + presets: [ + ['module:@react-native/babel-preset', { useTransformReactJSX: true }], + ], + }, + }, + }; +}; diff --git a/samples/rn-shared/.eslintrc.json b/samples/rn-shared/.eslintrc.json new file mode 100644 index 00000000..8beb09df --- /dev/null +++ b/samples/rn-shared/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["plugin:@nx/react", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*", "public", ".cache", "node_modules"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/samples/rn-shared/jest.config.ts b/samples/rn-shared/jest.config.ts new file mode 100644 index 00000000..a2488ac0 --- /dev/null +++ b/samples/rn-shared/jest.config.ts @@ -0,0 +1,22 @@ +module.exports = { + displayName: 'rn-shared', + preset: 'react-native', + resolver: '@nx/jest/plugins/resolver', + moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'], + setupFilesAfterEnv: ['/test-setup.ts'], + moduleNameMapper: { + '\\.svg$': '@nx/react-native/plugins/jest/svg-mock', + }, + transform: { + '^.+.(js|ts|tsx)$': [ + 'babel-jest', + { + configFile: __dirname + '/.babelrc.js', + }, + ], + '^.+.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve( + 'react-native/jest/assetFileTransformer.js', + ), + }, + coverageDirectory: '../../coverage/samples/rn-shared', +}; diff --git a/samples/rn-shared/project.json b/samples/rn-shared/project.json new file mode 100644 index 00000000..3144b48e --- /dev/null +++ b/samples/rn-shared/project.json @@ -0,0 +1,19 @@ +{ + "name": "rn-shared", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "samples/rn-shared/src", + "projectType": "library", + "tags": [], + "targets": { + "lint": { + "executor": "@nx/eslint:lint" + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "samples/rn-shared/jest.config.ts" + } + } + } +} diff --git a/samples/rn-shared/src/Constants.ts b/samples/rn-shared/src/Constants.ts new file mode 100644 index 00000000..36199b3e --- /dev/null +++ b/samples/rn-shared/src/Constants.ts @@ -0,0 +1,2 @@ +export const DEMO_CLIENT_KEY = + 'client-rfLvYGag3eyU0jYW5zcIJTQip7GXxSrhOFN69IGMjvq'; diff --git a/samples/rn-shared/src/DummyAuthService.ts b/samples/rn-shared/src/DummyAuthService.ts new file mode 100644 index 00000000..9673cd9c --- /dev/null +++ b/samples/rn-shared/src/DummyAuthService.ts @@ -0,0 +1,44 @@ +import { DJB2, StatsigUser, Storage } from '@statsig/client-core'; + +type LoginFormData = { + email: string; + password: string; +}; + +type AuthResult = { + authorizedUser: StatsigUser; +}; + +const storageKey = 'fake_logged_in_user'; + +const service = { + login: async (data: LoginFormData): Promise => { + await new Promise((r) => setTimeout(r, 1000)); + const userID = `user-${DJB2(data.email)}`; + const user = { userID, email: data.email }; + await Storage.setItem(storageKey, JSON.stringify(user)); + + const authorizedUser = user; + + return { + authorizedUser, // An authenticated StatsigUser object + }; + }, + + getUser: async (): Promise => { + const data = await Storage.getItem(storageKey); + if (!data) { + return { userID: '' }; + } + + return JSON.parse(data) as StatsigUser; + }, + logout: (): void => { + Storage.removeItem(storageKey).catch((e) => { + // eslint-disable-next-line no-console + console.error(e); + }); + }, +}; + +export const AuthService = service; diff --git a/samples/rn-shared/src/SampleListView.tsx b/samples/rn-shared/src/SampleListView.tsx new file mode 100644 index 00000000..c70910b8 --- /dev/null +++ b/samples/rn-shared/src/SampleListView.tsx @@ -0,0 +1,56 @@ +import React, { useState } from 'react'; +import { + FlatList, + SafeAreaView, + StatusBar, + Text, + TouchableOpacity, +} from 'react-native'; + +import { RNBootstrapExample } from './examples/RNBootstrapExample'; +import { RNLoginExample } from './examples/RNLoginExample'; + +const fruits = [ + { name: 'Bootstrapping' }, + { name: 'Login Flow' }, + { name: 'Login Flo2w' }, +]; + +export function SampleListView(): React.ReactNode { + const [selectedExample, setSelectedExample] = useState(null); + + const onBackPress = () => setSelectedExample(null); + + return ( + <> + + + {(() => { + switch (selectedExample) { + case 'Bootstrapping': + return ; + + case 'Login Flow': + return ; + + default: + return ( + ( + setSelectedExample(args.item.name)} + > + {args.item.name} + + )} + keyExtractor={(item) => item.name.toString()} + /> + ); + } + })()} + + + ); +} diff --git a/samples/rn-shared/src/dcs_response.json b/samples/rn-shared/src/dcs_response.json new file mode 100644 index 00000000..a68dc625 --- /dev/null +++ b/samples/rn-shared/src/dcs_response.json @@ -0,0 +1,484 @@ +{ + "__note": "Sample Response using the SDK Demo project", + "dynamic_configs": [ + { + "name": "a_dynamic_config", + "type": "dynamic_config", + "salt": "5519338f-1c08-4673-b833-9e06ef7bfe3a", + "enabled": true, + "defaultValue": { + "red": "#FF0000", + "blue": "#00FF00", + "green": "#0000FF" + }, + "rules": [], + "isDeviceBased": false, + "idType": "userID", + "entity": "dynamic_config" + }, + { + "name": "another_experiment", + "type": "dynamic_config", + "salt": "a37c5e3d-f2f1-407e-9f91-5669de5de0fd", + "enabled": true, + "defaultValue": {}, + "rules": [ + { + "name": "layerAssignment", + "groupName": "Layer Assignment", + "passPercentage": 100, + "conditions": [ + { + "type": "user_bucket", + "targetValue": [-1], + "operator": "any", + "field": null, + "additionalValues": { + "salt": "daa8ca46-c742-4869-83be-43e00c59f704" + }, + "isDeviceBased": false, + "idType": "userID" + } + ], + "returnValue": {}, + "id": "layerAssignment", + "salt": "", + "isDeviceBased": false, + "idType": "userID" + }, + { + "name": "3cOnAalaaO5dOXqAvGjLX9", + "groupName": "Control", + "passPercentage": 100, + "conditions": [ + { + "type": "user_bucket", + "targetValue": 500, + "operator": "lt", + "field": null, + "additionalValues": { + "salt": "a37c5e3d-f2f1-407e-9f91-5669de5de0fd" + }, + "isDeviceBased": false, + "idType": "userID" + } + ], + "returnValue": { + "a_string": "control", + "a_bool": false + }, + "id": "3cOnAalaaO5dOXqAvGjLX9", + "salt": "3cOnAalaaO5dOXqAvGjLX9", + "isDeviceBased": false, + "idType": "userID", + "isExperimentGroup": true + }, + { + "name": "3cOnAc0cD6eI8mYw6Ofpgb", + "groupName": "Test", + "passPercentage": 100, + "conditions": [ + { + "type": "user_bucket", + "targetValue": 1000, + "operator": "lt", + "field": null, + "additionalValues": { + "salt": "a37c5e3d-f2f1-407e-9f91-5669de5de0fd" + }, + "isDeviceBased": false, + "idType": "userID" + } + ], + "returnValue": { + "a_string": "test", + "a_bool": true + }, + "id": "3cOnAc0cD6eI8mYw6Ofpgb", + "salt": "3cOnAc0cD6eI8mYw6Ofpgb", + "isDeviceBased": false, + "idType": "userID", + "isExperimentGroup": true + } + ], + "isDeviceBased": false, + "idType": "userID", + "entity": "experiment", + "isActive": true, + "hasSharedParams": false + }, + { + "name": "three_groups", + "type": "dynamic_config", + "salt": "19ad889d-f4b5-4740-bcb2-72ff1896d438", + "enabled": true, + "defaultValue": {}, + "rules": [ + { + "name": "layerAssignment", + "groupName": "Layer Assignment", + "passPercentage": 100, + "conditions": [ + { + "type": "user_bucket", + "targetValue": [-1], + "operator": "any", + "field": null, + "additionalValues": { + "salt": "87b91fb6-6d25-4f8e-a53c-73e49a72560f" + }, + "isDeviceBased": false, + "idType": "userID" + } + ], + "returnValue": {}, + "id": "layerAssignment", + "salt": "", + "isDeviceBased": false, + "idType": "userID" + }, + { + "name": "1J6QLlETnyrV1XE2um2XiS", + "groupName": "Control", + "passPercentage": 100, + "conditions": [ + { + "type": "user_bucket", + "targetValue": 334, + "operator": "lt", + "field": null, + "additionalValues": { + "salt": "19ad889d-f4b5-4740-bcb2-72ff1896d438" + }, + "isDeviceBased": false, + "idType": "userID" + } + ], + "returnValue": { + "a_string": "c" + }, + "id": "1J6QLlETnyrV1XE2um2XiS", + "salt": "1J6QLlETnyrV1XE2um2XiS", + "isDeviceBased": false, + "idType": "userID", + "isExperimentGroup": true + }, + { + "name": "1J6QLnjVPQBplnbY5tYABU", + "groupName": "Test", + "passPercentage": 100, + "conditions": [ + { + "type": "user_bucket", + "targetValue": 667, + "operator": "lt", + "field": null, + "additionalValues": { + "salt": "19ad889d-f4b5-4740-bcb2-72ff1896d438" + }, + "isDeviceBased": false, + "idType": "userID" + } + ], + "returnValue": { + "a_string": "t" + }, + "id": "1J6QLnjVPQBplnbY5tYABU", + "salt": "1J6QLnjVPQBplnbY5tYABU", + "isDeviceBased": false, + "idType": "userID", + "isExperimentGroup": true + }, + { + "name": "22NwxasoExmyIpd8Iy3m1o", + "groupName": "Test #2", + "passPercentage": 100, + "conditions": [ + { + "type": "user_bucket", + "targetValue": 1000, + "operator": "lt", + "field": null, + "additionalValues": { + "salt": "19ad889d-f4b5-4740-bcb2-72ff1896d438" + }, + "isDeviceBased": false, + "idType": "userID" + } + ], + "returnValue": { + "a_string": "t2" + }, + "id": "22NwxasoExmyIpd8Iy3m1o", + "salt": "22NwxasoExmyIpd8Iy3m1o", + "isDeviceBased": false, + "idType": "userID", + "isExperimentGroup": true + } + ], + "isDeviceBased": false, + "idType": "userID", + "entity": "experiment", + "isActive": true, + "hasSharedParams": false + }, + { + "name": "an_experiment", + "type": "dynamic_config", + "salt": "f5c1b26a-6374-4f8b-8b9b-de2292019ecd", + "enabled": true, + "defaultValue": { + "a_string": "Layer Default Value" + }, + "rules": [ + { + "name": "layerAssignment", + "groupName": "Layer Assignment", + "passPercentage": 100, + "conditions": [ + { + "type": "user_bucket", + "targetValue": [-1], + "operator": "any", + "field": null, + "additionalValues": { + "salt": "3269e41c-4c15-4da2-a8d3-85d01895b887" + }, + "isDeviceBased": false, + "idType": "userID" + } + ], + "returnValue": { + "a_string": "Layer Default Value" + }, + "id": "layerAssignment", + "salt": "", + "isDeviceBased": false, + "idType": "userID" + }, + { + "name": "49CGlRW56QYlkNSNzhUM2y", + "groupName": "Control", + "passPercentage": 100, + "conditions": [ + { + "type": "user_bucket", + "targetValue": 500, + "operator": "lt", + "field": null, + "additionalValues": { + "salt": "f5c1b26a-6374-4f8b-8b9b-de2292019ecd" + }, + "isDeviceBased": false, + "idType": "userID" + } + ], + "returnValue": { + "a_string": "Experiment Control Value" + }, + "id": "49CGlRW56QYlkNSNzhUM2y", + "salt": "49CGlRW56QYlkNSNzhUM2y", + "isDeviceBased": false, + "idType": "userID", + "isExperimentGroup": true + }, + { + "name": "49CGlTB7z97PEdqJapQplA", + "groupName": "Test", + "passPercentage": 100, + "conditions": [ + { + "type": "user_bucket", + "targetValue": 1000, + "operator": "lt", + "field": null, + "additionalValues": { + "salt": "f5c1b26a-6374-4f8b-8b9b-de2292019ecd" + }, + "isDeviceBased": false, + "idType": "userID" + } + ], + "returnValue": { + "a_string": "Experiment Test Value" + }, + "id": "49CGlTB7z97PEdqJapQplA", + "salt": "49CGlTB7z97PEdqJapQplA", + "isDeviceBased": false, + "idType": "userID", + "isExperimentGroup": true + } + ], + "isDeviceBased": false, + "idType": "userID", + "entity": "experiment", + "isActive": true, + "hasSharedParams": true, + "explicitParameters": ["a_string"] + } + ], + "feature_gates": [ + { + "name": "third_gate", + "type": "feature_gate", + "salt": "f1261590-d48e-44b4-8f87-4eb9988d1174", + "enabled": true, + "defaultValue": false, + "rules": [ + { + "name": "2XsjGYU4EC4c28B86AMCMx", + "groupName": "Specific User", + "passPercentage": 100, + "conditions": [ + { + "type": "user_field", + "targetValue": ["1", "2", "3", "4", "5"], + "operator": "any", + "field": "userID", + "additionalValues": {}, + "isDeviceBased": false, + "idType": "userID" + } + ], + "returnValue": true, + "id": "2XsjGYU4EC4c28B86AMCMx", + "salt": "593d1d17-e7f5-4a33-ae3c-f7f300617945", + "isDeviceBased": false, + "idType": "userID" + } + ], + "isDeviceBased": false, + "idType": "userID", + "entity": "feature_gate" + }, + { + "name": "partial_gate", + "type": "feature_gate", + "salt": "62afcf6d-2879-4a0b-8ffd-7b482d7da05d", + "enabled": true, + "defaultValue": false, + "rules": [ + { + "name": "59nkHdlmIytrqNG9iT7gkd:50.00:2", + "groupName": "50/50", + "passPercentage": 50, + "conditions": [ + { + "type": "public", + "targetValue": null, + "operator": null, + "field": null, + "additionalValues": {}, + "isDeviceBased": false, + "idType": "userID" + } + ], + "returnValue": true, + "id": "59nkHdlmIytrqNG9iT7gkd:50.00:2", + "salt": "235f34bc-3067-4947-a617-29bbbb1c5f62", + "isDeviceBased": false, + "idType": "userID" + } + ], + "isDeviceBased": false, + "idType": "userID", + "entity": "feature_gate" + }, + { + "name": "a_gate", + "type": "feature_gate", + "salt": "6ca5e892-2dd3-4607-8742-7c48fe92d265", + "enabled": true, + "defaultValue": false, + "rules": [ + { + "name": "2QWhVkWdUEXR6Q3KYgV73O", + "groupName": "First gate rule", + "passPercentage": 100, + "conditions": [ + { + "type": "public", + "targetValue": null, + "operator": null, + "field": null, + "additionalValues": {}, + "isDeviceBased": false, + "idType": "userID" + } + ], + "returnValue": true, + "id": "2QWhVkWdUEXR6Q3KYgV73O", + "salt": "df505804-d3a5-48cb-949a-44fa378426d4", + "isDeviceBased": false, + "idType": "userID" + } + ], + "isDeviceBased": false, + "idType": "userID", + "entity": "feature_gate" + } + ], + "layers": { + "a_layer": ["an_experiment"] + }, + "layer_configs": [ + { + "name": "a_layer", + "type": "dynamic_config", + "salt": "3269e41c-4c15-4da2-a8d3-85d01895b887", + "enabled": true, + "defaultValue": { + "a_string": "Layer Default Value" + }, + "rules": [ + { + "name": "experimentAssignment", + "groupName": "Experiment Assignment", + "passPercentage": 100, + "conditions": [ + { + "type": "public", + "targetValue": null, + "operator": null, + "field": null, + "additionalValues": { + "salt": "3269e41c-4c15-4da2-a8d3-85d01895b887" + }, + "isDeviceBased": false, + "idType": "userID" + } + ], + "returnValue": { + "a_string": "Layer Default Value" + }, + "id": "experimentAssignment", + "salt": "", + "isDeviceBased": false, + "idType": "userID", + "configDelegate": "an_experiment" + } + ], + "isDeviceBased": false, + "idType": "userID", + "entity": "layer" + } + ], + "has_updates": true, + "time": 1705543730484, + "company_id": "2etz0PtUkhGsJfH0mR6whu", + "id_lists": {}, + "diagnostics": { + "initialize": 10000, + "dcs": 1000, + "download_config_specs": 1000, + "idlist": 100, + "get_id_list": 100, + "get_id_list_sources": 100, + "log": 100, + "log_event": 100, + "api_call": 100 + }, + "sdk_flags": { + "stop_log_event_compression": true + } +} diff --git a/samples/rn-shared/src/examples/RNBootstrapExample.tsx b/samples/rn-shared/src/examples/RNBootstrapExample.tsx new file mode 100644 index 00000000..0e1e17da --- /dev/null +++ b/samples/rn-shared/src/examples/RNBootstrapExample.tsx @@ -0,0 +1,56 @@ +import { useMemo } from 'react'; +import { Button, Text, View } from 'react-native'; + +import { Storage } from '@statsig/client-core'; +import { StatsigOnDeviceEvalClient } from '@statsig/js-on-device-eval-client'; +import { + StatsigProviderRN, + useGate, + warmCachingFromAsyncStorage, +} from '@statsig/react-native-bindings'; + +import { DEMO_CLIENT_KEY } from '../Constants'; +import BootstrapValues from '../dcs_response.json'; + +type Props = { + onBackPress: () => void; +}; + +function Content() { + const gate = useGate('a_gate', { user: { userID: 'a-user' } }); + return ( + + a_gate: {gate.value ? 'Pass' : 'Fail'} ({gate.details.reason}){' '} + + ); +} + +export function RNBootstrapExample({ onBackPress }: Props): React.ReactNode { + const onClearCachePress = () => { + Storage.getAllKeys() + .then((keys) => keys.map((key) => Storage.removeItem(key))) + .catch((e) => { + // eslint-disable-next-line no-console + console.error(e); + }); + }; + + const { client, warming } = useMemo(() => { + const client = new StatsigOnDeviceEvalClient(DEMO_CLIENT_KEY); + client.dataAdapter.setData(JSON.stringify(BootstrapValues)); + + const warming = warmCachingFromAsyncStorage(client); + + return { client, warming }; + }, []); + + return ( + + + + + + + + ); +} diff --git a/samples/rn-shared/src/examples/RNLoginExample.tsx b/samples/rn-shared/src/examples/RNLoginExample.tsx new file mode 100644 index 00000000..43ea41ee --- /dev/null +++ b/samples/rn-shared/src/examples/RNLoginExample.tsx @@ -0,0 +1,97 @@ +import { useEffect, useMemo, useState } from 'react'; +import { Button, Text, TextInput, View } from 'react-native'; + +import { StatsigClient } from '@statsig/js-client'; +import { useStatsigClient } from '@statsig/react-bindings'; +import { + StatsigProviderRN, + useGate, + warmCachingFromAsyncStorage, +} from '@statsig/react-native-bindings'; + +import { DEMO_CLIENT_KEY } from '../Constants'; +import { AuthService } from '../DummyAuthService'; + +type Props = { + onBackPress: () => void; +}; + +function Content() { + const gate = useGate('third_gate'); // gate passes with non-empty email + const client = useStatsigClient(); + + return ( + <> + + third_gate: {gate.value ? 'Pass' : 'Fail'} ({gate.details.reason}) + + {JSON.stringify(client.getCurrentUser())} + + + ); +} + +function LoginForm({ onSubmit }: { onSubmit: (email: string) => void }) { + const [email, setEmail] = useState(''); + + return ( + + + setEmail(text)} + /> + + + + ); +} + +export function RNLoginExample({ onBackPress }: Props): React.ReactNode { + const { client, warming } = useMemo(() => { + const client = new StatsigClient(DEMO_CLIENT_KEY, { userID: '' }); + const warming = warmCachingFromAsyncStorage(client); + + return { client, warming }; + }, []); + + useEffect(() => { + AuthService.getUser() + .then((u) => client.updateUserSync(u)) + .catch((e) => { + // eslint-disable-next-line no-console + console.error(e); + }); + }, [client]); + + return ( + + + + { + AuthService.login({ email, password: '' }) + .then((result) => { + return client.updateUserAsync(result.authorizedUser); + }) + .catch((e) => { + // eslint-disable-next-line no-console + console.error(e); + }); + }} + /> + + + + ); +} diff --git a/samples/rn-shared/src/index.ts b/samples/rn-shared/src/index.ts new file mode 100644 index 00000000..a3213d5e --- /dev/null +++ b/samples/rn-shared/src/index.ts @@ -0,0 +1 @@ +export * from './SampleListView'; diff --git a/samples/rn-shared/test-setup.ts b/samples/rn-shared/test-setup.ts new file mode 100644 index 00000000..9f28ad21 --- /dev/null +++ b/samples/rn-shared/test-setup.ts @@ -0,0 +1 @@ +import '@testing-library/jest-native/extend-expect'; diff --git a/samples/rn-shared/tsconfig.json b/samples/rn-shared/tsconfig.json new file mode 100644 index 00000000..5ddb4122 --- /dev/null +++ b/samples/rn-shared/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "jsx": "react-jsx", + "allowJs": true, + "esModuleInterop": true, + "resolveJsonModule": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/samples/rn-shared/tsconfig.lib.json b/samples/rn-shared/tsconfig.lib.json new file mode 100644 index 00000000..4447ea9b --- /dev/null +++ b/samples/rn-shared/tsconfig.lib.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["node"] + }, + "exclude": [ + "jest.config.ts", + "src/**/*.spec.ts", + "src/**/*.spec.tsx", + "test-setup.ts" + ], + "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] +} diff --git a/samples/rn-shared/tsconfig.spec.json b/samples/rn-shared/tsconfig.spec.json new file mode 100644 index 00000000..26ef046a --- /dev/null +++ b/samples/rn-shared/tsconfig.spec.json @@ -0,0 +1,20 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "jest.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.test.tsx", + "src/**/*.spec.tsx", + "src/**/*.test.js", + "src/**/*.spec.js", + "src/**/*.test.jsx", + "src/**/*.spec.jsx", + "src/**/*.d.ts" + ] +} diff --git a/samples/web-minified/src/assets/statsig-js-client.min.js b/samples/web-minified/src/assets/statsig-js-client.min.js index 71e82e87..0b5d6cc9 100644 --- a/samples/web-minified/src/assets/statsig-js-client.min.js +++ b/samples/web-minified/src/assets/statsig-js-client.min.js @@ -1 +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.p(t))?(this.m(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.m(e,t),"Network"!==(null==t?void 0:t.source)&&"NetworkNotModified"!==(null==t?void 0:t.source)||(yield this.j(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.m(t,Object.assign(Object.assign({},e),{source:"Prefetch"}))})}setData(t,e){e=this._(e);this.m(e,{source:"Bootstrap",data:t,receivedAt:Date.now()})}__setInMemoryCache(t){this.h=t}O(n,i){return s(this,void 0,void 0,function*(){var t,e=yield this.S(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)})}N(){return null!=this.l?this.l:(o.Log.error(this.i+" is not attached to a Client"),"")}_(t){t=(0,l.getUserStorageKey)(this.N(),t);return`${u.DataAdapterCachePrefix}.${this.o}.`+t}m(t,e){var n=Object.entries(this.h);n.length<10||([n]=n.reduce((t,e)=>e[1]e[1]{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.M=new Set}capture(e,t,n){try{var i=t();return i&&i instanceof Promise?i.catch(t=>this.T(e,t,n)):i}catch(t){return this.T(e,t,n),null}}logError(t,e){this.T(t,e)}T(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.M.has(i)||(this.M.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.D=e,this.A=n,this.P=i,this.C=[],this.qt={},this.Kt={},this.F=!1,this.L=Date.now(),this.V=!0===(null==i?void 0:i.disableLogging),this.R=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.q(),n),this.Ft=(0,c.Lt)(null==i?void 0:i.logEventUrl,null==i?void 0:i.api,"/rgstr",h),this.Vt=(0,c.Lt)(null==i?void 0:i.logEventBeaconUrl,null==i?void 0:i.api,"/log_event_beacon",h),d.VisibilityChangeObserver.add(this),this.J()}setLoggingDisabled(t){this.V=t}enqueue(t){this.U(t)&&(this.Jt(t),this.B(),this.C.length>this.R)&&this.q()}incrementNonExposureCount(t){var e=null!=(e=this.Kt[t])?e:0;this.Kt[t]=e+1}reset(){this.qt={}}onVisibilityChanged(t){"background"===t&&this.q()}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.zt(),0!==this.C.length&&(t=this.C,this.C=[],yield this.W(t))})}B(){this.F||(this.F=!0,200this.q(),200)}U(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.qt[t],n=Date.now();if(e&&n-e<6e4)return!1;1e3{})}W(t){return i(this,void 0,void 0,function*(){if(this.V)this.Y(t);else try{(!d.VisibilityChangeObserver.isCurrentlyVisible()&&this.A.isBeaconSupported()?yield this.H(t):yield this.X(t)).success?this.D({name:"logs_flushed",events:t}):this.Y(t)}catch(t){s.Log.warn("Failed to flush events.")}})}X(e){return i(this,void 0,void 0,function*(){var t=yield this.A.post({sdkKey:this.l,data:{events:e},url:this.Ft,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)}})}H(t){return i(this,void 0,void 0,function*(){return{success:yield this.A.beacon({sdkKey:this.l,data:{events:t},url:this.Vt})}})}Y(t){for(;500{s.Log.warn("Unable to save failed logs to storage")})}J(){const e=this.Z();i(this,void 0,void 0,function*(){var t=yield(0,l.getObjectFromStorage)(e);t&&(yield l.Storage.removeItem(e),yield this.W(t))}).catch(()=>{s.Log.warn("Failed to flush stored logs")})}Z(){return"statsig.failed_logs."+(0,o.DJB2)(this.l)}Jt(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}}))}zt(){0!==Object.keys(this.Kt).length&&(this.Jt({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:Object.assign({},this.Kt)}}),this.Kt={})}}},832:(t,e)=>{function n(e){let n=0;for(let t=0;t>>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)))}},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.tt.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"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.D=e,this.et=null!=(e=null==t?void 0:t.networkTimeoutMs)?e:1e4}post(e){return o(this,void 0,void 0,function*(){var t=yield this.nt(e);return this.it(Object.assign({method:"POST",body:t},e))})}get(t){return o(this,void 0,void 0,function*(){return this.it(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=this.rt(n),e=yield this.nt(n);return navigator.sendBeacon(t,e)})}it(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.et}ms expired.`),this.et),l=this.rt(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.D)&&d.call(this,{name:"error",error:t}),v.Log.error(`A networking error occured during ${e} request to ${l}.`,n,t),null):this.it(Object.assign(Object.assign({},c),{retries:i-1}))}})}rt(t){var e=u.StatsigMetadataProvider.get(),e=Object.assign({k:t.sdkKey,st:e.sdkType,sv:e.sdkVersion,t:String(Date.now()),sid:s.SessionID.get(t.sdkKey)},t.params),e=Object.entries(e).map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e)).join("&");return t.url+(e?"?"+e:"")}nt(i){return o(this,void 0,void 0,function*(){var t=i["data"],e=yield r.StableID.get(i.sdkKey),n=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.ot(t=>{var e;return null!=(e=null==(e=t.getGateOverride)?void 0:e.call(t,n,i))?e:null})}getDynamicConfigOverride(n,i){return this.ot(t=>{var e;return null!=(e=null==(e=t.getDynamicConfigOverride)?void 0:e.call(t,n,i))?e:null})}ot(t){for(const n of this.providers){var e=t(n);if(e)return e}return null}}},612:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SessionID=void 0;const i=n(556),o={};e.SessionID={get:t=>(null==o[t]&&(o[t]=(0,i.getUUID)()),o[t])}},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:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigClientBase=void 0,n(496);const s=n(512),r=n(728),u=n(780),l=n(604),a=n(444);e.StatsigClientBase=class{constructor(t,e,n,i){this.l=t,this.loadingStatus="Uninitialized",this.ut={},null!=i&&i.disableStorage&&a.Storage.setDisabled(!0),null!=i&&i.overrideStableID&&l.StableID.setOverride(i.overrideStableID,t),u.Log.level=null!=(o=null==i?void 0:i.logLevel)?o:u.LogLevel.Warn,this.Pt=null!=(o=null==i?void 0:i.overrideAdapter)?o:null,this.lt=new r.EventLogger(t,this.tt.bind(this),n,i),this.u=new s.ErrorBoundary(t);var o,n=null!=(o=(__STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}).instances)?o:new Set;n.add(this),__STATSIG__.instances=n,this.dataAdapter=e,this.dataAdapter.attach(t,i)}updateRuntimeOptions(t){null!=t.disableLogging&&this.lt.setLoggingDisabled(t.disableLogging),null!=t.disableStorage&&a.Storage.setDisabled(t.disableStorage)}flush(){return this.lt.flush()}on(t,e){this.ut[t]||(this.ut[t]=[]),this.ut[t].push(e)}off(t,e){this.ut[t]&&-1!==(e=this.ut[t].indexOf(e))&&this.ut[t].splice(e,1)}tt(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.ut[e.name]&&this.ut[e.name].forEach(t=>n(t)),null!=(t=this.ut["*"])&&t.forEach(n)}ct(t,e){this.loadingStatus=t,this.tt({name:"values_updated",status:t,values:e})}dt(t,e,n){!0===(null==n?void 0:n.disableExposureLog)?this.lt.incrementNonExposureCount(t):this.lt.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.14",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,Et: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(){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{Object.defineProperty(e,"__esModule",{value:!0}),e.Lt=void 0,e.Lt=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.ht}static add(t){this.ut.push(t)}static remove(t){t=this.ut.indexOf(t);-1!==t&&this.ut.splice(t,1)}static notify(e){e!==this.ht&&(this.ht=e,this.ut.forEach(t=>t.onVisibilityChanged(e)))}}(e.VisibilityChangeObserver=n).ut=[],n.ht="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}}),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(780),e),o(n(104),e),o(n(188),e),o(n(264),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,Storage:u.Storage})},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(t){this.l=t,this.wt=null,this.xt="Uninitialized",this.Nt=0,this.It=0}reset(){this.wt=null,this.xt="Loading",this.Nt=0,this.It=0}finalize(){this.wt||(this.xt="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.Nt=e.time,this.It=t.receivedAt,this.xt=t.source,this.wt=e)}getGate(t){var e,t=null!=(e=null==(e=this.wt)?void 0:e.feature_gates[t])?e:null;return this.Ut(t)}getConfig(t){var e,t=null!=(e=null==(e=this.wt)?void 0:e.dynamic_configs[t])?e:null;return this.Ut(t)}getLayer(t){var e,t=null!=(e=null==(e=this.wt)?void 0:e.layer_configs[t])?e:null;return this.Ut(t)}Ut(t){return{evaluation:t,details:this._t(null==t)}}_t(t){return"Uninitialized"===this.xt||"NoValues"===this.xt?{reason:this.xt}:{reason:this.xt+":"+(t?"Unrecognized":"Recognized"),lcut:this.Nt,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.$t=(0,r.Lt)(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.Bt(n,t,e)})}Bt(e,n,i){var o;return s(this,void 0,void 0,function*(){var t=yield this.post({sdkKey:e,url:this.$t,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.Bt(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),s=n(536),u=n(400),l=n(364);n(807);class o extends r.StatsigClientBase{constructor(t,e,n=null){var i,o=new u.default(n,t=>{this.tt(t)});super(t,null!=(i=null==n?void 0:n.dataAdapter)?i:new l.StatsigEvaluationsDataAdapter,o,n),(0,r.monitorClass)(this.u,this),(0,r.monitorClass)(this.u,o),this.P=null!=n?n:{},this.vt=new s.default(t),this.A=o,this.Yt=e}initializeSync(){this.updateUserSync(this.Yt)}initializeAsync(){return this.updateUserAsync(this.Yt)}getCurrentUser(){return JSON.parse(JSON.stringify(this.Yt))}updateUserSync(t){this.Wt(t);t=this.dataAdapter.getDataSync(this.Yt);this.vt.setValuesFromDataAdapter(t),this.vt.finalize(),this.ct("Ready",t),this.Dt(null!=t?t:null,this.Yt)}updateUserAsync(n){return i(this,void 0,void 0,function*(){this.Wt(n);var t=this.Yt,e=this.dataAdapter.getDataSync(t);this.ct("Loading",e),this.vt.setValuesFromDataAdapter(e),e=yield this.dataAdapter.getDataAsync(e,t),t===this.Yt&&this.vt.setValuesFromDataAdapter(e),this.vt.finalize(),this.ct("Ready",e)})}shutdown(){return i(this,void 0,void 0,function*(){yield this.lt.shutdown()})}checkGate(t,e){return this.getFeatureGate(t,e).value}getFeatureGate(t,e){var n=(0,r.DJB2)(t),{evaluation:n,details:i}=this.vt.getGate(n),i=(0,r.makeFeatureGate)(t,i,n),o=null==(o=null==(n=this.Pt)?void 0:n.getGateOverride)?void 0:o.call(n,i,this.Yt,e),n=null!=o?o:i;return this.dt(t,(0,r.createGateExposure)(this.Yt,n),e),this.tt({name:"gate_evaluation",gate:n}),n}getDynamicConfig(t,e){t=this.kt("dynamic_config",t,e);return this.tt({name:"dynamic_config_evaluation",dynamicConfig:t}),t}getExperiment(t,e){t=this.kt("experiment",t,e);return this.tt({name:"experiment_evaluation",experiment:t}),t}getLayer(n,i){var t=(0,r.DJB2)(n),{evaluation:t,details:e}=this.vt.getLayer(t),e=(0,r.makeLayer)(n,e,t),o=null==(o=null==(t=this.Pt)?void 0:t.getLayerOverride)?void 0:o.call(t,e,this.Yt,i);const s=null!=o?o:e;return this.tt({name:"layer_evaluation",layer:s}),Object.assign(Object.assign({},s),{getValue:t=>{var e;return t in s.Et&&(e=(0,r.createLayerParameterExposure)(this.Yt,s,t),this.dt(n,e,i),null!=(e=s.Et[t]))?e:null}})}logEvent(t){this.lt.enqueue(Object.assign(Object.assign({},t),{user:this.Yt,time:Date.now()}))}Dt(t,e){this.dataAdapter.getDataAsync(t,e).catch(t=>{r.Log.error("An error occurred after update.",t)})}Wt(t){this.lt.reset(),this.vt.reset(),this.Yt=(0,r.normalizeUser)(t,this.P.environment)}kt(t,e,n){var i=(0,r.DJB2)(e),{evaluation:i,details:o}=this.vt.getConfig(i),o=(0,r.makeDynamicConfig)(e,o,i),i="experiment"===t?null==(t=null==(i=this.Pt)?void 0:i.getExperimentOverride)?void 0:t.call(i,o,this.Yt,n):null==(i=null==(t=this.Pt)?void 0:t.getDynamicConfigOverride)?void 0:i.call(t,o,this.Yt,n),t=null!=i?i:o;return this.dt(e,(0,r.createConfigExposure)(this.Yt,t),n),t}}e.default=o},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.A=null}attach(t,e){super.attach(t,e),this.A=new s.default(null!=e?e:{})}S(e,n){var i;return o(this,void 0,void 0,function*(){var t=yield null==(i=this.A)?void 0:i.fetchEvaluations(this.N(),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})}},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,s=o(520);s.default;const r=o(364);o(807),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{StatsigEvaluationsDataAdapter:r.StatsigEvaluationsDataAdapter,StatsigClient:s.default}),e.default=__STATSIG__}return t.default})()); \ No newline at end of file +!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 console.log("get",t,this.h),e||((e=this.p(t))?(this.m(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.m(e,t),"Network"!==(null==t?void 0:t.source)&&"NetworkNotModified"!==(null==t?void 0:t.source)||(yield this.j(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.m(t,Object.assign(Object.assign({},e),{source:"Prefetch"}))})}setData(t,e){e=this._(e);this.m(e,{source:"Bootstrap",data:t,receivedAt:Date.now()}),console.log("set",e,this.h)}__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.S(n,i);return console.log("DA Fetch"),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)})}N(){return null!=this.l?this.l:(o.Log.error(this.i+" is not attached to a Client"),"")}_(t){t=(0,l.getUserStorageKey)(this.N(),t);return`${u.DataAdapterCachePrefix}.${this.o}.`+t}m(t,e){var n=Object.entries(this.h);n.length<10||([n]=n.reduce((t,e)=>e[1]e[1]{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.M=new Set}capture(e,t,n){try{var i=t();return i&&i instanceof Promise?i.catch(t=>this.T(e,t,n)):i}catch(t){return this.T(e,t,n),null}}logError(t,e){this.T(t,e)}T(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.M.has(i)||(this.M.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.D=e,this.A=n,this.P=i,this.C=[],this.qt={},this.Kt={},this.F=!1,this.L=Date.now(),this.V=!0===(null==i?void 0:i.disableLogging),this.R=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.q(),n),this.Ft=(0,c.Lt)(null==i?void 0:i.logEventUrl,null==i?void 0:i.api,"/rgstr",h),this.Vt=(0,c.Lt)(null==i?void 0:i.logEventBeaconUrl,null==i?void 0:i.api,"/log_event_beacon",h),d.VisibilityChangeObserver.add(this),this.J()}setLoggingDisabled(t){this.V=t}enqueue(t){this.U(t)&&(this.Jt(t),this.B(),this.C.length>this.R)&&this.q()}incrementNonExposureCount(t){var e=null!=(e=this.Kt[t])?e:0;this.Kt[t]=e+1}reset(){this.qt={}}onVisibilityChanged(t){"background"===t&&this.q()}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.zt(),0!==this.C.length&&(t=this.C,this.C=[],yield this.W(t))})}B(){this.F||(this.F=!0,200this.q(),200)}U(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.qt[t],n=Date.now();if(e&&n-e<6e4)return!1;1e3{})}W(t){return i(this,void 0,void 0,function*(){if(this.V)this.Y(t);else try{(!d.VisibilityChangeObserver.isCurrentlyVisible()&&this.A.isBeaconSupported()?yield this.H(t):yield this.X(t)).success?this.D({name:"logs_flushed",events:t}):this.Y(t)}catch(t){s.Log.warn("Failed to flush events.")}})}X(e){return i(this,void 0,void 0,function*(){var t=yield this.A.post({sdkKey:this.l,data:{events:e},url:this.Ft,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)}})}H(t){return i(this,void 0,void 0,function*(){return{success:yield this.A.beacon({sdkKey:this.l,data:{events:t},url:this.Vt})}})}Y(t){for(;500{s.Log.warn("Unable to save failed logs to storage")})}J(){const e=this.Z();i(this,void 0,void 0,function*(){var t=yield(0,l.getObjectFromStorage)(e);t&&(yield l.Storage.removeItem(e),yield this.W(t))}).catch(()=>{s.Log.warn("Failed to flush stored logs")})}Z(){return"statsig.failed_logs."+(0,o.DJB2)(this.l)}Jt(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}}))}zt(){0!==Object.keys(this.Kt).length&&(this.Jt({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:Object.assign({},this.Kt)}}),this.Kt={})}}},832:(t,e)=>{function n(e){let n=0;for(let t=0;t>>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)))}},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.tt.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"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.D=e,this.et=null!=(e=null==t?void 0:t.networkTimeoutMs)?e:1e4}post(e){return o(this,void 0,void 0,function*(){var t=yield this.nt(e);return this.it(Object.assign({method:"POST",body:t},e))})}get(t){return o(this,void 0,void 0,function*(){return this.it(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=this.rt(n),e=yield this.nt(n);return navigator.sendBeacon(t,e)})}it(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.et}ms expired.`),this.et),l=this.rt(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.D)&&d.call(this,{name:"error",error:t}),v.Log.error(`A networking error occured during ${e} request to ${l}.`,n,t),null):this.it(Object.assign(Object.assign({},c),{retries:i-1}))}})}rt(t){var e=u.StatsigMetadataProvider.get(),e=Object.assign({k:t.sdkKey,st:e.sdkType,sv:e.sdkVersion,t:String(Date.now()),sid:s.SessionID.get(t.sdkKey)},t.params),e=Object.entries(e).map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e)).join("&");return t.url+(e?"?"+e:"")}nt(i){return o(this,void 0,void 0,function*(){var t=i["data"],e=yield r.StableID.get(i.sdkKey),n=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.ot(t=>{var e;return null!=(e=null==(e=t.getGateOverride)?void 0:e.call(t,n,i))?e:null})}getDynamicConfigOverride(n,i){return this.ot(t=>{var e;return null!=(e=null==(e=t.getDynamicConfigOverride)?void 0:e.call(t,n,i))?e:null})}ot(t){for(const n of this.providers){var e=t(n);if(e)return e}return null}}},612:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SessionID=void 0;const i=n(556),o={};e.SessionID={get:t=>(null==o[t]&&(o[t]=(0,i.getUUID)()),o[t])}},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:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigClientBase=void 0,n(496);const s=n(512),r=n(728),u=n(780),l=n(604),a=n(444);e.StatsigClientBase=class{constructor(t,e,n,i){this.l=t,this.loadingStatus="Uninitialized",this.ut={},null!=i&&i.disableStorage&&a.Storage.setDisabled(!0),null!=i&&i.overrideStableID&&l.StableID.setOverride(i.overrideStableID,t),u.Log.level=null!=(o=null==i?void 0:i.logLevel)?o:u.LogLevel.Warn,this.Pt=null!=(o=null==i?void 0:i.overrideAdapter)?o:null,this.lt=new r.EventLogger(t,this.tt.bind(this),n,i),this.u=new s.ErrorBoundary(t);var o,n=null!=(o=(__STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}).instances)?o:new Set;n.add(this),__STATSIG__.instances=n,this.dataAdapter=e,this.dataAdapter.attach(t,i)}updateRuntimeOptions(t){null!=t.disableLogging&&this.lt.setLoggingDisabled(t.disableLogging),null!=t.disableStorage&&a.Storage.setDisabled(t.disableStorage)}flush(){return this.lt.flush()}on(t,e){this.ut[t]||(this.ut[t]=[]),this.ut[t].push(e)}off(t,e){this.ut[t]&&-1!==(e=this.ut[t].indexOf(e))&&this.ut[t].splice(e,1)}tt(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.ut[e.name]&&this.ut[e.name].forEach(t=>n(t)),null!=(t=this.ut["*"])&&t.forEach(n)}ct(t,e){this.loadingStatus=t,this.tt({name:"values_updated",status:t,values:e})}dt(t,e,n){!0===(null==n?void 0:n.disableExposureLog)?this.lt.incrementNonExposureCount(t):this.lt.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.16",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,Et: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(){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{Object.defineProperty(e,"__esModule",{value:!0}),e.Lt=void 0,e.Lt=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.ht}static add(t){this.ut.push(t)}static remove(t){t=this.ut.indexOf(t);-1!==t&&this.ut.splice(t,1)}static notify(e){e!==this.ht&&(this.ht=e,this.ut.forEach(t=>t.onVisibilityChanged(e)))}}(e.VisibilityChangeObserver=n).ut=[],n.ht="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}}),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(780),e),o(n(104),e),o(n(188),e),o(n(264),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,Storage:u.Storage})},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(t){this.l=t,this.wt=null,this.xt="Uninitialized",this.Nt=0,this.It=0}reset(){this.wt=null,this.xt="Loading",this.Nt=0,this.It=0}finalize(){this.wt||(this.xt="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.Nt=e.time,this.It=t.receivedAt,this.xt=t.source,this.wt=e)}getGate(t){var e,t=null!=(e=null==(e=this.wt)?void 0:e.feature_gates[t])?e:null;return this.Ut(t)}getConfig(t){var e,t=null!=(e=null==(e=this.wt)?void 0:e.dynamic_configs[t])?e:null;return this.Ut(t)}getLayer(t){var e,t=null!=(e=null==(e=this.wt)?void 0:e.layer_configs[t])?e:null;return this.Ut(t)}Ut(t){return{evaluation:t,details:this._t(null==t)}}_t(t){return"Uninitialized"===this.xt||"NoValues"===this.xt?{reason:this.xt}:{reason:this.xt+":"+(t?"Unrecognized":"Recognized"),lcut:this.Nt,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.$t=(0,r.Lt)(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.Bt(n,t,e)})}Bt(e,n,i){var o;return s(this,void 0,void 0,function*(){var t=yield this.post({sdkKey:e,url:this.$t,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.Bt(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),s=n(536),u=n(400),l=n(364);n(807);class o extends r.StatsigClientBase{constructor(t,e,n=null){var i,o=new u.default(n,t=>{this.tt(t)});super(t,null!=(i=null==n?void 0:n.dataAdapter)?i:new l.StatsigEvaluationsDataAdapter,o,n),(0,r.monitorClass)(this.u,this),(0,r.monitorClass)(this.u,o),this.P=null!=n?n:{},this.vt=new s.default(t),this.A=o,this.Yt=e}initializeSync(){this.updateUserSync(this.Yt)}initializeAsync(){return this.updateUserAsync(this.Yt)}getCurrentUser(){return JSON.parse(JSON.stringify(this.Yt))}updateUserSync(t){this.Wt(t);t=this.dataAdapter.getDataSync(this.Yt);this.vt.setValuesFromDataAdapter(t),this.vt.finalize(),this.ct("Ready",t),this.Dt(null!=t?t:null,this.Yt)}updateUserAsync(n){return i(this,void 0,void 0,function*(){this.Wt(n);var t=this.Yt,e=this.dataAdapter.getDataSync(t);this.ct("Loading",e),this.vt.setValuesFromDataAdapter(e),e=yield this.dataAdapter.getDataAsync(e,t),t===this.Yt&&this.vt.setValuesFromDataAdapter(e),this.vt.finalize(),this.ct("Ready",e)})}shutdown(){return i(this,void 0,void 0,function*(){yield this.lt.shutdown()})}checkGate(t,e){return this.getFeatureGate(t,e).value}getFeatureGate(t,e){var n=(0,r.DJB2)(t),{evaluation:n,details:i}=this.vt.getGate(n),i=(0,r.makeFeatureGate)(t,i,n),o=null==(o=null==(n=this.Pt)?void 0:n.getGateOverride)?void 0:o.call(n,i,this.Yt,e),n=null!=o?o:i;return this.dt(t,(0,r.createGateExposure)(this.Yt,n),e),this.tt({name:"gate_evaluation",gate:n}),n}getDynamicConfig(t,e){t=this.kt("dynamic_config",t,e);return this.tt({name:"dynamic_config_evaluation",dynamicConfig:t}),t}getExperiment(t,e){t=this.kt("experiment",t,e);return this.tt({name:"experiment_evaluation",experiment:t}),t}getLayer(n,i){var t=(0,r.DJB2)(n),{evaluation:t,details:e}=this.vt.getLayer(t),e=(0,r.makeLayer)(n,e,t),o=null==(o=null==(t=this.Pt)?void 0:t.getLayerOverride)?void 0:o.call(t,e,this.Yt,i);const s=null!=o?o:e;return this.tt({name:"layer_evaluation",layer:s}),Object.assign(Object.assign({},s),{getValue:t=>{var e;return t in s.Et&&(e=(0,r.createLayerParameterExposure)(this.Yt,s,t),this.dt(n,e,i),null!=(e=s.Et[t]))?e:null}})}logEvent(t){this.lt.enqueue(Object.assign(Object.assign({},t),{user:this.Yt,time:Date.now()}))}Dt(t,e){this.dataAdapter.getDataAsync(t,e).catch(t=>{r.Log.error("An error occurred after update.",t)})}Wt(t){this.lt.reset(),this.vt.reset(),this.Yt=(0,r.normalizeUser)(t,this.P.environment)}kt(t,e,n){var i=(0,r.DJB2)(e),{evaluation:i,details:o}=this.vt.getConfig(i),o=(0,r.makeDynamicConfig)(e,o,i),i="experiment"===t?null==(t=null==(i=this.Pt)?void 0:i.getExperimentOverride)?void 0:t.call(i,o,this.Yt,n):null==(i=null==(t=this.Pt)?void 0:t.getDynamicConfigOverride)?void 0:i.call(t,o,this.Yt,n),t=null!=i?i:o;return this.dt(e,(0,r.createConfigExposure)(this.Yt,t),n),t}}e.default=o},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.A=null}attach(t,e){super.attach(t,e),this.A=new s.default(null!=e?e:{})}S(e,n){var i;return o(this,void 0,void 0,function*(){var t=yield null==(i=this.A)?void 0:i.fetchEvaluations(this.N(),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})}},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,s=o(520);s.default;const r=o(364);o(807),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{StatsigEvaluationsDataAdapter:r.StatsigEvaluationsDataAdapter,StatsigClient:s.default}),e.default=__STATSIG__}return t.default})()); \ No newline at end of file diff --git a/samples/web-minified/src/assets/statsig-js-on-device-eval-client.min.js b/samples/web-minified/src/assets/statsig-js-on-device-eval-client.min.js index 0f956b82..18da5475 100644 --- a/samples/web-minified/src/assets/statsig-js-on-device-eval-client.min.js +++ b/samples/web-minified/src/assets/statsig-js-on-device-eval-client.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.StatsigOnDeviceEval=e():t.StatsigOnDeviceEval=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:{},r=null!=(r=null!=(r=null!=(r=e.__STATSIG__)?r:n.__STATSIG__)?r:i.__STATSIG__)?r:{};e.__STATSIG__=r,n.__STATSIG__=r,i.__STATSIG__=r},856:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},320:function(t,e,n){var s=this&&this.__awaiter||function(t,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.DataAdapterCore=void 0;const i=n(512),r=n(780),o=n(104),u=n(283),a=n(296),l=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,o.monitorClass)(this.u,this)}getDataSync(t){var t=this._(t),e=this.h[t];return e||((e=this.p(t))?(this.m(t,e),this.h[t]):null)}getDataAsync(n,i){var r;return s(this,void 0,void 0,function*(){var t=null!=n?n:this.getDataSync(i),t=yield this.O(null!=(r=null==t?void 0:t.data)?r:null,i),e=this._(i);return t&&this.m(e,t),"Network"!==(null==t?void 0:t.source)&&"NetworkNotModified"!==(null==t?void 0:t.source)||(yield this.j(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.m(t,Object.assign(Object.assign({},e),{source:"Prefetch"}))})}setData(t,e){e=this._(e);this.m(e,{source:"Bootstrap",data:t,receivedAt:Date.now()})}__setInMemoryCache(t){this.h=t}O(n,i){return s(this,void 0,void 0,function*(){var t,e=yield this.S(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()}):(r.Log.debug("No response returned for latest value"),null)})}N(){return null!=this.l?this.l:(r.Log.error(this.i+" is not attached to a Client"),"")}_(t){t=(0,a.getUserStorageKey)(this.N(),t);return`${u.DataAdapterCachePrefix}.${this.o}.`+t}m(t,e){var n=Object.entries(this.h);n.length<10||([n]=n.reduce((t,e)=>e[1]e[1]{Object.defineProperty(e,"__esModule",{value:!0}),e.Diagnostics=e.captureDiagnostics=void 0;const i=n(780),r="undefined"!=typeof performance&&void 0!==performance.mark;let s=[];e.captureDiagnostics=function(t,e){o.mark(t+":start"),e=e();const n=()=>{o.mark(t+":end"),(t+":end").startsWith("initialize:")&&o.flush()};return e&&e instanceof Promise?e.finally(()=>n()):(n(),e)};class o{static mark(t,e){r&&(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=o},512:function(t,u,e){var n=this&&this.__awaiter||function(t,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})};Object.defineProperty(u,"__esModule",{value:!0}),u.ErrorBoundary=u.EXCEPTION_ENDPOINT=void 0;const i=e(780),a=e(972);u.EXCEPTION_ENDPOINT="https://statsigapi.net/v1/sdk_exception";u.ErrorBoundary=class{constructor(t){this.l=t,this.M=new Set}capture(e,t,n){try{var i=t();return i&&i instanceof Promise?i.catch(t=>this.T(e,t,n)):i}catch(t){return this.T(e,t,n),null}}logError(t,e){this.T(t,e)}T(r,s,o){try{i.Log.warn("Caught error in "+r,{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.M.has(i)||(this.M.add(i),t=a.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:r,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!=o&&o({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,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.EventLogger=void 0;const r=n(832),s=n(780),o=n(876),u=n(972),a=n(444),l=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.D=e,this.A=n,this.P=i,this.C=[],this.qt={},this.Kt={},this.F=!1,this.L=Date.now(),this.V=!0===(null==i?void 0:i.disableLogging),this.R=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.q(),n),this.Ft=(0,c.Lt)(null==i?void 0:i.logEventUrl,null==i?void 0:i.api,"/rgstr",h),this.Vt=(0,c.Lt)(null==i?void 0:i.logEventBeaconUrl,null==i?void 0:i.api,"/log_event_beacon",h),d.VisibilityChangeObserver.add(this),this.J()}setLoggingDisabled(t){this.V=t}enqueue(t){this.U(t)&&(this.Jt(t),this.B(),this.C.length>this.R)&&this.q()}incrementNonExposureCount(t){var e=null!=(e=this.Kt[t])?e:0;this.Kt[t]=e+1}reset(){this.qt={}}onVisibilityChanged(t){"background"===t&&this.q()}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.zt(),0!==this.C.length&&(t=this.C,this.C=[],yield this.W(t))})}B(){this.F||(this.F=!0,200this.q(),200)}U(t){if((0,o.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.qt[t],n=Date.now();if(e&&n-e<6e4)return!1;1e3{})}W(t){return i(this,void 0,void 0,function*(){if(this.V)this.Y(t);else try{(!d.VisibilityChangeObserver.isCurrentlyVisible()&&this.A.isBeaconSupported()?yield this.H(t):yield this.X(t)).success?this.D({name:"logs_flushed",events:t}):this.Y(t)}catch(t){s.Log.warn("Failed to flush events.")}})}X(e){return i(this,void 0,void 0,function*(){var t=yield this.A.post({sdkKey:this.l,data:{events:e},url:this.Ft,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)}})}H(t){return i(this,void 0,void 0,function*(){return{success:yield this.A.beacon({sdkKey:this.l,data:{events:t},url:this.Vt})}})}Y(t){for(;500{s.Log.warn("Unable to save failed logs to storage")})}J(){const e=this.Z();i(this,void 0,void 0,function*(){var t=yield(0,a.getObjectFromStorage)(e);t&&(yield a.Storage.removeItem(e),yield this.W(t))}).catch(()=>{s.Log.warn("Failed to flush stored logs")})}Z(){return"statsig.failed_logs."+(0,r.DJB2)(this.l)}Jt(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}}))}zt(){0!==Object.keys(this.Kt).length&&(this.Jt({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:Object.assign({},this.Kt)}}),this.Kt={})}}},832:(t,e)=>{function n(e){let n=0;for(let t=0;t>>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 r={};t.forEach(t=>{let e=i[t];e instanceof Object&&(e=n(e)),r[t]=e});return r}(t)))}},780:(t,e)=>{function n(t){return t.unshift("[Statsig]"),t}var i,r;Object.defineProperty(e,"__esModule",{value:!0}),e.Log=e.LogLevel=void 0,(r=i||(e.LogLevel=i={}))[r.None=0]="None",r[r.Error=1]="Error",r[r.Warn=2]="Warn",r[r.Info=3]="Info",r[r.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),o=n(688);function c(t,e,n,i){var r=i instanceof o.StatsigClientBase?i.tt.bind(i):void 0;return t.capture(e,()=>(0,s.captureDiagnostics)(e,()=>n.apply(i)),r)}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 r;const s=i;for(const o 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"!==o){const u=s[o];s[o]=function(...t){return c(n,o,()=>u.apply(this,t),i)}}for(const a 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"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 l=null==(r=null===s||void 0===s?void 0:s.constructor)?void 0:r[a];(null===s||void 0===s?void 0:s.constructor)[a]=function(...t){return c(n,s.constructor.name+"."+a,()=>l.apply(s.constructor,t),i)}}return}}catch(t){e.logError("monitorClass",t)}}},188:function(t,e,n){var r=this&&this.__awaiter||function(t,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.NetworkCore=void 0;const h=n(280),v=n(780),s=n(612),o=n(604),u=n(972);e.NetworkCore=class{constructor(t,e){this.P=t,this.D=e,this.et=null!=(e=null==t?void 0:t.networkTimeoutMs)?e:1e4}post(e){return r(this,void 0,void 0,function*(){var t=yield this.nt(e);return this.it(Object.assign({method:"POST",body:t},e))})}get(t){return r(this,void 0,void 0,function*(){return this.it(Object.assign({method:"GET"},t))})}isBeaconSupported(){return"undefined"!=typeof navigator&&"function"==typeof(null===navigator||void 0===navigator?void 0:navigator.sendBeacon)}beacon(n){return r(this,void 0,void 0,function*(){var t=this.rt(n),e=yield this.nt(n);return navigator.sendBeacon(t,e)})}it(c){var d;return r(this,void 0,void 0,function*(){var{method:e,body:n,retries:i}=c;const r=new AbortController;var t,s,o,u=setTimeout(()=>r.abort(`Timeout of ${this.et}ms expired.`),this.et),a=this.rt(c);let l=null;try{if(l=yield fetch(a,{method:e,body:n,headers:Object.assign({},c.headers),signal:r.signal}),clearTimeout(u),l.ok)return o=yield l.text(),h.Diagnostics.mark("_sendRequest:response-received",{status:l.status,contentLength:l.headers.get("content-length")}),{body:o,code:l.status};throw t=yield l.text().catch(()=>"No Text"),(s=new Error(`Failed to fetch: ${a} `+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}(r,t);return h.Diagnostics.mark("_sendRequest:error",{error:n,status:null===l||void 0===l?void 0:l.status,contentLength:null===l||void 0===l?void 0:l.headers.get("content-length")}),!i||i<=0?(null!=(d=this.D)&&d.call(this,{name:"error",error:t}),v.Log.error(`A networking error occured during ${e} request to ${a}.`,n,t),null):this.it(Object.assign(Object.assign({},c),{retries:i-1}))}})}rt(t){var e=u.StatsigMetadataProvider.get(),e=Object.assign({k:t.sdkKey,st:e.sdkType,sv:e.sdkVersion,t:String(Date.now()),sid:s.SessionID.get(t.sdkKey)},t.params),e=Object.entries(e).map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e)).join("&");return t.url+(e?"?"+e:"")}nt(i){return r(this,void 0,void 0,function*(){var t=i["data"],e=yield o.StableID.get(i.sdkKey),n=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.ot(t=>{var e;return null!=(e=null==(e=t.getGateOverride)?void 0:e.call(t,n,i))?e:null})}getDynamicConfigOverride(n,i){return this.ot(t=>{var e;return null!=(e=null==(e=t.getDynamicConfigOverride)?void 0:e.call(t,n,i))?e:null})}ot(t){for(const n of this.providers){var e=t(n);if(e)return e}return null}}},612:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SessionID=void 0;const i=n(556),r={};e.SessionID={get:t=>(null==r[t]&&(r[t]=(0,i.getUUID)()),r[t])}},604:function(t,e,n){var i=this&&this.__awaiter||function(t,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.StableID=void 0;const r=n(832),s=n(780),o=n(444),u=n(556),a={};function l(t){return"statsig.stable_id."+(0,r.DJB2)(t)}function c(t,e){e=l(e);(0,o.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==a[e]&&(a[e]=function(t){t=l(t);return(0,o.getObjectFromStorage)(t)}(e).then(t=>{return null!=t||c(t=(0,u.getUUID)(),e),t})),a[e]}),setOverride:(t,e)=>{a[e]=Promise.resolve(t),c(t,e)}}},688:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigClientBase=void 0,n(496);const s=n(512),o=n(728),u=n(780),a=n(604),l=n(444);e.StatsigClientBase=class{constructor(t,e,n,i){this.l=t,this.loadingStatus="Uninitialized",this.ut={},null!=i&&i.disableStorage&&l.Storage.setDisabled(!0),null!=i&&i.overrideStableID&&a.StableID.setOverride(i.overrideStableID,t),u.Log.level=null!=(r=null==i?void 0:i.logLevel)?r:u.LogLevel.Warn,this.Pt=null!=(r=null==i?void 0:i.overrideAdapter)?r:null,this.lt=new o.EventLogger(t,this.tt.bind(this),n,i),this.u=new s.ErrorBoundary(t);var r,n=null!=(r=(__STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}).instances)?r:new Set;n.add(this),__STATSIG__.instances=n,this.dataAdapter=e,this.dataAdapter.attach(t,i)}updateRuntimeOptions(t){null!=t.disableLogging&&this.lt.setLoggingDisabled(t.disableLogging),null!=t.disableStorage&&l.Storage.setDisabled(t.disableStorage)}flush(){return this.lt.flush()}on(t,e){this.ut[t]||(this.ut[t]=[]),this.ut[t].push(e)}off(t,e){this.ut[t]&&-1!==(e=this.ut[t].indexOf(e))&&this.ut[t].splice(e,1)}tt(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.ut[e.name]&&this.ut[e.name].forEach(t=>n(t)),null!=(t=this.ut["*"])&&t.forEach(n)}ct(t,e){this.loadingStatus=t,this.tt({name:"values_updated",status:t,values:e})}dt(t,e,n){!0===(null==n?void 0:n.disableExposureLog)?this.lt.incrementNonExposureCount(t):this.lt.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 a(t,e,n,i,r){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:r,time:Date.now()}}e.isExposureEvent=function({eventName:t}){return t===i||t===n},e.createGateExposure=function(t,e){return a(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 a(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,r=e.__evaluation,s=!0===(null==(s=null==r?void 0:r.explicit_parameters)?void 0:s.includes(n));let o="",u=null!=(i=null==r?void 0:r.undelegated_secondary_exposures)?i:[];return s&&(o=null!=(i=r.allocated_experiment_name)?i:"",u=r.secondary_exposures),a("statsig::layer_exposure",t,e.details,{config:e.name,parameterName:n,ruleID:e.ruleID,allocatedExperiment:o,isExplicitParameter:String(s)},u)}},972:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigMetadataProvider=void 0;let n={sdkVersion:"0.0.1-beta.14",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 r="default";e.makeFeatureGate=function(t,e,n){return{name:t,details:e,ruleID:null!=(t=null==n?void 0:n.rule_id)?t:r,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:r,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:r,Et: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,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})},n=(Object.defineProperty(e,"__esModule",{value:!0}),e.setObjectInStorage=e.getObjectFromStorage=e.Storage=void 0,n(780));const r={},s={getProviderName:()=>"InMemory",getItemSync(t){return null!=(t=r[t])?t:null},getItem(t){return Promise.resolve(null!=(t=r[t])?t:null)},setItem(t,e){return r[t]=e,Promise.resolve()},removeItem(t){return delete r[t],Promise.resolve()},getAllKeys(){return Promise.resolve(Object.keys(r))}};let o=null;try{"undefined"!=typeof window&&"localStorage"in window&&(o={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!==o&&void 0!==o?o:s,a=u;e.Storage={getProviderName:()=>a.getProviderName(),getItem:t=>a.getItem(t),setItem:(t,e)=>a.setItem(t,e),removeItem:t=>a.removeItem(t),getAllKeys:()=>a.getAllKeys(),getItemSync:t=>{var e;return null!=(e=null==(e=a.getItemSync)?void 0:e.call(a,t))?e:null},setProvider:t=>{u=t,a=t},setDisabled:t=>{a=t?s:u}},e.getObjectFromStorage=function(e){return i(this,void 0,void 0,function*(){var t=yield a.getItem(e);return JSON.parse(null!=t?t:"null")})},e.setObjectInStorage=function(t,e){return i(this,void 0,void 0,function*(){yield a.setItem(t,JSON.stringify(e))})}},412:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.typedJsonParse=void 0;const r=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 r.Log.error(n),null}},556:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getUUID=void 0,e.getUUID=function(){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{Object.defineProperty(e,"__esModule",{value:!0}),e.Lt=void 0,e.Lt=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.ht}static add(t){this.ut.push(t)}static remove(t){t=this.ut.indexOf(t);-1!==t&&this.ut.splice(t,1)}static notify(e){e!==this.ht&&(this.ht=e,this.ut.forEach(t=>t.onVisibilityChanged(e)))}}(e.VisibilityChangeObserver=n).ut=[],n.ht="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 r=Object.getOwnPropertyDescriptor(e,n);r&&("get"in r?e.__esModule:!r.writable&&!r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),r=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),o=(Object.defineProperty(e,"EventLogger",{enumerable:!0,get:function(){return s.EventLogger}}),n(780)),u=(Object.defineProperty(e,"Log",{enumerable:!0,get:function(){return o.Log}}),n(444));Object.defineProperty(e,"Storage",{enumerable:!0,get:function(){return u.Storage}}),r(n(496),e),r(n(856),e),r(n(320),e),r(n(512),e),r(n(500),e),r(n(788),e),r(n(832),e),r(n(780),e),r(n(104),e),r(n(188),e),r(n(264),e),r(n(604),e),r(n(688),e),r(n(808),e),r(n(283),e),r(n(876),e),r(n(972),e),r(n(384),e),r(n(136),e),r(n(296),e),r(n(444),e),r(n(412),e),r(n(84),e),r(n(539),e),r(n(556),e),r(n(408),e),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{EventLogger:s.EventLogger,Log:o.Log,Storage:u.Storage})},532:(t,e)=>{function u(t){return t.setUTCHours(0,0,0,0),t.getTime()}Object.defineProperty(e,"__esModule",{value:!0}),e.default={compareNumbers(t,e,n){if(null==t||null==e)return!1;var i=Number(t),r=Number(e);if(isNaN(i)||isNaN(r))return!1;switch(n){case"gt":return e{var e=t.indexOf("-");return-1!==e?t.substring(0,e):t},r=((t,e)=>{var n=t.split(".").map(t=>parseInt(t)),i=e.split(".").map(t=>parseInt(t));let r=0;for(;r{var e=String(r),t=String(t),n=o?e.toLowerCase():e,i=o?t.toLowerCase():t;switch(s){case"any":case"none":case"any_case_sensitive":case"none_case_sensitive":return n===i;case"str_starts_with_any":return n.startsWith(i);case"str_ends_with_any":return n.endsWith(i);case"str_contains_any":case"str_contains_none":return n.includes(i);default:return!1}});switch(s){case"none":case"none_case_sensitive":case"str_contains_none":return!e;default:return e}},compareStringWithRegEx(t,e){try{var n=String(t);if(n.length<1e3)return new RegExp(String(e)).test(n)}catch(t){}return!1},compareTime(n,i,r){if(null==n||null==i)return!1;try{let t=new Date(String(n)),e=(isNaN(t.getTime())&&(t=new Date(Number(n))),new Date(String(i)));isNaN(e.getTime())&&(e=new Date(Number(i)));var s=t.getTime(),o=e.getTime();if(isNaN(s)||isNaN(o))return!1;switch(r){case"before":return s{Object.defineProperty(e,"__esModule",{value:!0}),e.resultToLayerEval=e.resultToConfigEval=e.resultToGateEval=e.makeEvalResult=void 0,e.makeEvalResult=function(t){return Object.assign(Object.assign({},{unsupported:!1,bool_value:!1,rule_id:"",secondary_exposures:[],json_value:{},explicit_parameters:null,allocated_experiment_name:null,is_experiment_group:!1,group_name:null,undelegated_secondary_exposures:void 0}),t)},e.resultToGateEval=function(t,e){return{name:t.name,id_type:t.idType,rule_id:e.rule_id,value:e.bool_value,secondary_exposures:e.secondary_exposures}},e.resultToConfigEval=function(t,e){var n;return{name:t.name,id_type:t.idType,rule_id:e.rule_id,value:e.json_value,secondary_exposures:e.secondary_exposures,group:null!=(n=e.group_name)?n:"",group_name:null!=(n=e.group_name)?n:void 0,is_device_based:!1,is_experiment_active:t.isActive,is_user_in_experiment:e.is_experiment_group}},e.resultToLayerEval=function(t,e,n){return{name:t.name,rule_id:n.rule_id,value:n.json_value,secondary_exposures:n.secondary_exposures,undelegated_secondary_exposures:n.undelegated_secondary_exposures,allocated_experiment_name:null!=(t=n.allocated_experiment_name)?t:"",explicit_parameters:null!=(t=n.explicit_parameters)?t:[],group:null!=(t=n.group_name)?t:"",group_name:null!=(t=n.group_name)?t:void 0,is_device_based:!1,is_experiment_active:null==e?void 0:e.isActive,is_user_in_experiment:n.is_experiment_group}}},931:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});const c=n(464),i=n(452),d=n(532),h=n(947);function v(t){return(0,i.SHA256)(t).dataView().getBigUint64(0,!1)}function u(t){return null!=t&&"object"==typeof t}e.default=class{constructor(t){this.vt=t}evaluateGate(t,e){var{spec:t,details:n}=this.Ct("gate",t);return t?{evaluation:(0,h.resultToGateEval)(t,this.ft(t,e)),details:n}:{evaluation:null,details:n}}evaluateConfig(t,e){var{spec:t,details:n}=this.Ct("config",t);return t?{evaluation:(0,h.resultToConfigEval)(t,this.ft(t,e)),details:n}:{evaluation:null,details:n}}evaluateLayer(t,e){var n,{spec:t,details:i}=this.Ct("layer",t);return t?(n=null!=(n=null==(e=this.ft(t,e))?void 0:e.allocated_experiment_name)?n:"",n=this.vt.getSpecAndSourceInfo("config",n).spec,{evaluation:(0,h.resultToLayerEval)(t,n,e),details:i}):{evaluation:null,details:i}}Ct(t,e){t=this.vt.getSpecAndSourceInfo(t,e);return{details:this.Gt(t),spec:t.spec}}Gt(t){var{source:t,spec:e,lcut:n,receivedAt:i}=t;return"Uninitialized"===t||"NoValues"===t?{reason:t}:{reason:t+":"+(null==e?"Unrecognized":"Recognized"),lcut:n,receivedAt:i}}ft(t,e){var n=u(t.defaultValue)?t.defaultValue:void 0;if(!t.enabled)return(0,h.makeEvalResult)({json_value:n,rule_id:"disabled"});var i=[];for(const o of t.rules){var r,s=this.gt(o,e);if(s.unsupported)return s;if(i.push(...s.secondary_exposures),s.bool_value)return this.bt(o.configDelegate,e,i)||(r=function(t,e,n){if(100===t.passPercentage)return!0;if(0===t.passPercentage)return!1;e=v(n.salt+"."+(null!=(n=t.salt)?n:t.id)+"."+(null!=(n=(0,c.getUnitIDFromUser)(e,t.idType))?n:""));return Number(e%BigInt(1e4))<100*t.passPercentage}(o,e,t),(0,h.makeEvalResult)({rule_id:s.rule_id,bool_value:r,json_value:r?s.json_value:n,secondary_exposures:i,undelegated_secondary_exposures:i,is_experiment_group:s.is_experiment_group,group_name:s.group_name}))}return(0,h.makeEvalResult)({json_value:n,secondary_exposures:i,undelegated_secondary_exposures:i,rule_id:"default"})}gt(t,e){var n=[];let i=!0;for(const s of t.conditions){var r=this.yt(s,e);if(r.unsupported)return r;n.push(...r.secondary_exposures),r.bool_value||(i=!1)}return(0,h.makeEvalResult)({rule_id:t.id,bool_value:i,json_value:u(t.returnValue)?t.returnValue:void 0,secondary_exposures:n,is_experiment_group:!0===t.isExperimentGroup,group_name:t.groupName})}yt(t,e){let n=null,i=!1;var r=t.field,s=t.targetValue,o=t.idType,u=t.type;switch(u){case"public":return(0,h.makeEvalResult)({bool_value:!0});case"pass_gate":case"fail_gate":var a=String(s),a=this.Ot(a,e);return(0,h.makeEvalResult)({bool_value:"fail_gate"===u?!a.bool_value:a.bool_value,secondary_exposures:a.secondary_exposures});case"multi_pass_gate":case"multi_fail_gate":return this.jt(s,u,e);case"user_field":case"ip_based":case"ua_based":n=function(t,e){var n;if(null==e||"object"!=typeof t||null==t)return null;var i=t;return null!=(n=null!=(n=null!=(n=null!=(n=null!=(n=i[e])?n:i[e.toLowerCase()])?n:null==(i=null==t?void 0:t.custom)?void 0:i[e])?n:null==(i=null==t?void 0:t.custom)?void 0:i[e.toLowerCase()])?n:null==(i=null==t?void 0:t.privateAttributes)?void 0:i[e])?n:null==(i=null==t?void 0:t.privateAttributes)?void 0:i[e.toLowerCase()]}(e,r);break;case"environment_field":n=function(t,e){if(null==e)return null;t=t.statsigEnvironment;if(null!=t){const n=e.toLowerCase(),i=Object.keys(t).find(t=>t.toLowerCase()===n);return void 0!==i?t[i]:void 0}}(e,r);break;case"current_time":n=Date.now();break;case"user_bucket":a=v(null!==(a=String(null!=(a=null==(a=t.additionalValues)?void 0:a.salt)?a:"")+"."+(0,c.getUnitIDFromUser)(e,o))?a:"");n=Number(a%BigInt(1e3));break;case"unit_id":n=(0,c.getUnitIDFromUser)(e,o);break;default:return(0,h.makeEvalResult)({unsupported:!0})}var l=t.operator;switch(l){case"gt":case"gte":case"lt":case"lte":i=d.default.compareNumbers(n,s,l);break;case"version_gt":case"version_gte":case"version_lt":case"version_lte":case"version_eq":case"version_neq":i=d.default.compareVersions(n,s,l);break;case"any":case"none":case"str_starts_with_any":case"str_ends_with_any":case"str_contains_any":case"str_contains_none":case"any_case_sensitive":case"none_case_sensitive":i=d.default.compareStringInArray(n,s,l);break;case"str_matches":i=d.default.compareStringWithRegEx(n,s);break;case"before":case"after":case"on":i=d.default.compareTime(n,s,l);break;case"eq":i=n==s;break;case"neq":i=n!=s;break;case"in_segment_list":case"not_in_segment_list":return(0,h.makeEvalResult)({unsupported:!0})}return(0,h.makeEvalResult)({bool_value:i})}bt(t,e,n){var i;return t&&(i=this.vt.getSpecAndSourceInfo("config",t).spec,i)?(e=this.ft(i,e),(0,h.makeEvalResult)(Object.assign(Object.assign({},e),{allocated_experiment_name:t,explicit_parameters:i.explicitParameters,secondary_exposures:n.concat(e.secondary_exposures),undelegated_secondary_exposures:n}))):null}Ot(t,e){var n=[];let i=!1;var r=this.vt.getSpecAndSourceInfo("gate",t)["spec"];if(r){r=this.ft(r,e);if(r.unsupported)return r;i=r.bool_value,n.push(...r.secondary_exposures),n.push({gate:t,gateValue:String(i),ruleID:r.rule_id})}return(0,h.makeEvalResult)({bool_value:i,secondary_exposures:n})}jt(t,e,n){if(!Array.isArray(t))return(0,h.makeEvalResult)({unsupported:!0});var i="multi_pass_gate"===e,r=[];let s=!1;for(const u of t){if("string"!=typeof u)return(0,h.makeEvalResult)({unsupported:!0});var o=this.Ot(u,n);if(o.unsupported)return o;if(r.push(...o.secondary_exposures),i?!0===o.bool_value:!1===o.bool_value){s=!0;break}}return(0,h.makeEvalResult)({bool_value:s,secondary_exposures:r})}}},160:function(t,e,n){var i=this&&this.__awaiter||function(t,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(464);class s extends r.NetworkCore{constructor(t=null){super(t),this.Rt=(0,r.Lt)(null==t?void 0:t.downloadConfigSpecsUrl,null==t?void 0:t.api,"/download_config_specs","https://api.statsigcdn.com/v1")}fetchConfigSpecs(e){var n;return i(this,void 0,void 0,function*(){var t=yield this.get({sdkKey:e,url:this.Rt});return null!=(n=null==t?void 0:t.body)?n:null})}}e.default=s},480:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=n(464);e.default=class{constructor(){this.wt=null,this.xt="Uninitialized",this.Nt=0,this.It=0}setValuesFromDataAdapter(t){var e;t&&!0===(null==(e=(0,i.typedJsonParse)(t.data,"has_updates","Failed to parse DownloadConfigSpecsResponse"))?void 0:e.has_updates)&&(this.Nt=e.time,this.It=t.receivedAt,this.xt=t.source,this.wt=e)}reset(){this.wt=null,this.xt="Loading"}finalize(){this.wt||(this.xt="NoValues")}getSpecAndSourceInfo(t,e){var t=this.Mt(t);return{spec:null!=(t=null==t?void 0:t.find(t=>t.name===e))?t:null,source:this.xt,lcut:this.Nt,receivedAt:this.It}}Mt(t){var e;switch(t){case"gate":return null==(e=this.wt)?void 0:e.feature_gates;case"config":return null==(e=this.wt)?void 0:e.dynamic_configs;case"layer":return null==(e=this.wt)?void 0:e.layer_configs}}}},348:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});n(464).StatsigMetadataProvider.add({sdkType:"js-on-device-eval-client"})},368:function(t,e,n){var i=this&&this.__awaiter||function(t,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const u=n(464),r=n(931),s=n(160),o=n(480),a=n(4);class l extends u.StatsigClientBase{constructor(t,e=null){var n=new s.default(e);super(t,null!=(t=null==e?void 0:e.dataAdapter)?t:new a.StatsigSpecsDataAdapter,n,e),(0,u.monitorClass)(this.u,this),(0,u.monitorClass)(this.u,n),this.P=null!=e?e:{},this.A=n,this.vt=new o.default,this.Tt=new r.default(this.vt)}initializeSync(){this.vt.reset();var t=this.dataAdapter.getDataSync();this.vt.setValuesFromDataAdapter(t),this.vt.finalize(),this.ct("Ready",t),this.Dt(t)}initializeAsync(){return i(this,void 0,void 0,function*(){this.vt.reset(),this.ct("Loading",null);var t=this.dataAdapter.getDataSync();this.vt.setValuesFromDataAdapter(t),t=yield this.dataAdapter.getDataAsync(t),this.vt.setValuesFromDataAdapter(t),this.vt.finalize(),this.ct("Ready",t)})}shutdown(){return i(this,void 0,void 0,function*(){yield this.lt.shutdown()})}checkGate(t,e,n){return this.getFeatureGate(t,e,n).value}getFeatureGate(t,e,n){e=(0,u.normalizeUser)(e,this.P.environment);var{evaluation:i,details:r}=this.Tt.evaluateGate(t,e),r=(0,u.makeFeatureGate)(t,r,i);return this.dt(t,(0,u.createGateExposure)(e,r),n),this.tt({name:"gate_evaluation",gate:r}),r}getDynamicConfig(t,e,n){t=this.kt("dynamic_config",t,e,n);return this.tt({name:"dynamic_config_evaluation",dynamicConfig:t}),t}getExperiment(t,e,n){t=this.kt("experiment",t,e,n);return this.tt({name:"experiment_evaluation",experiment:t}),t}getLayer(n,i,r){i=(0,u.normalizeUser)(i,this.P.environment);const{evaluation:s,details:t}=this.Tt.evaluateLayer(n,i),o=(0,u.makeLayer)(n,t,s,t=>{var e;return s&&t in s.value&&this.dt(n,(0,u.createLayerParameterExposure)(i,o,t),r),null!=(e=null==(e=null===s||void 0===s?void 0:s.value)?void 0:e[t])?e:null});return this.tt({name:"layer_evaluation",layer:o}),o}logEvent(t,e){this.lt.enqueue(Object.assign(Object.assign({},t),{user:e,time:Date.now()}))}Dt(t){this.dataAdapter.getDataAsync(t).catch(t=>{u.Log.error("An error occurred after update.",t)})}kt(t,e,n,i){n=(0,u.normalizeUser)(n,this.P.environment);var{evaluation:r,details:s}=this.Tt.evaluateConfig(e,n),s=(0,u.makeDynamicConfig)(e,s,r),r="experiment"===t?null==(t=null==(r=this.Pt)?void 0:r.getExperimentOverride)?void 0:t.call(r,s,n,i):null==(r=null==(t=this.Pt)?void 0:t.getDynamicConfigOverride)?void 0:r.call(t,s,n,i),t=null!=r?r:s;return this.dt(e,(0,u.createConfigExposure)(n,t),i),t}}e.default=l},4:function(t,e,n){var i=this&&this.__awaiter||function(t,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})},r=(Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigSpecsDataAdapter=void 0,n(464));const s=n(160);class o extends r.DataAdapterCore{constructor(){super("SpecsDataAdapter","specs"),this.A=null}attach(t,e){super.attach(t,e),this.A=new s.default(null!=e?e:{})}S(t,e){var n;return i(this,void 0,void 0,function*(){return null!=(n=yield null==(n=this.A)?void 0:n.fetchConfigSpecs(this.N()))?n:null})}}e.StatsigSpecsDataAdapter=o},452:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SHA256=void 0;const i=n(891);Object.defineProperty(e,"SHA256",{enumerable:!0,get:function(){return i.SHA256}})},891:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SHA256=void 0,e.SHA256=function(t){return(new i).update(t)};const n=[-2147483648,8388608,32768,128],o=[24,16,8,0],m=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];class i{constructor(){this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.lastByteIndex=-1}update(n){if(!this.finalized){if("string"!=typeof n)throw new Error('Must be of type "string"');var i;let t=0,e;for(var r=n.length,s=this.blocks;t>2]|=i<>2]|=(192|i>>6)<>2]|=(224|i>>12)<>2]|=(240|i>>18)<>2]|=(128|i>>12&63)<>2]|=(128|i>>6&63)<>2]|=(128|63&i)<>2]|=n[3&e],this.block=t[16],56<=e&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash())}hash(){var t=this.blocks;let e=this.h0,n=this.h1,i=this.h2,r=this.h3,s=this.h4,o=this.h5,u=this.h6,a=this.h7,l,c,d,h,v,_,f,g,p,b,y;for(l=16;l<64;++l)v=t[l-15],c=(v>>>7|v<<25)^(v>>>18|v<<14)^v>>>3,v=t[l-2],d=(v>>>17|v<<15)^(v>>>19|v<<13)^v>>>10,t[l]=t[l-16]+c+t[l-7]+d<<0;for(y=n&i,l=0;l<64;l+=4)this.first?(g=704751109,v=t[0]-210244248,a=v-1521486534<<0,r=v+143694565<<0,this.first=!1):(c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),d=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),g=e&n,h=g^e&i^y,f=s&o^~s&u,v=a+d+f+m[l]+t[l],_=c+h,a=r+v<<0,r=v+_<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),d=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),p=r&e,h=p^r&n^g,f=a&s^~a&o,v=u+d+f+m[l+1]+t[l+1],_=c+h,u=i+v<<0,i=v+_<<0,c=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),d=(u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7),b=i&r,h=b^i&e^p,f=u&a^~u&s,v=o+d+f+m[l+2]+t[l+2],_=c+h,o=n+v<<0,n=v+_<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),d=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),y=n&i,h=y^n&r^b,f=o&u^~o&a,v=s+d+f+m[l+3]+t[l+3],_=c+h,s=e+v<<0,e=v+_<<0;this.h0=this.h0+e<<0,this.h1=this.h1+n<<0,this.h2=this.h2+i<<0,this.h3=this.h3+r<<0,this.h4=this.h4+s<<0,this.h5=this.h5+o<<0,this.h6=this.h6+u<<0,this.h7=this.h7+a<<0}arrayBuffer(){return this.At().buffer}dataView(){return this.At().dataView}At(){this.finalize();var t=new ArrayBuffer(32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),e.setUint32(28,this.h7),{dataView:e,buffer:t}}}}},i={};function r(t){var e=i[t];return void 0!==e||(e=i[t]={exports:{}},n[t].call(e.exports,e,e.exports,r)),e.exports}r.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,s=(r(348),r(368));s.default;const o=r(4);__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{StatsigSpecsDataAdapter:o.StatsigSpecsDataAdapter,StatsigOnDeviceEvalClient:s.default}),e.default=__STATSIG__}return t.default})()); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.StatsigOnDeviceEval=e():t.StatsigOnDeviceEval=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:{},r=null!=(r=null!=(r=null!=(r=e.__STATSIG__)?r:n.__STATSIG__)?r:i.__STATSIG__)?r:{};e.__STATSIG__=r,n.__STATSIG__=r,i.__STATSIG__=r},856:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},320:function(t,e,n){var s=this&&this.__awaiter||function(t,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.DataAdapterCore=void 0;const i=n(512),r=n(780),o=n(104),u=n(283),a=n(296),l=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,o.monitorClass)(this.u,this)}getDataSync(t){var t=this._(t),e=this.h[t];return console.log("get",t,this.h),e||((e=this.p(t))?(this.m(t,e),this.h[t]):null)}getDataAsync(n,i){var r;return s(this,void 0,void 0,function*(){var t=null!=n?n:this.getDataSync(i),t=yield this.O(null!=(r=null==t?void 0:t.data)?r:null,i),e=this._(i);return t&&this.m(e,t),"Network"!==(null==t?void 0:t.source)&&"NetworkNotModified"!==(null==t?void 0:t.source)||(yield this.j(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.m(t,Object.assign(Object.assign({},e),{source:"Prefetch"}))})}setData(t,e){e=this._(e);this.m(e,{source:"Bootstrap",data:t,receivedAt:Date.now()}),console.log("set",e,this.h)}__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.S(n,i);return console.log("DA Fetch"),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()}):(r.Log.debug("No response returned for latest value"),null)})}N(){return null!=this.l?this.l:(r.Log.error(this.i+" is not attached to a Client"),"")}_(t){t=(0,a.getUserStorageKey)(this.N(),t);return`${u.DataAdapterCachePrefix}.${this.o}.`+t}m(t,e){var n=Object.entries(this.h);n.length<10||([n]=n.reduce((t,e)=>e[1]e[1]{Object.defineProperty(e,"__esModule",{value:!0}),e.Diagnostics=e.captureDiagnostics=void 0;const i=n(780),r="undefined"!=typeof performance&&void 0!==performance.mark;let s=[];e.captureDiagnostics=function(t,e){o.mark(t+":start"),e=e();const n=()=>{o.mark(t+":end"),(t+":end").startsWith("initialize:")&&o.flush()};return e&&e instanceof Promise?e.finally(()=>n()):(n(),e)};class o{static mark(t,e){r&&(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=o},512:function(t,u,e){var n=this&&this.__awaiter||function(t,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})};Object.defineProperty(u,"__esModule",{value:!0}),u.ErrorBoundary=u.EXCEPTION_ENDPOINT=void 0;const i=e(780),a=e(972);u.EXCEPTION_ENDPOINT="https://statsigapi.net/v1/sdk_exception";u.ErrorBoundary=class{constructor(t){this.l=t,this.M=new Set}capture(e,t,n){try{var i=t();return i&&i instanceof Promise?i.catch(t=>this.T(e,t,n)):i}catch(t){return this.T(e,t,n),null}}logError(t,e){this.T(t,e)}T(r,s,o){try{i.Log.warn("Caught error in "+r,{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.M.has(i)||(this.M.add(i),t=a.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:r,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!=o&&o({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,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.EventLogger=void 0;const r=n(832),s=n(780),o=n(876),u=n(972),a=n(444),l=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.D=e,this.A=n,this.P=i,this.C=[],this.qt={},this.Kt={},this.F=!1,this.L=Date.now(),this.V=!0===(null==i?void 0:i.disableLogging),this.R=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.q(),n),this.Ft=(0,c.Lt)(null==i?void 0:i.logEventUrl,null==i?void 0:i.api,"/rgstr",h),this.Vt=(0,c.Lt)(null==i?void 0:i.logEventBeaconUrl,null==i?void 0:i.api,"/log_event_beacon",h),d.VisibilityChangeObserver.add(this),this.J()}setLoggingDisabled(t){this.V=t}enqueue(t){this.U(t)&&(this.Jt(t),this.B(),this.C.length>this.R)&&this.q()}incrementNonExposureCount(t){var e=null!=(e=this.Kt[t])?e:0;this.Kt[t]=e+1}reset(){this.qt={}}onVisibilityChanged(t){"background"===t&&this.q()}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.zt(),0!==this.C.length&&(t=this.C,this.C=[],yield this.W(t))})}B(){this.F||(this.F=!0,200this.q(),200)}U(t){if((0,o.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.qt[t],n=Date.now();if(e&&n-e<6e4)return!1;1e3{})}W(t){return i(this,void 0,void 0,function*(){if(this.V)this.Y(t);else try{(!d.VisibilityChangeObserver.isCurrentlyVisible()&&this.A.isBeaconSupported()?yield this.H(t):yield this.X(t)).success?this.D({name:"logs_flushed",events:t}):this.Y(t)}catch(t){s.Log.warn("Failed to flush events.")}})}X(e){return i(this,void 0,void 0,function*(){var t=yield this.A.post({sdkKey:this.l,data:{events:e},url:this.Ft,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)}})}H(t){return i(this,void 0,void 0,function*(){return{success:yield this.A.beacon({sdkKey:this.l,data:{events:t},url:this.Vt})}})}Y(t){for(;500{s.Log.warn("Unable to save failed logs to storage")})}J(){const e=this.Z();i(this,void 0,void 0,function*(){var t=yield(0,a.getObjectFromStorage)(e);t&&(yield a.Storage.removeItem(e),yield this.W(t))}).catch(()=>{s.Log.warn("Failed to flush stored logs")})}Z(){return"statsig.failed_logs."+(0,r.DJB2)(this.l)}Jt(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}}))}zt(){0!==Object.keys(this.Kt).length&&(this.Jt({eventName:"statsig::non_exposed_checks",user:null,time:Date.now(),metadata:{checks:Object.assign({},this.Kt)}}),this.Kt={})}}},832:(t,e)=>{function n(e){let n=0;for(let t=0;t>>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 r={};t.forEach(t=>{let e=i[t];e instanceof Object&&(e=n(e)),r[t]=e});return r}(t)))}},780:(t,e)=>{function n(t){return t.unshift("[Statsig]"),t}var i,r;Object.defineProperty(e,"__esModule",{value:!0}),e.Log=e.LogLevel=void 0,(r=i||(e.LogLevel=i={}))[r.None=0]="None",r[r.Error=1]="Error",r[r.Warn=2]="Warn",r[r.Info=3]="Info",r[r.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),o=n(688);function c(t,e,n,i){var r=i instanceof o.StatsigClientBase?i.tt.bind(i):void 0;return t.capture(e,()=>(0,s.captureDiagnostics)(e,()=>n.apply(i)),r)}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 r;const s=i;for(const o 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"!==o){const u=s[o];s[o]=function(...t){return c(n,o,()=>u.apply(this,t),i)}}for(const a 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"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 l=null==(r=null===s||void 0===s?void 0:s.constructor)?void 0:r[a];(null===s||void 0===s?void 0:s.constructor)[a]=function(...t){return c(n,s.constructor.name+"."+a,()=>l.apply(s.constructor,t),i)}}return}}catch(t){e.logError("monitorClass",t)}}},188:function(t,e,n){var r=this&&this.__awaiter||function(t,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.NetworkCore=void 0;const h=n(280),v=n(780),s=n(612),o=n(604),u=n(972);e.NetworkCore=class{constructor(t,e){this.P=t,this.D=e,this.et=null!=(e=null==t?void 0:t.networkTimeoutMs)?e:1e4}post(e){return r(this,void 0,void 0,function*(){var t=yield this.nt(e);return this.it(Object.assign({method:"POST",body:t},e))})}get(t){return r(this,void 0,void 0,function*(){return this.it(Object.assign({method:"GET"},t))})}isBeaconSupported(){return"undefined"!=typeof navigator&&"function"==typeof(null===navigator||void 0===navigator?void 0:navigator.sendBeacon)}beacon(n){return r(this,void 0,void 0,function*(){var t=this.rt(n),e=yield this.nt(n);return navigator.sendBeacon(t,e)})}it(c){var d;return r(this,void 0,void 0,function*(){var{method:e,body:n,retries:i}=c;const r=new AbortController;var t,s,o,u=setTimeout(()=>r.abort(`Timeout of ${this.et}ms expired.`),this.et),a=this.rt(c);let l=null;try{if(l=yield fetch(a,{method:e,body:n,headers:Object.assign({},c.headers),signal:r.signal}),clearTimeout(u),l.ok)return o=yield l.text(),h.Diagnostics.mark("_sendRequest:response-received",{status:l.status,contentLength:l.headers.get("content-length")}),{body:o,code:l.status};throw t=yield l.text().catch(()=>"No Text"),(s=new Error(`Failed to fetch: ${a} `+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}(r,t);return h.Diagnostics.mark("_sendRequest:error",{error:n,status:null===l||void 0===l?void 0:l.status,contentLength:null===l||void 0===l?void 0:l.headers.get("content-length")}),!i||i<=0?(null!=(d=this.D)&&d.call(this,{name:"error",error:t}),v.Log.error(`A networking error occured during ${e} request to ${a}.`,n,t),null):this.it(Object.assign(Object.assign({},c),{retries:i-1}))}})}rt(t){var e=u.StatsigMetadataProvider.get(),e=Object.assign({k:t.sdkKey,st:e.sdkType,sv:e.sdkVersion,t:String(Date.now()),sid:s.SessionID.get(t.sdkKey)},t.params),e=Object.entries(e).map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e)).join("&");return t.url+(e?"?"+e:"")}nt(i){return r(this,void 0,void 0,function*(){var t=i["data"],e=yield o.StableID.get(i.sdkKey),n=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.ot(t=>{var e;return null!=(e=null==(e=t.getGateOverride)?void 0:e.call(t,n,i))?e:null})}getDynamicConfigOverride(n,i){return this.ot(t=>{var e;return null!=(e=null==(e=t.getDynamicConfigOverride)?void 0:e.call(t,n,i))?e:null})}ot(t){for(const n of this.providers){var e=t(n);if(e)return e}return null}}},612:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SessionID=void 0;const i=n(556),r={};e.SessionID={get:t=>(null==r[t]&&(r[t]=(0,i.getUUID)()),r[t])}},604:function(t,e,n){var i=this&&this.__awaiter||function(t,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.StableID=void 0;const r=n(832),s=n(780),o=n(444),u=n(556),a={};function l(t){return"statsig.stable_id."+(0,r.DJB2)(t)}function c(t,e){e=l(e);(0,o.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==a[e]&&(a[e]=function(t){t=l(t);return(0,o.getObjectFromStorage)(t)}(e).then(t=>{return null!=t||c(t=(0,u.getUUID)(),e),t})),a[e]}),setOverride:(t,e)=>{a[e]=Promise.resolve(t),c(t,e)}}},688:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigClientBase=void 0,n(496);const s=n(512),o=n(728),u=n(780),a=n(604),l=n(444);e.StatsigClientBase=class{constructor(t,e,n,i){this.l=t,this.loadingStatus="Uninitialized",this.ut={},null!=i&&i.disableStorage&&l.Storage.setDisabled(!0),null!=i&&i.overrideStableID&&a.StableID.setOverride(i.overrideStableID,t),u.Log.level=null!=(r=null==i?void 0:i.logLevel)?r:u.LogLevel.Warn,this.Pt=null!=(r=null==i?void 0:i.overrideAdapter)?r:null,this.lt=new o.EventLogger(t,this.tt.bind(this),n,i),this.u=new s.ErrorBoundary(t);var r,n=null!=(r=(__STATSIG__=null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}).instances)?r:new Set;n.add(this),__STATSIG__.instances=n,this.dataAdapter=e,this.dataAdapter.attach(t,i)}updateRuntimeOptions(t){null!=t.disableLogging&&this.lt.setLoggingDisabled(t.disableLogging),null!=t.disableStorage&&l.Storage.setDisabled(t.disableStorage)}flush(){return this.lt.flush()}on(t,e){this.ut[t]||(this.ut[t]=[]),this.ut[t].push(e)}off(t,e){this.ut[t]&&-1!==(e=this.ut[t].indexOf(e))&&this.ut[t].splice(e,1)}tt(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.ut[e.name]&&this.ut[e.name].forEach(t=>n(t)),null!=(t=this.ut["*"])&&t.forEach(n)}ct(t,e){this.loadingStatus=t,this.tt({name:"values_updated",status:t,values:e})}dt(t,e,n){!0===(null==n?void 0:n.disableExposureLog)?this.lt.incrementNonExposureCount(t):this.lt.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 a(t,e,n,i,r){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:r,time:Date.now()}}e.isExposureEvent=function({eventName:t}){return t===i||t===n},e.createGateExposure=function(t,e){return a(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 a(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,r=e.__evaluation,s=!0===(null==(s=null==r?void 0:r.explicit_parameters)?void 0:s.includes(n));let o="",u=null!=(i=null==r?void 0:r.undelegated_secondary_exposures)?i:[];return s&&(o=null!=(i=r.allocated_experiment_name)?i:"",u=r.secondary_exposures),a("statsig::layer_exposure",t,e.details,{config:e.name,parameterName:n,ruleID:e.ruleID,allocatedExperiment:o,isExplicitParameter:String(s)},u)}},972:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigMetadataProvider=void 0;let n={sdkVersion:"0.0.1-beta.16",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 r="default";e.makeFeatureGate=function(t,e,n){return{name:t,details:e,ruleID:null!=(t=null==n?void 0:n.rule_id)?t:r,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:r,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:r,Et: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,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})},n=(Object.defineProperty(e,"__esModule",{value:!0}),e.setObjectInStorage=e.getObjectFromStorage=e.Storage=void 0,n(780));const r={},s={getProviderName:()=>"InMemory",getItemSync(t){return null!=(t=r[t])?t:null},getItem(t){return Promise.resolve(null!=(t=r[t])?t:null)},setItem(t,e){return r[t]=e,Promise.resolve()},removeItem(t){return delete r[t],Promise.resolve()},getAllKeys(){return Promise.resolve(Object.keys(r))}};let o=null;try{"undefined"!=typeof window&&"localStorage"in window&&(o={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!==o&&void 0!==o?o:s,a=u;e.Storage={getProviderName:()=>a.getProviderName(),getItem:t=>a.getItem(t),setItem:(t,e)=>a.setItem(t,e),removeItem:t=>a.removeItem(t),getAllKeys:()=>a.getAllKeys(),getItemSync:t=>{var e;return null!=(e=null==(e=a.getItemSync)?void 0:e.call(a,t))?e:null},setProvider:t=>{u=t,a=t},setDisabled:t=>{a=t?s:u}},e.getObjectFromStorage=function(e){return i(this,void 0,void 0,function*(){var t=yield a.getItem(e);return JSON.parse(null!=t?t:"null")})},e.setObjectInStorage=function(t,e){return i(this,void 0,void 0,function*(){yield a.setItem(t,JSON.stringify(e))})}},412:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.typedJsonParse=void 0;const r=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 r.Log.error(n),null}},556:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getUUID=void 0,e.getUUID=function(){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{Object.defineProperty(e,"__esModule",{value:!0}),e.Lt=void 0,e.Lt=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.ht}static add(t){this.ut.push(t)}static remove(t){t=this.ut.indexOf(t);-1!==t&&this.ut.splice(t,1)}static notify(e){e!==this.ht&&(this.ht=e,this.ut.forEach(t=>t.onVisibilityChanged(e)))}}(e.VisibilityChangeObserver=n).ut=[],n.ht="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 r=Object.getOwnPropertyDescriptor(e,n);r&&("get"in r?e.__esModule:!r.writable&&!r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){t[i=void 0===i?n:i]=e[n]}),r=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),o=(Object.defineProperty(e,"EventLogger",{enumerable:!0,get:function(){return s.EventLogger}}),n(780)),u=(Object.defineProperty(e,"Log",{enumerable:!0,get:function(){return o.Log}}),n(444));Object.defineProperty(e,"Storage",{enumerable:!0,get:function(){return u.Storage}}),r(n(496),e),r(n(856),e),r(n(320),e),r(n(512),e),r(n(500),e),r(n(788),e),r(n(832),e),r(n(780),e),r(n(104),e),r(n(188),e),r(n(264),e),r(n(604),e),r(n(688),e),r(n(808),e),r(n(283),e),r(n(876),e),r(n(972),e),r(n(384),e),r(n(136),e),r(n(296),e),r(n(444),e),r(n(412),e),r(n(84),e),r(n(539),e),r(n(556),e),r(n(408),e),__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{EventLogger:s.EventLogger,Log:o.Log,Storage:u.Storage})},532:(t,e)=>{function u(t){return t.setUTCHours(0,0,0,0),t.getTime()}Object.defineProperty(e,"__esModule",{value:!0}),e.default={compareNumbers(t,e,n){if(null==t||null==e)return!1;var i=Number(t),r=Number(e);if(isNaN(i)||isNaN(r))return!1;switch(n){case"gt":return e{var e=t.indexOf("-");return-1!==e?t.substring(0,e):t},r=((t,e)=>{var n=t.split(".").map(t=>parseInt(t)),i=e.split(".").map(t=>parseInt(t));let r=0;for(;r{var e=String(r),t=String(t),n=o?e.toLowerCase():e,i=o?t.toLowerCase():t;switch(s){case"any":case"none":case"any_case_sensitive":case"none_case_sensitive":return n===i;case"str_starts_with_any":return n.startsWith(i);case"str_ends_with_any":return n.endsWith(i);case"str_contains_any":case"str_contains_none":return n.includes(i);default:return!1}});switch(s){case"none":case"none_case_sensitive":case"str_contains_none":return!e;default:return e}},compareStringWithRegEx(t,e){try{var n=String(t);if(n.length<1e3)return new RegExp(String(e)).test(n)}catch(t){}return!1},compareTime(n,i,r){if(null==n||null==i)return!1;try{let t=new Date(String(n)),e=(isNaN(t.getTime())&&(t=new Date(Number(n))),new Date(String(i)));isNaN(e.getTime())&&(e=new Date(Number(i)));var s=t.getTime(),o=e.getTime();if(isNaN(s)||isNaN(o))return!1;switch(r){case"before":return s{Object.defineProperty(e,"__esModule",{value:!0}),e.resultToLayerEval=e.resultToConfigEval=e.resultToGateEval=e.makeEvalResult=void 0,e.makeEvalResult=function(t){return Object.assign(Object.assign({},{unsupported:!1,bool_value:!1,rule_id:"",secondary_exposures:[],json_value:{},explicit_parameters:null,allocated_experiment_name:null,is_experiment_group:!1,group_name:null,undelegated_secondary_exposures:void 0}),t)},e.resultToGateEval=function(t,e){return{name:t.name,id_type:t.idType,rule_id:e.rule_id,value:e.bool_value,secondary_exposures:e.secondary_exposures}},e.resultToConfigEval=function(t,e){var n;return{name:t.name,id_type:t.idType,rule_id:e.rule_id,value:e.json_value,secondary_exposures:e.secondary_exposures,group:null!=(n=e.group_name)?n:"",group_name:null!=(n=e.group_name)?n:void 0,is_device_based:!1,is_experiment_active:t.isActive,is_user_in_experiment:e.is_experiment_group}},e.resultToLayerEval=function(t,e,n){return{name:t.name,rule_id:n.rule_id,value:n.json_value,secondary_exposures:n.secondary_exposures,undelegated_secondary_exposures:n.undelegated_secondary_exposures,allocated_experiment_name:null!=(t=n.allocated_experiment_name)?t:"",explicit_parameters:null!=(t=n.explicit_parameters)?t:[],group:null!=(t=n.group_name)?t:"",group_name:null!=(t=n.group_name)?t:void 0,is_device_based:!1,is_experiment_active:null==e?void 0:e.isActive,is_user_in_experiment:n.is_experiment_group}}},931:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});const c=n(464),i=n(452),d=n(532),h=n(947);function v(t){return(0,i.SHA256)(t).dataView().getBigUint64(0,!1)}function u(t){return null!=t&&"object"==typeof t}e.default=class{constructor(t){this.vt=t}evaluateGate(t,e){var{spec:t,details:n}=this.Ct("gate",t);return t?{evaluation:(0,h.resultToGateEval)(t,this.ft(t,e)),details:n}:{evaluation:null,details:n}}evaluateConfig(t,e){var{spec:t,details:n}=this.Ct("config",t);return t?{evaluation:(0,h.resultToConfigEval)(t,this.ft(t,e)),details:n}:{evaluation:null,details:n}}evaluateLayer(t,e){var n,{spec:t,details:i}=this.Ct("layer",t);return t?(n=null!=(n=null==(e=this.ft(t,e))?void 0:e.allocated_experiment_name)?n:"",n=this.vt.getSpecAndSourceInfo("config",n).spec,{evaluation:(0,h.resultToLayerEval)(t,n,e),details:i}):{evaluation:null,details:i}}Ct(t,e){t=this.vt.getSpecAndSourceInfo(t,e);return{details:this.Gt(t),spec:t.spec}}Gt(t){var{source:t,spec:e,lcut:n,receivedAt:i}=t;return"Uninitialized"===t||"NoValues"===t?{reason:t}:{reason:t+":"+(null==e?"Unrecognized":"Recognized"),lcut:n,receivedAt:i}}ft(t,e){var n=u(t.defaultValue)?t.defaultValue:void 0;if(!t.enabled)return(0,h.makeEvalResult)({json_value:n,rule_id:"disabled"});var i=[];for(const o of t.rules){var r,s=this.gt(o,e);if(s.unsupported)return s;if(i.push(...s.secondary_exposures),s.bool_value)return this.bt(o.configDelegate,e,i)||(r=function(t,e,n){if(100===t.passPercentage)return!0;if(0===t.passPercentage)return!1;e=v(n.salt+"."+(null!=(n=t.salt)?n:t.id)+"."+(null!=(n=(0,c.getUnitIDFromUser)(e,t.idType))?n:""));return Number(e%BigInt(1e4))<100*t.passPercentage}(o,e,t),(0,h.makeEvalResult)({rule_id:s.rule_id,bool_value:r,json_value:r?s.json_value:n,secondary_exposures:i,undelegated_secondary_exposures:i,is_experiment_group:s.is_experiment_group,group_name:s.group_name}))}return(0,h.makeEvalResult)({json_value:n,secondary_exposures:i,undelegated_secondary_exposures:i,rule_id:"default"})}gt(t,e){var n=[];let i=!0;for(const s of t.conditions){var r=this.yt(s,e);if(r.unsupported)return r;n.push(...r.secondary_exposures),r.bool_value||(i=!1)}return(0,h.makeEvalResult)({rule_id:t.id,bool_value:i,json_value:u(t.returnValue)?t.returnValue:void 0,secondary_exposures:n,is_experiment_group:!0===t.isExperimentGroup,group_name:t.groupName})}yt(t,e){let n=null,i=!1;var r=t.field,s=t.targetValue,o=t.idType,u=t.type;switch(u){case"public":return(0,h.makeEvalResult)({bool_value:!0});case"pass_gate":case"fail_gate":var a=String(s),a=this.Ot(a,e);return(0,h.makeEvalResult)({bool_value:"fail_gate"===u?!a.bool_value:a.bool_value,secondary_exposures:a.secondary_exposures});case"multi_pass_gate":case"multi_fail_gate":return this.jt(s,u,e);case"user_field":case"ip_based":case"ua_based":n=function(t,e){var n;if(null==e||"object"!=typeof t||null==t)return null;var i=t;return null!=(n=null!=(n=null!=(n=null!=(n=null!=(n=i[e])?n:i[e.toLowerCase()])?n:null==(i=null==t?void 0:t.custom)?void 0:i[e])?n:null==(i=null==t?void 0:t.custom)?void 0:i[e.toLowerCase()])?n:null==(i=null==t?void 0:t.privateAttributes)?void 0:i[e])?n:null==(i=null==t?void 0:t.privateAttributes)?void 0:i[e.toLowerCase()]}(e,r);break;case"environment_field":n=function(t,e){if(null==e)return null;t=t.statsigEnvironment;if(null!=t){const n=e.toLowerCase(),i=Object.keys(t).find(t=>t.toLowerCase()===n);return void 0!==i?t[i]:void 0}}(e,r);break;case"current_time":n=Date.now();break;case"user_bucket":a=v(null!==(a=String(null!=(a=null==(a=t.additionalValues)?void 0:a.salt)?a:"")+"."+(0,c.getUnitIDFromUser)(e,o))?a:"");n=Number(a%BigInt(1e3));break;case"unit_id":n=(0,c.getUnitIDFromUser)(e,o);break;default:return(0,h.makeEvalResult)({unsupported:!0})}var l=t.operator;switch(l){case"gt":case"gte":case"lt":case"lte":i=d.default.compareNumbers(n,s,l);break;case"version_gt":case"version_gte":case"version_lt":case"version_lte":case"version_eq":case"version_neq":i=d.default.compareVersions(n,s,l);break;case"any":case"none":case"str_starts_with_any":case"str_ends_with_any":case"str_contains_any":case"str_contains_none":case"any_case_sensitive":case"none_case_sensitive":i=d.default.compareStringInArray(n,s,l);break;case"str_matches":i=d.default.compareStringWithRegEx(n,s);break;case"before":case"after":case"on":i=d.default.compareTime(n,s,l);break;case"eq":i=n==s;break;case"neq":i=n!=s;break;case"in_segment_list":case"not_in_segment_list":return(0,h.makeEvalResult)({unsupported:!0})}return(0,h.makeEvalResult)({bool_value:i})}bt(t,e,n){var i;return t&&(i=this.vt.getSpecAndSourceInfo("config",t).spec,i)?(e=this.ft(i,e),(0,h.makeEvalResult)(Object.assign(Object.assign({},e),{allocated_experiment_name:t,explicit_parameters:i.explicitParameters,secondary_exposures:n.concat(e.secondary_exposures),undelegated_secondary_exposures:n}))):null}Ot(t,e){var n=[];let i=!1;var r=this.vt.getSpecAndSourceInfo("gate",t)["spec"];if(r){r=this.ft(r,e);if(r.unsupported)return r;i=r.bool_value,n.push(...r.secondary_exposures),n.push({gate:t,gateValue:String(i),ruleID:r.rule_id})}return(0,h.makeEvalResult)({bool_value:i,secondary_exposures:n})}jt(t,e,n){if(!Array.isArray(t))return(0,h.makeEvalResult)({unsupported:!0});var i="multi_pass_gate"===e,r=[];let s=!1;for(const u of t){if("string"!=typeof u)return(0,h.makeEvalResult)({unsupported:!0});var o=this.Ot(u,n);if(o.unsupported)return o;if(r.push(...o.secondary_exposures),i?!0===o.bool_value:!1===o.bool_value){s=!0;break}}return(0,h.makeEvalResult)({bool_value:s,secondary_exposures:r})}}},160:function(t,e,n){var i=this&&this.__awaiter||function(t,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=n(464);class s extends r.NetworkCore{constructor(t=null){super(t),this.Rt=(0,r.Lt)(null==t?void 0:t.downloadConfigSpecsUrl,null==t?void 0:t.api,"/download_config_specs","https://api.statsigcdn.com/v1")}fetchConfigSpecs(e){var n;return i(this,void 0,void 0,function*(){console.log("fetch latest");var t=yield this.get({sdkKey:e,url:this.Rt});return null!=(n=null==t?void 0:t.body)?n:null})}}e.default=s},480:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=n(464);e.default=class{constructor(){this.wt=null,this.xt="Uninitialized",this.Nt=0,this.It=0}setValuesFromDataAdapter(t){var e;t&&!0===(null==(e=(0,i.typedJsonParse)(t.data,"has_updates","Failed to parse DownloadConfigSpecsResponse"))?void 0:e.has_updates)&&(this.Nt=e.time,this.It=t.receivedAt,this.xt=t.source,this.wt=e)}reset(){this.wt=null,this.xt="Loading"}finalize(){this.wt||(this.xt="NoValues")}getSpecAndSourceInfo(t,e){var t=this.Mt(t);return{spec:null!=(t=null==t?void 0:t.find(t=>t.name===e))?t:null,source:this.xt,lcut:this.Nt,receivedAt:this.It}}Mt(t){var e;switch(t){case"gate":return null==(e=this.wt)?void 0:e.feature_gates;case"config":return null==(e=this.wt)?void 0:e.dynamic_configs;case"layer":return null==(e=this.wt)?void 0:e.layer_configs}}}},348:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});n(464).StatsigMetadataProvider.add({sdkType:"js-on-device-eval-client"})},368:function(t,e,n){var i=this&&this.__awaiter||function(t,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const u=n(464),r=n(931),s=n(160),o=n(480),a=n(4);class l extends u.StatsigClientBase{constructor(t,e=null){var n=new s.default(e);super(t,null!=(t=null==e?void 0:e.dataAdapter)?t:new a.StatsigSpecsDataAdapter,n,e),(0,u.monitorClass)(this.u,this),(0,u.monitorClass)(this.u,n),this.P=null!=e?e:{},this.A=n,this.vt=new o.default,this.Tt=new r.default(this.vt)}initializeSync(){this.vt.reset();var t=this.dataAdapter.getDataSync();this.vt.setValuesFromDataAdapter(t),this.vt.finalize(),this.ct("Ready",t),this.Dt(t)}initializeAsync(){return i(this,void 0,void 0,function*(){this.vt.reset(),this.ct("Loading",null);var t=this.dataAdapter.getDataSync();this.vt.setValuesFromDataAdapter(t),t=yield this.dataAdapter.getDataAsync(t),this.vt.setValuesFromDataAdapter(t),this.vt.finalize(),this.ct("Ready",t)})}shutdown(){return i(this,void 0,void 0,function*(){yield this.lt.shutdown()})}checkGate(t,e,n){return this.getFeatureGate(t,e,n).value}getFeatureGate(t,e,n){e=(0,u.normalizeUser)(e,this.P.environment);var{evaluation:i,details:r}=this.Tt.evaluateGate(t,e),r=(0,u.makeFeatureGate)(t,r,i);return this.dt(t,(0,u.createGateExposure)(e,r),n),this.tt({name:"gate_evaluation",gate:r}),r}getDynamicConfig(t,e,n){t=this.kt("dynamic_config",t,e,n);return this.tt({name:"dynamic_config_evaluation",dynamicConfig:t}),t}getExperiment(t,e,n){t=this.kt("experiment",t,e,n);return this.tt({name:"experiment_evaluation",experiment:t}),t}getLayer(n,i,r){i=(0,u.normalizeUser)(i,this.P.environment);const{evaluation:s,details:t}=this.Tt.evaluateLayer(n,i),o=(0,u.makeLayer)(n,t,s,t=>{var e;return s&&t in s.value&&this.dt(n,(0,u.createLayerParameterExposure)(i,o,t),r),null!=(e=null==(e=null===s||void 0===s?void 0:s.value)?void 0:e[t])?e:null});return this.tt({name:"layer_evaluation",layer:o}),o}logEvent(t,e){this.lt.enqueue(Object.assign(Object.assign({},t),{user:e,time:Date.now()}))}Dt(t){this.dataAdapter.getDataAsync(t).catch(t=>{u.Log.error("An error occurred after update.",t)})}kt(t,e,n,i){n=(0,u.normalizeUser)(n,this.P.environment);var{evaluation:r,details:s}=this.Tt.evaluateConfig(e,n),s=(0,u.makeDynamicConfig)(e,s,r),r="experiment"===t?null==(t=null==(r=this.Pt)?void 0:r.getExperimentOverride)?void 0:t.call(r,s,n,i):null==(r=null==(t=this.Pt)?void 0:t.getDynamicConfigOverride)?void 0:r.call(t,s,n,i),t=null!=r?r:s;return this.dt(e,(0,u.createConfigExposure)(n,t),i),t}}e.default=l},4:function(t,e,n){var i=this&&this.__awaiter||function(t,o,u,a){return new(u=u||Promise)(function(n,e){function i(t){try{s(a.next(t))}catch(t){e(t)}}function r(t){try{s(a.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,r)}s((a=a.apply(t,o||[])).next())})},r=(Object.defineProperty(e,"__esModule",{value:!0}),e.StatsigSpecsDataAdapter=void 0,n(464));const s=n(160);class o extends r.DataAdapterCore{constructor(){super("SpecsDataAdapter","specs"),this.A=null}attach(t,e){super.attach(t,e),this.A=new s.default(null!=e?e:{})}S(t,e){var n;return i(this,void 0,void 0,function*(){return null!=(n=yield null==(n=this.A)?void 0:n.fetchConfigSpecs(this.N()))?n:null})}}e.StatsigSpecsDataAdapter=o},452:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SHA256=void 0;const i=n(891);Object.defineProperty(e,"SHA256",{enumerable:!0,get:function(){return i.SHA256}})},891:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SHA256=void 0,e.SHA256=function(t){return(new i).update(t)};const n=[-2147483648,8388608,32768,128],o=[24,16,8,0],m=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];class i{constructor(){this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.lastByteIndex=-1}update(n){if(!this.finalized){if("string"!=typeof n)throw new Error('Must be of type "string"');var i;let t=0,e;for(var r=n.length,s=this.blocks;t>2]|=i<>2]|=(192|i>>6)<>2]|=(224|i>>12)<>2]|=(240|i>>18)<>2]|=(128|i>>12&63)<>2]|=(128|i>>6&63)<>2]|=(128|63&i)<>2]|=n[3&e],this.block=t[16],56<=e&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash())}hash(){var t=this.blocks;let e=this.h0,n=this.h1,i=this.h2,r=this.h3,s=this.h4,o=this.h5,u=this.h6,a=this.h7,l,c,d,h,v,_,f,g,p,b,y;for(l=16;l<64;++l)v=t[l-15],c=(v>>>7|v<<25)^(v>>>18|v<<14)^v>>>3,v=t[l-2],d=(v>>>17|v<<15)^(v>>>19|v<<13)^v>>>10,t[l]=t[l-16]+c+t[l-7]+d<<0;for(y=n&i,l=0;l<64;l+=4)this.first?(g=704751109,v=t[0]-210244248,a=v-1521486534<<0,r=v+143694565<<0,this.first=!1):(c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),d=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),g=e&n,h=g^e&i^y,f=s&o^~s&u,v=a+d+f+m[l]+t[l],_=c+h,a=r+v<<0,r=v+_<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),d=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),p=r&e,h=p^r&n^g,f=a&s^~a&o,v=u+d+f+m[l+1]+t[l+1],_=c+h,u=i+v<<0,i=v+_<<0,c=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),d=(u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7),b=i&r,h=b^i&e^p,f=u&a^~u&s,v=o+d+f+m[l+2]+t[l+2],_=c+h,o=n+v<<0,n=v+_<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),d=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),y=n&i,h=y^n&r^b,f=o&u^~o&a,v=s+d+f+m[l+3]+t[l+3],_=c+h,s=e+v<<0,e=v+_<<0;this.h0=this.h0+e<<0,this.h1=this.h1+n<<0,this.h2=this.h2+i<<0,this.h3=this.h3+r<<0,this.h4=this.h4+s<<0,this.h5=this.h5+o<<0,this.h6=this.h6+u<<0,this.h7=this.h7+a<<0}arrayBuffer(){return this.At().buffer}dataView(){return this.At().dataView}At(){this.finalize();var t=new ArrayBuffer(32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),e.setUint32(28,this.h7),{dataView:e,buffer:t}}}}},i={};function r(t){var e=i[t];return void 0!==e||(e=i[t]={exports:{}},n[t].call(e.exports,e,e.exports,r)),e.exports}r.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,s=(r(348),r(368));s.default;const o=r(4);__STATSIG__=Object.assign(Object.assign({},null!==__STATSIG__&&void 0!==__STATSIG__?__STATSIG__:{}),{StatsigSpecsDataAdapter:o.StatsigSpecsDataAdapter,StatsigOnDeviceEvalClient:s.default}),e.default=__STATSIG__}return t.default})()); \ No newline at end of file diff --git a/samples/web-minified/src/main.js b/samples/web-minified/src/main.js index fb4f74a0..d1f940dd 100644 --- a/samples/web-minified/src/main.js +++ b/samples/web-minified/src/main.js @@ -16,6 +16,9 @@ window.fetch = (url, args) => { const client = new StatsigClient(DEMO_CLIENT_KEY, { userID: 'a-user' }); (async () => { + const timeout = setTimeout(() => { + test('test timeout', () => false); + }, 5000); await client.initializeAsync(); // prime cache client.on('*', (event) => { @@ -69,4 +72,7 @@ const client = new StatsigClient(DEMO_CLIENT_KEY, { userID: 'a-user' }); // SDK Exception test('logged to sdk_exception', () => requests[3].url.startsWith('https://statsigapi.net/v1/sdk_exception')); + + clearTimeout(timeout); + test('test timeout', () => true); })(); diff --git a/tsconfig.base.json b/tsconfig.base.json index 8ba386b0..bb8a856c 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -34,6 +34,7 @@ ], "@statsig/sha256": ["packages/sha256/src/index.ts"], "combination-tests": ["packages/combination-tests/src/index.ts"], + "statsig-rn-shared": ["samples/rn-shared/src/index.ts"], "statsig-test-helpers": ["packages/test-helpers/src/index.ts"] }, "rootDir": ".",