@bwg-ui/core 1.1.26 → 1.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/chunks/common-components-CniOkOzu.js +15776 -0
  2. package/dist/chunks/common-components-DrcQahsO.cjs +183 -0
  3. package/dist/chunks/{core-BBMCFpHx.js → core-CEDyqniq.js} +1 -2
  4. package/dist/chunks/core-lmAmbqvY.cjs +1 -0
  5. package/dist/chunks/{enc-base64-DAsYWbA2.js → enc-base64-CF2tIkYl.js} +4 -5
  6. package/dist/chunks/enc-base64-Dxq399hI.cjs +1 -0
  7. package/dist/chunks/{sha256-D80RpYO2.js → sha256-DYurgXCU.js} +12 -13
  8. package/dist/chunks/sha256-H5WWQnKT.cjs +1 -0
  9. package/dist/components/common/BwgPagination.d.ts +1 -1
  10. package/dist/components/common/BwgPagination.d.ts.map +1 -1
  11. package/dist/components/common/index.cjs +1 -2
  12. package/dist/components/common/index.d.ts +3 -1
  13. package/dist/components/common/index.d.ts.map +1 -1
  14. package/dist/components/common/index.js +16 -17
  15. package/dist/components/core/index.cjs +1 -2
  16. package/dist/components/core/index.js +1218 -23
  17. package/dist/components/guide/index.cjs +1 -2
  18. package/dist/components/guide/index.js +1 -2
  19. package/dist/components/layout/index.cjs +35 -2
  20. package/dist/components/layout/index.js +350 -10
  21. package/dist/components/popup/MenuReport.d.ts.map +1 -1
  22. package/dist/index.cjs +1 -2
  23. package/dist/index.js +211 -222
  24. package/dist/provider/index.cjs +1 -2
  25. package/dist/provider/index.js +384 -25
  26. package/dist/stores/index.cjs +2 -2
  27. package/dist/stores/index.js +1394 -24
  28. package/dist/utils/index.cjs +1 -2
  29. package/dist/utils/index.js +1369 -200
  30. package/package.json +1 -1
  31. package/dist/chunks/AuthContext-BQ3gHLbr.cjs +0 -2
  32. package/dist/chunks/AuthContext-BQ3gHLbr.cjs.map +0 -1
  33. package/dist/chunks/AuthContext-CVizgYxY.js +0 -57
  34. package/dist/chunks/AuthContext-CVizgYxY.js.map +0 -1
  35. package/dist/chunks/BwgSpace-BPJARdOc.js +0 -27
  36. package/dist/chunks/BwgSpace-BPJARdOc.js.map +0 -1
  37. package/dist/chunks/BwgSpace-Cw27d-XU.cjs +0 -2
  38. package/dist/chunks/BwgSpace-Cw27d-XU.cjs.map +0 -1
  39. package/dist/chunks/BwgSwitch-BLtVdW44.cjs +0 -2
  40. package/dist/chunks/BwgSwitch-BLtVdW44.cjs.map +0 -1
  41. package/dist/chunks/BwgSwitch-DdHo4gYR.js +0 -269
  42. package/dist/chunks/BwgSwitch-DdHo4gYR.js.map +0 -1
  43. package/dist/chunks/BwgUploader-BUmFmeuS.js +0 -3250
  44. package/dist/chunks/BwgUploader-BUmFmeuS.js.map +0 -1
  45. package/dist/chunks/BwgUploader-Djhl4lIt.cjs +0 -3
  46. package/dist/chunks/BwgUploader-Djhl4lIt.cjs.map +0 -1
  47. package/dist/chunks/LoadingOverlay-Uf6xy04v.js +0 -19
  48. package/dist/chunks/LoadingOverlay-Uf6xy04v.js.map +0 -1
  49. package/dist/chunks/LoadingOverlay-jdMzdB-z.cjs +0 -2
  50. package/dist/chunks/LoadingOverlay-jdMzdB-z.cjs.map +0 -1
  51. package/dist/chunks/SSOHandler-CR0nR3rJ.js +0 -28654
  52. package/dist/chunks/SSOHandler-CR0nR3rJ.js.map +0 -1
  53. package/dist/chunks/SSOHandler-DQG0Jp4V.cjs +0 -237
  54. package/dist/chunks/SSOHandler-DQG0Jp4V.cjs.map +0 -1
  55. package/dist/chunks/ScreenProtectContext-BMsPPcTX.js +0 -154
  56. package/dist/chunks/ScreenProtectContext-BMsPPcTX.js.map +0 -1
  57. package/dist/chunks/ScreenProtectContext-DrCGlcTs.cjs +0 -2
  58. package/dist/chunks/ScreenProtectContext-DrCGlcTs.cjs.map +0 -1
  59. package/dist/chunks/SearchBoxContext-DY6lES-W.cjs +0 -2
  60. package/dist/chunks/SearchBoxContext-DY6lES-W.cjs.map +0 -1
  61. package/dist/chunks/SearchBoxContext-Dtzo_rJd.js +0 -86
  62. package/dist/chunks/SearchBoxContext-Dtzo_rJd.js.map +0 -1
  63. package/dist/chunks/ViewContainer-BfiTFvLP.cjs +0 -36
  64. package/dist/chunks/ViewContainer-BfiTFvLP.cjs.map +0 -1
  65. package/dist/chunks/ViewContainer-CTl3_56W.js +0 -338
  66. package/dist/chunks/ViewContainer-CTl3_56W.js.map +0 -1
  67. package/dist/chunks/apiUtils-D9Vn1gwZ.cjs +0 -3
  68. package/dist/chunks/apiUtils-D9Vn1gwZ.cjs.map +0 -1
  69. package/dist/chunks/apiUtils-DPUgfmKk.js +0 -1450
  70. package/dist/chunks/apiUtils-DPUgfmKk.js.map +0 -1
  71. package/dist/chunks/codeStore-BrCfe9K3.js +0 -450
  72. package/dist/chunks/codeStore-BrCfe9K3.js.map +0 -1
  73. package/dist/chunks/codeStore-_b2fDZtD.cjs +0 -2
  74. package/dist/chunks/codeStore-_b2fDZtD.cjs.map +0 -1
  75. package/dist/chunks/core-BBMCFpHx.js.map +0 -1
  76. package/dist/chunks/core-CM9MsJRf.cjs +0 -2
  77. package/dist/chunks/core-CM9MsJRf.cjs.map +0 -1
  78. package/dist/chunks/enc-base64-DAsYWbA2.js.map +0 -1
  79. package/dist/chunks/enc-base64-DbK5VBfD.cjs +0 -2
  80. package/dist/chunks/enc-base64-DbK5VBfD.cjs.map +0 -1
  81. package/dist/chunks/favoriteStore-BnQ2u-sa.cjs +0 -2
  82. package/dist/chunks/favoriteStore-BnQ2u-sa.cjs.map +0 -1
  83. package/dist/chunks/favoriteStore-SyAjqLG8.js +0 -439
  84. package/dist/chunks/favoriteStore-SyAjqLG8.js.map +0 -1
  85. package/dist/chunks/popupStore-BrKcPw7K.js +0 -92
  86. package/dist/chunks/popupStore-BrKcPw7K.js.map +0 -1
  87. package/dist/chunks/popupStore-ChbYTqy1.cjs +0 -2
  88. package/dist/chunks/popupStore-ChbYTqy1.cjs.map +0 -1
  89. package/dist/chunks/realFormat-Cha7OTd9.cjs +0 -2
  90. package/dist/chunks/realFormat-Cha7OTd9.cjs.map +0 -1
  91. package/dist/chunks/realFormat-DRGLFabQ.js +0 -305
  92. package/dist/chunks/realFormat-DRGLFabQ.js.map +0 -1
  93. package/dist/chunks/sha256-BnWVPP1K.cjs +0 -2
  94. package/dist/chunks/sha256-BnWVPP1K.cjs.map +0 -1
  95. package/dist/chunks/sha256-D80RpYO2.js.map +0 -1
  96. package/dist/chunks/usePopup-DnfKRiYs.js +0 -109
  97. package/dist/chunks/usePopup-DnfKRiYs.js.map +0 -1
  98. package/dist/chunks/usePopup-Domnpg55.cjs +0 -2
  99. package/dist/chunks/usePopup-Domnpg55.cjs.map +0 -1
  100. package/dist/components/common/index.cjs.map +0 -1
  101. package/dist/components/common/index.js.map +0 -1
  102. package/dist/components/core/index.cjs.map +0 -1
  103. package/dist/components/core/index.js.map +0 -1
  104. package/dist/components/guide/index.cjs.map +0 -1
  105. package/dist/components/guide/index.js.map +0 -1
  106. package/dist/components/layout/index.cjs.map +0 -1
  107. package/dist/components/layout/index.js.map +0 -1
  108. package/dist/index.cjs.map +0 -1
  109. package/dist/index.js.map +0 -1
  110. package/dist/provider/index.cjs.map +0 -1
  111. package/dist/provider/index.js.map +0 -1
  112. package/dist/stores/index.cjs.map +0 -1
  113. package/dist/stores/index.js.map +0 -1
  114. package/dist/utils/index.cjs.map +0 -1
  115. package/dist/utils/index.js.map +0 -1
@@ -1,26 +1,1396 @@
1
- import { u as e } from "../chunks/codeStore-BrCfe9K3.js";
2
- import { a as x, b as C } from "../chunks/codeStore-BrCfe9K3.js";
3
- import { u as t } from "../chunks/favoriteStore-SyAjqLG8.js";
4
- import { aI as o, aG as s, aH as r } from "../chunks/apiUtils-DPUgfmKk.js";
5
- import { aE as P, aF as v } from "../chunks/apiUtils-DPUgfmKk.js";
6
- import { u as a } from "../chunks/popupStore-BrKcPw7K.js";
7
- const i = () => e.getState(), m = () => a.getState(), g = () => o.getState(), c = () => t.getState(), d = () => s.getState(), f = () => r.getState();
1
+ import { create as y } from "zustand";
2
+ import { callService as v, getServiceCode as E, getUserId as N, getUserInfo as x } from "../utils/index.js";
3
+ import { message as L } from "antd";
4
+ function q(r, s) {
5
+ let e;
6
+ try {
7
+ e = r();
8
+ } catch {
9
+ return;
10
+ }
11
+ return {
12
+ getItem: (o) => {
13
+ var t;
14
+ const a = (d) => d === null ? null : JSON.parse(d, void 0), c = (t = e.getItem(o)) != null ? t : null;
15
+ return c instanceof Promise ? c.then(a) : a(c);
16
+ },
17
+ setItem: (o, t) => e.setItem(o, JSON.stringify(t, void 0)),
18
+ removeItem: (o) => e.removeItem(o)
19
+ };
20
+ }
21
+ const H = (r) => (s) => {
22
+ try {
23
+ const e = r(s);
24
+ return e instanceof Promise ? e : {
25
+ then(n) {
26
+ return H(n)(e);
27
+ },
28
+ catch(n) {
29
+ return this;
30
+ }
31
+ };
32
+ } catch (e) {
33
+ return {
34
+ then(n) {
35
+ return this;
36
+ },
37
+ catch(n) {
38
+ return H(n)(e);
39
+ }
40
+ };
41
+ }
42
+ }, z = (r, s) => (e, n, o) => {
43
+ let t = {
44
+ storage: q(() => localStorage),
45
+ partialize: (m) => m,
46
+ version: 0,
47
+ merge: (m, b) => ({
48
+ ...b,
49
+ ...m
50
+ }),
51
+ ...s
52
+ }, a = !1;
53
+ const c = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
54
+ let u = t.storage;
55
+ if (!u)
56
+ return r(
57
+ (...m) => {
58
+ console.warn(
59
+ `[zustand persist middleware] Unable to update item '${t.name}', the given storage is currently unavailable.`
60
+ ), e(...m);
61
+ },
62
+ n,
63
+ o
64
+ );
65
+ const i = () => {
66
+ const m = t.partialize({ ...n() });
67
+ return u.setItem(t.name, {
68
+ state: m,
69
+ version: t.version
70
+ });
71
+ }, g = o.setState;
72
+ o.setState = (m, b) => (g(m, b), i());
73
+ const p = r(
74
+ (...m) => (e(...m), i()),
75
+ n,
76
+ o
77
+ );
78
+ o.getInitialState = () => p;
79
+ let h;
80
+ const I = () => {
81
+ var m, b;
82
+ if (!u) return;
83
+ a = !1, c.forEach((C) => {
84
+ var k;
85
+ return C((k = n()) != null ? k : p);
86
+ });
87
+ const M = ((b = t.onRehydrateStorage) == null ? void 0 : b.call(t, (m = n()) != null ? m : p)) || void 0;
88
+ return H(u.getItem.bind(u))(t.name).then((C) => {
89
+ if (C)
90
+ if (typeof C.version == "number" && C.version !== t.version) {
91
+ if (t.migrate) {
92
+ const k = t.migrate(
93
+ C.state,
94
+ C.version
95
+ );
96
+ return k instanceof Promise ? k.then((O) => [!0, O]) : [!0, k];
97
+ }
98
+ console.error(
99
+ "State loaded from storage couldn't be migrated since no migrate function was provided"
100
+ );
101
+ } else
102
+ return [!1, C.state];
103
+ return [!1, void 0];
104
+ }).then((C) => {
105
+ var k;
106
+ const [O, Y] = C;
107
+ if (h = t.merge(
108
+ Y,
109
+ (k = n()) != null ? k : p
110
+ ), e(h, !0), O)
111
+ return i();
112
+ }).then(() => {
113
+ M?.(h, void 0), h = n(), a = !0, d.forEach((C) => C(h));
114
+ }).catch((C) => {
115
+ M?.(void 0, C);
116
+ });
117
+ };
118
+ return o.persist = {
119
+ setOptions: (m) => {
120
+ t = {
121
+ ...t,
122
+ ...m
123
+ }, m.storage && (u = m.storage);
124
+ },
125
+ clearStorage: () => {
126
+ u?.removeItem(t.name);
127
+ },
128
+ getOptions: () => t,
129
+ rehydrate: () => I(),
130
+ hasHydrated: () => a,
131
+ onHydrate: (m) => (c.add(m), () => {
132
+ c.delete(m);
133
+ }),
134
+ onFinishHydration: (m) => (d.add(m), () => {
135
+ d.delete(m);
136
+ })
137
+ }, t.skipHydration || I(), h || p;
138
+ }, S = z, J = y()(
139
+ S(
140
+ (r, s) => ({
141
+ user: null,
142
+ isLoggedIn: !1,
143
+ // 로그인
144
+ login: (e) => {
145
+ r({ user: e, isLoggedIn: !0 }), console.log("사용자 로그인:", e);
146
+ },
147
+ // 로그아웃
148
+ logout: () => {
149
+ r({ user: null, isLoggedIn: !1 }), console.log("사용자 로그아웃");
150
+ },
151
+ // 사용자 정보 업데이트
152
+ updateUser: (e) => {
153
+ const n = s().user;
154
+ n && r({ user: { ...n, ...e } });
155
+ }
156
+ }),
157
+ {
158
+ name: "user-storage",
159
+ // 로컬 스토리지 키
160
+ partialize: (r) => ({
161
+ user: r.user,
162
+ isLoggedIn: r.isLoggedIn
163
+ })
164
+ // 저장할 상태만 선택
165
+ }
166
+ )
167
+ ), F = {
168
+ CACHE_SIZE_LIMIT: 1e3
169
+ }, l = {
170
+ codeCache: /* @__PURE__ */ new Map(),
171
+ nameCache: /* @__PURE__ */ new Map(),
172
+ optionCache: /* @__PURE__ */ new Map(),
173
+ colorCache: /* @__PURE__ */ new Map(),
174
+ loadedGroups: /* @__PURE__ */ new Set(),
175
+ cacheHits: /* @__PURE__ */ new Map(),
176
+ clearCache() {
177
+ this.codeCache.clear(), this.nameCache.clear(), this.optionCache.clear(), this.colorCache.clear(), this.loadedGroups.clear(), this.cacheHits.clear();
178
+ },
179
+ cleanupCache() {
180
+ const r = Array.from(this.cacheHits.entries());
181
+ r.sort((e, n) => e[1] - n[1]), r.slice(0, Math.floor(r.length * 0.3)).forEach(([e]) => {
182
+ this.codeCache.delete(e), this.nameCache.delete(e), this.optionCache.delete(e), this.colorCache.delete(e), this.cacheHits.delete(e);
183
+ });
184
+ },
185
+ isGroupLoaded(r) {
186
+ return this.loadedGroups.has(r);
187
+ },
188
+ markGroupLoaded(r) {
189
+ this.loadedGroups.add(r);
190
+ }
191
+ }, X = (r) => {
192
+ console.log("대규모 데이터 변환 시작:", r);
193
+ const s = {};
194
+ if (r && r.code && Array.isArray(r.code)) {
195
+ const e = r.code, n = r.opt || [], o = /* @__PURE__ */ new Map();
196
+ n.forEach((t) => {
197
+ t.cmmnCd && t.enblYn === "Y" && (o.has(t.cmmnCd) || o.set(t.cmmnCd, []), o.get(t.cmmnCd).push(t));
198
+ }), e.forEach((t) => {
199
+ if (t && t.cmmnCdGrp && t.cmmnCd && t.enblYn === "Y") {
200
+ const a = t.cmmnCdGrp;
201
+ s[a] || (s[a] = {});
202
+ const d = (o.get(t.cmmnCd) || []).reduce((u, i) => (i.optnCd && i.optnNm && (u[i.optnCd] = i.optnNm), u), {});
203
+ s[a][t.cmmnCd] = {
204
+ codeValue: t.cmmnCd,
205
+ codeNm: t.cmmnCdNm,
206
+ groupCode: t.cmmnCdGrp,
207
+ commonCode: t.cmmnCd,
208
+ labelColor: t.cmmnCdClr,
209
+ systemCodeYn: t.syscdYn,
210
+ sortOrder: parseInt(t.sortOrd) || 1,
211
+ enabled: t.enblYn === "Y",
212
+ options: Object.keys(d).length > 0 ? d : null,
213
+ originalData: t
214
+ };
215
+ }
216
+ });
217
+ }
218
+ return console.log("대규모 데이터 변환 완료:", s), s;
219
+ }, f = y()(
220
+ S(
221
+ (r, s) => ({
222
+ codeData: null,
223
+ isLoading: !1,
224
+ error: null,
225
+ lastUpdated: null,
226
+ loadedGroups: /* @__PURE__ */ new Set(),
227
+ fetchData: async () => {
228
+ r({ isLoading: !0, error: null });
229
+ try {
230
+ console.log("대규모 공통코드 데이터 가져오기 시작: SCMSIGN00301");
231
+ const e = await v(E("SRCH_CODE"), {
232
+ crprCd: "100"
233
+ });
234
+ console.log("대규모 공통코드 응답:", e), console.log("대규모 공통코드목록:", e.code), console.log("대규모 공통코드옵션션목록:", e.opt);
235
+ const n = X(e);
236
+ l.clearCache();
237
+ const o = new Set(Object.keys(n));
238
+ o.forEach((t) => {
239
+ l.markGroupLoaded(t);
240
+ }), r({
241
+ codeData: n,
242
+ isLoading: !1,
243
+ error: null,
244
+ lastUpdated: /* @__PURE__ */ new Date(),
245
+ loadedGroups: o
246
+ }), console.log("대규모 공통코드 데이터 가져오기 완료");
247
+ } catch (e) {
248
+ console.error("대규모 공통코드 데이터 가져오기 실패:", e), r({
249
+ isLoading: !1,
250
+ error: e instanceof Error ? e.message : "대규모 공통코드 데이터 가져오기 실패"
251
+ });
252
+ }
253
+ },
254
+ loadSpecificGroup: async (e) => {
255
+ const { codeData: n, loadedGroups: o } = s();
256
+ if (!n || o.has(e)) return;
257
+ const t = new Set(o).add(e);
258
+ r({ loadedGroups: t }), l.markGroupLoaded(e);
259
+ },
260
+ setData: (e) => {
261
+ l.clearCache();
262
+ const n = new Set(Object.keys(e));
263
+ n.forEach((o) => {
264
+ l.markGroupLoaded(o);
265
+ }), r({
266
+ codeData: e,
267
+ lastUpdated: /* @__PURE__ */ new Date(),
268
+ loadedGroups: n
269
+ });
270
+ },
271
+ clearData: () => {
272
+ l.clearCache(), r({
273
+ codeData: null,
274
+ isLoading: !1,
275
+ error: null,
276
+ lastUpdated: null,
277
+ loadedGroups: /* @__PURE__ */ new Set()
278
+ });
279
+ },
280
+ getLoadedGroups: () => Array.from(s().loadedGroups)
281
+ }),
282
+ {
283
+ name: "large-data-storage",
284
+ partialize: (r) => ({
285
+ codeData: r.codeData,
286
+ lastUpdated: r.lastUpdated,
287
+ loadedGroups: Array.from(r.loadedGroups)
288
+ })
289
+ }
290
+ )
291
+ ), Z = y()(
292
+ S(
293
+ (r, s) => ({
294
+ // 공통 데이터 스토어에서 상태 가져오기
295
+ get codeData() {
296
+ return f.getState().codeData;
297
+ },
298
+ get isLoading() {
299
+ return f.getState().isLoading;
300
+ },
301
+ get error() {
302
+ return f.getState().error;
303
+ },
304
+ get lastUpdated() {
305
+ return f.getState().lastUpdated;
306
+ },
307
+ // 공통코드 가져오기 (중앙 스토어 사용)
308
+ fetchCommonCodes: async () => {
309
+ await f.getState().fetchData();
310
+ },
311
+ // 1. 통합된 코드 목록 조회 (그룹코드 필수, 옵션으로 필터링)
312
+ getCodeList: (e, n) => {
313
+ const {
314
+ enabledOnly: o = !0,
315
+ systemCodeOnly: t = !1,
316
+ sortByOrder: a = !1,
317
+ excludeParentCode: c = !1
318
+ } = n || {}, d = `simpleCodeList_${e}_${o}_${t}_${a}_${c}`;
319
+ if (l.optionCache.has(d)) {
320
+ const I = l.cacheHits.get(d) || 0;
321
+ return l.cacheHits.set(d, I + 1), l.optionCache.get(d);
322
+ }
323
+ const u = f.getState().codeData;
324
+ if (!u) return [];
325
+ if (!l.isGroupLoaded(e) && !u[e])
326
+ return console.warn(`그룹 ${e}가 아직 로드되지 않았습니다.`), [];
327
+ const i = [], g = u[e];
328
+ g && Object.values(g).forEach((I) => {
329
+ if (!(o && !I.enabled) && !(t && I.systemCodeYn !== "Y"))
330
+ if (c) {
331
+ const m = e.length, b = I.codeValue.substring(m);
332
+ b.length > 0 && i.push({
333
+ ...I,
334
+ codeValue: b
335
+ // 자식코드만 사용
336
+ });
337
+ } else
338
+ i.push(I);
339
+ });
340
+ let p;
341
+ a ? p = i.sort((I, m) => I.sortOrder !== m.sortOrder ? I.sortOrder - m.sortOrder : I.codeValue.localeCompare(m.codeValue)) : p = i.sort(
342
+ (I, m) => I.codeValue.localeCompare(m.codeValue)
343
+ );
344
+ const h = p.map((I) => ({
345
+ label: I.codeNm,
346
+ value: I.codeValue,
347
+ tagColor: I.labelColor
348
+ }));
349
+ return l.optionCache.size >= F.CACHE_SIZE_LIMIT && l.cleanupCache(), l.optionCache.set(d, h), l.cacheHits.set(d, 1), h;
350
+ },
351
+ // 2. 코드를 던졌을 때 코드명을 리턴 (대규모 최적화)
352
+ getCodeName: (e) => {
353
+ if (l.nameCache.has(e)) {
354
+ const o = l.cacheHits.get(`name_${e}`) || 0;
355
+ return l.cacheHits.set(`name_${e}`, o + 1), l.nameCache.get(e);
356
+ }
357
+ const n = f.getState().codeData;
358
+ if (!n) return null;
359
+ for (const o of Object.values(n))
360
+ for (const t of Object.values(o))
361
+ if (t.codeValue === e)
362
+ return l.nameCache.set(e, t.codeNm), l.cacheHits.set(`name_${e}`, 1), t.codeNm;
363
+ return null;
364
+ },
365
+ // 3. 코드를 던졌을 때 라벨 컬러를 리턴 (대규모 최적화)
366
+ getCodeColor: (e) => {
367
+ if (l.colorCache.has(e)) {
368
+ const o = l.cacheHits.get(`color_${e}`) || 0;
369
+ return l.cacheHits.set(`color_${e}`, o + 1), l.colorCache.get(e);
370
+ }
371
+ const n = f.getState().codeData;
372
+ if (!n) return null;
373
+ for (const o of Object.values(n))
374
+ for (const t of Object.values(o))
375
+ if (t.codeValue === e)
376
+ return l.colorCache.set(
377
+ e,
378
+ t.labelColor || ""
379
+ ), l.cacheHits.set(`color_${e}`, 1), t.labelColor;
380
+ return null;
381
+ },
382
+ // 4. 그리드 lookup용 데이터 반환 (labels, values 배열, lookupDisplay 포함)
383
+ getGridLookup: (e) => {
384
+ const n = `gridLookup_${e}`;
385
+ if (l.optionCache.has(n)) {
386
+ const u = l.cacheHits.get(n) || 0;
387
+ return l.cacheHits.set(n, u + 1), l.optionCache.get(n);
388
+ }
389
+ const o = f.getState().codeData;
390
+ if (!o) return { labels: [], values: [], lookupDisplay: !0 };
391
+ const t = o[e];
392
+ if (!t) return { labels: [], values: [], lookupDisplay: !0 };
393
+ const a = [], c = [];
394
+ Object.values(t).filter((u) => u.enabled).sort((u, i) => u.sortOrder - i.sortOrder).forEach((u) => {
395
+ a.push(u.codeNm), c.push(u.codeValue);
396
+ });
397
+ const d = { labels: a, values: c, lookupDisplay: !0 };
398
+ return l.optionCache.set(n, d), l.cacheHits.set(n, 1), d;
399
+ },
400
+ // 3. 옵션값으로 코드를 조회하는 새로운 메서드
401
+ getCodeByOption: (e, n, o) => {
402
+ const t = `codeByOption_${e}_${n}_${o}`;
403
+ if (l.codeCache.has(t)) {
404
+ const i = l.cacheHits.get(t) || 0;
405
+ return l.cacheHits.set(t, i + 1), l.codeCache.get(t);
406
+ }
407
+ const a = f.getState().codeData;
408
+ if (!a) return [];
409
+ const c = [], d = a[e];
410
+ d && Object.values(d).forEach((i) => {
411
+ i.enabled && i.options && i.options[n] === o && c.push({
412
+ ...i,
413
+ codeNm: i.options[n] || i.codeNm
414
+ // 옵션값을 코드명으로 사용
415
+ });
416
+ });
417
+ const u = c.sort(
418
+ (i, g) => i.codeValue.localeCompare(g.codeValue)
419
+ );
420
+ return l.codeCache.size >= F.CACHE_SIZE_LIMIT && l.cleanupCache(), l.codeCache.set(t, u), l.cacheHits.set(t, 1), u;
421
+ },
422
+ // 6. 옵션코드별로 코드 목록 조회 (SimpleCodeItem 형태로 반환)
423
+ getCodeListByOption: (e, n, o) => {
424
+ const {
425
+ enabledOnly: t = !0,
426
+ systemCodeOnly: a = !1,
427
+ sortByOrder: c = !1
428
+ } = o || {}, d = `codeListByOption_${e}_${n}_${t}_${a}_${c}`;
429
+ if (l.codeCache.has(d)) {
430
+ const h = l.cacheHits.get(d) || 0;
431
+ return l.cacheHits.set(d, h + 1), l.codeCache.get(
432
+ d
433
+ );
434
+ }
435
+ const u = f.getState().codeData;
436
+ if (!u) return [];
437
+ if (!l.isGroupLoaded(e) && !u[e])
438
+ return console.warn(`그룹 ${e}가 아직 로드되지 않았습니다.`), [];
439
+ const i = [], g = u[e];
440
+ g && Object.values(g).forEach((h) => {
441
+ t && !h.enabled || a && h.systemCodeYn !== "Y" || h.options && h.options[n] && i.push({
442
+ label: h.options[n],
443
+ // optnNm 값
444
+ value: h.commonCode,
445
+ // 공통코드값
446
+ tagColor: h.labelColor
447
+ // 라벨 컬러
448
+ });
449
+ });
450
+ let p;
451
+ return c ? p = i.sort((h, I) => h.value.localeCompare(I.value)) : p = i.sort(
452
+ (h, I) => h.value.localeCompare(I.value)
453
+ ), l.codeCache.size >= F.CACHE_SIZE_LIMIT && l.cleanupCache(), l.codeCache.set(d, p), l.cacheHits.set(d, 1), p;
454
+ },
455
+ // 7. 그룹코드 목록 조회
456
+ getAvailableGroupCodes: () => {
457
+ const e = "available_group_codes";
458
+ if (l.nameCache.has(e)) {
459
+ const t = l.cacheHits.get(e) || 0;
460
+ return l.cacheHits.set(e, t + 1), JSON.parse(l.nameCache.get(e));
461
+ }
462
+ const n = f.getState().codeData;
463
+ if (!n) return [];
464
+ const o = Object.keys(n).sort();
465
+ return l.nameCache.set(
466
+ e,
467
+ JSON.stringify(o)
468
+ ), l.cacheHits.set(e, 1), o;
469
+ },
470
+ // 공통코드 초기화
471
+ clearCodes: () => {
472
+ f.getState().clearData();
473
+ }
474
+ }),
475
+ {
476
+ name: "code-storage",
477
+ partialize: (r) => ({
478
+ // 상태는 중앙 스토어에서 관리하므로 여기서는 저장하지 않음
479
+ })
480
+ }
481
+ )
482
+ ), he = y()(
483
+ S(
484
+ (r, s) => ({
485
+ // 공통 데이터 스토어에서 상태 가져오기
486
+ get codeData() {
487
+ return f.getState().codeData;
488
+ },
489
+ get isLoading() {
490
+ return f.getState().isLoading;
491
+ },
492
+ get error() {
493
+ return f.getState().error;
494
+ },
495
+ get lastUpdated() {
496
+ return f.getState().lastUpdated;
497
+ },
498
+ // 공통코드 가져오기 (중앙 스토어 사용)
499
+ fetchCommonCodes: async () => {
500
+ await f.getState().fetchData();
501
+ },
502
+ // 그룹코드와 옵션코드를 던졌을 때 상세코드의 옵션값을 리턴 (대규모 최적화)
503
+ getOptionValue: (e, n) => {
504
+ const o = `option_${e}_${n}`;
505
+ if (l.optionCache.has(o)) {
506
+ const c = l.cacheHits.get(o) || 0;
507
+ return l.cacheHits.set(o, c + 1), l.optionCache.get(o);
508
+ }
509
+ const t = f.getState().codeData;
510
+ if (!t) return null;
511
+ const a = t[e];
512
+ if (a && a[n]) {
513
+ const c = a[n].options;
514
+ return l.optionCache.set(o, c), l.cacheHits.set(o, 1), c;
515
+ }
516
+ return null;
517
+ },
518
+ // 특정 옵션 키의 값 가져오기 (대규모 최적화)
519
+ getOptionByKey: (e, n, o) => {
520
+ const t = `option_${e}_${n}_${o}`;
521
+ if (l.optionCache.has(t)) {
522
+ const d = l.cacheHits.get(t) || 0;
523
+ return l.cacheHits.set(t, d + 1), l.optionCache.get(t);
524
+ }
525
+ const a = s().getOptionValue(e, n), c = a ? a[o] : null;
526
+ return l.optionCache.set(t, c), l.cacheHits.set(t, 1), c;
527
+ },
528
+ // 공통코드 초기화
529
+ clearCodes: () => {
530
+ f.getState().clearData();
531
+ }
532
+ }),
533
+ {
534
+ name: "option-storage",
535
+ partialize: (r) => ({
536
+ // 상태는 중앙 스토어에서 관리하므로 여기서는 저장하지 않음
537
+ })
538
+ }
539
+ )
540
+ ), me = y()(
541
+ S(
542
+ (r, s) => ({
543
+ // 공통 데이터 스토어에서 상태 가져오기
544
+ get codeData() {
545
+ return f.getState().codeData;
546
+ },
547
+ get isLoading() {
548
+ return f.getState().isLoading;
549
+ },
550
+ get error() {
551
+ return f.getState().error;
552
+ },
553
+ get lastUpdated() {
554
+ return f.getState().lastUpdated;
555
+ },
556
+ // 공통코드 가져오기 (중앙 스토어 사용)
557
+ fetchCommonCodes: async () => {
558
+ await f.getState().fetchData();
559
+ },
560
+ // 코드를 던졌을 때 컬러코드를 리턴 (대규모 최적화)
561
+ getColorCode: (e) => {
562
+ if (l.colorCache.has(e)) {
563
+ const o = l.cacheHits.get(`color_${e}`) || 0;
564
+ return l.cacheHits.set(`color_${e}`, o + 1), l.colorCache.get(e);
565
+ }
566
+ const n = f.getState().codeData;
567
+ if (!n) return null;
568
+ for (const o of Object.values(n))
569
+ for (const t of Object.values(o))
570
+ if (t.codeValue === e)
571
+ return l.colorCache.set(
572
+ e,
573
+ t.labelColor || ""
574
+ ), l.cacheHits.set(`color_${e}`, 1), t.labelColor;
575
+ return null;
576
+ },
577
+ // 코드/컬러 매핑 배열 가져오기 (대규모 최적화)
578
+ getColorMapping: () => {
579
+ const e = "color_mapping";
580
+ if (l.optionCache.has(e)) {
581
+ const t = l.cacheHits.get(e) || 0;
582
+ return l.cacheHits.set(e, t + 1), l.optionCache.get(e);
583
+ }
584
+ const n = f.getState().codeData;
585
+ if (!n) return [];
586
+ const o = [];
587
+ return Object.values(n).forEach((t) => {
588
+ Object.values(t).forEach((a) => {
589
+ a.labelColor && o.push({
590
+ code: a.codeValue,
591
+ color: a.labelColor
592
+ });
593
+ });
594
+ }), l.optionCache.set(e, o), l.cacheHits.set(e, 1), o;
595
+ },
596
+ // 공통코드 초기화
597
+ clearCodes: () => {
598
+ f.getState().clearData();
599
+ }
600
+ }),
601
+ {
602
+ name: "color-storage",
603
+ partialize: (r) => ({
604
+ // 상태는 중앙 스토어에서 관리하므로 여기서는 저장하지 않음
605
+ })
606
+ }
607
+ )
608
+ ), W = (r, s) => ({
609
+ nodes: {},
610
+ rootIds: [],
611
+ loadedFor: void 0,
612
+ loading: !1,
613
+ error: void 0,
614
+ treeNodes: [],
615
+ // ====== 셀렉터 ======
616
+ isMenuBookmarked: (e) => Object.values(s().nodes).some(
617
+ (n) => n.type === "M" && n.menuId === e
618
+ ),
619
+ getPrntBkmkIdByMenuId: (e) => {
620
+ const n = w(s().nodes, e);
621
+ return n ? s().nodes[n]?.prntBkmkId ?? "-" : "-";
622
+ },
623
+ getNodeByMenuId: (e) => {
624
+ const n = w(s().nodes, e);
625
+ if (!n) return null;
626
+ const o = s().nodes[n];
627
+ return o?.type === "M" ? o : null;
628
+ },
629
+ getFolderTree: (e) => {
630
+ const { nodes: n, rootIds: o } = s(), t = (c) => e ? c.toLowerCase().includes(e.toLowerCase()) : !0, a = (c) => {
631
+ const d = n[c];
632
+ if (!d || d.type !== "F") return null;
633
+ const u = d, i = (u.children || []).map((p) => n[p]).filter((p) => !!p && p.type === "F").map((p) => a(p.bkmkId)).filter(Boolean);
634
+ return t(u.bkmkNm) || i.length > 0 ? {
635
+ key: u.bkmkId,
636
+ title: `📁 ${u.bkmkNm}`,
637
+ children: i.length ? i : void 0
638
+ } : null;
639
+ };
640
+ return o.map((c) => a(c)).filter(Boolean);
641
+ },
642
+ // ====== 로더 ======
643
+ loadFavorites: async (e, n = !1) => {
644
+ console.log("loadFavorites ::::: ", e, n);
645
+ const o = s();
646
+ if (!(!n && o.loadedFor === e && Object.keys(o.nodes).length)) {
647
+ r({ loading: !0, error: void 0 });
648
+ try {
649
+ const t = await v("SCMBKMK00101", { userId: e }), a = Array.isArray(t?.sub) ? t.sub : [], c = V(a), d = _(
650
+ c.nodes,
651
+ c.rootIds
652
+ );
653
+ r({
654
+ ...c,
655
+ treeNodes: d,
656
+ loadedFor: e,
657
+ loading: !1
658
+ });
659
+ } catch (t) {
660
+ throw r({ loading: !1, error: t?.message || "즐겨찾기 로드 실패" }), t;
661
+ }
662
+ }
663
+ },
664
+ loadFavoritesIfNeeded: async (e) => {
665
+ const n = s();
666
+ (n.loadedFor !== e || Object.keys(n.nodes).length === 0) && await s().loadFavorites(e);
667
+ },
668
+ // ====== 공통: 생성 ======
669
+ addNode: async (e) => {
670
+ const n = D(s()), o = ee();
671
+ r((t) => {
672
+ const a = e.sortOrdr ?? A(t, e.prntBkmkId), c = {
673
+ ...t,
674
+ nodes: {
675
+ ...t.nodes,
676
+ [o]: e.type === "F" ? {
677
+ bkmkId: o,
678
+ type: "F",
679
+ prntBkmkId: e.prntBkmkId || "-",
680
+ sortOrdr: a,
681
+ bkmkNm: e.bkmkNm ?? "새 폴더",
682
+ children: [],
683
+ sysCd: e.sysCd,
684
+ userId: e.userId
685
+ } : {
686
+ bkmkId: o,
687
+ type: "M",
688
+ prntBkmkId: e.prntBkmkId,
689
+ sortOrdr: a,
690
+ menuId: e.menuId ?? "",
691
+ menuNm: e.menuNm,
692
+ sysCd: e.sysCd,
693
+ userId: e.userId
694
+ }
695
+ },
696
+ rootIds: t.rootIds.slice(),
697
+ treeNodes: t.treeNodes
698
+ };
699
+ return te(c, o, e.prntBkmkId), c.treeNodes = _(c.nodes, c.rootIds), c;
700
+ });
701
+ try {
702
+ let t = o;
703
+ const a = A(s(), e.prntBkmkId), c = await v("SCMBKMK00102", {
704
+ iudFlag: "I",
705
+ type: e.type,
706
+ sysCd: e.sysCd,
707
+ userId: e.userId,
708
+ bkmkId: o,
709
+ // 서버 새 ID 반환 시 매칭용
710
+ bkmkNm: e.bkmkNm,
711
+ prntBkmkId: e.prntBkmkId,
712
+ menuId: e.menuId,
713
+ sortOrdr: a,
714
+ chngId: N()
715
+ });
716
+ return t = String(c?.bkmkId ?? c?.itemId ?? o), r((d) => {
717
+ const u = ne(d, o, t);
718
+ return {
719
+ ...u,
720
+ treeNodes: _(u.nodes, u.rootIds)
721
+ };
722
+ }), t;
723
+ } catch (t) {
724
+ throw r(n), t;
725
+ }
726
+ },
727
+ // ====== 공통: 이동 ======
728
+ moveNode: async ({ bkmkId: e, newPrntBkmkId: n, sortOrdr: o, userId: t }) => {
729
+ const a = s(), c = structuredClone(a.nodes), d = [...a.rootIds], u = c[e];
730
+ if (!u) return;
731
+ if (n !== "-") {
732
+ const h = c[n];
733
+ if (!h || h.type !== "F")
734
+ throw new Error("부모는 폴더만 가능합니다.");
735
+ }
736
+ const i = u.prntBkmkId ?? "-", g = i === "-" ? d : c[i].children ||= [];
737
+ {
738
+ const h = g.indexOf(e);
739
+ h >= 0 && g.splice(h, 1);
740
+ }
741
+ const p = n === "-" ? d : c[n].children ||= [];
742
+ p.splice(
743
+ Math.max(0, Math.min(o, p.length)),
744
+ 0,
745
+ e
746
+ ), u.prntBkmkId = n, r({ nodes: c, rootIds: d }), U(c, d, n), U(c, d, i);
747
+ try {
748
+ await v("SCMBKMK00104", {
749
+ // 백엔드 명칭 호환
750
+ bkmkId: e,
751
+ prntBkmkId: n,
752
+ sortOrdr: o,
753
+ chngId: t
754
+ });
755
+ } catch (h) {
756
+ throw r(a), h;
757
+ }
758
+ },
759
+ // ====== 공통: 삭제 ======
760
+ removeNode: async (e) => {
761
+ const n = D(s());
762
+ r((o) => {
763
+ if (!o.nodes[e]) return o;
764
+ const t = {
765
+ ...o,
766
+ nodes: { ...o.nodes },
767
+ rootIds: o.rootIds.slice(),
768
+ treeNodes: o.treeNodes
769
+ };
770
+ return K(t, e), t.treeNodes = _(t.nodes, t.rootIds), t;
771
+ });
772
+ try {
773
+ await v("SCMBKMK00103", { bkmkId: e });
774
+ } catch (o) {
775
+ throw r(n), o;
776
+ }
777
+ },
778
+ // ====== 공통: 수정 ======
779
+ editNode: async ({ bkmkId: e, userId: n, bkmkNm: o, prntBkmkId: t, sortOrdr: a }) => {
780
+ const c = D(s());
781
+ r((d) => {
782
+ const u = { ...d, nodes: { ...d.nodes } }, i = u.nodes[e];
783
+ return i?.type === "F" && typeof o == "string" && (u.nodes[e] = {
784
+ ...i,
785
+ bkmkNm: o
786
+ }), u;
787
+ });
788
+ try {
789
+ await v("SCMBKMK00102", {
790
+ iudFlag: "U",
791
+ userId: n,
792
+ bkmkId: e,
793
+ bkmkNm: o,
794
+ prntBkmkId: t,
795
+ sortOrdr: a,
796
+ chngId: N()
797
+ });
798
+ } catch (d) {
799
+ throw r(c), d;
800
+ }
801
+ },
802
+ // ====== 호환용 래퍼 ======
803
+ addFolder: async (e, n, o, t) => await s().addNode({
804
+ type: "F",
805
+ bkmkNm: e,
806
+ prntBkmkId: n,
807
+ sysCd: o,
808
+ userId: t
809
+ }),
810
+ addMenuToFolder: async (e, n) => w(s().nodes, n.menuId) ? "이미 북마크에 저장된 메뉴입니다." : await s().addNode({
811
+ type: "M",
812
+ prntBkmkId: e,
813
+ sysCd: "KH",
814
+ userId: N(),
815
+ menuId: n.menuId,
816
+ menuNm: n.menuNm
817
+ }),
818
+ toggleMenuFavorite: async (e, n) => {
819
+ const o = s(), t = Object.values(o.nodes).find(
820
+ (c) => c.type === "M" && c.menuId === n.menuId
821
+ );
822
+ if (t) {
823
+ await s().removeNode(t.bkmkId);
824
+ return;
825
+ }
826
+ let a = $(o);
827
+ a || (await s().loadFavorites(e, !0), a = $(s())), a && await s().addNode({
828
+ type: "M",
829
+ prntBkmkId: a,
830
+ sysCd: "KH",
831
+ userId: N(),
832
+ menuId: n.menuId,
833
+ menuNm: n.menuNm
834
+ });
835
+ },
836
+ removeMenuByMenuId: async (e) => {
837
+ const n = s(), o = w(n.nodes, e);
838
+ o && await s().removeNode(o);
839
+ },
840
+ removeMenu: async (e) => {
841
+ await s().removeNode(e);
842
+ },
843
+ removeFolder: async (e) => {
844
+ await s().removeNode(e);
845
+ },
846
+ editFolder: async (e, n, o, t, a) => {
847
+ await s().editNode({
848
+ bkmkId: e,
849
+ userId: n,
850
+ bkmkNm: o,
851
+ prntBkmkId: t,
852
+ sortOrdr: a
853
+ });
854
+ },
855
+ /** Ant Tree 데이터 변환 (검색 포함) */
856
+ convertToAntTreeData: (e, n, o, t = !1) => {
857
+ const a = (d) => o ? d.toLowerCase().includes(o.toLowerCase()) : !0, c = (d) => {
858
+ const u = e[d];
859
+ if (!u || t && u.type !== "F") return null;
860
+ if (u.type === "F") {
861
+ const i = u, g = (i.children || []).map((h) => c(h)).filter(Boolean);
862
+ return a(i.bkmkNm) || g.length > 0 ? {
863
+ key: i.bkmkId,
864
+ type: "F",
865
+ title: `📁 ${i.bkmkNm}`,
866
+ bkmkNm: i.bkmkNm,
867
+ prntBkmkId: i.prntBkmkId,
868
+ sortOrdr: i.sortOrdr,
869
+ fullPath: i.fullPath,
870
+ children: g.length ? g : void 0
871
+ } : null;
872
+ } else {
873
+ const i = u, g = i.menuNm ? `${i.menuNm} (${i.menuId})` : i.menuId;
874
+ return a(g) ? {
875
+ key: i.bkmkId,
876
+ type: "M",
877
+ title: `📄 ${g}`,
878
+ prntBkmkId: i.prntBkmkId,
879
+ sortOrdr: i.sortOrdr,
880
+ fullPath: i.fullPath,
881
+ isLeaf: !0
882
+ } : null;
883
+ }
884
+ };
885
+ return n.map(c).filter(Boolean);
886
+ }
887
+ }), Q = y(W);
888
+ function V(r) {
889
+ const s = {}, e = [], n = (o) => {
890
+ o.forEach((t) => {
891
+ const a = {
892
+ type: t.type,
893
+ bkmkId: t.bkmkId ?? t.BKMK_ID ?? t.id,
894
+ prntBkmkId: t.prntBkmkId ?? t.PRNT_BKMK_ID ?? "-",
895
+ sortOrdr: Number(t.sortOrdr ?? t.SORT_ORDR ?? 0),
896
+ sysCd: t.sysCd ?? t.SYS_CD,
897
+ userId: t.userId ?? t.USER_ID,
898
+ fullPath: t.fullPath ?? t.FULL_PATH
899
+ };
900
+ if (t.type === "F") {
901
+ s[a.bkmkId] = {
902
+ ...a,
903
+ bkmkNm: t.bkmkNm ?? t.BKMK_NM ?? t.name ?? a.bkmkId,
904
+ children: []
905
+ };
906
+ const c = Array.isArray(t.children) ? t.children : [];
907
+ n(c);
908
+ } else
909
+ s[a.bkmkId] = {
910
+ ...a,
911
+ menuId: t.menuId ?? t.MENU_ID ?? "",
912
+ menuNm: t.menuNm ?? t.MENU_NM
913
+ };
914
+ });
915
+ };
916
+ return n(r), Object.values(s).forEach((o) => {
917
+ if (o.prntBkmkId && o.prntBkmkId !== "-") {
918
+ const t = s[o.prntBkmkId];
919
+ t?.type === "F" && t.children.push(o.bkmkId);
920
+ } else o.type === "F" && e.push(o.bkmkId);
921
+ }), e.sort((o, t) => (s[o].sortOrdr ?? 0) - (s[t].sortOrdr ?? 0)), Object.values(s).forEach((o) => {
922
+ o.type === "F" && o.children.sort(
923
+ (a, c) => (s[a].sortOrdr ?? 0) - (s[c].sortOrdr ?? 0)
924
+ );
925
+ }), { nodes: s, rootIds: e };
926
+ }
927
+ function D(r) {
928
+ return {
929
+ ...r,
930
+ nodes: JSON.parse(JSON.stringify(r.nodes)),
931
+ rootIds: r.rootIds.slice()
932
+ };
933
+ }
934
+ function ee() {
935
+ return `tmp_${Math.random().toString(36).slice(2, 10)}`;
936
+ }
937
+ function A(r, s) {
938
+ if (!s || s === "-") return r.rootIds.length;
939
+ const e = r.nodes[s];
940
+ return e ? e.children.length : 0;
941
+ }
942
+ function te(r, s, e) {
943
+ const n = r.nodes[s];
944
+ if (n)
945
+ if (e && e !== "-") {
946
+ const o = r.nodes[e];
947
+ if (!o || o.type !== "F") return;
948
+ n.prntBkmkId = e, o.children = [...o.children, s];
949
+ } else
950
+ n.prntBkmkId = "-", r.rootIds = [...r.rootIds, s];
951
+ }
952
+ function oe(r, s) {
953
+ const e = r.nodes[s];
954
+ if (!e) return;
955
+ const n = e.prntBkmkId;
956
+ if (n && n !== "-") {
957
+ const o = r.nodes[n];
958
+ o?.type === "F" && (o.children = o.children.filter((t) => t !== s));
959
+ } else
960
+ r.rootIds = r.rootIds.filter((o) => o !== s);
961
+ }
962
+ function K(r, s) {
963
+ const e = r.nodes[s];
964
+ if (!e) return;
965
+ e.type === "F" && e.children.slice().forEach((a) => K(r, a)), oe(r, s);
966
+ const { [s]: n, ...o } = r.nodes;
967
+ r.nodes = o;
968
+ }
969
+ function ne(r, s, e) {
970
+ if (s === e) return r;
971
+ const n = r.nodes[s];
972
+ if (!n) return r;
973
+ const o = JSON.parse(JSON.stringify(n));
974
+ o.bkmkId = e;
975
+ const t = { ...r.nodes, [e]: o };
976
+ delete t[s];
977
+ let a = r.rootIds;
978
+ if (o.prntBkmkId && o.prntBkmkId !== "-") {
979
+ const c = t[o.prntBkmkId];
980
+ c?.type === "F" && (t[o.prntBkmkId] = {
981
+ ...c,
982
+ children: c.children.map((d) => d === s ? e : d)
983
+ });
984
+ } else
985
+ a = r.rootIds.map((c) => c === s ? e : c);
986
+ return { ...r, nodes: t, rootIds: a };
987
+ }
988
+ function $(r) {
989
+ return r.rootIds.find((s) => r.nodes[s]?.type === "F") ?? null;
990
+ }
991
+ function _(r, s) {
992
+ const e = {};
993
+ Object.values(r).forEach((d) => {
994
+ const u = d.bkmkId, i = d.prntBkmkId;
995
+ !u || !i || i === "-" || i === u || (e[i] ??= []).push(u);
996
+ });
997
+ const n = /* @__PURE__ */ new Set(), o = (d) => {
998
+ if (n.has(d)) return null;
999
+ const u = r[d];
1000
+ if (!u) return null;
1001
+ n.add(d);
1002
+ try {
1003
+ if (u.type === "F") {
1004
+ const g = u, p = e[d] ?? [];
1005
+ return {
1006
+ type: "F",
1007
+ bkmkId: d,
1008
+ bkmkNm: g.bkmkNm,
1009
+ prntBkmkId: g.prntBkmkId,
1010
+ children: p.map(o).filter(Boolean)
1011
+ };
1012
+ }
1013
+ const i = u;
1014
+ return {
1015
+ type: "M",
1016
+ bkmkId: d,
1017
+ bkmkNm: i.menuNm,
1018
+ menuId: i.menuId,
1019
+ menuNm: i.menuNm,
1020
+ prntBkmkId: i.prntBkmkId
1021
+ };
1022
+ } finally {
1023
+ n.delete(d);
1024
+ }
1025
+ }, t = Object.values(r).filter((d) => d.prntBkmkId === "-" && d.type === "M").map((d) => d.bkmkId), a = Object.values(r).filter((d) => d.prntBkmkId === "-" && d.type === "F").map((d) => d.bkmkId);
1026
+ return Array.from(
1027
+ /* @__PURE__ */ new Set([...s, ...t, ...a])
1028
+ ).map(o).filter(Boolean);
1029
+ }
1030
+ function w(r, s) {
1031
+ for (const e of Object.values(r))
1032
+ if (e.type === "M" && e.menuId === s) return e.bkmkId;
1033
+ return null;
1034
+ }
1035
+ function U(r, s, e) {
1036
+ (!e || e === "-" ? s : r[e].children || []).forEach((o, t) => {
1037
+ const a = r[o];
1038
+ a && (a.sortOrdr = t);
1039
+ });
1040
+ }
1041
+ const T = {
1042
+ DEFAULT_PRNT_GBCD: 1
1043
+ }, re = (r) => r && typeof r == "object" && typeof r.menuId == "string" && typeof r.menuNm == "string", G = (r) => Array.isArray(r) && r.every(re);
1044
+ let B = [], j = [];
1045
+ const se = (r) => {
1046
+ if (r && typeof r == "object") {
1047
+ const s = r;
1048
+ if (s.menus && G(s.menus)) return s.menus;
1049
+ if (G(r)) return r;
1050
+ }
1051
+ return console.warn("⚠️ 메뉴 응답이 비어있거나 예상과 다릅니다."), [];
1052
+ }, ae = (r, s) => !!s && r.crprCd === s.crprCd && r.userId === s.userId && (r.prntGbcd ?? T.DEFAULT_PRNT_GBCD) === (s.prntGbcd ?? T.DEFAULT_PRNT_GBCD), ce = (r) => {
1053
+ if (B.length === r.length && B.every(
1054
+ (t, a) => t.menuId === r[a]?.menuId && t.menuPrntId === r[a]?.menuPrntId
1055
+ ))
1056
+ return j;
1057
+ if (!r.length) return [];
1058
+ const s = /* @__PURE__ */ new Map(), e = [];
1059
+ r.forEach((t) => t?.menuId && s.set(t.menuId, { ...t, children: [] })), r.forEach((t) => {
1060
+ const a = s.get(t.menuId);
1061
+ a && (t.menuPrntId && t.menuPrntId !== "" && t.menuPrntId !== "-" ? s.get(t.menuPrntId)?.children?.push(a) : e.push(a));
1062
+ });
1063
+ const n = (t) => t.sort((a, c) => (a?.menuNo ?? 0) - (c?.menuNo ?? 0)).map((a) => ({
1064
+ ...a,
1065
+ children: a.children && a.children.length ? n(a.children) : void 0
1066
+ })), o = n(e);
1067
+ return B = [...r], j = o, o;
1068
+ }, R = y((r, s) => ({
1069
+ // 📊 초기 상태값
1070
+ menuList: [],
1071
+ flatMenuList: [],
1072
+ isLoading: !1,
1073
+ error: null,
1074
+ _lastFetchParams: null,
1075
+ // 🔧 메뉴 모델 조회
1076
+ // 서버에서 사용자별 메뉴 권한 데이터를 가져와서 트리/플랫 구조로 저장
1077
+ fetchMenu: async ({ crprCd: e, userId: n, prntGbcd: o }) => {
1078
+ const t = {
1079
+ crprCd: e,
1080
+ userId: n,
1081
+ prntGbcd: o ?? T.DEFAULT_PRNT_GBCD
1082
+ };
1083
+ if (ae(t, s()._lastFetchParams)) {
1084
+ console.log("✅ 중복 fetch 차단", t);
1085
+ return;
1086
+ }
1087
+ r({ isLoading: !0, error: null, _lastFetchParams: t });
1088
+ try {
1089
+ const a = await v(E("AUTH_MENU"), t), c = se(a), d = ce(c);
1090
+ r({
1091
+ flatMenuList: c,
1092
+ // 평면 리스트 저장
1093
+ menuList: d,
1094
+ // 트리 구조 저장
1095
+ isLoading: !1,
1096
+ error: null
1097
+ });
1098
+ } catch (a) {
1099
+ r({ isLoading: !1, error: a?.message ?? "메뉴 로드 실패" });
1100
+ }
1101
+ },
1102
+ // 🔧 메뉴 모델 초기화
1103
+ // 로그아웃 시나 사용자 변경 시 메뉴 모델 클리어
1104
+ clearMenu: () => {
1105
+ r({
1106
+ menuList: [],
1107
+ flatMenuList: [],
1108
+ error: null,
1109
+ _lastFetchParams: null
1110
+ });
1111
+ },
1112
+ // 🔧 메뉴 ID로 메뉴 아이템 찾기
1113
+ // URL 파라미터나 프로그래밍 방식으로 특정 메뉴를 찾을 때 사용
1114
+ findMenuById: (e) => {
1115
+ const { flatMenuList: n } = s();
1116
+ return n.find((o) => o.menuId === e) ?? null;
1117
+ }
1118
+ })), P = {
1119
+ MAX_TABS: 15
1120
+ }, de = y((r, s) => ({
1121
+ // 📊 초기 상태값
1122
+ activeMenuId: null,
1123
+ activeMenuItem: null,
1124
+ activeDetailItem: null,
1125
+ tabs: [],
1126
+ sidebarCollapsed: !1,
1127
+ maxTabs: P.MAX_TABS,
1128
+ tabProtectFlag: {},
1129
+ tabParams: {},
1130
+ componentLabelMap: {},
1131
+ // 🔧 탭 추가 (메뉴 아이템 객체로)
1132
+ // 사이드바에서 메뉴 클릭 시 호출되는 메인 함수
1133
+ openTabFromMenu: (e, n) => {
1134
+ const { tabs: o } = s(), t = o.find((c) => c.key === e.menuId), a = o.find((c) => c.key === e.menuId);
1135
+ if (t)
1136
+ a != null ? (r({ activeMenuId: e.menuId, activeMenuItem: e }), s().setTabParams(e.menuId, n || {}), e?.prsnInfoYn === "Y" && s().setProtectFlagForKey(e.menuId)) : L.warning("유효하지 않은 메뉴정보입니다.");
1137
+ else {
1138
+ if (o.length > P.MAX_TABS) {
1139
+ console.warn("❌ 최대 탭 개수를 초과했습니다."), L.warning(
1140
+ `최대 ${P.MAX_TABS}개의 탭만 열 수 있습니다.
1141
+ 기존 탭을 닫고 다시 시도해주세요.`
1142
+ );
1143
+ return;
1144
+ }
1145
+ const c = {
1146
+ key: e.menuId,
1147
+ label: e.menuNm,
1148
+ gubun: "M",
1149
+ menuItem: e,
1150
+ closable: !0
1151
+ };
1152
+ r({
1153
+ tabs: [...o, c],
1154
+ // 탭 목록에 추가
1155
+ activeMenuId: e.menuId,
1156
+ // 새 탭을 활성화
1157
+ activeMenuItem: e
1158
+ // 현재 프로그램으로 설정
1159
+ }), s().setTabParams(e.menuId, n || {}), e?.prsnInfoYn === "Y" && s().setProtectFlagForKey(e.menuId);
1160
+ }
1161
+ },
1162
+ // 🔧 탭 추가 (메뉴 ID로)
1163
+ // URL 파라미터로 메뉴 열기 시 사용 (예: ?menuId=CM000301)
1164
+ openTabByMenuId: (e, n) => {
1165
+ const o = R.getState().findMenuById(e);
1166
+ o ? s().openTabFromMenu(o, n) : L.warning("메뉴 ID를 찾을 수 없습니다.");
1167
+ },
1168
+ openDetailView: (e, n, o) => {
1169
+ const { tabs: t } = s();
1170
+ if (t.find((c) => c.key === e.viewId))
1171
+ s().focusTab(e.viewId);
1172
+ else {
1173
+ const c = {
1174
+ key: e.viewId,
1175
+ label: e.viewLabel,
1176
+ gubun: "C",
1177
+ componentItem: {
1178
+ scrnPath: n,
1179
+ prsnInfoYn: o,
1180
+ prntInfo: e.prntInfo
1181
+ },
1182
+ closable: !0
1183
+ };
1184
+ r({
1185
+ tabs: [...t, c],
1186
+ // 탭 목록에 추가
1187
+ activeMenuId: e.viewId,
1188
+ // 새 탭을 활성화
1189
+ activeDetailItem: e
1190
+ }), s().setTabParams(e.viewId, e.viewParams || {});
1191
+ }
1192
+ },
1193
+ // 🔧 탭 제거
1194
+ // X 버튼 클릭 시 탭을 닫고 관련 상태도 정리
1195
+ closeTab: (e) => {
1196
+ const { tabs: n, activeMenuId: o } = s();
1197
+ n.find((c) => c.key === e);
1198
+ const t = n.filter((c) => c.key !== e);
1199
+ let a = o;
1200
+ if (o === e) {
1201
+ const c = n.findIndex((d) => d.key === e);
1202
+ a = t.length ? t[Math.min(c, t.length - 1)]?.key ?? null : null;
1203
+ }
1204
+ r({
1205
+ tabs: t
1206
+ }), a && s().focusTab(a);
1207
+ },
1208
+ // 🔧 활성 탭 변경
1209
+ // 탭 헤더 클릭 시 해당 탭으로 전환
1210
+ focusTab: (e) => {
1211
+ const { tabs: n } = s(), o = n.find((t) => t.key === e);
1212
+ if (o) {
1213
+ const t = o.gubun === "C" ? {
1214
+ viewId: o.key,
1215
+ viewLabel: o.label,
1216
+ prntInfo: o.componentItem?.prntInfo
1217
+ } : null;
1218
+ o.menuItem?.prsnInfoYn === "Y" ? (r({
1219
+ activeMenuId: e,
1220
+ activeMenuItem: o.menuItem,
1221
+ activeDetailItem: t
1222
+ }), console.log(
1223
+ "✅ 탭 포커스 (개인정보) - activeMenuItem:",
1224
+ o.menuItem
1225
+ ), s().setProtectFlagForKey(e)) : (r({
1226
+ activeMenuId: e,
1227
+ activeMenuItem: o.menuItem,
1228
+ activeDetailItem: t
1229
+ }), s().clearProtectFlagForKey(e));
1230
+ } else
1231
+ r({
1232
+ activeMenuId: e,
1233
+ activeMenuItem: null,
1234
+ activeDetailItem: null
1235
+ }), console.warn("❌ 탭을 찾을 수 없음:", e);
1236
+ },
1237
+ // 🔧 모든 탭 제거
1238
+ // 로그아웃이나 전체 초기화 시 사용
1239
+ closeAllTabs: () => r({
1240
+ tabs: [],
1241
+ activeMenuId: null,
1242
+ activeMenuItem: null,
1243
+ activeDetailItem: null
1244
+ }),
1245
+ // 🔧 사이드바 토글
1246
+ // 햄버거 메뉴 클릭 시 사이드바 접기/펼치기
1247
+ toggleSidebar: () => r((e) => ({ sidebarCollapsed: !e.sidebarCollapsed })),
1248
+ // useMenuViewStore.ts
1249
+ reorderTabs: (e) => r((n) => {
1250
+ const o = new Map(n.tabs.map((t) => [t.key, t]));
1251
+ return { tabs: e.map((t) => o.get(t)).filter(Boolean) };
1252
+ }),
1253
+ // 개인정보 포함여부에 따른 탭 잠금 Flag 설정
1254
+ setProtectFlagForKey: (e) => r((n) => ({
1255
+ tabProtectFlag: { ...n.tabProtectFlag, [e]: !0 }
1256
+ })),
1257
+ // 개인정보 포함여부에 따른 탭 잠금 해제
1258
+ clearProtectFlagForKey: (e) => r((n) => {
1259
+ const o = { ...n.tabProtectFlag };
1260
+ return delete o[e], { tabProtectFlag: o };
1261
+ }),
1262
+ // 탭 파라미터 설정
1263
+ setTabParams: (e, n) => r((o) => {
1264
+ const t = o.tabParams[e] || {}, a = { ...n || {} };
1265
+ return Object.keys(t).length === Object.keys(a).length && Object.keys(a).every((d) => t[d] === a[d]) ? o : {
1266
+ tabParams: { ...o.tabParams, [e]: a }
1267
+ };
1268
+ }),
1269
+ // 컴포넌트 라벨 맵 설정
1270
+ setComponentLabelMap: (e, n) => r({ componentLabelMap: e })
1271
+ })), le = y((r, s) => ({
1272
+ popups: [],
1273
+ activePopupId: null,
1274
+ isLoading: !1,
1275
+ error: null,
1276
+ // 팝업 열기
1277
+ openPopup: async (e, n, o) => {
1278
+ r({ isLoading: !0, error: null });
1279
+ try {
1280
+ let t = null;
1281
+ const a = await v(E("SRCH_POPU"), {
1282
+ crprCd: x()?.crprCd,
1283
+ popuCd: e
1284
+ });
1285
+ t = a?.mstr;
1286
+ const c = a?.dtls || [];
1287
+ if (!t || !t.popuUrl) {
1288
+ const p = `팝업 정보를 찾을 수 없습니다: ${e}`;
1289
+ throw console.error(p), new Error(p);
1290
+ }
1291
+ const u = ((p) => `/src/pages/views/popup/${p}`)(t.popuUrl), i = {
1292
+ popupId: `popup_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
1293
+ popupCode: e,
1294
+ //config.title을 통해 팝업 제목 변경 가능
1295
+ popupTitle: o?.title || t.popuNm || "팝업",
1296
+ popupUrl: u,
1297
+ popupParams: n,
1298
+ width: t.popuWdth || 800,
1299
+ height: t.popuHght || 600,
1300
+ resizable: !0,
1301
+ draggable: !0,
1302
+ buttonList: c,
1303
+ // 버튼 목록 추가
1304
+ config: o
1305
+ }, g = s().popups.find((p) => p.popupCode === e);
1306
+ if (g) {
1307
+ r({
1308
+ activePopupId: g.popupId,
1309
+ popups: s().popups.map(
1310
+ (p) => p.popupId === g.popupId ? { ...p, config: o } : p
1311
+ ),
1312
+ isLoading: !1
1313
+ });
1314
+ return;
1315
+ }
1316
+ r((p) => ({
1317
+ popups: [...p.popups, i],
1318
+ activePopupId: i.popupId,
1319
+ isLoading: !1
1320
+ }));
1321
+ } catch (t) {
1322
+ r({
1323
+ error: t instanceof Error ? t.message : "팝업 열기 실패",
1324
+ isLoading: !1
1325
+ });
1326
+ }
1327
+ },
1328
+ // 팝업 닫기
1329
+ closePopup: (e) => {
1330
+ const { popups: n, activePopupId: o } = s(), t = n.filter((c) => c.popupId !== e);
1331
+ let a = o;
1332
+ o === e && (a = t.length > 0 ? t[t.length - 1].popupId : null), r({
1333
+ popups: t,
1334
+ activePopupId: a
1335
+ });
1336
+ },
1337
+ // 모든 팝업 닫기
1338
+ closeAllPopups: () => {
1339
+ r({
1340
+ popups: [],
1341
+ activePopupId: null
1342
+ });
1343
+ },
1344
+ // 활성 팝업 설정
1345
+ setActivePopup: (e) => {
1346
+ r({ activePopupId: e });
1347
+ },
1348
+ // 팝업 설정 업데이트
1349
+ updatePopupConfig: (e, n) => {
1350
+ r((o) => ({
1351
+ popups: o.popups.map(
1352
+ (t) => t.popupId === e ? { ...t, config: { ...t.config, ...n } } : t
1353
+ )
1354
+ }));
1355
+ }
1356
+ })), fe = y((r) => ({
1357
+ requestCount: 0,
1358
+ loading: !1,
1359
+ showLoading: () => r((s) => {
1360
+ const e = s.requestCount + 1;
1361
+ return { requestCount: e, loading: e > 0 };
1362
+ }),
1363
+ hideLoading: () => r((s) => {
1364
+ const e = Math.max(0, s.requestCount - 1);
1365
+ return { requestCount: e, loading: e > 0 };
1366
+ })
1367
+ })), ge = y((r) => ({
1368
+ requestCount: 0,
1369
+ loading: !1,
1370
+ showLoading: () => r((s) => {
1371
+ const e = s.requestCount + 1;
1372
+ return { requestCount: e, loading: e > 0 };
1373
+ }),
1374
+ hideLoading: () => r((s) => {
1375
+ const e = Math.max(0, s.requestCount - 1);
1376
+ return { requestCount: e, loading: e > 0 };
1377
+ })
1378
+ })), Ie = () => Z.getState(), Ce = () => le.getState(), ye = () => J.getState(), be = () => Q.getState(), ke = () => R.getState(), ve = () => de.getState();
8
1379
  export {
9
- i as useCode,
10
- e as useCodeStore,
11
- x as useColorStore,
12
- c as useFavorite,
13
- t as useFavoriteStore,
14
- P as useLoadingStore,
15
- d as useMenuModel,
16
- s as useMenuModelStore,
17
- f as useMenuView,
18
- r as useMenuViewStore,
19
- C as useOptionStore,
20
- v as usePopupLoadingStore,
21
- m as usePopupState,
22
- a as usePopupStore,
23
- g as useUser,
24
- o as useUserStore
1380
+ Ie as useCode,
1381
+ Z as useCodeStore,
1382
+ me as useColorStore,
1383
+ be as useFavorite,
1384
+ Q as useFavoriteStore,
1385
+ fe as useLoadingStore,
1386
+ ke as useMenuModel,
1387
+ R as useMenuModelStore,
1388
+ ve as useMenuView,
1389
+ de as useMenuViewStore,
1390
+ he as useOptionStore,
1391
+ ge as usePopupLoadingStore,
1392
+ Ce as usePopupState,
1393
+ le as usePopupStore,
1394
+ ye as useUser,
1395
+ J as useUserStore
25
1396
  };
26
- //# sourceMappingURL=index.js.map