@meowdown/core 0.59.0 → 0.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -139,8 +139,6 @@ The clipboard pipeline ships inside `defineEditorExtension`. Copying writes two
139
139
 
140
140
  Enter at the end of the document's first heading (the title line) can start a fresh empty bullet instead of a plain paragraph: [`defineBulletAfterHeading`](https://npmx.dev/package-docs/@meowdown%2Fcore#function-defineBulletAfterHeading) (`@meowdown/react`'s `bulletAfterHeading` prop). Not part of `defineEditorExtension`.
141
141
 
142
- Find-in-document ships inside `defineEditorExtension`, built on [prosemirror-search](https://github.com/ProseMirror/prosemirror-search). `editor.commands.setSearchQuery(query)` highlights every match and selects the first one at or after the caret (an empty query clears the highlights and leaves the selection alone); `editor.commands.findNext()` and `findPrev()` walk the matches and wrap at the document edges. Read the match count with `getSearchStatus(state)` (`{ total, active }`, where `active` is one-based and `0` means the selection is not on a match), or subscribe with [`defineSearchStatusHandler`](https://npmx.dev/package-docs/@meowdown%2Fcore#function-defineSearchStatusHandler) (`@meowdown/react`'s `onSearchChange` prop) to drive a match counter. Search runs over the Markdown source, so a match can land in a run that hide and focus modes render invisible (a link destination, a link title, math source); the match that is currently selected reveals itself, the same way focus mode reveals the unit under the caret. Style the highlights with `--meowdown-find-match` and `--meowdown-find-match-active`.
143
-
144
142
  An arrow press that can move the caret no further can notify the host, so it can move focus elsewhere (a previous/next note or page): [`defineExitBoundaryHandler`](https://npmx.dev/package-docs/@meowdown%2Fcore#function-defineExitBoundaryHandler) (`@meowdown/react`'s `onExitBoundary` prop). Not part of `defineEditorExtension`.
145
143
 
146
144
  ## API
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Editor, Extension, ExtractMarkBuilders, ExtractNodeBuilders, PlainExten
2
2
  import { CodeBlockAttrs, CodeBlockAttrs as CodeBlockAttrs$1, defineCodeBlockPreviewPlugin, isCodeBlockPreviewHiddenDecoration } from "@prosekit/extensions/code-block";
3
3
  import { PlaceholderOptions, definePlaceholder } from "@prosekit/extensions/placeholder";
4
4
  import { defineReadonly } from "@prosekit/extensions/readonly";
5
+ import { SearchStatus, SearchStatusHandler, defineSearchStatusHandler, getSearchStatus } from "@prosekit/extensions/search";
5
6
  import { Command, EditorState, PluginKey } from "@prosekit/pm/state";
6
7
  import { EditorView } from "@prosekit/pm/view";
7
8
  import { EditorNode, Mark, ProseMirrorNode } from "@prosekit/pm/model";
@@ -661,11 +662,7 @@ declare function defineEditorExtensionImpl(options: EditorExtensionOptions): imp
661
662
  acceptPendingReplacement: [options?: AcceptPendingReplacementOptions | undefined];
662
663
  discardPendingReplacement: [];
663
664
  };
664
- }>, import("@prosekit/core").PlainExtension]>, import("@prosekit/core").Union<readonly [import("@prosekit/core").PlainExtension, import("@prosekit/extensions/search").SearchCommandsExtension, import("@prosekit/core").Extension<{
665
- Commands: {
666
- setSearchQuery: [query: string];
667
- };
668
- }>]>]>;
665
+ }>, import("@prosekit/core").PlainExtension]>, import("@prosekit/core").Union<readonly [import("@prosekit/core").PlainExtension, import("@prosekit/extensions/search").SearchCommandsExtension, import("@prosekit/core").PlainExtension]>]>;
669
666
  type EditorExtension = ReturnType<typeof defineEditorExtensionImpl>;
670
667
  /**
671
668
  * Options for {@link defineEditorExtension}. Creation-time configuration:
@@ -839,20 +836,6 @@ type ExitBoundaryHandler = (options: ExitBoundaryOptions) => boolean | void;
839
836
  /** Call `onExitBoundary` when an arrow key press would leave the document boundary. */
840
837
  declare function defineExitBoundaryHandler(onExitBoundary: ExitBoundaryHandler): PlainExtension;
841
838
  //#endregion
842
- //#region src/extensions/find.d.ts
843
- /** The current query's match count and which match the selection sits on. */
844
- interface SearchStatus {
845
- /** Total matches of the current query. */
846
- total: number;
847
- /** One-based position of the selected match; 0 when the selection is not on one. */
848
- active: number;
849
- }
850
- type SearchStatusHandler = (status: SearchStatus) => void;
851
- /** The current query's match count and which match the selection sits on. */
852
- declare function getSearchStatus(state: EditorState): SearchStatus;
853
- /** Reports search-status changes so a host can render a match counter. */
854
- declare function defineSearchStatusHandler(handler: SearchStatusHandler): PlainExtension;
855
- //#endregion
856
839
  //#region src/extensions/file-click.d.ts
857
840
  /** Payload for {@link FileClickHandler}. */
858
841
  interface FileClickPayload {
@@ -1157,6 +1140,9 @@ declare function defineWikilinkHoverHandler(onHoverChange: WikilinkHoverHandler)
1157
1140
  */
1158
1141
  declare function defineWikilinkTrigger(): PlainExtension;
1159
1142
  //#endregion
1143
+ //#region src/utils/composition.d.ts
1144
+ declare function getIsComposing(): boolean;
1145
+ //#endregion
1160
1146
  //#region src/utils/display-text.d.ts
1161
1147
  /**
1162
1148
  * The textblock as its live-preview marks display it: syntax runs are
@@ -1208,4 +1194,4 @@ declare function getSelectedText(state: EditorState): string;
1208
1194
  */
1209
1195
  declare function getVirtualElementFromRange(view: EditorView, range: PositionRange): VirtualElement;
1210
1196
  //#endregion
1211
- export { type AcceptPendingReplacementOptions, type CheckRoundTripOptions, type CodeBlockAttrs, type CodeBlockFenceStyle, type CodeToken, type DocToMarkdownOptions, EDITOR_KEY_BINDINGS, type EditorExtension, type EditorExtensionOptions, type EmbedDescriptor, type ExitBoundaryHandler, type ExitBoundaryOptions, type FileClickHandler, type FileClickPayload, type FileInfo, type FileInfoResolver, type FileLinkOptions, type FileLinkPayload, type FileLinkResolver, type FilePasteHandler, type FilePasteOptions, type FileSaveErrorHandler, type FileViewOptions, type FollowLinkHandlers, type ImageClickHandler, type ImageClickPayload, type ImageOptions, type InlineMarkContext, type InlineMarkOptions, type KaTeXRender, type LanguageItem, type LinkAttrs, type LinkClickHandler, type LinkClickPayload, type LinkCopyHandler, type LinkCopyPayload, type LinkEditHandler, type LinkEditOptions, type LinkHoverHandler, type LinkUnit, type ListMarker, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdFileAttrs, type MdImageAttrs, type MdLinkTextAttrs, type MdMathAttrs, type MdWikilinkAttrs, type MeowdownCodeBlockAttrs, type MeowdownHTMLCommentAttrs, type MeowdownListAttrs, type MeowdownTableCellAttrs, type NodeName, type ParsedWikiEmbed, type PendingReplacement, type PendingReplacementEvent, type PendingReplacementHandler, type PendingReplacementMode, type PendingReplacementOutcome, type PlaceholderOptions, type PositionRange, Priority, type ReferenceDefinition, type ReferenceDefinitionIndex, type ReferenceDefinitions, type RoundTripFidelity, type SearchStatus, type SearchStatusHandler, type StartPendingReplacementOptions, type TableColumnAlign, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type VirtualElement, type WikiEmbedOptions, type WikiEmbedResolution, type WikiEmbedResolver, type WikilinkClickHandler, type WikilinkClickPayload, type WikilinkHoverHandler, type WikilinkHoverHit, buildFileMarkdown, checkRoundTrip, codeBlockLanguages, collectReferenceDefinitions, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockPreviewPlugin, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineFileClickHandler, defineFilePaste, defineFileView, defineFollowLinkHandler, defineHTMLComment, defineImage, defineImageClickHandler, defineLinkClickHandler, defineLinkCommands, defineLinkEditKeymap, defineLinkHoverHandler, defineLinkPaste, defineMath, definePendingReplacementHandler, definePlaceholder, defineReadonly, defineSearchStatusHandler, defineSpellCheckPlugin, defineSubstitution, defineTagClickHandler, defineViewAttributes, defineWikilinkClickHandler, defineWikilinkHoverHandler, defineWikilinkTrigger, docToMarkdown, formatFileSize, formatSizedWikiEmbed, getCodeTokens, getFileKind, getLinkUnitAt, getMarkBuilders, getPendingReplacement, getSearchStatus, getSelectedText, getTableColumnAlign, getTextblockDisplayText, getVirtualElementFromRange, inlineTextToMarkChunks, inlineTextToMarkChunksWithContext, insertLink, isCodeBlockPreviewHiddenDecoration, isMarkOfType, isNodeOfType, isSelectionInTableCell, listenForTweetHeight, loadKaTeX, markdownToDoc, matchEmbed, parseWikiEmbed, removeLink, renderMathInto, updateLink, wikiEmbedBasename, withPriority };
1197
+ export { type AcceptPendingReplacementOptions, type CheckRoundTripOptions, type CodeBlockAttrs, type CodeBlockFenceStyle, type CodeToken, type DocToMarkdownOptions, EDITOR_KEY_BINDINGS, type EditorExtension, type EditorExtensionOptions, type EmbedDescriptor, type ExitBoundaryHandler, type ExitBoundaryOptions, type FileClickHandler, type FileClickPayload, type FileInfo, type FileInfoResolver, type FileLinkOptions, type FileLinkPayload, type FileLinkResolver, type FilePasteHandler, type FilePasteOptions, type FileSaveErrorHandler, type FileViewOptions, type FollowLinkHandlers, type ImageClickHandler, type ImageClickPayload, type ImageOptions, type InlineMarkContext, type InlineMarkOptions, type KaTeXRender, type LanguageItem, type LinkAttrs, type LinkClickHandler, type LinkClickPayload, type LinkCopyHandler, type LinkCopyPayload, type LinkEditHandler, type LinkEditOptions, type LinkHoverHandler, type LinkUnit, type ListMarker, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdFileAttrs, type MdImageAttrs, type MdLinkTextAttrs, type MdMathAttrs, type MdWikilinkAttrs, type MeowdownCodeBlockAttrs, type MeowdownHTMLCommentAttrs, type MeowdownListAttrs, type MeowdownTableCellAttrs, type NodeName, type ParsedWikiEmbed, type PendingReplacement, type PendingReplacementEvent, type PendingReplacementHandler, type PendingReplacementMode, type PendingReplacementOutcome, type PlaceholderOptions, type PositionRange, Priority, type ReferenceDefinition, type ReferenceDefinitionIndex, type ReferenceDefinitions, type RoundTripFidelity, type SearchStatus, type SearchStatusHandler, type StartPendingReplacementOptions, type TableColumnAlign, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type VirtualElement, type WikiEmbedOptions, type WikiEmbedResolution, type WikiEmbedResolver, type WikilinkClickHandler, type WikilinkClickPayload, type WikilinkHoverHandler, type WikilinkHoverHit, buildFileMarkdown, checkRoundTrip, codeBlockLanguages, collectReferenceDefinitions, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockPreviewPlugin, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineFileClickHandler, defineFilePaste, defineFileView, defineFollowLinkHandler, defineHTMLComment, defineImage, defineImageClickHandler, defineLinkClickHandler, defineLinkCommands, defineLinkEditKeymap, defineLinkHoverHandler, defineLinkPaste, defineMath, definePendingReplacementHandler, definePlaceholder, defineReadonly, defineSearchStatusHandler, defineSpellCheckPlugin, defineSubstitution, defineTagClickHandler, defineViewAttributes, defineWikilinkClickHandler, defineWikilinkHoverHandler, defineWikilinkTrigger, docToMarkdown, formatFileSize, formatSizedWikiEmbed, getCodeTokens, getFileKind, getIsComposing, getLinkUnitAt, getMarkBuilders, getPendingReplacement, getSearchStatus, getSelectedText, getTableColumnAlign, getTextblockDisplayText, getVirtualElementFromRange, inlineTextToMarkChunks, inlineTextToMarkChunksWithContext, insertLink, isCodeBlockPreviewHiddenDecoration, isMarkOfType, isNodeOfType, isSelectionInTableCell, listenForTweetHeight, loadKaTeX, markdownToDoc, matchEmbed, parseWikiEmbed, removeLink, renderMathInto, updateLink, wikiEmbedBasename, withPriority };
package/dist/index.js CHANGED
@@ -1,39 +1,39 @@
1
- import{Priority as e,Priority as t,createMarkBuilders as n,createNodeBuilders as r,defineBaseCommands as i,defineBaseKeymap as a,defineClipboardSerializer as o,defineCommands as s,defineHistory as c,defineKeymap as l,defineMarkSpec as u,defineMarkView as d,defineNodeAttr as f,defineNodeSpec as p,definePlugin as m,getMarkRange as h,getMarkType as g,getNodeType as _,isAllSelection as v,isApple as ee,isAtBlockStart as te,isNodeSelection as ne,isTextSelection as y,setBlockType as re,toggleNode as ie,union as b,unsetBlockType as ae,withPriority as oe,withPriority as x,withSkipCodeBlock as se}from"@prosekit/core";import{defineCodeBlock as ce,defineCodeBlockHighlight as le,defineCodeBlockPreviewPlugin as ue,isCodeBlockPreviewHiddenDecoration as de}from"@prosekit/extensions/code-block";import{definePlaceholder as fe}from"@prosekit/extensions/placeholder";import{defineReadonly as pe}from"@prosekit/extensions/readonly";import{LEZER_NODE_IDS as S,collectInlineElements as me,getAutolinkHref as he,gfmBlockOnlyParser as ge,gfmParser as _e,isSpaceChar as C,parseInline as ve}from"@meowdown/markdown";import{isElementLike as ye,isHTMLElement as be,isObject as xe,once as Se}from"@ocavue/utils";import{defineBlockquote as Ce}from"@prosekit/extensions/blockquote";import{defineDoc as we}from"@prosekit/extensions/doc";import{defineGapCursor as Te}from"@prosekit/extensions/gap-cursor";import{defineModClickPrevention as Ee}from"@prosekit/extensions/mod-click-prevention";import{defineText as De}from"@prosekit/extensions/text";import{defineVirtualSelection as Oe}from"@prosekit/extensions/virtual-selection";import{NodeSelection as ke,Plugin as w,PluginKey as T,Selection as Ae,TextSelection as E}from"@prosekit/pm/state";import{Decoration as je,DecorationSet as D}from"@prosekit/pm/view";import{NO_BREAK_SPACE as Me}from"unicode-by-name";import{defaultHandlers as Ne}from"hast-util-to-mdast";import{defaultHandlers as Pe}from"mdast-util-to-markdown";import Fe from"rehype-parse";import Ie from"rehype-remark";import Le from"remark-gfm";import Re from"remark-stringify";import{unified as ze}from"unified";import{DOMParser as Be,DOMSerializer as Ve,Fragment as O,Mark as He,Slice as k}from"@prosekit/pm/model";import{defineHeadingCommands as Ue,defineHeadingInputRule as We,defineHeadingSpec as Ge}from"@prosekit/extensions/heading";import{defineParagraphCommands as Ke,defineParagraphKeymap as qe}from"@prosekit/extensions/paragraph";import{LanguageDescription as Je}from"@codemirror/language";import{languages as Ye}from"@codemirror/language-data";import{classHighlighter as Xe,highlightTree as Ze}from"@lezer/highlight";import{createParser as Qe}from"prosemirror-highlight/lezer";import{defineEnterRule as $e,defineTextBlockEnterRule as et}from"@prosekit/extensions/enter-rule";import{defineInputRule as tt,defineTextBlockInputRule as nt}from"@prosekit/extensions/input-rule";import{triggerAutocomplete as rt}from"@prosekit/extensions/autocomplete";import{defineListCommands as it,defineListDropIndicator as at,defineListKeymap as ot,defineListSpec as st,moveList as ct,toggleList as lt,unwrapList as ut,wrapInList as dt}from"@prosekit/extensions/list";import{chainCommands as ft,lift as pt}from"@prosekit/pm/commands";import{defineSearchCommands as mt}from"@prosekit/extensions/search";import{SearchQuery as ht,getMatchHighlights as gt,getSearchState as _t,search as vt,setSearchState as yt}from"prosemirror-search";import{defineHorizontalRule as bt}from"@prosekit/extensions/horizontal-rule";import{AddMarkStep as xt,AddNodeMarkStep as St,AttrStep as Ct,RemoveMarkStep as wt,RemoveNodeMarkStep as Tt,ReplaceStep as Et,Step as Dt,StepResult as A,Transform as Ot}from"@prosekit/pm/transform";import{decodeString as kt}from"micromark-util-decode-string";import{normalizeIdentifier as At}from"micromark-util-normalize-identifier";import{createListRenderingPlugin as jt,createSafariInputMethodWorkaroundPlugin as Mt,createToggleCollapsedCommand as Nt,defaultAttributesGetter as Pt,findCheckboxInListItem as Ft,handleListMarkerMouseDown as It,joinListElements as Lt,listToDOM as Rt,unwrapListSlice as zt,wrappingListInputRule as Bt}from"prosemirror-flat-list";import{defineTableCellSpec as Vt,defineTableCommands as Ht,defineTableDropIndicator as Ut,defineTableEditingPlugin as Wt,defineTableHeaderCellSpec as Gt,defineTableRowSpec as Kt,defineTableSpec as qt,deleteTable as Jt,isCellSelection as Yt}from"@prosekit/extensions/table";import{closeHistory as Xt}from"@prosekit/pm/history";import{registerResizableHandleElement as Zt,registerResizableRootElement as Qt}from"@prosekit/web/resizable";import{InputRule as $t}from"@prosekit/pm/inputrules";function j(e,t,n,r){let i=e.doc.content.size;if(t<0||t>i)return;let a=e.doc.resolve(t);if(!(!a.parent.isTextblock||a.parent.type.spec.code))return h(a,n,r)}const M=new T(`mark-mode`);function en(e){return M.getState(e)}function tn(e){return new w({key:M,state:{init:()=>e,apply:(e,t)=>e.getMeta(M)??t},props:{attributes:t=>({"data-mark-mode":en(t)??e}),decorations:e=>{let t=en(e);if(t===`focus`)return an(e);if(t===`hide`)return on(e)}}})}function nn(e){return(t,n)=>N(t)===e?!1:(n?.(t.tr.setMeta(M,e)),!0)}function rn(e){return b(m(tn(e)),s({setMarkMode:nn}))}function N(e){return M.getState(e)}function an(e){return sn(e,void 0)}function on(e){return sn(e,{key:`math`})}function sn(e,t){let{selection:n}=e;if(!n.empty)return D.empty;let r=n.$head,{parent:i}=r;if(!i.isTextblock||i.type.spec.code)return D.empty;let a=h(r,g(e.schema,`mdPack`),t);return a?D.create(e.doc,[je.inline(a.from,a.to,{class:`show`})]):D.empty}const cn=[`mdImage`,`mdWikilink`,`mdFile`];function P(e,t){let n=N(t);return n?e.flatMap(e=>e.modes.includes(n)?[e.name]:[]):[]}function ln(e,t,n){for(let r of n){let n=j(e,t,r);if(n)return n}}function F(e,t,n){let r=ln(e,t,n);return r&&r.to===t?r:void 0}function I(e,t,n){let r=ln(e,t,n);return r&&r.from===t?r:void 0}function un(e,t){let{from:n,to:r,empty:i}=e.selection;if(i)return;let a=ln(e,n,t);return a&&a.from===n&&a.to===r?a:void 0}function dn(e,t){return E.create(e.doc,t.from,t.to)}function fn(e,t,n,r){let i=e.doc.resolve(t);if(!(r===-1?i.parentOffset===0:i.parentOffset===i.parent.content.size)||i.depth===0)return;let a=r===-1?I(e,t,n):F(e,t,n),o=r===-1?i.before():i.after(),s=Ae.findFrom(e.doc.resolve(o),r);if(!s)return;let c=y(s)?r===-1?F(e,s.head,n):I(e,s.head,n):void 0;if(a!=null||c!=null)return s}function pn(e){return(t,n)=>{let r=P(e,t);if(r.length===0||!y(t.selection))return!1;let i=t.selection;if(i.empty){let e=I(t,i.from,r);if(e)return n?.(t.tr.setSelection(dn(t,e))),!0;if(F(t,i.from,r)&&i.from<t.doc.resolve(i.from).end())return n?.(t.tr.setSelection(E.create(t.doc,i.from+1))),!0;let a=fn(t,i.from,r,1);return a?(n?.(t.tr.setSelection(a).scrollIntoView()),!0):!1}let a=un(t,r);return a?(n?.(t.tr.setSelection(E.create(t.doc,a.to))),!0):!1}}function mn(e){return(t,n)=>{let r=P(e,t);if(r.length===0||!y(t.selection))return!1;let i=t.selection;if(i.empty){let e=F(t,i.from,r);if(e)return n?.(t.tr.setSelection(dn(t,e))),!0;let a=fn(t,i.from,r,-1);return a?(n?.(t.tr.setSelection(a).scrollIntoView()),!0):!1}let a=un(t,r);return a?(n?.(t.tr.setSelection(E.create(t.doc,a.from))),!0):!1}}function hn(e,t){return(n,r)=>{let i=P(e,n);if(i.length===0||!y(n.selection))return!1;let{anchor:a,head:o}=n.selection,s=t===-1?F(n,o,i):I(n,o,i);if(s){let e=t===-1?s.from:s.to;return r?.(n.tr.setSelection(E.create(n.doc,a,e)).scrollIntoView()),!0}let c=fn(n,o,i,t);return!c||!y(c)?!1:(r?.(n.tr.setSelection(E.create(n.doc,a,c.head)).scrollIntoView()),!0)}}function gn(e){return(t,n)=>{let r=P(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=F(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!I(t,i,r)||i<=t.doc.resolve(i).start()?!1:(n?.(t.tr.delete(i-1,i)),!0)}}function _n(e){return(t,n)=>{let r=P(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=I(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!F(t,i,r)||i>=t.doc.resolve(i).end()?!1:(n?.(t.tr.delete(i,i+1)),!0)}}const vn=`md-atom-selected`;function yn(e){return new w({key:new T(`atom-mark-selection`),props:{decorations:t=>{let n=P(e,t);if(n.length===0||ne(t.selection))return;let r=un(t,n);if(r)return D.create(t.doc,[je.inline(r.from,r.to,{class:vn})]);let{from:i,to:a,empty:o}=t.selection;if(o)return null;let s=[];return t.doc.nodesBetween(i,a,(e,t)=>{e.marks.some(e=>n.includes(e.type.name))&&s.push(je.inline(t,t+e.nodeSize,{class:vn}))}),D.create(t.doc,s)}}})}function bn({marks:e}){return b(x(l({ArrowRight:pn(e),ArrowLeft:mn(e),"Shift-ArrowRight":hn(e,1),"Shift-ArrowLeft":hn(e,-1),Backspace:gn(e),Delete:_n(e)}),t.high),m(yn(e)))}const xn=(e,t)=>{let n={type:`highlight`,children:e.all(t)};return e.patch(t,n),n},Sn=(e,t,n,r)=>{let i=e,a=n.createTracker(r),o=a.move(`==`);return o+=a.move(n.containerPhrasing(i,{...a.current(),before:o,after:`=`})),o+=a.move(`==`),o};function Cn(e){return e.tagName===`input`&&e.properties.type===`checkbox`}function wn(e){for(let t of e.children){if(t.type!==`element`)continue;if(Cn(t))return t;if(t.tagName===`ul`||t.tagName===`ol`)continue;let e=wn(t);if(e)return e}}function Tn(e){let t=e.properties.dataChecked,n=wn(e);if(t==null&&e.properties.dataType!==`taskItem`&&e.properties.dataTaskListItem==null&&n===void 0)return;let r=typeof t==`string`?t!==`false`:!!n?.properties.checked,i=e.children.filter(e=>e.type!==`element`||!(Cn(e)||e.tagName===`label`&&wn(e)));for(let e of[`div`,`p`]){let t=i.length===1&&i[0].type===`element`?i[0]:void 0;t?.tagName===e&&(i=t.children)}let a={type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:r},children:[]};return{...e,children:[a,...i]}}const En=(e,t)=>Ne.li(e,Tn(t)??t);function Dn(e){return e.filter(e=>e.character!==`[`&&e.character!==`~`?!0:e.atBreak?e.character===`~`:!(Array.isArray(e.inConstruct)?e.inConstruct:e.inConstruct?[e.inConstruct]:[]).includes(`phrasing`))}const On=(e,t,n,r)=>Pe.text(e,t,{...n,unsafe:Dn(n.unsafe)},r);function kn(){return ze().use(Fe).use(Ie,{handlers:{mark:xn,li:En}}).use(Le).use(Re,{bullet:`-`,emphasis:`*`,strong:`*`,fence:"`",fences:!0,rule:`-`,ruleRepetition:3,listItemIndent:`one`,handlers:{highlight:Sn,text:On}}).freeze()}const An=Se(kn);function jn(e){return String(An().processSync(e))}function Mn(e){if(e==null)return;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)?t:void 0}function Nn(e){let t=Mn(e);return t!=null&&t>0?t:void 0}function Pn(e,t){return e.type.name===t}const Fn=new Set([`mdMark`,`mdLinkUri`,`mdLinkTitle`]),In=new Set([`mdWikilink`,`mdImage`,`mdFile`,`mdMath`]);function Ln(e){return e.find(e=>In.has(e.type.name))}function Rn(e){return e.some(e=>Fn.has(e.type.name))}function zn(e){let t=[];return e.forEach(e=>{if(!e.isText||!e.text)return;let n=Ln(e.marks),r=t.at(-1);if(n!=null&&r!=null&&r.atom===n){r.text+=e.text,r.children.push(e);return}t.push({atom:n,text:e.text,children:[e]})}),t}const Bn={mdStrong:`strong`,mdEm:`em`,mdCode:`code`,mdDel:`del`,mdHighlight:`mark`,mdLinkText:`a`};function Vn(e,t,n={}){let r=document.createElement(e);r.setAttribute(`data-md`,t.textContent);for(let[e,t]of Object.entries(n))t!=null&&r.setAttribute(e,t);return Un(t,r),r}function Hn(e,t,n){return{tag:`${e}[data-md]`,node:t,priority:100,getAttrs:n,getContent:(e,t)=>{let n=(be(e)?e:void 0)?.getAttribute(`data-md`)??``;return n?O.from(t.text(n)):O.empty}}}function Un(e,t){let n=[];for(let r of zn(e)){if(r.atom!=null){n.length=0,t.append(Kn(r.atom,r.text));continue}for(let e of r.children)Rn(e.marks)||(Wn(n,e.marks.filter(e=>Bn[e.type.name]),t),Gn(n.at(-1)?.element??t,e.text??``))}}function Wn(e,t,n){let r=0;for(;r<e.length&&r<t.length&&t[r].eq(e[r].mark);)r++;e.length=r;for(let i=r;i<t.length;i++){let r=t[i],a=document.createElement(Bn[r.type.name]??`span`);Pn(r,`mdLinkText`)&&a.setAttribute(`href`,r.attrs.href),(e.at(-1)?.element??n).append(a),e.push({mark:r,element:a})}}function Gn(e,t){let n=t.split(`
2
- `);for(let[t,r]of n.entries())t>0&&e.append(document.createElement(`br`)),r&&e.append(document.createTextNode(r))}function Kn(e,t){switch(e.type.name){case`mdImage`:{let t=e.attrs,n=document.createElement(`img`);return n.setAttribute(`src`,t.src),t.alt&&n.setAttribute(`alt`,t.alt),t.title&&n.setAttribute(`title`,t.title),t.width!=null&&n.setAttribute(`width`,String(t.width)),t.height!=null&&n.setAttribute(`height`,String(t.height)),n}case`mdWikilink`:{let t=e.attrs;return document.createTextNode(t.display||t.target)}case`mdFile`:{let t=e.attrs,n=document.createElement(`a`);return n.setAttribute(`href`,t.href),n.append(document.createTextNode(t.name||t.href)),n}default:return document.createTextNode(t)}}function L(e,t){return e.type.name===t}function qn(){return p({name:`heading`,whitespace:`pre`})}function Jn(e){let t=e.attrs;return Vn(`h${t.level}`,e,{"data-setext-underline":t.setextUnderline==null?void 0:String(t.setextUnderline),"data-closing-hashes":t.closingHashes==null?void 0:String(t.closingHashes)})}function Yn(){return[1,2,3,4,5,6].map(e=>Hn(`h${e}`,`heading`,t=>({level:e,setextUnderline:Nn(t.getAttribute(`data-setext-underline`))??null,closingHashes:Nn(t.getAttribute(`data-closing-hashes`))??null})))}function Xn(){return f({type:`heading`,attr:`setextUnderline`,default:null,toDOM:e=>e==null?null:[`data-setext-underline`,String(e)],parseDOM:e=>Nn(e.getAttribute(`data-setext-underline`))??null})}function Zn(){return f({type:`heading`,attr:`closingHashes`,default:null,toDOM:e=>e==null?null:[`data-closing-hashes`,String(e)],parseDOM:e=>Nn(e.getAttribute(`data-closing-hashes`))??null})}function R(e){return se(ie({type:`heading`,attrs:{level:e}}))}const Qn=(e,t,n)=>{let r=te(e,n);return r!=null&&L(r.parent,`heading`)?ae()(e,t,n):!1};function $n(){return l({"Mod-1":R(1),"Mod-2":R(2),"Mod-3":R(3),"Mod-4":R(4),"Mod-5":R(5),"Mod-6":R(6),Backspace:Qn})}function er(){return b(Ge(),qn(),Xn(),Zn(),We(),Ue(),$n())}function tr(){return p({name:`paragraph`,content:`inline*`,group:`block`,whitespace:`pre`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}})}function nr(e){return Vn(`p`,e)}function rr(){return[Hn(`p`,`paragraph`)]}function ir(){return b(x(tr(),t.highest),Ke(),qe())}function ar(e){return{...e,paragraph:e=>({dom:nr(e)}),heading:e=>({dom:Jn(e)})}}function or(){return o({serializeFragmentWrapper:e=>(...t)=>{let n=e(...t);for(let e of n.children)e.setAttribute(`data-meowdown`,``);return n},nodesFromSchemaWrapper:e=>(...t)=>ar(e(...t))})}const sr=new WeakMap;function cr(e){let t=sr.get(e);return t??(t=new Ve(ar(Ve.nodesFromSchema(e)),Ve.marksFromSchema(e)),sr.set(e,t)),t}const lr=new T(`meowdown-html-paste`);function ur(e){return e.includes(`data-meowdown`)?!0:e.includes(`data-pm-slice`)&&e.includes(`md-mark`)}const dr=new Set([`html`,`head`,`body`,`meta`,`style`,`title`,`div`,`span`,`p`,`br`,`font`,`wbr`]);function fr(e){let t=new window.DOMParser().parseFromString(e,`text/html`),n={chunks:[],hasContent:!1,trailingNewlines:0,hasStyledLine:!1};if(hr(t.documentElement,n,!1)&&n.hasStyledLine)return n.chunks.join(``).replaceAll(Me,` `)}function pr(e,t){!e.hasContent||e.trailingNewlines>=t||mr(e,`
3
- `.repeat(t-e.trailingNewlines))}function mr(e,t){if(!t)return;e.chunks.push(t);let n=t.length;for(;n>0&&t.charCodeAt(n-1)===10;)n--;n===0?e.trailingNewlines+=t.length:(e.hasContent=!0,e.trailingNewlines=t.length-n)}function hr(e,t,n){if(e.nodeType===Node.TEXT_NODE)return mr(t,e.nodeValue??``),!0;if(e.nodeType!==Node.ELEMENT_NODE)return!0;let r=e,i=r.tagName;if(!dr.has(i.toLowerCase()))return!1;if(n||=i===`DIV`,n&&r.getAttribute(`style`)?.trim()&&(t.hasStyledLine=!0),i===`BR`)return mr(t,`
4
- `),!0;if(i===`STYLE`||i===`TITLE`)return!0;let a=i===`DIV`?1:i===`P`?2:0;a&&pr(t,a);for(let r of e.childNodes)if(!hr(r,t,n))return!1;return a&&pr(t,a),!0}function gr(){return m(new w({key:lr,props:{transformPastedHTML:(e,t)=>{if(ur(e))return e;let n=t.state.selection.$from.parent;if(!n.inlineContent||n.type.spec.code)return e;let r=fr(e)??jn(e);if(!r.trim())return e;let i=Z(r,{nodes:ol(t.state.schema)}),a=cr(t.state.schema),o=document.createElement(`div`);return o.append(a.serializeFragment(i.content)),o.innerHTML}}}))}function _r(e){return new Be(e,[...rr(),...Yn(),...Be.fromSchema(e).rules])}const vr=new T(`meowdown-clipboard-parser`);function yr(){return m(({schema:e})=>new w({key:vr,props:{clipboardParser:_r(e)}}))}function br(e,t){let n=t.replaceAll(/\r\n?/g,`
5
- `).replace(/^\n+/,``).replace(/\n+$/,``);if(!n)return k.empty;let r=Z(n,{nodes:ol(e)}),i=_(e,`paragraph`),a=+(r.childCount>0&&r.child(0).type===i),o=+(r.childCount>0&&r.child(r.childCount-1).type===i);return new k(r.content,a,o)}function xr(e,t,n){let r=n.marks(),i=Ve.fromSchema(e),a=document.createElement(`div`);for(let n of t.split(/(?:\r\n?|\n)+/)){let t=a.appendChild(document.createElement(`p`));n&&t.appendChild(i.serializeNode(e.text(n,r)))}return Be.fromSchema(e).parseSlice(a,{preserveWhitespace:!0,context:n})}function Sr(){let e;return m(new w({key:new T(`meowdown-plain-paste`),props:{clipboardTextParser:(t,n,r,i)=>{let{schema:a}=i.state;return r?xr(a,t,n):e=br(a,t)},transformPasted:t=>{if(e==null)return t;let n=e;return e=void 0,n}}}))}function Cr(e,t,n=0){let r=n,i=0;for(let n=0;n<e.length;n++)e.charCodeAt(n)===t?(i++,i>r&&(r=i)):i=0;return r}function wr(e,t=0){return Cr(e,96,t)}function Tr(e,t={}){let n=new kr;return t.frontmatter&&Er(e.attrs.frontmatter,n),Ar(e,n),n.finish()}function Er(e,t){e!==null&&(t.write(`---`),t.write(`
1
+ import{Priority as e,Priority as t,createMarkBuilders as n,createNodeBuilders as r,defineBaseCommands as i,defineBaseKeymap as a,defineClipboardSerializer as o,defineCommands as s,defineHistory as c,defineKeymap as l,defineMarkSpec as u,defineMarkView as d,defineNodeAttr as f,defineNodeSpec as p,definePlugin as m,getMarkRange as h,getMarkType as g,getNodeType as _,isAllSelection as v,isApple as ee,isAtBlockStart as te,isNodeSelection as ne,isTextSelection as y,setBlockType as re,toggleNode as ie,union as b,unsetBlockType as ae,withPriority as oe,withPriority as x,withSkipCodeBlock as se}from"@prosekit/core";import{defineCodeBlock as ce,defineCodeBlockHighlight as le,defineCodeBlockPreviewPlugin as ue,isCodeBlockPreviewHiddenDecoration as de}from"@prosekit/extensions/code-block";import{definePlaceholder as fe}from"@prosekit/extensions/placeholder";import{defineReadonly as pe}from"@prosekit/extensions/readonly";import{defineSearchCommands as me,defineSearchQuery as he,defineSearchStatusHandler as ge,getSearchStatus as _e,getSearchStatus as ve}from"@prosekit/extensions/search";import{LEZER_NODE_IDS as S,collectInlineElements as ye,getAutolinkHref as be,gfmBlockOnlyParser as xe,gfmParser as Se,isSpaceChar as C,parseInline as Ce}from"@meowdown/markdown";import{isElementLike as we,isHTMLElement as Te,isObject as Ee,once as De}from"@ocavue/utils";import{defineBlockquote as Oe}from"@prosekit/extensions/blockquote";import{defineDoc as ke}from"@prosekit/extensions/doc";import{defineGapCursor as Ae}from"@prosekit/extensions/gap-cursor";import{defineModClickPrevention as je}from"@prosekit/extensions/mod-click-prevention";import{defineText as Me}from"@prosekit/extensions/text";import{defineVirtualSelection as Ne}from"@prosekit/extensions/virtual-selection";import{NodeSelection as Pe,Plugin as w,PluginKey as T,Selection as Fe,TextSelection as E}from"@prosekit/pm/state";import{Decoration as Ie,DecorationSet as D}from"@prosekit/pm/view";import{NO_BREAK_SPACE as Le}from"unicode-by-name";import{defaultHandlers as Re}from"hast-util-to-mdast";import{defaultHandlers as ze}from"mdast-util-to-markdown";import Be from"rehype-parse";import Ve from"rehype-remark";import He from"remark-gfm";import Ue from"remark-stringify";import{unified as We}from"unified";import{DOMParser as Ge,DOMSerializer as Ke,Fragment as O,Mark as qe,Slice as k}from"@prosekit/pm/model";import{defineHeadingCommands as Je,defineHeadingInputRule as Ye,defineHeadingSpec as Xe}from"@prosekit/extensions/heading";import{defineParagraphCommands as Ze,defineParagraphKeymap as Qe}from"@prosekit/extensions/paragraph";import{LanguageDescription as $e}from"@codemirror/language";import{languages as et}from"@codemirror/language-data";import{classHighlighter as tt,highlightTree as nt}from"@lezer/highlight";import{createParser as rt}from"prosemirror-highlight/lezer";import{defineEnterRule as it,defineTextBlockEnterRule as at}from"@prosekit/extensions/enter-rule";import{defineInputRule as ot,defineTextBlockInputRule as st}from"@prosekit/extensions/input-rule";import{triggerAutocomplete as ct}from"@prosekit/extensions/autocomplete";import{defineListCommands as lt,defineListDropIndicator as ut,defineListKeymap as dt,defineListSpec as ft,moveList as pt,toggleList as mt,unwrapList as ht,wrapInList as gt}from"@prosekit/extensions/list";import{chainCommands as _t,lift as vt}from"@prosekit/pm/commands";import{defineHorizontalRule as yt}from"@prosekit/extensions/horizontal-rule";import{AddMarkStep as bt,AddNodeMarkStep as xt,AttrStep as St,RemoveMarkStep as Ct,RemoveNodeMarkStep as wt,ReplaceStep as Tt,Step as Et,StepResult as Dt,Transform as Ot}from"@prosekit/pm/transform";import{decodeString as kt}from"micromark-util-decode-string";import{normalizeIdentifier as At}from"micromark-util-normalize-identifier";import{createListRenderingPlugin as jt,createSafariInputMethodWorkaroundPlugin as Mt,createToggleCollapsedCommand as Nt,defaultAttributesGetter as Pt,findCheckboxInListItem as Ft,handleListMarkerMouseDown as It,joinListElements as Lt,listToDOM as Rt,unwrapListSlice as zt,wrappingListInputRule as Bt}from"prosemirror-flat-list";import{defineTableCellSpec as Vt,defineTableCommands as Ht,defineTableDropIndicator as Ut,defineTableEditingPlugin as Wt,defineTableHeaderCellSpec as Gt,defineTableRowSpec as Kt,defineTableSpec as qt,deleteTable as Jt,isCellSelection as Yt}from"@prosekit/extensions/table";import{closeHistory as Xt}from"@prosekit/pm/history";import{registerResizableHandleElement as Zt,registerResizableRootElement as Qt}from"@prosekit/web/resizable";import{InputRule as $t}from"@prosekit/pm/inputrules";function A(e,t,n,r){let i=e.doc.content.size;if(t<0||t>i)return;let a=e.doc.resolve(t);if(!(!a.parent.isTextblock||a.parent.type.spec.code))return h(a,n,r)}const en=new T(`mark-mode`);function tn(e){return en.getState(e)}function nn(e){return new w({key:en,state:{init:()=>e,apply:(e,t)=>e.getMeta(en)??t},props:{attributes:t=>({"data-mark-mode":tn(t)??e}),decorations:e=>{let t=tn(e);if(t===`focus`)return on(e);if(t===`hide`)return sn(e)}}})}function rn(e){return(t,n)=>j(t)===e?!1:(n?.(t.tr.setMeta(en,e)),!0)}function an(e){return b(m(nn(e)),s({setMarkMode:rn}))}function j(e){return en.getState(e)}function on(e){return cn(e,void 0)}function sn(e){return cn(e,{key:`math`})}function cn(e,t){let{selection:n}=e;if(!n.empty)return D.empty;let r=n.$head,{parent:i}=r;if(!i.isTextblock||i.type.spec.code)return D.empty;let a=h(r,g(e.schema,`mdPack`),t);return a?D.create(e.doc,[Ie.inline(a.from,a.to,{class:`show`})]):D.empty}const ln=[`mdImage`,`mdWikilink`,`mdFile`];function M(e,t){let n=j(t);return n?e.flatMap(e=>e.modes.includes(n)?[e.name]:[]):[]}function un(e,t,n){for(let r of n){let n=A(e,t,r);if(n)return n}}function N(e,t,n){let r=un(e,t,n);return r&&r.to===t?r:void 0}function P(e,t,n){let r=un(e,t,n);return r&&r.from===t?r:void 0}function dn(e,t){let{from:n,to:r,empty:i}=e.selection;if(i)return;let a=un(e,n,t);return a&&a.from===n&&a.to===r?a:void 0}function fn(e,t){return E.create(e.doc,t.from,t.to)}function pn(e,t,n,r){let i=e.doc.resolve(t);if(!(r===-1?i.parentOffset===0:i.parentOffset===i.parent.content.size)||i.depth===0)return;let a=r===-1?P(e,t,n):N(e,t,n),o=r===-1?i.before():i.after(),s=Fe.findFrom(e.doc.resolve(o),r);if(!s)return;let c=y(s)?r===-1?N(e,s.head,n):P(e,s.head,n):void 0;if(a!=null||c!=null)return s}function mn(e){return(t,n)=>{let r=M(e,t);if(r.length===0||!y(t.selection))return!1;let i=t.selection;if(i.empty){let e=P(t,i.from,r);if(e)return n?.(t.tr.setSelection(fn(t,e))),!0;if(N(t,i.from,r)&&i.from<t.doc.resolve(i.from).end())return n?.(t.tr.setSelection(E.create(t.doc,i.from+1))),!0;let a=pn(t,i.from,r,1);return a?(n?.(t.tr.setSelection(a).scrollIntoView()),!0):!1}let a=dn(t,r);return a?(n?.(t.tr.setSelection(E.create(t.doc,a.to))),!0):!1}}function hn(e){return(t,n)=>{let r=M(e,t);if(r.length===0||!y(t.selection))return!1;let i=t.selection;if(i.empty){let e=N(t,i.from,r);if(e)return n?.(t.tr.setSelection(fn(t,e))),!0;let a=pn(t,i.from,r,-1);return a?(n?.(t.tr.setSelection(a).scrollIntoView()),!0):!1}let a=dn(t,r);return a?(n?.(t.tr.setSelection(E.create(t.doc,a.from))),!0):!1}}function gn(e,t){return(n,r)=>{let i=M(e,n);if(i.length===0||!y(n.selection))return!1;let{anchor:a,head:o}=n.selection,s=t===-1?N(n,o,i):P(n,o,i);if(s){let e=t===-1?s.from:s.to;return r?.(n.tr.setSelection(E.create(n.doc,a,e)).scrollIntoView()),!0}let c=pn(n,o,i,t);return!c||!y(c)?!1:(r?.(n.tr.setSelection(E.create(n.doc,a,c.head)).scrollIntoView()),!0)}}function _n(e){return(t,n)=>{let r=M(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=N(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!P(t,i,r)||i<=t.doc.resolve(i).start()?!1:(n?.(t.tr.delete(i-1,i)),!0)}}function vn(e){return(t,n)=>{let r=M(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=P(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!N(t,i,r)||i>=t.doc.resolve(i).end()?!1:(n?.(t.tr.delete(i,i+1)),!0)}}const yn=`md-atom-selected`;function bn(e){return new w({key:new T(`atom-mark-selection`),props:{decorations:t=>{let n=M(e,t);if(n.length===0||ne(t.selection))return;let r=dn(t,n);if(r)return D.create(t.doc,[Ie.inline(r.from,r.to,{class:yn})]);let{from:i,to:a,empty:o}=t.selection;if(o)return null;let s=[];return t.doc.nodesBetween(i,a,(e,t)=>{e.marks.some(e=>n.includes(e.type.name))&&s.push(Ie.inline(t,t+e.nodeSize,{class:yn}))}),D.create(t.doc,s)}}})}function xn({marks:e}){return b(x(l({ArrowRight:mn(e),ArrowLeft:hn(e),"Shift-ArrowRight":gn(e,1),"Shift-ArrowLeft":gn(e,-1),Backspace:_n(e),Delete:vn(e)}),t.high),m(bn(e)))}const Sn=(e,t)=>{let n={type:`highlight`,children:e.all(t)};return e.patch(t,n),n},Cn=(e,t,n,r)=>{let i=e,a=n.createTracker(r),o=a.move(`==`);return o+=a.move(n.containerPhrasing(i,{...a.current(),before:o,after:`=`})),o+=a.move(`==`),o};function wn(e){return e.tagName===`input`&&e.properties.type===`checkbox`}function Tn(e){for(let t of e.children){if(t.type!==`element`)continue;if(wn(t))return t;if(t.tagName===`ul`||t.tagName===`ol`)continue;let e=Tn(t);if(e)return e}}function En(e){let t=e.properties.dataChecked,n=Tn(e);if(t==null&&e.properties.dataType!==`taskItem`&&e.properties.dataTaskListItem==null&&n===void 0)return;let r=typeof t==`string`?t!==`false`:!!n?.properties.checked,i=e.children.filter(e=>e.type!==`element`||!(wn(e)||e.tagName===`label`&&Tn(e)));for(let e of[`div`,`p`]){let t=i.length===1&&i[0].type===`element`?i[0]:void 0;t?.tagName===e&&(i=t.children)}let a={type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:r},children:[]};return{...e,children:[a,...i]}}const Dn=(e,t)=>Re.li(e,En(t)??t);function On(e){return e.filter(e=>e.character!==`[`&&e.character!==`~`?!0:e.atBreak?e.character===`~`:!(Array.isArray(e.inConstruct)?e.inConstruct:e.inConstruct?[e.inConstruct]:[]).includes(`phrasing`))}const kn=(e,t,n,r)=>ze.text(e,t,{...n,unsafe:On(n.unsafe)},r);function An(){return We().use(Be).use(Ve,{handlers:{mark:Sn,li:Dn}}).use(He).use(Ue,{bullet:`-`,emphasis:`*`,strong:`*`,fence:"`",fences:!0,rule:`-`,ruleRepetition:3,listItemIndent:`one`,handlers:{highlight:Cn,text:kn}}).freeze()}const jn=De(An);function Mn(e){return String(jn().processSync(e))}function Nn(e){if(e==null)return;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)?t:void 0}function Pn(e){let t=Nn(e);return t!=null&&t>0?t:void 0}function Fn(e,t){return e.type.name===t}const In=new Set([`mdMark`,`mdLinkUri`,`mdLinkTitle`]),Ln=new Set([`mdWikilink`,`mdImage`,`mdFile`,`mdMath`]);function Rn(e){return e.find(e=>Ln.has(e.type.name))}function zn(e){return e.some(e=>In.has(e.type.name))}function Bn(e){let t=[];return e.forEach(e=>{if(!e.isText||!e.text)return;let n=Rn(e.marks),r=t.at(-1);if(n!=null&&r!=null&&r.atom===n){r.text+=e.text,r.children.push(e);return}t.push({atom:n,text:e.text,children:[e]})}),t}const Vn={mdStrong:`strong`,mdEm:`em`,mdCode:`code`,mdDel:`del`,mdHighlight:`mark`,mdLinkText:`a`};function Hn(e,t,n={}){let r=document.createElement(e);r.setAttribute(`data-md`,t.textContent);for(let[e,t]of Object.entries(n))t!=null&&r.setAttribute(e,t);return Wn(t,r),r}function Un(e,t,n){return{tag:`${e}[data-md]`,node:t,priority:100,getAttrs:n,getContent:(e,t)=>{let n=(Te(e)?e:void 0)?.getAttribute(`data-md`)??``;return n?O.from(t.text(n)):O.empty}}}function Wn(e,t){let n=[];for(let r of Bn(e)){if(r.atom!=null){n.length=0,t.append(qn(r.atom,r.text));continue}for(let e of r.children)zn(e.marks)||(Gn(n,e.marks.filter(e=>Vn[e.type.name]),t),Kn(n.at(-1)?.element??t,e.text??``))}}function Gn(e,t,n){let r=0;for(;r<e.length&&r<t.length&&t[r].eq(e[r].mark);)r++;e.length=r;for(let i=r;i<t.length;i++){let r=t[i],a=document.createElement(Vn[r.type.name]??`span`);Fn(r,`mdLinkText`)&&a.setAttribute(`href`,r.attrs.href),(e.at(-1)?.element??n).append(a),e.push({mark:r,element:a})}}function Kn(e,t){let n=t.split(`
2
+ `);for(let[t,r]of n.entries())t>0&&e.append(document.createElement(`br`)),r&&e.append(document.createTextNode(r))}function qn(e,t){switch(e.type.name){case`mdImage`:{let t=e.attrs,n=document.createElement(`img`);return n.setAttribute(`src`,t.src),t.alt&&n.setAttribute(`alt`,t.alt),t.title&&n.setAttribute(`title`,t.title),t.width!=null&&n.setAttribute(`width`,String(t.width)),t.height!=null&&n.setAttribute(`height`,String(t.height)),n}case`mdWikilink`:{let t=e.attrs;return document.createTextNode(t.display||t.target)}case`mdFile`:{let t=e.attrs,n=document.createElement(`a`);return n.setAttribute(`href`,t.href),n.append(document.createTextNode(t.name||t.href)),n}default:return document.createTextNode(t)}}function F(e,t){return e.type.name===t}function Jn(){return p({name:`heading`,whitespace:`pre`})}function Yn(e){let t=e.attrs;return Hn(`h${t.level}`,e,{"data-setext-underline":t.setextUnderline==null?void 0:String(t.setextUnderline),"data-closing-hashes":t.closingHashes==null?void 0:String(t.closingHashes)})}function Xn(){return[1,2,3,4,5,6].map(e=>Un(`h${e}`,`heading`,t=>({level:e,setextUnderline:Pn(t.getAttribute(`data-setext-underline`))??null,closingHashes:Pn(t.getAttribute(`data-closing-hashes`))??null})))}function Zn(){return f({type:`heading`,attr:`setextUnderline`,default:null,toDOM:e=>e==null?null:[`data-setext-underline`,String(e)],parseDOM:e=>Pn(e.getAttribute(`data-setext-underline`))??null})}function Qn(){return f({type:`heading`,attr:`closingHashes`,default:null,toDOM:e=>e==null?null:[`data-closing-hashes`,String(e)],parseDOM:e=>Pn(e.getAttribute(`data-closing-hashes`))??null})}function I(e){return se(ie({type:`heading`,attrs:{level:e}}))}const $n=(e,t,n)=>{let r=te(e,n);return r!=null&&F(r.parent,`heading`)?ae()(e,t,n):!1};function er(){return l({"Mod-1":I(1),"Mod-2":I(2),"Mod-3":I(3),"Mod-4":I(4),"Mod-5":I(5),"Mod-6":I(6),Backspace:$n})}function tr(){return b(Xe(),Jn(),Zn(),Qn(),Ye(),Je(),er())}function nr(){return p({name:`paragraph`,content:`inline*`,group:`block`,whitespace:`pre`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}})}function rr(e){return Hn(`p`,e)}function ir(){return[Un(`p`,`paragraph`)]}function ar(){return b(x(nr(),t.highest),Ze(),Qe())}function or(e){return{...e,paragraph:e=>({dom:rr(e)}),heading:e=>({dom:Yn(e)})}}function sr(){return o({serializeFragmentWrapper:e=>(...t)=>{let n=e(...t);for(let e of n.children)e.setAttribute(`data-meowdown`,``);return n},nodesFromSchemaWrapper:e=>(...t)=>or(e(...t))})}const cr=new WeakMap;function lr(e){let t=cr.get(e);return t??(t=new Ke(or(Ke.nodesFromSchema(e)),Ke.marksFromSchema(e)),cr.set(e,t)),t}const ur=new T(`meowdown-html-paste`);function dr(e){return e.includes(`data-meowdown`)?!0:e.includes(`data-pm-slice`)&&e.includes(`md-mark`)}const fr=new Set([`html`,`head`,`body`,`meta`,`style`,`title`,`div`,`span`,`p`,`br`,`font`,`wbr`]);function pr(e){let t=new window.DOMParser().parseFromString(e,`text/html`),n={chunks:[],hasContent:!1,trailingNewlines:0,hasStyledLine:!1};if(gr(t.documentElement,n,!1)&&n.hasStyledLine)return n.chunks.join(``).replaceAll(Le,` `)}function mr(e,t){!e.hasContent||e.trailingNewlines>=t||hr(e,`
3
+ `.repeat(t-e.trailingNewlines))}function hr(e,t){if(!t)return;e.chunks.push(t);let n=t.length;for(;n>0&&t.charCodeAt(n-1)===10;)n--;n===0?e.trailingNewlines+=t.length:(e.hasContent=!0,e.trailingNewlines=t.length-n)}function gr(e,t,n){if(e.nodeType===Node.TEXT_NODE)return hr(t,e.nodeValue??``),!0;if(e.nodeType!==Node.ELEMENT_NODE)return!0;let r=e,i=r.tagName;if(!fr.has(i.toLowerCase()))return!1;if(n||=i===`DIV`,n&&r.getAttribute(`style`)?.trim()&&(t.hasStyledLine=!0),i===`BR`)return hr(t,`
4
+ `),!0;if(i===`STYLE`||i===`TITLE`)return!0;let a=i===`DIV`?1:i===`P`?2:0;a&&mr(t,a);for(let r of e.childNodes)if(!gr(r,t,n))return!1;return a&&mr(t,a),!0}function _r(){return m(new w({key:ur,props:{transformPastedHTML:(e,t)=>{if(dr(e))return e;let n=t.state.selection.$from.parent;if(!n.inlineContent||n.type.spec.code)return e;let r=pr(e)??Mn(e);if(!r.trim())return e;let i=X(r,{nodes:al(t.state.schema)}),a=lr(t.state.schema),o=document.createElement(`div`);return o.append(a.serializeFragment(i.content)),o.innerHTML}}}))}function vr(e){return new Ge(e,[...ir(),...Xn(),...Ge.fromSchema(e).rules])}const yr=new T(`meowdown-clipboard-parser`);function br(){return m(({schema:e})=>new w({key:yr,props:{clipboardParser:vr(e)}}))}function xr(e,t){let n=t.replaceAll(/\r\n?/g,`
5
+ `).replace(/^\n+/,``).replace(/\n+$/,``);if(!n)return k.empty;let r=X(n,{nodes:al(e)}),i=_(e,`paragraph`),a=+(r.childCount>0&&r.child(0).type===i),o=+(r.childCount>0&&r.child(r.childCount-1).type===i);return new k(r.content,a,o)}function Sr(e,t,n){let r=n.marks(),i=Ke.fromSchema(e),a=document.createElement(`div`);for(let n of t.split(/(?:\r\n?|\n)+/)){let t=a.appendChild(document.createElement(`p`));n&&t.appendChild(i.serializeNode(e.text(n,r)))}return Ge.fromSchema(e).parseSlice(a,{preserveWhitespace:!0,context:n})}function Cr(){let e;return m(new w({key:new T(`meowdown-plain-paste`),props:{clipboardTextParser:(t,n,r,i)=>{let{schema:a}=i.state;return r?Sr(a,t,n):e=xr(a,t)},transformPasted:t=>{if(e==null)return t;let n=e;return e=void 0,n}}}))}function wr(e,t,n=0){let r=n,i=0;for(let n=0;n<e.length;n++)e.charCodeAt(n)===t?(i++,i>r&&(r=i)):i=0;return r}function Tr(e,t=0){return wr(e,96,t)}function Er(e,t={}){let n=new Ar;return t.frontmatter&&Dr(e.attrs.frontmatter,n),jr(e,n),n.finish()}function Dr(e,t){e!==null&&(t.write(`---`),t.write(`
6
6
  `),e!==``&&(t.write(e),t.write(`
7
- `)),t.write(`---`),t.closeBlock())}const Dr=[``,`# `,`## `,`### `,`#### `,`##### `,`###### `];function Or(e,t){let n=e.attrs,r=n.setextUnderline;if(r!=null&&e.content.size>0&&n.level<=2){Pr(e,t);let i=n.level===1?`=`:`-`;t.write(`
8
- `+i.repeat(Math.max(1,r))),t.closeBlock();return}t.write(Dr[n.level]??`# `),Pr(e,t);let i=n.closingHashes;i!=null&&i>0&&t.write(` `+`#`.repeat(i)),t.closeBlock()}var kr=class{constructor(){this.parts=[],this.linePrefix=``,this.pendingFirst=null,this.atLineStart=!0,this.deferredBlankPrefix=null}write(e){if(e===``)return;if(this.emitDeferredBlankLine(),this.atLineStart&&=(this.parts.push(this.pendingFirst??this.linePrefix),this.pendingFirst=null,!1),!e.includes(`
7
+ `)),t.write(`---`),t.closeBlock())}const Or=[``,`# `,`## `,`### `,`#### `,`##### `,`###### `];function kr(e,t){let n=e.attrs,r=n.setextUnderline;if(r!=null&&e.content.size>0&&n.level<=2){Fr(e,t);let i=n.level===1?`=`:`-`;t.write(`
8
+ `+i.repeat(Math.max(1,r))),t.closeBlock();return}t.write(Or[n.level]??`# `),Fr(e,t);let i=n.closingHashes;i!=null&&i>0&&t.write(` `+`#`.repeat(i)),t.closeBlock()}var Ar=class{constructor(){this.parts=[],this.linePrefix=``,this.pendingFirst=null,this.atLineStart=!0,this.deferredBlankPrefix=null}write(e){if(e===``)return;if(this.emitDeferredBlankLine(),this.atLineStart&&=(this.parts.push(this.pendingFirst??this.linePrefix),this.pendingFirst=null,!1),!e.includes(`
9
9
  `)){this.parts.push(e);return}let t=e.split(`
10
10
  `);for(let e=0;e<t.length;e++)e>0&&this.parts.push(`
11
11
  `,this.linePrefix),t[e]!==``&&this.parts.push(t[e])}closeEmptyBlock(){if(!this.atLineStart||this.pendingFirst!==null){this.closeBlock();return}this.parts.length!==0&&(this.emitDeferredBlankLine(),this.deferredBlankPrefix=this.linePrefix)}closeBlock(){this.atLineStart&&this.pendingFirst!==null&&(this.emitDeferredBlankLine(),this.parts.push(this.pendingFirst.trimEnd()),this.pendingFirst=null,this.atLineStart=!1),this.atLineStart||this.parts.push(`
12
12
  `),this.atLineStart=!0,this.deferredBlankPrefix=this.linePrefix}suppressBlank(){this.deferredBlankPrefix=null}withPrefix(e,t,n){let r=this.linePrefix,i=this.pendingFirst;if(this.linePrefix=r+e,t!==null){let e=i??r;this.pendingFirst=e+t}n(),this.linePrefix=r,this.pendingFirst=t===null?i:null}finish(){return this.parts.join(``).replace(/\s+$/,``)+`
13
13
  `}emitDeferredBlankLine(){let e=this.deferredBlankPrefix;e!==null&&(this.parts.push(e.trimEnd(),`
14
- `),this.deferredBlankPrefix=null)}};function Ar(e,t){switch(e.type.name){case`doc`:jr(e,t);return;case`paragraph`:if(e.childCount===0){t.closeEmptyBlock();return}Pr(e,t),t.closeBlock();return;case`heading`:Or(e,t);return;case`blockquote`:t.withPrefix(`> `,`> `,()=>jr(e,t)),t.closeBlock();return;case`list`:Fr(e,t,Nr(e));return;case`codeBlock`:Ir(e,t);return;case`horizontalRule`:{let{marker:n}=e.attrs;t.write(n||`---`),t.closeBlock();return}case`htmlComment`:{let{content:n}=e.attrs;t.write(n),t.closeBlock();return}case`table`:zr(e,t);return;case`text`:e.text&&t.write(e.text);return}}function jr(e,t,n=!1){let r=e.childCount,i=0;for(;i<r;){let a=e.child(i);if(!L(a,`list`)){n&&i>0&&t.suppressBlank(),Ar(a,t),i++;continue}let o=i+1;for(;o<r&&L(e.child(o),`list`);)o++;let s=Mr(e,i,o);for(let r=i;r<o;r++)(r===i?n&&i>0:s)&&t.suppressBlank(),Fr(e.child(r),t,s);i=o}}function Mr(e,t,n){for(let r=t;r<n;r++)if(!Nr(e.child(r)))return!1;return!0}function Nr(e){let t=e.childCount;for(let n=0;n<t;n++){let t=e.child(n).type.name;if(t!==`list`&&(t!==`paragraph`||n!==0))return!1}return!0}function Pr(e,t){let n=e.childCount;for(let r=0;r<n;r++){let n=e.child(r);n.isText&&n.text&&t.write(n.text)}}function Fr(e,t,n){let{kind:r,marker:i,order:a,taskMarker:o,collapsed:s,markerGap:c,checked:l}=e.attrs,u=r===`task`?i===`+`?`+`:i===`*`?`*`:`-`:s?`+`:i===`*`?`*`:`-`,d=i===`)`?`)`:`.`,f=o===`X`?`X`:`x`,p=Math.min(Math.max(c??1,1),4),m=`${r===`ordered`?`${a??1}${d}`:u}${` `.repeat(p)}`,h=r===`task`?`${m}[${l?f:` `}] `:m,g=` `.repeat(m.length);t.withPrefix(g,h,()=>jr(e,t,n)),t.closeBlock()}function Ir(e,t){let n=e.attrs,r=n.language||``,i=e.textContent;if(n.fenceStyle===`indented`&&!r){let e=Lr(i);if(e!=null){t.write(e),t.closeBlock();return}}if(n.fenceStyle===`dollar`&&r===`math`&&!Rr(i)){t.write(`$$`),t.write(`
14
+ `),this.deferredBlankPrefix=null)}};function jr(e,t){switch(e.type.name){case`doc`:Mr(e,t);return;case`paragraph`:if(e.childCount===0){t.closeEmptyBlock();return}Fr(e,t),t.closeBlock();return;case`heading`:kr(e,t);return;case`blockquote`:t.withPrefix(`> `,`> `,()=>Mr(e,t)),t.closeBlock();return;case`list`:Ir(e,t,Pr(e));return;case`codeBlock`:Lr(e,t);return;case`horizontalRule`:{let{marker:n}=e.attrs;t.write(n||`---`),t.closeBlock();return}case`htmlComment`:{let{content:n}=e.attrs;t.write(n),t.closeBlock();return}case`table`:Br(e,t);return;case`text`:e.text&&t.write(e.text);return}}function Mr(e,t,n=!1){let r=e.childCount,i=0;for(;i<r;){let a=e.child(i);if(!F(a,`list`)){n&&i>0&&t.suppressBlank(),jr(a,t),i++;continue}let o=i+1;for(;o<r&&F(e.child(o),`list`);)o++;let s=Nr(e,i,o);for(let r=i;r<o;r++)(r===i?n&&i>0:s)&&t.suppressBlank(),Ir(e.child(r),t,s);i=o}}function Nr(e,t,n){for(let r=t;r<n;r++)if(!Pr(e.child(r)))return!1;return!0}function Pr(e){let t=e.childCount;for(let n=0;n<t;n++){let t=e.child(n).type.name;if(t!==`list`&&(t!==`paragraph`||n!==0))return!1}return!0}function Fr(e,t){let n=e.childCount;for(let r=0;r<n;r++){let n=e.child(r);n.isText&&n.text&&t.write(n.text)}}function Ir(e,t,n){let{kind:r,marker:i,order:a,taskMarker:o,collapsed:s,markerGap:c,checked:l}=e.attrs,u=r===`task`?i===`+`?`+`:i===`*`?`*`:`-`:s?`+`:i===`*`?`*`:`-`,d=i===`)`?`)`:`.`,f=o===`X`?`X`:`x`,p=Math.min(Math.max(c??1,1),4),m=`${r===`ordered`?`${a??1}${d}`:u}${` `.repeat(p)}`,h=r===`task`?`${m}[${l?f:` `}] `:m,g=` `.repeat(m.length);t.withPrefix(g,h,()=>Mr(e,t,n)),t.closeBlock()}function Lr(e,t){let n=e.attrs,r=n.language||``,i=e.textContent;if(n.fenceStyle===`indented`&&!r){let e=Rr(i);if(e!=null){t.write(e),t.closeBlock();return}}if(n.fenceStyle===`dollar`&&r===`math`&&!zr(i)){t.write(`$$`),t.write(`
15
15
  `),i&&(t.write(i),t.write(`
16
- `)),t.write(`$$`),t.closeBlock();return}let a=n.fenceStyle===`tilde`,o=Cr(i,a?126:96,2)+1,s=(a?`~`:"`").repeat(Math.max(n.fenceLength??0,o));t.write(s),r&&t.write(r),t.write(`
16
+ `)),t.write(`$$`),t.closeBlock();return}let a=n.fenceStyle===`tilde`,o=wr(i,a?126:96,2)+1,s=(a?`~`:"`").repeat(Math.max(n.fenceLength??0,o));t.write(s),r&&t.write(r),t.write(`
17
17
  `),i&&(t.write(i),t.write(`
18
- `)),t.write(s),t.closeBlock()}function Lr(e){if(e===``)return;let t=e.split(`
18
+ `)),t.write(s),t.closeBlock()}function Rr(e){if(e===``)return;let t=e.split(`
19
19
  `);if(t[0]!==``&&t[t.length-1]!==``){for(let e=0;e<t.length;e++)t[e]!==``&&(t[e]=` ${t[e]}`);return t.join(`
20
- `)}}function Rr(e){return e.split(`
21
- `).some(e=>e.trim()===`$$`)}function zr(e,t){let n=e.childCount;if(n===0)return;let r=[],i=0,a=-1;for(let t=0;t<n;t++){let n=e.child(t),o=[],s=!1;for(let e=0;e<n.childCount;e++){let t=n.child(e);L(t,`tableHeaderCell`)&&(s=!0),o.push(Hr(t))}s&&a<0&&(a=t),o.length>i&&(i=o.length),r.push(o)}if(i===0)return;let o=e.child(a>=0?a:0),s=[];for(let e=0;e<i;e++){let t=e<o.childCount?o.child(e):void 0,n=t?t.attrs.align:void 0;s.push(Br(n))}let c=`| `+s.join(` | `)+` |`,l=a>=0?r[a]:Array(i).fill(``);t.write(Vr(l,i)),t.write(`
20
+ `)}}function zr(e){return e.split(`
21
+ `).some(e=>e.trim()===`$$`)}function Br(e,t){let n=e.childCount;if(n===0)return;let r=[],i=0,a=-1;for(let t=0;t<n;t++){let n=e.child(t),o=[],s=!1;for(let e=0;e<n.childCount;e++){let t=n.child(e);F(t,`tableHeaderCell`)&&(s=!0),o.push(Ur(t))}s&&a<0&&(a=t),o.length>i&&(i=o.length),r.push(o)}if(i===0)return;let o=e.child(a>=0?a:0),s=[];for(let e=0;e<i;e++){let t=e<o.childCount?o.child(e):void 0,n=t?t.attrs.align:void 0;s.push(Vr(n))}let c=`| `+s.join(` | `)+` |`,l=a>=0?r[a]:Array(i).fill(``);t.write(Hr(l,i)),t.write(`
22
22
  `),t.write(c);for(let e=0;e<n;e++)e!==a&&(t.write(`
23
- `),t.write(Vr(r[e],i)));t.closeBlock()}function Br(e){switch(e){case`left`:return`:--`;case`center`:return`:-:`;case`right`:return`--:`;default:return`---`}}function Vr(e,t){let n=`|`;for(let r=0;r<t;r++)n+=` `+(e[r]??``)+` |`;return n}function Hr(e){let t=e.textContent.trim();return!t.includes(`|`)&&!t.includes(`
23
+ `),t.write(Hr(r[e],i)));t.closeBlock()}function Vr(e){switch(e){case`left`:return`:--`;case`center`:return`:-:`;case`right`:return`--:`;default:return`---`}}function Hr(e,t){let n=`|`;for(let r=0;r<t;r++)n+=` `+(e[r]??``)+` |`;return n}function Ur(e){let t=e.textContent.trim();return!t.includes(`|`)&&!t.includes(`
24
24
  `)?t:t.replaceAll(`|`,String.raw`\|`).replaceAll(`
25
- `,` `)}function Ur(e){if(e.depth===0)return!0;if(e.parentOffset!==0)return!1;for(let t=1;t<e.depth;t++)if(e.index(t)!==0)return!1;return!0}function Wr(e){if(e.depth===0)return!0;if(e.parentOffset!==e.parent.content.size)return!1;for(let t=1;t<e.depth;t++)if(e.indexAfter(t)!==e.node(t).childCount)return!1;return!0}function Gr(e,t,n){let r=Kr(e,t,n),i;try{i=e.topNodeType.createAndFill(void 0,r)??void 0}catch{i=void 0}return i?Tr(i).replace(/\n+$/,``):r.textBetween(0,r.size,`
25
+ `,` `)}function Wr(e){if(e.depth===0)return!0;if(e.parentOffset!==0)return!1;for(let t=1;t<e.depth;t++)if(e.index(t)!==0)return!1;return!0}function Gr(e){if(e.depth===0)return!0;if(e.parentOffset!==e.parent.content.size)return!1;for(let t=1;t<e.depth;t++)if(e.indexAfter(t)!==e.node(t).childCount)return!1;return!0}function Kr(e,t,n){let r=qr(e,t,n),i;try{i=e.topNodeType.createAndFill(void 0,r)??void 0}catch{i=void 0}return i?Er(i).replace(/\n+$/,``):r.textBetween(0,r.size,`
26
26
  `,`
27
- `)}function Kr(e,t,n){let{content:r,openStart:i,openEnd:a}=t;if(r.childCount===0||i===0&&a===0)return r;let o=y(n)&&Ur(n.$from),s=y(n)&&Wr(n.$to),c=r.childCount-1,l=[];return r.forEach((t,n,r)=>{r===0&&i>0&&!o?l.push(Jr(e,t)):r===c&&a>0&&!s?l.push(qr(e,t,a)):l.push(t)}),O.from(l)}function qr(e,t,n){if(L(t,`codeBlock`)||L(t,`table`))return Jr(e,t);if(L(t,`heading`)){let n=t.attrs;if(n.setextUnderline!=null)return Jr(e,t);if(n.closingHashes!=null)return t.type.create({...n,closingHashes:null},t.content,t.marks)}if(n<=1||t.childCount===0)return t;let r=t.childCount-1,i=t.child(r),a=qr(e,i,n-1);return a===i?t:t.copy(t.content.replaceChild(r,a))}function Jr(e,t){let n=_(e,`paragraph`),r=t.textBetween(0,t.content.size,`
27
+ `)}function qr(e,t,n){let{content:r,openStart:i,openEnd:a}=t;if(r.childCount===0||i===0&&a===0)return r;let o=y(n)&&Wr(n.$from),s=y(n)&&Gr(n.$to),c=r.childCount-1,l=[];return r.forEach((t,n,r)=>{r===0&&i>0&&!o?l.push(Yr(e,t)):r===c&&a>0&&!s?l.push(Jr(e,t,a)):l.push(t)}),O.from(l)}function Jr(e,t,n){if(F(t,`codeBlock`)||F(t,`table`))return Yr(e,t);if(F(t,`heading`)){let n=t.attrs;if(n.setextUnderline!=null)return Yr(e,t);if(n.closingHashes!=null)return t.type.create({...n,closingHashes:null},t.content,t.marks)}if(n<=1||t.childCount===0)return t;let r=t.childCount-1,i=t.child(r),a=Jr(e,i,n-1);return a===i?t:t.copy(t.content.replaceChild(r,a))}function Yr(e,t){let n=_(e,`paragraph`),r=t.textBetween(0,t.content.size,`
28
28
  `,`
29
- `);return n.create(void 0,r?e.text(r):void 0)}function Yr(){return m(new w({key:new T(`meowdown-plain-text-copy`),props:{clipboardTextSerializer:(e,t)=>{let n=N(t.state)===`hide`?Xr(e):e;return Gr(t.state.schema,n,t.state.selection)}}}))}function Xr(e){return new k(Zr(e.content),e.openStart,e.openEnd)}function Zr(e){let t=[];return e.forEach(e=>{t.push(e.isTextblock?$r(e):Qr(e))}),O.from(t)}function Qr(e){return e.childCount>0?e.copy(Zr(e.content)):e}function $r(e){let t=e.type.schema,n=[];for(let r of zn(e)){let e=r.atom;if(e!=null){if(Pn(e,`mdWikilink`)){let r=e.attrs,i=r.display||r.target;i&&n.push(t.text(i))}else n.push(...r.children);continue}for(let e of r.children)Rn(e.marks)||n.push(e)}return e.copy(O.from(n))}function ei(){return b(or(),Yr(),yr(),gr(),Sr())}const z=new Map,ti=new Map,ni={math:`latex`};async function ri(e){let t=z.get(e);if(t!==void 0)return t;let n=Je.matchLanguageName(Ye,ni[e]??e,!0);if(!n)return z.set(e,null),null;let r=n.support;if(!r)try{r=await n.load()}catch(t){return console.error(`[meowdown] Failed to load language "${e}":`,t),z.set(e,null),null}return z.set(e,r),r}function ii(e,t){let n=ti.get(e);if(n)return n;let r=Qe({parse:e=>t.language.parser.parse(e.content),highlighter:Xe});return ti.set(e,r),r}const ai=e=>{let t=e.language?.trim();if(!t)return[];let n=z.get(t);return n===null?[]:n?ii(t,n)(e):ri(t).then(()=>void 0)};function oi(){return le({parser:ai,nodeTypes:[`codeBlock`]})}function si(e,t){let n=t.language.parser.parse(e),r=[];return Ze(n,Xe,(e,t,n)=>{r.push([e,t,n])}),r}function ci(e,t){let n=t.trim();if(!n)return[];let r=z.get(n);return r===null?[]:r?si(e,r):ri(n).then(t=>t?si(e,t):[])}function li(){return f({type:`codeBlock`,attr:`fenceStyle`,default:null,toDOM:e=>e==null?null:[`data-fence-style`,e],parseDOM:e=>{let t=e.getAttribute(`data-fence-style`);return t===`tilde`||t===`indented`||t===`dollar`?t:null}})}function ui(){return f({type:`codeBlock`,attr:`fenceLength`,default:null,toDOM:e=>e==null?null:[`data-fence-length`,String(e)],parseDOM:e=>{let t=Mn(e.getAttribute(`data-fence-length`));return t!=null&&t>3?t:null}})}function di(e){return{language:e[1]||``,fenceStyle:`tilde`}}function fi(){return nt({regex:/^~~~(\S*)\s$/,type:`codeBlock`,attrs:di})}function pi(){return et({regex:/^~~~(\S*)$/,type:`codeBlock`,attrs:di})}function mi(){return et({regex:/^\$\$$/,type:`codeBlock`,attrs:()=>({language:`math`,fenceStyle:`dollar`})})}function hi(){return b(ce(),li(),ui(),fi(),pi(),mi())}function gi(e,t){return(n,r)=>{if(r){let i=E.create(n.doc,e,t);r(n.tr.setSelection(i))}return!0}}function _i(e,t,n){return(r,i)=>{if(i){let a=E.between(e,t,n);i(r.tr.setSelection(a))}return!0}}function vi(e){return(t,n)=>{if(!e.trim())return!1;let r=Z(e,{nodes:ol(t.schema)}).content;if(r.childCount===0)return!1;let i=r.childCount===1&&L(r.child(0),`paragraph`)?new k(r,1,1):new k(r,0,k.maxOpen(r).openEnd);if(n){let e=t.tr,r=e.selection;(!y(r)||!r.empty)&&e.setSelection(E.near(r.$from)),n(e.replaceSelection(i).scrollIntoView())}return!0}}function yi(e){return(t,n)=>{if(!e)return!1;let r=t.selection.$from;if(r.parent.type.spec.code)return!1;if(n){let i=r.parentOffset,a=i===0?``:r.parent.textBetween(i-1,i),o=a!==``&&!/\s/u.test(a),s=t.tr.insertText(o?` ${e}`:e);rt(s),n(s.scrollIntoView())}return!0}}function bi(){return ft(re({type:`paragraph`}),ut(),pt)}function xi(){return(e,t)=>(t&&t(e.tr.scrollIntoView()),!0)}function Si(){return s({insertMarkdown:vi,insertTrigger:yi,scrollIntoView:xi,selectText:gi,selectTextBetween:_i,turnIntoText:bi})}const Ci=new Set;function wi(e){for(let t of Ci)if(t!==e&&!t.isDestroyed&&t.editable&&t.dragging)return t}function Ti(e,t){let n=e.state.tr;if(t.node){if(e.state.doc.nodeAt(t.node.from)!==t.node.node)return;t.node.replace(n)}else n.deleteSelection();n.docChanged&&e.dispatch(n.setMeta(`uiEvent`,`drop`))}function Ei(e,t,n,r){if(r||n.size===0)return!1;let i=wi(e);if(!i)return!1;let a=i.dragging;if(!a||(ee?t.altKey:t.ctrlKey))return!1;i.dragging=null;let o=e.state.doc;return queueMicrotask(()=>{i.isDestroyed||e.isDestroyed||e.state.doc!==o&&Ti(i,a)}),!1}function Di(){return new w({key:new T(`meowdown-cross-editor-drag`),view:e=>(Ci.add(e),{destroy:()=>{Ci.delete(e)}}),props:{handleDrop:Ei}})}function Oi(){return x(m(Di()),t.high)}const ki=(e,t,n)=>{let{selection:r}=e;return r.empty||n?.composing?!1:(t?.(e.tr.setSelection(E.near(r.$head))),!0)};function Ai(){return x(l({Escape:ki}),t.low)}function ji(e){return new ht({search:e,literal:!0})}function Mi(e){return(t,n)=>{let r=ji(e);if(_t(t)?.query.eq(r))return!1;if(n){let e=yt(t.tr,r),i=r.findNext(t,t.selection.from)??r.findNext(t);i&&e.setSelection(E.create(e.doc,i.from,i.to)).scrollIntoView(),n(e)}return!0}}function Ni(e){let t=gt(e).find(),{from:n,to:r}=e.selection;return{total:t.length,active:t.findIndex(e=>e.from===n&&e.to===r)+1}}const Pi=new w({props:{decorations:e=>{let{from:t,to:n,empty:r}=e.selection;if(!r&&gt(e).find(t,n).some(e=>e.from===t&&e.to===n))return D.create(e.doc,[je.inline(t,n,{class:`show`})])}}});function Fi(){return b(m([vt(),Pi]),mt(),s({setSearchQuery:Mi}))}function Ii(e){return m(new w({view:t=>{let n=Ni(t.state);return{update:t=>{let r=Ni(t.state);(r.total!==n.total||r.active!==n.active)&&(n=r,e(r))}}}}))}function Li(){return f({type:`doc`,attr:`frontmatter`,default:null})}function Ri(e,t){return t(e.state,e.dispatch,e)}function zi(e,t){if(t<0||t+1>e.doc.content.size)return;let n=e.doc.resolve(t),r=n.parent.maybeChild(n.index());if(!(r==null||!r.isText))return r.marks}function B(e,t){let n=zi(e,t);return n!=null&&n.some(e=>Fn.has(e.type.name))}function Bi(e,t){if(t<0||t>e.doc.content.size)return!1;let n=e.doc.resolve(t);return n.parent.isTextblock&&!n.parent.type.spec.code}function V(e,t){if(!Bi(e,t))return;let n=e.doc.resolve(t).start(),r=t;for(;r>n&&B(e,r-1);)r--;return r<t?{from:r,to:t}:void 0}function H(e,t){if(!Bi(e,t))return;let n=e.doc.resolve(t).end(),r=t;for(;r<n&&B(e,r);)r++;return r>t?{from:t,to:r}:void 0}function Vi(e,t){return B(e,t-1)&&B(e,t)}function Hi(e,t){if(!Vi(e,t))return;let n=V(e,t);if(!n)return;let r=H(e,t);if(r)return{from:n.from,to:r.to}}function Ui(e,t,n){let r=zi(e,t);return r!=null&&n.isInSet(r)}function Wi(e,t){let n=zi(e,t);if(n==null)return;let r=g(e.schema,`mdPack`),i=n.filter(e=>e.type===r);if(i.length===0)return;let a=e.doc.resolve(t),o=a.start(),s=a.end(),c;for(let n of i){let r=t;for(;r>o&&Ui(e,r-1,n);)r--;let i=t+1;for(;i<s&&Ui(e,i,n);)i++;(c==null||i-r<c.to-c.from)&&(c={from:r,to:i})}return c}function Gi(e,t,n){let r=Wi(e,n===`from`?t.from:t.to-1);return r==null?!1:n===`from`?r.from===t.from:r.to===t.to}function Ki(e,t,n){let r=Gi(e,t,`from`),i=Gi(e,t,`to`);return r&&!i?t.from:i&&!r?t.to:n-t.from<=t.to-n?t.from:t.to}function qi(e,t,n,r){if(!Bi(e,n))return n;let i=Hi(e,n);if(i!=null)return r?Ki(e,i,n):n>=t?i.to:i.from;if(!r)return n;let a=V(e,n);if(a!=null&&Gi(e,a,`from`))return a.from;let o=H(e,n);return o!=null&&Gi(e,o,`to`)?o.to:n}function Ji(e,t){if(!Bi(e,t))return;let n=B(e,t-1),r=B(e,t);if(n!==r)return r?`left`:`right`}function Yi(e,t){let n=Wi(e,t);if(n==null)return[];let r=H(e,n.from),i=V(e,n.to),a=[];return i!=null&&a.push(i),r!=null&&(i==null||r.from!==i.from)&&a.push(r),a}const Xi=new T(`meowdown-hidden-run-snap`),Zi=new T(`meowdown-hidden-run-beforeinput`);function Qi(){let e=!1;return new w({key:Xi,props:{handleDOMEvents:{compositionstart:()=>(e=!0,!1),compositionend:()=>(e=!1,!1)}},appendTransaction:(t,n,r)=>{if(e||N(r)!==`hide`)return null;let i=r.selection;if(!y(i))return null;let a=t.some(e=>e.getMeta(`pointer`)!=null);if(i.empty){let e=qi(r,n.selection.head,i.head,a);return e===i.head?null:r.tr.setSelection(E.create(r.doc,e))}let o=Hi(r,i.from)?.from??i.from,s=Hi(r,i.to)?.to??i.to;if(o===i.from&&s===i.to)return null;let c=i.anchor===i.from?o:s,l=i.head===i.from?o:s;return r.tr.setSelection(E.create(r.doc,c,l))}})}const $i=(e,t)=>{if(N(e)!==`hide`)return!1;let n=e.selection;if(!y(n)||!n.empty)return!1;let r=qi(e,n.head,n.head,!0);return r===n.head||t?.(e.tr.setSelection(E.create(e.doc,r))),!1};function ea(e){return(t,n)=>{if(N(t)!==`hide`)return!1;let r=t.selection;if(!y(r)||!r.empty)return!1;let i=r.$head;if(!i.parent.isTextblock||i.parent.type.spec.code)return!1;let a=e===-1?V(t,r.head):H(t,r.head);if(a==null)return!1;let o=Yi(t,e===-1?a.to-1:a.from),s=t.tr;if(o.length===0)s.delete(a.from,a.to);else for(let e of o)s.delete(e.from,e.to);return n?.(s),!0}}const ta=ea(-1),na=ea(1);function ra(){return new w({key:Zi,props:{handleDOMEvents:{beforeinput:(e,t)=>{if(e.composing)return!1;let n=t.inputType===`deleteContentBackward`?ta:t.inputType===`deleteContentForward`?na:void 0;return n==null||!Ri(e,n)?!1:(t.preventDefault(),!0)}}}})}function ia(){return b(m(Qi()),m(ra()),x(l({Enter:$i,Backspace:ta,Delete:na}),t.highest))}function aa(){return f({type:`horizontalRule`,attr:`marker`,default:null,toDOM:e=>e?[`data-hr-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-hr-marker`)})}function oa(){return b(bt(),aa())}function sa(){return p({name:`htmlComment`,group:`block`,atom:!0,selectable:!1,attrs:{content:{default:``}},toDOM:e=>[`div`,{"data-html-comment":e.attrs.content,style:`display: none`}],parseDOM:[{tag:`div[data-html-comment]`,getAttrs:e=>({content:e.getAttribute(`data-html-comment`)??``})}]})}function ca(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function la(e,t){let[n,r,i]=t;return[n,r,i.map(t=>He.fromJSON(e,t))]}function ua(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}function da(e,t){let n=e.content.size,r;for(let[i,a,o]of t){if(i>=a)continue;let t=Math.max(0,Math.min(i,n)),s=Math.max(t,Math.min(a,n));if(t>=s)continue;let c=He.setFrom(o);e.nodesBetween(t,s,(n,i)=>{if(!n.isText)return!0;let a=Math.max(t,i),o=Math.min(s,i+n.nodeSize);if(a>=o||ua(n.marks,c))return!1;r??=new Ot(e);for(let e of n.marks)r.removeMark(a,o,e);for(let e of c)r.addMark(a,o,e);return!1})}return A.ok(r?.doc??e)}function fa(e,t){let n=e.content.size,r=[...t].filter(([e,t])=>e<t&&e<n).sort((e,t)=>e[0]-t[0]);if(r.length===0)return A.ok(e);let i=r.map(([,,e])=>He.setFrom(e)),a=Math.max(0,r[0][0]),o=0;for(let[,e]of r)e>o&&(o=e);if(o=Math.min(o,n),a>=o)return A.ok(e);let s=0;function c(e,t){let n=t+e.nodeSize;for(;s<r.length&&r[s][1]<=t;)s++;let a=[],o=t,c=!1;for(let t=s;t<r.length;t++){let[s,l]=r[t];if(s>=n)break;let u=Math.max(s,o),d=Math.min(l,n);if(u>=d)continue;u>o&&a.push({from:o,to:u,marks:void 0});let f=i[t],p=!ua(e.marks,f);p&&(c=!0),a.push({from:u,to:d,marks:p?f:void 0}),o=d}if(c)return o<n&&a.push({from:o,to:n,marks:void 0}),a.map(n=>{let r=e.cut(n.from-t,n.to-t);return n.marks==null?r:r.mark(n.marks)})}function l(e,t){let n,r=t;for(let t=0;t<e.childCount;t++){let i=e.child(t),s=r+i.nodeSize,u=i;if(s>a&&r<o){if(i.isText)u=c(i,r)??i;else if(i.childCount>0){let e=l(i,r+1);e!=null&&(u=i.copy(e))}}if(u!==i&&n==null){n=[];for(let r=0;r<t;r++)n.push(e.child(r))}n!=null&&(Array.isArray(u)?n.push(...u):n.push(u)),r=s}return n==null?void 0:O.fromArray(n)}let u=l(e,0);return A.ok(u==null?e:e.copy(u))}var pa=class e extends Dt{constructor(e){super(),this.chunks=e}apply(e){return this.chunks.length===0?A.ok(e):this.chunks.length<=32?da(e,this.chunks):fa(e,this.chunks)}invert(e){if(this.chunks.length===0)return ma;let t=this.chunks[0][0],n=this.chunks[0][1];for(let[,e]of this.chunks)e>n&&(n=e);let r=e.content.size,i=Math.max(0,Math.min(t,r)),a=Math.max(i,Math.min(n,r));return new Et(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(ca)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>la(t,e)))}};Dt.jsonID(`batchSetMark`,pa);const ma=new pa([]),ha=/^<!--\s*(\{[^}]*\})\s*-->$/,ga=/<!--\s*\{[^}]*\}\s*-->$/;function _a(e){let t=ha.exec(e.trim());if(!t)return;let n;try{n=JSON.parse(t[1])}catch{return}if(!xe(n))return;let r=va(n);return Object.keys(r).length>0?r:void 0}function va(e){let t={},{width:n,height:r}=e;return typeof n==`number`&&Number.isFinite(n)&&n>0&&(t.width=Math.round(n)),typeof r==`number`&&Number.isFinite(r)&&r>0&&(t.height=Math.round(r)),t}function ya(e){return`<!-- ${JSON.stringify(e)} -->`}function ba(e){return e.replace(ga,``)}function xa(e){return At(e)}function Sa(e){if(e.length>1024)return!1;let t=e.search(/\S/);return t<0||e.charCodeAt(t)!==91?!1:e.includes(`]:`,t+1)}function Ca(e){if(!Sa(e))return;let t=_e.parse(e).topNode.firstChild;if(t?.type.id===S.LinkReference&&t.nextSibling==null)return t}function wa(e){return kt(e.startsWith(`<`)&&e.endsWith(`>`)?e.slice(1,-1):e)}function Ta(e){return e.length<2?``:kt(e.slice(1,-1))}function Ea(e){let t=Ca(e);if(t==null)return;let n=t.getChild(`LinkLabel`),r=t.getChild(`URL`);if(n==null||r==null)return;let i=xa(e.slice(n.from+1,n.to-1));if(i===``)return;let a=t.getChild(`LinkTitle`);return{key:i,href:wa(e.slice(r.from,r.to)),title:a==null?``:Ta(e.slice(a.from,a.to))}}function Da(e,t){return e==null?!0:L(e,`tableCell`)||L(e,`tableHeaderCell`)?!1:!L(e,`list`)||e.attrs.kind!==`task`||t>0}function Oa(e,t,n){return L(e,`paragraph`)&&Da(t,n)}const ka=new WeakMap;function Aa(e,t,n){if(!Oa(e,t,n))return;if(ka.has(e))return ka.get(e);let r=Ea(e.textContent);return ka.set(e,r),r}function ja(e,t,n){return Aa(e,t,n)!=null}function Ma(e){let t=new Map,n=new Set;return e.descendants((e,r,i,a)=>{if(e.type.spec.code)return!1;if(!e.isTextblock)return!0;let o=Aa(e,i,a);return o!=null&&(n.add(e),t.has(o.key)||t.set(o.key,o)),!1}),{definitions:t,nodes:n}}function Na(e,t,n){let r=e.content.size,i=!1;return e.nodesBetween(Math.max(0,t-1),Math.min(r,n+1),(e,t,n,r)=>i||e.type.spec.code?!1:e.isTextblock?(Oa(e,n,r)&&(ka.has(e)?ka.get(e)!=null:Sa(e.textContent))&&(i=!0),!1):!0),i}function Pa(e){if(e.steps.some(e=>e instanceof Ct&&e.attr===`kind`))return!0;for(let[t,n]of e.mapping.maps.entries()){let r=e.docs[t],i=t+1<e.docs.length?e.docs[t+1]:e.doc,a=!1;if(n.forEach((e,t,n,o)=>{a||=Na(r,e,t)||Na(i,n,o)}),a)return!0}return!1}function Fa(e,t,n){return!t.docChanged||!Pa(t)?e:Ma(n)}const Ia=/^(\d+)(?:x(\d+))?$/i;function La(e){if(!e)return null;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)&&t>0?t:null}function Ra(e){let t=e.replace(/^!\[\[/,``).replace(/\]\]$/,``),n=t.lastIndexOf(`|`);if(n<0)return{target:t.trim(),display:``,width:null,height:null};let r=t.slice(0,n).trim(),i=t.slice(n+1).trim(),a=Ia.exec(i);if(!a)return{target:r,display:i,width:null,height:null};let o=La(a[1]),s=La(a[2]);return o==null||a[2]&&s==null?{target:r,display:i,width:null,height:null}:{target:r,display:``,width:o,height:s}}function za(e,t,n){return`![[${e}|${Math.round(t)}x${Math.round(n)}]]`}function Ba(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function Va(e){let t=e.replace(/^\[\[/,``).replace(/\]\]$/,``),n=t.indexOf(`|`);return n<0?{target:t.trim(),display:``}:{target:t.slice(0,n).trim(),display:t.slice(n+1).trim()}}function Ha(){return e=>{let t=e.attrs,n=document.createElement(`span`);n.className=`md-wikilink-view md-atom-view`;let r=document.createElement(`span`);r.className=`md-wikilink-view-preview md-atom-view-preview`,r.contentEditable=`false`,r.dataset.testid=`wikilink`,n.appendChild(r);let i=document.createElement(`span`);i.className=`md-wikilink-view-label`,i.contentEditable=`false`,i.textContent=t.display||t.target,r.appendChild(i);let a=document.createElement(`span`);return a.className=`md-wikilink-view-content md-atom-view-content`,n.appendChild(a),{dom:n,contentDOM:a,ignoreMutation:e=>!a.contains(e.target)}}}function Ua(){return d({name:`mdWikilink`,constructor:Ha()})}const Wa=new Map([[S.Emphasis,`mdEm`],[S.StrongEmphasis,`mdStrong`],[S.InlineCode,`mdCode`],[S.Strikethrough,`mdDel`],[S.Highlight,`mdHighlight`],[S.EmphasisMark,`mdMark`],[S.CodeMark,`mdMark`],[S.LinkMark,`mdMark`],[S.StrikethroughMark,`mdMark`],[S.HighlightMark,`mdMark`],[S.URL,`mdLinkUri`],[S.LinkTitle,`mdLinkTitle`],[S.Hashtag,`mdTag`],[S.WikilinkMark,`mdMark`]]);function Ga(e,t,n){return Ka(e,t,n)}function Ka(e,t,n,r){let i=ve(t),a=[];return Ja(i,[],0,t.length,t,e,a,n,r),a}function qa(e){return e.slice(1,-1).replaceAll(/\\(.)/g,`$1`)}function Ja(e,t,n,r,i,a,o,s,c){let l=n;for(let n=0;n<e.length;n++){let r=e[n];if(r.from>l&&U(o,l,r.from,t),r.type===S.Image){let u=ao(r,e[n+1],i);oo(r,t,i,a,o,s,c,u),u&&n++,l=u?u.to:r.to;continue}Ya(r,t,i,a,o,s,c),l=r.to}l<r&&U(o,l,r,t)}function Ya(e,t,n,r,i,a,o){switch(e.type){case S.Link:return Qa(e,t,n,r,i,a,o);case S.Wikilink:return co(e,t,n,r,i);case S.WikiEmbed:return lo(e,t,n,r,i,a);case S.InlineMath:return so(e,t,n,r,i);case S.URL:return Za(e,t,n,r,i);default:return Xa(e,t,n,r,i,a,o)}}function Xa(e,t,n,r,i,a,o){let s=e.type,c;s===S.Emphasis?c=`italic`:s===S.StrongEmphasis?c=`bold`:s===S.InlineCode?c=`code`:s===S.Strikethrough?c=`strike`:s===S.Highlight?c=`highlight`:s===S.Autolink&&(c=`autolink`);let l=c?[...t,r.mdPack.create({key:c})]:t,u=Wa.get(s),d=u?[...l,r[u].create()]:l;e.children.length===0?U(i,e.from,e.to,d):Ja(e.children,d,e.from,e.to,n,r,i,a,o)}function Za(e,t,n,r,i){let a=he(n.slice(e.from,e.to)),o=a?r.mdLinkText.create({href:a}):r.mdLinkUri.create();U(i,e.from,e.to,[...t,o])}function Qa(e,t,n,r,i,a,o){let s=$a(e),c=eo(s,n,o);if(c==null){to(e,t,n,r,i,a,o);return}let l=ro(s,c,t,n,r,a);if(l){U(i,e.from,e.to,l);return}io(e,s,c,t,n,r,i,a,o)}function $a(e){let t=-1,n=-1,r=null,i=null,a=null,o=0,s=0;for(let c of e.children){let e=c.type;e===S.LinkMark?(s++,o++,o===1&&(t=c.to),o===2&&(n=c.from)):r==null&&e===S.URL?r=c:i==null&&e===S.LinkTitle?i=c:a==null&&e===S.LinkLabel&&(a=c)}return{labelFrom:t,labelTo:n,urlNode:r,titleNode:i,referenceLabelNode:a,linkMarkCount:s}}function eo(e,t,n){if(e.linkMarkCount>=3)return{href:e.urlNode==null?``:t.slice(e.urlNode.from,e.urlNode.to),title:e.titleNode==null?``:qa(t.slice(e.titleNode.from,e.titleNode.to)),isReference:!1};if(e.labelFrom<0||e.labelTo<0||n?.isReferenceDefinition===!0)return;let r=t.slice(e.labelFrom,e.labelTo),i=xa(e.referenceLabelNode==null?r:t.slice(e.referenceLabelNode.from+1,e.referenceLabelNode.to-1)||r);if(i===``)return;n?.referencedKeys?.add(i);let a=n?.referenceDefinitions?.get(i);if(a!=null)return{href:a.href,title:a.title,isReference:!0}}function to(e,t,n,r,i,a,o){Ja(e.children.filter(e=>e.type!==S.LinkMark&&e.type!==S.LinkLabel),t,e.from,e.to,n,r,i,a,o)}function no(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function ro(e,t,n,r,i,a){let o=a?.resolveFileLink;if(!o)return;let{labelFrom:s,labelTo:c}=e;if(s<0||c<0)return;let{href:l,title:u}=t;if(!l)return;let d=r.slice(s,c);if(!o({href:l,label:d,title:u}))return;let f=d||no(l);return[...n,i.mdFile.create({href:l,name:f,title:u})]}function io(e,t,n,r,i,a,o,s,c){let{labelTo:l}=t,{href:u,title:d,isReference:f}=n,p=a.mdLinkText.create({href:u}),m=e=>l>=0&&e<l,h=f?{href:u,title:d,reference:!0}:{href:u,title:d},g=a.mdPack.create({key:`link`,data:h}),_=[...r,g],v=e.from;for(let t of e.children){if(t.from>v){let e=m(v)?[..._,p]:_;U(o,v,t.from,e)}let e=m(t.from)?[..._,p]:_;if(t.type===S.Wikilink){co(t,e,i,a,o),v=t.to;continue}if(t.type===S.WikiEmbed){lo(t,e,i,a,o,s),v=t.to;continue}if(t.type===S.Image){oo(t,e,i,a,o,s,c),v=t.to;continue}if(f&&t.type===S.LinkLabel){U(o,t.from,t.to,[...e,a.mdMark.create()]),v=t.to;continue}let n=Wa.get(t.type),r=n?[...e,a[n].create()]:e;t.children.length===0?U(o,t.from,t.to,r):Ja(t.children,r,t.from,t.to,i,a,o,s,c),v=t.to}v<e.to&&U(o,v,e.to,_)}function ao(e,t,n){if(!t||t.type!==S.Comment||t.from!==e.to)return;let r=_a(n.slice(t.from,t.to));if(r)return{magic:r,to:t.to}}function oo(e,t,n,r,i,a,o,s){let c=eo($a(e),n,o);if(c==null){to(e,t,n,r,i,a,o),s!=null&&U(i,e.to,s.to,t);return}let l=e.children.filter(e=>e.type===S.LinkMark),u=c.href,d=l.length>=2?n.slice(l[0].to,l[1].from):``,f=c.title,p=s?.magic.width??null,m=s?.magic.height??null,h=s?.to??e.to;U(i,e.from,h,[...t,r.mdImage.create({src:u,alt:d,title:f,width:p,height:m,syntax:null,wikiTarget:null})])}function so(e,t,n,r,i){let a=e.children.filter(e=>e.type===S.InlineMathMark);if(a.length<2){U(i,e.from,e.to,t);return}let o=n.slice(a[0].to,a[1].from),s=[...t,r.mdPack.create({key:`math`}),r.mdMath.create({formula:o})];U(i,e.from,a[0].to,[...s,r.mdMark.create()]),U(i,a[0].to,a[1].from,s),U(i,a[1].from,e.to,[...s,r.mdMark.create()])}function co(e,t,n,r,i){let{target:a,display:o}=Va(n.slice(e.from,e.to));U(i,e.from,e.to,[...t,r.mdWikilink.create({target:a,display:o})])}function lo(e,t,n,r,i,a){let o=Ra(n.slice(e.from,e.to)),s=a?.resolveWikiEmbed?.(o);if(!s){U(i,e.from,e.to,t);return}if(s.kind===`image`){let n=s.src??o.target,a=(s.alt??o.display)||Ba(o.target);U(i,e.from,e.to,[...t,r.mdImage.create({src:n,alt:a,title:``,width:o.width,height:o.height,syntax:`wikiEmbed`,wikiTarget:o.target})]);return}if(s.kind===`file`){let n=s.href??o.target,a=(s.name??o.display)||Ba(o.target);U(i,e.from,e.to,[...t,r.mdFile.create({href:n,name:a,title:s.title??``})]);return}let c=s.target??o.target,l=s.display??o.display;U(i,e.from,e.to,[...t,r.mdWikilink.create({target:c,display:l})])}function U(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&ua(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const uo=`inline-marks-applied`,fo=`inline-marks-trigger`,po=`inline-marks-restyle`,W=new T(`inline-mark`),mo=new Set;let ho=0,go=0;function _o(e,t){let n=1/0,r=-1/0;for(let t of e)for(let e of t.mapping.maps)e.forEach((e,t,i,a)=>{i<n&&(n=i),a>r&&(r=a)});let i=t.doc.content.size;return n>r?{from:0,to:i}:{from:Math.max(0,n),to:Math.min(i,r)}}function vo(e){let t=new WeakMap;function n(e,t){for(let n of e)if(t.has(n))return!0;return!1}function r(e,t){let n=[];for(let[r,i,a]of e)n.push([r+t,i+t,a]);return n}function i(i,a,o,s,c,l){let u=t.get(i),d;if(u?.isReferenceDefinition===l&&!n(u.referencedKeys,c))go++,d=u.chunks;else{ho++;let n=new Set;d=Ka(il(o),i.textContent,e,{referenceDefinitions:s.definitions,isReferenceDefinition:l,referencedKeys:n}),t.set(i,{isReferenceDefinition:l,referencedKeys:n,chunks:d})}return a===0?d:r(d,a)}function a(e,r,a,o){let s=[],c=[],l=(l,u,d,f)=>{if(l.type.spec.code)return!1;if(!l.isTextblock)return!0;if(l.childCount===0)return!1;let p=t.get(l),m=u<=r.to&&u+l.nodeSize>=r.from,h=p==null||n(p.referencedKeys,o);if(!m&&!h)return!1;let g=i(l,u+1,e.schema,a,o,ja(l,d,f));g.length>0&&s.push(...g);let _=t.get(l);return _!=null&&c.push({position:u,cached:_}),!1};return o.size===0?e.doc.nodesBetween(r.from,r.to,l):e.doc.descendants(l),{chunks:s,processed:c}}function o(e,n){for(let{position:r,cached:i}of n){let n=e.nodeAt(r);n?.isTextblock&&t.set(n,i)}}return new w({key:W,state:{init(e,t){return{references:Ma(t.doc),pendingReferenceKeys:mo}},apply(e,t,n,r){if(e.getMeta(po)===!0)return t.pendingReferenceKeys.size===0?t:{references:t.references,pendingReferenceKeys:mo};if(e.getMeta(uo))return t;let i=Fa(t.references,e,r.doc);if(i===t.references)return t;let a=xo(t.references.definitions,i.definitions);return a.size===0?{references:i,pendingReferenceKeys:t.pendingReferenceKeys}:{references:i,pendingReferenceKeys:So(t.pendingReferenceKeys,a)}}},appendTransaction(e,t,n){for(let t of e)if(t.getMeta(uo))return null;let r=e.some(e=>e.getMeta(po));if(!(r||e.some(e=>e.docChanged||e.getMeta(fo))))return null;let i=W.getState(n)?.references;if(i==null)return null;let s=r?W.getState(t)?.pendingReferenceKeys??mo:mo,{chunks:c,processed:l}=a(n,r?{from:0,to:0}:_o(e,n),i,s);if(c.length===0)return null;let u=n.tr.step(new pa(c));return o(u.doc,l),u.setMeta(uo,!0),u.setMeta(`addToHistory`,!1),u},view(e){e.dispatch(yo(e.state));let t,n=e=>{t=void 0,!e.isDestroyed&&(W.getState(e.state)?.pendingReferenceKeys.size??0)!==0&&e.dispatch(e.state.tr.setMeta(po,!0))};return{update(e,r){let i=W.getState(e.state);if((i?.pendingReferenceKeys.size??0)===0){t!=null&&clearTimeout(t),t=void 0;return}(t==null||W.getState(r)!==i)&&(t!=null&&clearTimeout(t),t=setTimeout(()=>n(e),200))},destroy(){t!=null&&clearTimeout(t)}}}})}function yo(e){return e.tr.setMeta(fo,!0)}function bo(e,t){return e?.href===t?.href&&e?.title===t?.title}function xo(e,t){if(e==null)return new Set(t.keys());let n=new Set;for(let[r,i]of e)bo(i,t.get(r))||n.add(r);for(let[r,i]of t)bo(i,e.get(r))||n.add(r);return n}function So(e,t){if(e.size===0)return t;let n=new Set(e);for(let e of t)n.add(e);return n}function Co(e){return m(vo(e))}function wo(){return u({name:`mdImage`,inclusive:!1,attrs:{src:{default:``},alt:{default:``},title:{default:``},width:{default:null},height:{default:null},syntax:{default:null},wikiTarget:{default:null}},toDOM:()=>[`span`,{class:`md-image`},0],parseDOM:[{tag:`span.md-image`}]})}function To(){return u({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function Eo(){return u({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function Do(){return u({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function Oo(){return u({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function ko(){return u({name:`mdLinkText`,inclusive:!1,attrs:{href:{default:``}},toDOM:e=>[`a`,{class:`md-link`,href:e.attrs.href},0],parseDOM:[{tag:`a`,getAttrs:e=>({href:e.getAttribute(`href`)??``})}]})}function Ao(){return u({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function jo(){return u({name:`mdLinkTitle`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-title`},0],parseDOM:[{tag:`span.md-link-title`}]})}function Mo(){return u({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function No(){return u({name:`mdHighlight`,toDOM:()=>[`mark`,0],parseDOM:[{tag:`mark`}]})}function Po(){return u({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function Fo(){return u({name:`mdWikilink`,inclusive:!1,attrs:{target:{default:``},display:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink`},0],parseDOM:[{tag:`span.md-wikilink`}]})}function Io(){return u({name:`mdFile`,inclusive:!1,attrs:{href:{default:``},name:{default:``},title:{default:``}},toDOM:()=>[`span`,{class:`md-file`},0],parseDOM:[{tag:`span.md-file`}]})}function Lo(){return u({name:`mdMath`,inclusive:!1,attrs:{formula:{default:``}},toDOM:()=>[`span`,{class:`md-math`},0],parseDOM:[{tag:`span.md-math`}]})}function Ro(){return u({name:`mdPack`,excludes:``,inclusive:!1,attrs:{key:{},data:{default:null}},toDOM:e=>[`span`,{class:`md-pack`,"data-key":e.attrs.key},0],parseDOM:[{tag:`span.md-pack`}]})}function zo(){return b(To(),Eo(),Do(),Oo(),ko(),Ao(),jo(),Mo(),No(),Po(),Fo(),wo(),Io(),Lo(),Ro())}const G={em:{node:S.Emphasis,delim:`*`},strong:{node:S.StrongEmphasis,delim:`**`},code:{node:S.InlineCode,delim:"`"},del:{node:S.Strikethrough,delim:`~~`},highlight:{node:S.Highlight,delim:`==`}},Bo=new Set([S.EmphasisMark,S.CodeMark,S.LinkMark,S.StrikethroughMark,S.HighlightMark]);function Vo(e){return[e.children[0],e.children.at(-1)]}function Ho(e){let{type:t,children:n}=e;if(t===S.Emphasis||t===S.StrongEmphasis||t===S.Strikethrough||t===S.Highlight)return[n[0].to,n.at(-1).from];if(t===S.Link||t===S.Image){let e=n.find((e,t)=>t>0&&e.type===S.LinkMark);return e?[n[0].to,e.from]:null}return null}function Uo(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=Ho(r);return i&&i[0]<=t&&n<=i[1]?Uo(r.children,t,n):Uo(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function Wo(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return Wo(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}function Go(e,t,n){for(;t<n&&C(e.charCodeAt(t));)t++;for(;n>t&&C(e.charCodeAt(n-1));)n--;return[t,n]}function Ko(e,t,n,r){let i=me(ve(e),e=>e.type===r.node||Bo.has(e.type));for(let r=t;r<n;r++)if(!C(e.charCodeAt(r))&&i.every(e=>!(e.from<=r&&r<e.to)))return!1;return!0}function qo(e,t,n,r,i){let a=ve(e),o=me(a,e=>e.type===r.node);return i?Xo(e,o,t,n):Jo(e,a,o,t,n,r)}function Jo(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=Uo(t,r,i);for(let e of n)e.to===r&&(r=e.from),e.from===i&&(i=e.to)}let o=[];for(let e of n)if(r<=e.from&&e.to<=i){let[t,n]=Vo(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=Yo(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function Yo(e,t,n,r,i){if(i.node!==S.InlineCode)return[i.delim,i.delim];let a=e.slice(t,n);for(let e of[...r].sort((e,t)=>t.from-e.from))a=a.slice(0,e.from-t)+a.slice(e.to-t);let o="`".repeat(wr(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function Xo(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=Vo(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=Wo(a.children.slice(1,-1),s,c);s>t.to&&C(e.charCodeAt(s-1));)s--;for(;c<o.from&&C(e.charCodeAt(c));)c++;s>t.to?i.push({from:s,to:s,insert:e.slice(o.from,o.to)}):i.push({from:t.from,to:t.to,insert:``}),c<o.from?i.push({from:c,to:c,insert:e.slice(t.from,t.to)}):i.push({from:o.from,to:o.to,insert:``})}return i}function Zo(e,t,n){let{delim:r}=n,i=r.length;if(e.slice(t-i,t)===r&&e.startsWith(r,t)&&e[t-i-1]!==r[0]&&e[t+i]!==r[0])return{kind:`unwrap`,from:t-i,to:t+i};let a=ve(e),o=me(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=Vo(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return Qo(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function Qo(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=Ho(n);return!e||t<e[0]||t>e[1]||Qo(n.children,t)}return!1}function K(e){return(t,n)=>{if(t.selection.empty)return $o(e,t,n);let{from:r,to:i,anchor:a,head:o}=t.selection,s=[];t.doc.nodesBetween(r,i,(t,n)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;let a=t.textContent,o=n+1,[c,l]=Go(a,Math.max(r-o,0),Math.min(i-o,a.length));return c<l&&s.push({text:a,base:o,from:c,to:l,active:Ko(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>qo(t.text,t.from,t.to,e,c).map(e=>({from:e.from+t.base,to:e.to+t.base,insert:e.insert})));if(l.length===0)return!1;if(n){let e=t.tr;l.sort((e,t)=>t.from-e.from||t.to-e.to);for(let t of l)t.insert?e.insertText(t.insert,t.from,t.to):e.delete(t.from,t.to);e.setSelection(E.create(e.doc,e.mapping.map(a,a<=o?1:-1),e.mapping.map(o,o<a?1:-1))),n(e.scrollIntoView())}return!0}}function $o(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=Zo(i.textContent,r.parentOffset,e);if(!a)return!1;if(n){let i=r.start(),o=t.tr;a.kind===`unwrap`&&o.delete(i+a.from,i+a.to),a.kind===`move`&&o.setSelection(E.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(E.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function es(){return s({toggleEm:()=>K(G.em),toggleStrong:()=>K(G.strong),toggleCode:()=>K(G.code),toggleDel:()=>K(G.del),toggleHighlight:()=>K(G.highlight)})}function ts(){return l({"Mod-b":K(G.strong),"Mod-i":K(G.em),"Mod-e":K(G.code),"Mod-Shift-x":K(G.del),"Mod-Shift-h":K(G.highlight)})}function ns(){return b(es(),ts())}function rs(e,t,n){let r;return e.doc.nodesBetween(t.from,t.to,(e,i)=>(e.isText&&e.marks.some(e=>Pn(e,n))&&(r={from:Math.max(i,t.from),to:Math.min(i+e.nodeSize,t.to)}),!0)),r}function q(e,t){let n=j(e,t,`mdLinkText`),r=j(e,t,`mdPack`,{key:`link`})??j(e,t,`mdPack`,{key:`autolink`}),i=r??n;if(!i)return;let a=r?.mark.attrs,o=n?.mark.attrs?.href??``;if(!r||a?.key!==`link`){let t={from:i.from,to:i.to};return{unit:t,text:a?.key===`autolink`?rs(e,t,`mdLinkText`)??{from:i.from+1,to:i.to-1}:t,href:o,title:``}}if(a.data.reference===!0){let e=n==null?{from:i.from,to:i.to}:{from:n.from+1,to:n.to};return{unit:{from:i.from,to:i.to},text:e,href:a.data.href,title:a.data.title}}let s=rs(e,i,`mdLinkUri`),c=s?s.from-2:i.to-3,l=s?s.from:i.to-1,u={from:i.from+1,to:c};return{unit:{from:i.from,to:i.to},text:u,label:u,dest:{from:l,to:i.to-1},href:a.data.href,title:a.data.title}}function is(e){let t=e.trim();return t?he(t)??t:``}function as(e,t){return e+(t?` "${t.replaceAll(/(["\\])/g,String.raw`\$1`)}"`:``)}function os(e){let{selection:t}=e,{$from:n,$to:r,empty:i}=t;if(i||!n.sameParent(r)||!y(t))return;let a=n.parent;if(!a.isTextblock||a.type.spec.code)return;let o=n.start(),[s,c]=Go(a.textContent,n.parentOffset,r.parentOffset);if(!(s>=c))return{from:o+s,to:o+c}}function ss({href:e,title:t,wrapText:n=!0}={}){return(r,i)=>{let a=os(r);if(!a)return!1;if(i){let{from:o,to:s}=a,c=r.tr,l=`](${as(is(e??``),t??``)})`;c.insertText(l,s).insertText(`[`,o);let u=s+1+l.length;c.setSelection(n?E.create(c.doc,o,u):E.create(c.doc,u)),c.scrollIntoView(),i(c)}return!0}}function cs(e){return(t,n)=>{let r=q(t,t.selection.from);if(!r?.dest)return!1;let i=as(is(e.href??r.href),e.title??r.title);return n&&n(t.tr.insertText(i,r.dest.from,r.dest.to).scrollIntoView()),!0}}function ls(){return(e,t)=>{let n=q(e,e.selection.from);return n?.label?(t&&t(e.tr.delete(n.label.to,n.unit.to).delete(n.unit.from,n.label.from).scrollIntoView()),!0):!1}}function us(){return s({insertLink:ss,updateLink:cs,removeLink:ls})}function ds(e){return(t,n,r)=>{let i=q(t,t.selection.from);if(i){if(i.label==null||i.dest==null)return!1;if(n&&r){let{unit:{from:a,to:o}}=i;n(t.tr.setSelection(E.create(t.doc,a,o)).scrollIntoView()),r.focus(),e({from:a,to:o,link:i})}return!0}let a=os(t);if(a){if(n&&r){let{from:i,to:o}=a;n(t.tr.setSelection(E.create(t.doc,i,o)).scrollIntoView()),r.focus(),e({from:i,to:o,link:void 0})}return!0}return!1}}function fs(e){return l({"Mod-k":ds(e)})}function ps(e){return e===`)`||e===`*`||e===`+`?e:void 0}function ms(e){return e===`X`?e:void 0}function hs(e){return vs(e)?String(e):void 0}function gs(){return f({type:`list`,attr:`marker`,default:null,splittable:!0,toDOM:e=>{let t=ps(e);return t==null?null:[`data-list-marker`,t]},parseDOM:e=>{let t=e.getAttribute(`data-list-marker`);return t===`)`||t===`*`||t===`+`?t:null}})}function _s(){return f({type:`list`,attr:`taskMarker`,default:null,splittable:!0,toDOM:e=>{let t=ms(e);return t==null?null:[`data-list-task-marker`,t]},parseDOM:e=>e.getAttribute(`data-list-task-marker`)===`X`?`X`:null})}function vs(e){return e===2||e===3||e===4}function ys(){return f({type:`list`,attr:`markerGap`,default:1,splittable:!0,toDOM:e=>{let t=hs(e);return t==null?null:[`data-list-marker-gap`,t]},parseDOM:e=>{let t=Number.parseInt(e.getAttribute(`data-list-marker-gap`)??``,10);return vs(t)?t:1}})}function bs(e){let t=e.attrs;return{...Pt(e),"data-list-marker":ps(t.marker),"data-list-task-marker":ms(t.taskMarker),"data-list-marker-gap":hs(t.markerGap)}}function xs(){return o({serializeFragmentWrapper:e=>(...t)=>Ss(Lt(e(...t))),serializeNodeWrapper:e=>(...t)=>{let n=e(...t);return ye(n)?Ss(Lt(n)):n},nodesFromSchemaWrapper:e=>(...t)=>({...e(...t),list:e=>Rt({node:e,nativeList:!0,getAttributes:bs})})})}function Ss(e){ye(e)&&Cs(e);for(let t of e.children)Ss(t);return e}function Cs(e){if(!e.classList.contains(`prosemirror-flat-list`)||e.getAttribute(`data-list-kind`)!==`task`||e.children.length!==2)return;let t=e.children.item(0);if(!t||!t.classList.contains(`list-marker`))return;let n=Ft(t);if(!n)return;let r=e.children.item(1);if(!r||!r.classList.contains(`list-content`))return;let i=r.children.item(0);!i||![`P`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`].includes(i.tagName)||(e.replaceChildren(...r.children),i.prepend(n))}const ws=[Bt(/^\s?([*-])\s$/,{kind:`bullet`,collapsed:!1}),Bt(/^\s?(\d+)\.\s$/,({match:e})=>{let t=e[1],n=t?parseInt(t,10):void 0;return{kind:`ordered`,collapsed:!1,order:n&&n>=2&&Number.isSafeInteger(n)?n:null}}),Bt(/^\s?\[([\sX]?)\]\s$/i,({match:e})=>({kind:`task`,checked:[`x`,`X`].includes(e[1]),collapsed:!1})),Bt(/^\s?\+\s$/,{kind:`task`,marker:`+`,checked:!1,collapsed:!1})];function Ts(){return b(ws.map(tt))}function Es(){return dt({kind:`task`,marker:`+`})}function Ds(){return dt({kind:`task`,marker:null})}function Os(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e);if(L(n,`list`))return n.attrs}return null}function ks(){return(e,t,n)=>{let r=Os(e);return(r?.kind===`task`?r.marker===`+`?Ds():Es():dt({kind:`task`,marker:null,checked:!1}))(e,t,n)}}function As(){return s({cycleCheckableList:ks,wrapInCircleTask:Es,wrapInSquareTask:Ds})}function js(){return(e,t,n)=>{let r=Os(e),i=r?.kind===`task`&&r.marker!==`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:r?.marker??null,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:null,checked:!1},dt(a)(e,t,n)}}function Ms(){return(e,t,n)=>{let r=Os(e),i=r?.kind===`task`&&r.marker===`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:`+`,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:`+`,checked:!1},dt(a)(e,t,n)}}function Ns(e){return L(e,`list`)&&e.attrs.kind===`bullet`&&e.childCount>=2&&e.firstChild?.type!==e.type}const Ps=e=>{let t=e.attrs;return t.kind===`task`?{...t,checked:!t.checked}:Ns(e)?{...t,collapsed:!t.collapsed}:t};function Fs(){return m(()=>[new w({props:{handleDOMEvents:{mousedown:(e,t)=>It({view:e,event:t,onListClick:Ps})}}}),jt(),new w({props:{transformCopied:zt}}),Mt()])}function Is(){return s({toggleListCollapsed:()=>Nt({isToggleable:Ns})})}function Ls(){return l({"Mod-Enter":js(),"Mod-Shift-Enter":Ms(),"Mod-.":Nt({isToggleable:Ns}),"Mod-Shift-7":lt({kind:`ordered`,collapsed:!1}),"Mod-Shift-8":lt({kind:`bullet`,collapsed:!1}),"Mod-Shift-9":lt({kind:`task`,checked:!1,collapsed:!1})})}function Rs(){return b(st(),Fs(),ot(),it(),xs(),at(),Ts(),Ls(),gs(),_s(),ys(),As(),Is())}let zs;function Bs(){return zs??=import(`./katex-chunk-Ch7kgbXr.js`).then(e=>e.render),zs}function Vs(e,t,n,r){try{e(n,t,{displayMode:r,throwOnError:!1,output:`mathml`})}catch(e){t.textContent=String(e)}}var Hs=class{#e;#t;#n;#r;constructor(e,t){this.#r=e.attrs.formula,this.#e=document.createElement(`span`),this.#e.className=`md-math-view`,this.#n=document.createElement(`span`),this.#n.className=`md-math-view-preview`,this.#n.dataset.testid=`math-preview`,this.#n.contentEditable=`false`,this.#n.addEventListener(`mousedown`,e=>{e.preventDefault();let n=t.posAtDOM(this.#t,0);if(n<0)return;let r=E.near(t.state.doc.resolve(n),1);t.dispatch(t.state.tr.setSelection(r)),t.focus()}),this.#t=document.createElement(`span`),this.#t.className=`md-math-view-content`,this.#e.appendChild(this.#n),this.#e.appendChild(this.#t),this.#i()}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs.formula;return t!==this.#r&&(this.#r=t,this.#i()),!0}ignoreMutation(e){return!this.#t.contains(e.target)}#i(){let e=this.#r;Bs().then(t=>{e===this.#r&&Vs(t,this.#n,e,!1)})}};function Us(){return d({name:`mdMath`,constructor:(e,t)=>new Hs(e,t)})}function Ws(e){return e===`left`||e===`center`||e===`right`?e:null}function Gs(){return f({type:`tableCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>Ws(e.getAttribute(`data-align`))})}function Ks(){return f({type:`tableHeaderCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>Ws(e.getAttribute(`data-align`))})}function qs(e){for(let t=0;t<e.childCount;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++)if(L(n.child(e),`tableHeaderCell`))return t}return 0}function Js(e){return e.child(qs(e))}function Ys(e,t){return t>=e.childCount?null:e.child(t).attrs.align??null}function Xs(e,t,n){if(e.childCount===0)return;let r=Js(e),i=t+1;for(let t=0;t<e.childCount;t++){let a=e.child(t),o=i+1;for(let e=0;e<a.childCount;e++){let t=a.child(e),i=Ys(r,e);(t.attrs.align??null)!==i&&n.setNodeMarkup(o,void 0,{...t.attrs,align:i}),o+=t.nodeSize}i+=a.nodeSize}}function Zs(e){let t,n;for(let r of e){if(!r.docChanged)continue;t!=null&&n!=null&&(t=r.mapping.map(t,-1),n=r.mapping.map(n,1));let e=r.mapping;for(let[r,i]of e.maps.entries()){let a=e.slice(r+1);i.forEach((e,r,i,o)=>{let s=a.map(i,-1),c=a.map(o,1);t=t==null?s:Math.min(t,s),n=n==null?c:Math.max(n,c)})}}if(t!=null&&n!=null)return{from:t,to:n}}function Qs(){return new w({key:new T(`table-align-sync`),appendTransaction(e,t,n){if(!e.some(e=>e.docChanged))return;let r=Zs(e);if(!r)return;let i=n.doc,a=Math.max(0,Math.min(r.from,i.content.size)),o=Math.max(a,Math.min(r.to,i.content.size)),s;return i.nodesBetween(a,o,(e,t)=>L(e,`table`)?(s??=n.tr,Xs(e,t,s),!1):!0),s?.docChanged?s:void 0}})}function $s(){return m(Qs())}function ec(e){let{selection:t}=e;if(Yt(t)){let{$anchorCell:e,$headCell:n}=t,r=e.depth-1,i=e.index(),a=n.index();return{table:e.node(r),tablePos:e.before(r),firstColumn:Math.min(i,a),lastColumn:Math.max(i,a)}}let{$from:n}=t;for(let e=n.depth;e>2;e--){let t=n.node(e).type.name;if(t===`tableCell`||t===`tableHeaderCell`){let t=n.index(e-1);return{table:n.node(e-2),tablePos:n.before(e-2),firstColumn:t,lastColumn:t}}}}function tc(e){return(t,n)=>{let r=ec(t);if(!r||r.table.childCount===0)return!1;if(n){let{table:i,tablePos:a,firstColumn:o,lastColumn:s}=r,c=qs(i),l=a+1;for(let e=0;e<c;e++)l+=i.child(e).nodeSize;let u=i.child(c),d=t.tr,f=l+1;for(let t=0;t<u.childCount;t++){let n=u.child(t);t>=o&&t<=s&&(n.attrs.align??null)!==e&&d.setNodeMarkup(f,void 0,{...n.attrs,align:e}),f+=n.nodeSize}n(d)}return!0}}function nc(e){let t=ec(e);if(!(!t||t.table.childCount===0))return Ys(Js(t.table),t.lastColumn)??void 0}function rc(){return s({setTableColumnAlign:tc})}function ic(){return b(Gs(),Ks(),$s(),rc())}function ac(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e).type.name;if(n===`tableCell`||n===`tableHeaderCell`)return!0}return!1}const oc=`paragraph`;function sc(){return b(p({name:`tableCell`,content:oc}),p({name:`tableHeaderCell`,content:oc}))}const cc=(e,t)=>{let{selection:n}=e;return!Yt(n)||!n.isColSelection()||!n.isRowSelection()?!1:Jt(e,t)};function lc(){return x(l({Backspace:cc,Delete:cc}),t.high)}function uc(){return b(qt(),Kt(),Vt(),Gt(),sc(),ic(),Wt({allowTableNodeSelection:!0}),Ht(),Ut(),lc())}function dc(e){let{selection:t}=e,{$from:n,$to:r}=t;if(ne(t)&&n.depth===0||n.depth>0&&r.depth>0&&n.index(0)===r.index(0))return n.index(0)}function fc(e){return(t,n)=>{if(ac(t))return!1;let r=dc(t);if(r==null)return!1;let i=r+e;if(i<0||i>=t.doc.childCount)return!1;if(n){let{selection:a}=t,o=Math.min(r,i),s=a.$from.posAtIndex(o,0),c=t.doc.child(o),l=t.doc.child(o+1),u=t.tr.replaceWith(s,s+c.nodeSize+l.nodeSize,[l,c]),d=e===-1?-c.nodeSize:l.nodeSize,f=ne(a)?ke.create(u.doc,a.from+d):E.create(u.doc,a.anchor+d,a.head+d);u.setSelection(f),n(u.scrollIntoView())}return!0}}function pc(e){return(t,n,r)=>ct(e)(t,n,r)||fc(e===`up`?-1:1)(t,n,r)}function mc(){return l({"Alt-ArrowUp":pc(`up`),"Alt-ArrowDown":pc(`down`)})}const J=new T(`meowdownPendingReplacement`);function hc(e){return J.getState(e)?.pending??null}function gc(e,t){switch(e.type){case`start`:return{pending:{from:e.from,to:e.to,mode:e.mode,text:``}};case`append`:return t.pending?{pending:{...t.pending,text:t.pending.text+e.text}}:t;case`accept`:return t.pending?{pending:null,ended:{pending:t.pending,outcome:`accepted`}}:t;case`discard`:return t.pending?{pending:null,ended:{pending:t.pending,outcome:`discarded`}}:t}}const _c=new w({key:J,state:{init:()=>({pending:null}),apply:(e,t)=>{let n=e.getMeta(J);if(n)return gc(n,t);if(e.docChanged&&t.pending){let n=e.mapping.mapResult(t.pending.from,1),r=e.mapping.mapResult(t.pending.to,-1),i=Math.min(n.pos,r.pos),a=Math.max(n.pos,r.pos);return(n.deletedAfter&&r.deletedBefore||i>=a)&&t.pending.mode===`replace`?{pending:null,ended:{pending:t.pending,outcome:`discarded`}}:{pending:{...t.pending,from:i,to:a}}}return t}},props:{decorations:e=>{let t=hc(e);return!t||t.from>=t.to?null:D.create(e.doc,[je.inline(t.from,t.to,{class:`md-pending-replacement`})])}}});function vc(e){return(t,n)=>{let{from:r,to:i,mode:a}=e;return r<0||i>t.doc.content.size||r>i||r===i&&a===`replace`?!1:(n?.(t.tr.setMeta(J,{type:`start`,from:r,to:i,mode:a})),!0)}}function yc(e){return(t,n)=>hc(t)?(n?.(t.tr.setMeta(J,{type:`append`,text:e})),!0):!1}function bc(){return(e,t)=>hc(e)?(t?.(e.tr.setMeta(J,{type:`discard`})),!0):!1}function xc(e={}){return(t,n)=>{let r=hc(t);if(!r||!r.text.trim())return!1;if(n){let i=e.mode??r.mode,a=ol(t.schema),o=Z(r.text,{nodes:a}),s=t.tr;if(s.setMeta(J,{type:`accept`}),i===`append`){let e=t.doc.resolve(r.to).after(1);s.insert(e,o.content),s.setSelection(E.near(s.doc.resolve(e+o.content.size),-1))}else{let e=t.doc.resolve(r.from),n=t.doc.resolve(r.to),i=o.childCount===1?o.firstChild:null;i!=null&&L(i,`paragraph`)&&e.sameParent(n)&&e.parent.isTextblock?(s.replaceWith(r.from,r.to,i.content),s.setSelection(E.near(s.doc.resolve(r.from+i.content.size),-1))):(s.replaceRange(r.from,r.to,new k(o.content,0,0)),s.setSelection(E.near(s.doc.resolve(s.mapping.map(r.to)),-1)))}n(s.scrollIntoView())}return!0}}function Sc(){return s({startPendingReplacement:vc,appendPendingReplacementText:yc,acceptPendingReplacement:xc,discardPendingReplacement:bc})}function Cc(){return l({"Mod-Enter":xc(),Escape:bc()})}function wc(){return b(m(_c),Sc(),Cc())}function Tc(e){return m(new w({view:()=>({update:(t,n)=>{let r=J.getState(n),i=J.getState(t.state);!i||r===i||(i.pending?i.pending!==r?.pending&&e({type:`update`,pending:i.pending}):i.ended&&i.ended!==r?.ended&&e({type:`ended`,pending:i.ended.pending,outcome:i.ended.outcome}))}})}))}function Ec(e){return e.left===e.right&&e.top===e.bottom}function Y(e,t,n){if(t<0||t>e.state.doc.content.size)return;let r;try{r=e.coordsAtPos(t,n)}catch{return}return Ec(r)?void 0:r}function Dc(e){let t=e.dom.ownerDocument.getSelection();if(t==null||t.rangeCount===0||!e.dom.contains(t.anchorNode))return;let n=t.getRangeAt(0).cloneRange();n.collapse(!0);let r=Array.from(n.getClientRects()).filter(e=>e.height>0);if(r.length===0)return;let i=r[r.length-1];return{left:i.left,top:i.top,height:i.height}}function Oc(e){let t=e.state,n=t.selection.head,r=V(t,n),i=H(t,n),a=t.doc.resolve(n),o=a.parentOffset>0&&a.parent.textBetween(a.parentOffset-1,a.parentOffset)===`
30
- `,s=r==null&&!o,c=[[n,s],[n,!s]];r!=null&&c.push([r.from,!0]),i!=null&&c.push([i.to,!1]);for(let[t,n]of c){let r=Y(e,t,n?-1:1);if(r!=null&&r.bottom>r.top)return{left:r.left,top:r.top,height:r.bottom-r.top}}}function kc(e){let t=e.state,n=t.selection.head;for(let r of cn){let i=j(t,n,r);if(i==null||i.from!==n&&i.to!==n)continue;let a=jc(e,i.from+1);if(a==null)continue;let o=Array.from(a.getClientRects()).filter(e=>e.height>0);if(o.length===0)continue;let s=i.to===n,c=s?o[o.length-1]:o[0];return{left:s?c.right:c.left,top:c.top,height:c.height}}}function Ac(e,t,n){let r=e.state;for(let i of cn){let a=j(r,t,i);if(a==null)continue;let o=jc(e,a.from+1);if(o==null)continue;let s=Array.from(o.getClientRects()).filter(e=>e.height>0);if(s.length!==0)return n===1?s[0]:s[s.length-1]}}function jc(e,t){let{node:n}=e.domAtPos(t,0);return(n instanceof Element?n:n.parentElement)?.closest(`.md-atom-view`)?.querySelector(`.md-atom-view-preview`)??void 0}function Mc(e){return Oc(e)??kc(e)}const Nc=new T(`meowdown-scroll-to-selection`);function Pc(e){let t=e.state.selection;if(!y(t)||Y(e,t.head,1)!=null)return!1;let n=Mc(e);if(n==null)return!1;let r=e.domAtPos(t.head).node;return Rc(e,{left:n.left,right:n.left,top:n.top,bottom:n.top+n.height},r),!0}function X(e,t){return typeof e==`number`?e:e[t]}function Fc(e){let t=e.assignedSlot??e.parentNode;return t?.nodeType===11?t.host:t}function Ic(e){let t=e.defaultView?.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Lc(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function Rc(e,t,n){let r=e.someProp(`scrollThreshold`)??0,i=e.someProp(`scrollMargin`)??5,a=e.dom.ownerDocument;for(let e=n;e;){if(e.nodeType!==1){e=Fc(e);continue}let n=e,o=n===a.body,s=o?Ic(a):Lc(n),c=0,l=0;if(t.top<s.top+X(r,`top`)?l=-(s.top-t.top+X(i,`top`)):t.bottom>s.bottom-X(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+X(i,`top`)-s.top:t.bottom-s.bottom+X(i,`bottom`)),t.left<s.left+X(r,`left`)?c=-(s.left-t.left+X(i,`left`)):t.right>s.right-X(r,`right`)&&(c=t.right-s.right+X(i,`right`)),c||l)if(o)a.defaultView?.scrollBy(c,l);else{let e=n.scrollLeft,r=n.scrollTop;l&&(n.scrollTop+=l),c&&(n.scrollLeft+=c);let i=n.scrollLeft-e,a=n.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=o?`fixed`:getComputedStyle(n).position;if(/^(?:fixed|sticky)$/.test(u))break;e=u===`absolute`?n.offsetParent:Fc(n)}}function zc(){return m(new w({key:Nc,props:{handleScrollToSelection:Pc}}))}function Bc(e,t){return(n,r)=>{let i=e<0?Ae.atStart(n.doc):Ae.atEnd(n.doc),a=t?E.between(n.selection.$anchor,i.$head):i;return n.selection.eq(a)||r?.(n.tr.setSelection(a).scrollIntoView()),!0}}function Vc(){return l({"Meta-ArrowUp":Bc(-1,!1),"Meta-ArrowDown":Bc(1,!1),"Shift-Meta-ArrowUp":Bc(-1,!0),"Shift-Meta-ArrowDown":Bc(1,!0)})}function Hc(e){return m(new w({props:{attributes:e}}))}function Uc(e){e.offsetWidth}const Wc=new T(`meowdown-virtual-caret`),Gc=[`md-virtual-caret-blink`,`md-virtual-caret-blink2`],Kc=`data-meowdown-virtual-caret`;function qc(e){let t=e.height*.19999999999999996;return{left:e.left,top:e.top-t/2,height:e.height+t}}function Jc(e){let t=Dc(e)??Oc(e);return t==null?kc(e):qc(t)}function Yc(e,t){return e==null||t==null?e===t:e.left===t.left&&e.top===t.top&&e.height===t.height}var Xc=class{#e;#t;#n;#r;#i;#a;#o;#s=0;constructor(e){this.#e=e,this.#r=e.dom.ownerDocument,this.#t=this.#r.createElement(`div`),this.#t.className=`md-virtual-caret-layer`,this.#n=this.#t.appendChild(this.#r.createElement(`div`)),this.#n.className=`md-virtual-caret`,this.#n.dataset.testid=`virtual-caret`,e.dom.insertAdjacentElement(`afterend`,this.#t),this.#r.addEventListener(`selectionchange`,this.#l),typeof ResizeObserver<`u`&&(this.#i=new ResizeObserver(this.#l),this.#i.observe(e.dom)),this.#l()}update(e,t){e.state.selection.eq(t.selection)||this.#c(),this.#l()}destroy(){this.#r.removeEventListener(`selectionchange`,this.#l),this.#i?.disconnect(),this.#t.remove()}#c(){this.#s=1-this.#s,this.#n.style.animationName=Gc[this.#s]}#l=()=>{let e=this.#e;if(e.isDestroyed)return;let t=e.state,n=t.selection,r=y(n)&&n.empty?Jc(e):void 0,i=r!=null&&N(t)===`hide`?Ji(t,n.head):void 0;if(Yc(r,this.#a)&&i===this.#o)return;let a=this.#a==null;if(this.#a=r,this.#o=i,i==null?delete this.#n.dataset.tail:this.#n.dataset.tail=i,r==null){this.#n.style.visibility=`hidden`,e.dom.removeAttribute(Kc);return}let o=this.#t.getBoundingClientRect();a&&(this.#n.style.transitionProperty=`none`),this.#n.style.visibility=``,this.#n.style.left=`${r.left-o.left}px`,this.#n.style.top=`${r.top-o.top}px`,this.#n.style.height=`${r.height}px`,e.dom.setAttribute(Kc,``),a&&(Uc(this.#n),this.#n.style.transitionProperty=``)}};function Zc(){return m(new w({key:Wc,view:e=>new Xc(e)}))}function Qc(e){return b(ir(),we(),Li(),De(),Ce(),Rs(),er(),uc(),hi(),oa(),sa(),zo(),Hc({class:`meowdown-content`}),oi(),Oi(),Ai(),mc(),Vc(),Co(e),ns(),us(),Ua(),Us(),rn(e.markMode??`focus`),ei(),Zc(),zc(),ia(),bn({marks:cn.map(e=>({name:e,modes:[`hide`,`focus`,`show`]}))}),a(),i(),c(),Te(),Oe(),Ee(),Si(),wc(),Fi())}function $c(e={}){return Qc(e)}const el=Se(()=>{let e=$c().schema;if(e==null)throw Error(`Unexpected empty schema`);return e}),tl=Se(()=>r(el())),nl=Se(()=>n(el())),rl=`meowdown_mark_builders`;function il(e){let t=e.cached[rl];if(t)return t;let r=n(e);return e.cached[rl]=r,r}const al=`meowdown_node_builders`;function ol(e){let t=e.cached[al];if(t)return t;let n=r(e);return e.cached[al]=n,n}function Z(e,t={}){let{nodes:n=tl(),frontmatter:r=!1}=t,i,a=e;if(r){let[t,n]=cl(e);i=t,n&&(a=e.slice(n))}let o=ll(n,ge.parse(a).cursor(),a);return n.doc(i===void 0?{}:{frontmatter:i},o)}const sl=/^---[ \t]*\r?\n([\s\S]*?\n)?---[ \t]*(?:\r?\n|$)/;function cl(e){let t=sl.exec(e);return t?[(t[1]??``).replace(/\r?\n$/,``),t[0].length]:[]}function ll(e,t,n){let r=[];if(!t.firstChild())return r;let i;do i!=null&&ul(r,e,n,i,t.from),i=t.to,r.push(...dl(e,t,n));while(t.nextSibling());return t.parent(),r}function ul(e,t,n,r,i){let a=0;for(let e=r;e<i;e++)n.charCodeAt(e)===10&&a++;for(let n=2;n<a;n++)e.push(t.paragraph())}function dl(e,t,n){switch(t.type.id){case S.ATXHeading1:return[Q(e,t,n,1,!1)];case S.ATXHeading2:return[Q(e,t,n,2,!1)];case S.ATXHeading3:return[Q(e,t,n,3,!1)];case S.ATXHeading4:return[Q(e,t,n,4,!1)];case S.ATXHeading5:return[Q(e,t,n,5,!1)];case S.ATXHeading6:return[Q(e,t,n,6,!1)];case S.SetextHeading1:return[Q(e,t,n,1,!0)];case S.SetextHeading2:return[Q(e,t,n,2,!0)];case S.Paragraph:return[_l(e,t,n)];case S.LinkReference:return[_l(e,t,n)];case S.CommentBlock:return[vl(e,t,n)];case S.HTMLBlock:case S.ProcessingInstructionBlock:return[_l(e,t,n)];case S.Blockquote:return[yl(e,t,n)];case S.BulletList:return bl(e,t,n,`bullet`);case S.OrderedList:return bl(e,t,n,`ordered`);case S.FencedCode:case S.CodeBlock:return[wl(e,t,n)];case S.BlockMath:return[Tl(e,t,n)];case S.HorizontalRule:{let r=n.slice(t.from,t.to).trimEnd();return[e.horizontalRule({marker:r===`---`?null:r})]}case S.Table:return[El(e,t,n)];case S.Task:return[_l(e,t,n)];default:return n.slice(t.from,t.to).trim()===``?[]:(console.warn(`[meowdown] unsupported lezer block "${t.type.name}"`),[_l(e,t,n)])}}function Q(e,t,n,r,i){let a=t.from,o=t.from,s=t.to,c=-1,l=-1;if(t.firstChild()){t.type.id===S.HeaderMark&&t.from===a&&(o=t.to);let e=-1,n=-1,r=-1;do e=t.type.id,n=t.from,r=t.to;while(t.nextSibling());e===S.HeaderMark&&n>o&&(s=n,c=n,l=r),t.parent()}let u=hl(n.slice(o,s),$(n,o)).trim(),d=i?fl(n,c,l)||1:null,f=!i&&c>=0&&pl(n,c,l)||null;return e.heading({level:r,setextUnderline:d,closingHashes:f},u)}function fl(e,t,n){if(t<0)return 0;let r=0;for(let i=t;i<n;i++){let t=e.charCodeAt(i);(t===61||t===45)&&r++}return r}function pl(e,t,n){if(t<0)return 0;let r=0;for(let i=t;i<n;i++)e.charCodeAt(i)===35&&r++;return r}function $(e,t){let n=e.lastIndexOf(`
31
- `,t-1)+1,r=0;for(let i=n;i<t;i++)r+=e.charCodeAt(i)===9?4-r%4:1;return r}function ml(e,t){let n=0,r=0;for(;r<e.length&&n<t;){let t=e.charCodeAt(r);if(t===32)n+=1;else if(t===9)n+=4-n%4;else break;r++}return e.slice(r)}function hl(e,t){return t===0||!e.includes(`
29
+ `);return n.create(void 0,r?e.text(r):void 0)}function Xr(){return m(new w({key:new T(`meowdown-plain-text-copy`),props:{clipboardTextSerializer:(e,t)=>{let n=j(t.state)===`hide`?Zr(e):e;return Kr(t.state.schema,n,t.state.selection)}}}))}function Zr(e){return new k(Qr(e.content),e.openStart,e.openEnd)}function Qr(e){let t=[];return e.forEach(e=>{t.push(e.isTextblock?ei(e):$r(e))}),O.from(t)}function $r(e){return e.childCount>0?e.copy(Qr(e.content)):e}function ei(e){let t=e.type.schema,n=[];for(let r of Bn(e)){let e=r.atom;if(e!=null){if(Fn(e,`mdWikilink`)){let r=e.attrs,i=r.display||r.target;i&&n.push(t.text(i))}else n.push(...r.children);continue}for(let e of r.children)zn(e.marks)||n.push(e)}return e.copy(O.from(n))}function ti(){return b(sr(),Xr(),br(),_r(),Cr())}const L=new Map,ni=new Map,ri={math:`latex`};async function ii(e){let t=L.get(e);if(t!==void 0)return t;let n=$e.matchLanguageName(et,ri[e]??e,!0);if(!n)return L.set(e,null),null;let r=n.support;if(!r)try{r=await n.load()}catch(t){return console.error(`[meowdown] Failed to load language "${e}":`,t),L.set(e,null),null}return L.set(e,r),r}function ai(e,t){let n=ni.get(e);if(n)return n;let r=rt({parse:e=>t.language.parser.parse(e.content),highlighter:tt});return ni.set(e,r),r}const oi=e=>{let t=e.language?.trim();if(!t)return[];let n=L.get(t);return n===null?[]:n?ai(t,n)(e):ii(t).then(()=>void 0)};function si(){return le({parser:oi,nodeTypes:[`codeBlock`]})}function ci(e,t){let n=t.language.parser.parse(e),r=[];return nt(n,tt,(e,t,n)=>{r.push([e,t,n])}),r}function li(e,t){let n=t.trim();if(!n)return[];let r=L.get(n);return r===null?[]:r?ci(e,r):ii(n).then(t=>t?ci(e,t):[])}function ui(){return f({type:`codeBlock`,attr:`fenceStyle`,default:null,toDOM:e=>e==null?null:[`data-fence-style`,e],parseDOM:e=>{let t=e.getAttribute(`data-fence-style`);return t===`tilde`||t===`indented`||t===`dollar`?t:null}})}function di(){return f({type:`codeBlock`,attr:`fenceLength`,default:null,toDOM:e=>e==null?null:[`data-fence-length`,String(e)],parseDOM:e=>{let t=Nn(e.getAttribute(`data-fence-length`));return t!=null&&t>3?t:null}})}function fi(e){return{language:e[1]||``,fenceStyle:`tilde`}}function pi(){return st({regex:/^~~~(\S*)\s$/,type:`codeBlock`,attrs:fi})}function mi(){return at({regex:/^~~~(\S*)$/,type:`codeBlock`,attrs:fi})}function hi(){return at({regex:/^\$\$$/,type:`codeBlock`,attrs:()=>({language:`math`,fenceStyle:`dollar`})})}function gi(){return b(ce(),ui(),di(),pi(),mi(),hi())}function _i(e,t){return(n,r)=>{if(r){let i=E.create(n.doc,e,t);r(n.tr.setSelection(i))}return!0}}function vi(e,t,n){return(r,i)=>{if(i){let a=E.between(e,t,n);i(r.tr.setSelection(a))}return!0}}function yi(e){return(t,n)=>{if(!e.trim())return!1;let r=X(e,{nodes:al(t.schema)}).content;if(r.childCount===0)return!1;let i=r.childCount===1&&F(r.child(0),`paragraph`)?new k(r,1,1):new k(r,0,k.maxOpen(r).openEnd);if(n){let e=t.tr,r=e.selection;(!y(r)||!r.empty)&&e.setSelection(E.near(r.$from)),n(e.replaceSelection(i).scrollIntoView())}return!0}}function bi(e){return(t,n)=>{if(!e)return!1;let r=t.selection.$from;if(r.parent.type.spec.code)return!1;if(n){let i=r.parentOffset,a=i===0?``:r.parent.textBetween(i-1,i),o=a!==``&&!/\s/u.test(a),s=t.tr.insertText(o?` ${e}`:e);ct(s),n(s.scrollIntoView())}return!0}}function xi(){return _t(re({type:`paragraph`}),ht(),vt)}function Si(){return(e,t)=>(t&&t(e.tr.scrollIntoView()),!0)}function Ci(){return s({insertMarkdown:yi,insertTrigger:bi,scrollIntoView:Si,selectText:_i,selectTextBetween:vi,turnIntoText:xi})}const wi=new Set;function Ti(e){for(let t of wi)if(t!==e&&!t.isDestroyed&&t.editable&&t.dragging)return t}function Ei(e,t){let n=e.state.tr;if(t.node){if(e.state.doc.nodeAt(t.node.from)!==t.node.node)return;t.node.replace(n)}else n.deleteSelection();n.docChanged&&e.dispatch(n.setMeta(`uiEvent`,`drop`))}function Di(e,t,n,r){if(r||n.size===0)return!1;let i=Ti(e);if(!i)return!1;let a=i.dragging;if(!a||(ee?t.altKey:t.ctrlKey))return!1;i.dragging=null;let o=e.state.doc;return queueMicrotask(()=>{i.isDestroyed||e.isDestroyed||e.state.doc!==o&&Ei(i,a)}),!1}function Oi(){return new w({key:new T(`meowdown-cross-editor-drag`),view:e=>(wi.add(e),{destroy:()=>{wi.delete(e)}}),props:{handleDrop:Di}})}function ki(){return x(m(Oi()),t.high)}const Ai=(e,t,n)=>{let{selection:r}=e;return r.empty||n?.composing?!1:(t?.(e.tr.setSelection(E.near(r.$head))),!0)};function ji(){return x(l({Escape:Ai}),t.low)}const Mi=new w({props:{decorations:e=>{let{from:t,to:n,empty:r}=e.selection;if(!(r||ve(e).active===0))return D.create(e.doc,[Ie.inline(t,n,{class:`show`})])}}});function Ni(){return b(he(),me(),m(Mi))}function Pi(){return f({type:`doc`,attr:`frontmatter`,default:null})}let Fi=-1,Ii=!1;typeof window<`u`&&(window.addEventListener(`compositionstart`,()=>{Ii=!0},{capture:!0,passive:!0}),window.addEventListener(`compositionend`,()=>{Ii=!1,Fi=Date.now()},{capture:!0,passive:!0}));function Li(){return Ii||Fi>0&&Date.now()-Fi<=50}function Ri(e,t){return t(e.state,e.dispatch,e)}function zi(e,t){if(t<0||t+1>e.doc.content.size)return;let n=e.doc.resolve(t),r=n.parent.maybeChild(n.index());if(!(r==null||!r.isText))return r.marks}function R(e,t){let n=zi(e,t);return n!=null&&n.some(e=>In.has(e.type.name))}function Bi(e,t){if(t<0||t>e.doc.content.size)return!1;let n=e.doc.resolve(t);return n.parent.isTextblock&&!n.parent.type.spec.code}function z(e,t){if(!Bi(e,t))return;let n=e.doc.resolve(t).start(),r=t;for(;r>n&&R(e,r-1);)r--;return r<t?{from:r,to:t}:void 0}function B(e,t){if(!Bi(e,t))return;let n=e.doc.resolve(t).end(),r=t;for(;r<n&&R(e,r);)r++;return r>t?{from:t,to:r}:void 0}function Vi(e,t){return R(e,t-1)&&R(e,t)}function Hi(e,t){if(!Vi(e,t))return;let n=z(e,t);if(!n)return;let r=B(e,t);if(r)return{from:n.from,to:r.to}}function Ui(e,t,n){let r=zi(e,t);return r!=null&&n.isInSet(r)}function Wi(e,t){let n=zi(e,t);if(n==null)return;let r=g(e.schema,`mdPack`),i=n.filter(e=>e.type===r);if(i.length===0)return;let a=e.doc.resolve(t),o=a.start(),s=a.end(),c;for(let n of i){let r=t;for(;r>o&&Ui(e,r-1,n);)r--;let i=t+1;for(;i<s&&Ui(e,i,n);)i++;(c==null||i-r<c.to-c.from)&&(c={from:r,to:i})}return c}function Gi(e,t,n){let r=Wi(e,n===`from`?t.from:t.to-1);return r==null?!1:n===`from`?r.from===t.from:r.to===t.to}function Ki(e,t,n){let r=Gi(e,t,`from`),i=Gi(e,t,`to`);return r&&!i?t.from:i&&!r?t.to:n-t.from<=t.to-n?t.from:t.to}function qi(e,t,n,r){if(!Bi(e,n))return n;let i=Hi(e,n);if(i!=null)return r?Ki(e,i,n):n>=t?i.to:i.from;if(!r)return n;let a=z(e,n);if(a!=null&&Gi(e,a,`from`))return a.from;let o=B(e,n);return o!=null&&Gi(e,o,`to`)?o.to:n}function Ji(e,t){if(!Bi(e,t))return;let n=R(e,t-1),r=R(e,t);if(n!==r)return r?`left`:`right`}function Yi(e,t){let n=Wi(e,t);if(n==null)return[];let r=B(e,n.from),i=z(e,n.to),a=[];return i!=null&&a.push(i),r!=null&&(i==null||r.from!==i.from)&&a.push(r),a}const Xi=new T(`meowdown-hidden-run-snap`),Zi=new T(`meowdown-hidden-run-beforeinput`);function Qi(){return new w({key:Xi,appendTransaction:(e,t,n)=>{if(Li()||j(n)!==`hide`)return null;let r=n.selection;if(!y(r))return null;let i=e.some(e=>e.getMeta(`pointer`)!=null);if(r.empty){let e=qi(n,t.selection.head,r.head,i);return e===r.head?null:n.tr.setSelection(E.create(n.doc,e))}let a=Hi(n,r.from)?.from??r.from,o=Hi(n,r.to)?.to??r.to;if(a===r.from&&o===r.to)return null;let s=r.anchor===r.from?a:o,c=r.head===r.from?a:o;return n.tr.setSelection(E.create(n.doc,s,c))}})}const $i=(e,t)=>{if(j(e)!==`hide`)return!1;let n=e.selection;if(!y(n)||!n.empty)return!1;let r=qi(e,n.head,n.head,!0);return r===n.head||t?.(e.tr.setSelection(E.create(e.doc,r))),!1};function ea(e){return(t,n)=>{if(j(t)!==`hide`)return!1;let r=t.selection;if(!y(r)||!r.empty)return!1;let i=r.$head;if(!i.parent.isTextblock||i.parent.type.spec.code)return!1;let a=e===-1?z(t,r.head):B(t,r.head);if(a==null)return!1;let o=Yi(t,e===-1?a.to-1:a.from),s=t.tr;if(o.length===0)s.delete(a.from,a.to);else for(let e of o)s.delete(e.from,e.to);return n?.(s),!0}}const ta=ea(-1),na=ea(1);function ra(){return new w({key:Zi,props:{handleDOMEvents:{beforeinput:(e,t)=>{if(e.composing)return!1;let n=t.inputType===`deleteContentBackward`?ta:t.inputType===`deleteContentForward`?na:void 0;return n==null||!Ri(e,n)?!1:(t.preventDefault(),!0)}}}})}function ia(){return b(m(Qi()),m(ra()),x(l({Enter:$i,Backspace:ta,Delete:na}),t.highest))}function aa(){return f({type:`horizontalRule`,attr:`marker`,default:null,toDOM:e=>e?[`data-hr-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-hr-marker`)})}function oa(){return b(yt(),aa())}function sa(){return p({name:`htmlComment`,group:`block`,atom:!0,selectable:!1,attrs:{content:{default:``}},toDOM:e=>[`div`,{"data-html-comment":e.attrs.content,style:`display: none`}],parseDOM:[{tag:`div[data-html-comment]`,getAttrs:e=>({content:e.getAttribute(`data-html-comment`)??``})}]})}function ca(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function la(e,t){let[n,r,i]=t;return[n,r,i.map(t=>qe.fromJSON(e,t))]}function ua(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}function da(e,t){let n=e.content.size,r;for(let[i,a,o]of t){if(i>=a)continue;let t=Math.max(0,Math.min(i,n)),s=Math.max(t,Math.min(a,n));if(t>=s)continue;let c=qe.setFrom(o);e.nodesBetween(t,s,(n,i)=>{if(!n.isText)return!0;let a=Math.max(t,i),o=Math.min(s,i+n.nodeSize);if(a>=o||ua(n.marks,c))return!1;r??=new Ot(e);for(let e of n.marks)r.removeMark(a,o,e);for(let e of c)r.addMark(a,o,e);return!1})}return Dt.ok(r?.doc??e)}function fa(e,t){let n=e.content.size,r=[...t].filter(([e,t])=>e<t&&e<n).sort((e,t)=>e[0]-t[0]);if(r.length===0)return Dt.ok(e);let i=r.map(([,,e])=>qe.setFrom(e)),a=Math.max(0,r[0][0]),o=0;for(let[,e]of r)e>o&&(o=e);if(o=Math.min(o,n),a>=o)return Dt.ok(e);let s=0;function c(e,t){let n=t+e.nodeSize;for(;s<r.length&&r[s][1]<=t;)s++;let a=[],o=t,c=!1;for(let t=s;t<r.length;t++){let[s,l]=r[t];if(s>=n)break;let u=Math.max(s,o),d=Math.min(l,n);if(u>=d)continue;u>o&&a.push({from:o,to:u,marks:void 0});let f=i[t],p=!ua(e.marks,f);p&&(c=!0),a.push({from:u,to:d,marks:p?f:void 0}),o=d}if(c)return o<n&&a.push({from:o,to:n,marks:void 0}),a.map(n=>{let r=e.cut(n.from-t,n.to-t);return n.marks==null?r:r.mark(n.marks)})}function l(e,t){let n,r=t;for(let t=0;t<e.childCount;t++){let i=e.child(t),s=r+i.nodeSize,u=i;if(s>a&&r<o){if(i.isText)u=c(i,r)??i;else if(i.childCount>0){let e=l(i,r+1);e!=null&&(u=i.copy(e))}}if(u!==i&&n==null){n=[];for(let r=0;r<t;r++)n.push(e.child(r))}n!=null&&(Array.isArray(u)?n.push(...u):n.push(u)),r=s}return n==null?void 0:O.fromArray(n)}let u=l(e,0);return Dt.ok(u==null?e:e.copy(u))}var pa=class e extends Et{constructor(e){super(),this.chunks=e}apply(e){return this.chunks.length===0?Dt.ok(e):this.chunks.length<=32?da(e,this.chunks):fa(e,this.chunks)}invert(e){if(this.chunks.length===0)return ma;let t=this.chunks[0][0],n=this.chunks[0][1];for(let[,e]of this.chunks)e>n&&(n=e);let r=e.content.size,i=Math.max(0,Math.min(t,r)),a=Math.max(i,Math.min(n,r));return new Tt(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(ca)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>la(t,e)))}};Et.jsonID(`batchSetMark`,pa);const ma=new pa([]),ha=/^<!--\s*(\{[^}]*\})\s*-->$/,ga=/<!--\s*\{[^}]*\}\s*-->$/;function _a(e){let t=ha.exec(e.trim());if(!t)return;let n;try{n=JSON.parse(t[1])}catch{return}if(!Ee(n))return;let r=va(n);return Object.keys(r).length>0?r:void 0}function va(e){let t={},{width:n,height:r}=e;return typeof n==`number`&&Number.isFinite(n)&&n>0&&(t.width=Math.round(n)),typeof r==`number`&&Number.isFinite(r)&&r>0&&(t.height=Math.round(r)),t}function ya(e){return`<!-- ${JSON.stringify(e)} -->`}function ba(e){return e.replace(ga,``)}function xa(e){return At(e)}function Sa(e){if(e.length>1024)return!1;let t=e.search(/\S/);return t<0||e.charCodeAt(t)!==91?!1:e.includes(`]:`,t+1)}function Ca(e){if(!Sa(e))return;let t=Se.parse(e).topNode.firstChild;if(t?.type.id===S.LinkReference&&t.nextSibling==null)return t}function wa(e){return kt(e.startsWith(`<`)&&e.endsWith(`>`)?e.slice(1,-1):e)}function Ta(e){return e.length<2?``:kt(e.slice(1,-1))}function Ea(e){let t=Ca(e);if(t==null)return;let n=t.getChild(`LinkLabel`),r=t.getChild(`URL`);if(n==null||r==null)return;let i=xa(e.slice(n.from+1,n.to-1));if(i===``)return;let a=t.getChild(`LinkTitle`);return{key:i,href:wa(e.slice(r.from,r.to)),title:a==null?``:Ta(e.slice(a.from,a.to))}}function Da(e,t){return e==null?!0:F(e,`tableCell`)||F(e,`tableHeaderCell`)?!1:!F(e,`list`)||e.attrs.kind!==`task`||t>0}function Oa(e,t,n){return F(e,`paragraph`)&&Da(t,n)}const V=new WeakMap;function ka(e,t,n){if(!Oa(e,t,n))return;if(V.has(e))return V.get(e);let r=Ea(e.textContent);return V.set(e,r),r}function Aa(e,t,n){return ka(e,t,n)!=null}function ja(e){let t=new Map,n=new Set;return e.descendants((e,r,i,a)=>{if(e.type.spec.code)return!1;if(!e.isTextblock)return!0;let o=ka(e,i,a);return o!=null&&(n.add(e),t.has(o.key)||t.set(o.key,o)),!1}),{definitions:t,nodes:n}}function Ma(e,t,n){let r=e.content.size,i=!1;return e.nodesBetween(Math.max(0,t-1),Math.min(r,n+1),(e,t,n,r)=>i||e.type.spec.code?!1:e.isTextblock?(Oa(e,n,r)&&(V.has(e)?V.get(e)!=null:Sa(e.textContent))&&(i=!0),!1):!0),i}function Na(e){if(e.steps.some(e=>e instanceof St&&e.attr===`kind`))return!0;for(let[t,n]of e.mapping.maps.entries()){let r=e.docs[t],i=t+1<e.docs.length?e.docs[t+1]:e.doc,a=!1;if(n.forEach((e,t,n,o)=>{a||=Ma(r,e,t)||Ma(i,n,o)}),a)return!0}return!1}function Pa(e,t,n){return!t.docChanged||!Na(t)?e:ja(n)}const Fa=/^(\d+)(?:x(\d+))?$/i;function Ia(e){if(!e)return null;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)&&t>0?t:null}function La(e){let t=e.replace(/^!\[\[/,``).replace(/\]\]$/,``),n=t.lastIndexOf(`|`);if(n<0)return{target:t.trim(),display:``,width:null,height:null};let r=t.slice(0,n).trim(),i=t.slice(n+1).trim(),a=Fa.exec(i);if(!a)return{target:r,display:i,width:null,height:null};let o=Ia(a[1]),s=Ia(a[2]);return o==null||a[2]&&s==null?{target:r,display:i,width:null,height:null}:{target:r,display:``,width:o,height:s}}function Ra(e,t,n){return`![[${e}|${Math.round(t)}x${Math.round(n)}]]`}function za(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function Ba(e){let t=e.replace(/^\[\[/,``).replace(/\]\]$/,``),n=t.indexOf(`|`);return n<0?{target:t.trim(),display:``}:{target:t.slice(0,n).trim(),display:t.slice(n+1).trim()}}function Va(){return e=>{let t=e.attrs,n=document.createElement(`span`);n.className=`md-wikilink-view md-atom-view`;let r=document.createElement(`span`);r.className=`md-wikilink-view-preview md-atom-view-preview`,r.contentEditable=`false`,r.dataset.testid=`wikilink`,n.appendChild(r);let i=document.createElement(`span`);i.className=`md-wikilink-view-label`,i.contentEditable=`false`,i.textContent=t.display||t.target,r.appendChild(i);let a=document.createElement(`span`);return a.className=`md-wikilink-view-content md-atom-view-content`,n.appendChild(a),{dom:n,contentDOM:a,ignoreMutation:e=>!a.contains(e.target)}}}function Ha(){return d({name:`mdWikilink`,constructor:Va()})}const Ua=new Map([[S.Emphasis,`mdEm`],[S.StrongEmphasis,`mdStrong`],[S.InlineCode,`mdCode`],[S.Strikethrough,`mdDel`],[S.Highlight,`mdHighlight`],[S.EmphasisMark,`mdMark`],[S.CodeMark,`mdMark`],[S.LinkMark,`mdMark`],[S.StrikethroughMark,`mdMark`],[S.HighlightMark,`mdMark`],[S.URL,`mdLinkUri`],[S.LinkTitle,`mdLinkTitle`],[S.Hashtag,`mdTag`],[S.WikilinkMark,`mdMark`]]);function Wa(e,t,n){return Ga(e,t,n)}function Ga(e,t,n,r){let i=Ce(t),a=[];return qa(i,[],0,t.length,t,e,a,n,r),a}function Ka(e){return e.slice(1,-1).replaceAll(/\\(.)/g,`$1`)}function qa(e,t,n,r,i,a,o,s,c){let l=n;for(let n=0;n<e.length;n++){let r=e[n];if(r.from>l&&H(o,l,r.from,t),r.type===S.Image){let u=io(r,e[n+1],i);ao(r,t,i,a,o,s,c,u),u&&n++,l=u?u.to:r.to;continue}Ja(r,t,i,a,o,s,c),l=r.to}l<r&&H(o,l,r,t)}function Ja(e,t,n,r,i,a,o){switch(e.type){case S.Link:return Za(e,t,n,r,i,a,o);case S.Wikilink:return so(e,t,n,r,i);case S.WikiEmbed:return co(e,t,n,r,i,a);case S.InlineMath:return oo(e,t,n,r,i);case S.URL:return Xa(e,t,n,r,i);default:return Ya(e,t,n,r,i,a,o)}}function Ya(e,t,n,r,i,a,o){let s=e.type,c;s===S.Emphasis?c=`italic`:s===S.StrongEmphasis?c=`bold`:s===S.InlineCode?c=`code`:s===S.Strikethrough?c=`strike`:s===S.Highlight?c=`highlight`:s===S.Autolink&&(c=`autolink`);let l=c?[...t,r.mdPack.create({key:c})]:t,u=Ua.get(s),d=u?[...l,r[u].create()]:l;e.children.length===0?H(i,e.from,e.to,d):qa(e.children,d,e.from,e.to,n,r,i,a,o)}function Xa(e,t,n,r,i){let a=be(n.slice(e.from,e.to)),o=a?r.mdLinkText.create({href:a}):r.mdLinkUri.create();H(i,e.from,e.to,[...t,o])}function Za(e,t,n,r,i,a,o){let s=Qa(e),c=$a(s,n,o);if(c==null){eo(e,t,n,r,i,a,o);return}let l=no(s,c,t,n,r,a);if(l){H(i,e.from,e.to,l);return}ro(e,s,c,t,n,r,i,a,o)}function Qa(e){let t=-1,n=-1,r=null,i=null,a=null,o=0,s=0;for(let c of e.children){let e=c.type;e===S.LinkMark?(s++,o++,o===1&&(t=c.to),o===2&&(n=c.from)):r==null&&e===S.URL?r=c:i==null&&e===S.LinkTitle?i=c:a==null&&e===S.LinkLabel&&(a=c)}return{labelFrom:t,labelTo:n,urlNode:r,titleNode:i,referenceLabelNode:a,linkMarkCount:s}}function $a(e,t,n){if(e.linkMarkCount>=3)return{href:e.urlNode==null?``:t.slice(e.urlNode.from,e.urlNode.to),title:e.titleNode==null?``:Ka(t.slice(e.titleNode.from,e.titleNode.to)),isReference:!1};if(e.labelFrom<0||e.labelTo<0||n?.isReferenceDefinition===!0)return;let r=t.slice(e.labelFrom,e.labelTo),i=xa(e.referenceLabelNode==null?r:t.slice(e.referenceLabelNode.from+1,e.referenceLabelNode.to-1)||r);if(i===``)return;n?.referencedKeys?.add(i);let a=n?.referenceDefinitions?.get(i);if(a!=null)return{href:a.href,title:a.title,isReference:!0}}function eo(e,t,n,r,i,a,o){qa(e.children.filter(e=>e.type!==S.LinkMark&&e.type!==S.LinkLabel),t,e.from,e.to,n,r,i,a,o)}function to(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function no(e,t,n,r,i,a){let o=a?.resolveFileLink;if(!o)return;let{labelFrom:s,labelTo:c}=e;if(s<0||c<0)return;let{href:l,title:u}=t;if(!l)return;let d=r.slice(s,c);if(!o({href:l,label:d,title:u}))return;let f=d||to(l);return[...n,i.mdFile.create({href:l,name:f,title:u})]}function ro(e,t,n,r,i,a,o,s,c){let{labelTo:l}=t,{href:u,title:d,isReference:f}=n,p=a.mdLinkText.create({href:u}),m=e=>l>=0&&e<l,h=f?{href:u,title:d,reference:!0}:{href:u,title:d},g=a.mdPack.create({key:`link`,data:h}),_=[...r,g],v=e.from;for(let t of e.children){if(t.from>v){let e=m(v)?[..._,p]:_;H(o,v,t.from,e)}let e=m(t.from)?[..._,p]:_;if(t.type===S.Wikilink){so(t,e,i,a,o),v=t.to;continue}if(t.type===S.WikiEmbed){co(t,e,i,a,o,s),v=t.to;continue}if(t.type===S.Image){ao(t,e,i,a,o,s,c),v=t.to;continue}if(f&&t.type===S.LinkLabel){H(o,t.from,t.to,[...e,a.mdMark.create()]),v=t.to;continue}let n=Ua.get(t.type),r=n?[...e,a[n].create()]:e;t.children.length===0?H(o,t.from,t.to,r):qa(t.children,r,t.from,t.to,i,a,o,s,c),v=t.to}v<e.to&&H(o,v,e.to,_)}function io(e,t,n){if(!t||t.type!==S.Comment||t.from!==e.to)return;let r=_a(n.slice(t.from,t.to));if(r)return{magic:r,to:t.to}}function ao(e,t,n,r,i,a,o,s){let c=$a(Qa(e),n,o);if(c==null){eo(e,t,n,r,i,a,o),s!=null&&H(i,e.to,s.to,t);return}let l=e.children.filter(e=>e.type===S.LinkMark),u=c.href,d=l.length>=2?n.slice(l[0].to,l[1].from):``,f=c.title,p=s?.magic.width??null,m=s?.magic.height??null,h=s?.to??e.to;H(i,e.from,h,[...t,r.mdImage.create({src:u,alt:d,title:f,width:p,height:m,syntax:null,wikiTarget:null})])}function oo(e,t,n,r,i){let a=e.children.filter(e=>e.type===S.InlineMathMark);if(a.length<2){H(i,e.from,e.to,t);return}let o=n.slice(a[0].to,a[1].from),s=[...t,r.mdPack.create({key:`math`}),r.mdMath.create({formula:o})];H(i,e.from,a[0].to,[...s,r.mdMark.create()]),H(i,a[0].to,a[1].from,s),H(i,a[1].from,e.to,[...s,r.mdMark.create()])}function so(e,t,n,r,i){let{target:a,display:o}=Ba(n.slice(e.from,e.to));H(i,e.from,e.to,[...t,r.mdWikilink.create({target:a,display:o})])}function co(e,t,n,r,i,a){let o=La(n.slice(e.from,e.to)),s=a?.resolveWikiEmbed?.(o);if(!s){H(i,e.from,e.to,t);return}if(s.kind===`image`){let n=s.src??o.target,a=(s.alt??o.display)||za(o.target);H(i,e.from,e.to,[...t,r.mdImage.create({src:n,alt:a,title:``,width:o.width,height:o.height,syntax:`wikiEmbed`,wikiTarget:o.target})]);return}if(s.kind===`file`){let n=s.href??o.target,a=(s.name??o.display)||za(o.target);H(i,e.from,e.to,[...t,r.mdFile.create({href:n,name:a,title:s.title??``})]);return}let c=s.target??o.target,l=s.display??o.display;H(i,e.from,e.to,[...t,r.mdWikilink.create({target:c,display:l})])}function H(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&ua(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const lo=`inline-marks-applied`,uo=`inline-marks-trigger`,fo=`inline-marks-restyle`,U=new T(`inline-mark`),po=new Set;let mo=0,ho=0;function go(e,t){let n=1/0,r=-1/0;for(let t of e)for(let e of t.mapping.maps)e.forEach((e,t,i,a)=>{i<n&&(n=i),a>r&&(r=a)});let i=t.doc.content.size;return n>r?{from:0,to:i}:{from:Math.max(0,n),to:Math.min(i,r)}}function _o(e){let t=new WeakMap;function n(e,t){for(let n of e)if(t.has(n))return!0;return!1}function r(e,t){let n=[];for(let[r,i,a]of e)n.push([r+t,i+t,a]);return n}function i(i,a,o,s,c,l){let u=t.get(i),d;if(u?.isReferenceDefinition===l&&!n(u.referencedKeys,c))ho++,d=u.chunks;else{mo++;let n=new Set;d=Ga(rl(o),i.textContent,e,{referenceDefinitions:s.definitions,isReferenceDefinition:l,referencedKeys:n}),t.set(i,{isReferenceDefinition:l,referencedKeys:n,chunks:d})}return a===0?d:r(d,a)}function a(e,r,a,o){let s=[],c=[],l=(l,u,d,f)=>{if(l.type.spec.code)return!1;if(!l.isTextblock)return!0;if(l.childCount===0)return!1;let p=t.get(l),m=u<=r.to&&u+l.nodeSize>=r.from,h=p==null||n(p.referencedKeys,o);if(!m&&!h)return!1;let g=i(l,u+1,e.schema,a,o,Aa(l,d,f));g.length>0&&s.push(...g);let _=t.get(l);return _!=null&&c.push({position:u,cached:_}),!1};return o.size===0?e.doc.nodesBetween(r.from,r.to,l):e.doc.descendants(l),{chunks:s,processed:c}}function o(e,n){for(let{position:r,cached:i}of n){let n=e.nodeAt(r);n?.isTextblock&&t.set(n,i)}}return new w({key:U,state:{init(e,t){return{references:ja(t.doc),pendingReferenceKeys:po}},apply(e,t,n,r){if(e.getMeta(fo)===!0)return t.pendingReferenceKeys.size===0?t:{references:t.references,pendingReferenceKeys:po};if(e.getMeta(lo))return t;let i=Pa(t.references,e,r.doc);if(i===t.references)return t;let a=bo(t.references.definitions,i.definitions);return a.size===0?{references:i,pendingReferenceKeys:t.pendingReferenceKeys}:{references:i,pendingReferenceKeys:xo(t.pendingReferenceKeys,a)}}},appendTransaction(e,t,n){for(let t of e)if(t.getMeta(lo))return null;let r=e.some(e=>e.getMeta(fo));if(!(r||e.some(e=>e.docChanged||e.getMeta(uo))))return null;let i=U.getState(n)?.references;if(i==null)return null;let s=r?U.getState(t)?.pendingReferenceKeys??po:po,{chunks:c,processed:l}=a(n,r?{from:0,to:0}:go(e,n),i,s);if(c.length===0)return null;let u=n.tr.step(new pa(c));return o(u.doc,l),u.setMeta(lo,!0),u.setMeta(`addToHistory`,!1),u},view(e){e.dispatch(vo(e.state));let t,n=e=>{t=void 0,!e.isDestroyed&&(U.getState(e.state)?.pendingReferenceKeys.size??0)!==0&&e.dispatch(e.state.tr.setMeta(fo,!0))};return{update(e,r){let i=U.getState(e.state);if((i?.pendingReferenceKeys.size??0)===0){t!=null&&clearTimeout(t),t=void 0;return}(t==null||U.getState(r)!==i)&&(t!=null&&clearTimeout(t),t=setTimeout(()=>n(e),200))},destroy(){t!=null&&clearTimeout(t)}}}})}function vo(e){return e.tr.setMeta(uo,!0)}function yo(e,t){return e?.href===t?.href&&e?.title===t?.title}function bo(e,t){if(e==null)return new Set(t.keys());let n=new Set;for(let[r,i]of e)yo(i,t.get(r))||n.add(r);for(let[r,i]of t)yo(i,e.get(r))||n.add(r);return n}function xo(e,t){if(e.size===0)return t;let n=new Set(e);for(let e of t)n.add(e);return n}function So(e){return m(_o(e))}function Co(){return u({name:`mdImage`,inclusive:!1,attrs:{src:{default:``},alt:{default:``},title:{default:``},width:{default:null},height:{default:null},syntax:{default:null},wikiTarget:{default:null}},toDOM:()=>[`span`,{class:`md-image`},0],parseDOM:[{tag:`span.md-image`}]})}function wo(){return u({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function To(){return u({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function Eo(){return u({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function Do(){return u({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function Oo(){return u({name:`mdLinkText`,inclusive:!1,attrs:{href:{default:``}},toDOM:e=>[`a`,{class:`md-link`,href:e.attrs.href},0],parseDOM:[{tag:`a`,getAttrs:e=>({href:e.getAttribute(`href`)??``})}]})}function ko(){return u({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function Ao(){return u({name:`mdLinkTitle`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-title`},0],parseDOM:[{tag:`span.md-link-title`}]})}function jo(){return u({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function Mo(){return u({name:`mdHighlight`,toDOM:()=>[`mark`,0],parseDOM:[{tag:`mark`}]})}function No(){return u({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function Po(){return u({name:`mdWikilink`,inclusive:!1,attrs:{target:{default:``},display:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink`},0],parseDOM:[{tag:`span.md-wikilink`}]})}function Fo(){return u({name:`mdFile`,inclusive:!1,attrs:{href:{default:``},name:{default:``},title:{default:``}},toDOM:()=>[`span`,{class:`md-file`},0],parseDOM:[{tag:`span.md-file`}]})}function Io(){return u({name:`mdMath`,inclusive:!1,attrs:{formula:{default:``}},toDOM:()=>[`span`,{class:`md-math`},0],parseDOM:[{tag:`span.md-math`}]})}function Lo(){return u({name:`mdPack`,excludes:``,inclusive:!1,attrs:{key:{},data:{default:null}},toDOM:e=>[`span`,{class:`md-pack`,"data-key":e.attrs.key},0],parseDOM:[{tag:`span.md-pack`}]})}function Ro(){return b(wo(),To(),Eo(),Do(),Oo(),ko(),Ao(),jo(),Mo(),No(),Po(),Co(),Fo(),Io(),Lo())}const W={em:{node:S.Emphasis,delim:`*`},strong:{node:S.StrongEmphasis,delim:`**`},code:{node:S.InlineCode,delim:"`"},del:{node:S.Strikethrough,delim:`~~`},highlight:{node:S.Highlight,delim:`==`}},zo=new Set([S.EmphasisMark,S.CodeMark,S.LinkMark,S.StrikethroughMark,S.HighlightMark]);function Bo(e){return[e.children[0],e.children.at(-1)]}function Vo(e){let{type:t,children:n}=e;if(t===S.Emphasis||t===S.StrongEmphasis||t===S.Strikethrough||t===S.Highlight)return[n[0].to,n.at(-1).from];if(t===S.Link||t===S.Image){let e=n.find((e,t)=>t>0&&e.type===S.LinkMark);return e?[n[0].to,e.from]:null}return null}function Ho(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=Vo(r);return i&&i[0]<=t&&n<=i[1]?Ho(r.children,t,n):Ho(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function Uo(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return Uo(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}function Wo(e,t,n){for(;t<n&&C(e.charCodeAt(t));)t++;for(;n>t&&C(e.charCodeAt(n-1));)n--;return[t,n]}function Go(e,t,n,r){let i=ye(Ce(e),e=>e.type===r.node||zo.has(e.type));for(let r=t;r<n;r++)if(!C(e.charCodeAt(r))&&i.every(e=>!(e.from<=r&&r<e.to)))return!1;return!0}function Ko(e,t,n,r,i){let a=Ce(e),o=ye(a,e=>e.type===r.node);return i?Yo(e,o,t,n):qo(e,a,o,t,n,r)}function qo(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=Ho(t,r,i);for(let e of n)e.to===r&&(r=e.from),e.from===i&&(i=e.to)}let o=[];for(let e of n)if(r<=e.from&&e.to<=i){let[t,n]=Bo(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=Jo(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function Jo(e,t,n,r,i){if(i.node!==S.InlineCode)return[i.delim,i.delim];let a=e.slice(t,n);for(let e of[...r].sort((e,t)=>t.from-e.from))a=a.slice(0,e.from-t)+a.slice(e.to-t);let o="`".repeat(Tr(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function Yo(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=Bo(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=Uo(a.children.slice(1,-1),s,c);s>t.to&&C(e.charCodeAt(s-1));)s--;for(;c<o.from&&C(e.charCodeAt(c));)c++;s>t.to?i.push({from:s,to:s,insert:e.slice(o.from,o.to)}):i.push({from:t.from,to:t.to,insert:``}),c<o.from?i.push({from:c,to:c,insert:e.slice(t.from,t.to)}):i.push({from:o.from,to:o.to,insert:``})}return i}function Xo(e,t,n){let{delim:r}=n,i=r.length;if(e.slice(t-i,t)===r&&e.startsWith(r,t)&&e[t-i-1]!==r[0]&&e[t+i]!==r[0])return{kind:`unwrap`,from:t-i,to:t+i};let a=Ce(e),o=ye(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=Bo(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return Zo(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function Zo(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=Vo(n);return!e||t<e[0]||t>e[1]||Zo(n.children,t)}return!1}function G(e){return(t,n)=>{if(t.selection.empty)return Qo(e,t,n);let{from:r,to:i,anchor:a,head:o}=t.selection,s=[];t.doc.nodesBetween(r,i,(t,n)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;let a=t.textContent,o=n+1,[c,l]=Wo(a,Math.max(r-o,0),Math.min(i-o,a.length));return c<l&&s.push({text:a,base:o,from:c,to:l,active:Go(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>Ko(t.text,t.from,t.to,e,c).map(e=>({from:e.from+t.base,to:e.to+t.base,insert:e.insert})));if(l.length===0)return!1;if(n){let e=t.tr;l.sort((e,t)=>t.from-e.from||t.to-e.to);for(let t of l)t.insert?e.insertText(t.insert,t.from,t.to):e.delete(t.from,t.to);e.setSelection(E.create(e.doc,e.mapping.map(a,a<=o?1:-1),e.mapping.map(o,o<a?1:-1))),n(e.scrollIntoView())}return!0}}function Qo(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=Xo(i.textContent,r.parentOffset,e);if(!a)return!1;if(n){let i=r.start(),o=t.tr;a.kind===`unwrap`&&o.delete(i+a.from,i+a.to),a.kind===`move`&&o.setSelection(E.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(E.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function $o(){return s({toggleEm:()=>G(W.em),toggleStrong:()=>G(W.strong),toggleCode:()=>G(W.code),toggleDel:()=>G(W.del),toggleHighlight:()=>G(W.highlight)})}function es(){return l({"Mod-b":G(W.strong),"Mod-i":G(W.em),"Mod-e":G(W.code),"Mod-Shift-x":G(W.del),"Mod-Shift-h":G(W.highlight)})}function ts(){return b($o(),es())}function ns(e,t,n){let r;return e.doc.nodesBetween(t.from,t.to,(e,i)=>(e.isText&&e.marks.some(e=>Fn(e,n))&&(r={from:Math.max(i,t.from),to:Math.min(i+e.nodeSize,t.to)}),!0)),r}function K(e,t){let n=A(e,t,`mdLinkText`),r=A(e,t,`mdPack`,{key:`link`})??A(e,t,`mdPack`,{key:`autolink`}),i=r??n;if(!i)return;let a=r?.mark.attrs,o=n?.mark.attrs?.href??``;if(!r||a?.key!==`link`){let t={from:i.from,to:i.to};return{unit:t,text:a?.key===`autolink`?ns(e,t,`mdLinkText`)??{from:i.from+1,to:i.to-1}:t,href:o,title:``}}if(a.data.reference===!0){let e=n==null?{from:i.from,to:i.to}:{from:n.from+1,to:n.to};return{unit:{from:i.from,to:i.to},text:e,href:a.data.href,title:a.data.title}}let s=ns(e,i,`mdLinkUri`),c=s?s.from-2:i.to-3,l=s?s.from:i.to-1,u={from:i.from+1,to:c};return{unit:{from:i.from,to:i.to},text:u,label:u,dest:{from:l,to:i.to-1},href:a.data.href,title:a.data.title}}function rs(e){let t=e.trim();return t?be(t)??t:``}function is(e,t){return e+(t?` "${t.replaceAll(/(["\\])/g,String.raw`\$1`)}"`:``)}function as(e){let{selection:t}=e,{$from:n,$to:r,empty:i}=t;if(i||!n.sameParent(r)||!y(t))return;let a=n.parent;if(!a.isTextblock||a.type.spec.code)return;let o=n.start(),[s,c]=Wo(a.textContent,n.parentOffset,r.parentOffset);if(!(s>=c))return{from:o+s,to:o+c}}function os({href:e,title:t,wrapText:n=!0}={}){return(r,i)=>{let a=as(r);if(!a)return!1;if(i){let{from:o,to:s}=a,c=r.tr,l=`](${is(rs(e??``),t??``)})`;c.insertText(l,s).insertText(`[`,o);let u=s+1+l.length;c.setSelection(n?E.create(c.doc,o,u):E.create(c.doc,u)),c.scrollIntoView(),i(c)}return!0}}function ss(e){return(t,n)=>{let r=K(t,t.selection.from);if(!r?.dest)return!1;let i=is(rs(e.href??r.href),e.title??r.title);return n&&n(t.tr.insertText(i,r.dest.from,r.dest.to).scrollIntoView()),!0}}function cs(){return(e,t)=>{let n=K(e,e.selection.from);return n?.label?(t&&t(e.tr.delete(n.label.to,n.unit.to).delete(n.unit.from,n.label.from).scrollIntoView()),!0):!1}}function ls(){return s({insertLink:os,updateLink:ss,removeLink:cs})}function us(e){return(t,n,r)=>{let i=K(t,t.selection.from);if(i){if(i.label==null||i.dest==null)return!1;if(n&&r){let{unit:{from:a,to:o}}=i;n(t.tr.setSelection(E.create(t.doc,a,o)).scrollIntoView()),r.focus(),e({from:a,to:o,link:i})}return!0}let a=as(t);if(a){if(n&&r){let{from:i,to:o}=a;n(t.tr.setSelection(E.create(t.doc,i,o)).scrollIntoView()),r.focus(),e({from:i,to:o,link:void 0})}return!0}return!1}}function ds(e){return l({"Mod-k":us(e)})}function fs(e){return e===`)`||e===`*`||e===`+`?e:void 0}function ps(e){return e===`X`?e:void 0}function ms(e){return _s(e)?String(e):void 0}function hs(){return f({type:`list`,attr:`marker`,default:null,splittable:!0,toDOM:e=>{let t=fs(e);return t==null?null:[`data-list-marker`,t]},parseDOM:e=>{let t=e.getAttribute(`data-list-marker`);return t===`)`||t===`*`||t===`+`?t:null}})}function gs(){return f({type:`list`,attr:`taskMarker`,default:null,splittable:!0,toDOM:e=>{let t=ps(e);return t==null?null:[`data-list-task-marker`,t]},parseDOM:e=>e.getAttribute(`data-list-task-marker`)===`X`?`X`:null})}function _s(e){return e===2||e===3||e===4}function vs(){return f({type:`list`,attr:`markerGap`,default:1,splittable:!0,toDOM:e=>{let t=ms(e);return t==null?null:[`data-list-marker-gap`,t]},parseDOM:e=>{let t=Number.parseInt(e.getAttribute(`data-list-marker-gap`)??``,10);return _s(t)?t:1}})}function ys(e){let t=e.attrs;return{...Pt(e),"data-list-marker":fs(t.marker),"data-list-task-marker":ps(t.taskMarker),"data-list-marker-gap":ms(t.markerGap)}}function bs(){return o({serializeFragmentWrapper:e=>(...t)=>xs(Lt(e(...t))),serializeNodeWrapper:e=>(...t)=>{let n=e(...t);return we(n)?xs(Lt(n)):n},nodesFromSchemaWrapper:e=>(...t)=>({...e(...t),list:e=>Rt({node:e,nativeList:!0,getAttributes:ys})})})}function xs(e){we(e)&&Ss(e);for(let t of e.children)xs(t);return e}function Ss(e){if(!e.classList.contains(`prosemirror-flat-list`)||e.getAttribute(`data-list-kind`)!==`task`||e.children.length!==2)return;let t=e.children.item(0);if(!t||!t.classList.contains(`list-marker`))return;let n=Ft(t);if(!n)return;let r=e.children.item(1);if(!r||!r.classList.contains(`list-content`))return;let i=r.children.item(0);!i||![`P`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`].includes(i.tagName)||(e.replaceChildren(...r.children),i.prepend(n))}const Cs=[Bt(/^\s?([*-])\s$/,{kind:`bullet`,collapsed:!1}),Bt(/^\s?(\d+)\.\s$/,({match:e})=>{let t=e[1],n=t?parseInt(t,10):void 0;return{kind:`ordered`,collapsed:!1,order:n&&n>=2&&Number.isSafeInteger(n)?n:null}}),Bt(/^\s?\[([\sX]?)\]\s$/i,({match:e})=>({kind:`task`,checked:[`x`,`X`].includes(e[1]),collapsed:!1})),Bt(/^\s?\+\s$/,{kind:`task`,marker:`+`,checked:!1,collapsed:!1})];function ws(){return b(Cs.map(ot))}function Ts(){return gt({kind:`task`,marker:`+`})}function Es(){return gt({kind:`task`,marker:null})}function Ds(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e);if(F(n,`list`))return n.attrs}return null}function Os(){return(e,t,n)=>{let r=Ds(e);return(r?.kind===`task`?r.marker===`+`?Es():Ts():gt({kind:`task`,marker:null,checked:!1}))(e,t,n)}}function ks(){return s({cycleCheckableList:Os,wrapInCircleTask:Ts,wrapInSquareTask:Es})}function As(){return(e,t,n)=>{let r=Ds(e),i=r?.kind===`task`&&r.marker!==`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:r?.marker??null,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:null,checked:!1},gt(a)(e,t,n)}}function js(){return(e,t,n)=>{let r=Ds(e),i=r?.kind===`task`&&r.marker===`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:`+`,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:`+`,checked:!1},gt(a)(e,t,n)}}function Ms(e){return F(e,`list`)&&e.attrs.kind===`bullet`&&e.childCount>=2&&e.firstChild?.type!==e.type}const Ns=e=>{let t=e.attrs;return t.kind===`task`?{...t,checked:!t.checked}:Ms(e)?{...t,collapsed:!t.collapsed}:t};function Ps(){return m(()=>[new w({props:{handleDOMEvents:{mousedown:(e,t)=>It({view:e,event:t,onListClick:Ns})}}}),jt(),new w({props:{transformCopied:zt}}),Mt()])}function Fs(){return s({toggleListCollapsed:()=>Nt({isToggleable:Ms})})}function Is(){return l({"Mod-Enter":As(),"Mod-Shift-Enter":js(),"Mod-.":Nt({isToggleable:Ms}),"Mod-Shift-7":mt({kind:`ordered`,collapsed:!1}),"Mod-Shift-8":mt({kind:`bullet`,collapsed:!1}),"Mod-Shift-9":mt({kind:`task`,checked:!1,collapsed:!1})})}function Ls(){return b(ft(),Ps(),dt(),lt(),bs(),ut(),ws(),Is(),hs(),gs(),vs(),ks(),Fs())}let Rs;function zs(){return Rs??=import(`./katex-chunk-Ch7kgbXr.js`).then(e=>e.render),Rs}function Bs(e,t,n,r){try{e(n,t,{displayMode:r,throwOnError:!1,output:`mathml`})}catch(e){t.textContent=String(e)}}var Vs=class{#e;#t;#n;#r;constructor(e,t){this.#r=e.attrs.formula,this.#e=document.createElement(`span`),this.#e.className=`md-math-view`,this.#n=document.createElement(`span`),this.#n.className=`md-math-view-preview`,this.#n.dataset.testid=`math-preview`,this.#n.contentEditable=`false`,this.#n.addEventListener(`mousedown`,e=>{e.preventDefault();let n=t.posAtDOM(this.#t,0);if(n<0)return;let r=E.near(t.state.doc.resolve(n),1);t.dispatch(t.state.tr.setSelection(r)),t.focus()}),this.#t=document.createElement(`span`),this.#t.className=`md-math-view-content`,this.#e.appendChild(this.#n),this.#e.appendChild(this.#t),this.#i()}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs.formula;return t!==this.#r&&(this.#r=t,this.#i()),!0}ignoreMutation(e){return!this.#t.contains(e.target)}#i(){let e=this.#r;zs().then(t=>{e===this.#r&&Bs(t,this.#n,e,!1)})}};function Hs(){return d({name:`mdMath`,constructor:(e,t)=>new Vs(e,t)})}function Us(e){return e===`left`||e===`center`||e===`right`?e:null}function Ws(){return f({type:`tableCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>Us(e.getAttribute(`data-align`))})}function Gs(){return f({type:`tableHeaderCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>Us(e.getAttribute(`data-align`))})}function Ks(e){for(let t=0;t<e.childCount;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++)if(F(n.child(e),`tableHeaderCell`))return t}return 0}function qs(e){return e.child(Ks(e))}function Js(e,t){return t>=e.childCount?null:e.child(t).attrs.align??null}function Ys(e,t,n){if(e.childCount===0)return;let r=qs(e),i=t+1;for(let t=0;t<e.childCount;t++){let a=e.child(t),o=i+1;for(let e=0;e<a.childCount;e++){let t=a.child(e),i=Js(r,e);(t.attrs.align??null)!==i&&n.setNodeMarkup(o,void 0,{...t.attrs,align:i}),o+=t.nodeSize}i+=a.nodeSize}}function Xs(e){let t,n;for(let r of e){if(!r.docChanged)continue;t!=null&&n!=null&&(t=r.mapping.map(t,-1),n=r.mapping.map(n,1));let e=r.mapping;for(let[r,i]of e.maps.entries()){let a=e.slice(r+1);i.forEach((e,r,i,o)=>{let s=a.map(i,-1),c=a.map(o,1);t=t==null?s:Math.min(t,s),n=n==null?c:Math.max(n,c)})}}if(t!=null&&n!=null)return{from:t,to:n}}function Zs(){return new w({key:new T(`table-align-sync`),appendTransaction(e,t,n){if(!e.some(e=>e.docChanged))return;let r=Xs(e);if(!r)return;let i=n.doc,a=Math.max(0,Math.min(r.from,i.content.size)),o=Math.max(a,Math.min(r.to,i.content.size)),s;return i.nodesBetween(a,o,(e,t)=>F(e,`table`)?(s??=n.tr,Ys(e,t,s),!1):!0),s?.docChanged?s:void 0}})}function Qs(){return m(Zs())}function $s(e){let{selection:t}=e;if(Yt(t)){let{$anchorCell:e,$headCell:n}=t,r=e.depth-1,i=e.index(),a=n.index();return{table:e.node(r),tablePos:e.before(r),firstColumn:Math.min(i,a),lastColumn:Math.max(i,a)}}let{$from:n}=t;for(let e=n.depth;e>2;e--){let t=n.node(e).type.name;if(t===`tableCell`||t===`tableHeaderCell`){let t=n.index(e-1);return{table:n.node(e-2),tablePos:n.before(e-2),firstColumn:t,lastColumn:t}}}}function ec(e){return(t,n)=>{let r=$s(t);if(!r||r.table.childCount===0)return!1;if(n){let{table:i,tablePos:a,firstColumn:o,lastColumn:s}=r,c=Ks(i),l=a+1;for(let e=0;e<c;e++)l+=i.child(e).nodeSize;let u=i.child(c),d=t.tr,f=l+1;for(let t=0;t<u.childCount;t++){let n=u.child(t);t>=o&&t<=s&&(n.attrs.align??null)!==e&&d.setNodeMarkup(f,void 0,{...n.attrs,align:e}),f+=n.nodeSize}n(d)}return!0}}function tc(e){let t=$s(e);if(!(!t||t.table.childCount===0))return Js(qs(t.table),t.lastColumn)??void 0}function nc(){return s({setTableColumnAlign:ec})}function rc(){return b(Ws(),Gs(),Qs(),nc())}function ic(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e).type.name;if(n===`tableCell`||n===`tableHeaderCell`)return!0}return!1}const ac=`paragraph`;function oc(){return b(p({name:`tableCell`,content:ac}),p({name:`tableHeaderCell`,content:ac}))}const sc=(e,t)=>{let{selection:n}=e;return!Yt(n)||!n.isColSelection()||!n.isRowSelection()?!1:Jt(e,t)};function cc(){return x(l({Backspace:sc,Delete:sc}),t.high)}function lc(){return b(qt(),Kt(),Vt(),Gt(),oc(),rc(),Wt({allowTableNodeSelection:!0}),Ht(),Ut(),cc())}function uc(e){let{selection:t}=e,{$from:n,$to:r}=t;if(ne(t)&&n.depth===0||n.depth>0&&r.depth>0&&n.index(0)===r.index(0))return n.index(0)}function dc(e){return(t,n)=>{if(ic(t))return!1;let r=uc(t);if(r==null)return!1;let i=r+e;if(i<0||i>=t.doc.childCount)return!1;if(n){let{selection:a}=t,o=Math.min(r,i),s=a.$from.posAtIndex(o,0),c=t.doc.child(o),l=t.doc.child(o+1),u=t.tr.replaceWith(s,s+c.nodeSize+l.nodeSize,[l,c]),d=e===-1?-c.nodeSize:l.nodeSize,f=ne(a)?Pe.create(u.doc,a.from+d):E.create(u.doc,a.anchor+d,a.head+d);u.setSelection(f),n(u.scrollIntoView())}return!0}}function fc(e){return(t,n,r)=>pt(e)(t,n,r)||dc(e===`up`?-1:1)(t,n,r)}function pc(){return l({"Alt-ArrowUp":fc(`up`),"Alt-ArrowDown":fc(`down`)})}const q=new T(`meowdownPendingReplacement`);function mc(e){return q.getState(e)?.pending??null}function hc(e,t){switch(e.type){case`start`:return{pending:{from:e.from,to:e.to,mode:e.mode,text:``}};case`append`:return t.pending?{pending:{...t.pending,text:t.pending.text+e.text}}:t;case`accept`:return t.pending?{pending:null,ended:{pending:t.pending,outcome:`accepted`}}:t;case`discard`:return t.pending?{pending:null,ended:{pending:t.pending,outcome:`discarded`}}:t}}const gc=new w({key:q,state:{init:()=>({pending:null}),apply:(e,t)=>{let n=e.getMeta(q);if(n)return hc(n,t);if(e.docChanged&&t.pending){let n=e.mapping.mapResult(t.pending.from,1),r=e.mapping.mapResult(t.pending.to,-1),i=Math.min(n.pos,r.pos),a=Math.max(n.pos,r.pos);return(n.deletedAfter&&r.deletedBefore||i>=a)&&t.pending.mode===`replace`?{pending:null,ended:{pending:t.pending,outcome:`discarded`}}:{pending:{...t.pending,from:i,to:a}}}return t}},props:{decorations:e=>{let t=mc(e);return!t||t.from>=t.to?null:D.create(e.doc,[Ie.inline(t.from,t.to,{class:`md-pending-replacement`})])}}});function _c(e){return(t,n)=>{let{from:r,to:i,mode:a}=e;return r<0||i>t.doc.content.size||r>i||r===i&&a===`replace`?!1:(n?.(t.tr.setMeta(q,{type:`start`,from:r,to:i,mode:a})),!0)}}function vc(e){return(t,n)=>mc(t)?(n?.(t.tr.setMeta(q,{type:`append`,text:e})),!0):!1}function yc(){return(e,t)=>mc(e)?(t?.(e.tr.setMeta(q,{type:`discard`})),!0):!1}function bc(e={}){return(t,n)=>{let r=mc(t);if(!r||!r.text.trim())return!1;if(n){let i=e.mode??r.mode,a=al(t.schema),o=X(r.text,{nodes:a}),s=t.tr;if(s.setMeta(q,{type:`accept`}),i===`append`){let e=t.doc.resolve(r.to).after(1);s.insert(e,o.content),s.setSelection(E.near(s.doc.resolve(e+o.content.size),-1))}else{let e=t.doc.resolve(r.from),n=t.doc.resolve(r.to),i=o.childCount===1?o.firstChild:null;i!=null&&F(i,`paragraph`)&&e.sameParent(n)&&e.parent.isTextblock?(s.replaceWith(r.from,r.to,i.content),s.setSelection(E.near(s.doc.resolve(r.from+i.content.size),-1))):(s.replaceRange(r.from,r.to,new k(o.content,0,0)),s.setSelection(E.near(s.doc.resolve(s.mapping.map(r.to)),-1)))}n(s.scrollIntoView())}return!0}}function xc(){return s({startPendingReplacement:_c,appendPendingReplacementText:vc,acceptPendingReplacement:bc,discardPendingReplacement:yc})}function Sc(){return l({"Mod-Enter":bc(),Escape:yc()})}function Cc(){return b(m(gc),xc(),Sc())}function wc(e){return m(new w({view:()=>({update:(t,n)=>{let r=q.getState(n),i=q.getState(t.state);!i||r===i||(i.pending?i.pending!==r?.pending&&e({type:`update`,pending:i.pending}):i.ended&&i.ended!==r?.ended&&e({type:`ended`,pending:i.ended.pending,outcome:i.ended.outcome}))}})}))}function Tc(e){return e.left===e.right&&e.top===e.bottom}function J(e,t,n){if(t<0||t>e.state.doc.content.size)return;let r;try{r=e.coordsAtPos(t,n)}catch{return}return Tc(r)?void 0:r}function Ec(e){let t=e.dom.ownerDocument.getSelection();if(t==null||t.rangeCount===0||!e.dom.contains(t.anchorNode))return;let n=t.getRangeAt(0).cloneRange();n.collapse(!0);let r=Array.from(n.getClientRects()).filter(e=>e.height>0);if(r.length===0)return;let i=r[r.length-1];return{left:i.left,top:i.top,height:i.height}}function Dc(e){let t=e.state,n=t.selection.head,r=z(t,n),i=B(t,n),a=t.doc.resolve(n),o=a.parentOffset>0&&a.parent.textBetween(a.parentOffset-1,a.parentOffset)===`
30
+ `,s=r==null&&!o,c=[[n,s],[n,!s]];r!=null&&c.push([r.from,!0]),i!=null&&c.push([i.to,!1]);for(let[t,n]of c){let r=J(e,t,n?-1:1);if(r!=null&&r.bottom>r.top)return{left:r.left,top:r.top,height:r.bottom-r.top}}}function Oc(e){let t=e.state,n=t.selection.head;for(let r of ln){let i=A(t,n,r);if(i==null||i.from!==n&&i.to!==n)continue;let a=Ac(e,i.from+1);if(a==null)continue;let o=Array.from(a.getClientRects()).filter(e=>e.height>0);if(o.length===0)continue;let s=i.to===n,c=s?o[o.length-1]:o[0];return{left:s?c.right:c.left,top:c.top,height:c.height}}}function kc(e,t,n){let r=e.state;for(let i of ln){let a=A(r,t,i);if(a==null)continue;let o=Ac(e,a.from+1);if(o==null)continue;let s=Array.from(o.getClientRects()).filter(e=>e.height>0);if(s.length!==0)return n===1?s[0]:s[s.length-1]}}function Ac(e,t){let{node:n}=e.domAtPos(t,0);return(n instanceof Element?n:n.parentElement)?.closest(`.md-atom-view`)?.querySelector(`.md-atom-view-preview`)??void 0}function jc(e){return Dc(e)??Oc(e)}const Mc=new T(`meowdown-scroll-to-selection`);function Nc(e){let t=e.state.selection;if(!y(t)||J(e,t.head,1)!=null)return!1;let n=jc(e);if(n==null)return!1;let r=e.domAtPos(t.head).node;return Lc(e,{left:n.left,right:n.left,top:n.top,bottom:n.top+n.height},r),!0}function Y(e,t){return typeof e==`number`?e:e[t]}function Pc(e){let t=e.assignedSlot??e.parentNode;return t?.nodeType===11?t.host:t}function Fc(e){let t=e.defaultView?.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Ic(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function Lc(e,t,n){let r=e.someProp(`scrollThreshold`)??0,i=e.someProp(`scrollMargin`)??5,a=e.dom.ownerDocument;for(let e=n;e;){if(e.nodeType!==1){e=Pc(e);continue}let n=e,o=n===a.body,s=o?Fc(a):Ic(n),c=0,l=0;if(t.top<s.top+Y(r,`top`)?l=-(s.top-t.top+Y(i,`top`)):t.bottom>s.bottom-Y(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+Y(i,`top`)-s.top:t.bottom-s.bottom+Y(i,`bottom`)),t.left<s.left+Y(r,`left`)?c=-(s.left-t.left+Y(i,`left`)):t.right>s.right-Y(r,`right`)&&(c=t.right-s.right+Y(i,`right`)),c||l)if(o)a.defaultView?.scrollBy(c,l);else{let e=n.scrollLeft,r=n.scrollTop;l&&(n.scrollTop+=l),c&&(n.scrollLeft+=c);let i=n.scrollLeft-e,a=n.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=o?`fixed`:getComputedStyle(n).position;if(/^(?:fixed|sticky)$/.test(u))break;e=u===`absolute`?n.offsetParent:Pc(n)}}function Rc(){return m(new w({key:Mc,props:{handleScrollToSelection:Nc}}))}function zc(e,t){return(n,r)=>{let i=e<0?Fe.atStart(n.doc):Fe.atEnd(n.doc),a=t?E.between(n.selection.$anchor,i.$head):i;return n.selection.eq(a)||r?.(n.tr.setSelection(a).scrollIntoView()),!0}}function Bc(){return l({"Meta-ArrowUp":zc(-1,!1),"Meta-ArrowDown":zc(1,!1),"Shift-Meta-ArrowUp":zc(-1,!0),"Shift-Meta-ArrowDown":zc(1,!0)})}function Vc(e){return m(new w({props:{attributes:e}}))}function Hc(e){e.offsetWidth}const Uc=new T(`meowdown-virtual-caret`),Wc=[`md-virtual-caret-blink`,`md-virtual-caret-blink2`],Gc=`data-meowdown-virtual-caret`;function Kc(e){let t=e.height*.19999999999999996;return{left:e.left,top:e.top-t/2,height:e.height+t}}function qc(e){let t=Ec(e)??Dc(e);return t==null?Oc(e):Kc(t)}function Jc(e,t){return e==null||t==null?e===t:e.left===t.left&&e.top===t.top&&e.height===t.height}var Yc=class{#e;#t;#n;#r;#i;#a;#o;#s=0;constructor(e){this.#e=e,this.#r=e.dom.ownerDocument,this.#t=this.#r.createElement(`div`),this.#t.className=`md-virtual-caret-layer`,this.#n=this.#t.appendChild(this.#r.createElement(`div`)),this.#n.className=`md-virtual-caret`,this.#n.dataset.testid=`virtual-caret`,e.dom.insertAdjacentElement(`afterend`,this.#t),this.#r.addEventListener(`selectionchange`,this.#l),typeof ResizeObserver<`u`&&(this.#i=new ResizeObserver(this.#l),this.#i.observe(e.dom)),this.#l()}update(e,t){e.state.selection.eq(t.selection)||this.#c(),this.#l()}destroy(){this.#r.removeEventListener(`selectionchange`,this.#l),this.#i?.disconnect(),this.#t.remove()}#c(){this.#s=1-this.#s,this.#n.style.animationName=Wc[this.#s]}#l=()=>{let e=this.#e;if(e.isDestroyed)return;let t=e.state,n=t.selection,r=y(n)&&n.empty?qc(e):void 0,i=r!=null&&j(t)===`hide`?Ji(t,n.head):void 0;if(Jc(r,this.#a)&&i===this.#o)return;let a=this.#a==null;if(this.#a=r,this.#o=i,i==null?delete this.#n.dataset.tail:this.#n.dataset.tail=i,r==null){this.#n.style.visibility=`hidden`,e.dom.removeAttribute(Gc);return}let o=this.#t.getBoundingClientRect();a&&(this.#n.style.transitionProperty=`none`),this.#n.style.visibility=``,this.#n.style.left=`${r.left-o.left}px`,this.#n.style.top=`${r.top-o.top}px`,this.#n.style.height=`${r.height}px`,e.dom.setAttribute(Gc,``),a&&(Hc(this.#n),this.#n.style.transitionProperty=``)}};function Xc(){return m(new w({key:Uc,view:e=>new Yc(e)}))}function Zc(e){return b(ar(),ke(),Pi(),Me(),Oe(),Ls(),tr(),lc(),gi(),oa(),sa(),Ro(),Vc({class:`meowdown-content`}),si(),ki(),ji(),pc(),Bc(),So(e),ts(),ls(),Ha(),Hs(),an(e.markMode??`focus`),ti(),Xc(),Rc(),ia(),xn({marks:ln.map(e=>({name:e,modes:[`hide`,`focus`,`show`]}))}),a(),i(),c(),Ae(),Ne(),je(),Ci(),Cc(),Ni())}function Qc(e={}){return Zc(e)}const $c=De(()=>{let e=Qc().schema;if(e==null)throw Error(`Unexpected empty schema`);return e}),el=De(()=>r($c())),tl=De(()=>n($c())),nl=`meowdown_mark_builders`;function rl(e){let t=e.cached[nl];if(t)return t;let r=n(e);return e.cached[nl]=r,r}const il=`meowdown_node_builders`;function al(e){let t=e.cached[il];if(t)return t;let n=r(e);return e.cached[il]=n,n}function X(e,t={}){let{nodes:n=el(),frontmatter:r=!1}=t,i,a=e;if(r){let[t,n]=sl(e);i=t,n&&(a=e.slice(n))}let o=cl(n,xe.parse(a).cursor(),a);return n.doc(i===void 0?{}:{frontmatter:i},o)}const ol=/^---[ \t]*\r?\n([\s\S]*?\n)?---[ \t]*(?:\r?\n|$)/;function sl(e){let t=ol.exec(e);return t?[(t[1]??``).replace(/\r?\n$/,``),t[0].length]:[]}function cl(e,t,n){let r=[];if(!t.firstChild())return r;let i;do i!=null&&ll(r,e,n,i,t.from),i=t.to,r.push(...ul(e,t,n));while(t.nextSibling());return t.parent(),r}function ll(e,t,n,r,i){let a=0;for(let e=r;e<i;e++)n.charCodeAt(e)===10&&a++;for(let n=2;n<a;n++)e.push(t.paragraph())}function ul(e,t,n){switch(t.type.id){case S.ATXHeading1:return[Z(e,t,n,1,!1)];case S.ATXHeading2:return[Z(e,t,n,2,!1)];case S.ATXHeading3:return[Z(e,t,n,3,!1)];case S.ATXHeading4:return[Z(e,t,n,4,!1)];case S.ATXHeading5:return[Z(e,t,n,5,!1)];case S.ATXHeading6:return[Z(e,t,n,6,!1)];case S.SetextHeading1:return[Z(e,t,n,1,!0)];case S.SetextHeading2:return[Z(e,t,n,2,!0)];case S.Paragraph:return[gl(e,t,n)];case S.LinkReference:return[gl(e,t,n)];case S.CommentBlock:return[_l(e,t,n)];case S.HTMLBlock:case S.ProcessingInstructionBlock:return[gl(e,t,n)];case S.Blockquote:return[vl(e,t,n)];case S.BulletList:return yl(e,t,n,`bullet`);case S.OrderedList:return yl(e,t,n,`ordered`);case S.FencedCode:case S.CodeBlock:return[Cl(e,t,n)];case S.BlockMath:return[wl(e,t,n)];case S.HorizontalRule:{let r=n.slice(t.from,t.to).trimEnd();return[e.horizontalRule({marker:r===`---`?null:r})]}case S.Table:return[Tl(e,t,n)];case S.Task:return[gl(e,t,n)];default:return n.slice(t.from,t.to).trim()===``?[]:(console.warn(`[meowdown] unsupported lezer block "${t.type.name}"`),[gl(e,t,n)])}}function Z(e,t,n,r,i){let a=t.from,o=t.from,s=t.to,c=-1,l=-1;if(t.firstChild()){t.type.id===S.HeaderMark&&t.from===a&&(o=t.to);let e=-1,n=-1,r=-1;do e=t.type.id,n=t.from,r=t.to;while(t.nextSibling());e===S.HeaderMark&&n>o&&(s=n,c=n,l=r),t.parent()}let u=ml(n.slice(o,s),Q(n,o)).trim(),d=i?dl(n,c,l)||1:null,f=!i&&c>=0&&fl(n,c,l)||null;return e.heading({level:r,setextUnderline:d,closingHashes:f},u)}function dl(e,t,n){if(t<0)return 0;let r=0;for(let i=t;i<n;i++){let t=e.charCodeAt(i);(t===61||t===45)&&r++}return r}function fl(e,t,n){if(t<0)return 0;let r=0;for(let i=t;i<n;i++)e.charCodeAt(i)===35&&r++;return r}function Q(e,t){let n=e.lastIndexOf(`
31
+ `,t-1)+1,r=0;for(let i=n;i<t;i++)r+=e.charCodeAt(i)===9?4-r%4:1;return r}function pl(e,t){let n=0,r=0;for(;r<e.length&&n<t;){let t=e.charCodeAt(r);if(t===32)n+=1;else if(t===9)n+=4-n%4;else break;r++}return e.slice(r)}function ml(e,t){return t===0||!e.includes(`
32
32
  `)?e:e.split(`
33
- `).map((e,n)=>n===0?e:ml(e,t)).join(`
34
- `)}function gl(e,t,n){return e.paragraph(hl(t,n))}function _l(e,t,n){let r=t.from,i=t.to,a=$(n,r);if(t.firstChild()){let o=``,s=r;do t.type.id===S.QuoteMark&&(o+=n.slice(s,t.from),s=t.to,C(n.charCodeAt(s))&&(s+=1));while(t.nextSibling());return t.parent(),o+=n.slice(s,i),gl(e,o,a)}return gl(e,n.slice(r,i),a)}function vl(e,t,n){let r=$(n,t.from),i=hl(n.slice(t.from,t.to),r);return e.htmlComment({content:i})}function yl(e,t,n){let r=[];if(t.firstChild()){let i;do{if(t.type.id===S.QuoteMark)continue;i!=null&&ul(r,e,n,i,t.from),i=t.to,r.push(...dl(e,t,n))}while(t.nextSibling());t.parent()}return e.blockquote(r)}function bl(e,t,n,r){let i=[];if(t.firstChild()){do t.type.id===S.ListItem&&i.push(Cl(e,t,n,r));while(t.nextSibling());t.parent()}return i}function xl(e,t,n){if(n===`ordered`){let n=t.charCodeAt(e.to-1),r;n===41?r=`)`:n===46&&(r=`.`);let i=Number.parseInt(t.slice(e.from,e.to),10);return{marker:r,order:Number.isFinite(i)?i:1}}let r=t.charCodeAt(e.from);return{marker:r===42?`*`:r===43?`+`:`-`,order:void 0}}function Sl(e,t,n){let r=t.from,i=t.to,a=!1,o;if(t.firstChild()){if(t.type.id===S.TaskMarker){let e=n.charCodeAt(t.from+1);e===120?(a=!0,o=`x`):e===88&&(a=!0,o=`X`),r=t.to}t.parent()}C(n.charCodeAt(r))&&(r+=1);let s=gl(e,n.slice(r,i),$(n,r));return{checked:a,taskMarker:o,paragraph:s}}function Cl(e,t,n,r){let i=[],a,o,s,c,l,u;if(t.firstChild()){do{if(t.type.id!==S.ListMark&&u==null&&(u=$(n,t.from)),t.type.id===S.ListMark){let e=xl(t,n,r);c=e.marker,s=e.order,l=$(n,t.to);continue}if(r===`bullet`&&t.type.id===S.Task){let r=Sl(e,t,n);a=r.checked,o=r.taskMarker,i.push(r.paragraph);continue}i.push(...dl(e,t,n))}while(t.nextSibling());t.parent()}let d=u!=null&&l!=null?u-l:1,f=a!=null,p=!f&&r===`bullet`&&c===`+`,m={kind:f?`task`:r,order:r===`ordered`?s??1:null,checked:a??!1,collapsed:p,marker:p?null:c,taskMarker:o,markerGap:d>=2&&d<=4?d:1};return e.list(m,i)}function wl(e,t,n){let r=t.type.id===S.CodeBlock,i=``,a=``,o=r?`indented`:null,s=null,c=!1;if(t.firstChild()){do switch(t.type.id){case S.CodeMark:{if(c)break;c=!0,n.charCodeAt(t.from)===126&&(o=`tilde`);let e=t.to-t.from;e>3&&(s=e);break}case S.CodeInfo:i=n.slice(t.from,t.to);break;case S.CodeText:a+=n.slice(t.from,t.to);break}while(t.nextSibling());t.parent()}return e.codeBlock({language:i,fenceStyle:o,fenceLength:s},a)}function Tl(e,t,n){let r=``;if(t.firstChild()){do t.type.id===S.CodeText&&(r+=n.slice(t.from,t.to));while(t.nextSibling());t.parent()}return e.codeBlock({language:`math`,fenceStyle:`dollar`,fenceLength:null},r)}function El(e,t,n){let r=[];if(t.firstChild()){do t.type.id===S.TableDelimiter&&(r=Dl(n.slice(t.from,t.to)));while(t.nextSibling());t.parent()}let i=[];if(t.firstChild()){do{let a=t.type.id;a===S.TableHeader?i.push(Ol(e,t,n,!0,r)):a===S.TableRow&&i.push(Ol(e,t,n,!1,r))}while(t.nextSibling());t.parent()}return e.table(i)}function Dl(e){return e.split(`|`).map(e=>e.trim()).filter(e=>e!==``).map(e=>{let t=e.startsWith(`:`),n=e.endsWith(`:`);return t&&n?`center`:t?`left`:n?`right`:null})}function Ol(e,t,n,r,i){let a=i.length,o=Array(a).fill(``);if(t.firstChild()){let e=t.type.id===S.TableDelimiter,r=0;do if(t.type.id===S.TableDelimiter)r++;else if(t.type.id===S.TableCell){let i=r-+!!e;i>=0&&i<a&&(o[i]=n.slice(t.from,t.to).trim().replaceAll(String.raw`\|`,`|`))}while(t.nextSibling());t.parent()}let s=o.map((t,n)=>{let a=e.paragraph(t),o={align:i[n]};return r?e.tableHeaderCell(o,a):e.tableCell(o,a)});return e.tableRow(s)}function kl(e){return e.replace(/\n+$/u,``)}function Al(e){return/^[\s>]*$/u.test(e)}function jl(e){return e.split(`
35
- `).filter(e=>!Al(e))}function Ml(e){return e.trim().replaceAll(/\s+/gu,` `)}const Nl=/^:?-+:?$/u;function Pl(e){let t=e.startsWith(`:`),n=e.endsWith(`:`);return t&&n?`:-:`:t?`:--`:n?`--:`:`---`}function Fl(e){if(!e.includes(`|`))return;let t=/^[\s>]*/u.exec(e)?.[0]??``,n=e.slice(t.length).trim().replace(/^\|/u,``).replace(/\|$/u,``).split(`|`).map(e=>Ml(e));return Ml(`${t} | ${(n.every(e=>Nl.test(e))?n.map(Pl):n).join(` | `)} |`)}function Il(e){return Fl(e)??Ml(e)}function Ll(e,t={}){let n=Tr(Z(e,{frontmatter:t.frontmatter}),{frontmatter:t.frontmatter});if(kl(n)===kl(e))return`exact`;let r=jl(e),i=jl(n);return r.length===i.length&&r.every((e,t)=>Il(e)===Il(i[t]))?`normalizing`:`lossy`}const Rl=(e,t)=>{let{$from:n,empty:r}=e.selection;if(!r||n.depth!==1||n.index(0)!==0||!L(n.parent,`heading`)||n.parentOffset!==n.parent.content.size)return!1;if(t){let r=_(e.schema,`list`),i=_(e.schema,`paragraph`),a=r.create({kind:`bullet`},i.create()),o=n.after(),s=e.tr.insert(o,a);s.setSelection(E.create(s.doc,o+2)),t(s.scrollIntoView())}return!0};function zl(){return x(l({Enter:Rl}),t.high)}const Bl=new Set([`MscGen`,`Xù`,`MsGenny`,`Angular Template`,`Brainfuck`,`Esper`,`Oz`,`Factor`,`Squirrel`,`Yacas`,`mIRC`,`FCL`,`ECL`,`MUMPS`,`Pig`,`Asterisk`,`Z80`,`Mathematica`]),Vl=Ye.map(e=>({label:e.name,value:e.name.toLowerCase()})).filter(e=>!Bl.has(e.label)).concat([{label:`Plain text`,value:``},{label:`Math`,value:`math`},{label:`Mermaid`,value:`mermaid`}]).sort((e,t)=>e.label.localeCompare(t.label));function Hl(){return typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches}const Ul=/^(?:www\.|mobile\.)?(?:twitter\.com|x\.com)$/i,Wl=/\/status(?:es)?\/(\d+)/;function Gl(e){let t;try{t=new URL(e)}catch{return}if(Ul.test(t.hostname))return Wl.exec(t.pathname)?.[1]}const Kl=e=>{let t=Gl(e);if(!t)return;let n=Hl()?`dark`:`light`;return{kind:`tweet`,key:`tweet:${t}`,src:`https://platform.twitter.com/embed/Tweet.html?id=${t}&theme=${n}&dnt=true`,title:`Tweet`,className:`md-embed md-embed-tweet`,testid:`tweet-embed`}};function ql(e){let t=t=>{if(t.source===e.contentWindow)try{let n=t.data?.[`twttr.embed`]?.params?.[0]?.height;typeof n==`number`&&(e.style.height=`${n}px`)}catch(e){console.warn(`[meowdown] failed to parse tweet resize message:`,e)}};window.addEventListener(`message`,t);let n=!1,r=()=>{n||(n=!0,window.removeEventListener(`message`,t),i.disconnect())},i=new MutationObserver(()=>{e.isConnected||r()});return i.observe(document.body,{childList:!0,subtree:!0}),r}const Jl=/^(?:www\.|m\.)?(?:youtube\.com|youtube-nocookie\.com)$/i,Yl=/^(?:www\.)?youtu\.be$/i,Xl=/^[\w-]{11}$/;function Zl(e){let t;try{t=new URL(e)}catch{return}let n=null;if(Yl.test(t.hostname))n=t.pathname.slice(1);else if(Jl.test(t.hostname)){let[,e,r]=t.pathname.split(`/`);t.pathname===`/watch`?n=t.searchParams.get(`v`):(e===`shorts`||e===`embed`||e===`live`)&&(n=r??null)}if(!n||!Xl.test(n))return;let r=t.searchParams.get(`start`)??t.searchParams.get(`t`),i=r?Ql(r):void 0;return{videoId:n,startSeconds:i}}function Ql(e){if(/^\d+$/.test(e))return Number(e);let t=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(e);if(!(!t||!t[1]&&!t[2]&&!t[3]))return Number(t[1]??0)*3600+Number(t[2]??0)*60+Number(t[3]??0)}const $l=[e=>{let t=Zl(e);if(!t)return;let n=t.startSeconds?`?start=${t.startSeconds}`:``;return{kind:`youtube`,key:`youtube:${t.videoId}:${t.startSeconds??0}`,src:`https://www.youtube-nocookie.com/embed/${t.videoId}${n}`,title:`YouTube video`,className:`md-embed md-embed-youtube`,testid:`youtube-embed`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen`,allowFullscreen:!0}},Kl];function eu(e){for(let t of $l){let n=t(e);if(n)return n}}function tu(e,t){return e.clipboardData?.getData(`text/plain`)||t.content.textBetween(0,t.content.size,`
36
- `)}const nu=new T(`meowdown-embed-paste`);function ru(e){let t=e.trim();if(!(!t||/\s/.test(t)))return eu(t)?t:void 0}function iu(e,t){let{from:n,to:r}=e.state.selection;e.dispatch(Xt(e.state.tr.insertText(t,n,r)));let i=e.state.tr.insertText(`![](${t})`,n,n+t.length);e.dispatch(Xt(i))}function au(){return m(new w({key:nu,props:{handlePaste:(e,t,n)=>{let r=e.state.selection.$from.parent;if(!r.inlineContent||r.type.spec.code)return!1;let i=tu(t,n);if(!i)return!1;let a=ru(i);return a?(iu(e,a),!0):!1}}}))}const ou=new T(`meowdown-exit-boundary`);function su(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):void 0:i;return!!(a&&Ae.findFrom(a,t))}function cu(e,t){let{state:n}=e,{selection:r}=n;return y(r)&&!r.empty||v(r)||r.$from.parent.inlineContent&&!e.endOfTextblock(t<0?`up`:`down`)?!0:su(n,t)}function lu(e){return new w({key:ou,props:{handleKeyDown:(t,n)=>{if(n.shiftKey||n.altKey||n.ctrlKey||n.metaKey)return!1;let r=n.key===`ArrowUp`?-1:n.key===`ArrowDown`?1:void 0;return!(!r||cu(t,r)||e({direction:r<0?`up`:`down`,event:n})===!1)}}})}function uu(e){return x(m(lu(e)),t.low)}const du=new T(`meowdown-file-click`);function fu(e,t){let n=j(e,t,`mdFile`);if(!n)return;let{href:r,name:i}=n.mark.attrs;return{href:r,name:i}}function pu(e){return m(new w({key:du,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(`.md-file-view-preview`);if(!i)return!1;let a=i.closest(`.md-file-view`)?.querySelector(`.md-file-view-content`);if(!a)return!1;let o=fu(t.state,t.posAtDOM(a,0));return o?(e({href:o.href,name:o.name,event:r}),!0):!1}}}))}const mu=new Set([`avif`,`bmp`,`gif`,`jpeg`,`jpg`,`png`,`svg`,`webp`]);function hu(e){if(e.type?.startsWith(`image/`))return!0;let t=e.name.lastIndexOf(`.`);if(t===-1)return!1;let n=e.name.slice(t+1).toLowerCase();return mu.has(n)}function gu(e,t){return hu(e)?`![](${t})`:`[${yu(e.name)}](${t})`}function _u(e,t){return!e||!t.onFilePaste?[]:Array.from(e.files)}const vu=e=>{console.error(`[meowdown] failed to save pasted file:`,e)};function yu(e){return e.replaceAll(/[\\[\]]/g,String.raw`\$&`)}async function bu(e,t,n,r){let{onFilePaste:i}=n;if(!i)return;let a=n.onFileSaveError??vu,o=r,s=!1;for(let n of t){let t;try{t=await i(n)}catch(e){a(e,n);continue}if(!t||e.isDestroyed)continue;let r=gu(n,t),c=s?`\n${r}`:r,l=o==null?e.state.tr.insertText(c):e.state.tr.insertText(c,o);e.dispatch(l),s=!0,o!=null&&(o+=c.length)}}function xu(e){return new w({key:new T(`file-paste`),props:{handlePaste:(t,n)=>{let r=_u(n.clipboardData,e);return r.length===0?!1:(bu(t,r,e),!0)},handleDrop:(t,n)=>{let r=_u(n.dataTransfer,e);return r.length===0?!1:(bu(t,r,e,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos),!0)}}})}function Su(e={}){return x(m(xu(e)),t.high)}const Cu=[`KB`,`MB`,`GB`,`TB`];function wu(e){let t=e,n=`B`;for(let e of Cu){if(t<999.5)break;t/=1e3,n=e}return n===`B`?`${Math.round(t)} B`:`${t<9.95?Math.round(t*10)/10:Math.round(t)} ${n}`}const Tu=new Map([[`pdf`,`pdf`],[`zip`,`archive`],[`tar`,`archive`],[`gz`,`archive`],[`tgz`,`archive`],[`rar`,`archive`],[`7z`,`archive`],[`doc`,`doc`],[`docx`,`doc`],[`pages`,`doc`],[`xls`,`sheet`],[`xlsx`,`sheet`],[`csv`,`sheet`],[`numbers`,`sheet`],[`ppt`,`slides`],[`pptx`,`slides`],[`key`,`slides`],[`mp3`,`audio`],[`wav`,`audio`],[`m4a`,`audio`],[`flac`,`audio`],[`ogg`,`audio`],[`mp4`,`video`],[`mov`,`video`],[`mkv`,`video`],[`webm`,`video`],[`txt`,`text`],[`md`,`text`]]);function Eu(e){let t=e.split(/[?#]/,1)[0],n=t.lastIndexOf(`.`);if(n<0)return`generic`;let r=t.slice(n+1).toLowerCase();return Tu.get(r)??`generic`}const Du=`http://www.w3.org/2000/svg`;function Ou(){let e=document.createElementNS(Du,`svg`);e.setAttribute(`class`,`md-file-view-icon`),e.setAttribute(`viewBox`,`0 0 24 24`),e.setAttribute(`aria-hidden`,`true`);for(let t of[`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,`M14 2v4a2 2 0 0 0 2 2h4`]){let n=document.createElementNS(Du,`path`);n.setAttribute(`d`,t),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),e.appendChild(n)}return e}var ku=class{#e;#t;#n;#r;#i;#a;#o=!1;constructor(e,t){this.#a=e.attrs,this.#e=document.createElement(`span`),this.#e.className=`md-file-view md-atom-view`,this.#n=document.createElement(`span`),this.#n.className=`md-file-view-preview md-atom-view-preview`,this.#n.contentEditable=`false`,this.#n.dataset.testid=`file-pill`,this.#n.dataset.fileKind=Eu(this.#a.href),this.#n.title=this.#a.name,this.#e.appendChild(this.#n),this.#n.appendChild(Ou()),this.#r=document.createElement(`span`),this.#r.className=`md-file-view-name`,this.#r.textContent=this.#a.name,this.#n.appendChild(this.#r),this.#i=document.createElement(`span`),this.#i.className=`md-file-view-size`,this.#i.dataset.testid=`file-pill-size`,this.#n.appendChild(this.#i),this.#t=document.createElement(`span`),this.#t.className=`md-file-view-content md-atom-view-content`,this.#e.appendChild(this.#t),this.#s(t.resolveFileInfo)}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs,n=this.#a;return t.href===n.href?(this.#a=t,t.name!==n.name&&(this.#r.textContent=t.name,this.#n.title=t.name),!0):!1}ignoreMutation(e){return!this.#t.contains(e.target)}destroy(){this.#o=!0}async#s(e){if(!e)return;let t;try{t=await e(this.#a.href)}catch(e){console.error(`[meowdown] resolveFileInfo failed:`,e);return}if(this.#o||!t)return;let{size:n}=t;n==null||!Number.isFinite(n)||n<0||(this.#i.textContent=wu(n))}};function Au(e={}){return d({name:`mdFile`,constructor:t=>new ku(t,e)})}function ju(e){return m(new w({key:e.key,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(e.selector);if(!i)return!1;let a=e.findPayloadForElement?e.findPayloadForElement(t,i):e.findPayloadAt(t.state,n);return a==null?!1:(e.preventDefault&&r.preventDefault(),e.onClick(a,r),!0)}}}))}const Mu=new T(`meowdown-tag-click`);function Nu(e,t){let n=j(e,t,`mdTag`);if(!n)return;let r=e.doc.textBetween(n.from,n.to),i=r.startsWith(`#`)?r.slice(1):r;return{from:n.from,to:n.to,tag:i}}function Pu(e){return ju({key:Mu,selector:`.md-tag`,preventDefault:!1,findPayloadAt:(e,t)=>Nu(e,t)?.tag,onClick:(t,n)=>e({tag:t,event:n})})}const Fu=new T(`meowdown-wikilink-click`);function Iu(e,t){let n=j(e,t,`mdWikilink`);if(!n)return;let{target:r}=n.mark.attrs;return{from:n.from,to:n.to,target:r}}function Lu(e,t){let n=t.closest(`.md-wikilink-view`)?.querySelector(`.md-wikilink-view-content`);if(n)return Iu(e.state,e.posAtDOM(n,0))}function Ru(e){return ju({key:Fu,selector:`.md-wikilink-view-preview`,preventDefault:!1,findPayloadAt:(e,t)=>Iu(e,t)?.target,findPayloadForElement:(e,t)=>Lu(e,t)?.target,onClick:(t,n)=>e({target:t,event:n})})}const zu=new T(`meowdown-follow-link`);function Bu(e){return e.key!==`Enter`||e.shiftKey||e.altKey?!1:ee?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Vu(e){return new w({key:zu,props:{handleKeyDown:(t,n)=>{if(!Bu(n))return!1;let{state:r}=t,i=r.selection.head,a=e.onWikilinkClick&&Iu(r,i);if(a)return e.onWikilinkClick?.({target:a.target,event:n}),!0;let o=e.onTagClick&&Nu(r,i);if(o)return e.onTagClick?.({tag:o.tag,event:n}),!0;let s=e.onFileClick&&fu(r,i);if(s)return e.onFileClick?.({href:s.href,name:s.name,event:n}),!0;let c=e.onLinkClick&&q(r,i);return c?(e.onLinkClick?.({href:c.href,event:n}),!0):!1}}})}function Hu(e){return x(m(Vu(e)),t.high)}const Uu=new T(`meowdown-image-click`);function Wu(e){return e instanceof HTMLElement&&e.closest(`.md-image-view-preview`)}function Gu(e,t){let n=j(e,t,`mdImage`);if(!n)return;let{src:r,alt:i}=n.mark.attrs;return{from:n.from,to:n.to,src:r,alt:i}}function Ku(e,t){let n=t.closest(`.md-image-view`)?.querySelector(`.md-image-view-content`);if(n)return Gu(e.state,e.posAtDOM(n,0))}function qu(e,t){return Array.from(e).find(e=>e.identifier===t)}function Ju(e,t){return Math.abs(t.clientX-e.clientX)<=10&&Math.abs(t.clientY-e.clientY)<=10}function Yu(e){let t=new WeakMap;return m(new w({key:Uu,props:{handleDOMEvents:{pointerdown:(e,t)=>(Wu(t.target)&&t.pointerType!==`mouse`&&t.preventDefault(),!1),touchstart:(e,n)=>{if(t.delete(e),n.touches.length!==1||!Wu(n.target)||n.target instanceof HTMLElement&&n.target.closest(`.md-image-resize-handle`))return!1;let r=n.changedTouches[0];return r&&t.set(e,{identifier:r.identifier,clientX:r.clientX,clientY:r.clientY}),!1},touchmove:(e,n)=>{let r=t.get(e);if(!r)return!1;let i=qu(n.changedTouches,r.identifier);return i&&!Ju(r,i)&&t.delete(e),!1},touchcancel:e=>(t.delete(e),!1),touchend:(n,r)=>{let i=t.get(n);if(t.delete(n),!i||r.touches.length>0)return!1;let a=qu(r.changedTouches,i.identifier);if(!a||!Ju(i,a))return!1;let o=Wu(r.target);if(!o)return!1;r.preventDefault();let s=Ku(n,o);return s&&e({src:s.src,alt:s.alt,event:r}),!0}},handleClick:(t,n,r)=>{let i=Wu(r.target);if(!i)return!1;let a=Ku(t,i);return a?(e({src:a.src,alt:a.alt,event:r}),!0):!1}}}))}function Xu(e){return/^https?:\/\//i.test(e)?e:void 0}function Zu(e){let t=document.createElement(`iframe`);return t.src=e.src,t.title=e.title,t.className=e.className,t.dataset.testid=e.testid,t.loading=`lazy`,t.referrerPolicy=`strict-origin-when-cross-origin`,t.setAttribute(`frameborder`,`0`),e.allow&&(t.allow=e.allow),e.allowFullscreen&&(t.allowFullscreen=!0),e.kind===`tweet`&&ql(t),t}function Qu(e,t,n,r){if(n!=null&&r!=null){e.setAttribute(`data-width`,String(n)),e.setAttribute(`data-height`,String(r));return}let i=t.naturalWidth/t.naturalHeight;if(!Number.isFinite(i)||i<=0){n!=null&&e.setAttribute(`data-width`,String(n)),r!=null&&e.setAttribute(`data-height`,String(r));return}let a=n==null?Math.min(t.naturalHeight,500):n/i,o=n??a*i;e.setAttribute(`data-width`,String(Math.round(o))),e.setAttribute(`data-height`,String(Math.round(a)))}function $u(e,t,n,r){let i=e.posAtDOM(t,0),a=j(e.state,i,`mdImage`);if(!a)return;let o=e.state.doc.textBetween(a.from,a.to),s=a.mark.attrs;if(s.syntax===`wikiEmbed`){let t=s.wikiTarget||Ra(o).target;if(!t)return;let i=za(t,n,r);i!==o&&e.dispatch(e.state.tr.insertText(i,a.from,a.to));return}let c=ba(o),l=a.from+c.length,u=o.slice(c.length),d=ya({..._a(u)??{},width:Math.round(n),height:Math.round(r)});d!==u&&e.dispatch(e.state.tr.insertText(d,l,a.to))}var ed=class{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n){this.#i=e.attrs,this.#n=n,this.#r=t,this.#e=document.createElement(`span`),this.#e.className=`md-image-view md-atom-view`,this.#t=document.createElement(`span`),this.#t.className=`md-image-view-content md-atom-view-content`;let r=this.#s();r&&(r.contentEditable=`false`,this.#e.appendChild(r)),this.#e.appendChild(this.#t)}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs,n=this.#i;return t.src===n.src?(this.#i=t,this.#o&&t.alt!==n.alt&&(this.#o.alt=t.alt),this.#a&&this.#o&&(t.width!==n.width||t.height!==n.height)&&Qu(this.#a,this.#o,t.width,t.height),!0):!1}ignoreMutation(e){return!this.#t.contains(e.target)}#s(){let{src:e}=this.#i,t=eu(e);if(t){let e=document.createElement(`span`);return e.className=`md-image-view-preview md-atom-view-preview`,e.appendChild(Zu(t)),e}let n=(this.#n.resolveImageUrl??Xu)(e);if(!n)return;let r=document.createElement(`span`);return r.className=`md-image-view-preview md-atom-view-preview`,r.dataset.testid=`image-preview`,r.appendChild(this.#c(n)),r}#c(e){Qt(),Zt();let t=document.createElement(`prosekit-resizable-root`);t.className=`md-image-resizable`,t.dataset.testid=`image-resizable`,t.setAttribute(`data-loading`,``);let n=document.createElement(`img`);n.src=e,n.alt=this.#i.alt,n.draggable=!1,Qu(t,n,this.#i.width,this.#i.height),n.addEventListener(`load`,()=>{t.removeAttribute(`data-loading`);let e=n.naturalWidth/n.naturalHeight;!Number.isFinite(e)||e<=0||(t.setAttribute(`data-aspect-ratio`,String(e)),Qu(t,n,this.#i.width,this.#i.height))}),n.addEventListener(`error`,()=>{t.removeAttribute(`data-loading`)}),t.appendChild(n);let r=document.createElement(`prosekit-resizable-handle`);return r.className=`md-image-resize-handle`,r.setAttribute(`position`,`bottom-right`),r.addEventListener(`click`,e=>e.stopPropagation()),t.appendChild(r),t.addEventListener(`resizeEnd`,e=>{let{width:t,height:n}=e.detail;$u(this.#r,this.#t,t,n)}),this.#a=t,this.#o=n,t}};function td(e={}){return d({name:`mdImage`,constructor:(t,n)=>new ed(t,n,e)})}const nd={"Mod-b":`Bold`,"Mod-i":`Italic`,"Mod-e":`Inline code`,"Mod-Shift-x":`Strikethrough`,"Mod-Shift-h":`Highlight`,"Mod-k":`Link`,"Mod-Shift-k":`Insert a wikilink`,"Mod-1":`Heading 1`,"Mod-2":`Heading 2`,"Mod-3":`Heading 3`,"Mod-4":`Heading 4`,"Mod-5":`Heading 5`,"Mod-6":`Heading 6`,"Mod-.":`Fold or unfold a bullet`,"Mod-Enter":`Follow the link under the caret, or cycle a checkbox task`,"Mod-Shift-Enter":`Cycle a circle checkbox task`,"Mod-Shift-7":`Ordered list`,"Mod-Shift-8":`Bullet list`,"Mod-Shift-9":`Checkbox task list`,"Alt-ArrowUp":`Move the block or list item up`,"Alt-ArrowDown":`Move the block or list item down`,"Meta-ArrowUp":`Move the caret to the document start`,"Meta-ArrowDown":`Move the caret to the document end`,"Shift-Meta-ArrowUp":`Select to the document start`,"Shift-Meta-ArrowDown":`Select to the document end`,Escape:`Collapse the selection`},rd=new T(`meowdown-link-click`);function id(e){return ju({key:rd,selector:`.md-link`,preventDefault:!0,findPayloadAt:(e,t)=>q(e,t)?.href,onClick:(t,n)=>e({href:t,event:n})})}function ad(e){let t,n=(t,n)=>e.findPayloadForElement?e.findPayloadForElement(t,n):e.findPayloadAt(t.state,t.posAtDOM(n,0)),r=()=>{t&&(t=void 0,e.onHoverChange(void 0))},i=(i,a)=>{let o=a.target;if(!o||!ye(o))return;let s=o.closest(e.selector);if(!s||!i.dom.contains(s)||s===t?.element)return;r();let c=n(i,s);c!=null&&(t={payload:c,element:s},e.onHoverChange(t))},a=e=>{if(!t)return;let n=e.relatedTarget;n instanceof Node&&t.element.contains(n)||r()};return m(new w({key:e.key,props:{handleDOMEvents:{mouseover:(e,t)=>(i(e,t),!1),mouseout:(e,t)=>(a(t),!1)}},view:()=>({update:i=>{if(!t)return;if(!t.element.isConnected||!i.dom.contains(t.element)){r();return}let a=n(i,t.element);if(a==null||!e.isSamePayload(t.payload,a)){r();return}t={...t,payload:a}},destroy:r})}))}const od=new T(`meowdown-link-hover`);function sd(e){return ad({key:od,selector:`.md-link`,findPayloadAt:(e,t)=>q(e,t),isSamePayload:(e,t)=>e.href===t.href&&e.title===t.title,onHoverChange:e})}const cd=new T(`meowdown-link-paste`);function ld(e){let t=e.trim();if(!(!t||/\s/.test(t)))return he(t)}function ud(){return x(m(new w({key:cd,props:{handlePaste:(e,t,n)=>{let r=tu(t,n);if(!r)return!1;let i=ld(r);return i?Ri(e,ss({href:i,wrapText:!1})):!1}}})),t.high)}function dd(e){return e instanceof xt||e instanceof St||e instanceof wt||e instanceof Tt||e instanceof pa}function fd(e){for(let t of e)for(let e of t.steps)if(!dd(e))return!0;return!1}function pd(e){let t,n,r=!1,i,a=()=>{let n=t&&!t.isDestroyed&&t.dom;if(!n)return;let a=e&&!r;a!==i&&(i=a,n.spellcheck=a)},o=()=>{n&&clearTimeout(n),r=!0,a(),n=setTimeout(()=>{r=!1,a()},1200)};return{pause:o,apply(e){fd(e)&&o()},view(e){return t=e,{destroy(){t=void 0}}}}}function md(e){let t=new T(`spell-check`);return new w({key:t,state:{init:()=>pd(e),apply:(e,t)=>t},view(e){return t.getState(e.state)?.view(e)||{}},props:{handleDOMEvents:{beforeinput:e=>{t.getState(e.state)?.pause()}}},appendTransaction(e,n){t.getState(n)?.apply(e)}})}function hd(e){return m(md(e))}const gd=[[/<-/,`←`],[/(?<!-)->/,`→`],[/\(c\)/,`©`],[/\(r\)/,`®`],[/1\/2/,`½`],[/\+\/-/,`±`],[/!=/,`≠`],[/<</,`«`],[/>>/,`»`],[/(?<!<!)(?<!^(?:-[ \t]*)+)--/,`—`]],_d=new T(`meowdown-substitution-undo`);function vd(e,t,n){let r=g(e.schema,`mdCode`);return e.doc.rangeHasMark(t,n,r)}function yd(e,t,n,r,i){if(vd(e,t,n))return null;let[,a]=r,o=i==null?a:`${a} `,s=e.tr.replaceWith(t,n,e.schema.text(o));return i!=null&&s.setMeta(_d,{from:t,to:t+o.length,before:i,after:o}),s}function bd(){return b(gd.map(e=>tt(new $t(new RegExp(String.raw`(?:${e[0].source})\s$`),(t,n,r,i)=>yd(t,r,i,e,n[0])))))}function xd(){return m(new w({key:_d,state:{init:()=>null,apply:(e,t)=>{let n=e.getMeta(_d);if(n!==void 0)return n;if(!t)return null;let r=e.mapping.map(t.from),i=e.mapping.map(t.to);return e.selection.empty&&e.selection.from===i&&e.doc.textBetween(r,i)===t.after?{...t,from:r,to:i}:null}}}))}function Sd(){return x(l({Backspace:(e,t)=>{let n=_d.getState(e);return n?(t?.(e.tr.replaceWith(n.from,n.to,e.schema.text(n.before)).setMeta(_d,null)),!0):!1}}),t.highest)}function Cd(){return b(xd(),Sd())}function wd(){return b(gd.map(e=>$e({regex:RegExp(`(?:${e[0].source})$`),handler:({state:t,from:n,to:r})=>yd(t,n,r,e)})))}function Td(){return b(bd(),Cd(),wd())}const Ed=new T(`meowdown-wikilink-hover`);function Dd(e){return ad({key:Ed,selector:`.md-wikilink-view-preview`,findPayloadAt:Iu,findPayloadForElement:Lu,isSamePayload:(e,t)=>e.target===t.target,onHoverChange:t=>{e(t?{...t.payload,element:t.element}:void 0)}})}function Od(e,t={}){let n=[];return e.content.forEach(e=>{let r=[];e.descendants(e=>{if(!e.isText||!e.text)return!0;let n=e.marks.map(e=>e.type.name);return n.some(e=>Fn.has(e))&&!(t.preserveMathSource&&n.includes(`mdMath`))||r.push(e.text),!1}),n.push(r.join(``))}),n.join(`
37
- `)}function kd({allowEmpty:e}){return(t,n)=>{let{selection:r}=t;if(!y(r)||!e&&r.empty||!r.$head.sameParent(r.$anchor)||r.$head.parent.type.spec.code)return!1;let i=Od(r.content());if(i.startsWith(`[[`))return!1;i.startsWith(`[`)&&(i=i.slice(1));let a=`[[`+i;if(n){let e=t.tr.insertText(a,r.from,r.to);e.setSelection(E.create(e.doc,r.from+a.length)),rt(e),n(e.scrollIntoView())}return!0}}function Ad(){return l({"Mod-Shift-k":kd({allowEmpty:!0}),"[":kd({allowEmpty:!1})})}function jd(e){switch(e.type.name){case`mdWikilink`:{let t=e.attrs;return t.display||t.target}case`mdImage`:return e.attrs.alt;case`mdFile`:return e.attrs.name;case`mdMath`:return e.attrs.formula;default:return``}}function Md(e){let t=``;for(let n of zn(e)){if(n.atom!=null){t+=jd(n.atom);continue}for(let e of n.children)Rn(e.marks)||(t+=e.text??``)}return t}function Nd(e){let{selection:t,schema:n}=e;if(t.empty)return``;let r=t.content().content;try{return Tr(n.topNodeType.create(null,r)).replace(/\n+$/,``)}catch{return e.doc.textBetween(t.from,t.to,`
33
+ `).map((e,n)=>n===0?e:pl(e,t)).join(`
34
+ `)}function hl(e,t,n){return e.paragraph(ml(t,n))}function gl(e,t,n){let r=t.from,i=t.to,a=Q(n,r);if(t.firstChild()){let o=``,s=r;do t.type.id===S.QuoteMark&&(o+=n.slice(s,t.from),s=t.to,C(n.charCodeAt(s))&&(s+=1));while(t.nextSibling());return t.parent(),o+=n.slice(s,i),hl(e,o,a)}return hl(e,n.slice(r,i),a)}function _l(e,t,n){let r=Q(n,t.from),i=ml(n.slice(t.from,t.to),r);return e.htmlComment({content:i})}function vl(e,t,n){let r=[];if(t.firstChild()){let i;do{if(t.type.id===S.QuoteMark)continue;i!=null&&ll(r,e,n,i,t.from),i=t.to,r.push(...ul(e,t,n))}while(t.nextSibling());t.parent()}return e.blockquote(r)}function yl(e,t,n,r){let i=[];if(t.firstChild()){do t.type.id===S.ListItem&&i.push(Sl(e,t,n,r));while(t.nextSibling());t.parent()}return i}function bl(e,t,n){if(n===`ordered`){let n=t.charCodeAt(e.to-1),r;n===41?r=`)`:n===46&&(r=`.`);let i=Number.parseInt(t.slice(e.from,e.to),10);return{marker:r,order:Number.isFinite(i)?i:1}}let r=t.charCodeAt(e.from);return{marker:r===42?`*`:r===43?`+`:`-`,order:void 0}}function xl(e,t,n){let r=t.from,i=t.to,a=!1,o;if(t.firstChild()){if(t.type.id===S.TaskMarker){let e=n.charCodeAt(t.from+1);e===120?(a=!0,o=`x`):e===88&&(a=!0,o=`X`),r=t.to}t.parent()}C(n.charCodeAt(r))&&(r+=1);let s=hl(e,n.slice(r,i),Q(n,r));return{checked:a,taskMarker:o,paragraph:s}}function Sl(e,t,n,r){let i=[],a,o,s,c,l,u;if(t.firstChild()){do{if(t.type.id!==S.ListMark&&u==null&&(u=Q(n,t.from)),t.type.id===S.ListMark){let e=bl(t,n,r);c=e.marker,s=e.order,l=Q(n,t.to);continue}if(r===`bullet`&&t.type.id===S.Task){let r=xl(e,t,n);a=r.checked,o=r.taskMarker,i.push(r.paragraph);continue}i.push(...ul(e,t,n))}while(t.nextSibling());t.parent()}let d=u!=null&&l!=null?u-l:1,f=a!=null,p=!f&&r===`bullet`&&c===`+`,m={kind:f?`task`:r,order:r===`ordered`?s??1:null,checked:a??!1,collapsed:p,marker:p?null:c,taskMarker:o,markerGap:d>=2&&d<=4?d:1};return e.list(m,i)}function Cl(e,t,n){let r=t.type.id===S.CodeBlock,i=``,a=``,o=r?`indented`:null,s=null,c=!1;if(t.firstChild()){do switch(t.type.id){case S.CodeMark:{if(c)break;c=!0,n.charCodeAt(t.from)===126&&(o=`tilde`);let e=t.to-t.from;e>3&&(s=e);break}case S.CodeInfo:i=n.slice(t.from,t.to);break;case S.CodeText:a+=n.slice(t.from,t.to);break}while(t.nextSibling());t.parent()}return e.codeBlock({language:i,fenceStyle:o,fenceLength:s},a)}function wl(e,t,n){let r=``;if(t.firstChild()){do t.type.id===S.CodeText&&(r+=n.slice(t.from,t.to));while(t.nextSibling());t.parent()}return e.codeBlock({language:`math`,fenceStyle:`dollar`,fenceLength:null},r)}function Tl(e,t,n){let r=[];if(t.firstChild()){do t.type.id===S.TableDelimiter&&(r=El(n.slice(t.from,t.to)));while(t.nextSibling());t.parent()}let i=[];if(t.firstChild()){do{let a=t.type.id;a===S.TableHeader?i.push(Dl(e,t,n,!0,r)):a===S.TableRow&&i.push(Dl(e,t,n,!1,r))}while(t.nextSibling());t.parent()}return e.table(i)}function El(e){return e.split(`|`).map(e=>e.trim()).filter(e=>e!==``).map(e=>{let t=e.startsWith(`:`),n=e.endsWith(`:`);return t&&n?`center`:t?`left`:n?`right`:null})}function Dl(e,t,n,r,i){let a=i.length,o=Array(a).fill(``);if(t.firstChild()){let e=t.type.id===S.TableDelimiter,r=0;do if(t.type.id===S.TableDelimiter)r++;else if(t.type.id===S.TableCell){let i=r-+!!e;i>=0&&i<a&&(o[i]=n.slice(t.from,t.to).trim().replaceAll(String.raw`\|`,`|`))}while(t.nextSibling());t.parent()}let s=o.map((t,n)=>{let a=e.paragraph(t),o={align:i[n]};return r?e.tableHeaderCell(o,a):e.tableCell(o,a)});return e.tableRow(s)}function Ol(e){return e.replace(/\n+$/u,``)}function kl(e){return/^[\s>]*$/u.test(e)}function Al(e){return e.split(`
35
+ `).filter(e=>!kl(e))}function jl(e){return e.trim().replaceAll(/\s+/gu,` `)}const Ml=/^:?-+:?$/u;function Nl(e){let t=e.startsWith(`:`),n=e.endsWith(`:`);return t&&n?`:-:`:t?`:--`:n?`--:`:`---`}function Pl(e){if(!e.includes(`|`))return;let t=/^[\s>]*/u.exec(e)?.[0]??``,n=e.slice(t.length).trim().replace(/^\|/u,``).replace(/\|$/u,``).split(`|`).map(e=>jl(e));return jl(`${t} | ${(n.every(e=>Ml.test(e))?n.map(Nl):n).join(` | `)} |`)}function Fl(e){return Pl(e)??jl(e)}function Il(e,t={}){let n=Er(X(e,{frontmatter:t.frontmatter}),{frontmatter:t.frontmatter});if(Ol(n)===Ol(e))return`exact`;let r=Al(e),i=Al(n);return r.length===i.length&&r.every((e,t)=>Fl(e)===Fl(i[t]))?`normalizing`:`lossy`}const Ll=(e,t)=>{let{$from:n,empty:r}=e.selection;if(!r||n.depth!==1||n.index(0)!==0||!F(n.parent,`heading`)||n.parentOffset!==n.parent.content.size)return!1;if(t){let r=_(e.schema,`list`),i=_(e.schema,`paragraph`),a=r.create({kind:`bullet`},i.create()),o=n.after(),s=e.tr.insert(o,a);s.setSelection(E.create(s.doc,o+2)),t(s.scrollIntoView())}return!0};function Rl(){return x(l({Enter:Ll}),t.high)}const zl=new Set([`MscGen`,`Xù`,`MsGenny`,`Angular Template`,`Brainfuck`,`Esper`,`Oz`,`Factor`,`Squirrel`,`Yacas`,`mIRC`,`FCL`,`ECL`,`MUMPS`,`Pig`,`Asterisk`,`Z80`,`Mathematica`]),Bl=et.map(e=>({label:e.name,value:e.name.toLowerCase()})).filter(e=>!zl.has(e.label)).concat([{label:`Plain text`,value:``},{label:`Math`,value:`math`},{label:`Mermaid`,value:`mermaid`}]).sort((e,t)=>e.label.localeCompare(t.label));function Vl(){return typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches}const Hl=/^(?:www\.|mobile\.)?(?:twitter\.com|x\.com)$/i,Ul=/\/status(?:es)?\/(\d+)/;function Wl(e){let t;try{t=new URL(e)}catch{return}if(Hl.test(t.hostname))return Ul.exec(t.pathname)?.[1]}const Gl=e=>{let t=Wl(e);if(!t)return;let n=Vl()?`dark`:`light`;return{kind:`tweet`,key:`tweet:${t}`,src:`https://platform.twitter.com/embed/Tweet.html?id=${t}&theme=${n}&dnt=true`,title:`Tweet`,className:`md-embed md-embed-tweet`,testid:`tweet-embed`}};function Kl(e){let t=t=>{if(t.source===e.contentWindow)try{let n=t.data?.[`twttr.embed`]?.params?.[0]?.height;typeof n==`number`&&(e.style.height=`${n}px`)}catch(e){console.warn(`[meowdown] failed to parse tweet resize message:`,e)}};window.addEventListener(`message`,t);let n=!1,r=()=>{n||(n=!0,window.removeEventListener(`message`,t),i.disconnect())},i=new MutationObserver(()=>{e.isConnected||r()});return i.observe(document.body,{childList:!0,subtree:!0}),r}const ql=/^(?:www\.|m\.)?(?:youtube\.com|youtube-nocookie\.com)$/i,Jl=/^(?:www\.)?youtu\.be$/i,Yl=/^[\w-]{11}$/;function Xl(e){let t;try{t=new URL(e)}catch{return}let n=null;if(Jl.test(t.hostname))n=t.pathname.slice(1);else if(ql.test(t.hostname)){let[,e,r]=t.pathname.split(`/`);t.pathname===`/watch`?n=t.searchParams.get(`v`):(e===`shorts`||e===`embed`||e===`live`)&&(n=r??null)}if(!n||!Yl.test(n))return;let r=t.searchParams.get(`start`)??t.searchParams.get(`t`),i=r?Zl(r):void 0;return{videoId:n,startSeconds:i}}function Zl(e){if(/^\d+$/.test(e))return Number(e);let t=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(e);if(!(!t||!t[1]&&!t[2]&&!t[3]))return Number(t[1]??0)*3600+Number(t[2]??0)*60+Number(t[3]??0)}const Ql=[e=>{let t=Xl(e);if(!t)return;let n=t.startSeconds?`?start=${t.startSeconds}`:``;return{kind:`youtube`,key:`youtube:${t.videoId}:${t.startSeconds??0}`,src:`https://www.youtube-nocookie.com/embed/${t.videoId}${n}`,title:`YouTube video`,className:`md-embed md-embed-youtube`,testid:`youtube-embed`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen`,allowFullscreen:!0}},Gl];function $l(e){for(let t of Ql){let n=t(e);if(n)return n}}function eu(e,t){return e.clipboardData?.getData(`text/plain`)||t.content.textBetween(0,t.content.size,`
36
+ `)}const tu=new T(`meowdown-embed-paste`);function nu(e){let t=e.trim();if(!(!t||/\s/.test(t)))return $l(t)?t:void 0}function ru(e,t){let{from:n,to:r}=e.state.selection;e.dispatch(Xt(e.state.tr.insertText(t,n,r)));let i=e.state.tr.insertText(`![](${t})`,n,n+t.length);e.dispatch(Xt(i))}function iu(){return m(new w({key:tu,props:{handlePaste:(e,t,n)=>{let r=e.state.selection.$from.parent;if(!r.inlineContent||r.type.spec.code)return!1;let i=eu(t,n);if(!i)return!1;let a=nu(i);return a?(ru(e,a),!0):!1}}}))}const au=new T(`meowdown-exit-boundary`);function ou(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):void 0:i;return!!(a&&Fe.findFrom(a,t))}function su(e,t){let{state:n}=e,{selection:r}=n;return y(r)&&!r.empty||v(r)||r.$from.parent.inlineContent&&!e.endOfTextblock(t<0?`up`:`down`)?!0:ou(n,t)}function cu(e){return new w({key:au,props:{handleKeyDown:(t,n)=>{if(n.shiftKey||n.altKey||n.ctrlKey||n.metaKey)return!1;let r=n.key===`ArrowUp`?-1:n.key===`ArrowDown`?1:void 0;return!(!r||su(t,r)||e({direction:r<0?`up`:`down`,event:n})===!1)}}})}function lu(e){return x(m(cu(e)),t.low)}const uu=new T(`meowdown-file-click`);function du(e,t){let n=A(e,t,`mdFile`);if(!n)return;let{href:r,name:i}=n.mark.attrs;return{href:r,name:i}}function fu(e){return m(new w({key:uu,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(`.md-file-view-preview`);if(!i)return!1;let a=i.closest(`.md-file-view`)?.querySelector(`.md-file-view-content`);if(!a)return!1;let o=du(t.state,t.posAtDOM(a,0));return o?(e({href:o.href,name:o.name,event:r}),!0):!1}}}))}const pu=new Set([`avif`,`bmp`,`gif`,`jpeg`,`jpg`,`png`,`svg`,`webp`]);function mu(e){if(e.type?.startsWith(`image/`))return!0;let t=e.name.lastIndexOf(`.`);if(t===-1)return!1;let n=e.name.slice(t+1).toLowerCase();return pu.has(n)}function hu(e,t){return mu(e)?`![](${t})`:`[${vu(e.name)}](${t})`}function gu(e,t){return!e||!t.onFilePaste?[]:Array.from(e.files)}const _u=e=>{console.error(`[meowdown] failed to save pasted file:`,e)};function vu(e){return e.replaceAll(/[\\[\]]/g,String.raw`\$&`)}async function yu(e,t,n,r){let{onFilePaste:i}=n;if(!i)return;let a=n.onFileSaveError??_u,o=r,s=!1;for(let n of t){let t;try{t=await i(n)}catch(e){a(e,n);continue}if(!t||e.isDestroyed)continue;let r=hu(n,t),c=s?`\n${r}`:r,l=o==null?e.state.tr.insertText(c):e.state.tr.insertText(c,o);e.dispatch(l),s=!0,o!=null&&(o+=c.length)}}function bu(e){return new w({key:new T(`file-paste`),props:{handlePaste:(t,n)=>{let r=gu(n.clipboardData,e);return r.length===0?!1:(yu(t,r,e),!0)},handleDrop:(t,n)=>{let r=gu(n.dataTransfer,e);return r.length===0?!1:(yu(t,r,e,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos),!0)}}})}function xu(e={}){return x(m(bu(e)),t.high)}const Su=[`KB`,`MB`,`GB`,`TB`];function Cu(e){let t=e,n=`B`;for(let e of Su){if(t<999.5)break;t/=1e3,n=e}return n===`B`?`${Math.round(t)} B`:`${t<9.95?Math.round(t*10)/10:Math.round(t)} ${n}`}const wu=new Map([[`pdf`,`pdf`],[`zip`,`archive`],[`tar`,`archive`],[`gz`,`archive`],[`tgz`,`archive`],[`rar`,`archive`],[`7z`,`archive`],[`doc`,`doc`],[`docx`,`doc`],[`pages`,`doc`],[`xls`,`sheet`],[`xlsx`,`sheet`],[`csv`,`sheet`],[`numbers`,`sheet`],[`ppt`,`slides`],[`pptx`,`slides`],[`key`,`slides`],[`mp3`,`audio`],[`wav`,`audio`],[`m4a`,`audio`],[`flac`,`audio`],[`ogg`,`audio`],[`mp4`,`video`],[`mov`,`video`],[`mkv`,`video`],[`webm`,`video`],[`txt`,`text`],[`md`,`text`]]);function Tu(e){let t=e.split(/[?#]/,1)[0],n=t.lastIndexOf(`.`);if(n<0)return`generic`;let r=t.slice(n+1).toLowerCase();return wu.get(r)??`generic`}const Eu=`http://www.w3.org/2000/svg`;function Du(){let e=document.createElementNS(Eu,`svg`);e.setAttribute(`class`,`md-file-view-icon`),e.setAttribute(`viewBox`,`0 0 24 24`),e.setAttribute(`aria-hidden`,`true`);for(let t of[`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,`M14 2v4a2 2 0 0 0 2 2h4`]){let n=document.createElementNS(Eu,`path`);n.setAttribute(`d`,t),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),e.appendChild(n)}return e}var Ou=class{#e;#t;#n;#r;#i;#a;#o=!1;constructor(e,t){this.#a=e.attrs,this.#e=document.createElement(`span`),this.#e.className=`md-file-view md-atom-view`,this.#n=document.createElement(`span`),this.#n.className=`md-file-view-preview md-atom-view-preview`,this.#n.contentEditable=`false`,this.#n.dataset.testid=`file-pill`,this.#n.dataset.fileKind=Tu(this.#a.href),this.#n.title=this.#a.name,this.#e.appendChild(this.#n),this.#n.appendChild(Du()),this.#r=document.createElement(`span`),this.#r.className=`md-file-view-name`,this.#r.textContent=this.#a.name,this.#n.appendChild(this.#r),this.#i=document.createElement(`span`),this.#i.className=`md-file-view-size`,this.#i.dataset.testid=`file-pill-size`,this.#n.appendChild(this.#i),this.#t=document.createElement(`span`),this.#t.className=`md-file-view-content md-atom-view-content`,this.#e.appendChild(this.#t),this.#s(t.resolveFileInfo)}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs,n=this.#a;return t.href===n.href?(this.#a=t,t.name!==n.name&&(this.#r.textContent=t.name,this.#n.title=t.name),!0):!1}ignoreMutation(e){return!this.#t.contains(e.target)}destroy(){this.#o=!0}async#s(e){if(!e)return;let t;try{t=await e(this.#a.href)}catch(e){console.error(`[meowdown] resolveFileInfo failed:`,e);return}if(this.#o||!t)return;let{size:n}=t;n==null||!Number.isFinite(n)||n<0||(this.#i.textContent=Cu(n))}};function ku(e={}){return d({name:`mdFile`,constructor:t=>new Ou(t,e)})}function Au(e){return m(new w({key:e.key,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(e.selector);if(!i)return!1;let a=e.findPayloadForElement?e.findPayloadForElement(t,i):e.findPayloadAt(t.state,n);return a==null?!1:(e.preventDefault&&r.preventDefault(),e.onClick(a,r),!0)}}}))}const ju=new T(`meowdown-tag-click`);function Mu(e,t){let n=A(e,t,`mdTag`);if(!n)return;let r=e.doc.textBetween(n.from,n.to),i=r.startsWith(`#`)?r.slice(1):r;return{from:n.from,to:n.to,tag:i}}function Nu(e){return Au({key:ju,selector:`.md-tag`,preventDefault:!1,findPayloadAt:(e,t)=>Mu(e,t)?.tag,onClick:(t,n)=>e({tag:t,event:n})})}const Pu=new T(`meowdown-wikilink-click`);function Fu(e,t){let n=A(e,t,`mdWikilink`);if(!n)return;let{target:r}=n.mark.attrs;return{from:n.from,to:n.to,target:r}}function Iu(e,t){let n=t.closest(`.md-wikilink-view`)?.querySelector(`.md-wikilink-view-content`);if(n)return Fu(e.state,e.posAtDOM(n,0))}function Lu(e){return Au({key:Pu,selector:`.md-wikilink-view-preview`,preventDefault:!1,findPayloadAt:(e,t)=>Fu(e,t)?.target,findPayloadForElement:(e,t)=>Iu(e,t)?.target,onClick:(t,n)=>e({target:t,event:n})})}const Ru=new T(`meowdown-follow-link`);function zu(e){return e.key!==`Enter`||e.shiftKey||e.altKey?!1:ee?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Bu(e){return new w({key:Ru,props:{handleKeyDown:(t,n)=>{if(!zu(n))return!1;let{state:r}=t,i=r.selection.head,a=e.onWikilinkClick&&Fu(r,i);if(a)return e.onWikilinkClick?.({target:a.target,event:n}),!0;let o=e.onTagClick&&Mu(r,i);if(o)return e.onTagClick?.({tag:o.tag,event:n}),!0;let s=e.onFileClick&&du(r,i);if(s)return e.onFileClick?.({href:s.href,name:s.name,event:n}),!0;let c=e.onLinkClick&&K(r,i);return c?(e.onLinkClick?.({href:c.href,event:n}),!0):!1}}})}function Vu(e){return x(m(Bu(e)),t.high)}const Hu=new T(`meowdown-image-click`);function Uu(e){return e instanceof HTMLElement&&e.closest(`.md-image-view-preview`)}function Wu(e,t){let n=A(e,t,`mdImage`);if(!n)return;let{src:r,alt:i}=n.mark.attrs;return{from:n.from,to:n.to,src:r,alt:i}}function Gu(e,t){let n=t.closest(`.md-image-view`)?.querySelector(`.md-image-view-content`);if(n)return Wu(e.state,e.posAtDOM(n,0))}function Ku(e,t){return Array.from(e).find(e=>e.identifier===t)}function qu(e,t){return Math.abs(t.clientX-e.clientX)<=10&&Math.abs(t.clientY-e.clientY)<=10}function Ju(e){let t=new WeakMap;return m(new w({key:Hu,props:{handleDOMEvents:{pointerdown:(e,t)=>(Uu(t.target)&&t.pointerType!==`mouse`&&t.preventDefault(),!1),touchstart:(e,n)=>{if(t.delete(e),n.touches.length!==1||!Uu(n.target)||n.target instanceof HTMLElement&&n.target.closest(`.md-image-resize-handle`))return!1;let r=n.changedTouches[0];return r&&t.set(e,{identifier:r.identifier,clientX:r.clientX,clientY:r.clientY}),!1},touchmove:(e,n)=>{let r=t.get(e);if(!r)return!1;let i=Ku(n.changedTouches,r.identifier);return i&&!qu(r,i)&&t.delete(e),!1},touchcancel:e=>(t.delete(e),!1),touchend:(n,r)=>{let i=t.get(n);if(t.delete(n),!i||r.touches.length>0)return!1;let a=Ku(r.changedTouches,i.identifier);if(!a||!qu(i,a))return!1;let o=Uu(r.target);if(!o)return!1;r.preventDefault();let s=Gu(n,o);return s&&e({src:s.src,alt:s.alt,event:r}),!0}},handleClick:(t,n,r)=>{let i=Uu(r.target);if(!i)return!1;let a=Gu(t,i);return a?(e({src:a.src,alt:a.alt,event:r}),!0):!1}}}))}function Yu(e){return/^https?:\/\//i.test(e)?e:void 0}function Xu(e){let t=document.createElement(`iframe`);return t.src=e.src,t.title=e.title,t.className=e.className,t.dataset.testid=e.testid,t.loading=`lazy`,t.referrerPolicy=`strict-origin-when-cross-origin`,t.setAttribute(`frameborder`,`0`),e.allow&&(t.allow=e.allow),e.allowFullscreen&&(t.allowFullscreen=!0),e.kind===`tweet`&&Kl(t),t}function Zu(e,t,n,r){if(n!=null&&r!=null){e.setAttribute(`data-width`,String(n)),e.setAttribute(`data-height`,String(r));return}let i=t.naturalWidth/t.naturalHeight;if(!Number.isFinite(i)||i<=0){n!=null&&e.setAttribute(`data-width`,String(n)),r!=null&&e.setAttribute(`data-height`,String(r));return}let a=n==null?Math.min(t.naturalHeight,500):n/i,o=n??a*i;e.setAttribute(`data-width`,String(Math.round(o))),e.setAttribute(`data-height`,String(Math.round(a)))}function Qu(e,t,n,r){let i=e.posAtDOM(t,0),a=A(e.state,i,`mdImage`);if(!a)return;let o=e.state.doc.textBetween(a.from,a.to),s=a.mark.attrs;if(s.syntax===`wikiEmbed`){let t=s.wikiTarget||La(o).target;if(!t)return;let i=Ra(t,n,r);i!==o&&e.dispatch(e.state.tr.insertText(i,a.from,a.to));return}let c=ba(o),l=a.from+c.length,u=o.slice(c.length),d=ya({..._a(u)??{},width:Math.round(n),height:Math.round(r)});d!==u&&e.dispatch(e.state.tr.insertText(d,l,a.to))}var $u=class{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n){this.#i=e.attrs,this.#n=n,this.#r=t,this.#e=document.createElement(`span`),this.#e.className=`md-image-view md-atom-view`,this.#t=document.createElement(`span`),this.#t.className=`md-image-view-content md-atom-view-content`;let r=this.#s();r&&(r.contentEditable=`false`,this.#e.appendChild(r)),this.#e.appendChild(this.#t)}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs,n=this.#i;return t.src===n.src?(this.#i=t,this.#o&&t.alt!==n.alt&&(this.#o.alt=t.alt),this.#a&&this.#o&&(t.width!==n.width||t.height!==n.height)&&Zu(this.#a,this.#o,t.width,t.height),!0):!1}ignoreMutation(e){return!this.#t.contains(e.target)}#s(){let{src:e}=this.#i,t=$l(e);if(t){let e=document.createElement(`span`);return e.className=`md-image-view-preview md-atom-view-preview`,e.appendChild(Xu(t)),e}let n=(this.#n.resolveImageUrl??Yu)(e);if(!n)return;let r=document.createElement(`span`);return r.className=`md-image-view-preview md-atom-view-preview`,r.dataset.testid=`image-preview`,r.appendChild(this.#c(n)),r}#c(e){Qt(),Zt();let t=document.createElement(`prosekit-resizable-root`);t.className=`md-image-resizable`,t.dataset.testid=`image-resizable`,t.setAttribute(`data-loading`,``);let n=document.createElement(`img`);n.src=e,n.alt=this.#i.alt,n.draggable=!1,Zu(t,n,this.#i.width,this.#i.height),n.addEventListener(`load`,()=>{t.removeAttribute(`data-loading`);let e=n.naturalWidth/n.naturalHeight;!Number.isFinite(e)||e<=0||(t.setAttribute(`data-aspect-ratio`,String(e)),Zu(t,n,this.#i.width,this.#i.height))}),n.addEventListener(`error`,()=>{t.removeAttribute(`data-loading`)}),t.appendChild(n);let r=document.createElement(`prosekit-resizable-handle`);return r.className=`md-image-resize-handle`,r.setAttribute(`position`,`bottom-right`),r.addEventListener(`click`,e=>e.stopPropagation()),t.appendChild(r),t.addEventListener(`resizeEnd`,e=>{let{width:t,height:n}=e.detail;Qu(this.#r,this.#t,t,n)}),this.#a=t,this.#o=n,t}};function ed(e={}){return d({name:`mdImage`,constructor:(t,n)=>new $u(t,n,e)})}const td={"Mod-b":`Bold`,"Mod-i":`Italic`,"Mod-e":`Inline code`,"Mod-Shift-x":`Strikethrough`,"Mod-Shift-h":`Highlight`,"Mod-k":`Link`,"Mod-Shift-k":`Insert a wikilink`,"Mod-1":`Heading 1`,"Mod-2":`Heading 2`,"Mod-3":`Heading 3`,"Mod-4":`Heading 4`,"Mod-5":`Heading 5`,"Mod-6":`Heading 6`,"Mod-.":`Fold or unfold a bullet`,"Mod-Enter":`Follow the link under the caret, or cycle a checkbox task`,"Mod-Shift-Enter":`Cycle a circle checkbox task`,"Mod-Shift-7":`Ordered list`,"Mod-Shift-8":`Bullet list`,"Mod-Shift-9":`Checkbox task list`,"Alt-ArrowUp":`Move the block or list item up`,"Alt-ArrowDown":`Move the block or list item down`,"Meta-ArrowUp":`Move the caret to the document start`,"Meta-ArrowDown":`Move the caret to the document end`,"Shift-Meta-ArrowUp":`Select to the document start`,"Shift-Meta-ArrowDown":`Select to the document end`,Escape:`Collapse the selection`},nd=new T(`meowdown-link-click`);function rd(e){return Au({key:nd,selector:`.md-link`,preventDefault:!0,findPayloadAt:(e,t)=>K(e,t)?.href,onClick:(t,n)=>e({href:t,event:n})})}function id(e){let t,n=(t,n)=>e.findPayloadForElement?e.findPayloadForElement(t,n):e.findPayloadAt(t.state,t.posAtDOM(n,0)),r=()=>{t&&(t=void 0,e.onHoverChange(void 0))},i=(i,a)=>{let o=a.target;if(!o||!we(o))return;let s=o.closest(e.selector);if(!s||!i.dom.contains(s)||s===t?.element)return;r();let c=n(i,s);c!=null&&(t={payload:c,element:s},e.onHoverChange(t))},a=e=>{if(!t)return;let n=e.relatedTarget;n instanceof Node&&t.element.contains(n)||r()};return m(new w({key:e.key,props:{handleDOMEvents:{mouseover:(e,t)=>(i(e,t),!1),mouseout:(e,t)=>(a(t),!1)}},view:()=>({update:i=>{if(!t)return;if(!t.element.isConnected||!i.dom.contains(t.element)){r();return}let a=n(i,t.element);if(a==null||!e.isSamePayload(t.payload,a)){r();return}t={...t,payload:a}},destroy:r})}))}const ad=new T(`meowdown-link-hover`);function od(e){return id({key:ad,selector:`.md-link`,findPayloadAt:(e,t)=>K(e,t),isSamePayload:(e,t)=>e.href===t.href&&e.title===t.title,onHoverChange:e})}const sd=new T(`meowdown-link-paste`);function cd(e){let t=e.trim();if(!(!t||/\s/.test(t)))return be(t)}function ld(){return x(m(new w({key:sd,props:{handlePaste:(e,t,n)=>{let r=eu(t,n);if(!r)return!1;let i=cd(r);return i?Ri(e,os({href:i,wrapText:!1})):!1}}})),t.high)}function ud(e){return e instanceof bt||e instanceof xt||e instanceof Ct||e instanceof wt||e instanceof pa}function dd(e){for(let t of e)for(let e of t.steps)if(!ud(e))return!0;return!1}function fd(e){let t,n,r=!1,i,a=()=>{let n=t&&!t.isDestroyed&&t.dom;if(!n)return;let a=e&&!r;a!==i&&(i=a,n.spellcheck=a)},o=()=>{n&&clearTimeout(n),r=!0,a(),n=setTimeout(()=>{r=!1,a()},1200)};return{pause:o,apply(e){dd(e)&&o()},view(e){return t=e,{destroy(){t=void 0}}}}}function pd(e){let t=new T(`spell-check`);return new w({key:t,state:{init:()=>fd(e),apply:(e,t)=>t},view(e){return t.getState(e.state)?.view(e)||{}},props:{handleDOMEvents:{beforeinput:e=>{t.getState(e.state)?.pause()}}},appendTransaction(e,n){t.getState(n)?.apply(e)}})}function md(e){return m(pd(e))}const hd=[[/<-/,`←`],[/(?<!-)->/,`→`],[/\(c\)/,`©`],[/\(r\)/,`®`],[/1\/2/,`½`],[/\+\/-/,`±`],[/!=/,`≠`],[/<</,`«`],[/>>/,`»`],[/(?<!<!)(?<!^(?:-[ \t]*)+)--/,`—`]],$=new T(`meowdown-substitution-undo`);function gd(e,t,n){let r=g(e.schema,`mdCode`);return e.doc.rangeHasMark(t,n,r)}function _d(e,t,n,r,i){if(gd(e,t,n))return null;let[,a]=r,o=i==null?a:`${a} `,s=e.tr.replaceWith(t,n,e.schema.text(o));return i!=null&&s.setMeta($,{from:t,to:t+o.length,before:i,after:o}),s}function vd(){return b(hd.map(e=>ot(new $t(new RegExp(String.raw`(?:${e[0].source})\s$`),(t,n,r,i)=>_d(t,r,i,e,n[0])))))}function yd(){return m(new w({key:$,state:{init:()=>null,apply:(e,t)=>{let n=e.getMeta($);if(n!==void 0)return n;if(!t)return null;let r=e.mapping.map(t.from),i=e.mapping.map(t.to);return e.selection.empty&&e.selection.from===i&&e.doc.textBetween(r,i)===t.after?{...t,from:r,to:i}:null}}}))}function bd(){return x(l({Backspace:(e,t)=>{let n=$.getState(e);return n?(t?.(e.tr.replaceWith(n.from,n.to,e.schema.text(n.before)).setMeta($,null)),!0):!1}}),t.highest)}function xd(){return b(yd(),bd())}function Sd(){return b(hd.map(e=>it({regex:RegExp(`(?:${e[0].source})$`),handler:({state:t,from:n,to:r})=>_d(t,n,r,e)})))}function Cd(){return b(vd(),xd(),Sd())}const wd=new T(`meowdown-wikilink-hover`);function Td(e){return id({key:wd,selector:`.md-wikilink-view-preview`,findPayloadAt:Fu,findPayloadForElement:Iu,isSamePayload:(e,t)=>e.target===t.target,onHoverChange:t=>{e(t?{...t.payload,element:t.element}:void 0)}})}function Ed(e,t={}){let n=[];return e.content.forEach(e=>{let r=[];e.descendants(e=>{if(!e.isText||!e.text)return!0;let n=e.marks.map(e=>e.type.name);return n.some(e=>In.has(e))&&!(t.preserveMathSource&&n.includes(`mdMath`))||r.push(e.text),!1}),n.push(r.join(``))}),n.join(`
37
+ `)}function Dd({allowEmpty:e}){return(t,n)=>{let{selection:r}=t;if(!y(r)||!e&&r.empty||!r.$head.sameParent(r.$anchor)||r.$head.parent.type.spec.code)return!1;let i=Ed(r.content());if(i.startsWith(`[[`))return!1;i.startsWith(`[`)&&(i=i.slice(1));let a=`[[`+i;if(n){let e=t.tr.insertText(a,r.from,r.to);e.setSelection(E.create(e.doc,r.from+a.length)),ct(e),n(e.scrollIntoView())}return!0}}function Od(){return l({"Mod-Shift-k":Dd({allowEmpty:!0}),"[":Dd({allowEmpty:!1})})}function kd(e){switch(e.type.name){case`mdWikilink`:{let t=e.attrs;return t.display||t.target}case`mdImage`:return e.attrs.alt;case`mdFile`:return e.attrs.name;case`mdMath`:return e.attrs.formula;default:return``}}function Ad(e){let t=``;for(let n of Bn(e)){if(n.atom!=null){t+=kd(n.atom);continue}for(let e of n.children)zn(e.marks)||(t+=e.text??``)}return t}function jd(e){let{selection:t,schema:n}=e;if(t.empty)return``;let r=t.content().content;try{return Er(n.topNodeType.create(null,r)).replace(/\n+$/,``)}catch{return e.doc.textBetween(t.from,t.to,`
38
38
 
39
- `)}}function Pd(e,t,n){if(n===1){let r=H(e.state,t);return r&&Y(e,r.to,n)}else{let n=V(e.state,t);return n&&Y(e,n.from,-1)}}function Fd(e,t){let n=new DOMRect(0,0,0,0),r=()=>{if(e.isDestroyed)return n;let r=Y(e,t.from,1)??Ac(e,t.from,1)??Pd(e,t.from,1)??Y(e,t.from,-1);if(r==null)return n;let i=Y(e,t.to,-1)??Ac(e,t.to,-1)??Pd(e,t.to,-1)??Y(e,t.to,1);if(i==null)return n;let a=Math.min(r.left,i.left),o=Math.max(r.right,i.right),s=Math.min(r.top,i.top),c=Math.max(r.bottom,i.bottom);return n=new DOMRect(a,s,o-a,c-s),n};return{getBoundingClientRect:r,getClientRects:()=>[r()]}}export{nd as EDITOR_KEY_BINDINGS,e as Priority,gu as buildFileMarkdown,Ll as checkRoundTrip,Vl as codeBlockLanguages,Ma as collectReferenceDefinitions,Xu as defaultResolveImageUrl,zl as defineBulletAfterHeading,ue as defineCodeBlockPreviewPlugin,oi as defineCodeBlockSyntaxHighlight,$c as defineEditorExtension,au as defineEmbedPaste,uu as defineExitBoundaryHandler,pu as defineFileClickHandler,Su as defineFilePaste,Au as defineFileView,Hu as defineFollowLinkHandler,sa as defineHTMLComment,td as defineImage,Yu as defineImageClickHandler,id as defineLinkClickHandler,us as defineLinkCommands,fs as defineLinkEditKeymap,sd as defineLinkHoverHandler,ud as defineLinkPaste,Us as defineMath,Tc as definePendingReplacementHandler,fe as definePlaceholder,pe as defineReadonly,Ii as defineSearchStatusHandler,hd as defineSpellCheckPlugin,Td as defineSubstitution,Pu as defineTagClickHandler,Hc as defineViewAttributes,Ru as defineWikilinkClickHandler,Dd as defineWikilinkHoverHandler,Ad as defineWikilinkTrigger,Tr as docToMarkdown,wu as formatFileSize,za as formatSizedWikiEmbed,ci as getCodeTokens,Eu as getFileKind,q as getLinkUnitAt,nl as getMarkBuilders,hc as getPendingReplacement,Ni as getSearchStatus,Nd as getSelectedText,nc as getTableColumnAlign,Md as getTextblockDisplayText,Fd as getVirtualElementFromRange,Ga as inlineTextToMarkChunks,Ka as inlineTextToMarkChunksWithContext,ss as insertLink,de as isCodeBlockPreviewHiddenDecoration,Pn as isMarkOfType,L as isNodeOfType,ac as isSelectionInTableCell,ql as listenForTweetHeight,Bs as loadKaTeX,Z as markdownToDoc,eu as matchEmbed,Ra as parseWikiEmbed,ls as removeLink,Vs as renderMathInto,cs as updateLink,Ba as wikiEmbedBasename,oe as withPriority};
39
+ `)}}function Md(e,t,n){if(n===1){let r=B(e.state,t);return r&&J(e,r.to,n)}else{let n=z(e.state,t);return n&&J(e,n.from,-1)}}function Nd(e,t){let n=new DOMRect(0,0,0,0),r=()=>{if(e.isDestroyed)return n;let r=J(e,t.from,1)??kc(e,t.from,1)??Md(e,t.from,1)??J(e,t.from,-1);if(r==null)return n;let i=J(e,t.to,-1)??kc(e,t.to,-1)??Md(e,t.to,-1)??J(e,t.to,1);if(i==null)return n;let a=Math.min(r.left,i.left),o=Math.max(r.right,i.right),s=Math.min(r.top,i.top),c=Math.max(r.bottom,i.bottom);return n=new DOMRect(a,s,o-a,c-s),n};return{getBoundingClientRect:r,getClientRects:()=>[r()]}}export{td as EDITOR_KEY_BINDINGS,e as Priority,hu as buildFileMarkdown,Il as checkRoundTrip,Bl as codeBlockLanguages,ja as collectReferenceDefinitions,Yu as defaultResolveImageUrl,Rl as defineBulletAfterHeading,ue as defineCodeBlockPreviewPlugin,si as defineCodeBlockSyntaxHighlight,Qc as defineEditorExtension,iu as defineEmbedPaste,lu as defineExitBoundaryHandler,fu as defineFileClickHandler,xu as defineFilePaste,ku as defineFileView,Vu as defineFollowLinkHandler,sa as defineHTMLComment,ed as defineImage,Ju as defineImageClickHandler,rd as defineLinkClickHandler,ls as defineLinkCommands,ds as defineLinkEditKeymap,od as defineLinkHoverHandler,ld as defineLinkPaste,Hs as defineMath,wc as definePendingReplacementHandler,fe as definePlaceholder,pe as defineReadonly,ge as defineSearchStatusHandler,md as defineSpellCheckPlugin,Cd as defineSubstitution,Nu as defineTagClickHandler,Vc as defineViewAttributes,Lu as defineWikilinkClickHandler,Td as defineWikilinkHoverHandler,Od as defineWikilinkTrigger,Er as docToMarkdown,Cu as formatFileSize,Ra as formatSizedWikiEmbed,li as getCodeTokens,Tu as getFileKind,Li as getIsComposing,K as getLinkUnitAt,tl as getMarkBuilders,mc as getPendingReplacement,_e as getSearchStatus,jd as getSelectedText,tc as getTableColumnAlign,Ad as getTextblockDisplayText,Nd as getVirtualElementFromRange,Wa as inlineTextToMarkChunks,Ga as inlineTextToMarkChunksWithContext,os as insertLink,de as isCodeBlockPreviewHiddenDecoration,Fn as isMarkOfType,F as isNodeOfType,ic as isSelectionInTableCell,Kl as listenForTweetHeight,zs as loadKaTeX,X as markdownToDoc,$l as matchEmbed,La as parseWikiEmbed,cs as removeLink,Bs as renderMathInto,ss as updateLink,za as wikiEmbedBasename,oe as withPriority};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meowdown/core",
3
3
  "type": "module",
4
- "version": "0.59.0",
4
+ "version": "0.60.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -27,9 +27,9 @@
27
27
  "@lezer/highlight": "^1.2.3",
28
28
  "@ocavue/utils": "^1.7.0",
29
29
  "@prosekit/core": "^0.13.0-beta.7",
30
- "@prosekit/extensions": "^0.18.0-beta.18",
30
+ "@prosekit/extensions": "^0.18.0-beta.19",
31
31
  "@prosekit/pm": "^0.1.19-beta.4",
32
- "@prosekit/web": "^0.9.0-beta.23",
32
+ "@prosekit/web": "^0.9.0-beta.24",
33
33
  "hast-util-to-mdast": "^10.1.2",
34
34
  "katex": "^0.18.1",
35
35
  "mdast-util-to-markdown": "^2.1.2",
@@ -37,24 +37,23 @@
37
37
  "micromark-util-normalize-identifier": "^2.0.1",
38
38
  "prosemirror-flat-list": "^0.7.1",
39
39
  "prosemirror-highlight": "^0.15.3",
40
- "prosemirror-search": "^1.1.1",
41
40
  "rehype-parse": "^9.0.1",
42
41
  "rehype-remark": "^10.0.1",
43
42
  "remark-gfm": "^4.0.1",
44
43
  "remark-stringify": "^11.0.0",
45
44
  "unicode-by-name": "^0.2.0",
46
45
  "unified": "^11.0.5",
47
- "@meowdown/markdown": "^0.59.0"
46
+ "@meowdown/markdown": "^0.60.0"
48
47
  },
49
48
  "devDependencies": {
50
49
  "@ocavue/tsconfig": "^0.7.1",
51
- "@tsdown/css": "^0.22.8",
50
+ "@tsdown/css": "^0.22.14",
52
51
  "@types/hast": "^3.0.5",
53
52
  "@types/mdast": "^4.0.4",
54
53
  "@vitest/browser-playwright": "^4.1.10",
55
54
  "dedent": "^1.7.2",
56
55
  "diffable-html-snapshot": "^0.3.0",
57
- "tsdown": "^0.22.8",
56
+ "tsdown": "^0.22.14",
58
57
  "vitest": "^4.1.10",
59
58
  "@meowdown/vitest": "0.0.0"
60
59
  },