@meowdown/core 0.56.0 → 0.57.1

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.js CHANGED
@@ -1,34 +1,36 @@
1
- import{Priority as e,Priority as t,createMarkBuilders as n,createNodeBuilders as r,defineBaseCommands as i,defineBaseKeymap as a,defineClipboardSerializer as o,defineCommands as s,defineHistory as c,defineKeymap as l,defineMarkSpec as u,defineMarkView as d,defineNodeAttr as f,defineNodeSpec as p,definePlugin as m,getMarkRange as h,getMarkType as ee,getNodeType as te,isAllSelection as ne,isApple as re,isAtBlockStart as ie,isNodeSelection as ae,isTextSelection as g,setBlockType as oe,toggleNode as se,union as _,unsetBlockType as ce,withPriority as le,withPriority as v,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{LEZER_NODE_IDS as y,collectInlineElements as _e,getAutolinkHref as ve,gfmBlockOnlyParser as ye,isSpaceChar as b,parseInline as be}from"@meowdown/markdown";import{isElementLike as xe,isHTMLElement as Se,isObject as Ce,once as we}from"@ocavue/utils";import{defineBlockquote as Te}from"@prosekit/extensions/blockquote";import{defineDoc as Ee}from"@prosekit/extensions/doc";import{defineGapCursor as De}from"@prosekit/extensions/gap-cursor";import{defineModClickPrevention as Oe}from"@prosekit/extensions/mod-click-prevention";import{defineText as ke}from"@prosekit/extensions/text";import{defineVirtualSelection as Ae}from"@prosekit/extensions/virtual-selection";import{NodeSelection as je,Plugin as x,PluginKey as S,Selection as Me,TextSelection as C}from"@prosekit/pm/state";import{Decoration as Ne,DecorationSet as w}from"@prosekit/pm/view";import Pe from"rehype-parse";import Fe from"rehype-remark";import Ie from"remark-gfm";import Le from"remark-stringify";import{unified as Re}from"unified";import{DOMParser as ze,DOMSerializer as Be,Fragment as T,Mark as Ve,Slice as E}from"@prosekit/pm/model";import{defineHeadingCommands as He,defineHeadingInputRule as Ue,defineHeadingSpec as We}from"@prosekit/extensions/heading";import{defineParagraphCommands as Ge,defineParagraphKeymap as Ke}from"@prosekit/extensions/paragraph";import{LanguageDescription as qe}from"@codemirror/language";import{languages as Je}from"@codemirror/language-data";import{classHighlighter as Ye,highlightTree as Xe}from"@lezer/highlight";import{createParser as Ze}from"prosemirror-highlight/lezer";import{defineEnterRule as Qe,defineTextBlockEnterRule as $e}from"@prosekit/extensions/enter-rule";import{defineInputRule as et,defineTextBlockInputRule as tt}from"@prosekit/extensions/input-rule";import{triggerAutocomplete as nt}from"@prosekit/extensions/autocomplete";import{defineListCommands as rt,defineListDropIndicator as it,defineListKeymap as at,defineListSpec as ot,moveList as st,toggleList as ct,unwrapList as lt,wrapInList as D}from"@prosekit/extensions/list";import{chainCommands as ut,lift as dt}from"@prosekit/pm/commands";import{defineHorizontalRule as ft}from"@prosekit/extensions/horizontal-rule";import{AddMarkStep as pt,AddNodeMarkStep as mt,RemoveMarkStep as ht,RemoveNodeMarkStep as gt,ReplaceStep as _t,Step as vt,StepResult as yt,Transform as bt}from"@prosekit/pm/transform";import{createListRenderingPlugin as xt,createSafariInputMethodWorkaroundPlugin as St,createToggleCollapsedCommand as Ct,defaultAttributesGetter as wt,findCheckboxInListItem as Tt,handleListMarkerMouseDown as Et,joinListElements as Dt,listToDOM as Ot,unwrapListSlice as kt,wrappingListInputRule as At}from"prosemirror-flat-list";import{defineTableCellSpec as jt,defineTableCommands as Mt,defineTableDropIndicator as Nt,defineTableEditingPlugin as Pt,defineTableHeaderCellSpec as Ft,defineTableRowSpec as It,defineTableSpec as Lt,deleteTable as Rt,isCellSelection as zt}from"@prosekit/extensions/table";import{closeHistory as Bt}from"@prosekit/pm/history";import{registerResizableHandleElement as Vt,registerResizableRootElement as Ht}from"@prosekit/web/resizable";import{InputRule as Ut}from"@prosekit/pm/inputrules";function O(e,t,n,r){let i=e.doc.content.size;if(t<0||t>i)return;let a=e.doc.resolve(t);if(!(!a.parent.isTextblock||a.parent.type.spec.code))return h(a,n,r)}const k=new S(`mark-mode`);function Wt(e){return k.getState(e)}function Gt(e){return new x({key:k,state:{init:()=>e,apply:(e,t)=>e.getMeta(k)??t},props:{attributes:t=>({"data-mark-mode":Wt(t)??e}),decorations:e=>{let t=Wt(e);if(t===`focus`)return Jt(e);if(t===`hide`)return Yt(e)}}})}function Kt(e){return(t,n)=>A(t)===e?!1:(n?.(t.tr.setMeta(k,e)),!0)}function qt(e){return _(m(Gt(e)),s({setMarkMode:Kt}))}function A(e){return k.getState(e)}function Jt(e){return Xt(e,void 0)}function Yt(e){return Xt(e,{key:`math`})}function Xt(e,t){let{selection:n}=e;if(!n.empty)return w.empty;let r=n.$head,{parent:i}=r;if(!i.isTextblock||i.type.spec.code)return w.empty;let a=h(r,ee(e.schema,`mdPack`),t);return a?w.create(e.doc,[Ne.inline(a.from,a.to,{class:`show`})]):w.empty}const Zt=[`mdImage`,`mdWikilink`,`mdFile`];function j(e,t){let n=A(t);return n?e.flatMap(e=>e.modes.includes(n)?[e.name]:[]):[]}function Qt(e,t,n){for(let r of n){let n=O(e,t,r);if(n)return n}}function M(e,t,n){let r=Qt(e,t,n);return r&&r.to===t?r:void 0}function N(e,t,n){let r=Qt(e,t,n);return r&&r.from===t?r:void 0}function $t(e,t){let{from:n,to:r,empty:i}=e.selection;if(i)return;let a=Qt(e,n,t);return a&&a.from===n&&a.to===r?a:void 0}function en(e,t){return C.create(e.doc,t.from,t.to)}function tn(e,t,n,r){let i=e.doc.resolve(t);if(!(r===-1?i.parentOffset===0:i.parentOffset===i.parent.content.size)||i.depth===0)return;let a=r===-1?N(e,t,n):M(e,t,n),o=r===-1?i.before():i.after(),s=Me.findFrom(e.doc.resolve(o),r);if(!s)return;let c=g(s)?r===-1?M(e,s.head,n):N(e,s.head,n):void 0;if(!(a==null&&c==null))return s}function nn(e){return(t,n)=>{let r=j(e,t);if(r.length===0||!g(t.selection))return!1;let i=t.selection;if(i.empty){let e=N(t,i.from,r);if(e)return n?.(t.tr.setSelection(en(t,e))),!0;if(M(t,i.from,r)&&i.from<t.doc.resolve(i.from).end())return n?.(t.tr.setSelection(C.create(t.doc,i.from+1))),!0;let a=tn(t,i.from,r,1);return a?(n?.(t.tr.setSelection(a).scrollIntoView()),!0):!1}let a=$t(t,r);return a?(n?.(t.tr.setSelection(C.create(t.doc,a.to))),!0):!1}}function rn(e){return(t,n)=>{let r=j(e,t);if(r.length===0||!g(t.selection))return!1;let i=t.selection;if(i.empty){let e=M(t,i.from,r);if(e)return n?.(t.tr.setSelection(en(t,e))),!0;let a=tn(t,i.from,r,-1);return a?(n?.(t.tr.setSelection(a).scrollIntoView()),!0):!1}let a=$t(t,r);return a?(n?.(t.tr.setSelection(C.create(t.doc,a.from))),!0):!1}}function an(e,t){return(n,r)=>{let i=j(e,n);if(i.length===0||!g(n.selection))return!1;let{anchor:a,head:o}=n.selection,s=t===-1?M(n,o,i):N(n,o,i);if(s){let e=t===-1?s.from:s.to;return r?.(n.tr.setSelection(C.create(n.doc,a,e)).scrollIntoView()),!0}let c=tn(n,o,i,t);return!c||!g(c)?!1:(r?.(n.tr.setSelection(C.create(n.doc,a,c.head)).scrollIntoView()),!0)}}function on(e){return(t,n)=>{let r=j(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=M(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!N(t,i,r)||i<=t.doc.resolve(i).start()?!1:(n?.(t.tr.delete(i-1,i)),!0)}}function sn(e){return(t,n)=>{let r=j(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=N(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!M(t,i,r)||i>=t.doc.resolve(i).end()?!1:(n?.(t.tr.delete(i,i+1)),!0)}}const cn=`md-atom-selected`;function ln(e){return new x({key:new S(`atom-mark-selection`),props:{decorations:t=>{let n=j(e,t);if(n.length===0||ae(t.selection))return;let r=$t(t,n);if(r)return w.create(t.doc,[Ne.inline(r.from,r.to,{class:cn})]);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(Ne.inline(t,t+e.nodeSize,{class:cn}))}),w.create(t.doc,s)}}})}function un({marks:e}){return _(v(l({ArrowRight:nn(e),ArrowLeft:rn(e),"Shift-ArrowRight":an(e,1),"Shift-ArrowLeft":an(e,-1),Backspace:on(e),Delete:sn(e)}),t.high),m(ln(e)))}const dn=(e,t)=>{let n={type:`highlight`,children:e.all(t)};return e.patch(t,n),n},fn=(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 pn(){return Re().use(Pe).use(Fe,{handlers:{mark:dn}}).use(Ie).use(Le,{bullet:`-`,emphasis:`*`,strong:`*`,fence:"`",fences:!0,rule:`-`,ruleRepetition:3,listItemIndent:`one`,handlers:{highlight:fn}}).freeze()}const mn=we(pn);function hn(e){return String(mn().processSync(e))}function gn(e){if(e==null)return;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)?t:void 0}function _n(e){let t=gn(e);return t!=null&&t>0?t:void 0}function P(e,t){return e.type.name===t}const vn=new Set([`mdMark`,`mdLinkUri`,`mdLinkTitle`]),yn=new Set([`mdWikilink`,`mdImage`,`mdFile`,`mdMath`]);function bn(e){return e.find(e=>yn.has(e.type.name))}function xn(e){return e.some(e=>vn.has(e.type.name))}function Sn(e){let t=[];return e.forEach(e=>{if(!e.isText||!e.text)return;let n=bn(e.marks),r=t.at(-1);if(n!=null&&r!=null&&r.atom===n){r.text+=e.text,r.children.push(e);return}t.push({atom:n,text:e.text,children:[e]})}),t}const Cn={mdStrong:`strong`,mdEm:`em`,mdCode:`code`,mdDel:`del`,mdHighlight:`mark`,mdLinkText:`a`};function wn(e,t,n={}){let r=document.createElement(e);r.setAttribute(`data-md`,t.textContent);for(let[e,t]of Object.entries(n))t!=null&&r.setAttribute(e,t);return En(t,r),r}function Tn(e,t,n){return{tag:`${e}[data-md]`,node:t,priority:100,getAttrs:n,getContent:(e,t)=>{let n=(Se(e)?e:void 0)?.getAttribute(`data-md`)??``;return n?T.from(t.text(n)):T.empty}}}function En(e,t){let n=[];for(let r of Sn(e)){if(r.atom!=null){n.length=0,t.append(kn(r.atom,r.text));continue}for(let e of r.children)xn(e.marks)||(Dn(n,e.marks.filter(e=>Cn[e.type.name]),t),On(n.at(-1)?.element??t,e.text??``))}}function Dn(e,t,n){let r=0;for(;r<e.length&&r<t.length&&t[r].eq(e[r].mark);)r++;e.length=r;for(let i=r;i<t.length;i++){let r=t[i],a=document.createElement(Cn[r.type.name]??`span`);P(r,`mdLinkText`)&&a.setAttribute(`href`,r.attrs.href),(e.at(-1)?.element??n).append(a),e.push({mark:r,element:a})}}function On(e,t){let n=t.split(`
2
- `);for(let[t,r]of n.entries())t>0&&e.append(document.createElement(`br`)),r&&e.append(document.createTextNode(r))}function kn(e,t){switch(e.type.name){case`mdImage`:{let t=e.attrs,n=document.createElement(`img`);return n.setAttribute(`src`,t.src),t.alt&&n.setAttribute(`alt`,t.alt),t.title&&n.setAttribute(`title`,t.title),t.width!=null&&n.setAttribute(`width`,String(t.width)),t.height!=null&&n.setAttribute(`height`,String(t.height)),n}case`mdWikilink`:{let t=e.attrs;return document.createTextNode(t.display||t.target)}case`mdFile`:{let t=e.attrs,n=document.createElement(`a`);return n.setAttribute(`href`,t.href),n.append(document.createTextNode(t.name||t.href)),n}default:return document.createTextNode(t)}}function F(e,t){return e.type.name===t}function An(){return p({name:`heading`,whitespace:`pre`})}function jn(e){let t=e.attrs;return wn(`h${t.level}`,e,{"data-setext-underline":t.setextUnderline==null?void 0:String(t.setextUnderline),"data-closing-hashes":t.closingHashes==null?void 0:String(t.closingHashes)})}function Mn(){return[1,2,3,4,5,6].map(e=>Tn(`h${e}`,`heading`,t=>({level:e,setextUnderline:_n(t.getAttribute(`data-setext-underline`))??null,closingHashes:_n(t.getAttribute(`data-closing-hashes`))??null})))}function Nn(){return f({type:`heading`,attr:`setextUnderline`,default:null,toDOM:e=>e==null?null:[`data-setext-underline`,String(e)],parseDOM:e=>_n(e.getAttribute(`data-setext-underline`))??null})}function Pn(){return f({type:`heading`,attr:`closingHashes`,default:null,toDOM:e=>e==null?null:[`data-closing-hashes`,String(e)],parseDOM:e=>_n(e.getAttribute(`data-closing-hashes`))??null})}function I(e){return ue(se({type:`heading`,attrs:{level:e}}))}const Fn=(e,t,n)=>{let r=ie(e,n);return r!=null&&F(r.parent,`heading`)?ce()(e,t,n):!1};function In(){return l({"Mod-1":I(1),"Mod-2":I(2),"Mod-3":I(3),"Mod-4":I(4),"Mod-5":I(5),"Mod-6":I(6),Backspace:Fn})}function Ln(){return _(We(),An(),Nn(),Pn(),Ue(),He(),In())}function Rn(){return p({name:`paragraph`,content:`inline*`,group:`block`,whitespace:`pre`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}})}function zn(e){return wn(`p`,e)}function Bn(){return[Tn(`p`,`paragraph`)]}function Vn(){return _(v(Rn(),t.highest),Ge(),Ke())}function Hn(e){return{...e,paragraph:e=>({dom:zn(e)}),heading:e=>({dom:jn(e)})}}function Un(){return o({serializeFragmentWrapper:e=>(...t)=>{let n=e(...t);for(let e of n.children)e.setAttribute(`data-meowdown`,``);return n},nodesFromSchemaWrapper:e=>(...t)=>Hn(e(...t))})}const Wn=new WeakMap;function Gn(e){let t=Wn.get(e);return t??(t=new Be(Hn(Be.nodesFromSchema(e)),Be.marksFromSchema(e)),Wn.set(e,t)),t}const Kn=new S(`meowdown-html-paste`);function qn(e){return e.includes(`data-meowdown`)?!0:e.includes(`data-pm-slice`)&&e.includes(`md-mark`)}function Jn(){return m(new x({key:Kn,props:{transformPastedHTML:(e,t)=>{if(qn(e))return e;let n=t.state.selection.$from.parent;if(!n.inlineContent||n.type.spec.code)return e;let r=hn(e);if(!r.trim())return e;let i=Y(r,{nodes:Us(t.state.schema)}),a=Gn(t.state.schema),o=document.createElement(`div`);return o.append(a.serializeFragment(i.content)),o.innerHTML}}}))}function Yn(e){return new ze(e,[...Bn(),...Mn(),...ze.fromSchema(e).rules])}const Xn=new S(`meowdown-clipboard-parser`);function Zn(){return m(({schema:e})=>new x({key:Xn,props:{clipboardParser:Yn(e)}}))}function Qn(e,t){let n=t.replaceAll(/\r\n?/g,`
3
- `).replace(/^\n+/,``).replace(/\n+$/,``);if(!n)return E.empty;let r=te(e,`paragraph`),i=[],a=n.split(/(\n{2,})/);for(let t=0;t<a.length;t++){let n=a[t];if(t%2==0)i.push(r.create(null,n?e.text(n):void 0));else{let e=n.length-1;for(let t=1;t<e;t++)i.push(r.create())}}return E.maxOpen(T.from(i))}function $n(e,t,n){let r=n.marks(),i=Be.fromSchema(e),a=document.createElement(`div`);for(let n of t.split(/(?:\r\n?|\n)+/)){let t=a.appendChild(document.createElement(`p`));n&&t.appendChild(i.serializeNode(e.text(n,r)))}return ze.fromSchema(e).parseSlice(a,{preserveWhitespace:!0,context:n})}function er(){return m(new x({key:new S(`meowdown-plain-paste`),props:{clipboardTextParser:(e,t,n,r)=>{let{schema:i}=r.state;return n?$n(i,e,t):Qn(i,e)}}}))}function tr(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 nr(e,t=0){return tr(e,96,t)}function rr(e,t={}){let n=new sr;return t.frontmatter&&ir(e.attrs.frontmatter,n),cr(e,n),n.finish()}function ir(e,t){e!==null&&(t.write(`---`),t.write(`
1
+ import{Priority as e,Priority as t,createMarkBuilders as n,createNodeBuilders as r,defineBaseCommands as i,defineBaseKeymap as a,defineClipboardSerializer as o,defineCommands as s,defineHistory as c,defineKeymap as l,defineMarkSpec as u,defineMarkView as d,defineNodeAttr as f,defineNodeSpec as p,definePlugin as m,getMarkRange as h,getMarkType as ee,getNodeType as te,isAllSelection as ne,isApple as re,isAtBlockStart as ie,isNodeSelection as ae,isTextSelection as g,setBlockType as oe,toggleNode as se,union as _,unsetBlockType as ce,withPriority as le,withPriority as v,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{LEZER_NODE_IDS as y,collectInlineElements as _e,getAutolinkHref as ve,gfmBlockOnlyParser as ye,isSpaceChar as b,parseInline as be}from"@meowdown/markdown";import{isElementLike as xe,isHTMLElement as Se,isObject as Ce,once as we}from"@ocavue/utils";import{defineBlockquote as Te}from"@prosekit/extensions/blockquote";import{defineDoc as Ee}from"@prosekit/extensions/doc";import{defineGapCursor as De}from"@prosekit/extensions/gap-cursor";import{defineModClickPrevention as Oe}from"@prosekit/extensions/mod-click-prevention";import{defineText as ke}from"@prosekit/extensions/text";import{defineVirtualSelection as Ae}from"@prosekit/extensions/virtual-selection";import{NodeSelection as je,Plugin as x,PluginKey as S,Selection as Me,TextSelection as C}from"@prosekit/pm/state";import{Decoration as w,DecorationSet as T}from"@prosekit/pm/view";import{NO_BREAK_SPACE as Ne}from"unicode-by-name";import{defaultHandlers as Pe}from"hast-util-to-mdast";import{defaultHandlers as Fe}from"mdast-util-to-markdown";import Ie from"rehype-parse";import Le from"rehype-remark";import Re from"remark-gfm";import ze from"remark-stringify";import{unified as Be}from"unified";import{DOMParser as Ve,DOMSerializer as He,Fragment as Ue,Mark as We,Slice as E}from"@prosekit/pm/model";import{defineHeadingCommands as Ge,defineHeadingInputRule as Ke,defineHeadingSpec as qe}from"@prosekit/extensions/heading";import{defineParagraphCommands as Je,defineParagraphKeymap as Ye}from"@prosekit/extensions/paragraph";import{LanguageDescription as Xe}from"@codemirror/language";import{languages as Ze}from"@codemirror/language-data";import{classHighlighter as Qe,highlightTree as $e}from"@lezer/highlight";import{createParser as et}from"prosemirror-highlight/lezer";import{defineEnterRule as tt,defineTextBlockEnterRule as nt}from"@prosekit/extensions/enter-rule";import{defineInputRule as rt,defineTextBlockInputRule as it}from"@prosekit/extensions/input-rule";import{triggerAutocomplete as at}from"@prosekit/extensions/autocomplete";import{defineListCommands as ot,defineListDropIndicator as st,defineListKeymap as ct,defineListSpec as lt,moveList as ut,toggleList as dt,unwrapList as ft,wrapInList as D}from"@prosekit/extensions/list";import{chainCommands as pt,lift as mt}from"@prosekit/pm/commands";import{defineHorizontalRule as ht}from"@prosekit/extensions/horizontal-rule";import{AddMarkStep as gt,AddNodeMarkStep as _t,RemoveMarkStep as vt,RemoveNodeMarkStep as yt,ReplaceStep as bt,Step as xt,StepResult as St,Transform as Ct}from"@prosekit/pm/transform";import{createListRenderingPlugin as wt,createSafariInputMethodWorkaroundPlugin as Tt,createToggleCollapsedCommand as Et,defaultAttributesGetter as Dt,findCheckboxInListItem as Ot,handleListMarkerMouseDown as kt,joinListElements as At,listToDOM as jt,unwrapListSlice as Mt,wrappingListInputRule as Nt}from"prosemirror-flat-list";import{defineTableCellSpec as Pt,defineTableCommands as Ft,defineTableDropIndicator as It,defineTableEditingPlugin as Lt,defineTableHeaderCellSpec as Rt,defineTableRowSpec as zt,defineTableSpec as Bt,deleteTable as Vt,isCellSelection as Ht}from"@prosekit/extensions/table";import{closeHistory as Ut}from"@prosekit/pm/history";import{registerResizableHandleElement as Wt,registerResizableRootElement as Gt}from"@prosekit/web/resizable";import{InputRule as Kt}from"@prosekit/pm/inputrules";function O(e,t,n,r){let i=e.doc.content.size;if(t<0||t>i)return;let a=e.doc.resolve(t);if(!(!a.parent.isTextblock||a.parent.type.spec.code))return h(a,n,r)}const k=new S(`mark-mode`);function qt(e){return k.getState(e)}function Jt(e){return new x({key:k,state:{init:()=>e,apply:(e,t)=>e.getMeta(k)??t},props:{attributes:t=>({"data-mark-mode":qt(t)??e}),decorations:e=>{let t=qt(e);if(t===`focus`)return Zt(e);if(t===`hide`)return Qt(e)}}})}function Yt(e){return(t,n)=>A(t)===e?!1:(n?.(t.tr.setMeta(k,e)),!0)}function Xt(e){return _(m(Jt(e)),s({setMarkMode:Yt}))}function A(e){return k.getState(e)}function Zt(e){return $t(e,void 0)}function Qt(e){return $t(e,{key:`math`})}function $t(e,t){let{selection:n}=e;if(!n.empty)return T.empty;let r=n.$head,{parent:i}=r;if(!i.isTextblock||i.type.spec.code)return T.empty;let a=h(r,ee(e.schema,`mdPack`),t);return a?T.create(e.doc,[w.inline(a.from,a.to,{class:`show`})]):T.empty}const en=[`mdImage`,`mdWikilink`,`mdFile`];function j(e,t){let n=A(t);return n?e.flatMap(e=>e.modes.includes(n)?[e.name]:[]):[]}function tn(e,t,n){for(let r of n){let n=O(e,t,r);if(n)return n}}function M(e,t,n){let r=tn(e,t,n);return r&&r.to===t?r:void 0}function N(e,t,n){let r=tn(e,t,n);return r&&r.from===t?r:void 0}function nn(e,t){let{from:n,to:r,empty:i}=e.selection;if(i)return;let a=tn(e,n,t);return a&&a.from===n&&a.to===r?a:void 0}function rn(e,t){return C.create(e.doc,t.from,t.to)}function an(e,t,n,r){let i=e.doc.resolve(t);if(!(r===-1?i.parentOffset===0:i.parentOffset===i.parent.content.size)||i.depth===0)return;let a=r===-1?N(e,t,n):M(e,t,n),o=r===-1?i.before():i.after(),s=Me.findFrom(e.doc.resolve(o),r);if(!s)return;let c=g(s)?r===-1?M(e,s.head,n):N(e,s.head,n):void 0;if(!(a==null&&c==null))return s}function on(e){return(t,n)=>{let r=j(e,t);if(r.length===0||!g(t.selection))return!1;let i=t.selection;if(i.empty){let e=N(t,i.from,r);if(e)return n?.(t.tr.setSelection(rn(t,e))),!0;if(M(t,i.from,r)&&i.from<t.doc.resolve(i.from).end())return n?.(t.tr.setSelection(C.create(t.doc,i.from+1))),!0;let a=an(t,i.from,r,1);return a?(n?.(t.tr.setSelection(a).scrollIntoView()),!0):!1}let a=nn(t,r);return a?(n?.(t.tr.setSelection(C.create(t.doc,a.to))),!0):!1}}function sn(e){return(t,n)=>{let r=j(e,t);if(r.length===0||!g(t.selection))return!1;let i=t.selection;if(i.empty){let e=M(t,i.from,r);if(e)return n?.(t.tr.setSelection(rn(t,e))),!0;let a=an(t,i.from,r,-1);return a?(n?.(t.tr.setSelection(a).scrollIntoView()),!0):!1}let a=nn(t,r);return a?(n?.(t.tr.setSelection(C.create(t.doc,a.from))),!0):!1}}function cn(e,t){return(n,r)=>{let i=j(e,n);if(i.length===0||!g(n.selection))return!1;let{anchor:a,head:o}=n.selection,s=t===-1?M(n,o,i):N(n,o,i);if(s){let e=t===-1?s.from:s.to;return r?.(n.tr.setSelection(C.create(n.doc,a,e)).scrollIntoView()),!0}let c=an(n,o,i,t);return!c||!g(c)?!1:(r?.(n.tr.setSelection(C.create(n.doc,a,c.head)).scrollIntoView()),!0)}}function ln(e){return(t,n)=>{let r=j(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=M(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!N(t,i,r)||i<=t.doc.resolve(i).start()?!1:(n?.(t.tr.delete(i-1,i)),!0)}}function un(e){return(t,n)=>{let r=j(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=N(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!M(t,i,r)||i>=t.doc.resolve(i).end()?!1:(n?.(t.tr.delete(i,i+1)),!0)}}const dn=`md-atom-selected`;function fn(e){return new x({key:new S(`atom-mark-selection`),props:{decorations:t=>{let n=j(e,t);if(n.length===0||ae(t.selection))return;let r=nn(t,n);if(r)return T.create(t.doc,[w.inline(r.from,r.to,{class:dn})]);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(w.inline(t,t+e.nodeSize,{class:dn}))}),T.create(t.doc,s)}}})}function pn({marks:e}){return _(v(l({ArrowRight:on(e),ArrowLeft:sn(e),"Shift-ArrowRight":cn(e,1),"Shift-ArrowLeft":cn(e,-1),Backspace:ln(e),Delete:un(e)}),t.high),m(fn(e)))}const mn=(e,t)=>{let n={type:`highlight`,children:e.all(t)};return e.patch(t,n),n},hn=(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 gn(e){return e.tagName===`input`&&e.properties.type===`checkbox`}function _n(e){for(let t of e.children){if(t.type!==`element`)continue;if(gn(t))return t;if(t.tagName===`ul`||t.tagName===`ol`)continue;let e=_n(t);if(e)return e}}function vn(e){let t=e.properties.dataChecked,n=_n(e);if(!(t!=null||e.properties.dataType===`taskItem`||e.properties.dataTaskListItem!=null||n!==void 0))return;let r=typeof t==`string`?t!==`false`:!!n?.properties.checked,i=e.children.filter(e=>e.type!==`element`||!(gn(e)||e.tagName===`label`&&_n(e)));for(let e of[`div`,`p`]){let t=i.length===1&&i[0].type===`element`?i[0]:void 0;t?.tagName===e&&(i=t.children)}let a={type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:r},children:[]};return{...e,children:[a,...i]}}const yn=(e,t)=>Pe.li(e,vn(t)??t);function bn(e){return e.filter(e=>e.character!==`[`&&e.character!==`~`?!0:e.atBreak?e.character===`~`:!(Array.isArray(e.inConstruct)?e.inConstruct:e.inConstruct?[e.inConstruct]:[]).includes(`phrasing`))}const xn=(e,t,n,r)=>Fe.text(e,t,{...n,unsafe:bn(n.unsafe)},r);function Sn(){return Be().use(Ie).use(Le,{handlers:{mark:mn,li:yn}}).use(Re).use(ze,{bullet:`-`,emphasis:`*`,strong:`*`,fence:"`",fences:!0,rule:`-`,ruleRepetition:3,listItemIndent:`one`,handlers:{highlight:hn,text:xn}}).freeze()}const Cn=we(Sn);function wn(e){return String(Cn().processSync(e))}function Tn(e){if(e==null)return;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)?t:void 0}function En(e){let t=Tn(e);return t!=null&&t>0?t:void 0}function P(e,t){return e.type.name===t}const Dn=new Set([`mdMark`,`mdLinkUri`,`mdLinkTitle`]),On=new Set([`mdWikilink`,`mdImage`,`mdFile`,`mdMath`]);function kn(e){return e.find(e=>On.has(e.type.name))}function An(e){return e.some(e=>Dn.has(e.type.name))}function jn(e){let t=[];return e.forEach(e=>{if(!e.isText||!e.text)return;let n=kn(e.marks),r=t.at(-1);if(n!=null&&r!=null&&r.atom===n){r.text+=e.text,r.children.push(e);return}t.push({atom:n,text:e.text,children:[e]})}),t}const Mn={mdStrong:`strong`,mdEm:`em`,mdCode:`code`,mdDel:`del`,mdHighlight:`mark`,mdLinkText:`a`};function Nn(e,t,n={}){let r=document.createElement(e);r.setAttribute(`data-md`,t.textContent);for(let[e,t]of Object.entries(n))t!=null&&r.setAttribute(e,t);return Fn(t,r),r}function Pn(e,t,n){return{tag:`${e}[data-md]`,node:t,priority:100,getAttrs:n,getContent:(e,t)=>{let n=(Se(e)?e:void 0)?.getAttribute(`data-md`)??``;return n?Ue.from(t.text(n)):Ue.empty}}}function Fn(e,t){let n=[];for(let r of jn(e)){if(r.atom!=null){n.length=0,t.append(Rn(r.atom,r.text));continue}for(let e of r.children)An(e.marks)||(In(n,e.marks.filter(e=>Mn[e.type.name]),t),Ln(n.at(-1)?.element??t,e.text??``))}}function In(e,t,n){let r=0;for(;r<e.length&&r<t.length&&t[r].eq(e[r].mark);)r++;e.length=r;for(let i=r;i<t.length;i++){let r=t[i],a=document.createElement(Mn[r.type.name]??`span`);P(r,`mdLinkText`)&&a.setAttribute(`href`,r.attrs.href),(e.at(-1)?.element??n).append(a),e.push({mark:r,element:a})}}function Ln(e,t){let n=t.split(`
2
+ `);for(let[t,r]of n.entries())t>0&&e.append(document.createElement(`br`)),r&&e.append(document.createTextNode(r))}function Rn(e,t){switch(e.type.name){case`mdImage`:{let t=e.attrs,n=document.createElement(`img`);return n.setAttribute(`src`,t.src),t.alt&&n.setAttribute(`alt`,t.alt),t.title&&n.setAttribute(`title`,t.title),t.width!=null&&n.setAttribute(`width`,String(t.width)),t.height!=null&&n.setAttribute(`height`,String(t.height)),n}case`mdWikilink`:{let t=e.attrs;return document.createTextNode(t.display||t.target)}case`mdFile`:{let t=e.attrs,n=document.createElement(`a`);return n.setAttribute(`href`,t.href),n.append(document.createTextNode(t.name||t.href)),n}default:return document.createTextNode(t)}}function F(e,t){return e.type.name===t}function zn(){return p({name:`heading`,whitespace:`pre`})}function Bn(e){let t=e.attrs;return Nn(`h${t.level}`,e,{"data-setext-underline":t.setextUnderline==null?void 0:String(t.setextUnderline),"data-closing-hashes":t.closingHashes==null?void 0:String(t.closingHashes)})}function Vn(){return[1,2,3,4,5,6].map(e=>Pn(`h${e}`,`heading`,t=>({level:e,setextUnderline:En(t.getAttribute(`data-setext-underline`))??null,closingHashes:En(t.getAttribute(`data-closing-hashes`))??null})))}function Hn(){return f({type:`heading`,attr:`setextUnderline`,default:null,toDOM:e=>e==null?null:[`data-setext-underline`,String(e)],parseDOM:e=>En(e.getAttribute(`data-setext-underline`))??null})}function Un(){return f({type:`heading`,attr:`closingHashes`,default:null,toDOM:e=>e==null?null:[`data-closing-hashes`,String(e)],parseDOM:e=>En(e.getAttribute(`data-closing-hashes`))??null})}function I(e){return ue(se({type:`heading`,attrs:{level:e}}))}const Wn=(e,t,n)=>{let r=ie(e,n);return r!=null&&F(r.parent,`heading`)?ce()(e,t,n):!1};function Gn(){return l({"Mod-1":I(1),"Mod-2":I(2),"Mod-3":I(3),"Mod-4":I(4),"Mod-5":I(5),"Mod-6":I(6),Backspace:Wn})}function Kn(){return _(qe(),zn(),Hn(),Un(),Ke(),Ge(),Gn())}function qn(){return p({name:`paragraph`,content:`inline*`,group:`block`,whitespace:`pre`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}})}function Jn(e){return Nn(`p`,e)}function Yn(){return[Pn(`p`,`paragraph`)]}function Xn(){return _(v(qn(),t.highest),Je(),Ye())}function Zn(e){return{...e,paragraph:e=>({dom:Jn(e)}),heading:e=>({dom:Bn(e)})}}function Qn(){return o({serializeFragmentWrapper:e=>(...t)=>{let n=e(...t);for(let e of n.children)e.setAttribute(`data-meowdown`,``);return n},nodesFromSchemaWrapper:e=>(...t)=>Zn(e(...t))})}const $n=new WeakMap;function er(e){let t=$n.get(e);return t??(t=new He(Zn(He.nodesFromSchema(e)),He.marksFromSchema(e)),$n.set(e,t)),t}const tr=new S(`meowdown-html-paste`);function nr(e){return e.includes(`data-meowdown`)?!0:e.includes(`data-pm-slice`)&&e.includes(`md-mark`)}const rr=new Set([`html`,`head`,`body`,`meta`,`style`,`title`,`div`,`span`,`p`,`br`,`font`,`wbr`]);function ir(e){let t=new window.DOMParser().parseFromString(e,`text/html`),n={chunks:[],hasContent:!1,trailingNewlines:0,hasStyledLine:!1};if(sr(t.documentElement,n,!1)&&n.hasStyledLine)return n.chunks.join(``).replaceAll(Ne,` `)}function ar(e,t){!e.hasContent||e.trailingNewlines>=t||or(e,`
3
+ `.repeat(t-e.trailingNewlines))}function or(e,t){if(!t)return;e.chunks.push(t);let n=t.length;for(;n>0&&t.charCodeAt(n-1)===10;)n--;n===0?e.trailingNewlines+=t.length:(e.hasContent=!0,e.trailingNewlines=t.length-n)}function sr(e,t,n){if(e.nodeType===Node.TEXT_NODE)return or(t,e.nodeValue??``),!0;if(e.nodeType!==Node.ELEMENT_NODE)return!0;let r=e,i=r.tagName;if(!rr.has(i.toLowerCase()))return!1;if(n||=i===`DIV`,n&&r.getAttribute(`style`)?.trim()&&(t.hasStyledLine=!0),i===`BR`)return or(t,`
4
+ `),!0;if(i===`STYLE`||i===`TITLE`)return!0;let a=i===`DIV`?1:i===`P`?2:0;a&&ar(t,a);for(let r of e.childNodes)if(!sr(r,t,n))return!1;return a&&ar(t,a),!0}function cr(){return m(new x({key:tr,props:{transformPastedHTML:(e,t)=>{if(nr(e))return e;let n=t.state.selection.$from.parent;if(!n.inlineContent||n.type.spec.code)return e;let r=ir(e)??wn(e);if(!r.trim())return e;let i=X(r,{nodes:rc(t.state.schema)}),a=er(t.state.schema),o=document.createElement(`div`);return o.append(a.serializeFragment(i.content)),o.innerHTML}}}))}function lr(e){return new Ve(e,[...Yn(),...Vn(),...Ve.fromSchema(e).rules])}const ur=new S(`meowdown-clipboard-parser`);function dr(){return m(({schema:e})=>new x({key:ur,props:{clipboardParser:lr(e)}}))}function fr(e,t){let n=t.replaceAll(/\r\n?/g,`
5
+ `).replace(/^\n+/,``).replace(/\n+$/,``);if(!n)return E.empty;let r=X(n,{nodes:rc(e)}),i=te(e,`paragraph`),a=+(r.childCount>0&&r.child(0).type===i),o=+(r.childCount>0&&r.child(r.childCount-1).type===i);return new E(r.content,a,o)}function pr(e,t,n){let r=n.marks(),i=He.fromSchema(e),a=document.createElement(`div`);for(let n of t.split(/(?:\r\n?|\n)+/)){let t=a.appendChild(document.createElement(`p`));n&&t.appendChild(i.serializeNode(e.text(n,r)))}return Ve.fromSchema(e).parseSlice(a,{preserveWhitespace:!0,context:n})}function mr(){let e;return m(new x({key:new S(`meowdown-plain-paste`),props:{clipboardTextParser:(t,n,r,i)=>{let{schema:a}=i.state;return r?pr(a,t,n):e=fr(a,t)},transformPasted:t=>{if(e==null)return t;let n=e;return e=void 0,n}}}))}function hr(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 gr(e,t=0){return hr(e,96,t)}function _r(e,t={}){let n=new xr;return t.frontmatter&&vr(e.attrs.frontmatter,n),Sr(e,n),n.finish()}function vr(e,t){e!==null&&(t.write(`---`),t.write(`
4
6
  `),e!==``&&(t.write(e),t.write(`
5
- `)),t.write(`---`),t.closeBlock())}const ar=[``,`# `,`## `,`### `,`#### `,`##### `,`###### `];function or(e,t){let n=e.attrs,r=n.setextUnderline;if(r!=null&&e.content.size>0&&n.level<=2){fr(e,t);let i=n.level===1?`=`:`-`;t.write(`
6
- `+i.repeat(Math.max(1,r))),t.closeBlock();return}t.write(ar[n.level]??`# `),fr(e,t);let i=n.closingHashes;i!=null&&i>0&&t.write(` `+`#`.repeat(i)),t.closeBlock()}var sr=class{constructor(){this.parts=[],this.linePrefix=``,this.pendingFirst=null,this.atLineStart=!0,this.deferredBlankPrefix=null}write(e){if(e===``)return;if(this.emitDeferredBlankLine(),this.atLineStart&&=(this.parts.push(this.pendingFirst??this.linePrefix),this.pendingFirst=null,!1),!e.includes(`
7
+ `)),t.write(`---`),t.closeBlock())}const yr=[``,`# `,`## `,`### `,`#### `,`##### `,`###### `];function br(e,t){let n=e.attrs,r=n.setextUnderline;if(r!=null&&e.content.size>0&&n.level<=2){Er(e,t);let i=n.level===1?`=`:`-`;t.write(`
8
+ `+i.repeat(Math.max(1,r))),t.closeBlock();return}t.write(yr[n.level]??`# `),Er(e,t);let i=n.closingHashes;i!=null&&i>0&&t.write(` `+`#`.repeat(i)),t.closeBlock()}var xr=class{constructor(){this.parts=[],this.linePrefix=``,this.pendingFirst=null,this.atLineStart=!0,this.deferredBlankPrefix=null}write(e){if(e===``)return;if(this.emitDeferredBlankLine(),this.atLineStart&&=(this.parts.push(this.pendingFirst??this.linePrefix),this.pendingFirst=null,!1),!e.includes(`
7
9
  `)){this.parts.push(e);return}let t=e.split(`
8
10
  `);for(let e=0;e<t.length;e++)e>0&&this.parts.push(`
9
11
  `,this.linePrefix),t[e]!==``&&this.parts.push(t[e])}closeEmptyBlock(){if(!this.atLineStart||this.pendingFirst!==null){this.closeBlock();return}this.parts.length!==0&&(this.emitDeferredBlankLine(),this.deferredBlankPrefix=this.linePrefix)}closeBlock(){this.atLineStart&&this.pendingFirst!==null&&(this.emitDeferredBlankLine(),this.parts.push(this.pendingFirst.trimEnd()),this.pendingFirst=null,this.atLineStart=!1),this.atLineStart||this.parts.push(`
10
12
  `),this.atLineStart=!0,this.deferredBlankPrefix=this.linePrefix}suppressBlank(){this.deferredBlankPrefix=null}withPrefix(e,t,n){let r=this.linePrefix,i=this.pendingFirst;if(this.linePrefix=r+e,t!==null){let e=i??r;this.pendingFirst=e+t}n(),this.linePrefix=r,this.pendingFirst=t===null?i:null}finish(){return this.parts.join(``).replace(/\s+$/,``)+`
11
13
  `}emitDeferredBlankLine(){let e=this.deferredBlankPrefix;e!==null&&(this.parts.push(e.trimEnd(),`
12
- `),this.deferredBlankPrefix=null)}};function cr(e,t){switch(e.type.name){case`doc`:lr(e,t);return;case`paragraph`:if(e.childCount===0){t.closeEmptyBlock();return}fr(e,t),t.closeBlock();return;case`heading`:or(e,t);return;case`blockquote`:t.withPrefix(`> `,`> `,()=>lr(e,t)),t.closeBlock();return;case`list`:pr(e,t,dr(e));return;case`codeBlock`:mr(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`:_r(e,t);return;case`text`:e.text&&t.write(e.text);return}}function lr(e,t,n=!1){let r=e.childCount,i=0;for(;i<r;){let a=e.child(i);if(!F(a,`list`)){n&&i>0&&t.suppressBlank(),cr(a,t),i++;continue}let o=i+1;for(;o<r&&F(e.child(o),`list`);)o++;let s=ur(e,i,o);for(let r=i;r<o;r++)(r===i?n&&i>0:s)&&t.suppressBlank(),pr(e.child(r),t,s);i=o}}function ur(e,t,n){for(let r=t;r<n;r++)if(!dr(e.child(r)))return!1;return!0}function dr(e){let t=e.childCount;for(let n=0;n<t;n++){let t=e.child(n).type.name;if(t!==`list`&&!(t===`paragraph`&&n===0))return!1}return!0}function fr(e,t){let n=e.childCount;for(let r=0;r<n;r++){let n=e.child(r);n.isText&&n.text&&t.write(n.text)}}function pr(e,t,n){let{kind:r,marker:i,order:a,taskMarker:o,collapsed:s,markerGap:c,checked:l}=e.attrs,u=r===`task`?i===`+`?`+`:i===`*`?`*`:`-`:s?`+`:i===`*`?`*`:`-`,d=i===`)`?`)`:`.`,f=o===`X`?`X`:`x`,p=Math.min(Math.max(c??1,1),4),m=`${r===`ordered`?`${a??1}${d}`:u}${` `.repeat(p)}`,h=r===`task`?`${m}[${l?f:` `}] `:m,ee=` `.repeat(m.length);t.withPrefix(ee,h,()=>lr(e,t,n)),t.closeBlock()}function mr(e,t){let n=e.attrs,r=n.language||``,i=e.textContent;if(n.fenceStyle===`indented`&&!r){let e=hr(i);if(e!=null){t.write(e),t.closeBlock();return}}if(n.fenceStyle===`dollar`&&r===`math`&&!gr(i)){t.write(`$$`),t.write(`
14
+ `),this.deferredBlankPrefix=null)}};function Sr(e,t){switch(e.type.name){case`doc`:Cr(e,t);return;case`paragraph`:if(e.childCount===0){t.closeEmptyBlock();return}Er(e,t),t.closeBlock();return;case`heading`:br(e,t);return;case`blockquote`:t.withPrefix(`> `,`> `,()=>Cr(e,t)),t.closeBlock();return;case`list`:Dr(e,t,Tr(e));return;case`codeBlock`:Or(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`:jr(e,t);return;case`text`:e.text&&t.write(e.text);return}}function Cr(e,t,n=!1){let r=e.childCount,i=0;for(;i<r;){let a=e.child(i);if(!F(a,`list`)){n&&i>0&&t.suppressBlank(),Sr(a,t),i++;continue}let o=i+1;for(;o<r&&F(e.child(o),`list`);)o++;let s=wr(e,i,o);for(let r=i;r<o;r++)(r===i?n&&i>0:s)&&t.suppressBlank(),Dr(e.child(r),t,s);i=o}}function wr(e,t,n){for(let r=t;r<n;r++)if(!Tr(e.child(r)))return!1;return!0}function Tr(e){let t=e.childCount;for(let n=0;n<t;n++){let t=e.child(n).type.name;if(t!==`list`&&!(t===`paragraph`&&n===0))return!1}return!0}function Er(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 Dr(e,t,n){let{kind:r,marker:i,order:a,taskMarker:o,collapsed:s,markerGap:c,checked:l}=e.attrs,u=r===`task`?i===`+`?`+`:i===`*`?`*`:`-`:s?`+`:i===`*`?`*`:`-`,d=i===`)`?`)`:`.`,f=o===`X`?`X`:`x`,p=Math.min(Math.max(c??1,1),4),m=`${r===`ordered`?`${a??1}${d}`:u}${` `.repeat(p)}`,h=r===`task`?`${m}[${l?f:` `}] `:m,ee=` `.repeat(m.length);t.withPrefix(ee,h,()=>Cr(e,t,n)),t.closeBlock()}function Or(e,t){let n=e.attrs,r=n.language||``,i=e.textContent;if(n.fenceStyle===`indented`&&!r){let e=kr(i);if(e!=null){t.write(e),t.closeBlock();return}}if(n.fenceStyle===`dollar`&&r===`math`&&!Ar(i)){t.write(`$$`),t.write(`
13
15
  `),i&&(t.write(i),t.write(`
14
- `)),t.write(`$$`),t.closeBlock();return}let a=n.fenceStyle===`tilde`,o=tr(i,a?126:96,2)+1,s=(a?`~`:"`").repeat(Math.max(n.fenceLength??0,o));t.write(s),r&&t.write(r),t.write(`
16
+ `)),t.write(`$$`),t.closeBlock();return}let a=n.fenceStyle===`tilde`,o=hr(i,a?126:96,2)+1,s=(a?`~`:"`").repeat(Math.max(n.fenceLength??0,o));t.write(s),r&&t.write(r),t.write(`
15
17
  `),i&&(t.write(i),t.write(`
16
- `)),t.write(s),t.closeBlock()}function hr(e){if(e===``)return;let t=e.split(`
18
+ `)),t.write(s),t.closeBlock()}function kr(e){if(e===``)return;let t=e.split(`
17
19
  `);if(!(t[0]===``||t[t.length-1]===``)){for(let e=0;e<t.length;e++)t[e]!==``&&(t[e]=` ${t[e]}`);return t.join(`
18
- `)}}function gr(e){return e.split(`
19
- `).some(e=>e.trim()===`$$`)}function _r(e,t){let n=e.childCount;if(n===0)return;let r=[],i=0,a=-1;for(let t=0;t<n;t++){let n=e.child(t),o=[],s=!1;for(let e=0;e<n.childCount;e++){let t=n.child(e);F(t,`tableHeaderCell`)&&(s=!0),o.push(br(t))}s&&a<0&&(a=t),o.length>i&&(i=o.length),r.push(o)}if(i===0)return;let o=e.child(a>=0?a:0),s=[];for(let e=0;e<i;e++){let t=e<o.childCount?o.child(e):void 0,n=t?t.attrs.align:void 0;s.push(vr(n))}let c=`| `+s.join(` | `)+` |`,l=a>=0?r[a]:Array(i).fill(``);t.write(yr(l,i)),t.write(`
20
+ `)}}function Ar(e){return e.split(`
21
+ `).some(e=>e.trim()===`$$`)}function jr(e,t){let n=e.childCount;if(n===0)return;let r=[],i=0,a=-1;for(let t=0;t<n;t++){let n=e.child(t),o=[],s=!1;for(let e=0;e<n.childCount;e++){let t=n.child(e);F(t,`tableHeaderCell`)&&(s=!0),o.push(Pr(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(Mr(n))}let c=`| `+s.join(` | `)+` |`,l=a>=0?r[a]:Array(i).fill(``);t.write(Nr(l,i)),t.write(`
20
22
  `),t.write(c);for(let e=0;e<n;e++)e!==a&&(t.write(`
21
- `),t.write(yr(r[e],i)));t.closeBlock()}function vr(e){switch(e){case`left`:return`:--`;case`center`:return`:-:`;case`right`:return`--:`;default:return`---`}}function yr(e,t){let n=`|`;for(let r=0;r<t;r++)n+=` `+(e[r]??``)+` |`;return n}function br(e){let t=e.textContent.trim();return!t.includes(`|`)&&!t.includes(`
23
+ `),t.write(Nr(r[e],i)));t.closeBlock()}function Mr(e){switch(e){case`left`:return`:--`;case`center`:return`:-:`;case`right`:return`--:`;default:return`---`}}function Nr(e,t){let n=`|`;for(let r=0;r<t;r++)n+=` `+(e[r]??``)+` |`;return n}function Pr(e){let t=e.textContent.trim();return!t.includes(`|`)&&!t.includes(`
22
24
  `)?t:t.replaceAll(`|`,String.raw`\|`).replaceAll(`
23
- `,` `)}function xr(e,t){let n=t.content,r;try{r=e.topNodeType.createAndFill(void 0,n)??void 0}catch{r=void 0}return r?rr(r).replace(/\n+$/,``):n.textBetween(0,n.size,`
25
+ `,` `)}function Fr(e,t){let n=t.content,r;try{r=e.topNodeType.createAndFill(void 0,n)??void 0}catch{r=void 0}return r?_r(r).replace(/\n+$/,``):n.textBetween(0,n.size,`
24
26
  `,`
25
- `)}function Sr(){return m(new x({key:new S(`meowdown-plain-text-copy`),props:{clipboardTextSerializer:(e,t)=>{let n=A(t.state)===`hide`?Cr(e):e;return xr(t.state.schema,n)}}}))}function Cr(e){return new E(wr(e.content),e.openStart,e.openEnd)}function wr(e){let t=[];return e.forEach(e=>{t.push(e.isTextblock?Er(e):Tr(e))}),T.from(t)}function Tr(e){return e.childCount>0?e.copy(wr(e.content)):e}function Er(e){let t=e.type.schema,n=[];for(let r of Sn(e)){let e=r.atom;if(e!=null){if(P(e,`mdWikilink`)){let r=e.attrs,i=r.display||r.target;i&&n.push(t.text(i))}else n.push(...r.children);continue}for(let e of r.children)xn(e.marks)||n.push(e)}return e.copy(T.from(n))}function Dr(){return _(Un(),Sr(),Zn(),Jn(),er())}const L=new Map,Or=new Map,kr={math:`latex`};async function Ar(e){let t=L.get(e);if(t!==void 0)return t;let n=qe.matchLanguageName(Je,kr[e]??e,!0);if(!n)return L.set(e,null),null;let r=n.support;if(!r)try{r=await n.load()}catch(t){return console.error(`[meowdown] Failed to load language "${e}":`,t),L.set(e,null),null}return L.set(e,r),r}function jr(e,t){let n=Or.get(e);if(n)return n;let r=Ze({parse:e=>t.language.parser.parse(e.content),highlighter:Ye});return Or.set(e,r),r}const Mr=e=>{let t=e.language?.trim();if(!t)return[];let n=L.get(t);return n===null?[]:n?jr(t,n)(e):Ar(t).then(()=>void 0)};function Nr(){return fe({parser:Mr,nodeTypes:[`codeBlock`]})}function Pr(e,t){let n=t.language.parser.parse(e),r=[];return Xe(n,Ye,(e,t,n)=>{r.push([e,t,n])}),r}function Fr(e,t){let n=t.trim();if(!n)return[];let r=L.get(n);return r===null?[]:r?Pr(e,r):Ar(n).then(t=>t?Pr(e,t):[])}function Ir(){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 Lr(){return f({type:`codeBlock`,attr:`fenceLength`,default:null,toDOM:e=>e==null?null:[`data-fence-length`,String(e)],parseDOM:e=>{let t=gn(e.getAttribute(`data-fence-length`));return t!=null&&t>3?t:null}})}function Rr(e){return{language:e[1]||``,fenceStyle:`tilde`}}function zr(){return tt({regex:/^~~~(\S*)\s$/,type:`codeBlock`,attrs:Rr})}function Br(){return $e({regex:/^~~~(\S*)$/,type:`codeBlock`,attrs:Rr})}function Vr(){return $e({regex:/^\$\$$/,type:`codeBlock`,attrs:()=>({language:`math`,fenceStyle:`dollar`})})}function Hr(){return _(de(),Ir(),Lr(),zr(),Br(),Vr())}function Ur(e,t){return(n,r)=>{if(r){let i=C.create(n.doc,e,t);r(n.tr.setSelection(i))}return!0}}function Wr(e,t,n){return(r,i)=>{if(i){let a=C.between(e,t,n);i(r.tr.setSelection(a))}return!0}}function Gr(e){return(t,n)=>{if(!e.trim())return!1;let r=Y(e,{nodes:Us(t.schema)}).content;if(r.childCount===0)return!1;let i=r.childCount===1&&F(r.child(0),`paragraph`)?new E(r,1,1):new E(r,0,E.maxOpen(r).openEnd);if(n){let e=t.tr,r=e.selection;(!g(r)||!r.empty)&&e.setSelection(C.near(r.$from)),n(e.replaceSelection(i).scrollIntoView())}return!0}}function Kr(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);nt(s),n(s.scrollIntoView())}return!0}}function qr(){return ut(oe({type:`paragraph`}),lt(),dt)}function Jr(){return(e,t)=>(t&&t(e.tr.scrollIntoView()),!0)}function Yr(){return s({insertMarkdown:Gr,insertTrigger:Kr,scrollIntoView:Jr,selectText:Ur,selectTextBetween:Wr,turnIntoText:qr})}const Xr=(e,t,n)=>{let{selection:r}=e;return r.empty||n?.composing?!1:(t?.(e.tr.setSelection(C.near(r.$head))),!0)};function Zr(){return v(l({Escape:Xr}),t.low)}function Qr(){return f({type:`doc`,attr:`frontmatter`,default:null})}function $r(e,t){return t(e.state,e.dispatch,e)}function ei(e,t){if(t<0||t+1>e.doc.content.size)return;let n=e.doc.resolve(t),r=n.parent.maybeChild(n.index());if(!(r==null||!r.isText))return r.marks}function R(e,t){let n=ei(e,t);return n!=null&&n.some(e=>vn.has(e.type.name))}function ti(e,t){if(t<0||t>e.doc.content.size)return!1;let n=e.doc.resolve(t);return n.parent.isTextblock&&!n.parent.type.spec.code}function z(e,t){if(!ti(e,t))return;let n=e.doc.resolve(t).start(),r=t;for(;r>n&&R(e,r-1);)r--;return r<t?{from:r,to:t}:void 0}function B(e,t){if(!ti(e,t))return;let n=e.doc.resolve(t).end(),r=t;for(;r<n&&R(e,r);)r++;return r>t?{from:t,to:r}:void 0}function ni(e,t){return R(e,t-1)&&R(e,t)}function ri(e,t){if(!ni(e,t))return;let n=z(e,t);if(!n)return;let r=B(e,t);if(r)return{from:n.from,to:r.to}}function ii(e,t,n){let r=ei(e,t);return r!=null&&n.isInSet(r)}function ai(e,t){let n=ei(e,t);if(n==null)return;let r=ee(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&&ii(e,r-1,n);)r--;let i=t+1;for(;i<s&&ii(e,i,n);)i++;(c==null||i-r<c.to-c.from)&&(c={from:r,to:i})}return c}function oi(e,t,n){let r=ai(e,n===`from`?t.from:t.to-1);return r==null?!1:n===`from`?r.from===t.from:r.to===t.to}function si(e,t,n){let r=oi(e,t,`from`),i=oi(e,t,`to`);return r&&!i?t.from:i&&!r?t.to:n-t.from<=t.to-n?t.from:t.to}function ci(e,t,n,r){if(!ti(e,n))return n;let i=ri(e,n);if(i!=null)return r?si(e,i,n):n>=t?i.to:i.from;if(!r)return n;let a=z(e,n);if(a!=null&&oi(e,a,`from`))return a.from;let o=B(e,n);return o!=null&&oi(e,o,`to`)?o.to:n}function li(e,t){if(!ti(e,t))return;let n=R(e,t-1),r=R(e,t);if(n!==r)return r?`left`:`right`}function ui(e,t){let n=ai(e,t);if(n==null)return[];let r=B(e,n.from),i=z(e,n.to),a=[];return i!=null&&a.push(i),r!=null&&(i==null||r.from!==i.from)&&a.push(r),a}const di=new S(`meowdown-hidden-run-snap`),fi=new S(`meowdown-hidden-run-beforeinput`);function pi(){let e=!1;return new x({key:di,props:{handleDOMEvents:{compositionstart:()=>(e=!0,!1),compositionend:()=>(e=!1,!1)}},appendTransaction:(t,n,r)=>{if(e||A(r)!==`hide`)return null;let i=r.selection;if(!g(i))return null;let a=t.some(e=>e.getMeta(`pointer`)!=null);if(i.empty){let e=ci(r,n.selection.head,i.head,a);return e===i.head?null:r.tr.setSelection(C.create(r.doc,e))}let o=ri(r,i.from)?.from??i.from,s=ri(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(C.create(r.doc,c,l))}})}const mi=(e,t)=>{if(A(e)!==`hide`)return!1;let n=e.selection;if(!g(n)||!n.empty)return!1;let r=ci(e,n.head,n.head,!0);return r===n.head||t?.(e.tr.setSelection(C.create(e.doc,r))),!1};function hi(e){return(t,n)=>{if(A(t)!==`hide`)return!1;let r=t.selection;if(!g(r)||!r.empty)return!1;let i=r.$head;if(!i.parent.isTextblock||i.parent.type.spec.code)return!1;let a=e===-1?z(t,r.head):B(t,r.head);if(a==null)return!1;let o=ui(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 gi=hi(-1),_i=hi(1);function vi(){return new x({key:fi,props:{handleDOMEvents:{beforeinput:(e,t)=>{if(e.composing)return!1;let n=t.inputType===`deleteContentBackward`?gi:t.inputType===`deleteContentForward`?_i:void 0;return n==null||!$r(e,n)?!1:(t.preventDefault(),!0)}}}})}function yi(){return _(m(pi()),m(vi()),v(l({Enter:mi,Backspace:gi,Delete:_i}),t.highest))}function bi(){return f({type:`horizontalRule`,attr:`marker`,default:null,toDOM:e=>e?[`data-hr-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-hr-marker`)})}function xi(){return _(ft(),bi())}function Si(){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 Ci(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function wi(e,t){let[n,r,i]=t;return[n,r,i.map(t=>Ve.fromJSON(e,t))]}function Ti(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 Ei=class e extends vt{constructor(e){super(),this.chunks=e}apply(e){if(this.chunks.length===0)return yt.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=Ve.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(Ti(l,c))return!1;n??=new bt(e);for(let e of l)n.removeMark(i,a,e);for(let e of c)n.addMark(i,a,e);return!1})}return yt.ok(n?n.doc:e)}invert(e){if(this.chunks.length===0)return Di;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 _t(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(Ci)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>wi(t,e)))}};vt.jsonID(`batchSetMark`,Ei);const Di=new Ei([]),Oi=/^<!--\s*(\{[^}]*\})\s*-->$/,ki=/<!--\s*\{[^}]*\}\s*-->$/;function Ai(e){let t=Oi.exec(e.trim());if(!t)return;let n;try{n=JSON.parse(t[1])}catch{return}if(!Ce(n))return;let r=ji(n);return Object.keys(r).length>0?r:void 0}function ji(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 Mi(e){return`<!-- ${JSON.stringify(e)} -->`}function Ni(e){return e.replace(ki,``)}const Pi=/^(\d+)(?:x(\d+))?$/i;function Fi(e){if(!e)return null;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)&&t>0?t:null}function Ii(e){let t=e.replace(/^!\[\[/,``).replace(/\]\]$/,``),n=t.lastIndexOf(`|`);if(n<0)return{target:t.trim(),display:``,width:null,height:null};let r=t.slice(0,n).trim(),i=t.slice(n+1).trim(),a=Pi.exec(i);if(!a)return{target:r,display:i,width:null,height:null};let o=Fi(a[1]),s=Fi(a[2]);return o==null||a[2]&&s==null?{target:r,display:i,width:null,height:null}:{target:r,display:``,width:o,height:s}}function Li(e,t,n){return`![[${e}|${Math.round(t)}x${Math.round(n)}]]`}function Ri(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function zi(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 Bi(){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 Vi(){return d({name:`mdWikilink`,constructor:Bi()})}const Hi=new Map([[y.Emphasis,`mdEm`],[y.StrongEmphasis,`mdStrong`],[y.InlineCode,`mdCode`],[y.Strikethrough,`mdDel`],[y.Highlight,`mdHighlight`],[y.EmphasisMark,`mdMark`],[y.CodeMark,`mdMark`],[y.LinkMark,`mdMark`],[y.StrikethroughMark,`mdMark`],[y.HighlightMark,`mdMark`],[y.URL,`mdLinkUri`],[y.LinkTitle,`mdLinkTitle`],[y.Hashtag,`mdTag`],[y.WikilinkMark,`mdMark`]]);function Ui(e,t,n){let r=be(t),i=[];return Gi(r,[],0,t.length,t,e,i,n),i}function Wi(e){return e.slice(1,-1).replaceAll(/\\(.)/g,`$1`)}function Gi(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&&V(o,c,r.from,t);let l=r.type;if(l===y.Link)if(!Ki(r))Gi(r.children.filter(e=>e.type!==y.LinkMark&&e.type!==y.LinkLabel),t,r.from,r.to,i,a,o,s);else{let e=Yi(r,t,i,a,s);e?V(o,r.from,r.to,e):Xi(r,t,i,a,o,s)}else if(l===y.Image){let s=Zi(r,e[n+1],i);Qi(r,t,i,a,o,s),s&&n++,c=s?s.to:r.to;continue}else if(l===y.Wikilink)ea(r,t,i,a,o);else if(l===y.WikiEmbed)ta(r,t,i,a,o,s);else if(l===y.InlineMath)$i(r,t,i,a,o);else if(l===y.URL){let e=ve(i.slice(r.from,r.to)),n=e?a.mdLinkText.create({href:e}):a.mdLinkUri.create();V(o,r.from,r.to,[...t,n])}else{let e;l===y.Emphasis?e=`italic`:l===y.StrongEmphasis?e=`bold`:l===y.InlineCode?e=`code`:l===y.Strikethrough?e=`strike`:l===y.Highlight?e=`highlight`:l===y.Autolink&&(e=`autolink`);let n=e?[...t,a.mdPack.create({key:e})]:t,c=Hi.get(l),u=c?[...n,a[c].create()]:n;r.children.length===0?V(o,r.from,r.to,u):Gi(r.children,u,r.from,r.to,i,a,o,s)}c=r.to}c<r&&V(o,c,r,t)}function Ki(e){let t=0;for(let n of e.children)n.type===y.LinkMark&&t++;return t>=3}function qi(e){let t=-1,n=-1,r=null,i=null,a=0;for(let o of e.children){let e=o.type;e===y.LinkMark?(a++,a===1&&(t=o.to),a===2&&(n=o.from)):r==null&&e===y.URL?r=o:i==null&&e===y.LinkTitle&&(i=o)}return{labelFrom:t,labelTo:n,urlNode:r,titleNode:i}}function Ji(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function Yi(e,t,n,r,i){let a=i?.resolveFileLink;if(!a)return;let{labelFrom:o,labelTo:s,urlNode:c,titleNode:l}=qi(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?Wi(n.slice(l.from,l.to)):``;if(!a({href:u,label:d,title:f}))return;let p=d||Ji(u);return[...t,r.mdFile.create({href:u,name:p,title:f})]}function Xi(e,t,n,r,i,a){let{labelTo:o,urlNode:s,titleNode:c}=qi(e),l=s?n.slice(s.from,s.to):``,u=c?Wi(n.slice(c.from,c.to)):``,d=l?r.mdLinkText.create({href:l}):null,f=e=>o>=0&&e<o&&d!==null,p=r.mdPack.create({key:`link`,data:{href:l,title:u}}),m=[...t,p],h=e.from;for(let t of e.children){if(t.from>h){let e=f(h)?[...m,d]:m;V(i,h,t.from,e)}let e=f(t.from)?[...m,d]:m;if(t.type===y.Wikilink){ea(t,e,n,r,i),h=t.to;continue}if(t.type===y.WikiEmbed){ta(t,e,n,r,i,a),h=t.to;continue}let o=Hi.get(t.type),s=o?[...e,r[o].create()]:e;t.children.length===0?V(i,t.from,t.to,s):Gi(t.children,s,t.from,t.to,n,r,i,a),h=t.to}h<e.to&&V(i,h,e.to,m)}function Zi(e,t,n){if(!t||t.type!==y.Comment||t.from!==e.to)return;let r=Ai(n.slice(t.from,t.to));if(r)return{magic:r,to:t.to}}function Qi(e,t,n,r,i,a){let o=e.children.find(e=>e.type===y.URL);if(!o){Xi(e,t,n,r,i,void 0);return}let s=e.children.filter(e=>e.type===y.LinkMark),c=e.children.find(e=>e.type===y.LinkTitle),l=n.slice(o.from,o.to),u=s.length>=2?n.slice(s[0].to,s[1].from):``,d=c?Wi(n.slice(c.from,c.to)):``,f=a?.magic.width??null,p=a?.magic.height??null,m=a?.to??e.to;V(i,e.from,m,[...t,r.mdImage.create({src:l,alt:u,title:d,width:f,height:p,syntax:null,wikiTarget:null})])}function $i(e,t,n,r,i){let a=e.children.filter(e=>e.type===y.InlineMathMark);if(a.length<2){V(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})];V(i,e.from,a[0].to,[...s,r.mdMark.create()]),V(i,a[0].to,a[1].from,s),V(i,a[1].from,e.to,[...s,r.mdMark.create()])}function ea(e,t,n,r,i){let{target:a,display:o}=zi(n.slice(e.from,e.to));V(i,e.from,e.to,[...t,r.mdWikilink.create({target:a,display:o})])}function ta(e,t,n,r,i,a){let o=Ii(n.slice(e.from,e.to)),s=a?.resolveWikiEmbed?.(o);if(!s){V(i,e.from,e.to,t);return}if(s.kind===`image`){let n=s.src??o.target,a=(s.alt??o.display)||Ri(o.target);V(i,e.from,e.to,[...t,r.mdImage.create({src:n,alt:a,title:``,width:o.width,height:o.height,syntax:`wikiEmbed`,wikiTarget:o.target})]);return}if(s.kind===`file`){let n=s.href??o.target,a=(s.name??o.display)||Ri(o.target);V(i,e.from,e.to,[...t,r.mdFile.create({href:n,name:a,title:s.title??``})]);return}let c=s.target??o.target,l=s.display??o.display;V(i,e.from,e.to,[...t,r.mdWikilink.create({target:c,display:l})])}function V(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&Ti(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const na=`inline-marks-applied`;let ra=0,ia=0;function aa(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 oa(e){let t=new WeakMap;function n(n,r,i){let a=t.get(n);if(a?ia++:(ra++,a=Ui(Vs(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 x({key:new S(`inline-mark`),appendTransaction(e,t,n){for(let t of e)if(t.getMeta(na))return null;let i=r(n,aa(e,n));if(i.length===0)return null;let a=n.tr.step(new Ei(i));return a.setMeta(na,!0),a.setMeta(`addToHistory`,!1),a},view(e){return e.dispatch(sa(e.state)),{}}})}function sa(e){return e.tr.setMeta(`inline-marks-trigger`,!0)}function ca(e){return m(oa(e))}function la(){return u({name:`mdImage`,inclusive:!1,attrs:{src:{default:``},alt:{default:``},title:{default:``},width:{default:null},height:{default:null},syntax:{default:null},wikiTarget:{default:null}},toDOM:()=>[`span`,{class:`md-image`},0],parseDOM:[{tag:`span.md-image`}]})}function ua(){return u({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function da(){return u({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function fa(){return u({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function pa(){return u({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function ma(){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 ha(){return u({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function ga(){return u({name:`mdLinkTitle`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-title`},0],parseDOM:[{tag:`span.md-link-title`}]})}function _a(){return u({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function va(){return u({name:`mdHighlight`,toDOM:()=>[`mark`,0],parseDOM:[{tag:`mark`}]})}function ya(){return u({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function ba(){return u({name:`mdWikilink`,inclusive:!1,attrs:{target:{default:``},display:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink`},0],parseDOM:[{tag:`span.md-wikilink`}]})}function xa(){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 Sa(){return u({name:`mdMath`,inclusive:!1,attrs:{formula:{default:``}},toDOM:()=>[`span`,{class:`md-math`},0],parseDOM:[{tag:`span.md-math`}]})}function Ca(){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 wa(){return _(ua(),da(),fa(),pa(),ma(),ha(),ga(),_a(),va(),ya(),ba(),la(),xa(),Sa(),Ca())}const H={em:{node:y.Emphasis,delim:`*`},strong:{node:y.StrongEmphasis,delim:`**`},code:{node:y.InlineCode,delim:"`"},del:{node:y.Strikethrough,delim:`~~`},highlight:{node:y.Highlight,delim:`==`}},Ta=new Set([y.EmphasisMark,y.CodeMark,y.LinkMark,y.StrikethroughMark,y.HighlightMark]);function Ea(e){return[e.children[0],e.children.at(-1)]}function Da(e){let{type:t,children:n}=e;if(t===y.Emphasis||t===y.StrongEmphasis||t===y.Strikethrough||t===y.Highlight)return[n[0].to,n.at(-1).from];if(t===y.Link||t===y.Image){let e=n.find((e,t)=>t>0&&e.type===y.LinkMark);return e?[n[0].to,e.from]:null}return null}function Oa(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=Da(r);return i&&i[0]<=t&&n<=i[1]?Oa(r.children,t,n):Oa(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function ka(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return ka(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}function Aa(e,t,n){for(;t<n&&b(e.charCodeAt(t));)t++;for(;n>t&&b(e.charCodeAt(n-1));)n--;return[t,n]}function ja(e,t,n,r){let i=_e(be(e),e=>e.type===r.node||Ta.has(e.type));for(let r=t;r<n;r++)if(!b(e.charCodeAt(r))&&i.every(e=>!(e.from<=r&&r<e.to)))return!1;return!0}function Ma(e,t,n,r,i){let a=be(e),o=_e(a,e=>e.type===r.node);return i?Fa(e,o,t,n):Na(e,a,o,t,n,r)}function Na(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=Oa(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]=Ea(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=Pa(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function Pa(e,t,n,r,i){if(i.node!==y.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(nr(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function Fa(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=Ea(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=ka(a.children.slice(1,-1),s,c);s>t.to&&b(e.charCodeAt(s-1));)s--;for(;c<o.from&&b(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 Ia(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=be(e),o=_e(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=Ea(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return La(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function La(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=Da(n);return!e||t<e[0]||t>e[1]||La(n.children,t)}return!1}function U(e){return(t,n)=>{if(t.selection.empty)return Ra(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]=Aa(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:ja(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>Ma(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(C.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 Ra(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=Ia(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(C.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(C.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function za(){return s({toggleEm:()=>U(H.em),toggleStrong:()=>U(H.strong),toggleCode:()=>U(H.code),toggleDel:()=>U(H.del),toggleHighlight:()=>U(H.highlight)})}function Ba(){return l({"Mod-b":U(H.strong),"Mod-i":U(H.em),"Mod-e":U(H.code),"Mod-Shift-x":U(H.del),"Mod-Shift-h":U(H.highlight)})}function Va(){return _(za(),Ba())}function Ha(e,t,n){let r;return e.doc.nodesBetween(t.from,t.to,(e,i)=>(e.isText&&e.marks.some(e=>P(e,n))&&(r={from:Math.max(i,t.from),to:Math.min(i+e.nodeSize,t.to)}),!0)),r}function W(e,t){let n=O(e,t,`mdLinkText`),r=O(e,t,`mdPack`,{key:`link`})??O(e,t,`mdPack`,{key:`autolink`}),i=r??n;if(!i)return;let a=r?.mark.attrs,o=n?.mark.attrs?.href??``;if(!r||a?.key!==`link`){let t={from:i.from,to:i.to};return{unit:t,text:a?.key===`autolink`?Ha(e,t,`mdLinkText`)??{from:i.from+1,to:i.to-1}:t,href:o,title:``}}let s=Ha(e,i,`mdLinkUri`),c=s?s.from-2:i.to-3,l=s?s.from:i.to-1,u={from:i.from+1,to:c};return{unit:{from:i.from,to:i.to},text:u,label:u,dest:{from:l,to:i.to-1},href:a.data.href,title:a.data.title}}function Ua(e){let t=e.trim();return t?ve(t)??t:``}function Wa(e,t){return e+(t?` "${t.replaceAll(/(["\\])/g,String.raw`\$1`)}"`:``)}function Ga(e){let{selection:t}=e,{$from:n,$to:r,empty:i}=t;if(i||!n.sameParent(r)||!g(t))return;let a=n.parent;if(!a.isTextblock||a.type.spec.code)return;let o=n.start(),[s,c]=Aa(a.textContent,n.parentOffset,r.parentOffset);if(!(s>=c))return{from:o+s,to:o+c}}function Ka({href:e,title:t,wrapText:n=!0}={}){return(r,i)=>{let a=Ga(r);if(!a)return!1;if(i){let{from:o,to:s}=a,c=r.tr,l=`](${Wa(Ua(e??``),t??``)})`;c.insertText(l,s).insertText(`[`,o);let u=s+1+l.length;c.setSelection(n?C.create(c.doc,o,u):C.create(c.doc,u)),c.scrollIntoView(),i(c)}return!0}}function qa(e){return(t,n)=>{let r=W(t,t.selection.from);if(!r?.dest)return!1;let i=Wa(Ua(e.href??r.href),e.title??r.title);return n&&n(t.tr.insertText(i,r.dest.from,r.dest.to).scrollIntoView()),!0}}function Ja(){return(e,t)=>{let n=W(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 Ya(){return s({insertLink:Ka,updateLink:qa,removeLink:Ja})}function Xa(e){return(t,n,r)=>{let i=W(t,t.selection.from);if(i){if(n&&r){let{unit:{from:a,to:o}}=i;n(t.tr.setSelection(C.create(t.doc,a,o)).scrollIntoView()),r.focus(),e({from:a,to:o,link:i})}return!0}let a=Ga(t);if(a){if(n&&r){let{from:i,to:o}=a;n(t.tr.setSelection(C.create(t.doc,i,o)).scrollIntoView()),r.focus(),e({from:i,to:o,link:void 0})}return!0}return!1}}function Za(e){return l({"Mod-k":Xa(e)})}function Qa(e){return e===`)`||e===`*`||e===`+`?e:void 0}function $a(e){return e===`X`?e:void 0}function eo(e){return ro(e)?String(e):void 0}function to(){return f({type:`list`,attr:`marker`,default:null,splittable:!0,toDOM:e=>{let t=Qa(e);return t==null?null:[`data-list-marker`,t]},parseDOM:e=>{let t=e.getAttribute(`data-list-marker`);return t===`)`||t===`*`||t===`+`?t:null}})}function no(){return f({type:`list`,attr:`taskMarker`,default:null,splittable:!0,toDOM:e=>{let t=$a(e);return t==null?null:[`data-list-task-marker`,t]},parseDOM:e=>e.getAttribute(`data-list-task-marker`)===`X`?`X`:null})}function ro(e){return e===2||e===3||e===4}function io(){return f({type:`list`,attr:`markerGap`,default:1,splittable:!0,toDOM:e=>{let t=eo(e);return t==null?null:[`data-list-marker-gap`,t]},parseDOM:e=>{let t=Number.parseInt(e.getAttribute(`data-list-marker-gap`)??``,10);return ro(t)?t:1}})}function ao(e){let t=e.attrs;return{...wt(e),"data-list-marker":Qa(t.marker),"data-list-task-marker":$a(t.taskMarker),"data-list-marker-gap":eo(t.markerGap)}}function oo(){return o({serializeFragmentWrapper:e=>(...t)=>so(Dt(e(...t))),serializeNodeWrapper:e=>(...t)=>{let n=e(...t);return xe(n)?so(Dt(n)):n},nodesFromSchemaWrapper:e=>(...t)=>({...e(...t),list:e=>Ot({node:e,nativeList:!0,getAttributes:ao})})})}function so(e){xe(e)&&co(e);for(let t of e.children)so(t);return e}function co(e){if(!e.classList.contains(`prosemirror-flat-list`)||e.getAttribute(`data-list-kind`)!==`task`||e.children.length!==2)return;let t=e.children.item(0);if(!t||!t.classList.contains(`list-marker`))return;let n=Tt(t);if(!n)return;let r=e.children.item(1);if(!r||!r.classList.contains(`list-content`))return;let i=r.children.item(0);!i||![`P`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`].includes(i.tagName)||(e.replaceChildren(...r.children),i.prepend(n))}const lo=[At(/^\s?([*-])\s$/,{kind:`bullet`,collapsed:!1}),At(/^\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}}),At(/^\s?\[([\sX]?)\]\s$/i,({match:e})=>({kind:`task`,checked:[`x`,`X`].includes(e[1]),collapsed:!1})),At(/^\s?\+\s$/,{kind:`task`,marker:`+`,checked:!1,collapsed:!1})];function uo(){return _(lo.map(et))}function fo(){return D({kind:`task`,marker:`+`})}function po(){return D({kind:`task`,marker:null})}function mo(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e);if(F(n,`list`))return n.attrs}return null}function ho(){return(e,t,n)=>{let r=mo(e);return(r?.kind===`task`?r.marker===`+`?po():fo():D({kind:`task`,marker:null,checked:!1}))(e,t,n)}}function go(){return s({cycleCheckableList:ho,wrapInCircleTask:fo,wrapInSquareTask:po})}function _o(){return(e,t,n)=>{let r=mo(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},D(a)(e,t,n)}}function vo(){return(e,t,n)=>{let r=mo(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},D(a)(e,t,n)}}function yo(e){return F(e,`list`)&&e.attrs.kind===`bullet`&&e.childCount>=2&&e.firstChild?.type!==e.type}const bo=e=>{let t=e.attrs;return t.kind===`task`?{...t,checked:!t.checked}:yo(e)?{...t,collapsed:!t.collapsed}:t};function xo(){return m(()=>[new x({props:{handleDOMEvents:{mousedown:(e,t)=>Et({view:e,event:t,onListClick:bo})}}}),xt(),new x({props:{transformCopied:kt}}),St()])}function So(){return s({toggleListCollapsed:()=>Ct({isToggleable:yo})})}function Co(){return l({"Mod-Enter":_o(),"Mod-Shift-Enter":vo(),"Mod-.":Ct({isToggleable:yo}),"Mod-Shift-7":ct({kind:`ordered`,collapsed:!1}),"Mod-Shift-8":ct({kind:`bullet`,collapsed:!1}),"Mod-Shift-9":ct({kind:`task`,checked:!1,collapsed:!1})})}function wo(){return _(ot(),xo(),at(),rt(),oo(),it(),uo(),Co(),to(),no(),io(),go(),So())}let To;function Eo(){return To??=import(`./katex-chunk-Ch7kgbXr.js`).then(e=>e.render),To}function Do(e,t,n,r){try{e(n,t,{displayMode:r,throwOnError:!1,output:`mathml`})}catch(e){t.textContent=String(e)}}var Oo=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=C.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;Eo().then(t=>{e===this.#r&&Do(t,this.#n,e,!1)})}};function ko(){return d({name:`mdMath`,constructor:(e,t)=>new Oo(e,t)})}function Ao(e){return e===`left`||e===`center`||e===`right`?e:null}function jo(){return f({type:`tableCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>Ao(e.getAttribute(`data-align`))})}function Mo(){return f({type:`tableHeaderCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>Ao(e.getAttribute(`data-align`))})}function No(e){for(let t=0;t<e.childCount;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++)if(F(n.child(e),`tableHeaderCell`))return t}return 0}function Po(e){return e.child(No(e))}function Fo(e,t){return t>=e.childCount?null:e.child(t).attrs.align??null}function Io(e,t,n){if(e.childCount===0)return;let r=Po(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=Fo(r,e);(t.attrs.align??null)!==i&&n.setNodeMarkup(o,void 0,{...t.attrs,align:i}),o+=t.nodeSize}i+=a.nodeSize}}function Lo(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 Ro(){return new x({key:new S(`table-align-sync`),appendTransaction(e,t,n){if(!e.some(e=>e.docChanged))return;let r=Lo(e);if(!r)return;let i=n.doc,a=Math.max(0,Math.min(r.from,i.content.size)),o=Math.max(a,Math.min(r.to,i.content.size)),s;return i.nodesBetween(a,o,(e,t)=>F(e,`table`)?(s??=n.tr,Io(e,t,s),!1):!0),s?.docChanged?s:void 0}})}function zo(){return m(Ro())}function Bo(e){let{selection:t}=e;if(zt(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 Vo(e){return(t,n)=>{let r=Bo(t);if(!r||r.table.childCount===0)return!1;if(n){let{table:i,tablePos:a,firstColumn:o,lastColumn:s}=r,c=No(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 Ho(e){let t=Bo(e);if(!(!t||t.table.childCount===0))return Fo(Po(t.table),t.lastColumn)??void 0}function Uo(){return s({setTableColumnAlign:Vo})}function Wo(){return _(jo(),Mo(),zo(),Uo())}function Go(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 Ko=`paragraph`;function qo(){return _(p({name:`tableCell`,content:Ko}),p({name:`tableHeaderCell`,content:Ko}))}const Jo=(e,t)=>{let{selection:n}=e;return!zt(n)||!n.isColSelection()||!n.isRowSelection()?!1:Rt(e,t)};function Yo(){return v(l({Backspace:Jo,Delete:Jo}),t.high)}function Xo(){return _(Lt(),It(),jt(),Ft(),qo(),Wo(),Pt({allowTableNodeSelection:!0}),Mt(),Nt(),Yo())}function Zo(e){let{selection:t}=e,{$from:n,$to:r}=t;if(ae(t)&&n.depth===0||n.depth>0&&r.depth>0&&n.index(0)===r.index(0))return n.index(0)}function Qo(e){return(t,n)=>{if(Go(t))return!1;let r=Zo(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=ae(a)?je.create(u.doc,a.from+d):C.create(u.doc,a.anchor+d,a.head+d);u.setSelection(f),n(u.scrollIntoView())}return!0}}function $o(e){return(t,n,r)=>st(e)(t,n,r)||Qo(e===`up`?-1:1)(t,n,r)}function es(){return l({"Alt-ArrowUp":$o(`up`),"Alt-ArrowDown":$o(`down`)})}const G=new S(`meowdownPendingReplacement`);function K(e){return G.getState(e)?.pending??null}function ts(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 ns=new x({key:G,state:{init:()=>({pending:null}),apply:(e,t)=>{let n=e.getMeta(G);if(n)return ts(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=K(e);return!t||t.from>=t.to?null:w.create(e.doc,[Ne.inline(t.from,t.to,{class:`md-pending-replacement`})])}}});function rs(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(G,{type:`start`,from:r,to:i,mode:a})),!0)}}function is(e){return(t,n)=>K(t)?(n?.(t.tr.setMeta(G,{type:`append`,text:e})),!0):!1}function as(){return(e,t)=>K(e)?(t?.(e.tr.setMeta(G,{type:`discard`})),!0):!1}function os(e={}){return(t,n)=>{let r=K(t);if(!r||!r.text.trim())return!1;if(n){let i=e.mode??r.mode,a=Us(t.schema),o=Y(r.text,{nodes:a}),s=t.tr;if(s.setMeta(G,{type:`accept`}),i===`append`){let e=t.doc.resolve(r.to).after(1);s.insert(e,o.content),s.setSelection(C.near(s.doc.resolve(e+o.content.size),-1))}else{let e=t.doc.resolve(r.from),n=t.doc.resolve(r.to),i=o.childCount===1?o.firstChild:null;i!=null&&F(i,`paragraph`)&&e.sameParent(n)&&e.parent.isTextblock?(s.replaceWith(r.from,r.to,i.content),s.setSelection(C.near(s.doc.resolve(r.from+i.content.size),-1))):(s.replaceRange(r.from,r.to,new E(o.content,0,0)),s.setSelection(C.near(s.doc.resolve(s.mapping.map(r.to)),-1)))}n(s.scrollIntoView())}return!0}}function ss(){return s({startPendingReplacement:rs,appendPendingReplacementText:is,acceptPendingReplacement:os,discardPendingReplacement:as})}function cs(){return l({"Mod-Enter":os(),Escape:as()})}function ls(){return _(m(ns),ss(),cs())}function us(e){return m(new x({view:()=>({update:(t,n)=>{let r=G.getState(n),i=G.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 ds(e){return e.left===e.right&&e.top===e.bottom}function q(e,t,n){if(t<0||t>e.state.doc.content.size)return;let r;try{r=e.coordsAtPos(t,n)}catch{return}return ds(r)?void 0:r}function fs(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 ps(e){let t=e.state,n=t.selection.head,r=z(t,n),i=B(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=q(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 ms(e){let t=e.state,n=t.selection.head;for(let r of Zt){let i=O(t,n,r);if(i==null||i.from!==n&&i.to!==n)continue;let a=gs(e,i.from+1);if(a==null)continue;let o=Array.from(a.getClientRects()).filter(e=>e.height>0);if(o.length===0)continue;let s=i.to===n,c=s?o[o.length-1]:o[0];return{left:s?c.right:c.left,top:c.top,height:c.height}}}function hs(e,t,n){let r=e.state;for(let i of Zt){let a=O(r,t,i);if(a==null)continue;let o=gs(e,a.from+1);if(o==null)continue;let s=Array.from(o.getClientRects()).filter(e=>e.height>0);if(s.length!==0)return n===1?s[0]:s[s.length-1]}}function gs(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 _s(e){return ps(e)??ms(e)}const vs=new S(`meowdown-scroll-to-selection`);function ys(e){let t=e.state.selection;if(!g(t)||q(e,t.head,1)!=null)return!1;let n=_s(e);if(n==null)return!1;let r=e.domAtPos(t.head).node;return Cs(e,{left:n.left,right:n.left,top:n.top,bottom:n.top+n.height},r),!0}function J(e,t){return typeof e==`number`?e:e[t]}function bs(e){let t=e.assignedSlot??e.parentNode;return t?.nodeType===11?t.host:t}function xs(e){let t=e.defaultView?.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Ss(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function Cs(e,t,n){let r=e.someProp(`scrollThreshold`)??0,i=e.someProp(`scrollMargin`)??5,a=e.dom.ownerDocument;for(let e=n;e;){if(e.nodeType!==1){e=bs(e);continue}let n=e,o=n===a.body,s=o?xs(a):Ss(n),c=0,l=0;if(t.top<s.top+J(r,`top`)?l=-(s.top-t.top+J(i,`top`)):t.bottom>s.bottom-J(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+J(i,`top`)-s.top:t.bottom-s.bottom+J(i,`bottom`)),t.left<s.left+J(r,`left`)?c=-(s.left-t.left+J(i,`left`)):t.right>s.right-J(r,`right`)&&(c=t.right-s.right+J(i,`right`)),c||l)if(o)a.defaultView?.scrollBy(c,l);else{let e=n.scrollLeft,r=n.scrollTop;l&&(n.scrollTop+=l),c&&(n.scrollLeft+=c);let i=n.scrollLeft-e,a=n.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=o?`fixed`:getComputedStyle(n).position;if(/^(?:fixed|sticky)$/.test(u))break;e=u===`absolute`?n.offsetParent:bs(n)}}function ws(){return m(new x({key:vs,props:{handleScrollToSelection:ys}}))}function Ts(e,t){return(n,r)=>{let i=e<0?Me.atStart(n.doc):Me.atEnd(n.doc),a=t?C.between(n.selection.$anchor,i.$head):i;return n.selection.eq(a)||r?.(n.tr.setSelection(a).scrollIntoView()),!0}}function Es(){return l({"Meta-ArrowUp":Ts(-1,!1),"Meta-ArrowDown":Ts(1,!1),"Shift-Meta-ArrowUp":Ts(-1,!0),"Shift-Meta-ArrowDown":Ts(1,!0)})}function Ds(e){e.offsetWidth}const Os=new S(`meowdown-virtual-caret`),ks=[`md-virtual-caret-blink`,`md-virtual-caret-blink2`];function As(e){let t=e.height*.19999999999999996;return{left:e.left,top:e.top-t/2,height:e.height+t}}function js(e){let t=fs(e)??ps(e);return t==null?ms(e):As(t)}function Ms(e,t){return e==null||t==null?e===t:e.left===t.left&&e.top===t.top&&e.height===t.height}var Ns=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=ks[this.#s]}#l=()=>{let e=this.#e;if(e.isDestroyed)return;let t=e.state,n=t.selection,r=g(n)&&n.empty?js(e):void 0,i=r!=null&&A(t)===`hide`?li(t,n.head):void 0;if(Ms(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&&(Ds(this.#n),this.#n.style.transitionProperty=``)}};function Ps(){return m(new x({key:Os,view:e=>new Ns(e)}))}function Fs(e){return _(Vn(),Ee(),Qr(),ke(),Te(),wo(),Ln(),Xo(),Hr(),xi(),Si(),wa(),Nr(),Zr(),es(),Es(),ca(e),Va(),Ya(),Vi(),ko(),qt(e.markMode??`focus`),Dr(),Ps(),ws(),yi(),un({marks:Zt.map(e=>({name:e,modes:[`hide`,`focus`,`show`]}))}),a(),i(),c(),De(),Ae(),Oe(),Yr(),ls())}function Is(e={}){return Fs(e)}const Ls=we(()=>{let e=Is().schema;if(e==null)throw Error(`Unexpected empty schema`);return e}),Rs=we(()=>r(Ls())),zs=we(()=>n(Ls())),Bs=`meowdown_mark_builders`;function Vs(e){let t=e.cached[Bs];if(t)return t;let r=n(e);return e.cached[Bs]=r,r}const Hs=`meowdown_node_builders`;function Us(e){let t=e.cached[Hs];if(t)return t;let n=r(e);return e.cached[Hs]=n,n}function Y(e,t={}){let{nodes:n=Rs(),frontmatter:r=!1}=t,i,a=e;if(r){let[t,n]=Gs(e);i=t,n&&(a=e.slice(n))}let o=Ks(n,ye.parse(a).cursor(),a);return n.doc(i===void 0?{}:{frontmatter:i},o)}const Ws=/^---[ \t]*\r?\n([\s\S]*?\n)?---[ \t]*(?:\r?\n|$)/;function Gs(e){let t=Ws.exec(e);return t?[(t[1]??``).replace(/\r?\n$/,``),t[0].length]:[]}function Ks(e,t,n){let r=[];if(!t.firstChild())return r;let i;do i!=null&&qs(r,e,n,i,t.from),i=t.to,r.push(...Js(e,t,n));while(t.nextSibling());return t.parent(),r}function qs(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 Js(e,t,n){switch(t.type.id){case y.ATXHeading1:return[X(e,t,n,1,!1)];case y.ATXHeading2:return[X(e,t,n,2,!1)];case y.ATXHeading3:return[X(e,t,n,3,!1)];case y.ATXHeading4:return[X(e,t,n,4,!1)];case y.ATXHeading5:return[X(e,t,n,5,!1)];case y.ATXHeading6:return[X(e,t,n,6,!1)];case y.SetextHeading1:return[X(e,t,n,1,!0)];case y.SetextHeading2:return[X(e,t,n,2,!0)];case y.Paragraph:return[ec(e,t,n)];case y.CommentBlock:return[tc(e,t,n)];case y.HTMLBlock:case y.ProcessingInstructionBlock:return[ec(e,t,n)];case y.Blockquote:return[nc(e,t,n)];case y.BulletList:return rc(e,t,n,`bullet`);case y.OrderedList:return rc(e,t,n,`ordered`);case y.FencedCode:case y.CodeBlock:return[ac(e,t,n)];case y.BlockMath:return[oc(e,t,n)];case y.HorizontalRule:{let r=n.slice(t.from,t.to).trimEnd();return[e.horizontalRule({marker:r===`---`?null:r})]}case y.Table:return[sc(e,t,n)];case y.Task:return[ec(e,t,n)];default:return n.slice(t.from,t.to).trim()===``?[]:(console.warn(`[meowdown] unsupported lezer block "${t.type.name}"`),[ec(e,t,n)])}}function X(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===y.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===y.HeaderMark&&n>o&&(s=n,c=n,l=r),t.parent()}let u=Qs(n.slice(o,s),Z(n,o)).trim(),d=i?Ys(n,c,l)||1:null,f=!i&&c>=0&&Xs(n,c,l)||null;return e.heading({level:r,setextUnderline:d,closingHashes:f},u)}function Ys(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 Xs(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 Z(e,t){let n=e.lastIndexOf(`
26
- `,t-1)+1,r=0;for(let i=n;i<t;i++)r+=e.charCodeAt(i)===9?4-r%4:1;return r}function Zs(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 Qs(e,t){return t===0||!e.includes(`
27
+ `)}function Ir(){return m(new x({key:new S(`meowdown-plain-text-copy`),props:{clipboardTextSerializer:(e,t)=>{let n=A(t.state)===`hide`?Lr(e):e;return Fr(t.state.schema,n)}}}))}function Lr(e){return new E(Rr(e.content),e.openStart,e.openEnd)}function Rr(e){let t=[];return e.forEach(e=>{t.push(e.isTextblock?Br(e):zr(e))}),Ue.from(t)}function zr(e){return e.childCount>0?e.copy(Rr(e.content)):e}function Br(e){let t=e.type.schema,n=[];for(let r of jn(e)){let e=r.atom;if(e!=null){if(P(e,`mdWikilink`)){let r=e.attrs,i=r.display||r.target;i&&n.push(t.text(i))}else n.push(...r.children);continue}for(let e of r.children)An(e.marks)||n.push(e)}return e.copy(Ue.from(n))}function Vr(){return _(Qn(),Ir(),dr(),cr(),mr())}const L=new Map,Hr=new Map,Ur={math:`latex`};async function Wr(e){let t=L.get(e);if(t!==void 0)return t;let n=Xe.matchLanguageName(Ze,Ur[e]??e,!0);if(!n)return L.set(e,null),null;let r=n.support;if(!r)try{r=await n.load()}catch(t){return console.error(`[meowdown] Failed to load language "${e}":`,t),L.set(e,null),null}return L.set(e,r),r}function Gr(e,t){let n=Hr.get(e);if(n)return n;let r=et({parse:e=>t.language.parser.parse(e.content),highlighter:Qe});return Hr.set(e,r),r}const Kr=e=>{let t=e.language?.trim();if(!t)return[];let n=L.get(t);return n===null?[]:n?Gr(t,n)(e):Wr(t).then(()=>void 0)};function qr(){return fe({parser:Kr,nodeTypes:[`codeBlock`]})}function Jr(e,t){let n=t.language.parser.parse(e),r=[];return $e(n,Qe,(e,t,n)=>{r.push([e,t,n])}),r}function Yr(e,t){let n=t.trim();if(!n)return[];let r=L.get(n);return r===null?[]:r?Jr(e,r):Wr(n).then(t=>t?Jr(e,t):[])}function Xr(){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 Zr(){return f({type:`codeBlock`,attr:`fenceLength`,default:null,toDOM:e=>e==null?null:[`data-fence-length`,String(e)],parseDOM:e=>{let t=Tn(e.getAttribute(`data-fence-length`));return t!=null&&t>3?t:null}})}function Qr(e){return{language:e[1]||``,fenceStyle:`tilde`}}function $r(){return it({regex:/^~~~(\S*)\s$/,type:`codeBlock`,attrs:Qr})}function ei(){return nt({regex:/^~~~(\S*)$/,type:`codeBlock`,attrs:Qr})}function ti(){return nt({regex:/^\$\$$/,type:`codeBlock`,attrs:()=>({language:`math`,fenceStyle:`dollar`})})}function ni(){return _(de(),Xr(),Zr(),$r(),ei(),ti())}function ri(e,t){return(n,r)=>{if(r){let i=C.create(n.doc,e,t);r(n.tr.setSelection(i))}return!0}}function ii(e,t,n){return(r,i)=>{if(i){let a=C.between(e,t,n);i(r.tr.setSelection(a))}return!0}}function ai(e){return(t,n)=>{if(!e.trim())return!1;let r=X(e,{nodes:rc(t.schema)}).content;if(r.childCount===0)return!1;let i=r.childCount===1&&F(r.child(0),`paragraph`)?new E(r,1,1):new E(r,0,E.maxOpen(r).openEnd);if(n){let e=t.tr,r=e.selection;(!g(r)||!r.empty)&&e.setSelection(C.near(r.$from)),n(e.replaceSelection(i).scrollIntoView())}return!0}}function oi(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);at(s),n(s.scrollIntoView())}return!0}}function si(){return pt(oe({type:`paragraph`}),ft(),mt)}function ci(){return(e,t)=>(t&&t(e.tr.scrollIntoView()),!0)}function li(){return s({insertMarkdown:ai,insertTrigger:oi,scrollIntoView:ci,selectText:ri,selectTextBetween:ii,turnIntoText:si})}const ui=(e,t,n)=>{let{selection:r}=e;return r.empty||n?.composing?!1:(t?.(e.tr.setSelection(C.near(r.$head))),!0)};function di(){return v(l({Escape:ui}),t.low)}function fi(){return f({type:`doc`,attr:`frontmatter`,default:null})}function pi(e,t){return t(e.state,e.dispatch,e)}function mi(e,t){if(t<0||t+1>e.doc.content.size)return;let n=e.doc.resolve(t),r=n.parent.maybeChild(n.index());if(!(r==null||!r.isText))return r.marks}function R(e,t){let n=mi(e,t);return n!=null&&n.some(e=>Dn.has(e.type.name))}function hi(e,t){if(t<0||t>e.doc.content.size)return!1;let n=e.doc.resolve(t);return n.parent.isTextblock&&!n.parent.type.spec.code}function z(e,t){if(!hi(e,t))return;let n=e.doc.resolve(t).start(),r=t;for(;r>n&&R(e,r-1);)r--;return r<t?{from:r,to:t}:void 0}function B(e,t){if(!hi(e,t))return;let n=e.doc.resolve(t).end(),r=t;for(;r<n&&R(e,r);)r++;return r>t?{from:t,to:r}:void 0}function gi(e,t){return R(e,t-1)&&R(e,t)}function _i(e,t){if(!gi(e,t))return;let n=z(e,t);if(!n)return;let r=B(e,t);if(r)return{from:n.from,to:r.to}}function vi(e,t,n){let r=mi(e,t);return r!=null&&n.isInSet(r)}function yi(e,t){let n=mi(e,t);if(n==null)return;let r=ee(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&&vi(e,r-1,n);)r--;let i=t+1;for(;i<s&&vi(e,i,n);)i++;(c==null||i-r<c.to-c.from)&&(c={from:r,to:i})}return c}function bi(e,t,n){let r=yi(e,n===`from`?t.from:t.to-1);return r==null?!1:n===`from`?r.from===t.from:r.to===t.to}function xi(e,t,n){let r=bi(e,t,`from`),i=bi(e,t,`to`);return r&&!i?t.from:i&&!r?t.to:n-t.from<=t.to-n?t.from:t.to}function Si(e,t,n,r){if(!hi(e,n))return n;let i=_i(e,n);if(i!=null)return r?xi(e,i,n):n>=t?i.to:i.from;if(!r)return n;let a=z(e,n);if(a!=null&&bi(e,a,`from`))return a.from;let o=B(e,n);return o!=null&&bi(e,o,`to`)?o.to:n}function Ci(e,t){if(!hi(e,t))return;let n=R(e,t-1),r=R(e,t);if(n!==r)return r?`left`:`right`}function wi(e,t){let n=yi(e,t);if(n==null)return[];let r=B(e,n.from),i=z(e,n.to),a=[];return i!=null&&a.push(i),r!=null&&(i==null||r.from!==i.from)&&a.push(r),a}const Ti=new S(`meowdown-hidden-run-snap`),Ei=new S(`meowdown-hidden-run-beforeinput`);function Di(){let e=!1;return new x({key:Ti,props:{handleDOMEvents:{compositionstart:()=>(e=!0,!1),compositionend:()=>(e=!1,!1)}},appendTransaction:(t,n,r)=>{if(e||A(r)!==`hide`)return null;let i=r.selection;if(!g(i))return null;let a=t.some(e=>e.getMeta(`pointer`)!=null);if(i.empty){let e=Si(r,n.selection.head,i.head,a);return e===i.head?null:r.tr.setSelection(C.create(r.doc,e))}let o=_i(r,i.from)?.from??i.from,s=_i(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(C.create(r.doc,c,l))}})}const Oi=(e,t)=>{if(A(e)!==`hide`)return!1;let n=e.selection;if(!g(n)||!n.empty)return!1;let r=Si(e,n.head,n.head,!0);return r===n.head||t?.(e.tr.setSelection(C.create(e.doc,r))),!1};function ki(e){return(t,n)=>{if(A(t)!==`hide`)return!1;let r=t.selection;if(!g(r)||!r.empty)return!1;let i=r.$head;if(!i.parent.isTextblock||i.parent.type.spec.code)return!1;let a=e===-1?z(t,r.head):B(t,r.head);if(a==null)return!1;let o=wi(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 Ai=ki(-1),ji=ki(1);function Mi(){return new x({key:Ei,props:{handleDOMEvents:{beforeinput:(e,t)=>{if(e.composing)return!1;let n=t.inputType===`deleteContentBackward`?Ai:t.inputType===`deleteContentForward`?ji:void 0;return n==null||!pi(e,n)?!1:(t.preventDefault(),!0)}}}})}function Ni(){return _(m(Di()),m(Mi()),v(l({Enter:Oi,Backspace:Ai,Delete:ji}),t.highest))}function Pi(){return f({type:`horizontalRule`,attr:`marker`,default:null,toDOM:e=>e?[`data-hr-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-hr-marker`)})}function Fi(){return _(ht(),Pi())}function Ii(){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 Li(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function Ri(e,t){let[n,r,i]=t;return[n,r,i.map(t=>We.fromJSON(e,t))]}function zi(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 Bi=class e extends xt{constructor(e){super(),this.chunks=e}apply(e){if(this.chunks.length===0)return St.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=We.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(zi(l,c))return!1;n??=new Ct(e);for(let e of l)n.removeMark(i,a,e);for(let e of c)n.addMark(i,a,e);return!1})}return St.ok(n?n.doc:e)}invert(e){if(this.chunks.length===0)return Vi;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 bt(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(Li)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>Ri(t,e)))}};xt.jsonID(`batchSetMark`,Bi);const Vi=new Bi([]),Hi=/^<!--\s*(\{[^}]*\})\s*-->$/,Ui=/<!--\s*\{[^}]*\}\s*-->$/;function Wi(e){let t=Hi.exec(e.trim());if(!t)return;let n;try{n=JSON.parse(t[1])}catch{return}if(!Ce(n))return;let r=Gi(n);return Object.keys(r).length>0?r:void 0}function Gi(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 Ki(e){return`<!-- ${JSON.stringify(e)} -->`}function qi(e){return e.replace(Ui,``)}const Ji=/^(\d+)(?:x(\d+))?$/i;function Yi(e){if(!e)return null;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)&&t>0?t:null}function Xi(e){let t=e.replace(/^!\[\[/,``).replace(/\]\]$/,``),n=t.lastIndexOf(`|`);if(n<0)return{target:t.trim(),display:``,width:null,height:null};let r=t.slice(0,n).trim(),i=t.slice(n+1).trim(),a=Ji.exec(i);if(!a)return{target:r,display:i,width:null,height:null};let o=Yi(a[1]),s=Yi(a[2]);return o==null||a[2]&&s==null?{target:r,display:i,width:null,height:null}:{target:r,display:``,width:o,height:s}}function Zi(e,t,n){return`![[${e}|${Math.round(t)}x${Math.round(n)}]]`}function Qi(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function $i(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 ea(){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 ta(){return d({name:`mdWikilink`,constructor:ea()})}const na=new Map([[y.Emphasis,`mdEm`],[y.StrongEmphasis,`mdStrong`],[y.InlineCode,`mdCode`],[y.Strikethrough,`mdDel`],[y.Highlight,`mdHighlight`],[y.EmphasisMark,`mdMark`],[y.CodeMark,`mdMark`],[y.LinkMark,`mdMark`],[y.StrikethroughMark,`mdMark`],[y.HighlightMark,`mdMark`],[y.URL,`mdLinkUri`],[y.LinkTitle,`mdLinkTitle`],[y.Hashtag,`mdTag`],[y.WikilinkMark,`mdMark`]]);function ra(e,t,n){let r=be(t),i=[];return aa(r,[],0,t.length,t,e,i,n),i}function ia(e){return e.slice(1,-1).replaceAll(/\\(.)/g,`$1`)}function aa(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&&V(o,c,r.from,t);let l=r.type;if(l===y.Link)if(!oa(r))aa(r.children.filter(e=>e.type!==y.LinkMark&&e.type!==y.LinkLabel),t,r.from,r.to,i,a,o,s);else{let e=la(r,t,i,a,s);e?V(o,r.from,r.to,e):ua(r,t,i,a,o,s)}else if(l===y.Image){let s=da(r,e[n+1],i);fa(r,t,i,a,o,s),s&&n++,c=s?s.to:r.to;continue}else if(l===y.Wikilink)ma(r,t,i,a,o);else if(l===y.WikiEmbed)ha(r,t,i,a,o,s);else if(l===y.InlineMath)pa(r,t,i,a,o);else if(l===y.URL){let e=ve(i.slice(r.from,r.to)),n=e?a.mdLinkText.create({href:e}):a.mdLinkUri.create();V(o,r.from,r.to,[...t,n])}else{let e;l===y.Emphasis?e=`italic`:l===y.StrongEmphasis?e=`bold`:l===y.InlineCode?e=`code`:l===y.Strikethrough?e=`strike`:l===y.Highlight?e=`highlight`:l===y.Autolink&&(e=`autolink`);let n=e?[...t,a.mdPack.create({key:e})]:t,c=na.get(l),u=c?[...n,a[c].create()]:n;r.children.length===0?V(o,r.from,r.to,u):aa(r.children,u,r.from,r.to,i,a,o,s)}c=r.to}c<r&&V(o,c,r,t)}function oa(e){let t=0;for(let n of e.children)n.type===y.LinkMark&&t++;return t>=3}function sa(e){let t=-1,n=-1,r=null,i=null,a=0;for(let o of e.children){let e=o.type;e===y.LinkMark?(a++,a===1&&(t=o.to),a===2&&(n=o.from)):r==null&&e===y.URL?r=o:i==null&&e===y.LinkTitle&&(i=o)}return{labelFrom:t,labelTo:n,urlNode:r,titleNode:i}}function ca(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function la(e,t,n,r,i){let a=i?.resolveFileLink;if(!a)return;let{labelFrom:o,labelTo:s,urlNode:c,titleNode:l}=sa(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?ia(n.slice(l.from,l.to)):``;if(!a({href:u,label:d,title:f}))return;let p=d||ca(u);return[...t,r.mdFile.create({href:u,name:p,title:f})]}function ua(e,t,n,r,i,a){let{labelTo:o,urlNode:s,titleNode:c}=sa(e),l=s?n.slice(s.from,s.to):``,u=c?ia(n.slice(c.from,c.to)):``,d=l?r.mdLinkText.create({href:l}):null,f=e=>o>=0&&e<o&&d!==null,p=r.mdPack.create({key:`link`,data:{href:l,title:u}}),m=[...t,p],h=e.from;for(let t of e.children){if(t.from>h){let e=f(h)?[...m,d]:m;V(i,h,t.from,e)}let e=f(t.from)?[...m,d]:m;if(t.type===y.Wikilink){ma(t,e,n,r,i),h=t.to;continue}if(t.type===y.WikiEmbed){ha(t,e,n,r,i,a),h=t.to;continue}let o=na.get(t.type),s=o?[...e,r[o].create()]:e;t.children.length===0?V(i,t.from,t.to,s):aa(t.children,s,t.from,t.to,n,r,i,a),h=t.to}h<e.to&&V(i,h,e.to,m)}function da(e,t,n){if(!t||t.type!==y.Comment||t.from!==e.to)return;let r=Wi(n.slice(t.from,t.to));if(r)return{magic:r,to:t.to}}function fa(e,t,n,r,i,a){let o=e.children.find(e=>e.type===y.URL);if(!o){ua(e,t,n,r,i,void 0);return}let s=e.children.filter(e=>e.type===y.LinkMark),c=e.children.find(e=>e.type===y.LinkTitle),l=n.slice(o.from,o.to),u=s.length>=2?n.slice(s[0].to,s[1].from):``,d=c?ia(n.slice(c.from,c.to)):``,f=a?.magic.width??null,p=a?.magic.height??null,m=a?.to??e.to;V(i,e.from,m,[...t,r.mdImage.create({src:l,alt:u,title:d,width:f,height:p,syntax:null,wikiTarget:null})])}function pa(e,t,n,r,i){let a=e.children.filter(e=>e.type===y.InlineMathMark);if(a.length<2){V(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})];V(i,e.from,a[0].to,[...s,r.mdMark.create()]),V(i,a[0].to,a[1].from,s),V(i,a[1].from,e.to,[...s,r.mdMark.create()])}function ma(e,t,n,r,i){let{target:a,display:o}=$i(n.slice(e.from,e.to));V(i,e.from,e.to,[...t,r.mdWikilink.create({target:a,display:o})])}function ha(e,t,n,r,i,a){let o=Xi(n.slice(e.from,e.to)),s=a?.resolveWikiEmbed?.(o);if(!s){V(i,e.from,e.to,t);return}if(s.kind===`image`){let n=s.src??o.target,a=(s.alt??o.display)||Qi(o.target);V(i,e.from,e.to,[...t,r.mdImage.create({src:n,alt:a,title:``,width:o.width,height:o.height,syntax:`wikiEmbed`,wikiTarget:o.target})]);return}if(s.kind===`file`){let n=s.href??o.target,a=(s.name??o.display)||Qi(o.target);V(i,e.from,e.to,[...t,r.mdFile.create({href:n,name:a,title:s.title??``})]);return}let c=s.target??o.target,l=s.display??o.display;V(i,e.from,e.to,[...t,r.mdWikilink.create({target:c,display:l})])}function V(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&zi(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const ga=`inline-marks-applied`;let _a=0,va=0;function ya(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 ba(e){let t=new WeakMap;function n(n,r,i){let a=t.get(n);if(a?va++:(_a++,a=ra(tc(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 x({key:new S(`inline-mark`),appendTransaction(e,t,n){for(let t of e)if(t.getMeta(ga))return null;let i=r(n,ya(e,n));if(i.length===0)return null;let a=n.tr.step(new Bi(i));return a.setMeta(ga,!0),a.setMeta(`addToHistory`,!1),a},view(e){return e.dispatch(xa(e.state)),{}}})}function xa(e){return e.tr.setMeta(`inline-marks-trigger`,!0)}function Sa(e){return m(ba(e))}function Ca(){return u({name:`mdImage`,inclusive:!1,attrs:{src:{default:``},alt:{default:``},title:{default:``},width:{default:null},height:{default:null},syntax:{default:null},wikiTarget:{default:null}},toDOM:()=>[`span`,{class:`md-image`},0],parseDOM:[{tag:`span.md-image`}]})}function wa(){return u({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function Ta(){return u({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function Ea(){return u({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function Da(){return u({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function Oa(){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 ka(){return u({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function Aa(){return u({name:`mdLinkTitle`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-title`},0],parseDOM:[{tag:`span.md-link-title`}]})}function ja(){return u({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function Ma(){return u({name:`mdHighlight`,toDOM:()=>[`mark`,0],parseDOM:[{tag:`mark`}]})}function Na(){return u({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function Pa(){return u({name:`mdWikilink`,inclusive:!1,attrs:{target:{default:``},display:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink`},0],parseDOM:[{tag:`span.md-wikilink`}]})}function Fa(){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 Ia(){return u({name:`mdMath`,inclusive:!1,attrs:{formula:{default:``}},toDOM:()=>[`span`,{class:`md-math`},0],parseDOM:[{tag:`span.md-math`}]})}function La(){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 Ra(){return _(wa(),Ta(),Ea(),Da(),Oa(),ka(),Aa(),ja(),Ma(),Na(),Pa(),Ca(),Fa(),Ia(),La())}const H={em:{node:y.Emphasis,delim:`*`},strong:{node:y.StrongEmphasis,delim:`**`},code:{node:y.InlineCode,delim:"`"},del:{node:y.Strikethrough,delim:`~~`},highlight:{node:y.Highlight,delim:`==`}},za=new Set([y.EmphasisMark,y.CodeMark,y.LinkMark,y.StrikethroughMark,y.HighlightMark]);function Ba(e){return[e.children[0],e.children.at(-1)]}function Va(e){let{type:t,children:n}=e;if(t===y.Emphasis||t===y.StrongEmphasis||t===y.Strikethrough||t===y.Highlight)return[n[0].to,n.at(-1).from];if(t===y.Link||t===y.Image){let e=n.find((e,t)=>t>0&&e.type===y.LinkMark);return e?[n[0].to,e.from]:null}return null}function Ha(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=Va(r);return i&&i[0]<=t&&n<=i[1]?Ha(r.children,t,n):Ha(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function Ua(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return Ua(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}function Wa(e,t,n){for(;t<n&&b(e.charCodeAt(t));)t++;for(;n>t&&b(e.charCodeAt(n-1));)n--;return[t,n]}function Ga(e,t,n,r){let i=_e(be(e),e=>e.type===r.node||za.has(e.type));for(let r=t;r<n;r++)if(!b(e.charCodeAt(r))&&i.every(e=>!(e.from<=r&&r<e.to)))return!1;return!0}function Ka(e,t,n,r,i){let a=be(e),o=_e(a,e=>e.type===r.node);return i?Ya(e,o,t,n):qa(e,a,o,t,n,r)}function qa(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=Ha(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]=Ba(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=Ja(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function Ja(e,t,n,r,i){if(i.node!==y.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(gr(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function Ya(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=Ba(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=Ua(a.children.slice(1,-1),s,c);s>t.to&&b(e.charCodeAt(s-1));)s--;for(;c<o.from&&b(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 Xa(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=be(e),o=_e(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=Ba(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return Za(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function Za(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=Va(n);return!e||t<e[0]||t>e[1]||Za(n.children,t)}return!1}function U(e){return(t,n)=>{if(t.selection.empty)return Qa(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]=Wa(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:Ga(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>Ka(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(C.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 Qa(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=Xa(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(C.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(C.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function $a(){return s({toggleEm:()=>U(H.em),toggleStrong:()=>U(H.strong),toggleCode:()=>U(H.code),toggleDel:()=>U(H.del),toggleHighlight:()=>U(H.highlight)})}function eo(){return l({"Mod-b":U(H.strong),"Mod-i":U(H.em),"Mod-e":U(H.code),"Mod-Shift-x":U(H.del),"Mod-Shift-h":U(H.highlight)})}function to(){return _($a(),eo())}function no(e,t,n){let r;return e.doc.nodesBetween(t.from,t.to,(e,i)=>(e.isText&&e.marks.some(e=>P(e,n))&&(r={from:Math.max(i,t.from),to:Math.min(i+e.nodeSize,t.to)}),!0)),r}function W(e,t){let n=O(e,t,`mdLinkText`),r=O(e,t,`mdPack`,{key:`link`})??O(e,t,`mdPack`,{key:`autolink`}),i=r??n;if(!i)return;let a=r?.mark.attrs,o=n?.mark.attrs?.href??``;if(!r||a?.key!==`link`){let t={from:i.from,to:i.to};return{unit:t,text:a?.key===`autolink`?no(e,t,`mdLinkText`)??{from:i.from+1,to:i.to-1}:t,href:o,title:``}}let s=no(e,i,`mdLinkUri`),c=s?s.from-2:i.to-3,l=s?s.from:i.to-1,u={from:i.from+1,to:c};return{unit:{from:i.from,to:i.to},text:u,label:u,dest:{from:l,to:i.to-1},href:a.data.href,title:a.data.title}}function ro(e){let t=e.trim();return t?ve(t)??t:``}function io(e,t){return e+(t?` "${t.replaceAll(/(["\\])/g,String.raw`\$1`)}"`:``)}function ao(e){let{selection:t}=e,{$from:n,$to:r,empty:i}=t;if(i||!n.sameParent(r)||!g(t))return;let a=n.parent;if(!a.isTextblock||a.type.spec.code)return;let o=n.start(),[s,c]=Wa(a.textContent,n.parentOffset,r.parentOffset);if(!(s>=c))return{from:o+s,to:o+c}}function oo({href:e,title:t,wrapText:n=!0}={}){return(r,i)=>{let a=ao(r);if(!a)return!1;if(i){let{from:o,to:s}=a,c=r.tr,l=`](${io(ro(e??``),t??``)})`;c.insertText(l,s).insertText(`[`,o);let u=s+1+l.length;c.setSelection(n?C.create(c.doc,o,u):C.create(c.doc,u)),c.scrollIntoView(),i(c)}return!0}}function so(e){return(t,n)=>{let r=W(t,t.selection.from);if(!r?.dest)return!1;let i=io(ro(e.href??r.href),e.title??r.title);return n&&n(t.tr.insertText(i,r.dest.from,r.dest.to).scrollIntoView()),!0}}function co(){return(e,t)=>{let n=W(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 lo(){return s({insertLink:oo,updateLink:so,removeLink:co})}function uo(e){return(t,n,r)=>{let i=W(t,t.selection.from);if(i){if(n&&r){let{unit:{from:a,to:o}}=i;n(t.tr.setSelection(C.create(t.doc,a,o)).scrollIntoView()),r.focus(),e({from:a,to:o,link:i})}return!0}let a=ao(t);if(a){if(n&&r){let{from:i,to:o}=a;n(t.tr.setSelection(C.create(t.doc,i,o)).scrollIntoView()),r.focus(),e({from:i,to:o,link:void 0})}return!0}return!1}}function fo(e){return l({"Mod-k":uo(e)})}function po(e){return e===`)`||e===`*`||e===`+`?e:void 0}function mo(e){return e===`X`?e:void 0}function ho(e){return vo(e)?String(e):void 0}function go(){return f({type:`list`,attr:`marker`,default:null,splittable:!0,toDOM:e=>{let t=po(e);return t==null?null:[`data-list-marker`,t]},parseDOM:e=>{let t=e.getAttribute(`data-list-marker`);return t===`)`||t===`*`||t===`+`?t:null}})}function _o(){return f({type:`list`,attr:`taskMarker`,default:null,splittable:!0,toDOM:e=>{let t=mo(e);return t==null?null:[`data-list-task-marker`,t]},parseDOM:e=>e.getAttribute(`data-list-task-marker`)===`X`?`X`:null})}function vo(e){return e===2||e===3||e===4}function yo(){return f({type:`list`,attr:`markerGap`,default:1,splittable:!0,toDOM:e=>{let t=ho(e);return t==null?null:[`data-list-marker-gap`,t]},parseDOM:e=>{let t=Number.parseInt(e.getAttribute(`data-list-marker-gap`)??``,10);return vo(t)?t:1}})}function bo(e){let t=e.attrs;return{...Dt(e),"data-list-marker":po(t.marker),"data-list-task-marker":mo(t.taskMarker),"data-list-marker-gap":ho(t.markerGap)}}function xo(){return o({serializeFragmentWrapper:e=>(...t)=>So(At(e(...t))),serializeNodeWrapper:e=>(...t)=>{let n=e(...t);return xe(n)?So(At(n)):n},nodesFromSchemaWrapper:e=>(...t)=>({...e(...t),list:e=>jt({node:e,nativeList:!0,getAttributes:bo})})})}function So(e){xe(e)&&Co(e);for(let t of e.children)So(t);return e}function Co(e){if(!e.classList.contains(`prosemirror-flat-list`)||e.getAttribute(`data-list-kind`)!==`task`||e.children.length!==2)return;let t=e.children.item(0);if(!t||!t.classList.contains(`list-marker`))return;let n=Ot(t);if(!n)return;let r=e.children.item(1);if(!r||!r.classList.contains(`list-content`))return;let i=r.children.item(0);!i||![`P`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`].includes(i.tagName)||(e.replaceChildren(...r.children),i.prepend(n))}const wo=[Nt(/^\s?([*-])\s$/,{kind:`bullet`,collapsed:!1}),Nt(/^\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}}),Nt(/^\s?\[([\sX]?)\]\s$/i,({match:e})=>({kind:`task`,checked:[`x`,`X`].includes(e[1]),collapsed:!1})),Nt(/^\s?\+\s$/,{kind:`task`,marker:`+`,checked:!1,collapsed:!1})];function To(){return _(wo.map(rt))}function Eo(){return D({kind:`task`,marker:`+`})}function Do(){return D({kind:`task`,marker:null})}function Oo(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e);if(F(n,`list`))return n.attrs}return null}function ko(){return(e,t,n)=>{let r=Oo(e);return(r?.kind===`task`?r.marker===`+`?Do():Eo():D({kind:`task`,marker:null,checked:!1}))(e,t,n)}}function Ao(){return s({cycleCheckableList:ko,wrapInCircleTask:Eo,wrapInSquareTask:Do})}function jo(){return(e,t,n)=>{let r=Oo(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},D(a)(e,t,n)}}function Mo(){return(e,t,n)=>{let r=Oo(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},D(a)(e,t,n)}}function No(e){return F(e,`list`)&&e.attrs.kind===`bullet`&&e.childCount>=2&&e.firstChild?.type!==e.type}const Po=e=>{let t=e.attrs;return t.kind===`task`?{...t,checked:!t.checked}:No(e)?{...t,collapsed:!t.collapsed}:t};function Fo(){return m(()=>[new x({props:{handleDOMEvents:{mousedown:(e,t)=>kt({view:e,event:t,onListClick:Po})}}}),wt(),new x({props:{transformCopied:Mt}}),Tt()])}function Io(){return s({toggleListCollapsed:()=>Et({isToggleable:No})})}function Lo(){return l({"Mod-Enter":jo(),"Mod-Shift-Enter":Mo(),"Mod-.":Et({isToggleable:No}),"Mod-Shift-7":dt({kind:`ordered`,collapsed:!1}),"Mod-Shift-8":dt({kind:`bullet`,collapsed:!1}),"Mod-Shift-9":dt({kind:`task`,checked:!1,collapsed:!1})})}function Ro(){return _(lt(),Fo(),ct(),ot(),xo(),st(),To(),Lo(),go(),_o(),yo(),Ao(),Io())}let zo;function Bo(){return zo??=import(`./katex-chunk-Ch7kgbXr.js`).then(e=>e.render),zo}function Vo(e,t,n,r){try{e(n,t,{displayMode:r,throwOnError:!1,output:`mathml`})}catch(e){t.textContent=String(e)}}var Ho=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=C.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;Bo().then(t=>{e===this.#r&&Vo(t,this.#n,e,!1)})}};function Uo(){return d({name:`mdMath`,constructor:(e,t)=>new Ho(e,t)})}function Wo(e){return e===`left`||e===`center`||e===`right`?e:null}function Go(){return f({type:`tableCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>Wo(e.getAttribute(`data-align`))})}function Ko(){return f({type:`tableHeaderCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>Wo(e.getAttribute(`data-align`))})}function qo(e){for(let t=0;t<e.childCount;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++)if(F(n.child(e),`tableHeaderCell`))return t}return 0}function Jo(e){return e.child(qo(e))}function Yo(e,t){return t>=e.childCount?null:e.child(t).attrs.align??null}function Xo(e,t,n){if(e.childCount===0)return;let r=Jo(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=Yo(r,e);(t.attrs.align??null)!==i&&n.setNodeMarkup(o,void 0,{...t.attrs,align:i}),o+=t.nodeSize}i+=a.nodeSize}}function Zo(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 Qo(){return new x({key:new S(`table-align-sync`),appendTransaction(e,t,n){if(!e.some(e=>e.docChanged))return;let r=Zo(e);if(!r)return;let i=n.doc,a=Math.max(0,Math.min(r.from,i.content.size)),o=Math.max(a,Math.min(r.to,i.content.size)),s;return i.nodesBetween(a,o,(e,t)=>F(e,`table`)?(s??=n.tr,Xo(e,t,s),!1):!0),s?.docChanged?s:void 0}})}function $o(){return m(Qo())}function es(e){let{selection:t}=e;if(Ht(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 ts(e){return(t,n)=>{let r=es(t);if(!r||r.table.childCount===0)return!1;if(n){let{table:i,tablePos:a,firstColumn:o,lastColumn:s}=r,c=qo(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 ns(e){let t=es(e);if(!(!t||t.table.childCount===0))return Yo(Jo(t.table),t.lastColumn)??void 0}function rs(){return s({setTableColumnAlign:ts})}function is(){return _(Go(),Ko(),$o(),rs())}function as(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 os=`paragraph`;function ss(){return _(p({name:`tableCell`,content:os}),p({name:`tableHeaderCell`,content:os}))}const cs=(e,t)=>{let{selection:n}=e;return!Ht(n)||!n.isColSelection()||!n.isRowSelection()?!1:Vt(e,t)};function ls(){return v(l({Backspace:cs,Delete:cs}),t.high)}function us(){return _(Bt(),zt(),Pt(),Rt(),ss(),is(),Lt({allowTableNodeSelection:!0}),Ft(),It(),ls())}function ds(e){let{selection:t}=e,{$from:n,$to:r}=t;if(ae(t)&&n.depth===0||n.depth>0&&r.depth>0&&n.index(0)===r.index(0))return n.index(0)}function fs(e){return(t,n)=>{if(as(t))return!1;let r=ds(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=ae(a)?je.create(u.doc,a.from+d):C.create(u.doc,a.anchor+d,a.head+d);u.setSelection(f),n(u.scrollIntoView())}return!0}}function ps(e){return(t,n,r)=>ut(e)(t,n,r)||fs(e===`up`?-1:1)(t,n,r)}function ms(){return l({"Alt-ArrowUp":ps(`up`),"Alt-ArrowDown":ps(`down`)})}const G=new S(`meowdownPendingReplacement`);function K(e){return G.getState(e)?.pending??null}function hs(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 gs=new x({key:G,state:{init:()=>({pending:null}),apply:(e,t)=>{let n=e.getMeta(G);if(n)return hs(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=K(e);return!t||t.from>=t.to?null:T.create(e.doc,[w.inline(t.from,t.to,{class:`md-pending-replacement`})])}}});function _s(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(G,{type:`start`,from:r,to:i,mode:a})),!0)}}function vs(e){return(t,n)=>K(t)?(n?.(t.tr.setMeta(G,{type:`append`,text:e})),!0):!1}function ys(){return(e,t)=>K(e)?(t?.(e.tr.setMeta(G,{type:`discard`})),!0):!1}function bs(e={}){return(t,n)=>{let r=K(t);if(!r||!r.text.trim())return!1;if(n){let i=e.mode??r.mode,a=rc(t.schema),o=X(r.text,{nodes:a}),s=t.tr;if(s.setMeta(G,{type:`accept`}),i===`append`){let e=t.doc.resolve(r.to).after(1);s.insert(e,o.content),s.setSelection(C.near(s.doc.resolve(e+o.content.size),-1))}else{let e=t.doc.resolve(r.from),n=t.doc.resolve(r.to),i=o.childCount===1?o.firstChild:null;i!=null&&F(i,`paragraph`)&&e.sameParent(n)&&e.parent.isTextblock?(s.replaceWith(r.from,r.to,i.content),s.setSelection(C.near(s.doc.resolve(r.from+i.content.size),-1))):(s.replaceRange(r.from,r.to,new E(o.content,0,0)),s.setSelection(C.near(s.doc.resolve(s.mapping.map(r.to)),-1)))}n(s.scrollIntoView())}return!0}}function xs(){return s({startPendingReplacement:_s,appendPendingReplacementText:vs,acceptPendingReplacement:bs,discardPendingReplacement:ys})}function Ss(){return l({"Mod-Enter":bs(),Escape:ys()})}function Cs(){return _(m(gs),xs(),Ss())}function ws(e){return m(new x({view:()=>({update:(t,n)=>{let r=G.getState(n),i=G.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 Ts(e){return e.left===e.right&&e.top===e.bottom}function q(e,t,n){if(t<0||t>e.state.doc.content.size)return;let r;try{r=e.coordsAtPos(t,n)}catch{return}return Ts(r)?void 0:r}function Es(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 Ds(e){let t=e.state,n=t.selection.head,r=z(t,n),i=B(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=q(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 Os(e){let t=e.state,n=t.selection.head;for(let r of en){let i=O(t,n,r);if(i==null||i.from!==n&&i.to!==n)continue;let a=As(e,i.from+1);if(a==null)continue;let o=Array.from(a.getClientRects()).filter(e=>e.height>0);if(o.length===0)continue;let s=i.to===n,c=s?o[o.length-1]:o[0];return{left:s?c.right:c.left,top:c.top,height:c.height}}}function ks(e,t,n){let r=e.state;for(let i of en){let a=O(r,t,i);if(a==null)continue;let o=As(e,a.from+1);if(o==null)continue;let s=Array.from(o.getClientRects()).filter(e=>e.height>0);if(s.length!==0)return n===1?s[0]:s[s.length-1]}}function As(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 js(e){return Ds(e)??Os(e)}const Ms=new S(`meowdown-scroll-to-selection`);function Ns(e){let t=e.state.selection;if(!g(t)||q(e,t.head,1)!=null)return!1;let n=js(e);if(n==null)return!1;let r=e.domAtPos(t.head).node;return Ls(e,{left:n.left,right:n.left,top:n.top,bottom:n.top+n.height},r),!0}function J(e,t){return typeof e==`number`?e:e[t]}function Ps(e){let t=e.assignedSlot??e.parentNode;return t?.nodeType===11?t.host:t}function Fs(e){let t=e.defaultView?.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Is(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function Ls(e,t,n){let r=e.someProp(`scrollThreshold`)??0,i=e.someProp(`scrollMargin`)??5,a=e.dom.ownerDocument;for(let e=n;e;){if(e.nodeType!==1){e=Ps(e);continue}let n=e,o=n===a.body,s=o?Fs(a):Is(n),c=0,l=0;if(t.top<s.top+J(r,`top`)?l=-(s.top-t.top+J(i,`top`)):t.bottom>s.bottom-J(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+J(i,`top`)-s.top:t.bottom-s.bottom+J(i,`bottom`)),t.left<s.left+J(r,`left`)?c=-(s.left-t.left+J(i,`left`)):t.right>s.right-J(r,`right`)&&(c=t.right-s.right+J(i,`right`)),c||l)if(o)a.defaultView?.scrollBy(c,l);else{let e=n.scrollLeft,r=n.scrollTop;l&&(n.scrollTop+=l),c&&(n.scrollLeft+=c);let i=n.scrollLeft-e,a=n.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=o?`fixed`:getComputedStyle(n).position;if(/^(?:fixed|sticky)$/.test(u))break;e=u===`absolute`?n.offsetParent:Ps(n)}}function Rs(){return m(new x({key:Ms,props:{handleScrollToSelection:Ns}}))}function Y(e,t){return(n,r)=>{let i=e<0?Me.atStart(n.doc):Me.atEnd(n.doc),a=t?C.between(n.selection.$anchor,i.$head):i;return n.selection.eq(a)||r?.(n.tr.setSelection(a).scrollIntoView()),!0}}function zs(){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 Bs(e){e.offsetWidth}const Vs=new S(`meowdown-virtual-caret`),Hs=[`md-virtual-caret-blink`,`md-virtual-caret-blink2`],Us=`data-meowdown-virtual-caret`;function Ws(e){let t=e.height*.19999999999999996;return{left:e.left,top:e.top-t/2,height:e.height+t}}function Gs(e){let t=Es(e)??Ds(e);return t==null?Os(e):Ws(t)}function Ks(e,t){return e==null||t==null?e===t:e.left===t.left&&e.top===t.top&&e.height===t.height}var qs=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=Hs[this.#s]}#l=()=>{let e=this.#e;if(e.isDestroyed)return;let t=e.state,n=t.selection,r=g(n)&&n.empty?Gs(e):void 0,i=r!=null&&A(t)===`hide`?Ci(t,n.head):void 0;if(Ks(r,this.#a)&&i===this.#o)return;let a=this.#a==null;if(this.#a=r,this.#o=i,i==null?delete this.#n.dataset.tail:this.#n.dataset.tail=i,r==null){this.#n.style.visibility=`hidden`,e.dom.removeAttribute(Us);return}let o=this.#t.getBoundingClientRect();a&&(this.#n.style.transitionProperty=`none`),this.#n.style.visibility=``,this.#n.style.left=`${r.left-o.left}px`,this.#n.style.top=`${r.top-o.top}px`,this.#n.style.height=`${r.height}px`,e.dom.setAttribute(Us,``),a&&(Bs(this.#n),this.#n.style.transitionProperty=``)}};function Js(){return m(new x({key:Vs,view:e=>new qs(e)}))}function Ys(e){return _(Xn(),Ee(),fi(),ke(),Te(),Ro(),Kn(),us(),ni(),Fi(),Ii(),Ra(),qr(),di(),ms(),zs(),Sa(e),to(),lo(),ta(),Uo(),Xt(e.markMode??`focus`),Vr(),Js(),Rs(),Ni(),pn({marks:en.map(e=>({name:e,modes:[`hide`,`focus`,`show`]}))}),a(),i(),c(),De(),Ae(),Oe(),li(),Cs())}function Xs(e={}){return Ys(e)}const Zs=we(()=>{let e=Xs().schema;if(e==null)throw Error(`Unexpected empty schema`);return e}),Qs=we(()=>r(Zs())),$s=we(()=>n(Zs())),ec=`meowdown_mark_builders`;function tc(e){let t=e.cached[ec];if(t)return t;let r=n(e);return e.cached[ec]=r,r}const nc=`meowdown_node_builders`;function rc(e){let t=e.cached[nc];if(t)return t;let n=r(e);return e.cached[nc]=n,n}function X(e,t={}){let{nodes:n=Qs(),frontmatter:r=!1}=t,i,a=e;if(r){let[t,n]=ac(e);i=t,n&&(a=e.slice(n))}let o=oc(n,ye.parse(a).cursor(),a);return n.doc(i===void 0?{}:{frontmatter:i},o)}const ic=/^---[ \t]*\r?\n([\s\S]*?\n)?---[ \t]*(?:\r?\n|$)/;function ac(e){let t=ic.exec(e);return t?[(t[1]??``).replace(/\r?\n$/,``),t[0].length]:[]}function oc(e,t,n){let r=[];if(!t.firstChild())return r;let i;do i!=null&&sc(r,e,n,i,t.from),i=t.to,r.push(...cc(e,t,n));while(t.nextSibling());return t.parent(),r}function sc(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 cc(e,t,n){switch(t.type.id){case y.ATXHeading1:return[Z(e,t,n,1,!1)];case y.ATXHeading2:return[Z(e,t,n,2,!1)];case y.ATXHeading3:return[Z(e,t,n,3,!1)];case y.ATXHeading4:return[Z(e,t,n,4,!1)];case y.ATXHeading5:return[Z(e,t,n,5,!1)];case y.ATXHeading6:return[Z(e,t,n,6,!1)];case y.SetextHeading1:return[Z(e,t,n,1,!0)];case y.SetextHeading2:return[Z(e,t,n,2,!0)];case y.Paragraph:return[mc(e,t,n)];case y.CommentBlock:return[hc(e,t,n)];case y.HTMLBlock:case y.ProcessingInstructionBlock:return[mc(e,t,n)];case y.Blockquote:return[gc(e,t,n)];case y.BulletList:return _c(e,t,n,`bullet`);case y.OrderedList:return _c(e,t,n,`ordered`);case y.FencedCode:case y.CodeBlock:return[yc(e,t,n)];case y.BlockMath:return[bc(e,t,n)];case y.HorizontalRule:{let r=n.slice(t.from,t.to).trimEnd();return[e.horizontalRule({marker:r===`---`?null:r})]}case y.Table:return[xc(e,t,n)];case y.Task:return[mc(e,t,n)];default:return n.slice(t.from,t.to).trim()===``?[]:(console.warn(`[meowdown] unsupported lezer block "${t.type.name}"`),[mc(e,t,n)])}}function Z(e,t,n,r,i){let a=t.from,o=t.from,s=t.to,c=-1,l=-1;if(t.firstChild()){t.type.id===y.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===y.HeaderMark&&n>o&&(s=n,c=n,l=r),t.parent()}let u=fc(n.slice(o,s),Q(n,o)).trim(),d=i?lc(n,c,l)||1:null,f=!i&&c>=0&&uc(n,c,l)||null;return e.heading({level:r,setextUnderline:d,closingHashes:f},u)}function lc(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 uc(e,t,n){if(t<0)return 0;let r=0;for(let i=t;i<n;i++)e.charCodeAt(i)===35&&r++;return r}function Q(e,t){let n=e.lastIndexOf(`
28
+ `,t-1)+1,r=0;for(let i=n;i<t;i++)r+=e.charCodeAt(i)===9?4-r%4:1;return r}function dc(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 fc(e,t){return t===0||!e.includes(`
27
29
  `)?e:e.split(`
28
- `).map((e,n)=>n===0?e:Zs(e,t)).join(`
29
- `)}function $s(e,t,n){return e.paragraph(Qs(t,n))}function ec(e,t,n){let r=t.from,i=t.to,a=Z(n,r);if(t.firstChild()){let o=``,s=r;do t.type.id===y.QuoteMark&&(o+=n.slice(s,t.from),s=t.to,b(n.charCodeAt(s))&&(s+=1));while(t.nextSibling());return t.parent(),o+=n.slice(s,i),$s(e,o,a)}return $s(e,n.slice(r,i),a)}function tc(e,t,n){let r=Z(n,t.from),i=Qs(n.slice(t.from,t.to),r);return e.htmlComment({content:i})}function nc(e,t,n){let r=[];if(t.firstChild()){let i;do{if(t.type.id===y.QuoteMark)continue;i!=null&&qs(r,e,n,i,t.from),i=t.to,r.push(...Js(e,t,n))}while(t.nextSibling());t.parent()}return e.blockquote(r)}function rc(e,t,n,r){let i=[];if(t.firstChild()){do t.type.id===y.ListItem&&i.push(ic(e,t,n,r));while(t.nextSibling());t.parent()}return i}function ic(e,t,n,r){let i=[],a,o,s,c,l,u;if(t.firstChild()){do{if(t.type.id!==y.ListMark&&u==null&&(u=Z(n,t.from)),t.type.id===y.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=Z(n,t.to);continue}if(r===`bullet`&&t.type.id===y.Task){let r=t.from,s=t.to;if(a=!1,t.firstChild()){if(t.type.id===y.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()}b(n.charCodeAt(r))&&(r+=1);let c=n.slice(r,s);i.push($s(e,c,Z(n,r)));continue}i.push(...Js(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 ac(e,t,n){let r=t.type.id===y.CodeBlock,i=``,a=``,o=r?`indented`:null,s=null,c=!1;if(t.firstChild()){do switch(t.type.id){case y.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 y.CodeInfo:i=n.slice(t.from,t.to);break;case y.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 oc(e,t,n){let r=``;if(t.firstChild()){do t.type.id===y.CodeText&&(r+=n.slice(t.from,t.to));while(t.nextSibling());t.parent()}return e.codeBlock({language:`math`,fenceStyle:`dollar`,fenceLength:null},r)}function sc(e,t,n){let r=[];if(t.firstChild()){do t.type.id===y.TableDelimiter&&(r=cc(n.slice(t.from,t.to)));while(t.nextSibling());t.parent()}let i=[];if(t.firstChild()){do{let a=t.type.id;a===y.TableHeader?i.push(lc(e,t,n,!0,r)):a===y.TableRow&&i.push(lc(e,t,n,!1,r))}while(t.nextSibling());t.parent()}return e.table(i)}function cc(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 lc(e,t,n,r,i){let a=i.length,o=Array(a).fill(``);if(t.firstChild()){let e=t.type.id===y.TableDelimiter,r=0;do if(t.type.id===y.TableDelimiter)r++;else if(t.type.id===y.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 uc(e){return e.replace(/\n+$/u,``)}function dc(e){return/^[\s>]*$/u.test(e)}function fc(e){return e.split(`
30
- `).filter(e=>!dc(e))}function pc(e){return e.trim().replaceAll(/\s+/gu,` `)}const mc=/^:?-+:?$/u;function hc(e){let t=e.startsWith(`:`),n=e.endsWith(`:`);return t&&n?`:-:`:t?`:--`:n?`--:`:`---`}function gc(e){if(!e.includes(`|`))return;let t=/^[\s>]*/u.exec(e)?.[0]??``,n=e.slice(t.length).trim().replace(/^\|/u,``).replace(/\|$/u,``).split(`|`).map(e=>pc(e));return pc(`${t} | ${(n.every(e=>mc.test(e))?n.map(hc):n).join(` | `)} |`)}function _c(e){return gc(e)??pc(e)}function vc(e,t={}){let n=rr(Y(e,{frontmatter:t.frontmatter}),{frontmatter:t.frontmatter});if(uc(n)===uc(e))return`exact`;let r=fc(e),i=fc(n);return r.length===i.length&&r.every((e,t)=>_c(e)===_c(i[t]))?`normalizing`:`lossy`}const yc=(e,t)=>{let{$from:n,empty:r}=e.selection;if(!r||n.depth!==1||n.index(0)!==0||!F(n.parent,`heading`)||n.parentOffset!==n.parent.content.size)return!1;if(t){let r=te(e.schema,`list`),i=te(e.schema,`paragraph`),a=r.create({kind:`bullet`},i.create()),o=n.after(),s=e.tr.insert(o,a);s.setSelection(C.create(s.doc,o+2)),t(s.scrollIntoView())}return!0};function bc(){return v(l({Enter:yc}),t.high)}const xc=new Set([`MscGen`,`Xù`,`MsGenny`,`Angular Template`,`Brainfuck`,`Esper`,`Oz`,`Factor`,`Squirrel`,`Yacas`,`mIRC`,`FCL`,`ECL`,`MUMPS`,`Pig`,`Asterisk`,`Z80`,`Mathematica`]),Sc=Je.map(e=>({label:e.name,value:e.name.toLowerCase()})).filter(e=>!xc.has(e.label)).concat([{label:`Plain text`,value:``},{label:`Math`,value:`math`},{label:`Mermaid`,value:`mermaid`}]).sort((e,t)=>e.label.localeCompare(t.label));function Cc(){return typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches}const wc=/^(?:www\.|mobile\.)?(?:twitter\.com|x\.com)$/i,Tc=/\/status(?:es)?\/(\d+)/;function Ec(e){let t;try{t=new URL(e)}catch{return}if(wc.test(t.hostname))return Tc.exec(t.pathname)?.[1]}const Dc=e=>{let t=Ec(e);if(!t)return;let n=Cc()?`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 Oc(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 kc=/^(?:www\.|m\.)?(?:youtube\.com|youtube-nocookie\.com)$/i,Ac=/^(?:www\.)?youtu\.be$/i,jc=/^[\w-]{11}$/;function Mc(e){let t;try{t=new URL(e)}catch{return}let n=null;if(Ac.test(t.hostname))n=t.pathname.slice(1);else if(kc.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||!jc.test(n))return;let r=t.searchParams.get(`start`)??t.searchParams.get(`t`),i=r?Nc(r):void 0;return{videoId:n,startSeconds:i}}function Nc(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 Pc=[e=>{let t=Mc(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}},Dc];function Fc(e){for(let t of Pc){let n=t(e);if(n)return n}}function Ic(e,t){return e.clipboardData?.getData(`text/plain`)||t.content.textBetween(0,t.content.size,`
31
- `)}const Lc=new S(`meowdown-embed-paste`);function Rc(e){let t=e.trim();if(!(!t||/\s/.test(t)))return Fc(t)?t:void 0}function zc(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(`![](${t})`,n,n+t.length);e.dispatch(Bt(i))}function Bc(){return m(new x({key:Lc,props:{handlePaste:(e,t,n)=>{let r=e.state.selection.$from.parent;if(!r.inlineContent||r.type.spec.code)return!1;let i=Ic(t,n);if(!i)return!1;let a=Rc(i);return a?(zc(e,a),!0):!1}}}))}const Vc=new S(`meowdown-exit-boundary`);function Hc(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&&Me.findFrom(a,t))}function Uc(e,t){let{state:n}=e,{selection:r}=n;return g(r)&&!r.empty||ne(r)||r.$from.parent.inlineContent&&!e.endOfTextblock(t<0?`up`:`down`)?!0:Hc(n,t)}function Wc(e){return new x({key:Vc,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||Uc(t,r)||e({direction:r<0?`up`:`down`,event:n})===!1)}}})}function Gc(e){return v(m(Wc(e)),t.low)}const Kc=new Set([`avif`,`bmp`,`gif`,`jpeg`,`jpg`,`png`,`svg`,`webp`]);function qc(e){if(e.type?.startsWith(`image/`))return!0;let t=e.name.lastIndexOf(`.`);if(t===-1)return!1;let n=e.name.slice(t+1).toLowerCase();return Kc.has(n)}function Jc(e,t){return qc(e)?`![](${t})`:`[${Zc(e.name)}](${t})`}function Yc(e,t){return!e||!t.onFilePaste?[]:Array.from(e.files)}const Xc=e=>{console.error(`[meowdown] failed to save pasted file:`,e)};function Zc(e){return e.replaceAll(/[\\[\]]/g,String.raw`\$&`)}async function Qc(e,t,n,r){let{onFilePaste:i}=n;if(!i)return;let a=n.onFileSaveError??Xc,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=Jc(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 $c(e){return new x({key:new S(`file-paste`),props:{handlePaste:(t,n)=>{let r=Yc(n.clipboardData,e);return r.length===0?!1:(Qc(t,r,e),!0)},handleDrop:(t,n)=>{let r=Yc(n.dataTransfer,e);return r.length===0?!1:(Qc(t,r,e,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos),!0)}}})}function el(e={}){return v(m($c(e)),t.high)}const tl=new S(`meowdown-file-click`);function nl(e,t){let n=O(e,t,`mdFile`);if(!n)return;let{href:r,name:i}=n.mark.attrs;return{href:r,name:i}}function rl(e){return m(new x({key:tl,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=nl(t.state,t.posAtDOM(a,0));return o?(e({href:o.href,name:o.name,event:r}),!0):!1}}}))}const il=[`KB`,`MB`,`GB`,`TB`];function al(e){let t=e,n=`B`;for(let e of il){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 ol=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 sl(e){let t=e.split(/[?#]/,1)[0],n=t.lastIndexOf(`.`);if(n<0)return`generic`;let r=t.slice(n+1).toLowerCase();return ol.get(r)??`generic`}const cl=`http://www.w3.org/2000/svg`;function ll(){let e=document.createElementNS(cl,`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(cl,`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 ul=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=sl(this.#a.href),this.#n.title=this.#a.name,this.#e.appendChild(this.#n),this.#n.appendChild(ll()),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=al(n))}};function dl(e={}){return d({name:`mdFile`,constructor:t=>new ul(t,e)})}function fl(e){return m(new x({key:e.key,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(e.selector);if(!i)return!1;let a=e.findPayloadForElement?e.findPayloadForElement(t,i):e.findPayloadAt(t.state,n);return a==null?!1:(e.preventDefault&&r.preventDefault(),e.onClick(a,r),!0)}}}))}const pl=new S(`meowdown-tag-click`);function ml(e,t){let n=O(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 hl(e){return fl({key:pl,selector:`.md-tag`,preventDefault:!1,findPayloadAt:(e,t)=>ml(e,t)?.tag,onClick:(t,n)=>e({tag:t,event:n})})}const gl=new S(`meowdown-wikilink-click`);function _l(e,t){let n=O(e,t,`mdWikilink`);if(!n)return;let{target:r}=n.mark.attrs;return{from:n.from,to:n.to,target:r}}function vl(e,t){let n=t.closest(`.md-wikilink-view`)?.querySelector(`.md-wikilink-view-content`);if(n)return _l(e.state,e.posAtDOM(n,0))}function yl(e){return fl({key:gl,selector:`.md-wikilink-view-preview`,preventDefault:!1,findPayloadAt:(e,t)=>_l(e,t)?.target,findPayloadForElement:(e,t)=>vl(e,t)?.target,onClick:(t,n)=>e({target:t,event:n})})}const bl=new S(`meowdown-follow-link`);function xl(e){return e.key!==`Enter`||e.shiftKey||e.altKey?!1:re?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Sl(e){return new x({key:bl,props:{handleKeyDown:(t,n)=>{if(!xl(n))return!1;let{state:r}=t,i=r.selection.head,a=e.onWikilinkClick&&_l(r,i);if(a)return e.onWikilinkClick?.({target:a.target,event:n}),!0;let o=e.onTagClick&&ml(r,i);if(o)return e.onTagClick?.({tag:o.tag,event:n}),!0;let s=e.onFileClick&&nl(r,i);if(s)return e.onFileClick?.({href:s.href,name:s.name,event:n}),!0;let c=e.onLinkClick&&W(r,i);return c?(e.onLinkClick?.({href:c.href,event:n}),!0):!1}}})}function Cl(e){return v(m(Sl(e)),t.high)}const wl=new S(`meowdown-image-click`);function Q(e){return e instanceof HTMLElement&&e.closest(`.md-image-view-preview`)}function Tl(e,t){let n=O(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 El(e,t){let n=t.closest(`.md-image-view`)?.querySelector(`.md-image-view-content`);if(n)return Tl(e.state,e.posAtDOM(n,0))}function Dl(e,t){return Array.from(e).find(e=>e.identifier===t)}function Ol(e,t){return Math.abs(t.clientX-e.clientX)<=10&&Math.abs(t.clientY-e.clientY)<=10}function kl(e){let t=new WeakMap;return m(new x({key:wl,props:{handleDOMEvents:{pointerdown:(e,t)=>(Q(t.target)&&t.pointerType!==`mouse`&&t.preventDefault(),!1),touchstart:(e,n)=>{if(t.delete(e),n.touches.length!==1||!Q(n.target)||n.target instanceof HTMLElement&&n.target.closest(`.md-image-resize-handle`))return!1;let r=n.changedTouches[0];return r&&t.set(e,{identifier:r.identifier,clientX:r.clientX,clientY:r.clientY}),!1},touchmove:(e,n)=>{let r=t.get(e);if(!r)return!1;let i=Dl(n.changedTouches,r.identifier);return i&&!Ol(r,i)&&t.delete(e),!1},touchcancel:e=>(t.delete(e),!1),touchend:(n,r)=>{let i=t.get(n);if(t.delete(n),!i||r.touches.length>0)return!1;let a=Dl(r.changedTouches,i.identifier);if(!a||!Ol(i,a))return!1;let o=Q(r.target);if(!o)return!1;r.preventDefault();let s=El(n,o);return s&&e({src:s.src,alt:s.alt,event:r}),!0}},handleClick:(t,n,r)=>{let i=Q(r.target);if(!i)return!1;let a=El(t,i);return a?(e({src:a.src,alt:a.alt,event:r}),!0):!1}}}))}function Al(e){return/^https?:\/\//i.test(e)?e:void 0}function jl(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`&&Oc(t),t}function Ml(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 Nl(e,t,n,r){let i=e.posAtDOM(t,0),a=O(e.state,i,`mdImage`);if(!a)return;let o=e.state.doc.textBetween(a.from,a.to),s=a.mark.attrs;if(s.syntax===`wikiEmbed`){let t=s.wikiTarget||Ii(o).target;if(!t)return;let i=Li(t,n,r);i!==o&&e.dispatch(e.state.tr.insertText(i,a.from,a.to));return}let c=Ni(o),l=a.from+c.length,u=o.slice(c.length),d=Mi({...Ai(u)??{},width:Math.round(n),height:Math.round(r)});d!==u&&e.dispatch(e.state.tr.insertText(d,l,a.to))}var Pl=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)&&Ml(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=Fc(e);if(t){let e=document.createElement(`span`);return e.className=`md-image-view-preview md-atom-view-preview`,e.appendChild(jl(t)),e}let n=(this.#n.resolveImageUrl??Al)(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){Ht(),Vt();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,Ml(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)),Ml(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;Nl(this.#r,this.#t,t,n)}),this.#a=t,this.#o=n,t}};function Fl(e={}){return d({name:`mdImage`,constructor:(t,n)=>new Pl(t,n,e)})}const Il={"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`},Ll=new S(`meowdown-link-click`);function Rl(e){return fl({key:Ll,selector:`.md-link`,preventDefault:!0,findPayloadAt:(e,t)=>W(e,t)?.href,onClick:(t,n)=>e({href:t,event:n})})}function zl(e){let t,n=(t,n)=>e.findPayloadForElement?e.findPayloadForElement(t,n):e.findPayloadAt(t.state,t.posAtDOM(n,0)),r=()=>{t&&(t=void 0,e.onHoverChange(void 0))},i=(i,a)=>{let o=a.target;if(!o||!xe(o))return;let s=o.closest(e.selector);if(!s||!i.dom.contains(s)||s===t?.element)return;r();let c=n(i,s);c!=null&&(t={payload:c,element:s},e.onHoverChange(t))},a=e=>{if(!t)return;let n=e.relatedTarget;n instanceof Node&&t.element.contains(n)||r()};return m(new x({key:e.key,props:{handleDOMEvents:{mouseover:(e,t)=>(i(e,t),!1),mouseout:(e,t)=>(a(t),!1)}},view:()=>({update:i=>{if(!t)return;if(!t.element.isConnected||!i.dom.contains(t.element)){r();return}let a=n(i,t.element);if(a==null||!e.isSamePayload(t.payload,a)){r();return}t={...t,payload:a}},destroy:r})}))}const Bl=new S(`meowdown-link-hover`);function Vl(e){return zl({key:Bl,selector:`.md-link`,findPayloadAt:(e,t)=>W(e,t),isSamePayload:(e,t)=>e.href===t.href&&e.title===t.title,onHoverChange:e})}const Hl=new S(`meowdown-link-paste`);function Ul(e){let t=e.trim();if(!(!t||/\s/.test(t)))return ve(t)}function Wl(){return v(m(new x({key:Hl,props:{handlePaste:(e,t,n)=>{let r=Ic(t,n);if(!r)return!1;let i=Ul(r);return i?$r(e,Ka({href:i,wrapText:!1})):!1}}})),t.high)}const Gl=[[/<-/,`←`],[/(?<!-)->/,`→`],[/\(c\)/,`©`],[/\(r\)/,`®`],[/1\/2/,`½`],[/\+\/-/,`±`],[/!=/,`≠`],[/<</,`«`],[/>>/,`»`],[/(?<!<!)(?<!^(?:-[ \t]*)+)--/,`—`]],$=new S(`meowdown-substitution-undo`);function Kl(e,t,n){let r=ee(e.schema,`mdCode`);return e.doc.rangeHasMark(t,n,r)}function ql(e,t,n,r,i){if(Kl(e,t,n))return null;let[,a]=r,o=i==null?a:`${a} `,s=e.tr.replaceWith(t,n,e.schema.text(o));return i!=null&&s.setMeta($,{from:t,to:t+o.length,before:i,after:o}),s}function Jl(){return _(Gl.map(e=>et(new Ut(new RegExp(String.raw`(?:${e[0].source})\s$`),(t,n,r,i)=>ql(t,r,i,e,n[0])))))}function Yl(){return m(new x({key:$,state:{init:()=>null,apply:(e,t)=>{let n=e.getMeta($);if(n!==void 0)return n;if(!t)return null;let r=e.mapping.map(t.from),i=e.mapping.map(t.to);return e.selection.empty&&e.selection.from===i&&e.doc.textBetween(r,i)===t.after?{...t,from:r,to:i}:null}}}))}function Xl(){return v(l({Backspace:(e,t)=>{let n=$.getState(e);return n?(t?.(e.tr.replaceWith(n.from,n.to,e.schema.text(n.before)).setMeta($,null)),!0):!1}}),t.highest)}function Zl(){return _(Yl(),Xl())}function Ql(){return _(Gl.map(e=>Qe({regex:RegExp(`(?:${e[0].source})$`),handler:({state:t,from:n,to:r})=>ql(t,n,r,e)})))}function $l(){return _(Jl(),Zl(),Ql())}const eu=new S(`meowdown-wikilink-hover`);function tu(e){return zl({key:eu,selector:`.md-wikilink-view-preview`,findPayloadAt:_l,findPayloadForElement:vl,isSamePayload:(e,t)=>e.target===t.target,onHoverChange:t=>{e(t?{...t.payload,element:t.element}:void 0)}})}function nu(e,t={}){let n=[];return e.content.forEach(e=>{let r=[];e.descendants(e=>{if(!e.isText||!e.text)return!0;let n=e.marks.map(e=>e.type.name);return n.some(e=>vn.has(e))&&!(t.preserveMathSource&&n.includes(`mdMath`))||r.push(e.text),!1}),n.push(r.join(``))}),n.join(`
32
- `)}function ru({allowEmpty:e}){return(t,n)=>{let{selection:r}=t;if(!g(r)||!e&&r.empty||!r.$head.sameParent(r.$anchor)||r.$head.parent.type.spec.code)return!1;let i=nu(r.content());if(i.startsWith(`[[`))return!1;i.startsWith(`[`)&&(i=i.slice(1));let a=`[[`+i;if(n){let e=t.tr.insertText(a,r.from,r.to);e.setSelection(C.create(e.doc,r.from+a.length)),nt(e),n(e.scrollIntoView())}return!0}}function iu(){return l({"Mod-Shift-k":ru({allowEmpty:!0}),"[":ru({allowEmpty:!1})})}function au(e){switch(e.type.name){case`mdWikilink`:{let t=e.attrs;return t.display||t.target}case`mdImage`:return e.attrs.alt;case`mdFile`:return e.attrs.name;case`mdMath`:return e.attrs.formula;default:return``}}function ou(e){let t=``;for(let n of Sn(e)){if(n.atom!=null){t+=au(n.atom);continue}for(let e of n.children)xn(e.marks)||(t+=e.text??``)}return t}function su(e){let{selection:t,schema:n}=e;if(t.empty)return``;let r=t.content().content;try{return rr(n.topNodeType.create(null,r)).replace(/\n+$/,``)}catch{return e.doc.textBetween(t.from,t.to,`
30
+ `).map((e,n)=>n===0?e:dc(e,t)).join(`
31
+ `)}function pc(e,t,n){return e.paragraph(fc(t,n))}function mc(e,t,n){let r=t.from,i=t.to,a=Q(n,r);if(t.firstChild()){let o=``,s=r;do t.type.id===y.QuoteMark&&(o+=n.slice(s,t.from),s=t.to,b(n.charCodeAt(s))&&(s+=1));while(t.nextSibling());return t.parent(),o+=n.slice(s,i),pc(e,o,a)}return pc(e,n.slice(r,i),a)}function hc(e,t,n){let r=Q(n,t.from),i=fc(n.slice(t.from,t.to),r);return e.htmlComment({content:i})}function gc(e,t,n){let r=[];if(t.firstChild()){let i;do{if(t.type.id===y.QuoteMark)continue;i!=null&&sc(r,e,n,i,t.from),i=t.to,r.push(...cc(e,t,n))}while(t.nextSibling());t.parent()}return e.blockquote(r)}function _c(e,t,n,r){let i=[];if(t.firstChild()){do t.type.id===y.ListItem&&i.push(vc(e,t,n,r));while(t.nextSibling());t.parent()}return i}function vc(e,t,n,r){let i=[],a,o,s,c,l,u;if(t.firstChild()){do{if(t.type.id!==y.ListMark&&u==null&&(u=Q(n,t.from)),t.type.id===y.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=Q(n,t.to);continue}if(r===`bullet`&&t.type.id===y.Task){let r=t.from,s=t.to;if(a=!1,t.firstChild()){if(t.type.id===y.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()}b(n.charCodeAt(r))&&(r+=1);let c=n.slice(r,s);i.push(pc(e,c,Q(n,r)));continue}i.push(...cc(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 yc(e,t,n){let r=t.type.id===y.CodeBlock,i=``,a=``,o=r?`indented`:null,s=null,c=!1;if(t.firstChild()){do switch(t.type.id){case y.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 y.CodeInfo:i=n.slice(t.from,t.to);break;case y.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 bc(e,t,n){let r=``;if(t.firstChild()){do t.type.id===y.CodeText&&(r+=n.slice(t.from,t.to));while(t.nextSibling());t.parent()}return e.codeBlock({language:`math`,fenceStyle:`dollar`,fenceLength:null},r)}function xc(e,t,n){let r=[];if(t.firstChild()){do t.type.id===y.TableDelimiter&&(r=Sc(n.slice(t.from,t.to)));while(t.nextSibling());t.parent()}let i=[];if(t.firstChild()){do{let a=t.type.id;a===y.TableHeader?i.push(Cc(e,t,n,!0,r)):a===y.TableRow&&i.push(Cc(e,t,n,!1,r))}while(t.nextSibling());t.parent()}return e.table(i)}function Sc(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 Cc(e,t,n,r,i){let a=i.length,o=Array(a).fill(``);if(t.firstChild()){let e=t.type.id===y.TableDelimiter,r=0;do if(t.type.id===y.TableDelimiter)r++;else if(t.type.id===y.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 wc(e){return e.replace(/\n+$/u,``)}function Tc(e){return/^[\s>]*$/u.test(e)}function Ec(e){return e.split(`
32
+ `).filter(e=>!Tc(e))}function Dc(e){return e.trim().replaceAll(/\s+/gu,` `)}const Oc=/^:?-+:?$/u;function kc(e){let t=e.startsWith(`:`),n=e.endsWith(`:`);return t&&n?`:-:`:t?`:--`:n?`--:`:`---`}function Ac(e){if(!e.includes(`|`))return;let t=/^[\s>]*/u.exec(e)?.[0]??``,n=e.slice(t.length).trim().replace(/^\|/u,``).replace(/\|$/u,``).split(`|`).map(e=>Dc(e));return Dc(`${t} | ${(n.every(e=>Oc.test(e))?n.map(kc):n).join(` | `)} |`)}function jc(e){return Ac(e)??Dc(e)}function Mc(e,t={}){let n=_r(X(e,{frontmatter:t.frontmatter}),{frontmatter:t.frontmatter});if(wc(n)===wc(e))return`exact`;let r=Ec(e),i=Ec(n);return r.length===i.length&&r.every((e,t)=>jc(e)===jc(i[t]))?`normalizing`:`lossy`}const Nc=(e,t)=>{let{$from:n,empty:r}=e.selection;if(!r||n.depth!==1||n.index(0)!==0||!F(n.parent,`heading`)||n.parentOffset!==n.parent.content.size)return!1;if(t){let r=te(e.schema,`list`),i=te(e.schema,`paragraph`),a=r.create({kind:`bullet`},i.create()),o=n.after(),s=e.tr.insert(o,a);s.setSelection(C.create(s.doc,o+2)),t(s.scrollIntoView())}return!0};function Pc(){return v(l({Enter:Nc}),t.high)}const Fc=new Set([`MscGen`,`Xù`,`MsGenny`,`Angular Template`,`Brainfuck`,`Esper`,`Oz`,`Factor`,`Squirrel`,`Yacas`,`mIRC`,`FCL`,`ECL`,`MUMPS`,`Pig`,`Asterisk`,`Z80`,`Mathematica`]),Ic=Ze.map(e=>({label:e.name,value:e.name.toLowerCase()})).filter(e=>!Fc.has(e.label)).concat([{label:`Plain text`,value:``},{label:`Math`,value:`math`},{label:`Mermaid`,value:`mermaid`}]).sort((e,t)=>e.label.localeCompare(t.label));function Lc(){return typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches}const Rc=/^(?:www\.|mobile\.)?(?:twitter\.com|x\.com)$/i,zc=/\/status(?:es)?\/(\d+)/;function Bc(e){let t;try{t=new URL(e)}catch{return}if(Rc.test(t.hostname))return zc.exec(t.pathname)?.[1]}const Vc=e=>{let t=Bc(e);if(!t)return;let n=Lc()?`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 Hc(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 Uc=/^(?:www\.|m\.)?(?:youtube\.com|youtube-nocookie\.com)$/i,Wc=/^(?:www\.)?youtu\.be$/i,Gc=/^[\w-]{11}$/;function Kc(e){let t;try{t=new URL(e)}catch{return}let n=null;if(Wc.test(t.hostname))n=t.pathname.slice(1);else if(Uc.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||!Gc.test(n))return;let r=t.searchParams.get(`start`)??t.searchParams.get(`t`),i=r?qc(r):void 0;return{videoId:n,startSeconds:i}}function qc(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 Jc=[e=>{let t=Kc(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}},Vc];function Yc(e){for(let t of Jc){let n=t(e);if(n)return n}}function Xc(e,t){return e.clipboardData?.getData(`text/plain`)||t.content.textBetween(0,t.content.size,`
33
+ `)}const Zc=new S(`meowdown-embed-paste`);function Qc(e){let t=e.trim();if(!(!t||/\s/.test(t)))return Yc(t)?t:void 0}function $c(e,t){let{from:n,to:r}=e.state.selection;e.dispatch(Ut(e.state.tr.insertText(t,n,r)));let i=e.state.tr.insertText(`![](${t})`,n,n+t.length);e.dispatch(Ut(i))}function el(){return m(new x({key:Zc,props:{handlePaste:(e,t,n)=>{let r=e.state.selection.$from.parent;if(!r.inlineContent||r.type.spec.code)return!1;let i=Xc(t,n);if(!i)return!1;let a=Qc(i);return a?($c(e,a),!0):!1}}}))}const tl=new S(`meowdown-exit-boundary`);function nl(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&&Me.findFrom(a,t))}function rl(e,t){let{state:n}=e,{selection:r}=n;return g(r)&&!r.empty||ne(r)||r.$from.parent.inlineContent&&!e.endOfTextblock(t<0?`up`:`down`)?!0:nl(n,t)}function il(e){return new x({key:tl,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||rl(t,r)||e({direction:r<0?`up`:`down`,event:n})===!1)}}})}function al(e){return v(m(il(e)),t.low)}const ol=new Set([`avif`,`bmp`,`gif`,`jpeg`,`jpg`,`png`,`svg`,`webp`]);function sl(e){if(e.type?.startsWith(`image/`))return!0;let t=e.name.lastIndexOf(`.`);if(t===-1)return!1;let n=e.name.slice(t+1).toLowerCase();return ol.has(n)}function cl(e,t){return sl(e)?`![](${t})`:`[${dl(e.name)}](${t})`}function ll(e,t){return!e||!t.onFilePaste?[]:Array.from(e.files)}const ul=e=>{console.error(`[meowdown] failed to save pasted file:`,e)};function dl(e){return e.replaceAll(/[\\[\]]/g,String.raw`\$&`)}async function fl(e,t,n,r){let{onFilePaste:i}=n;if(!i)return;let a=n.onFileSaveError??ul,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=cl(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 pl(e){return new x({key:new S(`file-paste`),props:{handlePaste:(t,n)=>{let r=ll(n.clipboardData,e);return r.length===0?!1:(fl(t,r,e),!0)},handleDrop:(t,n)=>{let r=ll(n.dataTransfer,e);return r.length===0?!1:(fl(t,r,e,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos),!0)}}})}function ml(e={}){return v(m(pl(e)),t.high)}const hl=new S(`meowdown-file-click`);function gl(e,t){let n=O(e,t,`mdFile`);if(!n)return;let{href:r,name:i}=n.mark.attrs;return{href:r,name:i}}function _l(e){return m(new x({key:hl,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=gl(t.state,t.posAtDOM(a,0));return o?(e({href:o.href,name:o.name,event:r}),!0):!1}}}))}const vl=[`KB`,`MB`,`GB`,`TB`];function yl(e){let t=e,n=`B`;for(let e of vl){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 bl=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 xl(e){let t=e.split(/[?#]/,1)[0],n=t.lastIndexOf(`.`);if(n<0)return`generic`;let r=t.slice(n+1).toLowerCase();return bl.get(r)??`generic`}const Sl=`http://www.w3.org/2000/svg`;function Cl(){let e=document.createElementNS(Sl,`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(Sl,`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 wl=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=xl(this.#a.href),this.#n.title=this.#a.name,this.#e.appendChild(this.#n),this.#n.appendChild(Cl()),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=yl(n))}};function Tl(e={}){return d({name:`mdFile`,constructor:t=>new wl(t,e)})}function El(e){return m(new x({key:e.key,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(e.selector);if(!i)return!1;let a=e.findPayloadForElement?e.findPayloadForElement(t,i):e.findPayloadAt(t.state,n);return a==null?!1:(e.preventDefault&&r.preventDefault(),e.onClick(a,r),!0)}}}))}const Dl=new S(`meowdown-tag-click`);function Ol(e,t){let n=O(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 kl(e){return El({key:Dl,selector:`.md-tag`,preventDefault:!1,findPayloadAt:(e,t)=>Ol(e,t)?.tag,onClick:(t,n)=>e({tag:t,event:n})})}const Al=new S(`meowdown-wikilink-click`);function jl(e,t){let n=O(e,t,`mdWikilink`);if(!n)return;let{target:r}=n.mark.attrs;return{from:n.from,to:n.to,target:r}}function Ml(e,t){let n=t.closest(`.md-wikilink-view`)?.querySelector(`.md-wikilink-view-content`);if(n)return jl(e.state,e.posAtDOM(n,0))}function Nl(e){return El({key:Al,selector:`.md-wikilink-view-preview`,preventDefault:!1,findPayloadAt:(e,t)=>jl(e,t)?.target,findPayloadForElement:(e,t)=>Ml(e,t)?.target,onClick:(t,n)=>e({target:t,event:n})})}const Pl=new S(`meowdown-follow-link`);function Fl(e){return e.key!==`Enter`||e.shiftKey||e.altKey?!1:re?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Il(e){return new x({key:Pl,props:{handleKeyDown:(t,n)=>{if(!Fl(n))return!1;let{state:r}=t,i=r.selection.head,a=e.onWikilinkClick&&jl(r,i);if(a)return e.onWikilinkClick?.({target:a.target,event:n}),!0;let o=e.onTagClick&&Ol(r,i);if(o)return e.onTagClick?.({tag:o.tag,event:n}),!0;let s=e.onFileClick&&gl(r,i);if(s)return e.onFileClick?.({href:s.href,name:s.name,event:n}),!0;let c=e.onLinkClick&&W(r,i);return c?(e.onLinkClick?.({href:c.href,event:n}),!0):!1}}})}function Ll(e){return v(m(Il(e)),t.high)}const Rl=new S(`meowdown-image-click`);function zl(e){return e instanceof HTMLElement&&e.closest(`.md-image-view-preview`)}function Bl(e,t){let n=O(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 Vl(e,t){let n=t.closest(`.md-image-view`)?.querySelector(`.md-image-view-content`);if(n)return Bl(e.state,e.posAtDOM(n,0))}function Hl(e,t){return Array.from(e).find(e=>e.identifier===t)}function Ul(e,t){return Math.abs(t.clientX-e.clientX)<=10&&Math.abs(t.clientY-e.clientY)<=10}function Wl(e){let t=new WeakMap;return m(new x({key:Rl,props:{handleDOMEvents:{pointerdown:(e,t)=>(zl(t.target)&&t.pointerType!==`mouse`&&t.preventDefault(),!1),touchstart:(e,n)=>{if(t.delete(e),n.touches.length!==1||!zl(n.target)||n.target instanceof HTMLElement&&n.target.closest(`.md-image-resize-handle`))return!1;let r=n.changedTouches[0];return r&&t.set(e,{identifier:r.identifier,clientX:r.clientX,clientY:r.clientY}),!1},touchmove:(e,n)=>{let r=t.get(e);if(!r)return!1;let i=Hl(n.changedTouches,r.identifier);return i&&!Ul(r,i)&&t.delete(e),!1},touchcancel:e=>(t.delete(e),!1),touchend:(n,r)=>{let i=t.get(n);if(t.delete(n),!i||r.touches.length>0)return!1;let a=Hl(r.changedTouches,i.identifier);if(!a||!Ul(i,a))return!1;let o=zl(r.target);if(!o)return!1;r.preventDefault();let s=Vl(n,o);return s&&e({src:s.src,alt:s.alt,event:r}),!0}},handleClick:(t,n,r)=>{let i=zl(r.target);if(!i)return!1;let a=Vl(t,i);return a?(e({src:a.src,alt:a.alt,event:r}),!0):!1}}}))}function Gl(e){return/^https?:\/\//i.test(e)?e:void 0}function Kl(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`&&Hc(t),t}function ql(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 Jl(e,t,n,r){let i=e.posAtDOM(t,0),a=O(e.state,i,`mdImage`);if(!a)return;let o=e.state.doc.textBetween(a.from,a.to),s=a.mark.attrs;if(s.syntax===`wikiEmbed`){let t=s.wikiTarget||Xi(o).target;if(!t)return;let i=Zi(t,n,r);i!==o&&e.dispatch(e.state.tr.insertText(i,a.from,a.to));return}let c=qi(o),l=a.from+c.length,u=o.slice(c.length),d=Ki({...Wi(u)??{},width:Math.round(n),height:Math.round(r)});d!==u&&e.dispatch(e.state.tr.insertText(d,l,a.to))}var Yl=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)&&ql(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=Yc(e);if(t){let e=document.createElement(`span`);return e.className=`md-image-view-preview md-atom-view-preview`,e.appendChild(Kl(t)),e}let n=(this.#n.resolveImageUrl??Gl)(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){Gt(),Wt();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,ql(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)),ql(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;Jl(this.#r,this.#t,t,n)}),this.#a=t,this.#o=n,t}};function Xl(e={}){return d({name:`mdImage`,constructor:(t,n)=>new Yl(t,n,e)})}const Zl={"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`},Ql=new S(`meowdown-link-click`);function $l(e){return El({key:Ql,selector:`.md-link`,preventDefault:!0,findPayloadAt:(e,t)=>W(e,t)?.href,onClick:(t,n)=>e({href:t,event:n})})}function eu(e){let t,n=(t,n)=>e.findPayloadForElement?e.findPayloadForElement(t,n):e.findPayloadAt(t.state,t.posAtDOM(n,0)),r=()=>{t&&(t=void 0,e.onHoverChange(void 0))},i=(i,a)=>{let o=a.target;if(!o||!xe(o))return;let s=o.closest(e.selector);if(!s||!i.dom.contains(s)||s===t?.element)return;r();let c=n(i,s);c!=null&&(t={payload:c,element:s},e.onHoverChange(t))},a=e=>{if(!t)return;let n=e.relatedTarget;n instanceof Node&&t.element.contains(n)||r()};return m(new x({key:e.key,props:{handleDOMEvents:{mouseover:(e,t)=>(i(e,t),!1),mouseout:(e,t)=>(a(t),!1)}},view:()=>({update:i=>{if(!t)return;if(!t.element.isConnected||!i.dom.contains(t.element)){r();return}let a=n(i,t.element);if(a==null||!e.isSamePayload(t.payload,a)){r();return}t={...t,payload:a}},destroy:r})}))}const tu=new S(`meowdown-link-hover`);function nu(e){return eu({key:tu,selector:`.md-link`,findPayloadAt:(e,t)=>W(e,t),isSamePayload:(e,t)=>e.href===t.href&&e.title===t.title,onHoverChange:e})}const ru=new S(`meowdown-link-paste`);function iu(e){let t=e.trim();if(!(!t||/\s/.test(t)))return ve(t)}function au(){return v(m(new x({key:ru,props:{handlePaste:(e,t,n)=>{let r=Xc(t,n);if(!r)return!1;let i=iu(r);return i?pi(e,oo({href:i,wrapText:!1})):!1}}})),t.high)}const ou=[[/<-/,`←`],[/(?<!-)->/,`→`],[/\(c\)/,`©`],[/\(r\)/,`®`],[/1\/2/,`½`],[/\+\/-/,`±`],[/!=/,`≠`],[/<</,`«`],[/>>/,`»`],[/(?<!<!)(?<!^(?:-[ \t]*)+)--/,`—`]],$=new S(`meowdown-substitution-undo`);function su(e,t,n){let r=ee(e.schema,`mdCode`);return e.doc.rangeHasMark(t,n,r)}function cu(e,t,n,r,i){if(su(e,t,n))return null;let[,a]=r,o=i==null?a:`${a} `,s=e.tr.replaceWith(t,n,e.schema.text(o));return i!=null&&s.setMeta($,{from:t,to:t+o.length,before:i,after:o}),s}function lu(){return _(ou.map(e=>rt(new Kt(new RegExp(String.raw`(?:${e[0].source})\s$`),(t,n,r,i)=>cu(t,r,i,e,n[0])))))}function uu(){return m(new x({key:$,state:{init:()=>null,apply:(e,t)=>{let n=e.getMeta($);if(n!==void 0)return n;if(!t)return null;let r=e.mapping.map(t.from),i=e.mapping.map(t.to);return e.selection.empty&&e.selection.from===i&&e.doc.textBetween(r,i)===t.after?{...t,from:r,to:i}:null}}}))}function du(){return v(l({Backspace:(e,t)=>{let n=$.getState(e);return n?(t?.(e.tr.replaceWith(n.from,n.to,e.schema.text(n.before)).setMeta($,null)),!0):!1}}),t.highest)}function fu(){return _(uu(),du())}function pu(){return _(ou.map(e=>tt({regex:RegExp(`(?:${e[0].source})$`),handler:({state:t,from:n,to:r})=>cu(t,n,r,e)})))}function mu(){return _(lu(),fu(),pu())}const hu=new S(`meowdown-wikilink-hover`);function gu(e){return eu({key:hu,selector:`.md-wikilink-view-preview`,findPayloadAt:jl,findPayloadForElement:Ml,isSamePayload:(e,t)=>e.target===t.target,onHoverChange:t=>{e(t?{...t.payload,element:t.element}:void 0)}})}function _u(e,t={}){let n=[];return e.content.forEach(e=>{let r=[];e.descendants(e=>{if(!e.isText||!e.text)return!0;let n=e.marks.map(e=>e.type.name);return n.some(e=>Dn.has(e))&&!(t.preserveMathSource&&n.includes(`mdMath`))||r.push(e.text),!1}),n.push(r.join(``))}),n.join(`
34
+ `)}function vu({allowEmpty:e}){return(t,n)=>{let{selection:r}=t;if(!g(r)||!e&&r.empty||!r.$head.sameParent(r.$anchor)||r.$head.parent.type.spec.code)return!1;let i=_u(r.content());if(i.startsWith(`[[`))return!1;i.startsWith(`[`)&&(i=i.slice(1));let a=`[[`+i;if(n){let e=t.tr.insertText(a,r.from,r.to);e.setSelection(C.create(e.doc,r.from+a.length)),at(e),n(e.scrollIntoView())}return!0}}function yu(){return l({"Mod-Shift-k":vu({allowEmpty:!0}),"[":vu({allowEmpty:!1})})}function bu(e){switch(e.type.name){case`mdWikilink`:{let t=e.attrs;return t.display||t.target}case`mdImage`:return e.attrs.alt;case`mdFile`:return e.attrs.name;case`mdMath`:return e.attrs.formula;default:return``}}function xu(e){let t=``;for(let n of jn(e)){if(n.atom!=null){t+=bu(n.atom);continue}for(let e of n.children)An(e.marks)||(t+=e.text??``)}return t}function Su(e){let{selection:t,schema:n}=e;if(t.empty)return``;let r=t.content().content;try{return _r(n.topNodeType.create(null,r)).replace(/\n+$/,``)}catch{return e.doc.textBetween(t.from,t.to,`
33
35
 
34
- `)}}function cu(e,t,n){if(n===1){let r=B(e.state,t);return r&&q(e,r.to,n)}else{let n=z(e.state,t);return n&&q(e,n.from,-1)}}function lu(e,t){let n=new DOMRect(0,0,0,0),r=()=>{if(e.isDestroyed)return n;let r=q(e,t.from,1)??hs(e,t.from,1)??cu(e,t.from,1)??q(e,t.from,-1);if(r==null)return n;let i=q(e,t.to,-1)??hs(e,t.to,-1)??cu(e,t.to,-1)??q(e,t.to,1);if(i==null)return n;let a=Math.min(r.left,i.left),o=Math.max(r.right,i.right),s=Math.min(r.top,i.top),c=Math.max(r.bottom,i.bottom);return n=new DOMRect(a,s,o-a,c-s),n};return{getBoundingClientRect:r,getClientRects:()=>[r()]}}function uu(e){return e instanceof pt||e instanceof mt||e instanceof ht||e instanceof gt||e instanceof Ei}function du(e){for(let t of e)for(let e of t.steps)if(!uu(e))return!0;return!1}function fu(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){du(e)&&o()},view(e){return t=e,{destroy(){t=void 0}}}}}function pu(e){let t=new S(`spell-check`);return new x({key:t,state:{init:()=>fu(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 mu(e){return m(pu(e))}export{Il as EDITOR_KEY_BINDINGS,e as Priority,Jc as buildFileMarkdown,vc as checkRoundTrip,Sc as codeBlockLanguages,Al as defaultResolveImageUrl,bc as defineBulletAfterHeading,pe as defineCodeBlockPreviewPlugin,Nr as defineCodeBlockSyntaxHighlight,Is as defineEditorExtension,Bc as defineEmbedPaste,Gc as defineExitBoundaryHandler,rl as defineFileClickHandler,el as defineFilePaste,dl as defineFileView,Cl as defineFollowLinkHandler,Si as defineHTMLComment,Fl as defineImage,kl as defineImageClickHandler,Rl as defineLinkClickHandler,Ya as defineLinkCommands,Za as defineLinkEditKeymap,Vl as defineLinkHoverHandler,Wl as defineLinkPaste,ko as defineMath,us as definePendingReplacementHandler,he as definePlaceholder,ge as defineReadonly,mu as defineSpellCheckPlugin,$l as defineSubstitution,hl as defineTagClickHandler,yl as defineWikilinkClickHandler,tu as defineWikilinkHoverHandler,iu as defineWikilinkTrigger,rr as docToMarkdown,al as formatFileSize,Li as formatSizedWikiEmbed,Fr as getCodeTokens,sl as getFileKind,W as getLinkUnitAt,zs as getMarkBuilders,K as getPendingReplacement,su as getSelectedText,Ho as getTableColumnAlign,ou as getTextblockDisplayText,lu as getVirtualElementFromRange,Ui as inlineTextToMarkChunks,Ka as insertLink,me as isCodeBlockPreviewHiddenDecoration,P as isMarkOfType,F as isNodeOfType,Go as isSelectionInTableCell,Oc as listenForTweetHeight,Eo as loadKaTeX,Y as markdownToDoc,Fc as matchEmbed,Ii as parseWikiEmbed,Ja as removeLink,Do as renderMathInto,qa as updateLink,Ri as wikiEmbedBasename,le as withPriority};
36
+ `)}}function Cu(e,t,n){if(n===1){let r=B(e.state,t);return r&&q(e,r.to,n)}else{let n=z(e.state,t);return n&&q(e,n.from,-1)}}function wu(e,t){let n=new DOMRect(0,0,0,0),r=()=>{if(e.isDestroyed)return n;let r=q(e,t.from,1)??ks(e,t.from,1)??Cu(e,t.from,1)??q(e,t.from,-1);if(r==null)return n;let i=q(e,t.to,-1)??ks(e,t.to,-1)??Cu(e,t.to,-1)??q(e,t.to,1);if(i==null)return n;let a=Math.min(r.left,i.left),o=Math.max(r.right,i.right),s=Math.min(r.top,i.top),c=Math.max(r.bottom,i.bottom);return n=new DOMRect(a,s,o-a,c-s),n};return{getBoundingClientRect:r,getClientRects:()=>[r()]}}function Tu(e){return e instanceof gt||e instanceof _t||e instanceof vt||e instanceof yt||e instanceof Bi}function Eu(e){for(let t of e)for(let e of t.steps)if(!Tu(e))return!0;return!1}function Du(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){Eu(e)&&o()},view(e){return t=e,{destroy(){t=void 0}}}}}function Ou(e){let t=new S(`spell-check`);return new x({key:t,state:{init:()=>Du(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 ku(e){return m(Ou(e))}export{Zl as EDITOR_KEY_BINDINGS,e as Priority,cl as buildFileMarkdown,Mc as checkRoundTrip,Ic as codeBlockLanguages,Gl as defaultResolveImageUrl,Pc as defineBulletAfterHeading,pe as defineCodeBlockPreviewPlugin,qr as defineCodeBlockSyntaxHighlight,Xs as defineEditorExtension,el as defineEmbedPaste,al as defineExitBoundaryHandler,_l as defineFileClickHandler,ml as defineFilePaste,Tl as defineFileView,Ll as defineFollowLinkHandler,Ii as defineHTMLComment,Xl as defineImage,Wl as defineImageClickHandler,$l as defineLinkClickHandler,lo as defineLinkCommands,fo as defineLinkEditKeymap,nu as defineLinkHoverHandler,au as defineLinkPaste,Uo as defineMath,ws as definePendingReplacementHandler,he as definePlaceholder,ge as defineReadonly,ku as defineSpellCheckPlugin,mu as defineSubstitution,kl as defineTagClickHandler,Nl as defineWikilinkClickHandler,gu as defineWikilinkHoverHandler,yu as defineWikilinkTrigger,_r as docToMarkdown,yl as formatFileSize,Zi as formatSizedWikiEmbed,Yr as getCodeTokens,xl as getFileKind,W as getLinkUnitAt,$s as getMarkBuilders,K as getPendingReplacement,Su as getSelectedText,ns as getTableColumnAlign,xu as getTextblockDisplayText,wu as getVirtualElementFromRange,ra as inlineTextToMarkChunks,oo as insertLink,me as isCodeBlockPreviewHiddenDecoration,P as isMarkOfType,F as isNodeOfType,as as isSelectionInTableCell,Hc as listenForTweetHeight,Bo as loadKaTeX,X as markdownToDoc,Yc as matchEmbed,Xi as parseWikiEmbed,co as removeLink,Vo as renderMathInto,so as updateLink,Qi as wikiEmbedBasename,le as withPriority};
package/dist/style.css CHANGED
@@ -160,6 +160,8 @@
160
160
  --meowdown-mark: var(--meowdown-muted);
161
161
  --meowdown-highlight: light-dark(oklch(94.5% .124 102), oklch(47.6% .103 62));
162
162
  --meowdown-border: light-dark(oklch(92% .004 286), oklch(37% .012 286));
163
+ --meowdown-hr: var(--meowdown-border);
164
+ --meowdown-table-border: var(--meowdown-border);
163
165
  --meowdown-blockquote-border: color-mix(in oklab, var(--meowdown-accent) 35%, transparent);
164
166
  --meowdown-code-bg: light-dark(oklch(96.7% 0 0), oklch(21% .006 286));
165
167
  --meowdown-mermaid-bg: var(--meowdown-code-bg);
@@ -205,11 +207,14 @@
205
207
  .ProseMirror {
206
208
  box-sizing: border-box;
207
209
  color: var(--meowdown-text);
208
- caret-color: #0000;
209
210
  -webkit-font-smoothing: antialiased;
210
211
  outline: none;
211
212
  font-size: 1.0625rem;
212
213
  line-height: 1.7;
214
+
215
+ &[data-meowdown-virtual-caret] {
216
+ caret-color: #0000;
217
+ }
213
218
  }
214
219
 
215
220
  .md-virtual-caret-layer {
@@ -541,7 +546,7 @@
541
546
 
542
547
  .ProseMirror hr {
543
548
  border: none;
544
- border-top: 1px solid var(--meowdown-border);
549
+ border-top: 1px solid var(--meowdown-hr);
545
550
  margin: 1.5em 0;
546
551
  }
547
552
 
@@ -554,7 +559,7 @@
554
559
 
555
560
  .ProseMirror td, .ProseMirror th {
556
561
  box-sizing: border-box;
557
- border: 1px solid var(--meowdown-border);
562
+ border: 1px solid var(--meowdown-table-border);
558
563
  vertical-align: top;
559
564
  text-align: left;
560
565
  padding: .4rem .75rem;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meowdown/core",
3
3
  "type": "module",
4
- "version": "0.56.0",
4
+ "version": "0.57.1",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -27,30 +27,31 @@
27
27
  "@lezer/highlight": "^1.2.3",
28
28
  "@ocavue/utils": "^1.7.0",
29
29
  "@prosekit/core": "^0.13.0-beta.6",
30
- "@prosekit/extensions": "^0.18.0-beta.16",
30
+ "@prosekit/extensions": "^0.18.0-beta.17",
31
31
  "@prosekit/pm": "^0.1.19-beta.3",
32
- "@prosekit/web": "^0.9.0-beta.21",
33
- "katex": "^0.17.0",
32
+ "@prosekit/web": "^0.9.0-beta.22",
33
+ "hast-util-to-mdast": "^10.1.2",
34
+ "katex": "^0.18.1",
35
+ "mdast-util-to-markdown": "^2.1.2",
34
36
  "prosemirror-flat-list": "^0.7.1",
35
37
  "prosemirror-highlight": "^0.15.3",
36
38
  "rehype-parse": "^9.0.1",
37
39
  "rehype-remark": "^10.0.1",
38
40
  "remark-gfm": "^4.0.1",
39
41
  "remark-stringify": "^11.0.0",
42
+ "unicode-by-name": "^0.2.0",
40
43
  "unified": "^11.0.5",
41
- "@meowdown/markdown": "^0.56.0"
44
+ "@meowdown/markdown": "^0.57.1"
42
45
  },
43
46
  "devDependencies": {
44
47
  "@ocavue/tsconfig": "^0.7.1",
45
48
  "@tsdown/css": "^0.22.8",
49
+ "@types/hast": "^3.0.5",
46
50
  "@types/mdast": "^4.0.4",
47
51
  "@vitest/browser-playwright": "^4.1.10",
48
52
  "dedent": "^1.7.2",
49
53
  "diffable-html-snapshot": "^0.3.0",
50
- "hast-util-to-mdast": "^10.1.2",
51
- "mdast-util-to-markdown": "^2.1.2",
52
54
  "tsdown": "^0.22.8",
53
- "unicode-by-name": "^0.2.0",
54
55
  "vitest": "^4.1.10",
55
56
  "@meowdown/vitest": "0.0.0"
56
57
  },