import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{A as t,D as n,E as r,F as i,G as a,K as o,M as s,R as c,S as l,Y as u,a as d,b as f,ct as p,dt as m,ft as h,h as ee,i as te,it as ne,j as re,lt as g,m as ie,mt as ae,nt as _,o as oe,pt as se,r as ce,st as v,u as le,v as ue,x as de,z as fe}from"./dist-CknG_5Uc.js";import{n as pe,o as me,r as he}from"./dist-Bs-JlthF.js";import{i as ge,t as _e}from"./dist-DPMMdvUZ.js";function ve(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==N.OrderedList?C:S)(n,t,!1);return r>0&&(e.type!=N.BulletList||x(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}function y(e){return e==32||e==9||e==10||e==13}function b(e,t=0){for(;tn&&y(e.charCodeAt(t-1));)t--;return t}function be(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(B.SetextHeading)>-1||r<3?-1:1}function Se(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function S(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||y(e.text.charCodeAt(e.pos+1)))&&(!n||Se(t,N.BulletList)||e.skipSpace(e.pos+2)=48&&i<=57;){if(r++,r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||re.pos+1||e.next!=49)?-1:r+1-e.pos}function Ce(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t6?-1:n}function we(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t=n+5||r==e.text.length?n+1:i}function w(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==N.CodeText?e[r].to=n:e.push(k(N.CodeText,t,n))}function T(e,t){for(;t=a:n>a;){let i=e[t+1].from-a;r+=i,n+=i,t++,a=e[t].to}}for(let u=n.firstChild;u;u=u.nextSibling){l(u.from+r,!0);let n=u.from+r,d,f=i.get(u.tree);f?d=f:u.to+r>a?(d=De(e,t,u,r,i),l(u.to+r,!1)):d=u.toTree(),o.push(d),s.push(n-c)}return l(n.to+r,!1),new h(n.type,o,s,n.to+r-c,n.tree?n.tree.propValues:void 0)}function E(e){return e!=null&&e.length>0}function D(e){if(!Array.isArray(e))return e;if(e.length==0)return null;let t=D(e[0]);if(e.length==1)return t;let n=D(e.slice(1));if(!n||!t)return t||n;let r=(e,t)=>(e||H).concat(t||H),i=t.wrap,a=n.wrap;return{props:r(t.props,n.props),defineNodes:r(t.defineNodes,n.defineNodes),parseBlock:r(t.parseBlock,n.parseBlock),parseInline:r(t.parseInline,n.parseInline),remove:r(t.remove,n.remove),wrap:i?a?(e,t,n,r)=>i(a(e,t,n,r),t,n,r):i:a}}function O(e,t){let n=e.indexOf(t);if(n<0)throw RangeError(`Position specified relative to unknown parser ${t}`);return n}function k(e,t,n,r){return new U(e,t,n,r)}function Oe(e,t,n,r,i){let{text:a}=e,o=e.char(i),s=i;if(t.unshift(k(N.LinkMark,r,r+(n==N.Image?2:1))),t.push(k(N.LinkMark,i-1,i)),o==40){let n=e.skipSpace(i+1),r=ke(a,n-e.offset,e.offset),o;r&&(n=e.skipSpace(r.to),n!=r.to&&(o=Ae(a,n-e.offset,e.offset),o&&(n=e.skipSpace(o.to)))),e.char(n)==41&&(t.push(k(N.LinkMark,i,i+1)),s=n+1,r&&t.push(r),o&&t.push(o),t.push(k(N.LinkMark,n,s)))}else if(o==91){let n=je(a,i-e.offset,e.offset,!1);n&&(t.push(n),s=n.to)}return k(n,r,s,t)}function ke(e,t,n){if(e.charCodeAt(t)==60){for(let r=t+1;rt?k(N.URL,t+n,i+n):i==e.length&&null}}function Ae(e,t,n){let r=e.charCodeAt(t);if(r!=39&&r!=34&&r!=40)return!1;let i=r==40?41:r;for(let r=t+1,a=!1;ra&&r.push({from:a,to:e}),!i)break;a=i.to}return r}function Pe(e){let{codeParser:t,htmlParser:n}=e;return{wrap:ae((e,r)=>{let i=e.type.id;if(t&&(i==N.CodeBlock||i==N.FencedCode)){let n=``;if(i==N.FencedCode){let t=e.node.getChild(N.CodeInfo);t&&(n=r.read(t.from,t.to))}let a=t(n);if(a)return{parser:a,overlay:e=>e.type.id==N.CodeText,bracketed:i==N.FencedCode}}else if(n&&(i==N.HTMLBlock||i==N.HTMLTag||i==N.CommentBlock))return{parser:n,overlay:Ne(e.node,e.from,e.to)};return null})}}function j(e,t,n=0,r,i=0){let a=0,o=!0,s=-1,c=-1,l=!1,u=()=>{r.push(e.elt(`TableCell`,i+s,i+c,e.parser.parseInline(t.slice(s,c),i+s)))};for(let d=n;d-1)&&a++,o=!1,r&&(s>-1&&u(),r.push(e.elt(`TableDelimiter`,d+i,d+i+1))),s=c=-1):(l||n!=32&&n!=9)&&(s<0&&(s=d),c=d+1),l=!l&&n==92}return s>-1&&(a++,r&&u()),a}function Fe(e,t){for(let n=t;n-1)return-1;let r=t+n[0].length;for(;;){let n=e[r-1],i;if(/[?!.,:*_~]/.test(n)||n==`)`&&Ie(e,t,r,`)`)>Ie(e,t,r,`(`))r--;else if(n==`;`&&(i=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(t,r))))r=t+i.index;else break}return r}function Re(e,t){pt.lastIndex=t;let n=pt.exec(e);if(!n)return-1;let r=n[0][n[0].length-1];return r==`_`||r==`-`?-1:t+n[0].length-+(r==`.`)}function ze(e,t,n){return(r,i,a)=>{if(i!=e||r.char(a+1)==e)return-1;let o=[r.elt(n,a,a+1)];for(let i=a+1;i{se(),t(),M=class e{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new e(t,n,r,o,a,[],[])}constructor(e,t,n,r,i,a,o){this.type=e,this.value=t,this.from=n,this.hash=r,this.end=i,this.children=a,this.positions=o,this.hashProp=[[v.contextHash,r]]}addChild(e,t){e.prop(v.contextHash)!=this.hash&&(e=new h(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new h(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,n)=>new h(g.none,e,t,n,this.hashProp)})}},(function(e){e[e.Document=1]=`Document`,e[e.CodeBlock=2]=`CodeBlock`,e[e.FencedCode=3]=`FencedCode`,e[e.Blockquote=4]=`Blockquote`,e[e.HorizontalRule=5]=`HorizontalRule`,e[e.BulletList=6]=`BulletList`,e[e.OrderedList=7]=`OrderedList`,e[e.ListItem=8]=`ListItem`,e[e.ATXHeading1=9]=`ATXHeading1`,e[e.ATXHeading2=10]=`ATXHeading2`,e[e.ATXHeading3=11]=`ATXHeading3`,e[e.ATXHeading4=12]=`ATXHeading4`,e[e.ATXHeading5=13]=`ATXHeading5`,e[e.ATXHeading6=14]=`ATXHeading6`,e[e.SetextHeading1=15]=`SetextHeading1`,e[e.SetextHeading2=16]=`SetextHeading2`,e[e.HTMLBlock=17]=`HTMLBlock`,e[e.LinkReference=18]=`LinkReference`,e[e.Paragraph=19]=`Paragraph`,e[e.CommentBlock=20]=`CommentBlock`,e[e.ProcessingInstructionBlock=21]=`ProcessingInstructionBlock`,e[e.Escape=22]=`Escape`,e[e.Entity=23]=`Entity`,e[e.HardBreak=24]=`HardBreak`,e[e.Emphasis=25]=`Emphasis`,e[e.StrongEmphasis=26]=`StrongEmphasis`,e[e.Link=27]=`Link`,e[e.Image=28]=`Image`,e[e.InlineCode=29]=`InlineCode`,e[e.HTMLTag=30]=`HTMLTag`,e[e.Comment=31]=`Comment`,e[e.ProcessingInstruction=32]=`ProcessingInstruction`,e[e.Autolink=33]=`Autolink`,e[e.HeaderMark=34]=`HeaderMark`,e[e.QuoteMark=35]=`QuoteMark`,e[e.ListMark=36]=`ListMark`,e[e.LinkMark=37]=`LinkMark`,e[e.EmphasisMark=38]=`EmphasisMark`,e[e.CodeMark=39]=`CodeMark`,e[e.CodeText=40]=`CodeText`,e[e.CodeInfo=41]=`CodeInfo`,e[e.LinkTitle=42]=`LinkTitle`,e[e.LinkLabel=43]=`LinkLabel`,e[e.URL=44]=`URL`})(N||={}),Be=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},Ve=class{constructor(){this.text=``,this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return b(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[N.OrderedList]:ve,[N.BulletList]:ve,[N.Document](){return!0}},F=/^[ \t]*$/,I=/-->/,L=/\?>/,R=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*/i.exec(r);if(a)return e.append(k(N.Comment,n,n+1+a[0].length));let o=/^\?[^]*?\?>/.exec(r);if(o)return e.append(k(N.ProcessingInstruction,n,n+1+o[0].length));let s=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(r);return s?e.append(k(N.HTMLTag,n,n+1+s[0].length)):-1},Emphasis(e,t,n){if(t!=95&&t!=42)return-1;let r=n+1;for(;e.char(r)==t;)r++;let i=e.slice(n-1,n),a=e.slice(r,r+1),o=q.test(i),s=q.test(a),c=/\s|^$/.test(i),l=/\s|^$/.test(a),u=!l&&(!s||c||o),d=!c&&(!o||l||s),f=u&&(t==42||!d||o),p=d&&(t==42||!u||s);return e.append(new K(t==95?Xe:Ze,n,r,!!f|(p?2:0)))},HardBreak(e,t,n){if(t==92&&e.char(n+1)==10)return e.append(k(N.HardBreak,n,n+2));if(t==32){let t=n+1;for(;e.char(t)==32;)t++;if(e.char(t)==10&&t>=n+2)return e.append(k(N.HardBreak,n,t+1))}return-1},Link(e,t,n){return t==91?e.append(new K(W,n,n+1,1)):-1},Image(e,t,n){return t==33&&e.char(n+1)==91?e.append(new K(G,n,n+2,1)):-1},LinkEnd(e,t,n){if(t!=93)return-1;for(let t=e.parts.length-1;t>=0;t--){let r=e.parts[t];if(r instanceof K&&(r.type==W||r.type==G)){if(!r.side||e.skipSpace(r.to)==n&&!/[(\[]/.test(e.slice(n+1,n+2)))return e.parts[t]=null,-1;let i=e.takeContent(t),a=e.parts[t]=Oe(e,i,r.type==W?N.Link:N.Image,r.from,n+1);if(r.type==W)for(let n=0;n=this.end?-1:this.text.charCodeAt(e-this.offset)}get end(){return this.offset+this.text.length}slice(e,t){return this.text.slice(e-this.offset,t-this.offset)}append(e){return this.parts.push(e),e.to}addDelimiter(e,t,n,r,i){return this.append(new K(e,t,n,!!r|(i?2:0)))}get hasOpenLink(){for(let e=this.parts.length-1;e>=0;e--){let t=this.parts[e];if(t instanceof K&&(t.type==W||t.type==G))return!0}return!1}addElement(e){return this.append(e)}resolveMarkers(e){for(let t=e;t=e;o--){let e=this.parts[o];if(e instanceof K&&e.side&1&&e.type==n.type&&!(r&&(n.side&1||e.side&2)&&(e.to-e.from+i)%3==0&&((e.to-e.from)%3||i%3))){a=e;break}}if(!a)continue;let s=n.type.resolve,c=[],l=a.from,u=n.to;if(r){let e=Math.min(2,a.to-a.from,i);l=a.to-e,u=n.from+e,s=e==1?`Emphasis`:`StrongEmphasis`}a.type.mark&&c.push(this.elt(a.type.mark,l,a.to));for(let e=o+1;e=0;t--){let n=this.parts[t];if(n instanceof K&&n.type==e&&n.side&1)return t}return null}takeContent(e){let t=this.resolveMarkers(e);return this.parts.length=e,t}getDelimiterAt(e){let t=this.parts[e];return t instanceof K?t:null}skipSpace(e){return b(this.text,e-this.offset)+this.offset}elt(e,t,n,r){return typeof e==`string`?k(this.parser.getNodeType(e),t,n,r):new Ye(e,t)}},Y.linkStart=W,Y.imageStart=G,$e=[N.CodeBlock,N.ListItem,N.OrderedList,N.BulletList],et=class{constructor(e,t){this.fragments=e,this.input=t,this.i=0,this.fragment=null,this.fragmentEnd=-1,this.cursor=null,e.length&&(this.fragment=e[this.i++])}nextFragment(){this.fragment=this.i(e?e-1:0))return!1;if(this.fragmentEnd<0){let e=this.fragment.to;for(;e>0&&this.input.read(e-1,e)!=` `;)e--;this.fragmentEnd=e?e-1:0}let n=this.cursor;n||(n=this.cursor=this.fragment.tree.cursor(),n.firstChild());let r=e+this.fragment.offset;for(;n.to<=r;)if(!n.parent())return!1;for(;;){if(n.from>=r)return this.fragment.from<=t;if(!n.childAfter(r))return!1}}matches(e){let t=this.cursor.tree;return t&&t.prop(v.contextHash)==e}takeNodes(e){let t=this.cursor,n=this.fragment.offset,r=this.fragmentEnd-+!!this.fragment.openEnd,i=e.absoluteLineStart,a=i,o=e.block.children.length,s=a,c=o;for(;;){if(t.to-n>r){if(t.type.isAnonymous&&t.firstChild())continue;break}let i=Me(t.from-n,e.ranges);if(t.to-n<=e.ranges[e.rangeI].to)e.addNode(t.tree,i);else{let n=new h(e.parser.nodeSet.types[N.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(n,t.tree),e.addNode(n,i)}if(t.type.is(`Block`)&&($e.indexOf(t.type.id)<0?(a=t.to-n,o=e.block.children.length):(a=s,o=c),s=t.to-n,c=e.block.children.length),!t.nextSibling())break}for(;e.block.children.length>o;)e.block.children.pop(),e.block.positions.pop();return a-i}},tt=re({"Blockquote/...":s.quote,HorizontalRule:s.contentSeparator,"ATXHeading1/... SetextHeading1/...":s.heading1,"ATXHeading2/... SetextHeading2/...":s.heading2,"ATXHeading3/...":s.heading3,"ATXHeading4/...":s.heading4,"ATXHeading5/...":s.heading5,"ATXHeading6/...":s.heading6,"Comment CommentBlock":s.comment,Escape:s.escape,Entity:s.character,"Emphasis/...":s.emphasis,"StrongEmphasis/...":s.strong,"Link/... Image/...":s.link,"OrderedList/... BulletList/...":s.list,"BlockQuote/...":s.quote,"InlineCode CodeText":s.monospace,"URL Autolink":s.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":s.processingInstruction,"CodeInfo LinkLabel":s.labelName,LinkTitle:s.string,Paragraph:s.content}),nt=new V(new p(qe).extend(tt),Object.keys(z).map(e=>z[e]),Object.keys(z).map(e=>B[e]),Object.keys(z),We,P,Object.keys(J).map(e=>J[e]),Object.keys(J),[]),rt={resolve:`Strikethrough`,mark:`StrikethroughMark`},it={defineNodes:[{name:`Strikethrough`,style:{"Strikethrough/...":s.strikethrough}},{name:`StrikethroughMark`,style:s.processingInstruction}],parseInline:[{name:`Strikethrough`,parse(e,t,n){if(t!=126||e.char(n+1)!=126||e.char(n+2)==126)return-1;let r=e.slice(n-1,n),i=e.slice(n+2,n+3),a=/\s|^$/.test(r),o=/\s|^$/.test(i),s=q.test(r),c=q.test(i);return e.addDelimiter(rt,n,n+2,!o&&(!c||a||s),!a&&(!s||o||c))},after:`Emphasis`}]},at=/^[>\s]*\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/,ot=class{constructor(){this.rows=null}nextLine(e,t,n){if(this.rows==null){this.rows=!1;let r;if((t.next==45||t.next==58||t.next==124)&&at.test(r=t.text.slice(t.pos))){let i=[];j(e,n.content,0,i,n.start)==j(e,r,0)&&(this.rows=[e.elt(`TableHeader`,n.start,n.start+n.content.length,i),e.elt(`TableDelimiter`,e.lineStart+t.pos,e.lineStart+t.text.length)])}}else if(this.rows){let n=[];j(e,t.text,t.pos,n,e.lineStart),this.rows.push(e.elt(`TableRow`,e.lineStart+t.pos,e.lineStart+t.text.length,n))}return!1}finish(e,t){return this.rows?(e.addLeafElement(t,e.elt(`Table`,t.start,t.start+t.content.length,this.rows)),!0):!1}},st={defineNodes:[{name:`Table`,block:!0},{name:`TableHeader`,style:{"TableHeader/...":s.heading}},`TableRow`,{name:`TableCell`,style:s.content},{name:`TableDelimiter`,style:s.processingInstruction}],parseBlock:[{name:`Table`,leaf(e,t){return Fe(t.content,0)?new ot:null},endLeaf(e,t,n){if(n.parsers.some(e=>e instanceof ot)||!Fe(t.text,t.basePos))return!1;let r=e.peekLine();return at.test(r)&&j(e,t.text,t.basePos)==j(e,r,t.basePos)},before:`SetextHeading`}]},ct=class{nextLine(){return!1}finish(e,t){return e.addLeafElement(t,e.elt(`Task`,t.start,t.start+t.content.length,[e.elt(`TaskMarker`,t.start,t.start+3),...e.parser.parseInline(t.content.slice(3),t.start+3)])),!0}},lt={defineNodes:[{name:`Task`,block:!0,style:s.list},{name:`TaskMarker`,style:s.atom}],parseBlock:[{name:`TaskList`,leaf(e,t){return/^\[[ xX]\][ \t]/.test(t.content)&&e.parentType().name==`ListItem`?new ct:null},after:`SetextHeading`}]},ut=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,dt=/[\w-]+(\.[\w-]+)+(:\d+)?(\/[^\s<]*)?/gy,ft=/[\w-]+\.[\w-]+($|[/:])/,pt=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,mt=/\/[a-zA-Z\d@.]+/gy,ht={parseInline:[{name:`Autolink`,parse(e,t,n){let r=n-e.offset;if(r&&/\w/.test(e.text[r-1]))return-1;ut.lastIndex=r;let i=ut.exec(e.text),a=-1;return!i||(i[1]||i[2]?(a=Le(e.text,r+i[0].length),a>-1&&e.hasOpenLink&&(a=r+/([^\[\]]|\[[^\]]*\])*/.exec(e.text.slice(r,a))[0].length)):i[3]?a=Re(e.text,r):(a=Re(e.text,r+i[0].length),a>-1&&i[0]==`xmpp:`&&(mt.lastIndex=a,i=mt.exec(e.text),i&&(a=i.index+i[0].length))),a<0)?-1:(e.addElement(e.elt(`URL`,n,a+e.offset)),a+e.offset)}}]},gt=[st,lt,it,ht],_t={defineNodes:[{name:`Superscript`,style:s.special(s.content)},{name:`SuperscriptMark`,style:s.processingInstruction}],parseInline:[{name:`Superscript`,parse:ze(94,`Superscript`,`SuperscriptMark`)}]},vt={defineNodes:[{name:`Subscript`,style:s.special(s.content)},{name:`SubscriptMark`,style:s.processingInstruction}],parseInline:[{name:`Subscript`,parse:ze(126,`Subscript`,`SubscriptMark`)}]},yt={defineNodes:[{name:`Emoji`,style:s.character}],parseInline:[{name:`Emoji`,parse(e,t,n){let r;return t!=58||!(r=/^[a-zA-Z_0-9]+:/.exec(e.slice(n+1,e.end)))?-1:e.addElement(e.elt(`Emoji`,n,n+1+r[0].length))}}]}})))()}function xt(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function St(e){return e.name==`OrderedList`||e.name==`BulletList`}function Ct(e,t){let n=e;for(;;){let e=n.nextSibling,r;if(!e||(r=xt(e.type))!=null&&r<=t)break;n=e}return n.to}function wt(e){return new ce(X,e,[],`markdown`)}function Tt(e,t){return n=>{if(n&&e){let t=null;if(n=/\S*/.exec(n)[0],t=typeof e==`function`?e(n):te.matchLanguageName(e,n,!0),t instanceof te)return t.support?t.support.language.parser:oe.getSkippingParser(t.load());if(t)return t.parser}return t?t.parser:null}}function Et(e,t){let n=[],r=[];for(let t=e;t;t=t.parent){if(t.name==`FencedCode`)return r;(t.name==`ListItem`||t.name==`Blockquote`)&&n.push(t)}for(let e=n.length-1;e>=0;e--){let i=n[e],a,o=t.lineAt(i.from),s=i.from-o.from;if(i.name==`Blockquote`&&(a=/^ *>( ?)/.exec(o.text.slice(s))))r.push(new Q(i,s,s+a[0].length,``,a[1],`>`,null));else if(i.name==`ListItem`&&i.parent.name==`OrderedList`&&(a=/^( *)\d+([.)])( *)/.exec(o.text.slice(s)))){let e=a[3],t=a[0].length;e.length>=4&&(e=e.slice(0,e.length-4),t-=4),r.push(new Q(i.parent,s,s+t,a[1],e,a[2],i))}else if(i.name==`ListItem`&&i.parent.name==`BulletList`&&(a=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(s)))){let e=a[4],t=a[0].length;e.length>4&&(e=e.slice(0,e.length-4),t-=4);let n=a[2];a[3]&&(n+=a[3].replace(/[xX]/,` `)),r.push(new Q(i.parent,s,s+t,a[1],e,n,i))}}return r}function Dt(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function Ot(e,t,n,r=0){for(let i=-1,a=e;;){if(a.name==`ListItem`){let e=Dt(a,t),o=+e[2];if(i>=0){if(o!=i+1)return;n.push({from:a.from+e[1].length,to:a.from+e[0].length,insert:String(i+2+r)})}i=o}let e=a.nextSibling;if(!e)break;a=e}}function kt(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(f)!=` `)return e;let r=_(e,4,n),i=``;for(let e=r;e>0;)e>=4?(i+=` `,e-=4):(i+=` `,e--);return i+e.slice(n)}function At(e){return e.name==`QuoteMark`||e.name==`ListMark`}function jt(e,t){if(e.name!=`OrderedList`&&e.name!=`BulletList`)return!1;let n=e.firstChild,r=e.getChild(`ListItem`,`ListItem`);if(!r)return!1;let i=t.lineAt(n.to),a=t.lineAt(r.from),o=/^[\s>]*$/.test(i.text);return i.number+ +!o{ne(),c(),de(),ge(),bt(),me(),se(),X=le({commentTokens:{block:{open:``}}}),Lt=new v,Rt=nt.configure({props:[ie.add(e=>!e.is(`Block`)||e.is(`Document`)||xt(e)!=null||St(e)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),Lt.add(xt),ue.add({Document:()=>null}),l.add({Document:X})]}),zt=ee.of((e,t,n)=>{for(let i=r(e).resolveInner(n,-1);i&&!(i.fromn)return{from:n,to:t}}return null}),Bt=wt(Rt),Z=wt(Rt.configure([gt,vt,_t,yt,{props:[ie.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}])),Q=class{constructor(e,t,n,r,i,a,o){this.node=e,this.from=t,this.to=n,this.spaceBefore=r,this.spaceAfter=i,this.type=a,this.item=o}blank(e,t=!0){let n=this.spaceBefore+(this.node.name==`Blockquote`?`>`:``);if(e!=null){for(;n.length0;e--)n+=` `;return n+(t?this.spaceAfter:``)}marker(e,t){let n=this.node.name==`OrderedList`?String(+Dt(this.item,e)[2]+t):``;return this.spaceBefore+n+this.type+this.spaceAfter}},Vt=(e={})=>({state:t,dispatch:n})=>{let i=r(t),{doc:o}=t,s=null,c=t.changeByRange(n=>{if(!n.empty||!Z.isActiveAt(t,n.from,-1)&&!Z.isActiveAt(t,n.from,1))return s={range:n};let r=n.from,c=o.lineAt(r),l=Et(i.resolveInner(r,-1),o);for(;l.length&&l[l.length-1].from>r-c.from;)l.pop();if(!l.length)return s={range:n};let u=l[l.length-1];if(u.to-u.spaceAfter.length>r-c.from)return s={range:n};let d=r>=u.to-u.spaceAfter.length&&!/\S/.test(c.text.slice(u.to));if(u.item&&d){let n=u.node.firstChild,i=u.node.getChild(`ListItem`,`ListItem`);if(n.to>=r||i&&i.to0&&!/[^\s>]/.test(o.lineAt(c.from-1).text)||e.nonTightLists===!1){let e=l.length>1?l[l.length-2]:null,t,n=``;e&&e.item?(t=c.from+e.from,n=e.marker(o,1)):t=c.from+(e?e.to:0);let i=[{from:t,to:r,insert:n}];return u.node.name==`OrderedList`&&Ot(u.item,o,i,-2),e&&e.node.name==`OrderedList`&&Ot(e.item,o,i),{range:a.cursor(t+n.length),changes:i}}{let e=Mt(l,t,c);return{range:a.cursor(r+e.length+1),changes:{from:c.from,insert:e+t.lineBreak}}}}if(u.node.name==`Blockquote`&&d&&c.from){let e=o.lineAt(c.from-1),r=/>\s*$/.exec(e.text);if(r&&r.index==u.from){let i=t.changes([{from:e.from+r.index,to:e.to},{from:c.from+u.from,to:c.to}]);return{range:n.map(i),changes:i}}}let f=[];u.node.name==`OrderedList`&&Ot(u.item,o,f);let p=u.item&&u.item.from]*/.exec(c.text)[0].length>=u.to)for(let e=0,t=l.length-1;e<=t;e++)m+=e==t&&!p?l[e].marker(o,1):l[e].blank(ec.from&&/\s/.test(c.text.charAt(h-c.from-1));)h--;return m=kt(m,t),jt(u.node,t.doc)&&(m=Mt(l,t,c)+t.lineBreak+m),f.push({from:h,to:r,insert:t.lineBreak+m}),{range:a.cursor(h+m.length+1),changes:f}});return!s&&(n(t.update(c,{scrollIntoView:!0,userEvent:`input`})),!0)},Ht=Vt(),Ut=({state:e,dispatch:t})=>{let n=r(e),i=null,o=e.changeByRange(t=>{let r=t.from,{doc:o}=e;if(t.empty&&Z.isActiveAt(e,t.from)){let t=o.lineAt(r),i=Et(Nt(n,r),o);if(i.length){let n=i[i.length-1],o=n.to-n.spaceAfter.length+ +!!n.spaceAfter;if(r-t.from>o&&!/\S/.test(t.text.slice(o,r-t.from)))return{range:a.cursor(t.from+o),changes:{from:t.from+o,to:r}};if(r-t.from==o&&(n.item&&t.from<=n.item.from||/^[\s>]*$/.test(t.text.slice(0,n.to)))){let i=t.from+n.from;if(n.item&&n.node.from{let{main:n}=t.state.selection;if(n.empty)return!1;let i=e.clipboardData?.getData(`text/plain`);if(!i||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(i)||(/^www\./.test(i)&&(i=`https://`+i),!Z.isActiveAt(t.state,n.from,1)))return!1;let a=r(t.state),o=!1;return a.iterate({from:n.from,to:n.to,enter:e=>{(e.from>n.from||Kt.test(e.name))&&(o=!0)},leave:e=>{e.to