@meowdown/core 0.37.1 → 0.39.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/dist/index.d.ts +42 -4
- package/dist/index.js +18 -18
- package/dist/style.css +6 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { Command, EditorState } from "@prosekit/pm/state";
|
|
|
6
6
|
import { EditorView } from "@prosekit/pm/view";
|
|
7
7
|
import { Mark, ProseMirrorNode } from "@prosekit/pm/model";
|
|
8
8
|
import { HorizontalRuleExtension } from "@prosekit/extensions/horizontal-rule";
|
|
9
|
+
import { ListAttrs } from "@prosekit/extensions/list";
|
|
9
10
|
import { render } from "katex";
|
|
10
11
|
import { VirtualElement } from "@floating-ui/dom";
|
|
11
12
|
|
|
@@ -56,6 +57,11 @@ type ListMarker = '.' | ')' | '-' | '*' | '+' | null;
|
|
|
56
57
|
* serializer emits as the canonical lowercase `x`.
|
|
57
58
|
*/
|
|
58
59
|
type TaskMarker = 'x' | 'X' | null;
|
|
60
|
+
interface MeowdownListAttrs extends ListAttrs {
|
|
61
|
+
marker?: ListMarker;
|
|
62
|
+
taskMarker?: TaskMarker;
|
|
63
|
+
markerGap?: number;
|
|
64
|
+
}
|
|
59
65
|
//#endregion
|
|
60
66
|
//#region src/extensions/table-column-align.d.ts
|
|
61
67
|
/**
|
|
@@ -268,14 +274,26 @@ interface LinkAttrs {
|
|
|
268
274
|
href?: string;
|
|
269
275
|
title?: string;
|
|
270
276
|
}
|
|
271
|
-
declare function insertLink(
|
|
277
|
+
declare function insertLink({
|
|
278
|
+
href,
|
|
279
|
+
title,
|
|
280
|
+
wrapText
|
|
281
|
+
}?: {
|
|
282
|
+
href?: string;
|
|
283
|
+
title?: string;
|
|
284
|
+
wrapText?: boolean;
|
|
285
|
+
}): Command;
|
|
272
286
|
/** Rewrite the `( ... )` of the link at the caret/selection. */
|
|
273
287
|
declare function updateLink(attrs: LinkAttrs): Command;
|
|
274
288
|
/** Unwrap the link at the caret: keep the label text, drop the syntax. */
|
|
275
289
|
declare function removeLink(): Command;
|
|
276
290
|
declare function defineLinkCommands(): import("@prosekit/core").Extension<{
|
|
277
291
|
Commands: {
|
|
278
|
-
insertLink: [
|
|
292
|
+
insertLink: [({
|
|
293
|
+
href?: string;
|
|
294
|
+
title?: string;
|
|
295
|
+
wrapText?: boolean;
|
|
296
|
+
} | undefined)?];
|
|
279
297
|
updateLink: [attrs: LinkAttrs];
|
|
280
298
|
removeLink: [];
|
|
281
299
|
};
|
|
@@ -539,7 +557,11 @@ declare function defineEditorExtensionImpl(options: EditorExtensionOptions): imp
|
|
|
539
557
|
};
|
|
540
558
|
}>, import("@prosekit/core").PlainExtension]>, import("@prosekit/core").Extension<{
|
|
541
559
|
Commands: {
|
|
542
|
-
insertLink: [
|
|
560
|
+
insertLink: [({
|
|
561
|
+
href?: string;
|
|
562
|
+
title?: string;
|
|
563
|
+
wrapText?: boolean;
|
|
564
|
+
} | undefined)?];
|
|
543
565
|
updateLink: [attrs: LinkAttrs];
|
|
544
566
|
removeLink: [];
|
|
545
567
|
};
|
|
@@ -968,6 +990,22 @@ interface MarkHoverHit<Payload> {
|
|
|
968
990
|
type LinkHoverHandler = (hit: MarkHoverHit<LinkUnit> | undefined) => void;
|
|
969
991
|
declare function defineLinkHoverHandler(onHoverChange: LinkHoverHandler): PlainExtension;
|
|
970
992
|
//#endregion
|
|
993
|
+
//#region src/extensions/link-paste.d.ts
|
|
994
|
+
/**
|
|
995
|
+
* Paste a URL over selected text to wrap the selection as a Markdown link
|
|
996
|
+
* `[selected text](url)`. Only fires when the clipboard holds exactly one URL
|
|
997
|
+
* and the selection is a non-empty text selection inside a single non-code
|
|
998
|
+
* textblock; otherwise the paste falls through to the other handlers
|
|
999
|
+
* (embed paste, plain paste). One undo restores the plain selected text.
|
|
1000
|
+
*
|
|
1001
|
+
* Registered with `Priority.high` so its `handlePaste` runs before
|
|
1002
|
+
* `defineEmbedPaste`'s: pasting an embeddable URL (tweet/YouTube) over a
|
|
1003
|
+
* selection keeps the selected text as a link instead of discarding it for an
|
|
1004
|
+
* embed. Not part of `defineEditorExtension`; the React package applies it via
|
|
1005
|
+
* the `linkPaste` prop (on by default).
|
|
1006
|
+
*/
|
|
1007
|
+
declare function defineLinkPaste(): PlainExtension;
|
|
1008
|
+
//#endregion
|
|
971
1009
|
//#region src/extensions/mark-names.d.ts
|
|
972
1010
|
declare const MARK_NAMES: readonly ["mdWikilink", "mdImage", "mdFile", "mdMath", "mdMark", "mdEm", "mdStrong", "mdCode", "mdLinkText", "mdLinkUri", "mdLinkTitle", "mdDel", "mdHighlight", "mdTag", "mdPack"];
|
|
973
1011
|
type MarkName = (typeof MARK_NAMES)[number];
|
|
@@ -1028,4 +1066,4 @@ declare function getVirtualElementFromRange(view: EditorView, range: PositionRan
|
|
|
1028
1066
|
//#region src/extensions/spell-check.d.ts
|
|
1029
1067
|
declare function defineSpellCheckPlugin(spellCheck: boolean): import("@prosekit/core").PlainExtension;
|
|
1030
1068
|
//#endregion
|
|
1031
|
-
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 KaTeXRender, type LanguageItem, type LinkAttrs, type LinkClickHandler, type LinkClickPayload, type LinkCopyHandler, type LinkCopyPayload, type LinkEditHandler, type LinkEditOptions, type LinkHoverHandler, type LinkUnit, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdFileAttrs, type MdImageAttrs, type MdLinkTextAttrs, type MdMathAttrs, type MdWikilinkAttrs, type MeowdownCodeBlockAttrs, type MeowdownHTMLCommentAttrs, type MeowdownTableCellAttrs, type NodeName, type PendingReplacement, type PendingReplacementEvent, type PendingReplacementHandler, type PendingReplacementMode, type PendingReplacementOutcome, type PlaceholderOptions, type PositionRange, Priority, type RoundTripFidelity, type StartPendingReplacementOptions, type TableColumnAlign, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type VirtualElement, type WikilinkClickHandler, type WikilinkClickPayload, buildFileMarkdown, checkRoundTrip, codeBlockLanguages, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockPreviewPlugin, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineFileClickHandler, defineFilePaste, defineFileView, defineFollowLinkHandler, defineHTMLComment, defineHTMLPaste, defineImage, defineImageClickHandler, defineLinkClickHandler, defineLinkCommands, defineLinkEditKeymap, defineLinkHoverHandler, defineMarkdownCopy, defineMath, definePendingReplacementHandler, definePlaceholder, defineReadonly, defineSpellCheckPlugin, defineTagClickHandler, defineWikilinkClickHandler, defineWikilinkTrigger, docToMarkdown, getCodeTokens, getLinkUnitAt, getMarkBuilders, getPendingReplacement, getSelectedText, getTableColumnAlign, getVirtualElementFromRange, inlineTextToMarkChunks, insertLink, isCodeBlockPreviewHiddenDecoration, isSelectionInTableCell, listenForTweetHeight, loadKaTeX, markdownToDoc, matchEmbed, removeLink, renderMathInto, updateLink, withPriority };
|
|
1069
|
+
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 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 PendingReplacement, type PendingReplacementEvent, type PendingReplacementHandler, type PendingReplacementMode, type PendingReplacementOutcome, type PlaceholderOptions, type PositionRange, Priority, type RoundTripFidelity, type StartPendingReplacementOptions, type TableColumnAlign, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type VirtualElement, type WikilinkClickHandler, type WikilinkClickPayload, buildFileMarkdown, checkRoundTrip, codeBlockLanguages, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockPreviewPlugin, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineFileClickHandler, defineFilePaste, defineFileView, defineFollowLinkHandler, defineHTMLComment, defineHTMLPaste, defineImage, defineImageClickHandler, defineLinkClickHandler, defineLinkCommands, defineLinkEditKeymap, defineLinkHoverHandler, defineLinkPaste, defineMarkdownCopy, defineMath, definePendingReplacementHandler, definePlaceholder, defineReadonly, defineSpellCheckPlugin, defineTagClickHandler, defineWikilinkClickHandler, defineWikilinkTrigger, docToMarkdown, getCodeTokens, getLinkUnitAt, getMarkBuilders, getPendingReplacement, getSelectedText, getTableColumnAlign, getVirtualElementFromRange, inlineTextToMarkChunks, insertLink, isCodeBlockPreviewHiddenDecoration, isSelectionInTableCell, listenForTweetHeight, loadKaTeX, markdownToDoc, matchEmbed, removeLink, renderMathInto, updateLink, withPriority };
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import{Priority as e,Priority as t,createMarkBuilders as n,createNodeBuilders as r,defineBaseCommands as i,defineBaseKeymap as a,defineCommands as o,defineDOMEventHandler 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 ee,getMarkType as te,getNodeType as ne,isAllSelection as re,isApple as ie,isAtBlockStart as ae,isNodeSelection as oe,isTextSelection as h,toggleNode as se,union as g,unsetBlockType as ce,withPriority as le,withPriority as _,withSkipCodeBlock as ue}from"@prosekit/core";import{defineCodeBlock as de,defineCodeBlockHighlight as fe,defineCodeBlockPreviewPlugin as pe,isCodeBlockPreviewHiddenDecoration as me}from"@prosekit/extensions/code-block";import{definePlaceholder as he}from"@prosekit/extensions/placeholder";import{defineReadonly as ge}from"@prosekit/extensions/readonly";import{isElementLike as _e,once as
|
|
2
|
-
`)}function It(e){return Rt(e,void 0)}function Lt(e){return Rt(e,{key:`math`})}function Rt(e,t){let{selection:n}=e;if(!n.empty)return S.empty;let r=n.$head,{parent:i}=r;if(!i.isTextblock||i.type.spec.code)return S.empty;let a=ee(r,te(e.schema,`mdPack`),t);return a?S.create(e.doc,[x.inline(a.from,a.to,{class:`show`})]):S.empty}const zt=[`mdImage`,`mdWikilink`,`mdFile`];function k(e,t){let n=O(t);return n?e.flatMap(e=>e.modes.includes(n)?[e.name]:[]):[]}function Bt(e,t,n){for(let r of n){let n=E(e,t,r);if(n)return n}}function A(e,t,n){let r=Bt(e,t,n);return r&&r.to===t?r:void 0}function Vt(e,t,n){let r=Bt(e,t,n);return r&&r.from===t?r:void 0}function Ht(e,t){let{from:n,to:r,empty:i}=e.selection;if(i)return;let a=Bt(e,n,t);return a&&a.from===n&&a.to===r?a:void 0}function Ut(e,t){return b.create(e.doc,t.from,t.to)}function Wt(e){return(t,n)=>{let r=k(e,t);if(r.length===0||!h(t.selection))return!1;let i=t.selection;if(i.empty){let e=Vt(t,i.from,r);if(e)return n?.(t.tr.setSelection(Ut(t,e))),!0;if(A(t,i.from,r)){let e=t.doc.resolve(i.from);return i.from>=e.end()?!1:(n?.(t.tr.setSelection(b.create(t.doc,i.from+1))),!0)}return!1}let a=Ht(t,r);return a?(n?.(t.tr.setSelection(b.create(t.doc,a.to))),!0):!1}}function Gt(e){return(t,n)=>{let r=k(e,t);if(r.length===0||!h(t.selection))return!1;let i=t.selection;if(i.empty){let e=A(t,i.from,r);return e?(n?.(t.tr.setSelection(Ut(t,e))),!0):!1}let a=Ht(t,r);return a?(n?.(t.tr.setSelection(b.create(t.doc,a.from))),!0):!1}}function Kt(e){return(t,n)=>{let r=k(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=A(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!Vt(t,i,r)||i<=t.doc.resolve(i).start()?!1:(n?.(t.tr.delete(i-1,i)),!0)}}function qt(e){return(t,n)=>{let r=k(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=Vt(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!A(t,i,r)||i>=t.doc.resolve(i).end()?!1:(n?.(t.tr.delete(i,i+1)),!0)}}const Jt=`md-atom-selected`;function Yt(e){return new v({key:new y(`atom-mark-selection`),props:{decorations:t=>{let n=k(e,t);if(n.length===0||oe(t.selection))return;let r=Ht(t,n);if(r)return S.create(t.doc,[x.inline(r.from,r.to,{class:Jt})]);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(x.inline(t,t+e.nodeSize,{class:Jt}))}),S.create(t.doc,s)}}})}function Xt({marks:e}){return g(_(l({ArrowRight:Wt(e),ArrowLeft:Gt(e),Backspace:Kt(e),Delete:qt(e)}),t.high),m(Yt(e)))}const j=new Map,Zt=new Map,Qt={math:`latex`};async function $t(e){let t=j.get(e);if(t!==void 0)return t;let n=De.matchLanguageName(Oe,Qt[e]??e,!0);if(!n)return j.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),j.set(e,null),null}return j.set(e,r),r}function en(e,t){let n=Zt.get(e);if(n)return n;let r=je({parse:e=>t.language.parser.parse(e.content),highlighter:ke});return Zt.set(e,r),r}const tn=e=>{let t=e.language?.trim();if(!t)return[];let n=j.get(t);return n===null?[]:n?en(t,n)(e):$t(t).then(()=>void 0)};function nn(){return fe({parser:tn,nodeTypes:[`codeBlock`]})}function rn(e,t){let n=t.language.parser.parse(e),r=[];return Ae(n,ke,(e,t,n)=>{r.push([e,t,n])}),r}function an(e,t){let n=t.trim();if(!n)return[];let r=j.get(n);return r===null?[]:r?rn(e,r):$t(n).then(t=>t?rn(e,t):[])}function on(){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 sn(){return f({type:`codeBlock`,attr:`fenceLength`,default:null,toDOM:e=>e==null?null:[`data-fence-length`,String(e)],parseDOM:e=>{let t=e.getAttribute(`data-fence-length`);if(t==null)return null;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>3?n:null}})}function cn(e){return{language:e[1]||``,fenceStyle:`tilde`}}function ln(){return Pe({regex:/^~~~(\S*)\s$/,type:`codeBlock`,attrs:cn})}function un(){return Me({regex:/^~~~(\S*)$/,type:`codeBlock`,attrs:cn})}function dn(){return Me({regex:/^\$\$$/,type:`codeBlock`,attrs:()=>({language:`math`,fenceStyle:`dollar`})})}function fn(){return g(de(),on(),sn(),ln(),un(),dn())}function pn(e,t){return(n,r)=>{if(r){let i=b.create(n.doc,e,t);r(n.tr.setSelection(i))}return!0}}function mn(e,t,n){return(r,i)=>{if(i){let a=b.between(e,t,n);i(r.tr.setSelection(a))}return!0}}function hn(e){return(t,n)=>{if(!e.trim())return!1;let r=Z(e,{nodes:yo(t.schema)}).content;if(r.childCount===0)return!1;let i=r.childCount===1&&r.child(0).type.name===`paragraph`?new C(r,1,1):new C(r,0,C.maxOpen(r).openEnd);if(n){let e=t.tr,r=e.selection;(!h(r)||!r.empty)&&e.setSelection(b.near(r.$from)),n(e.replaceSelection(i).scrollIntoView())}return!0}}function gn(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);Fe(s),n(s.scrollIntoView())}return!0}}function _n(){return o({insertMarkdown:hn,insertTrigger:gn,selectText:pn,selectTextBetween:mn})}const vn=(e,t,n)=>{let{selection:r}=e;return r.empty||n?.composing?!1:(t?.(e.tr.setSelection(b.near(r.$head))),!0)};function yn(){return _(l({Escape:vn}),t.low)}function bn(){return f({type:`doc`,attr:`frontmatter`,default:null})}function xn(){return p({name:`heading`,whitespace:`pre`})}function Sn(){return f({type:`heading`,attr:`setextUnderline`,default:null,toDOM:e=>e==null?null:[`data-setext-underline`,String(e)],parseDOM:e=>{let t=e.getAttribute(`data-setext-underline`);if(t==null)return null;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:null}})}function Cn(){return f({type:`heading`,attr:`closingHashes`,default:null,toDOM:e=>e==null?null:[`data-closing-hashes`,String(e)],parseDOM:e=>{let t=e.getAttribute(`data-closing-hashes`);if(t==null)return null;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:null}})}function M(e){return ue(se({type:`heading`,attrs:{level:e}}))}const wn=(e,t,n)=>ae(e,n)?.parent.type.name===`heading`?ce()(e,t,n):!1;function Tn(){return l({"Mod-1":M(1),"Mod-2":M(2),"Mod-3":M(3),"Mod-4":M(4),"Mod-5":M(5),"Mod-6":M(6),Backspace:wn})}function En(){return g(Be(),xn(),Sn(),Cn(),ze(),Re(),Tn())}const Dn=new Set([`mdMark`,`mdLinkUri`,`mdLinkTitle`]);function On(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 N(e,t){let n=On(e,t);return n==null?!1:n.some(e=>Dn.has(e.type.name))}function P(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 F(e,t){if(!P(e,t))return;let n=e.doc.resolve(t).start(),r=t;for(;r>n&&N(e,r-1);)r--;return r<t?{from:r,to:t}:void 0}function I(e,t){if(!P(e,t))return;let n=e.doc.resolve(t).end(),r=t;for(;r<n&&N(e,r);)r++;return r>t?{from:t,to:r}:void 0}function kn(e,t){return N(e,t-1)&&N(e,t)}function An(e,t){if(!kn(e,t))return;let n=F(e,t),r=I(e,t);if(!(n==null||r==null))return{from:n.from,to:r.to}}function jn(e,t,n){let r=On(e,t);return r!=null&&n.isInSet(r)}function Mn(e,t){let n=On(e,t);if(n==null)return;let r=te(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&&jn(e,r-1,n);)r--;let i=t+1;for(;i<s&&jn(e,i,n);)i++;(c==null||i-r<c.to-c.from)&&(c={from:r,to:i})}return c}function L(e,t,n){let r=Mn(e,n===`from`?t.from:t.to-1);return r==null?!1:n===`from`?r.from===t.from:r.to===t.to}function Nn(e,t,n){let r=L(e,t,`from`),i=L(e,t,`to`);return r&&!i?t.from:i&&!r?t.to:n-t.from<=t.to-n?t.from:t.to}function Pn(e,t,n,r){if(!P(e,n))return n;let i=An(e,n);if(i!=null)return r?Nn(e,i,n):n>=t?i.to:i.from;if(!r)return n;let a=F(e,n);if(a!=null&&L(e,a,`from`))return a.from;let o=I(e,n);return o!=null&&L(e,o,`to`)?o.to:n}function Fn(e,t){if(!P(e,t))return;let n=N(e,t-1),r=N(e,t);if(n!==r)return r?`left`:`right`}function In(e,t){let n=Mn(e,t);if(n==null)return[];let r=I(e,n.from),i=F(e,n.to),a=[];return i!=null&&a.push(i),r!=null&&(i==null||r.from!==i.from)&&a.push(r),a}const Ln=new y(`meowdown-hidden-run-snap`),Rn=new y(`meowdown-hidden-run-beforeinput`);function zn(){let e=!1;return new v({key:Ln,props:{handleDOMEvents:{compositionstart:()=>(e=!0,!1),compositionend:()=>(e=!1,!1)}},appendTransaction:(t,n,r)=>{if(e||O(r)!==`hide`)return null;let i=r.selection;if(!h(i))return null;let a=t.some(e=>e.getMeta(`pointer`)!=null);if(i.empty){let e=Pn(r,n.selection.head,i.head,a);return e===i.head?null:r.tr.setSelection(b.create(r.doc,e))}let o=An(r,i.from)?.from??i.from,s=An(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(b.create(r.doc,c,l))}})}const Bn=(e,t)=>{if(O(e)!==`hide`)return!1;let n=e.selection;if(!h(n)||!n.empty)return!1;let r=Pn(e,n.head,n.head,!0);return r===n.head||t?.(e.tr.setSelection(b.create(e.doc,r))),!1};function Vn(e){return(t,n)=>{if(O(t)!==`hide`)return!1;let r=t.selection;if(!h(r)||!r.empty)return!1;let i=r.$head;if(!i.parent.isTextblock||i.parent.type.spec.code)return!1;let a=e===-1?F(t,r.head):I(t,r.head);if(a==null)return!1;let o=In(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 Hn=Vn(-1),Un=Vn(1);function Wn(){return new v({key:Rn,props:{handleDOMEvents:{beforeinput:(e,t)=>{if(e.composing)return!1;let n=t.inputType===`deleteContentBackward`?Hn:t.inputType===`deleteContentForward`?Un:void 0;return n==null||!n(e.state,e.dispatch)?!1:(t.preventDefault(),!0)}}}})}function Gn(){return g(m(zn()),m(Wn()),_(l({Enter:Bn,Backspace:Hn,Delete:Un}),t.highest))}function Kn(){return f({type:`horizontalRule`,attr:`marker`,default:null,toDOM:e=>e?[`data-hr-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-hr-marker`)})}function qn(){return g(Ve(),Kn())}function Jn(){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 Yn(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function Xn(e,t){let[n,r,i]=t;return[n,r,i.map(t=>Le.fromJSON(e,t))]}function Zn(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}var R=class e extends qe{constructor(e){super(),this.chunks=e}apply(e){if(this.chunks.length===0)return Je.ok(e);let t=e.content.size,n;for(let[r,i,a]of this.chunks){if(r>=i)continue;let o=Math.max(0,Math.min(r,t)),s=Math.max(o,Math.min(i,t));if(o>=s)continue;let c=Le.setFrom(a);e.nodesBetween(o,s,(t,r)=>{if(!t.isText)return!0;let i=Math.max(o,r),a=Math.min(s,r+t.nodeSize);if(i>=a)return!1;let l=t.marks;if(Zn(l,c))return!1;n??=new Ye(e);for(let e of l)n.removeMark(i,a,e);for(let e of c)n.addMark(i,a,e);return!1})}return Je.ok(n?n.doc:e)}invert(e){if(this.chunks.length===0)return Qn;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 Ke(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(Yn)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>Xn(t,e)))}};qe.jsonID(`batchSetMark`,R);const Qn=new R([]),$n=new Set([`com`,`br`,`net`,`jp`,`org`,`in`,`de`,`ru`,`it`,`fr`]),er=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;function tr(e){let t=e.indexOf(`/`);return t===-1?e:e.slice(0,t)}function nr(e){let t=e.split(`.`);if(t.length<2)return!1;let n=t[t.length-1].toLowerCase();if(!$n.has(n)||t[t.length-2].length<3)return!1;for(let e of t)if(e.length>63||!er.test(e))return!1;return!0}function rr(e){if(/^[a-z][a-z0-9+.-]*:/i.test(e))return e;if(/^[^\s@]+@[^\s@]+$/.test(e))return`mailto:${e}`;if(/^www\./i.test(e)||nr(tr(e)))return`https://${e}`}function z(e){return e===32||e===9||e===10||e===13}const ir=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:\/[^\s<]*)?/i,ar=/[\s(*_~]/;function or(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45}function sr(e,t,n){let r=0;for(let i=0;i<t;i++)e[i]===n&&r++;return r}function cr(e){let t=e.length;for(;;){let n=e[t-1];if(/[?!.,:*_~]/.test(n)||n===`)`&&sr(e,t,`)`)>sr(e,t,`(`))t--;else if(n===`;`){let n=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(0,t));if(!n)break;t=n.index}else break}return t}const lr={parseInline:[{name:`BareAutolink`,before:`Link`,parse(e,t,n){if(!or(t)||e.hasOpenLink)return-1;let r=e.slice(n-1,n);if(r!==``&&!ar.test(r))return-1;let i=ir.exec(e.slice(n,e.end));if(!i)return-1;let a=cr(i[0]);return a===0||!nr(tr(i[0].slice(0,a)))?-1:e.addElement(e.elt(`URL`,n,n+a))}}]};function ur(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45||e===95||e>127&&/[\p{L}\p{N}]/u.test(String.fromCharCode(e))}function dr(e){return e>=65&&e<=90||e>=97&&e<=122||e>127&&/\p{L}/u.test(String.fromCharCode(e))}const fr={defineNodes:[{name:`Hashtag`}],parseInline:[{name:`Hashtag`,parse(e,t,n){if(t!==35||!/\s|^$/.test(e.slice(n-1,n)))return-1;let r=n+1,i=!1;for(;r<e.end;){let t=e.char(r);if(!ur(t))break;i||=dr(t),r++}return i?e.addElement(e.elt(`Hashtag`,n,r)):-1}}]},pr={resolve:`Highlight`,mark:`HighlightMark`},mr=/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~\u{A1}\u{2010}-\u{2027}]/u,hr={defineNodes:[{name:`Highlight`},{name:`HighlightMark`}],parseInline:[{name:`Highlight`,after:`Emphasis`,parse(e,t,n){if(t!==61||e.char(n+1)!==61||e.char(n+2)===61)return-1;let r=e.slice(n-1,n),i=e.slice(n+2,n+3),a=/\s|^$/.test(r),o=/\s|^$/.test(i),s=mr.test(r),c=mr.test(i);return e.addDelimiter(pr,n,n+2,!o&&(!c||a||s),!a&&(!s||o||c))}}]};function gr(e){return e>=48&&e<=57}function _r(e){return e.next!==36||e.text.charCodeAt(e.pos+1)!==36||e.text.charCodeAt(e.pos+2)===36?!1:e.skipSpace(e.pos+2)===e.text.length}function vr(e){let t=e.depth;return typeof t==`number`?t:2**53-1}const yr={defineNodes:[{name:`InlineMath`},{name:`InlineMathMark`},{name:`BlockMath`,block:!0},{name:`BlockMathMark`}],parseBlock:[{name:`BlockMath`,before:`FencedCode`,parse(e,t){if(!_r(t))return!1;let n=e.lineStart+t.pos,r=[e.elt(`BlockMathMark`,n,n+2)];for(let n=!0,i=!0,a=!1;!(!e.nextLine()||vr(t)<e.depth);n=!1){if(_r(t)){i&&a&&r.push(e.elt(`CodeText`,e.lineStart-1,e.lineStart)),r.push(e.elt(`BlockMathMark`,e.lineStart+t.pos,e.lineStart+t.pos+2)),e.nextLine();break}a=!0,n||(r.push(e.elt(`CodeText`,e.lineStart-1,e.lineStart)),i=!1);let o=e.lineStart+t.basePos,s=e.lineStart+t.text.length;o<s&&(r.push(e.elt(`CodeText`,o,s)),i=!1)}return e.addElement(e.elt(`BlockMath`,n,e.prevLineEnd(),r)),!0},endLeaf(e,t){return _r(t)}}],parseInline:[{name:`InlineMath`,after:`InlineCode`,parse(e,t,n){if(t!==36||e.char(n-1)===36)return-1;let r=e.char(n+1)===36?2:1;if(e.char(n+r)===36)return-1;let i=n+r;if(z(e.char(i)))return-1;for(let t=i;t<e.end;t++){let a=e.char(t);if(a===10)return-1;if(a===92){t++;continue}if(a!==36)continue;let o=1;for(;e.char(t+o)===36;)o++;if(o!==r||z(e.char(t-1))||gr(e.char(t+o)))return-1;let s=t+o;return e.addElement(e.elt(`InlineMath`,n,s,[e.elt(`InlineMathMark`,n,i),e.elt(`InlineMathMark`,t,s)]))}return-1}}]},br={defineNodes:[{name:`Wikilink`},{name:`WikilinkMark`}],parseInline:[{name:`Wikilink`,before:`Link`,parse(e,t,n){if(t!==91||e.char(n+1)!==91)return-1;let r=!1;for(let t=n+2;t<e.end-1;t++){let i=e.char(t);if(i===93){if(e.char(t+1)!==93||!r)return-1;let i=t+2;return e.addElement(e.elt(`Wikilink`,n,i,[e.elt(`WikilinkMark`,n,n+2),e.elt(`WikilinkMark`,t,i)]))}if(i===91||i===10)return-1;i!==32&&i!==9&&(r=!0)}return-1}}]};function xr(e){return e.end}const Sr=Ze.configure([Xe,fr,br,lr,hr,yr]),Cr=Sr.configure({parseInline:[{name:`SkipInline`,before:`Escape`,parse:xr}]});function B(e){return Sr.parseInline(e,0)}function V(e,t,n=[]){for(let r of e)t(r)&&n.push(r),V(r.children,t,n);return n}function wr(e){let t={};for(let n of e.nodeSet.types)t[n.name]=n.id;return t}const H=wr(Sr),Tr=/^<!--\s*(\{[^}]*\})\s*-->$/,Er=/<!--\s*\{[^}]*\}\s*-->$/;function Dr(e){let t=Tr.exec(e.trim());if(!t)return;let n;try{n=JSON.parse(t[1])}catch{return}if(typeof n!=`object`||!n)return;let r=Or(n);return Object.keys(r).length>0?r:void 0}function Or(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 kr(e){return`<!-- ${JSON.stringify(e)} -->`}function Ar(e){return e.replace(Er,``)}function jr(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 Mr(){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 Nr(){return d({name:`mdWikilink`,constructor:Mr()})}const Pr=new Map([[H.Emphasis,`mdEm`],[H.StrongEmphasis,`mdStrong`],[H.InlineCode,`mdCode`],[H.Strikethrough,`mdDel`],[H.Highlight,`mdHighlight`],[H.EmphasisMark,`mdMark`],[H.CodeMark,`mdMark`],[H.LinkMark,`mdMark`],[H.StrikethroughMark,`mdMark`],[H.HighlightMark,`mdMark`],[H.URL,`mdLinkUri`],[H.LinkTitle,`mdLinkTitle`],[H.Hashtag,`mdTag`],[H.WikilinkMark,`mdMark`]]);function Fr(e,t,n){let r=B(t),i=[];return Lr(r,[],0,t.length,t,e,i,n),i}function Ir(e){return e.slice(1,-1).replaceAll(/\\(.)/g,`$1`)}function Lr(e,t,n,r,i,a,o,s){let c=n;for(let n=0;n<e.length;n++){let r=e[n];r.from>c&&U(o,c,r.from,t);let l=r.type;if(l===H.Link){let e=Br(r,t,i,a,s);e?U(o,r.from,r.to,e):Vr(r,t,i,a,o)}else if(l===H.Image){let s=Hr(r,e[n+1],i);Ur(r,t,i,a,o,s),s&&n++,c=s?s.to:r.to;continue}else if(l===H.Wikilink)Gr(r,t,i,a,o);else if(l===H.InlineMath)Wr(r,t,i,a,o);else if(l===H.URL){let e=rr(i.slice(r.from,r.to)),n=e?a.mdLinkText.create({href:e}):a.mdLinkUri.create();U(o,r.from,r.to,[...t,n])}else{let e;l===H.Emphasis?e=`italic`:l===H.StrongEmphasis?e=`bold`:l===H.InlineCode?e=`code`:l===H.Strikethrough?e=`strike`:l===H.Highlight?e=`highlight`:l===H.Autolink&&(e=`autolink`);let n=e?[...t,a.mdPack.create({key:e})]:t,c=Pr.get(l),u=c?[...n,a[c].create()]:n;r.children.length===0?U(o,r.from,r.to,u):Lr(r.children,u,r.from,r.to,i,a,o,s)}c=r.to}c<r&&U(o,c,r,t)}function Rr(e){let t=-1,n=-1,r=null,i=null,a=0;for(let o of e.children)o.type===H.LinkMark?(a++,a===1&&(t=o.to),a===2&&(n=o.from)):o.type===H.URL&&r===null?r=o:o.type===H.LinkTitle&&i===null&&(i=o);return{labelFrom:t,labelTo:n,urlNode:r,titleNode:i}}function zr(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function Br(e,t,n,r,i){let a=i?.resolveFileLink;if(!a)return;let{labelFrom:o,labelTo:s,urlNode:c,titleNode:l}=Rr(e);if(o<0||s<0||!c)return;let u=n.slice(c.from,c.to);if(!u)return;let d=n.slice(o,s),f=l?Ir(n.slice(l.from,l.to)):``;if(!a({href:u,label:d,title:f}))return;let p=d||zr(u);return[...t,r.mdFile.create({href:u,name:p,title:f})]}function Vr(e,t,n,r,i){let{labelTo:a,urlNode:o,titleNode:s}=Rr(e),c=o?n.slice(o.from,o.to):``,l=s?Ir(n.slice(s.from,s.to)):``,u=c?r.mdLinkText.create({href:c}):null,d=e=>a>=0&&e<a&&u!==null,f=r.mdPack.create({key:`link`,data:{href:c,title:l}}),p=[...t,f],m=e.from;for(let t of e.children){if(t.from>m){let e=d(m)?[...p,u]:p;U(i,m,t.from,e)}let e=d(t.from)?[...p,u]:p;if(t.type===H.Wikilink){Gr(t,e,n,r,i),m=t.to;continue}let a=Pr.get(t.type),o=a?[...e,r[a].create()]:e;t.children.length===0?U(i,t.from,t.to,o):Lr(t.children,o,t.from,t.to,n,r,i,void 0),m=t.to}m<e.to&&U(i,m,e.to,p)}function Hr(e,t,n){if(!t||t.type!==H.Comment||t.from!==e.to)return;let r=Dr(n.slice(t.from,t.to));if(r)return{magic:r,to:t.to}}function Ur(e,t,n,r,i,a){let o=e.children.find(e=>e.type===H.URL);if(!o){Vr(e,t,n,r,i);return}let s=e.children.filter(e=>e.type===H.LinkMark),c=e.children.find(e=>e.type===H.LinkTitle),l=n.slice(o.from,o.to),u=s.length>=2?n.slice(s[0].to,s[1].from):``,d=c?Ir(n.slice(c.from,c.to)):``,f=a?.magic.width??null,p=a?.magic.height??null,m=a?.to??e.to;U(i,e.from,m,[...t,r.mdImage.create({src:l,alt:u,title:d,width:f,height:p})])}function Wr(e,t,n,r,i){let a=e.children.filter(e=>e.type===H.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 Gr(e,t,n,r,i){let{target:a,display:o}=jr(n.slice(e.from,e.to));U(i,e.from,e.to,[...t,r.mdWikilink.create({target:a,display:o})])}function U(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&Zn(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const Kr=`inline-marks-applied`;let qr=0,Jr=0;function Yr(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 Xr(e){let t=new WeakMap;function n(n,r,i){let a=t.get(n);if(a?Jr++:(qr++,a=Fr(_o(i),n.textContent,e),t.set(n,a)),r===0)return a;let o=[];for(let[e,t,n]of a)o.push([e+r,t+r,n]);return o}function r(e,t){let r=[];return e.doc.nodesBetween(t.from,t.to,(t,i)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;if(t.childCount===0)return!1;let a=n(t,i+1,e.schema);return a.length>0&&r.push(...a),!1}),r}return new v({key:new y(`inline-mark`),appendTransaction(e,t,n){for(let t of e)if(t.getMeta(Kr))return null;let i=r(n,Yr(e,n));if(i.length===0)return null;let a=n.tr.step(new R(i));return a.setMeta(Kr,!0),a.setMeta(`addToHistory`,!1),a},view(e){return e.dispatch(Zr(e.state)),{}}})}function Zr(e){return e.tr.setMeta(`inline-marks-trigger`,!0)}function Qr(e){return m(Xr(e))}function $r(){return u({name:`mdImage`,inclusive:!1,attrs:{src:{default:``},alt:{default:``},title:{default:``},width:{default:null},height:{default:null}},toDOM:()=>[`span`,{class:`md-image`},0],parseDOM:[{tag:`span.md-image`}]})}function ei(){return u({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function ti(){return u({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function ni(){return u({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function ri(){return u({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function ii(){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 ai(){return u({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function oi(){return u({name:`mdLinkTitle`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-title`},0],parseDOM:[{tag:`span.md-link-title`}]})}function si(){return u({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function ci(){return u({name:`mdHighlight`,toDOM:()=>[`mark`,0],parseDOM:[{tag:`mark`}]})}function li(){return u({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function ui(){return u({name:`mdWikilink`,inclusive:!1,attrs:{target:{default:``},display:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink`},0],parseDOM:[{tag:`span.md-wikilink`}]})}function di(){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 fi(){return u({name:`mdMath`,inclusive:!1,attrs:{formula:{default:``}},toDOM:()=>[`span`,{class:`md-math`},0],parseDOM:[{tag:`span.md-math`}]})}function pi(){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 mi(){return g(ei(),ti(),ni(),ri(),ii(),ai(),oi(),si(),ci(),li(),ui(),$r(),di(),fi(),pi())}function hi(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 gi(e,t=0){return hi(e,96,t)}const W={em:{node:H.Emphasis,delim:`*`},strong:{node:H.StrongEmphasis,delim:`**`},code:{node:H.InlineCode,delim:"`"},del:{node:H.Strikethrough,delim:`~~`},highlight:{node:H.Highlight,delim:`==`}},_i=new Set([H.EmphasisMark,H.CodeMark,H.LinkMark,H.StrikethroughMark,H.HighlightMark]);function vi(e){return[e.children[0],e.children.at(-1)]}function yi(e){let{type:t,children:n}=e;if(t===H.Emphasis||t===H.StrongEmphasis||t===H.Strikethrough||t===H.Highlight)return[n[0].to,n.at(-1).from];if(t===H.Link||t===H.Image){let e=n.find((e,t)=>t>0&&e.type===H.LinkMark);return e?[n[0].to,e.from]:null}return null}function bi(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=yi(r);return i&&i[0]<=t&&n<=i[1]?bi(r.children,t,n):bi(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function xi(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return xi(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}function Si(e,t,n){for(;t<n&&z(e.charCodeAt(t));)t++;for(;n>t&&z(e.charCodeAt(n-1));)n--;return[t,n]}function Ci(e,t,n,r){let i=V(B(e),e=>e.type===r.node||_i.has(e.type));for(let r=t;r<n;r++)if(!z(e.charCodeAt(r))&&i.every(e=>!(e.from<=r&&r<e.to)))return!1;return!0}function wi(e,t,n,r,i){let a=B(e),o=V(a,e=>e.type===r.node);return i?Di(e,o,t,n):Ti(e,a,o,t,n,r)}function Ti(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=bi(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]=vi(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=Ei(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function Ei(e,t,n,r,i){if(i.node!==H.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(gi(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function Di(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=vi(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=xi(a.children.slice(1,-1),s,c);s>t.to&&z(e.charCodeAt(s-1));)s--;for(;c<o.from&&z(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 Oi(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=B(e),o=V(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=vi(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return ki(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function ki(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=yi(n);return!e||t<e[0]||t>e[1]?!0:ki(n.children,t)}return!1}function G(e){return(t,n)=>{if(t.selection.empty)return Ai(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]=Si(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:Ci(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>wi(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(b.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 Ai(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=Oi(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(b.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(b.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function ji(){return o({toggleEm:()=>G(W.em),toggleStrong:()=>G(W.strong),toggleCode:()=>G(W.code),toggleDel:()=>G(W.del),toggleHighlight:()=>G(W.highlight)})}function Mi(){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 Ni(){return g(ji(),Mi())}function Pi(e,t,n){let r;return e.doc.nodesBetween(t.from,t.to,(e,i)=>(e.isText&&e.marks.some(e=>e.type.name===n)&&(r={from:Math.max(i,t.from),to:Math.min(i+e.nodeSize,t.to)}),!0)),r}function K(e,t){let n=E(e,t,`mdLinkText`),r=E(e,t,`mdPack`,{key:`link`})??E(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`)return{unit:{from:i.from,to:i.to},href:o,title:``};let s=Pi(e,i,`mdLinkUri`),c=s?s.from-2:i.to-3,l=s?s.from:i.to-1;return{unit:{from:i.from,to:i.to},label:{from:i.from+1,to:c},dest:{from:l,to:i.to-1},href:a.data.href,title:a.data.title}}function Fi(e){let t=e.trim();return t?rr(t)??t:``}function Ii(e,t){return e+(t?` "${t.replaceAll(/(["\\])/g,String.raw`\$1`)}"`:``)}function Li(e){let{selection:t}=e,{$from:n,$to:r,empty:i}=t;if(i||!n.sameParent(r)||!h(t))return;let a=n.parent;if(!a.isTextblock||a.type.spec.code)return;let o=n.start(),[s,c]=Si(a.textContent,n.parentOffset,r.parentOffset);if(!(s>=c))return{from:o+s,to:o+c}}function Ri(e={}){return(t,n)=>{let r=Ii(Fi(e.href??``),e.title??``),i=Li(t);if(!i)return!1;if(n){let{from:e,to:a}=i,o=t.tr,s=`](${r})`;o.insertText(s,a).insertText(`[`,e),n(o.setSelection(b.create(o.doc,e,a+1+s.length)).scrollIntoView())}return!0}}function zi(e){return(t,n)=>{let r=K(t,t.selection.from);if(!r?.dest)return!1;let i=Ii(Fi(e.href??r.href),e.title??r.title);return n&&n(t.tr.insertText(i,r.dest.from,r.dest.to).scrollIntoView()),!0}}function Bi(){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 Vi(){return o({insertLink:Ri,updateLink:zi,removeLink:Bi})}function Hi(e){return(t,n,r)=>{let i=K(t,t.selection.from);if(i){if(n&&r){let{unit:{from:a,to:o}}=i;n(t.tr.setSelection(b.create(t.doc,a,o)).scrollIntoView()),r.focus(),e({from:a,to:o,link:i})}return!0}let a=Li(t);if(a){if(n&&r){let{from:i,to:o}=a;n(t.tr.setSelection(b.create(t.doc,i,o)).scrollIntoView()),r.focus(),e({from:i,to:o,link:void 0})}return!0}return!1}}function Ui(e){return l({"Mod-k":Hi(e)})}function Wi(){return f({type:`list`,attr:`marker`,default:null,splittable:!0,toDOM:e=>e===`)`||e===`*`||e===`+`?[`data-list-marker`,e]:null,parseDOM:e=>{let t=e.getAttribute(`data-list-marker`);return t===`)`||t===`*`||t===`+`?t:null}})}function Gi(){return f({type:`list`,attr:`taskMarker`,default:null,splittable:!0,toDOM:e=>e===`X`?[`data-list-task-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-list-task-marker`)===`X`?`X`:null})}function Ki(e){return e===2||e===3||e===4}function qi(){return f({type:`list`,attr:`markerGap`,default:1,splittable:!0,toDOM:e=>Ki(e)?[`data-list-marker-gap`,String(e)]:null,parseDOM:e=>{let t=Number.parseInt(e.getAttribute(`data-list-marker-gap`)??``,10);return Ki(t)?t:1}})}const Ji=[T(/^\s?([*-])\s$/,{kind:`bullet`,collapsed:!1}),T(/^\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}}),T(/^\s?\[([\sX]?)\]\s$/i,({match:e})=>({kind:`task`,checked:[`x`,`X`].includes(e[1]),collapsed:!1})),T(/^\s?\+\s$/,{kind:`task`,marker:`+`,checked:!1,collapsed:!1})];function Yi(){return g(Ji.map(Ne))}function Xi(){return w({kind:`task`,marker:`+`})}function Zi(){return w({kind:`task`,marker:null})}function Qi(){return o({wrapInCircleTask:Xi,wrapInSquareTask:Zi})}function $i(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.name===`list`)return n.attrs}return null}function ea(){return(e,t,n)=>{let r=$i(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},w(a)(e,t,n)}}function ta(){return(e,t,n)=>{let r=$i(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},w(a)(e,t,n)}}function na(e){return e.type.name===`list`&&e.attrs.kind===`bullet`&&e.childCount>=2&&e.firstChild?.type!==e.type}const ra=e=>{let t=e.attrs;return t.kind===`task`?{...t,checked:!t.checked}:na(e)?{...t,collapsed:!t.collapsed}:t};function ia(){return m(()=>[new v({props:{handleDOMEvents:{mousedown:(e,t)=>ct({view:e,event:t,onListClick:ra})}}}),at(),new v({props:{transformCopied:lt}}),ot()])}function aa(){return o({toggleListCollapsed:()=>st({isToggleable:na})})}function oa(){return l({"Mod-Enter":ea(),"Mod-Shift-Enter":ta(),"Mod-.":st({isToggleable:na}),"Mod-Shift-7":it({kind:`ordered`,collapsed:!1}),"Mod-Shift-8":it({kind:`bullet`,collapsed:!1}),"Mod-Shift-9":it({kind:`task`,checked:!1,collapsed:!1})})}function sa(){return g(nt(),ia(),et(),Qe(),tt(),$e(),Yi(),oa(),Wi(),Gi(),qi(),Qi(),aa())}let ca;function la(){return ca??=import(`katex`).then(e=>e.render),ca}function ua(e,t,n,r){try{e(n,t,{displayMode:r,throwOnError:!1,output:`mathml`})}catch(e){t.textContent=String(e)}}var da=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=b.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;la().then(t=>{e===this.#r&&ua(t,this.#n,e,!1)})}};function fa(){return d({name:`mdMath`,constructor:(e,t)=>new da(e,t)})}function pa(e){return e===`left`||e===`center`||e===`right`?e:null}function ma(){return f({type:`tableCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>pa(e.getAttribute(`data-align`))})}function ha(){return f({type:`tableHeaderCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>pa(e.getAttribute(`data-align`))})}function ga(e){for(let t=0;t<e.childCount;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++)if(n.child(e).type.name===`tableHeaderCell`)return t}return 0}function _a(e){return e.child(ga(e))}function va(e,t){return t>=e.childCount?null:e.child(t).attrs.align??null}function ya(e,t,n){if(e.childCount===0)return;let r=_a(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=va(r,e);(t.attrs.align??null)!==i&&n.setNodeMarkup(o,void 0,{...t.attrs,align:i}),o+=t.nodeSize}i+=a.nodeSize}}function ba(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 xa(){return new v({key:new y(`table-align-sync`),appendTransaction(e,t,n){if(!e.some(e=>e.docChanged))return;let r=ba(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)=>e.type.name===`table`?(s??=n.tr,ya(e,t,s),!1):!0),s?.docChanged?s:void 0}})}function Sa(){return m(xa())}function Ca(e){let{selection:t}=e;if(vt(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 wa(e){return(t,n)=>{let r=Ca(t);if(!r||r.table.childCount===0)return!1;if(n){let{table:i,tablePos:a,firstColumn:o,lastColumn:s}=r,c=ga(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 Ta(e){let t=Ca(e);if(!(!t||t.table.childCount===0))return va(_a(t.table),t.lastColumn)??void 0}function Ea(){return o({setTableColumnAlign:wa})}function Da(){return g(ma(),ha(),Sa(),Ea())}function Oa(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 ka=`paragraph`;function Aa(){return g(p({name:`tableCell`,content:ka}),p({name:`tableHeaderCell`,content:ka}))}const ja=(e,t)=>{let{selection:n}=e;return!vt(n)||!n.isColSelection()||!n.isRowSelection()?!1:_t(e,t)};function Ma(){return _(l({Backspace:ja,Delete:ja}),t.high)}function Na(){return g(gt(),ht(),ut(),mt(),Aa(),Da(),pt({allowTableNodeSelection:!0}),dt(),ft(),Ma())}function Pa(e){let{selection:t}=e,{$from:n,$to:r}=t;if(oe(t)&&n.depth===0||n.depth>0&&r.depth>0&&n.index(0)===r.index(0))return n.index(0)}function Fa(e){return(t,n)=>{if(Oa(t))return!1;let r=Pa(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=oe(a)?Te.create(u.doc,a.from+d):b.create(u.doc,a.anchor+d,a.head+d);u.setSelection(f),n(u.scrollIntoView())}return!0}}function Ia(e){return(t,n,r)=>rt(e)(t,n,r)||Fa(e===`up`?-1:1)(t,n,r)}function La(){return l({"Alt-ArrowUp":Ia(`up`),"Alt-ArrowDown":Ia(`down`)})}function Ra(){return p({name:`paragraph`,content:`inline*`,group:`block`,whitespace:`pre`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}})}function za(){return g(_(Ra(),t.highest),yt(),bt())}const q=new y(`meowdownPendingReplacement`);function J(e){return q.getState(e)?.pending??null}function Ba(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 Va=new v({key:q,state:{init:()=>({pending:null}),apply:(e,t)=>{let n=e.getMeta(q);if(n)return Ba(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=J(e);return!t||t.from>=t.to?null:S.create(e.doc,[x.inline(t.from,t.to,{class:`md-pending-replacement`})])}}});function Ha(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 Ua(e){return(t,n)=>J(t)?(n?.(t.tr.setMeta(q,{type:`append`,text:e})),!0):!1}function Wa(){return(e,t)=>J(e)?(t?.(e.tr.setMeta(q,{type:`discard`})),!0):!1}function Ga(e={}){return(t,n)=>{let r=J(t);if(!r||!r.text.trim())return!1;if(n){let i=e.mode??r.mode,a=yo(t.schema),o=Z(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(b.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?.type.name===`paragraph`&&e.sameParent(n)&&e.parent.isTextblock?(s.replaceWith(r.from,r.to,i.content),s.setSelection(b.near(s.doc.resolve(r.from+i.content.size),-1))):(s.replaceRange(r.from,r.to,new C(o.content,0,0)),s.setSelection(b.near(s.doc.resolve(s.mapping.map(r.to)),-1)))}n(s.scrollIntoView())}return!0}}function Ka(){return o({startPendingReplacement:Ha,appendPendingReplacementText:Ua,acceptPendingReplacement:Ga,discardPendingReplacement:Wa})}function qa(){return l({"Mod-Enter":Ga(),Escape:Wa()})}function Ja(){return g(m(Va),Ka(),qa())}function Ya(e){return m(new v({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 Y(e,t){return(n,r)=>{let i=e<0?Ee.atStart(n.doc):Ee.atEnd(n.doc),a=t?b.between(n.selection.$anchor,i.$head):i;return n.selection.eq(a)||r?.(n.tr.setSelection(a).scrollIntoView()),!0}}function Xa(){return l({"Meta-ArrowUp":Y(-1,!1),"Meta-ArrowDown":Y(1,!1),"Shift-Meta-ArrowUp":Y(-1,!0),"Shift-Meta-ArrowDown":Y(1,!0)})}function Za(e){return e.left===0&&e.top===0&&e.right===0&&e.bottom===0}function X(e,t,n){if(t<0||t>e.state.doc.content.size)return;let r;try{r=e.coordsAtPos(t,n)}catch{return}return Za(r)?void 0:r}function Qa(e){e.offsetWidth}const $a=new y(`meowdown-virtual-caret`),eo=[`md-virtual-caret-blink`,`md-virtual-caret-blink2`];function to(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 no(e){let t=e.state,n=t.selection.head,r=F(t,n),i=I(t,n),a=r==null,o=[[n,a],[n,!a]];r!=null&&o.push([r.from,!0]),i!=null&&o.push([i.to,!1]);for(let[t,n]of o){let r=X(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 ro(e){let t=e.state,n=t.selection.head;for(let r of zt){let i=E(t,n,r);if(i==null||i.from!==n&&i.to!==n)continue;let a=io(e,i.from+1);if(a==null)continue;let o=a.getBoundingClientRect();if(o.height!==0)return{left:i.to===n?o.right:o.left,top:o.top,height:o.height}}}function io(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 ao(e){let t=e.height*.19999999999999996;return{left:e.left,top:e.top-t/2,height:e.height+t}}function oo(e){let t=to(e)??no(e);return t==null?ro(e):ao(t)}function so(e,t){return e==null||t==null?e===t:e.left===t.left&&e.top===t.top&&e.height===t.height}var co=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=eo[this.#s]}#l=()=>{let e=this.#e;if(e.isDestroyed)return;let t=e.state,n=t.selection,r=h(n)&&n.empty?oo(e):void 0,i=r!=null&&O(t)===`hide`?Fn(t,n.head):void 0;if(so(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`;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`,a&&(Qa(this.#n),this.#n.style.transitionProperty=``)}};function lo(){return m(new v({key:$a,view:e=>new co(e)}))}function uo(e){return g(za(),be(),bn(),Ce(),ye(),sa(),En(),Na(),fn(),qn(),Jn(),mi(),nn(),yn(),La(),Xa(),Qr(e),Ni(),Vi(),Nr(),fa(),Pt(e.markMode??`focus`),lo(),Gn(),Xt({marks:zt.map(e=>({name:e,modes:[`hide`,`focus`,`show`]}))}),a(),i(),c(),xe(),we(),Se(),_n(),Ja())}function fo(e={}){return uo(e)}const po=ve(()=>{let e=fo().schema;if(e==null)throw Error(`Unexpected empty schema`);return e}),mo=ve(()=>r(po())),ho=ve(()=>n(po())),go=`meowdown_mark_builders`;function _o(e){let t=e.cached[go];if(t)return t;let r=n(e);return e.cached[go]=r,r}const vo=`meowdown_node_builders`;function yo(e){let t=e.cached[vo];if(t)return t;let n=r(e);return e.cached[vo]=n,n}function Z(e,t={}){let{nodes:n=mo(),frontmatter:r=!1}=t,i,a=e;if(r){let[t,n]=xo(e);i=t,n&&(a=e.slice(n))}let o=So(n,Cr.parse(a).cursor(),a);return n.doc(i===void 0?{}:{frontmatter:i},o)}const bo=/^---[ \t]*\r?\n([\s\S]*?\n)?---[ \t]*(?:\r?\n|$)/;function xo(e){let t=bo.exec(e);return t?[(t[1]??``).replace(/\r?\n$/,``),t[0].length]:[]}function So(e,t,n){let r=[];if(!t.firstChild())return r;let i;do i!=null&&Co(r,e,n,i,t.from),i=t.to,r.push(...wo(e,t,n));while(t.nextSibling());return t.parent(),r}function Co(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 wo(e,t,n){switch(t.type.id){case H.ATXHeading1:return[Q(e,t,n,1,!1)];case H.ATXHeading2:return[Q(e,t,n,2,!1)];case H.ATXHeading3:return[Q(e,t,n,3,!1)];case H.ATXHeading4:return[Q(e,t,n,4,!1)];case H.ATXHeading5:return[Q(e,t,n,5,!1)];case H.ATXHeading6:return[Q(e,t,n,6,!1)];case H.SetextHeading1:return[Q(e,t,n,1,!0)];case H.SetextHeading2:return[Q(e,t,n,2,!0)];case H.Paragraph:return[Ao(e,t,n)];case H.CommentBlock:return[jo(e,t,n)];case H.HTMLBlock:case H.ProcessingInstructionBlock:return[Ao(e,t,n)];case H.Blockquote:return[Mo(e,t,n)];case H.BulletList:return No(e,t,n,`bullet`);case H.OrderedList:return No(e,t,n,`ordered`);case H.FencedCode:case H.CodeBlock:return[Fo(e,t,n)];case H.BlockMath:return[Io(e,t,n)];case H.HorizontalRule:{let r=n.slice(t.from,t.to).trimEnd();return[e.horizontalRule({marker:r===`---`?null:r})]}case H.Table:return[Lo(e,t,n)];case H.Task:return[Ao(e,t,n)];default:return n.slice(t.from,t.to).trim()===``?[]:(console.warn(`[meowdown] unsupported lezer block "${t.type.name}"`),[Ao(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===H.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===H.HeaderMark&&n>o&&(s=n,c=n,l=r),t.parent()}let u=Oo(n.slice(o,s),$(n,o)).trim(),d=i?To(n,c,l)||1:null,f=!i&&c>=0&&Eo(n,c,l)||null;return e.heading({level:r,setextUnderline:d,closingHashes:f},u)}function To(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 Eo(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(`
|
|
3
|
-
`,t-1)+1,r=0;for(let i=n;i<t;i++)r+=e.charCodeAt(i)===9?4-r%4:1;return r}function
|
|
1
|
+
import{Priority as e,Priority as t,createMarkBuilders as n,createNodeBuilders as r,defineBaseCommands as i,defineBaseKeymap as a,defineCommands as o,defineDOMEventHandler 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 ee,getMarkType as te,getNodeType as ne,isAllSelection as re,isApple as ie,isAtBlockStart as ae,isNodeSelection as oe,isTextSelection as h,toggleNode as se,union as g,unsetBlockType as ce,withPriority as le,withPriority as _,withSkipCodeBlock as ue}from"@prosekit/core";import{defineCodeBlock as de,defineCodeBlockHighlight as fe,defineCodeBlockPreviewPlugin as pe,isCodeBlockPreviewHiddenDecoration as me}from"@prosekit/extensions/code-block";import{definePlaceholder as he}from"@prosekit/extensions/placeholder";import{defineReadonly as ge}from"@prosekit/extensions/readonly";import{isElementLike as _e,once as v}from"@ocavue/utils";import{defineBlockquote as ve}from"@prosekit/extensions/blockquote";import{defineDoc as ye}from"@prosekit/extensions/doc";import{defineGapCursor as be}from"@prosekit/extensions/gap-cursor";import{defineModClickPrevention as xe}from"@prosekit/extensions/mod-click-prevention";import{defineText as Se}from"@prosekit/extensions/text";import{defineVirtualSelection as Ce}from"@prosekit/extensions/virtual-selection";import{NodeSelection as we,Plugin as y,PluginKey as b,Selection as Te,TextSelection as x}from"@prosekit/pm/state";import{Decoration as S,DecorationSet as C}from"@prosekit/pm/view";import{LanguageDescription as Ee}from"@codemirror/language";import{languages as De}from"@codemirror/language-data";import{classHighlighter as Oe,highlightTree as ke}from"@lezer/highlight";import{createParser as Ae}from"prosemirror-highlight/lezer";import{defineTextBlockEnterRule as je}from"@prosekit/extensions/enter-rule";import{defineInputRule as Me,defineTextBlockInputRule as Ne}from"@prosekit/extensions/input-rule";import{triggerAutocomplete as Pe}from"@prosekit/extensions/autocomplete";import{DOMSerializer as Fe,Mark as Ie,Slice as w}from"@prosekit/pm/model";import{defineHeadingCommands as Le,defineHeadingInputRule as Re,defineHeadingSpec as ze}from"@prosekit/extensions/heading";import{defineHorizontalRule as Be}from"@prosekit/extensions/horizontal-rule";import{AddMarkStep as Ve,AddNodeMarkStep as He,RemoveMarkStep as Ue,RemoveNodeMarkStep as We,ReplaceStep as Ge,Step as Ke,StepResult as qe,Transform as Je}from"@prosekit/pm/transform";import{GFM as Ye,parser as Xe}from"@lezer/markdown";import{defineListCommands as Ze,defineListDropIndicator as Qe,defineListKeymap as $e,defineListSerializer as et,defineListSpec as tt,moveList as nt,toggleList as rt,wrapInList as T}from"@prosekit/extensions/list";import{createListRenderingPlugin as it,createSafariInputMethodWorkaroundPlugin as at,createToggleCollapsedCommand as ot,handleListMarkerMouseDown as st,unwrapListSlice as ct,wrappingListInputRule as E}from"prosemirror-flat-list";import{defineTableCellSpec as lt,defineTableCommands as ut,defineTableDropIndicator as dt,defineTableEditingPlugin as ft,defineTableHeaderCellSpec as pt,defineTableRowSpec as mt,defineTableSpec as ht,deleteTable as gt,isCellSelection as _t}from"@prosekit/extensions/table";import{defineParagraphCommands as vt,defineParagraphKeymap as yt}from"@prosekit/extensions/paragraph";import{closeHistory as bt}from"@prosekit/pm/history";import xt from"rehype-parse";import St from"rehype-remark";import Ct from"remark-gfm";import wt from"remark-stringify";import{unified as Tt}from"unified";import{registerResizableHandleElement as Et,registerResizableRootElement as Dt}from"@prosekit/web/resizable";function D(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 ee(a,n,r)}const Ot=new Set([`mdMark`,`mdLinkUri`,`mdLinkTitle`]),kt=new Set([`mdMath`]),O=new b(`mark-mode`);function At(e){return O.getState(e)}function jt(e){return new y({key:O,state:{init:()=>e,apply:(e,t)=>e.getMeta(O)??t},props:{attributes:t=>({"data-mark-mode":At(t)??e}),decorations:e=>{let t=At(e);if(t===`focus`)return Ft(e);if(t===`hide`)return It(e)},clipboardTextSerializer:(e,t)=>At(t.state)===`show`?``:Pt(e)}})}function Mt(e){return(t,n)=>k(t)===e?!1:(n?.(t.tr.setMeta(O,e)),!0)}function Nt(e){return g(m(jt(e)),o({setMarkMode:Mt}))}function k(e){return O.getState(e)}function Pt(e){let t=[];return e.content.forEach(e=>{let n=[];e.descendants(e=>{if(!e.isText||!e.text)return!0;let t=e.marks.map(e=>e.type.name);return t.some(e=>Ot.has(e))&&!t.some(e=>kt.has(e))||n.push(e.text),!1}),t.push(n.join(``))}),t.join(`
|
|
2
|
+
`)}function Ft(e){return Lt(e,void 0)}function It(e){return Lt(e,{key:`math`})}function Lt(e,t){let{selection:n}=e;if(!n.empty)return C.empty;let r=n.$head,{parent:i}=r;if(!i.isTextblock||i.type.spec.code)return C.empty;let a=ee(r,te(e.schema,`mdPack`),t);return a?C.create(e.doc,[S.inline(a.from,a.to,{class:`show`})]):C.empty}const Rt=[`mdImage`,`mdWikilink`,`mdFile`];function A(e,t){let n=k(t);return n?e.flatMap(e=>e.modes.includes(n)?[e.name]:[]):[]}function zt(e,t,n){for(let r of n){let n=D(e,t,r);if(n)return n}}function j(e,t,n){let r=zt(e,t,n);return r&&r.to===t?r:void 0}function Bt(e,t,n){let r=zt(e,t,n);return r&&r.from===t?r:void 0}function Vt(e,t){let{from:n,to:r,empty:i}=e.selection;if(i)return;let a=zt(e,n,t);return a&&a.from===n&&a.to===r?a:void 0}function Ht(e,t){return x.create(e.doc,t.from,t.to)}function Ut(e){return(t,n)=>{let r=A(e,t);if(r.length===0||!h(t.selection))return!1;let i=t.selection;if(i.empty){let e=Bt(t,i.from,r);if(e)return n?.(t.tr.setSelection(Ht(t,e))),!0;if(j(t,i.from,r)){let e=t.doc.resolve(i.from);return i.from>=e.end()?!1:(n?.(t.tr.setSelection(x.create(t.doc,i.from+1))),!0)}return!1}let a=Vt(t,r);return a?(n?.(t.tr.setSelection(x.create(t.doc,a.to))),!0):!1}}function Wt(e){return(t,n)=>{let r=A(e,t);if(r.length===0||!h(t.selection))return!1;let i=t.selection;if(i.empty){let e=j(t,i.from,r);return e?(n?.(t.tr.setSelection(Ht(t,e))),!0):!1}let a=Vt(t,r);return a?(n?.(t.tr.setSelection(x.create(t.doc,a.from))),!0):!1}}function Gt(e){return(t,n)=>{let r=A(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=j(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!Bt(t,i,r)||i<=t.doc.resolve(i).start()?!1:(n?.(t.tr.delete(i-1,i)),!0)}}function Kt(e){return(t,n)=>{let r=A(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=Bt(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!j(t,i,r)||i>=t.doc.resolve(i).end()?!1:(n?.(t.tr.delete(i,i+1)),!0)}}const qt=`md-atom-selected`;function Jt(e){return new y({key:new b(`atom-mark-selection`),props:{decorations:t=>{let n=A(e,t);if(n.length===0||oe(t.selection))return;let r=Vt(t,n);if(r)return C.create(t.doc,[S.inline(r.from,r.to,{class:qt})]);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(S.inline(t,t+e.nodeSize,{class:qt}))}),C.create(t.doc,s)}}})}function Yt({marks:e}){return g(_(l({ArrowRight:Ut(e),ArrowLeft:Wt(e),Backspace:Gt(e),Delete:Kt(e)}),t.high),m(Jt(e)))}const M=new Map,Xt=new Map,Zt={math:`latex`};async function Qt(e){let t=M.get(e);if(t!==void 0)return t;let n=Ee.matchLanguageName(De,Zt[e]??e,!0);if(!n)return M.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),M.set(e,null),null}return M.set(e,r),r}function $t(e,t){let n=Xt.get(e);if(n)return n;let r=Ae({parse:e=>t.language.parser.parse(e.content),highlighter:Oe});return Xt.set(e,r),r}const en=e=>{let t=e.language?.trim();if(!t)return[];let n=M.get(t);return n===null?[]:n?$t(t,n)(e):Qt(t).then(()=>void 0)};function tn(){return fe({parser:en,nodeTypes:[`codeBlock`]})}function nn(e,t){let n=t.language.parser.parse(e),r=[];return ke(n,Oe,(e,t,n)=>{r.push([e,t,n])}),r}function rn(e,t){let n=t.trim();if(!n)return[];let r=M.get(n);return r===null?[]:r?nn(e,r):Qt(n).then(t=>t?nn(e,t):[])}function an(){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 on(){return f({type:`codeBlock`,attr:`fenceLength`,default:null,toDOM:e=>e==null?null:[`data-fence-length`,String(e)],parseDOM:e=>{let t=e.getAttribute(`data-fence-length`);if(t==null)return null;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>3?n:null}})}function sn(e){return{language:e[1]||``,fenceStyle:`tilde`}}function cn(){return Ne({regex:/^~~~(\S*)\s$/,type:`codeBlock`,attrs:sn})}function ln(){return je({regex:/^~~~(\S*)$/,type:`codeBlock`,attrs:sn})}function un(){return je({regex:/^\$\$$/,type:`codeBlock`,attrs:()=>({language:`math`,fenceStyle:`dollar`})})}function dn(){return g(de(),an(),on(),cn(),ln(),un())}function fn(e,t){return(n,r)=>{if(r){let i=x.create(n.doc,e,t);r(n.tr.setSelection(i))}return!0}}function pn(e,t,n){return(r,i)=>{if(i){let a=x.between(e,t,n);i(r.tr.setSelection(a))}return!0}}function mn(e){return(t,n)=>{if(!e.trim())return!1;let r=Z(e,{nodes:Co(t.schema)}).content;if(r.childCount===0)return!1;let i=r.childCount===1&&r.child(0).type.name===`paragraph`?new w(r,1,1):new w(r,0,w.maxOpen(r).openEnd);if(n){let e=t.tr,r=e.selection;(!h(r)||!r.empty)&&e.setSelection(x.near(r.$from)),n(e.replaceSelection(i).scrollIntoView())}return!0}}function hn(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);Pe(s),n(s.scrollIntoView())}return!0}}function gn(){return o({insertMarkdown:mn,insertTrigger:hn,selectText:fn,selectTextBetween:pn})}const _n=(e,t,n)=>{let{selection:r}=e;return r.empty||n?.composing?!1:(t?.(e.tr.setSelection(x.near(r.$head))),!0)};function vn(){return _(l({Escape:_n}),t.low)}function yn(){return f({type:`doc`,attr:`frontmatter`,default:null})}function bn(){return p({name:`heading`,whitespace:`pre`})}function xn(){return f({type:`heading`,attr:`setextUnderline`,default:null,toDOM:e=>e==null?null:[`data-setext-underline`,String(e)],parseDOM:e=>{let t=e.getAttribute(`data-setext-underline`);if(t==null)return null;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:null}})}function Sn(){return f({type:`heading`,attr:`closingHashes`,default:null,toDOM:e=>e==null?null:[`data-closing-hashes`,String(e)],parseDOM:e=>{let t=e.getAttribute(`data-closing-hashes`);if(t==null)return null;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:null}})}function N(e){return ue(se({type:`heading`,attrs:{level:e}}))}const Cn=(e,t,n)=>ae(e,n)?.parent.type.name===`heading`?ce()(e,t,n):!1;function wn(){return l({"Mod-1":N(1),"Mod-2":N(2),"Mod-3":N(3),"Mod-4":N(4),"Mod-5":N(5),"Mod-6":N(6),Backspace:Cn})}function Tn(){return g(ze(),bn(),xn(),Sn(),Re(),Le(),wn())}function En(e,t){return t(e.state,e.dispatch,e)}const Dn=new Set([`mdMark`,`mdLinkUri`,`mdLinkTitle`]);function On(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 P(e,t){let n=On(e,t);return n==null?!1:n.some(e=>Dn.has(e.type.name))}function F(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 I(e,t){if(!F(e,t))return;let n=e.doc.resolve(t).start(),r=t;for(;r>n&&P(e,r-1);)r--;return r<t?{from:r,to:t}:void 0}function L(e,t){if(!F(e,t))return;let n=e.doc.resolve(t).end(),r=t;for(;r<n&&P(e,r);)r++;return r>t?{from:t,to:r}:void 0}function kn(e,t){return P(e,t-1)&&P(e,t)}function An(e,t){if(!kn(e,t))return;let n=I(e,t),r=L(e,t);if(!(n==null||r==null))return{from:n.from,to:r.to}}function jn(e,t,n){let r=On(e,t);return r!=null&&n.isInSet(r)}function Mn(e,t){let n=On(e,t);if(n==null)return;let r=te(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&&jn(e,r-1,n);)r--;let i=t+1;for(;i<s&&jn(e,i,n);)i++;(c==null||i-r<c.to-c.from)&&(c={from:r,to:i})}return c}function Nn(e,t,n){let r=Mn(e,n===`from`?t.from:t.to-1);return r==null?!1:n===`from`?r.from===t.from:r.to===t.to}function Pn(e,t,n){let r=Nn(e,t,`from`),i=Nn(e,t,`to`);return r&&!i?t.from:i&&!r?t.to:n-t.from<=t.to-n?t.from:t.to}function Fn(e,t,n,r){if(!F(e,n))return n;let i=An(e,n);if(i!=null)return r?Pn(e,i,n):n>=t?i.to:i.from;if(!r)return n;let a=I(e,n);if(a!=null&&Nn(e,a,`from`))return a.from;let o=L(e,n);return o!=null&&Nn(e,o,`to`)?o.to:n}function In(e,t){if(!F(e,t))return;let n=P(e,t-1),r=P(e,t);if(n!==r)return r?`left`:`right`}function Ln(e,t){let n=Mn(e,t);if(n==null)return[];let r=L(e,n.from),i=I(e,n.to),a=[];return i!=null&&a.push(i),r!=null&&(i==null||r.from!==i.from)&&a.push(r),a}const Rn=new b(`meowdown-hidden-run-snap`),zn=new b(`meowdown-hidden-run-beforeinput`);function Bn(){let e=!1;return new y({key:Rn,props:{handleDOMEvents:{compositionstart:()=>(e=!0,!1),compositionend:()=>(e=!1,!1)}},appendTransaction:(t,n,r)=>{if(e||k(r)!==`hide`)return null;let i=r.selection;if(!h(i))return null;let a=t.some(e=>e.getMeta(`pointer`)!=null);if(i.empty){let e=Fn(r,n.selection.head,i.head,a);return e===i.head?null:r.tr.setSelection(x.create(r.doc,e))}let o=An(r,i.from)?.from??i.from,s=An(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(x.create(r.doc,c,l))}})}const Vn=(e,t)=>{if(k(e)!==`hide`)return!1;let n=e.selection;if(!h(n)||!n.empty)return!1;let r=Fn(e,n.head,n.head,!0);return r===n.head||t?.(e.tr.setSelection(x.create(e.doc,r))),!1};function Hn(e){return(t,n)=>{if(k(t)!==`hide`)return!1;let r=t.selection;if(!h(r)||!r.empty)return!1;let i=r.$head;if(!i.parent.isTextblock||i.parent.type.spec.code)return!1;let a=e===-1?I(t,r.head):L(t,r.head);if(a==null)return!1;let o=Ln(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 Un=Hn(-1),Wn=Hn(1);function Gn(){return new y({key:zn,props:{handleDOMEvents:{beforeinput:(e,t)=>{if(e.composing)return!1;let n=t.inputType===`deleteContentBackward`?Un:t.inputType===`deleteContentForward`?Wn:void 0;return n==null||!En(e,n)?!1:(t.preventDefault(),!0)}}}})}function Kn(){return g(m(Bn()),m(Gn()),_(l({Enter:Vn,Backspace:Un,Delete:Wn}),t.highest))}function qn(){return f({type:`horizontalRule`,attr:`marker`,default:null,toDOM:e=>e?[`data-hr-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-hr-marker`)})}function Jn(){return g(Be(),qn())}function Yn(){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 Xn(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function Zn(e,t){let[n,r,i]=t;return[n,r,i.map(t=>Ie.fromJSON(e,t))]}function Qn(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}var R=class e extends Ke{constructor(e){super(),this.chunks=e}apply(e){if(this.chunks.length===0)return qe.ok(e);let t=e.content.size,n;for(let[r,i,a]of this.chunks){if(r>=i)continue;let o=Math.max(0,Math.min(r,t)),s=Math.max(o,Math.min(i,t));if(o>=s)continue;let c=Ie.setFrom(a);e.nodesBetween(o,s,(t,r)=>{if(!t.isText)return!0;let i=Math.max(o,r),a=Math.min(s,r+t.nodeSize);if(i>=a)return!1;let l=t.marks;if(Qn(l,c))return!1;n??=new Je(e);for(let e of l)n.removeMark(i,a,e);for(let e of c)n.addMark(i,a,e);return!1})}return qe.ok(n?n.doc:e)}invert(e){if(this.chunks.length===0)return $n;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 Ge(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(Xn)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>Zn(t,e)))}};Ke.jsonID(`batchSetMark`,R);const $n=new R([]),er=new Set([`com`,`br`,`net`,`jp`,`org`,`in`,`de`,`ru`,`it`,`fr`]),tr=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;function nr(e){let t=e.indexOf(`/`);return t===-1?e:e.slice(0,t)}function rr(e){let t=e.split(`.`);if(t.length<2)return!1;let n=t[t.length-1].toLowerCase();if(!er.has(n)||t[t.length-2].length<3)return!1;for(let e of t)if(e.length>63||!tr.test(e))return!1;return!0}function ir(e){if(/^[a-z][a-z0-9+.-]*:/i.test(e))return e;if(/^[^\s@]+@[^\s@]+$/.test(e))return`mailto:${e}`;if(/^www\./i.test(e)||rr(nr(e)))return`https://${e}`}function z(e){return e===32||e===9||e===10||e===13}const ar=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:\/[^\s<]*)?/i,or=/[\s(*_~]/;function sr(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45}function cr(e,t,n){let r=0;for(let i=0;i<t;i++)e[i]===n&&r++;return r}function lr(e){let t=e.length;for(;;){let n=e[t-1];if(/[?!.,:*_~]/.test(n)||n===`)`&&cr(e,t,`)`)>cr(e,t,`(`))t--;else if(n===`;`){let n=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(0,t));if(!n)break;t=n.index}else break}return t}const ur={parseInline:[{name:`BareAutolink`,before:`Link`,parse(e,t,n){if(!sr(t)||e.hasOpenLink)return-1;let r=e.slice(n-1,n);if(r!==``&&!or.test(r))return-1;let i=ar.exec(e.slice(n,e.end));if(!i)return-1;let a=lr(i[0]);return a===0||!rr(nr(i[0].slice(0,a)))?-1:e.addElement(e.elt(`URL`,n,n+a))}}]};function dr(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45||e===95||e>127&&/[\p{L}\p{N}]/u.test(String.fromCharCode(e))}function fr(e){return e>=65&&e<=90||e>=97&&e<=122||e>127&&/\p{L}/u.test(String.fromCharCode(e))}const pr={defineNodes:[{name:`Hashtag`}],parseInline:[{name:`Hashtag`,parse(e,t,n){if(t!==35||!/\s|^$/.test(e.slice(n-1,n)))return-1;let r=n+1,i=!1;for(;r<e.end;){let t=e.char(r);if(!dr(t))break;i||=fr(t),r++}return i?e.addElement(e.elt(`Hashtag`,n,r)):-1}}]},mr={resolve:`Highlight`,mark:`HighlightMark`},hr=/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~\u{A1}\u{2010}-\u{2027}]/u,gr={defineNodes:[{name:`Highlight`},{name:`HighlightMark`}],parseInline:[{name:`Highlight`,after:`Emphasis`,parse(e,t,n){if(t!==61||e.char(n+1)!==61||e.char(n+2)===61)return-1;let r=e.slice(n-1,n),i=e.slice(n+2,n+3),a=/\s|^$/.test(r),o=/\s|^$/.test(i),s=hr.test(r),c=hr.test(i);return e.addDelimiter(mr,n,n+2,!o&&(!c||a||s),!a&&(!s||o||c))}}]};function _r(e){return e>=48&&e<=57}function vr(e){return e.next!==36||e.text.charCodeAt(e.pos+1)!==36||e.text.charCodeAt(e.pos+2)===36?!1:e.skipSpace(e.pos+2)===e.text.length}function yr(e){let t=e.depth;return typeof t==`number`?t:2**53-1}const br={defineNodes:[{name:`InlineMath`},{name:`InlineMathMark`},{name:`BlockMath`,block:!0},{name:`BlockMathMark`}],parseBlock:[{name:`BlockMath`,before:`FencedCode`,parse(e,t){if(!vr(t))return!1;let n=e.lineStart+t.pos,r=[e.elt(`BlockMathMark`,n,n+2)];for(let n=!0,i=!0,a=!1;!(!e.nextLine()||yr(t)<e.depth);n=!1){if(vr(t)){i&&a&&r.push(e.elt(`CodeText`,e.lineStart-1,e.lineStart)),r.push(e.elt(`BlockMathMark`,e.lineStart+t.pos,e.lineStart+t.pos+2)),e.nextLine();break}a=!0,n||(r.push(e.elt(`CodeText`,e.lineStart-1,e.lineStart)),i=!1);let o=e.lineStart+t.basePos,s=e.lineStart+t.text.length;o<s&&(r.push(e.elt(`CodeText`,o,s)),i=!1)}return e.addElement(e.elt(`BlockMath`,n,e.prevLineEnd(),r)),!0},endLeaf(e,t){return vr(t)}}],parseInline:[{name:`InlineMath`,after:`InlineCode`,parse(e,t,n){if(t!==36||e.char(n-1)===36)return-1;let r=e.char(n+1)===36?2:1;if(e.char(n+r)===36)return-1;let i=n+r;if(z(e.char(i)))return-1;for(let t=i;t<e.end;t++){let a=e.char(t);if(a===10)return-1;if(a===92){t++;continue}if(a!==36)continue;let o=1;for(;e.char(t+o)===36;)o++;if(o!==r||z(e.char(t-1))||_r(e.char(t+o)))return-1;let s=t+o;return e.addElement(e.elt(`InlineMath`,n,s,[e.elt(`InlineMathMark`,n,i),e.elt(`InlineMathMark`,t,s)]))}return-1}}]},xr=/^[a-z][a-z0-9+.-]*:\/\/[^\s<]+/i;function Sr(e){return e>=65&&e<=90||e>=97&&e<=122}const Cr={parseInline:[{name:`SchemeAutolink`,after:`Autolink`,parse(e,t,n){if(!Sr(t)||e.hasOpenLink)return-1;let r=e.slice(n-1,n);if(r!==``&&!or.test(r))return-1;let i=xr.exec(e.slice(n,e.end));if(!i)return-1;let a=lr(i[0]);return a<=i[0].indexOf(`://`)+3?-1:e.addElement(e.elt(`URL`,n,n+a))}}]},wr={defineNodes:[{name:`Wikilink`},{name:`WikilinkMark`}],parseInline:[{name:`Wikilink`,before:`Link`,parse(e,t,n){if(t!==91||e.char(n+1)!==91)return-1;let r=!1;for(let t=n+2;t<e.end-1;t++){let i=e.char(t);if(i===93){if(e.char(t+1)!==93||!r)return-1;let i=t+2;return e.addElement(e.elt(`Wikilink`,n,i,[e.elt(`WikilinkMark`,n,n+2),e.elt(`WikilinkMark`,t,i)]))}if(i===91||i===10)return-1;i!==32&&i!==9&&(r=!0)}return-1}}]};function Tr(e){return e.end}const Er=Xe.configure([Ye,pr,wr,ur,Cr,gr,br]),Dr=Er.configure({parseInline:[{name:`SkipInline`,before:`Escape`,parse:Tr}]});function B(e){return Er.parseInline(e,0)}function V(e,t,n=[]){for(let r of e)t(r)&&n.push(r),V(r.children,t,n);return n}function Or(e){let t={};for(let n of e.nodeSet.types)t[n.name]=n.id;return t}const H=Or(Er),kr=/^<!--\s*(\{[^}]*\})\s*-->$/,Ar=/<!--\s*\{[^}]*\}\s*-->$/;function jr(e){let t=kr.exec(e.trim());if(!t)return;let n;try{n=JSON.parse(t[1])}catch{return}if(typeof n!=`object`||!n)return;let r=Mr(n);return Object.keys(r).length>0?r:void 0}function Mr(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 Nr(e){return`<!-- ${JSON.stringify(e)} -->`}function Pr(e){return e.replace(Ar,``)}function Fr(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 Ir(){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 Lr(){return d({name:`mdWikilink`,constructor:Ir()})}const Rr=new Map([[H.Emphasis,`mdEm`],[H.StrongEmphasis,`mdStrong`],[H.InlineCode,`mdCode`],[H.Strikethrough,`mdDel`],[H.Highlight,`mdHighlight`],[H.EmphasisMark,`mdMark`],[H.CodeMark,`mdMark`],[H.LinkMark,`mdMark`],[H.StrikethroughMark,`mdMark`],[H.HighlightMark,`mdMark`],[H.URL,`mdLinkUri`],[H.LinkTitle,`mdLinkTitle`],[H.Hashtag,`mdTag`],[H.WikilinkMark,`mdMark`]]);function zr(e,t,n){let r=B(t),i=[];return Vr(r,[],0,t.length,t,e,i,n),i}function Br(e){return e.slice(1,-1).replaceAll(/\\(.)/g,`$1`)}function Vr(e,t,n,r,i,a,o,s){let c=n;for(let n=0;n<e.length;n++){let r=e[n];r.from>c&&U(o,c,r.from,t);let l=r.type;if(l===H.Link){let e=Wr(r,t,i,a,s);e?U(o,r.from,r.to,e):Gr(r,t,i,a,o)}else if(l===H.Image){let s=Kr(r,e[n+1],i);qr(r,t,i,a,o,s),s&&n++,c=s?s.to:r.to;continue}else if(l===H.Wikilink)Yr(r,t,i,a,o);else if(l===H.InlineMath)Jr(r,t,i,a,o);else if(l===H.URL){let e=ir(i.slice(r.from,r.to)),n=e?a.mdLinkText.create({href:e}):a.mdLinkUri.create();U(o,r.from,r.to,[...t,n])}else{let e;l===H.Emphasis?e=`italic`:l===H.StrongEmphasis?e=`bold`:l===H.InlineCode?e=`code`:l===H.Strikethrough?e=`strike`:l===H.Highlight?e=`highlight`:l===H.Autolink&&(e=`autolink`);let n=e?[...t,a.mdPack.create({key:e})]:t,c=Rr.get(l),u=c?[...n,a[c].create()]:n;r.children.length===0?U(o,r.from,r.to,u):Vr(r.children,u,r.from,r.to,i,a,o,s)}c=r.to}c<r&&U(o,c,r,t)}function Hr(e){let t=-1,n=-1,r=null,i=null,a=0;for(let o of e.children)o.type===H.LinkMark?(a++,a===1&&(t=o.to),a===2&&(n=o.from)):o.type===H.URL&&r===null?r=o:o.type===H.LinkTitle&&i===null&&(i=o);return{labelFrom:t,labelTo:n,urlNode:r,titleNode:i}}function Ur(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function Wr(e,t,n,r,i){let a=i?.resolveFileLink;if(!a)return;let{labelFrom:o,labelTo:s,urlNode:c,titleNode:l}=Hr(e);if(o<0||s<0||!c)return;let u=n.slice(c.from,c.to);if(!u)return;let d=n.slice(o,s),f=l?Br(n.slice(l.from,l.to)):``;if(!a({href:u,label:d,title:f}))return;let p=d||Ur(u);return[...t,r.mdFile.create({href:u,name:p,title:f})]}function Gr(e,t,n,r,i){let{labelTo:a,urlNode:o,titleNode:s}=Hr(e),c=o?n.slice(o.from,o.to):``,l=s?Br(n.slice(s.from,s.to)):``,u=c?r.mdLinkText.create({href:c}):null,d=e=>a>=0&&e<a&&u!==null,f=r.mdPack.create({key:`link`,data:{href:c,title:l}}),p=[...t,f],m=e.from;for(let t of e.children){if(t.from>m){let e=d(m)?[...p,u]:p;U(i,m,t.from,e)}let e=d(t.from)?[...p,u]:p;if(t.type===H.Wikilink){Yr(t,e,n,r,i),m=t.to;continue}let a=Rr.get(t.type),o=a?[...e,r[a].create()]:e;t.children.length===0?U(i,t.from,t.to,o):Vr(t.children,o,t.from,t.to,n,r,i,void 0),m=t.to}m<e.to&&U(i,m,e.to,p)}function Kr(e,t,n){if(!t||t.type!==H.Comment||t.from!==e.to)return;let r=jr(n.slice(t.from,t.to));if(r)return{magic:r,to:t.to}}function qr(e,t,n,r,i,a){let o=e.children.find(e=>e.type===H.URL);if(!o){Gr(e,t,n,r,i);return}let s=e.children.filter(e=>e.type===H.LinkMark),c=e.children.find(e=>e.type===H.LinkTitle),l=n.slice(o.from,o.to),u=s.length>=2?n.slice(s[0].to,s[1].from):``,d=c?Br(n.slice(c.from,c.to)):``,f=a?.magic.width??null,p=a?.magic.height??null,m=a?.to??e.to;U(i,e.from,m,[...t,r.mdImage.create({src:l,alt:u,title:d,width:f,height:p})])}function Jr(e,t,n,r,i){let a=e.children.filter(e=>e.type===H.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 Yr(e,t,n,r,i){let{target:a,display:o}=Fr(n.slice(e.from,e.to));U(i,e.from,e.to,[...t,r.mdWikilink.create({target:a,display:o})])}function U(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&Qn(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const Xr=`inline-marks-applied`;let Zr=0,Qr=0;function $r(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 ei(e){let t=new WeakMap;function n(n,r,i){let a=t.get(n);if(a?Qr++:(Zr++,a=zr(xo(i),n.textContent,e),t.set(n,a)),r===0)return a;let o=[];for(let[e,t,n]of a)o.push([e+r,t+r,n]);return o}function r(e,t){let r=[];return e.doc.nodesBetween(t.from,t.to,(t,i)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;if(t.childCount===0)return!1;let a=n(t,i+1,e.schema);return a.length>0&&r.push(...a),!1}),r}return new y({key:new b(`inline-mark`),appendTransaction(e,t,n){for(let t of e)if(t.getMeta(Xr))return null;let i=r(n,$r(e,n));if(i.length===0)return null;let a=n.tr.step(new R(i));return a.setMeta(Xr,!0),a.setMeta(`addToHistory`,!1),a},view(e){return e.dispatch(ti(e.state)),{}}})}function ti(e){return e.tr.setMeta(`inline-marks-trigger`,!0)}function ni(e){return m(ei(e))}function ri(){return u({name:`mdImage`,inclusive:!1,attrs:{src:{default:``},alt:{default:``},title:{default:``},width:{default:null},height:{default:null}},toDOM:()=>[`span`,{class:`md-image`},0],parseDOM:[{tag:`span.md-image`}]})}function ii(){return u({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function ai(){return u({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function oi(){return u({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function si(){return u({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function ci(){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 li(){return u({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function ui(){return u({name:`mdLinkTitle`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-title`},0],parseDOM:[{tag:`span.md-link-title`}]})}function di(){return u({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function fi(){return u({name:`mdHighlight`,toDOM:()=>[`mark`,0],parseDOM:[{tag:`mark`}]})}function pi(){return u({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function mi(){return u({name:`mdWikilink`,inclusive:!1,attrs:{target:{default:``},display:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink`},0],parseDOM:[{tag:`span.md-wikilink`}]})}function hi(){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 gi(){return u({name:`mdMath`,inclusive:!1,attrs:{formula:{default:``}},toDOM:()=>[`span`,{class:`md-math`},0],parseDOM:[{tag:`span.md-math`}]})}function _i(){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 vi(){return g(ii(),ai(),oi(),si(),ci(),li(),ui(),di(),fi(),pi(),mi(),ri(),hi(),gi(),_i())}function yi(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 bi(e,t=0){return yi(e,96,t)}const W={em:{node:H.Emphasis,delim:`*`},strong:{node:H.StrongEmphasis,delim:`**`},code:{node:H.InlineCode,delim:"`"},del:{node:H.Strikethrough,delim:`~~`},highlight:{node:H.Highlight,delim:`==`}},xi=new Set([H.EmphasisMark,H.CodeMark,H.LinkMark,H.StrikethroughMark,H.HighlightMark]);function Si(e){return[e.children[0],e.children.at(-1)]}function Ci(e){let{type:t,children:n}=e;if(t===H.Emphasis||t===H.StrongEmphasis||t===H.Strikethrough||t===H.Highlight)return[n[0].to,n.at(-1).from];if(t===H.Link||t===H.Image){let e=n.find((e,t)=>t>0&&e.type===H.LinkMark);return e?[n[0].to,e.from]:null}return null}function wi(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=Ci(r);return i&&i[0]<=t&&n<=i[1]?wi(r.children,t,n):wi(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function Ti(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return Ti(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}function Ei(e,t,n){for(;t<n&&z(e.charCodeAt(t));)t++;for(;n>t&&z(e.charCodeAt(n-1));)n--;return[t,n]}function Di(e,t,n,r){let i=V(B(e),e=>e.type===r.node||xi.has(e.type));for(let r=t;r<n;r++)if(!z(e.charCodeAt(r))&&i.every(e=>!(e.from<=r&&r<e.to)))return!1;return!0}function Oi(e,t,n,r,i){let a=B(e),o=V(a,e=>e.type===r.node);return i?ji(e,o,t,n):ki(e,a,o,t,n,r)}function ki(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=wi(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]=Si(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=Ai(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function Ai(e,t,n,r,i){if(i.node!==H.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(bi(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function ji(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=Si(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=Ti(a.children.slice(1,-1),s,c);s>t.to&&z(e.charCodeAt(s-1));)s--;for(;c<o.from&&z(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 Mi(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=B(e),o=V(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=Si(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return Ni(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function Ni(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=Ci(n);return!e||t<e[0]||t>e[1]?!0:Ni(n.children,t)}return!1}function G(e){return(t,n)=>{if(t.selection.empty)return Pi(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]=Ei(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:Di(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>Oi(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(x.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 Pi(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=Mi(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(x.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(x.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function Fi(){return o({toggleEm:()=>G(W.em),toggleStrong:()=>G(W.strong),toggleCode:()=>G(W.code),toggleDel:()=>G(W.del),toggleHighlight:()=>G(W.highlight)})}function Ii(){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 Li(){return g(Fi(),Ii())}function Ri(e,t,n){let r;return e.doc.nodesBetween(t.from,t.to,(e,i)=>(e.isText&&e.marks.some(e=>e.type.name===n)&&(r={from:Math.max(i,t.from),to:Math.min(i+e.nodeSize,t.to)}),!0)),r}function K(e,t){let n=D(e,t,`mdLinkText`),r=D(e,t,`mdPack`,{key:`link`})??D(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`)return{unit:{from:i.from,to:i.to},href:o,title:``};let s=Ri(e,i,`mdLinkUri`),c=s?s.from-2:i.to-3,l=s?s.from:i.to-1;return{unit:{from:i.from,to:i.to},label:{from:i.from+1,to:c},dest:{from:l,to:i.to-1},href:a.data.href,title:a.data.title}}function zi(e){let t=e.trim();return t?ir(t)??t:``}function Bi(e,t){return e+(t?` "${t.replaceAll(/(["\\])/g,String.raw`\$1`)}"`:``)}function Vi(e){let{selection:t}=e,{$from:n,$to:r,empty:i}=t;if(i||!n.sameParent(r)||!h(t))return;let a=n.parent;if(!a.isTextblock||a.type.spec.code)return;let o=n.start(),[s,c]=Ei(a.textContent,n.parentOffset,r.parentOffset);if(!(s>=c))return{from:o+s,to:o+c}}function Hi({href:e,title:t,wrapText:n=!0}={}){return(r,i)=>{let a=Vi(r);if(!a)return!1;if(i){let{from:o,to:s}=a,c=r.tr,l=`](${Bi(zi(e??``),t??``)})`;c.insertText(l,s).insertText(`[`,o);let u=s+1+l.length;c.setSelection(n?x.create(c.doc,o,u):x.create(c.doc,u)),c.scrollIntoView(),i(c)}return!0}}function Ui(e){return(t,n)=>{let r=K(t,t.selection.from);if(!r?.dest)return!1;let i=Bi(zi(e.href??r.href),e.title??r.title);return n&&n(t.tr.insertText(i,r.dest.from,r.dest.to).scrollIntoView()),!0}}function Wi(){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 Gi(){return o({insertLink:Hi,updateLink:Ui,removeLink:Wi})}function Ki(e){return(t,n,r)=>{let i=K(t,t.selection.from);if(i){if(n&&r){let{unit:{from:a,to:o}}=i;n(t.tr.setSelection(x.create(t.doc,a,o)).scrollIntoView()),r.focus(),e({from:a,to:o,link:i})}return!0}let a=Vi(t);if(a){if(n&&r){let{from:i,to:o}=a;n(t.tr.setSelection(x.create(t.doc,i,o)).scrollIntoView()),r.focus(),e({from:i,to:o,link:void 0})}return!0}return!1}}function qi(e){return l({"Mod-k":Ki(e)})}function Ji(){return f({type:`list`,attr:`marker`,default:null,splittable:!0,toDOM:e=>e===`)`||e===`*`||e===`+`?[`data-list-marker`,e]:null,parseDOM:e=>{let t=e.getAttribute(`data-list-marker`);return t===`)`||t===`*`||t===`+`?t:null}})}function Yi(){return f({type:`list`,attr:`taskMarker`,default:null,splittable:!0,toDOM:e=>e===`X`?[`data-list-task-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-list-task-marker`)===`X`?`X`:null})}function Xi(e){return e===2||e===3||e===4}function Zi(){return f({type:`list`,attr:`markerGap`,default:1,splittable:!0,toDOM:e=>Xi(e)?[`data-list-marker-gap`,String(e)]:null,parseDOM:e=>{let t=Number.parseInt(e.getAttribute(`data-list-marker-gap`)??``,10);return Xi(t)?t:1}})}const Qi=[E(/^\s?([*-])\s$/,{kind:`bullet`,collapsed:!1}),E(/^\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}}),E(/^\s?\[([\sX]?)\]\s$/i,({match:e})=>({kind:`task`,checked:[`x`,`X`].includes(e[1]),collapsed:!1})),E(/^\s?\+\s$/,{kind:`task`,marker:`+`,checked:!1,collapsed:!1})];function $i(){return g(Qi.map(Me))}function ea(){return T({kind:`task`,marker:`+`})}function ta(){return T({kind:`task`,marker:null})}function na(){return o({wrapInCircleTask:ea,wrapInSquareTask:ta})}function ra(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.name===`list`)return n.attrs}return null}function ia(){return(e,t,n)=>{let r=ra(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},T(a)(e,t,n)}}function aa(){return(e,t,n)=>{let r=ra(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},T(a)(e,t,n)}}function oa(e){return e.type.name===`list`&&e.attrs.kind===`bullet`&&e.childCount>=2&&e.firstChild?.type!==e.type}const sa=e=>{let t=e.attrs;return t.kind===`task`?{...t,checked:!t.checked}:oa(e)?{...t,collapsed:!t.collapsed}:t};function ca(){return m(()=>[new y({props:{handleDOMEvents:{mousedown:(e,t)=>st({view:e,event:t,onListClick:sa})}}}),it(),new y({props:{transformCopied:ct}}),at()])}function la(){return o({toggleListCollapsed:()=>ot({isToggleable:oa})})}function ua(){return l({"Mod-Enter":ia(),"Mod-Shift-Enter":aa(),"Mod-.":ot({isToggleable:oa}),"Mod-Shift-7":rt({kind:`ordered`,collapsed:!1}),"Mod-Shift-8":rt({kind:`bullet`,collapsed:!1}),"Mod-Shift-9":rt({kind:`task`,checked:!1,collapsed:!1})})}function da(){return g(tt(),ca(),$e(),Ze(),et(),Qe(),$i(),ua(),Ji(),Yi(),Zi(),na(),la())}let fa;function pa(){return fa??=import(`katex`).then(e=>e.render),fa}function ma(e,t,n,r){try{e(n,t,{displayMode:r,throwOnError:!1,output:`mathml`})}catch(e){t.textContent=String(e)}}var ha=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=x.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;pa().then(t=>{e===this.#r&&ma(t,this.#n,e,!1)})}};function ga(){return d({name:`mdMath`,constructor:(e,t)=>new ha(e,t)})}function _a(e){return e===`left`||e===`center`||e===`right`?e:null}function va(){return f({type:`tableCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>_a(e.getAttribute(`data-align`))})}function ya(){return f({type:`tableHeaderCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>_a(e.getAttribute(`data-align`))})}function ba(e){for(let t=0;t<e.childCount;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++)if(n.child(e).type.name===`tableHeaderCell`)return t}return 0}function xa(e){return e.child(ba(e))}function Sa(e,t){return t>=e.childCount?null:e.child(t).attrs.align??null}function Ca(e,t,n){if(e.childCount===0)return;let r=xa(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=Sa(r,e);(t.attrs.align??null)!==i&&n.setNodeMarkup(o,void 0,{...t.attrs,align:i}),o+=t.nodeSize}i+=a.nodeSize}}function wa(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 Ta(){return new y({key:new b(`table-align-sync`),appendTransaction(e,t,n){if(!e.some(e=>e.docChanged))return;let r=wa(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)=>e.type.name===`table`?(s??=n.tr,Ca(e,t,s),!1):!0),s?.docChanged?s:void 0}})}function Ea(){return m(Ta())}function Da(e){let{selection:t}=e;if(_t(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 Oa(e){return(t,n)=>{let r=Da(t);if(!r||r.table.childCount===0)return!1;if(n){let{table:i,tablePos:a,firstColumn:o,lastColumn:s}=r,c=ba(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 ka(e){let t=Da(e);if(!(!t||t.table.childCount===0))return Sa(xa(t.table),t.lastColumn)??void 0}function Aa(){return o({setTableColumnAlign:Oa})}function ja(){return g(va(),ya(),Ea(),Aa())}function Ma(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 Na=`paragraph`;function Pa(){return g(p({name:`tableCell`,content:Na}),p({name:`tableHeaderCell`,content:Na}))}const Fa=(e,t)=>{let{selection:n}=e;return!_t(n)||!n.isColSelection()||!n.isRowSelection()?!1:gt(e,t)};function Ia(){return _(l({Backspace:Fa,Delete:Fa}),t.high)}function La(){return g(ht(),mt(),lt(),pt(),Pa(),ja(),ft({allowTableNodeSelection:!0}),ut(),dt(),Ia())}function Ra(e){let{selection:t}=e,{$from:n,$to:r}=t;if(oe(t)&&n.depth===0||n.depth>0&&r.depth>0&&n.index(0)===r.index(0))return n.index(0)}function za(e){return(t,n)=>{if(Ma(t))return!1;let r=Ra(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=oe(a)?we.create(u.doc,a.from+d):x.create(u.doc,a.anchor+d,a.head+d);u.setSelection(f),n(u.scrollIntoView())}return!0}}function Ba(e){return(t,n,r)=>nt(e)(t,n,r)||za(e===`up`?-1:1)(t,n,r)}function Va(){return l({"Alt-ArrowUp":Ba(`up`),"Alt-ArrowDown":Ba(`down`)})}function Ha(){return p({name:`paragraph`,content:`inline*`,group:`block`,whitespace:`pre`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}})}function Ua(){return g(_(Ha(),t.highest),vt(),yt())}const q=new b(`meowdownPendingReplacement`);function J(e){return q.getState(e)?.pending??null}function Wa(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 Ga=new y({key:q,state:{init:()=>({pending:null}),apply:(e,t)=>{let n=e.getMeta(q);if(n)return Wa(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=J(e);return!t||t.from>=t.to?null:C.create(e.doc,[S.inline(t.from,t.to,{class:`md-pending-replacement`})])}}});function Ka(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 qa(e){return(t,n)=>J(t)?(n?.(t.tr.setMeta(q,{type:`append`,text:e})),!0):!1}function Ja(){return(e,t)=>J(e)?(t?.(e.tr.setMeta(q,{type:`discard`})),!0):!1}function Ya(e={}){return(t,n)=>{let r=J(t);if(!r||!r.text.trim())return!1;if(n){let i=e.mode??r.mode,a=Co(t.schema),o=Z(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(x.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?.type.name===`paragraph`&&e.sameParent(n)&&e.parent.isTextblock?(s.replaceWith(r.from,r.to,i.content),s.setSelection(x.near(s.doc.resolve(r.from+i.content.size),-1))):(s.replaceRange(r.from,r.to,new w(o.content,0,0)),s.setSelection(x.near(s.doc.resolve(s.mapping.map(r.to)),-1)))}n(s.scrollIntoView())}return!0}}function Xa(){return o({startPendingReplacement:Ka,appendPendingReplacementText:qa,acceptPendingReplacement:Ya,discardPendingReplacement:Ja})}function Za(){return l({"Mod-Enter":Ya(),Escape:Ja()})}function Qa(){return g(m(Ga),Xa(),Za())}function $a(e){return m(new y({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 Y(e,t){return(n,r)=>{let i=e<0?Te.atStart(n.doc):Te.atEnd(n.doc),a=t?x.between(n.selection.$anchor,i.$head):i;return n.selection.eq(a)||r?.(n.tr.setSelection(a).scrollIntoView()),!0}}function eo(){return l({"Meta-ArrowUp":Y(-1,!1),"Meta-ArrowDown":Y(1,!1),"Shift-Meta-ArrowUp":Y(-1,!0),"Shift-Meta-ArrowDown":Y(1,!0)})}function to(e){return e.left===0&&e.top===0&&e.right===0&&e.bottom===0}function X(e,t,n){if(t<0||t>e.state.doc.content.size)return;let r;try{r=e.coordsAtPos(t,n)}catch{return}return to(r)?void 0:r}function no(e){e.offsetWidth}const ro=new b(`meowdown-virtual-caret`),io=[`md-virtual-caret-blink`,`md-virtual-caret-blink2`];function ao(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 oo(e){let t=e.state,n=t.selection.head,r=I(t,n),i=L(t,n),a=r==null,o=[[n,a],[n,!a]];r!=null&&o.push([r.from,!0]),i!=null&&o.push([i.to,!1]);for(let[t,n]of o){let r=X(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 so(e){let t=e.state,n=t.selection.head;for(let r of Rt){let i=D(t,n,r);if(i==null||i.from!==n&&i.to!==n)continue;let a=co(e,i.from+1);if(a==null)continue;let o=a.getBoundingClientRect();if(o.height!==0)return{left:i.to===n?o.right:o.left,top:o.top,height:o.height}}}function co(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 lo(e){let t=e.height*.19999999999999996;return{left:e.left,top:e.top-t/2,height:e.height+t}}function uo(e){let t=ao(e)??oo(e);return t==null?so(e):lo(t)}function fo(e,t){return e==null||t==null?e===t:e.left===t.left&&e.top===t.top&&e.height===t.height}var po=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=io[this.#s]}#l=()=>{let e=this.#e;if(e.isDestroyed)return;let t=e.state,n=t.selection,r=h(n)&&n.empty?uo(e):void 0,i=r!=null&&k(t)===`hide`?In(t,n.head):void 0;if(fo(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`;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`,a&&(no(this.#n),this.#n.style.transitionProperty=``)}};function mo(){return m(new y({key:ro,view:e=>new po(e)}))}function ho(e){return g(Ua(),ye(),yn(),Se(),ve(),da(),Tn(),La(),dn(),Jn(),Yn(),vi(),tn(),vn(),Va(),eo(),ni(e),Li(),Gi(),Lr(),ga(),Nt(e.markMode??`focus`),mo(),Kn(),Yt({marks:Rt.map(e=>({name:e,modes:[`hide`,`focus`,`show`]}))}),a(),i(),c(),be(),Ce(),xe(),gn(),Qa())}function go(e={}){return ho(e)}const _o=v(()=>{let e=go().schema;if(e==null)throw Error(`Unexpected empty schema`);return e}),vo=v(()=>r(_o())),yo=v(()=>n(_o())),bo=`meowdown_mark_builders`;function xo(e){let t=e.cached[bo];if(t)return t;let r=n(e);return e.cached[bo]=r,r}const So=`meowdown_node_builders`;function Co(e){let t=e.cached[So];if(t)return t;let n=r(e);return e.cached[So]=n,n}function Z(e,t={}){let{nodes:n=vo(),frontmatter:r=!1}=t,i,a=e;if(r){let[t,n]=To(e);i=t,n&&(a=e.slice(n))}let o=Eo(n,Dr.parse(a).cursor(),a);return n.doc(i===void 0?{}:{frontmatter:i},o)}const wo=/^---[ \t]*\r?\n([\s\S]*?\n)?---[ \t]*(?:\r?\n|$)/;function To(e){let t=wo.exec(e);return t?[(t[1]??``).replace(/\r?\n$/,``),t[0].length]:[]}function Eo(e,t,n){let r=[];if(!t.firstChild())return r;let i;do i!=null&&Do(r,e,n,i,t.from),i=t.to,r.push(...Oo(e,t,n));while(t.nextSibling());return t.parent(),r}function Do(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 Oo(e,t,n){switch(t.type.id){case H.ATXHeading1:return[Q(e,t,n,1,!1)];case H.ATXHeading2:return[Q(e,t,n,2,!1)];case H.ATXHeading3:return[Q(e,t,n,3,!1)];case H.ATXHeading4:return[Q(e,t,n,4,!1)];case H.ATXHeading5:return[Q(e,t,n,5,!1)];case H.ATXHeading6:return[Q(e,t,n,6,!1)];case H.SetextHeading1:return[Q(e,t,n,1,!0)];case H.SetextHeading2:return[Q(e,t,n,2,!0)];case H.Paragraph:return[Po(e,t,n)];case H.CommentBlock:return[Fo(e,t,n)];case H.HTMLBlock:case H.ProcessingInstructionBlock:return[Po(e,t,n)];case H.Blockquote:return[Io(e,t,n)];case H.BulletList:return Lo(e,t,n,`bullet`);case H.OrderedList:return Lo(e,t,n,`ordered`);case H.FencedCode:case H.CodeBlock:return[zo(e,t,n)];case H.BlockMath:return[Bo(e,t,n)];case H.HorizontalRule:{let r=n.slice(t.from,t.to).trimEnd();return[e.horizontalRule({marker:r===`---`?null:r})]}case H.Table:return[Vo(e,t,n)];case H.Task:return[Po(e,t,n)];default:return n.slice(t.from,t.to).trim()===``?[]:(console.warn(`[meowdown] unsupported lezer block "${t.type.name}"`),[Po(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===H.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===H.HeaderMark&&n>o&&(s=n,c=n,l=r),t.parent()}let u=Mo(n.slice(o,s),$(n,o)).trim(),d=i?ko(n,c,l)||1:null,f=!i&&c>=0&&Ao(n,c,l)||null;return e.heading({level:r,setextUnderline:d,closingHashes:f},u)}function ko(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 Ao(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(`
|
|
3
|
+
`,t-1)+1,r=0;for(let i=n;i<t;i++)r+=e.charCodeAt(i)===9?4-r%4:1;return r}function jo(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 Mo(e,t){return t===0||!e.includes(`
|
|
4
4
|
`)?e:e.split(`
|
|
5
|
-
`).map((e,n)=>n===0?e:
|
|
6
|
-
`)}function
|
|
5
|
+
`).map((e,n)=>n===0?e:jo(e,t)).join(`
|
|
6
|
+
`)}function No(e,t,n){return e.paragraph(Mo(t,n))}function Po(e,t,n){let r=t.from,i=t.to,a=$(n,r);if(t.firstChild()){let o=``,s=r;do t.type.id===H.QuoteMark&&(o+=n.slice(s,t.from),s=t.to,z(n.charCodeAt(s))&&(s+=1));while(t.nextSibling());return t.parent(),o+=n.slice(s,i),No(e,o,a)}return No(e,n.slice(r,i),a)}function Fo(e,t,n){let r=$(n,t.from),i=Mo(n.slice(t.from,t.to),r);return e.htmlComment({content:i})}function Io(e,t,n){let r=[];if(t.firstChild()){let i;do{if(t.type.id===H.QuoteMark)continue;i!=null&&Do(r,e,n,i,t.from),i=t.to,r.push(...Oo(e,t,n))}while(t.nextSibling());t.parent()}return e.blockquote(r)}function Lo(e,t,n,r){let i=[];if(t.firstChild()){do t.type.id===H.ListItem&&i.push(Ro(e,t,n,r));while(t.nextSibling());t.parent()}return i}function Ro(e,t,n,r){let i=[],a,o,s,c,l,u;if(t.firstChild()){do{if(t.type.id!==H.ListMark&&u==null&&(u=$(n,t.from)),t.type.id===H.ListMark){if(r===`ordered`){let e=n.charCodeAt(t.to-1);e===41?c=`)`:e===46&&(c=`.`);let r=Number.parseInt(n.slice(t.from,t.to),10);s=Number.isFinite(r)?r:1}else{let e=n.charCodeAt(t.from);c=e===42?`*`:e===43?`+`:`-`}l=$(n,t.to);continue}if(r===`bullet`&&t.type.id===H.Task){let r=t.from,s=t.to;if(a=!1,t.firstChild()){if(t.type.id===H.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()}z(n.charCodeAt(r))&&(r+=1);let c=n.slice(r,s);i.push(No(e,c,$(n,r)));continue}i.push(...Oo(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===`+`;return e.list({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},i)}function zo(e,t,n){let r=t.type.id===H.CodeBlock,i=``,a=``,o=r?`indented`:null,s=null,c=!1;if(t.firstChild()){do switch(t.type.id){case H.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 H.CodeInfo:i=n.slice(t.from,t.to);break;case H.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 Bo(e,t,n){let r=``;if(t.firstChild()){do t.type.id===H.CodeText&&(r+=n.slice(t.from,t.to));while(t.nextSibling());t.parent()}return e.codeBlock({language:`math`,fenceStyle:`dollar`,fenceLength:null},r)}function Vo(e,t,n){let r=[];if(t.firstChild()){do t.type.id===H.TableDelimiter&&(r=Ho(n.slice(t.from,t.to)));while(t.nextSibling());t.parent()}let i=[];if(t.firstChild()){do{let a=t.type.id;a===H.TableHeader?i.push(Uo(e,t,n,!0,r)):a===H.TableRow&&i.push(Uo(e,t,n,!1,r))}while(t.nextSibling());t.parent()}return e.table(i)}function Ho(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 Uo(e,t,n,r,i){let a=i.length,o=Array(a).fill(``);if(t.firstChild()){let e=t.type.id===H.TableDelimiter,r=0;do if(t.type.id===H.TableDelimiter)r++;else if(t.type.id===H.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 Wo(e,t={}){let n=new Jo;return t.frontmatter&&Go(e.attrs.frontmatter,n),Yo(e,n),n.finish()}function Go(e,t){e!==null&&(t.write(`---`),t.write(`
|
|
7
7
|
`),e!==``&&(t.write(e),t.write(`
|
|
8
|
-
`)),t.write(`---`),t.closeBlock())}const
|
|
9
|
-
`+i.repeat(Math.max(1,r))),t.closeBlock();return}t.write(
|
|
8
|
+
`)),t.write(`---`),t.closeBlock())}const Ko=[``,`# `,`## `,`### `,`#### `,`##### `,`###### `];function qo(e,t){let n=e.attrs,r=n.setextUnderline;if(r!=null&&e.content.size>0&&n.level<=2){$o(e,t);let i=n.level===1?`=`:`-`;t.write(`
|
|
9
|
+
`+i.repeat(Math.max(1,r))),t.closeBlock();return}t.write(Ko[n.level]??`# `),$o(e,t);let i=n.closingHashes;i!=null&&i>0&&t.write(` `+`#`.repeat(i)),t.closeBlock()}var Jo=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(`
|
|
10
10
|
`)){this.parts.push(e);return}let t=e.split(`
|
|
11
11
|
`);for(let e=0;e<t.length;e++)e>0&&this.parts.push(`
|
|
12
12
|
`,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(`
|
|
13
13
|
`),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+$/,``)+`
|
|
14
14
|
`}emitDeferredBlankLine(){let e=this.deferredBlankPrefix;e!==null&&(this.parts.push(e.trimEnd(),`
|
|
15
|
-
`),this.deferredBlankPrefix=null)}};function
|
|
15
|
+
`),this.deferredBlankPrefix=null)}};function Yo(e,t){switch(e.type.name){case`doc`:Xo(e,t);return;case`paragraph`:if(e.childCount===0){t.closeEmptyBlock();return}$o(e,t),t.closeBlock();return;case`heading`:qo(e,t);return;case`blockquote`:t.withPrefix(`> `,`> `,()=>Xo(e,t)),t.closeBlock();return;case`list`:es(e,t,Qo(e));return;case`codeBlock`:ts(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`:is(e,t);return;case`text`:e.text&&t.write(e.text);return}}function Xo(e,t,n=!1){let r=e.childCount,i=0;for(;i<r;){let a=e.child(i);if(a.type.name!==`list`){n&&i>0&&t.suppressBlank(),Yo(a,t),i++;continue}let o=i+1;for(;o<r&&e.child(o).type.name===`list`;)o++;let s=Zo(e,i,o);for(let r=i;r<o;r++)(r===i?n&&i>0:s)&&t.suppressBlank(),es(e.child(r),t,s);i=o}}function Zo(e,t,n){for(let r=t;r<n;r++)if(!Qo(e.child(r)))return!1;return!0}function Qo(e){let t=e.childCount;for(let n=0;n<t;n++){let t=e.child(n);if(t.type.name!==`list`&&!(t.type.name===`paragraph`&&n===0))return!1}return!0}function $o(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 es(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)}`,ee=r===`task`?`${m}[${l?f:` `}] `:m,te=` `.repeat(m.length);t.withPrefix(te,ee,()=>Xo(e,t,n)),t.closeBlock()}function ts(e,t){let n=e.attrs,r=n.language||``,i=e.textContent;if(n.fenceStyle===`indented`&&!r){let e=ns(i);if(e!=null){t.write(e),t.closeBlock();return}}if(n.fenceStyle===`dollar`&&r===`math`&&!rs(i)){t.write(`$$`),t.write(`
|
|
16
16
|
`),i&&(t.write(i),t.write(`
|
|
17
|
-
`)),t.write(`$$`),t.closeBlock();return}let a=n.fenceStyle===`tilde`,o=
|
|
17
|
+
`)),t.write(`$$`),t.closeBlock();return}let a=n.fenceStyle===`tilde`,o=yi(i,a?126:96,2)+1,s=(a?`~`:"`").repeat(Math.max(n.fenceLength??0,o));t.write(s),r&&t.write(r),t.write(`
|
|
18
18
|
`),i&&(t.write(i),t.write(`
|
|
19
|
-
`)),t.write(s),t.closeBlock()}function
|
|
19
|
+
`)),t.write(s),t.closeBlock()}function ns(e){if(e===``)return;let t=e.split(`
|
|
20
20
|
`);if(!(t[0]===``||t[t.length-1]===``)){for(let e=0;e<t.length;e++)t[e]!==``&&(t[e]=` ${t[e]}`);return t.join(`
|
|
21
|
-
`)}}function
|
|
22
|
-
`).some(e=>e.trim()===`$$`)}function
|
|
21
|
+
`)}}function rs(e){return e.split(`
|
|
22
|
+
`).some(e=>e.trim()===`$$`)}function is(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);t.type.name===`tableHeaderCell`&&(s=!0),o.push(ss(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(as(n))}let c=`| `+s.join(` | `)+` |`,l=a>=0?r[a]:Array(i).fill(``);t.write(os(l,i)),t.write(`
|
|
23
23
|
`),t.write(c);for(let e=0;e<n;e++)e!==a&&(t.write(`
|
|
24
|
-
`),t.write(
|
|
24
|
+
`),t.write(os(r[e],i)));t.closeBlock()}function as(e){switch(e){case`left`:return`:--`;case`center`:return`:-:`;case`right`:return`--:`;default:return`---`}}function os(e,t){let n=`|`;for(let r=0;r<t;r++)n+=` `+(e[r]??``)+` |`;return n}function ss(e){let t=e.textContent.trim();return!t.includes(`|`)&&!t.includes(`
|
|
25
25
|
`)?t:t.replaceAll(`|`,String.raw`\|`).replaceAll(`
|
|
26
|
-
`,` `)}function
|
|
27
|
-
`).filter(e=>!
|
|
28
|
-
`)}function ks(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(``,n,n+t.length);e.dispatch(xt(i))}function As(){return m(new v({key:Es,props:{handlePaste:(e,t,n)=>{let r=e.state.selection.$from.parent;if(!r.inlineContent||r.type.spec.code)return!1;let i=Os(t,n);if(!i)return!1;let a=Ds(i);return a?(ks(e,a),!0):!1}}}))}const js=new y(`meowdown-exit-boundary`);function Ms(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&&Ee.findFrom(a,t))}function Ns(e,t){let{state:n}=e,{selection:r}=n;return h(r)&&!r.empty||re(r)||r.$from.parent.inlineContent&&!e.endOfTextblock(t<0?`up`:`down`)?!0:Ms(n,t)}function Ps(e){return new v({key:js,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||Ns(t,r)||e({direction:r<0?`up`:`down`,event:n})===!1)}}})}function Fs(e){return _(m(Ps(e)),t.low)}function Is(e){return!!e.type?.startsWith(`image/`)}function Ls(e,t){return Is(e)?``:`[${Bs(e.name)}](${t})`}function Rs(e,t){return!e||!t.onFilePaste?[]:Array.from(e.files)}const zs=e=>{console.error(`[meowdown] failed to save pasted file:`,e)};function Bs(e){return e.replaceAll(/[\\[\]]/g,String.raw`\$&`)}async function Vs(e,t,n,r){let{onFilePaste:i}=n;if(!i)return;let a=n.onFileSaveError??zs,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=Ls(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 Hs(e){return new v({key:new y(`file-paste`),props:{handlePaste:(t,n)=>{let r=Rs(n.clipboardData,e);return r.length===0?!1:(Vs(t,r,e),!0)},handleDrop:(t,n)=>{let r=Rs(n.dataTransfer,e);return r.length===0?!1:(Vs(t,r,e,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos),!0)}}})}function Us(e={}){return _(m(Hs(e)),t.high)}const Ws=new y(`meowdown-file-click`);function Gs(e,t){let n=E(e,t,`mdFile`);if(!n)return;let{href:r,name:i}=n.mark.attrs;return{href:r,name:i}}function Ks(e){return m(new v({key:Ws,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=Gs(t.state,t.posAtDOM(a,0));return o?(e({href:o.href,name:o.name,event:r}),!0):!1}}}))}const qs=[`KB`,`MB`,`GB`,`TB`];function Js(e){let t=e,n=`B`;for(let e of qs){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 Ys=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 Xs(e){let t=e.split(/[?#]/,1)[0],n=t.lastIndexOf(`.`);if(n<0)return`generic`;let r=t.slice(n+1).toLowerCase();return Ys.get(r)??`generic`}const Zs=`http://www.w3.org/2000/svg`;function Qs(){let e=document.createElementNS(Zs,`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(Zs,`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 $s=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=Xs(this.#a.href),this.#n.title=this.#a.name,this.#e.appendChild(this.#n),this.#n.appendChild(Qs()),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=Js(n))}};function ec(e={}){return d({name:`mdFile`,constructor:t=>new $s(t,e)})}function tc(e){return m(new v({key:e.key,props:{handleClick:(t,n,r)=>{if(!r.target?.closest?.(e.selector))return!1;let i=e.findPayloadAt(t.state,n);return i==null?!1:(e.preventDefault&&r.preventDefault(),e.onClick(i,r),!0)}}}))}const nc=new y(`meowdown-tag-click`);function rc(e,t){let n=E(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 ic(e){return tc({key:nc,selector:`.md-tag`,preventDefault:!1,findPayloadAt:(e,t)=>rc(e,t)?.tag,onClick:(t,n)=>e({tag:t,event:n})})}const ac=new y(`meowdown-wikilink-click`);function oc(e,t){let n=E(e,t,`mdWikilink`);if(!n)return;let{target:r}=n.mark.attrs;return{from:n.from,to:n.to,target:r}}function sc(e){return tc({key:ac,selector:`.md-wikilink-view-preview`,preventDefault:!1,findPayloadAt:(e,t)=>oc(e,t)?.target,onClick:(t,n)=>e({target:t,event:n})})}const cc=new y(`meowdown-follow-link`);function lc(e){return e.key!==`Enter`||e.shiftKey||e.altKey?!1:ie?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function uc(e){return new v({key:cc,props:{handleKeyDown:(t,n)=>{if(!lc(n))return!1;let{state:r}=t,i=r.selection.head,a=e.onWikilinkClick&&oc(r,i);if(a)return e.onWikilinkClick?.({target:a.target,event:n}),!0;let o=e.onTagClick&&rc(r,i);if(o)return e.onTagClick?.({tag:o.tag,event:n}),!0;let s=e.onFileClick&&Gs(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 dc(e){return _(m(uc(e)),t.high)}const fc=(e,t)=>{let n={type:`highlight`,children:e.all(t)};return e.patch(t,n),n},pc=(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 mc(){return Et().use(St).use(Ct,{handlers:{mark:fc}}).use(wt).use(Tt,{bullet:`-`,emphasis:`*`,strong:`*`,fence:"`",fences:!0,rule:`-`,ruleRepetition:3,listItemIndent:`one`,handlers:{highlight:pc}}).freeze()}const hc=ve(mc);function gc(e){return String(hc().processSync(e))}const _c=new y(`meowdown-html-paste`);function vc(){return m(new v({key:_c,props:{transformPastedHTML:(e,t)=>{if(e.includes(`data-pm-slice`))return e;let n=t.state.selection.$from.parent;if(!n.inlineContent||n.type.spec.code)return e;let r=gc(e);if(!r.trim())return e;let i=Z(r,{nodes:yo(t.state.schema)}),a=Ie.fromSchema(t.state.schema),o=document.createElement(`div`);return o.append(a.serializeFragment(i.content)),o.innerHTML}}}))}const yc=new y(`meowdown-image-click`);function bc(e,t){let n=E(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 xc(e){return m(new v({key:yc,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(`.md-image-view-preview`);if(!i)return!1;let a=i.closest(`.md-image-view`)?.querySelector(`.md-image-view-content`);if(!a)return!1;let o=bc(t.state,t.posAtDOM(a,0));return o?(e({src:o.src,alt:o.alt,event:r}),!0):!1}}}))}function Sc(e){return/^https?:\/\//i.test(e)?e:void 0}function Cc(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`&&vs(t),t}function wc(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 Tc(e,t,n,r){let i=e.posAtDOM(t,0),a=E(e.state,i,`mdImage`);if(!a)return;let o=e.state.doc.textBetween(a.from,a.to),s=Ar(o),c=a.from+s.length,l=o.slice(s.length),u=kr({...Dr(l)??{},width:Math.round(n),height:Math.round(r)});u!==l&&e.dispatch(e.state.tr.insertText(u,c,a.to))}var Ec=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)&&wc(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=Ts(e);if(t){let e=document.createElement(`span`);return e.className=`md-image-view-preview md-atom-view-preview`,e.appendChild(Cc(t)),e}let n=(this.#n.resolveImageUrl??Sc)(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){Ot(),Dt();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,wc(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)),wc(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;Tc(this.#r,this.#t,t,n)}),this.#a=t,this.#o=n,t}};function Dc(e={}){return d({name:`mdImage`,constructor:(t,n)=>new Ec(t,n,e)})}const Oc={"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`},kc=new y(`meowdown-link-click`);function Ac(e){return tc({key:kc,selector:`.md-link`,preventDefault:!0,findPayloadAt:(e,t)=>K(e,t)?.href,onClick:(t,n)=>e({href:t,event:n})})}function jc(e){let t,n=(n,r)=>{let i=r.target;if(!i||!_e(i))return;let a=i.closest(e.selector);if(!a||a===t)return;let o=n.posAtDOM(a,0),s=e.findPayloadAt(n.state,o);s!=null&&(t=a,e.onHoverChange({payload:s,element:a}))},r=n=>{if(!t)return;let r=n.relatedTarget;r&&t.contains(r)||(t=void 0,e.onHoverChange(void 0))};return g(s(`mouseover`,(e,t)=>n(e,t)),s(`mouseout`,(e,t)=>r(t)))}function Mc(e){return jc({selector:`.md-link`,findPayloadAt:(e,t)=>K(e,t),onHoverChange:e})}const Nc=new y(`meowdown-markdown-copy`);function Pc(){return m(new v({key:Nc,props:{clipboardTextSerializer:(e,t)=>{let n=e.content,r;try{r=t.state.schema.topNodeType.createAndFill(void 0,n)??void 0}catch{r=void 0}return r?Bo(r).replace(/\n+$/,``):n.textBetween(0,n.size,`
|
|
26
|
+
`,` `)}function cs(e){return e.replace(/\n+$/u,``)}function ls(e){return/^[\s>]*$/u.test(e)}function us(e){return e.split(`
|
|
27
|
+
`).filter(e=>!ls(e))}function ds(e){return e.trim().replaceAll(/\s+/gu,` `)}function fs(e,t={}){let n=Wo(Z(e,{frontmatter:t.frontmatter}),{frontmatter:t.frontmatter});if(cs(n)===cs(e))return`exact`;let r=us(e),i=us(n);return r.length===i.length&&r.every((e,t)=>ds(e)===ds(i[t]))?`normalizing`:`lossy`}const ps=(e,t)=>{let{$from:n,empty:r}=e.selection;if(!r||n.depth!==1||n.index(0)!==0||n.parent.type.name!==`heading`||n.parentOffset!==n.parent.content.size)return!1;if(t){let r=ne(e.schema,`list`),i=ne(e.schema,`paragraph`),a=r.create({kind:`bullet`},i.create()),o=n.after(),s=e.tr.insert(o,a);s.setSelection(x.create(s.doc,o+2)),t(s.scrollIntoView())}return!0};function ms(){return _(l({Enter:ps}),t.high)}const hs=new Set([`MscGen`,`Xù`,`MsGenny`,`Angular Template`,`Brainfuck`,`Esper`,`Oz`,`Factor`,`Squirrel`,`Yacas`,`mIRC`,`FCL`,`ECL`,`MUMPS`,`Pig`,`Asterisk`,`Z80`,`Mathematica`]),gs=De.map(e=>({label:e.name,value:e.name.toLowerCase()})).filter(e=>!hs.has(e.label)).concat([{label:`Plain text`,value:``},{label:`Math`,value:`math`}]).sort((e,t)=>e.label.localeCompare(t.label));function _s(){return typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches}const vs=/^(?:www\.|mobile\.)?(?:twitter\.com|x\.com)$/i,ys=/\/status(?:es)?\/(\d+)/;function bs(e){let t;try{t=new URL(e)}catch{return}if(vs.test(t.hostname))return ys.exec(t.pathname)?.[1]}const xs=e=>{let t=bs(e);if(!t)return;let n=_s()?`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 Ss(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 Cs=/^(?:www\.|m\.)?(?:youtube\.com|youtube-nocookie\.com)$/i,ws=/^(?:www\.)?youtu\.be$/i,Ts=/^[\w-]{11}$/;function Es(e){let t;try{t=new URL(e)}catch{return}let n=null;if(ws.test(t.hostname))n=t.pathname.slice(1);else if(Cs.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||!Ts.test(n))return;let r=t.searchParams.get(`start`)??t.searchParams.get(`t`),i=r?Ds(r):void 0;return{videoId:n,startSeconds:i}}function Ds(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 Os=[e=>{let t=Es(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}},xs];function ks(e){for(let t of Os){let n=t(e);if(n)return n}}function As(e,t){return e.clipboardData?.getData(`text/plain`)||t.content.textBetween(0,t.content.size,`
|
|
28
|
+
`)}const js=new b(`meowdown-embed-paste`);function Ms(e){let t=e.trim();if(!(!t||/\s/.test(t)))return ks(t)?t:void 0}function Ns(e,t){let{from:n,to:r}=e.state.selection;e.dispatch(bt(e.state.tr.insertText(t,n,r)));let i=e.state.tr.insertText(``,n,n+t.length);e.dispatch(bt(i))}function Ps(){return m(new y({key:js,props:{handlePaste:(e,t,n)=>{let r=e.state.selection.$from.parent;if(!r.inlineContent||r.type.spec.code)return!1;let i=As(t,n);if(!i)return!1;let a=Ms(i);return a?(Ns(e,a),!0):!1}}}))}const Fs=new b(`meowdown-exit-boundary`);function Is(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&&Te.findFrom(a,t))}function Ls(e,t){let{state:n}=e,{selection:r}=n;return h(r)&&!r.empty||re(r)||r.$from.parent.inlineContent&&!e.endOfTextblock(t<0?`up`:`down`)?!0:Is(n,t)}function Rs(e){return new y({key:Fs,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||Ls(t,r)||e({direction:r<0?`up`:`down`,event:n})===!1)}}})}function zs(e){return _(m(Rs(e)),t.low)}function Bs(e){return!!e.type?.startsWith(`image/`)}function Vs(e,t){return Bs(e)?``:`[${Ws(e.name)}](${t})`}function Hs(e,t){return!e||!t.onFilePaste?[]:Array.from(e.files)}const Us=e=>{console.error(`[meowdown] failed to save pasted file:`,e)};function Ws(e){return e.replaceAll(/[\\[\]]/g,String.raw`\$&`)}async function Gs(e,t,n,r){let{onFilePaste:i}=n;if(!i)return;let a=n.onFileSaveError??Us,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=Vs(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 Ks(e){return new y({key:new b(`file-paste`),props:{handlePaste:(t,n)=>{let r=Hs(n.clipboardData,e);return r.length===0?!1:(Gs(t,r,e),!0)},handleDrop:(t,n)=>{let r=Hs(n.dataTransfer,e);return r.length===0?!1:(Gs(t,r,e,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos),!0)}}})}function qs(e={}){return _(m(Ks(e)),t.high)}const Js=new b(`meowdown-file-click`);function Ys(e,t){let n=D(e,t,`mdFile`);if(!n)return;let{href:r,name:i}=n.mark.attrs;return{href:r,name:i}}function Xs(e){return m(new y({key:Js,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=Ys(t.state,t.posAtDOM(a,0));return o?(e({href:o.href,name:o.name,event:r}),!0):!1}}}))}const Zs=[`KB`,`MB`,`GB`,`TB`];function Qs(e){let t=e,n=`B`;for(let e of Zs){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 $s=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 ec(e){let t=e.split(/[?#]/,1)[0],n=t.lastIndexOf(`.`);if(n<0)return`generic`;let r=t.slice(n+1).toLowerCase();return $s.get(r)??`generic`}const tc=`http://www.w3.org/2000/svg`;function nc(){let e=document.createElementNS(tc,`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(tc,`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 rc=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=ec(this.#a.href),this.#n.title=this.#a.name,this.#e.appendChild(this.#n),this.#n.appendChild(nc()),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=Qs(n))}};function ic(e={}){return d({name:`mdFile`,constructor:t=>new rc(t,e)})}function ac(e){return m(new y({key:e.key,props:{handleClick:(t,n,r)=>{if(!r.target?.closest?.(e.selector))return!1;let i=e.findPayloadAt(t.state,n);return i==null?!1:(e.preventDefault&&r.preventDefault(),e.onClick(i,r),!0)}}}))}const oc=new b(`meowdown-tag-click`);function sc(e,t){let n=D(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 cc(e){return ac({key:oc,selector:`.md-tag`,preventDefault:!1,findPayloadAt:(e,t)=>sc(e,t)?.tag,onClick:(t,n)=>e({tag:t,event:n})})}const lc=new b(`meowdown-wikilink-click`);function uc(e,t){let n=D(e,t,`mdWikilink`);if(!n)return;let{target:r}=n.mark.attrs;return{from:n.from,to:n.to,target:r}}function dc(e){return ac({key:lc,selector:`.md-wikilink-view-preview`,preventDefault:!1,findPayloadAt:(e,t)=>uc(e,t)?.target,onClick:(t,n)=>e({target:t,event:n})})}const fc=new b(`meowdown-follow-link`);function pc(e){return e.key!==`Enter`||e.shiftKey||e.altKey?!1:ie?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function mc(e){return new y({key:fc,props:{handleKeyDown:(t,n)=>{if(!pc(n))return!1;let{state:r}=t,i=r.selection.head,a=e.onWikilinkClick&&uc(r,i);if(a)return e.onWikilinkClick?.({target:a.target,event:n}),!0;let o=e.onTagClick&&sc(r,i);if(o)return e.onTagClick?.({tag:o.tag,event:n}),!0;let s=e.onFileClick&&Ys(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 hc(e){return _(m(mc(e)),t.high)}const gc=(e,t)=>{let n={type:`highlight`,children:e.all(t)};return e.patch(t,n),n},_c=(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 vc(){return Tt().use(xt).use(St,{handlers:{mark:gc}}).use(Ct).use(wt,{bullet:`-`,emphasis:`*`,strong:`*`,fence:"`",fences:!0,rule:`-`,ruleRepetition:3,listItemIndent:`one`,handlers:{highlight:_c}}).freeze()}const yc=v(vc);function bc(e){return String(yc().processSync(e))}const xc=new b(`meowdown-html-paste`);function Sc(){return m(new y({key:xc,props:{transformPastedHTML:(e,t)=>{if(e.includes(`data-pm-slice`))return e;let n=t.state.selection.$from.parent;if(!n.inlineContent||n.type.spec.code)return e;let r=bc(e);if(!r.trim())return e;let i=Z(r,{nodes:Co(t.state.schema)}),a=Fe.fromSchema(t.state.schema),o=document.createElement(`div`);return o.append(a.serializeFragment(i.content)),o.innerHTML}}}))}const Cc=new b(`meowdown-image-click`);function wc(e){return e instanceof HTMLElement&&e.closest(`.md-image-view-preview`)}function Tc(e,t){let n=D(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 Ec(e){return m(new y({key:Cc,props:{handleDOMEvents:{pointerdown:(e,t)=>(wc(t.target)&&t.pointerType!==`mouse`&&t.preventDefault(),!1)},handleClick:(t,n,r)=>{let i=wc(r.target);if(!i)return!1;let a=i.closest(`.md-image-view`)?.querySelector(`.md-image-view-content`);if(!a)return!1;let o=Tc(t.state,t.posAtDOM(a,0));return o?(e({src:o.src,alt:o.alt,event:r}),!0):!1}}}))}function Dc(e){return/^https?:\/\//i.test(e)?e:void 0}function Oc(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`&&Ss(t),t}function kc(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 Ac(e,t,n,r){let i=e.posAtDOM(t,0),a=D(e.state,i,`mdImage`);if(!a)return;let o=e.state.doc.textBetween(a.from,a.to),s=Pr(o),c=a.from+s.length,l=o.slice(s.length),u=Nr({...jr(l)??{},width:Math.round(n),height:Math.round(r)});u!==l&&e.dispatch(e.state.tr.insertText(u,c,a.to))}var jc=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)&&kc(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=ks(e);if(t){let e=document.createElement(`span`);return e.className=`md-image-view-preview md-atom-view-preview`,e.appendChild(Oc(t)),e}let n=(this.#n.resolveImageUrl??Dc)(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){Dt(),Et();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,kc(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)),kc(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;Ac(this.#r,this.#t,t,n)}),this.#a=t,this.#o=n,t}};function Mc(e={}){return d({name:`mdImage`,constructor:(t,n)=>new jc(t,n,e)})}const Nc={"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`},Pc=new b(`meowdown-link-click`);function Fc(e){return ac({key:Pc,selector:`.md-link`,preventDefault:!0,findPayloadAt:(e,t)=>K(e,t)?.href,onClick:(t,n)=>e({href:t,event:n})})}function Ic(e){let t,n=(n,r)=>{let i=r.target;if(!i||!_e(i))return;let a=i.closest(e.selector);if(!a||a===t)return;let o=n.posAtDOM(a,0),s=e.findPayloadAt(n.state,o);s!=null&&(t=a,e.onHoverChange({payload:s,element:a}))},r=n=>{if(!t)return;let r=n.relatedTarget;r&&t.contains(r)||(t=void 0,e.onHoverChange(void 0))};return g(s(`mouseover`,(e,t)=>n(e,t)),s(`mouseout`,(e,t)=>r(t)))}function Lc(e){return Ic({selector:`.md-link`,findPayloadAt:(e,t)=>K(e,t),onHoverChange:e})}const Rc=new b(`meowdown-link-paste`);function zc(e){let t=e.trim();if(!(!t||/\s/.test(t)))return ir(t)}function Bc(){return _(m(new y({key:Rc,props:{handlePaste:(e,t,n)=>{let r=As(t,n);if(!r)return!1;let i=zc(r);return i?En(e,Hi({href:i,wrapText:!1})):!1}}})),t.high)}const Vc=new b(`meowdown-markdown-copy`);function Hc(){return m(new y({key:Vc,props:{clipboardTextSerializer:(e,t)=>{let n=e.content,r;try{r=t.state.schema.topNodeType.createAndFill(void 0,n)??void 0}catch{r=void 0}return r?Wo(r).replace(/\n+$/,``):n.textBetween(0,n.size,`
|
|
29
29
|
`,`
|
|
30
|
-
`)}}}))}function
|
|
30
|
+
`)}}}))}function Uc({allowEmpty:e}){return(t,n)=>{let{selection:r}=t;if(!h(r)||!e&&r.empty||!r.$head.sameParent(r.$anchor)||r.$head.parent.type.spec.code)return!1;let i=t.doc.textBetween(r.from,r.to);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(x.create(e.doc,r.from+a.length)),Pe(e),n(e.scrollIntoView())}return!0}}function Wc(){return l({"Mod-Shift-k":Uc({allowEmpty:!0}),"[":Uc({allowEmpty:!1})})}function Gc(e){let{selection:t,schema:n}=e;if(t.empty)return``;let r=t.content().content;try{return Wo(n.topNodeType.create(null,r)).replace(/\n+$/,``)}catch{return e.doc.textBetween(t.from,t.to,`
|
|
31
31
|
|
|
32
|
-
`)}}function
|
|
32
|
+
`)}}function Kc(e,t){let n=new DOMRect(0,0,0,0),r=()=>{if(e.isDestroyed)return n;let r=X(e,t.from,1)??X(e,t.from,-1),i=X(e,t.to,-1)??X(e,t.to,1);if(r==null||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()]}}function qc(e){return e instanceof Ve||e instanceof He||e instanceof Ue||e instanceof We||e instanceof R}function Jc(e){for(let t of e)for(let e of t.steps)if(!qc(e))return!0;return!1}function Yc(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){Jc(e)&&o()},view(e){return t=e,{destroy(){t=void 0}}}}}function Xc(e){let t=new b(`spell-check`);return new y({key:t,state:{init:()=>Yc(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 Zc(e){return m(Xc(e))}export{Nc as EDITOR_KEY_BINDINGS,e as Priority,Vs as buildFileMarkdown,fs as checkRoundTrip,gs as codeBlockLanguages,Dc as defaultResolveImageUrl,ms as defineBulletAfterHeading,pe as defineCodeBlockPreviewPlugin,tn as defineCodeBlockSyntaxHighlight,go as defineEditorExtension,Ps as defineEmbedPaste,zs as defineExitBoundaryHandler,Xs as defineFileClickHandler,qs as defineFilePaste,ic as defineFileView,hc as defineFollowLinkHandler,Yn as defineHTMLComment,Sc as defineHTMLPaste,Mc as defineImage,Ec as defineImageClickHandler,Fc as defineLinkClickHandler,Gi as defineLinkCommands,qi as defineLinkEditKeymap,Lc as defineLinkHoverHandler,Bc as defineLinkPaste,Hc as defineMarkdownCopy,ga as defineMath,$a as definePendingReplacementHandler,he as definePlaceholder,ge as defineReadonly,Zc as defineSpellCheckPlugin,cc as defineTagClickHandler,dc as defineWikilinkClickHandler,Wc as defineWikilinkTrigger,Wo as docToMarkdown,rn as getCodeTokens,K as getLinkUnitAt,yo as getMarkBuilders,J as getPendingReplacement,Gc as getSelectedText,ka as getTableColumnAlign,Kc as getVirtualElementFromRange,zr as inlineTextToMarkChunks,Hi as insertLink,me as isCodeBlockPreviewHiddenDecoration,Ma as isSelectionInTableCell,Ss as listenForTweetHeight,pa as loadKaTeX,Z as markdownToDoc,ks as matchEmbed,Wi as removeLink,ma as renderMathInto,Ui as updateLink,le as withPriority};
|
package/dist/style.css
CHANGED
|
@@ -824,7 +824,13 @@
|
|
|
824
824
|
}
|
|
825
825
|
|
|
826
826
|
.ProseMirror {
|
|
827
|
+
& .md-wikilink-view-preview.md-atom-view-preview {
|
|
828
|
+
display: inline;
|
|
829
|
+
}
|
|
830
|
+
|
|
827
831
|
& .md-wikilink-view-label {
|
|
832
|
+
-webkit-box-decoration-break: clone;
|
|
833
|
+
box-decoration-break: clone;
|
|
828
834
|
background: color-mix(in oklab, var(--meowdown-accent) 10%, transparent);
|
|
829
835
|
color: color-mix(in oklab, var(--meowdown-accent) 80%, var(--meowdown-heading));
|
|
830
836
|
text-underline-offset: 2px;
|