@feedmepos/mf-inventory-portal 0.0.25-dev.52 → 0.0.25-dev.53
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.
- package/dist/{App-DkPiRPu7.js → App-CjqJghCI.js} +2 -2
- package/dist/{ApprovalView-BEF-qPdZ.js → ApprovalView-C42xNBr9.js} +2 -2
- package/dist/{BindingsDialog-B6vjaPiA.js → BindingsDialog-DfShaOTO.js} +2 -2
- package/dist/{BindingsPicker-BmWf3j6H.js → BindingsPicker-BZmmKaqZ.js} +1 -1
- package/dist/{BindingsTable-VVNmzkzf.js → BindingsTable-Dzk1x-qi.js} +1 -1
- package/dist/{ClosingDraftView-C6sNEHK5.js → ClosingDraftView-DpP-cqpM.js} +91 -91
- package/dist/{ClosingTemplateView-5k8R-fMI.js → ClosingTemplateView-DSo8B_Cq.js} +3 -3
- package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DclFOxv5.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-JsmwiIQG.js} +3 -3
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BFqAE1ZI.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DhicQW8Q.js} +1 -1
- package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DwAyTAFy.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-feCBwmiz.js} +1 -1
- package/dist/{IngredientGroupView-DAeurvqt.js → IngredientGroupView-p1jRflBc.js} +1 -1
- package/dist/{IngredientsView-Ca8fShPE.js → IngredientsView-KrhaER9Y.js} +4 -4
- package/dist/{IntegrationView-Db4XlQvK.js → IntegrationView-CFXpiR1g.js} +2 -2
- package/dist/{InventoryBindingForm-BTtpF1P5.js → InventoryBindingForm-CaeO-fpj.js} +1 -1
- package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-ByJPHKqO.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-CPgkL2CW.js} +3 -3
- package/dist/{InventoryBindingSummary-Bb5gN9Bu.js → InventoryBindingSummary-NLY5i6ql.js} +1 -1
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-D4vUOy_R.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BTJ4Omyi.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-fFfOjNOU.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CEroADf4.js} +1 -1
- package/dist/{PublishView-BqE9qfwb.js → PublishView-DFTo5S0F.js} +45 -45
- package/dist/{PurchaseOrderPrintPreview-Cp6a-P8I.js → PurchaseOrderPrintPreview-7YBYHbP6.js} +1 -1
- package/dist/{ReceiveRequestView-DKPPCyAU.js → ReceiveRequestView-BG5s-oS9.js} +9 -9
- package/dist/{RecipeView-BEsrqzuU.js → RecipeView-kc50YRZk.js} +3 -3
- package/dist/{StockView-DplJi2OM.js → StockView-XymZfzq8.js} +7 -7
- package/dist/{SupplierView-DL3D84U2.js → SupplierView-B2vB9f9I.js} +4 -4
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-BzFkrRui.js → TransferDetails.vue_vue_type_script_setup_true_lang-CsQoRock.js} +5 -5
- package/dist/{TransferTemplateView-DakAYozL.js → TransferTemplateView-OD4SE6qf.js} +7 -7
- package/dist/{UnitView-C_Wqv69Z.js → UnitView-Bb8gEtVh.js} +3 -3
- package/dist/{WarehouseView-CeoVZ9cs.js → WarehouseView-BeGII5M9.js} +1 -1
- package/dist/{app-CulzKCFs.js → app-CvTTGb1Y.js} +8200 -8269
- package/dist/app.d.ts +3 -0
- package/dist/app.js +1 -1
- package/dist/{decimal-DdjfkmJS.js → decimal-XcUTkVCR.js} +1 -1
- package/dist/{feature-jwErVPVw.js → feature-Bv1NYHN4.js} +415 -421
- package/dist/{format-unit-display-BMC3HZ0N.js → format-unit-display-BsM7BR8x.js} +2 -2
- package/dist/{index-BDCZItPF.js → index-j3NNoa4K.js} +1 -1
- package/dist/{index-C7-QVxlo.js → index-xfhlIOM0.js} +1 -1
- package/dist/{stock-Czw9__W8.js → stock-DgLOMQ1X.js} +1 -1
- package/dist/{supplier-f0XPCLm-.js → supplier-B0HyUoxP.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{use-ingredient-select-dialog-DDeNnPW0.js → use-ingredient-select-dialog-D9arr1HY.js} +1 -1
- package/dist/{use-inventory-binding-dialog-BTE0Ceov.js → use-inventory-binding-dialog-DGnSxKpE.js} +1 -1
- package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +88 -0
- package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +528 -0
- package/dist/{vue-i18n-B0gOxrrS.js → vue-i18n-BFNEEDAX.js} +349 -349
- package/package.json +4 -4
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var fe = Object.defineProperty;
|
|
2
|
-
var pe = (
|
|
3
|
-
var
|
|
2
|
+
var pe = (m, u, h) => u in m ? fe(m, u, { enumerable: !0, configurable: !0, writable: !0, value: h }) : m[u] = h;
|
|
3
|
+
var ct = (m, u, h) => pe(m, typeof u != "symbol" ? u + "" : u, h);
|
|
4
4
|
import { useCoreStore as vt } from "@feedmepos/mf-common";
|
|
5
|
-
import { a5 as
|
|
6
|
-
import { ref as
|
|
5
|
+
import { a5 as ht, u as Dt, aH as re, a as ye } from "./app-CvTTGb1Y.js";
|
|
6
|
+
import { ref as dt, readonly as Kt } from "vue";
|
|
7
7
|
var Gt = { exports: {} };
|
|
8
|
-
(function(
|
|
9
|
-
(function(
|
|
10
|
-
|
|
11
|
-
})(
|
|
12
|
-
var
|
|
8
|
+
(function(m, u) {
|
|
9
|
+
(function(h, g) {
|
|
10
|
+
g(u);
|
|
11
|
+
})(ht, function(h) {
|
|
12
|
+
var g = { getItemSync: function(a) {
|
|
13
13
|
try {
|
|
14
14
|
return localStorage.getItem(a) || null;
|
|
15
15
|
} catch {
|
|
@@ -21,8 +21,8 @@ var Gt = { exports: {} };
|
|
|
21
21
|
try {
|
|
22
22
|
var r = t.getItemSync(a);
|
|
23
23
|
e == null || e(null, r), i(r);
|
|
24
|
-
} catch (
|
|
25
|
-
e && e(
|
|
24
|
+
} catch (o) {
|
|
25
|
+
e && e(o, null), n(o);
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
}, setItem: function(a, e, t) {
|
|
@@ -33,101 +33,101 @@ var Gt = { exports: {} };
|
|
|
33
33
|
t && t(r, null), n(r);
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
} },
|
|
37
|
-
return
|
|
36
|
+
} }, s = function() {
|
|
37
|
+
return s = Object.assign || function(a) {
|
|
38
38
|
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]);
|
|
39
39
|
return a;
|
|
40
|
-
},
|
|
40
|
+
}, s.apply(this, arguments);
|
|
41
41
|
};
|
|
42
|
-
function
|
|
42
|
+
function F(a, e, t, i) {
|
|
43
43
|
return new (t || (t = Promise))(function(n, r) {
|
|
44
|
-
function
|
|
44
|
+
function o(f) {
|
|
45
45
|
try {
|
|
46
|
-
|
|
47
|
-
} catch (
|
|
48
|
-
r(
|
|
46
|
+
v(i.next(f));
|
|
47
|
+
} catch (l) {
|
|
48
|
+
r(l);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
function c(f) {
|
|
52
52
|
try {
|
|
53
|
-
|
|
54
|
-
} catch (
|
|
55
|
-
r(
|
|
53
|
+
v(i.throw(f));
|
|
54
|
+
} catch (l) {
|
|
55
|
+
r(l);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
var
|
|
60
|
-
f.done ? n(f.value) : (
|
|
61
|
-
|
|
62
|
-
})).then(
|
|
58
|
+
function v(f) {
|
|
59
|
+
var l;
|
|
60
|
+
f.done ? n(f.value) : (l = f.value, l instanceof t ? l : new t(function(p) {
|
|
61
|
+
p(l);
|
|
62
|
+
})).then(o, c);
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
v((i = i.apply(a, [])).next());
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
var t, i, n, r,
|
|
67
|
+
function J(a, e) {
|
|
68
|
+
var t, i, n, r, o = { label: 0, sent: function() {
|
|
69
69
|
if (1 & n[0]) throw n[1];
|
|
70
70
|
return n[1];
|
|
71
71
|
}, trys: [], ops: [] };
|
|
72
72
|
return r = { next: c(0), throw: c(1), return: c(2) }, typeof Symbol == "function" && (r[Symbol.iterator] = function() {
|
|
73
73
|
return this;
|
|
74
74
|
}), r;
|
|
75
|
-
function c(
|
|
75
|
+
function c(v) {
|
|
76
76
|
return function(f) {
|
|
77
|
-
return function(
|
|
77
|
+
return function(l) {
|
|
78
78
|
if (t) throw new TypeError("Generator is already executing.");
|
|
79
|
-
for (;
|
|
80
|
-
if (t = 1, i && (n = 2 &
|
|
81
|
-
switch (i = 0, n && (
|
|
79
|
+
for (; o; ) try {
|
|
80
|
+
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;
|
|
81
|
+
switch (i = 0, n && (l = [2 & l[0], n.value]), l[0]) {
|
|
82
82
|
case 0:
|
|
83
83
|
case 1:
|
|
84
|
-
n =
|
|
84
|
+
n = l;
|
|
85
85
|
break;
|
|
86
86
|
case 4:
|
|
87
|
-
return
|
|
87
|
+
return o.label++, { value: l[1], done: !1 };
|
|
88
88
|
case 5:
|
|
89
|
-
|
|
89
|
+
o.label++, i = l[1], l = [0];
|
|
90
90
|
continue;
|
|
91
91
|
case 7:
|
|
92
|
-
|
|
92
|
+
l = o.ops.pop(), o.trys.pop();
|
|
93
93
|
continue;
|
|
94
94
|
default:
|
|
95
|
-
if (n =
|
|
96
|
-
|
|
95
|
+
if (n = o.trys, !((n = n.length > 0 && n[n.length - 1]) || l[0] !== 6 && l[0] !== 2)) {
|
|
96
|
+
o = 0;
|
|
97
97
|
continue;
|
|
98
98
|
}
|
|
99
|
-
if (
|
|
100
|
-
|
|
99
|
+
if (l[0] === 3 && (!n || l[1] > n[0] && l[1] < n[3])) {
|
|
100
|
+
o.label = l[1];
|
|
101
101
|
break;
|
|
102
102
|
}
|
|
103
|
-
if (
|
|
104
|
-
|
|
103
|
+
if (l[0] === 6 && o.label < n[1]) {
|
|
104
|
+
o.label = n[1], n = l;
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
107
|
-
if (n &&
|
|
108
|
-
|
|
107
|
+
if (n && o.label < n[2]) {
|
|
108
|
+
o.label = n[2], o.ops.push(l);
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
|
-
n[2] &&
|
|
111
|
+
n[2] && o.ops.pop(), o.trys.pop();
|
|
112
112
|
continue;
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
} catch (
|
|
116
|
-
|
|
114
|
+
l = e.call(a, o);
|
|
115
|
+
} catch (p) {
|
|
116
|
+
l = [6, p], i = 0;
|
|
117
117
|
} finally {
|
|
118
118
|
t = n = 0;
|
|
119
119
|
}
|
|
120
|
-
if (5 &
|
|
121
|
-
return { value:
|
|
122
|
-
}([
|
|
120
|
+
if (5 & l[0]) throw l[1];
|
|
121
|
+
return { value: l[0] ? l[1] : void 0, done: !0 };
|
|
122
|
+
}([v, f]);
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function I(a, e, t) {
|
|
127
127
|
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]);
|
|
128
128
|
return a.concat(i || Array.prototype.slice.call(e));
|
|
129
129
|
}
|
|
130
|
-
var
|
|
130
|
+
var nt = function a(e, t) {
|
|
131
131
|
if (e === t) return !0;
|
|
132
132
|
if (e && t && typeof e == "object" && typeof t == "object") {
|
|
133
133
|
if (e.constructor !== t.constructor) return !1;
|
|
@@ -143,110 +143,110 @@ var Gt = { exports: {} };
|
|
|
143
143
|
if ((i = (r = Object.keys(e)).length) !== Object.keys(t).length) return !1;
|
|
144
144
|
for (n = i; n-- != 0; ) if (!Object.prototype.hasOwnProperty.call(t, r[n])) return !1;
|
|
145
145
|
for (n = i; n-- != 0; ) {
|
|
146
|
-
var
|
|
147
|
-
if (!a(e[
|
|
146
|
+
var o = r[n];
|
|
147
|
+
if (!a(e[o], t[o])) return !1;
|
|
148
148
|
}
|
|
149
149
|
return !0;
|
|
150
150
|
}
|
|
151
151
|
return e != e && t != t;
|
|
152
152
|
};
|
|
153
|
-
function
|
|
153
|
+
function C(a, e) {
|
|
154
154
|
var t = Object.keys(e || {}).filter(function(i) {
|
|
155
155
|
var n = a == null ? void 0 : a[i], r = e == null ? void 0 : e[i];
|
|
156
|
-
return !
|
|
156
|
+
return !nt(n, r);
|
|
157
157
|
});
|
|
158
158
|
return Object.keys(a || {}).filter(function(i) {
|
|
159
159
|
Object.keys(e || {}).includes(i) || t.push(i);
|
|
160
160
|
}), Object.keys(t).length ? t : null;
|
|
161
161
|
}
|
|
162
|
-
var
|
|
163
|
-
function
|
|
162
|
+
var d, S;
|
|
163
|
+
function _(a, e, t) {
|
|
164
164
|
var i = "shortString", n = !0;
|
|
165
165
|
typeof t == "number" && (i = "javaDouble", n = !1), a[i] = a[i] || {}, a[i][e] = n ? t + "" : t;
|
|
166
166
|
}
|
|
167
|
-
function
|
|
167
|
+
function N(a) {
|
|
168
168
|
return !!a && typeof a == "object" && a.value !== void 0;
|
|
169
169
|
}
|
|
170
|
-
function
|
|
170
|
+
function H(a) {
|
|
171
171
|
return Object.fromEntries(Object.entries(a).map(function(e) {
|
|
172
172
|
var t = e[0], i = e[1];
|
|
173
|
-
return [t,
|
|
173
|
+
return [t, N(i) ? i : { value: i }];
|
|
174
174
|
}));
|
|
175
175
|
}
|
|
176
|
-
function
|
|
177
|
-
return
|
|
176
|
+
function X(a) {
|
|
177
|
+
return s(s({}, a), { identity: a.identity ? s(s({}, a.identity), { traits: H(a.identity.traits || {}) }) : void 0 });
|
|
178
178
|
}
|
|
179
179
|
(function(a) {
|
|
180
180
|
a.NONE = "NONE", a.DEFAULT_FLAGS = "DEFAULT_FLAGS", a.CACHE = "CACHE", a.SERVER = "SERVER";
|
|
181
|
-
})(
|
|
182
|
-
var
|
|
181
|
+
})(d || (d = {}));
|
|
182
|
+
var q, L = null, ce = "FLAGSMITH_EVENT", lt = ce, Jt = "https://edge.api.flagsmith.com/api/v1/", Mt = "flagsmith_value_", Bt = "flagsmith_enabled_", zt = "flagsmith_trait_", ve = function() {
|
|
183
183
|
function a(e) {
|
|
184
184
|
var t = this;
|
|
185
185
|
this._trigger = null, this._triggerLoadingState = null, this.timestamp = null, this.isLoading = !1, this.eventSource = null, this.getFlags = function() {
|
|
186
186
|
var i = t, n = i.api, r = i.evaluationContext;
|
|
187
|
-
t.log("Get Flags"), t.isLoading = !0, t.loadingState.isFetching || t.setLoadingState(
|
|
188
|
-
var
|
|
189
|
-
var f,
|
|
190
|
-
if (
|
|
191
|
-
var
|
|
187
|
+
t.log("Get Flags"), t.isLoading = !0, t.loadingState.isFetching || t.setLoadingState(s(s({}, t.loadingState), { isFetching: !0 }));
|
|
188
|
+
var o = "".concat(t.getContext().identity), c = function(v) {
|
|
189
|
+
var f, l, p, E;
|
|
190
|
+
if (v && o === "".concat(t.getContext().identity)) {
|
|
191
|
+
var U = v.flags, T = v.traits, k = v.identifier;
|
|
192
192
|
t.isLoading = !1;
|
|
193
|
-
var
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}),
|
|
197
|
-
|
|
198
|
-
}), t.oldFlags =
|
|
199
|
-
var
|
|
200
|
-
if ((k || Object.keys(
|
|
193
|
+
var A = {}, j = {};
|
|
194
|
+
T = T || [], (U = U || []).forEach(function(y) {
|
|
195
|
+
A[y.feature.name.toLowerCase().replace(/ /g, "_")] = { id: y.feature.id, enabled: y.enabled, value: y.feature_state_value };
|
|
196
|
+
}), T.forEach(function(y) {
|
|
197
|
+
j[y.trait_key.toLowerCase().replace(/ /g, "_")] = { transient: y.transient, value: y.trait_value };
|
|
198
|
+
}), t.oldFlags = s({}, t.flags);
|
|
199
|
+
var D = C(t.oldFlags, A), it = C((f = t.evaluationContext.identity) === null || f === void 0 ? void 0 : f.traits, j);
|
|
200
|
+
if ((k || Object.keys(j).length) && (t.evaluationContext.identity = s(s({}, t.evaluationContext.identity), { traits: j }), k && (t.evaluationContext.identity.identifier = k)), t.flags = A, t.updateStorage(), t._onChange(t.oldFlags, { isFromServer: !0, flagsChanged: D, traitsChanged: it }, t._loadedState(null, d.SERVER)), t.datadogRum) try {
|
|
201
201
|
if (t.datadogRum.trackTraits) {
|
|
202
|
-
var
|
|
203
|
-
Object.keys(((
|
|
204
|
-
|
|
202
|
+
var at = {};
|
|
203
|
+
Object.keys(((l = t.evaluationContext.identity) === null || l === void 0 ? void 0 : l.traits) || {}).map(function(y) {
|
|
204
|
+
at[zt + y] = t.getTrait(y);
|
|
205
205
|
});
|
|
206
|
-
var
|
|
207
|
-
t.log("Setting Datadog user",
|
|
206
|
+
var W = s(s(s({}, t.datadogRum.client.getUser()), { id: t.datadogRum.client.getUser().id || ((p = t.evaluationContext.identity) === null || p === void 0 ? void 0 : p.identifier) }), at);
|
|
207
|
+
t.log("Setting Datadog user", W), t.datadogRum.client.setUser(W);
|
|
208
208
|
}
|
|
209
|
-
} catch (
|
|
210
|
-
console.error(
|
|
209
|
+
} catch (y) {
|
|
210
|
+
console.error(y);
|
|
211
211
|
}
|
|
212
212
|
if (t.dtrum) try {
|
|
213
213
|
var O = { javaDouble: {}, date: {}, shortString: {}, javaLongOrObject: {} };
|
|
214
|
-
Object.keys(t.flags).map(function(
|
|
215
|
-
|
|
216
|
-
}), Object.keys(((
|
|
217
|
-
|
|
214
|
+
Object.keys(t.flags).map(function(y) {
|
|
215
|
+
_(O, Mt + y, t.getValue(y, { skipAnalytics: !0 })), _(O, Bt + y, t.hasFeature(y, { skipAnalytics: !0 }));
|
|
216
|
+
}), Object.keys(((E = t.evaluationContext.identity) === null || E === void 0 ? void 0 : E.traits) || {}).map(function(y) {
|
|
217
|
+
_(O, zt + y, t.getTrait(y));
|
|
218
218
|
}), t.log("Sending javaLongOrObject traits to dynatrace", O.javaLongOrObject), t.log("Sending date traits to dynatrace", O.date), t.log("Sending shortString traits to dynatrace", O.shortString), t.log("Sending javaDouble to dynatrace", O.javaDouble), t.dtrum.sendSessionProperties(O.javaLongOrObject, O.date, O.shortString, O.javaDouble);
|
|
219
|
-
} catch (
|
|
220
|
-
console.error(
|
|
219
|
+
} catch (y) {
|
|
220
|
+
console.error(y);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
|
-
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(
|
|
225
|
-
var f =
|
|
226
|
-
return { trait_key: f, trait_value:
|
|
227
|
-
}).filter(function(
|
|
228
|
-
return
|
|
229
|
-
}) })) : t.getJSON(n + "identities/?identifier=" + encodeURIComponent(r.identity.identifier) + (r.identity.transient ? "&transient=true" : ""))]).then(function(
|
|
230
|
-
return t.evaluationContext.identity =
|
|
231
|
-
}).catch(function(
|
|
232
|
-
var f =
|
|
233
|
-
return Promise.reject(
|
|
234
|
-
}) : t.getJSON(n + "flags/").then(function(
|
|
235
|
-
return c({ flags:
|
|
224
|
+
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(v) {
|
|
225
|
+
var f = v[0], l = v[1];
|
|
226
|
+
return { trait_key: f, trait_value: l == null ? void 0 : l.value, transient: l == null ? void 0 : l.transient };
|
|
227
|
+
}).filter(function(v) {
|
|
228
|
+
return v.trait_value !== void 0 || (t.log("Warning - attempted to set an undefined trait value for key", v.trait_key), !1);
|
|
229
|
+
}) })) : t.getJSON(n + "identities/?identifier=" + encodeURIComponent(r.identity.identifier) + (r.identity.transient ? "&transient=true" : ""))]).then(function(v) {
|
|
230
|
+
return t.evaluationContext.identity = s(s({}, t.evaluationContext.identity), { traits: {} }), c(v == null ? void 0 : v[0]);
|
|
231
|
+
}).catch(function(v) {
|
|
232
|
+
var f = v.message, l = new Error(f);
|
|
233
|
+
return Promise.reject(l);
|
|
234
|
+
}) : t.getJSON(n + "flags/").then(function(v) {
|
|
235
|
+
return c({ flags: v, traits: void 0 });
|
|
236
236
|
});
|
|
237
237
|
}, this.analyticsFlags = function() {
|
|
238
238
|
var i = t.api;
|
|
239
239
|
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) {
|
|
240
240
|
if (t.evaluationContext.environment) {
|
|
241
241
|
var r = t.getState();
|
|
242
|
-
t.evaluationEvent || (t.evaluationEvent = {}), t.evaluationEvent[t.evaluationContext.environment.apiKey] = {}, t.setState(
|
|
242
|
+
t.evaluationEvent || (t.evaluationEvent = {}), t.evaluationEvent[t.evaluationContext.environment.apiKey] = {}, t.setState(s(s({}, r), { evaluationEvent: t.evaluationEvent })), t.updateEventStorage();
|
|
243
243
|
}
|
|
244
244
|
}).catch(function(n) {
|
|
245
245
|
t.log("Exception fetching evaluationEvent", n);
|
|
246
246
|
}) : void 0;
|
|
247
|
-
}, this.datadogRum = null, this.loadingState = { isLoading: !0, isFetching: !0, error: null, source:
|
|
248
|
-
var
|
|
249
|
-
if (
|
|
247
|
+
}, this.datadogRum = null, this.loadingState = { isLoading: !0, isFetching: !0, error: null, source: d.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) {
|
|
248
|
+
var o = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")], c = null;
|
|
249
|
+
if (o && (c = o.value), n != null && n.skipAnalytics || r || t.evaluateFlag(i, "VALUE"), c === null && (n == null ? void 0 : n.fallback) !== void 0) return n.fallback;
|
|
250
250
|
if (n != null && n.json) try {
|
|
251
251
|
return c === null ? (t.log("Tried to parse null flag as JSON: " + i), null) : JSON.parse(c);
|
|
252
252
|
} catch {
|
|
@@ -259,59 +259,59 @@ var Gt = { exports: {} };
|
|
|
259
259
|
}, this.getAllTraits = function() {
|
|
260
260
|
var i;
|
|
261
261
|
return Object.fromEntries(Object.entries(((i = t.evaluationContext.identity) === null || i === void 0 ? void 0 : i.traits) || {}).map(function(n) {
|
|
262
|
-
var r = n[0],
|
|
263
|
-
return [r,
|
|
262
|
+
var r = n[0], o = n[1];
|
|
263
|
+
return [r, o == null ? void 0 : o.value];
|
|
264
264
|
}));
|
|
265
265
|
}, this.setContext = function(i) {
|
|
266
|
-
var n =
|
|
267
|
-
return t.evaluationContext =
|
|
266
|
+
var n = X(i);
|
|
267
|
+
return t.evaluationContext = s(s({}, n), { environment: n.environment || t.evaluationContext.environment }), t.initialised ? t.getFlags() : Promise.resolve();
|
|
268
268
|
}, this.getContext = function() {
|
|
269
269
|
return t.evaluationContext;
|
|
270
270
|
}, this.updateContext = function(i) {
|
|
271
|
-
return t.setContext(
|
|
271
|
+
return t.setContext(s(s({}, t.getContext()), i));
|
|
272
272
|
}, this.setTrait = function(i, n) {
|
|
273
273
|
var r;
|
|
274
|
-
if (t.api) return t.setContext(
|
|
274
|
+
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), H(Object.fromEntries([[i, n]]))) }) }));
|
|
275
275
|
}, this.setTraits = function(i) {
|
|
276
276
|
var n;
|
|
277
|
-
if (t.api) return t.setContext(
|
|
278
|
-
var
|
|
279
|
-
return [
|
|
277
|
+
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) {
|
|
278
|
+
var o = r[0], c = r[1];
|
|
279
|
+
return [o, N(c) ? c : { value: c }];
|
|
280
280
|
}))) }) }));
|
|
281
281
|
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.");
|
|
282
282
|
}, this.hasFeature = function(i, n) {
|
|
283
|
-
var r = typeof n == "object",
|
|
284
|
-
return !
|
|
283
|
+
var r = typeof n == "object", o = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")], c = !1;
|
|
284
|
+
return !o && r && n.fallback !== void 0 ? c = n == null ? void 0 : n.fallback : o && o.enabled && (c = !0), (r && !n.skipAnalytics || !n) && t.evaluateFlag(i, "ENABLED"), c;
|
|
285
285
|
}, this.getStorageKey = function() {
|
|
286
286
|
var i, n;
|
|
287
287
|
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);
|
|
288
288
|
}, this.getJSON = function(i, n, r) {
|
|
289
|
-
var
|
|
289
|
+
var o, c = t;
|
|
290
290
|
c.evaluationContext;
|
|
291
|
-
var
|
|
292
|
-
t.evaluationContext.environment && (f.headers["X-Environment-Key"] = t.evaluationContext.environment.apiKey), n && n !== "GET" && (f.headers["Content-Type"] = "application/json; charset=utf-8"),
|
|
293
|
-
var
|
|
294
|
-
return
|
|
295
|
-
var
|
|
296
|
-
if (
|
|
297
|
-
var k = (
|
|
291
|
+
var v = c.headers, f = { method: n || "GET", body: r, cache: "no-cache", headers: {} };
|
|
292
|
+
t.evaluationContext.environment && (f.headers["X-Environment-Key"] = t.evaluationContext.environment.apiKey), n && n !== "GET" && (f.headers["Content-Type"] = "application/json; charset=utf-8"), v && Object.assign(f.headers, v), S || console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");
|
|
293
|
+
var l = "".concat((o = t.evaluationContext.identity) === null || o === void 0 ? void 0 : o.identifier);
|
|
294
|
+
return S(i, f).then(function(p) {
|
|
295
|
+
var E, U, T = "".concat((E = t.evaluationContext.identity) === null || E === void 0 ? void 0 : E.identifier);
|
|
296
|
+
if (l === T) {
|
|
297
|
+
var k = (U = p.headers) === null || U === void 0 ? void 0 : U.get("x-flagsmith-document-updated-at");
|
|
298
298
|
if (k) try {
|
|
299
|
-
var
|
|
300
|
-
if (isNaN(
|
|
301
|
-
t.timestamp =
|
|
302
|
-
} catch (
|
|
303
|
-
t.log(
|
|
299
|
+
var A = parseFloat(k);
|
|
300
|
+
if (isNaN(A)) return Promise.reject("Failed to parse x-flagsmith-document-updated-at");
|
|
301
|
+
t.timestamp = A;
|
|
302
|
+
} catch (j) {
|
|
303
|
+
t.log(j, "Failed to parse x-flagsmith-document-updated-at", k);
|
|
304
304
|
}
|
|
305
|
-
return t.log("Fetch response: " +
|
|
306
|
-
var
|
|
305
|
+
return t.log("Fetch response: " + p.status + " " + (n || "GET") + 0 + i), p.text().then(function(j) {
|
|
306
|
+
var D = j;
|
|
307
307
|
try {
|
|
308
|
-
|
|
308
|
+
D = JSON.parse(j);
|
|
309
309
|
} catch {
|
|
310
310
|
}
|
|
311
|
-
return !
|
|
311
|
+
return !D && p.status && (D = "API Response: ".concat(p.status)), p.status && p.status >= 200 && p.status < 300 ? D : Promise.reject(new Error(D));
|
|
312
312
|
});
|
|
313
313
|
}
|
|
314
|
-
t.log("Received response with identity mismatch, ignoring response. Requested: ".concat(
|
|
314
|
+
t.log("Received response with identity mismatch, ignoring response. Requested: ".concat(l, ", Current: ").concat(T));
|
|
315
315
|
});
|
|
316
316
|
}, this.evaluateFlag = function(i, n) {
|
|
317
317
|
if (t.datadogRum && (t.datadogRum.client.addFeatureFlagEvaluation ? n === "VALUE" ? t.datadogRum.client.addFeatureFlagEvaluation(Mt + i, t.getValue(i, {}, !0)) : t.datadogRum.client.addFeatureFlagEvaluation(Bt + i, t.hasFeature(i, !0)) : console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")), t.enableAnalytics) {
|
|
@@ -320,127 +320,127 @@ var Gt = { exports: {} };
|
|
|
320
320
|
}
|
|
321
321
|
t.updateEventStorage();
|
|
322
322
|
}, this._onChange = function(i, n, r) {
|
|
323
|
-
var
|
|
324
|
-
t.setLoadingState(r), (
|
|
325
|
-
},
|
|
323
|
+
var o, c;
|
|
324
|
+
t.setLoadingState(r), (o = t.onChange) === null || o === void 0 || o.call(t, i, n, t.loadingState), (c = t._trigger) === null || c === void 0 || c.call(t);
|
|
325
|
+
}, S = e.fetch ? e.fetch : typeof fetch < "u" ? fetch : ht === null || ht === void 0 ? void 0 : ht.fetch, this.canUseStorage = typeof window < "u" || !!e.browserlessStorage, this.log("Constructing flagsmith instance " + e), e.eventSource && (q = e.eventSource), e.AsyncStorage && (L = e.AsyncStorage);
|
|
326
326
|
}
|
|
327
327
|
return a.prototype.init = function(e) {
|
|
328
328
|
var t, i, n;
|
|
329
|
-
return
|
|
330
|
-
var r,
|
|
331
|
-
return
|
|
332
|
-
switch (
|
|
329
|
+
return F(this, void 0, void 0, function() {
|
|
330
|
+
var r, o, c, v, f, l, p, E, U, T, k, A, j, D, it, at, W, O, y, pt, rt, Zt, Y, yt, Qt, te, mt, ee, St, ot, Z, ne, w = this;
|
|
331
|
+
return J(this, function(R) {
|
|
332
|
+
switch (R.label) {
|
|
333
333
|
case 0:
|
|
334
|
-
r =
|
|
334
|
+
r = X(e.evaluationContext || this.evaluationContext), R.label = 1;
|
|
335
335
|
case 1:
|
|
336
|
-
if (
|
|
337
|
-
if (r.identity = pt ||
|
|
338
|
-
return [
|
|
339
|
-
})) : {} } : r.identity, this.evaluationContext = r, this.api =
|
|
340
|
-
|
|
341
|
-
}, this.enableLogs =
|
|
342
|
-
return function(
|
|
343
|
-
var
|
|
344
|
-
return new Promise(function(
|
|
336
|
+
if (R.trys.push([1, 13, , 14]), o = e.environmentID, c = e.api, v = c === void 0 ? Jt : c, f = e.headers, l = e.onChange, p = e.cacheFlags, E = e.datadogRum, U = e.onError, T = e.defaultFlags, k = e.fetch, A = e.preventFetch, j = e.enableLogs, D = e.enableDynatrace, it = e.enableAnalytics, at = e.realtime, W = e.eventSourceUrl, O = W === void 0 ? "https://realtime.flagsmith.com/" : W, y = e.AsyncStorage, pt = e.identity, rt = e.traits, Zt = e.state, Y = e.cacheOptions, yt = e.angularHttpClient, Qt = e._trigger, te = 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`");
|
|
337
|
+
if (r.identity = pt || rt ? { identifier: pt, traits: rt ? Object.fromEntries(Object.entries(rt).map(function(P) {
|
|
338
|
+
return [P[0], { value: P[1] }];
|
|
339
|
+
})) : {} } : r.identity, this.evaluationContext = r, this.api = v, this.headers = f, this.getFlagInterval = null, this.analyticsInterval = null, this.onChange = l, mt = "Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided", this._trigger = Qt || this._trigger, this._triggerLoadingState = te || this._triggerLoadingState, this.onError = function(P) {
|
|
340
|
+
w.setLoadingState(s(s({}, w.loadingState), { isFetching: !1, isLoading: !1, error: P })), U == null || U(P);
|
|
341
|
+
}, this.enableLogs = j || !1, this.cacheOptions = Y ? { skipAPI: !!Y.skipAPI, ttl: Y.ttl || 0, storageKey: Y.storageKey, loadStale: !!Y.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."), k && (S = k), this.enableAnalytics = it || !1, this.flags = Object.assign({}, T) || {}, this.datadogRum = E || null, this.initialised = !0, this.ticks = 1e4, this.timer = this.enableLogs ? (/* @__PURE__ */ new Date()).valueOf() : null, this.cacheFlags = L !== void 0 && !!p, lt = "FLAGSMITH_EVENT_" + r.environment.apiKey, y && (L = y), at && typeof window < "u" && this.setupRealtime(O, r.environment.apiKey), Object.keys(this.flags).length && (this.loadingState = s(s({}, this.loadingState), { isLoading: !1, source: d.DEFAULT_FLAGS })), this.setState(Zt), this.log("Initialising with properties", e, this), D && (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), yt && (S = /* @__PURE__ */ function(P) {
|
|
342
|
+
return function(K, G) {
|
|
343
|
+
var B = G.headers, b = G.method, Q = G.body;
|
|
344
|
+
return new Promise(function($) {
|
|
345
345
|
switch (b) {
|
|
346
346
|
case "GET":
|
|
347
|
-
return
|
|
348
|
-
|
|
349
|
-
return Promise.resolve(
|
|
347
|
+
return P.get(K, { headers: B }).subscribe(function(M) {
|
|
348
|
+
$({ ok: !0, text: function() {
|
|
349
|
+
return Promise.resolve(M);
|
|
350
350
|
} });
|
|
351
351
|
});
|
|
352
352
|
case "POST":
|
|
353
353
|
case "PUT":
|
|
354
|
-
return
|
|
355
|
-
|
|
356
|
-
return Promise.resolve(
|
|
354
|
+
return P.post(K, Q, { headers: B }).subscribe(function(M) {
|
|
355
|
+
$({ ok: !0, text: function() {
|
|
356
|
+
return Promise.resolve(M);
|
|
357
357
|
} });
|
|
358
358
|
});
|
|
359
359
|
}
|
|
360
360
|
});
|
|
361
361
|
};
|
|
362
|
-
}(yt)),
|
|
362
|
+
}(yt)), L && this.canUseStorage && L.getItem(lt).then(function(P) {
|
|
363
363
|
try {
|
|
364
|
-
|
|
364
|
+
w.evaluationEvent = JSON.parse(P) || {};
|
|
365
365
|
} catch {
|
|
366
|
-
|
|
366
|
+
w.evaluationEvent = {};
|
|
367
367
|
}
|
|
368
|
-
|
|
369
|
-
}), this.enableAnalytics && (this.analyticsInterval && clearInterval(this.analyticsInterval),
|
|
370
|
-
if (
|
|
371
|
-
var
|
|
372
|
-
if (
|
|
373
|
-
var
|
|
374
|
-
|
|
368
|
+
w.analyticsInterval = setInterval(w.analyticsFlags, w.ticks);
|
|
369
|
+
}), this.enableAnalytics && (this.analyticsInterval && clearInterval(this.analyticsInterval), L && this.canUseStorage && L.getItem(lt, function(P, K) {
|
|
370
|
+
if (K && w.evaluationContext.environment) {
|
|
371
|
+
var G = JSON.parse(K);
|
|
372
|
+
if (G[w.evaluationContext.environment.apiKey]) {
|
|
373
|
+
var B = w.getState();
|
|
374
|
+
w.log("Retrieved events from cache", K), w.setState(s(s({}, B), { evaluationEvent: G[w.evaluationContext.environment.apiKey] }));
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
-
})), !
|
|
378
|
-
if (!
|
|
379
|
-
ee = function(
|
|
380
|
-
return
|
|
381
|
-
var
|
|
382
|
-
return
|
|
383
|
-
switch (
|
|
377
|
+
})), !p) return [3, 9];
|
|
378
|
+
if (!L || !this.canUseStorage) return [3, 8];
|
|
379
|
+
ee = function(P, K) {
|
|
380
|
+
return F(w, void 0, void 0, function() {
|
|
381
|
+
var G, B, b, Q, $, M, bt, ie, _t, Ct, xt, Ft, Et, Ot, wt, It, Lt, Tt, At, jt, Pt, Nt, kt, Rt, ae = this;
|
|
382
|
+
return J(this, function(z) {
|
|
383
|
+
switch (z.label) {
|
|
384
384
|
case 0:
|
|
385
|
-
if (!
|
|
386
|
-
|
|
385
|
+
if (!K) return [3, 7];
|
|
386
|
+
G = null, B = null, z.label = 1;
|
|
387
387
|
case 1:
|
|
388
|
-
return
|
|
388
|
+
return z.trys.push([1, 5, , 6]), b = JSON.parse(K), Q = !1, $ = !1, b && b.api === this.api && ((Ct = (_t = b.evaluationContext) === null || _t === void 0 ? void 0 : _t.environment) === null || Ct === void 0 ? void 0 : Ct.apiKey) === ((xt = this.evaluationContext.environment) === null || xt === void 0 ? void 0 : xt.apiKey) && (M = !0, this.evaluationContext.identity && ((Et = (Ft = b.evaluationContext) === null || Ft === void 0 ? void 0 : Ft.identity) === null || Et === void 0 ? void 0 : Et.identifier) !== this.evaluationContext.identity.identifier && (this.log("Ignoring cache, identity has changed from " + ((wt = (Ot = b.evaluationContext) === null || Ot === void 0 ? void 0 : Ot.identity) === null || wt === void 0 ? void 0 : wt.identifier) + " to " + this.evaluationContext.identity.identifier), M = !1), this.cacheOptions.ttl && (!b.ts || (/* @__PURE__ */ new Date()).valueOf() - b.ts > this.cacheOptions.ttl) && (b.ts && !this.cacheOptions.loadStale ? (this.log("Ignoring cache, timestamp is too old ts:" + b.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - b.ts) + "ms"), M = !1) : b.ts && this.cacheOptions.loadStale && (this.log("Loading stale cache, timestamp ts:" + b.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - b.ts) + "ms"), $ = !0, M = !0)), M && (Q = !0, B = C((It = this.evaluationContext.identity) === null || It === void 0 ? void 0 : It.traits, (Tt = (Lt = b.evaluationContext) === null || Lt === void 0 ? void 0 : Lt.identity) === null || Tt === void 0 ? void 0 : Tt.traits), G = C(this.flags, b.flags), this.setState(s(s({}, b), { evaluationContext: X(s(s({}, b.evaluationContext), { identity: !((At = b.evaluationContext) === null || At === void 0) && At.identity ? s(s({}, (jt = b.evaluationContext) === null || jt === void 0 ? void 0 : jt.identity), { traits: s(s({}, ((Nt = (Pt = b.evaluationContext) === null || Pt === void 0 ? void 0 : Pt.identity) === null || Nt === void 0 ? void 0 : Nt.traits) || {}), rt || {}) }) : void 0 })) })), this.log("Retrieved flags from cache", b))), Q ? (bt = !A && (!this.cacheOptions.skipAPI || $), this._onChange(null, { isFromServer: !1, flagsChanged: G, traitsChanged: B }, this._loadedState(null, d.CACHE, bt)), this.oldFlags = this.flags, this.cacheOptions.skipAPI && Q && !$ && this.log("Skipping API, using cache"), bt && this.getFlags().catch(function(de) {
|
|
389
389
|
var Ut;
|
|
390
|
-
(Ut = ae.onError) === null || Ut === void 0 || Ut.call(ae,
|
|
390
|
+
(Ut = ae.onError) === null || Ut === void 0 || Ut.call(ae, de);
|
|
391
391
|
}), [3, 4]) : [3, 2];
|
|
392
392
|
case 2:
|
|
393
|
-
return
|
|
393
|
+
return A ? [3, 4] : [4, this.getFlags()];
|
|
394
394
|
case 3:
|
|
395
|
-
|
|
395
|
+
z.sent(), z.label = 4;
|
|
396
396
|
case 4:
|
|
397
397
|
return [3, 6];
|
|
398
398
|
case 5:
|
|
399
|
-
return ie =
|
|
399
|
+
return ie = z.sent(), this.log("Exception fetching cached logs", ie), [3, 6];
|
|
400
400
|
case 6:
|
|
401
401
|
return [3, 10];
|
|
402
402
|
case 7:
|
|
403
|
-
return
|
|
403
|
+
return A ? [3, 9] : [4, this.getFlags()];
|
|
404
404
|
case 8:
|
|
405
|
-
return
|
|
405
|
+
return z.sent(), [3, 10];
|
|
406
406
|
case 9:
|
|
407
|
-
if (
|
|
407
|
+
if (T) this._onChange(null, { isFromServer: !1, flagsChanged: C({}, this.flags), traitsChanged: C({}, (kt = this.evaluationContext.identity) === null || kt === void 0 ? void 0 : kt.traits) }, this._loadedState(null, d.DEFAULT_FLAGS));
|
|
408
408
|
else {
|
|
409
409
|
if (!this.flags) throw new Error(mt);
|
|
410
|
-
this._onChange(null, { isFromServer: !1, flagsChanged:
|
|
410
|
+
this._onChange(null, { isFromServer: !1, flagsChanged: C({}, this.flags), traitsChanged: C({}, (Rt = this.evaluationContext.identity) === null || Rt === void 0 ? void 0 : Rt.traits) }, this._loadedState(null, d.DEFAULT_FLAGS));
|
|
411
411
|
}
|
|
412
|
-
|
|
412
|
+
z.label = 10;
|
|
413
413
|
case 10:
|
|
414
414
|
return [2];
|
|
415
415
|
}
|
|
416
416
|
});
|
|
417
417
|
});
|
|
418
|
-
},
|
|
418
|
+
}, R.label = 2;
|
|
419
419
|
case 2:
|
|
420
|
-
return
|
|
420
|
+
return R.trys.push([2, 7, , 8]), L.getItemSync ? (St = L.getItemSync(this.getStorageKey()), [3, 5]) : [3, 3];
|
|
421
421
|
case 3:
|
|
422
|
-
return [4,
|
|
422
|
+
return [4, L.getItem(this.getStorageKey())];
|
|
423
423
|
case 4:
|
|
424
|
-
St =
|
|
424
|
+
St = R.sent(), R.label = 5;
|
|
425
425
|
case 5:
|
|
426
426
|
return [4, ee(null, St)];
|
|
427
427
|
case 6:
|
|
428
428
|
case 7:
|
|
429
|
-
return
|
|
429
|
+
return R.sent(), [3, 8];
|
|
430
430
|
case 8:
|
|
431
431
|
return [3, 12];
|
|
432
432
|
case 9:
|
|
433
|
-
return
|
|
433
|
+
return A ? [3, 11] : [4, this.getFlags()];
|
|
434
434
|
case 10:
|
|
435
|
-
return
|
|
435
|
+
return R.sent(), [3, 12];
|
|
436
436
|
case 11:
|
|
437
|
-
if (
|
|
438
|
-
else if (this.flags && (
|
|
439
|
-
|
|
437
|
+
if (T) this._onChange(null, { isFromServer: !1, flagsChanged: C({}, T), traitsChanged: C({}, (t = r.identity) === null || t === void 0 ? void 0 : t.traits) }, this._loadedState(null, d.DEFAULT_FLAGS));
|
|
438
|
+
else if (this.flags && (ot = null, Object.keys(this.flags).length === 0 && (ot = mt), this._onChange(null, { isFromServer: !1, flagsChanged: C({}, this.flags), traitsChanged: C({}, (i = r.identity) === null || i === void 0 ? void 0 : i.traits) }, this._loadedState(ot, d.DEFAULT_FLAGS)), ot)) throw new Error(ot);
|
|
439
|
+
R.label = 12;
|
|
440
440
|
case 12:
|
|
441
441
|
return [3, 14];
|
|
442
442
|
case 13:
|
|
443
|
-
throw
|
|
443
|
+
throw Z = R.sent(), this.log("Error during initialisation ", Z), ne = Z instanceof Error ? Z : new Error("".concat(Z)), (n = this.onError) === null || n === void 0 || n.call(this, ne), Z;
|
|
444
444
|
case 14:
|
|
445
445
|
return [2];
|
|
446
446
|
}
|
|
@@ -450,8 +450,8 @@ var Gt = { exports: {} };
|
|
|
450
450
|
return this.flags;
|
|
451
451
|
}, a.prototype.identify = function(e, t, i) {
|
|
452
452
|
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) {
|
|
453
|
-
var r = n[0],
|
|
454
|
-
return [r,
|
|
453
|
+
var r = n[0], o = n[1];
|
|
454
|
+
return [r, N(o) ? o : { value: o }];
|
|
455
455
|
}))), this.initialised ? this.getFlags() : Promise.resolve();
|
|
456
456
|
}, a.prototype.getState = function() {
|
|
457
457
|
return { api: this.api, flags: this.flags, ts: this.ts, evaluationContext: this.evaluationContext, evaluationEvent: this.evaluationEvent };
|
|
@@ -467,52 +467,52 @@ var Gt = { exports: {} };
|
|
|
467
467
|
return e === void 0 && (e = null), i === void 0 && (i = !1), { error: e, isFetching: i, isLoading: !1, source: t };
|
|
468
468
|
}, a.prototype.log = function() {
|
|
469
469
|
for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
|
|
470
|
-
this.enableLogs && console.log.apply(this,
|
|
470
|
+
this.enableLogs && console.log.apply(this, I(["FLAGSMITH:", (/* @__PURE__ */ new Date()).valueOf() - (this.timer || 0), "ms"], e));
|
|
471
471
|
}, a.prototype.updateStorage = function() {
|
|
472
472
|
if (this.cacheFlags) {
|
|
473
473
|
this.ts = (/* @__PURE__ */ new Date()).valueOf();
|
|
474
474
|
var e = JSON.stringify(this.getState());
|
|
475
|
-
this.log("Setting storage", e),
|
|
475
|
+
this.log("Setting storage", e), L.setItem(this.getStorageKey(), e);
|
|
476
476
|
}
|
|
477
477
|
}, a.prototype.updateEventStorage = function() {
|
|
478
478
|
if (this.enableAnalytics) {
|
|
479
479
|
var e = JSON.stringify(this.getState().evaluationEvent);
|
|
480
|
-
|
|
480
|
+
L.setItem(lt, e).catch(function(t) {
|
|
481
481
|
return console.error("Flagsmith: Error setting item in async storage", t);
|
|
482
482
|
});
|
|
483
483
|
}
|
|
484
484
|
}, a.prototype.setLoadingState = function(e) {
|
|
485
485
|
var t;
|
|
486
|
-
|
|
486
|
+
nt(e, this.loadingState) || (this.loadingState = s({}, e), this.log("Loading state changed", e), (t = this._triggerLoadingState) === null || t === void 0 || t.call(this));
|
|
487
487
|
}, a.prototype.setupRealtime = function(e, t) {
|
|
488
488
|
var i = this, n = e + "sse/environments/" + t + "/stream";
|
|
489
|
-
|
|
490
|
-
var
|
|
489
|
+
q ? this.eventSource || (this.log("Creating event source with url " + n), this.eventSource = new q(n), this.eventSource.addEventListener("environment_updated", function(r) {
|
|
490
|
+
var o;
|
|
491
491
|
try {
|
|
492
|
-
|
|
492
|
+
o = JSON.parse(r.data).updated_at;
|
|
493
493
|
} catch (c) {
|
|
494
494
|
i.log("Could not parse sse event", c);
|
|
495
495
|
}
|
|
496
|
-
|
|
496
|
+
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);
|
|
497
497
|
})) : this.log("Error, EventSource is undefined");
|
|
498
498
|
}, a;
|
|
499
499
|
}();
|
|
500
500
|
function Ht(a) {
|
|
501
501
|
var e = a.fetch, t = a.AsyncStorage, i = a.eventSource;
|
|
502
|
-
return new
|
|
502
|
+
return new ve({ fetch: e, AsyncStorage: t, eventSource: i });
|
|
503
503
|
}
|
|
504
|
-
var
|
|
505
|
-
return
|
|
504
|
+
var ut, he = (ut = function(a, e) {
|
|
505
|
+
return ut = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, i) {
|
|
506
506
|
t.__proto__ = i;
|
|
507
507
|
} || function(t, i) {
|
|
508
508
|
for (var n in i) Object.prototype.hasOwnProperty.call(i, n) && (t[n] = i[n]);
|
|
509
|
-
},
|
|
509
|
+
}, ut(a, e);
|
|
510
510
|
}, function(a, e) {
|
|
511
511
|
if (typeof e != "function" && e !== null) throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
|
|
512
512
|
function t() {
|
|
513
513
|
this.constructor = a;
|
|
514
514
|
}
|
|
515
|
-
|
|
515
|
+
ut(a, e), a.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
|
|
516
516
|
}), $t = function(a) {
|
|
517
517
|
var e = typeof Symbol == "function" && Symbol.iterator, t = e && a[e], i = 0;
|
|
518
518
|
if (t) return t.call(a);
|
|
@@ -523,9 +523,9 @@ var Gt = { exports: {} };
|
|
|
523
523
|
}, Xt = function(a, e) {
|
|
524
524
|
var t = typeof Symbol == "function" && a[Symbol.iterator];
|
|
525
525
|
if (!t) return a;
|
|
526
|
-
var i, n, r = t.call(a),
|
|
526
|
+
var i, n, r = t.call(a), o = [];
|
|
527
527
|
try {
|
|
528
|
-
for (; (e === void 0 || e-- > 0) && !(i = r.next()).done; )
|
|
528
|
+
for (; (e === void 0 || e-- > 0) && !(i = r.next()).done; ) o.push(i.value);
|
|
529
529
|
} catch (c) {
|
|
530
530
|
n = { error: c };
|
|
531
531
|
} finally {
|
|
@@ -535,20 +535,20 @@ var Gt = { exports: {} };
|
|
|
535
535
|
if (n) throw n.error;
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
|
-
return
|
|
538
|
+
return o;
|
|
539
539
|
}, ft = function(a, e, t) {
|
|
540
540
|
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]);
|
|
541
541
|
return a.concat(i || Array.prototype.slice.call(e));
|
|
542
|
-
},
|
|
542
|
+
}, ge = function(a) {
|
|
543
543
|
function e() {
|
|
544
544
|
return a.call(this, `EventSource not available.
|
|
545
545
|
Consider loading an EventSource polyfill and making it available globally as EventSource, or passing one in as eventSourceClass to the ReconnectingEventSource constructor.`) || this;
|
|
546
546
|
}
|
|
547
|
-
return
|
|
547
|
+
return he(e, a), e;
|
|
548
548
|
}(Error), qt = function() {
|
|
549
549
|
function a(e, t) {
|
|
550
550
|
var i = this;
|
|
551
|
-
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
|
|
551
|
+
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 ge();
|
|
552
552
|
this._onevent_wrapped = function(n) {
|
|
553
553
|
i._onevent(n);
|
|
554
554
|
}, this._start();
|
|
@@ -557,23 +557,23 @@ Consider loading an EventSource polyfill and making it available globally as Eve
|
|
|
557
557
|
throw new Error("Method not implemented.");
|
|
558
558
|
}, a.prototype._start = function() {
|
|
559
559
|
var e, t, i = this, n = this.url;
|
|
560
|
-
this._lastEventId && (n.indexOf("?") === -1 ? n += "?" : n += "&", n += "lastEventId=" + encodeURIComponent(this._lastEventId)), this._eventSource = new this.eventSourceClass(n, this._configuration), this._eventSource.onopen = function(
|
|
561
|
-
i._onopen(
|
|
562
|
-
}, this._eventSource.onerror = function(
|
|
563
|
-
i._onerror(
|
|
564
|
-
}, this._eventSource.onmessage = function(
|
|
565
|
-
i.onmessage(
|
|
560
|
+
this._lastEventId && (n.indexOf("?") === -1 ? n += "?" : n += "&", n += "lastEventId=" + encodeURIComponent(this._lastEventId)), this._eventSource = new this.eventSourceClass(n, this._configuration), this._eventSource.onopen = function(v) {
|
|
561
|
+
i._onopen(v);
|
|
562
|
+
}, this._eventSource.onerror = function(v) {
|
|
563
|
+
i._onerror(v);
|
|
564
|
+
}, this._eventSource.onmessage = function(v) {
|
|
565
|
+
i.onmessage(v);
|
|
566
566
|
};
|
|
567
567
|
try {
|
|
568
|
-
for (var r = $t(Object.keys(this._listeners)),
|
|
569
|
-
var c =
|
|
568
|
+
for (var r = $t(Object.keys(this._listeners)), o = r.next(); !o.done; o = r.next()) {
|
|
569
|
+
var c = o.value;
|
|
570
570
|
this._eventSource.addEventListener(c, this._onevent_wrapped);
|
|
571
571
|
}
|
|
572
|
-
} catch (
|
|
573
|
-
e = { error:
|
|
572
|
+
} catch (v) {
|
|
573
|
+
e = { error: v };
|
|
574
574
|
} finally {
|
|
575
575
|
try {
|
|
576
|
-
|
|
576
|
+
o && !o.done && (t = r.return) && t.call(r);
|
|
577
577
|
} finally {
|
|
578
578
|
if (e) throw e.error;
|
|
579
579
|
}
|
|
@@ -594,13 +594,13 @@ Consider loading an EventSource polyfill and making it available globally as Eve
|
|
|
594
594
|
e && e.lastEventId && (this._lastEventId = e.lastEventId);
|
|
595
595
|
var n = this._listeners[e.type];
|
|
596
596
|
if (n != null) try {
|
|
597
|
-
for (var r = $t(ft([], Xt(n), !1)),
|
|
598
|
-
|
|
597
|
+
for (var r = $t(ft([], Xt(n), !1)), o = r.next(); !o.done; o = r.next())
|
|
598
|
+
o.value.call(this, e);
|
|
599
599
|
} catch (c) {
|
|
600
600
|
t = { error: c };
|
|
601
601
|
} finally {
|
|
602
602
|
try {
|
|
603
|
-
|
|
603
|
+
o && !o.done && (i = r.return) && i.call(r);
|
|
604
604
|
} finally {
|
|
605
605
|
if (t) throw t.error;
|
|
606
606
|
}
|
|
@@ -625,228 +625,214 @@ Consider loading an EventSource polyfill and making it available globally as Eve
|
|
|
625
625
|
globalThis.FlagsmithEventSource = typeof EventSource < "u" ? EventSource : null;
|
|
626
626
|
var Wt = function(a, e) {
|
|
627
627
|
return e = e || {}, new Promise(function(t, i) {
|
|
628
|
-
var n = new XMLHttpRequest(), r = [],
|
|
628
|
+
var n = new XMLHttpRequest(), r = [], o = [], c = {}, v = function() {
|
|
629
629
|
return { ok: (n.status / 100 | 0) == 2, statusText: n.statusText, status: n.status, url: n.responseURL, text: function() {
|
|
630
630
|
return Promise.resolve(n.responseText);
|
|
631
631
|
}, json: function() {
|
|
632
632
|
return Promise.resolve(n.responseText).then(JSON.parse);
|
|
633
633
|
}, blob: function() {
|
|
634
634
|
return Promise.resolve(new Blob([n.response]));
|
|
635
|
-
}, clone:
|
|
635
|
+
}, clone: v, headers: { keys: function() {
|
|
636
636
|
return r;
|
|
637
637
|
}, entries: function() {
|
|
638
|
-
return
|
|
639
|
-
}, get: function(
|
|
640
|
-
return c[
|
|
641
|
-
}, has: function(
|
|
642
|
-
return
|
|
638
|
+
return o;
|
|
639
|
+
}, get: function(l) {
|
|
640
|
+
return c[l.toLowerCase()];
|
|
641
|
+
}, has: function(l) {
|
|
642
|
+
return l.toLowerCase() in c;
|
|
643
643
|
} } };
|
|
644
644
|
};
|
|
645
645
|
for (var f in n.open(e.method || "get", a, !0), n.onload = function() {
|
|
646
|
-
n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(
|
|
647
|
-
r.push(
|
|
648
|
-
}), t(
|
|
646
|
+
n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(l, p, E) {
|
|
647
|
+
r.push(p = p.toLowerCase()), o.push([p, E]), c[p] = c[p] ? c[p] + "," + E : E;
|
|
648
|
+
}), t(v());
|
|
649
649
|
}, n.onerror = i, n.withCredentials = e.credentials == "include", e.headers) n.setRequestHeader(f, e.headers[f]);
|
|
650
650
|
n.send(e.body || null);
|
|
651
651
|
});
|
|
652
|
-
}, Yt = Ht({ AsyncStorage:
|
|
653
|
-
typeof window < "u" && (window.flagsmith = Yt),
|
|
654
|
-
return Ht({ AsyncStorage:
|
|
655
|
-
},
|
|
652
|
+
}, Yt = Ht({ AsyncStorage: g, fetch: Wt, eventSource: qt });
|
|
653
|
+
typeof window < "u" && (window.flagsmith = Yt), h.createFlagsmithInstance = function() {
|
|
654
|
+
return Ht({ AsyncStorage: g, fetch: Wt, eventSource: qt });
|
|
655
|
+
}, h.default = Yt, Object.defineProperty(h, "__esModule", { value: !0 });
|
|
656
656
|
});
|
|
657
657
|
})(Gt, Gt.exports);
|
|
658
|
-
var me = Gt.exports,
|
|
658
|
+
var me = Gt.exports, Se = {
|
|
659
659
|
NOT_INITIALIZED: "FeatureFlag not initialized. Call init() first.",
|
|
660
660
|
INVALID_CONFIG: "Invalid Flagsmith configuration",
|
|
661
661
|
FETCH_FAILED: "Failed to fetch Flagsmith configuration",
|
|
662
662
|
NO_USER_CONTEXT: "User context not set. Call setUser() first.",
|
|
663
663
|
ALREADY_INITIALIZED: "FeatureFlag is already initialized."
|
|
664
|
-
}, oe = "business",
|
|
664
|
+
}, oe = "business", V, be = (V = class {
|
|
665
665
|
constructor() {
|
|
666
|
-
|
|
667
|
-
|
|
666
|
+
ct(this, "flagsmithClient", null);
|
|
667
|
+
ct(this, "userContext", null);
|
|
668
668
|
}
|
|
669
669
|
static getInstance() {
|
|
670
|
-
return
|
|
670
|
+
return V.instance || (V.instance = new V()), V.instance;
|
|
671
671
|
}
|
|
672
672
|
ensureInitialized() {
|
|
673
673
|
if (!this.flagsmithClient)
|
|
674
|
-
throw new Error(
|
|
674
|
+
throw new Error(Se.NOT_INITIALIZED);
|
|
675
675
|
}
|
|
676
|
-
async init(
|
|
676
|
+
async init(u, h = []) {
|
|
677
677
|
if (!this.flagsmithClient)
|
|
678
678
|
try {
|
|
679
679
|
this.flagsmithClient = me.createFlagsmithInstance();
|
|
680
|
-
const
|
|
680
|
+
const g = h.reduce((s, F) => (s[F.feature.name] = F, s), {});
|
|
681
681
|
await this.flagsmithClient.init({
|
|
682
|
-
environmentID:
|
|
683
|
-
api: (
|
|
684
|
-
enableAnalytics: (
|
|
685
|
-
defaultFlags:
|
|
686
|
-
cacheFlags: (
|
|
682
|
+
environmentID: u.apiKey,
|
|
683
|
+
api: (u == null ? void 0 : u.url) ?? "https://feature-flag-proxy.feedme.farm/api/v1/",
|
|
684
|
+
enableAnalytics: (u == null ? void 0 : u.enableAnalytics) ?? !0,
|
|
685
|
+
defaultFlags: g,
|
|
686
|
+
cacheFlags: (u == null ? void 0 : u.cacheFlags) ?? !0
|
|
687
687
|
});
|
|
688
|
-
} catch (
|
|
689
|
-
throw console.error("Failed to initialize FeatureFlag:",
|
|
688
|
+
} catch (g) {
|
|
689
|
+
throw console.error("Failed to initialize FeatureFlag:", g), g;
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
|
-
async setUser(
|
|
693
|
-
this.ensureInitialized(), this.userContext = { identifier:
|
|
694
|
-
}
|
|
695
|
-
async addTraits(l) {
|
|
696
|
-
if (this.ensureInitialized(), !this.userContext)
|
|
697
|
-
throw new Error(se.NO_USER_CONTEXT);
|
|
698
|
-
this.userContext.traits = { ...this.userContext.traits, ...l }, await this.updateContext();
|
|
692
|
+
async setUser(u) {
|
|
693
|
+
this.ensureInitialized(), this.userContext = { identifier: u }, await this.updateContext();
|
|
699
694
|
}
|
|
700
695
|
async updateContext() {
|
|
701
696
|
try {
|
|
702
697
|
if (!this.userContext) return;
|
|
703
698
|
await this.flagsmithClient.setContext({
|
|
704
699
|
identity: {
|
|
705
|
-
identifier: this.userContext.identifier
|
|
706
|
-
traits: this.userContext.traits || {}
|
|
700
|
+
identifier: this.userContext.identifier
|
|
707
701
|
}
|
|
708
702
|
});
|
|
709
|
-
} catch (
|
|
710
|
-
throw console.error("Failed to update user context:",
|
|
703
|
+
} catch (u) {
|
|
704
|
+
throw console.error("Failed to update user context:", u), u;
|
|
711
705
|
}
|
|
712
706
|
}
|
|
713
707
|
async getFlags() {
|
|
714
708
|
this.ensureInitialized();
|
|
715
|
-
const
|
|
716
|
-
return Object.entries(
|
|
717
|
-
var
|
|
709
|
+
const u = this.flagsmithClient.getAllFlags();
|
|
710
|
+
return Object.entries(u).map(([h, g]) => {
|
|
711
|
+
var s;
|
|
718
712
|
return {
|
|
719
713
|
feature: {
|
|
720
|
-
name:
|
|
721
|
-
id: (
|
|
714
|
+
name: h,
|
|
715
|
+
id: (g == null ? void 0 : g.id) ?? 0
|
|
722
716
|
},
|
|
723
|
-
enabled:
|
|
724
|
-
value: ((
|
|
717
|
+
enabled: g.enabled,
|
|
718
|
+
value: ((s = g.value) == null ? void 0 : s.toString()) ?? null
|
|
725
719
|
};
|
|
726
720
|
});
|
|
727
721
|
}
|
|
728
|
-
getFlagValue(
|
|
722
|
+
getFlagValue(u, h) {
|
|
729
723
|
this.ensureInitialized();
|
|
730
|
-
const
|
|
731
|
-
if (
|
|
724
|
+
const g = this.flagsmithClient.getValue(u);
|
|
725
|
+
if (g == null)
|
|
732
726
|
return null;
|
|
733
727
|
try {
|
|
734
|
-
const
|
|
735
|
-
return
|
|
736
|
-
} catch (
|
|
737
|
-
return console.error("Error transforming flag value:",
|
|
728
|
+
const s = g.toString();
|
|
729
|
+
return h ? h(s) : typeof {} == "number" ? isNaN(Number(s)) ? null : Number(s) : typeof {} == "boolean" ? s.toLowerCase() === "true" : s;
|
|
730
|
+
} catch (s) {
|
|
731
|
+
return console.error("Error transforming flag value:", s), null;
|
|
738
732
|
}
|
|
739
733
|
}
|
|
740
|
-
getFlag(
|
|
734
|
+
getFlag(u) {
|
|
741
735
|
this.ensureInitialized();
|
|
742
|
-
const
|
|
743
|
-
if (
|
|
744
|
-
const
|
|
736
|
+
const h = this.flagsmithClient.getValue(u);
|
|
737
|
+
if (h == null) return null;
|
|
738
|
+
const g = this.flagsmithClient.hasFeature(u);
|
|
745
739
|
return {
|
|
746
740
|
feature: {
|
|
747
|
-
name:
|
|
741
|
+
name: u,
|
|
748
742
|
id: 0
|
|
749
743
|
},
|
|
750
|
-
enabled:
|
|
751
|
-
value:
|
|
744
|
+
enabled: g,
|
|
745
|
+
value: h.toString()
|
|
752
746
|
};
|
|
753
747
|
}
|
|
754
|
-
async getUserFlagValue(
|
|
755
|
-
var
|
|
756
|
-
const
|
|
748
|
+
async getUserFlagValue(u, h, g = null, s) {
|
|
749
|
+
var J;
|
|
750
|
+
const F = this.userContext;
|
|
757
751
|
try {
|
|
758
|
-
return await this.setUser(
|
|
759
|
-
} catch (
|
|
760
|
-
return console.error(`Error getting user flag value for ${
|
|
752
|
+
return await this.setUser(u), this.getFlagValue(h, s) ?? g;
|
|
753
|
+
} catch (I) {
|
|
754
|
+
return console.error(`Error getting user flag value for ${h}:`, I), g;
|
|
761
755
|
} finally {
|
|
762
756
|
try {
|
|
763
|
-
await ((
|
|
764
|
-
} catch (
|
|
765
|
-
console.error("Error during cleanup:",
|
|
757
|
+
await ((J = this.flagsmithClient) == null ? void 0 : J.logout()), this.userContext = null, F && await this.setUser(F.identifier);
|
|
758
|
+
} catch (I) {
|
|
759
|
+
console.error("Error during cleanup:", I);
|
|
766
760
|
}
|
|
767
761
|
}
|
|
768
762
|
}
|
|
769
763
|
reset() {
|
|
770
764
|
this.flagsmithClient = null, this.userContext = null;
|
|
771
765
|
}
|
|
772
|
-
},
|
|
773
|
-
function Ce(
|
|
774
|
-
const
|
|
766
|
+
}, ct(V, "instance"), V), _e = be.getInstance(), st = dt(!1), gt = dt([]), tt = dt(null);
|
|
767
|
+
function Ce(m = _e) {
|
|
768
|
+
const u = () => st.value ? !0 : (console.warn("FeatureFlag is not initialized. Using default values."), !1), h = async (d, S = []) => {
|
|
775
769
|
if (st.value) {
|
|
776
770
|
console.warn("FeatureFlag is already initialized.");
|
|
777
771
|
return;
|
|
778
772
|
}
|
|
779
773
|
try {
|
|
780
|
-
await
|
|
781
|
-
} catch (
|
|
782
|
-
console.error("Failed to initialize feature flags:",
|
|
774
|
+
await m.init(d, S), gt.value = await m.getFlags(), st.value = !0, tt.value = null;
|
|
775
|
+
} catch (_) {
|
|
776
|
+
console.error("Failed to initialize feature flags:", _), tt.value = _;
|
|
783
777
|
}
|
|
784
|
-
},
|
|
785
|
-
if (
|
|
786
|
-
try {
|
|
787
|
-
await p.setUser(g, y), ot.value = await p.getFlags(), X.value = null;
|
|
788
|
-
} catch (C) {
|
|
789
|
-
console.error("Failed to set user:", C), X.value = C;
|
|
790
|
-
}
|
|
791
|
-
}, o = async (g, y) => d(`${oe}-${g}`, y), x = async (g) => {
|
|
792
|
-
if (l())
|
|
778
|
+
}, g = async (d) => {
|
|
779
|
+
if (u())
|
|
793
780
|
try {
|
|
794
|
-
await
|
|
795
|
-
} catch (
|
|
796
|
-
console.error("Failed to
|
|
781
|
+
await m.setUser(d), gt.value = await m.getFlags(), tt.value = null;
|
|
782
|
+
} catch (S) {
|
|
783
|
+
console.error("Failed to set user:", S), tt.value = S;
|
|
797
784
|
}
|
|
798
|
-
},
|
|
799
|
-
if (!
|
|
785
|
+
}, s = async (d) => g(`${oe}-${d}`), F = (d, S, _ = null) => {
|
|
786
|
+
if (!u()) return _;
|
|
800
787
|
try {
|
|
801
|
-
return
|
|
802
|
-
} catch (
|
|
803
|
-
return console.error(`Error getting flag value for ${
|
|
788
|
+
return m.getFlagValue(d, S) ?? _;
|
|
789
|
+
} catch (N) {
|
|
790
|
+
return console.error(`Error getting flag value for ${d}:`, N), _;
|
|
804
791
|
}
|
|
805
|
-
},
|
|
806
|
-
if (!
|
|
792
|
+
}, J = (d, S) => {
|
|
793
|
+
if (!u()) return S ?? null;
|
|
807
794
|
try {
|
|
808
|
-
return
|
|
809
|
-
} catch (
|
|
810
|
-
return console.error(`Error getting flag for ${
|
|
795
|
+
return m.getFlag(d) ?? S ?? null;
|
|
796
|
+
} catch (_) {
|
|
797
|
+
return console.error(`Error getting flag for ${d}:`, _), S ?? null;
|
|
811
798
|
}
|
|
812
|
-
},
|
|
813
|
-
if (!
|
|
799
|
+
}, I = async (d, S, _ = null, N) => {
|
|
800
|
+
if (!u()) return _;
|
|
814
801
|
try {
|
|
815
|
-
return await
|
|
816
|
-
} catch (
|
|
817
|
-
return console.error(`Error getting user flag value for ${
|
|
802
|
+
return await m.getUserFlagValue(d, S, _, N);
|
|
803
|
+
} catch (H) {
|
|
804
|
+
return console.error(`Error getting user flag value for ${S}:`, H), _;
|
|
818
805
|
}
|
|
819
|
-
},
|
|
806
|
+
}, nt = async (d, S, _ = null, N) => I(`${oe}-${d}`, S, _, N), C = () => {
|
|
820
807
|
try {
|
|
821
|
-
|
|
822
|
-
} catch (
|
|
823
|
-
console.error("Error resetting feature flags:",
|
|
808
|
+
m.reset();
|
|
809
|
+
} catch (d) {
|
|
810
|
+
console.error("Error resetting feature flags:", d);
|
|
824
811
|
} finally {
|
|
825
|
-
|
|
812
|
+
gt.value = [], st.value = !1, tt.value = null;
|
|
826
813
|
}
|
|
827
814
|
};
|
|
828
815
|
return {
|
|
829
|
-
flags: Kt(
|
|
816
|
+
flags: Kt(gt),
|
|
830
817
|
isInitialized: Kt(st),
|
|
831
|
-
error: Kt(
|
|
832
|
-
init:
|
|
833
|
-
setUser:
|
|
834
|
-
setBusiness:
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
reset: F
|
|
818
|
+
error: Kt(tt),
|
|
819
|
+
init: h,
|
|
820
|
+
setUser: g,
|
|
821
|
+
setBusiness: s,
|
|
822
|
+
getFlagValue: F,
|
|
823
|
+
getFlag: J,
|
|
824
|
+
getUserFlagValue: I,
|
|
825
|
+
getBusinessFlagValue: nt,
|
|
826
|
+
reset: C
|
|
841
827
|
};
|
|
842
828
|
}
|
|
843
829
|
var Vt = () => Ce();
|
|
844
|
-
const
|
|
830
|
+
const xe = /* @__PURE__ */ new Set([
|
|
845
831
|
// vivo pizza prod
|
|
846
832
|
"business_6687e91fa7240b001ba3f4c2",
|
|
847
833
|
// vivo dev
|
|
848
834
|
"business_669a1d2efc050a001cfbb5a2"
|
|
849
|
-
]),
|
|
835
|
+
]), Fe = /* @__PURE__ */ new Set([
|
|
850
836
|
// vivo pizza prod
|
|
851
837
|
"business_6687e91fa7240b001ba3f4c2",
|
|
852
838
|
// vivo dev
|
|
@@ -855,17 +841,17 @@ const _e = /* @__PURE__ */ new Set([
|
|
|
855
841
|
"business_655b25254fe3be001b123f0b",
|
|
856
842
|
// King Menu V4
|
|
857
843
|
"business_646ee00ebffa92001b84c4c7"
|
|
858
|
-
]),
|
|
844
|
+
]), se = /* @__PURE__ */ new Set([
|
|
859
845
|
// zus dev
|
|
860
846
|
"business_671005de24a7f4001c87e25e",
|
|
861
847
|
// zus prod
|
|
862
848
|
"business_6776a1fe205a52001c516efa"
|
|
863
|
-
]),
|
|
849
|
+
]), le = /* @__PURE__ */ new Set([
|
|
864
850
|
// zus dev
|
|
865
851
|
"business_671005de24a7f4001c87e25e",
|
|
866
852
|
// zus prod
|
|
867
853
|
"business_6776a1fe205a52001c516efa"
|
|
868
|
-
]),
|
|
854
|
+
]), Ee = /* @__PURE__ */ new Set([
|
|
869
855
|
// zus dev
|
|
870
856
|
"business_671005de24a7f4001c87e25e",
|
|
871
857
|
// zus prod
|
|
@@ -888,128 +874,136 @@ function ue() {
|
|
|
888
874
|
enablePoOperateV2: !1
|
|
889
875
|
};
|
|
890
876
|
}
|
|
891
|
-
const
|
|
877
|
+
const x = dt(ue()), Te = () => ({
|
|
892
878
|
get businessDbName() {
|
|
893
|
-
var
|
|
894
|
-
return `business_${((
|
|
879
|
+
var h;
|
|
880
|
+
return `business_${((h = vt().currentBusiness.value) == null ? void 0 : h._id) ?? ""}`;
|
|
895
881
|
},
|
|
896
882
|
get isWarehouse() {
|
|
897
|
-
var
|
|
898
|
-
return ((
|
|
883
|
+
var u;
|
|
884
|
+
return ((u = Dt()._currentLocation) == null ? void 0 : u.type) === re.enum.warehouse;
|
|
899
885
|
},
|
|
900
886
|
get restaurantPosVersion() {
|
|
901
|
-
var
|
|
902
|
-
const
|
|
903
|
-
return (
|
|
904
|
-
(
|
|
905
|
-
var
|
|
906
|
-
return
|
|
887
|
+
var h;
|
|
888
|
+
const m = Dt();
|
|
889
|
+
return (h = vt().restaurants.value.find(
|
|
890
|
+
(g) => {
|
|
891
|
+
var s;
|
|
892
|
+
return g._id === ((s = m._currentLocation) == null ? void 0 : s.doc._id);
|
|
907
893
|
}
|
|
908
|
-
)) == null ? void 0 :
|
|
894
|
+
)) == null ? void 0 : h.posVersion;
|
|
909
895
|
},
|
|
910
896
|
get enableTotalCost() {
|
|
911
|
-
return
|
|
897
|
+
return x.value.enableTotalCost;
|
|
912
898
|
},
|
|
913
899
|
get enableBackdatePo() {
|
|
914
|
-
return
|
|
900
|
+
return x.value.enableBackdatePo;
|
|
915
901
|
},
|
|
916
902
|
/** @deprecated TODO: remove */
|
|
917
903
|
get autoReceiveWarehouse() {
|
|
918
|
-
return
|
|
904
|
+
return x.value.autoReceiveWarehouse;
|
|
919
905
|
},
|
|
920
906
|
/** @deprecated TODO: remove */
|
|
921
907
|
get manualReceive() {
|
|
922
|
-
return
|
|
908
|
+
return x.value.manualReceive;
|
|
923
909
|
},
|
|
924
910
|
get enablePoTemplate() {
|
|
925
|
-
return
|
|
911
|
+
return x.value.enablePoTemplate;
|
|
926
912
|
},
|
|
927
913
|
get enableClosingTemplate() {
|
|
928
|
-
return
|
|
914
|
+
return x.value.enableClosingTemplate;
|
|
929
915
|
},
|
|
930
916
|
get enableWastageTemplate() {
|
|
931
|
-
return
|
|
917
|
+
return x.value.enableWastageTemplate;
|
|
932
918
|
},
|
|
933
919
|
get enableIngredientGroup() {
|
|
934
|
-
return
|
|
920
|
+
return x.value.enableIngredientGroup;
|
|
935
921
|
},
|
|
936
922
|
get mustUsePoTemplate() {
|
|
937
|
-
return
|
|
923
|
+
return x.value.mustUsePoTemplate;
|
|
938
924
|
},
|
|
939
925
|
get enableSupplierMasterList() {
|
|
940
|
-
return
|
|
926
|
+
return x.value.enableSupplierMasterList;
|
|
941
927
|
},
|
|
942
928
|
get businessSupplierOnly() {
|
|
943
|
-
return
|
|
929
|
+
return x.value.businessSupplierOnly;
|
|
944
930
|
},
|
|
945
931
|
get enableXilnexTransferNote() {
|
|
946
|
-
return
|
|
932
|
+
return x.value.enableXilnexTransferNote;
|
|
947
933
|
},
|
|
948
934
|
get enablePoOperateV2() {
|
|
949
|
-
return
|
|
935
|
+
return x.value.enablePoOperateV2;
|
|
950
936
|
},
|
|
951
937
|
async init() {
|
|
952
|
-
const
|
|
953
|
-
await
|
|
954
|
-
apiKey:
|
|
938
|
+
const m = vt(), { init: u, setUser: h } = Vt(), g = m.namespace.value === "prod";
|
|
939
|
+
await u({
|
|
940
|
+
apiKey: g ? "6GhcttsJ9Rj9cTevcdrpin" : "MaGoXrEWuEJNpWgKTqseee"
|
|
955
941
|
// url: 'https://flag.feedme.farm/api/v1/', // optional -> this is a default URL value
|
|
956
942
|
// enableAnalytics: true, // optional, defaults to true
|
|
957
943
|
// cacheFlags: true // optional, defaults to true
|
|
958
|
-
}), Dt().watchLocation(async (
|
|
959
|
-
var
|
|
960
|
-
if (!
|
|
961
|
-
|
|
944
|
+
}), Dt().watchLocation(async (F) => {
|
|
945
|
+
var H, X, q;
|
|
946
|
+
if (!F) {
|
|
947
|
+
x.value = ue();
|
|
962
948
|
return;
|
|
963
949
|
}
|
|
964
|
-
await
|
|
965
|
-
const
|
|
950
|
+
await h(F.doc._id);
|
|
951
|
+
const J = ye(), I = vt(), C = `business_${((H = I.currentBusiness.value) == null ? void 0 : H._id) ?? ""}`, d = F.type === re.enum.warehouse, S = (
|
|
966
952
|
// if menu v4, must manual receive && must use outlet app
|
|
967
|
-
((
|
|
953
|
+
((X = I.currentBusiness.value) == null ? void 0 : X.menuVersion) === "v4" && // more guard for businesses using menu v4, only those listed for manual receive will be included
|
|
968
954
|
// TODO: may be removed to use menu version only
|
|
969
|
-
|
|
970
|
-
),
|
|
955
|
+
xe.has(this.businessDbName)
|
|
956
|
+
), _ = se.has(C) || et(
|
|
971
957
|
"inventory_portal_must_use_transfer_template"
|
|
972
958
|
/* inventory_portal_must_use_transfer_template */
|
|
973
|
-
)
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
959
|
+
);
|
|
960
|
+
console.log(
|
|
961
|
+
le.has(C),
|
|
962
|
+
et(
|
|
963
|
+
"inventory_pos_closing_v2"
|
|
964
|
+
/* inventory_pos_closing_v2 */
|
|
965
|
+
)
|
|
966
|
+
);
|
|
967
|
+
const N = Fe.has(this.businessDbName) && (this.isWarehouse || J.state.closing !== null);
|
|
968
|
+
x.value = {
|
|
969
|
+
enableTotalCost: ((q = I.currentBusiness.value) == null ? void 0 : q.menuVersion) === "v4",
|
|
970
|
+
enableBackdatePo: N,
|
|
971
|
+
autoReceiveWarehouse: d && !S,
|
|
972
|
+
manualReceive: S,
|
|
973
|
+
enablePoTemplate: _,
|
|
974
|
+
enableClosingTemplate: le.has(C) || et(
|
|
981
975
|
"inventory_pos_closing_v2"
|
|
982
976
|
/* inventory_pos_closing_v2 */
|
|
983
977
|
),
|
|
984
|
-
enableWastageTemplate:
|
|
978
|
+
enableWastageTemplate: Ee.has(C) && et(
|
|
985
979
|
"inventory_pos_adjust_v2_wastage"
|
|
986
980
|
/* inventory_pos_adjust_v2_wastage */
|
|
987
981
|
),
|
|
988
982
|
enableIngredientGroup: !1,
|
|
989
|
-
mustUsePoTemplate:
|
|
990
|
-
businessSupplierOnly:
|
|
991
|
-
enableSupplierMasterList:
|
|
992
|
-
enableXilnexTransferNote:
|
|
983
|
+
mustUsePoTemplate: _,
|
|
984
|
+
businessSupplierOnly: _,
|
|
985
|
+
enableSupplierMasterList: se.has(C),
|
|
986
|
+
enableXilnexTransferNote: et(
|
|
993
987
|
"inventory_portal_xilnex_transfer_note"
|
|
994
988
|
/* inventory_portal_xilnex_transfer_note */
|
|
995
989
|
),
|
|
996
|
-
enablePoOperateV2:
|
|
990
|
+
enablePoOperateV2: et(
|
|
997
991
|
"inventory_portal_po_operate_v2"
|
|
998
992
|
/* inventory_portal_po_operate_v2 */
|
|
999
993
|
)
|
|
1000
994
|
};
|
|
1001
995
|
}, "feature");
|
|
1002
996
|
},
|
|
1003
|
-
async setUser(
|
|
1004
|
-
const { setUser:
|
|
1005
|
-
await
|
|
997
|
+
async setUser(m) {
|
|
998
|
+
const { setUser: u } = Vt();
|
|
999
|
+
await u(m.doc._id);
|
|
1006
1000
|
}
|
|
1007
1001
|
});
|
|
1008
|
-
function
|
|
1009
|
-
|
|
1010
|
-
const { getFlagValue:
|
|
1011
|
-
return
|
|
1002
|
+
function et(m, u) {
|
|
1003
|
+
u = u === void 0 ? null : u;
|
|
1004
|
+
const { getFlagValue: h } = Vt();
|
|
1005
|
+
return h(m, (g) => (m === "inventory_pos_closing_v2" && console.log(g, typeof g), g === "true")) ?? u;
|
|
1012
1006
|
}
|
|
1013
1007
|
export {
|
|
1014
|
-
|
|
1008
|
+
Te as u
|
|
1015
1009
|
};
|