diff --git a/.obsidian/plugins/obsidian-style-settings/data.json b/.obsidian/plugins/obsidian-style-settings/data.json
index abe830a..6425082 100644
--- a/.obsidian/plugins/obsidian-style-settings/data.json
+++ b/.obsidian/plugins/obsidian-style-settings/data.json
@@ -1,12 +1,11 @@
{
"anuppuccin-theme-settings@@anp-alt-rainbow-style": "anp-full-rainbow-color-toggle",
"anuppuccin-theme-settings@@anp-custom-checkboxes": true,
- "anuppuccin-theme-settings@@anuppuccin-theme-light": "ctp-latte",
"anuppuccin-theme-settings-extended@@anp-theme-ext-amoled": true,
"anuppuccin-theme-settings-extended@@anp-theme-ext-dark": true,
"anuppuccin-theme-settings-extended@@anp-theme-ext-light": true,
"anuppuccin-theme-settings@@anp-codeblock-numbers": true,
- "anuppuccin-theme-settings-extended@@catppuccin-theme-extended": "ctp-nord-light",
- "anuppuccin-theme-settings-extended@@catppuccin-theme-dark-extended": "ctp-nord-dark",
- "anuppuccin-theme-settings@@anp-pdf-blend-toggle": true
+ "anuppuccin-theme-settings@@anuppuccin-accent-toggle": true,
+ "anuppuccin-theme-settings@@anp-color-transition-toggle": false,
+ "anuppuccin-theme-settings-extended@@catppuccin-theme-extended": "ctp-nord-light"
}
\ No newline at end of file
diff --git a/.obsidian/plugins/obsidian-style-settings/main.js b/.obsidian/plugins/obsidian-style-settings/main.js
index dc19d1d..14324f0 100644
--- a/.obsidian/plugins/obsidian-style-settings/main.js
+++ b/.obsidian/plugins/obsidian-style-settings/main.js
@@ -32,6 +32,157 @@ function __awaiter(thisArg, _arguments, P, generator) {
});
}
+class ExportModal extends obsidian.Modal {
+ constructor(app, plugin, section, config) {
+ super(app);
+ this.plugin = plugin;
+ this.config = config;
+ this.section = section;
+ }
+ onOpen() {
+ const { contentEl, modalEl } = this;
+ modalEl.addClass('modal-style-settings');
+ new obsidian.Setting(contentEl)
+ .setName(`Export settings for: ${this.section}`)
+ .then((setting) => {
+ const output = JSON.stringify(this.config, null, 2);
+ // Build a copy to clipboard link
+ setting.controlEl.createEl('a', {
+ cls: 'style-settings-copy',
+ text: 'Copy to clipboard',
+ href: '#',
+ }, (copyButton) => {
+ new obsidian.TextAreaComponent(contentEl)
+ .setValue(output)
+ .then((textarea) => {
+ copyButton.addEventListener('click', (e) => {
+ e.preventDefault();
+ // Select the textarea contents and copy them to the clipboard
+ textarea.inputEl.select();
+ textarea.inputEl.setSelectionRange(0, 99999);
+ document.execCommand('copy');
+ copyButton.addClass('success');
+ setTimeout(() => {
+ // If the button is still in the dom, remove the success class
+ if (copyButton.parentNode) {
+ copyButton.removeClass('success');
+ }
+ }, 2000);
+ });
+ });
+ });
+ // Build a download link
+ setting.controlEl.createEl('a', {
+ cls: 'style-settings-download',
+ text: 'Download',
+ attr: {
+ download: 'style-settings.json',
+ href: `data:application/json;charset=utf-8,${encodeURIComponent(output)}`,
+ },
+ });
+ });
+ }
+ onClose() {
+ const { contentEl } = this;
+ contentEl.empty();
+ }
+}
+
+class ImportModal extends obsidian.Modal {
+ constructor(app, plugin) {
+ super(app);
+ this.plugin = plugin;
+ }
+ onOpen() {
+ const { contentEl, modalEl } = this;
+ modalEl.addClass('modal-style-settings');
+ new obsidian.Setting(contentEl)
+ .setName('Import style setting')
+ .setDesc('Import an entire or partial configuration. Warning: this may override existing settings');
+ new obsidian.Setting(contentEl).then((setting) => {
+ // Build an error message container
+ const errorSpan = createSpan({
+ cls: 'style-settings-import-error',
+ text: 'Error importing config',
+ });
+ setting.nameEl.appendChild(errorSpan);
+ // Attempt to parse the imported data and close if successful
+ const importAndClose = (str) => __awaiter(this, void 0, void 0, function* () {
+ if (str) {
+ try {
+ const importedSettings = JSON.parse(str);
+ yield this.plugin.settingsManager.setSettings(importedSettings);
+ this.plugin.settingsTab.display();
+ this.close();
+ }
+ catch (e) {
+ errorSpan.addClass('active');
+ errorSpan.setText(`Error importing style settings: ${e}`);
+ }
+ }
+ else {
+ errorSpan.addClass('active');
+ errorSpan.setText(`Error importing style settings: config is empty`);
+ }
+ });
+ // Build a file input
+ setting.controlEl.createEl('input', {
+ cls: 'style-settings-import-input',
+ attr: {
+ id: 'style-settings-import-input',
+ name: 'style-settings-import-input',
+ type: 'file',
+ accept: '.json',
+ },
+ }, (importInput) => {
+ // Set up a FileReader so we can parse the file contents
+ importInput.addEventListener('change', (e) => {
+ const reader = new FileReader();
+ reader.onload = (e) => __awaiter(this, void 0, void 0, function* () {
+ yield importAndClose(e.target.result.toString().trim());
+ });
+ reader.readAsText(e.target.files[0]);
+ });
+ });
+ // Build a label we will style as a link
+ setting.controlEl.createEl('label', {
+ cls: 'style-settings-import-label',
+ text: 'Import from file',
+ attr: {
+ for: 'style-settings-import-input',
+ },
+ });
+ new obsidian.TextAreaComponent(contentEl)
+ .setPlaceholder('Paste config here...')
+ .then((ta) => {
+ new obsidian.ButtonComponent(contentEl)
+ .setButtonText('Save')
+ .onClick(() => __awaiter(this, void 0, void 0, function* () {
+ yield importAndClose(ta.getValue().trim());
+ }));
+ });
+ });
+ }
+ onClose() {
+ const { contentEl } = this;
+ contentEl.empty();
+ }
+}
+
+const SettingType = {
+ HEADING: 'heading',
+ INFO_TEXT: 'info-text',
+ CLASS_TOGGLE: 'class-toggle',
+ CLASS_SELECT: 'class-select',
+ VARIABLE_TEXT: 'variable-text',
+ VARIABLE_NUMBER: 'variable-number',
+ VARIABLE_NUMBER_SLIDER: 'variable-number-slider',
+ VARIABLE_SELECT: 'variable-select',
+ VARIABLE_COLOR: 'variable-color',
+ VARIABLE_THEMED_COLOR: 'variable-themed-color',
+ COLOR_GRADIENT: 'color-gradient',
+};
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function getDefaultExportFromCjs (x) {
@@ -3277,157 +3428,6 @@ var chroma = createCommonjsModule(function (module, exports) {
})));
});
-class ImportModal extends obsidian.Modal {
- constructor(app, plugin) {
- super(app);
- this.plugin = plugin;
- }
- onOpen() {
- const { contentEl, modalEl } = this;
- modalEl.addClass('modal-style-settings');
- new obsidian.Setting(contentEl)
- .setName('Import style setting')
- .setDesc('Import an entire or partial configuration. Warning: this may override existing settings');
- new obsidian.Setting(contentEl).then((setting) => {
- // Build an error message container
- const errorSpan = createSpan({
- cls: 'style-settings-import-error',
- text: 'Error importing config',
- });
- setting.nameEl.appendChild(errorSpan);
- // Attempt to parse the imported data and close if successful
- const importAndClose = (str) => __awaiter(this, void 0, void 0, function* () {
- if (str) {
- try {
- const importedSettings = JSON.parse(str);
- yield this.plugin.settingsManager.setSettings(importedSettings);
- this.plugin.settingsTab.display();
- this.close();
- }
- catch (e) {
- errorSpan.addClass('active');
- errorSpan.setText(`Error importing style settings: ${e}`);
- }
- }
- else {
- errorSpan.addClass('active');
- errorSpan.setText(`Error importing style settings: config is empty`);
- }
- });
- // Build a file input
- setting.controlEl.createEl('input', {
- cls: 'style-settings-import-input',
- attr: {
- id: 'style-settings-import-input',
- name: 'style-settings-import-input',
- type: 'file',
- accept: '.json',
- },
- }, (importInput) => {
- // Set up a FileReader so we can parse the file contents
- importInput.addEventListener('change', (e) => {
- const reader = new FileReader();
- reader.onload = (e) => __awaiter(this, void 0, void 0, function* () {
- yield importAndClose(e.target.result.toString().trim());
- });
- reader.readAsText(e.target.files[0]);
- });
- });
- // Build a label we will style as a link
- setting.controlEl.createEl('label', {
- cls: 'style-settings-import-label',
- text: 'Import from file',
- attr: {
- for: 'style-settings-import-input',
- },
- });
- new obsidian.TextAreaComponent(contentEl)
- .setPlaceholder('Paste config here...')
- .then((ta) => {
- new obsidian.ButtonComponent(contentEl)
- .setButtonText('Save')
- .onClick(() => __awaiter(this, void 0, void 0, function* () {
- yield importAndClose(ta.getValue().trim());
- }));
- });
- });
- }
- onClose() {
- const { contentEl } = this;
- contentEl.empty();
- }
-}
-
-class ExportModal extends obsidian.Modal {
- constructor(app, plugin, section, config) {
- super(app);
- this.plugin = plugin;
- this.config = config;
- this.section = section;
- }
- onOpen() {
- const { contentEl, modalEl } = this;
- modalEl.addClass('modal-style-settings');
- new obsidian.Setting(contentEl)
- .setName(`Export settings for: ${this.section}`)
- .then((setting) => {
- const output = JSON.stringify(this.config, null, 2);
- // Build a copy to clipboard link
- setting.controlEl.createEl('a', {
- cls: 'style-settings-copy',
- text: 'Copy to clipboard',
- href: '#',
- }, (copyButton) => {
- new obsidian.TextAreaComponent(contentEl)
- .setValue(output)
- .then((textarea) => {
- copyButton.addEventListener('click', (e) => {
- e.preventDefault();
- // Select the textarea contents and copy them to the clipboard
- textarea.inputEl.select();
- textarea.inputEl.setSelectionRange(0, 99999);
- document.execCommand('copy');
- copyButton.addClass('success');
- setTimeout(() => {
- // If the button is still in the dom, remove the success class
- if (copyButton.parentNode) {
- copyButton.removeClass('success');
- }
- }, 2000);
- });
- });
- });
- // Build a download link
- setting.controlEl.createEl('a', {
- cls: 'style-settings-download',
- text: 'Download',
- attr: {
- download: 'style-settings.json',
- href: `data:application/json;charset=utf-8,${encodeURIComponent(output)}`,
- },
- });
- });
- }
- onClose() {
- const { contentEl } = this;
- contentEl.empty();
- }
-}
-
-const SettingType = {
- HEADING: 'heading',
- INFO_TEXT: 'info-text',
- CLASS_TOGGLE: 'class-toggle',
- CLASS_SELECT: 'class-select',
- VARIABLE_TEXT: 'variable-text',
- VARIABLE_NUMBER: 'variable-number',
- VARIABLE_NUMBER_SLIDER: 'variable-number-slider',
- VARIABLE_SELECT: 'variable-select',
- VARIABLE_COLOR: 'variable-color',
- VARIABLE_THEMED_COLOR: 'variable-themed-color',
- COLOR_GRADIENT: 'color-gradient',
-};
-
function generateColorVariables(key, format, colorStr, opacity, altFormats = []) {
const parsedColor = chroma(colorStr);
const alts = altFormats.reduce((a, alt) => {
@@ -3776,7 +3776,9 @@ class CSSSettingsManager {
`
.trim()
.replace(/[\r\n\s]+/g, ' ');
- this.plugin.app.workspace.trigger('css-change', { source: 'style-settings' });
+ this.plugin.app.workspace.trigger('css-change', {
+ source: 'style-settings',
+ });
}
setConfig(settings) {
this.config = {};
@@ -3865,6 +3867,1912 @@ class CSSSettingsManager {
}
}
+const ar = {};
+
+const cz = {};
+
+const da = {};
+
+const de = {
+ 'Default:': 'Standard:',
+ 'Error:': 'Fehler:',
+ 'missing default light value, or value is not in a valid color format': 'Fehlender heller standard Wert oder Wert ist in keinem validen Farb-Format',
+ 'missing default dark value, or value is not in a valid color format': 'Fehlender dunkler standard Wert oder Wert ist in keinem validen Farb-Format',
+ 'missing default value, or value is not in a valid color format': 'Fehlender standard Wert oder Wert ist in keinem validen Farb-Format',
+ 'missing default value': 'Fehlender standard Wert',
+};
+
+const en = {
+ 'Default:': 'Default:',
+ 'Error:': 'Error:',
+ 'missing default light value, or value is not in a valid color format': 'missing default light value, or value is not in a valid color format',
+ 'missing default dark value, or value is not in a valid color format': 'missing default dark value, or value is not in a valid color format',
+ 'missing default value, or value is not in a valid color format': 'missing default value, or value is not in a valid color format',
+ 'missing default value': 'missing default value',
+};
+
+const es = {};
+
+const fr = {};
+
+const hi = {};
+
+const id = {};
+
+const it = {};
+
+const ja = {};
+
+const ko = {};
+
+const nl = {
+ 'Default:': 'Standaard:',
+ 'Error:': 'Error:',
+ 'missing default light value, or value is not in a valid color format': 'Geen standaard waarde voor het lichte thema, of de waarde is niet in het goede formaat',
+ 'missing default dark value, or value is not in a valid color format': 'Geen standaard waarde voor het donkere thema, of de waarde is niet in het goede formaat',
+ 'missing default value, or value is not in a valid color format': 'Geen standaard waarde, of de waarde is niet in het goede formaat',
+ 'missing default value': 'Geen standaard waarde',
+};
+
+const no = {};
+
+const pl = {};
+
+const pt = {};
+
+const ptBr = {};
+
+const ro = {};
+
+const ru = {};
+
+const sq = {};
+
+const tr = {};
+
+const uk = {};
+
+const zh = {
+ 'Default:': '默认:',
+ 'Error:': '错误:',
+ 'missing default light value, or value is not in a valid color format': '缺少默认的浅色模式色值,或该色值没有采用一个有效的颜色格式',
+ 'missing default dark value, or value is not in a valid color format': '缺少默认的深色模式色值,或该色值没有采用一个有效的颜色格式',
+ 'missing default value, or value is not in a valid color format': '缺少默认色值,或该色值没有采用一个有效的颜色格式',
+ 'missing default value': '缺少默认色值',
+};
+
+const zhTw = {};
+
+const lang = window.localStorage.getItem('language');
+const localeMap = {
+ ar,
+ cz,
+ da,
+ de,
+ en,
+ es,
+ fr,
+ hi,
+ id,
+ it,
+ ja,
+ ko,
+ nl,
+ no,
+ pl,
+ 'pt-BR': ptBr,
+ pt,
+ ro,
+ ru,
+ sq,
+ tr,
+ uk,
+ 'zh-TW': zhTw,
+ zh,
+};
+const locale = localeMap[lang || 'en'];
+function t(str) {
+ if (!locale) {
+ console.error('Error: Style Settings locale not found', lang);
+ }
+ return (locale && locale[str]) || en[str];
+}
+
+const settingRegExp = /\/\*!?\s*@settings[\r\n]+?([\s\S]+?)\*\//g;
+const nameRegExp = /^name:\s*(.+)$/m;
+function getTitle(config) {
+ if (lang) {
+ return config[`title.${lang}`] || config.title;
+ }
+ return config.title;
+}
+function getDescription(config) {
+ if (lang) {
+ return (config[`description.${lang}`] ||
+ config.description);
+ }
+ return config.description;
+}
+function isValidDefaultColor(color) {
+ return /^(#|rgb|hsl)/.test(color);
+}
+function getPickrSettings(opts) {
+ const { el, isView, containerEl, swatches, opacity, defaultColor } = opts;
+ return {
+ el,
+ container: isView ? document.body : containerEl,
+ theme: 'nano',
+ swatches,
+ lockOpacity: !opacity,
+ default: defaultColor,
+ position: 'left-middle',
+ components: {
+ preview: true,
+ hue: true,
+ opacity: !!opacity,
+ interaction: {
+ hex: true,
+ rgba: true,
+ hsla: true,
+ input: true,
+ cancel: true,
+ save: true,
+ },
+ },
+ };
+}
+function onPickrCancel(instance) {
+ instance.hide();
+}
+function sanitizeText(str) {
+ if (str === '') {
+ return `""`;
+ }
+ return str.replace(/[;<>]/g, '');
+}
+function createDescription(description, def, defLabel) {
+ const fragment = createFragment();
+ if (description) {
+ fragment.appendChild(document.createTextNode(description));
+ }
+ if (def) {
+ const small = createEl('small');
+ small.appendChild(createEl('strong', { text: `${t('Default:')} ` }));
+ small.appendChild(document.createTextNode(defLabel || def));
+ const div = createEl('div');
+ div.appendChild(small);
+ fragment.appendChild(div);
+ }
+ return fragment;
+}
+
+var fuzzysort = createCommonjsModule(function (module) {
+((root, UMD) => {
+ if(module.exports) module.exports = UMD();
+ else root['fuzzysort'] = UMD();
+})(commonjsGlobal, _ => {
+
+ var single = (search, target) => { if(search=='farzher')return {target:"farzher was here (^-^*)/",score:0,_indexes:[0]}
+ if(!search || !target) return NULL
+
+ var preparedSearch = getPreparedSearch(search);
+ if(!isObj(target)) target = getPrepared(target);
+
+ var searchBitflags = preparedSearch.bitflags;
+ if((searchBitflags & target._bitflags) !== searchBitflags) return NULL
+
+ return algorithm(preparedSearch, target)
+ };
+
+
+ var go = (search, targets, options) => { if(search=='farzher')return [{target:"farzher was here (^-^*)/",score:0,_indexes:[0],obj:targets?targets[0]:NULL}]
+ if(!search) return options&&options.all ? all(search, targets, options) : noResults
+
+ var preparedSearch = getPreparedSearch(search);
+ var searchBitflags = preparedSearch.bitflags;
+ preparedSearch.containsSpace;
+
+ var threshold = options&&options.threshold || INT_MIN;
+ var limit = options&&options['limit'] || INT_MAX; // for some reason only limit breaks when minified
+
+ var resultsLen = 0; var limitedCount = 0;
+ var targetsLen = targets.length;
+
+ // This code is copy/pasted 3 times for performance reasons [options.keys, options.key, no keys]
+
+ // options.key
+ if(options && options.key) {
+ var key = options.key;
+ for(var i = 0; i < targetsLen; ++i) { var obj = targets[i];
+ var target = getValue(obj, key);
+ if(!target) continue
+ if(!isObj(target)) target = getPrepared(target);
+
+ if((searchBitflags & target._bitflags) !== searchBitflags) continue
+ var result = algorithm(preparedSearch, target);
+ if(result === NULL) continue
+ if(result.score < threshold) continue
+
+ // have to clone result so duplicate targets from different obj can each reference the correct obj
+ result = {target:result.target, _targetLower:'', _targetLowerCodes:NULL, _nextBeginningIndexes:NULL, _bitflags:0, score:result.score, _indexes:result._indexes, obj:obj}; // hidden
+
+ if(resultsLen < limit) { q.add(result); ++resultsLen; }
+ else {
+ ++limitedCount;
+ if(result.score > q.peek().score) q.replaceTop(result);
+ }
+ }
+
+ // options.keys
+ } else if(options && options.keys) {
+ var scoreFn = options['scoreFn'] || defaultScoreFn;
+ var keys = options.keys;
+ var keysLen = keys.length;
+ for(var i = 0; i < targetsLen; ++i) { var obj = targets[i];
+ var objResults = new Array(keysLen);
+ for (var keyI = 0; keyI < keysLen; ++keyI) {
+ var key = keys[keyI];
+ var target = getValue(obj, key);
+ if(!target) { objResults[keyI] = NULL; continue }
+ if(!isObj(target)) target = getPrepared(target);
+
+ if((searchBitflags & target._bitflags) !== searchBitflags) objResults[keyI] = NULL;
+ else objResults[keyI] = algorithm(preparedSearch, target);
+ }
+ objResults.obj = obj; // before scoreFn so scoreFn can use it
+ var score = scoreFn(objResults);
+ if(score === NULL) continue
+ if(score < threshold) continue
+ objResults.score = score;
+ if(resultsLen < limit) { q.add(objResults); ++resultsLen; }
+ else {
+ ++limitedCount;
+ if(score > q.peek().score) q.replaceTop(objResults);
+ }
+ }
+
+ // no keys
+ } else {
+ for(var i = 0; i < targetsLen; ++i) { var target = targets[i];
+ if(!target) continue
+ if(!isObj(target)) target = getPrepared(target);
+
+ if((searchBitflags & target._bitflags) !== searchBitflags) continue
+ var result = algorithm(preparedSearch, target);
+ if(result === NULL) continue
+ if(result.score < threshold) continue
+ if(resultsLen < limit) { q.add(result); ++resultsLen; }
+ else {
+ ++limitedCount;
+ if(result.score > q.peek().score) q.replaceTop(result);
+ }
+ }
+ }
+
+ if(resultsLen === 0) return noResults
+ var results = new Array(resultsLen);
+ for(var i = resultsLen - 1; i >= 0; --i) results[i] = q.poll();
+ results.total = resultsLen + limitedCount;
+ return results
+ };
+
+
+ var highlight = (result, hOpen, hClose) => {
+ if(typeof hOpen === 'function') return highlightCallback(result, hOpen)
+ if(result === NULL) return NULL
+ if(hOpen === undefined) hOpen = '';
+ if(hClose === undefined) hClose = '';
+ var highlighted = '';
+ var matchesIndex = 0;
+ var opened = false;
+ var target = result.target;
+ var targetLen = target.length;
+ var indexes = result._indexes;
+ indexes = indexes.slice(0, indexes.len).sort((a,b)=>a-b);
+ for(var i = 0; i < targetLen; ++i) { var char = target[i];
+ if(indexes[matchesIndex] === i) {
+ ++matchesIndex;
+ if(!opened) { opened = true;
+ highlighted += hOpen;
+ }
+
+ if(matchesIndex === indexes.length) {
+ highlighted += char + hClose + target.substr(i+1);
+ break
+ }
+ } else {
+ if(opened) { opened = false;
+ highlighted += hClose;
+ }
+ }
+ highlighted += char;
+ }
+
+ return highlighted
+ };
+ var highlightCallback = (result, cb) => {
+ if(result === NULL) return NULL
+ var target = result.target;
+ var targetLen = target.length;
+ var indexes = result._indexes;
+ indexes = indexes.slice(0, indexes.len).sort((a,b)=>a-b);
+ var highlighted = '';
+ var matchI = 0;
+ var indexesI = 0;
+ var opened = false;
+ var result = [];
+ for(var i = 0; i < targetLen; ++i) { var char = target[i];
+ if(indexes[indexesI] === i) {
+ ++indexesI;
+ if(!opened) { opened = true;
+ result.push(highlighted); highlighted = '';
+ }
+
+ if(indexesI === indexes.length) {
+ highlighted += char;
+ result.push(cb(highlighted, matchI++)); highlighted = '';
+ result.push(target.substr(i+1));
+ break
+ }
+ } else {
+ if(opened) { opened = false;
+ result.push(cb(highlighted, matchI++)); highlighted = '';
+ }
+ }
+ highlighted += char;
+ }
+ return result
+ };
+
+
+ var indexes = result => result._indexes.slice(0, result._indexes.len).sort((a,b)=>a-b);
+
+
+ var prepare = (target) => {
+ if(typeof target !== 'string') target = '';
+ var info = prepareLowerInfo(target);
+ return {'target':target, _targetLower:info._lower, _targetLowerCodes:info.lowerCodes, _nextBeginningIndexes:NULL, _bitflags:info.bitflags, 'score':NULL, _indexes:[0], 'obj':NULL} // hidden
+ };
+
+
+ // Below this point is only internal code
+ // Below this point is only internal code
+ // Below this point is only internal code
+ // Below this point is only internal code
+
+
+ var prepareSearch = (search) => {
+ if(typeof search !== 'string') search = '';
+ search = search.trim();
+ var info = prepareLowerInfo(search);
+
+ var spaceSearches = [];
+ if(info.containsSpace) {
+ var searches = search.split(/\s+/);
+ searches = [...new Set(searches)]; // distinct
+ for(var i=0; i {
+ if(target.length > 999) return prepare(target) // don't cache huge targets
+ var targetPrepared = preparedCache.get(target);
+ if(targetPrepared !== undefined) return targetPrepared
+ targetPrepared = prepare(target);
+ preparedCache.set(target, targetPrepared);
+ return targetPrepared
+ };
+ var getPreparedSearch = (search) => {
+ if(search.length > 999) return prepareSearch(search) // don't cache huge searches
+ var searchPrepared = preparedSearchCache.get(search);
+ if(searchPrepared !== undefined) return searchPrepared
+ searchPrepared = prepareSearch(search);
+ preparedSearchCache.set(search, searchPrepared);
+ return searchPrepared
+ };
+
+
+ var all = (search, targets, options) => {
+ var results = []; results.total = targets.length;
+
+ var limit = options && options.limit || INT_MAX;
+
+ if(options && options.key) {
+ for(var i=0;i= limit) return results
+ }
+ } else if(options && options.keys) {
+ for(var i=0;i= 0; --keyI) {
+ var target = getValue(obj, options.keys[keyI]);
+ if(!target) { objResults[keyI] = NULL; continue }
+ if(!isObj(target)) target = getPrepared(target);
+ target.score = INT_MIN;
+ target._indexes.len = 0;
+ objResults[keyI] = target;
+ }
+ objResults.obj = obj;
+ objResults.score = INT_MIN;
+ results.push(objResults); if(results.length >= limit) return results
+ }
+ } else {
+ for(var i=0;i= limit) return results
+ }
+ }
+
+ return results
+ };
+
+
+ var algorithm = (preparedSearch, prepared, allowSpaces=false) => {
+ if(allowSpaces===false && preparedSearch.containsSpace) return algorithmSpaces(preparedSearch, prepared)
+
+ var searchLower = preparedSearch._lower;
+ var searchLowerCodes = preparedSearch.lowerCodes;
+ var searchLowerCode = searchLowerCodes[0];
+ var targetLowerCodes = prepared._targetLowerCodes;
+ var searchLen = searchLowerCodes.length;
+ var targetLen = targetLowerCodes.length;
+ var searchI = 0; // where we at
+ var targetI = 0; // where you at
+ var matchesSimpleLen = 0;
+
+ // very basic fuzzy match; to remove non-matching targets ASAP!
+ // walk through target. find sequential matches.
+ // if all chars aren't found then exit
+ for(;;) {
+ var isMatch = searchLowerCode === targetLowerCodes[targetI];
+ if(isMatch) {
+ matchesSimple[matchesSimpleLen++] = targetI;
+ ++searchI; if(searchI === searchLen) break
+ searchLowerCode = searchLowerCodes[searchI];
+ }
+ ++targetI; if(targetI >= targetLen) return NULL // Failed to find searchI
+ }
+
+ var searchI = 0;
+ var successStrict = false;
+ var matchesStrictLen = 0;
+
+ var nextBeginningIndexes = prepared._nextBeginningIndexes;
+ if(nextBeginningIndexes === NULL) nextBeginningIndexes = prepared._nextBeginningIndexes = prepareNextBeginningIndexes(prepared.target);
+ targetI = matchesSimple[0]===0 ? 0 : nextBeginningIndexes[matchesSimple[0]-1];
+
+ // Our target string successfully matched all characters in sequence!
+ // Let's try a more advanced and strict test to improve the score
+ // only count it as a match if it's consecutive or a beginning character!
+ var backtrackCount = 0;
+ if(targetI !== targetLen) for(;;) {
+ if(targetI >= targetLen) {
+ // We failed to find a good spot for this search char, go back to the previous search char and force it forward
+ if(searchI <= 0) break // We failed to push chars forward for a better match
+
+ ++backtrackCount; if(backtrackCount > 200) break // exponential backtracking is taking too long, just give up and return a bad match
+
+ --searchI;
+ var lastMatch = matchesStrict[--matchesStrictLen];
+ targetI = nextBeginningIndexes[lastMatch];
+
+ } else {
+ var isMatch = searchLowerCodes[searchI] === targetLowerCodes[targetI];
+ if(isMatch) {
+ matchesStrict[matchesStrictLen++] = targetI;
+ ++searchI; if(searchI === searchLen) { successStrict = true; break }
+ ++targetI;
+ } else {
+ targetI = nextBeginningIndexes[targetI];
+ }
+ }
+ }
+
+ // check if it's a substring match
+ var substringIndex = prepared._targetLower.indexOf(searchLower, matchesSimple[0]); // perf: this is slow
+ var isSubstring = ~substringIndex;
+ if(isSubstring && !successStrict) { // rewrite the indexes from basic to the substring
+ for(var i=0; i 24) score *= (uniqueBeginningIndexes-24)*10; // quite arbitrary numbers here ...
+ }
+
+ if(isSubstring) score /= 1+searchLen*searchLen*1; // bonus for being a full substring
+ if(isSubstringBeginning) score /= 1+searchLen*searchLen*1; // bonus for substring starting on a beginningIndex
+
+ score -= targetLen - searchLen; // penality for longer targets
+ prepared.score = score;
+
+ for(var i = 0; i < matchesBestLen; ++i) prepared._indexes[i] = matchesBest[i];
+ prepared._indexes.len = matchesBestLen;
+
+ return prepared
+ }
+ };
+ var algorithmSpaces = (preparedSearch, target) => {
+ var seen_indexes = new Set();
+ var score = 0;
+ var result = NULL;
+
+ var first_seen_index_last_search = 0;
+ var searches = preparedSearch.spaceSearches;
+ for(var i=0; i score) {
+ return allowSpacesResult
+ }
+
+ result.score = score;
+
+ var i = 0;
+ for (let index of seen_indexes) result._indexes[i++] = index;
+ result._indexes.len = i;
+
+ return result
+ };
+
+
+ var prepareLowerInfo = (str) => {
+ var strLen = str.length;
+ var lower = str.toLowerCase();
+ var lowerCodes = []; // new Array(strLen) sparse array is too slow
+ var bitflags = 0;
+ var containsSpace = false; // space isn't stored in bitflags because of how searching with a space works
+
+ for(var i = 0; i < strLen; ++i) {
+ var lowerCode = lowerCodes[i] = lower.charCodeAt(i);
+
+ if(lowerCode === 32) {
+ containsSpace = true;
+ continue // it's important that we don't set any bitflags for space
+ }
+
+ var bit = lowerCode>=97&&lowerCode<=122 ? lowerCode-97 // alphabet
+ : lowerCode>=48&&lowerCode<=57 ? 26 // numbers
+ // 3 bits available
+ : lowerCode<=127 ? 30 // other ascii
+ : 31; // other utf8
+ bitflags |= 1< {
+ var targetLen = target.length;
+ var beginningIndexes = []; var beginningIndexesLen = 0;
+ var wasUpper = false;
+ var wasAlphanum = false;
+ for(var i = 0; i < targetLen; ++i) {
+ var targetCode = target.charCodeAt(i);
+ var isUpper = targetCode>=65&&targetCode<=90;
+ var isAlphanum = isUpper || targetCode>=97&&targetCode<=122 || targetCode>=48&&targetCode<=57;
+ var isBeginning = isUpper && !wasUpper || !wasAlphanum || !isAlphanum;
+ wasUpper = isUpper;
+ wasAlphanum = isAlphanum;
+ if(isBeginning) beginningIndexes[beginningIndexesLen++] = i;
+ }
+ return beginningIndexes
+ };
+ var prepareNextBeginningIndexes = (target) => {
+ var targetLen = target.length;
+ var beginningIndexes = prepareBeginningIndexes(target);
+ var nextBeginningIndexes = []; // new Array(targetLen) sparse array is too slow
+ var lastIsBeginning = beginningIndexes[0];
+ var lastIsBeginningI = 0;
+ for(var i = 0; i < targetLen; ++i) {
+ if(lastIsBeginning > i) {
+ nextBeginningIndexes[i] = lastIsBeginning;
+ } else {
+ lastIsBeginning = beginningIndexes[++lastIsBeginningI];
+ nextBeginningIndexes[i] = lastIsBeginning===undefined ? targetLen : lastIsBeginning;
+ }
+ }
+ return nextBeginningIndexes
+ };
+
+
+ var cleanup = () => { preparedCache.clear(); preparedSearchCache.clear(); matchesSimple = []; matchesStrict = []; };
+
+ var preparedCache = new Map();
+ var preparedSearchCache = new Map();
+ var matchesSimple = []; var matchesStrict = [];
+
+
+ // for use with keys. just returns the maximum score
+ var defaultScoreFn = (a) => {
+ var max = INT_MIN;
+ var len = a.length;
+ for (var i = 0; i < len; ++i) {
+ var result = a[i]; if(result === NULL) continue
+ var score = result.score;
+ if(score > max) max = score;
+ }
+ if(max === INT_MIN) return NULL
+ return max
+ };
+
+ // prop = 'key' 2.5ms optimized for this case, seems to be about as fast as direct obj[prop]
+ // prop = 'key1.key2' 10ms
+ // prop = ['key1', 'key2'] 27ms
+ var getValue = (obj, prop) => {
+ var tmp = obj[prop]; if(tmp !== undefined) return tmp
+ var segs = prop;
+ if(!Array.isArray(prop)) segs = prop.split('.');
+ var len = segs.length;
+ var i = -1;
+ while (obj && (++i < len)) obj = obj[segs[i]];
+ return obj
+ };
+
+ var isObj = (x) => { return typeof x === 'object' }; // faster as a function
+ // var INT_MAX = 9007199254740991; var INT_MIN = -INT_MAX
+ var INT_MAX = Infinity; var INT_MIN = -INT_MAX;
+ var noResults = []; noResults.total = 0;
+ var NULL = null;
+
+
+ // Hacked version of https://github.com/lemire/FastPriorityQueue.js
+ var fastpriorityqueue=r=>{var e=[],o=0,a={},v=r=>{for(var a=0,v=e[a],c=1;c>1]=e[a],c=1+(a<<1);}for(var f=a-1>>1;a>0&&v.score>1)e[a]=e[f];e[a]=v;};return a.add=(r=>{var a=o;e[o++]=r;for(var v=a-1>>1;a>0&&r.score>1)e[a]=e[v];e[a]=r;}),a.poll=(r=>{if(0!==o){var a=e[0];return e[0]=e[--o],v(),a}}),a.peek=(r=>{if(0!==o)return e[0]}),a.replaceTop=(r=>{e[0]=r,v();}),a};
+ var q = fastpriorityqueue(); // reuse this
+
+
+ // fuzzysort is written this way for minification. all names are mangeled unless quoted
+ return {'single':single, 'go':go, 'highlight':highlight, 'prepare':prepare, 'indexes':indexes, 'cleanup':cleanup}
+}); // UMD
+
+// TODO: (feature) frecency
+// TODO: (perf) use different sorting algo depending on the # of results?
+// TODO: (perf) preparedCache is a memory leak
+// TODO: (like sublime) backslash === forwardslash
+// TODO: (perf) prepareSearch seems slow
+});
+
+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;
+ }
+ 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.
+ *
+ * @param str the string to match this Component against.
+ */
+ match(str) {
+ var _a, _b, _c, _d;
+ if (!str) {
+ return Number.NEGATIVE_INFINITY;
+ }
+ return Math.max((_b = (_a = fuzzysort.single(str, getTitle(this.setting))) === null || _a === void 0 ? void 0 : _a.score) !== null && _b !== void 0 ? _b : Number.NEGATIVE_INFINITY, (_d = (_c = fuzzysort.single(str, getDescription(this.setting))) === null || _c === void 0 ? void 0 : _c.score) !== null && _d !== void 0 ? _d : Number.NEGATIVE_INFINITY);
+ }
+ /**
+ * Matches the Component against `str`. A match returns true, no match or a bad match returns false.
+ *
+ * @param str the string to match this Component against.
+ */
+ decisiveMatch(str) {
+ return this.match(str) > -100000;
+ }
+}
+
+const resetTooltip = 'Restore default';
+
+class ClassMultiToggleSettingComponent extends AbstractSettingComponent {
+ 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')}`);
+ }
+ let prevValue = this.getPreviousValue();
+ const defaultLabel = this.getDefaultOptionLabel();
+ this.settingEl = new obsidian.Setting(this.containerEl);
+ this.settingEl.setName(title);
+ this.settingEl.setDesc(createDescription(description, this.setting.default, defaultLabel));
+ this.settingEl.addDropdown((dropdown) => {
+ if (this.setting.allowEmpty) {
+ dropdown.addOption('none', '');
+ }
+ for (const o of this.setting.options) {
+ if (typeof o === 'string') {
+ dropdown.addOption(o, o);
+ }
+ else {
+ dropdown.addOption(o.value, o.label);
+ }
+ }
+ dropdown.setValue(prevValue);
+ dropdown.onChange((value) => {
+ this.settingsManager.setSetting(this.sectionId, this.setting.id, value);
+ prevValue = value;
+ });
+ this.dropdownComponent = dropdown;
+ });
+ this.settingEl.addExtraButton((b) => {
+ b.setIcon('reset');
+ b.onClick(() => {
+ this.dropdownComponent.setValue(this.setting.default || 'none');
+ this.settingsManager.clearSetting(this.sectionId, this.setting.id);
+ });
+ b.setTooltip(resetTooltip);
+ });
+ this.settingEl.settingEl.dataset.id = this.setting.id;
+ }
+ destroy() {
+ var _a;
+ (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.remove();
+ }
+ getDefaultOption() {
+ if (this.setting.default) {
+ return this.setting.options.find((o) => {
+ if (typeof o === 'string') {
+ return o === this.setting.default;
+ }
+ return o.value === this.setting.default;
+ });
+ }
+ return undefined;
+ }
+ getDefaultOptionLabel() {
+ const defaultOption = this.getDefaultOption();
+ if (defaultOption) {
+ if (typeof defaultOption === 'string') {
+ return defaultOption;
+ }
+ return defaultOption.label;
+ }
+ return undefined;
+ }
+ getPreviousValue() {
+ const prevValue = this.settingsManager.getSetting(this.sectionId, this.setting.id);
+ if (prevValue === undefined) {
+ if (this.setting.default) {
+ return this.setting.default;
+ }
+ return 'none';
+ }
+ return prevValue;
+ }
+}
+
+class ClassToggleSettingComponent extends AbstractSettingComponent {
+ render() {
+ const title = getTitle(this.setting);
+ const description = getDescription(this.setting);
+ this.settingEl = new obsidian.Setting(this.containerEl);
+ this.settingEl.setName(title);
+ this.settingEl.setDesc(description !== null && description !== void 0 ? description : '');
+ this.settingEl.addToggle((toggle) => {
+ const value = this.settingsManager.getSetting(this.sectionId, this.setting.id);
+ toggle.setValue(value !== undefined ? !!value : !!this.setting.default);
+ toggle.onChange((value) => {
+ this.settingsManager.setSetting(this.sectionId, this.setting.id, value);
+ });
+ this.toggleComponent = toggle;
+ });
+ this.settingEl.addExtraButton((b) => {
+ b.setIcon('reset');
+ b.onClick(() => {
+ const value = !!this.setting.default;
+ this.toggleComponent.setValue(value);
+ this.settingsManager.clearSetting(this.sectionId, this.setting.id);
+ });
+ b.setTooltip(resetTooltip);
+ });
+ this.settingEl.settingEl.dataset.id = this.setting.id;
+ }
+ destroy() {
+ var _a;
+ (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.remove();
+ }
+}
+
+class InfoTextSettingComponent extends AbstractSettingComponent {
+ render() {
+ const title = getTitle(this.setting);
+ const description = getDescription(this.setting);
+ 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, '', this);
+ this.settingEl.descEl.addClass('style-settings-markdown');
+ }
+ else {
+ this.settingEl.setDesc(description);
+ }
+ }
+ this.settingEl.settingEl.dataset.id = this.setting.id;
+ }
+ destroy() {
+ var _a;
+ (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.remove();
+ }
+}
+
+var pickr_min = createCommonjsModule(function (module, exports) {
+/*! Pickr 1.8.4 MIT | https://github.com/Simonwep/pickr */
+!function(t,e){module.exports=e();}(self,(function(){return (()=>{var t={d:(e,o)=>{for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]});},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0});}},e={};t.d(e,{default:()=>x});var o={};function n(t,e,o,n){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};e instanceof HTMLCollection||e instanceof NodeList?e=Array.from(e):Array.isArray(e)||(e=[e]),Array.isArray(o)||(o=[o]);for(const s of e)for(const e of o)s[t](e,n,{capture:!1,...i});return Array.prototype.slice.call(arguments,1)}t.r(o),t.d(o,{adjustableInputNumbers:()=>p,createElementFromString:()=>r,createFromTemplate:()=>a,eventPath:()=>l,off:()=>s,on:()=>i,resolveElement:()=>c});const i=n.bind(null,"addEventListener"),s=n.bind(null,"removeEventListener");function r(t){const e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild}function a(t){const e=(t,e)=>{const o=t.getAttribute(e);return t.removeAttribute(e),o},o=function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=e(t,":obj"),s=e(t,":ref"),r=i?n[i]={}:n;s&&(n[s]=t);for(const n of Array.from(t.children)){const t=e(n,":arr"),i=o(n,t?{}:r);t&&(r[t]||(r[t]=[])).push(Object.keys(i).length?i:n);}return n};return o(r(t))}function l(t){let e=t.path||t.composedPath&&t.composedPath();if(e)return e;let o=t.target.parentElement;for(e=[t.target,o];o=o.parentElement;)e.push(o);return e.push(document,window),e}function c(t){return t instanceof Element?t:"string"==typeof t?t.split(/>>/g).reduce(((t,e,o,n)=>(t=t.querySelector(e),o1&&void 0!==arguments[1]?arguments[1]:t=>t;function o(o){const n=[.001,.01,.1][Number(o.shiftKey||2*o.ctrlKey)]*(o.deltaY<0?1:-1);let i=0,s=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,((t,o)=>o<=s&&o+t.length>=s?(s=o,e(Number(t),n,i)):(i++,t))),t.focus(),t.setSelectionRange(s,s),o.preventDefault(),t.dispatchEvent(new Event("input"));}i(t,"focus",(()=>i(window,"wheel",o,{passive:!1}))),i(t,"blur",(()=>s(window,"wheel",o)));}const{min:h,max:u,floor:d,round:v}=Math;function m(t,e,o){e/=100,o/=100;const n=d(t=t/360*6),i=t-n,s=o*(1-e),r=o*(1-i*e),a=o*(1-(1-i)*e),l=n%6;return [255*[o,r,s,s,a,o][l],255*[a,o,o,r,s,s][l],255*[s,s,a,o,o,r][l]]}function f(t,e,o){return m(t,e,o).map((t=>v(t).toString(16).padStart(2,"0")))}function g(t,e,o){const n=m(t,e,o),i=n[0]/255,s=n[1]/255,r=n[2]/255,a=h(1-i,1-s,1-r);return [100*(1===a?0:(1-i-a)/(1-a)),100*(1===a?0:(1-s-a)/(1-a)),100*(1===a?0:(1-r-a)/(1-a)),100*a]}function b(t,e,o){const n=(2-(e/=100))*(o/=100)/2;return 0!==n&&(e=1===n?0:n<.5?e*o/(2*n):e*o/(2-2*n)),[t,100*e,100*n]}function y(t,e,o){const n=h(t/=255,e/=255,o/=255),i=u(t,e,o),s=i-n;let r,a;if(0===s)r=a=0;else {a=s/i;const n=((i-t)/6+s/2)/s,l=((i-e)/6+s/2)/s,c=((i-o)/6+s/2)/s;t===i?r=c-l:e===i?r=1/3+n-c:o===i&&(r=2/3+l-n),r<0?r+=1:r>1&&(r-=1);}return [360*r,100*a,100*i]}function _(t,e,o,n){e/=100,o/=100;return [...y(255*(1-h(1,(t/=100)*(1-(n/=100))+n)),255*(1-h(1,e*(1-n)+n)),255*(1-h(1,o*(1-n)+n)))]}function w(t,e,o){e/=100;const n=2*(e*=(o/=100)<.5?o:1-o)/(o+e)*100,i=100*(o+e);return [t,isNaN(n)?0:n,i]}function A(t){return y(...t.match(/.{2}/g).map((t=>parseInt(t,16))))}function C(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return "#000";const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000"===e.fillStyle?null:e.fillStyle}(t):t;const e={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},o=t=>t.map((t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0));let n;t:for(const i in e){if(!(n=e[i].exec(t)))continue;const s=t=>!!n[2]==("number"==typeof t);switch(i){case"cmyk":{const[,t,e,s,r]=o(n);if(t>100||e>100||s>100||r>100)break t;return {values:_(t,e,s,r),type:i}}case"rgba":{const[,,,t,e,r,a]=o(n);if(t>255||e>255||r>255||a<0||a>1||!s(a))break t;return {values:[...y(t,e,r),a],a,type:i}}case"hexa":{let[,t]=n;4!==t.length&&3!==t.length||(t=t.split("").map((t=>t+t)).join(""));const e=t.substring(0,6);let o=t.substring(6);return o=o?parseInt(o,16)/255:void 0,{values:[...A(e),o],a:o,type:i}}case"hsla":{const[,,,t,e,r,a]=o(n);if(t>360||e>100||r>100||a<0||a>1||!s(a))break t;return {values:[...w(t,e,r),a],a,type:i}}case"hsva":{const[,,,t,e,r,a]=o(n);if(t>360||e>100||r>100||a<0||a>1||!s(a))break t;return {values:[t,e,r,a],a,type:i}}}}return {values:null,type:null}}function $(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;const i=(t,e)=>function(){let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;return e(~o?t.map((t=>Number(t.toFixed(o)))):t)},s={h:t,s:e,v:o,a:n,toHSVA(){const t=[s.h,s.s,s.v,s.a];return t.toString=i(t,(t=>`hsva(${t[0]}, ${t[1]}%, ${t[2]}%, ${s.a})`)),t},toHSLA(){const t=[...b(s.h,s.s,s.v),s.a];return t.toString=i(t,(t=>`hsla(${t[0]}, ${t[1]}%, ${t[2]}%, ${s.a})`)),t},toRGBA(){const t=[...m(s.h,s.s,s.v),s.a];return t.toString=i(t,(t=>`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${s.a})`)),t},toCMYK(){const t=g(s.h,s.s,s.v);return t.toString=i(t,(t=>`cmyk(${t[0]}%, ${t[1]}%, ${t[2]}%, ${t[3]}%)`)),t},toHEXA(){const t=f(s.h,s.s,s.v),e=s.a>=1?"":Number((255*s.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return e&&t.push(e),t.toString=()=>`#${t.join("").toUpperCase()}`,t},clone:()=>$(s.h,s.s,s.v,s.a)};return s}const k=t=>Math.max(Math.min(t,1),0);function S(t){const e={options:Object.assign({lock:null,onchange:()=>0,onstop:()=>0},t),_keyboard(t){const{options:o}=e,{type:n,key:i}=t;if(document.activeElement===o.wrapper){const{lock:o}=e.options,s="ArrowUp"===i,r="ArrowRight"===i,a="ArrowDown"===i,l="ArrowLeft"===i;if("keydown"===n&&(s||r||a||l)){let n=0,i=0;"v"===o?n=s||r?1:-1:"h"===o?n=s||r?-1:1:(i=s?-1:a?1:0,n=l?-1:r?1:0),e.update(k(e.cache.x+.01*n),k(e.cache.y+.01*i)),t.preventDefault();}else i.startsWith("Arrow")&&(e.options.onstop(),t.preventDefault());}},_tapstart(t){i(document,["mouseup","touchend","touchcancel"],e._tapstop),i(document,["mousemove","touchmove"],e._tapmove),t.cancelable&&t.preventDefault(),e._tapmove(t);},_tapmove(t){const{options:o,cache:n}=e,{lock:i,element:s,wrapper:r}=o,a=r.getBoundingClientRect();let l=0,c=0;if(t){const e=t&&t.touches&&t.touches[0];l=t?(e||t).clientX:0,c=t?(e||t).clientY:0,la.left+a.width&&(l=a.left+a.width),ca.top+a.height&&(c=a.top+a.height),l-=a.left,c-=a.top;}else n&&(l=n.x*a.width,c=n.y*a.height);"h"!==i&&(s.style.left=`calc(${l/a.width*100}% - ${s.offsetWidth/2}px)`),"v"!==i&&(s.style.top=`calc(${c/a.height*100}% - ${s.offsetHeight/2}px)`),e.cache={x:l/a.width,y:c/a.height};const p=k(l/a.width),h=k(c/a.height);switch(i){case"v":return o.onchange(p);case"h":return o.onchange(h);default:return o.onchange(p,h)}},_tapstop(){e.options.onstop(),s(document,["mouseup","touchend","touchcancel"],e._tapstop),s(document,["mousemove","touchmove"],e._tapmove);},trigger(){e._tapmove();},update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const{left:n,top:i,width:s,height:r}=e.options.wrapper.getBoundingClientRect();"h"===e.options.lock&&(o=t),e._tapmove({clientX:n+s*t,clientY:i+r*o});},destroy(){const{options:t,_tapstart:o,_keyboard:n}=e;s(document,["keydown","keyup"],n),s([t.wrapper,t.element],"mousedown",o),s([t.wrapper,t.element],"touchstart",o,{passive:!1});}},{options:o,_tapstart:n,_keyboard:r}=e;return i([o.wrapper,o.element],"mousedown",n),i([o.wrapper,o.element],"touchstart",n,{passive:!1}),i(document,["keydown","keyup"],r),e}function O(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=Object.assign({onchange:()=>0,className:"",elements:[]},t);const e=i(t.elements,"click",(e=>{t.elements.forEach((o=>o.classList[e.target===o?"add":"remove"](t.className))),t.onchange(e),e.stopPropagation();}));return {destroy:()=>s(...e)}}const E={variantFlipOrder:{start:"sme",middle:"mse",end:"ems"},positionFlipOrder:{top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},position:"bottom",margin:8},L=(t,e,o)=>{const{container:n,margin:i,position:s,variantFlipOrder:r,positionFlipOrder:a}={container:document.documentElement.getBoundingClientRect(),...E,...o},{left:l,top:c}=e.style;e.style.left="0",e.style.top="0";const p=t.getBoundingClientRect(),h=e.getBoundingClientRect(),u={t:p.top-h.height-i,b:p.bottom+i,r:p.right+i,l:p.left-h.width-i},d={vs:p.left,vm:p.left+p.width/2+-h.width/2,ve:p.left+p.width-h.width,hs:p.top,hm:p.bottom-p.height/2-h.height/2,he:p.bottom-h.height},[v,m="middle"]=s.split("-"),f=a[v],g=r[m],{top:b,left:y,bottom:_,right:w}=n;for(const t of f){const o="t"===t||"b"===t,n=u[t],[i,s]=o?["top","left"]:["left","top"],[r,a]=o?[h.height,h.width]:[h.width,h.height],[l,c]=o?[_,w]:[w,_],[p,v]=o?[b,y]:[y,b];if(!(n
l))for(const r of g){const l=d[(o?"v":"h")+r];if(!(lc))return e.style[s]=l-h[s]+"px",e.style[i]=n-h[i]+"px",t+r}}return e.style.left=l,e.style.top=c,null};function P(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class x{constructor(t){P(this,"_initializingActive",!0),P(this,"_recalc",!0),P(this,"_nanopop",null),P(this,"_root",null),P(this,"_color",$()),P(this,"_lastColor",$()),P(this,"_swatchColors",[]),P(this,"_setupAnimationFrame",null),P(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=t=Object.assign({...x.DEFAULT_OPTIONS},t);const{swatches:e,components:o,theme:n,sliders:i,lockOpacity:s,padding:r}=t;["nano","monolith"].includes(n)&&!i&&(t.sliders="h"),o.interaction||(o.interaction={});const{preview:a,opacity:l,hue:c,palette:p}=o;o.opacity=!s&&l,o.palette=p||a||l||c,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),e&&e.length&&e.forEach((t=>this.addSwatch(t)));const{button:h,app:u}=this._root;this._nanopop=((t,e,o)=>{const n="object"!=typeof t||t instanceof HTMLElement?{reference:t,popper:e,...o}:t;return {update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n;const{reference:e,popper:o}=Object.assign(n,t);if(!o||!e)throw new Error("Popper- or reference-element missing.");return L(e,o,n)}}})(h,u,{margin:r}),h.setAttribute("role","button"),h.setAttribute("aria-label",this._t("btn:toggle"));const d=this;this._setupAnimationFrame=requestAnimationFrame((function e(){if(!u.offsetWidth)return d._setupAnimationFrame=requestAnimationFrame(e);d.setColor(t.default),d._rePositioningPicker(),t.defaultRepresentation&&(d._representation=t.defaultRepresentation,d.setColorRepresentation(d._representation)),t.showAlways&&d.show(),d._initializingActive=!1,d._emit("init");}));}_preBuild(){const{options:t}=this;for(const e of ["el","container"])t[e]=c(t[e]);this._root=(t=>{const{components:e,useAsButton:o,inline:n,appClass:i,theme:s,lockOpacity:r}=t.options,l=t=>t?"":'style="display:none" hidden',c=e=>t._t(e),p=a(`\n
\n\n ${o?"":''}\n\n
\n
\n
\n \n \n
\n\n
\n \n \n
\n\n
\n \n \n
\n\n
\n \n \n
\n
\n\n \n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n
\n `),h=p.interaction;return h.options.find((t=>!t.hidden&&!t.classList.add("active"))),h.type=()=>h.options.find((t=>t.classList.contains("active"))),p})(this),t.useAsButton&&(this._root.button=t.el),t.container.appendChild(this._root.root);}_finalBuild(){const t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){const o=t.el.parentElement;t.el.nextSibling?o.insertBefore(e.app,t.el.nextSibling):o.appendChild(e.app);}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide();}_buildComponents(){const t=this,e=this.options.components,o=(t.options.sliders||"v").repeat(2),[n,i]=o.match(/^[vh]+$/g)?o:[],s=()=>this._color||(this._color=this._lastColor.clone()),r={palette:S({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop","slider",t),onchange(o,n){if(!e.palette)return;const i=s(),{_root:r,options:a}=t,{lastColor:l,currentColor:c}=r.preview;t._recalc&&(i.s=100*o,i.v=100-100*n,i.v<0&&(i.v=0),t._updateOutput("slider"));const p=i.toRGBA().toString(0);this.element.style.background=p,this.wrapper.style.background=`\n linear-gradient(to top, rgba(0, 0, 0, ${i.a}), transparent),\n linear-gradient(to left, hsla(${i.h}, 100%, 50%, ${i.a}), rgba(255, 255, 255, ${i.a}))\n `,a.comparison?a.useAsButton||t._lastColor||l.style.setProperty("--pcr-color",p):(r.button.style.setProperty("--pcr-color",p),r.button.classList.remove("clear"));const h=i.toHEXA().toString();for(const{el:e,color:o}of t._swatchColors)e.classList[h===o.toHEXA().toString()?"add":"remove"]("pcr-active");c.style.setProperty("--pcr-color",p);}}),hue:S({lock:"v"===i?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop","slider",t),onchange(o){if(!e.hue||!e.palette)return;const n=s();t._recalc&&(n.h=360*o),this.element.style.backgroundColor=`hsl(${n.h}, 100%, 50%)`,r.palette.trigger();}}),opacity:S({lock:"v"===n?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop","slider",t),onchange(o){if(!e.opacity||!e.palette)return;const n=s();t._recalc&&(n.a=Math.round(100*o)/100),this.element.style.background=`rgba(0, 0, 0, ${n.a})`,r.palette.trigger();}}),selectable:O({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput("swatch");}})};this._components=r;}_bindEvents(){const{_root:t,options:e}=this,o=[i(t.interaction.clear,"click",(()=>this._clearColor())),i([t.interaction.cancel,t.preview.lastColor],"click",(()=>{this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0),this._emit("cancel");})),i(t.interaction.save,"click",(()=>{!this.applyColor()&&!e.showAlways&&this.hide();})),i(t.interaction.result,["keyup","input"],(t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&(this._emit("change",this._color,"input",this),this._emit("changestop","input",this)),t.stopImmediatePropagation();})),i(t.interaction.result,["focus","blur"],(t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput(null);})),i([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],(()=>this._recalc=!0),{passive:!0})];if(!e.showAlways){const n=e.closeWithKey;o.push(i(t.button,"click",(()=>this.isOpen()?this.hide():this.show())),i(document,"keyup",(t=>this.isOpen()&&(t.key===n||t.code===n)&&this.hide())),i(document,["touchstart","mousedown"],(e=>{this.isOpen()&&!l(e).some((e=>e===t.app||e===t.button))&&this.hide();}),{capture:!0}));}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};p(t.interaction.result,((t,o,n)=>{const i=e[this.getColorRepresentation().toLowerCase()];if(i){const e=i[n],s=t+(e>=100?1e3*o:o);return s<=0?0:Number((s{n.isOpen()&&(e.closeOnScroll&&n.hide(),null===t?(t=setTimeout((()=>t=null),100),requestAnimationFrame((function e(){n._rePositioningPicker(),null!==t&&requestAnimationFrame(e);}))):(clearTimeout(t),t=setTimeout((()=>t=null),100)));}),{capture:!0}));}this._eventBindings=o;}_rePositioningPicker(){const{options:t}=this;if(!t.inline){if(!this._nanopop.update({container:document.body.getBoundingClientRect(),position:t.position})){const t=this._root.app,e=t.getBoundingClientRect();t.style.top=(window.innerHeight-e.height)/2+"px",t.style.left=(window.innerWidth-e.width)/2+"px";}}}_updateOutput(t){const{_root:e,_color:o,options:n}=this;if(e.interaction.type()){const t=`to${e.interaction.type().getAttribute("data-type")}`;e.interaction.result.value="function"==typeof o[t]?o[t]().toString(n.outputPrecision):"";}!this._initializingActive&&this._recalc&&this._emit("change",o,t,this);}_clearColor(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{_root:e,options:o}=this;o.useAsButton||e.button.style.setProperty("--pcr-color","rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),o.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear"));}_parseLocalColor(t){const{values:e,type:o,a:n}=C(t),{lockOpacity:i}=this.options,s=void 0!==n&&1!==n;return e&&3===e.length&&(e[3]=void 0),{values:!e||i&&s?null:e,type:o}}_t(t){return this.options.i18n[t]||x.I18N_DEFAULTS[t]}_emit(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),n=1;nt(...o,this)));}on(t,e){return this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t]||[],n=o.indexOf(e);return ~n&&o.splice(n,1),this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:o}=this,n=$(...e),s=r(``);return o.swatches.appendChild(s),t.push({el:s,color:n}),this._eventBindings.push(i(s,"click",(()=>{this.setHSVA(...n.toHSVA(),!0),this._emit("swatchselect",n),this._emit("change",n,"swatch",this);}))),!0}return !1}removeSwatch(t){const e=this._swatchColors[t];if(e){const{el:o}=e;return this._root.swatches.removeChild(o),this._swatchColors.splice(t,1),!0}return !1}applyColor(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{preview:e,button:o}=this._root,n=this._color.toRGBA().toString(0);return e.lastColor.style.setProperty("--pcr-color",n),this.options.useAsButton||o.style.setProperty("--pcr-color",n),o.classList.remove("clear"),this._lastColor=this._color.clone(),this._initializingActive||t||this._emit("save",this._color),this}destroy(){cancelAnimationFrame(this._setupAnimationFrame),this._eventBindings.forEach((t=>s(...t))),Object.keys(this._components).forEach((t=>this._components[t].destroy()));}destroyAndRemove(){this.destroy();const{root:t,app:e}=this._root;t.parentElement&&t.parentElement.removeChild(t),e.parentElement.removeChild(e),Object.keys(this).forEach((t=>this[t]=null));}hide(){return !!this.isOpen()&&(this._root.app.classList.remove("visible"),this._emit("hide"),!0)}show(){return !this.options.disabled&&!this.isOpen()&&(this._root.app.classList.add("visible"),this._rePositioningPicker(),this._emit("show",this._color),this)}isOpen(){return this._root.app.classList.contains("visible")}setHSVA(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:360,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const s=this._recalc;if(this._recalc=!1,t<0||t>360||e<0||e>100||o<0||o>100||n<0||n>1)return !1;this._color=$(t,e,o,n);const{hue:r,opacity:a,palette:l}=this._components;return r.update(t/360),a.update(n),l.update(e/100,1-o/100),i||this.applyColor(),s&&this._updateOutput(),this._recalc=s,!0}setColor(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(null===t)return this._clearColor(e),!0;const{values:o,type:n}=this._parseLocalColor(t);if(o){const t=n.toUpperCase(),{options:i}=this._root.interaction,s=i.find((e=>e.getAttribute("data-type")===t));if(s&&!s.hidden)for(const t of i)t.classList[t===s?"add":"remove"]("active");return !!this.setHSVA(...o,e)&&this.setColorRepresentation(t)}return !1}setColorRepresentation(t){return t=t.toUpperCase(),!!this._root.interaction.options.find((e=>e.getAttribute("data-type").startsWith(t)&&!e.click()))}getColorRepresentation(){return this._representation}getColor(){return this._color}getSelectedColor(){return this._lastColor}getRoot(){return this._root}disable(){return this.hide(),this.options.disabled=!0,this._root.button.classList.add("disabled"),this}enable(){return this.options.disabled=!1,this._root.button.classList.remove("disabled"),this}}return P(x,"utils",o),P(x,"version","1.8.4"),P(x,"I18N_DEFAULTS",{"ui:dialog":"color picker dialog","btn:toggle":"toggle color picker dialog","btn:swatch":"color swatch","btn:last-color":"use previous color","btn:save":"Save","btn:cancel":"Cancel","btn:clear":"Clear","aria:btn:save":"save and close","aria:btn:cancel":"cancel and close","aria:btn:clear":"clear and close","aria:input":"color input field","aria:palette":"color selection area","aria:hue":"hue selection slider","aria:opacity":"selection slider"}),P(x,"DEFAULT_OPTIONS",{appClass:null,theme:"classic",useAsButton:!1,padding:8,disabled:!1,comparison:!0,closeOnScroll:!1,outputPrecision:0,lockOpacity:!1,autoReposition:!0,container:"body",components:{interaction:{}},i18n:{},swatches:null,inline:!1,sliders:null,default:"#42445a",defaultRepresentation:null,position:"bottom-middle",adjustableNumbers:!0,showAlways:!1,closeWithKey:"Escape"}),P(x,"create",(t=>new x(t))),e=e.default})()}));
+
+});
+
+var Pickr = /*@__PURE__*/getDefaultExportFromCjs(pickr_min);
+
+class VariableColorSettingComponent extends AbstractSettingComponent {
+ render() {
+ var _a;
+ const title = getTitle(this.setting);
+ const description = getDescription(this.setting);
+ if (typeof this.setting.default !== 'string' ||
+ !isValidDefaultColor(this.setting.default)) {
+ this.setting.default = (_a = this.settingsManager.plugin
+ .getCSSVar(this.setting.id)
+ .current) === null || _a === void 0 ? void 0 : _a.trim();
+ }
+ if (typeof this.setting.default !== 'string' ||
+ !isValidDefaultColor(this.setting.default)) {
+ return console.error(`${t('Error:')} ${title} ${t('missing default value, or value is not in a valid color format')}`);
+ }
+ const value = this.settingsManager.getSetting(this.sectionId, this.setting.id);
+ const swatches = [];
+ if (this.setting.default) {
+ swatches.push(this.setting.default);
+ }
+ if (value !== undefined) {
+ swatches.push(value);
+ }
+ 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;
+ this.containerEl.style.setProperty('--pcr-color', defaultColor);
+ this.pickr = Pickr.create(getPickrSettings({
+ isView: this.isView,
+ el: this.settingEl.controlEl.createDiv({ cls: 'picker' }),
+ containerEl: this.containerEl,
+ swatches: swatches,
+ opacity: this.setting.opacity,
+ defaultColor: defaultColor,
+ }));
+ this.pickr.on('save', (color, instance) => {
+ if (!color)
+ return;
+ this.settingsManager.setSetting(this.sectionId, this.setting.id, color.toHEXA().toString());
+ instance.hide();
+ instance.addSwatch(color.toHEXA().toString());
+ });
+ this.pickr.on('show', () => {
+ const { result } = this.pickr.getRoot().interaction;
+ activeWindow.requestAnimationFrame(() => {
+ activeWindow.requestAnimationFrame(() => result.select());
+ });
+ });
+ this.pickr.on('cancel', onPickrCancel);
+ this.settingEl.addExtraButton((b) => {
+ b.setIcon('reset');
+ b.onClick(() => {
+ this.pickr.setColor(this.setting.default);
+ this.settingsManager.clearSetting(this.sectionId, this.setting.id);
+ });
+ b.setTooltip(resetTooltip);
+ });
+ this.settingEl.settingEl.dataset.id = this.setting.id;
+ }
+ destroy() {
+ var _a, _b;
+ (_a = this.pickr) === null || _a === void 0 ? void 0 : _a.destroyAndRemove();
+ this.pickr = undefined;
+ (_b = this.settingEl) === null || _b === void 0 ? void 0 : _b.settingEl.remove();
+ }
+}
+
+class VariableNumberSettingComponent extends AbstractSettingComponent {
+ 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(this.containerEl);
+ this.settingEl.setName(title);
+ this.settingEl.setDesc(createDescription(description, this.setting.default.toString(10)));
+ this.settingEl.addText((text) => {
+ const value = this.settingsManager.getSetting(this.sectionId, this.setting.id);
+ const onChange = obsidian.debounce((value) => {
+ const isFloat = /\./.test(value);
+ this.settingsManager.setSetting(this.sectionId, this.setting.id, isFloat ? parseFloat(value) : parseInt(value, 10));
+ }, 250, true);
+ text.setValue(value !== undefined ? value.toString() : this.setting.default.toString());
+ text.onChange(onChange);
+ this.textComponent = text;
+ });
+ this.settingEl.addExtraButton((b) => {
+ b.setIcon('reset');
+ b.onClick(() => {
+ this.textComponent.setValue(this.setting.default.toString());
+ this.settingsManager.clearSetting(this.sectionId, this.setting.id);
+ });
+ b.setTooltip(resetTooltip);
+ });
+ this.settingEl.settingEl.dataset.id = this.setting.id;
+ }
+ destroy() {
+ var _a;
+ (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.remove();
+ }
+}
+
+class VariableNumberSliderSettingComponent extends AbstractSettingComponent {
+ 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(this.containerEl);
+ this.settingEl.setName(title);
+ this.settingEl.setDesc(createDescription(description, this.setting.default.toString(10)));
+ this.settingEl.addSlider((slider) => {
+ const value = this.settingsManager.getSetting(this.sectionId, this.setting.id);
+ const onChange = obsidian.debounce((value) => {
+ this.settingsManager.setSetting(this.sectionId, this.setting.id, value);
+ }, 250, true);
+ slider.setDynamicTooltip();
+ slider.setLimits(this.setting.min, this.setting.max, this.setting.step);
+ slider.setValue(value !== undefined ? value : this.setting.default);
+ slider.onChange(onChange);
+ this.sliderComponent = slider;
+ });
+ this.settingEl.addExtraButton((b) => {
+ b.setIcon('reset');
+ b.onClick(() => {
+ this.sliderComponent.setValue(this.setting.default);
+ this.settingsManager.clearSetting(this.sectionId, this.setting.id);
+ });
+ b.setTooltip(resetTooltip);
+ });
+ this.settingEl.settingEl.dataset.id = this.setting.id;
+ }
+ destroy() {
+ var _a;
+ (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.remove();
+ }
+}
+
+class VariableSelectSettingComponent extends AbstractSettingComponent {
+ 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(this.containerEl);
+ this.settingEl.setName(title);
+ this.settingEl.setDesc(createDescription(description, this.setting.default, defaultLabel));
+ this.settingEl.addDropdown((dropdown) => {
+ const value = this.settingsManager.getSetting(this.sectionId, this.setting.id);
+ for (const o of this.setting.options) {
+ if (typeof o === 'string') {
+ dropdown.addOption(o, o);
+ }
+ else {
+ dropdown.addOption(o.value, o.label);
+ }
+ }
+ dropdown.setValue(value !== undefined ? value : this.setting.default);
+ dropdown.onChange((value) => {
+ this.settingsManager.setSetting(this.sectionId, this.setting.id, value);
+ });
+ this.dropdownComponent = dropdown;
+ });
+ this.settingEl.addExtraButton((b) => {
+ b.setIcon('reset');
+ b.onClick(() => {
+ this.dropdownComponent.setValue(this.setting.default);
+ this.settingsManager.clearSetting(this.sectionId, this.setting.id);
+ });
+ b.setTooltip(resetTooltip);
+ });
+ this.settingEl.settingEl.dataset.id = this.setting.id;
+ }
+ destroy() {
+ var _a;
+ (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.remove();
+ }
+ getDefaultOption() {
+ if (this.setting.default) {
+ return this.setting.options.find((o) => {
+ if (typeof o === 'string') {
+ return o === this.setting.default;
+ }
+ return o.value === this.setting.default;
+ });
+ }
+ return undefined;
+ }
+ getDefaultOptionLabel() {
+ const defaultOption = this.getDefaultOption();
+ if (defaultOption) {
+ if (typeof defaultOption === 'string') {
+ return defaultOption;
+ }
+ return defaultOption.label;
+ }
+ return undefined;
+ }
+}
+
+class VariableTextSettingComponent extends AbstractSettingComponent {
+ 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(this.containerEl);
+ this.settingEl.setName(title);
+ this.settingEl.setDesc(createDescription(description, this.setting.default));
+ this.settingEl.addText((text) => {
+ let value = this.settingsManager.getSetting(this.sectionId, this.setting.id);
+ const onChange = obsidian.debounce((value) => {
+ this.settingsManager.setSetting(this.sectionId, this.setting.id, sanitizeText(value));
+ }, 250, true);
+ if (this.setting.quotes && value === `""`) {
+ value = ``;
+ }
+ text.setValue(value ? value.toString() : this.setting.default);
+ text.onChange(onChange);
+ this.textComponent = text;
+ });
+ this.settingEl.addExtraButton((b) => {
+ b.setIcon('reset');
+ b.onClick(() => {
+ this.textComponent.setValue(this.setting.default);
+ this.settingsManager.clearSetting(this.sectionId, this.setting.id);
+ });
+ b.setTooltip(resetTooltip);
+ });
+ this.settingEl.settingEl.dataset.id = this.setting.id;
+ }
+ destroy() {
+ var _a;
+ (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.remove();
+ }
+}
+
+class VariableThemedColorSettingComponent extends AbstractSettingComponent {
+ render() {
+ const title = getTitle(this.setting);
+ const description = getDescription(this.setting);
+ if (typeof this.setting['default-light'] !== 'string' ||
+ !isValidDefaultColor(this.setting['default-light'])) {
+ return console.error(`${t('Error:')} ${title} ${t('missing default light value, or value is not in a valid color format')}`);
+ }
+ if (typeof this.setting['default-dark'] !== 'string' ||
+ !isValidDefaultColor(this.setting['default-dark'])) {
+ return console.error(`${t('Error:')} ${title} ${t('missing default dark value, or value is not in a valid color format')}`);
+ }
+ const idLight = `${this.setting.id}@@light`;
+ const idDark = `${this.setting.id}@@dark`;
+ const valueLight = this.settingsManager.getSetting(this.sectionId, idLight);
+ const valueDark = this.settingsManager.getSetting(this.sectionId, idDark);
+ const swatchesLight = [];
+ const swatchesDark = [];
+ if (this.setting['default-light']) {
+ swatchesLight.push(this.setting['default-light']);
+ }
+ if (valueLight !== undefined) {
+ swatchesLight.push(valueLight);
+ }
+ if (this.setting['default-dark']) {
+ swatchesDark.push(this.setting['default-dark']);
+ }
+ if (valueDark !== undefined) {
+ swatchesDark.push(valueDark);
+ }
+ this.settingEl = new obsidian.Setting(this.containerEl);
+ this.settingEl.setName(title);
+ // Construct description
+ this.settingEl.descEl.createSpan({}, (span) => {
+ if (description) {
+ span.appendChild(document.createTextNode(description));
+ }
+ });
+ this.settingEl.descEl.createDiv({}, (div) => {
+ div.createEl('small', {}, (sm) => {
+ sm.appendChild(createEl('strong', { text: 'Default (light): ' }));
+ sm.appendChild(document.createTextNode(this.setting['default-light']));
+ });
+ div.createEl('br');
+ div.createEl('small', {}, (sm) => {
+ sm.appendChild(createEl('strong', { text: 'Default (dark): ' }));
+ sm.appendChild(document.createTextNode(this.setting['default-dark']));
+ });
+ });
+ const wrapper = this.settingEl.controlEl.createDiv({
+ cls: 'themed-color-wrapper',
+ });
+ // Create light color picker
+ this.createColorPickerLight(wrapper, this.containerEl, swatchesLight, valueLight, idLight);
+ // Create dark color picker
+ this.createColorPickerDark(wrapper, this.containerEl, swatchesDark, valueDark, idDark);
+ this.settingEl.settingEl.dataset.id = this.setting.id;
+ }
+ destroy() {
+ var _a, _b, _c;
+ (_a = this.pickrLight) === null || _a === void 0 ? void 0 : _a.destroyAndRemove();
+ (_b = this.pickrDark) === null || _b === void 0 ? void 0 : _b.destroyAndRemove();
+ this.pickrLight = undefined;
+ this.pickrDark = undefined;
+ (_c = this.settingEl) === null || _c === void 0 ? void 0 : _c.settingEl.remove();
+ }
+ createColorPickerLight(wrapper, containerEl, swatchesLight, valueLight, idLight) {
+ const themeLightWrapper = wrapper.createDiv({ cls: 'theme-light' });
+ // fix, so that the color is correctly shown before the color picker has been opened
+ const defaultColor = valueLight !== undefined
+ ? valueLight
+ : this.setting['default-light'];
+ themeLightWrapper.style.setProperty('--pcr-color', defaultColor);
+ this.pickrLight = Pickr.create(getPickrSettings({
+ isView: this.isView,
+ el: themeLightWrapper.createDiv({ cls: 'picker' }),
+ containerEl,
+ swatches: swatchesLight,
+ opacity: this.setting.opacity,
+ defaultColor: defaultColor,
+ }));
+ this.pickrLight.on('show', () => {
+ const { result } = this.pickrLight.getRoot().interaction;
+ activeWindow.requestAnimationFrame(() => activeWindow.requestAnimationFrame(() => result.select()));
+ });
+ this.pickrLight.on('save', (color, instance) => this.onSave(idLight, color, instance));
+ this.pickrLight.on('cancel', onPickrCancel);
+ const themeLightReset = new obsidian.ButtonComponent(themeLightWrapper.createDiv({ cls: 'pickr-reset' }));
+ themeLightReset.setIcon('reset');
+ themeLightReset.onClick(() => {
+ this.pickrLight.setColor(this.setting['default-light']);
+ this.settingsManager.clearSetting(this.sectionId, idLight);
+ });
+ themeLightReset.setTooltip(resetTooltip);
+ }
+ createColorPickerDark(wrapper, containerEl, swatchesDark, valueDark, idDark) {
+ const themeDarkWrapper = wrapper.createDiv({ cls: 'theme-dark' });
+ // fix, so that the color is correctly shown before the color picker has been opened
+ const defaultColor = valueDark !== undefined
+ ? valueDark
+ : this.setting['default-dark'];
+ themeDarkWrapper.style.setProperty('--pcr-color', defaultColor);
+ this.pickrDark = Pickr.create(getPickrSettings({
+ isView: this.isView,
+ el: themeDarkWrapper.createDiv({ cls: 'picker' }),
+ containerEl,
+ swatches: swatchesDark,
+ opacity: this.setting.opacity,
+ defaultColor: defaultColor,
+ }));
+ this.pickrDark.on('show', () => {
+ const { result } = this.pickrDark.getRoot().interaction;
+ activeWindow.requestAnimationFrame(() => activeWindow.requestAnimationFrame(() => result.select()));
+ });
+ this.pickrDark.on('save', (color, instance) => this.onSave(idDark, color, instance));
+ this.pickrDark.on('cancel', onPickrCancel);
+ const themeDarkReset = new obsidian.ButtonComponent(themeDarkWrapper.createDiv({ cls: 'pickr-reset' }));
+ themeDarkReset.setIcon('reset');
+ themeDarkReset.onClick(() => {
+ this.pickrDark.setColor(this.setting['default-dark']);
+ this.settingsManager.clearSetting(this.sectionId, idDark);
+ });
+ themeDarkReset.setTooltip(resetTooltip);
+ }
+ onSave(id, color, instance) {
+ if (!color)
+ return;
+ this.settingsManager.setSetting(this.sectionId, id, color.toHEXA().toString());
+ instance.hide();
+ instance.addSwatch(color.toHEXA().toString());
+ }
+}
+
+function createSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView) {
+ if (setting.type === SettingType.HEADING) {
+ return new HeadingSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView);
+ }
+ else if (setting.type === SettingType.INFO_TEXT) {
+ return new InfoTextSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView);
+ }
+ else if (setting.type === SettingType.CLASS_TOGGLE) {
+ return new ClassToggleSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView);
+ }
+ else if (setting.type === SettingType.CLASS_SELECT) {
+ return new ClassMultiToggleSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView);
+ }
+ else if (setting.type === SettingType.VARIABLE_TEXT) {
+ return new VariableTextSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView);
+ }
+ else if (setting.type === SettingType.VARIABLE_NUMBER) {
+ return new VariableNumberSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView);
+ }
+ else if (setting.type === SettingType.VARIABLE_NUMBER_SLIDER) {
+ return new VariableNumberSliderSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView);
+ }
+ else if (setting.type === SettingType.VARIABLE_SELECT) {
+ return new VariableSelectSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView);
+ }
+ else if (setting.type === SettingType.VARIABLE_COLOR) {
+ return new VariableColorSettingComponent(parent, sectionId, sectionName, setting, settingsManager, isView);
+ }
+ else if (setting.type === SettingType.VARIABLE_THEMED_COLOR) {
+ 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 {
+ constructor() {
+ super(...arguments);
+ this.children = [];
+ this.filteredChildren = [];
+ this.filterMode = false;
+ this.filterResultCount = 0;
+ }
+ render() {
+ const title = getTitle(this.setting);
+ const description = getDescription(this.setting);
+ this.settingEl = new obsidian.Setting(this.containerEl);
+ this.settingEl.setHeading();
+ this.settingEl.setClass('style-settings-heading');
+ this.settingEl.setName(title);
+ this.settingEl.setDesc(description !== null && description !== void 0 ? description : '');
+ this.settingEl.settingEl.dataset.level = this.setting.level.toString();
+ this.settingEl.settingEl.dataset.id = this.setting.id;
+ const iconContainer = createSpan({
+ cls: 'style-settings-collapse-indicator',
+ });
+ obsidian.setIcon(iconContainer, 'right-triangle');
+ this.settingEl.nameEl.prepend(iconContainer);
+ 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 = this.containerEl.createDiv({
+ cls: 'style-settings-container',
+ });
+ this.setCollapsed(this.setting.collapsed);
+ }
+ destroy() {
+ var _a;
+ 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) {
+ if (child.setting.type === SettingType.HEADING) {
+ const childResultCount = child.filter(filterString);
+ if (childResultCount > 0) {
+ this.filterResultCount += childResultCount;
+ this.filteredChildren.push(child);
+ }
+ }
+ else {
+ if (child.decisiveMatch(filterString)) {
+ this.filteredChildren.push(child);
+ this.filterResultCount += 1;
+ }
+ }
+ }
+ this.filterMode = true;
+ 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) {
+ child.clearFilter();
+ }
+ }
+ this.filterMode = false;
+ this.setCollapsed(true);
+ this.renderChildren();
+ (_a = this.resultsEl) === null || _a === void 0 ? void 0 : _a.empty();
+ }
+ renderChildren() {
+ this.removeChildren();
+ if (this.filterMode) {
+ for (const child of this.filteredChildren) {
+ this.addChild(child);
+ }
+ }
+ else {
+ for (const child of this.children) {
+ this.addChild(child);
+ }
+ }
+ }
+ removeChildren() {
+ for (const child of this.children) {
+ this.removeChild(child);
+ }
+ }
+ toggleVisible() {
+ this.setCollapsed(!this.setting.collapsed);
+ }
+ setCollapsed(collapsed) {
+ var _a;
+ this.setting.collapsed = collapsed;
+ (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.toggleClass('is-collapsed', collapsed);
+ if (collapsed) {
+ this.removeChildren();
+ }
+ else {
+ this.renderChildren();
+ }
+ }
+ addResetButton() {
+ if (this.setting.resetFn) {
+ this.settingEl.addExtraButton((b) => {
+ b.setIcon('reset')
+ .setTooltip('Reset all settings to default')
+ .onClick(this.setting.resetFn);
+ });
+ }
+ }
+ addExportButton() {
+ this.settingEl.addExtraButton((b) => {
+ b.setIcon('install');
+ b.setTooltip('Export settings');
+ b.extraSettingsEl.onClickEvent((e) => {
+ e.stopPropagation();
+ let title = getTitle(this.setting);
+ title =
+ this.sectionName === title ? title : `${this.sectionName} > ${title}`;
+ this.settingsManager.export(title, this.settingsManager.getSettings(this.sectionId, this.getAllChildrenIds()));
+ });
+ });
+ }
+ addSettingChild(child) {
+ const newSettingComponent = createSettingComponent(this, this.sectionId, this.sectionName, child, this.settingsManager, this.isView);
+ if (!newSettingComponent) {
+ return undefined;
+ }
+ this.children.push(newSettingComponent);
+ return newSettingComponent;
+ }
+ getAllChildrenIds() {
+ const children = [];
+ for (const child of this.children) {
+ children.push(child.setting.id);
+ if (child.setting.type === 'heading') {
+ children.push(...child.getAllChildrenIds());
+ }
+ }
+ return children;
+ }
+}
+
+class SettingsMarkup extends obsidian.Component {
+ constructor(app, plugin, containerEl, isView) {
+ super();
+ this.settingsComponentTrees = [];
+ this.filterString = '';
+ this.settings = [];
+ this.errorList = [];
+ this.app = app;
+ this.plugin = plugin;
+ 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;
+ this.removeChildren();
+ (_a = this.settingsContainerEl) === null || _a === void 0 ? void 0 : _a.empty();
+ }
+ setSettings(settings, errorList) {
+ this.settings = settings;
+ this.errorList = errorList;
+ if (this.containerEl.parentNode) {
+ this.generate(settings);
+ }
+ }
+ displayErrors() {
+ const { containerEl, errorList } = this;
+ errorList.forEach((err) => {
+ containerEl.createDiv({ cls: 'style-settings-error' }, (wrapper) => {
+ wrapper.createDiv({
+ cls: 'style-settings-error-name',
+ text: `Error: ${err.name}`,
+ });
+ wrapper.createDiv({
+ cls: 'style-settings-error-desc',
+ text: err.error,
+ });
+ });
+ });
+ }
+ displayEmpty() {
+ const { containerEl } = this;
+ containerEl.createDiv({ cls: 'style-settings-empty' }, (wrapper) => {
+ wrapper.createDiv({
+ cls: 'style-settings-empty-name',
+ text: 'No style settings found',
+ });
+ wrapper.createDiv({ cls: 'style-settings-empty-desc' }).appendChild(createFragment((frag) => {
+ frag.appendText('Style settings configured by theme and plugin authors will show up here. You can also create your own configuration by creating a CSS snippet in your vault. ');
+ frag.createEl('a', {
+ text: 'Click here for details and examples.',
+ href: 'https://github.com/mgmeyers/obsidian-style-settings#obsidian-style-settings-plugin',
+ });
+ }));
+ });
+ }
+ generate(settings) {
+ var _a;
+ const { containerEl, plugin } = this;
+ containerEl.empty();
+ this.cleanup();
+ this.displayErrors();
+ if (settings.length === 0) {
+ return this.displayEmpty();
+ }
+ new obsidian.Setting(containerEl).then((setting) => {
+ // Build and import link to open the import modal
+ setting.controlEl.createEl('a', {
+ cls: 'style-settings-import',
+ text: 'Import',
+ href: '#',
+ }, (el) => {
+ el.addEventListener('click', (e) => {
+ e.preventDefault();
+ this.plugin.settingsManager.import();
+ });
+ });
+ // Build and export link to open the export modal
+ setting.controlEl.createEl('a', {
+ cls: 'style-settings-export',
+ text: 'Export',
+ href: '#',
+ }, (el) => {
+ el.addEventListener('click', (e) => {
+ e.preventDefault();
+ this.plugin.settingsManager.export('All settings', this.plugin.settingsManager.settings);
+ });
+ });
+ // Searchbar
+ let searchComponent;
+ setting.addSearch((s) => {
+ searchComponent = s;
+ });
+ // move the search component from the back to the front
+ setting.nameEl.appendChild(setting.controlEl.lastChild);
+ searchComponent.setValue(this.filterString);
+ 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();
+ this.settingsComponentTrees = [];
+ for (const s of settings) {
+ const options = [
+ {
+ id: s.id,
+ type: 'heading',
+ title: s.name,
+ level: 0,
+ collapsed: (_a = s.collapsed) !== null && _a !== void 0 ? _a : true,
+ resetFn: () => {
+ plugin.settingsManager.clearSection(s.id);
+ 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,
+ });
+ this.addChild(settingsComponentTree);
+ this.settingsComponentTrees.push(settingsComponentTree);
+ }
+ catch (e) {
+ console.error('Style Settings | Failed to render section', e);
+ }
+ }
+ }
+ /**
+ * Recursively filter all setting elements based on `filterString` and then re-renders.
+ */
+ filter() {
+ for (const settingsComponentTree of this.settingsComponentTrees) {
+ settingsComponentTree.filter(this.filterString);
+ }
+ }
+ /**
+ * Recursively clears the filter and then re-renders.
+ */
+ clearFilter() {
+ for (const settingsComponentTree of this.settingsComponentTrees) {
+ settingsComponentTree.clearFilter();
+ }
+ }
+ rerender() {
+ this.cleanup();
+ this.display();
+ }
+}
+
+class CSSSettingsTab extends obsidian.PluginSettingTab {
+ constructor(app, plugin) {
+ super(app, plugin);
+ this.plugin = plugin;
+ }
+ setSettings(settings, errorList) {
+ this.settings = settings;
+ this.errorList = errorList;
+ if (this.settingsMarkup) {
+ this.settingsMarkup.setSettings(settings, errorList);
+ }
+ }
+ 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.plugin.removeChild(this.settingsMarkup);
+ this.settingsMarkup = null;
+ }
+}
+
+const viewType = 'style-settings';
+class SettingsView extends obsidian.ItemView {
+ constructor(plugin, leaf) {
+ super(leaf);
+ this.plugin = plugin;
+ }
+ 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;
+ }
+ getIcon() {
+ return 'gear';
+ }
+ getDisplayText() {
+ return 'Style Settings';
+ }
+}
+
+// Detect either spaces or tabs but not both to properly handle tabs for indentation and spaces for alignment
+const INDENT_REGEX = /^(?:( )+|\t+)/;
+
+const INDENT_TYPE_SPACE = 'space';
+const INDENT_TYPE_TAB = 'tab';
+
+/**
+Make a Map that counts how many indents/unindents have occurred for a given size and how many lines follow a given indentation.
+
+The key is a concatenation of the indentation type (s = space and t = tab) and the size of the indents/unindents.
+
+```
+indents = {
+ t3: [1, 0],
+ t4: [1, 5],
+ s5: [1, 0],
+ s12: [1, 0],
+}
+```
+*/
+function makeIndentsMap(string, ignoreSingleSpaces) {
+ const indents = new Map();
+
+ // Remember the size of previous line's indentation
+ let previousSize = 0;
+ let previousIndentType;
+
+ // Indents key (ident type + size of the indents/unindents)
+ let key;
+
+ for (const line of string.split(/\n/g)) {
+ if (!line) {
+ // Ignore empty lines
+ continue;
+ }
+
+ let indent;
+ let indentType;
+ let weight;
+ let entry;
+ const matches = line.match(INDENT_REGEX);
+
+ if (matches === null) {
+ previousSize = 0;
+ previousIndentType = '';
+ } else {
+ indent = matches[0].length;
+ indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
+
+ // Ignore single space unless it's the only indent detected to prevent common false positives
+ if (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {
+ continue;
+ }
+
+ if (indentType !== previousIndentType) {
+ previousSize = 0;
+ }
+
+ previousIndentType = indentType;
+
+ weight = 0;
+
+ const indentDifference = indent - previousSize;
+ previousSize = indent;
+
+ // Previous line have same indent?
+ if (indentDifference === 0) {
+ weight++;
+ // We use the key from previous loop
+ } else {
+ const absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;
+ key = encodeIndentsKey(indentType, absoluteIndentDifference);
+ }
+
+ // Update the stats
+ entry = indents.get(key);
+ entry = entry === undefined ? [1, 0] : [++entry[0], entry[1] + weight];
+
+ indents.set(key, entry);
+ }
+ }
+
+ return indents;
+}
+
+// Encode the indent type and amount as a string (e.g. 's4') for use as a compound key in the indents Map.
+function encodeIndentsKey(indentType, indentAmount) {
+ const typeCharacter = indentType === INDENT_TYPE_SPACE ? 's' : 't';
+ return typeCharacter + String(indentAmount);
+}
+
+// Extract the indent type and amount from a key of the indents Map.
+function decodeIndentsKey(indentsKey) {
+ const keyHasTypeSpace = indentsKey[0] === 's';
+ const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
+
+ const amount = Number(indentsKey.slice(1));
+
+ return {type, amount};
+}
+
+// Return the key (e.g. 's4') from the indents Map that represents the most common indent,
+// or return undefined if there are no indents.
+function getMostUsedKey(indents) {
+ let result;
+ let maxUsed = 0;
+ let maxWeight = 0;
+
+ for (const [key, [usedCount, weight]] of indents) {
+ if (usedCount > maxUsed || (usedCount === maxUsed && weight > maxWeight)) {
+ maxUsed = usedCount;
+ maxWeight = weight;
+ result = key;
+ }
+ }
+
+ return result;
+}
+
+function makeIndentString(type, amount) {
+ const indentCharacter = type === INDENT_TYPE_SPACE ? ' ' : '\t';
+ return indentCharacter.repeat(amount);
+}
+
+function detectIndent(string) {
+ if (typeof string !== 'string') {
+ throw new TypeError('Expected a string');
+ }
+
+ // Identify indents while skipping single space indents to avoid common edge cases (e.g. code comments)
+ // If no indents are identified, run again and include all indents for comprehensive detection
+ let indents = makeIndentsMap(string, true);
+ if (indents.size === 0) {
+ indents = makeIndentsMap(string, false);
+ }
+
+ const keyOfMostUsedIndent = getMostUsedKey(indents);
+
+ let type;
+ let amount = 0;
+ let indent = '';
+
+ if (keyOfMostUsedIndent !== undefined) {
+ ({type, amount} = decodeIndentsKey(keyOfMostUsedIndent));
+ indent = makeIndentString(type, amount);
+ }
+
+ return {
+ amount,
+ type,
+ indent,
+ };
+}
+
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
function isNothing(subject) {
return (typeof subject === 'undefined') || (subject === null);
@@ -7713,1912 +9621,6 @@ var jsYaml = {
safeDump: safeDump
};
-// Detect either spaces or tabs but not both to properly handle tabs for indentation and spaces for alignment
-const INDENT_REGEX = /^(?:( )+|\t+)/;
-
-const INDENT_TYPE_SPACE = 'space';
-const INDENT_TYPE_TAB = 'tab';
-
-/**
-Make a Map that counts how many indents/unindents have occurred for a given size and how many lines follow a given indentation.
-
-The key is a concatenation of the indentation type (s = space and t = tab) and the size of the indents/unindents.
-
-```
-indents = {
- t3: [1, 0],
- t4: [1, 5],
- s5: [1, 0],
- s12: [1, 0],
-}
-```
-*/
-function makeIndentsMap(string, ignoreSingleSpaces) {
- const indents = new Map();
-
- // Remember the size of previous line's indentation
- let previousSize = 0;
- let previousIndentType;
-
- // Indents key (ident type + size of the indents/unindents)
- let key;
-
- for (const line of string.split(/\n/g)) {
- if (!line) {
- // Ignore empty lines
- continue;
- }
-
- let indent;
- let indentType;
- let weight;
- let entry;
- const matches = line.match(INDENT_REGEX);
-
- if (matches === null) {
- previousSize = 0;
- previousIndentType = '';
- } else {
- indent = matches[0].length;
- indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
-
- // Ignore single space unless it's the only indent detected to prevent common false positives
- if (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {
- continue;
- }
-
- if (indentType !== previousIndentType) {
- previousSize = 0;
- }
-
- previousIndentType = indentType;
-
- weight = 0;
-
- const indentDifference = indent - previousSize;
- previousSize = indent;
-
- // Previous line have same indent?
- if (indentDifference === 0) {
- weight++;
- // We use the key from previous loop
- } else {
- const absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;
- key = encodeIndentsKey(indentType, absoluteIndentDifference);
- }
-
- // Update the stats
- entry = indents.get(key);
- entry = entry === undefined ? [1, 0] : [++entry[0], entry[1] + weight];
-
- indents.set(key, entry);
- }
- }
-
- return indents;
-}
-
-// Encode the indent type and amount as a string (e.g. 's4') for use as a compound key in the indents Map.
-function encodeIndentsKey(indentType, indentAmount) {
- const typeCharacter = indentType === INDENT_TYPE_SPACE ? 's' : 't';
- return typeCharacter + String(indentAmount);
-}
-
-// Extract the indent type and amount from a key of the indents Map.
-function decodeIndentsKey(indentsKey) {
- const keyHasTypeSpace = indentsKey[0] === 's';
- const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
-
- const amount = Number(indentsKey.slice(1));
-
- return {type, amount};
-}
-
-// Return the key (e.g. 's4') from the indents Map that represents the most common indent,
-// or return undefined if there are no indents.
-function getMostUsedKey(indents) {
- let result;
- let maxUsed = 0;
- let maxWeight = 0;
-
- for (const [key, [usedCount, weight]] of indents) {
- if (usedCount > maxUsed || (usedCount === maxUsed && weight > maxWeight)) {
- maxUsed = usedCount;
- maxWeight = weight;
- result = key;
- }
- }
-
- return result;
-}
-
-function makeIndentString(type, amount) {
- const indentCharacter = type === INDENT_TYPE_SPACE ? ' ' : '\t';
- return indentCharacter.repeat(amount);
-}
-
-function detectIndent(string) {
- if (typeof string !== 'string') {
- throw new TypeError('Expected a string');
- }
-
- // Identify indents while skipping single space indents to avoid common edge cases (e.g. code comments)
- // If no indents are identified, run again and include all indents for comprehensive detection
- let indents = makeIndentsMap(string, true);
- if (indents.size === 0) {
- indents = makeIndentsMap(string, false);
- }
-
- const keyOfMostUsedIndent = getMostUsedKey(indents);
-
- let type;
- let amount = 0;
- let indent = '';
-
- if (keyOfMostUsedIndent !== undefined) {
- ({type, amount} = decodeIndentsKey(keyOfMostUsedIndent));
- indent = makeIndentString(type, amount);
- }
-
- return {
- amount,
- type,
- indent,
- };
-}
-
-const ar = {};
-
-const cz = {};
-
-const da = {};
-
-const de = {
- 'Default:': 'Standard:',
- 'Error:': 'Fehler:',
- 'missing default light value, or value is not in a valid color format': 'Fehlender heller standard Wert oder Wert ist in keinem validen Farb-Format',
- 'missing default dark value, or value is not in a valid color format': 'Fehlender dunkler standard Wert oder Wert ist in keinem validen Farb-Format',
- 'missing default value, or value is not in a valid color format': 'Fehlender standard Wert oder Wert ist in keinem validen Farb-Format',
- 'missing default value': 'Fehlender standard Wert',
-};
-
-const en = {
- 'Default:': 'Default:',
- 'Error:': 'Error:',
- 'missing default light value, or value is not in a valid color format': 'missing default light value, or value is not in a valid color format',
- 'missing default dark value, or value is not in a valid color format': 'missing default dark value, or value is not in a valid color format',
- 'missing default value, or value is not in a valid color format': 'missing default value, or value is not in a valid color format',
- 'missing default value': 'missing default value',
-};
-
-const es = {};
-
-const fr = {};
-
-const hi = {};
-
-const id = {};
-
-const it = {};
-
-const ja = {};
-
-const ko = {};
-
-const nl = {
- 'Default:': 'Standaard:',
- 'Error:': 'Error:',
- 'missing default light value, or value is not in a valid color format': 'Geen standaard waarde voor het lichte thema, of de waarde is niet in het goede formaat',
- 'missing default dark value, or value is not in a valid color format': 'Geen standaard waarde voor het donkere thema, of de waarde is niet in het goede formaat',
- 'missing default value, or value is not in a valid color format': 'Geen standaard waarde, of de waarde is niet in het goede formaat',
- 'missing default value': 'Geen standaard waarde',
-};
-
-const no = {};
-
-const pl = {};
-
-const pt = {};
-
-const ptBr = {};
-
-const ro = {};
-
-const ru = {};
-
-const sq = {};
-
-const tr = {};
-
-const uk = {};
-
-const zh = {
- 'Default:': '默认:',
- 'Error:': '错误:',
- 'missing default light value, or value is not in a valid color format': '缺少默认的浅色模式色值,或该色值没有采用一个有效的颜色格式',
- 'missing default dark value, or value is not in a valid color format': '缺少默认的深色模式色值,或该色值没有采用一个有效的颜色格式',
- 'missing default value, or value is not in a valid color format': '缺少默认色值,或该色值没有采用一个有效的颜色格式',
- 'missing default value': '缺少默认色值',
-};
-
-const zhTw = {};
-
-const lang = window.localStorage.getItem('language');
-const localeMap = {
- ar,
- cz,
- da,
- de,
- en,
- es,
- fr,
- hi,
- id,
- it,
- ja,
- ko,
- nl,
- no,
- pl,
- 'pt-BR': ptBr,
- pt,
- ro,
- ru,
- sq,
- tr,
- uk,
- 'zh-TW': zhTw,
- zh,
-};
-const locale = localeMap[lang || 'en'];
-function t(str) {
- if (!locale) {
- console.error('Error: Style Settings locale not found', lang);
- }
- return (locale && locale[str]) || en[str];
-}
-
-const settingRegExp = /\/\*\s*@settings[\r\n]+?([\s\S]+?)\*\//g;
-const nameRegExp = /^name:\s*(.+)$/m;
-function getTitle(config) {
- if (lang) {
- return config[`title.${lang}`] || config.title;
- }
- return config.title;
-}
-function getDescription(config) {
- if (lang) {
- return (config[`description.${lang}`] ||
- config.description);
- }
- return config.description;
-}
-function isValidDefaultColor(color) {
- return /^(#|rgb|hsl)/.test(color);
-}
-function getPickrSettings(opts) {
- const { el, isView, containerEl, swatches, opacity, defaultColor } = opts;
- return {
- el,
- container: isView ? document.body : containerEl,
- theme: 'nano',
- swatches,
- lockOpacity: !opacity,
- default: defaultColor,
- position: 'left-middle',
- components: {
- preview: true,
- hue: true,
- opacity: !!opacity,
- interaction: {
- hex: true,
- rgba: true,
- hsla: true,
- input: true,
- cancel: true,
- save: true,
- },
- },
- };
-}
-function onPickrCancel(instance) {
- instance.hide();
-}
-function sanitizeText(str) {
- if (str === '') {
- return `""`;
- }
- return str.replace(/[;<>]/g, '');
-}
-function createDescription(description, def, defLabel) {
- const fragment = createFragment();
- if (description) {
- fragment.appendChild(document.createTextNode(description));
- }
- if (def) {
- const small = createEl('small');
- small.appendChild(createEl('strong', { text: `${t('Default:')} ` }));
- small.appendChild(document.createTextNode(defLabel || def));
- const div = createEl('div');
- div.appendChild(small);
- fragment.appendChild(div);
- }
- return fragment;
-}
-
-var fuzzysort = createCommonjsModule(function (module) {
-((root, UMD) => {
- if(module.exports) module.exports = UMD();
- else root['fuzzysort'] = UMD();
-})(commonjsGlobal, _ => {
-
- var single = (search, target) => { if(search=='farzher')return {target:"farzher was here (^-^*)/",score:0,_indexes:[0]}
- if(!search || !target) return NULL
-
- var preparedSearch = getPreparedSearch(search);
- if(!isObj(target)) target = getPrepared(target);
-
- var searchBitflags = preparedSearch.bitflags;
- if((searchBitflags & target._bitflags) !== searchBitflags) return NULL
-
- return algorithm(preparedSearch, target)
- };
-
-
- var go = (search, targets, options) => { if(search=='farzher')return [{target:"farzher was here (^-^*)/",score:0,_indexes:[0],obj:targets?targets[0]:NULL}]
- if(!search) return options&&options.all ? all(search, targets, options) : noResults
-
- var preparedSearch = getPreparedSearch(search);
- var searchBitflags = preparedSearch.bitflags;
- preparedSearch.containsSpace;
-
- var threshold = options&&options.threshold || INT_MIN;
- var limit = options&&options['limit'] || INT_MAX; // for some reason only limit breaks when minified
-
- var resultsLen = 0; var limitedCount = 0;
- var targetsLen = targets.length;
-
- // This code is copy/pasted 3 times for performance reasons [options.keys, options.key, no keys]
-
- // options.key
- if(options && options.key) {
- var key = options.key;
- for(var i = 0; i < targetsLen; ++i) { var obj = targets[i];
- var target = getValue(obj, key);
- if(!target) continue
- if(!isObj(target)) target = getPrepared(target);
-
- if((searchBitflags & target._bitflags) !== searchBitflags) continue
- var result = algorithm(preparedSearch, target);
- if(result === NULL) continue
- if(result.score < threshold) continue
-
- // have to clone result so duplicate targets from different obj can each reference the correct obj
- result = {target:result.target, _targetLower:'', _targetLowerCodes:NULL, _nextBeginningIndexes:NULL, _bitflags:0, score:result.score, _indexes:result._indexes, obj:obj}; // hidden
-
- if(resultsLen < limit) { q.add(result); ++resultsLen; }
- else {
- ++limitedCount;
- if(result.score > q.peek().score) q.replaceTop(result);
- }
- }
-
- // options.keys
- } else if(options && options.keys) {
- var scoreFn = options['scoreFn'] || defaultScoreFn;
- var keys = options.keys;
- var keysLen = keys.length;
- for(var i = 0; i < targetsLen; ++i) { var obj = targets[i];
- var objResults = new Array(keysLen);
- for (var keyI = 0; keyI < keysLen; ++keyI) {
- var key = keys[keyI];
- var target = getValue(obj, key);
- if(!target) { objResults[keyI] = NULL; continue }
- if(!isObj(target)) target = getPrepared(target);
-
- if((searchBitflags & target._bitflags) !== searchBitflags) objResults[keyI] = NULL;
- else objResults[keyI] = algorithm(preparedSearch, target);
- }
- objResults.obj = obj; // before scoreFn so scoreFn can use it
- var score = scoreFn(objResults);
- if(score === NULL) continue
- if(score < threshold) continue
- objResults.score = score;
- if(resultsLen < limit) { q.add(objResults); ++resultsLen; }
- else {
- ++limitedCount;
- if(score > q.peek().score) q.replaceTop(objResults);
- }
- }
-
- // no keys
- } else {
- for(var i = 0; i < targetsLen; ++i) { var target = targets[i];
- if(!target) continue
- if(!isObj(target)) target = getPrepared(target);
-
- if((searchBitflags & target._bitflags) !== searchBitflags) continue
- var result = algorithm(preparedSearch, target);
- if(result === NULL) continue
- if(result.score < threshold) continue
- if(resultsLen < limit) { q.add(result); ++resultsLen; }
- else {
- ++limitedCount;
- if(result.score > q.peek().score) q.replaceTop(result);
- }
- }
- }
-
- if(resultsLen === 0) return noResults
- var results = new Array(resultsLen);
- for(var i = resultsLen - 1; i >= 0; --i) results[i] = q.poll();
- results.total = resultsLen + limitedCount;
- return results
- };
-
-
- var highlight = (result, hOpen, hClose) => {
- if(typeof hOpen === 'function') return highlightCallback(result, hOpen)
- if(result === NULL) return NULL
- if(hOpen === undefined) hOpen = '';
- if(hClose === undefined) hClose = '';
- var highlighted = '';
- var matchesIndex = 0;
- var opened = false;
- var target = result.target;
- var targetLen = target.length;
- var indexes = result._indexes;
- indexes = indexes.slice(0, indexes.len).sort((a,b)=>a-b);
- for(var i = 0; i < targetLen; ++i) { var char = target[i];
- if(indexes[matchesIndex] === i) {
- ++matchesIndex;
- if(!opened) { opened = true;
- highlighted += hOpen;
- }
-
- if(matchesIndex === indexes.length) {
- highlighted += char + hClose + target.substr(i+1);
- break
- }
- } else {
- if(opened) { opened = false;
- highlighted += hClose;
- }
- }
- highlighted += char;
- }
-
- return highlighted
- };
- var highlightCallback = (result, cb) => {
- if(result === NULL) return NULL
- var target = result.target;
- var targetLen = target.length;
- var indexes = result._indexes;
- indexes = indexes.slice(0, indexes.len).sort((a,b)=>a-b);
- var highlighted = '';
- var matchI = 0;
- var indexesI = 0;
- var opened = false;
- var result = [];
- for(var i = 0; i < targetLen; ++i) { var char = target[i];
- if(indexes[indexesI] === i) {
- ++indexesI;
- if(!opened) { opened = true;
- result.push(highlighted); highlighted = '';
- }
-
- if(indexesI === indexes.length) {
- highlighted += char;
- result.push(cb(highlighted, matchI++)); highlighted = '';
- result.push(target.substr(i+1));
- break
- }
- } else {
- if(opened) { opened = false;
- result.push(cb(highlighted, matchI++)); highlighted = '';
- }
- }
- highlighted += char;
- }
- return result
- };
-
-
- var indexes = result => result._indexes.slice(0, result._indexes.len).sort((a,b)=>a-b);
-
-
- var prepare = (target) => {
- if(typeof target !== 'string') target = '';
- var info = prepareLowerInfo(target);
- return {'target':target, _targetLower:info._lower, _targetLowerCodes:info.lowerCodes, _nextBeginningIndexes:NULL, _bitflags:info.bitflags, 'score':NULL, _indexes:[0], 'obj':NULL} // hidden
- };
-
-
- // Below this point is only internal code
- // Below this point is only internal code
- // Below this point is only internal code
- // Below this point is only internal code
-
-
- var prepareSearch = (search) => {
- if(typeof search !== 'string') search = '';
- search = search.trim();
- var info = prepareLowerInfo(search);
-
- var spaceSearches = [];
- if(info.containsSpace) {
- var searches = search.split(/\s+/);
- searches = [...new Set(searches)]; // distinct
- for(var i=0; i {
- if(target.length > 999) return prepare(target) // don't cache huge targets
- var targetPrepared = preparedCache.get(target);
- if(targetPrepared !== undefined) return targetPrepared
- targetPrepared = prepare(target);
- preparedCache.set(target, targetPrepared);
- return targetPrepared
- };
- var getPreparedSearch = (search) => {
- if(search.length > 999) return prepareSearch(search) // don't cache huge searches
- var searchPrepared = preparedSearchCache.get(search);
- if(searchPrepared !== undefined) return searchPrepared
- searchPrepared = prepareSearch(search);
- preparedSearchCache.set(search, searchPrepared);
- return searchPrepared
- };
-
-
- var all = (search, targets, options) => {
- var results = []; results.total = targets.length;
-
- var limit = options && options.limit || INT_MAX;
-
- if(options && options.key) {
- for(var i=0;i= limit) return results
- }
- } else if(options && options.keys) {
- for(var i=0;i= 0; --keyI) {
- var target = getValue(obj, options.keys[keyI]);
- if(!target) { objResults[keyI] = NULL; continue }
- if(!isObj(target)) target = getPrepared(target);
- target.score = INT_MIN;
- target._indexes.len = 0;
- objResults[keyI] = target;
- }
- objResults.obj = obj;
- objResults.score = INT_MIN;
- results.push(objResults); if(results.length >= limit) return results
- }
- } else {
- for(var i=0;i= limit) return results
- }
- }
-
- return results
- };
-
-
- var algorithm = (preparedSearch, prepared, allowSpaces=false) => {
- if(allowSpaces===false && preparedSearch.containsSpace) return algorithmSpaces(preparedSearch, prepared)
-
- var searchLower = preparedSearch._lower;
- var searchLowerCodes = preparedSearch.lowerCodes;
- var searchLowerCode = searchLowerCodes[0];
- var targetLowerCodes = prepared._targetLowerCodes;
- var searchLen = searchLowerCodes.length;
- var targetLen = targetLowerCodes.length;
- var searchI = 0; // where we at
- var targetI = 0; // where you at
- var matchesSimpleLen = 0;
-
- // very basic fuzzy match; to remove non-matching targets ASAP!
- // walk through target. find sequential matches.
- // if all chars aren't found then exit
- for(;;) {
- var isMatch = searchLowerCode === targetLowerCodes[targetI];
- if(isMatch) {
- matchesSimple[matchesSimpleLen++] = targetI;
- ++searchI; if(searchI === searchLen) break
- searchLowerCode = searchLowerCodes[searchI];
- }
- ++targetI; if(targetI >= targetLen) return NULL // Failed to find searchI
- }
-
- var searchI = 0;
- var successStrict = false;
- var matchesStrictLen = 0;
-
- var nextBeginningIndexes = prepared._nextBeginningIndexes;
- if(nextBeginningIndexes === NULL) nextBeginningIndexes = prepared._nextBeginningIndexes = prepareNextBeginningIndexes(prepared.target);
- targetI = matchesSimple[0]===0 ? 0 : nextBeginningIndexes[matchesSimple[0]-1];
-
- // Our target string successfully matched all characters in sequence!
- // Let's try a more advanced and strict test to improve the score
- // only count it as a match if it's consecutive or a beginning character!
- var backtrackCount = 0;
- if(targetI !== targetLen) for(;;) {
- if(targetI >= targetLen) {
- // We failed to find a good spot for this search char, go back to the previous search char and force it forward
- if(searchI <= 0) break // We failed to push chars forward for a better match
-
- ++backtrackCount; if(backtrackCount > 200) break // exponential backtracking is taking too long, just give up and return a bad match
-
- --searchI;
- var lastMatch = matchesStrict[--matchesStrictLen];
- targetI = nextBeginningIndexes[lastMatch];
-
- } else {
- var isMatch = searchLowerCodes[searchI] === targetLowerCodes[targetI];
- if(isMatch) {
- matchesStrict[matchesStrictLen++] = targetI;
- ++searchI; if(searchI === searchLen) { successStrict = true; break }
- ++targetI;
- } else {
- targetI = nextBeginningIndexes[targetI];
- }
- }
- }
-
- // check if it's a substring match
- var substringIndex = prepared._targetLower.indexOf(searchLower, matchesSimple[0]); // perf: this is slow
- var isSubstring = ~substringIndex;
- if(isSubstring && !successStrict) { // rewrite the indexes from basic to the substring
- for(var i=0; i 24) score *= (uniqueBeginningIndexes-24)*10; // quite arbitrary numbers here ...
- }
-
- if(isSubstring) score /= 1+searchLen*searchLen*1; // bonus for being a full substring
- if(isSubstringBeginning) score /= 1+searchLen*searchLen*1; // bonus for substring starting on a beginningIndex
-
- score -= targetLen - searchLen; // penality for longer targets
- prepared.score = score;
-
- for(var i = 0; i < matchesBestLen; ++i) prepared._indexes[i] = matchesBest[i];
- prepared._indexes.len = matchesBestLen;
-
- return prepared
- }
- };
- var algorithmSpaces = (preparedSearch, target) => {
- var seen_indexes = new Set();
- var score = 0;
- var result = NULL;
-
- var first_seen_index_last_search = 0;
- var searches = preparedSearch.spaceSearches;
- for(var i=0; i score) {
- return allowSpacesResult
- }
-
- result.score = score;
-
- var i = 0;
- for (let index of seen_indexes) result._indexes[i++] = index;
- result._indexes.len = i;
-
- return result
- };
-
-
- var prepareLowerInfo = (str) => {
- var strLen = str.length;
- var lower = str.toLowerCase();
- var lowerCodes = []; // new Array(strLen) sparse array is too slow
- var bitflags = 0;
- var containsSpace = false; // space isn't stored in bitflags because of how searching with a space works
-
- for(var i = 0; i < strLen; ++i) {
- var lowerCode = lowerCodes[i] = lower.charCodeAt(i);
-
- if(lowerCode === 32) {
- containsSpace = true;
- continue // it's important that we don't set any bitflags for space
- }
-
- var bit = lowerCode>=97&&lowerCode<=122 ? lowerCode-97 // alphabet
- : lowerCode>=48&&lowerCode<=57 ? 26 // numbers
- // 3 bits available
- : lowerCode<=127 ? 30 // other ascii
- : 31; // other utf8
- bitflags |= 1< {
- var targetLen = target.length;
- var beginningIndexes = []; var beginningIndexesLen = 0;
- var wasUpper = false;
- var wasAlphanum = false;
- for(var i = 0; i < targetLen; ++i) {
- var targetCode = target.charCodeAt(i);
- var isUpper = targetCode>=65&&targetCode<=90;
- var isAlphanum = isUpper || targetCode>=97&&targetCode<=122 || targetCode>=48&&targetCode<=57;
- var isBeginning = isUpper && !wasUpper || !wasAlphanum || !isAlphanum;
- wasUpper = isUpper;
- wasAlphanum = isAlphanum;
- if(isBeginning) beginningIndexes[beginningIndexesLen++] = i;
- }
- return beginningIndexes
- };
- var prepareNextBeginningIndexes = (target) => {
- var targetLen = target.length;
- var beginningIndexes = prepareBeginningIndexes(target);
- var nextBeginningIndexes = []; // new Array(targetLen) sparse array is too slow
- var lastIsBeginning = beginningIndexes[0];
- var lastIsBeginningI = 0;
- for(var i = 0; i < targetLen; ++i) {
- if(lastIsBeginning > i) {
- nextBeginningIndexes[i] = lastIsBeginning;
- } else {
- lastIsBeginning = beginningIndexes[++lastIsBeginningI];
- nextBeginningIndexes[i] = lastIsBeginning===undefined ? targetLen : lastIsBeginning;
- }
- }
- return nextBeginningIndexes
- };
-
-
- var cleanup = () => { preparedCache.clear(); preparedSearchCache.clear(); matchesSimple = []; matchesStrict = []; };
-
- var preparedCache = new Map();
- var preparedSearchCache = new Map();
- var matchesSimple = []; var matchesStrict = [];
-
-
- // for use with keys. just returns the maximum score
- var defaultScoreFn = (a) => {
- var max = INT_MIN;
- var len = a.length;
- for (var i = 0; i < len; ++i) {
- var result = a[i]; if(result === NULL) continue
- var score = result.score;
- if(score > max) max = score;
- }
- if(max === INT_MIN) return NULL
- return max
- };
-
- // prop = 'key' 2.5ms optimized for this case, seems to be about as fast as direct obj[prop]
- // prop = 'key1.key2' 10ms
- // prop = ['key1', 'key2'] 27ms
- var getValue = (obj, prop) => {
- var tmp = obj[prop]; if(tmp !== undefined) return tmp
- var segs = prop;
- if(!Array.isArray(prop)) segs = prop.split('.');
- var len = segs.length;
- var i = -1;
- while (obj && (++i < len)) obj = obj[segs[i]];
- return obj
- };
-
- var isObj = (x) => { return typeof x === 'object' }; // faster as a function
- // var INT_MAX = 9007199254740991; var INT_MIN = -INT_MAX
- var INT_MAX = Infinity; var INT_MIN = -INT_MAX;
- var noResults = []; noResults.total = 0;
- var NULL = null;
-
-
- // Hacked version of https://github.com/lemire/FastPriorityQueue.js
- var fastpriorityqueue=r=>{var e=[],o=0,a={},v=r=>{for(var a=0,v=e[a],c=1;c>1]=e[a],c=1+(a<<1);}for(var f=a-1>>1;a>0&&v.score>1)e[a]=e[f];e[a]=v;};return a.add=(r=>{var a=o;e[o++]=r;for(var v=a-1>>1;a>0&&r.score>1)e[a]=e[v];e[a]=r;}),a.poll=(r=>{if(0!==o){var a=e[0];return e[0]=e[--o],v(),a}}),a.peek=(r=>{if(0!==o)return e[0]}),a.replaceTop=(r=>{e[0]=r,v();}),a};
- var q = fastpriorityqueue(); // reuse this
-
-
- // fuzzysort is written this way for minification. all names are mangeled unless quoted
- return {'single':single, 'go':go, 'highlight':highlight, 'prepare':prepare, 'indexes':indexes, 'cleanup':cleanup}
-}); // UMD
-
-// TODO: (feature) frecency
-// TODO: (perf) use different sorting algo depending on the # of results?
-// TODO: (perf) preparedCache is a memory leak
-// TODO: (like sublime) backslash === forwardslash
-// TODO: (perf) prepareSearch seems slow
-});
-
-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;
- }
- 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.
- *
- * @param str the string to match this Component against.
- */
- match(str) {
- var _a, _b, _c, _d;
- if (!str) {
- return Number.NEGATIVE_INFINITY;
- }
- return Math.max((_b = (_a = fuzzysort.single(str, getTitle(this.setting))) === null || _a === void 0 ? void 0 : _a.score) !== null && _b !== void 0 ? _b : Number.NEGATIVE_INFINITY, (_d = (_c = fuzzysort.single(str, getDescription(this.setting))) === null || _c === void 0 ? void 0 : _c.score) !== null && _d !== void 0 ? _d : Number.NEGATIVE_INFINITY);
- }
- /**
- * Matches the Component against `str`. A match returns true, no match or a bad match returns false.
- *
- * @param str the string to match this Component against.
- */
- decisiveMatch(str) {
- return this.match(str) > -100000;
- }
-}
-
-const resetTooltip = 'Restore default';
-
-class ClassToggleSettingComponent extends AbstractSettingComponent {
- render() {
- const title = getTitle(this.setting);
- const description = getDescription(this.setting);
- this.settingEl = new obsidian.Setting(this.containerEl);
- this.settingEl.setName(title);
- this.settingEl.setDesc(description !== null && description !== void 0 ? description : '');
- this.settingEl.addToggle((toggle) => {
- const value = this.settingsManager.getSetting(this.sectionId, this.setting.id);
- toggle.setValue(value !== undefined ? !!value : !!this.setting.default);
- toggle.onChange((value) => {
- this.settingsManager.setSetting(this.sectionId, this.setting.id, value);
- });
- this.toggleComponent = toggle;
- });
- this.settingEl.addExtraButton((b) => {
- b.setIcon('reset');
- b.onClick(() => {
- const value = !!this.setting.default;
- this.toggleComponent.setValue(value);
- this.settingsManager.clearSetting(this.sectionId, this.setting.id);
- });
- b.setTooltip(resetTooltip);
- });
- this.settingEl.settingEl.dataset.id = this.setting.id;
- }
- destroy() {
- var _a;
- (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.remove();
- }
-}
-
-class ClassMultiToggleSettingComponent extends AbstractSettingComponent {
- 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')}`);
- }
- let prevValue = this.getPreviousValue();
- const defaultLabel = this.getDefaultOptionLabel();
- this.settingEl = new obsidian.Setting(this.containerEl);
- this.settingEl.setName(title);
- this.settingEl.setDesc(createDescription(description, this.setting.default, defaultLabel));
- this.settingEl.addDropdown((dropdown) => {
- if (this.setting.allowEmpty) {
- dropdown.addOption('none', '');
- }
- for (const o of this.setting.options) {
- if (typeof o === 'string') {
- dropdown.addOption(o, o);
- }
- else {
- dropdown.addOption(o.value, o.label);
- }
- }
- dropdown.setValue(prevValue);
- dropdown.onChange((value) => {
- this.settingsManager.setSetting(this.sectionId, this.setting.id, value);
- prevValue = value;
- });
- this.dropdownComponent = dropdown;
- });
- this.settingEl.addExtraButton((b) => {
- b.setIcon('reset');
- b.onClick(() => {
- this.dropdownComponent.setValue(this.setting.default || 'none');
- this.settingsManager.clearSetting(this.sectionId, this.setting.id);
- });
- b.setTooltip(resetTooltip);
- });
- this.settingEl.settingEl.dataset.id = this.setting.id;
- }
- destroy() {
- var _a;
- (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.remove();
- }
- getDefaultOption() {
- if (this.setting.default) {
- return this.setting.options.find((o) => {
- if (typeof o === 'string') {
- return o === this.setting.default;
- }
- return o.value === this.setting.default;
- });
- }
- return undefined;
- }
- getDefaultOptionLabel() {
- const defaultOption = this.getDefaultOption();
- if (defaultOption) {
- if (typeof defaultOption === 'string') {
- return defaultOption;
- }
- return defaultOption.label;
- }
- return undefined;
- }
- getPreviousValue() {
- const prevValue = this.settingsManager.getSetting(this.sectionId, this.setting.id);
- if (prevValue === undefined) {
- if (this.setting.default) {
- return this.setting.default;
- }
- return 'none';
- }
- return prevValue;
- }
-}
-
-class VariableTextSettingComponent extends AbstractSettingComponent {
- 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(this.containerEl);
- this.settingEl.setName(title);
- this.settingEl.setDesc(createDescription(description, this.setting.default));
- this.settingEl.addText((text) => {
- let value = this.settingsManager.getSetting(this.sectionId, this.setting.id);
- const onChange = obsidian.debounce((value) => {
- this.settingsManager.setSetting(this.sectionId, this.setting.id, sanitizeText(value));
- }, 250, true);
- if (this.setting.quotes && value === `""`) {
- value = ``;
- }
- text.setValue(value ? value.toString() : this.setting.default);
- text.onChange(onChange);
- this.textComponent = text;
- });
- this.settingEl.addExtraButton((b) => {
- b.setIcon('reset');
- b.onClick(() => {
- this.textComponent.setValue(this.setting.default);
- this.settingsManager.clearSetting(this.sectionId, this.setting.id);
- });
- b.setTooltip(resetTooltip);
- });
- this.settingEl.settingEl.dataset.id = this.setting.id;
- }
- destroy() {
- var _a;
- (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.remove();
- }
-}
-
-class VariableNumberSettingComponent extends AbstractSettingComponent {
- 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(this.containerEl);
- this.settingEl.setName(title);
- this.settingEl.setDesc(createDescription(description, this.setting.default.toString(10)));
- this.settingEl.addText((text) => {
- const value = this.settingsManager.getSetting(this.sectionId, this.setting.id);
- const onChange = obsidian.debounce((value) => {
- const isFloat = /\./.test(value);
- this.settingsManager.setSetting(this.sectionId, this.setting.id, isFloat ? parseFloat(value) : parseInt(value, 10));
- }, 250, true);
- text.setValue(value !== undefined ? value.toString() : this.setting.default.toString());
- text.onChange(onChange);
- this.textComponent = text;
- });
- this.settingEl.addExtraButton((b) => {
- b.setIcon('reset');
- b.onClick(() => {
- this.textComponent.setValue(this.setting.default.toString());
- this.settingsManager.clearSetting(this.sectionId, this.setting.id);
- });
- b.setTooltip(resetTooltip);
- });
- this.settingEl.settingEl.dataset.id = this.setting.id;
- }
- destroy() {
- var _a;
- (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.remove();
- }
-}
-
-class VariableNumberSliderSettingComponent extends AbstractSettingComponent {
- 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(this.containerEl);
- this.settingEl.setName(title);
- this.settingEl.setDesc(createDescription(description, this.setting.default.toString(10)));
- this.settingEl.addSlider((slider) => {
- const value = this.settingsManager.getSetting(this.sectionId, this.setting.id);
- const onChange = obsidian.debounce((value) => {
- this.settingsManager.setSetting(this.sectionId, this.setting.id, value);
- }, 250, true);
- slider.setDynamicTooltip();
- slider.setLimits(this.setting.min, this.setting.max, this.setting.step);
- slider.setValue(value !== undefined ? value : this.setting.default);
- slider.onChange(onChange);
- this.sliderComponent = slider;
- });
- this.settingEl.addExtraButton((b) => {
- b.setIcon('reset');
- b.onClick(() => {
- this.sliderComponent.setValue(this.setting.default);
- this.settingsManager.clearSetting(this.sectionId, this.setting.id);
- });
- b.setTooltip(resetTooltip);
- });
- this.settingEl.settingEl.dataset.id = this.setting.id;
- }
- destroy() {
- var _a;
- (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.remove();
- }
-}
-
-class VariableSelectSettingComponent extends AbstractSettingComponent {
- 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(this.containerEl);
- this.settingEl.setName(title);
- this.settingEl.setDesc(createDescription(description, this.setting.default, defaultLabel));
- this.settingEl.addDropdown((dropdown) => {
- const value = this.settingsManager.getSetting(this.sectionId, this.setting.id);
- for (const o of this.setting.options) {
- if (typeof o === 'string') {
- dropdown.addOption(o, o);
- }
- else {
- dropdown.addOption(o.value, o.label);
- }
- }
- dropdown.setValue(value !== undefined ? value : this.setting.default);
- dropdown.onChange((value) => {
- this.settingsManager.setSetting(this.sectionId, this.setting.id, value);
- });
- this.dropdownComponent = dropdown;
- });
- this.settingEl.addExtraButton((b) => {
- b.setIcon('reset');
- b.onClick(() => {
- this.dropdownComponent.setValue(this.setting.default);
- this.settingsManager.clearSetting(this.sectionId, this.setting.id);
- });
- b.setTooltip(resetTooltip);
- });
- this.settingEl.settingEl.dataset.id = this.setting.id;
- }
- destroy() {
- var _a;
- (_a = this.settingEl) === null || _a === void 0 ? void 0 : _a.settingEl.remove();
- }
- getDefaultOption() {
- if (this.setting.default) {
- return this.setting.options.find((o) => {
- if (typeof o === 'string') {
- return o === this.setting.default;
- }
- return o.value === this.setting.default;
- });
- }
- return undefined;
- }
- getDefaultOptionLabel() {
- const defaultOption = this.getDefaultOption();
- if (defaultOption) {
- if (typeof defaultOption === 'string') {
- return defaultOption;
- }
- return defaultOption.label;
- }
- return undefined;
- }
-}
-
-var pickr_min = createCommonjsModule(function (module, exports) {
-/*! Pickr 1.8.4 MIT | https://github.com/Simonwep/pickr */
-!function(t,e){module.exports=e();}(self,(function(){return (()=>{var t={d:(e,o)=>{for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]});},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0});}},e={};t.d(e,{default:()=>x});var o={};function n(t,e,o,n){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};e instanceof HTMLCollection||e instanceof NodeList?e=Array.from(e):Array.isArray(e)||(e=[e]),Array.isArray(o)||(o=[o]);for(const s of e)for(const e of o)s[t](e,n,{capture:!1,...i});return Array.prototype.slice.call(arguments,1)}t.r(o),t.d(o,{adjustableInputNumbers:()=>p,createElementFromString:()=>r,createFromTemplate:()=>a,eventPath:()=>l,off:()=>s,on:()=>i,resolveElement:()=>c});const i=n.bind(null,"addEventListener"),s=n.bind(null,"removeEventListener");function r(t){const e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild}function a(t){const e=(t,e)=>{const o=t.getAttribute(e);return t.removeAttribute(e),o},o=function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=e(t,":obj"),s=e(t,":ref"),r=i?n[i]={}:n;s&&(n[s]=t);for(const n of Array.from(t.children)){const t=e(n,":arr"),i=o(n,t?{}:r);t&&(r[t]||(r[t]=[])).push(Object.keys(i).length?i:n);}return n};return o(r(t))}function l(t){let e=t.path||t.composedPath&&t.composedPath();if(e)return e;let o=t.target.parentElement;for(e=[t.target,o];o=o.parentElement;)e.push(o);return e.push(document,window),e}function c(t){return t instanceof Element?t:"string"==typeof t?t.split(/>>/g).reduce(((t,e,o,n)=>(t=t.querySelector(e),o1&&void 0!==arguments[1]?arguments[1]:t=>t;function o(o){const n=[.001,.01,.1][Number(o.shiftKey||2*o.ctrlKey)]*(o.deltaY<0?1:-1);let i=0,s=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,((t,o)=>o<=s&&o+t.length>=s?(s=o,e(Number(t),n,i)):(i++,t))),t.focus(),t.setSelectionRange(s,s),o.preventDefault(),t.dispatchEvent(new Event("input"));}i(t,"focus",(()=>i(window,"wheel",o,{passive:!1}))),i(t,"blur",(()=>s(window,"wheel",o)));}const{min:h,max:u,floor:d,round:v}=Math;function m(t,e,o){e/=100,o/=100;const n=d(t=t/360*6),i=t-n,s=o*(1-e),r=o*(1-i*e),a=o*(1-(1-i)*e),l=n%6;return [255*[o,r,s,s,a,o][l],255*[a,o,o,r,s,s][l],255*[s,s,a,o,o,r][l]]}function f(t,e,o){return m(t,e,o).map((t=>v(t).toString(16).padStart(2,"0")))}function g(t,e,o){const n=m(t,e,o),i=n[0]/255,s=n[1]/255,r=n[2]/255,a=h(1-i,1-s,1-r);return [100*(1===a?0:(1-i-a)/(1-a)),100*(1===a?0:(1-s-a)/(1-a)),100*(1===a?0:(1-r-a)/(1-a)),100*a]}function b(t,e,o){const n=(2-(e/=100))*(o/=100)/2;return 0!==n&&(e=1===n?0:n<.5?e*o/(2*n):e*o/(2-2*n)),[t,100*e,100*n]}function y(t,e,o){const n=h(t/=255,e/=255,o/=255),i=u(t,e,o),s=i-n;let r,a;if(0===s)r=a=0;else {a=s/i;const n=((i-t)/6+s/2)/s,l=((i-e)/6+s/2)/s,c=((i-o)/6+s/2)/s;t===i?r=c-l:e===i?r=1/3+n-c:o===i&&(r=2/3+l-n),r<0?r+=1:r>1&&(r-=1);}return [360*r,100*a,100*i]}function _(t,e,o,n){e/=100,o/=100;return [...y(255*(1-h(1,(t/=100)*(1-(n/=100))+n)),255*(1-h(1,e*(1-n)+n)),255*(1-h(1,o*(1-n)+n)))]}function w(t,e,o){e/=100;const n=2*(e*=(o/=100)<.5?o:1-o)/(o+e)*100,i=100*(o+e);return [t,isNaN(n)?0:n,i]}function A(t){return y(...t.match(/.{2}/g).map((t=>parseInt(t,16))))}function C(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return "#000";const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000"===e.fillStyle?null:e.fillStyle}(t):t;const e={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},o=t=>t.map((t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0));let n;t:for(const i in e){if(!(n=e[i].exec(t)))continue;const s=t=>!!n[2]==("number"==typeof t);switch(i){case"cmyk":{const[,t,e,s,r]=o(n);if(t>100||e>100||s>100||r>100)break t;return {values:_(t,e,s,r),type:i}}case"rgba":{const[,,,t,e,r,a]=o(n);if(t>255||e>255||r>255||a<0||a>1||!s(a))break t;return {values:[...y(t,e,r),a],a,type:i}}case"hexa":{let[,t]=n;4!==t.length&&3!==t.length||(t=t.split("").map((t=>t+t)).join(""));const e=t.substring(0,6);let o=t.substring(6);return o=o?parseInt(o,16)/255:void 0,{values:[...A(e),o],a:o,type:i}}case"hsla":{const[,,,t,e,r,a]=o(n);if(t>360||e>100||r>100||a<0||a>1||!s(a))break t;return {values:[...w(t,e,r),a],a,type:i}}case"hsva":{const[,,,t,e,r,a]=o(n);if(t>360||e>100||r>100||a<0||a>1||!s(a))break t;return {values:[t,e,r,a],a,type:i}}}}return {values:null,type:null}}function $(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;const i=(t,e)=>function(){let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;return e(~o?t.map((t=>Number(t.toFixed(o)))):t)},s={h:t,s:e,v:o,a:n,toHSVA(){const t=[s.h,s.s,s.v,s.a];return t.toString=i(t,(t=>`hsva(${t[0]}, ${t[1]}%, ${t[2]}%, ${s.a})`)),t},toHSLA(){const t=[...b(s.h,s.s,s.v),s.a];return t.toString=i(t,(t=>`hsla(${t[0]}, ${t[1]}%, ${t[2]}%, ${s.a})`)),t},toRGBA(){const t=[...m(s.h,s.s,s.v),s.a];return t.toString=i(t,(t=>`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${s.a})`)),t},toCMYK(){const t=g(s.h,s.s,s.v);return t.toString=i(t,(t=>`cmyk(${t[0]}%, ${t[1]}%, ${t[2]}%, ${t[3]}%)`)),t},toHEXA(){const t=f(s.h,s.s,s.v),e=s.a>=1?"":Number((255*s.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return e&&t.push(e),t.toString=()=>`#${t.join("").toUpperCase()}`,t},clone:()=>$(s.h,s.s,s.v,s.a)};return s}const k=t=>Math.max(Math.min(t,1),0);function S(t){const e={options:Object.assign({lock:null,onchange:()=>0,onstop:()=>0},t),_keyboard(t){const{options:o}=e,{type:n,key:i}=t;if(document.activeElement===o.wrapper){const{lock:o}=e.options,s="ArrowUp"===i,r="ArrowRight"===i,a="ArrowDown"===i,l="ArrowLeft"===i;if("keydown"===n&&(s||r||a||l)){let n=0,i=0;"v"===o?n=s||r?1:-1:"h"===o?n=s||r?-1:1:(i=s?-1:a?1:0,n=l?-1:r?1:0),e.update(k(e.cache.x+.01*n),k(e.cache.y+.01*i)),t.preventDefault();}else i.startsWith("Arrow")&&(e.options.onstop(),t.preventDefault());}},_tapstart(t){i(document,["mouseup","touchend","touchcancel"],e._tapstop),i(document,["mousemove","touchmove"],e._tapmove),t.cancelable&&t.preventDefault(),e._tapmove(t);},_tapmove(t){const{options:o,cache:n}=e,{lock:i,element:s,wrapper:r}=o,a=r.getBoundingClientRect();let l=0,c=0;if(t){const e=t&&t.touches&&t.touches[0];l=t?(e||t).clientX:0,c=t?(e||t).clientY:0,la.left+a.width&&(l=a.left+a.width),ca.top+a.height&&(c=a.top+a.height),l-=a.left,c-=a.top;}else n&&(l=n.x*a.width,c=n.y*a.height);"h"!==i&&(s.style.left=`calc(${l/a.width*100}% - ${s.offsetWidth/2}px)`),"v"!==i&&(s.style.top=`calc(${c/a.height*100}% - ${s.offsetHeight/2}px)`),e.cache={x:l/a.width,y:c/a.height};const p=k(l/a.width),h=k(c/a.height);switch(i){case"v":return o.onchange(p);case"h":return o.onchange(h);default:return o.onchange(p,h)}},_tapstop(){e.options.onstop(),s(document,["mouseup","touchend","touchcancel"],e._tapstop),s(document,["mousemove","touchmove"],e._tapmove);},trigger(){e._tapmove();},update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const{left:n,top:i,width:s,height:r}=e.options.wrapper.getBoundingClientRect();"h"===e.options.lock&&(o=t),e._tapmove({clientX:n+s*t,clientY:i+r*o});},destroy(){const{options:t,_tapstart:o,_keyboard:n}=e;s(document,["keydown","keyup"],n),s([t.wrapper,t.element],"mousedown",o),s([t.wrapper,t.element],"touchstart",o,{passive:!1});}},{options:o,_tapstart:n,_keyboard:r}=e;return i([o.wrapper,o.element],"mousedown",n),i([o.wrapper,o.element],"touchstart",n,{passive:!1}),i(document,["keydown","keyup"],r),e}function O(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=Object.assign({onchange:()=>0,className:"",elements:[]},t);const e=i(t.elements,"click",(e=>{t.elements.forEach((o=>o.classList[e.target===o?"add":"remove"](t.className))),t.onchange(e),e.stopPropagation();}));return {destroy:()=>s(...e)}}const E={variantFlipOrder:{start:"sme",middle:"mse",end:"ems"},positionFlipOrder:{top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},position:"bottom",margin:8},L=(t,e,o)=>{const{container:n,margin:i,position:s,variantFlipOrder:r,positionFlipOrder:a}={container:document.documentElement.getBoundingClientRect(),...E,...o},{left:l,top:c}=e.style;e.style.left="0",e.style.top="0";const p=t.getBoundingClientRect(),h=e.getBoundingClientRect(),u={t:p.top-h.height-i,b:p.bottom+i,r:p.right+i,l:p.left-h.width-i},d={vs:p.left,vm:p.left+p.width/2+-h.width/2,ve:p.left+p.width-h.width,hs:p.top,hm:p.bottom-p.height/2-h.height/2,he:p.bottom-h.height},[v,m="middle"]=s.split("-"),f=a[v],g=r[m],{top:b,left:y,bottom:_,right:w}=n;for(const t of f){const o="t"===t||"b"===t,n=u[t],[i,s]=o?["top","left"]:["left","top"],[r,a]=o?[h.height,h.width]:[h.width,h.height],[l,c]=o?[_,w]:[w,_],[p,v]=o?[b,y]:[y,b];if(!(n
l))for(const r of g){const l=d[(o?"v":"h")+r];if(!(lc))return e.style[s]=l-h[s]+"px",e.style[i]=n-h[i]+"px",t+r}}return e.style.left=l,e.style.top=c,null};function P(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class x{constructor(t){P(this,"_initializingActive",!0),P(this,"_recalc",!0),P(this,"_nanopop",null),P(this,"_root",null),P(this,"_color",$()),P(this,"_lastColor",$()),P(this,"_swatchColors",[]),P(this,"_setupAnimationFrame",null),P(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=t=Object.assign({...x.DEFAULT_OPTIONS},t);const{swatches:e,components:o,theme:n,sliders:i,lockOpacity:s,padding:r}=t;["nano","monolith"].includes(n)&&!i&&(t.sliders="h"),o.interaction||(o.interaction={});const{preview:a,opacity:l,hue:c,palette:p}=o;o.opacity=!s&&l,o.palette=p||a||l||c,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),e&&e.length&&e.forEach((t=>this.addSwatch(t)));const{button:h,app:u}=this._root;this._nanopop=((t,e,o)=>{const n="object"!=typeof t||t instanceof HTMLElement?{reference:t,popper:e,...o}:t;return {update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n;const{reference:e,popper:o}=Object.assign(n,t);if(!o||!e)throw new Error("Popper- or reference-element missing.");return L(e,o,n)}}})(h,u,{margin:r}),h.setAttribute("role","button"),h.setAttribute("aria-label",this._t("btn:toggle"));const d=this;this._setupAnimationFrame=requestAnimationFrame((function e(){if(!u.offsetWidth)return d._setupAnimationFrame=requestAnimationFrame(e);d.setColor(t.default),d._rePositioningPicker(),t.defaultRepresentation&&(d._representation=t.defaultRepresentation,d.setColorRepresentation(d._representation)),t.showAlways&&d.show(),d._initializingActive=!1,d._emit("init");}));}_preBuild(){const{options:t}=this;for(const e of ["el","container"])t[e]=c(t[e]);this._root=(t=>{const{components:e,useAsButton:o,inline:n,appClass:i,theme:s,lockOpacity:r}=t.options,l=t=>t?"":'style="display:none" hidden',c=e=>t._t(e),p=a(`\n