ozdenui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +14 -0
  3. data/NOTICE +5 -0
  4. data/README.md +242 -0
  5. data/exe/ozdenui +17 -0
  6. data/lib/ozdenui/AGENTS.md +210 -0
  7. data/lib/ozdenui/COMPONENTS.md +3017 -0
  8. data/lib/ozdenui/app.rb +749 -0
  9. data/lib/ozdenui/command.rb +107 -0
  10. data/lib/ozdenui/components.rb +368 -0
  11. data/lib/ozdenui/dialogs.rb +212 -0
  12. data/lib/ozdenui/files.rb +124 -0
  13. data/lib/ozdenui/icon.png +0 -0
  14. data/lib/ozdenui/kit.json +1 -0
  15. data/lib/ozdenui/kit.rb +115 -0
  16. data/lib/ozdenui/look.rb +229 -0
  17. data/lib/ozdenui/objects.rb +652 -0
  18. data/lib/ozdenui/server.rb +270 -0
  19. data/lib/ozdenui/values.rb +273 -0
  20. data/lib/ozdenui/version.rb +15 -0
  21. data/lib/ozdenui/web/basic/LICENSE +14 -0
  22. data/lib/ozdenui/web/basic/basic.min.css +1 -0
  23. data/lib/ozdenui/web/basic/basic.min.js +78 -0
  24. data/lib/ozdenui/web/basic/font/open-sans/LICENSE.txt +206 -0
  25. data/lib/ozdenui/web/basic/font/open-sans/OpenSans-Bold.ttf +0 -0
  26. data/lib/ozdenui/web/basic/font/open-sans/OpenSans-Regular.ttf +0 -0
  27. data/lib/ozdenui/web/basic/scroll-bar.min.js +3 -0
  28. data/lib/ozdenui/web/bridge.js +584 -0
  29. data/lib/ozdenui/web/comp/accordion.js +659 -0
  30. data/lib/ozdenui/web/comp/action-button/add.png +0 -0
  31. data/lib/ozdenui/web/comp/action-button.js +521 -0
  32. data/lib/ozdenui/web/comp/action-tab-bar.js +383 -0
  33. data/lib/ozdenui/web/comp/app-bar.js +237 -0
  34. data/lib/ozdenui/web/comp/badge.js +292 -0
  35. data/lib/ozdenui/web/comp/bottom-bar.js +555 -0
  36. data/lib/ozdenui/web/comp/breadcrumbs.js +524 -0
  37. data/lib/ozdenui/web/comp/canvas.js +652 -0
  38. data/lib/ozdenui/web/comp/chat-view.js +827 -0
  39. data/lib/ozdenui/web/comp/check-box.js +490 -0
  40. data/lib/ozdenui/web/comp/code-editor.js +965 -0
  41. data/lib/ozdenui/web/comp/color-picker.js +636 -0
  42. data/lib/ozdenui/web/comp/context-menu.js +951 -0
  43. data/lib/ozdenui/web/comp/currency-field.js +209 -0
  44. data/lib/ozdenui/web/comp/data-table/arrow.svg +2 -0
  45. data/lib/ozdenui/web/comp/data-table.js +937 -0
  46. data/lib/ozdenui/web/comp/date-picker.js +1055 -0
  47. data/lib/ozdenui/web/comp/dialog.js +992 -0
  48. data/lib/ozdenui/web/comp/email-field.js +65 -0
  49. data/lib/ozdenui/web/comp/file-picker.js +920 -0
  50. data/lib/ozdenui/web/comp/filters.js +807 -0
  51. data/lib/ozdenui/web/comp/form.js +602 -0
  52. data/lib/ozdenui/web/comp/full-screen-select/arrow.svg +2 -0
  53. data/lib/ozdenui/web/comp/full-screen-select/cancel.svg +2 -0
  54. data/lib/ozdenui/web/comp/full-screen-select.js +614 -0
  55. data/lib/ozdenui/web/comp/gauge.js +439 -0
  56. data/lib/ozdenui/web/comp/graph-box.js +3911 -0
  57. data/lib/ozdenui/web/comp/grid-group.js +185 -0
  58. data/lib/ozdenui/web/comp/hold-to-confirm-button/trash-red.png +0 -0
  59. data/lib/ozdenui/web/comp/hold-to-confirm-button/trash.png +0 -0
  60. data/lib/ozdenui/web/comp/hold-to-confirm-button.js +289 -0
  61. data/lib/ozdenui/web/comp/image-view.js +598 -0
  62. data/lib/ozdenui/web/comp/item-list.js +1740 -0
  63. data/lib/ozdenui/web/comp/json-editor.js +3221 -0
  64. data/lib/ozdenui/web/comp/json-view.js +597 -0
  65. data/lib/ozdenui/web/comp/label-editor.js +1140 -0
  66. data/lib/ozdenui/web/comp/left-menu/data-table.png +0 -0
  67. data/lib/ozdenui/web/comp/left-menu/home.png +0 -0
  68. data/lib/ozdenui/web/comp/left-menu/reports.png +0 -0
  69. data/lib/ozdenui/web/comp/left-menu/setting.png +0 -0
  70. data/lib/ozdenui/web/comp/left-menu.js +548 -0
  71. data/lib/ozdenui/web/comp/line-progress-bar.js +343 -0
  72. data/lib/ozdenui/web/comp/loading-screen.js +413 -0
  73. data/lib/ozdenui/web/comp/log-view.js +530 -0
  74. data/lib/ozdenui/web/comp/login-page.js +685 -0
  75. data/lib/ozdenui/web/comp/markdown-view.js +1045 -0
  76. data/lib/ozdenui/web/comp/menu-bar.js +624 -0
  77. data/lib/ozdenui/web/comp/mini-graph-box.js +492 -0
  78. data/lib/ozdenui/web/comp/minimal-accent.js +208 -0
  79. data/lib/ozdenui/web/comp/notice.js +229 -0
  80. data/lib/ozdenui/web/comp/number-field.js +128 -0
  81. data/lib/ozdenui/web/comp/numeric-keyboard.js +298 -0
  82. data/lib/ozdenui/web/comp/page-control.js +762 -0
  83. data/lib/ozdenui/web/comp/page-header.js +191 -0
  84. data/lib/ozdenui/web/comp/password-field/hide-btn.png +0 -0
  85. data/lib/ozdenui/web/comp/password-field/hide-btn2.png +0 -0
  86. data/lib/ozdenui/web/comp/password-field/show-btn.png +0 -0
  87. data/lib/ozdenui/web/comp/password-field/show-btn2.png +0 -0
  88. data/lib/ozdenui/web/comp/password-field.js +192 -0
  89. data/lib/ozdenui/web/comp/period-bar.js +436 -0
  90. data/lib/ozdenui/web/comp/phone-field.js +322 -0
  91. data/lib/ozdenui/web/comp/progress-bar.js +992 -0
  92. data/lib/ozdenui/web/comp/property-panel.js +3639 -0
  93. data/lib/ozdenui/web/comp/radio-button.js +527 -0
  94. data/lib/ozdenui/web/comp/range-slider.js +569 -0
  95. data/lib/ozdenui/web/comp/rich-text-editor.js +1064 -0
  96. data/lib/ozdenui/web/comp/scroll-area.js +308 -0
  97. data/lib/ozdenui/web/comp/scrolling-text.js +297 -0
  98. data/lib/ozdenui/web/comp/search-input/clear-round.svg +1 -0
  99. data/lib/ozdenui/web/comp/search-input/clear.svg +1 -0
  100. data/lib/ozdenui/web/comp/search-input/filter.png +0 -0
  101. data/lib/ozdenui/web/comp/search-input/filter.svg +1 -0
  102. data/lib/ozdenui/web/comp/search-input/search.svg +1 -0
  103. data/lib/ozdenui/web/comp/search-input.js +725 -0
  104. data/lib/ozdenui/web/comp/search-results.js +596 -0
  105. data/lib/ozdenui/web/comp/select-box.js +1862 -0
  106. data/lib/ozdenui/web/comp/settings-row.js +299 -0
  107. data/lib/ozdenui/web/comp/side-panel.js +616 -0
  108. data/lib/ozdenui/web/comp/slider-field.js +952 -0
  109. data/lib/ozdenui/web/comp/slider.js +838 -0
  110. data/lib/ozdenui/web/comp/smart-button/alert-black.png +0 -0
  111. data/lib/ozdenui/web/comp/smart-button/clock.png +0 -0
  112. data/lib/ozdenui/web/comp/smart-button.js +981 -0
  113. data/lib/ozdenui/web/comp/smart-table/clock.png +0 -0
  114. data/lib/ozdenui/web/comp/smart-table/down.png +0 -0
  115. data/lib/ozdenui/web/comp/smart-table/scroll.png +0 -0
  116. data/lib/ozdenui/web/comp/smart-table/sort.png +0 -0
  117. data/lib/ozdenui/web/comp/smart-table/up.png +0 -0
  118. data/lib/ozdenui/web/comp/smart-table.js +1883 -0
  119. data/lib/ozdenui/web/comp/sortable-list.js +1181 -0
  120. data/lib/ozdenui/web/comp/spark-line-box.js +738 -0
  121. data/lib/ozdenui/web/comp/splitter.js +411 -0
  122. data/lib/ozdenui/web/comp/status-bar.js +408 -0
  123. data/lib/ozdenui/web/comp/step-bar.js +345 -0
  124. data/lib/ozdenui/web/comp/stepper.js +753 -0
  125. data/lib/ozdenui/web/comp/tabs.js +1366 -0
  126. data/lib/ozdenui/web/comp/tag-input.js +1107 -0
  127. data/lib/ozdenui/web/comp/tap-effect.js +170 -0
  128. data/lib/ozdenui/web/comp/text-area-field.js +233 -0
  129. data/lib/ozdenui/web/comp/text-field.js +1006 -0
  130. data/lib/ozdenui/web/comp/time-line.js +398 -0
  131. data/lib/ozdenui/web/comp/time-picker.js +1032 -0
  132. data/lib/ozdenui/web/comp/tiny-select/arrow.svg +1 -0
  133. data/lib/ozdenui/web/comp/tiny-select.js +322 -0
  134. data/lib/ozdenui/web/comp/tiny-table.js +283 -0
  135. data/lib/ozdenui/web/comp/toast.js +891 -0
  136. data/lib/ozdenui/web/comp/toggle.js +757 -0
  137. data/lib/ozdenui/web/comp/tool-bar.js +760 -0
  138. data/lib/ozdenui/web/comp/tooltip.js +534 -0
  139. data/lib/ozdenui/web/comp/tree-view.js +1179 -0
  140. data/lib/ozdenui/web/comp/ui-effects.js +1097 -0
  141. data/lib/ozdenui/web/comp/ui-standards.js +403 -0
  142. data/lib/ozdenui/web/comp/url-field.js +190 -0
  143. data/lib/ozdenui/web/comp/web-view.js +588 -0
  144. data/lib/ozdenui/web/components.js +123 -0
  145. data/lib/ozdenui/web/index.html +39 -0
  146. data/lib/ozdenui/window.rb +188 -0
  147. data/lib/ozdenui/window_cocoa.rb +221 -0
  148. data/lib/ozdenui.rb +32 -0
  149. metadata +200 -0
@@ -0,0 +1,827 @@
1
+ /* Bismillah */
2
+
3
+ /*
4
+
5
+ ChatView - v26.11
6
+
7
+ UI COMPONENT
8
+ - A conversation with an AI (or with a person): the messages one under the other, an answer that comes piece by piece,
9
+ and a field at the bottom for the next message.
10
+ - A message: { key, role, text }. role "user": a bubble on the right, its text as it is written. "assistant" (an answer):
11
+ the whole width, its text is Markdown, drawn by comp/markdown-view.js (headings, lists, tables, code with a button that
12
+ copies it). "system": a small soft line in the middle. A text is never read as HTML.
13
+ - An answer that comes: addMessage({ role: "assistant" }) gives its key, appendText(key, piece) adds every piece. Only the
14
+ end of the answer is drawn again, and the view follows it until the reader scrolls up.
15
+ - The field: Enter sends, Shift+Enter makes a new line (sendOnEnter: 0: Enter makes a new line, Ctrl / Cmd + Enter sends).
16
+ The message of the user is added, the field is emptied and onSend(self, text, key) is called (key: the key of that
17
+ message): the page asks for the answer.
18
+ setBusy(1) while it comes: three dots until its first words, and Stop in the place of Send (Stop: setBusy(0), then
19
+ onStop(self)).
20
+ - showInput: 0 -> only the messages: the page has a field of its own and adds every message.
21
+ - height: a number or "100%" (the messages scroll above the field).
22
+ - Needs comp/markdown-view.js and comp/scroll-area.js (basic/scroll-bar.js for the bar; comp/code-editor.js colors the code).
23
+ - Style packages: "light" (default), "dark", "minimal", "minimalDark" (_designs/minimal-theme.htm: small and made of
24
+ lines; MinimalAccent makes them in a color of the page). Select with styleName (ChatView.styles), or later with setTheme().
25
+
26
+ USAGE:
27
+ const chat = ChatView({
28
+ width: "100%",
29
+ height: 560,
30
+ emptyText: "Ask something",
31
+ onSend: function (self, text) {
32
+ const key = self.addMessage({ role: "assistant" });
33
+ self.setBusy(1);
34
+ askTheAi(text, function (piece) { self.appendText(key, piece); }, function () { self.setBusy(0); });
35
+ },
36
+ });
37
+ chat.addMessage({ role: "user", text: "Hello" });
38
+ chat.addMessage({ role: "assistant", text: "**Hello!** How can I help?" });
39
+ chat.setMessages([{ role: "system", text: "A new conversation" }]);
40
+ chat.getMessages(); // [{ key, role, text }]
41
+ chat.setTheme("dark");
42
+
43
+ Started Date: November 2026
44
+ Webpage: https://bug7a.github.io/js-components/
45
+
46
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
47
+ Licensed under the Apache License, Version 2.0
48
+ SPDX-License-Identifier: Apache-2.0
49
+
50
+ */
51
+
52
+ "use strict";
53
+
54
+ // Default values:
55
+ const ChatViewDefaults = {
56
+ key: "0", // Your name for this object: read it in a callback (self.key)
57
+ width: 480,
58
+ height: 560, // A number or "100%". (Not "auto": the messages scroll above the field.)
59
+ messages: [], // [{ key, role: "user" | "assistant" | "system", text }]: the messages at the start (a text: an answer)
60
+ placeholder: "Write a message",
61
+ emptyText: "", // Shown while there is no message (Ex: "Ask something")
62
+ sendText: "Send", // The name of the button: a screen reader says it, the mouse shows it
63
+ stopText: "Stop",
64
+ showInput: 1, // 0: only the messages (the page has a field of its own)
65
+ sendOnEnter: 1, // 1: Enter sends, Shift+Enter makes a new line. 0: Enter makes a new line, Ctrl / Cmd + Enter sends.
66
+ maxInputLines: 6, // The field grows up to this many lines, then it scrolls
67
+ busy: 0, // 1: an answer is coming: the dots, and Stop in the place of Send. setBusy()
68
+ autoScroll: 1, // 1: the view follows a new message and an answer that comes, until the reader scrolls up
69
+ remotePictures: 0, // 1: a picture of an answer with an http address is drawn (See the note of MarkdownView)
70
+ ariaLabel: "Conversation",
71
+ copyText: "Copy", // The button of a code in an answer
72
+ copiedText: "Copied",
73
+ onSend: function (self, text, key) { }, // The user sent a text: its message (key) is on the view, the field is empty again
74
+ onStop: function (self) { }, // Stop was pressed (busy is 0 already)
75
+ onLinkClick: null, // function (self, address) {}: a link of an answer comes to you. null: it opens in a new tab.
76
+ styleName: "light", // "light", "dark", "minimal", "minimalDark" or a name added to ChatView.styles
77
+ style: { // Light style package (default)
78
+ box: { color: "white" },
79
+ page: { padding: [18, 20], gap: 20, maxWidth: 760 }, // The column of the messages. WHY maxWidth: a wide line is hard to read.
80
+ user: { color: "#EFEFEC", textColor: Black(0.88), fontSize: 15, lineRatio: 1.55, round: 18, padding: [16, 10], maxWidth: "82%", border: 0, borderColor: "transparent" },
81
+ system: { fontSize: 13, textColor: Black(0.45) },
82
+ answerStyleName: "light", // The package of MarkdownView an answer is drawn with
83
+ answer: {}, // Keys of the style of that MarkdownView over its package (Ex: { text: { fontSize: 13 } })
84
+ dots: { color: Black(0.35), size: 7, gap: 5 }, // While the first words of an answer are waited for
85
+ field: { // The place of the field and its button, under the messages
86
+ margin: [16, 12], // Around it
87
+ padding: [12, 8],
88
+ gap: 8,
89
+ color: White(1),
90
+ border: 1,
91
+ borderColor: Black(0.14),
92
+ hoverBorderColor: Black(0.3),
93
+ focusBorderColor: "#3D7A6B", // the accent of the kit
94
+ round: 16,
95
+ fontSize: 15,
96
+ lineHeight: 22,
97
+ lineSpace: 6, // px above and under the lines: one line is as high as the button
98
+ textColor: Black(0.88),
99
+ placeholderColor: Black(0.4),
100
+ },
101
+ button: {
102
+ size: 34,
103
+ iconSize: 18,
104
+ round: null, // null: a circle
105
+ color: "#3D7A6B",
106
+ iconColor: White(1),
107
+ disabledColor: Black(0.1), // Send while the field is empty
108
+ disabledIconColor: White(1),
109
+ stopColor: Black(0.85),
110
+ stopIconColor: White(1),
111
+ },
112
+ empty: { fontSize: 15, textColor: Black(0.45) },
113
+ focus: { ringColor: "rgba(61, 122, 107, 0.6)" },
114
+ scrollBar: { bar_color: "#9A9A98", bar_mouseOverColor: "#6A6A68", bar_width: 4, bar_round: 3, showDots: 0 },
115
+ },
116
+ };
117
+
118
+ const ChatView = function (params = {}) {
119
+
120
+ // Merge style package: params.style > ChatView.styles[styleName] > ChatViewDefaults.style (light)
121
+ const pageStyle = params.style; // WHY: setTheme() puts it over another package.
122
+ basic.applyStylePackage(params, ChatView.styles, ChatViewDefaults);
123
+
124
+ // Merge params:
125
+ mergeIntoIfMissing(params, ChatViewDefaults);
126
+
127
+ // Edit params, if needed:
128
+ const startMessages = (Array.isArray(params.messages)) ? params.messages.slice() : [];
129
+ params.messages = []; // WHY: The array of the page does not change; getMessages() gives the messages.
130
+
131
+ // BOX: Component container
132
+ let box = startObject(params);
133
+
134
+ // *** PRIVATE VARIABLES:
135
+ let _s = box.style;
136
+ let entries = []; // { key, role, text, row, view (an answer: its MarkdownView), label (a bubble, a system line) }
137
+ let keyNumber = 0;
138
+ let isFollowing = 1; // 1: the reader is at the end, and the view follows it
139
+ let lastScrollTop = 0;
140
+ let isFieldFocused = 0;
141
+ let isFieldHover = 0;
142
+ const ROLES = ["user", "assistant", "system"];
143
+ const BOTTOM_SPACE = 30; // px: this near to the end is at the end
144
+
145
+ // *** PUBLIC VARIABLES:
146
+ box.textareaElem = null; // The raw <textarea> of the field: a page can listen to its paste / drop
147
+ // NOTE: Default values are also public variables. (box.busy, box.placeholder, box.emptyText...)
148
+
149
+ // *** PRIVATE FUNCTIONS:
150
+
151
+ // The style of a package, with the style of the page over it. (setTheme)
152
+ const styleOfPackage = function (styleName) {
153
+ const fresh = { styleName: styleName, style: pageStyle };
154
+ basic.applyStylePackage(fresh, ChatView.styles, ChatViewDefaults);
155
+ mergeIntoIfMissing(fresh, ChatViewDefaults);
156
+ return fresh.style;
157
+ };
158
+
159
+ const textOf = function (value) {
160
+ return (value === null || value === undefined) ? "" : String(value);
161
+ };
162
+
163
+ const findEntry = function (key) {
164
+ const text = String(key);
165
+ return entries.find(function (entry) { return entry.key === text; }) || null;
166
+ };
167
+
168
+ const newKey = function () {
169
+ let key = "";
170
+ do {
171
+ keyNumber += 1;
172
+ key = "m" + keyNumber;
173
+ } while (findEntry(key));
174
+ return key;
175
+ };
176
+
177
+ // A message of the page as the view keeps it. A text is an answer.
178
+ const toEntry = function (message) {
179
+ const isObject = (message !== null && typeof message === "object");
180
+ const hasKey = (isObject && message.key !== undefined && message.key !== null);
181
+ const role = (isObject) ? message.role : "assistant";
182
+ return {
183
+ key: (hasKey) ? String(message.key) : newKey(),
184
+ role: (ROLES.indexOf(role) > -1) ? role : "assistant",
185
+ text: textOf((isObject) ? message.text : message),
186
+ row: null,
187
+ view: null,
188
+ label: null,
189
+ };
190
+ };
191
+
192
+ const lastEntry = function () {
193
+ return entries[entries.length - 1] || null;
194
+ };
195
+
196
+ // ROWS: each kind of message as objects
197
+
198
+ const createUserRow = function (entry) {
199
+ // GROUP: The bubble on the right
200
+ entry.row = HGroup({ width: "100%", height: "auto", align: "right top", clipContent: 0 });
201
+ entry.label = Label({ width: "auto", plainText: entry.text, selectable: 1 });
202
+ entry.label.css = { whiteSpace: "pre-wrap", overflowWrap: "anywhere", boxSizing: "border-box" };
203
+ endGroup();
204
+ };
205
+
206
+ const createSystemRow = function (entry) {
207
+ // GROUP: A soft line in the middle
208
+ entry.row = HGroup({ width: "100%", height: "auto", align: "center top" });
209
+ entry.label = Label({ width: "auto", plainText: entry.text, textAlign: "center", selectable: 1 });
210
+ entry.label.css = { whiteSpace: "pre-wrap", overflowWrap: "anywhere", maxWidth: "100%" };
211
+ endGroup();
212
+ };
213
+
214
+ const onAnswerLinkClick = function (view, address) {
215
+ box.onLinkClick(box, address);
216
+ };
217
+
218
+ const createAnswerView = function (entry) {
219
+ entry.view = MarkdownView({
220
+ width: "100%",
221
+ height: "auto",
222
+ markdownText: entry.text,
223
+ autoScroll: 0, // WHY: The view of the conversation follows the end, not the answer.
224
+ remotePictures: box.remotePictures,
225
+ copyText: box.copyText,
226
+ copiedText: box.copiedText,
227
+ onLinkClick: (typeof box.onLinkClick === "function") ? onAnswerLinkClick : null,
228
+ styleName: _s.answerStyleName,
229
+ style: ChatView.answerLookOf(_s),
230
+ });
231
+ };
232
+
233
+ const createAnswerRow = function (entry) {
234
+ // GROUP: The whole width; its MarkdownView grows with its text
235
+ entry.row = VGroup({ width: "100%", height: "auto", align: "left top", clipContent: 0 });
236
+ createAnswerView(entry);
237
+ endGroup();
238
+ };
239
+
240
+ // WHY made again (setTheme): the sizes of a package (minimal) are a style of the MarkdownView, given when it is made.
241
+ const drawAnswerAgain = function (entry) {
242
+ entry.view.remove();
243
+ createIn(entry.row, function () { createAnswerView(entry); });
244
+ };
245
+
246
+ const createRow = function (entry) {
247
+ if (entry.role === "user") createUserRow(entry);
248
+ else if (entry.role === "system") createSystemRow(entry);
249
+ else createAnswerRow(entry);
250
+ paintEntry(entry);
251
+ };
252
+
253
+ // The look of a message, and the room of an answer with no text yet (the dots stand in its place).
254
+ const paintEntry = function (entry) {
255
+ if (entry.role === "assistant") {
256
+ entry.row.visible = (entry.text === "") ? 0 : 1;
257
+ return;
258
+ }
259
+ if (entry.role === "system") {
260
+ entry.label.props({ fontSize: _s.system.fontSize, textColor: _s.system.textColor });
261
+ return;
262
+ }
263
+ const look = _s.user;
264
+ entry.label.props({
265
+ color: look.color,
266
+ textColor: look.textColor,
267
+ fontSize: look.fontSize,
268
+ lineHeight: Math.round(look.fontSize * look.lineRatio),
269
+ round: look.round,
270
+ padding: look.padding,
271
+ border: look.border,
272
+ borderColor: look.borderColor,
273
+ });
274
+ entry.label.css.maxWidth = look.maxWidth;
275
+ };
276
+
277
+ // The text of a message on the view. piece: the end that was added (appendText): an answer draws only the end again.
278
+ const writeText = function (entry, text, piece) {
279
+ entry.text = text;
280
+ if (entry.view && piece !== undefined) entry.view.appendText(piece);
281
+ else if (entry.view) entry.view.setMarkdownText(text);
282
+ else entry.label.plainText = text;
283
+ paintEntry(entry);
284
+ paintDots();
285
+ };
286
+
287
+ const paintEmpty = function () {
288
+ const isEmpty = (entries.length === 0 && box.emptyText !== "");
289
+ box.lblEmpty.plainText = box.emptyText;
290
+ box.lblEmpty.visible = (isEmpty) ? 1 : 0;
291
+ };
292
+
293
+ // The dots: busy, and the answer has no words yet (or it was not added yet).
294
+ const paintDots = function () {
295
+ const last = lastEntry();
296
+ const isWaiting = (box.busy == 1) && (!last || last.role !== "assistant" || last.text === "");
297
+ box.dotsRow.visible = (isWaiting) ? 1 : 0;
298
+ };
299
+
300
+ // FOLLOWING THE END
301
+
302
+ const isSelectingText = function () {
303
+ const selection = window.getSelection();
304
+ return !!(selection && !selection.isCollapsed && box.elem.contains(selection.anchorNode));
305
+ };
306
+
307
+ const isAtEnd = function () {
308
+ const elem = box.messageArea.scrollBox.elem;
309
+ return (elem.scrollHeight - elem.scrollTop - elem.clientHeight <= BOTTOM_SPACE);
310
+ };
311
+
312
+ const goToEnd = function () {
313
+ const elem = box.messageArea.scrollBox.elem;
314
+ elem.scrollTop = elem.scrollHeight;
315
+ lastScrollTop = elem.scrollTop; // WHY: Its scroll event comes a frame late, when more text may have come: not a scroll up.
316
+ };
317
+
318
+ // WHY on a resize of the column: an answer is drawn a little after its piece came (MarkdownView), and it grows then.
319
+ const followEnd = function () {
320
+ if (box.autoScroll != 1 || !isFollowing || isSelectingText()) return;
321
+ goToEnd();
322
+ };
323
+
324
+ // The reader moved: at the end the view follows again, above it the view stays.
325
+ const onScroll = function () {
326
+ const scrollTop = box.messageArea.getScrollTop();
327
+ if (scrollTop === lastScrollTop) return;
328
+ lastScrollTop = scrollTop;
329
+ isFollowing = isAtEnd() ? 1 : 0;
330
+ };
331
+
332
+ // THE FIELD
333
+
334
+ const hasText = function () {
335
+ return !!box.textareaElem && box.textareaElem.value.trim() !== "";
336
+ };
337
+
338
+ // The field grows with its lines up to maxInputLines, then it scrolls.
339
+ const growField = function () {
340
+ const elem = box.textareaElem;
341
+ const most = _s.field.lineHeight * box.maxInputLines + _s.field.lineSpace * 2;
342
+ elem.style.height = "auto"; // WHY: First reset, so scrollHeight is the height of the text (also when it got shorter).
343
+ // WHY: Not drawn yet (a closed tab): scrollHeight is 0, and the field keeps the height of its CSS.
344
+ if (elem.scrollHeight === 0) return;
345
+ elem.style.height = Math.min(elem.scrollHeight, most) + "px";
346
+ elem.style.overflowY = (elem.scrollHeight > most) ? "auto" : "hidden";
347
+ };
348
+
349
+ const paintField = function () {
350
+ const look = _s.field;
351
+ let borderColor = look.borderColor;
352
+ if (isFieldHover) borderColor = look.hoverBorderColor;
353
+ if (isFieldFocused) borderColor = look.focusBorderColor;
354
+ box.fieldGroup.borderColor = borderColor;
355
+ };
356
+
357
+ const paintButton = function () {
358
+ const look = _s.button;
359
+ const isBusy = (box.busy == 1);
360
+ const isEnabled = isBusy || hasText();
361
+ let color = look.color;
362
+ let iconColor = look.iconColor;
363
+ if (!isEnabled) {
364
+ color = look.disabledColor;
365
+ iconColor = look.disabledIconColor;
366
+ }
367
+ if (isBusy) {
368
+ color = look.stopColor;
369
+ iconColor = look.stopIconColor;
370
+ }
371
+ const name = (isBusy) ? box.stopText : box.sendText;
372
+ const svg = (isBusy) ? ChatView.getStopSvg(iconColor, look.iconSize) : ChatView.getSendSvg(iconColor, look.iconSize);
373
+ const round = (look.round === null || look.round === undefined) ? look.size / 2 : look.round;
374
+ box.btnSend.props({ color: color, text: svg, width: look.size, height: look.size, round: round });
375
+ box.btnSend.cursor = (isEnabled) ? "pointer" : "default";
376
+ box.btnSend.aria = { label: name, disabled: (isEnabled) ? "false" : "true" };
377
+ box.btnSend.elem.title = name;
378
+ };
379
+
380
+ const onFieldInput = function () {
381
+ growField();
382
+ paintButton();
383
+ };
384
+
385
+ const onFieldKeyDown = function (self, event) {
386
+ // WHY isComposing: the Enter of an input method (Japanese, Chinese) chooses a word; it does not send.
387
+ if (event.key !== "Enter" || event.isComposing) return;
388
+ const isSendKey = (box.sendOnEnter == 1) ? !event.shiftKey : (event.ctrlKey || event.metaKey);
389
+ if (!isSendKey) return;
390
+ event.preventDefault();
391
+ box.send();
392
+ };
393
+
394
+ const pressButton = function () {
395
+ if (box.busy == 1) {
396
+ box.stop();
397
+ return;
398
+ }
399
+ box.send();
400
+ };
401
+
402
+ const onButtonKeyDown = function (self, event) {
403
+ if (event.key !== "Enter" && event.key !== " ") return;
404
+ event.preventDefault();
405
+ pressButton();
406
+ };
407
+
408
+ // WHY variables: the placeholder of a raw <textarea> is reached only by a style sheet.
409
+ const applyFieldLook = function () {
410
+ const look = _s.field;
411
+ const elem = box.textareaElem;
412
+ box.fieldGroup.props({ color: look.color, border: look.border, round: look.round, padding: look.padding, gap: look.gap });
413
+ box.fieldGroup.css.maxWidth = _s.page.maxWidth + "px";
414
+ box.inputRow.padding = look.margin;
415
+ elem.style.fontSize = look.fontSize + "px";
416
+ elem.style.lineHeight = look.lineHeight + "px";
417
+ elem.style.padding = look.lineSpace + "px 4px";
418
+ elem.style.color = look.textColor;
419
+ elem.style.setProperty("--chat-view-placeholder", look.placeholderColor);
420
+ growField();
421
+ paintField();
422
+ paintButton();
423
+ };
424
+
425
+ const applyScrollBarLook = function () {
426
+ const scrollBar = box.messageArea.scrollBar;
427
+ if (!scrollBar) return;
428
+ Object.assign(scrollBar, _s.scrollBar);
429
+ scrollBar.boxScrollBarTop.color = _s.scrollBar.bar_color;
430
+ scrollBar.boxScrollBarLeft.color = _s.scrollBar.bar_color;
431
+ };
432
+
433
+ const applyLook = function () {
434
+ box.color = _s.box.color;
435
+ box.messageArea.setPadding(_s.page.padding);
436
+ box.column.gap = _s.page.gap;
437
+ box.messageGroup.gap = _s.page.gap;
438
+ box.column.css.maxWidth = _s.page.maxWidth + "px";
439
+ box.lblEmpty.props({ fontSize: _s.empty.fontSize, textColor: _s.empty.textColor });
440
+ box.dotsRow.gap = _s.dots.gap;
441
+ box.dots.forEach(function (dot) {
442
+ dot.props({ width: _s.dots.size, height: _s.dots.size, round: _s.dots.size / 2, color: _s.dots.color });
443
+ });
444
+ box.messageArea.scrollBox.setFocusRing(_s.focus.ringColor);
445
+ box.btnSend.setFocusRing(_s.focus.ringColor);
446
+ applyFieldLook();
447
+ applyScrollBarLook();
448
+ entries.forEach(paintEntry);
449
+ };
450
+
451
+ // *** PUBLIC FUNCTIONS:
452
+
453
+ // A message at the end: { key, role, text } (a text: an answer). Returns its key ("m1"... when it has none).
454
+ box.addMessage = function (message) {
455
+ const entry = toEntry(message);
456
+ entries.push(entry);
457
+ createIn(box.messageGroup, function () { createRow(entry); });
458
+ paintEmpty();
459
+ paintDots();
460
+ return entry.key;
461
+ };
462
+ // USAGE: const key = chat.addMessage({ role: "assistant" }) // an answer that will come: appendText(key, piece)
463
+
464
+ // The next piece of a message (an answer as it comes). MarkdownView draws the pieces that come fast together.
465
+ box.appendText = function (key, text) {
466
+ const entry = findEntry(key);
467
+ if (!entry || text === null || text === undefined) return;
468
+ writeText(entry, entry.text + String(text), String(text));
469
+ };
470
+ // USAGE: chat.appendText(key, " and the next words")
471
+
472
+ box.setMessageText = function (key, text) {
473
+ const entry = findEntry(key);
474
+ if (!entry) return;
475
+ writeText(entry, textOf(text));
476
+ };
477
+ // USAGE: chat.setMessageText(key, "The whole answer")
478
+
479
+ box.getMessageText = function (key) {
480
+ const entry = findEntry(key);
481
+ return (entry) ? entry.text : "";
482
+ };
483
+
484
+ box.removeMessage = function (key) {
485
+ const entry = findEntry(key);
486
+ if (!entry) return;
487
+ entries.splice(entries.indexOf(entry), 1);
488
+ entry.row.remove();
489
+ paintEmpty();
490
+ paintDots();
491
+ };
492
+
493
+ // Every message goes (the field keeps its text).
494
+ box.clear = function () {
495
+ entries.forEach(function (entry) { entry.row.remove(); });
496
+ entries = [];
497
+ paintEmpty();
498
+ paintDots();
499
+ };
500
+
501
+ // Another conversation: its end is shown.
502
+ box.setMessages = function (messages) {
503
+ box.clear();
504
+ (Array.isArray(messages) ? messages : []).forEach(box.addMessage);
505
+ box.scrollToEnd();
506
+ };
507
+ // USAGE: chat.setMessages([{ role: "user", text: "Hi" }, { role: "assistant", text: "Hello!" }])
508
+
509
+ // [{ key, role, text }]: copies, in order.
510
+ box.getMessages = function () {
511
+ return entries.map(function (entry) { return { key: entry.key, role: entry.role, text: entry.text }; });
512
+ };
513
+
514
+ // An answer is coming: the dots (until its first words) and Stop.
515
+ box.setBusy = function (value) {
516
+ box.busy = basic.isOn(value) ? 1 : 0;
517
+ box.messageArea.scrollBox.aria = { busy: (box.busy == 1) ? "true" : "false" };
518
+ paintDots();
519
+ paintButton();
520
+ };
521
+ // USAGE: get: chat.busy, set: chat.setBusy(1)
522
+
523
+ // The text of the field is sent, as the button does: its message, an empty field, onSend(self, text, key).
524
+ // WHY the key: a page that keeps the conversation (or a program in another language) knows the message by it.
525
+ box.send = function () {
526
+ if (box.busy == 1 || !hasText()) return;
527
+ const text = box.textareaElem.value.trim();
528
+ box.setInputText("");
529
+ const key = box.addMessage({ role: "user", text: text });
530
+ box.scrollToEnd();
531
+ box.onSend(box, text, key);
532
+ };
533
+
534
+ // As the Stop button: busy goes to 0, then onStop(self).
535
+ box.stop = function () {
536
+ if (box.busy != 1) return;
537
+ box.setBusy(0);
538
+ box.onStop(box);
539
+ };
540
+
541
+ box.setInputText = function (text) {
542
+ box.textareaElem.value = textOf(text);
543
+ growField();
544
+ paintButton();
545
+ };
546
+
547
+ box.getInputText = function () {
548
+ return box.textareaElem.value;
549
+ };
550
+
551
+ box.focus = function () {
552
+ box.textareaElem.focus();
553
+ };
554
+
555
+ box.setPlaceholder = function (text) {
556
+ box.placeholder = textOf(text);
557
+ box.textareaElem.placeholder = box.placeholder;
558
+ box.textareaElem.setAttribute("aria-label", box.placeholder);
559
+ };
560
+
561
+ box.setEmptyText = function (text) {
562
+ box.emptyText = textOf(text);
563
+ paintEmpty();
564
+ };
565
+
566
+ box.setShowInput = function (value) {
567
+ box.showInput = basic.isOn(value) ? 1 : 0;
568
+ box.inputRow.visible = box.showInput;
569
+ };
570
+
571
+ // It goes to the end, and follows again.
572
+ box.scrollToEnd = function () {
573
+ isFollowing = 1;
574
+ goToEnd();
575
+ };
576
+
577
+ box.scrollToTop = function () {
578
+ box.messageArea.scrollToTop();
579
+ lastScrollTop = 0;
580
+ isFollowing = isAtEnd() ? 1 : 0;
581
+ };
582
+
583
+ // Another style package while it is on the page. A style given by the page stays over it.
584
+ box.setTheme = function (styleName) {
585
+ box.styleName = styleName;
586
+ _s = styleOfPackage(styleName);
587
+ box.style = _s;
588
+ applyLook();
589
+ entries.forEach(function (entry) {
590
+ if (entry.view) drawAnswerAgain(entry);
591
+ });
592
+ };
593
+ // USAGE: chat.setTheme("dark")
594
+
595
+ // *** OBJECT VIEW:
596
+
597
+ // GROUP: The messages above, the field under them
598
+ box.layout = VGroup({ width: "100%", height: "100%", align: "center top", gap: 0, clipContent: 0 });
599
+
600
+ // SCROLL AREA: The messages (the room the field leaves)
601
+ box.messageArea = ScrollArea({ align: "center top", onScroll: onScroll, style: { scrollBar: _s.scrollBar } });
602
+
603
+ // GROUP: The column of the messages (in the middle of a wide window)
604
+ box.column = VGroup({ width: "100%", height: "auto", align: "left top", clipContent: 0 });
605
+
606
+ box.messageGroup = VGroup({ width: "100%", height: "auto", align: "left top", clipContent: 0 });
607
+ endGroup();
608
+
609
+ // GROUP: The dots of an answer that is waited for
610
+ box.dotsRow = HGroup({ hug: 1, align: "left center", padding: [2, 8] });
611
+ box.dots = [Box(), Box(), Box()];
612
+ endGroup();
613
+
614
+ endGroup();
615
+
616
+ // LABEL: Shown while there is no message (in the middle of the area)
617
+ box.lblEmpty = Label({ width: "100%", textAlign: "center", visible: 0 });
618
+ box.lblEmpty.css = { margin: "auto 0", whiteSpace: "pre-wrap", padding: "0 20px", boxSizing: "border-box" };
619
+
620
+ endGroup();
621
+
622
+ // GROUP: The field and its button
623
+ box.inputRow = HGroup({ width: "100%", height: "auto", align: "center top", clipContent: 0 });
624
+ box.fieldGroup = HGroup({ width: "100%", height: "auto", align: "left bottom", clipContent: 0 });
625
+ // BOX: The place of the raw <textarea>
626
+ box.fieldBox = Box({ width: "auto", height: "auto", color: "transparent" });
627
+ box.fieldBox.grow = 1;
628
+ box.fieldBox.css.minWidth = "0px";
629
+ box.btnSend = Label({ clickable: 1 });
630
+ box.btnSend.shrink = 0;
631
+ box.btnSend.lineHeight = "0";
632
+ box.btnSend.role = "button";
633
+ box.btnSend.tabIndex = 0;
634
+ box.btnSend.elem.style.display = "flex";
635
+ box.btnSend.css = { alignItems: "center", justifyContent: "center" };
636
+ endGroup();
637
+ endGroup();
638
+
639
+ endGroup();
640
+
641
+ // *** OBJECT INIT CODE:
642
+
643
+ ChatView.addCss();
644
+
645
+ const textareaElem = document.createElement("textarea");
646
+ textareaElem.rows = 1;
647
+ textareaElem.className = "chat-view-field";
648
+ box.fieldBox.elem.appendChild(textareaElem);
649
+ box.textareaElem = textareaElem;
650
+
651
+ box.messageArea.scrollBox.role = "log";
652
+ box.messageArea.scrollBox.aria = { label: box.ariaLabel, busy: "false" };
653
+ box.messageArea.scrollBox.tabIndex = 0; // WHY: The keys of a focused area scroll it (arrows, Page Up, Home, End).
654
+ box.dots.forEach(function (dot, index) {
655
+ dot.elem.classList.add("chat-view-dot");
656
+ dot.elem.style.animationDelay = (index * ChatView.DOT_DELAY) + "s";
657
+ });
658
+
659
+ box.listenTo(textareaElem, "input", onFieldInput);
660
+ box.listenTo(textareaElem, "keydown", onFieldKeyDown);
661
+ box.listenTo(textareaElem, "focus", function () {
662
+ isFieldFocused = 1;
663
+ paintField();
664
+ });
665
+ box.listenTo(textareaElem, "blur", function () {
666
+ isFieldFocused = 0;
667
+ paintField();
668
+ });
669
+ box.fieldGroup.onHoverChange(function (self, isOver) {
670
+ isFieldHover = isOver ? 1 : 0;
671
+ paintField();
672
+ });
673
+ // WHY: A click on the padding of the field, around the text, writes in it too.
674
+ box.fieldGroup.on("click", function (self, event) {
675
+ if (event.target === textareaElem || box.btnSend.elem.contains(event.target)) return;
676
+ textareaElem.focus();
677
+ });
678
+ box.btnSend.on("click", pressButton);
679
+ box.btnSend.on("keydown", onButtonKeyDown);
680
+ box.column.onResize(followEnd);
681
+
682
+ box.setPlaceholder(box.placeholder);
683
+ applyLook();
684
+ box.setShowInput(box.showInput);
685
+ startMessages.forEach(box.addMessage);
686
+ paintEmpty();
687
+ box.setBusy(box.busy);
688
+ // WHY the motion after the first color: the field reads its height before the button gets its color, so the first
689
+ // color came with a motion from transparent, and a window that was not drawn (behind the others) kept it
690
+ // transparent. Reading the style now draws the first color without a motion.
691
+ getComputedStyle(box.btnSend.elem).backgroundColor;
692
+ box.btnSend.css.transition = "background-color 0.15s";
693
+ box.after(0, box.scrollToEnd); // WHY later: the messages of the start are drawn first.
694
+
695
+ return endObject(box);
696
+
697
+ };
698
+
699
+ // *** STATIC VARIABLES AND FUNCTIONS:
700
+
701
+ ChatView.DOT_DELAY = 0.16; // s: between the dots
702
+
703
+ // The look of the MarkdownView of an answer over its package: no ground, no room around it (the column has it).
704
+ ChatView.ANSWER_LOOK = { box: { color: "transparent" }, page: { padding: [0, 0] } };
705
+
706
+ // The style of the MarkdownView of an answer: ANSWER_LOOK and the answer keys of a package (the sizes of minimal).
707
+ ChatView.answerLookOf = function (style) {
708
+ return Object.assign({}, ChatView.ANSWER_LOOK, style.answer);
709
+ };
710
+
711
+ ChatView.getSendSvg = function (color, size) {
712
+ return '<svg xmlns="http://www.w3.org/2000/svg" width="' + size + '" height="' + size + '" viewBox="0 0 24 24" fill="none" stroke="' + color + '" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M12 19V5"/><path d="M5.5 11.5 12 5l6.5 6.5"/></svg>';
713
+ };
714
+
715
+ ChatView.getStopSvg = function (color, size) {
716
+ return '<svg xmlns="http://www.w3.org/2000/svg" width="' + size + '" height="' + size + '" viewBox="0 0 24 24"><rect x="6.5" y="6.5" width="11" height="11" rx="2.5" fill="' + color + '"/></svg>';
717
+ };
718
+
719
+ // The field (a raw <textarea>) and the dots: only a style sheet reaches them.
720
+ ChatView.addCss = function () {
721
+ basic.addCss("chat-view-css",
722
+ ".chat-view-field { display: block; width: 100%; box-sizing: border-box; margin: 0; border: 0; outline: none; resize: none;" +
723
+ " background: transparent; font-family: inherit; overflow-y: hidden; pointer-events: auto; user-select: text; -webkit-user-select: text; }" +
724
+ ".chat-view-field::placeholder { color: var(--chat-view-placeholder); opacity: 1; }" +
725
+ "@keyframes chat-view-dot { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }" +
726
+ ".chat-view-dot { animation: chat-view-dot 1.2s infinite ease-in-out; }" +
727
+ "@media (prefers-reduced-motion: reduce) { .chat-view-dot { animation: none; opacity: 0.6; } }");
728
+ };
729
+
730
+ // *** STYLE PACKAGES:
731
+ // USAGE: ChatView({ styleName: "dark" })
732
+ // USAGE: ChatView({ styleName: "dark", style: { user: { round: 12 } } }) // Change only some keys.
733
+ // NOTE: A new package needs only the keys that differ from the default (light) style.
734
+ ChatView.styles = {
735
+
736
+ // A white page.
737
+ light: ChatViewDefaults.style,
738
+
739
+ // For a dark window: the colors of MarkdownView "dark" and of the fields of the kit.
740
+ dark: {
741
+ box: { color: "#1C1C1B" },
742
+ user: { color: "#2E2E2D", textColor: White(0.9) },
743
+ system: { textColor: White(0.5) },
744
+ answerStyleName: "dark",
745
+ dots: { color: White(0.45) },
746
+ field: {
747
+ color: "#232322",
748
+ borderColor: White(0.12),
749
+ hoverBorderColor: White(0.32),
750
+ focusBorderColor: "#65A293", // the accent of the kit on a dark page
751
+ textColor: White(0.9),
752
+ placeholderColor: White(0.4),
753
+ },
754
+ button: {
755
+ color: "#65A293",
756
+ iconColor: "#141414", // WHY not white: white on the green is too soft to read
757
+ disabledColor: White(0.1),
758
+ disabledIconColor: White(0.4),
759
+ stopColor: White(0.88),
760
+ stopIconColor: "#141414",
761
+ },
762
+ empty: { textColor: White(0.5) },
763
+ focus: { ringColor: "rgba(101, 162, 147, 0.7)" },
764
+ scrollBar: { bar_color: "#8A8A88", bar_mouseOverColor: "#BFBFBD" },
765
+ },
766
+
767
+ };
768
+
769
+ // The minimal theme (_designs/minimal-theme.htm): small (a 13 px text, a 28 px button) and made of lines: the bubble of
770
+ // the user and the field are lines on the ground of the window; the ink fills only Send. MinimalAccent makes the
771
+ // packages of a color of the page from these colors.
772
+ ChatView.createMinimalStyle = function (colors) {
773
+ return {
774
+ box: { color: colors.ground },
775
+ page: { padding: [14, 12], gap: 14, maxWidth: 760 },
776
+ user: { color: "transparent", textColor: colors.text, fontSize: 13, lineRatio: 1.55, round: 10, padding: [12, 7], maxWidth: "82%", border: 1, borderColor: colors.line },
777
+ system: { fontSize: 12, textColor: colors.softText },
778
+ answerStyleName: colors.answerStyleName,
779
+ // WHY the sizes of an answer here: MarkdownView has no minimal package; its text takes the 13 px of the theme.
780
+ answer: {
781
+ text: { fontSize: 13, lineRatio: 1.55 },
782
+ heading: { fontSizes: [20, 17, 15, 14, 13, 13] },
783
+ code: { color: "transparent", borderColor: colors.line, round: 4, fontSize: 12, lineHeight: 18 }, // a code is lines too
784
+ },
785
+ dots: { color: colors.softText, size: 5, gap: 4 },
786
+ field: {
787
+ margin: [12, 10],
788
+ padding: [8, 2],
789
+ gap: 6,
790
+ color: "transparent",
791
+ border: 1,
792
+ borderColor: colors.edge,
793
+ hoverBorderColor: colors.edgeHover,
794
+ focusBorderColor: colors.ink,
795
+ round: 4,
796
+ fontSize: 13,
797
+ lineHeight: 20,
798
+ lineSpace: 4,
799
+ textColor: colors.text,
800
+ placeholderColor: colors.faintText,
801
+ },
802
+ button: {
803
+ size: 28,
804
+ iconSize: 14,
805
+ round: 4,
806
+ color: colors.ink,
807
+ iconColor: colors.onInk,
808
+ disabledColor: "transparent",
809
+ disabledIconColor: colors.faintText,
810
+ stopColor: colors.ink,
811
+ stopIconColor: colors.onInk,
812
+ },
813
+ empty: { fontSize: 13, textColor: colors.softText },
814
+ focus: { ringColor: colors.focus },
815
+ scrollBar: { bar_color: colors.scrollBar, bar_mouseOverColor: colors.scrollBar, bar_width: 3, bar_mouseOverWidth: 4, bar_round: 3, showDots: 0 },
816
+ };
817
+ };
818
+ ChatView.MINIMAL_COLORS = {
819
+ ground: "#FFFFFF", text: Black(0.85), softText: Black(0.55), faintText: Black(0.54), line: Black(0.2), edge: Black(0.45),
820
+ edgeHover: Black(0.65), ink: "#1F1F1F", onInk: "#FFFFFF", focus: "#3D8BD9", scrollBar: "#373836", answerStyleName: "light",
821
+ };
822
+ ChatView.styles.minimal = ChatView.createMinimalStyle(ChatView.MINIMAL_COLORS);
823
+ ChatView.MINIMAL_DARK_COLORS = {
824
+ ground: "#1A1A19", text: White(0.88), softText: White(0.55), faintText: White(0.48), line: White(0.18), edge: White(0.42),
825
+ edgeHover: White(0.62), ink: "#EDEDEB", onInk: "#1A1A19", focus: "#7FB6DE", scrollBar: "#CFCFCD", answerStyleName: "dark",
826
+ };
827
+ ChatView.styles.minimalDark = ChatView.createMinimalStyle(ChatView.MINIMAL_DARK_COLORS);