-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_browser_client.html
3569 lines (3308 loc) · 134 KB
/
index_browser_client.html
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
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Pastel Inference Client UI</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@sira-ui/tailwind/dist/css/styles.css"
/>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/xterm@5.3.0/css/xterm.css"
/>
<script src="https://cdn.jsdelivr.net/npm/xterm@5.3.0/lib/xterm.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.6.0/jszip.min.js"></script>
<link
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;700&display=swap"
rel="stylesheet"
/>
<script src="https://cdn.tailwindcss.com"></script>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/styles/default.min.css"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/languages/json.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-sha3/0.9.3/sha3.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/yup@1.4.0/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/uuid@10.0.0/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/pouchdb@9.0.0/lib/index-browser.min.js"></script>
<style>
.ground-glass {
background-color: rgba(255, 255, 255, 0.8);
backdrop-filter: blur(10px);
}
body {
font-family: Montserrat, sans-serif;
}
.btn.success.outline {
border-color: #4caf50;
color: #4caf50;
}
.btn.success.outline:hover {
background-color: #4caf50;
color: #ffffff;
}
.btn.success.outline:active {
background-color: #388e3c;
border-color: #388e3c;
color: #ffffff;
}
.xterm {
width: 100% !important;
border-radius: 0.5rem; /* Adds rounded corners */
}
.table-container {
overflow-x: auto;
}
.table {
width: 100%;
table-layout: fixed;
}
.table th,
.table td {
padding: 0.5rem;
border: 1px solid #ccc;
}
.table th:last-child,
.table td:last-child {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 150px;
}
.table td:last-child:hover {
white-space: normal;
}
[data-theme="dark"] {
background-color: #121212;
color: #ffffff;
}
[data-theme="dark"] .bg-white {
background-color: #333333;
}
[data-theme="dark"] .text-bw-50 {
color: #cccccc;
}
[data-theme="dark"] .text-bw-600 {
color: #ffffff;
}
[data-theme="dark"] .text-bw-700 {
color: #eeeeee;
}
[data-theme="dark"] .text-bw-800 {
color: #ffffff;
}
[data-theme="dark"] .bg-bw-50 {
background-color: #333333;
}
[data-theme="dark"] .btn.outline.bw {
border-color: #ffffff;
color: #ffffff;
}
[data-theme="dark"] .btn.outline.bw:hover {
background-color: #ffffff;
color: #000000;
}
[data-theme="dark"] .table .bg-gray-200 {
background-color: #333333;
color: #ffffff; /* This needs to be adjusted */
}
[data-theme="dark"] .table .bg-gray-200.selected-row {
color: #000000; /* Adjust this color to be dark for legibility */
}
[data-theme="dark"] #previousRequestsList {
background-color: #333333;
color: #ffffff;
}
[data-theme="dark"] .delete-btn {
color: #ffffff;
border-color: #ffffff;
}
.table-responsive {
overflow-x: auto;
}
.truncate {
max-width: 150px; /* Adjust as needed */
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.prompt.success.xs {
display: inline-block;
flex-grow: 1; /* Allow it to take up the remaining space */
max-width: calc(
100% - 2rem
); /* Leave some padding for better readability */
word-wrap: break-word; /* Ensure the text wraps correctly */
height: 333px; /* Set a fixed height */
overflow-y: auto; /* Add a scrollbar if the content exceeds the height */
padding: 0.5rem; /* Add padding for better readability */
border: 1px solid #ccc; /* Optional: Add a border for better visibility */
border-radius: 0.5rem; /* Optional: Add rounded corners */
}
.prompt.success.xs .content {
overflow-wrap: break-word;
}
.flex {
display: flex;
}
.items-center {
align-items: center;
}
.gap-4 {
gap: 1rem; /* Adjust gap as needed */
}
.hidden {
display: none;
}
#previousRequestsList {
background-color: #f9f9f9;
border: 1px solid #e5e7eb;
border-radius: 0.5rem;
padding: 1rem;
max-height: 1200px;
overflow-y: auto;
}
#requestPreview {
background-color: #ffffff;
border: 1px solid #e5e7eb;
border-radius: 0.5rem;
padding: 1.5rem;
}
.delete-btn {
background: none;
border: none;
font-size: 1.25rem;
cursor: pointer;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
border-radius: 50%;
transition: box-shadow 0.3s;
}
.delete-btn:hover {
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}
#exportRequestsButton {
display: flex;
align-items: center;
gap: 0.5rem;
margin-top: auto;
}
.align-middle {
vertical-align: middle;
}
.new-ticket-table {
width: auto; /* Change to auto to fit content */
table-layout: auto; /* Use auto layout to fit column content */
}
.tooltip-icon {
margin-left: 5px;
font-size: 14px;
color: #6b7280;
}
</style>
</head>
<body class="flex flex-col gap-6 px-20 transition-all duration-300 bg-bw-50">
<div
class="flex gap-6 items-center sticky top-0 p-4 bg-bw-50 z-10 ground-glass shadow-md"
id="title"
>
<h1 class="text-4xl font-bold text-bw-600">
Pastel Inference Client
<span id="networkName" class="text-xl font-normal align-middle"></span>
</h1>
<input
id="theme-toggle"
class="switch success lg"
data-content="☀"
type="checkbox"
onchange="toggleDarkMode()"
/>
</div>
<div
class="grid grid-cols-5 gap-4 p-4 has-border rounded-xl bg-white shadow-md"
>
<h2 class="text-2xl col-span-full text-bw-800">User Information</h2>
<div class="col-span-full">
<div id="noPastelIDContainer" class="hidden">
<p class="text-bw-700">
No PastelID found. Would you like to create a new one for 1,000 PSL?
</p>
<form id="createPastelIDForm" class="mt-4">
<label
class="block text-bw-700 font-bold mb-2"
for="newPastelIDPassphrase"
>
Enter Passphrase (min 6 characters):
</label>
<input
id="newPastelIDPassphrase"
class="input w-full"
type="password"
placeholder="Enter passphrase"
minlength="6"
required
/>
<button type="submit" class="btn success outline mt-4">
Create PastelID
</button>
<div id="messageContainer" class="my-4"></div>
<!-- Container for messages -->
</form>
<p class="mt-4">
Already have an existing PastelID? Import the file here:
</p>
<input id="importPastelIDFile" class="input w-full" type="file" />
<button id="importPastelIDButton" class="btn outline success m-2">
Import PastelID
</button>
</div>
<button
id="changePastelIDButton"
class="btn outline success"
onclick="togglePastelIDDropdown()"
>
Switch to a Different PastelID
</button>
<div id="pastelIDDropdownContainer" class="mt-4 hidden">
<label class="block text-bw-700 font-bold mb-2"
>Select Existing PastelID to Use:</label
>
<select id="pastelIDDropdown" class="select w-full">
<!-- Options will be dynamically populated -->
</select>
</div>
<div class="mt-4 hidden" id="passphraseContainer">
<label
class="block text-bw-700 font-bold mb-2"
for="pastelIDPassphrase"
>Enter Passphrase:</label
>
<input
id="pastelIDPassphrase"
class="input w-full"
type="password"
placeholder="Enter passphrase"
minlength="6"
required
/>
<div class="mt-2">
<input type="checkbox" id="rememberPassphrase" />
<label for="rememberPassphrase" class="text-bw-700"
>Remember password?</label
>
</div>
<button id="submitPassphraseButton" class="btn success outline mt-4">
Submit
</button>
<div id="messageContainer" class="my-4"></div>
<!-- Container for messages -->
</div>
<div class="mt-4">
<label class="block text-bw-700 font-bold mb-2"
>Your Currently Selected PastelID:</label
>
<span id="userPastelID" class="text-bw-700">Loading...</span>
</div>
<div class="mt-4">
<label class="block text-bw-700 font-bold mb-2"
>Wallet Balance (PSL):</label
>
<span id="walletBalance" class="text-bw-700">
Loading...
<script>
document.addEventListener("DOMContentLoaded", async () => {
try {
const walletInfoResponse = await axios.get(
`${API_URL}/get-wallet-info`
);
const walletInfo = walletInfoResponse.data.result;
const formattedWalletBalance =
walletInfo.balance.toLocaleString(undefined, {
minimumFractionDigits: 1,
maximumFractionDigits: 1,
});
document.getElementById(
"walletBalance"
).textContent = `${formattedWalletBalance} PSL`;
} catch (error) {
console.error("Error retrieving wallet info:", error);
document.getElementById("walletBalance").textContent =
"Failed to load balance";
}
});
</script>
</span>
</div>
<div class="mt-4 flex items-center">
<label class="block text-bw-700 font-bold mb-2"
>My PSL Address:</label
>
<span id="myPslAddress" class="text-bw-700 ml-2"></span>
<button
id="copyAddressButton"
class="ml-2 tooltip"
data-tooltip="Copy address to clipboard"
>
📋
</button>
</div>
<button
id="createPastelIDButton"
class="btn success outline m-4 hidden"
>
Create a PastelID so you can make inference requests? (Costs 1,000
PSL)
</button>
</div>
</div>
<div
class="grid grid-cols-1 gap-4 p-4 has-border rounded-xl bg-white shadow-md"
>
<h2 class="text-2xl text-bw-800">Create New Credit Pack Ticket</h2>
<form id="createTicketForm" class="grid grid-cols-2 gap-4">
<div>
<label class="block text-bw-700 font-bold mb-2" for="numCredits"
>Number of Credits</label
>
<input
class="input w-full"
id="numCredits"
type="text"
placeholder="Enter number of credits"
value="1500"
data-raw-value="1500"
/>
</div>
<div>
<label class="block text-bw-700 font-bold mb-2" for="maxTotalPrice"
>Maximum Total Price (PSL)</label
>
<input
class="input w-full"
id="maxTotalPrice"
type="text"
placeholder="Enter maximum total price"
value="150000"
data-raw-value="150000"
/>
</div>
<div>
<label
class="block text-bw-700 font-bold mb-2"
for="maxPerCreditPrice"
>Maximum Per Credit Price (PSL)</label
>
<input
class="input w-full"
id="maxPerCreditPrice"
type="text"
placeholder="Enter maximum per credit price"
value="100.0"
data-raw-value="100.0"
/>
</div>
<div class="col-span-full flex justify-between">
<div class="flex gap-4 items-center" style="width: 100%">
<button
class="btn success outline"
type="submit"
id="createCreditPackButton"
>
Create Credit Pack
</button>
<div id="loaderContainer"></div>
<!-- Add this div for the loader -->
<div class="prompt success xs" id="createTicketStatusContainer">
<label class="text-bw-800 font-bold mb-4" for="createTicketStatus"
>Current Status:</label
>
<div class="content p-2" id="createTicketStatus"></div>
</div>
</div>
</div>
<div id="newCreditPackTicketDetailsContainer" style="display: none">
<h3 class="text-xl text-bw-800">New Credit Pack Ticket Details</h3>
<div class="table-responsive new-ticket-table">
<table class="table bordered bw new-ticket-table">
<thead>
<tr>
<th>Registration TXID</th>
<th>SHA3-256 Hash of Credit Pack Purchase Request Fields</th>
<th>Responding Supernode PastelID</th>
<th>Outcome</th>
</tr>
</thead>
<tbody id="newCreditPackTicketDetails">
<!-- New ticket details will be dynamically populated here -->
</tbody>
</table>
</div>
</div>
</form>
</div>
<div
class="grid grid-cols-1 gap-4 p-4 has-border rounded-xl bg-white shadow-md"
>
<h2 class="text-2xl text-bw-800">Select Existing Credit Pack Ticket</h2>
<div class="relative text-bw-700 table-responsive">
<table class="table bordered bw">
<thead>
<tr>
<th>Select</th>
<th>Initial Credits in Pack</th>
<th>Current Credit Balance</th>
<th>Tracking Address</th>
<th>Blockheight Registered</th>
<th>Credit Pack Registration TXID</th>
</tr>
</thead>
<tbody id="creditPackTicketTableBody">
<!-- Rows will be dynamically populated here -->
</tbody>
</table>
<div class="flex items-center gap-4 mt-4">
<button id="refreshButton" class="btn success outline p-4 relative">
Manually Refresh Credit Pack Tickets
<span
class="loader hidden absolute inset-0 flex items-center justify-center"
>
<div class="is-loading"></div>
</span>
</button>
<div class="btn is-loading hidden" id="loadingMessage">
Loading...
</div>
</div>
</div>
</div>
<div
class="grid grid-cols-1 gap-4 p-4 has-border rounded-xl bg-white shadow-md"
>
<h2 class="text-2xl text-bw-800">Create New Inference Request</h2>
<form id="inferenceRequestForm" class="grid grid-cols-2 gap-4">
<div>
<label class="block text-bw-700 font-bold mb-2" for="inferenceType"
>Inference Type</label
>
<div class="relative text-bw-700">
<select id="inferenceType" class="select w-full">
<option value="">Select an inference type</option>
<option value="text_completion">Text Completion</option>
<option value="ask_question_about_an_image">
Ask a Question About an Image
</option>
<option value="text_to_image">Image Generation</option>
<option value="embedding_document">Embedding Document</option>
<option value="embedding_audio">
Audio Transcript and Embedding
</option>
</select>
</div>
</div>
<div>
<label class="block text-bw-700 font-bold mb-2" for="model"
>Model/Service</label
>
<div class="relative text-bw-700">
<select id="model" class="select w-full">
<option value="">Select a model/service</option>
<option value="groq-llama3-70b-8192" selected></option>
<option value="claude3-opus">Claude3-Opus</option>
</select>
</div>
</div>
<div id="textCompletionSettings" class="col-span-full">
<div class="mb-4">
<label class="block text-bw-700 font-bold mb-2" for="prompt"
>Prompt</label
>
<textarea
class="input w-full"
id="prompt"
rows="5"
placeholder="Enter your prompt"
>
Write me a Shakespeare-style sonnet about Pastel Network and how it's really decentralized and powerful. </textarea
>
</div>
</div>
<div id="modelParametersContainer" class="col-span-full"></div>
<div
id="imageGenerationSettings"
class="col-span-full"
style="display: none"
>
<div class="mb-4">
<label class="block text-bw-700 font-bold mb-2" for="imagePrompt"
>Image Prompt</label
>
<textarea
class="input w-full"
id="imagePrompt"
rows="5"
placeholder="Enter your image prompt"
>
A picture of a clown holding a sign that says PASTEL</textarea
>
</div>
</div>
<div
id="embeddingDocumentSettings"
class="col-span-full"
style="display: none"
>
<div class="mb-4">
<label
class="block text-bw-700 font-bold mb-2"
for="embeddingDocumentFile"
>Document to Embed</label
>
<input
type="file"
class="input w-full"
id="embeddingDocumentFile"
accept=".pdf,.doc,.docx,.txt"
/>
</div>
<div class="mb-4">
<label
class="block text-bw-700 font-bold mb-2"
for="document_semantic_query_string"
>Semantic Query String (Optional):</label
>
<input
class="input w-full"
id="document_semantic_query_string"
type="text"
placeholder="Enter your query"
/>
</div>
</div>
<div
id="embeddingAudioSettings"
class="col-span-full"
style="display: none"
>
<div class="mb-4">
<label
class="block text-bw-700 font-bold mb-2"
for="embeddingAudioFile"
>Audio File to Transcribe and Embed</label
>
<input
type="file"
class="input w-full"
id="embeddingAudioFile"
accept="audio/*"
/>
</div>
<div class="mb-4">
<label
class="block text-bw-700 font-bold mb-2"
for="audio_semantic_query_string"
>Semantic Query String (Optional):</label
>
<input
class="input w-full"
id="audio_semantic_query_string"
type="text"
placeholder="Enter your query"
/>
</div>
</div>
<div
id="askQuestionAboutImageSettings"
class="col-span-full"
style="display: none"
>
<div class="mb-4">
<label class="block text-bw-700 font-bold mb-2" for="imageFile"
>Image File</label
>
<input
type="file"
class="input w-full"
id="imageFile"
accept="image/*"
/>
</div>
<div class="mb-4">
<label class="block text-bw-700 font-bold mb-2" for="question"
>Question</label
>
<input
class="input w-full"
id="question"
type="text"
placeholder="Enter your question"
/>
</div>
</div>
<div class="mb-4">
<label class="block text-bw-700 font-bold mb-2" for="maxCost"
>Maximum Cost (Credits)</label
>
<input
class="input w-full"
id="maxCost"
type="text"
placeholder="Enter maximum cost"
value="200"
data-raw-value="200"
/>
<span id="maxCostFormatted" class="text-bw-700"></span>
</div>
<div class="col-span-full flex justify-between">
<div class="flex gap-4 items-center" style="width: 100%">
<button class="btn success outline" type="submit">
Create Inference Request
</button>
<div class="prompt success xs" id="currentStatusContainer">
<label class="text-bw-800 font-bold mb-4" for="currentStatus"
>Current Status:</label
>
<div class="content p-2" id="currentStatus"></div>
</div>
</div>
</div>
<div id="inferenceRequestResult"></div>
</form>
</div>
<div
class="grid grid-cols-1 lg:grid-cols-3 gap-8 p-4 has-border rounded-xl bg-white shadow-md"
style="height: 800px; overflow-y: auto"
>
<div class="lg:col-span-1 flex flex-col">
<h2 class="text-2xl mb-4 text-bw-800">
View Previous Inference Requests
</h2>
<div
id="previousRequestsList"
class="bg-gray-100 p-4 rounded-lg overflow-y-auto flex-grow"
style="max-height: 1200px"
>
<!-- List of previous inference requests will be dynamically populated here -->
</div>
<button
id="exportRequestsButton"
class="btn success outline mt-4 flex items-center self-start"
>
💾 Export all Saved Inference Requests
</button>
</div>
<div id="requestPreview" class="lg:col-span-2 bg-gray-50 p-4 rounded-lg">
<!-- Preview of selected inference request will be shown here -->
</div>
</div>
<div
class="grid grid-cols-1 lg:grid-cols-2 gap-8 p-4 has-border rounded-xl bg-white shadow-md"
>
<div>
<h2 class="text-2xl mb-4 text-bw-800">
Send and Receive Messages using PastelIDs
</h2>
<form id="sendMessageForm" class="grid grid-cols-1 gap-4">
<div>
<label class="block text-bw-700 font-bold mb-2" for="toPastelID"
>Recipient Pastel ID</label
>
<input
class="input w-full"
id="toPastelID"
type="text"
placeholder="Enter recipient Pastel ID"
value="jXXiVgtFzLto4eYziePHjjb1hj3c6eXdABej5ndnQ62B8ouv1GYveJaD5QUMfainQM3b4MTieQuzFEmJexw8Cr"
/>
</div>
<div>
<label class="block text-bw-700 font-bold mb-2" for="messageBody"
>Message Body</label
>
<textarea
class="input w-full"
id="messageBody"
rows="5"
placeholder="Enter your message"
>
Hello, this is a brand 🍉 NEW test message from a regular user!</textarea
>
</div>
<div class="flex justify-between">
<button class="btn success outline" type="submit">
Send Message
</button>
</div>
</form>
</div>
<div>
<h2 class="text-2xl mb-4">Received Messages</h2>
<div id="receivedMessages" class="bg-bw-50 p-4 rounded-xl">
<!-- Received messages will be dynamically populated here -->
</div>
</div>
</div>
<div class="grid grid-cols-1 gap-4 p-4 has-border rounded-xl">
<h2 class="text-2xl">Manage Wallet</h2>
<div class="mb-4">
<label class="block text-bw-700 font-bold mb-2" for="importPrivKey">
Import Private Key
<span
class="tooltip"
data-tooltip="Import a private key into your wallet."
>ⓘ</span
>
</label>
<input
id="importPrivKey"
class="input w-full"
type="text"
placeholder="Enter private key"
/>
<button id="importPrivKeyButton" class="btn success outline mt-2">
Import Private Key
</button>
</div>
<div class="mb-4">
<label class="block text-bw-700 font-bold mb-2" for="importWallet">
Import Wallet
<span
class="tooltip"
data-tooltip="Import a wallet file into your wallet."
>ⓘ</span
>
</label>
<input
id="importWallet"
class="input w-full"
type="file"
accept=".dat"
/>
<button id="importWalletButton" class="btn success outline mt-2">
Import Wallet
</button>
</div>
<label
class="block text-bw-700 font-bold mb-2"
for="listAddressAmountsButton"
>
Misc Functions:
</label>
<div class="mb-4">
<button id="listAddressAmountsButton" class="btn success outline">
List Address Amounts
<span
class="tooltip"
data-tooltip="List the amounts associated with each address in your wallet."
>
ⓘ
</span>
</button>
<div
id="addressAmountsContainer"
class="mt-4"
style="display: none; position: relative"
>
<h2 class="text-2xl text-bw-800">Address Amounts:</h2>
<button
id="copyAddressAmountsButton"
class="btn success outline"
style="
position: absolute;
top: -1.5rem;
right: 0.5rem;
display: none;
"
>
📋
</button>
<div class="table-responsive">
<table id="addressAmountsTable" class="table bordered bw"></table>
</div>
</div>
</div>
<div class="mb-4">
<button id="getWalletInfoButton" class="btn success outline">
Get Wallet Info
<span
class="tooltip"
data-tooltip="Retrieve information about your wallet."
>
ⓘ
</span>
</button>
<div
id="walletInfoContainer"
class="mt-4"
style="display: none; position: relative"
>
<h2 class="text-2xl text-bw-800">Wallet Info:</h2>
<button
id="copyWalletInfoButton"
class="btn success outline"
style="
position: absolute;
top: -1.5rem;
right: 0.5rem;
display: none;
"
>
📋
</button>
<div class="table-responsive">
<table id="walletInfoTable" class="table bordered bw"></table>
</div>
</div>
</div>
<div class="mb-4">
<button id="clearLocalStorageButton" class="btn success outline">
Clear Inference Client Local Storage
<span
class="tooltip"
data-tooltip="Clear all local storage data for this page."
>
ⓘ
</span>
</button>
</div>
</div>
<button onclick="toggleTerminal()" class="btn success outline">
Toggle Terminal
</button>
<h2 class="text-2xl">Terminal</h2>
<div id="terminal" class="bg-gray-900 text-white p-4 rounded-xl"></div>
<div class="flex justify-between items-center">
<button id="exportTerminalButton" class="btn success outline">
Export Terminal Session Text
</button>
</div>
<div class="bg-bw-800 text-bw-50 py-6">
<div class="container mx-auto px-4">
<p class="text-center">
© 2023 Pastel Inference Client UI. All rights reserved.
</p>
</div>
</div>
<script type="text/javascript" src="libpastel_wasm.js"></script>
<script type="text/javascript" src="sequelize_data_models_browser_client.js"></script>
<script type="text/javascript" src="storage_browser_client.js"></script>
<script type="text/javascript" src="utility_functions_browser_replacements.js"></script>
<script src="logger_browser_cient.js"></script>
<script src="validation_schemas_browser_client.js"></script>
<script src="pastel_inference_client_browser_client.js"></script>
<script src="end_to_end_functions_browser_client.js"></script>
<script src="rpc_functions_browser_client.js"></script>
<script>
const API_URL = 'http://localhost:3100';
const MESSAGING_TIMEOUT_IN_SECONDS = 60;
const LOADING_MESSAGE = "Wait while data is loaded...";
const STORAGE_KEY = "validCreditPackTickets";
const STORAGE_TIMESTAMP_KEY = "creditPackTicketsTimestamp";
const REFRESH_INTERVAL = 24 * 60 * 60 * 1000; // 24 hours in milliseconds
function debounce(func, wait) {
let timeout;
return function (...args) {
const context = this;
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(context, args), wait);
};
}
function formatNumberWithCommas(number) {
return number.toLocaleString();
}
function parseAndFormatNumber(value) {
const number = parseFloat(value.replace(/,/g, ""));
return isNaN(number) ? value : formatNumberWithCommas(number);
}
function handleInputChange(event) {
const inputElement = event.target;
if (inputElement.type === "file") {
return;
}
const rawValue = inputElement.value.replace(/,/g, "");
inputElement.setAttribute("data-raw-value", rawValue);
}
function handleInputBlur(event) {
const inputElement = event.target;
if (inputElement.type === "file") {
return;
}
const formattedValue = parseAndFormatNumber(inputElement.value);
inputElement.value = formattedValue;
}
async function fetchImageSize(url) {
const response = await fetch(url);
const blob = await response.blob();
return blob.size;
}
function parseAndFormat(value) {
try {
if (typeof value === "string") {
// Check if the JSON string is already formatted
if (value.includes("\n")) {
return value;
}
// Parse JSON string to handle it properly
const parsedValue = JSON.parse(value);
return JSON.stringify(parsedValue, null, 4); // Indent JSON string
}
return JSON.stringify(value, null, 4); // Format other values
} catch (error) {
return value; // Return original value if parsing fails
}
}
function prettyJSON(data) {
if (data instanceof Map) {
data = Object.fromEntries(data); // Convert Map to object
}
if (
Array.isArray(data) ||