blocks inside this element; for each one, look for things of the form `= ...`.
+ let codeblocks = el.querySelectorAll("code");
+ for (let index = 0; index < codeblocks.length; index++) {
+ let codeblock = codeblocks.item(index);
+ // Skip code inside of pre elements if not explicitly enabled.
+ if (codeblock.parentElement &&
+ codeblock.parentElement.nodeName.toLowerCase() == "pre" &&
+ !this.settings.inlineQueriesInCodeblocks)
+ continue;
+ let text = codeblock.innerText.trim();
+ if (this.settings.inlineJsQueryPrefix.length > 0 && text.startsWith(this.settings.inlineJsQueryPrefix)) {
+ let code = text.substring(this.settings.inlineJsQueryPrefix.length).trim();
+ if (code.length == 0)
+ continue;
+ component.addChild(new DataviewInlineJSRenderer(this.api, code, el, codeblock, sourcePath));
+ }
+ else if (this.settings.inlineQueryPrefix.length > 0 && text.startsWith(this.settings.inlineQueryPrefix)) {
+ let potentialField = text.substring(this.settings.inlineQueryPrefix.length).trim();
+ if (potentialField.length == 0)
+ continue;
+ let field = tryOrPropagate(() => parseField(potentialField));
+ if (!field.successful) {
+ let errorBlock = el.createEl("div");
+ renderErrorPre(errorBlock, `Dataview (inline field '${potentialField}'): ${field.error}`);
+ }
+ else {
+ let fieldValue = field.value;
+ component.addChild(new DataviewInlineRenderer(fieldValue, text, el, codeblock, this.index, sourcePath, this.settings, this.app));
+ }
+ }
+ }
+ }
+ /** Update plugin settings. */
+ async updateSettings(settings) {
+ Object.assign(this.settings, settings);
+ this.updateRefreshSettings();
+ await this.saveData(this.settings);
+ }
+ /** @deprecated Call the given callback when the dataview API has initialized. */
+ withApi(callback) {
+ callback(this.api);
+ }
+ /**
+ * Create an API element localized to the given path, with lifecycle management managed by the given component.
+ * The API will output results to the given HTML element.
+ */
+ localApi(path, component, el) {
+ return new DataviewInlineApi(this.api, component, el, path);
+ }
+}
+/** All of the dataview settings in a single, nice tab. */
+class GeneralSettingsTab extends obsidian.PluginSettingTab {
+ plugin;
+ constructor(app, plugin) {
+ super(app, plugin);
+ this.plugin = plugin;
+ }
+ display() {
+ this.containerEl.empty();
+ new obsidian.Setting(this.containerEl)
+ .setName("Enable inline queries")
+ .setDesc("Enable or disable executing regular inline Dataview queries.")
+ .addToggle(toggle => toggle
+ .setValue(this.plugin.settings.enableInlineDataview)
+ .onChange(async (value) => await this.plugin.updateSettings({ enableInlineDataview: value })));
+ new obsidian.Setting(this.containerEl)
+ .setName("Enable JavaScript queries")
+ .setDesc("Enable or disable executing DataviewJS queries.")
+ .addToggle(toggle => toggle
+ .setValue(this.plugin.settings.enableDataviewJs)
+ .onChange(async (value) => await this.plugin.updateSettings({ enableDataviewJs: value })));
+ new obsidian.Setting(this.containerEl)
+ .setName("Enable inline JavaScript queries")
+ .setDesc("Enable or disable executing inline DataviewJS queries. Requires that DataviewJS queries are enabled.")
+ .addToggle(toggle => toggle
+ .setValue(this.plugin.settings.enableInlineDataviewJs)
+ .onChange(async (value) => await this.plugin.updateSettings({ enableInlineDataviewJs: value })));
+ new obsidian.Setting(this.containerEl)
+ .setName("Enable inline field highlighting in reading view")
+ .setDesc("Enables or disables visual highlighting / pretty rendering for inline fields in reading view.")
+ .addToggle(toggle => toggle
+ .setValue(this.plugin.settings.prettyRenderInlineFields)
+ .onChange(async (value) => await this.plugin.updateSettings({ prettyRenderInlineFields: value })));
+ new obsidian.Setting(this.containerEl)
+ .setName("Enable inline field highlighting in Live Preview")
+ .setDesc("Enables or disables visual highlighting / pretty rendering for inline fields in Live Preview.")
+ .addToggle(toggle => toggle.setValue(this.plugin.settings.prettyRenderInlineFieldsInLivePreview).onChange(async (value) => {
+ await this.plugin.updateSettings({ prettyRenderInlineFieldsInLivePreview: value });
+ this.plugin.updateEditorExtensions();
+ }));
+ new obsidian.Setting(this.containerEl).setName("Codeblocks").setHeading();
+ new obsidian.Setting(this.containerEl)
+ .setName("DataviewJS keyword")
+ .setDesc("Keyword for DataviewJS blocks. Defaults to 'dataviewjs'. Reload required for changes to take effect.")
+ .addText(text => text
+ .setPlaceholder("dataviewjs")
+ .setValue(this.plugin.settings.dataviewJsKeyword)
+ .onChange(async (value) => {
+ if (value.length == 0)
+ return;
+ this.plugin.unregisterDataviewjsCodeHighlighting();
+ await this.plugin.updateSettings({ dataviewJsKeyword: value });
+ this.plugin.registerDataviewjsCodeHighlighting();
+ }));
+ new obsidian.Setting(this.containerEl)
+ .setName("Inline query prefix")
+ .setDesc("The prefix to inline queries (to mark them as Dataview queries). Defaults to '='.")
+ .addText(text => text
+ .setPlaceholder("=")
+ .setValue(this.plugin.settings.inlineQueryPrefix)
+ .onChange(async (value) => {
+ if (value.length == 0)
+ return;
+ await this.plugin.updateSettings({ inlineQueryPrefix: value });
+ }));
+ new obsidian.Setting(this.containerEl)
+ .setName("JavaScript inline query prefix")
+ .setDesc("The prefix to JavaScript inline queries (to mark them as DataviewJS queries). Defaults to '$='.")
+ .addText(text => text
+ .setPlaceholder("$=")
+ .setValue(this.plugin.settings.inlineJsQueryPrefix)
+ .onChange(async (value) => {
+ if (value.length == 0)
+ return;
+ await this.plugin.updateSettings({ inlineJsQueryPrefix: value });
+ }));
+ new obsidian.Setting(this.containerEl)
+ .setName("Code block inline queries")
+ .setDesc("If enabled, inline queries will also be evaluated inside full code blocks.")
+ .addToggle(toggle => toggle
+ .setValue(this.plugin.settings.inlineQueriesInCodeblocks)
+ .onChange(async (value) => await this.plugin.updateSettings({ inlineQueriesInCodeblocks: value })));
+ new obsidian.Setting(this.containerEl).setName("View").setHeading();
+ new obsidian.Setting(this.containerEl)
+ .setName("Display result count")
+ .setDesc("If toggled off, the small number in the result header of TASK and TABLE queries will be hidden.")
+ .addToggle(toggle => toggle.setValue(this.plugin.settings.showResultCount).onChange(async (value) => {
+ await this.plugin.updateSettings({ showResultCount: value });
+ this.plugin.index.touch();
+ }));
+ new obsidian.Setting(this.containerEl)
+ .setName("Warn on empty result")
+ .setDesc("If set, queries which return 0 results will render a warning message.")
+ .addToggle(toggle => toggle.setValue(this.plugin.settings.warnOnEmptyResult).onChange(async (value) => {
+ await this.plugin.updateSettings({ warnOnEmptyResult: value });
+ this.plugin.index.touch();
+ }));
+ new obsidian.Setting(this.containerEl)
+ .setName("Render null as")
+ .setDesc("What null/non-existent should show up as in tables, by default. This supports Markdown notation.")
+ .addText(text => text
+ .setPlaceholder("-")
+ .setValue(this.plugin.settings.renderNullAs)
+ .onChange(async (value) => {
+ await this.plugin.updateSettings({ renderNullAs: value });
+ this.plugin.index.touch();
+ }));
+ new obsidian.Setting(this.containerEl)
+ .setName("Automatic view refreshing")
+ .setDesc("If enabled, views will automatically refresh when files in your vault change; this can negatively affect" +
+ " some functionality like embeds in views, so turn it off if such functionality is not working.")
+ .addToggle(toggle => toggle.setValue(this.plugin.settings.refreshEnabled).onChange(async (value) => {
+ await this.plugin.updateSettings({ refreshEnabled: value });
+ this.plugin.index.touch();
+ }));
+ new obsidian.Setting(this.containerEl)
+ .setName("Refresh interval")
+ .setDesc("How long to wait (in milliseconds) for files to stop changing before updating views.")
+ .addText(text => text
+ .setPlaceholder("500")
+ .setValue("" + this.plugin.settings.refreshInterval)
+ .onChange(async (value) => {
+ let parsed = parseInt(value);
+ if (isNaN(parsed))
+ return;
+ parsed = parsed < 100 ? 100 : parsed;
+ await this.plugin.updateSettings({ refreshInterval: parsed });
+ }));
+ let dformat = new obsidian.Setting(this.containerEl)
+ .setName("Date format")
+ .setDesc("The default date format (see Luxon date format options)." +
+ " Currently: " +
+ DateTime.now().toFormat(this.plugin.settings.defaultDateFormat, { locale: currentLocale() }))
+ .addText(text => text
+ .setPlaceholder(DEFAULT_QUERY_SETTINGS.defaultDateFormat)
+ .setValue(this.plugin.settings.defaultDateFormat)
+ .onChange(async (value) => {
+ dformat.setDesc("The default date format (see Luxon date format options)." +
+ " Currently: " +
+ DateTime.now().toFormat(value, { locale: currentLocale() }));
+ await this.plugin.updateSettings({ defaultDateFormat: value });
+ this.plugin.index.touch();
+ }));
+ let dtformat = new obsidian.Setting(this.containerEl)
+ .setName("Date + time format")
+ .setDesc("The default date and time format (see Luxon date format options)." +
+ " Currently: " +
+ DateTime.now().toFormat(this.plugin.settings.defaultDateTimeFormat, { locale: currentLocale() }))
+ .addText(text => text
+ .setPlaceholder(DEFAULT_QUERY_SETTINGS.defaultDateTimeFormat)
+ .setValue(this.plugin.settings.defaultDateTimeFormat)
+ .onChange(async (value) => {
+ dtformat.setDesc("The default date and time format (see Luxon date format options)." +
+ " Currently: " +
+ DateTime.now().toFormat(value, { locale: currentLocale() }));
+ await this.plugin.updateSettings({ defaultDateTimeFormat: value });
+ this.plugin.index.touch();
+ }));
+ new obsidian.Setting(this.containerEl).setName("Tables").setHeading();
+ new obsidian.Setting(this.containerEl)
+ .setName("Primary column name")
+ .setDesc("The name of the default ID column in tables; this is the auto-generated first column that links to the source file.")
+ .addText(text => text
+ .setPlaceholder("File")
+ .setValue(this.plugin.settings.tableIdColumnName)
+ .onChange(async (value) => {
+ await this.plugin.updateSettings({ tableIdColumnName: value });
+ this.plugin.index.touch();
+ }));
+ new obsidian.Setting(this.containerEl)
+ .setName("Grouped column name")
+ .setDesc("The name of the default ID column in tables, when the table is on grouped data; this is the auto-generated first column" +
+ "that links to the source file/group.")
+ .addText(text => text
+ .setPlaceholder("Group")
+ .setValue(this.plugin.settings.tableGroupColumnName)
+ .onChange(async (value) => {
+ await this.plugin.updateSettings({ tableGroupColumnName: value });
+ this.plugin.index.touch();
+ }));
+ new obsidian.Setting(this.containerEl).setName("Tasks").setHeading();
+ let taskCompletionSubsettingsEnabled = this.plugin.settings.taskCompletionTracking;
+ let taskCompletionInlineSubsettingsEnabled = taskCompletionSubsettingsEnabled && !this.plugin.settings.taskCompletionUseEmojiShorthand;
+ new obsidian.Setting(this.containerEl)
+ .setName("Automatic task completion tracking")
+ .setDesc(createFragment(el => {
+ el.appendText("If enabled, Dataview will automatically append tasks with their completion date when they are checked in Dataview views.");
+ el.createEl("br");
+ el.appendText("Example with default field name and date format: - [x] my task [completion:: 2022-01-01]");
+ }))
+ .addToggle(toggle => toggle.setValue(this.plugin.settings.taskCompletionTracking).onChange(async (value) => {
+ await this.plugin.updateSettings({ taskCompletionTracking: value });
+ taskCompletionSubsettingsEnabled = value;
+ this.display();
+ }));
+ let taskEmojiShorthand = new obsidian.Setting(this.containerEl)
+ .setName("Use emoji shorthand for completion")
+ .setDisabled(!taskCompletionSubsettingsEnabled);
+ if (taskCompletionSubsettingsEnabled)
+ taskEmojiShorthand
+ .setDesc(createFragment(el => {
+ el.appendText('If enabled, will use emoji shorthand instead of inline field formatting to fill out implicit task field "completion".');
+ el.createEl("br");
+ el.appendText("Example: - [x] my task ✅ 2022-01-01");
+ el.createEl("br");
+ el.appendText("Disable this to customize the completion date format or field name, or to use Dataview inline field formatting.");
+ el.createEl("br");
+ el.appendText('Only available when "automatic task completion tracking" is enabled.');
+ }))
+ .addToggle(toggle => toggle.setValue(this.plugin.settings.taskCompletionUseEmojiShorthand).onChange(async (value) => {
+ await this.plugin.updateSettings({ taskCompletionUseEmojiShorthand: value });
+ taskCompletionInlineSubsettingsEnabled = taskCompletionSubsettingsEnabled && !value;
+ this.display();
+ }));
+ else
+ taskEmojiShorthand.setDesc('Only available when "automatic task completion tracking" is enabled.');
+ let taskFieldName = new obsidian.Setting(this.containerEl)
+ .setName("Completion field name")
+ .setDisabled(!taskCompletionInlineSubsettingsEnabled);
+ if (taskCompletionInlineSubsettingsEnabled)
+ taskFieldName
+ .setDesc(createFragment(el => {
+ el.appendText("Text used as inline field key for task completion date when toggling a task's checkbox in a Dataview view.");
+ el.createEl("br");
+ el.appendText('Only available when "automatic task completion tracking" is enabled and "use emoji shorthand for completion" is disabled.');
+ }))
+ .addText(text => text.setValue(this.plugin.settings.taskCompletionText).onChange(async (value) => {
+ await this.plugin.updateSettings({ taskCompletionText: value.trim() });
+ }));
+ else
+ taskFieldName.setDesc('Only available when "automatic task completion tracking" is enabled and "use emoji shorthand for completion" is disabled.');
+ let taskDtFormat = new obsidian.Setting(this.containerEl)
+ .setName("Completion date format")
+ .setDisabled(!taskCompletionInlineSubsettingsEnabled);
+ if (taskCompletionInlineSubsettingsEnabled) {
+ let descTextLines = [
+ "Date-time format for task completion date when toggling a task's checkbox in a Dataview view (see Luxon date format options).",
+ 'Only available when "automatic task completion tracking" is enabled and "use emoji shorthand for completion" is disabled.',
+ "Currently: ",
+ ];
+ taskDtFormat
+ .setDesc(createFragment(el => {
+ el.appendText(descTextLines[0]);
+ el.createEl("br");
+ el.appendText(descTextLines[1]);
+ el.createEl("br");
+ el.appendText(descTextLines[2] +
+ DateTime.now().toFormat(this.plugin.settings.taskCompletionDateFormat, {
+ locale: currentLocale(),
+ }));
+ }))
+ .addText(text => text
+ .setPlaceholder(DEFAULT_SETTINGS.taskCompletionDateFormat)
+ .setValue(this.plugin.settings.taskCompletionDateFormat)
+ .onChange(async (value) => {
+ taskDtFormat.setDesc(createFragment(el => {
+ el.appendText(descTextLines[0]);
+ el.createEl("br");
+ el.appendText(descTextLines[1]);
+ el.createEl("br");
+ el.appendText(descTextLines[2] +
+ DateTime.now().toFormat(value.trim(), { locale: currentLocale() }));
+ }));
+ await this.plugin.updateSettings({ taskCompletionDateFormat: value.trim() });
+ this.plugin.index.touch();
+ }));
+ }
+ else {
+ taskDtFormat.setDesc('Only available when "automatic task completion tracking" is enabled and "use emoji shorthand for completion" is disabled.');
+ }
+ new obsidian.Setting(this.containerEl)
+ .setName("Recursive sub-task completion")
+ // I gotta word this better :/
+ .setDesc("If enabled, completing a task in a Dataview will automatically complete its subtasks too.")
+ .addToggle(toggle => toggle
+ .setValue(this.plugin.settings.recursiveSubTaskCompletion)
+ .onChange(async (value) => await this.plugin.updateSettings({ recursiveSubTaskCompletion: value })));
+ }
+}
+
+module.exports = DataviewPlugin;
+
+
+/* nosourcemap */
\ No newline at end of file
diff --git a/.obsidian/plugins/dataview/manifest.json b/.obsidian/plugins/dataview/manifest.json
new file mode 100644
index 00000000..926b2a6d
--- /dev/null
+++ b/.obsidian/plugins/dataview/manifest.json
@@ -0,0 +1,11 @@
+{
+ "id": "dataview",
+ "name": "Dataview",
+ "version": "0.5.68",
+ "minAppVersion": "0.13.11",
+ "description": "Complex data views for the data-obsessed.",
+ "author": "Michael Brenan ",
+ "authorUrl": "https://github.com/blacksmithgu",
+ "helpUrl": "https://blacksmithgu.github.io/obsidian-dataview/",
+ "isDesktopOnly": false
+}
diff --git a/.obsidian/plugins/dataview/styles.css b/.obsidian/plugins/dataview/styles.css
new file mode 100644
index 00000000..618821aa
--- /dev/null
+++ b/.obsidian/plugins/dataview/styles.css
@@ -0,0 +1,141 @@
+.block-language-dataview {
+ overflow-y: auto;
+}
+
+/*****************/
+/** Table Views **/
+/*****************/
+
+/* List View Default Styling; rendered internally as a table. */
+.table-view-table {
+ width: 100%;
+}
+
+.table-view-table > thead > tr, .table-view-table > tbody > tr {
+ margin-top: 1em;
+ margin-bottom: 1em;
+ text-align: left;
+}
+
+.table-view-table > tbody > tr:hover {
+ background-color: var(--table-row-background-hover);
+}
+
+.table-view-table > thead > tr > th {
+ font-weight: 700;
+ font-size: larger;
+ border-top: none;
+ border-left: none;
+ border-right: none;
+ border-bottom: solid;
+
+ max-width: 100%;
+}
+
+.table-view-table > tbody > tr > td {
+ text-align: left;
+ border: none;
+ font-weight: 400;
+ max-width: 100%;
+}
+
+.table-view-table ul, .table-view-table ol {
+ margin-block-start: 0.2em !important;
+ margin-block-end: 0.2em !important;
+}
+
+/** Rendered value styling for any view. */
+.dataview-result-list-root-ul {
+ padding: 0em !important;
+ margin: 0em !important;
+}
+
+.dataview-result-list-ul {
+ margin-block-start: 0.2em !important;
+ margin-block-end: 0.2em !important;
+}
+
+/** Generic grouping styling. */
+.dataview.result-group {
+ padding-left: 8px;
+}
+
+/*******************/
+/** Inline Fields **/
+/*******************/
+
+.dataview.inline-field-key {
+ padding-left: 8px;
+ padding-right: 8px;
+ font-family: var(--font-monospace);
+ background-color: var(--background-primary-alt);
+ color: var(--nav-item-color-selected);
+}
+
+.dataview.inline-field-value {
+ padding-left: 8px;
+ padding-right: 8px;
+ font-family: var(--font-monospace);
+ background-color: var(--background-secondary-alt);
+ color: var(--nav-item-color-selected);
+}
+
+.dataview.inline-field-standalone-value {
+ padding-left: 8px;
+ padding-right: 8px;
+ font-family: var(--font-monospace);
+ background-color: var(--background-secondary-alt);
+ color: var(--nav-item-color-selected);
+}
+
+/***************/
+/** Task View **/
+/***************/
+
+.dataview.task-list-item, .dataview.task-list-basic-item {
+ margin-top: 3px;
+ margin-bottom: 3px;
+ transition: 0.4s;
+}
+
+.dataview.task-list-item:hover, .dataview.task-list-basic-item:hover {
+ background-color: var(--text-selection);
+ box-shadow: -40px 0 0 var(--text-selection);
+ cursor: pointer;
+}
+
+/*****************/
+/** Error Views **/
+/*****************/
+
+div.dataview-error-box {
+ width: 100%;
+ min-height: 150px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border: 4px dashed var(--background-secondary);
+}
+
+.dataview-error-message {
+ color: var(--text-muted);
+ text-align: center;
+}
+
+/*************************/
+/** Additional Metadata **/
+/*************************/
+
+.dataview.small-text {
+ font-size: smaller;
+ color: var(--text-muted);
+ margin-left: 3px;
+}
+
+.dataview.small-text::before {
+ content: "(";
+}
+
+.dataview.small-text::after {
+ content: ")";
+}
diff --git a/.obsidian/plugins/editing-toolbar/data.json b/.obsidian/plugins/editing-toolbar/data.json
new file mode 100644
index 00000000..dad99606
--- /dev/null
+++ b/.obsidian/plugins/editing-toolbar/data.json
@@ -0,0 +1,456 @@
+{
+ "lastVersion": "3.2.7",
+ "aestheticStyle": "default",
+ "positionStyle": "top",
+ "menuCommands": [
+ {
+ "id": "editing-toolbar:editor-undo",
+ "name": "Undo Edit",
+ "icon": "undo-glyph"
+ },
+ {
+ "id": "editing-toolbar:editor-redo",
+ "name": "Redo Edit",
+ "icon": "redo-glyph"
+ },
+ {
+ "id": "editing-toolbar:toggle-format-brush",
+ "name": "Format Brush",
+ "icon": "paintbrush"
+ },
+ {
+ "id": "editing-toolbar:format-eraser",
+ "name": "Clear Text Formatting",
+ "icon": "eraser"
+ },
+ {
+ "id": "editing-toolbar:header2-text",
+ "name": "Header 2",
+ "icon": "header-2"
+ },
+ {
+ "id": "editing-toolbar:header3-text",
+ "name": "Header 3",
+ "icon": "header-3"
+ },
+ {
+ "id": "SubmenuCommands-header",
+ "name": "submenu",
+ "icon": "header-n",
+ "SubmenuCommands": [
+ {
+ "id": "editing-toolbar:header1-text",
+ "name": "Header 1",
+ "icon": "header-1"
+ },
+ {
+ "id": "editing-toolbar:header4-text",
+ "name": "Header 4",
+ "icon": "header-4"
+ },
+ {
+ "id": "editing-toolbar:header5-text",
+ "name": "Header 5",
+ "icon": "header-5"
+ },
+ {
+ "id": "editing-toolbar:header6-text",
+ "name": "Header 6",
+ "icon": "header-6"
+ }
+ ]
+ },
+ {
+ "id": "editing-toolbar:toggle-bold",
+ "name": "Bold",
+ "icon": "bold-glyph"
+ },
+ {
+ "id": "editing-toolbar:toggle-italics",
+ "name": "Italic",
+ "icon": "italic-glyph"
+ },
+ {
+ "id": "editing-toolbar:toggle-strikethrough",
+ "name": "Strikethrough",
+ "icon": "strikethrough-glyph"
+ },
+ {
+ "id": "editing-toolbar:underline",
+ "name": "Underline",
+ "icon": "underline-glyph"
+ },
+ {
+ "id": "editing-toolbar:toggle-highlight",
+ "name": "Highlight",
+ "icon": "highlight-glyph"
+ },
+ {
+ "id": "SubmenuCommands-text-tools",
+ "name": "Text Tools",
+ "icon": "box",
+ "menuType": "dropdown",
+ "SubmenuCommands": [
+ {
+ "id": "editing-toolbar:get-plain-text",
+ "name": "Get Plain Text",
+ "icon": "lucide-file-text"
+ },
+ {
+ "id": "editing-toolbar:smart-symbols",
+ "name": "Full Half Converter",
+ "icon": "lucide-at-sign"
+ },
+ {
+ "id": "editingToolbar-Divider-Line",
+ "name": "Line Operations",
+ "icon": "vertical-split"
+ },
+ {
+ "id": "editing-toolbar:insert-blank-lines",
+ "name": "Insert Blank Lines",
+ "icon": "lucide-space"
+ },
+ {
+ "id": "editing-toolbar:remove-blank-lines",
+ "name": "Remove Blank Lines",
+ "icon": "lucide-minimize-2"
+ },
+ {
+ "id": "editing-toolbar:split-lines",
+ "name": "Split Lines",
+ "icon": "lucide-split"
+ },
+ {
+ "id": "editing-toolbar:merge-lines",
+ "name": "Merge Lines",
+ "icon": "lucide-merge"
+ },
+ {
+ "id": "editing-toolbar:dedupe-lines",
+ "name": "Dedupe Lines",
+ "icon": "lucide-filter"
+ },
+ {
+ "id": "editingToolbar-Divider-Line",
+ "name": "Text Processing",
+ "icon": "vertical-split"
+ },
+ {
+ "id": "editing-toolbar:add-wrap",
+ "name": "Add Prefix/Suffix",
+ "icon": "lucide-wrap-text"
+ },
+ {
+ "id": "editing-toolbar:number-lines",
+ "name": "Number Lines (Custom)",
+ "icon": "lucide-list-ordered"
+ },
+ {
+ "id": "editing-toolbar:remove-whitespace-trim",
+ "name": "Trim Line Ends",
+ "icon": "lucide-scissors"
+ },
+ {
+ "id": "editing-toolbar:remove-whitespace-compress",
+ "name": "Shrink Extra Spaces",
+ "icon": "lucide-minimize"
+ },
+ {
+ "id": "editing-toolbar:remove-whitespace-all",
+ "name": "Remove All Whitespace",
+ "icon": "lucide-eraser"
+ },
+ {
+ "id": "editingToolbar-Divider-Line",
+ "name": "Advanced Tools",
+ "icon": "vertical-split"
+ },
+ {
+ "id": "editing-toolbar:list-to-table",
+ "name": "List to Table",
+ "icon": "lucide-table"
+ },
+ {
+ "id": "editing-toolbar:table-to-list",
+ "name": "Table to List",
+ "icon": "lucide-list"
+ },
+ {
+ "id": "editing-toolbar:extract-between",
+ "name": "Extract Between Strings",
+ "icon": "lucide-brackets"
+ }
+ ]
+ },
+ {
+ "id": "SubmenuCommands-lucdf3en5",
+ "name": "submenu",
+ "icon": "edit",
+ "SubmenuCommands": [
+ {
+ "id": "editing-toolbar:editor-cut",
+ "name": "Cut",
+ "icon": "lucide-scissors"
+ },
+ {
+ "id": "editing-toolbar:editor-copy",
+ "name": "Copy",
+ "icon": "lucide-copy"
+ },
+ {
+ "id": "editing-toolbar:editor-paste",
+ "name": "Paste",
+ "icon": "lucide-clipboard-type"
+ },
+ {
+ "id": "editing-toolbar:editor:swap-line-down",
+ "name": "Swap Line Down",
+ "icon": "lucide-corner-right-down"
+ },
+ {
+ "id": "editing-toolbar:editor:swap-line-up",
+ "name": "Swap Line Up",
+ "icon": "lucide-corner-right-up"
+ }
+ ]
+ },
+ {
+ "id": "editing-toolbar:editor:attach-file",
+ "name": "Attach File",
+ "icon": "lucide-paperclip"
+ },
+ {
+ "id": "editing-toolbar:editor:insert-table",
+ "name": "Insert Table",
+ "icon": "lucide-table"
+ },
+ {
+ "id": "editing-toolbar:editor:cycle-list-checklist",
+ "name": "Cycle List and Checklist",
+ "icon": "check-circle"
+ },
+ {
+ "id": "SubmenuCommands-luc8efull",
+ "name": "submenu",
+ "icon": "message-square",
+ "SubmenuCommands": [
+ {
+ "id": "editing-toolbar:editor:toggle-blockquote",
+ "name": "Blockquote",
+ "icon": "lucide-text-quote"
+ },
+ {
+ "id": "editing-toolbar:insert-callout",
+ "name": "Callout",
+ "icon": "lucide-quote"
+ }
+ ]
+ },
+ {
+ "id": "SubmenuCommands-mdcmder",
+ "name": "submenu",
+ "icon": "",
+ "SubmenuCommands": [
+ {
+ "id": "editing-toolbar:superscript",
+ "name": "Superscript",
+ "icon": "superscript-glyph"
+ },
+ {
+ "id": "editing-toolbar:subscript",
+ "name": "Subscript",
+ "icon": "subscript-glyph"
+ },
+ {
+ "id": "editing-toolbar:editor:toggle-code",
+ "name": "Inline Code",
+ "icon": "code-glyph"
+ },
+ {
+ "id": "editing-toolbar:codeblock",
+ "name": "Code Block",
+ "icon": "codeblock-glyph"
+ },
+ {
+ "id": "editing-toolbar:editor:insert-wikilink",
+ "name": "Wikilink",
+ "icon": ""
+ },
+ {
+ "id": "editing-toolbar:editor:insert-embed",
+ "name": "Embed",
+ "icon": "note-glyph"
+ },
+ {
+ "id": "editing-toolbar:insert-link",
+ "name": "Link",
+ "icon": "link-glyph"
+ },
+ {
+ "id": "editing-toolbar:hrline",
+ "name": "Horizontal Divider",
+ "icon": ""
+ },
+ {
+ "id": "editing-toolbar:toggle-inline-math",
+ "name": "Inline Math",
+ "icon": "lucide-sigma"
+ },
+ {
+ "id": "editing-toolbar:editor:insert-mathblock",
+ "name": "MathBlock",
+ "icon": "lucide-sigma-square"
+ }
+ ]
+ },
+ {
+ "id": "SubmenuCommands-list",
+ "name": "submenu-list",
+ "icon": "bullet-list-glyph",
+ "SubmenuCommands": [
+ {
+ "id": "editing-toolbar:editor:toggle-checklist-status",
+ "name": "Checklist",
+ "icon": "checkbox-glyph"
+ },
+ {
+ "id": "editing-toolbar:renumber-ordered-list",
+ "name": "Renumber Ordered List",
+ "icon": "list-restart"
+ },
+ {
+ "id": "editing-toolbar:toggle-numbered-list",
+ "name": "Ordered List",
+ "icon": ""
+ },
+ {
+ "id": "editing-toolbar:toggle-bullet-list",
+ "name": "Unordered List",
+ "icon": ""
+ },
+ {
+ "id": "editing-toolbar:undent-list",
+ "name": "Unindent List",
+ "icon": ""
+ },
+ {
+ "id": "editing-toolbar:indent-list",
+ "name": "Indent list",
+ "icon": ""
+ }
+ ]
+ },
+ {
+ "id": "SubmenuCommands-aligin",
+ "name": "submenu-aligin",
+ "icon": "",
+ "SubmenuCommands": [
+ {
+ "id": "editing-toolbar:justify",
+ "name": "Justify Text",
+ "icon": ""
+ },
+ {
+ "id": "editing-toolbar:left",
+ "name": "Align Text Left",
+ "icon": ""
+ },
+ {
+ "id": "editing-toolbar:center",
+ "name": "Center Text",
+ "icon": ""
+ },
+ {
+ "id": "editing-toolbar:right",
+ "name": "Align Text Right",
+ "icon": ""
+ }
+ ]
+ },
+ {
+ "id": "editing-toolbar:change-font-color",
+ "name": "Change Font Color",
+ "icon": ""
+ },
+ {
+ "id": "editing-toolbar:change-background-color",
+ "name": "Change Background Color",
+ "icon": ""
+ },
+ {
+ "id": "editing-toolbar:fullscreen-focus",
+ "name": "Fullscreen Focus Mode",
+ "icon": "fullscreen"
+ },
+ {
+ "id": "editing-toolbar:workplace-fullscreen-focus",
+ "name": "Workplace Fullscreen",
+ "icon": "exit-fullscreen"
+ }
+ ],
+ "followingCommands": [],
+ "topCommands": [],
+ "fixedCommands": [],
+ "mobileCommands": [],
+ "enableMultipleConfig": false,
+ "enableTopToolbar": true,
+ "enableFollowingToolbar": false,
+ "enableFixedToolbar": false,
+ "appendMethod": "workspace",
+ "shouldShowMenuOnSelect": false,
+ "cMenuVisibility": true,
+ "cMenuBottomValue": 4.25,
+ "cMenuNumRows": 12,
+ "cMenuWidth": 610,
+ "cMenuFontColor": "#2DC26B",
+ "cMenuBackgroundColor": "#d3f8b6",
+ "autohide": false,
+ "Iscentered": false,
+ "custom_bg1": "#FFB78B8C",
+ "custom_bg2": "#CDF4698C",
+ "custom_bg3": "#A0CCF68C",
+ "custom_bg4": "#F0A7D88C",
+ "custom_bg5": "#ADEFEF8C",
+ "custom_fc1": "#D83931",
+ "custom_fc2": "#DE7802",
+ "custom_fc3": "#245BDB",
+ "custom_fc4": "#6425D0",
+ "custom_fc5": "#646A73",
+ "isLoadOnMobile": false,
+ "horizontalPosition": 0,
+ "verticalPosition": 0,
+ "formatBrushes": {},
+ "customCommands": [],
+ "viewTypeSettings": {},
+ "appearanceByStyle": {
+ "top": {
+ "toolbarBackgroundColor": "rgba(var(--background-secondary-rgb), 0.7)",
+ "toolbarIconColor": "var(--text-normal)",
+ "toolbarIconSize": 18,
+ "aestheticStyle": "default"
+ },
+ "following": {
+ "toolbarBackgroundColor": "rgba(var(--background-secondary-rgb), 0.7)",
+ "toolbarIconColor": "var(--text-normal)",
+ "toolbarIconSize": 18,
+ "aestheticStyle": "default"
+ },
+ "fixed": {
+ "toolbarBackgroundColor": "rgba(var(--background-secondary-rgb), 0.7)",
+ "toolbarIconColor": "var(--text-normal)",
+ "toolbarIconSize": 18,
+ "aestheticStyle": "default"
+ },
+ "mobile": {
+ "toolbarBackgroundColor": "rgba(var(--background-secondary-rgb), 0.7)",
+ "toolbarIconColor": "var(--text-normal)",
+ "toolbarIconSize": 18,
+ "aestheticStyle": "default"
+ }
+ },
+ "toolbarBackgroundColor": "rgba(var(--background-secondary-rgb), 0.7)",
+ "toolbarIconColor": "var(--text-normal)",
+ "toolbarIconSize": 18,
+ "useCurrentLineForRegex": false
+}
\ No newline at end of file
diff --git a/.obsidian/plugins/editing-toolbar/main.js b/.obsidian/plugins/editing-toolbar/main.js
new file mode 100644
index 00000000..5673a57b
--- /dev/null
+++ b/.obsidian/plugins/editing-toolbar/main.js
@@ -0,0 +1,12 @@
+"use strict";var e=require("obsidian");const t=["Custom","editingToolbar","editingToolbarSub","editingToolbarAdd","editingToolbarDelete","editingToolbarReload","codeblock-glyph","underline-glyph","superscript-glyph","subscript-glyph","bot-glyph","header-1","header-2","header-3","header-4","header-5","header-6","header-n","obsidian","obsidian-new","accessibility","activity","air-vent","airplay","alarm-check","alarm-clock-off","alarm-clock","alarm-minus","alarm-plus","album","alert-circle","alert-octagon","alert-triangle","align-center-horizontal","align-center-vertical","align-center","align-end-horizontal","align-end-vertical","align-horizontal-distribute-center","align-horizontal-distribute-end","align-horizontal-distribute-start","align-horizontal-justify-center","align-horizontal-justify-end","align-horizontal-justify-start","align-horizontal-space-around","align-horizontal-space-between","align-justify","align-left","align-right","align-start-horizontal","align-start-vertical","align-vertical-distribute-center","align-vertical-distribute-end","align-vertical-distribute-start","align-vertical-justify-center","align-vertical-justify-end","align-vertical-justify-start","align-vertical-space-around","align-vertical-space-between","anchor","angry","annoyed","aperture","apple","archive-restore","archive","armchair","arrow-big-down","arrow-big-left","arrow-big-right","arrow-big-up","arrow-down-circle","arrow-down-left","arrow-down-right","arrow-down","arrow-left-circle","arrow-left-right","arrow-left","arrow-right-circle","arrow-right","arrow-up-circle","arrow-up-left","arrow-up-right","arrow-up","asterisk","at-sign","award","axe","axis-3d","baby","backpack","baggage-claim","banana","banknote","bar-chart-2","bar-chart-3","bar-chart-4","bar-chart-horizontal","bar-chart","baseline","bath","battery-charging","battery-full","battery-low","battery-medium","battery","beaker","bed-double","bed-single","bed","beer","bell-minus","bell-off","bell-plus","bell-ring","bell","bike","binary","bitcoin","bluetooth-connected","bluetooth-off","bluetooth-searching","bluetooth","bold","bomb","bone","book-open","book","bookmark-minus","bookmark-plus","bookmark","bot","box-select","box","boxes","briefcase","brush","bug","building-2","building","bus","cake","calculator","calendar-check-2","calendar-check","calendar-clock","calendar-days","calendar-heart","calendar-minus","calendar-off","calendar-plus","calendar-range","calendar-search","calendar-x2","calendar-x","calendar","camera-off","camera","car","carrot","cast","check-circle-2","check-circle","check-square","check","chef-hat","cherry","chevron-down","chevron-first","chevron-last","chevron-left","chevron-right","chevron-up","chevrons-down-up","chevrons-down","chevrons-left-right","chevrons-left","chevrons-right-left","chevrons-right","chevrons-up-down","chevrons-up","chrome","cigarette-off","cigarette","circle-dot","circle-ellipsis","circle-slashed","circle","citrus","clapperboard","clipboard-check","clipboard-copy","clipboard-edit","clipboard-list","clipboard-signature","clipboard-type","clipboard-x","clipboard","clock-1","clock-10","clock-11","clock-12","clock-2","clock-3","clock-4","clock-5","clock-6","clock-7","clock-8","clock-9","clock","cloud-cog","cloud-drizzle","cloud-fog","cloud-hail","cloud-lightning","cloud-moon-rain","cloud-moon","cloud-off","cloud-rain-wind","cloud-rain","cloud-snow","cloud-sun-rain","cloud-sun","cloud","cloudy","clover","code-2","code","codepen","codesandbox","coffee","cog","coins","columns","command","compass","component","contact","contrast","cookie","copy","copyleft","copyright","corner-down-left","corner-down-right","corner-left-down","corner-left-up","corner-right-down","corner-right-up","corner-up-left","corner-up-right","cpu","credit-card","croissant","crop","cross","crosshair","crown","cup-soda","curly-braces","currency","database","delete","diamond","dice-1","dice-2","dice-3","dice-4","dice-5","dice-6","dices","diff","disc","divide-circle","divide-square","divide","dollar-sign","download-cloud","download","dribbble","droplet","droplets","drumstick","edit-2","edit-3","edit","egg-fried","egg","equal-not","equal","eraser","euro","expand","external-link","eye-off","eye","facebook","factory","fast-forward","feather","figma","file-archive","file-audio-2","file-audio","file-axis-3d","file-badge-2","file-badge","file-bar-chart-2","file-bar-chart","file-box","file-check-2","file-check","file-clock","file-code","file-cog-2","file-cog","file-diff","file-digit","file-down","file-edit","file-heart","file-image","file-input","file-json-2","file-json","file-key-2","file-key","file-line-chart","file-lock-2","file-lock","file-minus-2","file-minus","file-output","file-pie-chart","file-plus-2","file-plus","file-question","file-scan","file-search-2","file-search","file-signature","file-spreadsheet","file-symlink","file-terminal","file-text","file-type-2","file-type","file-up","file-video-2","file-video","file-volume-2","file-volume","file-warning","file-x2","file-x","file","files","film","filter","fingerprint","flag-off","flag-triangle-left","flag-triangle-right","flag","flame","flashlight-off","flashlight","flask-conical","flask-round","flip-horizontal-2","flip-horizontal","flip-vertical-2","flip-vertical","flower-2","flower","focus","folder-archive","folder-check","folder-clock","folder-closed","folder-cog-2","folder-cog","folder-down","folder-edit","folder-heart","folder-input","folder-key","folder-lock","folder-minus","folder-open","folder-output","folder-plus","folder-search-2","folder-search","folder-symlink","folder-tree","folder-up","folder-x","folder","folders","form-input","forward","frame","framer","frown","fuel","function-square","gamepad-2","gamepad","gauge","gavel","gem","ghost","gift","git-branch-plus","git-branch","git-commit","git-compare","git-fork","git-merge","git-pull-request-closed","git-pull-request-draft","git-pull-request","github","gitlab","glass-water","glasses","globe-2","globe","grab","graduation-cap","grape","grid","grip-horizontal","grip-vertical","hammer","hand-metal","hand","hard-drive","hard-hat","hash","haze","headphones","heart-crack","heart-handshake","heart-off","heart-pulse","heart","help-circle","hexagon","highlighter","history","home","hourglass","ice-cream","image-minus","image-off","image-plus","image","import","inbox","indent","indian-rupee","infinity","info","inspect","instagram","italic","japanese-yen","joystick","key","keyboard","lamp-ceiling","lamp-desk","lamp-floor","lamp-wall-down","lamp-wall-up","lamp","landmark","languages","laptop-2","laptop","lasso-select","lasso","laugh","layers","layout-dashboard","layout-grid","layout-list","layout-template","layout","leaf","library","life-buoy","lightbulb-off","lightbulb","line-chart","link-2off","link-2","link","linkedin","list-checks","list-end","list-minus","list-music","list-ordered","list-plus","list-start","list-video","list-x","list","loader-2","loader","locate-fixed","locate-off","locate","lock","log-in","log-out","luggage","magnet","mail-check","mail-minus","mail-open","mail-plus","mail-question","mail-search","mail-warning","mail-x","mail","mails","map-pin-off","map-pin","map","martini","maximize-2","maximize","medal","megaphone-off","megaphone","meh","menu","message-circle","message-square","mic-2","mic-off","mic","microscope","milestone","minimize-2","minimize","minus-circle","minus-square","minus","monitor-off","monitor-speaker","monitor","moon","more-horizontal","more-vertical","mountain-snow","mountain","mouse-pointer-2","mouse-pointer-click","mouse-pointer","mouse","move-3d","move-diagonal-2","move-diagonal","move-horizontal","move-vertical","move","music-2","music-3","music-4","music","navigation-2off","navigation-2","navigation-off","navigation","network","newspaper","octagon","option","outdent","package-2","package-check","package-minus","package-open","package-plus","package-search","package-x","package","paint-bucket","paintbrush-2","paintbrush","palette","palmtree","paperclip","party-popper","pause-circle","pause-octagon","pause","pen-tool","pencil","percent","person-standing","phone-call","phone-forwarded","phone-incoming","phone-missed","phone-off","phone-outgoing","phone","pie-chart","piggy-bank","pin-off","pin","pipette","pizza","plane","play-circle","play","plug-zap","plus-circle","plus-square","plus","pocket","podcast","pointer","pound-sterling","power-off","power","printer","puzzle","qr-code","quote","radio-receiver","radio","recycle","redo-2","redo","refresh-ccw","refresh-cw","regex","repeat-1","repeat","reply-all","reply","rewind","rocket","rocking-chair","rotate-3d","rotate-ccw","rotate-cw","rss","ruler","russian-ruble","save","scale-3d","scale","scaling","scan-face","scan-line","scan","scissors","screen-share-off","screen-share","scroll","search","send","separator-horizontal","separator-vertical","server-cog","server-crash","server-off","server","settings-2","settings","share-2","share","sheet","shield-alert","shield-check","shield-close","shield-off","shield","shirt","shopping-bag","shopping-cart","shovel","shrink","shrub","shuffle","sidebar-close","sidebar-open","sidebar","sigma","signal-high","signal-low","signal-medium","signal-zero","signal","siren","skip-back","skip-forward","skull","slack","slash","slice","sliders-horizontal","sliders","smartphone-charging","smartphone","smile-plus","smile","snowflake","sofa","sort-asc","sort-desc","speaker","sprout","square","star-half","star-off","star","stethoscope","sticker","sticky-note","stop-circle","stretch-horizontal","stretch-vertical","strikethrough","subscript","sun-dim","sun-medium","sun-moon","sun-snow","sun","sunrise","sunset","superscript","swiss-franc","switch-camera","sword","swords","syringe","table-2","table","tablet","tag","tags","target","tent","terminal-square","terminal","text-cursor-input","text-cursor","thermometer-snowflake","thermometer-sun","thermometer","thumbs-down","thumbs-up","ticket","timer-off","timer-reset","timer","toggle-left","toggle-right","tornado","toy-brick","train","trash-2","trash","tree-deciduous","tree-pine","trees","trello","trending-down","trending-up","triangle","trophy","truck","tv-2","tv","twitch","twitter","type","umbrella","underline","undo-2","undo","unlink-2","unlink","unlock","upload-cloud","upload","usb","user-check","user-cog","user-minus","user-plus","user-x","user","users","utensils-crossed","utensils","venetian-mask","verified","vibrate-off","vibrate","video-off","video","view","voicemail","volume-1","volume-2","volume-x","volume","wallet","wand-2","wand","watch","waves","webcam","webhook","wifi-off","wifi","wind","wine","wrap-text","wrench","x-circle","x-octagon","x-square","x","youtube","zap-off","zap","zoom-in","zoom-out","create-new","trash","search","right-triangle","document","folder","pencil","left-arrow","right-arrow","three-horizontal-bars","dot-network","audio-file","image-file","pdf-file","gear","documents","blocks","go-to-file","presentation","cross-in-box","microphone","microphone-filled","two-columns","link","popup-open","checkmark","hashtag","left-arrow-with-tail","right-arrow-with-tail","up-arrow-with-tail","down-arrow-with-tail","lines-of-text","vertical-three-dots","pin","magnifying-glass","info","horizontal-split","vertical-split","calendar-with-checkmark","folder-minus","sheets-in-box","up-and-down-arrows","broken-link","cross","any-key","reset","star","crossed-star","dice","filled-pin","enter","help","vault","open-vault","paper-plane","bullet-list","uppercase-lowercase-a","star-list","expand-vertically","languages","switch","pane-layout","install","sync","check-in-circle","sync-small","check-small","paused","forward-arrow","stacked-levels","bracket-glyph","note-glyph","tag-glyph","price-tag-glyph","heading-glyph","bold-glyph","italic-glyph","strikethrough-glyph","highlight-glyph","code-glyph","quote-glyph","link-glyph","bullet-list-glyph","number-list-glyph","checkbox-glyph","undo-glyph","redo-glyph","up-chevron-glyph","down-chevron-glyph","left-chevron-glyph","right-chevron-glyph","percent-sign-glyph","keyboard-glyph","double-up-arrow-glyph","double-down-arrow-glyph","image-glyph","wrench-screwdriver-glyph","clock","plus-with-circle","minus-with-circle","indent-glyph","unindent-glyph","fullscreen","exit-fullscreen","cloud","run-command","compress-glyph","enlarge-glyph","scissors-glyph","up-curly-arrow-glyph","down-curly-arrow-glyph","plus-minus-glyph","links-going-out","links-coming-in","add-note-glyph","duplicate-glyph","clock-glyph","calendar-glyph","command-glyph","dice-glyph","file-explorer-glyph","graph-glyph","import-glyph","navigate-glyph","open-elsewhere-glyph","presentation-glyph","paper-plane-glyph","question-mark-glyph","restore-file-glyph","search-glyph","star-glyph","play-audio-glyph","stop-audio-glyph","tomorrow-glyph","wand-glyph","workspace-glyph","yesterday-glyph","box-glyph","merge-files-glyph","merge-files","two-blank-pages","scissors","paste","paste-text","split","select-all-text","wand","github-glyph","reading-glasses","user-manual-filled","discord-filled","chat-bubbles-filled","experiment-filled","bracket-glyph","box-glyph","check-small","dice-glyph","dice","discord","right-triangle","heading-glyph","help","keyboard-toggle","broken-link","experiment","left-arrow","link","link-glyph","links-coming-in","links-going-out","open-vault","paused","question-mark-glyph","right-arrow","sidebar-left","sidebar-right","sheets-in-box","star-list","sync-small","tabs","uppercase-lowercase-a","vault","stack-horizontal","stack-vertical","stretch-horizontal","stretch-vertical","distribute-space-horizontal","distribute-space-vertical"],i=1024;let o=0;class n{constructor(e,t){this.from=e,this.to=t}}class s{constructor(e={}){this.id=o++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=l.match(e)),t=>{let i=e(t);return void 0===i?null:[this,i]}}}s.closedBy=new s({deserialize:e=>e.split(" ")}),s.openedBy=new s({deserialize:e=>e.split(" ")}),s.group=new s({deserialize:e=>e.split(" ")}),s.isolate=new s({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),s.contextHash=new s({perNode:!0}),s.lookAhead=new s({perNode:!0}),s.mounted=new s({perNode:!0});class r{constructor(e,t,i,o=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=o}static get(e){return e&&e.props&&e.props[s.mounted.id]}}const a=Object.create(null);class l{constructor(e,t,i,o=0){this.name=e,this.props=t,this.id=i,this.flags=o}static define(e){let t=e.props&&e.props.length?Object.create(null):a,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),o=new l(e.name||"",t,e.id,i);if(e.props)for(let i of e.props)if(Array.isArray(i)||(i=i(o)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}return o}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(s.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let o of i.split(" "))t[o]=e[i];return e=>{for(let i=e.prop(s.group),o=-1;o<(i?i.length:0);o++){let n=t[o<0?e.name:i[o]];if(n)return n}}}}l.none=new l("",Object.create(null),0,8);const c=new WeakMap,d=new WeakMap;var h;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"}(h||(h={}));class u{constructor(e,t,i,o,n){if(this.type=e,this.children=t,this.positions=i,this.length=o,this.props=null,n&&n.length){this.props=Object.create(null);for(let[e,t]of n)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=r.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let i=e.toString();i&&(t&&(t+=","),t+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new T(this.topNode,e)}cursorAt(e,t=0,i=0){let o=c.get(this)||this.topNode,n=new T(o);return n.moveTo(e,t),c.set(this,n._tree),n}get topNode(){return new y(this,0,0,null)}resolve(e,t=0){let i=f(c.get(this)||this.topNode,e,t,!1);return c.set(this,i),i}resolveInner(e,t=0){let i=f(d.get(this)||this.topNode,e,t,!0);return d.set(this,i),i}resolveStack(e,t=0){return function(e,t,i){let o=e.resolveInner(t,i),n=null;for(let e=o instanceof y?o:o.context.parent;e;e=e.parent)if(e.index<0){let s=e.parent;(n||(n=[o])).push(s.resolve(t,i)),e=s}else{let s=r.get(e.tree);if(s&&s.overlay&&s.overlay[0].from<=t&&s.overlay[s.overlay.length-1].to>=t){let r=new y(s.tree,s.overlay[0].from+e.from,-1,e);(n||(n=[o])).push(f(r,t,i,!1))}}return n?k(n):o}(this,e,t)}iterate(e){let{enter:t,leave:i,from:o=0,to:n=this.length}=e,s=e.mode||0,r=(s&h.IncludeAnonymous)>0;for(let e=this.cursor(s|h.IncludeAnonymous);;){let s=!1;if(e.from<=n&&e.to>=o&&(!r&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;s=!0}for(;s&&i&&(r||!e.type.isAnonymous)&&i(e),!e.nextSibling();){if(!e.parent())return;s=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:I(l.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,i)=>new u(this.type,e,t,i,this.propValues),e.makeTree||((e,t,i)=>new u(l.none,e,t,i)))}static build(e){return function(e){var t;let{buffer:o,nodeSet:n,maxBufferLength:r=i,reused:a=[],minRepeatType:l=n.types.length}=e,c=Array.isArray(o)?new p(o,o.length):o,d=n.types,h=0,g=0;function f(e,t,i,o,s,u){let{id:p,start:k,end:S,size:T}=c,E=g,M=h;if(T<0){if(c.next(),-1==T){let t=a[p];return i.push(t),void o.push(k-e)}if(-3==T)return void(h=p);if(-4==T)return void(g=p);throw new RangeError(`Unrecognized record size: ${T}`)}let A,D,O=d[p],B=k-e;if(S-k<=r&&(D=C(c.pos-t,s))){let t=new Uint16Array(D.size-D.skip),i=c.pos-D.size,o=t.length;for(;c.pos>i;)o=x(D.start,t,o);A=new m(t,S-D.start,n),B=D.start-e}else{let e=c.pos-T;c.next();let t=[],i=[],o=p>=l?p:-1,n=0,s=S;for(;c.pos>e;)o>=0&&c.id==o&&c.size>=0?(c.end<=s-r&&(w(t,i,k,n,c.end,s,o,E,M),n=t.length,s=c.end),c.next()):u>2500?b(k,e,t,i):f(k,e,t,i,o,u+1);if(o>=0&&n>0&&n-1&&n>0){let e=y(O,M);A=I(O,t,i,0,t.length,0,S-k,e,e)}else A=v(O,t,i,S-k,E-S,M)}i.push(A),o.push(B)}function b(e,t,i,o){let s=[],a=0,l=-1;for(;c.pos>t;){let{id:e,start:t,end:i,size:o}=c;if(o>4)c.next();else{if(l>-1&&t=0;e-=3)t[i++]=s[e],t[i++]=s[e+1]-r,t[i++]=s[e+2]-r,t[i++]=i;i.push(new m(t,s[2]-r,n)),o.push(r-e)}}function y(e,t){return(i,o,n)=>{let r,a,l=0,c=i.length-1;if(c>=0&&(r=i[c])instanceof u){if(!c&&r.type==e&&r.length==n)return r;(a=r.prop(s.lookAhead))&&(l=o[c]+r.length+a)}return v(e,i,o,n,l,t)}}function w(e,t,i,o,s,r,a,l,c){let d=[],h=[];for(;e.length>o;)d.push(e.pop()),h.push(t.pop()+i-s);e.push(v(n.types[a],d,h,r-s,l-r,c)),t.push(s-i)}function v(e,t,i,o,n,r,a){if(r){let e=[s.contextHash,r];a=a?[e].concat(a):[e]}if(n>25){let e=[s.lookAhead,n];a=a?[e].concat(a):[e]}return new u(e,t,i,o,a)}function C(e,t){let i=c.fork(),o=0,n=0,s=0,a=i.end-r,d={size:0,start:0,skip:0};e:for(let r=i.pos-e;i.pos>r;){let e=i.size;if(i.id==t&&e>=0){d.size=o,d.start=n,d.skip=s,s+=4,o+=4,i.next();continue}let c=i.pos-e;if(e<0||c=l?4:0,u=i.start;for(i.next();i.pos>c;){if(i.size<0){if(-3!=i.size&&-4!=i.size)break e;h+=4}else i.id>=l&&(h+=4);i.next()}n=u,o+=e,s+=h}return(t<0||o==e)&&(d.size=o,d.start=n,d.skip=s),d.size>4?d:void 0}function x(e,t,i){let{id:o,start:n,end:s,size:r}=c;if(c.next(),r>=0&&o4){let o=c.pos-(r-4);for(;c.pos>o;)i=x(e,t,i)}t[--i]=a,t[--i]=s-e,t[--i]=n-e,t[--i]=o}else-3==r?h=o:-4==r&&(g=o);return i}let k=[],S=[];for(;c.pos>0;)f(e.start||0,e.bufferStart||0,k,S,-1,0);let T=null!==(t=e.length)&&void 0!==t?t:k.length?S[0]+k[0].length:0;return new u(d[e.topID],k.reverse(),S.reverse(),T)}(e)}}u.empty=new u(l.none,[],[],0);class p{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new p(this.buffer,this.index)}}class m{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return l.none}toString(){let e=[];for(let t=0;t0));a=s[a+3]);return r}slice(e,t,i){let o=this.buffer,n=new Uint16Array(t-e),s=0;for(let r=e,a=0;r=t&⁢case 1:return i<=t&&o>t;case 2:return o>t;case 4:return!0}}function f(e,t,i,o){for(var n;e.from==e.to||(i<1?e.from>=t:e.from>t)||(i>-1?e.to<=t:e.to0?l.length:-1;e!=d;e+=t){let d=l[e],p=c[e]+a.from;if(n&h.EnterBracketed&&d instanceof u&&null===(null===(s=r.get(d))||void 0===s?void 0:s.overlay)&&(p>=i||p+d.length<=i)||g(o,i,p,p+d.length))if(d instanceof m){if(n&h.ExcludeBuffers)continue;let s=d.findChild(0,d.buffer.length,t,i-p,o);if(s>-1)return new x(new C(a,d,e,p),null,s)}else if(n&h.IncludeAnonymous||!d.type.isAnonymous||E(d)){let s;if(!(n&h.IgnoreMounts)&&(s=r.get(d))&&!s.overlay)return new y(s.tree,p,e,a);let l=new y(d,p,e,a);return n&h.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(t<0?d.children.length-1:0,t,i,o,n)}}if(n&h.IncludeAnonymous||!a.type.isAnonymous)return null;if(e=a.index>=0?a.index+t:t<0?-1:a._parent._tree.children.length,a=a._parent,!a)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let o;if(!(i&h.IgnoreOverlays)&&(o=r.get(this._tree))&&o.overlay){let n=e-this.from,s=i&h.EnterBracketed&&o.bracketed;for(let{from:e,to:i}of o.overlay)if((t>0||s?e<=n:e=n:i>n))return new y(o.tree,o.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function w(e,t,i,o){let n=e.cursor(),s=[];if(!n.firstChild())return s;if(null!=i)for(let e=!1;!e;)if(e=n.type.is(i),!n.nextSibling())return s;for(;;){if(null!=o&&n.type.is(o))return s;if(n.type.is(t)&&s.push(n.node),!n.nextSibling())return null==o?s:[]}}function v(e,t,i=t.length-1){for(let o=e;i>=0;o=o.parent){if(!o)return!1;if(!o.type.isAnonymous){if(t[i]&&t[i]!=o.name)return!1;i--}}return!0}class C{constructor(e,t,i,o){this.parent=e,this.buffer=t,this.index=i,this.start=o}}class x extends b{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:o}=this.context,n=o.findChild(this.index+4,o.buffer[this.index+3],e,t-this.context.start,i);return n<0?null:new x(this.context,this,n)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&h.ExcludeBuffers)return null;let{buffer:o}=this.context,n=o.findChild(this.index+4,o.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return n<0?null:new x(this.context,this,n)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new x(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new x(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,o=this.index+4,n=i.buffer[this.index+3];if(n>o){let s=i.buffer[this.index+1];e.push(i.slice(o,n,s)),t.push(0)}return new u(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function k(e){if(!e.length)return null;let t=0,i=e[0];for(let o=1;oi.from||n.to0){if(this.index-1)for(let o=t+e,n=e<0?-1:i._tree.children.length;o!=n;o+=e){let e=i._tree.children[o];if(this.mode&h.IncludeAnonymous||e instanceof m||!e.type.isAnonymous||E(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let s=e;s;s=s._parent)if(s.index==o){if(o==this.index)return s;t=s,i=n+1;break e}o=this.stack[--n]}for(let e=i;e=0;n--){if(n<0)return v(this._tree,e,o);let s=i[t.buffer[this.stack[n]]];if(!s.isAnonymous){if(e[o]&&e[o]!=s.name)return!1;o--}}return!0}}function E(e){return e.children.some(e=>e instanceof m||!e.type.isAnonymous||E(e))}const M=new WeakMap;function A(e,t){if(!e.isAnonymous||t instanceof m||t.type!=e)return 1;let i=M.get(t);if(null==i){i=1;for(let o of t.children){if(o.type!=e||!(o instanceof u)){i=1;break}i+=A(e,o)}M.set(t,i)}return i}function I(e,t,i,o,n,s,r,a,l){let c=0;for(let i=o;i=d)break;m+=t}if(c==n+1){if(m>d){let e=i[n];t(e.children,e.positions,0,e.children.length,o[n]+a);continue}h.push(i[n])}else{let t=o[c-1]+i[c-1].length-p;h.push(I(e,i,o,n,c,p,t,null,l))}u.push(p+a-s)}}(t,i,o,n,0),(a||l)(h,u,r)}class D{constructor(e,t,i,o,n=!1,s=!1){this.from=e,this.to=t,this.tree=i,this.offset=o,this.open=(n?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],i=!1){let o=[new D(0,e.length,e,0,!1,i)];for(let i of t)i.to>e.length&&o.push(i);return o}static applyChanges(e,t,i=128){if(!t.length)return e;let o=[],n=1,s=e.length?e[0]:null;for(let r=0,a=0,l=0;;r++){let c=r=i)for(;s&&s.from=t.from||d<=t.to||l){let e=Math.max(t.from,a)-l,i=Math.min(t.to,d)-l;t=e>=i?null:new D(e,i,t.tree,t.offset+l,r>0,!!c)}if(t&&o.push(t),s.to>d)break;s=nnew n(e.from,e.to)):[new n(0,0)]:[new n(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let o=this.startParse(e,t,i);for(;;){let e=o.advance();if(e)return e}}}class B{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new s({perNode:!0});let L=[],P=[];function N(e){if(e<768)return!1;for(let t=0,i=L.length;;){let o=t+i>>1;if(e=P[o]))return!0;t=o+1}if(t==i)return!1}}function R(e){return e>=127462&&e<=127487}(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let t=0,i=0;t=0&&R(z(e,o));)i++,o-=2;if(i%2==0)break;t+=2}}}return t}function _(e,t,i){for(;t>0;){let o=q(e,t-2,i);if(o=56320&&e<57344}function W(e){return e>=55296&&e<56320}function H(e){return e<65536?1:2}class ${lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Q(this,e,t);let o=[];return this.decompose(0,e,o,2),i.length&&i.decompose(0,i.length,o,3),this.decompose(t,this.length,o,1),j.from(o,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Q(this,e,t);let i=[];return this.decompose(e,t,i,0),j.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),o=new Z(this),n=new Z(e);for(let e=t,s=t;;){if(o.next(e),n.next(e),e=0,o.lineBreak!=n.lineBreak||o.done!=n.done||o.value!=n.value)return!1;if(s+=o.value.length,o.done||s>=i)return!0}}iter(e=1){return new Z(this,e)}iterRange(e,t=this.length){return new K(this,e,t)}iterLines(e,t){let i;if(null==e)i=this.iter();else{null==t&&(t=this.lines+1);let o=this.line(e).from;i=this.iterRange(o,Math.max(o,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new J(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new U(e):j.from(U.split(e,[])):$.empty}}class U extends ${constructor(e,t=function(e){let t=-1;for(let i of e)t+=i.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,o){for(let n=0;;n++){let s=this.text[n],r=o+s.length;if((t?i:r)>=e)return new X(o,r,i,s);o=r+1,i++}}decompose(e,t,i,o){let n=e<=0&&t>=this.length?this:new U(G(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&o){let e=i.pop(),t=Y(n.text,e.text.slice(),0,n.length);if(t.length<=32)i.push(new U(t,e.length+n.length));else{let e=t.length>>1;i.push(new U(t.slice(0,e)),new U(t.slice(e)))}}else i.push(n)}replace(e,t,i){if(!(i instanceof U))return super.replace(e,t,i);[e,t]=Q(this,e,t);let o=Y(this.text,Y(i.text,G(this.text,0,e)),t),n=this.length+i.length-(t-e);return o.length<=32?new U(o,n):j.from(U.split(o,[]),n)}sliceString(e,t=this.length,i="\n"){[e,t]=Q(this,e,t);let o="";for(let n=0,s=0;n<=t&&se&&s&&(o+=i),en&&(o+=r.slice(Math.max(0,e-n),t-n)),n=a+1}return o}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],o=-1;for(let n of e)i.push(n),o+=n.length+1,32==i.length&&(t.push(new U(i,o)),i=[],o=-1);return o>-1&&t.push(new U(i,o)),t}}class j extends ${constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,i,o){for(let n=0;;n++){let s=this.children[n],r=o+s.length,a=i+s.lines-1;if((t?a:r)>=e)return s.lineInner(e,t,i,o);o=r+1,i=a+1}}decompose(e,t,i,o){for(let n=0,s=0;s<=t&&n=s){let n=o&((s<=e?1:0)|(a>=t?2:0));s>=e&&a<=t&&!n?i.push(r):r.decompose(e-s,t-s,i,n)}s=a+1}}replace(e,t,i){if([e,t]=Q(this,e,t),i.lines=n&&t<=r){let a=s.replace(e-n,t-n,i),l=this.lines-s.lines+a.lines;if(a.lines>4&&a.lines>l>>6){let n=this.children.slice();return n[o]=a,new j(n,this.length-(t-e)+i.length)}return super.replace(n,r,a)}n=r+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i="\n"){[e,t]=Q(this,e,t);let o="";for(let n=0,s=0;ne&&n&&(o+=i),es&&(o+=r.sliceString(e-s,t-s,i)),s=a+1}return o}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof j))return 0;let i=0,[o,n,s,r]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;o+=t,n+=t){if(o==s||n==r)return i;let a=this.children[o],l=e.children[n];if(a!=l)return i+a.scanIdentical(l,t);i+=a.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let i=0;for(let t of e)i+=t.lines;if(i<32){let i=[];for(let t of e)t.flatten(i);return new U(i,t)}let o=Math.max(32,i>>5),n=o<<1,s=o>>1,r=[],a=0,l=-1,c=[];function d(e){let t;if(e.lines>n&&e instanceof j)for(let t of e.children)d(t);else e.lines>s&&(a>s||!a)?(h(),r.push(e)):e instanceof U&&a&&(t=c[c.length-1])instanceof U&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new U(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>o&&h(),a+=e.lines,l+=e.length+1,c.push(e))}function h(){0!=a&&(r.push(1==c.length?c[0]:j.from(c,l)),l=-1,a=c.length=0)}for(let t of e)d(t);return h(),1==r.length?r[0]:new j(r,t)}}function Y(e,t,i=0,o=1e9){for(let n=0,s=0,r=!0;s=i&&(l>o&&(a=a.slice(0,o-n)),n0?1:(e instanceof U?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,o=this.nodes[i],n=this.offsets[i],s=n>>1,r=o instanceof U?o.text.length:o.children.length;if(s==(t>0?r:0)){if(0==i)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&n)==(t>0?0:1)){if(this.offsets[i]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(o instanceof U){let n=o.text[s+(t<0?-1:0)];if(this.offsets[i]+=t,n.length>Math.max(0,e))return this.value=0==e?n:t>0?n.slice(e):n.slice(0,n.length-e),this;e-=n.length}else{let n=o.children[s+(t<0?-1:0)];e>n.length?(e-=n.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(n),this.offsets.push(t>0?1:(n instanceof U?n.text.length:n.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class K{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Z(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:o}=this.cursor.next(e);return this.pos+=(o.length+e)*t,this.value=o.length<=i?o:t<0?o.slice(o.length-i):o.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class J{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:o}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=o,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&($.prototype[Symbol.iterator]=function(){return this.iter()},Z.prototype[Symbol.iterator]=K.prototype[Symbol.iterator]=J.prototype[Symbol.iterator]=function(){return this});class X{constructor(e,t,i,o){this.from=e,this.to=t,this.number=i,this.text=o}get length(){return this.to-this.from}}function Q(e,t,i){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,i))]}function ee(e,t,i=!0,o=!0){return F(e,t,i,o)}const te=/\r\n?|\n/;var ie=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(ie||(ie={}));class oe{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return n+(e-o);n+=r}else{if(i!=ie.Simple&&l>=e&&(i==ie.TrackDel&&oe||i==ie.TrackBefore&&oe))return null;if(l>e||l==e&&t<0&&!r)return e==o||t<0?n:n+a;n+=a}o=l}if(e>o)throw new RangeError(`Position ${e} is out of range for changeset of length ${o}`);return n}touchesRange(e,t=e){for(let i=0,o=0;i=0&&o<=t&&n>=e)return!(ot)||"cover";o=n}return!1}toString(){let e="";for(let t=0;t=0?":"+o:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeDesc");return new oe(e)}static create(e){return new oe(e)}}class ne extends oe{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ae(this,(t,i,o,n,s)=>e=e.replace(o,o+(i-t),s),!1),e}mapDesc(e,t=!1){return le(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let o=0,n=0;o=0){t[o]=r,t[o+1]=s;let a=o>>1;for(;i.length0&&re(i,t,n.text),n.forward(e),r+=e}let l=e[s++];for(;r>1].toJSON()))}return e}static of(e,t,i){let o=[],n=[],s=0,r=null;function a(e=!1){if(!e&&!o.length)return;sr||e<0||r>t)throw new RangeError(`Invalid change range ${e} to ${r} (in doc of length ${t})`);let d=c?"string"==typeof c?$.of(c.split(i||te)):c:$.empty,h=d.length;if(e==r&&0==h)return;es&&se(o,e-s,-1),se(o,r-e,h),re(n,o,d),s=r}}(e),a(!r),r}static empty(e){return new ne(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let o=0;ot&&"string"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==n.length)t.push(n[0],0);else{for(;i.length=0&&i<=0&&i==e[n+1]?e[n]+=t:n>=0&&0==t&&0==e[n]?e[n+1]+=i:o?(e[n]+=t,e[n+1]+=i):e.push(t,i)}function re(e,t,i){if(0==i.length)return;let o=t.length-2>>1;if(o>1])),!(i||r==e.sections.length||e.sections[r+1]<0);)a=e.sections[r++],l=e.sections[r++];t(n,c,s,d,h),n=c,s=d}}}function le(e,t,i,o=!1){let n=[],s=o?[]:null,r=new de(e),a=new de(t);for(let e=-1;;){if(r.done&&a.len||a.done&&r.len)throw new Error("Mismatched change set lengths");if(-1==r.ins&&-1==a.ins){let e=Math.min(r.len,a.len);se(n,e,-1),r.forward(e),a.forward(e)}else if(a.ins>=0&&(r.ins<0||e==r.i||0==r.off&&(a.len=0&&e=0)){if(r.done&&a.done)return s?ne.createSet(n,s):oe.create(n);throw new Error("Mismatched change set lengths")}{let t=0,i=r.len;for(;i;)if(-1==a.ins){let e=Math.min(i,a.len);t+=e,i-=e,a.forward(e)}else{if(!(0==a.ins&&a.lent||r.ins>=0&&r.len>t)&&(e||o.length>i),s.forward2(t),r.forward(t)}}else se(o,0,r.ins,e),n&&re(n,o,r.text),r.next()}}class de{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?$.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?$.empty:t[i].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class he{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let i,o;return this.empty?i=o=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),o=e.mapPos(this.to,-1)),i==this.from&&o==this.to?this:new he(i,o,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return ue.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return ue.range(this.anchor,i)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||this.goalColumn!=e.goalColumn||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return ue.range(e.anchor,e.head)}static create(e,t,i){return new he(e,t,i)}}class ue{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:ue.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ue(e.ranges.map(e=>he.fromJSON(e)),e.main)}static single(e,t=e){return new ue([ue.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let i=0,o=0;oe?8:0)|n)}static normalized(e,t=0){let i=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(i);for(let i=1;io.head?ue.range(r,s):ue.range(s,r))}}return new ue(e,t)}}function pe(e,t){for(let i of e.ranges)if(i.to>t)throw new RangeError("Selection points outside of document")}let me=0;class ge{constructor(e,t,i,o,n){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=o,this.id=me++,this.default=e([]),this.extensions="function"==typeof n?n(this):n}get reader(){return this}static define(e={}){return new ge(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:fe),!!e.static,e.enables)}of(e){return new be([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new be(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new be(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],i=>t(i.field(e)))}}function fe(e,t){return e==t||e.length==t.length&&e.every((e,i)=>e===t[i])}class be{constructor(e,t,i,o){this.dependencies=e,this.facet=t,this.type=i,this.value=o,this.id=me++}dynamicSlot(e){var t;let i=this.value,o=this.facet.compareInput,n=this.id,s=e[n]>>1,r=2==this.type,a=!1,l=!1,c=[];for(let i of this.dependencies)"doc"==i?a=!0:"selection"==i?l=!0:1&(null!==(t=e[i.id])&&void 0!==t?t:1)||c.push(e[i.id]);return{create:e=>(e.values[s]=i(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||we(e,c)){let t=i(e);if(r?!ye(t,e.values[s],o):!o(t,e.values[s]))return e.values[s]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[n];if(null!=l){let n=Pe(t,l);if(this.dependencies.every(i=>i instanceof ge?t.facet(i)===e.facet(i):!(i instanceof xe)||t.field(i,!1)==e.field(i,!1))||(r?ye(a=i(e),n,o):o(a=i(e),n)))return e.values[s]=n,0}else a=i(e);return e.values[s]=a,1}}}}function ye(e,t,i){if(e.length!=t.length)return!1;for(let o=0;oe[t.id]),n=i.map(e=>e.type),s=o.filter(e=>!(1&e)),r=e[t.id]>>1;function a(e){let i=[];for(let t=0;te===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Ce).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,i)=>{let o=e.values[t],n=this.updateF(o,i);return this.compareF(o,n)?0:(e.values[t]=n,1)},reconfigure:(e,i)=>{let o,n=e.facet(Ce),s=i.facet(Ce);return(o=n.find(e=>e.field==this))&&o!=s.find(e=>e.field==this)?(e.values[t]=o.create(e),1):null!=i.config.address[this.id]?(e.values[t]=i.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,Ce.of({field:this,create:e})]}get extension(){return this}}const ke=4,Se=3,Te=2,Ee=1;function Me(e){return t=>new Ie(t,e)}const Ae={highest:Me(0),high:Me(Ee),default:Me(Te),low:Me(Se),lowest:Me(ke)};class Ie{constructor(e,t){this.inner=e,this.prec=t}}class De{of(e){return new Oe(this,e)}reconfigure(e){return De.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Oe{constructor(e,t){this.compartment=e,this.inner=t}}class Be{constructor(e,t,i,o,n,s){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=o,this.staticValues=n,this.facets=s,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let o=[],n=Object.create(null),s=new Map;for(let i of function(e,t,i){let o=[[],[],[],[],[]],n=new Map;function s(e,r){let a=n.get(e);if(null!=a){if(a<=r)return;let t=o[a].indexOf(e);t>-1&&o[a].splice(t,1),e instanceof Oe&&i.delete(e.compartment)}if(n.set(e,r),Array.isArray(e))for(let t of e)s(t,r);else if(e instanceof Oe){if(i.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let o=t.get(e.compartment)||e.inner;i.set(e.compartment,o),s(o,r)}else if(e instanceof Ie)s(e.inner,e.prec);else if(e instanceof xe)o[r].push(e),e.provides&&s(e.provides,r);else if(e instanceof be)o[r].push(e),e.facet.extensions&&s(e.facet.extensions,Te);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(t,r)}}return s(e,Te),o.reduce((e,t)=>e.concat(t))}(e,t,s))i instanceof xe?o.push(i):(n[i.facet.id]||(n[i.facet.id]=[])).push(i);let r=Object.create(null),a=[],l=[];for(let e of o)r[e.id]=l.length<<1,l.push(t=>e.slot(t));let c=null==i?void 0:i.config.facets;for(let e in n){let t=n[e],o=t[0].facet,s=c&&c[e]||[];if(t.every(e=>0==e.type))if(r[o.id]=a.length<<1|1,fe(s,t))a.push(i.facet(o));else{let e=o.combine(t.map(e=>e.value));a.push(i&&o.compare(e,i.facet(o))?i.facet(o):e)}else{for(let e of t)0==e.type?(r[e.id]=a.length<<1|1,a.push(e.value)):(r[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));r[o.id]=l.length<<1,l.push(e=>ve(e,o,t))}}let d=l.map(e=>e(r));return new Be(e,s,d,r,a,n)}}function Le(e,t){if(1&t)return 2;let i=t>>1,o=e.status[i];if(4==o)throw new Error("Cyclic dependency between fields and/or facets");if(2&o)return o;e.status[i]=4;let n=e.computeSlot(e,e.config.dynamicSlots[i]);return e.status[i]=2|n}function Pe(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const Ne=ge.define(),Re=ge.define({combine:e=>e.some(e=>e),static:!0}),Fe=ge.define({combine:e=>e.length?e[0]:void 0,static:!0}),qe=ge.define(),_e=ge.define(),ze=ge.define(),Ve=ge.define({combine:e=>!!e.length&&e[0]});class We{constructor(e,t){this.type=e,this.value=t}static define(){return new He}}class He{of(e){return new We(this,e)}}class $e{constructor(e){this.map=e}of(e){return new Ue(this,e)}}class Ue{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new Ue(this.type,t)}is(e){return this.type==e}static define(e={}){return new $e(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let o of e){let e=o.map(t);e&&i.push(e)}return i}}Ue.reconfigure=Ue.define(),Ue.appendConfig=Ue.define();class je{constructor(e,t,i,o,n,s){this.startState=e,this.changes=t,this.selection=i,this.effects=o,this.annotations=n,this.scrollIntoView=s,this._doc=null,this._state=null,i&&pe(i,t.newLength),n.some(e=>e.type==je.time)||(this.annotations=n.concat(je.time.of(Date.now())))}static create(e,t,i,o,n,s){return new je(e,t,i,o,n,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(je.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function Ye(e,t){let i=[];for(let o=0,n=0;;){let s,r;if(o=e[o]))s=e[o++],r=e[o++];else{if(!(n=0;n--){let s=i[n](e);s&&Object.keys(s).length&&(o=Ge(o,Ze(t,s,e.changes.newLength),!0))}return o==e?e:je.create(t,e.changes,e.selection,o.effects,o.annotations,o.scrollIntoView)}(i?function(e){let t=e.startState,i=!0;for(let o of t.facet(qe)){let t=o(e);if(!1===t){i=!1;break}Array.isArray(t)&&(i=!0===i?t:Ye(i,t))}if(!0!==i){let o,n;if(!1===i)n=e.changes.invertedDesc,o=ne.empty(t.doc.length);else{let t=e.changes.filter(i);o=t.changes,n=t.filtered.mapDesc(t.changes).invertedDesc}e=je.create(t,o,e.selection&&e.selection.map(n),Ue.mapEffects(e.effects,n),e.annotations,e.scrollIntoView)}let o=t.facet(_e);for(let i=o.length-1;i>=0;i--){let n=o[i](e);e=n instanceof je?n:Array.isArray(n)&&1==n.length&&n[0]instanceof je?n[0]:Ke(t,Xe(n),!1)}return e}(n):n)}je.time=We.define(),je.userEvent=We.define(),je.addToHistory=We.define(),je.remote=We.define();const Je=[];function Xe(e){return null==e?Je:Array.isArray(e)?e:[e]}var Qe=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(Qe||(Qe={}));const et=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let tt;try{tt=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function it(e){return t=>{if(!/\S/.test(t))return Qe.Space;if(function(e){if(tt)return tt.test(e);for(let t=0;t""&&(i.toUpperCase()!=i.toLowerCase()||et.test(i)))return!0}return!1}(t))return Qe.Word;for(let i=0;i-1)return Qe.Word;return Qe.Other}}class ot{constructor(e,t,i,o,n,s){this.config=e,this.doc=t,this.selection=i,this.values=o,this.status=e.statusTemplate.slice(),this.computeSlot=n,s&&(s._state=this);for(let e=0;en.set(t,e)),i=null),n.set(t.value.compartment,t.value.extension)):t.is(Ue.reconfigure)?(i=null,o=t.value):t.is(Ue.appendConfig)&&(i=null,o=Xe(o).concat(t.value));if(i)t=e.startState.values.slice();else{i=Be.resolve(o,n,this),t=new ot(i,this.doc,this.selection,i.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values}let s=e.startState.facet(Re)?e.newSelection:e.newSelection.asSingle();new ot(i,e.newDoc,s,t,(t,i)=>i.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:ue.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),o=this.changes(i.changes),n=[i.range],s=Xe(i.effects);for(let i=1;in.spec.fromJSON(s,e)))}return ot.create({doc:e.doc,selection:ue.fromJSON(e.selection),extensions:t.extensions?o.concat([t.extensions]):o})}static create(e={}){let t=Be.resolve(e.extensions||[],new Map),i=e.doc instanceof $?e.doc:$.of((e.doc||"").split(t.staticFacet(ot.lineSeparator)||te)),o=e.selection?e.selection instanceof ue?e.selection:ue.single(e.selection.anchor,e.selection.head):ue.single(0);return pe(o,i.length),t.staticFacet(Re)||(o=o.asSingle()),new ot(t,i,o,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(ot.tabSize)}get lineBreak(){return this.facet(ot.lineSeparator)||"\n"}get readOnly(){return this.facet(Ve)}phrase(e,...t){for(let t of this.facet(ot.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,i)=>{if("$"==i)return"$";let o=+(i||1);return!o||o>t.length?e:t[o-1]})),e}languageDataAt(e,t,i=-1){let o=[];for(let n of this.facet(Ne))for(let s of n(this,t,i))Object.prototype.hasOwnProperty.call(s,e)&&o.push(s[e]);return o}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return it(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:o}=this.doc.lineAt(e),n=this.charCategorizer(e),s=e-i,r=e-i;for(;s>0;){let e=ee(t,s,!1);if(n(t.slice(e,s))!=Qe.Word)break;s=e}for(;re.length?e[0]:4}),ot.lineSeparator=Fe,ot.readOnly=Ve,ot.phrases=ge.define({compare(e,t){let i=Object.keys(e),o=Object.keys(t);return i.length==o.length&&i.every(i=>e[i]==t[i])}}),ot.languageData=Ne,ot.changeFilter=qe,ot.transactionFilter=_e,ot.transactionExtender=ze,De.reconfigure=Ue.define();class nt{eq(e){return this==e}range(e,t=e){return rt.create(e,t,this)}}function st(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}nt.prototype.startSide=nt.prototype.endSide=0,nt.prototype.point=!1,nt.prototype.mapMode=ie.TrackDel;class rt{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new rt(e,t,i)}}function at(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class lt{constructor(e,t,i,o){this.from=e,this.to=t,this.value=i,this.maxPoint=o}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,o=0){let n=i?this.to:this.from;for(let s=o,r=n.length;;){if(s==r)return s;let o=s+r>>1,a=n[o]-e||(i?this.value[o].endSide:this.value[o].startSide)-t;if(o==s)return a>=0?s:r;a>=0?r=o:s=o+1}}between(e,t,i,o){for(let n=this.findIndex(t,-1e9,!0),s=this.findIndex(i,1e9,!1,n);nc||l==c&&d.startSide>0&&d.endSide<=0)continue;(c-l||d.endSide-d.startSide)<0||(s<0&&(s=l),d.point&&(r=Math.max(r,c-l)),i.push(d),o.push(l-s),n.push(c-s))}return{mapped:i.length?new lt(o,n,i,r):null,pos:s}}}class ct{constructor(e,t,i,o){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=o}static create(e,t,i,o){return new ct(e,t,i,o)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:o=0,filterTo:n=this.length}=e,s=e.filter;if(0==t.length&&!s)return this;if(i&&(t=t.slice().sort(at)),this.isEmpty)return t.length?ct.of(t):this;let r=new ut(this,null,-1).goto(0),a=0,l=[],c=new dt;for(;r.value||a=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==r.rangeIndex&&r.chunkIndexthis.chunkEnd(r.chunkIndex)||nr.to||n=n&&e<=n+s.length&&!1===s.between(n,e-n,t-n,i))return}this.nextLayer.between(e,t,i)}}iter(e=0){return pt.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return pt.from(e).goto(t)}static compare(e,t,i,o,n=-1){let s=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=n),r=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=n),a=ht(s,r,i),l=new gt(s,a,n),c=new gt(r,a,n);i.iterGaps((e,t,i)=>ft(l,e,c,t,i,o)),i.empty&&0==i.length&&ft(l,0,c,0,0,o)}static eq(e,t,i=0,o){null==o&&(o=999999999);let n=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),s=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(n.length!=s.length)return!1;if(!n.length)return!0;let r=ht(n,s),a=new gt(n,r,0).goto(i),l=new gt(s,r,0).goto(i);for(;;){if(a.to!=l.to||!bt(a.active,l.active)||a.point&&(!l.point||!st(a.point,l.point)))return!1;if(a.to>o)return!0;a.next(),l.next()}}static spans(e,t,i,o,n=-1){let s=new gt(e,null,n).goto(t),r=t,a=s.openStart;for(;;){let e=Math.min(s.to,i);if(s.point){let i=s.activeForPoint(s.to),n=s.pointFromr&&(o.span(r,e,s.active,a),a=s.openEnd(e));if(s.to>i)return a+(s.point&&s.to>i?1:0);r=s.to,s.next()}}static of(e,t=!1){let i=new dt;for(let o of e instanceof rt?[e]:t?function(e){if(e.length>1)for(let t=e[0],i=1;i0)return e.slice().sort(at);t=o}return e}(e):e)i.add(o.from,o.to,o.value);return i.finish()}static join(e){if(!e.length)return ct.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let o=e[i];o!=ct.empty;o=o.nextLayer)t=new ct(o.chunkPos,o.chunk,t,Math.max(o.maxPoint,t.maxPoint));return t}}ct.empty=new ct([],[],null,-1),ct.empty.nextLayer=ct.empty;class dt{finishChunk(e){this.chunks.push(new lt(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new dt)).add(e,t,i)}addInner(e,t,i){let o=e-this.lastTo||i.startSide-this.last.endSide;if(o<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(o<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(ct.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=ct.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function ht(e,t,i){let o=new Map;for(let t of e)for(let e=0;e=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&o.push(new ut(s,t,i,n));return 1==o.length?o[0]:new pt(o)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)mt(this.heap,e);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)mt(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),mt(this.heap,0)}}}function mt(e,t){for(let i=e[t];;){let o=1+(t<<1);if(o>=e.length)break;let n=e[o];if(o+1=0&&(n=e[o+1],o++),i.compare(n)<0)break;e[o]=i,e[t]=n,t=o}}class gt{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=pt.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){yt(this.active,e),yt(this.activeTo,e),yt(this.activeRank,e),this.minActive=vt(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:o,rank:n}=this.cursor;for(;t0;)t++;wt(this.active,t,i),wt(this.activeTo,t,o),wt(this.activeRank,t,n),e&&wt(e,t,this.cursor.from),this.minActive=vt(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let o=this.minActive;if(o>-1&&(this.activeTo[o]-this.cursor.from||this.active[o].endSide-this.cursor.startSide)<0){if(this.activeTo[o]>e){this.to=this.activeTo[o],this.endSide=this.active[o].endSide;break}this.removeActive(o),i&&yt(i,o)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[t]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function ft(e,t,i,o,n,s){e.goto(t),i.goto(o);let r=o+n,a=o,l=o-t,c=!!s.boundChange;for(let t=!1;;){let o=e.to+l-i.to,n=o||e.endSide-i.endSide,d=n<0?e.to+l:i.to,h=Math.min(d,r);if(e.point||i.point?(e.point&&i.point&&st(e.point,i.point)&&bt(e.activeForPoint(e.to),i.activeForPoint(i.to))||s.comparePoint(a,h,e.point,i.point),t=!1):(t&&s.boundChange(a),h>a&&!bt(e.active,i.active)&&s.compareRange(a,h,e.active,i.active),c&&hr)break;a=d,n<=0&&e.next(),n>=0&&i.next()}}function bt(e,t){if(e.length!=t.length)return!1;for(let i=0;i=t;i--)e[i+1]=e[i];e[t]=i}function vt(e,t){let i=-1,o=1e9;for(let n=0;ne.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),r,s);else if(r&&"object"==typeof r){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");n(o(i),r,a,c)}else null!=r&&a.push(i.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+r+";")}(a.length||c)&&s.push((!i||l||r?e:e.map(i)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)n(o(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=kt[Ct]||1;return kt[Ct]=e+1,"ͼ"+e.toString(36)}static mount(e,t,i){let o=e[xt],n=i&&i.nonce;o?n&&o.setNonce(n):o=new Et(e,n),o.mount(Array.isArray(t)?t:[t],e)}}let Tt=new Map;class Et{constructor(e,t){let i=e.ownerDocument||e,o=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&o.CSSStyleSheet){let t=Tt.get(i);if(t)return e[xt]=t;this.sheet=new o.CSSStyleSheet,Tt.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[xt]=this}mount(e,t){let i=this.sheet,o=0,n=0;for(let t=0;t-1&&(this.modules.splice(r,1),n--,r=-1),-1==r){if(this.modules.splice(n++,0,s),i)for(let e=0;e",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'};"undefined"!=typeof navigator&&/Mac/.test(navigator.platform),"undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var It=0;It<10;It++)Mt[48+It]=Mt[96+It]=String(It);for(It=1;It<=24;It++)Mt[It+111]="F"+It;for(It=65;It<=90;It++)Mt[It]=String.fromCharCode(It+32),At[It]=String.fromCharCode(It);for(var Dt in Mt)At.hasOwnProperty(Dt)||(At[Dt]=Mt[Dt]);let Ot="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Bt="undefined"!=typeof document?document:{documentElement:{style:{}}};const Lt=/Edge\/(\d+)/.exec(Ot.userAgent),Pt=/MSIE \d/.test(Ot.userAgent),Nt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ot.userAgent),Rt=!!(Pt||Nt||Lt),Ft=!Rt&&/gecko\/(\d+)/i.test(Ot.userAgent),qt=!Rt&&/Chrome\/(\d+)/.exec(Ot.userAgent),_t="webkitFontSmoothing"in Bt.documentElement.style,zt=!Rt&&/Apple Computer/.test(Ot.vendor),Vt=zt&&(/Mobile\/\w+/.test(Ot.userAgent)||Ot.maxTouchPoints>2);var Wt={mac:Vt||/Mac/.test(Ot.platform),windows:/Win/.test(Ot.platform),linux:/Linux|X11/.test(Ot.platform),ie:Rt,ie_version:Pt?Bt.documentMode||6:Nt?+Nt[1]:Lt?+Lt[1]:0,gecko:Ft,gecko_version:Ft?+(/Firefox\/(\d+)/.exec(Ot.userAgent)||[0,0])[1]:0,chrome:!!qt,chrome_version:qt?+qt[1]:0,ios:Vt,android:/Android\b/.test(Ot.userAgent),webkit:_t,webkit_version:_t?+(/\bAppleWebKit\/(\d+)/.exec(Ot.userAgent)||[0,0])[1]:0,safari:zt,safari_version:zt?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Ot.userAgent)||[0,0])[1]:0,tabSize:null!=Bt.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function Ht(e,t){for(let i in e)"class"==i&&t.class?t.class+=" "+e.class:"style"==i&&t.style?t.style+=";"+e.style:t[i]=e[i];return t}const $t=Object.create(null);function Ut(e,t,i){if(e==t)return!0;e||(e=$t),t||(t=$t);let o=Object.keys(e),n=Object.keys(t);if(o.length-(i&&o.indexOf(i)>-1?1:0)!=n.length-(i&&n.indexOf(i)>-1?1:0))return!1;for(let s of o)if(s!=i&&(-1==n.indexOf(s)||e[s]!==t[s]))return!1;return!0}function jt(e,t,i){let o=!1;if(t)for(let n in t)i&&n in i||(o=!0,"style"==n?e.style.cssText="":e.removeAttribute(n));if(i)for(let n in i)t&&t[n]==i[n]||(o=!0,"style"==n?e.style.cssText=i[n]:e.setAttribute(n,i[n]));return o}function Yt(e){let t=Object.create(null);for(let i=0;i0?3e8:-4e8:t>0?1e8:-1e8,new Qt(e,t,t,i,e.widget||null,!1)}static replace(e){let t,i,o=!!e.block;if(e.isBlockGap)t=-5e8,i=4e8;else{let{start:n,end:s}=ei(e,o);t=(n?o?-3e8:-1:5e8)-1,i=1+(s?o?2e8:1:-6e8)}return new Qt(e,t,i,o,e.widget||null,!0)}static line(e){return new Xt(e)}static set(e,t=!1){return ct.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Kt.none=ct.empty;class Jt extends Kt{constructor(e){let{start:t,end:i}=ei(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Ht(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||$t}eq(e){return this==e||e instanceof Jt&&this.tagName==e.tagName&&Ut(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Jt.prototype.point=!1;class Xt extends Kt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Xt&&this.spec.class==e.spec.class&&Ut(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Xt.prototype.mapMode=ie.TrackBefore,Xt.prototype.point=!0;class Qt extends Kt{constructor(e,t,i,o,n,s){super(t,i,n,e),this.block=o,this.isReplace=s,this.mapMode=o?t<=0?ie.TrackBefore:ie.TrackAfter:ie.TrackDel}get type(){return this.startSide!=this.endSide?Zt.WidgetRange:this.startSide<=0?Zt.WidgetBefore:Zt.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Qt&&(t=this.widget,i=e.widget,t==i||!!(t&&i&&t.compare(i)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide;var t,i}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function ei(e,t=!1){let{inclusiveStart:i,inclusiveEnd:o}=e;return null==i&&(i=e.inclusive),null==o&&(o=e.inclusive),{start:null!=i?i:t,end:null!=o?o:t}}function ti(e,t,i,o=0){let n=i.length-1;n>=0&&i[n]+o>=e?i[n]=Math.max(i[n],t):i.push(e,t)}Qt.prototype.point=!0;class ii extends nt{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof ii&&this.tagName==e.tagName&&Ut(this.attributes,e.attributes)}static create(e){return new ii(e.tagName,e.attributes||$t)}static set(e,t=!1){return ct.of(e,t)}}function oi(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function ni(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function si(e,t){if(!t.anchorNode)return!1;try{return ni(e,t.anchorNode)}catch(e){return!1}}function ri(e){return 3==e.nodeType?wi(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function ai(e,t,i,o){return!!i&&(di(e,t,i,o,-1)||di(e,t,i,o,1))}function li(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function ci(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function di(e,t,i,o,n){for(;;){if(e==i&&t==o)return!0;if(t==(n<0?0:hi(e))){if("DIV"==e.nodeName)return!1;let i=e.parentNode;if(!i||1!=i.nodeType)return!1;t=li(e)+(n<0?0:1),e=i}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(n<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=n<0?hi(e):0}}}function hi(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ui(e,t){let i=t?e.left:e.right;return{left:i,right:i,top:e.top,bottom:e.bottom}}function pi(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function mi(e,t){let i=t.width/e.offsetWidth,o=t.height/e.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.width-e.offsetWidth)<1)&&(i=1),(o>.995&&o<1.005||!isFinite(o)||Math.abs(t.height-e.offsetHeight)<1)&&(o=1),{scaleX:i,scaleY:o}}ii.prototype.startSide=ii.prototype.endSide=-1;class gi{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?hi(t):0),i,Math.min(e.focusOffset,i?hi(i):0))}set(e,t,i,o){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=o}}let fi,bi=null;function yi(e){if(e.setActive)return e.setActive();if(bi)return e.focus(bi);let t=[];for(let i=e;i&&(t.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(e.focus(null==bi?{get preventScroll(){return bi={preventScroll:!0},!0}}:void 0),!bi){bi=!1;for(let e=0;eMath.max(1,e.scrollHeight-e.clientHeight-4)}function xi(e,t){for(let i=e,o=t;;){if(3==i.nodeType&&o>0)return{node:i,offset:o};if(1==i.nodeType&&o>0){if("false"==i.contentEditable)return null;i=i.childNodes[o-1],o=hi(i)}else{if(!i.parentNode||ci(i))return null;o=li(i),i=i.parentNode}}}function ki(e,t){for(let i=e,o=t;;){if(3==i.nodeType&&o=26&&(bi=!1);class Si{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new Si(e.parentNode,li(e),t)}static after(e,t){return new Si(e.parentNode,li(e)+1,t)}}var Ti=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(Ti||(Ti={}));const Ei=Ti.LTR,Mi=Ti.RTL;function Ai(e){let t=[];for(let i=0;i=t){if(r.level==i)return s;(n<0||(0!=o?o<0?r.fromt:e[n].level>r.level))&&(n=s)}}if(n<0)throw new RangeError("Index out of range");return n}}function Ri(e,t){if(e.length!=t.length)return!1;for(let i=0;il&&r.push(new Ni(l,m.from,u)),_i(e,m.direction==Ei!=!(u%2)?o+1:o,n,m.inner,m.from,m.to,r),l=m.to}p=m.to}else{if(p==i||(t?Fi[p]!=a:Fi[p]==a))break;p++}h?qi(e,l,p,o+1,n,h,r):lt;){let i=!0,d=!1;if(!c||l>s[c-1].to){let e=Fi[l-1];e!=a&&(i=!1,d=16==e)}let h=i||1!=a?null:[],u=i?o:o+1,p=l;e:for(;;)if(c&&p==s[c-1].to){if(d)break e;let m=s[--c];if(!i)for(let e=m.from,i=c;;){if(e==t)break e;if(!i||s[i-1].to!=e){if(Fi[e-1]==a)break e;break}e=s[--i].from}if(h)h.push(m);else{m.to=0;e-=3)if(Bi[e+1]==-i){let t=Bi[e+2],i=2&t?n:4&t?1&t?s:n:0;i&&(Fi[r]=Fi[Bi[e]]=i),a=e;break}}else{if(189==Bi.length)break;Bi[a++]=r,Bi[a++]=t,Bi[a++]=l}else if(2==(o=Fi[r])||1==o){let e=o==n;l=e?0:1;for(let t=a-3;t>=0;t-=3){let i=Bi[t+2];if(2&i)break;if(e)Bi[t+2]|=2;else{if(4&i)break;Bi[t+2]|=4}}}}}(e,n,s,o,a),function(e,t,i,o){for(let n=0,s=o;n<=i.length;n++){let r=n?i[n-1].to:e,a=nl;)t==s&&(t=i[--o].from,s=o?i[o-1].to:e),Fi[--t]=d;l=r}else s=r,l++}}}(n,s,o,a),qi(e,n,s,t,i,o,r)}function zi(e){return[new Ni(0,e,0)]}let Vi="";function Wi(e,t,i,o,n){var s;let r=o.head-e.from,a=Ni.find(t,r,null!==(s=o.bidiLevel)&&void 0!==s?s:-1,o.assoc),l=t[a],c=l.side(n,i);if(r==c){let e=a+=n?1:-1;if(e<0||e>=t.length)return null;l=t[a=e],r=l.side(!n,i),c=l.side(n,i)}let d=ee(e.text,r,l.forward(n,i));(dl.to)&&(d=c),Vi=e.text.slice(Math.min(r,d),Math.max(r,d));let h=a==(n?t.length-1:0)?null:t[a+(n?1:-1)];return h&&d==c&&h.level+(n?0:1)e.some(e=>e)}),eo=ge.define({combine:e=>e.some(e=>e)}),to=ge.define();class io{constructor(e,t="nearest",i="nearest",o=5,n=5,s=!1){this.range=e,this.y=t,this.x=i,this.yMargin=o,this.xMargin=n,this.isSnapshot=s}map(e){return e.empty?this:new io(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new io(ue.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oo=Ue.define({map:(e,t)=>e.map(t)}),no=Ue.define();function so(e,t,i){let o=e.facet(Yi);o.length?o[0](t):window.onerror&&window.onerror(String(t),i,void 0,void 0,t)||(i?console.error(i+":",t):console.error(t))}const ro=ge.define({combine:e=>!e.length||e[0]});let ao=0;const lo=ge.define({combine:e=>e.filter((t,i)=>{for(let o=0;o{let t=[];return s&&t.push(mo.of(t=>{let i=t.plugin(e);return i?s(i):Kt.none})),n&&t.push(n(e)),t})}static fromClass(e,t){return co.define((t,i)=>new e(t,i),t)}}class ho{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(so(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){so(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){so(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const uo=ge.define(),po=ge.define(),mo=ge.define(),go=ge.define(),fo=ge.define(),bo=ge.define(),yo=ge.define();function wo(e,t){let i=e.state.facet(yo);if(!i.length)return i;let o=i.map(t=>t instanceof Function?t(e):t),n=[];return ct.spans(o,t.from,t.to,{point(){},span(e,i,o,s){let r=e-t.from,a=i-t.from,l=n;for(let e=o.length-1;e>=0;e--,s--){let i,n=o[e].spec.bidiIsolate;if(null==n&&(n=Hi(t.text,r,a)),s>0&&l.length&&(i=l[l.length-1]).to==r&&i.direction==n)i.to=a,l=i.inner;else{let e={from:r,to:a,direction:n,inner:[]};l.push(e),l=e.inner}}}}),n}const vo=ge.define();function Co(e){let t=0,i=0,o=0,n=0;for(let s of e.state.facet(vo)){let r=s(e);r&&(null!=r.left&&(t=Math.max(t,r.left)),null!=r.right&&(i=Math.max(i,r.right)),null!=r.top&&(o=Math.max(o,r.top)),null!=r.bottom&&(n=Math.max(n,r.bottom)))}return{left:t,right:i,top:o,bottom:n}}const xo=ge.define();class ko{constructor(e,t,i,o){this.fromA=e,this.toA=t,this.fromB=i,this.toB=o}join(e){return new ko(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let o=e[t-1];if(!(o.fromA>i.toA)){if(o.toAo.push(new ko(e,t,i,n))),this.changedRanges=o}static create(e,t,i){return new So(e,t,i)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}const To=[];class Eo{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return To}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,4&this.flags){this.flags&=-5;let e=this.domAttrs;e&&function(e,t){for(let i=e.attributes.length-1;i>=0;i--){let o=e.attributes[i].name;null==t[o]&&e.removeAttribute(o)}for(let i in t){let o=t[i];"style"==i?e.style.cssText=o:e.getAttribute(i)!=o&&e.setAttribute(i,o)}}(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let t of this.children){if(t==e)return i;i+=t.length+t.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let i=li(this.dom),o=this.length?e>0:t>0;return new Si(this.parent.dom,i+(o?1:0),0==e||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Io)return e;return null}static get(e){return e.cmTile}}class Mo extends Eo{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(2&this.flags)return;super.sync(e);let t,i=this.dom,o=null,n=(null==e?void 0:e.node)==i?e:null,s=0;for(let r of this.children){if(r.sync(e),s+=r.length+r.breakAfter,t=o?o.nextSibling:i.firstChild,n&&t!=r.dom&&(n.written=!0),r.dom.parentNode==i)for(;t&&t!=r.dom;)t=Ao(t);else i.insertBefore(r.dom,t);o=r.dom}for(t=o?o.nextSibling:i.firstChild,n&&t&&(n.written=!0);t;)t=Ao(t);this.length=s}}function Ao(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Io extends Mo{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Eo.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,o=0,n=0;;)if(o==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&n++,o=t.pop()}else{let s=i.children[o++];if(s instanceof Do)t.push(o),i=s,o=0;else{let t=n+s.length,i=e(s,n);if(void 0!==i)return i;n=t+s.breakAfter}}}resolveBlock(e,t){let i,o,n=-1,s=-1;if(this.blockTiles((r,a)=>{let l=a+r.length;if(e>=a&&e<=l){if(r.isWidget()&&t>=-1&&t<=1){if(32&r.flags)return!0;16&r.flags&&(i=void 0)}(ae||e==a&&(t>1?r.length:r.covers(-1)))&&(!o||!r.isWidget()&&o.isWidget())&&(o=r,s=e-a)}}),!i&&!o)throw new Error("No tile at position "+e);return i&&t<0||!o?{tile:i,offset:n}:{tile:o,offset:s}}}class Do extends Mo{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new Do(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Oo extends Mo{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let o=new Oo(t||document.createElement("div"),e);return t&&i||(o.flags|=4),o}get domAttrs(){return this.attrs}resolveInline(e,t,i){let o=null,n=-1,s=null,r=-1;!function e(a,l){for(let c=0,d=0;c=l&&(h.isComposite()?e(h,l-d):(!s||s.isHidden&&(t>0||i&&Bo(s,h)))&&(u>l||32&h.flags)?(s=h,r=l-d):(di&&(e=i);let o=e,n=e,s=0;0==e&&t<0||e==i&&t>=0?Wt.chrome||Wt.gecko||(e?(o--,s=1):n=0)?0:r.length-1];return Wt.safari&&!s&&0==a.width&&(a=Array.prototype.find.call(r,e=>e.width)||a),s?ui(a,s<0):a||null}static of(e,t){let i=new Po(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class No extends Eo{constructor(e,t,i,o){super(e,t,o),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let o=this.widget.coordsAt(this.dom,e,t);if(o)return o;if(i)return ui(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);{let t=this.dom.getClientRects(),i=null;if(!t.length)return null;let o=!!(16&this.flags)||!(32&this.flags)&&e>0;for(let n=o?t.length-1:0;i=t[n],!(e>0?0==n:n==t.length-1||i.top0;)if(o.isComposite())if(s){if(!e)break;i&&i.break(),e--,s=!1}else if(n==o.children.length){if(!e&&!r.length)break;i&&i.leave(o),s=!!o.breakAfter,({tile:o,index:n}=r.pop()),n++}else{let a=o.children[n],l=a.breakAfter;!(t>0?a.length<=e:a.length=0;e--){let i=t.marks[e],n=o.lastChild;if(n instanceof Lo&&n.mark.eq(i.mark))n.dom!=i.dom&&n.setDOM(jo(i.dom)),o=n;else{if(this.cache.reused.get(i)){let e=Eo.get(i.dom);e&&e.setDOM(jo(i.dom))}let e=Lo.of(i.mark,i.dom);o.append(e),o=e}this.cache.reused.set(i,2)}let n=Eo.get(e.text);n&&this.cache.reused.set(n,2);let s=new Po(e.text,e.text.nodeValue);s.flags|=8,o.append(s)}addInlineWidget(e,t,i){let o=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);o||this.flushBuffer();let n=this.ensureMarks(t,i);o||16&e.flags||n.append(this.getBuffer(1)),n.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){(this.afterWidget||this.lastBlock).length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=Uo);let o=Oo.start(e,t||(null===(i=this.cache.find(Oo))||void 0===i?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=o)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let o=this.curLine;for(let n=e.length-1;n>=0;n--){let s,r=e[n];if(t>0&&(s=o.lastChild)&&s instanceof Lo&&s.mark.eq(r))o=s,t--;else{let e=Lo.of(r,null===(i=this.cache.find(Lo,e=>e.mark.eq(r)))||void 0===i?void 0:i.dom);o.append(e),o=e,t=0}}return o}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;e&&$o(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||Wt.ios&&$o(this.curLine,!0))||this.curLine.append(this.cache.findWidget(Go,0,32)||new No(Go.toDOM(),0,Go,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let t=new qo(e.from,e.to,e.value,e.rank),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-t.rank||this.wrappers[i-1].to-t.to)<0;)i--;this.wrappers.splice(i,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let o=t.lastChild;if(i.frome.wrapper.eq(i.wrapper)))||void 0===e?void 0:e.dom);t.append(o),t=o}}return t}blockPosCovered(){let e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(Ro,void 0,1);return i&&(i.flags=t),i||new Ro(t)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class zo{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:i,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=t;let n=this.textOff=Math.min(e,t.length);return i?null:t.slice(0,n)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const Vo=[No,Oo,Po,Lo,Ro,Do,Io];for(let e=0;e[]),this.index=Vo.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let o=e.bucket,n=this.buckets[o],s=this.index[o];for(let e=n.length-1;e>=0;e--){let r=(e+s)%n.length,a=n[r];if((!t||t(a))&&!this.reused.has(a))return n.splice(r,1),r{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let o=0,n=0,s=0;;){let r=so){let e=a-o;this.preserve(e,!s,!r),o=a,n+=e}if(!r)break;t&&r.fromA<=t.range.fromA&&r.toA>=t.range.toA?(this.forward(r.fromA,t.range.fromA,t.range.fromA1;i--){let o=i==e.parents.length?e.tile:e.parents[i].tile;o instanceof Lo&&t.push(o.mark)}return t}(this.old),n=this.openMarks;this.old.advance(e,i?1:-1,{skip:(e,t,i)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(i-t);else{let s=i>0||t{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof Lo&&o.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?o.length&&(o.length=n=0):e instanceof Lo&&(o.shift(),n=Math.min(n,o.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,o=this.builder,n=0,s=ct.spans(this.decorations,e,t,{point:(e,t,s,r,a,l)=>{if(s instanceof Qt){if(this.disallowBlockEffectsFor[l]){if(s.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.view.state.doc.lineAt(e).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(n=r.length,a>r.length)o.continueWidget(t-e);else{let n=s.widget||(s.block?Yo.block:Yo.inline),l=function(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;e.block&&(t|=256);return t}(s),c=this.cache.findWidget(n,t-e,l)||No.of(n,this.view,t-e,l);s.block?(s.startSide>0&&o.addLineStartIfNotCovered(i),o.addBlockWidget(c)):(o.ensureLine(i),o.addInlineWidget(c,r,a))}i=null}else i=function(e,t){let i=t.spec.attributes,o=t.spec.class;if(!i&&!o)return e;e||(e={class:"cm-line"});i&&Ht(i,e);o&&(e.class+=" "+o);return e}(i,s);t>e&&this.text.skip(t-e)},span:(e,t,n,s)=>{for(let r=e;rn,this.openMarks=s}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let o=e.parentNode;;o=o.parentNode){let e=Eo.get(o);if(o==this.view.contentDOM)break;e instanceof Lo?t.push(e):(null==e?void 0:e.isLine())?i=e:"DIV"!=o.nodeName||i||o==this.view.contentDOM?t.push(Lo.of(new Jt({tagName:o.nodeName.toLowerCase(),attributes:Yt(o)}),o)):i=new Oo(o,Uo)}return{line:i,marks:t}}}function $o(e,t){let i=e=>{for(let o of e.children)if((t?o.isText():o.length)||i(o))return!0;return!1};return i(e)}const Uo={class:"cm-line"};function jo(e){let t=Eo.get(e);return t&&t.setDOM(e.cloneNode()),e}class Yo extends Gt{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Yo.inline=new Yo("span"),Yo.block=new Yo("div");const Go=new class extends Gt{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Zo{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Kt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Io(e,e.contentDOM),this.updateInner([new ko(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:e,toA:t})=>tthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let o=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?o=this.domChanged.newSel.head:function(e,t){let i=!1;t&&e.iterChangedRanges((e,o)=>{et.from&&(i=!0)});return i}(e.changes,this.hasComposition)||e.selectionSet||(o=e.state.selection.main.head));let n=o>-1?function(e,t,i){let o=Jo(e,i);if(!o)return null;let{node:n,from:s,to:r}=o,a=n.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(o.from,o.to)!=a)return null;let l=t.invertedDesc;return{range:new ko(l.mapPos(s),l.mapPos(r),s,r),text:n}}(this.view,e.changes,o):null;if(this.domChanged=null,this.hasComposition){let{from:t,to:o}=this.hasComposition;i=new ko(t,o,e.changes.mapPos(t,-1),e.changes.mapPos(o,1)).addToSet(i.slice())}this.hasComposition=n?{from:n.range.fromB,to:n.range.toB}:null,(Wt.ie||Wt.chrome)&&!n&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let s=this.decorations,r=this.blockWrappers;this.updateDeco();let a=function(e,t,i){let o=new Xo;return ct.compare(e,t,i,o),o.changes}(s,this.decorations,e.changes);a.length&&(i=ko.extendWithRanges(i,a));let l=function(e,t,i){let o=new Qo;return ct.compare(e,t,i,o),o.changes}(r,this.blockWrappers,e.changes);return l.length&&(i=ko.extendWithRanges(i,l)),n&&!i.some(e=>e.fromA<=n.range.fromA&&e.toA>=n.range.toA)&&(i=n.range.addToSet(i.slice())),!(2&this.tile.flags&&0==i.length)&&(this.updateInner(i,n),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let i=this.tile,o=new Ho(this.view,i,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=o.run(e,t),Ko(i,o.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=Wt.chrome||Wt.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),!o||!o.written&&i.selectionRange.focusNode==o.node&&this.tile.dom.contains(o.node)||(this.forceSelection=!0),this.tile.dom.style.height=""});let o=[];if(this.view.viewport.from||this.view.viewport.to-1)&&si(i,this.view.observer.selectionRange)&&!(o&&i.contains(o));if(!(n||t||s))return;let r=this.forceSelection;this.forceSelection=!1;let a,l,c=this.view.state.selection.main;if(c.empty?l=a=this.inlineDOMNearPos(c.anchor,c.assoc||1):(l=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),a=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),Wt.gecko&&c.empty&&!this.hasComposition&&(1==(d=a).node.nodeType&&d.node.firstChild&&(0==d.offset||"false"==d.node.childNodes[d.offset-1].contentEditable)&&(d.offset==d.node.childNodes.length||"false"==d.node.childNodes[d.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null)),a=l=new Si(e,0),r=!0}var d;let h=this.view.observer.selectionRange;!r&&h.focusNode&&(ai(a.node,a.offset,h.anchorNode,h.anchorOffset)&&ai(l.node,l.offset,h.focusNode,h.focusOffset)||this.suppressWidgetCursorChange(h,c))||(this.view.observer.ignore(()=>{Wt.android&&Wt.chrome&&i.contains(h.focusNode)&&function(e,t){for(let i=e;i&&i!=t;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(h.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let e=oi(this.view.root);if(e)if(c.empty){if(Wt.gecko){let e=(t=a.node,n=a.offset,1!=t.nodeType?0:(n&&"false"==t.childNodes[n-1].contentEditable?1:0)|(nc.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}else;var t,n;s&&this.view.root.activeElement==i&&(i.blur(),o&&o.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new Si(h.anchorNode,h.anchorOffset),this.impreciseHead=l.precise?null:new Si(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&ai(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=oi(e.root),{anchorNode:o,anchorOffset:n}=e.observer.selectionRange;if(!(i&&t.empty&&t.assoc&&i.modify))return;let s=this.lineAt(t.head,t.assoc);if(!s)return;let r=s.posAtStart;if(t.head==r||t.head==r+s.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let d=e.observer.selectionRange;e.docView.posFromDOM(d.anchorNode,d.anchorOffset)!=t.from&&i.collapse(o,n)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;let o=i.posAtStart;if(!i.isComposite())return i.isText()?e==i.dom?o+t:o+(t?i.length:0):o;{let n;if(e==i.dom)n=i.dom.childNodes[t];else{let o=0==hi(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==i.dom)break;0==o&&t.firstChild!=t.lastChild&&(o=e==t.firstChild?-1:1),e=t}n=o<0?e:e.nextSibling}if(n==i.dom.firstChild)return o;for(;n&&!Eo.get(n);)n=n.nextSibling;if(!n)return o+i.length;for(let e=0,t=o;;e++){let o=i.children[e];if(o.dom==n)return t;t+=o.length+o.breakAfter}}}domAtPos(e,t){let{tile:i,offset:o}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(e,t):i.domIn(o,t)}inlineDOMNearPos(e,t){let i,o,n=-1,s=!1,r=-1,a=!1;return this.tile.blockTiles((t,l)=>{if(t.isWidget()){if(32&t.flags&&l>=e)return!0;16&t.flags&&(s=!0)}else{let c=l+t.length;if(l<=e&&(i=t,n=e-l,s=c=e&&!o&&(o=t,r=e-l,a=l>e),l>e&&o)return!0}}),i||o?(s&&o?i=null:a&&i&&(o=null),i&&t<0||!o?i.domIn(n,t):o.domIn(r,t)):this.domAtPos(e,t)}coordsAt(e,t){let{tile:i,offset:o}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof en?null:i.coordsInWidget(o,t,!0):i.coordsIn(o,t)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;return function e(t,i){if(t.isComposite())for(let o of t.children){if(o.length>=i){let t=e(o,i);if(t)return t}if((i-=o.length)<0)break}else if(t.isText()&&iMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,a=this.view.textDirection==Ti.LTR,l=0,c=(e,d,h)=>{for(let u=0;uo);u++){let o=e.children[u],p=d+o.length,m=o.dom.getBoundingClientRect(),{height:g}=m;if(h&&!u&&(l+=m.top-h.top),o instanceof Do)p>i&&c(o,d,m);else if(d>=i&&(l>0&&t.push(-l),t.push(g+l),l=0,s)){let e=o.dom.lastChild,t=e?ri(e):[];if(t.length){let e=t[t.length-1],i=a?e.right-m.left:m.right-e.left;i>r&&(r=i,this.minWidth=n,this.minWidthFrom=d,this.minWidthTo=p)}}h&&u==e.children.length-1&&(l+=h.bottom-m.bottom),d=p+o.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return"rtl"==getComputedStyle(t.dom).direction?Ti.RTL:Ti.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t,i=0;for(let o of e.children){if(!o.isText()||/[^ -~]/.test(o.text))return;let e=ri(o.dom);if(1!=e.length)return;i+=e[0].width,t=e[0].height}if(i)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:i/e.length,textHeight:t}}});if(e)return e;let t,i,o,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let e=ri(n.firstChild)[0];t=n.getBoundingClientRect().height,i=e&&e.width?e.width/27:7,o=e&&e.height?e.height:t,n.remove()}),{lineHeight:t,charWidth:i,textHeight:o}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,o=0;;o++){let n=o==t.viewports.length?null:t.viewports[o],s=n?n.from-1:this.view.state.doc.length;if(s>i){let o=(t.lineBlockAt(s).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(Kt.replace({widget:new en(o),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!n)break;i=n.to+1}return Kt.set(e)}updateDeco(){let e=1,t=this.view.state.facet(mo).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),i=!1,o=this.view.state.facet(fo).map((e,t)=>{let o="function"==typeof e;return o&&(i=!0),o?e(this.view):e});for(o.length&&(this.dynamicDecorationMap[e++]=i,t.push(ct.join(o))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e"function"==typeof e?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(to))try{if(t(this.view,e.range,e))return!0}catch(e){so(this.view.state,e,"scroll handler")}let t,{range:i}=e,o=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!o)return;!i.empty&&(t=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(o={left:Math.min(o.left,t.left),top:Math.min(o.top,t.top),right:Math.max(o.right,t.right),bottom:Math.max(o.bottom,t.bottom)});let n=Co(this.view),s={left:o.left-n.left,top:o.top-n.top,right:o.right+n.right,bottom:o.bottom+n.bottom},{offsetWidth:r,offsetHeight:a}=this.view.scrollDOM;!function(e,t,i,o,n,s,r,a){let l=e.ownerDocument,c=l.defaultView||window;for(let d=e,h=!1;d&&!h;)if(1==d.nodeType){let e,u=d==l.body,p=1,m=1;if(u)e=pi(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(d).position)&&(h=!0),d.scrollHeight<=d.clientHeight&&d.scrollWidth<=d.clientWidth){d=d.assignedSlot||d.parentNode;continue}let t=d.getBoundingClientRect();({scaleX:p,scaleY:m}=mi(d,t)),e={left:t.left,right:t.left+d.clientWidth*p,top:t.top,bottom:t.top+d.clientHeight*m}}let g=0,f=0;if("nearest"==n)t.top0&&t.bottom>e.bottom+f&&(f=t.bottom-e.bottom+r)):t.bottom>e.bottom&&(f=t.bottom-e.bottom+r,i<0&&t.top-f0&&t.right>e.right+g&&(g=t.right-e.right+s)):t.right>e.right&&(g=t.right-e.right+s,i<0&&t.lefte.bottom||t.lefte.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),d=d.assignedSlot||d.parentNode}else{if(11!=d.nodeType)break;d=d.host}}(this.view.scrollDOM,s,i.heade.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Ko(this.tile)}}function Ko(e,t){let i=null==t?void 0:t.get(e);if(1!=i){null==i&&e.destroy();for(let i of e.children)Ko(i,t)}}function Jo(e,t){let i=e.observer.selectionRange;if(!i.focusNode)return null;let o=xi(i.focusNode,i.focusOffset),n=ki(i.focusNode,i.focusOffset),s=o||n;if(n&&o&&n.node!=o.node){let t=Eo.get(n.node);if(!t||t.isText()&&t.text!=n.node.nodeValue)s=n;else if(e.docView.lastCompositionAfterCursor){let e=Eo.get(o.node);!e||e.isText()&&e.text!=o.node.nodeValue||(s=n)}}if(e.docView.lastCompositionAfterCursor=s!=o,!s)return null;let r=t-s.offset;return{from:r,to:r+s.node.nodeValue.length,node:s.node}}let Xo=class{constructor(){this.changes=[]}compareRange(e,t){ti(e,t,this.changes)}comparePoint(e,t){ti(e,t,this.changes)}boundChange(e){ti(e,e,this.changes)}};class Qo{constructor(){this.changes=[]}compareRange(e,t){ti(e,t,this.changes)}comparePoint(){}boundChange(e){ti(e,e,this.changes)}}class en extends Gt{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function tn(e,t,i,o,n){let s=Math.round((o-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&i.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;s+=Math.floor((n-i.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let r=e.state.sliceDoc(i.from,i.to);return i.from+function(e,t,i,o){for(let o=0,n=0;;){if(n>=t)return o;if(o==e.length)break;n+=9==e.charCodeAt(o)?i-n%i:1,o=ee(e,o)}return!0===o?-1:e.length}(r,s,e.state.tabSize)}function on(e,t,i,o){let n=function(e,t,i){let o=e.lineBlockAt(t);if(Array.isArray(o.type)){let e;for(let n of o.type){if(n.from>t)break;if(!(n.tot)return n;e&&(n.type!=Zt.Text||e.type==n.type&&!(i<0?n.fromt))||(e=n)}}return e||o}return o}(e,t.head,t.assoc||-1),s=o&&n.type==Zt.Text&&(e.lineWrapping||n.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>n.from?t.head-1:t.head):null;if(s){let t=e.dom.getBoundingClientRect(),o=e.textDirectionAt(n.from),r=e.posAtCoords({x:i==(o==Ti.LTR)?t.right-1:t.left+1,y:(s.top+s.bottom)/2});if(null!=r)return ue.cursor(r,i?-1:1)}return ue.cursor(i?n.to:n.from,i?-1:1)}function nn(e,t,i,o){let n=e.state.doc.lineAt(t.head),s=e.bidiSpans(n),r=e.textDirectionAt(n.from);for(let a=t,l=null;;){let t=Wi(n,s,r,a,i),c=Vi;if(!t){if(n.number==(i?e.state.doc.lines:1))return a;c="\n",n=e.state.doc.line(n.number+(i?1:-1)),s=e.bidiSpans(n),t=e.visualLineSide(n,!i)}if(l){if(!l(c))return a}else{if(!o)return t;l=o(c)}a=t}}function sn(e,t,i){for(;;){let o=0;for(let n of e)n.between(t-1,t+1,(e,n,s)=>{if(t>e&&tt(e)),i.from,t.head>i.from?-1:1);return o==i.from?i:ue.cursor(o,oe.viewState.docHeight)return new ln(e.state.doc.length,-1);if(n=e.elementAtHeight(c),null==o)break;if(n.type==Zt.Text){let t=e.docView.coordsAt(o<0?n.from:n.to,o);if(t&&(o<0?t.top<=c+r:t.bottom>=c+r))break}let t=e.viewState.heightOracle.textHeight/2;c=o>0?n.bottom+t:n.top-t}if(e.viewport.from>=n.to||e.viewport.to<=n.from){if(i)return null;if(n.type==Zt.Text){let t=tn(e,s,n,a,l);return new ln(t,t==n.from?1:-1)}}if(n.type!=Zt.Text)return c<(n.top+n.bottom)/2?new ln(n.from,1):new ln(n.to,-1);let d=e.docView.lineAt(n.from,2);return d&&d.length==n.length||(d=e.docView.lineAt(n.from,-2)),dn(e,d,n.from,a,l)}function dn(e,t,i,o,n){let s=-1,r=null,a=1e9,l=1e9,c=n,d=n,h=(e,t)=>{for(let i=0;io?h.left-o:h.rightn?h.top-n:h.bottom=c&&(c=Math.min(h.top,c),d=Math.max(h.bottom,d),p=0),(s<0||(p-l||u-a)<0)&&(s>=0&&l&&a=c+2?l=0:(s=t,a=u,l=p,r=h))}};if(t.isText()){for(let e=0;e(r.left+r.right)/2==(hn(e,s+i)==Ti.LTR)?new ln(i+ee(t.text,s),-1):new ln(i+s,1)}{if(!t.length)return new ln(i,1);for(let e=0;e(r.left+r.right)/2==(hn(e,s+i)==Ti.LTR)?new ln(d+c.length,-1):new ln(d,1)}}function hn(e,t){let i=e.state.doc.lineAt(t);return e.bidiSpans(i)[Ni.find(e.bidiSpans(i),t-i.from,-1,1)].dir}const un="";class pn{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(ot.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=un}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let o=e;;){this.findPointBefore(i,o);let e=this.text.length;this.readNode(o);let n=Eo.get(o),s=o.nextSibling;if(s==t){(null==n?void 0:n.breakAfter)&&!s&&i!=this.view.contentDOM&&this.lineBreak();break}let r=Eo.get(s);(n&&r?n.breakAfter:(n?n.breakAfter:ci(o))||ci(s)&&("BR"!=o.nodeName||(null==n?void 0:n.isWidget()))&&this.text.length>e)&&!gn(s,t)&&this.lineBreak(),o=s}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,o=this.lineSeparator?null:/\r\n?|\n/g;;){let n,s=-1,r=1;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),r=this.lineSeparator.length):(n=o.exec(t))&&(s=n.index,r=n[0].length),this.append(t.slice(i,s<0?t.length:s)),s<0)break;if(this.lineBreak(),r>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=r-1);i=s+r}}readNode(e){let t=Eo.get(e),i=t&&t.overrideDOMText;if(null!=i){this.findPointInside(e,i.length);for(let e=i.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(3==e.nodeType?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(mn(e,i.node,i.offset)?t:0))}}function mn(e,t,i){for(;;){if(!t||i-1;let{impreciseHead:n,impreciseAnchor:s}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=yn(e.docView.tile,t,i,0))){let t=n||s?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:i,anchorOffset:o,focusNode:n,focusOffset:s}=e.observer.selectionRange;i&&(t.push(new fn(i,o)),n==i&&s==o||t.push(new fn(n,s)));return t}(e),i=new pn(t,e);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(e,t){if(0==e.length)return null;let i=e[0].pos,o=2==e.length?e[1].pos:i;return i>-1&&o>-1?ue.single(i+t,o+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,i=n&&n.node==t.focusNode&&n.offset==t.focusOffset||!ni(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),o=s&&s.node==t.anchorNode&&s.offset==t.anchorOffset||!ni(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),r=e.viewport;if((Wt.ios||Wt.chrome)&&e.state.selection.main.empty&&i!=o&&(r.from>0||r.to-1&&e.state.selection.ranges.length>1?this.newSel=e.state.selection.replaceRange(ue.range(o,i)):this.newSel=ue.single(o,i)}}}function yn(e,t,i,o){if(e.isComposite()){let n=-1,s=-1,r=-1,a=-1;for(let l=0,c=o,d=o;li)return yn(o,t,i,c);if(h>=t&&-1==n&&(n=l,s=c),c>i&&o.dom.parentNode==e.dom){r=l,a=d;break}d=h,c=h+o.breakAfter}return{from:s,to:a<0?o+e.length:a,startDOM:(n?e.children[n-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:r=0?e.children[r].dom:null}}return e.isText()?{from:o,to:o+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function wn(e,t){let i,{newSel:o}=t,n=e.state.selection.main,s=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:o,to:r}=t.bounds,a=n.from,l=null;(8===s||Wt.android&&t.text.length=n.from&&i.to<=n.to&&(i.from!=n.from||i.to!=n.to)&&n.to-n.from-(i.to-i.from)<=4?i={from:n.from,to:n.to,insert:e.state.doc.slice(n.from,i.from).append(i.insert).append(e.state.doc.slice(i.to,n.to))}:e.state.doc.lineAt(n.from).toDate.now()-50?i={from:n.from,to:n.to,insert:e.state.toText(e.inputState.insertingText)}:Wt.chrome&&i&&i.from==i.to&&i.from==n.head&&"\n "==i.insert.toString()&&e.lineWrapping&&(o&&(o=ue.single(o.main.anchor-1,o.main.head-1)),i={from:n.from,to:n.to,insert:$.of([" "])}),i)return vn(e,i,o,s);if(o&&!xn(o,n)){let t=!1,i="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),i=e.inputState.lastSelectionOrigin,"select.pointer"==i&&(o=rn(e.state.facet(bo).map(t=>t(e)),o))),e.dispatch({selection:o,scrollIntoView:t,userEvent:i}),!0}return!1}function vn(e,t,i,o=-1){if(Wt.ios&&e.inputState.flushIOSKey(t))return!0;let n=e.state.selection.main;if(Wt.android&&(t.to==n.to&&(t.from==n.from||t.from==n.from-1&&" "==e.state.sliceDoc(t.from,n.from))&&1==t.insert.length&&2==t.insert.lines&&vi(e.contentDOM,"Enter",13)||(t.from==n.from-1&&t.to==n.to&&0==t.insert.length||8==o&&t.insert.lengthn.head)&&vi(e.contentDOM,"Backspace",8)||t.from==n.from&&t.to==n.to+1&&0==t.insert.length&&vi(e.contentDOM,"Delete",46)))return!0;let s,r=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>s||(s=function(e,t,i){let o,n=e.state,s=n.selection.main,r=-1;if(t.from==t.to&&t.froms.to){let i=t.fromt(e)),o,i);t.from==a&&(r=a)}if(r>-1)o={changes:t,selection:ue.cursor(t.from+t.insert.length,-1)};else if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!i||i.main.empty&&i.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let i=s.fromt.to?n.sliceDoc(t.to,s.to):"";o=n.replaceSelection(e.state.toText(i+t.insert.sliceString(0,void 0,e.state.lineBreak)+r))}else{let r=n.changes(t),a=i&&i.main.to<=r.newLength?i.main:void 0;if(n.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=s.to+10&&t.to>=s.to-10){let l,c=e.state.sliceDoc(t.from,t.to),d=i&&Jo(e,i.main.head);if(d){let e=t.insert.length-(t.to-t.from);l={from:d.from,to:d.to-e}}else l=e.state.doc.lineAt(s.head);let h=s.to-t.to;o=n.changeByRange(i=>{if(i.from==s.from&&i.to==s.to)return{changes:r,range:a||i.map(r)};let o=i.to-h,d=o-c.length;if(e.state.sliceDoc(d,o)!=c||o>=l.from&&d<=l.to)return{range:i};let u=n.changes({from:d,to:o,insert:t.insert}),p=i.to-s.to;return{changes:u,range:a?ue.range(Math.max(0,a.anchor+p),Math.max(0,a.head+p)):i.map(u)}})}else o={changes:r,selection:a&&n.selection.replaceRange(a)}}let a="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,a+=".compose",e.inputState.compositionFirstChange&&(a+=".start",e.inputState.compositionFirstChange=!1));return n.update(o,{userEvent:a,scrollIntoView:!0})}(e,t,i));return e.state.facet(Zi).some(i=>i(e,t.from,t.to,r,a))||e.dispatch(a()),!0}function Cn(e,t,i,o){let n=Math.min(e.length,t.length),s=0;for(;s0&&a>0&&e.charCodeAt(r-1)==t.charCodeAt(a-1);)r--,a--;if("end"==o){i-=r+Math.max(0,s-Math.min(r,a))-s}if(r=r?s-i:0,a=s+(a-r),r=s}else if(a=a?s-i:0,r=s+(r-a),a=s}return{from:s,toA:r,toB:a}}function xn(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class kn{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Wt.safari&&e.contentDOM.addEventListener("input",()=>null),Wt.gecko&&function(e){Yn.has(e)||(Yn.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let i,o=t.target;o!=e.contentDOM;o=o.parentNode)if(!o||11==o.nodeType||(i=Eo.get(o))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e)))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let e of i.observers)e(this.view,t);for(let e of i.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Tn(e),i=this.handlers,o=this.view.contentDOM;for(let e in t)if("scroll"!=e){let n=!t[e].handlers.length,s=i[e];s&&n!=!s.handlers.length&&(o.removeEventListener(e,this.handleEvent),s=null),s||o.addEventListener(e,this.handleEvent,{passive:n})}for(let e in i)"scroll"==e||t[e]||o.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&An.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Wt.android&&Wt.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!Wt.ios||e.synthetic||e.altKey||e.metaKey||!((t=En.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||Mn.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from0||!!(Wt.safari&&!Wt.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Sn(e,t){return(i,o)=>{try{return t.call(e,o,i)}catch(e){so(i.state,e)}}}function Tn(e){let t=Object.create(null);function i(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,o=e&&e.plugin.domEventHandlers,n=e&&e.plugin.domEventObservers;if(o)for(let e in o){let n=o[e];n&&i(e).handlers.push(Sn(t.value,n))}if(n)for(let e in n){let o=n[e];o&&i(e).observers.push(Sn(t.value,o))}}for(let e in On)i(e).handlers.push(On[e]);for(let e in Bn)i(e).observers.push(Bn[e]);return t}const En=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Mn="dthko",An=[16,17,18,20,91,92,224,225];function In(e){return.7*Math.max(0,e)+8}class Dn{constructor(e,t,i,o){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=o,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t,i,o=e.ownerDocument;for(let n=e.parentNode;n&&!(n==o.body||t&&i);)if(1==n.nodeType)!i&&n.scrollHeight>n.clientHeight&&(i=n),!t&&n.scrollWidth>n.clientWidth&&(t=n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}return{x:t,y:i}}(e.contentDOM),this.atoms=e.state.facet(bo).map(t=>t(e));let n=e.contentDOM.ownerDocument;n.addEventListener("mousemove",this.move=this.move.bind(this)),n.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(ot.allowMultipleSelections)&&function(e,t){let i=e.state.facet($i);return i.length?i[0](t):Wt.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:i}=e.state.selection;if(i.empty)return!1;let o=oi(e.root);if(!o||0==o.rangeCount)return!0;let n=o.getRangeAt(0).getClientRects();for(let e=0;e=t.clientX&&i.top<=t.clientY&&i.bottom>=t.clientY)return!0}return!1}(e,t)||1!=Vn(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(t=this.startEvent,i=e,Math.max(Math.abs(t.clientX-i.clientX),Math.abs(t.clientY-i.clientY))<10))return;var t,i;this.select(this.lastEvent=e);let o=0,n=0,s=0,r=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=Co(this.view);e.clientX-c.left<=s+6?o=-In(s-e.clientX):e.clientX+c.right>=a-6&&(o=In(e.clientX-a)),e.clientY-c.top<=r+6?n=-In(r-e.clientY):e.clientY+c.bottom>=l-6&&(n=In(e.clientY-l)),this.setScrollSpeed(o,n)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=rn(this.atoms,this.style.get(e,this.extend,this.multiple));!this.mustSelect&&i.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}const On=Object.create(null),Bn=Object.create(null),Ln=Wt.ie&&Wt.ie_version<15||Wt.ios&&Wt.webkit_version<604;function Pn(e,t,i){for(let o of e.facet(t))i=o(i,e);return i}function Nn(e,t){t=Pn(e.state,Ji,t);let i,{state:o}=e,n=1,s=o.toText(t),r=s.lines==o.selection.ranges.length;if(null!=Hn&&o.selection.ranges.every(e=>e.empty)&&Hn==s.toString()){let e=-1;i=o.changeByRange(i=>{let a=o.doc.lineAt(i.from);if(a.from==e)return{range:i};e=a.from;let l=o.toText((r?s.line(n++).text:t)+o.lineBreak);return{changes:{from:a.from,insert:l},range:ue.cursor(i.from+l.length)}})}else i=r?o.changeByRange(e=>{let t=s.line(n++);return{changes:{from:e.from,to:e.to,insert:t.text},range:ue.cursor(e.from+t.length)}}):o.replaceSelection(s);e.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Rn(e,t,i,o){if(1==o)return ue.cursor(t,i);if(2==o)return function(e,t,i=1){let o=e.charCategorizer(t),n=e.doc.lineAt(t),s=t-n.from;if(0==n.length)return ue.cursor(t);0==s?i=1:s==n.length&&(i=-1);let r=s,a=s;i<0?r=ee(n.text,s,!1):a=ee(n.text,s);let l=o(n.text.slice(r,a));for(;r>0;){let e=ee(n.text,r,!1);if(o(n.text.slice(e,r))!=l)break;r=e}for(;a{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},On.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),Bn.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},Bn.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},On.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let o of e.state.facet(ji))if(i=o(e,t),i)break;if(i||0!=t.button||(i=function(e,t){let i=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),o=Vn(t),n=e.state.selection;return{update(e){e.docChanged&&(i.pos=e.changes.mapPos(i.pos),n=n.map(e.changes))},get(t,s,r){let a,l=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c=Rn(e,l.pos,l.assoc,o);if(i.pos!=l.pos&&!s){let t=Rn(e,i.pos,i.assoc,o),n=Math.min(t.from,c.from),s=Math.max(t.to,c.to);c=n1&&(a=function(e,t){for(let i=0;i=t)return ue.create(e.ranges.slice(0,i).concat(e.ranges.slice(i+1)),e.mainIndex==i?0:e.mainIndex-(e.mainIndex>i?1:0))}return null}(n,l.pos))?a:r?n.addRange(c):ue.create([c])}}}(e,t)),i){let o=!e.hasFocus;e.inputState.startMouseSelection(new Dn(e,t,i,o)),o&&e.observer.ignore(()=>{yi(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let n=e.inputState.mouseSelection;if(n)return n.start(t),!1===n.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};const Fn=Wt.ie&&Wt.ie_version<=11;let qn=null,_n=0,zn=0;function Vn(e){if(!Fn)return e.detail;let t=qn,i=zn;return qn=e,zn=Date.now(),_n=!t||i>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(_n+1)%3:1}function Wn(e,t,i,o){if(!(i=Pn(e.state,Ji,i)))return;let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:s}=e.inputState,r=o&&s&&function(e,t){let i=e.state.facet(Ui);return i.length?i[0](t):Wt.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:s.from,to:s.to}:null,a={from:n,insert:i},l=e.state.changes(r?[r,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(n,-1),head:l.mapPos(n,1)},userEvent:r?"move.drop":"input.drop"}),e.inputState.draggedContent=null}On.dragstart=(e,t)=>{let{selection:{main:i}}=e.state;if(t.target.draggable){let o=e.docView.tile.nearest(t.target);if(o&&o.isWidget()){let e=o.posAtStart,t=e+o.length;(e>=i.to||t<=i.from)&&(i=ue.range(e,t))}}let{inputState:o}=e;return o.mouseSelection&&(o.mouseSelection.dragging=!0),o.draggedContent=i,t.dataTransfer&&(t.dataTransfer.setData("Text",Pn(e.state,Xi,e.state.sliceDoc(i.from,i.to))),t.dataTransfer.effectAllowed="copyMove"),!1},On.dragend=e=>(e.inputState.draggedContent=null,!1),On.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let i=t.dataTransfer.files;if(i&&i.length){let o=Array(i.length),n=0,s=()=>{++n==i.length&&Wn(e,t,o.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(o[e]=t.result),s()},t.readAsText(i[e])}return!0}{let i=t.dataTransfer.getData("Text");if(i)return Wn(e,t,i,!0),!0}return!1},On.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let i=Ln?null:t.clipboardData;return i?(Nn(e,i.getData("text/plain")||i.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{e.focus(),i.remove(),Nn(e,i.value)},50)}(e),!1)};let Hn=null;On.copy=On.cut=(e,t)=>{let i=oi(e.root);if(i&&!si(e.contentDOM,i))return!1;let{text:o,ranges:n,linewise:s}=function(e){let t=[],i=[],o=!1;for(let o of e.selection.ranges)o.empty||(t.push(e.sliceDoc(o.from,o.to)),i.push(o));if(!t.length){let n=-1;for(let{from:o}of e.selection.ranges){let s=e.doc.lineAt(o);s.number>n&&(t.push(s.text),i.push({from:s.from,to:Math.min(e.doc.length,s.to+1)})),n=s.number}o=!0}return{text:Pn(e,Xi,t.join(e.lineBreak)),ranges:i,linewise:o}}(e.state);if(!o&&!s)return!1;Hn=s?o:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=Ln?null:t.clipboardData;return r?(r.clearData(),r.setData("text/plain",o),!0):(function(e,t){let i=e.dom.parentNode;if(!i)return;let o=i.appendChild(document.createElement("textarea"));o.style.cssText="position: fixed; left: -10000px; top: 10px",o.value=t,o.focus(),o.selectionEnd=t.length,o.selectionStart=0,setTimeout(()=>{o.remove(),e.focus()},50)}(e,o),!1)};const $n=We.define();function Un(e,t){let i=[];for(let o of e.facet(Ki)){let n=o(e,t);n&&i.push(n)}return i.length?e.update({effects:i,annotations:$n.of(!0)}):null}function jn(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let i=Un(e.state,t);i?e.dispatch(i):e.update([])}},10)}Bn.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),jn(e)},Bn.blur=e=>{e.observer.clearSelectionRange(),jn(e)},Bn.compositionstart=Bn.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},Bn.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,Wt.chrome&&Wt.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},Bn.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},On.beforeinput=(e,t)=>{var i,o;if("insertText"!=t.inputType&&"insertCompositionText"!=t.inputType||(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){let o=null===(i=t.dataTransfer)||void 0===i?void 0:i.getData("text/plain"),n=t.getTargetRanges();if(o&&n.length){let t=n[0],i=e.posAtDOM(t.startContainer,t.startOffset),s=e.posAtDOM(t.endContainer,t.endOffset);return vn(e,{from:i,to:s,insert:e.state.toText(o)},null),!0}}let n;if(Wt.chrome&&Wt.android&&(n=En.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let t=(null===(o=window.visualViewport)||void 0===o?void 0:o.height)||0;setTimeout(()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return Wt.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),Wt.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>Bn.compositionend(e,t),20),!1};const Yn=new Set;const Gn=["pre-wrap","normal","pre-line","break-spaces"];let Zn=!1;function Kn(){Zn=!1}class Jn{constructor(e){this.lineWrapping=e,this.doc=$.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Gn.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=r||Math.abs(i-this.charWidth)>.1;if(this.lineWrapping=r,this.lineHeight=t,this.charWidth=i,this.textHeight=o,this.lineLength=n,a){this.heightSamples={};for(let e=0;e0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>ts&&(Zn=!0),this.height=e)}replace(e,t,i){return is.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,o){let n=this,s=i.doc;for(let r=o.length-1;r>=0;r--){let{fromA:a,toA:l,fromB:c,toB:d}=o[r],h=n.lineAt(a,es.ByPosNoHeight,i.setDoc(t),0,0),u=h.to>=l?h:n.lineAt(l,es.ByPosNoHeight,i,0,0);for(d+=u.to-l,l=u.to;r>0&&h.from<=o[r-1].toA;)a=o[r-1].fromA,c=o[r-1].fromB,r--,a2*n){let n=e[t-1];n.break?e.splice(--t,1,n.left,null,n.right):e.splice(--t,1,n.left,n.right),i+=1+n.break,o-=n.size}else{if(!(n>2*o))break;{let t=e[i];t.break?e.splice(i,1,t.left,null,t.right):e.splice(i,1,t.left,t.right),i+=2+t.break,n-=t.size}}else if(o=n&&s(this.lineAt(0,es.ByPos,i,o,n))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,o){return o&&o.from<=t&&o.more&&this.setMeasuredHeight(o),this.outdated=!1,this}toString(){return`block(${this.length})`}}class rs extends ss{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new Qn(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let o=i[0];return 1==i.length&&(o instanceof rs||o instanceof as&&4&o.flags)&&Math.abs(this.length-o.length)<10?(o instanceof as?o=new rs(o.length,this.height,this.spaceAbove):o.height=this.height,this.outdated||(o.outdated=!1),o):is.of(i)}updateHeight(e,t=0,i=!1,o){return o&&o.from<=t&&o.more?this.setMeasuredHeight(o):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class as extends is{constructor(e){super(e,0)}heightMetrics(e,t){let i,o=e.doc.lineAt(t).number,n=e.doc.lineAt(t+this.length).number,s=n-o+1,r=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*s);i=t/s,this.length>s+1&&(r=(this.height-t)/(this.length-s-1))}else i=this.height/s;return{firstLine:o,lastLine:n,perLine:i,perChar:r}}blockAt(e,t,i,o){let{firstLine:n,lastLine:s,perLine:r,perChar:a}=this.heightMetrics(t,o);if(t.lineWrapping){let n=o+(e0){let e=i[i.length-1];e instanceof as?i[i.length-1]=new as(e.length+o):i.push(null,new as(o-1))}if(e>0){let t=i[0];t instanceof as?i[0]=new as(e+t.length):i.unshift(new as(e-1),null)}return is.of(i)}decomposeLeft(e,t){t.push(new as(e-1),null)}decomposeRight(e,t){t.push(null,new as(this.length-e-1))}updateHeight(e,t=0,i=!1,o){let n=t+this.length;if(o&&o.from<=t+this.length&&o.more){let i=[],s=Math.max(t,o.from),r=-1;for(o.from>t&&i.push(new as(o.from-t-1).updateHeight(e,t));s<=n&&o.more;){let t=e.doc.lineAt(s).length;i.length&&i.push(null);let n=o.heights[o.index++],a=0;n<0&&(a=-n,n=o.heights[o.index++]),-1==r?r=n:Math.abs(n-r)>=ts&&(r=-2);let l=new rs(t,n,a);l.outdated=!1,i.push(l),s+=t+1}s<=n&&i.push(null,new as(n-s).updateHeight(e,s));let a=is.of(i);return(r<0||Math.abs(a.height-this.height)>=ts||Math.abs(r-this.heightMetrics(e,t).perLine)>=ts)&&(Zn=!0),os(this,a)}return(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class ls extends is{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return 1&this.flags}blockAt(e,t,i,o){let n=i+this.left.height;return er))return l;let c=t==es.ByPosNoHeight?es.ByPosNoHeight:es.ByPos;return a?l.join(this.right.lineAt(r,c,i,s,r)):this.left.lineAt(r,c,i,o,n).join(l)}forEachLine(e,t,i,o,n,s){let r=o+this.left.height,a=n+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,i,r,a,s);else{let l=this.lineAt(a,es.ByPos,i,o,n);e=e&&l.from<=t&&s(l),t>l.to&&this.right.forEachLine(l.to+1,t,i,r,a,s)}}replace(e,t,i){let o=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-o,t-o,i));let n=[];e>0&&this.decomposeLeft(e,n);let s=n.length;for(let e of i)n.push(e);if(e>0&&cs(n,s-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,o=i+this.break;if(e>=o)return this.right.decomposeRight(e-o,t);e2*t.size||t.size>2*e.size?is.of(this.break?[e,null,t]:[e,t]):(this.left=os(this.left,e),this.right=os(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,o){let{left:n,right:s}=this,r=t+n.length+this.break,a=null;return o&&o.from<=t+n.length&&o.more?a=n=n.updateHeight(e,t,i,o):n.updateHeight(e,t,i),o&&o.from<=r+s.length&&o.more?a=s=s.updateHeight(e,r,i,o):s.updateHeight(e,r,i),a?this.balanced(n,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cs(e,t){let i,o;null==e[t]&&(i=e[t-1])instanceof as&&(o=e[t+1])instanceof as&&e.splice(t-1,3,new as(i.length+1+o.length))}class ds{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof rs?i.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new rs(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=5)&&this.addLineDeco(o,n,s)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new rs(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new as(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof rs)return e;let t=new rs(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let o=this.ensureLine();o.length+=i,o.collapsed+=i,o.widgetHeight=Math.max(o.widgetHeight,e),o.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof rs||this.isCovered?(this.writtenToi.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=o.overflow){let o=i.getBoundingClientRect();s=Math.max(s,o.left),r=Math.min(r,o.right),a=Math.max(a,o.top),l=Math.min(t==e.parentNode?n.innerHeight:l,o.bottom)}t="absolute"==o.position||"fixed"==o.position?i.offsetParent:i.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:s-i.left,right:Math.max(s,r)-i.left,top:a-(i.top+t),bottom:Math.max(a,l)-(i.top+t)}}function ps(e,t){let i=e.getBoundingClientRect();return{left:0,right:i.right-i.left,top:t,bottom:i.bottom-(i.top+t)}}class ms{constructor(e,t,i,o){this.from=e,this.to=t,this.size=i,this.displaySize=o}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new Jn(t),this.stateDeco=Cs(e),this.heightMap=is.empty().applyChanges(this.stateDeco,$.empty,this.heightOracle.setDoc(e.doc),[new ko(0,0,0,e.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Kt.set(this.lineGaps.map(e=>e.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let o=i?t.head:t.anchor;if(!e.some(({from:e,to:t})=>o>=e&&o<=t)){let{from:t,to:i}=this.lineBlockAt(o);e.push(new bs(t,i))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?vs:new xs(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(ks(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=Cs(this.state);let o=e.changedRanges,n=ko.extendWithRanges(o,function(e,t,i){let o=new hs;return ct.compare(e,t,i,o,0),o.changes}(i,this.stateDeco,e?e.changes:ne.empty(this.state.doc.length))),s=this.heightMap.height,r=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Kn(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),n),(this.heightMap.height!=s||Zn)&&(e.flags|=2),r?(this.scrollAnchorPos=e.changes.mapPos(r.from,-1),this.scrollAnchorHeight=r.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=s);let a=n.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||2&e.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(eo)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),o=this.heightOracle,n=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Ti.RTL:Ti.LTR;let s=this.heightOracle.mustRefreshForWrapping(n)||this.mustMeasureContent,r=t.getBoundingClientRect(),a=s||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let l=0,c=0;if(r.width&&r.height){let{scaleX:e,scaleY:i}=mi(t,r);(e>.005&&Math.abs(this.scaleX-e)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=e,this.scaleY=i,l|=16,s=a=!0)}let d=(parseInt(i.paddingTop)||0)*this.scaleY,h=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==d&&this.paddingBottom==h||(this.paddingTop=d,this.paddingBottom=h,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(o.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let u=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=u&&(this.scrollAnchorHeight=-1,this.scrollTop=u),this.scrolledToBottom=Ci(e.scrollDOM);let p=(this.printing?ps:us)(t,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let f=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(f!=this.inView&&(this.inView=f,f&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(e){let t=e.getBoundingClientRect(),i=e.ownerDocument.defaultView||window;return t.left0&&t.top0}(e.dom))return 0;let b=r.width;if(this.contentDOMWidth==b&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=r.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(t)&&(s=!0),s||o.lineWrapping&&Math.abs(b-this.contentDOMWidth)>o.charWidth){let{lineHeight:i,charWidth:r,textHeight:a}=e.docView.measureTextSize();s=i>0&&o.refresh(n,i,r,a,Math.max(5,b/r),t),s&&(e.docView.minWidth=0,l|=16)}m>0&&g>0?c=Math.max(m,g):m<0&&g<0&&(c=Math.min(m,g)),Kn();for(let i of this.viewports){let n=i.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(i);this.heightMap=(s?is.empty().applyChanges(this.stateDeco,$.empty,this.heightOracle,[new ko(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(o,0,s,new Xn(i.from,n))}Zn&&(l|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return y&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),o=this.heightMap,n=this.heightOracle,{visibleTop:s,visibleBottom:r}=this,a=new bs(o.lineAt(s-1e3*i,es.ByHeight,n,0,0).from,o.lineAt(r+1e3*(1-i),es.ByHeight,n,0,0).to);if(t){let{head:e}=t.range;if(ea.to){let i,s=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),r=o.lineAt(e,es.ByPos,n,0,0);i="center"==t.y?(r.top+r.bottom)/2-s/2:"start"==t.y||"nearest"==t.y&&e=r+Math.max(10,Math.min(i,250)))&&o>s-2e3&&n>1,s=o<<1;if(this.defaultTextDirection!=Ti.LTR&&!i)return[];let r=[],a=(o,s,l,c)=>{if(s-oo&&ee.from>=l.from&&e.to<=l.to&&Math.abs(e.from-o)e.fromt));if(!u){if(se.from<=s&&e.to>=s)){let e=t.moveToLineBoundary(ue.cursor(s),!1,!0).head;e>o&&(s=e)}let e=this.gapSize(l,o,s,c);u=new ms(o,s,e,i||e<2e6?e:2e6)}r.push(u)},l=t=>{if(t.lengthn&&(o.push({from:n,to:e}),s+=e-n),n=t}},20),n2e6)for(let i of e)i.from>=t.from&&i.fromt.from&&a(t.from,r,t,n),le.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];ct.spans(t,this.viewport.from,this.viewport.to,{span(e,t){i.push({from:e,to:t})},point(){}},20);let o=0;if(i.length!=this.visibleRanges.length)o=12;else for(let t=0;t=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||ks(this.heightMap.lineAt(e,es.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||ks(this.heightMap.lineAt(this.scaler.fromDOM(e),es.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return ks(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class bs{constructor(e,t){this.from=e,this.to=t}}function ys({total:e,ranges:t},i){if(i<=0)return t[0].from;if(i>=1)return t[t.length-1].to;let o=Math.floor(e*i);for(let e=0;;e++){let{from:i,to:n}=t[e],s=n-i;if(o<=s)return i+o;o-=s}}function ws(e,t){let i=0;for(let{from:o,to:n}of e.ranges){if(t<=n){i+=t-o;break}i+=n-o}return i/e.total}const vs={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function Cs(e){let t=e.facet(mo).filter(e=>"function"!=typeof e),i=e.facet(fo).filter(e=>"function"!=typeof e);return i.length&&t.push(ct.join(i)),t}class xs{constructor(e,t,i){let o=0,n=0,s=0;this.viewports=i.map(({from:i,to:n})=>{let s=t.lineAt(i,es.ByPos,e,0,0).top,r=t.lineAt(n,es.ByPos,e,0,0).bottom;return o+=r-s,{from:i,to:n,top:s,bottom:r,domTop:0,domBottom:0}}),this.scale=(7e6-o)/(t.height-o);for(let e of this.viewports)e.domTop=s+(e.top-n)*this.scale,s=e.domBottom=e.domTop+(e.bottom-e.top),n=e.bottom}toDOM(e){for(let t=0,i=0,o=0;;t++){let n=tt.from==e.viewports[i].from&&t.to==e.viewports[i].to))}}function ks(e,t){if(1==t.scale)return e;let i=t.toDOM(e.top),o=t.toDOM(e.bottom);return new Qn(e.from,e.length,i,o-i,Array.isArray(e._content)?e._content.map(e=>ks(e,t)):e._content)}const Ss=ge.define({combine:e=>e.join(" ")}),Ts=ge.define({combine:e=>e.indexOf(!0)>-1}),Es=St.newName(),Ms=St.newName(),As=St.newName(),Is={"&light":"."+Ms,"&dark":"."+As};function Ds(e,t,i){return new St(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!i||!i[t])throw new RangeError(`Unsupported selector: ${t}`);return i[t]}):e+" "+t})}const Os=Ds("."+Es,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Is),Bs={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ls=Wt.ie&&Wt.ie_version<=11;class Ps{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new gi,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(Wt.ie&&Wt.ie_version<=11||Wt.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!Wt.android||!1===e.constructor.EDIT_CONTEXT||Wt.chrome&&Wt.chrome_version<126||(this.editContext=new Fs(e),e.state.facet(ro)&&(e.contentDOM.editContext=this.editContext.editContext)),Ls&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){("change"!=e.type&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,o=this.selectionRange;if(i.state.facet(ro)?i.root.activeElement!=this.dom:!si(this.dom,o))return;let n=o.anchorNode&&i.docView.tile.nearest(o.anchorNode);n&&n.isWidget()&&n.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(Wt.ie&&Wt.ie_version<=11||Wt.android&&Wt.chrome)&&!i.state.selection.main.empty&&o.focusNode&&ai(o.focusNode,o.focusOffset,o.anchorNode,o.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=oi(e.root);if(!t)return!1;let i=Wt.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let i=t.getComposedRanges(e.root)[0];if(i)return Rs(e,i)}let i=null;function o(e){e.preventDefault(),e.stopImmediatePropagation(),i=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",o,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",o,!0),i?Rs(e,i):null}(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let o=si(this.dom,i);return o&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let e=this.delayedAndroidKey;if(e){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&vi(this.dom,e.key,e.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,o=!1;for(let n of e){let e=this.readMutation(n);e&&(e.typeOver&&(o=!0),-1==t?({from:t,to:i}=e):(t=Math.min(e.from,t),i=Math.max(e.to,i)))}return{from:t,to:i,typeOver:o}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),o=this.selectionChanged&&si(this.dom,this.selectionRange);if(e<0&&!o)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let n=new bn(this.view,e,t,i);return this.view.docView.domChanged={newSel:n.newSel?n.newSel.main:null},n}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,o=wn(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!xn(this.view.state.selection,t.newSel.main))&&this.view.update([]),o}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){let i=Ns(t,e.previousSibling||e.target.previousSibling,-1),o=Ns(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:o?t.posBefore(o):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(ro)!=e.state.facet(ro)&&(e.view.contentDOM.editContext=e.state.facet(ro)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect();for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Ns(e,t,i){for(;t;){let o=Eo.get(t);if(o&&o.parent==e)return o;let n=t.parentNode;t=n!=e.dom?n:i>0?t.nextSibling:t.previousSibling}return null}function Rs(e,t){let i=t.startContainer,o=t.startOffset,n=t.endContainer,s=t.endOffset,r=e.docView.domAtPos(e.state.selection.main.anchor,1);return ai(r.node,r.offset,n,s)&&([i,o,n,s]=[n,s,i,o]),{anchorNode:i,anchorOffset:o,focusNode:n,focusOffset:s}}class Fs{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let o=e.state.selection.main,{anchor:n,head:s}=o,r=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:r,drifted:!1});let l=a-r>i.text.length;r==this.from&&nthis.to&&(a=n);let c=Cn(e.state.sliceDoc(r,a),i.text,(l?o.from:o.to)-r,l?"end":null);if(!c){let t=ue.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));return void(xn(t,o)||e.dispatch({selection:t,userEvent:"select"}))}let d={from:c.from+r,to:c.toA+r,insert:$.of(i.text.slice(c.from,c.toB).split("\n"))};if((Wt.mac||Wt.android)&&d.from==s-1&&/^\. ?$/.test(i.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(d={from:r,to:a,insert:$.of([i.text.replace("."," ")])}),this.pendingContextChange=d,!e.state.readOnly){let t=this.to-this.from+(d.to-d.from+d.insert.length);vn(e,d,ue.single(this.toEditorPos(i.selectionStart,t),this.toEditorPos(i.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),d.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let o=[],n=null;for(let t=this.toEditorPos(i.rangeStart),s=this.toEditorPos(i.rangeEnd);t{let i=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,o=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(o)){let n=this.toEditorPos(e.rangeStart),s=this.toEditorPos(e.rangeEnd);if(n{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=oi(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,o=this.pendingContextChange;return e.changes.iterChanges((n,s,r,a,l)=>{if(i)return;let c=l.length-(s-n);if(o&&s>=o.to){if(o.from==n&&o.to==s&&o.insert.eq(l))return o=this.pendingContextChange=null,t+=c,void(this.to+=c);o=null,this.revertPending(e.state)}if(n+=t,(s+=t)<=this.from)this.from+=c,this.to+=c;else if(nthis.to||this.to-this.from+l.length>3e4)return void(i=!0);this.editContext.updateText(this.toContextPos(n),this.toContextPos(s),l.toString()),this.to+=c}t+=c}),o&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(e=>!e.isUserEvent("input.type")&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):this.applyEdits(e)&&this.rangeIsValid(e.state)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(e.state)),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),o=this.toContextPos(t.head);this.editContext.selectionStart==i&&this.editContext.selectionEnd==o||this.editContext.updateSelection(i,o)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class qs{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(e=>e.forEach(e=>i(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new fs(e.state||ot.create(e)),e.scrollTo&&e.scrollTo.is(oo)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(lo).map(e=>new ho(e));for(let e of this.plugins)e.update(this);this.observer=new Ps(this),this.inputState=new kn(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Zo(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=!0,this.requestMeasure()})}dispatch(...e){let t=1==e.length&&e[0]instanceof je?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,i=!1,o=!1,n=this.state;for(let t of e){if(t.startState!=n)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");n=t.state}if(this.destroyed)return void(this.viewState.state=n);let s=this.hasFocus,r=0,a=null;e.some(e=>e.annotation($n))?(this.inputState.notifiedFocused=s,r=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,a=Un(n,s),a||(r=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(n.doc)||!this.state.selection.eq(n.selection))&&(c=null)):this.observer.clear(),n.facet(ot.phrases)!=this.state.facet(ot.phrases))return this.setState(n);t=So.create(this,n,e),t.flags|=r;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(d&&(d=d.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;d=new io(e.empty?e:ue.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(oo)&&(d=e.value.clip(this.state))}this.viewState.update(t,d),this.bidiCache=Vs.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),i=this.docView.update(t),this.state.facet(xo)!=this.styleModules&&this.mountStyles(),o=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(i,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(t.startState.facet(Ss)!=t.state.facet(Ss)&&(this.viewState.mustMeasureContent=!0),(i||o||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(Gi))try{e(t)}catch(e){so(this.state,e,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!wn(this,c)&&l.force&&vi(this.contentDOM,l.key,l.keyCode)})}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new fs(e),this.plugins=e.facet(lo).map(e=>new ho(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new Zo(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(lo),i=e.state.facet(lo);if(t!=i){let o=[];for(let n of i){let i=t.indexOf(n);if(i<0)o.push(new ho(n));else{let t=this.plugins[i];t.mustUpdate=e,o.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=o,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,o=i.scrollTop*this.scaleY,{scrollAnchorPos:n,scrollAnchorHeight:s}=this.viewState;Math.abs(o-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(s<0)if(Ci(i))n=-1,s=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(o);n=e.from,s=e.top}this.updateState=1;let r=this.viewState.measure(this);if(!r&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let a=[];4&r||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(e=>{try{return e.read(this)}catch(e){return so(this.state,e),zs}}),c=So.create(this,this.state,[]),d=!1;c.flags|=r,t?t.flags|=r:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),d=this.docView.update(c),d&&this.docViewUpdate());for(let e=0;e1||e<-1){o+=e,i.scrollTop=o/this.scaleY,s=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(Gi))e(t)}get themeClasses(){return Es+" "+(this.state.facet(Ts)?As:Ms)+" "+this.state.facet(Ss)}updateAttrs(){let e=Ws(this,uo,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ro)?"true":"false",class:"cm-content",style:`${Wt.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Ws(this,po,t);let i=this.observer.ignore(()=>{let i=jt(this.contentDOM,this.contentAttrs,t),o=jt(this.dom,this.editorAttrs,e);return i||o});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let e of i.effects)if(e.is(qs.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(xo);let e=this.state.facet(qs.cspNonce);St.mount(this.root,this.styleModules.concat(Os).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(null!=e.key)for(let t=0;tt.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return an(this,e,nn(this,e,t,i))}moveByGroup(e,t){return an(this,e,nn(this,e,t,t=>function(e,t,i){let o=e.state.charCategorizer(t),n=o(i);return e=>{let t=o(e);return n==Qe.Space&&(n=t),n==t}}(this,e.head,t)))}visualLineSide(e,t){let i=this.bidiSpans(e),o=this.textDirectionAt(e.from),n=i[t?i.length-1:0];return ue.cursor(n.side(t,o)+e.from,n.forward(!t,o)?1:-1)}moveToLineBoundary(e,t,i=!0){return on(this,e,t,i)}moveVertically(e,t,i){return an(this,e,function(e,t,i,o){let n=t.head,s=i?1:-1;if(n==(i?e.state.doc.length:0))return ue.cursor(n,t.assoc);let r,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(n,t.assoc||-1),d=e.documentTop;if(c)null==a&&(a=c.left-l.left),r=s<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(n);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(n-t.from))),r=(s<0?t.top:t.bottom)+d}let h=cn(e,{x:l.left+a,y:r+(null!=o?o:e.viewState.heightOracle.textHeight>>1)*s},!1,s);return ue.cursor(h.pos,h.assoc,void 0,a)}(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=cn(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),cn(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let o=this.state.doc.lineAt(e),n=this.bidiSpans(o);return ui(i,n[Ni.find(n,e-o.from,-1,t)].dir==Ti.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Qi)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>_s)return zi(e.length);let t,i=this.textDirectionAt(e.from);for(let o of this.bidiCache)if(o.from==e.from&&o.dir==i&&(o.fresh||Ri(o.isolates,t=wo(this,e))))return o.order;t||(t=wo(this,e));let o=function(e,t,i){if(!e)return[new Ni(0,0,t==Mi?1:0)];if(t==Ei&&!i.length&&!Pi.test(e))return zi(e.length);if(i.length)for(;e.length>Fi.length;)Fi[Fi.length]=256;let o=[],n=t==Ei?0:1;return _i(e,n,n,i,0,e.length,o),o}(e.text,i,t);return this.bidiCache.push(new Vs(e.from,e.to,i,t,!0,o)),o}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Wt.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{yi(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return oo.of(new io("number"==typeof e?ue.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return oo.of(new io(ue.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return co.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return co.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=St.newName(),o=[Ss.of(i),xo.of(Ds(`.${i}`,e))];return t&&t.dark&&o.push(Ts.of(!0)),o}static baseTheme(e){return Ae.lowest(xo.of(Ds("."+Es,e,Is)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),o=i&&Eo.get(i)||Eo.get(e);return(null===(t=null==o?void 0:o.root)||void 0===t?void 0:t.view)||null}}qs.styleModule=xo,qs.inputHandler=Zi,qs.clipboardInputFilter=Ji,qs.clipboardOutputFilter=Xi,qs.scrollHandler=to,qs.focusChangeEffect=Ki,qs.perLineTextDirection=Qi,qs.exceptionSink=Yi,qs.updateListener=Gi,qs.editable=ro,qs.mouseSelectionStyle=ji,qs.dragMovesSelection=Ui,qs.clickAddsSelectionRange=$i,qs.decorations=mo,qs.blockWrappers=go,qs.outerDecorations=fo,qs.atomicRanges=bo,qs.bidiIsolatedRanges=yo,qs.scrollMargins=vo,qs.darkTheme=Ts,qs.cspNonce=ge.define({combine:e=>e.length?e[0]:""}),qs.contentAttributes=po,qs.editorAttributes=uo,qs.lineWrapping=qs.contentAttributes.of({class:"cm-lineWrapping"}),qs.announce=Ue.define();const _s=4096,zs={};class Vs{constructor(e,t,i,o,n,s){this.from=e,this.to=t,this.dir=i,this.isolates=o,this.fresh=n,this.order=s}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let i=[],o=e.length?e[e.length-1].dir:Ti.LTR;for(let n=Math.max(0,e.length-10);n=0;n--){let t=o[n],s="function"==typeof t?t(e):t;s&&Ht(s,i)}return i}class Hs extends nt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Hs.prototype.elementClass="",Hs.prototype.toDOM=void 0,Hs.prototype.mapMode=ie.TrackBefore,Hs.prototype.startSide=Hs.prototype.endSide=-1,Hs.prototype.point=!0;let $s=0;class Us{constructor(e,t,i,o){this.name=e,this.set=t,this.base=i,this.modified=o,this.id=$s++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i="string"==typeof e?e:"?";if(e instanceof Us&&(t=e),null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let o=new Us(i,[],null,[]);if(o.set.push(o),t)for(let e of t.set)o.set.push(e);return o}static defineModifier(e){let t=new Ys(e);return e=>e.modified.indexOf(t)>-1?e:Ys.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let js=0;class Ys{constructor(e){this.name=e,this.instances=[],this.id=js++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(i=>{return i.base==e&&(o=t,n=i.modified,o.length==n.length&&o.every((e,t)=>e==n[t]));var o,n});if(i)return i;let o=[],n=new Us(e.name,o,e,t);for(let e of t)e.instances.push(n);let s=function(e){let t=[[]];for(let i=0;it.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of s)o.push(Ys.get(t,e));return n}}function Gs(e){let t=Object.create(null);for(let i in e){let o=e[i];Array.isArray(o)||(o=[o]);for(let e of i.split(" "))if(e){let i=[],n=2,s=e;for(let t=0;;){if("..."==s&&t>0&&t+3==e.length){n=1;break}let o=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!o)throw new RangeError("Invalid path: "+e);if(i.push("*"==o[0]?"":'"'==o[0][0]?JSON.parse(o[0]):o[0]),t+=o[0].length,t==e.length)break;let r=e[t++];if(t==e.length&&"!"==r){n=0;break}if("/"!=r)throw new RangeError("Invalid path: "+e);s=e.slice(t)}let r=i.length-1,a=i[r];if(!a)throw new RangeError("Invalid path: "+e);let l=new Ks(o,n,r>0?i.slice(0,r):null);t[a]=l.sort(t[a])}}return Zs.add(t)}const Zs=new s({combine(e,t){let i,o,n;for(;e||t;){if(!e||t&&e.depth>=t.depth?(n=t,t=t.next):(n=e,e=e.next),i&&i.mode==n.mode&&!n.context&&!i.context)continue;let s=new Ks(n.tags,n.mode,n.context);i?i.next=s:o=s,i=s}return o}});class Ks{constructor(e,t,i,o){this.tags=e,this.mode=t,this.context=i,this.next=o}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth{let t=n;for(let o of e)for(let e of o.set){let o=i[e.id];if(o){t=t?t+" "+o:o;break}}return t},scope:o}}Ks.empty=new Ks([],2,null);const Xs=Us.define,Qs=Xs(),er=Xs(),tr=Xs(er),ir=Xs(er),or=Xs(),nr=Xs(or),sr=Xs(or),rr=Xs(),ar=Xs(rr),lr=Xs(),cr=Xs(),dr=Xs(),hr=Xs(dr),ur=Xs(),pr={comment:Qs,lineComment:Xs(Qs),blockComment:Xs(Qs),docComment:Xs(Qs),name:er,variableName:Xs(er),typeName:tr,tagName:Xs(tr),propertyName:ir,attributeName:Xs(ir),className:Xs(er),labelName:Xs(er),namespace:Xs(er),macroName:Xs(er),literal:or,string:nr,docString:Xs(nr),character:Xs(nr),attributeValue:Xs(nr),number:sr,integer:Xs(sr),float:Xs(sr),bool:Xs(or),regexp:Xs(or),escape:Xs(or),color:Xs(or),url:Xs(or),keyword:lr,self:Xs(lr),null:Xs(lr),atom:Xs(lr),unit:Xs(lr),modifier:Xs(lr),operatorKeyword:Xs(lr),controlKeyword:Xs(lr),definitionKeyword:Xs(lr),moduleKeyword:Xs(lr),operator:cr,derefOperator:Xs(cr),arithmeticOperator:Xs(cr),logicOperator:Xs(cr),bitwiseOperator:Xs(cr),compareOperator:Xs(cr),updateOperator:Xs(cr),definitionOperator:Xs(cr),typeOperator:Xs(cr),controlOperator:Xs(cr),punctuation:dr,separator:Xs(dr),bracket:hr,angleBracket:Xs(hr),squareBracket:Xs(hr),paren:Xs(hr),brace:Xs(hr),content:rr,heading:ar,heading1:Xs(ar),heading2:Xs(ar),heading3:Xs(ar),heading4:Xs(ar),heading5:Xs(ar),heading6:Xs(ar),contentSeparator:Xs(rr),list:Xs(rr),quote:Xs(rr),emphasis:Xs(rr),strong:Xs(rr),link:Xs(rr),monospace:Xs(rr),strikethrough:Xs(rr),inserted:Xs(),deleted:Xs(),changed:Xs(),invalid:Xs(),meta:ur,documentMeta:Xs(ur),annotation:Xs(ur),processingInstruction:Xs(ur),definition:Us.defineModifier("definition"),constant:Us.defineModifier("constant"),function:Us.defineModifier("function"),standard:Us.defineModifier("standard"),local:Us.defineModifier("local"),special:Us.defineModifier("special")};for(let e in pr){let t=pr[e];t instanceof Us&&(t.name=e)}var mr;Js([{tag:pr.link,class:"tok-link"},{tag:pr.heading,class:"tok-heading"},{tag:pr.emphasis,class:"tok-emphasis"},{tag:pr.strong,class:"tok-strong"},{tag:pr.keyword,class:"tok-keyword"},{tag:pr.atom,class:"tok-atom"},{tag:pr.bool,class:"tok-bool"},{tag:pr.url,class:"tok-url"},{tag:pr.labelName,class:"tok-labelName"},{tag:pr.inserted,class:"tok-inserted"},{tag:pr.deleted,class:"tok-deleted"},{tag:pr.literal,class:"tok-literal"},{tag:pr.string,class:"tok-string"},{tag:pr.number,class:"tok-number"},{tag:[pr.regexp,pr.escape,pr.special(pr.string)],class:"tok-string2"},{tag:pr.variableName,class:"tok-variableName"},{tag:pr.local(pr.variableName),class:"tok-variableName tok-local"},{tag:pr.definition(pr.variableName),class:"tok-variableName tok-definition"},{tag:pr.special(pr.variableName),class:"tok-variableName2"},{tag:pr.definition(pr.propertyName),class:"tok-propertyName tok-definition"},{tag:pr.typeName,class:"tok-typeName"},{tag:pr.namespace,class:"tok-namespace"},{tag:pr.className,class:"tok-className"},{tag:pr.macroName,class:"tok-macroName"},{tag:pr.propertyName,class:"tok-propertyName"},{tag:pr.operator,class:"tok-operator"},{tag:pr.comment,class:"tok-comment"},{tag:pr.meta,class:"tok-meta"},{tag:pr.invalid,class:"tok-invalid"},{tag:pr.punctuation,class:"tok-punctuation"}]);const gr=new s,fr=new s;class br{constructor(e,t,i=[],o=""){this.data=e,this.name=o,ot.prototype.hasOwnProperty("tree")||Object.defineProperty(ot.prototype,"tree",{get(){return wr(this)}}),this.parser=t,this.extension=[Ar.of(this),ot.languageData.of((e,t,i)=>{let o=yr(e,t,i),n=o.type.prop(gr);if(!n)return[];let s=e.facet(n),r=o.type.prop(fr);if(r){let n=o.resolve(t-o.from,i);for(let t of r)if(t.test(n,e)){let i=e.facet(t.facet);return"replace"==t.type?i:i.concat(s)}}return s})].concat(i)}isActiveAt(e,t,i=-1){return yr(e,t,i).type.prop(gr)==this.data}findRegions(e){let t=e.facet(Ar);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],o=(e,t)=>{if(e.prop(gr)==this.data)return void i.push({from:t,to:t+e.length});let n=e.prop(s.mounted);if(n){if(n.tree.prop(gr)==this.data){if(n.overlay)for(let e of n.overlay)i.push({from:e.from+t,to:e.to+t});else i.push({from:t,to:t+e.length});return}if(n.overlay){let e=i.length;if(o(n.tree,n.overlay[0].from+t),i.length>e)return}}for(let i=0;i