diff --git a/.obsidian/plugins/obsidian-git/main.js b/.obsidian/plugins/obsidian-git/main.js index 8baa0fd..0d30906 100644 --- a/.obsidian/plugins/obsidian-git/main.js +++ b/.obsidian/plugins/obsidian-git/main.js @@ -41968,12 +41968,12 @@ function instance9($$self, $$props, $$invalidate) { plugin.setState(0 /* idle */); return false; } - plugin.gitManager.commit(commitMessage).then(() => { + plugin.promiseQueue.addTask(() => plugin.gitManager.commit(commitMessage).then(() => { if (commitMessage !== plugin.settings.commitMessage) { $$invalidate(2, commitMessage = ""); } plugin.setUpAutoBackup(); - }).finally(triggerRefresh2); + }).finally(triggerRefresh2)); } }); } @@ -41981,11 +41981,11 @@ function instance9($$self, $$props, $$invalidate) { return __awaiter(this, void 0, void 0, function* () { $$invalidate(5, loading = true); if (status2) { - plugin.createBackup(false, false, commitMessage).then(() => { + plugin.promiseQueue.addTask(() => plugin.createBackup(false, false, commitMessage).then(() => { if (commitMessage !== plugin.settings.commitMessage) { $$invalidate(2, commitMessage = ""); } - }).finally(triggerRefresh2); + }).finally(triggerRefresh2)); } }); } @@ -42039,26 +42039,26 @@ function instance9($$self, $$props, $$invalidate) { } function stageAll() { $$invalidate(5, loading = true); - plugin.gitManager.stageAll({ status: status2 }).finally(triggerRefresh2); + plugin.promiseQueue.addTask(() => plugin.gitManager.stageAll({ status: status2 }).finally(triggerRefresh2)); } function unstageAll() { $$invalidate(5, loading = true); - plugin.gitManager.unstageAll({ status: status2 }).finally(triggerRefresh2); + plugin.promiseQueue.addTask(() => plugin.gitManager.unstageAll({ status: status2 }).finally(triggerRefresh2)); } function push2() { $$invalidate(5, loading = true); - plugin.push().finally(triggerRefresh2); + plugin.promiseQueue.addTask(() => plugin.push().finally(triggerRefresh2)); } function pull2() { $$invalidate(5, loading = true); - plugin.pullChangesFromRemote().finally(triggerRefresh2); + plugin.promiseQueue.addTask(() => plugin.pullChangesFromRemote().finally(triggerRefresh2)); } function discard() { new DiscardModal(view.app, false, plugin.gitManager.getVaultPath("/")).myOpen().then((shouldDiscard) => { if (shouldDiscard === true) { - plugin.gitManager.discardAll({ status: plugin.cachedStatus }).finally(() => { + plugin.promiseQueue.addTask(() => plugin.gitManager.discardAll({ status: plugin.cachedStatus }).finally(() => { dispatchEvent(new CustomEvent("git-refresh")); - }); + })); } }); } diff --git a/.obsidian/plugins/obsidian-git/manifest.json b/.obsidian/plugins/obsidian-git/manifest.json index 813daf5..1138fb6 100644 --- a/.obsidian/plugins/obsidian-git/manifest.json +++ b/.obsidian/plugins/obsidian-git/manifest.json @@ -5,5 +5,5 @@ "isDesktopOnly": false, "fundingUrl": "https://ko-fi.com/vinzent", "js": "main.js", - "version": "2.20.0" + "version": "2.20.1" } diff --git a/.obsidian/plugins/obsidian-style-settings/main.js b/.obsidian/plugins/obsidian-style-settings/main.js index 2be04f6..9ebf6ac 100644 --- a/.obsidian/plugins/obsidian-style-settings/main.js +++ b/.obsidian/plugins/obsidian-style-settings/main.js @@ -3737,9 +3737,18 @@ class CSSSettingsManager { Object.keys(config).forEach((settingId) => { const setting = config[settingId]; if (setting.type === SettingType.CLASS_TOGGLE) { - if (this.getSetting(section, settingId)) { - document.body.classList.remove(setting.id); - } + document.body.classList.remove(setting.id); + } + else if (setting.type === SettingType.CLASS_SELECT) { + const multiToggle = setting; + multiToggle.options.forEach((v) => { + if (typeof v === 'string') { + document.body.classList.remove(v); + } + else { + document.body.classList.remove(v.value); + } + }); } }); }); @@ -3747,26 +3756,27 @@ class CSSSettingsManager { setCSSVariables() { const [vars, themedLight, themedDark] = getCSSVariables(this.settings, this.config, this.gradients, this); this.styleTag.innerText = ` - body.css-settings-manager { - ${vars.reduce((combined, current) => { + body.css-settings-manager { + ${vars.reduce((combined, current) => { return combined + `--${current.key}: ${current.value}; `; }, '')} - } + } - body.theme-light.css-settings-manager { - ${themedLight.reduce((combined, current) => { + body.theme-light.css-settings-manager { + ${themedLight.reduce((combined, current) => { return combined + `--${current.key}: ${current.value}; `; }, '')} - } + } - body.theme-dark.css-settings-manager { - ${themedDark.reduce((combined, current) => { + body.theme-dark.css-settings-manager { + ${themedDark.reduce((combined, current) => { return combined + `--${current.key}: ${current.value}; `; }, '')} - } - ` + } + ` .trim() .replace(/[\r\n\s]+/g, ' '); + this.plugin.app.workspace.trigger('css-change', { source: 'style-settings' }); } setConfig(settings) { this.config = {}; @@ -3819,16 +3829,22 @@ class CSSSettingsManager { setSetting(sectionId, settingId, value) { this.settings[`${sectionId}@@${settingId}`] = value; this.save(); + this.removeClasses(); + this.initClasses(); } setSettings(settings) { Object.keys(settings).forEach((id) => { this.settings[id] = settings[id]; }); + this.removeClasses(); + this.initClasses(); return this.save(); } clearSetting(sectionId, settingId) { delete this.settings[`${sectionId}@@${settingId}`]; this.save(); + this.removeClasses(); + this.initClasses(); } clearSection(sectionId) { Object.keys(this.settings).forEach((key) => { @@ -3838,6 +3854,8 @@ class CSSSettingsManager { } }); this.save(); + this.removeClasses(); + this.initClasses(); } export(section, config) { new ExportModal(this.plugin.app, this.plugin, section, config).open(); @@ -8027,13 +8045,6 @@ function createDescription(description, def, defLabel) { } return fragment; } -let timer; -function customDebounce(cb, timeout = 300) { - clearTimeout(timer); - timer = setTimeout(() => { - cb(); - }, timeout); -} var fuzzysort = createCommonjsModule(function (module) { ((root, UMD) => { @@ -8579,16 +8590,28 @@ var fuzzysort = createCommonjsModule(function (module) { // TODO: (perf) prepareSearch seems slow }); -class AbstractSettingComponent { - constructor(sectionId, sectionName, setting, settingsManager, isView) { +class AbstractSettingComponent extends obsidian.Component { + constructor(parent, sectionId, sectionName, setting, settingsManager, isView) { + super(); + this.childEl = null; + this.parent = parent; this.sectionId = sectionId; this.sectionName = sectionName; this.setting = setting; this.settingsManager = settingsManager; this.isView = isView; - this.onInit(); } - onInit() { } + get containerEl() { + return this.parent instanceof HTMLElement + ? this.parent + : this.parent.childEl; + } + onload() { + this.render(); + } + onunload() { + this.destroy(); + } /** * Matches the Component against `str`. A perfect match returns 0, no match returns negative infinity. * @@ -8614,10 +8637,10 @@ class AbstractSettingComponent { const resetTooltip = 'Restore default'; class ClassToggleSettingComponent extends AbstractSettingComponent { - render(containerEl) { + render() { const title = getTitle(this.setting); const description = getDescription(this.setting); - this.settingEl = new obsidian.Setting(containerEl); + this.settingEl = new obsidian.Setting(this.containerEl); this.settingEl.setName(title); this.settingEl.setDesc(description !== null && description !== void 0 ? description : ''); this.settingEl.addToggle((toggle) => { @@ -8625,12 +8648,6 @@ class ClassToggleSettingComponent extends AbstractSettingComponent { toggle.setValue(value !== undefined ? !!value : !!this.setting.default); toggle.onChange((value) => { this.settingsManager.setSetting(this.sectionId, this.setting.id, value); - if (value) { - document.body.classList.add(this.setting.id); - } - else { - document.body.classList.remove(this.setting.id); - } }); this.toggleComponent = toggle; }); @@ -8639,12 +8656,6 @@ class ClassToggleSettingComponent extends AbstractSettingComponent { b.onClick(() => { const value = !!this.setting.default; this.toggleComponent.setValue(value); - if (value) { - document.body.classList.add(this.setting.id); - } - else { - document.body.classList.remove(this.setting.id); - } this.settingsManager.clearSetting(this.sectionId, this.setting.id); }); b.setTooltip(resetTooltip); @@ -8658,7 +8669,7 @@ class ClassToggleSettingComponent extends AbstractSettingComponent { } class ClassMultiToggleSettingComponent extends AbstractSettingComponent { - render(containerEl) { + render() { const title = getTitle(this.setting); const description = getDescription(this.setting); if (typeof this.setting.default !== 'string') { @@ -8666,7 +8677,7 @@ class ClassMultiToggleSettingComponent extends AbstractSettingComponent { } let prevValue = this.getPreviousValue(); const defaultLabel = this.getDefaultOptionLabel(); - this.settingEl = new obsidian.Setting(containerEl); + this.settingEl = new obsidian.Setting(this.containerEl); this.settingEl.setName(title); this.settingEl.setDesc(createDescription(description, this.setting.default, defaultLabel)); this.settingEl.addDropdown((dropdown) => { @@ -8684,12 +8695,6 @@ class ClassMultiToggleSettingComponent extends AbstractSettingComponent { dropdown.setValue(prevValue); dropdown.onChange((value) => { this.settingsManager.setSetting(this.sectionId, this.setting.id, value); - if (value !== 'none') { - document.body.classList.add(value); - } - if (prevValue) { - document.body.classList.remove(prevValue); - } prevValue = value; }); this.dropdownComponent = dropdown; @@ -8697,14 +8702,7 @@ class ClassMultiToggleSettingComponent extends AbstractSettingComponent { this.settingEl.addExtraButton((b) => { b.setIcon('reset'); b.onClick(() => { - const value = this.setting.default || 'none'; this.dropdownComponent.setValue(this.setting.default || 'none'); - if (value !== 'none') { - document.body.classList.add(value); - } - if (prevValue) { - document.body.classList.remove(prevValue); - } this.settingsManager.clearSetting(this.sectionId, this.setting.id); }); b.setTooltip(resetTooltip); @@ -8749,13 +8747,13 @@ class ClassMultiToggleSettingComponent extends AbstractSettingComponent { } class VariableTextSettingComponent extends AbstractSettingComponent { - render(containerEl) { + render() { const title = getTitle(this.setting); const description = getDescription(this.setting); if (typeof this.setting.default !== 'string') { return console.error(`${t('Error:')} ${title} ${t('missing default value')}`); } - this.settingEl = new obsidian.Setting(containerEl); + this.settingEl = new obsidian.Setting(this.containerEl); this.settingEl.setName(title); this.settingEl.setDesc(createDescription(description, this.setting.default)); this.settingEl.addText((text) => { @@ -8787,13 +8785,13 @@ class VariableTextSettingComponent extends AbstractSettingComponent { } class VariableNumberSettingComponent extends AbstractSettingComponent { - render(containerEl) { + render() { const title = getTitle(this.setting); const description = getDescription(this.setting); if (typeof this.setting.default !== 'number') { return console.error(`${t('Error:')} ${title} ${t('missing default value')}`); } - this.settingEl = new obsidian.Setting(containerEl); + this.settingEl = new obsidian.Setting(this.containerEl); this.settingEl.setName(title); this.settingEl.setDesc(createDescription(description, this.setting.default.toString(10))); this.settingEl.addText((text) => { @@ -8823,13 +8821,13 @@ class VariableNumberSettingComponent extends AbstractSettingComponent { } class VariableNumberSliderSettingComponent extends AbstractSettingComponent { - render(containerEl) { + render() { const title = getTitle(this.setting); const description = getDescription(this.setting); if (typeof this.setting.default !== 'number') { return console.error(`${t('Error:')} ${title} ${t('missing default value')}`); } - this.settingEl = new obsidian.Setting(containerEl); + this.settingEl = new obsidian.Setting(this.containerEl); this.settingEl.setName(title); this.settingEl.setDesc(createDescription(description, this.setting.default.toString(10))); this.settingEl.addSlider((slider) => { @@ -8860,14 +8858,14 @@ class VariableNumberSliderSettingComponent extends AbstractSettingComponent { } class VariableSelectSettingComponent extends AbstractSettingComponent { - render(containerEl) { + render() { const title = getTitle(this.setting); const description = getDescription(this.setting); if (typeof this.setting.default !== 'string') { return console.error(`${t('Error:')} ${title} ${t('missing default value')}`); } const defaultLabel = this.getDefaultOptionLabel(); - this.settingEl = new obsidian.Setting(containerEl); + this.settingEl = new obsidian.Setting(this.containerEl); this.settingEl.setName(title); this.settingEl.setDesc(createDescription(description, this.setting.default, defaultLabel)); this.settingEl.addDropdown((dropdown) => { @@ -8932,7 +8930,7 @@ var pickr_min = createCommonjsModule(function (module, exports) { var Pickr = /*@__PURE__*/getDefaultExportFromCjs(pickr_min); class VariableColorSettingComponent extends AbstractSettingComponent { - render(containerEl) { + render() { var _a; const title = getTitle(this.setting); const description = getDescription(this.setting); @@ -8954,16 +8952,16 @@ class VariableColorSettingComponent extends AbstractSettingComponent { if (value !== undefined) { swatches.push(value); } - this.settingEl = new obsidian.Setting(containerEl); + this.settingEl = new obsidian.Setting(this.containerEl); this.settingEl.setName(title); this.settingEl.setDesc(createDescription(description, this.setting.default)); // fix, so that the color is correctly shown before the color picker has been opened const defaultColor = value !== undefined ? value : this.setting.default; - containerEl.style.setProperty('--pcr-color', defaultColor); + this.containerEl.style.setProperty('--pcr-color', defaultColor); this.pickr = Pickr.create(getPickrSettings({ isView: this.isView, el: this.settingEl.controlEl.createDiv({ cls: 'picker' }), - containerEl: containerEl, + containerEl: this.containerEl, swatches: swatches, opacity: this.setting.opacity, defaultColor: defaultColor, @@ -8977,7 +8975,9 @@ class VariableColorSettingComponent extends AbstractSettingComponent { }); this.pickr.on('show', () => { const { result } = this.pickr.getRoot().interaction; - requestAnimationFrame(() => requestAnimationFrame(() => result.select())); + activeWindow.requestAnimationFrame(() => { + activeWindow.requestAnimationFrame(() => result.select()); + }); }); this.pickr.on('cancel', onPickrCancel); this.settingEl.addExtraButton((b) => { @@ -8999,7 +8999,7 @@ class VariableColorSettingComponent extends AbstractSettingComponent { } class VariableThemedColorSettingComponent extends AbstractSettingComponent { - render(containerEl) { + render() { const title = getTitle(this.setting); const description = getDescription(this.setting); if (typeof this.setting['default-light'] !== 'string' || @@ -9028,7 +9028,7 @@ class VariableThemedColorSettingComponent extends AbstractSettingComponent { if (valueDark !== undefined) { swatchesDark.push(valueDark); } - this.settingEl = new obsidian.Setting(containerEl); + this.settingEl = new obsidian.Setting(this.containerEl); this.settingEl.setName(title); // Construct description this.settingEl.descEl.createSpan({}, (span) => { @@ -9051,9 +9051,9 @@ class VariableThemedColorSettingComponent extends AbstractSettingComponent { cls: 'themed-color-wrapper', }); // Create light color picker - this.createColorPickerLight(wrapper, containerEl, swatchesLight, valueLight, idLight); + this.createColorPickerLight(wrapper, this.containerEl, swatchesLight, valueLight, idLight); // Create dark color picker - this.createColorPickerDark(wrapper, containerEl, swatchesDark, valueDark, idDark); + this.createColorPickerDark(wrapper, this.containerEl, swatchesDark, valueDark, idDark); this.settingEl.settingEl.dataset.id = this.setting.id; } destroy() { @@ -9081,7 +9081,7 @@ class VariableThemedColorSettingComponent extends AbstractSettingComponent { })); this.pickrLight.on('show', () => { const { result } = this.pickrLight.getRoot().interaction; - requestAnimationFrame(() => requestAnimationFrame(() => result.select())); + activeWindow.requestAnimationFrame(() => activeWindow.requestAnimationFrame(() => result.select())); }); this.pickrLight.on('save', (color, instance) => this.onSave(idLight, color, instance)); this.pickrLight.on('cancel', onPickrCancel); @@ -9110,7 +9110,7 @@ class VariableThemedColorSettingComponent extends AbstractSettingComponent { })); this.pickrDark.on('show', () => { const { result } = this.pickrDark.getRoot().interaction; - requestAnimationFrame(() => requestAnimationFrame(() => result.select())); + activeWindow.requestAnimationFrame(() => activeWindow.requestAnimationFrame(() => result.select())); }); this.pickrDark.on('save', (color, instance) => this.onSave(idDark, color, instance)); this.pickrDark.on('cancel', onPickrCancel); @@ -9132,17 +9132,17 @@ class VariableThemedColorSettingComponent extends AbstractSettingComponent { } class InfoTextSettingComponent extends AbstractSettingComponent { - render(containerEl) { + render() { const title = getTitle(this.setting); const description = getDescription(this.setting); - this.settingEl = new obsidian.Setting(containerEl); + this.settingEl = new obsidian.Setting(this.containerEl); this.settingEl.setClass('style-settings-info-text'); if (title) { this.settingEl.setName(title); } if (description) { if (this.setting.markdown) { - obsidian.MarkdownRenderer.renderMarkdown(description, this.settingEl.descEl, '', undefined); + obsidian.MarkdownRenderer.renderMarkdown(description, this.settingEl.descEl, '', this); this.settingEl.descEl.addClass('style-settings-markdown'); } else { @@ -9157,52 +9157,84 @@ class InfoTextSettingComponent extends AbstractSettingComponent { } } -function createSettingComponent(sectionId, sectionName, setting, settingsManager, isView) { +function createSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView) { if (setting.type === SettingType.HEADING) { - return new HeadingSettingComponent(sectionId, sectionName, setting, settingsManager, isView); + return new HeadingSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView); } else if (setting.type === SettingType.INFO_TEXT) { - return new InfoTextSettingComponent(sectionId, sectionName, setting, settingsManager, isView); + return new InfoTextSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView); } else if (setting.type === SettingType.CLASS_TOGGLE) { - return new ClassToggleSettingComponent(sectionId, sectionName, setting, settingsManager, isView); + return new ClassToggleSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView); } else if (setting.type === SettingType.CLASS_SELECT) { - return new ClassMultiToggleSettingComponent(sectionId, sectionName, setting, settingsManager, isView); + return new ClassMultiToggleSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView); } else if (setting.type === SettingType.VARIABLE_TEXT) { - return new VariableTextSettingComponent(sectionId, sectionName, setting, settingsManager, isView); + return new VariableTextSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView); } else if (setting.type === SettingType.VARIABLE_NUMBER) { - return new VariableNumberSettingComponent(sectionId, sectionName, setting, settingsManager, isView); + return new VariableNumberSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView); } else if (setting.type === SettingType.VARIABLE_NUMBER_SLIDER) { - return new VariableNumberSliderSettingComponent(sectionId, sectionName, setting, settingsManager, isView); + return new VariableNumberSliderSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView); } else if (setting.type === SettingType.VARIABLE_SELECT) { - return new VariableSelectSettingComponent(sectionId, sectionName, setting, settingsManager, isView); + return new VariableSelectSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView); } else if (setting.type === SettingType.VARIABLE_COLOR) { - return new VariableColorSettingComponent(sectionId, sectionName, setting, settingsManager, isView); + return new VariableColorSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView); } else if (setting.type === SettingType.VARIABLE_THEMED_COLOR) { - return new VariableThemedColorSettingComponent(sectionId, sectionName, setting, settingsManager, isView); + return new VariableThemedColorSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView); } else { return undefined; } } +function buildSettingComponentTree(opts) { + const { containerEl, isView, sectionId, settings, settingsManager, sectionName, } = opts; + const root = new HeadingSettingComponent(containerEl, sectionId, sectionName, settings[0], settingsManager, isView); + let currentHeading = root; + for (const setting of settings.splice(1)) { + if (setting.type === 'heading') { + const newHeading = setting; + if (newHeading.level < currentHeading.setting.level) { + while (newHeading.level < currentHeading.setting.level) { + currentHeading = currentHeading.parent; + } + if (currentHeading.setting.id === root.setting.id) { + currentHeading = currentHeading.addSettingChild(newHeading); + } + else { + currentHeading = currentHeading.parent.addSettingChild(newHeading); + } + } + else if (newHeading.level === currentHeading.setting.level) { + currentHeading = currentHeading.parent.addSettingChild(newHeading); + } + else { + currentHeading = currentHeading.addSettingChild(newHeading); + } + } + else { + currentHeading.addSettingChild(setting); + } + } + return root; +} class HeadingSettingComponent extends AbstractSettingComponent { - onInit() { + constructor() { + super(...arguments); this.children = []; this.filteredChildren = []; this.filterMode = false; this.filterResultCount = 0; } - render(containerEl) { + render() { const title = getTitle(this.setting); const description = getDescription(this.setting); - this.settingEl = new obsidian.Setting(containerEl); + this.settingEl = new obsidian.Setting(this.containerEl); this.settingEl.setHeading(); this.settingEl.setClass('style-settings-heading'); this.settingEl.setName(title); @@ -9214,28 +9246,28 @@ class HeadingSettingComponent extends AbstractSettingComponent { }); obsidian.setIcon(iconContainer, 'right-triangle'); this.settingEl.nameEl.prepend(iconContainer); - if (this.filterMode) { - this.settingEl.nameEl.createSpan({ - cls: 'style-settings-filter-result-count', - text: `${this.filterResultCount} Results`, - }); - } + this.resultsEl = this.settingEl.nameEl.createSpan({ + cls: 'style-settings-filter-result-count', + text: this.filterMode ? `${this.filterResultCount} Results` : undefined, + }); this.settingEl.settingEl.addEventListener('click', () => { this.toggleVisible(); }); this.addResetButton(); this.addExportButton(); - this.childEl = containerEl.createDiv({ cls: 'style-settings-container' }); + this.childEl = this.containerEl.createDiv({ + cls: 'style-settings-container', + }); this.setCollapsed(this.setting.collapsed); } destroy() { var _a; - if (!this.setting.collapsed) { - this.destroyChildren(); - } + this.removeChildren(); (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.remove(); + this.childEl.remove(); } filter(filterString) { + var _a; this.filteredChildren = []; this.filterResultCount = 0; for (const child of this.children) { @@ -9254,10 +9286,18 @@ class HeadingSettingComponent extends AbstractSettingComponent { } } this.filterMode = true; - this.setting.collapsed = false; + if (this.filterResultCount) { + this.setCollapsed(false); + } + else { + this.setCollapsed(true); + } + this.renderChildren(); + (_a = this.resultsEl) === null || _a === void 0 ? void 0 : _a.setText(`${this.filterResultCount} Results`); return this.filterResultCount; } clearFilter() { + var _a; this.filteredChildren = []; for (const child of this.children) { if (child.setting.type === SettingType.HEADING) { @@ -9265,36 +9305,37 @@ class HeadingSettingComponent extends AbstractSettingComponent { } } this.filterMode = false; - this.setting.collapsed = true; + this.setCollapsed(true); + this.renderChildren(); + (_a = this.resultsEl) === null || _a === void 0 ? void 0 : _a.empty(); } renderChildren() { - this.destroyChildren(); + this.removeChildren(); if (this.filterMode) { for (const child of this.filteredChildren) { - child.render(this.childEl); + this.addChild(child); } } else { for (const child of this.children) { - child.render(this.childEl); + this.addChild(child); } } } - destroyChildren() { - var _a; + removeChildren() { for (const child of this.children) { - child.destroy(); + this.removeChild(child); } - (_a = this.childEl) === null || _a === void 0 ? void 0 : _a.empty(); } toggleVisible() { this.setCollapsed(!this.setting.collapsed); } setCollapsed(collapsed) { + var _a; this.setting.collapsed = collapsed; - this.settingEl.settingEl.toggleClass('is-collapsed', collapsed); + (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.toggleClass('is-collapsed', collapsed); if (collapsed) { - this.destroyChildren(); + this.removeChildren(); } else { this.renderChildren(); @@ -9322,14 +9363,11 @@ class HeadingSettingComponent extends AbstractSettingComponent { }); }); } - addChild(child) { - const newSettingComponent = createSettingComponent(this.sectionId, this.sectionName, child, this.settingsManager, this.isView); + addSettingChild(child) { + const newSettingComponent = createSettingComponent(this, this.sectionId, this.sectionName, child, this.settingsManager, this.isView); if (!newSettingComponent) { return undefined; } - if (newSettingComponent.setting.type === SettingType.HEADING) { - newSettingComponent.parent = this; - } this.children.push(newSettingComponent); return newSettingComponent; } @@ -9344,40 +9382,10 @@ class HeadingSettingComponent extends AbstractSettingComponent { return children; } } -function buildSettingComponentTree(opts) { - const { isView, sectionId, settings, settingsManager, sectionName } = opts; - const root = new HeadingSettingComponent(sectionId, sectionName, settings[0], settingsManager, isView); - let currentHeading = root; - for (const setting of settings.splice(1)) { - if (setting.type === 'heading') { - const newHeading = setting; - if (newHeading.level < currentHeading.setting.level) { - while (newHeading.level < currentHeading.setting.level) { - currentHeading = currentHeading.parent; - } - if (currentHeading.setting.id === root.setting.id) { - currentHeading = currentHeading.addChild(newHeading); - } - else { - currentHeading = currentHeading.parent.addChild(newHeading); - } - } - else if (newHeading.level === currentHeading.setting.level) { - currentHeading = currentHeading.parent.addChild(newHeading); - } - else { - currentHeading = currentHeading.addChild(newHeading); - } - } - else { - currentHeading.addChild(setting); - } - } - return root; -} -class SettingsMarkup { +class SettingsMarkup extends obsidian.Component { constructor(app, plugin, containerEl, isView) { + super(); this.settingsComponentTrees = []; this.filterString = ''; this.settings = []; @@ -9387,23 +9395,31 @@ class SettingsMarkup { this.containerEl = containerEl; this.isView = !!isView; } + onload() { + this.display(); + } + onunload() { + this.settingsComponentTrees = []; + } display() { this.generate(this.settings); } + removeChildren() { + for (const settingsComponentTree of this.settingsComponentTrees) { + this.removeChild(settingsComponentTree); + } + } /** * Recursively destroys all setting elements. */ cleanup() { var _a; - for (const settingsComponentTree of this.settingsComponentTrees) { - settingsComponentTree.destroy(); - } + this.removeChildren(); (_a = this.settingsContainerEl) === null || _a === void 0 ? void 0 : _a.empty(); } setSettings(settings, errorList) { this.settings = settings; this.errorList = errorList; - this.plugin.settingsManager.setConfig(settings); if (this.containerEl.parentNode) { this.generate(settings); } @@ -9479,17 +9495,15 @@ class SettingsMarkup { // move the search component from the back to the front setting.nameEl.appendChild(setting.controlEl.lastChild); searchComponent.setValue(this.filterString); - searchComponent.onChange((value) => { - customDebounce(() => { - this.filterString = value; - if (value) { - this.filter(); - } - else { - this.clearFilter(); - } - }, 250); - }); + searchComponent.onChange(obsidian.debounce((value) => { + this.filterString = value; + if (value) { + this.filter(); + } + else { + this.clearFilter(); + } + }, 250, true)); searchComponent.setPlaceholder('Search Style Settings...'); }); this.settingsContainerEl = containerEl.createDiv(); @@ -9504,20 +9518,21 @@ class SettingsMarkup { collapsed: (_a = s.collapsed) !== null && _a !== void 0 ? _a : true, resetFn: () => { plugin.settingsManager.clearSection(s.id); - this.generate(this.settings); + this.rerender(); }, }, ...s.settings, ]; try { const settingsComponentTree = buildSettingComponentTree({ + containerEl: this.settingsContainerEl, isView: this.isView, sectionId: s.id, sectionName: s.name, settings: options, settingsManager: plugin.settingsManager, }); - settingsComponentTree.render(this.settingsContainerEl); + this.addChild(settingsComponentTree); this.settingsComponentTrees.push(settingsComponentTree); } catch (e) { @@ -9529,39 +9544,45 @@ class SettingsMarkup { * Recursively filter all setting elements based on `filterString` and then re-renders. */ filter() { - this.cleanup(); for (const settingsComponentTree of this.settingsComponentTrees) { settingsComponentTree.filter(this.filterString); - settingsComponentTree.render(this.settingsContainerEl); } } /** * Recursively clears the filter and then re-renders. */ clearFilter() { - this.cleanup(); for (const settingsComponentTree of this.settingsComponentTrees) { settingsComponentTree.clearFilter(); - settingsComponentTree.render(this.settingsContainerEl); } } rerender() { - for (const settingsComponentTree of this.settingsComponentTrees) { - settingsComponentTree.render(this.settingsContainerEl); - } + this.cleanup(); + this.display(); } } class CSSSettingsTab extends obsidian.PluginSettingTab { constructor(app, plugin) { super(app, plugin); - this.settingsMarkup = new SettingsMarkup(app, plugin, this.containerEl); + this.plugin = plugin; + } + setSettings(settings, errorList) { + this.settings = settings; + this.errorList = errorList; + if (this.settingsMarkup) { + this.settingsMarkup.setSettings(settings, errorList); + } } display() { - this.settingsMarkup.display(); + this.settingsMarkup = this.plugin.addChild(new SettingsMarkup(this.app, this.plugin, this.containerEl)); + if (this.settings) { + this.settingsMarkup.setSettings(this.settings, this.errorList); + } } hide() { - this.settingsMarkup.cleanup(); + this.plugin.removeChild(this.settingsMarkup); + this.settingsMarkup = null; } } @@ -9570,7 +9591,22 @@ class SettingsView extends obsidian.ItemView { constructor(plugin, leaf) { super(leaf); this.plugin = plugin; - this.settingsMarkup = new SettingsMarkup(plugin.app, plugin, this.contentEl, true); + } + setSettings(settings, errorList) { + this.settings = settings; + this.errorList = errorList; + if (this.settingsMarkup) { + this.settingsMarkup.setSettings(settings, errorList); + } + } + onload() { + this.settingsMarkup = this.addChild(new SettingsMarkup(this.plugin.app, this.plugin, this.contentEl, true)); + if (this.settings) { + this.settingsMarkup.setSettings(this.settings, this.errorList); + } + } + onunload() { + this.settingsMarkup = null; } getViewType() { return viewType; @@ -9581,16 +9617,6 @@ class SettingsView extends obsidian.ItemView { getDisplayText() { return 'Style Settings'; } - onOpen() { - return __awaiter(this, void 0, void 0, function* () { - return this.settingsMarkup.display(); - }); - } - onClose() { - return __awaiter(this, void 0, void 0, function* () { - return this.settingsMarkup.cleanup(); - }); - } } class CSSSettingsPlugin extends obsidian.Plugin { @@ -9615,8 +9641,10 @@ class CSSSettingsPlugin extends obsidian.Plugin { this.activateView(); }, }); - this.registerEvent(this.app.workspace.on('css-change', () => { - this.parseCSS(); + this.registerEvent(this.app.workspace.on('css-change', (data) => { + if ((data === null || data === void 0 ? void 0 : data.source) !== 'style-settings') { + this.parseCSS(); + } })); this.registerEvent(this.app.workspace.on('parse-style-settings', () => { this.parseCSS(); @@ -9625,6 +9653,13 @@ class CSSSettingsPlugin extends obsidian.Plugin { this.darkEl = document.body.createDiv('theme-dark style-settings-ref'); document.body.classList.add('css-settings-manager'); this.parseCSS(); + this.app.workspace.onLayoutReady(() => { + if (this.settingsList) { + this.app.workspace.getLeavesOfType(viewType).forEach((leaf) => { + leaf.view.setSettings(this.settingsList, this.errorList); + }); + } + }); }); } getCSSVar(id) { @@ -9635,15 +9670,16 @@ class CSSSettingsPlugin extends obsidian.Plugin { } parseCSS() { clearTimeout(this.debounceTimer); - this.settingsList = []; - this.errorList = []; - // remove registered theme commands (sadly undocumented API) - for (const command of this.commandList) { - // @ts-ignore - this.app.commands.removeCommand(command.id); - } - this.commandList = []; - this.debounceTimer = window.setTimeout(() => { + this.debounceTimer = activeWindow.setTimeout(() => { + this.settingsList = []; + this.errorList = []; + // remove registered theme commands (sadly undocumented API) + for (const command of this.commandList) { + // @ts-ignore + this.app.commands.removeCommand(command.id); + } + this.commandList = []; + this.settingsManager.removeClasses(); const styleSheets = document.styleSheets; for (let i = 0, len = styleSheets.length; i < len; i++) { const sheet = styleSheets.item(i); @@ -9651,10 +9687,11 @@ class CSSSettingsPlugin extends obsidian.Plugin { } // compatability with Settings Search Plugin this.registerSettingsToSettingsSearch(); - this.settingsTab.settingsMarkup.setSettings(this.settingsList, this.errorList); + this.settingsTab.setSettings(this.settingsList, this.errorList); this.app.workspace.getLeavesOfType(viewType).forEach((leaf) => { - leaf.view.settingsMarkup.setSettings(this.settingsList, this.errorList); + leaf.view.setSettings(this.settingsList, this.errorList); }); + this.settingsManager.setConfig(this.settingsList); this.settingsManager.initClasses(); this.registerSettingCommands(); }, 100); @@ -9775,12 +9812,6 @@ class CSSSettingsPlugin extends obsidian.Plugin { callback: () => { const value = !this.settingsManager.getSetting(section.id, setting.id); this.settingsManager.setSetting(section.id, setting.id, value); - if (value) { - document.body.classList.add(setting.id); - } - else { - document.body.classList.remove(setting.id); - } this.settingsTab.settingsMarkup.rerender(); for (const leaf of this.app.workspace.getLeavesOfType(viewType)) { leaf.view.settingsMarkup.rerender(); @@ -9795,7 +9826,6 @@ class CSSSettingsPlugin extends obsidian.Plugin { this.darkEl = null; document.body.classList.remove('css-settings-manager'); this.settingsManager.cleanup(); - this.settingsTab.settingsMarkup.cleanup(); this.deactivateView(); this.unregisterSettingsFromSettingsSearch(); } @@ -9810,7 +9840,7 @@ class CSSSettingsPlugin extends obsidian.Plugin { type: viewType, active: true, }); - leaf.view.settingsMarkup.setSettings(this.settingsList, this.errorList); + leaf.view.setSettings(this.settingsList, this.errorList); }); } } diff --git a/.obsidian/plugins/obsidian-style-settings/manifest.json b/.obsidian/plugins/obsidian-style-settings/manifest.json index 71f1bfd..a4bc22e 100644 --- a/.obsidian/plugins/obsidian-style-settings/manifest.json +++ b/.obsidian/plugins/obsidian-style-settings/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-style-settings", "name": "Style Settings", - "version": "1.0.3", + "version": "1.0.6", "minAppVersion": "0.11.5", "description": "Offers controls for adjusting theme, plugin, and snippet CSS variables.", "author": "mgmeyers", diff --git a/.obsidian/plugins/omnisearch/data.json b/.obsidian/plugins/omnisearch/data.json index 9398522..9b33c73 100644 --- a/.obsidian/plugins/omnisearch/data.json +++ b/.obsidian/plugins/omnisearch/data.json @@ -6,6 +6,7 @@ "PDFIndexing": false, "imagesIndexing": false, "splitCamelCase": false, + "openInNewPane": false, "ribbonIcon": true, "showExcerpt": true, "renderLineReturnInExcerpts": true, diff --git a/.obsidian/plugins/omnisearch/main.js b/.obsidian/plugins/omnisearch/main.js index da68102..3a75417 100644 --- a/.obsidian/plugins/omnisearch/main.js +++ b/.obsidian/plugins/omnisearch/main.js @@ -3,43 +3,43 @@ THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ -var Fc=Object.create;var Sr=Object.defineProperty,Sc=Object.defineProperties,Ec=Object.getOwnPropertyDescriptor,Dc=Object.getOwnPropertyDescriptors,Tc=Object.getOwnPropertyNames,ro=Object.getOwnPropertySymbols,kc=Object.getPrototypeOf,no=Object.prototype.hasOwnProperty,Ic=Object.prototype.propertyIsEnumerable;var io=(t,e,r)=>e in t?Sr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,re=(t,e)=>{for(var r in e||(e={}))no.call(e,r)&&io(t,r,e[r]);if(ro)for(var r of ro(e))Ic.call(e,r)&&io(t,r,e[r]);return t},xe=(t,e)=>Sc(t,Dc(e)),so=t=>Sr(t,"__esModule",{value:!0});var yi=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Oc=(t,e)=>{so(t);for(var r in e)Sr(t,r,{get:e[r],enumerable:!0})},Mc=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Tc(e))!no.call(t,n)&&n!=="default"&&Sr(t,n,{get:()=>e[n],enumerable:!(r=Ec(e,n))||r.enumerable});return t},be=t=>Mc(so(Sr(t!=null?Fc(kc(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var ya=yi((Xr,bs)=>{(function(t,e){if(typeof Xr=="object"&&typeof bs=="object")bs.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var r=e();for(var n in r)(typeof Xr=="object"?Xr:t)[n]=r[n]}})(typeof self!="undefined"?self:Xr,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(n,i,s){r.o(n,i)||Object.defineProperty(n,i,{enumerable:!0,get:s})},r.r=function(n){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,i){if(1&i&&(n=r(n)),8&i||4&i&&typeof n=="object"&&n&&n.__esModule)return n;var s=Object.create(null);if(r.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:n}),2&i&&typeof n!="string")for(var o in n)r.d(s,o,function(a){return n[a]}.bind(null,o));return s},r.n=function(n){var i=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(i,"a",i),i},r.o=function(n,i){return Object.prototype.hasOwnProperty.call(n,i)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";r.r(e),r.d(e,"md5",function(){return b});var n="0123456789abcdef".split(""),i=function(x){for(var h="",v=0;v<4;v++)h+=n[x>>8*v+4&15]+n[x>>8*v&15];return h},s=function(x){for(var h=x.length,v=0;v>>32-A,C)}(h=function(j,A,C,F){return A=o(o(A,j),o(C,F))}(x,h,p,_),m,v)},l=function(x,h,v,p,m,_,g,j){return a(v&p|~v&m,h,v,_,g,j,x)},u=function(x,h,v,p,m,_,g,j){return a(v&m|p&~m,h,v,_,g,j,x)},c=function(x,h,v,p,m,_,g,j){return a(v^p^m,h,v,_,g,j,x)},d=function(x,h,v,p,m,_,g,j){return a(p^(v|~m),h,v,_,g,j,x)},f=function(x,h,v){v===void 0&&(v=o);var p=x[0],m=x[1],_=x[2],g=x[3],j=l.bind(null,v);p=j(p,m,_,g,h[0],7,-680876936),g=j(g,p,m,_,h[1],12,-389564586),_=j(_,g,p,m,h[2],17,606105819),m=j(m,_,g,p,h[3],22,-1044525330),p=j(p,m,_,g,h[4],7,-176418897),g=j(g,p,m,_,h[5],12,1200080426),_=j(_,g,p,m,h[6],17,-1473231341),m=j(m,_,g,p,h[7],22,-45705983),p=j(p,m,_,g,h[8],7,1770035416),g=j(g,p,m,_,h[9],12,-1958414417),_=j(_,g,p,m,h[10],17,-42063),m=j(m,_,g,p,h[11],22,-1990404162),p=j(p,m,_,g,h[12],7,1804603682),g=j(g,p,m,_,h[13],12,-40341101),_=j(_,g,p,m,h[14],17,-1502002290),m=j(m,_,g,p,h[15],22,1236535329);var A=u.bind(null,v);p=A(p,m,_,g,h[1],5,-165796510),g=A(g,p,m,_,h[6],9,-1069501632),_=A(_,g,p,m,h[11],14,643717713),m=A(m,_,g,p,h[0],20,-373897302),p=A(p,m,_,g,h[5],5,-701558691),g=A(g,p,m,_,h[10],9,38016083),_=A(_,g,p,m,h[15],14,-660478335),m=A(m,_,g,p,h[4],20,-405537848),p=A(p,m,_,g,h[9],5,568446438),g=A(g,p,m,_,h[14],9,-1019803690),_=A(_,g,p,m,h[3],14,-187363961),m=A(m,_,g,p,h[8],20,1163531501),p=A(p,m,_,g,h[13],5,-1444681467),g=A(g,p,m,_,h[2],9,-51403784),_=A(_,g,p,m,h[7],14,1735328473),m=A(m,_,g,p,h[12],20,-1926607734);var C=c.bind(null,v);p=C(p,m,_,g,h[5],4,-378558),g=C(g,p,m,_,h[8],11,-2022574463),_=C(_,g,p,m,h[11],16,1839030562),m=C(m,_,g,p,h[14],23,-35309556),p=C(p,m,_,g,h[1],4,-1530992060),g=C(g,p,m,_,h[4],11,1272893353),_=C(_,g,p,m,h[7],16,-155497632),m=C(m,_,g,p,h[10],23,-1094730640),p=C(p,m,_,g,h[13],4,681279174),g=C(g,p,m,_,h[0],11,-358537222),_=C(_,g,p,m,h[3],16,-722521979),m=C(m,_,g,p,h[6],23,76029189),p=C(p,m,_,g,h[9],4,-640364487),g=C(g,p,m,_,h[12],11,-421815835),_=C(_,g,p,m,h[15],16,530742520),m=C(m,_,g,p,h[2],23,-995338651);var F=d.bind(null,v);p=F(p,m,_,g,h[0],6,-198630844),g=F(g,p,m,_,h[7],10,1126891415),_=F(_,g,p,m,h[14],15,-1416354905),m=F(m,_,g,p,h[5],21,-57434055),p=F(p,m,_,g,h[12],6,1700485571),g=F(g,p,m,_,h[3],10,-1894986606),_=F(_,g,p,m,h[10],15,-1051523),m=F(m,_,g,p,h[1],21,-2054922799),p=F(p,m,_,g,h[8],6,1873313359),g=F(g,p,m,_,h[15],10,-30611744),_=F(_,g,p,m,h[6],15,-1560198380),m=F(m,_,g,p,h[13],21,1309151649),p=F(p,m,_,g,h[4],6,-145523070),g=F(g,p,m,_,h[11],10,-1120210379),_=F(_,g,p,m,h[2],15,718787259),m=F(m,_,g,p,h[9],21,-343485551),x[0]=v(p,x[0]),x[1]=v(m,x[1]),x[2]=v(_,x[2]),x[3]=v(g,x[3])},y=function(x){for(var h=[],v=0;v<64;v+=4)h[v>>2]=x.charCodeAt(v)+(x.charCodeAt(v+1)<<8)+(x.charCodeAt(v+2)<<16)+(x.charCodeAt(v+3)<<24);return h},w=function(x,h){var v,p=x.length,m=[1732584193,-271733879,-1732584194,271733878];for(v=64;v<=p;v+=64)f(m,y(x.substring(v-64,v)),h);var _=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],g=(x=x.substring(v-64)).length;for(v=0;v>2]|=x.charCodeAt(v)<<(v%4<<3);if(_[v>>2]|=128<<(v%4<<3),v>55)for(f(m,_,h),v=16;v--;)_[v]=0;return _[14]=8*p,f(m,_,h),m};function b(x){var h;return s(w("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(h=function(v,p){var m=(65535&v)+(65535&p);return(v>>16)+(p>>16)+(m>>16)<<16|65535&m}),s(w(x,h))}}])})});var Ha=yi(Qn=>{Qn.parse=function(t,e){if(e?e.offsets=typeof e.offsets=="undefined"?!0:e.offsets:e={offsets:!0},t||(t=""),t.indexOf(":")===-1&&!e.tokenize)return t;if(!e.keywords&&!e.ranges&&!e.tokenize)return t;var r={text:[]};e.offsets&&(r.offsets=[]);for(var n={},i=[],s=/(\S+:'(?:[^'\\]|\\.)*')|(\S+:"(?:[^"\\]|\\.)*")|(-?"(?:[^"\\]|\\.)*")|(-?'(?:[^'\\]|\\.)*')|\S+|\S+:\S+/g,o;(o=s.exec(t))!==null;){var f=o[0],a=f.indexOf(":");if(a!==-1){var l=f.split(":"),u=f.slice(0,a),c=f.slice(a+1);c=c.replace(/^\"|\"$|^\'|\'$/g,""),c=(c+"").replace(/\\(.?)/g,function(g,j){switch(j){case"\\":return"\\";case"0":return"\0";case"":return"";default:return j}}),i.push({keyword:u,value:c,offsetStart:o.index,offsetEnd:o.index+f.length})}else{var d=!1;f[0]==="-"&&(d=!0,f=f.slice(1)),f=f.replace(/^\"|\"$|^\'|\'$/g,""),f=(f+"").replace(/\\(.?)/g,function(g,j){switch(j){case"\\":return"\\";case"0":return"\0";case"":return"";default:return j}}),d?n.text?(n.text instanceof Array||(n.text=[n.text]),n.text.push(f)):n.text=f:i.push({text:f,offsetStart:o.index,offsetEnd:o.index+f.length})}}i.reverse();for(var f;f=i.pop();)if(f.text)r.text.push(f.text),e.offsets&&r.offsets.push(f);else{var u=f.keyword;e.keywords=e.keywords||[];var y=!1,w=!1;if(!/^-/.test(u))y=e.keywords.indexOf(u)!==-1;else if(u[0]==="-"){var b=u.slice(1);y=e.keywords.indexOf(b)!==-1,y&&(u=b,w=!0)}e.ranges=e.ranges||[];var x=e.ranges.indexOf(u)!==-1;if(y){e.offsets&&r.offsets.push({keyword:u,value:f.value,offsetStart:w?f.offsetStart+1:f.offsetStart,offsetEnd:f.offsetEnd});var h=f.value;if(h.length){var v=h.split(",");w?n[u]?n[u]instanceof Array?v.length>1?n[u]=n[u].concat(v):n[u].push(h):(n[u]=[n[u]],n[u].push(h)):v.length>1?n[u]=v:e.alwaysArray?n[u]=[h]:n[u]=h:r[u]?r[u]instanceof Array?v.length>1?r[u]=r[u].concat(v):r[u].push(h):(r[u]=[r[u]],r[u].push(h)):v.length>1?r[u]=v:e.alwaysArray?r[u]=[h]:r[u]=h}}else if(x){e.offsets&&r.offsets.push(f);var h=f.value,p=h.split("-");r[u]={},p.length===2?(r[u].from=p[0],r[u].to=p[1]):!p.length%2||(r[u].from=h)}else{var m=f.keyword+":"+f.value;r.text.push(m),e.offsets&&r.offsets.push({text:m,offsetStart:f.offsetStart,offsetEnd:f.offsetEnd})}}return r.text.length?e.tokenize||(r.text=r.text.join(" ").trim()):delete r.text,r.exclude=n,r};Qn.stringify=function(t,e,r){if(e||(e={offsets:!0}),!t)return"";if(typeof t=="string")return t;if(Array.isArray(t))return t.join(" ");if(!Object.keys(t).length)return"";if(Object.keys(t).length===3&&!!t.text&&!!t.offsets&&!!t.exclude&&typeof t.text=="string")return t.text;r||(r="");var n=function(a){return a.indexOf(" ")>-1?JSON.stringify(a):a},i=function(a){return r+a},s=[];if(t.text){var o=[];typeof t.text=="string"?o.push(t.text):o.push.apply(o,t.text),o.length>0&&s.push(o.map(n).map(i).join(" "))}return e.keywords&&e.keywords.forEach(function(a){if(!!t[a]){var l=[];typeof t[a]=="string"?l.push(t[a]):l.push.apply(l,t[a]),l.length>0&&s.push(i(a+":"+l.map(n).join(",")))}}),e.ranges&&e.ranges.forEach(function(a){if(!!t[a]){var l=t[a].from,u=t[a].to;u&&(l=l+"-"+u),l&&s.push(i(a+":"+l))}}),t.exclude&&Object.keys(t.exclude).length>0&&s.push(Qn.stringify(t.exclude,e,"-")),s.join(" ")}});var Ua=yi(($v,Wa)=>{Wa.exports=Ha()});Oc(exports,{default:()=>eo});var Fr=be(require("obsidian"));var wc=be(require("obsidian"));function ne(){}function Pc(t,e){for(let r in e)t[r]=e[r];return t}function vi(t){return t()}function oo(){return Object.create(null)}function Re(t){t.forEach(vi)}function Ut(t){return typeof t=="function"}function fe(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}var an;function _i(t,e){return an||(an=document.createElement("a")),an.href=e,t===an.href}function ao(t){return Object.keys(t).length===0}function lo(t,...e){if(t==null)return ne;let r=t.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function ln(t,e,r){t.$$.on_destroy.push(lo(e,r))}function Gt(t,e,r,n){if(t){let i=uo(t,e,r,n);return t[0](i)}}function uo(t,e,r,n){return t[1]&&n?Pc(r.ctx.slice(),t[1](n(e))):r.ctx}function Qt(t,e,r,n){if(t[2]&&n){let i=t[2](n(r));if(e.dirty===void 0)return i;if(typeof i=="object"){let s=[],o=Math.max(e.dirty.length,i.length);for(let a=0;a32){let e=[],r=t.ctx.length/32;for(let n=0;nt.removeEventListener(e,r,n)}function B(t,e,r){r==null?t.removeAttribute(e):t.getAttribute(e)!==r&&t.setAttribute(e,r)}function Lc(t){return Array.from(t.childNodes)}function St(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function xi(t,e){t.value=e??""}function ke(t,e,r,n){r===null?t.style.removeProperty(e):t.style.setProperty(e,r,n?"important":"")}function bi(t,e,r){t.classList[r?"add":"remove"](e)}function Nc(t,e,{bubbles:r=!1,cancelable:n=!1}={}){let i=document.createEvent("CustomEvent");return i.initCustomEvent(t,r,n,e),i}var Er;function Dr(t){Er=t}function wi(){if(!Er)throw new Error("Function called outside component initialization");return Er}function Tr(t){wi().$$.on_mount.push(t)}function kr(t){wi().$$.on_destroy.push(t)}function ji(){let t=wi();return(e,r,{cancelable:n=!1}={})=>{let i=t.$$.callbacks[e];if(i){let s=Nc(e,r,{cancelable:n});return i.slice().forEach(o=>{o.call(t,s)}),!s.defaultPrevented}return!0}}function Me(t,e){let r=t.$$.callbacks[e.type];r&&r.slice().forEach(n=>n.call(this,e))}var Ir=[];var He=[],cn=[],ho=[],po=Promise.resolve(),Ai=!1;function mo(){Ai||(Ai=!0,po.then(go))}function ot(){return mo(),po}function Ci(t){cn.push(t)}var Fi=new Set,fn=0;function go(){let t=Er;do{for(;fn{dn.delete(t),n&&(r&&t.d(1),n())}),t.o(e)}else n&&n()}var Py=typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:global;function Se(t){t&&t.c()}function we(t,e,r,n){let{fragment:i,after_update:s}=t.$$;i&&i.m(e,r),n||Ci(()=>{let o=t.$$.on_mount.map(vi).filter(Ut);t.$$.on_destroy?t.$$.on_destroy.push(...o):Re(o),t.$$.on_mount=[]}),s.forEach(Ci)}function ge(t,e){let r=t.$$;r.fragment!==null&&(Re(r.on_destroy),r.fragment&&r.fragment.d(e),r.on_destroy=r.fragment=null,r.ctx=[])}function zc(t,e){t.$$.dirty[0]===-1&&(Ir.push(t),mo(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{let w=y.length?y[0]:f;return u.ctx&&i(u.ctx[d],u.ctx[d]=w)&&(!u.skip_bound&&u.bound[d]&&u.bound[d](w),c&&zc(t,d)),f}):[],u.update(),c=!0,Re(u.before_update),u.fragment=n?n(u.ctx):!1,e.target){if(e.hydrate){Rc();let d=Lc(e.target);u.fragment&&u.fragment.l(d),d.forEach(K)}else u.fragment&&u.fragment.c();e.intro&&Q(t.$$.fragment),we(t,e.target,e.anchor,e.customElement),Bc(),go()}Dr(l)}var Vc;typeof HTMLElement=="function"&&(Vc=class extends HTMLElement{constructor(){super();this.attachShadow({mode:"open"})}connectedCallback(){let{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(vi).filter(Ut);for(let e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(t,e,r){this[t]=r}disconnectedCallback(){Re(this.$$.on_disconnect)}$destroy(){ge(this,1),this.$destroy=ne}$on(t,e){if(!Ut(e))return ne;let r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(e),()=>{let n=r.indexOf(e);n!==-1&&r.splice(n,1)}}$set(t){this.$$set&&!ao(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});var pe=class{$destroy(){ge(this,1),this.$destroy=ne}$on(e,r){if(!Ut(r))return ne;let n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(r),()=>{let i=n.indexOf(r);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!ao(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}};var Ft=be(require("obsidian"));var Ta=be(require("obsidian"));var Si=class{constructor(){this.handlers=new Map;this.disabled=[]}on(e,r,n){if(e.includes("@")||r.includes("@"))throw new Error("Invalid context/event name - Cannot contain @");this.handlers.set(`${e}@${r}`,n)}off(e,r){if(r)this.handlers.delete(`${e}@${r}`);else for(let[n]of this.handlers.entries())n.startsWith(`${e}@`)&&this.handlers.delete(n)}disable(e){this.enable(e),this.disabled.push(e)}enable(e){this.disabled=this.disabled.filter(r=>r!==e)}emit(e,...r){let n=[...this.handlers.entries()].filter(([i,s])=>!this.disabled.includes(i.split("@")[0]));for(let[i,s]of n)i.endsWith(`@${e}`)&&s(...r)}};var Xt=[];function hn(t,e=ne){let r,n=new Set;function i(a){if(fe(t,a)&&(t=a,r)){let l=!Xt.length;for(let u of n)u[1](),Xt.push(u,t);if(l){for(let u=0;u{n.delete(u),n.size===0&&(r(),r=null)}}return{set:i,update:s,subscribe:o}}var G=be(require("obsidian"));var J=typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global,oe=Object.keys,ve=Array.isArray;typeof Promise!="undefined"&&!J.Promise&&(J.Promise=Promise);function je(t,e){return typeof e!="object"||oe(e).forEach(function(r){t[r]=e[r]}),t}var Or=Object.getPrototypeOf,$c={}.hasOwnProperty;function Ie(t,e){return $c.call(t,e)}function Zt(t,e){typeof e=="function"&&(e=e(Or(t))),(typeof Reflect=="undefined"?oe:Reflect.ownKeys)(e).forEach(r=>{We(t,r,e[r])})}var yo=Object.defineProperty;function We(t,e,r,n){yo(t,e,je(r&&Ie(r,"get")&&typeof r.get=="function"?{get:r.get,set:r.set,configurable:!0}:{value:r,configurable:!0,writable:!0},n))}function er(t){return{from:function(e){return t.prototype=Object.create(e.prototype),We(t.prototype,"constructor",t),{extend:Zt.bind(null,t.prototype)}}}}var Hc=Object.getOwnPropertyDescriptor;function Ei(t,e){let r=Hc(t,e),n;return r||(n=Or(t))&&Ei(n,e)}var Wc=[].slice;function pn(t,e,r){return Wc.call(t,e,r)}function vo(t,e){return e(t)}function Mr(t){if(!t)throw new Error("Assertion Failed")}function _o(t){J.setImmediate?setImmediate(t):setTimeout(t,0)}function xo(t,e){return t.reduce((r,n,i)=>{var s=e(n,i);return s&&(r[s[0]]=s[1]),r},{})}function Uc(t,e,r){try{t.apply(null,r)}catch(n){e&&e(n)}}function Ue(t,e){if(Ie(t,e))return t[e];if(!e)return t;if(typeof e!="string"){for(var r=[],n=0,i=e.length;n["Int","Uint","Float"].map(e=>e+t+"Array")))).filter(t=>J[t]),qc=jo.map(t=>J[t]);xo(jo,t=>[t,!0]);var at=null;function Pr(t){at=typeof WeakMap!="undefined"&&new WeakMap;let e=Di(t);return at=null,e}function Di(t){if(!t||typeof t!="object")return t;let e=at&&at.get(t);if(e)return e;if(ve(t)){e=[],at&&at.set(t,e);for(var r=0,n=t.length;r=0)e=t;else{let s=Or(t);e=s===Object.prototype?{}:Object.create(s),at&&at.set(t,e);for(var i in t)Ie(t,i)&&(e[i]=Di(t[i]))}return e}var{toString:Yc}={};function Ti(t){return Yc.call(t).slice(8,-1)}var ki=typeof Symbol!="undefined"?Symbol.iterator:"@@iterator",Jc=typeof ki=="symbol"?function(t){var e;return t!=null&&(e=t[ki])&&e.apply(t)}:function(){return null},tr={};function Ge(t){var e,r,n,i;if(arguments.length===1){if(ve(t))return t.slice();if(this===tr&&typeof t=="string")return[t];if(i=Jc(t)){for(r=[];n=i.next(),!n.done;)r.push(n.value);return r}if(t==null)return[t];if(e=t.length,typeof e=="number"){for(r=new Array(e);e--;)r[e]=t[e];return r}return[t]}for(e=arguments.length,r=new Array(e);e--;)r[e]=arguments[e];return r}var Ii=typeof Symbol!="undefined"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1,Ke=typeof location!="undefined"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Ao(t,e){Ke=t,Co=e}var Co=()=>!0,Xc=!new Error("").stack;function kt(){if(Xc)try{throw kt.arguments,new Error}catch(t){return t}return new Error}function Oi(t,e){var r=t.stack;return r?(e=e||0,r.indexOf(t.name)===0&&(e+=(t.name+t.message).split(` +var Kc=Object.create;var Mr=Object.defineProperty,zc=Object.defineProperties,Vc=Object.getOwnPropertyDescriptor,Hc=Object.getOwnPropertyDescriptors,$c=Object.getOwnPropertyNames,gs=Object.getOwnPropertySymbols,Wc=Object.getPrototypeOf,ys=Object.prototype.hasOwnProperty,Uc=Object.prototype.propertyIsEnumerable;var vs=(t,e,r)=>e in t?Mr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ue=(t,e)=>{for(var r in e||(e={}))ys.call(e,r)&&vs(t,r,e[r]);if(gs)for(var r of gs(e))Uc.call(e,r)&&vs(t,r,e[r]);return t},Oe=(t,e)=>zc(t,Hc(e)),_s=t=>Mr(t,"__esModule",{value:!0});var yn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Gc=(t,e)=>{_s(t);for(var r in e)Mr(t,r,{get:e[r],enumerable:!0})},Qc=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $c(e))!ys.call(t,n)&&n!=="default"&&Mr(t,n,{get:()=>e[n],enumerable:!(r=Vc(e,n))||r.enumerable});return t},Fe=t=>Qc(_s(Mr(t!=null?Kc(Wc(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var Ta=yn((un,Po)=>{(function(t,e){if(typeof un=="object"&&typeof Po=="object")Po.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var r=e();for(var n in r)(typeof un=="object"?un:t)[n]=r[n]}})(typeof self!="undefined"?self:un,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(n,i,o){r.o(n,i)||Object.defineProperty(n,i,{enumerable:!0,get:o})},r.r=function(n){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,i){if(1&i&&(n=r(n)),8&i||4&i&&typeof n=="object"&&n&&n.__esModule)return n;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&i&&typeof n!="string")for(var s in n)r.d(o,s,function(a){return n[a]}.bind(null,s));return o},r.n=function(n){var i=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(i,"a",i),i},r.o=function(n,i){return Object.prototype.hasOwnProperty.call(n,i)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";r.r(e),r.d(e,"md5",function(){return x});var n="0123456789abcdef".split(""),i=function(b){for(var h="",_=0;_<4;_++)h+=n[b>>8*_+4&15]+n[b>>8*_&15];return h},o=function(b){for(var h=b.length,_=0;_>>32-C,S)}(h=function(j,C,S,E){return C=s(s(C,j),s(S,E))}(b,h,p,v),m,_)},l=function(b,h,_,p,m,v,g,j){return a(_&p|~_&m,h,_,v,g,j,b)},u=function(b,h,_,p,m,v,g,j){return a(_&m|p&~m,h,_,v,g,j,b)},d=function(b,h,_,p,m,v,g,j){return a(_^p^m,h,_,v,g,j,b)},f=function(b,h,_,p,m,v,g,j){return a(p^(_|~m),h,_,v,g,j,b)},c=function(b,h,_){_===void 0&&(_=s);var p=b[0],m=b[1],v=b[2],g=b[3],j=l.bind(null,_);p=j(p,m,v,g,h[0],7,-680876936),g=j(g,p,m,v,h[1],12,-389564586),v=j(v,g,p,m,h[2],17,606105819),m=j(m,v,g,p,h[3],22,-1044525330),p=j(p,m,v,g,h[4],7,-176418897),g=j(g,p,m,v,h[5],12,1200080426),v=j(v,g,p,m,h[6],17,-1473231341),m=j(m,v,g,p,h[7],22,-45705983),p=j(p,m,v,g,h[8],7,1770035416),g=j(g,p,m,v,h[9],12,-1958414417),v=j(v,g,p,m,h[10],17,-42063),m=j(m,v,g,p,h[11],22,-1990404162),p=j(p,m,v,g,h[12],7,1804603682),g=j(g,p,m,v,h[13],12,-40341101),v=j(v,g,p,m,h[14],17,-1502002290),m=j(m,v,g,p,h[15],22,1236535329);var C=u.bind(null,_);p=C(p,m,v,g,h[1],5,-165796510),g=C(g,p,m,v,h[6],9,-1069501632),v=C(v,g,p,m,h[11],14,643717713),m=C(m,v,g,p,h[0],20,-373897302),p=C(p,m,v,g,h[5],5,-701558691),g=C(g,p,m,v,h[10],9,38016083),v=C(v,g,p,m,h[15],14,-660478335),m=C(m,v,g,p,h[4],20,-405537848),p=C(p,m,v,g,h[9],5,568446438),g=C(g,p,m,v,h[14],9,-1019803690),v=C(v,g,p,m,h[3],14,-187363961),m=C(m,v,g,p,h[8],20,1163531501),p=C(p,m,v,g,h[13],5,-1444681467),g=C(g,p,m,v,h[2],9,-51403784),v=C(v,g,p,m,h[7],14,1735328473),m=C(m,v,g,p,h[12],20,-1926607734);var S=d.bind(null,_);p=S(p,m,v,g,h[5],4,-378558),g=S(g,p,m,v,h[8],11,-2022574463),v=S(v,g,p,m,h[11],16,1839030562),m=S(m,v,g,p,h[14],23,-35309556),p=S(p,m,v,g,h[1],4,-1530992060),g=S(g,p,m,v,h[4],11,1272893353),v=S(v,g,p,m,h[7],16,-155497632),m=S(m,v,g,p,h[10],23,-1094730640),p=S(p,m,v,g,h[13],4,681279174),g=S(g,p,m,v,h[0],11,-358537222),v=S(v,g,p,m,h[3],16,-722521979),m=S(m,v,g,p,h[6],23,76029189),p=S(p,m,v,g,h[9],4,-640364487),g=S(g,p,m,v,h[12],11,-421815835),v=S(v,g,p,m,h[15],16,530742520),m=S(m,v,g,p,h[2],23,-995338651);var E=f.bind(null,_);p=E(p,m,v,g,h[0],6,-198630844),g=E(g,p,m,v,h[7],10,1126891415),v=E(v,g,p,m,h[14],15,-1416354905),m=E(m,v,g,p,h[5],21,-57434055),p=E(p,m,v,g,h[12],6,1700485571),g=E(g,p,m,v,h[3],10,-1894986606),v=E(v,g,p,m,h[10],15,-1051523),m=E(m,v,g,p,h[1],21,-2054922799),p=E(p,m,v,g,h[8],6,1873313359),g=E(g,p,m,v,h[15],10,-30611744),v=E(v,g,p,m,h[6],15,-1560198380),m=E(m,v,g,p,h[13],21,1309151649),p=E(p,m,v,g,h[4],6,-145523070),g=E(g,p,m,v,h[11],10,-1120210379),v=E(v,g,p,m,h[2],15,718787259),m=E(m,v,g,p,h[9],21,-343485551),b[0]=_(p,b[0]),b[1]=_(m,b[1]),b[2]=_(v,b[2]),b[3]=_(g,b[3])},y=function(b){for(var h=[],_=0;_<64;_+=4)h[_>>2]=b.charCodeAt(_)+(b.charCodeAt(_+1)<<8)+(b.charCodeAt(_+2)<<16)+(b.charCodeAt(_+3)<<24);return h},w=function(b,h){var _,p=b.length,m=[1732584193,-271733879,-1732584194,271733878];for(_=64;_<=p;_+=64)c(m,y(b.substring(_-64,_)),h);var v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],g=(b=b.substring(_-64)).length;for(_=0;_>2]|=b.charCodeAt(_)<<(_%4<<3);if(v[_>>2]|=128<<(_%4<<3),_>55)for(c(m,v,h),_=16;_--;)v[_]=0;return v[14]=8*p,c(m,v,h),m};function x(b){var h;return o(w("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(h=function(_,p){var m=(65535&_)+(65535&p);return(_>>16)+(p>>16)+(m>>16)<<16|65535&m}),o(w(b,h))}}])})});var nl=yn(ii=>{ii.parse=function(t,e){if(e?e.offsets=typeof e.offsets=="undefined"?!0:e.offsets:e={offsets:!0},t||(t=""),t.indexOf(":")===-1&&!e.tokenize)return t;if(!e.keywords&&!e.ranges&&!e.tokenize)return t;var r={text:[]};e.offsets&&(r.offsets=[]);for(var n={},i=[],o=/(\S+:'(?:[^'\\]|\\.)*')|(\S+:"(?:[^"\\]|\\.)*")|(-?"(?:[^"\\]|\\.)*")|(-?'(?:[^'\\]|\\.)*')|\S+|\S+:\S+/g,s;(s=o.exec(t))!==null;){var c=s[0],a=c.indexOf(":");if(a!==-1){var l=c.split(":"),u=c.slice(0,a),d=c.slice(a+1);d=d.replace(/^\"|\"$|^\'|\'$/g,""),d=(d+"").replace(/\\(.?)/g,function(g,j){switch(j){case"\\":return"\\";case"0":return"\0";case"":return"";default:return j}}),i.push({keyword:u,value:d,offsetStart:s.index,offsetEnd:s.index+c.length})}else{var f=!1;c[0]==="-"&&(f=!0,c=c.slice(1)),c=c.replace(/^\"|\"$|^\'|\'$/g,""),c=(c+"").replace(/\\(.?)/g,function(g,j){switch(j){case"\\":return"\\";case"0":return"\0";case"":return"";default:return j}}),f?n.text?(n.text instanceof Array||(n.text=[n.text]),n.text.push(c)):n.text=c:i.push({text:c,offsetStart:s.index,offsetEnd:s.index+c.length})}}i.reverse();for(var c;c=i.pop();)if(c.text)r.text.push(c.text),e.offsets&&r.offsets.push(c);else{var u=c.keyword;e.keywords=e.keywords||[];var y=!1,w=!1;if(!/^-/.test(u))y=e.keywords.indexOf(u)!==-1;else if(u[0]==="-"){var x=u.slice(1);y=e.keywords.indexOf(x)!==-1,y&&(u=x,w=!0)}e.ranges=e.ranges||[];var b=e.ranges.indexOf(u)!==-1;if(y){e.offsets&&r.offsets.push({keyword:u,value:c.value,offsetStart:w?c.offsetStart+1:c.offsetStart,offsetEnd:c.offsetEnd});var h=c.value;if(h.length){var _=h.split(",");w?n[u]?n[u]instanceof Array?_.length>1?n[u]=n[u].concat(_):n[u].push(h):(n[u]=[n[u]],n[u].push(h)):_.length>1?n[u]=_:e.alwaysArray?n[u]=[h]:n[u]=h:r[u]?r[u]instanceof Array?_.length>1?r[u]=r[u].concat(_):r[u].push(h):(r[u]=[r[u]],r[u].push(h)):_.length>1?r[u]=_:e.alwaysArray?r[u]=[h]:r[u]=h}}else if(b){e.offsets&&r.offsets.push(c);var h=c.value,p=h.split("-");r[u]={},p.length===2?(r[u].from=p[0],r[u].to=p[1]):!p.length%2||(r[u].from=h)}else{var m=c.keyword+":"+c.value;r.text.push(m),e.offsets&&r.offsets.push({text:m,offsetStart:c.offsetStart,offsetEnd:c.offsetEnd})}}return r.text.length?e.tokenize||(r.text=r.text.join(" ").trim()):delete r.text,r.exclude=n,r};ii.stringify=function(t,e,r){if(e||(e={offsets:!0}),!t)return"";if(typeof t=="string")return t;if(Array.isArray(t))return t.join(" ");if(!Object.keys(t).length)return"";if(Object.keys(t).length===3&&!!t.text&&!!t.offsets&&!!t.exclude&&typeof t.text=="string")return t.text;r||(r="");var n=function(a){return a.indexOf(" ")>-1?JSON.stringify(a):a},i=function(a){return r+a},o=[];if(t.text){var s=[];typeof t.text=="string"?s.push(t.text):s.push.apply(s,t.text),s.length>0&&o.push(s.map(n).map(i).join(" "))}return e.keywords&&e.keywords.forEach(function(a){if(!!t[a]){var l=[];typeof t[a]=="string"?l.push(t[a]):l.push.apply(l,t[a]),l.length>0&&o.push(i(a+":"+l.map(n).join(",")))}}),e.ranges&&e.ranges.forEach(function(a){if(!!t[a]){var l=t[a].from,u=t[a].to;u&&(l=l+"-"+u),l&&o.push(i(a+":"+l))}}),t.exclude&&Object.keys(t.exclude).length>0&&o.push(ii.stringify(t.exclude,e,"-")),o.join(" ")}});var ol=yn((n_,il)=>{il.exports=nl()});var xc=yn(Si=>{function fs(t){return fs=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},fs(t)}(function(t,e){if(typeof define=="function"&&define.amd)define(["exports"],e);else if(typeof Si!="undefined")e(Si);else{var r={exports:{}};e(r.exports),t.CancelablePromise=r.exports}})(typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:Si,function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CancelablePromise=void 0,t.cancelable=L,t.default=void 0,t.isCancelablePromise=k;function e(A,F){if(typeof F!="function"&&F!==null)throw new TypeError("Super expression must either be null or a function");A.prototype=Object.create(F&&F.prototype,{constructor:{value:A,writable:!0,configurable:!0}}),Object.defineProperty(A,"prototype",{writable:!1}),F&&r(A,F)}function r(A,F){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(N,O){return N.__proto__=O,N},r(A,F)}function n(A){var F=s();return function(){var N=a(A),O;if(F){var X=a(this).constructor;O=Reflect.construct(N,arguments,X)}else O=N.apply(this,arguments);return i(this,O)}}function i(A,F){if(F&&(fs(F)==="object"||typeof F=="function"))return F;if(F!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return o(A)}function o(A){if(A===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return A}function s(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function a(A){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(D){return D.__proto__||Object.getPrototypeOf(D)},a(A)}function l(A,F){var D=typeof Symbol!="undefined"&&A[Symbol.iterator]||A["@@iterator"];if(!D){if(Array.isArray(A)||(D=u(A))||F&&A&&typeof A.length=="number"){D&&(A=D);var N=0,O=function(){};return{s:O,n:function(){return N>=A.length?{done:!0}:{done:!1,value:A[N++]}},e:function(te){throw te},f:O}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var X=!0,le=!1,_e;return{s:function(){D=D.call(A)},n:function(){var te=D.next();return X=te.done,te},e:function(te){le=!0,_e=te},f:function(){try{!X&&D.return!=null&&D.return()}finally{if(le)throw _e}}}}function u(A,F){if(!!A){if(typeof A=="string")return d(A,F);var D=Object.prototype.toString.call(A).slice(8,-1);if(D==="Object"&&A.constructor&&(D=A.constructor.name),D==="Map"||D==="Set")return Array.from(A);if(D==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(D))return d(A,F)}}function d(A,F){(F==null||F>A.length)&&(F=A.length);for(var D=0,N=new Array(F);Dps});var Pr=Fe(require("obsidian"));var Lc=Fe(require("obsidian"));function ce(){}function qc(t,e){for(let r in e)t[r]=e[r];return t}function Di(t){return t()}function bs(){return Object.create(null)}function Ue(t){t.forEach(Di)}function er(t){return typeof t=="function"}function be(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}var vn;function Ti(t,e){return vn||(vn=document.createElement("a")),vn.href=e,t===vn.href}function xs(t){return Object.keys(t).length===0}function ws(t,...e){if(t==null)return ce;let r=t.subscribe(...e);return r.unsubscribe?()=>r.unsubscribe():r}function _n(t,e,r){t.$$.on_destroy.push(ws(e,r))}function tr(t,e,r,n){if(t){let i=js(t,e,r,n);return t[0](i)}}function js(t,e,r,n){return t[1]&&n?qc(r.ctx.slice(),t[1](n(e))):r.ctx}function rr(t,e,r,n){if(t[2]&&n){let i=t[2](n(r));if(e.dirty===void 0)return i;if(typeof i=="object"){let o=[],s=Math.max(e.dirty.length,i.length);for(let a=0;a32){let e=[],r=t.ctx.length/32;for(let n=0;nt.removeEventListener(e,r,n)}function B(t,e,r){r==null?t.removeAttribute(e):t.getAttribute(e)!==r&&t.setAttribute(e,r)}function Xc(t){return Array.from(t.childNodes)}function Ge(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function Ii(t,e){t.value=e??""}function ze(t,e,r,n){r===null?t.style.removeProperty(e):t.style.setProperty(e,r,n?"important":"")}function Oi(t,e,r){t.classList[r?"add":"remove"](e)}function Zc(t,e,{bubbles:r=!1,cancelable:n=!1}={}){let i=document.createEvent("CustomEvent");return i.initCustomEvent(t,r,n,e),i}var Rr;function Lr(t){Rr=t}function ki(){if(!Rr)throw new Error("Function called outside component initialization");return Rr}function Br(t){ki().$$.on_mount.push(t)}function Nr(t){ki().$$.on_destroy.push(t)}function Pi(){let t=ki();return(e,r,{cancelable:n=!1}={})=>{let i=t.$$.callbacks[e];if(i){let o=Zc(e,r,{cancelable:n});return i.slice().forEach(s=>{s.call(t,o)}),!o.defaultPrevented}return!0}}function $e(t,e){let r=t.$$.callbacks[e.type];r&&r.slice().forEach(n=>n.call(this,e))}var Kr=[];var tt=[],xn=[],Ss=[],Fs=Promise.resolve(),Mi=!1;function Es(){Mi||(Mi=!0,Fs.then(Ds))}function mt(){return Es(),Fs}function Ri(t){xn.push(t)}var Li=new Set,wn=0;function Ds(){let t=Rr;do{for(;wn{jn.delete(t),n&&(r&&t.d(1),n())}),t.o(e)}else n&&n()}var qy=typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:global;function Le(t){t&&t.c()}function ke(t,e,r,n){let{fragment:i,after_update:o}=t.$$;i&&i.m(e,r),n||Ri(()=>{let s=t.$$.on_mount.map(Di).filter(er);t.$$.on_destroy?t.$$.on_destroy.push(...s):Ue(s),t.$$.on_mount=[]}),o.forEach(Ri)}function Ee(t,e){let r=t.$$;r.fragment!==null&&(Ue(r.on_destroy),r.fragment&&r.fragment.d(e),r.on_destroy=r.fragment=null,r.ctx=[])}function tf(t,e){t.$$.dirty[0]===-1&&(Kr.push(t),Es(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{let w=y.length?y[0]:c;return u.ctx&&i(u.ctx[f],u.ctx[f]=w)&&(!u.skip_bound&&u.bound[f]&&u.bound[f](w),d&&tf(t,f)),c}):[],u.update(),d=!0,Ue(u.before_update),u.fragment=n?n(u.ctx):!1,e.target){if(e.hydrate){Yc();let f=Xc(e.target);u.fragment&&u.fragment.l(f),f.forEach(H)}else u.fragment&&u.fragment.c();e.intro&&ee(t.$$.fragment),ke(t,e.target,e.anchor,e.customElement),Jc(),Ds()}Lr(l)}var rf;typeof HTMLElement=="function"&&(rf=class extends HTMLElement{constructor(){super();this.attachShadow({mode:"open"})}connectedCallback(){let{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(Di).filter(er);for(let e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(t,e,r){this[t]=r}disconnectedCallback(){Ue(this.$$.on_disconnect)}$destroy(){Ee(this,1),this.$destroy=ce}$on(t,e){if(!er(e))return ce;let r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(e),()=>{let n=r.indexOf(e);n!==-1&&r.splice(n,1)}}$set(t){this.$$set&&!xs(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});var Ae=class{$destroy(){Ee(this,1),this.$destroy=ce}$on(e,r){if(!er(r))return ce;let n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(r),()=>{let i=n.indexOf(r);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!xs(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}};var Mt=Fe(require("obsidian"));var Ha=Fe(require("obsidian"));var Bi=class{constructor(){this.handlers=new Map;this.disabled=[]}on(e,r,n){if(e.includes("@")||r.includes("@"))throw new Error("Invalid context/event name - Cannot contain @");this.handlers.set(`${e}@${r}`,n)}off(e,r){if(r)this.handlers.delete(`${e}@${r}`);else for(let[n]of this.handlers.entries())n.startsWith(`${e}@`)&&this.handlers.delete(n)}disable(e){this.enable(e),this.disabled.push(e)}enable(e){this.disabled=this.disabled.filter(r=>r!==e)}emit(e,...r){let n=[...this.handlers.entries()].filter(([i,o])=>!this.disabled.includes(i.split("@")[0]));for(let[i,o]of n)i.endsWith(`@${e}`)&&o(...r)}};var sr=[];function Cn(t,e=ce){let r,n=new Set;function i(a){if(be(t,a)&&(t=a,r)){let l=!sr.length;for(let u of n)u[1](),sr.push(u,t);if(l){for(let u=0;u{n.delete(u),n.size===0&&(r(),r=null)}}return{set:i,update:o,subscribe:s}}var Y=Fe(require("obsidian"));var ie=typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global,he=Object.keys,Te=Array.isArray;typeof Promise!="undefined"&&!ie.Promise&&(ie.Promise=Promise);function Pe(t,e){return typeof e!="object"||he(e).forEach(function(r){t[r]=e[r]}),t}var zr=Object.getPrototypeOf,nf={}.hasOwnProperty;function Ve(t,e){return nf.call(t,e)}function ar(t,e){typeof e=="function"&&(e=e(zr(t))),(typeof Reflect=="undefined"?he:Reflect.ownKeys)(e).forEach(r=>{rt(t,r,e[r])})}var Ts=Object.defineProperty;function rt(t,e,r,n){Ts(t,e,Pe(r&&Ve(r,"get")&&typeof r.get=="function"?{get:r.get,set:r.set,configurable:!0}:{value:r,configurable:!0,writable:!0},n))}function lr(t){return{from:function(e){return t.prototype=Object.create(e.prototype),rt(t.prototype,"constructor",t),{extend:ar.bind(null,t.prototype)}}}}var of=Object.getOwnPropertyDescriptor;function Ni(t,e){let r=of(t,e),n;return r||(n=zr(t))&&Ni(n,e)}var sf=[].slice;function An(t,e,r){return sf.call(t,e,r)}function Is(t,e){return e(t)}function Vr(t){if(!t)throw new Error("Assertion Failed")}function Os(t){ie.setImmediate?setImmediate(t):setTimeout(t,0)}function ks(t,e){return t.reduce((r,n,i)=>{var o=e(n,i);return o&&(r[o[0]]=o[1]),r},{})}function af(t,e,r){try{t.apply(null,r)}catch(n){e&&e(n)}}function nt(t,e){if(Ve(t,e))return t[e];if(!e)return t;if(typeof e!="string"){for(var r=[],n=0,i=e.length;n["Int","Uint","Float"].map(e=>e+t+"Array")))).filter(t=>ie[t]),cf=Rs.map(t=>ie[t]);ks(Rs,t=>[t,!0]);var gt=null;function Hr(t){gt=typeof WeakMap!="undefined"&&new WeakMap;let e=Ki(t);return gt=null,e}function Ki(t){if(!t||typeof t!="object")return t;let e=gt&>.get(t);if(e)return e;if(Te(t)){e=[],gt&>.set(t,e);for(var r=0,n=t.length;r=0)e=t;else{let o=zr(t);e=o===Object.prototype?{}:Object.create(o),gt&>.set(t,e);for(var i in t)Ve(t,i)&&(e[i]=Ki(t[i]))}return e}var{toString:ff}={};function zi(t){return ff.call(t).slice(8,-1)}var Vi=typeof Symbol!="undefined"?Symbol.iterator:"@@iterator",df=typeof Vi=="symbol"?function(t){var e;return t!=null&&(e=t[Vi])&&e.apply(t)}:function(){return null},ur={};function it(t){var e,r,n,i;if(arguments.length===1){if(Te(t))return t.slice();if(this===ur&&typeof t=="string")return[t];if(i=df(t)){for(r=[];n=i.next(),!n.done;)r.push(n.value);return r}if(t==null)return[t];if(e=t.length,typeof e=="number"){for(r=new Array(e);e--;)r[e]=t[e];return r}return[t]}for(e=arguments.length,r=new Array(e);e--;)r[e]=arguments[e];return r}var Hi=typeof Symbol!="undefined"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1,Je=typeof location!="undefined"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Ls(t,e){Je=t,Bs=e}var Bs=()=>!0,hf=!new Error("").stack;function Nt(){if(hf)try{throw Nt.arguments,new Error}catch(t){return t}return new Error}function $i(t,e){var r=t.stack;return r?(e=e||0,r.indexOf(t.name)===0&&(e+=(t.name+t.message).split(` `).length),r.split(` -`).slice(e).filter(Co).map(n=>` -`+n).join("")):""}var Zc=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"],Fo=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Mi=Zc.concat(Fo),ef={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function rr(t,e){this._e=kt(),this.name=t,this.message=e}er(rr).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Oi(this._e,2))}},toString:function(){return this.name+": "+this.message}});function So(t,e){return t+". Errors: "+Object.keys(e).map(r=>e[r].toString()).filter((r,n,i)=>i.indexOf(r)===n).join(` -`)}function mn(t,e,r,n){this._e=kt(),this.failures=e,this.failedKeys=n,this.successCount=r,this.message=So(t,e)}er(mn).from(rr);function Rr(t,e){this._e=kt(),this.name="BulkError",this.failures=Object.keys(e).map(r=>e[r]),this.failuresByPos=e,this.message=So(t,e)}er(Rr).from(rr);var Pi=Mi.reduce((t,e)=>(t[e]=e+"Error",t),{}),tf=rr,L=Mi.reduce((t,e)=>{var r=e+"Error";function n(i,s){this._e=kt(),this.name=r,i?typeof i=="string"?(this.message=`${i}${s?` - `+s:""}`,this.inner=s||null):typeof i=="object"&&(this.message=`${i.name} ${i.message}`,this.inner=i):(this.message=ef[e]||r,this.inner=null)}return er(n).from(tf),t[e]=n,t},{});L.Syntax=SyntaxError;L.Type=TypeError;L.Range=RangeError;var Eo=Fo.reduce((t,e)=>(t[e+"Error"]=L[e],t),{});function rf(t,e){if(!t||t instanceof rr||t instanceof TypeError||t instanceof SyntaxError||!t.name||!Eo[t.name])return t;var r=new Eo[t.name](e||t.message,t);return"stack"in t&&We(r,"stack",{get:function(){return this.inner.stack}}),r}var gn=Mi.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=L[e]),t),{});gn.ModifyError=mn;gn.DexieError=rr;gn.BulkError=Rr;function Y(){}function Br(t){return t}function nf(t,e){return t==null||t===Br?e:function(r){return e(t(r))}}function It(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function sf(t,e){return t===Y?e:function(){var r=t.apply(this,arguments);r!==void 0&&(arguments[0]=r);var n=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var s=e.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?It(n,this.onsuccess):n),i&&(this.onerror=this.onerror?It(i,this.onerror):i),s!==void 0?s:r}}function of(t,e){return t===Y?e:function(){t.apply(this,arguments);var r=this.onsuccess,n=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),r&&(this.onsuccess=this.onsuccess?It(r,this.onsuccess):r),n&&(this.onerror=this.onerror?It(n,this.onerror):n)}}function af(t,e){return t===Y?e:function(r){var n=t.apply(this,arguments);je(r,n);var i=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var o=e.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?It(i,this.onsuccess):i),s&&(this.onerror=this.onerror?It(s,this.onerror):s),n===void 0?o===void 0?void 0:o:je(n,o)}}function lf(t,e){return t===Y?e:function(){return e.apply(this,arguments)===!1?!1:t.apply(this,arguments)}}function Ri(t,e){return t===Y?e:function(){var r=t.apply(this,arguments);if(r&&typeof r.then=="function"){for(var n=this,i=arguments.length,s=new Array(i);i--;)s[i]=arguments[i];return r.then(function(){return e.apply(n,s)})}return e.apply(this,arguments)}}var Lr={},uf=100,cf=20,Do=100,[Bi,yn,Li]=typeof Promise=="undefined"?[]:(()=>{let t=Promise.resolve();if(typeof crypto=="undefined"||!crypto.subtle)return[t,Or(t),t];let e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,Or(e),t]})(),To=yn&&yn.then,vn=Bi&&Bi.constructor,Ni=!!Li,Ki=!1,ff=Li?()=>{Li.then(wn)}:J.setImmediate?setImmediate.bind(null,wn):J.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{wn(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(wn,0)},Nr=function(t,e){Kr.push([t,e]),_n&&(ff(),_n=!1)},zi=!0,_n=!0,Ot=[],xn=[],Vi=null,$i=Br,nr={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:Ko,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{Ko(t[0],t[1])}catch{}})}},R=nr,Kr=[],Mt=0,bn=[];function I(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=Y,this._lib=!1;var e=this._PSD=R;if(Ke&&(this._stackHolder=kt(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Lr)throw new TypeError("Not a function");this._state=arguments[1],this._value=arguments[2],this._state===!1&&Wi(this,this._value);return}this._state=null,this._value=null,++e.ref,Io(this,t)}var Hi={get:function(){var t=R,e=Cn;function r(n,i){var s=!t.global&&(t!==R||e!==Cn);let o=s&&!Qe();var a=new I((l,u)=>{Ui(this,new ko(Sn(n,t,s,o),Sn(i,t,s,o),l,u,t))});return Ke&&Po(a,this),a}return r.prototype=Lr,r},set:function(t){We(this,"then",t&&t.prototype===Lr?Hi:{get:function(){return t},set:Hi.set})}};Zt(I.prototype,{then:Hi,_then:function(t,e){Ui(this,new ko(null,null,t,e,R))},catch:function(t){if(arguments.length===1)return this.then(null,t);var e=arguments[0],r=arguments[1];return typeof e=="function"?this.then(null,n=>n instanceof e?r(n):jn(n)):this.then(null,n=>n&&n.name===e?r(n):jn(n))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),jn(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Ki=!0;var t=Mo(this,[],cf),e=t.join(` -From previous: `);return this._state!==null&&(this._stack=e),e}finally{Ki=!1}}},timeout:function(t,e){return t<1/0?new I((r,n)=>{var i=setTimeout(()=>n(new L.Timeout(e)),t);this.then(r,n).finally(clearTimeout.bind(null,i))}):this}});typeof Symbol!="undefined"&&Symbol.toStringTag&&We(I.prototype,Symbol.toStringTag,"Dexie.Promise");nr.env=Ro();function ko(t,e,r,n,i){this.onFulfilled=typeof t=="function"?t:null,this.onRejected=typeof e=="function"?e:null,this.resolve=r,this.reject=n,this.psd=i}Zt(I,{all:function(){var t=Ge.apply(null,arguments).map(Fn);return new I(function(e,r){t.length===0&&e([]);var n=t.length;t.forEach((i,s)=>I.resolve(i).then(o=>{t[s]=o,--n||e(t)},r))})},resolve:t=>{if(t instanceof I)return t;if(t&&typeof t.then=="function")return new I((r,n)=>{t.then(r,n)});var e=new I(Lr,!0,t);return Po(e,Vi),e},reject:jn,race:function(){var t=Ge.apply(null,arguments).map(Fn);return new I((e,r)=>{t.map(n=>I.resolve(n).then(e,r))})},PSD:{get:()=>R,set:t=>R=t},totalEchoes:{get:()=>Cn},newPSD:lt,usePSD:sr,scheduler:{get:()=>Nr,set:t=>{Nr=t}},rejectionMapper:{get:()=>$i,set:t=>{$i=t}},follow:(t,e)=>new I((r,n)=>lt((i,s)=>{var o=R;o.unhandleds=[],o.onunhandled=s,o.finalize=It(function(){hf(()=>{this.unhandleds.length===0?i():s(this.unhandleds[0])})},o.finalize),t()},e,r,n))});vn&&(vn.allSettled&&We(I,"allSettled",function(){let t=Ge.apply(null,arguments).map(Fn);return new I(e=>{t.length===0&&e([]);let r=t.length,n=new Array(r);t.forEach((i,s)=>I.resolve(i).then(o=>n[s]={status:"fulfilled",value:o},o=>n[s]={status:"rejected",reason:o}).then(()=>--r||e(n)))})}),vn.any&&typeof AggregateError!="undefined"&&We(I,"any",function(){let t=Ge.apply(null,arguments).map(Fn);return new I((e,r)=>{t.length===0&&r(new AggregateError([]));let n=t.length,i=new Array(n);t.forEach((s,o)=>I.resolve(s).then(a=>e(a),a=>{i[o]=a,--n||r(new AggregateError(i))}))})}));function Io(t,e){try{e(r=>{if(t._state===null){if(r===t)throw new TypeError("A promise cannot be resolved with itself.");var n=t._lib&&zr();r&&typeof r.then=="function"?Io(t,(i,s)=>{r instanceof I?r._then(i,s):r.then(i,s)}):(t._state=!0,t._value=r,Oo(t)),n&&Vr()}},Wi.bind(null,t))}catch(r){Wi(t,r)}}function Wi(t,e){if(xn.push(e),t._state===null){var r=t._lib&&zr();e=$i(e),t._state=!1,t._value=e,Ke&&e!==null&&typeof e=="object"&&!e._promise&&Uc(()=>{var n=Ei(e,"stack");e._promise=t,We(e,"stack",{get:()=>Ki?n&&(n.get?n.get.apply(e):n.value):t.stack})}),pf(t),Oo(t),r&&Vr()}}function Oo(t){var e=t._listeners;t._listeners=[];for(var r=0,n=e.length;r{--Mt==0&&Gi()},[]))}function Ui(t,e){if(t._state===null){t._listeners.push(e);return}var r=t._state?e.onFulfilled:e.onRejected;if(r===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++Mt,Nr(df,[r,t,e])}function df(t,e,r){try{Vi=e;var n,i=e._value;e._state?n=t(i):(xn.length&&(xn=[]),n=t(i),xn.indexOf(i)===-1&&mf(e)),r.resolve(n)}catch(s){r.reject(s)}finally{Vi=null,--Mt==0&&Gi(),--r.psd.ref||r.psd.finalize()}}function Mo(t,e,r){if(e.length===r)return e;var n="";if(t._state===!1){var i=t._value,s,o;i!=null?(s=i.name||"Error",o=i.message||i,n=Oi(i,0)):(s=i,o=""),e.push(s+(o?": "+o:"")+n)}return Ke&&(n=Oi(t._stackHolder,2),n&&e.indexOf(n)===-1&&e.push(n),t._prev&&Mo(t._prev,e,r)),e}function Po(t,e){var r=e?e._numPrev+1:0;r0;)for(t=Kr,Kr=[],r=t.length,e=0;e0);zi=!0,_n=!0}function Gi(){var t=Ot;Ot=[],t.forEach(n=>{n._PSD.onunhandled.call(null,n._value,n)});for(var e=bn.slice(0),r=e.length;r;)e[--r]()}function hf(t){function e(){t(),bn.splice(bn.indexOf(e),1)}bn.push(e),++Mt,Nr(()=>{--Mt==0&&Gi()},[])}function pf(t){Ot.some(e=>e._value===t._value)||Ot.push(t)}function mf(t){for(var e=Ot.length;e;)if(Ot[--e]._value===t._value){Ot.splice(e,1);return}}function jn(t){return new I(Lr,!1,t)}function Z(t,e){var r=R;return function(){var n=zr(),i=R;try{return ut(r,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{ut(i,!1),n&&Vr()}}}var _e={awaits:0,echoes:0,id:0},gf=0,An=[],Qi=0,Cn=0,yf=0;function lt(t,e,r,n){var i=R,s=Object.create(i);s.parent=i,s.ref=0,s.global=!1,s.id=++yf;var o=nr.env;s.env=Ni?{Promise:I,PromiseProp:{value:I,configurable:!0,writable:!0},all:I.all,race:I.race,allSettled:I.allSettled,any:I.any,resolve:I.resolve,reject:I.reject,nthen:Lo(o.nthen,s),gthen:Lo(o.gthen,s)}:{},e&&je(s,e),++i.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=sr(s,t,r,n);return s.ref===0&&s.finalize(),a}function ir(){return _e.id||(_e.id=++gf),++_e.awaits,_e.echoes+=Do,_e.id}function Qe(){return _e.awaits?(--_e.awaits==0&&(_e.id=0),_e.echoes=_e.awaits*Do,!0):!1}(""+To).indexOf("[native code]")===-1&&(ir=Qe=Y);function Fn(t){return _e.echoes&&t&&t.constructor===vn?(ir(),t.then(e=>(Qe(),e),e=>(Qe(),le(e)))):t}function vf(t){++Cn,(!_e.echoes||--_e.echoes==0)&&(_e.echoes=_e.id=0),An.push(R),ut(t,!0)}function _f(){var t=An[An.length-1];An.pop(),ut(t,!1)}function ut(t,e){var r=R;if((e?_e.echoes&&(!Qi++||t!==R):Qi&&(!--Qi||t!==R))&&Bo(e?vf.bind(null,t):_f),t!==R&&(R=t,r===nr&&(nr.env=Ro()),Ni)){var n=nr.env.Promise,i=t.env;yn.then=i.nthen,n.prototype.then=i.gthen,(r.global||t.global)&&(Object.defineProperty(J,"Promise",i.PromiseProp),n.all=i.all,n.race=i.race,n.resolve=i.resolve,n.reject=i.reject,i.allSettled&&(n.allSettled=i.allSettled),i.any&&(n.any=i.any))}}function Ro(){var t=J.Promise;return Ni?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(J,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:yn.then,gthen:t.prototype.then}:{}}function sr(t,e,r,n,i){var s=R;try{return ut(t,!0),e(r,n,i)}finally{ut(s,!1)}}function Bo(t){To.call(Bi,t)}function Sn(t,e,r,n){return typeof t!="function"?t:function(){var i=R;r&&ir(),ut(e,!0);try{return t.apply(this,arguments)}finally{ut(i,!1),n&&Bo(Qe)}}}function Lo(t,e){return function(r,n){return t.call(this,Sn(r,e),Sn(n,e))}}var No="unhandledrejection";function Ko(t,e){var r;try{r=e.onuncatched(t)}catch{}if(r!==!1)try{var n,i={promise:e,reason:t};if(J.document&&document.createEvent?(n=document.createEvent("Event"),n.initEvent(No,!0,!0),je(n,i)):J.CustomEvent&&(n=new CustomEvent(No,{detail:i}),je(n,i)),n&&J.dispatchEvent&&(dispatchEvent(n),!J.PromiseRejectionEvent&&J.onunhandledrejection))try{J.onunhandledrejection(n)}catch{}Ke&&n&&!n.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var le=I.reject;function qi(t,e,r,n){if(!t.idbdb||!t._state.openComplete&&!R.letThrough&&!t._vip){if(t._state.openComplete)return le(new L.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return le(new L.DatabaseClosed);t.open().catch(Y)}return t._state.dbReadyPromise.then(()=>qi(t,e,r,n))}else{var i=t._createTransaction(e,r,t._dbSchema);try{i.create(),t._state.PR1398_maxLoop=3}catch(s){return s.name===Pi.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>qi(t,e,r,n))):le(s)}return i._promise(e,(s,o)=>lt(()=>(R.trans=i,n(s,o,i)))).then(s=>i._completion.then(()=>s))}}var zo="3.2.2",Pt=String.fromCharCode(65535),Yi=-1/0,qe="Invalid key provided. Keys must be of type string, number, Date or Array.",Vo="String expected.",$r=[],En=typeof navigator!="undefined"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),xf=En,bf=En,$o=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),Dn="__dbnames",Ji="readonly",Xi="readwrite";function Rt(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}var Ho={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Tn(t){return typeof t=="string"&&!/\./.test(t)?e=>(e[t]===void 0&&t in e&&(e=Pr(e),delete e[t]),e):e=>e}var Wo=class{_trans(e,r,n){let i=this._tx||R.trans,s=this.name;function o(l,u,c){if(!c.schema[s])throw new L.NotFound("Table "+s+" not part of transaction");return r(c.idbtrans,c)}let a=zr();try{return i&&i.db===this.db?i===R.trans?i._promise(e,o,n):lt(()=>i._promise(e,o,n),{trans:i,transless:R.transless||R}):qi(this.db,e,[this.name],o)}finally{a&&Vr()}}get(e,r){return e&&e.constructor===Object?this.where(e).first(r):this._trans("readonly",n=>this.core.get({trans:n,key:e}).then(i=>this.hook.reading.fire(i))).then(r)}where(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(ve(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let r=oe(e);if(r.length===1)return this.where(r[0]).equals(e[r[0]]);let n=this.schema.indexes.concat(this.schema.primKey).filter(u=>u.compound&&r.every(c=>u.keyPath.indexOf(c)>=0)&&u.keyPath.every(c=>r.indexOf(c)>=0))[0];if(n&&this.db._maxKey!==Pt)return this.where(n.name).equals(n.keyPath.map(u=>e[u]));!n&&Ke&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${r.join("+")}]`);let{idxByName:i}=this.schema,s=this.db._deps.indexedDB;function o(u,c){try{return s.cmp(u,c)===0}catch{return!1}}let[a,l]=r.reduce(([u,c],d)=>{let f=i[d],y=e[d];return[u||f,u||!f?Rt(c,f&&f.multi?w=>{let b=Ue(w,d);return ve(b)&&b.some(x=>o(y,x))}:w=>o(y,Ue(w,d))):c]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(l):n?this.filter(l):this.where(r).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,ve(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let r=n=>{if(!n)return n;let i=Object.create(e.prototype);for(var s in n)if(Ie(n,s))try{i[s]=n[s]}catch{}return i};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=r,this.hook("reading",r),e}defineClass(){function e(r){je(this,r)}return this.mapToClass(e)}add(e,r){let{auto:n,keyPath:i}=this.schema.primKey,s=e;return i&&n&&(s=Tn(i)(e)),this._trans("readwrite",o=>this.core.mutate({trans:o,type:"add",keys:r!=null?[r]:null,values:[s]})).then(o=>o.numFailures?I.reject(o.failures[0]):o.lastResult).then(o=>{if(i)try{Be(e,i,o)}catch{}return o})}update(e,r){if(typeof e=="object"&&!ve(e)){let n=Ue(e,this.schema.primKey.keyPath);if(n===void 0)return le(new L.InvalidArgument("Given object does not contain its primary key"));try{typeof r!="function"?oe(r).forEach(i=>{Be(e,i,r[i])}):r(e,{value:e,primKey:n})}catch{}return this.where(":id").equals(n).modify(r)}else return this.where(":id").equals(e).modify(r)}put(e,r){let{auto:n,keyPath:i}=this.schema.primKey,s=e;return i&&n&&(s=Tn(i)(e)),this._trans("readwrite",o=>this.core.mutate({trans:o,type:"put",values:[s],keys:r!=null?[r]:null})).then(o=>o.numFailures?I.reject(o.failures[0]):o.lastResult).then(o=>{if(i)try{Be(e,i,o)}catch{}return o})}delete(e){return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:[e]})).then(r=>r.numFailures?I.reject(r.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:Ho})).then(e=>e.numFailures?I.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",r=>this.core.getMany({keys:e,trans:r}).then(n=>n.map(i=>this.hook.reading.fire(i))))}bulkAdd(e,r,n){let i=Array.isArray(r)?r:void 0;n=n||(i?void 0:r);let s=n?n.allKeys:void 0;return this._trans("readwrite",o=>{let{auto:a,keyPath:l}=this.schema.primKey;if(l&&i)throw new L.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new L.InvalidArgument("Arguments objects and keys must have the same length");let u=e.length,c=l&&a?e.map(Tn(l)):e;return this.core.mutate({trans:o,type:"add",keys:i,values:c,wantResults:s}).then(({numFailures:d,results:f,lastResult:y,failures:w})=>{let b=s?f:y;if(d===0)return b;throw new Rr(`${this.name}.bulkAdd(): ${d} of ${u} operations failed`,w)})})}bulkPut(e,r,n){let i=Array.isArray(r)?r:void 0;n=n||(i?void 0:r);let s=n?n.allKeys:void 0;return this._trans("readwrite",o=>{let{auto:a,keyPath:l}=this.schema.primKey;if(l&&i)throw new L.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new L.InvalidArgument("Arguments objects and keys must have the same length");let u=e.length,c=l&&a?e.map(Tn(l)):e;return this.core.mutate({trans:o,type:"put",keys:i,values:c,wantResults:s}).then(({numFailures:d,results:f,lastResult:y,failures:w})=>{let b=s?f:y;if(d===0)return b;throw new Rr(`${this.name}.bulkPut(): ${d} of ${u} operations failed`,w)})})}bulkDelete(e){let r=e.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:e})).then(({numFailures:n,lastResult:i,failures:s})=>{if(n===0)return i;throw new Rr(`${this.name}.bulkDelete(): ${n} of ${r} operations failed`,s)})}};function Hr(t){var e={},r=function(a,l){if(l){for(var u=arguments.length,c=new Array(u-1);--u;)c[u-1]=arguments[u];return e[a].subscribe.apply(null,c),t}else if(typeof a=="string")return e[a]};r.addEventType=s;for(var n=1,i=arguments.length;nRt(n(),e()):e,t.justLimit=r&&!n}function jf(t,e){t.isMatch=Rt(t.isMatch,e)}function kn(t,e){if(t.isPrimKey)return e.primaryKey;let r=e.getIndexByKeyPath(t.index);if(!r)throw new L.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return r}function Uo(t,e,r){let n=kn(t,e.schema);return e.openCursor({trans:r,values:!t.keysOnly,reverse:t.dir==="prev",unique:!!t.unique,query:{index:n,range:t.range}})}function In(t,e,r,n){let i=t.replayFilter?Rt(t.filter,t.replayFilter()):t.filter;if(t.or){let s={},o=(a,l,u)=>{if(!i||i(l,u,f=>l.stop(f),f=>l.fail(f))){var c=l.primaryKey,d=""+c;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(c)),Ie(s,d)||(s[d]=!0,e(a,l,u))}};return Promise.all([t.or._iterate(o,r),Go(Uo(t,n,r),t.algorithm,o,!t.keysOnly&&t.valueMapper)])}else return Go(Uo(t,n,r),Rt(t.algorithm,i),e,!t.keysOnly&&t.valueMapper)}function Go(t,e,r,n){var i=n?(o,a,l)=>r(n(o),a,l):r,s=Z(i);return t.then(o=>{if(o)return o.start(()=>{var a=()=>o.continue();(!e||e(o,l=>a=l,l=>{o.stop(l),a=Y},l=>{o.fail(l),a=Y}))&&s(o.value,o,l=>a=l),a()})})}function Ae(t,e){try{let r=Qo(t),n=Qo(e);if(r!==n)return r==="Array"?1:n==="Array"?-1:r==="binary"?1:n==="binary"?-1:r==="string"?1:n==="string"?-1:r==="Date"?1:n!=="Date"?NaN:-1;switch(r){case"number":case"Date":case"string":return t>e?1:tIn(r,e,n,r.table.core))}count(e){return this._read(r=>{let n=this._ctx,i=n.table.core;if(or(n,!0))return i.count({trans:r,query:{index:kn(n,i.schema),range:n.range}}).then(o=>Math.min(o,n.limit));var s=0;return In(n,()=>(++s,!1),r,i).then(()=>s)}).then(e)}sortBy(e,r){let n=e.split(".").reverse(),i=n[0],s=n.length-1;function o(u,c){return c?o(u[n[c]],c-1):u[i]}var a=this._ctx.dir==="next"?1:-1;function l(u,c){var d=o(u,s),f=o(c,s);return df?a:0}return this.toArray(function(u){return u.sort(l)}).then(r)}toArray(e){return this._read(r=>{var n=this._ctx;if(n.dir==="next"&&or(n,!0)&&n.limit>0){let{valueMapper:i}=n,s=kn(n,n.table.core.schema);return n.table.core.query({trans:r,limit:n.limit,values:!0,query:{index:s,range:n.range}}).then(({result:o})=>i?o.map(i):o)}else{let i=[];return In(n,s=>i.push(s),r,n.table.core).then(()=>i)}},e)}offset(e){var r=this._ctx;return e<=0?this:(r.offset+=e,or(r)?es(r,()=>{var n=e;return(i,s)=>n===0?!0:n===1?(--n,!1):(s(()=>{i.advance(n),n=0}),!1)}):es(r,()=>{var n=e;return()=>--n<0}),this)}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),es(this._ctx,()=>{var r=e;return function(n,i,s){return--r<=0&&i(s),r>=0}},!0),this}until(e,r){return Zi(this._ctx,function(n,i,s){return e(n.value)?(i(s),r):!0}),this}first(e){return this.limit(1).toArray(function(r){return r[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){return Zi(this._ctx,function(r){return e(r.value)}),jf(this._ctx,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var r=this._ctx;return r.keysOnly=!r.isMatch,this.each(function(n,i){e(i.key,i)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var r=this._ctx;return r.keysOnly=!r.isMatch,this.each(function(n,i){e(i.primaryKey,i)})}keys(e){var r=this._ctx;r.keysOnly=!r.isMatch;var n=[];return this.each(function(i,s){n.push(s.key)}).then(function(){return n}).then(e)}primaryKeys(e){var r=this._ctx;if(r.dir==="next"&&or(r,!0)&&r.limit>0)return this._read(i=>{var s=kn(r,r.table.core.schema);return r.table.core.query({trans:i,values:!1,limit:r.limit,query:{index:s,range:r.range}})}).then(({result:i})=>i).then(e);r.keysOnly=!r.isMatch;var n=[];return this.each(function(i,s){n.push(s.primaryKey)}).then(function(){return n}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(r){return r[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,r=e.index&&e.table.schema.idxByName[e.index];if(!r||!r.multi)return this;var n={};return Zi(this._ctx,function(i){var s=i.primaryKey.toString(),o=Ie(n,s);return n[s]=!0,!o}),this}modify(e){var r=this._ctx;return this._write(n=>{var i;if(typeof e=="function")i=e;else{var s=oe(e),o=s.length;i=function(b){for(var x=!1,h=0;h{let{failures:h,numFailures:v}=x;f+=b-v;for(let p of oe(h))d.push(h[p])};return this.clone().primaryKeys().then(b=>{let x=h=>{let v=Math.min(c,b.length-h);return a.getMany({trans:n,keys:b.slice(h,h+v),cache:"immutable"}).then(p=>{let m=[],_=[],g=l?[]:null,j=[];for(let C=0;C0&&a.mutate({trans:n,type:"add",values:m}).then(C=>{for(let F in C.failures)j.splice(parseInt(F),1);w(m.length,C)})).then(()=>(_.length>0||A&&typeof e=="object")&&a.mutate({trans:n,type:"put",keys:g,values:_,criteria:A,changeSpec:typeof e!="function"&&e}).then(C=>w(_.length,C))).then(()=>(j.length>0||A&&e===ts)&&a.mutate({trans:n,type:"delete",keys:j,criteria:A}).then(C=>w(j.length,C))).then(()=>b.length>h+v&&x(h+c))})};return x(0).then(()=>{if(d.length>0)throw new mn("Error modifying one or more objects",d,f,y);return b.length})})})}delete(){var e=this._ctx,r=e.range;return or(e)&&(e.isPrimKey&&!bf||r.type===3)?this._write(n=>{let{primaryKey:i}=e.table.core.schema,s=r;return e.table.core.count({trans:n,query:{index:i,range:s}}).then(o=>e.table.core.mutate({trans:n,type:"deleteRange",range:s}).then(({failures:a,lastResult:l,results:u,numFailures:c})=>{if(c)throw new mn("Could not delete some values",Object.keys(a).map(d=>a[d]),o-c);return o-c}))}):this.modify(ts)}},ts=(t,e)=>e.value=null;function Ff(t){return Wr(Yo.prototype,function(r,n){this.db=t;let i=Ho,s=null;if(n)try{i=n()}catch(u){s=u}let o=r._ctx,a=o.table,l=a.hook.reading.fire;this._ctx={table:a,index:o.index,isPrimKey:!o.index||a.schema.primKey.keyPath&&o.index===a.schema.primKey.name,range:i,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:s,or:o.or,valueMapper:l!==Br?l:null}})}function Sf(t,e){return te?-1:t===e?0:1}function Oe(t,e,r){var n=t instanceof rs?new t.Collection(t):t;return n._ctx.error=r?new r(e):new TypeError(e),n}function ar(t){return new t.Collection(t,()=>Jo("")).limit(0)}function Df(t){return t==="next"?e=>e.toUpperCase():e=>e.toLowerCase()}function Tf(t){return t==="next"?e=>e.toLowerCase():e=>e.toUpperCase()}function kf(t,e,r,n,i,s){for(var o=Math.min(t.length,n.length),a=-1,l=0;l=0?t.substr(0,a)+e[a]+r.substr(a+1):null;i(t[l],u)<0&&(a=l)}return otypeof b=="string"))return Oe(t,Vo);function f(b){i=Df(b),s=Tf(b),o=b==="next"?Sf:Ef;var x=r.map(function(h){return{lower:s(h),upper:i(h)}}).sort(function(h,v){return o(h.lower,v.lower)});a=x.map(function(h){return h.upper}),l=x.map(function(h){return h.lower}),u=b,c=b==="next"?"":n}f("next");var y=new t.Collection(t,()=>ct(a[0],l[d-1]+n));y._ondirectionchange=function(b){f(b)};var w=0;return y._addAlgorithm(function(b,x,h){var v=b.key;if(typeof v!="string")return!1;var p=s(v);if(e(p,l,w))return!0;for(var m=null,_=w;_0)&&(m=g)}return x(m!==null?function(){b.continue(m+c)}:h),!1}),y}function ct(t,e,r,n){return{type:2,lower:t,upper:e,lowerOpen:r,upperOpen:n}}function Jo(t){return{type:1,lower:t,upper:t}}var rs=class{get Collection(){return this._ctx.table.db.Collection}between(e,r,n,i){n=n!==!1,i=i===!0;try{return this._cmp(e,r)>0||this._cmp(e,r)===0&&(n||i)&&!(n&&i)?ar(this):new this.Collection(this,()=>ct(e,r,!n,!i))}catch{return Oe(this,qe)}}equals(e){return e==null?Oe(this,qe):new this.Collection(this,()=>Jo(e))}above(e){return e==null?Oe(this,qe):new this.Collection(this,()=>ct(e,void 0,!0))}aboveOrEqual(e){return e==null?Oe(this,qe):new this.Collection(this,()=>ct(e,void 0,!1))}below(e){return e==null?Oe(this,qe):new this.Collection(this,()=>ct(void 0,e,!1,!0))}belowOrEqual(e){return e==null?Oe(this,qe):new this.Collection(this,()=>ct(void 0,e))}startsWith(e){return typeof e!="string"?Oe(this,Vo):this.between(e,e+Pt,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):On(this,(r,n)=>r.indexOf(n[0])===0,[e],Pt)}equalsIgnoreCase(e){return On(this,(r,n)=>r===n[0],[e],"")}anyOfIgnoreCase(){var e=Ge.apply(tr,arguments);return e.length===0?ar(this):On(this,(r,n)=>n.indexOf(r)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=Ge.apply(tr,arguments);return e.length===0?ar(this):On(this,(r,n)=>n.some(i=>r.indexOf(i)===0),e,Pt)}anyOf(){let e=Ge.apply(tr,arguments),r=this._cmp;try{e.sort(r)}catch{return Oe(this,qe)}if(e.length===0)return ar(this);let n=new this.Collection(this,()=>ct(e[0],e[e.length-1]));n._ondirectionchange=s=>{r=s==="next"?this._ascending:this._descending,e.sort(r)};let i=0;return n._addAlgorithm((s,o,a)=>{let l=s.key;for(;r(l,e[i])>0;)if(++i,i===e.length)return o(a),!1;return r(l,e[i])===0?!0:(o(()=>{s.continue(e[i])}),!1)}),n}notEqual(e){return this.inAnyRange([[Yi,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=Ge.apply(tr,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return Oe(this,qe)}let r=e.reduce((n,i)=>n?n.concat([[n[n.length-1][1],i]]):[[Yi,i]],null);return r.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(r,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,r){let n=this._cmp,i=this._ascending,s=this._descending,o=this._min,a=this._max;if(e.length===0)return ar(this);if(!e.every(m=>m[0]!==void 0&&m[1]!==void 0&&i(m[0],m[1])<=0))return Oe(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",L.InvalidArgument);let l=!r||r.includeLowers!==!1,u=r&&r.includeUppers===!0;function c(m,_){let g=0,j=m.length;for(;g0){A[0]=o(A[0],_[0]),A[1]=a(A[1],_[1]);break}}return g===j&&m.push(_),m}let d=i;function f(m,_){return d(m[0],_[0])}let y;try{y=e.reduce(c,[]),y.sort(f)}catch{return Oe(this,qe)}let w=0,b=u?m=>i(m,y[w][1])>0:m=>i(m,y[w][1])>=0,x=l?m=>s(m,y[w][0])>0:m=>s(m,y[w][0])>=0;function h(m){return!b(m)&&!x(m)}let v=b,p=new this.Collection(this,()=>ct(y[0][0],y[y.length-1][1],!l,!u));return p._ondirectionchange=m=>{m==="next"?(v=b,d=i):(v=x,d=s),y.sort(f)},p._addAlgorithm((m,_,g)=>{for(var j=m.key;v(j);)if(++w,w===y.length)return _(g),!1;return h(j)?!0:(this._cmp(j,y[w][1])===0||this._cmp(j,y[w][0])===0||_(()=>{d===i?m.continue(y[w][0]):m.continue(y[w][1])}),!1)}),p}startsWithAnyOf(){let e=Ge.apply(tr,arguments);return e.every(r=>typeof r=="string")?e.length===0?ar(this):this.inAnyRange(e.map(r=>[r,r+Pt])):Oe(this,"startsWithAnyOf() only works with strings")}};function If(t){return Wr(rs.prototype,function(r,n,i){this.db=t,this._ctx={table:r,index:n===":id"?null:n,or:i};let s=t._deps.indexedDB;if(!s)throw new L.MissingAPI;this._cmp=this._ascending=s.cmp.bind(s),this._descending=(o,a)=>s.cmp(a,o),this._max=(o,a)=>s.cmp(o,a)>0?o:a,this._min=(o,a)=>s.cmp(o,a)<0?o:a,this._IDBKeyRange=t._deps.IDBKeyRange})}function ze(t){return Z(function(e){return Ur(e),t(e.target.error),!1})}function Ur(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}var Gr="storagemutated",ft="x-storagemutated-1",dt=Hr(null,Gr),Xo=class{_lock(){return Mr(!R.global),++this._reculock,this._reculock===1&&!R.global&&(R.lockOwnerFor=this),this}_unlock(){if(Mr(!R.global),--this._reculock==0)for(R.global||(R.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{sr(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&R.lockOwnerFor!==this}create(e){if(!this.mode)return this;let r=this.db.idbdb,n=this.db._state.dbOpenError;if(Mr(!this.idbtrans),!e&&!r)switch(n&&n.name){case"DatabaseClosedError":throw new L.DatabaseClosed(n);case"MissingAPIError":throw new L.MissingAPI(n.message,n);default:throw new L.OpenFailed(n)}if(!this.active)throw new L.TransactionInactive;return Mr(this._completion._state===null),e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):r.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})),e.onerror=Z(i=>{Ur(i),this._reject(e.error)}),e.onabort=Z(i=>{Ur(i),this.active&&this._reject(new L.Abort(e.error)),this.active=!1,this.on("abort").fire(i)}),e.oncomplete=Z(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&dt.storagemutated.fire(e.mutatedParts)}),this}_promise(e,r,n){if(e==="readwrite"&&this.mode!=="readwrite")return le(new L.ReadOnly("Transaction is readonly"));if(!this.active)return le(new L.TransactionInactive);if(this._locked())return new I((s,o)=>{this._blockedFuncs.push([()=>{this._promise(e,r,n).then(s,o)},R])});if(n)return lt(()=>{var s=new I((o,a)=>{this._lock();let l=r(o,a,this);l&&l.then&&l.then(o,a)});return s.finally(()=>this._unlock()),s._lib=!0,s});var i=new I((s,o)=>{var a=r(s,o,this);a&&a.then&&a.then(s,o)});return i._lib=!0,i}_root(){return this.parent?this.parent._root():this}waitFor(e){var r=this._root();let n=I.resolve(e);if(r._waitingFor)r._waitingFor=r._waitingFor.then(()=>n);else{r._waitingFor=n,r._waitingQueue=[];var i=r.idbtrans.objectStore(r.storeNames[0]);(function o(){for(++r._spinCount;r._waitingQueue.length;)r._waitingQueue.shift()();r._waitingFor&&(i.get(-1/0).onsuccess=o)})()}var s=r._waitingFor;return new I((o,a)=>{n.then(l=>r._waitingQueue.push(Z(o.bind(null,l))),l=>r._waitingQueue.push(Z(a.bind(null,l)))).finally(()=>{r._waitingFor===s&&(r._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new L.Abort))}table(e){let r=this._memoizedTables||(this._memoizedTables={});if(Ie(r,e))return r[e];let n=this.schema[e];if(!n)throw new L.NotFound("Table "+e+" not part of transaction");let i=new this.db.Table(e,n,this);return i.core=this.db.core.table(e),r[e]=i,i}};function Of(t){return Wr(Xo.prototype,function(r,n,i,s,o){this.db=t,this.mode=r,this.storeNames=n,this.schema=i,this.chromeTransactionDurability=s,this.idbtrans=null,this.on=Hr(this,"complete","error","abort"),this.parent=o||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new I((a,l)=>{this._resolve=a,this._reject=l}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},a=>{var l=this.active;return this.active=!1,this.on.error.fire(a),this.parent?this.parent._reject(a):l&&this.idbtrans&&this.idbtrans.abort(),le(a)})})}function ns(t,e,r,n,i,s,o){return{name:t,keyPath:e,unique:r,multi:n,auto:i,compound:s,src:(r&&!o?"&":"")+(n?"*":"")+(i?"++":"")+Zo(e)}}function Zo(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function ea(t,e,r){return{name:t,primKey:e,indexes:r,mappedClass:null,idxByName:xo(r,n=>[n.name,n])}}function Mf(t){return t.length===1?t[0]:t}var Qr=t=>{try{return t.only([[]]),Qr=()=>[[]],[[]]}catch{return Qr=()=>Pt,Pt}};function is(t){return t==null?()=>{}:typeof t=="string"?Pf(t):e=>Ue(e,t)}function Pf(t){return t.split(".").length===1?r=>r[t]:r=>Ue(r,t)}function ta(t){return[].slice.call(t)}var Rf=0;function qr(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function Bf(t,e,r){function n(c,d){let f=ta(c.objectStoreNames);return{schema:{name:c.name,tables:f.map(y=>d.objectStore(y)).map(y=>{let{keyPath:w,autoIncrement:b}=y,x=ve(w),h=w==null,v={},p={name:y.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:h,compound:x,keyPath:w,autoIncrement:b,unique:!0,extractKey:is(w)},indexes:ta(y.indexNames).map(m=>y.index(m)).map(m=>{let{name:_,unique:g,multiEntry:j,keyPath:A}=m,C=ve(A),F={name:_,compound:C,keyPath:A,unique:g,multiEntry:j,extractKey:is(A)};return v[qr(A)]=F,F}),getIndexByKeyPath:m=>v[qr(m)]};return v[":id"]=p.primaryKey,w!=null&&(v[qr(w)]=p.primaryKey),p})},hasGetAll:f.length>0&&"getAll"in d.objectStore(f[0])&&!(typeof navigator!="undefined"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}function i(c){if(c.type===3)return null;if(c.type===4)throw new Error("Cannot convert never type to IDBKeyRange");let{lower:d,upper:f,lowerOpen:y,upperOpen:w}=c;return d===void 0?f===void 0?null:e.upperBound(f,!!w):f===void 0?e.lowerBound(d,!!y):e.bound(d,f,!!y,!!w)}function s(c){let d=c.name;function f({trans:b,type:x,keys:h,values:v,range:p}){return new Promise((m,_)=>{m=Z(m);let g=b.objectStore(d),j=g.keyPath==null,A=x==="put"||x==="add";if(!A&&x!=="delete"&&x!=="deleteRange")throw new Error("Invalid operation type: "+x);let{length:C}=h||v||{length:1};if(h&&v&&h.length!==v.length)throw new Error("Given keys array must have same length as given values array.");if(C===0)return m({numFailures:0,failures:{},results:[],lastResult:void 0});let F,D=[],P=[],T=0,N=M=>{++T,Ur(M)};if(x==="deleteRange"){if(p.type===4)return m({numFailures:T,failures:P,results:[],lastResult:void 0});p.type===3?D.push(F=g.clear()):D.push(F=g.delete(i(p)))}else{let[M,S]=A?j?[v,h]:[v,null]:[h,null];if(A)for(let V=0;V{let S=M.target.result;D.forEach((V,te)=>V.error!=null&&(P[te]=V.error)),m({numFailures:T,failures:P,results:x==="delete"?h:D.map(V=>V.result),lastResult:S})};F.onerror=M=>{N(M),$(M)},F.onsuccess=$})}function y({trans:b,values:x,query:h,reverse:v,unique:p}){return new Promise((m,_)=>{m=Z(m);let{index:g,range:j}=h,A=b.objectStore(d),C=g.isPrimaryKey?A:A.index(g.name),F=v?p?"prevunique":"prev":p?"nextunique":"next",D=x||!("openKeyCursor"in C)?C.openCursor(i(j),F):C.openKeyCursor(i(j),F);D.onerror=ze(_),D.onsuccess=Z(P=>{let T=D.result;if(!T){m(null);return}T.___id=++Rf,T.done=!1;let N=T.continue.bind(T),$=T.continuePrimaryKey;$&&($=$.bind(T));let M=T.advance.bind(T),S=()=>{throw new Error("Cursor not started")},V=()=>{throw new Error("Cursor not stopped")};T.trans=b,T.stop=T.continue=T.continuePrimaryKey=T.advance=S,T.fail=Z(_),T.next=function(){let te=1;return this.start(()=>te--?this.continue():this.stop()).then(()=>this)},T.start=te=>{let Wt=new Promise((st,to)=>{st=Z(st),D.onerror=ze(to),T.fail=to,T.stop=Cc=>{T.stop=T.continue=T.continuePrimaryKey=T.advance=V,st(Cc)}}),it=()=>{if(D.result)try{te()}catch(st){T.fail(st)}else T.done=!0,T.start=()=>{throw new Error("Cursor behind last entry")},T.stop()};return D.onsuccess=Z(st=>{D.onsuccess=it,it()}),T.continue=N,T.continuePrimaryKey=$,T.advance=M,it(),Wt},m(T)},_)})}function w(b){return x=>new Promise((h,v)=>{h=Z(h);let{trans:p,values:m,limit:_,query:g}=x,j=_===1/0?void 0:_,{index:A,range:C}=g,F=p.objectStore(d),D=A.isPrimaryKey?F:F.index(A.name),P=i(C);if(_===0)return h({result:[]});if(b){let T=m?D.getAll(P,j):D.getAllKeys(P,j);T.onsuccess=N=>h({result:N.target.result}),T.onerror=ze(v)}else{let T=0,N=m||!("openKeyCursor"in D)?D.openCursor(P):D.openKeyCursor(P),$=[];N.onsuccess=M=>{let S=N.result;if(!S)return h({result:$});if($.push(m?S.value:S.primaryKey),++T===_)return h({result:$});S.continue()},N.onerror=ze(v)}})}return{name:d,schema:c,mutate:f,getMany({trans:b,keys:x}){return new Promise((h,v)=>{h=Z(h);let p=b.objectStore(d),m=x.length,_=new Array(m),g=0,j=0,A,C=D=>{let P=D.target;(_[P._pos]=P.result)!=null,++j===g&&h(_)},F=ze(v);for(let D=0;D{h=Z(h);let m=b.objectStore(d).get(x);m.onsuccess=_=>h(_.target.result),m.onerror=ze(v)})},query:w(a),openCursor:y,count({query:b,trans:x}){let{index:h,range:v}=b;return new Promise((p,m)=>{let _=x.objectStore(d),g=h.isPrimaryKey?_:_.index(h.name),j=i(v),A=j?g.count(j):g.count();A.onsuccess=Z(C=>p(C.target.result)),A.onerror=ze(m)})}}}let{schema:o,hasGetAll:a}=n(t,r),l=o.tables.map(c=>s(c)),u={};return l.forEach(c=>u[c.name]=c),{stack:"dbcore",transaction:t.transaction.bind(t),table(c){if(!u[c])throw new Error(`Table '${c}' not found`);return u[c]},MIN_KEY:-1/0,MAX_KEY:Qr(e),schema:o}}function Lf(t,e){return e.reduce((r,{create:n})=>re(re({},r),n(r)),t)}function Nf(t,e,{IDBKeyRange:r,indexedDB:n},i){return{dbcore:Lf(Bf(e,r,i),t.dbcore)}}function ss({_novip:t},e){let r=e.db,n=Nf(t._middlewares,r,t._deps,e);t.core=n.dbcore,t.tables.forEach(i=>{let s=i.name;t.core.schema.tables.some(o=>o.name===s)&&(i.core=t.core.table(s),t[s]instanceof t.Table&&(t[s].core=i.core))})}function Mn({_novip:t},e,r,n){r.forEach(i=>{let s=n[i];e.forEach(o=>{let a=Ei(o,i);(!a||"value"in a&&a.value===void 0)&&(o===t.Transaction.prototype||o instanceof t.Transaction?We(o,i,{get(){return this.table(i)},set(l){yo(this,i,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):o[i]=new t.Table(i,s))})})}function os({_novip:t},e){e.forEach(r=>{for(let n in r)r[n]instanceof t.Table&&delete r[n]})}function Kf(t,e){return t._cfg.version-e._cfg.version}function zf(t,e,r,n){let i=t._dbSchema,s=t._createTransaction("readwrite",t._storeNames,i);s.create(r),s._completion.catch(n);let o=s._reject.bind(s),a=R.transless||R;lt(()=>{R.trans=s,R.transless=a,e===0?(oe(i).forEach(l=>{as(r,l,i[l].primKey,i[l].indexes)}),ss(t,r),I.follow(()=>t.on.populate.fire(s)).catch(o)):Vf(t,e,s,r).catch(o)})}function Vf({_novip:t},e,r,n){let i=[],s=t._versions,o=t._dbSchema=us(t,t.idbdb,n),a=!1;s.filter(c=>c._cfg.version>=e).forEach(c=>{i.push(()=>{let d=o,f=c._cfg.dbschema;cs(t,d,n),cs(t,f,n),o=t._dbSchema=f;let y=ra(d,f);y.add.forEach(b=>{as(n,b[0],b[1].primKey,b[1].indexes)}),y.change.forEach(b=>{if(b.recreate)throw new L.Upgrade("Not yet support for changing primary key");{let x=n.objectStore(b.name);b.add.forEach(h=>ls(x,h)),b.change.forEach(h=>{x.deleteIndex(h.name),ls(x,h)}),b.del.forEach(h=>x.deleteIndex(h))}});let w=c._cfg.contentUpgrade;if(w&&c._cfg.version>e){ss(t,n),r._memoizedTables={},a=!0;let b=bo(f);y.del.forEach(p=>{b[p]=d[p]}),os(t,[t.Transaction.prototype]),Mn(t,[t.Transaction.prototype],oe(b),b),r.schema=b;let x=Ii(w);x&&ir();let h,v=I.follow(()=>{if(h=w(r),h&&x){var p=Qe.bind(null,null);h.then(p,p)}});return h&&typeof h.then=="function"?I.resolve(h):v.then(()=>h)}}),i.push(d=>{if(!a||!xf){let f=c._cfg.dbschema;Hf(f,d)}os(t,[t.Transaction.prototype]),Mn(t,[t.Transaction.prototype],t._storeNames,t._dbSchema),r.schema=t._dbSchema})});function u(){return i.length?I.resolve(i.shift()(r.idbtrans)).then(u):I.resolve()}return u().then(()=>{$f(o,n)})}function ra(t,e){let r={del:[],add:[],change:[]},n;for(n in t)e[n]||r.del.push(n);for(n in e){let i=t[n],s=e[n];if(!i)r.add.push([n,s]);else{let o={name:n,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||i.primKey.auto!==s.primKey.auto&&!En)o.recreate=!0,r.change.push(o);else{let a=i.idxByName,l=s.idxByName,u;for(u in a)l[u]||o.del.push(u);for(u in l){let c=a[u],d=l[u];c?c.src!==d.src&&o.change.push(d):o.add.push(d)}(o.del.length>0||o.add.length>0||o.change.length>0)&&r.change.push(o)}}}return r}function as(t,e,r,n){let i=t.db.createObjectStore(e,r.keyPath?{keyPath:r.keyPath,autoIncrement:r.auto}:{autoIncrement:r.auto});return n.forEach(s=>ls(i,s)),i}function $f(t,e){oe(t).forEach(r=>{e.db.objectStoreNames.contains(r)||as(e,r,t[r].primKey,t[r].indexes)})}function Hf(t,e){[].slice.call(e.db.objectStoreNames).forEach(r=>t[r]==null&&e.db.deleteObjectStore(r))}function ls(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function us(t,e,r){let n={};return pn(e.objectStoreNames,0).forEach(s=>{let o=r.objectStore(s),a=o.keyPath,l=ns(Zo(a),a||"",!1,!1,!!o.autoIncrement,a&&typeof a!="string",!0),u=[];for(let d=0;di.add.length||i.change.length))}function cs({_novip:t},e,r){let n=r.db.objectStoreNames;for(let i=0;i{e=e.trim();let n=e.replace(/([&*]|\+\+)/g,""),i=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return ns(n,i||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),ve(i),r===0)})}var na=class{_parseStoresSpec(e,r){oe(e).forEach(n=>{if(e[n]!==null){var i=Gf(e[n]),s=i.shift();if(s.multi)throw new L.Schema("Primary key cannot be multi-valued");i.forEach(o=>{if(o.auto)throw new L.Schema("Only primary key can be marked as autoIncrement (++)");if(!o.keyPath)throw new L.Schema("Index must have a name and cannot be an empty string")}),r[n]=ea(n,s,i)}})}stores(e){let r=this.db;this._cfg.storesSource=this._cfg.storesSource?je(this._cfg.storesSource,e):e;let n=r._versions,i={},s={};return n.forEach(o=>{je(i,o._cfg.storesSource),s=o._cfg.dbschema={},o._parseStoresSpec(i,s)}),r._dbSchema=s,os(r,[r._allTables,r,r.Transaction.prototype]),Mn(r,[r._allTables,r,r.Transaction.prototype,this._cfg.tables],oe(s),s),r._storeNames=oe(s),this}upgrade(e){return this._cfg.contentUpgrade=Ri(this._cfg.contentUpgrade||Y,e),this}};function Qf(t){return Wr(na.prototype,function(r){this.db=t,this._cfg={version:r,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}function fs(t,e){let r=t._dbNamesDB;return r||(r=t._dbNamesDB=new Je(Dn,{addons:[],indexedDB:t,IDBKeyRange:e}),r.version(1).stores({dbnames:"name"})),r.table("dbnames")}function ds(t){return t&&typeof t.databases=="function"}function qf({indexedDB:t,IDBKeyRange:e}){return ds(t)?Promise.resolve(t.databases()).then(r=>r.map(n=>n.name).filter(n=>n!==Dn)):fs(t,e).toCollection().primaryKeys()}function Yf({indexedDB:t,IDBKeyRange:e},r){!ds(t)&&r!==Dn&&fs(t,e).put({name:r}).catch(Y)}function Jf({indexedDB:t,IDBKeyRange:e},r){!ds(t)&&r!==Dn&&fs(t,e).delete(r).catch(Y)}function hs(t){return lt(function(){return R.letThrough=!0,t()})}function Xf(){var t=!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent);if(!t||!indexedDB.databases)return Promise.resolve();var e;return new Promise(function(r){var n=function(){return indexedDB.databases().finally(r)};e=setInterval(n,100),n()}).finally(function(){return clearInterval(e)})}function Zf(t){let e=t._state,{indexedDB:r}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?le(e.dbOpenError):t);Ke&&(e.openCanceller._stackHolder=kt()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;let n=e.openCanceller;function i(){if(e.openCanceller!==n)throw new L.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,o=null,a=!1;return I.race([n,(typeof navigator=="undefined"?I.resolve():Xf()).then(()=>new I((l,u)=>{if(i(),!r)throw new L.MissingAPI;let c=t.name,d=e.autoSchema?r.open(c):r.open(c,Math.round(t.verno*10));if(!d)throw new L.MissingAPI;d.onerror=ze(u),d.onblocked=Z(t._fireOnBlocked),d.onupgradeneeded=Z(f=>{if(o=d.transaction,e.autoSchema&&!t._options.allowEmptyDB){d.onerror=Ur,o.abort(),d.result.close();let w=r.deleteDatabase(c);w.onsuccess=w.onerror=Z(()=>{u(new L.NoSuchDatabase(`Database ${c} doesnt exist`))})}else{o.onerror=ze(u);var y=f.oldVersion>Math.pow(2,62)?0:f.oldVersion;a=y<1,t._novip.idbdb=d.result,zf(t,y/10,o,u)}},u),d.onsuccess=Z(()=>{o=null;let f=t._novip.idbdb=d.result,y=pn(f.objectStoreNames);if(y.length>0)try{let w=f.transaction(Mf(y),"readonly");e.autoSchema?Wf(t,f,w):(cs(t,t._dbSchema,w),Uf(t,w)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),ss(t,w)}catch{}$r.push(t),f.onversionchange=Z(w=>{e.vcFired=!0,t.on("versionchange").fire(w)}),f.onclose=Z(w=>{t.on("close").fire(w)}),a&&Yf(t._deps,c),l()},u)}))]).then(()=>(i(),e.onReadyBeingFired=[],I.resolve(hs(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let u=e.onReadyBeingFired.reduce(Ri,Y);return e.onReadyBeingFired=[],I.resolve(hs(()=>u(t.vip))).then(l)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(l=>{e.dbOpenError=l;try{o&&o.abort()}catch{}return n===e.openCanceller&&t._close(),le(l)}).finally(()=>{e.openComplete=!0,s()})}function ps(t){var e=o=>t.next(o),r=o=>t.throw(o),n=s(e),i=s(r);function s(o){return a=>{var l=o(a),u=l.value;return l.done?u:!u||typeof u.then!="function"?ve(u)?Promise.all(u).then(n,i):n(u):u.then(n,i)}}return s(e)()}function ed(t,e,r){var n=arguments.length;if(n<2)throw new L.InvalidArgument("Too few arguments");for(var i=new Array(n-1);--n;)i[n-1]=arguments[n];r=i.pop();var s=wo(i);return[t,s,r]}function ia(t,e,r,n,i){return I.resolve().then(()=>{let s=R.transless||R,o=t._createTransaction(e,r,t._dbSchema,n),a={trans:o,transless:s};if(n)o.idbtrans=n.idbtrans;else try{o.create(),t._state.PR1398_maxLoop=3}catch(d){return d.name===Pi.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>ia(t,e,r,null,i))):le(d)}let l=Ii(i);l&&ir();let u,c=I.follow(()=>{if(u=i.call(o,o),u)if(l){var d=Qe.bind(null,null);u.then(d,d)}else typeof u.next=="function"&&typeof u.throw=="function"&&(u=ps(u))},a);return(u&&typeof u.then=="function"?I.resolve(u).then(d=>o.active?d:le(new L.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):c.then(()=>u)).then(d=>(n&&o._resolve(),o._completion.then(()=>d))).catch(d=>(o._reject(d),le(d)))})}function Pn(t,e,r){let n=ve(t)?t.slice():[t];for(let i=0;i0,p=xe(re({},w),{isVirtual:v,keyTail:y,keyLength:h,extractKey:is(f),unique:!v&&w.unique});if(x.push(p),p.isPrimaryKey||s.push(p),h>1){let m=h===2?f[0]:f.slice(0,h-1);o(m,y+1,w)}return x.sort((m,_)=>m.keyTail-_.keyTail),p}let a=o(n.primaryKey.keyPath,0,n.primaryKey);i[":id"]=[a];for(let f of n.indexes)o(f.keyPath,0,f);function l(f){let y=i[qr(f)];return y&&y[0]}function u(f,y){return{type:f.type===1?2:f.type,lower:Pn(f.lower,f.lowerOpen?t.MAX_KEY:t.MIN_KEY,y),lowerOpen:!0,upper:Pn(f.upper,f.upperOpen?t.MIN_KEY:t.MAX_KEY,y),upperOpen:!0}}function c(f){let y=f.query.index;return y.isVirtual?xe(re({},f),{query:{index:y,range:u(f.query.range,y.keyTail)}}):f}return xe(re({},r),{schema:xe(re({},n),{primaryKey:a,indexes:s,getIndexByKeyPath:l}),count(f){return r.count(c(f))},query(f){return r.query(c(f))},openCursor(f){let{keyTail:y,isVirtual:w,keyLength:b}=f.query.index;if(!w)return r.openCursor(f);function x(h){function v(m){m!=null?h.continue(Pn(m,f.reverse?t.MAX_KEY:t.MIN_KEY,y)):f.unique?h.continue(h.key.slice(0,b).concat(f.reverse?t.MIN_KEY:t.MAX_KEY,y)):h.continue()}return Object.create(h,{continue:{value:v},continuePrimaryKey:{value(m,_){h.continuePrimaryKey(Pn(m,t.MAX_KEY,y),_)}},primaryKey:{get(){return h.primaryKey}},key:{get(){let m=h.key;return b===1?m[0]:m.slice(0,b)}},value:{get(){return h.value}}})}return r.openCursor(c(f)).then(h=>h&&x(h))}})}})}var rd={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:td};function ms(t,e,r,n){return r=r||{},n=n||"",oe(t).forEach(i=>{if(!Ie(e,i))r[n+i]=void 0;else{var s=t[i],o=e[i];if(typeof s=="object"&&typeof o=="object"&&s&&o){let a=Ti(s),l=Ti(o);a!==l?r[n+i]=e[i]:a==="Object"?ms(s,o,r,n+i+"."):s!==o&&(r[n+i]=e[i])}else s!==o&&(r[n+i]=e[i])}}),oe(e).forEach(i=>{Ie(t,i)||(r[n+i]=e[i])}),r}function nd(t,e){return e.type==="delete"?e.keys:e.keys||e.values.map(t.extractKey)}var id={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>xe(re({},t),{table(e){let r=t.table(e),{primaryKey:n}=r.schema;return xe(re({},r),{mutate(s){let o=R.trans,{deleting:a,creating:l,updating:u}=o.table(e).hook;switch(s.type){case"add":if(l.fire===Y)break;return o._promise("readwrite",()=>c(s),!0);case"put":if(l.fire===Y&&u.fire===Y)break;return o._promise("readwrite",()=>c(s),!0);case"delete":if(a.fire===Y)break;return o._promise("readwrite",()=>c(s),!0);case"deleteRange":if(a.fire===Y)break;return o._promise("readwrite",()=>d(s),!0)}return r.mutate(s);function c(y){let w=R.trans,b=y.keys||nd(n,y);if(!b)throw new Error("Keys missing");return y=y.type==="add"||y.type==="put"?xe(re({},y),{keys:b}):re({},y),y.type!=="delete"&&(y.values=[...y.values]),y.keys&&(y.keys=[...y.keys]),sd(r,y,b).then(x=>{let h=b.map((v,p)=>{let m=x[p],_={onerror:null,onsuccess:null};if(y.type==="delete")a.fire.call(_,v,m,w);else if(y.type==="add"||m===void 0){let g=l.fire.call(_,v,y.values[p],w);v==null&&g!=null&&(v=g,y.keys[p]=v,n.outbound||Be(y.values[p],n.keyPath,v))}else{let g=ms(m,y.values[p]),j=u.fire.call(_,g,v,m,w);if(j){let A=y.values[p];Object.keys(j).forEach(C=>{Ie(A,C)?A[C]=j[C]:Be(A,C,j[C])})}}return _});return r.mutate(y).then(({failures:v,results:p,numFailures:m,lastResult:_})=>{for(let g=0;g(h.forEach(p=>p.onerror&&p.onerror(v)),Promise.reject(v)))})}function d(y){return f(y.trans,y.range,1e4)}function f(y,w,b){return r.query({trans:y,values:!1,query:{index:n,range:w},limit:b}).then(({result:x})=>c({type:"delete",keys:x,trans:y}).then(h=>h.numFailures>0?Promise.reject(h.failures[0]):x.length({table:e=>{let r=t.table(e);return xe(re({},r),{getMany:n=>{if(!n.cache)return r.getMany(n);let i=sa(n.keys,n.trans._cache,n.cache==="clone");return i?I.resolve(i):r.getMany(n).then(s=>(n.trans._cache={keys:n.keys,values:n.cache==="clone"?Pr(s):s},s))},mutate:n=>(n.type!=="add"&&(n.trans._cache=null),r.mutate(n))})}})};function gs(t){return!("from"in t)}var Ye=function(t,e){if(this)je(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0});else{let r=new Ye;return t&&"d"in t&&je(r,t),r}};Zt(Ye.prototype,{add(t){return Rn(this,t),this},addKey(t){return Yr(this,t,t),this},addKeys(t){return t.forEach(e=>Yr(this,e,e)),this},[ki](){return ys(this)}});function Yr(t,e,r){let n=Ae(e,r);if(isNaN(n))return;if(n>0)throw RangeError();if(gs(t))return je(t,{from:e,to:r,d:1});let i=t.l,s=t.r;if(Ae(r,t.from)<0)return i?Yr(i,e,r):t.l={from:e,to:r,d:1,l:null,r:null},oa(t);if(Ae(e,t.to)>0)return s?Yr(s,e,r):t.r={from:e,to:r,d:1,l:null,r:null},oa(t);Ae(e,t.from)<0&&(t.from=e,t.l=null,t.d=s?s.d+1:1),Ae(r,t.to)>0&&(t.to=r,t.r=null,t.d=t.l?t.l.d+1:1);let o=!t.r;i&&!t.l&&Rn(t,i),s&&o&&Rn(t,s)}function Rn(t,e){function r(n,{from:i,to:s,l:o,r:a}){Yr(n,i,s),o&&r(n,o),a&&r(n,a)}gs(e)||r(t,e)}function ad(t,e){let r=ys(e),n=r.next();if(n.done)return!1;let i=n.value,s=ys(t),o=s.next(i.from),a=o.value;for(;!n.done&&!o.done;){if(Ae(a.from,i.to)<=0&&Ae(a.to,i.from)>=0)return!0;Ae(i.from,a.from)<0?i=(n=r.next(a.from)).value:a=(o=s.next(i.from)).value}return!1}function ys(t){let e=gs(t)?null:{s:0,n:t};return{next(r){let n=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,n)for(;e.n.l&&Ae(r,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!n||Ae(r,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function oa(t){var e,r;let n=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((r=t.l)===null||r===void 0?void 0:r.d)||0),i=n>1?"r":n<-1?"l":"";if(i){let s=i==="r"?"l":"r",o=re({},t),a=t[i];t.from=a.from,t.to=a.to,t[i]=a[i],o[i]=a[s],t[s]=o,o.d=aa(o)}t.d=aa(t)}function aa({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}var ld={stack:"dbcore",level:0,create:t=>{let e=t.schema.name,r=new Ye(t.MIN_KEY,t.MAX_KEY);return xe(re({},t),{table:n=>{let i=t.table(n),{schema:s}=i,{primaryKey:o}=s,{extractKey:a,outbound:l}=o,u=xe(re({},i),{mutate:f=>{let y=f.trans,w=y.mutatedParts||(y.mutatedParts={}),b=g=>{let j=`idb://${e}/${n}/${g}`;return w[j]||(w[j]=new Ye)},x=b(""),h=b(":dels"),{type:v}=f,[p,m]=f.type==="deleteRange"?[f.range]:f.type==="delete"?[f.keys]:f.values.length<50?[[],f.values]:[],_=f.trans._cache;return i.mutate(f).then(g=>{if(ve(p)){v!=="delete"&&(p=g.results),x.addKeys(p);let j=sa(p,_);!j&&v!=="add"&&h.addKeys(p),(j||m)&&ud(b,s,j,m)}else if(p){let j={from:p.lower,to:p.upper};h.add(j),x.add(j)}else x.add(r),h.add(r),s.indexes.forEach(j=>b(j.name).add(r));return g})}}),c=({query:{index:f,range:y}})=>{var w,b;return[f,new Ye((w=y.lower)!==null&&w!==void 0?w:t.MIN_KEY,(b=y.upper)!==null&&b!==void 0?b:t.MAX_KEY)]},d={get:f=>[o,new Ye(f.key)],getMany:f=>[o,new Ye().addKeys(f.keys)],count:c,query:c,openCursor:c};return oe(d).forEach(f=>{u[f]=function(y){let{subscr:w}=R;if(w){let b=m=>{let _=`idb://${e}/${n}/${m}`;return w[_]||(w[_]=new Ye)},x=b(""),h=b(":dels"),[v,p]=d[f](y);if(b(v.name||"").add(p),!v.isPrimaryKey)if(f==="count")h.add(r);else{let m=f==="query"&&l&&y.values&&i.query(xe(re({},y),{values:!1}));return i[f].apply(this,arguments).then(_=>{if(f==="query"){if(l&&y.values)return m.then(({result:j})=>(x.addKeys(j),_));let g=y.values?_.result.map(a):_.result;y.values?x.addKeys(g):h.addKeys(g)}else if(f==="openCursor"){let g=_,j=y.values;return g&&Object.create(g,{key:{get(){return h.addKey(g.primaryKey),g.key}},primaryKey:{get(){let A=g.primaryKey;return h.addKey(A),A}},value:{get(){return j&&x.addKey(g.primaryKey),g.value}}})}return _})}}return i[f].apply(this,arguments)}}),u}})}};function ud(t,e,r,n){function i(s){let o=t(s.name||"");function a(u){return u!=null?s.extractKey(u):null}let l=u=>s.multiEntry&&ve(u)?u.forEach(c=>o.addKey(c)):o.addKey(u);(r||n).forEach((u,c)=>{let d=r&&a(r[c]),f=n&&a(n[c]);Ae(d,f)!==0&&(d!=null&&l(d),f!=null&&l(f))})}e.indexes.forEach(i)}var Je=class{constructor(e,r){this._middlewares={},this.verno=0;let n=Je.dependencies;this._options=r=re({addons:Je.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange},r),this._deps={indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange};let{addons:i}=r;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;let s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:Y,dbReadyPromise:null,cancelOpen:Y,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};s.dbReadyPromise=new I(o=>{s.dbReadyResolve=o}),s.openCanceller=new I((o,a)=>{s.cancelOpen=a}),this._state=s,this.name=e,this.on=Hr(this,"populate","blocked","versionchange","close",{ready:[Ri,Y]}),this.on.ready.subscribe=vo(this.on.ready.subscribe,o=>(a,l)=>{Je.vip(()=>{let u=this._state;if(u.openComplete)u.dbOpenError||I.resolve().then(a),l&&o(a);else if(u.onReadyBeingFired)u.onReadyBeingFired.push(a),l&&o(a);else{o(a);let c=this;l||o(function d(){c.on.ready.unsubscribe(a),c.on.ready.unsubscribe(d)})}})}),this.Collection=Ff(this),this.Table=wf(this),this.Transaction=Of(this),this.Version=Qf(this),this.WhereClause=If(this),this.on("versionchange",o=>{o.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",o=>{!o.newVersion||o.newVersionnew this.Transaction(o,a,l,this._options.chromeTransactionDurability,u),this._fireOnBlocked=o=>{this.on("blocked").fire(o),$r.filter(a=>a.name===this.name&&a!==this&&!a._state.vcFired).map(a=>a.on("versionchange").fire(o))},this.use(rd),this.use(id),this.use(ld),this.use(od),this.vip=Object.create(this,{_vip:{value:!0}}),i.forEach(o=>o(this))}version(e){if(isNaN(e)||e<.1)throw new L.Type("Given version is not a positive number");if(e=Math.round(e*10)/10,this.idbdb||this._state.isBeingOpened)throw new L.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let r=this._versions;var n=r.filter(i=>i._cfg.version===e)[0];return n||(n=new this.Version(e),r.push(n),r.sort(Kf),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(e){return this.idbdb&&(this._state.openComplete||R.letThrough||this._vip)?e():new I((r,n)=>{if(this._state.openComplete)return n(new L.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen){n(new L.DatabaseClosed);return}this.open().catch(Y)}this._state.dbReadyPromise.then(r,n)}).then(e)}use({stack:e,create:r,level:n,name:i}){i&&this.unuse({stack:e,name:i});let s=this._middlewares[e]||(this._middlewares[e]=[]);return s.push({stack:e,create:r,level:n??10,name:i}),s.sort((o,a)=>o.level-a.level),this}unuse({stack:e,name:r,create:n}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(i=>n?i.create!==n:r?i.name!==r:!1)),this}open(){return Zf(this)}_close(){let e=this._state,r=$r.indexOf(this);if(r>=0&&$r.splice(r,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new I(n=>{e.dbReadyResolve=n}),e.openCanceller=new I((n,i)=>{e.cancelOpen=i})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new L.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,r=this._state;return new I((n,i)=>{let s=()=>{this.close();var o=this._deps.indexedDB.deleteDatabase(this.name);o.onsuccess=Z(()=>{Jf(this._deps,this.name),n()}),o.onerror=ze(i),o.onblocked=this._fireOnBlocked};if(e)throw new L.InvalidArgument("Arguments not allowed in db.delete()");r.isBeingOpened?r.dbReadyPromise.then(s):s()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){let e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return oe(this._allTables).map(e=>this._allTables[e])}transaction(){let e=ed.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,r,n){let i=R.trans;(!i||i.db!==this||e.indexOf("!")!==-1)&&(i=null);let s=e.indexOf("?")!==-1;e=e.replace("!","").replace("?","");let o,a;try{if(a=r.map(u=>{var c=u instanceof this.Table?u.name:u;if(typeof c!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return c}),e=="r"||e===Ji)o=Ji;else if(e=="rw"||e==Xi)o=Xi;else throw new L.InvalidArgument("Invalid transaction mode: "+e);if(i){if(i.mode===Ji&&o===Xi)if(s)i=null;else throw new L.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i&&a.forEach(u=>{if(i&&i.storeNames.indexOf(u)===-1)if(s)i=null;else throw new L.SubTransaction("Table "+u+" not included in parent transaction.")}),s&&i&&!i.active&&(i=null)}}catch(u){return i?i._promise(null,(c,d)=>{d(u)}):le(u)}let l=ia.bind(null,this,o,a,i,n);return i?i._promise(o,l,"lock"):R.trans?sr(R.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!Ie(this._allTables,e))throw new L.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}},cd=typeof Symbol!="undefined"&&"observable"in Symbol?Symbol.observable:"@@observable",la=class{constructor(e){this._subscribe=e}subscribe(e,r,n){return this._subscribe(!e||typeof e=="function"?{next:e,error:r,complete:n}:e)}[cd](){return this}};function ua(t,e){return oe(e).forEach(r=>{let n=t[r]||(t[r]=new Ye);Rn(n,e[r])}),t}function fd(t){return new la(e=>{let r=Ii(t);function n(y){r&&ir();let w=()=>lt(t,{subscr:y,trans:null}),b=R.trans?sr(R.transless,w):w();return r&&b.then(Qe,Qe),b}let i=!1,s={},o={},a={get closed(){return i},unsubscribe:()=>{i=!0,dt.storagemutated.unsubscribe(d)}};e.start&&e.start(a);let l=!1,u=!1;function c(){return oe(o).some(y=>s[y]&&ad(s[y],o[y]))}let d=y=>{ua(s,y),c()&&f()},f=()=>{if(l||i)return;s={};let y={},w=n(y);u||(dt(Gr,d),u=!0),l=!0,Promise.resolve(w).then(b=>{l=!1,!i&&(c()?f():(s={},o=y,e.next&&e.next(b)))},b=>{l=!1,e.error&&e.error(b),a.unsubscribe()})};return f(),a})}var vs;try{vs={indexedDB:J.indexedDB||J.mozIndexedDB||J.webkitIndexedDB||J.msIndexedDB,IDBKeyRange:J.IDBKeyRange||J.webkitIDBKeyRange}}catch{vs={indexedDB:null,IDBKeyRange:null}}var Bt=Je;Zt(Bt,xe(re({},gn),{delete(t){return new Bt(t,{addons:[]}).delete()},exists(t){return new Bt(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1)},getDatabaseNames(t){try{return qf(Bt.dependencies).then(t)}catch{return le(new L.MissingAPI)}},defineClass(){function t(e){je(this,e)}return t},ignoreTransaction(t){return R.trans?sr(R.transless,t):t()},vip:hs,async:function(t){return function(){try{var e=ps(t.apply(this,arguments));return!e||typeof e.then!="function"?I.resolve(e):e}catch(r){return le(r)}}},spawn:function(t,e,r){try{var n=ps(t.apply(r,e||[]));return!n||typeof n.then!="function"?I.resolve(n):n}catch(i){return le(i)}},currentTransaction:{get:()=>R.trans||null},waitFor:function(t,e){let r=I.resolve(typeof t=="function"?Bt.ignoreTransaction(t):t).timeout(e||6e4);return R.trans?R.trans.waitFor(r):r},Promise:I,debug:{get:()=>Ke,set:t=>{Ao(t,t==="dexie"?()=>!0:$o)}},derive:er,extend:je,props:Zt,override:vo,Events:Hr,on:dt,liveQuery:fd,extendObservabilitySet:ua,getByKeyPath:Ue,setByKeyPath:Be,delByKeyPath:Gc,shallowClone:bo,deepClone:Pr,getObjectDiff:ms,cmp:Ae,asap:_o,minKey:Yi,addons:[],connections:$r,errnames:Pi,dependencies:vs,semVer:zo,version:zo.split(".").map(t=>parseInt(t)).reduce((t,e,r)=>t+e/Math.pow(10,r*2))}));Bt.maxKey=Qr(Bt.dependencies.IDBKeyRange);typeof dispatchEvent!="undefined"&&typeof addEventListener!="undefined"&&(dt(Gr,t=>{if(!Xe){let e;En?(e=document.createEvent("CustomEvent"),e.initCustomEvent(ft,!0,!0,t)):e=new CustomEvent(ft,{detail:t}),Xe=!0,dispatchEvent(e),Xe=!1}}),addEventListener(ft,({detail:t})=>{Xe||Bn(t)}));function Bn(t){let e=Xe;try{Xe=!0,dt.storagemutated.fire(t)}finally{Xe=e}}var Xe=!1;if(typeof BroadcastChannel!="undefined"){let t=new BroadcastChannel(ft);dt(Gr,e=>{Xe||t.postMessage(e)}),t.onmessage=e=>{e.data&&Bn(e.data)}}else if(typeof self!="undefined"&&typeof navigator!="undefined"){dt(Gr,e=>{try{Xe||(typeof localStorage!="undefined"&&localStorage.setItem(ft,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(r=>r.postMessage({type:ft,changedParts:e})))}catch{}}),typeof addEventListener!="undefined"&&addEventListener("storage",e=>{if(e.key===ft){let r=JSON.parse(e.newValue);r&&Bn(r.changedParts)}});let t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",dd)}function dd({data:t}){t&&t.type===ft&&Bn(t.changedParts)}I.rejectionMapper=rf;Ao(Ke,$o);var Ve=class extends Je{constructor(){super(Ve.dbName);this.version(Ve.dbVersion).stores({searchHistory:"++id",minisearch:"date"})}static async clearOldDatabases(){let e=(await indexedDB.databases()).filter(r=>r.name===Ve.dbName&&r.version!==Ve.dbVersion*10);if(e.length){console.log("Omnisearch - Those IndexedDb databases will be deleted:");for(let r of e)r.name&&indexedDB.deleteDatabase(r.name)}}static getInstance(){return Ve.instance||(Ve.instance=new Ve),Ve.instance}async clearCache(){await this.minisearch.clear()}},lr=Ve;lr.dbVersion=8,lr.dbName="omnisearch/cache/"+app.appId;var Ee=lr.getInstance();var Lt=hn(!1),_s=class extends G.PluginSettingTab{constructor(e){super(app,e);this.plugin=e,Lt.subscribe(async r=>{E.showExcerpt=r,await ue(this.plugin)})}display(){let{containerEl:e}=this;e.empty(),e.createEl("h2",{text:"Omnisearch"});let r=e.createDiv();r.innerHTML=` +`).slice(e).filter(Bs).map(n=>` +`+n).join("")):""}var pf=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"],Ns=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Wi=pf.concat(Ns),mf={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function cr(t,e){this._e=Nt(),this.name=t,this.message=e}lr(cr).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+$i(this._e,2))}},toString:function(){return this.name+": "+this.message}});function Ks(t,e){return t+". Errors: "+Object.keys(e).map(r=>e[r].toString()).filter((r,n,i)=>i.indexOf(r)===n).join(` +`)}function Sn(t,e,r,n){this._e=Nt(),this.failures=e,this.failedKeys=n,this.successCount=r,this.message=Ks(t,e)}lr(Sn).from(cr);function $r(t,e){this._e=Nt(),this.name="BulkError",this.failures=Object.keys(e).map(r=>e[r]),this.failuresByPos=e,this.message=Ks(t,e)}lr($r).from(cr);var Ui=Wi.reduce((t,e)=>(t[e]=e+"Error",t),{}),gf=cr,V=Wi.reduce((t,e)=>{var r=e+"Error";function n(i,o){this._e=Nt(),this.name=r,i?typeof i=="string"?(this.message=`${i}${o?` + `+o:""}`,this.inner=o||null):typeof i=="object"&&(this.message=`${i.name} ${i.message}`,this.inner=i):(this.message=mf[e]||r,this.inner=null)}return lr(n).from(gf),t[e]=n,t},{});V.Syntax=SyntaxError;V.Type=TypeError;V.Range=RangeError;var zs=Ns.reduce((t,e)=>(t[e+"Error"]=V[e],t),{});function yf(t,e){if(!t||t instanceof cr||t instanceof TypeError||t instanceof SyntaxError||!t.name||!zs[t.name])return t;var r=new zs[t.name](e||t.message,t);return"stack"in t&&rt(r,"stack",{get:function(){return this.inner.stack}}),r}var Fn=Wi.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=V[e]),t),{});Fn.ModifyError=Sn;Fn.DexieError=cr;Fn.BulkError=$r;function ne(){}function Wr(t){return t}function vf(t,e){return t==null||t===Wr?e:function(r){return e(t(r))}}function Kt(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function _f(t,e){return t===ne?e:function(){var r=t.apply(this,arguments);r!==void 0&&(arguments[0]=r);var n=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=e.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?Kt(n,this.onsuccess):n),i&&(this.onerror=this.onerror?Kt(i,this.onerror):i),o!==void 0?o:r}}function bf(t,e){return t===ne?e:function(){t.apply(this,arguments);var r=this.onsuccess,n=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),r&&(this.onsuccess=this.onsuccess?Kt(r,this.onsuccess):r),n&&(this.onerror=this.onerror?Kt(n,this.onerror):n)}}function xf(t,e){return t===ne?e:function(r){var n=t.apply(this,arguments);Pe(r,n);var i=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var s=e.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?Kt(i,this.onsuccess):i),o&&(this.onerror=this.onerror?Kt(o,this.onerror):o),n===void 0?s===void 0?void 0:s:Pe(n,s)}}function wf(t,e){return t===ne?e:function(){return e.apply(this,arguments)===!1?!1:t.apply(this,arguments)}}function Gi(t,e){return t===ne?e:function(){var r=t.apply(this,arguments);if(r&&typeof r.then=="function"){for(var n=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return r.then(function(){return e.apply(n,o)})}return e.apply(this,arguments)}}var Ur={},jf=100,Cf=20,Vs=100,[Qi,En,qi]=typeof Promise=="undefined"?[]:(()=>{let t=Promise.resolve();if(typeof crypto=="undefined"||!crypto.subtle)return[t,zr(t),t];let e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,zr(e),t]})(),Hs=En&&En.then,Dn=Qi&&Qi.constructor,Yi=!!qi,Ji=!1,Af=qi?()=>{qi.then(kn)}:ie.setImmediate?setImmediate.bind(null,kn):ie.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{kn(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(kn,0)},Gr=function(t,e){Qr.push([t,e]),Tn&&(Af(),Tn=!1)},Xi=!0,Tn=!0,zt=[],In=[],Zi=null,eo=Wr,fr={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:Zs,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{Zs(t[0],t[1])}catch{}})}},K=fr,Qr=[],Vt=0,On=[];function M(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=ne,this._lib=!1;var e=this._PSD=K;if(Je&&(this._stackHolder=Nt(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Ur)throw new TypeError("Not a function");this._state=arguments[1],this._value=arguments[2],this._state===!1&&ro(this,this._value);return}this._state=null,this._value=null,++e.ref,Ws(this,t)}var to={get:function(){var t=K,e=Rn;function r(n,i){var o=!t.global&&(t!==K||e!==Rn);let s=o&&!ot();var a=new M((l,u)=>{no(this,new $s(Bn(n,t,o,s),Bn(i,t,o,s),l,u,t))});return Je&&Qs(a,this),a}return r.prototype=Ur,r},set:function(t){rt(this,"then",t&&t.prototype===Ur?to:{get:function(){return t},set:to.set})}};ar(M.prototype,{then:to,_then:function(t,e){no(this,new $s(null,null,t,e,K))},catch:function(t){if(arguments.length===1)return this.then(null,t);var e=arguments[0],r=arguments[1];return typeof e=="function"?this.then(null,n=>n instanceof e?r(n):Pn(n)):this.then(null,n=>n&&n.name===e?r(n):Pn(n))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),Pn(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Ji=!0;var t=Gs(this,[],Cf),e=t.join(` +From previous: `);return this._state!==null&&(this._stack=e),e}finally{Ji=!1}}},timeout:function(t,e){return t<1/0?new M((r,n)=>{var i=setTimeout(()=>n(new V.Timeout(e)),t);this.then(r,n).finally(clearTimeout.bind(null,i))}):this}});typeof Symbol!="undefined"&&Symbol.toStringTag&&rt(M.prototype,Symbol.toStringTag,"Dexie.Promise");fr.env=qs();function $s(t,e,r,n,i){this.onFulfilled=typeof t=="function"?t:null,this.onRejected=typeof e=="function"?e:null,this.resolve=r,this.reject=n,this.psd=i}ar(M,{all:function(){var t=it.apply(null,arguments).map(Ln);return new M(function(e,r){t.length===0&&e([]);var n=t.length;t.forEach((i,o)=>M.resolve(i).then(s=>{t[o]=s,--n||e(t)},r))})},resolve:t=>{if(t instanceof M)return t;if(t&&typeof t.then=="function")return new M((r,n)=>{t.then(r,n)});var e=new M(Ur,!0,t);return Qs(e,Zi),e},reject:Pn,race:function(){var t=it.apply(null,arguments).map(Ln);return new M((e,r)=>{t.map(n=>M.resolve(n).then(e,r))})},PSD:{get:()=>K,set:t=>K=t},totalEchoes:{get:()=>Rn},newPSD:yt,usePSD:hr,scheduler:{get:()=>Gr,set:t=>{Gr=t}},rejectionMapper:{get:()=>eo,set:t=>{eo=t}},follow:(t,e)=>new M((r,n)=>yt((i,o)=>{var s=K;s.unhandleds=[],s.onunhandled=o,s.finalize=Kt(function(){Ff(()=>{this.unhandleds.length===0?i():o(this.unhandleds[0])})},s.finalize),t()},e,r,n))});Dn&&(Dn.allSettled&&rt(M,"allSettled",function(){let t=it.apply(null,arguments).map(Ln);return new M(e=>{t.length===0&&e([]);let r=t.length,n=new Array(r);t.forEach((i,o)=>M.resolve(i).then(s=>n[o]={status:"fulfilled",value:s},s=>n[o]={status:"rejected",reason:s}).then(()=>--r||e(n)))})}),Dn.any&&typeof AggregateError!="undefined"&&rt(M,"any",function(){let t=it.apply(null,arguments).map(Ln);return new M((e,r)=>{t.length===0&&r(new AggregateError([]));let n=t.length,i=new Array(n);t.forEach((o,s)=>M.resolve(o).then(a=>e(a),a=>{i[s]=a,--n||r(new AggregateError(i))}))})}));function Ws(t,e){try{e(r=>{if(t._state===null){if(r===t)throw new TypeError("A promise cannot be resolved with itself.");var n=t._lib&&qr();r&&typeof r.then=="function"?Ws(t,(i,o)=>{r instanceof M?r._then(i,o):r.then(i,o)}):(t._state=!0,t._value=r,Us(t)),n&&Yr()}},ro.bind(null,t))}catch(r){ro(t,r)}}function ro(t,e){if(In.push(e),t._state===null){var r=t._lib&&qr();e=eo(e),t._state=!1,t._value=e,Je&&e!==null&&typeof e=="object"&&!e._promise&&af(()=>{var n=Ni(e,"stack");e._promise=t,rt(e,"stack",{get:()=>Ji?n&&(n.get?n.get.apply(e):n.value):t.stack})}),Ef(t),Us(t),r&&Yr()}}function Us(t){var e=t._listeners;t._listeners=[];for(var r=0,n=e.length;r{--Vt==0&&io()},[]))}function no(t,e){if(t._state===null){t._listeners.push(e);return}var r=t._state?e.onFulfilled:e.onRejected;if(r===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++Vt,Gr(Sf,[r,t,e])}function Sf(t,e,r){try{Zi=e;var n,i=e._value;e._state?n=t(i):(In.length&&(In=[]),n=t(i),In.indexOf(i)===-1&&Df(e)),r.resolve(n)}catch(o){r.reject(o)}finally{Zi=null,--Vt==0&&io(),--r.psd.ref||r.psd.finalize()}}function Gs(t,e,r){if(e.length===r)return e;var n="";if(t._state===!1){var i=t._value,o,s;i!=null?(o=i.name||"Error",s=i.message||i,n=$i(i,0)):(o=i,s=""),e.push(o+(s?": "+s:"")+n)}return Je&&(n=$i(t._stackHolder,2),n&&e.indexOf(n)===-1&&e.push(n),t._prev&&Gs(t._prev,e,r)),e}function Qs(t,e){var r=e?e._numPrev+1:0;r0;)for(t=Qr,Qr=[],r=t.length,e=0;e0);Xi=!0,Tn=!0}function io(){var t=zt;zt=[],t.forEach(n=>{n._PSD.onunhandled.call(null,n._value,n)});for(var e=On.slice(0),r=e.length;r;)e[--r]()}function Ff(t){function e(){t(),On.splice(On.indexOf(e),1)}On.push(e),++Vt,Gr(()=>{--Vt==0&&io()},[])}function Ef(t){zt.some(e=>e._value===t._value)||zt.push(t)}function Df(t){for(var e=zt.length;e;)if(zt[--e]._value===t._value){zt.splice(e,1);return}}function Pn(t){return new M(Ur,!1,t)}function se(t,e){var r=K;return function(){var n=qr(),i=K;try{return vt(r,!0),t.apply(this,arguments)}catch(o){e&&e(o)}finally{vt(i,!1),n&&Yr()}}}var Ie={awaits:0,echoes:0,id:0},Tf=0,Mn=[],oo=0,Rn=0,If=0;function yt(t,e,r,n){var i=K,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++If;var s=fr.env;o.env=Yi?{Promise:M,PromiseProp:{value:M,configurable:!0,writable:!0},all:M.all,race:M.race,allSettled:M.allSettled,any:M.any,resolve:M.resolve,reject:M.reject,nthen:Js(s.nthen,o),gthen:Js(s.gthen,o)}:{},e&&Pe(o,e),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=hr(o,t,r,n);return o.ref===0&&o.finalize(),a}function dr(){return Ie.id||(Ie.id=++Tf),++Ie.awaits,Ie.echoes+=Vs,Ie.id}function ot(){return Ie.awaits?(--Ie.awaits==0&&(Ie.id=0),Ie.echoes=Ie.awaits*Vs,!0):!1}(""+Hs).indexOf("[native code]")===-1&&(dr=ot=ne);function Ln(t){return Ie.echoes&&t&&t.constructor===Dn?(dr(),t.then(e=>(ot(),e),e=>(ot(),ye(e)))):t}function Of(t){++Rn,(!Ie.echoes||--Ie.echoes==0)&&(Ie.echoes=Ie.id=0),Mn.push(K),vt(t,!0)}function kf(){var t=Mn[Mn.length-1];Mn.pop(),vt(t,!1)}function vt(t,e){var r=K;if((e?Ie.echoes&&(!oo++||t!==K):oo&&(!--oo||t!==K))&&Ys(e?Of.bind(null,t):kf),t!==K&&(K=t,r===fr&&(fr.env=qs()),Yi)){var n=fr.env.Promise,i=t.env;En.then=i.nthen,n.prototype.then=i.gthen,(r.global||t.global)&&(Object.defineProperty(ie,"Promise",i.PromiseProp),n.all=i.all,n.race=i.race,n.resolve=i.resolve,n.reject=i.reject,i.allSettled&&(n.allSettled=i.allSettled),i.any&&(n.any=i.any))}}function qs(){var t=ie.Promise;return Yi?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(ie,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:En.then,gthen:t.prototype.then}:{}}function hr(t,e,r,n,i){var o=K;try{return vt(t,!0),e(r,n,i)}finally{vt(o,!1)}}function Ys(t){Hs.call(Qi,t)}function Bn(t,e,r,n){return typeof t!="function"?t:function(){var i=K;r&&dr(),vt(e,!0);try{return t.apply(this,arguments)}finally{vt(i,!1),n&&Ys(ot)}}}function Js(t,e){return function(r,n){return t.call(this,Bn(r,e),Bn(n,e))}}var Xs="unhandledrejection";function Zs(t,e){var r;try{r=e.onuncatched(t)}catch{}if(r!==!1)try{var n,i={promise:e,reason:t};if(ie.document&&document.createEvent?(n=document.createEvent("Event"),n.initEvent(Xs,!0,!0),Pe(n,i)):ie.CustomEvent&&(n=new CustomEvent(Xs,{detail:i}),Pe(n,i)),n&&ie.dispatchEvent&&(dispatchEvent(n),!ie.PromiseRejectionEvent&&ie.onunhandledrejection))try{ie.onunhandledrejection(n)}catch{}Je&&n&&!n.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var ye=M.reject;function so(t,e,r,n){if(!t.idbdb||!t._state.openComplete&&!K.letThrough&&!t._vip){if(t._state.openComplete)return ye(new V.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return ye(new V.DatabaseClosed);t.open().catch(ne)}return t._state.dbReadyPromise.then(()=>so(t,e,r,n))}else{var i=t._createTransaction(e,r,t._dbSchema);try{i.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===Ui.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>so(t,e,r,n))):ye(o)}return i._promise(e,(o,s)=>yt(()=>(K.trans=i,n(o,s,i)))).then(o=>i._completion.then(()=>o))}}var ea="3.2.2",Ht=String.fromCharCode(65535),ao=-1/0,st="Invalid key provided. Keys must be of type string, number, Date or Array.",ta="String expected.",Jr=[],Nn=typeof navigator!="undefined"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Pf=Nn,Mf=Nn,ra=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),Kn="__dbnames",lo="readonly",uo="readwrite";function $t(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}var na={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function zn(t){return typeof t=="string"&&!/\./.test(t)?e=>(e[t]===void 0&&t in e&&(e=Hr(e),delete e[t]),e):e=>e}var ia=class{_trans(e,r,n){let i=this._tx||K.trans,o=this.name;function s(l,u,d){if(!d.schema[o])throw new V.NotFound("Table "+o+" not part of transaction");return r(d.idbtrans,d)}let a=qr();try{return i&&i.db===this.db?i===K.trans?i._promise(e,s,n):yt(()=>i._promise(e,s,n),{trans:i,transless:K.transless||K}):so(this.db,e,[this.name],s)}finally{a&&Yr()}}get(e,r){return e&&e.constructor===Object?this.where(e).first(r):this._trans("readonly",n=>this.core.get({trans:n,key:e}).then(i=>this.hook.reading.fire(i))).then(r)}where(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(Te(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let r=he(e);if(r.length===1)return this.where(r[0]).equals(e[r[0]]);let n=this.schema.indexes.concat(this.schema.primKey).filter(u=>u.compound&&r.every(d=>u.keyPath.indexOf(d)>=0)&&u.keyPath.every(d=>r.indexOf(d)>=0))[0];if(n&&this.db._maxKey!==Ht)return this.where(n.name).equals(n.keyPath.map(u=>e[u]));!n&&Je&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${r.join("+")}]`);let{idxByName:i}=this.schema,o=this.db._deps.indexedDB;function s(u,d){try{return o.cmp(u,d)===0}catch{return!1}}let[a,l]=r.reduce(([u,d],f)=>{let c=i[f],y=e[f];return[u||c,u||!c?$t(d,c&&c.multi?w=>{let x=nt(w,f);return Te(x)&&x.some(b=>s(y,b))}:w=>s(y,nt(w,f))):d]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(l):n?this.filter(l):this.where(r).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,Te(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let r=n=>{if(!n)return n;let i=Object.create(e.prototype);for(var o in n)if(Ve(n,o))try{i[o]=n[o]}catch{}return i};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=r,this.hook("reading",r),e}defineClass(){function e(r){Pe(this,r)}return this.mapToClass(e)}add(e,r){let{auto:n,keyPath:i}=this.schema.primKey,o=e;return i&&n&&(o=zn(i)(e)),this._trans("readwrite",s=>this.core.mutate({trans:s,type:"add",keys:r!=null?[r]:null,values:[o]})).then(s=>s.numFailures?M.reject(s.failures[0]):s.lastResult).then(s=>{if(i)try{Qe(e,i,s)}catch{}return s})}update(e,r){if(typeof e=="object"&&!Te(e)){let n=nt(e,this.schema.primKey.keyPath);if(n===void 0)return ye(new V.InvalidArgument("Given object does not contain its primary key"));try{typeof r!="function"?he(r).forEach(i=>{Qe(e,i,r[i])}):r(e,{value:e,primKey:n})}catch{}return this.where(":id").equals(n).modify(r)}else return this.where(":id").equals(e).modify(r)}put(e,r){let{auto:n,keyPath:i}=this.schema.primKey,o=e;return i&&n&&(o=zn(i)(e)),this._trans("readwrite",s=>this.core.mutate({trans:s,type:"put",values:[o],keys:r!=null?[r]:null})).then(s=>s.numFailures?M.reject(s.failures[0]):s.lastResult).then(s=>{if(i)try{Qe(e,i,s)}catch{}return s})}delete(e){return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:[e]})).then(r=>r.numFailures?M.reject(r.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:na})).then(e=>e.numFailures?M.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",r=>this.core.getMany({keys:e,trans:r}).then(n=>n.map(i=>this.hook.reading.fire(i))))}bulkAdd(e,r,n){let i=Array.isArray(r)?r:void 0;n=n||(i?void 0:r);let o=n?n.allKeys:void 0;return this._trans("readwrite",s=>{let{auto:a,keyPath:l}=this.schema.primKey;if(l&&i)throw new V.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new V.InvalidArgument("Arguments objects and keys must have the same length");let u=e.length,d=l&&a?e.map(zn(l)):e;return this.core.mutate({trans:s,type:"add",keys:i,values:d,wantResults:o}).then(({numFailures:f,results:c,lastResult:y,failures:w})=>{let x=o?c:y;if(f===0)return x;throw new $r(`${this.name}.bulkAdd(): ${f} of ${u} operations failed`,w)})})}bulkPut(e,r,n){let i=Array.isArray(r)?r:void 0;n=n||(i?void 0:r);let o=n?n.allKeys:void 0;return this._trans("readwrite",s=>{let{auto:a,keyPath:l}=this.schema.primKey;if(l&&i)throw new V.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new V.InvalidArgument("Arguments objects and keys must have the same length");let u=e.length,d=l&&a?e.map(zn(l)):e;return this.core.mutate({trans:s,type:"put",keys:i,values:d,wantResults:o}).then(({numFailures:f,results:c,lastResult:y,failures:w})=>{let x=o?c:y;if(f===0)return x;throw new $r(`${this.name}.bulkPut(): ${f} of ${u} operations failed`,w)})})}bulkDelete(e){let r=e.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:e})).then(({numFailures:n,lastResult:i,failures:o})=>{if(n===0)return i;throw new $r(`${this.name}.bulkDelete(): ${n} of ${r} operations failed`,o)})}};function Xr(t){var e={},r=function(a,l){if(l){for(var u=arguments.length,d=new Array(u-1);--u;)d[u-1]=arguments[u];return e[a].subscribe.apply(null,d),t}else if(typeof a=="string")return e[a]};r.addEventType=o;for(var n=1,i=arguments.length;n$t(n(),e()):e,t.justLimit=r&&!n}function Lf(t,e){t.isMatch=$t(t.isMatch,e)}function Vn(t,e){if(t.isPrimKey)return e.primaryKey;let r=e.getIndexByKeyPath(t.index);if(!r)throw new V.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return r}function oa(t,e,r){let n=Vn(t,e.schema);return e.openCursor({trans:r,values:!t.keysOnly,reverse:t.dir==="prev",unique:!!t.unique,query:{index:n,range:t.range}})}function Hn(t,e,r,n){let i=t.replayFilter?$t(t.filter,t.replayFilter()):t.filter;if(t.or){let o={},s=(a,l,u)=>{if(!i||i(l,u,c=>l.stop(c),c=>l.fail(c))){var d=l.primaryKey,f=""+d;f==="[object ArrayBuffer]"&&(f=""+new Uint8Array(d)),Ve(o,f)||(o[f]=!0,e(a,l,u))}};return Promise.all([t.or._iterate(s,r),sa(oa(t,n,r),t.algorithm,s,!t.keysOnly&&t.valueMapper)])}else return sa(oa(t,n,r),$t(t.algorithm,i),e,!t.keysOnly&&t.valueMapper)}function sa(t,e,r,n){var i=n?(s,a,l)=>r(n(s),a,l):r,o=se(i);return t.then(s=>{if(s)return s.start(()=>{var a=()=>s.continue();(!e||e(s,l=>a=l,l=>{s.stop(l),a=ne},l=>{s.fail(l),a=ne}))&&o(s.value,s,l=>a=l),a()})})}function Me(t,e){try{let r=aa(t),n=aa(e);if(r!==n)return r==="Array"?1:n==="Array"?-1:r==="binary"?1:n==="binary"?-1:r==="string"?1:n==="string"?-1:r==="Date"?1:n!=="Date"?NaN:-1;switch(r){case"number":case"Date":case"string":return t>e?1:tHn(r,e,n,r.table.core))}count(e){return this._read(r=>{let n=this._ctx,i=n.table.core;if(pr(n,!0))return i.count({trans:r,query:{index:Vn(n,i.schema),range:n.range}}).then(s=>Math.min(s,n.limit));var o=0;return Hn(n,()=>(++o,!1),r,i).then(()=>o)}).then(e)}sortBy(e,r){let n=e.split(".").reverse(),i=n[0],o=n.length-1;function s(u,d){return d?s(u[n[d]],d-1):u[i]}var a=this._ctx.dir==="next"?1:-1;function l(u,d){var f=s(u,o),c=s(d,o);return fc?a:0}return this.toArray(function(u){return u.sort(l)}).then(r)}toArray(e){return this._read(r=>{var n=this._ctx;if(n.dir==="next"&&pr(n,!0)&&n.limit>0){let{valueMapper:i}=n,o=Vn(n,n.table.core.schema);return n.table.core.query({trans:r,limit:n.limit,values:!0,query:{index:o,range:n.range}}).then(({result:s})=>i?s.map(i):s)}else{let i=[];return Hn(n,o=>i.push(o),r,n.table.core).then(()=>i)}},e)}offset(e){var r=this._ctx;return e<=0?this:(r.offset+=e,pr(r)?fo(r,()=>{var n=e;return(i,o)=>n===0?!0:n===1?(--n,!1):(o(()=>{i.advance(n),n=0}),!1)}):fo(r,()=>{var n=e;return()=>--n<0}),this)}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),fo(this._ctx,()=>{var r=e;return function(n,i,o){return--r<=0&&i(o),r>=0}},!0),this}until(e,r){return co(this._ctx,function(n,i,o){return e(n.value)?(i(o),r):!0}),this}first(e){return this.limit(1).toArray(function(r){return r[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){return co(this._ctx,function(r){return e(r.value)}),Lf(this._ctx,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var r=this._ctx;return r.keysOnly=!r.isMatch,this.each(function(n,i){e(i.key,i)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var r=this._ctx;return r.keysOnly=!r.isMatch,this.each(function(n,i){e(i.primaryKey,i)})}keys(e){var r=this._ctx;r.keysOnly=!r.isMatch;var n=[];return this.each(function(i,o){n.push(o.key)}).then(function(){return n}).then(e)}primaryKeys(e){var r=this._ctx;if(r.dir==="next"&&pr(r,!0)&&r.limit>0)return this._read(i=>{var o=Vn(r,r.table.core.schema);return r.table.core.query({trans:i,values:!1,limit:r.limit,query:{index:o,range:r.range}})}).then(({result:i})=>i).then(e);r.keysOnly=!r.isMatch;var n=[];return this.each(function(i,o){n.push(o.primaryKey)}).then(function(){return n}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(r){return r[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,r=e.index&&e.table.schema.idxByName[e.index];if(!r||!r.multi)return this;var n={};return co(this._ctx,function(i){var o=i.primaryKey.toString(),s=Ve(n,o);return n[o]=!0,!s}),this}modify(e){var r=this._ctx;return this._write(n=>{var i;if(typeof e=="function")i=e;else{var o=he(e),s=o.length;i=function(x){for(var b=!1,h=0;h{let{failures:h,numFailures:_}=b;c+=x-_;for(let p of he(h))f.push(h[p])};return this.clone().primaryKeys().then(x=>{let b=h=>{let _=Math.min(d,x.length-h);return a.getMany({trans:n,keys:x.slice(h,h+_),cache:"immutable"}).then(p=>{let m=[],v=[],g=l?[]:null,j=[];for(let S=0;S<_;++S){let E=p[S],P={value:Hr(E),primKey:x[h+S]};i.call(P,P.value,P)!==!1&&(P.value==null?j.push(x[h+S]):!l&&Me(u(E),u(P.value))!==0?(j.push(x[h+S]),m.push(P.value)):(v.push(P.value),l&&g.push(x[h+S])))}let C=pr(r)&&r.limit===1/0&&(typeof e!="function"||e===ho)&&{index:r.index,range:r.range};return Promise.resolve(m.length>0&&a.mutate({trans:n,type:"add",values:m}).then(S=>{for(let E in S.failures)j.splice(parseInt(E),1);w(m.length,S)})).then(()=>(v.length>0||C&&typeof e=="object")&&a.mutate({trans:n,type:"put",keys:g,values:v,criteria:C,changeSpec:typeof e!="function"&&e}).then(S=>w(v.length,S))).then(()=>(j.length>0||C&&e===ho)&&a.mutate({trans:n,type:"delete",keys:j,criteria:C}).then(S=>w(j.length,S))).then(()=>x.length>h+_&&b(h+d))})};return b(0).then(()=>{if(f.length>0)throw new Sn("Error modifying one or more objects",f,c,y);return x.length})})})}delete(){var e=this._ctx,r=e.range;return pr(e)&&(e.isPrimKey&&!Mf||r.type===3)?this._write(n=>{let{primaryKey:i}=e.table.core.schema,o=r;return e.table.core.count({trans:n,query:{index:i,range:o}}).then(s=>e.table.core.mutate({trans:n,type:"deleteRange",range:o}).then(({failures:a,lastResult:l,results:u,numFailures:d})=>{if(d)throw new Sn("Could not delete some values",Object.keys(a).map(f=>a[f]),s-d);return s-d}))}):this.modify(ho)}},ho=(t,e)=>e.value=null;function Kf(t){return Zr(ua.prototype,function(r,n){this.db=t;let i=na,o=null;if(n)try{i=n()}catch(u){o=u}let s=r._ctx,a=s.table,l=a.hook.reading.fire;this._ctx={table:a,index:s.index,isPrimKey:!s.index||a.schema.primKey.keyPath&&s.index===a.schema.primKey.name,range:i,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:o,or:s.or,valueMapper:l!==Wr?l:null}})}function zf(t,e){return te?-1:t===e?0:1}function He(t,e,r){var n=t instanceof po?new t.Collection(t):t;return n._ctx.error=r?new r(e):new TypeError(e),n}function mr(t){return new t.Collection(t,()=>ca("")).limit(0)}function Hf(t){return t==="next"?e=>e.toUpperCase():e=>e.toLowerCase()}function $f(t){return t==="next"?e=>e.toLowerCase():e=>e.toUpperCase()}function Wf(t,e,r,n,i,o){for(var s=Math.min(t.length,n.length),a=-1,l=0;l=0?t.substr(0,a)+e[a]+r.substr(a+1):null;i(t[l],u)<0&&(a=l)}return stypeof x=="string"))return He(t,ta);function c(x){i=Hf(x),o=$f(x),s=x==="next"?zf:Vf;var b=r.map(function(h){return{lower:o(h),upper:i(h)}}).sort(function(h,_){return s(h.lower,_.lower)});a=b.map(function(h){return h.upper}),l=b.map(function(h){return h.lower}),u=x,d=x==="next"?"":n}c("next");var y=new t.Collection(t,()=>_t(a[0],l[f-1]+n));y._ondirectionchange=function(x){c(x)};var w=0;return y._addAlgorithm(function(x,b,h){var _=x.key;if(typeof _!="string")return!1;var p=o(_);if(e(p,l,w))return!0;for(var m=null,v=w;v0)&&(m=g)}return b(m!==null?function(){x.continue(m+d)}:h),!1}),y}function _t(t,e,r,n){return{type:2,lower:t,upper:e,lowerOpen:r,upperOpen:n}}function ca(t){return{type:1,lower:t,upper:t}}var po=class{get Collection(){return this._ctx.table.db.Collection}between(e,r,n,i){n=n!==!1,i=i===!0;try{return this._cmp(e,r)>0||this._cmp(e,r)===0&&(n||i)&&!(n&&i)?mr(this):new this.Collection(this,()=>_t(e,r,!n,!i))}catch{return He(this,st)}}equals(e){return e==null?He(this,st):new this.Collection(this,()=>ca(e))}above(e){return e==null?He(this,st):new this.Collection(this,()=>_t(e,void 0,!0))}aboveOrEqual(e){return e==null?He(this,st):new this.Collection(this,()=>_t(e,void 0,!1))}below(e){return e==null?He(this,st):new this.Collection(this,()=>_t(void 0,e,!1,!0))}belowOrEqual(e){return e==null?He(this,st):new this.Collection(this,()=>_t(void 0,e))}startsWith(e){return typeof e!="string"?He(this,ta):this.between(e,e+Ht,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):$n(this,(r,n)=>r.indexOf(n[0])===0,[e],Ht)}equalsIgnoreCase(e){return $n(this,(r,n)=>r===n[0],[e],"")}anyOfIgnoreCase(){var e=it.apply(ur,arguments);return e.length===0?mr(this):$n(this,(r,n)=>n.indexOf(r)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=it.apply(ur,arguments);return e.length===0?mr(this):$n(this,(r,n)=>n.some(i=>r.indexOf(i)===0),e,Ht)}anyOf(){let e=it.apply(ur,arguments),r=this._cmp;try{e.sort(r)}catch{return He(this,st)}if(e.length===0)return mr(this);let n=new this.Collection(this,()=>_t(e[0],e[e.length-1]));n._ondirectionchange=o=>{r=o==="next"?this._ascending:this._descending,e.sort(r)};let i=0;return n._addAlgorithm((o,s,a)=>{let l=o.key;for(;r(l,e[i])>0;)if(++i,i===e.length)return s(a),!1;return r(l,e[i])===0?!0:(s(()=>{o.continue(e[i])}),!1)}),n}notEqual(e){return this.inAnyRange([[ao,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=it.apply(ur,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return He(this,st)}let r=e.reduce((n,i)=>n?n.concat([[n[n.length-1][1],i]]):[[ao,i]],null);return r.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(r,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,r){let n=this._cmp,i=this._ascending,o=this._descending,s=this._min,a=this._max;if(e.length===0)return mr(this);if(!e.every(m=>m[0]!==void 0&&m[1]!==void 0&&i(m[0],m[1])<=0))return He(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",V.InvalidArgument);let l=!r||r.includeLowers!==!1,u=r&&r.includeUppers===!0;function d(m,v){let g=0,j=m.length;for(;g0){C[0]=s(C[0],v[0]),C[1]=a(C[1],v[1]);break}}return g===j&&m.push(v),m}let f=i;function c(m,v){return f(m[0],v[0])}let y;try{y=e.reduce(d,[]),y.sort(c)}catch{return He(this,st)}let w=0,x=u?m=>i(m,y[w][1])>0:m=>i(m,y[w][1])>=0,b=l?m=>o(m,y[w][0])>0:m=>o(m,y[w][0])>=0;function h(m){return!x(m)&&!b(m)}let _=x,p=new this.Collection(this,()=>_t(y[0][0],y[y.length-1][1],!l,!u));return p._ondirectionchange=m=>{m==="next"?(_=x,f=i):(_=b,f=o),y.sort(c)},p._addAlgorithm((m,v,g)=>{for(var j=m.key;_(j);)if(++w,w===y.length)return v(g),!1;return h(j)?!0:(this._cmp(j,y[w][1])===0||this._cmp(j,y[w][0])===0||v(()=>{f===i?m.continue(y[w][0]):m.continue(y[w][1])}),!1)}),p}startsWithAnyOf(){let e=it.apply(ur,arguments);return e.every(r=>typeof r=="string")?e.length===0?mr(this):this.inAnyRange(e.map(r=>[r,r+Ht])):He(this,"startsWithAnyOf() only works with strings")}};function Uf(t){return Zr(po.prototype,function(r,n,i){this.db=t,this._ctx={table:r,index:n===":id"?null:n,or:i};let o=t._deps.indexedDB;if(!o)throw new V.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(s,a)=>o.cmp(a,s),this._max=(s,a)=>o.cmp(s,a)>0?s:a,this._min=(s,a)=>o.cmp(s,a)<0?s:a,this._IDBKeyRange=t._deps.IDBKeyRange})}function Xe(t){return se(function(e){return en(e),t(e.target.error),!1})}function en(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}var tn="storagemutated",bt="x-storagemutated-1",xt=Xr(null,tn),fa=class{_lock(){return Vr(!K.global),++this._reculock,this._reculock===1&&!K.global&&(K.lockOwnerFor=this),this}_unlock(){if(Vr(!K.global),--this._reculock==0)for(K.global||(K.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{hr(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&K.lockOwnerFor!==this}create(e){if(!this.mode)return this;let r=this.db.idbdb,n=this.db._state.dbOpenError;if(Vr(!this.idbtrans),!e&&!r)switch(n&&n.name){case"DatabaseClosedError":throw new V.DatabaseClosed(n);case"MissingAPIError":throw new V.MissingAPI(n.message,n);default:throw new V.OpenFailed(n)}if(!this.active)throw new V.TransactionInactive;return Vr(this._completion._state===null),e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):r.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})),e.onerror=se(i=>{en(i),this._reject(e.error)}),e.onabort=se(i=>{en(i),this.active&&this._reject(new V.Abort(e.error)),this.active=!1,this.on("abort").fire(i)}),e.oncomplete=se(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&xt.storagemutated.fire(e.mutatedParts)}),this}_promise(e,r,n){if(e==="readwrite"&&this.mode!=="readwrite")return ye(new V.ReadOnly("Transaction is readonly"));if(!this.active)return ye(new V.TransactionInactive);if(this._locked())return new M((o,s)=>{this._blockedFuncs.push([()=>{this._promise(e,r,n).then(o,s)},K])});if(n)return yt(()=>{var o=new M((s,a)=>{this._lock();let l=r(s,a,this);l&&l.then&&l.then(s,a)});return o.finally(()=>this._unlock()),o._lib=!0,o});var i=new M((o,s)=>{var a=r(o,s,this);a&&a.then&&a.then(o,s)});return i._lib=!0,i}_root(){return this.parent?this.parent._root():this}waitFor(e){var r=this._root();let n=M.resolve(e);if(r._waitingFor)r._waitingFor=r._waitingFor.then(()=>n);else{r._waitingFor=n,r._waitingQueue=[];var i=r.idbtrans.objectStore(r.storeNames[0]);(function s(){for(++r._spinCount;r._waitingQueue.length;)r._waitingQueue.shift()();r._waitingFor&&(i.get(-1/0).onsuccess=s)})()}var o=r._waitingFor;return new M((s,a)=>{n.then(l=>r._waitingQueue.push(se(s.bind(null,l))),l=>r._waitingQueue.push(se(a.bind(null,l)))).finally(()=>{r._waitingFor===o&&(r._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new V.Abort))}table(e){let r=this._memoizedTables||(this._memoizedTables={});if(Ve(r,e))return r[e];let n=this.schema[e];if(!n)throw new V.NotFound("Table "+e+" not part of transaction");let i=new this.db.Table(e,n,this);return i.core=this.db.core.table(e),r[e]=i,i}};function Gf(t){return Zr(fa.prototype,function(r,n,i,o,s){this.db=t,this.mode=r,this.storeNames=n,this.schema=i,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=Xr(this,"complete","error","abort"),this.parent=s||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new M((a,l)=>{this._resolve=a,this._reject=l}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},a=>{var l=this.active;return this.active=!1,this.on.error.fire(a),this.parent?this.parent._reject(a):l&&this.idbtrans&&this.idbtrans.abort(),ye(a)})})}function mo(t,e,r,n,i,o,s){return{name:t,keyPath:e,unique:r,multi:n,auto:i,compound:o,src:(r&&!s?"&":"")+(n?"*":"")+(i?"++":"")+da(e)}}function da(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function ha(t,e,r){return{name:t,primKey:e,indexes:r,mappedClass:null,idxByName:ks(r,n=>[n.name,n])}}function Qf(t){return t.length===1?t[0]:t}var rn=t=>{try{return t.only([[]]),rn=()=>[[]],[[]]}catch{return rn=()=>Ht,Ht}};function go(t){return t==null?()=>{}:typeof t=="string"?qf(t):e=>nt(e,t)}function qf(t){return t.split(".").length===1?r=>r[t]:r=>nt(r,t)}function pa(t){return[].slice.call(t)}var Yf=0;function nn(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function Jf(t,e,r){function n(d,f){let c=pa(d.objectStoreNames);return{schema:{name:d.name,tables:c.map(y=>f.objectStore(y)).map(y=>{let{keyPath:w,autoIncrement:x}=y,b=Te(w),h=w==null,_={},p={name:y.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:h,compound:b,keyPath:w,autoIncrement:x,unique:!0,extractKey:go(w)},indexes:pa(y.indexNames).map(m=>y.index(m)).map(m=>{let{name:v,unique:g,multiEntry:j,keyPath:C}=m,S=Te(C),E={name:v,compound:S,keyPath:C,unique:g,multiEntry:j,extractKey:go(C)};return _[nn(C)]=E,E}),getIndexByKeyPath:m=>_[nn(m)]};return _[":id"]=p.primaryKey,w!=null&&(_[nn(w)]=p.primaryKey),p})},hasGetAll:c.length>0&&"getAll"in f.objectStore(c[0])&&!(typeof navigator!="undefined"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}function i(d){if(d.type===3)return null;if(d.type===4)throw new Error("Cannot convert never type to IDBKeyRange");let{lower:f,upper:c,lowerOpen:y,upperOpen:w}=d;return f===void 0?c===void 0?null:e.upperBound(c,!!w):c===void 0?e.lowerBound(f,!!y):e.bound(f,c,!!y,!!w)}function o(d){let f=d.name;function c({trans:x,type:b,keys:h,values:_,range:p}){return new Promise((m,v)=>{m=se(m);let g=x.objectStore(f),j=g.keyPath==null,C=b==="put"||b==="add";if(!C&&b!=="delete"&&b!=="deleteRange")throw new Error("Invalid operation type: "+b);let{length:S}=h||_||{length:1};if(h&&_&&h.length!==_.length)throw new Error("Given keys array must have same length as given values array.");if(S===0)return m({numFailures:0,failures:{},results:[],lastResult:void 0});let E,P=[],L=[],k=0,z=Q=>{++k,en(Q)};if(b==="deleteRange"){if(p.type===4)return m({numFailures:k,failures:L,results:[],lastResult:void 0});p.type===3?P.push(E=g.clear()):P.push(E=g.delete(i(p)))}else{let[Q,Z]=C?j?[_,h]:[_,null]:[h,null];if(C)for(let A=0;A{let Z=Q.target.result;P.forEach((A,F)=>A.error!=null&&(L[F]=A.error)),m({numFailures:k,failures:L,results:b==="delete"?h:P.map(A=>A.result),lastResult:Z})};E.onerror=Q=>{z(Q),J(Q)},E.onsuccess=J})}function y({trans:x,values:b,query:h,reverse:_,unique:p}){return new Promise((m,v)=>{m=se(m);let{index:g,range:j}=h,C=x.objectStore(f),S=g.isPrimaryKey?C:C.index(g.name),E=_?p?"prevunique":"prev":p?"nextunique":"next",P=b||!("openKeyCursor"in S)?S.openCursor(i(j),E):S.openKeyCursor(i(j),E);P.onerror=Xe(v),P.onsuccess=se(L=>{let k=P.result;if(!k){m(null);return}k.___id=++Yf,k.done=!1;let z=k.continue.bind(k),J=k.continuePrimaryKey;J&&(J=J.bind(k));let Q=k.advance.bind(k),Z=()=>{throw new Error("Cursor not started")},A=()=>{throw new Error("Cursor not stopped")};k.trans=x,k.stop=k.continue=k.continuePrimaryKey=k.advance=Z,k.fail=se(v),k.next=function(){let F=1;return this.start(()=>F--?this.continue():this.stop()).then(()=>this)},k.start=F=>{let D=new Promise((O,X)=>{O=se(O),P.onerror=Xe(X),k.fail=X,k.stop=le=>{k.stop=k.continue=k.continuePrimaryKey=k.advance=A,O(le)}}),N=()=>{if(P.result)try{F()}catch(O){k.fail(O)}else k.done=!0,k.start=()=>{throw new Error("Cursor behind last entry")},k.stop()};return P.onsuccess=se(O=>{P.onsuccess=N,N()}),k.continue=z,k.continuePrimaryKey=J,k.advance=Q,N(),D},m(k)},v)})}function w(x){return b=>new Promise((h,_)=>{h=se(h);let{trans:p,values:m,limit:v,query:g}=b,j=v===1/0?void 0:v,{index:C,range:S}=g,E=p.objectStore(f),P=C.isPrimaryKey?E:E.index(C.name),L=i(S);if(v===0)return h({result:[]});if(x){let k=m?P.getAll(L,j):P.getAllKeys(L,j);k.onsuccess=z=>h({result:z.target.result}),k.onerror=Xe(_)}else{let k=0,z=m||!("openKeyCursor"in P)?P.openCursor(L):P.openKeyCursor(L),J=[];z.onsuccess=Q=>{let Z=z.result;if(!Z)return h({result:J});if(J.push(m?Z.value:Z.primaryKey),++k===v)return h({result:J});Z.continue()},z.onerror=Xe(_)}})}return{name:f,schema:d,mutate:c,getMany({trans:x,keys:b}){return new Promise((h,_)=>{h=se(h);let p=x.objectStore(f),m=b.length,v=new Array(m),g=0,j=0,C,S=P=>{let L=P.target;(v[L._pos]=L.result)!=null,++j===g&&h(v)},E=Xe(_);for(let P=0;P{h=se(h);let m=x.objectStore(f).get(b);m.onsuccess=v=>h(v.target.result),m.onerror=Xe(_)})},query:w(a),openCursor:y,count({query:x,trans:b}){let{index:h,range:_}=x;return new Promise((p,m)=>{let v=b.objectStore(f),g=h.isPrimaryKey?v:v.index(h.name),j=i(_),C=j?g.count(j):g.count();C.onsuccess=se(S=>p(S.target.result)),C.onerror=Xe(m)})}}}let{schema:s,hasGetAll:a}=n(t,r),l=s.tables.map(d=>o(d)),u={};return l.forEach(d=>u[d.name]=d),{stack:"dbcore",transaction:t.transaction.bind(t),table(d){if(!u[d])throw new Error(`Table '${d}' not found`);return u[d]},MIN_KEY:-1/0,MAX_KEY:rn(e),schema:s}}function Xf(t,e){return e.reduce((r,{create:n})=>ue(ue({},r),n(r)),t)}function Zf(t,e,{IDBKeyRange:r,indexedDB:n},i){return{dbcore:Xf(Jf(e,r,i),t.dbcore)}}function yo({_novip:t},e){let r=e.db,n=Zf(t._middlewares,r,t._deps,e);t.core=n.dbcore,t.tables.forEach(i=>{let o=i.name;t.core.schema.tables.some(s=>s.name===o)&&(i.core=t.core.table(o),t[o]instanceof t.Table&&(t[o].core=i.core))})}function Wn({_novip:t},e,r,n){r.forEach(i=>{let o=n[i];e.forEach(s=>{let a=Ni(s,i);(!a||"value"in a&&a.value===void 0)&&(s===t.Transaction.prototype||s instanceof t.Transaction?rt(s,i,{get(){return this.table(i)},set(l){Ts(this,i,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):s[i]=new t.Table(i,o))})})}function vo({_novip:t},e){e.forEach(r=>{for(let n in r)r[n]instanceof t.Table&&delete r[n]})}function ed(t,e){return t._cfg.version-e._cfg.version}function td(t,e,r,n){let i=t._dbSchema,o=t._createTransaction("readwrite",t._storeNames,i);o.create(r),o._completion.catch(n);let s=o._reject.bind(o),a=K.transless||K;yt(()=>{K.trans=o,K.transless=a,e===0?(he(i).forEach(l=>{_o(r,l,i[l].primKey,i[l].indexes)}),yo(t,r),M.follow(()=>t.on.populate.fire(o)).catch(s)):rd(t,e,o,r).catch(s)})}function rd({_novip:t},e,r,n){let i=[],o=t._versions,s=t._dbSchema=xo(t,t.idbdb,n),a=!1;o.filter(d=>d._cfg.version>=e).forEach(d=>{i.push(()=>{let f=s,c=d._cfg.dbschema;wo(t,f,n),wo(t,c,n),s=t._dbSchema=c;let y=ma(f,c);y.add.forEach(x=>{_o(n,x[0],x[1].primKey,x[1].indexes)}),y.change.forEach(x=>{if(x.recreate)throw new V.Upgrade("Not yet support for changing primary key");{let b=n.objectStore(x.name);x.add.forEach(h=>bo(b,h)),x.change.forEach(h=>{b.deleteIndex(h.name),bo(b,h)}),x.del.forEach(h=>b.deleteIndex(h))}});let w=d._cfg.contentUpgrade;if(w&&d._cfg.version>e){yo(t,n),r._memoizedTables={},a=!0;let x=Ps(c);y.del.forEach(p=>{x[p]=f[p]}),vo(t,[t.Transaction.prototype]),Wn(t,[t.Transaction.prototype],he(x),x),r.schema=x;let b=Hi(w);b&&dr();let h,_=M.follow(()=>{if(h=w(r),h&&b){var p=ot.bind(null,null);h.then(p,p)}});return h&&typeof h.then=="function"?M.resolve(h):_.then(()=>h)}}),i.push(f=>{if(!a||!Pf){let c=d._cfg.dbschema;id(c,f)}vo(t,[t.Transaction.prototype]),Wn(t,[t.Transaction.prototype],t._storeNames,t._dbSchema),r.schema=t._dbSchema})});function u(){return i.length?M.resolve(i.shift()(r.idbtrans)).then(u):M.resolve()}return u().then(()=>{nd(s,n)})}function ma(t,e){let r={del:[],add:[],change:[]},n;for(n in t)e[n]||r.del.push(n);for(n in e){let i=t[n],o=e[n];if(!i)r.add.push([n,o]);else{let s={name:n,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!=""+(o.primKey.keyPath||"")||i.primKey.auto!==o.primKey.auto&&!Nn)s.recreate=!0,r.change.push(s);else{let a=i.idxByName,l=o.idxByName,u;for(u in a)l[u]||s.del.push(u);for(u in l){let d=a[u],f=l[u];d?d.src!==f.src&&s.change.push(f):s.add.push(f)}(s.del.length>0||s.add.length>0||s.change.length>0)&&r.change.push(s)}}}return r}function _o(t,e,r,n){let i=t.db.createObjectStore(e,r.keyPath?{keyPath:r.keyPath,autoIncrement:r.auto}:{autoIncrement:r.auto});return n.forEach(o=>bo(i,o)),i}function nd(t,e){he(t).forEach(r=>{e.db.objectStoreNames.contains(r)||_o(e,r,t[r].primKey,t[r].indexes)})}function id(t,e){[].slice.call(e.db.objectStoreNames).forEach(r=>t[r]==null&&e.db.deleteObjectStore(r))}function bo(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function xo(t,e,r){let n={};return An(e.objectStoreNames,0).forEach(o=>{let s=r.objectStore(o),a=s.keyPath,l=mo(da(a),a||"",!1,!1,!!s.autoIncrement,a&&typeof a!="string",!0),u=[];for(let f=0;fi.add.length||i.change.length))}function wo({_novip:t},e,r){let n=r.db.objectStoreNames;for(let i=0;i{e=e.trim();let n=e.replace(/([&*]|\+\+)/g,""),i=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return mo(n,i||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),Te(i),r===0)})}var ga=class{_parseStoresSpec(e,r){he(e).forEach(n=>{if(e[n]!==null){var i=ad(e[n]),o=i.shift();if(o.multi)throw new V.Schema("Primary key cannot be multi-valued");i.forEach(s=>{if(s.auto)throw new V.Schema("Only primary key can be marked as autoIncrement (++)");if(!s.keyPath)throw new V.Schema("Index must have a name and cannot be an empty string")}),r[n]=ha(n,o,i)}})}stores(e){let r=this.db;this._cfg.storesSource=this._cfg.storesSource?Pe(this._cfg.storesSource,e):e;let n=r._versions,i={},o={};return n.forEach(s=>{Pe(i,s._cfg.storesSource),o=s._cfg.dbschema={},s._parseStoresSpec(i,o)}),r._dbSchema=o,vo(r,[r._allTables,r,r.Transaction.prototype]),Wn(r,[r._allTables,r,r.Transaction.prototype,this._cfg.tables],he(o),o),r._storeNames=he(o),this}upgrade(e){return this._cfg.contentUpgrade=Gi(this._cfg.contentUpgrade||ne,e),this}};function ld(t){return Zr(ga.prototype,function(r){this.db=t,this._cfg={version:r,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}function jo(t,e){let r=t._dbNamesDB;return r||(r=t._dbNamesDB=new lt(Kn,{addons:[],indexedDB:t,IDBKeyRange:e}),r.version(1).stores({dbnames:"name"})),r.table("dbnames")}function Co(t){return t&&typeof t.databases=="function"}function ud({indexedDB:t,IDBKeyRange:e}){return Co(t)?Promise.resolve(t.databases()).then(r=>r.map(n=>n.name).filter(n=>n!==Kn)):jo(t,e).toCollection().primaryKeys()}function cd({indexedDB:t,IDBKeyRange:e},r){!Co(t)&&r!==Kn&&jo(t,e).put({name:r}).catch(ne)}function fd({indexedDB:t,IDBKeyRange:e},r){!Co(t)&&r!==Kn&&jo(t,e).delete(r).catch(ne)}function Ao(t){return yt(function(){return K.letThrough=!0,t()})}function dd(){var t=!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent);if(!t||!indexedDB.databases)return Promise.resolve();var e;return new Promise(function(r){var n=function(){return indexedDB.databases().finally(r)};e=setInterval(n,100),n()}).finally(function(){return clearInterval(e)})}function hd(t){let e=t._state,{indexedDB:r}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?ye(e.dbOpenError):t);Je&&(e.openCanceller._stackHolder=Nt()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;let n=e.openCanceller;function i(){if(e.openCanceller!==n)throw new V.DatabaseClosed("db.open() was cancelled")}let o=e.dbReadyResolve,s=null,a=!1;return M.race([n,(typeof navigator=="undefined"?M.resolve():dd()).then(()=>new M((l,u)=>{if(i(),!r)throw new V.MissingAPI;let d=t.name,f=e.autoSchema?r.open(d):r.open(d,Math.round(t.verno*10));if(!f)throw new V.MissingAPI;f.onerror=Xe(u),f.onblocked=se(t._fireOnBlocked),f.onupgradeneeded=se(c=>{if(s=f.transaction,e.autoSchema&&!t._options.allowEmptyDB){f.onerror=en,s.abort(),f.result.close();let w=r.deleteDatabase(d);w.onsuccess=w.onerror=se(()=>{u(new V.NoSuchDatabase(`Database ${d} doesnt exist`))})}else{s.onerror=Xe(u);var y=c.oldVersion>Math.pow(2,62)?0:c.oldVersion;a=y<1,t._novip.idbdb=f.result,td(t,y/10,s,u)}},u),f.onsuccess=se(()=>{s=null;let c=t._novip.idbdb=f.result,y=An(c.objectStoreNames);if(y.length>0)try{let w=c.transaction(Qf(y),"readonly");e.autoSchema?od(t,c,w):(wo(t,t._dbSchema,w),sd(t,w)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),yo(t,w)}catch{}Jr.push(t),c.onversionchange=se(w=>{e.vcFired=!0,t.on("versionchange").fire(w)}),c.onclose=se(w=>{t.on("close").fire(w)}),a&&cd(t._deps,d),l()},u)}))]).then(()=>(i(),e.onReadyBeingFired=[],M.resolve(Ao(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let u=e.onReadyBeingFired.reduce(Gi,ne);return e.onReadyBeingFired=[],M.resolve(Ao(()=>u(t.vip))).then(l)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(l=>{e.dbOpenError=l;try{s&&s.abort()}catch{}return n===e.openCanceller&&t._close(),ye(l)}).finally(()=>{e.openComplete=!0,o()})}function So(t){var e=s=>t.next(s),r=s=>t.throw(s),n=o(e),i=o(r);function o(s){return a=>{var l=s(a),u=l.value;return l.done?u:!u||typeof u.then!="function"?Te(u)?Promise.all(u).then(n,i):n(u):u.then(n,i)}}return o(e)()}function pd(t,e,r){var n=arguments.length;if(n<2)throw new V.InvalidArgument("Too few arguments");for(var i=new Array(n-1);--n;)i[n-1]=arguments[n];r=i.pop();var o=Ms(i);return[t,o,r]}function ya(t,e,r,n,i){return M.resolve().then(()=>{let o=K.transless||K,s=t._createTransaction(e,r,t._dbSchema,n),a={trans:s,transless:o};if(n)s.idbtrans=n.idbtrans;else try{s.create(),t._state.PR1398_maxLoop=3}catch(f){return f.name===Ui.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>ya(t,e,r,null,i))):ye(f)}let l=Hi(i);l&&dr();let u,d=M.follow(()=>{if(u=i.call(s,s),u)if(l){var f=ot.bind(null,null);u.then(f,f)}else typeof u.next=="function"&&typeof u.throw=="function"&&(u=So(u))},a);return(u&&typeof u.then=="function"?M.resolve(u).then(f=>s.active?f:ye(new V.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):d.then(()=>u)).then(f=>(n&&s._resolve(),s._completion.then(()=>f))).catch(f=>(s._reject(f),ye(f)))})}function Un(t,e,r){let n=Te(t)?t.slice():[t];for(let i=0;i0,p=Oe(ue({},w),{isVirtual:_,keyTail:y,keyLength:h,extractKey:go(c),unique:!_&&w.unique});if(b.push(p),p.isPrimaryKey||o.push(p),h>1){let m=h===2?c[0]:c.slice(0,h-1);s(m,y+1,w)}return b.sort((m,v)=>m.keyTail-v.keyTail),p}let a=s(n.primaryKey.keyPath,0,n.primaryKey);i[":id"]=[a];for(let c of n.indexes)s(c.keyPath,0,c);function l(c){let y=i[nn(c)];return y&&y[0]}function u(c,y){return{type:c.type===1?2:c.type,lower:Un(c.lower,c.lowerOpen?t.MAX_KEY:t.MIN_KEY,y),lowerOpen:!0,upper:Un(c.upper,c.upperOpen?t.MIN_KEY:t.MAX_KEY,y),upperOpen:!0}}function d(c){let y=c.query.index;return y.isVirtual?Oe(ue({},c),{query:{index:y,range:u(c.query.range,y.keyTail)}}):c}return Oe(ue({},r),{schema:Oe(ue({},n),{primaryKey:a,indexes:o,getIndexByKeyPath:l}),count(c){return r.count(d(c))},query(c){return r.query(d(c))},openCursor(c){let{keyTail:y,isVirtual:w,keyLength:x}=c.query.index;if(!w)return r.openCursor(c);function b(h){function _(m){m!=null?h.continue(Un(m,c.reverse?t.MAX_KEY:t.MIN_KEY,y)):c.unique?h.continue(h.key.slice(0,x).concat(c.reverse?t.MIN_KEY:t.MAX_KEY,y)):h.continue()}return Object.create(h,{continue:{value:_},continuePrimaryKey:{value(m,v){h.continuePrimaryKey(Un(m,t.MAX_KEY,y),v)}},primaryKey:{get(){return h.primaryKey}},key:{get(){let m=h.key;return x===1?m[0]:m.slice(0,x)}},value:{get(){return h.value}}})}return r.openCursor(d(c)).then(h=>h&&b(h))}})}})}var gd={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:md};function Fo(t,e,r,n){return r=r||{},n=n||"",he(t).forEach(i=>{if(!Ve(e,i))r[n+i]=void 0;else{var o=t[i],s=e[i];if(typeof o=="object"&&typeof s=="object"&&o&&s){let a=zi(o),l=zi(s);a!==l?r[n+i]=e[i]:a==="Object"?Fo(o,s,r,n+i+"."):o!==s&&(r[n+i]=e[i])}else o!==s&&(r[n+i]=e[i])}}),he(e).forEach(i=>{Ve(t,i)||(r[n+i]=e[i])}),r}function yd(t,e){return e.type==="delete"?e.keys:e.keys||e.values.map(t.extractKey)}var vd={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>Oe(ue({},t),{table(e){let r=t.table(e),{primaryKey:n}=r.schema;return Oe(ue({},r),{mutate(o){let s=K.trans,{deleting:a,creating:l,updating:u}=s.table(e).hook;switch(o.type){case"add":if(l.fire===ne)break;return s._promise("readwrite",()=>d(o),!0);case"put":if(l.fire===ne&&u.fire===ne)break;return s._promise("readwrite",()=>d(o),!0);case"delete":if(a.fire===ne)break;return s._promise("readwrite",()=>d(o),!0);case"deleteRange":if(a.fire===ne)break;return s._promise("readwrite",()=>f(o),!0)}return r.mutate(o);function d(y){let w=K.trans,x=y.keys||yd(n,y);if(!x)throw new Error("Keys missing");return y=y.type==="add"||y.type==="put"?Oe(ue({},y),{keys:x}):ue({},y),y.type!=="delete"&&(y.values=[...y.values]),y.keys&&(y.keys=[...y.keys]),_d(r,y,x).then(b=>{let h=x.map((_,p)=>{let m=b[p],v={onerror:null,onsuccess:null};if(y.type==="delete")a.fire.call(v,_,m,w);else if(y.type==="add"||m===void 0){let g=l.fire.call(v,_,y.values[p],w);_==null&&g!=null&&(_=g,y.keys[p]=_,n.outbound||Qe(y.values[p],n.keyPath,_))}else{let g=Fo(m,y.values[p]),j=u.fire.call(v,g,_,m,w);if(j){let C=y.values[p];Object.keys(j).forEach(S=>{Ve(C,S)?C[S]=j[S]:Qe(C,S,j[S])})}}return v});return r.mutate(y).then(({failures:_,results:p,numFailures:m,lastResult:v})=>{for(let g=0;g(h.forEach(p=>p.onerror&&p.onerror(_)),Promise.reject(_)))})}function f(y){return c(y.trans,y.range,1e4)}function c(y,w,x){return r.query({trans:y,values:!1,query:{index:n,range:w},limit:x}).then(({result:b})=>d({type:"delete",keys:b,trans:y}).then(h=>h.numFailures>0?Promise.reject(h.failures[0]):b.length({table:e=>{let r=t.table(e);return Oe(ue({},r),{getMany:n=>{if(!n.cache)return r.getMany(n);let i=va(n.keys,n.trans._cache,n.cache==="clone");return i?M.resolve(i):r.getMany(n).then(o=>(n.trans._cache={keys:n.keys,values:n.cache==="clone"?Hr(o):o},o))},mutate:n=>(n.type!=="add"&&(n.trans._cache=null),r.mutate(n))})}})};function Eo(t){return!("from"in t)}var at=function(t,e){if(this)Pe(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0});else{let r=new at;return t&&"d"in t&&Pe(r,t),r}};ar(at.prototype,{add(t){return Gn(this,t),this},addKey(t){return on(this,t,t),this},addKeys(t){return t.forEach(e=>on(this,e,e)),this},[Vi](){return Do(this)}});function on(t,e,r){let n=Me(e,r);if(isNaN(n))return;if(n>0)throw RangeError();if(Eo(t))return Pe(t,{from:e,to:r,d:1});let i=t.l,o=t.r;if(Me(r,t.from)<0)return i?on(i,e,r):t.l={from:e,to:r,d:1,l:null,r:null},_a(t);if(Me(e,t.to)>0)return o?on(o,e,r):t.r={from:e,to:r,d:1,l:null,r:null},_a(t);Me(e,t.from)<0&&(t.from=e,t.l=null,t.d=o?o.d+1:1),Me(r,t.to)>0&&(t.to=r,t.r=null,t.d=t.l?t.l.d+1:1);let s=!t.r;i&&!t.l&&Gn(t,i),o&&s&&Gn(t,o)}function Gn(t,e){function r(n,{from:i,to:o,l:s,r:a}){on(n,i,o),s&&r(n,s),a&&r(n,a)}Eo(e)||r(t,e)}function xd(t,e){let r=Do(e),n=r.next();if(n.done)return!1;let i=n.value,o=Do(t),s=o.next(i.from),a=s.value;for(;!n.done&&!s.done;){if(Me(a.from,i.to)<=0&&Me(a.to,i.from)>=0)return!0;Me(i.from,a.from)<0?i=(n=r.next(a.from)).value:a=(s=o.next(i.from)).value}return!1}function Do(t){let e=Eo(t)?null:{s:0,n:t};return{next(r){let n=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,n)for(;e.n.l&&Me(r,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!n||Me(r,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function _a(t){var e,r;let n=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((r=t.l)===null||r===void 0?void 0:r.d)||0),i=n>1?"r":n<-1?"l":"";if(i){let o=i==="r"?"l":"r",s=ue({},t),a=t[i];t.from=a.from,t.to=a.to,t[i]=a[i],s[i]=a[o],t[o]=s,s.d=ba(s)}t.d=ba(t)}function ba({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}var wd={stack:"dbcore",level:0,create:t=>{let e=t.schema.name,r=new at(t.MIN_KEY,t.MAX_KEY);return Oe(ue({},t),{table:n=>{let i=t.table(n),{schema:o}=i,{primaryKey:s}=o,{extractKey:a,outbound:l}=s,u=Oe(ue({},i),{mutate:c=>{let y=c.trans,w=y.mutatedParts||(y.mutatedParts={}),x=g=>{let j=`idb://${e}/${n}/${g}`;return w[j]||(w[j]=new at)},b=x(""),h=x(":dels"),{type:_}=c,[p,m]=c.type==="deleteRange"?[c.range]:c.type==="delete"?[c.keys]:c.values.length<50?[[],c.values]:[],v=c.trans._cache;return i.mutate(c).then(g=>{if(Te(p)){_!=="delete"&&(p=g.results),b.addKeys(p);let j=va(p,v);!j&&_!=="add"&&h.addKeys(p),(j||m)&&jd(x,o,j,m)}else if(p){let j={from:p.lower,to:p.upper};h.add(j),b.add(j)}else b.add(r),h.add(r),o.indexes.forEach(j=>x(j.name).add(r));return g})}}),d=({query:{index:c,range:y}})=>{var w,x;return[c,new at((w=y.lower)!==null&&w!==void 0?w:t.MIN_KEY,(x=y.upper)!==null&&x!==void 0?x:t.MAX_KEY)]},f={get:c=>[s,new at(c.key)],getMany:c=>[s,new at().addKeys(c.keys)],count:d,query:d,openCursor:d};return he(f).forEach(c=>{u[c]=function(y){let{subscr:w}=K;if(w){let x=m=>{let v=`idb://${e}/${n}/${m}`;return w[v]||(w[v]=new at)},b=x(""),h=x(":dels"),[_,p]=f[c](y);if(x(_.name||"").add(p),!_.isPrimaryKey)if(c==="count")h.add(r);else{let m=c==="query"&&l&&y.values&&i.query(Oe(ue({},y),{values:!1}));return i[c].apply(this,arguments).then(v=>{if(c==="query"){if(l&&y.values)return m.then(({result:j})=>(b.addKeys(j),v));let g=y.values?v.result.map(a):v.result;y.values?b.addKeys(g):h.addKeys(g)}else if(c==="openCursor"){let g=v,j=y.values;return g&&Object.create(g,{key:{get(){return h.addKey(g.primaryKey),g.key}},primaryKey:{get(){let C=g.primaryKey;return h.addKey(C),C}},value:{get(){return j&&b.addKey(g.primaryKey),g.value}}})}return v})}}return i[c].apply(this,arguments)}}),u}})}};function jd(t,e,r,n){function i(o){let s=t(o.name||"");function a(u){return u!=null?o.extractKey(u):null}let l=u=>o.multiEntry&&Te(u)?u.forEach(d=>s.addKey(d)):s.addKey(u);(r||n).forEach((u,d)=>{let f=r&&a(r[d]),c=n&&a(n[d]);Me(f,c)!==0&&(f!=null&&l(f),c!=null&&l(c))})}e.indexes.forEach(i)}var lt=class{constructor(e,r){this._middlewares={},this.verno=0;let n=lt.dependencies;this._options=r=ue({addons:lt.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange},r),this._deps={indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange};let{addons:i}=r;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;let o={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:ne,dbReadyPromise:null,cancelOpen:ne,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};o.dbReadyPromise=new M(s=>{o.dbReadyResolve=s}),o.openCanceller=new M((s,a)=>{o.cancelOpen=a}),this._state=o,this.name=e,this.on=Xr(this,"populate","blocked","versionchange","close",{ready:[Gi,ne]}),this.on.ready.subscribe=Is(this.on.ready.subscribe,s=>(a,l)=>{lt.vip(()=>{let u=this._state;if(u.openComplete)u.dbOpenError||M.resolve().then(a),l&&s(a);else if(u.onReadyBeingFired)u.onReadyBeingFired.push(a),l&&s(a);else{s(a);let d=this;l||s(function f(){d.on.ready.unsubscribe(a),d.on.ready.unsubscribe(f)})}})}),this.Collection=Kf(this),this.Table=Rf(this),this.Transaction=Gf(this),this.Version=ld(this),this.WhereClause=Uf(this),this.on("versionchange",s=>{s.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",s=>{!s.newVersion||s.newVersionnew this.Transaction(s,a,l,this._options.chromeTransactionDurability,u),this._fireOnBlocked=s=>{this.on("blocked").fire(s),Jr.filter(a=>a.name===this.name&&a!==this&&!a._state.vcFired).map(a=>a.on("versionchange").fire(s))},this.use(gd),this.use(vd),this.use(wd),this.use(bd),this.vip=Object.create(this,{_vip:{value:!0}}),i.forEach(s=>s(this))}version(e){if(isNaN(e)||e<.1)throw new V.Type("Given version is not a positive number");if(e=Math.round(e*10)/10,this.idbdb||this._state.isBeingOpened)throw new V.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let r=this._versions;var n=r.filter(i=>i._cfg.version===e)[0];return n||(n=new this.Version(e),r.push(n),r.sort(ed),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(e){return this.idbdb&&(this._state.openComplete||K.letThrough||this._vip)?e():new M((r,n)=>{if(this._state.openComplete)return n(new V.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen){n(new V.DatabaseClosed);return}this.open().catch(ne)}this._state.dbReadyPromise.then(r,n)}).then(e)}use({stack:e,create:r,level:n,name:i}){i&&this.unuse({stack:e,name:i});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:r,level:n??10,name:i}),o.sort((s,a)=>s.level-a.level),this}unuse({stack:e,name:r,create:n}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(i=>n?i.create!==n:r?i.name!==r:!1)),this}open(){return hd(this)}_close(){let e=this._state,r=Jr.indexOf(this);if(r>=0&&Jr.splice(r,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new M(n=>{e.dbReadyResolve=n}),e.openCanceller=new M((n,i)=>{e.cancelOpen=i})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new V.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,r=this._state;return new M((n,i)=>{let o=()=>{this.close();var s=this._deps.indexedDB.deleteDatabase(this.name);s.onsuccess=se(()=>{fd(this._deps,this.name),n()}),s.onerror=Xe(i),s.onblocked=this._fireOnBlocked};if(e)throw new V.InvalidArgument("Arguments not allowed in db.delete()");r.isBeingOpened?r.dbReadyPromise.then(o):o()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){let e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return he(this._allTables).map(e=>this._allTables[e])}transaction(){let e=pd.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,r,n){let i=K.trans;(!i||i.db!==this||e.indexOf("!")!==-1)&&(i=null);let o=e.indexOf("?")!==-1;e=e.replace("!","").replace("?","");let s,a;try{if(a=r.map(u=>{var d=u instanceof this.Table?u.name:u;if(typeof d!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return d}),e=="r"||e===lo)s=lo;else if(e=="rw"||e==uo)s=uo;else throw new V.InvalidArgument("Invalid transaction mode: "+e);if(i){if(i.mode===lo&&s===uo)if(o)i=null;else throw new V.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i&&a.forEach(u=>{if(i&&i.storeNames.indexOf(u)===-1)if(o)i=null;else throw new V.SubTransaction("Table "+u+" not included in parent transaction.")}),o&&i&&!i.active&&(i=null)}}catch(u){return i?i._promise(null,(d,f)=>{f(u)}):ye(u)}let l=ya.bind(null,this,s,a,i,n);return i?i._promise(s,l,"lock"):K.trans?hr(K.transless,()=>this._whenReady(l)):this._whenReady(l)}table(e){if(!Ve(this._allTables,e))throw new V.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}},Cd=typeof Symbol!="undefined"&&"observable"in Symbol?Symbol.observable:"@@observable",xa=class{constructor(e){this._subscribe=e}subscribe(e,r,n){return this._subscribe(!e||typeof e=="function"?{next:e,error:r,complete:n}:e)}[Cd](){return this}};function wa(t,e){return he(e).forEach(r=>{let n=t[r]||(t[r]=new at);Gn(n,e[r])}),t}function Ad(t){return new xa(e=>{let r=Hi(t);function n(y){r&&dr();let w=()=>yt(t,{subscr:y,trans:null}),x=K.trans?hr(K.transless,w):w();return r&&x.then(ot,ot),x}let i=!1,o={},s={},a={get closed(){return i},unsubscribe:()=>{i=!0,xt.storagemutated.unsubscribe(f)}};e.start&&e.start(a);let l=!1,u=!1;function d(){return he(s).some(y=>o[y]&&xd(o[y],s[y]))}let f=y=>{wa(o,y),d()&&c()},c=()=>{if(l||i)return;o={};let y={},w=n(y);u||(xt(tn,f),u=!0),l=!0,Promise.resolve(w).then(x=>{l=!1,!i&&(d()?c():(o={},s=y,e.next&&e.next(x)))},x=>{l=!1,e.error&&e.error(x),a.unsubscribe()})};return c(),a})}var To;try{To={indexedDB:ie.indexedDB||ie.mozIndexedDB||ie.webkitIndexedDB||ie.msIndexedDB,IDBKeyRange:ie.IDBKeyRange||ie.webkitIDBKeyRange}}catch{To={indexedDB:null,IDBKeyRange:null}}var Wt=lt;ar(Wt,Oe(ue({},Fn),{delete(t){return new Wt(t,{addons:[]}).delete()},exists(t){return new Wt(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1)},getDatabaseNames(t){try{return ud(Wt.dependencies).then(t)}catch{return ye(new V.MissingAPI)}},defineClass(){function t(e){Pe(this,e)}return t},ignoreTransaction(t){return K.trans?hr(K.transless,t):t()},vip:Ao,async:function(t){return function(){try{var e=So(t.apply(this,arguments));return!e||typeof e.then!="function"?M.resolve(e):e}catch(r){return ye(r)}}},spawn:function(t,e,r){try{var n=So(t.apply(r,e||[]));return!n||typeof n.then!="function"?M.resolve(n):n}catch(i){return ye(i)}},currentTransaction:{get:()=>K.trans||null},waitFor:function(t,e){let r=M.resolve(typeof t=="function"?Wt.ignoreTransaction(t):t).timeout(e||6e4);return K.trans?K.trans.waitFor(r):r},Promise:M,debug:{get:()=>Je,set:t=>{Ls(t,t==="dexie"?()=>!0:ra)}},derive:lr,extend:Pe,props:ar,override:Is,Events:Xr,on:xt,liveQuery:Ad,extendObservabilitySet:wa,getByKeyPath:nt,setByKeyPath:Qe,delByKeyPath:lf,shallowClone:Ps,deepClone:Hr,getObjectDiff:Fo,cmp:Me,asap:Os,minKey:ao,addons:[],connections:Jr,errnames:Ui,dependencies:To,semVer:ea,version:ea.split(".").map(t=>parseInt(t)).reduce((t,e,r)=>t+e/Math.pow(10,r*2))}));Wt.maxKey=rn(Wt.dependencies.IDBKeyRange);typeof dispatchEvent!="undefined"&&typeof addEventListener!="undefined"&&(xt(tn,t=>{if(!ut){let e;Nn?(e=document.createEvent("CustomEvent"),e.initCustomEvent(bt,!0,!0,t)):e=new CustomEvent(bt,{detail:t}),ut=!0,dispatchEvent(e),ut=!1}}),addEventListener(bt,({detail:t})=>{ut||Qn(t)}));function Qn(t){let e=ut;try{ut=!0,xt.storagemutated.fire(t)}finally{ut=e}}var ut=!1;if(typeof BroadcastChannel!="undefined"){let t=new BroadcastChannel(bt);xt(tn,e=>{ut||t.postMessage(e)}),t.onmessage=e=>{e.data&&Qn(e.data)}}else if(typeof self!="undefined"&&typeof navigator!="undefined"){xt(tn,e=>{try{ut||(typeof localStorage!="undefined"&&localStorage.setItem(bt,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(r=>r.postMessage({type:bt,changedParts:e})))}catch{}}),typeof addEventListener!="undefined"&&addEventListener("storage",e=>{if(e.key===bt){let r=JSON.parse(e.newValue);r&&Qn(r.changedParts)}});let t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",Sd)}function Sd({data:t}){t&&t.type===bt&&Qn(t.changedParts)}M.rejectionMapper=yf;Ls(Je,ra);var Ze=class extends lt{constructor(){super(Ze.dbName);this.version(Ze.dbVersion).stores({searchHistory:"++id",minisearch:"date"})}static async clearOldDatabases(){let e=(await indexedDB.databases()).filter(r=>r.name===Ze.dbName&&r.version!==Ze.dbVersion*10);if(e.length){console.log("Omnisearch - Those IndexedDb databases will be deleted:");for(let r of e)r.name&&indexedDB.deleteDatabase(r.name)}}static getInstance(){return Ze.instance||(Ze.instance=new Ze),Ze.instance}async clearCache(){await this.minisearch.clear()}},gr=Ze;gr.dbVersion=8,gr.dbName="omnisearch/cache/"+app.appId;var Be=gr.getInstance();var Ut=Cn(!1),sn='Needs a restart to fully take effect.',Io=class extends Y.PluginSettingTab{constructor(e){super(app,e);this.plugin=e,Ut.subscribe(async r=>{I.showExcerpt=r,await pe(this.plugin)})}display(){let{containerEl:e}=this;if(e.empty(),app.loadLocalStorage(an)=="1"){let f=e.createEl("span");f.innerHTML='\u26A0\uFE0F OMNISEARCH IS DISABLED \u26A0\uFE0F'}e.createEl("h2",{text:"Omnisearch"});let r=e.createDiv();r.innerHTML=` Buy Me a Coffee at ko-fi.com - `,new G.Setting(e).setName("Indexing").setHeading();let n=new DocumentFragment;$e()?n.createSpan({},c=>{c.innerHTML=`\u{1F44D} You have installed Text Extractor, Omnisearch will use it to index PDFs and images. -
Text extraction only works on desktop, but the cache can be synchronized with your mobile device.`}):n.createSpan({},c=>{c.innerHTML='\u26A0\uFE0F Omnisearch requires Text Extractor to index PDFs and images.'}),new G.Setting(e).setDesc(n);let i=new DocumentFragment;i.createSpan({},c=>{c.innerHTML="Include PDFs in search results"}),new G.Setting(e).setName(`PDFs Indexing ${$e()?"":"\u26A0\uFE0F Disabled"}`).setDesc(i).addToggle(c=>c.setValue(E.PDFIndexing).onChange(async d=>{E.PDFIndexing=d,await ue(this.plugin)})).setDisabled(!$e());let s=new DocumentFragment;s.createSpan({},c=>{c.innerHTML="Include images in search results"}),new G.Setting(e).setName(`Images Indexing ${$e()?"":"\u26A0\uFE0F Disabled"}`).setDesc(s).addToggle(c=>c.setValue(E.imagesIndexing).onChange(async d=>{E.imagesIndexing=d,await ue(this.plugin)})).setDisabled(!$e());let o=new DocumentFragment;o.createSpan({},c=>{c.innerHTML=`In addition to standard md files, Omnisearch can also index other plaintext files.
+ `,new Y.Setting(e).setName("Indexing").setHeading();let n=new DocumentFragment;et()?n.createSpan({},f=>{f.innerHTML=`\u{1F44D} You have installed Text Extractor, Omnisearch will use it to index PDFs and images. +
Text extraction only works on desktop, but the cache can be synchronized with your mobile device.`}):n.createSpan({},f=>{f.innerHTML='\u26A0\uFE0F Omnisearch requires Text Extractor to index PDFs and images.'}),new Y.Setting(e).setDesc(n);let i=new DocumentFragment;i.createSpan({},f=>{f.innerHTML="Include PDFs in search results"}),new Y.Setting(e).setName(`PDFs Indexing ${et()?"":"\u26A0\uFE0F Disabled"}`).setDesc(i).addToggle(f=>f.setValue(I.PDFIndexing).onChange(async c=>{I.PDFIndexing=c,await pe(this.plugin)})).setDisabled(!et());let o=new DocumentFragment;o.createSpan({},f=>{f.innerHTML="Include images in search results"}),new Y.Setting(e).setName(`Images Indexing ${et()?"":"\u26A0\uFE0F Disabled"}`).setDesc(o).addToggle(f=>f.setValue(I.imagesIndexing).onChange(async c=>{I.imagesIndexing=c,await pe(this.plugin)})).setDisabled(!et());let s=new DocumentFragment;s.createSpan({},f=>{f.innerHTML=`In addition to standard md files, Omnisearch can also index other plaintext files.
Add extensions separated by a space, without the dot. Example: "txt org".
\u26A0\uFE0F Using extensions of non-plaintext files (like .docx or .pptx) WILL cause crashes, because Omnisearch will try to index their content.
- Needs a restart to fully take effect.`}),new G.Setting(e).setName("Additional files to index").setDesc(o).addText(c=>{c.setValue(E.indexedFileTypes.join(" ")).setPlaceholder("Example: txt org").onChange(async d=>{E.indexedFileTypes=d.split(" "),await ue(this.plugin)})}),new G.Setting(e).setName("Behavior").setHeading(),new G.Setting(e).setName("Save index to cache").setDesc("Enable caching to speed up indexing time. In rare cases, the cache write may cause a freeze in Obsidian. This option will disable itself if it happens.").addToggle(c=>c.setValue(E.useCache).onChange(async d=>{E.useCache=d,await ue(this.plugin)})),new G.Setting(e).setName(`Respect Obsidian's "Excluded Files"`).setDesc(`By default, files that are in Obsidian's "Options > Files & Links > Excluded Files" list are downranked in results. - Enable this option to completely hide them`).addToggle(c=>c.setValue(E.hideExcluded).onChange(async d=>{E.hideExcluded=d,await ue(this.plugin)}));let a=new DocumentFragment;a.createSpan({},c=>{c.innerHTML=`Normalize diacritics in search terms. Words like "br\xFBl\xE9e" or "\u017Elu\u0165ou\u010Dk\xFD" will be indexed as "brulee" and "zlutoucky".
+ ${sn}`}),new Y.Setting(e).setName("Additional files to index").setDesc(s).addText(f=>{f.setValue(I.indexedFileTypes.join(" ")).setPlaceholder("Example: txt org").onChange(async c=>{I.indexedFileTypes=c.split(" "),await pe(this.plugin)})}),new Y.Setting(e).setName("Behavior").setHeading(),new Y.Setting(e).setName("Save index to cache").setDesc("Enable caching to speed up indexing time. In rare cases, the cache write may cause a freeze in Obsidian. This option will disable itself if it happens.").addToggle(f=>f.setValue(I.useCache).onChange(async c=>{I.useCache=c,await pe(this.plugin)})),new Y.Setting(e).setName(`Respect Obsidian's "Excluded Files"`).setDesc(`By default, files that are in Obsidian's "Options > Files & Links > Excluded Files" list are downranked in results. + Enable this option to completely hide them`).addToggle(f=>f.setValue(I.hideExcluded).onChange(async c=>{I.hideExcluded=c,await pe(this.plugin)}));let a=new DocumentFragment;a.createSpan({},f=>{f.innerHTML=`Normalize diacritics in search terms. Words like "br\xFBl\xE9e" or "\u017Elu\u0165ou\u010Dk\xFD" will be indexed as "brulee" and "zlutoucky".
\u26A0\uFE0F You probably should NOT disable this.
\u26A0\uFE0F Changing this setting will clear the cache.
- Needs a restart to fully take effect. - `}),new G.Setting(e).setName("Ignore diacritics").setDesc(a).addToggle(c=>c.setValue(E.ignoreDiacritics).onChange(async d=>{await Ee.clearCache(),E.ignoreDiacritics=d,await ue(this.plugin)}));let l=new DocumentFragment;l.createSpan({},c=>{c.innerHTML=`Enable this if you want to be able to search for CamelCaseWords as separate words.
+ ${sn} + `}),new Y.Setting(e).setName("Ignore diacritics").setDesc(a).addToggle(f=>f.setValue(I.ignoreDiacritics).onChange(async c=>{await Be.clearCache(),I.ignoreDiacritics=c,await pe(this.plugin)}));let l=new DocumentFragment;l.createSpan({},f=>{f.innerHTML=`Enable this if you want to be able to search for CamelCaseWords as separate words.
\u26A0\uFE0F Changing this setting will clear the cache.
- Needs a restart to fully take effect. - `}),new G.Setting(e).setName("Split CamelCaseWords").setDesc(l).addToggle(c=>c.setValue(E.splitCamelCase).onChange(async d=>{await Ee.clearCache(),E.splitCamelCase=d,await ue(this.plugin)})),new G.Setting(e).setName("Simpler search").setDesc(`Enable this if Obsidian often freezes while making searches. - Words shorter than 3 characters won't be used as prefixes; this can reduce search delay but will return fewer results.`).addToggle(c=>c.setValue(E.simpleSearch).onChange(async d=>{E.simpleSearch=d,await ue(this.plugin)})),new G.Setting(e).setName("User Interface").setHeading(),new G.Setting(e).setName("Show ribbon button").setDesc("Add a button on the sidebar to open the Vault search modal.").addToggle(c=>c.setValue(E.ribbonIcon).onChange(async d=>{E.ribbonIcon=d,await ue(this.plugin),d?this.plugin.addRibbonButton():this.plugin.removeRibbonButton()})),new G.Setting(e).setName("Show excerpts").setDesc("Shows the contextual part of the note that matches the search. Disable this to only show filenames in results.").addToggle(c=>c.setValue(E.showExcerpt).onChange(async d=>{Lt.set(d)})),new G.Setting(e).setName("Render line return in excerpts").setDesc("Activate this option to render line returns in result excerpts.").addToggle(c=>c.setValue(E.renderLineReturnInExcerpts).onChange(async d=>{E.renderLineReturnInExcerpts=d,await ue(this.plugin)})),new G.Setting(e).setName("Show previous query results").setDesc("Re-executes the previous query when opening Omnisearch.").addToggle(c=>c.setValue(E.showPreviousQueryResults).onChange(async d=>{E.showPreviousQueryResults=d,await ue(this.plugin)}));let u=new DocumentFragment;if(u.createSpan({},c=>{c.innerHTML=`Shows a button next to the search input, to create a note. - Acts the same as the shift \u21B5 shortcut, can be useful for mobile device users.`}),new G.Setting(e).setName('Show "Create note" button').setDesc(u).addToggle(c=>c.setValue(E.showCreateButton).onChange(async d=>{E.showCreateButton=d,await ue(this.plugin)})),new G.Setting(e).setName("Highlight matching words in results").setDesc("Will highlight matching results when enabled. See README for more customization options.").addToggle(c=>c.setValue(E.highlight).onChange(async d=>{E.highlight=d,await ue(this.plugin)})),new G.Setting(e).setName("Results weighting").setHeading(),new G.Setting(e).setName(`File name & declared aliases (default: ${Nt.weightBasename})`).addSlider(c=>this.weightSlider(c,"weightBasename")),new G.Setting(e).setName(`File directory (default: ${Nt.weightDirectory})`).addSlider(c=>this.weightSlider(c,"weightDirectory")),new G.Setting(e).setName(`Headings level 1 (default: ${Nt.weightH1})`).addSlider(c=>this.weightSlider(c,"weightH1")),new G.Setting(e).setName(`Headings level 2 (default: ${Nt.weightH2})`).addSlider(c=>this.weightSlider(c,"weightH2")),new G.Setting(e).setName(`Headings level 3 (default: ${Nt.weightH3})`).addSlider(c=>this.weightSlider(c,"weightH3")),new G.Setting(e).setName("Debugging").setHeading(),new G.Setting(e).setName("Enable verbose logging").setDesc("Adds a LOT of logs for debugging purposes. Don't forget to disable it.").addToggle(c=>c.setValue(E.verboseLogging).onChange(async d=>{E.verboseLogging=d,await ue(this.plugin)})),ht()){new G.Setting(e).setName("Danger Zone").setHeading();let c=new DocumentFragment;c.createSpan({},d=>{d.innerHTML=`Erase all Omnisearch cache data. - Use this if Omnisearch results are inconsistent, missing, or appear outdated.
- Needs a restart to fully take effect.`}),new G.Setting(e).setName("Clear cache data").setDesc(c).addButton(d=>{d.setButtonText("Clear cache"),d.onClick(async()=>{await Ee.clearCache(),new G.Notice("Omnisearch - Cache cleared. Please restart Obsidian.")})})}}weightSlider(e,r){e.setLimits(1,5,.1).setValue(E[r]).setDynamicTooltip().onChange(n=>{E[r]=n,ue(this.plugin)})}},Nt={useCache:!0,hideExcluded:!1,ignoreDiacritics:!0,indexedFileTypes:[],PDFIndexing:!1,imagesIndexing:!1,splitCamelCase:!1,ribbonIcon:!0,showExcerpt:!0,renderLineReturnInExcerpts:!0,showCreateButton:!1,highlight:!0,showPreviousQueryResults:!0,simpleSearch:!1,weightBasename:3,weightDirectory:2,weightH1:1.5,weightH2:1.3,weightH3:1.1,welcomeMessage:"",verboseLogging:!1},E=Object.assign({},Nt);async function ca(t){E=Object.assign({},Nt,await t.loadData()),Lt.set(E.showExcerpt)}async function ue(t){await t.saveData(E)}var fa=be(require("obsidian"));var da=/[\u4e00-\u9fa5]/;var ha=100,Jr=300,pa=`suggestion-highlight omnisearch-highlight ${E.highlight?"omnisearch-default-highlight":""}`,H=new Si,Ln={ToggleExcerpts:"toggle-excerpts"},Pe=(s=>(s[s.Done=0]="Done",s[s.LoadingCache=1]="LoadingCache",s[s.ReadingFiles=2]="ReadingFiles",s[s.IndexingFiles=3]="IndexingFiles",s[s.WritingCache=4]="WritingCache",s))(Pe||{});var pt=hn(0),ma=!1;function xs(t){ma=t}function ga(){return ma}function Nn(){return app.plugins.plugins["cm-chs-patch"]}function $e(){return app.plugins?.plugins?.["text-extractor"]?.api}function ht(){return!fa.Platform.isIosApp&&E.useCache}var mt=/[|\n\r -#%-*,-/:;?@[-\]_{}\u00A0\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u1680\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2000-\u200A\u2010-\u2029\u202F-\u2043\u2045-\u2051\u2053-\u205F\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u3000-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]+/u;var Ea=be(require("obsidian"));var Ze=be(require("obsidian"));var va=be(require("crypto")),_a=be(ya());function gt(...t){return t[1]!==null&&t[1]!==void 0&&t[2]!==null&&t[2]!==void 0?`${t[1]}${t[2]}`:"<no content>"}function hd(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function xa(t){let e=t.split("/");return e.pop(),e.join("/")}function pd(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"[$&]")}function yt(t){if(!t.length)return/^$/g;let e="("+(Nn()?"":E.splitCamelCase?`^|${mt.source}|[A-Z]`:`^|${mt.source}`)+`)(${t.map(n=>pd(n)).join("|")})`;return new RegExp(`${e}`,"giu")}function Kn(t,e){return t.headings?.filter(r=>r.level===e).map(r=>r.heading)??[]}function zn(t,e){return(t+e)%e}function ur(t,e){try{let r=e??-1,n=Math.max(0,r-ha),i=Math.min(t.length,r+Jr);if(r>-1?t=(n>0?"\u2026":"")+t.slice(n,i).trim()+(ia).join(` -`);let o=t.lastIndexOf(` -`,r-n);o>0&&(t=t.slice(o))}return t=hd(t),E.renderLineReturnInExcerpts&&(t=t.trim().replaceAll(` -`,"
")),t}catch(r){return new Ze.Notice("Omnisearch - Error while creating excerpt, see developer console"),console.error("Omnisearch - Error while creating excerpt"),console.error(r),""}}function ws(t){return t.replace(/(\*|_)+(.+?)(\*|_)+/g,(e,r,n)=>n)}function ba(t){return t?.frontmatter?(0,Ze.parseFrontMatterAliases)(t.frontmatter)??[]:[]}function wa(t){let e=t?(0,Ze.getAllTags)(t)??[]:[];return e=[...new Set(e.reduce((r,n)=>[...r,...n.split("/").filter(i=>i).map(i=>i.startsWith("#")?i:`#${i}`),n],[]))],e}function et(t){return t==null?"":(t=t.replaceAll("`","[__omnisearch__backtick__]"),t=t.normalize("NFD").replace(/\p{Diacritic}/gu,""),t=t.replaceAll("[__omnisearch__backtick__]","`"),t)}function Vn(){return Ze.Platform.isMacOS?"\u2318":"ctrl"}function Zr(t){let e=!!$e(),r=e&&E.PDFIndexing,n=e&&E.imagesIndexing;return js(t)||tn(t)||r&&en(t)||n&&$n(t)}function $n(t){let e=Kt(t);return e==="png"||e==="jpg"||e==="jpeg"}function en(t){return Kt(t)==="pdf"}function js(t){return[...E.indexedFileTypes,"md"].some(e=>t.endsWith(`.${e}`))}function tn(t){return t.endsWith(".canvas")}function Kt(t){let e=t.split(".");return e[e.length-1]??""}function ja(t){return Ze.Platform.isMobileApp?(0,_a.md5)(t.toString()):(0,va.createHash)("md5").update(t).digest("hex")}function Aa(t,e){let r=[],n=0,i=t.length;for(;ns.path===t);if(!e)throw new Error(`Invalid file path: "${t}"`);let r=null,n=$e();if(js(t))r=await app.vault.cachedRead(e);else if(tn(t)){let s=JSON.parse(await app.vault.cachedRead(e)),o=[];for(let a of s.nodes)a.type==="text"?o.push(a.text):a.type==="file"&&o.push(a.file);for(let a of s.edges.filter(l=>!!l.label))o.push(a.label);r=o.join(`\r -`)}else if(n?.canFileBeExtracted(t))r=await n.extractText(e);else throw new Error(`Unsupported file type: "${t}"`);r==null&&(console.warn(`Omnisearch: ${r} content for file`,e.path),r=""),r=et(r);let i=app.metadataCache.getFileCache(e);if(i&&i.frontmatter?.["excalidraw-plugin"]){let s=i.sections?.filter(o=>o.type==="comment")??[];for(let{start:o,end:a}of s.map(l=>l.position))r=r.substring(0,o.offset-1)+r.substring(a.offset)}return{basename:et(e.basename),content:r,path:e.path,mtime:e.stat.mtime,tags:wa(i),aliases:ba(i).join(""),headings1:i?Kn(i,1).join(" "):"",headings2:i?Kn(i,2).join(" "):"",headings3:i?Kn(i,3).join(" "):""}}var Da=class{constructor(){this.nextQueryIsEmpty=!1;this.documents=new Map}async addToLiveCache(e){try{let r=await md(e);if(!r.path){console.error(`Missing .path field in IndexedDocument "${r.basename}", skipping`);return}this.documents.set(e,r)}catch(r){console.warn(`Omnisearch: Error while adding "${e}" to live cache`,r),this.removeFromLiveCache(e)}}removeFromLiveCache(e){this.documents.delete(e)}async getDocument(e){return this.documents.has(e)?this.documents.get(e):(ie("Generating IndexedDocument from",e),await this.addToLiveCache(e),this.documents.get(e))}async addToSearchHistory(e){if(!e){this.nextQueryIsEmpty=!0;return}this.nextQueryIsEmpty=!1;let r=await Ee.searchHistory.toArray();r=r.filter(n=>n.query!==e).reverse(),r.unshift({query:e}),r=r.slice(0,10),await Ee.searchHistory.clear(),await Ee.searchHistory.bulkAdd(r)}async getSearchHistory(){let e=(await Ee.searchHistory.toArray()).reverse().map(r=>r.query);return this.nextQueryIsEmpty&&e.unshift(""),e}getDocumentsChecksum(e){return ja(JSON.stringify(e.sort((r,n)=>r.pathn.path?1:0)))}async getMinisearchCache(){try{return(await Ee.minisearch.toArray())[0]}catch(e){return new Ea.Notice("Omnisearch - Cache missing or invalid. Some freezes may occur while Omnisearch indexes your vault."),console.error("Omnisearch - Error while loading Minisearch cache"),console.error(e),null}}async writeMinisearchCache(e,r){let n=Array.from(r).map(([i,s])=>({path:i,mtime:s}));await Ee.minisearch.clear(),await Ee.minisearch.add({date:new Date().toISOString(),paths:n,data:e.toJSON()}),console.log("Omnisearch - Search cache written")}},de=new Da;function gd(t){let e,r,n,i,s,o,a,l,u=t[9].default,c=Gt(u,t,t[8],null);return{c(){e=O("div"),r=O("div"),n=O("input"),s=U(),c&&c.c(),B(n,"class","prompt-input"),B(n,"placeholder",t[0]),B(n,"spellcheck","false"),B(n,"type","text"),B(r,"class","omnisearch-input-field"),B(e,"class","omnisearch-input-container")},m(d,f){z(d,e,f),k(e,r),k(r,n),t[10](n),xi(n,t[1]),k(e,s),c&&c.m(e,null),o=!0,a||(l=[Te(n,"input",t[11]),co(i=t[3].call(null,n)),Te(n,"compositionend",t[12]),Te(n,"compositionstart",t[13]),Te(n,"input",t[4])],a=!0)},p(d,[f]){(!o||f&1)&&B(n,"placeholder",d[0]),f&2&&n.value!==d[1]&&xi(n,d[1]),c&&c.p&&(!o||f&256)&&qt(c,u,d,d[8],o?Qt(u,d[8],f,null):Yt(d[8]),null)},i(d){o||(Q(c,d),o=!0)},o(d){q(c,d),o=!1},d(d){d&&K(e),t[10](null),c&&c.d(d),a=!1,Re(l)}}}function yd(t,e,r){let{$$slots:n={},$$scope:i}=e,{initialValue:s=""}=e,o=!1,{placeholder:a=""}=e,l="",u,c=ji();function d(v){r(1,l=v)}function f(v){ot().then(()=>(u.focus(),ot())).then(()=>{u.select()})}let y=(0,Ta.debounce)(()=>{de.addToSearchHistory(""),c("input",l)},250);function w(v){He[v?"unshift":"push"](()=>{u=v,r(2,u)})}function b(){l=this.value,r(1,l),r(5,s),r(7,o)}let x=v=>xs(!1),h=v=>xs(!0);return t.$$set=v=>{"initialValue"in v&&r(5,s=v.initialValue),"placeholder"in v&&r(0,a=v.placeholder),"$$scope"in v&&r(8,i=v.$$scope)},t.$$.update=()=>{if(t.$$.dirty&162){e:s&&!o&&!l&&(r(7,o=!0),r(1,l=s),f())}},[a,l,u,f,y,s,d,o,i,n,w,b,x,h]}var ka=class extends pe{constructor(e){super();ye(this,e,yd,gd,fe,{initialValue:5,placeholder:0,setInputValue:6})}get setInputValue(){return this.$$.ctx[6]}},Hn=ka;function vd(t){let e,r,n,i,s=t[1].default,o=Gt(s,t,t[0],null);return{c(){e=O("div"),o&&o.c(),B(e,"class","prompt-results")},m(a,l){z(a,e,l),o&&o.m(e,null),r=!0,n||(i=Te(e,"mousedown",_d),n=!0)},p(a,[l]){o&&o.p&&(!r||l&1)&&qt(o,s,a,a[0],r?Qt(s,a[0],l,null):Yt(a[0]),null)},i(a){r||(Q(o,a),r=!0)},o(a){q(o,a),r=!1},d(a){a&&K(e),o&&o.d(a),n=!1,i()}}}var _d=t=>t.preventDefault();function xd(t,e,r){let{$$slots:n={},$$scope:i}=e;return t.$$set=s=>{"$$scope"in s&&r(0,i=s.$$scope)},[i,n]}var Ia=class extends pe{constructor(e){super();ye(this,e,xd,vd,fe,{})}},Wn=Ia;var As=be(require("obsidian"));async function Un(t,e=!1){let r=yt(t.foundWords);r.exec(t.content);let n=r.lastIndex,i=!1;app.workspace.iterateAllLeaves(a=>{a.view instanceof As.MarkdownView&&!e&&a.getViewState().state?.file===t.path&&a.getViewState()?.pinned&&(app.workspace.setActiveLeaf(a,{focus:!0}),i=!0)}),i||await app.workspace.openLinkText(t.path,"",e);let s=app.workspace.getActiveViewOfType(As.MarkdownView);if(!s)return;let o=s.editor.offsetToPos(n);o.ch=0,s.editor.setCursor(o),s.editor.scrollIntoView({from:{line:o.line-10,ch:0},to:{line:o.line+10,ch:0}})}async function Oa(t,e=!1){try{let r;switch(app.vault.getConfig("newFileLocation")){case"current":r=(app.workspace.getActiveFile()?.parent.path??"")+"/";break;case"folder":r=app.vault.getConfig("newFileFolderPath")+"/";break;default:r="";break}await app.workspace.openLinkText(`${r}${t}.md`,"",e)}catch(r){throw r.message="OmniSearch - Could not create note: "+r.message,console.error(r),r}}function bd(t){let e;return{c(){e=O("span"),e.innerHTML='',B(e,"class","suggestion-flair"),B(e,"aria-label","Not created yet, select to create")},m(r,n){z(r,e,n)},p:ne,i:ne,o:ne,d(r){r&&K(e)}}}function wd(t){"use strict";return[]}var Ma=class extends pe{constructor(e){super();ye(this,e,wd,bd,fe,{})}},Pa=Ma;function Ra(t){let e,r;return e=new Pa({}),{c(){Se(e.$$.fragment)},m(n,i){we(e,n,i),r=!0},i(n){r||(Q(e.$$.fragment,n),r=!0)},o(n){q(e.$$.fragment,n),r=!1},d(n){ge(e,n)}}}function jd(t){let e,r,n,i,s,o=t[2]&&Ra(t),a=t[4].default,l=Gt(a,t,t[3],null);return{c(){e=O("div"),o&&o.c(),r=U(),l&&l.c(),B(e,"data-result-id",t[0]),B(e,"class","suggestion-item omnisearch-result"),bi(e,"is-selected",t[1])},m(u,c){z(u,e,c),o&&o.m(e,null),k(e,r),l&&l.m(e,null),n=!0,i||(s=[Te(e,"mousemove",t[5]),Te(e,"click",t[6]),Te(e,"auxclick",t[7])],i=!0)},p(u,[c]){u[2]?o?c&4&&Q(o,1):(o=Ra(u),o.c(),Q(o,1),o.m(e,r)):o&&(Dt(),q(o,1,1,()=>{o=null}),Tt()),l&&l.p&&(!n||c&8)&&qt(l,a,u,u[3],n?Qt(a,u[3],c,null):Yt(u[3]),null),(!n||c&1)&&B(e,"data-result-id",u[0]),(!n||c&2)&&bi(e,"is-selected",u[1])},i(u){n||(Q(o),Q(l,u),n=!0)},o(u){q(o),q(l,u),n=!1},d(u){u&&K(e),o&&o.d(),l&&l.d(u),i=!1,Re(s)}}}function Ad(t,e,r){let{$$slots:n={},$$scope:i}=e,{id:s}=e,{selected:o=!1}=e,{glyph:a=!1}=e;function l(d){Me.call(this,t,d)}function u(d){Me.call(this,t,d)}function c(d){Me.call(this,t,d)}return t.$$set=d=>{"id"in d&&r(0,s=d.id),"selected"in d&&r(1,o=d.selected),"glyph"in d&&r(2,a=d.glyph),"$$scope"in d&&r(3,i=d.$$scope)},[s,o,a,i,n,l,u,c]}var Ba=class extends pe{constructor(e){super();ye(this,e,Ad,jd,fe,{id:0,selected:1,glyph:2})}},Gn=Ba;var cr=be(require("obsidian"));function La(t){let e,r=t[1].matches.length+"",n,i,s=(t[1].matches.length>1?"matches":"match")+"",o;return{c(){e=O("span"),n=Fe(r),i=Fe("\xA0"),o=Fe(s),B(e,"class","omnisearch-result__counter")},m(a,l){z(a,e,l),k(e,n),k(e,i),k(e,o)},p(a,l){l&2&&r!==(r=a[1].matches.length+"")&&St(n,r),l&2&&s!==(s=(a[1].matches.length>1?"matches":"match")+"")&&St(o,s)},d(a){a&&K(e)}}}function Na(t){let e,r,n,i,s;return{c(){e=O("div"),r=O("span"),n=U(),i=O("span"),s=Fe(t[6]),B(e,"class","omnisearch-result__folder-path")},m(o,a){z(o,e,a),k(e,r),t[12](r),k(e,n),k(e,i),k(i,s)},p(o,a){a&64&&St(s,o[6])},d(o){o&&K(e),t[12](null)}}}function Ka(t){let e,r=t[8].replace(t[9],gt)+"";return{c(){e=O("div"),B(e,"class","omnisearch-result__body")},m(n,i){z(n,e,i),e.innerHTML=r},p(n,i){i&768&&r!==(r=n[8].replace(n[9],gt)+"")&&(e.innerHTML=r)},d(n){n&&K(e)}}}function za(t){let e,r,n;return{c(){e=O("div"),r=O("img"),ke(r,"width","100px"),_i(r.src,n=t[5])||B(r,"src",n),B(r,"alt",""),B(e,"class","omnisearch-result__image-container")},m(i,s){z(i,e,s),k(e,r)},p(i,s){s&32&&!_i(r.src,n=i[5])&&B(r,"src",n)},d(i){i&&K(e)}}}function Cd(t){let e,r,n,i,s,o,a=t[2].replace(t[9],gt)+"",l,u,c,d=Kt(t[1].path)+"",f,y,w,b,x,h,v=t[1].matches.length>0&&La(t),p=t[6]&&Na(t),m=t[10]&&Ka(t),_=t[5]&&za(t);return{c(){e=O("div"),r=O("div"),n=O("span"),i=O("span"),s=U(),o=O("span"),l=U(),u=O("span"),c=Fe("."),f=Fe(d),y=U(),v&&v.c(),w=U(),p&&p.c(),b=U(),x=O("div"),m&&m.c(),h=U(),_&&_.c(),B(u,"class","omnisearch-result__extension"),B(n,"class","omnisearch-result__title"),B(r,"class","omnisearch-result__title-container"),ke(x,"display","flex"),ke(x,"flex-direction","row")},m(g,j){z(g,e,j),k(e,r),k(r,n),k(n,i),t[11](i),k(n,s),k(n,o),o.innerHTML=a,k(n,l),k(n,u),k(u,c),k(u,f),k(n,y),v&&v.m(n,null),k(e,w),p&&p.m(e,null),k(e,b),k(e,x),m&&m.m(x,null),k(x,h),_&&_.m(x,null)},p(g,j){j&516&&a!==(a=g[2].replace(g[9],gt)+"")&&(o.innerHTML=a),j&2&&d!==(d=Kt(g[1].path)+"")&&St(f,d),g[1].matches.length>0?v?v.p(g,j):(v=La(g),v.c(),v.m(n,null)):v&&(v.d(1),v=null),g[6]?p?p.p(g,j):(p=Na(g),p.c(),p.m(e,b)):p&&(p.d(1),p=null),g[10]?m?m.p(g,j):(m=Ka(g),m.c(),m.m(x,h)):m&&(m.d(1),m=null),g[5]?_?_.p(g,j):(_=za(g),_.c(),_.m(x,null)):_&&(_.d(1),_=null)},d(g){g&&K(e),t[11](null),v&&v.d(),p&&p.d(),m&&m.d(),_&&_.d()}}}function Fd(t){let e,r;return e=new Gn({props:{glyph:t[7],id:t[1].path,selected:t[0],$$slots:{default:[Cd]},$$scope:{ctx:t}}}),e.$on("click",t[13]),e.$on("auxclick",t[14]),e.$on("mousemove",t[15]),{c(){Se(e.$$.fragment)},m(n,i){we(e,n,i),r=!0},p(n,[i]){let s={};i&128&&(s.glyph=n[7]),i&2&&(s.id=n[1].path),i&1&&(s.selected=n[0]),i&67454&&(s.$$scope={dirty:i,ctx:n}),e.$set(s)},i(n){r||(Q(e.$$.fragment,n),r=!0)},o(n){q(e.$$.fragment,n),r=!1},d(n){ge(e,n)}}}function Sd(t,e,r){let n,i,s,o;ln(t,Lt,p=>r(10,o=p));let{selected:a=!1}=e,{note:l}=e,u=null,c="",d="",f,y;function w(p){He[p?"unshift":"push"](()=>{y=p,r(4,y)})}function b(p){He[p?"unshift":"push"](()=>{f=p,r(3,f)})}function x(p){Me.call(this,t,p)}function h(p){Me.call(this,t,p)}function v(p){Me.call(this,t,p)}t.$$set=p=>{"selected"in p&&r(0,a=p.selected),"note"in p&&r(1,l=p.note)},t.$$.update=()=>{if(t.$$.dirty&2){e:if(r(5,u=null),$n(l.path)){let p=app.vault.getFiles().find(m=>m.path===l.path);p&&r(5,u=app.vault.getResourcePath(p))}}if(t.$$.dirty&2){e:r(9,n=yt(l.foundWords))}if(t.$$.dirty&2){e:r(8,i=ur(l.content,l.matches[0]?.offset??-1))}if(t.$$.dirty&30){e:r(2,c=l.basename),r(6,d=xa(l.path)),E.ignoreDiacritics&&r(2,c=et(c)),f&&(0,cr.setIcon)(f,"folder-open"),y&&($n(l.path)?(0,cr.setIcon)(y,"image"):en(l.path)?(0,cr.setIcon)(y,"file-text"):tn(l.path)?(0,cr.setIcon)(y,"layout-dashboard"):(0,cr.setIcon)(y,"file"))}};e:r(7,s=!1);return[a,l,c,f,y,u,d,s,i,n,o,w,b,x,h,v]}var Va=class extends pe{constructor(e){super();ye(this,e,Sd,Fd,fe,{selected:0,note:1})}},$a=Va;var Ga=be(Ua()),Cs=["ext","path"],zt=class{constructor(e=""){this.extensions=[];E.ignoreDiacritics&&(e=et(e));let r=(0,Ga.parse)(e.toLowerCase(),{tokenize:!0,keywords:Cs});r.text=r.text??[],r.exclude=r.exclude??{},r.exclude.text=r.exclude.text??[],Array.isArray(r.exclude.text)||(r.exclude.text=[r.exclude.text]);for(let n of Cs){let i=r[n];i&&(r[n]=Array.isArray(i)?i:[i]);let s=r.exclude[n];s&&(r.exclude[n]=Array.isArray(s)?s:[s])}this.query=r,this.extensions=this.query.ext??[]}isEmpty(){for(let e of Cs)if(this.query[e]?.length||this.query.text.length)return!1;return!0}segmentsToStr(){return this.query.text.join(" ")}getTags(){return this.query.text.filter(e=>e.startsWith("#"))}getTagsWithoutHashtag(){return this.getTags().map(e=>e.replace(/^#/,""))}getExactTerms(){return this.query.text.filter(e=>e.split(" ").length>1)}};var ee=function(){return ee=Object.assign||function(e){for(var r,n=1,i=arguments.length;n0&&s[s.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ae(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}var Td="ENTRIES",Qa="KEYS",qa="VALUES",me="",Fs=function(){function t(e,r){var n=e._tree,i=Array.from(n.keys());this.set=e,this._type=r,this._path=i.length>0?[{node:n,keys:i}]:[]}return t.prototype.next=function(){var e=this.dive();return this.backtrack(),e},t.prototype.dive=function(){if(this._path.length===0)return{done:!0,value:void 0};var e=fr(this._path),r=e.node,n=e.keys;if(fr(n)===me)return{done:!1,value:this.result()};var i=r.get(fr(n));return this._path.push({node:i,keys:Array.from(i.keys())}),this.dive()},t.prototype.backtrack=function(){if(this._path.length!==0){var e=fr(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack())}},t.prototype.key=function(){return this.set._prefix+this._path.map(function(e){var r=e.keys;return fr(r)}).filter(function(e){return e!==me}).join("")},t.prototype.value=function(){return fr(this._path).node.get(me)},t.prototype.result=function(){switch(this._type){case qa:return this.value();case Qa:return this.key();default:return[this.key(),this.value()]}},t.prototype[Symbol.iterator]=function(){return this},t}(),fr=function(t){return t[t.length-1]},kd=function(t,e,r){var n=new Map;if(e===void 0)return n;for(var i=e.length+1,s=i+r,o=new Uint8Array(s*i).fill(r+1),a=0;ar)continue e}Ya(t.get(y),e,r,n,i,b,o,a+y)}}}catch(T){l={error:T}}finally{try{f&&!f.done&&(u=d.return)&&u.call(d)}finally{if(l)throw l.error}}},Ss=function(){function t(e,r){e===void 0&&(e=new Map),r===void 0&&(r=""),this._size=void 0,this._tree=e,this._prefix=r}return t.prototype.atPrefix=function(e){var r,n;if(!e.startsWith(this._prefix))throw new Error("Mismatched prefix");var i=ae(qn(this._tree,e.slice(this._prefix.length)),2),s=i[0],o=i[1];if(s===void 0){var a=ae(Ts(o),2),l=a[0],u=a[1];try{for(var c=W(l.keys()),d=c.next();!d.done;d=c.next()){var f=d.value;if(f!==me&&f.startsWith(u)){var y=new Map;return y.set(f.slice(u.length),l.get(f)),new t(y,e)}}}catch(w){r={error:w}}finally{try{d&&!d.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}}return new t(s,e)},t.prototype.clear=function(){this._size=void 0,this._tree.clear()},t.prototype.delete=function(e){return this._size=void 0,Id(this._tree,e)},t.prototype.entries=function(){return new Fs(this,Td)},t.prototype.forEach=function(e){var r,n;try{for(var i=W(this),s=i.next();!s.done;s=i.next()){var o=ae(s.value,2),a=o[0],l=o[1];e(a,l,this)}}catch(u){r={error:u}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}},t.prototype.fuzzyGet=function(e,r){return kd(this._tree,e,r)},t.prototype.get=function(e){var r=Es(this._tree,e);return r!==void 0?r.get(me):void 0},t.prototype.has=function(e){var r=Es(this._tree,e);return r!==void 0&&r.has(me)},t.prototype.keys=function(){return new Fs(this,Qa)},t.prototype.set=function(e,r){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var n=Ds(this._tree,e);return n.set(me,r),this},Object.defineProperty(t.prototype,"size",{get:function(){if(this._size)return this._size;this._size=0;for(var e=this.entries();!e.next().done;)this._size+=1;return this._size},enumerable:!1,configurable:!0}),t.prototype.update=function(e,r){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var n=Ds(this._tree,e);return n.set(me,r(n.get(me))),this},t.prototype.fetch=function(e,r){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var n=Ds(this._tree,e),i=n.get(me);return i===void 0&&n.set(me,i=r()),i},t.prototype.values=function(){return new Fs(this,qa)},t.prototype[Symbol.iterator]=function(){return this.entries()},t.from=function(e){var r,n,i=new t;try{for(var s=W(e),o=s.next();!o.done;o=s.next()){var a=ae(o.value,2),l=a[0],u=a[1];i.set(l,u)}}catch(c){r={error:c}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return i},t.fromObject=function(e){return t.from(Object.entries(e))},t}(),qn=function(t,e,r){var n,i;if(r===void 0&&(r=[]),e.length===0||t==null)return[t,r];try{for(var s=W(t.keys()),o=s.next();!o.done;o=s.next()){var a=o.value;if(a!==me&&e.startsWith(a))return r.push([t,a]),qn(t.get(a),e.slice(a.length),r)}}catch(l){n={error:l}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}return r.push([t,e]),qn(void 0,"",r)},Es=function(t,e){var r,n;if(e.length===0||t==null)return t;try{for(var i=W(t.keys()),s=i.next();!s.done;s=i.next()){var o=s.value;if(o!==me&&e.startsWith(o))return Es(t.get(o),e.slice(o.length))}}catch(a){r={error:a}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}},Ds=function(t,e){var r,n,i=e.length;e:for(var s=0;t&&s0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new Ss,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}},t.prototype.discard=function(e){var r=this,n=this._idToShortId.get(e);if(n==null)throw new Error("MiniSearch: cannot discard document with ID ".concat(e,": it is not in the index"));this._idToShortId.delete(e),this._documentIds.delete(n),this._storedFields.delete(n),(this._fieldLength.get(n)||[]).forEach(function(i,s){r.removeFieldLength(n,s,r._documentCount,i)}),this._fieldLength.delete(n),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()},t.prototype.maybeAutoVacuum=function(){if(this._options.autoVacuum!==!1){var e=this._options.autoVacuum,r=e.minDirtFactor,n=e.minDirtCount,i=e.batchSize,s=e.batchWait;this.conditionalVacuum({batchSize:i,batchWait:s},{minDirtCount:n,minDirtFactor:r})}},t.prototype.discardAll=function(e){var r,n,i=this._options.autoVacuum;try{this._options.autoVacuum=!1;try{for(var s=W(e),o=s.next();!o.done;o=s.next()){var a=o.value;this.discard(a)}}catch(l){r={error:l}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}}finally{this._options.autoVacuum=i}this.maybeAutoVacuum()},t.prototype.replace=function(e){var r=this._options,n=r.idField,i=r.extractField,s=i(e,n);this.discard(s),this.add(e)},t.prototype.vacuum=function(e){return e===void 0&&(e={}),this.conditionalVacuum(e)},t.prototype.conditionalVacuum=function(e,r){var n=this;return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&r,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(function(){var i=n._enqueuedVacuumConditions;return n._enqueuedVacuumConditions=Rs,n.performVacuuming(e,i)}),this._enqueuedVacuum)):this.vacuumConditionsMet(r)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(e),this._currentVacuum)},t.prototype.performVacuuming=function(e,r){return Ed(this,void 0,void 0,function(){var n,i,s,o,a,l,u,c,d,f,y,w,b,x,h,v,p,m,_,g,j,A,C,F,D;return Dd(this,function(P){switch(P.label){case 0:if(n=this._dirtCount,!this.vacuumConditionsMet(r))return[3,10];i=e.batchSize||Ps.batchSize,s=e.batchWait||Ps.batchWait,o=1,P.label=1;case 1:P.trys.push([1,7,8,9]),a=W(this._index),l=a.next(),P.label=2;case 2:if(l.done)return[3,6];u=ae(l.value,2),c=u[0],d=u[1];try{for(f=(A=void 0,W(d)),y=f.next();!y.done;y=f.next()){w=ae(y.value,2),b=w[0],x=w[1];try{for(h=(F=void 0,W(x)),v=h.next();!v.done;v=h.next())p=ae(v.value,1),m=p[0],!this._documentIds.has(m)&&(x.size<=1?d.delete(b):x.delete(m))}catch(T){F={error:T}}finally{try{v&&!v.done&&(D=h.return)&&D.call(h)}finally{if(F)throw F.error}}}}catch(T){A={error:T}}finally{try{y&&!y.done&&(C=f.return)&&C.call(f)}finally{if(A)throw A.error}}return this._index.get(c).size===0&&this._index.delete(c),o%i!=0?[3,4]:[4,new Promise(function(T){return setTimeout(T,s)})];case 3:P.sent(),P.label=4;case 4:o+=1,P.label=5;case 5:return l=a.next(),[3,2];case 6:return[3,9];case 7:return _=P.sent(),g={error:_},[3,9];case 8:try{l&&!l.done&&(j=a.return)&&j.call(a)}finally{if(g)throw g.error}return[7];case 9:this._dirtCount-=n,P.label=10;case 10:return[4,null];case 11:return P.sent(),this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null,[2]}})})},t.prototype.vacuumConditionsMet=function(e){if(e==null)return!0;var r=e.minDirtCount,n=e.minDirtFactor;return r=r||Bs.minDirtCount,n=n||Bs.minDirtFactor,this.dirtCount>=r&&this.dirtFactor>=n},Object.defineProperty(t.prototype,"isVacuuming",{get:function(){return this._currentVacuum!=null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dirtCount",{get:function(){return this._dirtCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dirtFactor",{get:function(){return this._dirtCount/(1+this._documentCount+this._dirtCount)},enumerable:!1,configurable:!0}),t.prototype.has=function(e){return this._idToShortId.has(e)},t.prototype.search=function(e,r){var n,i;r===void 0&&(r={});var s=this.executeQuery(e,r),o=[];try{for(var a=W(s),l=a.next();!l.done;l=a.next()){var u=ae(l.value,2),c=u[0],d=u[1],f=d.score,y=d.terms,w=d.match,b=y.length,x={id:this._documentIds.get(c),score:f*b,terms:Object.keys(w),match:w};Object.assign(x,this._storedFields.get(c)),(r.filter==null||r.filter(x))&&o.push(x)}}catch(h){n={error:h}}finally{try{l&&!l.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return o.sort(rl),o},t.prototype.autoSuggest=function(e,r){var n,i,s,o;r===void 0&&(r={}),r=ee(ee({},this._options.autoSuggestOptions),r);var a=new Map;try{for(var l=W(this.search(e,r)),u=l.next();!u.done;u=l.next()){var c=u.value,d=c.score,f=c.terms,y=f.join(" "),w=a.get(y);w!=null?(w.score+=d,w.count+=1):a.set(y,{score:d,terms:f,count:1})}}catch(_){n={error:_}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}var b=[];try{for(var x=W(a),h=x.next();!h.done;h=x.next()){var v=ae(h.value,2),w=v[0],p=v[1],d=p.score,f=p.terms,m=p.count;b.push({suggestion:w,terms:f,score:d/m})}}catch(_){s={error:_}}finally{try{h&&!h.done&&(o=x.return)&&o.call(x)}finally{if(s)throw s.error}}return b.sort(rl),b},Object.defineProperty(t.prototype,"documentCount",{get:function(){return this._documentCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"termCount",{get:function(){return this._index.size},enumerable:!1,configurable:!0}),t.loadJSON=function(e,r){if(r==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(e),r)},t.getDefault=function(e){if(Ms.hasOwnProperty(e))return Os(Ms,e);throw new Error('MiniSearch: unknown option "'.concat(e,'"'))},t.loadJS=function(e,r){var n,i,s,o,a,l,u=e.index,c=e.documentCount,d=e.nextId,f=e.documentIds,y=e.fieldIds,w=e.fieldLength,b=e.averageFieldLength,x=e.storedFields,h=e.dirtCount,v=e.serializationVersion;if(v!==1&&v!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");var p=new t(r);p._documentCount=c,p._nextId=d,p._documentIds=Yn(f),p._idToShortId=new Map,p._fieldIds=y,p._fieldLength=Yn(w),p._avgFieldLength=b,p._storedFields=Yn(x),p._dirtCount=h||0,p._index=new Ss;try{for(var m=W(p._documentIds),_=m.next();!_.done;_=m.next()){var g=ae(_.value,2),j=g[0],A=g[1];p._idToShortId.set(A,j)}}catch(te){n={error:te}}finally{try{_&&!_.done&&(i=m.return)&&i.call(m)}finally{if(n)throw n.error}}try{for(var C=W(u),F=C.next();!F.done;F=C.next()){var D=ae(F.value,2),P=D[0],T=D[1],N=new Map;try{for(var $=(a=void 0,W(Object.keys(T))),M=$.next();!M.done;M=$.next()){var S=M.value,V=T[S];v===1&&(V=V.ds),N.set(parseInt(S,10),Yn(V))}}catch(te){a={error:te}}finally{try{M&&!M.done&&(l=$.return)&&l.call($)}finally{if(a)throw a.error}}p._index.set(P,N)}}catch(te){s={error:te}}finally{try{F&&!F.done&&(o=C.return)&&o.call(C)}finally{if(s)throw s.error}}return p},t.prototype.executeQuery=function(e,r){var n=this;if(r===void 0&&(r={}),typeof e!="string"){var i=ee(ee(ee({},r),e),{queries:void 0}),s=e.queries.map(function(x){return n.executeQuery(x,i)});return this.combineResults(s,e.combineWith)}var o=this._options,a=o.tokenize,l=o.processTerm,u=o.searchOptions,c=ee(ee({tokenize:a,processTerm:l},u),r),d=c.tokenize,f=c.processTerm,y=d(e).flatMap(function(x){return f(x)}).filter(function(x){return!!x}),w=y.map(Bd(c)),b=w.map(function(x){return n.executeQuerySpec(x,c)});return this.combineResults(b,c.combineWith)},t.prototype.executeQuerySpec=function(e,r){var n,i,s,o,a=ee(ee({},this._options.searchOptions),r),l=(a.fields||this._options.fields).reduce(function(S,V){var te;return ee(ee({},S),(te={},te[V]=Os(S,V)||1,te))},a.boost||{}),u=a.boostDocument,c=a.weights,d=a.maxFuzzy,f=a.bm25,y=ee(ee({},el.weights),c),w=y.fuzzy,b=y.prefix,x=this._index.get(e.term),h=this.termResults(e.term,e.term,1,x,l,u,f),v,p;if(e.prefix&&(v=this._index.atPrefix(e.term)),e.fuzzy){var m=e.fuzzy===!0?.2:e.fuzzy,_=m<1?Math.min(d,Math.round(e.term.length*m)):m;_&&(p=this._index.fuzzyGet(e.term,_))}if(v)try{for(var g=W(v),j=g.next();!j.done;j=g.next()){var A=ae(j.value,2),C=A[0],F=A[1],D=C.length-e.term.length;if(!!D){p==null||p.delete(C);var P=b*C.length/(C.length+.3*D);this.termResults(e.term,C,P,F,l,u,f,h)}}}catch(S){n={error:S}}finally{try{j&&!j.done&&(i=g.return)&&i.call(g)}finally{if(n)throw n.error}}if(p)try{for(var T=W(p.keys()),N=T.next();!N.done;N=T.next()){var C=N.value,$=ae(p.get(C),2),M=$[0],D=$[1];if(!!D){var P=w*C.length/(C.length+D);this.termResults(e.term,C,P,M,l,u,f,h)}}}catch(S){s={error:S}}finally{try{N&&!N.done&&(o=T.return)&&o.call(T)}finally{if(s)throw s.error}}return h},t.prototype.combineResults=function(e,r){if(r===void 0&&(r=ks),e.length===0)return new Map;var n=r.toLowerCase();return e.reduce(Md[n])||new Map},t.prototype.toJSON=function(){var e,r,n,i,s=[];try{for(var o=W(this._index),a=o.next();!a.done;a=o.next()){var l=ae(a.value,2),u=l[0],c=l[1],d={};try{for(var f=(n=void 0,W(c)),y=f.next();!y.done;y=f.next()){var w=ae(y.value,2),b=w[0],x=w[1];d[b]=Object.fromEntries(x)}}catch(h){n={error:h}}finally{try{y&&!y.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}s.push([u,d])}}catch(h){e={error:h}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:s,serializationVersion:2}},t.prototype.termResults=function(e,r,n,i,s,o,a,l){var u,c,d,f,y;if(l===void 0&&(l=new Map),i==null)return l;try{for(var w=W(Object.keys(s)),b=w.next();!b.done;b=w.next()){var x=b.value,h=s[x],v=this._fieldIds[x],p=i.get(v);if(p!=null){var m=p.size,_=this._avgFieldLength[v];try{for(var g=(d=void 0,W(p.keys())),j=g.next();!j.done;j=g.next()){var A=j.value;if(!this._documentIds.has(A)){this.removeTerm(v,A,r),m-=1;continue}var C=o?o(this._documentIds.get(A),r):1;if(!!C){var F=p.get(A),D=this._fieldLength.get(A)[v],P=Rd(F,m,this._documentCount,D,_,a),T=n*h*C*P,N=l.get(A);if(N){N.score+=T,Nd(N.terms,e);var $=Os(N.match,r);$?$.push(x):N.match[r]=[x]}else l.set(A,{score:T,terms:[e],match:(y={},y[r]=[x],y)})}}}catch(M){d={error:M}}finally{try{j&&!j.done&&(f=g.return)&&f.call(g)}finally{if(d)throw d.error}}}}}catch(M){u={error:M}}finally{try{b&&!b.done&&(c=w.return)&&c.call(w)}finally{if(u)throw u.error}}return l},t.prototype.addTerm=function(e,r,n){var i=this._index.fetch(n,nl),s=i.get(e);if(s==null)s=new Map,s.set(r,1),i.set(e,s);else{var o=s.get(r);s.set(r,(o||0)+1)}},t.prototype.removeTerm=function(e,r,n){if(!this._index.has(n)){this.warnDocumentChanged(r,e,n);return}var i=this._index.fetch(n,nl),s=i.get(e);s==null||s.get(r)==null?this.warnDocumentChanged(r,e,n):s.get(r)<=1?s.size<=1?i.delete(e):s.delete(r):s.set(r,s.get(r)-1),this._index.get(n).size===0&&this._index.delete(n)},t.prototype.warnDocumentChanged=function(e,r,n){var i,s;try{for(var o=W(Object.keys(this._fieldIds)),a=o.next();!a.done;a=o.next()){var l=a.value;if(this._fieldIds[l]===r){this._options.logger("warn","MiniSearch: document with ID ".concat(this._documentIds.get(e),' has changed before removal: term "').concat(n,'" was not present in field "').concat(l,'". Removing a document after it has changed can corrupt the index!'),"version_conflict");return}}}catch(u){i={error:u}}finally{try{a&&!a.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}},t.prototype.addDocumentId=function(e){var r=this._nextId;return this._idToShortId.set(e,r),this._documentIds.set(r,e),this._documentCount+=1,this._nextId+=1,r},t.prototype.addFields=function(e){for(var r=0;r0){if(++e>=Th)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var yl=Oh;function Mh(t){return function(){return t}}var vl=Mh;var Ph=function(){try{var t=De(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Ls=Ph;var Rh=Ls?function(t,e){return Ls(t,"toString",{configurable:!0,enumerable:!1,value:vl(e),writable:!0})}:_t,_l=Rh;var Bh=yl(_l),xl=Bh;var Lh=9007199254740991,Nh=/^(?:0|[1-9]\d*)$/;function Kh(t,e){var r=typeof t;return e=e??Lh,!!e&&(r=="number"||r!="symbol"&&Nh.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Hh}var mr=Wh;function Uh(t){return t!=null&&mr(t.length)&&!Xn(t)}var xt=Uh;function Gh(t,e,r){if(!vt(r))return!1;var n=typeof e;return(n=="number"?xt(r)&&hr(e,r.length):n=="string"&&e in r)?pr(r[e],t):!1}var Ns=Gh;var Qh=Object.prototype;function qh(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Qh;return t===r}var Al=qh;function Yh(t,e){for(var r=-1,n=Array(t);++r-1}var Ul=fm;function dm(t,e){var r=this.__data__,n=bt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}var Gl=dm;function xr(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e0&&r(a)?e>1?au(a,e-1,r,n,i):ii(i,a):n||(i[i.length]=a)}return i}var lu=au;function Pm(){this.__data__=new wt,this.size=0}var uu=Pm;function Rm(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var cu=Rm;function Bm(t){return this.__data__.get(t)}var fu=Bm;function Lm(t){return this.__data__.has(t)}var du=Lm;var Nm=200;function Km(t,e){var r=this.__data__;if(r instanceof wt){var n=r.__data__;if(!jt||n.lengtha))return!1;var u=s.get(t),c=s.get(e);if(u&&c)return u==e&&c==t;var d=-1,f=!0,y=r&cg?new Fu:void 0;for(s.set(t,e),s.set(e,t);++de||s&&o&&l&&!a&&!u||n&&o&&l||!r&&l||!i)return 1;if(!n&&!s&&!u&&t=a)return l;var u=r[n];return l*(u=="desc"?-1:1)}}return t.index-e.index}var ic=oy;function ay(t,e,r){e.length?e=dr(e,function(s){return se(s)?function(o){return wr(o,s.length===1?s[0]:s)}:s}):e=[_t];var n=-1;e=dr(e,ti(qu));var i=tc(t,function(s,o,a){var l=dr(e,function(u){return u(s)});return{criteria:l,index:++n,value:s}});return rc(i,function(s,o){return ic(s,o,r)})}var sc=ay;var ly=jl(function(t,e){if(t==null)return[];var r=e.length;return r>1&&Ns(t,e[0],e[1])?e=[]:r>2&&Ns(e[0],e[1],e[2])&&(e=[e[0]]),sc(t,lu(e,1),[])}),qs=ly;var uy=t=>{let e=t.split(mt),r=Nn();return r?e.flatMap(n=>da.test(n)?r.cut(n):[n]):E.splitCamelCase?[...e,...e.flatMap(Ca)]:e},pi=class{constructor(){this.indexedDocuments=new Map;this.minisearch=new Is(pi.options)}async loadCache(){let e=await de.getMinisearchCache();return e?(this.minisearch=Is.loadJS(e.data,pi.options),this.indexedDocuments=new Map(e.paths.map(r=>[r.path,r.mtime])),!0):(console.log("Omnisearch - No cache found"),!1)}getDiff(e){let r=new Map(e.map(s=>[s.path,s.mtime])),n=e.filter(s=>!this.indexedDocuments.has(s.path)||this.indexedDocuments.get(s.path)!==s.mtime),i=[...this.indexedDocuments].filter(([s,o])=>!r.has(s)||r.get(s)!==o).map(s=>({path:s[0],mtime:s[1]}));return{toAdd:n,toRemove:i}}async addFromPaths(e){ie("Adding files",e);let r=(await Promise.all(e.map(async i=>await de.getDocument(i)))).filter(i=>!!i?.path);ie("Sorting documents to first index markdown"),r=qs(r,i=>i.path.endsWith(".md")?0:1),this.removeFromPaths(r.filter(i=>this.indexedDocuments.has(i.path)).map(i=>i.path));let n=Aa(r,500);for(let i of n){ie("Indexing into search engine",i),i.forEach(o=>this.indexedDocuments.set(o.path,o.mtime));let s=i.filter(o=>this.minisearch.has(o.path));this.removeFromPaths(s.map(o=>o.path)),await this.minisearch.addAllAsync(i)}}removeFromPaths(e){e.forEach(n=>this.indexedDocuments.delete(n));let r=e.filter(n=>this.minisearch.has(n));this.minisearch.discardAll(r)}async search(e,r){if(e.isEmpty())return[];ie("Starting search for",e);let n=this.minisearch.search(e.segmentsToStr(),{prefix:l=>l.length>=r.prefixLength,fuzzy:l=>l.length<=3?0:l.length<=5?.1:.2,combineWith:"AND",boost:{basename:E.weightBasename,directory:E.weightDirectory,aliases:E.weightBasename,headings1:E.weightH1,headings2:E.weightH2,headings3:E.weightH3}});if(ie("Found",n.length,"results"),e.extensions.length&&(n=n.filter(l=>{let u="."+l.id.split(".").pop();return e.extensions.some(c=>u.startsWith(c))})),e.query.path&&(n=n.filter(l=>e.query.path?.some(u=>l.id.toLowerCase().includes(u.toLowerCase())))),e.query.exclude.path&&(n=n.filter(l=>!e.query.exclude.path?.some(u=>l.id.toLowerCase().includes(u.toLowerCase())))),!n.length)return[];if(r.singleFilePath)return n.filter(l=>l.id===r.singleFilePath);E.hideExcluded?n=n.filter(l=>!(app.metadataCache.isUserIgnored&&app.metadataCache.isUserIgnored(l.id))):n.forEach(l=>{app.metadataCache.isUserIgnored&&app.metadataCache.isUserIgnored(l.id)&&(l.score/=10)});let i=e.getTags();for(let l of i)for(let u of n)(u.tags??[]).includes(l)&&(u.score*=100);ie("Sorting and limiting results"),n=n.sort((l,u)=>u.score-l.score).slice(0,50);let s=await Promise.all(n.map(async l=>await de.getDocument(l.id))),o=e.getExactTerms();o.length&&(ie("Filtering with quoted terms"),n=n.filter(l=>{let u=s.find(f=>f.path===l.id),c=u?.path.toLowerCase()??"",d=ws(u?.content??"").toLowerCase();return o.every(f=>d.includes(f)||c.includes(f))}));let a=e.query.exclude.text;return a.length&&(ie("Filtering with exclusions"),n=n.filter(l=>{let u=ws(s.find(c=>c.path===l.id)?.content??"").toLowerCase();return a.every(c=>!u.includes(c))})),ie("Deduping"),n=n.filter((l,u,c)=>c.findIndex(d=>d.id===l.id)===u),n}getMatches(e,r,n){let i=new Date().getTime(),s=null,o=[],a=0;for(;(s=r.exec(e))!==null;){if(++a>=100||new Date().getTime()-i>50){Fa("Stopped getMatches at",a,"results");break}let u=s[0];u&&o.push({match:u,offset:s.index})}let l=e.toLowerCase().indexOf(n.segmentsToStr());return l>-1&&o.unshift({offset:l,match:n.segmentsToStr()}),o}async getSuggestions(e,r){let n;E.simpleSearch?n=await this.search(e,{prefixLength:3,singleFilePath:r?.singleFilePath}):n=await this.search(e,{prefixLength:1,singleFilePath:r?.singleFilePath});let i=await Promise.all(n.map(async o=>await de.getDocument(o.id)));return n.map(o=>{ie("Locating matches for",o.id);let a=i.find(d=>d.path===o.id);a||(console.warn(`Omnisearch - Note "${o.id}" not in the live cache`),a={content:"",basename:o.id,path:o.id});let l=[...Object.keys(o.match),...e.getExactTerms(),...e.getTags()].filter(d=>d.length>1||/\p{Emoji}/u.test(d));ie("Matching tokens:",l),ie("Getting matches locations...");let u=this.getMatches(a.content,yt(l),e);return ie("Matches:",u),re({score:o.score,foundWords:l,matches:u},a)})}async writeToCache(){await de.writeMinisearchCache(this.minisearch,this.indexedDocuments)}},Ys=pi;Ys.options={tokenize:uy,extractField:(e,r)=>{if(r==="directory"){let n=e.path.split("/");return n.pop(),n.join("/")}return e[r]},processTerm:e=>(E.ignoreDiacritics?et(e):e).toLowerCase(),idField:"path",fields:["basename","directory","aliases","content","headings1","headings2","headings3"],storeFields:["tags"],logger(e,r,n){n==="version_conflict"&&new oc.Notice("Omnisearch - Your index cache may be incorrect or corrupted. If this message keeps appearing, go to Settings to clear the cache.",5e3)}};var ce=new Ys;var Js=new Set;function ac(t){Js.add(t)}async function mi(){let t=[...Js].map(e=>e.path);t.length&&(ce.removeFromPaths(t),ce.addFromPaths(t),Js.clear())}function lc(t,e,r){let n=t.slice();return n[30]=e[r],n[32]=r,n}function cy(t){let e,r,n;return{c(){e=O("button"),e.textContent="Create note"},m(i,s){z(i,e,s),r||(n=Te(e,"click",t[8]),r=!0)},p:ne,d(i){i&&K(e),r=!1,n()}}}function fy(t){let e,r=E.showCreateButton&&cy(t);return{c(){r&&r.c(),e=Jt()},m(n,i){r&&r.m(n,i),z(n,e,i)},p(n,i){E.showCreateButton&&r.p(n,i)},d(n){r&&r.d(n),n&&K(e)}}}function uc(t){let e,r,n;return{c(){e=O("div"),r=Fe("\u23F3 Work in progress: "),n=Fe(t[3]),ke(e,"text-align","center"),ke(e,"color","var(--text-accent)"),ke(e,"margin-top","10px")},m(i,s){z(i,e,s),k(e,r),k(e,n)},p(i,s){s[0]&8&&St(n,i[3])},d(i){i&&K(e)}}}function cc(t){let e,r;function n(...i){return t[14](t[32],...i)}return e=new $a({props:{selected:t[32]===t[0],note:t[30]}}),e.$on("mousemove",n),e.$on("click",t[6]),e.$on("auxclick",t[15]),{c(){Se(e.$$.fragment)},m(i,s){we(e,i,s),r=!0},p(i,s){t=i;let o={};s[0]&1&&(o.selected=t[32]===t[0]),s[0]&4&&(o.note=t[30]),e.$set(o)},i(i){r||(Q(e.$$.fragment,i),r=!0)},o(i){q(e.$$.fragment,i),r=!1},d(i){ge(e,i)}}}function dy(t){let e;return{c(){e=Fe("Searching...")},m(r,n){z(r,e,n)},p:ne,d(r){r&&K(e)}}}function hy(t){let e,r=E.simpleSearch&&t[1].split(mt).some(dc),n,i=r&&fc(t);return{c(){e=Fe(`We found 0 result for your search here. - `),i&&i.c(),n=Jt()},m(s,o){z(s,e,o),i&&i.m(s,o),z(s,n,o)},p(s,o){o[0]&2&&(r=E.simpleSearch&&s[1].split(mt).some(dc)),r?i||(i=fc(s),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},d(s){s&&K(e),i&&i.d(s),s&&K(n)}}}function fc(t){let e,r,n;return{c(){e=O("br"),r=U(),n=O("span"),n.textContent=`You have enabled "Simpler Search" in the settings, try to type more - characters.`,ke(n,"color","var(--text-accent)"),ke(n,"font-size","small")},m(i,s){z(i,e,s),z(i,r,s),z(i,n,s)},d(i){i&&K(e),i&&K(r),i&&K(n)}}}function py(t){let e,r,n,i=t[2],s=[];for(let c=0;cq(s[c],1,1,()=>{s[c]=null});function a(c,d){if(!c[2].length&&c[1]&&!c[4])return hy;if(c[4])return dy}let l=a(t,[-1,-1]),u=l&&l(t);return{c(){for(let c=0;c\u2191\u2193to navigate',l=U(),u=O("div"),u.innerHTML=`alt \u2191\u2193 - to cycle history`,c=U(),d=O("div"),d.innerHTML='\u21B5to open',f=U(),y=O("div"),y.innerHTML=`tab - to switch to In-File Search`,w=U(),b=O("div"),x=O("span"),x.textContent=`${Vn()} \u21B5`,h=U(),v=O("span"),v.textContent="to open in a new pane",p=U(),m=O("div"),m.innerHTML=`shift \u21B5 - to create`,_=U(),g=O("div"),g.innerHTML=`ctrl shift \u21B5 - to create in a new pane`,j=U(),A=O("div"),A.innerHTML=`alt \u21B5 - to insert a link`,C=U(),F=O("div"),F.innerHTML=`ctrl+h - to toggle excerpts`,D=U(),P=O("div"),P.innerHTML='escto close',B(a,"class","prompt-instruction"),B(u,"class","prompt-instruction"),B(d,"class","prompt-instruction"),B(y,"class","prompt-instruction"),B(x,"class","prompt-instruction-command"),B(b,"class","prompt-instruction"),B(m,"class","prompt-instruction"),B(g,"class","prompt-instruction"),B(A,"class","prompt-instruction"),B(F,"class","prompt-instruction"),B(P,"class","prompt-instruction"),B(o,"class","prompt-instructions")},m(M,S){we(e,M,S),z(M,r,S),$&&$.m(M,S),z(M,n,S),we(i,M,S),z(M,s,S),z(M,o,S),k(o,a),k(o,l),k(o,u),k(o,c),k(o,d),k(o,f),k(o,y),k(o,w),k(o,b),k(b,x),k(b,h),k(b,v),k(o,p),k(o,m),k(o,_),k(o,g),k(o,j),k(o,A),k(o,C),k(o,F),k(o,D),k(o,P),T=!0},p(M,S){let V={};S[0]&2&&(V.initialValue=M[1]),S[1]&4&&(V.$$scope={dirty:S,ctx:M}),e.$set(V),M[3]?$?$.p(M,S):($=uc(M),$.c(),$.m(n.parentNode,n)):$&&($.d(1),$=null);let te={};S[0]&23|S[1]&4&&(te.$$scope={dirty:S,ctx:M}),i.$set(te)},i(M){T||(Q(e.$$.fragment,M),Q(i.$$.fragment,M),T=!0)},o(M){q(e.$$.fragment,M),q(i.$$.fragment,M),T=!1},d(M){t[12](null),ge(e,M),M&&K(r),$&&$.d(M),M&&K(n),ge(i,M),M&&K(s),M&&K(o)}}}var dc=t=>t.length<3;function gy(t,e,r){let n,i;ln(t,pt,S=>r(11,i=S));let{modal:s}=e,{previousQuery:o}=e,a=0,l=0,u,c=[],d,f="",y=!0,w;Tr(async()=>{H.enable("vault"),H.on("vault","enter",p),H.on("vault","create-note",A),H.on("vault","open-in-new-pane",m),H.on("vault","insert-link",C),H.on("vault","tab",F),H.on("vault","arrow-up",()=>D(-1)),H.on("vault","arrow-down",()=>D(1)),H.on("vault","prev-search-history",b),H.on("vault","next-search-history",x),await mi(),E.showPreviousQueryResults&&r(9,o=(await de.getSearchHistory())[0])}),kr(()=>{H.disable("vault")});async function b(){let S=(await de.getSearchHistory()).filter(V=>V);++l>=S.length&&(l=0),r(1,u=S[l]),w?.setInputValue(u)}async function x(){let S=(await de.getSearchHistory()).filter(V=>V);--l<0&&(l=S.length?S.length-1:0),r(1,u=S[l]),w?.setInputValue(u)}async function h(){d=new zt(u),r(2,c=await ce.getSuggestions(d)),r(0,a=0),await P()}function v(S){!n||(S?.ctrlKey?m():p(),s.close())}function p(){!n||(g(n),s.close())}function m(){!n||(g(n,!0),s.close())}function _(){u&&de.addToSearchHistory(u)}function g(S,V=!1){_(),Un(S,V)}async function j(S){await A()}async function A(S){if(u){try{await Oa(u,S?.newLeaf)}catch(V){new Ft.Notice(V.message);return}s.close()}}function C(){if(!n)return;let S=app.vault.getMarkdownFiles().find(st=>st.path===n.path),V=app.workspace.getActiveFile(),te=app.workspace.getActiveViewOfType(Ft.MarkdownView);if(!te?.editor){new Ft.Notice("Omnisearch - Error - No active editor",3e3);return}let Wt;S&&V?Wt=app.fileManager.generateMarkdownLink(S,V.path):Wt=`[[${n.basename}.${Kt(n.path)}]]`;let it=te.editor.getCursor();te.editor.replaceRange(Wt,it,it),it.ch+=Wt.length,te.editor.setCursor(it),s.close()}function F(){if(!(n&&(en(n?.path)||!n?.matches.length)))if(_(),s.close(),n){let S=app.vault.getAbstractFileByPath(n.path);S&&S instanceof Ft.TFile&&new Cr(app,S,u).open()}else{let S=app.workspace.getActiveViewOfType(Ft.MarkdownView);S&&new Cr(app,S.file,u).open()}}function D(S){r(0,a=zn(a+S,c.length)),P()}async function P(){await ot(),n&&activeWindow.document.querySelector(`[data-result-id="${n.path}"]`)?.scrollIntoView({behavior:"auto",block:"nearest"})}function T(S){He[S?"unshift":"push"](()=>{w=S,r(5,w)})}let N=S=>r(1,u=S.detail),$=(S,V)=>r(0,a=S),M=S=>{S.button==1&&m()};return t.$$set=S=>{"modal"in S&&r(10,s=S.modal),"previousQuery"in S&&r(9,o=S.previousQuery)},t.$$.update=()=>{if(t.$$.dirty[0]&514){e:r(1,u=u??o)}if(t.$$.dirty[0]&2){e:u?(r(4,y=!0),h().then(()=>{r(4,y=!1)})):(r(4,y=!1),r(2,c=[]))}if(t.$$.dirty[0]&5){e:n=c[a]}if(t.$$.dirty[0]&2048){e:switch(i){case Pe.LoadingCache:r(3,f="Loading cache...");break;case Pe.ReadingFiles:r(3,f="Reading files...");break;case Pe.IndexingFiles:r(3,f="Indexing files...");break;case Pe.WritingCache:h(),r(3,f="Updating cache...");break;default:h(),r(3,f="");break}}},[a,u,c,f,y,w,v,m,j,o,s,i,T,N,$,M]}var hc=class extends pe{constructor(e){super();ye(this,e,gy,my,fe,{modal:10,previousQuery:9},null,[-1,-1])}},pc=hc;var yc=be(require("obsidian"));function yy(t){let e,r=t[2].replace(t[3],gt)+"";return{c(){e=O("div"),B(e,"class","omnisearch-result__body")},m(n,i){z(n,e,i),e.innerHTML=r},p(n,i){i&12&&r!==(r=n[2].replace(n[3],gt)+"")&&(e.innerHTML=r)},d(n){n&&K(e)}}}function vy(t){let e,r;return e=new Gn({props:{id:t[0].toString(),selected:t[1],$$slots:{default:[yy]},$$scope:{ctx:t}}}),e.$on("mousemove",t[6]),e.$on("click",t[7]),e.$on("auxclick",t[8]),{c(){Se(e.$$.fragment)},m(n,i){we(e,n,i),r=!0},p(n,[i]){let s={};i&1&&(s.id=n[0].toString()),i&2&&(s.selected=n[1]),i&524&&(s.$$scope={dirty:i,ctx:n}),e.$set(s)},i(n){r||(Q(e.$$.fragment,n),r=!0)},o(n){q(e.$$.fragment,n),r=!1},d(n){ge(e,n)}}}function _y(t,e,r){let n,i,{offset:s}=e,{note:o}=e,{index:a=0}=e,{selected:l=!1}=e;function u(f){Me.call(this,t,f)}function c(f){Me.call(this,t,f)}function d(f){Me.call(this,t,f)}return t.$$set=f=>{"offset"in f&&r(4,s=f.offset),"note"in f&&r(5,o=f.note),"index"in f&&r(0,a=f.index),"selected"in f&&r(1,l=f.selected)},t.$$.update=()=>{if(t.$$.dirty&32){e:r(3,n=yt(o.foundWords))}if(t.$$.dirty&48){e:r(2,i=ur(o?.content??"",s))}},[a,l,i,n,s,o,u,c,d]}var mc=class extends pe{constructor(e){super();ye(this,e,_y,vy,fe,{offset:4,note:5,index:0,selected:1})}},gc=mc;function vc(t,e,r){let n=t.slice();return n[19]=e[r],n[21]=r,n}function xy(t){let e;return{c(){e=O("div"),e.textContent="We found 0 result for your search here.",ke(e,"text-align","center")},m(r,n){z(r,e,n)},p:ne,i:ne,o:ne,d(r){r&&K(e)}}}function by(t){let e,r,n=t[4],i=[];for(let o=0;oq(i[o],1,1,()=>{i[o]=null});return{c(){for(let o=0;o{o[c]=null}),Tt(),r=o[e],r?r.p(l,u):(r=o[e]=s[e](l),r.c()),Q(r,1),r.m(n.parentNode,n))},i(l){i||(Q(r),i=!0)},o(l){q(r),i=!1},d(l){o[e].d(l),l&&K(n)}}}function jy(t){let e;return{c(){e=O("span"),e.textContent="to close"},m(r,n){z(r,e,n)},d(r){r&&K(e)}}}function Ay(t){let e;return{c(){e=O("span"),e.textContent="to go back to Vault Search"},m(r,n){z(r,e,n)},d(r){r&&K(e)}}}function Cy(t){let e,r,n,i,s,o,a,l,u,c,d,f,y,w,b,x,h,v,p,m;e=new Hn({props:{placeholder:"Omnisearch - File",initialValue:t[1]}}),e.$on("input",t[10]),n=new Wn({props:{$$slots:{default:[wy]},$$scope:{ctx:t}}});function _(A,C){return A[0]?Ay:jy}let g=_(t,-1),j=g(t);return{c(){Se(e.$$.fragment),r=U(),Se(n.$$.fragment),i=U(),s=O("div"),o=O("div"),o.innerHTML='\u2191\u2193to navigate',a=U(),l=O("div"),l.innerHTML='\u21B5to open',u=U(),c=O("div"),c.innerHTML=`tab - to switch to Vault Search`,d=U(),f=O("div"),y=O("span"),y.textContent="esc",w=U(),j.c(),b=U(),x=O("div"),h=O("span"),h.textContent=`${Vn()} \u21B5`,v=U(),p=O("span"),p.textContent="to open in a new pane",B(o,"class","prompt-instruction"),B(l,"class","prompt-instruction"),B(c,"class","prompt-instruction"),B(y,"class","prompt-instruction-command"),B(f,"class","prompt-instruction"),B(h,"class","prompt-instruction-command"),B(x,"class","prompt-instruction"),B(s,"class","prompt-instructions")},m(A,C){we(e,A,C),z(A,r,C),we(n,A,C),z(A,i,C),z(A,s,C),k(s,o),k(s,a),k(s,l),k(s,u),k(s,c),k(s,d),k(s,f),k(f,y),k(f,w),j.m(f,null),k(s,b),k(s,x),k(x,h),k(x,v),k(x,p),m=!0},p(A,[C]){let F={};C&2&&(F.initialValue=A[1]),e.$set(F);let D={};C&4194360&&(D.$$scope={dirty:C,ctx:A}),n.$set(D),g!==(g=_(A,C))&&(j.d(1),j=g(A),j&&(j.c(),j.m(f,null)))},i(A){m||(Q(e.$$.fragment,A),Q(n.$$.fragment,A),m=!0)},o(A){q(e.$$.fragment,A),q(n.$$.fragment,A),m=!1},d(A){ge(e,A),A&&K(r),ge(n,A),A&&K(i),A&&K(s),j.d()}}}function Fy(t,e,r){let n=t.find(i=>i.offset>e);return n?t.filter(i=>i.offset>e&&i.offset<=n.offset+r):[]}function Sy(t,e,r){let{modal:n}=e,{parent:i=null}=e,{singleFilePath:s=""}=e,{previousQuery:o}=e,a,l=[],u=0,c,d;Tr(()=>{H.enable("infile"),H.on("infile","enter",x),H.on("infile","open-in-new-pane",b),H.on("infile","arrow-up",()=>y(-1)),H.on("infile","arrow-down",()=>y(1)),H.on("infile","tab",h)}),kr(()=>{H.disable("infile")});function f(g){let j=[],A=-1,C=0;for(;;){let F=Fy(g,A,Jr);if(!F.length||(A=F.last().offset,j.push(F),++C>100))break}return j}function y(g){r(5,u=zn(u+g,l.length)),w()}async function w(){await ot(),document.querySelector(`[data-result-id="${u}"]`)?.scrollIntoView({behavior:"auto",block:"nearest"})}async function b(){return x(!0)}async function x(g=!1){if(c){n.close(),i&&i.close(),await Un(c,g);let j=app.workspace.getActiveViewOfType(yc.MarkdownView);if(!j)return;let A=l[u]??0,C=j.editor.offsetToPos(A);C.ch=0,j.editor.setCursor(C),j.editor.scrollIntoView({from:{line:C.line-10,ch:0},to:{line:C.line+10,ch:0}})}}function h(){new Ht(app,a??o).open(),n.close()}let v=g=>r(2,a=g.detail),p=(g,j)=>r(5,u=g),m=g=>x(g.ctrlKey),_=g=>{g.button==1&&x(!0)};return t.$$set=g=>{"modal"in g&&r(7,n=g.modal),"parent"in g&&r(0,i=g.parent),"singleFilePath"in g&&r(8,s=g.singleFilePath),"previousQuery"in g&&r(1,o=g.previousQuery)},t.$$.update=()=>{if(t.$$.dirty&2){e:r(2,a=o??"")}if(t.$$.dirty&772){e:(async()=>{a&&(r(9,d=new zt(a)),r(3,c=(await ce.getSuggestions(d,{singleFilePath:s}))[0]??null)),r(5,u=0),await w()})()}if(t.$$.dirty&8){e:if(c){let g=f(c.matches);r(4,l=g.map(j=>Math.round((j.first().offset+j.last().offset)/2)))}}},[i,o,a,c,l,u,x,n,s,d,v,p,m,_]}var xc=class extends pe{constructor(e){super();ye(this,e,Sy,Cy,fe,{modal:7,parent:0,singleFilePath:8,previousQuery:1})}},bc=xc;var Xs=class extends wc.Modal{constructor(e){super(e);this.modalEl.replaceChildren(),this.modalEl.addClass("omnisearch-modal","prompt"),this.modalEl.removeClass("modal"),this.modalEl.tabIndex=-1,this.scope.register([],"ArrowDown",r=>{r.preventDefault(),H.emit("arrow-down")}),this.scope.register([],"ArrowUp",r=>{r.preventDefault(),H.emit("arrow-up")});for(let r of[{k:"J",dir:"down"},{k:"K",dir:"up"}])for(let n of["Ctrl","Mod"])this.scope.register([n],r.k,i=>{this.app.vault.getConfig("vimMode")&&H.emit("arrow-"+r.dir)});for(let r of[{k:"N",dir:"down"},{k:"P",dir:"up"}])for(let n of["Ctrl","Mod"])this.scope.register([n],r.k,i=>{this.app.vault.getConfig("vimMode")&&H.emit("arrow-"+r.dir)});this.scope.register(["Mod"],"Enter",r=>{r.preventDefault(),H.emit("open-in-new-pane")}),this.scope.register(["Alt"],"Enter",r=>{r.preventDefault(),H.emit("insert-link")}),this.scope.register(["Shift"],"Enter",r=>{r.preventDefault(),H.emit("create-note")}),this.scope.register(["Ctrl","Shift"],"Enter",r=>{r.preventDefault(),H.emit("create-note",{newLeaf:!0})}),this.scope.register([],"Enter",r=>{ga()||(r.preventDefault(),H.emit("enter"))}),this.scope.register([],"Tab",r=>{r.preventDefault(),H.emit("tab")}),this.scope.register(["Alt"],"ArrowDown",r=>{r.preventDefault(),H.emit("next-search-history")}),this.scope.register(["Alt"],"ArrowUp",r=>{r.preventDefault(),H.emit("prev-search-history")}),this.scope.register(["Ctrl"],"H",r=>{H.emit(Ln.ToggleExcerpts)})}},Ht=class extends Xs{constructor(e,r){super(e);let n=new pc({target:this.modalEl,props:{modal:this,previousQuery:r}});this.onClose=()=>{n.$destroy()}}},Cr=class extends Xs{constructor(e,r,n="",i){super(e);let s=new bc({target:this.modalEl,props:{modal:this,singleFilePath:r.path,parent:i,previousQuery:n}});i&&i.containerEl.toggleVisibility(!1),this.onClose=()=>{i&&i.containerEl.toggleVisibility(!0),s.$destroy()}}};var jc=!1,gi=[];function Ey(t){return t.map(e=>{let{score:r,path:n,basename:i,foundWords:s,matches:o,content:a}=e,l=ur(a,o[0]?.offset??-1);return{score:r,path:n,basename:i,foundWords:s,matches:o.map(u=>({match:u.match,offset:u.offset})),excerpt:l}})}async function Dy(t){let e=new zt(t),r=await ce.getSuggestions(e);return Ey(r)}function Ty(t){gi.push(t),jc&&t()}function ky(t){gi=gi.filter(e=>e!==t)}function Ac(){jc=!0,gi.forEach(t=>t())}var Zs={search:Dy,registerOnIndexed:Ty,unregisterOnIndexed:ky,refreshIndex:mi};var eo=class extends Fr.Plugin{async onload(){await ca(this),await Iy(),await lr.clearOldDatabases(),Oy(this),E.ribbonIcon&&this.addRibbonButton(),this.addSettingTab(new _s(this)),H.disable("vault"),H.disable("infile"),H.on("global",Ln.ToggleExcerpts,()=>{Lt.set(!E.showExcerpt)}),this.addCommand({id:"show-modal",name:"Vault search",callback:()=>{new Ht(app).open()}}),this.addCommand({id:"show-modal-infile",name:"In-file search",editorCallback:(e,r)=>{r.file&&new Cr(app,r.file).open()}}),app.workspace.onLayoutReady(async()=>{this.registerEvent(this.app.vault.on("create",e=>{Zr(e.path)&&(ie("Indexing new file",e.path),ce.addFromPaths([e.path]))})),this.registerEvent(this.app.vault.on("delete",e=>{ie("Removing file",e.path),de.removeFromLiveCache(e.path),ce.removeFromPaths([e.path])})),this.registerEvent(this.app.vault.on("modify",async e=>{Zr(e.path)&&(ie("Updating file",e.path),await de.addToLiveCache(e.path),ac(e))})),this.registerEvent(this.app.vault.on("rename",async(e,r)=>{Zr(e.path)&&(ie("Renaming file",e.path),de.removeFromLiveCache(r),de.addToLiveCache(e.path),ce.removeFromPaths([r]),await ce.addFromPaths([e.path]))})),this.executeFirstLaunchTasks(),await this.populateIndex()})}executeFirstLaunchTasks(){let e="1.10.1";if(E.welcomeMessage!==e){let r=new DocumentFragment;r.createSpan({},n=>{n.innerHTML="\u{1F50E} Omnisearch now requires the Text Extractor plugin to index PDF and images. See Omnisearch settings for more information."}),new Fr.Notice(r,2e4)}E.welcomeMessage=e,this.saveData(E)}async onunload(){delete globalThis.omnisearch,await Ee.clearCache()}addRibbonButton(){this.ribbonButton=this.addRibbonIcon("search","Omnisearch",e=>{new Ht(app).open()})}removeRibbonButton(){this.ribbonButton&&this.ribbonButton.parentNode?.removeChild(this.ribbonButton)}async populateIndex(){console.time("Omnisearch - Indexing total time"),pt.set(Pe.ReadingFiles);let e=app.vault.getFiles().filter(n=>Zr(n.path));console.log(`Omnisearch - ${e.length} files total`),console.log(`Omnisearch - Cache is ${ht()?"enabled":"disabled"}`),ht()&&(console.time("Omnisearch - Loading index from cache"),pt.set(Pe.LoadingCache),await ce.loadCache()&&console.timeEnd("Omnisearch - Loading index from cache"));let r=ce.getDiff(e.map(n=>({path:n.path,mtime:n.stat.mtime})));ht()&&(r.toAdd.length&&console.log("Omnisearch - Total number of files to add/update: "+r.toAdd.length),r.toRemove.length&&console.log("Omnisearch - Total number of files to remove: "+r.toRemove.length)),r.toAdd.length>=1e3&&ht()&&new Fr.Notice(`Omnisearch - ${r.toAdd.length} files need to be indexed. Obsidian may experience stutters and freezes during the process`,1e4),pt.set(Pe.IndexingFiles),ce.removeFromPaths(r.toRemove.map(n=>n.path)),await ce.addFromPaths(r.toAdd.map(n=>n.path)),(r.toRemove.length||r.toAdd.length)&&ht()&&(pt.set(Pe.WritingCache),E.useCache=!1,ue(this),await ce.writeToCache(),E.useCache=!0,ue(this)),console.timeEnd("Omnisearch - Indexing total time"),r.toAdd.length>=1e3&&new Fr.Notice("Omnisearch - Your files have been indexed."),pt.set(Pe.Done),Ac()}};async function Iy(){let t=[`${app.vault.configDir}/plugins/omnisearch/searchIndex.json`,`${app.vault.configDir}/plugins/omnisearch/notesCache.json`,`${app.vault.configDir}/plugins/omnisearch/notesCache.data`,`${app.vault.configDir}/plugins/omnisearch/searchIndex.data`,`${app.vault.configDir}/plugins/omnisearch/historyCache.json`,`${app.vault.configDir}/plugins/omnisearch/pdfCache.data`];for(let e of t)if(await app.vault.adapter.exists(e))try{await app.vault.adapter.remove(e)}catch{}}function Oy(t){t.registerObsidianProtocolHandler("omnisearch",e=>{new Ht(app,e.query).open()}),globalThis.omnisearch=Zs,app.plugins.plugins.omnisearch.api=Zs} + ${sn} + `}),new Y.Setting(e).setName("Split CamelCaseWords").setDesc(l).addToggle(f=>f.setValue(I.splitCamelCase).onChange(async c=>{await Be.clearCache(),I.splitCamelCase=c,await pe(this.plugin)})),new Y.Setting(e).setName("Simpler search").setDesc(`Enable this if Obsidian often freezes while making searches. + Words shorter than 3 characters won't be used as prefixes; this can reduce search delay but will return fewer results.`).addToggle(f=>f.setValue(I.simpleSearch).onChange(async c=>{I.simpleSearch=c,await pe(this.plugin)})),new Y.Setting(e).setName("Open in new pane").setDesc("Open and create files in a new pane instead of the current pane.").addToggle(f=>f.setValue(I.openInNewPane).onChange(async c=>{I.openInNewPane=c,await pe(this.plugin)})),new Y.Setting(e).setName("User Interface").setHeading(),new Y.Setting(e).setName("Show ribbon button").setDesc("Add a button on the sidebar to open the Vault search modal.").addToggle(f=>f.setValue(I.ribbonIcon).onChange(async c=>{I.ribbonIcon=c,await pe(this.plugin),c?this.plugin.addRibbonButton():this.plugin.removeRibbonButton()})),new Y.Setting(e).setName("Show excerpts").setDesc("Shows the contextual part of the note that matches the search. Disable this to only show filenames in results.").addToggle(f=>f.setValue(I.showExcerpt).onChange(async c=>{Ut.set(c)})),new Y.Setting(e).setName("Render line return in excerpts").setDesc("Activate this option to render line returns in result excerpts.").addToggle(f=>f.setValue(I.renderLineReturnInExcerpts).onChange(async c=>{I.renderLineReturnInExcerpts=c,await pe(this.plugin)})),new Y.Setting(e).setName("Show previous query results").setDesc("Re-executes the previous query when opening Omnisearch.").addToggle(f=>f.setValue(I.showPreviousQueryResults).onChange(async c=>{I.showPreviousQueryResults=c,await pe(this.plugin)}));let u=new DocumentFragment;u.createSpan({},f=>{f.innerHTML=`Shows a button next to the search input, to create a note. + Acts the same as the shift \u21B5 shortcut, can be useful for mobile device users.`}),new Y.Setting(e).setName('Show "Create note" button').setDesc(u).addToggle(f=>f.setValue(I.showCreateButton).onChange(async c=>{I.showCreateButton=c,await pe(this.plugin)})),new Y.Setting(e).setName("Highlight matching words in results").setDesc("Will highlight matching results when enabled. See README for more customization options.").addToggle(f=>f.setValue(I.highlight).onChange(async c=>{I.highlight=c,await pe(this.plugin)})),new Y.Setting(e).setName("Results weighting").setHeading(),new Y.Setting(e).setName(`File name & declared aliases (default: ${Gt.weightBasename})`).addSlider(f=>this.weightSlider(f,"weightBasename")),new Y.Setting(e).setName(`File directory (default: ${Gt.weightDirectory})`).addSlider(f=>this.weightSlider(f,"weightDirectory")),new Y.Setting(e).setName(`Headings level 1 (default: ${Gt.weightH1})`).addSlider(f=>this.weightSlider(f,"weightH1")),new Y.Setting(e).setName(`Headings level 2 (default: ${Gt.weightH2})`).addSlider(f=>this.weightSlider(f,"weightH2")),new Y.Setting(e).setName(`Headings level 3 (default: ${Gt.weightH3})`).addSlider(f=>this.weightSlider(f,"weightH3")),new Y.Setting(e).setName("Debugging").setHeading(),new Y.Setting(e).setName("Enable verbose logging").setDesc("Adds a LOT of logs for debugging purposes. Don't forget to disable it.").addToggle(f=>f.setValue(I.verboseLogging).onChange(async c=>{I.verboseLogging=c,await pe(this.plugin)})),new Y.Setting(e).setName("Danger Zone").setHeading();let d=new DocumentFragment;if(d.createSpan({},f=>{f.innerHTML=`Disable Omnisearch on this device only.
+ ${sn}`}),new Y.Setting(e).setName("Disable on this device").setDesc(d).addToggle(f=>f.setValue(Oo()).onChange(async c=>{c?app.saveLocalStorage(an,"1"):app.saveLocalStorage(an),new Y.Notice("Omnisearch - Disabled. Please restart Obsidian.")})),wt()){let f=new DocumentFragment;f.createSpan({},c=>{c.innerHTML=`Erase all Omnisearch cache data. + Use this if Omnisearch results are inconsistent, missing, or appear outdated.
+ ${sn}`}),new Y.Setting(e).setName("Clear cache data").setDesc(f).addButton(c=>{c.setButtonText("Clear cache"),c.onClick(async()=>{await Be.clearCache(),new Y.Notice("Omnisearch - Cache cleared. Please restart Obsidian.")})})}}weightSlider(e,r){e.setLimits(1,5,.1).setValue(I[r]).setDynamicTooltip().onChange(n=>{I[r]=n,pe(this.plugin)})}},Gt={useCache:!0,hideExcluded:!1,ignoreDiacritics:!0,indexedFileTypes:[],PDFIndexing:!1,imagesIndexing:!1,splitCamelCase:!1,openInNewPane:!1,ribbonIcon:!0,showExcerpt:!0,renderLineReturnInExcerpts:!0,showCreateButton:!1,highlight:!0,showPreviousQueryResults:!0,simpleSearch:!1,weightBasename:3,weightDirectory:2,weightH1:1.5,weightH2:1.3,weightH3:1.1,welcomeMessage:"",verboseLogging:!1},I=Object.assign({},Gt);async function ja(t){I=Object.assign({},Gt,await t.loadData()),Ut.set(I.showExcerpt)}async function pe(t){await t.saveData(I)}function Oo(){return app.loadLocalStorage(an)=="1"}var Ca=Fe(require("obsidian"));var Aa=/[\u4e00-\u9fa5]/;var Sa=100,ln=300,Fa=`suggestion-highlight omnisearch-highlight ${I.highlight?"omnisearch-default-highlight":""}`,an="omnisearch-disabled",U=new Bi,qn={ToggleExcerpts:"toggle-excerpts"},We=(o=>(o[o.Done=0]="Done",o[o.LoadingCache=1]="LoadingCache",o[o.ReadingFiles=2]="ReadingFiles",o[o.IndexingFiles=3]="IndexingFiles",o[o.WritingCache=4]="WritingCache",o))(We||{});var jt=Cn(0),Ea=!1;function ko(t){Ea=t}function Da(){return Ea}function Yn(){return app.plugins.plugins["cm-chs-patch"]}function et(){return app.plugins?.plugins?.["text-extractor"]?.api}function wt(){return!Ca.Platform.isIosApp&&I.useCache}var Ct=/[|\n\r -#%-*,-/:;?@[-\]_{}\u00A0\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u1680\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2000-\u200A\u2010-\u2029\u202F-\u2043\u2045-\u2051\u2053-\u205F\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u3000-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]+/u;var za=Fe(require("obsidian"));var ct=Fe(require("obsidian"));var Ia=Fe(require("crypto")),Oa=Fe(Ta());function At(...t){return t[1]!==null&&t[1]!==void 0&&t[2]!==null&&t[2]!==void 0?`${t[1]}${t[2]}`:"<no content>"}function Fd(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function ka(t){let e=t.split("/");return e.pop(),e.join("/")}function Ed(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"[$&]")}function St(t){if(!t.length)return/^$/g;let e="("+(Yn()?"":I.splitCamelCase?`^|${Ct.source}|[A-Z]`:`^|${Ct.source}`)+`)(${t.map(n=>Ed(n)).join("|")})`;return new RegExp(`${e}`,"giu")}function Jn(t,e){return t.headings?.filter(r=>r.level===e).map(r=>r.heading)??[]}function Xn(t,e){return(t+e)%e}function yr(t,e){try{let r=e??-1,n=Math.max(0,r-Sa),i=Math.min(t.length,r+ln);if(r>-1?t=(n>0?"\u2026":"")+t.slice(n,i).trim()+(ia).join(` +`);let s=t.lastIndexOf(` +`,r-n);s>0&&(t=t.slice(s))}return t=Fd(t),I.renderLineReturnInExcerpts&&(t=t.trim().replaceAll(` +`,"
")),t}catch(r){return new ct.Notice("Omnisearch - Error while creating excerpt, see developer console"),console.error("Omnisearch - Error while creating excerpt"),console.error(r),""}}function Mo(t){return t.replace(/(\*|_)+(.+?)(\*|_)+/g,(e,r,n)=>n)}function Pa(t){return t?.frontmatter?(0,ct.parseFrontMatterAliases)(t.frontmatter)??[]:[]}function Ma(t){let e=t?(0,ct.getAllTags)(t)??[]:[];return e=[...new Set(e.reduce((r,n)=>[...r,...n.split("/").filter(i=>i).map(i=>i.startsWith("#")?i:`#${i}`),n],[]))],e}function ft(t){return t==null?"":(t=t.replaceAll("`","[__omnisearch__backtick__]"),t=t.normalize("NFD").replace(/\p{Diacritic}/gu,""),t=t.replaceAll("[__omnisearch__backtick__]","`"),t)}function Qt(){return ct.Platform.isMacOS?"\u2318":"ctrl"}function cn(t){let e=!!et(),r=e&&I.PDFIndexing,n=e&&I.imagesIndexing;return Ro(t)||dn(t)||r&&fn(t)||n&&Zn(t)}function Zn(t){let e=qt(t);return e==="png"||e==="jpg"||e==="jpeg"}function fn(t){return qt(t)==="pdf"}function Ro(t){return[...I.indexedFileTypes,"md"].some(e=>t.endsWith(`.${e}`))}function dn(t){return t.endsWith(".canvas")}function qt(t){let e=t.split(".");return e[e.length-1]??""}function Ra(t){return ct.Platform.isMobileApp?(0,Oa.md5)(t.toString()):(0,Ia.createHash)("md5").update(t).digest("hex")}function La(t,e){let r=[],n=0,i=t.length;for(;no.path===t);if(!e)throw new Error(`Invalid file path: "${t}"`);let r=null,n=et();if(Ro(t))r=await app.vault.cachedRead(e);else if(dn(t)){let o=JSON.parse(await app.vault.cachedRead(e)),s=[];for(let a of o.nodes)a.type==="text"?s.push(a.text):a.type==="file"&&s.push(a.file);for(let a of o.edges.filter(l=>!!l.label))s.push(a.label);r=s.join(`\r +`)}else if(n?.canFileBeExtracted(t))r=await n.extractText(e);else throw new Error(`Unsupported file type: "${t}"`);r==null&&(console.warn(`Omnisearch: ${r} content for file`,e.path),r=""),r=ft(r);let i=app.metadataCache.getFileCache(e);if(i&&i.frontmatter?.["excalidraw-plugin"]){let o=i.sections?.filter(s=>s.type==="comment")??[];for(let{start:s,end:a}of o.map(l=>l.position))r=r.substring(0,s.offset-1)+r.substring(a.offset)}return{basename:ft(e.basename),content:r,path:e.path,mtime:e.stat.mtime,tags:Ma(i),aliases:Pa(i).join(""),headings1:i?Jn(i,1).join(" "):"",headings2:i?Jn(i,2).join(" "):"",headings3:i?Jn(i,3).join(" "):""}}var Va=class{constructor(){this.nextQueryIsEmpty=!1;this.documents=new Map}async addToLiveCache(e){try{let r=await Dd(e);if(!r.path){console.error(`Missing .path field in IndexedDocument "${r.basename}", skipping`);return}this.documents.set(e,r)}catch(r){console.warn(`Omnisearch: Error while adding "${e}" to live cache`,r),this.removeFromLiveCache(e)}}removeFromLiveCache(e){this.documents.delete(e)}async getDocument(e){return this.documents.has(e)?this.documents.get(e):(fe("Generating IndexedDocument from",e),await this.addToLiveCache(e),this.documents.get(e))}async addToSearchHistory(e){if(!e){this.nextQueryIsEmpty=!0;return}this.nextQueryIsEmpty=!1;let r=await Be.searchHistory.toArray();r=r.filter(n=>n.query!==e).reverse(),r.unshift({query:e}),r=r.slice(0,10),await Be.searchHistory.clear(),await Be.searchHistory.bulkAdd(r)}async getSearchHistory(){let e=(await Be.searchHistory.toArray()).reverse().map(r=>r.query);return this.nextQueryIsEmpty&&e.unshift(""),e}getDocumentsChecksum(e){return Ra(JSON.stringify(e.sort((r,n)=>r.pathn.path?1:0)))}async getMinisearchCache(){try{return(await Be.minisearch.toArray())[0]}catch(e){return new za.Notice("Omnisearch - Cache missing or invalid. Some freezes may occur while Omnisearch indexes your vault."),console.error("Omnisearch - Error while loading Minisearch cache"),console.error(e),null}}async writeMinisearchCache(e,r){let n=Array.from(r).map(([i,o])=>({path:i,mtime:o}));await Be.minisearch.clear(),await Be.minisearch.add({date:new Date().toISOString(),paths:n,data:e.toJSON()}),console.log("Omnisearch - Search cache written")}},we=new Va;function Td(t){let e,r,n,i,o,s,a,l,u=t[8].default,d=tr(u,t,t[7],null);return{c(){e=R("div"),r=R("div"),n=R("input"),o=W(),d&&d.c(),B(n,"class","prompt-input"),B(n,"placeholder",t[0]),B(n,"spellcheck","false"),B(n,"type","text"),B(r,"class","omnisearch-input-field"),B(e,"class","omnisearch-input-container")},m(f,c){$(f,e,c),T(e,r),T(r,n),t[9](n),Ii(n,t[1]),T(e,o),d&&d.m(e,null),s=!0,a||(l=[Ke(n,"input",t[10]),Cs(i=t[3].call(null,n)),Ke(n,"compositionend",t[11]),Ke(n,"compositionstart",t[12]),Ke(n,"input",t[4])],a=!0)},p(f,[c]){(!s||c&1)&&B(n,"placeholder",f[0]),c&2&&n.value!==f[1]&&Ii(n,f[1]),d&&d.p&&(!s||c&128)&&nr(d,u,f,f[7],s?rr(u,f[7],c,null):ir(f[7]),null)},i(f){s||(ee(d,f),s=!0)},o(f){re(d,f),s=!1},d(f){f&&H(e),t[9](null),d&&d.d(f),a=!1,Ue(l)}}}function Id(t,e,r){let{$$slots:n={},$$scope:i}=e,{initialValue:o=""}=e,{placeholder:s=""}=e,a=!1,l="",u,d=Pi();function f(p){r(1,l=p)}function c(p){p&&!a&&!l&&(a=!0,r(1,l=p),y())}function y(p){mt().then(()=>(u.focus(),mt())).then(()=>{u.select()})}let w=(0,Ha.debounce)(()=>{we.addToSearchHistory(""),d("input",l)},300);function x(p){tt[p?"unshift":"push"](()=>{u=p,r(2,u)})}function b(){l=this.value,r(1,l)}let h=p=>ko(!1),_=p=>ko(!0);return t.$$set=p=>{"initialValue"in p&&r(5,o=p.initialValue),"placeholder"in p&&r(0,s=p.placeholder),"$$scope"in p&&r(7,i=p.$$scope)},t.$$.update=()=>{if(t.$$.dirty&32){e:c(o)}},[s,l,u,y,w,o,f,i,n,x,b,h,_]}var $a=class extends Ae{constructor(e){super();De(this,e,Id,Td,be,{initialValue:5,placeholder:0,setInputValue:6})}get setInputValue(){return this.$$.ctx[6]}},ei=$a;function Od(t){let e,r,n,i,o=t[1].default,s=tr(o,t,t[0],null);return{c(){e=R("div"),s&&s.c(),B(e,"class","prompt-results")},m(a,l){$(a,e,l),s&&s.m(e,null),r=!0,n||(i=Ke(e,"mousedown",kd),n=!0)},p(a,[l]){s&&s.p&&(!r||l&1)&&nr(s,o,a,a[0],r?rr(o,a[0],l,null):ir(a[0]),null)},i(a){r||(ee(s,a),r=!0)},o(a){re(s,a),r=!1},d(a){a&&H(e),s&&s.d(a),n=!1,i()}}}var kd=t=>t.preventDefault();function Pd(t,e,r){let{$$slots:n={},$$scope:i}=e;return t.$$set=o=>{"$$scope"in o&&r(0,i=o.$$scope)},[i,n]}var Wa=class extends Ae{constructor(e){super();De(this,e,Pd,Od,be,{})}},ti=Wa;var Lo=Fe(require("obsidian"));async function ri(t,e=!1){let r=St(t.foundWords);r.exec(t.content);let n=r.lastIndex,i=!1;app.workspace.iterateAllLeaves(a=>{a.view instanceof Lo.MarkdownView&&!e&&a.getViewState().state?.file===t.path&&a.getViewState()?.pinned&&(app.workspace.setActiveLeaf(a,{focus:!0}),i=!0)}),i||await app.workspace.openLinkText(t.path,"",e);let o=app.workspace.getActiveViewOfType(Lo.MarkdownView);if(!o)return;let s=o.editor.offsetToPos(n);s.ch=0,o.editor.setCursor(s),o.editor.scrollIntoView({from:{line:s.line-10,ch:0},to:{line:s.line+10,ch:0}})}async function Ua(t,e=!1){try{let r;switch(app.vault.getConfig("newFileLocation")){case"current":r=(app.workspace.getActiveFile()?.parent?.path??"")+"/";break;case"folder":r=app.vault.getConfig("newFileFolderPath")+"/";break;default:r="";break}await app.workspace.openLinkText(`${r}${t}.md`,"",e)}catch(r){throw r.message="OmniSearch - Could not create note: "+r.message,console.error(r),r}}function Md(t){let e;return{c(){e=R("span"),e.innerHTML='',B(e,"class","suggestion-flair"),B(e,"aria-label","Not created yet, select to create")},m(r,n){$(r,e,n)},p:ce,i:ce,o:ce,d(r){r&&H(e)}}}function Rd(t){"use strict";return[]}var Ga=class extends Ae{constructor(e){super();De(this,e,Rd,Md,be,{})}},Qa=Ga;function qa(t){let e,r;return e=new Qa({}),{c(){Le(e.$$.fragment)},m(n,i){ke(e,n,i),r=!0},i(n){r||(ee(e.$$.fragment,n),r=!0)},o(n){re(e.$$.fragment,n),r=!1},d(n){Ee(e,n)}}}function Ld(t){let e,r,n,i,o,s=t[2]&&qa(t),a=t[4].default,l=tr(a,t,t[3],null);return{c(){e=R("div"),s&&s.c(),r=W(),l&&l.c(),B(e,"data-result-id",t[0]),B(e,"class","suggestion-item omnisearch-result"),Oi(e,"is-selected",t[1])},m(u,d){$(u,e,d),s&&s.m(e,null),T(e,r),l&&l.m(e,null),n=!0,i||(o=[Ke(e,"mousemove",t[5]),Ke(e,"click",t[6]),Ke(e,"auxclick",t[7])],i=!0)},p(u,[d]){u[2]?s?d&4&&ee(s,1):(s=qa(u),s.c(),ee(s,1),s.m(e,r)):s&&(Lt(),re(s,1,1,()=>{s=null}),Bt()),l&&l.p&&(!n||d&8)&&nr(l,a,u,u[3],n?rr(a,u[3],d,null):ir(u[3]),null),(!n||d&1)&&B(e,"data-result-id",u[0]),(!n||d&2)&&Oi(e,"is-selected",u[1])},i(u){n||(ee(s),ee(l,u),n=!0)},o(u){re(s),re(l,u),n=!1},d(u){u&&H(e),s&&s.d(),l&&l.d(u),i=!1,Ue(o)}}}function Bd(t,e,r){let{$$slots:n={},$$scope:i}=e,{id:o}=e,{selected:s=!1}=e,{glyph:a=!1}=e;function l(f){$e.call(this,t,f)}function u(f){$e.call(this,t,f)}function d(f){$e.call(this,t,f)}return t.$$set=f=>{"id"in f&&r(0,o=f.id),"selected"in f&&r(1,s=f.selected),"glyph"in f&&r(2,a=f.glyph),"$$scope"in f&&r(3,i=f.$$scope)},[o,s,a,i,n,l,u,d]}var Ya=class extends Ae{constructor(e){super();De(this,e,Bd,Ld,be,{id:0,selected:1,glyph:2})}},ni=Ya;var vr=Fe(require("obsidian"));function Ja(t){let e,r=t[1].matches.length+"",n,i,o=(t[1].matches.length>1?"matches":"match")+"",s;return{c(){e=R("span"),n=xe(r),i=xe("\xA0"),s=xe(o),B(e,"class","omnisearch-result__counter")},m(a,l){$(a,e,l),T(e,n),T(e,i),T(e,s)},p(a,l){l&2&&r!==(r=a[1].matches.length+"")&&Ge(n,r),l&2&&o!==(o=(a[1].matches.length>1?"matches":"match")+"")&&Ge(s,o)},d(a){a&&H(e)}}}function Xa(t){let e,r,n,i,o;return{c(){e=R("div"),r=R("span"),n=W(),i=R("span"),o=xe(t[6]),B(e,"class","omnisearch-result__folder-path")},m(s,a){$(s,e,a),T(e,r),t[12](r),T(e,n),T(e,i),T(i,o)},p(s,a){a&64&&Ge(o,s[6])},d(s){s&&H(e),t[12](null)}}}function Za(t){let e,r=t[8].replace(t[9],At)+"";return{c(){e=R("div"),B(e,"class","omnisearch-result__body")},m(n,i){$(n,e,i),e.innerHTML=r},p(n,i){i&768&&r!==(r=n[8].replace(n[9],At)+"")&&(e.innerHTML=r)},d(n){n&&H(e)}}}function el(t){let e,r,n;return{c(){e=R("div"),r=R("img"),ze(r,"width","100px"),Ti(r.src,n=t[5])||B(r,"src",n),B(r,"alt",""),B(e,"class","omnisearch-result__image-container")},m(i,o){$(i,e,o),T(e,r)},p(i,o){o&32&&!Ti(r.src,n=i[5])&&B(r,"src",n)},d(i){i&&H(e)}}}function Nd(t){let e,r,n,i,o,s,a=t[2].replace(t[9],At)+"",l,u,d,f=qt(t[1].path)+"",c,y,w,x,b,h,_=t[1].matches.length>0&&Ja(t),p=t[6]&&Xa(t),m=t[10]&&Za(t),v=t[5]&&el(t);return{c(){e=R("div"),r=R("div"),n=R("span"),i=R("span"),o=W(),s=R("span"),l=W(),u=R("span"),d=xe("."),c=xe(f),y=W(),_&&_.c(),w=W(),p&&p.c(),x=W(),b=R("div"),m&&m.c(),h=W(),v&&v.c(),B(u,"class","omnisearch-result__extension"),B(n,"class","omnisearch-result__title"),B(r,"class","omnisearch-result__title-container"),ze(b,"display","flex"),ze(b,"flex-direction","row")},m(g,j){$(g,e,j),T(e,r),T(r,n),T(n,i),t[11](i),T(n,o),T(n,s),s.innerHTML=a,T(n,l),T(n,u),T(u,d),T(u,c),T(n,y),_&&_.m(n,null),T(e,w),p&&p.m(e,null),T(e,x),T(e,b),m&&m.m(b,null),T(b,h),v&&v.m(b,null)},p(g,j){j&516&&a!==(a=g[2].replace(g[9],At)+"")&&(s.innerHTML=a),j&2&&f!==(f=qt(g[1].path)+"")&&Ge(c,f),g[1].matches.length>0?_?_.p(g,j):(_=Ja(g),_.c(),_.m(n,null)):_&&(_.d(1),_=null),g[6]?p?p.p(g,j):(p=Xa(g),p.c(),p.m(e,x)):p&&(p.d(1),p=null),g[10]?m?m.p(g,j):(m=Za(g),m.c(),m.m(b,h)):m&&(m.d(1),m=null),g[5]?v?v.p(g,j):(v=el(g),v.c(),v.m(b,null)):v&&(v.d(1),v=null)},d(g){g&&H(e),t[11](null),_&&_.d(),p&&p.d(),m&&m.d(),v&&v.d()}}}function Kd(t){let e,r;return e=new ni({props:{glyph:t[7],id:t[1].path,selected:t[0],$$slots:{default:[Nd]},$$scope:{ctx:t}}}),e.$on("click",t[13]),e.$on("auxclick",t[14]),e.$on("mousemove",t[15]),{c(){Le(e.$$.fragment)},m(n,i){ke(e,n,i),r=!0},p(n,[i]){let o={};i&128&&(o.glyph=n[7]),i&2&&(o.id=n[1].path),i&1&&(o.selected=n[0]),i&67454&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){r||(ee(e.$$.fragment,n),r=!0)},o(n){re(e.$$.fragment,n),r=!1},d(n){Ee(e,n)}}}function zd(t,e,r){let n,i,o,s;_n(t,Ut,p=>r(10,s=p));let{selected:a=!1}=e,{note:l}=e,u=null,d="",f="",c,y;function w(p){tt[p?"unshift":"push"](()=>{y=p,r(4,y)})}function x(p){tt[p?"unshift":"push"](()=>{c=p,r(3,c)})}function b(p){$e.call(this,t,p)}function h(p){$e.call(this,t,p)}function _(p){$e.call(this,t,p)}t.$$set=p=>{"selected"in p&&r(0,a=p.selected),"note"in p&&r(1,l=p.note)},t.$$.update=()=>{if(t.$$.dirty&2){e:if(r(5,u=null),Zn(l.path)){let p=app.vault.getFiles().find(m=>m.path===l.path);p&&r(5,u=app.vault.getResourcePath(p))}}if(t.$$.dirty&2){e:r(9,n=St(l.foundWords))}if(t.$$.dirty&2){e:r(8,i=yr(l.content,l.matches[0]?.offset??-1))}if(t.$$.dirty&30){e:r(2,d=l.basename),r(6,f=ka(l.path)),I.ignoreDiacritics&&r(2,d=ft(d)),c&&(0,vr.setIcon)(c,"folder-open"),y&&(Zn(l.path)?(0,vr.setIcon)(y,"image"):fn(l.path)?(0,vr.setIcon)(y,"file-text"):dn(l.path)?(0,vr.setIcon)(y,"layout-dashboard"):(0,vr.setIcon)(y,"file"))}};e:r(7,o=!1);return[a,l,d,c,y,u,f,o,i,n,s,w,x,b,h,_]}var tl=class extends Ae{constructor(e){super();De(this,e,zd,Kd,be,{selected:0,note:1})}},rl=tl;var sl=Fe(ol()),Bo=["ext","path"],Yt=class{constructor(e=""){this.extensions=[];I.ignoreDiacritics&&(e=ft(e));let r=(0,sl.parse)(e.toLowerCase(),{tokenize:!0,keywords:Bo});r.text=r.text??[],r.exclude=r.exclude??{},r.exclude.text=r.exclude.text??[],Array.isArray(r.exclude.text)||(r.exclude.text=[r.exclude.text]);for(let n of Bo){let i=r[n];i&&(r[n]=Array.isArray(i)?i:[i]);let o=r.exclude[n];o&&(r.exclude[n]=Array.isArray(o)?o:[o])}this.query=r,this.extensions=this.query.ext??[]}isEmpty(){for(let e of Bo)if(this.query[e]?.length||this.query.text.length)return!1;return!0}segmentsToStr(){return this.query.text.join(" ")}getTags(){return this.query.text.filter(e=>e.startsWith("#"))}getTagsWithoutHashtag(){return this.getTags().map(e=>e.replace(/^#/,""))}getExactTerms(){return this.query.text.filter(e=>e.split(" ").length>1)}};var ae=function(){return ae=Object.assign||function(e){for(var r,n=1,i=arguments.length;n0&&o[o.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function me(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o}var $d="ENTRIES",al="KEYS",ll="VALUES",Se="",No=function(){function t(e,r){var n=e._tree,i=Array.from(n.keys());this.set=e,this._type=r,this._path=i.length>0?[{node:n,keys:i}]:[]}return t.prototype.next=function(){var e=this.dive();return this.backtrack(),e},t.prototype.dive=function(){if(this._path.length===0)return{done:!0,value:void 0};var e=_r(this._path),r=e.node,n=e.keys;if(_r(n)===Se)return{done:!1,value:this.result()};var i=r.get(_r(n));return this._path.push({node:i,keys:Array.from(i.keys())}),this.dive()},t.prototype.backtrack=function(){if(this._path.length!==0){var e=_r(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack())}},t.prototype.key=function(){return this.set._prefix+this._path.map(function(e){var r=e.keys;return _r(r)}).filter(function(e){return e!==Se}).join("")},t.prototype.value=function(){return _r(this._path).node.get(Se)},t.prototype.result=function(){switch(this._type){case ll:return this.value();case al:return this.key();default:return[this.key(),this.value()]}},t.prototype[Symbol.iterator]=function(){return this},t}(),_r=function(t){return t[t.length-1]},Wd=function(t,e,r){var n=new Map;if(e===void 0)return n;for(var i=e.length+1,o=i+r,s=new Uint8Array(o*i).fill(r+1),a=0;ar)continue e}ul(t.get(y),e,r,n,i,x,s,a+y)}}}catch(k){l={error:k}}finally{try{c&&!c.done&&(u=f.return)&&u.call(f)}finally{if(l)throw l.error}}},Ko=function(){function t(e,r){e===void 0&&(e=new Map),r===void 0&&(r=""),this._size=void 0,this._tree=e,this._prefix=r}return t.prototype.atPrefix=function(e){var r,n;if(!e.startsWith(this._prefix))throw new Error("Mismatched prefix");var i=me(oi(this._tree,e.slice(this._prefix.length)),2),o=i[0],s=i[1];if(o===void 0){var a=me(Ho(s),2),l=a[0],u=a[1];try{for(var d=G(l.keys()),f=d.next();!f.done;f=d.next()){var c=f.value;if(c!==Se&&c.startsWith(u)){var y=new Map;return y.set(c.slice(u.length),l.get(c)),new t(y,e)}}}catch(w){r={error:w}}finally{try{f&&!f.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}}return new t(o,e)},t.prototype.clear=function(){this._size=void 0,this._tree.clear()},t.prototype.delete=function(e){return this._size=void 0,Ud(this._tree,e)},t.prototype.entries=function(){return new No(this,$d)},t.prototype.forEach=function(e){var r,n;try{for(var i=G(this),o=i.next();!o.done;o=i.next()){var s=me(o.value,2),a=s[0],l=s[1];e(a,l,this)}}catch(u){r={error:u}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}},t.prototype.fuzzyGet=function(e,r){return Wd(this._tree,e,r)},t.prototype.get=function(e){var r=zo(this._tree,e);return r!==void 0?r.get(Se):void 0},t.prototype.has=function(e){var r=zo(this._tree,e);return r!==void 0&&r.has(Se)},t.prototype.keys=function(){return new No(this,al)},t.prototype.set=function(e,r){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var n=Vo(this._tree,e);return n.set(Se,r),this},Object.defineProperty(t.prototype,"size",{get:function(){if(this._size)return this._size;this._size=0;for(var e=this.entries();!e.next().done;)this._size+=1;return this._size},enumerable:!1,configurable:!0}),t.prototype.update=function(e,r){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var n=Vo(this._tree,e);return n.set(Se,r(n.get(Se))),this},t.prototype.fetch=function(e,r){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var n=Vo(this._tree,e),i=n.get(Se);return i===void 0&&n.set(Se,i=r()),i},t.prototype.values=function(){return new No(this,ll)},t.prototype[Symbol.iterator]=function(){return this.entries()},t.from=function(e){var r,n,i=new t;try{for(var o=G(e),s=o.next();!s.done;s=o.next()){var a=me(s.value,2),l=a[0],u=a[1];i.set(l,u)}}catch(d){r={error:d}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i},t.fromObject=function(e){return t.from(Object.entries(e))},t}(),oi=function(t,e,r){var n,i;if(r===void 0&&(r=[]),e.length===0||t==null)return[t,r];try{for(var o=G(t.keys()),s=o.next();!s.done;s=o.next()){var a=s.value;if(a!==Se&&e.startsWith(a))return r.push([t,a]),oi(t.get(a),e.slice(a.length),r)}}catch(l){n={error:l}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return r.push([t,e]),oi(void 0,"",r)},zo=function(t,e){var r,n;if(e.length===0||t==null)return t;try{for(var i=G(t.keys()),o=i.next();!o.done;o=i.next()){var s=o.value;if(s!==Se&&e.startsWith(s))return zo(t.get(s),e.slice(s.length))}}catch(a){r={error:a}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}},Vo=function(t,e){var r,n,i=e.length;e:for(var o=0;t&&o0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new Ko,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}},t.prototype.discard=function(e){var r=this,n=this._idToShortId.get(e);if(n==null)throw new Error("MiniSearch: cannot discard document with ID ".concat(e,": it is not in the index"));this._idToShortId.delete(e),this._documentIds.delete(n),this._storedFields.delete(n),(this._fieldLength.get(n)||[]).forEach(function(i,o){r.removeFieldLength(n,o,r._documentCount,i)}),this._fieldLength.delete(n),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()},t.prototype.maybeAutoVacuum=function(){if(this._options.autoVacuum!==!1){var e=this._options.autoVacuum,r=e.minDirtFactor,n=e.minDirtCount,i=e.batchSize,o=e.batchWait;this.conditionalVacuum({batchSize:i,batchWait:o},{minDirtCount:n,minDirtFactor:r})}},t.prototype.discardAll=function(e){var r,n,i=this._options.autoVacuum;try{this._options.autoVacuum=!1;try{for(var o=G(e),s=o.next();!s.done;s=o.next()){var a=s.value;this.discard(a)}}catch(l){r={error:l}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}finally{this._options.autoVacuum=i}this.maybeAutoVacuum()},t.prototype.replace=function(e){var r=this._options,n=r.idField,i=r.extractField,o=i(e,n);this.discard(o),this.add(e)},t.prototype.vacuum=function(e){return e===void 0&&(e={}),this.conditionalVacuum(e)},t.prototype.conditionalVacuum=function(e,r){var n=this;return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&r,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(function(){var i=n._enqueuedVacuumConditions;return n._enqueuedVacuumConditions=qo,n.performVacuuming(e,i)}),this._enqueuedVacuum)):this.vacuumConditionsMet(r)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(e),this._currentVacuum)},t.prototype.performVacuuming=function(e,r){return Vd(this,void 0,void 0,function(){var n,i,o,s,a,l,u,d,f,c,y,w,x,b,h,_,p,m,v,g,j,C,S,E,P;return Hd(this,function(L){switch(L.label){case 0:if(n=this._dirtCount,!this.vacuumConditionsMet(r))return[3,10];i=e.batchSize||Qo.batchSize,o=e.batchWait||Qo.batchWait,s=1,L.label=1;case 1:L.trys.push([1,7,8,9]),a=G(this._index),l=a.next(),L.label=2;case 2:if(l.done)return[3,6];u=me(l.value,2),d=u[0],f=u[1];try{for(c=(C=void 0,G(f)),y=c.next();!y.done;y=c.next()){w=me(y.value,2),x=w[0],b=w[1];try{for(h=(E=void 0,G(b)),_=h.next();!_.done;_=h.next())p=me(_.value,1),m=p[0],!this._documentIds.has(m)&&(b.size<=1?f.delete(x):b.delete(m))}catch(k){E={error:k}}finally{try{_&&!_.done&&(P=h.return)&&P.call(h)}finally{if(E)throw E.error}}}}catch(k){C={error:k}}finally{try{y&&!y.done&&(S=c.return)&&S.call(c)}finally{if(C)throw C.error}}return this._index.get(d).size===0&&this._index.delete(d),s%i!=0?[3,4]:[4,new Promise(function(k){return setTimeout(k,o)})];case 3:L.sent(),L.label=4;case 4:s+=1,L.label=5;case 5:return l=a.next(),[3,2];case 6:return[3,9];case 7:return v=L.sent(),g={error:v},[3,9];case 8:try{l&&!l.done&&(j=a.return)&&j.call(a)}finally{if(g)throw g.error}return[7];case 9:this._dirtCount-=n,L.label=10;case 10:return[4,null];case 11:return L.sent(),this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null,[2]}})})},t.prototype.vacuumConditionsMet=function(e){if(e==null)return!0;var r=e.minDirtCount,n=e.minDirtFactor;return r=r||Yo.minDirtCount,n=n||Yo.minDirtFactor,this.dirtCount>=r&&this.dirtFactor>=n},Object.defineProperty(t.prototype,"isVacuuming",{get:function(){return this._currentVacuum!=null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dirtCount",{get:function(){return this._dirtCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dirtFactor",{get:function(){return this._dirtCount/(1+this._documentCount+this._dirtCount)},enumerable:!1,configurable:!0}),t.prototype.has=function(e){return this._idToShortId.has(e)},t.prototype.search=function(e,r){var n,i;r===void 0&&(r={});var o=this.executeQuery(e,r),s=[];try{for(var a=G(o),l=a.next();!l.done;l=a.next()){var u=me(l.value,2),d=u[0],f=u[1],c=f.score,y=f.terms,w=f.match,x=y.length,b={id:this._documentIds.get(d),score:c*x,terms:Object.keys(w),match:w};Object.assign(b,this._storedFields.get(d)),(r.filter==null||r.filter(b))&&s.push(b)}}catch(h){n={error:h}}finally{try{l&&!l.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return s.sort(ml),s},t.prototype.autoSuggest=function(e,r){var n,i,o,s;r===void 0&&(r={}),r=ae(ae({},this._options.autoSuggestOptions),r);var a=new Map;try{for(var l=G(this.search(e,r)),u=l.next();!u.done;u=l.next()){var d=u.value,f=d.score,c=d.terms,y=c.join(" "),w=a.get(y);w!=null?(w.score+=f,w.count+=1):a.set(y,{score:f,terms:c,count:1})}}catch(v){n={error:v}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}var x=[];try{for(var b=G(a),h=b.next();!h.done;h=b.next()){var _=me(h.value,2),w=_[0],p=_[1],f=p.score,c=p.terms,m=p.count;x.push({suggestion:w,terms:c,score:f/m})}}catch(v){o={error:v}}finally{try{h&&!h.done&&(s=b.return)&&s.call(b)}finally{if(o)throw o.error}}return x.sort(ml),x},Object.defineProperty(t.prototype,"documentCount",{get:function(){return this._documentCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"termCount",{get:function(){return this._index.size},enumerable:!1,configurable:!0}),t.loadJSON=function(e,r){if(r==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(e),r)},t.getDefault=function(e){if(Go.hasOwnProperty(e))return Uo(Go,e);throw new Error('MiniSearch: unknown option "'.concat(e,'"'))},t.loadJS=function(e,r){var n,i,o,s,a,l,u=e.index,d=e.documentCount,f=e.nextId,c=e.documentIds,y=e.fieldIds,w=e.fieldLength,x=e.averageFieldLength,b=e.storedFields,h=e.dirtCount,_=e.serializationVersion;if(_!==1&&_!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");var p=new t(r);p._documentCount=d,p._nextId=f,p._documentIds=si(c),p._idToShortId=new Map,p._fieldIds=y,p._fieldLength=si(w),p._avgFieldLength=x,p._storedFields=si(b),p._dirtCount=h||0,p._index=new Ko;try{for(var m=G(p._documentIds),v=m.next();!v.done;v=m.next()){var g=me(v.value,2),j=g[0],C=g[1];p._idToShortId.set(C,j)}}catch(F){n={error:F}}finally{try{v&&!v.done&&(i=m.return)&&i.call(m)}finally{if(n)throw n.error}}try{for(var S=G(u),E=S.next();!E.done;E=S.next()){var P=me(E.value,2),L=P[0],k=P[1],z=new Map;try{for(var J=(a=void 0,G(Object.keys(k))),Q=J.next();!Q.done;Q=J.next()){var Z=Q.value,A=k[Z];_===1&&(A=A.ds),z.set(parseInt(Z,10),si(A))}}catch(F){a={error:F}}finally{try{Q&&!Q.done&&(l=J.return)&&l.call(J)}finally{if(a)throw a.error}}p._index.set(L,z)}}catch(F){o={error:F}}finally{try{E&&!E.done&&(s=S.return)&&s.call(S)}finally{if(o)throw o.error}}return p},t.prototype.executeQuery=function(e,r){var n=this;if(r===void 0&&(r={}),typeof e!="string"){var i=ae(ae(ae({},r),e),{queries:void 0}),o=e.queries.map(function(b){return n.executeQuery(b,i)});return this.combineResults(o,e.combineWith)}var s=this._options,a=s.tokenize,l=s.processTerm,u=s.searchOptions,d=ae(ae({tokenize:a,processTerm:l},u),r),f=d.tokenize,c=d.processTerm,y=f(e).flatMap(function(b){return c(b)}).filter(function(b){return!!b}),w=y.map(Jd(d)),x=w.map(function(b){return n.executeQuerySpec(b,d)});return this.combineResults(x,d.combineWith)},t.prototype.executeQuerySpec=function(e,r){var n,i,o,s,a=ae(ae({},this._options.searchOptions),r),l=(a.fields||this._options.fields).reduce(function(Z,A){var F;return ae(ae({},Z),(F={},F[A]=Uo(Z,A)||1,F))},a.boost||{}),u=a.boostDocument,d=a.weights,f=a.maxFuzzy,c=a.bm25,y=ae(ae({},hl.weights),d),w=y.fuzzy,x=y.prefix,b=this._index.get(e.term),h=this.termResults(e.term,e.term,1,b,l,u,c),_,p;if(e.prefix&&(_=this._index.atPrefix(e.term)),e.fuzzy){var m=e.fuzzy===!0?.2:e.fuzzy,v=m<1?Math.min(f,Math.round(e.term.length*m)):m;v&&(p=this._index.fuzzyGet(e.term,v))}if(_)try{for(var g=G(_),j=g.next();!j.done;j=g.next()){var C=me(j.value,2),S=C[0],E=C[1],P=S.length-e.term.length;if(!!P){p==null||p.delete(S);var L=x*S.length/(S.length+.3*P);this.termResults(e.term,S,L,E,l,u,c,h)}}}catch(Z){n={error:Z}}finally{try{j&&!j.done&&(i=g.return)&&i.call(g)}finally{if(n)throw n.error}}if(p)try{for(var k=G(p.keys()),z=k.next();!z.done;z=k.next()){var S=z.value,J=me(p.get(S),2),Q=J[0],P=J[1];if(!!P){var L=w*S.length/(S.length+P);this.termResults(e.term,S,L,Q,l,u,c,h)}}}catch(Z){o={error:Z}}finally{try{z&&!z.done&&(s=k.return)&&s.call(k)}finally{if(o)throw o.error}}return h},t.prototype.combineResults=function(e,r){if(r===void 0&&(r=$o),e.length===0)return new Map;var n=r.toLowerCase();return e.reduce(Qd[n])||new Map},t.prototype.toJSON=function(){var e,r,n,i,o=[];try{for(var s=G(this._index),a=s.next();!a.done;a=s.next()){var l=me(a.value,2),u=l[0],d=l[1],f={};try{for(var c=(n=void 0,G(d)),y=c.next();!y.done;y=c.next()){var w=me(y.value,2),x=w[0],b=w[1];f[x]=Object.fromEntries(b)}}catch(h){n={error:h}}finally{try{y&&!y.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}o.push([u,f])}}catch(h){e={error:h}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:o,serializationVersion:2}},t.prototype.termResults=function(e,r,n,i,o,s,a,l){var u,d,f,c,y;if(l===void 0&&(l=new Map),i==null)return l;try{for(var w=G(Object.keys(o)),x=w.next();!x.done;x=w.next()){var b=x.value,h=o[b],_=this._fieldIds[b],p=i.get(_);if(p!=null){var m=p.size,v=this._avgFieldLength[_];try{for(var g=(f=void 0,G(p.keys())),j=g.next();!j.done;j=g.next()){var C=j.value;if(!this._documentIds.has(C)){this.removeTerm(_,C,r),m-=1;continue}var S=s?s(this._documentIds.get(C),r):1;if(!!S){var E=p.get(C),P=this._fieldLength.get(C)[_],L=Yd(E,m,this._documentCount,P,v,a),k=n*h*S*L,z=l.get(C);if(z){z.score+=k,Zd(z.terms,e);var J=Uo(z.match,r);J?J.push(b):z.match[r]=[b]}else l.set(C,{score:k,terms:[e],match:(y={},y[r]=[b],y)})}}}catch(Q){f={error:Q}}finally{try{j&&!j.done&&(c=g.return)&&c.call(g)}finally{if(f)throw f.error}}}}}catch(Q){u={error:Q}}finally{try{x&&!x.done&&(d=w.return)&&d.call(w)}finally{if(u)throw u.error}}return l},t.prototype.addTerm=function(e,r,n){var i=this._index.fetch(n,gl),o=i.get(e);if(o==null)o=new Map,o.set(r,1),i.set(e,o);else{var s=o.get(r);o.set(r,(s||0)+1)}},t.prototype.removeTerm=function(e,r,n){if(!this._index.has(n)){this.warnDocumentChanged(r,e,n);return}var i=this._index.fetch(n,gl),o=i.get(e);o==null||o.get(r)==null?this.warnDocumentChanged(r,e,n):o.get(r)<=1?o.size<=1?i.delete(e):o.delete(r):o.set(r,o.get(r)-1),this._index.get(n).size===0&&this._index.delete(n)},t.prototype.warnDocumentChanged=function(e,r,n){var i,o;try{for(var s=G(Object.keys(this._fieldIds)),a=s.next();!a.done;a=s.next()){var l=a.value;if(this._fieldIds[l]===r){this._options.logger("warn","MiniSearch: document with ID ".concat(this._documentIds.get(e),' has changed before removal: term "').concat(n,'" was not present in field "').concat(l,'". Removing a document after it has changed can corrupt the index!'),"version_conflict");return}}}catch(u){i={error:u}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}},t.prototype.addDocumentId=function(e){var r=this._nextId;return this._idToShortId.set(e,r),this._documentIds.set(r,e),this._documentCount+=1,this._nextId+=1,r},t.prototype.addFields=function(e){for(var r=0;r0){if(++e>=$h)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var Tl=Gh;function Qh(t){return function(){return t}}var Il=Qh;var qh=function(){try{var t=Ne(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Jo=qh;var Yh=Jo?function(t,e){return Jo(t,"toString",{configurable:!0,enumerable:!1,value:Il(e),writable:!0})}:Et,Ol=Yh;var Jh=Tl(Ol),kl=Jh;var Xh=9007199254740991,Zh=/^(?:0|[1-9]\d*)$/;function ep(t,e){var r=typeof t;return e=e??Xh,!!e&&(r=="number"||r!="symbol"&&Zh.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=ip}var jr=op;function sp(t){return t!=null&&jr(t.length)&&!li(t)}var Dt=sp;function ap(t,e,r){if(!Ft(r))return!1;var n=typeof e;return(n=="number"?Dt(r)&&xr(e,r.length):n=="string"&&e in r)?wr(r[e],t):!1}var Xo=ap;var lp=Object.prototype;function up(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||lp;return t===r}var Ll=up;function cp(t,e){for(var r=-1,n=Array(t);++r-1}var ou=Am;function Sm(t,e){var r=this.__data__,n=Tt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}var su=Sm;function Er(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e0&&r(a)?e>1?bu(a,e-1,r,n,i):pi(i,a):n||(i[i.length]=a)}return i}var xu=bu;function qm(){this.__data__=new It,this.size=0}var wu=qm;function Ym(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ju=Ym;function Jm(t){return this.__data__.get(t)}var Cu=Jm;function Xm(t){return this.__data__.has(t)}var Au=Xm;var Zm=200;function eg(t,e){var r=this.__data__;if(r instanceof It){var n=r.__data__;if(!Ot||n.lengtha))return!1;var u=o.get(t),d=o.get(e);if(u&&d)return u==e&&d==t;var f=-1,c=!0,y=r&Cg?new Nu:void 0;for(o.set(t,e),o.set(e,t);++fe||o&&s&&l&&!a&&!u||n&&s&&l||!r&&l||!i)return 1;if(!n&&!o&&!u&&t=a)return l;var u=r[n];return l*(u=="desc"?-1:1)}}return t.index-e.index}var yc=by;function xy(t,e,r){e.length?e=br(e,function(o){return de(o)?function(s){return Tr(s,o.length===1?o[0]:o)}:o}):e=[Et];var n=-1;e=br(e,fi(lc));var i=pc(t,function(o,s,a){var l=br(e,function(u){return u(o)});return{criteria:l,index:++n,value:o}});return mc(i,function(o,s){return yc(o,s,r)})}var vc=xy;var wy=Rl(function(t,e){if(t==null)return[];var r=e.length;return r>1&&Xo(t,e[0],e[1])?e=[]:r>2&&Xo(e[0],e[1],e[2])&&(e=[e[0]]),vc(t,xu(e,1),[])}),ls=wy;var jy=t=>{let e=t.split(Ct),r=Yn();return r?e.flatMap(n=>Aa.test(n)?r.cut(n):[n]):I.splitCamelCase?[...e,...e.flatMap(Ba)]:e},Ci=class{constructor(){this.indexedDocuments=new Map;this.minisearch=new Wo(Ci.options)}async loadCache(){let e=await we.getMinisearchCache();return e?(this.minisearch=Wo.loadJS(e.data,Ci.options),this.indexedDocuments=new Map(e.paths.map(r=>[r.path,r.mtime])),!0):(console.log("Omnisearch - No cache found"),!1)}getDiff(e){let r=new Map(e.map(o=>[o.path,o.mtime])),n=e.filter(o=>!this.indexedDocuments.has(o.path)||this.indexedDocuments.get(o.path)!==o.mtime),i=[...this.indexedDocuments].filter(([o,s])=>!r.has(o)||r.get(o)!==s).map(o=>({path:o[0],mtime:o[1]}));return{toAdd:n,toRemove:i}}async addFromPaths(e){fe("Adding files",e);let r=(await Promise.all(e.map(async i=>await we.getDocument(i)))).filter(i=>!!i?.path);fe("Sorting documents to first index markdown"),r=ls(r,i=>i.path.endsWith(".md")?0:1),this.removeFromPaths(r.filter(i=>this.indexedDocuments.has(i.path)).map(i=>i.path));let n=La(r,500);for(let i of n){fe("Indexing into search engine",i),i.forEach(s=>this.indexedDocuments.set(s.path,s.mtime));let o=i.filter(s=>this.minisearch.has(s.path));this.removeFromPaths(o.map(s=>s.path)),await this.minisearch.addAllAsync(i)}}removeFromPaths(e){e.forEach(n=>this.indexedDocuments.delete(n));let r=e.filter(n=>this.minisearch.has(n));this.minisearch.discardAll(r)}async search(e,r){if(e.isEmpty())return[];fe("Starting search for",e);let n=this.minisearch.search(e.segmentsToStr(),{prefix:l=>l.length>=r.prefixLength,fuzzy:l=>l.length<=3?0:l.length<=5?.1:.2,combineWith:"AND",boost:{basename:I.weightBasename,directory:I.weightDirectory,aliases:I.weightBasename,headings1:I.weightH1,headings2:I.weightH2,headings3:I.weightH3}});if(fe("Found",n.length,"results"),e.query.ext?.length&&(n=n.filter(l=>{let u="."+l.id.split(".").pop();return e.query.ext?.some(d=>u.startsWith(d.startsWith(".")?d:"."+d))}),console.log(e.query.ext,n.length)),e.query.path&&(n=n.filter(l=>e.query.path?.some(u=>l.id.toLowerCase().includes(u.toLowerCase())))),e.query.exclude.path&&(n=n.filter(l=>!e.query.exclude.path?.some(u=>l.id.toLowerCase().includes(u.toLowerCase())))),!n.length)return[];if(r.singleFilePath)return n.filter(l=>l.id===r.singleFilePath);I.hideExcluded?n=n.filter(l=>!(app.metadataCache.isUserIgnored&&app.metadataCache.isUserIgnored(l.id))):n.forEach(l=>{app.metadataCache.isUserIgnored&&app.metadataCache.isUserIgnored(l.id)&&(l.score/=10)});let i=e.getTags();for(let l of i)for(let u of n)(u.tags??[]).includes(l)&&(u.score*=100);fe("Sorting and limiting results"),n=n.sort((l,u)=>u.score-l.score).slice(0,50);let o=await Promise.all(n.map(async l=>await we.getDocument(l.id))),s=e.getExactTerms();s.length&&(fe("Filtering with quoted terms"),n=n.filter(l=>{let u=o.find(c=>c.path===l.id),d=u?.path.toLowerCase()??"",f=Mo(u?.content??"").toLowerCase();return s.every(c=>f.includes(c)||d.includes(c))}));let a=e.query.exclude.text;return a.length&&(fe("Filtering with exclusions"),n=n.filter(l=>{let u=Mo(o.find(d=>d.path===l.id)?.content??"").toLowerCase();return a.every(d=>!u.includes(d))})),fe("Deduping"),n=n.filter((l,u,d)=>d.findIndex(f=>f.id===l.id)===u),n}getMatches(e,r,n){let i=new Date().getTime(),o=null,s=[],a=0;for(;(o=r.exec(e))!==null;){if(++a>=100||new Date().getTime()-i>50){Na("Stopped getMatches at",a,"results");break}let u=o[0];u&&s.push({match:u,offset:o.index})}let l=e.toLowerCase().indexOf(n.segmentsToStr());return l>-1&&s.unshift({offset:l,match:n.segmentsToStr()}),s}async getSuggestions(e,r){let n;I.simpleSearch?n=await this.search(e,{prefixLength:3,singleFilePath:r?.singleFilePath}):n=await this.search(e,{prefixLength:1,singleFilePath:r?.singleFilePath});let i=await Promise.all(n.map(async s=>await we.getDocument(s.id)));return n.map(s=>{fe("Locating matches for",s.id);let a=i.find(f=>f.path===s.id);a||(console.warn(`Omnisearch - Note "${s.id}" not in the live cache`),a={content:"",basename:s.id,path:s.id});let l=[...Object.keys(s.match),...e.getExactTerms(),...e.getTags()].filter(f=>f.length>1||/\p{Emoji}/u.test(f));fe("Matching tokens:",l),fe("Getting matches locations...");let u=this.getMatches(a.content,St(l),e);return fe("Matches:",u),ue({score:s.score,foundWords:l,matches:u},a)})}async writeToCache(){await we.writeMinisearchCache(this.minisearch,this.indexedDocuments)}},us=Ci;us.options={tokenize:jy,extractField:(e,r)=>{if(r==="directory"){let n=e.path.split("/");return n.pop(),n.join("/")}return e[r]},processTerm:e=>(I.ignoreDiacritics?ft(e):e).toLowerCase(),idField:"path",fields:["basename","directory","aliases","content","headings1","headings2","headings3"],storeFields:["tags"],logger(e,r,n){n==="version_conflict"&&new _c.Notice("Omnisearch - Your index cache may be incorrect or corrupted. If this message keeps appearing, go to Settings to clear the cache.",5e3)}};var ve=new us;var cs=new Set;function bc(t){cs.add(t)}async function Ai(){let t=[...cs].map(e=>e.path);t.length&&(ve.removeFromPaths(t),ve.addFromPaths(t),cs.clear())}var wc=Fe(xc());function jc(t,e,r){let n=t.slice();return n[35]=e[r],n[37]=r,n}function Cy(t){let e,r,n;return{c(){e=R("button"),e.textContent="Create note"},m(i,o){$(i,e,o),r||(n=Ke(e,"click",t[12]),r=!0)},p:ce,d(i){i&&H(e),r=!1,n()}}}function Ay(t){let e,r=I.showCreateButton&&Cy(t);return{c(){r&&r.c(),e=or()},m(n,i){r&&r.m(n,i),$(n,e,i)},p(n,i){I.showCreateButton&&r.p(n,i)},d(n){r&&r.d(n),n&&H(e)}}}function Cc(t){let e,r,n;return{c(){e=R("div"),r=xe("\u23F3 Work in progress: "),n=xe(t[3]),ze(e,"text-align","center"),ze(e,"color","var(--text-accent)"),ze(e,"margin-top","10px")},m(i,o){$(i,e,o),T(e,r),T(e,n)},p(i,o){o[0]&8&&Ge(n,i[3])},d(i){i&&H(e)}}}function Ac(t){let e,r;function n(...i){return t[18](t[37],...i)}return e=new rl({props:{selected:t[37]===t[0],note:t[35]}}),e.$on("mousemove",n),e.$on("click",t[10]),e.$on("auxclick",t[19]),{c(){Le(e.$$.fragment)},m(i,o){ke(e,i,o),r=!0},p(i,o){t=i;let s={};o[0]&1&&(s.selected=t[37]===t[0]),o[0]&4&&(s.note=t[35]),e.$set(s)},i(i){r||(ee(e.$$.fragment,i),r=!0)},o(i){re(e.$$.fragment,i),r=!1},d(i){Ee(e,i)}}}function Sy(t){let e;return{c(){e=xe("Searching...")},m(r,n){$(r,e,n)},p:ce,d(r){r&&H(e)}}}function Fy(t){let e,r=I.simpleSearch&&t[1].split(Ct).some(Fc),n,i=r&&Sc(t);return{c(){e=xe(`We found 0 result for your search here. + `),i&&i.c(),n=or()},m(o,s){$(o,e,s),i&&i.m(o,s),$(o,n,s)},p(o,s){s[0]&2&&(r=I.simpleSearch&&o[1].split(Ct).some(Fc)),r?i||(i=Sc(o),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},d(o){o&&H(e),i&&i.d(o),o&&H(n)}}}function Sc(t){let e,r,n;return{c(){e=R("br"),r=W(),n=R("span"),n.textContent=`You have enabled "Simpler Search" in the settings, try to type more + characters.`,ze(n,"color","var(--text-accent)"),ze(n,"font-size","small")},m(i,o){$(i,e,o),$(i,r,o),$(i,n,o)},d(i){i&&H(e),i&&H(r),i&&H(n)}}}function Ey(t){let e,r,n,i=t[2],o=[];for(let d=0;dre(o[d],1,1,()=>{o[d]=null});function a(d,f){if(!d[2].length&&d[1]&&!d[4])return Fy;if(d[4])return Sy}let l=a(t,[-1,-1]),u=l&&l(t);return{c(){for(let d=0;d\u2191\u2193to navigate',l=W(),u=R("div"),u.innerHTML=`alt \u2191\u2193 + to cycle history`,d=W(),f=R("div"),c=R("span"),y=xe(t[7]),w=R("span"),w.textContent="to open",x=W(),b=R("div"),b.innerHTML=`tab + to switch to In-File Search`,h=W(),_=R("div"),p=R("span"),m=xe(t[6]),v=W(),g=R("span"),g.textContent="to open in a new pane",j=W(),C=R("div"),S=R("span"),E=xe(t[9]),P=W(),L=R("span"),L.textContent="to create",k=W(),z=R("div"),J=R("span"),Q=xe(t[8]),Z=W(),A=R("span"),A.textContent="to create in a new pane",F=W(),D=R("div"),D.innerHTML=`alt \u21B5 + to insert a link`,N=W(),O=R("div"),O.innerHTML=`ctrl+h + to toggle excerpts`,X=W(),le=R("div"),le.innerHTML='escto close',B(a,"class","prompt-instruction"),B(u,"class","prompt-instruction"),B(c,"class","prompt-instruction-command"),B(f,"class","prompt-instruction"),B(b,"class","prompt-instruction"),B(p,"class","prompt-instruction-command"),B(_,"class","prompt-instruction"),B(S,"class","prompt-instruction-command"),B(C,"class","prompt-instruction"),B(J,"class","prompt-instruction-command"),B(z,"class","prompt-instruction"),B(D,"class","prompt-instruction"),B(O,"class","prompt-instruction"),B(le,"class","prompt-instruction"),B(s,"class","prompt-instructions")},m(q,ge){ke(e,q,ge),$(q,r,ge),te&&te.m(q,ge),$(q,n,ge),ke(i,q,ge),$(q,o,ge),$(q,s,ge),T(s,a),T(s,l),T(s,u),T(s,d),T(s,f),T(f,c),T(c,y),T(f,w),T(s,x),T(s,b),T(s,h),T(s,_),T(_,p),T(p,m),T(_,v),T(_,g),T(s,j),T(s,C),T(C,S),T(S,E),T(C,P),T(C,L),T(s,k),T(s,z),T(z,J),T(J,Q),T(z,Z),T(z,A),T(s,F),T(s,D),T(s,N),T(s,O),T(s,X),T(s,le),_e=!0},p(q,ge){let Ei={};ge[0]&2&&(Ei.initialValue=q[1]),ge[1]&128&&(Ei.$$scope={dirty:ge,ctx:q}),e.$set(Ei),q[3]?te?te.p(q,ge):(te=Cc(q),te.c(),te.m(n.parentNode,n)):te&&(te.d(1),te=null);let ms={};ge[0]&23|ge[1]&128&&(ms.$$scope={dirty:ge,ctx:q}),i.$set(ms),(!_e||ge[0]&128)&&Ge(y,q[7]),(!_e||ge[0]&64)&&Ge(m,q[6]),(!_e||ge[0]&512)&&Ge(E,q[9]),(!_e||ge[0]&256)&&Ge(Q,q[8])},i(q){_e||(ee(e.$$.fragment,q),ee(i.$$.fragment,q),_e=!0)},o(q){re(e.$$.fragment,q),re(i.$$.fragment,q),_e=!1},d(q){t[16](null),Ee(e,q),q&&H(r),te&&te.d(q),q&&H(n),Ee(i,q),q&&H(o),q&&H(s)}}}var Fc=t=>t.length<3;function Ty(t,e,r){let n,i;_n(t,jt,O=>r(15,i=O));let{modal:o}=e,{previousQuery:s}=e,a=0,l=0,u,d=[],f,c="",y=!0,w,x,b,h,_;Br(async()=>{U.enable("vault"),U.on("vault","enter",C),U.on("vault","create-note",k),U.on("vault","open-in-new-pane",S),U.on("vault","insert-link",z),U.on("vault","tab",J),U.on("vault","arrow-up",()=>Q(-1)),U.on("vault","arrow-down",()=>Q(1)),U.on("vault","prev-search-history",p),U.on("vault","next-search-history",m),await Ai(),I.showPreviousQueryResults&&r(13,s=(await we.getSearchHistory())[0])}),Nr(()=>{U.disable("vault")});async function p(){let O=(await we.getSearchHistory()).filter(X=>X);++l>=O.length&&(l=0),r(1,u=O[l]),w?.setInputValue(u)}async function m(){let O=(await we.getSearchHistory()).filter(X=>X);--l<0&&(l=O.length?O.length-1:0),r(1,u=O[l]),w?.setInputValue(u)}let v=null;async function g(){v&&(v.cancel(),v=null),f=new Yt(u),v=(0,wc.cancelable)(new Promise(O=>{O(ve.getSuggestions(f))})),r(2,d=await v),r(0,a=0),await Z()}function j(O){!n||(O?.ctrlKey?S():C(),o.close())}function C(){!n||(P(n),o.close())}function S(){!n||(P(n,!0),o.close())}function E(){u&&we.addToSearchHistory(u)}function P(O,X=!1){E(),ri(O,X)}async function L(O){await k()}async function k(O){if(u){try{await Ua(u,O?.newLeaf)}catch(X){new Mt.Notice(X.message);return}o.close()}}function z(){if(!n)return;let O=app.vault.getMarkdownFiles().find(te=>te.path===n.path),X=app.workspace.getActiveFile(),le=app.workspace.getActiveViewOfType(Mt.MarkdownView);if(!le?.editor){new Mt.Notice("Omnisearch - Error - No active editor",3e3);return}let _e;O&&X?_e=app.fileManager.generateMarkdownLink(O,X.path):_e=`[[${n.basename}.${qt(n.path)}]]`;let Ce=le.editor.getCursor();le.editor.replaceRange(_e,Ce,Ce),Ce.ch+=_e.length,le.editor.setCursor(Ce),o.close()}function J(){if(!(n&&(fn(n?.path)||!n?.matches.length)))if(E(),o.close(),n){let O=app.vault.getAbstractFileByPath(n.path);O&&O instanceof Mt.TFile&&new kr(app,O,u).open()}else{let O=app.workspace.getActiveViewOfType(Mt.MarkdownView);O&&new kr(app,O.file,u).open()}}function Q(O){r(0,a=Xn(a+O,d.length)),Z()}async function Z(){await mt(),n&&activeWindow.document.querySelector(`[data-result-id="${n.path}"]`)?.scrollIntoView({behavior:"auto",block:"nearest"})}function A(O){tt[O?"unshift":"push"](()=>{w=O,r(5,w)})}let F=O=>r(1,u=O.detail),D=(O,X)=>r(0,a=O),N=O=>{O.button==1&&S()};t.$$set=O=>{"modal"in O&&r(14,o=O.modal),"previousQuery"in O&&r(13,s=O.previousQuery)},t.$$.update=()=>{if(t.$$.dirty[0]&8194){e:r(1,u=u??s)}if(t.$$.dirty[0]&2){e:u?(r(4,y=!0),g().then(()=>{r(4,y=!1)})):(r(4,y=!1),r(2,d=[]))}if(t.$$.dirty[0]&5){e:n=d[a]}if(t.$$.dirty[0]&32768){e:switch(i){case We.LoadingCache:r(3,c="Loading cache...");break;case We.ReadingFiles:r(3,c="Reading files...");break;case We.IndexingFiles:r(3,c="Indexing files...");break;case We.WritingCache:g(),r(3,c="Updating cache...");break;default:g(),r(3,c="");break}}};e:I.openInNewPane?(r(6,x="\u21B5"),r(7,b=Qt()+" \u21B5"),r(8,h="shift \u21B5"),r(9,_=Qt()+" shift \u21B5")):(r(6,x=Qt()+" \u21B5"),r(7,b="\u21B5"),r(8,h=Qt()+" shift \u21B5"),r(9,_="shift \u21B5"));return[a,u,d,c,y,w,x,b,h,_,j,S,L,s,o,i,A,F,D,N]}var Ec=class extends Ae{constructor(e){super();De(this,e,Ty,Dy,be,{modal:14,previousQuery:13},null,[-1,-1])}},Dc=Ec;var Oc=Fe(require("obsidian"));function Iy(t){let e,r=t[2].replace(t[3],At)+"";return{c(){e=R("div"),B(e,"class","omnisearch-result__body")},m(n,i){$(n,e,i),e.innerHTML=r},p(n,i){i&12&&r!==(r=n[2].replace(n[3],At)+"")&&(e.innerHTML=r)},d(n){n&&H(e)}}}function Oy(t){let e,r;return e=new ni({props:{id:t[0].toString(),selected:t[1],$$slots:{default:[Iy]},$$scope:{ctx:t}}}),e.$on("mousemove",t[6]),e.$on("click",t[7]),e.$on("auxclick",t[8]),{c(){Le(e.$$.fragment)},m(n,i){ke(e,n,i),r=!0},p(n,[i]){let o={};i&1&&(o.id=n[0].toString()),i&2&&(o.selected=n[1]),i&524&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){r||(ee(e.$$.fragment,n),r=!0)},o(n){re(e.$$.fragment,n),r=!1},d(n){Ee(e,n)}}}function ky(t,e,r){let n,i,{offset:o}=e,{note:s}=e,{index:a=0}=e,{selected:l=!1}=e;function u(c){$e.call(this,t,c)}function d(c){$e.call(this,t,c)}function f(c){$e.call(this,t,c)}return t.$$set=c=>{"offset"in c&&r(4,o=c.offset),"note"in c&&r(5,s=c.note),"index"in c&&r(0,a=c.index),"selected"in c&&r(1,l=c.selected)},t.$$.update=()=>{if(t.$$.dirty&32){e:r(3,n=St(s.foundWords))}if(t.$$.dirty&48){e:r(2,i=yr(s?.content??"",o))}},[a,l,i,n,o,s,u,d,f]}var Tc=class extends Ae{constructor(e){super();De(this,e,ky,Oy,be,{offset:4,note:5,index:0,selected:1})}},Ic=Tc;function kc(t,e,r){let n=t.slice();return n[19]=e[r],n[21]=r,n}function Py(t){let e;return{c(){e=R("div"),e.textContent="We found 0 result for your search here.",ze(e,"text-align","center")},m(r,n){$(r,e,n)},p:ce,i:ce,o:ce,d(r){r&&H(e)}}}function My(t){let e,r,n=t[4],i=[];for(let s=0;sre(i[s],1,1,()=>{i[s]=null});return{c(){for(let s=0;s{s[d]=null}),Bt(),r=s[e],r?r.p(l,u):(r=s[e]=o[e](l),r.c()),ee(r,1),r.m(n.parentNode,n))},i(l){i||(ee(r),i=!0)},o(l){re(r),i=!1},d(l){s[e].d(l),l&&H(n)}}}function Ly(t){let e;return{c(){e=R("span"),e.textContent="to close"},m(r,n){$(r,e,n)},d(r){r&&H(e)}}}function By(t){let e;return{c(){e=R("span"),e.textContent="to go back to Vault Search"},m(r,n){$(r,e,n)},d(r){r&&H(e)}}}function Ny(t){let e,r,n,i,o,s,a,l,u,d,f,c,y,w,x,b,h,_,p,m;e=new ei({props:{placeholder:"Omnisearch - File",initialValue:t[1]}}),e.$on("input",t[10]),n=new ti({props:{$$slots:{default:[Ry]},$$scope:{ctx:t}}});function v(C,S){return C[0]?By:Ly}let g=v(t,-1),j=g(t);return{c(){Le(e.$$.fragment),r=W(),Le(n.$$.fragment),i=W(),o=R("div"),s=R("div"),s.innerHTML='\u2191\u2193to navigate',a=W(),l=R("div"),l.innerHTML='\u21B5to open',u=W(),d=R("div"),d.innerHTML=`tab + to switch to Vault Search`,f=W(),c=R("div"),y=R("span"),y.textContent="esc",w=W(),j.c(),x=W(),b=R("div"),h=R("span"),h.textContent=`${Qt()} \u21B5`,_=W(),p=R("span"),p.textContent="to open in a new pane",B(s,"class","prompt-instruction"),B(l,"class","prompt-instruction"),B(d,"class","prompt-instruction"),B(y,"class","prompt-instruction-command"),B(c,"class","prompt-instruction"),B(h,"class","prompt-instruction-command"),B(b,"class","prompt-instruction"),B(o,"class","prompt-instructions")},m(C,S){ke(e,C,S),$(C,r,S),ke(n,C,S),$(C,i,S),$(C,o,S),T(o,s),T(o,a),T(o,l),T(o,u),T(o,d),T(o,f),T(o,c),T(c,y),T(c,w),j.m(c,null),T(o,x),T(o,b),T(b,h),T(b,_),T(b,p),m=!0},p(C,[S]){let E={};S&2&&(E.initialValue=C[1]),e.$set(E);let P={};S&4194360&&(P.$$scope={dirty:S,ctx:C}),n.$set(P),g!==(g=v(C,S))&&(j.d(1),j=g(C),j&&(j.c(),j.m(c,null)))},i(C){m||(ee(e.$$.fragment,C),ee(n.$$.fragment,C),m=!0)},o(C){re(e.$$.fragment,C),re(n.$$.fragment,C),m=!1},d(C){Ee(e,C),C&&H(r),Ee(n,C),C&&H(i),C&&H(o),j.d()}}}function Ky(t,e,r){let n=t.find(i=>i.offset>e);return n?t.filter(i=>i.offset>e&&i.offset<=n.offset+r):[]}function zy(t,e,r){let{modal:n}=e,{parent:i=null}=e,{singleFilePath:o=""}=e,{previousQuery:s}=e,a,l=[],u=0,d,f;Br(()=>{U.enable("infile"),U.on("infile","enter",b),U.on("infile","open-in-new-pane",x),U.on("infile","arrow-up",()=>y(-1)),U.on("infile","arrow-down",()=>y(1)),U.on("infile","tab",h)}),Nr(()=>{U.disable("infile")});function c(g){let j=[],C=-1,S=0;for(;;){let E=Ky(g,C,ln);if(!E.length||(C=E.last().offset,j.push(E),++S>100))break}return j}function y(g){r(5,u=Xn(u+g,l.length)),w()}async function w(){await mt(),document.querySelector(`[data-result-id="${u}"]`)?.scrollIntoView({behavior:"auto",block:"nearest"})}async function x(){return b(!0)}async function b(g=!1){if(d){n.close(),i&&i.close(),await ri(d,g);let j=app.workspace.getActiveViewOfType(Oc.MarkdownView);if(!j)return;let C=l[u]??0,S=j.editor.offsetToPos(C);S.ch=0,j.editor.setCursor(S),j.editor.scrollIntoView({from:{line:S.line-10,ch:0},to:{line:S.line+10,ch:0}})}}function h(){new Zt(app,a??s).open(),n.close()}let _=g=>r(2,a=g.detail),p=(g,j)=>r(5,u=g),m=g=>b(g.ctrlKey),v=g=>{g.button==1&&b(!0)};return t.$$set=g=>{"modal"in g&&r(7,n=g.modal),"parent"in g&&r(0,i=g.parent),"singleFilePath"in g&&r(8,o=g.singleFilePath),"previousQuery"in g&&r(1,s=g.previousQuery)},t.$$.update=()=>{if(t.$$.dirty&2){e:r(2,a=s??"")}if(t.$$.dirty&772){e:(async()=>{a&&(r(9,f=new Yt(a)),r(3,d=(await ve.getSuggestions(f,{singleFilePath:o}))[0]??null)),r(5,u=0),await w()})()}if(t.$$.dirty&8){e:if(d){let g=c(d.matches);r(4,l=g.map(j=>Math.round((j.first().offset+j.last().offset)/2)))}}},[i,s,a,d,l,u,b,n,o,f,_,p,m,v]}var Mc=class extends Ae{constructor(e){super();De(this,e,zy,Ny,be,{modal:7,parent:0,singleFilePath:8,previousQuery:1})}},Rc=Mc;var ds=class extends Lc.Modal{constructor(e){super(e);this.modalEl.replaceChildren(),this.modalEl.addClass("omnisearch-modal","prompt"),this.modalEl.removeClass("modal"),this.modalEl.tabIndex=-1,this.scope.register([],"ArrowDown",s=>{s.preventDefault(),U.emit("arrow-down")}),this.scope.register([],"ArrowUp",s=>{s.preventDefault(),U.emit("arrow-up")});for(let s of[{k:"J",dir:"down"},{k:"K",dir:"up"}])for(let a of["Ctrl","Mod"])this.scope.register([a],s.k,l=>{this.app.vault.getConfig("vimMode")&&U.emit("arrow-"+s.dir)});for(let s of[{k:"N",dir:"down"},{k:"P",dir:"up"}])for(let a of["Ctrl","Mod"])this.scope.register([a],s.k,l=>{this.app.vault.getConfig("vimMode")&&U.emit("arrow-"+s.dir)});let r,n,i,o;I.openInNewPane?(r=["Mod"],n=[],i=["Mod","Shift"],o=["Shift"]):(r=[],n=["Mod"],i=["Shift"],o=["Mod","Shift"]),this.scope.register(n,"Enter",s=>{s.preventDefault(),U.emit("open-in-new-pane")}),this.scope.register(["Alt"],"Enter",s=>{s.preventDefault(),U.emit("insert-link")}),this.scope.register(i,"Enter",s=>{s.preventDefault(),U.emit("create-note")}),this.scope.register(o,"Enter",s=>{s.preventDefault(),U.emit("create-note",{newLeaf:!0})}),this.scope.register(r,"Enter",s=>{Da()||(s.preventDefault(),U.emit("enter"))}),this.scope.register([],"Tab",s=>{s.preventDefault(),U.emit("tab")}),this.scope.register(["Alt"],"ArrowDown",s=>{s.preventDefault(),U.emit("next-search-history")}),this.scope.register(["Alt"],"ArrowUp",s=>{s.preventDefault(),U.emit("prev-search-history")}),this.scope.register(["Ctrl"],"H",s=>{U.emit(qn.ToggleExcerpts)})}},Zt=class extends ds{constructor(e,r){super(e);let n=new Dc({target:this.modalEl,props:{modal:this,previousQuery:r}});this.onClose=()=>{n.$destroy()}}},kr=class extends ds{constructor(e,r,n="",i){super(e);let o=new Rc({target:this.modalEl,props:{modal:this,singleFilePath:r.path,parent:i,previousQuery:n}});i&&i.containerEl.toggleVisibility(!1),this.onClose=()=>{i&&i.containerEl.toggleVisibility(!0),o.$destroy()}}};var Bc=!1,Fi=[];function Vy(t){return t.map(e=>{let{score:r,path:n,basename:i,foundWords:o,matches:s,content:a}=e,l=yr(a,s[0]?.offset??-1);return{score:r,path:n,basename:i,foundWords:o,matches:s.map(u=>({match:u.match,offset:u.offset})),excerpt:l}})}async function Hy(t){let e=new Yt(t),r=await ve.getSuggestions(e);return Vy(r)}function $y(t){Fi.push(t),Bc&&t()}function Wy(t){Fi=Fi.filter(e=>e!==t)}function Nc(){Bc=!0,Fi.forEach(t=>t())}var hs={search:Hy,registerOnIndexed:$y,unregisterOnIndexed:Wy,refreshIndex:Ai};var ps=class extends Pr.Plugin{async onload(){if(await ja(this),this.addSettingTab(new Io(this)),Oo()){console.log("Omnisearch - Plugin disabled");return}await Uy(),await gr.clearOldDatabases(),Gy(this),I.ribbonIcon&&this.addRibbonButton(),U.disable("vault"),U.disable("infile"),U.on("global",qn.ToggleExcerpts,()=>{Ut.set(!I.showExcerpt)}),this.addCommand({id:"show-modal",name:"Vault search",callback:()=>{new Zt(app).open()}}),this.addCommand({id:"show-modal-infile",name:"In-file search",editorCallback:(e,r)=>{r.file&&new kr(app,r.file).open()}}),app.workspace.onLayoutReady(async()=>{this.registerEvent(this.app.vault.on("create",e=>{cn(e.path)&&(fe("Indexing new file",e.path),ve.addFromPaths([e.path]))})),this.registerEvent(this.app.vault.on("delete",e=>{fe("Removing file",e.path),we.removeFromLiveCache(e.path),ve.removeFromPaths([e.path])})),this.registerEvent(this.app.vault.on("modify",async e=>{cn(e.path)&&(fe("Updating file",e.path),await we.addToLiveCache(e.path),bc(e))})),this.registerEvent(this.app.vault.on("rename",async(e,r)=>{cn(e.path)&&(fe("Renaming file",e.path),we.removeFromLiveCache(r),we.addToLiveCache(e.path),ve.removeFromPaths([r]),await ve.addFromPaths([e.path]))})),this.executeFirstLaunchTasks(),await this.populateIndex()})}executeFirstLaunchTasks(){let e="1.10.1";if(I.welcomeMessage!==e){let r=new DocumentFragment;r.createSpan({},n=>{n.innerHTML="\u{1F50E} Omnisearch now requires the Text Extractor plugin to index PDF and images. See Omnisearch settings for more information."}),new Pr.Notice(r,2e4)}I.welcomeMessage=e,this.saveData(I)}async onunload(){delete globalThis.omnisearch,await Be.clearCache()}addRibbonButton(){this.ribbonButton=this.addRibbonIcon("search","Omnisearch",e=>{new Zt(app).open()})}removeRibbonButton(){this.ribbonButton&&this.ribbonButton.parentNode?.removeChild(this.ribbonButton)}async populateIndex(){console.time("Omnisearch - Indexing total time"),jt.set(We.ReadingFiles);let e=app.vault.getFiles().filter(n=>cn(n.path));console.log(`Omnisearch - ${e.length} files total`),console.log(`Omnisearch - Cache is ${wt()?"enabled":"disabled"}`),wt()&&(console.time("Omnisearch - Loading index from cache"),jt.set(We.LoadingCache),await ve.loadCache()&&console.timeEnd("Omnisearch - Loading index from cache"));let r=ve.getDiff(e.map(n=>({path:n.path,mtime:n.stat.mtime})));wt()&&(r.toAdd.length&&console.log("Omnisearch - Total number of files to add/update: "+r.toAdd.length),r.toRemove.length&&console.log("Omnisearch - Total number of files to remove: "+r.toRemove.length)),r.toAdd.length>=1e3&&wt()&&new Pr.Notice(`Omnisearch - ${r.toAdd.length} files need to be indexed. Obsidian may experience stutters and freezes during the process`,1e4),jt.set(We.IndexingFiles),ve.removeFromPaths(r.toRemove.map(n=>n.path)),await ve.addFromPaths(r.toAdd.map(n=>n.path)),(r.toRemove.length||r.toAdd.length)&&wt()&&(jt.set(We.WritingCache),I.useCache=!1,pe(this),await ve.writeToCache(),I.useCache=!0,pe(this)),console.timeEnd("Omnisearch - Indexing total time"),r.toAdd.length>=1e3&&new Pr.Notice("Omnisearch - Your files have been indexed."),jt.set(We.Done),Nc()}};async function Uy(){let t=[`${app.vault.configDir}/plugins/omnisearch/searchIndex.json`,`${app.vault.configDir}/plugins/omnisearch/notesCache.json`,`${app.vault.configDir}/plugins/omnisearch/notesCache.data`,`${app.vault.configDir}/plugins/omnisearch/searchIndex.data`,`${app.vault.configDir}/plugins/omnisearch/historyCache.json`,`${app.vault.configDir}/plugins/omnisearch/pdfCache.data`];for(let e of t)if(await app.vault.adapter.exists(e))try{await app.vault.adapter.remove(e)}catch{}}function Gy(t){t.registerObsidianProtocolHandler("omnisearch",e=>{new Zt(app,e.query).open()}),globalThis.omnisearch=hs,app.plugins.plugins.omnisearch.api=hs} diff --git a/.obsidian/plugins/omnisearch/manifest.json b/.obsidian/plugins/omnisearch/manifest.json index b390e55..6708391 100644 --- a/.obsidian/plugins/omnisearch/manifest.json +++ b/.obsidian/plugins/omnisearch/manifest.json @@ -1,7 +1,7 @@ { "id": "omnisearch", "name": "Omnisearch", - "version": "1.14.0", + "version": "1.14.2", "minAppVersion": "1.0.0", "description": "A search engine that just works", "author": "Simon Cambier", diff --git a/.obsidian/plugins/omnisearch/styles.css b/.obsidian/plugins/omnisearch/styles.css index eccf2d5..2e8501e 100644 --- a/.obsidian/plugins/omnisearch/styles.css +++ b/.obsidian/plugins/omnisearch/styles.css @@ -18,6 +18,7 @@ } .omnisearch-result__title { + white-space: pre-wrap; align-items: center; display: flex; gap: 5px;