From 6c7d6baf4cc4e9255f742688efc629c3a31cd2d3 Mon Sep 17 00:00:00 2001 From: sdfsdf Date: Mon, 30 Sep 2024 23:15:46 +0200 Subject: [PATCH] vault backup: 2024-09-30 23:15:41 --- GGDoc/.obsidian/community-plugins.json | 6 +- .../automatic-table-of-contents/main.js | 291 + .../automatic-table-of-contents/manifest.json | 10 + .../.obsidian/plugins/awesome-image/data.json | 34 + GGDoc/.obsidian/plugins/awesome-image/main.js | 28588 ++++++++++++++++ .../plugins/awesome-image/manifest.json | 10 + .../plugins/awesome-image/styles.css | 341 + GGDoc/.obsidian/plugins/dataview/data.json | 27 + GGDoc/.obsidian/plugins/dataview/main.js | 20723 +++++++++++ .../.obsidian/plugins/dataview/manifest.json | 11 + GGDoc/.obsidian/plugins/dataview/styles.css | 146 + .../plugins/obsidian-file-color/data.json | 4 +- .../plugins/obsidian-thumbnails/data.json | 8 + .../plugins/obsidian-thumbnails/main.js | 616 + .../plugins/obsidian-thumbnails/manifest.json | 10 + .../plugins/obsidian-thumbnails/styles.css | 178 + GGDoc/.obsidian/plugins/tag-wrangler/main.js | 135 + .../plugins/tag-wrangler/manifest.json | 11 + .../.obsidian/plugins/tag-wrangler/styles.css | 1 + GGDoc/.obsidian/workspace.json | 65 +- .../{Design => 10 Design}/Hypothèses.canvas | 0 GGDoc/Misc/How to Obsidian.md | 6 + ...4668326e86f70408af7ebaf2d99b9f1210a5ed.png | Bin 0 -> 37291 bytes ...b1714cc49112ad86de394b437f3e65d4b38ec5.png | Bin 0 -> 23591 bytes 24 files changed, 51195 insertions(+), 26 deletions(-) create mode 100644 GGDoc/.obsidian/plugins/automatic-table-of-contents/main.js create mode 100644 GGDoc/.obsidian/plugins/automatic-table-of-contents/manifest.json create mode 100644 GGDoc/.obsidian/plugins/awesome-image/data.json create mode 100644 GGDoc/.obsidian/plugins/awesome-image/main.js create mode 100644 GGDoc/.obsidian/plugins/awesome-image/manifest.json create mode 100644 GGDoc/.obsidian/plugins/awesome-image/styles.css create mode 100644 GGDoc/.obsidian/plugins/dataview/data.json create mode 100644 GGDoc/.obsidian/plugins/dataview/main.js create mode 100644 GGDoc/.obsidian/plugins/dataview/manifest.json create mode 100644 GGDoc/.obsidian/plugins/dataview/styles.css create mode 100644 GGDoc/.obsidian/plugins/obsidian-thumbnails/data.json create mode 100644 GGDoc/.obsidian/plugins/obsidian-thumbnails/main.js create mode 100644 GGDoc/.obsidian/plugins/obsidian-thumbnails/manifest.json create mode 100644 GGDoc/.obsidian/plugins/obsidian-thumbnails/styles.css create mode 100644 GGDoc/.obsidian/plugins/tag-wrangler/main.js create mode 100644 GGDoc/.obsidian/plugins/tag-wrangler/manifest.json create mode 100644 GGDoc/.obsidian/plugins/tag-wrangler/styles.css rename GGDoc/{Design => 10 Design}/Hypothèses.canvas (100%) create mode 100644 GGDoc/Misc/How to Obsidian.md create mode 100644 GGDoc/Misc/Storage/Attachments/8/2/8/828b38e1763369b52b2efba15d4668326e86f70408af7ebaf2d99b9f1210a5ed.png create mode 100644 GGDoc/Misc/Storage/Attachments/9/4/e/94ebc76d29274d246b1bd9bcb4b1714cc49112ad86de394b437f3e65d4b38ec5.png diff --git a/GGDoc/.obsidian/community-plugins.json b/GGDoc/.obsidian/community-plugins.json index f298fde..919ce7f 100644 --- a/GGDoc/.obsidian/community-plugins.json +++ b/GGDoc/.obsidian/community-plugins.json @@ -3,5 +3,9 @@ "obsidian-style-settings", "obsidian-icon-folder", "obsidian-file-color", - "obsidian-git" + "obsidian-git", + "tag-wrangler", + "obsidian-thumbnails", + "dataview", + "awesome-image" ] \ No newline at end of file diff --git a/GGDoc/.obsidian/plugins/automatic-table-of-contents/main.js b/GGDoc/.obsidian/plugins/automatic-table-of-contents/main.js new file mode 100644 index 0000000..bbc2b0f --- /dev/null +++ b/GGDoc/.obsidian/plugins/automatic-table-of-contents/main.js @@ -0,0 +1,291 @@ +let Plugin = class {} +let MarkdownRenderer = {} +let MarkdownRenderChild = class {} +let htmlToMarkdown = (html) => html + +if (isObsidian()) { + const obsidian = require('obsidian') + Plugin = obsidian.Plugin + MarkdownRenderer = obsidian.MarkdownRenderer + MarkdownRenderChild = obsidian.MarkdownRenderChild + htmlToMarkdown = obsidian.htmlToMarkdown +} + +const codeblockId = 'table-of-contents' +const codeblockIdShort = 'toc' +const availableOptions = { + title: { + type: 'string', + default: '', + comment: '', + }, + style: { + type: 'value', + default: 'nestedList', + values: ['nestedList', 'nestedOrderedList', 'inlineFirstLevel'], + comment: 'TOC style (nestedList|nestedOrderedList|inlineFirstLevel)', + }, + minLevel: { + type: 'number', + default: 0, + comment: 'Include headings from the specified level', + }, + maxLevel: { + type: 'number', + default: 0, + comment: 'Include headings up to the specified level', + }, + includeLinks: { + type: 'boolean', + default: true, + comment: 'Make headings clickable', + }, + debugInConsole: { + type: 'boolean', + default: false, + comment: 'Print debug info in Obsidian console', + }, +} + +class ObsidianAutomaticTableOfContents extends Plugin { + async onload() { + const handler = (sourceText, element, context) => { + context.addChild(new Renderer(this.app, element, context.sourcePath, sourceText)) + } + this.registerMarkdownCodeBlockProcessor(codeblockId, handler) + this.registerMarkdownCodeBlockProcessor(codeblockIdShort, handler) + this.addCommand({ + id: 'insert-automatic-table-of-contents', + name: 'Insert table of contents', + editorCallback: onInsertToc, + }) + this.addCommand({ + id: 'insert-automatic-table-of-contents-docs', + name: 'Insert table of contents (documented)', + editorCallback: onInsertTocWithDocs, + }) + } +} + +function onInsertToc(editor) { + const markdown = '```' + codeblockId + '\n```' + editor.replaceRange(markdown, editor.getCursor()) +} + +function onInsertTocWithDocs(editor) { + let markdown = ['```' + codeblockId] + Object.keys(availableOptions).forEach((optionName) => { + const option = availableOptions[optionName] + const comment = option.comment.length > 0 ? ` # ${option.comment}` : '' + markdown.push(`${optionName}: ${option.default}${comment}`) + }) + markdown.push('```') + editor.replaceRange(markdown.join('\n'), editor.getCursor()) +} + +class Renderer extends MarkdownRenderChild { + constructor(app, element, sourcePath, sourceText) { + super(element) + this.app = app + this.element = element + this.sourcePath = sourcePath + this.sourceText = sourceText + } + + // Render on load + onload() { + this.render() + this.registerEvent(this.app.metadataCache.on('changed', this.onMetadataChange.bind(this))) + } + + // Render on file change + onMetadataChange() { + this.render() + } + + render() { + try { + const options = parseOptionsFromSourceText(this.sourceText) + if (options.debugInConsole) debug('Options', options) + + const metadata = this.app.metadataCache.getCache(this.sourcePath) + const headings = metadata && metadata.headings ? metadata.headings : [] + if (options.debugInConsole) debug('Headings', headings) + + const markdown = getMarkdownFromHeadings(headings, options) + if (options.debugInConsole) debug('Markdown', markdown) + + this.element.empty() + MarkdownRenderer.renderMarkdown(markdown, this.element, this.sourcePath, this) + } catch(error) { + const readableError = `_💥 Could not render table of contents (${error.message})_` + MarkdownRenderer.renderMarkdown(readableError, this.element, this.sourcePath, this) + } + } +} + +function getMarkdownFromHeadings(headings, options) { + const markdownHandlersByStyle = { + nestedList: getMarkdownNestedListFromHeadings, + nestedOrderedList: getMarkdownNestedOrderedListFromHeadings, + inlineFirstLevel: getMarkdownInlineFirstLevelFromHeadings, + } + let markdown = '' + if (options.title && options.title.length > 0) { + markdown += options.title + '\n' + } + const noHeadingMessage = '_Table of contents: no headings found_' + markdown += markdownHandlersByStyle[options.style](headings, options) || noHeadingMessage + return markdown +} + +function getMarkdownNestedListFromHeadings(headings, options) { + return getMarkdownListFromHeadings(headings, false, options) +} + +function getMarkdownNestedOrderedListFromHeadings(headings, options) { + return getMarkdownListFromHeadings(headings, true, options) +} + +function getMarkdownListFromHeadings(headings, isOrdered, options) { + const prefix = isOrdered ? '1.' : '-' + const lines = [] + const minLevel = options.minLevel > 0 + ? options.minLevel + : Math.min(...headings.map((heading) => heading.level)) + headings.forEach((heading) => { + if (heading.level < minLevel) return + if (options.maxLevel > 0 && heading.level > options.maxLevel) return + lines.push(`${'\t'.repeat(heading.level - minLevel)}${prefix} ${getMarkdownHeading(heading, options)}`) + }) + return lines.length > 0 ? lines.join('\n') : null +} + +function getMarkdownInlineFirstLevelFromHeadings(headings, options) { + const minLevel = options.minLevel > 0 + ? options.minLevel + : Math.min(...headings.map((heading) => heading.level)) + const items = headings + .filter((heading) => heading.level === minLevel) + .map((heading) => { + return getMarkdownHeading(heading, options) + }) + return items.length > 0 ? items.join(' | ') : null +} + +function getMarkdownHeading(heading, options) { + const stripMarkdown = (text) => { + text = text.replaceAll('*', '').replaceAll('_', '').replaceAll('`', '') + text = text.replaceAll('==', '').replaceAll('~~', '') + text = text.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // Strip markdown links + return text + } + const stripHtml = (text) => stripMarkdown(htmlToMarkdown(text)) + const stripWikilinks = (text, isForLink) => { + // Strip [[link|text]] format + // For the text part of the final link we only keep "text" + // For the link part we need the text + link + // Example: "# Some [[file.md|heading]]" must be translated to "[[#Some file.md heading|Some heading]]" + text = text.replace(/\[\[([^\]]+)\|([^\]]+)\]\]/g, isForLink ? '$1 $2' : '$2') + text = text.replace(/\[\[([^\]]+)\]\]/g, '$1') // Strip [[link]] format + // Replace malformed links & reserved wikilinks chars + text = text.replaceAll('[[', '').replaceAll('| ', isForLink ? '' : '- ').replaceAll('|', isForLink ? ' ' : '-') + return text + } + const stripTags = (text) => text.replaceAll('#', '') + if (options.includeLinks) { + // Remove markdown, HTML & wikilinks from text for readability, as they are not rendered in a wikilink + let text = heading.heading + text = stripMarkdown(text) + text = stripHtml(text) + text = stripWikilinks(text, false) + // Remove wikilinks & tags from link or it won't be clickable (on the other hand HTML & markdown must stay) + let link = heading.heading + link = stripWikilinks(link, true) + link = stripTags(link) + + // Return wiklink style link + return `[[#${link}|${text}]]` + // Why not markdown links? Because even if it looks like the text part would have a better compatibility + // with complex headings (as it would support HTML, markdown, etc) the link part is messy, + // because it requires some encoding that looks buggy and undocumented; official docs state the link must be URL encoded + // (https://help.obsidian.md/Linking+notes+and+files/Internal+links#Supported+formats+for+internal+links) + // but it doesn't work properly, example: "## Some heading with simple HTML" must be encoded as: + // [Some heading with simple HTML](#Some%20heading%20with%20simpler%20HTML) + // and not + // [Some heading with simple HTML](#Some%20%3Cem%3Eheading%3C%2Fem%3E%20with%20simpler%20HTML) + // Also it won't be clickable at all if the heading contains #tags or more complex HTML + // (example: ## Some heading #with-a-tag) + // (unless there is a way to encode these use cases that I didn't find) + } + return heading.heading +} + +function parseOptionsFromSourceText(sourceText = '') { + const options = {} + Object.keys(availableOptions).forEach((option) => { + options[option] = availableOptions[option].default + }) + sourceText.split('\n').forEach((line) => { + const option = parseOptionFromSourceLine(line) + if (option !== null) { + options[option.name] = option.value + } + }) + return options +} + +function parseOptionFromSourceLine(line) { + const matches = line.match(/([a-zA-Z0-9._ ]+):(.*)/) + if (line.startsWith('#') || !matches) return null + const possibleName = matches[1].trim() + const optionParams = availableOptions[possibleName] + let possibleValue = matches[2].trim() + if (!optionParams || optionParams.type !== 'string') { + // Strip comments from values except for strings (as a string may contain markdown) + possibleValue = possibleValue.replace(/#[^#]*$/, '').trim() + } + const valueError = new Error(`Invalid value for \`${possibleName}\``) + if (optionParams && optionParams.type === 'number') { + const value = parseInt(possibleValue) + if (value < 0) throw valueError + return { name: possibleName, value } + } + if (optionParams && optionParams.type === 'boolean') { + if (!['true', 'false'].includes(possibleValue)) throw valueError + return { name: possibleName, value: possibleValue === 'true' } + } + if (optionParams && optionParams.type === 'value') { + if (!optionParams.values.includes(possibleValue)) throw valueError + return { name: possibleName, value: possibleValue } + } + if (optionParams && optionParams.type === 'string') { + return { name: possibleName, value: possibleValue } + } + return null +} + +function debug(type, data) { + console.log(...[ + `%cAutomatic Table Of Contents %c${type}:\n`, + 'color: orange; font-weight: bold', + 'font-weight: bold', + data, + ]) +} + +function isObsidian() { + if (typeof process !== 'object') { + return true // Obsidian mobile doesn't have a global process object + } + return !process.env || !process.env.JEST_WORKER_ID // Jest runtime is not Obsidian +} + +if (isObsidian()) { + module.exports = ObsidianAutomaticTableOfContents +} else { + module.exports = { + parseOptionsFromSourceText, + getMarkdownFromHeadings, + } +} diff --git a/GGDoc/.obsidian/plugins/automatic-table-of-contents/manifest.json b/GGDoc/.obsidian/plugins/automatic-table-of-contents/manifest.json new file mode 100644 index 0000000..535186f --- /dev/null +++ b/GGDoc/.obsidian/plugins/automatic-table-of-contents/manifest.json @@ -0,0 +1,10 @@ +{ + "id": "automatic-table-of-contents", + "name": "Automatic Table Of Contents", + "version": "1.4.0", + "minAppVersion": "1.3.0", + "description": "Create a table of contents in a note, that updates itself when the note changes", + "author": "Johan Satgé", + "authorUrl": "https://github.com/johansatge", + "isDesktopOnly": false +} \ No newline at end of file diff --git a/GGDoc/.obsidian/plugins/awesome-image/data.json b/GGDoc/.obsidian/plugins/awesome-image/data.json new file mode 100644 index 0000000..6042f78 --- /dev/null +++ b/GGDoc/.obsidian/plugins/awesome-image/data.json @@ -0,0 +1,34 @@ +{ + "viewImageEditor": true, + "viewImageInCPB": true, + "viewImageWithALink": true, + "viewImageOther": true, + "pinMode": false, + "pinMaximum": 3, + "pinCoverMode": true, + "imageMoveSpeed": 10, + "imgTipToggle": true, + "imgFullScreenMode": "FIT", + "imgViewBackgroundColor": "#00000000", + "imageBorderToggle": false, + "imageBorderWidth": "medium", + "imageBorderStyle": "solid", + "imageBorderColor": "red", + "galleryNavbarToggle": true, + "galleryNavbarDefaultColor": "#0000001A", + "galleryNavbarHoverColor": "#0000004D", + "galleryImgBorderActive": true, + "galleryImgBorderActiveColor": "#FF0000", + "moveTheImageHotkey": "ALT", + "switchTheImageHotkey": "NONE", + "doubleClickToolbar": "toolbar_full_screen", + "viewTriggerHotkey": "CTRL", + "realTimeUpdate": true, + "excludedFolders": [ + ".git/", + ".obsidian/", + ".trash/" + ], + "includedFileRegex": ".*\\.md", + "mediaRootDirectory": "Misc/Storage/Attachments" +} \ No newline at end of file diff --git a/GGDoc/.obsidian/plugins/awesome-image/main.js b/GGDoc/.obsidian/plugins/awesome-image/main.js new file mode 100644 index 0000000..1d973b5 --- /dev/null +++ b/GGDoc/.obsidian/plugins/awesome-image/main.js @@ -0,0 +1,28588 @@ +/* +THIS IS A GENERATED/BUNDLED FILE BY ROLLUP +if you want to view the source visit the plugins github repository +*/ + +'use strict'; + +var obsidian = require('obsidian'); +var path = require('path'); +var node_buffer = require('node:buffer'); +var require$$0$1 = require('stream'); +var require$$0$3 = require('events'); +var require$$0$2 = require('buffer'); +var require$$1 = require('util'); +var EventEmitter$2 = require('node:events'); +var process$1 = require('node:process'); +var stream$3 = require('node:stream'); +var urlLib = require('node:url'); +var http$3 = require('node:http'); +var crypto = require('node:crypto'); +var require$$1$1 = require('zlib'); +var node_util = require('node:util'); +var net = require('node:net'); +var node_tls = require('node:tls'); +var https$3 = require('node:https'); +var node_dns = require('node:dns'); +var os = require('node:os'); +var require$$3 = require('http2'); +var require$$0$4 = require('url'); +var require$$0$5 = require('tls'); +var require$$1$3 = require('http'); +var require$$2 = require('https'); +var require$$0$6 = require('net'); +var require$$1$2 = require('assert'); +require('node:path'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var path__default = /*#__PURE__*/_interopDefaultLegacy(path); +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$1); +var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3); +var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2); +var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); +var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter$2); +var process__default = /*#__PURE__*/_interopDefaultLegacy(process$1); +var stream__default = /*#__PURE__*/_interopDefaultLegacy(stream$3); +var urlLib__default = /*#__PURE__*/_interopDefaultLegacy(urlLib); +var http__default = /*#__PURE__*/_interopDefaultLegacy(http$3); +var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto); +var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1); +var net__default = /*#__PURE__*/_interopDefaultLegacy(net); +var https__default = /*#__PURE__*/_interopDefaultLegacy(https$3); +var os__default = /*#__PURE__*/_interopDefaultLegacy(os); +var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3); +var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4); +var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5); +var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3); +var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2); +var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$6); +var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2); + +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ + +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}; + +// العربية +var ar = {}; + +// čeština +var cz = {}; + +// Dansk +var da = {}; + +// Deutsch +var de = {}; + +// English +var en = { + // settings + IMAGE_TOOLKIT_SETTINGS_TITLE: "Image Toolkit Settings", + // >>>View Trigger Settings: + VIEW_TRIGGER_SETTINGS: 'View Trigger Settings:', + VIEW_IMAGE_GLOBAL_NAME: 'Click and view an image globally', + VIEW_IMAGE_GLOBAL_DESC: 'You can zoom, rotate, drag, and invert it on the popup layer when clicking an image.', + VIEW_IMAGE_EDITOR_NAME: 'Click and view an image in the Editor Area', + VIEW_IMAGE_EDITOR_DESC: 'Turn on this option if you want to click and view an image in the Editor Area.', + // CPB = COMMUNITY_PLUGINS_BROWSER + VIEW_IMAGE_IN_CPB_NAME: 'Click and view an image in the Community Plugins browser', + VIEW_IMAGE_IN_CPB_DESC: 'Turn on this option if you want to click and view an image in the Community Plugins browser.', + VIEW_IMAGE_WITH_A_LINK_NAME: 'Click and view an image with a link', + VIEW_IMAGE_WITH_A_LINK_DESC: 'Turn on this option if you want to click and view an image with a link. (NOTE: The browser will be opened for you to visit the link and the image will be popped up for being viewed at the same time when you click the image.)', + VIEW_IMAGE_OTHER_NAME: 'Click and view in the other areas except the above', + VIEW_IMAGE_OTHER_DESC: 'Except for the above mentioned, it also supports other areas, e.g. flashcards.', + // >>> PIN_MODE_SETTINGS + PIN_MODE_SETTINGS: "Pin Mode Settings:", + PIN_MODE_NAME: "📌 Pin an image", + PIN_MODE_DESC: "You can pin an image onto the top of the screen. And have more options by right click. (press Esc to close the image where your mouse cursor is hovering)", + PIN_MAXIMUM_NAME: "The maximum image you can pin", + PIN_COVER_NAME: "Cover mode", + PIN_COVER_DESC: "After those pinned images reach maximum, you can cover the earliest pinned image when you click an image once again.", + // >>>View Detail Settings: + VIEW_DETAILS_SETTINGS: 'View Detail Settings:', + IMAGE_MOVE_SPEED_NAME: 'Set the moving speed of the image', + IMAGE_MOVE_SPEED_DESC: 'When you move an image on the popup layer by keyboard (up, down, left, right), the moving speed of the image can be set here.', + IMAGE_TIP_TOGGLE_NAME: "Display the image's zoom number", + IMAGE_TIP_TOGGLE_DESC: "Turn on this option if you want to display the zoom number when you zoom the image.", + IMG_FULL_SCREEN_MODE_NAME: 'Full-screen preview mode', + // preview mode options: + FIT: 'Fit', + FILL: 'Fill', + STRETCH: 'Stretch', + IMG_VIEW_BACKGROUND_COLOR_NAME: "Set the background color of the previewed image (Only support the image with transparent background)", + // >>>Image Border Settings: + IMAGE_BORDER_SETTINGS: 'Image Border Settings:', + IMAGE_BORDER_TOGGLE_NAME: "Display the image's border", + IMAGE_BORDER_TOGGLE_DESC: "The clicked image's border can be displayed after you exit previewing and close the popup layer.", + IMAGE_BORDER_WIDTH_NAME: "Set the image's border width", + IMAGE_BORDER_STYLE_NAME: "Set the image's border style", + IMAGE_BORDER_COLOR_NAME: "Set the image's border color", + // IMG_BORDER_WIDTH options: + THIN: 'thin', + MEDIUM: 'medium', + THICK: 'thick', + // IMG_BORDER_STYLE options: + //HIDDEN: 'hidden', + DOTTED: 'dotted', + DASHED: 'dashed', + SOLID: 'solid', + DOUBLE: 'double', + GROOVE: 'groove', + RIDGE: 'ridge', + INSET: 'inset', + OUTSET: 'outset', + // IMAGE_BORDER_COLOR_NAME options: + BLACK: 'black', + BLUE: 'blue', + DARK_GREEN: 'dark green', + GREEN: 'green', + LIME: 'lime', + STEEL_BLUE: 'steel blue', + INDIGO: 'indigo', + PURPLE: 'purple', + GRAY: 'gray', + DARK_RED: 'dark red', + LIGHT_GREEN: 'light green', + BROWN: 'brown', + LIGHT_BLUE: 'light blue', + SILVER: 'silver', + RED: 'red', + PINK: 'pink', + ORANGE: 'orange', + GOLD: 'gold', + YELLOW: 'yellow', + // >>>Gallery Navbar Settings: + GALLERY_NAVBAR_SETTINGS: 'Gallery Navbar Settings (Experimental):', + GALLERY_NAVBAR_TOGGLE_NAME: "Display gallery navbar", + GALLERY_NAVBAR_TOGGLE_DESC: "All of the images in the current pane view can be displayed at the bottom of the popup layer.", + GALLERY_NAVBAR_DEFAULT_COLOR_NAME: "Set the background color of the gallery navbar (default state)", + GALLERY_NAVBAR_HOVER_COLOR_NAME: "Set the background color of the gallery navbar (hovering state)", + GALLERY_IMG_BORDER_TOGGLE_NAME: "Display the selected image on the gallery navbar", + GALLERY_IMG_BORDER_TOGGLE_DESC: "When you select an image, the image's border will be displayed, so you can know which image is currently active.", + GALLERY_IMG_BORDER_ACTIVE_COLOR_NAME: 'Set the border color of the selected image', + // >>>HOTKEYS_SETTINGS: + HOTKEY_SETTINGS: "Hotkey Settings:", + HOTKEY_SETTINGS_DESC: "📢 You cannot set the same hotkey for 'Move the image' and 'Switch the image' at the same time. (NOT SUPPORT in Pin Mode)", + MOVE_THE_IMAGE_NAME: "Set the hotkey for moving the image", + MOVE_THE_IMAGE_DESC: "You can move the image on the popup layer by hotkey.", + SWITCH_THE_IMAGE_NAME: "Set the hotkey for switching the image", + SWITCH_THE_IMAGE_DESC: "You can switch to the previous/next image on the gallery navbar by hotkey. (NOTE: You need to turn on 'Display gallery navbar' first, if you wanna use this hotkey.)", + DOUBLE_CLICK_TOOLBAR_NAME: "Double click", + VIEW_TRIGGER_HOTKEY_NAME: "Set the hotkey for triggering viewing an image", + VIEW_TRIGGER_HOTKEY_DESC: "When you set 'None', you can directly click and preview an image without holding any modifier keys; otherwise, you must hold the configured modifier keys to click and preview an image.", + // MODIFIER_HOTKEYS + NONE: "None", + CTRL: "Ctrl", + ALT: "Alt", + SHIFT: "Shift", + CTRL_ALT: "Ctrl+Alt", + CTRL_SHIFT: "Ctrl+Shift", + SHIFT_ALT: "Shift+Alt", + CTRL_SHIFT_ALT: "Ctrl+Shift+Alt", + // toolbar icon title + ZOOM_TO_100: "zoom to 100%", + ZOOM_IN: "zoom in", + ZOOM_OUT: "zoom out", + FULL_SCREEN: 'full screen', + REFRESH: "refresh", + ROTATE_LEFT: "rotate left", + ROTATE_RIGHT: "rotate right", + SCALE_X: 'flip along x-axis', + SCALE_Y: 'flip along y-axis', + INVERT_COLOR: 'invert color', + COPY: 'copy', + CLOSE: 'close', + // tip: + COPY_IMAGE_SUCCESS: 'Copy the image successfully!', + COPY_IMAGE_ERROR: 'Fail to copy the image!' +}; + +// British English +var enGB = {}; + +// Español +var es = {}; + +// français +var fr = {}; + +// हिन्दी +var hi = {}; + +// Bahasa Indonesia +var id = {}; + +// Italiano +var it = {}; + +// 日本語 +var ja = {}; + +// 한국어 +var ko = {}; + +// Nederlands +var nl = {}; + +// Norsk +var no = {}; + +// język polski +var pl = {}; + +// Português +var pt = {}; + +// Português do Brasil +// Brazilian Portuguese +var ptBR = {}; + +// Română +var ro = {}; + +// русский +var ru = {}; + +// Türkçe +var tr = {}; + +// 简体中文 +var zhCN = { + // settings + IMAGE_TOOLKIT_SETTINGS_TITLE: "Image Toolkit 插件设置", + // >>> 预览触发配置: + VIEW_TRIGGER_SETTINGS: '预览触发配置:', + VIEW_IMAGE_GLOBAL_NAME: '支持全局预览图片', + VIEW_IMAGE_GLOBAL_DESC: '开启后,在任何地方点击图片都可以弹出预览界面,可对图片进行缩放、旋转、拖动、和反色等。', + VIEW_IMAGE_EDITOR_NAME: '支持在编辑区域预览图片', + VIEW_IMAGE_EDITOR_DESC: '开启后,支持在编辑区域,点击图片预览。', + // CPB = COMMUNITY_PLUGINS_BROWSER + VIEW_IMAGE_IN_CPB_NAME: '支持在社区插件页面预览图片', + VIEW_IMAGE_IN_CPB_DESC: '开启后,支持在社区插件页面,点击图片预览。', + VIEW_IMAGE_WITH_A_LINK_NAME: '支持预览带链接的图片', + VIEW_IMAGE_WITH_A_LINK_DESC: '开启后,支持点击带链接的图片(注意:点击该图片,会同时打开浏览器访问指定地址和弹出预览图片)', + VIEW_IMAGE_OTHER_NAME: '支持除上述其他地方来预览图片', + VIEW_IMAGE_OTHER_DESC: '除上述支持范围外,还支持一些其他区域,如flashcards。', + // >>> PIN_MODE_SETTINGS + PIN_MODE_SETTINGS: "贴图模式设置:", + PIN_MODE_NAME: "📌 将所点击的图片贴到屏幕上", + PIN_MODE_DESC: "你可以将当前所点击的图片贴到屏幕上,并且可以通过右击图片选择更多操作(按 Esc 关闭已贴图片的展示)", + PIN_MAXIMUM_NAME: "最大贴图数量", + PIN_COVER_NAME: "覆盖模式", + PIN_COVER_DESC: "当贴图数量达到最大值后,此时再次点击图片,该图片会覆盖最早弹出的那个贴图。", + // >>>查看细节设置: + VIEW_DETAILS_SETTINGS: '查看细节设置:', + IMAGE_MOVE_SPEED_NAME: '图片移动速度设置', + IMAGE_MOVE_SPEED_DESC: '当使用键盘(上、下、左、右)移动图片时,可对图片移动速度进行设置。', + IMAGE_TIP_TOGGLE_NAME: "展示缩放比例提示", + IMAGE_TIP_TOGGLE_DESC: "开启后,当你缩放图片时会展示当前缩放的比例。", + IMG_FULL_SCREEN_MODE_NAME: '全屏预览模式', + // 全屏预览模式 下拉: + FIT: '自适应', + FILL: '填充', + STRETCH: '拉伸', + IMG_VIEW_BACKGROUND_COLOR_NAME: "设置预览图片的背景色(仅对透明背景的图片生效)", + // >>>图片边框设置: + IMAGE_BORDER_SETTINGS: '图片边框设置:', + IMAGE_BORDER_TOGGLE_NAME: "展示被点击图片的边框", + IMAGE_BORDER_TOGGLE_DESC: "当离开图片预览和关闭弹出层后,突出展示被点击图片的边框。", + IMAGE_BORDER_WIDTH_NAME: "设置图片边框宽度", + IMAGE_BORDER_STYLE_NAME: "设置图片边框样式", + IMAGE_BORDER_COLOR_NAME: "设置图片边框颜色", + // IMG_BORDER_WIDTH 下拉: + THIN: '较细', + MEDIUM: '正常', + THICK: '较粗', + // IMG_BORDER_STYLE 下拉: + //HIDDEN: '隐藏', + DOTTED: '点状', + DASHED: '虚线', + SOLID: '实线', + DOUBLE: '双线', + GROOVE: '凹槽', + RIDGE: ' 垄状', + INSET: '凹边', + OUTSET: '凸边', + // IMAGE_BORDER_COLOR_NAME 下拉: + BLACK: '黑色', + BLUE: '蓝色', + DARK_GREEN: '深绿色', + GREEN: '绿色', + LIME: '淡黄绿色', + STEEL_BLUE: '钢青色', + INDIGO: '靛蓝色', + PURPLE: '紫色', + GRAY: '灰色', + DARK_RED: '深红色', + LIGHT_GREEN: '浅绿色', + BROWN: '棕色', + LIGHT_BLUE: '浅蓝色', + SILVER: '银色', + RED: '红色', + PINK: '粉红色', + ORANGE: '橘黄色', + GOLD: '金色', + YELLOW: '黄色', + // >>>Gallery Navbar Settings: + GALLERY_NAVBAR_SETTINGS: '图片导航设置 (体验版):', + GALLERY_NAVBAR_TOGGLE_NAME: "展示图片导航", + GALLERY_NAVBAR_TOGGLE_DESC: "当前文档的所有图片会展示在弹出层的底部,可随意切换展示不同图片。", + GALLERY_NAVBAR_DEFAULT_COLOR_NAME: "设置图片导航底栏背景色(默认展示)", + GALLERY_NAVBAR_HOVER_COLOR_NAME: "设置图片导航底栏背景色(鼠标悬浮时)", + GALLERY_IMG_BORDER_TOGGLE_NAME: "展示图片导航上被选中的图片", + GALLERY_IMG_BORDER_TOGGLE_DESC: "当你选中正查看某一图片,对应图片导航底栏上将突出显示该缩略图片的边框。", + GALLERY_IMG_BORDER_ACTIVE_COLOR_NAME: '设置被选中图片的边框色', + // >>>HOTKEYS_SETTINGS: + HOTKEY_SETTINGS: "快捷键设置:", + HOTKEY_SETTINGS_DESC: "📢 你无法为'移动图片'和'切换图片'设置相同的快捷键。(不支持贴图模式)", + MOVE_THE_IMAGE_NAME: "为移动图片设置快捷键", + MOVE_THE_IMAGE_DESC: "你可以利用快捷键来移动弹出层上的图片。", + SWITCH_THE_IMAGE_NAME: "为切换图片设置快捷键", + SWITCH_THE_IMAGE_DESC: "你可以利用快捷键来切换在图片导航栏上的图片至上一张/下一张。(注意: 仅当开启“展示图片导航”后,才能使用该快捷键来控制切换图片。)", + DOUBLE_CLICK_TOOLBAR_NAME: "双击", + VIEW_TRIGGER_HOTKEY_NAME: "为触发弹出查看图片设置快捷键", + VIEW_TRIGGER_HOTKEY_DESC: "当你设置为“无”,你可以直接点击预览图片;否则,须按住已配置的修改键(Ctrl、Alt、Shift)才能点击查看某个图片。", + // MODIFIER_HOTKEYS + NONE: "无", + // toolbar icon title + ZOOM_TO_100: "缩放至100%", + ZOOM_IN: "放大", + ZOOM_OUT: "缩小", + FULL_SCREEN: "全屏", + REFRESH: "刷新", + ROTATE_LEFT: "左旋", + ROTATE_RIGHT: "右旋", + SCALE_X: 'x轴翻转', + SCALE_Y: 'y轴翻转', + INVERT_COLOR: '反色', + COPY: '复制', + CLOSE: '关闭', + // tip: + COPY_IMAGE_SUCCESS: '拷贝图片成功!', + COPY_IMAGE_ERROR: '拷贝图片失败!' +}; + +// 繁體中文 +var zhTW = { + // settings + IMAGE_TOOLKIT_SETTINGS_TITLE: "image toolkit 設定", + // toolbar icon title + ZOOM_IN: "放大", + ZOOM_OUT: "縮小", + FULL_SCREEN: '全螢幕', + REFRESH: "重整", + ROTATE_LEFT: "向左旋轉", + ROTATE_RIGHT: "向右旋轉", + SCALE_X: 'x 軸縮放', + SCALE_Y: 'y 軸縮放', + INVERT_COLOR: '色彩反轉', + COPY: '複製', + COPY_IMAGE_SUCCESS: '成功複製圖片!' +}; + +const localeMap = { + ar, + cs: cz, + da, + de, + en, + "en-gb": enGB, + es, + fr, + hi, + id, + it, + ja, + ko, + nl, + nn: no, + pl, + pt, + "pt-br": ptBR, + ro, + ru, + tr, + "zh-cn": zhCN, + "zh-tw": zhTW, +}; +const locale = localeMap[obsidian.moment.locale()]; +function t(str) { + if (!locale) { + console.error("Error: Image toolkit locale not found", obsidian.moment.locale()); + } + return (locale && locale[str]) || en[str]; +} + +const ZOOM_FACTOR = 0.8; +const IMG_VIEW_MIN = 30; +const ICONS = [{ + id: 'zoom-to-100', + svg: ` 1:1 ` + }]; +const SEPARATOR_SYMBOL = "---"; +const TOOLBAR_CONF = [{ + title: "ZOOM_TO_100", + class: 'toolbar_zoom_to_100', + icon: 'zoom-to-100', + enableToolbarIcon: true, + enableMenu: true, + enableHotKey: true + }, { + title: "ZOOM_IN", + class: 'toolbar_zoom_in', + icon: 'zoom-in', + enableToolbarIcon: true, + enableMenu: false, + enableHotKey: true + }, { + title: "ZOOM_OUT", + class: 'toolbar_zoom_out', + icon: 'zoom-out', + enableToolbarIcon: true, + enableMenu: false, + enableHotKey: true + }, { + title: "FULL_SCREEN", + class: 'toolbar_full_screen', + icon: 'expand', + enableToolbarIcon: true, + enableMenu: true, + enableHotKey: true + }, { + title: "REFRESH", + class: 'toolbar_refresh', + icon: 'refresh-ccw', + enableToolbarIcon: true, + enableMenu: true, + enableHotKey: true + }, { + title: "ROTATE_LEFT", + class: 'toolbar_rotate_left', + icon: 'rotate-ccw', + enableToolbarIcon: true, + enableMenu: true, + enableHotKey: true + }, { + title: "ROTATE_RIGHT", + class: 'toolbar_rotate_right', + icon: 'rotate-cw', + enableToolbarIcon: true, + enableMenu: true, + enableHotKey: true + }, { + title: "SCALE_X", + class: 'toolbar_scale_x', + icon: 'move-horizontal', + enableToolbarIcon: true, + enableMenu: true, + enableHotKey: true + }, { + title: "SCALE_Y", + class: 'toolbar_scale_y', + icon: 'move-vertical', + enableToolbarIcon: true, + enableMenu: true, + enableHotKey: true + }, { + title: "INVERT_COLOR", + class: 'toolbar_invert_color', + icon: 'droplet', + enableToolbarIcon: true, + enableMenu: true, + enableHotKey: true + }, { + title: "COPY", + class: 'toolbar_copy', + icon: 'copy', + enableToolbarIcon: true, + enableMenu: true, + enableHotKey: true + }, { + title: SEPARATOR_SYMBOL, + enableToolbarIcon: false, + enableMenu: true, + enableHotKey: false + }, { + title: "CLOSE", + class: 'toolbar_close', + icon: 'trash', + enableToolbarIcon: false, + enableMenu: true, + enableHotKey: true + }]; +const IMG_FULL_SCREEN_MODE = { + FIT: 'FIT', + FILL: 'FILL', + STRETCH: 'STRETCH' +}; +const VIEW_IMG_SELECTOR = { + EDITOR_AREAS: `.workspace-leaf-content[data-type='markdown'] img,.workspace-leaf-content[data-type='image'] img`, + EDITOR_AREAS_NO_LINK: `.workspace-leaf-content[data-type='markdown'] img:not(a img),.workspace-leaf-content[data-type='image'] img:not(a img)`, + CPB: `.community-plugin-readme img`, + CPB_NO_LINK: `.community-plugin-readme img:not(a img)`, + OTHER: `#sr-flashcard-view img`, + OTHER_NO_LINK: `#sr-flashcard-view img:not(a img)`, +}; +const IMG_BORDER_WIDTH = { + THIN: 'thin', + MEDIUM: 'medium', + THICK: 'thick' +}; +const IMG_BORDER_STYLE = { + // HIDDEN: 'hidden', + DOTTED: 'dotted', + DASHED: 'dashed', + SOLID: 'solid', + DOUBLE: 'double', + GROOVE: 'groove', + RIDGE: 'ridge', + INSET: 'inset', + OUTSET: 'outset' +}; +// https://www.runoob.com/cssref/css-colorsfull.html +const IMG_BORDER_COLOR = { + BLACK: 'black', + BLUE: 'blue', + DARK_GREEN: 'darkgreen', + GREEN: 'green', + LIME: 'lime', + STEEL_BLUE: 'steelblue', + INDIGO: 'indigo', + PURPLE: 'purple', + GRAY: 'gray', + DARK_RED: 'darkred', + LIGHT_GREEN: 'lightgreen', + BROWN: 'brown', + LIGHT_BLUE: 'lightblue', + SILVER: 'silver', + RED: 'red', + PINK: 'pink', + ORANGE: 'orange', + GOLD: 'gold', + YELLOW: 'yellow' +}; +const GALLERY_NAVBAR_DEFAULT_COLOR = '#0000001A'; // rgba(0, 0, 0, 0.1) +const GALLERY_NAVBAR_HOVER_COLOR = '#0000004D'; // rgba(0, 0, 0, 0.3) +const GALLERY_IMG_BORDER_ACTIVE_COLOR = '#FF0000'; // red +const MODIFIER_HOTKEYS = { + NONE: "NONE", + CTRL: "CTRL", + ALT: "ALT", + SHIFT: "SHIFT", + CTRL_ALT: "CTRL_ALT", + CTRL_SHIFT: "CTRL_SHIFT", + SHIFT_ALT: "SHIFT_ALT", + CTRL_SHIFT_ALT: "CTRL_SHIFT_ALT" +}; +const MOVE_THE_IMAGE = { + CODE: "MOVE_THE_IMAGE", + DEFAULT_HOTKEY: MODIFIER_HOTKEYS.NONE, + SVG: `` +}; +const SWITCH_THE_IMAGE = { + CODE: "SWITCH_THE_IMAGE", + DEFAULT_HOTKEY: MODIFIER_HOTKEYS.CTRL, + SVG: `` +}; +const IMG_DEFAULT_BACKGROUND_COLOR = '#00000000'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + var f = n.default; + if (typeof f == "function") { + var a = function () { + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var pickr_min = {exports: {}}; + +/*! Pickr 1.9.0 MIT | https://github.com/Simonwep/pickr */ + +(function (module, exports) { + !function(t,e){module.exports=e();}(self,(()=>(()=>{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:()=>E});var o={};function n(t,e,o,n,i={}){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=(t,n={})=>{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),ot)){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:u,max:h,floor:d,round:m}=Math;function f(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 v(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 b(t,e,o){const n=u(t/=255,e/=255,o/=255),i=h(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 y(t,e,o,n){e/=100,o/=100;return [...b(255*(1-u(1,(t/=100)*(1-(n/=100))+n)),255*(1-u(1,e*(1-n)+n)),255*(1-u(1,o*(1-n)+n)))]}function g(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 _(t){return b(...t.match(/.{2}/g).map((t=>parseInt(t,16))))}function w(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?\D+([\d.]+)(%?)\D+([\d.]+)(%?)\D+([\d.]+)(%?)\D*?(([\d.]+)(%?)|$)/i,hsla:/^hsla?\D+([\d.]+)\D+([\d.]+)\D+([\d.]+)\D*?(([\d.]+)(%?)|$)/i,hsva:/^hsva?\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))switch(i){case"cmyk":{const[,t,e,s,r]=o(n);if(t>100||e>100||s>100||r>100)break t;return {values:y(t,e,s,r),type:i}}case"rgba":{let[,t,,e,,s,,,r]=o(n);if(t="%"===n[2]?t/100*255:t,e="%"===n[4]?e/100*255:e,s="%"===n[6]?s/100*255:s,r="%"===n[9]?r/100:r,t>255||e>255||s>255||r<0||r>1)break t;return {values:[...b(t,e,s),r],a:r,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:[..._(e),o],a:o,type:i}}case"hsla":{let[,t,e,s,,r]=o(n);if(r="%"===n[6]?r/100:r,t>360||e>100||s>100||r<0||r>1)break t;return {values:[...g(t,e,s),r],a:r,type:i}}case"hsva":{let[,t,e,s,,r]=o(n);if(r="%"===n[6]?r/100:r,t>360||e>100||s>100||r<0||r>1)break t;return {values:[t,e,s,r],a:r,type:i}}}return {values:null,type:null}}function A(t=0,e=0,o=0,n=1){const i=(t,e)=>(o=-1)=>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=[...v(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=[...f(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=function(t,e,o){const n=f(t,e,o),i=n[0]/255,s=n[1]/255,r=n[2]/255,a=u(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]}(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=function(t,e,o){return f(t,e,o).map((t=>m(t).toString(16).padStart(2,"0")))}(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:()=>A(s.h,s.s,s.v,s.a)};return s}const $=t=>Math.max(Math.min(t,1),0);function C(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($(e.cache.x+.01*n),$(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=$(l/a.width),u=$(c/a.height);switch(i){case"v":return o.onchange(p);case"h":return o.onchange(u);default:return o.onchange(p,u)}},_tapstop(){e.options.onstop(),s(document,["mouseup","touchend","touchcancel"],e._tapstop),s(document,["mousemove","touchmove"],e._tapmove);},trigger(){e._tapmove();},update(t=0,o=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 k(t={}){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 S={variantFlipOrder:{start:"sme",middle:"mse",end:"ems"},positionFlipOrder:{top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},position:"bottom",margin:8,padding:0},O=(t,e,o)=>{const n="object"!=typeof t||t instanceof HTMLElement?{reference:t,popper:e,...o}:t;return {update(t=n){const{reference:e,popper:o}=Object.assign(n,t);if(!o||!e)throw new Error("Popper- or reference-element missing.");return ((t,e,o)=>{const{container:n,arrow:i,margin:s,padding:r,position:a,variantFlipOrder:l,positionFlipOrder:c}={container:document.documentElement.getBoundingClientRect(),...S,...o},{left:p,top:u}=e.style;e.style.left="0",e.style.top="0";const h=t.getBoundingClientRect(),d=e.getBoundingClientRect(),m={t:h.top-d.height-s,b:h.bottom+s,r:h.right+s,l:h.left-d.width-s},f={vs:h.left,vm:h.left+h.width/2-d.width/2,ve:h.left+h.width-d.width,hs:h.top,hm:h.bottom-h.height/2-d.height/2,he:h.bottom-d.height},[v,b="middle"]=a.split("-"),y=c[v],g=l[b],{top:_,left:w,bottom:A,right:$}=n;for(const t of y){const o="t"===t||"b"===t;let n=m[t];const[s,a]=o?["top","left"]:["left","top"],[l,c]=o?[d.height,d.width]:[d.width,d.height],[p,u]=o?[A,$]:[$,A],[v,b]=o?[_,w]:[w,_];if(!(np))for(const p of g){let m=f[(o?"v":"h")+p];if(!(mu)){if(m-=d[a],n-=d[s],e.style[a]=`${m}px`,e.style[s]=`${n}px`,i){const t=o?h.width/2:h.height/2,e=2*tthis.addSwatch(t)));const{button:u,app:h}=this._root;this._nanopop=O(u,h,{margin:r}),u.setAttribute("role","button"),u.setAttribute("aria-label",this._t("btn:toggle"));const d=this;this._setupAnimationFrame=requestAnimationFrame((function e(){if(!h.offsetWidth)return 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");}));}static create=t=>new E(t);_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 `),u=p.interaction;return u.options.find((t=>!t.hidden&&!t.classList.add("active"))),u.type=()=>u.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:C({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 u=i.toHEXA().toString();for(const{el:e,color:o}of t._swatchColors)e.classList[u===o.toHEXA().toString()?"add":"remove"]("pcr-active");c.style.setProperty("--pcr-color",p);}}),hue:C({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:C({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:k({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(t=!1){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}=w(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]||E.I18N_DEFAULTS[t]}_emit(t,...e){this._eventListener[t].forEach((t=>t(...e,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=A(...e),s=r(`