@featbit/js-client-sdk 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +289 -0
  3. package/esm/constants.d.ts +7 -0
  4. package/esm/constants.js +8 -0
  5. package/esm/constants.js.map +1 -0
  6. package/esm/events.d.ts +14 -0
  7. package/esm/events.js +27 -0
  8. package/esm/events.js.map +1 -0
  9. package/esm/featbit.d.ts +34 -0
  10. package/esm/featbit.js +382 -0
  11. package/esm/featbit.js.map +1 -0
  12. package/esm/index.d.ts +4 -0
  13. package/esm/index.js +5 -0
  14. package/esm/index.js.map +1 -0
  15. package/esm/logger.d.ts +4 -0
  16. package/esm/logger.js +24 -0
  17. package/esm/logger.js.map +1 -0
  18. package/esm/network.service.d.ts +27 -0
  19. package/esm/network.service.js +288 -0
  20. package/esm/network.service.js.map +1 -0
  21. package/esm/optionMessages.d.ts +5 -0
  22. package/esm/optionMessages.js +16 -0
  23. package/esm/optionMessages.js.map +1 -0
  24. package/esm/queue.d.ts +8 -0
  25. package/esm/queue.js +35 -0
  26. package/esm/queue.js.map +1 -0
  27. package/esm/store.d.ts +20 -0
  28. package/esm/store.js +143 -0
  29. package/esm/store.js.map +1 -0
  30. package/esm/throttleutil.d.ts +9 -0
  31. package/esm/throttleutil.js +133 -0
  32. package/esm/throttleutil.js.map +1 -0
  33. package/esm/types.d.ts +94 -0
  34. package/esm/types.js +24 -0
  35. package/esm/types.js.map +1 -0
  36. package/esm/umd.d.ts +2 -0
  37. package/esm/utils.d.ts +11 -0
  38. package/esm/utils.js +142 -0
  39. package/esm/utils.js.map +1 -0
  40. package/package.json +48 -0
  41. package/src/constants.ts +7 -0
  42. package/src/events.ts +29 -0
  43. package/src/featbit.ts +343 -0
  44. package/src/index.ts +6 -0
  45. package/src/logger.ts +18 -0
  46. package/src/network.service.ts +223 -0
  47. package/src/optionMessages.ts +13 -0
  48. package/src/queue.ts +23 -0
  49. package/src/store.ts +169 -0
  50. package/src/throttleutil.ts +72 -0
  51. package/src/types.ts +113 -0
  52. package/src/umd.ts +15 -0
  53. package/src/utils.ts +173 -0
  54. package/umd/featbit-js-client-sdk-2.0.0.js +2 -0
  55. package/umd/featbit-js-client-sdk-2.0.0.js.map +1 -0
  56. package/umd/featbit-js-client-sdk.js +2 -0
  57. package/umd/featbit-js-client-sdk.js.map +1 -0
package/src/store.ts ADDED
@@ -0,0 +1,169 @@
1
+ import {featureFlagEvaluatedTopic} from "./constants";
2
+ import {eventHub} from "./events";
3
+ import {logger} from "./logger";
4
+ import {
5
+ FeatureFlagUpdateOperation, FeatureFlagValue,
6
+ IDataStore,
7
+ IFeatureFlag,
8
+ IFeatureFlagChange,
9
+ InsightType
10
+ } from "./types";
11
+ import {parseVariation} from "./utils";
12
+
13
+ const DataStoreStorageKey = 'fb-datastore';
14
+
15
+ class Store {
16
+ private _userId: string | null = null;
17
+
18
+ private _store: IDataStore = {
19
+ featureFlags: {} as { [key: string]: IFeatureFlag }
20
+ }
21
+
22
+ constructor() { }
23
+
24
+ set userId(id: string) {
25
+ this._userId = id;
26
+ this._loadFromStorage();
27
+ }
28
+
29
+ getFeatureFlag(key: string): IFeatureFlag {
30
+ return this._store.featureFlags[key];
31
+ }
32
+
33
+ getVariation(key: string): FeatureFlagValue {
34
+ const featureFlag = this._store.featureFlags[key];
35
+
36
+ if (!featureFlag) {
37
+ return undefined;
38
+ }
39
+
40
+ eventHub.emit(featureFlagEvaluatedTopic, {
41
+ insightType: InsightType.featureFlagUsage,
42
+ id: featureFlag.id,
43
+ timestamp: Date.now(),
44
+ sendToExperiment: featureFlag.sendToExperiment,
45
+ variation: featureFlag.variationOptions.find(o => o.value === featureFlag.variation)
46
+ });
47
+
48
+ const { variationType, variation } = featureFlag;
49
+
50
+ return parseVariation(variationType, variation);
51
+ }
52
+
53
+ setFullData(data: IDataStore) {
54
+ this._store = {
55
+ featureFlags: {} as { [key: string]: IFeatureFlag }
56
+ };
57
+
58
+ this._dumpToStorage(this._store);
59
+ this.updateBulkFromRemote(data);
60
+ }
61
+
62
+ getFeatureFlags(): { [key: string]: IFeatureFlag } {
63
+ return this._store.featureFlags;
64
+ }
65
+
66
+ updateStorageBulk(data: IDataStore, storageKey: string, onlyInsertNewElement: boolean) {
67
+ let dataStoreStr = localStorage.getItem(storageKey);
68
+ let store: IDataStore | null = null;
69
+
70
+ try {
71
+ if (dataStoreStr && dataStoreStr.trim().length > 0) {
72
+ store = JSON.parse(dataStoreStr);
73
+ }
74
+ } catch (err) {
75
+ logger.logDebug(`error while loading local data store: ${storageKey}` + err);
76
+ }
77
+
78
+ if (!!store) {
79
+ const { featureFlags } = data;
80
+
81
+ Object.keys(featureFlags).forEach(id => {
82
+ const remoteFf = featureFlags[id];
83
+ const localFf = store!.featureFlags[id];
84
+
85
+ const predicate = !localFf || !onlyInsertNewElement;
86
+ if (predicate) {
87
+ store!.featureFlags[remoteFf.id] = Object.assign({}, remoteFf);
88
+ }
89
+ });
90
+
91
+ this._dumpToStorage(store, storageKey);
92
+ }
93
+ }
94
+
95
+ updateBulkFromRemote(data: IDataStore) {
96
+ const storageKey = `${DataStoreStorageKey}-${this._userId}`;
97
+
98
+ this.updateStorageBulk(data, storageKey, false);
99
+
100
+ this._loadFromStorage();
101
+ }
102
+
103
+ private _emitUpdateEvents(updatedFeatureFlags: any[]): void {
104
+ if (updatedFeatureFlags.length > 0) {
105
+ updatedFeatureFlags.forEach(({ id, operation, data }) => eventHub.emit(`ff_${operation}:${data.id}`, data));
106
+ eventHub.emit(`ff_${FeatureFlagUpdateOperation.update}`, updatedFeatureFlags.map(item => item.data));
107
+ }
108
+ }
109
+
110
+ private _dumpToStorage(store?: IDataStore, localStorageKey?: string): void {
111
+ if (store) {
112
+ const storageKey = localStorageKey || `${DataStoreStorageKey}-${this._userId}`;
113
+ localStorage.setItem(storageKey, JSON.stringify(store));
114
+ return;
115
+ }
116
+ const storageKey = `${DataStoreStorageKey}-${this._userId}`;
117
+ localStorage.setItem(storageKey, JSON.stringify(this._store));
118
+ }
119
+
120
+ private _loadFromStorage(): void {
121
+ try {
122
+ const storageKey = `${DataStoreStorageKey}-${this._userId}`;
123
+ let dataStoreStr = localStorage.getItem(storageKey);
124
+
125
+ let shouldDumpToStorage = false;
126
+
127
+ if (dataStoreStr && dataStoreStr.trim().length > 0) {
128
+ // compare _store and dataStoreStr data and send notification if different
129
+ const storageData: IDataStore = JSON.parse(dataStoreStr);
130
+
131
+ const updatedFeatureFlags = Object.keys(storageData.featureFlags).filter(key => {
132
+ const storageFf = storageData.featureFlags[key];
133
+ const ff = this._store.featureFlags[key];
134
+ return !ff || storageFf.variation !== ff.variation || storageFf.variationType !== ff.variationType;
135
+ }).map(key => {
136
+ const storageFf = storageData.featureFlags[key];
137
+ const ff = this._store.featureFlags[key];
138
+
139
+ return {
140
+ id: key,
141
+ operation: FeatureFlagUpdateOperation.update,
142
+ sendToExperiment: storageFf.sendToExperiment,
143
+ data: {
144
+ id: key,
145
+ oldValue: ff ? parseVariation(ff.variationType, ff.variation): undefined,
146
+ newValue: parseVariation(storageFf.variationType, storageFf.variation)
147
+ } as IFeatureFlagChange
148
+ }
149
+ });
150
+
151
+ this._store = storageData;
152
+ this._emitUpdateEvents(updatedFeatureFlags);
153
+ } else {
154
+ this._store = {
155
+ featureFlags: {} as { [key: string]: IFeatureFlag }
156
+ };
157
+ }
158
+
159
+ if (shouldDumpToStorage) {
160
+ this._dumpToStorage();
161
+ }
162
+
163
+ } catch (err) {
164
+ logger.logDebug('error while loading local data store: ' + err);
165
+ }
166
+ }
167
+ }
168
+
169
+ export default new Store();
@@ -0,0 +1,72 @@
1
+ import { uuid } from "./utils";
2
+
3
+ const API_CALL_RESULTS : {[key: string]: string} = {};
4
+ const FOOT_PRINTS: string[] = [];
5
+ let _throttleWait: number = 0; // send immediately
6
+
7
+ class ThrottleUtil {
8
+ private _key: string;
9
+
10
+ constructor(){
11
+ this._key = uuid();
12
+ }
13
+
14
+ setKey(key: string) {
15
+ this._key = key || this._key;
16
+ }
17
+
18
+ throttle(fn: Function, ms: number) {
19
+ let timer:any = 0
20
+ return function(...args) {
21
+ clearTimeout(timer)
22
+ timer = setTimeout(fn.bind(null, ...args), ms || 0)
23
+ }
24
+ }
25
+
26
+ throttleAsync (callback: any): any {
27
+ let waiting = false;
28
+
29
+ let getFootprint = (args: any): string => {
30
+ const params = args.map(arg => {
31
+ if (
32
+ typeof arg === 'object' &&
33
+ typeof arg !== "function" &&
34
+ arg !== null
35
+ ) {
36
+ if (Array.isArray(arg)) {
37
+ return arg.map(a => ({...a, ...{timestamp: null}}))
38
+ } else {
39
+ return {...arg, ...{timestamp: null}};
40
+ }
41
+ }
42
+
43
+ return arg;
44
+ });
45
+
46
+ return this._key + JSON.stringify(params);
47
+ };
48
+
49
+ return async function (...args) {
50
+ const footprint = getFootprint(args);
51
+ const idx = FOOT_PRINTS.findIndex(f => f === footprint);
52
+ if (!waiting || idx === -1) {
53
+ waiting = true;
54
+ if (idx === -1) {
55
+ FOOT_PRINTS.push(footprint);
56
+ }
57
+
58
+ API_CALL_RESULTS[footprint] = await callback.apply(null, args);
59
+
60
+ setTimeout(function () {
61
+ waiting = false;
62
+ }, _throttleWait);
63
+ }
64
+
65
+ return API_CALL_RESULTS[footprint];
66
+ }
67
+ }
68
+ }
69
+
70
+ export default new ThrottleUtil();
71
+
72
+
package/src/types.ts ADDED
@@ -0,0 +1,113 @@
1
+ export type FeatureFlagValue = any;
2
+
3
+ export interface IFeatureFlagSet {
4
+ [key: string]: FeatureFlagValue;
5
+ }
6
+
7
+ export interface IFeatureFlagChange {
8
+ id: string,
9
+ oldValue: FeatureFlagValue,
10
+ newValue: FeatureFlagValue
11
+ }
12
+
13
+ export interface IOption {
14
+ secret: string,
15
+ anonymous?: boolean,
16
+ bootstrap?: IFeatureFlag[],
17
+ streamingUri?: string,
18
+ eventsUri?: string,
19
+
20
+ // deprecated, this option will be removed in the future, please use streamingUri and eventsUri instead
21
+ api?: string,
22
+
23
+ appType?: string,
24
+ user?: IUser,
25
+ enableDataSync?: boolean
26
+ }
27
+
28
+ export interface IUser {
29
+ name: string,
30
+ keyId: string,
31
+ customizedProperties?: ICustomizedProperty[]
32
+ }
33
+
34
+ export interface ICustomizedProperty {
35
+ name: string,
36
+ value: string | number | boolean
37
+ }
38
+
39
+ export interface IVariationOption {
40
+ id: number,
41
+ value: FeatureFlagValue
42
+ }
43
+
44
+ export interface IFeatureFlagVariation {
45
+ id?: string,
46
+ sendToExperiment?: boolean
47
+ timestamp?: number,
48
+ variation?: {
49
+ id: number,
50
+ value: FeatureFlagValue,
51
+ }
52
+ }
53
+
54
+ export interface IFeatureFlagVariationBuffer {
55
+ id: string,
56
+ timestamp: number,
57
+ variationValue: FeatureFlagValue
58
+ }
59
+
60
+ export enum InsightType {
61
+ featureFlagUsage = 1,
62
+ customEvent = 2,
63
+ pageView = 3,
64
+ click = 4
65
+ }
66
+
67
+ export enum VariationDataType {
68
+ string = 'string',
69
+ boolean = 'boolean',
70
+ number = 'number',
71
+ json = 'json',
72
+ }
73
+
74
+ export interface IInsight extends IFeatureFlagVariation, ICustomEvent {
75
+ insightType: InsightType
76
+ }
77
+
78
+ export interface IFeatureFlagBase {
79
+ id: string, // the keyname
80
+ variation: FeatureFlagValue,
81
+ variationType: VariationDataType
82
+ }
83
+
84
+ export interface IFeatureFlag extends IFeatureFlagBase{
85
+ sendToExperiment: boolean,
86
+ timestamp: number,
87
+ variationOptions: IVariationOption[]
88
+ }
89
+
90
+ export interface IDataStore {
91
+ featureFlags: { [key: string]: IFeatureFlag }
92
+ }
93
+
94
+ export enum StreamResponseEventType {
95
+ full = 'full',
96
+ patch = 'patch'
97
+ }
98
+
99
+ export enum FeatureFlagUpdateOperation {
100
+ update = 'update'
101
+ }
102
+
103
+ export interface IStreamResponse {
104
+ eventType: StreamResponseEventType,
105
+ userKeyId: string,
106
+ featureFlags: IFeatureFlag[]
107
+ }
108
+
109
+ export interface ICustomEvent {
110
+ type?: string,
111
+ eventName: string,
112
+ numericValue?: number
113
+ }
package/src/umd.ts ADDED
@@ -0,0 +1,15 @@
1
+ // This file is only for umd version
2
+
3
+ const html = document.querySelector('html');
4
+ const waittime = 500;
5
+ if (html) {
6
+ html.style.visibility = 'hidden';
7
+ setTimeout(() => html.style.visibility = 'visible', waittime);
8
+ }
9
+
10
+ import fbClient from './featbit';
11
+ import { logger } from './logger';
12
+
13
+ logger.logDebug(`version: __VERSION__`);
14
+
15
+ export { fbClient }
package/src/utils.ts ADDED
@@ -0,0 +1,173 @@
1
+ import {FeatureFlagValue, IOption, IUser, VariationDataType} from "./types";
2
+ import {logger} from "./logger";
3
+ import OptionMessages from "./optionMessages";
4
+
5
+
6
+ // generate default user info
7
+ export function generateorGetGuid(): string {
8
+ let guid = localStorage.getItem("fb-guid");
9
+ if (guid) {
10
+ return guid;
11
+ }
12
+ else {
13
+ const id = uuid();
14
+ localStorage.setItem("fb-guid", id);
15
+ return id;
16
+ }
17
+ }
18
+
19
+ export function serializeUser(user: IUser | undefined): string {
20
+ if (!user) {
21
+ return '';
22
+ }
23
+
24
+ const builtInProperties = `${user.keyId},${user.name}`;
25
+
26
+ const customizedProperties = user.customizedProperties?.map(p => `${p.name}:${p.value}`).join(',');
27
+
28
+ return `${builtInProperties},${customizedProperties}`;
29
+ }
30
+
31
+ export function isNumeric(str: string) {
32
+ if (typeof str != "string") return false // we only process strings!
33
+ // @ts-ignore
34
+ return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
35
+ !isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail
36
+ }
37
+
38
+ export function parseVariation(type: VariationDataType, value: string): FeatureFlagValue {
39
+ switch (type) {
40
+ case VariationDataType.string:
41
+ return value;
42
+ case VariationDataType.boolean:
43
+ if (value === 'true') {
44
+ return true;
45
+ }
46
+
47
+ if (value === 'false') {
48
+ return false;
49
+ }
50
+
51
+ logger.log(`expected boolean value, but got ${value}`);
52
+ return value;
53
+ case VariationDataType.number:
54
+ if (isNumeric(value)) {
55
+ return +value;
56
+ }
57
+
58
+ logger.log(`expected numeric value, but got ${value}`);
59
+ return value;
60
+ case VariationDataType.json:
61
+ try {
62
+ return JSON.parse(value);
63
+ }
64
+ catch (e) {
65
+ logger.log(`expected json value, but got ${value}`);
66
+ return value;
67
+ }
68
+ default:
69
+ logger.log(`unexpected variation type ${type} for ${value}`);
70
+ return value;
71
+ }
72
+ }
73
+
74
+ export function uuid(): string {
75
+ let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
76
+ var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
77
+ return v.toString(16);
78
+ });
79
+
80
+ return uuid;
81
+ }
82
+
83
+ export function validateUser(user: IUser): string | null {
84
+ if (!user) {
85
+ return OptionMessages.mandatory('user')
86
+ }
87
+
88
+ const { keyId, name } = user;
89
+
90
+ if (keyId === undefined || keyId === null || keyId.trim() === '') {
91
+ return OptionMessages.mandatory('user.keyId');
92
+ }
93
+
94
+ if (name === undefined || name === null || name.trim() === '') {
95
+ return OptionMessages.mandatory('user.name');
96
+ }
97
+
98
+ return null;
99
+ }
100
+
101
+ export function isNullOrUndefinedOrWhiteSpace(value?: string): boolean {
102
+ return value === null || value === undefined || value.trim() === '';
103
+ }
104
+
105
+ export function validateOption(option: IOption): string | null {
106
+ if (option === undefined || option === null) {
107
+ return OptionMessages.mandatory('option')
108
+ }
109
+
110
+ const { streamingUri, eventsUri, secret, anonymous, user, enableDataSync } = option;
111
+
112
+ const streamingUriMissing = isNullOrUndefinedOrWhiteSpace(streamingUri);
113
+ const eventsUriMissing = isNullOrUndefinedOrWhiteSpace(eventsUri);
114
+
115
+ if (enableDataSync && (streamingUriMissing || eventsUriMissing))
116
+ {
117
+ if (eventsUriMissing) {
118
+ return OptionMessages.partialEndpoint('eventsUri');
119
+ }
120
+
121
+ if (streamingUriMissing) {
122
+ return OptionMessages.partialEndpoint('streamingUri');
123
+ }
124
+ }
125
+
126
+ if (enableDataSync && isNullOrUndefinedOrWhiteSpace(secret)) {
127
+ return OptionMessages.invalidParam('secret');
128
+ }
129
+
130
+ // validate user
131
+ if (!!anonymous === false && !user) {
132
+ return OptionMessages.mandatory('user');
133
+ }
134
+
135
+ if (user) {
136
+ return validateUser(user);
137
+ }
138
+
139
+ return null;
140
+ }
141
+
142
+ /********************** encode text begin *****************************/
143
+ const alphabet = {
144
+ "0": "Q",
145
+ "1": "B",
146
+ "2": "W",
147
+ "3": "S",
148
+ "4": "P",
149
+ "5": "H",
150
+ "6": "D",
151
+ "7": "X",
152
+ "8": "Z",
153
+ "9": "U",
154
+ }
155
+
156
+ function encodeNumber(param: number, length: number): string {
157
+ var s = "000000000000" + param;
158
+ const numberWithLeadingZeros = s.slice(s.length - length);
159
+ return numberWithLeadingZeros.split('').map(n => alphabet[n]).join('');
160
+ }
161
+
162
+ // generate connection token
163
+ export function generateConnectionToken(text: string): string {
164
+ text = text.replace(/=*$/, '');
165
+ const timestamp = Date.now();
166
+ const timestampCode = encodeNumber(timestamp, timestamp.toString().length);
167
+ // get random number less than the length of the text as the start point, and it must be greater or equal to 2
168
+ const start = Math.max(Math.floor(Math.random() * text.length), 2);
169
+
170
+ return `${encodeNumber(start, 3)}${encodeNumber(timestampCode.length, 2)}${text.slice(0, start)}${timestampCode}${text.slice(start)}`;
171
+ }
172
+
173
+ /********************** encode text end *****************************/
@@ -0,0 +1,2 @@
1
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(this,(()=>(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{fbClient:()=>R});var n,r,i,o,a=new(function(){function t(t){this.events=t||{}}return t.prototype.subscribe=function(t,e){var n=this;return(this.events[t]||(this.events[t]=[])).push(e),{unsubscribe:function(){return n.events[t]&&n.events[t].splice(n.events[t].indexOf(e)>>>0,1)}}},t.prototype.unsubscribe=function(t,e){this.events[t]&&this.events[t].splice(this.events[t].indexOf(e)>>>0,1)},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];(this.events[t]||[]).forEach((function(t){return t.apply(void 0,e)}))},t}()),u="insights.flush",s="featureflag.evaluated.topic",c="featureflag.evaluated.buffer.topic",l="network.websocket.reconnect",f="fb-user",p=window.location.search,d=new URLSearchParams(p).get("debugmode"),h={logDebug:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];"true"===d&&console.log.apply(console,t)},log:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];console.log.apply(console,t)}};!function(t){t[t.featureFlagUsage=1]="featureFlagUsage",t[t.customEvent=2]="customEvent",t[t.pageView=3]="pageView",t[t.click=4]="click"}(n||(n={})),function(t){t.string="string",t.boolean="boolean",t.number="number",t.json="json"}(r||(r={})),function(t){t.full="full",t.patch="patch"}(i||(i={})),function(t){t.update="update"}(o||(o={}));const v=function(){function t(){}return t.partialEndpoint=function(t){return"You have set custom uris without specifying the ".concat(t," URI; connections may not work properly")},t.invalidParam=function(t){return"The ".concat(t," option is not passed in or its value is invalid")},t.mandatory=function(t){return"".concat(t," is mandatory")},t}();function g(t){var e;if(!t)return"";var n="".concat(t.keyId,",").concat(t.name),r=null===(e=t.customizedProperties)||void 0===e?void 0:e.map((function(t){return"".concat(t.name,":").concat(t.value)})).join(",");return"".concat(n,",").concat(r)}function y(t,e){switch(t){case r.string:return e;case r.boolean:return"true"===e||"false"!==e&&(h.log("expected boolean value, but got ".concat(e)),e);case r.number:return"string"!=typeof(n=e)||isNaN(n)||isNaN(parseFloat(n))?(h.log("expected numeric value, but got ".concat(e)),e):+e;case r.json:try{return JSON.parse(e)}catch(t){return h.log("expected json value, but got ".concat(e)),e}default:return h.log("unexpected variation type ".concat(t," for ").concat(e)),e}var n}function m(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))}function b(t){if(!t)return v.mandatory("user");var e=t.keyId,n=t.name;return null==e||""===e.trim()?v.mandatory("user.keyId"):null==n||""===n.trim()?v.mandatory("user.name"):null}function w(t){return null==t||""===t.trim()}var x={0:"Q",1:"B",2:"W",3:"S",4:"P",5:"H",6:"D",7:"X",8:"Z",9:"U"};function _(t,e){var n="000000000000"+t;return n.slice(n.length-e).split("").map((function(t){return x[t]})).join("")}var k="fb-datastore",S=function(){function t(){this._userId=null,this._store={featureFlags:{}}}return Object.defineProperty(t.prototype,"userId",{set:function(t){this._userId=t,this._loadFromStorage()},enumerable:!1,configurable:!0}),t.prototype.getFeatureFlag=function(t){return this._store.featureFlags[t]},t.prototype.getVariation=function(t){var e=this._store.featureFlags[t];if(e)return a.emit(s,{insightType:n.featureFlagUsage,id:e.id,timestamp:Date.now(),sendToExperiment:e.sendToExperiment,variation:e.variationOptions.find((function(t){return t.value===e.variation}))}),y(e.variationType,e.variation)},t.prototype.setFullData=function(t){this._store={featureFlags:{}},this._dumpToStorage(this._store),this.updateBulkFromRemote(t)},t.prototype.getFeatureFlags=function(){return this._store.featureFlags},t.prototype.updateStorageBulk=function(t,e,n){var r=localStorage.getItem(e),i=null;try{r&&r.trim().length>0&&(i=JSON.parse(r))}catch(t){h.logDebug("error while loading local data store: ".concat(e)+t)}if(i){var o=t.featureFlags;Object.keys(o).forEach((function(t){var e=o[t];(!i.featureFlags[t]||!n)&&(i.featureFlags[e.id]=Object.assign({},e))})),this._dumpToStorage(i,e)}},t.prototype.updateBulkFromRemote=function(t){var e="".concat(k,"-").concat(this._userId);this.updateStorageBulk(t,e,!1),this._loadFromStorage()},t.prototype._emitUpdateEvents=function(t){t.length>0&&(t.forEach((function(t){t.id;var e=t.operation,n=t.data;return a.emit("ff_".concat(e,":").concat(n.id),n)})),a.emit("ff_".concat(o.update),t.map((function(t){return t.data}))))},t.prototype._dumpToStorage=function(t,e){if(t){var n=e||"".concat(k,"-").concat(this._userId);localStorage.setItem(n,JSON.stringify(t))}else{var r="".concat(k,"-").concat(this._userId);localStorage.setItem(r,JSON.stringify(this._store))}},t.prototype._loadFromStorage=function(){var t=this;try{var e="".concat(k,"-").concat(this._userId),n=localStorage.getItem(e);if(n&&n.trim().length>0){var r=JSON.parse(n),i=Object.keys(r.featureFlags).filter((function(e){var n=r.featureFlags[e],i=t._store.featureFlags[e];return!i||n.variation!==i.variation||n.variationType!==i.variationType})).map((function(e){var n=r.featureFlags[e],i=t._store.featureFlags[e];return{id:e,operation:o.update,sendToExperiment:n.sendToExperiment,data:{id:e,oldValue:i?y(i.variationType,i.variation):void 0,newValue:y(n.variationType,n.variation)}}}));this._store=r,this._emitUpdateEvents(i)}else this._store={featureFlags:{}}}catch(t){h.logDebug("error while loading local data store: "+t)}},t}();const T=new S;var F=function(){return F=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},F.apply(this,arguments)},E={},O=[];const D=new(function(){function t(){this._key=m()}return t.prototype.setKey=function(t){this._key=t||this._key},t.prototype.throttle=function(t,e){var n=0;return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];clearTimeout(n),n=setTimeout(t.bind.apply(t,function(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}([null],r,!1)),e||0)}},t.prototype.throttleAsync=function(t){var e=this,n=!1;return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return o=this,a=void 0,s=function(){var i,o,a,u;return function(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){a.label=u[1];break}if(6===u[0]&&a.label<i[1]){a.label=i[1],i=u;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(u);break}i[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}(this,(function(s){switch(s.label){case 0:return i=function(t){var n=t.map((function(t){return"object"==typeof t&&"function"!=typeof t&&null!==t?Array.isArray(t)?t.map((function(t){return F(F({},t),{timestamp:null})})):F(F({},t),{timestamp:null}):t}));return e._key+JSON.stringify(n)}(r),o=O.findIndex((function(t){return t===i})),n&&-1!==o?[3,2]:(n=!0,-1===o&&O.push(i),a=E,u=i,[4,t.apply(null,r)]);case 1:a[u]=s.sent(),setTimeout((function(){n=!1}),0),s.label=2;case 2:return[2,E[i]]}}))},new((u=void 0)||(u=Promise))((function(t,e){function n(t){try{i(s.next(t))}catch(t){e(t)}}function r(t){try{i(s.throw(t))}catch(t){e(t)}}function i(e){var i;e.done?t(e.value):(i=e.value,i instanceof u?i:new u((function(t){t(i)}))).then(n,r)}i((s=s.apply(o,a||[])).next())}));var o,a,u,s}},t}());var I=function(){return I=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},I.apply(this,arguments)},j=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{s(r.next(t))}catch(t){o(t)}}function u(t){try{s(r.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},P=function(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){a.label=u[1];break}if(6===u[0]&&a.label<i[1]){a.label=i[1],i=u;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(u);break}i[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},U=[250,500,1e3,2e3,4e3,8e3],N=new(function(){function t(){var t=this;this.retryCounter=0,this.sendInsights=D.throttleAsync((function(e){return j(t,void 0,void 0,(function(){var t,r,i=this;return P(this,(function(o){switch(o.label){case 0:if(!this.secret||!this.user||!e||0===e.length)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),t=[{user:this.__getUserInfo(),variations:e.filter((function(t){return t.insightType===n.featureFlagUsage})).map((function(t){return{featureFlagKey:t.id,sendToExperiment:t.sendToExperiment,timestamp:t.timestamp,variation:{id:t.variation.id,value:t.variation.value}}})),metrics:e.filter((function(t){return t.insightType!==n.featureFlagUsage})).map((function(t){return{route:location.pathname,timestamp:t.timestamp,numericValue:null===t.numericValue||void 0===t.numericValue?1:t.numericValue,appType:i.appType,eventName:t.eventName,type:t.type}}))}],[4,M("".concat(this.eventsUri,"/api/public/insight/track"),t,{Authorization:this.secret})];case 2:return o.sent(),[3,4];case 3:return r=o.sent(),h.logDebug(r),[3,4];case 4:return[2]}}))}))}))}return t.prototype.init=function(t,e,n,r){this.streamingUri=t,this.eventsUri=e,this.secret=n,this.appType=r},t.prototype.identify=function(t,e){var n;this.user=I({},t),D.setKey(null===(n=this.user)||void 0===n?void 0:n.keyId),e&&this.socket&&this.sendUserIdentifyMessage(0)},t.prototype.sendUserIdentifyMessage=function(t){var e,n,r=this.user,i={messageType:"data-sync",data:{user:{name:r.name,keyId:r.keyId,customizedProperties:r.customizedProperties},timestamp:t}};try{(null===(e=this.socket)||void 0===e?void 0:e.readyState)===WebSocket.OPEN?(h.logDebug("sending user identify message"),null===(n=this.socket)||void 0===n||n.send(JSON.stringify(i))):h.logDebug("didn't send user identify message because socket not open")}catch(t){h.logDebug(t)}},t.prototype.reconnect=function(){this.socket=null;var t=U[Math.min(this.retryCounter++,U.length-1)];setTimeout((function(){h.logDebug("emit reconnect event"),a.emit(l,{})}),t),h.logDebug(t)},t.prototype.sendPingMessage=function(){var t=this,e={messageType:"ping",data:null};setTimeout((function(){var n;try{(null===(n=t.socket)||void 0===n?void 0:n.readyState)===WebSocket.OPEN?(h.logDebug("sending ping"),t.socket.send(JSON.stringify(e)),t.sendPingMessage()):(h.logDebug("socket closed at ".concat(new Date)),t.reconnect())}catch(t){h.logDebug(t)}}),18e3)},t.prototype.createConnection=function(t,e){var n=this;if(n.socket)e({});else{var r=Date.now(),i="".concat(this.streamingUri,"/streaming?type=client&token=").concat(function(t){t=t.replace(/=*$/,"");var e=Date.now(),n=_(e,e.toString().length),r=Math.max(Math.floor(Math.random()*t.length),2);return"".concat(_(r,3)).concat(_(n.length,2)).concat(t.slice(0,r)).concat(n).concat(t.slice(r))}(this.secret));n.socket=new WebSocket(i),n.socket.addEventListener("open",(function(e){n.retryCounter=0,h.logDebug("Connection time: ".concat(Date.now()-r," ms")),n.sendUserIdentifyMessage(t),n.sendPingMessage()})),n.socket.addEventListener("close",(function(t){h.logDebug("close"),4003!==t.code&&n.reconnect()})),n.socket.addEventListener("error",(function(t){h.logDebug("error")})),n.socket.addEventListener("message",(function(t){var n=JSON.parse(t.data);"data-sync"===n.messageType&&(e(n.data),n.data.featureFlags.length>0&&h.logDebug("socket push update time(ms): ",Date.now()-n.data.featureFlags[0].timestamp))}))}},t.prototype.__getUserInfo=function(){var t=this.user;return{name:t.name,keyId:t.keyId,customizedProperties:t.customizedProperties}},t}());function M(t,e,n){return void 0===t&&(t=""),void 0===e&&(e={}),void 0===n&&(n={}),j(this,void 0,void 0,(function(){var r,i;return P(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,fetch(t,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},n),body:JSON.stringify(e)})];case 1:return[2,200===(r=o.sent()).status?r.json():{}];case 2:return i=o.sent(),h.logDebug(i),[2,{}];case 3:return[2]}}))}))}var V=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=""),this.flushLimit=t,this.arriveflushLimitTopic=e,this.queue=[]}return t.prototype.add=function(t){this.queue.push(t),this.flushLimit>0&&this.queue.length>=this.flushLimit&&a.emit(this.arriveflushLimitTopic,{})},t.prototype.flush=function(){var t=function(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}([],this.queue,!0);return this.queue=[],t},t}(),A=function(){return A=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},A.apply(this,arguments)},C=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{s(r.next(t))}catch(t){o(t)}}function u(t){try{s(r.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},L=function(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){a.label=u[1];break}if(6===u[0]&&a.label<i[1]){a.label=i[1],i=u;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(u);break}i[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},z=function(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))};function J(){var t=function(){var t=localStorage.getItem("fb-guid");if(t)return t;var e=m();return localStorage.setItem("fb-guid",e),e}();return{name:t,keyId:t}}function B(t){return Object.keys(t).map((function(e){var n=t[e],i=n.id,o=n.variation,a=t[e].variationType||r.string;return{id:i,variation:y(a,o),variationType:a}}))}var q=function(){function t(){var t=this;this._readyEventEmitted=!1,this._insightsQueue=new V(1,u),this._featureFlagEvaluationBuffer=new V,this._option={secret:"",api:"",streamingUri:"",eventsUri:"",enableDataSync:!0,appType:"javascript"},this._readyPromise=new Promise((function(e,r){t.on("ready",(function(){var r=T.getFeatureFlags();if(e(B(r)),t._option.enableDataSync){var i=t._featureFlagEvaluationBuffer.flush().map((function(t){var e=r[t.id];if(!e)return h.log("Called unexisting feature flag: ".concat(t.id)),null;var i=e.variationOptions.find((function(e){return e.value===t.variationValue}));return i?h.logDebug("Sent buffered insight for feature flag: ".concat(t.id," with variation: ").concat(i.value)):h.log("Sent buffered insight for feature flag: ".concat(t.id," with unexisting default variation: ").concat(t.variationValue)),{insightType:n.featureFlagUsage,id:e.id,timestamp:t.timestamp,sendToExperiment:e.sendToExperiment,variation:i||{id:-1,value:t.variationValue}}}));N.sendInsights(i.filter((function(t){return!!t})))}}))})),a.subscribe(l,(function(){return C(t,void 0,void 0,(function(){var t;return L(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),h.logDebug("reconnecting"),[4,this.dataSync()];case 1:return e.sent(),this._readyEventEmitted||(this._readyEventEmitted=!0,a.emit("ready",B(T.getFeatureFlags()))),[3,3];case 2:return t=e.sent(),h.log("data sync error",t),[3,3];case 3:return[2]}}))}))})),a.subscribe(c,(function(e){t._featureFlagEvaluationBuffer.add(e)})),a.subscribe(u,(function(){t._option.enableDataSync&&N.sendInsights(t._insightsQueue.flush())})),a.subscribe(s,(function(e){t._insightsQueue.add(e)})),a.subscribe("insights.topic",(function(e){t._insightsQueue.add(e)}))}return t.prototype.on=function(t,e){a.subscribe(t,e)},t.prototype.off=function(t,e){a.unsubscribe(t,e)},t.prototype.waitUntilReady=function(){return this._readyPromise},t.prototype.init=function(t){var e;return C(this,void 0,void 0,(function(){var n;return L(this,(function(r){switch(r.label){case 0:return n=function(t){if(null==t)return v.mandatory("option");var e=t.streamingUri,n=t.eventsUri,r=t.secret,i=t.anonymous,o=t.user,a=t.enableDataSync,u=w(e),s=w(n);if(a&&(u||s)){if(s)return v.partialEndpoint("eventsUri");if(u)return v.partialEndpoint("streamingUri")}return a&&w(r)?v.invalidParam("secret"):0!=!!i||o?o?b(o):null:v.mandatory("user")}(A(A({},this._option),t)),null!==n?(h.log(n),[2]):(this._option=A(A(A({},this._option),t),{api:null===(e=t.api||this._option.api)||void 0===e?void 0:e.replace(/\/$/,"")}),this._option.enableDataSync&&N.init(this._option.streamingUri,this._option.eventsUri,this._option.secret,this._option.appType),[4,this.identify(t.user||J())]);case 1:return r.sent(),[2]}}))}))},t.prototype.identify=function(t){var e;return C(this,void 0,void 0,(function(){var n,r;return L(this,(function(i){switch(i.label){case 0:return null!==(n=b(t))?(h.log(n),[2]):(t.customizedProperties=null===(e=t.customizedProperties)||void 0===e?void 0:e.map((function(t){return{name:t.name,value:"".concat(t.value)}})),r=g(t)!==localStorage.getItem(f),this._option.user=Object.assign({},t),localStorage.setItem(f,g(this._option.user)),T.userId=this._option.user.keyId,N.identify(this._option.user,r),[4,this.bootstrap(this._option.bootstrap,r)]);case 1:return i.sent(),[2]}}))}))},t.prototype.logout=function(){return C(this,void 0,void 0,(function(){var t;return L(this,(function(e){switch(e.label){case 0:return t=J(),[4,this.identify(t)];case 1:return e.sent(),[2,t]}}))}))},t.prototype.bootstrap=function(t,e){return C(this,void 0,void 0,(function(){var n,i;return L(this,(function(o){switch(o.label){case 0:if((t=t||this._option.bootstrap)&&t.length>0&&(n={featureFlags:t.reduce((function(t,e){var n=e.id,i=e.variation,o=e.timestamp,a=e.variationOptions,u=e.sendToExperiment,s=e.variationType;return t[n]={id:n,variation:i,timestamp:o,variationOptions:a||[{id:1,value:i}],sendToExperiment:u,variationType:s||r.string},t}),{})},T.setFullData(n),h.logDebug("bootstrapped with full data")),!this._option.enableDataSync)return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.dataSync(e)];case 2:return o.sent(),[3,4];case 3:return i=o.sent(),h.log("data sync error",i),[3,4];case 4:return this._readyEventEmitted||(this._readyEventEmitted=!0,a.emit("ready",B(T.getFeatureFlags()))),[2]}}))}))},t.prototype.dataSync=function(t){return C(this,void 0,void 0,(function(){var e=this;return L(this,(function(n){return[2,new Promise((function(n,o){var a=t?0:Math.max.apply(Math,z(z([],Object.values(T.getFeatureFlags()).map((function(t){return t.timestamp})),!1),[0],!1));N.createConnection(a,(function(t){var o;if(t&&t.userKeyId===(null===(o=e._option.user)||void 0===o?void 0:o.keyId)){var a=t.featureFlags;switch(t.eventType){case i.full:case i.patch:var u={featureFlags:a.reduce((function(t,e){var n=e.id,i=e.variation,o=e.timestamp,a=e.variationOptions,u=e.sendToExperiment,s=e.variationType;return t[n]={id:n,variation:i,timestamp:o,variationOptions:a,sendToExperiment:u,variationType:s||r.string},t}),{})};t.eventType===i.full?(T.setFullData(u),h.logDebug("synchonized with full data")):(T.updateBulkFromRemote(u),h.logDebug("synchonized with partial data"));break;default:h.logDebug("invalid stream event type: "+t.eventType)}}n()}))}))]}))}))},t.prototype.variation=function(t,e){var n=Q(t,e);return void 0===n?e:n},t.prototype.boolVariation=function(t,e){var n=Q(t,e);return void 0===n?e:"true"===(null==n?void 0:n.toLocaleLowerCase())},t.prototype.getUser=function(){return A({},this._option.user)},t.prototype.sendCustomEvent=function(t){var e=this;(t||[]).forEach((function(t){return e._insightsQueue.add(A({insightType:n.customEvent,timestamp:Date.now(),type:"CustomEvent"},t))}))},t.prototype.sendFeatureFlagInsight=function(t,e){this.variation(t,e)},t.prototype.getAllFeatureFlags=function(){var t=T.getFeatureFlags();return Object.values(t).reduce((function(t,e){return t[e.id]=y(e.variationType,e.variation),t}),{})},t}(),Q=function(t,e){var n=T.getVariation(t);return void 0===n&&a.emit(c,{id:t,timestamp:Date.now(),variationValue:"".concat(e)}),n};const R=new q;var K=document.querySelector("html");return K&&(K.style.visibility="hidden",setTimeout((function(){return K.style.visibility="visible"}),500)),h.logDebug("version: 2.0.0"),e})()));
2
+ //# sourceMappingURL=featbit-js-client-sdk-2.0.0.js.map