create-basicjs 0.1.5 → 0.1.6

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 (94) hide show
  1. package/README.md +10 -0
  2. package/bin/create-basicjs.js +27 -1
  3. package/package.json +1 -1
  4. package/payload/projects/tauri/.github/workflows/build.yml +86 -0
  5. package/payload/projects/tauri/.github/workflows/tests.yml +87 -0
  6. package/payload/projects/tauri/AGENTS.md +128 -0
  7. package/payload/projects/tauri/CLAUDE.md +1 -0
  8. package/payload/projects/tauri/LICENSE +201 -0
  9. package/payload/projects/tauri/NOTICE +8 -0
  10. package/payload/projects/tauri/README.md +269 -0
  11. package/payload/projects/tauri/checks/window-check.js +189 -0
  12. package/payload/projects/tauri/gitignore +8 -0
  13. package/payload/projects/tauri/handbook/01-getting-started.md +188 -0
  14. package/payload/projects/tauri/handbook/02-the-project.md +264 -0
  15. package/payload/projects/tauri/handbook/03-the-page.md +260 -0
  16. package/payload/projects/tauri/handbook/04-commands.md +265 -0
  17. package/payload/projects/tauri/handbook/05-events-and-state.md +275 -0
  18. package/payload/projects/tauri/handbook/06-plugins.md +282 -0
  19. package/payload/projects/tauri/handbook/07-the-window-and-the-app.md +431 -0
  20. package/payload/projects/tauri/handbook/08-security.md +374 -0
  21. package/payload/projects/tauri/handbook/09-tests-and-checks.md +266 -0
  22. package/payload/projects/tauri/handbook/10-building-and-releasing.md +238 -0
  23. package/payload/projects/tauri/handbook/11-troubleshooting.md +259 -0
  24. package/payload/projects/tauri/handbook/README.md +125 -0
  25. package/payload/projects/tauri/handbook/turkce/01-getting-started.md +193 -0
  26. package/payload/projects/tauri/handbook/turkce/02-the-project.md +272 -0
  27. package/payload/projects/tauri/handbook/turkce/03-the-page.md +272 -0
  28. package/payload/projects/tauri/handbook/turkce/04-commands.md +271 -0
  29. package/payload/projects/tauri/handbook/turkce/05-events-and-state.md +284 -0
  30. package/payload/projects/tauri/handbook/turkce/06-plugins.md +286 -0
  31. package/payload/projects/tauri/handbook/turkce/07-the-window-and-the-app.md +433 -0
  32. package/payload/projects/tauri/handbook/turkce/08-security.md +384 -0
  33. package/payload/projects/tauri/handbook/turkce/09-tests-and-checks.md +275 -0
  34. package/payload/projects/tauri/handbook/turkce/10-building-and-releasing.md +241 -0
  35. package/payload/projects/tauri/handbook/turkce/11-troubleshooting.md +264 -0
  36. package/payload/projects/tauri/handbook/turkce/README.md +128 -0
  37. package/payload/projects/tauri/images/app.png +0 -0
  38. package/payload/projects/tauri/src-tauri/Cargo.lock +4389 -0
  39. package/payload/projects/tauri/src-tauri/Cargo.toml +31 -0
  40. package/payload/projects/tauri/src-tauri/app-icon.svg +16 -0
  41. package/payload/projects/tauri/src-tauri/build.rs +15 -0
  42. package/payload/projects/tauri/src-tauri/capabilities/default.json +7 -0
  43. package/payload/projects/tauri/src-tauri/gitignore +5 -0
  44. package/payload/projects/tauri/src-tauri/icons/128x128.png +0 -0
  45. package/payload/projects/tauri/src-tauri/icons/128x128@2x.png +0 -0
  46. package/payload/projects/tauri/src-tauri/icons/32x32.png +0 -0
  47. package/payload/projects/tauri/src-tauri/icons/icon.icns +0 -0
  48. package/payload/projects/tauri/src-tauri/icons/icon.ico +0 -0
  49. package/payload/projects/tauri/src-tauri/src/check.rs +144 -0
  50. package/payload/projects/tauri/src-tauri/src/files.rs +255 -0
  51. package/payload/projects/tauri/src-tauri/src/main.rs +45 -0
  52. package/payload/projects/tauri/src-tauri/src/sizes.rs +214 -0
  53. package/payload/projects/tauri/src-tauri/tauri.conf.json +44 -0
  54. package/payload/projects/tauri/src-tauri/tests/project.rs +243 -0
  55. package/payload/projects/tauri/ui/app.js +459 -0
  56. package/payload/projects/tauri/ui/backend.js +196 -0
  57. package/payload/projects/tauri/ui/basic/LICENSE +14 -0
  58. package/payload/projects/tauri/ui/basic/basic.min.css +1 -0
  59. package/payload/projects/tauri/ui/basic/basic.min.js +78 -0
  60. package/payload/projects/tauri/ui/basic/font/open-sans/LICENSE.txt +206 -0
  61. package/payload/projects/tauri/ui/basic/font/open-sans/OpenSans-Bold.ttf +0 -0
  62. package/payload/projects/tauri/ui/basic/font/open-sans/OpenSans-Regular.ttf +0 -0
  63. package/payload/projects/tauri/ui/basic/scroll-bar.min.js +3 -0
  64. package/payload/projects/tauri/ui/comp/_sources.txt +9 -0
  65. package/payload/projects/tauri/ui/comp/components.min.js +21 -0
  66. package/payload/projects/tauri/ui/index.html +28 -0
  67. package/payload/projects/tauri/ui/sizes.js +104 -0
  68. package/payload/starter/_basic/VERSION +1 -1
  69. package/payload/starter/_basic/comp/bottom-bar.js +31 -3
  70. package/payload/starter/_basic/comp/code-editor.js +219 -1
  71. package/payload/starter/_basic/comp/context-menu.js +6 -1
  72. package/payload/starter/_basic/comp/markdown-view.js +4 -2
  73. package/payload/starter/_basic/comp/property-panel.js +1 -1
  74. package/payload/starter/_basic/comp/slider.js +27 -12
  75. package/payload/starter/_basic/comp/smart-button.js +5 -1
  76. package/payload/starter/_basic/comp/smart-table.js +8 -1
  77. package/payload/starter/_basic/comp/stepper.js +29 -3
  78. package/payload/starter/_basic/comp/toggle.js +2 -1
  79. package/payload/starter/_basic/docs/component-index.md +53 -53
  80. package/payload/starter/_basic/examples/code-editor.htm +48 -1
  81. package/payload/starter/_basic/examples/gallery-styled.htm +896 -0
  82. package/payload/starter/_basic/examples/search-input.htm +1 -1
  83. package/payload/starter/_basic/examples/select-box-2-item-view.htm +304 -0
  84. package/payload/starter/_basic/examples/{slider-2-classic.htm → slider-2-split.htm} +36 -2
  85. package/payload/starter/_basic/examples/stepper-2.htm +22 -6
  86. package/payload/starter/_basic/min/bottom-bar.min.js +1 -1
  87. package/payload/starter/_basic/min/code-editor.min.js +1 -1
  88. package/payload/starter/_basic/min/context-menu.min.js +1 -1
  89. package/payload/starter/_basic/min/markdown-view.min.js +1 -1
  90. package/payload/starter/_basic/min/slider.min.js +1 -1
  91. package/payload/starter/_basic/min/smart-button.min.js +1 -1
  92. package/payload/starter/_basic/min/smart-table.min.js +1 -1
  93. package/payload/starter/_basic/min/stepper.min.js +1 -1
  94. package/payload/starter/_basic/min/toggle.min.js +1 -1
@@ -22,7 +22,7 @@
22
22
 
23
23
  // SearchInput (comp/search-input.js): the model page, and the design page of SearchInput.styles.ozden.
24
24
  // The look comes only from the package: the samples give no look params.
25
- // basic-designer:
25
+ // basic.js Designer:
26
26
  // http://127.0.0.1:5505/_basic-designer/index.htm?page=_basic/examples/search-input.htm
27
27
  // WHY a name for every SearchInput: it is the name of its layer in basic-designer.
28
28
 
@@ -0,0 +1,304 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <base href="../../"><!-- This page uses the paths of a page at the root of the project. -->
5
+
6
+ <title>SelectBox - your own rows and field, in every package</title>
7
+
8
+ <meta charset="UTF-8">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
10
+
11
+ <link rel="preload" href="_basic/basic/font/open-sans/OpenSans-Regular.ttf" as="font" crossorigin="anonymous">
12
+ <link rel="stylesheet" type="text/css" href="_basic/basic/basic.css">
13
+ <script src="_basic/basic/basic.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="_basic/basic/scroll-bar.js" type="text/javascript" charset="utf-8"></script>
15
+
16
+ <script src="_basic/comp/scroll-area.js" type="text/javascript" charset="utf-8"></script>
17
+ <script src="_basic/comp/smart-button.js" type="text/javascript" charset="utf-8"></script>
18
+ <!-- item-list.js before select-box.js: with createItemView, the list of SelectBox is an ItemList -->
19
+ <script src="_basic/comp/item-list.js" type="text/javascript" charset="utf-8"></script>
20
+ <script src="_basic/comp/search-input.js" type="text/javascript" charset="utf-8"></script>
21
+ <script src="_basic/comp/select-box.js" type="text/javascript" charset="utf-8"></script>
22
+
23
+ <script>
24
+
25
+ /* Bismillah */
26
+
27
+ /*
28
+
29
+ SelectBox with YOUR OWN ROWS and FIELD, in the packages "ozden", "light" and "dark".
30
+
31
+ - createItemView(option, row, self) -> draws one row of the list (an HGroup: the objects side by side).
32
+ - createValueView(option, field, self) -> draws the selected option in the field.
33
+ - disabled: 1 -> the option can not be selected. searchText -> more words the search finds it by ("Turkey").
34
+
35
+ 1. Countries: single, ozden, own rows and field, a search, a disabled option (Vatican City).
36
+ 2. Fruits: multiple, ozden, own rows (a picture, the name and a tag).
37
+ 3. Fruits: single, light, own rows and field, a search.
38
+ 4. Fruits: single, dark, own rows.
39
+
40
+ The buttons under a select call its functions: setValue() (with 1: no onChange), clear(), setOptions(), setEnabled().
41
+
42
+ */
43
+
44
+ // *** VARIABLES:
45
+ const FRUITS_PATH = "_basic/assets/fruids/";
46
+ const COLUMN_WIDTH = 350;
47
+ const COUNTRY_FIELD_HEIGHT = 60;
48
+ const COUNTRY_ROW_HEIGHT = 60;
49
+ const ROW_LINE = "inset 0px -1px 0px rgba(0, 0, 0, 0.05)";
50
+
51
+ const COUNTRIES = [
52
+ { value: "US", label: "United States", code: "+1" },
53
+ { value: "CA", label: "Canada", code: "+1" },
54
+ { value: "GB", label: "United Kingdom", code: "+44" },
55
+ { value: "DE", label: "Germany", code: "+49" },
56
+ { value: "FR", label: "France", code: "+33" },
57
+ { value: "TR", label: "Türkiye", code: "+90", searchText: "Turkey Turkiye" },
58
+ { value: "RU", label: "Russia", code: "+7" },
59
+ { value: "IT", label: "Italy", code: "+39" },
60
+ { value: "VA", label: "Vatican City", code: "+39", disabled: 1 },
61
+ { value: "ES", label: "Spain", code: "+34" },
62
+ { value: "BR", label: "Brazil", code: "+55" },
63
+ { value: "IN", label: "India", code: "+91" },
64
+ { value: "CN", label: "China", code: "+86" },
65
+ { value: "JP", label: "Japan", code: "+81" },
66
+ { value: "DZ", label: "Algeria", code: "+213" },
67
+ { value: "NG", label: "Nigeria", code: "+234" },
68
+ ];
69
+
70
+ const FRUITS = [
71
+ { value: "Broccoli", label: "Broccoli", description: "Vegetable", iconFile: FRUITS_PATH + "brokoli.png" },
72
+ { value: "Strawberry", label: "Strawberry", description: "Fruit", iconFile: FRUITS_PATH + "cilek.png" },
73
+ { value: "Tomato", label: "Tomato", description: "Vegetable", iconFile: FRUITS_PATH + "domates.png" },
74
+ { value: "Apple", label: "Apple", description: "Fruit", iconFile: FRUITS_PATH + "elma.png" },
75
+ { value: "Carrot", label: "Carrot", description: "Vegetable", iconFile: FRUITS_PATH + "havuc.png", disabled: 1 },
76
+ { value: "Watermelon", label: "Watermelon", description: "Fruit", iconFile: FRUITS_PATH + "karpuz.png" },
77
+ { value: "Lemon", label: "Lemon", description: "Fruit", iconFile: FRUITS_PATH + "limon.png" },
78
+ { value: "Banana", label: "Banana", description: "Fruit", iconFile: FRUITS_PATH + "muz.png" },
79
+ { value: "Pomegranate", label: "Pomegranate", description: "Fruit", iconFile: FRUITS_PATH + "nar.png" },
80
+ { value: "Eggplant", label: "Eggplant", description: "Vegetable", iconFile: FRUITS_PATH + "patlican.png" },
81
+ ];
82
+
83
+ let countrySelect = null;
84
+ let fruitsSelect = null;
85
+ let lightSelect = null;
86
+ let darkSelect = null;
87
+ let changeLabel = null;
88
+ let changeCount = 0;
89
+
90
+ // *** START:
91
+ const start = function () {
92
+
93
+ page.color = "white";
94
+
95
+ // WHY 16 px at the sides: a column of 350 px fits a phone of 390 px
96
+ ScrollArea({ align: "center top", gap: 24, padding: [16, 30] });
97
+
98
+ Label({ text: "SelectBox: createItemView / createValueView", fontSize: 22 });
99
+ changeLabel = Label({ plainText: "onChange: -", fontSize: 14, textColor: Black(0.6) });
100
+
101
+ HGroup({ hug: 1, align: "left top", gap: 40, wrap: 1, clipContent: 0 });
102
+
103
+ startColumn("1. Countries (single, ozden)");
104
+
105
+ countrySelect = SelectBox({
106
+ styleName: "ozden",
107
+ width: "100%",
108
+ height: COUNTRY_FIELD_HEIGHT,
109
+ options: COUNTRIES,
110
+ value: "US",
111
+ searchPlaceholder: "Search a country or a code",
112
+ style: { itemList: { row: { gap: 12 } } },
113
+ createItemView: createCountryRow,
114
+ createValueView: createCountryValue,
115
+ onChange: logChange,
116
+ });
117
+
118
+ startButtonRow();
119
+
120
+ SmartButton({
121
+ labelText: "setValue(\"DE\")",
122
+ style: { label: { fontSize: 14 } },
123
+ onClick: function () { countrySelect.setValue("DE"); },
124
+ });
125
+
126
+ // 1: silent, onChange is not called
127
+ SmartButton({
128
+ labelText: "setValue(\"TR\", silent)",
129
+ style: { label: { fontSize: 14 } },
130
+ onClick: function () { countrySelect.setValue("TR", 1); },
131
+ });
132
+
133
+ SmartButton({
134
+ labelText: "clear()",
135
+ style: { label: { fontSize: 14 } },
136
+ onClick: function () { countrySelect.clear(); },
137
+ });
138
+
139
+ SmartButton({
140
+ labelText: "setOptions(5)",
141
+ style: { label: { fontSize: 14 } },
142
+ onClick: function () { countrySelect.setOptions(COUNTRIES.slice(0, 5)); },
143
+ });
144
+
145
+ SmartButton({
146
+ labelText: "setOptions(all)",
147
+ style: { label: { fontSize: 14 } },
148
+ onClick: function () { countrySelect.setOptions(COUNTRIES); },
149
+ });
150
+
151
+ SmartButton({
152
+ labelText: "setEnabled(on / off)",
153
+ style: { label: { fontSize: 14 } },
154
+ onClick: function () { countrySelect.setEnabled(!countrySelect.enabled); },
155
+ });
156
+
157
+ endButtonRow();
158
+
159
+ endColumn();
160
+
161
+ startColumn("2. Fruits (multiple, ozden)");
162
+
163
+ fruitsSelect = SelectBox({
164
+ styleName: "ozden",
165
+ width: "100%",
166
+ multiple: 1,
167
+ options: FRUITS,
168
+ value: ["Apple", "Lemon"],
169
+ placeholder: "Select fruits",
170
+ createItemView: createFruitRow,
171
+ onChange: logChange,
172
+ });
173
+
174
+ startButtonRow();
175
+
176
+ SmartButton({
177
+ labelText: "setValue([Tomato, Banana])",
178
+ style: { label: { fontSize: 14 } },
179
+ onClick: function () { fruitsSelect.setValue(["Tomato", "Banana"]); },
180
+ });
181
+
182
+ SmartButton({
183
+ labelText: "clear()",
184
+ style: { label: { fontSize: 14 } },
185
+ onClick: function () { fruitsSelect.clear(); },
186
+ });
187
+
188
+ endButtonRow();
189
+
190
+ endColumn();
191
+
192
+ startColumn("3. Fruits (single, light)");
193
+
194
+ lightSelect = SelectBox({
195
+ width: 300,
196
+ options: FRUITS,
197
+ value: "Tomato",
198
+ searchable: 1,
199
+ createItemView: createFruitRow,
200
+ createValueView: createFruitValue,
201
+ onChange: logChange,
202
+ });
203
+
204
+ startButtonRow();
205
+
206
+ SmartButton({
207
+ labelText: "setValue(\"Banana\")",
208
+ style: { label: { fontSize: 14 } },
209
+ onClick: function () { lightSelect.setValue("Banana"); },
210
+ });
211
+
212
+ endButtonRow();
213
+
214
+ endColumn();
215
+
216
+ startColumn("4. Fruits (single, dark)");
217
+
218
+ darkSelect = SelectBox({
219
+ styleName: "dark",
220
+ width: 300,
221
+ options: FRUITS,
222
+ value: "Lemon",
223
+ createItemView: createDarkFruitRow,
224
+ onChange: logChange,
225
+ });
226
+
227
+ endColumn();
228
+
229
+ endGroup();
230
+
231
+ endGroup();
232
+
233
+ };
234
+
235
+ // *** FUNCTIONS:
236
+
237
+ // A column: its title, then the select and its buttons. Close it with endColumn().
238
+ const startColumn = function (titleText) {
239
+ VGroup({ width: COLUMN_WIDTH, height: "auto", align: "left top", gap: 12, clipContent: 0, css: { maxWidth: "100%" } });
240
+ Label({ plainText: titleText, fontSize: 16, textColor: "#555555" });
241
+ };
242
+
243
+ const endColumn = function () {
244
+ endGroup();
245
+ };
246
+
247
+ // The buttons under a select, side by side
248
+ const startButtonRow = function () {
249
+ HGroup({ width: "100%", height: "auto", align: "left top", gap: 8, wrap: 1, clipContent: 0 });
250
+ };
251
+
252
+ const endButtonRow = function () {
253
+ endGroup();
254
+ };
255
+
256
+ const logChange = function (self) {
257
+ changeCount++;
258
+ changeLabel.plainText = "onChange: " + JSON.stringify(self.value) + " (" + changeCount + " calls)";
259
+ };
260
+
261
+ // The dial code in a gray round pill
262
+ const createCodePill = function (code) {
263
+ return Label({ plainText: code, fontSize: 16, padding: [6, 2], color: "rgba(0, 0, 0, 0.05)", textColor: "#373836", round: 8 });
264
+ };
265
+
266
+ const createCountryRow = function (option, row) {
267
+ row.height = COUNTRY_ROW_HEIGHT;
268
+ row.boxShadow = ROW_LINE;
269
+ createCodePill(option.code);
270
+ Label({ plainText: option.label, fontSize: 20 });
271
+ };
272
+
273
+ const createCountryValue = function (option) {
274
+ createCodePill(option.code);
275
+ Label({ plainText: option.label, fontSize: 20 });
276
+ that.ellipsis = 1;
277
+ };
278
+
279
+ const createFruitRow = function (option, row) {
280
+ Icon({ width: 36, height: 36, round: 4 });
281
+ that.load(option.iconFile);
282
+ Label({ plainText: option.label, fontSize: 18 });
283
+ that.grow = 1;
284
+ Label({ plainText: option.description, fontSize: 12, padding: [8, 2], round: 10, color: Black(0.06), textColor: Black(0.6) });
285
+ };
286
+
287
+ const createFruitValue = function (option) {
288
+ Icon({ width: 24, height: 24, round: 4 });
289
+ that.load(option.iconFile);
290
+ Label({ plainText: option.label, fontSize: 16 });
291
+ };
292
+
293
+ const createDarkFruitRow = function (option) {
294
+ Icon({ width: 28, height: 28, round: 4 });
295
+ that.load(option.iconFile);
296
+ Label({ plainText: option.label, fontSize: 15, textColor: White(0.9) });
297
+ };
298
+
299
+ </script>
300
+
301
+ </head>
302
+ <body>
303
+ </body>
304
+ </html>
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <base href="../../"><!-- This page uses the paths of a page at the root of the project. -->
5
5
 
6
- <title>Slider JS Component</title>
6
+ <title>Slider - split</title>
7
7
 
8
8
  <meta charset="UTF-8">
9
9
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -19,7 +19,8 @@
19
19
 
20
20
  <script>
21
21
 
22
- // Slider (comp/slider.js) in its classic look (inspired by Material 3): two sliders, one with its own track. New pages use "round": slider.htm.
22
+ // Slider (comp/slider.js) in its split look (inspired by Material 3): two sliders, one with its own track, and
23
+ // "splitDark" on a dark band. New pages use "round": slider.htm.
23
24
 
24
25
  const start = function () {
25
26
 
@@ -55,6 +56,37 @@
55
56
  value: random(0,100),
56
57
  });
57
58
 
59
+ // SPACING
60
+ Box({
61
+ height: 20,
62
+ color: "transparent",
63
+ });
64
+
65
+ // GROUP: A dark band
66
+ VGroup({
67
+ width: "auto",
68
+ height: "auto",
69
+ align: "left top",
70
+ gap: 8,
71
+ padding: [16, 14],
72
+ color: "#232322",
73
+ round: 12,
74
+ });
75
+
76
+ Label({
77
+ text: "styleName: \"splitDark\" (a dark page)",
78
+ fontSize: 14,
79
+ textColor: White(0.75),
80
+ });
81
+
82
+ // SLIDER: C
83
+ const sliderC = Slider({
84
+ styleName: "splitDark",
85
+ value: random(0,100),
86
+ });
87
+
88
+ endGroup();
89
+
58
90
  endGroup();
59
91
 
60
92
  // GROUP: Top left buttons
@@ -67,11 +99,13 @@
67
99
  createPageButton("Set Random Values", function () {
68
100
  sliderA.setValue(random(0,100));
69
101
  sliderB.setValue(random(0,100));
102
+ sliderC.setValue(random(0,100));
70
103
  });
71
104
 
72
105
  createPageButton("Show Values", function () {
73
106
  sliderA.showValue();
74
107
  sliderB.showValue();
108
+ sliderC.showValue();
75
109
  });
76
110
 
77
111
  endGroup();
@@ -3,7 +3,7 @@
3
3
 
4
4
  <head>
5
5
  <base href="../../"><!-- This page uses the paths of a page at the root of the project. -->
6
- <title>Stepper: ozden and the button line</title>
6
+ <title>Stepper: ozden, ozdenDark and the button line</title>
7
7
  <meta charset="UTF-8">
8
8
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
9
9
 
@@ -21,7 +21,7 @@
21
21
 
22
22
  /* Bismillah */
23
23
 
24
- // The "ozden" package of Stepper and
24
+ // The "ozden" package of Stepper, its dark twin "ozdenDark" and
25
25
  // style.button.border / borderColor (a line around the buttons) on the other packages.
26
26
 
27
27
  // *** VARIABLES:
@@ -80,9 +80,25 @@
80
80
 
81
81
  endCard();
82
82
 
83
- // SAMPLE 3: The line around the buttons
83
+ // SAMPLE 3: ozdenDark
84
84
  startCard(
85
- "3. style.button.border and borderColor",
85
+ "3. styleName: \"ozdenDark\"",
86
+ "ozden on a dark page: the same shape, the buttons in the ground of a dark card with a light line."
87
+ );
88
+
89
+ // GROUP: Dark background
90
+ HGroup({ width: "100%", height: "auto", align: "left center", gap: 16, wrap: 1, padding: 16, color: "#232322", round: 10 });
91
+
92
+ Stepper({ styleName: "ozdenDark", value: 1, minValue: 1, maxValue: 10 });
93
+ Stepper({ styleName: "ozdenDark", value: 5, minValue: 1, maxValue: 10 });
94
+
95
+ endGroup();
96
+
97
+ endCard();
98
+
99
+ // SAMPLE 4: The line around the buttons
100
+ startCard(
101
+ "4. style.button.border and borderColor",
86
102
  "A line around the buttons, on any package. (0 and \"transparent\" by default: no line)"
87
103
  );
88
104
 
@@ -112,8 +128,8 @@
112
128
 
113
129
  endCard();
114
130
 
115
- // SAMPLE 4: classic, to compare
116
- startCard("4. classic (the default), to compare", "No line around the buttons, no fade.");
131
+ // SAMPLE 5: classic, to compare
132
+ startCard("5. classic (the default), to compare", "No line around the buttons, no fade.");
117
133
 
118
134
  HGroup({ width: "100%", height: "auto", align: "left center", gap: 16, wrap: 1 });
119
135
  Stepper({ value: 1, minValue: 1, maxValue: 10 });
@@ -1,2 +1,2 @@
1
1
  /* Bismillah */
2
- "use strict";const BottomBarDefaults={selectedIndex:0,left:0,width:"100%",height:100,items:[],onItemClick:function(e,t,o){},hoverEffect:!0,labelMode:"inline",allowHtml:0,floatLabelTime:600,badge:{showZero:0,dotForOne:1,maxValue:99,dotSize:12,style:{color:"#FE5D49"},numberStyle:{}},style:{container:{color:"transparent",gradient:"linear-gradient(to bottom, transparent, whitesmoke)",border:0},background:{gradient:"linear-gradient(to right, #FFC8C1, #A5E5EB)",border:0,round:100},layout:{barHeight:76,iconBoxSize:40,padding:40,itemSpacing:20,iconGap:6,selectionPadding:14,labelEndSpace:6},icon:{width:40,height:40},label:{textColor:"#FE5D49"},selectedBox:{color:"#EAEAE9",round:100,border:1,borderColor:"#FFFFFF",height:56},floatLabel:{fontSize:14,textColor:Black(.8),color:White(.8),border:1,borderColor:Black(.6),round:6,padding:[8,3],space:20},focus:{ringColor:"rgba(95, 158, 160, 0.8)"}}},BottomBar=function(e={}){mergeIntoIfMissing(e,BottomBarDefaults);const t=startObject(e);t.color=t.style.container.color,t.border=t.style.container.border,t.css.background=t.style.container.gradient;const o=t.clipContent;let n=1,i=0,l=null;t.itemObjList=[];const c=function(e,o){const n=null==o?"":String(o);1==t.allowHtml?e.text=n:e.plainText=n},a=function(){return"float"===t.labelMode},r=function(){return"float"!==t.labelMode&&"none"!==t.labelMode},s=function(e,t){return e.text||"Tab "+(t+1)},d=function(e,o){return o&&r()?e.icon.width+t.style.layout.iconGap+e.label.width+function(e){return(e.icon.width-t.style.icon.width)/2+t.style.layout.labelEndSpace}(e):e.icon.width},u=function(e){const o=t.style.layout;t.selectedBox.opacity=1,t.selectedBox.left=e.icon.left-o.selectionPadding,t.selectedBox.width=d(e,!0)+2*o.selectionPadding,function(e){t.itemObjList.some(e=>e.data.color)&&(t.selectedBox.color=e.data.color||t.style.selectedBox.color)}(e)},f=function(){const e={...t.style.floatLabel};return delete e.space,e},b=function(){const e=Label({...f(),opacity:0});return e.css={whiteSpace:"nowrap"},e.aria={hidden:!0},e.setMotion("left 0.3s, opacity 0.3s"),e.onResize(h),e},h=function(){if(!t.lblFloat)return;const e=t.innerBox.border||0,o=t.innerBox.left+e+t.selectedBox.left+t.selectedBox.width/2,n=t.innerBox.top+e+t.selectedBox.top;i||t.lblFloat.dontMotion(),i=1,t.lblFloat.left=Math.round(o-t.lblFloat.width/2),t.lblFloat.top=Math.round(n-t.style.floatLabel.space-t.lblFloat.height)},y=function(){l&&l(),l=null,t.lblFloat.opacity=0},p=function(){if(!t.lblFloat)return;const e=t.itemObjList[t.selectedIndex];var o;if(a()&&e)return n?(n=0,o=e,y(),void(o.data.text&&(c(t.lblFloat,o.data.text),h(),t.lblFloat.opacity=1,l=t.after(t.floatLabelTime,y)))):void h();y()},x=function(){if(a())return t.clipContent=0,void(t.lblFloat||(t.lblFloat=createIn(t,b)));t.lblFloat&&(t.clipContent=o)},g=function(e,o){t.selectedIndex=o,n=1,t.onItemClick(t,e,o),t.refresh()},B=function(e,o,n){const i=t.style.layout.iconBoxSize;e.icon=startBox({width:i,height:i,color:"transparent",position:"absolute",clipContent:0}),t.innerBox.add(e.icon),e.icon.center("top"),e.icon.setMotion("left 0.3s, opacity 0.3s"),e.icon.cursor="pointer",e.icon.on("click",function(){g(e,n)}),function(e,o,n){const i=e.icon;i.role="button",i.aria={label:s(o,n)},i.tabIndex=0,i.setFocusRing(t.style.focus.ringColor),i.on("keydown",function(o,i){"Enter"!==i.key&&" "!==i.key||(i.preventDefault(),t.selectedIndex!=n&&g(e,n))})}(e,o,n),e.icon.i1=Icon(0,0,{width:t.style.icon.width,height:t.style.icon.height,position:"absolute"}),e.icon.i1.center(),e.icon.i1.load(o.iconFile),e.icon.i1.setMotion("opacity 0.3s"),e.icon.i2=Icon(0,0,{width:t.style.icon.width,height:t.style.icon.height,position:"absolute",opacity:0}),e.icon.i2.center(),e.icon.i2.load(function(e){return e.selectedIconFile||e.iconFile}(o)),e.icon.i2.setMotion("opacity 0.3s"),t.hoverEffect&&(e.icon.on("mouseover",function(){e.icon.i2.opacity=.5}),e.icon.on("mouseout",function(){t.selectedIndex!=n&&(e.icon.i2.opacity=0)})),e.badge=function(){const{style:e,numberStyle:o,...n}=t.badge;return Badge({...n,value:"",badgeStyle:{...e},numberStyle:{...o}})}(),endBox()},m=function(e,o){const n={};B(n,e,o),function(e,o){e.label=Label({left:12,width:"auto",height:"auto",color:"transparent",textColor:t.style.label.textColor,position:"absolute",opacity:0}),c(e.label,o.text),e.label.css={whiteSpace:"nowrap"},t.innerBox.add(e.label),e.label.center("top"),e.label.top-=2,e.label.setMotion("left 0.3s, opacity 0.3s"),e.label.aria={hidden:!0},e.label.onResize(t.refreshOneTime)}(n,e),n.index=o,n.data=e,t.itemObjList.push(n),t.refreshOneTime()};return t.refreshOneTime=function(){t.refreshTimeout&&t.refreshTimeout(),t.refreshTimeout=t.after(3,function(){t.refresh()})},t.setBadge=function(e,o){t.itemObjList[e].badge.setValue(o)},t.selectNone=function(){t.selectedIndex=-1,t.refreshOneTime()},t.selectByIndex=function(e){t.selectedIndex=e,n=1,t.refreshOneTime()},t.setLabelMode=function(e){t.labelMode=e,x(),t.refreshOneTime()},t.refresh=function(){const e=t.style.layout,o=function(){const e=t.style.layout,o=t.itemObjList.reduce(function(e,o,n){return e+d(o,n==t.selectedIndex)},0),n=e.itemSpacing*(t.itemObjList.length-1),i=t.width-o-n-2*e.padding;return!t.width||i>=0?e.padding:Math.max(e.selectionPadding,e.padding+i/2)}();let n=o;-1==t.selectedIndex&&(t.selectedBox.opacity=0),t.itemObjList.forEach((o,i)=>{const l=i==t.selectedIndex;o.icon.left=n,o.label.left=function(e,o){return o&&r()?e.icon.left+e.icon.width+t.style.layout.iconGap:e.icon.left}(o,l),function(e,t){e.label.opacity=t&&r()?1:0,e.icon.i1.opacity=t?0:1,e.icon.i2.opacity=t?1:0,e.icon.clickable=t?0:1,e.icon.aria={pressed:t}}(o,l),l&&u(o),n+=d(o,l)+e.itemSpacing}),n+=o-e.itemSpacing,t.innerBox.width=n,t.innerBox.center(),p()},t.innerBox=startBox({round:t.style.background.round,width:350,height:t.style.layout.barHeight,border:t.style.background.border}),t.innerBox.css.background=t.style.background.gradient,t.innerBox.setMotion("width 0.3s, left 0.3s"),t.selectedBox=Box(0,0,142,t.style.selectedBox.height,t.style.selectedBox),t.selectedBox.opacity=0,t.selectedBox.setMotion("left 0.3s, width 0.3s, opacity 0.3s, background-color 0.3s"),t.selectedBox.center("top"),endBox(),x(),t.items.forEach((e,t)=>{m(e,t)}),t.onResize(function(){t.innerBox.dontMotion(),t.innerBox.center(),t.refreshOneTime(),t.lblFloat&&(t.lblFloat.dontMotion(),h())}),endObject(t)};
2
+ "use strict";const BottomBarDefaults={selectedIndex:0,left:0,width:"100%",height:100,items:[],onItemClick:function(e,t,o){},hoverEffect:!0,labelMode:"inline",allowHtml:0,floatLabelTime:600,badge:{showZero:0,dotForOne:1,maxValue:99,dotSize:12,style:{color:"#FE5D49"},numberStyle:{}},style:{container:{color:"transparent",gradient:"linear-gradient(to bottom, transparent, whitesmoke)",border:0},background:{gradient:"linear-gradient(to right, #FFC8C1, #A5E5EB)",border:0,round:100},layout:{barHeight:76,iconBoxSize:40,padding:40,itemSpacing:20,iconGap:6,selectionPadding:14,labelEndSpace:6},icon:{width:40,height:40},label:{textColor:"#FE5D49"},selectedBox:{color:"#EAEAE9",round:100,border:1,borderColor:"#FFFFFF",height:56},floatLabel:{fontSize:14,textColor:Black(.8),color:White(.8),border:1,borderColor:Black(.6),round:6,padding:[8,3],space:20},focus:{ringColor:"rgba(95, 158, 160, 0.8)"}}},BottomBar=function(e={}){mergeIntoIfMissing(e,BottomBarDefaults);const t=startObject(e);t.color=t.style.container.color,t.border=t.style.container.border,t.css.background=t.style.container.gradient;const o=t.clipContent;let n=1,i=0,l=null,c=1,a=0;t.itemObjList=[];const r=function(e,o){const n=null==o?"":String(o);1==t.allowHtml?e.text=n:e.plainText=n},s=function(){return"float"===t.labelMode},d=function(){return"float"!==t.labelMode&&"none"!==t.labelMode},u=function(e,t){return e.text||"Tab "+(t+1)},f=function(e,o){return o&&d()?e.icon.width+t.style.layout.iconGap+e.label.width+function(e){return(e.icon.width-t.style.icon.width)/2+t.style.layout.labelEndSpace}(e):e.icon.width},b=function(e){const o=t.style.layout;t.selectedBox.opacity=1,t.selectedBox.left=e.icon.left-o.selectionPadding,t.selectedBox.width=f(e,!0)+2*o.selectionPadding,function(e){t.itemObjList.some(e=>e.data.color)&&(t.selectedBox.color=e.data.color||t.style.selectedBox.color)}(e)},h=function(){const e={...t.style.floatLabel};return delete e.space,e},y=function(){const e=Label({...h(),opacity:0});return e.css={whiteSpace:"nowrap"},e.aria={hidden:!0},e.setMotion("left 0.3s, opacity 0.3s"),e.onResize(p),e},p=function(){if(!t.lblFloat)return;const e=t.innerBox.border||0,o=t.innerBox.left+e+t.selectedBox.left+t.selectedBox.width/2,n=t.innerBox.top+e+t.selectedBox.top;i||t.lblFloat.dontMotion(),i=1,t.lblFloat.left=Math.round(o-t.lblFloat.width/2),t.lblFloat.top=Math.round(n-t.style.floatLabel.space-t.lblFloat.height)},x=function(){l&&l(),l=null,t.lblFloat.opacity=0},g=function(){if(!t.lblFloat)return;const e=t.itemObjList[t.selectedIndex];var o;if(s()&&e)return n?(n=0,o=e,x(),void(o.data.text&&(r(t.lblFloat,o.data.text),p(),t.lblFloat.opacity=1,l=t.after(t.floatLabelTime,x)))):void p();x()},B=function(){if(s())return t.clipContent=0,void(t.lblFloat||(t.lblFloat=createIn(t,y)));t.lblFloat&&(t.clipContent=o)},m=function(){a&&(c=0)},w=function(e,o){m(),t.selectedIndex=o,n=1,t.onItemClick(t,e,o),t.refresh()},F=function(e,o,n){const i=t.style.layout.iconBoxSize;e.icon=startBox({width:i,height:i,color:"transparent",position:"absolute",clipContent:0}),t.innerBox.add(e.icon),e.icon.center("top"),e.icon.setMotion("left 0.3s, opacity 0.3s"),e.icon.cursor="pointer",e.icon.on("click",function(){w(e,n)}),function(e,o,n){const i=e.icon;i.role="button",i.aria={label:u(o,n)},i.tabIndex=0,i.setFocusRing(t.style.focus.ringColor),i.on("keydown",function(o,i){"Enter"!==i.key&&" "!==i.key||(i.preventDefault(),t.selectedIndex!=n&&w(e,n))})}(e,o,n),e.icon.i1=Icon(0,0,{width:t.style.icon.width,height:t.style.icon.height,position:"absolute"}),e.icon.i1.center(),e.icon.i1.load(o.iconFile),e.icon.i1.setMotion("opacity 0.3s"),e.icon.i2=Icon(0,0,{width:t.style.icon.width,height:t.style.icon.height,position:"absolute",opacity:0}),e.icon.i2.center(),e.icon.i2.load(function(e){return e.selectedIconFile||e.iconFile}(o)),e.icon.i2.setMotion("opacity 0.3s"),t.hoverEffect&&(e.icon.on("mouseover",function(){e.icon.i2.opacity=.5}),e.icon.on("mouseout",function(){t.selectedIndex!=n&&(e.icon.i2.opacity=0)})),e.badge=function(){const{style:e,numberStyle:o,...n}=t.badge;return Badge({...n,value:"",badgeStyle:{...e},numberStyle:{...o}})}(),endBox()},M=function(e,o){const n={};F(n,e,o),function(e,o){e.label=Label({left:12,width:"auto",height:"auto",color:"transparent",textColor:t.style.label.textColor,position:"absolute",opacity:0}),r(e.label,o.text),e.label.css={whiteSpace:"nowrap"},t.innerBox.add(e.label),e.label.setMotion("left 0.3s, opacity 0.3s"),e.label.aria={hidden:!0},e.label.onResize(t.refreshOneTime)}(n,e),n.index=o,n.data=e,t.itemObjList.push(n),t.refreshOneTime()};return t.refreshOneTime=function(){t.refreshTimeout&&t.refreshTimeout(),t.refreshTimeout=t.after(3,function(){t.refresh()})},t.setBadge=function(e,o){t.itemObjList[e].badge.setValue(o)},t.selectNone=function(){m(),t.selectedIndex=-1,t.refreshOneTime()},t.selectByIndex=function(e){m(),t.selectedIndex=e,n=1,t.refreshOneTime()},t.setLabelMode=function(e){m(),t.labelMode=e,B(),t.refreshOneTime()},t.refresh=function(){const e=t.style.layout,o=function(){const e=t.style.layout,o=t.itemObjList.reduce(function(e,o,n){return e+f(o,n==t.selectedIndex)},0),n=e.itemSpacing*(t.itemObjList.length-1),i=t.width-o-n-2*e.padding;return!t.width||i>=0?e.padding:Math.max(e.selectionPadding,e.padding+i/2)}();let n=o;c&&(t.innerBox.dontMotion(),t.selectedBox.dontMotion(),t.itemObjList.forEach(function(e){e.icon.dontMotion(),e.icon.i1.dontMotion(),e.icon.i2.dontMotion(),e.label.dontMotion()}),t.lblFloat&&t.lblFloat.dontMotion()),-1==t.selectedIndex&&(t.selectedBox.opacity=0),t.itemObjList.forEach((o,i)=>{const l=i==t.selectedIndex;o.icon.left=n,o.label.left=function(e,o){return o&&d()?e.icon.left+e.icon.width+t.style.layout.iconGap:e.icon.left}(o,l),o.label.center("top"),function(e,t){e.label.opacity=t&&d()?1:0,e.icon.i1.opacity=t?0:1,e.icon.i2.opacity=t?1:0,e.icon.clickable=t?0:1,e.icon.aria={pressed:t}}(o,l),l&&b(o),n+=f(o,l)+e.itemSpacing}),n+=o-e.itemSpacing,t.innerBox.width=n,t.innerBox.center(),g(),c&&t.innerBox.elem.offsetHeight,a=1},t.innerBox=startBox({round:t.style.background.round,width:350,height:t.style.layout.barHeight,border:t.style.background.border}),t.innerBox.css.background=t.style.background.gradient,t.innerBox.setMotion("width 0.3s, left 0.3s"),t.selectedBox=Box(0,0,142,t.style.selectedBox.height,t.style.selectedBox),t.selectedBox.opacity=0,t.selectedBox.setMotion("left 0.3s, width 0.3s, opacity 0.3s, background-color 0.3s"),t.selectedBox.center("top"),endBox(),B(),t.items.forEach((e,t)=>{M(e,t)}),t.onResize(function(){t.innerBox.dontMotion(),t.innerBox.center(),t.refreshOneTime(),t.lblFloat&&(t.lblFloat.dontMotion(),p())}),endObject(t)};
@@ -1,2 +1,2 @@
1
1
  /* Bismillah */
2
- "use strict";const CodeEditorDefaults={key:"0",left:0,top:0,width:"100%",height:320,value:"",language:"text",tabSize:4,readOnly:0,showLineNumbers:1,placeholder:"",changeDelay:0,ariaLabel:"Code",onChange:function(e){},onCursorChange:function(e){},styleName:"light",style:{box:{color:"white",border:1,borderColor:Black(.14),round:8},text:{fontSize:13,lineHeight:20,fontFamily:'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',color:"#2B2B2A",caretColor:"#111111",paddingX:10,paddingY:8},gutter:{color:"#F6F6F4",lineColor:Black(.08),textColor:Black(.38),activeTextColor:Black(.8),space:1},activeLine:{color:"rgba(91, 186, 193, 0.1)"},selection:{color:"rgba(91, 186, 193, 0.35)"},placeholder:{color:Black(.4)},scrollBar:{color:Black(.22),hoverColor:Black(.4),size:10},kinds:{keyword:"#8A2F8E",string:"#1F7A3D",number:"#A85A00",comment:"#7A7F87",builtin:"#00717A",function:"#2467B8",property:"#2467B8",tag:"#A32A4B",attribute:"#A85A00",variable:"#00717A"}}},CodeEditor=function(e={}){const t=e.style;basic.applyStylePackage(e,CodeEditor.styles,CodeEditorDefaults),mergeIntoIfMissing(e,CodeEditorDefaults);const n=startObject(e);let o=n.style;const r=2e3;let i=[""],l=[null],a=1,s=-1,c=-1,d=null,u=0;n.cursorLine=1,n.cursorColumn=1;const f=function(){return CodeEditor.languages[n.language]||CodeEditor.languages.text},g=function(){return n.textareaElem},p=function(e){const t=i[e],n=t.slice(0,r);return CodeEditor.tokenizeLine(n,l[e],f()).parts.map(CodeEditor.partHtml).join("")+basic.escapeHtml(t.slice(r))},h=function(){return o.text.lineHeight},m=function(e){const t=g(),n=Math.floor(t.scrollTop/h()),o=Math.ceil(t.clientHeight/h())+1,d=Math.min(i.length-1,n+o);!e&&(n>=s&&d<=c)||(s=Math.max(0,n-25),c=Math.min(i.length-1,d+25),function(e){const t=f();for(let n=a;n<=e&&n<i.length;n++){const e=i[n-1].slice(0,r);l[n]=CodeEditor.tokenizeLine(e,l[n-1],t).state,a=n+1}}(c),b(),x()),y()},b=function(){const e=[];for(let t=s;t<=c;t++)e.push(p(t));n.codeLayer.text=e.join("\n")},x=function(){const e=[];for(let t=s;t<=c;t++){const o=t+1===n.cursorLine;e.push(o?'<span class="code-editor-active-number">'+(t+1)+"</span>":String(t+1))}n.gutterLayer.text=e.join("\n")},y=function(){const e=g(),t=o.text.paddingY+s*h()-e.scrollTop,r=o.text.paddingX-e.scrollLeft;n.codeLayer.css.transform="translate("+r+"px, "+t+"px)",n.gutterLayer.css.transform="translateY("+t+"px)",n.activeLine.top=o.text.paddingY+(n.cursorLine-1)*h()-e.scrollTop},C=function(){const e=Math.max(2,String(i.length).length)+2*o.gutter.space,t=1==n.showLineNumbers?"calc("+e+"ch + 1px)":"0px";n.gutter.visible=1==n.showLineNumbers?1:0,n.gutter.css.width=t,n.gutterLayer.css.right=o.gutter.space+"ch",n.codeArea.css.left=t,n.codeArea.css.width="calc(100% - "+t+")"},E=function(){const e=g().value,t=e.split("\n");let o=0;const r=Math.min(i.length,t.length);for(;o<r&&i[o]===t[o];)o++;i=t,l.length=Math.min(l.length,i.length),a=Math.min(a,o+1,i.length),n.value=e},v=function(){const e=g().selectionStart;let t=1,o=0,r=n.value.indexOf("\n");for(;r>=0&&r<e;)t++,o=r+1,r=n.value.indexOf("\n",o);const i=e-o+1,l=t===n.cursorLine&&i===n.cursorColumn,a=t!==n.cursorLine;n.cursorLine=t,n.cursorColumn=i,a&&x(),y(),l||n.onCursorChange(n)},k=function(){d&&d(),d=null,n.changeDelay<=0?n.onChange(n):d=n.after(n.changeDelay,function(){d=null,n.onChange(n)})},S=function(){E(),C(),m(1),v(),k()},w=function(e){const t=g();t.focus();(""===e?document.execCommand("delete"):document.execCommand("insertText",!1,e))||(t.setRangeText(e,t.selectionStart,t.selectionEnd,"end"),S())},L=function(){const e=g(),t=e.value,n=t.lastIndexOf("\n",e.selectionStart-1)+1,o=e.selectionEnd>e.selectionStart&&"\n"===t[e.selectionEnd-1]?e.selectionEnd-1:e.selectionEnd;let r=t.indexOf("\n",o);return r<0&&(r=t.length),{start:n,end:r}},z=function(e){const t=g(),n=L(),o=t.value.slice(n.start,n.end).split("\n").map(e).join("\n");t.setSelectionRange(n.start,n.end),w(o),t.setSelectionRange(n.start,n.start+o.length)},A=function(){return" ".repeat(n.tabSize)},O=function(){if(function(){const e=g();return e.value.slice(e.selectionStart,e.selectionEnd).includes("\n")}())return void z(function(e){return e.length>0?A()+e:e});const e=g(),t=e.value.lastIndexOf("\n",e.selectionStart-1)+1,o=e.selectionStart-t;w(" ".repeat(n.tabSize-o%n.tabSize))},B=function(e){const t="Tab"===e.key,o="/"===e.key&&(e.ctrlKey||e.metaKey);"Escape"===e.key?u=1:t||(u=0),t&&u?u=0:1!=n.readOnly&&(t?(e.preventDefault(),e.shiftKey?z(function(e){const t=e.match(/^ */)[0].length;return e.slice(Math.min(t,n.tabSize))}):O()):"Enter"!==e.key||e.isComposing?"Backspace"!==e.key||e.isComposing?o&&(e.preventDefault(),function(){const e=f().lineComment;if(!e)return;const t=g(),n=L(),o=t.value.slice(n.start,n.end).split("\n").every(function(t){return""===t.trim()||t.trimStart().startsWith(e)});z(function(t){return""===t.trim()?t:o?t.replace(new RegExp("^(\\s*)"+CodeEditor.escapeRegExp(e)+" ?"),"$1"):t.replace(/^(\s*)/,"$1"+e+" ")})}()):function(){const e=g();if(e.selectionStart!==e.selectionEnd)return 0;const t=e.value.lastIndexOf("\n",e.selectionStart-1)+1,o=e.value.slice(t,e.selectionStart);if(0===o.length||o.trim().length>0)return 0;const r=(o.length-1)%n.tabSize+1;return e.setSelectionRange(e.selectionStart-r,e.selectionStart),w(""),1}()&&e.preventDefault():(e.preventDefault(),function(){const e=g(),t=e.value.lastIndexOf("\n",e.selectionStart-1)+1,n=e.value.slice(t,e.selectionStart),o=n.match(/^[ \t]*/)[0],r=(f().indentAfter||"").includes(n.trimEnd().slice(-1)||" ");w("\n"+o+(r?A():""))}()))},D=function(){const e=o.text,t={fontFamily:e.fontFamily,fontSize:e.fontSize+"px",lineHeight:e.lineHeight+"px"};n.props(o.box),n.gutter.color=o.gutter.color,n.gutter.css={...t,borderRight:"1px solid "+o.gutter.lineColor},n.codeArea.css=t,n.gutterLayer.css={...t,color:o.gutter.textColor},n.codeLayer.css={...t,color:e.color,tabSize:n.tabSize},n.activeLine.color=o.activeLine.color,n.activeLine.height=e.lineHeight,Object.assign(g().style,t,{padding:e.paddingY+"px "+e.paddingX+"px",caretColor:e.caretColor,tabSize:n.tabSize});const r={"--code-editor-selection":o.selection.color,"--code-editor-placeholder":o.placeholder.color,"--code-editor-active-number":o.gutter.activeTextColor,"--code-editor-bar":o.scrollBar.color,"--code-editor-bar-hover":o.scrollBar.hoverColor,"--code-editor-bar-size":o.scrollBar.size+"px"};Object.keys(o.kinds).forEach(function(e){r["--code-editor-"+e]=o.kinds[e]}),Object.keys(r).forEach(function(e){n.elem.style.setProperty(e,r[e])}),C(),m(1)};return n.setValue=function(e,t=0){const o=null==e?"":String(e);o!==g().value&&(g().value=o,i=[""],l=[null],a=1,E(),g().scrollTop=0,g().scrollLeft=0,n.cursorLine=1,n.cursorColumn=1,C(),m(1),t||k())},n.getValue=function(){return g().value},n.insertText=function(e){w(String(e))},n.getSelectedText=function(){const e=g();return e.value.slice(e.selectionStart,e.selectionEnd)},n.setLanguage=function(e){n.language=e,a=1,m(1)},n.setReadOnly=function(e){n.readOnly=basic.isOn(e)?1:0,g().readOnly=1==n.readOnly},n.setShowLineNumbers=function(e){n.showLineNumbers=basic.isOn(e)?1:0,C()},n.setTabSize=function(e){n.tabSize=e,g().style.tabSize=e,n.codeLayer.css.tabSize=e},n.goToLine=function(e){const t=g(),n=basic.clamp(Math.round(e),1,i.length);let o=0;for(let e=0;e<n-1;e++)o+=i[e].length+1;t.focus({preventScroll:!0}),t.setSelectionRange(o,o);const r=(n-1)*h(),l=2*h();r-l>=t.scrollTop&&r+h()+l<=t.scrollTop+t.clientHeight||(t.scrollTop=Math.max(0,r-t.clientHeight/2)),m(0),v()},n.focusEditor=function(){g().focus({preventScroll:!0})},n.setTheme=function(e){n.styleName=e,o=function(e){const n={styleName:e,style:t};return basic.applyStylePackage(n,CodeEditor.styles,CodeEditorDefaults),mergeIntoIfMissing(n,CodeEditorDefaults),n.style}(e),n.style=o,D()},basic.addCss("code-editor",".code-editor-textarea { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 0; border: 0; outline: none; resize: none; box-sizing: border-box; background: transparent; color: transparent; -webkit-text-fill-color: transparent; white-space: pre; overflow: auto; pointer-events: auto; user-select: text; -webkit-user-select: text; font-variant-ligatures: none; }.code-editor-textarea::selection { background: var(--code-editor-selection); }.code-editor-textarea::placeholder { color: var(--code-editor-placeholder); -webkit-text-fill-color: var(--code-editor-placeholder); }.code-editor-textarea::-webkit-scrollbar { width: var(--code-editor-bar-size); height: var(--code-editor-bar-size); }.code-editor-textarea::-webkit-scrollbar-thumb { background: var(--code-editor-bar); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }.code-editor-textarea::-webkit-scrollbar-thumb:hover { background: var(--code-editor-bar-hover); border: 2px solid transparent; background-clip: padding-box; }.code-editor-textarea::-webkit-scrollbar-corner { background: transparent; }.code-editor-layer { white-space: pre; font-variant-ligatures: none; overflow: visible; width: max-content; }.code-editor-active-number { color: var(--code-editor-active-number); }"+CodeEditor.KIND_NAMES.map(function(e){return".code-editor-"+e+" { color: var(--code-editor-"+e+"); }"}).join("")),n.gutter=startBox({left:0,top:0,height:"100%",css:{boxSizing:"border-box"}}),n.gutterLayer=Label({top:0,textAlign:"right"}),n.gutterLayer.elem.classList.add("code-editor-layer"),n.gutterLayer.css.left="auto",n.gutterLayer.aria={hidden:"true"},endBox(),n.codeArea=startBox({top:0,height:"100%",color:"transparent"}),n.activeLine=Box({left:0,width:"100%"}),n.codeLayer=Label({left:0,top:0}),n.codeLayer.elem.classList.add("code-editor-layer"),n.codeLayer.aria={hidden:"true"},endBox(),n.textareaElem=document.createElement("textarea"),n.textareaElem.classList.add("code-editor-textarea"),n.textareaElem.wrap="off",n.textareaElem.spellcheck=!1,n.textareaElem.setAttribute("autocomplete","off"),n.textareaElem.setAttribute("autocorrect","off"),n.textareaElem.setAttribute("autocapitalize","off"),n.textareaElem.setAttribute("aria-label",n.ariaLabel),n.textareaElem.placeholder=n.placeholder,n.textareaElem.readOnly=1==n.readOnly,n.textareaElem.value=null===n.value||void 0===n.value?"":String(n.value),n.codeArea.elem.appendChild(n.textareaElem),n.listenTo(g(),"input",S),n.listenTo(g(),"scroll",function(){m(0)}),n.listenTo(g(),"keydown",function(e,t){B(t)}),n.listenTo(g(),"keyup",v),n.listenTo(g(),"mouseup",v),n.listenTo(g(),"focus",v),n.listenTo(document,"selectionchange",function(){document.activeElement===g()&&v()}),n.onResize(function(){m(0)}),E(),D(),endObject(n)};CodeEditor.KIND_NAMES=["keyword","string","number","comment","builtin","function","property","tag","attribute","variable"],CodeEditor.escapeRegExp=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},CodeEditor.partHtml=function(e){const t=basic.escapeHtml(e[1]);return e[0]?'<span class="code-editor-'+e[0]+'">'+t+"</span>":t},CodeEditor.NUMBER=/^(0[xX][0-9a-fA-F_]+|0[bB][01_]+|\d[\d_]*(\.\d*)?([eE][+-]?\d+)?|\.\d+([eE][+-]?\d+)?)/,CodeEditor.WORD=/^[\p{L}_][\p{L}\p{N}_]*/u,CodeEditor.WORD_LETTER=/[\p{L}\p{N}_]/u,CodeEditor.findStringEnd=function(e,t,n){let o=t;for(;o<e.length;)if("\\"===e[o])o+=2;else{if(e.startsWith(n,o))return o+n.length;o++}return-1},CodeEditor.kindOfWord=function(e,t,n){const o=n.ignoreCase?e.toLowerCase():e;return n.keywordSet.has(o)?"keyword":n.builtinSet.has(o)?"builtin":n.callWords&&/^\s*\(/.test(t)?"function":n.propertyWords&&/^\s*:/.test(t)?"property":""},CodeEditor.prepareDefinition=function(e){e.keywordSet||(e.keywordSet=new Set(e.keywords||[]),e.builtinSet=new Set(e.builtins||[]))},CodeEditor.tokenizeLine=function(e,t,n){if(n.tokenize)return n.tokenize(e,t);CodeEditor.prepareDefinition(n);const o=[],r=function(e,t){if(0===t.length)return;const n=o[o.length-1];n&&n[0]===e?n[1]+=t:o.push([e,t])};let i=0,l=t;if(l){const t=(n.multiLineStrings||[]).includes(l),a=t?CodeEditor.findStringEnd(e,0,l):e.indexOf(l),s=t?"string":"comment";if(a<0)return r(s,e),{parts:o,state:l};const c=t?a:a+l.length;r(s,e.slice(0,c)),i=c,l=null}const a=n.lineComment,s=n.blockComment,c=n.strings||[],d=n.multiLineStrings||[];for(;i<e.length;){const t=e.slice(i),o=e[i];if(a&&t.startsWith(a)){r("comment",t);break}if(s&&t.startsWith(s[0])){const n=e.indexOf(s[1],i+s[0].length);if(n<0){r("comment",t),l=s[1];break}r("comment",e.slice(i,n+s[1].length)),i=n+s[1].length;continue}const u=c.find(function(e){return t.startsWith(e)});if(u){const o=CodeEditor.findStringEnd(e,i+u.length,u);if(o<0){r("string",t),d.includes(u)&&(l=u);break}r(n.propertyStrings&&/^\s*:/.test(e.slice(o))?"property":"string",e.slice(i,o)),i=o;continue}const f=i>0&&CodeEditor.WORD_LETTER.test(e[i-1])?null:CodeEditor.NUMBER.exec(t);if(f){r("number",f[0]),i+=f[0].length;continue}if(n.decorators&&o===n.decorators){const e=CodeEditor.WORD.exec(t.slice(1));if(e){r("function",o+e[0]),i+=1+e[0].length;continue}}if(n.variables&&o===n.variables){const e=CodeEditor.WORD.exec(t.slice(1));if(e){r("variable",o+e[0]),i+=1+e[0].length;continue}}const g=CodeEditor.WORD.exec(t);if(g){const e=g[0];r(CodeEditor.kindOfWord(e,t.slice(e.length),n),e),i+=e.length;continue}r("",o),i++}return{parts:o,state:l}},CodeEditor.tokenizeHtml=function(e,t){const n=[];let o=0,r=t;const i=function(){for(;o<e.length;){const t=e.slice(o),i=/^\/?>/.exec(t);if(i)return n.push(["tag",i[0]]),o+=i[0].length,void(r=null);const l=/^[A-Za-z_:@][\w:.-]*/.exec(t),a=/^("[^"]*"?|'[^']*'?)/.exec(t);l?(n.push(["attribute",l[0]]),o+=l[0].length):a?(n.push(["string",a[0]]),o+=a[0].length):(n.push(["",e[o]]),o++)}r="tag"};if("--\x3e"===r){const t=e.indexOf("--\x3e");if(t<0)return{parts:[["comment",e]],state:"--\x3e"};n.push(["comment",e.slice(0,t+3)]),o=t+3,r=null}else"tag"===r&&i();for(;o<e.length;){const t=e.slice(o);if(t.startsWith("\x3c!--")){const r=e.indexOf("--\x3e",o+4);if(r<0)return n.push(["comment",t]),{parts:n,state:"--\x3e"};n.push(["comment",e.slice(o,r+3)]),o=r+3;continue}const r=/^<\/?[A-Za-z!][\w:-]*/.exec(t);if(r){n.push(["tag",r[0]]),o+=r[0].length,i();continue}const l=t.indexOf("<",1),a=l<0?e.length:o+l;n.push(["",e.slice(o,a)]),o=a}return{parts:n,state:r}},CodeEditor.languages={text:{tokenize:function(e){return{parts:[["",e]],state:null}}},python:{lineComment:"#",strings:['"""',"'''",'"',"'"],multiLineStrings:['"""',"'''"],keywords:["False","None","True","and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"],builtins:["abs","all","any","bool","bytes","dict","dir","enumerate","filter","float","format","getattr","hasattr","input","int","isinstance","iter","len","list","map","max","min","next","object","open","print","range","repr","reversed","round","set","setattr","sorted","str","sum","super","tuple","type","zip","self","cls"],callWords:1,decorators:"@",indentAfter:":"},javascript:{lineComment:"//",blockComment:["/*","*/"],strings:['"',"'","`"],multiLineStrings:["`"],keywords:["async","await","break","case","catch","class","const","continue","default","delete","do","else","export","extends","false","finally","for","function","if","import","in","instanceof","let","new","null","of","return","static","super","switch","this","throw","true","try","typeof","undefined","var","void","while","yield"],builtins:["Array","Boolean","Date","Error","JSON","Map","Math","Number","Object","Promise","RegExp","Set","String","console","document","window"],callWords:1,indentAfter:"{[("},json:{strings:['"'],keywords:["true","false","null"],propertyStrings:1,indentAfter:"{["},css:{blockComment:["/*","*/"],strings:['"',"'"],propertyWords:1,variables:"#",indentAfter:"{"},sql:{lineComment:"--",blockComment:["/*","*/"],strings:["'",'"'],ignoreCase:1,keywords:["add","all","alter","and","as","asc","between","by","case","create","delete","desc","distinct","drop","else","end","exists","from","group","having","in","index","inner","insert","into","is","join","key","left","like","limit","not","null","offset","on","or","order","outer","primary","right","select","set","table","then","union","unique","update","values","view","when","where"],builtins:["avg","count","max","min","sum","coalesce","lower","upper","integer","text","real","varchar","boolean","date"],callWords:1,indentAfter:"("},bash:{lineComment:"#",strings:['"',"'"],keywords:["case","do","done","elif","else","esac","exit","export","fi","for","function","if","in","local","return","set","then","until","while"],builtins:["cat","cd","chmod","cp","echo","find","grep","ls","mkdir","mv","pwd","read","rm","sed","sudo","touch"],variables:"$",indentAfter:"{("},html:{tokenize:CodeEditor.tokenizeHtml}},CodeEditor.styles={light:CodeEditorDefaults.style,dark:{box:{color:"#1C1C1B",borderColor:White(.1)},text:{color:"#E6E6E3",caretColor:"#FFFFFF"},gutter:{color:"#232322",lineColor:White(.08),textColor:White(.38),activeTextColor:White(.85)},activeLine:{color:White(.05)},selection:{color:"rgba(111, 198, 205, 0.35)"},placeholder:{color:White(.42)},scrollBar:{color:White(.22),hoverColor:White(.4)},kinds:{keyword:"#D7A2E8",string:"#8FD694",number:"#F0B56A",comment:"#8D939B",builtin:"#6FC6CD",function:"#8CC4EE",property:"#8CC4EE",tag:"#F08FA8",attribute:"#F0B56A",variable:"#6FC6CD"}}};
2
+ "use strict";const CodeEditorDefaults={key:"0",left:0,top:0,width:"100%",height:320,value:"",language:"text",tabSize:4,readOnly:0,showLineNumbers:1,placeholder:"",changeDelay:0,ariaLabel:"Code",onChange:function(e){},onCursorChange:function(e){},styleName:"light",style:{box:{color:"white",border:1,borderColor:Black(.14),round:8},text:{fontSize:13,lineHeight:20,fontFamily:'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',color:"#2B2B2A",caretColor:"#111111",paddingX:10,paddingY:8},gutter:{color:"#F6F6F4",lineColor:Black(.08),textColor:Black(.38),activeTextColor:Black(.8),space:1},activeLine:{color:"rgba(91, 186, 193, 0.1)"},selection:{color:"rgba(91, 186, 193, 0.35)"},placeholder:{color:Black(.4)},scrollBar:{color:Black(.22),hoverColor:Black(.4),size:10},kinds:{keyword:"#8A2F8E",string:"#1F7A3D",number:"#A85A00",comment:"#7A7F87",builtin:"#00717A",function:"#2467B8",property:"#2467B8",tag:"#A32A4B",attribute:"#A85A00",variable:"#00717A"}}},CodeEditor=function(e={}){const t=e.style;basic.applyStylePackage(e,CodeEditor.styles,CodeEditorDefaults),mergeIntoIfMissing(e,CodeEditorDefaults);const n=startObject(e);let o=n.style;const r=2e3;let i=[""],l=[null],s=1,a=-1,c=-1,d=null,u=0;n.cursorLine=1,n.cursorColumn=1;const f=function(){return CodeEditor.languages[n.language]||CodeEditor.languages.text},p=function(){return n.textareaElem},g=function(e){const t=i[e],n=t.slice(0,r);return CodeEditor.tokenizeLine(n,l[e],f()).parts.map(CodeEditor.partHtml).join("")+basic.escapeHtml(t.slice(r))},h=function(){return o.text.lineHeight},m=function(e){const t=p(),n=Math.floor(t.scrollTop/h()),o=Math.ceil(t.clientHeight/h())+1,d=Math.min(i.length-1,n+o);!e&&(n>=a&&d<=c)||(a=Math.max(0,n-25),c=Math.min(i.length-1,d+25),function(e){const t=f();for(let n=s;n<=e&&n<i.length;n++){const e=i[n-1].slice(0,r);l[n]=CodeEditor.tokenizeLine(e,l[n-1],t).state,s=n+1}}(c),b(),E()),x()},b=function(){const e=[];for(let t=a;t<=c;t++)e.push(g(t));n.codeLayer.text=e.join("\n")},E=function(){const e=[];for(let t=a;t<=c;t++){const o=t+1===n.cursorLine;e.push(o?'<span class="code-editor-active-number">'+(t+1)+"</span>":String(t+1))}n.gutterLayer.text=e.join("\n")},x=function(){const e=p(),t=o.text.paddingY+a*h()-e.scrollTop,r=o.text.paddingX-e.scrollLeft;n.codeLayer.css.transform="translate("+r+"px, "+t+"px)",n.gutterLayer.css.transform="translateY("+t+"px)",n.activeLine.top=o.text.paddingY+(n.cursorLine-1)*h()-e.scrollTop},C=function(){const e=Math.max(2,String(i.length).length)+2*o.gutter.space,t=1==n.showLineNumbers?"calc("+e+"ch + 1px)":"0px";n.gutter.visible=1==n.showLineNumbers?1:0,n.gutter.css.width=t,n.gutterLayer.css.right=o.gutter.space+"ch",n.codeArea.css.left=t,n.codeArea.css.width="calc(100% - "+t+")"},y=function(){const e=p().value,t=e.split("\n");let o=0;const r=Math.min(i.length,t.length);for(;o<r&&i[o]===t[o];)o++;i=t,l.length=Math.min(l.length,i.length),s=Math.min(s,o+1,i.length),n.value=e},k=function(){const e=p().selectionStart;let t=1,o=0,r=n.value.indexOf("\n");for(;r>=0&&r<e;)t++,o=r+1,r=n.value.indexOf("\n",o);const i=e-o+1,l=t===n.cursorLine&&i===n.cursorColumn,s=t!==n.cursorLine;n.cursorLine=t,n.cursorColumn=i,s&&E(),x(),l||n.onCursorChange(n)},v=function(){d&&d(),d=null,n.changeDelay<=0?n.onChange(n):d=n.after(n.changeDelay,function(){d=null,n.onChange(n)})},S=function(){y(),C(),m(1),k(),v()},L=function(e){const t=p();t.focus();(""===e?document.execCommand("delete"):document.execCommand("insertText",!1,e))||(t.setRangeText(e,t.selectionStart,t.selectionEnd,"end"),S())},w=function(){const e=p(),t=e.value,n=t.lastIndexOf("\n",e.selectionStart-1)+1,o=e.selectionEnd>e.selectionStart&&"\n"===t[e.selectionEnd-1]?e.selectionEnd-1:e.selectionEnd;let r=t.indexOf("\n",o);return r<0&&(r=t.length),{start:n,end:r}},R=function(e){const t=p(),n=w(),o=t.value.slice(n.start,n.end).split("\n").map(e).join("\n");t.setSelectionRange(n.start,n.end),L(o),t.setSelectionRange(n.start,n.start+o.length)},B=function(){return" ".repeat(n.tabSize)},A=function(){if(function(){const e=p();return e.value.slice(e.selectionStart,e.selectionEnd).includes("\n")}())return void R(function(e){return e.length>0?B()+e:e});const e=p(),t=e.value.lastIndexOf("\n",e.selectionStart-1)+1,o=e.selectionStart-t;L(" ".repeat(n.tabSize-o%n.tabSize))},O=function(e){const t="Tab"===e.key,o="/"===e.key&&(e.ctrlKey||e.metaKey);"Escape"===e.key?u=1:t||(u=0),t&&u?u=0:1!=n.readOnly&&(t?(e.preventDefault(),e.shiftKey?R(function(e){const t=e.match(/^ */)[0].length;return e.slice(Math.min(t,n.tabSize))}):A()):"Enter"!==e.key||e.isComposing?"Backspace"!==e.key||e.isComposing?o&&(e.preventDefault(),function(){const e=f().lineComment;if(!e)return;const t=p(),n=w(),o=t.value.slice(n.start,n.end).split("\n").every(function(t){return""===t.trim()||t.trimStart().startsWith(e)});R(function(t){return""===t.trim()?t:o?t.replace(new RegExp("^(\\s*)"+CodeEditor.escapeRegExp(e)+" ?"),"$1"):t.replace(/^(\s*)/,"$1"+e+" ")})}()):function(){const e=p();if(e.selectionStart!==e.selectionEnd)return 0;const t=e.value.lastIndexOf("\n",e.selectionStart-1)+1,o=e.value.slice(t,e.selectionStart);if(0===o.length||o.trim().length>0)return 0;const r=(o.length-1)%n.tabSize+1;return e.setSelectionRange(e.selectionStart-r,e.selectionStart),L(""),1}()&&e.preventDefault():(e.preventDefault(),function(){const e=p(),t=e.value.lastIndexOf("\n",e.selectionStart-1)+1,n=e.value.slice(t,e.selectionStart),o=n.match(/^[ \t]*/)[0],r=(f().indentAfter||"").includes(n.trimEnd().slice(-1)||" ");L("\n"+o+(r?B():""))}()))},_=function(){const e=o.text,t={fontFamily:e.fontFamily,fontSize:e.fontSize+"px",lineHeight:e.lineHeight+"px"};n.props(o.box),n.gutter.color=o.gutter.color,n.gutter.css={...t,borderRight:"1px solid "+o.gutter.lineColor},n.codeArea.css=t,n.gutterLayer.css={...t,color:o.gutter.textColor},n.codeLayer.css={...t,color:e.color,tabSize:n.tabSize},n.activeLine.color=o.activeLine.color,n.activeLine.height=e.lineHeight,Object.assign(p().style,t,{padding:e.paddingY+"px "+e.paddingX+"px",caretColor:e.caretColor,tabSize:n.tabSize});const r={"--code-editor-selection":o.selection.color,"--code-editor-placeholder":o.placeholder.color,"--code-editor-active-number":o.gutter.activeTextColor,"--code-editor-bar":o.scrollBar.color,"--code-editor-bar-hover":o.scrollBar.hoverColor,"--code-editor-bar-size":o.scrollBar.size+"px"};Object.keys(o.kinds).forEach(function(e){r["--code-editor-"+e]=o.kinds[e]}),Object.keys(r).forEach(function(e){n.elem.style.setProperty(e,r[e])}),C(),m(1)};return n.setValue=function(e,t=0){const o=null==e?"":String(e);o!==p().value&&(p().value=o,i=[""],l=[null],s=1,y(),p().scrollTop=0,p().scrollLeft=0,n.cursorLine=1,n.cursorColumn=1,C(),m(1),t||v())},n.getValue=function(){return p().value},n.insertText=function(e){L(String(e))},n.getSelectedText=function(){const e=p();return e.value.slice(e.selectionStart,e.selectionEnd)},n.setLanguage=function(e){n.language=e,s=1,m(1)},n.setReadOnly=function(e){n.readOnly=basic.isOn(e)?1:0,p().readOnly=1==n.readOnly},n.setShowLineNumbers=function(e){n.showLineNumbers=basic.isOn(e)?1:0,C()},n.setTabSize=function(e){n.tabSize=e,p().style.tabSize=e,n.codeLayer.css.tabSize=e},n.goToLine=function(e){const t=p(),n=basic.clamp(Math.round(e),1,i.length);let o=0;for(let e=0;e<n-1;e++)o+=i[e].length+1;t.focus({preventScroll:!0}),t.setSelectionRange(o,o);const r=(n-1)*h(),l=2*h();r-l>=t.scrollTop&&r+h()+l<=t.scrollTop+t.clientHeight||(t.scrollTop=Math.max(0,r-t.clientHeight/2)),m(0),k()},n.focusEditor=function(){p().focus({preventScroll:!0})},n.setTheme=function(e){n.styleName=e,o=function(e){const n={styleName:e,style:t};return basic.applyStylePackage(n,CodeEditor.styles,CodeEditorDefaults),mergeIntoIfMissing(n,CodeEditorDefaults),n.style}(e),n.style=o,_()},basic.addCss("code-editor",".code-editor-textarea { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 0; border: 0; outline: none; resize: none; box-sizing: border-box; background: transparent; color: transparent; -webkit-text-fill-color: transparent; white-space: pre; overflow: auto; pointer-events: auto; user-select: text; -webkit-user-select: text; font-variant-ligatures: none; }.code-editor-textarea::selection { background: var(--code-editor-selection); }.code-editor-textarea::placeholder { color: var(--code-editor-placeholder); -webkit-text-fill-color: var(--code-editor-placeholder); }.code-editor-textarea::-webkit-scrollbar { width: var(--code-editor-bar-size); height: var(--code-editor-bar-size); }.code-editor-textarea::-webkit-scrollbar-thumb { background: var(--code-editor-bar); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }.code-editor-textarea::-webkit-scrollbar-thumb:hover { background: var(--code-editor-bar-hover); border: 2px solid transparent; background-clip: padding-box; }.code-editor-textarea::-webkit-scrollbar-corner { background: transparent; }.code-editor-layer { white-space: pre; font-variant-ligatures: none; overflow: visible; width: max-content; }.code-editor-active-number { color: var(--code-editor-active-number); }"+CodeEditor.KIND_NAMES.map(function(e){return".code-editor-"+e+" { color: var(--code-editor-"+e+"); }"}).join("")),n.gutter=startBox({left:0,top:0,height:"100%",css:{boxSizing:"border-box"}}),n.gutterLayer=Label({top:0,textAlign:"right"}),n.gutterLayer.elem.classList.add("code-editor-layer"),n.gutterLayer.css.left="auto",n.gutterLayer.aria={hidden:"true"},endBox(),n.codeArea=startBox({top:0,height:"100%",color:"transparent"}),n.activeLine=Box({left:0,width:"100%"}),n.codeLayer=Label({left:0,top:0}),n.codeLayer.elem.classList.add("code-editor-layer"),n.codeLayer.aria={hidden:"true"},endBox(),n.textareaElem=document.createElement("textarea"),n.textareaElem.classList.add("code-editor-textarea"),n.textareaElem.wrap="off",n.textareaElem.spellcheck=!1,n.textareaElem.setAttribute("autocomplete","off"),n.textareaElem.setAttribute("autocorrect","off"),n.textareaElem.setAttribute("autocapitalize","off"),n.textareaElem.setAttribute("aria-label",n.ariaLabel),n.textareaElem.placeholder=n.placeholder,n.textareaElem.readOnly=1==n.readOnly,n.textareaElem.value=null===n.value||void 0===n.value?"":String(n.value),n.codeArea.elem.appendChild(n.textareaElem),n.listenTo(p(),"input",S),n.listenTo(p(),"scroll",function(){m(0)}),n.listenTo(p(),"keydown",function(e,t){O(t)}),n.listenTo(p(),"keyup",k),n.listenTo(p(),"mouseup",k),n.listenTo(p(),"focus",k),n.listenTo(document,"selectionchange",function(){document.activeElement===p()&&k()}),n.onResize(function(){m(0)}),y(),_(),endObject(n)};CodeEditor.KIND_NAMES=["keyword","string","number","comment","builtin","function","property","tag","attribute","variable"],CodeEditor.escapeRegExp=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},CodeEditor.partHtml=function(e){const t=basic.escapeHtml(e[1]);return e[0]?'<span class="code-editor-'+e[0]+'">'+t+"</span>":t},CodeEditor.NUMBER=/^(0[xX][0-9a-fA-F_]+|0[bB][01_]+|\d[\d_]*(\.\d*)?([eE][+-]?\d+)?|\.\d+([eE][+-]?\d+)?)/,CodeEditor.WORD=/^[\p{L}_][\p{L}\p{N}_]*/u,CodeEditor.WORD_LETTER=/[\p{L}\p{N}_]/u,CodeEditor.findStringEnd=function(e,t,n){let o=t;for(;o<e.length;)if("\\"===e[o])o+=2;else{if(e.startsWith(n,o))return o+n.length;o++}return-1},CodeEditor.kindOfWord=function(e,t,n){const o=n.ignoreCase?e.toLowerCase():e;return n.keywordSet.has(o)?"keyword":n.builtinSet.has(o)?"builtin":n.callWords&&/^\s*\(/.test(t)?"function":n.propertyWords&&/^\s*:/.test(t)?"property":""},CodeEditor.prepareDefinition=function(e){e.keywordSet||(e.keywordSet=new Set(e.keywords||[]),e.builtinSet=new Set(e.builtins||[]))},CodeEditor.tokenizeLine=function(e,t,n){if(n.tokenize)return n.tokenize(e,t);CodeEditor.prepareDefinition(n);const o=[],r=function(e,t){if(0===t.length)return;const n=o[o.length-1];n&&n[0]===e?n[1]+=t:o.push([e,t])};let i=0,l=t;if(l){const t=(n.multiLineStrings||[]).includes(l),s=t?CodeEditor.findStringEnd(e,0,l):e.indexOf(l),a=t?"string":"comment";if(s<0)return r(a,e),{parts:o,state:l};const c=t?s:s+l.length;r(a,e.slice(0,c)),i=c,l=null}const s=n.lineComment,a=n.blockComment,c=n.strings||[],d=n.multiLineStrings||[];for(;i<e.length;){const t=e.slice(i),o=e[i];if(s&&t.startsWith(s)){r("comment",t);break}if(a&&t.startsWith(a[0])){const n=e.indexOf(a[1],i+a[0].length);if(n<0){r("comment",t),l=a[1];break}r("comment",e.slice(i,n+a[1].length)),i=n+a[1].length;continue}const u=c.find(function(e){return t.startsWith(e)});if(u){const o=CodeEditor.findStringEnd(e,i+u.length,u);if(o<0){r("string",t),d.includes(u)&&(l=u);break}r(n.propertyStrings&&/^\s*:/.test(e.slice(o))?"property":"string",e.slice(i,o)),i=o;continue}const f=i>0&&CodeEditor.WORD_LETTER.test(e[i-1])?null:CodeEditor.NUMBER.exec(t);if(f){r("number",f[0]),i+=f[0].length;continue}if(n.decorators&&o===n.decorators){const e=CodeEditor.WORD.exec(t.slice(1));if(e){r("function",o+e[0]),i+=1+e[0].length;continue}}if(n.variables&&o===n.variables){const e=CodeEditor.WORD.exec(t.slice(1));if(e){r("variable",o+e[0]),i+=1+e[0].length;continue}}const p=CodeEditor.WORD.exec(t);if(p){const e=p[0];r(CodeEditor.kindOfWord(e,t.slice(e.length),n),e),i+=e.length;continue}r("",o),i++}return{parts:o,state:l}},CodeEditor.tokenizeHtml=function(e,t){const n=[];let o=0,r=t;const i=function(){for(;o<e.length;){const t=e.slice(o),i=/^\/?>/.exec(t);if(i)return n.push(["tag",i[0]]),o+=i[0].length,void(r=null);const l=/^[A-Za-z_:@][\w:.-]*/.exec(t),s=/^("[^"]*"?|'[^']*'?)/.exec(t);l?(n.push(["attribute",l[0]]),o+=l[0].length):s?(n.push(["string",s[0]]),o+=s[0].length):(n.push(["",e[o]]),o++)}r="tag"};if("--\x3e"===r){const t=e.indexOf("--\x3e");if(t<0)return{parts:[["comment",e]],state:"--\x3e"};n.push(["comment",e.slice(0,t+3)]),o=t+3,r=null}else"tag"===r&&i();for(;o<e.length;){const t=e.slice(o);if(t.startsWith("\x3c!--")){const r=e.indexOf("--\x3e",o+4);if(r<0)return n.push(["comment",t]),{parts:n,state:"--\x3e"};n.push(["comment",e.slice(o,r+3)]),o=r+3;continue}const r=/^<\/?[A-Za-z!][\w:-]*/.exec(t);if(r){n.push(["tag",r[0]]),o+=r[0].length,i();continue}const l=t.indexOf("<",1),s=l<0?e.length:o+l;n.push(["",e.slice(o,s)]),o=s}return{parts:n,state:r}},CodeEditor.RUBY_CLOSERS={"[":"]","(":")","{":"}","<":">"},CodeEditor.RUBY_HEREDOC=/^<<([~-]?)(["'`]?)([A-Za-z_]\w*)\2/,CodeEditor.RUBY_PERCENT=/^%([wWiIqQ]?)([[({<|!\/])/,CodeEditor.RUBY_SYMBOL=/^:[\p{L}_][\p{L}\p{N}_]*[?!]?/u,CodeEditor.RUBY_VARIABLE=/^(@@?|\$)[\p{L}_][\p{L}\p{N}_]*/u,CodeEditor.tokenizeRuby=function(e,t){const n=CodeEditor.languages.ruby;CodeEditor.prepareDefinition(n);const o=[],r=function(e,t){if(0===t.length)return;const n=o[o.length-1];n&&n[0]===e?n[1]+=t:o.push([e,t])};let i=0,l=t,s=null,a="";const c=function(t,n){let o=t,i=t+1;for(;i<e.length;){if("\\"===e[i]){i+=2;continue}if(e[i]===n)return r("string",e.slice(o,i+1)),i+1;const t=e.startsWith("#{",i)?CodeEditor.findRubyBraceEnd(e,i+2):-1;t<0?i++:(r("string",e.slice(o,i)),r("variable","#{"),CodeEditor.tokenizeRuby(e.slice(i+2,t),null).parts.forEach(function(e){r(e[0],e[1])}),r("variable","}"),i=t+1,o=i)}return r("string",e.slice(o)),-1};if("=end"===l)return r("comment",e),{parts:o,state:/^=end\b/.test(e)?null:"=end"};if(l&&l.startsWith("<<")){const t="~"===l[2],n=l.slice(t?3:2),i=(t?e.trim():e)===n;return r("string",e),{parts:o,state:i?null:l}}if(l&&l.startsWith("%")){const t=CodeEditor.findStringEnd(e,0,l[1]);if(t<0)return r("string",e),{parts:o,state:l};r("string",e.slice(0,t)),i=t,l=null}if(/^=begin\b/.test(e))return r("comment",e),{parts:o,state:"=end"};for(;i<e.length;){const t=e.slice(i),o=e[i],d=e.slice(0,i).trimEnd(),u=/[\p{L}\p{N}_)\]}]$/u.test(d);if("#"===o){r("comment",t);break}if('"'===o||"`"===o){const e=c(i,o);if(e<0)break;i=e;continue}if("'"===o){const t=CodeEditor.findStringEnd(e,i+1,"'"),n=t<0?e.length:t;r("string",e.slice(i,n)),i=n;continue}const f=CodeEditor.RUBY_PERCENT.exec(t);if(f&&(f[1]||!u)){const n=CodeEditor.RUBY_CLOSERS[f[2]]||f[2],o=CodeEditor.findStringEnd(e,i+f[0].length,n);if(o<0){r("string",t),l="%"+n;break}r("string",e.slice(i,o)),i=o;continue}const p=CodeEditor.RUBY_HEREDOC.exec(t);if(p&&(p[1]||/^[A-Z_]+$/.test(p[3]))){r("string",p[0]),s||(s="<<"+(p[1]?"~":"")+p[3]),i+=p[0].length;continue}if(t.startsWith("::")){r("","::"),i+=2;continue}const g=i>0&&CodeEditor.WORD_LETTER.test(e[i-1]),h=g?null:CodeEditor.RUBY_SYMBOL.exec(t);if(h){r("property",h[0]),i+=h[0].length;continue}const m=CodeEditor.RUBY_VARIABLE.exec(t);if(m){r("variable",m[0]),i+=m[0].length;continue}const b=g?null:CodeEditor.NUMBER.exec(t);if(b){r("number",b[0]),i+=b[0].length;continue}const E=CodeEditor.WORD.exec(t);if(E){const e=/^[?!](?!=)/.exec(t.slice(E[0].length)),o=E[0]+(e?e[0]:""),l=t.slice(o.length),s=CodeEditor.kindOfRubyWord(o,l,a,n),c="property"===s?o+":":o;r(s,c),i+=c.length,a=o;continue}r("",o),i++}return{parts:o,state:l||s}},CodeEditor.findRubyBraceEnd=function(e,t){let n=1;for(let o=t;o<e.length;o++)if("{"===e[o]&&n++,"}"===e[o]&&n--,0===n)return o;return-1},CodeEditor.kindOfRubyWord=function(e,t,n,o){return/^:(?!:)/.test(t)?"property":o.keywordSet.has(e)?"keyword":o.builtinSet.has(e)?"builtin":"def"===n||/^\(/.test(t)?"function":/^\p{Lu}/u.test(e)?"builtin":""},CodeEditor.languages={text:{tokenize:function(e){return{parts:[["",e]],state:null}}},python:{lineComment:"#",strings:['"""',"'''",'"',"'"],multiLineStrings:['"""',"'''"],keywords:["False","None","True","and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"],builtins:["abs","all","any","bool","bytes","dict","dir","enumerate","filter","float","format","getattr","hasattr","input","int","isinstance","iter","len","list","map","max","min","next","object","open","print","range","repr","reversed","round","set","setattr","sorted","str","sum","super","tuple","type","zip","self","cls"],callWords:1,decorators:"@",indentAfter:":"},javascript:{lineComment:"//",blockComment:["/*","*/"],strings:['"',"'","`"],multiLineStrings:["`"],keywords:["async","await","break","case","catch","class","const","continue","default","delete","do","else","export","extends","false","finally","for","function","if","import","in","instanceof","let","new","null","of","return","static","super","switch","this","throw","true","try","typeof","undefined","var","void","while","yield"],builtins:["Array","Boolean","Date","Error","JSON","Map","Math","Number","Object","Promise","RegExp","Set","String","console","document","window"],callWords:1,indentAfter:"{[("},go:{lineComment:"//",blockComment:["/*","*/"],strings:['"',"'","`"],multiLineStrings:["`"],keywords:["break","case","chan","const","continue","default","defer","else","fallthrough","false","for","func","go","goto","if","import","interface","iota","map","nil","package","range","return","select","struct","switch","true","type","var"],builtins:["any","append","bool","byte","cap","clear","close","complex","copy","delete","error","float32","float64","int","int8","int16","int32","int64","len","make","max","min","new","panic","print","println","recover","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"],callWords:1,indentAfter:"{[("},ruby:{tokenize:CodeEditor.tokenizeRuby,lineComment:"#",keywords:["BEGIN","END","__FILE__","__LINE__","__method__","alias","and","attr_accessor","attr_reader","attr_writer","begin","break","case","class","def","defined?","do","else","elsif","end","ensure","extend","false","for","if","in","include","lambda","loop","module","next","nil","not","or","prepend","private","proc","protected","public","raise","redo","require","require_relative","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield"],builtins:["Array","Float","Hash","Integer","String","format","gets","print","printf","puts","rand","sleep","sprintf"],indentAfter:"{[(|"},json:{strings:['"'],keywords:["true","false","null"],propertyStrings:1,indentAfter:"{["},css:{blockComment:["/*","*/"],strings:['"',"'"],propertyWords:1,variables:"#",indentAfter:"{"},sql:{lineComment:"--",blockComment:["/*","*/"],strings:["'",'"'],ignoreCase:1,keywords:["add","all","alter","and","as","asc","between","by","case","create","delete","desc","distinct","drop","else","end","exists","from","group","having","in","index","inner","insert","into","is","join","key","left","like","limit","not","null","offset","on","or","order","outer","primary","right","select","set","table","then","union","unique","update","values","view","when","where"],builtins:["avg","count","max","min","sum","coalesce","lower","upper","integer","text","real","varchar","boolean","date"],callWords:1,indentAfter:"("},bash:{lineComment:"#",strings:['"',"'"],keywords:["case","do","done","elif","else","esac","exit","export","fi","for","function","if","in","local","return","set","then","until","while"],builtins:["cat","cd","chmod","cp","echo","find","grep","ls","mkdir","mv","pwd","read","rm","sed","sudo","touch"],variables:"$",indentAfter:"{("},html:{tokenize:CodeEditor.tokenizeHtml}},CodeEditor.styles={light:CodeEditorDefaults.style,dark:{box:{color:"#1C1C1B",borderColor:White(.1)},text:{color:"#E6E6E3",caretColor:"#FFFFFF"},gutter:{color:"#232322",lineColor:White(.08),textColor:White(.38),activeTextColor:White(.85)},activeLine:{color:White(.05)},selection:{color:"rgba(111, 198, 205, 0.35)"},placeholder:{color:White(.42)},scrollBar:{color:White(.22),hoverColor:White(.4)},kinds:{keyword:"#D7A2E8",string:"#8FD694",number:"#F0B56A",comment:"#8D939B",builtin:"#6FC6CD",function:"#8CC4EE",property:"#8CC4EE",tag:"#F08FA8",attribute:"#F0B56A",variable:"#6FC6CD"}}};