@feedmepos/mf-inventory-portal 1.8.0-dev.3 → 1.8.0-dev.4

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 (102) hide show
  1. package/dist/{App-DRXADP0k.js → App-FeJnwZme.js} +362 -374
  2. package/dist/{ApprovalView-hV1msz5Y.js → ApprovalView-Eo-cGWyA.js} +9 -9
  3. package/dist/{BindingsDialog-BX1Lopf0.js → BindingsDialog-DkjuXydb.js} +2 -2
  4. package/dist/{BindingsPicker-BNKW8-XY.js → BindingsPicker-DUOQcOlj.js} +2 -2
  5. package/dist/{BindingsTable-DiLDsL83.js → BindingsTable-CoDdU5xh.js} +4 -4
  6. package/dist/{BulkReceiveRequestView-oQh6kFLc.js → BulkReceiveRequestView-BGh8fbEX.js} +21 -22
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-BaMcGU-x.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-CStISRqy.js} +1 -1
  8. package/dist/{ClosingDraftView-sgLoaSf4.js → ClosingDraftView-Cwnhrv5P.js} +20 -20
  9. package/dist/{ClosingHistoryView-BnE9HrzA.js → ClosingHistoryView-oHf77Lal.js} +5 -5
  10. package/dist/{ClosingTemplateView-BD3Pa11r.js → ClosingTemplateView-1P8J1vAn.js} +18 -18
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-DlbyxkMQ.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-BuEPaqQK.js} +1 -1
  12. package/dist/{DefaultView-CuzvVkfE.js → DefaultView-3Z8aVFSU.js} +5 -5
  13. package/dist/{DeliveryOrderPrintPreview-w-1aAOY1.js → DeliveryOrderPrintPreview-uT_e3Suw.js} +2 -2
  14. package/dist/{DeprecateSoonWarningDialog.vue_vue_type_script_setup_true_lang-Bp8bjDU1.js → DeprecateSoonWarningDialog.vue_vue_type_script_setup_true_lang-D_vmtZDZ.js} +1 -1
  15. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-CxD12Qct.js → EmailDialog.vue_vue_type_script_setup_true_lang-BCgnXxEi.js} +29 -30
  16. package/dist/FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-D-RzUmqA.js +81 -0
  17. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-BqCh_vTP.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-BlKpGdCx.js} +1 -1
  18. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CAXnmdUy.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DKkxn1J-.js} +2 -2
  19. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-NhOdW33O.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-dOXDST-E.js} +2 -2
  20. package/dist/{FmMultiselectDialog-BqZgHP8s.js → FmMultiselectDialog-C8uYx8rr.js} +1 -1
  21. package/dist/{FmMultiselectDialog-CULwA_hi.js → FmMultiselectDialog-DRxZAkcu.js} +2 -2
  22. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-CI3Y9kDl.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DRSzQqVJ.js} +6 -6
  23. package/dist/{ImportView-DqQG673_.js → ImportView-Qigtf3ik.js} +6 -6
  24. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DfvNUu80.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-B8PJeYrP.js} +1 -1
  25. package/dist/{IngredientGroupView-CyngKxPo.js → IngredientGroupView-RNYZLkQu.js} +7 -7
  26. package/dist/{IngredientsView-pzpP6oXT.js → IngredientsView-N9U7tdI_.js} +17 -17
  27. package/dist/{IntegrationExplorerView-C5aAhB6e.js → IntegrationExplorerView-CjmeGQ14.js} +4 -4
  28. package/dist/{IntegrationView-Bqun7nX0.js → IntegrationView-DAdpmuxx.js} +15 -15
  29. package/dist/{InventoryBindingForm-r_Ua1C4a.js → InventoryBindingForm-CAj3MurI.js} +1 -1
  30. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CYDuu4kU.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-3pYuu62C.js} +5 -5
  31. package/dist/{InventoryBindingSummary-BQuZLohR.js → InventoryBindingSummary-B-1OBUdw.js} +1 -1
  32. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-7r-QcJdU.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CUYYEuW3.js} +1 -1
  33. package/dist/{ProductionRunDetailView-95fu_CfH.js → ProductionRunDetailView-eFvl8-By.js} +4 -4
  34. package/dist/{ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-CdOca1tV.js → ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-DaC7e4qS.js} +7 -7
  35. package/dist/{ProductionRunView-DIjor_Ix.js → ProductionRunView-C_NJJKLr.js} +3 -3
  36. package/dist/{PublishView-DYObyHQq.js → PublishView-BglAEkzU.js} +3 -3
  37. package/dist/{PurchaseOrderPrintPreview-C0jCmI9L.js → PurchaseOrderPrintPreview-BTF9ikpQ.js} +2 -2
  38. package/dist/{ReceiveRequestView-i7ibPfIE.js → ReceiveRequestView-BUvehG10.js} +15 -16
  39. package/dist/{RecipeView-C5VO7yr3.js → RecipeView-DO5-jgwh.js} +19 -20
  40. package/dist/{SettingsView-CdBloj9k.js → SettingsView-DRR86cHo.js} +10 -11
  41. package/dist/{StockView-g_6eJ62R.js → StockView-D1oEnbZp.js} +23 -24
  42. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-C1rKc7MA.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CxU92-io.js} +1 -1
  43. package/dist/{SupplierView-DkYp_Frj.js → SupplierView-D68wz0-g.js} +14 -14
  44. package/dist/{SurchargeView-CfkV4Y3y.js → SurchargeView-Cw9rTw2h.js} +7 -7
  45. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-2MtN1p5t.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-Az-a1Dsp.js} +2 -2
  46. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CYMjKXq4.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-C-sxbacO.js} +1 -1
  47. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-D0zNr_vQ.js → TransferDetails.vue_vue_type_script_setup_true_lang-CsHfLaCv.js} +241 -242
  48. package/dist/{TransferTemplateView-Ne2gYUSn.js → TransferTemplateView-CHPJMjYC.js} +22 -23
  49. package/dist/{UnitCostHistoryView-Db0_otOb.js → UnitCostHistoryView-DM8OzWhe.js} +4 -4
  50. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-BzO1lq7j.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-DpwK5mFH.js} +4 -4
  51. package/dist/{UnitView-CiCeQ63i.js → UnitView-90uR-ZzQ.js} +8 -8
  52. package/dist/{WarehouseView-BcuJSOMF.js → WarehouseView-Bulg6Vac.js} +8 -8
  53. package/dist/{WastageTemplateView-CPQmtOKQ.js → WastageTemplateView-BmAHnnwm.js} +15 -15
  54. package/dist/{app-DqJp3dcI.js → app-Ccdgbe4f.js} +16 -16
  55. package/dist/app.js +1 -1
  56. package/dist/{closing-template-BNlgZviN.js → closing-template-DuBZxoXx.js} +1 -1
  57. package/dist/components/FeatureCapabilityBadge.vue.d.ts +1 -1
  58. package/dist/{date2-Ci7521dn.js → date2-IBrLdtni.js} +1 -1
  59. package/dist/{dayjs.min-Cyp32v4J.js → dayjs.min-DEkq-Hpp.js} +1 -1
  60. package/dist/{decimal-BGdm5R3A.js → decimal-g6jRdlSk.js} +2 -2
  61. package/dist/{defineDeepModel-B2cJ-rtd.js → defineDeepModel-P5a5Ffpn.js} +1 -1
  62. package/dist/{duplicate-template-By5WeKZ0.js → duplicate-template-Do8s80ei.js} +1 -1
  63. package/dist/{core-Js7d-3Pv.js → feature-ChVm5JED.js} +3296 -1860
  64. package/dist/feature-flags/core.d.ts +3 -2
  65. package/dist/feature-flags/portal-feature-catalog.d.ts +2 -5
  66. package/dist/feature-flags/premium-flags.spec.d.ts +1 -0
  67. package/dist/feature-flags/vue.d.ts +2 -0
  68. package/dist/{format-time-from-id-Q8C2P96H.js → format-time-from-id-BgbBOII7.js} +1 -1
  69. package/dist/{format-unit-display-CICrmm8r.js → format-unit-display-hSXy2iu6.js} +13 -13
  70. package/dist/{id-to-date-DeN5x0LR.js → id-to-date-DlGYysU8.js} +1 -1
  71. package/dist/{import-export.helper-BOTQWxr6.js → import-export.helper-LrZhiz2W.js} +28 -28
  72. package/dist/{index-BbbqCCfp.js → index-BTNJ1fk2.js} +3 -3
  73. package/dist/{index-Cxm3Sgfv.js → index-DCiNwlw2.js} +1 -1
  74. package/dist/{index-tCYhLCKP.js → index-DsOmtywr.js} +1 -1
  75. package/dist/{lz-string-Dy4Pg8mh.js → lz-string-DRuyjE9G.js} +1 -1
  76. package/dist/{netsuite-BaJjkDM8.js → netsuite-B6y8GZCP.js} +2 -2
  77. package/dist/{number-CB36d2PQ.js → number-Besn-1-5.js} +3 -3
  78. package/dist/{predefined-templates-DLm93Bpx.js → predefined-templates-D92mN_2S.js} +1 -1
  79. package/dist/{purchase-order-template-CDhn9ZIF.js → purchase-order-template-hvq2pfWx.js} +1 -1
  80. package/dist/{recalculationUtils-Cqvefakh.js → recalculationUtils-BlZR5O2G.js} +1 -1
  81. package/dist/{row-action.enum-NTfVmGY8.js → row-action.enum-R2bi3eAv.js} +1 -1
  82. package/dist/{rules-C8dfM84-.js → rules-DzwoRKUS.js} +2 -2
  83. package/dist/{stock-BGB0Siue.js → stock-Cq37EARQ.js} +3 -3
  84. package/dist/{stock-Qu5IiN2_.js → stock-oJqnUrtt.js} +1 -1
  85. package/dist/stores/feature.d.ts +1 -0
  86. package/dist/{supplier-CZdNOSMN.js → supplier-DtdwvcPr.js} +17 -17
  87. package/dist/{surcharge-Cm40oJvU.js → surcharge-CjdJGIsM.js} +1 -1
  88. package/dist/tsconfig.app.tsbuildinfo +1 -1
  89. package/dist/{uom-rules-L-IW4Nwk.js → uom-rules-BqPn_GoZ.js} +1 -1
  90. package/dist/{use-ingredient-select-dialog-B2TDVJM6.js → use-ingredient-select-dialog-0hRCj6Fu.js} +2 -2
  91. package/dist/{use-inventory-binding-dialog-BJ00hl5f.js → use-inventory-binding-dialog-BLRcIC1u.js} +2 -2
  92. package/dist/{use-template-enabled-locations-DYAPMvo9.js → use-template-enabled-locations-8ZfTj4YB.js} +2 -2
  93. package/dist/{use-transfer-locations-w-9tymYS.js → use-transfer-locations-BGS1EBEt.js} +2 -2
  94. package/dist/{useHrmPermission-BFCIo5sA.js → useHrmPermission-BcQ2KPD-.js} +1 -1
  95. package/dist/{useNavigationMenu-BPHAH5sJ.js → useNavigationMenu-DImtns81.js} +73 -71
  96. package/dist/{useSseClient-CWjRacRs.js → useSseClient-DPSFFVci.js} +1 -1
  97. package/dist/{vue-i18n-S4YQ9w6a.js → vue-i18n-DTyGIjTI.js} +1 -1
  98. package/dist/{xlsx.util-CP8_VajN.js → xlsx.util-CK9Lnq3Q.js} +2 -2
  99. package/package.json +6 -6
  100. package/dist/FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-CMoQKl_a.js +0 -308
  101. package/dist/feature-fG7d73oi.js +0 -371
  102. package/dist/index-Dqf27vLH.js +0 -841
@@ -1,841 +0,0 @@
1
- var se = Object.defineProperty;
2
- var le = (S, c, y) => c in S ? se(S, c, { enumerable: !0, configurable: !0, writable: !0, value: y }) : S[c] = y;
3
- var ot = (S, c, y) => le(S, typeof c != "symbol" ? c + "" : c, y);
4
- import { readonly as Nt, ref as Rt } from "vue";
5
- import { a1 as st } from "./app-DqJp3dcI.js";
6
- const ue = ["lite", "standard", "premium"], te = {
7
- lite: 0,
8
- standard: 1,
9
- premium: 2
10
- };
11
- function me(S) {
12
- const c = S == null ? void 0 : S.trim().toLowerCase();
13
- return ue.includes(c) ? c : "standard";
14
- }
15
- function Se(S, c) {
16
- return te[S] >= te[c];
17
- }
18
- var Pt = { exports: {} };
19
- (function(S, c) {
20
- (function(y, p) {
21
- p(c);
22
- })(st, function(y) {
23
- var p = { getItemSync: function(a) {
24
- try {
25
- return localStorage.getItem(a) || null;
26
- } catch {
27
- return null;
28
- }
29
- }, getItem: function(a, e) {
30
- var t = this;
31
- return new Promise(function(i, n) {
32
- try {
33
- var r = t.getItemSync(a);
34
- e == null || e(null, r), i(r);
35
- } catch (o) {
36
- e && e(o, null), n(o);
37
- }
38
- });
39
- }, setItem: function(a, e, t) {
40
- return new Promise(function(i, n) {
41
- try {
42
- localStorage.setItem(a, e), t && t(null, e), i(e);
43
- } catch (r) {
44
- t && t(r, null), n(r);
45
- }
46
- });
47
- } }, s = function() {
48
- return s = Object.assign || function(a) {
49
- for (var e, t = 1, i = arguments.length; t < i; t++) for (var n in e = arguments[t]) Object.prototype.hasOwnProperty.call(e, n) && (a[n] = e[n]);
50
- return a;
51
- }, s.apply(this, arguments);
52
- };
53
- function k(a, e, t, i) {
54
- return new (t || (t = Promise))(function(n, r) {
55
- function o(d) {
56
- try {
57
- h(i.next(d));
58
- } catch (l) {
59
- r(l);
60
- }
61
- }
62
- function u(d) {
63
- try {
64
- h(i.throw(d));
65
- } catch (l) {
66
- r(l);
67
- }
68
- }
69
- function h(d) {
70
- var l;
71
- d.done ? n(d.value) : (l = d.value, l instanceof t ? l : new t(function(g) {
72
- g(l);
73
- })).then(o, u);
74
- }
75
- h((i = i.apply(a, [])).next());
76
- });
77
- }
78
- function M(a, e) {
79
- var t, i, n, r, o = { label: 0, sent: function() {
80
- if (1 & n[0]) throw n[1];
81
- return n[1];
82
- }, trys: [], ops: [] };
83
- return r = { next: u(0), throw: u(1), return: u(2) }, typeof Symbol == "function" && (r[Symbol.iterator] = function() {
84
- return this;
85
- }), r;
86
- function u(h) {
87
- return function(d) {
88
- return function(l) {
89
- if (t) throw new TypeError("Generator is already executing.");
90
- for (; o; ) try {
91
- if (t = 1, i && (n = 2 & l[0] ? i.return : l[0] ? i.throw || ((n = i.return) && n.call(i), 0) : i.next) && !(n = n.call(i, l[1])).done) return n;
92
- switch (i = 0, n && (l = [2 & l[0], n.value]), l[0]) {
93
- case 0:
94
- case 1:
95
- n = l;
96
- break;
97
- case 4:
98
- return o.label++, { value: l[1], done: !1 };
99
- case 5:
100
- o.label++, i = l[1], l = [0];
101
- continue;
102
- case 7:
103
- l = o.ops.pop(), o.trys.pop();
104
- continue;
105
- default:
106
- if (n = o.trys, !((n = n.length > 0 && n[n.length - 1]) || l[0] !== 6 && l[0] !== 2)) {
107
- o = 0;
108
- continue;
109
- }
110
- if (l[0] === 3 && (!n || l[1] > n[0] && l[1] < n[3])) {
111
- o.label = l[1];
112
- break;
113
- }
114
- if (l[0] === 6 && o.label < n[1]) {
115
- o.label = n[1], n = l;
116
- break;
117
- }
118
- if (n && o.label < n[2]) {
119
- o.label = n[2], o.ops.push(l);
120
- break;
121
- }
122
- n[2] && o.ops.pop(), o.trys.pop();
123
- continue;
124
- }
125
- l = e.call(a, o);
126
- } catch (g) {
127
- l = [6, g], i = 0;
128
- } finally {
129
- t = n = 0;
130
- }
131
- if (5 & l[0]) throw l[1];
132
- return { value: l[0] ? l[1] : void 0, done: !0 };
133
- }([h, d]);
134
- };
135
- }
136
- }
137
- function D(a, e, t) {
138
- for (var i, n = 0, r = e.length; n < r; n++) !i && n in e || (i || (i = Array.prototype.slice.call(e, 0, n)), i[n] = e[n]);
139
- return a.concat(i || Array.prototype.slice.call(e));
140
- }
141
- var nt = function a(e, t) {
142
- if (e === t) return !0;
143
- if (e && t && typeof e == "object" && typeof t == "object") {
144
- if (e.constructor !== t.constructor) return !1;
145
- var i, n, r;
146
- if (Array.isArray(e)) {
147
- if ((i = e.length) != t.length) return !1;
148
- for (n = i; n-- != 0; ) if (!a(e[n], t[n])) return !1;
149
- return !0;
150
- }
151
- if (e.constructor === RegExp) return e.source === t.source && e.flags === t.flags;
152
- if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === t.valueOf();
153
- if (e.toString !== Object.prototype.toString) return e.toString() === t.toString();
154
- if ((i = (r = Object.keys(e)).length) !== Object.keys(t).length) return !1;
155
- for (n = i; n-- != 0; ) if (!Object.prototype.hasOwnProperty.call(t, r[n])) return !1;
156
- for (n = i; n-- != 0; ) {
157
- var o = r[n];
158
- if (!a(e[o], t[o])) return !1;
159
- }
160
- return !0;
161
- }
162
- return e != e && t != t;
163
- };
164
- function b(a, e) {
165
- var t = Object.keys(e || {}).filter(function(i) {
166
- var n = a == null ? void 0 : a[i], r = e == null ? void 0 : e[i];
167
- return !nt(n, r);
168
- });
169
- return Object.keys(a || {}).filter(function(i) {
170
- Object.keys(e || {}).includes(i) || t.push(i);
171
- }), Object.keys(t).length ? t : null;
172
- }
173
- var v, C;
174
- function _(a, e, t) {
175
- var i = "shortString", n = !0;
176
- typeof t == "number" && (i = "javaDouble", n = !1), a[i] = a[i] || {}, a[i][e] = n ? t + "" : t;
177
- }
178
- function G(a) {
179
- return !!a && typeof a == "object" && a.value !== void 0;
180
- }
181
- function it(a) {
182
- return Object.fromEntries(Object.entries(a).map(function(e) {
183
- var t = e[0], i = e[1];
184
- return [t, G(i) ? i : { value: i }];
185
- }));
186
- }
187
- function ut(a) {
188
- return s(s({}, a), { identity: a.identity ? s(s({}, a.identity), { traits: it(a.identity.traits || {}) }) : void 0 });
189
- }
190
- (function(a) {
191
- a.NONE = "NONE", a.DEFAULT_FLAGS = "DEFAULT_FLAGS", a.CACHE = "CACHE", a.SERVER = "SERVER";
192
- })(v || (v = {}));
193
- var ct, O = null, ne = "FLAGSMITH_EVENT", at = ne, Ut = "https://edge.api.flagsmith.com/api/v1/", Kt = "flagsmith_value_", Dt = "flagsmith_enabled_", Gt = "flagsmith_trait_", ie = function() {
194
- function a(e) {
195
- var t = this;
196
- this._trigger = null, this._triggerLoadingState = null, this.timestamp = null, this.isLoading = !1, this.eventSource = null, this.getFlags = function() {
197
- var i = t, n = i.api, r = i.evaluationContext;
198
- t.log("Get Flags"), t.isLoading = !0, t.loadingState.isFetching || t.setLoadingState(s(s({}, t.loadingState), { isFetching: !0 }));
199
- var o = "".concat(t.getContext().identity), u = function(h) {
200
- var d, l, g, x;
201
- if (h && o === "".concat(t.getContext().identity)) {
202
- var N = h.flags, w = h.traits, j = h.identifier;
203
- t.isLoading = !1;
204
- var I = {}, L = {};
205
- w = w || [], (N = N || []).forEach(function(f) {
206
- I[f.feature.name.toLowerCase().replace(/ /g, "_")] = { id: f.feature.id, enabled: f.enabled, value: f.feature_state_value };
207
- }), w.forEach(function(f) {
208
- L[f.trait_key.toLowerCase().replace(/ /g, "_")] = { transient: f.transient, value: f.trait_value };
209
- }), t.oldFlags = s({}, t.flags);
210
- var P = b(t.oldFlags, I), Z = b((d = t.evaluationContext.identity) === null || d === void 0 ? void 0 : d.traits, L);
211
- if ((j || Object.keys(L).length) && (t.evaluationContext.identity = s(s({}, t.evaluationContext.identity), { traits: L }), j && (t.evaluationContext.identity.identifier = j)), t.flags = I, t.updateStorage(), t._onChange(t.oldFlags, { isFromServer: !0, flagsChanged: P, traitsChanged: Z }, t._loadedState(null, v.SERVER)), t.datadogRum) try {
212
- if (t.datadogRum.trackTraits) {
213
- var Q = {};
214
- Object.keys(((l = t.evaluationContext.identity) === null || l === void 0 ? void 0 : l.traits) || {}).map(function(f) {
215
- Q[Gt + f] = t.getTrait(f);
216
- });
217
- var $ = s(s(s({}, t.datadogRum.client.getUser()), { id: t.datadogRum.client.getUser().id || ((g = t.evaluationContext.identity) === null || g === void 0 ? void 0 : g.identifier) }), Q);
218
- t.log("Setting Datadog user", $), t.datadogRum.client.setUser($);
219
- }
220
- } catch (f) {
221
- console.error(f);
222
- }
223
- if (t.dtrum) try {
224
- var E = { javaDouble: {}, date: {}, shortString: {}, javaLongOrObject: {} };
225
- Object.keys(t.flags).map(function(f) {
226
- _(E, Kt + f, t.getValue(f, { skipAnalytics: !0 })), _(E, Dt + f, t.hasFeature(f, { skipAnalytics: !0 }));
227
- }), Object.keys(((x = t.evaluationContext.identity) === null || x === void 0 ? void 0 : x.traits) || {}).map(function(f) {
228
- _(E, Gt + f, t.getTrait(f));
229
- }), t.log("Sending javaLongOrObject traits to dynatrace", E.javaLongOrObject), t.log("Sending date traits to dynatrace", E.date), t.log("Sending shortString traits to dynatrace", E.shortString), t.log("Sending javaDouble to dynatrace", E.javaDouble), t.dtrum.sendSessionProperties(E.javaLongOrObject, E.date, E.shortString, E.javaDouble);
230
- } catch (f) {
231
- console.error(f);
232
- }
233
- }
234
- };
235
- return r.identity ? Promise.all([r.identity.traits && Object.keys(r.identity.traits).length || !r.identity.identifier ? t.getJSON(n + "identities/", "POST", JSON.stringify({ identifier: r.identity.identifier, transient: r.identity.transient, traits: Object.entries(r.identity.traits).map(function(h) {
236
- var d = h[0], l = h[1];
237
- return { trait_key: d, trait_value: l == null ? void 0 : l.value, transient: l == null ? void 0 : l.transient };
238
- }).filter(function(h) {
239
- return h.trait_value !== void 0 || (t.log("Warning - attempted to set an undefined trait value for key", h.trait_key), !1);
240
- }) })) : t.getJSON(n + "identities/?identifier=" + encodeURIComponent(r.identity.identifier) + (r.identity.transient ? "&transient=true" : ""))]).then(function(h) {
241
- return t.evaluationContext.identity = s(s({}, t.evaluationContext.identity), { traits: {} }), u(h == null ? void 0 : h[0]);
242
- }).catch(function(h) {
243
- var d = h.message, l = new Error(d);
244
- return Promise.reject(l);
245
- }) : t.getJSON(n + "flags/").then(function(h) {
246
- return u({ flags: h, traits: void 0 });
247
- });
248
- }, this.analyticsFlags = function() {
249
- var i = t.api;
250
- if (t.evaluationEvent && t.evaluationContext.environment && t.evaluationEvent[t.evaluationContext.environment.apiKey]) return t.evaluationEvent && Object.getOwnPropertyNames(t.evaluationEvent).length !== 0 && Object.getOwnPropertyNames(t.evaluationEvent[t.evaluationContext.environment.apiKey]).length !== 0 ? t.getJSON(i + "analytics/flags/", "POST", JSON.stringify(t.evaluationEvent[t.evaluationContext.environment.apiKey])).then(function(n) {
251
- if (t.evaluationContext.environment) {
252
- var r = t.getState();
253
- t.evaluationEvent || (t.evaluationEvent = {}), t.evaluationEvent[t.evaluationContext.environment.apiKey] = {}, t.setState(s(s({}, r), { evaluationEvent: t.evaluationEvent })), t.updateEventStorage();
254
- }
255
- }).catch(function(n) {
256
- t.log("Exception fetching evaluationEvent", n);
257
- }) : void 0;
258
- }, this.datadogRum = null, this.loadingState = { isLoading: !0, isFetching: !0, error: null, source: v.NONE }, this.canUseStorage = !1, this.analyticsInterval = null, this.api = null, this.cacheFlags = !1, this.ts = null, this.enableAnalytics = !1, this.enableLogs = !1, this.evaluationContext = {}, this.evaluationEvent = null, this.flags = null, this.getFlagInterval = null, this.headers = null, this.initialised = !1, this.oldFlags = null, this.onChange = null, this.onError = null, this.ticks = null, this.timer = null, this.dtrum = null, this.withTraits = null, this.cacheOptions = { ttl: 0, skipAPI: !1, loadStale: !1, storageKey: void 0 }, this.getValue = function(i, n, r) {
259
- var o = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")], u = null;
260
- if (o && (u = o.value), n != null && n.skipAnalytics || r || t.evaluateFlag(i, "VALUE"), u === null && (n == null ? void 0 : n.fallback) !== void 0) return n.fallback;
261
- if (n != null && n.json) try {
262
- return u === null ? (t.log("Tried to parse null flag as JSON: " + i), null) : JSON.parse(u);
263
- } catch {
264
- return n.fallback;
265
- }
266
- return u;
267
- }, this.getTrait = function(i) {
268
- var n, r;
269
- return ((n = t.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits) && ((r = t.evaluationContext.identity.traits[i.toLowerCase().replace(/ /g, "_")]) === null || r === void 0 ? void 0 : r.value);
270
- }, this.getAllTraits = function() {
271
- var i;
272
- return Object.fromEntries(Object.entries(((i = t.evaluationContext.identity) === null || i === void 0 ? void 0 : i.traits) || {}).map(function(n) {
273
- var r = n[0], o = n[1];
274
- return [r, o == null ? void 0 : o.value];
275
- }));
276
- }, this.setContext = function(i) {
277
- var n = ut(i);
278
- return t.evaluationContext = s(s({}, n), { environment: n.environment || t.evaluationContext.environment }), t.initialised ? t.getFlags() : Promise.resolve();
279
- }, this.getContext = function() {
280
- return t.evaluationContext;
281
- }, this.updateContext = function(i) {
282
- return t.setContext(s(s({}, t.getContext()), i));
283
- }, this.setTrait = function(i, n) {
284
- var r;
285
- if (t.api) return t.setContext(s(s({}, t.evaluationContext), { identity: s(s({}, t.evaluationContext.identity), { traits: s(s({}, (r = t.evaluationContext.identity) === null || r === void 0 ? void 0 : r.traits), it(Object.fromEntries([[i, n]]))) }) }));
286
- }, this.setTraits = function(i) {
287
- var n;
288
- if (t.api) return t.setContext(s(s({}, t.evaluationContext), { identity: s(s({}, t.evaluationContext.identity), { traits: s(s({}, (n = t.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits), Object.fromEntries(Object.entries(i).map(function(r) {
289
- var o = r[0], u = r[1];
290
- return [o, G(u) ? u : { value: u }];
291
- }))) }) }));
292
- console.error("Attempted to setTraits a user before calling flagsmith.init. Call flagsmith.init first, if you wish to prevent it sending a request for flags, call init with preventFetch:true.");
293
- }, this.hasFeature = function(i, n) {
294
- var r = typeof n == "object", o = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")], u = !1;
295
- return !o && r && n.fallback !== void 0 ? u = n == null ? void 0 : n.fallback : o && o.enabled && (u = !0), (r && !n.skipAnalytics || !n) && t.evaluateFlag(i, "ENABLED"), u;
296
- }, this.getStorageKey = function() {
297
- var i, n;
298
- return ((i = t.cacheOptions) === null || i === void 0 ? void 0 : i.storageKey) || "FLAGSMITH_DB_" + ((n = t.evaluationContext.environment) === null || n === void 0 ? void 0 : n.apiKey);
299
- }, this.getJSON = function(i, n, r) {
300
- var o, u = t;
301
- u.evaluationContext;
302
- var h = u.headers, d = { method: n || "GET", body: r, cache: "no-cache", headers: {} };
303
- t.evaluationContext.environment && (d.headers["X-Environment-Key"] = t.evaluationContext.environment.apiKey), n && n !== "GET" && (d.headers["Content-Type"] = "application/json; charset=utf-8"), h && Object.assign(d.headers, h), C || console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");
304
- var l = "".concat((o = t.evaluationContext.identity) === null || o === void 0 ? void 0 : o.identifier);
305
- return C(i, d).then(function(g) {
306
- var x, N, w = "".concat((x = t.evaluationContext.identity) === null || x === void 0 ? void 0 : x.identifier);
307
- if (l === w) {
308
- var j = (N = g.headers) === null || N === void 0 ? void 0 : N.get("x-flagsmith-document-updated-at");
309
- if (j) try {
310
- var I = parseFloat(j);
311
- if (isNaN(I)) return Promise.reject("Failed to parse x-flagsmith-document-updated-at");
312
- t.timestamp = I;
313
- } catch (L) {
314
- t.log(L, "Failed to parse x-flagsmith-document-updated-at", j);
315
- }
316
- return t.log("Fetch response: " + g.status + " " + (n || "GET") + 0 + i), g.text().then(function(L) {
317
- var P = L;
318
- try {
319
- P = JSON.parse(L);
320
- } catch {
321
- }
322
- return !P && g.status && (P = "API Response: ".concat(g.status)), g.status && g.status >= 200 && g.status < 300 ? P : Promise.reject(new Error(P));
323
- });
324
- }
325
- t.log("Received response with identity mismatch, ignoring response. Requested: ".concat(l, ", Current: ").concat(w));
326
- });
327
- }, this.evaluateFlag = function(i, n) {
328
- if (t.datadogRum && (t.datadogRum.client.addFeatureFlagEvaluation ? n === "VALUE" ? t.datadogRum.client.addFeatureFlagEvaluation(Kt + i, t.getValue(i, {}, !0)) : t.datadogRum.client.addFeatureFlagEvaluation(Dt + i, t.hasFeature(i, !0)) : console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")), t.enableAnalytics) {
329
- if (!t.evaluationEvent || !t.evaluationContext.environment) return;
330
- t.evaluationEvent[t.evaluationContext.environment.apiKey] || (t.evaluationEvent[t.evaluationContext.environment.apiKey] = {}), t.evaluationEvent[t.evaluationContext.environment.apiKey][i] === void 0 && (t.evaluationEvent[t.evaluationContext.environment.apiKey][i] = 0), t.evaluationEvent[t.evaluationContext.environment.apiKey][i] += 1;
331
- }
332
- t.updateEventStorage();
333
- }, this._onChange = function(i, n, r) {
334
- var o, u;
335
- t.setLoadingState(r), (o = t.onChange) === null || o === void 0 || o.call(t, i, n, t.loadingState), (u = t._trigger) === null || u === void 0 || u.call(t);
336
- }, C = e.fetch ? e.fetch : typeof fetch < "u" ? fetch : st === null || st === void 0 ? void 0 : st.fetch, this.canUseStorage = typeof window < "u" || !!e.browserlessStorage, this.log("Constructing flagsmith instance " + e), e.eventSource && (ct = e.eventSource), e.AsyncStorage && (O = e.AsyncStorage);
337
- }
338
- return a.prototype.init = function(e) {
339
- var t, i, n;
340
- return k(this, void 0, void 0, function() {
341
- var r, o, u, h, d, l, g, x, N, w, j, I, L, P, Z, Q, $, E, f, vt, W, Bt, B, dt, qt, Xt, gt, Yt, ft, tt, q, Zt, F = this;
342
- return M(this, function(T) {
343
- switch (T.label) {
344
- case 0:
345
- r = ut(e.evaluationContext || this.evaluationContext), T.label = 1;
346
- case 1:
347
- if (T.trys.push([1, 13, , 14]), o = e.environmentID, u = e.api, h = u === void 0 ? Ut : u, d = e.headers, l = e.onChange, g = e.cacheFlags, x = e.datadogRum, N = e.onError, w = e.defaultFlags, j = e.fetch, I = e.preventFetch, L = e.enableLogs, P = e.enableDynatrace, Z = e.enableAnalytics, Q = e.realtime, $ = e.eventSourceUrl, E = $ === void 0 ? "https://realtime.flagsmith.com/" : $, f = e.AsyncStorage, vt = e.identity, W = e.traits, Bt = e.state, B = e.cacheOptions, dt = e.angularHttpClient, qt = e._trigger, Xt = e._triggerLoadingState, r.environment = o ? { apiKey: o } : r.environment, !r.environment || !r.environment.apiKey) throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");
348
- if (r.identity = vt || W ? { identifier: vt, traits: W ? Object.fromEntries(Object.entries(W).map(function(A) {
349
- return [A[0], { value: A[1] }];
350
- })) : {} } : r.identity, this.evaluationContext = r, this.api = h, this.headers = d, this.getFlagInterval = null, this.analyticsInterval = null, this.onChange = l, gt = "Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided", this._trigger = qt || this._trigger, this._triggerLoadingState = Xt || this._triggerLoadingState, this.onError = function(A) {
351
- F.setLoadingState(s(s({}, F.loadingState), { isFetching: !1, isLoading: !1, error: A })), N == null || N(A);
352
- }, this.enableLogs = L || !1, this.cacheOptions = B ? { skipAPI: !!B.skipAPI, ttl: B.ttl || 0, storageKey: B.storageKey, loadStale: !!B.loadStale } : this.cacheOptions, !this.cacheOptions.ttl && this.cacheOptions.skipAPI && console.warn("Flagsmith: you have set a cache ttl of 0 and are skipping API calls, this means the API will not be hit unless you clear local storage."), j && (C = j), this.enableAnalytics = Z || !1, this.flags = Object.assign({}, w) || {}, this.datadogRum = x || null, this.initialised = !0, this.ticks = 1e4, this.timer = this.enableLogs ? (/* @__PURE__ */ new Date()).valueOf() : null, this.cacheFlags = O !== void 0 && !!g, at = "FLAGSMITH_EVENT_" + r.environment.apiKey, f && (O = f), Q && typeof window < "u" && this.setupRealtime(E, r.environment.apiKey), Object.keys(this.flags).length && (this.loadingState = s(s({}, this.loadingState), { isLoading: !1, source: v.DEFAULT_FLAGS })), this.setState(Bt), this.log("Initialising with properties", e, this), P && (typeof dtrum > "u" ? console.error("You have attempted to enable dynatrace but dtrum is undefined, please check you have the Dynatrace RUM JavaScript API installed.") : this.dtrum = dtrum), dt && (C = /* @__PURE__ */ function(A) {
353
- return function(R, U) {
354
- var V = U.headers, m = U.method, X = U.body;
355
- return new Promise(function(H) {
356
- switch (m) {
357
- case "GET":
358
- return A.get(R, { headers: V }).subscribe(function(J) {
359
- H({ ok: !0, text: function() {
360
- return Promise.resolve(J);
361
- } });
362
- });
363
- case "POST":
364
- case "PUT":
365
- return A.post(R, X, { headers: V }).subscribe(function(J) {
366
- H({ ok: !0, text: function() {
367
- return Promise.resolve(J);
368
- } });
369
- });
370
- }
371
- });
372
- };
373
- }(dt)), O && this.canUseStorage && O.getItem(at).then(function(A) {
374
- try {
375
- F.evaluationEvent = JSON.parse(A) || {};
376
- } catch {
377
- F.evaluationEvent = {};
378
- }
379
- F.analyticsInterval = setInterval(F.analyticsFlags, F.ticks);
380
- }), this.enableAnalytics && (this.analyticsInterval && clearInterval(this.analyticsInterval), O && this.canUseStorage && O.getItem(at, function(A, R) {
381
- if (R && F.evaluationContext.environment) {
382
- var U = JSON.parse(R);
383
- if (U[F.evaluationContext.environment.apiKey]) {
384
- var V = F.getState();
385
- F.log("Retrieved events from cache", R), F.setState(s(s({}, V), { evaluationEvent: U[F.evaluationContext.environment.apiKey] }));
386
- }
387
- }
388
- })), !g) return [3, 9];
389
- if (!O || !this.canUseStorage) return [3, 8];
390
- Yt = function(A, R) {
391
- return k(F, void 0, void 0, function() {
392
- var U, V, m, X, H, J, pt, Qt, yt, mt, St, Ct, _t, bt, xt, Et, Ft, Ot, wt, It, Lt, At, jt, Tt, Wt = this;
393
- return M(this, function(z) {
394
- switch (z.label) {
395
- case 0:
396
- if (!R) return [3, 7];
397
- U = null, V = null, z.label = 1;
398
- case 1:
399
- return z.trys.push([1, 5, , 6]), m = JSON.parse(R), X = !1, H = !1, m && m.api === this.api && ((mt = (yt = m.evaluationContext) === null || yt === void 0 ? void 0 : yt.environment) === null || mt === void 0 ? void 0 : mt.apiKey) === ((St = this.evaluationContext.environment) === null || St === void 0 ? void 0 : St.apiKey) && (J = !0, this.evaluationContext.identity && ((_t = (Ct = m.evaluationContext) === null || Ct === void 0 ? void 0 : Ct.identity) === null || _t === void 0 ? void 0 : _t.identifier) !== this.evaluationContext.identity.identifier && (this.log("Ignoring cache, identity has changed from " + ((xt = (bt = m.evaluationContext) === null || bt === void 0 ? void 0 : bt.identity) === null || xt === void 0 ? void 0 : xt.identifier) + " to " + this.evaluationContext.identity.identifier), J = !1), this.cacheOptions.ttl && (!m.ts || (/* @__PURE__ */ new Date()).valueOf() - m.ts > this.cacheOptions.ttl) && (m.ts && !this.cacheOptions.loadStale ? (this.log("Ignoring cache, timestamp is too old ts:" + m.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - m.ts) + "ms"), J = !1) : m.ts && this.cacheOptions.loadStale && (this.log("Loading stale cache, timestamp ts:" + m.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - m.ts) + "ms"), H = !0, J = !0)), J && (X = !0, V = b((Et = this.evaluationContext.identity) === null || Et === void 0 ? void 0 : Et.traits, (Ot = (Ft = m.evaluationContext) === null || Ft === void 0 ? void 0 : Ft.identity) === null || Ot === void 0 ? void 0 : Ot.traits), U = b(this.flags, m.flags), this.setState(s(s({}, m), { evaluationContext: ut(s(s({}, m.evaluationContext), { identity: !((wt = m.evaluationContext) === null || wt === void 0) && wt.identity ? s(s({}, (It = m.evaluationContext) === null || It === void 0 ? void 0 : It.identity), { traits: s(s({}, ((At = (Lt = m.evaluationContext) === null || Lt === void 0 ? void 0 : Lt.identity) === null || At === void 0 ? void 0 : At.traits) || {}), W || {}) }) : void 0 })) })), this.log("Retrieved flags from cache", m))), X ? (pt = !I && (!this.cacheOptions.skipAPI || H), this._onChange(null, { isFromServer: !1, flagsChanged: U, traitsChanged: V }, this._loadedState(null, v.CACHE, pt)), this.oldFlags = this.flags, this.cacheOptions.skipAPI && X && !H && this.log("Skipping API, using cache"), pt && this.getFlags().catch(function(oe) {
400
- var kt;
401
- (kt = Wt.onError) === null || kt === void 0 || kt.call(Wt, oe);
402
- }), [3, 4]) : [3, 2];
403
- case 2:
404
- return I ? [3, 4] : [4, this.getFlags()];
405
- case 3:
406
- z.sent(), z.label = 4;
407
- case 4:
408
- return [3, 6];
409
- case 5:
410
- return Qt = z.sent(), this.log("Exception fetching cached logs", Qt), [3, 6];
411
- case 6:
412
- return [3, 10];
413
- case 7:
414
- return I ? [3, 9] : [4, this.getFlags()];
415
- case 8:
416
- return z.sent(), [3, 10];
417
- case 9:
418
- if (w) this._onChange(null, { isFromServer: !1, flagsChanged: b({}, this.flags), traitsChanged: b({}, (jt = this.evaluationContext.identity) === null || jt === void 0 ? void 0 : jt.traits) }, this._loadedState(null, v.DEFAULT_FLAGS));
419
- else {
420
- if (!this.flags) throw new Error(gt);
421
- this._onChange(null, { isFromServer: !1, flagsChanged: b({}, this.flags), traitsChanged: b({}, (Tt = this.evaluationContext.identity) === null || Tt === void 0 ? void 0 : Tt.traits) }, this._loadedState(null, v.DEFAULT_FLAGS));
422
- }
423
- z.label = 10;
424
- case 10:
425
- return [2];
426
- }
427
- });
428
- });
429
- }, T.label = 2;
430
- case 2:
431
- return T.trys.push([2, 7, , 8]), O.getItemSync ? (ft = O.getItemSync(this.getStorageKey()), [3, 5]) : [3, 3];
432
- case 3:
433
- return [4, O.getItem(this.getStorageKey())];
434
- case 4:
435
- ft = T.sent(), T.label = 5;
436
- case 5:
437
- return [4, Yt(null, ft)];
438
- case 6:
439
- case 7:
440
- return T.sent(), [3, 8];
441
- case 8:
442
- return [3, 12];
443
- case 9:
444
- return I ? [3, 11] : [4, this.getFlags()];
445
- case 10:
446
- return T.sent(), [3, 12];
447
- case 11:
448
- if (w) this._onChange(null, { isFromServer: !1, flagsChanged: b({}, w), traitsChanged: b({}, (t = r.identity) === null || t === void 0 ? void 0 : t.traits) }, this._loadedState(null, v.DEFAULT_FLAGS));
449
- else if (this.flags && (tt = null, Object.keys(this.flags).length === 0 && (tt = gt), this._onChange(null, { isFromServer: !1, flagsChanged: b({}, this.flags), traitsChanged: b({}, (i = r.identity) === null || i === void 0 ? void 0 : i.traits) }, this._loadedState(tt, v.DEFAULT_FLAGS)), tt)) throw new Error(tt);
450
- T.label = 12;
451
- case 12:
452
- return [3, 14];
453
- case 13:
454
- throw q = T.sent(), this.log("Error during initialisation ", q), Zt = q instanceof Error ? q : new Error("".concat(q)), (n = this.onError) === null || n === void 0 || n.call(this, Zt), q;
455
- case 14:
456
- return [2];
457
- }
458
- });
459
- });
460
- }, a.prototype.getAllFlags = function() {
461
- return this.flags;
462
- }, a.prototype.identify = function(e, t, i) {
463
- return this.evaluationContext.identity = { identifier: e, transient: i, traits: this.evaluationContext.identity && this.evaluationContext.identity.identifier == e ? this.evaluationContext.identity.traits : {} }, this.evaluationContext.identity.identifier = e, this.log("Identify: " + this.evaluationContext.identity.identifier), t && (this.evaluationContext.identity.traits = Object.fromEntries(Object.entries(t).map(function(n) {
464
- var r = n[0], o = n[1];
465
- return [r, G(o) ? o : { value: o }];
466
- }))), this.initialised ? this.getFlags() : Promise.resolve();
467
- }, a.prototype.getState = function() {
468
- return { api: this.api, flags: this.flags, ts: this.ts, evaluationContext: this.evaluationContext, evaluationEvent: this.evaluationEvent };
469
- }, a.prototype.setState = function(e) {
470
- e && (this.initialised = !0, this.api = e.api || this.api || Ut, this.flags = e.flags || this.flags, this.evaluationContext = e.evaluationContext || this.evaluationContext, this.evaluationEvent = e.evaluationEvent || this.evaluationEvent, this.log("setState called", this));
471
- }, a.prototype.logout = function() {
472
- return this.evaluationContext.identity = null, this.initialised ? this.getFlags() : Promise.resolve();
473
- }, a.prototype.startListening = function(e) {
474
- e === void 0 && (e = 1e3), this.getFlagInterval && clearInterval(this.getFlagInterval), this.getFlagInterval = setInterval(this.getFlags, e);
475
- }, a.prototype.stopListening = function() {
476
- this.getFlagInterval && (clearInterval(this.getFlagInterval), this.getFlagInterval = null);
477
- }, a.prototype._loadedState = function(e, t, i) {
478
- return e === void 0 && (e = null), i === void 0 && (i = !1), { error: e, isFetching: i, isLoading: !1, source: t };
479
- }, a.prototype.log = function() {
480
- for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
481
- this.enableLogs && console.log.apply(this, D(["FLAGSMITH:", (/* @__PURE__ */ new Date()).valueOf() - (this.timer || 0), "ms"], e));
482
- }, a.prototype.updateStorage = function() {
483
- if (this.cacheFlags) {
484
- this.ts = (/* @__PURE__ */ new Date()).valueOf();
485
- var e = JSON.stringify(this.getState());
486
- this.log("Setting storage", e), O.setItem(this.getStorageKey(), e);
487
- }
488
- }, a.prototype.updateEventStorage = function() {
489
- if (this.enableAnalytics) {
490
- var e = JSON.stringify(this.getState().evaluationEvent);
491
- O.setItem(at, e).catch(function(t) {
492
- return console.error("Flagsmith: Error setting item in async storage", t);
493
- });
494
- }
495
- }, a.prototype.setLoadingState = function(e) {
496
- var t;
497
- nt(e, this.loadingState) || (this.loadingState = s({}, e), this.log("Loading state changed", e), (t = this._triggerLoadingState) === null || t === void 0 || t.call(this));
498
- }, a.prototype.setupRealtime = function(e, t) {
499
- var i = this, n = e + "sse/environments/" + t + "/stream";
500
- ct ? this.eventSource || (this.log("Creating event source with url " + n), this.eventSource = new ct(n), this.eventSource.addEventListener("environment_updated", function(r) {
501
- var o;
502
- try {
503
- o = JSON.parse(r.data).updated_at;
504
- } catch (u) {
505
- i.log("Could not parse sse event", u);
506
- }
507
- o ? !i.timestamp || o > i.timestamp ? i.isLoading ? i.log("updated_at is new, but flags are loading", r.data, i.timestamp) : (i.log("updated_at is new, fetching flags", r.data, i.timestamp), i.getFlags()) : i.log("updated_at is outdated, skipping get flags", r.data, i.timestamp) : i.log("No updated_at received, fetching flags", r);
508
- })) : this.log("Error, EventSource is undefined");
509
- }, a;
510
- }();
511
- function Jt(a) {
512
- var e = a.fetch, t = a.AsyncStorage, i = a.eventSource;
513
- return new ie({ fetch: e, AsyncStorage: t, eventSource: i });
514
- }
515
- var rt, ae = (rt = function(a, e) {
516
- return rt = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, i) {
517
- t.__proto__ = i;
518
- } || function(t, i) {
519
- for (var n in i) Object.prototype.hasOwnProperty.call(i, n) && (t[n] = i[n]);
520
- }, rt(a, e);
521
- }, function(a, e) {
522
- if (typeof e != "function" && e !== null) throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
523
- function t() {
524
- this.constructor = a;
525
- }
526
- rt(a, e), a.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
527
- }), Vt = function(a) {
528
- var e = typeof Symbol == "function" && Symbol.iterator, t = e && a[e], i = 0;
529
- if (t) return t.call(a);
530
- if (a && typeof a.length == "number") return { next: function() {
531
- return a && i >= a.length && (a = void 0), { value: a && a[i++], done: !a };
532
- } };
533
- throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
534
- }, zt = function(a, e) {
535
- var t = typeof Symbol == "function" && a[Symbol.iterator];
536
- if (!t) return a;
537
- var i, n, r = t.call(a), o = [];
538
- try {
539
- for (; (e === void 0 || e-- > 0) && !(i = r.next()).done; ) o.push(i.value);
540
- } catch (u) {
541
- n = { error: u };
542
- } finally {
543
- try {
544
- i && !i.done && (t = r.return) && t.call(r);
545
- } finally {
546
- if (n) throw n.error;
547
- }
548
- }
549
- return o;
550
- }, ht = function(a, e, t) {
551
- if (arguments.length === 2) for (var i, n = 0, r = e.length; n < r; n++) !i && n in e || (i || (i = Array.prototype.slice.call(e, 0, n)), i[n] = e[n]);
552
- return a.concat(i || Array.prototype.slice.call(e));
553
- }, re = function(a) {
554
- function e() {
555
- return a.call(this, `EventSource not available.
556
- Consider loading an EventSource polyfill and making it available globally as EventSource, or passing one in as eventSourceClass to the ReconnectingEventSource constructor.`) || this;
557
- }
558
- return ae(e, a), e;
559
- }(Error), Mt = function() {
560
- function a(e, t) {
561
- var i = this;
562
- if (this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, this._configuration = t != null ? Object.assign({}, t) : void 0, this.withCredentials = !1, this._eventSource = null, this._lastEventId = null, this._timer = null, this._listeners = { open: [], error: [], message: [] }, this.url = e.toString(), this.readyState = this.CONNECTING, this.max_retry_time = 3e3, this.eventSourceClass = globalThis.FlagsmithEventSource, this._configuration != null && (this._configuration.lastEventId && (this._lastEventId = this._configuration.lastEventId, delete this._configuration.lastEventId), this._configuration.max_retry_time && (this.max_retry_time = this._configuration.max_retry_time, delete this._configuration.max_retry_time), this._configuration.eventSourceClass && (this.eventSourceClass = this._configuration.eventSourceClass, delete this._configuration.eventSourceClass)), this.eventSourceClass == null || typeof this.eventSourceClass != "function") throw new re();
563
- this._onevent_wrapped = function(n) {
564
- i._onevent(n);
565
- }, this._start();
566
- }
567
- return a.prototype.dispatchEvent = function(e) {
568
- throw new Error("Method not implemented.");
569
- }, a.prototype._start = function() {
570
- var e, t, i = this, n = this.url;
571
- this._lastEventId && (n.indexOf("?") === -1 ? n += "?" : n += "&", n += "lastEventId=" + encodeURIComponent(this._lastEventId)), this._eventSource = new this.eventSourceClass(n, this._configuration), this._eventSource.onopen = function(h) {
572
- i._onopen(h);
573
- }, this._eventSource.onerror = function(h) {
574
- i._onerror(h);
575
- }, this._eventSource.onmessage = function(h) {
576
- i.onmessage(h);
577
- };
578
- try {
579
- for (var r = Vt(Object.keys(this._listeners)), o = r.next(); !o.done; o = r.next()) {
580
- var u = o.value;
581
- this._eventSource.addEventListener(u, this._onevent_wrapped);
582
- }
583
- } catch (h) {
584
- e = { error: h };
585
- } finally {
586
- try {
587
- o && !o.done && (t = r.return) && t.call(r);
588
- } finally {
589
- if (e) throw e.error;
590
- }
591
- }
592
- }, a.prototype._onopen = function(e) {
593
- this.readyState === 0 && (this.readyState = 1, this.onopen(e));
594
- }, a.prototype._onerror = function(e) {
595
- var t = this;
596
- if (this.readyState === 1 && (this.readyState = 0, this.onerror(e)), this._eventSource) {
597
- this._eventSource.close(), this._eventSource = null;
598
- var i = Math.round(this.max_retry_time * Math.random());
599
- this._timer = setTimeout(function() {
600
- return t._start();
601
- }, i);
602
- }
603
- }, a.prototype._onevent = function(e) {
604
- var t, i;
605
- e && e.lastEventId && (this._lastEventId = e.lastEventId);
606
- var n = this._listeners[e.type];
607
- if (n != null) try {
608
- for (var r = Vt(ht([], zt(n), !1)), o = r.next(); !o.done; o = r.next())
609
- o.value.call(this, e);
610
- } catch (u) {
611
- t = { error: u };
612
- } finally {
613
- try {
614
- o && !o.done && (i = r.return) && i.call(r);
615
- } finally {
616
- if (t) throw t.error;
617
- }
618
- }
619
- e.type === "message" && this.onmessage(e);
620
- }, a.prototype.onopen = function(e) {
621
- }, a.prototype.onerror = function(e) {
622
- }, a.prototype.onmessage = function(e) {
623
- }, a.prototype.close = function() {
624
- this._timer && (clearTimeout(this._timer), this._timer = null), this._eventSource && (this._eventSource.close(), this._eventSource = null), this.readyState = 2;
625
- }, a.prototype.addEventListener = function(e, t, i) {
626
- this._listeners[e] == null && (this._listeners[e] = [], this._eventSource != null && this._eventSource.addEventListener(e, this._onevent_wrapped));
627
- var n = this._listeners[e];
628
- n.includes(t) || (this._listeners[e] = ht(ht([], zt(n), !1), [t], !1));
629
- }, a.prototype.removeEventListener = function(e, t, i) {
630
- var n = this._listeners[e];
631
- this._listeners[e] = n.filter(function(r) {
632
- return r !== t;
633
- });
634
- }, a;
635
- }();
636
- globalThis.FlagsmithEventSource = typeof EventSource < "u" ? EventSource : null;
637
- var Ht = function(a, e) {
638
- return e = e || {}, new Promise(function(t, i) {
639
- var n = new XMLHttpRequest(), r = [], o = [], u = {}, h = function() {
640
- return { ok: (n.status / 100 | 0) == 2, statusText: n.statusText, status: n.status, url: n.responseURL, text: function() {
641
- return Promise.resolve(n.responseText);
642
- }, json: function() {
643
- return Promise.resolve(n.responseText).then(JSON.parse);
644
- }, blob: function() {
645
- return Promise.resolve(new Blob([n.response]));
646
- }, clone: h, headers: { keys: function() {
647
- return r;
648
- }, entries: function() {
649
- return o;
650
- }, get: function(l) {
651
- return u[l.toLowerCase()];
652
- }, has: function(l) {
653
- return l.toLowerCase() in u;
654
- } } };
655
- };
656
- for (var d in n.open(e.method || "get", a, !0), n.onload = function() {
657
- n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(l, g, x) {
658
- r.push(g = g.toLowerCase()), o.push([g, x]), u[g] = u[g] ? u[g] + "," + x : x;
659
- }), t(h());
660
- }, n.onerror = i, n.withCredentials = e.credentials == "include", e.headers) n.setRequestHeader(d, e.headers[d]);
661
- n.send(e.body || null);
662
- });
663
- }, $t = Jt({ AsyncStorage: p, fetch: Ht, eventSource: Mt });
664
- typeof window < "u" && (window.flagsmith = $t), y.createFlagsmithInstance = function() {
665
- return Jt({ AsyncStorage: p, fetch: Ht, eventSource: Mt });
666
- }, y.default = $t, Object.defineProperty(y, "__esModule", { value: !0 });
667
- });
668
- })(Pt, Pt.exports);
669
- var ce = Pt.exports, he = {
670
- NOT_INITIALIZED: "FeatureFlag not initialized. Call init() first."
671
- }, ee = "business", K, ve = (K = class {
672
- constructor() {
673
- ot(this, "flagsmithClient", null);
674
- ot(this, "userContext", null);
675
- }
676
- static getInstance() {
677
- return K.instance || (K.instance = new K()), K.instance;
678
- }
679
- ensureInitialized() {
680
- if (!this.flagsmithClient)
681
- throw new Error(he.NOT_INITIALIZED);
682
- }
683
- async init(c, y = []) {
684
- if (!this.flagsmithClient)
685
- try {
686
- this.flagsmithClient = ce.createFlagsmithInstance();
687
- const p = y.reduce((s, k) => (s[k.feature.name] = k, s), {});
688
- await this.flagsmithClient.init({
689
- environmentID: c.apiKey,
690
- api: (c == null ? void 0 : c.url) ?? "https://feature-flag-proxy.feedme.farm/api/v1/",
691
- enableAnalytics: (c == null ? void 0 : c.enableAnalytics) ?? !0,
692
- defaultFlags: p,
693
- cacheFlags: (c == null ? void 0 : c.cacheFlags) ?? !0
694
- });
695
- } catch (p) {
696
- throw console.error("Failed to initialize FeatureFlag:", p), p;
697
- }
698
- }
699
- async setUser(c) {
700
- this.ensureInitialized(), this.userContext = { identifier: c }, await this.updateContext();
701
- }
702
- async updateContext() {
703
- try {
704
- if (!this.userContext) return;
705
- await this.flagsmithClient.setContext({
706
- identity: {
707
- identifier: this.userContext.identifier
708
- }
709
- });
710
- } catch (c) {
711
- throw console.error("Failed to update user context:", c), c;
712
- }
713
- }
714
- async getFlags() {
715
- this.ensureInitialized();
716
- const c = this.flagsmithClient.getAllFlags();
717
- return Object.entries(c).map(([y, p]) => {
718
- var s;
719
- return {
720
- feature: {
721
- name: y,
722
- id: (p == null ? void 0 : p.id) ?? 0
723
- },
724
- enabled: p.enabled,
725
- value: ((s = p.value) == null ? void 0 : s.toString()) ?? null
726
- };
727
- });
728
- }
729
- getFlagValue(c, y) {
730
- this.ensureInitialized();
731
- const p = this.flagsmithClient.getValue(c);
732
- if (p == null)
733
- return null;
734
- try {
735
- const s = p.toString();
736
- return y ? y(s) : typeof {} == "number" ? isNaN(Number(s)) ? null : Number(s) : typeof {} == "boolean" ? s.toLowerCase() === "true" : s;
737
- } catch (s) {
738
- return console.error("Error transforming flag value:", s), null;
739
- }
740
- }
741
- getFlag(c) {
742
- this.ensureInitialized();
743
- const y = this.flagsmithClient.getValue(c);
744
- if (y == null) return null;
745
- const p = this.flagsmithClient.hasFeature(c);
746
- return {
747
- feature: {
748
- name: c,
749
- id: 0
750
- },
751
- enabled: p,
752
- value: y.toString()
753
- };
754
- }
755
- async getUserFlagValue(c, y, p = null, s) {
756
- var M;
757
- const k = this.userContext;
758
- try {
759
- return await this.setUser(c), this.getFlagValue(y, s) ?? p;
760
- } catch (D) {
761
- return console.error(`Error getting user flag value for ${y}:`, D), p;
762
- } finally {
763
- try {
764
- await ((M = this.flagsmithClient) == null ? void 0 : M.logout()), this.userContext = null, k && await this.setUser(k.identifier);
765
- } catch (D) {
766
- console.error("Error during cleanup:", D);
767
- }
768
- }
769
- }
770
- reset() {
771
- this.flagsmithClient = null, this.userContext = null;
772
- }
773
- }, ot(K, "instance"), K), de = ve.getInstance(), et = Rt(!1), lt = Rt([]), Y = Rt(null);
774
- function ge(S = de) {
775
- const c = () => et.value ? !0 : (console.warn("FeatureFlag is not initialized. Using default values."), !1), y = async (v, C = []) => {
776
- if (et.value) {
777
- console.warn("FeatureFlag is already initialized.");
778
- return;
779
- }
780
- try {
781
- await S.init(v, C), lt.value = await S.getFlags(), et.value = !0, Y.value = null;
782
- } catch (_) {
783
- console.error("Failed to initialize feature flags:", _), Y.value = _;
784
- }
785
- }, p = async (v) => {
786
- if (c())
787
- try {
788
- await S.setUser(v), lt.value = await S.getFlags(), Y.value = null;
789
- } catch (C) {
790
- console.error("Failed to set user:", C), Y.value = C;
791
- }
792
- }, s = async (v) => p(`${ee}-${v}`), k = (v, C, _ = null) => {
793
- if (!c()) return _;
794
- try {
795
- return S.getFlagValue(v, C) ?? _;
796
- } catch (G) {
797
- return console.error(`Error getting flag value for ${v}:`, G), _;
798
- }
799
- }, M = (v, C) => {
800
- if (!c()) return C ?? null;
801
- try {
802
- return S.getFlag(v) ?? C ?? null;
803
- } catch (_) {
804
- return console.error(`Error getting flag for ${v}:`, _), C ?? null;
805
- }
806
- }, D = async (v, C, _ = null, G) => {
807
- if (!c()) return _;
808
- try {
809
- return await S.getUserFlagValue(v, C, _, G);
810
- } catch (it) {
811
- return console.error(`Error getting user flag value for ${C}:`, it), _;
812
- }
813
- }, nt = async (v, C, _ = null, G) => D(`${ee}-${v}`, C, _, G), b = () => {
814
- try {
815
- S.reset();
816
- } catch (v) {
817
- console.error("Error resetting feature flags:", v);
818
- } finally {
819
- lt.value = [], et.value = !1, Y.value = null;
820
- }
821
- };
822
- return {
823
- flags: Nt(lt),
824
- isInitialized: Nt(et),
825
- error: Nt(Y),
826
- init: y,
827
- setUser: p,
828
- setBusiness: s,
829
- getFlagValue: k,
830
- getFlag: M,
831
- getUserFlagValue: D,
832
- getBusinessFlagValue: nt,
833
- reset: b
834
- };
835
- }
836
- var Ce = () => ge();
837
- export {
838
- Se as h,
839
- me as p,
840
- Ce as u
841
- };