@ibdop/platform-kit 1.0.9 → 1.0.11

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/index.mjs ADDED
@@ -0,0 +1,1784 @@
1
+ import Ze, { useState as R, useRef as Dt, useCallback as k, useEffect as V, useMemo as Ge, Component as $t, createContext as Lt, useContext as Ut } from "react";
2
+ import Vt from "axios";
3
+ const Ye = {
4
+ log: (...t) => {
5
+ },
6
+ warn: (...t) => {
7
+ }
8
+ };
9
+ function he() {
10
+ if (typeof window > "u") return null;
11
+ const t = window;
12
+ if (t.__SHELL_AUTH_INSTANCE__)
13
+ return t.__SHELL_AUTH_INSTANCE__;
14
+ const r = window;
15
+ return r.__SHELL_AUTH__?.authInstance ? r.__SHELL_AUTH__.authInstance : null;
16
+ }
17
+ function ne() {
18
+ const [t, r] = R(null), [o, u] = R(!0), a = Dt(0), d = 20, s = k(() => he(), []);
19
+ V(() => {
20
+ const E = s();
21
+ if (E) {
22
+ r(E), u(!1);
23
+ return;
24
+ }
25
+ const l = (c) => {
26
+ r(c.detail), u(!1);
27
+ }, m = setInterval(() => {
28
+ a.current++;
29
+ const c = s();
30
+ c ? (Ye.log("Auth found via polling, attempts:", a.current), r(c), u(!1), clearInterval(m)) : a.current >= d && (u(!1), clearInterval(m));
31
+ }, 500);
32
+ return window.addEventListener("shell-auth-ready", l), () => {
33
+ clearInterval(m), window.removeEventListener("shell-auth-ready", l);
34
+ };
35
+ }, [s]);
36
+ const f = t || {
37
+ user: null,
38
+ isAuthenticated: !1,
39
+ isLoading: o,
40
+ signinRedirect: async () => {
41
+ const E = he();
42
+ E?.signinRedirect ? await E.signinRedirect() : typeof window < "u" && (window.location.href = "/");
43
+ },
44
+ removeUser: async () => {
45
+ const E = he();
46
+ E?.removeUser && await E.removeUser();
47
+ }
48
+ };
49
+ return Ye.log("Auth result:", { isAuthenticated: f.isAuthenticated, isLoading: f.isLoading }), f;
50
+ }
51
+ const Bt = {
52
+ log: (...t) => {
53
+ },
54
+ warn: (...t) => {
55
+ },
56
+ error: (...t) => {
57
+ console.error("[useInfoData]", ...t);
58
+ }
59
+ };
60
+ function Ht(t) {
61
+ if (t) return t;
62
+ if (typeof window < "u") {
63
+ const r = window;
64
+ if (r.__MF_NAME__) return r.__MF_NAME__;
65
+ }
66
+ return "unknown-mfe";
67
+ }
68
+ function zt(t) {
69
+ const [r, o] = R(null), [u, a] = R(!0), [d, s] = R(null), x = k(() => {
70
+ const E = Ht(t?.mfeName).replace("@ib-dop/", "");
71
+ a(!0), s(null), fetch(`/svc/${E}/info.json`).then((l) => {
72
+ if (!l.ok)
73
+ throw new Error(`HTTP ${l.status}: ${l.statusText}`);
74
+ return l.json();
75
+ }).then((l) => {
76
+ o(l);
77
+ }).catch((l) => {
78
+ Bt.error("Failed to load info:", l), s(l instanceof Error ? l.message : String(l));
79
+ }).finally(() => {
80
+ a(!1);
81
+ });
82
+ }, [t?.mfeName]);
83
+ return V(() => {
84
+ x();
85
+ }, [x]), {
86
+ data: r,
87
+ isLoading: u,
88
+ error: d,
89
+ refetch: x
90
+ };
91
+ }
92
+ const ge = {
93
+ log: (...t) => {
94
+ },
95
+ warn: (...t) => {
96
+ },
97
+ error: (...t) => {
98
+ console.error("[useV1Config]", ...t);
99
+ }
100
+ }, ee = {
101
+ authority: "",
102
+ client_id: "",
103
+ environment: "development"
104
+ };
105
+ function ar() {
106
+ const [t, r] = R(null), [o, u] = R(!0), [a, d] = R(null);
107
+ return V(() => {
108
+ (() => {
109
+ if (typeof sessionStorage > "u") {
110
+ d("sessionStorage not available"), r(ee), u(!1);
111
+ return;
112
+ }
113
+ try {
114
+ const x = sessionStorage.getItem("config");
115
+ if (x) {
116
+ const f = JSON.parse(x);
117
+ r({ ...ee, ...f }), d(null), ge.log("Config loaded successfully");
118
+ } else
119
+ r(ee), d("Config not found in sessionStorage"), ge.warn("Config not found in sessionStorage");
120
+ } catch (x) {
121
+ ge.error("Error parsing config:", x), r(ee), d("Error parsing config");
122
+ } finally {
123
+ u(!1);
124
+ }
125
+ })();
126
+ }, []), {
127
+ data: t,
128
+ isLoading: o,
129
+ error: a
130
+ };
131
+ }
132
+ function Qe(t) {
133
+ if (typeof window > "u") return;
134
+ const r = window.__MF_NAME__ || "unknown", o = {
135
+ ...t,
136
+ mfeName: r,
137
+ timestamp: Date.now()
138
+ };
139
+ window.dispatchEvent(new CustomEvent("mfe-notification", {
140
+ detail: o,
141
+ bubbles: !0
142
+ }));
143
+ }
144
+ function Je(t, r) {
145
+ const o = {
146
+ network: {
147
+ title: "Нет подключения",
148
+ message: "Сервер недоступен. Проверьте подключение к интернету."
149
+ },
150
+ unauthorized: {
151
+ title: "Требуется вход",
152
+ message: "Ваша сессия истекла. Войдите в систему снова."
153
+ },
154
+ forbidden: {
155
+ title: "Доступ запрещён",
156
+ message: "У вас нет прав для выполнения этого действия."
157
+ },
158
+ not_found: {
159
+ title: "Не найдено",
160
+ message: "Запрошенный ресурс не найден."
161
+ },
162
+ server: {
163
+ title: "Ошибка сервера",
164
+ message: "Произошла ошибка на сервере. Попробуйте позже."
165
+ },
166
+ client: {
167
+ title: "Ошибка",
168
+ message: t.message || "Произошла ошибка при выполнении запроса."
169
+ },
170
+ unknown: {
171
+ title: "Неизвестная ошибка",
172
+ message: t.message || "Произошла неизвестная ошибка."
173
+ }
174
+ }, u = o[t.type] || o.unknown;
175
+ Qe({
176
+ type: t.type === "network" ? "warning" : "error",
177
+ title: u.title,
178
+ message: r ? `${u.message} (${r})` : u.message
179
+ });
180
+ }
181
+ function ir(t, r = {}) {
182
+ const {
183
+ notifyOnError: o = !0,
184
+ notifyOnSuccess: u = !1,
185
+ successMessage: a,
186
+ errorContext: d,
187
+ onSuccess: s,
188
+ onError: x
189
+ } = r, [f, E] = R(null), [l, m] = R(null), [c, _] = R(!1), w = l !== null, N = f !== null && !c && !w, C = k(async () => {
190
+ _(!0), m(null);
191
+ try {
192
+ const p = await t();
193
+ if (p.ok)
194
+ return E(p.data), u && a && Qe({
195
+ type: "success",
196
+ title: "Успешно",
197
+ message: a
198
+ }), s?.(p.data), p.data;
199
+ {
200
+ const A = {
201
+ message: p.data || "Request failed",
202
+ status: p.status,
203
+ type: "client",
204
+ timestamp: Date.now()
205
+ };
206
+ return m(A), o && Je(A, d), x?.(A), null;
207
+ }
208
+ } catch (p) {
209
+ const A = p;
210
+ return m(A), o && Je(A, d), x?.(A), null;
211
+ } finally {
212
+ _(!1);
213
+ }
214
+ }, [t, o, u, a, d, s, x]), b = k(() => {
215
+ E(null), m(null), _(!1);
216
+ }, []);
217
+ return {
218
+ data: f,
219
+ error: l,
220
+ isLoading: c,
221
+ isError: w,
222
+ isSuccess: N,
223
+ execute: C,
224
+ reset: b
225
+ };
226
+ }
227
+ const Wt = {
228
+ canView: ["all"],
229
+ canEdit: ["ibdop-user", "ibdop-admin", "ibdop-devops"],
230
+ canDelete: ["ibdop-admin", "ibdop-devops"],
231
+ canAdmin: ["ibdop-admin"],
232
+ canViewSensitiveData: ["ibdop-admin", "ibdop-devops"],
233
+ canExportData: ["ibdop-user"],
234
+ canManageUsers: ["ibdop-admin"]
235
+ };
236
+ function ur(t = {}) {
237
+ const r = ne(), o = Ge(() => ({
238
+ ...Wt,
239
+ ...t
240
+ }), [t]), u = Ge(() => {
241
+ const d = r.user?.profile?.realm_roles || r.user?.profile?.roles || [];
242
+ return Array.isArray(d) ? d : [d];
243
+ }, [r.user]), a = (d) => d.includes("all") ? !0 : d.some((s) => u.includes(s));
244
+ return {
245
+ canView: a(o.canView),
246
+ canEdit: a(o.canEdit),
247
+ canDelete: a(o.canDelete),
248
+ canAdmin: a(o.canAdmin),
249
+ canViewSensitiveData: a(o.canViewSensitiveData),
250
+ canExportData: a(o.canExportData),
251
+ canManageUsers: a(o.canManageUsers)
252
+ };
253
+ }
254
+ function cr() {
255
+ const t = ne(), [r, o] = R([]), [u, a] = R(0), [d, s] = R([]), [x, f] = R(!0), [E, l] = R(null), m = k(async () => {
256
+ if (!t.isAuthenticated) {
257
+ console.debug("[useFeatures] Not authenticated"), f(!1);
258
+ return;
259
+ }
260
+ f(!0), l(null);
261
+ try {
262
+ const w = {
263
+ "Content-Type": "application/json"
264
+ }, N = t.user?.access_token;
265
+ N && (w.Authorization = `Bearer ${N}`);
266
+ const C = await fetch("/api/features", { headers: w });
267
+ if (!C.ok)
268
+ throw new Error(`HTTP ${C.status}: ${C.statusText}`);
269
+ const b = await C.json();
270
+ o(b.features || []), a(b.totalCount || 0), s(b.userRoles || []);
271
+ } catch (w) {
272
+ console.debug("Features fetch error:", w), l(w instanceof Error ? w.message : String(w)), o([]), s([]);
273
+ } finally {
274
+ f(!1);
275
+ }
276
+ }, [t.isAuthenticated, t.user?.access_token]);
277
+ V(() => {
278
+ m();
279
+ }, [m]);
280
+ const c = k(
281
+ (w) => r.find((C) => C.name === w)?.userEnabled ?? !1,
282
+ [r]
283
+ ), _ = k(
284
+ (w) => r.filter((N) => N.mfDependencies?.includes(w)),
285
+ [r]
286
+ );
287
+ return {
288
+ features: r,
289
+ totalCount: u,
290
+ userRoles: d,
291
+ isLoading: x,
292
+ error: E,
293
+ refetch: m,
294
+ isFeatureEnabled: c,
295
+ getFeaturesByMf: _
296
+ };
297
+ }
298
+ function lr() {
299
+ const t = ne(), [r, o] = R([]), [u, a] = R([]), [d, s] = R(!1), [x, f] = R(!0), [E, l] = R(null), m = k(async () => {
300
+ if (!t.isAuthenticated) {
301
+ console.debug("[useFeatureAdmin] Not authenticated"), f(!1);
302
+ return;
303
+ }
304
+ f(!0), l(null);
305
+ try {
306
+ const C = {
307
+ "Content-Type": "application/json"
308
+ }, b = t.user?.access_token;
309
+ b && (C.Authorization = `Bearer ${b}`);
310
+ const p = await fetch("/api/features/admin", { headers: C });
311
+ if (!p.ok) {
312
+ if (p.status === 403) {
313
+ console.warn("[useFeatureAdmin] 403 Forbidden - checking if token has admin role"), s(!1), o([]), a([]), f(!1);
314
+ return;
315
+ }
316
+ throw new Error(`HTTP ${p.status}: ${p.statusText}`);
317
+ }
318
+ const A = await p.json();
319
+ o(A.featureToggles || []), a(A.microfrontends || []), s(A.isAdmin || !1);
320
+ } catch (C) {
321
+ console.debug("FeatureAdmin fetch error:", C), o([]), a([]), s(!1);
322
+ } finally {
323
+ f(!1);
324
+ }
325
+ }, [t.isAuthenticated, t.user?.access_token]), c = k(
326
+ async (C) => {
327
+ try {
328
+ const b = {
329
+ "Content-Type": "application/json"
330
+ }, p = t.user?.access_token;
331
+ p && (b.Authorization = `Bearer ${p}`);
332
+ const A = await fetch("/api/features/admin", {
333
+ method: "POST",
334
+ headers: b,
335
+ body: JSON.stringify(C)
336
+ });
337
+ if (!A.ok) {
338
+ const P = await A.json().catch(() => ({}));
339
+ throw new Error(P.error || `HTTP ${A.status}`);
340
+ }
341
+ return await m(), !0;
342
+ } catch (b) {
343
+ return l(b instanceof Error ? b.message : String(b)), !1;
344
+ }
345
+ },
346
+ [m]
347
+ ), _ = k(
348
+ async (C, b) => {
349
+ try {
350
+ const p = {
351
+ "Content-Type": "application/json"
352
+ }, A = t.user?.access_token;
353
+ A && (p.Authorization = `Bearer ${A}`);
354
+ const P = await fetch(`/api/features/admin/${encodeURIComponent(C)}`, {
355
+ method: "PUT",
356
+ headers: p,
357
+ body: JSON.stringify(b)
358
+ });
359
+ if (!P.ok) {
360
+ const z = await P.json().catch(() => ({}));
361
+ throw new Error(z.error || `HTTP ${P.status}`);
362
+ }
363
+ return await m(), !0;
364
+ } catch (p) {
365
+ return l(p instanceof Error ? p.message : String(p)), !1;
366
+ }
367
+ },
368
+ [m]
369
+ ), w = k(
370
+ async (C, b) => {
371
+ try {
372
+ const p = {}, A = t.user?.access_token;
373
+ A && (p.Authorization = `Bearer ${A}`);
374
+ const P = await fetch(
375
+ `/api/features/admin/${encodeURIComponent(C)}/toggle?enabled=${b}`,
376
+ {
377
+ method: "POST",
378
+ headers: p
379
+ }
380
+ );
381
+ if (!P.ok) {
382
+ const z = await P.json().catch(() => ({}));
383
+ throw new Error(z.error || `HTTP ${P.status}`);
384
+ }
385
+ return await m(), !0;
386
+ } catch (p) {
387
+ return l(p instanceof Error ? p.message : String(p)), !1;
388
+ }
389
+ },
390
+ [m]
391
+ ), N = k(
392
+ async (C) => {
393
+ try {
394
+ const b = {}, p = t.user?.access_token;
395
+ p && (b.Authorization = `Bearer ${p}`);
396
+ const A = await fetch(`/api/features/admin/${encodeURIComponent(C)}`, {
397
+ method: "DELETE",
398
+ headers: b
399
+ });
400
+ if (!A.ok) {
401
+ const P = await A.json().catch(() => ({}));
402
+ throw new Error(P.error || `HTTP ${A.status}`);
403
+ }
404
+ return await m(), !0;
405
+ } catch (b) {
406
+ return l(b instanceof Error ? b.message : String(b)), !1;
407
+ }
408
+ },
409
+ [m]
410
+ );
411
+ return V(() => {
412
+ m();
413
+ }, [m]), {
414
+ features: r,
415
+ microfrontends: u,
416
+ isAdmin: d,
417
+ isLoading: x,
418
+ error: E,
419
+ refetch: m,
420
+ createFeature: c,
421
+ updateFeature: _,
422
+ toggleFeature: w,
423
+ deleteFeature: N
424
+ };
425
+ }
426
+ function fr() {
427
+ const t = ne(), [r, o] = R([]), [u, a] = R(0), [d, s] = R(!0), [x, f] = R(null), E = k(async () => {
428
+ if (!t.isAuthenticated) {
429
+ s(!1);
430
+ return;
431
+ }
432
+ s(!0), f(null);
433
+ try {
434
+ const l = {
435
+ "Content-Type": "application/json"
436
+ }, m = t.user?.access_token;
437
+ m && (l.Authorization = `Bearer ${m}`);
438
+ const c = await fetch("/api/features/microfrontends", { headers: l });
439
+ if (!c.ok)
440
+ throw new Error(`HTTP ${c.status}: ${c.statusText}`);
441
+ const _ = await c.json();
442
+ o(_.microfrontends || []), a(_.totalCount || 0);
443
+ } catch (l) {
444
+ f(l instanceof Error ? l.message : String(l));
445
+ } finally {
446
+ s(!1);
447
+ }
448
+ }, [t.isAuthenticated, t.user?.access_token]);
449
+ return V(() => {
450
+ E();
451
+ }, [E]), {
452
+ microfrontends: r,
453
+ totalCount: u,
454
+ isLoading: d,
455
+ error: x,
456
+ refetch: E
457
+ };
458
+ }
459
+ var te = { exports: {} }, Y = {};
460
+ var qe;
461
+ function Gt() {
462
+ if (qe) return Y;
463
+ qe = 1;
464
+ var t = Ze, r = /* @__PURE__ */ Symbol.for("react.element"), o = /* @__PURE__ */ Symbol.for("react.fragment"), u = Object.prototype.hasOwnProperty, a = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, d = { key: !0, ref: !0, __self: !0, __source: !0 };
465
+ function s(x, f, E) {
466
+ var l, m = {}, c = null, _ = null;
467
+ E !== void 0 && (c = "" + E), f.key !== void 0 && (c = "" + f.key), f.ref !== void 0 && (_ = f.ref);
468
+ for (l in f) u.call(f, l) && !d.hasOwnProperty(l) && (m[l] = f[l]);
469
+ if (x && x.defaultProps) for (l in f = x.defaultProps, f) m[l] === void 0 && (m[l] = f[l]);
470
+ return { $$typeof: r, type: x, key: c, ref: _, props: m, _owner: a.current };
471
+ }
472
+ return Y.Fragment = o, Y.jsx = s, Y.jsxs = s, Y;
473
+ }
474
+ var J = {};
475
+ var Ke;
476
+ function Yt() {
477
+ return Ke || (Ke = 1, process.env.NODE_ENV !== "production" && (function() {
478
+ var t = Ze, r = /* @__PURE__ */ Symbol.for("react.element"), o = /* @__PURE__ */ Symbol.for("react.portal"), u = /* @__PURE__ */ Symbol.for("react.fragment"), a = /* @__PURE__ */ Symbol.for("react.strict_mode"), d = /* @__PURE__ */ Symbol.for("react.profiler"), s = /* @__PURE__ */ Symbol.for("react.provider"), x = /* @__PURE__ */ Symbol.for("react.context"), f = /* @__PURE__ */ Symbol.for("react.forward_ref"), E = /* @__PURE__ */ Symbol.for("react.suspense"), l = /* @__PURE__ */ Symbol.for("react.suspense_list"), m = /* @__PURE__ */ Symbol.for("react.memo"), c = /* @__PURE__ */ Symbol.for("react.lazy"), _ = /* @__PURE__ */ Symbol.for("react.offscreen"), w = Symbol.iterator, N = "@@iterator";
479
+ function C(e) {
480
+ if (e === null || typeof e != "object")
481
+ return null;
482
+ var n = w && e[w] || e[N];
483
+ return typeof n == "function" ? n : null;
484
+ }
485
+ var b = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
486
+ function p(e) {
487
+ {
488
+ for (var n = arguments.length, i = new Array(n > 1 ? n - 1 : 0), h = 1; h < n; h++)
489
+ i[h - 1] = arguments[h];
490
+ A("error", e, i);
491
+ }
492
+ }
493
+ function A(e, n, i) {
494
+ {
495
+ var h = b.ReactDebugCurrentFrame, S = h.getStackAddendum();
496
+ S !== "" && (n += "%s", i = i.concat([S]));
497
+ var T = i.map(function(y) {
498
+ return String(y);
499
+ });
500
+ T.unshift("Warning: " + n), Function.prototype.apply.call(console[e], console, T);
501
+ }
502
+ }
503
+ var P = !1, z = !1, st = !1, at = !1, it = !1, we;
504
+ we = /* @__PURE__ */ Symbol.for("react.module.reference");
505
+ function ut(e) {
506
+ return !!(typeof e == "string" || typeof e == "function" || e === u || e === d || it || e === a || e === E || e === l || at || e === _ || P || z || st || typeof e == "object" && e !== null && (e.$$typeof === c || e.$$typeof === m || e.$$typeof === s || e.$$typeof === x || e.$$typeof === f || // This needs to include all possible module reference object
507
+ // types supported by any Flight configuration anywhere since
508
+ // we don't know which Flight build this will end up being used
509
+ // with.
510
+ e.$$typeof === we || e.getModuleId !== void 0));
511
+ }
512
+ function ct(e, n, i) {
513
+ var h = e.displayName;
514
+ if (h)
515
+ return h;
516
+ var S = n.displayName || n.name || "";
517
+ return S !== "" ? i + "(" + S + ")" : i;
518
+ }
519
+ function be(e) {
520
+ return e.displayName || "Context";
521
+ }
522
+ function $(e) {
523
+ if (e == null)
524
+ return null;
525
+ if (typeof e.tag == "number" && p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
526
+ return e.displayName || e.name || null;
527
+ if (typeof e == "string")
528
+ return e;
529
+ switch (e) {
530
+ case u:
531
+ return "Fragment";
532
+ case o:
533
+ return "Portal";
534
+ case d:
535
+ return "Profiler";
536
+ case a:
537
+ return "StrictMode";
538
+ case E:
539
+ return "Suspense";
540
+ case l:
541
+ return "SuspenseList";
542
+ }
543
+ if (typeof e == "object")
544
+ switch (e.$$typeof) {
545
+ case x:
546
+ var n = e;
547
+ return be(n) + ".Consumer";
548
+ case s:
549
+ var i = e;
550
+ return be(i._context) + ".Provider";
551
+ case f:
552
+ return ct(e, e.render, "ForwardRef");
553
+ case m:
554
+ var h = e.displayName || null;
555
+ return h !== null ? h : $(e.type) || "Memo";
556
+ case c: {
557
+ var S = e, T = S._payload, y = S._init;
558
+ try {
559
+ return $(y(T));
560
+ } catch {
561
+ return null;
562
+ }
563
+ }
564
+ }
565
+ return null;
566
+ }
567
+ var L = Object.assign, W = 0, xe, Se, Ae, Te, Re, Ce, Ie;
568
+ function ke() {
569
+ }
570
+ ke.__reactDisabledLog = !0;
571
+ function lt() {
572
+ {
573
+ if (W === 0) {
574
+ xe = console.log, Se = console.info, Ae = console.warn, Te = console.error, Re = console.group, Ce = console.groupCollapsed, Ie = console.groupEnd;
575
+ var e = {
576
+ configurable: !0,
577
+ enumerable: !0,
578
+ value: ke,
579
+ writable: !0
580
+ };
581
+ Object.defineProperties(console, {
582
+ info: e,
583
+ log: e,
584
+ warn: e,
585
+ error: e,
586
+ group: e,
587
+ groupCollapsed: e,
588
+ groupEnd: e
589
+ });
590
+ }
591
+ W++;
592
+ }
593
+ }
594
+ function ft() {
595
+ {
596
+ if (W--, W === 0) {
597
+ var e = {
598
+ configurable: !0,
599
+ enumerable: !0,
600
+ writable: !0
601
+ };
602
+ Object.defineProperties(console, {
603
+ log: L({}, e, {
604
+ value: xe
605
+ }),
606
+ info: L({}, e, {
607
+ value: Se
608
+ }),
609
+ warn: L({}, e, {
610
+ value: Ae
611
+ }),
612
+ error: L({}, e, {
613
+ value: Te
614
+ }),
615
+ group: L({}, e, {
616
+ value: Re
617
+ }),
618
+ groupCollapsed: L({}, e, {
619
+ value: Ce
620
+ }),
621
+ groupEnd: L({}, e, {
622
+ value: Ie
623
+ })
624
+ });
625
+ }
626
+ W < 0 && p("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
627
+ }
628
+ }
629
+ var ae = b.ReactCurrentDispatcher, ie;
630
+ function K(e, n, i) {
631
+ {
632
+ if (ie === void 0)
633
+ try {
634
+ throw Error();
635
+ } catch (S) {
636
+ var h = S.stack.trim().match(/\n( *(at )?)/);
637
+ ie = h && h[1] || "";
638
+ }
639
+ return `
640
+ ` + ie + e;
641
+ }
642
+ }
643
+ var ue = !1, X;
644
+ {
645
+ var dt = typeof WeakMap == "function" ? WeakMap : Map;
646
+ X = new dt();
647
+ }
648
+ function Me(e, n) {
649
+ if (!e || ue)
650
+ return "";
651
+ {
652
+ var i = X.get(e);
653
+ if (i !== void 0)
654
+ return i;
655
+ }
656
+ var h;
657
+ ue = !0;
658
+ var S = Error.prepareStackTrace;
659
+ Error.prepareStackTrace = void 0;
660
+ var T;
661
+ T = ae.current, ae.current = null, lt();
662
+ try {
663
+ if (n) {
664
+ var y = function() {
665
+ throw Error();
666
+ };
667
+ if (Object.defineProperty(y.prototype, "props", {
668
+ set: function() {
669
+ throw Error();
670
+ }
671
+ }), typeof Reflect == "object" && Reflect.construct) {
672
+ try {
673
+ Reflect.construct(y, []);
674
+ } catch (O) {
675
+ h = O;
676
+ }
677
+ Reflect.construct(e, [], y);
678
+ } else {
679
+ try {
680
+ y.call();
681
+ } catch (O) {
682
+ h = O;
683
+ }
684
+ e.call(y.prototype);
685
+ }
686
+ } else {
687
+ try {
688
+ throw Error();
689
+ } catch (O) {
690
+ h = O;
691
+ }
692
+ e();
693
+ }
694
+ } catch (O) {
695
+ if (O && h && typeof O.stack == "string") {
696
+ for (var v = O.stack.split(`
697
+ `), j = h.stack.split(`
698
+ `), I = v.length - 1, M = j.length - 1; I >= 1 && M >= 0 && v[I] !== j[M]; )
699
+ M--;
700
+ for (; I >= 1 && M >= 0; I--, M--)
701
+ if (v[I] !== j[M]) {
702
+ if (I !== 1 || M !== 1)
703
+ do
704
+ if (I--, M--, M < 0 || v[I] !== j[M]) {
705
+ var F = `
706
+ ` + v[I].replace(" at new ", " at ");
707
+ return e.displayName && F.includes("<anonymous>") && (F = F.replace("<anonymous>", e.displayName)), typeof e == "function" && X.set(e, F), F;
708
+ }
709
+ while (I >= 1 && M >= 0);
710
+ break;
711
+ }
712
+ }
713
+ } finally {
714
+ ue = !1, ae.current = T, ft(), Error.prepareStackTrace = S;
715
+ }
716
+ var H = e ? e.displayName || e.name : "", U = H ? K(H) : "";
717
+ return typeof e == "function" && X.set(e, U), U;
718
+ }
719
+ function pt(e, n, i) {
720
+ return Me(e, !1);
721
+ }
722
+ function ht(e) {
723
+ var n = e.prototype;
724
+ return !!(n && n.isReactComponent);
725
+ }
726
+ function Z(e, n, i) {
727
+ if (e == null)
728
+ return "";
729
+ if (typeof e == "function")
730
+ return Me(e, ht(e));
731
+ if (typeof e == "string")
732
+ return K(e);
733
+ switch (e) {
734
+ case E:
735
+ return K("Suspense");
736
+ case l:
737
+ return K("SuspenseList");
738
+ }
739
+ if (typeof e == "object")
740
+ switch (e.$$typeof) {
741
+ case f:
742
+ return pt(e.render);
743
+ case m:
744
+ return Z(e.type, n, i);
745
+ case c: {
746
+ var h = e, S = h._payload, T = h._init;
747
+ try {
748
+ return Z(T(S), n, i);
749
+ } catch {
750
+ }
751
+ }
752
+ }
753
+ return "";
754
+ }
755
+ var G = Object.prototype.hasOwnProperty, Ne = {}, je = b.ReactDebugCurrentFrame;
756
+ function Q(e) {
757
+ if (e) {
758
+ var n = e._owner, i = Z(e.type, e._source, n ? n.type : null);
759
+ je.setExtraStackFrame(i);
760
+ } else
761
+ je.setExtraStackFrame(null);
762
+ }
763
+ function gt(e, n, i, h, S) {
764
+ {
765
+ var T = Function.call.bind(G);
766
+ for (var y in e)
767
+ if (T(e, y)) {
768
+ var v = void 0;
769
+ try {
770
+ if (typeof e[y] != "function") {
771
+ var j = Error((h || "React class") + ": " + i + " type `" + y + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[y] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
772
+ throw j.name = "Invariant Violation", j;
773
+ }
774
+ v = e[y](n, y, h, i, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
775
+ } catch (I) {
776
+ v = I;
777
+ }
778
+ v && !(v instanceof Error) && (Q(S), p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", h || "React class", i, y, typeof v), Q(null)), v instanceof Error && !(v.message in Ne) && (Ne[v.message] = !0, Q(S), p("Failed %s type: %s", i, v.message), Q(null));
779
+ }
780
+ }
781
+ }
782
+ var mt = Array.isArray;
783
+ function ce(e) {
784
+ return mt(e);
785
+ }
786
+ function _t(e) {
787
+ {
788
+ var n = typeof Symbol == "function" && Symbol.toStringTag, i = n && e[Symbol.toStringTag] || e.constructor.name || "Object";
789
+ return i;
790
+ }
791
+ }
792
+ function vt(e) {
793
+ try {
794
+ return Oe(e), !1;
795
+ } catch {
796
+ return !0;
797
+ }
798
+ }
799
+ function Oe(e) {
800
+ return "" + e;
801
+ }
802
+ function Pe(e) {
803
+ if (vt(e))
804
+ return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", _t(e)), Oe(e);
805
+ }
806
+ var Fe = b.ReactCurrentOwner, Et = {
807
+ key: !0,
808
+ ref: !0,
809
+ __self: !0,
810
+ __source: !0
811
+ }, De, $e;
812
+ function yt(e) {
813
+ if (G.call(e, "ref")) {
814
+ var n = Object.getOwnPropertyDescriptor(e, "ref").get;
815
+ if (n && n.isReactWarning)
816
+ return !1;
817
+ }
818
+ return e.ref !== void 0;
819
+ }
820
+ function wt(e) {
821
+ if (G.call(e, "key")) {
822
+ var n = Object.getOwnPropertyDescriptor(e, "key").get;
823
+ if (n && n.isReactWarning)
824
+ return !1;
825
+ }
826
+ return e.key !== void 0;
827
+ }
828
+ function bt(e, n) {
829
+ typeof e.ref == "string" && Fe.current;
830
+ }
831
+ function xt(e, n) {
832
+ {
833
+ var i = function() {
834
+ De || (De = !0, p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", n));
835
+ };
836
+ i.isReactWarning = !0, Object.defineProperty(e, "key", {
837
+ get: i,
838
+ configurable: !0
839
+ });
840
+ }
841
+ }
842
+ function St(e, n) {
843
+ {
844
+ var i = function() {
845
+ $e || ($e = !0, p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", n));
846
+ };
847
+ i.isReactWarning = !0, Object.defineProperty(e, "ref", {
848
+ get: i,
849
+ configurable: !0
850
+ });
851
+ }
852
+ }
853
+ var At = function(e, n, i, h, S, T, y) {
854
+ var v = {
855
+ // This tag allows us to uniquely identify this as a React Element
856
+ $$typeof: r,
857
+ // Built-in properties that belong on the element
858
+ type: e,
859
+ key: n,
860
+ ref: i,
861
+ props: y,
862
+ // Record the component responsible for creating this element.
863
+ _owner: T
864
+ };
865
+ return v._store = {}, Object.defineProperty(v._store, "validated", {
866
+ configurable: !1,
867
+ enumerable: !1,
868
+ writable: !0,
869
+ value: !1
870
+ }), Object.defineProperty(v, "_self", {
871
+ configurable: !1,
872
+ enumerable: !1,
873
+ writable: !1,
874
+ value: h
875
+ }), Object.defineProperty(v, "_source", {
876
+ configurable: !1,
877
+ enumerable: !1,
878
+ writable: !1,
879
+ value: S
880
+ }), Object.freeze && (Object.freeze(v.props), Object.freeze(v)), v;
881
+ };
882
+ function Tt(e, n, i, h, S) {
883
+ {
884
+ var T, y = {}, v = null, j = null;
885
+ i !== void 0 && (Pe(i), v = "" + i), wt(n) && (Pe(n.key), v = "" + n.key), yt(n) && (j = n.ref, bt(n, S));
886
+ for (T in n)
887
+ G.call(n, T) && !Et.hasOwnProperty(T) && (y[T] = n[T]);
888
+ if (e && e.defaultProps) {
889
+ var I = e.defaultProps;
890
+ for (T in I)
891
+ y[T] === void 0 && (y[T] = I[T]);
892
+ }
893
+ if (v || j) {
894
+ var M = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
895
+ v && xt(y, M), j && St(y, M);
896
+ }
897
+ return At(e, v, j, S, h, Fe.current, y);
898
+ }
899
+ }
900
+ var le = b.ReactCurrentOwner, Le = b.ReactDebugCurrentFrame;
901
+ function B(e) {
902
+ if (e) {
903
+ var n = e._owner, i = Z(e.type, e._source, n ? n.type : null);
904
+ Le.setExtraStackFrame(i);
905
+ } else
906
+ Le.setExtraStackFrame(null);
907
+ }
908
+ var fe;
909
+ fe = !1;
910
+ function de(e) {
911
+ return typeof e == "object" && e !== null && e.$$typeof === r;
912
+ }
913
+ function Ue() {
914
+ {
915
+ if (le.current) {
916
+ var e = $(le.current.type);
917
+ if (e)
918
+ return `
919
+
920
+ Check the render method of \`` + e + "`.";
921
+ }
922
+ return "";
923
+ }
924
+ }
925
+ function Rt(e) {
926
+ return "";
927
+ }
928
+ var Ve = {};
929
+ function Ct(e) {
930
+ {
931
+ var n = Ue();
932
+ if (!n) {
933
+ var i = typeof e == "string" ? e : e.displayName || e.name;
934
+ i && (n = `
935
+
936
+ Check the top-level render call using <` + i + ">.");
937
+ }
938
+ return n;
939
+ }
940
+ }
941
+ function Be(e, n) {
942
+ {
943
+ if (!e._store || e._store.validated || e.key != null)
944
+ return;
945
+ e._store.validated = !0;
946
+ var i = Ct(n);
947
+ if (Ve[i])
948
+ return;
949
+ Ve[i] = !0;
950
+ var h = "";
951
+ e && e._owner && e._owner !== le.current && (h = " It was passed a child from " + $(e._owner.type) + "."), B(e), p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', i, h), B(null);
952
+ }
953
+ }
954
+ function He(e, n) {
955
+ {
956
+ if (typeof e != "object")
957
+ return;
958
+ if (ce(e))
959
+ for (var i = 0; i < e.length; i++) {
960
+ var h = e[i];
961
+ de(h) && Be(h, n);
962
+ }
963
+ else if (de(e))
964
+ e._store && (e._store.validated = !0);
965
+ else if (e) {
966
+ var S = C(e);
967
+ if (typeof S == "function" && S !== e.entries)
968
+ for (var T = S.call(e), y; !(y = T.next()).done; )
969
+ de(y.value) && Be(y.value, n);
970
+ }
971
+ }
972
+ }
973
+ function It(e) {
974
+ {
975
+ var n = e.type;
976
+ if (n == null || typeof n == "string")
977
+ return;
978
+ var i;
979
+ if (typeof n == "function")
980
+ i = n.propTypes;
981
+ else if (typeof n == "object" && (n.$$typeof === f || // Note: Memo only checks outer props here.
982
+ // Inner props are checked in the reconciler.
983
+ n.$$typeof === m))
984
+ i = n.propTypes;
985
+ else
986
+ return;
987
+ if (i) {
988
+ var h = $(n);
989
+ gt(i, e.props, "prop", h, e);
990
+ } else if (n.PropTypes !== void 0 && !fe) {
991
+ fe = !0;
992
+ var S = $(n);
993
+ p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", S || "Unknown");
994
+ }
995
+ typeof n.getDefaultProps == "function" && !n.getDefaultProps.isReactClassApproved && p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
996
+ }
997
+ }
998
+ function kt(e) {
999
+ {
1000
+ for (var n = Object.keys(e.props), i = 0; i < n.length; i++) {
1001
+ var h = n[i];
1002
+ if (h !== "children" && h !== "key") {
1003
+ B(e), p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", h), B(null);
1004
+ break;
1005
+ }
1006
+ }
1007
+ e.ref !== null && (B(e), p("Invalid attribute `ref` supplied to `React.Fragment`."), B(null));
1008
+ }
1009
+ }
1010
+ var ze = {};
1011
+ function We(e, n, i, h, S, T) {
1012
+ {
1013
+ var y = ut(e);
1014
+ if (!y) {
1015
+ var v = "";
1016
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (v += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
1017
+ var j = Rt();
1018
+ j ? v += j : v += Ue();
1019
+ var I;
1020
+ e === null ? I = "null" : ce(e) ? I = "array" : e !== void 0 && e.$$typeof === r ? (I = "<" + ($(e.type) || "Unknown") + " />", v = " Did you accidentally export a JSX literal instead of a component?") : I = typeof e, p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", I, v);
1021
+ }
1022
+ var M = Tt(e, n, i, S, T);
1023
+ if (M == null)
1024
+ return M;
1025
+ if (y) {
1026
+ var F = n.children;
1027
+ if (F !== void 0)
1028
+ if (h)
1029
+ if (ce(F)) {
1030
+ for (var H = 0; H < F.length; H++)
1031
+ He(F[H], e);
1032
+ Object.freeze && Object.freeze(F);
1033
+ } else
1034
+ p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
1035
+ else
1036
+ He(F, e);
1037
+ }
1038
+ if (G.call(n, "key")) {
1039
+ var U = $(e), O = Object.keys(n).filter(function(Ft) {
1040
+ return Ft !== "key";
1041
+ }), pe = O.length > 0 ? "{key: someKey, " + O.join(": ..., ") + ": ...}" : "{key: someKey}";
1042
+ if (!ze[U + pe]) {
1043
+ var Pt = O.length > 0 ? "{" + O.join(": ..., ") + ": ...}" : "{}";
1044
+ p(`A props object containing a "key" prop is being spread into JSX:
1045
+ let props = %s;
1046
+ <%s {...props} />
1047
+ React keys must be passed directly to JSX without using spread:
1048
+ let props = %s;
1049
+ <%s key={someKey} {...props} />`, pe, U, Pt, U), ze[U + pe] = !0;
1050
+ }
1051
+ }
1052
+ return e === u ? kt(M) : It(M), M;
1053
+ }
1054
+ }
1055
+ function Mt(e, n, i) {
1056
+ return We(e, n, i, !0);
1057
+ }
1058
+ function Nt(e, n, i) {
1059
+ return We(e, n, i, !1);
1060
+ }
1061
+ var jt = Nt, Ot = Mt;
1062
+ J.Fragment = u, J.jsx = jt, J.jsxs = Ot;
1063
+ })()), J;
1064
+ }
1065
+ var Xe;
1066
+ function Jt() {
1067
+ return Xe || (Xe = 1, process.env.NODE_ENV === "production" ? te.exports = Gt() : te.exports = Yt()), te.exports;
1068
+ }
1069
+ var g = Jt();
1070
+ const et = "platform-kit", qt = !1, me = {
1071
+ log: (...t) => {
1072
+ },
1073
+ warn: (...t) => {
1074
+ },
1075
+ error: (...t) => {
1076
+ console.error(`[${et}]`, ...t);
1077
+ }
1078
+ };
1079
+ class dr extends $t {
1080
+ hasDispatched = !1;
1081
+ constructor(r) {
1082
+ super(r), this.state = { hasError: !1 };
1083
+ }
1084
+ /**
1085
+ * Получить имя MF из props или window
1086
+ */
1087
+ getMfeName() {
1088
+ if (this.props.mfeName) return this.props.mfeName;
1089
+ if (typeof window < "u") {
1090
+ const r = window;
1091
+ if (r.__MF_NAME__) return r.__MF_NAME__;
1092
+ }
1093
+ return et;
1094
+ }
1095
+ /**
1096
+ * Определить нужно ли показывать детали ошибки
1097
+ */
1098
+ shouldShowDetails() {
1099
+ if (this.props.showDetails !== void 0)
1100
+ return this.props.showDetails;
1101
+ if (typeof sessionStorage < "u")
1102
+ try {
1103
+ const r = sessionStorage.getItem("config");
1104
+ if (r) {
1105
+ const o = JSON.parse(r);
1106
+ if (o.showErrorDetails !== void 0)
1107
+ return o.showErrorDetails;
1108
+ }
1109
+ } catch {
1110
+ }
1111
+ return qt;
1112
+ }
1113
+ /**
1114
+ * Dispatch ошибки в shell
1115
+ */
1116
+ dispatchError(r, o) {
1117
+ if (this.hasDispatched || typeof window > "u") return;
1118
+ this.hasDispatched = !0;
1119
+ const u = this.getMfeName();
1120
+ me.error("ErrorBoundary caught:", r);
1121
+ try {
1122
+ window.dispatchEvent(new CustomEvent("mfe-error", {
1123
+ detail: {
1124
+ mfeName: u,
1125
+ error: r.message || String(r),
1126
+ stack: r.stack,
1127
+ componentStack: o?.componentStack,
1128
+ timestamp: Date.now()
1129
+ },
1130
+ bubbles: !0
1131
+ }));
1132
+ } catch (a) {
1133
+ me.error("Failed to dispatch mfe-error event:", a);
1134
+ }
1135
+ }
1136
+ /**
1137
+ * Получить derived state из ошибки
1138
+ */
1139
+ static getDerivedStateFromError(r) {
1140
+ return { hasError: !0, error: r };
1141
+ }
1142
+ /**
1143
+ * Обработать ошибку
1144
+ */
1145
+ componentDidCatch(r, o) {
1146
+ this.dispatchError(r, o), me.error("Error info:", o.componentStack);
1147
+ }
1148
+ /**
1149
+ * Копировать ошибку в буфер обмена
1150
+ */
1151
+ handleCopy = () => {
1152
+ const r = `Error in ${this.getMfeName()}:
1153
+ ${this.state.error?.message}
1154
+ ${this.state.error?.stack}`;
1155
+ typeof navigator < "u" && navigator.clipboard && navigator.clipboard.writeText(r).then(() => {
1156
+ alert("Ошибка скопирована в буфер обмена");
1157
+ }).catch(() => {
1158
+ prompt("Скопируйте ошибку:", r);
1159
+ });
1160
+ };
1161
+ /**
1162
+ * Повторить рендер
1163
+ */
1164
+ handleRetry = () => {
1165
+ this.setState({ hasError: !1, error: void 0 }), this.hasDispatched = !1, typeof window < "u" && window.location.reload();
1166
+ };
1167
+ /**
1168
+ * Перейти на главную
1169
+ */
1170
+ handleGoHome = () => {
1171
+ typeof window < "u" && (window.location.href = "/");
1172
+ };
1173
+ /**
1174
+ * Рендер
1175
+ */
1176
+ render() {
1177
+ if (this.state.hasError) {
1178
+ const r = this.state.error?.message || "Unknown error", o = this.state.error?.stack || "", u = this.shouldShowDetails(), a = this.getMfeName();
1179
+ return /* @__PURE__ */ g.jsxs("div", { style: {
1180
+ padding: "20px",
1181
+ textAlign: "center",
1182
+ color: "#d32f2f",
1183
+ fontFamily: "monospace",
1184
+ background: "#ffebee",
1185
+ border: "1px solid #ef5350",
1186
+ borderRadius: "4px",
1187
+ margin: "10px"
1188
+ }, children: [
1189
+ /* @__PURE__ */ g.jsxs("h2", { style: { fontSize: "16px", margin: "0 0 8px 0" }, children: [
1190
+ "⚠️ Ошибка в ",
1191
+ a
1192
+ ] }),
1193
+ /* @__PURE__ */ g.jsx("p", { style: { fontSize: "12px", margin: 0 }, children: "Произошла ошибка в микрофронтенде. Сообщение отправлено в shell." }),
1194
+ u && /* @__PURE__ */ g.jsxs("details", { style: {
1195
+ whiteSpace: "pre-wrap",
1196
+ textAlign: "left",
1197
+ marginTop: "10px",
1198
+ background: "#fff",
1199
+ padding: "8px",
1200
+ borderRadius: "4px"
1201
+ }, children: [
1202
+ /* @__PURE__ */ g.jsx("summary", { style: { cursor: "pointer", fontWeight: "bold" }, children: "Детали ошибки" }),
1203
+ /* @__PURE__ */ g.jsxs("pre", { style: {
1204
+ fontSize: "11px",
1205
+ overflow: "auto",
1206
+ maxHeight: "150px",
1207
+ margin: "8px 0 0 0",
1208
+ padding: "8px",
1209
+ background: "#f5f5f5",
1210
+ borderRadius: "4px"
1211
+ }, children: [
1212
+ r,
1213
+ o && `
1214
+
1215
+ ${o}`
1216
+ ] })
1217
+ ] }),
1218
+ /* @__PURE__ */ g.jsxs("div", { style: { marginTop: "12px", display: "flex", gap: "8px", justifyContent: "center" }, children: [
1219
+ /* @__PURE__ */ g.jsx(
1220
+ "button",
1221
+ {
1222
+ onClick: this.handleCopy,
1223
+ style: {
1224
+ padding: "8px 12px",
1225
+ background: "#666",
1226
+ color: "white",
1227
+ border: "none",
1228
+ borderRadius: "4px",
1229
+ cursor: "pointer"
1230
+ },
1231
+ children: "📋 Копировать"
1232
+ }
1233
+ ),
1234
+ /* @__PURE__ */ g.jsx(
1235
+ "button",
1236
+ {
1237
+ onClick: this.handleRetry,
1238
+ style: {
1239
+ padding: "8px 12px",
1240
+ background: "#d32f2f",
1241
+ color: "white",
1242
+ border: "none",
1243
+ borderRadius: "4px",
1244
+ cursor: "pointer"
1245
+ },
1246
+ children: "🔄 Обновить"
1247
+ }
1248
+ ),
1249
+ /* @__PURE__ */ g.jsx(
1250
+ "button",
1251
+ {
1252
+ onClick: this.handleGoHome,
1253
+ style: {
1254
+ padding: "8px 12px",
1255
+ background: "#1976d2",
1256
+ color: "white",
1257
+ border: "none",
1258
+ borderRadius: "4px",
1259
+ cursor: "pointer"
1260
+ },
1261
+ children: "🏠 На главную"
1262
+ }
1263
+ )
1264
+ ] })
1265
+ ] });
1266
+ }
1267
+ return this.props.children == null ? null : this.props.children;
1268
+ }
1269
+ }
1270
+ const D = {
1271
+ info: "ℹ️",
1272
+ code: "💻",
1273
+ link: "🔗",
1274
+ user: "👤",
1275
+ clock: "🕐",
1276
+ apps: "📦",
1277
+ storage: "💾",
1278
+ tags: "🏷️",
1279
+ spreadsheet: "📊"
1280
+ };
1281
+ function pr({ mfeName: t }) {
1282
+ const { data: r, isLoading: o, error: u } = zt({ mfeName: t }), [a, d] = R(!1);
1283
+ if (o)
1284
+ return /* @__PURE__ */ g.jsxs("span", { className: "text-muted small me-2", children: [
1285
+ /* @__PURE__ */ g.jsx("span", { className: "me-1", children: "⏳" }),
1286
+ "Загрузка..."
1287
+ ] });
1288
+ if (u || !r)
1289
+ return /* @__PURE__ */ g.jsxs("span", { className: "text-muted small me-2", title: `Ошибка: ${u || "нет данных"}`, children: [
1290
+ /* @__PURE__ */ g.jsx("span", { className: "me-1", children: "ℹ️" }),
1291
+ "N/A"
1292
+ ] });
1293
+ const s = r, x = s.BUILD_VERSION || s.IMAGE_VERSION || s.APP_NAME || "N/A", f = [];
1294
+ return s.APP_NAME && f.push({ key: "APP_NAME", value: s.APP_NAME, label: "Приложение", icon: D.apps }), s.BUILD_VERSION && f.push({ key: "BUILD_VERSION", value: s.BUILD_VERSION, label: "Версия", icon: D.tags }), s.IMAGE_VERSION && f.push({ key: "IMAGE_VERSION", value: s.IMAGE_VERSION, label: "Образ", icon: D.storage }), s.GIT_COMMIT && f.push({ key: "GIT_COMMIT", value: s.GIT_COMMIT, label: "Commit", icon: D.spreadsheet }), s.GIT_BRANCH && f.push({ key: "GIT_BRANCH", value: s.GIT_BRANCH, label: "Ветка", icon: D.spreadsheet }), s.CI_COMMIT_AUTHOR && f.push({ key: "CI_COMMIT_AUTHOR", value: s.CI_COMMIT_AUTHOR, label: "Автор", icon: D.user }), s.CI_COMMIT_TIMESTAMP && f.push({ key: "CI_COMMIT_TIMESTAMP", value: s.CI_COMMIT_TIMESTAMP, label: "Дата", icon: D.clock }), s.CI_JOB_URL && f.push({ key: "CI_JOB_URL", value: s.CI_JOB_URL, label: "CI Job", icon: D.link }), s.CI_PIPELINE_URL && f.push({ key: "CI_PIPELINE_URL", value: s.CI_PIPELINE_URL, label: "Pipeline", icon: D.link }), s.CI_COMMIT_MESSAGE && (s.CI_COMMIT_MESSAGE.length > 60 ? s.CI_COMMIT_MESSAGE.substring(0, 57) + "" : s.CI_COMMIT_MESSAGE, f.push({ key: "CI_COMMIT_MESSAGE", value: s.CI_COMMIT_MESSAGE, label: "Сообщение", icon: D.code })), /* @__PURE__ */ g.jsxs("div", { style: { display: "inline-block", position: "relative" }, children: [
1295
+ /* @__PURE__ */ g.jsxs(
1296
+ "button",
1297
+ {
1298
+ onClick: () => d(!a),
1299
+ style: {
1300
+ background: "transparent",
1301
+ border: "none",
1302
+ cursor: "pointer",
1303
+ padding: "4px 8px",
1304
+ fontSize: "14px",
1305
+ display: "inline-flex",
1306
+ alignItems: "center"
1307
+ },
1308
+ title: "Информация о версии",
1309
+ children: [
1310
+ /* @__PURE__ */ g.jsx("span", { className: "me-1", children: D.info }),
1311
+ /* @__PURE__ */ g.jsx("span", { className: "text-dark", children: x })
1312
+ ]
1313
+ }
1314
+ ),
1315
+ a && /* @__PURE__ */ g.jsxs(
1316
+ "div",
1317
+ {
1318
+ style: {
1319
+ position: "absolute",
1320
+ top: "100%",
1321
+ right: 0,
1322
+ zIndex: 1e3,
1323
+ minWidth: "300px",
1324
+ background: "white",
1325
+ border: "1px solid #dee2e6",
1326
+ borderRadius: "8px",
1327
+ boxShadow: "0 4px 12px rgba(0,0,0,0.15)",
1328
+ padding: "16px",
1329
+ marginTop: "4px"
1330
+ },
1331
+ children: [
1332
+ /* @__PURE__ */ g.jsxs("div", { style: {
1333
+ marginBottom: "12px",
1334
+ paddingBottom: "8px",
1335
+ borderBottom: "1px solid #dee2e6",
1336
+ display: "flex",
1337
+ alignItems: "center"
1338
+ }, children: [
1339
+ /* @__PURE__ */ g.jsx("span", { className: "me-2", children: D.apps }),
1340
+ /* @__PURE__ */ g.jsx("strong", { children: s.APP_NAME || t })
1341
+ ] }),
1342
+ /* @__PURE__ */ g.jsxs("div", { style: { marginBottom: "12px" }, children: [
1343
+ /* @__PURE__ */ g.jsx("span", { className: "text-muted", children: "Версия: " }),
1344
+ /* @__PURE__ */ g.jsx("strong", { children: x })
1345
+ ] }),
1346
+ f.length > 0 && /* @__PURE__ */ g.jsx("div", { style: { fontSize: "13px" }, children: f.map(({ key: E, value: l, label: m, icon: c }) => {
1347
+ const _ = l.length > 40 && (E.includes("URL") || E.includes("MESSAGE")) ? `${l.substring(0, 37)}...` : l;
1348
+ return /* @__PURE__ */ g.jsxs("div", { style: { marginBottom: "8px", display: "flex", alignItems: "flex-start" }, children: [
1349
+ /* @__PURE__ */ g.jsx("span", { className: "me-2", style: { flexShrink: 0 }, children: c }),
1350
+ /* @__PURE__ */ g.jsxs("div", { style: { flex: 1, minWidth: 0 }, children: [
1351
+ /* @__PURE__ */ g.jsx("div", { className: "small text-muted", children: m }),
1352
+ /* @__PURE__ */ g.jsx(
1353
+ "div",
1354
+ {
1355
+ className: "font-monospace small text-truncate",
1356
+ style: { maxWidth: "100%" },
1357
+ title: l,
1358
+ children: E.includes("URL") ? /* @__PURE__ */ g.jsx(
1359
+ "a",
1360
+ {
1361
+ href: l,
1362
+ target: "_blank",
1363
+ rel: "noopener noreferrer",
1364
+ style: { color: "#007bff" },
1365
+ children: _
1366
+ }
1367
+ ) : _
1368
+ }
1369
+ )
1370
+ ] })
1371
+ ] }, E);
1372
+ }) }),
1373
+ f.length === 0 && /* @__PURE__ */ g.jsx("div", { className: "text-center text-muted py-2 small", children: "Нет информации о версии" }),
1374
+ /* @__PURE__ */ g.jsx("div", { style: {
1375
+ marginTop: "12px",
1376
+ paddingTop: "8px",
1377
+ borderTop: "1px solid #dee2e6",
1378
+ textAlign: "center",
1379
+ fontSize: "12px",
1380
+ color: "#6c757d"
1381
+ }, children: "IngoBank DevOps Platform" }),
1382
+ /* @__PURE__ */ g.jsx(
1383
+ "button",
1384
+ {
1385
+ onClick: () => d(!1),
1386
+ style: {
1387
+ position: "absolute",
1388
+ top: "8px",
1389
+ right: "8px",
1390
+ background: "transparent",
1391
+ border: "none",
1392
+ cursor: "pointer",
1393
+ fontSize: "16px",
1394
+ color: "#6c757d"
1395
+ },
1396
+ children: "×"
1397
+ }
1398
+ )
1399
+ ]
1400
+ }
1401
+ ),
1402
+ a && /* @__PURE__ */ g.jsx(
1403
+ "div",
1404
+ {
1405
+ onClick: () => d(!1),
1406
+ style: {
1407
+ position: "fixed",
1408
+ top: 0,
1409
+ left: 0,
1410
+ right: 0,
1411
+ bottom: 0,
1412
+ zIndex: 999
1413
+ }
1414
+ }
1415
+ )
1416
+ ] });
1417
+ }
1418
+ const _e = "platform-kit", tt = Lt(null);
1419
+ function hr({ children: t }) {
1420
+ const [r, o] = R([]), u = typeof window < "u" && window.__MF_NAME__ || _e, a = k((c, _, w, N) => ({
1421
+ id: `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
1422
+ type: c,
1423
+ title: _,
1424
+ message: w,
1425
+ mfeName: u,
1426
+ timestamp: Date.now(),
1427
+ duration: N
1428
+ }), [u]), d = k((c) => {
1429
+ o((w) => [...w, c].slice(0, 5));
1430
+ const _ = c.duration || 5e3;
1431
+ _ > 0 && setTimeout(() => {
1432
+ o((w) => w.filter((N) => N.id !== c.id));
1433
+ }, _);
1434
+ }, []), s = k((c) => {
1435
+ const _ = a(c.type, c.title, c.message, c.duration);
1436
+ d(_), typeof window < "u" && window.dispatchEvent(new CustomEvent("mfe-notification", {
1437
+ detail: _,
1438
+ bubbles: !0
1439
+ }));
1440
+ }, [a, d]), x = k((c, _ = "Успешно") => {
1441
+ s({ type: "success", title: _, message: c });
1442
+ }, [s]), f = k((c, _ = "Ошибка") => {
1443
+ s({ type: "error", title: _, message: c });
1444
+ }, [s]), E = k((c, _ = "Предупреждение") => {
1445
+ s({ type: "warning", title: _, message: c });
1446
+ }, [s]), l = k((c, _ = "Информация") => {
1447
+ s({ type: "info", title: _, message: c });
1448
+ }, [s]), m = k((c) => {
1449
+ o((_) => _.filter((w) => w.id !== c));
1450
+ }, []);
1451
+ return V(() => {
1452
+ if (typeof window > "u") return;
1453
+ const c = (_) => {
1454
+ const w = _.detail;
1455
+ if (w && w.type && w.title && w.message) {
1456
+ const N = {
1457
+ ...w,
1458
+ id: `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`
1459
+ };
1460
+ d(N);
1461
+ }
1462
+ };
1463
+ return window.addEventListener("mfe-notification", c), () => {
1464
+ window.removeEventListener("mfe-notification", c);
1465
+ };
1466
+ }, [d]), /* @__PURE__ */ g.jsxs(tt.Provider, { value: {
1467
+ notify: s,
1468
+ notifySuccess: x,
1469
+ notifyError: f,
1470
+ notifyWarning: E,
1471
+ notifyInfo: l,
1472
+ removeNotification: m
1473
+ }, children: [
1474
+ t,
1475
+ r.length > 0 && /* @__PURE__ */ g.jsx(
1476
+ "div",
1477
+ {
1478
+ style: {
1479
+ position: "fixed",
1480
+ top: "80px",
1481
+ right: "20px",
1482
+ zIndex: 9998,
1483
+ maxWidth: "400px",
1484
+ width: "100%",
1485
+ display: "flex",
1486
+ flexDirection: "column",
1487
+ gap: "8px",
1488
+ pointerEvents: "none"
1489
+ },
1490
+ children: r.map((c) => /* @__PURE__ */ g.jsxs(
1491
+ "div",
1492
+ {
1493
+ className: `notification notification-${c.type}`,
1494
+ style: {
1495
+ pointerEvents: "auto",
1496
+ padding: "12px 16px",
1497
+ borderRadius: "8px",
1498
+ background: c.type === "success" ? "#d4edda" : c.type === "error" ? "#f8d7da" : c.type === "warning" ? "#fff3cd" : "#d1ecf1",
1499
+ color: c.type === "success" ? "#155724" : c.type === "error" ? "#721c24" : c.type === "warning" ? "#856404" : "#0c5460",
1500
+ boxShadow: "0 4px 12px rgba(0,0,0,0.15)",
1501
+ display: "flex",
1502
+ alignItems: "flex-start",
1503
+ gap: "12px"
1504
+ },
1505
+ children: [
1506
+ /* @__PURE__ */ g.jsxs("div", { style: { flex: 1 }, children: [
1507
+ /* @__PURE__ */ g.jsx("strong", { style: { display: "block", marginBottom: "4px" }, children: c.title }),
1508
+ /* @__PURE__ */ g.jsx("p", { style: { margin: 0, fontSize: "14px" }, children: c.message }),
1509
+ /* @__PURE__ */ g.jsx("small", { style: { opacity: 0.7, fontSize: "12px" }, children: c.mfeName })
1510
+ ] }),
1511
+ /* @__PURE__ */ g.jsx(
1512
+ "button",
1513
+ {
1514
+ onClick: () => m(c.id),
1515
+ style: {
1516
+ background: "transparent",
1517
+ border: "none",
1518
+ cursor: "pointer",
1519
+ fontSize: "18px",
1520
+ lineHeight: 1,
1521
+ opacity: 0.5
1522
+ },
1523
+ children: "×"
1524
+ }
1525
+ )
1526
+ ]
1527
+ },
1528
+ c.id
1529
+ ))
1530
+ }
1531
+ )
1532
+ ] });
1533
+ }
1534
+ function gr() {
1535
+ const t = Ut(tt);
1536
+ return t || {
1537
+ notify: () => {
1538
+ },
1539
+ notifySuccess: () => {
1540
+ },
1541
+ notifyError: () => {
1542
+ },
1543
+ notifyWarning: () => {
1544
+ },
1545
+ notifyInfo: () => {
1546
+ },
1547
+ removeNotification: () => {
1548
+ }
1549
+ };
1550
+ }
1551
+ function mr(t) {
1552
+ if (typeof window > "u") return;
1553
+ const r = window.__MF_NAME__ || _e, o = {
1554
+ ...t,
1555
+ mfeName: r,
1556
+ timestamp: Date.now()
1557
+ };
1558
+ window.dispatchEvent(new CustomEvent("mfe-notification", {
1559
+ detail: o,
1560
+ bubbles: !0
1561
+ }));
1562
+ }
1563
+ const rt = "platform-kit", q = {
1564
+ log: (...t) => {
1565
+ },
1566
+ warn: (...t) => {
1567
+ },
1568
+ error: (...t) => {
1569
+ console.error(`[${rt}]`, ...t);
1570
+ },
1571
+ info: (...t) => {
1572
+ }
1573
+ };
1574
+ function Kt() {
1575
+ if (typeof window > "u")
1576
+ return { isAuthenticated: !1 };
1577
+ const t = window.__SHELL_AUTH_INSTANCE__;
1578
+ if (t)
1579
+ return t;
1580
+ const r = window.__SHELL_AUTH__;
1581
+ return r?.authInstance ? r.authInstance : { isAuthenticated: !1 };
1582
+ }
1583
+ function Xt() {
1584
+ if (typeof window > "u") return;
1585
+ const t = window.__SHELL_AUTH_INSTANCE__;
1586
+ t?.signinRedirect ? t.signinRedirect().catch((r) => {
1587
+ q.error("Failed to redirect to login:", r);
1588
+ }) : window.location.href = "/";
1589
+ }
1590
+ function Zt(t) {
1591
+ const r = t.response;
1592
+ let o = "unknown";
1593
+ return r ? r.status === 401 ? o = "unauthorized" : r.status === 403 ? o = "forbidden" : r.status === 404 ? o = "not_found" : r.status >= 500 && (o = "server") : o = "network", {
1594
+ message: r?.data?.message ?? t.message ?? "Unknown error",
1595
+ code: r?.data?.code,
1596
+ status: r?.status,
1597
+ type: o,
1598
+ timestamp: Date.now(),
1599
+ url: t.config?.url
1600
+ };
1601
+ }
1602
+ function Qt(t = {}) {
1603
+ const r = t.name || rt, o = {
1604
+ log: (...a) => q.log(`[API:${r}]`, ...a),
1605
+ warn: (...a) => q.warn(`[API:${r}]`, ...a),
1606
+ error: (...a) => q.error(`[API:${r}]`, ...a),
1607
+ info: (...a) => q.info(`[API:${r}]`, ...a)
1608
+ }, u = Vt.create({
1609
+ timeout: t.timeout ?? 1e4,
1610
+ baseURL: t.baseURL ?? "",
1611
+ headers: {
1612
+ "Content-Type": "application/json"
1613
+ }
1614
+ });
1615
+ return u.interceptors.request.use(
1616
+ (a) => {
1617
+ const d = Kt();
1618
+ if (d?.isAuthenticated) {
1619
+ const s = d.user?.profile?.access_token;
1620
+ s && a.headers && (a.headers.Authorization = `Bearer ${s}`, o.info("Auth token attached"));
1621
+ } else
1622
+ o.info("User not authenticated - request without token");
1623
+ return o.log(`${a.method?.toUpperCase()} ${a.url}`), a;
1624
+ },
1625
+ (a) => (o.error("Request interceptor error:", a.message), Promise.reject(a))
1626
+ ), u.interceptors.response.use(
1627
+ (a) => (o.log(`Response ${a.status}:`, a.config.url), a),
1628
+ (a) => {
1629
+ const d = a.response?.status, s = a.config?.url;
1630
+ return d === 401 ? (o.warn("401 Unauthorized - triggering re-auth"), Xt()) : d === 403 ? o.warn("403 Forbidden - insufficient permissions") : d === 404 ? o.warn("404 Not found:", s) : d === 429 ? o.warn("429 Rate limited") : d === 500 ? o.error("500 Server error:", s) : a.response ? o.warn(`Error ${d}:`, a.message) : o.error("Network error - backend may be unavailable:", s), Promise.reject(Zt(a));
1631
+ }
1632
+ ), u;
1633
+ }
1634
+ const oe = Qt();
1635
+ async function _r(t, r, o = oe) {
1636
+ const u = await o.get(t, { params: r });
1637
+ return {
1638
+ data: u.data,
1639
+ status: u.status,
1640
+ ok: u.status >= 200 && u.status < 300
1641
+ };
1642
+ }
1643
+ async function vr(t, r, o = oe) {
1644
+ const u = await o.post(t, r);
1645
+ return {
1646
+ data: u.data,
1647
+ status: u.status,
1648
+ ok: u.status >= 200 && u.status < 300
1649
+ };
1650
+ }
1651
+ async function Er(t, r, o = oe) {
1652
+ const u = await o.put(t, r);
1653
+ return {
1654
+ data: u.data,
1655
+ status: u.status,
1656
+ ok: u.status >= 200 && u.status < 300
1657
+ };
1658
+ }
1659
+ async function yr(t, r = oe) {
1660
+ const o = await r.delete(t);
1661
+ return {
1662
+ data: o.data,
1663
+ status: o.status,
1664
+ ok: o.status >= 200 && o.status < 300
1665
+ };
1666
+ }
1667
+ function se(t, r) {
1668
+ const o = r?.prefix ? `[${r.prefix}]` : `[${t}]`;
1669
+ return {
1670
+ log: (...u) => {
1671
+ },
1672
+ warn: (...u) => {
1673
+ },
1674
+ error: (...u) => {
1675
+ console.error(o, ...u);
1676
+ },
1677
+ info: (...u) => {
1678
+ }
1679
+ };
1680
+ }
1681
+ const wr = se("platform-kit", { prefix: "AUTH" }), br = se("platform-kit", { prefix: "API" }), xr = se("platform-kit", { prefix: "ERROR" }), Sr = se("platform-kit", { prefix: "INFO" }), er = {}, tr = {
1682
+ log: (...t) => {
1683
+ },
1684
+ warn: (...t) => {
1685
+ },
1686
+ error: (...t) => {
1687
+ console.error("[getMfeName]", ...t);
1688
+ }
1689
+ };
1690
+ function Ee(t) {
1691
+ return t ? t.mfeName ? t.mfeName : t.name ? t.name.replace("@ib-dop/", "") : null : null;
1692
+ }
1693
+ function nt() {
1694
+ if (typeof window > "u") return null;
1695
+ const t = window;
1696
+ return t.__MF_NAME__ ? t.__MF_NAME__ : null;
1697
+ }
1698
+ function ot() {
1699
+ if (typeof window > "u") return null;
1700
+ try {
1701
+ const t = sessionStorage.getItem("mf-config");
1702
+ if (t) {
1703
+ const r = JSON.parse(t);
1704
+ if (r.mfeName) return r.mfeName;
1705
+ if (r.name) return r.name;
1706
+ if (r.appName) return r.appName;
1707
+ }
1708
+ } catch {
1709
+ }
1710
+ return null;
1711
+ }
1712
+ function ye() {
1713
+ const t = er;
1714
+ return t.VITE_MFE_NAME ? String(t.VITE_MFE_NAME) : t.MFE_NAME ? String(t.MFE_NAME) : null;
1715
+ }
1716
+ let re = null, ve = !1;
1717
+ function rr(t, r) {
1718
+ const o = Ee(t);
1719
+ if (o)
1720
+ return o;
1721
+ if (ve && re)
1722
+ return re;
1723
+ const u = [
1724
+ { source: "window.__MF_NAME__", value: nt() },
1725
+ { source: "sessionStorage.mf-config", value: ot() },
1726
+ { source: "import.meta.env.VITE_MFE_NAME", value: ye() }
1727
+ ];
1728
+ for (const { source: d, value: s } of u)
1729
+ if (s)
1730
+ return re = s, ve = !0, s;
1731
+ if (r)
1732
+ return r;
1733
+ const a = "Cannot determine MFE name. Please pass mfeName in props, set window.__MF_NAME__, sessionStorage.mf-config, or VITE_MFE_NAME";
1734
+ throw tr.error(a), new Error(a);
1735
+ }
1736
+ function Ar(t) {
1737
+ return rr(t);
1738
+ }
1739
+ function nr(t) {
1740
+ return Ee(t) ? "props.mfeName" : nt() ? "window.__MF_NAME__" : ot() ? "sessionStorage.mf-config" : ye() ? "import.meta.env.VITE_MFE_NAME" : null;
1741
+ }
1742
+ function Tr(t) {
1743
+ return nr(t) !== null;
1744
+ }
1745
+ function Rr() {
1746
+ re = null, ve = !1;
1747
+ }
1748
+ function Cr(t) {
1749
+ const r = [];
1750
+ return Ee(t) && r.push("props.mfeName"), typeof window < "u" && (window.__MF_NAME__ && r.push("window.__MF_NAME__"), sessionStorage.getItem("mf-config") && r.push("sessionStorage.mf-config")), ye() && r.push("import.meta.env.VITE_MFE_NAME"), r;
1751
+ }
1752
+ export {
1753
+ dr as ErrorBoundary,
1754
+ hr as NotificationProvider,
1755
+ pr as VersionInfo,
1756
+ oe as api,
1757
+ br as apiLogger,
1758
+ wr as authLogger,
1759
+ Qt as createApiClient,
1760
+ se as createMfLogger,
1761
+ yr as del,
1762
+ mr as dispatchNotification,
1763
+ xr as errorLogger,
1764
+ _r as get,
1765
+ Cr as getAllMfeNameSources,
1766
+ he as getAuth,
1767
+ rr as getMfeName,
1768
+ nr as getMfeNameSource,
1769
+ Tr as hasMfeName,
1770
+ Sr as infoLogger,
1771
+ vr as post,
1772
+ Er as put,
1773
+ Ar as requireMfeName,
1774
+ Rr as resetMfeNameCache,
1775
+ ir as useApi,
1776
+ lr as useFeatureAdmin,
1777
+ cr as useFeatures,
1778
+ zt as useInfoData,
1779
+ fr as useMicrofrontendsFeatures,
1780
+ gr as useNotification,
1781
+ ur as usePermissions,
1782
+ ne as useShellAuth,
1783
+ ar as useV1Config
1784
+ };