@weaveui/web 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/LICENSE +35 -0
  2. package/README.md +119 -0
  3. package/THIRD_PARTY_NOTICES +29 -0
  4. package/dist/apm-log.es.js +996 -0
  5. package/dist/apm-log.umd.cjs +1 -0
  6. package/dist/business/apm-log/behavior-directive.d.ts +9 -0
  7. package/dist/business/apm-log/behavior-log.d.ts +6 -0
  8. package/dist/business/apm-log/behavior-types.d.ts +121 -0
  9. package/dist/business/apm-log/browser.d.ts +3 -0
  10. package/dist/business/apm-log/directive.d.ts +13 -0
  11. package/dist/business/apm-log/index.d.ts +8 -0
  12. package/dist/business/apm-log/legacy-apm-log.d.ts +6 -0
  13. package/dist/business/apm-log/types.d.ts +147 -0
  14. package/dist/business/apm-log/vue.d.ts +5 -0
  15. package/dist/business/monitor/index.d.ts +81 -0
  16. package/dist/business/monitor/monitor-plugin.d.ts +9 -0
  17. package/dist/business/monitor/runtime-types.d.ts +166 -0
  18. package/dist/business/monitor/runtime.d.ts +6 -0
  19. package/dist/business/monitor/types.d.ts +221 -0
  20. package/dist/business/permission/Permission.d.ts +18 -0
  21. package/dist/business/permission/PermissionPluginClass.d.ts +40 -0
  22. package/dist/business/permission/directive.d.ts +7 -0
  23. package/dist/business/permission/index.d.ts +35 -0
  24. package/dist/business/permission/permission-plugin.d.ts +16 -0
  25. package/dist/business/permission/storage.d.ts +30 -0
  26. package/dist/business/permission/tree.d.ts +19 -0
  27. package/dist/business/permission/types.d.ts +115 -0
  28. package/dist/business/upload-cos/index.d.ts +117 -0
  29. package/dist/business/upload-cos/src/UploadCos.vue.d.ts +70 -0
  30. package/dist/business/upload-cos/src/types.d.ts +72 -0
  31. package/dist/business/upload-cos/src/utils.d.ts +9 -0
  32. package/dist/index.d.ts +1894 -0
  33. package/dist/index.es.js +4315 -0
  34. package/dist/index.umd.cjs +6 -0
  35. package/dist/monitor.es.js +1217 -0
  36. package/dist/monitor.umd.cjs +1 -0
  37. package/dist/permission.es.js +631 -0
  38. package/dist/permission.umd.cjs +1 -0
  39. package/dist/style.css +1 -0
  40. package/dist/upload-cos.es.js +426 -0
  41. package/dist/upload-cos.style.css +1 -0
  42. package/dist/upload-cos.umd.cjs +1 -0
  43. package/dist/utils/index.d.ts +3 -0
  44. package/dist/utils/is.d.ts +2 -0
  45. package/dist/utils/withInstall.d.ts +7 -0
  46. package/package.json +105 -0
@@ -0,0 +1,996 @@
1
+ import "vue";
2
+ function bt() {
3
+ const t = globalThis.document;
4
+ return typeof (t == null ? void 0 : t.addEventListener) == "function" ? t : void 0;
5
+ }
6
+ function Dt(t) {
7
+ const e = globalThis.Element;
8
+ return typeof e < "u" && t instanceof e;
9
+ }
10
+ function lt(t) {
11
+ const e = globalThis.MouseEvent;
12
+ return typeof e < "u" && t instanceof e;
13
+ }
14
+ function rt(t) {
15
+ return t.tagName.toLowerCase();
16
+ }
17
+ function Ut(t, e) {
18
+ var u, s;
19
+ if (typeof t == "string") {
20
+ const g = t.trim();
21
+ return g ? {
22
+ type: "click",
23
+ properties: {
24
+ action: g,
25
+ element: rt(e)
26
+ }
27
+ } : void 0;
28
+ }
29
+ if (!t)
30
+ return;
31
+ const n = ((u = t.type) == null ? void 0 : u.trim()) || "click", c = {
32
+ element: rt(e),
33
+ ...t.properties
34
+ };
35
+ return (s = t.label) != null && s.trim() && (c.label = t.label.trim()), {
36
+ type: n,
37
+ properties: c,
38
+ context: t.context ? { ...t.context } : void 0
39
+ };
40
+ }
41
+ function ot(t) {
42
+ const e = /* @__PURE__ */ new WeakMap();
43
+ return {
44
+ mounted(n, c) {
45
+ const u = {
46
+ value: c.value,
47
+ listener: (s) => {
48
+ if (!lt(s))
49
+ return;
50
+ const g = Ut(u.value, n);
51
+ g && t.track(g);
52
+ }
53
+ };
54
+ n.addEventListener("click", u.listener), e.set(n, u);
55
+ },
56
+ updated(n, c) {
57
+ const u = e.get(n);
58
+ u && (u.value = c.value);
59
+ },
60
+ unmounted(n) {
61
+ const c = e.get(n);
62
+ c && (n.removeEventListener("click", c.listener), e.delete(n));
63
+ }
64
+ };
65
+ }
66
+ const Nt = Symbol(
67
+ "EasyOilBehaviorLog"
68
+ ), Pt = 100, kt = 2, wt = 1e3, Rt = "[data-behavior-log]", Tt = "behavior-log";
69
+ function O(t) {
70
+ return t ? { ...t } : {};
71
+ }
72
+ function At(t) {
73
+ return t ? { ...t } : void 0;
74
+ }
75
+ function xt(t, e) {
76
+ return !Number.isFinite(t) || !t || t < 1 ? e : Math.floor(t);
77
+ }
78
+ function It(t, e) {
79
+ return !Number.isFinite(t) || t === void 0 || t < 0 ? e : Math.floor(t);
80
+ }
81
+ function Ct(t) {
82
+ var n;
83
+ const e = (n = globalThis.crypto) == null ? void 0 : n.randomUUID;
84
+ return typeof e == "function" ? e.call(globalThis.crypto) : `eol_${Date.now().toString(36)}_${t.toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
85
+ }
86
+ function it(t) {
87
+ if (t.fullPath)
88
+ return t.fullPath;
89
+ if (t.path)
90
+ return t.path;
91
+ if (t.name !== null && t.name !== void 0)
92
+ return String(t.name);
93
+ }
94
+ function Lt(t) {
95
+ var s;
96
+ const e = (s = t.meta) == null ? void 0 : s.title, n = t.fullPath, c = n ? n.split(/[?#]/, 1)[0] : void 0, u = t.path || c;
97
+ return {
98
+ ...u ? { path: u } : {},
99
+ ...t.name !== null && t.name !== void 0 ? { name: String(t.name) } : {},
100
+ ...typeof e == "string" && e.trim() ? { title: e.trim() } : {}
101
+ };
102
+ }
103
+ function Ft(t) {
104
+ const e = t.currentRoute;
105
+ if (e)
106
+ return "value" in e ? e.value : e;
107
+ }
108
+ function _t(t, e) {
109
+ const n = it(t), c = it(e);
110
+ return !!(n && n === c);
111
+ }
112
+ function Mt(t) {
113
+ const e = xt(
114
+ t.maxQueueSize,
115
+ Pt
116
+ ), n = It(
117
+ t.maxRetries,
118
+ kt
119
+ ), c = t.dropStrategy ?? "oldest", u = [], s = /* @__PURE__ */ new WeakSet();
120
+ let g = 0, l = !1, f = !1, d, b, k, D, A, R, C;
121
+ function N(r, o) {
122
+ var a;
123
+ try {
124
+ (a = t.onError) == null || a.call(t, r, o);
125
+ } catch {
126
+ }
127
+ }
128
+ function T(r, o, a) {
129
+ var m;
130
+ try {
131
+ (m = t.onDrop) == null || m.call(t, r, { reason: o, error: a });
132
+ } catch {
133
+ }
134
+ }
135
+ function F(r) {
136
+ const o = u.indexOf(r);
137
+ o >= 0 && u.splice(o, 1);
138
+ }
139
+ function P() {
140
+ const r = u.findIndex((a) => a !== A);
141
+ if (r < 0)
142
+ return;
143
+ const [o] = u.splice(r, 1);
144
+ return o;
145
+ }
146
+ function K(r) {
147
+ if (u.length >= e) {
148
+ if (c === "newest")
149
+ return T(r, "queue-full"), !1;
150
+ const o = P();
151
+ if (!o)
152
+ return T(r, "queue-full"), !1;
153
+ T(o.event, "queue-full");
154
+ }
155
+ return u.push({ event: r, attempts: 0 }), !0;
156
+ }
157
+ function H(r, o) {
158
+ try {
159
+ const a = typeof t.retryDelay == "function" ? t.retryDelay(r, o) : t.retryDelay;
160
+ if (typeof a == "number" && Number.isFinite(a) && a >= 0)
161
+ return a;
162
+ } catch (a) {
163
+ N(a, { stage: "transport", attempt: r });
164
+ }
165
+ return wt;
166
+ }
167
+ function j(r, o) {
168
+ b || f || !l || (b = globalThis.setTimeout(() => {
169
+ b = void 0, y();
170
+ }, H(r, o)));
171
+ }
172
+ async function _(r) {
173
+ let o, a;
174
+ if (t.getSessionId)
175
+ try {
176
+ o = await t.getSessionId() || void 0;
177
+ } catch (m) {
178
+ return { ok: !1, error: m, stage: "session-context" };
179
+ }
180
+ if (t.getUserContext)
181
+ try {
182
+ a = At(await t.getUserContext());
183
+ } catch (m) {
184
+ return { ok: !1, error: m, stage: "user-context" };
185
+ }
186
+ return {
187
+ ok: !0,
188
+ event: {
189
+ ...r,
190
+ properties: O(r.properties),
191
+ ...r.context ? { context: O(r.context) } : {},
192
+ ...o ? { sessionId: o } : {},
193
+ ...a ? { user: a } : {}
194
+ }
195
+ };
196
+ }
197
+ async function i(r) {
198
+ const o = await _(r.event);
199
+ if (!o.ok)
200
+ return o;
201
+ if (f || !l)
202
+ return {
203
+ ok: !1,
204
+ error: new Error("Behavior log was stopped before delivery."),
205
+ stage: "transport"
206
+ };
207
+ try {
208
+ return await t.transport(o.event), { ok: !0 };
209
+ } catch (a) {
210
+ return { ok: !1, error: a, stage: "transport" };
211
+ }
212
+ }
213
+ async function p() {
214
+ for (; l && !f; ) {
215
+ const r = u[0];
216
+ if (!r)
217
+ return;
218
+ A = r;
219
+ const o = await i(r);
220
+ if (A === r && (A = void 0), f || !l)
221
+ return;
222
+ if (o.ok) {
223
+ F(r);
224
+ continue;
225
+ }
226
+ if (u.includes(r)) {
227
+ if (r.attempts += 1, N(o.error, {
228
+ stage: o.stage,
229
+ event: r.event,
230
+ attempt: r.attempts
231
+ }), r.attempts > n) {
232
+ F(r), T(r.event, "transport-failed", o.error);
233
+ continue;
234
+ }
235
+ j(r.attempts, o.error);
236
+ return;
237
+ }
238
+ }
239
+ }
240
+ function y() {
241
+ if (f || !l)
242
+ return Promise.resolve();
243
+ if (d)
244
+ return d;
245
+ b && (globalThis.clearTimeout(b), b = void 0);
246
+ const r = p().catch((o) => {
247
+ N(o, { stage: "transport" });
248
+ }).finally(() => {
249
+ d === r && (d = void 0, E());
250
+ });
251
+ return d = r, r;
252
+ }
253
+ function E() {
254
+ f || !l || !u.length || d || b || y();
255
+ }
256
+ function v(r, o) {
257
+ if (o.resolveRoute)
258
+ try {
259
+ const a = o.resolveRoute(r);
260
+ if (a)
261
+ return { ...a };
262
+ } catch (a) {
263
+ N(a, { stage: "router" });
264
+ }
265
+ return Lt(r);
266
+ }
267
+ function S(r, o, a) {
268
+ z({
269
+ type: "page_enter",
270
+ properties: {
271
+ page: v(r, a),
272
+ ...o ? { from: v(o, a) } : {}
273
+ }
274
+ }), R = r, C = Date.now();
275
+ }
276
+ function U(r, o, a, m) {
277
+ if (a || f || !l)
278
+ return;
279
+ const h = R ?? o;
280
+ h && !m.includeSameRoute && _t(h, r) || (R && C !== void 0 && z({
281
+ type: "page_leave",
282
+ properties: {
283
+ page: v(R, m),
284
+ to: v(r, m),
285
+ durationMs: Math.max(0, Date.now() - C)
286
+ }
287
+ }), S(r, h, m));
288
+ }
289
+ function X() {
290
+ const r = t.router, o = t.routeTracking;
291
+ if (!r || o === !1)
292
+ return;
293
+ const a = o ?? {};
294
+ try {
295
+ const m = r.afterEach((h, x, q) => {
296
+ U(h, x, q, a);
297
+ });
298
+ if (typeof m == "function" && (k = m), a.trackInitialRoute) {
299
+ const h = Ft(r);
300
+ h && S(h, void 0, a);
301
+ }
302
+ } catch (m) {
303
+ N(m, { stage: "router" });
304
+ }
305
+ }
306
+ function yt(r) {
307
+ var m, h;
308
+ const o = ((m = r.getAttribute("data-behavior-log")) == null ? void 0 : m.trim()) || "click", a = (h = r.getAttribute("data-behavior-log-label")) == null ? void 0 : h.trim();
309
+ return {
310
+ type: "click",
311
+ properties: {
312
+ action: o,
313
+ element: r.tagName.toLowerCase(),
314
+ ...a ? { label: a } : {}
315
+ }
316
+ };
317
+ }
318
+ function vt(r, o) {
319
+ if (Dt(r.target))
320
+ return r.target.closest(o) ?? void 0;
321
+ }
322
+ function ht() {
323
+ const r = t.clickTracking;
324
+ if (!r)
325
+ return;
326
+ const o = r.root ?? bt();
327
+ if (!o)
328
+ return;
329
+ const a = r.selector ?? Rt, m = (h) => {
330
+ if (!(!lt(h) || f || !l))
331
+ try {
332
+ const x = vt(h, a);
333
+ if (!x)
334
+ return;
335
+ const q = r.getPayload ? r.getPayload(h, x) : yt(x);
336
+ q && z(q);
337
+ } catch (x) {
338
+ N(x, { stage: "click-tracking" });
339
+ }
340
+ };
341
+ try {
342
+ o.addEventListener("click", m), D = () => o.removeEventListener("click", m);
343
+ } catch (h) {
344
+ N(h, { stage: "click-tracking" });
345
+ }
346
+ }
347
+ function nt() {
348
+ return f ? !1 : (l || (l = !0, X(), ht(), E()), !0);
349
+ }
350
+ function z(r, o) {
351
+ if (!l || f)
352
+ return;
353
+ const a = typeof r == "string" ? { type: r, properties: o } : r, m = a.type.trim();
354
+ if (!m)
355
+ return;
356
+ g += 1;
357
+ const h = {
358
+ id: Ct(g),
359
+ type: m,
360
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
361
+ properties: O(a.properties),
362
+ ...a.context ? { context: O(a.context) } : {}
363
+ };
364
+ if (K(h))
365
+ return E(), h;
366
+ }
367
+ function Et(r) {
368
+ if (s.has(r))
369
+ return;
370
+ s.add(r), r.provide(Nt, $);
371
+ const o = t.directiveName === void 0 ? Tt : t.directiveName;
372
+ o && r.directive(o, ot($)), nt();
373
+ }
374
+ function St() {
375
+ if (f)
376
+ return;
377
+ f = !0, l = !1, b && (globalThis.clearTimeout(b), b = void 0);
378
+ const r = k;
379
+ k = void 0;
380
+ const o = D;
381
+ D = void 0;
382
+ try {
383
+ r == null || r();
384
+ } catch (a) {
385
+ N(a, { stage: "router" });
386
+ }
387
+ try {
388
+ o == null || o();
389
+ } catch (a) {
390
+ N(a, { stage: "click-tracking" });
391
+ }
392
+ for (; u.length; ) {
393
+ const a = u.shift();
394
+ a && T(a.event, "destroyed");
395
+ }
396
+ }
397
+ const $ = {
398
+ get isStarted() {
399
+ return l;
400
+ },
401
+ get isDestroyed() {
402
+ return f;
403
+ },
404
+ install: Et,
405
+ start: nt,
406
+ track: z,
407
+ flush: y,
408
+ createClickDirective: () => ot($),
409
+ destroy: St
410
+ };
411
+ return $;
412
+ }
413
+ function W(t) {
414
+ if (t == null || t === "")
415
+ return null;
416
+ try {
417
+ return String(t);
418
+ } catch {
419
+ return null;
420
+ }
421
+ }
422
+ function Bt(t, e) {
423
+ return typeof e == "string" ? W(e) : (e == null ? void 0 : e.buttonName) !== void 0 ? W(e.buttonName) : W(t.innerText || t.textContent || void 0);
424
+ }
425
+ function zt(t, e) {
426
+ return typeof t != "string" && (t == null ? void 0 : t.pageName) !== void 0 ? W(t.pageName) : e.pageName;
427
+ }
428
+ function $t(t, e) {
429
+ const n = /* @__PURE__ */ new WeakMap();
430
+ return {
431
+ mounted(c, u) {
432
+ const s = {
433
+ value: u.value,
434
+ listener: () => {
435
+ try {
436
+ const g = e();
437
+ t.addTask("ClickButton", {
438
+ fromUrl: null,
439
+ fromPage: null,
440
+ toUrl: null,
441
+ toPage: null,
442
+ pageName: zt(s.value, g),
443
+ buttonName: Bt(c, s.value),
444
+ stopDuration: null,
445
+ systemStopDuration: null
446
+ });
447
+ } catch {
448
+ }
449
+ }
450
+ };
451
+ c.addEventListener("click", s.listener), n.set(c, s);
452
+ },
453
+ updated(c, u) {
454
+ const s = n.get(c);
455
+ s && (s.value = u.value);
456
+ },
457
+ unmounted(c) {
458
+ const u = n.get(c);
459
+ u && (c.removeEventListener("click", u.listener), n.delete(c));
460
+ }
461
+ };
462
+ }
463
+ const ft = "v1.0.0", tt = "6cff83cad70a55a7cfd197e1f29ff0d6", at = "9e09e21609f011ce6eab6effd527bc63", Y = "4bcbb789845ec91c1fb804235a797e0a";
464
+ function B() {
465
+ return typeof globalThis.window < "u" && typeof globalThis.document < "u";
466
+ }
467
+ function dt() {
468
+ return B() ? globalThis.window : void 0;
469
+ }
470
+ function gt() {
471
+ const t = dt();
472
+ if (t)
473
+ try {
474
+ return t.sessionStorage;
475
+ } catch {
476
+ return;
477
+ }
478
+ }
479
+ function et(t) {
480
+ var e;
481
+ try {
482
+ return ((e = gt()) == null ? void 0 : e.getItem(t)) || void 0;
483
+ } catch {
484
+ return;
485
+ }
486
+ }
487
+ function M(t, e) {
488
+ var n;
489
+ try {
490
+ (n = gt()) == null || n.setItem(t, e);
491
+ } catch {
492
+ }
493
+ }
494
+ function ct(t) {
495
+ const e = Number(et(t));
496
+ return Number.isFinite(e) && e > 0 ? e : void 0;
497
+ }
498
+ function qt() {
499
+ var e;
500
+ const t = (e = globalThis.crypto) == null ? void 0 : e.randomUUID;
501
+ return typeof t == "function" ? t.call(globalThis.crypto) : `eol_legacy_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 12)}`;
502
+ }
503
+ function J() {
504
+ if (!B())
505
+ return;
506
+ const t = et(tt);
507
+ if (t)
508
+ return t;
509
+ const e = qt();
510
+ return M(tt, e), e;
511
+ }
512
+ function w(t) {
513
+ if (t == null)
514
+ return "";
515
+ try {
516
+ return String(t);
517
+ } catch {
518
+ return "";
519
+ }
520
+ }
521
+ function L(t) {
522
+ if (t !== void 0)
523
+ return t === null ? null : w(t);
524
+ }
525
+ function I(t) {
526
+ return t && w(t) || null;
527
+ }
528
+ function mt(t) {
529
+ return typeof t != "string" ? void 0 : t.trim() || void 0;
530
+ }
531
+ function pt(t) {
532
+ return typeof t == "number" && Number.isFinite(t) && t !== 0 ? t : null;
533
+ }
534
+ function Ot(t = /* @__PURE__ */ new Date()) {
535
+ const e = t.getFullYear(), n = t.getMonth() + 1, c = String(t.getDate()).padStart(2, "0"), u = String(t.getHours()).padStart(2, "0"), s = String(t.getMinutes()).padStart(2, "0"), g = String(t.getSeconds()).padStart(2, "0");
536
+ return `${e}-${n}-${c} ${u}:${s}:${g}`;
537
+ }
538
+ function Yt() {
539
+ var e;
540
+ const t = {
541
+ deviceSystem: "unknow",
542
+ deviceModel: "web",
543
+ deviceSystemVersion: "unknow",
544
+ browser: "unknow"
545
+ };
546
+ if (!B())
547
+ return t;
548
+ try {
549
+ const n = globalThis.navigator, c = n.userAgent || "", s = ((e = n.userAgentData) == null ? void 0 : e.platform) || n.platform || "unknow", g = /Android|webOS|iPhone|iPod|BlackBerry/i.test(c) ? "phone" : "web";
550
+ let l = "unknow", f = "unknow";
551
+ if (c.includes("Chrome")) {
552
+ const d = c.match(/Chrome\/([\d.]+)/);
553
+ l = (d == null ? void 0 : d[1]) || "unknow", f = (d == null ? void 0 : d[0]) || "Chrome";
554
+ } else if (c.includes("Safari")) {
555
+ const d = c.match(/Version\/([\d.]+)/);
556
+ l = (d == null ? void 0 : d[1]) || "unknow", f = "Safari";
557
+ } else if (c.includes("Firefox")) {
558
+ const d = c.match(/Firefox\/([\d.]+)/);
559
+ l = (d == null ? void 0 : d[1]) || "unknow", f = (d == null ? void 0 : d[0]) || "unknow";
560
+ }
561
+ return {
562
+ deviceSystem: s,
563
+ deviceModel: g,
564
+ deviceSystemVersion: l,
565
+ browser: f
566
+ };
567
+ } catch {
568
+ return t;
569
+ }
570
+ }
571
+ function Vt(t) {
572
+ const e = t.trim();
573
+ if (e)
574
+ return `${e.replace(/\/+$/, "")}/frontEndLog/add`;
575
+ }
576
+ function Wt(t) {
577
+ return {
578
+ "Content-Type": "application/json",
579
+ x_app_channel_id: w(t.appChannelId),
580
+ x_data_channel_id: w(t.dataChannelId)
581
+ };
582
+ }
583
+ function G(t) {
584
+ return typeof t == "object" && t !== null && !Array.isArray(t);
585
+ }
586
+ function Gt(t, e) {
587
+ const n = t.action;
588
+ if (!G(n))
589
+ return {
590
+ type: e,
591
+ fromPage: null,
592
+ pageName: null,
593
+ buttonName: null,
594
+ stopDuration: null
595
+ };
596
+ const c = mt(n.type) || e, u = L(n.fromUrl), s = L(n.toUrl), g = L(n.toPage), l = n.systemStopDuration, f = {
597
+ type: c,
598
+ fromPage: I(n.fromPage),
599
+ pageName: I(n.pageName),
600
+ buttonName: I(n.buttonName),
601
+ stopDuration: pt(n.stopDuration)
602
+ };
603
+ return u !== void 0 && (f.fromUrl = u), s !== void 0 && (f.toUrl = s), g !== void 0 && (f.toPage = g), (l === null || typeof l == "number" && Number.isFinite(l)) && (f.systemStopDuration = l), f;
604
+ }
605
+ function Qt(t) {
606
+ return {
607
+ account: w(t == null ? void 0 : t.account),
608
+ nickName: w(t == null ? void 0 : t.nickName)
609
+ };
610
+ }
611
+ function Kt(t) {
612
+ if (t)
613
+ try {
614
+ Promise.resolve(t()).catch(() => {
615
+ });
616
+ } catch {
617
+ }
618
+ }
619
+ function Ht(t, e) {
620
+ if (t)
621
+ try {
622
+ Promise.resolve(t(e)).catch(() => {
623
+ });
624
+ } catch {
625
+ }
626
+ }
627
+ async function ut(t) {
628
+ if (!t)
629
+ return "";
630
+ try {
631
+ return w(await t());
632
+ } catch {
633
+ return "";
634
+ }
635
+ }
636
+ async function jt(t) {
637
+ const [e, n] = await Promise.all([
638
+ ut(t.getAccountFn),
639
+ ut(t.getNickNameFn)
640
+ ]);
641
+ return { account: e, nickName: n };
642
+ }
643
+ function Xt(t, e) {
644
+ try {
645
+ return typeof t == "string" ? t === e : t instanceof RegExp ? (t.lastIndex = 0, t.test(e)) : t(e);
646
+ } catch {
647
+ return !1;
648
+ }
649
+ }
650
+ function Jt(t, e) {
651
+ if (!t || t.mode !== "match" && t.mode !== "ignore")
652
+ return !1;
653
+ const c = (Array.isArray(t.rules) ? t.rules : [t.rules]).some((u) => Xt(u, e));
654
+ return t.mode === "ignore" ? c : !c;
655
+ }
656
+ function Q(t) {
657
+ return t && (t.fullPath || t.path) || null;
658
+ }
659
+ function Zt(t) {
660
+ return (t == null ? void 0 : t.path) || Q(t);
661
+ }
662
+ function Z(t) {
663
+ var n;
664
+ if (!t)
665
+ return null;
666
+ const e = (n = t.meta) == null ? void 0 : n.title;
667
+ return typeof e == "string" || typeof e == "number" ? I(e) : typeof t.name == "string" || typeof t.name == "number" || typeof t.name == "symbol" ? w(t.name) : null;
668
+ }
669
+ function te(t) {
670
+ const e = t == null ? void 0 : t.currentRoute;
671
+ if (e)
672
+ return "value" in e ? e.value : e;
673
+ }
674
+ function V(t, e) {
675
+ return t === void 0 ? null : Math.max(0, e - t);
676
+ }
677
+ function ee(t, e, n) {
678
+ const c = L(e.fromUrl), u = L(e.toUrl), s = L(e.toPage), g = I(e.pageName);
679
+ g && (n.currentPageName = g);
680
+ const l = {
681
+ type: t,
682
+ fromPage: I(e.fromPage),
683
+ pageName: g || n.currentPageName || null,
684
+ buttonName: I(e.buttonName),
685
+ stopDuration: pt(e.stopDuration)
686
+ };
687
+ return c !== void 0 && (l.fromUrl = c), u !== void 0 && (l.toUrl = u), s !== void 0 && (l.toPage = s), e.systemStopDuration !== void 0 && (l.systemStopDuration = e.systemStopDuration), l;
688
+ }
689
+ function ne(t) {
690
+ const e = G(t) ? t : {}, n = typeof e.version == "string" && e.version.trim() ? e.version.trim() : ft;
691
+ return {
692
+ envUrl: typeof e.envUrl == "string" ? e.envUrl : "",
693
+ ...typeof e.appChannelId == "string" || typeof e.appChannelId == "number" || e.appChannelId === null ? { appChannelId: e.appChannelId } : {},
694
+ ...typeof e.dataChannelId == "string" || typeof e.dataChannelId == "number" || e.dataChannelId === null ? { dataChannelId: e.dataChannelId } : {},
695
+ ...G(e.router) ? { router: e.router } : {},
696
+ ...typeof e.getAccountFn == "function" ? { getAccountFn: e.getAccountFn } : {},
697
+ ...typeof e.getNickNameFn == "function" ? { getNickNameFn: e.getNickNameFn } : {},
698
+ ...G(e.pageFilter) ? { pageFilter: e.pageFilter } : {},
699
+ ...typeof e.success == "function" ? { success: e.success } : {},
700
+ ...typeof e.failed == "function" ? { failed: e.failed } : {},
701
+ version: n
702
+ };
703
+ }
704
+ function re(t) {
705
+ const e = ne(t), n = {
706
+ currentRouteUrl: null,
707
+ currentPageName: null,
708
+ systemEnteredAt: void 0,
709
+ pageEnteredAt: void 0
710
+ }, c = Yt(), u = /* @__PURE__ */ new WeakSet();
711
+ let s = !1, g = !1, l, f = !1, d, b;
712
+ const k = Mt({
713
+ directiveName: !1,
714
+ maxRetries: 0,
715
+ getSessionId: () => J(),
716
+ getUserContext: () => jt(e),
717
+ transport: async (i) => {
718
+ if (!B())
719
+ return;
720
+ const p = Vt(e.envUrl);
721
+ if (!p)
722
+ throw new Error("Legacy apm-log requires a non-empty envUrl.");
723
+ if (typeof globalThis.fetch != "function")
724
+ throw new Error("The browser Fetch API is unavailable.");
725
+ const y = Gt(i.properties, i.type), E = Qt(i.user), v = {
726
+ sessionId: i.sessionId || J() || null,
727
+ account: E.account,
728
+ nickName: E.nickName,
729
+ deviceInfo: { ...c },
730
+ action: y,
731
+ version: e.version || ft,
732
+ time: Ot()
733
+ }, S = await globalThis.fetch(p, {
734
+ method: "POST",
735
+ headers: Wt(e),
736
+ body: JSON.stringify(v)
737
+ });
738
+ if (!S.ok)
739
+ throw new Error(`Legacy apm-log request failed with HTTP ${S.status}.`);
740
+ Kt(e.success);
741
+ },
742
+ onDrop: (i, p) => {
743
+ p.reason === "transport-failed" && Ht(e.failed, p.error);
744
+ }
745
+ });
746
+ function D(i, p = {}) {
747
+ if (s)
748
+ return;
749
+ const y = mt(i);
750
+ if (!y)
751
+ return;
752
+ const E = w(p.toUrl), v = p.filter || e.pageFilter;
753
+ if (Jt(v, E))
754
+ return;
755
+ const S = ee(y, p, n);
756
+ return k.track({
757
+ type: y,
758
+ properties: { action: S }
759
+ });
760
+ }
761
+ function A(i, p) {
762
+ if (s)
763
+ return;
764
+ const y = Date.now(), E = Q(p) || n.currentRouteUrl, v = Z(p) || n.currentPageName, S = Q(i), U = Z(i), X = !!et(tt);
765
+ J(), n.systemEnteredAt === void 0 && (n.systemEnteredAt = ct(at) || y), n.pageEnteredAt === void 0 && (n.pageEnteredAt = ct(Y) || y), X ? n.currentRouteUrl ? (D("EnterPage", {
766
+ fromUrl: E,
767
+ fromPage: v,
768
+ toUrl: S,
769
+ toPage: U,
770
+ pageName: U,
771
+ stopDuration: null,
772
+ systemStopDuration: null
773
+ }), D("LeavePage", {
774
+ fromUrl: E,
775
+ fromPage: v,
776
+ toUrl: S,
777
+ toPage: U,
778
+ pageName: U,
779
+ stopDuration: V(n.pageEnteredAt, y),
780
+ systemStopDuration: V(n.systemEnteredAt, y)
781
+ }), n.pageEnteredAt = y, M(Y, String(y))) : (D("EnterPage", {
782
+ fromUrl: E,
783
+ fromPage: v,
784
+ toUrl: S,
785
+ toPage: U,
786
+ pageName: U,
787
+ stopDuration: null,
788
+ systemStopDuration: null
789
+ }), n.pageEnteredAt = y, M(Y, String(y))) : (n.systemEnteredAt = y, n.pageEnteredAt = y, M(at, String(y)), M(Y, String(y)), D("EnterSystem", {
790
+ fromUrl: E,
791
+ fromPage: null,
792
+ toUrl: S,
793
+ toPage: U,
794
+ pageName: U,
795
+ stopDuration: null,
796
+ systemStopDuration: null
797
+ }), D("EnterPage", {
798
+ fromUrl: E,
799
+ fromPage: v,
800
+ toUrl: S,
801
+ toPage: U,
802
+ pageName: U,
803
+ stopDuration: null,
804
+ systemStopDuration: null
805
+ })), n.currentRouteUrl = Zt(i), n.currentPageName = U;
806
+ }
807
+ function R(i) {
808
+ var E;
809
+ if (!i || !B() || f)
810
+ return;
811
+ l = i;
812
+ const p = (v, S) => {
813
+ try {
814
+ A(v, S);
815
+ } catch {
816
+ }
817
+ }, y = (v, S, U) => {
818
+ if (!U)
819
+ try {
820
+ A(v, S);
821
+ } catch {
822
+ }
823
+ };
824
+ try {
825
+ const v = i.beforeEach ? i.beforeEach(p) : (E = i.afterEach) == null ? void 0 : E.call(i, y);
826
+ typeof v == "function" && (d = v), f = !0;
827
+ } catch {
828
+ l = void 0;
829
+ }
830
+ }
831
+ function C() {
832
+ s || (D("LeavePage", {
833
+ fromUrl: null,
834
+ fromPage: n.currentRouteUrl,
835
+ toUrl: null,
836
+ toPage: null,
837
+ pageName: null,
838
+ buttonName: null,
839
+ stopDuration: null,
840
+ systemStopDuration: null
841
+ }), D("LeaveSystem", {
842
+ fromUrl: null,
843
+ fromPage: n.currentRouteUrl,
844
+ toUrl: null,
845
+ toPage: null,
846
+ pageName: null,
847
+ buttonName: null,
848
+ stopDuration: null,
849
+ systemStopDuration: null
850
+ }));
851
+ }
852
+ function N() {
853
+ if (s)
854
+ return;
855
+ const i = Date.now();
856
+ D("LeavePage", {
857
+ fromUrl: n.currentRouteUrl,
858
+ fromPage: n.currentPageName,
859
+ toUrl: "",
860
+ toPage: "",
861
+ pageName: "",
862
+ buttonName: null,
863
+ stopDuration: V(n.pageEnteredAt, i),
864
+ systemStopDuration: null
865
+ }), D("LeaveSystem", {
866
+ fromUrl: n.currentRouteUrl,
867
+ fromPage: n.currentPageName,
868
+ toUrl: "",
869
+ toPage: "",
870
+ pageName: "",
871
+ buttonName: null,
872
+ stopDuration: null,
873
+ systemStopDuration: V(n.systemEnteredAt, i)
874
+ });
875
+ }
876
+ function T() {
877
+ const i = dt();
878
+ if (!i || b)
879
+ return;
880
+ const p = () => {
881
+ try {
882
+ N();
883
+ } catch {
884
+ }
885
+ };
886
+ try {
887
+ i.addEventListener("beforeunload", p), b = () => i.removeEventListener("beforeunload", p);
888
+ } catch {
889
+ }
890
+ }
891
+ function F(i, p) {
892
+ D("ClickButton", {
893
+ fromUrl: null,
894
+ fromPage: null,
895
+ toUrl: null,
896
+ toPage: null,
897
+ pageName: i || n.currentPageName,
898
+ buttonName: p,
899
+ stopDuration: null,
900
+ systemStopDuration: null
901
+ });
902
+ }
903
+ const P = {
904
+ get isInitialized() {
905
+ return g && !s;
906
+ },
907
+ init(i) {
908
+ return s || (R(i || l || e.router), T(), g = !0), P;
909
+ },
910
+ initRouter(i) {
911
+ return s || (R(i || l || e.router), g = !0), P;
912
+ },
913
+ initUniRouter() {
914
+ return P;
915
+ },
916
+ mountBtnFunction() {
917
+ },
918
+ mountExitSystemFunction() {
919
+ },
920
+ addListener() {
921
+ return s || (T(), g = !0), P;
922
+ },
923
+ addRouterListener() {
924
+ return s || (R(l || e.router), g = !0), P;
925
+ }
926
+ };
927
+ function K() {
928
+ return $t(_, () => {
929
+ const i = te(l || e.router);
930
+ return {
931
+ pageName: Z(i) || n.currentPageName,
932
+ routeUrl: Q(i) || n.currentRouteUrl
933
+ };
934
+ });
935
+ }
936
+ function H(i) {
937
+ if (!(s || u.has(i))) {
938
+ u.add(i);
939
+ try {
940
+ k.install(i);
941
+ } catch {
942
+ }
943
+ try {
944
+ i.directive("BtnLog", K());
945
+ } catch {
946
+ }
947
+ try {
948
+ i.config.globalProperties.LogClass = _, i.config.globalProperties.MixinClass = P, i.config.globalProperties.$btnLog = F, i.config.globalProperties.$exitSystem = C;
949
+ } catch {
950
+ }
951
+ P.init(e.router);
952
+ }
953
+ }
954
+ function j() {
955
+ if (s)
956
+ return;
957
+ s = !0;
958
+ const i = d, p = b;
959
+ d = void 0, b = void 0, f = !1, l = void 0;
960
+ try {
961
+ i == null || i();
962
+ } catch {
963
+ }
964
+ try {
965
+ p == null || p();
966
+ } catch {
967
+ }
968
+ k.destroy();
969
+ }
970
+ const _ = {
971
+ behaviorLog: k,
972
+ mixinClass: P,
973
+ options: e,
974
+ get isDestroyed() {
975
+ return s;
976
+ },
977
+ install: H,
978
+ addTask: D,
979
+ btnLog: F,
980
+ exitSystem: C,
981
+ flush: () => k.flush(),
982
+ destroy: j
983
+ };
984
+ return _;
985
+ }
986
+ const st = /* @__PURE__ */ new WeakMap(), ie = {
987
+ install(t, e) {
988
+ if (st.get(t))
989
+ return;
990
+ const c = re(e);
991
+ st.set(t, c), c.install(t);
992
+ }
993
+ };
994
+ export {
995
+ ie as default
996
+ };