@qubit-ltd/json 1.2.1 → 1.2.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 (63) hide show
  1. package/doc/api/LosslessNumber.html +3 -610
  2. package/doc/api/data/search.json +1 -0
  3. package/doc/api/fonts/Inconsolata-Regular.ttf +0 -0
  4. package/doc/api/fonts/OpenSans-Regular.ttf +0 -0
  5. package/doc/api/fonts/WorkSans-Bold.ttf +0 -0
  6. package/doc/api/global.html +3 -1274
  7. package/doc/api/index.html +63 -264
  8. package/doc/api/scripts/core.js +726 -0
  9. package/doc/api/scripts/core.min.js +23 -0
  10. package/doc/api/scripts/resize.js +90 -0
  11. package/doc/api/scripts/search.js +265 -0
  12. package/doc/api/scripts/search.min.js +6 -0
  13. package/doc/api/scripts/{prettify → third-party}/Apache-License-2.0.txt +202 -202
  14. package/doc/api/scripts/third-party/fuse.js +9 -0
  15. package/doc/api/scripts/third-party/hljs-line-num-original.js +369 -0
  16. package/doc/api/scripts/third-party/hljs-line-num.js +1 -0
  17. package/doc/api/scripts/third-party/hljs-original.js +5171 -0
  18. package/doc/api/scripts/third-party/hljs.js +1 -0
  19. package/doc/api/scripts/third-party/popper.js +5 -0
  20. package/doc/api/scripts/third-party/tippy.js +1 -0
  21. package/doc/api/scripts/third-party/tocbot.js +672 -0
  22. package/doc/api/scripts/third-party/tocbot.min.js +1 -0
  23. package/doc/api/styles/clean-jsdoc-theme-base.css +1159 -0
  24. package/doc/api/styles/clean-jsdoc-theme-dark.css +412 -0
  25. package/doc/api/styles/clean-jsdoc-theme-light.css +482 -0
  26. package/doc/api/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  27. package/doc/api/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  28. package/doc/api/styles/clean-jsdoc-theme.min.css +1 -0
  29. package/doc/json.min.visualization.html +1 -1
  30. package/doc/json.visualization.html +1 -1
  31. package/package.json +2 -1
  32. package/doc/api/fonts/OpenSans-Bold-webfont.eot +0 -0
  33. package/doc/api/fonts/OpenSans-Bold-webfont.svg +0 -1838
  34. package/doc/api/fonts/OpenSans-Bold-webfont.woff +0 -0
  35. package/doc/api/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  36. package/doc/api/fonts/OpenSans-BoldItalic-webfont.svg +0 -1838
  37. package/doc/api/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  38. package/doc/api/fonts/OpenSans-Italic-webfont.eot +0 -0
  39. package/doc/api/fonts/OpenSans-Italic-webfont.svg +0 -1838
  40. package/doc/api/fonts/OpenSans-Italic-webfont.woff +0 -0
  41. package/doc/api/fonts/OpenSans-Light-webfont.eot +0 -0
  42. package/doc/api/fonts/OpenSans-Light-webfont.svg +0 -1839
  43. package/doc/api/fonts/OpenSans-Light-webfont.woff +0 -0
  44. package/doc/api/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  45. package/doc/api/fonts/OpenSans-LightItalic-webfont.svg +0 -1843
  46. package/doc/api/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  47. package/doc/api/fonts/OpenSans-Regular-webfont.eot +0 -0
  48. package/doc/api/fonts/OpenSans-Regular-webfont.svg +0 -1839
  49. package/doc/api/fonts/OpenSans-Regular-webfont.woff +0 -0
  50. package/doc/api/fonts/OpenSans-Semibold-webfont.eot +0 -0
  51. package/doc/api/fonts/OpenSans-Semibold-webfont.svg +0 -1838
  52. package/doc/api/fonts/OpenSans-Semibold-webfont.ttf +0 -0
  53. package/doc/api/fonts/OpenSans-Semibold-webfont.woff +0 -0
  54. package/doc/api/fonts/OpenSans-SemiboldItalic-webfont.eot +0 -0
  55. package/doc/api/fonts/OpenSans-SemiboldItalic-webfont.svg +0 -1838
  56. package/doc/api/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
  57. package/doc/api/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
  58. package/doc/api/scripts/linenumber.js +0 -34
  59. package/doc/api/scripts/prettify/lang-css.js +0 -2
  60. package/doc/api/scripts/prettify/prettify.js +0 -28
  61. package/doc/api/styles/jsdoc-default.css +0 -699
  62. package/doc/api/styles/prettify-jsdoc.css +0 -120
  63. package/doc/api/styles/prettify-tomorrow.css +0 -141
@@ -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(){var e=localStorage.getItem(themeLocalStorageKey);if(e)return e;switch(e=document.body.getAttribute("data-theme")){case"dark":case"light":return e;case"fallback-dark":return window.matchMedia("(prefers-color-scheme)").matches&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark";case"fallback-light":return window.matchMedia("(prefers-color-scheme)").matches&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";default:return"dark"}}function localUpdateTheme(e){var t=document.body,o=document.querySelectorAll(".theme-svg-use"),n="dark"===e?"#light-theme-icon":"#dark-theme-icon";t.setAttribute("data-theme",e),t.classList.remove("dark","light"),t.classList.add(e),o.forEach(function(e){e.setAttribute("xlink:href",n)})}function updateTheme(e){localUpdateTheme(e),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,n,i,c;e&&(tocbotInstance&&setTimeout(()=>tocbotInstance.updateTocListActiveElement(e),60),o=document.querySelector(".navbar-container"),n=document.querySelector(".main-content"),i=e.getBoundingClientRect().top,c=16,o&&(c+=o.scrollHeight),n&&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,t;isSourcePage()||""!==(e=window.location.hash)&&((t=document.getElementById(e.slice(1)))||(e=decodeURI(e),t=document.getElementById(e.slice(1))),t&&bringElementIntoView(t,!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.trim().replace(/(^\t)/gm,"")),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 copy-code" 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("#PeOAagUepe"),o=document.querySelector("#VuAckcnZhf"),n=0,i=0,c=(t&&(i=t.getBoundingClientRect().height),o&&(n=o.getBoundingClientRect().height),window.innerHeight-n-i-250);e.forEach(function(e,t){var o,n=e.parentNode;n&&"true"===n.getAttribute("data-skip-pre-process")||(n=getPreDiv(),o=getPreTopBar(t="ScDloZOMdL"+t,e.getAttribute("data-lang")||"code"),n.innerHTML=o,e.style.maxHeight=c+"px",e.id=t,e.classList.add("prettyprint"),e.parentNode.insertBefore(n,e),n.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 localUpdateFontSize(e){html.style.fontSize=e+"px";var t=document.querySelector("#b77a68a492f343baabea06fad81f651e");t&&(t.innerHTML=e)}function updateFontSize(e){localUpdateFontSize(e),localStorage.setItem(fontSizeLocalStorageKey,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="b77a68a492f343baabea06fad81f651e">
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(".copy-code",{content:"Copy this code",placement:"left"}),tippy(".font-size",{content:fontSizeTooltip(),trigger:"click",interactive:!0,allowHTML:!0,placement:"left"})}function fixTable(){for(const t of document.querySelectorAll("table")){if(t.classList.contains("hljs-ln"))return;var e=document.createElement("div");e.classList.add("table-div"),t.parentNode.insertBefore(e,t),e.appendChild(t)}}function hideMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.remove("show"),t&&t.setAttribute("data-isopen","false"),o&&o.setAttribute("xlink:href","#menu-icon")}function showMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.add("show"),t&&t.setAttribute("data-isopen","true"),o&&o.setAttribute("xlink:href","#close-icon")}function onMobileMenuClick(){("true"===document.querySelector("#mobile-menu").getAttribute("data-isopen")?hideMobileMenu:showMobileMenu)()}function initMobileMenu(){var e=document.querySelector("#mobile-menu");e&&e.addEventListener("click",onMobileMenuClick)}function addHrefToSidebarTitle(){document.querySelectorAll(".sidebar-title-anchor").forEach(function(e){e.setAttribute("href",baseURL)})}function highlightActiveLinkInSidebar(){var e=document.location.href.split("/");const t=decodeURI(e[e.length-1]);let o=document.querySelector(`.sidebar a[href*='${t}']`);if(!o)try{o=document.querySelector(`.sidebar a[href*='${t.split("#")[0]}']`)}catch(e){return void console.error(e)}o&&(o.parentElement.classList.add("active"),o.scrollIntoView())}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(),addHrefToSidebarTitle(),highlightActiveLinkInSidebar()}updateTheme(getTheme()),function(){var e=getFontSize(),t=localStorage.getItem(fontSizeLocalStorageKey);t?(t=Number.parseInt(t,10))!==e&&updateFontSize(t):updateFontSize(e)}(),window.addEventListener("DOMContentLoaded",onDomContentLoaded),window.addEventListener("hashchange",e=>{e=new URL(e.newURL);""!==e.hash&&bringIdToViewOnMount(e.hash)}),window.addEventListener("storage",e=>{"undefined"!==e.newValue&&(initTooltip(),e.key===themeLocalStorageKey&&localUpdateTheme(e.newValue),e.key===fontSizeLocalStorageKey&&localUpdateFontSize(e.newValue))});
@@ -0,0 +1,90 @@
1
+ /* global document */
2
+ // This file is @deprecated
3
+
4
+ var NAVBAR_OPTIONS = {};
5
+
6
+ (function() {
7
+ var NAVBAR_RESIZE_LOCAL_STORAGE_KEY = 'NAVBAR_RESIZE_LOCAL_STORAGE_KEY';
8
+
9
+ var navbar = document.querySelector('#navbar');
10
+ var footer = document.querySelector('#footer');
11
+ var mainSection = document.querySelector('#main');
12
+ var localStorageResizeObject = JSON.parse(
13
+ // eslint-disable-next-line no-undef
14
+ localStorage.getItem(NAVBAR_RESIZE_LOCAL_STORAGE_KEY)
15
+ );
16
+
17
+ /**
18
+ * Check whether we have any resize value in local storage or not.
19
+ * If we have resize value then resize the navbar.
20
+ **/
21
+ if (localStorageResizeObject) {
22
+ navbar.style.width = localStorageResizeObject.width;
23
+ mainSection.style.marginLeft = localStorageResizeObject.width;
24
+ footer.style.marginLeft = localStorageResizeObject.width;
25
+ }
26
+
27
+ var navbarSlider = document.querySelector('#navbar-resize');
28
+
29
+ function resizeNavbar(event) {
30
+ var pageX = event.pageX,
31
+ pageXPlusPx = event.pageX + 'px',
32
+ min = Number.parseInt(NAVBAR_OPTIONS.min, 10) || 300,
33
+ max = Number.parseInt(NAVBAR_OPTIONS.max, 10) || 600;
34
+
35
+ /**
36
+ * Just to add some checks. If min is smaller than 10 then
37
+ * user may accidentally end up reducing the size of navbar
38
+ * less than 10. In that case user will not able to resize navbar
39
+ * because navbar slider will be hidden.
40
+ */
41
+ if (min < 10) {
42
+ min = 10;
43
+ }
44
+
45
+ /**
46
+ * Only resize if pageX in range between min and max
47
+ * allowed value.
48
+ */
49
+ if (min < pageX && pageX < max) {
50
+ navbar.style.width = pageXPlusPx;
51
+ mainSection.style.marginLeft = pageXPlusPx;
52
+ footer.style.marginLeft = pageXPlusPx;
53
+ }
54
+ }
55
+
56
+ function setupEventListeners() {
57
+ // eslint-disable-next-line no-undef
58
+ window.addEventListener('mousemove', resizeNavbar);
59
+ // eslint-disable-next-line no-undef
60
+ window.addEventListener('touchmove', resizeNavbar);
61
+ }
62
+
63
+ function afterRemovingEventListeners() {
64
+ // eslint-disable-next-line no-undef
65
+ localStorage.setItem(
66
+ NAVBAR_RESIZE_LOCAL_STORAGE_KEY,
67
+ JSON.stringify({
68
+ width: navbar.style.width
69
+ })
70
+ );
71
+ }
72
+
73
+ function removeEventListeners() {
74
+ // eslint-disable-next-line no-undef
75
+ window.removeEventListener('mousemove', resizeNavbar);
76
+ // eslint-disable-next-line no-undef
77
+ window.removeEventListener('touchend', resizeNavbar);
78
+ afterRemovingEventListeners();
79
+ }
80
+
81
+ navbarSlider.addEventListener('mousedown', setupEventListeners);
82
+ navbarSlider.addEventListener('touchstart', setupEventListeners);
83
+ // eslint-disable-next-line no-undef
84
+ window.addEventListener('mouseup', removeEventListeners);
85
+ })();
86
+
87
+ // eslint-disable-next-line no-unused-vars
88
+ function setupResizeOptions(options) {
89
+ NAVBAR_OPTIONS = options;
90
+ }
@@ -0,0 +1,265 @@
1
+ /* global document */
2
+
3
+ const searchId = 'LiBfqbJVcV';
4
+ const searchHash = '#' + searchId;
5
+ const searchContainer = document.querySelector('#PkfLWpAbet');
6
+ const searchWrapper = document.querySelector('#iCxFxjkHbP');
7
+ const searchCloseButton = document.querySelector('#VjLlGakifb');
8
+ const searchInput = document.querySelector('#vpcKVYIppa');
9
+ const resultBox = document.querySelector('#fWwVHRuDuN');
10
+
11
+ function showResultText(text) {
12
+ resultBox.innerHTML = `<span class="search-result-c-text">${text}</span>`;
13
+ }
14
+
15
+ function hideSearch() {
16
+ // eslint-disable-next-line no-undef
17
+ if (window.location.hash === searchHash) {
18
+ // eslint-disable-next-line no-undef
19
+ history.go(-1);
20
+ }
21
+
22
+ // eslint-disable-next-line no-undef
23
+ window.onhashchange = null;
24
+
25
+ if (searchContainer) {
26
+ searchContainer.style.display = 'none';
27
+ }
28
+ }
29
+
30
+ function listenCloseKey(event) {
31
+ if (event.key === 'Escape') {
32
+ hideSearch();
33
+ // eslint-disable-next-line no-undef
34
+ window.removeEventListener('keyup', listenCloseKey);
35
+ }
36
+ }
37
+
38
+ function showSearch() {
39
+ try {
40
+ // Closing mobile menu before opening
41
+ // search box.
42
+ // It is defined in core.js
43
+ // eslint-disable-next-line no-undef
44
+ hideMobileMenu();
45
+ } catch (error) {
46
+ console.error(error);
47
+ }
48
+
49
+ // eslint-disable-next-line no-undef
50
+ window.onhashchange = hideSearch;
51
+
52
+ // eslint-disable-next-line no-undef
53
+ if (window.location.hash !== searchHash) {
54
+ // eslint-disable-next-line no-undef
55
+ history.pushState(null, null, searchHash);
56
+ }
57
+
58
+ if (searchContainer) {
59
+ searchContainer.style.display = 'flex';
60
+ // eslint-disable-next-line no-undef
61
+ window.addEventListener('keyup', listenCloseKey);
62
+ }
63
+
64
+ if (searchInput) {
65
+ searchInput.focus();
66
+ }
67
+ }
68
+
69
+ async function fetchAllData() {
70
+ // eslint-disable-next-line no-undef
71
+ const { hostname, protocol, port } = location;
72
+
73
+ // eslint-disable-next-line no-undef
74
+ const base = protocol + '//' + hostname + (port !== '' ? ':' + port : '') + baseURL;
75
+ // eslint-disable-next-line no-undef
76
+ const url = new URL('data/search.json', base);
77
+ const result = await fetch(url);
78
+ const { list } = await result.json();
79
+
80
+ return list;
81
+ }
82
+
83
+ // eslint-disable-next-line no-unused-vars
84
+ function onClickSearchItem(event) {
85
+ const target = event.currentTarget;
86
+
87
+ if (target) {
88
+ const href = target.getAttribute('href') || '';
89
+ let elementId = href.split('#')[1] || '';
90
+ let element = document.getElementById(elementId);
91
+
92
+ if (!element) {
93
+ elementId = decodeURI(elementId);
94
+ element = document.getElementById(elementId);
95
+ }
96
+
97
+ if (element) {
98
+ setTimeout(function() {
99
+ // eslint-disable-next-line no-undef
100
+ bringElementIntoView(element); // defined in core.js
101
+ }, 100);
102
+ }
103
+ }
104
+ }
105
+
106
+ function buildSearchResult(result) {
107
+ let output = '';
108
+ const removeHTMLTagsRegExp = /(<([^>]+)>)/ig;
109
+
110
+ for (const res of result) {
111
+ const { title = '', description = '' } = res.item;
112
+
113
+ const _link = res.item.link.replace('<a href="', '').replace(/">.*/, '');
114
+ const _title = title.replace(removeHTMLTagsRegExp, "");
115
+ const _description = description.replace(removeHTMLTagsRegExp, "");
116
+
117
+ output += `
118
+ <a onclick="onClickSearchItem(event)" href="${_link}" class="search-result-item">
119
+ <div class="search-result-item-title">${_title}</div>
120
+ <div class="search-result-item-p">${_description || 'No description available.'}</div>
121
+ </a>
122
+ `;
123
+ }
124
+
125
+ return output;
126
+ }
127
+
128
+ function getSearchResult(list, keys, searchKey) {
129
+ const defaultOptions = {
130
+ shouldSort: true,
131
+ threshold: 0.4,
132
+ location: 0,
133
+ distance: 100,
134
+ maxPatternLength: 32,
135
+ minMatchCharLength: 1,
136
+ keys: keys
137
+ };
138
+
139
+ const options = { ...defaultOptions };
140
+
141
+ // eslint-disable-next-line no-undef
142
+ const searchIndex = Fuse.createIndex(options.keys, list);
143
+
144
+ // eslint-disable-next-line no-undef
145
+ const fuse = new Fuse(list, options, searchIndex);
146
+
147
+ const result = fuse.search(searchKey);
148
+
149
+ if (result.length > 20) {
150
+ return result.slice(0, 20);
151
+ }
152
+
153
+ return result;
154
+ }
155
+
156
+ function debounce(func, wait, immediate) {
157
+ let timeout;
158
+
159
+ return function() {
160
+ const args = arguments;
161
+
162
+ clearTimeout(timeout);
163
+ timeout = setTimeout(() => {
164
+ timeout = null;
165
+ if (!immediate) {
166
+ // eslint-disable-next-line consistent-this, no-invalid-this
167
+ func.apply(this, args);
168
+ }
169
+ }, wait);
170
+
171
+ if (immediate && !timeout) {
172
+ // eslint-disable-next-line consistent-this, no-invalid-this
173
+ func.apply(this, args);
174
+ }
175
+ };
176
+ }
177
+
178
+ let searchData;
179
+
180
+ async function search(event) {
181
+ const value = event.target.value;
182
+ const keys = ['title', 'description'];
183
+
184
+ if (!resultBox) {
185
+ console.error('Search result container not found');
186
+
187
+ return;
188
+ }
189
+
190
+ if (!value) {
191
+ showResultText('Type anything to view search result');
192
+
193
+ return;
194
+ }
195
+
196
+ if (!searchData) {
197
+ showResultText('Loading...');
198
+
199
+ try {
200
+ // eslint-disable-next-line require-atomic-updates
201
+ searchData = await fetchAllData();
202
+ } catch (e) {
203
+ console.log(e);
204
+ showResultText('Failed to load result.');
205
+
206
+ return;
207
+ }
208
+ }
209
+
210
+ const result = getSearchResult(searchData, keys, value);
211
+
212
+ if (!result.length) {
213
+ showResultText('No result found! Try some different combination.');
214
+
215
+ return;
216
+ }
217
+
218
+ // eslint-disable-next-line require-atomic-updates
219
+ resultBox.innerHTML = buildSearchResult(result);
220
+ }
221
+
222
+ function onDomContentLoaded() {
223
+ const searchButton = document.querySelectorAll('.search-button');
224
+ const debouncedSearch = debounce(search, 300);
225
+
226
+ if (searchCloseButton) {
227
+ searchCloseButton.addEventListener('click', hideSearch);
228
+ }
229
+
230
+ if (searchButton) {
231
+ searchButton.forEach(function(item) {
232
+ item.addEventListener('click', showSearch);
233
+ });
234
+ }
235
+
236
+ if (searchContainer) {
237
+ searchContainer.addEventListener('click', hideSearch);
238
+ }
239
+
240
+ if (searchWrapper) {
241
+ searchWrapper.addEventListener('click', function(event) {
242
+ event.stopPropagation();
243
+ });
244
+ }
245
+
246
+ if (searchInput) {
247
+ searchInput.addEventListener('keyup', debouncedSearch);
248
+ }
249
+
250
+ // eslint-disable-next-line no-undef
251
+ if (window.location.hash === searchHash) {
252
+ showSearch();
253
+ }
254
+ }
255
+
256
+ // eslint-disable-next-line no-undef
257
+ window.addEventListener('DOMContentLoaded', onDomContentLoaded);
258
+
259
+ // eslint-disable-next-line no-undef
260
+ window.addEventListener('hashchange', function() {
261
+ // eslint-disable-next-line no-undef
262
+ if (window.location.hash === searchHash) {
263
+ showSearch();
264
+ }
265
+ });
@@ -0,0 +1,6 @@
1
+ const searchId="LiBfqbJVcV",searchHash="#"+searchId,searchContainer=document.querySelector("#PkfLWpAbet"),searchWrapper=document.querySelector("#iCxFxjkHbP"),searchCloseButton=document.querySelector("#VjLlGakifb"),searchInput=document.querySelector("#vpcKVYIppa"),resultBox=document.querySelector("#fWwVHRuDuN");function showResultText(e){resultBox.innerHTML=`<span class="search-result-c-text">${e}</span>`}function hideSearch(){window.location.hash===searchHash&&history.go(-1),window.onhashchange=null,searchContainer&&(searchContainer.style.display="none")}function listenCloseKey(e){"Escape"===e.key&&(hideSearch(),window.removeEventListener("keyup",listenCloseKey))}function showSearch(){try{hideMobileMenu()}catch(e){console.error(e)}window.onhashchange=hideSearch,window.location.hash!==searchHash&&history.pushState(null,null,searchHash),searchContainer&&(searchContainer.style.display="flex",window.addEventListener("keyup",listenCloseKey)),searchInput&&searchInput.focus()}async function fetchAllData(){var{hostname:e,protocol:t,port:n}=location,t=t+"//"+e+(""!==n?":"+n:"")+baseURL,e=new URL("data/search.json",t);const a=await fetch(e);n=(await a.json()).list;return n}function onClickSearchItem(t){const n=t.currentTarget;if(n){const a=n.getAttribute("href")||"";t=a.split("#")[1]||"";let e=document.getElementById(t);e||(t=decodeURI(t),e=document.getElementById(t)),e&&setTimeout(function(){bringElementIntoView(e)},100)}}function buildSearchResult(e){let t="";var n=/(<([^>]+)>)/gi;for(const s of e){const{title:c="",description:i=""}=s.item;var a=s.item.link.replace('<a href="',"").replace(/">.*/,""),o=c.replace(n,""),r=i.replace(n,"");t+=`
2
+ <a onclick="onClickSearchItem(event)" href="${a}" class="search-result-item">
3
+ <div class="search-result-item-title">${o}</div>
4
+ <div class="search-result-item-p">${r||"No description available."}</div>
5
+ </a>
6
+ `}return t}function getSearchResult(e,t,n){var t={...{shouldSort:!0,threshold:.4,location:0,distance:100,maxPatternLength:32,minMatchCharLength:1,keys:t}},a=Fuse.createIndex(t.keys,e);const o=new Fuse(e,t,a),r=o.search(n);return 20<r.length?r.slice(0,20):r}function debounce(t,n,a){let o;return function(){const e=arguments;clearTimeout(o),o=setTimeout(()=>{o=null,a||t.apply(this,e)},n),a&&!o&&t.apply(this,e)}}let searchData;async function search(e){e=e.target.value;if(resultBox)if(e){if(!searchData){showResultText("Loading...");try{searchData=await fetchAllData()}catch(e){return console.log(e),void showResultText("Failed to load result.")}}e=getSearchResult(searchData,["title","description"],e);e.length?resultBox.innerHTML=buildSearchResult(e):showResultText("No result found! Try some different combination.")}else showResultText("Type anything to view search result");else console.error("Search result container not found")}function onDomContentLoaded(){const e=document.querySelectorAll(".search-button");var t=debounce(search,300);searchCloseButton&&searchCloseButton.addEventListener("click",hideSearch),e&&e.forEach(function(e){e.addEventListener("click",showSearch)}),searchContainer&&searchContainer.addEventListener("click",hideSearch),searchWrapper&&searchWrapper.addEventListener("click",function(e){e.stopPropagation()}),searchInput&&searchInput.addEventListener("keyup",t),window.location.hash===searchHash&&showSearch()}window.addEventListener("DOMContentLoaded",onDomContentLoaded),window.addEventListener("hashchange",function(){window.location.hash===searchHash&&showSearch()});