hia-frontend-debug-tool 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1371 @@
1
+ import React2, { useEffect, useState, useMemo, useRef, useCallback } from 'react';
2
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
+ import { isClient, getEnvironmentFromHostname } from 'hia-frontend-utils';
4
+ import { create } from 'zustand';
5
+
6
+ // src/debug-tool.tsx
7
+
8
+ // src/styles/styles.ts
9
+ var debugFloatingButtonStyle = {
10
+ position: "fixed",
11
+ right: "10px",
12
+ bottom: "80px",
13
+ borderRadius: "50%",
14
+ backgroundColor: "#f0f0f0",
15
+ border: "1px solid #ccc",
16
+ padding: "8px 12px",
17
+ fontWeight: "bold",
18
+ zIndex: 9999
19
+ };
20
+ var debugMenuPanelStyle = {
21
+ position: "fixed",
22
+ right: "20px",
23
+ bottom: "90px",
24
+ display: "flex",
25
+ flexDirection: "column",
26
+ maxHeight: "400px",
27
+ backgroundColor: "#ffffff",
28
+ border: "1px solid #e0e0e0",
29
+ borderRadius: "8px",
30
+ boxShadow: "0 4px 8px rgba(0, 0, 0, 0.1)",
31
+ zIndex: 1e4,
32
+ overflowY: "auto"
33
+ };
34
+ var panelHeaderStyle = {
35
+ display: "flex",
36
+ alignItems: "center",
37
+ justifyContent: "space-between",
38
+ padding: "10px 15px",
39
+ backgroundColor: "#f5f5f5",
40
+ borderBottom: "1px solid #e0e0e0",
41
+ flexShrink: 0
42
+ };
43
+ var h2Style = {
44
+ margin: 0,
45
+ fontSize: "16px"
46
+ };
47
+ var modalOverlayStyle = {
48
+ position: "fixed",
49
+ top: 0,
50
+ left: 0,
51
+ width: "100%",
52
+ height: "100%",
53
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
54
+ zIndex: 9999
55
+ };
56
+ var debugFeaturePanelStyle = {
57
+ margin: "20px",
58
+ position: "fixed",
59
+ top: 0,
60
+ left: 0,
61
+ width: "calc(100% - 40px)",
62
+ height: "calc(100% - 40px)",
63
+ backgroundColor: "#ffffff",
64
+ zIndex: 10001,
65
+ display: "flex",
66
+ flexDirection: "column"
67
+ };
68
+ var panelToolbarStyle = {
69
+ display: "flex",
70
+ alignItems: "center",
71
+ padding: "10px",
72
+ borderBottom: "1px solid #e0e0e0",
73
+ gap: "8px",
74
+ flexShrink: 0
75
+ };
76
+ var logListContainerStyle = {
77
+ flex: 1,
78
+ padding: "10px",
79
+ overflowY: "auto",
80
+ fontFamily: "monospace",
81
+ fontSize: "12px",
82
+ backgroundColor: "#ffffff"
83
+ };
84
+ var logItemStyle = {
85
+ display: "flex",
86
+ alignItems: "flex-start",
87
+ padding: "4px 0",
88
+ borderBottom: "1px solid #e0e0e0"
89
+ };
90
+ var logTimestampStyle = {
91
+ marginRight: "10px",
92
+ color: "#888888"
93
+ };
94
+ var logMessageStyle = {
95
+ margin: 0,
96
+ wordBreak: "break-all",
97
+ whiteSpace: "pre-wrap"
98
+ };
99
+ var logTypeStyles = {
100
+ log: { color: "#333333" },
101
+ info: { color: "#007bff" },
102
+ warn: { color: "#ffc107" },
103
+ error: { color: "#dc3545" },
104
+ debug: { color: "#6c757d" },
105
+ return: { color: "#8a2be2" }
106
+ };
107
+ var loginFormContainerStyle = {
108
+ display: "flex",
109
+ flex: 1,
110
+ flexDirection: "column",
111
+ gap: "15px",
112
+ padding: "20px",
113
+ overflowY: "auto"
114
+ };
115
+ var formActionsStyle = {
116
+ display: "flex",
117
+ justifyContent: "flex-start",
118
+ marginTop: "10px"
119
+ };
120
+ var searchContainerStyle = {
121
+ display: "flex",
122
+ gap: "8px",
123
+ marginBottom: "16px",
124
+ alignItems: "center"
125
+ };
126
+ var logListStyle = {
127
+ overflowY: "auto"
128
+ };
129
+ var logSummaryStyle = {
130
+ wordBreak: "break-all",
131
+ margin: 0,
132
+ cursor: "pointer"
133
+ };
134
+ var logContentStyle = {
135
+ padding: "8px",
136
+ wordBreak: "break-all",
137
+ whiteSpace: "pre-wrap",
138
+ backgroundColor: "#f5f5f5",
139
+ borderRadius: "4px"
140
+ };
141
+ var pageNavigationContentStyle = {
142
+ display: "flex",
143
+ flexDirection: "column",
144
+ gap: "10px",
145
+ padding: "20px"
146
+ };
147
+ var h3Style = {
148
+ margin: 0,
149
+ fontSize: "16px"
150
+ };
151
+ var scriptExecutorContentStyle = {
152
+ display: "flex",
153
+ flex: 1,
154
+ flexDirection: "column",
155
+ overflow: "hidden"
156
+ };
157
+ var scriptInputSectionStyle = {
158
+ display: "flex",
159
+ flex: 1,
160
+ flexDirection: "column",
161
+ minHeight: "150px",
162
+ borderBottom: "1px solid #e0e0e0"
163
+ };
164
+ var scriptTextareaStyle = {
165
+ flex: 1,
166
+ width: "100%",
167
+ padding: "10px",
168
+ fontFamily: "monospace",
169
+ fontSize: "14px",
170
+ resize: "none",
171
+ outline: "none",
172
+ border: "none"
173
+ };
174
+ var scriptActionsStyle = {
175
+ display: "flex",
176
+ justifyContent: "flex-end",
177
+ gap: "8px",
178
+ padding: "8px",
179
+ borderTop: "1px solid #e0e0e0"
180
+ };
181
+ var scriptOutputSectionStyle = {
182
+ display: "flex",
183
+ flex: 1,
184
+ flexDirection: "column",
185
+ overflow: "hidden"
186
+ };
187
+ var storageSearchInputStyle = {
188
+ width: "100%",
189
+ padding: "8px",
190
+ border: "1px solid #ccc",
191
+ borderRadius: "4px"
192
+ };
193
+ var storageTableContainerStyle = {
194
+ flex: 1,
195
+ overflowY: "auto",
196
+ padding: "10px"
197
+ };
198
+ var menuItemStyle = {
199
+ cursor: "pointer",
200
+ padding: "8px 12px"
201
+ };
202
+ var clearButtonStyle = {
203
+ marginLeft: "auto"
204
+ };
205
+ var networkLogContainerStyle = {
206
+ padding: "10px",
207
+ display: "flex",
208
+ flexDirection: "column",
209
+ flex: 1,
210
+ overflow: "hidden"
211
+ };
212
+ var flex1Style = {
213
+ flex: 1
214
+ };
215
+ var holdButtonsContainerStyle = {
216
+ display: "flex",
217
+ flexDirection: "row",
218
+ gap: "8px",
219
+ marginBottom: "10px"
220
+ };
221
+ var textareaStyle = {
222
+ width: "100%",
223
+ minHeight: "80px"
224
+ };
225
+ var FloatingButton = ({ onClick }) => {
226
+ const [position, setPosition] = useState({ x: 0, y: 0 });
227
+ const [isDragging, setIsDragging] = useState(false);
228
+ const [isVisible, setIsVisible] = useState(false);
229
+ const gestureStep = useRef(0);
230
+ const gestureTimeout = useRef(null);
231
+ const globalDragStart = useRef(null);
232
+ const dragHappened = useRef(false);
233
+ const dragStartPos = useRef({ x: 0, y: 0 });
234
+ const elementStartPos = useRef({ x: 0, y: 0 });
235
+ const clickCount = useRef(0);
236
+ const clickTimeout = useRef(null);
237
+ useEffect(() => {
238
+ const handleGlobalMouseDown = (e) => {
239
+ globalDragStart.current = { x: e.clientX, y: e.clientY };
240
+ };
241
+ const handleGlobalMouseUp = (e) => {
242
+ if (!globalDragStart.current) {
243
+ return;
244
+ }
245
+ const dx = e.clientX - globalDragStart.current.x;
246
+ const dy = e.clientY - globalDragStart.current.y;
247
+ const absDx = Math.abs(dx);
248
+ const absDy = Math.abs(dy);
249
+ const THRESHOLD = 200;
250
+ if (dy > THRESHOLD && absDy > absDx) {
251
+ if (gestureStep.current === 0) {
252
+ gestureStep.current = 1;
253
+ if (gestureTimeout.current) {
254
+ clearTimeout(gestureTimeout.current);
255
+ }
256
+ gestureTimeout.current = setTimeout(() => {
257
+ gestureStep.current = 0;
258
+ }, 2e3);
259
+ }
260
+ } else if (dx > THRESHOLD && absDx > absDy) {
261
+ if (gestureStep.current === 1) {
262
+ setIsVisible((prev) => !prev);
263
+ gestureStep.current = 0;
264
+ if (gestureTimeout.current) {
265
+ clearTimeout(gestureTimeout.current);
266
+ }
267
+ } else {
268
+ gestureStep.current = 0;
269
+ }
270
+ }
271
+ globalDragStart.current = null;
272
+ };
273
+ window.addEventListener("mousedown", handleGlobalMouseDown);
274
+ window.addEventListener("mouseup", handleGlobalMouseUp);
275
+ return () => {
276
+ window.removeEventListener("mousedown", handleGlobalMouseDown);
277
+ window.removeEventListener("mouseup", handleGlobalMouseUp);
278
+ if (gestureTimeout.current) {
279
+ clearTimeout(gestureTimeout.current);
280
+ }
281
+ };
282
+ }, []);
283
+ useEffect(() => {
284
+ const handleGlobalClick = () => {
285
+ clickCount.current += 1;
286
+ if (clickCount.current === 1) {
287
+ clickTimeout.current = setTimeout(() => {
288
+ clickCount.current = 0;
289
+ }, 3e3);
290
+ }
291
+ if (clickCount.current >= 10) {
292
+ setIsVisible((prev) => !prev);
293
+ clickCount.current = 0;
294
+ if (clickTimeout.current) {
295
+ clearTimeout(clickTimeout.current);
296
+ }
297
+ }
298
+ };
299
+ window.addEventListener("click", handleGlobalClick);
300
+ return () => {
301
+ window.removeEventListener("click", handleGlobalClick);
302
+ if (clickTimeout.current) {
303
+ clearTimeout(clickTimeout.current);
304
+ }
305
+ };
306
+ }, []);
307
+ const handleMouseDown = (e) => {
308
+ if (e.button !== 0) {
309
+ return;
310
+ }
311
+ dragHappened.current = false;
312
+ setIsDragging(true);
313
+ dragStartPos.current = { x: e.clientX, y: e.clientY };
314
+ elementStartPos.current = { ...position };
315
+ const handleMouseMove = (event) => {
316
+ const dx = event.clientX - dragStartPos.current.x;
317
+ const dy = event.clientY - dragStartPos.current.y;
318
+ if (!dragHappened.current && (Math.abs(dx) > 5 || Math.abs(dy) > 5)) {
319
+ dragHappened.current = true;
320
+ }
321
+ setPosition({
322
+ x: elementStartPos.current.x + dx,
323
+ y: elementStartPos.current.y + dy
324
+ });
325
+ };
326
+ const handleMouseUp = () => {
327
+ window.removeEventListener("mousemove", handleMouseMove);
328
+ window.removeEventListener("mouseup", handleMouseUp);
329
+ setIsDragging(false);
330
+ };
331
+ window.addEventListener("mousemove", handleMouseMove);
332
+ window.addEventListener("mouseup", handleMouseUp);
333
+ };
334
+ const handleClick = (e) => {
335
+ if (dragHappened.current) {
336
+ e.preventDefault();
337
+ e.stopPropagation();
338
+ return;
339
+ }
340
+ onClick();
341
+ };
342
+ const buttonStyle = {
343
+ ...debugFloatingButtonStyle,
344
+ transform: `translate(${position.x}px, ${position.y}px)`,
345
+ cursor: isDragging ? "grabbing" : "grab",
346
+ display: isVisible ? "flex" : "none"
347
+ };
348
+ return /* @__PURE__ */ jsx("button", { type: "button", style: buttonStyle, onMouseDown: handleMouseDown, onClick: handleClick, children: "DEBUG" });
349
+ };
350
+ var floating_button_default = FloatingButton;
351
+
352
+ // src/utils/cookie.ts
353
+ function getCookie(name) {
354
+ if (typeof document === "undefined") {
355
+ return "";
356
+ }
357
+ const match = document.cookie.match(new RegExp(`(?:^|; )${name.replace(/([.$?*|{}()[\]\\/+^])/g, "\\$1")}=([^;]*)`));
358
+ return match ? decodeURIComponent(match[1] ?? "") : "";
359
+ }
360
+ function setCookie(name, value, days) {
361
+ if (typeof document === "undefined") {
362
+ return;
363
+ }
364
+ let expires = "";
365
+ document.cookie = `${name}=${encodeURIComponent(value)}${expires}; path=/`;
366
+ }
367
+ function deleteCookie(name) {
368
+ if (typeof document === "undefined") {
369
+ return;
370
+ }
371
+ document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
372
+ }
373
+ function ChangeHost() {
374
+ const handleHost = (host) => {
375
+ setCookie("hia-debug-mode-env", host);
376
+ alert(`\uD638\uC2A4\uD2B8\uAC00 \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4. :${host}`);
377
+ console.log("\uD638\uC2A4\uD2B8\uAC00 \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4.", {
378
+ "hia-debug-mode-env": getCookie("hia-debug-mode-env")
379
+ });
380
+ };
381
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
382
+ /* @__PURE__ */ jsx("div", { style: panelHeaderStyle, children: /* @__PURE__ */ jsx("h2", { style: h2Style, children: "API \uD638\uC2A4\uD2B8" }) }),
383
+ /* @__PURE__ */ jsxs("ul", { children: [
384
+ /* @__PURE__ */ jsx("li", { style: menuItemStyle, onClick: () => handleHost("local"), children: "local" }),
385
+ /* @__PURE__ */ jsx("li", { style: menuItemStyle, onClick: () => handleHost("dev"), children: "dev" }),
386
+ /* @__PURE__ */ jsx("li", { style: menuItemStyle, onClick: () => handleHost("stg"), children: "stg" })
387
+ ] })
388
+ ] });
389
+ }
390
+ var filterNameCookieKey = "hia-debug-mode-filter-name";
391
+ var filterList = [
392
+ {
393
+ key: "console-log",
394
+ description: "\uCF58\uC194\uB85C\uADF8 on/off"
395
+ },
396
+ {
397
+ key: "http-log",
398
+ description: "http \uC694\uCCAD/\uC751\uB2F5 \uB85C\uADF8 on/off"
399
+ },
400
+ {
401
+ key: "validation-off",
402
+ description: "\uC720\uD6A8\uC131\uAC80\uC0AC off"
403
+ },
404
+ {
405
+ key: "data-init-button",
406
+ description: "\uCD08\uAE30\uD654 \uBC84\uD2BC \uCD94\uAC00"
407
+ }
408
+ ];
409
+ function Filter() {
410
+ const [filterName, setFilterName] = React2.useState("");
411
+ useEffect(() => {
412
+ const name = getCookie(filterNameCookieKey);
413
+ setFilterName(name);
414
+ }, []);
415
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
416
+ /* @__PURE__ */ jsx("div", { style: panelHeaderStyle, children: /* @__PURE__ */ jsx("h2", { style: h2Style, children: "\uB514\uBC84\uAE45 \uC635\uC158" }) }),
417
+ /* @__PURE__ */ jsx("ul", { children: filterList.map((filter) => /* @__PURE__ */ jsxs("li", { style: menuItemStyle, children: [
418
+ /* @__PURE__ */ jsx(
419
+ "input",
420
+ {
421
+ type: "checkbox",
422
+ checked: filterName.includes(filter.key),
423
+ onChange: (e) => {
424
+ if (e.target.checked) {
425
+ setFilterName((prev) => {
426
+ const newFilterName = prev ? `${prev},${filter.key}` : filter.key;
427
+ setCookie(filterNameCookieKey, newFilterName);
428
+ return newFilterName;
429
+ });
430
+ } else {
431
+ setFilterName((prev) => {
432
+ if (prev.includes(",")) {
433
+ const newFilterName = prev.split(",").filter((item) => item !== filter.key).join(",");
434
+ setCookie(filterNameCookieKey, newFilterName);
435
+ return newFilterName;
436
+ } else {
437
+ deleteCookie(filterNameCookieKey);
438
+ return "";
439
+ }
440
+ });
441
+ }
442
+ }
443
+ }
444
+ ),
445
+ filter.key,
446
+ " \u2014 ",
447
+ filter.description
448
+ ] }, filter.key)) })
449
+ ] });
450
+ }
451
+ function FormFactor() {
452
+ const handleFormFactor = (formFactor) => {
453
+ setCookie("x-channel-formfactor", formFactor);
454
+ alert(`\uD3FC\uD329\uD130\uAC00 \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4. :${formFactor}`);
455
+ console.log("\uD3FC\uD329\uD130\uAC00 \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4.", {
456
+ "x-channel-formfactor": getCookie("x-channel-formfactor")
457
+ });
458
+ };
459
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
460
+ /* @__PURE__ */ jsx("div", { style: panelHeaderStyle, children: /* @__PURE__ */ jsx("h2", { style: h2Style, children: "\uD3FC\uD329\uD130" }) }),
461
+ /* @__PURE__ */ jsxs("ul", { children: [
462
+ /* @__PURE__ */ jsx("li", { style: menuItemStyle, onClick: () => handleFormFactor("tablet"), children: "Tablet" }),
463
+ /* @__PURE__ */ jsx("li", { style: menuItemStyle, onClick: () => handleFormFactor("phone"), children: "Phone" }),
464
+ /* @__PURE__ */ jsx("li", { style: menuItemStyle, onClick: () => handleFormFactor("pc"), children: "PC" })
465
+ ] })
466
+ ] });
467
+ }
468
+ function InitRefresh() {
469
+ const handleDeleteHostCookie = () => {
470
+ deleteCookie("hia-debug-mode-env");
471
+ alert("\uD638\uC2A4\uD2B8\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
472
+ console.log("\uD638\uC2A4\uD2B8\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.", {
473
+ "hia-debug-mode-env": getCookie("hia-debug-mode-env")
474
+ });
475
+ };
476
+ const handleDeleteTokenCookie = () => {
477
+ deleteCookie("accessToken");
478
+ alert("\uD1A0\uD070\uCFE0\uD0A4\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
479
+ console.log("\uD1A0\uD070\uCFE0\uD0A4\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.", {
480
+ accessToken: getCookie("accessToken")
481
+ });
482
+ };
483
+ const handleDeleteCustomCookie = () => {
484
+ deleteCookie("x-channel-appversion");
485
+ deleteCookie("x-channel-deviceid");
486
+ deleteCookie("x-channel-devicemodel");
487
+ deleteCookie("x-channel-formfactor");
488
+ deleteCookie("x-channel-loginchannel");
489
+ deleteCookie("x-channel-logintype");
490
+ deleteCookie("x-channel-platformname");
491
+ deleteCookie("x-channel-platformversion");
492
+ deleteCookie("x-channel-screenid");
493
+ alert("\uCEE4\uC2A4\uD140\uCFE0\uD0A4\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
494
+ console.log("\uCEE4\uC2A4\uD140\uCFE0\uD0A4\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
495
+ };
496
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
497
+ /* @__PURE__ */ jsx("div", { style: panelHeaderStyle, children: /* @__PURE__ */ jsx("h2", { style: h2Style, children: "\uCD08\uAE30\uD654" }) }),
498
+ /* @__PURE__ */ jsxs("ul", { children: [
499
+ /* @__PURE__ */ jsx("li", { style: menuItemStyle, children: /* @__PURE__ */ jsx("button", { type: "button", onClick: () => window.location.reload(), children: "\uC0C8\uB85C\uACE0\uCE68" }) }),
500
+ /* @__PURE__ */ jsx("li", { style: menuItemStyle, children: /* @__PURE__ */ jsx("button", { type: "button", onClick: handleDeleteHostCookie, children: "Host \uC0AD\uC81C" }) }),
501
+ /* @__PURE__ */ jsx("li", { style: menuItemStyle, children: /* @__PURE__ */ jsx("button", { type: "button", onClick: handleDeleteCustomCookie, children: "\uCEE4\uC2A4\uD140(x-channel-) \uC0AD\uC81C" }) }),
502
+ /* @__PURE__ */ jsx("li", { style: menuItemStyle, children: /* @__PURE__ */ jsx("button", { type: "button", onClick: handleDeleteTokenCookie, children: "\uD1A0\uD070 \uC0AD\uC81C" }) })
503
+ ] })
504
+ ] });
505
+ }
506
+ var MenuPanel = ({ menuItems: menuItems2, onMenuItemClick, onClose, serviceCode }) => {
507
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
508
+ /* @__PURE__ */ jsx("div", { style: modalOverlayStyle, onClick: onClose }),
509
+ /* @__PURE__ */ jsxs("div", { style: debugMenuPanelStyle, children: [
510
+ /* @__PURE__ */ jsxs("div", { style: panelHeaderStyle, children: [
511
+ /* @__PURE__ */ jsx("h2", { style: h2Style, children: "Debug Menu" }),
512
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: onClose, children: "X" })
513
+ ] }),
514
+ /* @__PURE__ */ jsx("ul", { children: menuItems2.map((item) => /* @__PURE__ */ jsx("li", { onClick: () => onMenuItemClick(item.component), style: menuItemStyle, children: item.label }, item.id)) }),
515
+ serviceCode === "hia" && /* @__PURE__ */ jsxs(Fragment, { children: [
516
+ /* @__PURE__ */ jsx(Filter, {}),
517
+ /* @__PURE__ */ jsx(FormFactor, {}),
518
+ /* @__PURE__ */ jsx(ChangeHost, {}),
519
+ /* @__PURE__ */ jsx(InitRefresh, {})
520
+ ] })
521
+ ] })
522
+ ] });
523
+ };
524
+ var menu_panel_default = MenuPanel;
525
+
526
+ // src/debug-utils.ts
527
+ function isDebugByFilterName(name) {
528
+ const filterNames = getCookie(filterNameCookieKey)?.split(",");
529
+ return filterNames?.includes(name) ?? false;
530
+ }
531
+
532
+ // src/features/console-log/use-console-log.ts
533
+ var globalLogs = [];
534
+ var listeners = [];
535
+ var originalConsoleMethods = {};
536
+ var isConsoleOverridden = false;
537
+ var MAX_LOGS = 10;
538
+ var addLog = (type, ...args) => {
539
+ const newLog = {
540
+ id: Date.now() + Math.random(),
541
+ type,
542
+ timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString(),
543
+ message: args
544
+ };
545
+ if (globalLogs.length >= MAX_LOGS) {
546
+ if (!isDebugByFilterName("console-log")) {
547
+ globalLogs.shift();
548
+ }
549
+ }
550
+ globalLogs = [...globalLogs, newLog];
551
+ listeners.forEach((listener) => listener([...globalLogs]));
552
+ };
553
+ var initializeConsoleLogOverride = () => {
554
+ if (!isClient() || isConsoleOverridden) {
555
+ return;
556
+ }
557
+ const logTypes = ["log", "info", "warn", "error", "debug"];
558
+ logTypes.forEach((type) => {
559
+ originalConsoleMethods[type] = console[type];
560
+ console[type] = (...args) => {
561
+ originalConsoleMethods[type]?.apply(console, args);
562
+ addLog(type, ...args);
563
+ };
564
+ });
565
+ isConsoleOverridden = true;
566
+ };
567
+ var restoreConsoleLog = () => {
568
+ if (!isClient() || !isConsoleOverridden) {
569
+ return;
570
+ }
571
+ const logTypes = ["log", "info", "warn", "error", "debug"];
572
+ logTypes.forEach((type) => {
573
+ if (originalConsoleMethods[type]) {
574
+ console[type] = originalConsoleMethods[type];
575
+ }
576
+ });
577
+ isConsoleOverridden = false;
578
+ };
579
+ var useConsoleLog = () => {
580
+ const [logs, setLogs] = useState(globalLogs);
581
+ useEffect(() => {
582
+ listeners.push(setLogs);
583
+ return () => {
584
+ listeners = listeners.filter((l) => l !== setLogs);
585
+ };
586
+ }, []);
587
+ const clearLogs = useCallback(() => {
588
+ globalLogs = [];
589
+ listeners.forEach((listener) => listener([]));
590
+ }, []);
591
+ return { logs, clearLogs };
592
+ };
593
+ var safeStringify = (obj) => {
594
+ try {
595
+ return JSON.stringify(obj, null, 2);
596
+ } catch (e) {
597
+ return "[Unserializable Object]";
598
+ }
599
+ };
600
+ var LogMessage = ({ entry }) => {
601
+ const messageParts = entry.message.map((part) => {
602
+ if (typeof part === "object" && part !== null) {
603
+ return safeStringify(part);
604
+ }
605
+ return String(part);
606
+ });
607
+ const style = { ...logMessageStyle, ...logTypeStyles[entry.type] };
608
+ return /* @__PURE__ */ jsx("pre", { style, children: messageParts.join(" ") });
609
+ };
610
+ var ConsoleLogPanel = ({ onClose }) => {
611
+ const { logs, clearLogs } = useConsoleLog();
612
+ const [filter, setFilter] = useState("all");
613
+ const logContainerRef = useRef(null);
614
+ const filteredLogs = useMemo(() => {
615
+ if (filter === "all") {
616
+ return logs;
617
+ }
618
+ return logs.filter((log) => log.type === filter);
619
+ }, [logs, filter]);
620
+ useEffect(() => {
621
+ if (logContainerRef.current) {
622
+ logContainerRef.current.scrollTop = logContainerRef.current.scrollHeight;
623
+ }
624
+ }, [filteredLogs]);
625
+ const segmentOptions = ["all", "log", "warn", "error"];
626
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
627
+ /* @__PURE__ */ jsx("div", { style: modalOverlayStyle, onClick: onClose }),
628
+ /* @__PURE__ */ jsxs("div", { style: debugFeaturePanelStyle, children: [
629
+ /* @__PURE__ */ jsxs("div", { style: panelHeaderStyle, children: [
630
+ /* @__PURE__ */ jsx("h2", { style: h2Style, children: "Console Logs" }),
631
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: onClose, children: "X" })
632
+ ] }),
633
+ /* @__PURE__ */ jsxs("div", { style: panelToolbarStyle, children: [
634
+ /* @__PURE__ */ jsx("div", { children: segmentOptions.map((option) => /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setFilter(option), disabled: filter === option, children: option.charAt(0).toUpperCase() + option.slice(1) }, option)) }),
635
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: clearLogs, style: clearButtonStyle, children: "Clear" })
636
+ ] }),
637
+ /* @__PURE__ */ jsx("div", { style: logListContainerStyle, ref: logContainerRef, children: filteredLogs.map((log) => /* @__PURE__ */ jsxs("div", { style: logItemStyle, children: [
638
+ /* @__PURE__ */ jsx("span", { style: logTimestampStyle, children: log.timestamp }),
639
+ /* @__PURE__ */ jsx(LogMessage, { entry: log })
640
+ ] }, log.id)) })
641
+ ] })
642
+ ] });
643
+ };
644
+ var console_log_panel_default = ConsoleLogPanel;
645
+ var LoginPanel = ({ onClose, onLogin }) => {
646
+ const [selectedTypeId, setSelectedTypeId] = useState(loginTypes[0]?.id || "");
647
+ const [formData, setFormData] = useState({});
648
+ const selectedType = useMemo(() => loginTypes.find((t) => t.id === selectedTypeId), [selectedTypeId]);
649
+ const handleInputChange = (e) => {
650
+ const { name, value } = e.target;
651
+ setFormData((prev) => ({ ...prev, [name]: value }));
652
+ };
653
+ const handleSubmit = (e) => {
654
+ e.preventDefault();
655
+ if (selectedType) {
656
+ deleteCookie("accessToken");
657
+ onLogin(selectedType.id, formData);
658
+ onClose();
659
+ }
660
+ };
661
+ useEffect(() => {
662
+ setFormData({});
663
+ }, [selectedType]);
664
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
665
+ /* @__PURE__ */ jsx("div", { style: modalOverlayStyle, onClick: onClose }),
666
+ /* @__PURE__ */ jsxs("div", { style: debugFeaturePanelStyle, children: [
667
+ /* @__PURE__ */ jsxs("div", { style: panelHeaderStyle, children: [
668
+ /* @__PURE__ */ jsx("h2", { style: h2Style, children: "\uAC04\uD3B8 \uB85C\uADF8\uC778" }),
669
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: onClose, children: "X" })
670
+ ] }),
671
+ /* @__PURE__ */ jsxs("form", { style: loginFormContainerStyle, onSubmit: handleSubmit, children: [
672
+ /* @__PURE__ */ jsxs("div", { children: [
673
+ /* @__PURE__ */ jsx("label", { htmlFor: "login-type-select", children: "\uB85C\uADF8\uC778 \uC720\uD615" }),
674
+ /* @__PURE__ */ jsx("select", { id: "login-type-select", value: selectedTypeId, onChange: (e) => setSelectedTypeId(e.target.value), children: loginTypes.map((type) => /* @__PURE__ */ jsx("option", { value: type.id, children: type.label }, type.id)) })
675
+ ] }),
676
+ selectedType?.fields.map((field) => /* @__PURE__ */ jsxs("div", { children: [
677
+ /* @__PURE__ */ jsx("label", { htmlFor: field.name, children: field.label }),
678
+ /* @__PURE__ */ jsx(
679
+ "input",
680
+ {
681
+ type: field.type,
682
+ id: field.name,
683
+ name: field.name,
684
+ placeholder: field.placeholder,
685
+ value: formData[field.name] || "",
686
+ onChange: handleInputChange,
687
+ required: true
688
+ }
689
+ )
690
+ ] }, field.name)),
691
+ /* @__PURE__ */ jsx("div", { style: formActionsStyle, children: /* @__PURE__ */ jsx("button", { type: "submit", children: "\uB85C\uADF8\uC778" }) })
692
+ ] })
693
+ ] })
694
+ ] });
695
+ };
696
+ var login_panel_default = LoginPanel;
697
+ var useDebugStore = create((set, get) => ({
698
+ requests: [],
699
+ responses: [],
700
+ errors: [],
701
+ heldRequests: [],
702
+ heldResponses: [],
703
+ heldErrors: [],
704
+ isHold: false,
705
+ addRequest: (request) => set((state) => ({ requests: [...state.requests, request] })),
706
+ addResponse: (response) => set((state) => ({ responses: [...state.responses, response] })),
707
+ addError: (error) => set((state) => ({ errors: [...state.errors, error] })),
708
+ holdRequest: (item) => set((state) => ({ heldRequests: [...state.heldRequests, item] })),
709
+ holdResponse: (item) => set((state) => ({ heldResponses: [...state.heldResponses, item] })),
710
+ holdError: (item) => set((state) => ({ heldErrors: [...state.heldErrors, item] })),
711
+ playAllRequests: () => {
712
+ const { heldRequests } = get();
713
+ heldRequests.forEach((item) => item.resolver(void 0));
714
+ set({ heldRequests: [] });
715
+ },
716
+ playAllResponses: () => {
717
+ const { heldResponses } = get();
718
+ heldResponses.forEach((item) => item.resolver(void 0));
719
+ set({ heldResponses: [] });
720
+ },
721
+ toggleHold: () => set((state) => ({ isHold: !state.isHold })),
722
+ clear: () => set({
723
+ requests: [],
724
+ responses: [],
725
+ errors: [],
726
+ heldRequests: [],
727
+ heldResponses: [],
728
+ heldErrors: []
729
+ })
730
+ }));
731
+ var SEARCH_SECTIONS = [
732
+ { value: "all", label: "\uC804\uCCB4" },
733
+ { value: "url", label: "\uC8FC\uC18C" },
734
+ { value: "headers", label: "\uD5E4\uB354" },
735
+ { value: "params", label: "\uD30C\uB77C\uBBF8\uD130" },
736
+ { value: "data", label: "\uC694\uCCAD" },
737
+ { value: "response", label: "\uC751\uB2F5" },
738
+ { value: "error", label: "\uC5D0\uB7EC" }
739
+ ];
740
+ var getLogInfo = (log) => {
741
+ if (log.holdStatus === "held") {
742
+ if ("request" in log) {
743
+ return log.request;
744
+ }
745
+ if ("response" in log) {
746
+ return log.response;
747
+ }
748
+ if ("error" in log) {
749
+ return log.error;
750
+ }
751
+ }
752
+ return log;
753
+ };
754
+ var NetworkLog = ({ onClose }) => {
755
+ const {
756
+ requests,
757
+ responses,
758
+ errors,
759
+ clear,
760
+ isHold,
761
+ toggleHold,
762
+ heldRequests,
763
+ heldResponses,
764
+ heldErrors,
765
+ playAllRequests,
766
+ playAllResponses
767
+ } = useDebugStore();
768
+ const [searchTerm, setSearchTerm] = useState("");
769
+ const [searchSection, setSearchSection] = useState(SEARCH_SECTIONS[0]?.value);
770
+ const allLogs = useMemo(() => {
771
+ const logs = [];
772
+ requests.forEach((req) => logs.push({ ...req, type: "request" }));
773
+ responses.forEach((res) => logs.push({ ...res, type: "response" }));
774
+ errors.forEach((err) => logs.push({ ...err, type: "error" }));
775
+ heldRequests.forEach((req) => logs.push({ ...req, type: "request", holdStatus: "held" }));
776
+ heldResponses.forEach((res) => logs.push({ ...res, type: "response", holdStatus: "held" }));
777
+ heldErrors.forEach((err) => logs.push({ ...err, type: "error", holdStatus: "held" }));
778
+ logs.sort((a, b) => {
779
+ const aInfo = getLogInfo(a);
780
+ const bInfo = getLogInfo(b);
781
+ const aTime = "startTime" in aInfo ? aInfo.startTime : 0;
782
+ const bTime = "startTime" in bInfo ? bInfo.startTime : 0;
783
+ return bTime - aTime;
784
+ });
785
+ return logs;
786
+ }, [requests, responses, errors, heldRequests, heldResponses, heldErrors]);
787
+ const filteredLogs = useMemo(() => {
788
+ if (!searchTerm) {
789
+ return allLogs;
790
+ }
791
+ const lowercasedTerm = searchTerm.toLowerCase();
792
+ return allLogs.filter((log) => {
793
+ const logInfo = getLogInfo(log);
794
+ switch (searchSection) {
795
+ case "url":
796
+ return logInfo.url?.toLowerCase().includes(lowercasedTerm);
797
+ case "headers":
798
+ return "headers" in logInfo && logInfo.headers && JSON.stringify(logInfo.headers)?.toLowerCase().includes(lowercasedTerm);
799
+ case "params":
800
+ return "params" in logInfo && logInfo.params && JSON.stringify(logInfo.params)?.toLowerCase().includes(lowercasedTerm);
801
+ case "data":
802
+ return "data" in logInfo && logInfo.data && log.type === "request" && JSON.stringify(logInfo.data)?.toLowerCase().includes(lowercasedTerm);
803
+ case "response":
804
+ return "data" in logInfo && logInfo.data && log.type === "response" && JSON.stringify(logInfo.data)?.toLowerCase().includes(lowercasedTerm);
805
+ case "error":
806
+ return log.type === "error" && JSON.stringify(logInfo)?.toLowerCase().includes(lowercasedTerm);
807
+ case "all":
808
+ default:
809
+ return JSON.stringify(logInfo).toLowerCase().includes(lowercasedTerm);
810
+ }
811
+ });
812
+ }, [allLogs, searchTerm, searchSection]);
813
+ const renderLogSummary = (log) => {
814
+ const logInfo = getLogInfo(log);
815
+ const prefix = log.holdStatus === "held" ? "[HELD] " : "";
816
+ if (log.type === "request") {
817
+ return `${prefix}[REQ] ${logInfo.method.toUpperCase()} ${logInfo.url}`;
818
+ }
819
+ if (log.type === "response" && "status" in logInfo) {
820
+ return `${prefix}[RES] ${logInfo.method.toUpperCase()} ${logInfo.url} - ${logInfo.status}`;
821
+ }
822
+ if (log.type === "error" && "message" in logInfo) {
823
+ return `${prefix}[ERR] ${logInfo.method.toUpperCase()} ${logInfo.url} - ${logInfo.message}`;
824
+ }
825
+ return "Unknown Log";
826
+ };
827
+ const renderLogContent = (log) => {
828
+ const logInfo = getLogInfo(log);
829
+ return /* @__PURE__ */ jsx("pre", { children: JSON.stringify(logInfo, null, 2) });
830
+ };
831
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
832
+ /* @__PURE__ */ jsx("div", { style: modalOverlayStyle, onClick: onClose }),
833
+ /* @__PURE__ */ jsxs("div", { style: debugFeaturePanelStyle, children: [
834
+ /* @__PURE__ */ jsxs("div", { style: panelHeaderStyle, children: [
835
+ /* @__PURE__ */ jsx("h2", { style: h2Style, children: "\uB124\uD2B8\uC6CC\uD06C \uB85C\uADF8" }),
836
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: onClose, children: "X" })
837
+ ] }),
838
+ /* @__PURE__ */ jsxs("div", { style: networkLogContainerStyle, children: [
839
+ /* @__PURE__ */ jsxs("div", { style: searchContainerStyle, children: [
840
+ /* @__PURE__ */ jsx("select", { value: searchSection, onChange: (e) => setSearchSection(e.target.value), children: SEARCH_SECTIONS.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value)) }),
841
+ /* @__PURE__ */ jsx(
842
+ "input",
843
+ {
844
+ type: "text",
845
+ placeholder: "\uAC80\uC0C9...",
846
+ value: searchTerm,
847
+ onChange: (e) => setSearchTerm(e.target.value),
848
+ style: flex1Style
849
+ }
850
+ ),
851
+ /* @__PURE__ */ jsxs("label", { children: [
852
+ /* @__PURE__ */ jsx("input", { type: "checkbox", checked: isHold, onChange: toggleHold }),
853
+ "Hold"
854
+ ] }),
855
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: clear, children: "clear" })
856
+ ] }),
857
+ isHold && /* @__PURE__ */ jsxs("div", { style: holdButtonsContainerStyle, children: [
858
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => playAllRequests(), children: "REQ Resolve" }),
859
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => playAllResponses(), children: "RES Resolve" })
860
+ ] }),
861
+ /* @__PURE__ */ jsx("div", { style: logListStyle, children: filteredLogs.length === 0 ? /* @__PURE__ */ jsx("p", { children: "\uD45C\uC2DC\uD560 \uB85C\uADF8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4." }) : /* @__PURE__ */ jsx("div", { children: filteredLogs.map((log, index) => /* @__PURE__ */ jsxs("details", { children: [
862
+ /* @__PURE__ */ jsx("summary", { style: logSummaryStyle, children: renderLogSummary(log) }),
863
+ /* @__PURE__ */ jsx("div", { style: logContentStyle, children: renderLogContent(log) })
864
+ ] }, index)) }) })
865
+ ] })
866
+ ] })
867
+ ] });
868
+ };
869
+ var network_log_default = NetworkLog;
870
+ var LocationInfo = () => {
871
+ return Object.keys(location).map((key) => {
872
+ const val = location[key];
873
+ if (typeof val === "string") {
874
+ return /* @__PURE__ */ jsxs("div", { children: [
875
+ key,
876
+ ": ",
877
+ val,
878
+ " ",
879
+ val && /* @__PURE__ */ jsx("button", { type: "button", onClick: () => navigator.clipboard.writeText(val), children: "\uBCF5\uC0AC" })
880
+ ] }, key);
881
+ }
882
+ });
883
+ };
884
+ var PageNavigationPanel = ({ onClose }) => {
885
+ const [url, setUrl] = useState("");
886
+ const handleNavigate = () => {
887
+ if (url) {
888
+ self.location.href = url;
889
+ }
890
+ };
891
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
892
+ /* @__PURE__ */ jsx("div", { style: modalOverlayStyle, onClick: onClose }),
893
+ /* @__PURE__ */ jsxs("div", { style: debugFeaturePanelStyle, children: [
894
+ /* @__PURE__ */ jsxs("div", { style: panelHeaderStyle, children: [
895
+ /* @__PURE__ */ jsx("h2", { style: h2Style, children: "\uD398\uC774\uC9C0 \uC815\uBCF4" }),
896
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: onClose, children: "X" })
897
+ ] }),
898
+ /* @__PURE__ */ jsxs("div", { style: pageNavigationContentStyle, children: [
899
+ /* @__PURE__ */ jsx("br", {}),
900
+ /* @__PURE__ */ jsx("br", {}),
901
+ "\uD398\uC774\uC9C0\uC815\uBCF4 :",
902
+ /* @__PURE__ */ jsx("span", { style: { whiteSpace: "normal", wordBreak: "break-all" }, children: LocationInfo() }),
903
+ /* @__PURE__ */ jsx("br", {}),
904
+ /* @__PURE__ */ jsx("br", {}),
905
+ "\uD398\uC774\uC9C0\uC774\uB3D9 :",
906
+ /* @__PURE__ */ jsx(
907
+ "input",
908
+ {
909
+ type: "text",
910
+ value: url,
911
+ onChange: (e) => setUrl(e.target.value),
912
+ placeholder: "\uC774\uB3D9\uD560 URL\uC744 \uC785\uB825\uD558\uC138\uC694 (\uC608: /main)",
913
+ style: flex1Style
914
+ }
915
+ ),
916
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: handleNavigate, children: "\uC774\uB3D9" })
917
+ ] })
918
+ ] })
919
+ ] });
920
+ };
921
+ var page_navigation_panel_default = PageNavigationPanel;
922
+ var logTypeStyles2 = {
923
+ log: { color: "#333333" },
924
+ warn: { color: "#ffc107" },
925
+ error: { color: "#dc3545" },
926
+ return: { color: "#8a2be2" }
927
+ };
928
+ var safeStringify2 = (obj) => {
929
+ try {
930
+ const replacer = (_key, value) => typeof value === "bigint" ? value.toString() : value;
931
+ return JSON.stringify(obj, replacer, 2);
932
+ } catch (e) {
933
+ return "[Unserializable Object]";
934
+ }
935
+ };
936
+ var ResultMessage = ({ log }) => {
937
+ const messageParts = log.message.map((part) => {
938
+ if (typeof part === "object" && part !== null) {
939
+ return safeStringify2(part);
940
+ }
941
+ return String(part);
942
+ });
943
+ const prefix = log.type === "return" ? "\u21A9 " : "";
944
+ const style = { ...logMessageStyle, ...logTypeStyles2[log.type] };
945
+ return /* @__PURE__ */ jsxs("pre", { style, children: [
946
+ prefix,
947
+ messageParts.join(" ")
948
+ ] });
949
+ };
950
+ var ScriptExecutorPanel = ({ onClose }) => {
951
+ const [code, setCode] = useState('// \uC5EC\uAE30\uC5D0 \uC2E4\uD589\uD560 \uCF54\uB4DC\uB97C \uC785\uB825\uD558\uC138\uC694\nconsole.log("Hello, World!");');
952
+ const [results, setResults] = useState([]);
953
+ const addResult = (type, ...args) => {
954
+ setResults((prevResults) => [
955
+ ...prevResults,
956
+ {
957
+ id: Date.now() + Math.random(),
958
+ type,
959
+ timestamp: (/* @__PURE__ */ new Date()).toLocaleTimeString(),
960
+ message: args
961
+ }
962
+ ]);
963
+ };
964
+ const handleExecute = () => {
965
+ const originalConsole = { ...console };
966
+ const newConsole = {
967
+ log: (...args) => {
968
+ originalConsole.log(...args);
969
+ addResult("log", ...args);
970
+ },
971
+ warn: (...args) => {
972
+ originalConsole.warn(...args);
973
+ addResult("warn", ...args);
974
+ },
975
+ error: (...args) => {
976
+ originalConsole.error(...args);
977
+ addResult("error", ...args);
978
+ }
979
+ };
980
+ try {
981
+ Object.assign(console, newConsole);
982
+ const result = new Function(code)();
983
+ if (result !== void 0) {
984
+ addResult("return", result);
985
+ }
986
+ } catch (e) {
987
+ addResult("error", e.name, e.message);
988
+ } finally {
989
+ Object.assign(console, originalConsole);
990
+ }
991
+ };
992
+ const handleClear = () => {
993
+ setResults([]);
994
+ };
995
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
996
+ /* @__PURE__ */ jsx("div", { style: modalOverlayStyle, onClick: onClose }),
997
+ /* @__PURE__ */ jsxs("div", { style: { ...debugFeaturePanelStyle, ...scriptExecutorContentStyle }, children: [
998
+ /* @__PURE__ */ jsxs("div", { style: panelHeaderStyle, children: [
999
+ /* @__PURE__ */ jsx("h2", { style: h2Style, children: "\uC2A4\uD06C\uB9BD\uD2B8 \uC2E4\uD589" }),
1000
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: onClose, children: "X" })
1001
+ ] }),
1002
+ /* @__PURE__ */ jsxs("div", { style: scriptExecutorContentStyle, children: [
1003
+ /* @__PURE__ */ jsxs("div", { style: scriptInputSectionStyle, children: [
1004
+ /* @__PURE__ */ jsx(
1005
+ "textarea",
1006
+ {
1007
+ style: scriptTextareaStyle,
1008
+ value: code,
1009
+ onChange: (e) => setCode(e.target.value),
1010
+ spellCheck: false
1011
+ }
1012
+ ),
1013
+ /* @__PURE__ */ jsxs("div", { style: scriptActionsStyle, children: [
1014
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: handleExecute, children: "\uC2E4\uD589 (\u25B6)" }),
1015
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: handleClear, children: "\uACB0\uACFC \uC9C0\uC6B0\uAE30" })
1016
+ ] })
1017
+ ] }),
1018
+ /* @__PURE__ */ jsxs("div", { style: scriptOutputSectionStyle, children: [
1019
+ /* @__PURE__ */ jsx("div", { style: panelHeaderStyle, children: /* @__PURE__ */ jsx("h3", { style: h3Style, children: "\uACB0\uACFC" }) }),
1020
+ /* @__PURE__ */ jsx("div", { style: logListContainerStyle, children: results.map((log) => /* @__PURE__ */ jsxs("div", { style: logItemStyle, children: [
1021
+ /* @__PURE__ */ jsx("span", { style: logTimestampStyle, children: log.timestamp }),
1022
+ /* @__PURE__ */ jsx(ResultMessage, { log })
1023
+ ] }, log.id)) })
1024
+ ] })
1025
+ ] })
1026
+ ] })
1027
+ ] });
1028
+ };
1029
+ var script_executor_panel_default = ScriptExecutorPanel;
1030
+ var useStorage = (storageType) => {
1031
+ const [items, setItems] = useState([]);
1032
+ const loadItems = useCallback(() => {
1033
+ const newItems = [];
1034
+ if (storageType === "localStorage") {
1035
+ for (let i = 0; i < localStorage.length; i++) {
1036
+ const key = localStorage.key(i);
1037
+ if (key) {
1038
+ newItems.push({ key, value: localStorage.getItem(key) || "" });
1039
+ }
1040
+ }
1041
+ } else {
1042
+ const cookies = document.cookie.split(";");
1043
+ cookies.forEach((cookie) => {
1044
+ const parts = cookie.split("=");
1045
+ const key = parts.shift()?.trim();
1046
+ if (key) {
1047
+ newItems.push({ key, value: decodeURIComponent(parts.join("=")) });
1048
+ }
1049
+ });
1050
+ }
1051
+ setItems(newItems);
1052
+ }, [storageType]);
1053
+ useEffect(() => {
1054
+ loadItems();
1055
+ }, [loadItems]);
1056
+ const setItem = useCallback(
1057
+ (key, value) => {
1058
+ if (storageType === "localStorage") {
1059
+ localStorage.setItem(key, value);
1060
+ } else {
1061
+ setCookie(key, value);
1062
+ }
1063
+ loadItems();
1064
+ },
1065
+ [storageType, loadItems]
1066
+ );
1067
+ const removeItem = useCallback(
1068
+ (key) => {
1069
+ if (storageType === "localStorage") {
1070
+ localStorage.removeItem(key);
1071
+ } else {
1072
+ deleteCookie(key);
1073
+ }
1074
+ loadItems();
1075
+ },
1076
+ [storageType, loadItems]
1077
+ );
1078
+ return { items, setItem, removeItem, loadItems };
1079
+ };
1080
+ var ValueDisplay = ({ value }) => {
1081
+ try {
1082
+ const parsed = JSON.parse(value);
1083
+ if (typeof parsed === "object" && parsed !== null) {
1084
+ return /* @__PURE__ */ jsx("pre", { style: logContentStyle, children: JSON.stringify(parsed, null, 2) });
1085
+ }
1086
+ } catch (e) {
1087
+ }
1088
+ return /* @__PURE__ */ jsx("div", { style: logContentStyle, children: value });
1089
+ };
1090
+ var EditableRow = ({
1091
+ item,
1092
+ onSave,
1093
+ onRemove
1094
+ }) => {
1095
+ const [isEditing, setIsEditing] = useState(false);
1096
+ const [value, setValue] = useState(item.value);
1097
+ const handleSave = () => {
1098
+ onSave(item.key, value);
1099
+ setIsEditing(false);
1100
+ };
1101
+ const handleEdit = () => {
1102
+ setValue(item.value);
1103
+ setIsEditing(true);
1104
+ };
1105
+ return /* @__PURE__ */ jsxs("details", { children: [
1106
+ /* @__PURE__ */ jsx("summary", { children: item.key }),
1107
+ /* @__PURE__ */ jsxs("div", { children: [
1108
+ isEditing ? /* @__PURE__ */ jsx("button", { type: "button", onClick: handleSave, children: "Save" }) : /* @__PURE__ */ jsx("button", { type: "button", onClick: handleEdit, children: "Edit" }),
1109
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => onRemove(item.key), children: "Remove" }),
1110
+ isEditing ? /* @__PURE__ */ jsx("textarea", { value, onChange: (e) => setValue(e.target.value), style: textareaStyle }) : /* @__PURE__ */ jsx(ValueDisplay, { value: item.value })
1111
+ ] })
1112
+ ] });
1113
+ };
1114
+ var StoragePanel = ({ onClose, storageType }) => {
1115
+ const { items, setItem, removeItem } = useStorage(storageType);
1116
+ const [filter, setFilter] = useState("");
1117
+ const filteredItems = useMemo(() => {
1118
+ if (!filter) {
1119
+ return items;
1120
+ }
1121
+ return items.filter(
1122
+ (item) => item.key.toLowerCase().includes(filter.toLowerCase()) || item.value.toLowerCase().includes(filter.toLowerCase())
1123
+ );
1124
+ }, [items, filter]);
1125
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1126
+ /* @__PURE__ */ jsx("div", { style: modalOverlayStyle, onClick: onClose }),
1127
+ /* @__PURE__ */ jsxs("div", { style: debugFeaturePanelStyle, children: [
1128
+ /* @__PURE__ */ jsxs("div", { style: panelHeaderStyle, children: [
1129
+ /* @__PURE__ */ jsx("h2", { style: h2Style, children: storageType === "localStorage" ? "Local Storage" : "Cookies" }),
1130
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: onClose, children: "X" })
1131
+ ] }),
1132
+ /* @__PURE__ */ jsx("div", { style: panelToolbarStyle, children: /* @__PURE__ */ jsx(
1133
+ "input",
1134
+ {
1135
+ type: "text",
1136
+ placeholder: "Search key or value...",
1137
+ value: filter,
1138
+ onChange: (e) => setFilter(e.target.value),
1139
+ style: storageSearchInputStyle
1140
+ }
1141
+ ) }),
1142
+ /* @__PURE__ */ jsx("div", { style: storageTableContainerStyle, children: filteredItems.map((item) => /* @__PURE__ */ jsx(EditableRow, { item, onSave: setItem, onRemove: removeItem }, item.key)) })
1143
+ ] })
1144
+ ] });
1145
+ };
1146
+ var storage_panel_default = StoragePanel;
1147
+ var loginTypes = [
1148
+ {
1149
+ id: "fp",
1150
+ label: "FP \uB85C\uADF8\uC778",
1151
+ fields: [{ name: "employeeId", label: "\uC0AC\uBC88", type: "text", placeholder: "\uC0AC\uBC88\uC744 \uC785\uB825\uD558\uC138\uC694" }]
1152
+ }
1153
+ ];
1154
+ var menuItems = [
1155
+ {
1156
+ id: "network-log",
1157
+ label: "\uB124\uD2B8\uC6CC\uD06C \uB85C\uADF8",
1158
+ component: network_log_default,
1159
+ display: true
1160
+ },
1161
+ {
1162
+ id: "console-log",
1163
+ label: "\uCF58\uC194 \uB85C\uADF8 \uD655\uC778",
1164
+ component: console_log_panel_default,
1165
+ display: true
1166
+ },
1167
+ {
1168
+ id: "local-storage",
1169
+ label: "\uB85C\uCEEC \uC2A4\uD1A0\uB9AC\uC9C0 \uAD00\uB9AC",
1170
+ component: (props) => /* @__PURE__ */ jsx(storage_panel_default, { ...props, storageType: "localStorage" }),
1171
+ display: true
1172
+ },
1173
+ {
1174
+ id: "cookie-management",
1175
+ label: "\uCFE0\uD0A4 \uAD00\uB9AC",
1176
+ component: (props) => /* @__PURE__ */ jsx(storage_panel_default, { ...props, storageType: "cookie" }),
1177
+ display: true
1178
+ },
1179
+ {
1180
+ id: "quick-login",
1181
+ label: "\uAC04\uD3B8 \uB85C\uADF8\uC778",
1182
+ component: login_panel_default,
1183
+ display: true
1184
+ },
1185
+ {
1186
+ id: "script-executor",
1187
+ label: "\uC2A4\uD06C\uB9BD\uD2B8 \uC2E4\uD589",
1188
+ component: script_executor_panel_default,
1189
+ display: true
1190
+ },
1191
+ {
1192
+ id: "page-navigation",
1193
+ label: "\uD398\uC774\uC9C0 \uC815\uBCF4",
1194
+ component: page_navigation_panel_default,
1195
+ display: true
1196
+ }
1197
+ ];
1198
+ var useEnvironment = () => {
1199
+ const [envInfo, setEnvInfo] = useState({
1200
+ env: "prd"
1201
+ });
1202
+ useEffect(() => {
1203
+ const { hostname } = window.location;
1204
+ setEnvInfo({ env: getEnvironmentFromHostname(hostname) });
1205
+ }, []);
1206
+ return envInfo;
1207
+ };
1208
+ var DebugTool = ({
1209
+ onLogin,
1210
+ envOverride,
1211
+ menuItemsOverride,
1212
+ serviceCode = "etc"
1213
+ }) => {
1214
+ useEffect(() => {
1215
+ initializeConsoleLogOverride();
1216
+ return () => {
1217
+ restoreConsoleLog();
1218
+ };
1219
+ }, []);
1220
+ const environment = useEnvironment();
1221
+ const env = envOverride || environment.env;
1222
+ const menuItems2 = menuItemsOverride || menuItems;
1223
+ const [isMenuOpen, setMenuOpen] = useState(false);
1224
+ const [activeFeature, setActiveFeature] = useState(null);
1225
+ const isVisible = ["local", "dev", "stg"].includes(env);
1226
+ const handleMenuClick = (itemComponent) => {
1227
+ setActiveFeature(() => itemComponent);
1228
+ setMenuOpen(false);
1229
+ };
1230
+ const handleCloseFeature = () => {
1231
+ setActiveFeature(null);
1232
+ };
1233
+ if (!isVisible) {
1234
+ return null;
1235
+ }
1236
+ const toggleMenu = () => {
1237
+ setMenuOpen((prev) => !prev);
1238
+ if (!isMenuOpen) {
1239
+ setActiveFeature(null);
1240
+ }
1241
+ };
1242
+ const availableMenuItems = menuItems2.filter(
1243
+ (item) => item.display && (item.id !== "quick-login" || item.id === "quick-login" && onLogin)
1244
+ );
1245
+ if (activeFeature) {
1246
+ const FeatureComponent = activeFeature;
1247
+ return /* @__PURE__ */ jsx(FeatureComponent, { onClose: handleCloseFeature, onLogin });
1248
+ }
1249
+ return /* @__PURE__ */ jsxs(
1250
+ "div",
1251
+ {
1252
+ style: {
1253
+ position: "fixed",
1254
+ right: "20px",
1255
+ bottom: "20px",
1256
+ zIndex: 9999
1257
+ },
1258
+ children: [
1259
+ /* @__PURE__ */ jsx(floating_button_default, { onClick: toggleMenu }),
1260
+ isMenuOpen && /* @__PURE__ */ jsx(
1261
+ menu_panel_default,
1262
+ {
1263
+ menuItems: availableMenuItems,
1264
+ onMenuItemClick: handleMenuClick,
1265
+ onClose: () => setMenuOpen(false),
1266
+ serviceCode
1267
+ }
1268
+ )
1269
+ ]
1270
+ }
1271
+ );
1272
+ };
1273
+ var MAX_LOGS2 = 20;
1274
+ function addRequestLog(config) {
1275
+ if (!isClient()) {
1276
+ return;
1277
+ }
1278
+ const env = getEnvironmentFromHostname(location.hostname);
1279
+ if (env !== "prd") {
1280
+ const { addRequest, isHold, holdRequest, requests } = useDebugStore.getState();
1281
+ if (requests.length >= MAX_LOGS2) {
1282
+ if (!isDebugByFilterName("http-log")) {
1283
+ requests.shift();
1284
+ }
1285
+ }
1286
+ const startTime = Date.now();
1287
+ const requestInfo = {
1288
+ url: config.url || "",
1289
+ method: config.method || "",
1290
+ headers: config.headers,
1291
+ params: config.params,
1292
+ data: config.data,
1293
+ startTime
1294
+ };
1295
+ if (isHold) {
1296
+ return new Promise((resolver) => {
1297
+ holdRequest({ request: requestInfo, resolver });
1298
+ });
1299
+ } else {
1300
+ addRequest(requestInfo);
1301
+ }
1302
+ }
1303
+ }
1304
+ function addResponseLog(response) {
1305
+ if (!isClient()) {
1306
+ return;
1307
+ }
1308
+ const env = getEnvironmentFromHostname(location.hostname);
1309
+ if (env !== "prd") {
1310
+ const { addResponse, isHold, holdResponse, responses } = useDebugStore.getState();
1311
+ if (responses.length >= MAX_LOGS2) {
1312
+ if (!isDebugByFilterName("http-log")) {
1313
+ responses.shift();
1314
+ }
1315
+ }
1316
+ const { config } = response;
1317
+ const responseInfo = {
1318
+ url: config.url || "",
1319
+ method: config.method || "",
1320
+ status: response.status,
1321
+ statusText: response.statusText,
1322
+ headers: response.headers,
1323
+ data: response.data
1324
+ };
1325
+ if (isHold) {
1326
+ return new Promise((resolver) => {
1327
+ holdResponse({ response: responseInfo, resolver });
1328
+ });
1329
+ } else {
1330
+ addResponse(responseInfo);
1331
+ }
1332
+ }
1333
+ }
1334
+ function addErrorLog(error) {
1335
+ if (!isClient()) {
1336
+ return;
1337
+ }
1338
+ const env = getEnvironmentFromHostname(location.hostname);
1339
+ if (env !== "prd") {
1340
+ const { addError, isHold, holdError, errors } = useDebugStore.getState();
1341
+ if (errors.length >= MAX_LOGS2) {
1342
+ if (!isDebugByFilterName("http-log")) {
1343
+ errors.shift();
1344
+ }
1345
+ }
1346
+ const { config } = error;
1347
+ const errorInfo = {
1348
+ url: config?.url || "",
1349
+ method: config?.method || "",
1350
+ message: error.message,
1351
+ config: error.config,
1352
+ response: error.response ? {
1353
+ url: error.response.config?.url || "",
1354
+ method: error.response.config?.method || "",
1355
+ status: error.response.status,
1356
+ statusText: error.response.statusText,
1357
+ headers: error.response.headers,
1358
+ data: error.response.data
1359
+ } : void 0
1360
+ };
1361
+ if (isHold) {
1362
+ return new Promise((resolver) => {
1363
+ holdError({ error: errorInfo, resolver });
1364
+ });
1365
+ } else {
1366
+ addError(errorInfo);
1367
+ }
1368
+ }
1369
+ }
1370
+
1371
+ export { DebugTool, addErrorLog, addRequestLog, addResponseLog, isDebugByFilterName };