Files
llm-in-text/.build-check/assets/vendor-lezer-markdown-DG8DLr3V.js
T

7 lines
35 KiB
JavaScript
Raw Normal View History

import{P as Te,b as y,N as H,c as fe,p as De,T as E}from"./vendor-lezer-common-tVQBIsvN.js";import{T as Xe,s as de,t as p}from"./vendor-lezer-highlight-DuEf3ZFH.js";class O{static create(e,s,r,n,i){let o=n+(n<<8)+e+(s<<4)|0;return new O(e,s,r,o,i,[],[])}constructor(e,s,r,n,i,o,a){this.type=e,this.value=s,this.from=r,this.hash=n,this.end=i,this.children=o,this.positions=a,this.hashProp=[[H.contextHash,n]]}addChild(e,s){e.prop(H.contextHash)!=this.hash&&(e=new E(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(s)}toTree(e,s=this.end){let r=this.children.length-1;return r>=0&&(s=Math.max(s,this.positions[r]+this.children[r].length+this.from)),new E(e.types[this.type],this.children,this.positions,s-this.from).balance({makeTree:(n,i,o)=>new E(y.none,n,i,o,this.hashProp)})}}var l;(function(t){t[t.Document=1]="Document",t[t.CodeBlock=2]="CodeBlock",t[t.FencedCode=3]="FencedCode",t[t.Blockquote=4]="Blockquote",t[t.HorizontalRule=5]="HorizontalRule",t[t.BulletList=6]="BulletList",t[t.OrderedList=7]="OrderedList",t[t.ListItem=8]="ListItem",t[t.ATXHeading1=9]="ATXHeading1",t[t.ATXHeading2=10]="ATXHeading2",t[t.ATXHeading3=11]="ATXHeading3",t[t.ATXHeading4=12]="ATXHeading4",t[t.ATXHeading5=13]="ATXHeading5",t[t.ATXHeading6=14]="ATXHeading6",t[t.SetextHeading1=15]="SetextHeading1",t[t.SetextHeading2=16]="SetextHeading2",t[t.HTMLBlock=17]="HTMLBlock",t[t.LinkReference=18]="LinkReference",t[t.Paragraph=19]="Paragraph",t[t.CommentBlock=20]="CommentBlock",t[t.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",t[t.Escape=22]="Escape",t[t.Entity=23]="Entity",t[t.HardBreak=24]="HardBreak",t[t.Emphasis=25]="Emphasis",t[t.StrongEmphasis=26]="StrongEmphasis",t[t.Link=27]="Link",t[t.Image=28]="Image",t[t.InlineCode=29]="InlineCode",t[t.HTMLTag=30]="HTMLTag",t[t.Comment=31]="Comment",t[t.ProcessingInstruction=32]="ProcessingInstruction",t[t.Autolink=33]="Autolink",t[t.HeaderMark=34]="HeaderMark",t[t.QuoteMark=35]="QuoteMark",t[t.ListMark=36]="ListMark",t[t.LinkMark=37]="LinkMark",t[t.EmphasisMark=38]="EmphasisMark",t[t.CodeMark=39]="CodeMark",t[t.CodeText=40]="CodeText",t[t.CodeInfo=41]="CodeInfo",t[t.LinkTitle=42]="LinkTitle",t[t.LinkLabel=43]="LinkLabel",t[t.URL=44]="URL"})(l||(l={}));class Fe{constructor(e,s){this.start=e,this.content=s,this.marks=[],this.parsers=[]}}class je{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 x(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,s=0,r=0){for(let n=s;n<e;n++)r+=this.text.charCodeAt(n)==9?4-r%4:1;return r}findColumn(e){let s=0;for(let r=0;s<this.text.length&&r<e;s++)r+=this.text.charCodeAt(s)==9?4-r%4:1;return s}scrub(){if(!this.baseIndent)return this.text;let e="";for(let s=0;s<this.basePos;s++)e+=" ";return e+this.text.slice(this.basePos)}}function Y(t,e,s){if(s.pos==s.text.length||t!=e.block&&s.indent>=e.stack[s.depth+1].value+s.baseIndent)return!0;if(s.indent>=s.baseIndent+4)return!1;let r=(t.type==l.OrderedList?G:Q)(s,e,!1);return r>0&&(t.type!=l.BulletList||Z(s,e,!1)<0)&&s.text.charCodeAt(s.pos+r-1)==t.value}const ue={[l.Blockquote](t,e,s){return s.next!=62?!1:(s.markers.push(c(l.QuoteMark,e.lineStart+s.pos,e.lineStart+s.pos+1)),s.moveBase(s.pos+(S(s.text.charCodeAt(s.pos+1))?2:1)),t.end=e.lineStart+s.text.length,!0)},[l.ListItem](t,e,s){return s.indent<s.baseIndent+t.value&&s.next>-1?!1:(s.moveBaseColumn(s.baseIndent+t.value),!0)},[l.OrderedList]:Y,[l.BulletList]:Y,[l.Document](){return!0}};function S(t){return
`+s.scrub(),i=this.advance(n);return i>-1&&i<n.length?this.complete(e,r,i):!1}finish(e,s){return(this.stage==2||this.stage==3)&&x(s.content,this.pos)==s.content.length?this.complete(e,s,s.content.length):!1}complete(e,s,r){return e.addLeafElement(s,c(l.LinkReference,this.start,this.start+r,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(Pe(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(c(l.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(Me(e,x(e,this.pos),this.start)))return-1}else if(this.stage==2){let s=x(e,this.pos),r=0;if(s>this.pos){let n=He(e,s,this.start);if(n){let i=F(e,n.to-this.start);i>0&&(this.nextStage(n),r=i)}}return r||(r=F(e,this.pos)),r>0&&r<e.length?r:-1}else return F(e,this.pos)}}}function F(t,e){for(;e<t.length;e++){let s=t.charCodeAt(e);if(s==10)break;if(!S(s))return-1}return e}class _e{nextLine(e,s,r){let n=s.depth<e.stack.length?-1:ge(s),i=s.next;if(n<0)return!1;let o=c(l.HeaderMark,e.lineStart+s.pos,e.lineStart+n);return e.nextLine(),e.addLeafElement(r,c(i==61?l.SetextHeading1:l.SetextHeading2,r.start,e.prevLineEnd(),[...e.parser.parseInline(r.content,r.start),o])),!0}finish(){return!1}}const we={LinkReference(t,e){return e.content.charCodeAt(0)==91?new $e(e):null},SetextHeading(){return new _e}},Ue=[(t,e)=>me(e)>=0,(t,e)=>pe(e)>=0,(t,e)=>ce(e)>=0,(t,e)=>Q(e,t,!0)>=0,(t,e)=>G(e,t,!0)>=0,(t,e)=>Z(e,t,!0)>=0,(t,e)=>Se(e,t,!0)>=0],qe={text:"",end:0};class Ze{constructor(e,s,r,n){this.parser=e,this.input=s,this.ranges=n,this.line=new je,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=n[n.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=n[0].from,this.block=O.create(l.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new Ve(r,s):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let r=0;;){let n=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;r<e.markers.length&&(!n||e.markers[r].from<n.end);){let i=e.markers[r++];this.addNode(i.type,i.from,i.to)}if(!n)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;e:for(;;){for(let r of this.parser.blockParsers)if(r){let n=r(this,e);if(n!=!1){if(n==!0)return null;e.forward();continue e}}break}let s=new Fe(this.lineStart+e.pos,e.text.slice(e.pos));for(let r of this.parser.leafBlockParsers)if(r){let n=r(this,s);n&&s.parsers.push(n)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let r of this.parser.endLeafBlock)if(r(this,e,s))break e}for(let r of s.parsers)if(r.nextLine(this,e,s))return null;s.content+=`
`+e.scrub();for(let r of e.markers)s.marks.push(r)}return this.finishLeaf(s),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let s=this.fragments.takeNodes(this);return s?(this.absoluteLineStart+=s,this.lineStart=ve(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let s=qe;if(s.end=e,e>=this.to)s.text="";else if(s.text=this.lineChunkAt(e),s.end+=s.text.length,this.ranges.length>1){let r=this.absoluteLineStart,n=this.rangeI;for(;this.ranges[n].to<s.end;){n++;let i=this.ranges[n].from,o=this.lineChunkAt(i);s.end=i+o.length,s.text=s.text.slice(0,this.ranges[n-1].to-r)+o,r=s.end-s.text.length}}return s}readLine(){let{line:e}=this,{text:s,end:r}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=r,e.reset(s);e.depth<this.stack.length;e.depth++){let n=this.stack[e.depth],i=this.parser.skipContextMarkup[n.type];if(!i)throw new Error("Unhandled block context "+l[n.type]);let o=this.line.markers.length;if(!i(n,this,e)){this.line.markers.length>o&&(n.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let s=this.input.chunk(e),r;if(this.input.lineChunks)r=s==`
`?"":s;else{let n=s.indexOf(`
`);r=n<0?s:s.slice(0,n)}return e+r.length>this.to?r.slice(0,this.to-e):r}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,s,r=0){this.block=O.create(e,r,this.lineStart+s,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,s,r=0){this.startContext(this.parser.getNodeType(e),s,r)}addNode(e,s,r){typeof e=="number"&&(e=new E(this.parser.nodeSet.types[e],A,A,(r??this.prevLineEnd())-s)),this.block.addChild(e,s-this.block.from)}addElement(e){this.block.addChild(e.toTree(this.parser.nodeSet),e.from-this.block.from)}addLeafElement(e,s){this.addNode(this.buffer.writeElements(q(s.children,e.marks),-s.from).finish(s.type,s.to-s.from),s.from)}finishContext(){let e=this.stack.pop(),s=this.stack[this.stack.length-1];s.addChild(e.toTree(this.parser.nodeSet),e.from-s.from),this.block=s}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(e){return this.ranges.length>1?Ce(this.ranges,0,e.topNode,this.ranges[0].from,this.reusePlaceholders):e}finishLeaf(e){for(let r of e.parsers)if(r.finish(this,e))return;let s=q(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(s,-e.start).finish(l.Paragraph,e.content.length),e.start)}elt(e,s,r,n){return typeof e=="string"?c(this.parser.getNodeType(e),s,r,n):new Ie(e,s)}get buffer(){return new Ae(this.parser.nodeSet)}}function Ce(t,e,s,r,n){let i=t[e].to,o=[],a=[],h=s.from+r;function d(u,k){for(;k?u>=i:u>i;){let f=t[e+1].from-i;r+=f,u+=f,e++,i=t[e].to}}for(let u=s.firstChild;u;u=u.nextSibling){d(u.from+r,!0);let k=u.from+r,f,m=n.get(u.tree);m?f=m:u.to+r>i?(f=Ce(t,e,u,r,n),d(u.to+r,!1)):f=u.toTree(),o.push(f),a.push(k-h)}return d(s.to+r,!1),new E(s.type,o,a,s.to+r-h,s.tree?s.tree.propValues:void 0)}class V extends Te{constructor(e,s,r,n,i,o,a,h,d){super(),this.nodeSet=e,this.blockParsers=s,this.leafBlockParsers=r,this.blockNames=n,this.endLeafBlock=i,this.skipContextMarkup=o,this.inlineParsers=a,this.inlineNames=h,this.wrappers=d,this.nodeTypes=Object.create(null);for(let u of e.types)this.nodeTypes[u.name]=u.id}createParse(e,s,r){let n=new Ze(this,e,s,r);for(let i of this.wrappers)n=i(n,e,s,r);return n}configure(e){let s=U(e);if(!s)return this;let{nodeSet:r,skipContextMarkup:n}=this,i=this.blockParsers.slice(),o=this.leafBlockParsers.slice(),a=this.blockNames.slice(),h=this.inlineParsers.slice(),d=this.inlineNames.slice(),u=this.endLeafBlock.slice(),k=this.wrappers;if(B(s.defineNodes)){n=Object.assign({},n);let f=r.types.slice(),m;for(let L of s.defineNodes){let{name:g,block:Oe,composite:T,style:I}=typeof L=="string"?{name:L}:L;if(f.some(X=>X.name==g))continue;T&&(n[f.length]=(X,ze,ye)=>T(ze,ye,X.value));let D=f.length,K=T?["Block","BlockContext"]:Oe?D>=l.ATXHeading1&&D<=l.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;f.push(y.define({id:D,name:g,props:K&&[[H.group,K]]})),I&&(m||(m={}),Array.isArray(I)||I instanceof Xe?m[g]=I:Object.assign(m,I))}r=new fe(f),m&&(r=r.extend(de(m)))}if(B(s.props)&&(r=r.extend(...s.props)),B(s.remove))for(let f of s.remove){let m=this.blockNames.indexOf(f),L=this.inlineNames.indexOf(f);m>-1&&(i[m]=o[m]=void 0),L>-1&&(h[L]=void 0)}if(B(s.parseBlock))for(let f of s.parseBlock){let m=a.indexOf(f.name);if(m>-1)i[m]=f.parse,o[m]=f.leaf;else{let L=f.before?R(a,f.before):f.after?R(a,f.after)+1:a.length-1;i.splice(L,0,f.parse),o.splice(L,0,f.leaf),a.splice(L,0,f.name)}f.endLeaf&&u.push(f.endLeaf)}if(B(s.parseInline))for(let f of s.parseInline){let m=d.indexOf(f.name);if(m>-1)h[m]=f.parse;else{let L=f.before?R(d,f.before):f.after?R(d,f.after)+1:d.length-1;h.splice(L,0,f.parse),d.splice(L,0,f.name)}}return s.wrap&&(k=k.concat(s.wrap)),new V(r,i,o,a,u,n,h,d,k)}getNodeType(e){let s=this.nodeTypes[e];if(s==null)throw new RangeError(`Unknown node type '${e}'`);return s}parseInline(e,s){let r=new J(this,e,s);e:for(let n=s;n<r.end;){let i=r.char(n);for(let o of this.inlineParsers)if(o){let a=o(r,i,n);if(a>=0){n=a;continue e}}n++}return r.resolveMarkers(0)}}funct
`;)i--;this.fragmentEnd=i?i-1:0}let r=this.cursor;r||(r=this.cursor=this.fragment.tree.cursor(),r.firstChild());let n=e+this.fragment.offset;for(;r.to<=n;)if(!r.parent())return!1;for(;;){if(r.from>=n)return this.fragment.from<=s;if(!r.childAfter(n))return!1}}matches(e){let s=this.cursor.tree;return s&&s.prop(H.contextHash)==e}takeNodes(e){let s=this.cursor,r=this.fragment.offset,n=this.fragmentEnd-(this.fragment.openEnd?1:0),i=e.absoluteLineStart,o=i,a=e.block.children.length,h=o,d=a;for(;;){if(s.to-r>n){if(s.type.isAnonymous&&s.firstChild())continue;break}let u=ve(s.from-r,e.ranges);if(s.to-r<=e.ranges[e.rangeI].to)e.addNode(s.tree,u);else{let k=new E(e.parser.nodeSet.types[l.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(k,s.tree),e.addNode(k,u)}if(s.type.is("Block")&&(Ge.indexOf(s.type.id)<0?(o=s.to-r,a=e.block.children.length):(o=h,a=d),h=s.to-r,d=e.block.children.length),!s.nextSibling())break}for(;e.block.children.length>a;)e.block.children.pop(),e.block.positions.pop();return o-i}}function ve(t,e){let s=t;for(let r=1;r<e.length;r++){let n=e[r-1].to,i=e[r].from;n<t&&(s-=i-n)}return s}const Je=de({"Blockquote/...":p.quote,HorizontalRule:p.contentSeparator,"ATXHeading1/... SetextHeading1/...":p.heading1,"ATXHeading2/... SetextHeading2/...":p.heading2,"ATXHeading3/...":p.heading3,"ATXHeading4/...":p.heading4,"ATXHeading5/...":p.heading5,"ATXHeading6/...":p.heading6,"Comment CommentBlock":p.comment,Escape:p.escape,Entity:p.character,"Emphasis/...":p.emphasis,"StrongEmphasis/...":p.strong,"Link/... Image/...":p.link,"OrderedList/... BulletList/...":p.list,"BlockQuote/...":p.quote,"InlineCode CodeText":p.monospace,"URL Autolink":p.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":p.processingInstruction,"CodeInfo LinkLabel":p.labelName,LinkTitle:p.string,Paragraph:p.content}),lt=new V(new fe(Ee).extend(Je),Object.keys(N).map(t=>N[t]),Object.keys(N).map(t=>we[t]),Object.keys(N),Ue,ue,Object.keys(j).map(t=>j[t]),Object.keys(j),[]);function Ke(t,e,s){let r=[];for(let n=t.firstChild,i=e;;n=n.nextSibling){let o=n?n.from:s;if(o>i&&r.push({from:i,to:o}),!n)break;i=n.to}return r}function ht(t){let{codeParser:e,htmlParser:s}=t;return{wrap:De((n,i)=>{let o=n.type.id;if(e&&(o==l.CodeBlock||o==l.FencedCode)){let a="";if(o==l.FencedCode){let d=n.node.getChild(l.CodeInfo);d&&(a=i.read(d.from,d.to))}let h=e(a);if(h)return{parser:h,overlay:d=>d.type.id==l.CodeText,bracketed:o==l.FencedCode}}else if(s&&(o==l.HTMLBlock||o==l.HTMLTag||o==l.CommentBlock))return{parser:s,overlay:Ke(n.node,n.from,n.to)};return null})}}const Ye={resolve:"Strikethrough",mark:"StrikethroughMark"},We={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":p.strikethrough}},{name:"StrikethroughMark",style:p.processingInstruction}],parseInline:[{name:"Strikethrough",parse(t,e,s){if(e!=126||t.char(s+1)!=126||t.char(s+2)==126)return-1;let r=t.slice(s-1,s),n=t.slice(s+2,s+3),i=/\s|^$/.test(r),o=/\s|^$/.test(n),a=v.test(r),h=v.test(n);return t.addDelimiter(Ye,s,s+2,!o&&(!h||i||a),!i&&(!a||o||h))},after:"Emphasis"}]};function M(t,e,s=0,r,n=0){let i=0,o=!0,a=-1,h=-1,d=!1,u=()=>{r.push(t.elt("TableCell",n+a,n+h,t.parser.parseInline(e.slice(a,h),n+a)))};for(let k=s;k<e.length;k++){let f=e.charCodeAt(k);f==124&&!d?((!o||a>-1)&&i++,o=!1,r&&(a>-1&&u(),r.push(t.elt("TableDelimiter",k+n,k+n+1))),a=h=-1):(d||f!=32&&f!=9)&&(a<0&&(a=k),h=k+1),d=!d&&f==92}return a>-1&&(i++,r&&u()),i}function se(t,e){for(let s=e;s<t.length;s++){let r=t.charCodeAt(s);if(r==124)return!0;r==92&&s++}return!1}const Ne=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;class re{constructor(){this.rows=null}nextLine(e,s,r){if(this.rows==null){this.rows=!1;let n;if((s.next==45||s.next==58||s.next==124)&&Ne.test(n=s.text.slice(s.pos))){let i=[];M(e,r.content,0,i,r.start)==M(e,n,s.pos)&&(this.rows=[e.elt("TableHeader",r.start,r.start+r.content.length,i),e.elt("TableDelimiter",e.lineStart+s.pos,e.lineStart+s.text.length)])}}else if(this.rows){let n=[];M(e,s.text,s.pos,n,e.lineStart),this.rows.push(e.elt("TableRow",e.lineStart+s.pos,e.lineStart+s.text.length,n))}return!1}fi