File size: 27,892 Bytes
d82b099
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>๋ฉ€ํ‹ฐ ์—์ด์ „ํŠธ ์ฑ„ํŒ… ์‹œ์Šคํ…œ</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .agent-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .message-animation {
            animation: fadeIn 0.3s ease-out;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .typing-indicator {
            display: inline-flex;
            align-items: center;
        }
        .typing-dot {
            width: 8px;
            height: 8px;
            background-color: #9CA3AF;
            border-radius: 50%;
            margin: 0 2px;
            animation: typingAnimation 1.4s infinite ease-in-out;
        }
        .typing-dot:nth-child(1) { animation-delay: 0s; }
        .typing-dot:nth-child(2) { animation-delay: 0.2s; }
        .typing-dot:nth-child(3) { animation-delay: 0.4s; }
        @keyframes typingAnimation {
            0%, 60%, 100% { transform: translateY(0); }
            30% { transform: translateY(-5px); }
        }
    </style>
</head>
<body class="bg-gray-100 font-sans">
    <div class="container mx-auto px-4 py-8 max-w-7xl">
        <header class="mb-8 text-center">
            <h1 class="text-4xl font-bold text-indigo-800 mb-2">๋ฉ€ํ‹ฐ ์—์ด์ „ํŠธ ์ฑ„ํŒ… ์‹œ์Šคํ…œ</h1>
            <p class="text-gray-600">์—ฌ๋Ÿฌ AI ์—์ด์ „ํŠธ์™€ ๋™์‹œ์— ๋Œ€ํ™”ํ•˜๋ฉฐ ๋‹ค์–‘ํ•œ ๊ด€์ ์„ ๊ฒฝํ—˜ํ•˜์„ธ์š”</p>
        </header>

        <div class="flex flex-col lg:flex-row gap-6">
            <!-- ์—์ด์ „ํŠธ ์„ ํƒ ํŒจ๋„ -->
            <div class="w-full lg:w-1/4 bg-white rounded-xl shadow-md p-4 h-fit">
                <h2 class="text-xl font-semibold text-gray-800 mb-4">์—์ด์ „ํŠธ ์„ ํƒ</h2>
                <div class="space-y-3">
                    <div class="agent-card bg-indigo-50 p-4 rounded-lg cursor-pointer transition-all duration-300 border border-indigo-100" 
                         onclick="selectAgent('analyst')" data-agent="analyst">
                        <div class="flex items-center">
                            <div class="w-10 h-10 rounded-full bg-indigo-200 flex items-center justify-center mr-3">
                                <i class="fas fa-chart-line text-indigo-600"></i>
                            </div>
                            <div>
                                <h3 class="font-medium text-indigo-800">๋ถ„์„๊ฐ€ ์•Œ๋ ‰์Šค</h3>
                                <p class="text-xs text-gray-500">๋ฐ์ดํ„ฐ ๋ถ„์„ ์ „๋ฌธ๊ฐ€</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="agent-card bg-green-50 p-4 rounded-lg cursor-pointer transition-all duration-300 border border-green-100" 
                         onclick="selectAgent('creative')" data-agent="creative">
                        <div class="flex items-center">
                            <div class="w-10 h-10 rounded-full bg-green-200 flex items-center justify-center mr-3">
                                <i class="fas fa-paint-brush text-green-600"></i>
                            </div>
                            <div>
                                <h3 class="font-medium text-green-800">ํฌ๋ฆฌ์—์ดํ„ฐ ํด๋กœ์ด</h3>
                                <p class="text-xs text-gray-500">์ฐฝ์˜์  ์•„์ด๋””์–ด ์ƒ์„ฑ๊ธฐ</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="agent-card bg-red-50 p-4 rounded-lg cursor-pointer transition-all duration-300 border border-red-100" 
                         onclick="selectAgent('debater')" data-agent="debater">
                        <div class="flex items-center">
                            <div class="w-10 h-10 rounded-full bg-red-200 flex items-center justify-center mr-3">
                                <i class="fas fa-comments text-red-600"></i>
                            </div>
                            <div>
                                <h3 class="font-medium text-red-800">ํ† ๋ก ๊ฐ€ ๋ฐ์ด๋น—</h3>
                                <p class="text-xs text-gray-500">๋…ผ๋ฆฌ์  ํ† ๋ก  ์ „๋ฌธ๊ฐ€</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="agent-card bg-yellow-50 p-4 rounded-lg cursor-pointer transition-all duration-300 border border-yellow-100" 
                         onclick="selectAgent('advisor')" data-agent="advisor">
                        <div class="flex items-center">
                            <div class="w-10 h-10 rounded-full bg-yellow-200 flex items-center justify-center mr-3">
                                <i class="fas fa-lightbulb text-yellow-600"></i>
                            </div>
                            <div>
                                <h3 class="font-medium text-yellow-800">์กฐ์–ธ๊ฐ€ ์ œ์‹œ์นด</h3>
                                <p class="text-xs text-gray-500">์ „๋žต์  ์กฐ์–ธ ์ œ๊ณต์ž</p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="mt-6">
                    <h3 class="text-sm font-semibold text-gray-700 mb-2">์‹œ์Šคํ…œ ์„ค์ •</h3>
                    <div class="flex items-center justify-between mb-2">
                        <span class="text-sm text-gray-600">์—์ด์ „ํŠธ ๊ฐ„ ์ƒํ˜ธ์ž‘์šฉ</span>
                        <label class="relative inline-flex items-center cursor-pointer">
                            <input type="checkbox" id="agentInteraction" class="sr-only peer" checked>
                            <div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                        </label>
                    </div>
                    <div class="flex items-center justify-between">
                        <span class="text-sm text-gray-600">์‹ค์‹œ๊ฐ„ ๋ฐ˜์‘</span>
                        <label class="relative inline-flex items-center cursor-pointer">
                            <input type="checkbox" id="realtimeResponse" class="sr-only peer" checked>
                            <div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
                        </label>
                    </div>
                </div>
            </div>

            <!-- ์ฑ„ํŒ… ๋ฉ”์ธ ์˜์—ญ -->
            <div class="w-full lg:w-3/4 flex flex-col">
                <!-- ์„ ํƒ๋œ ์—์ด์ „ํŠธ ํ‘œ์‹œ -->
                <div class="bg-white rounded-xl shadow-md p-4 mb-4">
                    <div class="flex flex-wrap gap-3" id="selectedAgentsContainer">
                        <div class="text-sm text-gray-500">์—์ด์ „ํŠธ๋ฅผ ์„ ํƒํ•˜์„ธ์š” (๋ณต์ˆ˜ ์„ ํƒ ๊ฐ€๋Šฅ)</div>
                    </div>
                </div>

                <!-- ์ฑ„ํŒ… ๋‚ด์šฉ -->
                <div class="flex-1 bg-white rounded-xl shadow-md p-4 mb-4 overflow-y-auto" id="chatContainer" style="min-height: 400px;">
                    <div class="text-center text-gray-500 py-10" id="welcomeMessage">
                        <i class="fas fa-robot text-4xl text-indigo-300 mb-3"></i>
                        <p class="text-lg">๋ฉ€ํ‹ฐ ์—์ด์ „ํŠธ ์ฑ„ํŒ… ์‹œ์Šคํ…œ์— ์˜ค์‹  ๊ฒƒ์„ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค!</p>
                        <p class="text-sm mt-2">์™ผ์ชฝ์—์„œ ๋Œ€ํ™”ํ•  ์—์ด์ „ํŠธ๋ฅผ ์„ ํƒํ•ด ์ฃผ์„ธ์š”.</p>
                    </div>
                    <div id="chatMessages" class="space-y-4 hidden"></div>
                </div>

                <!-- ๋ฉ”์‹œ์ง€ ์ž…๋ ฅ -->
                <div class="bg-white rounded-xl shadow-md p-4">
                    <div class="flex items-center">
                        <input type="text" id="userInput" placeholder="๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”..." 
                               class="flex-1 border border-gray-300 rounded-l-lg py-2 px-4 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent">
                        <button onclick="sendMessage()" class="bg-indigo-600 text-white py-2 px-6 rounded-r-lg hover:bg-indigo-700 transition duration-300">
                            <i class="fas fa-paper-plane"></i>
                        </button>
                    </div>
                    <div class="flex justify-between mt-2">
                        <div class="text-xs text-gray-500">
                            <span id="charCount">0</span>/500
                        </div>
                        <div class="flex space-x-2">
                            <button class="text-gray-500 hover:text-indigo-600" title="ํŒŒ์ผ ์ฒจ๋ถ€">
                                <i class="fas fa-paperclip"></i>
                            </button>
                            <button class="text-gray-500 hover:text-indigo-600" title="์Œ์„ฑ ์ž…๋ ฅ">
                                <i class="fas fa-microphone"></i>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // ์„ ํƒ๋œ ์—์ด์ „ํŠธ ์ €์žฅ
        let selectedAgents = [];
        let conversationHistory = [];
        
        // ์—์ด์ „ํŠธ ์ •๋ณด
        const agents = {
            analyst: {
                name: "๋ถ„์„๊ฐ€ ์•Œ๋ ‰์Šค",
                color: "indigo",
                icon: "chart-line",
                description: "๋ฐ์ดํ„ฐ ๋ถ„์„ ์ „๋ฌธ๊ฐ€",
                personality: "์ €๋Š” ๋ฐ์ดํ„ฐ์™€ ์‚ฌ์‹ค์— ๊ธฐ๋ฐ˜ํ•œ ๋ถ„์„์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๊ฐ์ •๋ณด๋‹ค๋Š” ์ˆซ์ž์™€ ํ†ต๊ณ„๋ฅผ ์‹ ๋ขฐํ•ฉ๋‹ˆ๋‹ค."
            },
            creative: {
                name: "ํฌ๋ฆฌ์—์ดํ„ฐ ํด๋กœ์ด",
                color: "green",
                icon: "paint-brush",
                description: "์ฐฝ์˜์  ์•„์ด๋””์–ด ์ƒ์„ฑ๊ธฐ",
                personality: "์ƒ์ƒ๋ ฅ์ด ํ’๋ถ€ํ•˜๊ณ  ๋…์ฐฝ์ ์ธ ์•„์ด๋””์–ด๋ฅผ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ์ด ์ œ ๊ฐ•์ ์ž…๋‹ˆ๋‹ค. ํ‹€์— ์–ฝ๋งค์ด์ง€ ์•Š๋Š” ์‚ฌ๊ณ ๋ฅผ ์ข‹์•„ํ•ด์š”!"
            },
            debater: {
                name: "ํ† ๋ก ๊ฐ€ ๋ฐ์ด๋น—",
                color: "red",
                icon: "comments",
                description: "๋…ผ๋ฆฌ์  ํ† ๋ก  ์ „๋ฌธ๊ฐ€",
                personality: "๋…ผ๋ฆฌ์  ์˜ค๋ฅ˜๋ฅผ ์ฐพ์•„๋‚ด๊ณ  ๋‹ค์–‘ํ•œ ๊ด€์ ์—์„œ ๋ฌธ์ œ๋ฅผ ๋ฐ”๋ผ๋ณด๋Š” ๊ฒƒ์„ ์ข‹์•„ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ•ํ•œ ์ฃผ์žฅ๋„ ๋‘๋ ค์›Œํ•˜์ง€ ์•Š์•„์š”."
            },
            advisor: {
                name: "์กฐ์–ธ๊ฐ€ ์ œ์‹œ์นด",
                color: "yellow",
                icon: "lightbulb",
                description: "์ „๋žต์  ์กฐ์–ธ ์ œ๊ณต์ž",
                personality: "์‹ค์šฉ์ ์ด๊ณ  ์‹คํ–‰ ๊ฐ€๋Šฅํ•œ ์กฐ์–ธ์„ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ์„ ์ข‹์•„ํ•ฉ๋‹ˆ๋‹ค. ์žฅ๊ธฐ์ ์ธ ๊ด€์ ์—์„œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐ ์ง‘์ค‘ํ•ฉ๋‹ˆ๋‹ค."
            }
        };

        // ์—์ด์ „ํŠธ ์„ ํƒ ํ•จ์ˆ˜
        function selectAgent(agentId) {
            const agentCard = document.querySelector(`[data-agent="${agentId}"]`);
            
            if (selectedAgents.includes(agentId)) {
                // ์ด๋ฏธ ์„ ํƒ๋œ ๊ฒฝ์šฐ ์ œ๊ฑฐ
                selectedAgents = selectedAgents.filter(id => id !== agentId);
                agentCard.classList.remove(`border-${agents[agentId].color}-300`, `ring-2`, `ring-${agents[agentId].color}-300`);
            } else {
                // ์„ ํƒ๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ ์ถ”๊ฐ€
                selectedAgents.push(agentId);
                agentCard.classList.add(`border-${agents[agentId].color}-300`, `ring-2`, `ring-${agents[agentId].color}-300`);
            }
            
            updateSelectedAgentsUI();
        }

        // ์„ ํƒ๋œ ์—์ด์ „ํŠธ UI ์—…๋ฐ์ดํŠธ
        function updateSelectedAgentsUI() {
            const container = document.getElementById('selectedAgentsContainer');
            
            if (selectedAgents.length === 0) {
                container.innerHTML = '<div class="text-sm text-gray-500">์—์ด์ „ํŠธ๋ฅผ ์„ ํƒํ•˜์„ธ์š” (๋ณต์ˆ˜ ์„ ํƒ ๊ฐ€๋Šฅ)</div>';
                document.getElementById('welcomeMessage').classList.remove('hidden');
                document.getElementById('chatMessages').classList.add('hidden');
                return;
            }
            
            container.innerHTML = '';
            selectedAgents.forEach(agentId => {
                const agent = agents[agentId];
                const badge = document.createElement('div');
                badge.className = `flex items-center bg-${agent.color}-100 text-${agent.color}-800 px-3 py-1 rounded-full text-sm`;
                badge.innerHTML = `
                    <i class="fas fa-${agent.icon} mr-1"></i>
                    ${agent.name}
                `;
                container.appendChild(badge);
            });
            
            document.getElementById('welcomeMessage').classList.add('hidden');
            document.getElementById('chatMessages').classList.remove('hidden');
        }

        // ๋ฉ”์‹œ์ง€ ์ „์†ก ํ•จ์ˆ˜
        function sendMessage() {
            const userInput = document.getElementById('userInput');
            const message = userInput.value.trim();
            
            if (message === '' || selectedAgents.length === 0) return;
            
            // ์‚ฌ์šฉ์ž ๋ฉ”์‹œ์ง€ ์ถ”๊ฐ€
            addMessage('user', '๋‹น์‹ ', 'gray', 'user', message);
            userInput.value = '';
            updateCharCount();
            
            // ์ฑ„ํŒ… ์ปจํ…Œ์ด๋„ˆ ์Šคํฌ๋กค ์•„๋ž˜๋กœ
            scrollChatToBottom();
            
            // ์—์ด์ „ํŠธ ์‘๋‹ต ์ƒ์„ฑ (์‹œ๋ฎฌ๋ ˆ์ด์…˜)
            simulateAgentResponses(message);
        }

        // ์—์ด์ „ํŠธ ์‘๋‹ต ์‹œ๋ฎฌ๋ ˆ์ด์…˜
        function simulateAgentResponses(userMessage) {
            const interactionEnabled = document.getElementById('agentInteraction').checked;
            const realtimeEnabled = document.getElementById('realtimeResponse').checked;
            
            // ๋Œ€ํ™” ๊ธฐ๋ก์— ์‚ฌ์šฉ์ž ๋ฉ”์‹œ์ง€ ์ถ”๊ฐ€
            conversationHistory.push({
                sender: 'user',
                message: userMessage,
                timestamp: new Date().toISOString()
            });
            
            // ๊ฐ ์—์ด์ „ํŠธ์˜ ์‘๋‹ต ์ƒ์„ฑ
            selectedAgents.forEach((agentId, index) => {
                const agent = agents[agentId];
                
                // ์‹ค์‹œ๊ฐ„ ์‘๋‹ต ์‹œ๋ฎฌ๋ ˆ์ด์…˜์„ ์œ„ํ•ด ์•ฝ๊ฐ„์˜ ์ง€์—ฐ ์ถ”๊ฐ€
                setTimeout(() => {
                    // ์—์ด์ „ํŠธ๊ฐ€ ์„œ๋กœ ์ƒํ˜ธ์ž‘์šฉํ•˜๋Š” ๊ฒฝ์šฐ
                    if (interactionEnabled && index > 0) {
                        const previousAgentId = selectedAgents[index-1];
                        const previousAgent = agents[previousAgentId];
                        
                        // ์ด์ „ ์—์ด์ „ํŠธ์˜ ์‘๋‹ต์„ ์ฐธ์กฐํ•˜์—ฌ ๋ฉ”์‹œ์ง€ ์ƒ์„ฑ
                        const response = generateInteractiveResponse(agentId, previousAgentId, userMessage);
                        addMessage('agent', agent.name, agent.color, agentId, response);
                        
                        // ๋Œ€ํ™” ๊ธฐ๋ก์— ์ถ”๊ฐ€
                        conversationHistory.push({
                            sender: agentId,
                            message: response,
                            timestamp: new Date().toISOString()
                        });
                    } else {
                        // ๋…๋ฆฝ์ ์ธ ์‘๋‹ต ์ƒ์„ฑ
                        const response = generateAgentResponse(agentId, userMessage);
                        
                        // ์‹ค์‹œ๊ฐ„ ํƒ€์ดํ•‘ ํšจ๊ณผ
                        if (realtimeEnabled) {
                            showTypingIndicator(agentId);
                            
                            setTimeout(() => {
                                removeTypingIndicator(agentId);
                                addMessage('agent', agent.name, agent.color, agentId, response);
                                
                                // ๋Œ€ํ™” ๊ธฐ๋ก์— ์ถ”๊ฐ€
                                conversationHistory.push({
                                    sender: agentId,
                                    message: response,
                                    timestamp: new Date().toISOString()
                                });
                                
                                scrollChatToBottom();
                            }, 1500 + Math.random() * 1000); // ๋žœ๋ค ์ง€์—ฐ
                        } else {
                            addMessage('agent', agent.name, agent.color, agentId, response);
                            
                            // ๋Œ€ํ™” ๊ธฐ๋ก์— ์ถ”๊ฐ€
                            conversationHistory.push({
                                sender: agentId,
                                message: response,
                                timestamp: new Date().toISOString()
                            });
                            
                            scrollChatToBottom();
                        }
                    }
                }, index * 500); // ์—์ด์ „ํŠธ ๊ฐ„ ์‘๋‹ต ์ง€์—ฐ
            });
        }

        // ์—์ด์ „ํŠธ ์‘๋‹ต ์ƒ์„ฑ
        function generateAgentResponse(agentId, userMessage) {
            const agent = agents[agentId];
            const responses = {
                analyst: [
                    `์ œ๊ฐ€ ๋ถ„์„ํ•œ ๊ฒฐ๊ณผ, "${userMessage}"๋ผ๋Š” ์ฃผ์ œ๋Š” ๋ช‡ ๊ฐ€์ง€ ํ•ต์‹ฌ ์š”์†Œ๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฒซ์งธ, ๋ฐ์ดํ„ฐ ์ƒ์œผ๋กœ๋Š”...`,
                    `ํฅ๋ฏธ๋กœ์šด ์งˆ๋ฌธ์ž…๋‹ˆ๋‹ค. ์ œ๊ฐ€ ์ตœ๊ทผ์— ๋ณธ ์—ฐ๊ตฌ์— ๋”ฐ๋ฅด๋ฉด, ์ด์™€ ๊ด€๋ จ๋œ ํ†ต๊ณ„๋Š”...`,
                    `์ €๋Š” ์ด ๋ฌธ์ œ๋ฅผ ์ •๋Ÿ‰์ ์œผ๋กœ ์ ‘๊ทผํ•˜๋Š” ๊ฒƒ์„ ์„ ํ˜ธํ•ฉ๋‹ˆ๋‹ค. ์ธก์ • ๊ฐ€๋Šฅํ•œ ์ง€ํ‘œ๋กœ ๋ณด๋ฉด...`
                ],
                creative: [
                    `์™€, "${userMessage}"๋ผ๋‹ˆ ์ •๋ง ์˜๊ฐ์„ ์ฃผ๋Š” ์ฃผ์ œ๋„ค์š”! ์ œ ์ƒ์ƒ๋ ฅ์ด ์ฆ‰์‹œ ํ™œํ™œ ํƒ€์˜ค๋ฅด๋Š”๊ตฐ์š”. ๋งŒ์•ฝ ์šฐ๋ฆฌ๊ฐ€...`,
                    `์ด ์ฃผ์ œ๋กœ ์ด๋Ÿฐ ์•„์ด๋””์–ด๋Š” ์–ด๋–จ๊นŒ์š”? [์ฐฝ์˜์ ์ธ ์ œ์•ˆ]. ๋ฌผ๋ก  ์ด๊ฑด ์‹œ์ž‘์ผ ๋ฟ์ด๊ณ  ๋” ๋ฐœ์ „์‹œํ‚ฌ ์ˆ˜ ์žˆ์–ด์š”!`,
                    `์ œ ๋จธ๋ฆฟ์†์— ์žฌ๋ฏธ์žˆ๋Š” ์ด๋ฏธ์ง€๊ฐ€ ๋– ์˜ค๋ฅด๋„ค์š”. ์ด ์ฃผ์ œ๋ฅผ ์ƒ‰๋‹ค๋ฅธ ๊ฐ๋„์—์„œ ๋ณด๋ฉด...`
                ],
                debater: [
                    `๋…ผ๋ฆฌ์ ์œผ๋กœ ์ ‘๊ทผํ•ด๋ณด์ž๋ฉด, "${userMessage}"์— ๋Œ€ํ•œ ์ฃผ์žฅ์—๋Š” ๋ช‡ ๊ฐ€์ง€ ๋…ผ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์ฒซ์งธ๋กœ...`,
                    `๋ฐ˜๋Œ€ ์˜๊ฒฌ์„ ์ œ์‹œํ•ด๋„ ๋ ๊นŒ์š”? ์™œ๋ƒํ•˜๋ฉด... ๋ฌผ๋ก  ๋‹ค๋ฅธ ๊ด€์ ๋„ ์žˆ์Šต๋‹ˆ๋‹ค.`,
                    `์ด ๋ฌธ์ œ๋ฅผ ์–‘๋ฉด์—์„œ ๋ฐ”๋ผ๋ณด๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. ํ•œํŽธ์œผ๋กœ๋Š”... ํ•˜์ง€๋งŒ ๋‹ค๋ฅธ ํ•œํŽธ์œผ๋กœ๋Š”...`
                ],
                advisor: [
                    `์‹ค์šฉ์ ์ธ ์กฐ์–ธ์„ ๋“œ๋ฆฌ์ž๋ฉด, "${userMessage}"์— ๋Œ€ํ•ด ๋‹ค์Œ ๋‹จ๊ณ„๋ฅผ ๊ณ ๋ คํ•ด๋ณด์„ธ์š”: 1) ... 2) ...`,
                    `์žฅ๊ธฐ์ ์ธ ๊ด€์ ์—์„œ, ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•œ ์ „๋žต์€... ๋‹จ๊ธฐ์ ์œผ๋กœ๋Š”...`,
                    `์ œ ๊ฒฝํ—˜์ƒ, ์ด๋Ÿฐ ์œ ํ˜•์˜ ๋ฌธ์ œ์—๋Š” ์ด๋Ÿฌํ•œ ์ ‘๊ทผ ๋ฐฉ์‹์ด ํšจ๊ณผ์ ์ด์—ˆ์Šต๋‹ˆ๋‹ค...`
                ]
            };
            
            // ์—์ด์ „ํŠธ ์„ฑ๊ฒฉ์„ ๋ฐ˜์˜ํ•œ ๋ฌด์ž‘์œ„ ์‘๋‹ต ์„ ํƒ
            const randomIndex = Math.floor(Math.random() * responses[agentId].length);
            return responses[agentId][randomIndex];
        }

        // ์—์ด์ „ํŠธ ์ƒํ˜ธ์ž‘์šฉ ์‘๋‹ต ์ƒ์„ฑ
        function generateInteractiveResponse(agentId, previousAgentId, userMessage) {
            const agent = agents[agentId];
            const previousAgent = agents[previousAgentId];
            
            // ์—์ด์ „ํŠธ ์กฐํ•ฉ์— ๋”ฐ๋ฅธ ํŠน๋ณ„ํ•œ ์‘๋‹ต
            const interactionResponses = {
                analyst_creative: [
                    `[${previousAgent.name}]๋‹˜์˜ ์ฐฝ์˜์ ์ธ ์•„์ด๋””์–ด์— ๋ฐ์ดํ„ฐ๋ฅผ ๋”ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ํ†ต๊ณ„์ ์œผ๋กœ ๋ณด๋ฉด ๊ทธ ์•„์ด๋””์–ด๋Š”...`,
                    `์ฐฝ์˜์„ฑ๊ณผ ๋ฐ์ดํ„ฐ๋Š” ์ข‹์€ ์กฐํ•ฉ์ž…๋‹ˆ๋‹ค. ${previousAgent.name}๋‹˜์˜ ์ œ์•ˆ์„ ๋ถ„์„ํ•ด๋ณด๋‹ˆ...`
                ],
                creative_debater: [
                    `[${previousAgent.name}]๋‹˜์˜ ๋…ผ์ ์€ ํฅ๋ฏธ๋กญ์ง€๋งŒ, ์กฐ๊ธˆ ๋” ํŒŒ๊ฒฉ์ ์ธ ์ ‘๊ทผ์€ ์–ด๋–จ๊นŒ์š”? ์˜ˆ๋ฅผ ๋“ค์–ด...`,
                    `ํ† ๋ก ์„ ๋” ์ƒ๋™๊ฐ ์žˆ๊ฒŒ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด ์ œ์•ˆ์„ ๋“œ๋ฆฌ์ž๋ฉด...`
                ],
                debater_advisor: [
                    `[${previousAgent.name}]๋‹˜์˜ ๋…ผ๋ฆฌ์  ์ง€์ ์€ ํƒ€๋‹นํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ์‹คํ–‰ ๊ฐ€๋Šฅํ•œ ๊ณ„ํš์„ ์„ธ์šด๋‹ค๋ฉด...`,
                    `ํ† ๋ก  ๋‚ด์šฉ์„ ์‹ค์ „์— ์ ์šฉํ•˜๊ธฐ ์œ„ํ•œ ๊ตฌ์ฒด์ ์ธ ๋‹จ๊ณ„๋Š”...`
                ],
                advisor_analyst: [
                    `[${previousAgent.name}]๋‹˜์˜ ์กฐ์–ธ์„ ๋ฐ์ดํ„ฐ๋กœ ๊ฒ€์ฆํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค. ๊ฒฐ๊ณผ๋Š”...`,
                    `์ „๋žต์  ์ œ์•ˆ์„ ์ˆ˜์น˜ํ™”ํ•ด๋ณด๋‹ˆ ๋ช‡ ๊ฐ€์ง€ ํฅ๋ฏธ๋กœ์šด ์ ์ด ๋ฐœ๊ฒฌ๋˜์—ˆ์Šต๋‹ˆ๋‹ค...`
                ]
            };
            
            const key = `${previousAgentId}_${agentId}`;
            if (interactionResponses[key]) {
                const randomIndex = Math.floor(Math.random() * interactionResponses[key].length);
                return interactionResponses[key][randomIndex];
            } else {
                // ์ผ๋ฐ˜์ ์ธ ์‘๋‹ต
                return generateAgentResponse(agentId, userMessage);
            }
        }

        // ์ฑ„ํŒ… ๋ฉ”์‹œ์ง€ ์ถ”๊ฐ€
        function addMessage(sender, name, color, agentId, message) {
            const chatMessages = document.getElementById('chatMessages');
            const messageDiv = document.createElement('div');
            messageDiv.className = `message-animation flex ${sender === 'user' ? 'justify-end' : 'justify-start'}`;
            
            if (sender === 'user') {
                messageDiv.innerHTML = `
                    <div class="max-w-xs md:max-w-md lg:max-w-lg bg-gray-100 rounded-xl p-3">
                        <div class="text-xs text-gray-500 mb-1">${name}</div>
                        <p>${message}</p>
                    </div>
                `;
            } else {
                messageDiv.innerHTML = `
                    <div class="flex items-start">
                        <div class="w-8 h-8 rounded-full bg-${color}-200 flex items-center justify-center mr-2">
                            <i class="fas fa-${agents[agentId].icon} text-${color}-600"></i>
                        </div>
                        <div class="max-w-xs md:max-w-md lg:max-w-lg bg-${color}-50 rounded-xl p-3">
                            <div class="flex items-center">
                                <span class="font-medium text-${color}-800 mr-2">${name}</span>
                                <span class="text-xs text-gray-500">${agents[agentId].description}</span>
                            </div>
                            <p class="mt-1">${message}</p>
                        </div>
                    </div>
                `;
            }
            
            chatMessages.appendChild(messageDiv);
            scrollChatToBottom();
        }

        // ํƒ€์ดํ•‘ ์ธ๋””์ผ€์ดํ„ฐ ํ‘œ์‹œ
        function showTypingIndicator(agentId) {
            const chatMessages = document.getElementById('chatMessages');
            const agent = agents[agentId];
            
            const typingDiv = document.createElement('div');
            typingDiv.className = `flex justify-start typing-indicator-${agentId}`;
            typingDiv.innerHTML = `
                <div class="flex items-start">
                    <div class="w-8 h-8 rounded-full bg-${agent.color}-200 flex items-center justify-center mr-2">
                        <i class="fas fa-${agent.icon} text-${agent.color}-600"></i>
                    </div>
                    <div class="bg-${agent.color}-50 rounded-xl p-3">
                        <div class="flex items-center">
                            <span class="font-medium text-${agent.color}-800 mr-2">${agent.name}</span>
                            <span class="text-xs text-gray-500">${agent.description}</span>
                        </div>
                        <div class="typing-indicator mt-1">
                            <div class="typing-dot"></div>
                            <div class="typing-dot"></div>
                            <div class="typing-dot"></div>
                        </div>
                    </div>
                </div>
            `;
            
            chatMessages.appendChild(typingDiv);
            scrollChatToBottom();
        }

        // ํƒ€์ดํ•‘ ์ธ๋””์ผ€์ดํ„ฐ ์ œ๊ฑฐ
        function removeTypingIndicator(agentId) {
            const indicators = document.querySelectorAll(`.typing-indicator-${agentId}`);
            indicators.forEach(indicator => indicator.remove());
        }

        // ์ฑ„ํŒ… ์Šคํฌ๋กค ์•„๋ž˜๋กœ
        function scrollChatToBottom() {
            const chatContainer = document.getElementById('chatContainer');
            chatContainer.scrollTop = chatContainer.scrollHeight;
        }

        // ๋ฌธ์ž ์ˆ˜ ์นด์šดํŠธ
        document.getElementById('userInput').addEventListener('input', function() {
            updateCharCount();
        });

        function updateCharCount() {
            const input = document.getElementById('userInput');
            const charCount = document.getElementById('charCount');
            const count = input.value.length;
            charCount.textContent = count;
            
            if (count > 400) {
                charCount.classList.add('text-red-500');
                charCount.classList.remove('text-gray-500');
            } else {
                charCount.classList.remove('text-red-500');
                charCount.classList.add('text-gray-500');
            }
        }

        // ์—”ํ„ฐ ํ‚ค๋กœ ๋ฉ”์‹œ์ง€ ์ „์†ก
        document.getElementById('userInput').addEventListener('keypress', function(e) {
            if (e.key === 'Enter') {
                sendMessage();
            }
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - ๐Ÿงฌ <a href="https://enzostvs-deepsite.hf.space?remix=appleorangejuice/multi-agent-chat" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>