@likec4/mcp 1.55.0 → 1.56.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 (159) hide show
  1. package/README.md +2 -2
  2. package/bin/likec4-mcp.mjs +3 -0
  3. package/dist/chunks/libs/@chevrotain/gast.mjs +1 -0
  4. package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +9 -0
  5. package/dist/chunks/libs/@chevrotain/utils.mjs +1 -0
  6. package/dist/chunks/libs/@hono/mcp.mjs +45 -0
  7. package/dist/chunks/libs/@hono/node-server.mjs +1 -0
  8. package/dist/chunks/libs/@logtape/logtape.mjs +4 -0
  9. package/dist/chunks/libs/@lume/kiwi.mjs +1 -0
  10. package/dist/chunks/libs/@modelcontextprotocol/sdk.mjs +12 -0
  11. package/dist/chunks/libs/@radix-ui/colors.mjs +1 -0
  12. package/dist/chunks/libs/@ungap/structured-clone.mjs +1 -0
  13. package/dist/chunks/libs/bail.mjs +1 -0
  14. package/dist/chunks/libs/ccount.mjs +1 -0
  15. package/dist/chunks/libs/chevrotain-allstar.mjs +2 -0
  16. package/dist/chunks/libs/chevrotain.mjs +58 -0
  17. package/dist/chunks/libs/chokidar.mjs +3 -0
  18. package/dist/chunks/libs/chroma-js.mjs +15 -0
  19. package/dist/chunks/libs/citty.mjs +5 -0
  20. package/dist/chunks/libs/comma-separated-tokens.mjs +1 -0
  21. package/dist/chunks/libs/decode-named-character-reference.mjs +1 -0
  22. package/dist/chunks/libs/defu.mjs +1 -0
  23. package/dist/chunks/libs/destr.mjs +1 -0
  24. package/dist/chunks/libs/devlop.mjs +1 -0
  25. package/dist/chunks/libs/escape-string-regexp.mjs +1 -0
  26. package/dist/chunks/libs/eventemitter3.mjs +1 -0
  27. package/dist/chunks/libs/extend.mjs +1 -0
  28. package/dist/chunks/libs/fdir.mjs +1 -0
  29. package/dist/chunks/libs/graphology-dag.mjs +1 -0
  30. package/dist/chunks/libs/graphology.mjs +1 -0
  31. package/dist/chunks/libs/hast-util-sanitize.mjs +1 -0
  32. package/dist/chunks/libs/hast-util-to-html.mjs +9 -0
  33. package/dist/chunks/libs/hono.mjs +1 -0
  34. package/dist/chunks/libs/immer.mjs +1 -0
  35. package/dist/chunks/libs/is-error-instance.mjs +1 -0
  36. package/dist/chunks/libs/is-plain-obj.mjs +1 -0
  37. package/dist/chunks/libs/isexe.mjs +1 -0
  38. package/dist/chunks/libs/json5.mjs +14 -0
  39. package/dist/chunks/libs/khroma.mjs +1 -0
  40. package/dist/chunks/libs/langium.mjs +29 -0
  41. package/dist/chunks/libs/longest-streak.mjs +1 -0
  42. package/dist/chunks/libs/markdown-table.mjs +2 -0
  43. package/dist/chunks/libs/mdast-util-find-and-replace.mjs +1 -0
  44. package/dist/chunks/libs/mdast-util-from-markdown.mjs +3 -0
  45. package/dist/chunks/libs/mdast-util-gfm.mjs +15 -0
  46. package/dist/chunks/libs/mdast-util-to-hast.mjs +11 -0
  47. package/dist/chunks/libs/merge-error-cause.mjs +2 -0
  48. package/dist/chunks/libs/micromark-extension-gfm.mjs +1 -0
  49. package/dist/chunks/libs/mnemonist.mjs +1 -0
  50. package/dist/chunks/libs/nano-spawn.mjs +3 -0
  51. package/dist/chunks/libs/natural-compare-lite.mjs +9 -0
  52. package/dist/chunks/libs/ohash.mjs +1 -0
  53. package/dist/chunks/libs/p-limit.mjs +1 -0
  54. package/dist/chunks/libs/p-queue.mjs +1 -0
  55. package/dist/chunks/libs/p-timeout.mjs +1 -0
  56. package/dist/chunks/libs/parse-ms.mjs +1 -0
  57. package/dist/chunks/libs/pathe.mjs +1 -0
  58. package/dist/chunks/libs/pretty-ms.mjs +1 -0
  59. package/dist/chunks/libs/rehype-sanitize.mjs +1 -0
  60. package/dist/chunks/libs/rehype-stringify.mjs +1 -0
  61. package/dist/chunks/libs/remark-gfm.mjs +1 -0
  62. package/dist/chunks/libs/remark-github-blockquote-alert.mjs +3 -0
  63. package/dist/chunks/libs/remark-parse.mjs +1 -0
  64. package/dist/chunks/libs/remark-rehype.mjs +1 -0
  65. package/dist/chunks/libs/remeda.mjs +1 -0
  66. package/dist/chunks/libs/safe-stringify.mjs +1 -0
  67. package/dist/chunks/libs/strip-indent.mjs +1 -0
  68. package/dist/chunks/libs/tinyrainbow.mjs +1 -0
  69. package/dist/chunks/libs/trough.mjs +1 -0
  70. package/dist/chunks/libs/ts-graphviz.mjs +4 -0
  71. package/dist/chunks/libs/ufo.mjs +1 -0
  72. package/dist/chunks/libs/unified.mjs +1 -0
  73. package/dist/chunks/libs/unstorage.mjs +1 -0
  74. package/dist/chunks/libs/which.mjs +1 -0
  75. package/dist/chunks/libs/word-wrap.mjs +12 -0
  76. package/dist/chunks/rolldown-runtime.mjs +1 -0
  77. package/dist/chunks/src.mjs +1228 -0
  78. package/dist/cli.mjs +1 -1
  79. package/dist/index.mjs +1 -1
  80. package/package.json +21 -17
  81. package/dist/THIRD-PARTY-LICENSES.md +0 -2318
  82. package/dist/_chunks/libs/@chevrotain/cst-dts-gen.mjs +0 -30
  83. package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +0 -9
  84. package/dist/_chunks/libs/@chevrotain/utils.mjs +0 -1
  85. package/dist/_chunks/libs/@hono/mcp.mjs +0 -45
  86. package/dist/_chunks/libs/@hono/node-server.mjs +0 -1
  87. package/dist/_chunks/libs/@logtape/logtape.mjs +0 -4
  88. package/dist/_chunks/libs/@lume/kiwi.mjs +0 -1
  89. package/dist/_chunks/libs/@mantine/colors-generator.mjs +0 -15
  90. package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +0 -12
  91. package/dist/_chunks/libs/@radix-ui/colors.mjs +0 -1
  92. package/dist/_chunks/libs/@ungap/structured-clone.mjs +0 -1
  93. package/dist/_chunks/libs/bail.mjs +0 -1
  94. package/dist/_chunks/libs/ccount.mjs +0 -1
  95. package/dist/_chunks/libs/chevrotain-allstar.mjs +0 -2
  96. package/dist/_chunks/libs/chevrotain.mjs +0 -58
  97. package/dist/_chunks/libs/chokidar.mjs +0 -3
  98. package/dist/_chunks/libs/citty.mjs +0 -5
  99. package/dist/_chunks/libs/comma-separated-tokens.mjs +0 -1
  100. package/dist/_chunks/libs/decode-named-character-reference.mjs +0 -1
  101. package/dist/_chunks/libs/defu.mjs +0 -1
  102. package/dist/_chunks/libs/destr.mjs +0 -1
  103. package/dist/_chunks/libs/devlop.mjs +0 -1
  104. package/dist/_chunks/libs/escape-string-regexp.mjs +0 -1
  105. package/dist/_chunks/libs/eventemitter3.mjs +0 -1
  106. package/dist/_chunks/libs/extend.mjs +0 -1
  107. package/dist/_chunks/libs/fast-equals.mjs +0 -1
  108. package/dist/_chunks/libs/fdir.mjs +0 -1
  109. package/dist/_chunks/libs/graphology-dag.mjs +0 -1
  110. package/dist/_chunks/libs/graphology.mjs +0 -1
  111. package/dist/_chunks/libs/hast-util-sanitize.mjs +0 -1
  112. package/dist/_chunks/libs/hast-util-to-html.mjs +0 -9
  113. package/dist/_chunks/libs/immer.mjs +0 -1
  114. package/dist/_chunks/libs/is-error-instance.mjs +0 -1
  115. package/dist/_chunks/libs/is-plain-obj.mjs +0 -1
  116. package/dist/_chunks/libs/isexe.mjs +0 -1
  117. package/dist/_chunks/libs/json5.mjs +0 -14
  118. package/dist/_chunks/libs/khroma.mjs +0 -1
  119. package/dist/_chunks/libs/langium.mjs +0 -30
  120. package/dist/_chunks/libs/longest-streak.mjs +0 -1
  121. package/dist/_chunks/libs/markdown-table.mjs +0 -2
  122. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +0 -1
  123. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +0 -3
  124. package/dist/_chunks/libs/mdast-util-gfm.mjs +0 -15
  125. package/dist/_chunks/libs/mdast-util-to-hast.mjs +0 -11
  126. package/dist/_chunks/libs/merge-error-cause.mjs +0 -2
  127. package/dist/_chunks/libs/micromark-extension-gfm.mjs +0 -1
  128. package/dist/_chunks/libs/mnemonist.mjs +0 -1
  129. package/dist/_chunks/libs/nano-spawn.mjs +0 -3
  130. package/dist/_chunks/libs/natural-compare-lite.mjs +0 -9
  131. package/dist/_chunks/libs/ohash.mjs +0 -1
  132. package/dist/_chunks/libs/p-limit.mjs +0 -1
  133. package/dist/_chunks/libs/p-queue.mjs +0 -1
  134. package/dist/_chunks/libs/p-timeout.mjs +0 -1
  135. package/dist/_chunks/libs/parse-ms.mjs +0 -1
  136. package/dist/_chunks/libs/pathe.mjs +0 -1
  137. package/dist/_chunks/libs/pretty-ms.mjs +0 -1
  138. package/dist/_chunks/libs/rehype-sanitize.mjs +0 -1
  139. package/dist/_chunks/libs/rehype-stringify.mjs +0 -1
  140. package/dist/_chunks/libs/remark-gfm.mjs +0 -1
  141. package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +0 -3
  142. package/dist/_chunks/libs/remark-parse.mjs +0 -1
  143. package/dist/_chunks/libs/remark-rehype.mjs +0 -1
  144. package/dist/_chunks/libs/remeda.mjs +0 -2
  145. package/dist/_chunks/libs/safe-stringify.mjs +0 -1
  146. package/dist/_chunks/libs/strip-indent.mjs +0 -1
  147. package/dist/_chunks/libs/tinyrainbow.mjs +0 -1
  148. package/dist/_chunks/libs/trough.mjs +0 -1
  149. package/dist/_chunks/libs/ts-graphviz.mjs +0 -4
  150. package/dist/_chunks/libs/ufo.mjs +0 -1
  151. package/dist/_chunks/libs/unified.mjs +0 -1
  152. package/dist/_chunks/libs/unstorage.mjs +0 -1
  153. package/dist/_chunks/libs/which.mjs +0 -1
  154. package/dist/_chunks/libs/word-wrap.mjs +0 -12
  155. package/dist/_chunks/rolldown-runtime.mjs +0 -1
  156. package/dist/_chunks/src.mjs +0 -1228
  157. /package/dist/{_chunks → chunks}/libs/character-entities-html4.mjs +0 -0
  158. /package/dist/{_chunks → chunks}/libs/character-entities-legacy.mjs +0 -0
  159. /package/dist/{_chunks → chunks}/libs/character-entities.mjs +0 -0
@@ -0,0 +1 @@
1
+ import{t as e}from"../../rolldown-runtime.mjs";var t=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.amber={amber1:`#fefdfb`,amber2:`#fefbe9`,amber3:`#fff7c2`,amber4:`#ffee9c`,amber5:`#fbe577`,amber6:`#f3d673`,amber7:`#e9c162`,amber8:`#e2a336`,amber9:`#ffc53d`,amber10:`#ffba18`,amber11:`#ab6400`,amber12:`#4f3422`},e.blue={blue1:`#fbfdff`,blue2:`#f4faff`,blue3:`#e6f4fe`,blue4:`#d5efff`,blue5:`#c2e5ff`,blue6:`#acd8fc`,blue7:`#8ec8f6`,blue8:`#5eb1ef`,blue9:`#0090ff`,blue10:`#0588f0`,blue11:`#0d74ce`,blue12:`#113264`},e.crimson={crimson1:`#fffcfd`,crimson2:`#fef7f9`,crimson3:`#ffe9f0`,crimson4:`#fedce7`,crimson5:`#facedd`,crimson6:`#f3bed1`,crimson7:`#eaacc3`,crimson8:`#e093b2`,crimson9:`#e93d82`,crimson10:`#df3478`,crimson11:`#cb1d63`,crimson12:`#621639`},e.grass={grass1:`#fbfefb`,grass2:`#f5fbf5`,grass3:`#e9f6e9`,grass4:`#daf1db`,grass5:`#c9e8ca`,grass6:`#b2ddb5`,grass7:`#94ce9a`,grass8:`#65ba74`,grass9:`#46a758`,grass10:`#3e9b4f`,grass11:`#2a7e3b`,grass12:`#203c25`},e.indigo={indigo1:`#fdfdfe`,indigo2:`#f7f9ff`,indigo3:`#edf2fe`,indigo4:`#e1e9ff`,indigo5:`#d2deff`,indigo6:`#c1d0ff`,indigo7:`#abbdf9`,indigo8:`#8da4ef`,indigo9:`#3e63dd`,indigo10:`#3358d4`,indigo11:`#3a5bc7`,indigo12:`#1f2d5c`},e.lime={lime1:`#fcfdfa`,lime2:`#f8faf3`,lime3:`#eef6d6`,lime4:`#e2f0bd`,lime5:`#d3e7a6`,lime6:`#c2da91`,lime7:`#abc978`,lime8:`#8db654`,lime9:`#bdee63`,lime10:`#b0e64c`,lime11:`#5c7c2f`,lime12:`#37401c`},e.orange={orange1:`#fefcfb`,orange2:`#fff7ed`,orange3:`#ffefd6`,orange4:`#ffdfb5`,orange5:`#ffd19a`,orange6:`#ffc182`,orange7:`#f5ae73`,orange8:`#ec9455`,orange9:`#f76b15`,orange10:`#ef5f00`,orange11:`#cc4e00`,orange12:`#582d1d`},e.pink={pink1:`#fffcfe`,pink2:`#fef7fb`,pink3:`#fee9f5`,pink4:`#fbdcef`,pink5:`#f6cee7`,pink6:`#efbfdd`,pink7:`#e7acd0`,pink8:`#dd93c2`,pink9:`#d6409f`,pink10:`#cf3897`,pink11:`#c2298a`,pink12:`#651249`},e.purple={purple1:`#fefcfe`,purple2:`#fbf7fe`,purple3:`#f7edfe`,purple4:`#f2e2fc`,purple5:`#ead5f9`,purple6:`#e0c4f4`,purple7:`#d1afec`,purple8:`#be93e4`,purple9:`#8e4ec6`,purple10:`#8347b9`,purple11:`#8145b5`,purple12:`#402060`},e.red={red1:`#fffcfc`,red2:`#fff7f7`,red3:`#feebec`,red4:`#ffdbdc`,red5:`#ffcdce`,red6:`#fdbdbe`,red7:`#f4a9aa`,red8:`#eb8e90`,red9:`#e5484d`,red10:`#dc3e42`,red11:`#ce2c31`,red12:`#641723`},e.ruby={ruby1:`#fffcfd`,ruby2:`#fff7f8`,ruby3:`#feeaed`,ruby4:`#ffdce1`,ruby5:`#ffced6`,ruby6:`#f8bfc8`,ruby7:`#efacb8`,ruby8:`#e592a3`,ruby9:`#e54666`,ruby10:`#dc3b5d`,ruby11:`#ca244d`,ruby12:`#64172b`},e.teal={teal1:`#fafefd`,teal2:`#f3fbf9`,teal3:`#e0f8f3`,teal4:`#ccf3ea`,teal5:`#b8eae0`,teal6:`#a1ded2`,teal7:`#83cdc1`,teal8:`#53b9ab`,teal9:`#12a594`,teal10:`#0d9b8a`,teal11:`#008573`,teal12:`#0d3d38`},e.tomato={tomato1:`#fffcfc`,tomato2:`#fff8f7`,tomato3:`#feebe7`,tomato4:`#ffdcd3`,tomato5:`#ffcdc2`,tomato6:`#fdbdaf`,tomato7:`#f5a898`,tomato8:`#ec8e7b`,tomato9:`#e54d2e`,tomato10:`#dd4425`,tomato11:`#d13415`,tomato12:`#5c271f`},e.violet={violet1:`#fdfcfe`,violet2:`#faf8ff`,violet3:`#f4f0fe`,violet4:`#ebe4ff`,violet5:`#e1d9ff`,violet6:`#d4cafe`,violet7:`#c2b5f5`,violet8:`#aa99ec`,violet9:`#6e56cf`,violet10:`#654dc4`,violet11:`#6550b9`,violet12:`#2f265f`},e.yellow={yellow1:`#fdfdf9`,yellow2:`#fefce9`,yellow3:`#fffab8`,yellow4:`#fff394`,yellow5:`#ffe770`,yellow6:`#f3d768`,yellow7:`#e4c767`,yellow8:`#d5ae39`,yellow9:`#ffe629`,yellow10:`#ffdc00`,yellow11:`#9e6c00`,yellow12:`#473b1f`}}));export{t};
@@ -0,0 +1 @@
1
+ import"../../rolldown-runtime.mjs";const e=typeof self==`object`?self:globalThis,deserializer=(t,n)=>{let as=(e,n)=>(t.set(n,e),e),unpair=r=>{if(t.has(r))return t.get(r);let[i,a]=n[r];switch(i){case 0:case-1:return as(a,r);case 1:{let e=as([],r);for(let t of a)e.push(unpair(t));return e}case 2:{let e=as({},r);for(let[t,n]of a)e[unpair(t)]=unpair(n);return e}case 3:return as(new Date(a),r);case 4:{let{source:e,flags:t}=a;return as(new RegExp(e,t),r)}case 5:{let e=as(new Map,r);for(let[t,n]of a)e.set(unpair(t),unpair(n));return e}case 6:{let e=as(new Set,r);for(let t of a)e.add(unpair(t));return e}case 7:{let{name:t,message:n}=a;return as(new e[t](n),r)}case 8:return as(BigInt(a),r);case`BigInt`:return as(Object(BigInt(a)),r);case`ArrayBuffer`:return as(new Uint8Array(a).buffer,a);case`DataView`:{let{buffer:e}=new Uint8Array(a);return as(new DataView(e),a)}}return as(new e[i](a),r)};return unpair},deserialize=e=>deserializer(new Map,e)(0),{toString:t}={},{keys:n}=Object,typeOf=e=>{let n=typeof e;if(n!==`object`||!e)return[0,n];let r=t.call(e).slice(8,-1);switch(r){case`Array`:return[1,``];case`Object`:return[2,``];case`Date`:return[3,``];case`RegExp`:return[4,``];case`Map`:return[5,``];case`Set`:return[6,``];case`DataView`:return[1,r]}return r.includes(`Array`)?[1,r]:r.includes(`Error`)?[7,r]:[2,r]},shouldSkip=([e,t])=>e===0&&(t===`function`||t===`symbol`),serializer=(e,t,r,i)=>{let as=(e,t)=>{let n=i.push(e)-1;return r.set(t,n),n},pair=i=>{if(r.has(i))return r.get(i);let[a,o]=typeOf(i);switch(a){case 0:{let t=i;switch(o){case`bigint`:a=8,t=i.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+o);t=null;break;case`undefined`:return as([-1],i)}return as([a,t],i)}case 1:{if(o){let e=i;return o===`DataView`?e=new Uint8Array(i.buffer):o===`ArrayBuffer`&&(e=new Uint8Array(i)),as([o,[...e]],i)}let e=[],t=as([a,e],i);for(let t of i)e.push(pair(t));return t}case 2:{if(o)switch(o){case`BigInt`:return as([o,i.toString()],i);case`Boolean`:case`Number`:case`String`:return as([o,i.valueOf()],i)}if(t&&`toJSON`in i)return pair(i.toJSON());let r=[],s=as([a,r],i);for(let t of n(i))(e||!shouldSkip(typeOf(i[t])))&&r.push([pair(t),pair(i[t])]);return s}case 3:return as([a,i.toISOString()],i);case 4:{let{source:e,flags:t}=i;return as([a,{source:e,flags:t}],i)}case 5:{let t=[],n=as([a,t],i);for(let[n,r]of i)(e||!(shouldSkip(typeOf(n))||shouldSkip(typeOf(r))))&&t.push([pair(n),pair(r)]);return n}case 6:{let t=[],n=as([a,t],i);for(let n of i)(e||!shouldSkip(typeOf(n)))&&t.push(pair(n));return n}}let{message:s}=i;return as([a,{name:o,message:s}],i)};return pair},serialize=(e,{json:t,lossy:n}={})=>{let r=[];return serializer(!(t||n),!!t,new Map,r)(e),r};var r=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?deserialize(serialize(e,t)):structuredClone(e):(e,t)=>deserialize(serialize(e,t));export{r as t};
@@ -0,0 +1 @@
1
+ import"../rolldown-runtime.mjs";function bail(e){if(e)throw e}export{bail as t};
@@ -0,0 +1 @@
1
+ import"../rolldown-runtime.mjs";function ccount(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}export{ccount as t};
@@ -0,0 +1,2 @@
1
+ import"../rolldown-runtime.mjs";import{C as e,D as t,T as n,c as r,d as i,f as a,h as o,ht as s,l as c,o as l,p as u,u as d,ut as f}from"./@chevrotain/gast.mjs";import{c as p,d as m,f as h,g,h as _,i as v,m as y,p as b,r as x,s as S}from"./chevrotain.mjs";function baseLt(e,t){return e<t}function baseExtremum(e,t,n){for(var r=-1,i=e.length;++r<i;){var a=e[r],o=t(a);if(o!=null&&(c===void 0?o===o&&!s(o):n(o,c)))var c=o,l=a}return l}function min(e){return e&&e.length?baseExtremum(e,f,baseLt):void 0}function uniqBy(e,n){return e&&e.length?m(e,t(n,2)):[]}function buildATNKey(e,t,n){return`${e.name}_${t}_${n}`}var AbstractTransition=class{constructor(e){this.target=e}isEpsilon(){return!1}},AtomTransition=class extends AbstractTransition{constructor(e,t){super(e),this.tokenType=t}},EpsilonTransition=class extends AbstractTransition{constructor(e){super(e)}isEpsilon(){return!0}},RuleTransition=class extends AbstractTransition{constructor(e,t,n){super(e),this.rule=t,this.followState=n}isEpsilon(){return!0}};function createATN(e){let t={decisionMap:{},decisionStates:[],ruleToStartState:new Map,ruleToStopState:new Map,states:[]};createRuleStartAndStopATNStates(t,e);let n=e.length;for(let r=0;r<n;r++){let n=e[r],i=block(t,n,n);i!==void 0&&buildRuleHandle(t,n,i)}return t}function createRuleStartAndStopATNStates(e,t){let n=t.length;for(let r=0;r<n;r++){let n=t[r],i=newState(e,n,void 0,{type:2}),a=newState(e,n,void 0,{type:7});i.stop=a,e.ruleToStartState.set(n,i),e.ruleToStopState.set(n,a)}}function atom(e,t,n){return n instanceof o?tokenRef(e,t,n.terminalType,n):n instanceof r?ruleRef(e,t,n):n instanceof l?alternation(e,t,n):n instanceof c?option(e,t,n):n instanceof d?repetition(e,t,n):n instanceof u?repetitionSep(e,t,n):n instanceof i?repetitionMandatory(e,t,n):n instanceof a?repetitionMandatorySep(e,t,n):block(e,t,n)}function repetition(e,t,n){let r=newState(e,t,n,{type:5});return defineDecisionState(e,r),star(e,t,n,makeAlts(e,t,r,n,block(e,t,n)))}function repetitionSep(e,t,n){let r=newState(e,t,n,{type:5});return defineDecisionState(e,r),star(e,t,n,makeAlts(e,t,r,n,block(e,t,n)),tokenRef(e,t,n.separator,n))}function repetitionMandatory(e,t,n){let r=newState(e,t,n,{type:4});return defineDecisionState(e,r),plus(e,t,n,makeAlts(e,t,r,n,block(e,t,n)))}function repetitionMandatorySep(e,t,n){let r=newState(e,t,n,{type:4});return defineDecisionState(e,r),plus(e,t,n,makeAlts(e,t,r,n,block(e,t,n)),tokenRef(e,t,n.separator,n))}function alternation(t,n,r){let i=newState(t,n,r,{type:1});return defineDecisionState(t,i),makeAlts(t,n,i,r,...e(r.definition,e=>atom(t,n,e)))}function option(e,t,n){let r=newState(e,t,n,{type:1});return defineDecisionState(e,r),optional(e,t,n,makeAlts(e,t,r,n,block(e,t,n)))}function block(t,n,r){let i=_(e(r.definition,e=>atom(t,n,e)),e=>e!==void 0);return i.length===1?i[0]:i.length===0?void 0:makeBlock(t,i)}function plus(e,t,n,r,i){let a=r.left,o=r.right,s=newState(e,t,n,{type:11});defineDecisionState(e,s);let c=newState(e,t,n,{type:12});return a.loopback=s,c.loopback=s,e.decisionMap[buildATNKey(t,i?`RepetitionMandatoryWithSeparator`:`RepetitionMandatory`,n.idx)]=s,epsilon(o,s),i===void 0?(epsilon(s,a),epsilon(s,c)):(epsilon(s,c),epsilon(s,i.left),epsilon(i.right,a)),{left:a,right:c}}function star(e,t,n,r,i){let a=r.left,o=r.right,s=newState(e,t,n,{type:10});defineDecisionState(e,s);let c=newState(e,t,n,{type:12}),l=newState(e,t,n,{type:9});return s.loopback=l,c.loopback=l,epsilon(s,a),epsilon(s,c),epsilon(o,l),i===void 0?epsilon(l,s):(epsilon(l,c),epsilon(l,i.left),epsilon(i.right,a)),e.decisionMap[buildATNKey(t,i?`RepetitionWithSeparator`:`Repetition`,n.idx)]=s,{left:s,right:c}}function optional(e,t,n,r){let i=r.left,a=r.right;return epsilon(i,a),e.decisionMap[buildATNKey(t,`Option`,n.idx)]=i,r}function defineDecisionState(e,t){return e.decisionStates.push(t),t.decision=e.decisionStates.length-1,t.decision}function makeAlts(e,t,n,r,...i){let a=newState(e,t,r,{type:8,start:n});n.end=a;for(let e of i)e===void 0?epsilon(n,a):(epsilon(n,e.left),epsilon(e.right,a));let o={left:n,right:a};return e.decisionMap[buildATNKey(t,getProdType(r),r.idx)]=n,o}function getProdType(e){if(e instanceof l)return`Alternation`;if(e instanceof c)return`Option`;if(e instanceof d)return`Repetition`;if(e instanceof u)return`RepetitionWithSeparator`;if(e instanceof i)return`RepetitionMandatory`;if(e instanceof a)return`RepetitionMandatoryWithSeparator`;throw Error(`Invalid production type encountered`)}function makeBlock(e,t){let n=t.length;for(let r=0;r<n-1;r++){let n=t[r],i;n.left.transitions.length===1&&(i=n.left.transitions[0]);let a=i instanceof RuleTransition,o=i,s=t[r+1].left;n.left.type===1&&n.right.type===1&&i!==void 0&&(a&&o.followState===n.right||i.target===n.right)?(a?o.followState=s:i.target=s,removeState(e,n.right)):epsilon(n.right,s)}let r=t[0],i=t[n-1];return{left:r.left,right:i.right}}function tokenRef(e,t,n,r){let i=newState(e,t,r,{type:1}),a=newState(e,t,r,{type:1});return addTransition(i,new AtomTransition(a,n)),{left:i,right:a}}function ruleRef(e,t,n){let r=n.referencedRule,i=e.ruleToStartState.get(r),a=newState(e,t,n,{type:1}),o=newState(e,t,n,{type:1});return addTransition(a,new RuleTransition(i,r,o)),{left:a,right:o}}function buildRuleHandle(e,t,n){let r=e.ruleToStartState.get(t);epsilon(r,n.left);let i=e.ruleToStopState.get(t);return epsilon(n.right,i),{left:r,right:i}}function epsilon(e,t){addTransition(e,new EpsilonTransition(t))}function newState(e,t,n,r){let i=Object.assign({atn:e,production:n,epsilonOnlyTransitions:!1,rule:t,transitions:[],nextTokenWithinRule:[],stateNumber:e.states.length},r);return e.states.push(i),i}function addTransition(e,t){e.transitions.length===0&&(e.epsilonOnlyTransitions=t.isEpsilon()),e.transitions.push(t)}function removeState(e,t){e.states.splice(e.states.indexOf(t),1)}const C={};var ATNConfigSet=class{constructor(){this.map={},this.configs=[]}get size(){return this.configs.length}finalize(){this.map={}}add(e){let t=getATNConfigKey(e);t in this.map||(this.map[t]=this.configs.length,this.configs.push(e))}get elements(){return this.configs}get alts(){return e(this.configs,e=>e.alt)}get key(){let e=``;for(let t in this.map)e+=t+`:`;return e}};function getATNConfigKey(e,t=!0){return`${t?`a${e.alt}`:``}s${e.state.stateNumber}:${e.stack.map(e=>e.stateNumber.toString()).join(`_`)}`}function createDFACache(e,t){let n={};return r=>{let i=r.toString(),a=n[i];return a===void 0?(a={atnStartState:e,decision:t,states:{}},n[i]=a,a):a}}var PredicateSet=class{constructor(){this.predicates=[]}is(e){return e>=this.predicates.length||this.predicates[e]}set(e,t){this.predicates[e]=t}toString(){let e=``,t=this.predicates.length;for(let n=0;n<t;n++)e+=this.predicates[n]===!0?`1`:`0`;return e}};const w=new PredicateSet;var LLStarLookaheadStrategy=class extends x{constructor(e){super(),this.logging=e?.logging??(e=>console.log(e))}initialize(e){this.atn=createATN(e.rules),this.dfas=initATNSimulator(this.atn)}validateAmbiguousAlternationAlternatives(){return[]}validateEmptyOrAlternatives(){return[]}buildLookaheadForAlternation(t){let{prodOccurrence:r,rule:i,hasPredicates:a,dynamicTokensEnabled:o}=t,s=this.dfas,c=this.logging,l=buildATNKey(i,`Alternation`,r),u=this.atn.decisionMap[l].decision,d=e(v({maxLookahead:1,occurrence:r,prodType:`Alternation`,rule:i}),t=>e(t,e=>e[0]));if(isLL1Sequence(d,!1)&&!o){let e=h(d,(e,t,r)=>(n(t,t=>{t&&(e[t.tokenTypeIdx]=r,n(t.categoryMatches,t=>{e[t]=r}))}),e),{});return a?function(t){let n=e[this.LA(1).tokenTypeIdx];if(t!==void 0&&n!==void 0){let e=t[n]?.GATE;if(e!==void 0&&e.call(this)===!1)return}return n}:function(){return e[this.LA(1).tokenTypeIdx]}}else if(a)return function(e){let t=new PredicateSet,n=e===void 0?0:e.length;for(let r=0;r<n;r++){let n=e?.[r].GATE;t.set(r,n===void 0||n.call(this))}let r=adaptivePredict.call(this,s,u,t,c);return typeof r==`number`?r:void 0};else return function(){let e=adaptivePredict.call(this,s,u,w,c);return typeof e==`number`?e:void 0}}buildLookaheadForOptional(t){let{prodOccurrence:r,rule:i,prodType:a,dynamicTokensEnabled:o}=t,s=this.dfas,c=this.logging,l=buildATNKey(i,a,r),u=this.atn.decisionMap[l].decision,d=e(v({maxLookahead:1,occurrence:r,prodType:a,rule:i}),t=>e(t,e=>e[0]));if(isLL1Sequence(d)&&d[0][0]&&!o){let e=d[0],t=g(e);if(t.length===1&&b(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}else{let e=h(t,(e,t)=>(t!==void 0&&(e[t.tokenTypeIdx]=!0,n(t.categoryMatches,t=>{e[t]=!0})),e),{});return function(){return e[this.LA(1).tokenTypeIdx]===!0}}}return function(){let e=adaptivePredict.call(this,s,u,w,c);return typeof e==`object`?!1:e===0}}};function isLL1Sequence(e,t=!0){let n=new Set;for(let r of e){let e=new Set;for(let i of r){if(i===void 0){if(t)break;return!1}let r=[i.tokenTypeIdx].concat(i.categoryMatches);for(let t of r)if(n.has(t)){if(!e.has(t))return!1}else n.add(t),e.add(t)}}return!0}function initATNSimulator(e){let t=e.decisionStates.length,n=Array(t);for(let r=0;r<t;r++)n[r]=createDFACache(e.decisionStates[r],r);return n}function adaptivePredict(e,t,n,r){let i=e[t](n),a=i.start;return a===void 0&&(a=addDFAState(i,newDFAState(computeStartState(i.atnStartState))),i.start=a),performLookahead.apply(this,[i,a,n,r])}function performLookahead(e,t,n,r){let i=t,a=1,o=[],s=this.LA(a++);for(;;){let t=getExistingTargetState(i,s);if(t===void 0&&(t=computeLookaheadTarget.apply(this,[e,i,s,a,n,r])),t===C)return buildAdaptivePredictError(o,i,s);if(t.isAcceptState===!0)return t.prediction;i=t,o.push(s),s=this.LA(a++)}}function computeLookaheadTarget(e,t,n,r,i,a){let o=computeReachSet(t.configs,n,i);if(o.size===0)return addDFAEdge(e,t,n,C),C;let s=newDFAState(o),c=getUniqueAlt(o,i);if(c!==void 0)s.isAcceptState=!0,s.prediction=c,s.configs.uniqueAlt=c;else if(hasConflictTerminatingPrediction(o)){let t=min(o.alts);s.isAcceptState=!0,s.prediction=t,s.configs.uniqueAlt=t,reportLookaheadAmbiguity.apply(this,[e,r,o.alts,a])}return s=addDFAEdge(e,t,n,s),s}function reportLookaheadAmbiguity(e,t,n,r){let i=[];for(let e=1;e<=t;e++)i.push(this.LA(e).tokenType);let a=e.atnStartState,o=a.rule,s=a.production;r(buildAmbiguityError({topLevelRule:o,ambiguityIndices:n,production:s,prefixPath:i}))}function buildAmbiguityError(t){let n=e(t.prefixPath,e=>S(e)).join(`, `),r=t.production.idx===0?``:t.production.idx,i=`Ambiguous Alternatives Detected: <${t.ambiguityIndices.join(`, `)}> in <${getProductionDslName(t.production)}${r}> inside <${t.topLevelRule.name}> Rule,\n<${n}> may appears as a prefix path in all these alternatives.\n`;return i+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
2
+ For Further details.`,i}function getProductionDslName(e){if(e instanceof r)return`SUBRULE`;if(e instanceof c)return`OPTION`;if(e instanceof l)return`OR`;if(e instanceof i)return`AT_LEAST_ONE`;if(e instanceof a)return`AT_LEAST_ONE_SEP`;if(e instanceof u)return`MANY_SEP`;if(e instanceof d)return`MANY`;if(e instanceof o)return`CONSUME`;throw Error(`non exhaustive match`)}function buildAdaptivePredictError(e,t,n){return{actualToken:n,possibleTokenTypes:uniqBy(y(t.configs.elements,e=>e.state.transitions).filter(e=>e instanceof AtomTransition).map(e=>e.tokenType),e=>e.tokenTypeIdx),tokenPath:e}}function getExistingTargetState(e,t){return e.edges[t.tokenTypeIdx]}function computeReachSet(e,t,n){let r=new ATNConfigSet,i=[];for(let a of e.elements){if(n.is(a.alt)===!1)continue;if(a.state.type===7){i.push(a);continue}let e=a.state.transitions.length;for(let n=0;n<e;n++){let e=a.state.transitions[n],i=getReachableTarget(e,t);i!==void 0&&r.add({state:i,alt:a.alt,stack:a.stack})}}let a;if(i.length===0&&r.size===1&&(a=r),a===void 0){a=new ATNConfigSet;for(let e of r.elements)closure(e,a)}if(i.length>0&&!hasConfigInRuleStopState(a))for(let e of i)a.add(e);return a}function getReachableTarget(e,t){if(e instanceof AtomTransition&&p(t,e.tokenType))return e.target}function getUniqueAlt(e,t){let n;for(let r of e.elements)if(t.is(r.alt)===!0){if(n===void 0)n=r.alt;else if(n!==r.alt)return}return n}function newDFAState(e){return{configs:e,edges:{},isAcceptState:!1,prediction:-1}}function addDFAEdge(e,t,n,r){return r=addDFAState(e,r),t.edges[n.tokenTypeIdx]=r,r}function addDFAState(e,t){if(t===C)return t;let n=t.configs.key,r=e.states[n];return r===void 0?(t.configs.finalize(),e.states[n]=t,t):r}function computeStartState(e){let t=new ATNConfigSet,n=e.transitions.length;for(let r=0;r<n;r++)closure({state:e.transitions[r].target,alt:r,stack:[]},t);return t}function closure(e,t){let n=e.state;if(n.type===7){if(e.stack.length>0){let n=[...e.stack];closure({state:n.pop(),alt:e.alt,stack:n},t)}else t.add(e);return}n.epsilonOnlyTransitions||t.add(e);let r=n.transitions.length;for(let i=0;i<r;i++){let r=n.transitions[i],a=getEpsilonTarget(e,r);a!==void 0&&closure(a,t)}}function getEpsilonTarget(e,t){if(t instanceof EpsilonTransition)return{state:t.target,alt:e.alt,stack:e.stack};if(t instanceof RuleTransition){let n=[...e.stack,t.followState];return{state:t.target,alt:e.alt,stack:n}}}function hasConfigInRuleStopState(e){for(let t of e.elements)if(t.state.type===7)return!0;return!1}function allConfigsInRuleStopStates(e){for(let t of e.elements)if(t.state.type!==7)return!1;return!0}function hasConflictTerminatingPrediction(e){if(allConfigsInRuleStopStates(e))return!0;let t=getConflictingAltSets(e.elements);return hasConflictingAltSet(t)&&!hasStateAssociatedWithOneAlt(t)}function getConflictingAltSets(e){let t=new Map;for(let n of e){let e=getATNConfigKey(n,!1),r=t.get(e);r===void 0&&(r={},t.set(e,r)),r[n.alt]=!0}return t}function hasConflictingAltSet(e){for(let t of Array.from(e.values()))if(Object.keys(t).length>1)return!0;return!1}function hasStateAssociatedWithOneAlt(e){for(let t of Array.from(e.values()))if(Object.keys(t).length===1)return!0;return!1}export{LLStarLookaheadStrategy as t};
@@ -0,0 +1,58 @@
1
+ import{i as e}from"../rolldown-runtime.mjs";import{n as t,t as n}from"./@chevrotain/regexp-to-ast.mjs";import{$ as r,A as i,B as a,C as o,D as s,E as c,F as l,G as u,H as d,I as f,J as p,K as m,L as h,M as g,N as _,O as v,P as y,Q as ee,R as te,S as b,T as x,U as S,V as C,W as w,X as ne,Y as T,Z as E,_ as D,_t as O,a as k,at as re,b as A,c as j,ct as ie,d as M,dt as ae,et as oe,f as N,ft as se,g as ce,gt as le,h as P,i as ue,it as de,j as fe,k as pe,l as F,lt as I,m as me,mt as he,n as ge,nt as _e,o as L,ot as ve,p as ye,pt as R,q as be,r as xe,rt as Se,s as z,st as Ce,t as B,tt as we,u as V,ut as Te,v as Ee,vt as De,w as H,x as U,y as W,z as Oe}from"./@chevrotain/gast.mjs";import{i as ke,n as Ae,r as je,t as Me}from"./@chevrotain/utils.mjs";var Ne=Object.create,Pe=function(){function object(){}return function(e){if(!se(e))return{};if(Ne)return Ne(e);object.prototype=e;var t=new object;return object.prototype=void 0,t}}();function noop(){}function copyArray(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}function arrayIncludes(e,t){return!!(e!=null&&e.length)&&ve(e,t,0)>-1}var Fe=O?O.isConcatSpreadable:void 0;function isFlattenable(e){return R(e)||E(e)||!!(Fe&&e&&e[Fe])}function baseFlatten(e,t,n,r,i){var a=-1,o=e.length;for(n||=isFlattenable,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?baseFlatten(s,t-1,n,r,i):d(i,s):r||(i[i.length]=s)}return i}function flatten(e){return e!=null&&e.length?baseFlatten(e,1):[]}function baseSlice(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=Array(i);++r<i;)a[r]=e[r+t];return a}function arrayReduce(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function baseAssign(e,t){return e&&_e(t,u(t),e)}function baseAssignIn(e,t){return e&&_e(t,S(t),e)}var Ie=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Le=Ie&&typeof module==`object`&&module&&!module.nodeType&&module,Re=Le&&Le.exports===Ie?De.Buffer:void 0,ze=Re?Re.allocUnsafe:void 0;function cloneBuffer(e,t){if(t)return e.slice();var n=e.length,r=ze?ze(n):new e.constructor(n);return e.copy(r),r}function copySymbols(e,t){return _e(e,te(e),t)}function copySymbolsIn(e,t){return _e(e,h(e),t)}var Be=Object.prototype.hasOwnProperty;function initCloneArray(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&Be.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}function cloneArrayBuffer(e){var t=new e.constructor(e.byteLength);return new g(t).set(new g(e)),t}function cloneDataView(e,t){var n=t?cloneArrayBuffer(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}var Ve=/\w*$/;function cloneRegExp(e){var t=new e.constructor(e.source,Ve.exec(e));return t.lastIndex=e.lastIndex,t}var He=O?O.prototype:void 0,Ue=He?He.valueOf:void 0;function cloneSymbol(e){return Ue?Object(Ue.call(e)):{}}function cloneTypedArray(e,t){var n=t?cloneArrayBuffer(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var We=`[object Boolean]`,Ge=`[object Date]`,Ke=`[object Map]`,qe=`[object Number]`,Je=`[object RegExp]`,Ye=`[object Set]`,Xe=`[object String]`,Ze=`[object Symbol]`,Qe=`[object ArrayBuffer]`,$e=`[object DataView]`,et=`[object Float32Array]`,tt=`[object Float64Array]`,nt=`[object Int8Array]`,rt=`[object Int16Array]`,it=`[object Int32Array]`,at=`[object Uint8Array]`,ot=`[object Uint8ClampedArray]`,st=`[object Uint16Array]`,ct=`[object Uint32Array]`;function initCloneByTag(e,t,n){var r=e.constructor;switch(t){case Qe:return cloneArrayBuffer(e);case We:case Ge:return new r(+e);case $e:return cloneDataView(e,n);case et:case tt:case nt:case rt:case it:case at:case ot:case st:case ct:return cloneTypedArray(e,n);case Ke:return new r;case qe:case Xe:return new r(e);case Je:return cloneRegExp(e);case Ye:return new r;case Ze:return cloneSymbol(e)}}function initCloneObject(e){return typeof e.constructor==`function`&&!ee(e)?Pe(C(e)):{}}var lt=`[object Map]`;function baseIsMap(e){return le(e)&&_(e)==lt}var ut=p&&p.isMap,dt=ut?T(ut):baseIsMap,ft=`[object Set]`;function baseIsSet(e){return le(e)&&_(e)==ft}var pt=p&&p.isSet,mt=pt?T(pt):baseIsSet,ht=1,gt=2,_t=4,vt=`[object Arguments]`,yt=`[object Array]`,bt=`[object Boolean]`,xt=`[object Date]`,St=`[object Error]`,Ct=`[object Function]`,wt=`[object GeneratorFunction]`,Tt=`[object Map]`,Et=`[object Number]`,Dt=`[object Object]`,Ot=`[object RegExp]`,kt=`[object Set]`,At=`[object String]`,jt=`[object Symbol]`,Mt=`[object WeakMap]`,Nt=`[object ArrayBuffer]`,Pt=`[object DataView]`,Ft=`[object Float32Array]`,It=`[object Float64Array]`,Lt=`[object Int8Array]`,Rt=`[object Int16Array]`,zt=`[object Int32Array]`,Bt=`[object Uint8Array]`,Vt=`[object Uint8ClampedArray]`,Ht=`[object Uint16Array]`,Ut=`[object Uint32Array]`,G={};G[vt]=G[yt]=G[Nt]=G[Pt]=G[bt]=G[xt]=G[Ft]=G[It]=G[Lt]=G[Rt]=G[zt]=G[Tt]=G[Et]=G[Dt]=G[Ot]=G[kt]=G[At]=G[jt]=G[Bt]=G[Vt]=G[Ht]=G[Ut]=!0,G[St]=G[Ct]=G[Mt]=!1;function baseClone(e,t,n,r,i,o){var s,c=t&ht,d=t&gt,p=t&_t;if(n&&(s=i?n(e,r,i,o):n(e)),s!==void 0)return s;if(!se(e))return e;var m=R(e);if(m){if(s=initCloneArray(e),!c)return copyArray(e,s)}else{var h=_(e),g=h==Ct||h==wt;if(ne(e))return cloneBuffer(e,c);if(h==Dt||h==vt||g&&!i){if(s=d||g?{}:initCloneObject(e),!c)return d?copySymbolsIn(e,baseAssignIn(s,e)):copySymbols(e,baseAssign(s,e))}else{if(!G[h])return i?e:{};s=initCloneByTag(e,h,c)}}o||=new a;var v=o.get(e);if(v)return v;o.set(e,s),mt(e)?e.forEach(function(r){s.add(baseClone(r,t,n,r,e,o))}):dt(e)&&e.forEach(function(r,i){s.set(i,baseClone(r,t,n,i,e,o))});var y=m?void 0:(p?d?l:f:d?S:u)(e);return ie(y||e,function(r,i){y&&(i=r,r=e[i]),Se(s,i,baseClone(r,t,n,i,e,o))}),s}var Wt=4;function clone(e){return baseClone(e,Wt)}function compact(e){for(var t=-1,n=e==null?0:e.length,r=0,i=[];++t<n;){var a=e[t];a&&(i[r++]=a)}return i}function arrayAggregator(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}function baseAggregator(e,t,n,r){return c(e,function(e,i,a){t(r,e,n(e),a)}),r}function createAggregator(e,t){return function(n,r){var i=R(n)?arrayAggregator:baseAggregator,a=t?t():{};return i(n,e,s(r,2),a)}}var Gt=Object.prototype,Kt=Gt.hasOwnProperty,qt=we(function(e,t){e=Object(e);var n=-1,i=t.length,a=i>2?t[2]:void 0;for(a&&r(t[0],t[1],a)&&(i=1);++n<i;)for(var o=t[n],s=S(o),c=-1,l=s.length;++c<l;){var u=s[c],d=e[u];(d===void 0||de(d,Gt[u])&&!Kt.call(e,u))&&(e[u]=o[u])}return e});function isArrayLikeObject(e){return le(e)&&oe(e)}function arrayIncludesWith(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}var Jt=200;function baseDifference(e,t,n,r){var a=-1,o=arrayIncludes,s=!0,c=e.length,l=[],u=t.length;if(!c)return l;n&&(t=he(t,T(n))),r?(o=arrayIncludesWith,s=!1):t.length>=Jt&&(o=i,s=!1,t=new fe(t));outer:for(;++a<c;){var d=e[a],f=n==null?d:n(d);if(d=r||d!==0?d:0,s&&f===f){for(var p=u;p--;)if(t[p]===f)continue outer;l.push(d)}else o(t,f,r)||l.push(d)}return l}var Yt=we(function(e,t){return isArrayLikeObject(e)?baseDifference(e,baseFlatten(t,1,isArrayLikeObject,!0)):[]});function last(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}function drop(e,t,n){var r=e==null?0:e.length;return r?(t=n||t===void 0?1:ae(t),baseSlice(e,t<0?0:t,r)):[]}function dropRight(e,t,n){var r=e==null?0:e.length;return r?(t=n||t===void 0?1:ae(t),t=r-t,baseSlice(e,0,t<0?0:t)):[]}function baseFilter(e,t){var n=[];return c(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function filter(e,t){return(R(e)?Oe:baseFilter)(e,s(t,3))}function createFind(e){return function(t,predicate,n){var r=Object(t);if(!oe(t)){var i=s(predicate,3);t=u(t),predicate=function(e){return i(r[e],e,r)}}var a=e(t,predicate,n);return a>-1?r[i?t[a]:a]:void 0}}var Xt=Math.max;function findIndex(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:ae(n);return i<0&&(i=Xt(r+i,0)),Ce(e,s(t,3),i)}var K=createFind(findIndex);function head(e){return e&&e.length?e[0]:void 0}function flatMap(e,t){return baseFlatten(o(e,t),1)}var Zt=Object.prototype.hasOwnProperty,Qt=createAggregator(function(e,t,n){Zt.call(e,n)?e[n].push(t):re(e,n,[t])}),$t=Object.prototype.hasOwnProperty;function baseHas(e,t){return e!=null&&$t.call(e,t)}function has(e,t){return e!=null&&v(e,t,baseHas)}var en=Math.max;function indexOf(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:ae(n);return i<0&&(i=en(r+i,0)),ve(e,t,i)}var tn=`[object Map]`,nn=`[object Set]`,rn=Object.prototype.hasOwnProperty;function isEmpty(e){if(e==null)return!0;if(oe(e)&&(R(e)||typeof e==`string`||typeof e.splice==`function`||ne(e)||be(e)||E(e)))return!e.length;var t=_(e);if(t==tn||t==nn)return!e.size;if(ee(e))return!m(e).length;for(var n in e)if(rn.call(e,n))return!1;return!0}function isUndefined(e){return e===void 0}var an=`Expected a function`;function negate(e){if(typeof e!=`function`)throw TypeError(an);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function baseReduce(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function reduce(e,t,n){var r=R(e)?arrayReduce:baseReduce,i=arguments.length<3;return r(e,s(t,4),n,i,c)}function reject(e,t){return(R(e)?Oe:baseFilter)(e,negate(s(t,3)))}var on=y&&1/pe(new y([,-0]))[1]==1/0?function(e){return new y(e)}:noop,sn=200;function baseUniq(e,t,n){var r=-1,a=arrayIncludes,o=e.length,s=!0,c=[],l=c;if(n)s=!1,a=arrayIncludesWith;else if(o>=sn){var u=t?null:on(e);if(u)return pe(u);s=!1,a=i,l=new fe}else l=t?[]:c;outer:for(;++r<o;){var d=e[r],f=t?t(d):d;if(d=n||d!==0?d:0,s&&f===f){for(var p=l.length;p--;)if(l[p]===f)continue outer;t&&l.push(f),c.push(d)}else a(l,f,n)||(l!==c&&l.push(f),c.push(d))}return c}function uniq(e){return e&&e.length?baseUniq(e):[]}var RestWalker=class{walk(e,t=[]){x(e.definition,(n,r)=>{let i=drop(e.definition,r+1);if(n instanceof j)this.walkProdRef(n,i,t);else if(n instanceof P)this.walkTerminal(n,i,t);else if(n instanceof z)this.walkFlat(n,i,t);else if(n instanceof F)this.walkOption(n,i,t);else if(n instanceof M)this.walkAtLeastOne(n,i,t);else if(n instanceof N)this.walkAtLeastOneSep(n,i,t);else if(n instanceof ye)this.walkManySep(n,i,t);else if(n instanceof V)this.walkMany(n,i,t);else if(n instanceof L)this.walkOr(n,i,t);else throw Error(`non exhaustive match`)})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){let r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){let r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){let r=[new F({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){let r=restForRepetitionWithSeparator(e,t,n);this.walk(e,r)}walkMany(e,t,n){let r=[new F({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){let r=restForRepetitionWithSeparator(e,t,n);this.walk(e,r)}walkOr(e,t,n){let r=t.concat(n);x(e.definition,e=>{let t=new z({definition:[e]});this.walk(t,r)})}};function restForRepetitionWithSeparator(e,t,n){return[new F({definition:[new P({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function first(e){if(e instanceof j)return first(e.referencedRule);if(e instanceof P)return firstForTerminal(e);if(ue(e))return firstForSequence(e);if(ge(e))return firstForBranching(e);throw Error(`non exhaustive match`)}function firstForSequence(e){let t=[],n=e.definition,r=0,i=n.length>r,a,o=!0;for(;i&&o;)a=n[r],o=xe(a),t=t.concat(first(a)),r+=1,i=n.length>r;return uniq(t)}function firstForBranching(e){return uniq(flatten(o(e.definition,e=>first(e))))}function firstForTerminal(e){return[e.terminalType]}const cn=`_~IN~_`;var ResyncFollowsWalker=class extends RestWalker{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){let r=buildBetweenProdsFollowPrefix(e.referencedRule,e.idx)+this.topProd.name,i=first(new z({definition:t.concat(n)}));this.follows[r]=i}};function computeAllProdsFollows(e){let t={};return x(e,e=>{w(t,new ResyncFollowsWalker(e).startWalking())}),t}function buildBetweenProdsFollowPrefix(e,t){return e.name+t+cn}let ln={};const un=new t;function getRegExpAst(e){let t=e.toString();if(ln.hasOwnProperty(t))return ln[t];{let e=un.pattern(t);return ln[t]=e,e}}function clearRegExpParserCache(){ln={}}const dn=`Complement Sets are not supported for first char optimization`,fn=`Unable to use "first char" lexer optimizations:
2
+ `;function getOptimizedStartCodesIndices(e,t=!1){try{let t=getRegExpAst(e);return firstCharOptimizedIndices(t.value,{},t.flags.ignoreCase)}catch(n){if(n.message===dn)t&&ke(`${fn}\tUnable to optimize: < ${e.toString()} >\n Complement Sets cannot be automatically optimized.
3
+ This will disable the lexer's first char optimizations.
4
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n=``;t&&(n=`
5
+ This will disable the lexer's first char optimizations.
6
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),je(`${fn}\n\tFailed parsing: < ${e.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function firstCharOptimizedIndices(e,t,n){switch(e.type){case`Disjunction`:for(let r=0;r<e.value.length;r++)firstCharOptimizedIndices(e.value[r],t,n);break;case`Alternative`:let r=e.value;for(let e=0;e<r.length;e++){let i=r[e];switch(i.type){case`EndAnchor`:case`GroupBackReference`:case`Lookahead`:case`NegativeLookahead`:case`StartAnchor`:case`WordBoundary`:case`NonWordBoundary`:continue}let a=i;switch(a.type){case`Character`:addOptimizedIdxToResult(a.value,t,n);break;case`Set`:if(a.complement===!0)throw Error(dn);x(a.value,e=>{if(typeof e==`number`)addOptimizedIdxToResult(e,t,n);else{let r=e;if(n===!0)for(let e=r.from;e<=r.to;e++)addOptimizedIdxToResult(e,t,n);else{for(let e=r.from;e<=r.to&&e<256;e++)addOptimizedIdxToResult(e,t,n);if(r.to>=256){let e=r.from>=256?r.from:256,n=r.to,i=charCodeToOptimizedIndex(e),a=charCodeToOptimizedIndex(n);for(let e=i;e<=a;e++)t[e]=e}}}});break;case`Group`:firstCharOptimizedIndices(a.value,t,n);break;default:throw Error(`Non Exhaustive Match`)}let o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type===`Group`&&isWholeOptional(a)===!1||a.type!==`Group`&&o===!1)break}break;default:throw Error(`non exhaustive match!`)}return U(t)}function addOptimizedIdxToResult(e,t,n){let r=charCodeToOptimizedIndex(e);t[r]=r,n===!0&&handleIgnoreCase(e,t)}function handleIgnoreCase(e,t){let n=String.fromCharCode(e),r=n.toUpperCase();if(r!==n){let e=charCodeToOptimizedIndex(r.charCodeAt(0));t[e]=e}else{let e=n.toLowerCase();if(e!==n){let n=charCodeToOptimizedIndex(e.charCodeAt(0));t[n]=n}}}function findCode(e,t){return K(e.value,e=>{if(typeof e==`number`)return A(t,e);{let n=e;return K(t,e=>n.from<=e&&e<=n.to)!==void 0}})}function isWholeOptional(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?R(e.value)?H(e.value,isWholeOptional):isWholeOptional(e.value):!1}var CharCodeFinder=class extends n{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case`Lookahead`:this.visitLookahead(e);return;case`NegativeLookahead`:this.visitNegativeLookahead(e);return}super.visitChildren(e)}}visitCharacter(e){A(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?findCode(e,this.targetCharCodes)===void 0&&(this.found=!0):findCode(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function canMatchCharCode(e,t){if(t instanceof RegExp){let n=getRegExpAst(t),r=new CharCodeFinder(e);return r.visit(n),r.found}else return K(t,t=>A(e,t.charCodeAt(0)))!==void 0}const q=`PATTERN`,pn=`defaultMode`;let mn=typeof RegExp(`(?:)`).sticky==`boolean`;function analyzeTokenTypes(e,t){t=qt(t,{useSticky:mn,debug:!1,safeMode:!1,positionTracking:`full`,lineTerminatorCharacters:[`\r`,`
7
+ `],tracer:(e,t)=>t()});let n=t.tracer;n(`initCharCodeToOptimizedIndexMap`,()=>{initCharCodeToOptimizedIndexMap()});let r;n(`Reject Lexer.NA`,()=>{r=reject(e,e=>e[q]===Lexer.NA)});let i=!1,a;n(`Transform Patterns`,()=>{i=!1,a=o(r,e=>{let n=e[q];if(W(n)){let e=n.source;return e.length===1&&e!==`^`&&e!==`$`&&e!==`.`&&!n.ignoreCase?e:e.length===2&&e[0]===`\\`&&!A([`d`,`D`,`s`,`S`,`t`,`r`,`n`,`t`,`0`,`c`,`b`,`B`,`f`,`v`,`w`,`W`],e[1])?e[1]:t.useSticky?addStickyFlag(n):addStartOfInput(n)}else if(I(n))return i=!0,{exec:n};else if(typeof n==`object`)return i=!0,n;else if(typeof n==`string`){if(n.length===1)return n;{let e=n.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`),r=new RegExp(e);return t.useSticky?addStickyFlag(r):addStartOfInput(r)}}else throw Error(`non exhaustive match`)})});let s,c,l,u,d;n(`misc mapping`,()=>{s=o(r,e=>e.tokenTypeIdx),c=o(r,e=>{let t=e.GROUP;if(t!==Lexer.SKIPPED){if(b(t))return t;if(isUndefined(t))return!1;throw Error(`non exhaustive match`)}}),l=o(r,e=>{let t=e.LONGER_ALT;if(t)return R(t)?o(t,e=>indexOf(r,e)):[indexOf(r,t)]}),u=o(r,e=>e.PUSH_MODE),d=o(r,e=>has(e,`POP_MODE`))});let f;n(`Line Terminator Handling`,()=>{let e=getCharCodes(t.lineTerminatorCharacters);f=o(r,e=>!1),t.positionTracking!==`onlyOffset`&&(f=o(r,t=>has(t,`LINE_BREAKS`)?!!t.LINE_BREAKS:checkLineBreaksIssues(t,e)===!1&&canMatchCharCode(e,t.PATTERN)))});let p,m,h,g;n(`Misc Mapping #2`,()=>{p=o(r,isCustomPattern),m=o(a,isShortPattern),h=reduce(r,(e,t)=>{let n=t.GROUP;return b(n)&&n!==Lexer.SKIPPED&&(e[n]=[]),e},{}),g=o(a,(e,t)=>({pattern:a[t],longerAlt:l[t],canLineTerminator:f[t],isCustom:p[t],short:m[t],group:c[t],push:u[t],pop:d[t],tokenTypeIdx:s[t],tokenType:r[t]}))});let _=!0,v=[];return t.safeMode||n(`First Char Optimization`,()=>{v=reduce(r,(e,n,r)=>{if(typeof n.PATTERN==`string`)addToMapOfArrays(e,charCodeToOptimizedIndex(n.PATTERN.charCodeAt(0)),g[r]);else if(R(n.START_CHARS_HINT)){let t;x(n.START_CHARS_HINT,n=>{let i=charCodeToOptimizedIndex(typeof n==`string`?n.charCodeAt(0):n);t!==i&&(t=i,addToMapOfArrays(e,i,g[r]))})}else if(W(n.PATTERN))if(n.PATTERN.unicode)_=!1,t.ensureOptimizations&&je(`${fn}\tUnable to analyze < ${n.PATTERN.toString()} > pattern.\n The regexp unicode flag is not currently supported by the regexp-to-ast library.
8
+ This will disable the lexer's first char optimizations.
9
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let i=getOptimizedStartCodesIndices(n.PATTERN,t.ensureOptimizations);isEmpty(i)&&(_=!1),x(i,t=>{addToMapOfArrays(e,t,g[r])})}else t.ensureOptimizations&&je(`${fn}\tTokenType: <${n.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n This will disable the lexer's first char optimizations.
10
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),_=!1;return e},[])}),{emptyGroups:h,patternIdxToConfig:g,charCodeToPatternIdxToConfig:v,hasCustom:i,canBeOptimized:_}}function validatePatterns(e,t){let n=[],r=findMissingPatterns(e);n=n.concat(r.errors);let i=findInvalidPatterns(r.valid),a=i.valid;return n=n.concat(i.errors),n=n.concat(validateRegExpPattern(a)),n=n.concat(findInvalidGroupType(a)),n=n.concat(findModesThatDoNotExist(a,t)),n=n.concat(findUnreachablePatterns(a)),n}function validateRegExpPattern(e){let t=[],n=filter(e,e=>W(e[q]));return t=t.concat(findEndOfInputAnchor(n)),t=t.concat(findStartOfInputAnchor(n)),t=t.concat(findUnsupportedFlags(n)),t=t.concat(findDuplicatePatterns(n)),t=t.concat(findEmptyMatchRegExps(n)),t}function findMissingPatterns(e){let t=filter(e,e=>!has(e,q));return{errors:o(t,e=>({message:`Token Type: ->`+e.name+`<- missing static 'PATTERN' property`,type:J.MISSING_PATTERN,tokenTypes:[e]})),valid:Yt(e,t)}}function findInvalidPatterns(e){let t=filter(e,e=>{let t=e[q];return!W(t)&&!I(t)&&!has(t,`exec`)&&!b(t)});return{errors:o(t,e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.`,type:J.INVALID_PATTERN,tokenTypes:[e]})),valid:Yt(e,t)}}const hn=/[^\\][$]/;function findEndOfInputAnchor(e){class EndAnchorFinder extends n{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}return o(filter(e,e=>{let t=e.PATTERN;try{let e=getRegExpAst(t),n=new EndAnchorFinder;return n.visit(e),n.found}catch{return hn.test(t.source)}}),e=>({message:`Unexpected RegExp Anchor Error:
11
+ Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
12
+ See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:J.EOI_ANCHOR_FOUND,tokenTypes:[e]}))}function findEmptyMatchRegExps(e){return o(filter(e,e=>e.PATTERN.test(``)),e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' must not match an empty string`,type:J.EMPTY_MATCH_PATTERN,tokenTypes:[e]}))}const gn=/[^\\[][\^]|^\^/;function findStartOfInputAnchor(e){class StartAnchorFinder extends n{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}return o(filter(e,e=>{let t=e.PATTERN;try{let e=getRegExpAst(t),n=new StartAnchorFinder;return n.visit(e),n.found}catch{return gn.test(t.source)}}),e=>({message:`Unexpected RegExp Anchor Error:
13
+ Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
14
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:J.SOI_ANCHOR_FOUND,tokenTypes:[e]}))}function findUnsupportedFlags(e){return o(filter(e,e=>{let t=e[q];return t instanceof RegExp&&(t.multiline||t.global)}),e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' may NOT contain global('g') or multiline('m')`,type:J.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}))}function findDuplicatePatterns(e){let t=[],n=o(e,n=>reduce(e,(e,r)=>n.PATTERN.source===r.PATTERN.source&&!A(t,r)&&r.PATTERN!==Lexer.NA?(t.push(r),e.push(r),e):e,[]));return n=compact(n),o(filter(n,e=>e.length>1),e=>{let t=o(e,e=>e.name);return{message:`The same RegExp pattern ->${head(e).PATTERN}<-has been used in all of the following Token Types: ${t.join(`, `)} <-`,type:J.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}})}function findInvalidGroupType(e){return o(filter(e,e=>{if(!has(e,`GROUP`))return!1;let t=e.GROUP;return t!==Lexer.SKIPPED&&t!==Lexer.NA&&!b(t)}),e=>({message:`Token Type: ->`+e.name+`<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String`,type:J.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}))}function findModesThatDoNotExist(e,t){return o(filter(e,e=>e.PUSH_MODE!==void 0&&!A(t,e.PUSH_MODE)),e=>({message:`Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,type:J.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}))}function findUnreachablePatterns(e){let t=[],n=reduce(e,(e,t,n)=>{let r=t.PATTERN;return r===Lexer.NA||(b(r)?e.push({str:r,idx:n,tokenType:t}):W(r)&&noMetaChar(r)&&e.push({str:r.source,idx:n,tokenType:t})),e},[]);return x(e,(e,r)=>{x(n,({str:n,idx:i,tokenType:a})=>{if(r<i&&testTokenType(n,e.PATTERN)){let n=`Token: ->${a.name}<- can never be matched.\nBecause it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:n,type:J.UNREACHABLE_PATTERN,tokenTypes:[e,a]})}})}),t}function testTokenType(e,t){if(W(t)){let n=t.exec(e);return n!==null&&n.index===0}else if(I(t))return t(e,0,[],{});else if(has(t,`exec`))return t.exec(e,0,[],{});else if(typeof t==`string`)return t===e;else throw Error(`non exhaustive match`)}function noMetaChar(e){return K([`.`,`\\`,`[`,`]`,`|`,`^`,`$`,`(`,`)`,`?`,`*`,`+`,`{`],t=>e.source.indexOf(t)!==-1)===void 0}function addStartOfInput(e){let t=e.ignoreCase?`i`:``;return RegExp(`^(?:${e.source})`,t)}function addStickyFlag(e){let t=e.ignoreCase?`iy`:`y`;return RegExp(`${e.source}`,t)}function performRuntimeChecks(e,t,n){let r=[];return has(e,`defaultMode`)||r.push({message:`A MultiMode Lexer cannot be initialized without a <`+pn+`> property in its definition
15
+ `,type:J.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),has(e,`modes`)||r.push({message:`A MultiMode Lexer cannot be initialized without a <modes> property in its definition
16
+ `,type:J.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),has(e,`modes`)&&has(e,`defaultMode`)&&!has(e.modes,e.defaultMode)&&r.push({message:`A MultiMode Lexer cannot be initialized with a ${pn}: <${e.defaultMode}>which does not exist\n`,type:J.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),has(e,`modes`)&&x(e.modes,(e,t)=>{x(e,(n,i)=>{isUndefined(n)?r.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${t}> at index: <${i}>\n`,type:J.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):has(n,`LONGER_ALT`)&&x(R(n.LONGER_ALT)?n.LONGER_ALT:[n.LONGER_ALT],i=>{!isUndefined(i)&&!A(e,i)&&r.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${i.name}> on token <${n.name}> outside of mode <${t}>\n`,type:J.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),r}function performWarningRuntimeChecks(e,t,n){let r=[],i=!1,a=reject(compact(flatten(U(e.modes))),e=>e[q]===Lexer.NA),o=getCharCodes(n);return t&&x(a,e=>{let t=checkLineBreaksIssues(e,o);if(t!==!1){let n={message:buildLineBreakIssueMessage(e,t),type:t.issue,tokenType:e};r.push(n)}else has(e,`LINE_BREAKS`)?e.LINE_BREAKS===!0&&(i=!0):canMatchCharCode(o,e.PATTERN)&&(i=!0)}),t&&!i&&r.push({message:`Warning: No LINE_BREAKS Found.
17
+ This Lexer has been defined to track line and column information,
18
+ But none of the Token Types can be identified as matching a line terminator.
19
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
20
+ for details.`,type:J.NO_LINE_BREAKS_FLAGS}),r}function cloneEmptyGroups(e){let t={};return x(u(e),n=>{let r=e[n];if(R(r))t[n]=[];else throw Error(`non exhaustive match`)}),t}function isCustomPattern(e){let t=e.PATTERN;if(W(t))return!1;if(I(t)||has(t,`exec`))return!0;if(b(t))return!1;throw Error(`non exhaustive match`)}function isShortPattern(e){return b(e)&&e.length===1?e.charCodeAt(0):!1}const _n={test:function(e){let t=e.length;for(let n=this.lastIndex;n<t;n++){let t=e.charCodeAt(n);if(t===10)return this.lastIndex=n+1,!0;if(t===13)return e.charCodeAt(n+1)===10?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0};function checkLineBreaksIssues(e,t){if(has(e,`LINE_BREAKS`))return!1;if(W(e.PATTERN)){try{canMatchCharCode(t,e.PATTERN)}catch(e){return{issue:J.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}else if(b(e.PATTERN))return!1;else if(isCustomPattern(e))return{issue:J.CUSTOM_LINE_BREAK};else throw Error(`non exhaustive match`)}function buildLineBreakIssueMessage(e,t){if(t.issue===J.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
21
+ \tThe problem is in the <${e.name}> Token Type\n\t Root cause: ${t.errMsg}.\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===J.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
22
+ \tThe problem is in the <${e.name}> Token Type\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error(`non exhaustive match`)}function getCharCodes(e){return o(e,e=>b(e)?e.charCodeAt(0):e)}function addToMapOfArrays(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}let vn=[];function charCodeToOptimizedIndex(e){return e<256?e:vn[e]}function initCharCodeToOptimizedIndexMap(){if(isEmpty(vn)){vn=Array(65536);for(let e=0;e<65536;e++)vn[e]=e>255?255+~~(e/255):e}}function tokenStructuredMatcher(e,t){let n=e.tokenTypeIdx;return n===t.tokenTypeIdx?!0:t.isParent===!0&&t.categoryMatchesMap[n]===!0}function tokenStructuredMatcherNoCategories(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}let yn=1;const bn={};function augmentTokenTypes(e){let t=expandCategories(e);assignTokenDefaultProps(t),assignCategoriesMapProp(t),assignCategoriesTokensProp(t),x(t,e=>{e.isParent=e.categoryMatches.length>0})}function expandCategories(e){let t=clone(e),n=e,r=!0;for(;r;){n=compact(flatten(o(n,e=>e.CATEGORIES)));let e=Yt(n,t);t=t.concat(e),isEmpty(e)?r=!1:n=e}return t}function assignTokenDefaultProps(e){x(e,e=>{hasShortKeyProperty(e)||(bn[yn]=e,e.tokenTypeIdx=yn++),hasCategoriesProperty(e)&&!R(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),hasCategoriesProperty(e)||(e.CATEGORIES=[]),hasExtendingTokensTypesProperty(e)||(e.categoryMatches=[]),hasExtendingTokensTypesMapProperty(e)||(e.categoryMatchesMap={})})}function assignCategoriesTokensProp(e){x(e,e=>{e.categoryMatches=[],x(e.categoryMatchesMap,(t,n)=>{e.categoryMatches.push(bn[n].tokenTypeIdx)})})}function assignCategoriesMapProp(e){x(e,e=>{singleAssignCategoriesToksMap([],e)})}function singleAssignCategoriesToksMap(e,t){x(e,e=>{t.categoryMatchesMap[e.tokenTypeIdx]=!0}),x(t.CATEGORIES,n=>{let r=e.concat(t);A(r,n)||singleAssignCategoriesToksMap(r,n)})}function hasShortKeyProperty(e){return has(e,`tokenTypeIdx`)}function hasCategoriesProperty(e){return has(e,`CATEGORIES`)}function hasExtendingTokensTypesProperty(e){return has(e,`categoryMatches`)}function hasExtendingTokensTypesMapProperty(e){return has(e,`categoryMatchesMap`)}function isTokenType(e){return has(e,`tokenTypeIdx`)}const xn={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,n,r,i){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters.`}};var J;(function(e){e[e.MISSING_PATTERN=0]=`MISSING_PATTERN`,e[e.INVALID_PATTERN=1]=`INVALID_PATTERN`,e[e.EOI_ANCHOR_FOUND=2]=`EOI_ANCHOR_FOUND`,e[e.UNSUPPORTED_FLAGS_FOUND=3]=`UNSUPPORTED_FLAGS_FOUND`,e[e.DUPLICATE_PATTERNS_FOUND=4]=`DUPLICATE_PATTERNS_FOUND`,e[e.INVALID_GROUP_TYPE_FOUND=5]=`INVALID_GROUP_TYPE_FOUND`,e[e.PUSH_MODE_DOES_NOT_EXIST=6]=`PUSH_MODE_DOES_NOT_EXIST`,e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]=`MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE`,e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]=`MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY`,e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]=`MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST`,e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]=`LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED`,e[e.SOI_ANCHOR_FOUND=11]=`SOI_ANCHOR_FOUND`,e[e.EMPTY_MATCH_PATTERN=12]=`EMPTY_MATCH_PATTERN`,e[e.NO_LINE_BREAKS_FLAGS=13]=`NO_LINE_BREAKS_FLAGS`,e[e.UNREACHABLE_PATTERN=14]=`UNREACHABLE_PATTERN`,e[e.IDENTIFY_TERMINATOR=15]=`IDENTIFY_TERMINATOR`,e[e.CUSTOM_LINE_BREAK=16]=`CUSTOM_LINE_BREAK`,e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]=`MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE`})(J||={});const Sn={deferDefinitionErrorsHandling:!1,positionTracking:`full`,lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
23
+ `,`\r`],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:xn,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Sn);var Lexer=class{constructor(e,t=Sn){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(e,t)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=Ae(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}else return t()},typeof t==`boolean`)throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
24
+ a boolean 2nd argument is no longer supported`);this.config=w({},Sn,t);let n=this.config.traceInitPerf;n===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof n==`number`&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT(`Lexer Constructor`,()=>{let n,r=!0;this.TRACE_INIT(`Lexer Config handling`,()=>{if(this.config.lineTerminatorsPattern===Sn.lineTerminatorsPattern)this.config.lineTerminatorsPattern=_n;else if(this.config.lineTerminatorCharacters===Sn.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
25
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error(`"safeMode" and "ensureOptimizations" flags are mutually exclusive.`);this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),R(e)?n={modes:{defaultMode:clone(e)},defaultMode:pn}:(r=!1,n=clone(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT(`performRuntimeChecks`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(performRuntimeChecks(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT(`performWarningRuntimeChecks`,()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(performWarningRuntimeChecks(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},x(n.modes,(e,t)=>{n.modes[t]=reject(e,e=>isUndefined(e))});let i=u(n.modes);if(x(n.modes,(e,n)=>{this.TRACE_INIT(`Mode: <${n}> processing`,()=>{if(this.modes.push(n),this.config.skipValidations===!1&&this.TRACE_INIT(`validatePatterns`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(validatePatterns(e,i))}),isEmpty(this.lexerDefinitionErrors)){augmentTokenTypes(e);let r;this.TRACE_INIT(`analyzeTokenTypes`,()=>{r=analyzeTokenTypes(e,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[n]=r.patternIdxToConfig,this.charCodeToPatternIdxToConfig[n]=r.charCodeToPatternIdxToConfig,this.emptyGroups=w({},this.emptyGroups,r.emptyGroups),this.hasCustom=r.hasCustom||this.hasCustom,this.canModeBeOptimized[n]=r.canBeOptimized}})}),this.defaultMode=n.defaultMode,!isEmpty(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let e=o(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
26
+ `);throw Error(`Errors detected in definition of Lexer:
27
+ `+e)}x(this.lexerDefinitionWarning,e=>{ke(e.message)}),this.TRACE_INIT(`Choosing sub-methods implementations`,()=>{if(mn?(this.chopInput=Te,this.match=this.matchWithTest):(this.updateLastIndex=noop,this.match=this.matchWithExec),r&&(this.handleModes=noop),this.trackStartLines===!1&&(this.computeNewColumn=Te),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=noop),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT(`Failed Optimization Warnings`,()=>{let e=reduce(this.canModeBeOptimized,(e,t,n)=>(t===!1&&e.push(n),e),[]);if(t.ensureOptimizations&&!isEmpty(e))throw Error(`Lexer Modes: < ${e.join(`, `)} > cannot be optimized.\n Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
28
+ Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT(`clearRegExpParserCache`,()=>{clearRegExpParserCache()}),this.TRACE_INIT(`toFastProperties`,()=>{Me(this)})})}tokenize(e,t=this.defaultMode){if(!isEmpty(this.lexerDefinitionErrors)){let e=o(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
29
+ `);throw Error(`Unable to Tokenize because Errors detected in definition of Lexer:
30
+ `+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=e,v=_.length,y=0,ee=0,te=this.hasCustom?0:Math.floor(e.length/10),b=Array(te),x=[],S=this.trackStartLines?1:void 0,C=this.trackStartLines?1:void 0,w=cloneEmptyGroups(this.emptyGroups),ne=this.trackStartLines,T=this.config.lineTerminatorsPattern,E=0,D=[],O=[],k=[],re=[];Object.freeze(re);let A;function getPossiblePatternsSlow(){return D}function getPossiblePatternsOptimized(e){let t=charCodeToOptimizedIndex(e),n=O[t];return n===void 0?re:n}let pop_mode=e=>{if(k.length===1&&e.tokenType.PUSH_MODE===void 0){let t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);x.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{k.pop();let e=last(k);D=this.patternIdxToConfig[e],O=this.charCodeToPatternIdxToConfig[e],E=D.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;A=O&&t?getPossiblePatternsOptimized:getPossiblePatternsSlow}};function push_mode(e){k.push(e),O=this.charCodeToPatternIdxToConfig[e],D=this.patternIdxToConfig[e],E=D.length,E=D.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;A=O&&t?getPossiblePatternsOptimized:getPossiblePatternsSlow}push_mode.call(this,t);let j,ie=this.config.recoveryEnabled;for(;y<v;){s=null;let t=_.charCodeAt(y),te=A(t),O=te.length;for(n=0;n<O;n++){j=te[n];let r=j.pattern;c=null;let u=j.short;if(u===!1?j.isCustom===!0?(g=r.exec(_,y,b,w),g===null?s=null:(s=g[0],g.payload!==void 0&&(c=g.payload))):(this.updateLastIndex(r,y),s=this.match(r,e,y)):t===u&&(s=r),s!==null){if(o=j.longerAlt,o!==void 0){let t=o.length;for(i=0;i<t;i++){let t=D[o[i]],n=t.pattern;if(l=null,t.isCustom===!0?(g=n.exec(_,y,b,w),g===null?a=null:(a=g[0],g.payload!==void 0&&(l=g.payload))):(this.updateLastIndex(n,y),a=this.match(n,e,y)),a&&a.length>s.length){s=a,c=l,j=t;break}}}break}}if(s!==null){if(u=s.length,d=j.group,d!==void 0&&(f=j.tokenTypeIdx,p=this.createTokenInstance(s,y,f,j.tokenType,S,C,u),this.handlePayload(p,c),d===!1?ee=this.addToken(b,ee,p):w[d].push(p)),e=this.chopInput(e,u),y+=u,C=this.computeNewColumn(C,u),ne===!0&&j.canLineTerminator===!0){let e=0,t,n;T.lastIndex=0;do t=T.test(s),t===!0&&(n=T.lastIndex-1,e++);while(t===!0);e!==0&&(S+=e,C=u-n,this.updateTokenEndLineColumnLocation(p,d,n,e,S,C,u))}this.handleModes(j,pop_mode,push_mode,p)}else{let t=y,n=S,i=C,a=ie===!1;for(;a===!1&&y<v;)for(e=this.chopInput(e,1),y++,r=0;r<E;r++){let t=D[r],n=t.pattern,i=t.short;if(i===!1?t.isCustom===!0?a=n.exec(_,y,b,w)!==null:(this.updateLastIndex(n,y),a=n.exec(e)!==null):_.charCodeAt(y)===i&&(a=!0),a===!0)break}if(m=y-t,C=this.computeNewColumn(C,m),h=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(_,t,m,n,i),x.push({offset:t,line:n,column:i,length:m,message:h}),ie===!1)break}}return this.hasCustom||(b.length=ee),{tokens:b,groups:w,errors:x}}handleModes(e,t,n,r){if(e.pop===!0){let i=e.push;t(r),i!==void 0&&n.call(this,i)}else e.push!==void 0&&n.call(this,e.push)}chopInput(e,t){return e.substring(t)}updateLastIndex(e,t){e.lastIndex=t}updateTokenEndLineColumnLocation(e,t,n,r,i,a,o){let s,c;t!==void 0&&(s=n===o-1,c=s?-1:0,r===1&&s===!0||(e.endLine=i+c,e.endColumn=a-1+-c))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,n,r){return{image:e,startOffset:t,tokenTypeIdx:n,tokenType:r}}createStartOnlyToken(e,t,n,r,i,a){return{image:e,startOffset:t,startLine:i,startColumn:a,tokenTypeIdx:n,tokenType:r}}createFullToken(e,t,n,r,i,a,o){return{image:e,startOffset:t,endOffset:t+o-1,startLine:i,endLine:i,startColumn:a,endColumn:a+o-1,tokenTypeIdx:n,tokenType:r}}addTokenUsingPush(e,t,n){return e.push(n),t}addTokenUsingMemberAccess(e,t,n){return e[t]=n,t++,t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){t!==null&&(e.payload=t)}matchWithTest(e,t,n){return e.test(t)===!0?t.substring(n,e.lastIndex):null}matchWithExec(e,t){let n=e.exec(t);return n===null?null:n[0]}};Lexer.SKIPPED=`This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.`,Lexer.NA=/NOT_APPLICABLE/;function tokenLabel(e){return hasTokenLabel(e)?e.LABEL:e.name}function hasTokenLabel(e){return b(e.LABEL)&&e.LABEL!==``}const Cn=`categories`,wn=`label`,Tn=`group`,En=`push_mode`,Dn=`pop_mode`,On=`longer_alt`,kn=`line_breaks`,An=`start_chars_hint`;function createToken(e){return createTokenInternal(e)}function createTokenInternal(e){let t=e.pattern,n={};if(n.name=e.name,isUndefined(t)||(n.PATTERN=t),has(e,`parent`))throw`The parent property is no longer supported.
31
+ See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return has(e,Cn)&&(n.CATEGORIES=e[Cn]),augmentTokenTypes([n]),has(e,wn)&&(n.LABEL=e[wn]),has(e,Tn)&&(n.GROUP=e[Tn]),has(e,Dn)&&(n.POP_MODE=e[Dn]),has(e,En)&&(n.PUSH_MODE=e[En]),has(e,On)&&(n.LONGER_ALT=e[On]),has(e,kn)&&(n.LINE_BREAKS=e[kn]),has(e,An)&&(n.START_CHARS_HINT=e[An]),n}const Y=createToken({name:`EOF`,pattern:Lexer.NA});augmentTokenTypes([Y]);function createTokenInstance(e,t,n,r,i,a,o,s){return{image:t,startOffset:n,endOffset:r,startLine:i,endLine:a,startColumn:o,endColumn:s,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function tokenMatcher(e,t){return tokenStructuredMatcher(e,t)}const jn={buildMismatchTokenMessage({expected:e,actual:t,previous:n,ruleName:r}){return`Expecting ${hasTokenLabel(e)?`--> ${tokenLabel(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:t}){return`Redundant input, expecting EOF but found: `+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:n,customUserDescription:r,ruleName:i}){let a=`
32
+ but found: '`+head(t).image+`'`;return r?`Expecting: `+r+a:`Expecting: one of these possible Token sequences:\n${o(o(reduce(e,(e,t)=>e.concat(t),[]),e=>`[${o(e,e=>tokenLabel(e)).join(`, `)}]`),(e,t)=>` ${t+1}. ${e}`).join(`
33
+ `)}`+a},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:n,ruleName:r}){let i=`
34
+ but found: '`+head(t).image+`'`;return n?`Expecting: `+n+i:`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::\n <${o(e,e=>`[${o(e,e=>tokenLabel(e)).join(`,`)}]`).join(` ,`)}>`+i}};Object.freeze(jn);const Mn={buildRuleNotFoundError(e,t){return`Invalid grammar, reference to a rule which is not defined: ->`+t.nonTerminalName+`<-
35
+ inside top level rule: ->`+e.name+`<-`}},X={buildDuplicateFoundError(e,t){function getExtraProductionArgument(e){return e instanceof P?e.terminalType.name:e instanceof j?e.nonTerminalName:``}let n=e.name,r=head(t),i=r.idx,a=B(r),o=getExtraProductionArgument(r),s=`->${a}${i>0?i:``}<- ${o?`with argument: ->${o}<-`:``}
36
+ appears more than once (${t.length} times) in the top level rule: ->${n}<-.
37
+ For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
38
+ `;return s=s.replace(/[ \t]+/g,` `),s=s.replace(/\s\s+/g,`
39
+ `),s},buildNamespaceConflictError(e){return`Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=o(e.prefixPath,e=>tokenLabel(e)).join(`, `),n=e.alternation.idx===0?``:e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(` ,`)}> due to common lookahead prefix\nin <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details.`},buildAlternationAmbiguityError(e){let t=o(e.prefixPath,e=>tokenLabel(e)).join(`, `),n=e.alternation.idx===0?``:e.alternation.idx,r=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(` ,`)}> in <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\n`;return r+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
40
+ For Further details.`,r},buildEmptyRepetitionError(e){let t=B(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis could lead to an infinite loop.`},buildTokenNameError(e){return`deprecated`},buildEmptyAlternationError(e){return`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\nOnly the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives:\n<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\n has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name;return`Left Recursion found in grammar.\nrule: <${t}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${t} --> ${o(e.leftRecursionPath,e=>e.name).concat([t]).join(` --> `)}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return`deprecated`},buildDuplicateRuleNameError(e){let t;return t=e.topLevelRule instanceof me?e.topLevelRule.name:e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function resolveGrammar$1(e,t){let n=new GastRefResolverVisitor(e,t);return n.resolveRefs(),n.errors}e(resolveGrammar$1,`resolveGrammar`);var GastRefResolverVisitor=class extends k{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){x(U(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:$.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},AbstractNextPossibleTokensWalker=class extends RestWalker{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName=``,this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error(`The path does not start with the walker's top Rule!`);return this.ruleStack=clone(this.path.ruleStack).reverse(),this.occurrenceStack=clone(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}}updateExpectedNext(){isEmpty(this.ruleStack)?(this.nextProductionName=``,this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},NextAfterTokenWalker=class extends AbstractNextPossibleTokensWalker{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName=``,this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let e=new z({definition:t.concat(n)});this.possibleTokTypes=first(e),this.found=!0}}},AbstractNextTerminalAfterProductionWalker=class extends RestWalker{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},NextTerminalAfterManyWalker=class extends AbstractNextTerminalAfterProductionWalker{walkMany(e,t,n){if(e.idx===this.occurrence){let e=head(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof P&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}},NextTerminalAfterManySepWalker=class extends AbstractNextTerminalAfterProductionWalker{walkManySep(e,t,n){if(e.idx===this.occurrence){let e=head(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof P&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}},NextTerminalAfterAtLeastOneWalker=class extends AbstractNextTerminalAfterProductionWalker{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){let e=head(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof P&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}},NextTerminalAfterAtLeastOneSepWalker=class extends AbstractNextTerminalAfterProductionWalker{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){let e=head(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof P&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}};function possiblePathsFrom(e,t,n=[]){n=clone(n);let r=[],i=0;function remainingPathWith(t){return t.concat(drop(e,i+1))}function getAlternativesForProd(e){let i=possiblePathsFrom(remainingPathWith(e),t,n);return r.concat(i)}for(;n.length<t&&i<e.length;){let t=e[i];if(t instanceof z||t instanceof j)return getAlternativesForProd(t.definition);if(t instanceof F)r=getAlternativesForProd(t.definition);else if(t instanceof M)return getAlternativesForProd(t.definition.concat([new V({definition:t.definition})]));else if(t instanceof N)return getAlternativesForProd([new z({definition:t.definition}),new V({definition:[new P({terminalType:t.separator})].concat(t.definition)})]);else if(t instanceof ye)r=getAlternativesForProd(t.definition.concat([new V({definition:[new P({terminalType:t.separator})].concat(t.definition)})]));else if(t instanceof V)r=getAlternativesForProd(t.definition.concat([new V({definition:t.definition})]));else if(t instanceof L)return x(t.definition,e=>{isEmpty(e.definition)===!1&&(r=getAlternativesForProd(e.definition))}),r;else if(t instanceof P)n.push(t.terminalType);else throw Error(`non exhaustive match`);i++}return r.push({partialPath:n,suffixDef:drop(e,i)}),r}function nextPossibleTokensAfter(e,t,n,r){let i=`EXIT_NONE_TERMINAL`,a=[i],o=`EXIT_ALTERNATIVE`,s=!1,c=t.length,l=c-r-1,u=[],d=[];for(d.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!isEmpty(d);){let e=d.pop();if(e===o){s&&last(d).idx<=l&&d.pop();continue}let r=e.def,f=e.idx,p=e.ruleStack,m=e.occurrenceStack;if(isEmpty(r))continue;let h=r[0];if(h===i){let e={idx:f,def:drop(r),ruleStack:dropRight(p),occurrenceStack:dropRight(m)};d.push(e)}else if(h instanceof P)if(f<c-1){let e=f+1,i=t[e];if(n(i,h.terminalType)){let t={idx:e,def:drop(r),ruleStack:p,occurrenceStack:m};d.push(t)}}else if(f===c-1)u.push({nextTokenType:h.terminalType,nextTokenOccurrence:h.idx,ruleStack:p,occurrenceStack:m}),s=!0;else throw Error(`non exhaustive match`);else if(h instanceof j){let e=clone(p);e.push(h.nonTerminalName);let t=clone(m);t.push(h.idx);let n={idx:f,def:h.definition.concat(a,drop(r)),ruleStack:e,occurrenceStack:t};d.push(n)}else if(h instanceof F){let e={idx:f,def:drop(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t={idx:f,def:h.definition.concat(drop(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof M){let e=new V({definition:h.definition,idx:h.idx}),t={idx:f,def:h.definition.concat([e],drop(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof N){let e=new V({definition:[new P({terminalType:h.separator})].concat(h.definition),idx:h.idx}),t={idx:f,def:h.definition.concat([e],drop(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof ye){let e={idx:f,def:drop(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new V({definition:[new P({terminalType:h.separator})].concat(h.definition),idx:h.idx}),n={idx:f,def:h.definition.concat([t],drop(r)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof V){let e={idx:f,def:drop(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new V({definition:h.definition,idx:h.idx}),n={idx:f,def:h.definition.concat([t],drop(r)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof L)for(let e=h.definition.length-1;e>=0;e--){let t={idx:f,def:h.definition[e].definition.concat(drop(r)),ruleStack:p,occurrenceStack:m};d.push(t),d.push(o)}else if(h instanceof z)d.push({idx:f,def:h.definition.concat(drop(r)),ruleStack:p,occurrenceStack:m});else if(h instanceof me)d.push(expandTopLevelRule(h,f,p,m));else throw Error(`non exhaustive match`)}return u}function expandTopLevelRule(e,t,n,r){let i=clone(n);i.push(e.name);let a=clone(r);return a.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:a}}var Z;(function(e){e[e.OPTION=0]=`OPTION`,e[e.REPETITION=1]=`REPETITION`,e[e.REPETITION_MANDATORY=2]=`REPETITION_MANDATORY`,e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]=`REPETITION_MANDATORY_WITH_SEPARATOR`,e[e.REPETITION_WITH_SEPARATOR=4]=`REPETITION_WITH_SEPARATOR`,e[e.ALTERNATION=5]=`ALTERNATION`})(Z||={});function getProdType(e){if(e instanceof F||e===`Option`)return Z.OPTION;if(e instanceof V||e===`Repetition`)return Z.REPETITION;if(e instanceof M||e===`RepetitionMandatory`)return Z.REPETITION_MANDATORY;if(e instanceof N||e===`RepetitionMandatoryWithSeparator`)return Z.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof ye||e===`RepetitionWithSeparator`)return Z.REPETITION_WITH_SEPARATOR;if(e instanceof L||e===`Alternation`)return Z.ALTERNATION;throw Error(`non exhaustive match`)}function getLookaheadPaths(e){let{occurrence:t,rule:n,prodType:r,maxLookahead:i}=e,a=getProdType(r);return a===Z.ALTERNATION?getLookaheadPathsForOr(t,n,i):getLookaheadPathsForOptionalProd(t,n,a,i)}function buildLookaheadFuncForOr(e,t,n,r,i,a){let o=getLookaheadPathsForOr(e,t,n);return a(o,r,areTokenCategoriesNotUsed(o)?tokenStructuredMatcherNoCategories:tokenStructuredMatcher,i)}function buildLookaheadFuncForOptionalProd(e,t,n,r,i,a){let o=getLookaheadPathsForOptionalProd(e,t,i,n),s=areTokenCategoriesNotUsed(o)?tokenStructuredMatcherNoCategories:tokenStructuredMatcher;return a(o[0],s,r)}function buildAlternativesLookAheadFunc(e,t,n,r){let i=e.length,a=H(e,e=>H(e,e=>e.length===1));if(t)return function(t){let r=o(t,e=>e.GATE);for(let t=0;t<i;t++){let i=e[t],a=i.length,o=r[t];if(!(o!==void 0&&o.call(this)===!1))nextPath:for(let e=0;e<a;e++){let r=i[e],a=r.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),r[e])===!1)continue nextPath;return t}}};if(a&&!r){let t=reduce(o(e,e=>flatten(e)),(e,t,n)=>(x(t,t=>{has(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),x(t.categoryMatches,t=>{has(e,t)||(e[t]=n)})}),e),{});return function(){return t[this.LA(1).tokenTypeIdx]}}else return function(){for(let t=0;t<i;t++){let r=e[t],i=r.length;nextPath:for(let e=0;e<i;e++){let i=r[e],a=i.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),i[e])===!1)continue nextPath;return t}}}}function buildSingleAlternativeLookaheadFunction(e,t,n){let r=H(e,e=>e.length===1),i=e.length;if(r&&!n){let t=flatten(e);if(t.length===1&&isEmpty(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}else{let e=reduce(t,(e,t,n)=>(e[t.tokenTypeIdx]=!0,x(t.categoryMatches,t=>{e[t]=!0}),e),[]);return function(){return e[this.LA(1).tokenTypeIdx]===!0}}}else return function(){nextPath:for(let n=0;n<i;n++){let r=e[n],i=r.length;for(let e=0;e<i;e++)if(t(this.LA(e+1),r[e])===!1)continue nextPath;return!0}return!1}}var RestDefinitionFinderWalker=class extends RestWalker{constructor(e,t,n){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,n,r){return e.idx===this.targetOccurrence&&this.targetProdType===t?(this.restDef=n.concat(r),!0):!1}walkOption(e,t,n){this.checkIsTarget(e,Z.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,Z.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,Z.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,Z.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}},InsideDefinitionFinderVisitor=class extends k{constructor(e,t,n){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=n,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,Z.OPTION)}visitRepetition(e){this.checkIsTarget(e,Z.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,Z.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,Z.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,Z.ALTERNATION)}};function initializeArrayOfArrays(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=[];return t}function pathToHashKeys(e){let t=[``];for(let n=0;n<e.length;n++){let r=e[n],i=[];for(let e=0;e<t.length;e++){let n=t[e];i.push(n+`_`+r.tokenTypeIdx);for(let e=0;e<r.categoryMatches.length;e++){let t=`_`+r.categoryMatches[e];i.push(n+t)}}t=i}return t}function isUniquePrefixHash(e,t,n){for(let r=0;r<e.length;r++){if(r===n)continue;let i=e[r];for(let e=0;e<t.length;e++)if(i[t[e]]===!0)return!1}return!0}function lookAheadSequenceFromAlternatives(e,t){let n=o(e,e=>possiblePathsFrom([e],1)),r=initializeArrayOfArrays(n.length),i=o(n,e=>{let t={};return x(e,e=>{x(pathToHashKeys(e.partialPath),e=>{t[e]=!0})}),t}),a=n;for(let e=1;e<=t;e++){let n=a;a=initializeArrayOfArrays(n.length);for(let o=0;o<n.length;o++){let s=n[o];for(let n=0;n<s.length;n++){let c=s[n].partialPath,l=s[n].suffixDef,u=pathToHashKeys(c);if(isUniquePrefixHash(i,u,o)||isEmpty(l)||c.length===t){let e=r[o];if(containsPath(e,c)===!1){e.push(c);for(let e=0;e<u.length;e++){let t=u[e];i[o][t]=!0}}}else{let t=possiblePathsFrom(l,e+1,c);a[o]=a[o].concat(t),x(t,e=>{x(pathToHashKeys(e.partialPath),e=>{i[o][e]=!0})})}}}}return r}function getLookaheadPathsForOr(e,t,n,r){let i=new InsideDefinitionFinderVisitor(e,Z.ALTERNATION,r);return t.accept(i),lookAheadSequenceFromAlternatives(i.result,n)}function getLookaheadPathsForOptionalProd(e,t,n,r){let i=new InsideDefinitionFinderVisitor(e,n);t.accept(i);let a=i.result,o=new RestDefinitionFinderWalker(t,e,n).startWalking();return lookAheadSequenceFromAlternatives([new z({definition:a}),new z({definition:o})],r)}function containsPath(e,t){compareOtherPath:for(let n=0;n<e.length;n++){let r=e[n];if(r.length===t.length){for(let e=0;e<r.length;e++){let n=t[e],i=r[e];if(!(n===i||i.categoryMatchesMap[n.tokenTypeIdx]!==void 0))continue compareOtherPath}return!0}}return!1}function isStrictPrefixOfPath(e,t){return e.length<t.length&&H(e,(e,n)=>{let r=t[n];return e===r||r.categoryMatchesMap[e.tokenTypeIdx]})}function areTokenCategoriesNotUsed(e){return H(e,e=>H(e,e=>H(e,e=>isEmpty(e.categoryMatches))))}function validateLookahead(e){return o(e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}),e=>Object.assign({type:$.CUSTOM_LOOKAHEAD_VALIDATION},e))}function validateGrammar$1(e,t,n,r){let i=flatMap(e,e=>validateDuplicateProductions(e,n)),a=checkTerminalAndNoneTerminalsNameSpace(e,t,n),o=flatMap(e,e=>validateTooManyAlts(e,n)),s=flatMap(e,t=>validateRuleDoesNotAlreadyExist(t,e,r,n));return i.concat(a,o,s)}e(validateGrammar$1,`validateGrammar`);function validateDuplicateProductions(e,t){let n=new OccurrenceValidationCollector;e.accept(n);let r=n.allProductions;return o(U(Ee(Qt(r,identifyProductionForDuplicates),e=>e.length>1)),n=>{let r=head(n),i=t.buildDuplicateFoundError(e,n),a=B(r),o={message:i,type:$.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:a,occurrence:r.idx},s=getExtraProductionArgument(r);return s&&(o.parameter=s),o})}function identifyProductionForDuplicates(e){return`${B(e)}_#_${e.idx}_#_${getExtraProductionArgument(e)}`}function getExtraProductionArgument(e){return e instanceof P?e.terminalType.name:e instanceof j?e.nonTerminalName:``}var OccurrenceValidationCollector=class extends k{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}};function validateRuleDoesNotAlreadyExist(e,t,n,r){let i=[];if(reduce(t,(t,n)=>n.name===e.name?t+1:t,0)>1){let t=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});i.push({message:t,type:$.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function validateRuleIsOverridden(e,t,n){let r=[],i;return A(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,r.push({message:i,type:$.INVALID_RULE_OVERRIDE,ruleName:e})),r}function validateNoLeftRecursion(e,t,n,r=[]){let i=[],a=getFirstNoneTerminal(t.definition);if(isEmpty(a))return[];{let t=e.name;A(a,e)&&i.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:r}),type:$.LEFT_RECURSION,ruleName:t});let o=flatMap(Yt(a,r.concat([e])),t=>{let i=clone(r);return i.push(t),validateNoLeftRecursion(e,t,n,i)});return i.concat(o)}}function getFirstNoneTerminal(e){let t=[];if(isEmpty(e))return t;let n=head(e);if(n instanceof j)t.push(n.referencedRule);else if(n instanceof z||n instanceof F||n instanceof M||n instanceof N||n instanceof ye||n instanceof V)t=t.concat(getFirstNoneTerminal(n.definition));else if(n instanceof L)t=flatten(o(n.definition,e=>getFirstNoneTerminal(e.definition)));else if(!(n instanceof P))throw Error(`non exhaustive match`);let r=xe(n),i=e.length>1;if(r&&i){let n=drop(e);return t.concat(getFirstNoneTerminal(n))}else return t}var OrCollector=class extends k{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function validateEmptyOrAlternative(e,t){let n=new OrCollector;e.accept(n);let r=n.alternations;return flatMap(r,n=>flatMap(dropRight(n.definition),(r,i)=>isEmpty(nextPossibleTokensAfter([r],[],tokenStructuredMatcher,1))?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:n,emptyChoiceIdx:i}),type:$.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:n.idx,alternative:i+1}]:[]))}function validateAmbiguousAlternationAlternatives(e,t,n){let r=new OrCollector;e.accept(r);let i=r.alternations;return i=reject(i,e=>e.ignoreAmbiguities===!0),flatMap(i,r=>{let i=r.idx,a=getLookaheadPathsForOr(i,e,r.maxLookahead||t,r),o=checkAlternativesAmbiguities(a,r,e,n),s=checkPrefixAlternativesAmbiguities(a,r,e,n);return o.concat(s)})}var RepetitionCollector=class extends k{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}};function validateTooManyAlts(e,t){let n=new OrCollector;e.accept(n);let r=n.alternations;return flatMap(r,n=>n.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:n}),type:$.TOO_MANY_ALTS,ruleName:e.name,occurrence:n.idx}]:[])}function validateSomeNonEmptyLookaheadPath(e,t,n){let r=[];return x(e,e=>{let i=new RepetitionCollector;e.accept(i);let a=i.allProductions;x(a,i=>{let a=getProdType(i),o=i.maxLookahead||t,s=i.idx,c=getLookaheadPathsForOptionalProd(s,e,a,o)[0];if(isEmpty(flatten(c))){let t=n.buildEmptyRepetitionError({topLevelRule:e,repetition:i});r.push({message:t,type:$.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),r}function checkAlternativesAmbiguities(e,t,n,r){let i=[];return o(reduce(e,(n,r,a)=>(t.definition[a].ignoreAmbiguities===!0||x(r,r=>{let o=[a];x(e,(e,n)=>{a!==n&&containsPath(e,r)&&t.definition[n].ignoreAmbiguities!==!0&&o.push(n)}),o.length>1&&!containsPath(i,r)&&(i.push(r),n.push({alts:o,path:r}))}),n),[]),e=>{let i=o(e.alts,e=>e+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:$.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:e.alts}})}function checkPrefixAlternativesAmbiguities(e,t,n,r){let i=reduce(e,(e,t,n)=>{let r=o(t,e=>({idx:n,path:e}));return e.concat(r)},[]);return compact(flatMap(i,e=>{if(t.definition[e.idx].ignoreAmbiguities===!0)return[];let a=e.idx,s=e.path;return o(filter(i,e=>t.definition[e.idx].ignoreAmbiguities!==!0&&e.idx<a&&isStrictPrefixOfPath(e.path,s)),e=>{let i=[e.idx+1,a+1],o=t.idx===0?``:t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:$.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:o,alternatives:i}})}))}function checkTerminalAndNoneTerminalsNameSpace(e,t,n){let r=[],i=o(t,e=>e.name);return x(e,e=>{let t=e.name;if(A(i,t)){let i=n.buildNamespaceConflictError(e);r.push({message:i,type:$.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),r}function resolveGrammar(e){let t=qt(e,{errMsgProvider:Mn}),n={};return x(e.rules,e=>{n[e.name]=e}),resolveGrammar$1(n,t.errMsgProvider)}function validateGrammar(e){return e=qt(e,{errMsgProvider:X}),validateGrammar$1(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}const Nn=`MismatchedTokenException`,Pn=`NoViableAltException`,Fn=`EarlyExitException`,In=`NotAllInputParsedException`,Ln=[Nn,Pn,Fn,In];Object.freeze(Ln);function isRecognitionException(e){return A(Ln,e.name)}var RecognitionException=class extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},MismatchedTokenException=class extends RecognitionException{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Nn}},NoViableAltException=class extends RecognitionException{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Pn}},NotAllInputParsedException=class extends RecognitionException{constructor(e,t){super(e,t),this.name=In}},EarlyExitException=class extends RecognitionException{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Fn}};const Rn={};var InRuleRecoveryException=class extends Error{constructor(e){super(e),this.name=`InRuleRecoveryException`}},Recoverable=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=has(e,`recoveryEnabled`)?e.recoveryEnabled:Q.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=attemptInRepetitionRecovery)}getTokenToInsert(e){let t=createTokenInstance(e,``,NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,n,r){let i=this.findReSyncTokenType(),a=this.exportLexerState(),o=[],s=!1,c=this.LA(1),l=this.LA(1),generateErrorMessage=()=>{let e=this.LA(0),t=new MismatchedTokenException(this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:e,ruleName:this.getCurrRuleFullName()}),c,this.LA(0));t.resyncedTokens=dropRight(o),this.SAVE_ERROR(t)};for(;!s;)if(this.tokenMatcher(l,r)){generateErrorMessage();return}else if(n.call(this)){generateErrorMessage(),e.apply(this,t);return}else this.tokenMatcher(l,i)?s=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,o));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,t,n){return!(n===!1||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new InRuleRecoveryException(`sad sad panda`)}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||isEmpty(t))return!1;let n=this.LA(1);return K(t,e=>this.tokenMatcher(n,e))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return A(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA(1),n=2;for(;;){let r=K(e,e=>tokenMatcher(t,e));if(r!==void 0)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return Rn;let e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return o(e,(n,r)=>r===0?Rn:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:t[r],inRule:this.shortRuleNameToFullName(e[r-1])})}flattenFollowSet(){return flatten(o(this.buildFullFollowKeyStack(),e=>this.getFollowSetFromFollowKey(e)))}getFollowSetFromFollowKey(e){if(e===Rn)return[Y];let t=e.ruleName+e.idxInCallingRule+cn+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,Y)||t.push(e),t}reSyncTo(e){let t=[],n=this.LA(1);for(;this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return dropRight(t)}attemptInRepetitionRecovery(e,t,n,r,i,a,o){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:clone(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return o(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}};function attemptInRepetitionRecovery(e,t,n,r,i,a,o){let s=this.getKeyForAutomaticLookahead(r,i),c=this.firstAfterRepMap[s];if(c===void 0){let e=this.getCurrRuleFullName(),t=this.getGAstProductions()[e];c=new a(t,i).startWalking(),this.firstAfterRepMap[s]=c}let l=c.token,u=c.occurrence,d=c.isEndOfRule;this.RULE_STACK.length===1&&d&&l===void 0&&(l=Y,u=1),!(l===void 0||u===void 0)&&this.shouldInRepetitionRecoveryBeTried(l,u,o)&&this.tryInRepetitionRecovery(e,t,n,l)}const zn=1024,Bn=1280,Vn=1536;function getKeyForAutomaticLookahead(e,t,n){return n|t|e}var LLkLookaheadStrategy=class{constructor(e){this.maxLookahead=e?.maxLookahead??Q.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);if(isEmpty(t)){let n=this.validateEmptyOrAlternatives(e.rules),r=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...n,...r,...i]}return t}validateNoLeftRecursion(e){return flatMap(e,e=>validateNoLeftRecursion(e,e,X))}validateEmptyOrAlternatives(e){return flatMap(e,e=>validateEmptyOrAlternative(e,X))}validateAmbiguousAlternationAlternatives(e,t){return flatMap(e,e=>validateAmbiguousAlternationAlternatives(e,t,X))}validateSomeNonEmptyLookaheadPath(e,t){return validateSomeNonEmptyLookaheadPath(e,t,X)}buildLookaheadForAlternation(e){return buildLookaheadFuncForOr(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,buildAlternativesLookAheadFunc)}buildLookaheadForOptional(e){return buildLookaheadFuncForOptionalProd(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,getProdType(e.prodType),buildSingleAlternativeLookaheadFunction)}},LooksAhead=class{initLooksAhead(e){this.dynamicTokensEnabled=has(e,`dynamicTokensEnabled`)?e.dynamicTokensEnabled:Q.dynamicTokensEnabled,this.maxLookahead=has(e,`maxLookahead`)?e.maxLookahead:Q.maxLookahead,this.lookaheadStrategy=has(e,`lookaheadStrategy`)?e.lookaheadStrategy:new LLkLookaheadStrategy({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){x(e,e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{let{alternation:t,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:o}=collectMethods(e);x(t,t=>{let n=t.idx===0?``:t.idx;this.TRACE_INIT(`${B(t)}${n}`,()=>{let n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),r=getKeyForAutomaticLookahead(this.fullRuleNameToShort[e.name],256,t.idx);this.setLaFuncCache(r,n)})}),x(n,t=>{this.computeLookaheadFunc(e,t.idx,768,`Repetition`,t.maxLookahead,B(t))}),x(r,t=>{this.computeLookaheadFunc(e,t.idx,512,`Option`,t.maxLookahead,B(t))}),x(i,t=>{this.computeLookaheadFunc(e,t.idx,zn,`RepetitionMandatory`,t.maxLookahead,B(t))}),x(a,t=>{this.computeLookaheadFunc(e,t.idx,Vn,`RepetitionMandatoryWithSeparator`,t.maxLookahead,B(t))}),x(o,t=>{this.computeLookaheadFunc(e,t.idx,Bn,`RepetitionWithSeparator`,t.maxLookahead,B(t))})})})}computeLookaheadFunc(e,t,n,r,i,a){this.TRACE_INIT(`${a}${t===0?``:t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),o=getKeyForAutomaticLookahead(this.fullRuleNameToShort[e.name],n,t);this.setLaFuncCache(o,a)})}getKeyForAutomaticLookahead(e,t){return getKeyForAutomaticLookahead(this.getLastExplicitRuleShortName(),e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},DslMethodsCollectorVisitor=class extends k{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}};const Hn=new DslMethodsCollectorVisitor;function collectMethods(e){Hn.reset(),e.accept(Hn);let t=Hn.dslMethods;return Hn.reset(),t}function setNodeLocationOnlyOffset(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function setNodeLocationFull(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function addTerminalToCst(e,t,n){e.children[n]===void 0?e.children[n]=[t]:e.children[n].push(t)}function addNoneTerminalToCst(e,t,n){e.children[t]===void 0?e.children[t]=[n]:e.children[t].push(n)}function defineNameProp(e,t){Object.defineProperty(e,`name`,{enumerable:!1,configurable:!0,writable:!1,value:t})}function defaultVisit(e,t){let n=u(e),r=n.length;for(let i=0;i<r;i++){let r=e[n[i]],a=r.length;for(let e=0;e<a;e++){let n=r[e];n.tokenTypeIdx===void 0&&this[n.name](n.children,t)}}}function createBaseSemanticVisitorConstructor(e,t){let derivedConstructor=function(){};return defineNameProp(derivedConstructor,e+`BaseSemantics`),derivedConstructor.prototype={visit:function(e,t){if(R(e)&&(e=e[0]),!isUndefined(e))return this[e.name](e.children,t)},validateVisitor:function(){let e=validateVisitor(this,t);if(!isEmpty(e)){let t=o(e,e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join(`
41
+
42
+ `).replace(/\n/g,`
43
+ `)}`)}}},derivedConstructor.prototype.constructor=derivedConstructor,derivedConstructor._RULE_NAMES=t,derivedConstructor}function createBaseVisitorConstructorWithDefaults(e,t,n){let derivedConstructor=function(){};defineNameProp(derivedConstructor,e+`BaseSemanticsWithDefaults`);let r=Object.create(n.prototype);return x(t,e=>{r[e]=defaultVisit}),derivedConstructor.prototype=r,derivedConstructor.prototype.constructor=derivedConstructor,derivedConstructor}var Un;(function(e){e[e.REDUNDANT_METHOD=0]=`REDUNDANT_METHOD`,e[e.MISSING_METHOD=1]=`MISSING_METHOD`})(Un||={});function validateVisitor(e,t){return validateMissingCstMethods(e,t)}function validateMissingCstMethods(e,t){return compact(o(filter(t,t=>I(e[t])===!1),t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:Un.MISSING_METHOD,methodName:t})))}var TreeBuilder=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=has(e,`nodeLocationTracking`)?e.nodeLocationTracking:Q.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=noop,this.cstFinallyStateUpdate=noop,this.cstPostTerminal=noop,this.cstPostNonTerminal=noop,this.cstPostRule=noop;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=setNodeLocationFull,this.setNodeLocationFromNode=setNodeLocationFull,this.cstPostRule=noop,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=noop,this.setNodeLocationFromNode=noop,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=setNodeLocationOnlyOffset,this.setNodeLocationFromNode=setNodeLocationOnlyOffset,this.cstPostRule=noop,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=noop,this.setNodeLocationFromNode=noop,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=noop,this.setNodeLocationFromNode=noop,this.cstPostRule=noop,this.setInitialNodeLocation=noop;else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){let t=this.LA(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(e){let t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?n.endOffset=t.endOffset:n.startOffset=NaN}cstPostTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];addTerminalToCst(n,t,e),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];addNoneTerminalToCst(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}getBaseCstVisitorConstructor(){if(isUndefined(this.baseCstVisitorConstructor)){let e=createBaseSemanticVisitorConstructor(this.className,u(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(isUndefined(this.baseCstVisitorWithDefaultsConstructor)){let e=createBaseVisitorConstructorWithDefaults(this.className,u(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-1]}getPreviousExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-2]}getLastExplicitRuleOccurrenceIndex(){let e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}},LexerAdapter=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error(`Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.`);this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):Jn}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?Jn:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}},RecognizerApi=class{ACTION(e){return e.call(this)}consume(e,t,n){return this.consumeInternal(t,e,n)}subrule(e,t,n){return this.subruleInternal(t,e,n)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,n=Yn){if(A(this.definedRulesNames,e)){let t={message:X.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:$.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);let r=this.defineRule(e,t,n);return this[e]=r,r}OVERRIDE_RULE(e,t,n=Yn){let r=validateRuleIsOverridden(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);let i=this.defineRule(e,t,n);return this[e]=i,i}BACKTRACK(e,t){return function(){this.isBackTrackingStack.push(1);let n=this.saveRecogState();try{return e.apply(this,t),!0}catch(e){if(isRecognitionException(e))return!1;throw e}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return ce(U(this.gastProductionsCache))}},RecognizerEngine=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=tokenStructuredMatcherNoCategories,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},has(t,`serializedGrammar`))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
44
+ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
45
+ For Further details.`);if(R(e)){if(isEmpty(e))throw Error(`A Token Vocabulary cannot be empty.
46
+ Note that the first argument for the parser constructor
47
+ is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset==`number`)throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
48
+ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
49
+ For Further details.`)}if(R(e))this.tokensMap=reduce(e,(e,t)=>(e[t.name]=t,e),{});else if(has(e,`modes`)&&H(flatten(U(e.modes)),isTokenType)){let t=uniq(flatten(U(e.modes)));this.tokensMap=reduce(t,(e,t)=>(e[t.name]=t,e),{})}else if(se(e))this.tokensMap=clone(e);else throw Error(`<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition`);this.tokensMap.EOF=Y;let n=H(has(e,`modes`)?flatten(U(e.modes)):U(e),e=>isEmpty(e.categoryMatches));this.tokenMatcher=n?tokenStructuredMatcherNoCategories:tokenStructuredMatcher,augmentTokenTypes(U(this.tokensMap))}defineRule(e,t,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let r=has(n,`resyncEnabled`)?n.resyncEnabled:Yn.resyncEnabled,i=has(n,`recoveryValueFunc`)?n.recoveryValueFunc:Yn.recoveryValueFunc,a=this.ruleShortNameIdx<<12;this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a;let o;return o=this.outputCst===!0?function invokeRuleWithTry(...n){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n);let r=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(r),r}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}}:function invokeRuleWithTryCst(...n){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n)}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(o,{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,n){let r=this.RULE_STACK.length===1,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(isRecognitionException(e)){let t=e;if(i){let r=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(r))if(t.resyncedTokens=this.reSyncTo(r),this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}else return n(e);else{if(this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];e.recoveredNode=!0,t.partialCstResult=e}throw t}}else if(r)return this.moveToTerminatedState(),n(e);else throw t}else throw e}optionInternal(e,t){let n=this.getKeyForAutomaticLookahead(512,t);return this.optionInternalLogic(e,t,n)}optionInternalLogic(e,t,n){let lookAheadFunc=this.getLaFuncFromCache(n),r;if(typeof e!=`function`){r=e.DEF;let t=e.GATE;if(t!==void 0){let e=lookAheadFunc;lookAheadFunc=()=>t.call(this)&&e.call(this)}}else r=e;if(lookAheadFunc.call(this)===!0)return r.call(this)}atLeastOneInternal(e,t){let n=this.getKeyForAutomaticLookahead(zn,e);return this.atLeastOneInternalLogic(e,t,n)}atLeastOneInternalLogic(e,t,n){let lookAheadFunc=this.getLaFuncFromCache(n),r;if(typeof t!=`function`){r=t.DEF;let e=t.GATE;if(e!==void 0){let t=lookAheadFunc;lookAheadFunc=()=>e.call(this)&&t.call(this)}}else r=t;if(lookAheadFunc.call(this)===!0){let e=this.doSingleRepetition(r);for(;lookAheadFunc.call(this)===!0&&e===!0;)e=this.doSingleRepetition(r)}else throw this.raiseEarlyExitException(e,Z.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],lookAheadFunc,zn,e,NextTerminalAfterAtLeastOneWalker)}atLeastOneSepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(Vn,e);this.atLeastOneSepFirstInternalLogic(e,t,n)}atLeastOneSepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);let separatorLookAheadFunc=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,separatorLookAheadFunc,r,NextTerminalAfterAtLeastOneSepWalker],separatorLookAheadFunc,Vn,e,NextTerminalAfterAtLeastOneSepWalker)}else throw this.raiseEarlyExitException(e,Z.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let n=this.getKeyForAutomaticLookahead(768,e);return this.manyInternalLogic(e,t,n)}manyInternalLogic(e,t,n){let lookaheadFunction=this.getLaFuncFromCache(n),r;if(typeof t!=`function`){r=t.DEF;let e=t.GATE;if(e!==void 0){let t=lookaheadFunction;lookaheadFunction=()=>e.call(this)&&t.call(this)}}else r=t;let i=!0;for(;lookaheadFunction.call(this)===!0&&i===!0;)i=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],lookaheadFunction,768,e,NextTerminalAfterManyWalker,i)}manySepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(Bn,e);this.manySepFirstInternalLogic(e,t,n)}manySepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);let separatorLookAheadFunc=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,separatorLookAheadFunc,r,NextTerminalAfterManySepWalker],separatorLookAheadFunc,Bn,e,NextTerminalAfterManySepWalker)}}repetitionSepSecondInternal(e,t,n,r,i){for(;n();)this.CONSUME(t),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,r,i],n,Vn,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let n=this.getKeyForAutomaticLookahead(256,t),r=R(e)?e:e.DEF,i=this.getLaFuncFromCache(n).call(this,r);if(i!==void 0)return r[i].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){let e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new NotAllInputParsedException(t,e))}}subruleInternal(e,t,n){let r;try{let i=n===void 0?void 0:n.ARGS;return this.subruleIdx=t,r=e.apply(this,i),this.cstPostNonTerminal(r,n!==void 0&&n.LABEL!==void 0?n.LABEL:e.ruleName),r}catch(t){throw this.subruleInternalError(t,n,e.ruleName)}}subruleInternalError(e,t,n){throw isRecognitionException(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:n),delete e.partialCstResult),e}consumeInternal(e,t,n){let r;try{let t=this.LA(1);this.tokenMatcher(t,e)===!0?(this.consumeToken(),r=t):this.consumeInternalError(e,t,n)}catch(n){r=this.consumeInternalRecovery(e,t,n)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:e.name,r),r}consumeInternalError(e,t,n){let r,i=this.LA(0);throw r=n!==void 0&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new MismatchedTokenException(r,t,i))}consumeInternalRecovery(e,t,n){if(this.recoveryEnabled&&n.name===`MismatchedTokenException`&&!this.isBackTracking()){let r=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,r)}catch(e){throw e.name===`InRuleRecoveryException`?n:e}}else throw n}saveRecogState(){let e=this.errors,t=clone(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK}ruleInvocationStateUpdate(e,t,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(t)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Y)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}},ErrorHandler=class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=has(e,`errorMessageProvider`)?e.errorMessageProvider:Q.errorMessageProvider}SAVE_ERROR(e){if(isRecognitionException(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:clone(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error(`Trying to save an Error which is not a RecognitionException`)}get errors(){return clone(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,n){let r=this.getCurrRuleFullName(),i=this.getGAstProductions()[r],a=getLookaheadPathsForOptionalProd(e,i,t,this.maxLookahead)[0],o=[];for(let e=1;e<=this.maxLookahead;e++)o.push(this.LA(e));let s=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:a,actual:o,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new EarlyExitException(s,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let n=this.getCurrRuleFullName(),r=this.getGAstProductions()[n],i=getLookaheadPathsForOr(e,r,this.maxLookahead),a=[];for(let e=1;e<=this.maxLookahead;e++)a.push(this.LA(e));let o=this.LA(0),s=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:a,previous:o,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new NoViableAltException(s,this.LA(1),o))}},ContentAssist=class{initContentAssist(){}computeContentAssist(e,t){let n=this.gastProductionsCache[e];if(isUndefined(n))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return nextPossibleTokensAfter([n],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=head(e.ruleStack),n=this.getGAstProductions()[t];return new NextAfterTokenWalker(n,e).startWalking()}};const Wn={description:`This Object indicates the Parser is during Recording Phase`};Object.freeze(Wn);const Gn=createToken({name:`RECORDING_PHASE_TOKEN`,pattern:Lexer.NA});augmentTokenTypes([Gn]);const Kn=createTokenInstance(Gn,`This IToken indicates the Parser is in Recording Phase
50
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Kn);const qn={name:`This CSTNode indicates the Parser is in Recording Phase
51
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};var GastRecorder=class{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT(`Enable Recording`,()=>{for(let e=0;e<10;e++){let t=e>0?e:``;this[`CONSUME${t}`]=function(t,n){return this.consumeInternalRecord(t,e,n)},this[`SUBRULE${t}`]=function(t,n){return this.subruleInternalRecord(t,e,n)},this[`OPTION${t}`]=function(t){return this.optionInternalRecord(t,e)},this[`OR${t}`]=function(t){return this.orInternalRecord(t,e)},this[`MANY${t}`]=function(t){this.manyInternalRecord(e,t)},this[`MANY_SEP${t}`]=function(t){this.manySepFirstInternalRecord(e,t)},this[`AT_LEAST_ONE${t}`]=function(t){this.atLeastOneInternalRecord(e,t)},this[`AT_LEAST_ONE_SEP${t}`]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}}this.consume=function(e,t,n){return this.consumeInternalRecord(t,e,n)},this.subrule=function(e,t,n){return this.subruleInternalRecord(t,e,n)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT(`Deleting Recording methods`,()=>{let e=this;for(let t=0;t<10;t++){let n=t>0?t:``;delete e[`CONSUME${n}`],delete e[`SUBRULE${n}`],delete e[`OPTION${n}`],delete e[`OR${n}`],delete e[`MANY${n}`],delete e[`MANY_SEP${n}`],delete e[`AT_LEAST_ONE${n}`],delete e[`AT_LEAST_ONE_SEP${n}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return Jn}topLevelRuleRecord(e,t){try{let n=new me({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),t.call(this),this.recordingProdStack.pop(),n}catch(e){if(e.KNOWN_RECORDER_ERROR!==!0)try{e.message+=`
52
+ This error was thrown during the "grammar recording phase" For more info see:
53
+ https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw e}throw e}}optionInternalRecord(e,t){return recordProd.call(this,F,e,t)}atLeastOneInternalRecord(e,t){recordProd.call(this,M,t,e)}atLeastOneSepFirstInternalRecord(e,t){recordProd.call(this,N,t,e,!0)}manyInternalRecord(e,t){recordProd.call(this,V,t,e)}manySepFirstInternalRecord(e,t){recordProd.call(this,ye,t,e,!0)}orInternalRecord(e,t){return recordOrProd.call(this,e,t)}subruleInternalRecord(e,t,n){if(assertMethodIdxIsValid(t),!e||has(e,`ruleName`)===!1){let n=Error(`<SUBRULE${getIdxSuffix(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}let r=last(this.recordingProdStack),i=e.ruleName,a=new j({idx:t,nonTerminalName:i,label:n?.LABEL,referencedRule:void 0});return r.definition.push(a),this.outputCst?qn:Wn}consumeInternalRecord(e,t,n){if(assertMethodIdxIsValid(t),!hasShortKeyProperty(e)){let n=Error(`<CONSUME${getIdxSuffix(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}let r=last(this.recordingProdStack),i=new P({idx:t,terminalType:e,label:n?.LABEL});return r.definition.push(i),Kn}};function recordProd(e,t,n,r=!1){assertMethodIdxIsValid(n);let i=last(this.recordingProdStack),a=I(t)?t:t.DEF,o=new e({definition:[],idx:n});return r&&(o.separator=t.SEP),has(t,`MAX_LOOKAHEAD`)&&(o.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(o),a.call(this),i.definition.push(o),this.recordingProdStack.pop(),Wn}function recordOrProd(e,t){assertMethodIdxIsValid(t);let n=last(this.recordingProdStack),r=R(e)===!1,i=r===!1?e:e.DEF,a=new L({definition:[],idx:t,ignoreAmbiguities:r&&e.IGNORE_AMBIGUITIES===!0});return has(e,`MAX_LOOKAHEAD`)&&(a.maxLookahead=e.MAX_LOOKAHEAD),a.hasPredicates=D(i,e=>I(e.GATE)),n.definition.push(a),x(i,e=>{let t=new z({definition:[]});a.definition.push(t),has(e,`IGNORE_AMBIGUITIES`)?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:has(e,`GATE`)&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),Wn}function getIdxSuffix(e){return e===0?``:`${e}`}function assertMethodIdxIsValid(e){if(e<0||e>255){let t=Error(`Invalid DSL Method idx value: <${e}>\n\tIdx value must be a none negative value smaller than 256`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var PerformanceTracer=class{initPerformanceTracer(e){if(has(e,`traceInitPerf`)){let t=e.traceInitPerf,n=typeof t==`number`;this.traceInitMaxIdent=n?t:1/0,this.traceInitPerf=n?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=Q.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=Ae(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}else return t()}};function applyMixins(e,t){t.forEach(t=>{let n=t.prototype;Object.getOwnPropertyNames(n).forEach(r=>{if(r===`constructor`)return;let i=Object.getOwnPropertyDescriptor(n,r);i&&(i.get||i.set)?Object.defineProperty(e.prototype,r,i):e.prototype[r]=t.prototype[r]})})}const Jn=createTokenInstance(Y,``,NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Jn);const Q=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:jn,nodeLocationTracking:`none`,traceInitPerf:!1,skipValidations:!1}),Yn=Object.freeze({recoveryValueFunc:()=>void 0,resyncEnabled:!0});var $;(function(e){e[e.INVALID_RULE_NAME=0]=`INVALID_RULE_NAME`,e[e.DUPLICATE_RULE_NAME=1]=`DUPLICATE_RULE_NAME`,e[e.INVALID_RULE_OVERRIDE=2]=`INVALID_RULE_OVERRIDE`,e[e.DUPLICATE_PRODUCTIONS=3]=`DUPLICATE_PRODUCTIONS`,e[e.UNRESOLVED_SUBRULE_REF=4]=`UNRESOLVED_SUBRULE_REF`,e[e.LEFT_RECURSION=5]=`LEFT_RECURSION`,e[e.NONE_LAST_EMPTY_ALT=6]=`NONE_LAST_EMPTY_ALT`,e[e.AMBIGUOUS_ALTS=7]=`AMBIGUOUS_ALTS`,e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]=`CONFLICT_TOKENS_RULES_NAMESPACE`,e[e.INVALID_TOKEN_NAME=9]=`INVALID_TOKEN_NAME`,e[e.NO_NON_EMPTY_LOOKAHEAD=10]=`NO_NON_EMPTY_LOOKAHEAD`,e[e.AMBIGUOUS_PREFIX_ALTS=11]=`AMBIGUOUS_PREFIX_ALTS`,e[e.TOO_MANY_ALTS=12]=`TOO_MANY_ALTS`,e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]=`CUSTOM_LOOKAHEAD_VALIDATION`})($||={});function EMPTY_ALT(e=void 0){return function(){return e}}var Xn=class Parser{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT(`performSelfAnalysis`,()=>{let e;this.selfAnalysisDone=!0;let t=this.className;this.TRACE_INIT(`toFastProps`,()=>{Me(this)}),this.TRACE_INIT(`Grammar Recording`,()=>{try{this.enableRecording(),x(this.definedRulesNames,e=>{let t=this[e].originalGrammarAction,n;this.TRACE_INIT(`${e} Rule`,()=>{n=this.topLevelRuleRecord(e,t)}),this.gastProductionsCache[e]=n})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT(`Grammar Resolving`,()=>{n=resolveGrammar({rules:U(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT(`Grammar Validations`,()=>{if(isEmpty(n)&&this.skipValidations===!1){let e=validateGrammar({rules:U(this.gastProductionsCache),tokenTypes:U(this.tokensMap),errMsgProvider:X,grammarName:t}),n=validateLookahead({lookaheadStrategy:this.lookaheadStrategy,rules:U(this.gastProductionsCache),tokenTypes:U(this.tokensMap),grammarName:t});this.definitionErrors=this.definitionErrors.concat(e,n)}}),isEmpty(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT(`computeAllProdsFollows`,()=>{let e=computeAllProdsFollows(U(this.gastProductionsCache));this.resyncFollows=e}),this.TRACE_INIT(`ComputeLookaheadFunctions`,()=>{var e,t;(t=(e=this.lookaheadStrategy).initialize)==null||t.call(e,{rules:U(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(U(this.gastProductionsCache))})),!Parser.DEFER_DEFINITION_ERRORS_HANDLING&&!isEmpty(this.definitionErrors))throw e=o(this.definitionErrors,e=>e.message),Error(`Parser Definition Errors detected:\n ${e.join(`
54
+ -------------------------------
55
+ `)}`)})}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(t),n.initLexerAdapter(),n.initLooksAhead(t),n.initRecognizerEngine(e,t),n.initRecoverable(t),n.initTreeBuilder(t),n.initContentAssist(),n.initGastRecorder(t),n.initPerformanceTracer(t),has(t,`ignoredIssues`))throw Error(`The <ignoredIssues> IParserConfig property has been deprecated.
56
+ Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
57
+ See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
58
+ For further details.`);this.skipValidations=has(t,`skipValidations`)?t.skipValidations:Q.skipValidations}};Xn.DEFER_DEFINITION_ERRORS_HANDLING=!1,applyMixins(Xn,[Recoverable,LooksAhead,TreeBuilder,LexerAdapter,RecognizerEngine,RecognizerApi,ErrorHandler,ContentAssist,GastRecorder,PerformanceTracer]);var EmbeddedActionsParser=class extends Xn{constructor(e,t=Q){let n=clone(t);n.outputCst=!1,super(e,n)}};export{jn as a,tokenMatcher as c,baseUniq as d,reduce as f,flatten as g,filter as h,getLookaheadPaths as i,Lexer as l,flatMap as m,EmbeddedActionsParser as n,Y as o,isEmpty as p,LLkLookaheadStrategy as r,tokenLabel as s,EMPTY_ALT as t,xn as u};
@@ -0,0 +1,3 @@
1
+ import{i as e}from"../rolldown-runtime.mjs";import*as t from"node:path";import{join as n,relative as r,resolve as i,sep as a}from"node:path";import{EventEmitter as o}from"node:events";import{lstat as s,open as c,readdir as l,realpath as u,stat as d}from"node:fs/promises";import{type as f}from"node:os";import{stat as p,unwatchFile as m,watch as h,watchFile as g}from"node:fs";import{Readable as _}from"node:stream";const v={FILE_TYPE:`files`,DIR_TYPE:`directories`,FILE_DIR_TYPE:`files_directories`,EVERYTHING_TYPE:`all`},y={root:`.`,fileFilter:e=>!0,directoryFilter:e=>!0,type:v.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(y);const b=`READDIRP_RECURSIVE_ERROR`,x=new Set([`ENOENT`,`EPERM`,`EACCES`,`ELOOP`,b]),S=[v.DIR_TYPE,v.EVERYTHING_TYPE,v.FILE_DIR_TYPE,v.FILE_TYPE],C=new Set([v.DIR_TYPE,v.EVERYTHING_TYPE,v.FILE_DIR_TYPE]),w=new Set([v.EVERYTHING_TYPE,v.FILE_DIR_TYPE,v.FILE_TYPE]),isNormalFlowError=e=>x.has(e.code),T=process.platform===`win32`,emptyFn=e=>!0,normalizeFilter=e=>{if(e===void 0)return emptyFn;if(typeof e==`function`)return e;if(typeof e==`string`){let t=e.trim();return e=>e.basename===t}if(Array.isArray(e)){let t=e.map(e=>e.trim());return e=>t.some(t=>e.basename===t)}return emptyFn};var ReaddirpStream=class extends _{parents;reading;parent;_stat;_maxDepth;_wantsDir;_wantsFile;_wantsEverything;_root;_isDirent;_statsProp;_rdOptions;_fileFilter;_directoryFilter;constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...y,...e},{root:n,type:r}=t;this._fileFilter=normalizeFilter(t.fileFilter),this._directoryFilter=normalizeFilter(t.directoryFilter);let a=t.lstat?s:d;T?this._stat=e=>a(e,{bigint:!0}):this._stat=a,this._maxDepth=t.depth!=null&&Number.isSafeInteger(t.depth)?t.depth:y.depth,this._wantsDir=r?C.has(r):!1,this._wantsFile=r?w.has(r):!1,this._wantsEverything=r===v.EVERYTHING_TYPE,this._root=i(n),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?`dirent`:`stats`,this._rdOptions={encoding:`utf8`,withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let t=this.parent,n=t&&t.files;if(n&&n.length>0){let{path:r,depth:i}=t,a=n.splice(0,e).map(e=>this._formatEntry(e,r)),o=await Promise.all(a);for(let t of o){if(!t)continue;if(this.destroyed)return;let n=await this._getEntryType(t);n===`directory`&&this._directoryFilter(t)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(t.fullPath,i+1)),this._wantsDir&&(this.push(t),e--)):(n===`file`||this._includeAsFile(t))&&this._fileFilter(t)&&this._wantsFile&&(this.push(t),e--)}}else{let e=this.parents.pop();if(!e){this.push(null);break}if(this.parent=await e,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(e,t){let n;try{n=await l(e,this._rdOptions)}catch(e){this._onError(e)}return{files:n,depth:t,path:e}}async _formatEntry(e,t){let a,o=this._isDirent?e.name:e;try{let s=i(n(t,o));a={path:r(this._root,s),fullPath:s,basename:o},a[this._statsProp]=this._isDirent?e:await this._stat(s)}catch(e){this._onError(e);return}return a}_onError(e){isNormalFlowError(e)&&!this.destroyed?this.emit(`warn`,e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return``;let t=e[this._statsProp];if(t.isFile())return`file`;if(t.isDirectory())return`directory`;if(t&&t.isSymbolicLink()){let t=e.fullPath;try{let e=await u(t),n=await s(e);if(n.isFile())return`file`;if(n.isDirectory()){let n=e.length;if(t.startsWith(e)&&t.substr(n,1)===a){let n=Error(`Circular symlink detected: "${t}" points to "${e}"`);return n.code=b,this._onError(n)}return`directory`}}catch(e){return this._onError(e),``}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}};function readdirp(e,t={}){let n=t.entryType||t.type;if(n===`both`&&(n=v.FILE_DIR_TYPE),n&&(t.type=n),!e)throw Error(`readdirp: root argument is required. Usage: readdirp(root, options)`);if(typeof e!=`string`)throw TypeError(`readdirp: root argument must be a string. Usage: readdirp(root, options)`);if(n&&!S.includes(n))throw Error(`readdirp: Invalid type passed. Use one of ${S.join(`, `)}`);return t.root=e,new ReaddirpStream(t)}const EMPTY_FN=()=>{},E=process.platform,D=E===`win32`,O=E===`darwin`,k=E===`linux`,A=E===`freebsd`,j=f()===`OS400`,M={ALL:`all`,READY:`ready`,ADD:`add`,CHANGE:`change`,ADD_DIR:`addDir`,UNLINK:`unlink`,UNLINK_DIR:`unlinkDir`,RAW:`raw`,ERROR:`error`},N=M,P={lstat:s,stat:d},F=`listeners`,I=`errHandlers`,L=`rawEmitters`,R=[F,I,L],z=new Set(`3dm.3ds.3g2.3gp.7z.a.aac.adp.afdesign.afphoto.afpub.ai.aif.aiff.alz.ape.apk.appimage.ar.arj.asf.au.avi.bak.baml.bh.bin.bk.bmp.btif.bz2.bzip2.cab.caf.cgm.class.cmx.cpio.cr2.cur.dat.dcm.deb.dex.djvu.dll.dmg.dng.doc.docm.docx.dot.dotm.dra.DS_Store.dsk.dts.dtshd.dvb.dwg.dxf.ecelp4800.ecelp7470.ecelp9600.egg.eol.eot.epub.exe.f4v.fbs.fh.fla.flac.flatpak.fli.flv.fpx.fst.fvt.g3.gh.gif.graffle.gz.gzip.h261.h263.h264.icns.ico.ief.img.ipa.iso.jar.jpeg.jpg.jpgv.jpm.jxr.key.ktx.lha.lib.lvp.lz.lzh.lzma.lzo.m3u.m4a.m4v.mar.mdi.mht.mid.midi.mj2.mka.mkv.mmr.mng.mobi.mov.movie.mp3.mp4.mp4a.mpeg.mpg.mpga.mxu.nef.npx.numbers.nupkg.o.odp.ods.odt.oga.ogg.ogv.otf.ott.pages.pbm.pcx.pdb.pdf.pea.pgm.pic.png.pnm.pot.potm.potx.ppa.ppam.ppm.pps.ppsm.ppsx.ppt.pptm.pptx.psd.pya.pyc.pyo.pyv.qt.rar.ras.raw.resources.rgb.rip.rlc.rmf.rmvb.rpm.rtf.rz.s3m.s7z.scpt.sgi.shar.snap.sil.sketch.slk.smv.snk.so.stl.suo.sub.swf.tar.tbz.tbz2.tga.tgz.thmx.tif.tiff.tlz.ttc.ttf.txz.udf.uvh.uvi.uvm.uvp.uvs.uvu.viv.vob.war.wav.wax.wbmp.wdp.weba.webm.webp.whl.wim.wm.wma.wmv.wmx.woff.woff2.wrm.wvx.xbm.xif.xla.xlam.xls.xlsb.xlsm.xlsx.xlt.xltm.xltx.xm.xmind.xpi.xpm.xwd.xz.z.zip.zipx`.split(`.`)),isBinaryPath=e=>z.has(t.extname(e).slice(1).toLowerCase()),foreach=(e,t)=>{e instanceof Set?e.forEach(t):t(e)},addAndConvert=(e,t,n)=>{let r=e[t];r instanceof Set||(e[t]=r=new Set([r])),r.add(n)},clearItem=e=>t=>{let n=e[t];n instanceof Set?n.clear():delete e[t]},delFromSet=(e,t,n)=>{let r=e[t];r instanceof Set?r.delete(n):r===n&&delete e[t]},isEmptySet=e=>e instanceof Set?e.size===0:!e,B=new Map;function createFsWatchInstance(e,n,r,i,a){let handleEvent=(n,i)=>{r(e),a(n,i,{watchedPath:e}),i&&e!==i&&fsWatchBroadcast(t.resolve(e,i),F,t.join(e,i))};try{return h(e,{persistent:n.persistent},handleEvent)}catch(e){i(e);return}}const fsWatchBroadcast=(e,t,n,r,i)=>{let a=B.get(e);a&&foreach(a[t],e=>{e(n,r,i)})},setFsWatchListener=(e,t,n,r)=>{let{listener:i,errHandler:a,rawEmitter:o}=r,s=B.get(t),l;if(!n.persistent)return l=createFsWatchInstance(e,n,i,a,o),l?l.close.bind(l):void 0;if(s)addAndConvert(s,F,i),addAndConvert(s,I,a),addAndConvert(s,L,o);else{if(l=createFsWatchInstance(e,n,fsWatchBroadcast.bind(null,t,F),a,fsWatchBroadcast.bind(null,t,L)),!l)return;l.on(N.ERROR,async n=>{let r=fsWatchBroadcast.bind(null,t,I);if(s&&(s.watcherUnusable=!0),D&&n.code===`EPERM`)try{await(await c(e,`r`)).close(),r(n)}catch{}else r(n)}),s={listeners:i,errHandlers:a,rawEmitters:o,watcher:l},B.set(t,s)}return()=>{delFromSet(s,F,i),delFromSet(s,I,a),delFromSet(s,L,o),isEmptySet(s.listeners)&&(s.watcher.close(),B.delete(t),R.forEach(clearItem(s)),s.watcher=void 0,Object.freeze(s))}},V=new Map,setFsWatchFileListener=(e,t,n,r)=>{let{listener:i,rawEmitter:a}=r,o=V.get(t),s=o&&o.options;return s&&(s.persistent<n.persistent||s.interval>n.interval)&&(m(t),o=void 0),o?(addAndConvert(o,F,i),addAndConvert(o,L,a)):(o={listeners:i,rawEmitters:a,options:n,watcher:g(t,n,(n,r)=>{foreach(o.rawEmitters,e=>{e(N.CHANGE,t,{curr:n,prev:r})});let i=n.mtimeMs;(n.size!==r.size||i>r.mtimeMs||i===0)&&foreach(o.listeners,t=>t(e,n))})},V.set(t,o)),()=>{delFromSet(o,F,i),delFromSet(o,L,a),isEmptySet(o.listeners)&&(V.delete(t),m(t),o.options=o.watcher=void 0,Object.freeze(o))}};var NodeFsHandler=class{fsw;_boundHandleError;constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,n){let r=this.fsw.options,i=t.dirname(e),a=t.basename(e);this.fsw._getWatchedDir(i).add(a);let o=t.resolve(e),s={persistent:r.persistent};n||=EMPTY_FN;let c;return r.usePolling?(s.interval=r.interval!==r.binaryInterval&&isBinaryPath(a)?r.binaryInterval:r.interval,c=setFsWatchFileListener(e,o,s,{listener:n,rawEmitter:this.fsw._emitRaw})):c=setFsWatchListener(e,o,s,{listener:n,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw}),c}_handleFile(e,n,r){if(this.fsw.closed)return;let i=t.dirname(e),a=t.basename(e),o=this.fsw._getWatchedDir(i),s=n;if(o.has(a))return;let listener=async(t,n)=>{if(this.fsw._throttle(`watch`,e,5)){if(!n||n.mtimeMs===0)try{let n=await d(e);if(this.fsw.closed)return;let r=n.atimeMs,i=n.mtimeMs;if((!r||r<=i||i!==s.mtimeMs)&&this.fsw._emit(N.CHANGE,e,n),(O||k||A)&&s.ino!==n.ino){this.fsw._closeFile(t),s=n;let r=this._watchWithNodeFs(e,listener);r&&this.fsw._addPathCloser(t,r)}else s=n}catch{this.fsw._remove(i,a)}else if(o.has(a)){let t=n.atimeMs,r=n.mtimeMs;(!t||t<=r||r!==s.mtimeMs)&&this.fsw._emit(N.CHANGE,e,n),s=n}}},c=this._watchWithNodeFs(e,listener);if(!(r&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(N.ADD,e,0))return;this.fsw._emit(N.ADD,e,n)}return c}async _handleSymlink(e,t,n,r){if(this.fsw.closed)return;let i=e.fullPath,a=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let t;try{t=await u(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==t&&(this.fsw._symlinkPaths.set(i,t),this.fsw._emit(N.CHANGE,n,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,t),this.fsw._emit(N.ADD,n,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(e,n,r,i,a,o,s){e=t.join(e,``);let c=i?`${e}:${i}`:e;if(s=this.fsw._throttle(`readdir`,c,1e3),!s)return;let l=this.fsw._getWatchedDir(r.path),u=new Set,d=this.fsw._readdirp(e,{fileFilter:e=>r.filterPath(e),directoryFilter:e=>r.filterDir(e)});if(d)return d.on(`data`,async s=>{if(this.fsw.closed){d=void 0;return}let c=s.path,f=t.join(e,c);if(u.add(c),!(s.stats.isSymbolicLink()&&await this._handleSymlink(s,e,f,c))){if(this.fsw.closed){d=void 0;return}(c===i||!i&&!l.has(c))&&(this.fsw._incrReadyCount(),f=t.join(a,t.relative(a,f)),this._addToNodeFs(f,n,r,o+1))}}).on(N.ERROR,this._boundHandleError),new Promise((t,n)=>{if(!d)return n();d.once(`end`,()=>{if(this.fsw.closed){d=void 0;return}let n=s?s.clear():!1;t(void 0),l.getChildren().filter(t=>t!==e&&!u.has(t)).forEach(t=>{this.fsw._remove(e,t)}),d=void 0,n&&this._handleRead(e,!1,r,i,a,o,s)})})}async _handleDir(e,n,r,i,a,o,s){let c=this.fsw._getWatchedDir(t.dirname(e)),l=c.has(t.basename(e));!(r&&this.fsw.options.ignoreInitial)&&!a&&!l&&this.fsw._emit(N.ADD_DIR,e,n),c.add(t.basename(e)),this.fsw._getWatchedDir(e);let u,d=this.fsw.options.depth;if((d==null||i<=d)&&!this.fsw._symlinkPaths.has(s)){if(!a&&(await this._handleRead(e,r,o,a,e,i,void 0),this.fsw.closed))return;u=this._watchWithNodeFs(e,(t,n)=>{n&&n.mtimeMs===0||this._handleRead(t,!1,o,a,e,i,void 0)})}return u}async _addToNodeFs(e,n,r,i,a){let o=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return o(),!1;let s=this.fsw._getWatchHelpers(e);r&&(s.filterPath=e=>r.filterPath(e),s.filterDir=e=>r.filterDir(e));try{let r=await P[s.statMethod](s.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(s.watchPath,r))return o(),!1;let c=this.fsw.options.followSymlinks,l;if(r.isDirectory()){let o=t.resolve(e),d=c?await u(e):e;if(this.fsw.closed||(l=await this._handleDir(s.watchPath,r,n,i,a,s,d),this.fsw.closed))return;o!==d&&d!==void 0&&this.fsw._symlinkPaths.set(o,d)}else if(r.isSymbolicLink()){let a=c?await u(e):e;if(this.fsw.closed)return;let o=t.dirname(s.watchPath);if(this.fsw._getWatchedDir(o).add(s.watchPath),this.fsw._emit(N.ADD,s.watchPath,r),l=await this._handleDir(o,r,n,i,e,s,a),this.fsw.closed)return;a!==void 0&&this.fsw._symlinkPaths.set(t.resolve(e),a)}else l=this._handleFile(s.watchPath,r,n);return o(),l&&this.fsw._addPathCloser(e,l),!1}catch(t){if(this.fsw._handleError(t))return o(),e}}};
2
+ /*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
3
+ const H=/\\/g,U=/\/\//g,W=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,G=/^\.[/\\]/;function arrify(e){return Array.isArray(e)?e:[e]}const isMatcherObject=e=>typeof e==`object`&&!!e&&!(e instanceof RegExp);function createPattern(e){return typeof e==`function`?e:typeof e==`string`?t=>e===t:e instanceof RegExp?t=>e.test(t):typeof e==`object`&&e?n=>{if(e.path===n)return!0;if(e.recursive){let r=t.relative(e.path,n);return r?!r.startsWith(`..`)&&!t.isAbsolute(r):!1}return!1}:()=>!1}function normalizePath(e){if(typeof e!=`string`)throw Error(`string expected`);e=t.normalize(e),e=e.replace(/\\/g,`/`);let n=!1;return e.startsWith(`//`)&&(n=!0),e=e.replace(U,`/`),n&&(e=`/`+e),e}function matchPatterns(e,t,n){let r=normalizePath(t);for(let t=0;t<e.length;t++){let i=e[t];if(i(r,n))return!0}return!1}function anymatch(e,t){if(e==null)throw TypeError(`anymatch: specify first argument`);let n=arrify(e).map(e=>createPattern(e));return t==null?(e,t)=>matchPatterns(n,e,t):matchPatterns(n,t)}const unifyPaths=e=>{let t=arrify(e).flat();if(!t.every(e=>typeof e==`string`))throw TypeError(`Non-string provided as watch path: ${t}`);return t.map(normalizePathToUnix)},toUnix=e=>{let t=e.replace(H,`/`),n=!1;return t.startsWith(`//`)&&(n=!0),t=t.replace(U,`/`),n&&(t=`/`+t),t},normalizePathToUnix=e=>toUnix(t.normalize(toUnix(e))),normalizeIgnored=(e=``)=>n=>typeof n==`string`?normalizePathToUnix(t.isAbsolute(n)?n:t.join(e,n)):n,getAbsolutePath=(e,n)=>t.isAbsolute(e)?e:t.join(n,e),K=Object.freeze(new Set);var DirEntry=class{path;_removeWatcher;items;constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==`.`&&e!==`..`&&t.add(e)}async remove(e){let{items:n}=this;if(!n||(n.delete(e),n.size>0))return;let r=this.path;try{await l(r)}catch{this._removeWatcher&&this._removeWatcher(t.dirname(r),t.basename(r))}}has(e){let{items:t}=this;if(t)return t.has(e)}getChildren(){let{items:e}=this;return e?[...e.values()]:[]}dispose(){this.items.clear(),this.path=``,this._removeWatcher=EMPTY_FN,this.items=K,Object.freeze(this)}},WatchHelper=class{fsw;path;watchPath;fullWatchPath;dirParts;followSymlinks;statMethod;constructor(e,n,r){this.fsw=r;let i=e;this.path=e=e.replace(G,``),this.watchPath=i,this.fullWatchPath=t.resolve(i),this.dirParts=[],this.dirParts.forEach(e=>{e.length>1&&e.pop()}),this.followSymlinks=n,this.statMethod=n?`stat`:`lstat`}entryPath(e){return t.join(this.watchPath,t.relative(this.watchPath,e.fullPath))}filterPath(e){let{stats:t}=e;if(t&&t.isSymbolicLink())return this.filterDir(e);let n=this.entryPath(e);return this.fsw._isntIgnored(n,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},FSWatcher=class extends o{closed;options;_closers;_ignoredPaths;_throttled;_streams;_symlinkPaths;_watched;_pendingWrites;_pendingUnlinks;_readyCount;_emitReady;_closePromise;_userIgnored;_readyEmitted;_emitRaw;_boundRemove;_nodeFsHandler;constructor(e={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let t=e.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...e,ignored:e.ignored?arrify(e.ignored):arrify([]),awaitWriteFinish:t===!0?n:typeof t==`object`?{...n,...t}:!1};j&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let e=i.toLowerCase();e===`false`||e===`0`?r.usePolling=!1:e===`true`||e===`1`?r.usePolling=!0:r.usePolling=!!e}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=EMPTY_FN,this._readyEmitted=!0,process.nextTick(()=>this.emit(M.READY)))},this._emitRaw=(...e)=>this.emit(M.RAW,...e),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new NodeFsHandler(this),Object.freeze(r)}_addIgnoredPath(e){if(isMatcherObject(e)){for(let t of this._ignoredPaths)if(isMatcherObject(t)&&t.path===e.path&&t.recursive===e.recursive)return}this._ignoredPaths.add(e)}_removeIgnoredPath(e){if(this._ignoredPaths.delete(e),typeof e==`string`)for(let t of this._ignoredPaths)isMatcherObject(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,n,r){let{cwd:i}=this.options;this.closed=!1,this._closePromise=void 0;let a=unifyPaths(e);return i&&(a=a.map(e=>getAbsolutePath(e,i))),a.forEach(e=>{this._removeIgnoredPath(e)}),this._userIgnored=void 0,this._readyCount||=0,this._readyCount+=a.length,Promise.all(a.map(async e=>{let t=await this._nodeFsHandler._addToNodeFs(e,!r,void 0,0,n);return t&&this._emitReady(),t})).then(e=>{this.closed||e.forEach(e=>{e&&this.add(t.dirname(e),t.basename(n||e))})}),this}unwatch(e){if(this.closed)return this;let n=unifyPaths(e),{cwd:r}=this.options;return n.forEach(e=>{!t.isAbsolute(e)&&!this._closers.has(e)&&(r&&(e=t.join(r,e)),e=t.resolve(e)),this._closePath(e),this._addIgnoredPath(e),this._watched.has(e)&&this._addIgnoredPath({path:e,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(t=>t.forEach(t=>{let n=t();n instanceof Promise&&e.push(n)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=e.length?Promise.all(e).then(()=>void 0):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((n,r)=>{let i=(this.options.cwd?t.relative(this.options.cwd,r):r)||`.`;e[i]=n.getChildren().sort()}),e}emitWithAll(e,t){this.emit(e,...t),e!==M.ERROR&&this.emit(M.ALL,e,...t)}async _emit(e,n,r){if(this.closed)return;let i=this.options;D&&(n=t.normalize(n)),i.cwd&&(n=t.relative(i.cwd,n));let a=[n];r!=null&&a.push(r);let o=i.awaitWriteFinish,s;if(o&&(s=this._pendingWrites.get(n)))return s.lastChange=new Date,this;if(i.atomic){if(e===M.UNLINK)return this._pendingUnlinks.set(n,[e,...a]),setTimeout(()=>{this._pendingUnlinks.forEach((e,t)=>{this.emit(...e),this.emit(M.ALL,...e),this._pendingUnlinks.delete(t)})},typeof i.atomic==`number`?i.atomic:100),this;e===M.ADD&&this._pendingUnlinks.has(n)&&(e=M.CHANGE,this._pendingUnlinks.delete(n))}if(o&&(e===M.ADD||e===M.CHANGE)&&this._readyEmitted){let awfEmit=(t,n)=>{t?(e=M.ERROR,a[0]=t,this.emitWithAll(e,a)):n&&(a.length>1?a[1]=n:a.push(n),this.emitWithAll(e,a))};return this._awaitWriteFinish(n,o.stabilityThreshold,e,awfEmit),this}if(e===M.CHANGE&&!this._throttle(M.CHANGE,n,50))return this;if(i.alwaysStat&&r===void 0&&(e===M.ADD||e===M.ADD_DIR||e===M.CHANGE)){let e=i.cwd?t.join(i.cwd,n):n,r;try{r=await d(e)}catch{}if(!r||this.closed)return;a.push(r)}return this.emitWithAll(e,a),this}_handleError(e){let t=e&&e.code;return e&&t!==`ENOENT`&&t!==`ENOTDIR`&&(!this.options.ignorePermissionErrors||t!==`EPERM`&&t!==`EACCES`)&&this.emit(M.ERROR,e),e||this.closed}_throttle(e,t,n){this._throttled.has(e)||this._throttled.set(e,new Map);let r=this._throttled.get(e);if(!r)throw Error(`invalid throttle`);let i=r.get(t);if(i)return i.count++,!1;let a,clear=()=>{let e=r.get(t),n=e?e.count:0;return r.delete(t),clearTimeout(a),e&&clearTimeout(e.timeoutObject),n};a=setTimeout(clear,n);let o={timeoutObject:a,clear,count:0};return r.set(t,o),o}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,n,r,i){let a=this.options.awaitWriteFinish;if(typeof a!=`object`)return;let o=a.pollInterval,s,c=e;this.options.cwd&&!t.isAbsolute(e)&&(c=t.join(this.options.cwd,e));let l=new Date,u=this._pendingWrites;function awaitWriteFinishFn(t){p(c,(r,a)=>{if(r||!u.has(e)){r&&r.code!==`ENOENT`&&i(r);return}let c=Number(new Date);t&&a.size!==t.size&&(u.get(e).lastChange=c),c-u.get(e).lastChange>=n?(u.delete(e),i(void 0,a)):s=setTimeout(awaitWriteFinishFn,o,a)})}u.has(e)||(u.set(e,{lastChange:l,cancelWait:()=>(u.delete(e),clearTimeout(s),r)}),s=setTimeout(awaitWriteFinishFn,o))}_isIgnored(e,t){if(this.options.atomic&&W.test(e))return!0;if(!this._userIgnored){let{cwd:e}=this.options,t=(this.options.ignored||[]).map(normalizeIgnored(e)),n=[...[...this._ignoredPaths].map(normalizeIgnored(e)),...t];this._userIgnored=anymatch(n,void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new WatchHelper(e,this.options.followSymlinks,this)}_getWatchedDir(e){let n=t.resolve(e);return this._watched.has(n)||this._watched.set(n,new DirEntry(n,this._boundRemove)),this._watched.get(n)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,n,r){let i=t.join(e,n),a=t.resolve(i);if(r??=this._watched.has(i)||this._watched.has(a),!this._throttle(`remove`,i,100))return;!r&&this._watched.size===1&&this.add(e,n,!0),this._getWatchedDir(i).getChildren().forEach(e=>this._remove(i,e));let o=this._getWatchedDir(e),s=o.has(n);o.remove(n),this._symlinkPaths.has(a)&&this._symlinkPaths.delete(a);let c=i;if(this.options.cwd&&(c=t.relative(this.options.cwd,i)),this.options.awaitWriteFinish&&this._pendingWrites.has(c)&&this._pendingWrites.get(c).cancelWait()===M.ADD)return;this._watched.delete(i),this._watched.delete(a);let l=r?M.UNLINK_DIR:M.UNLINK;s&&!this._isIgnored(i)&&this._emit(l,i),this._closePath(i)}_closePath(e){this._closeFile(e);let n=t.dirname(e);this._getWatchedDir(n).remove(t.basename(e))}_closeFile(e){let t=this._closers.get(e);t&&(t.forEach(e=>e()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let n=this._closers.get(e);n||(n=[],this._closers.set(e,n)),n.push(t)}_readdirp(e,t){if(this.closed)return;let n=readdirp(e,{type:M.ALL,alwaysStat:!0,lstat:!0,...t,depth:0});return this._streams.add(n),n.once(`close`,()=>{n=void 0}),n.once(`end`,()=>{n&&=(this._streams.delete(n),void 0)}),n}};function watch$1(e,t={}){let n=new FSWatcher(t);return n.add(e),n}e(watch$1,`watch`);var q={watch:watch$1,FSWatcher};export{q as t};
@@ -0,0 +1,15 @@
1
+ import{i as e}from"../rolldown-runtime.mjs";const{min:t,max:n}=Math;var r=e((e,r=0,i=1)=>t(n(r,e),i),`default`),i=e(e=>{e._clipped=!1,e._unclipped=e.slice(0);for(let t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=r(e[t],0,255)):t===3&&(e[t]=r(e[t],0,1));return e},`default`);const a={};for(let e of[`Boolean`,`Number`,`String`,`Function`,`Array`,`Date`,`RegExp`,`Undefined`,`Null`])a[`[object ${e}]`]=e.toLowerCase();function type_default(e){return a[Object.prototype.toString.call(e)]||`object`}e(type_default,`default`);var o=e((e,t=null)=>e.length>=3?Array.prototype.slice.call(e):type_default(e[0])==`object`&&t?t.split(``).filter(t=>e[0][t]!==void 0).map(t=>e[0][t]):e[0].slice(0),`default`),s=e(e=>{if(e.length<2)return null;let t=e.length-1;return type_default(e[t])==`string`?e[t].toLowerCase():null},`default`);const{PI:c,min:l,max:u}=Math,rnd2=e=>Math.round(e*100)/100,rnd3=e=>Math.round(e*100)/100,d=c*2,p=c/3,m=c/180,h=180/c;function reverse3(e){return[...e.slice(0,3).reverse(),...e.slice(3)]}var g={format:{},autodetect:[]},Color=class{constructor(...e){let t=this;if(type_default(e[0])===`object`&&e[0].constructor&&e[0].constructor===this.constructor)return e[0];let n=s(e),r=!1;if(!n){r=!0,g.sorted||=(g.autodetect=g.autodetect.sort((e,t)=>t.p-e.p),!0);for(let t of g.autodetect)if(n=t.test(...e),n)break}if(g.format[n])t._rgb=i(g.format[n].apply(null,r?e:e.slice(0,-1)));else throw Error(`unknown format: `+e);t._rgb.length===3&&t._rgb.push(1)}toString(){return type_default(this.hex)==`function`?this.hex():`[${this._rgb.join(`,`)}]`}};const chroma=(...e)=>new Color(...e);chroma.version=`3.2.0`;const _={aliceblue:`#f0f8ff`,antiquewhite:`#faebd7`,aqua:`#00ffff`,aquamarine:`#7fffd4`,azure:`#f0ffff`,beige:`#f5f5dc`,bisque:`#ffe4c4`,black:`#000000`,blanchedalmond:`#ffebcd`,blue:`#0000ff`,blueviolet:`#8a2be2`,brown:`#a52a2a`,burlywood:`#deb887`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,cornflowerblue:`#6495ed`,cornsilk:`#fff8dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,darkkhaki:`#bdb76b`,darkmagenta:`#8b008b`,darkolivegreen:`#556b2f`,darkorange:`#ff8c00`,darkorchid:`#9932cc`,darkred:`#8b0000`,darksalmon:`#e9967a`,darkseagreen:`#8fbc8f`,darkslateblue:`#483d8b`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,darkturquoise:`#00ced1`,darkviolet:`#9400d3`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,dimgray:`#696969`,dimgrey:`#696969`,dodgerblue:`#1e90ff`,firebrick:`#b22222`,floralwhite:`#fffaf0`,forestgreen:`#228b22`,fuchsia:`#ff00ff`,gainsboro:`#dcdcdc`,ghostwhite:`#f8f8ff`,gold:`#ffd700`,goldenrod:`#daa520`,gray:`#808080`,green:`#008000`,greenyellow:`#adff2f`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,indianred:`#cd5c5c`,indigo:`#4b0082`,ivory:`#fffff0`,khaki:`#f0e68c`,laserlemon:`#ffff54`,lavender:`#e6e6fa`,lavenderblush:`#fff0f5`,lawngreen:`#7cfc00`,lemonchiffon:`#fffacd`,lightblue:`#add8e6`,lightcoral:`#f08080`,lightcyan:`#e0ffff`,lightgoldenrod:`#fafad2`,lightgoldenrodyellow:`#fafad2`,lightgray:`#d3d3d3`,lightgreen:`#90ee90`,lightgrey:`#d3d3d3`,lightpink:`#ffb6c1`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,lightskyblue:`#87cefa`,lightslategray:`#778899`,lightslategrey:`#778899`,lightsteelblue:`#b0c4de`,lightyellow:`#ffffe0`,lime:`#00ff00`,limegreen:`#32cd32`,linen:`#faf0e6`,magenta:`#ff00ff`,maroon:`#800000`,maroon2:`#7f0000`,maroon3:`#b03060`,mediumaquamarine:`#66cdaa`,mediumblue:`#0000cd`,mediumorchid:`#ba55d3`,mediumpurple:`#9370db`,mediumseagreen:`#3cb371`,mediumslateblue:`#7b68ee`,mediumspringgreen:`#00fa9a`,mediumturquoise:`#48d1cc`,mediumvioletred:`#c71585`,midnightblue:`#191970`,mintcream:`#f5fffa`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,navajowhite:`#ffdead`,navy:`#000080`,oldlace:`#fdf5e6`,olive:`#808000`,olivedrab:`#6b8e23`,orange:`#ffa500`,orangered:`#ff4500`,orchid:`#da70d6`,palegoldenrod:`#eee8aa`,palegreen:`#98fb98`,paleturquoise:`#afeeee`,palevioletred:`#db7093`,papayawhip:`#ffefd5`,peachpuff:`#ffdab9`,peru:`#cd853f`,pink:`#ffc0cb`,plum:`#dda0dd`,powderblue:`#b0e0e6`,purple:`#800080`,purple2:`#7f007f`,purple3:`#a020f0`,rebeccapurple:`#663399`,red:`#ff0000`,rosybrown:`#bc8f8f`,royalblue:`#4169e1`,saddlebrown:`#8b4513`,salmon:`#fa8072`,sandybrown:`#f4a460`,seagreen:`#2e8b57`,seashell:`#fff5ee`,sienna:`#a0522d`,silver:`#c0c0c0`,skyblue:`#87ceeb`,slateblue:`#6a5acd`,slategray:`#708090`,slategrey:`#708090`,snow:`#fffafa`,springgreen:`#00ff7f`,steelblue:`#4682b4`,tan:`#d2b48c`,teal:`#008080`,thistle:`#d8bfd8`,tomato:`#ff6347`,turquoise:`#40e0d0`,violet:`#ee82ee`,wheat:`#f5deb3`,white:`#ffffff`,whitesmoke:`#f5f5f5`,yellow:`#ffff00`,yellowgreen:`#9acd32`},v=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,y=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,hex2rgb=e=>{if(e.match(v)){(e.length===4||e.length===7)&&(e=e.substr(1)),e.length===3&&(e=e.split(``),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);let t=parseInt(e,16);return[t>>16,t>>8&255,t&255,1]}if(e.match(y)){(e.length===5||e.length===9)&&(e=e.substr(1)),e.length===4&&(e=e.split(``),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);let t=parseInt(e,16);return[t>>24&255,t>>16&255,t>>8&255,Math.round((t&255)/255*100)/100]}throw Error(`unknown hex color: ${e}`)},{round:b}=Math,rgb2hex=(...e)=>{let[t,n,r,i]=o(e,`rgba`),a=s(e)||`auto`;i===void 0&&(i=1),a===`auto`&&(a=i<1?`rgba`:`rgb`),t=b(t),n=b(n),r=b(r);let c=`000000`+(t<<16|n<<8|r).toString(16);c=c.substr(c.length-6);let l=`0`+b(i*255).toString(16);switch(l=l.substr(l.length-2),a.toLowerCase()){case`rgba`:return`#${c}${l}`;case`argb`:return`#${l}${c}`;default:return`#${c}`}};Color.prototype.name=function(){let e=rgb2hex(this._rgb,`rgb`);for(let t of Object.keys(_))if(_[t]===e)return t.toLowerCase();return e},g.format.named=e=>{if(e=e.toLowerCase(),_[e])return hex2rgb(_[e]);throw Error(`unknown color name: `+e)},g.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&type_default(e)===`string`&&_[e.toLowerCase()])return`named`}}),Color.prototype.alpha=function(e,t=!1){return e!==void 0&&type_default(e)===`number`?t?(this._rgb[3]=e,this):new Color([this._rgb[0],this._rgb[1],this._rgb[2],e],`rgb`):this._rgb[3]},Color.prototype.clipped=function(){return this._rgb._clipped||!1};const x={Kn:18,labWhitePoint:`d65`,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:216/24389,kKE:8,kK:24389/27,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},S=new Map([[`a`,[1.0985,.35585]],[`b`,[1.0985,.35585]],[`c`,[.98074,1.18232]],[`d50`,[.96422,.82521]],[`d55`,[.95682,.92149]],[`d65`,[.95047,1.08883]],[`e`,[1,1,1]],[`f2`,[.99186,.67393]],[`f7`,[.95041,1.08747]],[`f11`,[1.00962,.6435]],[`icc`,[.96422,.82521]]]);function setLabWhitePoint(e){let t=S.get(String(e).toLowerCase());if(!t)throw Error(`unknown Lab illuminant `+e);x.labWhitePoint=e,x.Xn=t[0],x.Zn=t[1]}function getLabWhitePoint(){return x.labWhitePoint}const lab2rgb=(...e)=>{e=o(e,`lab`);let[t,n,r]=e,[i,a,s]=lab2xyz(t,n,r),[c,l,u]=xyz2rgb(i,a,s);return[c,l,u,e.length>3?e[3]:1]},lab2xyz=(e,t,n)=>{let{kE:r,kK:i,kKE:a,Xn:o,Yn:s,Zn:c}=x,l=(e+16)/116,u=.002*t+l,d=l-.005*n,p=u*u*u,m=d*d*d,h=p>r?p:(116*u-16)/i,g=e>a?((e+16)/116)**3:e/i,_=m>r?m:(116*d-16)/i;return[h*o,g*s,_*c]},compand=e=>{let t=Math.sign(e);return e=Math.abs(e),(e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055)*t},xyz2rgb=(e,t,n)=>{let{MtxAdaptMa:r,MtxAdaptMaI:i,MtxXYZ2RGB:a,RefWhiteRGB:o,Xn:s,Yn:c,Zn:l}=x,u=s*r.m00+c*r.m10+l*r.m20,d=s*r.m01+c*r.m11+l*r.m21,p=s*r.m02+c*r.m12+l*r.m22,m=o.X*r.m00+o.Y*r.m10+o.Z*r.m20,h=o.X*r.m01+o.Y*r.m11+o.Z*r.m21,g=o.X*r.m02+o.Y*r.m12+o.Z*r.m22,_=(e*r.m00+t*r.m10+n*r.m20)*(m/u),v=(e*r.m01+t*r.m11+n*r.m21)*(h/d),y=(e*r.m02+t*r.m12+n*r.m22)*(g/p),b=_*i.m00+v*i.m10+y*i.m20,S=_*i.m01+v*i.m11+y*i.m21,C=_*i.m02+v*i.m12+y*i.m22,w=compand(b*a.m00+S*a.m10+C*a.m20),T=compand(b*a.m01+S*a.m11+C*a.m21),E=compand(b*a.m02+S*a.m12+C*a.m22);return[w*255,T*255,E*255]},rgb2lab=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=rgb2xyz(t,n,r),[l,u,d]=xyz2lab(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};function xyz2lab(e,t,n){let{Xn:r,Yn:i,Zn:a,kE:o,kK:s}=x,c=e/r,l=t/i,u=n/a,d=c>o?c**(1/3):(s*c+16)/116,p=l>o?l**(1/3):(s*l+16)/116,m=u>o?u**(1/3):(s*u+16)/116;return[116*p-16,500*(d-p),200*(p-m)]}function gammaAdjustSRGB(e){let t=Math.sign(e);return e=Math.abs(e),(e<=.04045?e/12.92:((e+.055)/1.055)**2.4)*t}const rgb2xyz=(e,t,n)=>{e=gammaAdjustSRGB(e/255),t=gammaAdjustSRGB(t/255),n=gammaAdjustSRGB(n/255);let{MtxRGB2XYZ:r,MtxAdaptMa:i,MtxAdaptMaI:a,Xn:o,Yn:s,Zn:c,As:l,Bs:u,Cs:d}=x,p=e*r.m00+t*r.m10+n*r.m20,m=e*r.m01+t*r.m11+n*r.m21,h=e*r.m02+t*r.m12+n*r.m22,g=o*i.m00+s*i.m10+c*i.m20,_=o*i.m01+s*i.m11+c*i.m21,v=o*i.m02+s*i.m12+c*i.m22,y=p*i.m00+m*i.m10+h*i.m20,b=p*i.m01+m*i.m11+h*i.m21,S=p*i.m02+m*i.m12+h*i.m22;return y*=g/l,b*=_/u,S*=v/d,p=y*a.m00+b*a.m10+S*a.m20,m=y*a.m01+b*a.m11+S*a.m21,h=y*a.m02+b*a.m12+S*a.m22,[p,m,h]};Color.prototype.lab=function(){return rgb2lab(this._rgb)},Object.assign(chroma,{lab:e((...e)=>new Color(...e,`lab`),`lab`),getLabWhitePoint,setLabWhitePoint}),g.format.lab=lab2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`lab`),type_default(e)===`array`&&e.length===3)return`lab`}}),Color.prototype.darken=function(e=1){let t=this,n=t.lab();return n[0]-=x.Kn*e,new Color(n,`lab`).alpha(t.alpha(),!0)},Color.prototype.brighten=function(e=1){return this.darken(-e)},Color.prototype.darker=Color.prototype.darken,Color.prototype.brighter=Color.prototype.brighten,Color.prototype.get=function(e){let[t,n]=e.split(`.`),r=this[t]();if(n){let e=t.indexOf(n)-(t.substr(0,2)===`ok`?2:0);if(e>-1)return r[e];throw Error(`unknown channel ${n} in mode ${t}`)}else return r};const{pow:C}=Math;Color.prototype.luminance=function(e,t=`rgb`){if(e!==void 0&&type_default(e)===`number`){if(e===0)return new Color([0,0,0,this._rgb[3]],`rgb`);if(e===1)return new Color([255,255,255,this._rgb[3]],`rgb`);let n=this.luminance(),r=20,test=(n,i)=>{let a=n.interpolate(i,.5,t),o=a.luminance();return Math.abs(e-o)<1e-7||!r--?a:o>e?test(n,a):test(a,i)};return new Color([...(n>e?test(new Color([0,0,0]),this):test(this,new Color([255,255,255]))).rgb(),this._rgb[3]])}return rgb2luminance(...this._rgb.slice(0,3))};const rgb2luminance=(e,t,n)=>(e=luminance_x(e),t=luminance_x(t),n=luminance_x(n),.2126*e+.7152*t+.0722*n),luminance_x=e=>(e/=255,e<=.03928?e/12.92:C((e+.055)/1.055,2.4));var w={},T=e((e,t,n=.5,...r)=>{let i=r[0]||`lrgb`;if(!w[i]&&!r.length&&(i=Object.keys(w)[0]),!w[i])throw Error(`interpolation mode ${i} is not defined`);return type_default(e)!==`object`&&(e=new Color(e)),type_default(t)!==`object`&&(t=new Color(t)),w[i](e,t,n).alpha(e.alpha()+n*(t.alpha()-e.alpha()))},`default`);Color.prototype.mix=Color.prototype.interpolate=function(e,t=.5,...n){return T(this,e,t,...n)},Color.prototype.premultiply=function(e=!1){let t=this._rgb,n=t[3];return e?(this._rgb=[t[0]*n,t[1]*n,t[2]*n,n],this):new Color([t[0]*n,t[1]*n,t[2]*n,n],`rgb`)};const{sin:E,cos:ee}=Math,lch2lab=(...e)=>{let[t,n,r]=o(e,`lch`);return isNaN(r)&&(r=0),r*=m,[t,ee(r)*n,E(r)*n]},lch2rgb=(...e)=>{e=o(e,`lch`);let[t,n,r]=e,[i,a,s]=lch2lab(t,n,r),[c,l,u]=lab2rgb(i,a,s);return[c,l,u,e.length>3?e[3]:1]},hcl2rgb=(...e)=>lch2rgb(...reverse3(o(e,`hcl`))),{sqrt:D,atan2:te,round:O}=Math,lab2lch=(...e)=>{let[t,n,r]=o(e,`lab`),i=D(n*n+r*r),a=(te(r,n)*h+360)%360;return O(i*1e4)===0&&(a=NaN),[t,i,a]},rgb2lch=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=rgb2lab(t,n,r),[l,u,d]=lab2lch(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};Color.prototype.lch=function(){return rgb2lch(this._rgb)},Color.prototype.hcl=function(){return reverse3(rgb2lch(this._rgb))};const k=e((...e)=>new Color(...e,`lch`),`lch`),hcl=(...e)=>new Color(...e,`hcl`);Object.assign(chroma,{lch:k,hcl}),g.format.lch=lch2rgb,g.format.hcl=hcl2rgb,[`lch`,`hcl`].forEach(e=>g.autodetect.push({p:2,test:(...t)=>{if(t=o(t,e),type_default(t)===`array`&&t.length===3)return e}})),Color.prototype.saturate=function(e=1){let t=this,n=t.lch();return n[1]+=x.Kn*e,n[1]<0&&(n[1]=0),new Color(n,`lch`).alpha(t.alpha(),!0)},Color.prototype.desaturate=function(e=1){return this.saturate(-e)},Color.prototype.set=function(e,t,n=!1){let[r,i]=e.split(`.`),a=this[r]();if(i){let e=r.indexOf(i)-(r.substr(0,2)===`ok`?2:0);if(e>-1){if(type_default(t)==`string`)switch(t.charAt(0)){case`+`:a[e]+=+t;break;case`-`:a[e]+=+t;break;case`*`:a[e]*=+t.substr(1);break;case`/`:a[e]/=+t.substr(1);break;default:a[e]=+t}else if(type_default(t)===`number`)a[e]=t;else throw Error(`unsupported value for Color.set`);let i=new Color(a,r);return n?(this._rgb=i._rgb,this):i}throw Error(`unknown channel ${i} in mode ${r}`)}else return a},Color.prototype.tint=function(e=.5,...t){return T(this,`white`,e,...t)},Color.prototype.shade=function(e=.5,...t){return T(this,`black`,e,...t)},w.rgb=e((e,t,n)=>{let r=e._rgb,i=t._rgb;return new Color(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`rgb`)},`rgb`);const{sqrt:A,pow:j}=Math,lrgb=(e,t,n)=>{let[r,i,a]=e._rgb,[o,s,c]=t._rgb;return new Color(A(j(r,2)*(1-n)+j(o,2)*n),A(j(i,2)*(1-n)+j(s,2)*n),A(j(a,2)*(1-n)+j(c,2)*n),`rgb`)};w.lrgb=lrgb;const lab=(e,t,n)=>{let r=e.lab(),i=t.lab();return new Color(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`lab`)};w.lab=lab;var M=e((e,t,n,r)=>{let i,a;r===`hsl`?(i=e.hsl(),a=t.hsl()):r===`hsv`?(i=e.hsv(),a=t.hsv()):r===`hcg`?(i=e.hcg(),a=t.hcg()):r===`hsi`?(i=e.hsi(),a=t.hsi()):r===`lch`||r===`hcl`?(r=`hcl`,i=e.hcl(),a=t.hcl()):r===`oklch`&&(i=e.oklch().reverse(),a=t.oklch().reverse());let o,s,c,l,u,d;(r.substr(0,1)===`h`||r===`oklch`)&&([o,c,u]=i,[s,l,d]=a);let p,m,h,g;return!isNaN(o)&&!isNaN(s)?(g=s>o&&s-o>180?s-(o+360):s<o&&o-s>180?s+360-o:s-o,m=o+n*g):isNaN(o)?isNaN(s)?m=NaN:(m=s,(u==1||u==0)&&r!=`hsv`&&(p=l)):(m=o,(d==1||d==0)&&r!=`hsv`&&(p=c)),p===void 0&&(p=c+n*(l-c)),h=u+n*(d-u),r===`oklch`?new Color([h,p,m],r):new Color([m,p,h],r)},`default`);const lch=(e,t,n)=>M(e,t,n,`lch`);w.lch=lch,w.hcl=lch;const num2rgb=e=>{if(type_default(e)==`number`&&e>=0&&e<=16777215)return[e>>16,e>>8&255,e&255,1];throw Error(`unknown num color: `+e)},rgb2num=(...e)=>{let[t,n,r]=o(e,`rgb`);return(t<<16)+(n<<8)+r};Color.prototype.num=function(){return rgb2num(this._rgb)},Object.assign(chroma,{num:e((...e)=>new Color(...e,`num`),`num`)}),g.format.num=num2rgb,g.autodetect.push({p:5,test:(...e)=>{if(e.length===1&&type_default(e[0])===`number`&&e[0]>=0&&e[0]<=16777215)return`num`}});const num=(e,t,n)=>{let r=e.num();return new Color(r+n*(t.num()-r),`num`)};w.num=num;const{floor:ne}=Math,hcg2rgb=(...e)=>{e=o(e,`hcg`);let[t,n,r]=e,i,a,s;r*=255;let c=n*255;if(n===0)i=a=s=r;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let e=ne(t),o=t-e,l=r*(1-n),u=l+c*(1-o),d=l+c*o,p=l+c;switch(e){case 0:[i,a,s]=[p,d,l];break;case 1:[i,a,s]=[u,p,l];break;case 2:[i,a,s]=[l,p,d];break;case 3:[i,a,s]=[l,u,p];break;case 4:[i,a,s]=[d,l,p];break;case 5:[i,a,s]=[p,l,u];break}}return[i,a,s,e.length>3?e[3]:1]},rgb2hcg=(...e)=>{let[t,n,r]=o(e,`rgb`),i=l(t,n,r),a=u(t,n,r),s=a-i,c=s*100/255,d=i/(255-s)*100,p;return s===0?p=NaN:(t===a&&(p=(n-r)/s),n===a&&(p=2+(r-t)/s),r===a&&(p=4+(t-n)/s),p*=60,p<0&&(p+=360)),[p,c,d]};Color.prototype.hcg=function(){return rgb2hcg(this._rgb)},chroma.hcg=e((...e)=>new Color(...e,`hcg`),`hcg`),g.format.hcg=hcg2rgb,g.autodetect.push({p:1,test:(...e)=>{if(e=o(e,`hcg`),type_default(e)===`array`&&e.length===3)return`hcg`}});const hcg=(e,t,n)=>M(e,t,n,`hcg`);w.hcg=hcg;const{cos:N}=Math,hsi2rgb=(...e)=>{e=o(e,`hsi`);let[t,n,i]=e,a,s,c;return isNaN(t)&&(t=0),isNaN(n)&&(n=0),t>360&&(t-=360),t<0&&(t+=360),t/=360,t<1/3?(c=(1-n)/3,a=(1+n*N(d*t)/N(p-d*t))/3,s=1-(c+a)):t<2/3?(t-=1/3,a=(1-n)/3,s=(1+n*N(d*t)/N(p-d*t))/3,c=1-(a+s)):(t-=2/3,s=(1-n)/3,c=(1+n*N(d*t)/N(p-d*t))/3,a=1-(s+c)),a=r(i*a*3),s=r(i*s*3),c=r(i*c*3),[a*255,s*255,c*255,e.length>3?e[3]:1]},{min:re,sqrt:ie,acos:ae}=Math,rgb2hsi=(...e)=>{let[t,n,r]=o(e,`rgb`);t/=255,n/=255,r/=255;let i,a=re(t,n,r),s=(t+n+r)/3,c=s>0?1-a/s:0;return c===0?i=NaN:(i=(t-n+(t-r))/2,i/=ie((t-n)*(t-n)+(t-r)*(n-r)),i=ae(i),r>n&&(i=d-i),i/=d),[i*360,c,s]};Color.prototype.hsi=function(){return rgb2hsi(this._rgb)},chroma.hsi=e((...e)=>new Color(...e,`hsi`),`hsi`),g.format.hsi=hsi2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsi`),type_default(e)===`array`&&e.length===3)return`hsi`}});const hsi=(e,t,n)=>M(e,t,n,`hsi`);w.hsi=hsi;const hsl2rgb=(...e)=>{e=o(e,`hsl`);let[t,n,r]=e,i,a,s;if(n===0)i=a=s=r*255;else{let e=[0,0,0],o=[0,0,0],c=r<.5?r*(1+n):r+n-r*n,l=2*r-c,u=t/360;e[0]=u+1/3,e[1]=u,e[2]=u-1/3;for(let t=0;t<3;t++)e[t]<0&&(e[t]+=1),e[t]>1&&--e[t],6*e[t]<1?o[t]=l+(c-l)*6*e[t]:2*e[t]<1?o[t]=c:3*e[t]<2?o[t]=l+(c-l)*(2/3-e[t])*6:o[t]=l;[i,a,s]=[o[0]*255,o[1]*255,o[2]*255]}return e.length>3?[i,a,s,e[3]]:[i,a,s,1]},oe=e((...e)=>{e=o(e,`rgba`);let[t,n,r]=e;t/=255,n/=255,r/=255;let i=l(t,n,r),a=u(t,n,r),s=(a+i)/2,c,d;return a===i?(c=0,d=NaN):c=s<.5?(a-i)/(a+i):(a-i)/(2-a-i),t==a?d=(n-r)/(a-i):n==a?d=2+(r-t)/(a-i):r==a&&(d=4+(t-n)/(a-i)),d*=60,d<0&&(d+=360),e.length>3&&e[3]!==void 0?[d,c,s,e[3]]:[d,c,s]},`rgb2hsl`);Color.prototype.hsl=function(){return oe(this._rgb)},chroma.hsl=e((...e)=>new Color(...e,`hsl`),`hsl`),g.format.hsl=hsl2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsl`),type_default(e)===`array`&&e.length===3)return`hsl`}});const hsl=(e,t,n)=>M(e,t,n,`hsl`);w.hsl=hsl;const{floor:se}=Math,hsv2rgb=(...e)=>{e=o(e,`hsv`);let[t,n,r]=e,i,a,s;if(r*=255,n===0)i=a=s=r;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let e=se(t),o=t-e,c=r*(1-n),l=r*(1-n*o),u=r*(1-n*(1-o));switch(e){case 0:[i,a,s]=[r,u,c];break;case 1:[i,a,s]=[l,r,c];break;case 2:[i,a,s]=[c,r,u];break;case 3:[i,a,s]=[c,l,r];break;case 4:[i,a,s]=[u,c,r];break;case 5:[i,a,s]=[r,c,l];break}}return[i,a,s,e.length>3?e[3]:1]},{min:ce,max:le}=Math,rgb2hsl=(...e)=>{e=o(e,`rgb`);let[t,n,r]=e,i=ce(t,n,r),a=le(t,n,r),s=a-i,c,l,u;return u=a/255,a===0?(c=NaN,l=0):(l=s/a,t===a&&(c=(n-r)/s),n===a&&(c=2+(r-t)/s),r===a&&(c=4+(t-n)/s),c*=60,c<0&&(c+=360)),[c,l,u]};Color.prototype.hsv=function(){return rgb2hsl(this._rgb)},chroma.hsv=e((...e)=>new Color(...e,`hsv`),`hsv`),g.format.hsv=hsv2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsv`),type_default(e)===`array`&&e.length===3)return`hsv`}});const hsv=(e,t,n)=>M(e,t,n,`hsv`);w.hsv=hsv;function multiplyMatrices(e,t){let n=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let r=t[0].length,i=t[0].map((e,n)=>t.map(e=>e[n])),a=e.map(e=>i.map(t=>Array.isArray(e)?e.reduce((e,n,r)=>e+n*(t[r]||0),0):t.reduce((t,n)=>t+n*e,0)));return n===1&&(a=a[0]),r===1?a.map(e=>e[0]):a}const oklab2rgb=(...e)=>{e=o(e,`lab`);let[t,n,r,...i]=e,[a,s,c]=OKLab_to_XYZ([t,n,r]),[l,u,d]=xyz2rgb(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};function OKLab_to_XYZ(e){return multiplyMatrices([[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],multiplyMatrices([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],e).map(e=>e**3))}const rgb2oklab=(...e)=>{let[t,n,r,...i]=o(e,`rgb`);return[...XYZ_to_OKLab(rgb2xyz(t,n,r)),...i.length>0&&i[0]<1?[i[0]]:[]]};function XYZ_to_OKLab(e){return multiplyMatrices([[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],multiplyMatrices([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],e).map(e=>Math.cbrt(e)))}Color.prototype.oklab=function(){return rgb2oklab(this._rgb)},Object.assign(chroma,{oklab:e((...e)=>new Color(...e,`oklab`),`oklab`)}),g.format.oklab=oklab2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`oklab`),type_default(e)===`array`&&e.length===3)return`oklab`}});const oklab=(e,t,n)=>{let r=e.oklab(),i=t.oklab();return new Color(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`oklab`)};w.oklab=oklab,w.oklch=e((e,t,n)=>M(e,t,n,`oklch`),`oklch`);const{pow:P,sqrt:F,PI:L,cos:ue,sin:de,atan2:fe}=Math;var pe=e((e,t=`lrgb`,n=null)=>{let r=e.length;n||=Array.from(Array(r)).map(()=>1);let i=r/n.reduce(function(e,t){return e+t});if(n.forEach((e,t)=>{n[t]*=i}),e=e.map(e=>new Color(e)),t===`lrgb`)return _average_lrgb(e,n);let a=e.shift(),o=a.get(t),s=[],c=0,l=0;for(let e=0;e<o.length;e++)if(o[e]=(o[e]||0)*n[0],s.push(isNaN(o[e])?0:n[0]),t.charAt(e)===`h`&&!isNaN(o[e])){let t=o[e]/180*L;c+=ue(t)*n[0],l+=de(t)*n[0]}let u=a.alpha()*n[0];e.forEach((e,r)=>{let i=e.get(t);u+=e.alpha()*n[r+1];for(let e=0;e<o.length;e++)if(!isNaN(i[e]))if(s[e]+=n[r+1],t.charAt(e)===`h`){let t=i[e]/180*L;c+=ue(t)*n[r+1],l+=de(t)*n[r+1]}else o[e]+=i[e]*n[r+1]});for(let e=0;e<o.length;e++)if(t.charAt(e)===`h`){let t=fe(l/s[e],c/s[e])/L*180;for(;t<0;)t+=360;for(;t>=360;)t-=360;o[e]=t}else o[e]=o[e]/s[e];return u/=r,new Color(o,t).alpha(u>.99999?1:u,!0)},`default`);const _average_lrgb=(e,t)=>{let n=e.length,r=[0,0,0,0];for(let i=0;i<e.length;i++){let a=e[i],o=t[i]/n,s=a._rgb;r[0]+=P(s[0],2)*o,r[1]+=P(s[1],2)*o,r[2]+=P(s[2],2)*o,r[3]+=s[3]*o}return r[0]=F(r[0]),r[1]=F(r[1]),r[2]=F(r[2]),r[3]>.9999999&&(r[3]=1),new Color(i(r))},{pow:me}=Math;function scale_default(e){let t=`rgb`,n=chroma(`#ccc`),i=0,a=[0,1],o=[0,1],s=[],c=[0,0],l=!1,u=[],d=!1,p=0,m=1,h=!1,g={},_=!0,v=1,setColors=function(e){if(e||=[`#fff`,`#000`],e&&type_default(e)===`string`&&chroma.brewer&&chroma.brewer[e.toLowerCase()]&&(e=chroma.brewer[e.toLowerCase()]),type_default(e)===`array`){e.length===1&&(e=[e[0],e[0]]),e=e.slice(0);for(let t=0;t<e.length;t++)e[t]=chroma(e[t]);s.length=0;for(let t=0;t<e.length;t++)s.push(t/(e.length-1))}return resetCache(),u=e},getClass=function(e){if(l!=null){let t=l.length-1,n=0;for(;n<t&&e>=l[n];)n++;return n-1}return 0},tMapLightness=e=>e,tMapDomain=e=>e,getColor=function(e,i){let a,o;if(i??=!1,isNaN(e)||e===null)return n;o=i?e:l&&l.length>2?getClass(e)/(l.length-2):m===p?1:(e-p)/(m-p),o=tMapDomain(o),i||(o=tMapLightness(o)),v!==1&&(o=me(o,v)),o=c[0]+o*(1-c[0]-c[1]),o=r(o,0,1);let d=Math.floor(o*1e4);if(_&&g[d])a=g[d];else{if(type_default(u)===`array`)for(let e=0;e<s.length;e++){let n=s[e];if(o<=n){a=u[e];break}if(o>=n&&e===s.length-1){a=u[e];break}if(o>n&&o<s[e+1]){o=(o-n)/(s[e+1]-n),a=chroma.interpolate(u[e],u[e+1],o,t);break}}else type_default(u)===`function`&&(a=u(o));_&&(g[d]=a)}return a};var resetCache=()=>g={};setColors(e);let f=function(e){let t=chroma(getColor(e));return d&&t[d]?t[d]():t};return f.classes=function(e){if(e!=null){if(type_default(e)===`array`)l=e,a=[e[0],e[e.length-1]];else{let t=chroma.analyze(a);l=e===0?[t.min,t.max]:chroma.limits(t,`e`,e)}return f}return l},f.domain=function(e){if(!arguments.length)return o;o=e.slice(0),p=e[0],m=e[e.length-1],s=[];let t=u.length;if(e.length===t&&p!==m)for(let t of Array.from(e))s.push((t-p)/(m-p));else{for(let e=0;e<t;e++)s.push(e/(t-1));if(e.length>2){let t=e.map((t,n)=>n/(e.length-1)),n=e.map(e=>(e-p)/(m-p));n.every((e,n)=>t[n]===e)||(tMapDomain=e=>{if(e<=0||e>=1)return e;let r=0;for(;e>=n[r+1];)r++;let i=(e-n[r])/(n[r+1]-n[r]);return t[r]+i*(t[r+1]-t[r])})}}return a=[p,m],f},f.mode=function(e){return arguments.length?(t=e,resetCache(),f):t},f.range=function(e,t){return setColors(e,t),f},f.out=function(e){return d=e,f},f.spread=function(e){return arguments.length?(i=e,f):i},f.correctLightness=function(e){return e??=!0,h=e,resetCache(),tMapLightness=h?function(e){let t=getColor(0,!0).lab()[0],n=getColor(1,!0).lab()[0],r=t>n,i=getColor(e,!0).lab()[0],a=t+(n-t)*e,o=i-a,s=0,c=1,l=20;for(;Math.abs(o)>.01&&l-- >0;)(function(){return r&&(o*=-1),o<0?(s=e,e+=(c-e)*.5):(c=e,e+=(s-e)*.5),i=getColor(e,!0).lab()[0],o=i-a})();return e}:e=>e,f},f.padding=function(e){return e==null?c:(type_default(e)===`number`&&(e=[e,e]),c=e,f)},f.colors=function(t,n){arguments.length<2&&(n=`hex`);let r=[];if(arguments.length===0)r=u.slice(0);else if(t===1)r=[f(.5)];else if(t>1){let e=a[0],n=a[1]-e;r=__range__(0,t,!1).map(r=>f(e+r/(t-1)*n))}else{e=[];let t=[];if(l&&l.length>2)for(let e=1,n=l.length,r=1<=n;r?e<n:e>n;r?e++:e--)t.push((l[e-1]+l[e])*.5);else t=a;r=t.map(e=>f(e))}return chroma[n]&&(r=r.map(e=>e[n]())),r},f.cache=function(e){return e==null?_:(_=e,f)},f.gamma=function(e){return e==null?v:(v=e,f)},f.nodata=function(e){return e==null?n:(n=chroma(e),f)},f}e(scale_default,`default`);function __range__(e,t,n){let r=[],i=e<t,a=n?i?t+1:t-1:t;for(let t=e;i?t<a:t>a;i?t++:t--)r.push(t);return r}const binom_row=function(e){let t=[1,1];for(let n=1;n<e;n++){let e=[1];for(let n=1;n<=t.length;n++)e[n]=(t[n]||0)+t[n-1];t=e}return t},bezier=function(e){let I,t,n,r;if(e=e.map(e=>new Color(e)),e.length===2)[t,n]=e.map(e=>e.lab()),I=function(e){return new Color([0,1,2].map(r=>t[r]+e*(n[r]-t[r])),`lab`)};else if(e.length===3)[t,n,r]=e.map(e=>e.lab()),I=function(e){return new Color([0,1,2].map(i=>(1-e)*(1-e)*t[i]+2*(1-e)*e*n[i]+e*e*r[i]),`lab`)};else if(e.length===4){let i;[t,n,r,i]=e.map(e=>e.lab()),I=function(e){return new Color([0,1,2].map(a=>(1-e)*(1-e)*(1-e)*t[a]+3*(1-e)*(1-e)*e*n[a]+3*(1-e)*e*e*r[a]+e*e*e*i[a]),`lab`)}}else if(e.length>=5){let t,n,r;t=e.map(e=>e.lab()),r=e.length-1,n=binom_row(r),I=function(e){let i=1-e;return new Color([0,1,2].map(a=>t.reduce((t,o,s)=>t+n[s]*i**(r-s)*e**s*o[a],0)),`lab`)}}else throw RangeError(`No point in running bezier with only one color.`);return I};var he=e(e=>{let t=bezier(e);return t.scale=()=>scale_default(t),t},`default`);const{round:R}=Math;Color.prototype.rgb=function(e=!0){return e===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(R)},Color.prototype.rgba=function(e=!0){return this._rgb.slice(0,4).map((t,n)=>n<3?e===!1?t:R(t):t)};const rgb=(...e)=>new Color(...e,`rgb`);Object.assign(chroma,{rgb}),g.format.rgb=(...e)=>{let t=o(e,`rgba`);return t[3]===void 0&&(t[3]=1),t},g.autodetect.push({p:3,test:(...e)=>{if(e=o(e,`rgba`),type_default(e)===`array`&&(e.length===3||e.length===4&&type_default(e[3])==`number`&&e[3]>=0&&e[3]<=1))return`rgb`}});const blend=(e,t,n)=>{if(!blend[n])throw Error(`unknown blend mode `+n);return blend[n](e,t)},blend_f=e=>(t,n)=>{let r=chroma(n).rgb(),i=chroma(t).rgb();return chroma.rgb(e(r,i))},each=e=>(t,n)=>{let r=[];return r[0]=e(t[0],n[0]),r[1]=e(t[1],n[1]),r[2]=e(t[2],n[2]),r},normal=e=>e,multiply=(e,t)=>e*t/255,darken=(e,t)=>e>t?t:e,lighten=(e,t)=>e>t?e:t,screen=(e,t)=>255*(1-(1-e/255)*(1-t/255)),overlay=(e,t)=>t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255)),burn=(e,t)=>255*(1-(1-t/255)/(e/255)),dodge=(e,t)=>e===255?255:(e=t/255*255/(1-e/255),e>255?255:e);blend.normal=blend_f(each(normal)),blend.multiply=blend_f(each(multiply)),blend.screen=blend_f(each(screen)),blend.overlay=blend_f(each(overlay)),blend.darken=blend_f(each(darken)),blend.lighten=blend_f(each(lighten)),blend.dodge=blend_f(each(dodge)),blend.burn=blend_f(each(burn));const{pow:ge,sin:_e,cos:ve}=Math;function cubehelix_default(e=300,t=-1.5,n=1,r=1,a=[0,1]){let o=0,s;type_default(a)===`array`?s=a[1]-a[0]:(s=0,a=[a,a]);let f=function(c){let l=d*((e+120)/360+t*c),u=ge(a[0]+s*c,r),p=(o===0?n:n[0]+c*o)*u*(1-u)/2,m=ve(l),h=_e(l),g=u+p*(-.14861*m+1.78277*h),_=u+p*(-.29227*m-.90649*h),v=u+1.97294*m*p;return chroma(i([g*255,_*255,v*255,1]))};return f.start=function(t){return t==null?e:(e=t,f)},f.rotations=function(e){return e==null?t:(t=e,f)},f.gamma=function(e){return e==null?r:(r=e,f)},f.hue=function(e){return e==null?n:(n=e,type_default(n)===`array`?(o=n[1]-n[0],o===0&&(n=n[1])):o=0,f)},f.lightness=function(e){return e==null?a:(type_default(e)===`array`?(a=e,s=e[1]-e[0]):(a=[e,e],s=0),f)},f.scale=()=>chroma.scale(f),f.hue(n),f}e(cubehelix_default,`default`);const{floor:ye,random:be}=Math;var xe=e((e=be)=>{let t=`#`;for(let n=0;n<6;n++)t+=`0123456789abcdef`.charAt(ye(e()*16));return new Color(t,`hex`)},`default`);const{log:Se,pow:Ce,floor:we,abs:Te}=Math;function analyze(e,t=null){let n={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return type_default(e)===`object`&&(e=Object.values(e)),e.forEach(e=>{t&&type_default(e)===`object`&&(e=e[t]),e!=null&&!isNaN(e)&&(n.values.push(e),n.sum+=e,e<n.min&&(n.min=e),e>n.max&&(n.max=e),n.count+=1)}),n.domain=[n.min,n.max],n.limits=(e,t)=>limits(n,e,t),n}function limits(e,t=`equal`,n=7){type_default(e)==`array`&&(e=analyze(e));let{min:r,max:i}=e,a=e.values.sort((e,t)=>e-t);if(n===1)return[r,i];let o=[];if(t.substr(0,1)===`c`&&(o.push(r),o.push(i)),t.substr(0,1)===`e`){o.push(r);for(let e=1;e<n;e++)o.push(r+e/n*(i-r));o.push(i)}else if(t.substr(0,1)===`l`){if(r<=0)throw Error(`Logarithmic scales are only possible for values > 0`);let e=Math.LOG10E*Se(r),t=Math.LOG10E*Se(i);o.push(r);for(let r=1;r<n;r++)o.push(Ce(10,e+r/n*(t-e)));o.push(i)}else if(t.substr(0,1)===`q`){o.push(r);for(let e=1;e<n;e++){let t=(a.length-1)*e/n,r=we(t);if(r===t)o.push(a[r]);else{let e=t-r;o.push(a[r]*(1-e)+a[r+1]*e)}}o.push(i)}else if(t.substr(0,1)===`k`){let e,t=a.length,s=Array(t),c=Array(n),l=!0,u=0,d=null;d=[],d.push(r);for(let e=1;e<n;e++)d.push(r+e/n*(i-r));for(d.push(i);l;){for(let e=0;e<n;e++)c[e]=0;for(let e=0;e<t;e++){let t=a[e],r=Number.MAX_VALUE,i;for(let a=0;a<n;a++){let n=Te(d[a]-t);n<r&&(r=n,i=a),c[i]++,s[e]=i}}let r=Array(n);for(let e=0;e<n;e++)r[e]=null;for(let n=0;n<t;n++)e=s[n],r[e]===null?r[e]=a[n]:r[e]+=a[n];for(let e=0;e<n;e++)r[e]*=1/c[e];l=!1;for(let e=0;e<n;e++)if(r[e]!==d[e]){l=!0;break}d=r,u++,u>200&&(l=!1)}let p={};for(let e=0;e<n;e++)p[e]=[];for(let n=0;n<t;n++)e=s[n],p[e].push(a[n]);let m=[];for(let e=0;e<n;e++)m.push(p[e][0]),m.push(p[e][p[e].length-1]);m=m.sort((e,t)=>e-t),o.push(m[0]);for(let e=1;e<m.length;e+=2){let t=m[e];!isNaN(t)&&o.indexOf(t)===-1&&o.push(t)}}return o}var Ee=e((e,t)=>{e=new Color(e),t=new Color(t);let n=e.luminance(),r=t.luminance();return n>r?(n+.05)/(r+.05):(r+.05)/(n+.05)},`default`);
2
+ /**
3
+ * @license
4
+ *
5
+ * The APCA contrast prediction algorithm is based of the formulas published
6
+ * in the APCA-1.0.98G specification by Myndex. The specification is available at:
7
+ * https://raw.githubusercontent.com/Myndex/apca-w3/master/images/APCAw3_0.1.17_APCA0.0.98G.svg
8
+ *
9
+ * Note that the APCA implementation is still beta, so please update to
10
+ * future versions of chroma.js when they become available.
11
+ *
12
+ * You can read more about the APCA Readability Criterion at
13
+ * https://readtech.org/ARC/
14
+ */
15
+ const De=.027,Oe=1.14,z=.022,ke=1.414;var Ae=e((e,t)=>{e=new Color(e),t=new Color(t),e.alpha()<1&&(e=T(t,e,e.alpha(),`rgb`));let n=lum(...e.rgb()),r=lum(...t.rgb()),i=n>=z?n:n+(z-n)**+ke,a=r>=z?r:r+(z-r)**+ke,o=a**.56-i**.57,s=a**.65-i**.62,c=Math.abs(a-i)<5e-4?0:i<a?o*Oe:s*Oe;return(Math.abs(c)<.1?0:c>0?c-De:c+De)*100},`default`);function lum(e,t,n){return .2126729*(e/255)**2.4+.7151522*(t/255)**2.4+.072175*(n/255)**2.4}const{sqrt:B,pow:V,min:je,max:Me,atan2:Ne,abs:Pe,cos:H,sin:Fe,exp:Ie,PI:Le}=Math;function delta_e_default(e,t,n=1,r=1,i=1){var rad2deg=function(e){return 360*e/(2*Le)},deg2rad=function(e){return 2*Le*e/360};e=new Color(e),t=new Color(t);let[a,o,s]=Array.from(e.lab()),[c,l,u]=Array.from(t.lab()),d=(a+c)/2,p=(B(V(o,2)+V(s,2))+B(V(l,2)+V(u,2)))/2,m=.5*(1-B(V(p,7)/(V(p,7)+V(25,7)))),h=o*(1+m),g=l*(1+m),_=B(V(h,2)+V(s,2)),v=B(V(g,2)+V(u,2)),y=(_+v)/2,b=rad2deg(Ne(s,h)),x=rad2deg(Ne(u,g)),S=b>=0?b:b+360,C=x>=0?x:x+360,w=Pe(S-C)>180?(S+C+360)/2:(S+C)/2,T=1-.17*H(deg2rad(w-30))+.24*H(deg2rad(2*w))+.32*H(deg2rad(3*w+6))-.2*H(deg2rad(4*w-63)),E=C-S;E=Pe(E)<=180?E:C<=S?E+360:E-360,E=2*B(_*v)*Fe(deg2rad(E)/2);let ee=c-a,D=v-_,te=1+.015*V(d-50,2)/B(20+V(d-50,2)),O=1+.045*y,k=1+.015*y*T,A=30*Ie(-V((w-275)/25,2)),j=-(2*B(V(y,7)/(V(y,7)+V(25,7))))*Fe(2*deg2rad(A));return Me(0,je(100,B(V(ee/(n*te),2)+V(D/(r*O),2)+V(E/(i*k),2)+j*(D/(r*O))*(E/(i*k)))))}e(delta_e_default,`default`);function distance_default(e,t,n=`lab`){e=new Color(e),t=new Color(t);let r=e.get(n),i=t.get(n),a=0;for(let e in r){let t=(r[e]||0)-(i[e]||0);a+=t*t}return Math.sqrt(a)}e(distance_default,`default`);var Re=e((...e)=>{try{return new Color(...e),!0}catch{return!1}},`default`),ze={cool(){return scale_default([chroma.hsl(180,1,.9),chroma.hsl(250,.7,.4)])},hot(){return scale_default([`#000`,`#f00`,`#ff0`,`#fff`],[0,.25,.75,1]).mode(`rgb`)}};const U={OrRd:[`#fff7ec`,`#fee8c8`,`#fdd49e`,`#fdbb84`,`#fc8d59`,`#ef6548`,`#d7301f`,`#b30000`,`#7f0000`],PuBu:[`#fff7fb`,`#ece7f2`,`#d0d1e6`,`#a6bddb`,`#74a9cf`,`#3690c0`,`#0570b0`,`#045a8d`,`#023858`],BuPu:[`#f7fcfd`,`#e0ecf4`,`#bfd3e6`,`#9ebcda`,`#8c96c6`,`#8c6bb1`,`#88419d`,`#810f7c`,`#4d004b`],Oranges:[`#fff5eb`,`#fee6ce`,`#fdd0a2`,`#fdae6b`,`#fd8d3c`,`#f16913`,`#d94801`,`#a63603`,`#7f2704`],BuGn:[`#f7fcfd`,`#e5f5f9`,`#ccece6`,`#99d8c9`,`#66c2a4`,`#41ae76`,`#238b45`,`#006d2c`,`#00441b`],YlOrBr:[`#ffffe5`,`#fff7bc`,`#fee391`,`#fec44f`,`#fe9929`,`#ec7014`,`#cc4c02`,`#993404`,`#662506`],YlGn:[`#ffffe5`,`#f7fcb9`,`#d9f0a3`,`#addd8e`,`#78c679`,`#41ab5d`,`#238443`,`#006837`,`#004529`],Reds:[`#fff5f0`,`#fee0d2`,`#fcbba1`,`#fc9272`,`#fb6a4a`,`#ef3b2c`,`#cb181d`,`#a50f15`,`#67000d`],RdPu:[`#fff7f3`,`#fde0dd`,`#fcc5c0`,`#fa9fb5`,`#f768a1`,`#dd3497`,`#ae017e`,`#7a0177`,`#49006a`],Greens:[`#f7fcf5`,`#e5f5e0`,`#c7e9c0`,`#a1d99b`,`#74c476`,`#41ab5d`,`#238b45`,`#006d2c`,`#00441b`],YlGnBu:[`#ffffd9`,`#edf8b1`,`#c7e9b4`,`#7fcdbb`,`#41b6c4`,`#1d91c0`,`#225ea8`,`#253494`,`#081d58`],Purples:[`#fcfbfd`,`#efedf5`,`#dadaeb`,`#bcbddc`,`#9e9ac8`,`#807dba`,`#6a51a3`,`#54278f`,`#3f007d`],GnBu:[`#f7fcf0`,`#e0f3db`,`#ccebc5`,`#a8ddb5`,`#7bccc4`,`#4eb3d3`,`#2b8cbe`,`#0868ac`,`#084081`],Greys:[`#ffffff`,`#f0f0f0`,`#d9d9d9`,`#bdbdbd`,`#969696`,`#737373`,`#525252`,`#252525`,`#000000`],YlOrRd:[`#ffffcc`,`#ffeda0`,`#fed976`,`#feb24c`,`#fd8d3c`,`#fc4e2a`,`#e31a1c`,`#bd0026`,`#800026`],PuRd:[`#f7f4f9`,`#e7e1ef`,`#d4b9da`,`#c994c7`,`#df65b0`,`#e7298a`,`#ce1256`,`#980043`,`#67001f`],Blues:[`#f7fbff`,`#deebf7`,`#c6dbef`,`#9ecae1`,`#6baed6`,`#4292c6`,`#2171b5`,`#08519c`,`#08306b`],PuBuGn:[`#fff7fb`,`#ece2f0`,`#d0d1e6`,`#a6bddb`,`#67a9cf`,`#3690c0`,`#02818a`,`#016c59`,`#014636`],Viridis:[`#440154`,`#482777`,`#3f4a8a`,`#31678e`,`#26838f`,`#1f9d8a`,`#6cce5a`,`#b6de2b`,`#fee825`],Spectral:[`#9e0142`,`#d53e4f`,`#f46d43`,`#fdae61`,`#fee08b`,`#ffffbf`,`#e6f598`,`#abdda4`,`#66c2a5`,`#3288bd`,`#5e4fa2`],RdYlGn:[`#a50026`,`#d73027`,`#f46d43`,`#fdae61`,`#fee08b`,`#ffffbf`,`#d9ef8b`,`#a6d96a`,`#66bd63`,`#1a9850`,`#006837`],RdBu:[`#67001f`,`#b2182b`,`#d6604d`,`#f4a582`,`#fddbc7`,`#f7f7f7`,`#d1e5f0`,`#92c5de`,`#4393c3`,`#2166ac`,`#053061`],PiYG:[`#8e0152`,`#c51b7d`,`#de77ae`,`#f1b6da`,`#fde0ef`,`#f7f7f7`,`#e6f5d0`,`#b8e186`,`#7fbc41`,`#4d9221`,`#276419`],PRGn:[`#40004b`,`#762a83`,`#9970ab`,`#c2a5cf`,`#e7d4e8`,`#f7f7f7`,`#d9f0d3`,`#a6dba0`,`#5aae61`,`#1b7837`,`#00441b`],RdYlBu:[`#a50026`,`#d73027`,`#f46d43`,`#fdae61`,`#fee090`,`#ffffbf`,`#e0f3f8`,`#abd9e9`,`#74add1`,`#4575b4`,`#313695`],BrBG:[`#543005`,`#8c510a`,`#bf812d`,`#dfc27d`,`#f6e8c3`,`#f5f5f5`,`#c7eae5`,`#80cdc1`,`#35978f`,`#01665e`,`#003c30`],RdGy:[`#67001f`,`#b2182b`,`#d6604d`,`#f4a582`,`#fddbc7`,`#ffffff`,`#e0e0e0`,`#bababa`,`#878787`,`#4d4d4d`,`#1a1a1a`],PuOr:[`#7f3b08`,`#b35806`,`#e08214`,`#fdb863`,`#fee0b6`,`#f7f7f7`,`#d8daeb`,`#b2abd2`,`#8073ac`,`#542788`,`#2d004b`],Set2:[`#66c2a5`,`#fc8d62`,`#8da0cb`,`#e78ac3`,`#a6d854`,`#ffd92f`,`#e5c494`,`#b3b3b3`],Accent:[`#7fc97f`,`#beaed4`,`#fdc086`,`#ffff99`,`#386cb0`,`#f0027f`,`#bf5b17`,`#666666`],Set1:[`#e41a1c`,`#377eb8`,`#4daf4a`,`#984ea3`,`#ff7f00`,`#ffff33`,`#a65628`,`#f781bf`,`#999999`],Set3:[`#8dd3c7`,`#ffffb3`,`#bebada`,`#fb8072`,`#80b1d3`,`#fdb462`,`#b3de69`,`#fccde5`,`#d9d9d9`,`#bc80bd`,`#ccebc5`,`#ffed6f`],Dark2:[`#1b9e77`,`#d95f02`,`#7570b3`,`#e7298a`,`#66a61e`,`#e6ab02`,`#a6761d`,`#666666`],Paired:[`#a6cee3`,`#1f78b4`,`#b2df8a`,`#33a02c`,`#fb9a99`,`#e31a1c`,`#fdbf6f`,`#ff7f00`,`#cab2d6`,`#6a3d9a`,`#ffff99`,`#b15928`],Pastel2:[`#b3e2cd`,`#fdcdac`,`#cbd5e8`,`#f4cae4`,`#e6f5c9`,`#fff2ae`,`#f1e2cc`,`#cccccc`],Pastel1:[`#fbb4ae`,`#b3cde3`,`#ccebc5`,`#decbe4`,`#fed9a6`,`#ffffcc`,`#e5d8bd`,`#fddaec`,`#f2f2f2`]},Be=Object.keys(U),Ve=new Map(Be.map(e=>[e.toLowerCase(),e])),He=typeof Proxy==`function`?new Proxy(U,{get(e,t){let n=t.toLowerCase();if(Ve.has(n))return e[Ve.get(n)]},getOwnPropertyNames(){return Object.getOwnPropertyNames(Be)}}):U,cmyk2rgb=(...e)=>{e=o(e,`cmyk`);let[t,n,r,i]=e,a=e.length>4?e[4]:1;return i===1?[0,0,0,a]:[t>=1?0:255*(1-t)*(1-i),n>=1?0:255*(1-n)*(1-i),r>=1?0:255*(1-r)*(1-i),a]},{max:Ue}=Math,rgb2cmyk=(...e)=>{let[t,n,r]=o(e,`rgb`);t/=255,n/=255,r/=255;let i=1-Ue(t,Ue(n,r)),a=i<1?1/(1-i):0;return[(1-t-i)*a,(1-n-i)*a,(1-r-i)*a,i]};Color.prototype.cmyk=function(){return rgb2cmyk(this._rgb)};const cmyk=(...e)=>new Color(...e,`cmyk`);Object.assign(chroma,{cmyk}),g.format.cmyk=cmyk2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`cmyk`),type_default(e)===`array`&&e.length===4)return`cmyk`}});const hsl2css=(...e)=>{let t=o(e,`hsla`),n=s(e)||`lsa`;return t[0]=rnd2(t[0]||0)+`deg`,t[1]=rnd2(t[1]*100)+`%`,t[2]=rnd2(t[2]*100)+`%`,n===`hsla`||t.length>3&&t[3]<1?(t[3]=`/ `+(t.length>3?t[3]:1),n=`hsla`):t.length=3,`${n.substr(0,3)}(${t.join(` `)})`},lab2css=(...e)=>{let t=o(e,`lab`),n=s(e)||`lab`;return t[0]=rnd2(t[0])+`%`,t[1]=rnd2(t[1]),t[2]=rnd2(t[2]),n===`laba`||t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`lab(${t.join(` `)})`},lch2css=(...e)=>{let t=o(e,`lch`),n=s(e)||`lab`;return t[0]=rnd2(t[0])+`%`,t[1]=rnd2(t[1]),t[2]=isNaN(t[2])?`none`:rnd2(t[2])+`deg`,n===`lcha`||t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`lch(${t.join(` `)})`},oklab2css=(...e)=>{let t=o(e,`lab`);return t[0]=rnd2(t[0]*100)+`%`,t[1]=rnd3(t[1]),t[2]=rnd3(t[2]),t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`oklab(${t.join(` `)})`},rgb2oklch=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=rgb2oklab(t,n,r),[l,u,d]=lab2lch(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]},oklch2css=(...e)=>{let t=o(e,`lch`);return t[0]=rnd2(t[0]*100)+`%`,t[1]=rnd3(t[1]),t[2]=isNaN(t[2])?`none`:rnd2(t[2])+`deg`,t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`oklch(${t.join(` `)})`},{round:W}=Math,rgb2css=(...e)=>{let t=o(e,`rgba`),n=s(e)||`rgb`;if(n.substr(0,3)===`hsl`)return hsl2css(oe(t),n);if(n.substr(0,3)===`lab`){let e=getLabWhitePoint();setLabWhitePoint(`d50`);let r=lab2css(rgb2lab(t),n);return setLabWhitePoint(e),r}if(n.substr(0,3)===`lch`){let e=getLabWhitePoint();setLabWhitePoint(`d50`);let r=lch2css(rgb2lch(t),n);return setLabWhitePoint(e),r}return n.substr(0,5)===`oklab`?oklab2css(rgb2oklab(t)):n.substr(0,5)===`oklch`?oklch2css(rgb2oklch(t)):(t[0]=W(t[0]),t[1]=W(t[1]),t[2]=W(t[2]),(n===`rgba`||t.length>3&&t[3]<1)&&(t[3]=`/ `+(t.length>3?t[3]:1),n=`rgba`),`${n.substr(0,3)}(${t.slice(0,n===`rgb`?3:4).join(` `)})`)},oklch2rgb=(...e)=>{e=o(e,`lch`);let[t,n,r,...i]=e,[a,s,c]=lch2lab(t,n,r),[l,u,d]=oklab2rgb(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]},G=`((?:-?\\d+)|(?:-?\\d+(?:\\.\\d+)?)%|none)`,K=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)%?)|none)`,q=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)%)|none)`,J=`\\s*,\\s*`,Y=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:deg)?)|none)`,X=`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?`,We=RegExp(`^rgba?\\(\\s*`+[G,G,G].join(`\\s+`)+X+`\\)$`),Ge=RegExp(`^rgb\\(\\s*`+[G,G,G].join(J)+`\\s*\\)$`),Ke=RegExp(`^rgba\\(\\s*`+[G,G,G,K].join(J)+`\\s*\\)$`),qe=RegExp(`^hsla?\\(\\s*`+[Y,q,q].join(`\\s+`)+X+`\\)$`),Je=RegExp(`^hsl?\\(\\s*`+[Y,q,q].join(J)+`\\s*\\)$`),Z=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,Ye=RegExp(`^lab\\(\\s*`+[K,K,K].join(`\\s+`)+X+`\\)$`),Xe=RegExp(`^lch\\(\\s*`+[K,K,Y].join(`\\s+`)+X+`\\)$`),Ze=RegExp(`^oklab\\(\\s*`+[K,K,K].join(`\\s+`)+X+`\\)$`),Qe=RegExp(`^oklch\\(\\s*`+[K,K,Y].join(`\\s+`)+X+`\\)$`),{round:Q}=Math,roundRGB=e=>e.map((e,t)=>t<=2?r(Q(e),0,255):e),percentToAbsolute=(e,t=0,n=100,r=!1)=>(typeof e==`string`&&e.endsWith(`%`)&&(e=parseFloat(e.substring(0,e.length-1))/100,e=r?t+(e+1)*.5*(n-t):t+e*(n-t)),+e),noneToValue=(e,t)=>e===`none`?t:e,css2rgb=e=>{if(e=e.toLowerCase().trim(),e===`transparent`)return[0,0,0,0];let t;if(g.format.named)try{return g.format.named(e)}catch{}if((t=e.match(We))||(t=e.match(Ge))){let e=t.slice(1,4);for(let t=0;t<3;t++)e[t]=+percentToAbsolute(noneToValue(e[t],0),0,255);e=roundRGB(e);let n=t[4]===void 0?1:+percentToAbsolute(t[4],0,1);return e[3]=n,e}if(t=e.match(Ke)){let e=t.slice(1,5);for(let t=0;t<4;t++)e[t]=+percentToAbsolute(e[t],0,255);return e}if((t=e.match(qe))||(t=e.match(Je))){let e=t.slice(1,4);e[0]=+noneToValue(e[0].replace(`deg`,``),0),e[1]=percentToAbsolute(noneToValue(e[1],0),0,100)*.01,e[2]=percentToAbsolute(noneToValue(e[2],0),0,100)*.01;let n=roundRGB(hsl2rgb(e));return n[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),n}if(t=e.match(Z)){let e=t.slice(1,4);e[1]*=.01,e[2]*=.01;let n=hsl2rgb(e);for(let e=0;e<3;e++)n[e]=Q(n[e]);return n[3]=+t[4],n}if(t=e.match(Ye)){let e=t.slice(1,4);e[0]=percentToAbsolute(noneToValue(e[0],0),0,100),e[1]=percentToAbsolute(noneToValue(e[1],0),-125,125,!0),e[2]=percentToAbsolute(noneToValue(e[2],0),-125,125,!0);let n=getLabWhitePoint();setLabWhitePoint(`d50`);let r=roundRGB(lab2rgb(e));return setLabWhitePoint(n),r[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),r}if(t=e.match(Xe)){let e=t.slice(1,4);e[0]=percentToAbsolute(e[0],0,100),e[1]=percentToAbsolute(noneToValue(e[1],0),0,150,!1),e[2]=+noneToValue(e[2].replace(`deg`,``),0);let n=getLabWhitePoint();setLabWhitePoint(`d50`);let r=roundRGB(lch2rgb(e));return setLabWhitePoint(n),r[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),r}if(t=e.match(Ze)){let e=t.slice(1,4);e[0]=percentToAbsolute(noneToValue(e[0],0),0,1),e[1]=percentToAbsolute(noneToValue(e[1],0),-.4,.4,!0),e[2]=percentToAbsolute(noneToValue(e[2],0),-.4,.4,!0);let n=roundRGB(oklab2rgb(e));return n[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),n}if(t=e.match(Qe)){let e=t.slice(1,4);e[0]=percentToAbsolute(noneToValue(e[0],0),0,1),e[1]=percentToAbsolute(noneToValue(e[1],0),0,.4,!1),e[2]=+noneToValue(e[2].replace(`deg`,``),0);let n=roundRGB(oklch2rgb(e));return n[3]=t[4]===void 0?1:+percentToAbsolute(t[4],0,1),n}};css2rgb.test=e=>We.test(e)||qe.test(e)||Ye.test(e)||Xe.test(e)||Ze.test(e)||Qe.test(e)||Ge.test(e)||Ke.test(e)||Je.test(e)||Z.test(e)||e===`transparent`,Color.prototype.css=function(e){return rgb2css(this._rgb,e)};const css=(...e)=>new Color(...e,`css`);chroma.css=css,g.format.css=css2rgb,g.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&type_default(e)===`string`&&css2rgb.test(e))return`css`}}),g.format.gl=(...e)=>{let t=o(e,`rgba`);return t[0]*=255,t[1]*=255,t[2]*=255,t};const gl=(...e)=>new Color(...e,`gl`);chroma.gl=gl,Color.prototype.gl=function(){let e=this._rgb;return[e[0]/255,e[1]/255,e[2]/255,e[3]]},Color.prototype.hex=function(e){return rgb2hex(this._rgb,e)};const hex=(...e)=>new Color(...e,`hex`);chroma.hex=hex,g.format.hex=hex2rgb,g.autodetect.push({p:4,test:(e,...t)=>{if(!t.length&&type_default(e)===`string`&&[3,4,5,6,7,8,9].indexOf(e.length)>=0)return`hex`}});const{log:$}=Math,temperature2rgb=e=>{let t=e/100,n,r,i;return t<66?(n=255,r=t<6?0:-155.25485562709179-.44596950469579133*(r=t-2)+104.49216199393888*$(r),i=t<20?0:-254.76935184120902+.8274096064007395*(i=t-10)+115.67994401066147*$(i)):(n=351.97690566805693+.114206453784165*(n=t-55)-40.25366309332127*$(n),r=325.4494125711974+.07943456536662342*(r=t-50)-28.0852963507957*$(r),i=255),[n,r,i,1]},{round:$e}=Math,rgb2temperature=(...e)=>{let t=o(e,`rgb`),n=t[0],r=t[2],i=1e3,a=4e4,s;for(;a-i>.4;){s=(a+i)*.5;let e=temperature2rgb(s);e[2]/e[0]>=r/n?a=s:i=s}return $e(s)};Color.prototype.temp=Color.prototype.kelvin=Color.prototype.temperature=function(){return rgb2temperature(this._rgb)};const temp=(...e)=>new Color(...e,`temp`);Object.assign(chroma,{temp,kelvin:temp,temperature:temp}),g.format.temp=g.format.kelvin=g.format.temperature=temperature2rgb,Color.prototype.oklch=function(){return rgb2oklch(this._rgb)};const oklch=(...e)=>new Color(...e,`oklch`);Object.assign(chroma,{oklch}),g.format.oklch=oklch2rgb,g.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`oklch`),type_default(e)===`array`&&e.length===3)return`oklch`}}),Object.assign(chroma,{analyze,average:pe,bezier:he,blend,brewer:He,Color,colors:_,contrast:Ee,contrastAPCA:Ae,cubehelix:cubehelix_default,deltaE:delta_e_default,distance:distance_default,input:g,interpolate:T,limits,mix:T,random:xe,scale:scale_default,scales:ze,valid:Re});var et=chroma;export{et as t};
@@ -0,0 +1,5 @@
1
+ import{i as e}from"../rolldown-runtime.mjs";import{parseArgs as t}from"node:util";const n=/\d/,r=[`-`,`_`,`/`,`.`];function isUppercase(e=``){if(!n.test(e))return e!==e.toLowerCase()}function splitByCase(e,t){let n=t??r,i=[];if(!e||typeof e!=`string`)return i;let a=``,o,s;for(let t of e){let e=n.includes(t);if(e===!0){i.push(a),a=``,o=void 0;continue}let r=isUppercase(t);if(s===!1){if(o===!1&&r===!0){i.push(a),a=t,o=r;continue}if(o===!0&&r===!1&&a.length>1){let e=a.at(-1);i.push(a.slice(0,Math.max(0,a.length-1))),a=e+t,o=r;continue}}a+=t,o=r,s=e}return i.push(a),i}function upperFirst(e){return e?e[0].toUpperCase()+e.slice(1):``}function lowerFirst(e){return e?e[0].toLowerCase()+e.slice(1):``}function pascalCase(e,t){return e?(Array.isArray(e)?e:splitByCase(e)).map(e=>upperFirst(t?.normalize?e.toLowerCase():e)).join(``):``}function camelCase(e,t){return lowerFirst(pascalCase(e||``,t))}function kebabCase(e,t){return e?(Array.isArray(e)?e:splitByCase(e)).map(e=>e.toLowerCase()).join(t??`-`):``}function snakeCase(e){return kebabCase(e||``,`_`)}function toArray(e){return Array.isArray(e)?e:e===void 0?[]:[e]}function formatLineColumns(e,t=``){let n=[];for(let t of e)for(let[e,r]of t.entries())n[e]=Math.max(n[e]||0,r.length);return e.map(e=>e.map((e,r)=>t+e[r===0?`padStart`:`padEnd`](n[r])).join(` `)).join(`
2
+ `)}function resolveValue(e){return typeof e==`function`?e():e}var CLIError=class extends Error{code;constructor(e,t){super(e),this.name=`CLIError`,this.code=t}};function parseRawArgs(e=[],n={}){let r=new Set(n.boolean||[]),i=new Set(n.string||[]),a=n.alias||{},o=n.default||{},s=new Map,c=new Map;for(let[e,t]of Object.entries(a)){let n=t;for(let t of n)s.set(e,t),c.has(t)||c.set(t,[]),c.get(t).push(e),s.set(t,e),c.has(e)||c.set(e,[]),c.get(e).push(t)}let l={};function getType(e){if(r.has(e))return`boolean`;let t=c.get(e)||[];for(let e of t)if(r.has(e))return`boolean`;return`string`}function isStringType(e){if(i.has(e))return!0;let t=c.get(e)||[];for(let e of t)if(i.has(e))return!0;return!1}let u=new Set([...r,...i,...Object.keys(a),...Object.values(a).flat(),...Object.keys(o)]);for(let e of u)l[e]||(l[e]={type:getType(e),default:o[e]});for(let[e,t]of s.entries())e.length===1&&l[t]&&!l[t].short&&(l[t].short=e);let d=[],f={};for(let t=0;t<e.length;t++){let n=e[t];if(n===`--`){d.push(...e.slice(t));break}if(n.startsWith(`--no-`)){let e=n.slice(5);f[e]=!0;continue}d.push(n)}let p;try{p=t({args:d,options:Object.keys(l).length>0?l:void 0,allowPositionals:!0,strict:!1})}catch{p={values:{},positionals:d}}let m={_:[]};m._=p.positionals;for(let[e,t]of Object.entries(p.values)){let n=t;getType(e)===`boolean`&&typeof t==`string`?n=t!==`false`:isStringType(e)&&typeof t==`boolean`&&(n=``),m[e]=n}for(let[e]of Object.entries(f)){m[e]=!1;let t=s.get(e);t&&(m[t]=!1);let n=c.get(e);if(n)for(let e of n)m[e]=!1}for(let[e,t]of s.entries())m[e]!==void 0&&m[t]===void 0&&(m[t]=m[e]),m[t]!==void 0&&m[e]===void 0&&(m[e]=m[t]),m[e]!==m[t]&&o[t]===m[t]&&(m[t]=m[e]);return m}const i=(()=>{let e=globalThis.process?.env??{};return e.NO_COLOR===`1`||e.TERM===`dumb`||e.TEST||e.CI})(),_c=(e,t=39)=>n=>i?n:`\u001B[${e}m${n}\u001B[${t}m`,a=_c(1,22),o=_c(36),s=_c(90),c=_c(4,24);function parseArgs$1(e,t){let n={boolean:[],string:[],alias:{},default:{}},r=resolveArgs(t);for(let e of r){if(e.type===`positional`)continue;e.type===`string`||e.type===`enum`?n.string.push(e.name):e.type===`boolean`&&n.boolean.push(e.name),e.default!==void 0&&(n.default[e.name]=e.default),e.alias&&(n.alias[e.name]=e.alias);let t=camelCase(e.name),r=kebabCase(e.name);if(t!==e.name||r!==e.name){let i=toArray(n.alias[e.name]||[]);t!==e.name&&!i.includes(t)&&i.push(t),r!==e.name&&!i.includes(r)&&i.push(r),i.length>0&&(n.alias[e.name]=i)}}let i=parseRawArgs(e,n),[...a]=i._,s=new Proxy(i,{get(e,t){return e[t]??e[camelCase(t)]??e[kebabCase(t)]}});for(let[,e]of r.entries())if(e.type===`positional`){let t=a.shift();if(t!==void 0)s[e.name]=t;else if(e.default===void 0&&e.required!==!1)throw new CLIError(`Missing required positional argument: ${e.name.toUpperCase()}`,`EARG`);else s[e.name]=e.default}else if(e.type===`enum`){let t=s[e.name],n=e.options||[];if(t!==void 0&&n.length>0&&!n.includes(t))throw new CLIError(`Invalid value for argument: ${o(`--${e.name}`)} (${o(t)}). Expected one of: ${n.map(e=>o(e)).join(`, `)}.`,`EARG`)}else if(e.required&&s[e.name]===void 0)throw new CLIError(`Missing required argument: --${e.name}`,`EARG`);return s}e(parseArgs$1,`parseArgs`);function resolveArgs(e){let t=[];for(let[n,r]of Object.entries(e||{}))t.push({...r,name:n,alias:toArray(r.alias)});return t}async function resolvePlugins(e){return Promise.all(e.map(e=>resolveValue(e)))}function defineCommand(e){return e}async function runCommand(e,t){let n=await resolveValue(e.args||{}),r=parseArgs$1(t.rawArgs,n),i={rawArgs:t.rawArgs,args:r,data:t.data,cmd:e},a=await resolvePlugins(e.plugins??[]),s,c;try{for(let e of a)await e.setup?.(i);typeof e.setup==`function`&&await e.setup(i);let r=await resolveValue(e.subCommands);if(r&&Object.keys(r).length>0){let i=findSubCommandIndex(t.rawArgs,n),a=t.rawArgs[i];if(a){let e=await _findSubCommand(r,a);if(!e)throw new CLIError(`Unknown command ${o(a)}`,`E_UNKNOWN_COMMAND`);await runCommand(e,{rawArgs:t.rawArgs.slice(i+1)})}else{let n=await resolveValue(e.default);if(n){if(e.run)throw new CLIError(`Cannot specify both 'run' and 'default' on the same command.`,`E_DEFAULT_CONFLICT`);let i=await _findSubCommand(r,n);if(!i)throw new CLIError(`Default sub command ${o(n)} not found in subCommands.`,`E_UNKNOWN_COMMAND`);await runCommand(i,{rawArgs:t.rawArgs})}else if(!e.run)throw new CLIError(`No command specified.`,`E_NO_COMMAND`)}}typeof e.run==`function`&&(s=await e.run(i))}catch(e){c=e}let l=[];if(typeof e.cleanup==`function`)try{await e.cleanup(i)}catch(e){l.push(e)}for(let e of[...a].reverse())try{await e.cleanup?.(i)}catch(e){l.push(e)}if(c)throw c;if(l.length===1)throw l[0];if(l.length>1)throw Error(`Multiple cleanup errors`,{cause:l});return{result:s}}async function resolveSubCommand(e,t,n){let r=await resolveValue(e.subCommands);if(r&&Object.keys(r).length>0){let n=findSubCommandIndex(t,await resolveValue(e.args||{})),i=t[n],a=await _findSubCommand(r,i);if(a)return resolveSubCommand(a,t.slice(n+1),e)}return[e,n]}async function _findSubCommand(e,t){if(t in e)return resolveValue(e[t]);for(let n of Object.values(e)){let e=await resolveValue(n),r=await resolveValue(e?.meta);if(r?.alias&&toArray(r.alias).includes(t))return e}}function findSubCommandIndex(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r===`--`)return-1;if(r.startsWith(`-`)){!r.includes(`=`)&&_isValueFlag(r,t)&&n++;continue}return n}return-1}function _isValueFlag(e,t){let n=e.replace(/^-{1,2}/,``),r=camelCase(n);for(let[e,i]of Object.entries(t))if(!(i.type!==`string`&&i.type!==`enum`)&&(r===camelCase(e)||(Array.isArray(i.alias)?i.alias:i.alias?[i.alias]:[]).includes(n)))return!0;return!1}async function showUsage(e,t){try{console.log(await renderUsage(e,t)+`
3
+ `)}catch(e){console.error(e)}}const l=/^no[-A-Z]/;async function renderUsage(e,t){let n=await resolveValue(e.meta||{}),r=resolveArgs(await resolveValue(e.args||{})),i=await resolveValue(t?.meta||{}),u=`${i.name?`${i.name} `:``}`+(n.name||process.argv[1]),d=[],f=[],p=[],m=[];for(let e of r)if(e.type===`positional`){let t=e.name.toUpperCase(),n=e.required!==!1&&e.default===void 0;f.push([o(t+renderValueHint(e)),renderDescription(e,n)]),m.push(n?`<${t}>`:`[${t}]`)}else{let t=e.required===!0&&e.default===void 0,n=[...(e.alias||[]).map(e=>`-${e}`),`--${e.name}`].join(`, `)+renderValueHint(e);if(d.push([o(n),renderDescription(e,t)]),e.type===`boolean`&&(e.default===!0||e.negativeDescription)&&!l.test(e.name)){let n=[...(e.alias||[]).map(e=>`--no-${e}`),`--no-${e.name}`].join(`, `);d.push([o(n),[e.negativeDescription,t?s(`(Required)`):``].filter(Boolean).join(` `)])}t&&m.push(`--${e.name}`+renderValueHint(e))}if(e.subCommands){let t=[],n=await resolveValue(e.subCommands);for(let[e,r]of Object.entries(n)){let n=await resolveValue((await resolveValue(r))?.meta);if(n?.hidden)continue;let i=toArray(n?.alias),a=[e,...i].join(`, `);p.push([o(a),n?.description||``]),t.push(e,...i)}m.push(t.join(`|`))}let h=[],g=n.version||i.version;h.push(s(`${n.description} (${u+(g?` v${g}`:``)})`),``);let _=d.length>0||f.length>0;return h.push(`${c(a(`USAGE`))} ${o(`${u}${_?` [OPTIONS]`:``} ${m.join(` `)}`)}`,``),f.length>0&&(h.push(c(a(`ARGUMENTS`)),``),h.push(formatLineColumns(f,` `)),h.push(``)),d.length>0&&(h.push(c(a(`OPTIONS`)),``),h.push(formatLineColumns(d,` `)),h.push(``)),p.length>0&&(h.push(c(a(`COMMANDS`)),``),h.push(formatLineColumns(p,` `)),h.push(``,`Use ${o(`${u} <command> --help`)} for more information about a command.`)),h.filter(e=>typeof e==`string`).join(`
4
+ `)}function renderValueHint(e){let t=e.valueHint?`=<${e.valueHint}>`:``,n=t||`=<${snakeCase(e.name)}>`;return!e.type||e.type===`positional`||e.type===`boolean`?t:e.type===`enum`&&e.options?.length?`=<${e.options.join(`|`)}>`:n}function renderDescription(e,t){let n=t?s(`(Required)`):``,r=e.default===void 0?``:s(`(Default: ${e.default})`);return[e.description,n,r].filter(Boolean).join(` `)}async function runMain(e,t={}){let n=t.rawArgs||process.argv.slice(2),r=t.showUsage||showUsage;try{let t=await _resolveBuiltinFlags(e);if(t.help.length>0&&n.some(e=>t.help.includes(e)))await r(...await resolveSubCommand(e,n)),process.exit(0);else if(n.length===1&&t.version.includes(n[0])){let t=typeof e.meta==`function`?await e.meta():await e.meta;if(!t?.version)throw new CLIError(`No version specified`,`E_NO_VERSION`);console.log(t.version)}else await runCommand(e,{rawArgs:n})}catch(t){t instanceof CLIError?(await r(...await resolveSubCommand(e,n)),console.error(t.message)):console.error(t,`
5
+ `),process.exit(1)}}async function _resolveBuiltinFlags(e){let t=await resolveValue(e.args||{}),n=new Set,r=new Set;for(let[e,i]of Object.entries(t)){n.add(e);for(let e of toArray(i.alias))r.add(e)}return{help:_getBuiltinFlags(`help`,`h`,n,r),version:_getBuiltinFlags(`version`,`v`,n,r)}}function _getBuiltinFlags(e,t,n,r){return n.has(e)||r.has(e)?[]:n.has(t)||r.has(t)?[`--${e}`]:[`--${e}`,`-${t}`]}export{runMain as n,defineCommand as t};
@@ -0,0 +1 @@
1
+ import"../rolldown-runtime.mjs";function stringify(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}export{stringify as t};
@@ -0,0 +1 @@
1
+ import"../rolldown-runtime.mjs";import{t as e}from"./character-entities.mjs";const t={}.hasOwnProperty;function decodeNamedCharacterReference(n){return t.call(e,n)?e[n]:!1}export{decodeNamedCharacterReference as t};
@@ -0,0 +1 @@
1
+ import"../rolldown-runtime.mjs";function isPlainObject(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function _defu(e,t,n=`.`,r){if(!isPlainObject(t))return _defu(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(Array.isArray(a)&&Array.isArray(i[t])?i[t]=[...a,...i[t]]:isPlainObject(a)&&isPlainObject(i[t])?i[t]=_defu(a,i[t],(n?`${n}.`:``)+t.toString(),r):i[t]=a))}return i}function createDefu(e){return(...t)=>t.reduce((t,n)=>_defu(t,n,``,e),{})}const e=createDefu();export{e as t};