UNPKG

ai-client-kit

Version:

一款 AI 集成套件,适配任意前端框架,兼容多种大模型、聊天面板、Function Calling、Agent、工作流等。

1 lines 1.47 MB
(function(wt,Xs){typeof exports=="object"&&typeof module<"u"?Xs(exports):typeof define=="function"&&define.amd?define(["exports"],Xs):(wt=typeof globalThis<"u"?globalThis:wt||self,Xs(wt.AIClientKit={}))})(this,(function(wt){"use strict";function Xs(t){if(t)throw t}function gl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Kh,$D;function Rk(){if($D)return Kh;$D=1;var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=function(l){return typeof Array.isArray=="function"?Array.isArray(l):e.call(l)==="[object Array]"},s=function(l){if(!l||e.call(l)!=="[object Object]")return!1;var c=t.call(l,"constructor"),p=l.constructor&&l.constructor.prototype&&t.call(l.constructor.prototype,"isPrototypeOf");if(l.constructor&&!c&&!p)return!1;var f;for(f in l);return typeof f>"u"||t.call(l,f)},a=function(l,c){r&&c.name==="__proto__"?r(l,c.name,{enumerable:!0,configurable:!0,value:c.newValue,writable:!0}):l[c.name]=c.newValue},o=function(l,c){if(c==="__proto__")if(t.call(l,c)){if(n)return n(l,c).value}else return;return l[c]};return Kh=function u(){var l,c,p,f,h,m,g=arguments[0],y=1,D=arguments.length,d=!1;for(typeof g=="boolean"&&(d=g,g=arguments[1]||{},y=2),(g==null||typeof g!="object"&&typeof g!="function")&&(g={});y<D;++y)if(l=arguments[y],l!=null)for(c in l)p=o(g,c),f=o(l,c),g!==f&&(d&&f&&(s(f)||(h=i(f)))?(h?(h=!1,m=p&&i(p)?p:[]):m=p&&s(p)?p:{},a(g,{name:c,newValue:u(d,m,f)})):typeof f<"u"&&a(g,{name:c,newValue:f}));return g},Kh}var jk=Rk();const Yh=gl(jk);function ele(){}function Xh(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function qk(){const t=[],e={run:r,use:n};return e;function r(...i){let s=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);o(null,...i);function o(u,...l){const c=t[++s];let p=-1;if(u){a(u);return}for(;++p<i.length;)(l[p]===null||l[p]===void 0)&&(l[p]=i[p]);i=l,c?Uk(c,o)(...l):a(null,...l)}}function n(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return t.push(i),e}}function Uk(t,e){let r;return n;function n(...a){const o=t.length>a.length;let u;o&&a.push(i);try{u=t.apply(this,a)}catch(l){const c=l;if(o&&r)throw c;return i(c)}o||(u&&u.then&&typeof u.then=="function"?u.then(s,i):u instanceof Error?i(u):s(u))}function i(a,...o){r||(r=!0,e(a,...o))}function s(a){i(null,a)}}function mo(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?ID(t.position):"start"in t||"end"in t?ID(t):"line"in t||"column"in t?Qh(t):""}function Qh(t){return OD(t&&t.line)+":"+OD(t&&t.column)}function ID(t){return Qh(t&&t.start)+"-"+Qh(t&&t.end)}function OD(t){return t&&typeof t=="number"?t:1}class yr extends Error{constructor(e,r,n){super(),typeof r=="string"&&(n=r,r=void 0);let i="",s={},a=!1;if(r&&("line"in r&&"column"in r?s={place:r}:"start"in r&&"end"in r?s={place:r}:"type"in r?s={ancestors:[r],place:r.position}:s={...r}),typeof e=="string"?i=e:!s.cause&&e&&(a=!0,i=e.message,s.cause=e),!s.ruleId&&!s.source&&typeof n=="string"){const u=n.indexOf(":");u===-1?s.ruleId=n:(s.source=n.slice(0,u),s.ruleId=n.slice(u+1))}if(!s.place&&s.ancestors&&s.ancestors){const u=s.ancestors[s.ancestors.length-1];u&&(s.place=u.position)}const o=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=o?o.line:void 0,this.name=mo(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}yr.prototype.file="",yr.prototype.name="",yr.prototype.reason="",yr.prototype.message="",yr.prototype.stack="",yr.prototype.column=void 0,yr.prototype.line=void 0,yr.prototype.ancestors=void 0,yr.prototype.cause=void 0,yr.prototype.fatal=void 0,yr.prototype.place=void 0,yr.prototype.ruleId=void 0,yr.prototype.source=void 0;const Cn={basename:zk,dirname:Vk,extname:Hk,join:Wk,sep:"/"};function zk(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');go(t);let r=0,n=-1,i=t.length,s;if(e===void 0||e.length===0||e.length>t.length){for(;i--;)if(t.codePointAt(i)===47){if(s){r=i+1;break}}else n<0&&(s=!0,n=i+1);return n<0?"":t.slice(r,n)}if(e===t)return"";let a=-1,o=e.length-1;for(;i--;)if(t.codePointAt(i)===47){if(s){r=i+1;break}}else a<0&&(s=!0,a=i+1),o>-1&&(t.codePointAt(i)===e.codePointAt(o--)?o<0&&(n=i):(o=-1,n=a));return r===n?n=a:n<0&&(n=t.length),t.slice(r,n)}function Vk(t){if(go(t),t.length===0)return".";let e=-1,r=t.length,n;for(;--r;)if(t.codePointAt(r)===47){if(n){e=r;break}}else n||(n=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function Hk(t){go(t);let e=t.length,r=-1,n=0,i=-1,s=0,a;for(;e--;){const o=t.codePointAt(e);if(o===47){if(a){n=e+1;break}continue}r<0&&(a=!0,r=e+1),o===46?i<0?i=e:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||r<0||s===0||s===1&&i===r-1&&i===n+1?"":t.slice(i,r)}function Wk(...t){let e=-1,r;for(;++e<t.length;)go(t[e]),t[e]&&(r=r===void 0?t[e]:r+"/"+t[e]);return r===void 0?".":Gk(r)}function Gk(t){go(t);const e=t.codePointAt(0)===47;let r=Jk(t,!e);return r.length===0&&!e&&(r="."),r.length>0&&t.codePointAt(t.length-1)===47&&(r+="/"),e?"/"+r:r}function Jk(t,e){let r="",n=0,i=-1,s=0,a=-1,o,u;for(;++a<=t.length;){if(a<t.length)o=t.codePointAt(a);else{if(o===47)break;o=47}if(o===47){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(r.length<2||n!==2||r.codePointAt(r.length-1)!==46||r.codePointAt(r.length-2)!==46){if(r.length>2){if(u=r.lastIndexOf("/"),u!==r.length-1){u<0?(r="",n=0):(r=r.slice(0,u),n=r.length-1-r.lastIndexOf("/")),i=a,s=0;continue}}else if(r.length>0){r="",n=0,i=a,s=0;continue}}e&&(r=r.length>0?r+"/..":"..",n=2)}else r.length>0?r+="/"+t.slice(i+1,a):r=t.slice(i+1,a),n=a-i-1;i=a,s=0}else o===46&&s>-1?s++:s=-1}return r}function go(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const Kk={cwd:Yk};function Yk(){return"/"}function Zh(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function Xk(t){if(typeof t=="string")t=new URL(t);else if(!Zh(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return Qk(t)}function Qk(t){if(t.hostname!==""){const n=new TypeError('File URL host must be "localhost" or empty on darwin');throw n.code="ERR_INVALID_FILE_URL_HOST",n}const e=t.pathname;let r=-1;for(;++r<e.length;)if(e.codePointAt(r)===37&&e.codePointAt(r+1)===50){const n=e.codePointAt(r+2);if(n===70||n===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(e)}const ef=["history","path","basename","stem","extname","dirname"];class Zk{constructor(e){let r;e?Zh(e)?r={path:e}:typeof e=="string"||e3(e)?r={value:e}:r=e:r={},this.cwd="cwd"in r?"":Kk.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<ef.length;){const s=ef[n];s in r&&r[s]!==void 0&&r[s]!==null&&(this[s]=s==="history"?[...r[s]]:r[s])}let i;for(i in r)ef.includes(i)||(this[i]=r[i])}get basename(){return typeof this.path=="string"?Cn.basename(this.path):void 0}set basename(e){rf(e,"basename"),tf(e,"basename"),this.path=Cn.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Cn.dirname(this.path):void 0}set dirname(e){LD(this.basename,"dirname"),this.path=Cn.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Cn.extname(this.path):void 0}set extname(e){if(tf(e,"extname"),LD(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Cn.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Zh(e)&&(e=Xk(e)),rf(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Cn.basename(this.path,this.extname):void 0}set stem(e){rf(e,"stem"),tf(e,"stem"),this.path=Cn.join(this.dirname||"",e+(this.extname||""))}fail(e,r,n){const i=this.message(e,r,n);throw i.fatal=!0,i}info(e,r,n){const i=this.message(e,r,n);return i.fatal=void 0,i}message(e,r,n){const i=new yr(e,r,n);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function tf(t,e){if(t&&t.includes(Cn.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Cn.sep+"`")}function rf(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function LD(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function e3(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const t3=(function(t){const n=this.constructor.prototype,i=n[t],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,n),s}),r3={}.hasOwnProperty;class nf extends t3{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=qk()}copy(){const e=new nf;let r=-1;for(;++r<this.attachers.length;){const n=this.attachers[r];e.use(...n)}return e.data(Yh(!0,{},this.namespace)),e}data(e,r){return typeof e=="string"?arguments.length===2?(of("data",this.frozen),this.namespace[e]=r,this):r3.call(this.namespace,e)&&this.namespace[e]||void 0:e?(of("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[r,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);const i=r.call(e,...n);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const r=yl(e),n=this.parser||this.Parser;return sf("parse",n),n(String(r),r)}process(e,r){const n=this;return this.freeze(),sf("process",this.parser||this.Parser),af("process",this.compiler||this.Compiler),r?i(void 0,r):new Promise(i);function i(s,a){const o=yl(e),u=n.parse(o);n.run(u,o,function(c,p,f){if(c||!p||!f)return l(c);const h=p,m=n.stringify(h,f);s3(m)?f.value=m:f.result=m,l(c,f)});function l(c,p){c||!p?a(c):s?s(p):r(void 0,p)}}}processSync(e){let r=!1,n;return this.freeze(),sf("processSync",this.parser||this.Parser),af("processSync",this.compiler||this.Compiler),this.process(e,i),RD("processSync","process",r),n;function i(s,a){r=!0,Xs(s),n=a}}run(e,r,n){MD(e),this.freeze();const i=this.transformers;return!n&&typeof r=="function"&&(n=r,r=void 0),n?s(void 0,n):new Promise(s);function s(a,o){const u=yl(r);i.run(e,u,l);function l(c,p,f){const h=p||e;c?o(c):a?a(h):n(void 0,h,f)}}}runSync(e,r){let n=!1,i;return this.run(e,r,s),RD("runSync","run",n),i;function s(a,o){Xs(a),i=o,n=!0}}stringify(e,r){this.freeze();const n=yl(r),i=this.compiler||this.Compiler;return af("stringify",i),MD(e),i(e,n)}use(e,...r){const n=this.attachers,i=this.namespace;if(of("use",this.frozen),e!=null)if(typeof e=="function")u(e,r);else if(typeof e=="object")Array.isArray(e)?o(e):a(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function s(l){if(typeof l=="function")u(l,[]);else if(typeof l=="object")if(Array.isArray(l)){const[c,...p]=l;u(c,p)}else a(l);else throw new TypeError("Expected usable value, not `"+l+"`")}function a(l){if(!("plugins"in l)&&!("settings"in l))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(l.plugins),l.settings&&(i.settings=Yh(!0,i.settings,l.settings))}function o(l){let c=-1;if(l!=null)if(Array.isArray(l))for(;++c<l.length;){const p=l[c];s(p)}else throw new TypeError("Expected a list of plugins, not `"+l+"`")}function u(l,c){let p=-1,f=-1;for(;++p<n.length;)if(n[p][0]===l){f=p;break}if(f===-1)n.push([l,...c]);else if(c.length>0){let[h,...m]=c;const g=n[f][1];Xh(g)&&Xh(h)&&(h=Yh(!0,g,h)),n[f]=[l,h,...m]}}}}const n3=new nf().freeze();function sf(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function af(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function of(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function MD(t){if(!Xh(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function RD(t,e,r){if(!r)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function yl(t){return i3(t)?t:new Zk(t)}function i3(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function s3(t){return typeof t=="string"||a3(t)}function a3(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const o3={};function uf(t,e){const r=o3,n=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,i=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return jD(t,n,i)}function jD(t,e,r){if(u3(t)){if("value"in t)return t.type==="html"&&!r?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return qD(t.children,e,r)}return Array.isArray(t)?qD(t,e,r):""}function qD(t,e,r){const n=[];let i=-1;for(;++i<t.length;)n[i]=jD(t[i],e,r);return n.join("")}function u3(t){return!!(t&&typeof t=="object")}const UD=document.createElement("i");function lf(t){const e="&"+t+";";UD.innerHTML=e;const r=UD.textContent;return r.charCodeAt(r.length-1)===59&&t!=="semi"||r===e?!1:r}function Nr(t,e,r,n){const i=t.length;let s=0,a;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,r=r>0?r:0,n.length<1e4)a=Array.from(n),a.unshift(e,r),t.splice(...a);else for(r&&t.splice(e,r);s<n.length;)a=n.slice(s,s+1e4),a.unshift(e,0),t.splice(...a),s+=1e4,e+=1e4}function Hr(t,e){return t.length>0?(Nr(t,t.length,0,e),t):e}const zD={}.hasOwnProperty;function VD(t){const e={};let r=-1;for(;++r<t.length;)l3(e,t[r]);return e}function l3(t,e){let r;for(r in e){const i=(zD.call(t,r)?t[r]:void 0)||(t[r]={}),s=e[r];let a;if(s)for(a in s){zD.call(i,a)||(i[a]=[]);const o=s[a];c3(i[a],Array.isArray(o)?o:o?[o]:[])}}}function c3(t,e){let r=-1;const n=[];for(;++r<e.length;)(e[r].add==="after"?t:n).push(e[r]);Nr(t,0,0,n)}function HD(t,e){const r=Number.parseInt(t,e);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function on(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const rr=Fi(/[A-Za-z]/),Kt=Fi(/[\dA-Za-z]/),p3=Fi(/[#-'*+\--9=?A-Z^-~]/);function Dl(t){return t!==null&&(t<32||t===127)}const cf=Fi(/\d/),h3=Fi(/[\dA-Fa-f]/),f3=Fi(/[!-/:-@[-`{-~]/);function Se(t){return t!==null&&t<-2}function at(t){return t!==null&&(t<0||t===32)}function ze(t){return t===-2||t===-1||t===32}const El=Fi(new RegExp("\\p{P}|\\p{S}","u")),ns=Fi(/\s/);function Fi(t){return e;function e(r){return r!==null&&r>-1&&t.test(String.fromCharCode(r))}}function Qs(t){const e=[];let r=-1,n=0,i=0;for(;++r<t.length;){const s=t.charCodeAt(r);let a="";if(s===37&&Kt(t.charCodeAt(r+1))&&Kt(t.charCodeAt(r+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const o=t.charCodeAt(r+1);s<56320&&o>56319&&o<57344?(a=String.fromCharCode(s,o),i=1):a="�"}else a=String.fromCharCode(s);a&&(e.push(t.slice(n,r),encodeURIComponent(a)),n=r+i+1,a=""),i&&(r+=i,i=0)}return e.join("")+t.slice(n)}function Ke(t,e,r,n){const i=n?n-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(u){return ze(u)?(t.enter(r),o(u)):e(u)}function o(u){return ze(u)&&s++<i?(t.consume(u),o):(t.exit(r),e(u))}}const d3={tokenize:m3};function m3(t){const e=t.attempt(this.parser.constructs.contentInitial,n,i);let r;return e;function n(o){if(o===null){t.consume(o);return}return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),Ke(t,e,"linePrefix")}function i(o){return t.enter("paragraph"),s(o)}function s(o){const u=t.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=u),r=u,a(o)}function a(o){if(o===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(o);return}return Se(o)?(t.consume(o),t.exit("chunkText"),s):(t.consume(o),a)}}const g3={tokenize:y3},WD={tokenize:D3};function y3(t){const e=this,r=[];let n=0,i,s,a;return o;function o(x){if(n<r.length){const A=r[n];return e.containerState=A[1],t.attempt(A[0].continuation,u,l)(x)}return l(x)}function u(x){if(n++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&d();const A=e.events.length;let E=A,C;for(;E--;)if(e.events[E][0]==="exit"&&e.events[E][1].type==="chunkFlow"){C=e.events[E][1].end;break}D(n);let b=A;for(;b<e.events.length;)e.events[b][1].end={...C},b++;return Nr(e.events,E+1,0,e.events.slice(A)),e.events.length=b,l(x)}return o(x)}function l(x){if(n===r.length){if(!i)return f(x);if(i.currentConstruct&&i.currentConstruct.concrete)return m(x);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(WD,c,p)(x)}function c(x){return i&&d(),D(n),f(x)}function p(x){return e.parser.lazy[e.now().line]=n!==r.length,a=e.now().offset,m(x)}function f(x){return e.containerState={},t.attempt(WD,h,m)(x)}function h(x){return n++,r.push([e.currentConstruct,e.containerState]),f(x)}function m(x){if(x===null){i&&d(),D(0),t.consume(x);return}return i=i||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),g(x)}function g(x){if(x===null){y(t.exit("chunkFlow"),!0),D(0),t.consume(x);return}return Se(x)?(t.consume(x),y(t.exit("chunkFlow")),n=0,e.interrupt=void 0,o):(t.consume(x),g)}function y(x,A){const E=e.sliceStream(x);if(A&&E.push(null),x.previous=s,s&&(s.next=x),s=x,i.defineSkip(x.start),i.write(E),e.parser.lazy[x.start.line]){let C=i.events.length;for(;C--;)if(i.events[C][1].start.offset<a&&(!i.events[C][1].end||i.events[C][1].end.offset>a))return;const b=e.events.length;let w=b,P,F;for(;w--;)if(e.events[w][0]==="exit"&&e.events[w][1].type==="chunkFlow"){if(P){F=e.events[w][1].end;break}P=!0}for(D(n),C=b;C<e.events.length;)e.events[C][1].end={...F},C++;Nr(e.events,w+1,0,e.events.slice(b)),e.events.length=C}}function D(x){let A=r.length;for(;A-- >x;){const E=r[A];e.containerState=E[1],E[0].exit.call(e,t)}r.length=x}function d(){i.write([null]),s=void 0,i=void 0,e.containerState._closeFlow=void 0}}function D3(t,e,r){return Ke(t,t.attempt(this.parser.constructs.document,e,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Zs(t){if(t===null||at(t)||ns(t))return 1;if(El(t))return 2}function xl(t,e,r){const n=[];let i=-1;for(;++i<t.length;){const s=t[i].resolveAll;s&&!n.includes(s)&&(e=s(e,r),n.push(s))}return e}const pf={name:"attention",resolveAll:E3,tokenize:x3};function E3(t,e){let r=-1,n,i,s,a,o,u,l,c;for(;++r<t.length;)if(t[r][0]==="enter"&&t[r][1].type==="attentionSequence"&&t[r][1]._close){for(n=r;n--;)if(t[n][0]==="exit"&&t[n][1].type==="attentionSequence"&&t[n][1]._open&&e.sliceSerialize(t[n][1]).charCodeAt(0)===e.sliceSerialize(t[r][1]).charCodeAt(0)){if((t[n][1]._close||t[r][1]._open)&&(t[r][1].end.offset-t[r][1].start.offset)%3&&!((t[n][1].end.offset-t[n][1].start.offset+t[r][1].end.offset-t[r][1].start.offset)%3))continue;u=t[n][1].end.offset-t[n][1].start.offset>1&&t[r][1].end.offset-t[r][1].start.offset>1?2:1;const p={...t[n][1].end},f={...t[r][1].start};GD(p,-u),GD(f,u),a={type:u>1?"strongSequence":"emphasisSequence",start:p,end:{...t[n][1].end}},o={type:u>1?"strongSequence":"emphasisSequence",start:{...t[r][1].start},end:f},s={type:u>1?"strongText":"emphasisText",start:{...t[n][1].end},end:{...t[r][1].start}},i={type:u>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},t[n][1].end={...a.start},t[r][1].start={...o.end},l=[],t[n][1].end.offset-t[n][1].start.offset&&(l=Hr(l,[["enter",t[n][1],e],["exit",t[n][1],e]])),l=Hr(l,[["enter",i,e],["enter",a,e],["exit",a,e],["enter",s,e]]),l=Hr(l,xl(e.parser.constructs.insideSpan.null,t.slice(n+1,r),e)),l=Hr(l,[["exit",s,e],["enter",o,e],["exit",o,e],["exit",i,e]]),t[r][1].end.offset-t[r][1].start.offset?(c=2,l=Hr(l,[["enter",t[r][1],e],["exit",t[r][1],e]])):c=0,Nr(t,n-1,r-n+3,l),r=n+l.length-c-2;break}}for(r=-1;++r<t.length;)t[r][1].type==="attentionSequence"&&(t[r][1].type="data");return t}function x3(t,e){const r=this.parser.constructs.attentionMarkers.null,n=this.previous,i=Zs(n);let s;return a;function a(u){return s=u,t.enter("attentionSequence"),o(u)}function o(u){if(u===s)return t.consume(u),o;const l=t.exit("attentionSequence"),c=Zs(u),p=!c||c===2&&i||r.includes(u),f=!i||i===2&&c||r.includes(n);return l._open=!!(s===42?p:p&&(i||!f)),l._close=!!(s===42?f:f&&(c||!p)),e(u)}}function GD(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const C3={name:"autolink",tokenize:A3};function A3(t,e,r){let n=0;return i;function i(h){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(h),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),s}function s(h){return rr(h)?(t.consume(h),a):h===64?r(h):l(h)}function a(h){return h===43||h===45||h===46||Kt(h)?(n=1,o(h)):l(h)}function o(h){return h===58?(t.consume(h),n=0,u):(h===43||h===45||h===46||Kt(h))&&n++<32?(t.consume(h),o):(n=0,l(h))}function u(h){return h===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(h),t.exit("autolinkMarker"),t.exit("autolink"),e):h===null||h===32||h===60||Dl(h)?r(h):(t.consume(h),u)}function l(h){return h===64?(t.consume(h),c):p3(h)?(t.consume(h),l):r(h)}function c(h){return Kt(h)?p(h):r(h)}function p(h){return h===46?(t.consume(h),n=0,c):h===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(h),t.exit("autolinkMarker"),t.exit("autolink"),e):f(h)}function f(h){if((h===45||Kt(h))&&n++<63){const m=h===45?f:p;return t.consume(h),m}return r(h)}}const yo={partial:!0,tokenize:b3};function b3(t,e,r){return n;function n(s){return ze(s)?Ke(t,i,"linePrefix")(s):i(s)}function i(s){return s===null||Se(s)?e(s):r(s)}}const JD={continuation:{tokenize:F3},exit:T3,name:"blockQuote",tokenize:v3};function v3(t,e,r){const n=this;return i;function i(a){if(a===62){const o=n.containerState;return o.open||(t.enter("blockQuote",{_container:!0}),o.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(a),t.exit("blockQuoteMarker"),s}return r(a)}function s(a){return ze(a)?(t.enter("blockQuotePrefixWhitespace"),t.consume(a),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(a))}}function F3(t,e,r){const n=this;return i;function i(a){return ze(a)?Ke(t,s,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return t.attempt(JD,e,r)(a)}}function T3(t){t.exit("blockQuote")}const KD={name:"characterEscape",tokenize:w3};function w3(t,e,r){return n;function n(s){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(s),t.exit("escapeMarker"),i}function i(s){return f3(s)?(t.enter("characterEscapeValue"),t.consume(s),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):r(s)}}const YD={name:"characterReference",tokenize:S3};function S3(t,e,r){const n=this;let i=0,s,a;return o;function o(p){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(p),t.exit("characterReferenceMarker"),u}function u(p){return p===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(p),t.exit("characterReferenceMarkerNumeric"),l):(t.enter("characterReferenceValue"),s=31,a=Kt,c(p))}function l(p){return p===88||p===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(p),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),s=6,a=h3,c):(t.enter("characterReferenceValue"),s=7,a=cf,c(p))}function c(p){if(p===59&&i){const f=t.exit("characterReferenceValue");return a===Kt&&!lf(n.sliceSerialize(f))?r(p):(t.enter("characterReferenceMarker"),t.consume(p),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return a(p)&&i++<s?(t.consume(p),c):r(p)}}const XD={partial:!0,tokenize:P3},QD={concrete:!0,name:"codeFenced",tokenize:k3};function k3(t,e,r){const n=this,i={partial:!0,tokenize:E};let s=0,a=0,o;return u;function u(C){return l(C)}function l(C){const b=n.events[n.events.length-1];return s=b&&b[1].type==="linePrefix"?b[2].sliceSerialize(b[1],!0).length:0,o=C,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),c(C)}function c(C){return C===o?(a++,t.consume(C),c):a<3?r(C):(t.exit("codeFencedFenceSequence"),ze(C)?Ke(t,p,"whitespace")(C):p(C))}function p(C){return C===null||Se(C)?(t.exit("codeFencedFence"),n.interrupt?e(C):t.check(XD,g,A)(C)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),f(C))}function f(C){return C===null||Se(C)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),p(C)):ze(C)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),Ke(t,h,"whitespace")(C)):C===96&&C===o?r(C):(t.consume(C),f)}function h(C){return C===null||Se(C)?p(C):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),m(C))}function m(C){return C===null||Se(C)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),p(C)):C===96&&C===o?r(C):(t.consume(C),m)}function g(C){return t.attempt(i,A,y)(C)}function y(C){return t.enter("lineEnding"),t.consume(C),t.exit("lineEnding"),D}function D(C){return s>0&&ze(C)?Ke(t,d,"linePrefix",s+1)(C):d(C)}function d(C){return C===null||Se(C)?t.check(XD,g,A)(C):(t.enter("codeFlowValue"),x(C))}function x(C){return C===null||Se(C)?(t.exit("codeFlowValue"),d(C)):(t.consume(C),x)}function A(C){return t.exit("codeFenced"),e(C)}function E(C,b,w){let P=0;return F;function F(_){return C.enter("lineEnding"),C.consume(_),C.exit("lineEnding"),S}function S(_){return C.enter("codeFencedFence"),ze(_)?Ke(C,I,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):I(_)}function I(_){return _===o?(C.enter("codeFencedFenceSequence"),B(_)):w(_)}function B(_){return _===o?(P++,C.consume(_),B):P>=a?(C.exit("codeFencedFenceSequence"),ze(_)?Ke(C,O,"whitespace")(_):O(_)):w(_)}function O(_){return _===null||Se(_)?(C.exit("codeFencedFence"),b(_)):w(_)}}}function P3(t,e,r){const n=this;return i;function i(a){return a===null?r(a):(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),s)}function s(a){return n.parser.lazy[n.now().line]?r(a):e(a)}}const hf={name:"codeIndented",tokenize:B3},_3={partial:!0,tokenize:N3};function B3(t,e,r){const n=this;return i;function i(l){return t.enter("codeIndented"),Ke(t,s,"linePrefix",5)(l)}function s(l){const c=n.events[n.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?a(l):r(l)}function a(l){return l===null?u(l):Se(l)?t.attempt(_3,a,u)(l):(t.enter("codeFlowValue"),o(l))}function o(l){return l===null||Se(l)?(t.exit("codeFlowValue"),a(l)):(t.consume(l),o)}function u(l){return t.exit("codeIndented"),e(l)}}function N3(t,e,r){const n=this;return i;function i(a){return n.parser.lazy[n.now().line]?r(a):Se(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),i):Ke(t,s,"linePrefix",5)(a)}function s(a){const o=n.events[n.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?e(a):Se(a)?i(a):r(a)}}const $3={name:"codeText",previous:O3,resolve:I3,tokenize:L3};function I3(t){let e=t.length-4,r=3,n,i;if((t[r][1].type==="lineEnding"||t[r][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(n=r;++n<e;)if(t[n][1].type==="codeTextData"){t[r][1].type="codeTextPadding",t[e][1].type="codeTextPadding",r+=2,e-=2;break}}for(n=r-1,e++;++n<=e;)i===void 0?n!==e&&t[n][1].type!=="lineEnding"&&(i=n):(n===e||t[n][1].type==="lineEnding")&&(t[i][1].type="codeTextData",n!==i+2&&(t[i][1].end=t[n-1][1].end,t.splice(i+2,n-i-2),e-=n-i-2,n=i+2),i=void 0);return t}function O3(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function L3(t,e,r){let n=0,i,s;return a;function a(p){return t.enter("codeText"),t.enter("codeTextSequence"),o(p)}function o(p){return p===96?(t.consume(p),n++,o):(t.exit("codeTextSequence"),u(p))}function u(p){return p===null?r(p):p===32?(t.enter("space"),t.consume(p),t.exit("space"),u):p===96?(s=t.enter("codeTextSequence"),i=0,c(p)):Se(p)?(t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),u):(t.enter("codeTextData"),l(p))}function l(p){return p===null||p===32||p===96||Se(p)?(t.exit("codeTextData"),u(p)):(t.consume(p),l)}function c(p){return p===96?(t.consume(p),i++,c):i===n?(t.exit("codeTextSequence"),t.exit("codeText"),e(p)):(s.type="codeTextData",l(p))}}class M3{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,r){const n=r??Number.POSITIVE_INFINITY;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,r,n){const i=r||0;this.setCursor(Math.trunc(e));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return n&&Do(this.left,n),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),Do(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Do(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const r=this.left.splice(e,Number.POSITIVE_INFINITY);Do(this.right,r.reverse())}else{const r=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);Do(this.left,r.reverse())}}}function Do(t,e){let r=0;if(e.length<1e4)t.push(...e);else for(;r<e.length;)t.push(...e.slice(r,r+1e4)),r+=1e4}function ZD(t){const e={};let r=-1,n,i,s,a,o,u,l;const c=new M3(t);for(;++r<c.length;){for(;r in e;)r=e[r];if(n=c.get(r),r&&n[1].type==="chunkFlow"&&c.get(r-1)[1].type==="listItemPrefix"&&(u=n[1]._tokenizer.events,s=0,s<u.length&&u[s][1].type==="lineEndingBlank"&&(s+=2),s<u.length&&u[s][1].type==="content"))for(;++s<u.length&&u[s][1].type!=="content";)u[s][1].type==="chunkText"&&(u[s][1]._isInFirstContentOfListItem=!0,s++);if(n[0]==="enter")n[1].contentType&&(Object.assign(e,R3(c,r)),r=e[r],l=!0);else if(n[1]._container){for(s=r,i=void 0;s--;)if(a=c.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(c.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(n[1].end={...c.get(i)[1].start},o=c.slice(i,r),o.unshift(n),c.splice(i,r-i+1,o))}}return Nr(t,0,Number.POSITIVE_INFINITY,c.slice(0)),!l}function R3(t,e){const r=t.get(e)[1],n=t.get(e)[2];let i=e-1;const s=[];let a=r._tokenizer;a||(a=n.parser[r.contentType](r.start),r._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const o=a.events,u=[],l={};let c,p,f=-1,h=r,m=0,g=0;const y=[g];for(;h;){for(;t.get(++i)[1]!==h;);s.push(i),h._tokenizer||(c=n.sliceStream(h),h.next||c.push(null),p&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(c),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),p=h,h=h.next}for(h=r;++f<o.length;)o[f][0]==="exit"&&o[f-1][0]==="enter"&&o[f][1].type===o[f-1][1].type&&o[f][1].start.line!==o[f][1].end.line&&(g=f+1,y.push(g),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):y.pop(),f=y.length;f--;){const D=o.slice(y[f],y[f+1]),d=s.pop();u.push([d,d+D.length-1]),t.splice(d,2,D)}for(u.reverse(),f=-1;++f<u.length;)l[m+u[f][0]]=m+u[f][1],m+=u[f][1]-u[f][0]-1;return l}const j3={resolve:U3,tokenize:z3},q3={partial:!0,tokenize:V3};function U3(t){return ZD(t),t}function z3(t,e){let r;return n;function n(o){return t.enter("content"),r=t.enter("chunkContent",{contentType:"content"}),i(o)}function i(o){return o===null?s(o):Se(o)?t.check(q3,a,s)(o):(t.consume(o),i)}function s(o){return t.exit("chunkContent"),t.exit("content"),e(o)}function a(o){return t.consume(o),t.exit("chunkContent"),r.next=t.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,i}}function V3(t,e,r){const n=this;return i;function i(a){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),Ke(t,s,"linePrefix")}function s(a){if(a===null||Se(a))return r(a);const o=n.events[n.events.length-1];return!n.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?e(a):t.interrupt(n.parser.constructs.flow,r,e)(a)}}function e2(t,e,r,n,i,s,a,o,u){const l=u||Number.POSITIVE_INFINITY;let c=0;return p;function p(D){return D===60?(t.enter(n),t.enter(i),t.enter(s),t.consume(D),t.exit(s),f):D===null||D===32||D===41||Dl(D)?r(D):(t.enter(n),t.enter(a),t.enter(o),t.enter("chunkString",{contentType:"string"}),g(D))}function f(D){return D===62?(t.enter(s),t.consume(D),t.exit(s),t.exit(i),t.exit(n),e):(t.enter(o),t.enter("chunkString",{contentType:"string"}),h(D))}function h(D){return D===62?(t.exit("chunkString"),t.exit(o),f(D)):D===null||D===60||Se(D)?r(D):(t.consume(D),D===92?m:h)}function m(D){return D===60||D===62||D===92?(t.consume(D),h):h(D)}function g(D){return!c&&(D===null||D===41||at(D))?(t.exit("chunkString"),t.exit(o),t.exit(a),t.exit(n),e(D)):c<l&&D===40?(t.consume(D),c++,g):D===41?(t.consume(D),c--,g):D===null||D===32||D===40||Dl(D)?r(D):(t.consume(D),D===92?y:g)}function y(D){return D===40||D===41||D===92?(t.consume(D),g):g(D)}}function t2(t,e,r,n,i,s){const a=this;let o=0,u;return l;function l(h){return t.enter(n),t.enter(i),t.consume(h),t.exit(i),t.enter(s),c}function c(h){return o>999||h===null||h===91||h===93&&!u||h===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?r(h):h===93?(t.exit(s),t.enter(i),t.consume(h),t.exit(i),t.exit(n),e):Se(h)?(t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),c):(t.enter("chunkString",{contentType:"string"}),p(h))}function p(h){return h===null||h===91||h===93||Se(h)||o++>999?(t.exit("chunkString"),c(h)):(t.consume(h),u||(u=!ze(h)),h===92?f:p)}function f(h){return h===91||h===92||h===93?(t.consume(h),o++,p):p(h)}}function r2(t,e,r,n,i,s){let a;return o;function o(f){return f===34||f===39||f===40?(t.enter(n),t.enter(i),t.consume(f),t.exit(i),a=f===40?41:f,u):r(f)}function u(f){return f===a?(t.enter(i),t.consume(f),t.exit(i),t.exit(n),e):(t.enter(s),l(f))}function l(f){return f===a?(t.exit(s),u(a)):f===null?r(f):Se(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),Ke(t,l,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),c(f))}function c(f){return f===a||f===null||Se(f)?(t.exit("chunkString"),l(f)):(t.consume(f),f===92?p:c)}function p(f){return f===a||f===92?(t.consume(f),c):c(f)}}function Eo(t,e){let r;return n;function n(i){return Se(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),r=!0,n):ze(i)?Ke(t,n,r?"linePrefix":"lineSuffix")(i):e(i)}}const H3={name:"definition",tokenize:G3},W3={partial:!0,tokenize:J3};function G3(t,e,r){const n=this;let i;return s;function s(h){return t.enter("definition"),a(h)}function a(h){return t2.call(n,t,o,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function o(h){return i=on(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),u):r(h)}function u(h){return at(h)?Eo(t,l)(h):l(h)}function l(h){return e2(t,c,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function c(h){return t.attempt(W3,p,p)(h)}function p(h){return ze(h)?Ke(t,f,"whitespace")(h):f(h)}function f(h){return h===null||Se(h)?(t.exit("definition"),n.parser.defined.push(i),e(h)):r(h)}}function J3(t,e,r){return n;function n(o){return at(o)?Eo(t,i)(o):r(o)}function i(o){return r2(t,s,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return ze(o)?Ke(t,a,"whitespace")(o):a(o)}function a(o){return o===null||Se(o)?e(o):r(o)}}const K3={name:"hardBreakEscape",tokenize:Y3};function Y3(t,e,r){return n;function n(s){return t.enter("hardBreakEscape"),t.consume(s),i}function i(s){return Se(s)?(t.exit("hardBreakEscape"),e(s)):r(s)}}const X3={name:"headingAtx",resolve:Q3,tokenize:Z3};function Q3(t,e){let r=t.length-2,n=3,i,s;return t[n][1].type==="whitespace"&&(n+=2),r-2>n&&t[r][1].type==="whitespace"&&(r-=2),t[r][1].type==="atxHeadingSequence"&&(n===r-1||r-4>n&&t[r-2][1].type==="whitespace")&&(r-=n+1===r?2:4),r>n&&(i={type:"atxHeadingText",start:t[n][1].start,end:t[r][1].end},s={type:"chunkText",start:t[n][1].start,end:t[r][1].end,contentType:"text"},Nr(t,n,r-n+1,[["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e]])),t}function Z3(t,e,r){let n=0;return i;function i(c){return t.enter("atxHeading"),s(c)}function s(c){return t.enter("atxHeadingSequence"),a(c)}function a(c){return c===35&&n++<6?(t.consume(c),a):c===null||at(c)?(t.exit("atxHeadingSequence"),o(c)):r(c)}function o(c){return c===35?(t.enter("atxHeadingSequence"),u(c)):c===null||Se(c)?(t.exit("atxHeading"),e(c)):ze(c)?Ke(t,o,"whitespace")(c):(t.enter("atxHeadingText"),l(c))}function u(c){return c===35?(t.consume(c),u):(t.exit("atxHeadingSequence"),o(c))}function l(c){return c===null||c===35||at(c)?(t.exit("atxHeadingText"),o(c)):(t.consume(c),l)}}const eP=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],n2=["pre","script","style","textarea"],tP={concrete:!0,name:"htmlFlow",resolveTo:iP,tokenize:sP},rP={partial:!0,tokenize:oP},nP={partial:!0,tokenize:aP};function iP(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function sP(t,e,r){const n=this;let i,s,a,o,u;return l;function l(v){return c(v)}function c(v){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(v),p}function p(v){return v===33?(t.consume(v),f):v===47?(t.consume(v),s=!0,g):v===63?(t.consume(v),i=3,n.interrupt?e:T):rr(v)?(t.consume(v),a=String.fromCharCode(v),y):r(v)}function f(v){return v===45?(t.consume(v),i=2,h):v===91?(t.consume(v),i=5,o=0,m):rr(v)?(t.consume(v),i=4,n.interrupt?e:T):r(v)}function h(v){return v===45?(t.consume(v),n.interrupt?e:T):r(v)}function m(v){const k="CDATA[";return v===k.charCodeAt(o++)?(t.consume(v),o===k.length?n.interrupt?e:I:m):r(v)}function g(v){return rr(v)?(t.consume(v),a=String.fromCharCode(v),y):r(v)}function y(v){if(v===null||v===47||v===62||at(v)){const k=v===47,N=a.toLowerCase();return!k&&!s&&n2.includes(N)?(i=1,n.interrupt?e(v):I(v)):eP.includes(a.toLowerCase())?(i=6,k?(t.consume(v),D):n.interrupt?e(v):I(v)):(i=7,n.interrupt&&!n.parser.lazy[n.now().line]?r(v):s?d(v):x(v))}return v===45||Kt(v)?(t.consume(v),a+=String.fromCharCode(v),y):r(v)}function D(v){return v===62?(t.consume(v),n.interrupt?e:I):r(v)}function d(v){return ze(v)?(t.consume(v),d):F(v)}function x(v){return v===47?(t.consume(v),F):v===58||v===95||rr(v)?(t.consume(v),A):ze(v)?(t.consume(v),x):F(v)}function A(v){return v===45||v===46||v===58||v===95||Kt(v)?(t.consume(v),A):E(v)}function E(v){return v===61?(t.consume(v),C):ze(v)?(t.consume(v),E):x(v)}function C(v){return v===null||v===60||v===61||v===62||v===96?r(v):v===34||v===39?(t.consume(v),u=v,b):ze(v)?(t.consume(v),C):w(v)}function b(v){return v===u?(t.consume(v),u=null,P):v===null||Se(v)?r(v):(t.consume(v),b)}function w(v){return v===null||v===34||v===39||v===47||v===60||v===61||v===62||v===96||at(v)?E(v):(t.consume(v),w)}function P(v){return v===47||v===62||ze(v)?x(v):r(v)}function F(v){return v===62?(t.consume(v),S):r(v)}function S(v){return v===null||Se(v)?I(v):ze(v)?(t.consume(v),S):r(v)}function I(v){return v===45&&i===2?(t.consume(v),$):v===60&&i===1?(t.consume(v),Y):v===62&&i===4?(t.consume(v),L):v===63&&i===3?(t.consume(v),T):v===93&&i===5?(t.consume(v),ee):Se(v)&&(i===6||i===7)?(t.exit("htmlFlowData"),t.check(rP,H,B)(v)):v===null||Se(v)?(t.exit("htmlFlowData"),B(v)):(t.consume(v),I)}function B(v){return t.check(nP,O,H)(v)}function O(v){return t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),_}function _(v){return v===null||Se(v)?B(v):(t.enter("htmlFlowData"),I(v))}function $(v){return v===45?(t.consume(v),T):I(v)}function Y(v){return v===47?(t.consume(v),a="",V):I(v)}function V(v){if(v===62){const k=a.toLowerCase();return n2.includes(k)?(t.consume(v),L):I(v)}return rr(v)&&a.length<8?(t.consume(v),a+=String.fromCharCode(v),V):I(v)}function ee(v){return v===93?(t.consume(v),T):I(v)}function T(v){return v===62?(t.consume(v),L):v===45&&i===2?(t.consume(v),T):I(v)}function L(v){return v===null||Se(v)?(t.exit("htmlFlowData"),H(v)):(t.consume(v),L)}function H(v){return t.exit("htmlFlow"),e(v)}}function aP(t,e,r){const n=this;return i;function i(a){return Se(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),s):r(a)}function s(a){return n.parser.lazy[n.now().line]?r(a):e(a)}}function oP(t,e,r){return n;function n(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),t.attempt(yo,e,r)}}const uP={name:"htmlText",tokenize:lP};function lP(t,e,r){const n=this;let i,s,a;return o;function o(T){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(T),u}function u(T){return T===33?(t.consume(T),l):T===47?(t.consume(T),E):T===63?(t.consume(T),x):rr(T)?(t.consume(T),w):r(T)}function l(T){return T===45?(t.consume(T),c):T===91?(t.consume(T),s=0,m):rr(T)?(t.consume(T),d):r(T)}function c(T){return T===45?(t.consume(T),h):r(T)}function p(T){return T===null?r(T):T===45?(t.consume(T),f):Se(T)?(a=p,Y(T)):(t.consume(T),p)}function f(T){return T===45?(t.consume(T),h):p(T)}function h(T){return T===62?$(T):T===45?f(T):p(T)}function m(T){const L="CDATA[";return T===L.charCodeAt(s++)?(t.consume(T),s===L.length?g:m):r(T)}function g(T){return T===null?r(T):T===93?(t.consume(T),y):Se(T)?(a=g,Y(T)):(t.consume(T),g)}function y(T){return T===93?(t.consume(T),D):g(T)}function D(T){return T===62?$(T):T===93?(t.consume(T),D):g(T)}function d(T){return T===null||T===62?$(T):Se(T)?(a=d,Y(T)):(t.consume(T),d)}function x(T){return T===null?r(T):T===63?(t.consume(T),A):Se(T)?(a=x,Y(T)):(t.consume(T),x)}function A(T){return T===62?$(T):x(T)}function E(T){return rr(T)?(t.consume(T),C):r(T)}function C(T){return T===45||Kt(T)?(t.consume(T),C):b(T)}function b(T){return Se(T)?(a=b,Y(T)):ze(T)?(t.consume(T),b):$(T)}function w(T){return T===45||Kt(T)?(t.consume(T),w):T===47||T===62||at(T)?P(T):r(T)}function P(T){return T===47?(t.consume(T),$):T===58||T===95||rr(T)?(t.consume(T),F):Se(T)?(a=P,Y(T)):ze(T)?(t.consume(T),P):$(T)}function F(T){return T===45||T===46||T===58||T===95||Kt(T)?(t.consume(T),F):S(T)}function S(T){return T===61?(t.consume(T),I):Se(T)?(a=S,Y(T)):ze(T)?(t.consume(T),S):P(T)}function I(T){return T===null||T===60||T===61||T===62||T===96?r(T):T===34||T===39?(t.consume(T),i=T,B):Se(T)?(a=I,Y(T)):ze(T)?(t.consume(T),I):(t.consume(T),O)}function B(T){return T===i?(t.consume(T),i=void 0,_):T===null?r(T):Se(T)?(a=B,Y(T)):(t.consume(T),B)}function O(T){return T===null||T===34||T===39||T===60||T===61||T===96?r(T):T===47||T===62||at(T)?P(T):(t.consume(T),O)}function _(T){return T===47||T===62||at(T)?P(T):r(T)}function $(T){return T===62?(t.consume(T),t.exit("htmlTextData"),t.exit("htmlText"),e):r(T)}function Y(T){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(T),t.exit("lineEnding"),V}function V(T){return ze(T)?Ke(t,ee,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):ee(T)}function ee(T){return t.enter("htmlTextData"),a(T)}}const ff={name:"labelEnd",resolveAll:fP,resolveTo:dP,tokenize:mP},cP={tokenize:gP},pP={tokenize:yP},hP={tokenize:DP};function fP(t){let e=-1;const r=[];for(;++e<t.length;){const n=t[e][1];if(r.push(t[e]),n.type==="labelImage"||n.type==="labelLink"||n.type==="labelEnd"){const i=n.type==="labelImage"?4:2;n.type="data",e+=i}}return t.length!==r.length&&Nr(t,0,t.length,r),t}function dP(t,e){let r=t.length,n=0,i,s,a,o;for(;r--;)if(i=t[r][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;t[r][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(t[r][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=r,i.type!=="labelLink")){n=2;break}}else i.type==="labelEnd"&&(a=r);const u={type:t[s][1].type==="labelLink"?"link":"image",start:{...t[s][1].start},end:{...t[t.length-1][1].end}},l={type:"label",start:{...t[s][1].start},end:{...t[a][1].end}},c={type:"labelText",start:{...t[s+n+2][1].end},end:{...t[a-2][1].start}};return o=[["enter",u,e],["enter",l,e]],o=Hr(o,t.slice(s+1,s+n+3)),o=Hr(o,[["enter",c,e]]),o=Hr(o,xl(e.parser.constructs.insideSpan.null,t.slice(s+n+4,a-3),e)),o=Hr(o,[["exit",c,e],t[a-2],t[a-1],["exit",l,e]]),o=Hr(o,t.slice(a+1)),o=Hr(o,[["exit",u,e]]),Nr(t,s,t.length,o),t}function mP(t,e,r){const n=this;let i=n.events.length,s,a;for(;i--;)if((n.events[i][1].type==="labelImage"||n.events[i][1].type==="labelLink")&&!n.events[i][1]._balanced){s=n.events[i][1];break}return o;function o(f){return s?s._inactive?p(f):(a=n.parser.defined.includes(on(n.sliceSerialize({start:s.end,end:n.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(f),t.exit("labelMarker"),t.exit("labelEnd"),u):r(f)}function u(f){return f===40?t.attempt(cP,c,a?c:p)(f):f===91?t.attempt(pP,c,a?l:p)(f):a?c(f):p(f)}function l(f){return t.attempt(hP,c,p)(f)}function c(f){return e(f)}function p(f){return s._balanced=!0,r(f)}}function gP(t,e,r){return n;function n(p){return t.enter("resource"),t.enter("resourceMarker"),t.consume(p),t.exit("resourceMarker"),i}function i(p){return at(p)?Eo(t,s)(p):s(p)}function s(p){return p===41?c(p):e2(t,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function a(p){return at(p)?Eo(t,u)(p):c(p)}function o(p){return r(p)}function u(p){return p===34||p===39||p===40?r2(t,l,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):c(p)}function l(p){return at(p)?Eo(t,c)(p):c(p)}function c(p){return p===41?(t.enter("resourceMarker"),t.consume(p),t.exit("resourceMarker"),t.exit("resource"),e):r(p)}}function yP(t,e,r){const n=this;return i;function i(o){return t2.call(n,t,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return n.parser.defined.includes(on(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)))?e(o):r(o)}function a(o){return r(o)}}function DP(t,e,r){return n;function n(s){return t.enter("reference"),t.enter("referenceMarker"),t.consume(s),t.exit("referenceMarker"),i}function i(s){return s===93?(t.enter("referenceMarker"),t.consume(s),t.exit("referenceMarker"),t.exit("reference"),e):r(s)}}const EP={name:"labelStartImage",resolveAll:ff.resolveAll,tokenize:xP};function xP(t,e,r){const n=this;return i;function i(o){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(o),t.exit("labelImageMarker"),s}function s(o){return o===91?(t.enter("labelMarker"),t.consume(o),t.exit("labelMarker"),t.exit("labelImage"),a):r(o)}function a(o){return o===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(o):e(o)}}const CP={name:"labelStartLink",resolveAll:ff.resolveAll,tokenize:AP};function AP(t,e,r){const n=this;return i;function i(a){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(a),t.exit("labelMarker"),t.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(a):e(a)}}const df={name:"lineEnding",tokenize:bP};function bP(t,e){return r;function r(n){return t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),Ke(t,e,"linePrefix")}}const Cl={name:"thematicBreak",tokenize:vP};function vP(t,e,r){let n=0,i;return s;function s(l){return t.enter("thematicBreak"),a(l)}function a(l){return i=l,o(l)}function o(l){return l===i?(t.enter("thematicBreakSequence"),u(l)):n>=3&&(l===null||Se(l))?(t.exit("thematicBreak"),e(l)):r(l)}function u(l){return l===i?(t.consume(l),n++,u):(t.exit("thematicBreakSequence"),ze(l)?Ke(t,o,"whitespace")(l):o(l))}}const Dr={continuation:{tokenize:SP},exit:PP,name:"list",tokenize:wP},FP={partial:!0,tokenize:_P},TP={partial:!0,tokenize:kP};function wP(t,e,r){const n=this,i=n.events[n.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerializ