likec4 1.59.3 → 1.60.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.
Files changed (99) hide show
  1. package/__app__/codegen/react.mjs +6 -6
  2. package/__app__/codegen/webcomponent.mjs +147 -69
  3. package/__app__/src/aichat/index.mjs +10 -5
  4. package/__app__/src/chunks/AIChat.mjs +1134 -693
  5. package/__app__/src/chunks/LikeC4Styles.mjs +4101 -1737
  6. package/__app__/src/chunks/ProjectsOverview.mjs +624 -334
  7. package/__app__/src/chunks/es.mjs +515 -335
  8. package/__app__/src/chunks/hooks.mjs +578 -366
  9. package/__app__/src/chunks/libs/@floating-ui.mjs +2720 -1966
  10. package/__app__/src/chunks/libs/@mantine.mjs +14067 -9487
  11. package/__app__/src/chunks/libs/@tanstack-ai.mjs +2266 -1146
  12. package/__app__/src/chunks/libs/@tanstack.mjs +3152 -1932
  13. package/__app__/src/chunks/libs/@xstate/react.mjs +2924 -1468
  14. package/__app__/src/chunks/libs/@xyflow/react.mjs +6627 -4067
  15. package/__app__/src/chunks/libs/bezier-js.mjs +1312 -726
  16. package/__app__/src/chunks/libs/d3.mjs +3218 -1509
  17. package/__app__/src/chunks/libs/fast-equals.mjs +437 -201
  18. package/__app__/src/chunks/libs/framer.mjs +9251 -3846
  19. package/__app__/src/chunks/libs/nanostores.mjs +174 -0
  20. package/__app__/src/chunks/libs/zod.mjs +4591 -2363
  21. package/__app__/src/chunks/rolldown-runtime.mjs +39 -23
  22. package/__app__/src/chunks/styled-system.mjs +3538 -756
  23. package/__app__/src/fonts.css +112 -1
  24. package/__app__/src/main.mjs +44398 -24039
  25. package/__app__/src/style.css +18488 -1
  26. package/config/schema.json +136 -97
  27. package/dist/app/render-view-client.css +1 -1
  28. package/dist/app/render-view-client.js +506 -338
  29. package/dist/chunks/enableServer.mjs +1 -1
  30. package/dist/chunks/filenames.mjs +16 -14
  31. package/dist/chunks/generate-likec4.mjs +5 -0
  32. package/dist/chunks/index.d.mts +246 -180
  33. package/dist/chunks/index2.d.mts +2882 -1977
  34. package/dist/chunks/libs/@chevrotain/gast.mjs +27 -1
  35. package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +81 -9
  36. package/dist/chunks/libs/@chevrotain/types.d.mts +111 -0
  37. package/dist/chunks/libs/@logtape/logtape.mjs +5 -4
  38. package/dist/chunks/libs/@lume/kiwi.mjs +1 -1
  39. package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -1
  40. package/dist/chunks/libs/birpc.mjs +1 -1
  41. package/dist/chunks/libs/chevrotain-allstar.mjs +2 -2
  42. package/dist/chunks/libs/chevrotain.mjs +87 -35
  43. package/dist/chunks/libs/eventemitter3.mjs +1 -1
  44. package/dist/chunks/libs/json5.mjs +4 -4
  45. package/dist/chunks/libs/langium.d.mts +9903 -5297
  46. package/dist/chunks/libs/langium.mjs +16 -24
  47. package/dist/chunks/libs/merge-error-cause.mjs +1 -1
  48. package/dist/chunks/libs/p-limit.mjs +1 -0
  49. package/dist/chunks/libs/p-queue.mjs +1 -1
  50. package/dist/chunks/libs/package-manager-detector.mjs +1 -1
  51. package/dist/chunks/libs/pako.mjs +2 -2
  52. package/dist/chunks/libs/pretty-ms.mjs +1 -1
  53. package/dist/chunks/libs/remeda.mjs +1 -1
  54. package/dist/chunks/libs/ufo.mjs +1 -1
  55. package/dist/chunks/libs/unstorage.mjs +1 -1
  56. package/dist/chunks/libs/which.mjs +1 -1
  57. package/dist/chunks/node.mjs +60 -60
  58. package/dist/chunks/rolldown-runtime.mjs +1 -1
  59. package/dist/chunks/sequence-view.mjs +1 -1
  60. package/dist/chunks/vite-plugin.mjs +55 -52
  61. package/dist/cli/index.d.mts +1 -1
  62. package/dist/cli/index.mjs +208 -1300
  63. package/dist/config/index.d.mts +2 -2
  64. package/dist/generators/likec4.d.mts +6578 -0
  65. package/dist/generators/likec4.mjs +1 -0
  66. package/dist/index.d.mts +3 -3
  67. package/dist/model/index.d.mts +8 -5
  68. package/dist/vite-plugin/index.d.mts +6 -3
  69. package/dist/vite-plugin/index.mjs +1 -1
  70. package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +9 -0
  71. package/dist/vite-plugin/internal/index.d.mts +16 -15
  72. package/dist/vite-plugin/internal/index.mjs +144 -46
  73. package/generators/likec4/package.json +4 -0
  74. package/package.json +117 -110
  75. package/react/index.d.mts +8500 -5399
  76. package/react/index.mjs +534 -58617
  77. package/react/rolldown-runtime-DnkiqaRY.js +1 -0
  78. package/skills/likec4-dsl/SKILL.md +428 -0
  79. package/skills/likec4-dsl/evals/evals-public.json +202 -0
  80. package/skills/likec4-dsl/evals/grading-spec.json +589 -0
  81. package/skills/likec4-dsl/references/bridge-leanix-drawio.md +42 -0
  82. package/skills/likec4-dsl/references/cli.md +139 -0
  83. package/skills/likec4-dsl/references/configuration.md +266 -0
  84. package/skills/likec4-dsl/references/deployment.md +160 -0
  85. package/skills/likec4-dsl/references/dynamic-views.md +455 -0
  86. package/skills/likec4-dsl/references/examples.md +370 -0
  87. package/skills/likec4-dsl/references/identifier-validity.md +90 -0
  88. package/skills/likec4-dsl/references/include-predicates-wildcards.md +179 -0
  89. package/skills/likec4-dsl/references/model.md +151 -0
  90. package/skills/likec4-dsl/references/predicates.md +123 -0
  91. package/skills/likec4-dsl/references/relationships-bidirectional.md +176 -0
  92. package/skills/likec4-dsl/references/specification.md +75 -0
  93. package/skills/likec4-dsl/references/style-tokens-colors.md +150 -0
  94. package/skills/likec4-dsl/references/troubleshooting.md +96 -0
  95. package/skills/likec4-dsl/references/views.md +329 -0
  96. package/vite-plugin-modules.d.ts +4 -2
  97. package/dist/chunks/libs/picomatch.mjs +0 -1
  98. package/dist/chunks/libs/zod.d.mts +0 -2140
  99. package/dist/chunks/libs/zod.mjs +0 -65
@@ -1 +1,27 @@
1
- import"../../rolldown-runtime.mjs";var e=typeof global==`object`&&global&&global.Object===Object&&global,t=typeof self==`object`&&self&&self.Object===Object&&self,n=e||t||Function(`return this`)(),r=n.Symbol,i=Object.prototype,a=i.hasOwnProperty,o=i.toString,s=r?r.toStringTag:void 0;function getRawTag(e){var t=a.call(e,s),n=e[s];try{e[s]=void 0;var r=!0}catch{}var i=o.call(e);return r&&(t?e[s]=n:delete e[s]),i}var c=Object.prototype.toString;function objectToString(e){return c.call(e)}var l=`[object Null]`,u=`[object Undefined]`,d=r?r.toStringTag:void 0;function baseGetTag(e){return e==null?e===void 0?u:l:d&&d in Object(e)?getRawTag(e):objectToString(e)}function isObjectLike(e){return typeof e==`object`&&!!e}var f=`[object Symbol]`;function isSymbol(e){return typeof e==`symbol`||isObjectLike(e)&&baseGetTag(e)==f}function arrayMap(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var p=Array.isArray,m=1/0,h=r?r.prototype:void 0,g=h?h.toString:void 0;function baseToString(e){if(typeof e==`string`)return e;if(p(e))return arrayMap(e,baseToString)+``;if(isSymbol(e))return g?g.call(e):``;var t=e+``;return t==`0`&&1/e==-m?`-0`:t}var _=/\s/;function trimmedEndIndex(e){for(var t=e.length;t--&&_.test(e.charAt(t)););return t}var v=/^\s+/;function baseTrim(e){return e&&e.slice(0,trimmedEndIndex(e)+1).replace(v,``)}function isObject(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var y=NaN,ee=/^[-+]0x[0-9a-f]+$/i,te=/^0b[01]+$/i,ne=/^0o[0-7]+$/i,re=parseInt;function toNumber(e){if(typeof e==`number`)return e;if(isSymbol(e))return y;if(isObject(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=isObject(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=baseTrim(e);var n=te.test(e);return n||ne.test(e)?re(e.slice(2),n?2:8):ee.test(e)?y:+e}var b=1/0,ie=17976931348623157e292;function toFinite(e){return e?(e=toNumber(e),e===b||e===-b?(e<0?-1:1)*ie:e===e?e:0):e===0?e:0}function toInteger(e){var t=toFinite(e),n=t%1;return t===t?n?t-n:t:0}function identity(e){return e}var ae=`[object AsyncFunction]`,oe=`[object Function]`,se=`[object GeneratorFunction]`,ce=`[object Proxy]`;function isFunction(e){if(!isObject(e))return!1;var t=baseGetTag(e);return t==oe||t==se||t==ae||t==ce}var x=n[`__core-js_shared__`],le=function(){var e=/[^.]+$/.exec(x&&x.keys&&x.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function isMasked(e){return!!le&&le in e}var ue=Function.prototype.toString;function toSource(e){if(e!=null){try{return ue.call(e)}catch{}try{return e+``}catch{}}return``}var de=/[\\^$.*+?()[\]{}|]/g,fe=/^\[object .+?Constructor\]$/,pe=Function.prototype,me=Object.prototype,he=pe.toString,ge=me.hasOwnProperty,_e=RegExp(`^`+he.call(ge).replace(de,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function baseIsNative(e){return!isObject(e)||isMasked(e)?!1:(isFunction(e)?_e:fe).test(toSource(e))}function getValue(e,t){return e?.[t]}function getNative(e,t){var n=getValue(e,t);return baseIsNative(n)?n:void 0}var S=getNative(n,`WeakMap`);function apply(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}var ve=800,ye=16,be=Date.now;function shortOut(e){var t=0,n=0;return function(){var r=be(),i=ye-(r-n);if(n=r,i>0){if(++t>=ve)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function constant(e){return function(){return e}}var C=function(){try{var e=getNative(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),xe=shortOut(C?function(e,t){return C(e,`toString`,{configurable:!0,enumerable:!1,value:constant(t),writable:!0})}:identity);function arrayEach(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}function baseFindIndex(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}function baseIsNaN(e){return e!==e}function strictIndexOf(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}function baseIndexOf(e,t,n){return t===t?strictIndexOf(e,t,n):baseFindIndex(e,baseIsNaN,n)}var Se=9007199254740991,Ce=/^(?:0|[1-9]\d*)$/;function isIndex(e,t){var n=typeof e;return t??=Se,!!t&&(n==`number`||n!=`symbol`&&Ce.test(e))&&e>-1&&e%1==0&&e<t}function baseAssignValue(e,t,n){t==`__proto__`&&C?C(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function eq(e,t){return e===t||e!==e&&t!==t}var we=Object.prototype.hasOwnProperty;function assignValue(e,t,n){var r=e[t];(!(we.call(e,t)&&eq(r,n))||n===void 0&&!(t in e))&&baseAssignValue(e,t,n)}function copyObject(e,t,n,r){var i=!n;n||={};for(var a=-1,o=t.length;++a<o;){var s=t[a],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?baseAssignValue(n,s,c):assignValue(n,s,c)}return n}var w=Math.max;function overRest(e,t,n){return t=w(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,a=w(r.length-t,0),o=Array(a);++i<a;)o[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(o),apply(e,this,s)}}function baseRest(e,t){return xe(overRest(e,t,identity),e+``)}var Te=9007199254740991;function isLength(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=Te}function isArrayLike(e){return e!=null&&isLength(e.length)&&!isFunction(e)}function isIterateeCall(e,t,n){if(!isObject(n))return!1;var r=typeof t;return(r==`number`?isArrayLike(n)&&isIndex(t,n.length):r==`string`&&t in n)?eq(n[t],e):!1}function createAssigner(e){return baseRest(function(t,n){var r=-1,i=n.length,a=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(a=e.length>3&&typeof a==`function`?(i--,a):void 0,o&&isIterateeCall(n[0],n[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++r<i;){var s=n[r];s&&e(t,s,r,a)}return t})}var Ee=Object.prototype;function isPrototype(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||Ee)}function baseTimes(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var De=`[object Arguments]`;function baseIsArguments(e){return isObjectLike(e)&&baseGetTag(e)==De}var T=Object.prototype,Oe=T.hasOwnProperty,ke=T.propertyIsEnumerable,E=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isObjectLike(e)&&Oe.call(e,`callee`)&&!ke.call(e,`callee`)};function stubFalse(){return!1}var D=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Ae=D&&typeof module==`object`&&module&&!module.nodeType&&module,je=Ae&&Ae.exports===D?n.Buffer:void 0,O=(je?je.isBuffer:void 0)||stubFalse,Me=`[object Arguments]`,Ne=`[object Array]`,Pe=`[object Boolean]`,Fe=`[object Date]`,Ie=`[object Error]`,Le=`[object Function]`,Re=`[object Map]`,ze=`[object Number]`,Be=`[object Object]`,Ve=`[object RegExp]`,He=`[object Set]`,Ue=`[object String]`,We=`[object WeakMap]`,Ge=`[object ArrayBuffer]`,Ke=`[object DataView]`,qe=`[object Float32Array]`,Je=`[object Float64Array]`,Ye=`[object Int8Array]`,Xe=`[object Int16Array]`,Ze=`[object Int32Array]`,Qe=`[object Uint8Array]`,$e=`[object Uint8ClampedArray]`,et=`[object Uint16Array]`,tt=`[object Uint32Array]`,k={};k[qe]=k[Je]=k[Ye]=k[Xe]=k[Ze]=k[Qe]=k[$e]=k[et]=k[tt]=!0,k[Me]=k[Ne]=k[Ge]=k[Pe]=k[Ke]=k[Fe]=k[Ie]=k[Le]=k[Re]=k[ze]=k[Be]=k[Ve]=k[He]=k[Ue]=k[We]=!1;function baseIsTypedArray(e){return isObjectLike(e)&&isLength(e.length)&&!!k[baseGetTag(e)]}function baseUnary(e){return function(t){return e(t)}}var A=typeof exports==`object`&&exports&&!exports.nodeType&&exports,j=A&&typeof module==`object`&&module&&!module.nodeType&&module,M=j&&j.exports===A&&e.process,N=function(){try{return j&&j.require&&j.require(`util`).types||M&&M.binding&&M.binding(`util`)}catch{}}(),P=N&&N.isTypedArray,F=P?baseUnary(P):baseIsTypedArray,nt=Object.prototype.hasOwnProperty;function arrayLikeKeys(e,t){var n=p(e),r=!n&&E(e),i=!n&&!r&&O(e),a=!n&&!r&&!i&&F(e),o=n||r||i||a,s=o?baseTimes(e.length,String):[],c=s.length;for(var l in e)(t||nt.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||isIndex(l,c)))&&s.push(l);return s}function overArg(e,t){return function(n){return e(t(n))}}var rt=overArg(Object.keys,Object),it=Object.prototype.hasOwnProperty;function baseKeys(e){if(!isPrototype(e))return rt(e);var t=[];for(var n in Object(e))it.call(e,n)&&n!=`constructor`&&t.push(n);return t}function keys(e){return isArrayLike(e)?arrayLikeKeys(e):baseKeys(e)}var at=Object.prototype.hasOwnProperty,I=createAssigner(function(e,t){if(isPrototype(t)||isArrayLike(t)){copyObject(t,keys(t),e);return}for(var n in t)at.call(t,n)&&assignValue(e,n,t[n])});function nativeKeysIn(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var ot=Object.prototype.hasOwnProperty;function baseKeysIn(e){if(!isObject(e))return nativeKeysIn(e);var t=isPrototype(e),n=[];for(var r in e)r==`constructor`&&(t||!ot.call(e,r))||n.push(r);return n}function keysIn(e){return isArrayLike(e)?arrayLikeKeys(e,!0):baseKeysIn(e)}var st=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ct=/^\w*$/;function isKey(e,t){if(p(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||isSymbol(e)?!0:ct.test(e)||!st.test(e)||t!=null&&e in Object(t)}var L=getNative(Object,`create`);function hashClear(){this.__data__=L?L(null):{},this.size=0}function hashDelete(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var lt=`__lodash_hash_undefined__`,ut=Object.prototype.hasOwnProperty;function hashGet(e){var t=this.__data__;if(L){var n=t[e];return n===lt?void 0:n}return ut.call(t,e)?t[e]:void 0}var dt=Object.prototype.hasOwnProperty;function hashHas(e){var t=this.__data__;return L?t[e]!==void 0:dt.call(t,e)}var ft=`__lodash_hash_undefined__`;function hashSet(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=L&&t===void 0?ft:t,this}function Hash(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Hash.prototype.clear=hashClear,Hash.prototype.delete=hashDelete,Hash.prototype.get=hashGet,Hash.prototype.has=hashHas,Hash.prototype.set=hashSet;function listCacheClear(){this.__data__=[],this.size=0}function assocIndexOf(e,t){for(var n=e.length;n--;)if(eq(e[n][0],t))return n;return-1}var pt=Array.prototype.splice;function listCacheDelete(e){var t=this.__data__,n=assocIndexOf(t,e);return n<0?!1:(n==t.length-1?t.pop():pt.call(t,n,1),--this.size,!0)}function listCacheGet(e){var t=this.__data__,n=assocIndexOf(t,e);return n<0?void 0:t[n][1]}function listCacheHas(e){return assocIndexOf(this.__data__,e)>-1}function listCacheSet(e,t){var n=this.__data__,r=assocIndexOf(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function ListCache(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ListCache.prototype.clear=listCacheClear,ListCache.prototype.delete=listCacheDelete,ListCache.prototype.get=listCacheGet,ListCache.prototype.has=listCacheHas,ListCache.prototype.set=listCacheSet;var R=getNative(n,`Map`);function mapCacheClear(){this.size=0,this.__data__={hash:new Hash,map:new(R||ListCache),string:new Hash}}function isKeyable(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function getMapData(e,t){var n=e.__data__;return isKeyable(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function mapCacheDelete(e){var t=getMapData(this,e).delete(e);return this.size-=+!!t,t}function mapCacheGet(e){return getMapData(this,e).get(e)}function mapCacheHas(e){return getMapData(this,e).has(e)}function mapCacheSet(e,t){var n=getMapData(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function MapCache(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}MapCache.prototype.clear=mapCacheClear,MapCache.prototype.delete=mapCacheDelete,MapCache.prototype.get=mapCacheGet,MapCache.prototype.has=mapCacheHas,MapCache.prototype.set=mapCacheSet;var mt=`Expected a function`;function memoize(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(mt);var memoized=function(){var n=arguments,r=t?t.apply(this,n):n[0],i=memoized.cache;if(i.has(r))return i.get(r);var a=e.apply(this,n);return memoized.cache=i.set(r,a)||i,a};return memoized.cache=new(memoize.Cache||MapCache),memoized}memoize.Cache=MapCache;var ht=500;function memoizeCapped(e){var t=memoize(e,function(e){return n.size===ht&&n.clear(),e}),n=t.cache;return t}var gt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,_t=/\\(\\)?/g,vt=memoizeCapped(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(gt,function(e,n,r,i){t.push(r?i.replace(_t,`$1`):n||e)}),t});function toString(e){return e==null?``:baseToString(e)}function castPath(e,t){return p(e)?e:isKey(e,t)?[e]:vt(toString(e))}var yt=1/0;function toKey(e){if(typeof e==`string`||isSymbol(e))return e;var t=e+``;return t==`0`&&1/e==-yt?`-0`:t}function baseGet(e,t){t=castPath(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[toKey(t[n++])];return n&&n==r?e:void 0}function get(e,t,n){var r=e==null?void 0:baseGet(e,t);return r===void 0?n:r}function arrayPush(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var bt=overArg(Object.getPrototypeOf,Object);function stackClear(){this.__data__=new ListCache,this.size=0}function stackDelete(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function stackGet(e){return this.__data__.get(e)}function stackHas(e){return this.__data__.has(e)}var xt=200;function stackSet(e,t){var n=this.__data__;if(n instanceof ListCache){var r=n.__data__;if(!R||r.length<xt-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new MapCache(r)}return n.set(e,t),this.size=n.size,this}function Stack(e){var t=this.__data__=new ListCache(e);this.size=t.size}Stack.prototype.clear=stackClear,Stack.prototype.delete=stackDelete,Stack.prototype.get=stackGet,Stack.prototype.has=stackHas,Stack.prototype.set=stackSet;function arrayFilter(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function stubArray(){return[]}var St=Object.prototype.propertyIsEnumerable,Ct=Object.getOwnPropertySymbols,z=Ct?function(e){return e==null?[]:(e=Object(e),arrayFilter(Ct(e),function(t){return St.call(e,t)}))}:stubArray,B=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)arrayPush(t,z(e)),e=bt(e);return t}:stubArray;function baseGetAllKeys(e,t,n){var r=t(e);return p(e)?r:arrayPush(r,n(e))}function getAllKeys(e){return baseGetAllKeys(e,keys,z)}function getAllKeysIn(e){return baseGetAllKeys(e,keysIn,B)}var V=getNative(n,`DataView`),H=getNative(n,`Promise`),U=getNative(n,`Set`),W=`[object Map]`,wt=`[object Object]`,G=`[object Promise]`,K=`[object Set]`,q=`[object WeakMap]`,J=`[object DataView]`,Tt=toSource(V),Et=toSource(R),Dt=toSource(H),Ot=toSource(U),kt=toSource(S),getTag=baseGetTag;(V&&getTag(new V(new ArrayBuffer(1)))!=J||R&&getTag(new R)!=W||H&&getTag(H.resolve())!=G||U&&getTag(new U)!=K||S&&getTag(new S)!=q)&&(getTag=function(e){var t=baseGetTag(e),n=t==wt?e.constructor:void 0,r=n?toSource(n):``;if(r)switch(r){case Tt:return J;case Et:return W;case Dt:return G;case Ot:return K;case kt:return q}return t});var Y=getTag,X=n.Uint8Array,At=`__lodash_hash_undefined__`;function setCacheAdd(e){return this.__data__.set(e,At),this}function setCacheHas(e){return this.__data__.has(e)}function SetCache(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new MapCache;++t<n;)this.add(e[t])}SetCache.prototype.add=SetCache.prototype.push=setCacheAdd,SetCache.prototype.has=setCacheHas;function arraySome(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function cacheHas(e,t){return e.has(t)}var jt=1,Mt=2;function equalArrays(e,t,n,r,i,a){var o=n&jt,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=n&Mt?new SetCache:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!arraySome(t,function(e,t){if(!cacheHas(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)})){f=!1;break}}else if(!(m===h||i(m,h,n,r,a))){f=!1;break}}return a.delete(e),a.delete(t),f}function mapToArray(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function setToArray(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var Nt=1,Pt=2,Ft=`[object Boolean]`,It=`[object Date]`,Lt=`[object Error]`,Rt=`[object Map]`,zt=`[object Number]`,Bt=`[object RegExp]`,Vt=`[object Set]`,Ht=`[object String]`,Ut=`[object Symbol]`,Wt=`[object ArrayBuffer]`,Gt=`[object DataView]`,Kt=r?r.prototype:void 0,Z=Kt?Kt.valueOf:void 0;function equalByTag(e,t,n,r,i,a,o){switch(n){case Gt:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Wt:return!(e.byteLength!=t.byteLength||!a(new X(e),new X(t)));case Ft:case It:case zt:return eq(+e,+t);case Lt:return e.name==t.name&&e.message==t.message;case Bt:case Ht:return e==t+``;case Rt:var s=mapToArray;case Vt:var c=r&Nt;if(s||=setToArray,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=Pt,o.set(e,t);var u=equalArrays(s(e),s(t),r,i,a,o);return o.delete(e),u;case Ut:if(Z)return Z.call(e)==Z.call(t)}return!1}var qt=1,Jt=Object.prototype.hasOwnProperty;function equalObjects(e,t,n,r,i,a){var o=n&qt,s=getAllKeys(e),c=s.length;if(c!=getAllKeys(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:Jt.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){u=s[l];var h=e[u],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||=u==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v!=y&&`constructor`in e&&`constructor`in t&&!(typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y)&&(p=!1)}return a.delete(e),a.delete(t),p}var Yt=1,Xt=`[object Arguments]`,Zt=`[object Array]`,Q=`[object Object]`,Qt=Object.prototype.hasOwnProperty;function baseIsEqualDeep(e,t,n,r,i,a){var o=p(e),s=p(t),c=o?Zt:Y(e),l=s?Zt:Y(t);c=c==Xt?Q:c,l=l==Xt?Q:l;var u=c==Q,d=l==Q,f=c==l;if(f&&O(e)){if(!O(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new Stack,o||F(e)?equalArrays(e,t,n,r,i,a):equalByTag(e,t,c,n,r,i,a);if(!(n&Yt)){var m=u&&Qt.call(e,`__wrapped__`),h=d&&Qt.call(t,`__wrapped__`);if(m||h){var g=m?e.value():e,_=h?t.value():t;return a||=new Stack,i(g,_,n,r,a)}}return f?(a||=new Stack,equalObjects(e,t,n,r,i,a)):!1}function baseIsEqual(e,t,n,r,i){return e===t?!0:e==null||t==null||!isObjectLike(e)&&!isObjectLike(t)?e!==e&&t!==t:baseIsEqualDeep(e,t,n,r,baseIsEqual,i)}var $t=1,en=2;function baseIsMatch(e,t,n,r){var i=n.length,a=i,o=!r;if(e==null)return!a;for(e=Object(e);i--;){var s=n[i];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<a;){s=n[i];var c=s[0],l=e[c],u=s[1];if(o&&s[2]){if(l===void 0&&!(c in e))return!1}else{var d=new Stack;if(r)var f=r(l,u,c,e,t,d);if(!(f===void 0?baseIsEqual(u,l,$t|en,r,d):f))return!1}}return!0}function isStrictComparable(e){return e===e&&!isObject(e)}function getMatchData(e){for(var t=keys(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,isStrictComparable(i)]}return t}function matchesStrictComparable(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}}function baseMatches(e){var t=getMatchData(e);return t.length==1&&t[0][2]?matchesStrictComparable(t[0][0],t[0][1]):function(n){return n===e||baseIsMatch(n,e,t)}}function baseHasIn(e,t){return e!=null&&t in Object(e)}function hasPath(e,t,n){t=castPath(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=toKey(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:(i=e==null?0:e.length,!!i&&isLength(i)&&isIndex(o,i)&&(p(e)||E(e)))}function hasIn(e,t){return e!=null&&hasPath(e,t,baseHasIn)}var tn=1,nn=2;function baseMatchesProperty(e,t){return isKey(e)&&isStrictComparable(t)?matchesStrictComparable(toKey(e),t):function(n){var r=get(n,e);return r===void 0&&r===t?hasIn(n,e):baseIsEqual(t,r,tn|nn)}}function baseProperty(e){return function(t){return t?.[e]}}function basePropertyDeep(e){return function(t){return baseGet(t,e)}}function property(e){return isKey(e)?baseProperty(toKey(e)):basePropertyDeep(e)}function baseIteratee(e){return typeof e==`function`?e:e==null?identity:typeof e==`object`?p(e)?baseMatchesProperty(e[0],e[1]):baseMatches(e):property(e)}function createBaseFor(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var rn=createBaseFor();function baseForOwn(e,t){return e&&rn(e,t,keys)}function createBaseEach(e,t){return function(n,r){if(n==null)return n;if(!isArrayLike(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Object(n);(t?a--:++a<i)&&r(o[a],a,o)!==!1;);return n}}var $=createBaseEach(baseForOwn);function castFunction(e){return typeof e==`function`?e:identity}function forEach(e,t){return(p(e)?arrayEach:$)(e,castFunction(t))}function arrayEvery(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function baseEvery(e,t){var n=!0;return $(e,function(e,r,i){return n=!!t(e,r,i),n}),n}function every(e,t,n){var r=p(e)?arrayEvery:baseEvery;return n&&isIterateeCall(e,t,n)&&(t=void 0),r(e,baseIteratee(t,3))}function baseMap(e,t){var n=-1,r=isArrayLike(e)?Array(e.length):[];return $(e,function(e,i,a){r[++n]=t(e,i,a)}),r}function map(e,t){return(p(e)?arrayMap:baseMap)(e,baseIteratee(t,3))}var an=`[object String]`;function isString(e){return typeof e==`string`||!p(e)&&isObjectLike(e)&&baseGetTag(e)==an}function baseValues(e,t){return arrayMap(t,function(t){return e[t]})}function values(e){return e==null?[]:baseValues(e,keys(e))}var on=Math.max;function includes(e,t,n,r){e=isArrayLike(e)?e:values(e),n=n&&!r?toInteger(n):0;var i=e.length;return n<0&&(n=on(i+n,0)),isString(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&baseIndexOf(e,t,n)>-1}var sn=`[object RegExp]`;function baseIsRegExp(e){return isObjectLike(e)&&baseGetTag(e)==sn}var cn=N&&N.isRegExp,ln=cn?baseUnary(cn):baseIsRegExp;function baseSet(e,t,n,r){if(!isObject(e))return e;t=castPath(t,e);for(var i=-1,a=t.length,o=a-1,s=e;s!=null&&++i<a;){var c=toKey(t[i]),l=n;if(c===`__proto__`||c===`constructor`||c===`prototype`)return e;if(i!=o){var u=s[c];l=r?r(u,c,s):void 0,l===void 0&&(l=isObject(u)?u:isIndex(t[i+1])?[]:{})}assignValue(s,c,l),s=s[c]}return e}function basePickBy(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=baseGet(e,o);n(s,o)&&baseSet(a,castPath(o,e),s)}return a}function pickBy(e,t){if(e==null)return{};var n=arrayMap(getAllKeysIn(e),function(e){return[e]});return t=baseIteratee(t),basePickBy(e,n,function(e,n){return t(e,n[0])})}function baseSome(e,t){var n;return $(e,function(e,r,i){return n=t(e,r,i),!n}),!!n}function some(e,t,n){var r=p(e)?arraySome:baseSome;return n&&isIterateeCall(e,t,n)&&(t=void 0),r(e,baseIteratee(t,3))}function tokenLabel(e){return hasTokenLabel(e)?e.LABEL:e.name}function hasTokenLabel(e){return isString(e.LABEL)&&e.LABEL!==``}var AbstractProduction=class{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),forEach(this.definition,t=>{t.accept(e)})}},NonTerminal=class extends AbstractProduction{constructor(e){super([]),this.idx=1,I(this,pickBy(e,e=>e!==void 0))}set definition(e){}get definition(){return this.referencedRule===void 0?[]:this.referencedRule.definition}accept(e){e.visit(this)}},Rule=class extends AbstractProduction{constructor(e){super(e.definition),this.orgText=``,I(this,pickBy(e,e=>e!==void 0))}},Alternative=class extends AbstractProduction{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,I(this,pickBy(e,e=>e!==void 0))}},Option=class extends AbstractProduction{constructor(e){super(e.definition),this.idx=1,I(this,pickBy(e,e=>e!==void 0))}},RepetitionMandatory=class extends AbstractProduction{constructor(e){super(e.definition),this.idx=1,I(this,pickBy(e,e=>e!==void 0))}},RepetitionMandatoryWithSeparator=class extends AbstractProduction{constructor(e){super(e.definition),this.idx=1,I(this,pickBy(e,e=>e!==void 0))}},Repetition=class extends AbstractProduction{constructor(e){super(e.definition),this.idx=1,I(this,pickBy(e,e=>e!==void 0))}},RepetitionWithSeparator=class extends AbstractProduction{constructor(e){super(e.definition),this.idx=1,I(this,pickBy(e,e=>e!==void 0))}},Alternation=class extends AbstractProduction{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,I(this,pickBy(e,e=>e!==void 0))}},Terminal=class{constructor(e){this.idx=1,I(this,pickBy(e,e=>e!==void 0))}accept(e){e.visit(this)}};function serializeGrammar(e){return map(e,serializeProduction)}function serializeProduction(e){function convertDefinition(e){return map(e,serializeProduction)}if(e instanceof NonTerminal){let t={type:`NonTerminal`,name:e.nonTerminalName,idx:e.idx};return isString(e.label)&&(t.label=e.label),t}if(e instanceof Alternative)return{type:`Alternative`,definition:convertDefinition(e.definition)};if(e instanceof Option)return{type:`Option`,idx:e.idx,definition:convertDefinition(e.definition)};if(e instanceof RepetitionMandatory)return{type:`RepetitionMandatory`,idx:e.idx,definition:convertDefinition(e.definition)};if(e instanceof RepetitionMandatoryWithSeparator)return{type:`RepetitionMandatoryWithSeparator`,idx:e.idx,separator:serializeProduction(new Terminal({terminalType:e.separator})),definition:convertDefinition(e.definition)};if(e instanceof RepetitionWithSeparator)return{type:`RepetitionWithSeparator`,idx:e.idx,separator:serializeProduction(new Terminal({terminalType:e.separator})),definition:convertDefinition(e.definition)};if(e instanceof Repetition)return{type:`Repetition`,idx:e.idx,definition:convertDefinition(e.definition)};if(e instanceof Alternation)return{type:`Alternation`,idx:e.idx,definition:convertDefinition(e.definition)};if(e instanceof Terminal){let t={type:`Terminal`,name:e.terminalType.name,label:tokenLabel(e.terminalType),idx:e.idx};isString(e.label)&&(t.terminalLabel=e.label);let n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(t.pattern=ln(n)?n.source:n),t}if(e instanceof Rule)return{type:`Rule`,name:e.name,orgText:e.orgText,definition:convertDefinition(e.definition)};throw Error(`non exhaustive match`)}var GAstVisitor=class{visit(e){let t=e;switch(t.constructor){case NonTerminal:return this.visitNonTerminal(t);case Alternative:return this.visitAlternative(t);case Option:return this.visitOption(t);case RepetitionMandatory:return this.visitRepetitionMandatory(t);case RepetitionMandatoryWithSeparator:return this.visitRepetitionMandatoryWithSeparator(t);case RepetitionWithSeparator:return this.visitRepetitionWithSeparator(t);case Repetition:return this.visitRepetition(t);case Alternation:return this.visitAlternation(t);case Terminal:return this.visitTerminal(t);case Rule:return this.visitRule(t);default:throw Error(`non exhaustive match`)}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}};function isSequenceProd(e){return e instanceof Alternative||e instanceof Option||e instanceof Repetition||e instanceof RepetitionMandatory||e instanceof RepetitionMandatoryWithSeparator||e instanceof RepetitionWithSeparator||e instanceof Terminal||e instanceof Rule}function isOptionalProd(e,t=[]){return e instanceof Option||e instanceof Repetition||e instanceof RepetitionWithSeparator?!0:e instanceof Alternation?some(e.definition,e=>isOptionalProd(e,t)):e instanceof NonTerminal&&includes(t,e)?!1:e instanceof AbstractProduction&&(e instanceof NonTerminal&&t.push(e),every(e.definition,e=>isOptionalProd(e,t)))}function isBranchingProd(e){return e instanceof Alternation}function getProductionDslName(e){if(e instanceof NonTerminal)return`SUBRULE`;if(e instanceof Option)return`OPTION`;if(e instanceof Alternation)return`OR`;if(e instanceof RepetitionMandatory)return`AT_LEAST_ONE`;if(e instanceof RepetitionMandatoryWithSeparator)return`AT_LEAST_ONE_SEP`;if(e instanceof RepetitionWithSeparator)return`MANY_SEP`;if(e instanceof Repetition)return`MANY`;if(e instanceof Terminal)return`CONSUME`;throw Error(`non exhaustive match`)}export{isIterateeCall as $,cacheHas as A,Stack as B,map as C,baseIteratee as D,$ as E,getAllKeysIn as F,keys as G,arrayPush as H,getAllKeys as I,N as J,baseKeys as K,B as L,X as M,Y as N,hasPath as O,U as P,isPrototype as Q,z as R,isString as S,forEach as T,keysIn as U,bt as V,I as W,O as X,baseUnary as Y,E as Z,some as _,n as _t,GAstVisitor as a,baseAssignValue as at,includes as b,NonTerminal as c,arrayEach as ct,RepetitionMandatory as d,toInteger as dt,isArrayLike as et,RepetitionMandatoryWithSeparator as f,isObject as ft,serializeGrammar as g,r as gt,Terminal as h,isObjectLike as ht,isSequenceProd as i,eq as it,SetCache as j,setToArray as k,Option as l,isFunction as lt,Rule as m,arrayMap as mt,isBranchingProd as n,copyObject as nt,Alternation as o,baseIndexOf as ot,RepetitionWithSeparator as p,p as pt,F as q,isOptionalProd as r,assignValue as rt,Alternative as s,baseFindIndex as st,getProductionDslName as t,baseRest as tt,Repetition as u,identity as ut,pickBy as v,every as w,values as x,ln as y,arrayFilter as z};
1
+ import"../../rolldown-runtime.mjs";function tokenLabel(e){return hasTokenLabel(e)?e.LABEL:e.name}function hasTokenLabel(e){return typeof e.LABEL==`string`&&e.LABEL!==``}var AbstractProduction=class{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),this.definition.forEach(t=>{t.accept(e)})}},NonTerminal=class extends AbstractProduction{constructor(e){super([]),this.idx=1,Object.assign(this,pickOnlyDefined(e))}set definition(e){}get definition(){return this.referencedRule===void 0?[]:this.referencedRule.definition}accept(e){e.visit(this)}},Rule=class extends AbstractProduction{constructor(e){super(e.definition),this.orgText=``,Object.assign(this,pickOnlyDefined(e))}},Alternative=class extends AbstractProduction{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,Object.assign(this,pickOnlyDefined(e))}},Option=class extends AbstractProduction{constructor(e){super(e.definition),this.idx=1,Object.assign(this,pickOnlyDefined(e))}},RepetitionMandatory=class extends AbstractProduction{constructor(e){super(e.definition),this.idx=1,Object.assign(this,pickOnlyDefined(e))}},RepetitionMandatoryWithSeparator=class extends AbstractProduction{constructor(e){super(e.definition),this.idx=1,Object.assign(this,pickOnlyDefined(e))}},Repetition=class extends AbstractProduction{constructor(e){super(e.definition),this.idx=1,Object.assign(this,pickOnlyDefined(e))}},RepetitionWithSeparator=class extends AbstractProduction{constructor(e){super(e.definition),this.idx=1,Object.assign(this,pickOnlyDefined(e))}},Alternation=class extends AbstractProduction{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,Object.assign(this,pickOnlyDefined(e))}},Terminal=class{constructor(e){this.idx=1,Object.assign(this,pickOnlyDefined(e))}accept(e){e.visit(this)}};function serializeGrammar(e){return e.map(serializeProduction)}function serializeProduction(e){function convertDefinition(e){return e.map(serializeProduction)}
2
+ /* istanbul ignore else */
3
+ if(e instanceof NonTerminal){let t={type:`NonTerminal`,name:e.nonTerminalName,idx:e.idx};return typeof e.label==`string`&&(t.label=e.label),t}if(e instanceof Alternative)return{type:`Alternative`,definition:convertDefinition(e.definition)};if(e instanceof Option)return{type:`Option`,idx:e.idx,definition:convertDefinition(e.definition)};if(e instanceof RepetitionMandatory)return{type:`RepetitionMandatory`,idx:e.idx,definition:convertDefinition(e.definition)};if(e instanceof RepetitionMandatoryWithSeparator)return{type:`RepetitionMandatoryWithSeparator`,idx:e.idx,separator:serializeProduction(new Terminal({terminalType:e.separator})),definition:convertDefinition(e.definition)};if(e instanceof RepetitionWithSeparator)return{type:`RepetitionWithSeparator`,idx:e.idx,separator:serializeProduction(new Terminal({terminalType:e.separator})),definition:convertDefinition(e.definition)};if(e instanceof Repetition)return{type:`Repetition`,idx:e.idx,definition:convertDefinition(e.definition)};if(e instanceof Alternation)return{type:`Alternation`,idx:e.idx,definition:convertDefinition(e.definition)};if(e instanceof Terminal){let t={type:`Terminal`,name:e.terminalType.name,label:tokenLabel(e.terminalType),idx:e.idx};typeof e.label==`string`&&(t.terminalLabel=e.label);let n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(t.pattern=n instanceof RegExp?n.source:n),t}if(e instanceof Rule)return{type:`Rule`,name:e.name,orgText:e.orgText,definition:convertDefinition(e.definition)};throw Error(`non exhaustive match`)}function pickOnlyDefined(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}var GAstVisitor=class{visit(e){let t=e;switch(t.constructor){case NonTerminal:return this.visitNonTerminal(t);case Alternative:return this.visitAlternative(t);case Option:return this.visitOption(t);case RepetitionMandatory:return this.visitRepetitionMandatory(t);case RepetitionMandatoryWithSeparator:return this.visitRepetitionMandatoryWithSeparator(t);case RepetitionWithSeparator:return this.visitRepetitionWithSeparator(t);case Repetition:return this.visitRepetition(t);case Alternation:return this.visitAlternation(t);case Terminal:return this.visitTerminal(t);case Rule:return this.visitRule(t);
4
+ /* c8 ignore next 2 */
5
+ default:throw Error(`non exhaustive match`)}}
6
+ /* c8 ignore next */
7
+ visitNonTerminal(e){}
8
+ /* c8 ignore next */
9
+ visitAlternative(e){}
10
+ /* c8 ignore next */
11
+ visitOption(e){}
12
+ /* c8 ignore next */
13
+ visitRepetition(e){}
14
+ /* c8 ignore next */
15
+ visitRepetitionMandatory(e){}
16
+ /* c8 ignore next 3 */
17
+ visitRepetitionMandatoryWithSeparator(e){}
18
+ /* c8 ignore next */
19
+ visitRepetitionWithSeparator(e){}
20
+ /* c8 ignore next */
21
+ visitAlternation(e){}
22
+ /* c8 ignore next */
23
+ visitTerminal(e){}
24
+ /* c8 ignore next */
25
+ visitRule(e){}};function isSequenceProd(e){return e instanceof Alternative||e instanceof Option||e instanceof Repetition||e instanceof RepetitionMandatory||e instanceof RepetitionMandatoryWithSeparator||e instanceof RepetitionWithSeparator||e instanceof Terminal||e instanceof Rule}function isOptionalProd(e,t=[]){return e instanceof Option||e instanceof Repetition||e instanceof RepetitionWithSeparator?!0:e instanceof Alternation?e.definition.some(e=>isOptionalProd(e,t)):e instanceof NonTerminal&&t.includes(e)?!1:e instanceof AbstractProduction&&(e instanceof NonTerminal&&t.push(e),e.definition.every(e=>isOptionalProd(e,t)))}function isBranchingProd(e){return e instanceof Alternation}function getProductionDslName(e){
26
+ /* istanbul ignore else */
27
+ if(e instanceof NonTerminal)return`SUBRULE`;if(e instanceof Option)return`OPTION`;if(e instanceof Alternation)return`OR`;if(e instanceof RepetitionMandatory)return`AT_LEAST_ONE`;if(e instanceof RepetitionMandatoryWithSeparator)return`AT_LEAST_ONE_SEP`;if(e instanceof RepetitionWithSeparator)return`MANY_SEP`;if(e instanceof Repetition)return`MANY`;if(e instanceof Terminal)return`CONSUME`;throw Error(`non exhaustive match`)}export{GAstVisitor as a,NonTerminal as c,RepetitionMandatory as d,RepetitionMandatoryWithSeparator as f,serializeGrammar as g,Terminal as h,isSequenceProd as i,Option as l,Rule as m,isBranchingProd as n,Alternation as o,RepetitionWithSeparator as p,isOptionalProd as r,Alternative as s,getProductionDslName as t,Repetition as u};
@@ -1,9 +1,81 @@
1
- import"../../rolldown-runtime.mjs";function cc(e){return e.charCodeAt(0)}function insertToSet(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function addFlag(e,t){if(e[t]===!0)throw`duplicate flag `+t;e[t],e[t]=!0}function ASSERT_EXISTS(e){if(e===void 0)throw Error(`Internal Error - Should never get here!`);return!0}function ASSERT_NEVER_REACH_HERE(){throw Error(`Internal Error - Should never get here!`)}function isCharacter(e){return e.type===`Character`}const e=[];for(let t=cc(`0`);t<=cc(`9`);t++)e.push(t);const t=[cc(`_`)].concat(e);for(let e=cc(`a`);e<=cc(`z`);e++)t.push(e);for(let e=cc(`A`);e<=cc(`Z`);e++)t.push(e);const n=[cc(` `),cc(`\f`),cc(`
2
- `),cc(`\r`),cc(` `),cc(`\v`),cc(` `),cc(`\xA0`),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(`\u2028`),cc(`\u2029`),cc(` `),cc(` `),cc(` `),cc(``)],r=/[0-9a-fA-F]/,i=/[0-9]/,a=/[1-9]/;var RegExpParser=class{constructor(){this.idx=0,this.input=``,this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar(`/`);let t=this.disjunction();this.consumeChar(`/`);let n={type:`Flags`,loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case`g`:addFlag(n,`global`);break;case`i`:addFlag(n,`ignoreCase`);break;case`m`:addFlag(n,`multiLine`);break;case`u`:addFlag(n,`unicode`);break;case`y`:addFlag(n,`sticky`)}if(this.idx!==this.input.length)throw Error(`Redundant input: `+this.input.substring(this.idx));return{type:`Pattern`,flags:n,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()===`|`;)this.consumeChar(`|`),e.push(this.alternative());return{type:`Disjunction`,value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:`Alternative`,value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case`^`:return{type:`StartAnchor`,loc:this.loc(e)};case`$`:return{type:`EndAnchor`,loc:this.loc(e)};case`\\`:switch(this.popChar()){case`b`:return{type:`WordBoundary`,loc:this.loc(e)};case`B`:return{type:`NonWordBoundary`,loc:this.loc(e)}}throw Error(`Invalid Assertion Escape`);case`(`:this.consumeChar(`?`);let t;switch(this.popChar()){case`=`:t=`Lookahead`;break;case`!`:t=`NegativeLookahead`}ASSERT_EXISTS(t);let n=this.disjunction();return this.consumeChar(`)`),{type:t,value:n,loc:this.loc(e)}}return ASSERT_NEVER_REACH_HERE()}quantifier(e=!1){let t,n=this.idx;switch(this.popChar()){case`*`:t={atLeast:0,atMost:1/0};break;case`+`:t={atLeast:1,atMost:1/0};break;case`?`:t={atLeast:0,atMost:1};break;case`{`:let n=this.integerIncludingZero();switch(this.popChar()){case`}`:t={atLeast:n,atMost:n};break;case`,`:let e;this.isDigit()?(e=this.integerIncludingZero(),t={atLeast:n,atMost:e}):t={atLeast:n,atMost:1/0},this.consumeChar(`}`)}if(e===!0&&t===void 0)return;ASSERT_EXISTS(t)}if((e!==!0||t!==void 0)&&ASSERT_EXISTS(t))return this.peekChar(0)===`?`?(this.consumeChar(`?`),t.greedy=!1):t.greedy=!0,t.type=`Quantifier`,t.loc=this.loc(n),t}atom(){let e,t=this.idx;switch(this.peekChar()){case`.`:e=this.dotAll();break;case`\\`:e=this.atomEscape();break;case`[`:e=this.characterClass();break;case`(`:e=this.group()}return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),ASSERT_EXISTS(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):ASSERT_NEVER_REACH_HERE()}dotAll(){return this.consumeChar(`.`),{type:`Set`,complement:!0,value:[cc(`
3
- `),cc(`\r`),cc(`\u2028`),cc(`\u2029`)]}}atomEscape(){switch(this.consumeChar(`\\`),this.peekChar()){case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:return this.decimalEscapeAtom();case`d`:case`D`:case`s`:case`S`:case`w`:case`W`:return this.characterClassEscape();case`f`:case`n`:case`r`:case`t`:case`v`:return this.controlEscapeAtom();case`c`:return this.controlLetterEscapeAtom();case`0`:return this.nulCharacterAtom();case`x`:return this.hexEscapeSequenceAtom();case`u`:return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:`GroupBackReference`,value:this.positiveInteger()}}characterClassEscape(){let r,i=!1;switch(this.popChar()){case`d`:r=e;break;case`D`:r=e,i=!0;break;case`s`:r=n;break;case`S`:r=n,i=!0;break;case`w`:r=t;break;case`W`:r=t,i=!0}return ASSERT_EXISTS(r)?{type:`Set`,value:r,complement:i}:ASSERT_NEVER_REACH_HERE()}controlEscapeAtom(){let e;switch(this.popChar()){case`f`:e=cc(`\f`);break;case`n`:e=cc(`
4
- `);break;case`r`:e=cc(`\r`);break;case`t`:e=cc(` `);break;case`v`:e=cc(`\v`)}return ASSERT_EXISTS(e)?{type:`Character`,value:e}:ASSERT_NEVER_REACH_HERE()}controlLetterEscapeAtom(){this.consumeChar(`c`);let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error(`Invalid `);return{type:`Character`,value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar(`0`),{type:`Character`,value:cc(`\0`)}}hexEscapeSequenceAtom(){return this.consumeChar(`x`),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar(`u`),this.parseHexDigits(4)}identityEscapeAtom(){return{type:`Character`,value:cc(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case`
5
- `:case`\r`:case`\u2028`:case`\u2029`:case`\\`:case`]`:throw Error(`TBD`);default:return{type:`Character`,value:cc(this.popChar())}}}characterClass(){let e=[],t=!1;for(this.consumeChar(`[`),this.peekChar(0)===`^`&&(this.consumeChar(`^`),t=!0);this.isClassAtom();){let t=this.classAtom();if(t.type,isCharacter(t)&&this.isRangeDash()){this.consumeChar(`-`);let n=this.classAtom();if(n.type,isCharacter(n)){if(n.value<t.value)throw Error(`Range out of order in character class`);e.push({from:t.value,to:n.value})}else insertToSet(t.value,e),e.push(cc(`-`)),insertToSet(n.value,e)}else insertToSet(t.value,e)}return this.consumeChar(`]`),{type:`Set`,complement:t,value:e}}classAtom(){switch(this.peekChar()){case`]`:case`
6
- `:case`\r`:case`\u2028`:case`\u2029`:throw Error(`TBD`);case`\\`:return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar(`\\`),this.peekChar()){case`b`:return this.consumeChar(`b`),{type:`Character`,value:cc(`\b`)};case`d`:case`D`:case`s`:case`S`:case`w`:case`W`:return this.characterClassEscape();case`f`:case`n`:case`r`:case`t`:case`v`:return this.controlEscapeAtom();case`c`:return this.controlLetterEscapeAtom();case`0`:return this.nulCharacterAtom();case`x`:return this.hexEscapeSequenceAtom();case`u`:return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;switch(this.consumeChar(`(`),this.peekChar(0)){case`?`:this.consumeChar(`?`),this.consumeChar(`:`),e=!1;break;default:this.groupIdx++}let t=this.disjunction();this.consumeChar(`)`);let n={type:`Group`,capturing:e,value:t};return e&&(n.idx=this.groupIdx),n}positiveInteger(){let e=this.popChar();if(a.test(e)===!1)throw Error(`Expecting a positive integer`);for(;i.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(i.test(e)===!1)throw Error(`Expecting an integer`);for(;i.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case`
7
- `:case`\r`:case`\u2028`:case`\u2029`:case`^`:case`$`:case`\\`:case`.`:case`*`:case`+`:case`?`:case`(`:case`)`:case`[`:case`|`:throw Error(`TBD`);default:return{type:`Character`,value:cc(e)}}}isRegExpFlag(){switch(this.peekChar(0)){case`g`:case`i`:case`m`:case`u`:case`y`:return!0;default:return!1}}isRangeDash(){return this.peekChar()===`-`&&this.isClassAtom(1)}isDigit(){return i.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case`]`:case`
8
- `:case`\r`:case`\u2028`:case`\u2029`:return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case`.`:case`\\`:case`[`:case`(`:return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case`^`:case`$`:return!0;case`\\`:switch(this.peekChar(1)){case`b`:case`B`:return!0;default:return!1}case`(`:return this.peekChar(1)===`?`&&(this.peekChar(2)===`=`||this.peekChar(2)===`!`);default:return!1}}isQuantifier(){let e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case`^`:case`$`:case`\\`:case`.`:case`*`:case`+`:case`?`:case`(`:case`)`:case`[`:case`|`:case`/`:case`
9
- `:case`\r`:case`\u2028`:case`\u2029`:return!1;default:return!0}}parseHexDigits(e){let t=``;for(let n=0;n<e;n++){let e=this.popChar();if(r.test(e)===!1)throw Error(`Expecting a HexDecimal digits`);t+=e}return{type:`Character`,value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error(`Expected: '`+e+`' but found: '`+this.input[this.idx]+`' at offset: `+this.idx);if(this.idx>=this.input.length)throw Error(`Unexpected end of input`);this.idx++}loc(e){return{begin:e,end:this.idx}}},BaseRegExpVisitor=class{visitChildren(e){for(let t in e){let n=e[t];e.hasOwnProperty(t)&&(n.type===void 0?Array.isArray(n)&&n.forEach(e=>{this.visit(e)},this):this.visit(n))}}visit(e){switch(e.type){case`Pattern`:this.visitPattern(e);break;case`Flags`:this.visitFlags(e);break;case`Disjunction`:this.visitDisjunction(e);break;case`Alternative`:this.visitAlternative(e);break;case`StartAnchor`:this.visitStartAnchor(e);break;case`EndAnchor`:this.visitEndAnchor(e);break;case`WordBoundary`:this.visitWordBoundary(e);break;case`NonWordBoundary`:this.visitNonWordBoundary(e);break;case`Lookahead`:this.visitLookahead(e);break;case`NegativeLookahead`:this.visitNegativeLookahead(e);break;case`Character`:this.visitCharacter(e);break;case`Set`:this.visitSet(e);break;case`Group`:this.visitGroup(e);break;case`GroupBackReference`:this.visitGroupBackReference(e);break;case`Quantifier`:this.visitQuantifier(e)}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}};export{RegExpParser as n,BaseRegExpVisitor as t};
1
+ import"../../rolldown-runtime.mjs";function cc(e){return e.charCodeAt(0)}function insertToSet(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function addFlag(e,t){if(e[t]===!0)throw`duplicate flag `+t;e[t],e[t]=!0}function ASSERT_EXISTS(e){
2
+ // istanbul ignore next
3
+ if(e===void 0)throw Error(`Internal Error - Should never get here!`);return!0}
4
+ // istanbul ignore next
5
+ function ASSERT_NEVER_REACH_HERE(){throw Error(`Internal Error - Should never get here!`)}function isCharacter(e){return e.type===`Character`}const e=[];for(let t=cc(`0`);t<=cc(`9`);t++)e.push(t);const t=[cc(`_`)].concat(e);for(let e=cc(`a`);e<=cc(`z`);e++)t.push(e);for(let e=cc(`A`);e<=cc(`Z`);e++)t.push(e);const n=[cc(` `),cc(`\f`),cc(`
6
+ `),cc(`\r`),cc(` `),cc(`\v`),cc(` `),cc(`\xA0`),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(` `),cc(`\u2028`),cc(`\u2029`),cc(` `),cc(` `),cc(` `),cc(``)],r=/[0-9a-fA-F]/,i=/[0-9]/,a=/[1-9]/;var RegExpParser=class{constructor(){this.idx=0,this.input=``,this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar(`/`);let t=this.disjunction();this.consumeChar(`/`);let n={type:`Flags`,loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case`g`:addFlag(n,`global`);break;case`i`:addFlag(n,`ignoreCase`);break;case`m`:addFlag(n,`multiLine`);break;case`u`:addFlag(n,`unicode`);break;case`y`:addFlag(n,`sticky`)}if(this.idx!==this.input.length)throw Error(`Redundant input: `+this.input.substring(this.idx));return{type:`Pattern`,flags:n,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()===`|`;)this.consumeChar(`|`),e.push(this.alternative());return{type:`Disjunction`,value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:`Alternative`,value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case`^`:return{type:`StartAnchor`,loc:this.loc(e)};case`$`:return{type:`EndAnchor`,loc:this.loc(e)};case`\\`:switch(this.popChar()){case`b`:return{type:`WordBoundary`,loc:this.loc(e)};case`B`:return{type:`NonWordBoundary`,loc:this.loc(e)}}
7
+ /* c8 ignore next */
8
+ throw Error(`Invalid Assertion Escape`);case`(`:this.consumeChar(`?`);let t;switch(this.popChar()){case`=`:t=`Lookahead`;break;case`!`:t=`NegativeLookahead`;break;case`<`:switch(this.popChar()){case`=`:t=`Lookbehind`;break;case`!`:t=`NegativeLookbehind`}}ASSERT_EXISTS(t);let n=this.disjunction();return this.consumeChar(`)`),{type:t,value:n,loc:this.loc(e)}}
9
+ // istanbul ignore next
10
+ return ASSERT_NEVER_REACH_HERE()}quantifier(e=!1){let t,n=this.idx;switch(this.popChar()){case`*`:t={atLeast:0,atMost:1/0};break;case`+`:t={atLeast:1,atMost:1/0};break;case`?`:t={atLeast:0,atMost:1};break;case`{`:let n=this.integerIncludingZero();switch(this.popChar()){case`}`:t={atLeast:n,atMost:n};break;case`,`:let e;this.isDigit()?(e=this.integerIncludingZero(),t={atLeast:n,atMost:e}):t={atLeast:n,atMost:1/0},this.consumeChar(`}`)}if(e===!0&&t===void 0)return;ASSERT_EXISTS(t)}if((e!==!0||t!==void 0)&&ASSERT_EXISTS(t))return this.peekChar(0)===`?`?(this.consumeChar(`?`),t.greedy=!1):t.greedy=!0,t.type=`Quantifier`,t.loc=this.loc(n),t}atom(){let e,t=this.idx;switch(this.peekChar()){case`.`:e=this.dotAll();break;case`\\`:e=this.atomEscape();break;case`[`:e=this.characterClass();break;case`(`:e=this.group()}
11
+ // istanbul ignore next
12
+ return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),ASSERT_EXISTS(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):ASSERT_NEVER_REACH_HERE()}dotAll(){return this.consumeChar(`.`),{type:`Set`,complement:!0,value:[cc(`
13
+ `),cc(`\r`),cc(`\u2028`),cc(`\u2029`)]}}atomEscape(){switch(this.consumeChar(`\\`),this.peekChar()){case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:return this.decimalEscapeAtom();case`d`:case`D`:case`s`:case`S`:case`w`:case`W`:return this.characterClassEscape();case`f`:case`n`:case`r`:case`t`:case`v`:return this.controlEscapeAtom();case`c`:return this.controlLetterEscapeAtom();case`0`:return this.nulCharacterAtom();case`x`:return this.hexEscapeSequenceAtom();case`u`:return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:`GroupBackReference`,value:this.positiveInteger()}}characterClassEscape(){let r,i=!1;switch(this.popChar()){case`d`:r=e;break;case`D`:r=e,i=!0;break;case`s`:r=n;break;case`S`:r=n,i=!0;break;case`w`:r=t;break;case`W`:r=t,i=!0}
14
+ // istanbul ignore next
15
+ return ASSERT_EXISTS(r)?{type:`Set`,value:r,complement:i}:ASSERT_NEVER_REACH_HERE()}controlEscapeAtom(){let e;switch(this.popChar()){case`f`:e=cc(`\f`);break;case`n`:e=cc(`
16
+ `);break;case`r`:e=cc(`\r`);break;case`t`:e=cc(` `);break;case`v`:e=cc(`\v`)}
17
+ // istanbul ignore next
18
+ return ASSERT_EXISTS(e)?{type:`Character`,value:e}:ASSERT_NEVER_REACH_HERE()}controlLetterEscapeAtom(){this.consumeChar(`c`);let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error(`Invalid `);return{type:`Character`,value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar(`0`),{type:`Character`,value:cc(`\0`)}}hexEscapeSequenceAtom(){return this.consumeChar(`x`),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar(`u`),this.parseHexDigits(4)}identityEscapeAtom(){return{type:`Character`,value:cc(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){
19
+ // istanbul ignore next
20
+ case`
21
+ `:
22
+ // istanbul ignore next
23
+ case`\r`:
24
+ // istanbul ignore next
25
+ case`\u2028`:
26
+ // istanbul ignore next
27
+ case`\u2029`:
28
+ // istanbul ignore next
29
+ case`\\`:
30
+ // istanbul ignore next
31
+ case`]`:throw Error(`TBD`);default:return{type:`Character`,value:cc(this.popChar())}}}characterClass(){let e=[],t=!1;for(this.consumeChar(`[`),this.peekChar(0)===`^`&&(this.consumeChar(`^`),t=!0);this.isClassAtom();){let t=this.classAtom();if(t.type,isCharacter(t)&&this.isRangeDash()){this.consumeChar(`-`);let n=this.classAtom();if(n.type,isCharacter(n)){if(n.value<t.value)throw Error(`Range out of order in character class`);e.push({from:t.value,to:n.value})}else insertToSet(t.value,e),e.push(cc(`-`)),insertToSet(n.value,e)}else insertToSet(t.value,e)}return this.consumeChar(`]`),{type:`Set`,complement:t,value:e}}classAtom(){switch(this.peekChar()){
32
+ // istanbul ignore next
33
+ case`]`:
34
+ // istanbul ignore next
35
+ case`
36
+ `:
37
+ // istanbul ignore next
38
+ case`\r`:
39
+ // istanbul ignore next
40
+ case`\u2028`:
41
+ // istanbul ignore next
42
+ case`\u2029`:throw Error(`TBD`);case`\\`:return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar(`\\`),this.peekChar()){case`b`:return this.consumeChar(`b`),{type:`Character`,value:cc(`\b`)};case`d`:case`D`:case`s`:case`S`:case`w`:case`W`:return this.characterClassEscape();case`f`:case`n`:case`r`:case`t`:case`v`:return this.controlEscapeAtom();case`c`:return this.controlLetterEscapeAtom();case`0`:return this.nulCharacterAtom();case`x`:return this.hexEscapeSequenceAtom();case`u`:return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;switch(this.consumeChar(`(`),this.peekChar(0)){case`?`:this.consumeChar(`?`),this.consumeChar(`:`),e=!1;break;default:this.groupIdx++}let t=this.disjunction();this.consumeChar(`)`);let n={type:`Group`,capturing:e,value:t};return e&&(n.idx=this.groupIdx),n}positiveInteger(){let e=this.popChar();
43
+ // istanbul ignore next - can't ever get here due to previous lookahead checks
44
+ if(a.test(e)===!1)throw Error(`Expecting a positive integer`);for(;i.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(i.test(e)===!1)throw Error(`Expecting an integer`);for(;i.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){
45
+ // istanbul ignore next
46
+ case`
47
+ `:
48
+ // istanbul ignore next
49
+ case`\r`:
50
+ // istanbul ignore next
51
+ case`\u2028`:
52
+ // istanbul ignore next
53
+ case`\u2029`:
54
+ // istanbul ignore next
55
+ case`^`:
56
+ // istanbul ignore next
57
+ case`$`:
58
+ // istanbul ignore next
59
+ case`\\`:
60
+ // istanbul ignore next
61
+ case`.`:
62
+ // istanbul ignore next
63
+ case`*`:
64
+ // istanbul ignore next
65
+ case`+`:
66
+ // istanbul ignore next
67
+ case`?`:
68
+ // istanbul ignore next
69
+ case`(`:
70
+ // istanbul ignore next
71
+ case`)`:
72
+ // istanbul ignore next
73
+ case`[`:
74
+ // istanbul ignore next
75
+ case`|`:
76
+ // istanbul ignore next
77
+ throw Error(`TBD`);default:return{type:`Character`,value:cc(e)}}}isRegExpFlag(){switch(this.peekChar(0)){case`g`:case`i`:case`m`:case`u`:case`y`:return!0;default:return!1}}isRangeDash(){return this.peekChar()===`-`&&this.isClassAtom(1)}isDigit(){return i.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case`]`:case`
78
+ `:case`\r`:case`\u2028`:case`\u2029`:return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case`.`:case`\\`:case`[`:case`(`:return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case`^`:case`$`:return!0;case`\\`:switch(this.peekChar(1)){case`b`:case`B`:return!0;default:return!1}case`(`:return this.peekChar(1)===`?`&&(this.peekChar(2)===`=`||this.peekChar(2)===`!`||this.peekChar(2)===`<`&&(this.peekChar(3)===`=`||this.peekChar(3)===`!`));default:return!1}}isQuantifier(){let e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case`^`:case`$`:case`\\`:case`.`:case`*`:case`+`:case`?`:case`(`:case`)`:case`[`:case`|`:case`/`:case`
79
+ `:case`\r`:case`\u2028`:case`\u2029`:return!1;default:return!0}}parseHexDigits(e){let t=``;for(let n=0;n<e;n++){let e=this.popChar();if(r.test(e)===!1)throw Error(`Expecting a HexDecimal digits`);t+=e}return{type:`Character`,value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error(`Expected: '`+e+`' but found: '`+this.input[this.idx]+`' at offset: `+this.idx);if(this.idx>=this.input.length)throw Error(`Unexpected end of input`);this.idx++}loc(e){return{begin:e,end:this.idx}}},BaseRegExpVisitor=class{visitChildren(e){for(let t in e){let n=e[t];
80
+ /* istanbul ignore else */
81
+ e.hasOwnProperty(t)&&(n.type===void 0?Array.isArray(n)&&n.forEach(e=>{this.visit(e)},this):this.visit(n))}}visit(e){switch(e.type){case`Pattern`:this.visitPattern(e);break;case`Flags`:this.visitFlags(e);break;case`Disjunction`:this.visitDisjunction(e);break;case`Alternative`:this.visitAlternative(e);break;case`StartAnchor`:this.visitStartAnchor(e);break;case`EndAnchor`:this.visitEndAnchor(e);break;case`WordBoundary`:this.visitWordBoundary(e);break;case`NonWordBoundary`:this.visitNonWordBoundary(e);break;case`Lookahead`:this.visitLookahead(e);break;case`NegativeLookahead`:this.visitNegativeLookahead(e);break;case`Lookbehind`:this.visitLookbehind(e);break;case`NegativeLookbehind`:this.visitNegativeLookbehind(e);break;case`Character`:this.visitCharacter(e);break;case`Set`:this.visitSet(e);break;case`Group`:this.visitGroup(e);break;case`GroupBackReference`:this.visitGroupBackReference(e);break;case`Quantifier`:this.visitQuantifier(e)}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}};export{RegExpParser as n,BaseRegExpVisitor as t};
@@ -0,0 +1,111 @@
1
+ import { i as __name } from "../../rolldown-runtime.mjs";
2
+ //#region ../../node_modules/.pnpm/@chevrotain+types@13.2.0/node_modules/@chevrotain/types/api.d.ts
3
+ type TokenPattern = RegExp | string | CustomPatternMatcherFunc | ICustomPattern;
4
+ /**
5
+ * API #1 [Custom Token Patterns](http://chevrotain.io/docs/guide/custom_token_patterns.html).
6
+ */
7
+ declare type CustomPatternMatcherFunc = (
8
+ /**
9
+ * The full input string.
10
+ */
11
+ text: string,
12
+ /**
13
+ * The offset at which to attempt a match
14
+ */
15
+ offset: number,
16
+ /**
17
+ * Previously scanned Tokens
18
+ */
19
+ tokens: IToken[],
20
+ /**
21
+ * Token Groups
22
+ */
23
+ groups: {
24
+ [groupName: string]: IToken[];
25
+ }) => CustomPatternMatcherReturn | RegExpExecArray | null; // RegExpExecArray included for legacy reasons
26
+ type CustomPatternMatcherReturn = [string] & {
27
+ payload?: any;
28
+ };
29
+ interface TokenType {
30
+ name: string;
31
+ GROUP?: string;
32
+ PATTERN?: TokenPattern;
33
+ LABEL?: string;
34
+ LONGER_ALT?: TokenType | TokenType[];
35
+ POP_MODE?: boolean;
36
+ PUSH_MODE?: string;
37
+ LINE_BREAKS?: boolean;
38
+ CATEGORIES?: TokenType[];
39
+ tokenTypeIdx?: number;
40
+ categoryMatches?: number[];
41
+ categoryMatchesMap?: {
42
+ [tokType: number]: boolean;
43
+ };
44
+ isParent?: boolean;
45
+ START_CHARS_HINT?: (string | number)[];
46
+ }
47
+ /**
48
+ * API #2 for [Custom Token Patterns](http://chevrotain.io/docs/guide/custom_token_patterns.html).
49
+ */
50
+ interface ICustomPattern {
51
+ exec: CustomPatternMatcherFunc;
52
+ }
53
+ /**
54
+ * Things to note:
55
+ * - The offset range is inclusive to exclusive.
56
+ *
57
+ * - A lineTerminator as the last character does not effect the Token's line numbering.
58
+ * In other words a new line only starts **after** a line terminator.
59
+ *
60
+ * - A Token's image is it's **literal** text.
61
+ * e.g unicode escaping is untouched.
62
+ *
63
+ * - Synthetic tokens without a source location, such as parser EOF and tokens inserted
64
+ * during error recovery, use `-1` for their location properties.
65
+ */
66
+ interface IToken {
67
+ /** The textual representation of the Token as it appeared in the text. */
68
+ image: string;
69
+ /** Offset of the first character of the Token. 0-indexed. */
70
+ startOffset: number;
71
+ /** Line of the first character of the Token. 1-indexed. */
72
+ startLine?: number;
73
+ /**
74
+ * Column of the first character of the Token. 1-indexed.
75
+ *
76
+ * For token foo in the following line, startColumn will be 3 and endColumn will be 5.
77
+ * ```
78
+ * a foo
79
+ * 123456
80
+ * ```
81
+ */
82
+ startColumn?: number;
83
+ /**
84
+ * Offset of the last character of the Token. 0-indexed.
85
+ * Note that this points at the last character, not the end of the token, so the original image would be
86
+ * `input.substring(token.startOffset, token.endOffset + 1)`.
87
+ */
88
+ endOffset?: number;
89
+ /** Line of the last character of the Token. 1-indexed. Will be the same as startLine for single-line tokens.*/
90
+ endLine?: number;
91
+ /** Column of the last character of the Token. 1-indexed. See also startColumn. */
92
+ endColumn?: number;
93
+ /** this marks if a Token does not really exist and has been inserted "artificially" during parsing in rule error recovery. */
94
+ isInsertedInRecovery?: boolean;
95
+ /** An number index representing the type of the Token use <getTokenConstructor> to get the Token Type from a token "instance" */
96
+ tokenTypeIdx: number;
97
+ /**
98
+ * The actual Token Type of this Token "instance"
99
+ * This is the same Object returned by the "createToken" API.
100
+ * This property is very useful for debugging the Lexing and Parsing phases.
101
+ */
102
+ tokenType: TokenType;
103
+ /**
104
+ * Custom Payload value, this is an optional feature of Custom Token Patterns
105
+ * For additional details see the docs:
106
+ * https://chevrotain.io/docs/guide/custom_token_patterns.html#custom-payloads
107
+ */
108
+ payload?: any;
109
+ }
110
+ //#endregion
111
+ export { IToken as t };
@@ -1,5 +1,6 @@
1
- import{i as e,r as t}from"../../rolldown-runtime.mjs";import n from"node:util";function toFilter(e){return typeof e==`function`?e:getLevelFilter(e)}function getLevelFilter(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 r=[`trace`,`debug`,`info`,`warning`,`error`,`fatal`];function compareLogLevel(e,t){let n=r.indexOf(e);if(n<0)throw TypeError(`Invalid log level: ${JSON.stringify(e)}.`);let i=r.indexOf(t);if(i<0)throw TypeError(`Invalid log level: ${JSON.stringify(t)}.`);return n-i}const i=Symbol.for(`logtape.lazy`),a=Symbol.for(`LogTape.throttlingSummaryRecord`);function isLazy(e){return typeof e==`object`&&!!e&&i in e&&e[i]===!0}function resolveProperties(e){let t={};for(let n in e){let r=e[n];t[n]=isLazy(r)?r.getter():r}let n=e,r=t;if(Object.prototype.propertyIsEnumerable.call(e,a)){let e=n[a];r[a]=isLazy(e)?e.getter():e}return t}function isPromiseObject(e){return e instanceof Promise||Object.prototype.toString.call(e)===`[object Promise]`&&typeof e.then==`function`}function logStringMessage(e,t,n,r){if(typeof r!=`function`){let i=r??{};e.log(t,n,i);return}if(!e.isEnabledFor(t))return Promise.resolve();let i=r();if(isPromiseObject(i))return Promise.resolve(i).then(r=>{e.log(t,n,r)});e.log(t,n,i)}function snapshotLogRecordProperties(e){let t=resolveProperties(e.properties),n=Object.getOwnPropertyDescriptors(e);return n.properties={value:t,enumerable:!0,configurable:!0},Object.defineProperties({},n)}function getLogger(e=[]){return s.getLogger(e)}const o=Symbol.for(`logtape.rootLogger`);function isMetaLoggerCategory(e){return e.length===2&&e[0]===`logtape`&&e[1]===`meta`}var s=class LoggerImpl{parent;children;category;sinks;parentSinks=`inherit`;filters;lowestLevel=`trace`;contextLocalStorage;static getLogger(e=[]){let t=o in globalThis?globalThis[o]??null:null;return t??(t=new LoggerImpl(null,[]),globalThis[o]=t),typeof e==`string`?t.getChild(e):e.length===0?t:t.getChild(e)}static getNearestExistingLogger(e){let t=LoggerImpl.getLogger();for(let n of e){let e=t.children[n],r=e instanceof LoggerImpl?e:e?.deref();if(r==null)break;t=r}return t}constructor(e,t){this.parent=e,this.children={},this.category=t,this.sinks=[],this.filters=[]}getChild(e){let t=typeof e==`string`?e:e[0],n=this.children[t],r=n instanceof LoggerImpl?n:n?.deref();return r??(r=new LoggerImpl(this,[...this.category,t]),this.children[t]=`WeakRef`in globalThis?new WeakRef(r):r),typeof e==`string`||e.length===1?r:r.getChild(e.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 e of Object.values(this.children))(e instanceof LoggerImpl?e:e.deref())?.resetDescendants();this.reset()}with(e){return new c(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||compareLogLevel(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){let t=isMetaLoggerCategory(this.category)?[]:getCategoryPrefix();return(t.length>0?LoggerImpl.getNearestExistingLogger([...t,...this.category]):this).isEnabledForResolved(e)}isEnabledForResolved(e){if(this.lowestLevel===null||compareLogLevel(e,this.lowestLevel)<0)return!1;for(let t of this.getSinks(e))return!0;return!1}emit(e,t){let n=`category`in e?e.category:this.category,r=isMetaLoggerCategory(n)?[]:getCategoryPrefix(),i=r.length>0?[...r,...n]:n,a=Object.getOwnPropertyDescriptors(e);a.category={value:i,enumerable:!0,configurable:!0};let o=Object.defineProperties({},a);(r.length>0?LoggerImpl.getNearestExistingLogger(i):this).emitResolved(o,t)}emitResolved(e,t){if(this.lowestLevel===null||compareLogLevel(e.level,this.lowestLevel)<0||!this.filter(e))return;let n=[...this.getSinks(e.level)];if(n.length<1)return;let r,i=!1;for(let a of n)if(!t?.has(a))try{if(r==null&&!i)try{r=snapshotLogRecordProperties(e)}catch{i=!0,r=e}a(r??e)}catch(n){let r=new Set(t);r.add(a),l.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:a,error:n,record:e},r)}}log(e,t,n,r){let i=getImplicitContext(),a,o,s=typeof n==`function`?{category:this.category,level:e,timestamp:Date.now(),get message(){return o??=parseMessageTemplate(t,this.properties),o},rawMessage:t,get properties(){return a??=resolveProperties({...i,...n()}),a}}:{category:this.category,level:e,timestamp:Date.now(),get message(){return o??=parseMessageTemplate(t,this.properties),o},rawMessage:t,get properties(){return a??=resolveProperties({...i,...n}),a}};this.emit(s,r)}logLazily(e,t,n={}){let r=getImplicitContext(),i,a;function realizeMessage(){if((a==null||i==null)&&(a=t((e,...t)=>(i=e,renderMessage(e,t))),i==null))throw TypeError(`No log record was made.`);return[a,i]}this.emit({category:this.category,level:e,get message(){return realizeMessage()[0]},get rawMessage(){return realizeMessage()[1]},timestamp:Date.now(),properties:{...r,...n}})}logTemplate(e,t,n,r={}){let i=getImplicitContext();this.emit({category:this.category,level:e,message:renderMessage(t,n),rawMessage:t,timestamp:Date.now(),properties:{...i,...r}})}trace(e,...t){if(typeof e==`string`)return logStringMessage(this,`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){if(typeof e==`string`)return logStringMessage(this,`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){if(typeof e==`string`)return logStringMessage(this,`info`,e,t[0]);typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}logError(e,t,n){if(typeof n!=`function`){this.log(e,`{error.message}`,{...n,error:t});return}if(!this.isEnabledFor(e))return Promise.resolve();let r=n();if(r instanceof Promise)return r.then(n=>{this.log(e,`{error.message}`,{...n,error:t})});this.log(e,`{error.message}`,{...r,error:t})}warn(e,...t){if(e instanceof Error)return this.logError(`warning`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0]);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)return this.logError(`warning`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0]);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)return this.logError(`error`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`error`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`error`,e,t[0]);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)return this.logError(`fatal`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`fatal`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`fatal`,e,t[0]);else typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},c=class LoggerCtx{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(e){return new LoggerCtx(this.logger,{...this.properties,...e})}log(e,t,n,r){let i=this.properties;this.logger.log(e,t,typeof n==`function`?()=>resolveProperties({...i,...n()}):()=>resolveProperties({...i,...n}),r)}logLazily(e,t){this.logger.logLazily(e,t,resolveProperties(this.properties))}logTemplate(e,t,n){this.logger.logTemplate(e,t,n,resolveProperties(this.properties))}emit(e){let t={...e,properties:resolveProperties({...this.properties,...e.properties})};this.logger.emit(t)}isEnabledFor(e){return this.logger.isEnabledFor(e)}trace(e,...t){if(typeof e==`string`)return logStringMessage(this,`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){if(typeof e==`string`)return logStringMessage(this,`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){if(typeof e==`string`)return logStringMessage(this,`info`,e,t[0]);typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}logError(e,t,n){if(typeof n!=`function`){this.log(e,`{error.message}`,{...n,error:t});return}if(!this.isEnabledFor(e))return Promise.resolve();let r=n();if(r instanceof Promise)return r.then(n=>{this.log(e,`{error.message}`,{...n,error:t})});this.log(e,`{error.message}`,{...r,error:t})}warn(e,...t){if(e instanceof Error)return this.logError(`warning`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0]);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)return this.logError(`warning`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0]);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)return this.logError(`error`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`error`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`error`,e,t[0]);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)return this.logError(`fatal`,e,t[0]);if(typeof e==`string`&&t[0]instanceof Error)this.log(`fatal`,e,{error:t[0]});else if(typeof e==`string`)return logStringMessage(this,`fatal`,e,t[0]);else typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}};const l=s.getLogger([`logtape`,`meta`]);function isNestedAccess(e){return e.includes(`.`)||e.includes(`[`)||e.includes(`?.`)}function getOwnProperty(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 parseNextSegment(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 accessProperty(e,t){if(typeof t==`string`)return getOwnProperty(e,t);if(Array.isArray(e)&&t>=0&&t<e.length)return e[t]}function resolvePropertyPath(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=parseNextSegment(t,r);if(e===null)return;let{segment:i,nextIndex:a}=e;if(r=a,n=accessProperty(n,i),n===void 0)return}return n}function parseMessageTemplate(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&&isNestedAccess(u)&&(l=resolvePropertyPath(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 renderMessage(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 u=Symbol.for(`logtape.categoryPrefix`);function getCategoryPrefix(){let e=s.getLogger().contextLocalStorage?.getStore();if(e==null)return[];let t=e[u];return Array.isArray(t)?t:[]}function getImplicitContext(){let e=s.getLogger().contextLocalStorage?.getStore();if(e==null)return{};let t={};for(let n of Object.keys(e))t[n]=e[n];return t}var d=t({inspect:()=>inspect$1});function inspect$1(e,t){return n.inspect(e,t)}e(inspect$1,`inspect`);const f={trace:`TRC`,debug:`DBG`,info:`INF`,warning:`WRN`,error:`ERR`,fatal:`FTL`},p=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}):d!=null&&`inspect`in d&&typeof inspect$1==`function`?(e,t)=>inspect$1(e,{maxArrayLength:1/0,maxStringLength:1/0,...t}):e=>JSON.stringify(e),inspect=(e,t)=>String(p(e,t)),m=new TextEncoder;function renderMessageParts(e,t){let n=e.length;if(n===1)return e[0];if(n<=6){let r=``;for(let i=0;i<n;i++)r+=i%2==0?e[i]:t(e[i]);return r}let r=Array(n);for(let i=0;i<n;i++)r[i]=i%2==0?e[i]:t(e[i]);return r.join(``)}function padZero(e){return e<10?`0${e}`:`${e}`}function padThree(e){return e<10?`00${e}`:e<100?`0${e}`:`${e}`}const h=/^([+-])(0\d|1\d|2[0-3]):([0-5]\d)$/;function formatOffset(e,t){let n=e<0?`-`:`+`,r=Math.abs(e),i=padZero(Math.floor(r/60)),a=padZero(r%60);return!t&&a===`00`?`${n}${i}`:`${n}${i}:${a}`}function readPartsFromFormatter(e,t){let n=e.formatToParts(new Date(t)),r=``,i=``,a=``,o=``,s=``,c=``;for(let e of n)e.type===`year`?r=e.value:e.type===`month`?i=e.value:e.type===`day`?a=e.value:e.type===`hour`?o=e.value:e.type===`minute`?s=e.value:e.type===`second`&&(c=e.value);return{year:r,month:i,day:a,hour:o,minute:s,second:c}}function getDateParts(e,t){let n=new Date(e),r=padThree(n.getUTCMilliseconds());if(t.kind===`utc`)return{year:`${n.getUTCFullYear()}`,month:padZero(n.getUTCMonth()+1),day:padZero(n.getUTCDate()),hour:padZero(n.getUTCHours()),minute:padZero(n.getUTCMinutes()),second:padZero(n.getUTCSeconds()),ms:r,offsetMinutes:0};if(t.kind===`local`)return{year:`${n.getFullYear()}`,month:padZero(n.getMonth()+1),day:padZero(n.getDate()),hour:padZero(n.getHours()),minute:padZero(n.getMinutes()),second:padZero(n.getSeconds()),ms:r,offsetMinutes:-n.getTimezoneOffset()};if(t.kind===`offset`){let n=new Date(e+t.minutes*6e4);return{year:`${n.getUTCFullYear()}`,month:padZero(n.getUTCMonth()+1),day:padZero(n.getUTCDate()),hour:padZero(n.getUTCHours()),minute:padZero(n.getUTCMinutes()),second:padZero(n.getUTCSeconds()),ms:r,offsetMinutes:t.minutes}}let i=readPartsFromFormatter(t.formatter,e),a=Date.UTC(Number(i.year),Number(i.month)-1,Number(i.day),Number(i.hour),Number(i.minute),Number(i.second),n.getUTCMilliseconds()),o=Math.round((a-e)/6e4);return{...i,ms:r,offsetMinutes:o}}function resolveTimeZone(e){if(e===void 0)return{kind:`utc`};if(e===null)return{kind:`local`};let t=h.exec(e);if(t!=null){let e=t[1]===`-`?-1:1,n=Number(t[2]),r=Number(t[3]);return{kind:`offset`,minutes:e*(n*60+r)}}if(typeof Intl>`u`||typeof Intl.DateTimeFormat!=`function`)throw TypeError(`Invalid timeZone option: ${JSON.stringify(e)}. This environment does not support IANA time zones.`);try{return{kind:`iana`,formatter:new Intl.DateTimeFormat(`en-CA`,{timeZone:e,hour12:!1,hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}}catch{throw TypeError(`Invalid timeZone option: ${JSON.stringify(e)}. Expected an IANA time zone name (e.g., "Asia/Seoul") or a fixed UTC offset string (e.g., "+09:00").`)}}function createTimestampFormatter(e,t){return e===`none`?()=>null:e===`rfc3339`&&t.kind===`utc`?e=>new Date(e).toISOString():n=>{let r=getDateParts(n,t),i=`${r.year}-${r.month}-${r.day}`,a=`${r.hour}:${r.minute}:${r.second}.${r.ms}`,o=formatOffset(r.offsetMinutes,!0),s=formatOffset(r.offsetMinutes,!1);return e===`date-time-timezone`?`${i} ${a} ${o}`:e===`date-time-tz`?`${i} ${a} ${s}`:e===`date-time`?`${i} ${a}`:e===`time-timezone`?`${a} ${o}`:e===`time-tz`?`${a} ${s}`:e===`time`?a:e===`date`?i:`${i}T${a}${o}`}}const g={ABBR:f,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 getLineEndingValue(e){return e===`crlf`?`\r
1
+ import{i as e,r as t}from"../../rolldown-runtime.mjs";import n from"node:util";function toFilter(e){return typeof e==`function`?e:getLevelFilter(e)}function getLevelFilter(e){let t=createLevelFilter(e);return r.set(t,e),t}const r=getLevelFilters();function getLevelFilters(){let e=globalThis,t=Symbol.for(`logtape.levelFilters`),n=e[t];if(n instanceof WeakMap)return n;let r=/* @__PURE__ */ new WeakMap;return e[t]=r,r}function createLevelFilter(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 compareLogLevel(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 a=Symbol.for(`logtape.scopedConfig`),o={filters:[],filterIds:[],lowestLevel:`trace`,parentSinks:`inherit`,sinks:[],sinkIds:[],captureSourceLocation:void 0},s=[];function getCurrentScopedConfig(e){let t=e?.getStore()?.[a];return isCompiledScopedConfig(t)?getActiveScopedConfig(t):void 0}function scopedConfigHasSink(e,t,n){return getScopedSinkDispatchPlan(e,t,n).kind!==`none`}function scopedConfigCapturesSourceLocation(e,t){if(!e.capturesSourceLocation)return!1;let n=categoryKey(t),r=e.sourceLocationCaptureCache.get(n);if(r==null){r=!1;for(let n=t.length;n>=0;n--){let i=e.nodes.get(categoryKey(t.slice(0,n)));if(i?.captureSourceLocation!=null){r=i.captureSourceLocation;break}}e.sourceLocationCaptureCache.set(n,r)}return r}function emitWithScopedConfig(e,t,n,r){let i=getScopedSinkDispatchPlan(e,t.category,t.level);if(i.kind!==`none`&&filterScopedRecord(e,t.category,t)){if(i.kind===`one`)n?.has(i.sink)||r(i.sink,n);else for(let e of i.sinks)n?.has(e)||r(e,n)}}function isCompiledScopedConfig(e){return typeof e==`object`&&!!e&&`nodes`in e}function getActiveScopedConfig(e){let t=e;for(;t?.disposed;)t=t.parent;return t}function categoryKey(e){return JSON.stringify(e)}function getScopedSinkDispatchPlan(e,t,n){let r=`${categoryKey(t)}:${n}`,i=e.dispatchCache.get(r);return i??(i=getScopedSinkDispatchPlanForPrefix(e,t,t.length,n),e.dispatchCache.set(r,i)),i}function getScopedSinkDispatchPlanForPrefix(e,t,n,r){let i=t.slice(0,n),a=e.nodes.get(categoryKey(i))??o;if(a.lowestLevel===null||compareLogLevel(r,a.lowestLevel)<0)return{kind:`none`};let s=n>0&&a.parentSinks===`inherit`?getScopedSinkDispatchPlanForPrefix(e,t,n-1,r):n>0&&a.parentSinks===`forward`?wrapScopedSinks(collectScopedForwardSinks(e,t,n-1)):{kind:`none`},c,l,appendSink=e=>{l==null?c==null?c=e:l=[c,e]:l.push(e)};if(s.kind===`one`)appendSink(s.sink);else if(s.kind===`many`)for(let e of s.sinks)appendSink(e);for(let e of a.sinks)appendSink(e);return l==null?c==null?{kind:`none`}:{kind:`one`,sink:c}:{kind:`many`,sinks:l}}function collectScopedForwardSinks(e,t,n){let r=e.nodes.get(categoryKey(t.slice(0,n)))??o,i=n>0&&r.parentSinks!==`override`?collectScopedForwardSinks(e,t,n-1):[];return r.sinks.length<1?i:i.length<1?r.sinks:[...i,...r.sinks]}function wrapScopedSinks(e){return e.length<1?{kind:`none`}:e.length===1?{kind:`one`,sink:e[0]}:{kind:`many`,sinks:e}}function filterScopedRecord(e,t,n){let r=categoryKey(t),i=e.filterCache.get(r);return i??(i=getScopedFilters(e,t),e.filterCache.set(r,i)),i.every(e=>e(n))}function getScopedFilters(e,t){for(let n=t.length;n>=0;n--){let r=e.nodes.get(categoryKey(t.slice(0,n)));if(!(r==null||r.filters.length<1))return r.filters}return s}const c=` at `,l=/^(?:[A-Za-z][A-Za-z0-9+.-]*:|\/|\\\\)/,u=/^(.+):(\d+):(\d+)$/,d=Symbol(`rejected`);function parseSourceLocation(e,t){if(typeof e!=`string`)return;let n=e.split(`
2
+ `);if(n[0].trim()===`Error`)return n.length<2||!n[1].startsWith(c)?void 0:parseV8Frame(n[t+1]);if(!(n[0]===``||/^\s/.test(n[0])))return parseSpiderMonkeyFrame(n[t])}function parseV8Frame(e){if(e==null||!e.startsWith(c))return;let t=e.slice(7);if(t.includes(`eval at `))return;if(!t.endsWith(`)`))return accept(parseLocation(t.startsWith(`async `)?t.slice(6):t));let n;for(let e=t.indexOf(` (`);e>=0;e=t.indexOf(` (`,e+1)){let r=parseLocation(t.slice(e+2,-1));if(r===d)return;if(r!=null){if(n!=null)return;n=r}}return n}function parseSpiderMonkeyFrame(e){if(e==null)return;let t=parseLocation(e);if(t===d||t!=null&&l.test(t.file))return;let n;for(let t=e.indexOf(`@`);t>=0;t=e.indexOf(`@`,t+1)){let r=parseLocation(e.slice(t+1));if(r===d)return;if(r!=null&&l.test(r.file)){if(n!=null)return;n=r}}return n}function accept(e){return e===d?void 0:e}function parseLocation(e){let t=u.exec(e);if(t==null)return;let n=t[1],r=Number(t[2]),i=Number(t[3]);return n===`native`||n===`<anonymous>`||n===`[native code]`||n.includes(`address at `)||n.includes(`eval at `)||n.includes(` > eval`)||n.includes(` > Function`)||r<1||i<1?d:{file:n,line:r,column:i}}const f=Symbol.for(`logtape.lazy`),p=Symbol.for(`LogTape.throttlingSummaryRecord`),m=Symbol.for(`LogTape.sinkSnapshotPolicy.immediate`),h=/* @__PURE__ */ new WeakSet,g=/* @__PURE__ */ new WeakSet;let _=!1,v=0;function isSourceLocationCaptureActive(){return _||v>0}function attachSourceLocation(e,t){t!=null&&(e.sourceLocation=t)}function isLazy(e){return typeof e==`object`&&!!e&&f in e&&e[f]===!0}function resolveProperties(e){let t={};for(let n in e){let r=e[n];t[n]=isLazy(r)?r.getter():r}let n=e,r=t;if(Object.prototype.propertyIsEnumerable.call(e,p)){let e=n[p];r[p]=isLazy(e)?e.getter():e}return t}function isPromiseObject(e){return e instanceof Promise||Object.prototype.toString.call(e)===`[object Promise]`&&typeof e.then==`function`}function logStringMessage(e,t,n,r,i){if(typeof r!=`function`){let a=r??{};e.log(t,n,a,void 0,i);return}if(!e.isEnabledFor(t))return Promise.resolve();let a=r();if(isPromiseObject(a))return Promise.resolve(a).then(r=>{e.log(t,n,r,void 0,i)});e.log(t,n,a,void 0,i)}function snapshotLogRecordProperties(e){if(g.has(e))return e;let t=resolveProperties(e.properties);if(h.has(e)){let n={category:e.category,level:e.level,get message(){return e.message},rawMessage:e.rawMessage,timestamp:e.timestamp,properties:t};return attachSourceLocation(n,e.sourceLocation),n}let n=Object.getOwnPropertyDescriptors(e);return n.properties={value:t,enumerable:!0,configurable:!0},Object.defineProperties({},n)}function hasEnumerableProperties(e){return typeof e!=`object`||!e?!1:Object.keys(e).length>0||Object.prototype.propertyIsEnumerable.call(e,p)}function shouldSnapshotForSink(e){return e[m]!==!0}function getLogger(e=[]){return b.getLogger(e)}const y=Symbol.for(`logtape.rootLogger`);function isMetaLoggerCategory(e){return e.length>=2&&e[0]===`logtape`&&e[1]===`meta`}var b=class LoggerImpl{parent;children;category;sinks;filters;contextLocalStorage;sourceLocationCapture=void 0;#e=`inherit`;#t=`trace`;#n={};#r=void 0;static getLogger(e=[]){let t=y in globalThis?globalThis[y]??null:null;return t??(t=new LoggerImpl(null,[]),globalThis[y]=t),typeof e==`string`?t.getChild(e):e.length===0?t:t.getChild(e)}static getNearestExistingLogger(e){let t=LoggerImpl.getLogger();for(let n of e){let e=t.children[n],r=e instanceof LoggerImpl?e:e?.deref();if(r==null)break;t=r}return t}constructor(e,t){this.parent=e,this.children={},this.category=t,this.sinks=[],this.filters=[]}get parentSinks(){return this.#e}set parentSinks(e){this.#e!==e&&(this.#e=e)}get lowestLevel(){return this.#t}set lowestLevel(e){this.#t!==e&&(this.#t=e)}getChild(e){let t=typeof e==`string`?e:e[0],n=this.children[t],r=n instanceof LoggerImpl?n:n?.deref();return r??(r=new LoggerImpl(this,[...this.category,t]),this.children[t]=`WeakRef`in globalThis?new WeakRef(r):r),typeof e==`string`||e.length===1?r:r.getChild(e.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`,this.sourceLocationCapture=void 0}resetDescendants(){for(let e of Object.values(this.children))(e instanceof LoggerImpl?e:e.deref())?.resetDescendants();this.reset()}with(e){return new x(this,{...e})}setGlobalSourceLocationCapture(e){_=e}retainScopedSourceLocationCapture(){v++}releaseScopedSourceLocationCapture(){v>0&&v--}captureSourceLocation(e){if(isMetaLoggerCategory(this.category))return;let t=getCategoryPrefix(),n=getCurrentScopedConfig(LoggerImpl.getLogger().contextLocalStorage);if(n!=null){let r=t.length>0?[...t,...this.category]:this.category;if(!scopedConfigHasSink(n,r,e)||!scopedConfigCapturesSourceLocation(n,r))return}else{let n=this.getDispatcher(t);if(n.isCertainlyDroppedResolved(e)||!n.capturesSourceLocation())return}try{return parseSourceLocation((/* @__PURE__ */ Error()).stack,2)}catch{return}}capturesSourceLocation(){return this.sourceLocationCapture==null?this.parent?.capturesSourceLocation()??!1:this.sourceLocationCapture}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){let t=this.getSinkDispatchPlan(e);switch(t.kind){case`none`:return;case`one`:yield t.sink;return;case`many`:yield*t.sinks;return}}getSinkDispatchPlan(e){let t=this.#n[e];if(t!=null&&this.isSinkDispatchPlanFresh(e,t))return t;let n=this.createSinkDispatchPlan(e,this.resolveParentPlan(e));return this.#n[e]=n,n}resolveParentPlan(e){if(this.parent!=null){if(this.parentSinks===`inherit`)return this.parent.getSinkDispatchPlan(e);if(this.parentSinks===`forward`)return this.parent.getForwardSinkPlan()}}isSinkDispatchPlanFresh(e,t){if(t.lowestLevel!==this.lowestLevel||t.parentSinks!==this.parentSinks||t.localSinks.length!==this.sinks.length)return!1;for(let e=0;e<t.localSinks.length;e++)if(t.localSinks[e]!==this.sinks[e])return!1;return t.parentPlan===this.resolveParentPlan(e)}getForwardSinkPlan(){let e=this.#r;if(e!=null&&this.isForwardSinkPlanFresh(e))return e;let t=this.parent!=null&&this.parentSinks!==`override`?this.parent.getForwardSinkPlan():void 0,n=this.createForwardSinkPlan(t);return this.#r=n,n}isForwardSinkPlanFresh(e){if(e.parentSinks!==this.parentSinks||e.localSinks.length!==this.sinks.length)return!1;for(let t=0;t<e.localSinks.length;t++)if(e.localSinks[t]!==this.sinks[t])return!1;let t=this.parent!=null&&this.parentSinks!==`override`?this.parent.getForwardSinkPlan():void 0;return e.parentPlan===t}createForwardSinkPlan(e){let t=[...this.sinks],n=e==null||e.sinks.length<1?t:[...e.sinks,...t];return{kind:`forward`,localSinks:t,parentSinks:this.parentSinks,parentPlan:e,sinks:n}}createSinkDispatchPlan(e,t){let n={localSinks:[...this.sinks],parentSinks:this.parentSinks,lowestLevel:this.lowestLevel,parentPlan:t};if(n.lowestLevel===null||compareLogLevel(e,n.lowestLevel)<0)return{...n,kind:`none`};let r,i,appendSink=e=>{i==null?r==null?r=e:i=[r,e]:i.push(e)};t!=null&&(t.kind===`one`?r=t.sink:t.kind===`many`?i=[...t.sinks]:t.kind===`forward`&&(t.sinks.length===1?r=t.sinks[0]:t.sinks.length>1&&(i=[...t.sinks])));for(let e of n.localSinks)appendSink(e);return i==null?r==null?{...n,kind:`none`}:{...n,kind:`one`,sink:r}:{...n,kind:`many`,sinks:i}}isEnabledFor(e){let t=isMetaLoggerCategory(this.category)?[]:getCategoryPrefix(),n=getCurrentScopedConfig(LoggerImpl.getLogger().contextLocalStorage);return n==null?this.getDispatcher(t).isEnabledForResolved(e):scopedConfigHasSink(n,t.length>0?[...t,...this.category]:this.category,e)}isCertainlyDropped(e){let t=isMetaLoggerCategory(this.category)?[]:getCategoryPrefix(),n=getCurrentScopedConfig(LoggerImpl.getLogger().contextLocalStorage);return n==null?this.getDispatcher(t).isCertainlyDroppedResolved(e):!scopedConfigHasSink(n,t.length>0?[...t,...this.category]:this.category,e)}isCertainlyDroppedResolved(e){return this.lowestLevel===null||compareLogLevel(e,this.lowestLevel)<0||!this.isEnabledForResolved(e)&&!this.hasEffectiveFilters()}getDispatcher(e){return e.length>0?LoggerImpl.getNearestExistingLogger([...e,...this.category]):this}hasEffectiveFilters(){return this.filters.length>0?!0:this.parent?.hasEffectiveFilters()??!1}isEnabledForResolved(e){return this.lowestLevel===null||compareLogLevel(e,this.lowestLevel)<0?!1:this.sinks.length>0?!0:this.parent==null?!1:this.parentSinks===`inherit`?this.parent.isEnabledForResolved(e):this.parentSinks===`forward`&&this.parent.hasForwardSinks()}hasForwardSinks(){return this.sinks.length>0||this.parent!=null&&this.parentSinks!==`override`&&this.parent.hasForwardSinks()}emit(e,t){let n=`category`in e?e.category:this.category,r=isMetaLoggerCategory(n)?[]:getCategoryPrefix(),i=r.length>0?[...r,...n]:n;if(r.length<1&&Object.prototype.hasOwnProperty.call(e,`category`)){this.emitResolved(e,t);return}let a=Object.getOwnPropertyDescriptors(e);a.category={value:i,enumerable:!0,configurable:!0};let o=Object.defineProperties({},a);(r.length>0?LoggerImpl.getNearestExistingLogger(i):this).emitResolved(o,t)}emitResolved(e,t){let n=getCurrentScopedConfig(LoggerImpl.getLogger().contextLocalStorage);if(n!=null){let r,i=!1;emitWithScopedConfig(n,e,t,(t,n)=>{try{if(shouldSnapshotForSink(t))try{r??=snapshotLogRecordProperties(e)}catch{i=!0,r=e}t(r??e)}catch(r){let i=new Set(n);i.add(t),S.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:t,error:r,record:e},i)}i&&(r=e)});return}if(this.lowestLevel===null||compareLogLevel(e.level,this.lowestLevel)<0||!this.filter(e))return;let r=this.getSinkDispatchPlan(e.level);if(r.kind===`none`)return;let i,a=!1;if(r.kind===`one`){let n=r.sink;if(t?.has(n))return;try{if(shouldSnapshotForSink(n))try{i=snapshotLogRecordProperties(e)}catch{a=!0,i=e}n(i??e)}catch(r){let i=new Set(t);i.add(n),S.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:n,error:r,record:e},i)}}else for(let n of r.sinks)if(!t?.has(n))try{if(i==null&&!a&&shouldSnapshotForSink(n))try{i=snapshotLogRecordProperties(e)}catch{a=!0,i=e}n(i??e)}catch(r){let i=new Set(t);i.add(n),S.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:n,error:r,record:e},i)}}log(e,t,n,r,i){if(this.isCertainlyDropped(e))return;let a=getImplicitContextIfAny();if(typeof n!=`function`&&a==null&&!t.includes(`{`)&&!hasEnumerableProperties(n)){let n={category:this.category,level:e,message:[t],rawMessage:t,timestamp:Date.now(),properties:{}};attachSourceLocation(n,i),g.add(n),this.emit(n,r);return}let o,s,c=typeof n==`function`?{category:this.category,level:e,timestamp:Date.now(),get message(){return s??=parseMessageTemplate(t,this.properties),s},rawMessage:t,get properties(){return o??=resolveProperties({...a??{},...n()}),o}}:{category:this.category,level:e,timestamp:Date.now(),get message(){return s??=parseMessageTemplate(t,this.properties),s},rawMessage:t,get properties(){return o??=resolveProperties({...a??{},...n}),o}};attachSourceLocation(c,i),h.add(c),this.emit(c,r)}logLazily(e,t,n={},r){if(this.isCertainlyDropped(e))return;let i=getImplicitContextIfAny(),a,o;function realizeMessage(){if((o==null||a==null)&&(o=t((e,...t)=>(a=e,renderMessage(e,t))),a==null))throw TypeError(`No log record was made.`);return[o,a]}let s={category:this.category,level:e,get message(){return realizeMessage()[0]},get rawMessage(){return realizeMessage()[1]},timestamp:Date.now(),properties:{...i??{},...n}};attachSourceLocation(s,r),this.emit(s)}logTemplate(e,t,n,r={},i){if(this.isCertainlyDropped(e))return;let a=getImplicitContextIfAny(),o={category:this.category,level:e,message:renderMessage(t,n),rawMessage:t,timestamp:Date.now(),properties:{...a??{},...r}};attachSourceLocation(o,i),this.emit(o)}trace(e,...t){let n=isSourceLocationCaptureActive()?this.captureSourceLocation(`trace`):void 0;if(typeof e==`string`)return logStringMessage(this,`trace`,e,t[0],n);typeof e==`function`?this.logLazily(`trace`,e,void 0,n):Array.isArray(e)?this.logTemplate(`trace`,e,t,void 0,n):this.log(`trace`,`{*}`,e,void 0,n)}debug(e,...t){let n=isSourceLocationCaptureActive()?this.captureSourceLocation(`debug`):void 0;if(typeof e==`string`)return logStringMessage(this,`debug`,e,t[0],n);typeof e==`function`?this.logLazily(`debug`,e,void 0,n):Array.isArray(e)?this.logTemplate(`debug`,e,t,void 0,n):this.log(`debug`,`{*}`,e,void 0,n)}info(e,...t){let n=isSourceLocationCaptureActive()?this.captureSourceLocation(`info`):void 0;if(typeof e==`string`)return logStringMessage(this,`info`,e,t[0],n);typeof e==`function`?this.logLazily(`info`,e,void 0,n):Array.isArray(e)?this.logTemplate(`info`,e,t,void 0,n):this.log(`info`,`{*}`,e,void 0,n)}logError(e,t,n,r){if(typeof n!=`function`){this.log(e,`{error.message}`,{...n,error:t},void 0,r);return}if(!this.isEnabledFor(e))return Promise.resolve();let i=n();if(i instanceof Promise)return i.then(n=>{this.log(e,`{error.message}`,{...n,error:t},void 0,r)});this.log(e,`{error.message}`,{...i,error:t},void 0,r)}warn(e,...t){let n=isSourceLocationCaptureActive()?this.captureSourceLocation(`warning`):void 0;if(e instanceof Error)return this.logError(`warning`,e,t[0],n);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]},void 0,n);else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0],n);else typeof e==`function`?this.logLazily(`warning`,e,void 0,n):Array.isArray(e)?this.logTemplate(`warning`,e,t,void 0,n):this.log(`warning`,`{*}`,e,void 0,n)}warning(e,...t){let n=isSourceLocationCaptureActive()?this.captureSourceLocation(`warning`):void 0;if(e instanceof Error)return this.logError(`warning`,e,t[0],n);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]},void 0,n);else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0],n);else typeof e==`function`?this.logLazily(`warning`,e,void 0,n):Array.isArray(e)?this.logTemplate(`warning`,e,t,void 0,n):this.log(`warning`,`{*}`,e,void 0,n)}error(e,...t){let n=isSourceLocationCaptureActive()?this.captureSourceLocation(`error`):void 0;if(e instanceof Error)return this.logError(`error`,e,t[0],n);if(typeof e==`string`&&t[0]instanceof Error)this.log(`error`,e,{error:t[0]},void 0,n);else if(typeof e==`string`)return logStringMessage(this,`error`,e,t[0],n);else typeof e==`function`?this.logLazily(`error`,e,void 0,n):Array.isArray(e)?this.logTemplate(`error`,e,t,void 0,n):this.log(`error`,`{*}`,e,void 0,n)}fatal(e,...t){let n=isSourceLocationCaptureActive()?this.captureSourceLocation(`fatal`):void 0;if(e instanceof Error)return this.logError(`fatal`,e,t[0],n);if(typeof e==`string`&&t[0]instanceof Error)this.log(`fatal`,e,{error:t[0]},void 0,n);else if(typeof e==`string`)return logStringMessage(this,`fatal`,e,t[0],n);else typeof e==`function`?this.logLazily(`fatal`,e,void 0,n):Array.isArray(e)?this.logTemplate(`fatal`,e,t,void 0,n):this.log(`fatal`,`{*}`,e,void 0,n)}},x=class LoggerCtx{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(e){return new LoggerCtx(this.logger,{...this.properties,...e})}log(e,t,n,r,i){if(this.logger.isCertainlyDropped(e))return;let a=this.properties;this.logger.log(e,t,typeof n==`function`?()=>resolveProperties({...a,...n()}):()=>resolveProperties({...a,...n}),r,i)}logLazily(e,t,n){this.logger.isCertainlyDropped(e)||this.logger.logLazily(e,t,resolveProperties(this.properties),n)}logTemplate(e,t,n,r){this.logger.isCertainlyDropped(e)||this.logger.logTemplate(e,t,n,resolveProperties(this.properties),r)}emit(e){let t={...e,properties:resolveProperties({...this.properties,...e.properties})};this.logger.emit(t)}isEnabledFor(e){return this.logger.isEnabledFor(e)}trace(e,...t){let n=isSourceLocationCaptureActive()?this.logger.captureSourceLocation(`trace`):void 0;if(typeof e==`string`)return logStringMessage(this,`trace`,e,t[0],n);typeof e==`function`?this.logLazily(`trace`,e,n):Array.isArray(e)?this.logTemplate(`trace`,e,t,n):this.log(`trace`,`{*}`,e,void 0,n)}debug(e,...t){let n=isSourceLocationCaptureActive()?this.logger.captureSourceLocation(`debug`):void 0;if(typeof e==`string`)return logStringMessage(this,`debug`,e,t[0],n);typeof e==`function`?this.logLazily(`debug`,e,n):Array.isArray(e)?this.logTemplate(`debug`,e,t,n):this.log(`debug`,`{*}`,e,void 0,n)}info(e,...t){let n=isSourceLocationCaptureActive()?this.logger.captureSourceLocation(`info`):void 0;if(typeof e==`string`)return logStringMessage(this,`info`,e,t[0],n);typeof e==`function`?this.logLazily(`info`,e,n):Array.isArray(e)?this.logTemplate(`info`,e,t,n):this.log(`info`,`{*}`,e,void 0,n)}logError(e,t,n,r){if(typeof n!=`function`){this.log(e,`{error.message}`,{...n,error:t},void 0,r);return}if(!this.isEnabledFor(e))return Promise.resolve();let i=n();if(i instanceof Promise)return i.then(n=>{this.log(e,`{error.message}`,{...n,error:t},void 0,r)});this.log(e,`{error.message}`,{...i,error:t},void 0,r)}warn(e,...t){let n=isSourceLocationCaptureActive()?this.logger.captureSourceLocation(`warning`):void 0;if(e instanceof Error)return this.logError(`warning`,e,t[0],n);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]},void 0,n);else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0],n);else typeof e==`function`?this.logLazily(`warning`,e,n):Array.isArray(e)?this.logTemplate(`warning`,e,t,n):this.log(`warning`,`{*}`,e,void 0,n)}warning(e,...t){let n=isSourceLocationCaptureActive()?this.logger.captureSourceLocation(`warning`):void 0;if(e instanceof Error)return this.logError(`warning`,e,t[0],n);if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]},void 0,n);else if(typeof e==`string`)return logStringMessage(this,`warning`,e,t[0],n);else typeof e==`function`?this.logLazily(`warning`,e,n):Array.isArray(e)?this.logTemplate(`warning`,e,t,n):this.log(`warning`,`{*}`,e,void 0,n)}error(e,...t){let n=isSourceLocationCaptureActive()?this.logger.captureSourceLocation(`error`):void 0;if(e instanceof Error)return this.logError(`error`,e,t[0],n);if(typeof e==`string`&&t[0]instanceof Error)this.log(`error`,e,{error:t[0]},void 0,n);else if(typeof e==`string`)return logStringMessage(this,`error`,e,t[0],n);else typeof e==`function`?this.logLazily(`error`,e,n):Array.isArray(e)?this.logTemplate(`error`,e,t,n):this.log(`error`,`{*}`,e,void 0,n)}fatal(e,...t){let n=isSourceLocationCaptureActive()?this.logger.captureSourceLocation(`fatal`):void 0;if(e instanceof Error)return this.logError(`fatal`,e,t[0],n);if(typeof e==`string`&&t[0]instanceof Error)this.log(`fatal`,e,{error:t[0]},void 0,n);else if(typeof e==`string`)return logStringMessage(this,`fatal`,e,t[0],n);else typeof e==`function`?this.logLazily(`fatal`,e,n):Array.isArray(e)?this.logTemplate(`fatal`,e,t,n):this.log(`fatal`,`{*}`,e,void 0,n)}};const S=b.getLogger([`logtape`,`meta`]);function isNestedAccess(e){return e.includes(`.`)||e.includes(`[`)||e.includes(`?.`)}function getOwnProperty(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 parseNextSegment(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+=`
3
+ `;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 accessProperty(e,t){if(typeof t==`string`)return getOwnProperty(e,t);if(Array.isArray(e)&&t>=0&&t<e.length)return e[t]}function resolvePropertyPath(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=parseNextSegment(t,r);if(e===null)return;let{segment:i,nextIndex:a}=e;if(r=a,n=accessProperty(n,i),n===void 0)return}return n}function parseMessageTemplate(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&&isNestedAccess(u)&&(l=resolvePropertyPath(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 renderMessage(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 C=Symbol.for(`logtape.categoryPrefix`);function getCategoryPrefix(){let e=b.getLogger().contextLocalStorage?.getStore();if(e==null)return[];let t=e[C];return Array.isArray(t)?t:[]}function getImplicitContextIfAny(){let e=b.getLogger().contextLocalStorage?.getStore();if(e==null)return;let t=Object.keys(e);if(t.length<1)return;let n={};for(let r of t)n[r]=e[r];return n}function escapeChar(e){return e===10?`\\n`:e===13?`\\r`:e===27?`\\x1b`:`\\x${e.toString(16).padStart(2,`0`)}`}function isDangerous(e,t){return e===9?!1:e===10||e===13?t:e<32||e===127||e>=128&&e<=159}const w=/^\x1b\[([0-9;:]*)m/;function sanitizeControlSequences(e,t={}){let n=t.sgr!==`escape`,r=t.newlines===`escape`,i=!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n===27||isDangerous(n,r)){i=!0;break}}if(!i)return e;let a=``,o=0,s=!1;for(;o<e.length;){let t=e.charCodeAt(o);if(t===27){if(n){let t=w.exec(e.slice(o));if(t!=null){a+=t[0],s=!isSgrReset(t[1]),o+=t[0].length;continue}}a+=escapeChar(27),o++}else isDangerous(t,r)?(a+=escapeChar(t),o++):(a+=e[o],o++)}return s?a+`\x1B[0m`:a}function isSgrReset(e){return/^0*$/.test(e.replace(/[;:]/g,``))}function getSanitizer(e){if(e===!1)return null;let t=e??{};return e=>sanitizeControlSequences(e,t)}function createCircularReplacer(e){let t=[],n=[];return function(r,i){let a=e===void 0?i:e.call(this,r,i);if(typeof a!=`object`||!a)return a;for(;n.length>0&&n[n.length-1]!==this;)n.pop(),t.pop();for(let e=0;e<n.length;e++)if(n[e]===a||t[e]===i)return`[Circular]`;return t.push(i),n.push(a),a}}function stringifyWithoutCycles(e,t,n){try{return JSON.stringify(e,t,n)}catch{return JSON.stringify(e,createCircularReplacer(t),n)}}var T=/* @__PURE__ */ t({inspect:()=>inspect$1});function inspect$1(e,t){return n.inspect(e,t)}e(inspect$1,`inspect`);const E={trace:`TRC`,debug:`DBG`,info:`INF`,warning:`WRN`,error:`ERR`,fatal:`FTL`},D=typeof document<`u`||typeof navigator<`u`&&navigator.product===`ReactNative`?e=>stringifyWithoutCycles(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}):T!=null&&`inspect`in T&&typeof inspect$1==`function`?(e,t)=>inspect$1(e,{maxArrayLength:1/0,maxStringLength:1/0,...t}):e=>stringifyWithoutCycles(e),inspect=(e,t)=>String(D(e,t)),O=new TextEncoder;function getValueRenderer(e,t,n){if(e==null)return n;if(typeof e==`function`)return t=>e(t,inspect);if(e!==`bare`)throw TypeError(`Invalid value option: ${JSON.stringify(e)}. It must be "bare" or a function.`);let r=t===!1?null:getSanitizer({sgr:`escape`,newlines:t?.newlines??`escape`});return r==null?e=>typeof e==`string`?e:n(e):e=>typeof e==`string`?r(e):n(e)}function renderMessageParts(e,t,n){let r=e.length,i=n==null?e=>e:e=>n(e);if(r===1)return i(e[0]);if(r<=6){let n=``;for(let a=0;a<r;a++)n+=a%2==0?i(e[a]):t(e[a]);return n}let a=Array(r);for(let n=0;n<r;n++)a[n]=n%2==0?i(e[n]):t(e[n]);return a.join(``)}function padZero(e){return e<10?`0${e}`:`${e}`}function padThree(e){return e<10?`00${e}`:e<100?`0${e}`:`${e}`}const k=/^([+-])(0\d|1\d|2[0-3]):([0-5]\d)$/;function formatOffset(e,t){let n=e<0?`-`:`+`,r=Math.abs(e),i=padZero(Math.floor(r/60)),a=padZero(r%60);return!t&&a===`00`?`${n}${i}`:`${n}${i}:${a}`}function readPartsFromFormatter(e,t){let n=e.formatToParts(new Date(t)),r=``,i=``,a=``,o=``,s=``,c=``;for(let e of n)e.type===`year`?r=e.value:e.type===`month`?i=e.value:e.type===`day`?a=e.value:e.type===`hour`?o=e.value:e.type===`minute`?s=e.value:e.type===`second`&&(c=e.value);return{year:r,month:i,day:a,hour:o,minute:s,second:c}}function getDateParts(e,t){let n=new Date(e),r=padThree(n.getUTCMilliseconds());if(t.kind===`utc`)return{year:`${n.getUTCFullYear()}`,month:padZero(n.getUTCMonth()+1),day:padZero(n.getUTCDate()),hour:padZero(n.getUTCHours()),minute:padZero(n.getUTCMinutes()),second:padZero(n.getUTCSeconds()),ms:r,offsetMinutes:0};if(t.kind===`local`)return{year:`${n.getFullYear()}`,month:padZero(n.getMonth()+1),day:padZero(n.getDate()),hour:padZero(n.getHours()),minute:padZero(n.getMinutes()),second:padZero(n.getSeconds()),ms:r,offsetMinutes:-n.getTimezoneOffset()};if(t.kind===`offset`){let n=new Date(e+t.minutes*6e4);return{year:`${n.getUTCFullYear()}`,month:padZero(n.getUTCMonth()+1),day:padZero(n.getUTCDate()),hour:padZero(n.getUTCHours()),minute:padZero(n.getUTCMinutes()),second:padZero(n.getUTCSeconds()),ms:r,offsetMinutes:t.minutes}}let i=readPartsFromFormatter(t.formatter,e),a=Date.UTC(Number(i.year),Number(i.month)-1,Number(i.day),Number(i.hour),Number(i.minute),Number(i.second),n.getUTCMilliseconds()),o=Math.round((a-e)/6e4);return{...i,ms:r,offsetMinutes:o}}function resolveTimeZone(e){if(e===void 0)return{kind:`utc`};if(e===null)return{kind:`local`};let t=k.exec(e);if(t!=null){let e=t[1]===`-`?-1:1,n=Number(t[2]),r=Number(t[3]);return{kind:`offset`,minutes:e*(n*60+r)}}if(typeof Intl>`u`||typeof Intl.DateTimeFormat!=`function`)throw TypeError(`Invalid timeZone option: ${JSON.stringify(e)}. This environment does not support IANA time zones.`);try{return{kind:`iana`,formatter:new Intl.DateTimeFormat(`en-CA`,{timeZone:e,hour12:!1,hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}}catch{throw TypeError(`Invalid timeZone option: ${JSON.stringify(e)}. Expected an IANA time zone name (e.g., "Asia/Seoul") or a fixed UTC offset string (e.g., "+09:00").`)}}function createTimestampFormatter(e,t){return e===`none`?()=>null:e===`rfc3339`&&t.kind===`utc`?e=>new Date(e).toISOString():n=>{let r=getDateParts(n,t),i=`${r.year}-${r.month}-${r.day}`,a=`${r.hour}:${r.minute}:${r.second}.${r.ms}`,o=formatOffset(r.offsetMinutes,!0),s=formatOffset(r.offsetMinutes,!1);return e===`date-time-timezone`?`${i} ${a} ${o}`:e===`date-time-tz`?`${i} ${a} ${s}`:e===`date-time`?`${i} ${a}`:e===`time-timezone`?`${a} ${o}`:e===`time-tz`?`${a} ${s}`:e===`time`?a:e===`date`?i:`${i}T${a}${o}`}}const A={ABBR:E,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 getLineEndingValue(e){return e===`crlf`?`\r
3
4
  `:`
4
- `}function jsonReplacer(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 getTextFormatter(e={}){let t=(()=>{let t=e.timestamp,n=resolveTimeZone(e.timeZone);return t==null?createTimestampFormatter(`date-time-timezone`,n):t===`disabled`?createTimestampFormatter(`none`,n):typeof t==`string`&&(t===`date-time-timezone`||t===`date-time-tz`||t===`date-time`||t===`time-timezone`||t===`time-tz`||t===`time`||t===`date`||t===`rfc3339`||t===`none`)?createTimestampFormatter(t,n):t})(),n=e.category??`·`,r=e.value?t=>e.value(t,inspect):inspect,i=(()=>{let t=e.level;return t==null||t===`ABBR`?e=>g.ABBR[e]:t===`abbr`?e=>g.abbr[e]:t===`FULL`?e=>g.FULL[e]:t===`full`?e=>g.full[e]:t===`L`?e=>g.L[e]:t===`l`?e=>g.l[e]:t})(),a=getLineEndingValue(e.lineEnding),o=e.format??(({timestamp:e,level:t,category:n,message:r})=>`${e?`${e} `:``}[${t}] ${n}: ${r}`);return e=>{let s=renderMessageParts(e.message,r),c={timestamp:t(e.timestamp),level:i(e.level),category:typeof n==`function`?n(e.category):e.category.join(n),message:s,record:e};return`${o(c)}${a}`}}getTextFormatter();const _=`\x1B[0m`,v={black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`},y={bold:`\x1B[1m`,dim:`\x1B[2m`,italic:`\x1B[3m`,underline:`\x1B[4m`,strikethrough:`\x1B[9m`},b={trace:null,debug:`blue`,info:`green`,warning:`yellow`,error:`red`,fatal:`magenta`};function getAnsiColorFormatter(e={}){let t=e.format,n=e.timestampStyle===void 0?`dim`:e.timestampStyle,r=e.timestampColor??null,i=`${n==null?``:y[n]}${r==null?``:v[r]}`,a=n==null&&r==null?``:_,o=e.levelStyle===void 0?`bold`:e.levelStyle,s=e.levelColors??b,c=e.categoryStyle===void 0?`dim`:e.categoryStyle,l=e.categoryColor??null,u=`${c==null?``:y[c]}${l==null?``:v[l]}`,d=c==null&&l==null?``:_;return getTextFormatter({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?``:y[o]}${f==null?``:v[f]}${n}${o==null&&f==null?``:_}`,t==null?`${e==null?``:`${e} `}${n} ${u}${r}:${d} ${c}`:t({timestamp:e,level:n,category:`${u}${r}${d}`,message:c,record:l})}})}getAnsiColorFormatter();function getJsonLinesFormatter(e={}){let t=getLineEndingValue(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},jsonReplacer)+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},jsonReplacer)+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},jsonReplacer)+t};let n=e.message===`template`,r=e.properties??`nest:properties`,joinCategory;if(typeof e.categorySeparator==`function`)joinCategory=e.categorySeparator;else{let t=e.categorySeparator??`.`;joinCategory=e=>e.join(t)}let getProperties;if(r===`flatten`)getProperties=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.`);getProperties=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);getProperties=t=>({[e]:t})}else throw TypeError(`Invalid properties option: ${JSON.stringify(r)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let i;return i=n?e=>{if(typeof e.rawMessage==`string`)return e.rawMessage;let t=``;for(let n=0;n<e.rawMessage.length;n++)n>0&&(t+=`{}`),t+=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:i(e),logger:joinCategory(e.category),...getProperties(e.properties)},jsonReplacer)+t}getJsonLinesFormatter();function renderStructuredMessage(e,t){return t?typeof e.rawMessage==`string`?e.rawMessage:e.rawMessage.join(`{}`):renderMessageParts(e.message,stringifyLogfmtValue)}function filterLogfmtKey(e){if(e===``)return null;let t=!1;for(let n of e)if(shouldEscapeLogfmtKeyChar(n,n.codePointAt(0))){t=!0;break}if(!t)return e;let n=``;for(let t of e)shouldEscapeLogfmtKeyChar(t,t.codePointAt(0))?n+=encodeLogfmtKeyChar(t):n+=t;return n}function shouldEscapeLogfmtKeyChar(e,t){return t<=32||t===127||t===65533||e===`=`||e===`"`||e===`%`}function encodeLogfmtKeyChar(e){let t=``;for(let n of m.encode(e))t+=`%${n.toString(16).toUpperCase().padStart(2,`0`)}`;return t}function stringifyLogfmtValue(e){if(typeof e==`string`)return e;if(e===null)return`null`;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||e===void 0||typeof e==`symbol`||typeof e==`function`)return String(e);try{let t=JSON.stringify(e,jsonReplacer);if(typeof t==`string`)return unwrapJsonStringLiteral(t)}catch{}return inspect(e,{colors:!1})}function unwrapJsonStringLiteral(e){return e.startsWith(`"`)&&e.endsWith(`"`)?JSON.parse(e):e}function quoteLogfmtValue(e,t){let n=e===``||t&&shouldQuoteStringLiteral(e);for(let t of e)if(shouldQuoteLogfmtValueChar(t,t.codePointAt(0))){n=!0;break}if(!n)return e;let r=``;for(let t of e){let e=t.codePointAt(0);r+=escapeLogfmtValueChar(t,e)}return`"${r}"`}function shouldQuoteStringLiteral(e){return e===`null`||e===`undefined`||e===`true`||e===`false`}function shouldQuoteLogfmtValueChar(e,t){return t<=32||t===127||t===65533||e===`=`||e===`"`||e===`\\`}function escapeLogfmtValueChar(e,t){switch(e){case` `:return`\\t`;case`
5
- `:return`\\n`;case`\r`:return`\\r`;case`"`:return`\\"`;case`\\`:return`\\\\`;default:return t<=31||t===127?`\\u${t.toString(16).padStart(4,`0`)}`:e}}function formatLogfmtValue(e){return quoteLogfmtValue(stringifyLogfmtValue(e),typeof e==`string`)}function pushLogfmtPair(e,t,n){let r=filterLogfmtKey(t);r!=null&&e.push(`${r}=${formatLogfmtValue(n)}`)}function getLogfmtFormatter(e={}){let t=getLineEndingValue(e.lineEnding),n=createTimestampFormatter(`rfc3339`,resolveTimeZone(e.timeZone)),r=e.message===`template`,i=e.properties??`flatten`,joinCategory;if(typeof e.categorySeparator==`function`)joinCategory=e.categorySeparator;else{let t=e.categorySeparator??`.`;joinCategory=e=>e.join(t)}let a=``;if(i===`flatten`)a=``;else if(i.startsWith(`prepend:`)){if(a=i.substring(8),a===``)throw TypeError(`Invalid properties option: `+JSON.stringify(i)+`. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`)}else throw TypeError(`Invalid properties option: ${JSON.stringify(i)}. It must be "flatten" or "prepend:<prefix>".`);return e=>{let i=[];pushLogfmtPair(i,`time`,n(e.timestamp)),pushLogfmtPair(i,`level`,e.level),pushLogfmtPair(i,`logger`,joinCategory(e.category)),pushLogfmtPair(i,`msg`,renderStructuredMessage(e,r));for(let t in e.properties)Object.prototype.hasOwnProperty.call(e.properties,t)&&pushLogfmtPair(i,`${a}${t}`,e.properties[t]);return`${i.join(` `)}${t}`}}getLogfmtFormatter();const x={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 defaultConsoleFormatter(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${f[e.level]}%c %c${e.category.join(`·`)} %c${t}`,`color: gray;`,x[e.level],`background-color: default;`,`color: gray;`,`color: default;`,...n]}function getConsoleSink(e={}){let t=e.formatter??defaultConsoleFormatter,n={trace:`debug`,debug:`debug`,info:`info`,warning:`warn`,error:`error`,fatal:`error`,...e.levelMap??{}},r=e.console??globalThis.console,baseSink=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 baseSink;let i=e.nonBlocking===!0?{}:e.nonBlocking,a=i.bufferSize??100,o=i.flushInterval??100,s=[],c=null,l=!1,u=!1,d=a*2;function flush(){if(s.length===0)return;let e=s.splice(0);for(let t of e)try{baseSink(t)}catch{}}function scheduleFlush(){u||(u=!0,setTimeout(()=>{u=!1,flush()},0))}function startFlushTimer(){c!==null||l||(c=setInterval(()=>{flush()},o))}let nonBlockingSink=e=>{l||(s.length>=d&&s.shift(),s.push(e),s.length>=a?scheduleFlush():c===null&&startFlushTimer())};return nonBlockingSink[Symbol.dispose]=()=>{l=!0,c!==null&&(clearInterval(c),c=null),flush()},nonBlockingSink}let S=null;const C=new Set,w=new Set,T=new Set,E=new Set,D=new Set;function isLoggerConfigMeta(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 registerDisposeHook(e){let t=e?dispose:disposeSync;if(typeof globalThis.EdgeRuntime!=`string`&&`process`in globalThis&&!(`Deno`in globalThis)){let e=globalThis.process,n=e?.on;if(typeof n==`function`){n.call(e,`exit`,t);return}}let n=globalThis.addEventListener;typeof n==`function`&&(`Deno`in globalThis?n.call(globalThis,`unload`,t):n.call(globalThis,`pagehide`,t))}function configureSync(e){if(S!=null&&!e.reset)throw new ConfigError(`Already configured; if you want to reset, turn on the reset flag.`);if(E.size>0||D.size>0)throw new ConfigError(`Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().`);resetSync();try{configureInternal(e,!1)}catch(e){throw e instanceof ConfigError&&resetSync(),e}}function configureInternal(e,t){S=e;let n=!1,r=new Set;for(let t of e.loggers){isLoggerConfigMeta(t)&&(n=!0);let i=Array.isArray(t.category)?JSON.stringify(t.category):JSON.stringify([t.category]);if(r.has(i))throw new ConfigError(`Duplicate logger configuration for category: ${i}. Each category can only be configured once.`);r.add(i);let a=s.getLogger(t.category);for(let n of t.sinks??[]){let t=e.sinks[n];if(!t)throw new ConfigError(`Sink not found: ${n}.`);a.sinks.push(t)}a.parentSinks=t.parentSinks??`inherit`,t.lowestLevel!==void 0&&(a.lowestLevel=t.lowestLevel);for(let n of t.filters??[]){let t=e.filters?.[n];if(t===void 0)throw new ConfigError(`Filter not found: ${n}.`);a.filters.push(toFilter(t))}C.add(a)}s.getLogger().contextLocalStorage=e.contextLocalStorage;for(let n of Object.values(e.sinks)){if(Symbol.asyncDispose in n){if(t)D.add(n);else throw new ConfigError(`Async disposables cannot be used with configureSync().`)}Symbol.dispose in n&&T.add(n)}for(let n of Object.values(e.filters??{}))if(n!=null&&typeof n!=`string`){if(Symbol.asyncDispose in n){if(t)E.add(n);else throw new ConfigError(`Async disposables cannot be used with configureSync().`);D.delete(n)}Symbol.dispose in n&&(w.add(n),T.delete(n))}registerDisposeHook(t);let i=s.getLogger([`logtape`,`meta`]);n||i.sinks.push(getConsoleSink()),i.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 resetSync(){disposeSync(),resetInternal()}function resetInternal(){let e=s.getLogger([]);e.resetDescendants(),delete e.contextLocalStorage,C.clear(),S=null}async function dispose(){let e=[];try{disposeSyncFilters()}catch(t){e.push(t)}try{await disposeAsyncFilters()}catch(t){e.push(t)}try{disposeSyncSinks()}catch(t){e.push(t)}try{await disposeAsyncSinks()}catch(t){e.push(t)}throwDisposeErrors(e)}function disposeSync(){let e=[];try{disposeSyncFilters()}catch(t){e.push(t)}try{disposeSyncSinks()}catch(t){e.push(t)}throwDisposeErrors(e)}function disposeSyncFilters(){disposeSyncDisposables(w)}function disposeSyncSinks(){disposeSyncDisposables(T)}function disposeSyncDisposables(e){let t=[];try{for(let n of e)try{n[Symbol.dispose]()}catch(e){t.push(e)}finally{e.delete(n)}}finally{e.clear()}throwDisposeErrors(t)}async function disposeAsyncFilters(){await disposeAsyncDisposables(E)}async function disposeAsyncSinks(){await disposeAsyncDisposables(D)}async function disposeAsyncDisposables(e){let t=[];try{for(let n of e)try{t.push(Promise.resolve(n[Symbol.asyncDispose]()))}catch(e){t.push(Promise.reject(e))}finally{e.delete(n)}}finally{e.clear()}await settleDisposePromises(t)}async function settleDisposePromises(e){throwDisposeErrors((await Promise.allSettled(e)).filter(e=>e.status===`rejected`).map(e=>e.reason))}function throwDisposeErrors(e){if(!(e.length<1))throw e.length===1?e[0]:AggregateError(e,`Multiple errors occurred while disposing LogTape resources.`)}var ConfigError=class extends Error{constructor(e){super(e),this.name=`ConfigureError`}};export{getLogger as a,getTextFormatter as i,getConsoleSink as n,getAnsiColorFormatter as r,configureSync as t};
5
+ `}const j=/[\u007f-\u009f]/g;function escapeJsonControlChars(e){return e.replace(j,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function jsonReplacer(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 renderDefaultJsonLinesMessage(e){let t=e.length;if(t===1)return e[0];if(t===3)return e[0]+stringifyWithoutCycles(e[1])+e[2];let n=e[0];for(let r=1;r<t;r++)n+=r&1?stringifyWithoutCycles(e[r]):e[r];return n}function stringifyJsonLinesField(e,t){if(t!=null&&(typeof t==`object`||typeof t==`function`||typeof t==`bigint`)){let n=t.toJSON;typeof n==`function`&&(t=n.call(t,e))}return JSON.stringify(jsonReplacer(e,t),createCircularReplacer(jsonReplacer))}function formatDefaultJsonLinesRecord(e,t){let n=e.level===`warning`?`WARN`:e.level.toUpperCase(),r=stringifyJsonLinesField(`message`,renderDefaultJsonLinesMessage(e.message)),i=stringifyJsonLinesField(`properties`,e.properties),a=`{"@timestamp":${JSON.stringify(new Date(e.timestamp).toISOString())},"level":${JSON.stringify(n)}`;return r!==void 0&&(a+=`,"message":${r}`),a+=`,"logger":${JSON.stringify(e.category.join(`.`))}`,i!==void 0&&(a+=`,"properties":${i}`),escapeJsonControlChars(`${a}}`)+t}function getTextFormatter(e={}){let t=(()=>{let t=e.timestamp,n=resolveTimeZone(e.timeZone);return t==null?createTimestampFormatter(`date-time-timezone`,n):t===`disabled`?createTimestampFormatter(`none`,n):typeof t==`string`&&(t===`date-time-timezone`||t===`date-time-tz`||t===`date-time`||t===`time-timezone`||t===`time-tz`||t===`time`||t===`date`||t===`rfc3339`||t===`none`)?createTimestampFormatter(t,n):t})(),n=e.category??`·`,r=getSanitizer(e.sanitize),i=getSanitizer(e.sanitize!==!1&&{...e.sanitize,sgr:`escape`}),a=getValueRenderer(e.value,e.sanitize,inspect),o=(()=>{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})(),s=getLineEndingValue(e.lineEnding),c=getSourceLocationRenderer(e.sourceLocation,e.sanitize===!1?null:getSanitizer({...e.sanitize,sgr:`escape`,newlines:`escape`})),l=e.format??(({timestamp:e,level:t,category:n,message:r,sourceLocation:i})=>`${e?`${e} `:``}[${t}] ${n}${i==null?``:` (${i})`}: ${r}`);return e=>{let u=renderMessageParts(e.message,a,r),d=t(e.timestamp),f=o(e.level),p=i==null?e.category:e.category.map(i),m={timestamp:d,level:f,category:typeof n==`function`?n(p):p.join(n),message:u,record:e};return c!=null&&(m.sourceLocation=e.sourceLocation==null?null:c(e.sourceLocation)),`${l(m)}${s}`}}function getSourceLocationRenderer(e,t){if(e==null||e===!1)return null;let n=e===!0?e=>`${e.file}:${e.line}:${e.column}`:e;return t==null?n:e=>t(n(e))}getTextFormatter();const M=`\x1B[0m`,N={black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`},P={bold:`\x1B[1m`,dim:`\x1B[2m`,italic:`\x1B[3m`,underline:`\x1B[4m`,strikethrough:`\x1B[9m`},F={trace:null,debug:`blue`,info:`green`,warning:`yellow`,error:`red`,fatal:`magenta`};function getAnsiColorFormatter(e={}){let t=e.format,n=e.timestampStyle===void 0?`dim`:e.timestampStyle,r=e.timestampColor??null,i=`${n==null?``:P[n]}${r==null?``:N[r]}`,a=n==null&&r==null?``:M,o=e.levelStyle===void 0?`bold`:e.levelStyle,s=e.levelColors??F,c=e.categoryStyle===void 0?`dim`:e.categoryStyle,l=e.categoryColor??null,u=`${c==null?``:P[c]}${l==null?``:N[l]}`,d=c==null&&l==null?``:M;return getTextFormatter({timestamp:`date-time-tz`,value(e,t){return t(e,{colors:!0})},...e,...e.value===`bare`?{value:getValueRenderer(`bare`,e.sanitize,e=>inspect(e,{colors:!0}))}:{},format({timestamp:e,level:n,category:r,message:c,sourceLocation:l,record:f}){let p=s[f.level];if(e=e==null?null:`${i}${e}${a}`,n=`${o==null?``:P[o]}${p==null?``:N[p]}${n}${o==null&&p==null?``:M}`,t==null)return`${e==null?``:`${e} `}${n} ${u}${r}${l==null?``:` (${l})`}:${d} ${c}`;let m={timestamp:e,level:n,category:`${u}${r}${d}`,message:c,record:f};return l!==void 0&&(m.sourceLocation=l==null?null:`${u}${l}${d}`),t(m)}})}getAnsiColorFormatter();function getJsonLinesFormatter(e={}){let t=getLineEndingValue(e.lineEnding);if(!e.categorySeparator&&!e.message&&!e.properties)return e=>formatDefaultJsonLinesRecord(e,t);let n=e.message===`template`,r=e.properties??`nest:properties`,joinCategory;if(typeof e.categorySeparator==`function`)joinCategory=e.categorySeparator;else{let t=e.categorySeparator??`.`;joinCategory=e=>e.join(t)}let getProperties;if(r===`flatten`)getProperties=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.`);getProperties=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);getProperties=t=>({[e]:t})}else throw TypeError(`Invalid properties option: ${JSON.stringify(r)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let i;return i=n?e=>{if(typeof e.rawMessage==`string`)return e.rawMessage;let t=``;for(let n=0;n<e.rawMessage.length;n++)n>0&&(t+=`{}`),t+=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]:stringifyWithoutCycles(e.message[r]);return n},e=>escapeJsonControlChars(JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:i(e),logger:joinCategory(e.category),...getProperties(e.properties)},createCircularReplacer(jsonReplacer)))+t}getJsonLinesFormatter();function renderStructuredMessage(e,t){return t?typeof e.rawMessage==`string`?e.rawMessage:e.rawMessage.join(`{}`):renderMessageParts(e.message,stringifyLogfmtValue)}function filterLogfmtKey(e){if(e===``)return null;let t=!1;for(let n of e)if(shouldEscapeLogfmtKeyChar(n,n.codePointAt(0))){t=!0;break}if(!t)return e;let n=``;for(let t of e)shouldEscapeLogfmtKeyChar(t,t.codePointAt(0))?n+=encodeLogfmtKeyChar(t):n+=t;return n}function isTerminalControlCode(e){return e===127||e>=128&&e<=159}function shouldEscapeLogfmtKeyChar(e,t){return t<=32||isTerminalControlCode(t)||t===65533||e===`=`||e===`"`||e===`%`}function encodeLogfmtKeyChar(e){let t=``;for(let n of O.encode(e))t+=`%${n.toString(16).toUpperCase().padStart(2,`0`)}`;return t}function stringifyLogfmtValue(e){if(typeof e==`string`)return e;if(e===null)return`null`;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||e===void 0||typeof e==`symbol`||typeof e==`function`)return String(e);try{let t=JSON.stringify(e,jsonReplacer);if(typeof t==`string`)return unwrapJsonStringLiteral(t)}catch{}return inspect(e,{colors:!1})}function unwrapJsonStringLiteral(e){return e.startsWith(`"`)&&e.endsWith(`"`)?JSON.parse(e):e}function quoteLogfmtValue(e,t){let n=e===``||t&&shouldQuoteStringLiteral(e);for(let t of e)if(shouldQuoteLogfmtValueChar(t,t.codePointAt(0))){n=!0;break}if(!n)return e;let r=``;for(let t of e){let e=t.codePointAt(0);r+=escapeLogfmtValueChar(t,e)}return`"${r}"`}function shouldQuoteStringLiteral(e){return e===`null`||e===`undefined`||e===`true`||e===`false`}function shouldQuoteLogfmtValueChar(e,t){return t<=32||isTerminalControlCode(t)||t===65533||e===`=`||e===`"`||e===`\\`}function escapeLogfmtValueChar(e,t){switch(e){case` `:return`\\t`;case`
6
+ `:return`\\n`;case`\r`:return`\\r`;case`"`:return`\\"`;case`\\`:return`\\\\`;default:return t<=31||isTerminalControlCode(t)?`\\u${t.toString(16).padStart(4,`0`)}`:e}}function formatLogfmtValue(e){return quoteLogfmtValue(stringifyLogfmtValue(e),typeof e==`string`)}function pushLogfmtPair(e,t,n){let r=filterLogfmtKey(t);r!=null&&e.push(`${r}=${formatLogfmtValue(n)}`)}function getLogfmtFormatter(e={}){let t=getLineEndingValue(e.lineEnding),n=createTimestampFormatter(`rfc3339`,resolveTimeZone(e.timeZone)),r=e.message===`template`,i=e.properties??`flatten`,joinCategory;if(typeof e.categorySeparator==`function`)joinCategory=e.categorySeparator;else{let t=e.categorySeparator??`.`;joinCategory=e=>e.join(t)}let a=``;if(i===`flatten`)a=``;else if(i.startsWith(`prepend:`)){if(a=i.substring(8),a===``)throw TypeError(`Invalid properties option: `+JSON.stringify(i)+`. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`)}else throw TypeError(`Invalid properties option: ${JSON.stringify(i)}. It must be "flatten" or "prepend:<prefix>".`);return e=>{let i=[];pushLogfmtPair(i,`time`,n(e.timestamp)),pushLogfmtPair(i,`level`,e.level),pushLogfmtPair(i,`logger`,joinCategory(e.category)),pushLogfmtPair(i,`msg`,renderStructuredMessage(e,r));for(let t in e.properties)Object.prototype.hasOwnProperty.call(e.properties,t)&&pushLogfmtPair(i,`${a}${t}`,e.properties[t]);return`${i.join(` `)}${t}`}}getLogfmtFormatter();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 defaultConsoleFormatter(e){return formatConsoleRecord(e,void 0)}function formatConsoleRecord(e,t){let n=``,r=[];for(let t=0;t<e.message.length;t++)t%2==0?n+=sanitizeControlSequences(e.message[t]):(n+=`%o`,r.push(e.message[t]));let i=new Date(e.timestamp),a=`${i.getUTCHours().toString().padStart(2,`0`)}:${i.getUTCMinutes().toString().padStart(2,`0`)}:${i.getUTCSeconds().toString().padStart(2,`0`)}.${i.getUTCMilliseconds().toString().padStart(3,`0`)}`,o=e.category.map(e=>sanitizeControlSequences(e,{sgr:`escape`})).join(`·`);return t==null?[`%c${a} %c${E[e.level]}%c %c${o} %c${n}`,`color: gray;`,I[e.level],`background-color: default;`,`color: gray;`,`color: default;`,...r]:[`%c${a} %c${E[e.level]}%c %c${o} (%s) %c${n}`,`color: gray;`,I[e.level],`background-color: default;`,`color: gray;`,t,`color: default;`,...r]}function createSinkNotifications(e,t,n,r){let i=0,a=0,o=null;function notify(e,t){i++;try{let n=e(t);n!=null&&Promise.resolve(n).catch(()=>{})}catch{}finally{i--}}function reportDrops(){let e=a;a=0,e>0&&n!=null&&notify(n,{count:e,reason:`overflow`})}return{get notifying(){return i>0},drop(){n!=null&&(a++,o??=setTimeout(()=>{o=null,reportDrops()},t))},error(t,n,i=!1){if(r==null)return;let a={error:t,sink:e,operation:n};i?queueMicrotask(()=>notify(r,a)):notify(r,a)},dispose(){o!=null&&(clearTimeout(o),o=null),reportDrops()}}}function getConsoleSink(e={}){let t=e.formatter??defaultConsoleFormatter,n={trace:`debug`,debug:`debug`,info:`info`,warning:`warn`,error:`error`,fatal:`error`,...e.levelMap??{}},r=e.console??globalThis.console,writeToConsole=(e,t)=>{let i=n[e.level];if(i===void 0)throw TypeError(`Invalid log level: ${e.level}.`);if(typeof t==`string`){let e=t.replace(/\r?\n$/,``);r[i](e)}else r[i](...t)},baseSink=e=>{writeToConsole(e,t(e))};if(!e.nonBlocking)return baseSink;let i=e.nonBlocking===!0?{}:e.nonBlocking,a=i.bufferSize??100,o=i.flushInterval??100,s=createSinkNotifications(`console`,o,i.onDrop,i.onError),c=[],l=null,u=null,d=!1,f=!1,p=a*2;function flush(){if(c.length===0)return;let e=c.splice(0);for(let n of e){let e=`format`;try{let r=t(n);e=`write`,writeToConsole(n,r)}catch(t){s.error(t,e)}}}function scheduleFlush(){f||(f=!0,u=setTimeout(()=>{u=null,f=!1,flush()},0))}function startFlushTimer(){l!==null||d||(l=setInterval(()=>{flush()},o))}let nonBlockingSink=e=>{d||s.notifying||(c.length>=p&&c.length>0&&(c.shift(),s.drop()),c.push(e),c.length>=a?scheduleFlush():l===null&&startFlushTimer())};return nonBlockingSink[Symbol.dispose]=()=>{d||(d=!0,l!==null&&(clearInterval(l),l=null),u!==null&&(clearTimeout(u),u=null,f=!1),s.dispose(),flush())},nonBlockingSink}let L=null,R=!1;const z=/* @__PURE__ */ new Set,B=/* @__PURE__ */ new Set,V=Symbol.for(`logtape.inspectionState`);function getInspectionState(){let e=globalThis,t=e[V];if(t!=null&&t.loggers instanceof WeakMap)return t;let n={configured:!1,loggers:/* @__PURE__ */ new WeakMap};return e[V]=n,n}const H=/* @__PURE__ */ new Set,U=/* @__PURE__ */ new Set,W=/* @__PURE__ */ new Set,G=/* @__PURE__ */ new Set;let unregisterDisposeHook;function getSourceLocationRoot(){return b.getLogger()}function isLoggerConfigMeta(e){let t=Array.isArray(e.category)?e.category:[e.category];return t.length===0||t.length===1&&t[0]===`logtape`||t.length===2&&t[0]===`logtape`&&t[1]===`meta`}function registerDisposeHook(e){unregisterDisposeHook?.(),unregisterDisposeHook=void 0;let t=e?disposeInternal:disposeSyncInternal;if(typeof globalThis.EdgeRuntime!=`string`&&`process`in globalThis&&!(`Deno`in globalThis)){let e=globalThis.process,n=e?.on;if(typeof n==`function`){n.call(e,`exit`,t),unregisterDisposeHook=()=>{let n=e?.off??e?.removeListener;typeof n==`function`&&n.call(e,`exit`,t)};return}}let n=globalThis.addEventListener;if(typeof n!=`function`)return;let r=globalThis.removeEventListener;`Deno`in globalThis?(n.call(globalThis,`unload`,t),typeof r==`function`&&(unregisterDisposeHook=()=>{r.call(globalThis,`unload`,t)})):(n.call(globalThis,`pagehide`,t),typeof r==`function`&&(unregisterDisposeHook=()=>{r.call(globalThis,`pagehide`,t)}))}function configureSync(e){runGlobalConfigMutationSync(`configureSync()`,()=>{if(L!=null&&!e.reset)throw new ConfigError(`Already configured; if you want to reset, turn on the reset flag.`);if(W.size>0||G.size>0)throw new ConfigError(`Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().`);disposeSyncInternal(),resetInternal();try{configureInternal(e,!1)}catch(e){throw e instanceof ConfigError&&(disposeSyncInternal(),resetInternal()),e}})}function configureInternal(e,t){L=e,getInspectionState().configured=!0;let n=!1,r=!1,i=/* @__PURE__ */ new Set;for(let t of e.loggers){isLoggerConfigMeta(t)&&(n=!0);let a=Array.isArray(t.category)?JSON.stringify(t.category):JSON.stringify([t.category]);if(i.has(a))throw new ConfigError(`Duplicate logger configuration for category: ${a}. Each category can only be configured once.`);i.add(a);let o=b.getLogger(t.category);for(let n of t.sinks??[]){let t=e.sinks[n];if(!t)throw new ConfigError(`Sink not found: ${n}.`);o.sinks.push(t)}if(o.parentSinks=t.parentSinks??`inherit`,t.lowestLevel!==void 0&&(o.lowestLevel=t.lowestLevel),t.captureSourceLocation!==void 0){if(typeof t.captureSourceLocation!=`boolean`)throw new ConfigError(`Logger captureSourceLocation must be a boolean.`);o.sourceLocationCapture=t.captureSourceLocation,t.captureSourceLocation&&(r=!0)}for(let n of t.filters??[]){let t=e.filters?.[n];if(t===void 0)throw new ConfigError(`Filter not found: ${n}.`);o.filters.push(toFilter(t))}getInspectionState().loggers.set(o,{sinks:[...o.sinks],sinkIds:[...t.sinks??[]],filters:[...o.filters],filterIds:[...t.filters??[]]}),z.add(o)}b.getLogger().contextLocalStorage=e.contextLocalStorage,getSourceLocationRoot().setGlobalSourceLocationCapture?.(r);for(let n of Object.values(e.sinks)){if(B.add(n),Symbol.asyncDispose in n){if(t)G.add(n);else throw new ConfigError(`Async disposables cannot be used with configureSync().`)}Symbol.dispose in n&&U.add(n)}for(let n of Object.values(e.filters??{}))if(n!=null&&typeof n!=`string`){if(Symbol.asyncDispose in n){if(t)W.add(n);else throw new ConfigError(`Async disposables cannot be used with configureSync().`);G.delete(n)}Symbol.dispose in n&&(H.add(n),U.delete(n))}registerDisposeHook(t);let a=b.getLogger([`logtape`,`meta`]);n||a.sinks.push(getConsoleSink()),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 resetInternal(){unregisterDisposeHook?.(),unregisterDisposeHook=void 0;let e=b.getLogger([]);e.resetDescendants(),getSourceLocationRoot().setGlobalSourceLocationCapture?.(!1),delete e.contextLocalStorage,z.clear(),B.clear();let t=getInspectionState();t.configured=!1,t.loggers=/* @__PURE__ */ new WeakMap,L=null}async function disposeInternal(){let e=[];try{disposeSyncFilters()}catch(t){e.push(t)}try{await disposeAsyncFilters()}catch(t){e.push(t)}try{disposeSyncSinks()}catch(t){e.push(t)}try{await disposeAsyncSinks()}catch(t){e.push(t)}throwDisposeErrors(e)}function disposeSyncInternal(){let e=[];try{disposeSyncFilters()}catch(t){e.push(t)}try{disposeSyncSinks()}catch(t){e.push(t)}throwDisposeErrors(e)}function runGlobalConfigMutationSync(e,t){assertCanMutateGlobalConfig(e),R=!0;try{return t()}finally{R=!1}}function assertCanMutateGlobalConfig(e){if(R)throw new ConfigError(`${e} cannot be called while LogTape is being reconfigured.`)}function disposeSyncFilters(){disposeSyncDisposables(H)}function disposeSyncSinks(){disposeSyncDisposables(U)}function disposeSyncDisposables(e){let t=[];try{for(let n of e)try{n[Symbol.dispose]()}catch(e){t.push(e)}finally{e.delete(n)}}finally{e.clear()}throwDisposeErrors(t)}async function disposeAsyncFilters(){await disposeAsyncDisposables(W)}async function disposeAsyncSinks(){await disposeAsyncDisposables(G)}async function disposeAsyncDisposables(e){let t=[];try{for(let n of e)try{t.push(Promise.resolve(n[Symbol.asyncDispose]()))}catch(e){t.push(Promise.reject(e))}finally{e.delete(n)}}finally{e.clear()}await settleDisposePromises(t)}async function settleDisposePromises(e){throwDisposeErrors((await Promise.allSettled(e)).filter(e=>e.status===`rejected`).map(e=>e.reason))}function throwDisposeErrors(e){if(!(e.length<1))throw e.length===1?e[0]:AggregateError(e,`Multiple errors occurred while disposing LogTape resources.`)}var ConfigError=class extends Error{constructor(e){super(e),this.name=`ConfigError`}};export{getTextFormatter as a,getAnsiColorFormatter as i,getConsoleSink as n,getLogger as o,defaultConsoleFormatter as r,configureSync as t};