838eec30a8
- Implemented a new composable `useTheme` for managing theme state. - Added functions to read and write theme preference to local storage. - Applied theme styles to the DOM based on user preference. - Introduced a toggle function to switch between light and dark themes. refactor: enhance copilot plugin functionality - Improved request handling with sequence and document versioning. - Refactored ghost text handling to improve clarity and efficiency. - Updated markdown insertion logic to handle parsed content more robustly. - Enhanced error handling and logging for better debugging. style: update global styles for light and dark themes - Defined CSS variables for light and dark themes to streamline styling. - Improved overall styling consistency and responsiveness. - Added transitions for smoother theme changes and interactions.
32 lines
19 KiB
JavaScript
32 lines
19 KiB
JavaScript
import{z as G}from"./vendor-zwitch-C2o2j-tx.js";import{l as Q}from"./vendor-longest-streak-CtXnX3Xp.js";import{c as C}from"./vendor-micromark-util-classify-character-Bc1Mydac.js";import{v as U}from"./vendor-unist-util-visit-8PRsQcuP.js";import{t as B}from"./vendor-mdast-util-to-string-C_aolqmU.js";import{E as D}from"./vendor-unist-util-visit-parents-BHoKBdZX.js";import{p as H}from"./vendor-mdast-util-phrasing-4oVbNLC3.js";import{d as Z}from"./vendor-micromark-util-decode-string-fHsnqYdj.js";const K={}.hasOwnProperty;function L(n,t){let e=-1,r;if(t.extensions)for(;++e<t.extensions.length;)L(n,t.extensions[e]);for(r in t)if(K.call(t,r))switch(r){case"extensions":break;case"unsafe":{A(n[r],t[r]);break}case"join":{A(n[r],t[r]);break}case"handlers":{W(n[r],t[r]);break}default:n.options[r]=t[r]}return n}function A(n,t){t&&n.push(...t)}function W(n,t){t&&Object.assign(n,t)}function X(n,t,e,r){const c=e.enter("blockquote"),l=e.createTracker(r);l.move("> "),l.shift(2);const o=e.indentLines(e.containerFlow(n,l.current()),J);return c(),o}function J(n,t,e){return">"+(e?"":" ")+n}function S(n,t){return I(n,t.inConstruct,!0)&&!I(n,t.notInConstruct,!1)}function I(n,t,e){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return e;let r=-1;for(;++r<t.length;)if(n.includes(t[r]))return!0;return!1}function _(n,t,e,r){let c=-1;for(;++c<e.unsafe.length;)if(e.unsafe[c].character===`
|
|
`&&S(e.stack,e.unsafe[c]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
`}function v(n,t){return!!(t.options.fences===!1&&n.value&&!n.lang&&/[^ \r\n]/.test(n.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(n.value))}function N(n){const t=n.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function V(n,t,e,r){const c=N(e),l=n.value||"",o=c==="`"?"GraveAccent":"Tilde";if(v(n,e)){const f=e.enter("codeIndented"),h=e.indentLines(l,Y);return f(),h}const s=e.createTracker(r),i=c.repeat(Math.max(Q(l,c)+1,3)),a=e.enter("codeFenced");let u=s.move(i);if(n.lang){const f=e.enter(`codeFencedLang${o}`);u+=s.move(e.safe(n.lang,{before:u,after:" ",encode:["`"],...s.current()})),f()}if(n.lang&&n.meta){const f=e.enter(`codeFencedMeta${o}`);u+=s.move(" "),u+=s.move(e.safe(n.meta,{before:u,after:`
|
|
`,encode:["`"],...s.current()})),f()}return u+=s.move(`
|
|
`),l&&(u+=s.move(l+`
|
|
`)),u+=s.move(i),a(),u}function Y(n,t,e){return(e?"":" ")+n}function x(n){const t=n.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function ee(n,t,e,r){const c=x(e),l=c==='"'?"Quote":"Apostrophe",o=e.enter("definition");let s=e.enter("label");const i=e.createTracker(r);let a=i.move("[");return a+=i.move(e.safe(e.associationId(n),{before:a,after:"]",...i.current()})),a+=i.move("]: "),s(),!n.url||/[\0- \u007F]/.test(n.url)?(s=e.enter("destinationLiteral"),a+=i.move("<"),a+=i.move(e.safe(n.url,{before:a,after:">",...i.current()})),a+=i.move(">")):(s=e.enter("destinationRaw"),a+=i.move(e.safe(n.url,{before:a,after:n.title?" ":`
|
|
`,...i.current()}))),s(),n.title&&(s=e.enter(`title${l}`),a+=i.move(" "+c),a+=i.move(e.safe(n.title,{before:a,after:c,...i.current()})),a+=i.move(c),s()),o(),a}function ne(n){const t=n.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function m(n){return"&#x"+n.toString(16).toUpperCase()+";"}function b(n,t,e){const r=C(n),c=C(t);return r===void 0?c===void 0?e==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:c===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?c===void 0?{inside:!1,outside:!1}:c===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:c===void 0?{inside:!1,outside:!1}:c===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}F.peek=te;function F(n,t,e,r){const c=ne(e),l=e.enter("emphasis"),o=e.createTracker(r),s=o.move(c);let i=o.move(e.containerPhrasing(n,{after:c,before:s,...o.current()}));const a=i.charCodeAt(0),u=b(r.before.charCodeAt(r.before.length-1),a,c);u.inside&&(i=m(a)+i.slice(1));const f=i.charCodeAt(i.length-1),h=b(r.after.charCodeAt(0),f,c);h.inside&&(i=i.slice(0,-1)+m(f));const d=o.move(c);return l(),e.attentionEncodeSurroundingInfo={after:h.outside,before:u.outside},s+i+d}function te(n,t,e){return e.options.emphasis||"*"}function P(n,t){let e=!1;return U(n,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return e=!0,D}),!!((!n.depth||n.depth<3)&&B(n)&&(t.options.setext||e))}function re(n,t,e,r){const c=Math.max(Math.min(6,n.depth||1),1),l=e.createTracker(r);if(P(n,e)){const u=e.enter("headingSetext"),f=e.enter("phrasing"),h=e.containerPhrasing(n,{...l.current(),before:`
|
|
`,after:`
|
|
`});return f(),u(),h+`
|
|
`+(c===1?"=":"-").repeat(h.length-(Math.max(h.lastIndexOf("\r"),h.lastIndexOf(`
|
|
`))+1))}const o="#".repeat(c),s=e.enter("headingAtx"),i=e.enter("phrasing");l.move(o+" ");let a=e.containerPhrasing(n,{before:"# ",after:`
|
|
`,...l.current()});return/^[\t ]/.test(a)&&(a=m(a.charCodeAt(0))+a.slice(1)),a=a?o+" "+a:o,e.options.closeAtx&&(a+=" "+o),i(),s(),a}T.peek=ie;function T(n){return n.value||""}function ie(){return"<"}E.peek=oe;function E(n,t,e,r){const c=x(e),l=c==='"'?"Quote":"Apostrophe",o=e.enter("image");let s=e.enter("label");const i=e.createTracker(r);let a=i.move("![");return a+=i.move(e.safe(n.alt,{before:a,after:"]",...i.current()})),a+=i.move("]("),s(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(s=e.enter("destinationLiteral"),a+=i.move("<"),a+=i.move(e.safe(n.url,{before:a,after:">",...i.current()})),a+=i.move(">")):(s=e.enter("destinationRaw"),a+=i.move(e.safe(n.url,{before:a,after:n.title?" ":")",...i.current()}))),s(),n.title&&(s=e.enter(`title${l}`),a+=i.move(" "+c),a+=i.move(e.safe(n.title,{before:a,after:c,...i.current()})),a+=i.move(c),s()),a+=i.move(")"),o(),a}function oe(){return"!"}R.peek=ce;function R(n,t,e,r){const c=n.referenceType,l=e.enter("imageReference");let o=e.enter("label");const s=e.createTracker(r);let i=s.move("![");const a=e.safe(n.alt,{before:i,after:"]",...s.current()});i+=s.move(a+"]["),o();const u=e.stack;e.stack=[],o=e.enter("reference");const f=e.safe(e.associationId(n),{before:i,after:"]",...s.current()});return o(),e.stack=u,l(),c==="full"||!a||a!==f?i+=s.move(f+"]"):c==="shortcut"?i=i.slice(0,-1):i+=s.move("]"),i}function ce(){return"!"}z.peek=ae;function z(n,t,e){let r=n.value||"",c="`",l=-1;for(;new RegExp("(^|[^`])"+c+"([^`]|$)").test(r);)c+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++l<e.unsafe.length;){const o=e.unsafe[l],s=e.compilePattern(o);let i;if(o.atBreak)for(;i=s.exec(r);){let a=i.index;r.charCodeAt(a)===10&&r.charCodeAt(a-1)===13&&a--,r=r.slice(0,a)+" "+r.slice(i.index+1)}}return c+r+c}function ae(){return"`"}function $(n,t){const e=B(n);return!!(!t.options.resourceLink&&n.url&&!n.title&&n.children&&n.children.length===1&&n.children[0].type==="text"&&(e===n.url||"mailto:"+e===n.url)&&/^[a-z][a-z+.-]+:/i.test(n.url)&&!/[\0- <>\u007F]/.test(n.url))}j.peek=se;function j(n,t,e,r){const c=x(e),l=c==='"'?"Quote":"Apostrophe",o=e.createTracker(r);let s,i;if($(n,e)){const u=e.stack;e.stack=[],s=e.enter("autolink");let f=o.move("<");return f+=o.move(e.containerPhrasing(n,{before:f,after:">",...o.current()})),f+=o.move(">"),s(),e.stack=u,f}s=e.enter("link"),i=e.enter("label");let a=o.move("[");return a+=o.move(e.containerPhrasing(n,{before:a,after:"](",...o.current()})),a+=o.move("]("),i(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(i=e.enter("destinationLiteral"),a+=o.move("<"),a+=o.move(e.safe(n.url,{before:a,after:">",...o.current()})),a+=o.move(">")):(i=e.enter("destinationRaw"),a+=o.move(e.safe(n.url,{before:a,after:n.title?" ":")",...o.current()}))),i(),n.title&&(i=e.enter(`title${l}`),a+=o.move(" "+c),a+=o.move(e.safe(n.title,{before:a,after:c,...o.current()})),a+=o.move(c),i()),a+=o.move(")"),s(),a}function se(n,t,e){return $(n,e)?"<":"["}M.peek=le;function M(n,t,e,r){const c=n.referenceType,l=e.enter("linkReference");let o=e.enter("label");const s=e.createTracker(r);let i=s.move("[");const a=e.containerPhrasing(n,{before:i,after:"]",...s.current()});i+=s.move(a+"]["),o();const u=e.stack;e.stack=[],o=e.enter("reference");const f=e.safe(e.associationId(n),{before:i,after:"]",...s.current()});return o(),e.stack=u,l(),c==="full"||!a||a!==f?i+=s.move(f+"]"):c==="shortcut"?i=i.slice(0,-1):i+=s.move("]"),i}function le(){return"["}function w(n){const t=n.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function ue(n){const t=w(n),e=n.options.bulletOther;if(!e)return t==="*"?"-":"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(e===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+e+"`) to be different");return e}function fe(n){const t=n.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function O(n){const t=n.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function he(n,t,e,r){const c=e.enter("list"),l=e.bulletCurrent;let o=n.ordered?fe(e):w(e);const s=n.ordered?o==="."?")":".":ue(e);let i=t&&e.bulletLastUsed?o===e.bulletLastUsed:!1;if(!n.ordered){const u=n.children?n.children[0]:void 0;if((o==="*"||o==="-")&&u&&(!u.children||!u.children[0])&&e.stack[e.stack.length-1]==="list"&&e.stack[e.stack.length-2]==="listItem"&&e.stack[e.stack.length-3]==="list"&&e.stack[e.stack.length-4]==="listItem"&&e.indexStack[e.indexStack.length-1]===0&&e.indexStack[e.indexStack.length-2]===0&&e.indexStack[e.indexStack.length-3]===0&&(i=!0),O(e)===o&&u){let f=-1;for(;++f<n.children.length;){const h=n.children[f];if(h&&h.type==="listItem"&&h.children&&h.children[0]&&h.children[0].type==="thematicBreak"){i=!0;break}}}}i&&(o=s),e.bulletCurrent=o;const a=e.containerFlow(n,r);return e.bulletLastUsed=o,e.bulletCurrent=l,c(),a}function de(n){const t=n.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function pe(n,t,e,r){const c=de(e);let l=e.bulletCurrent||w(e);t&&t.type==="list"&&t.ordered&&(l=(typeof t.start=="number"&&t.start>-1?t.start:1)+(e.options.incrementListMarker===!1?0:t.children.indexOf(n))+l);let o=l.length+1;(c==="tab"||c==="mixed"&&(t&&t.type==="list"&&t.spread||n.spread))&&(o=Math.ceil(o/4)*4);const s=e.createTracker(r);s.move(l+" ".repeat(o-l.length)),s.shift(o);const i=e.enter("listItem"),a=e.indentLines(e.containerFlow(n,s.current()),u);return i(),a;function u(f,h,d){return h?(d?"":" ".repeat(o))+f:(d?l:l+" ".repeat(o-l.length))+f}}function me(n,t,e,r){const c=e.enter("paragraph"),l=e.enter("phrasing"),o=e.containerPhrasing(n,r);return l(),c(),o}function ke(n,t,e,r){return(n.children.some(function(o){return H(o)})?e.containerPhrasing:e.containerFlow).call(e,n,r)}function ge(n){const t=n.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}q.peek=be;function q(n,t,e,r){const c=ge(e),l=e.enter("strong"),o=e.createTracker(r),s=o.move(c+c);let i=o.move(e.containerPhrasing(n,{after:c,before:s,...o.current()}));const a=i.charCodeAt(0),u=b(r.before.charCodeAt(r.before.length-1),a,c);u.inside&&(i=m(a)+i.slice(1));const f=i.charCodeAt(i.length-1),h=b(r.after.charCodeAt(0),f,c);h.inside&&(i=i.slice(0,-1)+m(f));const d=o.move(c+c);return l(),e.attentionEncodeSurroundingInfo={after:h.outside,before:u.outside},s+i+d}function be(n,t,e){return e.options.strong||"*"}function ve(n,t,e,r){return e.safe(n.value,r)}function xe(n){const t=n.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function we(n,t,e){const r=(O(e)+(e.options.ruleSpaces?" ":"")).repeat(xe(e));return e.options.ruleSpaces?r.slice(0,-1):r}const Ce={blockquote:X,break:_,code:V,definition:ee,emphasis:F,hardBreak:_,heading:re,html:T,image:E,imageReference:R,inlineCode:z,link:j,linkReference:M,list:he,listItem:pe,paragraph:me,root:ke,strong:q,text:ve,thematicBreak:we},Ae=[Ie];function Ie(n,t,e,r){if(t.type==="code"&&v(t,r)&&(n.type==="list"||n.type===t.type&&v(n,r)))return!1;if("spread"in e&&typeof e.spread=="boolean")return n.type==="paragraph"&&(n.type===t.type||t.type==="definition"||t.type==="heading"&&P(t,r))?void 0:e.spread?1:0}const g=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],_e=[{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:`
|
|
`,inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:g},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:`(?:[\r
|
|
]|$)`},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:g},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ \r
|
|
*])`},{character:"*",inConstruct:"phrasing",notInConstruct:g},{atBreak:!0,character:"+",after:`(?:[ \r
|
|
])`},{atBreak:!0,character:"-",after:`(?:[ \r
|
|
-])`},{atBreak:!0,before:"\\d+",character:".",after:`(?:[ \r
|
|
]|$)`},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:g},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:g},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:g},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:g},{atBreak:!0,character:"~"}];function ye(n){return n.label||!n.identifier?n.label||"":Z(n.identifier)}function Be(n){if(!n._compiled){const t=(n.atBreak?"[\\r\\n][\\t ]*":"")+(n.before?"(?:"+n.before+")":"");n._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(n.character)?"\\":"")+n.character+(n.after?"(?:"+n.after+")":""),"g")}return n._compiled}function Le(n,t,e){const r=t.indexStack,c=n.children||[],l=[];let o=-1,s=e.before,i;r.push(-1);let a=t.createTracker(e);for(;++o<c.length;){const u=c[o];let f;if(r[r.length-1]=o,o+1<c.length){let p=t.handle.handlers[c[o+1].type];p&&p.peek&&(p=p.peek),f=p?p(c[o+1],n,t,{before:"",after:"",...a.current()}).charAt(0):""}else f=e.after;l.length>0&&(s==="\r"||s===`
|
|
`)&&u.type==="html"&&(l[l.length-1]=l[l.length-1].replace(/(\r?\n|\r)$/," "),s=" ",a=t.createTracker(e),a.move(l.join("")));let h=t.handle(u,n,t,{...a.current(),after:f,before:s});i&&i===h.slice(0,1)&&(h=m(i.charCodeAt(0))+h.slice(1));const d=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,i=void 0,d&&(l.length>0&&d.before&&s===l[l.length-1].slice(-1)&&(l[l.length-1]=l[l.length-1].slice(0,-1)+m(s.charCodeAt(0))),d.after&&(i=f)),a.move(h),l.push(h),s=h.slice(-1)}return r.pop(),l.join("")}function Se(n,t,e){const r=t.indexStack,c=n.children||[],l=t.createTracker(e),o=[];let s=-1;for(r.push(-1);++s<c.length;){const i=c[s];r[r.length-1]=s,o.push(l.move(t.handle(i,n,t,{before:`
|
|
`,after:`
|
|
`,...l.current()}))),i.type!=="list"&&(t.bulletLastUsed=void 0),s<c.length-1&&o.push(l.move(Fe(i,c[s+1],n,t)))}return r.pop(),o.join("")}function Fe(n,t,e,r){let c=r.join.length;for(;c--;){const l=r.join[c](n,t,e,r);if(l===!0||l===1)break;if(typeof l=="number")return`
|
|
`.repeat(1+l);if(l===!1)return`
|
|
|
|
<!---->
|
|
|
|
`}return`
|
|
|
|
`}const Pe=/\r?\n|\r/g;function Te(n,t){const e=[];let r=0,c=0,l;for(;l=Pe.exec(n);)o(n.slice(r,l.index)),e.push(l[0]),r=l.index+l[0].length,c++;return o(n.slice(r)),e.join("");function o(s){e.push(t(s,c,!s))}}function Ee(n,t,e){const r=(e.before||"")+(t||"")+(e.after||""),c=[],l=[],o={};let s=-1;for(;++s<n.unsafe.length;){const u=n.unsafe[s];if(!S(n.stack,u))continue;const f=n.compilePattern(u);let h;for(;h=f.exec(r);){const d="before"in u||!!u.atBreak,p="after"in u,k=h.index+(d?h[1].length:0);c.includes(k)?(o[k].before&&!d&&(o[k].before=!1),o[k].after&&!p&&(o[k].after=!1)):(c.push(k),o[k]={before:d,after:p})}}c.sort(Re);let i=e.before?e.before.length:0;const a=r.length-(e.after?e.after.length:0);for(s=-1;++s<c.length;){const u=c[s];u<i||u>=a||u+1<a&&c[s+1]===u+1&&o[u].after&&!o[u+1].before&&!o[u+1].after||c[s-1]===u-1&&o[u].before&&!o[u-1].before&&!o[u-1].after||(i!==u&&l.push(y(r.slice(i,u),"\\")),i=u,/[!-/:-@[-`{-~]/.test(r.charAt(u))&&(!e.encode||!e.encode.includes(r.charAt(u)))?l.push("\\"):(l.push(m(r.charCodeAt(u))),i++))}return l.push(y(r.slice(i,a),e.after)),l.join("")}function Re(n,t){return n-t}function y(n,t){const e=/\\(?=[!-/:-@[-`{-~])/g,r=[],c=[],l=n+t;let o=-1,s=0,i;for(;i=e.exec(l);)r.push(i.index);for(;++o<r.length;)s!==r[o]&&c.push(n.slice(s,r[o])),c.push("\\"),s=r[o];return c.push(n.slice(s)),c.join("")}function ze(n){const t=n||{},e=t.now||{};let r=t.lineShift||0,c=e.line||1,l=e.column||1;return{move:i,current:o,shift:s};function o(){return{now:{line:c,column:l},lineShift:r}}function s(a){r+=a}function i(a){const u=a||"",f=u.split(/\r?\n|\r/g),h=f[f.length-1];return c+=f.length-1,l=f.length===1?l+h.length:1+h.length+r,u}}function Je(n,t){const e=t||{},r={associationId:ye,containerPhrasing:Oe,containerFlow:qe,createTracker:ze,compilePattern:Be,enter:l,handlers:{...Ce},handle:void 0,indentLines:Te,indexStack:[],join:[...Ae],options:{},safe:Ge,stack:[],unsafe:[..._e]};L(r,e),r.options.tightDefinitions&&r.join.push(Me),r.handle=G("type",{invalid:$e,unknown:je,handlers:r.handlers});let c=r.handle(n,void 0,r,{before:`
|
|
`,after:`
|
|
`,now:{line:1,column:1},lineShift:0});return c&&c.charCodeAt(c.length-1)!==10&&c.charCodeAt(c.length-1)!==13&&(c+=`
|
|
`),c;function l(o){return r.stack.push(o),s;function s(){r.stack.pop()}}}function $e(n){throw new Error("Cannot handle value `"+n+"`, expected node")}function je(n){const t=n;throw new Error("Cannot handle unknown node `"+t.type+"`")}function Me(n,t){if(n.type==="definition"&&n.type===t.type)return 0}function Oe(n,t){return Le(n,this,t)}function qe(n,t){return Se(n,this,t)}function Ge(n,t){return Ee(this,n,t)}export{Ce as h,Je as t};
|