@likec4/mcp 1.52.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.
@@ -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 m(e,t){if(typeof t==`string`)return f(e,t);if(Array.isArray(e)&&t>=0&&t<e.length)return e[t]}function h(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=p(t,r);if(e===null)return;let{segment:i,nextIndex:a}=e;if(r=a,n=m(n,i),n===void 0)return}return n}function g(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&&d(u)&&(l=h(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 _(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 v=Symbol.for(`logtape.categoryPrefix`);function y(){let e=c.getLogger().contextLocalStorage?.getStore();if(e==null)return[];let t=e[v];return Array.isArray(t)?t:[]}function b(){let e=c.getLogger().contextLocalStorage?.getStore();if(e==null)return{};let t={};for(let n of Object.keys(e))t[n]=e[n];return t}var x=e({inspect:()=>S});function S(e,n){return t.inspect(e,n)}const C={trace:`TRC`,debug:`DBG`,info:`INF`,warning:`WRN`,error:`ERR`,fatal:`FTL`},w=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}):x!=null&&`inspect`in x&&typeof S==`function`?(e,t)=>S(e,{maxArrayLength:1/0,maxStringLength:1/0,...t}):e=>JSON.stringify(e);function T(e){return e<10?`0${e}`:`${e}`}function E(e){return e<10?`00${e}`:e<100?`0${e}`:`${e}`}const D={"date-time-timezone":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())} ${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())} +00:00`},"date-time-tz":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())} ${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())} +00`},"date-time":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())} ${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())}`},"time-timezone":e=>{let t=new Date(e);return`${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())} +00:00`},"time-tz":e=>{let t=new Date(e);return`${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())} +00`},time:e=>{let t=new Date(e);return`${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())}`},date:e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())}`},rfc3339:e=>new Date(e).toISOString(),none:()=>null},O={ABBR:C,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 k(e={}){let t=(()=>{let t=e.timestamp;return t==null?D[`date-time-timezone`]:t===`disabled`?D.none:typeof t==`string`&&t in D?D[t]:t})(),n=e.category??`·`,r=e.value?t=>e.value(t,w):w,i=(()=>{let t=e.level;return t==null||t===`ABBR`?e=>O.ABBR[e]:t===`abbr`?e=>O.abbr[e]:t===`FULL`?e=>O.FULL[e]:t===`full`?e=>O.full[e]:t===`L`?e=>O.L[e]:t===`l`?e=>O.l[e]:t})(),a=e.format??(({timestamp:e,level:t,category:n,message:r})=>`${e?`${e} `:``}[${t}] ${n}: ${r}`);return e=>{let o=e.message,s=o.length,c;if(s===1)c=o[0];else if(s<=6){c=``;for(let e=0;e<s;e++)c+=e%2==0?o[e]:r(o[e])}else{let e=Array(s);for(let t=0;t<s;t++)e[t]=t%2==0?o[t]:r(o[t]);c=e.join(``)}return`${a({timestamp:t(e.timestamp),level:i(e.level),category:typeof n==`function`?n(e.category):e.category.join(n),message:c,record:e})}\n`}}k();const A=`\x1B[0m`,j={black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`},M={bold:`\x1B[1m`,dim:`\x1B[2m`,italic:`\x1B[3m`,underline:`\x1B[4m`,strikethrough:`\x1B[9m`},N={trace:null,debug:`blue`,info:`green`,warning:`yellow`,error:`red`,fatal:`magenta`};function P(e={}){let t=e.format,n=e.timestampStyle===void 0?`dim`:e.timestampStyle,r=e.timestampColor??null,i=`${n==null?``:M[n]}${r==null?``:j[r]}`,a=n==null&&r==null?``:A,o=e.levelStyle===void 0?`bold`:e.levelStyle,s=e.levelColors??N,c=e.categoryStyle===void 0?`dim`:e.categoryStyle,l=e.categoryColor??null,u=`${c==null?``:M[c]}${l==null?``:j[l]}`,d=c==null&&l==null?``:A;return k({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=`${i}${e}${a}`,n=`${o==null?``:M[o]}${f==null?``:j[f]}${n}${o==null&&f==null?``:A}`,t==null?`${e} ${n} ${u}${r}:${d} ${c}`:t({timestamp:e,level:n,category:`${u}${r}${d}`,message:c,record:l})}})}P();function F(e={}){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})+`
3
- `;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})+`
4
- `;let t=e.message[0];for(let n=1;n<e.message.length;n++)t+=n&1?JSON.stringify(e.message[n]):e.message[n];return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:t,logger:e.category.join(`.`),properties:e.properties})+`
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}}const j=M();M({strict:!0}),M({circular:!0}),M({circular:!0,strict:!0}),M({createInternalComparator:()=>l}),M({strict:!0,createInternalComparator:()=>l}),M({circular:!0,createInternalComparator:()=>l}),M({circular:!0,createInternalComparator:()=>l,strict:!0});function M(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{j as t};
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{On as $,xs as A,Aa as B,Is as C,As as D,js as E,X as F,Zi as G,Ji as H,Y as I,Ci as J,ta as K,So as L,vs as M,us as N,Ds as O,ds as P,oi as Q,Pa as R,Ls as S,Ns as T,Xi as U,Sa as V,Qi as W,Jr as X,q as Y,ei as Z,Xs as _,Yl as a,Le as at,Us as b,kl as c,ut as ct,cl as d,L as dt,U as et,ol as f,kt as ft,jc as g,qc as h,ql as i,ge as it,Q as j,$ as k,yl as l,lt,$c as m,Zl as n,H as nt,Ul as o,F as ot,tl as p,k as pt,Li as q,eu as r,Ie as rt,Fl as s,I as st,tu as t,wn as tt,fl as u,Xe as ut,Ws as v,Fs as w,Rs as x,Bs as y,ja as z};
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,2 +1,2 @@
1
- function e(e,t,n){let r=n=>e(n,...t);return n===void 0?r:Object.assign(r,{lazy:n,lazyArgs:t})}function t(t,n,r){let i=t.length-n.length;if(i===0)return t(...n);if(i===1)return e(t,n,r);throw Error(`Wrong number of arguments`)}function n(...e){return t(r,e)}const r=(e,t)=>t.every(t=>t(e));function i(...e){return t(a,e)}const a=(e,t)=>t.some(t=>t(e));function o(...e){return t(s,e)}function s(e,t){if(t<1)throw RangeError(`chunk: A chunk size of '${t.toString()}' would result in an infinite array`);if(e.length===0)return[];if(t>=e.length)return[[...e]];let n=Math.ceil(e.length/t),r=Array(n);if(t===1)for(let[t,n]of e.entries())r[t]=[n];else for(let i=0;i<n;i+=1){let n=i*t;r[i]=e.slice(n,n+t)}return r}function c(...e){return t(l,e)}const l=(e,{min:t,max:n})=>t!==void 0&&e<t?t:n!==void 0&&e>n?n:e;function u(...e){return t(d,e)}const d=(e,t)=>[...e,...t];function f(e){return()=>e}const ee={done:!0,hasNext:!1},p={done:!1,hasNext:!1},m=()=>ee,h=e=>({hasNext:!0,next:e,done:!1});function g(e,...t){let n=e,r=t.map(e=>`lazy`in e?te(e):void 0),i=0;for(;i<t.length;){if(r[i]===void 0||!ne(n)){let e=t[i];n=e(n),i+=1;continue}let e=[];for(let n=i;n<t.length;n++){let t=r[n];if(t===void 0||(e.push(t),t.isSingle))break}let a=[];for(let t of n)if(_(t,a,e))break;let{isSingle:o}=e.at(-1);n=o?a[0]:a,i+=e.length}return n}function _(e,t,n){if(n.length===0)return t.push(e),!1;let r=e,i=p,a=!1;for(let[e,o]of n.entries()){let{index:s,items:c}=o;if(c.push(r),i=o(r,s,c),o.index+=1,i.hasNext){if(i.hasMany??!1){for(let r of i.next)if(_(r,t,n.slice(e+1)))return!0;return a}r=i.next}if(!i.hasNext)break;i.done&&(a=!0)}return i.hasNext&&t.push(r),a}function te(e){let{lazy:t,lazyArgs:n}=e,r=t(...n);return Object.assign(r,{isSingle:t.single??!1,index:0,items:[]})}function ne(e){return typeof e==`string`||typeof e==`object`&&!!e&&Symbol.iterator in e}function v(e,t){let n=t.length-e.length;if(n===1){let[n,...r]=t;return g(n,{lazy:e,lazyArgs:r})}if(n===0){let n={lazy:e,lazyArgs:t};return Object.assign(e=>g(e,n),n)}throw Error(`Wrong number of arguments`)}function y(...e){return v(b,e)}function b(e){if(e.length===0)return h;let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return e=>{let n=t.get(e);return n===void 0||n===0?{done:!1,hasNext:!0,next:e}:(t.set(e,n-1),p)}}function x(...e){return t(re,e)}const re=(e,t)=>e.length>=t,S={asc:(e,t)=>e>t,desc:(e,t)=>e<t};function ie(e,t){let[n,...r]=t;if(!ae(n))return e(n,C(...r));let i=C(n,...r);return t=>e(t,i)}function C(e,t,...n){let r=typeof e==`function`?e:e[0],i=typeof e==`function`?`asc`:e[1],{[i]:a}=S,o=t===void 0?void 0:C(t,...n);return(e,t)=>{let n=r(e),i=r(t);return a(n,i)?1:a(i,n)?-1:o?.(e,t)??0}}function ae(e){if(w(e))return!0;if(typeof e!=`object`||!Array.isArray(e))return!1;let[t,n,...r]=e;return w(t)&&typeof n==`string`&&n in S&&r.length===0}const w=e=>typeof e==`function`&&e.length===1;function T(...e){return t(E,e)}function E(e,t){for(let[n,r]of e.entries())if(!t(r,n,e))return e.slice(n);return[]}function D(...e){return t(Object.entries,e)}function O(...e){return t(k,e,A)}const k=(e,t)=>e.filter(t),A=e=>(t,n,r)=>e(t,n,r)?{done:!1,hasNext:!0,next:t}:p,j=e=>Object.assign(e,{single:!0});function M(...e){return t(N,e,j(P))}const N=(e,t)=>e.find(t),P=e=>(t,n,r)=>e(t,n,r)?{done:!0,hasNext:!0,next:t}:p;function F(...e){return t(I,e)}const I=(e,t)=>{for(let n=e.length-1;n>=0;n--){let r=e[n];if(t(r,n,e))return r}};function L(...e){return t(R,e,j(z))}const R=([e])=>e,z=()=>B,B=e=>({hasNext:!0,next:e,done:!0});function V(t,n){return typeof t==`object`?H(t,n):e(H,t===void 0?[]:[t],U)}const H=(e,t)=>t===void 0?e.flat():e.flat(t),U=e=>e===void 0||e===1?W:e<=0?h:t=>Array.isArray(t)?{next:t.flat(e-1),hasNext:!0,hasMany:!0,done:!1}:{next:t,hasNext:!0,done:!1},W=e=>Array.isArray(e)?{next:e,hasNext:!0,hasMany:!0,done:!1}:{next:e,hasNext:!0,done:!1};function G(...e){return t(K,e,q)}const K=(e,t)=>e.flatMap(t),q=e=>(t,n,r)=>{let i=e(t,n,r);return Array.isArray(i)?{done:!1,hasNext:!0,hasMany:!0,next:i}:{done:!1,hasNext:!0,next:i}};function J(...e){return t(oe,e,se)}function oe(e,t){return e.forEach(t),e}const se=e=>(t,n,r)=>(e(t,n,r),{done:!1,hasNext:!0,next:t});function ce(...e){return t(le,e)}function le(e,t){for(let[n,r]of Object.entries(e))t(r,n,e);return e}const Y=Symbol(`funnel/voidReducer`),ue=()=>Y;function de(e,{triggerAt:t=`end`,minQuietPeriodMs:n,maxBurstDurationMs:r,minGapMs:i,reducer:a=ue}){let o,s,c,l,u=()=>{let t=c;t!==void 0&&(c=void 0,t===Y?e():e(t),i!==void 0&&(s=setTimeout(d,i)))},d=()=>{clearTimeout(s),s=void 0,o===void 0&&u()},f=()=>{clearTimeout(o),o=void 0,l=void 0,s===void 0&&u()};return{call:(...e)=>{let d=o===void 0&&s===void 0;if((t!==`start`||d)&&(c=a(c,...e)),!(o===void 0&&!d)){if(n!==void 0||r!==void 0||i===void 0){clearTimeout(o);let e=Date.now();l??=e;let t=r===void 0?n??0:Math.min(n??r,Math.max(0,r-(e-l)));o=setTimeout(f,t)}t!==`end`&&d&&u()}},cancel:()=>{clearTimeout(o),o=void 0,l=void 0,clearTimeout(s),s=void 0,c=void 0},flush:()=>{f(),d()},get isIdle(){return o===void 0&&s===void 0}}}function fe(...e){return t(pe,e)}const pe=(e,t)=>{let n=Object.create(null);for(let r=0;r<e.length;r++){let i=e[r],a=t(i,r,e);if(a!==void 0){let e=n[a];e===void 0?n[a]=[i]:e.push(i)}}return Object.setPrototypeOf(n,Object.prototype),n};function me(...e){return t(he,e)}function he(e,t){let n=Object.create(null);for(let r of e){let e=r?.[t];if(e!==void 0){let t=n[e];t===void 0?n[e]=[r]:t.push(r)}}return Object.setPrototypeOf(n,Object.prototype),n}function ge(...e){return t(X,e)}function X(e,t){if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(Array.isArray(e))return _e(e,t);if(e instanceof Map)return ve(e,t);if(e instanceof Set)return ye(e,t);if(e instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp)return e.toString()===t.toString();if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let[n,r]of Object.entries(e))if(!(n in t)||!X(r,t[n]))return!1;return!0}function _e(e,t){if(e.length!==t.length)return!1;for(let[n,r]of e.entries())if(!X(r,t[n]))return!1;return!0}function ve(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e.entries())if(!t.has(n)||!X(r,t.get(n)))return!1;return!0}function ye(e,t){if(e.size!==t.size)return!1;let n=[...t];for(let t of e){let e=!1;for(let[r,i]of n.entries())if(X(t,i)){e=!0,n.splice(r,1);break}if(!e)return!1}return!0}function be(){return xe}const xe=e=>e;function Se(...e){return t(Ce,e)}function Ce(e,t){let n={};for(let[r,i]of e.entries()){let a=t(i,r,e);n[a]=i}return n}function we(e){return Array.isArray(e)}function Te(e){return typeof e==`boolean`}function Ee(e){return e!==void 0}function De(e){return e===``||e===void 0?!0:Array.isArray(e)?e.length===0:Object.keys(e).length===0}function Oe(e){if(e==null||e===``)return!0;if(typeof e!=`object`)return!1;if(`length`in e&&typeof e.length==`number`)return e.length===0;if(`size`in e&&typeof e.size==`number`)return e.size===0;for(let t in e)return!1;return Object.getOwnPropertySymbols(e).length===0}const ke=e=>typeof e==`function`;function Ae(e){return e!=null}function je(e){return t=>!e(t)}function Me(e){return e==null}function Ne(e){return typeof e==`number`&&!Number.isNaN(e)}function Pe(e){return e instanceof Promise}function Fe(...e){return t(Ie,e)}function Ie(e,t){if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map)return Le(e,t);if(e instanceof Set&&t instanceof Set)return Re(e,t);let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let{[r]:n}=e,{[r]:i}=t;if(n!==i||!Object.is(n,i))return!1}return!0}function Le(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(r!==e||!Object.is(r,e))return!1}return!0}function Re(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function ze(e){return typeof e==`string`}function Be(e){return!!e}function Ve(...e){return t(Object.keys,e)}function He(...e){return t(Ue,e)}const Ue=e=>e.at(-1);function We(...e){return t(Ge,e,Ke)}const Ge=(e,t)=>e.map(t),Ke=e=>(t,n,r)=>({done:!1,hasNext:!0,next:e(t,n,r)});function qe(...e){return t(Je,e)}function Je(e,t){let n={};for(let[r,i]of e.entries()){let[a,o]=t(i,r,e);n[a]=o}return n}function Ye(...e){return t(Xe,e)}function Xe(e,t){let n={};for(let[r,i]of Object.entries(e))n[r]=t(i,r,e);return n}function Ze(...e){return t(Qe,e)}function Qe(e,t){if(!x(t,1))return{...e};if(!x(t,2)){let{[t[0]]:n,...r}=e;return r}let n={...e};for(let e of t)delete n[e];return n}function $e(...e){return t(et,e)}function et(e,t){let n={...e};for(let[r,i]of Object.entries(n))t(i,r,e)&&delete n[r];return n}function tt(e){let t=!1,n;return()=>(t||=(n=e(),!0),n)}function nt(...e){return t(rt,e)}const rt=e=>e.length===1?e[0]:void 0;function it(...e){return t(at,e)}const at=(e,t)=>{let n=[[],[]];for(let[r,i]of e.entries())t(i,r,e)?n[0].push(i):n[1].push(i);return n};function ot(...e){return t(st,e)}function st(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function ct(...e){return t(lt,e)}function lt(e,t){let n={};for(let[r,i]of Object.entries(e))t(i,r,e)&&(n[r]=i);return n}function ut(...e){return t=>g(t,...e)}function dt(e,...t){return typeof e==`string`||typeof e==`number`||typeof e==`symbol`?n=>Z(n,e,...t):Z(e,...t)}function Z(e,...t){let n=e;for(let e of t){if(n==null)return;n=n[e]}return n}function ft(...e){return t(pt,e)}function pt(e,t,n){let r={};for(let[i,a]of e.entries()){let o=t(a,i,e);r[o]=n(a,i,e)}return r}function mt(e,t){let n=Math.ceil(e),r=Math.floor(t);if(r<n)throw RangeError(`randomInteger: The range [${e.toString()},${t.toString()}] contains no integer`);return Math.floor(Math.random()*(r-n+1)+n)}function ht(...e){return t(gt,e)}function gt(e){let t=[];for(let n=0;n<e;n++){let e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`[Math.floor(Math.random()*62)];t.push(e)}return t.join(``)}function _t(...e){return t(vt,e)}const vt=(e,t,n)=>e.reduce(t,n);function yt(...e){return t(bt,e)}function bt(e){return[...e].reverse()}function xt(...e){return t(St,e)}function St(e,t){let n=[...e];return n.sort(t),n}function Ct(...e){return ie(wt,e)}const wt=(e,t)=>[...e].sort(t);function Tt(e,t,n){return typeof t==`number`||t===void 0?n=>n.split(e,t):e.split(t,n)}function Et(...e){return t(Dt,e,Q)}const Dt=(e,t)=>t<0?[]:e.slice(0,t);function Q(e){if(e<=0)return m;let t=e;return e=>(--t,{done:t<=0,hasNext:!0,next:e})}function Ot(...e){return t(kt,e)}function kt(e,t){let n=[];for(let[r,i]of e.entries()){if(!t(i,r,e))break;n.push(i)}return n}function At(...e){return t(jt,e)}function jt(e,t){return t(e),e}new Set([`-`,`_`,...` .
2
- .\v.\f.\r. .….\xA0. . . . . . . . . . . . .\u2028.\u2029. . . .`.split(`.`)]);function Mt(...e){return v(Nt,e)}function Nt(){let e=new Set;return t=>e.has(t)?p:(e.add(t),{done:!1,hasNext:!0,next:t})}function Pt(...e){return v(Ft,e)}function Ft(e){let t=e,n=new Set;return(e,r,i)=>{let a=t(e,r,i);return n.has(a)?p:(n.add(a),{done:!1,hasNext:!0,next:e})}}function It(...e){return t(Object.values,e)}function Lt(...e){return e.length===2?(t,...n)=>$(t,...e,...n):$(...e)}const $=(e,t,n,...r)=>t(e,...r)?typeof n==`function`?n(e,...r):n.onTrue(e,...r):typeof n==`function`?e:n.onFalse(e,...r);function Rt(...e){return t(zt,e,Bt)}const zt=(e,t)=>e.length<t.length?e.map((e,n)=>[e,t[n]]):t.map((t,n)=>[e[n],t]),Bt=e=>(t,n)=>({hasNext:!0,next:[t,e[n]],done:n>=e.length-1});export{G as $,Ve as A,Oe as B,tt as C,qe as D,Ye as E,Ne as F,Se as G,Ee as H,Me as I,me as J,be as K,je as L,ze as M,Fe as N,We as O,Pe as P,J as Q,Ae as R,nt as S,Ze as T,Te as U,De as V,we as W,de as X,fe as Y,ce as Z,dt as _,Mt as a,D as at,ot as b,Et as c,y as ct,xt as d,u as dt,V as et,yt as f,c as ft,ft as g,t as gt,mt as h,n as ht,Pt as i,O as it,Be as j,He as k,Tt as l,g as lt,ht as m,i as mt,Lt as n,F as nt,At as o,T as ot,_t as p,o as pt,ge as q,It as r,M as rt,Ot as s,x as st,Rt as t,L as tt,Ct as u,f as ut,ut as v,$e as w,it as x,ct as y,ke as z};
1
+ function e(e,t,n){let r=n=>e(n,...t);return n===void 0?r:Object.assign(r,{lazy:n,lazyArgs:t})}function t(t,n,r){let i=t.length-n.length;if(i===0)return t(...n);if(i===1)return e(t,n,r);throw Error(`Wrong number of arguments`)}function n(...e){return t(r,e)}const r=(e,t)=>t.every(t=>t(e));function i(...e){return t(a,e)}const a=(e,t)=>t.some(t=>t(e));function o(...e){return t(s,e)}function s(e,t){if(t<1)throw RangeError(`chunk: A chunk size of '${t.toString()}' would result in an infinite array`);if(e.length===0)return[];if(t>=e.length)return[[...e]];let n=Math.ceil(e.length/t),r=Array(n);if(t===1)for(let[t,n]of e.entries())r[t]=[n];else for(let i=0;i<n;i+=1){let n=i*t;r[i]=e.slice(n,n+t)}return r}function c(...e){return t(l,e)}const l=(e,{min:t,max:n})=>t!==void 0&&e<t?t:n!==void 0&&e>n?n:e;function u(...e){return t(d,e)}const d=(e,t)=>[...e,...t];function f(e){return()=>e}const ee={done:!0,hasNext:!1},p={done:!1,hasNext:!1},m=()=>ee,h=e=>({hasNext:!0,next:e,done:!1});function g(e,...t){let n=e,r=t.map(e=>`lazy`in e?te(e):void 0),i=0;for(;i<t.length;){if(r[i]===void 0||!ne(n)){let e=t[i];n=e(n),i+=1;continue}let e=[];for(let n=i;n<t.length;n++){let t=r[n];if(t===void 0||(e.push(t),t.isSingle))break}let a=[];for(let t of n)if(_(t,a,e))break;let{isSingle:o}=e.at(-1);n=o?a[0]:a,i+=e.length}return n}function _(e,t,n){if(n.length===0)return t.push(e),!1;let r=e,i=p,a=!1;for(let[e,o]of n.entries()){let{index:s,items:c}=o;if(c.push(r),i=o(r,s,c),o.index+=1,i.hasNext){if(i.hasMany??!1){for(let r of i.next)if(_(r,t,n.slice(e+1)))return!0;return a}r=i.next}if(!i.hasNext)break;i.done&&(a=!0)}return i.hasNext&&t.push(r),a}function te(e){let{lazy:t,lazyArgs:n}=e,r=t(...n);return Object.assign(r,{isSingle:t.single??!1,index:0,items:[]})}function ne(e){return typeof e==`string`||typeof e==`object`&&!!e&&Symbol.iterator in e}function v(e,t){let n=t.length-e.length;if(n===1){let[n,...r]=t;return g(n,{lazy:e,lazyArgs:r})}if(n===0){let n={lazy:e,lazyArgs:t};return Object.assign(e=>g(e,n),n)}throw Error(`Wrong number of arguments`)}function y(...e){return v(b,e)}function b(e){if(e.length===0)return h;let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return e=>{let n=t.get(e);return n===void 0||n===0?{done:!1,hasNext:!0,next:e}:(t.set(e,n-1),p)}}function x(...e){return t(re,e)}const re=(e,t)=>e.length>=t,S={asc:(e,t)=>e>t,desc:(e,t)=>e<t};function ie(e,t){let[n,...r]=t;if(!ae(n))return e(n,C(...r));let i=C(n,...r);return t=>e(t,i)}function C(e,t,...n){let r=typeof e==`function`?e:e[0],i=typeof e==`function`?`asc`:e[1],{[i]:a}=S,o=t===void 0?void 0:C(t,...n);return(e,t)=>{let n=r(e),i=r(t);return a(n,i)?1:a(i,n)?-1:o?.(e,t)??0}}function ae(e){if(w(e))return!0;if(typeof e!=`object`||!Array.isArray(e))return!1;let[t,n,...r]=e;return w(t)&&typeof n==`string`&&n in S&&r.length===0}const w=e=>typeof e==`function`&&e.length===1;function T(...e){return t(E,e)}function E(e,t){for(let[n,r]of e.entries())if(!t(r,n,e))return e.slice(n);return[]}function D(...e){return t(Object.entries,e)}function O(...e){return t(k,e,A)}const k=(e,t)=>e.filter(t),A=e=>(t,n,r)=>e(t,n,r)?{done:!1,hasNext:!0,next:t}:p,j=e=>Object.assign(e,{single:!0});function M(...e){return t(N,e,j(P))}const N=(e,t)=>e.find(t),P=e=>(t,n,r)=>e(t,n,r)?{done:!0,hasNext:!0,next:t}:p;function F(...e){return t(I,e)}const I=(e,t)=>{for(let n=e.length-1;n>=0;n--){let r=e[n];if(t(r,n,e))return r}};function L(...e){return t(R,e,j(z))}const R=([e])=>e,z=()=>B,B=e=>({hasNext:!0,next:e,done:!0});function V(t,n){return typeof t==`object`?H(t,n):e(H,t===void 0?[]:[t],U)}const H=(e,t)=>t===void 0?e.flat():e.flat(t),U=e=>e===void 0||e===1?W:e<=0?h:t=>Array.isArray(t)?{next:t.flat(e-1),hasNext:!0,hasMany:!0,done:!1}:{next:t,hasNext:!0,done:!1},W=e=>Array.isArray(e)?{next:e,hasNext:!0,hasMany:!0,done:!1}:{next:e,hasNext:!0,done:!1};function G(...e){return t(K,e,q)}const K=(e,t)=>e.flatMap(t),q=e=>(t,n,r)=>{let i=e(t,n,r);return Array.isArray(i)?{done:!1,hasNext:!0,hasMany:!0,next:i}:{done:!1,hasNext:!0,next:i}};function J(...e){return t(oe,e,se)}function oe(e,t){return e.forEach(t),e}const se=e=>(t,n,r)=>(e(t,n,r),{done:!1,hasNext:!0,next:t});function ce(...e){return t(le,e)}function le(e,t){for(let[n,r]of Object.entries(e))t(r,n,e);return e}const Y=Symbol(`funnel/voidReducer`),ue=()=>Y;function de(e,{triggerAt:t=`end`,minQuietPeriodMs:n,maxBurstDurationMs:r,minGapMs:i,reducer:a=ue}){let o,s,c,l,u=()=>{let t=c;t!==void 0&&(c=void 0,t===Y?e():e(t),i!==void 0&&(s=setTimeout(d,i)))},d=()=>{clearTimeout(s),s=void 0,o===void 0&&u()},f=()=>{clearTimeout(o),o=void 0,l=void 0,s===void 0&&u()};return{call:(...e)=>{let d=o===void 0&&s===void 0;if((t!==`start`||d)&&(c=a(c,...e)),!(o===void 0&&!d)){if(n!==void 0||r!==void 0||i===void 0){clearTimeout(o);let e=Date.now();l??=e;let t=r===void 0?n??0:Math.min(n??r,Math.max(0,r-(e-l)));o=setTimeout(f,t)}t!==`end`&&d&&u()}},cancel:()=>{clearTimeout(o),o=void 0,l=void 0,clearTimeout(s),s=void 0,c=void 0},flush:()=>{f(),d()},get isIdle(){return o===void 0&&s===void 0}}}function fe(...e){return t(pe,e)}const pe=(e,t)=>{let n=Object.create(null);for(let r=0;r<e.length;r++){let i=e[r],a=t(i,r,e);if(a!==void 0){let e=n[a];e===void 0?n[a]=[i]:e.push(i)}}return Object.setPrototypeOf(n,Object.prototype),n};function me(...e){return t(he,e)}function he(e,t){let n=Object.create(null);for(let r of e){let e=r?.[t];if(e!==void 0){let t=n[e];t===void 0?n[e]=[r]:t.push(r)}}return Object.setPrototypeOf(n,Object.prototype),n}function ge(...e){return t(X,e)}function X(e,t){if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(Array.isArray(e))return _e(e,t);if(e instanceof Map)return ve(e,t);if(e instanceof Set)return ye(e,t);if(e instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp)return e.toString()===t.toString();if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let[n,r]of Object.entries(e))if(!(n in t)||!X(r,t[n]))return!1;return!0}function _e(e,t){if(e.length!==t.length)return!1;for(let[n,r]of e.entries())if(!X(r,t[n]))return!1;return!0}function ve(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e.entries())if(!t.has(n)||!X(r,t.get(n)))return!1;return!0}function ye(e,t){if(e.size!==t.size)return!1;let n=[...t];for(let t of e){let e=!1;for(let[r,i]of n.entries())if(X(t,i)){e=!0,n.splice(r,1);break}if(!e)return!1}return!0}function be(){return xe}const xe=e=>e;function Se(...e){return t(Ce,e)}function Ce(e,t){let n={};for(let[r,i]of e.entries()){let a=t(i,r,e);n[a]=i}return n}function we(e){return Array.isArray(e)}function Te(e){return typeof e==`boolean`}function Ee(e){return e!==void 0}function De(e){return e===``||e===void 0?!0:Array.isArray(e)?e.length===0:Object.keys(e).length===0}function Oe(e){if(e==null||e===``)return!0;if(typeof e!=`object`)return!1;if(`length`in e&&typeof e.length==`number`)return e.length===0;if(`size`in e&&typeof e.size==`number`)return e.size===0;for(let t in e)return!1;return Object.getOwnPropertySymbols(e).length===0}const ke=e=>typeof e==`function`;function Ae(e){return e!=null}function je(e){return t=>!e(t)}function Me(e){return e==null}function Ne(e){return typeof e==`number`&&!Number.isNaN(e)}function Pe(e){return e instanceof Promise}function Fe(...e){return t(Ie,e)}function Ie(e,t){if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map)return Le(e,t);if(e instanceof Set&&t instanceof Set)return Re(e,t);let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let{[r]:n}=e,{[r]:i}=t;if(n!==i||!Object.is(n,i))return!1}return!0}function Le(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(r!==e||!Object.is(r,e))return!1}return!0}function Re(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function ze(e){return typeof e==`string`}function Be(e){return!!e}function Ve(...e){return t(He,e)}const He=(e,t)=>e.join(t);function Ue(...e){return t(Object.keys,e)}function We(...e){return t(Ge,e)}const Ge=e=>e.at(-1);function Ke(...e){return t(qe,e,Je)}const qe=(e,t)=>e.map(t),Je=e=>(t,n,r)=>({done:!1,hasNext:!0,next:e(t,n,r)});function Ye(...e){return t(Xe,e)}function Xe(e,t){let n={};for(let[r,i]of e.entries()){let[a,o]=t(i,r,e);n[a]=o}return n}function Ze(...e){return t(Qe,e)}function Qe(e,t){let n={};for(let[r,i]of Object.entries(e))n[r]=t(i,r,e);return n}function $e(...e){return t(et,e)}function et(e,t){if(!x(t,1))return{...e};if(!x(t,2)){let{[t[0]]:n,...r}=e;return r}let n={...e};for(let e of t)delete n[e];return n}function tt(...e){return t(nt,e)}function nt(e,t){let n={...e};for(let[r,i]of Object.entries(n))t(i,r,e)&&delete n[r];return n}function rt(e){let t=!1,n;return()=>(t||=(n=e(),!0),n)}function it(...e){return t(at,e)}const at=e=>e.length===1?e[0]:void 0;function ot(...e){return t(st,e)}const st=(e,t)=>{let n=[[],[]];for(let[r,i]of e.entries())t(i,r,e)?n[0].push(i):n[1].push(i);return n};function ct(...e){return t(lt,e)}function lt(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function ut(...e){return t(dt,e)}function dt(e,t){let n={};for(let[r,i]of Object.entries(e))t(i,r,e)&&(n[r]=i);return n}function ft(...e){return t=>g(t,...e)}function pt(e,...t){return typeof e==`string`||typeof e==`number`||typeof e==`symbol`?n=>Z(n,e,...t):Z(e,...t)}function Z(e,...t){let n=e;for(let e of t){if(n==null)return;n=n[e]}return n}function mt(...e){return t(ht,e)}function ht(e,t,n){let r={};for(let[i,a]of e.entries()){let o=t(a,i,e);r[o]=n(a,i,e)}return r}function gt(e,t){let n=Math.ceil(e),r=Math.floor(t);if(r<n)throw RangeError(`randomInteger: The range [${e.toString()},${t.toString()}] contains no integer`);return Math.floor(Math.random()*(r-n+1)+n)}function _t(...e){return t(vt,e)}function vt(e){let t=[];for(let n=0;n<e;n++){let e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`[Math.floor(Math.random()*62)];t.push(e)}return t.join(``)}function yt(...e){return t(bt,e)}const bt=(e,t,n)=>e.reduce(t,n);function xt(...e){return t(St,e)}function St(e){return[...e].reverse()}function Ct(...e){return t(wt,e)}function wt(e,t){let n=[...e];return n.sort(t),n}function Tt(...e){return ie(Et,e)}const Et=(e,t)=>[...e].sort(t);function Dt(e,t,n){return typeof t==`number`||t===void 0?n=>n.split(e,t):e.split(t,n)}function Q(...e){return t(Ot,e,kt)}const Ot=(e,t)=>t<0?[]:e.slice(0,t);function kt(e){if(e<=0)return m;let t=e;return e=>(--t,{done:t<=0,hasNext:!0,next:e})}function At(...e){return t(jt,e)}function jt(e,t){let n=[];for(let[r,i]of e.entries()){if(!t(i,r,e))break;n.push(i)}return n}function Mt(...e){return t(Nt,e)}function Nt(e,t){return t(e),e}new Set([`-`,`_`,...` .
2
+ .\v.\f.\r. .….\xA0. . . . . . . . . . . . .\u2028.\u2029. . . .`.split(`.`)]);function Pt(...e){return v(Ft,e)}function Ft(){let e=new Set;return t=>e.has(t)?p:(e.add(t),{done:!1,hasNext:!0,next:t})}function It(...e){return v(Lt,e)}function Lt(e){let t=e,n=new Set;return(e,r,i)=>{let a=t(e,r,i);return n.has(a)?p:(n.add(a),{done:!1,hasNext:!0,next:e})}}function Rt(...e){return t(Object.values,e)}function zt(...e){return e.length===2?(t,...n)=>$(t,...e,...n):$(...e)}const $=(e,t,n,...r)=>t(e,...r)?typeof n==`function`?n(e,...r):n.onTrue(e,...r):typeof n==`function`?e:n.onFalse(e,...r);function Bt(...e){return t(Vt,e,Ht)}const Vt=(e,t)=>e.length<t.length?e.map((e,n)=>[e,t[n]]):t.map((t,n)=>[e[n],t]),Ht=e=>(t,n)=>({hasNext:!0,next:[t,e[n]],done:n>=e.length-1});export{J as $,Ue as A,ke as B,rt as C,Ye as D,Ze as E,Pe as F,we as G,De as H,Ne as I,ge as J,Se as K,Me as L,Be as M,ze as N,Ke as O,Fe as P,ce as Q,je as R,it as S,$e as T,Ee as U,Oe as V,Te as W,fe as X,me as Y,de as Z,pt as _,t as _t,Pt as a,O as at,ct as b,Q as c,x as ct,Ct as d,f as dt,G as et,xt as f,u as ft,mt as g,n as gt,gt as h,i as ht,It as i,M as it,Ve as j,We as k,Dt as l,y as lt,_t as m,o as mt,zt as n,L as nt,Mt as o,D as ot,yt as p,c as pt,be as q,Rt as r,F as rt,At as s,T as st,Bt as t,V as tt,Tt as u,g as ut,ft as v,tt as w,ot as x,ut as y,Ae as z};
@@ -0,0 +1 @@
1
+ import{t as e}from"./destr.mjs";function t(e){return!e||typeof e.then!=`function`?Promise.resolve(e):e}function n(e,...n){try{return t(e(...n))}catch(e){return Promise.reject(e)}}function r(e){let t=typeof e;return e===null||t!==`object`&&t!==`function`}function i(e){let t=Object.getPrototypeOf(e);return!t||t.isPrototypeOf(Object)}function a(e){if(r(e))return String(e);if(i(e)||Array.isArray(e))return JSON.stringify(e);if(typeof e.toJSON==`function`)return a(e.toJSON());throw Error(`[unstorage] Cannot stringify value!`)}const o=`base64:`;function s(e){return typeof e==`string`?e:o+u(e)}function c(e){return typeof e!=`string`||!e.startsWith(o)?e:l(e.slice(7))}function l(e){return globalThis.Buffer?Buffer.from(e,`base64`):Uint8Array.from(globalThis.atob(e),e=>e.codePointAt(0))}function u(e){return globalThis.Buffer?Buffer.from(e).toString(`base64`):globalThis.btoa(String.fromCodePoint(...e))}const d=[`has`,`hasItem`,`get`,`getItem`,`getItemRaw`,`set`,`setItem`,`setItemRaw`,`del`,`remove`,`removeItem`,`getMeta`,`setMeta`,`removeMeta`,`getKeys`,`clear`,`mount`,`unmount`];function f(e,t){if(t=h(t),!t)return e;let n={...e};for(let r of d)n[r]=(n=``,...i)=>e[r](t+n,...i);return n.getKeys=(n=``,...r)=>e.getKeys(t+n,...r).then(e=>e.map(e=>e.slice(t.length))),n.keys=n.getKeys,n.getItems=async(n,r)=>{let i=n.map(e=>typeof e==`string`?t+e:{...e,key:t+e.key});return(await e.getItems(i,r)).map(e=>({key:e.key.slice(t.length),value:e.value}))},n.setItems=async(n,r)=>{let i=n.map(e=>({key:t+e.key,value:e.value,options:e.options}));return e.setItems(i,r)},n}function p(e){return e&&e.split(`?`)[0]?.replace(/[/\\]/g,`:`).replace(/:+/g,`:`).replace(/^:|:$/g,``)||``}function m(...e){return p(e.join(`:`))}function h(e){return e=p(e),e?e+`:`:``}function g(e,t){if(t===void 0)return!0;let n=0,r=e.indexOf(`:`);for(;r>-1;)n++,r=e.indexOf(`:`,r+1);return n<=t}function _(e,t){return t?e.startsWith(t)&&e[e.length-1]!==`$`:e[e.length-1]!==`$`}function v(e){return e}const y=v(()=>{let e=new Map;return{name:`memory`,getInstance:()=>e,hasItem(t){return e.has(t)},getItem(t){return e.get(t)??null},getItemRaw(t){return e.get(t)??null},setItem(t,n){e.set(t,n)},setItemRaw(t,n){e.set(t,n)},removeItem(t){e.delete(t)},getKeys(){return[...e.keys()]},clear(){e.clear()},dispose(){e.clear()}}});function b(t={}){let r={mounts:{"":t.driver||y()},mountpoints:[``],watching:!1,watchListeners:[],unwatch:{}},i=e=>{for(let t of r.mountpoints)if(e.startsWith(t))return{base:t,relativeKey:e.slice(t.length),driver:r.mounts[t]};return{base:``,relativeKey:e,driver:r.mounts[``]}},o=(e,t)=>r.mountpoints.filter(n=>n.startsWith(e)||t&&e.startsWith(n)).map(t=>({relativeBase:e.length>t.length?e.slice(t.length):void 0,mountpoint:t,driver:r.mounts[t]})),l=(e,t)=>{if(r.watching){t=p(t);for(let n of r.watchListeners)n(e,t)}},u=async()=>{if(!r.watching){r.watching=!0;for(let e in r.mounts)r.unwatch[e]=await x(r.mounts[e],l,e)}},d=async()=>{if(r.watching){for(let e in r.unwatch)await r.unwatch[e]();r.unwatch={},r.watching=!1}},f=(e,t,n)=>{let r=new Map,a=e=>{let t=r.get(e.base);return t||(t={driver:e.driver,base:e.base,items:[]},r.set(e.base,t)),t};for(let n of e){let e=typeof n==`string`,r=p(e?n:n.key),o=e?void 0:n.value,s=e||!n.options?t:{...t,...n.options},c=i(r);a(c).items.push({key:r,value:o,relativeKey:c.relativeKey,options:s})}return Promise.all([...r.values()].map(e=>n(e))).then(e=>e.flat())},v={hasItem(e,t={}){e=p(e);let{relativeKey:r,driver:a}=i(e);return n(a.hasItem,r,t)},getItem(t,r={}){t=p(t);let{relativeKey:a,driver:o}=i(t);return n(o.getItem,a,r).then(t=>e(t))},getItems(t,r={}){return f(t,r,t=>t.driver.getItems?n(t.driver.getItems,t.items.map(e=>({key:e.relativeKey,options:e.options})),r).then(n=>n.map(n=>({key:m(t.base,n.key),value:e(n.value)}))):Promise.all(t.items.map(r=>n(t.driver.getItem,r.relativeKey,r.options).then(t=>({key:r.key,value:e(t)})))))},getItemRaw(e,t={}){e=p(e);let{relativeKey:r,driver:a}=i(e);return a.getItemRaw?n(a.getItemRaw,r,t):n(a.getItem,r,t).then(e=>c(e))},async setItem(e,t,r={}){if(t===void 0)return v.removeItem(e);e=p(e);let{relativeKey:o,driver:s}=i(e);s.setItem&&(await n(s.setItem,o,a(t),r),s.watch||l(`update`,e))},async setItems(e,t){await f(e,t,async e=>{if(e.driver.setItems)return n(e.driver.setItems,e.items.map(e=>({key:e.relativeKey,value:a(e.value),options:e.options})),t);e.driver.setItem&&await Promise.all(e.items.map(t=>n(e.driver.setItem,t.relativeKey,a(t.value),t.options)))})},async setItemRaw(e,t,r={}){if(t===void 0)return v.removeItem(e,r);e=p(e);let{relativeKey:a,driver:o}=i(e);if(o.setItemRaw)await n(o.setItemRaw,a,t,r);else if(o.setItem)await n(o.setItem,a,s(t),r);else return;o.watch||l(`update`,e)},async removeItem(e,t={}){typeof t==`boolean`&&(t={removeMeta:t}),e=p(e);let{relativeKey:r,driver:a}=i(e);a.removeItem&&(await n(a.removeItem,r,t),(t.removeMeta||t.removeMata)&&await n(a.removeItem,r+`$`,t),a.watch||l(`remove`,e))},async getMeta(t,r={}){typeof r==`boolean`&&(r={nativeOnly:r}),t=p(t);let{relativeKey:a,driver:o}=i(t),s=Object.create(null);if(o.getMeta&&Object.assign(s,await n(o.getMeta,a,r)),!r.nativeOnly){let t=await n(o.getItem,a+`$`,r).then(t=>e(t));t&&typeof t==`object`&&(typeof t.atime==`string`&&(t.atime=new Date(t.atime)),typeof t.mtime==`string`&&(t.mtime=new Date(t.mtime)),Object.assign(s,t))}return s},setMeta(e,t,n={}){return this.setItem(e+`$`,t,n)},removeMeta(e,t={}){return this.removeItem(e+`$`,t)},async getKeys(e,t={}){e=h(e);let r=o(e,!0),i=[],a=[],s=!0;for(let e of r){e.driver.flags?.maxDepth||(s=!1);let r=await n(e.driver.getKeys,e.relativeBase,t);for(let t of r){let n=e.mountpoint+p(t);i.some(e=>n.startsWith(e))||a.push(n)}i=[e.mountpoint,...i.filter(t=>!t.startsWith(e.mountpoint))]}let c=t.maxDepth!==void 0&&!s;return a.filter(n=>(!c||g(n,t.maxDepth))&&_(n,e))},async clear(e,t={}){e=h(e),await Promise.all(o(e,!1).map(async e=>{if(e.driver.clear)return n(e.driver.clear,e.relativeBase,t);if(e.driver.removeItem){let n=await e.driver.getKeys(e.relativeBase||``,t);return Promise.all(n.map(n=>e.driver.removeItem(n,t)))}}))},async dispose(){await Promise.all(Object.values(r.mounts).map(e=>S(e)))},async watch(e){return await u(),r.watchListeners.push(e),async()=>{r.watchListeners=r.watchListeners.filter(t=>t!==e),r.watchListeners.length===0&&await d()}},async unwatch(){r.watchListeners=[],await d()},mount(e,t){if(e=h(e),e&&r.mounts[e])throw Error(`already mounted at ${e}`);return e&&(r.mountpoints.push(e),r.mountpoints.sort((e,t)=>t.length-e.length)),r.mounts[e]=t,r.watching&&Promise.resolve(x(t,l,e)).then(t=>{r.unwatch[e]=t}).catch(console.error),v},async unmount(e,t=!0){e=h(e),!(!e||!r.mounts[e])&&(r.watching&&e in r.unwatch&&(r.unwatch[e]?.(),delete r.unwatch[e]),t&&await S(r.mounts[e]),r.mountpoints=r.mountpoints.filter(t=>t!==e),delete r.mounts[e])},getMount(e=``){e=p(e)+`:`;let t=i(e);return{driver:t.driver,base:t.base}},getMounts(e=``,t={}){return e=p(e),o(e,t.parents).map(e=>({driver:e.driver,base:e.mountpoint}))},keys:(e,t={})=>v.getKeys(e,t),get:(e,t={})=>v.getItem(e,t),set:(e,t,n={})=>v.setItem(e,t,n),has:(e,t={})=>v.hasItem(e,t),del:(e,t={})=>v.removeItem(e,t),remove:(e,t={})=>v.removeItem(e,t)};return v}function x(e,t,n){return e.watch?e.watch((e,r)=>t(e,n+r)):()=>{}}async function S(e){typeof e.dispose==`function`&&await n(e.dispose)}export{f as n,b as t};