@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.
@@ -0,0 +1,445 @@
1
+ /**
2
+ * Hook for working with feature toggles
3
+ */
4
+
5
+ import { useState, useEffect, useCallback, useMemo } from 'react'
6
+ import { useShellAuth } from './useShellAuth'
7
+ import type {
8
+ FeatureToggleInfo,
9
+ FeaturesResponse,
10
+ FeatureToggleAdmin,
11
+ FeatureAdminResponse,
12
+ FeatureCreateRequest,
13
+ FeatureUpdateRequest,
14
+ MicrofrontendWithFeatures,
15
+ MicrofrontendsFeaturesResponse,
16
+ } from '../types'
17
+
18
+ /**
19
+ * Result of useFeatures hook
20
+ */
21
+ export interface UseFeaturesResult {
22
+ features: FeatureToggleInfo[]
23
+ totalCount: number
24
+ userRoles: string[]
25
+ isLoading: boolean
26
+ error: string | null
27
+ refetch: () => Promise<void>
28
+ isFeatureEnabled: (featureName: string) => boolean
29
+ getFeaturesByMf: (mfName: string) => FeatureToggleInfo[]
30
+ }
31
+
32
+ /**
33
+ * Hook to get feature toggles for the current user
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * import { useFeatures } from '@ib-dop/platform-kit'
38
+ *
39
+ * function FeatureFlagComponent() {
40
+ * const { features, isFeatureEnabled, isLoading } = useFeatures()
41
+ *
42
+ * if (isLoading) return <Spinner />
43
+ *
44
+ * return (
45
+ * <div>
46
+ * {isFeatureEnabled('new-dashboard') && <NewDashboard />}
47
+ * {!isFeatureEnabled('new-dashboard') && <OldDashboard />}
48
+ * </div>
49
+ * )
50
+ * }
51
+ * ```
52
+ */
53
+ export function useFeatures(): UseFeaturesResult {
54
+ const auth = useShellAuth()
55
+ const [features, setFeatures] = useState<FeatureToggleInfo[]>([])
56
+ const [totalCount, setTotalCount] = useState(0)
57
+ const [userRoles, setUserRoles] = useState<string[]>([])
58
+ const [isLoading, setIsLoading] = useState(true)
59
+ const [error, setError] = useState<string | null>(null)
60
+
61
+ const fetchFeatures = useCallback(async () => {
62
+ if (!auth.isAuthenticated) {
63
+ console.debug('[useFeatures] Not authenticated')
64
+ setIsLoading(false)
65
+ return
66
+ }
67
+
68
+ setIsLoading(true)
69
+ setError(null)
70
+
71
+ try {
72
+ const headers: Record<string, string> = {
73
+ 'Content-Type': 'application/json',
74
+ }
75
+
76
+ const token = auth.user?.access_token
77
+ if (token) {
78
+ headers['Authorization'] = `Bearer ${token}`
79
+ }
80
+
81
+ const response = await fetch('/api/features', { headers })
82
+
83
+ if (!response.ok) {
84
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`)
85
+ }
86
+
87
+ const result: FeaturesResponse = await response.json()
88
+ setFeatures(result.features || [])
89
+ setTotalCount(result.totalCount || 0)
90
+ setUserRoles(result.userRoles || [])
91
+ } catch (err) {
92
+ console.debug('Features fetch error:', err)
93
+ setError(err instanceof Error ? err.message : String(err))
94
+ setFeatures([])
95
+ setUserRoles([])
96
+ } finally {
97
+ setIsLoading(false)
98
+ }
99
+ }, [auth.isAuthenticated, auth.user?.access_token])
100
+
101
+ useEffect(() => {
102
+ fetchFeatures()
103
+ }, [fetchFeatures])
104
+
105
+ const isFeatureEnabled = useCallback(
106
+ (featureName: string): boolean => {
107
+ const feature = features.find((f) => f.name === featureName)
108
+ return feature?.userEnabled ?? false
109
+ },
110
+ [features]
111
+ )
112
+
113
+ const getFeaturesByMf = useCallback(
114
+ (mfName: string): FeatureToggleInfo[] => {
115
+ return features.filter((f) => f.mfDependencies?.includes(mfName))
116
+ },
117
+ [features]
118
+ )
119
+
120
+ return {
121
+ features,
122
+ totalCount,
123
+ userRoles,
124
+ isLoading,
125
+ error,
126
+ refetch: fetchFeatures,
127
+ isFeatureEnabled,
128
+ getFeaturesByMf,
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Result of useFeatureAdmin hook
134
+ */
135
+ export interface UseFeatureAdminResult {
136
+ features: FeatureToggleAdmin[]
137
+ microfrontends: string[]
138
+ isAdmin: boolean
139
+ isLoading: boolean
140
+ error: string | null
141
+ refetch: () => Promise<void>
142
+ createFeature: (feature: FeatureCreateRequest) => Promise<boolean>
143
+ updateFeature: (name: string, feature: FeatureUpdateRequest) => Promise<boolean>
144
+ toggleFeature: (name: string, enabled: boolean) => Promise<boolean>
145
+ deleteFeature: (name: string) => Promise<boolean>
146
+ }
147
+
148
+ /**
149
+ * Hook for admin operations with feature toggles
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * import { useFeatureAdmin } from '@ib-dop/platform-kit'
154
+ *
155
+ * function AdminPanel() {
156
+ * const {
157
+ * features,
158
+ * isAdmin,
159
+ * isLoading,
160
+ * toggleFeature
161
+ * } = useFeatureAdmin()
162
+ *
163
+ * if (isLoading) return <Spinner />
164
+ * if (!isAdmin) return <AccessDenied />
165
+ *
166
+ * return (
167
+ * <table>
168
+ * {features.map(f => (
169
+ * <tr key={f.name}>
170
+ * <td>{f.name}</td>
171
+ * <td>{f.enabled ? 'ON' : 'OFF'}</td>
172
+ * <button onClick={() => toggleFeature(f.name, !f.enabled)}>
173
+ * Toggle
174
+ * </button>
175
+ * </tr>
176
+ * ))}
177
+ * </table>
178
+ * )
179
+ * }
180
+ * ```
181
+ */
182
+ export function useFeatureAdmin(): UseFeatureAdminResult {
183
+ const auth = useShellAuth()
184
+ const [features, setFeatures] = useState<FeatureToggleAdmin[]>([])
185
+ const [microfrontends, setMicrofrontends] = useState<string[]>([])
186
+ const [isAdmin, setIsAdmin] = useState(false)
187
+ const [isLoading, setIsLoading] = useState(true)
188
+ const [error, setError] = useState<string | null>(null)
189
+
190
+ const fetchFeatures = useCallback(async () => {
191
+ if (!auth.isAuthenticated) {
192
+ console.debug('[useFeatureAdmin] Not authenticated')
193
+ setIsLoading(false)
194
+ return
195
+ }
196
+
197
+ setIsLoading(true)
198
+ setError(null)
199
+
200
+ try {
201
+ const headers: Record<string, string> = {
202
+ 'Content-Type': 'application/json',
203
+ }
204
+
205
+ const token = auth.user?.access_token
206
+ if (token) {
207
+ headers['Authorization'] = `Bearer ${token}`
208
+ }
209
+
210
+ const response = await fetch('/api/features/admin', { headers })
211
+
212
+ if (!response.ok) {
213
+ if (response.status === 403) {
214
+ console.warn('[useFeatureAdmin] 403 Forbidden - checking if token has admin role')
215
+ setIsAdmin(false)
216
+ setFeatures([])
217
+ setMicrofrontends([])
218
+ setIsLoading(false)
219
+ return
220
+ }
221
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`)
222
+ }
223
+
224
+ const result: FeatureAdminResponse = await response.json()
225
+ setFeatures(result.featureToggles || [])
226
+ setMicrofrontends(result.microfrontends || [])
227
+ setIsAdmin(result.isAdmin || false)
228
+ } catch (err) {
229
+ console.debug('FeatureAdmin fetch error:', err)
230
+ setFeatures([])
231
+ setMicrofrontends([])
232
+ setIsAdmin(false)
233
+ } finally {
234
+ setIsLoading(false)
235
+ }
236
+ }, [auth.isAuthenticated, auth.user?.access_token])
237
+
238
+ const createFeature = useCallback(
239
+ async (feature: FeatureCreateRequest): Promise<boolean> => {
240
+ try {
241
+ const headers: Record<string, string> = {
242
+ 'Content-Type': 'application/json',
243
+ }
244
+ const token = auth.user?.access_token
245
+ if (token) {
246
+ headers['Authorization'] = `Bearer ${token}`
247
+ }
248
+
249
+ const response = await fetch('/api/features/admin', {
250
+ method: 'POST',
251
+ headers,
252
+ body: JSON.stringify(feature),
253
+ })
254
+
255
+ if (!response.ok) {
256
+ const errorData = await response.json().catch(() => ({}))
257
+ throw new Error(errorData.error || `HTTP ${response.status}`)
258
+ }
259
+
260
+ await fetchFeatures()
261
+ return true
262
+ } catch (err) {
263
+ setError(err instanceof Error ? err.message : String(err))
264
+ return false
265
+ }
266
+ },
267
+ [fetchFeatures]
268
+ )
269
+
270
+ const updateFeature = useCallback(
271
+ async (name: string, feature: FeatureUpdateRequest): Promise<boolean> => {
272
+ try {
273
+ const headers: Record<string, string> = {
274
+ 'Content-Type': 'application/json',
275
+ }
276
+ const token = auth.user?.access_token
277
+ if (token) {
278
+ headers['Authorization'] = `Bearer ${token}`
279
+ }
280
+
281
+ const response = await fetch(`/api/features/admin/${encodeURIComponent(name)}`, {
282
+ method: 'PUT',
283
+ headers,
284
+ body: JSON.stringify(feature),
285
+ })
286
+
287
+ if (!response.ok) {
288
+ const errorData = await response.json().catch(() => ({}))
289
+ throw new Error(errorData.error || `HTTP ${response.status}`)
290
+ }
291
+
292
+ await fetchFeatures()
293
+ return true
294
+ } catch (err) {
295
+ setError(err instanceof Error ? err.message : String(err))
296
+ return false
297
+ }
298
+ },
299
+ [fetchFeatures]
300
+ )
301
+
302
+ const toggleFeature = useCallback(
303
+ async (name: string, enabled: boolean): Promise<boolean> => {
304
+ try {
305
+ const headers: Record<string, string> = {}
306
+ const token = auth.user?.access_token
307
+ if (token) {
308
+ headers['Authorization'] = `Bearer ${token}`
309
+ }
310
+
311
+ const response = await fetch(
312
+ `/api/features/admin/${encodeURIComponent(name)}/toggle?enabled=${enabled}`,
313
+ {
314
+ method: 'POST',
315
+ headers,
316
+ }
317
+ )
318
+
319
+ if (!response.ok) {
320
+ const errorData = await response.json().catch(() => ({}))
321
+ throw new Error(errorData.error || `HTTP ${response.status}`)
322
+ }
323
+
324
+ await fetchFeatures()
325
+ return true
326
+ } catch (err) {
327
+ setError(err instanceof Error ? err.message : String(err))
328
+ return false
329
+ }
330
+ },
331
+ [fetchFeatures]
332
+ )
333
+
334
+ const deleteFeature = useCallback(
335
+ async (name: string): Promise<boolean> => {
336
+ try {
337
+ const headers: Record<string, string> = {}
338
+ const token = auth.user?.access_token
339
+ if (token) {
340
+ headers['Authorization'] = `Bearer ${token}`
341
+ }
342
+
343
+ const response = await fetch(`/api/features/admin/${encodeURIComponent(name)}`, {
344
+ method: 'DELETE',
345
+ headers,
346
+ })
347
+
348
+ if (!response.ok) {
349
+ const errorData = await response.json().catch(() => ({}))
350
+ throw new Error(errorData.error || `HTTP ${response.status}`)
351
+ }
352
+
353
+ await fetchFeatures()
354
+ return true
355
+ } catch (err) {
356
+ setError(err instanceof Error ? err.message : String(err))
357
+ return false
358
+ }
359
+ },
360
+ [fetchFeatures]
361
+ )
362
+
363
+ useEffect(() => {
364
+ fetchFeatures()
365
+ }, [fetchFeatures])
366
+
367
+ return {
368
+ features,
369
+ microfrontends,
370
+ isAdmin,
371
+ isLoading,
372
+ error,
373
+ refetch: fetchFeatures,
374
+ createFeature,
375
+ updateFeature,
376
+ toggleFeature,
377
+ deleteFeature,
378
+ }
379
+ }
380
+
381
+ /**
382
+ * Hook to get microfrontends with their features
383
+ */
384
+ export interface UseMicrofrontendsFeaturesResult {
385
+ microfrontends: MicrofrontendWithFeatures[]
386
+ totalCount: number
387
+ isLoading: boolean
388
+ error: string | null
389
+ refetch: () => Promise<void>
390
+ }
391
+
392
+ export function useMicrofrontendsFeatures(): UseMicrofrontendsFeaturesResult {
393
+ const auth = useShellAuth()
394
+ const [microfrontends, setMicrofrontends] = useState<MicrofrontendWithFeatures[]>([])
395
+ const [totalCount, setTotalCount] = useState(0)
396
+ const [isLoading, setIsLoading] = useState(true)
397
+ const [error, setError] = useState<string | null>(null)
398
+
399
+ const fetchData = useCallback(async () => {
400
+ if (!auth.isAuthenticated) {
401
+ setIsLoading(false)
402
+ return
403
+ }
404
+
405
+ setIsLoading(true)
406
+ setError(null)
407
+
408
+ try {
409
+ const headers: Record<string, string> = {
410
+ 'Content-Type': 'application/json',
411
+ }
412
+
413
+ const token = auth.user?.access_token
414
+ if (token) {
415
+ headers['Authorization'] = `Bearer ${token}`
416
+ }
417
+
418
+ const response = await fetch('/api/features/microfrontends', { headers })
419
+
420
+ if (!response.ok) {
421
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`)
422
+ }
423
+
424
+ const result: MicrofrontendsFeaturesResponse = await response.json()
425
+ setMicrofrontends(result.microfrontends || [])
426
+ setTotalCount(result.totalCount || 0)
427
+ } catch (err) {
428
+ setError(err instanceof Error ? err.message : String(err))
429
+ } finally {
430
+ setIsLoading(false)
431
+ }
432
+ }, [auth.isAuthenticated, auth.user?.access_token])
433
+
434
+ useEffect(() => {
435
+ fetchData()
436
+ }, [fetchData])
437
+
438
+ return {
439
+ microfrontends,
440
+ totalCount,
441
+ isLoading,
442
+ error,
443
+ refetch: fetchData,
444
+ }
445
+ }
@@ -225,3 +225,102 @@ export type MfeNameSource =
225
225
  | 'sessionStorage.mf-config'
226
226
  | 'import.meta.env.VITE_MFE_NAME'
227
227
  | 'import.meta.env.MFE_NAME'
228
+
229
+ // ==================== Feature Types ====================
230
+
231
+ /**
232
+ * Feature toggle for a user
233
+ */
234
+ export interface FeatureToggleInfo {
235
+ name: string
236
+ enabled: boolean
237
+ description?: string
238
+ roles?: string[]
239
+ percentage?: number
240
+ microfrontends?: string[]
241
+ userEnabled: boolean
242
+ mfDependencies?: string[]
243
+ }
244
+
245
+ /**
246
+ * Response from /api/features endpoint
247
+ */
248
+ export interface FeaturesResponse {
249
+ features: FeatureToggleInfo[]
250
+ totalCount: number
251
+ userRoles: string[]
252
+ }
253
+
254
+ /**
255
+ * Admin feature toggle (full info)
256
+ */
257
+ export interface FeatureToggleAdmin {
258
+ name: string
259
+ enabled: boolean
260
+ description: string
261
+ roles: string[]
262
+ percentage: number
263
+ microfrontends: string[]
264
+ mfDependencies: string[]
265
+ }
266
+
267
+ /**
268
+ * Admin response from /api/features/admin endpoint
269
+ */
270
+ export interface FeatureAdminResponse {
271
+ featureToggles: FeatureToggleAdmin[]
272
+ isAdmin: boolean
273
+ microfrontends: string[]
274
+ totalCount: number
275
+ }
276
+
277
+ /**
278
+ * Feature creation request
279
+ */
280
+ export interface FeatureCreateRequest {
281
+ name: string
282
+ enabled?: boolean
283
+ description?: string
284
+ roles?: string[]
285
+ percentage?: number
286
+ microfrontends?: string[]
287
+ }
288
+
289
+ /**
290
+ * Feature update request
291
+ */
292
+ export interface FeatureUpdateRequest {
293
+ enabled?: boolean
294
+ description?: string
295
+ roles?: string[]
296
+ percentage?: number
297
+ microfrontends?: string[]
298
+ }
299
+
300
+ /**
301
+ * Microfrontend with its features
302
+ */
303
+ export interface MicrofrontendWithFeatures {
304
+ name: string
305
+ description?: string
306
+ featureToggles: string[]
307
+ features: FeatureInfo[]
308
+ }
309
+
310
+ /**
311
+ * Feature info for a microfrontend
312
+ */
313
+ export interface FeatureInfo {
314
+ name: string
315
+ enabled: boolean
316
+ global: boolean
317
+ required: boolean
318
+ }
319
+
320
+ /**
321
+ * Response from /api/features/microfrontends endpoint
322
+ */
323
+ export interface MicrofrontendsFeaturesResponse {
324
+ microfrontends: MicrofrontendWithFeatures[]
325
+ totalCount: number
326
+ }
package/dist/index.cjs.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),Ft=require("axios"),Ve={log:(...t)=>{},warn:(...t)=>{}};function Q(){if(typeof window>"u")return null;const t=window;if(t.__SHELL_AUTH_INSTANCE__)return t.__SHELL_AUTH_INSTANCE__;const r=window;return r.__SHELL_AUTH__?.authInstance?r.__SHELL_AUTH__.authInstance:null}function ze(){const[t,r]=m.useState(null),[o,u]=m.useState(!0),s=m.useRef(0),f=20,i=m.useCallback(()=>Q(),[]);m.useEffect(()=>{const y=i();if(y){r(y),u(!1);return}const g=l=>{r(l.detail),u(!1)},S=setInterval(()=>{s.current++;const l=i();l?(Ve.log("Auth found via polling, attempts:",s.current),r(l),u(!1),clearInterval(S)):s.current>=f&&(u(!1),clearInterval(S))},500);return window.addEventListener("shell-auth-ready",g),()=>{clearInterval(S),window.removeEventListener("shell-auth-ready",g)}},[i]);const p=t||{user:null,isAuthenticated:!1,isLoading:o,signinRedirect:async()=>{const y=Q();y?.signinRedirect?await y.signinRedirect():typeof window<"u"&&(window.location.href="/")},removeUser:async()=>{const y=Q();y?.removeUser&&await y.removeUser()}};return Ve.log("Auth result:",{isAuthenticated:p.isAuthenticated,isLoading:p.isLoading}),p}const Lt={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[useInfoData]",...t)}};function $t(t){if(t)return t;if(typeof window<"u"){const r=window;if(r.__MF_NAME__)return r.__MF_NAME__}return"unknown-mfe"}function Ye(t){const[r,o]=m.useState(null),[u,s]=m.useState(!0),[f,i]=m.useState(null),b=m.useCallback(()=>{const y=$t(t?.mfeName).replace("@ib-dop/","");s(!0),i(null),fetch(`/svc/${y}/info.json`).then(g=>{if(!g.ok)throw new Error(`HTTP ${g.status}: ${g.statusText}`);return g.json()}).then(g=>{o(g)}).catch(g=>{Lt.error("Failed to load info:",g),i(g instanceof Error?g.message:String(g))}).finally(()=>{s(!1)})},[t?.mfeName]);return m.useEffect(()=>{b()},[b]),{data:r,isLoading:u,error:f,refetch:b}}const ce={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[useV1Config]",...t)}},X={authority:"",client_id:"",environment:"development"};function Ut(){const[t,r]=m.useState(null),[o,u]=m.useState(!0),[s,f]=m.useState(null);return m.useEffect(()=>{(()=>{if(typeof sessionStorage>"u"){f("sessionStorage not available"),r(X),u(!1);return}try{const b=sessionStorage.getItem("config");if(b){const p=JSON.parse(b);r({...X,...p}),f(null),ce.log("Config loaded successfully")}else r(X),f("Config not found in sessionStorage"),ce.warn("Config not found in sessionStorage")}catch(b){ce.error("Error parsing config:",b),r(X),f("Error parsing config")}finally{u(!1)}})()},[]),{data:t,isLoading:o,error:s}}function Je(t){if(typeof window>"u")return;const r=window.__MF_NAME__||"unknown",o={...t,mfeName:r,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:o,bubbles:!0}))}function We(t,r){const o={network:{title:"Нет подключения",message:"Сервер недоступен. Проверьте подключение к интернету."},unauthorized:{title:"Требуется вход",message:"Ваша сессия истекла. Войдите в систему снова."},forbidden:{title:"Доступ запрещён",message:"У вас нет прав для выполнения этого действия."},not_found:{title:"Не найдено",message:"Запрошенный ресурс не найден."},server:{title:"Ошибка сервера",message:"Произошла ошибка на сервере. Попробуйте позже."},client:{title:"Ошибка",message:t.message||"Произошла ошибка при выполнении запроса."},unknown:{title:"Неизвестная ошибка",message:t.message||"Произошла неизвестная ошибка."}},u=o[t.type]||o.unknown;Je({type:t.type==="network"?"warning":"error",title:u.title,message:r?`${u.message} (${r})`:u.message})}function Vt(t,r={}){const{notifyOnError:o=!0,notifyOnSuccess:u=!1,successMessage:s,errorContext:f,onSuccess:i,onError:b}=r,[p,y]=m.useState(null),[g,S]=m.useState(null),[l,v]=m.useState(!1),C=g!==null,k=p!==null&&!l&&!C,te=m.useCallback(async()=>{v(!0),S(null);try{const x=await t();if(x.ok)return y(x.data),u&&s&&Je({type:"success",title:"Успешно",message:s}),i?.(x.data),x.data;{const O={message:x.data||"Request failed",status:x.status,type:"client",timestamp:Date.now()};return S(O),o&&We(O,f),b?.(O),null}}catch(x){const O=x;return S(O),o&&We(O,f),b?.(O),null}finally{v(!1)}},[t,o,u,s,f,i,b]),j=m.useCallback(()=>{y(null),S(null),v(!1)},[]);return{data:p,error:g,isLoading:l,isError:C,isSuccess:k,execute:te,reset:j}}const Wt={canView:["all"],canEdit:["ibdop-user","ibdop-admin","ibdop-devops"],canDelete:["ibdop-admin","ibdop-devops"],canAdmin:["ibdop-admin"],canViewSensitiveData:["ibdop-admin","ibdop-devops"],canExportData:["ibdop-user"],canManageUsers:["ibdop-admin"]};function Bt(t={}){const r=ze(),o=m.useMemo(()=>({...Wt,...t}),[t]),u=m.useMemo(()=>{const f=r.user?.profile?.realm_roles||r.user?.profile?.roles||[];return Array.isArray(f)?f:[f]},[r.user]),s=f=>f.includes("all")?!0:f.some(i=>u.includes(i));return{canView:s(o.canView),canEdit:s(o.canEdit),canDelete:s(o.canDelete),canAdmin:s(o.canAdmin),canViewSensitiveData:s(o.canViewSensitiveData),canExportData:s(o.canExportData),canManageUsers:s(o.canManageUsers)}}var Z={exports:{}},W={};var Be;function Ht(){if(Be)return W;Be=1;var t=m,r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),u=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,f={key:!0,ref:!0,__self:!0,__source:!0};function i(b,p,y){var g,S={},l=null,v=null;y!==void 0&&(l=""+y),p.key!==void 0&&(l=""+p.key),p.ref!==void 0&&(v=p.ref);for(g in p)u.call(p,g)&&!f.hasOwnProperty(g)&&(S[g]=p[g]);if(b&&b.defaultProps)for(g in p=b.defaultProps,p)S[g]===void 0&&(S[g]=p[g]);return{$$typeof:r,type:b,key:l,ref:v,props:S,_owner:s.current}}return W.Fragment=o,W.jsx=i,W.jsxs=i,W}var B={};var He;function Gt(){return He||(He=1,process.env.NODE_ENV!=="production"&&(function(){var t=m,r=Symbol.for("react.element"),o=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),b=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),l=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),C=Symbol.iterator,k="@@iterator";function te(e){if(e===null||typeof e!="object")return null;var n=C&&e[C]||e[k];return typeof n=="function"?n:null}var j=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(e){{for(var n=arguments.length,a=new Array(n>1?n-1:0),c=1;c<n;c++)a[c-1]=arguments[c];O("error",e,a)}}function O(e,n,a){{var c=j.ReactDebugCurrentFrame,E=c.getStackAddendum();E!==""&&(n+="%s",a=a.concat([E]));var w=a.map(function(_){return String(_)});w.unshift("Warning: "+n),Function.prototype.apply.call(console[e],console,w)}}var nt=!1,ot=!1,at=!1,it=!1,st=!1,he;he=Symbol.for("react.module.reference");function ut(e){return!!(typeof e=="string"||typeof e=="function"||e===u||e===f||st||e===s||e===y||e===g||it||e===v||nt||ot||at||typeof e=="object"&&e!==null&&(e.$$typeof===l||e.$$typeof===S||e.$$typeof===i||e.$$typeof===b||e.$$typeof===p||e.$$typeof===he||e.getModuleId!==void 0))}function lt(e,n,a){var c=e.displayName;if(c)return c;var E=n.displayName||n.name||"";return E!==""?a+"("+E+")":a}function _e(e){return e.displayName||"Context"}function P(e){if(e==null)return null;if(typeof e.tag=="number"&&x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case u:return"Fragment";case o:return"Portal";case f:return"Profiler";case s:return"StrictMode";case y:return"Suspense";case g:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case b:var n=e;return _e(n)+".Consumer";case i:var a=e;return _e(a._context)+".Provider";case p:return lt(e,e.render,"ForwardRef");case S:var c=e.displayName||null;return c!==null?c:P(e.type)||"Memo";case l:{var E=e,w=E._payload,_=E._init;try{return P(_(w))}catch{return null}}}return null}var D=Object.assign,U=0,ve,Ee,ye,we,be,xe,Se;function Re(){}Re.__reactDisabledLog=!0;function ct(){{if(U===0){ve=console.log,Ee=console.info,ye=console.warn,we=console.error,be=console.group,xe=console.groupCollapsed,Se=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Re,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}U++}}function ft(){{if(U--,U===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:D({},e,{value:ve}),info:D({},e,{value:Ee}),warn:D({},e,{value:ye}),error:D({},e,{value:we}),group:D({},e,{value:be}),groupCollapsed:D({},e,{value:xe}),groupEnd:D({},e,{value:Se})})}U<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var re=j.ReactCurrentDispatcher,ne;function Y(e,n,a){{if(ne===void 0)try{throw Error()}catch(E){var c=E.stack.trim().match(/\n( *(at )?)/);ne=c&&c[1]||""}return`
2
- `+ne+e}}var oe=!1,J;{var dt=typeof WeakMap=="function"?WeakMap:Map;J=new dt}function Ae(e,n){if(!e||oe)return"";{var a=J.get(e);if(a!==void 0)return a}var c;oe=!0;var E=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var w;w=re.current,re.current=null,ct();try{if(n){var _=function(){throw Error()};if(Object.defineProperty(_.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_,[])}catch(I){c=I}Reflect.construct(e,[],_)}else{try{_.call()}catch(I){c=I}e.call(_.prototype)}}else{try{throw Error()}catch(I){c=I}e()}}catch(I){if(I&&c&&typeof I.stack=="string"){for(var h=I.stack.split(`
3
- `),M=c.stack.split(`
4
- `),R=h.length-1,A=M.length-1;R>=1&&A>=0&&h[R]!==M[A];)A--;for(;R>=1&&A>=0;R--,A--)if(h[R]!==M[A]){if(R!==1||A!==1)do if(R--,A--,A<0||h[R]!==M[A]){var N=`
5
- `+h[R].replace(" at new "," at ");return e.displayName&&N.includes("<anonymous>")&&(N=N.replace("<anonymous>",e.displayName)),typeof e=="function"&&J.set(e,N),N}while(R>=1&&A>=0);break}}}finally{oe=!1,re.current=w,ft(),Error.prepareStackTrace=E}var $=e?e.displayName||e.name:"",F=$?Y($):"";return typeof e=="function"&&J.set(e,F),F}function pt(e,n,a){return Ae(e,!1)}function gt(e){var n=e.prototype;return!!(n&&n.isReactComponent)}function q(e,n,a){if(e==null)return"";if(typeof e=="function")return Ae(e,gt(e));if(typeof e=="string")return Y(e);switch(e){case y:return Y("Suspense");case g:return Y("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case p:return pt(e.render);case S:return q(e.type,n,a);case l:{var c=e,E=c._payload,w=c._init;try{return q(w(E),n,a)}catch{}}}return""}var V=Object.prototype.hasOwnProperty,Ce={},Me=j.ReactDebugCurrentFrame;function K(e){if(e){var n=e._owner,a=q(e.type,e._source,n?n.type:null);Me.setExtraStackFrame(a)}else Me.setExtraStackFrame(null)}function mt(e,n,a,c,E){{var w=Function.call.bind(V);for(var _ in e)if(w(e,_)){var h=void 0;try{if(typeof e[_]!="function"){var M=Error((c||"React class")+": "+a+" type `"+_+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[_]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw M.name="Invariant Violation",M}h=e[_](n,_,c,a,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(R){h=R}h&&!(h instanceof Error)&&(K(E),x("%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).",c||"React class",a,_,typeof h),K(null)),h instanceof Error&&!(h.message in Ce)&&(Ce[h.message]=!0,K(E),x("Failed %s type: %s",a,h.message),K(null))}}}var ht=Array.isArray;function ae(e){return ht(e)}function _t(e){{var n=typeof Symbol=="function"&&Symbol.toStringTag,a=n&&e[Symbol.toStringTag]||e.constructor.name||"Object";return a}}function vt(e){try{return Ie(e),!1}catch{return!0}}function Ie(e){return""+e}function Ne(e){if(vt(e))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",_t(e)),Ie(e)}var Te=j.ReactCurrentOwner,Et={key:!0,ref:!0,__self:!0,__source:!0},ke,Oe;function yt(e){if(V.call(e,"ref")){var n=Object.getOwnPropertyDescriptor(e,"ref").get;if(n&&n.isReactWarning)return!1}return e.ref!==void 0}function wt(e){if(V.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function bt(e,n){typeof e.ref=="string"&&Te.current}function xt(e,n){{var a=function(){ke||(ke=!0,x("%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))};a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}}function St(e,n){{var a=function(){Oe||(Oe=!0,x("%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))};a.isReactWarning=!0,Object.defineProperty(e,"ref",{get:a,configurable:!0})}}var Rt=function(e,n,a,c,E,w,_){var h={$$typeof:r,type:e,key:n,ref:a,props:_,_owner:w};return h._store={},Object.defineProperty(h._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(h,"_self",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.defineProperty(h,"_source",{configurable:!1,enumerable:!1,writable:!1,value:E}),Object.freeze&&(Object.freeze(h.props),Object.freeze(h)),h};function At(e,n,a,c,E){{var w,_={},h=null,M=null;a!==void 0&&(Ne(a),h=""+a),wt(n)&&(Ne(n.key),h=""+n.key),yt(n)&&(M=n.ref,bt(n,E));for(w in n)V.call(n,w)&&!Et.hasOwnProperty(w)&&(_[w]=n[w]);if(e&&e.defaultProps){var R=e.defaultProps;for(w in R)_[w]===void 0&&(_[w]=R[w])}if(h||M){var A=typeof e=="function"?e.displayName||e.name||"Unknown":e;h&&xt(_,A),M&&St(_,A)}return Rt(e,h,M,E,c,Te.current,_)}}var ie=j.ReactCurrentOwner,je=j.ReactDebugCurrentFrame;function L(e){if(e){var n=e._owner,a=q(e.type,e._source,n?n.type:null);je.setExtraStackFrame(a)}else je.setExtraStackFrame(null)}var se;se=!1;function ue(e){return typeof e=="object"&&e!==null&&e.$$typeof===r}function Pe(){{if(ie.current){var e=P(ie.current.type);if(e)return`
6
-
7
- Check the render method of \``+e+"`."}return""}}function Ct(e){return""}var De={};function Mt(e){{var n=Pe();if(!n){var a=typeof e=="string"?e:e.displayName||e.name;a&&(n=`
8
-
9
- Check the top-level render call using <`+a+">.")}return n}}function Fe(e,n){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var a=Mt(n);if(De[a])return;De[a]=!0;var c="";e&&e._owner&&e._owner!==ie.current&&(c=" It was passed a child from "+P(e._owner.type)+"."),L(e),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',a,c),L(null)}}function Le(e,n){{if(typeof e!="object")return;if(ae(e))for(var a=0;a<e.length;a++){var c=e[a];ue(c)&&Fe(c,n)}else if(ue(e))e._store&&(e._store.validated=!0);else if(e){var E=te(e);if(typeof E=="function"&&E!==e.entries)for(var w=E.call(e),_;!(_=w.next()).done;)ue(_.value)&&Fe(_.value,n)}}}function It(e){{var n=e.type;if(n==null||typeof n=="string")return;var a;if(typeof n=="function")a=n.propTypes;else if(typeof n=="object"&&(n.$$typeof===p||n.$$typeof===S))a=n.propTypes;else return;if(a){var c=P(n);mt(a,e.props,"prop",c,e)}else if(n.PropTypes!==void 0&&!se){se=!0;var E=P(n);x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",E||"Unknown")}typeof n.getDefaultProps=="function"&&!n.getDefaultProps.isReactClassApproved&&x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Nt(e){{for(var n=Object.keys(e.props),a=0;a<n.length;a++){var c=n[a];if(c!=="children"&&c!=="key"){L(e),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",c),L(null);break}}e.ref!==null&&(L(e),x("Invalid attribute `ref` supplied to `React.Fragment`."),L(null))}}var $e={};function Ue(e,n,a,c,E,w){{var _=ut(e);if(!_){var h="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(h+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var M=Ct();M?h+=M:h+=Pe();var R;e===null?R="null":ae(e)?R="array":e!==void 0&&e.$$typeof===r?(R="<"+(P(e.type)||"Unknown")+" />",h=" Did you accidentally export a JSX literal instead of a component?"):R=typeof e,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",R,h)}var A=At(e,n,a,E,w);if(A==null)return A;if(_){var N=n.children;if(N!==void 0)if(c)if(ae(N)){for(var $=0;$<N.length;$++)Le(N[$],e);Object.freeze&&Object.freeze(N)}else x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Le(N,e)}if(V.call(n,"key")){var F=P(e),I=Object.keys(n).filter(function(Dt){return Dt!=="key"}),le=I.length>0?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}";if(!$e[F+le]){var Pt=I.length>0?"{"+I.join(": ..., ")+": ...}":"{}";x(`A props object containing a "key" prop is being spread into JSX:
10
- let props = %s;
11
- <%s {...props} />
12
- React keys must be passed directly to JSX without using spread:
13
- let props = %s;
14
- <%s key={someKey} {...props} />`,le,F,Pt,F),$e[F+le]=!0}}return e===u?Nt(A):It(A),A}}function Tt(e,n,a){return Ue(e,n,a,!0)}function kt(e,n,a){return Ue(e,n,a,!1)}var Ot=kt,jt=Tt;B.Fragment=u,B.jsx=Ot,B.jsxs=jt})()),B}var Ge;function zt(){return Ge||(Ge=1,process.env.NODE_ENV==="production"?Z.exports=Ht():Z.exports=Gt()),Z.exports}var d=zt();const qe="platform-kit",Yt=!1,fe={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error(`[${qe}]`,...t)}};class Jt extends m.Component{hasDispatched=!1;constructor(r){super(r),this.state={hasError:!1}}getMfeName(){if(this.props.mfeName)return this.props.mfeName;if(typeof window<"u"){const r=window;if(r.__MF_NAME__)return r.__MF_NAME__}return qe}shouldShowDetails(){if(this.props.showDetails!==void 0)return this.props.showDetails;if(typeof sessionStorage<"u")try{const r=sessionStorage.getItem("config");if(r){const o=JSON.parse(r);if(o.showErrorDetails!==void 0)return o.showErrorDetails}}catch{}return Yt}dispatchError(r,o){if(this.hasDispatched||typeof window>"u")return;this.hasDispatched=!0;const u=this.getMfeName();fe.error("ErrorBoundary caught:",r);try{window.dispatchEvent(new CustomEvent("mfe-error",{detail:{mfeName:u,error:r.message||String(r),stack:r.stack,componentStack:o?.componentStack,timestamp:Date.now()},bubbles:!0}))}catch(s){fe.error("Failed to dispatch mfe-error event:",s)}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,o){this.dispatchError(r,o),fe.error("Error info:",o.componentStack)}handleCopy=()=>{const r=`Error in ${this.getMfeName()}:
15
- ${this.state.error?.message}
16
- ${this.state.error?.stack}`;typeof navigator<"u"&&navigator.clipboard&&navigator.clipboard.writeText(r).then(()=>{alert("Ошибка скопирована в буфер обмена")}).catch(()=>{prompt("Скопируйте ошибку:",r)})};handleRetry=()=>{this.setState({hasError:!1,error:void 0}),this.hasDispatched=!1,typeof window<"u"&&window.location.reload()};handleGoHome=()=>{typeof window<"u"&&(window.location.href="/")};render(){if(this.state.hasError){const r=this.state.error?.message||"Unknown error",o=this.state.error?.stack||"",u=this.shouldShowDetails(),s=this.getMfeName();return d.jsxs("div",{style:{padding:"20px",textAlign:"center",color:"#d32f2f",fontFamily:"monospace",background:"#ffebee",border:"1px solid #ef5350",borderRadius:"4px",margin:"10px"},children:[d.jsxs("h2",{style:{fontSize:"16px",margin:"0 0 8px 0"},children:["⚠️ Ошибка в ",s]}),d.jsx("p",{style:{fontSize:"12px",margin:0},children:"Произошла ошибка в микрофронтенде. Сообщение отправлено в shell."}),u&&d.jsxs("details",{style:{whiteSpace:"pre-wrap",textAlign:"left",marginTop:"10px",background:"#fff",padding:"8px",borderRadius:"4px"},children:[d.jsx("summary",{style:{cursor:"pointer",fontWeight:"bold"},children:"Детали ошибки"}),d.jsxs("pre",{style:{fontSize:"11px",overflow:"auto",maxHeight:"150px",margin:"8px 0 0 0",padding:"8px",background:"#f5f5f5",borderRadius:"4px"},children:[r,o&&`
17
-
18
- ${o}`]})]}),d.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"8px",justifyContent:"center"},children:[d.jsx("button",{onClick:this.handleCopy,style:{padding:"8px 12px",background:"#666",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"📋 Копировать"}),d.jsx("button",{onClick:this.handleRetry,style:{padding:"8px 12px",background:"#d32f2f",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"🔄 Обновить"}),d.jsx("button",{onClick:this.handleGoHome,style:{padding:"8px 12px",background:"#1976d2",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"🏠 На главную"})]})]})}return this.props.children==null?null:this.props.children}}const T={info:"ℹ️",code:"💻",link:"🔗",user:"👤",clock:"🕐",apps:"📦",storage:"💾",tags:"🏷️",spreadsheet:"📊"};function qt({mfeName:t}){const{data:r,isLoading:o,error:u}=Ye({mfeName:t}),[s,f]=m.useState(!1);if(o)return d.jsxs("span",{className:"text-muted small me-2",children:[d.jsx("span",{className:"me-1",children:"⏳"}),"Загрузка..."]});if(u||!r)return d.jsxs("span",{className:"text-muted small me-2",title:`Ошибка: ${u||"нет данных"}`,children:[d.jsx("span",{className:"me-1",children:"ℹ️"}),"N/A"]});const i=r,b=i.BUILD_VERSION||i.IMAGE_VERSION||i.APP_NAME||"N/A",p=[];return i.APP_NAME&&p.push({key:"APP_NAME",value:i.APP_NAME,label:"Приложение",icon:T.apps}),i.BUILD_VERSION&&p.push({key:"BUILD_VERSION",value:i.BUILD_VERSION,label:"Версия",icon:T.tags}),i.IMAGE_VERSION&&p.push({key:"IMAGE_VERSION",value:i.IMAGE_VERSION,label:"Образ",icon:T.storage}),i.GIT_COMMIT&&p.push({key:"GIT_COMMIT",value:i.GIT_COMMIT,label:"Commit",icon:T.spreadsheet}),i.GIT_BRANCH&&p.push({key:"GIT_BRANCH",value:i.GIT_BRANCH,label:"Ветка",icon:T.spreadsheet}),i.CI_COMMIT_AUTHOR&&p.push({key:"CI_COMMIT_AUTHOR",value:i.CI_COMMIT_AUTHOR,label:"Автор",icon:T.user}),i.CI_COMMIT_TIMESTAMP&&p.push({key:"CI_COMMIT_TIMESTAMP",value:i.CI_COMMIT_TIMESTAMP,label:"Дата",icon:T.clock}),i.CI_JOB_URL&&p.push({key:"CI_JOB_URL",value:i.CI_JOB_URL,label:"CI Job",icon:T.link}),i.CI_PIPELINE_URL&&p.push({key:"CI_PIPELINE_URL",value:i.CI_PIPELINE_URL,label:"Pipeline",icon:T.link}),i.CI_COMMIT_MESSAGE&&(i.CI_COMMIT_MESSAGE.length>60?i.CI_COMMIT_MESSAGE.substring(0,57)+"":i.CI_COMMIT_MESSAGE,p.push({key:"CI_COMMIT_MESSAGE",value:i.CI_COMMIT_MESSAGE,label:"Сообщение",icon:T.code})),d.jsxs("div",{style:{display:"inline-block",position:"relative"},children:[d.jsxs("button",{onClick:()=>f(!s),style:{background:"transparent",border:"none",cursor:"pointer",padding:"4px 8px",fontSize:"14px",display:"inline-flex",alignItems:"center"},title:"Информация о версии",children:[d.jsx("span",{className:"me-1",children:T.info}),d.jsx("span",{className:"text-dark",children:b})]}),s&&d.jsxs("div",{style:{position:"absolute",top:"100%",right:0,zIndex:1e3,minWidth:"300px",background:"white",border:"1px solid #dee2e6",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",padding:"16px",marginTop:"4px"},children:[d.jsxs("div",{style:{marginBottom:"12px",paddingBottom:"8px",borderBottom:"1px solid #dee2e6",display:"flex",alignItems:"center"},children:[d.jsx("span",{className:"me-2",children:T.apps}),d.jsx("strong",{children:i.APP_NAME||t})]}),d.jsxs("div",{style:{marginBottom:"12px"},children:[d.jsx("span",{className:"text-muted",children:"Версия: "}),d.jsx("strong",{children:b})]}),p.length>0&&d.jsx("div",{style:{fontSize:"13px"},children:p.map(({key:y,value:g,label:S,icon:l})=>{const v=g.length>40&&(y.includes("URL")||y.includes("MESSAGE"))?`${g.substring(0,37)}...`:g;return d.jsxs("div",{style:{marginBottom:"8px",display:"flex",alignItems:"flex-start"},children:[d.jsx("span",{className:"me-2",style:{flexShrink:0},children:l}),d.jsxs("div",{style:{flex:1,minWidth:0},children:[d.jsx("div",{className:"small text-muted",children:S}),d.jsx("div",{className:"font-monospace small text-truncate",style:{maxWidth:"100%"},title:g,children:y.includes("URL")?d.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",style:{color:"#007bff"},children:v}):v})]})]},y)})}),p.length===0&&d.jsx("div",{className:"text-center text-muted py-2 small",children:"Нет информации о версии"}),d.jsx("div",{style:{marginTop:"12px",paddingTop:"8px",borderTop:"1px solid #dee2e6",textAlign:"center",fontSize:"12px",color:"#6c757d"},children:"IngoBank DevOps Platform"}),d.jsx("button",{onClick:()=>f(!1),style:{position:"absolute",top:"8px",right:"8px",background:"transparent",border:"none",cursor:"pointer",fontSize:"16px",color:"#6c757d"},children:"×"})]}),s&&d.jsx("div",{onClick:()=>f(!1),style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:999}})]})}const de="platform-kit",Ke=m.createContext(null);function Kt({children:t}){const[r,o]=m.useState([]),u=typeof window<"u"&&window.__MF_NAME__||de,s=m.useCallback((l,v,C,k)=>({id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,type:l,title:v,message:C,mfeName:u,timestamp:Date.now(),duration:k}),[u]),f=m.useCallback(l=>{o(C=>[...C,l].slice(0,5));const v=l.duration||5e3;v>0&&setTimeout(()=>{o(C=>C.filter(k=>k.id!==l.id))},v)},[]),i=m.useCallback(l=>{const v=s(l.type,l.title,l.message,l.duration);f(v),typeof window<"u"&&window.dispatchEvent(new CustomEvent("mfe-notification",{detail:v,bubbles:!0}))},[s,f]),b=m.useCallback((l,v="Успешно")=>{i({type:"success",title:v,message:l})},[i]),p=m.useCallback((l,v="Ошибка")=>{i({type:"error",title:v,message:l})},[i]),y=m.useCallback((l,v="Предупреждение")=>{i({type:"warning",title:v,message:l})},[i]),g=m.useCallback((l,v="Информация")=>{i({type:"info",title:v,message:l})},[i]),S=m.useCallback(l=>{o(v=>v.filter(C=>C.id!==l))},[]);return m.useEffect(()=>{if(typeof window>"u")return;const l=v=>{const C=v.detail;if(C&&C.type&&C.title&&C.message){const k={...C,id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`};f(k)}};return window.addEventListener("mfe-notification",l),()=>{window.removeEventListener("mfe-notification",l)}},[f]),d.jsxs(Ke.Provider,{value:{notify:i,notifySuccess:b,notifyError:p,notifyWarning:y,notifyInfo:g,removeNotification:S},children:[t,r.length>0&&d.jsx("div",{style:{position:"fixed",top:"80px",right:"20px",zIndex:9998,maxWidth:"400px",width:"100%",display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none"},children:r.map(l=>d.jsxs("div",{className:`notification notification-${l.type}`,style:{pointerEvents:"auto",padding:"12px 16px",borderRadius:"8px",background:l.type==="success"?"#d4edda":l.type==="error"?"#f8d7da":l.type==="warning"?"#fff3cd":"#d1ecf1",color:l.type==="success"?"#155724":l.type==="error"?"#721c24":l.type==="warning"?"#856404":"#0c5460",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",display:"flex",alignItems:"flex-start",gap:"12px"},children:[d.jsxs("div",{style:{flex:1},children:[d.jsx("strong",{style:{display:"block",marginBottom:"4px"},children:l.title}),d.jsx("p",{style:{margin:0,fontSize:"14px"},children:l.message}),d.jsx("small",{style:{opacity:.7,fontSize:"12px"},children:l.mfeName})]}),d.jsx("button",{onClick:()=>S(l.id),style:{background:"transparent",border:"none",cursor:"pointer",fontSize:"18px",lineHeight:1,opacity:.5},children:"×"})]},l.id))})]})}function Xt(){const t=m.useContext(Ke);return t||{notify:()=>{},notifySuccess:()=>{},notifyError:()=>{},notifyWarning:()=>{},notifyInfo:()=>{},removeNotification:()=>{}}}function Zt(t){if(typeof window>"u")return;const r=window.__MF_NAME__||de,o={...t,mfeName:r,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:o,bubbles:!0}))}const Xe="platform-kit",H={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error(`[${Xe}]`,...t)},info:(...t)=>{}};function Qt(){if(typeof window>"u")return{isAuthenticated:!1};const t=window.__SHELL_AUTH_INSTANCE__;if(t)return t;const r=window.__SHELL_AUTH__;return r?.authInstance?r.authInstance:{isAuthenticated:!1}}function er(){if(typeof window>"u")return;const t=window.__SHELL_AUTH_INSTANCE__;t?.signinRedirect?t.signinRedirect().catch(r=>{H.error("Failed to redirect to login:",r)}):window.location.href="/"}function tr(t){const r=t.response;let o="unknown";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",{message:r?.data?.message??t.message??"Unknown error",code:r?.data?.code,status:r?.status,type:o,timestamp:Date.now(),url:t.config?.url}}function Ze(t={}){const r=t.name||Xe,o={log:(...s)=>H.log(`[API:${r}]`,...s),warn:(...s)=>H.warn(`[API:${r}]`,...s),error:(...s)=>H.error(`[API:${r}]`,...s),info:(...s)=>H.info(`[API:${r}]`,...s)},u=Ft.create({timeout:t.timeout??1e4,baseURL:t.baseURL??"",headers:{"Content-Type":"application/json"}});return u.interceptors.request.use(s=>{const f=Qt();if(f?.isAuthenticated){const i=f.user?.profile?.access_token;i&&s.headers&&(s.headers.Authorization=`Bearer ${i}`,o.info("Auth token attached"))}else o.info("User not authenticated - request without token");return o.log(`${s.method?.toUpperCase()} ${s.url}`),s},s=>(o.error("Request interceptor error:",s.message),Promise.reject(s))),u.interceptors.response.use(s=>(o.log(`Response ${s.status}:`,s.config.url),s),s=>{const f=s.response?.status,i=s.config?.url;return f===401?(o.warn("401 Unauthorized - triggering re-auth"),er()):f===403?o.warn("403 Forbidden - insufficient permissions"):f===404?o.warn("404 Not found:",i):f===429?o.warn("429 Rate limited"):f===500?o.error("500 Server error:",i):s.response?o.warn(`Error ${f}:`,s.message):o.error("Network error - backend may be unavailable:",i),Promise.reject(tr(s))}),u}const G=Ze();async function rr(t,r,o=G){const u=await o.get(t,{params:r});return{data:u.data,status:u.status,ok:u.status>=200&&u.status<300}}async function nr(t,r,o=G){const u=await o.post(t,r);return{data:u.data,status:u.status,ok:u.status>=200&&u.status<300}}async function or(t,r,o=G){const u=await o.put(t,r);return{data:u.data,status:u.status,ok:u.status>=200&&u.status<300}}async function ar(t,r=G){const o=await r.delete(t);return{data:o.data,status:o.status,ok:o.status>=200&&o.status<300}}function z(t,r){const o=r?.prefix?`[${r.prefix}]`:`[${t}]`;return{log:(...u)=>{},warn:(...u)=>{},error:(...u)=>{console.error(o,...u)},info:(...u)=>{}}}const ir=z("platform-kit",{prefix:"AUTH"}),sr=z("platform-kit",{prefix:"API"}),ur=z("platform-kit",{prefix:"ERROR"}),lr=z("platform-kit",{prefix:"INFO"}),cr={},fr={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[getMfeName]",...t)}};function ge(t){return t?t.mfeName?t.mfeName:t.name?t.name.replace("@ib-dop/",""):null:null}function Qe(){if(typeof window>"u")return null;const t=window;return t.__MF_NAME__?t.__MF_NAME__:null}function et(){if(typeof window>"u")return null;try{const t=sessionStorage.getItem("mf-config");if(t){const r=JSON.parse(t);if(r.mfeName)return r.mfeName;if(r.name)return r.name;if(r.appName)return r.appName}}catch{}return null}function me(){const t=cr;return t.VITE_MFE_NAME?String(t.VITE_MFE_NAME):t.MFE_NAME?String(t.MFE_NAME):null}let ee=null,pe=!1;function tt(t,r){const o=ge(t);if(o)return o;if(pe&&ee)return ee;const u=[{source:"window.__MF_NAME__",value:Qe()},{source:"sessionStorage.mf-config",value:et()},{source:"import.meta.env.VITE_MFE_NAME",value:me()}];for(const{source:f,value:i}of u)if(i)return ee=i,pe=!0,i;if(r)return r;const s="Cannot determine MFE name. Please pass mfeName in props, set window.__MF_NAME__, sessionStorage.mf-config, or VITE_MFE_NAME";throw fr.error(s),new Error(s)}function dr(t){return tt(t)}function rt(t){return ge(t)?"props.mfeName":Qe()?"window.__MF_NAME__":et()?"sessionStorage.mf-config":me()?"import.meta.env.VITE_MFE_NAME":null}function pr(t){return rt(t)!==null}function gr(){ee=null,pe=!1}function mr(t){const r=[];return ge(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")),me()&&r.push("import.meta.env.VITE_MFE_NAME"),r}exports.ErrorBoundary=Jt;exports.NotificationProvider=Kt;exports.VersionInfo=qt;exports.api=G;exports.apiLogger=sr;exports.authLogger=ir;exports.createApiClient=Ze;exports.createMfLogger=z;exports.del=ar;exports.dispatchNotification=Zt;exports.errorLogger=ur;exports.get=rr;exports.getAllMfeNameSources=mr;exports.getAuth=Q;exports.getMfeName=tt;exports.getMfeNameSource=rt;exports.hasMfeName=pr;exports.infoLogger=lr;exports.post=nr;exports.put=or;exports.requireMfeName=dr;exports.resetMfeNameCache=gr;exports.useApi=Vt;exports.useInfoData=Ye;exports.useNotification=Xt;exports.usePermissions=Bt;exports.useShellAuth=ze;exports.useV1Config=Ut;