@likec4/mcp 1.51.0 → 1.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD-PARTY-LICENSES.md +24 -226
- package/dist/_chunks/libs/@hono/mcp.mjs +9 -9
- package/dist/_chunks/libs/@hono/node-server.mjs +1 -1
- package/dist/_chunks/libs/@logtape/logtape.mjs +4 -6
- package/dist/_chunks/libs/destr.mjs +1 -0
- package/dist/_chunks/libs/fast-equals.mjs +1 -1
- package/dist/_chunks/libs/langium.mjs +1 -1
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +1 -1
- package/dist/_chunks/libs/remeda.mjs +2 -2
- package/dist/_chunks/libs/unstorage.mjs +1 -0
- package/dist/index.mjs +80 -77
- package/package.json +15 -15
- package/dist/_chunks/libs/@msgpack/msgpack.mjs +0 -1
- package/dist/_chunks/libs/@smithy/is-array-buffer.mjs +0 -1
- package/dist/_chunks/libs/@smithy/util-base64.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"crypto";import{createServer as t}from"http";import{Http2ServerRequest as n}from"http2";import{Readable as r}from"stream";var i=class extends Error{constructor(e,t){super(e,t),this.name=`RequestError`}},a=e=>e instanceof i?e:new i(e.message,{cause:e}),o=global.Request,s=class extends o{constructor(e,t){typeof e==`object`&&d in e&&(e=e[d]()),t?.body?.getReader!==void 0&&(t.duplex??=`half`),super(e,t)}},c=e=>{let t=[],n=e.rawHeaders;for(let e=0;e<n.length;e+=2){let{[e]:r,[e+1]:i}=n;r.charCodeAt(0)!==58&&t.push([r,i])}return new Headers(t)},l=Symbol(`wrapBodyStream`),u=(e,t,n,i,a)=>{let o={method:e,headers:n,signal:a.signal};if(e===`TRACE`){o.method=`GET`;let e=new s(t,o);return Object.defineProperty(e,`method`,{get(){return`TRACE`}}),e}if(!(e===`GET`||e===`HEAD`))if(`rawBody`in i&&i.rawBody instanceof Buffer)o.body=new ReadableStream({start(e){e.enqueue(i.rawBody),e.close()}});else if(i[l]){let e;o.body=new ReadableStream({async pull(t){try{e||=r.toWeb(i).getReader();let{done:n,value:a}=await e.read();n?t.close():t.enqueue(a)}catch(e){t.error(e)}}})}else o.body=r.toWeb(i);return new s(t,o)},d=Symbol(`getRequestCache`),f=Symbol(`requestCache`),p=Symbol(`incomingKey`),m=Symbol(`urlKey`),h=Symbol(`headersKey`),g=Symbol(`abortControllerKey`),_={get method(){return this[p].method||`GET`},get url(){return this[m]},get headers(){return this[h]||=c(this[p])},[Symbol(`getAbortController`)](){return this[d](),this[g]},[d](){return this[g]||=new AbortController,this[f]||=u(this.method,this[m],this.headers,this[p],this[g])}};[`body`,`bodyUsed`,`cache`,`credentials`,`destination`,`integrity`,`mode`,`redirect`,`referrer`,`referrerPolicy`,`signal`,`keepalive`].forEach(e=>{Object.defineProperty(_,e,{get(){return this[d]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(_,e,{value:function(){return this[d]()[e]()}})}),Object.setPrototypeOf(_,s.prototype);var v=(e,t)=>{let r=Object.create(_);r[p]=e;let a=e.url||``;if(a[0]!==`/`&&(a.startsWith(`http://`)||a.startsWith(`https://`))){if(e instanceof n)throw new i(`Absolute URL for :path is not allowed in HTTP/2`);try{r[m]=new URL(a).href}catch(e){throw new i(`Invalid absolute URL`,{cause:e})}return r}let o=(e instanceof n?e.authority:e.headers.host)||t;if(!o)throw new i(`Missing host header`);let s;if(e instanceof n){if(s=e.scheme,!(s===`http`||s===`https`))throw new i(`Unsupported scheme`)}else s=e.socket&&e.socket.encrypted?`https`:`http`;let c=new URL(`${s}://${o}${a}`);if(c.hostname.length!==o.length&&c.hostname!==o.replace(/:\d+$/,``))throw new i(`Invalid host header`);return r[m]=c.href,r},y=Symbol(`responseCache`),b=Symbol(`getResponseCache`),x=Symbol(`cache`),S=global.Response,C=class e{#e;#t;[b](){return delete this[x],this[y]||=new S(this.#e,this.#t)}constructor(t,n){let r;if(this.#e=t,n instanceof e){let e=n[y];if(e){this.#t=e,this[b]();return}else this.#t=n.#t,r=new Headers(n.#t.headers)}else this.#t=n;(typeof t==`string`||t?.getReader!==void 0||t instanceof Blob||t instanceof Uint8Array)&&(
|
|
1
|
+
import e from"crypto";import{createServer as t}from"http";import{Http2ServerRequest as n}from"http2";import{Readable as r}from"stream";var i=class extends Error{constructor(e,t){super(e,t),this.name=`RequestError`}},a=e=>e instanceof i?e:new i(e.message,{cause:e}),o=global.Request,s=class extends o{constructor(e,t){typeof e==`object`&&d in e&&(e=e[d]()),t?.body?.getReader!==void 0&&(t.duplex??=`half`),super(e,t)}},c=e=>{let t=[],n=e.rawHeaders;for(let e=0;e<n.length;e+=2){let{[e]:r,[e+1]:i}=n;r.charCodeAt(0)!==58&&t.push([r,i])}return new Headers(t)},l=Symbol(`wrapBodyStream`),u=(e,t,n,i,a)=>{let o={method:e,headers:n,signal:a.signal};if(e===`TRACE`){o.method=`GET`;let e=new s(t,o);return Object.defineProperty(e,`method`,{get(){return`TRACE`}}),e}if(!(e===`GET`||e===`HEAD`))if(`rawBody`in i&&i.rawBody instanceof Buffer)o.body=new ReadableStream({start(e){e.enqueue(i.rawBody),e.close()}});else if(i[l]){let e;o.body=new ReadableStream({async pull(t){try{e||=r.toWeb(i).getReader();let{done:n,value:a}=await e.read();n?t.close():t.enqueue(a)}catch(e){t.error(e)}}})}else o.body=r.toWeb(i);return new s(t,o)},d=Symbol(`getRequestCache`),f=Symbol(`requestCache`),p=Symbol(`incomingKey`),m=Symbol(`urlKey`),h=Symbol(`headersKey`),g=Symbol(`abortControllerKey`),_={get method(){return this[p].method||`GET`},get url(){return this[m]},get headers(){return this[h]||=c(this[p])},[Symbol(`getAbortController`)](){return this[d](),this[g]},[d](){return this[g]||=new AbortController,this[f]||=u(this.method,this[m],this.headers,this[p],this[g])}};[`body`,`bodyUsed`,`cache`,`credentials`,`destination`,`integrity`,`mode`,`redirect`,`referrer`,`referrerPolicy`,`signal`,`keepalive`].forEach(e=>{Object.defineProperty(_,e,{get(){return this[d]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(_,e,{value:function(){return this[d]()[e]()}})}),Object.setPrototypeOf(_,s.prototype);var v=(e,t)=>{let r=Object.create(_);r[p]=e;let a=e.url||``;if(a[0]!==`/`&&(a.startsWith(`http://`)||a.startsWith(`https://`))){if(e instanceof n)throw new i(`Absolute URL for :path is not allowed in HTTP/2`);try{r[m]=new URL(a).href}catch(e){throw new i(`Invalid absolute URL`,{cause:e})}return r}let o=(e instanceof n?e.authority:e.headers.host)||t;if(!o)throw new i(`Missing host header`);let s;if(e instanceof n){if(s=e.scheme,!(s===`http`||s===`https`))throw new i(`Unsupported scheme`)}else s=e.socket&&e.socket.encrypted?`https`:`http`;let c=new URL(`${s}://${o}${a}`);if(c.hostname.length!==o.length&&c.hostname!==o.replace(/:\d+$/,``))throw new i(`Invalid host header`);return r[m]=c.href,r},y=Symbol(`responseCache`),b=Symbol(`getResponseCache`),x=Symbol(`cache`),S=global.Response,C=class e{#e;#t;[b](){return delete this[x],this[y]||=new S(this.#e,this.#t)}constructor(t,n){let r;if(this.#e=t,n instanceof e){let e=n[y];if(e){this.#t=e,this[b]();return}else this.#t=n.#t,r=new Headers(n.#t.headers)}else this.#t=n;(typeof t==`string`||t?.getReader!==void 0||t instanceof Blob||t instanceof Uint8Array)&&(this[x]=[n?.status||200,t,r||n?.headers])}get headers(){let e=this[x];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":`text/plain; charset=UTF-8`})),e[2]):this[b]().headers}get status(){return this[x]?.[0]??this[b]().status}get ok(){let e=this.status;return e>=200&&e<300}};[`body`,`bodyUsed`,`redirected`,`statusText`,`trailers`,`type`,`url`].forEach(e=>{Object.defineProperty(C.prototype,e,{get(){return this[b]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(C.prototype,e,{value:function(){return this[b]()[e]()}})}),Object.setPrototypeOf(C,S),Object.setPrototypeOf(C.prototype,S.prototype);async function w(e){return Promise.race([e,Promise.resolve().then(()=>Promise.resolve(void 0))])}function T(e,t,n){let r=t=>{e.cancel(t).catch(()=>{})};return t.on(`close`,r),t.on(`error`,r),(n??e.read()).then(o,i),e.closed.finally(()=>{t.off(`close`,r),t.off(`error`,r)});function i(e){e&&t.destroy(e)}function a(){e.read().then(o,i)}function o({done:n,value:r}){try{if(n)t.end();else if(!t.write(r))t.once(`drain`,a);else return e.read().then(o,i)}catch(e){i(e)}}}function E(e,t){if(e.locked)throw TypeError(`ReadableStream is locked.`);return t.destroyed?void 0:T(e.getReader(),t)}var D=e=>{let t={};e instanceof Headers||(e=new Headers(e??void 0));let n=[];for(let[r,i]of e)r===`set-cookie`?n.push(i):t[r]=i;return n.length>0&&(t[`set-cookie`]=n),t[`content-type`]??=`text/plain; charset=UTF-8`,t},O=`x-hono-already-sent`;global.crypto===void 0&&(global.crypto=e);var k=Symbol(`outgoingEnded`),A=()=>new Response(null,{status:400}),j=e=>new Response(null,{status:e instanceof Error&&(e.name===`TimeoutError`||e.constructor.name===`TimeoutError`)?504:500}),M=(e,t)=>{let n=e instanceof Error?e:Error(`unknown error`,{cause:e});n.code===`ERR_STREAM_PREMATURE_CLOSE`?console.info(`The user aborted a request.`):(console.error(e),t.headersSent||t.writeHead(500,{"Content-Type":`text/plain`}),t.end(`Error: ${n.message}`),t.destroy(n))},N=e=>{`flushHeaders`in e&&e.writable&&e.flushHeaders()},P=async(e,t)=>{let[n,r,i]=e[x],a=!1;if(!i)i={"content-type":`text/plain; charset=UTF-8`};else if(i instanceof Headers)a=i.has(`content-length`),i=D(i);else if(Array.isArray(i)){let e=new Headers(i);a=e.has(`content-length`),i=D(e)}else for(let e in i)if(e.length===14&&e.toLowerCase()===`content-length`){a=!0;break}a||(typeof r==`string`?i[`Content-Length`]=Buffer.byteLength(r):r instanceof Uint8Array?i[`Content-Length`]=r.byteLength:r instanceof Blob&&(i[`Content-Length`]=r.size)),t.writeHead(n,i),typeof r==`string`||r instanceof Uint8Array?t.end(r):r instanceof Blob?t.end(new Uint8Array(await r.arrayBuffer())):(N(t),await E(r,t)?.catch(e=>M(e,t))),t[k]?.()},F=e=>typeof e.then==`function`,I=async(e,t,n={})=>{if(F(e))if(n.errorHandler)try{e=await e}catch(t){let r=await n.errorHandler(t);if(!r)return;e=r}else e=await e.catch(j);if(x in e)return P(e,t);let r=D(e.headers);if(e.body){let n=e.body.getReader(),i=[],a=!1,o;if(r[`transfer-encoding`]!==`chunked`){let e=2;for(let t=0;t<e;t++){o||=n.read();let r=await w(o).catch(e=>{console.error(e),a=!0});if(!r){if(t===1){await new Promise(e=>setTimeout(e)),e=3;continue}break}if(o=void 0,r.value&&i.push(r.value),r.done){a=!0;break}}a&&!(`content-length`in r)&&(r[`content-length`]=i.reduce((e,t)=>e+t.length,0))}t.writeHead(e.status,r),i.forEach(e=>{t.write(e)}),a?t.end():(i.length===0&&N(t),await T(n,t,o))}else r[O]||(t.writeHead(e.status,r),t.end());t[k]?.()},L=(e,t={})=>{let r=t.autoCleanupIncoming??!0;return t.overrideGlobalObjects!==!1&&global.Request!==s&&(Object.defineProperty(global,`Request`,{value:s}),Object.defineProperty(global,`Response`,{value:C})),async(i,o)=>{let s,c;try{c=v(i,t.hostname);let a=!r||i.method===`GET`||i.method===`HEAD`;if(a||(i[l]=!0,i.on(`end`,()=>{a=!0}),i instanceof n&&(o[k]=()=>{a||setTimeout(()=>{a||setTimeout(()=>{i.destroy(),o.destroy()})})})),o.on(`close`,()=>{c[g]&&(i.errored?c[g].abort(i.errored.toString()):o.writableFinished||c[g].abort(`Client connection prematurely closed.`)),a||setTimeout(()=>{a||setTimeout(()=>{i.destroy()})})}),s=e(c,{incoming:i,outgoing:o}),x in s)return P(s,o)}catch(e){if(s)return M(e,o);if(t.errorHandler){if(s=await t.errorHandler(c?e:a(e)),!s)return}else s=c?j(e):A()}try{return await I(s,o,t)}catch(e){return M(e,o)}}},R=e=>{let n=e.fetch,r=L(n,{hostname:e.hostname,overrideGlobalObjects:e.overrideGlobalObjects,autoCleanupIncoming:e.autoCleanupIncoming});return(e.createServer||t)(e.serverOptions||{},r)},z=(e,t)=>{let n=R(e);return n.listen(e?.port??3e3,e.hostname,()=>{let e=n.address();t&&t(e)}),n};export{z as t};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import{r as e}from"../../rolldown-runtime.mjs";import t from"node:util";function n(e){return typeof e==`function`?e:r(e)}function r(e){if(e==null)return()=>!1;if(e===`fatal`)return e=>e.level===`fatal`;if(e===`error`)return e=>e.level===`fatal`||e.level===`error`;if(e===`warning`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`;if(e===`info`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`;if(e===`debug`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`||e.level===`debug`;if(e===`trace`)return()=>!0;throw TypeError(`Invalid log level: ${e}.`)}const i=[`trace`,`debug`,`info`,`warning`,`error`,`fatal`];function a(e,t){let n=i.indexOf(e);if(n<0)throw TypeError(`Invalid log level: ${JSON.stringify(e)}.`);let r=i.indexOf(t);if(r<0)throw TypeError(`Invalid log level: ${JSON.stringify(t)}.`);return n-r}function o(e=[]){return c.getLogger(e)}const s=Symbol.for(`logtape.rootLogger`);var c=class e{parent;children;category;sinks;parentSinks=`inherit`;filters;lowestLevel=`trace`;contextLocalStorage;static getLogger(t=[]){let n=s in globalThis?globalThis[s]??null:null;return n??(n=new e(null,[]),globalThis[s]=n),typeof t==`string`?n.getChild(t):t.length===0?n:n.getChild(t)}constructor(e,t){this.parent=e,this.children={},this.category=t,this.sinks=[],this.filters=[]}getChild(t){let n=typeof t==`string`?t:t[0],r=this.children[n],i=r instanceof e?r:r?.deref();return i??(i=new e(this,[...this.category,n]),this.children[n]=`WeakRef`in globalThis?new WeakRef(i):i),typeof t==`string`||t.length===1?i:i.getChild(t.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks=`inherit`;this.filters.length>0;)this.filters.shift();this.lowestLevel=`trace`}resetDescendants(){for(let t of Object.values(this.children))(t instanceof e?t:t.deref())?.resetDescendants();this.reset()}with(e){return new l(this,{...e})}filter(e){for(let t of this.filters)if(!t(e))return!1;return this.filters.length<1?this.parent?.filter(e)??!0:!0}*getSinks(e){if(!(this.lowestLevel===null||a(e,this.lowestLevel)<0)){if(this.parent!=null&&this.parentSinks===`inherit`)for(let t of this.parent.getSinks(e))yield t;for(let e of this.sinks)yield e}}emit(e,t){let n=y(),r=`category`in e?e.category:this.category,i=n.length>0?[...n,...r]:r,o=Object.getOwnPropertyDescriptors(e);o.category={value:i,enumerable:!0,configurable:!0};let s=Object.defineProperties({},o);if(!(this.lowestLevel===null||a(s.level,this.lowestLevel)<0||!this.filter(s))){for(let e of this.getSinks(s.level))if(!t?.has(e))try{e(s)}catch(n){let r=new Set(t);r.add(e),u.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:e,error:n,record:s},r)}}}log(e,t,n,r){let i=b(),a,o=typeof n==`function`?{category:this.category,level:e,timestamp:Date.now(),get message(){return g(t,this.properties)},rawMessage:t,get properties(){return a??={...i,...n()},a}}:{category:this.category,level:e,timestamp:Date.now(),message:g(t,{...i,...n}),rawMessage:t,properties:{...i,...n}};this.emit(o,r)}logLazily(e,t,n={}){let r=b(),i,a;function o(){if((a==null||i==null)&&(a=t((e,...t)=>(i=e,_(e,t))),i==null))throw TypeError(`No log record was made.`);return[a,i]}this.emit({category:this.category,level:e,get message(){return o()[0]},get rawMessage(){return o()[1]},timestamp:Date.now(),properties:{...r,...n}})}logTemplate(e,t,n,r={}){let i=b();this.emit({category:this.category,level:e,message:_(t,n),rawMessage:t,timestamp:Date.now(),properties:{...i,...r}})}trace(e,...t){typeof e==`string`?this.log(`trace`,e,t[0]??{}):typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){typeof e==`string`?this.log(`debug`,e,t[0]??{}):typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){typeof e==`string`?this.log(`info`,e,t[0]??{}):typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){typeof e==`string`?this.log(`warning`,e,t[0]??{}):typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){this.warn(e,...t)}error(e,...t){typeof e==`string`?this.log(`error`,e,t[0]??{}):typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){typeof e==`string`?this.log(`fatal`,e,t[0]??{}):typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},l=class e{logger;properties;constructor(e,t){this.logger=e,this.properties=t}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(e){return this.logger.getChild(e).with(this.properties)}with(t){return new e(this.logger,{...this.properties,...t})}log(e,t,n,r){this.logger.log(e,t,typeof n==`function`?()=>({...this.properties,...n()}):{...this.properties,...n},r)}logLazily(e,t){this.logger.logLazily(e,t,this.properties)}logTemplate(e,t,n){this.logger.logTemplate(e,t,n,this.properties)}emit(e){let t={...e,properties:{...this.properties,...e.properties}};this.logger.emit(t)}trace(e,...t){typeof e==`string`?this.log(`trace`,e,t[0]??{}):typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){typeof e==`string`?this.log(`debug`,e,t[0]??{}):typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){typeof e==`string`?this.log(`info`,e,t[0]??{}):typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){typeof e==`string`?this.log(`warning`,e,t[0]??{}):typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){this.warn(e,...t)}error(e,...t){typeof e==`string`?this.log(`error`,e,t[0]??{}):typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){typeof e==`string`?this.log(`fatal`,e,t[0]??{}):typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}};const u=c.getLogger([`logtape`,`meta`]);function d(e){return e.includes(`.`)||e.includes(`[`)||e.includes(`?.`)}function f(e,t){if(!(t===`__proto__`||t===`prototype`||t===`constructor`)&&(typeof e==`object`||typeof e==`function`)&&e!==null)return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function p(e,t){let n=e.length,r=t;if(r>=n)return null;let i;if(e[r]===`[`){if(r++,r>=n)return null;if(e[r]===`"`||e[r]===`'`){let t=e[r];r++;let a=``;for(;r<n&&e[r]!==t;)if(e[r]===`\\`){if(r++,r<n){let t=e[r];switch(t){case`n`:a+=`
|
|
2
|
-
`;break;case`t`:a+=` `;break;case`r`:a+=`\r`;break;case`b`:a+=`\b`;break;case`f`:a+=`\f`;break;case`v`:a+=`\v`;break;case`0`:a+=`\0`;break;case`\\`:a+=`\\`;break;case`"`:a+=`"`;break;case`'`:a+=`'`;break;case`u`:if(r+4<n){let n=e.slice(r+1,r+5),i=Number.parseInt(n,16);Number.isNaN(i)?a+=t:(a+=String.fromCharCode(i),r+=4)}else a+=t;break;default:a+=t}r++}}else a+=e[r],r++;if(r>=n)return null;i=a,r++}else{let t=r;for(;r<n&&e[r]!==`]`&&e[r]!==`'`&&e[r]!==`"`;)r++;if(r>=n)return null;let a=e.slice(t,r);if(a.length===0)return null;let o=Number(a);i=Number.isNaN(o)?a:o}for(;r<n&&e[r]!==`]`;)r++;r<n&&r++}else{let t=r;for(;r<n&&e[r]!==`.`&&e[r]!==`[`&&e[r]!==`?`&&e[r]!==`]`;)r++;if(i=e.slice(t,r),i.length===0)return null}return r<n&&e[r]===`.`&&r++,{segment:i,nextIndex:r}}function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
`};let t=e.message===`template`,n=e.properties??`nest:properties`,r;if(typeof e.categorySeparator==`function`)r=e.categorySeparator;else{let t=e.categorySeparator??`.`;r=e=>e.join(t)}let i;if(n===`flatten`)i=e=>e;else if(n.startsWith(`prepend:`)){let e=n.substring(8);if(e===``)throw TypeError(`Invalid properties option: ${JSON.stringify(n)}. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`);i=t=>{let n={};for(let r in t)n[`${e}${r}`]=t[r];return n}}else if(n.startsWith(`nest:`)){let e=n.substring(5);i=t=>({[e]:t})}else throw TypeError(`Invalid properties option: ${JSON.stringify(n)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let a;return a=t?e=>{if(typeof e.rawMessage==`string`)return e.rawMessage;let t=``;for(let n=0;n<e.rawMessage.length;n++)t+=n%2<1?e.rawMessage[n]:`{}`;return t}:e=>{let t=e.message.length;if(t===1)return e.message[0];let n=``;for(let r=0;r<t;r++)n+=r%2<1?e.message[r]:JSON.stringify(e.message[r]);return n},e=>JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:a(e),logger:r(e.category),...i(e.properties)})+`
|
|
6
|
-
`}F();const I={trace:`background-color: gray; color: white;`,debug:`background-color: gray; color: white;`,info:`background-color: white; color: black;`,warning:`background-color: orange; color: black;`,error:`background-color: red; color: white;`,fatal:`background-color: maroon; color: white;`};function L(e){let t=``,n=[];for(let r=0;r<e.message.length;r++)r%2==0?t+=e.message[r]:(t+=`%o`,n.push(e.message[r]));let r=new Date(e.timestamp);return[`%c${`${r.getUTCHours().toString().padStart(2,`0`)}:${r.getUTCMinutes().toString().padStart(2,`0`)}:${r.getUTCSeconds().toString().padStart(2,`0`)}.${r.getUTCMilliseconds().toString().padStart(3,`0`)}`} %c${C[e.level]}%c %c${e.category.join(`·`)} %c${t}`,`color: gray;`,I[e.level],`background-color: default;`,`color: gray;`,`color: default;`,...n]}function R(e={}){let t=e.formatter??L,n={trace:`debug`,debug:`debug`,info:`info`,warning:`warn`,error:`error`,fatal:`error`,...e.levelMap??{}},r=e.console??globalThis.console,i=e=>{let i=t(e),a=n[e.level];if(a===void 0)throw TypeError(`Invalid log level: ${e.level}.`);if(typeof i==`string`){let e=i.replace(/\r?\n$/,``);r[a](e)}else r[a](...i)};if(!e.nonBlocking)return i;let a=e.nonBlocking===!0?{}:e.nonBlocking,o=a.bufferSize??100,s=a.flushInterval??100,c=[],l=null,u=!1,d=!1,f=o*2;function p(){if(c.length===0)return;let e=c.splice(0);for(let t of e)try{i(t)}catch{}}function m(){d||(d=!0,setTimeout(()=>{d=!1,p()},0))}function h(){l!==null||u||(l=setInterval(()=>{p()},s))}let g=e=>{u||(c.length>=f&&c.shift(),c.push(e),c.length>=o?m():l===null&&h())};return g[Symbol.dispose]=()=>{u=!0,l!==null&&(clearInterval(l),l=null),p()},g}let z=null;const B=new Set,V=new Set,H=new Set;function U(e){return e.category.length===0||e.category.length===1&&e.category[0]===`logtape`||e.category.length===2&&e.category[0]===`logtape`&&e.category[1]===`meta`}function W(e){if(z!=null&&!e.reset)throw new X(`Already configured; if you want to reset, turn on the reset flag.`);if(H.size>0)throw new X(`Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().`);K();try{G(e,!1)}catch(e){throw e instanceof X&&K(),e}}function G(e,t){z=e;let r=!1,i=new Set;for(let t of e.loggers){U(t)&&(r=!0);let a=Array.isArray(t.category)?JSON.stringify(t.category):JSON.stringify([t.category]);if(i.has(a))throw new X(`Duplicate logger configuration for category: ${a}. Each category can only be configured once.`);i.add(a);let o=c.getLogger(t.category);for(let n of t.sinks??[]){let t=e.sinks[n];if(!t)throw new X(`Sink not found: ${n}.`);o.sinks.push(t)}o.parentSinks=t.parentSinks??`inherit`,t.lowestLevel!==void 0&&(o.lowestLevel=t.lowestLevel);for(let r of t.filters??[]){let t=e.filters?.[r];if(t===void 0)throw new X(`Filter not found: ${r}.`);o.filters.push(n(t))}B.add(o)}c.getLogger().contextLocalStorage=e.contextLocalStorage;for(let n of Object.values(e.sinks)){if(Symbol.asyncDispose in n)if(t)H.add(n);else throw new X(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&V.add(n)}for(let n of Object.values(e.filters??{}))if(!(n==null||typeof n==`string`)){if(Symbol.asyncDispose in n)if(t)H.add(n);else throw new X(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&V.add(n)}if(typeof globalThis.EdgeRuntime!=`string`&&`process`in globalThis&&!(`Deno`in globalThis)){let e=globalThis.process,n=e?.on;typeof n==`function`&&n.call(e,`exit`,t?J:Y)}else addEventListener(`unload`,t?J:Y);let a=c.getLogger([`logtape`,`meta`]);r||a.sinks.push(R()),a.info(`LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger purposes to log internal errors such as sink exceptions. If you are seeing this message, the meta logger is automatically configured. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.`,{metaLoggerCategory:[`logtape`,`meta`],dismissLevel:`info`})}function K(){Y(),q()}function q(){let e=c.getLogger([]);e.resetDescendants(),delete e.contextLocalStorage,B.clear(),z=null}async function J(){Y();let e=[];for(let t of H)e.push(t[Symbol.asyncDispose]()),H.delete(t);await Promise.all(e)}function Y(){for(let e of V)e[Symbol.dispose]();V.clear()}var X=class extends Error{constructor(e){super(e),this.name=`ConfigureError`}};export{o as a,k as i,R as n,P as r,W as t};
|
|
1
|
+
import{r as e}from"../../rolldown-runtime.mjs";import t from"node:util";function n(e){return typeof e==`function`?e:r(e)}function r(e){if(e==null)return()=>!1;if(e===`fatal`)return e=>e.level===`fatal`;if(e===`error`)return e=>e.level===`fatal`||e.level===`error`;if(e===`warning`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`;if(e===`info`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`;if(e===`debug`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`||e.level===`debug`;if(e===`trace`)return()=>!0;throw TypeError(`Invalid log level: ${e}.`)}const i=[`trace`,`debug`,`info`,`warning`,`error`,`fatal`];function a(e,t){let n=i.indexOf(e);if(n<0)throw TypeError(`Invalid log level: ${JSON.stringify(e)}.`);let r=i.indexOf(t);if(r<0)throw TypeError(`Invalid log level: ${JSON.stringify(t)}.`);return n-r}const o=Symbol.for(`logtape.lazy`);function s(e){return typeof e==`object`&&!!e&&o in e&&e[o]===!0}function c(e){let t={};for(let n in e){let r=e[n];t[n]=s(r)?r.getter():r}return t}function l(e=[]){return d.getLogger(e)}const u=Symbol.for(`logtape.rootLogger`);var d=class e{parent;children;category;sinks;parentSinks=`inherit`;filters;lowestLevel=`trace`;contextLocalStorage;static getLogger(t=[]){let n=u in globalThis?globalThis[u]??null:null;return n??(n=new e(null,[]),globalThis[u]=n),typeof t==`string`?n.getChild(t):t.length===0?n:n.getChild(t)}constructor(e,t){this.parent=e,this.children={},this.category=t,this.sinks=[],this.filters=[]}getChild(t){let n=typeof t==`string`?t:t[0],r=this.children[n],i=r instanceof e?r:r?.deref();return i??(i=new e(this,[...this.category,n]),this.children[n]=`WeakRef`in globalThis?new WeakRef(i):i),typeof t==`string`||t.length===1?i:i.getChild(t.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks=`inherit`;this.filters.length>0;)this.filters.shift();this.lowestLevel=`trace`}resetDescendants(){for(let t of Object.values(this.children))(t instanceof e?t:t.deref())?.resetDescendants();this.reset()}with(e){return new f(this,{...e})}filter(e){for(let t of this.filters)if(!t(e))return!1;return this.filters.length<1?this.parent?.filter(e)??!0:!0}*getSinks(e){if(!(this.lowestLevel===null||a(e,this.lowestLevel)<0)){if(this.parent!=null&&this.parentSinks===`inherit`)for(let t of this.parent.getSinks(e))yield t;for(let e of this.sinks)yield e}}isEnabledFor(e){if(this.lowestLevel===null||a(e,this.lowestLevel)<0)return!1;for(let t of this.getSinks(e))return!0;return!1}emit(e,t){let n=ee(),r=`category`in e?e.category:this.category,i=n.length>0?[...n,...r]:r,o=Object.getOwnPropertyDescriptors(e);o.category={value:i,enumerable:!0,configurable:!0};let s=Object.defineProperties({},o);if(!(this.lowestLevel===null||a(s.level,this.lowestLevel)<0||!this.filter(s))){for(let e of this.getSinks(s.level))if(!t?.has(e))try{e(s)}catch(n){let r=new Set(t);r.add(e),p.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:e,error:n,record:s},r)}}}log(e,t,n,r){let i=S(),a,o=typeof n==`function`?{category:this.category,level:e,timestamp:Date.now(),get message(){return y(t,this.properties)},rawMessage:t,get properties(){return a??={...i,...n()},a}}:{category:this.category,level:e,timestamp:Date.now(),message:y(t,{...i,...n}),rawMessage:t,properties:{...i,...n}};this.emit(o,r)}logLazily(e,t,n={}){let r=S(),i,a;function o(){if((a==null||i==null)&&(a=t((e,...t)=>(i=e,b(e,t))),i==null))throw TypeError(`No log record was made.`);return[a,i]}this.emit({category:this.category,level:e,get message(){return o()[0]},get rawMessage(){return o()[1]},timestamp:Date.now(),properties:{...r,...n}})}logTemplate(e,t,n,r={}){let i=S();this.emit({category:this.category,level:e,message:b(t,n),rawMessage:t,timestamp:Date.now(),properties:{...i,...r}})}trace(e,...t){if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`trace`)?n().then(t=>{this.log(`trace`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`trace`)?t.then(t=>{this.log(`trace`,e,t)}):Promise.resolve();this.log(`trace`,e,t);return}this.log(`trace`,e,n??{})}else typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`debug`)?n().then(t=>{this.log(`debug`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`debug`)?t.then(t=>{this.log(`debug`,e,t)}):Promise.resolve();this.log(`debug`,e,t);return}this.log(`debug`,e,n??{})}else typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`info`)?n().then(t=>{this.log(`info`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`info`)?t.then(t=>{this.log(`info`,e,t)}):Promise.resolve();this.log(`info`,e,t);return}this.log(`info`,e,n??{})}else typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){if(e instanceof Error)this.log(`warning`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`warning`)?n().then(t=>{this.log(`warning`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`warning`)?t.then(t=>{this.log(`warning`,e,t)}):Promise.resolve();this.log(`warning`,e,t);return}this.log(`warning`,e,n??{})}else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){if(e instanceof Error)this.log(`warning`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`warning`)?n().then(t=>{this.log(`warning`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`warning`)?t.then(t=>{this.log(`warning`,e,t)}):Promise.resolve();this.log(`warning`,e,t);return}this.log(`warning`,e,n??{})}else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}error(e,...t){if(e instanceof Error)this.log(`error`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`error`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`error`)?n().then(t=>{this.log(`error`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`error`)?t.then(t=>{this.log(`error`,e,t)}):Promise.resolve();this.log(`error`,e,t);return}this.log(`error`,e,n??{})}else typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){if(e instanceof Error)this.log(`fatal`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`fatal`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`fatal`)?n().then(t=>{this.log(`fatal`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`fatal`)?t.then(t=>{this.log(`fatal`,e,t)}):Promise.resolve();this.log(`fatal`,e,t);return}this.log(`fatal`,e,n??{})}else typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},f=class e{logger;properties;constructor(e,t){this.logger=e,this.properties=t}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(e){return this.logger.getChild(e).with(this.properties)}with(t){return new e(this.logger,{...this.properties,...t})}log(e,t,n,r){let i=this.properties;this.logger.log(e,t,typeof n==`function`?()=>c({...i,...n()}):()=>c({...i,...n}),r)}logLazily(e,t){this.logger.logLazily(e,t,c(this.properties))}logTemplate(e,t,n){this.logger.logTemplate(e,t,n,c(this.properties))}emit(e){let t={...e,properties:c({...this.properties,...e.properties})};this.logger.emit(t)}isEnabledFor(e){return this.logger.isEnabledFor(e)}trace(e,...t){if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`trace`)?n().then(t=>{this.log(`trace`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`trace`)?t.then(t=>{this.log(`trace`,e,t)}):Promise.resolve();this.log(`trace`,e,t);return}this.log(`trace`,e,n??{})}else typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`debug`)?n().then(t=>{this.log(`debug`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`debug`)?t.then(t=>{this.log(`debug`,e,t)}):Promise.resolve();this.log(`debug`,e,t);return}this.log(`debug`,e,n??{})}else typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`info`)?n().then(t=>{this.log(`info`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`info`)?t.then(t=>{this.log(`info`,e,t)}):Promise.resolve();this.log(`info`,e,t);return}this.log(`info`,e,n??{})}else typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){if(e instanceof Error)this.log(`warning`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`warning`)?n().then(t=>{this.log(`warning`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`warning`)?t.then(t=>{this.log(`warning`,e,t)}):Promise.resolve();this.log(`warning`,e,t);return}this.log(`warning`,e,n??{})}else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){if(e instanceof Error)this.log(`warning`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`warning`)?n().then(t=>{this.log(`warning`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`warning`)?t.then(t=>{this.log(`warning`,e,t)}):Promise.resolve();this.log(`warning`,e,t);return}this.log(`warning`,e,n??{})}else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}error(e,...t){if(e instanceof Error)this.log(`error`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`error`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`error`)?n().then(t=>{this.log(`error`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`error`)?t.then(t=>{this.log(`error`,e,t)}):Promise.resolve();this.log(`error`,e,t);return}this.log(`error`,e,n??{})}else typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){if(e instanceof Error)this.log(`fatal`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`fatal`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`fatal`)?n().then(t=>{this.log(`fatal`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`fatal`)?t.then(t=>{this.log(`fatal`,e,t)}):Promise.resolve();this.log(`fatal`,e,t);return}this.log(`fatal`,e,n??{})}else typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}};const p=d.getLogger([`logtape`,`meta`]);function m(e){return e.includes(`.`)||e.includes(`[`)||e.includes(`?.`)}function h(e,t){if(!(t===`__proto__`||t===`prototype`||t===`constructor`)&&(typeof e==`object`||typeof e==`function`)&&e!==null)return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function g(e,t){let n=e.length,r=t;if(r>=n)return null;let i;if(e[r]===`[`){if(r++,r>=n)return null;if(e[r]===`"`||e[r]===`'`){let t=e[r];r++;let a=``;for(;r<n&&e[r]!==t;)if(e[r]===`\\`){if(r++,r<n){let t=e[r];switch(t){case`n`:a+=`
|
|
2
|
+
`;break;case`t`:a+=` `;break;case`r`:a+=`\r`;break;case`b`:a+=`\b`;break;case`f`:a+=`\f`;break;case`v`:a+=`\v`;break;case`0`:a+=`\0`;break;case`\\`:a+=`\\`;break;case`"`:a+=`"`;break;case`'`:a+=`'`;break;case`u`:if(r+4<n){let n=e.slice(r+1,r+5),i=Number.parseInt(n,16);Number.isNaN(i)?a+=t:(a+=String.fromCharCode(i),r+=4)}else a+=t;break;default:a+=t}r++}}else a+=e[r],r++;if(r>=n)return null;i=a,r++}else{let t=r;for(;r<n&&e[r]!==`]`&&e[r]!==`'`&&e[r]!==`"`;)r++;if(r>=n)return null;let a=e.slice(t,r);if(a.length===0)return null;let o=Number(a);i=Number.isNaN(o)?a:o}for(;r<n&&e[r]!==`]`;)r++;r<n&&r++}else{let t=r;for(;r<n&&e[r]!==`.`&&e[r]!==`[`&&e[r]!==`?`&&e[r]!==`]`;)r++;if(i=e.slice(t,r),i.length===0)return null}return r<n&&e[r]===`.`&&r++,{segment:i,nextIndex:r}}function _(e,t){if(typeof t==`string`)return h(e,t);if(Array.isArray(e)&&t>=0&&t<e.length)return e[t]}function v(e,t){if(e==null||t.length===0||t.endsWith(`.`))return;let n=e,r=0,i=t.length;for(;r<i;){if(t.slice(r,r+2)===`?.`){if(r+=2,n==null)return}else if(n==null)return;let e=g(t,r);if(e===null)return;let{segment:i,nextIndex:a}=e;if(r=a,n=_(n,i),n===void 0)return}return n}function y(e,t){let n=e.length;if(n===0)return[``];if(!e.includes(`{`))return[e];let r=[],i=0;for(let a=0;a<n;a++){let o=e[a];if(o===`{`){if((a+1<n?e[a+1]:``)===`{`){a++;continue}let o=e.indexOf(`}`,a+1);if(o===-1)continue;let s=e.slice(i,a);r.push(s.replace(/{{/g,`{`).replace(/}}/g,`}`));let c=e.slice(a+1,o),l,u=c.trim();u===`*`?l=c in t?t[c]:`*`in t?t[`*`]:t:(l=c===u||c in t?t[c]:t[u],l===void 0&&m(u)&&(l=v(t,u))),r.push(l),a=o,i=a+1}else o===`}`&&a+1<n&&e[a+1]===`}`&&a++}let a=e.slice(i);return r.push(a.replace(/{{/g,`{`).replace(/}}/g,`}`)),r}function b(e,t){let n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<t.length&&n.push(t[r]);return n}const x=Symbol.for(`logtape.categoryPrefix`);function ee(){let e=d.getLogger().contextLocalStorage?.getStore();if(e==null)return[];let t=e[x];return Array.isArray(t)?t:[]}function S(){let e=d.getLogger().contextLocalStorage?.getStore();if(e==null)return{};let t={};for(let n of Object.keys(e))t[n]=e[n];return t}var C=e({inspect:()=>w});function w(e,n){return t.inspect(e,n)}const T={trace:`TRC`,debug:`DBG`,info:`INF`,warning:`WRN`,error:`ERR`,fatal:`FTL`},E=typeof document<`u`||typeof navigator<`u`&&navigator.product===`ReactNative`?e=>JSON.stringify(e):`Deno`in globalThis&&`inspect`in globalThis.Deno&&typeof globalThis.Deno.inspect==`function`?(e,t)=>globalThis.Deno.inspect(e,{strAbbreviateSize:1/0,iterableLimit:1/0,...t}):C!=null&&`inspect`in C&&typeof w==`function`?(e,t)=>w(e,{maxArrayLength:1/0,maxStringLength:1/0,...t}):e=>JSON.stringify(e);function D(e){return e<10?`0${e}`:`${e}`}function O(e){return e<10?`00${e}`:e<100?`0${e}`:`${e}`}const k={"date-time-timezone":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${D(t.getUTCMonth()+1)}-${D(t.getUTCDate())} ${D(t.getUTCHours())}:${D(t.getUTCMinutes())}:${D(t.getUTCSeconds())}.${O(t.getUTCMilliseconds())} +00:00`},"date-time-tz":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${D(t.getUTCMonth()+1)}-${D(t.getUTCDate())} ${D(t.getUTCHours())}:${D(t.getUTCMinutes())}:${D(t.getUTCSeconds())}.${O(t.getUTCMilliseconds())} +00`},"date-time":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${D(t.getUTCMonth()+1)}-${D(t.getUTCDate())} ${D(t.getUTCHours())}:${D(t.getUTCMinutes())}:${D(t.getUTCSeconds())}.${O(t.getUTCMilliseconds())}`},"time-timezone":e=>{let t=new Date(e);return`${D(t.getUTCHours())}:${D(t.getUTCMinutes())}:${D(t.getUTCSeconds())}.${O(t.getUTCMilliseconds())} +00:00`},"time-tz":e=>{let t=new Date(e);return`${D(t.getUTCHours())}:${D(t.getUTCMinutes())}:${D(t.getUTCSeconds())}.${O(t.getUTCMilliseconds())} +00`},time:e=>{let t=new Date(e);return`${D(t.getUTCHours())}:${D(t.getUTCMinutes())}:${D(t.getUTCSeconds())}.${O(t.getUTCMilliseconds())}`},date:e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${D(t.getUTCMonth()+1)}-${D(t.getUTCDate())}`},rfc3339:e=>new Date(e).toISOString(),none:()=>null},A={ABBR:T,abbr:{trace:`trc`,debug:`dbg`,info:`inf`,warning:`wrn`,error:`err`,fatal:`ftl`},FULL:{trace:`TRACE`,debug:`DEBUG`,info:`INFO`,warning:`WARNING`,error:`ERROR`,fatal:`FATAL`},full:{trace:`trace`,debug:`debug`,info:`info`,warning:`warning`,error:`error`,fatal:`fatal`},L:{trace:`T`,debug:`D`,info:`I`,warning:`W`,error:`E`,fatal:`F`},l:{trace:`t`,debug:`d`,info:`i`,warning:`w`,error:`e`,fatal:`f`}};function j(e){return e===`crlf`?`\r
|
|
3
|
+
`:`
|
|
4
|
+
`}function M(e,t){if(!(t instanceof Error))return t;let n={name:t.name,message:t.message};typeof t.stack==`string`&&(n.stack=t.stack);let r=t.cause;r!==void 0&&(n.cause=r),typeof AggregateError<`u`&&t instanceof AggregateError&&(n.errors=t.errors);for(let e of Object.keys(t))e in n||(n[e]=t[e]);return n}function N(e={}){let t=(()=>{let t=e.timestamp;return t==null?k[`date-time-timezone`]:t===`disabled`?k.none:typeof t==`string`&&t in k?k[t]:t})(),n=e.category??`·`,r=e.value?t=>e.value(t,E):E,i=(()=>{let t=e.level;return t==null||t===`ABBR`?e=>A.ABBR[e]:t===`abbr`?e=>A.abbr[e]:t===`FULL`?e=>A.FULL[e]:t===`full`?e=>A.full[e]:t===`L`?e=>A.L[e]:t===`l`?e=>A.l[e]:t})(),a=j(e.lineEnding),o=e.format??(({timestamp:e,level:t,category:n,message:r})=>`${e?`${e} `:``}[${t}] ${n}: ${r}`);return e=>{let s=e.message,c=s.length,l;if(c===1)l=s[0];else if(c<=6){l=``;for(let e=0;e<c;e++)l+=e%2==0?s[e]:r(s[e])}else{let e=Array(c);for(let t=0;t<c;t++)e[t]=t%2==0?s[t]:r(s[t]);l=e.join(``)}return`${o({timestamp:t(e.timestamp),level:i(e.level),category:typeof n==`function`?n(e.category):e.category.join(n),message:l,record:e})}${a}`}}N();const P=`\x1B[0m`,F={black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`},I={bold:`\x1B[1m`,dim:`\x1B[2m`,italic:`\x1B[3m`,underline:`\x1B[4m`,strikethrough:`\x1B[9m`},L={trace:null,debug:`blue`,info:`green`,warning:`yellow`,error:`red`,fatal:`magenta`};function R(e={}){let t=e.format,n=e.timestampStyle===void 0?`dim`:e.timestampStyle,r=e.timestampColor??null,i=`${n==null?``:I[n]}${r==null?``:F[r]}`,a=n==null&&r==null?``:P,o=e.levelStyle===void 0?`bold`:e.levelStyle,s=e.levelColors??L,c=e.categoryStyle===void 0?`dim`:e.categoryStyle,l=e.categoryColor??null,u=`${c==null?``:I[c]}${l==null?``:F[l]}`,d=c==null&&l==null?``:P;return N({timestamp:`date-time-tz`,value(e,t){return t(e,{colors:!0})},...e,format({timestamp:e,level:n,category:r,message:c,record:l}){let f=s[l.level];return e=e==null?null:`${i}${e}${a}`,n=`${o==null?``:I[o]}${f==null?``:F[f]}${n}${o==null&&f==null?``:P}`,t==null?`${e==null?``:`${e} `}${n} ${u}${r}:${d} ${c}`:t({timestamp:e,level:n,category:`${u}${r}${d}`,message:c,record:l})}})}R();function z(e={}){let t=j(e.lineEnding);if(!e.categorySeparator&&!e.message&&!e.properties)return e=>{if(e.message.length===3)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0]+JSON.stringify(e.message[1])+e.message[2],logger:e.category.join(`.`),properties:e.properties},M)+t;if(e.message.length===1)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0],logger:e.category.join(`.`),properties:e.properties},M)+t;let n=e.message[0];for(let t=1;t<e.message.length;t++)n+=t&1?JSON.stringify(e.message[t]):e.message[t];return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:n,logger:e.category.join(`.`),properties:e.properties},M)+t};let n=e.message===`template`,r=e.properties??`nest:properties`,i;if(typeof e.categorySeparator==`function`)i=e.categorySeparator;else{let t=e.categorySeparator??`.`;i=e=>e.join(t)}let a;if(r===`flatten`)a=e=>e;else if(r.startsWith(`prepend:`)){let e=r.substring(8);if(e===``)throw TypeError(`Invalid properties option: ${JSON.stringify(r)}. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`);a=t=>{let n={};for(let r in t)n[`${e}${r}`]=t[r];return n}}else if(r.startsWith(`nest:`)){let e=r.substring(5);a=t=>({[e]:t})}else throw TypeError(`Invalid properties option: ${JSON.stringify(r)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let o;return o=n?e=>{if(typeof e.rawMessage==`string`)return e.rawMessage;let t=``;for(let n=0;n<e.rawMessage.length;n++)t+=n%2<1?e.rawMessage[n]:`{}`;return t}:e=>{let t=e.message.length;if(t===1)return e.message[0];let n=``;for(let r=0;r<t;r++)n+=r%2<1?e.message[r]:JSON.stringify(e.message[r]);return n},e=>JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:o(e),logger:i(e.category),...a(e.properties)},M)+t}z();const B={trace:`background-color: gray; color: white;`,debug:`background-color: gray; color: white;`,info:`background-color: white; color: black;`,warning:`background-color: orange; color: black;`,error:`background-color: red; color: white;`,fatal:`background-color: maroon; color: white;`};function V(e){let t=``,n=[];for(let r=0;r<e.message.length;r++)r%2==0?t+=e.message[r]:(t+=`%o`,n.push(e.message[r]));let r=new Date(e.timestamp);return[`%c${`${r.getUTCHours().toString().padStart(2,`0`)}:${r.getUTCMinutes().toString().padStart(2,`0`)}:${r.getUTCSeconds().toString().padStart(2,`0`)}.${r.getUTCMilliseconds().toString().padStart(3,`0`)}`} %c${T[e.level]}%c %c${e.category.join(`·`)} %c${t}`,`color: gray;`,B[e.level],`background-color: default;`,`color: gray;`,`color: default;`,...n]}function H(e={}){let t=e.formatter??V,n={trace:`debug`,debug:`debug`,info:`info`,warning:`warn`,error:`error`,fatal:`error`,...e.levelMap??{}},r=e.console??globalThis.console,i=e=>{let i=t(e),a=n[e.level];if(a===void 0)throw TypeError(`Invalid log level: ${e.level}.`);if(typeof i==`string`){let e=i.replace(/\r?\n$/,``);r[a](e)}else r[a](...i)};if(!e.nonBlocking)return i;let a=e.nonBlocking===!0?{}:e.nonBlocking,o=a.bufferSize??100,s=a.flushInterval??100,c=[],l=null,u=!1,d=!1,f=o*2;function p(){if(c.length===0)return;let e=c.splice(0);for(let t of e)try{i(t)}catch{}}function m(){d||(d=!0,setTimeout(()=>{d=!1,p()},0))}function h(){l!==null||u||(l=setInterval(()=>{p()},s))}let g=e=>{u||(c.length>=f&&c.shift(),c.push(e),c.length>=o?m():l===null&&h())};return g[Symbol.dispose]=()=>{u=!0,l!==null&&(clearInterval(l),l=null),p()},g}let U=null;const W=new Set,G=new Set,K=new Set;function q(e){return e.category.length===0||e.category.length===1&&e.category[0]===`logtape`||e.category.length===2&&e.category[0]===`logtape`&&e.category[1]===`meta`}function J(e){if(U!=null&&!e.reset)throw new $(`Already configured; if you want to reset, turn on the reset flag.`);if(K.size>0)throw new $(`Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().`);X();try{Y(e,!1)}catch(e){throw e instanceof $&&X(),e}}function Y(e,t){U=e;let r=!1,i=new Set;for(let t of e.loggers){q(t)&&(r=!0);let a=Array.isArray(t.category)?JSON.stringify(t.category):JSON.stringify([t.category]);if(i.has(a))throw new $(`Duplicate logger configuration for category: ${a}. Each category can only be configured once.`);i.add(a);let o=d.getLogger(t.category);for(let n of t.sinks??[]){let t=e.sinks[n];if(!t)throw new $(`Sink not found: ${n}.`);o.sinks.push(t)}o.parentSinks=t.parentSinks??`inherit`,t.lowestLevel!==void 0&&(o.lowestLevel=t.lowestLevel);for(let r of t.filters??[]){let t=e.filters?.[r];if(t===void 0)throw new $(`Filter not found: ${r}.`);o.filters.push(n(t))}W.add(o)}d.getLogger().contextLocalStorage=e.contextLocalStorage;for(let n of Object.values(e.sinks)){if(Symbol.asyncDispose in n)if(t)K.add(n);else throw new $(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&G.add(n)}for(let n of Object.values(e.filters??{}))if(!(n==null||typeof n==`string`)){if(Symbol.asyncDispose in n)if(t)K.add(n);else throw new $(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&G.add(n)}if(typeof globalThis.EdgeRuntime!=`string`&&`process`in globalThis&&!(`Deno`in globalThis)){let e=globalThis.process,n=e?.on;typeof n==`function`&&n.call(e,`exit`,t?Z:Q)}else `Deno`in globalThis?addEventListener(`unload`,t?Z:Q):addEventListener(`pagehide`,t?Z:Q);let a=d.getLogger([`logtape`,`meta`]);r||a.sinks.push(H()),a.info(`LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger is used to log internal diagnostics such as sink exceptions. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.`,{metaLoggerCategory:[`logtape`,`meta`],dismissLevel:`info`})}function X(){Q(),te()}function te(){let e=d.getLogger([]);e.resetDescendants(),delete e.contextLocalStorage,W.clear(),U=null}async function Z(){Q();let e=[];for(let t of K)e.push(t[Symbol.asyncDispose]()),K.delete(t);await Promise.all(e)}function Q(){for(let e of G)e[Symbol.dispose]();G.clear()}var $=class extends Error{constructor(e){super(e),this.name=`ConfigureError`}};export{l as a,N as i,H as n,R as r,J as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,t=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,n=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function r(e,t){if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){i(e);return}return t}function i(e){console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`)}function a(i,a={}){if(typeof i!=`string`)return i;if(i[0]===`"`&&i[i.length-1]===`"`&&i.indexOf(`\\`)===-1)return i.slice(1,-1);let o=i.trim();if(o.length<=9)switch(o.toLowerCase()){case`true`:return!0;case`false`:return!1;case`undefined`:return;case`null`:return null;case`nan`:return NaN;case`infinity`:return 1/0;case`-infinity`:return-1/0}if(!n.test(i)){if(a.strict)throw SyntaxError(`[destr] Invalid JSON`);return i}try{if(e.test(i)||t.test(i)){if(a.strict)throw Error(`[destr] Possible prototype pollution`);return JSON.parse(i,r)}return JSON.parse(i)}catch(e){if(a.strict)throw e;return i}}export{a as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const{getOwnPropertyNames:e,getOwnPropertySymbols:t}=Object,{hasOwnProperty:n}=Object.prototype;function r(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function i(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function a(n){return e(n).concat(t(n))}const o=Object.hasOwn||((e,t)=>n.call(e,t)),{getOwnPropertyDescriptor:s,keys:c}=Object,l=Object.is||function(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t};function u(e,t){return e===t}function d(e,t){return e.byteLength===t.byteLength&&S(new Uint8Array(e),new Uint8Array(t))}function f(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function p(e,t){return e.byteLength===t.byteLength&&S(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function m(e,t){return l(e.getTime(),t.getTime())}function h(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function g(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}function _(e,t,n){let r=c(e),i=r.length;if(c(t).length!==i)return!1;for(;i-- >0;)if(!w(e,t,n,r[i]))return!1;return!0}function v(e,t,n){let r=a(e),i=r.length;if(a(t).length!==i)return!1;let o,c,l;for(;i-- >0;)if(o=r[i],!w(e,t,n,o)||(c=s(e,o),l=s(t,o),(c||l)&&(!c||!l||c.configurable!==l.configurable||c.enumerable!==l.enumerable||c.writable!==l.writable)))return!1;return!0}function y(e,t){return l(e.valueOf(),t.valueOf())}function b(e,t){return e.source===t.source&&e.flags===t.flags}function x(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function S(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function C(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function w(e,t,n,r){return(r===`_owner`||r===`__o`||r===`__v`)&&(e.$$typeof||t.$$typeof)?!0:o(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}const T=Object.prototype.toString;function E(e){let t=A(e),{areArraysEqual:n,areDatesEqual:r,areFunctionsEqual:i,areMapsEqual:a,areNumbersEqual:o,areObjectsEqual:s,areRegExpsEqual:c,areSetsEqual:l,getUnsupportedCustomComparator:u}=e;return function(e,d,f){if(e===d)return!0;if(e==null||d==null)return!1;let p=typeof e;if(p!==typeof d)return!1;if(p!==`object`)return p===`number`||p===`bigint`?o(e,d,f):p===`function`?i(e,d,f):!1;let m=e.constructor;if(m!==d.constructor)return!1;if(m===Object)return s(e,d,f);if(m===Array)return n(e,d,f);if(m===Date)return r(e,d,f);if(m===RegExp)return c(e,d,f);if(m===Map)return a(e,d,f);if(m===Set)return l(e,d,f);if(m===Promise)return!1;if(Array.isArray(e))return n(e,d,f);let h=T.call(e),g=t[h];if(g)return g(e,d,f);let _=u&&u(e,d,f,h);return _?_(e,d,f):!1}}function D({circular:e,createCustomConfig:t,strict:n}){let a={areArrayBuffersEqual:d,areArraysEqual:n?v:f,areDataViewsEqual:p,areDatesEqual:m,areErrorsEqual:h,areFunctionsEqual:u,areMapsEqual:n?r(g,v):g,areNumbersEqual:l,areObjectsEqual:n?v:_,arePrimitiveWrappersEqual:y,areRegExpsEqual:b,areSetsEqual:n?r(x,v):x,areTypedArraysEqual:n?r(S,v):S,areUrlsEqual:C,getUnsupportedCustomComparator:void 0};if(t&&(a=Object.assign({},a,t(a))),e){let e=i(a.areArraysEqual),t=i(a.areMapsEqual),n=i(a.areObjectsEqual),r=i(a.areSetsEqual);a=Object.assign({},a,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:r})}return a}function O(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function k({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}function A({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p}){return{"[object Arguments]":c,"[object Array]":t,"[object ArrayBuffer]":e,"[object AsyncGeneratorFunction]":a,"[object BigInt]":s,"[object BigInt64Array]":f,"[object BigUint64Array]":f,"[object Boolean]":l,"[object DataView]":n,"[object Date]":r,"[object Error]":i,"[object Float16Array]":f,"[object Float32Array]":f,"[object Float64Array]":f,"[object Function]":a,"[object GeneratorFunction]":a,"[object Int8Array]":f,"[object Int16Array]":f,"[object Int32Array]":f,"[object Map]":o,"[object Number]":l,"[object Object]":(e,t,n)=>typeof e.then!=`function`&&typeof t.then!=`function`&&c(e,t,n),"[object RegExp]":u,"[object Set]":d,"[object String]":l,"[object URL]":p,"[object Uint8Array]":f,"[object Uint8ClampedArray]":f,"[object Uint16Array]":f,"[object Uint32Array]":f}}
|
|
1
|
+
const{getOwnPropertyNames:e,getOwnPropertySymbols:t}=Object,{hasOwnProperty:n}=Object.prototype;function r(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function i(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function a(n){return e(n).concat(t(n))}const o=Object.hasOwn||((e,t)=>n.call(e,t)),{getOwnPropertyDescriptor:s,keys:c}=Object,l=Object.is||function(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t};function u(e,t){return e===t}function d(e,t){return e.byteLength===t.byteLength&&S(new Uint8Array(e),new Uint8Array(t))}function f(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function p(e,t){return e.byteLength===t.byteLength&&S(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function m(e,t){return l(e.getTime(),t.getTime())}function h(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function g(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}function _(e,t,n){let r=c(e),i=r.length;if(c(t).length!==i)return!1;for(;i-- >0;)if(!w(e,t,n,r[i]))return!1;return!0}function v(e,t,n){let r=a(e),i=r.length;if(a(t).length!==i)return!1;let o,c,l;for(;i-- >0;)if(o=r[i],!w(e,t,n,o)||(c=s(e,o),l=s(t,o),(c||l)&&(!c||!l||c.configurable!==l.configurable||c.enumerable!==l.enumerable||c.writable!==l.writable)))return!1;return!0}function y(e,t){return l(e.valueOf(),t.valueOf())}function b(e,t){return e.source===t.source&&e.flags===t.flags}function x(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function S(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function C(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function w(e,t,n,r){return(r===`_owner`||r===`__o`||r===`__v`)&&(e.$$typeof||t.$$typeof)?!0:o(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}const T=Object.prototype.toString;function E(e){let t=A(e),{areArraysEqual:n,areDatesEqual:r,areFunctionsEqual:i,areMapsEqual:a,areNumbersEqual:o,areObjectsEqual:s,areRegExpsEqual:c,areSetsEqual:l,getUnsupportedCustomComparator:u}=e;return function(e,d,f){if(e===d)return!0;if(e==null||d==null)return!1;let p=typeof e;if(p!==typeof d)return!1;if(p!==`object`)return p===`number`||p===`bigint`?o(e,d,f):p===`function`?i(e,d,f):!1;let m=e.constructor;if(m!==d.constructor)return!1;if(m===Object)return s(e,d,f);if(m===Array)return n(e,d,f);if(m===Date)return r(e,d,f);if(m===RegExp)return c(e,d,f);if(m===Map)return a(e,d,f);if(m===Set)return l(e,d,f);if(m===Promise)return!1;if(Array.isArray(e))return n(e,d,f);let h=T.call(e),g=t[h];if(g)return g(e,d,f);let _=u&&u(e,d,f,h);return _?_(e,d,f):!1}}function D({circular:e,createCustomConfig:t,strict:n}){let a={areArrayBuffersEqual:d,areArraysEqual:n?v:f,areDataViewsEqual:p,areDatesEqual:m,areErrorsEqual:h,areFunctionsEqual:u,areMapsEqual:n?r(g,v):g,areNumbersEqual:l,areObjectsEqual:n?v:_,arePrimitiveWrappersEqual:y,areRegExpsEqual:b,areSetsEqual:n?r(x,v):x,areTypedArraysEqual:n?r(S,v):S,areUrlsEqual:C,getUnsupportedCustomComparator:void 0};if(t&&(a=Object.assign({},a,t(a))),e){let e=i(a.areArraysEqual),t=i(a.areMapsEqual),n=i(a.areObjectsEqual),r=i(a.areSetsEqual);a=Object.assign({},a,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:r})}return a}function O(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function k({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}function A({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p}){return{"[object Arguments]":c,"[object Array]":t,"[object ArrayBuffer]":e,"[object AsyncGeneratorFunction]":a,"[object BigInt]":s,"[object BigInt64Array]":f,"[object BigUint64Array]":f,"[object Boolean]":l,"[object DataView]":n,"[object Date]":r,"[object Error]":i,"[object Float16Array]":f,"[object Float32Array]":f,"[object Float64Array]":f,"[object Function]":a,"[object GeneratorFunction]":a,"[object Int8Array]":f,"[object Int16Array]":f,"[object Int32Array]":f,"[object Map]":o,"[object Number]":l,"[object Object]":(e,t,n)=>typeof e.then!=`function`&&typeof t.then!=`function`&&c(e,t,n),"[object RegExp]":u,"[object Set]":d,"[object String]":l,"[object URL]":p,"[object Uint8Array]":f,"[object Uint8ClampedArray]":f,"[object Uint16Array]":f,"[object Uint32Array]":f}}j(),j({strict:!0}),j({circular:!0}),j({circular:!0,strict:!0}),j({createInternalComparator:()=>l}),j({strict:!0,createInternalComparator:()=>l}),j({circular:!0,createInternalComparator:()=>l}),j({circular:!0,createInternalComparator:()=>l,strict:!0});function j(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=E(D(e));return k({circular:t,comparator:a,createState:r,equals:n?n(a):O(a),strict:i})}export{};
|
|
@@ -27,4 +27,4 @@ import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"../rolldown-runtime.mjs"
|
|
|
27
27
|
`.includes(e[t-1])}matchWhitespace(e,t,n,r){this.whitespaceRegExp.lastIndex=t;let i=this.whitespaceRegExp.exec(e);return{currIndentLevel:i?.[0].length??0,prevIndentLevel:this.indentationStack.at(-1),match:i}}createIndentationTokenInstance(e,t,n,r){let i=this.getLineNumber(t,r);return u(e,n,r,r+n.length,i,i,1,n.length)}getLineNumber(e,t){return e.substring(0,t).split(/\r\n|\r|\n/).length}indentMatcher(e,t,n,r){if(!this.isStartOfLine(e,t))return null;let{currIndentLevel:i,prevIndentLevel:a,match:o}=this.matchWhitespace(e,t,n,r);return i<=a?null:(this.indentationStack.push(i),o)}dedentMatcher(e,t,n,r){if(!this.isStartOfLine(e,t))return null;let{currIndentLevel:i,prevIndentLevel:a,match:o}=this.matchWhitespace(e,t,n,r);if(i>=a)return null;let s=this.indentationStack.lastIndexOf(i);if(s===-1)return this.diagnostics.push({severity:`error`,message:`Invalid dedent level ${i} at offset: ${t}. Current indentation stack: ${this.indentationStack}`,offset:t,length:o?.[0]?.length??0,line:this.getLineNumber(e,t),column:1}),null;let c=this.indentationStack.length-s-1,l=e.substring(0,t).match(/[\r\n]+$/)?.[0].length??1;for(let r=0;r<c;r++){let r=this.createIndentationTokenInstance(this.dedentTokenType,e,``,t-(l-1));n.push(r),this.indentationStack.pop()}return null}buildTerminalToken(e){let t=super.buildTerminalToken(e),{indentTokenName:n,dedentTokenName:r,whitespaceTokenName:i}=this.options;return t.name===n?this.indentTokenType:t.name===r?this.dedentTokenType:t.name===i?g({name:i,pattern:this.whitespaceRegExp,group:d.SKIPPED}):t}flushRemainingDedents(e){let t=[];for(;this.indentationStack.length>1;)t.push(this.createIndentationTokenInstance(this.dedentTokenType,e,``,e.length)),this.indentationStack.pop();return this.indentationStack=[0],t}},Gc=class extends Rc{constructor(e){if(super(e),e.parser.TokenBuilder instanceof Wc)this.indentationTokenBuilder=e.parser.TokenBuilder;else throw Error(`IndentationAwareLexer requires an accompanying IndentationAwareTokenBuilder`)}tokenize(e,t=Lc){let n=super.tokenize(e),r=n.report;t?.mode===`full`&&n.tokens.push(...r.remainingDedents),r.remainingDedents=[];let{indentTokenType:i,dedentTokenType:a}=this.indentationTokenBuilder,o=i.tokenTypeIdx,s=a.tokenTypeIdx,c=[],l=n.tokens.length-1;for(let e=0;e<l;e++){let t=n.tokens[e],r=n.tokens[e+1];if(t.tokenTypeIdx===o&&r.tokenTypeIdx===s){e++;continue}c.push(t)}return l>=0&&c.push(n.tokens[l]),n.tokens=c,n}},Kc=class{constructor(e){this.grammarElementIdMap=new Ps,this.tokenTypeIdMap=new Ps,this.grammar=e.Grammar,this.lexer=e.parser.Lexer,this.linker=e.references.Linker}dehydrate(e){return{lexerErrors:e.lexerErrors,lexerReport:e.lexerReport?this.dehydrateLexerReport(e.lexerReport):void 0,parserErrors:e.parserErrors.map(e=>Object.assign(Object.assign({},e),{message:e.message})),value:this.dehydrateAstNode(e.value,this.createDehyrationContext(e.value))}}dehydrateLexerReport(e){return e}createDehyrationContext(e){let t=new Map,n=new Map;for(let n of na(e))t.set(n,{});if(e.$cstNode)for(let t of Di(e.$cstNode))n.set(t,{});return{astNodes:t,cstNodes:n}}dehydrateAstNode(e,t){let n=t.astNodes.get(e);n.$type=e.$type,n.$containerIndex=e.$containerIndex,n.$containerProperty=e.$containerProperty,e.$cstNode!==void 0&&(n.$cstNode=this.dehydrateCstNode(e.$cstNode,t));for(let[r,i]of Object.entries(e))if(!r.startsWith(`$`))if(Array.isArray(i)){let e=[];n[r]=e;for(let n of i)U(n)?e.push(this.dehydrateAstNode(n,t)):Tn(n)?e.push(this.dehydrateReference(n,t)):e.push(n)}else U(i)?n[r]=this.dehydrateAstNode(i,t):Tn(i)?n[r]=this.dehydrateReference(i,t):i!==void 0&&(n[r]=i);return n}dehydrateReference(e,t){let n={};return n.$refText=e.$refText,e.$refNode&&(n.$refNode=t.cstNodes.get(e.$refNode)),n}dehydrateCstNode(e,t){let n=t.cstNodes.get(e);return jn(e)?n.fullText=e.fullText:n.grammarSource=this.getGrammarElementId(e.grammarSource),n.hidden=e.hidden,n.astNode=t.astNodes.get(e.astNode),kn(e)?n.content=e.content.map(e=>this.dehydrateCstNode(e,t)):An(e)&&(n.tokenType=e.tokenType.name,n.offset=e.offset,n.length=e.length,n.startLine=e.range.start.line,n.startColumn=e.range.start.character,n.endLine=e.range.end.line,n.endColumn=e.range.end.character),n}hydrate(e){let t=e.value,n=this.createHydrationContext(t);return`$cstNode`in t&&this.hydrateCstNode(t.$cstNode,n),{lexerErrors:e.lexerErrors,lexerReport:e.lexerReport,parserErrors:e.parserErrors,value:this.hydrateAstNode(t,n)}}createHydrationContext(e){let t=new Map,n=new Map;for(let n of na(e))t.set(n,{});let r;if(e.$cstNode)for(let t of Di(e.$cstNode)){let e;`fullText`in t?(e=new Mo(t.fullText),r=e):`content`in t?e=new Ao:`tokenType`in t&&(e=this.hydrateCstLeafNode(t)),e&&(n.set(t,e),e.root=r)}return{astNodes:t,cstNodes:n}}hydrateAstNode(e,t){let n=t.astNodes.get(e);n.$type=e.$type,n.$containerIndex=e.$containerIndex,n.$containerProperty=e.$containerProperty,e.$cstNode&&(n.$cstNode=t.cstNodes.get(e.$cstNode));for(let[r,i]of Object.entries(e))if(!r.startsWith(`$`))if(Array.isArray(i)){let e=[];n[r]=e;for(let a of i)U(a)?e.push(this.setParent(this.hydrateAstNode(a,t),n)):Tn(a)?e.push(this.hydrateReference(a,n,r,t)):e.push(a)}else U(i)?n[r]=this.setParent(this.hydrateAstNode(i,t),n):Tn(i)?n[r]=this.hydrateReference(i,n,r,t):i!==void 0&&(n[r]=i);return n}setParent(e,t){return e.$container=t,e}hydrateReference(e,t,n,r){return this.linker.buildReference(t,n,r.cstNodes.get(e.$refNode),e.$refText)}hydrateCstNode(e,t,n=0){let r=t.cstNodes.get(e);if(typeof e.grammarSource==`number`&&(r.grammarSource=this.getGrammarElement(e.grammarSource)),r.astNode=t.astNodes.get(e.astNode),kn(r))for(let i of e.content){let e=this.hydrateCstNode(i,t,n++);r.content.push(e)}return r}hydrateCstLeafNode(e){let t=this.getTokenType(e.tokenType),n=e.offset,r=e.length,i=e.startLine,a=e.startColumn,o=e.endLine,s=e.endColumn,c=e.hidden;return new ko(n,r,{start:{line:i,character:a},end:{line:o,character:s}},t,c)}getTokenType(e){return this.lexer.definition[e]}getGrammarElementId(e){if(e)return this.grammarElementIdMap.size===0&&this.createGrammarElementIdMap(),this.grammarElementIdMap.get(e)}getGrammarElement(e){return this.grammarElementIdMap.size===0&&this.createGrammarElementIdMap(),this.grammarElementIdMap.getKey(e)}createGrammarElementIdMap(){let e=0;for(let t of na(this.grammar))qn(t)&&this.grammarElementIdMap.set(t,e++)}},qc;(function(e){function t(e){return{dispose:async()=>await e()}}e.create=t})(qc||={});var Jc=class{readFile(){throw Error(`No file system is available.`)}async readDirectory(){return[]}};const Yc={fileSystemProvider:()=>new Jc},Xc={Grammar:()=>void 0,LanguageMetaData:()=>({caseInsensitive:!1,fileExtensions:[`.langium`],languageId:`langium`})},Zc={AstReflection:()=>new yi};function Qc(){let e=Xs(vl(Yc),Zc),t=Xs(_l({shared:e}),Xc);return e.ServiceRegistry.register(t),t}function $c(e){let t=Qc(),n=t.serializer.JsonSerializer.deserialize(e);return t.shared.workspace.LangiumDocumentFactory.fromModel(n,Y.parse(`memory://${n.name??`grammar`}.langium`)),n}var el=i({AstUtils:()=>Ji,BiMap:()=>Ps,Cancellation:()=>Z,ContextCache:()=>Vs,CstUtils:()=>Ei,DONE_RESULT:()=>K,Deferred:()=>ys,Disposable:()=>qc,DisposableCache:()=>zs,DocumentCache:()=>Hs,EMPTY_STREAM:()=>Ci,ErrorWithLocation:()=>la,GrammarUtils:()=>Sa,MultiMap:()=>Ns,OperationCancelled:()=>_s,Reduction:()=>Ti,RegExpUtils:()=>da,SimpleCache:()=>Bs,StreamImpl:()=>bi,TreeStreamImpl:()=>wi,URI:()=>Y,UriUtils:()=>X,WorkspaceCache:()=>Us,assertUnreachable:()=>ua,delayNextTick:()=>fs,interruptAndCheck:()=>Q,isOperationCancelled:()=>vs,loadGrammarFromJson:()=>$c,setInterruptionPeriod:()=>gs,startCancelableOperation:()=>hs,stream:()=>q});t(el,Mc);var tl=class{constructor(e){this.astNodeLocator=e.workspace.AstNodeLocator,this.nameProvider=e.references.NameProvider}createDescription(e,t,n){let r=n??Qi(e);t??=this.nameProvider.getName(e);let i=this.astNodeLocator.getAstNodePath(e);if(!t)throw Error(`Node at path ${i} has no name.`);let a,o=()=>a??=ji(this.nameProvider.getNameNode(e)??e.$cstNode);return{node:e,name:t,get nameSegment(){return o()},selectionSegment:ji(e.$cstNode),type:e.$type,documentUri:r.uri,path:i}}},nl=class{constructor(e){this.nodeLocator=e.workspace.AstNodeLocator}async createDescriptions(e,t=Z.CancellationToken.None){let n=[],r=e.parseResult.value;for(let e of na(r))await Q(t),ia(e).filter(e=>!Dn(e)).forEach(e=>{let t=this.createDescription(e);t&&n.push(t)});return n}createDescription(e){let t=e.reference.$nodeDescription,n=e.reference.$refNode;if(!t||!n)return;let r=Qi(e.container).uri;return{sourceUri:r,sourcePath:this.nodeLocator.getAstNodePath(e.container),targetUri:t.documentUri,targetPath:t.path,segment:ji(n),local:X.equals(t.documentUri,r)}}},rl=class{constructor(){this.segmentSeparator=`/`,this.indexSeparator=`@`}getAstNodePath(e){if(e.$container){let t=this.getAstNodePath(e.$container),n=this.getPathSegment(e);return t+this.segmentSeparator+n}return``}getPathSegment({$containerProperty:e,$containerIndex:t}){if(!e)throw Error(`Missing '$containerProperty' in AST node.`);return t===void 0?e:e+this.indexSeparator+t}getAstNode(e,t){return t.split(this.segmentSeparator).reduce((e,t)=>{if(!e||t.length===0)return e;let n=t.indexOf(this.indexSeparator);if(n>0){let r=t.substring(0,n),i=parseInt(t.substring(n+1));return e[r]?.[i]}return e[t]},e)}},il=class{constructor(e){this._ready=new ys,this.settings={},this.workspaceConfig=!1,this.onConfigurationSectionUpdateEmitter=new Mc.Emitter,this.serviceRegistry=e.ServiceRegistry}get ready(){return this._ready.promise}initialize(e){this.workspaceConfig=e.capabilities.workspace?.configuration??!1}async initialized(e){if(this.workspaceConfig){if(e.register){let t=this.serviceRegistry.all;e.register({section:t.map(e=>this.toSectionName(e.LanguageMetaData.languageId))})}if(e.fetchConfiguration){let t=this.serviceRegistry.all.map(e=>({section:this.toSectionName(e.LanguageMetaData.languageId)})),n=await e.fetchConfiguration(t);t.forEach((e,t)=>{this.updateSectionConfiguration(e.section,n[t])})}}this._ready.resolve()}updateConfiguration(e){e.settings&&Object.keys(e.settings).forEach(t=>{let n=e.settings[t];this.updateSectionConfiguration(t,n),this.onConfigurationSectionUpdateEmitter.fire({section:t,configuration:n})})}updateSectionConfiguration(e,t){this.settings[e]=t}async getConfiguration(e,t){await this.ready;let n=this.toSectionName(e);if(this.settings[n])return this.settings[n][t]}toSectionName(e){return`${e}`}get onConfigurationSectionUpdate(){return this.onConfigurationSectionUpdateEmitter.event}},al=class{constructor(e){this.updateBuildOptions={validation:{categories:[`built-in`,`fast`]}},this.updateListeners=[],this.buildPhaseListeners=new Ns,this.documentPhaseListeners=new Ns,this.buildState=new Map,this.documentBuildWaiters=new Map,this.currentState=$.Changed,this.langiumDocuments=e.workspace.LangiumDocuments,this.langiumDocumentFactory=e.workspace.LangiumDocumentFactory,this.textDocuments=e.workspace.TextDocuments,this.indexManager=e.workspace.IndexManager,this.serviceRegistry=e.ServiceRegistry}async build(e,t={},n=Z.CancellationToken.None){for(let n of e){let e=n.uri.toString();if(n.state===$.Validated){if(typeof t.validation==`boolean`&&t.validation)n.state=$.IndexedReferences,n.diagnostics=void 0,this.buildState.delete(e);else if(typeof t.validation==`object`){let r=this.buildState.get(e),i=r?.result?.validationChecks;if(i){let a=(t.validation.categories??ul.all).filter(e=>!i.includes(e));a.length>0&&(this.buildState.set(e,{completed:!1,options:{validation:Object.assign(Object.assign({},t.validation),{categories:a})},result:r.result}),n.state=$.IndexedReferences)}}}else this.buildState.delete(e)}this.currentState=$.Changed,await this.emitUpdate(e.map(e=>e.uri),[]),await this.buildDocuments(e,t,n)}async update(e,t,n=Z.CancellationToken.None){this.currentState=$.Changed;for(let e of t)this.langiumDocuments.deleteDocument(e),this.buildState.delete(e.toString()),this.indexManager.remove(e);for(let t of e){if(!this.langiumDocuments.invalidateDocument(t)){let e=this.langiumDocumentFactory.fromModel({$type:`INVALID`},t);e.state=$.Changed,this.langiumDocuments.addDocument(e)}this.buildState.delete(t.toString())}let r=q(e).concat(t).map(e=>e.toString()).toSet();this.langiumDocuments.all.filter(e=>!r.has(e.uri.toString())&&this.shouldRelink(e,r)).forEach(e=>{this.serviceRegistry.getServices(e.uri).references.Linker.unlink(e),e.state=Math.min(e.state,$.ComputedScopes),e.diagnostics=void 0}),await this.emitUpdate(e,t),await Q(n);let i=this.sortDocuments(this.langiumDocuments.all.filter(e=>e.state<$.Linked||!this.buildState.get(e.uri.toString())?.completed).toArray());await this.buildDocuments(i,this.updateBuildOptions,n)}async emitUpdate(e,t){await Promise.all(this.updateListeners.map(n=>n(e,t)))}sortDocuments(e){let t=0,n=e.length-1;for(;t<n;){for(;t<e.length&&this.hasTextDocument(e[t]);)t++;for(;n>=0&&!this.hasTextDocument(e[n]);)n--;t<n&&([e[t],e[n]]=[e[n],e[t]])}return e}hasTextDocument(e){return!!this.textDocuments?.get(e.uri)}shouldRelink(e,t){return e.references.some(e=>e.error!==void 0)?!0:this.indexManager.isAffected(e,t)}onUpdate(e){return this.updateListeners.push(e),qc.create(()=>{let t=this.updateListeners.indexOf(e);t>=0&&this.updateListeners.splice(t,1)})}async buildDocuments(e,t,n){this.prepareBuild(e,t),await this.runCancelable(e,$.Parsed,n,e=>this.langiumDocumentFactory.update(e,n)),await this.runCancelable(e,$.IndexedContent,n,e=>this.indexManager.updateContent(e,n)),await this.runCancelable(e,$.ComputedScopes,n,async e=>{e.precomputedScopes=await this.serviceRegistry.getServices(e.uri).references.ScopeComputation.computeLocalScopes(e,n)});let r=e.filter(e=>this.shouldLink(e));await this.runCancelable(r,$.Linked,n,e=>this.serviceRegistry.getServices(e.uri).references.Linker.link(e,n)),await this.runCancelable(r,$.IndexedReferences,n,e=>this.indexManager.updateReferences(e,n));let i=e.filter(e=>this.shouldValidate(e));await this.runCancelable(i,$.Validated,n,e=>this.validate(e,n));for(let t of e){let e=this.buildState.get(t.uri.toString());e&&(e.completed=!0)}}prepareBuild(e,t){for(let n of e){let e=n.uri.toString(),r=this.buildState.get(e);(!r||r.completed)&&this.buildState.set(e,{completed:!1,options:t,result:r?.result})}}async runCancelable(e,t,n,r){let i=e.filter(e=>e.state<t);for(let e of i)await Q(n),await r(e),e.state=t,await this.notifyDocumentPhase(e,t,n);let a=e.filter(e=>e.state===t);await this.notifyBuildPhase(a,t,n),this.currentState=t}onBuildPhase(e,t){return this.buildPhaseListeners.add(e,t),qc.create(()=>{this.buildPhaseListeners.delete(e,t)})}onDocumentPhase(e,t){return this.documentPhaseListeners.add(e,t),qc.create(()=>{this.documentPhaseListeners.delete(e,t)})}waitUntil(e,t,n){let r;if(t&&`path`in t?r=t:n=t,n??=Z.CancellationToken.None,r){let t=this.langiumDocuments.getDocument(r);if(t&&t.state>=e)return Promise.resolve(r)}return this.currentState>=e?Promise.resolve(void 0):n.isCancellationRequested?Promise.reject(_s):new Promise((t,i)=>{let a=this.onBuildPhase(e,()=>{a.dispose(),o.dispose(),t(r?this.langiumDocuments.getDocument(r)?.uri:void 0)}),o=n.onCancellationRequested(()=>{a.dispose(),o.dispose(),i(_s)})})}async notifyDocumentPhase(e,t,n){let r=this.documentPhaseListeners.get(t).slice();for(let t of r)try{await t(e,n)}catch(e){if(!vs(e))throw e}}async notifyBuildPhase(e,t,n){if(e.length===0)return;let r=this.buildPhaseListeners.get(t).slice();for(let t of r)await Q(n),await t(e,n)}shouldLink(e){return this.getBuildOptions(e).eagerLinking??!0}shouldValidate(e){return!!this.getBuildOptions(e).validation}async validate(e,t){let n=this.serviceRegistry.getServices(e.uri).validation.DocumentValidator,r=this.getBuildOptions(e).validation,i=typeof r==`object`?r:void 0,a=await n.validateDocument(e,i,t);e.diagnostics?e.diagnostics.push(...a):e.diagnostics=a;let o=this.buildState.get(e.uri.toString());if(o){o.result??={};let e=i?.categories??ul.all;o.result.validationChecks?o.result.validationChecks.push(...e):o.result.validationChecks=[...e]}}getBuildOptions(e){return this.buildState.get(e.uri.toString())?.options??{}}},ol=class{constructor(e){this.symbolIndex=new Map,this.symbolByTypeIndex=new Vs,this.referenceIndex=new Map,this.documents=e.workspace.LangiumDocuments,this.serviceRegistry=e.ServiceRegistry,this.astReflection=e.AstReflection}findAllReferences(e,t){let n=Qi(e).uri,r=[];return this.referenceIndex.forEach(e=>{e.forEach(e=>{X.equals(e.targetUri,n)&&e.targetPath===t&&r.push(e)})}),q(r)}allElements(e,t){let n=q(this.symbolIndex.keys());return t&&(n=n.filter(e=>!t||t.has(e))),n.map(t=>this.getFileDescriptions(t,e)).flat()}getFileDescriptions(e,t){return t?this.symbolByTypeIndex.get(e,t,()=>(this.symbolIndex.get(e)??[]).filter(e=>this.astReflection.isSubtype(e.type,t))):this.symbolIndex.get(e)??[]}remove(e){let t=e.toString();this.symbolIndex.delete(t),this.symbolByTypeIndex.clear(t),this.referenceIndex.delete(t)}async updateContent(e,t=Z.CancellationToken.None){let n=await this.serviceRegistry.getServices(e.uri).references.ScopeComputation.computeExports(e,t),r=e.uri.toString();this.symbolIndex.set(r,n),this.symbolByTypeIndex.clear(r)}async updateReferences(e,t=Z.CancellationToken.None){let n=await this.serviceRegistry.getServices(e.uri).workspace.ReferenceDescriptionProvider.createDescriptions(e,t);this.referenceIndex.set(e.uri.toString(),n)}isAffected(e,t){let n=this.referenceIndex.get(e.uri.toString());return n?n.some(e=>!e.local&&t.has(e.targetUri.toString())):!1}},sl=class{constructor(){this.previousTokenSource=new Z.CancellationTokenSource,this.writeQueue=[],this.readQueue=[],this.done=!0}write(e){this.cancelWrite();let t=hs();return this.previousTokenSource=t,this.enqueue(this.writeQueue,e,t.token)}read(e){return this.enqueue(this.readQueue,e)}enqueue(e,t,n=Z.CancellationToken.None){let r=new ys,i={action:t,deferred:r,cancellationToken:n};return e.push(i),this.performNextOperation(),r.promise}async performNextOperation(){if(!this.done)return;let e=[];if(this.writeQueue.length>0)e.push(this.writeQueue.shift());else if(this.readQueue.length>0)e.push(...this.readQueue.splice(0,this.readQueue.length));else return;this.done=!1,await Promise.all(e.map(async({action:e,deferred:t,cancellationToken:n})=>{try{let r=await Promise.resolve().then(()=>e(n));t.resolve(r)}catch(e){vs(e)?t.resolve(void 0):t.reject(e)}})),this.done=!0,this.performNextOperation()}cancelWrite(){this.previousTokenSource.cancel()}},cl=class{constructor(e){this.initialBuildOptions={},this._ready=new ys,this.serviceRegistry=e.ServiceRegistry,this.langiumDocuments=e.workspace.LangiumDocuments,this.documentBuilder=e.workspace.DocumentBuilder,this.fileSystemProvider=e.workspace.FileSystemProvider,this.mutex=e.workspace.WorkspaceLock}get ready(){return this._ready.promise}get workspaceFolders(){return this.folders}initialize(e){this.folders=e.workspaceFolders??void 0}initialized(e){return this.mutex.write(e=>this.initializeWorkspace(this.folders??[],e))}async initializeWorkspace(e,t=Z.CancellationToken.None){let n=await this.performStartup(e);await Q(t),await this.documentBuilder.build(n,this.initialBuildOptions,t)}async performStartup(e){let t=this.serviceRegistry.all.flatMap(e=>e.LanguageMetaData.fileExtensions),n=this.serviceRegistry.all.flatMap(e=>e.LanguageMetaData.fileNames??[]),r=[],i=e=>{r.push(e),this.langiumDocuments.hasDocument(e.uri)||this.langiumDocuments.addDocument(e)};return await this.loadAdditionalDocuments(e,i),await Promise.all(e.map(e=>[e,this.getRootFolder(e)]).map(async e=>this.traverseFolder(...e,{fileExtensions:t,fileNames:n},i))),this._ready.resolve(),r}loadAdditionalDocuments(e,t){return Promise.resolve()}getRootFolder(e){return Y.parse(e.uri)}async traverseFolder(e,t,n,r){let i=await this.fileSystemProvider.readDirectory(t);await Promise.all(i.map(async t=>{this.includeEntry(e,t,n)&&(t.isDirectory?await this.traverseFolder(e,t.uri,n,r):t.isFile&&r(await this.langiumDocuments.getOrCreateDocument(t.uri)))}))}includeEntry(e,t,n){let r=X.basename(t.uri);return r.startsWith(`.`)?!1:t.isDirectory?r!==`node_modules`&&r!==`out`:t.isFile?n.fileExtensions.includes(X.extname(t.uri))||n.fileNames.includes(X.basename(t.uri)):!1}};t(i({AbstractAstReflection:()=>On,AbstractCstNode:()=>Oo,AbstractLangiumParser:()=>Io,AbstractParserErrorMessageProvider:()=>Ro,AbstractThreadedAsyncParser:()=>Pc,AstUtils:()=>Ji,BiMap:()=>Ps,Cancellation:()=>Z,CompositeCstNodeImpl:()=>Ao,ContextCache:()=>Vs,CstNodeBuilder:()=>Do,CstUtils:()=>Ei,DEFAULT_TOKENIZE_OPTIONS:()=>Lc,DONE_RESULT:()=>K,DatatypeSymbol:()=>No,DefaultAstNodeDescriptionProvider:()=>tl,DefaultAstNodeLocator:()=>rl,DefaultAsyncParser:()=>Nc,DefaultCommentProvider:()=>rc,DefaultConfigurationProvider:()=>il,DefaultDocumentBuilder:()=>al,DefaultDocumentValidator:()=>fl,DefaultHydrator:()=>Kc,DefaultIndexManager:()=>ol,DefaultJsonSerializer:()=>qs,DefaultLangiumDocumentFactory:()=>Es,DefaultLangiumDocuments:()=>Ds,DefaultLexer:()=>Rc,DefaultLexerErrorMessageProvider:()=>Ic,DefaultLinker:()=>ks,DefaultNameProvider:()=>js,DefaultReferenceDescriptionProvider:()=>nl,DefaultReferences:()=>Ms,DefaultScopeComputation:()=>Fs,DefaultScopeProvider:()=>Ws,DefaultServiceRegistry:()=>Js,DefaultTokenBuilder:()=>ls,DefaultValueConverter:()=>us,DefaultWorkspaceLock:()=>sl,DefaultWorkspaceManager:()=>cl,Deferred:()=>ys,Disposable:()=>qc,DisposableCache:()=>zs,DocumentCache:()=>Hs,DocumentState:()=>$,DocumentValidator:()=>gl,EMPTY_SCOPE:()=>Rs,EMPTY_STREAM:()=>Ci,EmptyFileSystem:()=>Yc,EmptyFileSystemProvider:()=>Jc,ErrorWithLocation:()=>la,GrammarAST:()=>Mn,GrammarUtils:()=>Sa,IndentationAwareLexer:()=>Gc,IndentationAwareTokenBuilder:()=>Wc,JSDocDocumentationProvider:()=>jc,LangiumCompletionParser:()=>Bo,LangiumParser:()=>Lo,LangiumParserErrorMessageProvider:()=>zo,LeafCstNodeImpl:()=>ko,LexingMode:()=>Uc,MapScope:()=>Ls,Module:()=>Ys,MultiMap:()=>Ns,OperationCancelled:()=>_s,ParserWorker:()=>Fc,Reduction:()=>Ti,RegExpUtils:()=>da,RootCstNodeImpl:()=>Mo,SimpleCache:()=>Bs,StreamImpl:()=>bi,StreamScope:()=>Is,TextDocument:()=>xs,TreeStreamImpl:()=>wi,URI:()=>Y,UriUtils:()=>X,ValidationCategory:()=>ul,ValidationRegistry:()=>dl,ValueConverter:()=>ds,WorkspaceCache:()=>Us,assertUnreachable:()=>ua,createCompletionParser:()=>os,createDefaultCoreModule:()=>_l,createDefaultSharedCoreModule:()=>vl,createGrammarConfig:()=>Eo,createLangiumParser:()=>ss,createParser:()=>Uo,delayNextTick:()=>fs,diagnosticData:()=>ll,eagerLoad:()=>Qs,getDiagnosticRange:()=>pl,indentationBuilderDefaultOptions:()=>Hc,inject:()=>Xs,interruptAndCheck:()=>Q,isAstNode:()=>U,isAstNodeDescription:()=>En,isAstNodeWithComment:()=>Gs,isCompositeCstNode:()=>kn,isIMultiModeLexerDefinition:()=>Bc,isJSDoc:()=>ac,isLeafCstNode:()=>An,isLinkingError:()=>Dn,isNamed:()=>As,isOperationCancelled:()=>vs,isReference:()=>Tn,isRootCstNode:()=>jn,isTokenTypeArray:()=>zc,isTokenTypeDictionary:()=>Vc,loadGrammarFromJson:()=>$c,parseJSDoc:()=>ic,prepareLangiumParser:()=>cs,setInterruptionPeriod:()=>gs,startCancelableOperation:()=>hs,stream:()=>q,toDiagnosticData:()=>hl,toDiagnosticSeverity:()=>ml}),el);function ll(e){return{code:e}}var ul;(function(e){e.all=[`fast`,`slow`,`built-in`]})(ul||={});var dl=class{constructor(e){this.entries=new Ns,this.entriesBefore=[],this.entriesAfter=[],this.reflection=e.shared.AstReflection}register(e,t=this,n=`fast`){if(n===`built-in`)throw Error(`The 'built-in' category is reserved for lexer, parser, and linker errors.`);for(let[r,i]of Object.entries(e)){let e=i;if(Array.isArray(e))for(let i of e){let e={check:this.wrapValidationException(i,t),category:n};this.addEntry(r,e)}else if(typeof e==`function`){let i={check:this.wrapValidationException(e,t),category:n};this.addEntry(r,i)}else ua(e)}}wrapValidationException(e,t){return async(n,r,i)=>{await this.handleException(()=>e.call(t,n,r,i),`An error occurred during validation`,r,n)}}async handleException(e,t,n,r){try{await e()}catch(e){if(vs(e))throw e;console.error(`${t}:`,e),e instanceof Error&&e.stack&&console.error(e.stack),n(`error`,`${t}: ${e instanceof Error?e.message:String(e)}`,{node:r})}}addEntry(e,t){if(e===`AstNode`){this.entries.add(`AstNode`,t);return}for(let n of this.reflection.getAllSubTypes(e))this.entries.add(n,t)}getChecks(e,t){let n=q(this.entries.get(e)).concat(this.entries.get(`AstNode`));return t&&(n=n.filter(e=>t.includes(e.category))),n.map(e=>e.check)}registerBeforeDocument(e,t=this){this.entriesBefore.push(this.wrapPreparationException(e,`An error occurred during set-up of the validation`,t))}registerAfterDocument(e,t=this){this.entriesAfter.push(this.wrapPreparationException(e,`An error occurred during tear-down of the validation`,t))}wrapPreparationException(e,t,n){return async(r,i,a,o)=>{await this.handleException(()=>e.call(n,r,i,a,o),t,i,r)}}get checksBefore(){return this.entriesBefore}get checksAfter(){return this.entriesAfter}},fl=class{constructor(e){this.validationRegistry=e.validation.ValidationRegistry,this.metadata=e.LanguageMetaData}async validateDocument(e,t={},n=Z.CancellationToken.None){let r=e.parseResult,i=[];if(await Q(n),(!t.categories||t.categories.includes(`built-in`))&&(this.processLexingErrors(r,i,t),t.stopAfterLexingErrors&&i.some(e=>e.data?.code===gl.LexingError)||(this.processParsingErrors(r,i,t),t.stopAfterParsingErrors&&i.some(e=>e.data?.code===gl.ParsingError))||(this.processLinkingErrors(e,i,t),t.stopAfterLinkingErrors&&i.some(e=>e.data?.code===gl.LinkingError))))return i;try{i.push(...await this.validateAst(r.value,t,n))}catch(e){if(vs(e))throw e;console.error(`An error occurred during validation:`,e)}return await Q(n),i}processLexingErrors(e,t,n){let r=[...e.lexerErrors,...e.lexerReport?.diagnostics??[]];for(let e of r){let n=e.severity??`error`,r={severity:ml(n),range:{start:{line:e.line-1,character:e.column-1},end:{line:e.line-1,character:e.column+e.length-1}},message:e.message,data:hl(n),source:this.getSource()};t.push(r)}}processParsingErrors(e,t,n){for(let n of e.parserErrors){let e;if(isNaN(n.token.startOffset)){if(`previousToken`in n){let t=n.previousToken;if(isNaN(t.startOffset)){let t={line:0,character:0};e={start:t,end:t}}else{let n={line:t.endLine-1,character:t.endColumn};e={start:n,end:n}}}}else e=Ai(n.token);if(e){let r={severity:ml(`error`),range:e,message:n.message,data:ll(gl.ParsingError),source:this.getSource()};t.push(r)}}}processLinkingErrors(e,t,n){for(let n of e.references){let e=n.error;if(e){let n={node:e.container,property:e.property,index:e.index,data:{code:gl.LinkingError,containerType:e.container.$type,property:e.property,refText:e.reference.$refText}};t.push(this.toDiagnostic(`error`,e.message,n))}}}async validateAst(e,t,n=Z.CancellationToken.None){let r=[],i=(e,t,n)=>{r.push(this.toDiagnostic(e,t,n))};return await this.validateAstBefore(e,t,i,n),await this.validateAstNodes(e,t,i,n),await this.validateAstAfter(e,t,i,n),r}async validateAstBefore(e,t,n,r=Z.CancellationToken.None){let i=this.validationRegistry.checksBefore;for(let a of i)await Q(r),await a(e,n,t.categories??[],r)}async validateAstNodes(e,t,n,r=Z.CancellationToken.None){await Promise.all(na(e).map(async e=>{await Q(r);let i=this.validationRegistry.getChecks(e.$type,t.categories);for(let t of i)await t(e,n,r)}))}async validateAstAfter(e,t,n,r=Z.CancellationToken.None){let i=this.validationRegistry.checksAfter;for(let a of i)await Q(r),await a(e,n,t.categories??[],r)}toDiagnostic(e,t,n){return{message:t,range:pl(n),severity:ml(e),code:n.code,codeDescription:n.codeDescription,tags:n.tags,relatedInformation:n.relatedInformation,data:n.data,source:this.getSource()}}getSource(){return this.metadata.languageId}};function pl(e){if(e.range)return e.range;let t;return typeof e.property==`string`?t=ja(e.node.$cstNode,e.property,e.index):typeof e.keyword==`string`&&(t=Pa(e.node.$cstNode,e.keyword,e.index)),t??=e.node.$cstNode,t?t.range:{start:{line:0,character:0},end:{line:0,character:0}}}function ml(e){switch(e){case`error`:return 1;case`warning`:return 2;case`info`:return 3;case`hint`:return 4;default:throw Error(`Invalid diagnostic severity: `+e)}}function hl(e){switch(e){case`error`:return ll(gl.LexingError);case`warning`:return ll(gl.LexingWarning);case`info`:return ll(gl.LexingInfo);case`hint`:return ll(gl.LexingHint);default:throw Error(`Invalid diagnostic severity: `+e)}}var gl;(function(e){e.LexingError=`lexing-error`,e.LexingWarning=`lexing-warning`,e.LexingInfo=`lexing-info`,e.LexingHint=`lexing-hint`,e.ParsingError=`parsing-error`,e.LinkingError=`linking-error`})(gl||={});function _l(e){return{documentation:{CommentProvider:e=>new rc(e),DocumentationProvider:e=>new jc(e)},parser:{AsyncParser:e=>new Nc(e),GrammarConfig:e=>Eo(e),LangiumParser:e=>ss(e),CompletionParser:e=>os(e),ValueConverter:()=>new us,TokenBuilder:()=>new ls,Lexer:e=>new Rc(e),ParserErrorMessageProvider:()=>new zo,LexerErrorMessageProvider:()=>new Ic},workspace:{AstNodeLocator:()=>new rl,AstNodeDescriptionProvider:e=>new tl(e),ReferenceDescriptionProvider:e=>new nl(e)},references:{Linker:e=>new ks(e),NameProvider:()=>new js,ScopeProvider:e=>new Ws(e),ScopeComputation:e=>new Fs(e),References:e=>new Ms(e)},serializer:{Hydrator:e=>new Kc(e),JsonSerializer:e=>new qs(e)},validation:{DocumentValidator:e=>new fl(e),ValidationRegistry:e=>new dl(e)},shared:()=>e.shared}}function vl(e){return{ServiceRegistry:e=>new Js(e),workspace:{LangiumDocuments:e=>new Ds(e),LangiumDocumentFactory:e=>new Es(e),DocumentBuilder:e=>new al(e),IndexManager:e=>new ol(e),WorkspaceManager:e=>new cl(e),FileSystemProvider:t=>e.fileSystemProvider(t),WorkspaceLock:()=>new sl,ConfigurationProvider:e=>new il(e)}}}var yl=class{constructor(e){this.references=e.references.References,this.nameProvider=e.references.NameProvider,this.grammarConfig=e.parser.GrammarConfig}getDocumentHighlight(e,t,n){let r=e.parseResult.value.$cstNode;if(!r)return;let i=Ii(r,e.textDocument.offsetAt(t.position),this.grammarConfig.nameRegexp);if(!i)return;let a=this.references.findDeclaration(i);if(a){let t=X.equals(Qi(a).uri,e.uri),n={documentUri:e.uri,includeDeclaration:t};return this.references.findReferences(a,n).map(e=>this.createDocumentHighlight(e)).toArray()}}createDocumentHighlight(e){return J.DocumentHighlight.create(e.segment.range)}},bl=class{constructor(e){this.nameProvider=e.references.NameProvider,this.nodeKindProvider=e.shared.lsp.NodeKindProvider}getSymbols(e,t,n){return this.getSymbol(e,e.parseResult.value)}getSymbol(e,t){let n=t.$cstNode,r=this.nameProvider.getNameNode(t);if(r&&n){let i=this.nameProvider.getName(t);return[{kind:this.nodeKindProvider.getSymbolKind(t),name:i||r.text,range:n.range,selectionRange:r.range,children:this.getChildSymbols(e,t)}]}else return this.getChildSymbols(e,t)||[]}getChildSymbols(e,t){let n=[];for(let r of ea(t)){let t=this.getSymbol(e,r);n.push(...t)}if(n.length>0)return n}},xl=class{constructor(e){this.workspaceManager=e.workspace.WorkspaceManager,this.documentBuilder=e.workspace.DocumentBuilder,this.workspaceLock=e.workspace.WorkspaceLock,this.serviceRegistry=e.ServiceRegistry;let t=!1;e.lsp.LanguageServer.onInitialize(e=>{t=!!e.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration}),e.lsp.LanguageServer.onInitialized(n=>{t&&this.registerFileWatcher(e)})}registerFileWatcher(e){let t=[],n=q(e.ServiceRegistry.all).flatMap(e=>e.LanguageMetaData.fileExtensions).map(e=>e.startsWith(`.`)?e.substring(1):e).distinct().toArray();n.length>0&&t.push({globPattern:n.length===1?`**/*.${n[0]}`:`**/*.{${n.join(`,`)}}`});let r=q(e.ServiceRegistry.all).flatMap(e=>e.LanguageMetaData.fileNames??[]).distinct().toArray();if(r.length>0&&t.push({globPattern:r.length===1?`**/${r[0]}`:`**/{${r.join(`,`)}}`}),t.length>0){let n=e.lsp.Connection,r={watchers:t};n?.client.register(J.DidChangeWatchedFilesNotification.type,r)}}fireDocumentUpdate(e,t){e=e.filter(e=>this.serviceRegistry.hasServices(e)),this.workspaceManager.ready.then(()=>{this.workspaceLock.write(n=>this.documentBuilder.update(e,t,n))}).catch(e=>{console.error(`Workspace initialization failed. Could not perform document update.`,e)})}didChangeContent(e){this.fireDocumentUpdate([Y.parse(e.document.uri)],[])}didChangeWatchedFiles(e){let t=q(e.changes).filter(e=>e.type!==J.FileChangeType.Deleted).distinct(e=>e.uri).map(e=>Y.parse(e.uri)).toArray(),n=q(e.changes).filter(e=>e.type===J.FileChangeType.Deleted).distinct(e=>e.uri).map(e=>Y.parse(e.uri)).toArray();this.fireDocumentUpdate(t,n)}},Sl=class{constructor(e){this.commentNames=e.parser.GrammarConfig.multilineCommentRules}getFoldingRanges(e,t,n){let r=[];return this.collectFolding(e,e=>r.push(e)),r}collectFolding(e,t){let n=e.parseResult?.value;if(n){if(this.shouldProcessContent(n)){let r=ta(n).iterator(),i;do if(i=r.next(),!i.done){let n=i.value;this.shouldProcess(n)&&this.collectObjectFolding(e,n,t),this.shouldProcessContent(n)||r.prune()}while(!i.done)}this.collectCommentFolding(e,n,t)}}shouldProcess(e){return!0}shouldProcessContent(e){return!0}collectObjectFolding(e,t,n){let r=t.$cstNode;if(r){let t=this.toFoldingRange(e,r);t&&n(t)}}collectCommentFolding(e,t,n){let r=t.$cstNode;if(r){for(let t of Oi(r))if(this.commentNames.includes(t.tokenType.name)){let r=this.toFoldingRange(e,t,J.FoldingRangeKind.Comment);r&&n(r)}}}toFoldingRange(e,t,n){let r=t.range,i=r.start,a=r.end;if(!(a.line-i.line<2))return this.includeLastFoldingLine(t,n)||(a=e.textDocument.positionAt(e.textDocument.offsetAt({line:a.line,character:0})-1)),J.FoldingRange.create(i.line,a.line,i.character,a.character,n)}includeLastFoldingLine(e,t){if(t===J.FoldingRangeKind.Comment)return!1;let n=e.text,r=n.charAt(n.length-1);return!(r===`}`||r===`)`||r===`]`)}},Cl=class{match(e,t){if(e.length===0)return!0;let n=!1,r,i=0,a=t.length;for(let o=0;o<a;o++){let a=t.charCodeAt(o),s=e.charCodeAt(i);if((a===s||this.toUpperCharCode(a)===this.toUpperCharCode(s))&&(n||=r===void 0||this.isWordTransition(r,a),n&&i++,i===e.length))return!0;r=a}return!1}isWordTransition(e,t){return wl<=e&&e<=Tl&&El<=t&&t<=Dl||e===Ol&&t!==Ol}toUpperCharCode(e){return wl<=e&&e<=Tl?e-32:e}};const wl=97,Tl=122,El=65,Dl=90,Ol=95;var kl=class{constructor(e){this.references=e.references.References,this.grammarConfig=e.parser.GrammarConfig}getHoverContent(e,t){let n=e.parseResult?.value?.$cstNode;if(n){let r=e.textDocument.offsetAt(t.position),i=Ii(n,r,this.grammarConfig.nameRegexp);if(i&&i.offset+i.length>r){let e=this.references.findDeclaration(i);if(e)return this.getAstNodeHoverContent(e);if(ei(i.grammarSource))return this.getKeywordHoverContent(i.grammarSource)}}}getKeywordHoverContent(e){let t=Gs(e)?e.$comment:void 0;if(t||=Li(e.$cstNode,[`ML_COMMENT`])?.text,t&&ac(t)){let e=ic(t).toMarkdown();if(e)return{contents:{kind:`markdown`,value:e}}}}},Al=class extends kl{constructor(e){super(e),this.documentationProvider=e.documentation.DocumentationProvider}getAstNodeHoverContent(e){let t=this.documentationProvider.getDocumentation(e);if(t)return{contents:{kind:`markdown`,value:t}}}};const jl={[J.SemanticTokenTypes.class]:0,[J.SemanticTokenTypes.comment]:1,[J.SemanticTokenTypes.enum]:2,[J.SemanticTokenTypes.enumMember]:3,[J.SemanticTokenTypes.event]:4,[J.SemanticTokenTypes.function]:5,[J.SemanticTokenTypes.interface]:6,[J.SemanticTokenTypes.keyword]:7,[J.SemanticTokenTypes.macro]:8,[J.SemanticTokenTypes.method]:9,[J.SemanticTokenTypes.modifier]:10,[J.SemanticTokenTypes.namespace]:11,[J.SemanticTokenTypes.number]:12,[J.SemanticTokenTypes.operator]:13,[J.SemanticTokenTypes.parameter]:14,[J.SemanticTokenTypes.property]:15,[J.SemanticTokenTypes.regexp]:16,[J.SemanticTokenTypes.string]:17,[J.SemanticTokenTypes.struct]:18,[J.SemanticTokenTypes.type]:19,[J.SemanticTokenTypes.typeParameter]:20,[J.SemanticTokenTypes.variable]:21,[J.SemanticTokenTypes.decorator]:22},Ml={[J.SemanticTokenModifiers.abstract]:1,[J.SemanticTokenModifiers.async]:2,[J.SemanticTokenModifiers.declaration]:4,[J.SemanticTokenModifiers.defaultLibrary]:8,[J.SemanticTokenModifiers.definition]:16,[J.SemanticTokenModifiers.deprecated]:32,[J.SemanticTokenModifiers.documentation]:64,[J.SemanticTokenModifiers.modification]:128,[J.SemanticTokenModifiers.readonly]:256,[J.SemanticTokenModifiers.static]:512};function Nl(e){let t=[],n=[],r=!0,i=!0,a=!0;for(let o of e)o&&(o.legend.tokenTypes.forEach((e,n)=>{let r=t[n];if(r&&r!==e)throw Error(`Cannot merge '${r}' and '${e}' token types. They use the same index ${n}.`);t[n]=e}),o.legend.tokenModifiers.forEach((e,t)=>{let r=n[t];if(r&&r!==e)throw Error(`Cannot merge '${r}' and '${e}' token modifier. They use the same index ${t}.`);n[t]=e}),o.full?typeof o.full==`object`&&!o.full.delta&&(i=!1):r=!1,o.range||(a=!1));return{legend:{tokenTypes:t,tokenModifiers:n},full:r&&{delta:i},range:a}}var Pl=class extends J.SemanticTokensBuilder{constructor(){super(...arguments),this._tokens=[]}push(e,t,n,r,i){this._tokens.push({line:e,char:t,length:n,tokenType:r,tokenModifiers:i})}build(){return this.applyTokens(),super.build()}buildEdits(){return this.applyTokens(),super.buildEdits()}flush(){this.previousResult(this.id)}applyTokens(){for(let e of this._tokens.sort(this.compareTokens))super.push(e.line,e.char,e.length,e.tokenType,e.tokenModifiers);this._tokens=[]}compareTokens(e,t){return e.line===t.line?e.char-t.char:e.line-t.line}},Fl=class{constructor(e){this.tokensBuilders=new Map,e.shared.workspace.TextDocuments.onDidClose(e=>{this.tokensBuilders.delete(e.document.uri)}),e.shared.lsp.LanguageServer.onInitialize(e=>{this.initialize(e.capabilities.textDocument?.semanticTokens)})}initialize(e){this.clientCapabilities=e}get tokenTypes(){return jl}get tokenModifiers(){return Ml}get semanticTokensOptions(){return{legend:{tokenTypes:Object.keys(this.tokenTypes),tokenModifiers:Object.keys(this.tokenModifiers)},full:{delta:!0},range:!0}}async semanticHighlight(e,t,n=Z.CancellationToken.None){return this.currentRange=void 0,this.currentDocument=e,this.currentTokensBuilder=this.getDocumentTokensBuilder(e),this.currentTokensBuilder.flush(),await this.computeHighlighting(e,this.createAcceptor(),n),this.currentTokensBuilder.build()}async semanticHighlightRange(e,t,n=Z.CancellationToken.None){return this.currentRange=t.range,this.currentDocument=e,this.currentTokensBuilder=this.getDocumentTokensBuilder(e),this.currentTokensBuilder.flush(),await this.computeHighlighting(e,this.createAcceptor(),n),this.currentTokensBuilder.build()}async semanticHighlightDelta(e,t,n=Z.CancellationToken.None){return this.currentRange=void 0,this.currentDocument=e,this.currentTokensBuilder=this.getDocumentTokensBuilder(e),this.currentTokensBuilder.previousResult(t.previousResultId),await this.computeHighlighting(e,this.createAcceptor(),n),this.currentTokensBuilder.buildEdits()}createAcceptor(){return e=>{`line`in e?this.highlightToken({range:{start:{line:e.line,character:e.char},end:{line:e.line,character:e.char+e.length}},type:e.type,modifier:e.modifier}):`range`in e?this.highlightToken(e):`keyword`in e?this.highlightKeyword(e):`property`in e?this.highlightProperty(e):this.highlightNode({node:e.cst,type:e.type,modifier:e.modifier})}}getDocumentTokensBuilder(e){let t=this.tokensBuilders.get(e.uri.toString());if(t)return t;let n=new Pl;return this.tokensBuilders.set(e.uri.toString(),n),n}async computeHighlighting(e,t,n){let r=e.parseResult.value,i=na(r,{range:this.currentRange}).iterator(),a;do if(a=i.next(),!a.done){await Q(n);let e=a.value;this.highlightElement(e,t)===`prune`&&i.prune()}while(!a.done)}highlightToken(e){let{range:t,type:n}=e,r=e.modifier;if(this.currentRange&&!Pi(t,this.currentRange)||!this.currentDocument||!this.currentTokensBuilder)return;let i=this.tokenTypes[n],a=0;if(r!==void 0){typeof r==`string`&&(r=[r]);for(let e of r){let t=this.tokenModifiers[e];a|=t}}let o=t.start.line,s=t.end.line;if(o===s){let e=t.start.character,n=t.end.character-e;this.currentTokensBuilder.push(o,e,n,i,a)}else if(this.clientCapabilities?.multilineTokenSupport){let e=t.start.character,n=this.currentDocument.textDocument.offsetAt(t.start),r=this.currentDocument.textDocument.offsetAt(t.end);this.currentTokensBuilder.push(o,e,r-n,i,a)}else{let e=t.start,n=this.currentDocument.textDocument.offsetAt({line:o+1,character:0});this.currentTokensBuilder.push(e.line,e.character,n-e.character-1,i,a);for(let e=o+1;e<s;e++){let t=n;n=this.currentDocument.textDocument.offsetAt({line:e+1,character:0}),this.currentTokensBuilder.push(e,0,n-t-1,i,a)}this.currentTokensBuilder.push(s,0,t.end.character,i,a)}}highlightProperty(e){let t=[];if(typeof e.index==`number`){let n=ja(e.node.$cstNode,e.property,e.index);n&&t.push(n)}else t.push(...Aa(e.node.$cstNode,e.property));let{type:n,modifier:r}=e;for(let e of t)this.highlightNode({node:e,type:n,modifier:r})}highlightKeyword(e){let{node:t,keyword:n,type:r,index:i,modifier:a}=e,o=[];if(typeof i==`number`){let e=Pa(t.$cstNode,n,i);e&&o.push(e)}else o.push(...Na(t.$cstNode,n));for(let e of o)this.highlightNode({node:e,type:r,modifier:a})}highlightNode(e){let{node:t,type:n,modifier:r}=e,i=t.range;this.highlightToken({range:i,type:n,modifier:r})}},Il;(function(e){function t(e,t,r){let i=new Map;Object.entries(t).forEach(([e,t])=>i.set(t,e));let a=0,o=0;return n(e.data,5).map(e=>{a+=e[0],e[0]!==0&&(o=0),o+=e[1];let t=e[2];return{offset:r.textDocument.offsetAt({line:a,character:o}),tokenType:i.get(e[3]),tokenModifiers:e[4],text:r.textDocument.getText({start:{line:a,character:o},end:{line:a,character:o+t}})}})}e.decode=t;function n(e,t){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}})(Il||={});function Ll(e){let t=[],n=[];e.forEach(e=>{e?.triggerCharacters&&t.push(...e.triggerCharacters),e?.retriggerCharacters&&n.push(...e.retriggerCharacters)});let r={triggerCharacters:t.length>0?Array.from(new Set(t)).sort():void 0,retriggerCharacters:n.length>0?Array.from(new Set(n)).sort():void 0};return r.triggerCharacters?r:void 0}var Rl=H(),zl=class{constructor(e){this.onInitializeEmitter=new Rl.Emitter,this.onInitializedEmitter=new Rl.Emitter,this.services=e}get onInitialize(){return this.onInitializeEmitter.event}get onInitialized(){return this.onInitializedEmitter.event}async initialize(e){return this.eagerLoadServices(),this.fireInitializeOnDefaultServices(e),this.onInitializeEmitter.fire(e),this.onInitializeEmitter.dispose(),this.buildInitializeResult(e)}eagerLoadServices(){Qs(this.services),this.services.ServiceRegistry.all.forEach(e=>Qs(e))}hasService(e){return this.services.ServiceRegistry.all.some(t=>e(t)!==void 0)}buildInitializeResult(e){let t=this.services.lsp.DocumentUpdateHandler,n=this.services.lsp.FileOperationHandler?.fileOperationOptions,r=this.services.ServiceRegistry.all,i=this.hasService(e=>e.lsp?.Formatter),a=r.map(e=>e.lsp?.Formatter?.formatOnTypeOptions).find(e=>!!e),o=this.hasService(e=>e.lsp?.CodeActionProvider),s=this.hasService(e=>e.lsp?.SemanticTokenProvider),c=Nl(r.map(e=>e.lsp?.SemanticTokenProvider?.semanticTokensOptions)),l=this.services.lsp?.ExecuteCommandHandler?.commands,u=this.hasService(e=>e.lsp?.DocumentLinkProvider),d=Ll(r.map(e=>e.lsp?.SignatureHelp?.signatureHelpOptions)),f=this.hasService(e=>e.lsp?.TypeProvider),p=this.hasService(e=>e.lsp?.ImplementationProvider),m=this.hasService(e=>e.lsp?.CompletionProvider),h=xo(r.map(e=>e.lsp?.CompletionProvider?.completionOptions)),g=this.hasService(e=>e.lsp?.ReferencesProvider),_=this.hasService(e=>e.lsp?.DocumentSymbolProvider),v=this.hasService(e=>e.lsp?.DefinitionProvider),y=this.hasService(e=>e.lsp?.DocumentHighlightProvider),b=this.hasService(e=>e.lsp?.FoldingRangeProvider),x=this.hasService(e=>e.lsp?.HoverProvider),S=this.hasService(e=>e.lsp?.RenameProvider),C=this.hasService(e=>e.lsp?.CallHierarchyProvider),w=this.hasService(e=>e.lsp?.TypeHierarchyProvider),ee=this.hasService(e=>e.lsp?.CodeLensProvider),T=this.hasService(e=>e.lsp?.DeclarationProvider),E=this.hasService(e=>e.lsp?.InlayHintProvider),D=this.services.lsp?.WorkspaceSymbolProvider;return{capabilities:{workspace:{workspaceFolders:{supported:!0},fileOperations:n},executeCommandProvider:l&&{commands:l},textDocumentSync:{change:Rl.TextDocumentSyncKind.Incremental,openClose:!0,save:!!t.didSaveDocument,willSave:!!t.willSaveDocument,willSaveWaitUntil:!!t.willSaveDocumentWaitUntil},completionProvider:m?h:void 0,referencesProvider:g,documentSymbolProvider:_,definitionProvider:v,typeDefinitionProvider:f,documentHighlightProvider:y,codeActionProvider:o,documentFormattingProvider:i,documentRangeFormattingProvider:i,documentOnTypeFormattingProvider:a,foldingRangeProvider:b,hoverProvider:x,renameProvider:S?{prepareProvider:!0}:void 0,semanticTokensProvider:s?c:void 0,signatureHelpProvider:d,implementationProvider:p,callHierarchyProvider:C?{}:void 0,typeHierarchyProvider:w?{}:void 0,documentLinkProvider:u?{resolveProvider:!1}:void 0,codeLensProvider:ee?{resolveProvider:!1}:void 0,declarationProvider:T,inlayHintProvider:E?{resolveProvider:!1}:void 0,workspaceSymbolProvider:D?{resolveProvider:!!D.resolveSymbol}:void 0}}}initialized(e){this.fireInitializedOnDefaultServices(e),this.onInitializedEmitter.fire(e),this.onInitializedEmitter.dispose()}fireInitializeOnDefaultServices(e){this.services.workspace.ConfigurationProvider.initialize(e),this.services.workspace.WorkspaceManager.initialize(e)}fireInitializedOnDefaultServices(e){let t=this.services.lsp.Connection,n=t?Object.assign(Object.assign({},e),{register:e=>t.client.register(Rl.DidChangeConfigurationNotification.type,e),fetchConfiguration:e=>t.workspace.getConfiguration(e)}):e;this.services.workspace.ConfigurationProvider.initialized(n).catch(e=>console.error(`Error in ConfigurationProvider initialization:`,e)),this.services.workspace.WorkspaceManager.initialized(e).catch(e=>console.error(`Error in WorkspaceManager initialization:`,e))}},Bl=class{getSymbolKind(e){return J.SymbolKind.Field}getCompletionItemKind(e){return J.CompletionItemKind.Reference}},Vl=class{constructor(e){this.nameProvider=e.references.NameProvider,this.references=e.references.References,this.grammarConfig=e.parser.GrammarConfig}findReferences(e,t,n){let r=e.parseResult.value.$cstNode;if(!r)return[];let i=Ii(r,e.textDocument.offsetAt(t.position),this.grammarConfig.nameRegexp);return i?this.getReferences(i,t,e):[]}getReferences(e,t,n){let r=[],i=this.references.findDeclaration(e);if(i){let e={includeDeclaration:t.context.includeDeclaration};this.references.findReferences(i,e).forEach(e=>{r.push(J.Location.create(e.sourceUri.toString(),e.segment.range))})}return r}};kt();var Hl=class{constructor(e){this.references=e.references.References,this.nameProvider=e.references.NameProvider,this.grammarConfig=e.parser.GrammarConfig}async rename(e,t,n){let r={},i=e.parseResult.value.$cstNode;if(!i)return;let a=Ii(i,e.textDocument.offsetAt(t.position),this.grammarConfig.nameRegexp);if(!a)return;let o=this.references.findDeclaration(a);if(o)return this.references.findReferences(o,{onlyLocal:!1,includeDeclaration:!0}).forEach(e=>{let n=L.replace(e.segment.range,t.newName),i=e.sourceUri.toString();r[i]?r[i].push(n):r[i]=[n]}),{changes:r}}prepareRename(e,t,n){return this.renameNodeRange(e,t.position)}renameNodeRange(e,t){let n=e.parseResult.value.$cstNode,r=e.textDocument.offsetAt(t);if(n&&r){let e=Ii(n,r,this.grammarConfig.nameRegexp);if(!e)return;if(this.references.findDeclaration(e)||this.isNameNode(e))return e.range}}isNameNode(e){return e?.astNode&&As(e.astNode)&&e===this.nameProvider.getNameNode(e.astNode)}},Ul=class{constructor(e){this.indexManager=e.workspace.IndexManager,this.nodeKindProvider=e.lsp.NodeKindProvider,this.fuzzyMatcher=e.lsp.FuzzyMatcher}async getSymbols(e,t=Z.CancellationToken.None){let n=[],r=e.query.toLowerCase();for(let e of this.indexManager.allElements())if(await Q(t),this.fuzzyMatcher.match(r,e.name)){let t=this.getWorkspaceSymbol(e);t&&n.push(t)}return n}getWorkspaceSymbol(e){let t=e.nameSegment;if(t)return{kind:this.nodeKindProvider.getSymbolKind(e),name:e.name,location:{range:t.range,uri:e.documentUri.toString()}}}},Wl=class{constructor(e){this._configuration=e,this._syncedDocuments=new Map,this._onDidChangeContent=new J.Emitter,this._onDidOpen=new J.Emitter,this._onDidClose=new J.Emitter,this._onDidSave=new J.Emitter,this._onWillSave=new J.Emitter}get onDidOpen(){return this._onDidOpen.event}get onDidChangeContent(){return this._onDidChangeContent.event}get onWillSave(){return this._onWillSave.event}onWillSaveWaitUntil(e){this._willSaveWaitUntil=e}get onDidSave(){return this._onDidSave.event}get onDidClose(){return this._onDidClose.event}get(e){return this._syncedDocuments.get(X.normalize(e))}set(e){let t=X.normalize(e.uri),n=!0;this._syncedDocuments.has(t)&&(n=!1),this._syncedDocuments.set(t,e);let r=Object.freeze({document:e});return this._onDidOpen.fire(r),this._onDidChangeContent.fire(r),n}delete(e){let t=X.normalize(typeof e==`object`&&`uri`in e?e.uri:e),n=this._syncedDocuments.get(t);n!==void 0&&(this._syncedDocuments.delete(t),this._onDidClose.fire(Object.freeze({document:n})))}all(){return Array.from(this._syncedDocuments.values())}keys(){return Array.from(this._syncedDocuments.keys())}listen(e){e.__textDocumentSync=J.TextDocumentSyncKind.Incremental;let t=[];return t.push(e.onDidOpenTextDocument(e=>{let t=e.textDocument,n=X.normalize(t.uri),r=this._configuration.create(n,t.languageId,t.version,t.text);this._syncedDocuments.set(n,r);let i=Object.freeze({document:r});this._onDidOpen.fire(i),this._onDidChangeContent.fire(i)})),t.push(e.onDidChangeTextDocument(e=>{let t=e.textDocument,n=e.contentChanges;if(n.length===0)return;let{version:r}=t;if(r==null)throw Error(`Received document change event for ${t.uri} without valid version identifier`);let i=X.normalize(t.uri),a=this._syncedDocuments.get(i);a!==void 0&&(a=this._configuration.update(a,n,r),this._syncedDocuments.set(i,a),this._onDidChangeContent.fire(Object.freeze({document:a})))})),t.push(e.onDidCloseTextDocument(e=>{let t=X.normalize(e.textDocument.uri),n=this._syncedDocuments.get(t);n!==void 0&&(this._syncedDocuments.delete(t),this._onDidClose.fire(Object.freeze({document:n})))})),t.push(e.onWillSaveTextDocument(e=>{let t=this._syncedDocuments.get(X.normalize(e.textDocument.uri));t!==void 0&&this._onWillSave.fire(Object.freeze({document:t,reason:e.reason}))})),t.push(e.onWillSaveTextDocumentWaitUntil((e,t)=>{let n=this._syncedDocuments.get(X.normalize(e.textDocument.uri));return n!==void 0&&this._willSaveWaitUntil?this._willSaveWaitUntil(Object.freeze({document:n,reason:e.reason}),t):[]})),t.push(e.onDidSaveTextDocument(e=>{let t=this._syncedDocuments.get(X.normalize(e.textDocument.uri));t!==void 0&&this._onDidSave.fire(Object.freeze({document:t}))})),J.Disposable.create(()=>{t.forEach(e=>e.dispose())})}},Gl=class{constructor(e){this.notebookDocuments=new Map,this.notebookCellMap=new Map,this._onDidOpen=new J.Emitter,this._onDidSave=new J.Emitter,this._onDidChange=new J.Emitter,this._onDidClose=new J.Emitter,`listen`in e?this._cellTextDocuments=e:this._cellTextDocuments=new Wl(e)}get cellTextDocuments(){return this._cellTextDocuments}getCellTextDocument(e){return this._cellTextDocuments.get(e.document)}getNotebookDocument(e){return this.notebookDocuments.get(X.normalize(e))}getNotebookCell(e){let t=this.notebookCellMap.get(X.normalize(e));return t&&t[0]}findNotebookDocumentForCell(e){let t=typeof e==`string`||`scheme`in e?e:e.document,n=this.notebookCellMap.get(X.normalize(t));return n&&n[1]}get onDidOpen(){return this._onDidOpen.event}get onDidSave(){return this._onDidSave.event}get onDidChange(){return this._onDidChange.event}get onDidClose(){return this._onDidClose.event}listen(e){let t=new Kl,n=[];return n.push(this.cellTextDocuments.listen(t)),n.push(e.notebooks.synchronization.onDidOpenNotebookDocument(e=>{let n=X.normalize(e.notebookDocument.uri);this.notebookDocuments.set(n,e.notebookDocument);for(let n of e.cellTextDocuments)t.openTextDocument({textDocument:n});this.updateCellMap(e.notebookDocument),this._onDidOpen.fire(e.notebookDocument)})),n.push(e.notebooks.synchronization.onDidChangeNotebookDocument(e=>{let n=X.normalize(e.notebookDocument.uri),r=this.notebookDocuments.get(n);if(r===void 0)return;r.version=e.notebookDocument.version;let i=r.metadata,a=!1,o=e.change;o.metadata!==void 0&&(a=!0,r.metadata=o.metadata);let s=[],c=[],l=[],u=[];if(o.cells!==void 0){let e=o.cells;if(e.structure!==void 0){let n=e.structure.array;if(r.cells.splice(n.start,n.deleteCount,...n.cells===void 0?[]:n.cells),e.structure.didOpen!==void 0)for(let n of e.structure.didOpen)t.openTextDocument({textDocument:n}),s.push(n.uri);if(e.structure.didClose)for(let n of e.structure.didClose)t.closeTextDocument({textDocument:n}),c.push(n.uri)}if(e.data!==void 0){let t=new Map(e.data.map(e=>[e.document,e]));for(let e=0;e<=r.cells.length;e++){let n=t.get(r.cells[e].document);if(n!==void 0){let i=r.cells.splice(e,1,n);if(l.push({old:i[0],new:n}),t.delete(n.document),t.size===0)break}}}if(e.textContent!==void 0)for(let n of e.textContent)t.changeTextDocument({textDocument:n.document,contentChanges:n.changes}),u.push(n.document.uri)}this.updateCellMap(r);let d={notebookDocument:r};a&&(d.metadata={old:i,new:r.metadata});let f=[];for(let e of s)f.push(this.getNotebookCell(e));let p=[];for(let e of c)p.push(this.getNotebookCell(e));let m=[];for(let e of u)m.push(this.getNotebookCell(e));(f.length>0||p.length>0||l.length>0||m.length>0)&&(d.cells={added:f,removed:p,changed:{data:l,textContent:m}}),(d.metadata!==void 0||d.cells!==void 0)&&this._onDidChange.fire(d)})),n.push(e.notebooks.synchronization.onDidSaveNotebookDocument(e=>{let t=this.getNotebookDocument(e.notebookDocument.uri);t!==void 0&&this._onDidSave.fire(t)})),n.push(e.notebooks.synchronization.onDidCloseNotebookDocument(e=>{let n=X.normalize(e.notebookDocument.uri),r=this.notebookDocuments.get(n);if(r!==void 0){this._onDidClose.fire(r);for(let n of e.cellTextDocuments)t.closeTextDocument({textDocument:n});this.notebookDocuments.delete(n);for(let e of r.cells)this.notebookCellMap.delete(e.document)}})),J.Disposable.create(()=>{n.forEach(e=>e.dispose())})}updateCellMap(e){for(let t of e.cells)this.notebookCellMap.set(t.document,[t,e])}},Kl=class e{onDidOpenTextDocument(e){return this.openHandler=e,J.Disposable.create(()=>{this.openHandler=void 0})}openTextDocument(e){this.openHandler&&this.openHandler(e)}onDidChangeTextDocument(e){return this.changeHandler=e,J.Disposable.create(()=>{this.changeHandler=e})}changeTextDocument(e){this.changeHandler&&this.changeHandler(e)}onDidCloseTextDocument(e){return this.closeHandler=e,J.Disposable.create(()=>{this.closeHandler=void 0})}closeTextDocument(e){this.closeHandler&&this.closeHandler(e)}onWillSaveTextDocument(){return e.NULL_DISPOSE}onWillSaveTextDocumentWaitUntil(){return e.NULL_DISPOSE}onDidSaveTextDocument(){return e.NULL_DISPOSE}};Kl.NULL_DISPOSE=Object.freeze({dispose:()=>{}});function ql(e){return Ys.merge(_l(e),Jl(e))}function Jl(e){return{lsp:{CompletionProvider:e=>new So(e),DocumentSymbolProvider:e=>new bl(e),HoverProvider:e=>new Al(e),FoldingRangeProvider:e=>new Sl(e),ReferencesProvider:e=>new Vl(e),DefinitionProvider:e=>new To(e),DocumentHighlightProvider:e=>new yl(e),RenameProvider:e=>new Hl(e)},shared:()=>e.shared}}function Yl(e){return Ys.merge(vl(e),Xl(e))}function Xl(e){return{lsp:{Connection:()=>e.connection,LanguageServer:e=>new zl(e),DocumentUpdateHandler:e=>new xl(e),WorkspaceSymbolProvider:e=>new Ul(e),NodeKindProvider:()=>new Bl,FuzzyMatcher:()=>new Cl},workspace:{TextDocuments:()=>new Wl(xs),NotebookDocuments:e=>new Gl(e.workspace.TextDocuments)}}}var Zl=class{constructor(){this.collector=()=>{}}getNodeFormatter(e){return new Ql(e,this.collector)}formatDocument(e,t){let n=e.parseResult;return n.lexerErrors.length===0&&n.parserErrors.length===0?this.doDocumentFormat(e,t.options):[]}isFormatRangeErrorFree(e,t){let n=e.parseResult;return n.lexerErrors.length||n.parserErrors.length?Math.min(...n.lexerErrors.map(e=>e.line??Number.MAX_VALUE),...n.parserErrors.map(e=>e.token.startLine??Number.MAX_VALUE))>t.end.line:!0}formatDocumentRange(e,t){return this.isFormatRangeErrorFree(e,t.range)?this.doDocumentFormat(e,t.options,t.range):[]}formatDocumentOnType(e,t){let n={start:{character:0,line:t.position.line},end:t.position};return this.isFormatRangeErrorFree(e,n)?this.doDocumentFormat(e,t.options,n):[]}get formatOnTypeOptions(){}doDocumentFormat(e,t,n){let r=new Map;this.collector=(e,t,n)=>{let i=this.nodeModeToKey(e,t),a=r.get(i),o=n.options.priority??0,s=a?.options.priority??0;(!a||s<=o)&&r.set(i,n)},this.iterateAstFormatting(e,n);let i=this.iterateCstFormatting(e,r,t,n);return this.avoidOverlappingEdits(e.textDocument,i)}avoidOverlappingEdits(e,t){let n=[];for(let r of t){let t=n[n.length-1];for(;t&&e.offsetAt(r.range.start)<e.offsetAt(t.range.end);)n.pop(),t=n[n.length-1];n.push(r)}return n.filter(t=>this.isNecessary(t,e))}iterateAstFormatting(e,t){let n=e.parseResult.value;this.format(n);let r=ta(n).iterator(),i;do if(i=r.next(),!i.done){let e=i.value;this.insideRange(e.$cstNode.range,t)?this.format(e):r.prune()}while(!i.done)}nodeModeToKey(e,t){return`${e.offset}:${e.end}:${t}`}insideRange(e,t){return!t||e.start.line<=t.start.line&&e.end.line>=t.end.line||e.start.line>=t.start.line&&e.end.line<=t.end.line||e.start.line<=t.end.line&&e.end.line>=t.end.line}isNecessary(e,t){return e.newText!==t.getText(e.range).replace(/\r/g,``)}iterateCstFormatting(e,t,n,r){let i={indentation:0,options:n,document:e.textDocument},a=[],o=this.iterateCstTree(e,i).iterator(),s,c;do if(c=o.next(),!c.done){let e=c.value,n=An(e),o=this.nodeModeToKey(e,`prepend`),l=t.get(o);if(t.delete(o),l){let t=this.createTextEdit(s,e,l,i);for(let e of t)e&&this.insideRange(e.range,r)&&a.push(e)}let u=this.nodeModeToKey(e,`append`),d=t.get(u);if(t.delete(u),d){let t=Ui(e);if(t){let n=this.createTextEdit(e,t,d,i);for(let e of n)e&&this.insideRange(e.range,r)&&a.push(e)}}if(!l&&e.hidden){let t=this.createHiddenTextEdits(s,e,void 0,i);for(let e of t)e&&this.insideRange(e.range,r)&&a.push(e)}n&&(s=e)}while(!c.done);return a}createHiddenTextEdits(e,t,n,r){let i=t.range.start.line;if(e&&e.range.end.line===i)return[];let a=[],o={start:{character:0,line:i},end:t.range.start},s=r.document.getText(o),c=this.findFittingMove(o,n?.moves??[],r),l=this.getExistingIndentationCharacterCount(s,r),u=this.getIndentationCharacterCount(r,c)-l;if(u===0)return[];let d=``;u>0&&(d=(r.options.insertSpaces?` `:` `).repeat(u));let f=t.text.split(`
|
|
28
28
|
`);f[0]=s+f[0];for(let e=0;e<f.length;e++){let t=i+e,n={character:0,line:t};if(u>0)a.push({newText:d,range:{start:n,end:n}});else{let r=f[e],i=0;for(;i<r.length;i++){let e=r.charAt(i);if(e!==` `&&e!==` `)break}a.push({newText:``,range:{start:n,end:{line:t,character:Math.min(i,Math.abs(u))}}})}}return a}getExistingIndentationCharacterCount(e,t){let n=` `.repeat(t.options.tabSize);return(t.options.insertSpaces?e.replaceAll(` `,n):e.replaceAll(n,` `)).length}getIndentationCharacterCount(e,t){let n=e.indentation;return t&&t.tabs&&(n+=t.tabs),(e.options.insertSpaces?e.options.tabSize:1)*n}createTextEdit(e,t,n,r){if(t.hidden)return this.createHiddenTextEdits(e,t,n,r);if(e&&(e.range.end.line>t.range.start.line||e.range.end.line===t.range.start.line&&e.range.end.character>t.range.start.character))return[];let i={start:e?.range.end??{character:0,line:0},end:t.range.start},a=this.findFittingMove(i,n.moves,r);if(!a)return[];let o=a.characters,s=a.lines,c=a.tabs,l=r.indentation;r.indentation+=c??0;let u=[];return o===void 0?s===void 0?c!==void 0&&u.push(this.createTabTextEdit(i,!!e,r)):u.push(this.createLineTextEdit(i,s,r,n.options)):e?.hidden||u.push(this.createSpaceTextEdit(i,o,n.options)),An(t)&&(r.indentation=l),u}createSpaceTextEdit(e,t,n){if(e.start.line===e.end.line){let r=e.end.character-e.start.character;t=this.fitIntoOptions(t,r,n)}return{newText:` `.repeat(t),range:e}}createLineTextEdit(e,t,n,r){let i=e.end.line-e.start.line;t=this.fitIntoOptions(t,i,r);let a=(n.options.insertSpaces?` `.repeat(n.options.tabSize):` `).repeat(n.indentation);return{newText:`${`
|
|
29
29
|
`.repeat(t)}${a}`,range:e}}createTabTextEdit(e,t,n){let r=(n.options.insertSpaces?` `.repeat(n.options.tabSize):` `).repeat(n.indentation),i=t?1:0,a=Math.max(e.end.line-e.start.line,i);return{newText:`${`
|
|
30
|
-
`.repeat(a)}${r}`,range:e}}fitIntoOptions(e,t,n){return n.allowMore?e=Math.max(t,e):n.allowLess&&(e=Math.min(t,e)),e}findFittingMove(e,t,n){if(t.length===0)return;if(t.length===1)return t[0];let r=e.end.line-e.start.line;for(let e of t)if(e.lines!==void 0&&r<=e.lines)return e;else if(e.lines===void 0&&r===0)return e;return t[t.length-1]}iterateCstTree(e,t){let n=e.parseResult.value.$cstNode;return n?new wi(n,e=>this.iterateCst(e,t)):Ci}iterateCst(e,t){if(!kn(e))return Ci;let n=t.indentation;return new bi(()=>({index:0}),r=>r.index<e.content.length?{done:!1,value:e.content[r.index++]}:(t.indentation=n,K))}},Ql=class{constructor(e,t){this.astNode=e,this.collector=t}node(e){return new $l(e.$cstNode?[e.$cstNode]:[],this.collector)}nodes(...e){let t=[];for(let n of e)n.$cstNode&&t.push(n.$cstNode);return new $l(t,this.collector)}property(e,t){let n=ja(this.astNode.$cstNode,e,t);return new $l(n?[n]:[],this.collector)}properties(...e){let t=[];for(let n of e){let e=Aa(this.astNode.$cstNode,n);t.push(...e)}return new $l(t,this.collector)}keyword(e,t){let n=Pa(this.astNode.$cstNode,e,t);return new $l(n?[n]:[],this.collector)}keywords(...e){let t=[];for(let n of e){let e=Na(this.astNode.$cstNode,n);t.push(...e)}return new $l(t,this.collector)}cst(e){return new $l([...e],this.collector)}interior(e,t){let n=e.nodes,r=t.nodes;if(n.length!==1||r.length!==1)return new $l([],this.collector);let i=n[0],a=r[0];if(i.offset>a.offset){let e=i;i=a,a=e}return new $l(Gi(i,a),this.collector)}},$l=class e{constructor(e,t){this.nodes=e,this.collector=t}prepend(e){for(let t of this.nodes)this.collector(t,`prepend`,e);return this}append(e){for(let t of this.nodes)this.collector(t,`append`,e);return this}surround(e){for(let t of this.nodes)this.collector(t,`prepend`,e),this.collector(t,`append`,e);return this}slice(t,n){return new e(this.nodes.slice(t,n),this.collector)}},eu;(function(e){function t(...e){return{options:{},moves:e.flatMap(e=>e.moves).sort(l)}}e.fit=t;function n(e){return i(0,e)}e.noSpace=n;function r(e){return i(1,e)}e.oneSpace=r;function i(e,t){return{options:t??{},moves:[{characters:e}]}}e.spaces=i;function a(e){return o(1,e)}e.newLine=a;function o(e,t){return{options:t??{},moves:[{lines:e}]}}e.newLines=o;function s(e){return{options:e??{},moves:[{tabs:1,lines:1}]}}e.indent=s;function c(e){return{options:e??{},moves:[{tabs:0}]}}e.noIndent=c;function l(e,t){let n=e.lines??0,r=t.lines??0,i=e.tabs??0,a=t.tabs??0,o=e.characters??0,s=t.characters??0;return n<r?-1:n>r?1:i<a?-1:i>a?1:o<s?-1:o>s?1:0}})(eu||={});var tu=class{constructor(){this.encoding=`utf-8`}readFile(e){return y.promises.readFile(e.fsPath,this.encoding)}async readDirectory(e){return(await y.promises.readdir(e.fsPath,{withFileTypes:!0})).map(t=>({dirent:t,isFile:t.isFile(),isDirectory:t.isDirectory(),uri:X.joinPath(e,t.name)}))}};export{
|
|
30
|
+
`.repeat(a)}${r}`,range:e}}fitIntoOptions(e,t,n){return n.allowMore?e=Math.max(t,e):n.allowLess&&(e=Math.min(t,e)),e}findFittingMove(e,t,n){if(t.length===0)return;if(t.length===1)return t[0];let r=e.end.line-e.start.line;for(let e of t)if(e.lines!==void 0&&r<=e.lines)return e;else if(e.lines===void 0&&r===0)return e;return t[t.length-1]}iterateCstTree(e,t){let n=e.parseResult.value.$cstNode;return n?new wi(n,e=>this.iterateCst(e,t)):Ci}iterateCst(e,t){if(!kn(e))return Ci;let n=t.indentation;return new bi(()=>({index:0}),r=>r.index<e.content.length?{done:!1,value:e.content[r.index++]}:(t.indentation=n,K))}},Ql=class{constructor(e,t){this.astNode=e,this.collector=t}node(e){return new $l(e.$cstNode?[e.$cstNode]:[],this.collector)}nodes(...e){let t=[];for(let n of e)n.$cstNode&&t.push(n.$cstNode);return new $l(t,this.collector)}property(e,t){let n=ja(this.astNode.$cstNode,e,t);return new $l(n?[n]:[],this.collector)}properties(...e){let t=[];for(let n of e){let e=Aa(this.astNode.$cstNode,n);t.push(...e)}return new $l(t,this.collector)}keyword(e,t){let n=Pa(this.astNode.$cstNode,e,t);return new $l(n?[n]:[],this.collector)}keywords(...e){let t=[];for(let n of e){let e=Na(this.astNode.$cstNode,n);t.push(...e)}return new $l(t,this.collector)}cst(e){return new $l([...e],this.collector)}interior(e,t){let n=e.nodes,r=t.nodes;if(n.length!==1||r.length!==1)return new $l([],this.collector);let i=n[0],a=r[0];if(i.offset>a.offset){let e=i;i=a,a=e}return new $l(Gi(i,a),this.collector)}},$l=class e{constructor(e,t){this.nodes=e,this.collector=t}prepend(e){for(let t of this.nodes)this.collector(t,`prepend`,e);return this}append(e){for(let t of this.nodes)this.collector(t,`append`,e);return this}surround(e){for(let t of this.nodes)this.collector(t,`prepend`,e),this.collector(t,`append`,e);return this}slice(t,n){return new e(this.nodes.slice(t,n),this.collector)}},eu;(function(e){function t(...e){return{options:{},moves:e.flatMap(e=>e.moves).sort(l)}}e.fit=t;function n(e){return i(0,e)}e.noSpace=n;function r(e){return i(1,e)}e.oneSpace=r;function i(e,t){return{options:t??{},moves:[{characters:e}]}}e.spaces=i;function a(e){return o(1,e)}e.newLine=a;function o(e,t){return{options:t??{},moves:[{lines:e}]}}e.newLines=o;function s(e){return{options:e??{},moves:[{tabs:1,lines:1}]}}e.indent=s;function c(e){return{options:e??{},moves:[{tabs:0}]}}e.noIndent=c;function l(e,t){let n=e.lines??0,r=t.lines??0,i=e.tabs??0,a=t.tabs??0,o=e.characters??0,s=t.characters??0;return n<r?-1:n>r?1:i<a?-1:i>a?1:o<s?-1:o>s?1:0}})(eu||={});var tu=class{constructor(){this.encoding=`utf-8`}readFile(e){return y.promises.readFile(e.fsPath,this.encoding)}async readDirectory(e){return(await y.promises.readdir(e.fsPath,{withFileTypes:!0})).map(t=>({dirent:t,isFile:t.isFile(),isDirectory:t.isDirectory(),uri:X.joinPath(e,t.name)}))}};export{oi as $,$ as A,ja as B,Ls as C,js as D,Ns as E,ds as F,Qi as G,Sa as H,X as I,Li as J,Zi as K,Y as L,Q as M,vs as N,As as O,us as P,ei as Q,So as R,Rs as S,Fs as T,Ji as U,Aa as V,Xi as W,q as X,Ci as Y,Jr as Z,Xs as _,Yl as a,ge as at,Bs as b,kl as c,I as ct,cl as d,Xe as dt,On as et,ol as f,L as ft,jc as g,qc as h,ql as i,Ie as it,xs as j,Ds as k,yl as l,ut as lt,$c as m,k as mt,Zl as n,wn as nt,Ul as o,Le as ot,tl as p,kt as pt,ta as q,eu as r,H as rt,Fl as s,F as st,tu as t,U as tt,fl as u,lt as ut,Ws as v,Is as w,Us as x,Vs as y,Pa as z};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import{r as e}from"../rolldown-runtime.mjs";import{t}from"./decode-named-character-reference.mjs";const n=m(/[A-Za-z]/),r=m(/[\dA-Za-z]/),i=m(/[#-'*+\--9=?A-Z^-~]/);function a(e){return e!==null&&(e<32||e===127)}const o=m(/\d/),s=m(/[\dA-Fa-f]/),c=m(/[!-/:-@[-`{-~]/);function l(e){return e!==null&&e<-2}function u(e){return e!==null&&(e<0||e===32)}function d(e){return e===-2||e===-1||e===32}const f=m(/\p{P}|\p{S}/u),p=m(/\s/);function m(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function h(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}function g(e){if(e===null||u(e)||p(e))return 1;if(f(e))return 2}const _={};function v(e,t){let n=t||_;return y(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function y(e,t,n){if(x(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return b(e.children,t,n)}return Array.isArray(e)?b(e,t,n):``}function b(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=y(e[i],t,n);return r.join(``)}function x(e){return!!(e&&typeof e==`object`)}function S(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}const C=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function w(e){return e.replace(C,T)}function T(e,n,r){if(n)return n;if(r.charCodeAt(0)===35){let e=r.charCodeAt(1),t=e===120||e===88;return S(r.slice(t?2:1),t?16:10)}return t(r)||e}function E(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function D(e,t){return e.length>0?(E(e,e.length,0,t),e):t}const O={}.hasOwnProperty;function k(e){let t={},n=-1;for(;++n<e.length;)A(t,e[n]);return t}function A(e,t){let n;for(n in t){let r=(O.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){O.call(r,a)||(r[a]=[]);let e=i[a];j(r[a],Array.isArray(e)?e:e?[e]:[])}}}function j(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);E(e,0,0,r)}function M(e){let t=[],n=-1,i=0,a=0;for(;++n<e.length;){let o=e.charCodeAt(n),s=``;if(o===37&&r(e.charCodeAt(n+1))&&r(e.charCodeAt(n+2)))a=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(s=String.fromCharCode(o));else if(o>55295&&o<57344){let t=e.charCodeAt(n+1);o<56320&&t>56319&&t<57344?(s=String.fromCharCode(o,t),a=1):s=`�`}else s=String.fromCharCode(o);s&&=(t.push(e.slice(i,n),encodeURIComponent(s)),i=n+a+1,``),a&&=(n+=a,0)}return t.join(``)+e.slice(i)}function N(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const P={name:`attention`,resolveAll:F,tokenize:I};function F(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};L(d,-c),L(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=D(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=D(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=D(l,N(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=D(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=D(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,E(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function I(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=g(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=g(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function L(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const R={name:`autolink`,tokenize:z};function z(e,t,o){let s=0;return c;function c(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),l}function l(t){return n(t)?(e.consume(t),u):t===64?o(t):p(t)}function u(e){return e===43||e===45||e===46||r(e)?(s=1,d(e)):p(e)}function d(t){return t===58?(e.consume(t),s=0,f):(t===43||t===45||t===46||r(t))&&s++<32?(e.consume(t),d):(s=0,p(t))}function f(n){return n===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):n===null||n===32||n===60||a(n)?o(n):(e.consume(n),f)}function p(t){return t===64?(e.consume(t),m):i(t)?(e.consume(t),p):o(t)}function m(e){return r(e)?h(e):o(e)}function h(n){return n===46?(e.consume(n),s=0,m):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):g(n)}function g(t){if((t===45||r(t))&&s++<63){let n=t===45?g:h;return e.consume(t),n}return o(t)}}function B(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return d(r)?(e.enter(n),s(r)):t(r)}function s(r){return d(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}const V={partial:!0,tokenize:H};function H(e,t,n){return r;function r(t){return d(t)?B(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||l(e)?t(e):n(e)}}const U={continuation:{tokenize:te},exit:W,name:`blockQuote`,tokenize:ee};function ee(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return d(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function te(e,t,n){let r=this;return i;function i(t){return d(t)?B(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(U,t,n)(r)}}function W(e){e.exit(`blockQuote`)}const ne={name:`characterEscape`,tokenize:re};function re(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return c(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}const G={name:`characterReference`,tokenize:ie};function ie(e,n,i){let a=this,c=0,l,u;return d;function d(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),f}function f(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),p):(e.enter(`characterReferenceValue`),l=31,u=r,m(t))}function p(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),l=6,u=s,m):(e.enter(`characterReferenceValue`),l=7,u=o,m(t))}function m(o){if(o===59&&c){let s=e.exit(`characterReferenceValue`);return u===r&&!t(a.sliceSerialize(s))?i(o):(e.enter(`characterReferenceMarker`),e.consume(o),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),n)}return u(o)&&c++<l?(e.consume(o),m):i(o)}}const ae={partial:!0,tokenize:se},K={concrete:!0,name:`codeFenced`,tokenize:oe};function oe(e,t,n){let r=this,i={partial:!0,tokenize:C},a=0,o=0,s;return c;function c(e){return u(e)}function u(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),f(t)}function f(t){return t===s?(o++,e.consume(t),f):o<3?n(t):(e.exit(`codeFencedFenceSequence`),d(t)?B(e,p,`whitespace`)(t):p(t))}function p(n){return n===null||l(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(ae,_,S)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),m(n))}function m(t){return t===null||l(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),p(t)):d(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),B(e,h,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return t===null||l(t)?p(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),g(t))}function g(t){return t===null||l(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),p(t)):t===96&&t===s?n(t):(e.consume(t),g)}function _(t){return e.attempt(i,S,v)(t)}function v(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),y}function y(t){return a>0&&d(t)?B(e,b,`linePrefix`,a+1)(t):b(t)}function b(t){return t===null||l(t)?e.check(ae,_,S)(t):(e.enter(`codeFlowValue`),x(t))}function x(t){return t===null||l(t)?(e.exit(`codeFlowValue`),b(t)):(e.consume(t),x)}function S(n){return e.exit(`codeFenced`),t(n)}function C(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),d(t)?B(e,u,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):u(t)}function u(t){return t===s?(e.enter(`codeFencedFenceSequence`),f(t)):n(t)}function f(t){return t===s?(i++,e.consume(t),f):i>=o?(e.exit(`codeFencedFenceSequence`),d(t)?B(e,p,`whitespace`)(t):p(t)):n(t)}function p(r){return r===null||l(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function se(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}const q={name:`codeIndented`,tokenize:le},ce={partial:!0,tokenize:ue};function le(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),B(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):l(t)?e.attempt(ce,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||l(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function ue(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):l(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):B(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):l(e)?i(e):n(e)}}const de={name:`codeText`,previous:pe,resolve:fe,tokenize:me};function fe(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function pe(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function me(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,d(t)):l(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),u(t))}function u(t){return t===null||t===32||t===96||l(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),u)}function d(n){return n===96?(e.consume(n),i++,d):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,u(n))}}var he=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw 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,t){let n=t??1/0;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,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&J(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),J(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),J(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){let t=this.left.splice(e,1/0);J(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);J(this.left,t.reverse())}}};function J(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function ge(e){let t={},n=-1,r,i,a,o,s,c,l,u=new he(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,_e(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return E(e,0,1/0,u.slice(0)),!l}function _e(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}const ve={resolve:be,tokenize:xe},ye={partial:!0,tokenize:Se};function be(e){return ge(e),e}function xe(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):l(t)?e.check(ye,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Se(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),B(e,a,`linePrefix`)}function a(i){if(i===null||l(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Ce(e,t,n,r,i,o,s,c,d){let f=d||1/0,p=0;return m;function m(t){return t===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(t),e.exit(o),h):t===null||t===32||t===41||a(t)?n(t):(e.enter(r),e.enter(s),e.enter(c),e.enter(`chunkString`,{contentType:`string`}),v(t))}function h(n){return n===62?(e.enter(o),e.consume(n),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(c),e.enter(`chunkString`,{contentType:`string`}),g(n))}function g(t){return t===62?(e.exit(`chunkString`),e.exit(c),h(t)):t===null||t===60||l(t)?n(t):(e.consume(t),t===92?_:g)}function _(t){return t===60||t===62||t===92?(e.consume(t),g):g(t)}function v(i){return!p&&(i===null||i===41||u(i))?(e.exit(`chunkString`),e.exit(c),e.exit(s),e.exit(r),t(i)):p<f&&i===40?(e.consume(i),p++,v):i===41?(e.consume(i),p--,v):i===null||i===32||i===40||a(i)?n(i):(e.consume(i),i===92?y:v)}function y(t){return t===40||t===41||t===92?(e.consume(t),v):v(t)}}function we(e,t,n,r,i,a){let o=this,s=0,c;return u;function u(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),f}function f(u){return s>999||u===null||u===91||u===93&&!c||u===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(u):u===93?(e.exit(a),e.enter(i),e.consume(u),e.exit(i),e.exit(r),t):l(u)?(e.enter(`lineEnding`),e.consume(u),e.exit(`lineEnding`),f):(e.enter(`chunkString`,{contentType:`string`}),p(u))}function p(t){return t===null||t===91||t===93||l(t)||s++>999?(e.exit(`chunkString`),f(t)):(e.consume(t),c||=!d(t),t===92?m:p)}function m(t){return t===91||t===92||t===93?(e.consume(t),s++,p):p(t)}}function Te(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),u(n))}function u(t){return t===o?(e.exit(a),c(o)):t===null?n(t):l(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),B(e,u,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),d(t))}function d(t){return t===o||t===null||l(t)?(e.exit(`chunkString`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===o||t===92?(e.consume(t),d):d(t)}}function Y(e,t){let n;return r;function r(i){return l(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):d(i)?B(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}const Ee={name:`definition`,tokenize:Oe},De={partial:!0,tokenize:ke};function Oe(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return we.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=h(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return u(t)?Y(e,f)(t):f(t)}function f(t){return Ce(e,p,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function p(t){return e.attempt(De,m,m)(t)}function m(t){return d(t)?B(e,g,`whitespace`)(t):g(t)}function g(a){return a===null||l(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function ke(e,t,n){return r;function r(t){return u(t)?Y(e,i)(t):n(t)}function i(t){return Te(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return d(t)?B(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||l(e)?t(e):n(e)}}const Ae={name:`hardBreakEscape`,tokenize:je};function je(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return l(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}const Me={name:`headingAtx`,resolve:Ne,tokenize:Pe};function Ne(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},E(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Pe(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||u(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||l(n)?(e.exit(`atxHeading`),t(n)):d(n)?B(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),f(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function f(t){return t===null||t===35||u(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),f)}}const Fe=`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`.split(`.`),Ie=[`pre`,`script`,`style`,`textarea`],Le={concrete:!0,name:`htmlFlow`,resolveTo:Be,tokenize:Ve},Re={partial:!0,tokenize:Ue},ze={partial:!0,tokenize:He};function Be(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Ve(e,t,i){let a=this,o,s,c,f,p;return m;function m(e){return h(e)}function h(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),g}function g(r){return r===33?(e.consume(r),_):r===47?(e.consume(r),s=!0,b):r===63?(e.consume(r),o=3,a.interrupt?t:V):n(r)?(e.consume(r),c=String.fromCharCode(r),x):i(r)}function _(r){return r===45?(e.consume(r),o=2,v):r===91?(e.consume(r),o=5,f=0,y):n(r)?(e.consume(r),o=4,a.interrupt?t:V):i(r)}function v(n){return n===45?(e.consume(n),a.interrupt?t:V):i(n)}function y(n){return n===`CDATA[`.charCodeAt(f++)?(e.consume(n),f===6?a.interrupt?t:N:y):i(n)}function b(t){return n(t)?(e.consume(t),c=String.fromCharCode(t),x):i(t)}function x(n){if(n===null||n===47||n===62||u(n)){let r=n===47,l=c.toLowerCase();return!r&&!s&&Ie.includes(l)?(o=1,a.interrupt?t(n):N(n)):Fe.includes(c.toLowerCase())?(o=6,r?(e.consume(n),S):a.interrupt?t(n):N(n)):(o=7,a.interrupt&&!a.parser.lazy[a.now().line]?i(n):s?C(n):w(n))}return n===45||r(n)?(e.consume(n),c+=String.fromCharCode(n),x):i(n)}function S(n){return n===62?(e.consume(n),a.interrupt?t:N):i(n)}function C(t){return d(t)?(e.consume(t),C):j(t)}function w(t){return t===47?(e.consume(t),j):t===58||t===95||n(t)?(e.consume(t),T):d(t)?(e.consume(t),w):j(t)}function T(t){return t===45||t===46||t===58||t===95||r(t)?(e.consume(t),T):E(t)}function E(t){return t===61?(e.consume(t),D):d(t)?(e.consume(t),E):w(t)}function D(t){return t===null||t===60||t===61||t===62||t===96?i(t):t===34||t===39?(e.consume(t),p=t,O):d(t)?(e.consume(t),D):k(t)}function O(t){return t===p?(e.consume(t),p=null,A):t===null||l(t)?i(t):(e.consume(t),O)}function k(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||u(t)?E(t):(e.consume(t),k)}function A(e){return e===47||e===62||d(e)?w(e):i(e)}function j(t){return t===62?(e.consume(t),M):i(t)}function M(t){return t===null||l(t)?N(t):d(t)?(e.consume(t),M):i(t)}function N(t){return t===45&&o===2?(e.consume(t),L):t===60&&o===1?(e.consume(t),R):t===62&&o===4?(e.consume(t),H):t===63&&o===3?(e.consume(t),V):t===93&&o===5?(e.consume(t),B):l(t)&&(o===6||o===7)?(e.exit(`htmlFlowData`),e.check(Re,U,P)(t)):t===null||l(t)?(e.exit(`htmlFlowData`),P(t)):(e.consume(t),N)}function P(t){return e.check(ze,F,U)(t)}function F(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),I}function I(t){return t===null||l(t)?P(t):(e.enter(`htmlFlowData`),N(t))}function L(t){return t===45?(e.consume(t),V):N(t)}function R(t){return t===47?(e.consume(t),c=``,z):N(t)}function z(t){if(t===62){let n=c.toLowerCase();return Ie.includes(n)?(e.consume(t),H):N(t)}return n(t)&&c.length<8?(e.consume(t),c+=String.fromCharCode(t),z):N(t)}function B(t){return t===93?(e.consume(t),V):N(t)}function V(t){return t===62?(e.consume(t),H):t===45&&o===2?(e.consume(t),V):N(t)}function H(t){return t===null||l(t)?(e.exit(`htmlFlowData`),U(t)):(e.consume(t),H)}function U(n){return e.exit(`htmlFlow`),t(n)}}function He(e,t,n){let r=this;return i;function i(t){return l(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Ue(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(V,t,n)}}const We={name:`htmlText`,tokenize:Ge};function Ge(e,t,i){let a=this,o,s,c;return f;function f(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),p}function p(t){return t===33?(e.consume(t),m):t===47?(e.consume(t),E):t===63?(e.consume(t),w):n(t)?(e.consume(t),k):i(t)}function m(t){return t===45?(e.consume(t),h):t===91?(e.consume(t),s=0,y):n(t)?(e.consume(t),C):i(t)}function h(t){return t===45?(e.consume(t),v):i(t)}function g(t){return t===null?i(t):t===45?(e.consume(t),_):l(t)?(c=g,R(t)):(e.consume(t),g)}function _(t){return t===45?(e.consume(t),v):g(t)}function v(e){return e===62?L(e):e===45?_(e):g(e)}function y(t){return t===`CDATA[`.charCodeAt(s++)?(e.consume(t),s===6?b:y):i(t)}function b(t){return t===null?i(t):t===93?(e.consume(t),x):l(t)?(c=b,R(t)):(e.consume(t),b)}function x(t){return t===93?(e.consume(t),S):b(t)}function S(t){return t===62?L(t):t===93?(e.consume(t),S):b(t)}function C(t){return t===null||t===62?L(t):l(t)?(c=C,R(t)):(e.consume(t),C)}function w(t){return t===null?i(t):t===63?(e.consume(t),T):l(t)?(c=w,R(t)):(e.consume(t),w)}function T(e){return e===62?L(e):w(e)}function E(t){return n(t)?(e.consume(t),D):i(t)}function D(t){return t===45||r(t)?(e.consume(t),D):O(t)}function O(t){return l(t)?(c=O,R(t)):d(t)?(e.consume(t),O):L(t)}function k(t){return t===45||r(t)?(e.consume(t),k):t===47||t===62||u(t)?A(t):i(t)}function A(t){return t===47?(e.consume(t),L):t===58||t===95||n(t)?(e.consume(t),j):l(t)?(c=A,R(t)):d(t)?(e.consume(t),A):L(t)}function j(t){return t===45||t===46||t===58||t===95||r(t)?(e.consume(t),j):M(t)}function M(t){return t===61?(e.consume(t),N):l(t)?(c=M,R(t)):d(t)?(e.consume(t),M):A(t)}function N(t){return t===null||t===60||t===61||t===62||t===96?i(t):t===34||t===39?(e.consume(t),o=t,P):l(t)?(c=N,R(t)):d(t)?(e.consume(t),N):(e.consume(t),F)}function P(t){return t===o?(e.consume(t),o=void 0,I):t===null?i(t):l(t)?(c=P,R(t)):(e.consume(t),P)}function F(t){return t===null||t===34||t===39||t===60||t===61||t===96?i(t):t===47||t===62||u(t)?A(t):(e.consume(t),F)}function I(e){return e===47||e===62||u(e)?A(e):i(e)}function L(n){return n===62?(e.consume(n),e.exit(`htmlTextData`),e.exit(`htmlText`),t):i(n)}function R(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),z}function z(t){return d(t)?B(e,V,`linePrefix`,a.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):V(t)}function V(t){return e.enter(`htmlTextData`),c(t)}}const Ke={name:`labelEnd`,resolveAll:Xe,resolveTo:Ze,tokenize:Qe},qe={tokenize:$e},Je={tokenize:et},Ye={tokenize:tt};function Xe(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&E(e,0,e.length,n),e}function Ze(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=D(s,e.slice(a+1,a+r+3)),s=D(s,[[`enter`,u,t]]),s=D(s,N(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=D(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=D(s,e.slice(o+1)),s=D(s,[[`exit`,c,t]]),E(e,a,e.length,s),e}function Qe(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(h(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(qe,u,o?u:d)(t):t===91?e.attempt(Je,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Ye,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function $e(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return u(t)?Y(e,a)(t):a(t)}function a(t){return t===41?d(t):Ce(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return u(t)?Y(e,c)(t):d(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Te(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):d(t)}function l(t){return u(t)?Y(e,d)(t):d(t)}function d(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function et(e,t,n){let r=this;return i;function i(t){return we.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(h(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function tt(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}const nt={name:`labelStartImage`,resolveAll:Ke.resolveAll,tokenize:rt};function rt(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}const it={name:`labelStartLink`,resolveAll:Ke.resolveAll,tokenize:at};function at(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}const ot={name:`lineEnding`,tokenize:st};function st(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),B(e,t,`linePrefix`)}}const X={name:`thematicBreak`,tokenize:ct};function ct(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||l(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),d(t)?B(e,s,`whitespace`)(t):s(t))}}const Z={continuation:{tokenize:ft},exit:mt,name:`list`,tokenize:dt},lt={partial:!0,tokenize:ht},ut={partial:!0,tokenize:pt};function dt(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,s=0;return c;function c(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:o(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(X,n,u)(t):u(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),l(t)}return n(t)}function l(t){return o(t)&&++s<10?(e.consume(t),l):(!r.interrupt||s<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),u(t)):n(t)}function u(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(V,r.interrupt?n:f,e.attempt(lt,m,p))}function f(e){return r.containerState.initialBlankLine=!0,a++,m(e)}function p(t){return d(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),m):n(t)}function m(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function ft(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(V,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,B(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!d(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(ut,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,B(e,e.attempt(Z,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function pt(e,t,n){let r=this;return B(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function mt(e){e.exit(this.containerState.type)}function ht(e,t,n){let r=this;return B(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!d(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}const gt={name:`setextUnderline`,resolveTo:_t,tokenize:vt};function _t(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function vt(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),d(t)?B(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||l(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}({}).hasOwnProperty;const yt={tokenize:bt};function bt(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),B(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return l(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}const xt={tokenize:Ct},St={tokenize:wt};function Ct(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,u)(i)}return u(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&y();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}v(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return E(t.events,a+1,0,t.events.slice(n)),t.events.length=s,u(e)}return s(e)}function u(a){if(r===n.length){if(!i)return p(a);if(i.currentConstruct&&i.currentConstruct.concrete)return h(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(St,d,f)(a)}function d(e){return i&&y(),v(r),p(e)}function f(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,h(e)}function p(n){return t.containerState={},e.attempt(St,m,h)(n)}function m(e){return r++,n.push([t.currentConstruct,t.containerState]),p(e)}function h(n){if(n===null){i&&y(),v(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),g(n)}function g(n){if(n===null){_(e.exit(`chunkFlow`),!0),v(0),e.consume(n);return}return l(n)?(e.consume(n),_(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),g)}function _(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(v(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;E(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function v(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function y(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function wt(e,t,n){return B(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}const Tt={tokenize:Et};function Et(e){let t=this,n=e.attempt(V,r,e.attempt(this.parser.constructs.flowInitial,i,B(e,e.attempt(this.parser.constructs.flow,i,e.attempt(ve,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}const Dt={resolveAll:jt()},Ot=At(`string`),kt=At(`text`);function At(e){return{resolveAll:jt(e===`text`?Mt:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function jt(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function Mt(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var Nt=e({attentionMarkers:()=>Vt,contentInitial:()=>Ft,disable:()=>Ht,document:()=>Pt,flow:()=>Lt,flowInitial:()=>It,insideSpan:()=>Bt,string:()=>Rt,text:()=>zt});const Pt={42:Z,43:Z,45:Z,48:Z,49:Z,50:Z,51:Z,52:Z,53:Z,54:Z,55:Z,56:Z,57:Z,62:U},Ft={91:Ee},It={[-2]:q,[-1]:q,32:q},Lt={35:Me,42:X,45:[gt,X],60:Le,61:gt,95:X,96:K,126:K},Rt={38:G,92:ne},zt={[-5]:ot,[-4]:ot,[-3]:ot,33:nt,38:G,42:P,60:[R,We],91:it,92:[Ae,ne],93:Ke,95:P,96:de},Bt={null:[P,Dt]},Vt={null:[42,95]},Ht={null:[]};function Ut(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:w(S),check:w(C),consume:y,enter:b,exit:x,interrupt:w(C,{interrupt:!0})},u={code:null,containerState:{},defineSkip:g,events:[],now:h,parser:e,previous:null,sliceSerialize:p,sliceStream:m,write:f},d=t.tokenize.call(u,c);return t.resolveAll&&a.push(t),u;function f(e){return o=D(o,e),_(),o[o.length-1]===null?(T(t,0),u.events=N(a,u.events,u),u.events):[]}function p(e,t){return Gt(m(e),t)}function m(e){return Wt(o,e)}function h(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function g(e){i[e.line]=e.column,k()}function _(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)v(t.charCodeAt(r._bufferIndex));else v(t)}}function v(e){d=d(e)}function y(e){l(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,k()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=e}function b(e,t){let n=t||{};return n.type=e,n.start=h(),u.events.push([`enter`,n,u]),s.push(n),n}function x(e){let t=s.pop();return t.end=h(),u.events.push([`exit`,t,u]),t}function S(e,t){T(e,t.from)}function C(e,t){t.restore()}function w(e,t){return n;function n(n,r,i){let a,o,s,l;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return l=O(),s=e,e.partial||(u.currentConstruct=e),e.name&&u.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(u),t):u,c,m,h)(n)}}function m(t){return e(s,l),r}function h(e){return l.restore(),++o<a.length?p(a[o]):i}}}function T(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&E(u.events,t,u.events.length-t,e.resolve(u.events.slice(t),u)),e.resolveTo&&(u.events=e.resolveTo(u.events,u))}function O(){let e=h(),t=u.previous,n=u.currentConstruct,i=u.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,u.previous=t,u.currentConstruct=n,u.events.length=i,s=a,k()}}function k(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Wt(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Gt(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
2
2
|
`;break;case-3:o=`\r
|
|
3
|
-
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function Kt(e){let t={constructs:k([Nt,...(e||{}).extensions||[]]),content:n(yt),defined:[],document:n(xt),flow:n(Tt),lazy:{},string:n(Ot),text:n(kt)};return t;function n(e){return n;function n(n){return Ut(t,e,n)}}}function qt(e){for(;!ge(e););return e}const Jt=/[\0\t\n\r]/g;function Yt(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(Jt.lastIndex=u,c=Jt.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}function Q(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Zt(e.position):`start`in e||`end`in e?Zt(e):`line`in e||`column`in e?Xt(e):``}function Xt(e){return Qt(e&&e.line)+`:`+Qt(e&&e.column)}function Zt(e){return Xt(e&&e.start)+`-`+Xt(e&&e.end)}function Qt(e){return e&&typeof e==`number`?e:1}const $t={}.hasOwnProperty;function en(e,t,n){return typeof t!=`string`&&(n=t,t=void 0),tn(n)(qt(Kt(n).document().write(Yt()(e,t,!0))))}function tn(e){let n={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:o(fe),autolinkProtocol:A,autolinkEmail:A,atxHeading:o(ce),blockQuote:o(ae),characterEscape:A,characterReference:A,codeFenced:o(K),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(K,s),codeText:o(oe,s),codeTextData:A,data:A,codeFlowValue:A,definition:o(se),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(q),hardBreakEscape:o(le),hardBreakTrailing:o(le),htmlFlow:o(ue,s),htmlFlowData:A,htmlText:o(ue,s),htmlTextData:A,image:o(de),label:s,link:o(fe),listItem:o(me),listItemValue:p,listOrdered:o(pe,f),listUnordered:o(pe),paragraph:o(he),reference:ee,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(ce),strong:o(J),thematicBreak:o(_e)},exit:{atxHeading:l(),atxHeadingSequence:E,autolink:l(),autolinkEmail:ie,autolinkProtocol:G,blockQuote:l(),characterEscapeValue:j,characterReferenceMarkerHexadecimal:W,characterReferenceMarkerNumeric:W,characterReferenceValue:ne,characterReference:re,codeFenced:l(y),codeFencedFence:_,codeFencedFenceInfo:m,codeFencedFenceMeta:g,codeFlowValue:j,codeIndented:l(b),codeText:l(I),codeTextData:j,data:j,definition:l(),definitionDestinationString:T,definitionLabelString:x,definitionTitleString:C,emphasis:l(),hardBreakEscape:l(N),hardBreakTrailing:l(N),htmlFlow:l(P),htmlFlowData:j,htmlText:l(F),htmlTextData:j,image:l(R),label:B,labelText:z,lineEnding:M,link:l(L),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:te,resourceDestinationString:V,resourceTitleString:H,resource:U,setextHeading:l(k),setextHeadingLineSequence:O,setextHeadingText:D,strong:l(),thematicBreak:l()}};nn(n,(e||{}).mdastExtensions||[]);let r={};return i;function i(e){let t={type:`root`,children:[]},i={stack:[t],tokenStack:[],config:n,enter:c,exit:u,buffer:s,resume:d,data:r},o=[],l=-1;for(;++l<e.length;)(e[l][1].type===`listOrdered`||e[l][1].type===`listUnordered`)&&(e[l][0]===`enter`?o.push(l):l=a(e,o.pop(),l));for(l=-1;++l<e.length;){let t=n[e[l][0]];$t.call(t,e[l][1].type)&&t[e[l][1].type].call(Object.assign({sliceSerialize:e[l][2].sliceSerialize},i),e[l][1])}if(i.tokenStack.length>0){let e=i.tokenStack[i.tokenStack.length-1];(e[1]||an).call(i,void 0,e[0])}for(t.position={start:$(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:$(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},l=-1;++l<n.transforms.length;)t=n.transforms[l](t)||t;return t}function a(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function o(e,t){return n;function n(n){c.call(this,e(n),n),t&&t.call(this,n)}}function s(){this.stack.push({type:`fragment`,children:[]})}function c(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:$(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),u.call(this,t)}}function u(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||an).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+Q({start:e.start,end:e.end})+`): it’s not open`);n.position.end=$(e.end)}function d(){return v(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function _(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function x(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=h(this.sliceSerialize(e)).toLowerCase()}function C(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function T(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function E(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function D(){this.data.setextHeadingSlurpLineEnding=!0}function O(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function k(){this.data.setextHeadingSlurpLineEnding=void 0}function A(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=ge(),n.position={start:$(e.start),end:void 0},t.push(n)),this.stack.push(n)}function j(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=$(e.end)}function M(e){let t=this.stack[this.stack.length-1];if(this.data.atHardBreak){let n=t.children[t.children.length-1];n.position.end=$(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(t.type)&&(A.call(this,e),j.call(this,e))}function N(){this.data.atHardBreak=!0}function P(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function F(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function L(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function R(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function z(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=w(t),n.identifier=h(t).toLowerCase()}function B(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function V(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function H(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function U(){this.data.inReference=void 0}function ee(){this.data.referenceType=`collapsed`}function te(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=h(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function W(e){this.data.characterReferenceType=e.type}function ne(e){let n=this.sliceSerialize(e),r=this.data.characterReferenceType,i;r?(i=S(n,r===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):i=t(n);let a=this.stack[this.stack.length-1];a.value+=i}function re(e){let t=this.stack.pop();t.position.end=$(e.end)}function G(e){j.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ie(e){j.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ae(){return{type:`blockquote`,children:[]}}function K(){return{type:`code`,lang:null,meta:null,value:``}}function oe(){return{type:`inlineCode`,value:``}}function se(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function q(){return{type:`emphasis`,children:[]}}function ce(){return{type:`heading`,depth:0,children:[]}}function le(){return{type:`break`}}function ue(){return{type:`html`,value:``}}function de(){return{type:`image`,title:null,url:``,alt:null}}function fe(){return{type:`link`,title:null,url:``,children:[]}}function pe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function me(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function he(){return{type:`paragraph`,children:[]}}function J(){return{type:`strong`,children:[]}}function ge(){return{type:`text`,value:``}}function _e(){return{type:`thematicBreak`}}}function $(e){return{line:e.line,column:e.column,offset:e.offset}}function nn(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?nn(e,r):rn(e,r)}}function rn(e,t){let n;for(n in t)if($t.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function an(e,t){throw e?Error("Cannot close `"+e.type+"` ("+Q({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Q({start:t.start,end:t.end})+`) is open`):Error("Cannot close document, a token (`"+t.type+"`, "+Q({start:t.start,end:t.end})+`) is still open`)}export{d as _,N as a,E as c,h as d,n as f,u as g,l as h,B as i,v as l,a as m,Q as n,M as o,r as p,V as r,k as s,en as t,g as u,f as v,p as y};
|
|
3
|
+
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function Kt(e){let t={constructs:k([Nt,...(e||{}).extensions||[]]),content:n(yt),defined:[],document:n(xt),flow:n(Tt),lazy:{},string:n(Ot),text:n(kt)};return t;function n(e){return n;function n(n){return Ut(t,e,n)}}}function qt(e){for(;!ge(e););return e}const Jt=/[\0\t\n\r]/g;function Yt(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(Jt.lastIndex=u,c=Jt.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}function Q(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Zt(e.position):`start`in e||`end`in e?Zt(e):`line`in e||`column`in e?Xt(e):``}function Xt(e){return Qt(e&&e.line)+`:`+Qt(e&&e.column)}function Zt(e){return Xt(e&&e.start)+`-`+Xt(e&&e.end)}function Qt(e){return e&&typeof e==`number`?e:1}const $t={}.hasOwnProperty;function en(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),tn(n)(qt(Kt(n).document().write(Yt()(e,t,!0))))}function tn(e){let n={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:o(fe),autolinkProtocol:A,autolinkEmail:A,atxHeading:o(ce),blockQuote:o(ae),characterEscape:A,characterReference:A,codeFenced:o(K),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(K,s),codeText:o(oe,s),codeTextData:A,data:A,codeFlowValue:A,definition:o(se),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(q),hardBreakEscape:o(le),hardBreakTrailing:o(le),htmlFlow:o(ue,s),htmlFlowData:A,htmlText:o(ue,s),htmlTextData:A,image:o(de),label:s,link:o(fe),listItem:o(me),listItemValue:p,listOrdered:o(pe,f),listUnordered:o(pe),paragraph:o(he),reference:ee,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(ce),strong:o(J),thematicBreak:o(_e)},exit:{atxHeading:l(),atxHeadingSequence:E,autolink:l(),autolinkEmail:ie,autolinkProtocol:G,blockQuote:l(),characterEscapeValue:j,characterReferenceMarkerHexadecimal:W,characterReferenceMarkerNumeric:W,characterReferenceValue:ne,characterReference:re,codeFenced:l(y),codeFencedFence:_,codeFencedFenceInfo:m,codeFencedFenceMeta:g,codeFlowValue:j,codeIndented:l(b),codeText:l(I),codeTextData:j,data:j,definition:l(),definitionDestinationString:T,definitionLabelString:x,definitionTitleString:C,emphasis:l(),hardBreakEscape:l(N),hardBreakTrailing:l(N),htmlFlow:l(P),htmlFlowData:j,htmlText:l(F),htmlTextData:j,image:l(R),label:B,labelText:z,lineEnding:M,link:l(L),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:te,resourceDestinationString:V,resourceTitleString:H,resource:U,setextHeading:l(k),setextHeadingLineSequence:O,setextHeadingText:D,strong:l(),thematicBreak:l()}};nn(n,(e||{}).mdastExtensions||[]);let r={};return i;function i(e){let t={type:`root`,children:[]},i={stack:[t],tokenStack:[],config:n,enter:c,exit:u,buffer:s,resume:d,data:r},o=[],l=-1;for(;++l<e.length;)(e[l][1].type===`listOrdered`||e[l][1].type===`listUnordered`)&&(e[l][0]===`enter`?o.push(l):l=a(e,o.pop(),l));for(l=-1;++l<e.length;){let t=n[e[l][0]];$t.call(t,e[l][1].type)&&t[e[l][1].type].call(Object.assign({sliceSerialize:e[l][2].sliceSerialize},i),e[l][1])}if(i.tokenStack.length>0){let e=i.tokenStack[i.tokenStack.length-1];(e[1]||an).call(i,void 0,e[0])}for(t.position={start:$(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:$(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},l=-1;++l<n.transforms.length;)t=n.transforms[l](t)||t;return t}function a(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function o(e,t){return n;function n(n){c.call(this,e(n),n),t&&t.call(this,n)}}function s(){this.stack.push({type:`fragment`,children:[]})}function c(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:$(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),u.call(this,t)}}function u(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||an).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+Q({start:e.start,end:e.end})+`): it’s not open`);n.position.end=$(e.end)}function d(){return v(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function _(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function x(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=h(this.sliceSerialize(e)).toLowerCase()}function C(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function T(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function E(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function D(){this.data.setextHeadingSlurpLineEnding=!0}function O(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function k(){this.data.setextHeadingSlurpLineEnding=void 0}function A(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=ge(),n.position={start:$(e.start),end:void 0},t.push(n)),this.stack.push(n)}function j(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=$(e.end)}function M(e){let t=this.stack[this.stack.length-1];if(this.data.atHardBreak){let n=t.children[t.children.length-1];n.position.end=$(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(t.type)&&(A.call(this,e),j.call(this,e))}function N(){this.data.atHardBreak=!0}function P(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function F(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function L(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function R(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function z(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=w(t),n.identifier=h(t).toLowerCase()}function B(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function V(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function H(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function U(){this.data.inReference=void 0}function ee(){this.data.referenceType=`collapsed`}function te(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=h(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function W(e){this.data.characterReferenceType=e.type}function ne(e){let n=this.sliceSerialize(e),r=this.data.characterReferenceType,i;r?(i=S(n,r===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):i=t(n);let a=this.stack[this.stack.length-1];a.value+=i}function re(e){let t=this.stack.pop();t.position.end=$(e.end)}function G(e){j.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ie(e){j.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ae(){return{type:`blockquote`,children:[]}}function K(){return{type:`code`,lang:null,meta:null,value:``}}function oe(){return{type:`inlineCode`,value:``}}function se(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function q(){return{type:`emphasis`,children:[]}}function ce(){return{type:`heading`,depth:0,children:[]}}function le(){return{type:`break`}}function ue(){return{type:`html`,value:``}}function de(){return{type:`image`,title:null,url:``,alt:null}}function fe(){return{type:`link`,title:null,url:``,children:[]}}function pe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function me(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function he(){return{type:`paragraph`,children:[]}}function J(){return{type:`strong`,children:[]}}function ge(){return{type:`text`,value:``}}function _e(){return{type:`thematicBreak`}}}function $(e){return{line:e.line,column:e.column,offset:e.offset}}function nn(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?nn(e,r):rn(e,r)}}function rn(e,t){let n;for(n in t)if($t.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function an(e,t){throw e?Error("Cannot close `"+e.type+"` ("+Q({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Q({start:t.start,end:t.end})+`) is open`):Error("Cannot close document, a token (`"+t.type+"`, "+Q({start:t.start,end:t.end})+`) is still open`)}export{d as _,N as a,E as c,h as d,n as f,u as g,l as h,B as i,v as l,a as m,Q as n,M as o,r as p,V as r,k as s,en as t,g as u,f as v,p as y};
|