dobo 2.0.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +0 -0
- package/.github/workflows/repo-lockdown.yml +0 -0
- package/.jsdoc.conf.json +0 -0
- package/LICENSE +0 -0
- package/README.md +2 -2
- package/docs/Dobo.html +0 -0
- package/docs/data/search.json +0 -0
- package/docs/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/global.html +0 -0
- package/docs/index.html +0 -0
- package/docs/index.js.html +0 -0
- package/docs/lib_collect-connections.js.html +0 -0
- package/docs/lib_collect-drivers.js.html +0 -0
- package/docs/lib_collect-features.js.html +0 -0
- package/docs/lib_collect-schemas.js.html +0 -0
- package/docs/lib_index.js.html +0 -0
- package/docs/method_model_create.js.html +0 -0
- package/docs/method_model_drop.js.html +0 -0
- package/docs/method_model_exists.js.html +0 -0
- package/docs/method_record_count.js.html +0 -0
- package/docs/method_record_create.js.html +0 -0
- package/docs/method_record_find-all.js.html +0 -0
- package/docs/method_record_find-one.js.html +0 -0
- package/docs/method_record_find.js.html +0 -0
- package/docs/method_record_get.js.html +0 -0
- package/docs/method_record_remove.js.html +0 -0
- package/docs/method_record_update.js.html +0 -0
- package/docs/method_record_upsert.js.html +0 -0
- package/docs/method_sanitize_body.js.html +0 -0
- package/docs/method_sanitize_date.js.html +0 -0
- package/docs/method_sanitize_id.js.html +0 -0
- package/docs/method_validate.js.html +0 -0
- package/docs/module-Lib.html +0 -0
- package/docs/scripts/core.js +476 -477
- package/docs/scripts/core.min.js +0 -0
- package/docs/scripts/resize.js +36 -36
- package/docs/scripts/search.js +105 -105
- package/docs/scripts/search.min.js +0 -0
- package/docs/scripts/third-party/Apache-License-2.0.txt +0 -0
- package/docs/scripts/third-party/fuse.js +1 -1
- package/docs/scripts/third-party/hljs-line-num-original.js +282 -285
- package/docs/scripts/third-party/hljs-line-num.js +1 -1
- package/docs/scripts/third-party/hljs-original.js +1195 -1202
- package/docs/scripts/third-party/hljs.js +1 -1
- package/docs/scripts/third-party/popper.js +1 -1
- package/docs/scripts/third-party/tippy.js +1 -1
- package/docs/scripts/third-party/tocbot.js +508 -509
- package/docs/scripts/third-party/tocbot.min.js +0 -0
- package/docs/static/bitcoin.jpeg +0 -0
- package/docs/static/home.md +0 -0
- package/docs/static/logo-ecosystem.png +0 -0
- package/docs/static/logo.png +0 -0
- package/docs/styles/clean-jsdoc-theme-base.css +0 -0
- package/docs/styles/clean-jsdoc-theme-dark.css +0 -0
- package/docs/styles/clean-jsdoc-theme-light.css +0 -0
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +0 -0
- package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +0 -0
- package/docs/styles/clean-jsdoc-theme.min.css +0 -0
- package/extend/bajo/intl/en-US.json +66 -28
- package/extend/bajo/intl/id.json +55 -27
- package/extend/bajoCli/applet/clear-record.js +22 -0
- package/extend/bajoCli/applet/connection.js +0 -0
- package/extend/bajoCli/applet/count-record.js +27 -0
- package/extend/bajoCli/applet/create-aggregate.js +33 -0
- package/extend/bajoCli/applet/create-histogram.js +33 -0
- package/extend/bajoCli/applet/create-record.js +39 -0
- package/extend/bajoCli/applet/find-record.js +27 -0
- package/extend/bajoCli/applet/get-record.js +27 -0
- package/extend/bajoCli/applet/lib/post-process.js +10 -17
- package/extend/bajoCli/applet/model.js +22 -0
- package/extend/bajoCli/applet/rebuild-model.js +91 -0
- package/extend/bajoCli/applet/remove-record.js +27 -0
- package/extend/bajoCli/applet/update-record.js +44 -0
- package/extend/bajoCli/applet.js +0 -0
- package/extend/dobo/driver/memory.js +170 -0
- package/extend/dobo/feature/created-at.js +9 -7
- package/extend/dobo/feature/dt.js +0 -0
- package/extend/dobo/feature/immutable.js +30 -0
- package/extend/dobo/feature/int-id.js +0 -0
- package/extend/dobo/feature/removed-at.js +32 -54
- package/extend/dobo/feature/updated-at.js +14 -12
- package/extend/waibuMpa/route/attachment/@model/@id/@field/@file.js +2 -6
- package/extend/waibuStatic/virtual.json +0 -0
- package/index.js +291 -366
- package/lib/collect-connections.js +49 -21
- package/lib/collect-drivers.js +19 -33
- package/lib/collect-features.js +24 -17
- package/lib/collect-models.js +319 -0
- package/lib/factory/action.js +161 -0
- package/lib/factory/connection.js +62 -0
- package/lib/factory/driver.js +358 -0
- package/lib/factory/feature.js +33 -0
- package/lib/factory/model/_util.js +402 -0
- package/lib/factory/model/build.js +15 -0
- package/lib/factory/model/clear-record.js +17 -0
- package/lib/factory/model/count-record.js +17 -0
- package/lib/factory/model/create-aggregate.js +17 -0
- package/lib/factory/model/create-attachment.js +29 -0
- package/lib/factory/model/create-histogram.js +17 -0
- package/lib/factory/model/create-record.js +35 -0
- package/lib/factory/model/drop.js +15 -0
- package/lib/factory/model/exists.js +21 -0
- package/lib/factory/model/find-all-record.js +71 -0
- package/lib/factory/model/find-attachment.js +29 -0
- package/lib/factory/model/find-one-record.js +19 -0
- package/{method/record/find.js → lib/factory/model/find-record.js} +103 -115
- package/lib/factory/model/get-attachment.js +15 -0
- package/lib/factory/model/get-record.js +79 -0
- package/lib/factory/model/list-attachment.js +37 -0
- package/lib/{add-fixtures.js → factory/model/load-fixtures.js} +69 -67
- package/lib/factory/model/remove-attachment.js +15 -0
- package/lib/factory/model/remove-record.js +59 -0
- package/lib/factory/model/sanitize-body.js +62 -0
- package/lib/factory/model/sanitize-id.js +7 -0
- package/lib/factory/model/sanitize-record.js +26 -0
- package/lib/factory/model/update-attachment.js +9 -0
- package/lib/factory/model/update-record.js +81 -0
- package/lib/factory/model/upsert-record.js +95 -0
- package/{method → lib/factory/model}/validate.js +38 -52
- package/lib/factory/model.js +150 -0
- package/lib/index.js +0 -0
- package/package.json +8 -4
- package/wiki/APPLETS.md +0 -0
- package/wiki/CHANGES.md +46 -0
- package/wiki/CONFIG.md +0 -0
- package/wiki/CONTRIBUTING.md +0 -0
- package/wiki/DEV-GUIDE.md +0 -0
- package/wiki/ECOSYSTEM.md +0 -0
- package/wiki/GETTING-STARTED.md +10 -10
- package/wiki/QUERY-LANGUAGE.md +0 -0
- package/wiki/USER-GUIDE.md +0 -0
- package/extend/bajoCli/applet/model-clear.js +0 -11
- package/extend/bajoCli/applet/model-rebuild.js +0 -101
- package/extend/bajoCli/applet/record-create.js +0 -43
- package/extend/bajoCli/applet/record-find.js +0 -28
- package/extend/bajoCli/applet/record-get.js +0 -24
- package/extend/bajoCli/applet/record-remove.js +0 -24
- package/extend/bajoCli/applet/record-update.js +0 -47
- package/extend/bajoCli/applet/schema.js +0 -22
- package/extend/bajoCli/applet/stat-count.js +0 -24
- package/lib/build-bulk-action.js +0 -12
- package/lib/check-unique.js +0 -39
- package/lib/collect-schemas.js +0 -91
- package/lib/exec-feature-hook.js +0 -13
- package/lib/exec-validation.js +0 -21
- package/lib/generic-prop-sanitizer.js +0 -32
- package/lib/handle-attachment-upload.js +0 -16
- package/lib/mem-db/conn-sanitizer.js +0 -8
- package/lib/mem-db/instantiate.js +0 -41
- package/lib/mem-db/method/model/clear.js +0 -6
- package/lib/mem-db/method/model/create.js +0 -5
- package/lib/mem-db/method/model/drop.js +0 -5
- package/lib/mem-db/method/model/exists.js +0 -5
- package/lib/mem-db/method/record/create.js +0 -12
- package/lib/mem-db/method/record/find.js +0 -20
- package/lib/mem-db/method/record/get.js +0 -9
- package/lib/mem-db/method/record/remove.js +0 -13
- package/lib/mem-db/method/record/update.js +0 -15
- package/lib/mem-db/method/stat/count.js +0 -11
- package/lib/mem-db/start.js +0 -25
- package/lib/merge-attachment-info.js +0 -16
- package/lib/multi-rel-rows.js +0 -42
- package/lib/resolve-method.js +0 -16
- package/lib/sanitize-schema.js +0 -198
- package/lib/single-rel-rows.js +0 -38
- package/method/attachment/copy-uploaded.js +0 -34
- package/method/attachment/create.js +0 -29
- package/method/attachment/find.js +0 -27
- package/method/attachment/get-path.js +0 -12
- package/method/attachment/get.js +0 -12
- package/method/attachment/pre-check.js +0 -9
- package/method/attachment/remove.js +0 -11
- package/method/attachment/update.js +0 -7
- package/method/bulk/create.js +0 -46
- package/method/model/clear.js +0 -22
- package/method/model/create.js +0 -32
- package/method/model/drop.js +0 -31
- package/method/model/exists.js +0 -37
- package/method/record/clear.js +0 -24
- package/method/record/count.js +0 -66
- package/method/record/create.js +0 -111
- package/method/record/find-all.js +0 -41
- package/method/record/find-one.js +0 -70
- package/method/record/get.js +0 -89
- package/method/record/remove.js +0 -72
- package/method/record/update.js +0 -104
- package/method/record/upsert.js +0 -51
- package/method/sanitize/body.js +0 -85
- package/method/sanitize/date.js +0 -27
- package/method/sanitize/id.js +0 -17
- package/method/stat/aggregate.js +0 -23
- package/method/stat/histogram.js +0 -26
package/docs/scripts/core.min.js
CHANGED
|
File without changes
|
package/docs/scripts/resize.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
/* global document */
|
|
2
2
|
// This file is @deprecated
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
let NAVBAR_OPTIONS = {};
|
|
5
5
|
|
|
6
|
-
(function() {
|
|
7
|
-
|
|
6
|
+
(function () {
|
|
7
|
+
const NAVBAR_RESIZE_LOCAL_STORAGE_KEY = 'NAVBAR_RESIZE_LOCAL_STORAGE_KEY'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const navbar = document.querySelector('#navbar')
|
|
10
|
+
const footer = document.querySelector('#footer')
|
|
11
|
+
const mainSection = document.querySelector('#main')
|
|
12
|
+
const localStorageResizeObject = JSON.parse(
|
|
13
13
|
// eslint-disable-next-line no-undef
|
|
14
14
|
localStorage.getItem(NAVBAR_RESIZE_LOCAL_STORAGE_KEY)
|
|
15
|
-
)
|
|
15
|
+
)
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Check whether we have any resize value in local storage or not.
|
|
19
19
|
* If we have resize value then resize the navbar.
|
|
20
20
|
**/
|
|
21
21
|
if (localStorageResizeObject) {
|
|
22
|
-
navbar.style.width = localStorageResizeObject.width
|
|
23
|
-
mainSection.style.marginLeft = localStorageResizeObject.width
|
|
24
|
-
footer.style.marginLeft = localStorageResizeObject.width
|
|
22
|
+
navbar.style.width = localStorageResizeObject.width
|
|
23
|
+
mainSection.style.marginLeft = localStorageResizeObject.width
|
|
24
|
+
footer.style.marginLeft = localStorageResizeObject.width
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const navbarSlider = document.querySelector('#navbar-resize')
|
|
28
28
|
|
|
29
|
-
function resizeNavbar(event) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
function resizeNavbar (event) {
|
|
30
|
+
const pageX = event.pageX
|
|
31
|
+
const pageXPlusPx = event.pageX + 'px'
|
|
32
|
+
let min = Number.parseInt(NAVBAR_OPTIONS.min, 10) || 300
|
|
33
|
+
const max = Number.parseInt(NAVBAR_OPTIONS.max, 10) || 600
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Just to add some checks. If min is smaller than 10 then
|
|
@@ -39,7 +39,7 @@ var NAVBAR_OPTIONS = {};
|
|
|
39
39
|
* because navbar slider will be hidden.
|
|
40
40
|
*/
|
|
41
41
|
if (min < 10) {
|
|
42
|
-
min = 10
|
|
42
|
+
min = 10
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
@@ -47,44 +47,44 @@ var NAVBAR_OPTIONS = {};
|
|
|
47
47
|
* allowed value.
|
|
48
48
|
*/
|
|
49
49
|
if (min < pageX && pageX < max) {
|
|
50
|
-
navbar.style.width = pageXPlusPx
|
|
51
|
-
mainSection.style.marginLeft = pageXPlusPx
|
|
52
|
-
footer.style.marginLeft = pageXPlusPx
|
|
50
|
+
navbar.style.width = pageXPlusPx
|
|
51
|
+
mainSection.style.marginLeft = pageXPlusPx
|
|
52
|
+
footer.style.marginLeft = pageXPlusPx
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
function setupEventListeners() {
|
|
56
|
+
function setupEventListeners () {
|
|
57
57
|
// eslint-disable-next-line no-undef
|
|
58
|
-
window.addEventListener('mousemove', resizeNavbar)
|
|
58
|
+
window.addEventListener('mousemove', resizeNavbar)
|
|
59
59
|
// eslint-disable-next-line no-undef
|
|
60
|
-
window.addEventListener('touchmove', resizeNavbar)
|
|
60
|
+
window.addEventListener('touchmove', resizeNavbar)
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
function afterRemovingEventListeners() {
|
|
63
|
+
function afterRemovingEventListeners () {
|
|
64
64
|
// eslint-disable-next-line no-undef
|
|
65
65
|
localStorage.setItem(
|
|
66
66
|
NAVBAR_RESIZE_LOCAL_STORAGE_KEY,
|
|
67
67
|
JSON.stringify({
|
|
68
68
|
width: navbar.style.width
|
|
69
69
|
})
|
|
70
|
-
)
|
|
70
|
+
)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
function removeEventListeners() {
|
|
73
|
+
function removeEventListeners () {
|
|
74
74
|
// eslint-disable-next-line no-undef
|
|
75
|
-
window.removeEventListener('mousemove', resizeNavbar)
|
|
75
|
+
window.removeEventListener('mousemove', resizeNavbar)
|
|
76
76
|
// eslint-disable-next-line no-undef
|
|
77
|
-
window.removeEventListener('touchend', resizeNavbar)
|
|
78
|
-
afterRemovingEventListeners()
|
|
77
|
+
window.removeEventListener('touchend', resizeNavbar)
|
|
78
|
+
afterRemovingEventListeners()
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
navbarSlider.addEventListener('mousedown', setupEventListeners)
|
|
82
|
-
navbarSlider.addEventListener('touchstart', setupEventListeners)
|
|
81
|
+
navbarSlider.addEventListener('mousedown', setupEventListeners)
|
|
82
|
+
navbarSlider.addEventListener('touchstart', setupEventListeners)
|
|
83
83
|
// eslint-disable-next-line no-undef
|
|
84
|
-
window.addEventListener('mouseup', removeEventListeners)
|
|
85
|
-
})()
|
|
84
|
+
window.addEventListener('mouseup', removeEventListeners)
|
|
85
|
+
})()
|
|
86
86
|
|
|
87
87
|
// eslint-disable-next-line no-unused-vars
|
|
88
|
-
function setupResizeOptions(options) {
|
|
89
|
-
NAVBAR_OPTIONS = options
|
|
88
|
+
function setupResizeOptions (options) {
|
|
89
|
+
NAVBAR_OPTIONS = options
|
|
90
90
|
}
|
package/docs/scripts/search.js
CHANGED
|
@@ -1,131 +1,131 @@
|
|
|
1
1
|
/* global document */
|
|
2
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
|
|
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
13
|
}
|
|
14
14
|
|
|
15
|
-
function hideSearch() {
|
|
15
|
+
function hideSearch () {
|
|
16
16
|
// eslint-disable-next-line no-undef
|
|
17
17
|
if (window.location.hash === searchHash) {
|
|
18
18
|
// eslint-disable-next-line no-undef
|
|
19
|
-
history.go(-1)
|
|
19
|
+
history.go(-1)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// eslint-disable-next-line no-undef
|
|
23
|
-
window.onhashchange = null
|
|
23
|
+
window.onhashchange = null
|
|
24
24
|
|
|
25
25
|
if (searchContainer) {
|
|
26
|
-
searchContainer.style.display = 'none'
|
|
26
|
+
searchContainer.style.display = 'none'
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function listenCloseKey(event) {
|
|
30
|
+
function listenCloseKey (event) {
|
|
31
31
|
if (event.key === 'Escape') {
|
|
32
|
-
hideSearch()
|
|
32
|
+
hideSearch()
|
|
33
33
|
// eslint-disable-next-line no-undef
|
|
34
|
-
window.removeEventListener('keyup', listenCloseKey)
|
|
34
|
+
window.removeEventListener('keyup', listenCloseKey)
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function showSearch() {
|
|
38
|
+
function showSearch () {
|
|
39
39
|
try {
|
|
40
40
|
// Closing mobile menu before opening
|
|
41
41
|
// search box.
|
|
42
42
|
// It is defined in core.js
|
|
43
43
|
// eslint-disable-next-line no-undef
|
|
44
|
-
hideMobileMenu()
|
|
44
|
+
hideMobileMenu()
|
|
45
45
|
} catch (error) {
|
|
46
|
-
console.error(error)
|
|
46
|
+
console.error(error)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// eslint-disable-next-line no-undef
|
|
50
|
-
window.onhashchange = hideSearch
|
|
50
|
+
window.onhashchange = hideSearch
|
|
51
51
|
|
|
52
52
|
// eslint-disable-next-line no-undef
|
|
53
53
|
if (window.location.hash !== searchHash) {
|
|
54
54
|
// eslint-disable-next-line no-undef
|
|
55
|
-
history.pushState(null, null, searchHash)
|
|
55
|
+
history.pushState(null, null, searchHash)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
if (searchContainer) {
|
|
59
|
-
searchContainer.style.display = 'flex'
|
|
59
|
+
searchContainer.style.display = 'flex'
|
|
60
60
|
// eslint-disable-next-line no-undef
|
|
61
|
-
window.addEventListener('keyup', listenCloseKey)
|
|
61
|
+
window.addEventListener('keyup', listenCloseKey)
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if (searchInput) {
|
|
65
|
-
searchInput.focus()
|
|
65
|
+
searchInput.focus()
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
async function fetchAllData() {
|
|
69
|
+
async function fetchAllData () {
|
|
70
70
|
// eslint-disable-next-line no-undef
|
|
71
|
-
const { hostname, protocol, port } = location
|
|
71
|
+
const { hostname, protocol, port } = location
|
|
72
72
|
|
|
73
73
|
// eslint-disable-next-line no-undef
|
|
74
|
-
const base = protocol + '//' + hostname + (port !== '' ? ':' + port : '') + baseURL
|
|
74
|
+
const base = protocol + '//' + hostname + (port !== '' ? ':' + port : '') + baseURL
|
|
75
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()
|
|
76
|
+
const url = new URL('data/search.json', base)
|
|
77
|
+
const result = await fetch(url)
|
|
78
|
+
const { list } = await result.json()
|
|
79
79
|
|
|
80
|
-
return list
|
|
80
|
+
return list
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// eslint-disable-next-line no-unused-vars
|
|
84
|
-
function onClickSearchItem(event) {
|
|
85
|
-
const target = event.currentTarget
|
|
84
|
+
function onClickSearchItem (event) {
|
|
85
|
+
const target = event.currentTarget
|
|
86
86
|
|
|
87
87
|
if (target) {
|
|
88
|
-
const href = target.getAttribute('href') || ''
|
|
89
|
-
let elementId = href.split('#')[1] || ''
|
|
90
|
-
let element = document.getElementById(elementId)
|
|
88
|
+
const href = target.getAttribute('href') || ''
|
|
89
|
+
let elementId = href.split('#')[1] || ''
|
|
90
|
+
let element = document.getElementById(elementId)
|
|
91
91
|
|
|
92
92
|
if (!element) {
|
|
93
|
-
elementId = decodeURI(elementId)
|
|
94
|
-
element = document.getElementById(elementId)
|
|
93
|
+
elementId = decodeURI(elementId)
|
|
94
|
+
element = document.getElementById(elementId)
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
if (element) {
|
|
98
|
-
setTimeout(function() {
|
|
98
|
+
setTimeout(function () {
|
|
99
99
|
// eslint-disable-next-line no-undef
|
|
100
|
-
bringElementIntoView(element)
|
|
101
|
-
}, 100)
|
|
100
|
+
bringElementIntoView(element) // defined in core.js
|
|
101
|
+
}, 100)
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
function buildSearchResult(result) {
|
|
107
|
-
let output = ''
|
|
108
|
-
const removeHTMLTagsRegExp = /(<([^>]+)>)/ig
|
|
109
|
-
|
|
106
|
+
function buildSearchResult (result) {
|
|
107
|
+
let output = ''
|
|
108
|
+
const removeHTMLTagsRegExp = /(<([^>]+)>)/ig
|
|
109
|
+
|
|
110
110
|
for (const res of result) {
|
|
111
|
-
const { title = '', description = '' } = res.item
|
|
111
|
+
const { title = '', description = '' } = res.item
|
|
112
112
|
|
|
113
|
-
const _link = res.item.link.replace('<a href="', '').replace(/">.*/, '')
|
|
114
|
-
const _title = title.replace(removeHTMLTagsRegExp,
|
|
115
|
-
const _description = description.replace(removeHTMLTagsRegExp,
|
|
113
|
+
const _link = res.item.link.replace('<a href="', '').replace(/">.*/, '')
|
|
114
|
+
const _title = title.replace(removeHTMLTagsRegExp, '')
|
|
115
|
+
const _description = description.replace(removeHTMLTagsRegExp, '')
|
|
116
116
|
|
|
117
117
|
output += `
|
|
118
118
|
<a onclick="onClickSearchItem(event)" href="${_link}" class="search-result-item">
|
|
119
119
|
<div class="search-result-item-title">${_title}</div>
|
|
120
120
|
<div class="search-result-item-p">${_description || 'No description available.'}</div>
|
|
121
121
|
</a>
|
|
122
|
-
|
|
122
|
+
`
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
return output
|
|
125
|
+
return output
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
function getSearchResult(list, keys, searchKey) {
|
|
128
|
+
function getSearchResult (list, keys, searchKey) {
|
|
129
129
|
const defaultOptions = {
|
|
130
130
|
shouldSort: true,
|
|
131
131
|
threshold: 0.4,
|
|
@@ -133,133 +133,133 @@ function getSearchResult(list, keys, searchKey) {
|
|
|
133
133
|
distance: 100,
|
|
134
134
|
maxPatternLength: 32,
|
|
135
135
|
minMatchCharLength: 1,
|
|
136
|
-
keys
|
|
137
|
-
}
|
|
136
|
+
keys
|
|
137
|
+
}
|
|
138
138
|
|
|
139
|
-
const options = { ...defaultOptions }
|
|
139
|
+
const options = { ...defaultOptions }
|
|
140
140
|
|
|
141
141
|
// eslint-disable-next-line no-undef
|
|
142
|
-
const searchIndex = Fuse.createIndex(options.keys, list)
|
|
142
|
+
const searchIndex = Fuse.createIndex(options.keys, list)
|
|
143
143
|
|
|
144
144
|
// eslint-disable-next-line no-undef
|
|
145
|
-
const fuse = new Fuse(list, options, searchIndex)
|
|
145
|
+
const fuse = new Fuse(list, options, searchIndex)
|
|
146
146
|
|
|
147
|
-
const result = fuse.search(searchKey)
|
|
147
|
+
const result = fuse.search(searchKey)
|
|
148
148
|
|
|
149
149
|
if (result.length > 20) {
|
|
150
|
-
return result.slice(0, 20)
|
|
150
|
+
return result.slice(0, 20)
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
return result
|
|
153
|
+
return result
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
function debounce(func, wait, immediate) {
|
|
157
|
-
let timeout
|
|
156
|
+
function debounce (func, wait, immediate) {
|
|
157
|
+
let timeout
|
|
158
158
|
|
|
159
|
-
return function() {
|
|
160
|
-
const args = arguments
|
|
159
|
+
return function () {
|
|
160
|
+
const args = arguments
|
|
161
161
|
|
|
162
|
-
clearTimeout(timeout)
|
|
162
|
+
clearTimeout(timeout)
|
|
163
163
|
timeout = setTimeout(() => {
|
|
164
|
-
timeout = null
|
|
164
|
+
timeout = null
|
|
165
165
|
if (!immediate) {
|
|
166
166
|
// eslint-disable-next-line consistent-this, no-invalid-this
|
|
167
|
-
func.apply(this, args)
|
|
167
|
+
func.apply(this, args)
|
|
168
168
|
}
|
|
169
|
-
}, wait)
|
|
169
|
+
}, wait)
|
|
170
170
|
|
|
171
171
|
if (immediate && !timeout) {
|
|
172
172
|
// eslint-disable-next-line consistent-this, no-invalid-this
|
|
173
|
-
func.apply(this, args)
|
|
173
|
+
func.apply(this, args)
|
|
174
174
|
}
|
|
175
|
-
}
|
|
175
|
+
}
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
let searchData
|
|
178
|
+
let searchData
|
|
179
179
|
|
|
180
|
-
async function search(event) {
|
|
181
|
-
const value = event.target.value
|
|
182
|
-
const keys = ['title', 'description']
|
|
180
|
+
async function search (event) {
|
|
181
|
+
const value = event.target.value
|
|
182
|
+
const keys = ['title', 'description']
|
|
183
183
|
|
|
184
184
|
if (!resultBox) {
|
|
185
|
-
console.error('Search result container not found')
|
|
185
|
+
console.error('Search result container not found')
|
|
186
186
|
|
|
187
|
-
return
|
|
187
|
+
return
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
if (!value) {
|
|
191
|
-
showResultText('Type anything to view search result')
|
|
191
|
+
showResultText('Type anything to view search result')
|
|
192
192
|
|
|
193
|
-
return
|
|
193
|
+
return
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
if (!searchData) {
|
|
197
|
-
showResultText('Loading...')
|
|
197
|
+
showResultText('Loading...')
|
|
198
198
|
|
|
199
199
|
try {
|
|
200
200
|
// eslint-disable-next-line require-atomic-updates
|
|
201
|
-
searchData = await fetchAllData()
|
|
201
|
+
searchData = await fetchAllData()
|
|
202
202
|
} catch (e) {
|
|
203
|
-
console.log(e)
|
|
204
|
-
showResultText('Failed to load result.')
|
|
203
|
+
console.log(e)
|
|
204
|
+
showResultText('Failed to load result.')
|
|
205
205
|
|
|
206
|
-
return
|
|
206
|
+
return
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
const result = getSearchResult(searchData, keys, value)
|
|
210
|
+
const result = getSearchResult(searchData, keys, value)
|
|
211
211
|
|
|
212
212
|
if (!result.length) {
|
|
213
|
-
showResultText('No result found! Try some different combination.')
|
|
213
|
+
showResultText('No result found! Try some different combination.')
|
|
214
214
|
|
|
215
|
-
return
|
|
215
|
+
return
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
// eslint-disable-next-line require-atomic-updates
|
|
219
|
-
resultBox.innerHTML = buildSearchResult(result)
|
|
219
|
+
resultBox.innerHTML = buildSearchResult(result)
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
function onDomContentLoaded() {
|
|
223
|
-
const searchButton = document.querySelectorAll('.search-button')
|
|
224
|
-
const debouncedSearch = debounce(search, 300)
|
|
222
|
+
function onDomContentLoaded () {
|
|
223
|
+
const searchButton = document.querySelectorAll('.search-button')
|
|
224
|
+
const debouncedSearch = debounce(search, 300)
|
|
225
225
|
|
|
226
226
|
if (searchCloseButton) {
|
|
227
|
-
searchCloseButton.addEventListener('click', hideSearch)
|
|
227
|
+
searchCloseButton.addEventListener('click', hideSearch)
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
if (searchButton) {
|
|
231
|
-
searchButton.forEach(function(item) {
|
|
232
|
-
item.addEventListener('click', showSearch)
|
|
233
|
-
})
|
|
231
|
+
searchButton.forEach(function (item) {
|
|
232
|
+
item.addEventListener('click', showSearch)
|
|
233
|
+
})
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
if (searchContainer) {
|
|
237
|
-
searchContainer.addEventListener('click', hideSearch)
|
|
237
|
+
searchContainer.addEventListener('click', hideSearch)
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
if (searchWrapper) {
|
|
241
|
-
searchWrapper.addEventListener('click', function(event) {
|
|
242
|
-
event.stopPropagation()
|
|
243
|
-
})
|
|
241
|
+
searchWrapper.addEventListener('click', function (event) {
|
|
242
|
+
event.stopPropagation()
|
|
243
|
+
})
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
if (searchInput) {
|
|
247
|
-
searchInput.addEventListener('keyup', debouncedSearch)
|
|
247
|
+
searchInput.addEventListener('keyup', debouncedSearch)
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
// eslint-disable-next-line no-undef
|
|
251
251
|
if (window.location.hash === searchHash) {
|
|
252
|
-
showSearch()
|
|
252
|
+
showSearch()
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
// eslint-disable-next-line no-undef
|
|
257
|
-
window.addEventListener('DOMContentLoaded', onDomContentLoaded)
|
|
257
|
+
window.addEventListener('DOMContentLoaded', onDomContentLoaded)
|
|
258
258
|
|
|
259
259
|
// eslint-disable-next-line no-undef
|
|
260
|
-
window.addEventListener('hashchange', function() {
|
|
260
|
+
window.addEventListener('hashchange', function () {
|
|
261
261
|
// eslint-disable-next-line no-undef
|
|
262
262
|
if (window.location.hash === searchHash) {
|
|
263
|
-
showSearch()
|
|
263
|
+
showSearch()
|
|
264
264
|
}
|
|
265
|
-
})
|
|
265
|
+
})
|
|
File without changes
|
|
File without changes
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
8
|
*/
|
|
9
|
-
var e,t;e=this,t=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=s(e);if(t){var i=s(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return h(this,n)}}function l(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function v(e){return Array.isArray?Array.isArray(e):"[object Array]"===b(e)}function g(e){return"string"==typeof e}function y(e){return"number"==typeof e}function p(e){return!0===e||!1===e||function(e){return m(e)&&null!==e}(e)&&"[object Boolean]"==b(e)}function m(t){return"object"===e(t)}function k(e){return null!=e}function M(e){return!e.trim().length}function b(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var x=function(e){return"Invalid value for key ".concat(e)},L=function(e){return"Pattern length exceeds max of ".concat(e,".")},S=Object.prototype.hasOwnProperty,w=function(){function e(n){var r=this;t(this,e),this._keys=[],this._keyMap={};var i=0;n.forEach((function(e){var t=_(e);i+=t.weight,r._keys.push(t),r._keyMap[t.id]=t,i+=t.weight})),this._keys.forEach((function(e){e.weight/=i}))}return r(e,[{key:"get",value:function(e){return this._keyMap[e]}},{key:"keys",value:function(){return this._keys}},{key:"toJSON",value:function(){return JSON.stringify(this._keys)}}]),e}();function _(e){var t=null,n=null,r=null,i=1;if(g(e)||v(e))r=e,t=O(e),n=j(e);else{if(!S.call(e,"name"))throw new Error(function(e){return"Missing ".concat(e," property in key")}("name"));var o=e.name;if(r=o,S.call(e,"weight")&&(i=e.weight)<=0)throw new Error(function(e){return"Property 'weight' in key '".concat(e,"' must be a positive integer")}(o));t=O(o),n=j(o)}return{path:t,id:n,weight:i,src:r}}function O(e){return v(e)?e:e.split(".")}function j(e){return v(e)?e.join("."):e}var A=c({},{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:function(e,t){return e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1}},{},{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},{},{location:0,threshold:.6,distance:100},{},{useExtendedSearch:!1,getFn:function(e,t){var n=[],r=!1;return function e(t,i,o){if(k(t))if(i[o]){var c=t[i[o]];if(!k(c))return;if(o===i.length-1&&(g(c)||y(c)||p(c)))n.push(function(e){return null==e?"":function(e){if("string"==typeof e)return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(c));else if(v(c)){r=!0;for(var a=0,s=c.length;a<s;a+=1)e(c[a],i,o+1)}else i.length&&e(c,i,o+1)}else n.push(t)}(e,g(t)?t.split("."):t,0),r?n:n[0]},ignoreLocation:!1,ignoreFieldNorm:!1}),I=/[^ ]+/g;function C(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3,t=new Map,n=Math.pow(10,e);return{get:function(e){var r=e.match(I).length;if(t.has(r))return t.get(r);var i=1/Math.sqrt(r),o=parseFloat(Math.round(i*n)/n);return t.set(r,o),o},clear:function(){t.clear()}}}var E=function(){function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.getFn,i=void 0===r?A.getFn:r;t(this,e),this.norm=C(3),this.getFn=i,this.isCreated=!1,this.setIndexRecords()}return r(e,[{key:"setSources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.docs=e}},{key:"setIndexRecords",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.records=e}},{key:"setKeys",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.keys=t,this._keysMap={},t.forEach((function(t,n){e._keysMap[t.id]=n}))}},{key:"create",value:function(){var e=this;!this.isCreated&&this.docs.length&&(this.isCreated=!0,g(this.docs[0])?this.docs.forEach((function(t,n){e._addString(t,n)})):this.docs.forEach((function(t,n){e._addObject(t,n)})),this.norm.clear())}},{key:"add",value:function(e){var t=this.size();g(e)?this._addString(e,t):this._addObject(e,t)}},{key:"removeAt",value:function(e){this.records.splice(e,1);for(var t=e,n=this.size();t<n;t+=1)this.records[t].i-=1}},{key:"getValueForItemAtKeyId",value:function(e,t){return e[this._keysMap[t]]}},{key:"size",value:function(){return this.records.length}},{key:"_addString",value:function(e,t){if(k(e)&&!M(e)){var n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}}},{key:"_addObject",value:function(e,t){var n=this,r={i:t,$:{}};this.keys.forEach((function(t,i){var o=n.getFn(e,t.path);if(k(o))if(v(o))!function(){for(var e=[],t=[{nestedArrIndex:-1,value:o}];t.length;){var c=t.pop(),a=c.nestedArrIndex,s=c.value;if(k(s))if(g(s)&&!M(s)){var u={v:s,i:a,n:n.norm.get(s)};e.push(u)}else v(s)&&s.forEach((function(e,n){t.push({nestedArrIndex:n,value:e})}))}r.$[i]=e}();else if(!M(o)){var c={v:o,n:n.norm.get(o)};r.$[i]=c}})),this.records.push(r)}},{key:"toJSON",value:function(){return{keys:this.keys,records:this.records}}}]),e}();function $(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.getFn,i=void 0===r?A.getFn:r,o=new E({getFn:i});return o.setKeys(e.map(_)),o.setSources(t),o.create(),o}function R(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.errors,r=void 0===n?0:n,i=t.currentLocation,o=void 0===i?0:i,c=t.expectedLocation,a=void 0===c?0:c,s=t.distance,u=void 0===s?A.distance:s,h=t.ignoreLocation,f=void 0===h?A.ignoreLocation:h,l=r/e.length;if(f)return l;var d=Math.abs(a-o);return u?l+d/u:d?1:l}function F(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:A.minMatchCharLength,n=[],r=-1,i=-1,o=0,c=e.length;o<c;o+=1){var a=e[o];a&&-1===r?r=o:a||-1===r||((i=o-1)-r+1>=t&&n.push([r,i]),r=-1)}return e[o-1]&&o-r>=t&&n.push([r,o-1]),n}function P(e){for(var t={},n=0,r=e.length;n<r;n+=1){var i=e.charAt(n);t[i]=(t[i]||0)|1<<r-n-1}return t}var N=function(){function e(n){var r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=i.location,c=void 0===o?A.location:o,a=i.threshold,s=void 0===a?A.threshold:a,u=i.distance,h=void 0===u?A.distance:u,f=i.includeMatches,l=void 0===f?A.includeMatches:f,d=i.findAllMatches,v=void 0===d?A.findAllMatches:d,g=i.minMatchCharLength,y=void 0===g?A.minMatchCharLength:g,p=i.isCaseSensitive,m=void 0===p?A.isCaseSensitive:p,k=i.ignoreLocation,M=void 0===k?A.ignoreLocation:k;if(t(this,e),this.options={location:c,threshold:s,distance:h,includeMatches:l,findAllMatches:v,minMatchCharLength:y,isCaseSensitive:m,ignoreLocation:M},this.pattern=m?n:n.toLowerCase(),this.chunks=[],this.pattern.length){var b=function(e,t){r.chunks.push({pattern:e,alphabet:P(e),startIndex:t})},x=this.pattern.length;if(x>32){for(var L=0,S=x%32,w=x-S;L<w;)b(this.pattern.substr(L,32),L),L+=32;if(S){var _=x-32;b(this.pattern.substr(_),_)}}else b(this.pattern,0)}}return r(e,[{key:"searchIn",value:function(e){var t=this.options,n=t.isCaseSensitive,r=t.includeMatches;if(n||(e=e.toLowerCase()),this.pattern===e){var i={isMatch:!0,score:0};return r&&(i.indices=[[0,e.length-1]]),i}var o=this.options,c=o.location,a=o.distance,s=o.threshold,u=o.findAllMatches,h=o.minMatchCharLength,f=o.ignoreLocation,d=[],v=0,g=!1;this.chunks.forEach((function(t){var n=t.pattern,i=t.alphabet,o=t.startIndex,y=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=r.location,o=void 0===i?A.location:i,c=r.distance,a=void 0===c?A.distance:c,s=r.threshold,u=void 0===s?A.threshold:s,h=r.findAllMatches,f=void 0===h?A.findAllMatches:h,l=r.minMatchCharLength,d=void 0===l?A.minMatchCharLength:l,v=r.includeMatches,g=void 0===v?A.includeMatches:v,y=r.ignoreLocation,p=void 0===y?A.ignoreLocation:y;if(t.length>32)throw new Error(L(32));for(var m,k=t.length,M=e.length,b=Math.max(0,Math.min(o,M)),x=u,S=b,w=d>1||g,_=w?Array(M):[];(m=e.indexOf(t,S))>-1;){var O=R(t,{currentLocation:m,expectedLocation:b,distance:a,ignoreLocation:p});if(x=Math.min(O,x),S=m+k,w)for(var j=0;j<k;)_[m+j]=1,j+=1}S=-1;for(var I=[],C=1,E=k+M,$=1<<k-1,P=0;P<k;P+=1){for(var N=0,D=E;N<D;){var z=R(t,{errors:P,currentLocation:b+D,expectedLocation:b,distance:a,ignoreLocation:p});z<=x?N=D:E=D,D=Math.floor((E-N)/2+N)}E=D;var K=Math.max(1,b-D+1),q=f?M:Math.min(b+D,M)+k,W=Array(q+2);W[q+1]=(1<<P)-1;for(var J=q;J>=K;J-=1){var T=J-1,U=n[e.charAt(T)];if(w&&(_[T]=+!!U),W[J]=(W[J+1]<<1|1)&U,P&&(W[J]|=(I[J+1]|I[J])<<1|1|I[J+1]),W[J]&$&&(C=R(t,{errors:P,currentLocation:T,expectedLocation:b,distance:a,ignoreLocation:p}))<=x){if(x=C,(S=T)<=b)break;K=Math.max(1,2*b-S)}}var V=R(t,{errors:P+1,currentLocation:b,expectedLocation:b,distance:a,ignoreLocation:p});if(V>x)break;I=W}var B={isMatch:S>=0,score:Math.max(.001,C)};if(w){var G=F(_,d);G.length?g&&(B.indices=G):B.isMatch=!1}return B}(e,n,i,{location:c+o,distance:a,threshold:s,findAllMatches:u,minMatchCharLength:h,includeMatches:r,ignoreLocation:f}),p=y.isMatch,m=y.score,k=y.indices;p&&(g=!0),v+=m,p&&k&&(d=[].concat(l(d),l(k)))}));var y={isMatch:g,score:g?v/this.chunks.length:1};return g&&r&&(y.indices=d),y}}]),e}(),D=function(){function e(n){t(this,e),this.pattern=n}return r(e,[{key:"search",value:function(){}}],[{key:"isMultiMatch",value:function(e){return z(e,this.multiRegex)}},{key:"isSingleMatch",value:function(e){return z(e,this.singleRegex)}}]),e}();function z(e,t){var n=e.match(t);return n?n[1]:null}var K=function(e){a(i,e);var n=f(i);function i(e){return t(this,i),n.call(this,e)}return r(i,[{key:"search",value:function(e){var t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}],[{key:"type",get:function(){return"exact"}},{key:"multiRegex",get:function(){return/^="(.*)"$/}},{key:"singleRegex",get:function(){return/^=(.*)$/}}]),i}(D),q=function(e){a(i,e);var n=f(i);function i(e){return t(this,i),n.call(this,e)}return r(i,[{key:"search",value:function(e){var t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-exact"}},{key:"multiRegex",get:function(){return/^!"(.*)"$/}},{key:"singleRegex",get:function(){return/^!(.*)$/}}]),i}(D),W=function(e){a(i,e);var n=f(i);function i(e){return t(this,i),n.call(this,e)}return r(i,[{key:"search",value:function(e){var t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}],[{key:"type",get:function(){return"prefix-exact"}},{key:"multiRegex",get:function(){return/^\^"(.*)"$/}},{key:"singleRegex",get:function(){return/^\^(.*)$/}}]),i}(D),J=function(e){a(i,e);var n=f(i);function i(e){return t(this,i),n.call(this,e)}return r(i,[{key:"search",value:function(e){var t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-prefix-exact"}},{key:"multiRegex",get:function(){return/^!\^"(.*)"$/}},{key:"singleRegex",get:function(){return/^!\^(.*)$/}}]),i}(D),T=function(e){a(i,e);var n=f(i);function i(e){return t(this,i),n.call(this,e)}return r(i,[{key:"search",value:function(e){var t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}],[{key:"type",get:function(){return"suffix-exact"}},{key:"multiRegex",get:function(){return/^"(.*)"\$$/}},{key:"singleRegex",get:function(){return/^(.*)\$$/}}]),i}(D),U=function(e){a(i,e);var n=f(i);function i(e){return t(this,i),n.call(this,e)}return r(i,[{key:"search",value:function(e){var t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-suffix-exact"}},{key:"multiRegex",get:function(){return/^!"(.*)"\$$/}},{key:"singleRegex",get:function(){return/^!(.*)\$$/}}]),i}(D),V=function(e){a(i,e);var n=f(i);function i(e){var r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=o.location,a=void 0===c?A.location:c,s=o.threshold,u=void 0===s?A.threshold:s,h=o.distance,f=void 0===h?A.distance:h,l=o.includeMatches,d=void 0===l?A.includeMatches:l,v=o.findAllMatches,g=void 0===v?A.findAllMatches:v,y=o.minMatchCharLength,p=void 0===y?A.minMatchCharLength:y,m=o.isCaseSensitive,k=void 0===m?A.isCaseSensitive:m,M=o.ignoreLocation,b=void 0===M?A.ignoreLocation:M;return t(this,i),(r=n.call(this,e))._bitapSearch=new N(e,{location:a,threshold:u,distance:f,includeMatches:d,findAllMatches:g,minMatchCharLength:p,isCaseSensitive:k,ignoreLocation:b}),r}return r(i,[{key:"search",value:function(e){return this._bitapSearch.searchIn(e)}}],[{key:"type",get:function(){return"fuzzy"}},{key:"multiRegex",get:function(){return/^"(.*)"$/}},{key:"singleRegex",get:function(){return/^(.*)$/}}]),i}(D),B=function(e){a(i,e);var n=f(i);function i(e){return t(this,i),n.call(this,e)}return r(i,[{key:"search",value:function(e){for(var t,n=0,r=[],i=this.pattern.length;(t=e.indexOf(this.pattern,n))>-1;)n=t+i,r.push([t,n-1]);var o=!!r.length;return{isMatch:o,score:o?0:1,indices:r}}}],[{key:"type",get:function(){return"include"}},{key:"multiRegex",get:function(){return/^'"(.*)"$/}},{key:"singleRegex",get:function(){return/^'(.*)$/}}]),i}(D),G=[K,B,W,J,U,T,q,V],H=G.length,Q=/ +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/;function X(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.split("|").map((function(e){for(var n=e.trim().split(Q).filter((function(e){return e&&!!e.trim()})),r=[],i=0,o=n.length;i<o;i+=1){for(var c=n[i],a=!1,s=-1;!a&&++s<H;){var u=G[s],h=u.isMultiMatch(c);h&&(r.push(new u(h,t)),a=!0)}if(!a)for(s=-1;++s<H;){var f=G[s],l=f.isSingleMatch(c);if(l){r.push(new f(l,t));break}}}return r}))}var Y=new Set([V.type,B.type]),Z=function(){function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.isCaseSensitive,o=void 0===i?A.isCaseSensitive:i,c=r.includeMatches,a=void 0===c?A.includeMatches:c,s=r.minMatchCharLength,u=void 0===s?A.minMatchCharLength:s,h=r.ignoreLocation,f=void 0===h?A.ignoreLocation:h,l=r.findAllMatches,d=void 0===l?A.findAllMatches:l,v=r.location,g=void 0===v?A.location:v,y=r.threshold,p=void 0===y?A.threshold:y,m=r.distance,k=void 0===m?A.distance:m;t(this,e),this.query=null,this.options={isCaseSensitive:o,includeMatches:a,minMatchCharLength:u,findAllMatches:d,ignoreLocation:f,location:g,threshold:p,distance:k},this.pattern=o?n:n.toLowerCase(),this.query=X(this.pattern,this.options)}return r(e,[{key:"searchIn",value:function(e){var t=this.query;if(!t)return{isMatch:!1,score:1};var n=this.options,r=n.includeMatches;e=n.isCaseSensitive?e:e.toLowerCase();for(var i=0,o=[],c=0,a=0,s=t.length;a<s;a+=1){var u=t[a];o.length=0,i=0;for(var h=0,f=u.length;h<f;h+=1){var d=u[h],v=d.search(e),g=v.isMatch,y=v.indices,p=v.score;if(!g){c=0,i=0,o.length=0;break}if(i+=1,c+=p,r){var m=d.constructor.type;Y.has(m)?o=[].concat(l(o),l(y)):o.push(y)}}if(i){var k={isMatch:!0,score:c/i};return r&&(k.indices=o),k}}return{isMatch:!1,score:1}}}],[{key:"condition",value:function(e,t){return t.useExtendedSearch}}]),e}(),ee=[];function te(e,t){for(var n=0,r=ee.length;n<r;n+=1){var i=ee[n];if(i.condition(e,t))return new i(e,t)}return new N(e,t)}var ne="$and",re="$or",ie="$path",oe="$val",ce=function(e){return!(!e[ne]&&!e[re])},ae=function(e){return!!e[ie]},se=function(e){return!v(e)&&m(e)&&!ce(e)},ue=function(e){return i({},ne,Object.keys(e).map((function(t){return i({},t,e[t])})))};function he(e,t){var n=t.ignoreFieldNorm,r=void 0===n?A.ignoreFieldNorm:n;e.forEach((function(e){var t=1;e.matches.forEach((function(e){var n=e.key,i=e.norm,o=e.score,c=n?n.weight:null;t*=Math.pow(0===o&&c?Number.EPSILON:o,(c||1)*(r?1:i))})),e.score=t}))}function fe(e,t){var n=e.matches;t.matches=[],k(n)&&n.forEach((function(e){if(k(e.indices)&&e.indices.length){var n={indices:e.indices,value:e.value};e.key&&(n.key=e.key.src),e.idx>-1&&(n.refIndex=e.idx),t.matches.push(n)}}))}function le(e,t){t.score=e.score}function de(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.includeMatches,i=void 0===r?A.includeMatches:r,o=n.includeScore,c=void 0===o?A.includeScore:o,a=[];return i&&a.push(fe),c&&a.push(le),e.map((function(e){var n=e.idx,r={item:t[n],refIndex:n};return a.length&&a.forEach((function(t){t(e,r)})),r}))}var ve=function(){function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;t(this,e),this.options=c({},A,{},r),this.options.useExtendedSearch,this._keyStore=new w(this.options.keys),this.setCollection(n,i)}return r(e,[{key:"setCollection",value:function(e,t){if(this._docs=e,t&&!(t instanceof E))throw new Error("Incorrect 'index' type");this._myIndex=t||$(this.options.keys,this._docs,{getFn:this.options.getFn})}},{key:"add",value:function(e){k(e)&&(this._docs.push(e),this._myIndex.add(e))}},{key:"remove",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},t=[],n=0,r=this._docs.length;n<r;n+=1){var i=this._docs[n];e(i,n)&&(this.removeAt(n),n-=1,r-=1,t.push(i))}return t}},{key:"removeAt",value:function(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}},{key:"getIndex",value:function(){return this._myIndex}},{key:"search",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.limit,r=void 0===n?-1:n,i=this.options,o=i.includeMatches,c=i.includeScore,a=i.shouldSort,s=i.sortFn,u=i.ignoreFieldNorm,h=g(e)?g(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return he(h,{ignoreFieldNorm:u}),a&&h.sort(s),y(r)&&r>-1&&(h=h.slice(0,r)),de(h,this._docs,{includeMatches:o,includeScore:c})}},{key:"_searchStringList",value:function(e){var t=te(e,this.options),n=this._myIndex.records,r=[];return n.forEach((function(e){var n=e.v,i=e.i,o=e.n;if(k(n)){var c=t.searchIn(n),a=c.isMatch,s=c.score,u=c.indices;a&&r.push({item:n,idx:i,matches:[{score:s,value:n,norm:o,indices:u}]})}})),r}},{key:"_searchLogical",value:function(e){var t=this,n=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.auto,i=void 0===r||r,o=function e(n){var r=Object.keys(n),o=ae(n);if(!o&&r.length>1&&!ce(n))return e(ue(n));if(se(n)){var c=o?n[ie]:r[0],a=o?n[oe]:n[c];if(!g(a))throw new Error(x(c));var s={keyId:j(c),pattern:a};return i&&(s.searcher=te(a,t)),s}var u={children:[],operator:r[0]};return r.forEach((function(t){var r=n[t];v(r)&&r.forEach((function(t){u.children.push(e(t))}))})),u};return ce(e)||(e=ue(e)),o(e)}(e,this.options),r=this._myIndex.records,i={},o=[];return r.forEach((function(e){var r=e.$,c=e.i;if(k(r)){var a=function e(n,r,i){if(!n.children){var o=n.keyId,c=n.searcher,a=t._findMatches({key:t._keyStore.get(o),value:t._myIndex.getValueForItemAtKeyId(r,o),searcher:c});return a&&a.length?[{idx:i,item:r,matches:a}]:[]}switch(n.operator){case ne:for(var s=[],u=0,h=n.children.length;u<h;u+=1){var f=e(n.children[u],r,i);if(!f.length)return[];s.push.apply(s,l(f))}return s;case re:for(var d=[],v=0,g=n.children.length;v<g;v+=1){var y=e(n.children[v],r,i);if(y.length){d.push.apply(d,l(y));break}}return d}}(n,r,c);a.length&&(i[c]||(i[c]={idx:c,item:r,matches:[]},o.push(i[c])),a.forEach((function(e){var t,n=e.matches;(t=i[c].matches).push.apply(t,l(n))})))}})),o}},{key:"_searchObjectList",value:function(e){var t=this,n=te(e,this.options),r=this._myIndex,i=r.keys,o=r.records,c=[];return o.forEach((function(e){var r=e.$,o=e.i;if(k(r)){var a=[];i.forEach((function(e,i){a.push.apply(a,l(t._findMatches({key:e,value:r[i],searcher:n})))})),a.length&&c.push({idx:o,item:r,matches:a})}})),c}},{key:"_findMatches",value:function(e){var t=e.key,n=e.value,r=e.searcher;if(!k(n))return[];var i=[];if(v(n))n.forEach((function(e){var n=e.v,o=e.i,c=e.n;if(k(n)){var a=r.searchIn(n),s=a.isMatch,u=a.score,h=a.indices;s&&i.push({score:u,key:t,value:n,idx:o,norm:c,indices:h})}}));else{var o=n.v,c=n.n,a=r.searchIn(o),s=a.isMatch,u=a.score,h=a.indices;s&&i.push({score:u,key:t,value:o,norm:c,indices:h})}return i}}]),e}();return ve.version="6.4.6",ve.createIndex=$,ve.parseIndex=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.getFn,r=void 0===n?A.getFn:n,i=e.keys,o=e.records,c=new E({getFn:r});return c.setKeys(i),c.setIndexRecords(o),c},ve.config=A,function(){ee.push.apply(ee,arguments)}(Z),ve},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Fuse=t();
|
|
9
|
+
let e, t; e = this, t = function () { 'use strict'; function e (t) { return (e = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? function (e) { return typeof e } : function (e) { return e && typeof Symbol === 'function' && e.constructor === Symbol && e !== Symbol.prototype ? 'symbol' : typeof e })(t) } function t (e, t) { if (!(e instanceof t)) throw new TypeError('Cannot call a class as a function') } function n (e, t) { for (let n = 0; n < t.length; n++) { const r = t[n]; r.enumerable = r.enumerable || !1, r.configurable = !0, 'value' in r && (r.writable = !0), Object.defineProperty(e, r.key, r) } } function r (e, t, r) { return t && n(e.prototype, t), r && n(e, r), e } function i (e, t, n) { return t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e } function o (e, t) { const n = Object.keys(e); if (Object.getOwnPropertySymbols) { let r = Object.getOwnPropertySymbols(e); t && (r = r.filter(function (t) { return Object.getOwnPropertyDescriptor(e, t).enumerable })), n.push.apply(n, r) } return n } function c (e) { for (let t = 1; t < arguments.length; t++) { var n = arguments[t] != null ? arguments[t] : {}; t % 2 ? o(Object(n), !0).forEach(function (t) { i(e, t, n[t]) }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : o(Object(n)).forEach(function (t) { Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t)) }) } return e } function a (e, t) { if (typeof t !== 'function' && t !== null) throw new TypeError('Super expression must either be null or a function'); e.prototype = Object.create(t && t.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), t && u(e, t) } function s (e) { return (s = Object.setPrototypeOf ? Object.getPrototypeOf : function (e) { return e.__proto__ || Object.getPrototypeOf(e) })(e) } function u (e, t) { return (u = Object.setPrototypeOf || function (e, t) { return e.__proto__ = t, e })(e, t) } function h (e, t) { return !t || typeof t !== 'object' && typeof t !== 'function' ? (function (e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e }(e)) : t } function f (e) { const t = (function () { if (typeof Reflect === 'undefined' || !Reflect.construct) return !1; if (Reflect.construct.sham) return !1; if (typeof Proxy === 'function') return !0; try { return Date.prototype.toString.call(Reflect.construct(Date, [], function () {})), !0 } catch (e) { return !1 } }()); return function () { let n; const r = s(e); if (t) { const i = s(this).constructor; n = Reflect.construct(r, arguments, i) } else n = r.apply(this, arguments); return h(this, n) } } function l (e) { return (function (e) { if (Array.isArray(e)) return d(e) }(e)) || (function (e) { if (typeof Symbol !== 'undefined' && Symbol.iterator in Object(e)) return Array.from(e) }(e)) || (function (e, t) { if (e) { if (typeof e === 'string') return d(e, t); let n = Object.prototype.toString.call(e).slice(8, -1); return n === 'Object' && e.constructor && (n = e.constructor.name), n === 'Map' || n === 'Set' ? Array.from(e) : n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? d(e, t) : void 0 } }(e)) || (function () { throw new TypeError('Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.') }()) } function d (e, t) { (t == null || t > e.length) && (t = e.length); for (var n = 0, r = new Array(t); n < t; n++)r[n] = e[n]; return r } function v (e) { return Array.isArray ? Array.isArray(e) : b(e) === '[object Array]' } function g (e) { return typeof e === 'string' } function y (e) { return typeof e === 'number' } function p (e) { return !0 === e || !1 === e || (function (e) { return m(e) && e !== null }(e)) && b(e) == '[object Boolean]' } function m (t) { return e(t) === 'object' } function k (e) { return e != null } function M (e) { return !e.trim().length } function b (e) { return e == null ? void 0 === e ? '[object Undefined]' : '[object Null]' : Object.prototype.toString.call(e) } const x = function (e) { return 'Invalid value for key '.concat(e) }; const L = function (e) { return 'Pattern length exceeds max of '.concat(e, '.') }; const S = Object.prototype.hasOwnProperty; const w = (function () { function e (n) { const r = this; t(this, e), this._keys = [], this._keyMap = {}; let i = 0; n.forEach(function (e) { const t = _(e); i += t.weight, r._keys.push(t), r._keyMap[t.id] = t, i += t.weight }), this._keys.forEach(function (e) { e.weight /= i }) } return r(e, [{ key: 'get', value: function (e) { return this._keyMap[e] } }, { key: 'keys', value: function () { return this._keys } }, { key: 'toJSON', value: function () { return JSON.stringify(this._keys) } }]), e }()); function _ (e) { let t = null; let n = null; let r = null; let i = 1; if (g(e) || v(e))r = e, t = O(e), n = j(e); else { if (!S.call(e, 'name')) throw new Error(function (e) { return 'Missing '.concat(e, ' property in key') }('name')); const o = e.name; if (r = o, S.call(e, 'weight') && (i = e.weight) <= 0) throw new Error(function (e) { return "Property 'weight' in key '".concat(e, "' must be a positive integer") }(o)); t = O(o), n = j(o) } return { path: t, id: n, weight: i, src: r } } function O (e) { return v(e) ? e : e.split('.') } function j (e) { return v(e) ? e.join('.') : e } const A = c({}, { isCaseSensitive: !1, includeScore: !1, keys: [], shouldSort: !0, sortFn: function (e, t) { return e.score === t.score ? e.idx < t.idx ? -1 : 1 : e.score < t.score ? -1 : 1 } }, {}, { includeMatches: !1, findAllMatches: !1, minMatchCharLength: 1 }, {}, { location: 0, threshold: 0.6, distance: 100 }, {}, { useExtendedSearch: !1, getFn: function (e, t) { const n = []; let r = !1; return (function e (t, i, o) { if (k(t)) if (i[o]) { const c = t[i[o]]; if (!k(c)) return; if (o === i.length - 1 && (g(c) || y(c) || p(c)))n.push(function (e) { return e == null ? '' : (function (e) { if (typeof e === 'string') return e; const t = e + ''; return t == '0' && 1 / e == -1 / 0 ? '-0' : t }(e)) }(c)); else if (v(c)) { r = !0; for (let a = 0, s = c.length; a < s; a += 1)e(c[a], i, o + 1) } else i.length && e(c, i, o + 1) } else n.push(t) }(e, g(t) ? t.split('.') : t, 0)), r ? n : n[0] }, ignoreLocation: !1, ignoreFieldNorm: !1 }); const I = /[^ ]+/g; function C () { const e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 3; const t = new Map(); const n = Math.pow(10, e); return { get: function (e) { const r = e.match(I).length; if (t.has(r)) return t.get(r); const i = 1 / Math.sqrt(r); const o = parseFloat(Math.round(i * n) / n); return t.set(r, o), o }, clear: function () { t.clear() } } } const E = (function () { function e () { const n = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; const r = n.getFn; const i = void 0 === r ? A.getFn : r; t(this, e), this.norm = C(3), this.getFn = i, this.isCreated = !1, this.setIndexRecords() } return r(e, [{ key: 'setSources', value: function () { const e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : []; this.docs = e } }, { key: 'setIndexRecords', value: function () { const e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : []; this.records = e } }, { key: 'setKeys', value: function () { const e = this; const t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : []; this.keys = t, this._keysMap = {}, t.forEach(function (t, n) { e._keysMap[t.id] = n }) } }, { key: 'create', value: function () { const e = this; !this.isCreated && this.docs.length && (this.isCreated = !0, g(this.docs[0]) ? this.docs.forEach(function (t, n) { e._addString(t, n) }) : this.docs.forEach(function (t, n) { e._addObject(t, n) }), this.norm.clear()) } }, { key: 'add', value: function (e) { const t = this.size(); g(e) ? this._addString(e, t) : this._addObject(e, t) } }, { key: 'removeAt', value: function (e) { this.records.splice(e, 1); for (let t = e, n = this.size(); t < n; t += 1) this.records[t].i -= 1 } }, { key: 'getValueForItemAtKeyId', value: function (e, t) { return e[this._keysMap[t]] } }, { key: 'size', value: function () { return this.records.length } }, { key: '_addString', value: function (e, t) { if (k(e) && !M(e)) { const n = { v: e, i: t, n: this.norm.get(e) }; this.records.push(n) } } }, { key: '_addObject', value: function (e, t) { const n = this; const r = { i: t, $: {} }; this.keys.forEach(function (t, i) { const o = n.getFn(e, t.path); if (k(o)) if (v(o))!(function () { for (var e = [], t = [{ nestedArrIndex: -1, value: o }]; t.length;) { const c = t.pop(); const a = c.nestedArrIndex; const s = c.value; if (k(s)) if (g(s) && !M(s)) { const u = { v: s, i: a, n: n.norm.get(s) }; e.push(u) } else v(s) && s.forEach(function (e, n) { t.push({ nestedArrIndex: n, value: e }) }) }r.$[i] = e }()); else if (!M(o)) { const c = { v: o, n: n.norm.get(o) }; r.$[i] = c } }), this.records.push(r) } }, { key: 'toJSON', value: function () { return { keys: this.keys, records: this.records } } }]), e }()); function $ (e, t) { const n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}; const r = n.getFn; const i = void 0 === r ? A.getFn : r; const o = new E({ getFn: i }); return o.setKeys(e.map(_)), o.setSources(t), o.create(), o } function R (e) { const t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; const n = t.errors; const r = void 0 === n ? 0 : n; const i = t.currentLocation; const o = void 0 === i ? 0 : i; const c = t.expectedLocation; const a = void 0 === c ? 0 : c; const s = t.distance; const u = void 0 === s ? A.distance : s; const h = t.ignoreLocation; const f = void 0 === h ? A.ignoreLocation : h; const l = r / e.length; if (f) return l; const d = Math.abs(a - o); return u ? l + d / u : d ? 1 : l } function F () { for (var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [], t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : A.minMatchCharLength, n = [], r = -1, i = -1, o = 0, c = e.length; o < c; o += 1) { const a = e[o]; a && r === -1 ? r = o : a || r === -1 || ((i = o - 1) - r + 1 >= t && n.push([r, i]), r = -1) } return e[o - 1] && o - r >= t && n.push([r, o - 1]), n } function P (e) { for (var t = {}, n = 0, r = e.length; n < r; n += 1) { const i = e.charAt(n); t[i] = (t[i] || 0) | 1 << r - n - 1 } return t } const N = (function () { function e (n) { const r = this; const i = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; const o = i.location; const c = void 0 === o ? A.location : o; const a = i.threshold; const s = void 0 === a ? A.threshold : a; const u = i.distance; const h = void 0 === u ? A.distance : u; const f = i.includeMatches; const l = void 0 === f ? A.includeMatches : f; const d = i.findAllMatches; const v = void 0 === d ? A.findAllMatches : d; const g = i.minMatchCharLength; const y = void 0 === g ? A.minMatchCharLength : g; const p = i.isCaseSensitive; const m = void 0 === p ? A.isCaseSensitive : p; const k = i.ignoreLocation; const M = void 0 === k ? A.ignoreLocation : k; if (t(this, e), this.options = { location: c, threshold: s, distance: h, includeMatches: l, findAllMatches: v, minMatchCharLength: y, isCaseSensitive: m, ignoreLocation: M }, this.pattern = m ? n : n.toLowerCase(), this.chunks = [], this.pattern.length) { const b = function (e, t) { r.chunks.push({ pattern: e, alphabet: P(e), startIndex: t }) }; const x = this.pattern.length; if (x > 32) { for (var L = 0, S = x % 32, w = x - S; L < w;)b(this.pattern.substr(L, 32), L), L += 32; if (S) { const _ = x - 32; b(this.pattern.substr(_), _) } } else b(this.pattern, 0) } } return r(e, [{ key: 'searchIn', value: function (e) { const t = this.options; const n = t.isCaseSensitive; const r = t.includeMatches; if (n || (e = e.toLowerCase()), this.pattern === e) { const i = { isMatch: !0, score: 0 }; return r && (i.indices = [[0, e.length - 1]]), i } const o = this.options; const c = o.location; const a = o.distance; const s = o.threshold; const u = o.findAllMatches; const h = o.minMatchCharLength; const f = o.ignoreLocation; let d = []; let v = 0; let g = !1; this.chunks.forEach(function (t) { const n = t.pattern; const i = t.alphabet; const o = t.startIndex; const y = (function (e, t, n) { const r = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {}; const i = r.location; const o = void 0 === i ? A.location : i; const c = r.distance; const a = void 0 === c ? A.distance : c; const s = r.threshold; const u = void 0 === s ? A.threshold : s; const h = r.findAllMatches; const f = void 0 === h ? A.findAllMatches : h; const l = r.minMatchCharLength; const d = void 0 === l ? A.minMatchCharLength : l; const v = r.includeMatches; const g = void 0 === v ? A.includeMatches : v; const y = r.ignoreLocation; const p = void 0 === y ? A.ignoreLocation : y; if (t.length > 32) throw new Error(L(32)); for (var m, k = t.length, M = e.length, b = Math.max(0, Math.min(o, M)), x = u, S = b, w = d > 1 || g, _ = w ? Array(M) : []; (m = e.indexOf(t, S)) > -1;) { const O = R(t, { currentLocation: m, expectedLocation: b, distance: a, ignoreLocation: p }); if (x = Math.min(O, x), S = m + k, w) for (let j = 0; j < k;)_[m + j] = 1, j += 1 }S = -1; for (var I = [], C = 1, E = k + M, $ = 1 << k - 1, P = 0; P < k; P += 1) { for (var N = 0, D = E; N < D;) { const z = R(t, { errors: P, currentLocation: b + D, expectedLocation: b, distance: a, ignoreLocation: p }); z <= x ? N = D : E = D, D = Math.floor((E - N) / 2 + N) }E = D; let K = Math.max(1, b - D + 1); const q = f ? M : Math.min(b + D, M) + k; const W = Array(q + 2); W[q + 1] = (1 << P) - 1; for (let J = q; J >= K; J -= 1) { const T = J - 1; const U = n[e.charAt(T)]; if (w && (_[T] = +!!U), W[J] = (W[J + 1] << 1 | 1) & U, P && (W[J] |= (I[J + 1] | I[J]) << 1 | 1 | I[J + 1]), W[J] & $ && (C = R(t, { errors: P, currentLocation: T, expectedLocation: b, distance: a, ignoreLocation: p })) <= x) { if (x = C, (S = T) <= b) break; K = Math.max(1, 2 * b - S) } } const V = R(t, { errors: P + 1, currentLocation: b, expectedLocation: b, distance: a, ignoreLocation: p }); if (V > x) break; I = W } const B = { isMatch: S >= 0, score: Math.max(0.001, C) }; if (w) { const G = F(_, d); G.length ? g && (B.indices = G) : B.isMatch = !1 } return B }(e, n, i, { location: c + o, distance: a, threshold: s, findAllMatches: u, minMatchCharLength: h, includeMatches: r, ignoreLocation: f })); const p = y.isMatch; const m = y.score; const k = y.indices; p && (g = !0), v += m, p && k && (d = [].concat(l(d), l(k))) }); const y = { isMatch: g, score: g ? v / this.chunks.length : 1 }; return g && r && (y.indices = d), y } }]), e }()); const D = (function () { function e (n) { t(this, e), this.pattern = n } return r(e, [{ key: 'search', value: function () {} }], [{ key: 'isMultiMatch', value: function (e) { return z(e, this.multiRegex) } }, { key: 'isSingleMatch', value: function (e) { return z(e, this.singleRegex) } }]), e }()); function z (e, t) { const n = e.match(t); return n ? n[1] : null } const K = (function (e) { a(i, e); const n = f(i); function i (e) { return t(this, i), n.call(this, e) } return r(i, [{ key: 'search', value: function (e) { const t = e === this.pattern; return { isMatch: t, score: t ? 0 : 1, indices: [0, this.pattern.length - 1] } } }], [{ key: 'type', get: function () { return 'exact' } }, { key: 'multiRegex', get: function () { return /^="(.*)"$/ } }, { key: 'singleRegex', get: function () { return /^=(.*)$/ } }]), i }(D)); const q = (function (e) { a(i, e); const n = f(i); function i (e) { return t(this, i), n.call(this, e) } return r(i, [{ key: 'search', value: function (e) { const t = e.indexOf(this.pattern) === -1; return { isMatch: t, score: t ? 0 : 1, indices: [0, e.length - 1] } } }], [{ key: 'type', get: function () { return 'inverse-exact' } }, { key: 'multiRegex', get: function () { return /^!"(.*)"$/ } }, { key: 'singleRegex', get: function () { return /^!(.*)$/ } }]), i }(D)); const W = (function (e) { a(i, e); const n = f(i); function i (e) { return t(this, i), n.call(this, e) } return r(i, [{ key: 'search', value: function (e) { const t = e.startsWith(this.pattern); return { isMatch: t, score: t ? 0 : 1, indices: [0, this.pattern.length - 1] } } }], [{ key: 'type', get: function () { return 'prefix-exact' } }, { key: 'multiRegex', get: function () { return /^\^"(.*)"$/ } }, { key: 'singleRegex', get: function () { return /^\^(.*)$/ } }]), i }(D)); const J = (function (e) { a(i, e); const n = f(i); function i (e) { return t(this, i), n.call(this, e) } return r(i, [{ key: 'search', value: function (e) { const t = !e.startsWith(this.pattern); return { isMatch: t, score: t ? 0 : 1, indices: [0, e.length - 1] } } }], [{ key: 'type', get: function () { return 'inverse-prefix-exact' } }, { key: 'multiRegex', get: function () { return /^!\^"(.*)"$/ } }, { key: 'singleRegex', get: function () { return /^!\^(.*)$/ } }]), i }(D)); const T = (function (e) { a(i, e); const n = f(i); function i (e) { return t(this, i), n.call(this, e) } return r(i, [{ key: 'search', value: function (e) { const t = e.endsWith(this.pattern); return { isMatch: t, score: t ? 0 : 1, indices: [e.length - this.pattern.length, e.length - 1] } } }], [{ key: 'type', get: function () { return 'suffix-exact' } }, { key: 'multiRegex', get: function () { return /^"(.*)"\$$/ } }, { key: 'singleRegex', get: function () { return /^(.*)\$$/ } }]), i }(D)); const U = (function (e) { a(i, e); const n = f(i); function i (e) { return t(this, i), n.call(this, e) } return r(i, [{ key: 'search', value: function (e) { const t = !e.endsWith(this.pattern); return { isMatch: t, score: t ? 0 : 1, indices: [0, e.length - 1] } } }], [{ key: 'type', get: function () { return 'inverse-suffix-exact' } }, { key: 'multiRegex', get: function () { return /^!"(.*)"\$$/ } }, { key: 'singleRegex', get: function () { return /^!(.*)\$$/ } }]), i }(D)); const V = (function (e) { a(i, e); const n = f(i); function i (e) { let r; const o = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; const c = o.location; const a = void 0 === c ? A.location : c; const s = o.threshold; const u = void 0 === s ? A.threshold : s; const h = o.distance; const f = void 0 === h ? A.distance : h; const l = o.includeMatches; const d = void 0 === l ? A.includeMatches : l; const v = o.findAllMatches; const g = void 0 === v ? A.findAllMatches : v; const y = o.minMatchCharLength; const p = void 0 === y ? A.minMatchCharLength : y; const m = o.isCaseSensitive; const k = void 0 === m ? A.isCaseSensitive : m; const M = o.ignoreLocation; const b = void 0 === M ? A.ignoreLocation : M; return t(this, i), (r = n.call(this, e))._bitapSearch = new N(e, { location: a, threshold: u, distance: f, includeMatches: d, findAllMatches: g, minMatchCharLength: p, isCaseSensitive: k, ignoreLocation: b }), r } return r(i, [{ key: 'search', value: function (e) { return this._bitapSearch.searchIn(e) } }], [{ key: 'type', get: function () { return 'fuzzy' } }, { key: 'multiRegex', get: function () { return /^"(.*)"$/ } }, { key: 'singleRegex', get: function () { return /^(.*)$/ } }]), i }(D)); const B = (function (e) { a(i, e); const n = f(i); function i (e) { return t(this, i), n.call(this, e) } return r(i, [{ key: 'search', value: function (e) { for (var t, n = 0, r = [], i = this.pattern.length; (t = e.indexOf(this.pattern, n)) > -1;)n = t + i, r.push([t, n - 1]); const o = !!r.length; return { isMatch: o, score: o ? 0 : 1, indices: r } } }], [{ key: 'type', get: function () { return 'include' } }, { key: 'multiRegex', get: function () { return /^'"(.*)"$/ } }, { key: 'singleRegex', get: function () { return /^'(.*)$/ } }]), i }(D)); const G = [K, B, W, J, U, T, q, V]; const H = G.length; const Q = / +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/; function X (e) { const t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; return e.split('|').map(function (e) { for (var n = e.trim().split(Q).filter(function (e) { return e && !!e.trim() }), r = [], i = 0, o = n.length; i < o; i += 1) { for (var c = n[i], a = !1, s = -1; !a && ++s < H;) { const u = G[s]; const h = u.isMultiMatch(c); h && (r.push(new u(h, t)), a = !0) } if (!a) for (s = -1; ++s < H;) { const f = G[s]; const l = f.isSingleMatch(c); if (l) { r.push(new f(l, t)); break } } } return r }) } const Y = new Set([V.type, B.type]); const Z = (function () { function e (n) { const r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; const i = r.isCaseSensitive; const o = void 0 === i ? A.isCaseSensitive : i; const c = r.includeMatches; const a = void 0 === c ? A.includeMatches : c; const s = r.minMatchCharLength; const u = void 0 === s ? A.minMatchCharLength : s; const h = r.ignoreLocation; const f = void 0 === h ? A.ignoreLocation : h; const l = r.findAllMatches; const d = void 0 === l ? A.findAllMatches : l; const v = r.location; const g = void 0 === v ? A.location : v; const y = r.threshold; const p = void 0 === y ? A.threshold : y; const m = r.distance; const k = void 0 === m ? A.distance : m; t(this, e), this.query = null, this.options = { isCaseSensitive: o, includeMatches: a, minMatchCharLength: u, findAllMatches: d, ignoreLocation: f, location: g, threshold: p, distance: k }, this.pattern = o ? n : n.toLowerCase(), this.query = X(this.pattern, this.options) } return r(e, [{ key: 'searchIn', value: function (e) { const t = this.query; if (!t) return { isMatch: !1, score: 1 }; const n = this.options; const r = n.includeMatches; e = n.isCaseSensitive ? e : e.toLowerCase(); for (let i = 0, o = [], c = 0, a = 0, s = t.length; a < s; a += 1) { const u = t[a]; o.length = 0, i = 0; for (let h = 0, f = u.length; h < f; h += 1) { const d = u[h]; const v = d.search(e); const g = v.isMatch; const y = v.indices; const p = v.score; if (!g) { c = 0, i = 0, o.length = 0; break } if (i += 1, c += p, r) { const m = d.constructor.type; Y.has(m) ? o = [].concat(l(o), l(y)) : o.push(y) } } if (i) { const k = { isMatch: !0, score: c / i }; return r && (k.indices = o), k } } return { isMatch: !1, score: 1 } } }], [{ key: 'condition', value: function (e, t) { return t.useExtendedSearch } }]), e }()); const ee = []; function te (e, t) { for (let n = 0, r = ee.length; n < r; n += 1) { const i = ee[n]; if (i.condition(e, t)) return new i(e, t) } return new N(e, t) } const ne = '$and'; const re = '$or'; const ie = '$path'; const oe = '$val'; const ce = function (e) { return !(!e[ne] && !e[re]) }; const ae = function (e) { return !!e[ie] }; const se = function (e) { return !v(e) && m(e) && !ce(e) }; const ue = function (e) { return i({}, ne, Object.keys(e).map(function (t) { return i({}, t, e[t]) })) }; function he (e, t) { const n = t.ignoreFieldNorm; const r = void 0 === n ? A.ignoreFieldNorm : n; e.forEach(function (e) { let t = 1; e.matches.forEach(function (e) { const n = e.key; const i = e.norm; const o = e.score; const c = n ? n.weight : null; t *= Math.pow(o === 0 && c ? Number.EPSILON : o, (c || 1) * (r ? 1 : i)) }), e.score = t }) } function fe (e, t) { const n = e.matches; t.matches = [], k(n) && n.forEach(function (e) { if (k(e.indices) && e.indices.length) { const n = { indices: e.indices, value: e.value }; e.key && (n.key = e.key.src), e.idx > -1 && (n.refIndex = e.idx), t.matches.push(n) } }) } function le (e, t) { t.score = e.score } function de (e, t) { const n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}; const r = n.includeMatches; const i = void 0 === r ? A.includeMatches : r; const o = n.includeScore; const c = void 0 === o ? A.includeScore : o; const a = []; return i && a.push(fe), c && a.push(le), e.map(function (e) { const n = e.idx; const r = { item: t[n], refIndex: n }; return a.length && a.forEach(function (t) { t(e, r) }), r }) } const ve = (function () { function e (n) { const r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; const i = arguments.length > 2 ? arguments[2] : void 0; t(this, e), this.options = c({}, A, {}, r), this.options.useExtendedSearch, this._keyStore = new w(this.options.keys), this.setCollection(n, i) } return r(e, [{ key: 'setCollection', value: function (e, t) { if (this._docs = e, t && !(t instanceof E)) throw new Error("Incorrect 'index' type"); this._myIndex = t || $(this.options.keys, this._docs, { getFn: this.options.getFn }) } }, { key: 'add', value: function (e) { k(e) && (this._docs.push(e), this._myIndex.add(e)) } }, { key: 'remove', value: function () { for (var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : function () { return !1 }, t = [], n = 0, r = this._docs.length; n < r; n += 1) { const i = this._docs[n]; e(i, n) && (this.removeAt(n), n -= 1, r -= 1, t.push(i)) } return t } }, { key: 'removeAt', value: function (e) { this._docs.splice(e, 1), this._myIndex.removeAt(e) } }, { key: 'getIndex', value: function () { return this._myIndex } }, { key: 'search', value: function (e) { const t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; const n = t.limit; const r = void 0 === n ? -1 : n; const i = this.options; const o = i.includeMatches; const c = i.includeScore; const a = i.shouldSort; const s = i.sortFn; const u = i.ignoreFieldNorm; let h = g(e) ? g(this._docs[0]) ? this._searchStringList(e) : this._searchObjectList(e) : this._searchLogical(e); return he(h, { ignoreFieldNorm: u }), a && h.sort(s), y(r) && r > -1 && (h = h.slice(0, r)), de(h, this._docs, { includeMatches: o, includeScore: c }) } }, { key: '_searchStringList', value: function (e) { const t = te(e, this.options); const n = this._myIndex.records; const r = []; return n.forEach(function (e) { const n = e.v; const i = e.i; const o = e.n; if (k(n)) { const c = t.searchIn(n); const a = c.isMatch; const s = c.score; const u = c.indices; a && r.push({ item: n, idx: i, matches: [{ score: s, value: n, norm: o, indices: u }] }) } }), r } }, { key: '_searchLogical', value: function (e) { const t = this; const n = (function (e, t) { const n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}; const r = n.auto; const i = void 0 === r || r; const o = function e (n) { const r = Object.keys(n); const o = ae(n); if (!o && r.length > 1 && !ce(n)) return e(ue(n)); if (se(n)) { const c = o ? n[ie] : r[0]; const a = o ? n[oe] : n[c]; if (!g(a)) throw new Error(x(c)); const s = { keyId: j(c), pattern: a }; return i && (s.searcher = te(a, t)), s } const u = { children: [], operator: r[0] }; return r.forEach(function (t) { const r = n[t]; v(r) && r.forEach(function (t) { u.children.push(e(t)) }) }), u }; return ce(e) || (e = ue(e)), o(e) }(e, this.options)); const r = this._myIndex.records; const i = {}; const o = []; return r.forEach(function (e) { const r = e.$; const c = e.i; if (k(r)) { const a = (function e (n, r, i) { if (!n.children) { const o = n.keyId; const c = n.searcher; const a = t._findMatches({ key: t._keyStore.get(o), value: t._myIndex.getValueForItemAtKeyId(r, o), searcher: c }); return a && a.length ? [{ idx: i, item: r, matches: a }] : [] } switch (n.operator) { case ne:for (var s = [], u = 0, h = n.children.length; u < h; u += 1) { const f = e(n.children[u], r, i); if (!f.length) return []; s.push.apply(s, l(f)) } return s; case re:for (var d = [], v = 0, g = n.children.length; v < g; v += 1) { const y = e(n.children[v], r, i); if (y.length) { d.push.apply(d, l(y)); break } } return d } }(n, r, c)); a.length && (i[c] || (i[c] = { idx: c, item: r, matches: [] }, o.push(i[c])), a.forEach(function (e) { let t; const n = e.matches; (t = i[c].matches).push.apply(t, l(n)) })) } }), o } }, { key: '_searchObjectList', value: function (e) { const t = this; const n = te(e, this.options); const r = this._myIndex; const i = r.keys; const o = r.records; const c = []; return o.forEach(function (e) { const r = e.$; const o = e.i; if (k(r)) { const a = []; i.forEach(function (e, i) { a.push.apply(a, l(t._findMatches({ key: e, value: r[i], searcher: n }))) }), a.length && c.push({ idx: o, item: r, matches: a }) } }), c } }, { key: '_findMatches', value: function (e) { const t = e.key; const n = e.value; const r = e.searcher; if (!k(n)) return []; const i = []; if (v(n))n.forEach(function (e) { const n = e.v; const o = e.i; const c = e.n; if (k(n)) { const a = r.searchIn(n); const s = a.isMatch; const u = a.score; const h = a.indices; s && i.push({ score: u, key: t, value: n, idx: o, norm: c, indices: h }) } }); else { const o = n.v; const c = n.n; const a = r.searchIn(o); const s = a.isMatch; const u = a.score; const h = a.indices; s && i.push({ score: u, key: t, value: o, norm: c, indices: h }) } return i } }]), e }()); return ve.version = '6.4.6', ve.createIndex = $, ve.parseIndex = function (e) { const t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; const n = t.getFn; const r = void 0 === n ? A.getFn : n; const i = e.keys; const o = e.records; const c = new E({ getFn: r }); return c.setKeys(i), c.setIndexRecords(o), c }, ve.config = A, (function () { ee.push.apply(ee, arguments) }(Z)), ve }, typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = t() : typeof define === 'function' && define.amd ? define(t) : (e = e || self).Fuse = t()
|