clean-jsdoc-theme 3.3.3 → 4.0.2

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 (61) hide show
  1. package/.github/workflows/{codeql-analysis.yml → codeql.yml} +23 -18
  2. package/.github/workflows/greetings.yml +16 -0
  3. package/CHANGELOG.md +16 -0
  4. package/LICENSE +1 -1
  5. package/README.md +206 -311
  6. package/jsdoc-config.json +7 -5
  7. package/minify.js +52 -0
  8. package/package.json +10 -6
  9. package/publish.js +805 -871
  10. package/static/fonts/Inconsolata-Regular.ttf +0 -0
  11. package/static/fonts/OpenSans-Regular.ttf +0 -0
  12. package/static/fonts/WorkSans-Bold.ttf +0 -0
  13. package/static/scripts/core.js +576 -0
  14. package/static/scripts/core.min.js +23 -0
  15. package/static/scripts/resize.js +59 -54
  16. package/static/scripts/search.js +220 -53
  17. package/static/scripts/search.min.js +11 -0
  18. package/static/scripts/third-party/hljs-line-num.js +1 -0
  19. package/static/scripts/third-party/hljs-original.js +5162 -0
  20. package/static/scripts/third-party/hljs.js +1 -0
  21. package/static/scripts/third-party/popper.js +6 -0
  22. package/static/scripts/third-party/tippy.js +2 -0
  23. package/static/scripts/third-party/tocbot.js +1 -0
  24. package/static/styles/clean-jsdoc-theme-base.css +752 -190
  25. package/static/styles/clean-jsdoc-theme-dark.css +216 -133
  26. package/static/styles/clean-jsdoc-theme-light.css +239 -170
  27. package/static/styles/clean-jsdoc-theme.min.css +1 -0
  28. package/tmpl/container.tmpl +13 -12
  29. package/tmpl/details.tmpl +16 -16
  30. package/tmpl/examples.tmpl +3 -1
  31. package/tmpl/icons.tmpl +43 -5
  32. package/tmpl/layout.tmpl +62 -81
  33. package/tmpl/members.tmpl +1 -2
  34. package/tmpl/method.tmpl +4 -5
  35. package/tmpl/mobile-sidebar.tmpl +21 -0
  36. package/tmpl/navbar-actions.tmpl +19 -0
  37. package/tmpl/navbar-menu.tmpl +25 -0
  38. package/tmpl/navbar.tmpl +14 -0
  39. package/tmpl/returns.tmpl +1 -1
  40. package/tmpl/search.tmpl +17 -0
  41. package/tmpl/sidebar-items.tmpl +24 -0
  42. package/tmpl/sidebar-title.tmpl +10 -0
  43. package/tmpl/sidebar.tmpl +9 -0
  44. package/tmpl/source.tmpl +7 -2
  45. package/tmpl/toc.tmpl +4 -0
  46. package/helpers/navbarBuilder.js +0 -0
  47. package/static/fonts/MavenPro-Regular.ttf +0 -0
  48. package/static/fonts/Montserrat-Regular.ttf +0 -0
  49. package/static/fonts/Muli-Black.ttf +0 -0
  50. package/static/fonts/OFL-hind.txt +0 -93
  51. package/static/fonts/OFL-montserrat.txt +0 -93
  52. package/static/scripts/fix-code-block.js +0 -53
  53. package/static/scripts/fix-navbar.js +0 -25
  54. package/static/scripts/linenumber.js +0 -25
  55. package/static/scripts/misc.js +0 -217
  56. package/static/scripts/third-party/lang-css.js +0 -2
  57. package/static/scripts/third-party/prettify.js +0 -28
  58. package/static/styles/reset.css +0 -351
  59. package/static/styles/third-party/ionicons.min.css +0 -11
  60. package/static/styles/third-party/prettify-jsdoc.css +0 -111
  61. package/static/styles/third-party/prettify-tomorrow.css +0 -5
Binary file
@@ -0,0 +1,576 @@
1
+ /* global document */
2
+ var accordionLocalStorageKey = 'accordion-id';
3
+ var themeLocalStorageKey = 'theme';
4
+ var fontSizeLocalStorageKey = 'font-size';
5
+ var html = document.querySelector('html');
6
+
7
+ var MAX_FONT_SIZE = 30;
8
+ var MIN_FONT_SIZE = 10;
9
+
10
+ // eslint-disable-next-line no-undef
11
+ var localStorage = window.localStorage;
12
+
13
+ function getTheme() {
14
+ var body = document.body;
15
+
16
+ return body.getAttribute('data-theme');
17
+ }
18
+
19
+ function updateTheme(theme) {
20
+ var body = document.body;
21
+ var svgUse = document.querySelectorAll('.theme-svg-use');
22
+ var icon = theme === 'dark' ? 'light' : 'dark';
23
+
24
+ body.setAttribute('data-theme', theme);
25
+ body.classList.remove('dark', 'light');
26
+ body.classList.add(theme);
27
+
28
+ svgUse.forEach(function(svg) {
29
+ svg.setAttribute('xlink:href', '#' + icon + '-theme-icon');
30
+ });
31
+
32
+ localStorage.setItem(themeLocalStorageKey, theme);
33
+ }
34
+
35
+ function toggleTheme() {
36
+ var body = document.body;
37
+ var theme = body.getAttribute('data-theme');
38
+
39
+ var newTheme = theme === 'dark' ? 'light' : 'dark';
40
+
41
+ updateTheme(newTheme);
42
+ }
43
+
44
+ (function() {
45
+ var theme = getTheme();
46
+
47
+ var themeStoredInLocalStorage = localStorage.getItem(themeLocalStorageKey);
48
+
49
+ if (themeStoredInLocalStorage) {
50
+ if (theme === themeStoredInLocalStorage) {
51
+ return;
52
+ }
53
+
54
+ updateTheme(themeStoredInLocalStorage);
55
+ } else {
56
+ localStorage.setItem(themeLocalStorageKey, theme);
57
+ }
58
+ })();
59
+
60
+ /**
61
+ * Function to set accordion id to localStorage.
62
+ * @param {string} id Accordion id
63
+ */
64
+ function setAccordionIdToLocalStorage(id) {
65
+ /**
66
+ * @type {object}
67
+ */
68
+ var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
69
+
70
+ ids[id] = id;
71
+ localStorage.setItem(accordionLocalStorageKey, JSON.stringify(ids));
72
+ }
73
+
74
+ /**
75
+ * Function to remove accordion id from localStorage.
76
+ * @param {string} id Accordion id
77
+ */
78
+ function removeAccordionIdFromLocalStorage(id) {
79
+ /**
80
+ * @type {object}
81
+ */
82
+ var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
83
+
84
+ delete ids[id];
85
+ localStorage.setItem(accordionLocalStorageKey, JSON.stringify(ids));
86
+ }
87
+
88
+ /**
89
+ * Function to get all accordion ids from localStorage.
90
+ *
91
+ * @returns {object}
92
+ */
93
+ function getAccordionIdsFromLocalStorage() {
94
+ /**
95
+ * @type {object}
96
+ */
97
+ var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));
98
+
99
+ return ids || {};
100
+ }
101
+
102
+ function toggleAccordion(element) {
103
+ var currentNode = element;
104
+ var isCollapsed = currentNode.getAttribute('data-isopen') === 'false';
105
+
106
+ if (isCollapsed) {
107
+ currentNode.setAttribute('data-isopen', 'true');
108
+ setAccordionIdToLocalStorage(currentNode.id);
109
+ } else {
110
+ currentNode.setAttribute('data-isopen', 'false');
111
+ removeAccordionIdFromLocalStorage(currentNode.id);
112
+ }
113
+ }
114
+
115
+ function initAccordion() {
116
+ if (
117
+ localStorage.getItem(accordionLocalStorageKey) === undefined ||
118
+ localStorage.getItem(accordionLocalStorageKey) === null
119
+ ) {
120
+ localStorage.setItem(accordionLocalStorageKey, '{}');
121
+ }
122
+ var allAccordion = document.querySelectorAll('.sidebar-section-title');
123
+ var ids = getAccordionIdsFromLocalStorage();
124
+
125
+ allAccordion.forEach(function(item) {
126
+ item.addEventListener('click', function() {
127
+ toggleAccordion(item);
128
+ });
129
+ if (item.id in ids) {
130
+ toggleAccordion(item);
131
+ }
132
+ });
133
+ }
134
+
135
+ function isSourcePage() {
136
+ return Boolean(document.querySelector('#source-page'));
137
+ }
138
+
139
+ function bringElementIntoView(element, updateHistory = true) {
140
+ var navbar = document.querySelector('.navbar-container');
141
+ var body = document.querySelector('.main-content');
142
+ var elementTop = element.getBoundingClientRect().top;
143
+
144
+ var offset = 16;
145
+
146
+ if (navbar) {
147
+ offset += navbar.scrollHeight;
148
+ }
149
+
150
+ body.scrollBy(0, elementTop - offset);
151
+
152
+ if (updateHistory) {
153
+ // eslint-disable-next-line no-undef
154
+ history.pushState(null, null, '#' + element.id);
155
+ }
156
+ }
157
+
158
+ // eslint-disable-next-line no-unused-vars
159
+ function bringLinkToView(event) {
160
+ event.preventDefault();
161
+ event.stopPropagation();
162
+ var id = event.currentTarget.getAttribute('href');
163
+
164
+ if (!id) {
165
+ return;
166
+ }
167
+
168
+ var element = document.getElementById(id.slice(1));
169
+
170
+ if (element) {
171
+ bringElementIntoView(element);
172
+ }
173
+ }
174
+
175
+ function bringIdToViewOnMount() {
176
+ if (isSourcePage()) {
177
+ return;
178
+ }
179
+
180
+ // eslint-disable-next-line no-undef
181
+ var id = window.location.hash;
182
+
183
+ if (id === '') {
184
+ return;
185
+ }
186
+
187
+ var element = document.getElementById(id.slice(1));
188
+
189
+ if (element) {
190
+ bringElementIntoView(element, false);
191
+ }
192
+ }
193
+
194
+ function createAnchorElement(id) {
195
+ var anchor = document.createElement('a');
196
+
197
+ anchor.textContent = '#';
198
+ anchor.href = '#' + id;
199
+ anchor.classList.add('link-anchor');
200
+ anchor.onclick = bringLinkToView;
201
+
202
+ return anchor;
203
+ }
204
+
205
+ function addAnchor() {
206
+ var main = document.querySelector('.main-content').querySelector('section');
207
+
208
+ var h1 = main.querySelectorAll('h1');
209
+ var h2 = main.querySelectorAll('h2');
210
+ var h3 = main.querySelectorAll('h3');
211
+ var h4 = main.querySelectorAll('h4');
212
+
213
+ var targets = [h1, h2, h3, h4];
214
+
215
+ targets.forEach(function(target) {
216
+ target.forEach(function(heading) {
217
+ var anchor = createAnchorElement(heading.id);
218
+
219
+ heading.classList.add('has-anchor');
220
+ heading.append(anchor);
221
+ });
222
+ });
223
+ }
224
+
225
+ /**
226
+ *
227
+ * @param {string} value
228
+ */
229
+ function copy(value) {
230
+ const el = document.createElement('textarea');
231
+
232
+ el.value = value;
233
+ document.body.appendChild(el);
234
+ el.select();
235
+ document.execCommand('copy');
236
+ document.body.removeChild(el);
237
+ }
238
+
239
+ function showTooltip(id) {
240
+ var tooltip = document.getElementById(id);
241
+
242
+ tooltip.classList.add('show-tooltip');
243
+ setTimeout(function() {
244
+ tooltip.classList.remove('show-tooltip');
245
+ }, 3000);
246
+ }
247
+
248
+ /* eslint-disable-next-line */
249
+ function copyFunction(id) {
250
+ // selecting the pre element
251
+ var code = document.getElementById(id);
252
+
253
+ // selecting the ol.linenums
254
+ var element = code.querySelector('.linenums');
255
+
256
+ if (!element) {
257
+ // selecting the code block
258
+ element = code.querySelector('code');
259
+ }
260
+
261
+ // copy
262
+ copy(element.innerText);
263
+
264
+ // show tooltip
265
+ showTooltip('tooltip-' + id);
266
+ }
267
+
268
+ function hideTocOnSourcePage() {
269
+ if (isSourcePage()) {
270
+ document.querySelector('.toc-container').style.display = 'none';
271
+ }
272
+ }
273
+
274
+ function getPreTopBar(id, lang = '') {
275
+ // tooltip
276
+ var tooltip = '<div class="tooltip" id="tooltip-' + id + '">Copied!</div>';
277
+
278
+ // template of copy to clipboard icon container
279
+ var copyToClipboard =
280
+ '<button aria-label="copy code" class="icon-button" onclick="copyFunction(\'' +
281
+ id +
282
+ '\')"><svg class="sm-icon" alt="click to copy"><use xlink:href="#copy-icon"></use></svg>' +
283
+ tooltip +
284
+ '</button>';
285
+
286
+ var langNameDiv =
287
+ '<div class="code-lang-name-container"><div class="code-lang-name">' +
288
+ lang.toLocaleUpperCase() +
289
+ '</div></div>';
290
+
291
+ var topBar =
292
+ '<div class="pre-top-bar-container">' +
293
+ langNameDiv +
294
+ copyToClipboard +
295
+ '</div>';
296
+
297
+ return topBar;
298
+ }
299
+
300
+ function getPreDiv() {
301
+ var divElement = document.createElement('div');
302
+
303
+ divElement.classList.add('pre-div');
304
+
305
+ return divElement;
306
+ }
307
+
308
+ function processAllPre() {
309
+ var targets = document.querySelectorAll('pre');
310
+ var footer = document.querySelector('#footer');
311
+ var navbar = document.querySelector('#navbar');
312
+
313
+ var footerHeight = footer.getBoundingClientRect().height;
314
+ var navbarHeight = navbar.getBoundingClientRect().height;
315
+
316
+ // eslint-disable-next-line no-undef
317
+ var preMaxHeight = window.innerHeight - navbarHeight - footerHeight - 250;
318
+
319
+ // var isSource = isSourcePage();
320
+
321
+ targets.forEach(function(pre, idx) {
322
+ var div = getPreDiv();
323
+ var id = 'pre-id' + idx;
324
+ var lang = pre.getAttribute('data-lang') || '';
325
+ var topBar = getPreTopBar(id, lang);
326
+
327
+ div.innerHTML = topBar;
328
+
329
+ pre.style.maxHeight = preMaxHeight + 'px';
330
+ pre.id = id;
331
+ pre.parentNode.insertBefore(div, pre);
332
+ div.appendChild(pre);
333
+ });
334
+ }
335
+
336
+ function highlightAndBringLineIntoView() {
337
+ // eslint-disable-next-line no-undef
338
+ var lineNumber = window.location.hash.replace('#line', '');
339
+
340
+ try {
341
+ var selector = '[data-line-number="' + lineNumber + '"';
342
+
343
+ var element = document.querySelector(selector);
344
+
345
+ element.scrollIntoView();
346
+ element.parentNode.classList.add('selected');
347
+ } catch (error) {
348
+ console.error(error);
349
+ }
350
+ }
351
+
352
+ function getFontSize() {
353
+ var currentFontSize = 16;
354
+
355
+ try {
356
+ currentFontSize = Number.parseInt(
357
+ html.style.fontSize.split('px')[0],
358
+ 10
359
+ );
360
+ } catch (error) {
361
+ console.log(error);
362
+ }
363
+
364
+ return currentFontSize;
365
+ }
366
+
367
+ function updateFontSize(fontSize) {
368
+ html.style.fontSize = fontSize + 'px';
369
+ localStorage.setItem(fontSizeLocalStorageKey, fontSize);
370
+ var fontSizeText = document.querySelector('#font-size-text');
371
+
372
+ if (fontSizeText) {
373
+ fontSizeText.innerHTML = fontSize;
374
+ }
375
+ }
376
+
377
+ (function() {
378
+ var fontSize = getFontSize();
379
+ var fontSizeInLocalStorage = localStorage.getItem(fontSizeLocalStorageKey);
380
+
381
+ if (fontSizeInLocalStorage) {
382
+ var n = Number.parseInt(fontSizeInLocalStorage, 10);
383
+
384
+ if (n === fontSize) {
385
+ return;
386
+ }
387
+ updateFontSize(n);
388
+ } else {
389
+ localStorage.setItem(fontSizeInLocalStorage, fontSize);
390
+ }
391
+ })();
392
+
393
+ // eslint-disable-next-line no-unused-vars
394
+ function incrementFont(event) {
395
+ var n = getFontSize();
396
+
397
+ if (n < MAX_FONT_SIZE) {
398
+ updateFontSize(n + 1);
399
+ }
400
+ }
401
+
402
+ // eslint-disable-next-line no-unused-vars
403
+ function decrementFont(event) {
404
+ var n = getFontSize();
405
+
406
+ if (n > MIN_FONT_SIZE) {
407
+ updateFontSize(n - 1);
408
+ }
409
+ }
410
+
411
+ function fontSizeTooltip() {
412
+ var fontSize = getFontSize();
413
+
414
+ return `
415
+ <div class="font-size-tooltip">
416
+ <button aria-label="decrease-font-size" class="icon-button ${
417
+ fontSize >= MAX_FONT_SIZE ? 'disabled' : ''
418
+ }" onclick="decrementFont(event)">
419
+ <svg>
420
+ <use xlink:href="#minus-icon"></use>
421
+ </svg>
422
+ </button>
423
+ <div class="font-size-text" id="font-size-text">
424
+ ${fontSize}
425
+ </div>
426
+ <button aria-label="increase-font-size" class="icon-button ${
427
+ fontSize <= MIN_FONT_SIZE ? 'disabled' : ''
428
+ }" onclick="incrementFont(event)">
429
+ <svg>
430
+ <use xlink:href="#add-icon"></use>
431
+ </svg>
432
+ </button>
433
+ <button class="icon-button" onclick="updateFontSize(16)">
434
+ <svg>
435
+ <use xlink:href="#reset-icon"></use>
436
+ </svg>
437
+ </button>
438
+ </div>
439
+
440
+ `;
441
+ }
442
+
443
+ function initTooltip() {
444
+ // add tooltip to navbar item
445
+ // eslint-disable-next-line no-undef
446
+ tippy('.theme-toggle', {
447
+ content: 'Toggle Theme',
448
+ delay: 500
449
+ });
450
+
451
+ // eslint-disable-next-line no-undef
452
+ tippy('.search-button', {
453
+ content: 'Search',
454
+ delay: 500
455
+ });
456
+
457
+ // eslint-disable-next-line no-undef
458
+ tippy('.font-size', {
459
+ content: 'Change font size',
460
+ delay: 500
461
+ });
462
+
463
+ // eslint-disable-next-line no-undef
464
+ tippy('.codepen-button', {
465
+ content: 'Open code in CodePen',
466
+ placement: 'left'
467
+ });
468
+
469
+ // eslint-disable-next-line no-undef
470
+ tippy('.font-size', {
471
+ content: fontSizeTooltip(),
472
+ trigger: 'click',
473
+ interactive: true,
474
+ allowHTML: true,
475
+ placement: 'left'
476
+ });
477
+ }
478
+
479
+ function fixTable() {
480
+ var tables = document.querySelectorAll('table');
481
+ var table;
482
+
483
+ // eslint-disable-next-line no-undef
484
+ if (window.innerWidth > 900) {
485
+ // Only fixing table if width is smaller than 900px
486
+ return;
487
+ }
488
+
489
+ for (table of tables) {
490
+ if (table.classList.contains('hljs-ln')) {
491
+ // don't want to wrap code blocks.
492
+ return;
493
+ }
494
+
495
+ var div = document.createElement('div');
496
+
497
+ div.classList.add('table-div');
498
+ table.parentNode.insertBefore(div, table);
499
+ div.appendChild(table);
500
+ }
501
+ }
502
+
503
+ function onMobileMenuClick(event) {
504
+ var mobileMenuContainer = document.querySelector('#mobile-sidebar');
505
+ var target = event.currentTarget;
506
+ var svgUse = target.querySelector('use');
507
+ var isOpen = target.getAttribute('data-isopen') === 'true';
508
+
509
+ if (mobileMenuContainer) {
510
+ if (isOpen) {
511
+ mobileMenuContainer.classList.remove('show');
512
+ target.setAttribute('data-isopen', 'false');
513
+ svgUse.setAttribute('xlink:href', '#menu-icon');
514
+ } else {
515
+ mobileMenuContainer.classList.add('show');
516
+ target.setAttribute('data-isopen', 'true');
517
+ svgUse.setAttribute('xlink:href', '#close-icon');
518
+ }
519
+ }
520
+ }
521
+
522
+ function initMobileMenu() {
523
+ var menu = document.querySelector('#mobile-menu');
524
+
525
+ if (menu) {
526
+ menu.addEventListener('click', onMobileMenuClick);
527
+ }
528
+ }
529
+
530
+ function onDomContentLoaded() {
531
+ var themeButton = document.querySelectorAll('.theme-toggle');
532
+
533
+ initMobileMenu();
534
+
535
+ if (themeButton) {
536
+ themeButton.forEach(function(button) {
537
+ button.addEventListener('click', toggleTheme);
538
+ });
539
+ }
540
+
541
+ // Highlighting code
542
+
543
+ // eslint-disable-next-line no-undef
544
+ hljs.addPlugin({
545
+ 'after:highlightElement': function(obj) {
546
+ // Replace 'code' with result.language when
547
+ // we are able to cross check the correctness of
548
+ // result.
549
+ obj.el.parentNode.setAttribute('data-lang', 'code');
550
+ }
551
+ });
552
+ // eslint-disable-next-line no-undef
553
+ hljs.highlightAll();
554
+ // eslint-disable-next-line no-undef
555
+ hljs.initLineNumbersOnLoad({
556
+ singleLine: true
557
+ });
558
+
559
+ // Highlight complete
560
+
561
+ initAccordion();
562
+ addAnchor();
563
+ processAllPre();
564
+ hideTocOnSourcePage();
565
+ setTimeout(function() {
566
+ bringIdToViewOnMount();
567
+ if (isSourcePage()) {
568
+ highlightAndBringLineIntoView();
569
+ }
570
+ }, 1000);
571
+ initTooltip();
572
+ fixTable();
573
+ }
574
+
575
+ // eslint-disable-next-line no-undef
576
+ window.addEventListener('DOMContentLoaded', onDomContentLoaded);
@@ -0,0 +1,23 @@
1
+ var accordionLocalStorageKey="accordion-id",themeLocalStorageKey="theme",fontSizeLocalStorageKey="font-size",html=document.querySelector("html"),MAX_FONT_SIZE=30,MIN_FONT_SIZE=10,localStorage=window.localStorage;function getTheme(){return document.body.getAttribute("data-theme")}function updateTheme(e){var t=document.body,o=document.querySelectorAll(".theme-svg-use"),n="dark"===e?"light":"dark";t.setAttribute("data-theme",e),t.classList.remove("dark","light"),t.classList.add(e),o.forEach(function(e){e.setAttribute("xlink:href","#"+n+"-theme-icon")}),localStorage.setItem(themeLocalStorageKey,e)}function toggleTheme(){updateTheme("dark"===document.body.getAttribute("data-theme")?"light":"dark")}function setAccordionIdToLocalStorage(e){var t=JSON.parse(localStorage.getItem(accordionLocalStorageKey));t[e]=e,localStorage.setItem(accordionLocalStorageKey,JSON.stringify(t))}function removeAccordionIdFromLocalStorage(e){var t=JSON.parse(localStorage.getItem(accordionLocalStorageKey));delete t[e],localStorage.setItem(accordionLocalStorageKey,JSON.stringify(t))}function getAccordionIdsFromLocalStorage(){return JSON.parse(localStorage.getItem(accordionLocalStorageKey))||{}}function toggleAccordion(e){"false"===e.getAttribute("data-isopen")?(e.setAttribute("data-isopen","true"),setAccordionIdToLocalStorage(e.id)):(e.setAttribute("data-isopen","false"),removeAccordionIdFromLocalStorage(e.id))}function initAccordion(){void 0!==localStorage.getItem(accordionLocalStorageKey)&&null!==localStorage.getItem(accordionLocalStorageKey)||localStorage.setItem(accordionLocalStorageKey,"{}");var e=document.querySelectorAll(".sidebar-section-title"),t=getAccordionIdsFromLocalStorage();e.forEach(function(e){e.addEventListener("click",function(){toggleAccordion(e)}),e.id in t&&toggleAccordion(e)})}function isSourcePage(){return Boolean(document.querySelector("#source-page"))}function bringElementIntoView(e,t=!0){var o=document.querySelector(".navbar-container"),n=document.querySelector(".main-content"),i=e.getBoundingClientRect().top,c=16;o&&(c+=o.scrollHeight),n.scrollBy(0,i-c),t&&history.pushState(null,null,"#"+e.id)}function bringLinkToView(e){e.preventDefault(),e.stopPropagation();var e=e.currentTarget.getAttribute("href");!e||(e=document.getElementById(e.slice(1)))&&bringElementIntoView(e)}function bringIdToViewOnMount(){var e;isSourcePage()||""!==(e=window.location.hash)&&(e=document.getElementById(e.slice(1)))&&bringElementIntoView(e,!1)}function createAnchorElement(e){var t=document.createElement("a");return t.textContent="#",t.href="#"+e,t.classList.add("link-anchor"),t.onclick=bringLinkToView,t}function addAnchor(){var e=document.querySelector(".main-content").querySelector("section");[e.querySelectorAll("h1"),e.querySelectorAll("h2"),e.querySelectorAll("h3"),e.querySelectorAll("h4")].forEach(function(e){e.forEach(function(e){var t=createAnchorElement(e.id);e.classList.add("has-anchor"),e.append(t)})})}function copy(e){const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function showTooltip(e){var t=document.getElementById(e);t.classList.add("show-tooltip"),setTimeout(function(){t.classList.remove("show-tooltip")},3e3)}function copyFunction(e){var t=document.getElementById(e);copy((t.querySelector(".linenums")||t.querySelector("code")).innerText),showTooltip("tooltip-"+e)}function hideTocOnSourcePage(){isSourcePage()&&(document.querySelector(".toc-container").style.display="none")}function getPreTopBar(e,t=""){e='<button aria-label="copy code" class="icon-button" onclick="copyFunction(\''+e+'\')"><svg class="sm-icon" alt="click to copy"><use xlink:href="#copy-icon"></use></svg>'+('<div class="tooltip" id="tooltip-'+e+'">Copied!</div>')+"</button>";return'<div class="pre-top-bar-container">'+('<div class="code-lang-name-container"><div class="code-lang-name">'+t.toLocaleUpperCase()+"</div></div>")+e+"</div>"}function getPreDiv(){var e=document.createElement("div");return e.classList.add("pre-div"),e}function processAllPre(){var e=document.querySelectorAll("pre"),t=document.querySelector("#footer"),o=document.querySelector("#navbar"),t=t.getBoundingClientRect().height,o=o.getBoundingClientRect().height,i=window.innerHeight-o-t-250;e.forEach(function(e,t){var o=getPreDiv(),t="pre-id"+t,n=getPreTopBar(t,e.getAttribute("data-lang")||"");o.innerHTML=n,e.style.maxHeight=i+"px",e.id=t,e.parentNode.insertBefore(o,e),o.appendChild(e)})}function highlightAndBringLineIntoView(){var e=window.location.hash.replace("#line","");try{var t='[data-line-number="'+e+'"',o=document.querySelector(t);o.scrollIntoView(),o.parentNode.classList.add("selected")}catch(e){console.error(e)}}function getFontSize(){var e=16;try{e=Number.parseInt(html.style.fontSize.split("px")[0],10)}catch(e){console.log(e)}return e}function updateFontSize(e){html.style.fontSize=e+"px",localStorage.setItem(fontSizeLocalStorageKey,e);var t=document.querySelector("#font-size-text");t&&(t.innerHTML=e)}function incrementFont(e){var t=getFontSize();t<MAX_FONT_SIZE&&updateFontSize(t+1)}function decrementFont(e){var t=getFontSize();MIN_FONT_SIZE<t&&updateFontSize(t-1)}function fontSizeTooltip(){var e=getFontSize();return`
2
+ <div class="font-size-tooltip">
3
+ <button aria-label="decrease-font-size" class="icon-button ${MAX_FONT_SIZE<=e?"disabled":""}" onclick="decrementFont(event)">
4
+ <svg>
5
+ <use xlink:href="#minus-icon"></use>
6
+ </svg>
7
+ </button>
8
+ <div class="font-size-text" id="font-size-text">
9
+ ${e}
10
+ </div>
11
+ <button aria-label="increase-font-size" class="icon-button ${e<=MIN_FONT_SIZE?"disabled":""}" onclick="incrementFont(event)">
12
+ <svg>
13
+ <use xlink:href="#add-icon"></use>
14
+ </svg>
15
+ </button>
16
+ <button class="icon-button" onclick="updateFontSize(16)">
17
+ <svg>
18
+ <use xlink:href="#reset-icon"></use>
19
+ </svg>
20
+ </button>
21
+ </div>
22
+
23
+ `}function initTooltip(){tippy(".theme-toggle",{content:"Toggle Theme",delay:500}),tippy(".search-button",{content:"Search",delay:500}),tippy(".font-size",{content:"Change font size",delay:500}),tippy(".codepen-button",{content:"Open code in CodePen",placement:"left"}),tippy(".font-size",{content:fontSizeTooltip(),trigger:"click",interactive:!0,allowHTML:!0,placement:"left"})}function fixTable(){var e,t=document.querySelectorAll("table");if(!(900<window.innerWidth))for(e of t){if(e.classList.contains("hljs-ln"))return;var o=document.createElement("div");o.classList.add("table-div"),e.parentNode.insertBefore(o,e),o.appendChild(e)}}function onMobileMenuClick(e){var t=document.querySelector("#mobile-sidebar"),e=e.currentTarget,o=e.querySelector("use"),n="true"===e.getAttribute("data-isopen");t&&(n?(t.classList.remove("show"),e.setAttribute("data-isopen","false"),o.setAttribute("xlink:href","#menu-icon")):(t.classList.add("show"),e.setAttribute("data-isopen","true"),o.setAttribute("xlink:href","#close-icon")))}function initMobileMenu(){var e=document.querySelector("#mobile-menu");e&&e.addEventListener("click",onMobileMenuClick)}function onDomContentLoaded(){var e=document.querySelectorAll(".theme-toggle");initMobileMenu(),e&&e.forEach(function(e){e.addEventListener("click",toggleTheme)}),hljs.addPlugin({"after:highlightElement":function(e){e.el.parentNode.setAttribute("data-lang","code")}}),hljs.highlightAll(),hljs.initLineNumbersOnLoad({singleLine:!0}),initAccordion(),addAnchor(),processAllPre(),hideTocOnSourcePage(),setTimeout(function(){bringIdToViewOnMount(),isSourcePage()&&highlightAndBringLineIntoView()},1e3),initTooltip(),fixTable()}!function(){var e=getTheme(),t=localStorage.getItem(themeLocalStorageKey);t?e!==t&&updateTheme(t):localStorage.setItem(themeLocalStorageKey,e)}(),function(){var e,t=getFontSize(),o=localStorage.getItem(fontSizeLocalStorageKey);o?(e=Number.parseInt(o,10))!==t&&updateFontSize(e):localStorage.setItem(o,t)}(),window.addEventListener("DOMContentLoaded",onDomContentLoaded);