@naturalcycles/internal-web-lib 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/analyticsClient.js +223 -200
- package/bundle/analyticsClient.js.map +1 -1
- package/bundle/conversionClient.js +223 -192
- package/bundle/conversionClient.js.map +1 -1
- package/bundle/cookieMonster.js +2 -2
- package/bundle/cookieMonster.js.map +1 -1
- package/dist/analytics/analyticsClient.d.ts +1 -1
- package/dist/analytics/analyticsClient.js +9 -8
- package/dist/analytics/index.js +1 -2
- package/dist/conversion/conversionClient.d.ts +3 -2
- package/dist/conversion/conversionClient.js +7 -4
- package/dist/cookie-monster/css/shared-sheets.js +1 -1
- package/dist/node_modules/.pnpm/@naturalcycles_ncuikit@1.15.0_react@19.3.0_undici@8.11.2/node_modules/@naturalcycles/ncuikit/dist/styles/_palette.js +4 -0
- package/package.json +1 -1
- package/dist/node_modules/.pnpm/@naturalcycles_ncuikit@1.14.0_react@19.3.0_undici@8.11.2/node_modules/@naturalcycles/ncuikit/dist/styles/_palette.js +0 -4
|
@@ -9,7 +9,7 @@ function t() {
|
|
|
9
9
|
return e();
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
12
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/is.util.js
|
|
13
13
|
var n = (e) => !!e;
|
|
14
14
|
function r(e) {
|
|
15
15
|
return typeof e == "object" && !!e && !Array.isArray(e) || !1;
|
|
@@ -25,7 +25,7 @@ function i(e) {
|
|
|
25
25
|
return !1;
|
|
26
26
|
}
|
|
27
27
|
//#endregion
|
|
28
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
28
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/abort.js
|
|
29
29
|
function a(e) {
|
|
30
30
|
return e ? o(e) : void 0;
|
|
31
31
|
}
|
|
@@ -54,8 +54,36 @@ function u(e) {
|
|
|
54
54
|
});
|
|
55
55
|
return t.signal;
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/log/commonLogger.js
|
|
59
|
+
function d(e, t) {
|
|
60
|
+
let n = (n, [r, i]) => e({
|
|
61
|
+
...t?.(),
|
|
62
|
+
...ee(r, i),
|
|
63
|
+
level: n
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
debug: (...e) => n("debug", e),
|
|
67
|
+
log: (...e) => n("log", e),
|
|
68
|
+
warn: (...e) => n("warn", e),
|
|
69
|
+
error: (...e) => n("error", e),
|
|
70
|
+
child: (n) => d(e, () => ({
|
|
71
|
+
...t?.(),
|
|
72
|
+
...n
|
|
73
|
+
}))
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function ee(e, t) {
|
|
77
|
+
return typeof e == "string" ? {
|
|
78
|
+
...t,
|
|
79
|
+
msg: e
|
|
80
|
+
} : e instanceof Error ? { err: e } : e;
|
|
81
|
+
}
|
|
82
|
+
var f = d(({ level: e, msg: t, err: n, ...r }) => {
|
|
83
|
+
let i = [];
|
|
84
|
+
t !== void 0 && i.push(t), n !== void 0 && i.push(n), Object.keys(r).length && i.push(r), console[e](...i);
|
|
85
|
+
}), p = new class {
|
|
86
|
+
logger = f;
|
|
59
87
|
pendingOps = /* @__PURE__ */ new Set();
|
|
60
88
|
onErrorHooks = [];
|
|
61
89
|
runInBackground(e) {
|
|
@@ -81,12 +109,15 @@ var d = new class {
|
|
|
81
109
|
this.pendingOps.clear(), this.onErrorHooks = [];
|
|
82
110
|
}
|
|
83
111
|
fireOnErrorHooks(e) {
|
|
84
|
-
this.onErrorHooks.length ? this.onErrorHooks.forEach((t) => t(e)) : this.logger.error(
|
|
112
|
+
this.onErrorHooks.length ? this.onErrorHooks.forEach((t) => t(e)) : this.logger.error({
|
|
113
|
+
msg: "AsyncManager unhandled rejection",
|
|
114
|
+
err: e
|
|
115
|
+
});
|
|
85
116
|
}
|
|
86
|
-
}(),
|
|
117
|
+
}(), m = p.runInBackground.bind(p), te = (...e) => void 0, h = Object.entries;
|
|
87
118
|
//#endregion
|
|
88
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
89
|
-
function
|
|
119
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/object/object.util.js
|
|
120
|
+
function ne(e, t, n = {}) {
|
|
90
121
|
if (n.mutate) {
|
|
91
122
|
for (let n of Object.keys(e)) t.includes(n) || delete e[n];
|
|
92
123
|
return e;
|
|
@@ -95,7 +126,7 @@ function te(e, t, n = {}) {
|
|
|
95
126
|
for (let n of t) n in e && (r[n] = e[n]);
|
|
96
127
|
return r;
|
|
97
128
|
}
|
|
98
|
-
function
|
|
129
|
+
function g(e, t, n = {}) {
|
|
99
130
|
if (n.mutate) {
|
|
100
131
|
for (let n of t) delete e[n];
|
|
101
132
|
return e;
|
|
@@ -104,98 +135,98 @@ function m(e, t, n = {}) {
|
|
|
104
135
|
for (let n of Object.keys(e)) t.includes(n) || (r[n] = e[n]);
|
|
105
136
|
return r;
|
|
106
137
|
}
|
|
107
|
-
function
|
|
108
|
-
return
|
|
138
|
+
function re(e, t = {}) {
|
|
139
|
+
return y(e, (e, t) => !!t, t);
|
|
109
140
|
}
|
|
110
|
-
function
|
|
111
|
-
return
|
|
141
|
+
function _(e, t = {}) {
|
|
142
|
+
return y(e, (e, t) => t != null, t);
|
|
112
143
|
}
|
|
113
|
-
function
|
|
114
|
-
return
|
|
144
|
+
function v(e, t = {}) {
|
|
145
|
+
return y(e, (e, t) => t !== void 0, t);
|
|
115
146
|
}
|
|
116
|
-
function
|
|
147
|
+
function y(e, t, n = {}) {
|
|
117
148
|
if (n.mutate) {
|
|
118
|
-
for (let [n, r] of
|
|
149
|
+
for (let [n, r] of h(e)) t(n, r, e) || delete e[n];
|
|
119
150
|
return e;
|
|
120
151
|
}
|
|
121
152
|
let r = {};
|
|
122
|
-
for (let [n, i] of
|
|
153
|
+
for (let [n, i] of h(e)) t(n, i, e) && (r[n] = i);
|
|
123
154
|
return r;
|
|
124
155
|
}
|
|
125
|
-
function
|
|
156
|
+
function b(e, t) {
|
|
126
157
|
let n = {};
|
|
127
158
|
for (let [r, i] of Object.entries(e)) n[t(r, i, e)] = i;
|
|
128
159
|
return n;
|
|
129
160
|
}
|
|
130
|
-
function
|
|
131
|
-
return
|
|
161
|
+
function ie(e, t = {}) {
|
|
162
|
+
return y(e, (e, t) => !i(t), t);
|
|
132
163
|
}
|
|
133
|
-
function
|
|
134
|
-
for (let n of t) if (r(n)) for (let t of Object.keys(n)) t !== "__proto__" && t !== "constructor" && t !== "prototype" && (r(n[t]) ? (e[t] ||= {},
|
|
164
|
+
function x(e, ...t) {
|
|
165
|
+
for (let n of t) if (r(n)) for (let t of Object.keys(n)) t !== "__proto__" && t !== "constructor" && t !== "prototype" && (r(n[t]) ? (e[t] ||= {}, x(e[t], n[t])) : e[t] = n[t]);
|
|
135
166
|
return e;
|
|
136
167
|
}
|
|
137
168
|
//#endregion
|
|
138
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
139
|
-
function
|
|
140
|
-
return !
|
|
169
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/env.js
|
|
170
|
+
function S() {
|
|
171
|
+
return !C();
|
|
141
172
|
}
|
|
142
|
-
function
|
|
173
|
+
function C() {
|
|
143
174
|
return typeof window < "u" && !!window?.document;
|
|
144
175
|
}
|
|
145
176
|
//#endregion
|
|
146
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
147
|
-
var
|
|
148
|
-
function
|
|
149
|
-
if (typeof e == "string" && e &&
|
|
177
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/string/json.util.js
|
|
178
|
+
var ae = /^\s*[{["\-\d]/;
|
|
179
|
+
function w(e, t) {
|
|
180
|
+
if (typeof e == "string" && e && ae.test(e)) try {
|
|
150
181
|
return JSON.parse(e, t);
|
|
151
182
|
} catch {}
|
|
152
183
|
return e;
|
|
153
184
|
}
|
|
154
|
-
function
|
|
185
|
+
function T(e, t) {
|
|
155
186
|
try {
|
|
156
187
|
return JSON.parse(e, t);
|
|
157
188
|
} catch {
|
|
158
|
-
throw new
|
|
189
|
+
throw new L({ text: e });
|
|
159
190
|
}
|
|
160
191
|
}
|
|
161
192
|
//#endregion
|
|
162
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
163
|
-
function
|
|
193
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/string/string.util.js
|
|
194
|
+
function E(e, t, n = "...") {
|
|
164
195
|
if (!e || e.length <= t) return e;
|
|
165
196
|
if (t <= n.length) return n;
|
|
166
197
|
let r = Math.round((t - n.length) / 2), i = e.length - Math.floor((t - n.length) / 2);
|
|
167
198
|
return e.slice(0, r) + n + e.slice(i);
|
|
168
199
|
}
|
|
169
200
|
//#endregion
|
|
170
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
171
|
-
function
|
|
201
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/error/error.util.js
|
|
202
|
+
function D(e, t = Error, n) {
|
|
172
203
|
let r;
|
|
173
|
-
return r = e instanceof t ? e : O(
|
|
204
|
+
return r = e instanceof t ? e : oe(O(e), t), n && (r.data ||= {}, Object.assign(r.data, n)), r;
|
|
174
205
|
}
|
|
175
|
-
function
|
|
206
|
+
function O(e, t) {
|
|
176
207
|
let n;
|
|
177
|
-
return
|
|
208
|
+
return M(e) ? n = k(e) : (e = w(e), n = A(e) ? e.error : j(e) ? e : M(e) ? k(e) : {
|
|
178
209
|
name: "Error",
|
|
179
|
-
message:
|
|
210
|
+
message: W(e),
|
|
180
211
|
data: {}
|
|
181
212
|
}), Object.assign(n.data, t), n;
|
|
182
213
|
}
|
|
183
|
-
function
|
|
184
|
-
if (!(e instanceof Error) &&
|
|
214
|
+
function k(e) {
|
|
215
|
+
if (!(e instanceof Error) && j(e)) return e;
|
|
185
216
|
let t = {
|
|
186
217
|
name: e.name,
|
|
187
218
|
message: e.message,
|
|
188
219
|
data: { ...e.data }
|
|
189
220
|
};
|
|
190
|
-
return e.stack && (t.stack = e.stack), e.cause && (t.cause =
|
|
221
|
+
return e.stack && (t.stack = e.stack), e.cause && (t.cause = O(e.cause)), t;
|
|
191
222
|
}
|
|
192
|
-
function
|
|
223
|
+
function oe(e, t = Error) {
|
|
193
224
|
if (e instanceof t) return e;
|
|
194
225
|
let { name: n, cause: r } = e, i = new t(e.message, e.data, {
|
|
195
226
|
name: n,
|
|
196
227
|
cause: r
|
|
197
228
|
});
|
|
198
|
-
return e.stack && Object.defineProperty(i, "stack", { value: e.stack }), i instanceof
|
|
229
|
+
return e.stack && Object.defineProperty(i, "stack", { value: e.stack }), i instanceof P || (Object.defineProperties(i, {
|
|
199
230
|
name: {
|
|
200
231
|
value: n,
|
|
201
232
|
configurable: !0,
|
|
@@ -219,31 +250,31 @@ function O(e, t = Error) {
|
|
|
219
250
|
writable: !0
|
|
220
251
|
})), i;
|
|
221
252
|
}
|
|
222
|
-
function
|
|
253
|
+
function A(e) {
|
|
223
254
|
try {
|
|
224
|
-
return
|
|
255
|
+
return j(e?.error);
|
|
225
256
|
} catch {
|
|
226
257
|
return !1;
|
|
227
258
|
}
|
|
228
259
|
}
|
|
229
|
-
function
|
|
260
|
+
function j(e) {
|
|
230
261
|
try {
|
|
231
262
|
return !!e && typeof e == "object" && typeof e.name == "string" && typeof e.message == "string" && typeof e.data == "object";
|
|
232
263
|
} catch {
|
|
233
264
|
return !1;
|
|
234
265
|
}
|
|
235
266
|
}
|
|
236
|
-
function
|
|
267
|
+
function M(e) {
|
|
237
268
|
try {
|
|
238
269
|
return !!e && typeof e == "object" && typeof e.name == "string" && typeof e.message == "string";
|
|
239
270
|
} catch {
|
|
240
271
|
return !1;
|
|
241
272
|
}
|
|
242
273
|
}
|
|
243
|
-
function
|
|
244
|
-
return t ?
|
|
274
|
+
function N(e, t) {
|
|
275
|
+
return t ? D(e, void 0, t) : e;
|
|
245
276
|
}
|
|
246
|
-
var
|
|
277
|
+
var P = class e extends Error {
|
|
247
278
|
data;
|
|
248
279
|
cause;
|
|
249
280
|
static of(t) {
|
|
@@ -254,7 +285,7 @@ var N = class e extends Error {
|
|
|
254
285
|
}
|
|
255
286
|
constructor(e, t = {}, n = {}) {
|
|
256
287
|
super(e);
|
|
257
|
-
let { name: r =
|
|
288
|
+
let { name: r = S() ? this.constructor.name : "AppError", cause: i } = n;
|
|
258
289
|
Object.defineProperties(this, {
|
|
259
290
|
name: {
|
|
260
291
|
value: r,
|
|
@@ -268,7 +299,7 @@ var N = class e extends Error {
|
|
|
268
299
|
enumerable: !1
|
|
269
300
|
}
|
|
270
301
|
}), i ? Object.defineProperty(this, "cause", {
|
|
271
|
-
value:
|
|
302
|
+
value: O(i),
|
|
272
303
|
writable: !0,
|
|
273
304
|
configurable: !0,
|
|
274
305
|
enumerable: !0
|
|
@@ -278,44 +309,44 @@ var N = class e extends Error {
|
|
|
278
309
|
writable: !0
|
|
279
310
|
});
|
|
280
311
|
}
|
|
281
|
-
},
|
|
312
|
+
}, F = class extends P {
|
|
282
313
|
constructor(e, t, n) {
|
|
283
314
|
t.response && Object.defineProperty(t, "response", { enumerable: !1 }), super(e, t, {
|
|
284
315
|
...n,
|
|
285
316
|
name: "HttpRequestError"
|
|
286
317
|
});
|
|
287
318
|
}
|
|
288
|
-
},
|
|
319
|
+
}, I = class extends P {
|
|
289
320
|
constructor(e, t) {
|
|
290
321
|
super(e, t, { name: "AssertionError" });
|
|
291
322
|
}
|
|
292
|
-
},
|
|
323
|
+
}, L = class extends P {
|
|
293
324
|
constructor(e) {
|
|
294
|
-
let t = ["Failed to parse", e.text &&
|
|
325
|
+
let t = ["Failed to parse", e.text && E(e.text, 200)].filter(Boolean).join(": ");
|
|
295
326
|
super(t, e, { name: "JsonParseError" });
|
|
296
327
|
}
|
|
297
|
-
},
|
|
328
|
+
}, R = class extends P {
|
|
298
329
|
constructor(e, t, n) {
|
|
299
330
|
super(e, t, {
|
|
300
331
|
...n,
|
|
301
332
|
name: "TimeoutError"
|
|
302
333
|
});
|
|
303
334
|
}
|
|
304
|
-
},
|
|
335
|
+
}, z = class extends P {
|
|
305
336
|
constructor(e) {
|
|
306
337
|
super(e || "expected error was not thrown", {}, { name: "UnexpectedPassError" });
|
|
307
338
|
}
|
|
308
339
|
};
|
|
309
340
|
//#endregion
|
|
310
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
311
|
-
function
|
|
341
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/string/safeJsonStringify.js
|
|
342
|
+
function B(e, t, n, r) {
|
|
312
343
|
try {
|
|
313
344
|
return JSON.stringify(e, t, n);
|
|
314
345
|
} catch {
|
|
315
|
-
return JSON.stringify(e,
|
|
346
|
+
return JSON.stringify(e, V(t, r), n);
|
|
316
347
|
}
|
|
317
348
|
}
|
|
318
|
-
function
|
|
349
|
+
function V(e, t) {
|
|
319
350
|
let n = [], r = [];
|
|
320
351
|
return t ??= (e, t) => n[0] === t ? "[Circular ~]" : "[Circular ~." + r.slice(0, n.indexOf(t)).join(".") + "]", function(i, a) {
|
|
321
352
|
if (n.length > 0) {
|
|
@@ -326,22 +357,22 @@ function z(e, t) {
|
|
|
326
357
|
};
|
|
327
358
|
}
|
|
328
359
|
//#endregion
|
|
329
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
330
|
-
var
|
|
331
|
-
function
|
|
360
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/string/stringify.js
|
|
361
|
+
var H = typeof globalThis.AggregateError == "function", U = B;
|
|
362
|
+
function W(e, t = {}) {
|
|
332
363
|
if (e === void 0) return "undefined";
|
|
333
364
|
if (e === null) return "null";
|
|
334
365
|
if (typeof e == "function") return "function";
|
|
335
366
|
if (typeof e == "symbol") return e.toString();
|
|
336
367
|
let n;
|
|
337
|
-
if (e =
|
|
338
|
-
if (e instanceof Error ||
|
|
368
|
+
if (e = w(e), A(e)) return W(e.error, t);
|
|
369
|
+
if (e instanceof Error || M(e)) n = G(e, t);
|
|
339
370
|
else if (typeof e == "string") n = e.trim() || "empty_string";
|
|
340
371
|
else if (typeof e == "number") n = String(e);
|
|
341
372
|
else {
|
|
342
373
|
e instanceof Map ? e = Object.fromEntries(e) : e instanceof Set && (e = Array.from(e));
|
|
343
374
|
try {
|
|
344
|
-
let { stringifyFn: r =
|
|
375
|
+
let { stringifyFn: r = U } = t;
|
|
345
376
|
n = r(e, void 0, 2);
|
|
346
377
|
} catch {
|
|
347
378
|
n = String(e);
|
|
@@ -349,31 +380,31 @@ function H(e, t = {}) {
|
|
|
349
380
|
}
|
|
350
381
|
if (n === void 0) return "undefined";
|
|
351
382
|
let { maxLen: r = 1e4 } = t;
|
|
352
|
-
return r && n.length > r ?
|
|
383
|
+
return r && n.length > r ? E(n, r, `\n... ${Math.ceil(n.length / 1024)} Kb message truncated ...\n`) : n;
|
|
353
384
|
}
|
|
354
|
-
function
|
|
385
|
+
function G(e, t) {
|
|
355
386
|
let { includeErrorCause: n = !0 } = t, r = [e.name, e.message].filter(Boolean).join(": ");
|
|
356
|
-
if (typeof e.code == "string" && (r += `\ncode: ${e.code}`), t.includeErrorData &&
|
|
387
|
+
if (typeof e.code == "string" && (r += `\ncode: ${e.code}`), t.includeErrorData && j(e) && Object.keys(e.data).length && (r += "\n" + W(e.data, t)), t.includeErrorStack && e.stack) {
|
|
357
388
|
let t = r.split("\n").length;
|
|
358
389
|
r = [r, ...e.stack.split("\n").slice(t)].join("\n");
|
|
359
390
|
}
|
|
360
|
-
return
|
|
391
|
+
return H && e instanceof AggregateError && e.errors.length && (r = [
|
|
361
392
|
r,
|
|
362
393
|
`${e.errors.length} error(s):`,
|
|
363
|
-
...e.errors.map((e, n) => `${n + 1}. ${
|
|
364
|
-
].join("\n")), e.cause && n && (r = r + "\nCaused by: " +
|
|
394
|
+
...e.errors.map((e, n) => `${n + 1}. ${W(e, t)}`)
|
|
395
|
+
].join("\n")), e.cause && n && (r = r + "\nCaused by: " + W(e.cause, t)), r;
|
|
365
396
|
}
|
|
366
397
|
//#endregion
|
|
367
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
368
|
-
function
|
|
369
|
-
if (!(e instanceof t)) throw new
|
|
398
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/error/assert.js
|
|
399
|
+
function K(e, t = Error) {
|
|
400
|
+
if (!(e instanceof t)) throw new I(`Expected to be instanceof ${t.name}, actual typeof: ${typeof e}`);
|
|
370
401
|
}
|
|
371
|
-
function
|
|
402
|
+
function q(e, t) {
|
|
372
403
|
if (!(e instanceof t)) throw e;
|
|
373
404
|
}
|
|
374
405
|
//#endregion
|
|
375
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
376
|
-
async function
|
|
406
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/promise/pDelay.js
|
|
407
|
+
async function se(e, t) {
|
|
377
408
|
t?.aborted || await new Promise((n) => {
|
|
378
409
|
let r = setTimeout(i, e);
|
|
379
410
|
function i() {
|
|
@@ -383,40 +414,38 @@ async function K(e, t) {
|
|
|
383
414
|
});
|
|
384
415
|
}
|
|
385
416
|
//#endregion
|
|
386
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
387
|
-
function
|
|
388
|
-
return
|
|
417
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/datetime/time.util.js
|
|
418
|
+
function J(e, t = Date.now()) {
|
|
419
|
+
return Y(t - e);
|
|
389
420
|
}
|
|
390
|
-
function
|
|
421
|
+
function Y(e) {
|
|
391
422
|
if (e < 1e3) return `${Math.round(e)} ms`;
|
|
392
423
|
if (e < 1e4) return `${(e / 1e3).toFixed(2)} sec`;
|
|
393
424
|
let t = Math.floor(e / 1e3) % 60, n = Math.floor(e / 6e4) % 60, r = Math.floor(e / 36e5);
|
|
394
425
|
return r === 0 ? n === 0 ? `${t} sec` : `${n}m${t}s` : r < 24 ? `${r}h${n}m` : r < 48 ? `${Math.round(r + n / 60)}h` : `${Math.floor(r / 24)} days`;
|
|
395
426
|
}
|
|
396
427
|
//#endregion
|
|
397
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
398
|
-
function
|
|
428
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/number/number.util.js
|
|
429
|
+
function ce(e, t, n) {
|
|
399
430
|
return e <= t ? t : e >= n ? n : e;
|
|
400
431
|
}
|
|
401
432
|
//#endregion
|
|
402
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
403
|
-
async function
|
|
433
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/promise/pTimeout.js
|
|
434
|
+
async function le(e, t) {
|
|
404
435
|
let n = new AbortController(), { signal: r } = n;
|
|
405
436
|
if (!t.timeout) return await e(r);
|
|
406
437
|
let { timeout: i, name: a = e.name || "pTimeout function", onTimeout: o } = t, s = t.fakeError || /* @__PURE__ */ Error("TimeoutError");
|
|
407
438
|
return await new Promise(async (c, l) => {
|
|
408
439
|
let u = setTimeout(() => {
|
|
409
|
-
let e = new
|
|
440
|
+
let e = new R(`"${a}" timed out after ${i} ms`, t.errorData);
|
|
410
441
|
if (e.stack = s.stack.replace("Error: TimeoutError", "TimeoutError: " + e.message), o) {
|
|
411
442
|
try {
|
|
412
443
|
c(o(e));
|
|
413
444
|
} catch (e) {
|
|
414
|
-
e.stack = s.stack.replace("Error: TimeoutError", e.name + ": " + e.message), l(
|
|
445
|
+
e.stack = s.stack.replace("Error: TimeoutError", e.name + ": " + e.message), l(N(e, t.errorData));
|
|
415
446
|
}
|
|
416
447
|
n.abort(e);
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
l(e), n.abort(e);
|
|
448
|
+
} else l(e), n.abort(e);
|
|
420
449
|
}, i);
|
|
421
450
|
try {
|
|
422
451
|
c(await e(r));
|
|
@@ -428,8 +457,8 @@ async function se(e, t) {
|
|
|
428
457
|
});
|
|
429
458
|
}
|
|
430
459
|
//#endregion
|
|
431
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
432
|
-
function
|
|
460
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/string/url.util.js
|
|
461
|
+
function ue(e, t) {
|
|
433
462
|
if (typeof e != "string") return null;
|
|
434
463
|
try {
|
|
435
464
|
return new URL(e, t || void 0);
|
|
@@ -438,21 +467,21 @@ function ce(e, t) {
|
|
|
438
467
|
}
|
|
439
468
|
}
|
|
440
469
|
//#endregion
|
|
441
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.
|
|
442
|
-
var
|
|
470
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+js-lib@15.93.0_undici@8.11.2/node_modules/@naturalcycles/js-lib/dist/http/http.model.js
|
|
471
|
+
var de = [
|
|
443
472
|
"GET",
|
|
444
473
|
"POST",
|
|
445
474
|
"PUT",
|
|
446
475
|
"PATCH",
|
|
447
476
|
"DELETE",
|
|
448
477
|
"HEAD"
|
|
449
|
-
],
|
|
478
|
+
], fe = class e {
|
|
450
479
|
static VERSION = 5;
|
|
451
|
-
static userAgent =
|
|
480
|
+
static userAgent = S() ? `fetcher/${this.VERSION}` : void 0;
|
|
452
481
|
constructor(e = {}) {
|
|
453
482
|
if (typeof globalThis.fetch != "function") throw TypeError("globalThis.fetch is not available");
|
|
454
483
|
this.cfg = this.normalizeCfg(e);
|
|
455
|
-
for (let e of
|
|
484
|
+
for (let e of de) {
|
|
456
485
|
let t = e.toLowerCase();
|
|
457
486
|
this[`${t}Void`] = async (t, n) => await this.fetch({
|
|
458
487
|
url: t,
|
|
@@ -514,7 +543,7 @@ var le = [
|
|
|
514
543
|
headVoid;
|
|
515
544
|
async queryGraphQL(e) {
|
|
516
545
|
e = { ...e }, e.method ||= this.cfg.init.method;
|
|
517
|
-
let t =
|
|
546
|
+
let t = re({
|
|
518
547
|
query: e.query,
|
|
519
548
|
variables: e.variables
|
|
520
549
|
});
|
|
@@ -526,7 +555,7 @@ var le = [
|
|
|
526
555
|
if (n.err) throw n.err;
|
|
527
556
|
if (n.body.errors) {
|
|
528
557
|
let e = n.body.errors[0];
|
|
529
|
-
throw new
|
|
558
|
+
throw new F(e.message, {
|
|
530
559
|
...t,
|
|
531
560
|
errors: n.body.errors,
|
|
532
561
|
response: n.fetchResponse,
|
|
@@ -569,12 +598,12 @@ var le = [
|
|
|
569
598
|
}
|
|
570
599
|
async expectError(e) {
|
|
571
600
|
let t = await this.doFetch(e);
|
|
572
|
-
if (!t.err) throw new
|
|
573
|
-
return
|
|
601
|
+
if (!t.err) throw new z("Fetch was expected to error");
|
|
602
|
+
return K(t.err, F), t.err;
|
|
574
603
|
}
|
|
575
604
|
async tryFetch(e) {
|
|
576
605
|
let t = await this.doFetch(e);
|
|
577
|
-
return t.err ? (
|
|
606
|
+
return t.err ? (q(t.err, F), [t.err, null]) : [null, t.body];
|
|
578
607
|
}
|
|
579
608
|
async doFetch(t) {
|
|
580
609
|
let n = 0;
|
|
@@ -604,36 +633,36 @@ var le = [
|
|
|
604
633
|
" >>",
|
|
605
634
|
u,
|
|
606
635
|
e && `try#${e + 1}/${r.retry.count + 1}`
|
|
607
|
-
].filter(Boolean).join(" ")), r.logRequestBody && r.init.body && i.log(r.init.body);
|
|
636
|
+
].filter(Boolean).join(" ")), r.logRequestBody && r.init.body && i.log({ body: r.init.body });
|
|
608
637
|
}
|
|
609
638
|
try {
|
|
610
639
|
d.fetchResponse = await (r.overrideFetchFn || e.callNativeFetch)(r.fullUrl, r.init, r.fetchFn), d.ok = d.fetchResponse.ok, d.err = void 0;
|
|
611
640
|
} catch (e) {
|
|
612
|
-
d.err =
|
|
641
|
+
d.err = D(e), d.ok = !1, d.fetchResponse = void 0;
|
|
613
642
|
}
|
|
614
643
|
if (d.statusFamily = this.getStatusFamily(d), d.statusCode = d.fetchResponse?.status, d.fetchResponse?.ok) try {
|
|
615
|
-
await
|
|
644
|
+
await le(async () => await this.onOkResponse(d), {
|
|
616
645
|
timeout: s ?? 0,
|
|
617
646
|
name: "Fetcher.downloadBody"
|
|
618
647
|
});
|
|
619
648
|
} catch (e) {
|
|
620
|
-
d.err =
|
|
649
|
+
d.err = D(e), d.ok = !1, await this.onNotOkResponse(d);
|
|
621
650
|
}
|
|
622
651
|
else await this.onNotOkResponse(d);
|
|
623
652
|
}
|
|
624
653
|
if (d.err) {
|
|
625
|
-
|
|
654
|
+
N(d.err, r.errorData), r.onError?.(d.err);
|
|
626
655
|
for (let e of this.cfg.hooks.onError || []) await e(d.err);
|
|
627
656
|
}
|
|
628
657
|
for (let e of this.cfg.hooks.afterResponse || []) await e(d);
|
|
629
658
|
return d.err && await this.detectStaleInit(t, d, n) ? await this.doFetch({
|
|
630
659
|
...t,
|
|
631
|
-
[
|
|
660
|
+
[X]: !0
|
|
632
661
|
}) : d;
|
|
633
662
|
}
|
|
634
663
|
async detectStaleInit(e, t, n) {
|
|
635
664
|
let { shouldReinit: r, init: i } = this.cfg.hooks;
|
|
636
|
-
return !r || !i || e[
|
|
665
|
+
return !r || !i || e[X] || !await r(t) ? !1 : (n === this.initGeneration && this.resetInit(), !0);
|
|
637
666
|
}
|
|
638
667
|
async runInitHooks() {
|
|
639
668
|
for (let e of this.cfg.hooks.init || []) await e(this.cfg);
|
|
@@ -643,7 +672,7 @@ var le = [
|
|
|
643
672
|
if (n === "json") {
|
|
644
673
|
if (e.fetchResponse.body) {
|
|
645
674
|
let n = await e.fetchResponse.text();
|
|
646
|
-
n ? (e.body = n, e.body =
|
|
675
|
+
n ? (e.body = n, e.body = T(n, t.jsonReviver)) : e.body = {};
|
|
647
676
|
} else e.body = {};
|
|
648
677
|
} else if (n === "text") e.body = e.fetchResponse.body ? await e.fetchResponse.text() : "";
|
|
649
678
|
else if (n === "arrayBuffer") e.body = e.fetchResponse.body ? await e.fetchResponse.arrayBuffer() : /* @__PURE__ */ new ArrayBuffer(0);
|
|
@@ -658,8 +687,8 @@ var le = [
|
|
|
658
687
|
e.fetchResponse.status,
|
|
659
688
|
e.signature,
|
|
660
689
|
n && `try#${n + 1}/${t.retry.count + 1}`,
|
|
661
|
-
|
|
662
|
-
].filter(Boolean).join(" ")), t.logResponseBody && e.body !== void 0 && r.log(e.body);
|
|
690
|
+
J(e.req.started)
|
|
691
|
+
].filter(Boolean).join(" ")), t.logResponseBody && e.body !== void 0 && r.log({ body: e.body });
|
|
663
692
|
}
|
|
664
693
|
}
|
|
665
694
|
static async callNativeFetch(e, t, n) {
|
|
@@ -668,15 +697,15 @@ var le = [
|
|
|
668
697
|
async onNotOkResponse(e) {
|
|
669
698
|
let t;
|
|
670
699
|
if (!e.body && e.fetchResponse) try {
|
|
671
|
-
e.body =
|
|
700
|
+
e.body = w(await e.fetchResponse.text());
|
|
672
701
|
} catch {}
|
|
673
|
-
t = e.err ?
|
|
702
|
+
t = e.err ? k(e.err) : e.body ? O(e.body) : {
|
|
674
703
|
name: "Error",
|
|
675
704
|
message: "Fetch failed",
|
|
676
705
|
data: {}
|
|
677
706
|
};
|
|
678
707
|
let n = e.fetchResponse?.status || 0;
|
|
679
|
-
e.statusFamily === 2 && (e.statusFamily = void 0, e.statusCode = void 0, n = 0), e.err = new
|
|
708
|
+
e.statusFamily === 2 && (e.statusFamily = void 0, e.statusCode = void 0, n = 0), e.err = new F([e.statusCode, e.signature].filter(Boolean).join(" "), _({
|
|
680
709
|
response: e.fetchResponse,
|
|
681
710
|
responseStatusCode: n,
|
|
682
711
|
requestUrl: e.req.fullUrl,
|
|
@@ -693,20 +722,19 @@ var le = [
|
|
|
693
722
|
this.shouldRetry(e) || (t.retryStopped = !0);
|
|
694
723
|
for (let t of this.cfg.hooks.beforeRetry || []) await t(e);
|
|
695
724
|
let { count: n, timeoutMultiplier: r, timeoutMax: i } = e.req.retry;
|
|
696
|
-
if (t.retryAttempt >= n && (t.retryStopped = !0), e.err && (!t.retryStopped || e.req.logResponse) && this.cfg.logger.error(
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
725
|
+
if (t.retryAttempt >= n && (t.retryStopped = !0), e.err && (!t.retryStopped || e.req.logResponse) && this.cfg.logger.error({
|
|
726
|
+
msg: [
|
|
727
|
+
" <<",
|
|
728
|
+
e.fetchResponse?.status || 0,
|
|
729
|
+
e.signature,
|
|
730
|
+
n && (t.retryAttempt || !t.retryStopped) && `try#${t.retryAttempt + 1}/${n + 1}`,
|
|
731
|
+
J(e.req.started)
|
|
732
|
+
].filter(Boolean).join(" "),
|
|
733
|
+
err: e.err.cause || e.err
|
|
734
|
+
}), t.retryStopped) return;
|
|
703
735
|
t.retryAttempt++;
|
|
704
736
|
let a = this.getRetryTimeout(e);
|
|
705
|
-
|
|
706
|
-
this.cfg.logger.warn(`${e.signature} server-indicated delay exceeds maxRetryAfter, will not retry`), t.retryStopped = !0;
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
t.retryTimeout = oe(t.retryTimeout * r, 0, i), e.req.debug && this.cfg.logger.log(` .. ${e.signature} waiting ${J(a)}`), await K(a, e.req.signal), e.req.signal?.aborted && (t.retryStopped = !0);
|
|
737
|
+
a === null ? (this.cfg.logger.warn(`${e.signature} server-indicated delay exceeds maxRetryAfter, will not retry`), t.retryStopped = !0) : (t.retryTimeout = ce(t.retryTimeout * r, 0, i), e.req.debug && this.cfg.logger.log(` .. ${e.signature} waiting ${Y(a)}`), await se(a, e.req.signal), e.req.signal?.aborted && (t.retryStopped = !0));
|
|
710
738
|
}
|
|
711
739
|
getRetryTimeout(e) {
|
|
712
740
|
let t = 0;
|
|
@@ -750,9 +778,9 @@ var le = [
|
|
|
750
778
|
return this.cfg.logWithSearchParams || (n = n.split("?")[0]), !this.cfg.logWithBaseUrl && t && n.startsWith(t) && (n = n.slice(t.length)), n;
|
|
751
779
|
}
|
|
752
780
|
normalizeCfg(t) {
|
|
753
|
-
let { debug: n = !1, logger: r =
|
|
781
|
+
let { debug: n = !1, logger: r = f } = t;
|
|
754
782
|
t.baseUrl?.endsWith("/") && (r.warn(`Fetcher: baseUrl should not end with slash: ${t.baseUrl}`), t.baseUrl = t.baseUrl.slice(0, t.baseUrl.length - 1));
|
|
755
|
-
let i =
|
|
783
|
+
let i = x({
|
|
756
784
|
baseUrl: "",
|
|
757
785
|
name: this.getFetcherName(t),
|
|
758
786
|
inputUrl: "",
|
|
@@ -769,12 +797,12 @@ var le = [
|
|
|
769
797
|
logRequestBody: n,
|
|
770
798
|
logResponse: n,
|
|
771
799
|
logResponseBody: n,
|
|
772
|
-
logWithBaseUrl:
|
|
800
|
+
logWithBaseUrl: S(),
|
|
773
801
|
logWithSearchParams: !0,
|
|
774
|
-
retry: { ...
|
|
802
|
+
retry: { ...he },
|
|
775
803
|
init: {
|
|
776
804
|
method: t.method || "GET",
|
|
777
|
-
headers:
|
|
805
|
+
headers: _({
|
|
778
806
|
"user-agent": e.userAgent,
|
|
779
807
|
...t.headers
|
|
780
808
|
}),
|
|
@@ -786,7 +814,7 @@ var le = [
|
|
|
786
814
|
hooks: {},
|
|
787
815
|
throwHttpErrors: !0,
|
|
788
816
|
errorData: {}
|
|
789
|
-
},
|
|
817
|
+
}, g(t, [
|
|
790
818
|
"method",
|
|
791
819
|
"credentials",
|
|
792
820
|
"headers",
|
|
@@ -795,19 +823,19 @@ var le = [
|
|
|
795
823
|
"name",
|
|
796
824
|
"keepalive"
|
|
797
825
|
]));
|
|
798
|
-
return i.init.headers =
|
|
826
|
+
return i.init.headers = b(i.init.headers, (e) => e.toLowerCase()), i;
|
|
799
827
|
}
|
|
800
828
|
getFetcherName(e) {
|
|
801
829
|
let { name: t } = e;
|
|
802
830
|
if (!t && e.baseUrl) {
|
|
803
|
-
let n =
|
|
831
|
+
let n = ue(e.baseUrl);
|
|
804
832
|
n && (t = n.hostname);
|
|
805
833
|
}
|
|
806
834
|
return t;
|
|
807
835
|
}
|
|
808
836
|
normalizeOptions(t) {
|
|
809
837
|
let n = {
|
|
810
|
-
...
|
|
838
|
+
...ne(this.cfg, [
|
|
811
839
|
"timeoutSeconds",
|
|
812
840
|
"retryPost",
|
|
813
841
|
"retry3xx",
|
|
@@ -826,7 +854,7 @@ var le = [
|
|
|
826
854
|
"overrideFetchFn"
|
|
827
855
|
]),
|
|
828
856
|
started: Date.now(),
|
|
829
|
-
...
|
|
857
|
+
...g(t, [
|
|
830
858
|
"method",
|
|
831
859
|
"headers",
|
|
832
860
|
"credentials"
|
|
@@ -835,9 +863,9 @@ var le = [
|
|
|
835
863
|
fullUrl: t.url || "",
|
|
836
864
|
retry: {
|
|
837
865
|
...this.cfg.retry,
|
|
838
|
-
...
|
|
866
|
+
...v(t.retry || {})
|
|
839
867
|
},
|
|
840
|
-
init:
|
|
868
|
+
init: x({
|
|
841
869
|
...this.cfg.init,
|
|
842
870
|
headers: {
|
|
843
871
|
...this.cfg.init.headers,
|
|
@@ -847,15 +875,15 @@ var le = [
|
|
|
847
875
|
credentials: t.credentials || this.cfg.init.credentials,
|
|
848
876
|
redirect: t.redirect || this.cfg.init.redirect || "follow",
|
|
849
877
|
keepalive: t.keepalive ?? this.cfg.init.keepalive
|
|
850
|
-
}, { headers:
|
|
878
|
+
}, { headers: b(t.headers || {}, (e) => e.toLowerCase()) })
|
|
851
879
|
};
|
|
852
|
-
|
|
880
|
+
_(n.init.headers, { mutate: !0 });
|
|
853
881
|
let r = t.baseUrl || this.cfg.baseUrl;
|
|
854
882
|
if (r) {
|
|
855
883
|
let { inputUrl: e } = n;
|
|
856
884
|
e.startsWith("/") && (this.cfg.logger.warn("Fetcher: url should not start with / when baseUrl is specified"), e = e.slice(1)), n.fullUrl = `${r}/${e}`;
|
|
857
885
|
}
|
|
858
|
-
let i =
|
|
886
|
+
let i = v({
|
|
859
887
|
...this.cfg.searchParams,
|
|
860
888
|
...t.searchParams
|
|
861
889
|
});
|
|
@@ -863,13 +891,13 @@ var le = [
|
|
|
863
891
|
let e = new URLSearchParams(i).toString();
|
|
864
892
|
n.fullUrl += (n.fullUrl.includes("?") ? "&" : "?") + e;
|
|
865
893
|
}
|
|
866
|
-
return t.json === void 0 ? t.text === void 0 ? t.form ? t.form instanceof URLSearchParams || t.form instanceof FormData ? n.init.body = t.form : (n.init.body = new URLSearchParams(t.form), n.init.headers["content-type"] ||= "application/x-www-form-urlencoded") : t.body !== void 0 && (n.init.body = t.body) : (n.init.body = t.text, n.init.headers["content-type"] ||= "text/plain") : (n.init.body = JSON.stringify(t.json), n.init.headers["content-type"] ||= "application/json"), n.init.headers.accept ||=
|
|
894
|
+
return t.json === void 0 ? t.text === void 0 ? t.form ? t.form instanceof URLSearchParams || t.form instanceof FormData ? n.init.body = t.form : (n.init.body = new URLSearchParams(t.form), n.init.headers["content-type"] ||= "application/x-www-form-urlencoded") : t.body !== void 0 && (n.init.body = t.body) : (n.init.body = t.text, n.init.headers["content-type"] ||= "text/plain") : (n.init.body = JSON.stringify(t.json), n.init.headers["content-type"] ||= "application/json"), n.init.headers.accept ||= me[n.responseType], n;
|
|
867
895
|
}
|
|
868
896
|
};
|
|
869
|
-
function
|
|
870
|
-
return
|
|
897
|
+
function pe(e = {}) {
|
|
898
|
+
return fe.create(e);
|
|
871
899
|
}
|
|
872
|
-
var
|
|
900
|
+
var X = Symbol("reinitAttempted"), me = {
|
|
873
901
|
text: "text/plain",
|
|
874
902
|
json: "application/json",
|
|
875
903
|
void: "*/*",
|
|
@@ -877,13 +905,13 @@ var Y = Symbol("reinitAttempted"), fe = {
|
|
|
877
905
|
arrayBuffer: "application/octet-stream",
|
|
878
906
|
bytes: "application/octet-stream",
|
|
879
907
|
blob: "application/octet-stream"
|
|
880
|
-
},
|
|
908
|
+
}, he = {
|
|
881
909
|
count: 2,
|
|
882
910
|
timeout: 1e3,
|
|
883
911
|
timeoutMax: 3e4,
|
|
884
912
|
timeoutMultiplier: 2,
|
|
885
913
|
maxRetryAfter: 6e5
|
|
886
|
-
},
|
|
914
|
+
}, ge = {
|
|
887
915
|
"https://www.naturalcycles.com/": [
|
|
888
916
|
"shop",
|
|
889
917
|
"research-library",
|
|
@@ -898,34 +926,34 @@ var Y = Symbol("reinitAttempted"), fe = {
|
|
|
898
926
|
"https://se.naturalcycles.com/": [],
|
|
899
927
|
"https://br.naturalcycles.com/": [],
|
|
900
928
|
"https://uk.naturalcycles.com/": []
|
|
901
|
-
},
|
|
929
|
+
}, _e = {
|
|
902
930
|
"http://localhost:8000": "https://www.naturalcycles.com/",
|
|
903
931
|
"http://localhost:8001": "https://www.naturalcycles.me/",
|
|
904
932
|
"http://localhost:4200": "https://signup.naturalcycles.com/"
|
|
905
|
-
},
|
|
933
|
+
}, ve = [
|
|
906
934
|
"https://www.naturalcycles.com/",
|
|
907
935
|
"https://www.naturalcycles.me/",
|
|
908
936
|
"https://signup.naturalcycles.com/",
|
|
909
937
|
"https://se.naturalcycles.com/",
|
|
910
938
|
"https://br.naturalcycles.com/",
|
|
911
939
|
"https://uk.naturalcycles.com/"
|
|
912
|
-
],
|
|
940
|
+
], Z;
|
|
913
941
|
(function(e) {
|
|
914
942
|
e.flow = "flow", e.code = "code", e.refId = "refId", e.referral = "referral", e.ignoreConfirmation = "ignoreConfirmation", e.ic = "ic", e.measuringDevice = "measuringDevice", e.irclickid = "irclickid", e.fg = "fg", e.sfg = "sfg", e.sq = "sq", e.cbo = "cbo", e.ip = "ip", e.ipv = "ipv", e.appleAuth = "appleAuth", e.googleAuth = "googleAuth", e.od = "od", e.pl = "pl", e.ScCid = "ScCid", e.fbclid = "fbclid", e.ttclid = "ttclid", e.rdt_cid = "rdt_cid", e.epik = "epik", e.adid = "adid", e.wcf = "wcf", e.we = "we", e.werr = "werr", e.wdpm = "wdpm", e.wsc = "wsc", e.ral = "ral";
|
|
915
|
-
})(
|
|
916
|
-
var
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
943
|
+
})(Z ||= {});
|
|
944
|
+
var ye = [
|
|
945
|
+
Z.ScCid,
|
|
946
|
+
Z.irclickid,
|
|
947
|
+
Z.fbclid,
|
|
948
|
+
Z.ttclid,
|
|
949
|
+
Z.rdt_cid,
|
|
950
|
+
Z.epik
|
|
923
951
|
];
|
|
924
|
-
|
|
925
|
-
var
|
|
952
|
+
Z.flow, Z.code, Z.ignoreConfirmation, Z.ic, Z.fg, Z.sfg, Z.sq, Z.cbo, Z.ip, Z.ipv, Z.od, Z.pl, Z.wcf, Z.we, Z.wdpm, Z.wsc, Z.ral;
|
|
953
|
+
var be;
|
|
926
954
|
(function(e) {
|
|
927
955
|
e[e.OURA = 1] = "OURA", e[e.APPLE_WATCH = 2] = "APPLE_WATCH", e[e.META_LANDING_PAGE = 3] = "META_LANDING_PAGE", e[e.PAYMENT_REDIRECT_FROM_APP = 4] = "PAYMENT_REDIRECT_FROM_APP", e[e.B1 = 5] = "B1", e[e.EMAIL_VERIFICATION_REDIRECT = 6] = "EMAIL_VERIFICATION_REDIRECT", e[e.WHOOP = 7] = "WHOOP";
|
|
928
|
-
})(
|
|
956
|
+
})(be ||= {});
|
|
929
957
|
var Q = new class {
|
|
930
958
|
getAllCookies() {
|
|
931
959
|
let e = {}, t = document.cookie.split("; ");
|
|
@@ -964,7 +992,7 @@ var Q = new class {
|
|
|
964
992
|
function $(e) {
|
|
965
993
|
if (e) return e.startsWith("fb.") ? e : `fb.1.${Date.now()}.${e}`;
|
|
966
994
|
}
|
|
967
|
-
function
|
|
995
|
+
function xe(e) {
|
|
968
996
|
if (!e) return;
|
|
969
997
|
e = e.split("?")[0], e.includes("__DOT__") && (e = e.replaceAll("__DOT__", ".")), e = e.split("%")[0], e = e.split("&")[0];
|
|
970
998
|
let t = e.split("."), n = t.lastIndexOf("fb");
|
|
@@ -972,13 +1000,13 @@ function ve(e) {
|
|
|
972
1000
|
}
|
|
973
1001
|
//#endregion
|
|
974
1002
|
//#region src/conversion/conversionClient.ts
|
|
975
|
-
var
|
|
1003
|
+
var Se = 30, Ce = 200, we = 20, Te = class {
|
|
976
1004
|
constructor(e) {
|
|
977
1005
|
this.cfg = {
|
|
978
1006
|
...e,
|
|
979
1007
|
enabled: e.enabled ?? !0,
|
|
980
|
-
onError: e.onError ??
|
|
981
|
-
}, this.fetcher =
|
|
1008
|
+
onError: e.onError ?? te
|
|
1009
|
+
}, this.fetcher = pe({ baseUrl: e.url });
|
|
982
1010
|
}
|
|
983
1011
|
cfg;
|
|
984
1012
|
fetcher;
|
|
@@ -988,24 +1016,27 @@ var ye = 30, be = 200, xe = 20, Se = class {
|
|
|
988
1016
|
this.cfg.enabled && this.tryOrReport(() => this.captureClickIds(), void 0);
|
|
989
1017
|
}
|
|
990
1018
|
pageView(e, t = {}) {
|
|
991
|
-
if (!this.cfg.enabled) return;
|
|
1019
|
+
if (!this.cfg.enabled || !this.hasMarketingConsent(e)) return;
|
|
992
1020
|
let n = this.getAllowedPathname(e.pathname);
|
|
993
|
-
n !== null &&
|
|
1021
|
+
n !== null && m(this.send("p", {
|
|
994
1022
|
...e,
|
|
995
1023
|
pathname: n
|
|
996
1024
|
}, t));
|
|
997
1025
|
}
|
|
998
1026
|
purchase(e, t = {}) {
|
|
999
|
-
if (!this.cfg.enabled) return;
|
|
1027
|
+
if (!this.cfg.enabled || !this.hasMarketingConsent(e)) return;
|
|
1000
1028
|
let n = this.getAllowedPathname(e.pathname);
|
|
1001
|
-
n !== null &&
|
|
1029
|
+
n !== null && m(this.send("purchase", {
|
|
1002
1030
|
...e,
|
|
1003
1031
|
pathname: n
|
|
1004
1032
|
}, t));
|
|
1005
1033
|
}
|
|
1034
|
+
hasMarketingConsent(e) {
|
|
1035
|
+
return (e.marketingConsent ?? e.marketingCookie) === !0;
|
|
1036
|
+
}
|
|
1006
1037
|
getAllowedPathname(e) {
|
|
1007
|
-
let { href: t, origin: n } = globalThis.location, r =
|
|
1008
|
-
return r ?
|
|
1038
|
+
let { href: t, origin: n } = globalThis.location, r = ve.find((e) => t.startsWith(e)) || _e[n];
|
|
1039
|
+
return r ? ge[r].some((t) => e.includes(t)) ? null : e : null;
|
|
1009
1040
|
}
|
|
1010
1041
|
async send(e, t, n) {
|
|
1011
1042
|
try {
|
|
@@ -1022,32 +1053,32 @@ var ye = 30, be = 200, xe = 20, Se = class {
|
|
|
1022
1053
|
});
|
|
1023
1054
|
r.err && this.cfg.onError(r.err);
|
|
1024
1055
|
} catch (e) {
|
|
1025
|
-
this.cfg.onError(
|
|
1056
|
+
this.cfg.onError(D(e));
|
|
1026
1057
|
}
|
|
1027
1058
|
}
|
|
1028
1059
|
getHeaders(e) {
|
|
1029
1060
|
let t = String(this.cfg.clientId);
|
|
1030
|
-
return e.marketingConsent ? this.tryOrReport(() => (this.cfg.enabled && this.storeClickIds(),
|
|
1061
|
+
return e.marketingConsent ? this.tryOrReport(() => (this.cfg.enabled && this.storeClickIds(), ie({
|
|
1031
1062
|
clientId: t,
|
|
1032
|
-
fbc: Q.getCookie("_fbc") || $(Q.getCookie(
|
|
1063
|
+
fbc: Q.getCookie("_fbc") || $(Q.getCookie(Z.fbclid)),
|
|
1033
1064
|
fbp: Q.getCookie("_fbp"),
|
|
1034
|
-
scCid: Q.getCookie(
|
|
1035
|
-
ttclid: Q.getCookie(
|
|
1036
|
-
rdtCid: Q.getCookie(
|
|
1037
|
-
epik: Q.getCookie("_epik") || Q.getCookie(
|
|
1065
|
+
scCid: Q.getCookie(Z.ScCid),
|
|
1066
|
+
ttclid: Q.getCookie(Z.ttclid),
|
|
1067
|
+
rdtCid: Q.getCookie(Z.rdt_cid),
|
|
1068
|
+
epik: Q.getCookie("_epik") || Q.getCookie(Z.epik),
|
|
1038
1069
|
uuid_c1: Q.getCookie("_scid") || Q.getCookie("uuid_c1")
|
|
1039
1070
|
})), { clientId: t }) : { clientId: t };
|
|
1040
1071
|
}
|
|
1041
1072
|
storeClickIds() {
|
|
1042
1073
|
this.captureClickIds();
|
|
1043
|
-
for (let [e, t] of Object.entries(this.pendingClickIds)) Q.setCookie(e, t,
|
|
1074
|
+
for (let [e, t] of Object.entries(this.pendingClickIds)) Q.setCookie(e, t, Se, this.cfg.cookieDomain);
|
|
1044
1075
|
this.pendingClickIds = {};
|
|
1045
1076
|
}
|
|
1046
1077
|
tryOrReport(e, t) {
|
|
1047
1078
|
try {
|
|
1048
1079
|
return e();
|
|
1049
1080
|
} catch (e) {
|
|
1050
|
-
return this.cfg.onError(
|
|
1081
|
+
return this.cfg.onError(D(e)), t;
|
|
1051
1082
|
}
|
|
1052
1083
|
}
|
|
1053
1084
|
captureClickIds() {
|
|
@@ -1055,19 +1086,19 @@ var ye = 30, be = 200, xe = 20, Se = class {
|
|
|
1055
1086
|
if (e === this.lastCapturedHref) return;
|
|
1056
1087
|
this.lastCapturedHref = e;
|
|
1057
1088
|
let n = new URLSearchParams(t);
|
|
1058
|
-
for (let e of
|
|
1089
|
+
for (let e of ye) {
|
|
1059
1090
|
let t = n.get(e) || n.get(e.toLowerCase());
|
|
1060
1091
|
if (!t) continue;
|
|
1061
|
-
let r = e ===
|
|
1092
|
+
let r = e === Z.fbclid ? this.toFbc(t) : t.slice(0, Ce);
|
|
1062
1093
|
r && (this.pendingClickIds[e] = r);
|
|
1063
1094
|
}
|
|
1064
1095
|
}
|
|
1065
1096
|
toFbc(e) {
|
|
1066
|
-
let t =
|
|
1067
|
-
if (!(!t || t.length <
|
|
1097
|
+
let t = xe(e);
|
|
1098
|
+
if (!(!t || t.length < we) && !(this.pendingClickIds[Z.fbclid] || Q.getCookie(Z.fbclid))?.endsWith(`.${t}`)) return $(t);
|
|
1068
1099
|
}
|
|
1069
1100
|
};
|
|
1070
1101
|
//#endregion
|
|
1071
|
-
export {
|
|
1102
|
+
export { Te as ConversionClient, t as generateConversionEventId };
|
|
1072
1103
|
|
|
1073
1104
|
//# sourceMappingURL=conversionClient.js.map
|