File size: 30,593 Bytes
353a253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TG Storage β€” File Vault</title>
<link href="https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Syne:wght@400;700;800&display=swap" rel="stylesheet" />
<style>

  :root {

    --bg:       #050810;

    --surface:  #0b1120;

    --border:   #1a2a45;

    --accent:   #00d4ff;

    --accent2:  #7b2fff;

    --danger:   #ff3c6e;

    --success:  #00ffb3;

    --text:     #c8d8f0;

    --muted:    #4a6080;

    --mono:     'Share Tech Mono', monospace;

    --sans:     'Syne', sans-serif;

  }



  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }



  body {

    background: var(--bg);

    color: var(--text);

    font-family: var(--sans);

    min-height: 100vh;

    overflow-x: hidden;

  }



  /* ── Grid bg ── */

  body::before {

    content: '';

    position: fixed;

    inset: 0;

    background-image:

      linear-gradient(rgba(0,212,255,.03) 1px, transparent 1px),

      linear-gradient(90deg, rgba(0,212,255,.03) 1px, transparent 1px);

    background-size: 40px 40px;

    pointer-events: none;

    z-index: 0;

  }



  /* ── Glow blobs ── */

  .blob {

    position: fixed;

    border-radius: 50%;

    filter: blur(120px);

    pointer-events: none;

    z-index: 0;

    opacity: .35;

  }

  .blob-1 { width: 500px; height: 500px; top: -150px; left: -100px; background: var(--accent2); }

  .blob-2 { width: 400px; height: 400px; bottom: -100px; right: -80px; background: var(--accent); }



  /* ── Layout ── */

  .wrapper { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: 40px 24px 80px; }



  /* ── Header ── */

  header { display: flex; align-items: center; gap: 16px; margin-bottom: 48px; }

  .logo-icon {

    width: 48px; height: 48px;

    background: linear-gradient(135deg, var(--accent2), var(--accent));

    border-radius: 12px;

    display: grid; place-items: center;

    font-size: 22px;

    box-shadow: 0 0 30px rgba(0,212,255,.3);

    flex-shrink: 0;

  }

  header h1 { font-size: 28px; font-weight: 800; letter-spacing: -1px; }

  header h1 span { color: var(--accent); }

  header p { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 3px; }

  .status-dot {

    width: 8px; height: 8px; border-radius: 50%;

    background: var(--success);

    box-shadow: 0 0 8px var(--success);

    animation: pulse 2s infinite;

    margin-left: auto; flex-shrink: 0;

  }

  @keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }



  /* ── Config bar ── */

  .config-bar {

    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: 14px;

    padding: 20px 24px;

    display: flex; gap: 16px; flex-wrap: wrap;

    align-items: flex-end;

    margin-bottom: 36px;

  }

  .config-bar label { font-family: var(--mono); font-size: 11px; color: var(--muted); display: block; margin-bottom: 6px; letter-spacing: .08em; }

  .config-bar input {

    background: var(--bg);

    border: 1px solid var(--border);

    border-radius: 8px;

    color: var(--text);

    font-family: var(--mono);

    font-size: 13px;

    padding: 10px 14px;

    outline: none;

    transition: border-color .2s;

    width: 100%;

  }

  .config-bar input:focus { border-color: var(--accent); }

  .config-bar .field { flex: 1; min-width: 180px; }

  .config-bar .field-key { flex: 1.2; min-width: 220px; }



  /* ── Tabs ── */

  .tabs { display: flex; gap: 4px; margin-bottom: 28px; }

  .tab {

    padding: 10px 22px;

    border-radius: 8px;

    font-family: var(--mono);

    font-size: 13px;

    cursor: pointer;

    border: 1px solid transparent;

    color: var(--muted);

    transition: all .2s;

    background: none;

  }

  .tab:hover { color: var(--text); border-color: var(--border); }

  .tab.active {

    background: var(--surface);

    border-color: var(--accent);

    color: var(--accent);

    box-shadow: 0 0 20px rgba(0,212,255,.1);

  }



  /* ── Panel ── */

  .panel { display: none; }

  .panel.active { display: block; }



  /* ── Upload zone ── */

  .upload-zone {

    border: 2px dashed var(--border);

    border-radius: 16px;

    padding: 60px 40px;

    text-align: center;

    cursor: pointer;

    transition: all .25s;

    position: relative;

    overflow: hidden;

    background: var(--surface);

  }

  .upload-zone:hover, .upload-zone.drag { border-color: var(--accent); background: rgba(0,212,255,.04); }

  .upload-zone .icon { font-size: 48px; margin-bottom: 16px; display: block; }

  .upload-zone h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }

  .upload-zone p { font-family: var(--mono); font-size: 12px; color: var(--muted); }

  .upload-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }



  /* ── Progress ── */

  .progress-wrap { margin-top: 24px; display: none; }

  .progress-wrap.show { display: block; }

  .progress-bar-bg {

    background: var(--border);

    border-radius: 100px;

    height: 6px;

    overflow: hidden;

  }

  .progress-bar-fill {

    height: 100%;

    border-radius: 100px;

    background: linear-gradient(90deg, var(--accent2), var(--accent));

    width: 0%;

    transition: width .3s ease;

    box-shadow: 0 0 12px var(--accent);

  }

  .progress-label { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 10px; }



  /* ── Response box ── */

  .response-box {

    background: #020509;

    border: 1px solid var(--border);

    border-radius: 12px;

    padding: 20px;

    font-family: var(--mono);

    font-size: 12.5px;

    line-height: 1.7;

    color: var(--success);

    white-space: pre-wrap;

    word-break: break-all;

    margin-top: 20px;

    min-height: 80px;

    display: none;

  }

  .response-box.show { display: block; }

  .response-box.error { color: var(--danger); }



  /* ── File list ── */

  .list-controls { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }

  .btn {

    padding: 10px 20px;

    border-radius: 8px;

    font-family: var(--mono);

    font-size: 13px;

    cursor: pointer;

    border: 1px solid var(--accent);

    background: transparent;

    color: var(--accent);

    transition: all .2s;

    display: inline-flex; align-items: center; gap: 8px;

  }

  .btn:hover { background: var(--accent); color: var(--bg); box-shadow: 0 0 20px rgba(0,212,255,.3); }

  .btn.danger { border-color: var(--danger); color: var(--danger); }

  .btn.danger:hover { background: var(--danger); color: #fff; box-shadow: 0 0 20px rgba(255,60,110,.3); }

  .btn.success { border-color: var(--success); color: var(--success); }

  .btn.success:hover { background: var(--success); color: var(--bg); }

  .btn:disabled { opacity: .4; cursor: not-allowed; }



  .files-grid { display: flex; flex-direction: column; gap: 10px; }



  .file-card {

    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: 12px;

    padding: 16px 20px;

    display: flex; align-items: center; gap: 16px;

    transition: border-color .2s, transform .15s;

    animation: fadeUp .3s ease both;

  }

  .file-card:hover { border-color: var(--accent); transform: translateY(-1px); }

  @keyframes fadeUp { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }



  .file-icon {

    width: 42px; height: 42px;

    border-radius: 10px;

    display: grid; place-items: center;

    font-size: 20px;

    flex-shrink: 0;

    background: rgba(0,212,255,.08);

    border: 1px solid rgba(0,212,255,.15);

  }

  .file-info { flex: 1; min-width: 0; }

  .file-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }

  .file-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }

  .file-actions { display: flex; gap: 8px; flex-shrink: 0; }

  .icon-btn {

    width: 36px; height: 36px;

    border-radius: 8px;

    border: 1px solid var(--border);

    background: transparent;

    color: var(--muted);

    cursor: pointer;

    display: grid; place-items: center;

    font-size: 16px;

    transition: all .2s;

  }

  .icon-btn:hover.dl { border-color: var(--success); color: var(--success); background: rgba(0,255,179,.08); }

  .icon-btn:hover.del { border-color: var(--danger); color: var(--danger); background: rgba(255,60,110,.08); }



  /* ── Download panel ── */

  .get-form { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; }

  .get-form label { font-family: var(--mono); font-size: 11px; color: var(--muted); display: block; margin-bottom: 8px; letter-spacing: .08em; }

  .get-form input {

    background: var(--bg);

    border: 1px solid var(--border);

    border-radius: 8px;

    color: var(--text);

    font-family: var(--mono);

    font-size: 13px;

    padding: 12px 16px;

    width: 100%;

    outline: none;

    margin-bottom: 16px;

    transition: border-color .2s;

  }

  .get-form input:focus { border-color: var(--accent); }



  /* ── Empty state ── */

  .empty {

    text-align: center;

    padding: 60px 20px;

    color: var(--muted);

    font-family: var(--mono);

    font-size: 13px;

  }

  .empty span { font-size: 40px; display: block; margin-bottom: 16px; }



  /* ── Toast ── */

  #toast {

    position: fixed;

    bottom: 32px; right: 32px;

    background: var(--surface);

    border: 1px solid var(--accent);

    border-radius: 10px;

    padding: 14px 22px;

    font-family: var(--mono);

    font-size: 13px;

    color: var(--accent);

    box-shadow: 0 8px 40px rgba(0,0,0,.6);

    transform: translateY(80px);

    opacity: 0;

    transition: all .3s ease;

    z-index: 999;

    max-width: 340px;

  }

  #toast.show { transform: translateY(0); opacity: 1; }

  #toast.err { border-color: var(--danger); color: var(--danger); }



  /* ── Spinner ── */

  .spin {

    width: 16px; height: 16px;

    border: 2px solid var(--border);

    border-top-color: var(--accent);

    border-radius: 50%;

    animation: spin .6s linear infinite;

    display: inline-block;

  }

  @keyframes spin { to{transform:rotate(360deg)} }





  /* ── CDN URL box ── */

  .cdn-box {

    display: none;

    margin-top: 16px;

    background: rgba(0,255,179,.05);

    border: 1px solid rgba(0,255,179,.3);

    border-radius: 12px;

    padding: 14px 18px;

    animation: fadeUp .3s ease;

  }

  .cdn-box.show { display: block; }

  .cdn-box label {

    font-family: var(--mono);

    font-size: 10px;

    color: var(--success);

    letter-spacing: .1em;

    display: block;

    margin-bottom: 8px;

  }

  .cdn-url-row {

    display: flex;

    gap: 8px;

    align-items: center;

  }

  .cdn-url-input {

    flex: 1;

    background: var(--bg);

    border: 1px solid rgba(0,255,179,.2);

    border-radius: 8px;

    color: var(--success);

    font-family: var(--mono);

    font-size: 12px;

    padding: 9px 13px;

    outline: none;

    min-width: 0;

  }

  .cdn-copy-btn {

    padding: 9px 16px;

    border-radius: 8px;

    border: 1px solid var(--success);

    background: transparent;

    color: var(--success);

    font-family: var(--mono);

    font-size: 12px;

    cursor: pointer;

    white-space: nowrap;

    transition: all .2s;

    flex-shrink: 0;

  }

  .cdn-copy-btn:hover { background: var(--success); color: var(--bg); }

  .cdn-open-btn {

    padding: 9px 14px;

    border-radius: 8px;

    border: 1px solid rgba(0,255,179,.3);

    background: transparent;

    color: var(--muted);

    font-family: var(--mono);

    font-size: 12px;

    cursor: pointer;

    text-decoration: none;

    white-space: nowrap;

    transition: all .2s;

    flex-shrink: 0;

  }

  .cdn-open-btn:hover { border-color: var(--success); color: var(--success); }





  /* ── Custom path input ── */

  .custom-path-wrap {

    margin-top: 16px;

    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: 12px;

    padding: 16px 18px;

  }

  .custom-path-wrap label {

    font-family: var(--mono);

    font-size: 10px;

    color: var(--muted);

    letter-spacing: .1em;

    display: flex;

    align-items: center;

    gap: 8px;

    margin-bottom: 8px;

  }

  .custom-path-wrap label span.opt {

    background: rgba(0,212,255,.1);

    color: var(--accent);

    border-radius: 4px;

    padding: 1px 6px;

    font-size: 9px;

  }

  .path-row {

    display: flex;

    align-items: center;

    gap: 0;

    background: var(--bg);

    border: 1px solid var(--border);

    border-radius: 8px;

    overflow: hidden;

    transition: border-color .2s;

  }

  .path-row:focus-within { border-color: var(--accent); }

  .path-prefix {

    font-family: var(--mono);

    font-size: 12px;

    color: var(--muted);

    padding: 10px 0 10px 13px;

    white-space: nowrap;

    flex-shrink: 0;

    user-select: none;

  }

  .path-input {

    flex: 1;

    background: transparent;

    border: none;

    color: var(--accent);

    font-family: var(--mono);

    font-size: 12px;

    padding: 10px 13px 10px 4px;

    outline: none;

    min-width: 0;

  }

  .path-input::placeholder { color: var(--muted); }

  .path-hint {

    font-family: var(--mono);

    font-size: 11px;

    color: var(--muted);

    margin-top: 7px;

  }

  .path-hint span { color: var(--accent); opacity: .7; }



  /* ── Scrollbar ── */

  ::-webkit-scrollbar { width: 6px; }

  ::-webkit-scrollbar-track { background: var(--bg); }

  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

</style>
</head>
<body>

<div class="blob blob-1"></div>
<div class="blob blob-2"></div>

<div class="wrapper">

  <!-- Header -->
  <header>
    <div class="logo-icon">πŸ“‘</div>
    <div>
      <h1>TG <span>Storage</span></h1>
      <p>telegram-powered file vault // api tester</p>
    </div>
    <div class="status-dot" id="statusDot" title="checking..."></div>
  </header>

  <!-- Config -->
  <div class="config-bar">
    <div class="field">
      <label>API BASE URL</label>
      <input id="baseUrl" type="text" value="http://localhost:8082" placeholder="http://localhost:8082" />
    </div>
    <div class="field-key">
      <label>X-API-KEY</label>
      <input id="apiKey" type="password" placeholder="your-admin-api-key" />
    </div>
    <button class="btn" onclick="checkHealth()">⚑ ping</button>
  </div>

  <!-- Tabs -->
  <div class="tabs">
    <button class="tab active" data-tab="upload">↑ Upload</button>
    <button class="tab" data-tab="files">≑ Files</button>
    <button class="tab" data-tab="download">↓ Download</button>
  </div>

  <!-- ── Upload Panel ── -->
  <div class="panel active" id="tab-upload">
    <div class="upload-zone" id="dropZone">
      <span class="icon">πŸ“‚</span>
      <h3>Drop a file here</h3>
      <p>or click to browse β€” any format, any size</p>
      <input type="file" id="fileInput" onchange="handleFileSelect()" />
    </div>

    <div class="custom-path-wrap">
      <label>CUSTOM CDN PATH <span class="opt">optional</span></label>
      <div class="path-row">
        <span class="path-prefix" id="pathPrefix">/cdn/</span>
        <input class="path-input" id="customPath" type="text"

          placeholder="images/logo.png  or  avatar.jpg  or  docs/readme.pdf"

          oninput="updatePathPreview()" />
      </div>
      <div class="path-hint" id="pathHint">Leave blank to use auto-generated ID &nbsp;Β·&nbsp; Use <span>/</span> for folders</div>
    </div>

    <div class="progress-wrap" id="progressWrap">
      <div class="progress-bar-bg"><div class="progress-bar-fill" id="progressFill"></div></div>
      <div class="progress-label" id="progressLabel">Uploading…</div>
    </div>

    <div class="cdn-box" id="cdnBox">
      <label>πŸ”— PUBLIC CDN URL β€” shareable, no auth required</label>
      <div class="cdn-url-row">
        <input class="cdn-url-input" id="cdnUrlInput" type="text" readonly />
        <button class="cdn-copy-btn" onclick="copyCdnUrl()">⎘ Copy</button>
        <a class="cdn-open-btn" id="cdnOpenLink" href="#" target="_blank" rel="noopener">β†— Open</a>
      </div>
    </div>
    <pre class="response-box" id="uploadResponse"></pre>
  </div>

  <!-- ── Files Panel ── -->
  <div class="panel" id="tab-files">
    <div class="list-controls">
      <button class="btn" onclick="loadFiles()">↻ Refresh</button>
      <span id="fileCount" style="font-family:var(--mono);font-size:12px;color:var(--muted)"></span>
    </div>
    <div class="files-grid" id="filesGrid">
      <div class="empty"><span>πŸ“­</span>Hit refresh to load files</div>
    </div>
  </div>

  <!-- ── Download Panel ── -->
  <div class="panel" id="tab-download">
    <div class="get-form">
      <label>FILE ID</label>
      <input id="dlFileId" type="text" placeholder="550e8400-e29b-41d4-a716-446655440000" />
      <button class="btn success" onclick="downloadFile()">↓ Download File</button>
    </div>
    <pre class="response-box" id="dlResponse"></pre>
  </div>

</div><!-- /wrapper -->

<div id="toast"></div>

<script>

// ──────────────────────────────────────────────

//  Helpers

// ──────────────────────────────────────────────

const $ = id => document.getElementById(id);



function cfg() {

  return {

    base: ($('baseUrl').value || 'http://localhost:8082').replace(/\/$/, ''),

    key: $('apiKey').value,

  };

}



function headers(extra = {}) {

  return { 'X-API-Key': cfg().key, ...extra };

}



function toast(msg, err = false) {

  const t = $('toast');

  t.textContent = msg;

  t.className = 'show' + (err ? ' err' : '');

  clearTimeout(t._t);

  t._t = setTimeout(() => t.className = '', 3200);

}



function showResponse(elId, data, isError = false) {

  const el = $(elId);

  el.textContent = JSON.stringify(data, null, 2);

  el.className = 'response-box show' + (isError ? ' error' : '');

}



function fileIcon(mime = '') {

  if (mime.startsWith('image/')) return 'πŸ–ΌοΈ';

  if (mime.startsWith('video/')) return '🎬';

  if (mime.startsWith('audio/')) return '🎡';

  if (mime.includes('pdf')) return 'πŸ“„';

  if (mime.includes('zip') || mime.includes('tar') || mime.includes('gz')) return 'πŸ—œοΈ';

  if (mime.includes('text')) return 'πŸ“';

  return 'πŸ“¦';

}



function formatBytes(b) {

  if (b < 1024) return b + ' B';

  if (b < 1048576) return (b / 1024).toFixed(1) + ' KB';

  return (b / 1048576).toFixed(1) + ' MB';

}



// ──────────────────────────────────────────────

//  Tabs

// ──────────────────────────────────────────────

document.querySelectorAll('.tab').forEach(btn => {

  btn.addEventListener('click', () => {

    document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));

    document.querySelectorAll('.panel').forEach(p => p.classList.remove('active'));

    btn.classList.add('active');

    $('tab-' + btn.dataset.tab).classList.add('active');

    if (btn.dataset.tab === 'files') loadFiles();

  });

});



// ──────────────────────────────────────────────

//  Health check

// ──────────────────────────────────────────────

async function checkHealth() {

  const dot = $('statusDot');

  dot.style.background = '#ffd700';

  dot.style.boxShadow = '0 0 8px #ffd700';

  try {

    const r = await fetch(cfg().base + '/health', { headers: headers() });

    const d = await r.json();

    dot.style.background = 'var(--success)';

    dot.style.boxShadow = '0 0 8px var(--success)';

    toast('βœ“ API online β€” ' + d.timestamp);

  } catch (e) {

    dot.style.background = 'var(--danger)';

    dot.style.boxShadow = '0 0 8px var(--danger)';

    toast('βœ— Cannot reach API', true);

  }

}

checkHealth();



// ──────────────────────────────────────────────

//  Drag & Drop

// ──────────────────────────────────────────────

const dz = $('dropZone');

['dragenter','dragover'].forEach(ev => dz.addEventListener(ev, e => { e.preventDefault(); dz.classList.add('drag'); }));

['dragleave','drop'].forEach(ev => dz.addEventListener(ev, e => { e.preventDefault(); dz.classList.remove('drag'); }));

dz.addEventListener('drop', e => {

  const file = e.dataTransfer.files[0];

  if (file) uploadFile(file);

});



function handleFileSelect() {

  const file = $('fileInput').files[0];

  if (file) uploadFile(file);

}



// ──────────────────────────────────────────────

//  Upload

// ──────────────────────────────────────────────

async function uploadFile(file) {

  const pw = $('progressWrap');

  const pf = $('progressFill');

  const pl = $('progressLabel');

  const rb = $('uploadResponse');



  pw.className = 'progress-wrap show';

  rb.className = 'response-box';

  $('cdnBox').className = 'cdn-box';

  $('cdnBox').querySelector('label').textContent = 'πŸ”— PUBLIC CDN URL β€” shareable, no auth required';

  pf.style.width = '0%';

  pl.textContent = `Uploading ${file.name} (${formatBytes(file.size)})…`;



  // Fake progress animation while real request runs

  let prog = 0;

  const tick = setInterval(() => {

    prog = Math.min(prog + Math.random() * 12, 88);

    pf.style.width = prog + '%';

  }, 200);



  try {

    const fd = new FormData();

    fd.append('file', file);

    const cp = $('customPath').value.trim();

    if (cp) fd.append('custom_path', cp);

    const r = await fetch(cfg().base + '/upload', {

      method: 'POST',

      headers: { 'X-API-Key': cfg().key },

      body: fd,

    });

    const data = await r.json();

    clearInterval(tick);

    pf.style.width = '100%';

    pl.textContent = r.ok ? `βœ“ Uploaded successfully` : `βœ— Upload failed`;



    showResponse('uploadResponse', data, !r.ok);

    if (r.ok) {

      toast(`βœ“ ${file.name} uploaded!`);

      if (data.public_url) {

        $('cdnUrlInput').value = data.public_url;

        $('cdnOpenLink').href  = data.public_url;

        // Update label to indicate whether custom path or UUID is used

        const lbl = $('cdnBox').querySelector('label');

        if (data.custom_path) {

          lbl.textContent = `πŸ”— CDN URL  β€’  custom path: /${data.custom_path}`;

        } else {

          lbl.textContent = 'πŸ”— PUBLIC CDN URL β€” shareable, no auth required';

        }

        $('cdnBox').className = 'cdn-box show';

      }

      navigator.clipboard?.writeText(data.public_url || data.file_id).catch(() => {});

      // Reset custom path input for next upload

      $('customPath').value = '';

      updatePathPreview();

    } else {

      $('cdnBox').className = 'cdn-box';

      toast('βœ— Upload failed', true);

    }

  } catch (e) {

    clearInterval(tick);

    pf.style.width = '0%';

    pl.textContent = 'βœ— Request failed';

    showResponse('uploadResponse', { error: e.message }, true);

    toast('βœ— Network error', true);

  }

}



// ──────────────────────────────────────────────

//  List files

// ──────────────────────────────────────────────

async function loadFiles() {

  const grid = $('filesGrid');

  const countEl = $('fileCount');

  grid.innerHTML = '<div class="empty"><span><div class="spin"></div></span>Loading…</div>';

  try {

    const r = await fetch(cfg().base + '/files?limit=100', { headers: headers() });

    const data = await r.json();

    if (!r.ok) { showFiles([], data); return; }

    countEl.textContent = `${data.total} file${data.total !== 1 ? 's' : ''}`;

    showFiles(data.files);

  } catch (e) {

    grid.innerHTML = `<div class="empty"><span>⚠️</span>${e.message}</div>`;

  }

}



function showFiles(files) {

  const grid = $('filesGrid');

  if (!files.length) {

    grid.innerHTML = '<div class="empty"><span>πŸ“­</span>No files stored yet</div>';

    return;

  }

  grid.innerHTML = files.map((f, i) => `

    <div class="file-card" style="animation-delay:${i * 40}ms">

      <div class="file-icon">${fileIcon(f.mime_type)}</div>

      <div class="file-info">

        <div class="file-name" title="${f.filename}">${f.filename}</div>

        <div class="file-meta">

          <span>${formatBytes(f.size_bytes)}</span>

          <span>${f.mime_type}</span>

          <span>${f.uploaded_at?.slice(0, 16).replace('T', ' ')}</span>

          <span style="color:var(--accent);cursor:pointer" onclick="copyId('${f.file_id}')" title="Click to copy file ID">${f.file_id.slice(0, 18)}…</span>

          ${f.custom_path ? `<span style="color:var(--accent);opacity:.6" title="custom path">/${f.custom_path}</span>` : ''}

          ${f.public_url ? `<span style="color:var(--success);cursor:pointer;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" onclick="copyCdnUrlStr('${f.public_url}')" title="${f.public_url}">πŸ”— CDN link</span>` : ''}

        </div>

      </div>

      <div class="file-actions">

        ${f.public_url ? `<button class="icon-btn dl" title="Copy CDN URL" onclick="copyCdnUrlStr('${f.public_url}')">πŸ”—</button>` : ''}

        <button class="icon-btn dl" title="Download" onclick="triggerDownload('${f.file_id}','${f.filename}')">↓</button>

        <button class="icon-btn del" title="Delete" onclick="deleteFile('${f.file_id}', this)">βœ•</button>

      </div>

    </div>

  `).join('');

}



function updatePathPreview() {

  const val = $('customPath').value.trim();

  const hint = $('pathHint');

  if (val) {

    const clean = val.replace(/^\/+/, '');

    hint.innerHTML = `CDN URL will be: <span>${cfg().base}/cdn/${clean}</span>`;

  } else {

    hint.innerHTML = `Leave blank to use auto-generated ID &nbsp;Β·&nbsp; Use <span>/</span> for folders`;

  }

}



function copyId(id) {

  navigator.clipboard?.writeText(id);

  toast('βœ“ File ID copied');

}



function copyCdnUrl() {

  const url = $('cdnUrlInput').value;

  navigator.clipboard?.writeText(url);

  const btn = document.querySelector('.cdn-copy-btn');

  btn.textContent = 'βœ“ Copied!';

  setTimeout(() => btn.textContent = '⎘ Copy', 2000);

  toast('βœ“ CDN URL copied to clipboard');

}



function copyCdnUrlStr(url) {

  navigator.clipboard?.writeText(url);

  toast('βœ“ CDN URL copied');

}



// ──────────────────────────────────────────────

//  Download

// ──────────────────────────────────────────────

async function triggerDownload(fileId, filename) {

  try {

    const r = await fetch(cfg().base + '/file/' + fileId, { headers: headers() });

    if (!r.ok) { toast('βœ— Download failed', true); return; }

    const blob = await r.blob();

    const url = URL.createObjectURL(blob);

    const a = document.createElement('a');

    a.href = url; a.download = filename;

    a.click();

    URL.revokeObjectURL(url);

    toast(`↓ ${filename} downloaded`);

  } catch (e) {

    toast('βœ— ' + e.message, true);

  }

}



async function downloadFile() {

  const id = $('dlFileId').value.trim();

  if (!id) { toast('βœ— Enter a file ID', true); return; }

  const rb = $('dlResponse');

  rb.className = 'response-box show';

  rb.textContent = 'Fetching…';

  try {

    const r = await fetch(cfg().base + '/file/' + id, { headers: headers() });

    if (!r.ok) {

      const d = await r.json();

      showResponse('dlResponse', d, true);

      toast('βœ— Not found', true);

      return;

    }

    const blob = await r.blob();

    const cd = r.headers.get('Content-Disposition') || '';

    const fnMatch = cd.match(/filename="?([^"]+)"?/);

    const filename = fnMatch ? fnMatch[1] : 'download';

    const url = URL.createObjectURL(blob);

    const a = document.createElement('a');

    a.href = url; a.download = filename;

    a.click();

    URL.revokeObjectURL(url);

    rb.textContent = `βœ“ Downloaded: ${filename} (${formatBytes(blob.size)})`;

    rb.className = 'response-box show';

    toast(`↓ ${filename} saved`);

  } catch (e) {

    showResponse('dlResponse', { error: e.message }, true);

    toast('βœ— Network error', true);

  }

}



// ──────────────────────────────────────────────

//  Delete

// ──────────────────────────────────────────────

async function deleteFile(fileId, btn) {

  if (!confirm('Delete this file record?')) return;

  btn.textContent = '…';

  btn.disabled = true;

  try {

    const r = await fetch(cfg().base + '/file/' + fileId, {

      method: 'DELETE', headers: headers()

    });

    const d = await r.json();

    if (r.ok) {

      toast('βœ“ File record deleted');

      loadFiles();

    } else {

      toast('βœ— Delete failed', true);

      btn.textContent = 'βœ•';

      btn.disabled = false;

    }

  } catch (e) {

    toast('βœ— ' + e.message, true);

    btn.textContent = 'βœ•';

    btn.disabled = false;

  }

}

</script>
</body>
</html>