@b4moss/hyogen-md 0.11.0 → 0.13.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 (83) hide show
  1. package/README.md +24 -3
  2. package/README_ja.md +24 -3
  3. package/dist/build/build.d.ts +2 -0
  4. package/dist/build/buildDependencyGraph.d.ts +22 -0
  5. package/dist/build/collectDependencies.d.ts +8 -0
  6. package/dist/build/collectEntryPaths.d.ts +10 -0
  7. package/dist/build/isUnderscorePartial.d.ts +4 -0
  8. package/dist/cli.js +5587 -0
  9. package/dist/client.js +1163 -821
  10. package/dist/component/ComponentRegistry.d.ts +11 -0
  11. package/dist/component/parsePropsContract.d.ts +10 -0
  12. package/dist/component/renderComponent.d.ts +17 -0
  13. package/dist/component/validateProps.d.ts +7 -0
  14. package/dist/config/defineConfig.d.ts +5 -0
  15. package/dist/config/index.d.ts +3 -0
  16. package/dist/config/index.js +143 -0
  17. package/dist/config/loadConfig.d.ts +13 -0
  18. package/dist/config/types.d.ts +26 -0
  19. package/dist/context/mergeContext.d.ts +3 -0
  20. package/dist/control/StructureNestTracker.d.ts +14 -0
  21. package/dist/control/expandControlStructures.d.ts +3 -0
  22. package/dist/control/parseControlOpener.d.ts +2 -0
  23. package/dist/control/parseControlStructures.d.ts +2 -0
  24. package/dist/createError-WZmAl05N.js +30 -0
  25. package/dist/errors/createError.d.ts +7 -0
  26. package/dist/errors/formatDiagnosticLog.d.ts +6 -0
  27. package/dist/errors/formatMessage.d.ts +3 -0
  28. package/dist/expr/evaluateExpression.d.ts +4 -0
  29. package/dist/expr/interpolateExpressions.d.ts +4 -0
  30. package/dist/expr/parseExpression.d.ts +4 -0
  31. package/dist/frontmatter/parseFrontMatter.d.ts +3 -0
  32. package/dist/include/VisitStack.d.ts +13 -0
  33. package/dist/include/expandIncludes.d.ts +18 -0
  34. package/dist/index.d.ts +11 -113
  35. package/dist/index.js +1162 -794
  36. package/dist/io/createFsLoader.d.ts +6 -0
  37. package/dist/io/createNodeLoader.d.ts +4 -0
  38. package/dist/io/isRemotePath.d.ts +2 -0
  39. package/dist/io/loadDataSources.d.ts +8 -0
  40. package/dist/io/parseCsvFromString.d.ts +1 -0
  41. package/dist/io/parseDataFile.d.ts +1 -0
  42. package/dist/io/resolveIncludePath.d.ts +1 -0
  43. package/dist/layout/expandExtendsAndBlocks.d.ts +19 -0
  44. package/dist/layout/parseBlockOpener.d.ts +8 -0
  45. package/dist/layout/parseBlockStructures.d.ts +15 -0
  46. package/dist/layout/parseExtendBlock.d.ts +12 -0
  47. package/dist/layout/parseExtendDirective.d.ts +5 -0
  48. package/dist/logic/executeDeclaration.d.ts +6 -0
  49. package/dist/logic/executeDeclarations.d.ts +6 -0
  50. package/dist/logic/executeStatement.d.ts +10 -0
  51. package/dist/logic/hgBlockUtils.d.ts +3 -0
  52. package/dist/logic/parseDeclaration.d.ts +5 -0
  53. package/dist/logic/parseStatement.d.ts +3 -0
  54. package/dist/logic/reservedWords.d.ts +2 -0
  55. package/dist/logic/stripComments.d.ts +2 -0
  56. package/dist/markdown/shiftHeadings.d.ts +25 -0
  57. package/dist/parse/hgMarkers.d.ts +5 -0
  58. package/dist/parse/parseComponentDirective.d.ts +6 -0
  59. package/dist/parse/parseIncludeDirective.d.ts +2 -0
  60. package/dist/parse/scanHgBlocks.d.ts +10 -0
  61. package/dist/paths/assertWithinRootDir.d.ts +2 -0
  62. package/dist/paths/findDocRoot.d.ts +1 -0
  63. package/dist/paths/resolveRenderInput.d.ts +11 -0
  64. package/dist/paths/resolveTemplatePath.d.ts +9 -0
  65. package/dist/pipeline/applyFrontMatterOutputOption.d.ts +4 -0
  66. package/dist/pipeline/executeHgBlocks.d.ts +9 -0
  67. package/dist/pipeline/joinRemovalSeam.d.ts +12 -0
  68. package/dist/pipeline/renderDocument.d.ts +22 -0
  69. package/dist/pipeline/stripHgComments.d.ts +7 -0
  70. package/dist/renderClient.d.ts +15 -0
  71. package/dist/renderServer.d.ts +4 -0
  72. package/dist/security/forbiddenKeys.d.ts +3 -0
  73. package/dist/security/scanSuspiciousContext.d.ts +6 -0
  74. package/dist/shims/fs-browser.d.ts +6 -0
  75. package/dist/shims/fs-promises-browser.d.ts +5 -0
  76. package/dist/toc/expandToc.d.ts +8 -0
  77. package/dist/toc/extractHeadings.d.ts +10 -0
  78. package/dist/toc/formatTocMarkdown.d.ts +7 -0
  79. package/dist/toc/githubHeadingSlug.d.ts +11 -0
  80. package/dist/toc/parseTocDirective.d.ts +10 -0
  81. package/dist/toc/plainifyHeadingText.d.ts +2 -0
  82. package/dist/types.d.ts +211 -0
  83. package/package.json +17 -4
package/dist/client.js CHANGED
@@ -1,25 +1,25 @@
1
- import { parse as Ne } from "yaml";
2
- const He = { file_not_found: "File not found: {path} (referenced from {from} via {via})", frontmatter_too_large: "Front matter exceeds size limit in {path} ({size} bytes, limit {limit})", duplicate_component_alias: 'Duplicate component alias "{alias}" in {path}', alias_collision: 'Component alias "{alias}" collides with an existing binding in {path}', forbidden_property_access: 'Forbidden property access "{property}" in {path}', parse_error: "Parse error in {path}: {message}", component_multiline_output: 'Component "{alias}" returned multiline output (single line required)', server_context_on_client: "serverContext is not allowed with renderClient", load_failed: "Failed to load {path}: {reason}" }, Pe = { circular_include: "Circular reference detected; skipped {path} (referenced from {from} via {via})", nest_limit_exceeded: "Nesting limit exceeded ({limit}); skipped block in {path}", extend_in_component: "extend is not allowed inside a component; skipped in {path}", prop_type_mismatch: 'Prop "{prop}" type mismatch in component "{component}"; expected {expected}, got {actual}', prop_missing: 'Required prop "{prop}" is missing for component "{component}"', prop_unknown: 'Unknown prop "{prop}" passed to component "{component}"; ignored', suspicious_context_value: 'Suspicious value in context key "{key}" ({reason})' }, Fe = { contains_html_script_tag: "contains HTML script tag", contains_event_handler: "contains inline event handler", contains_dangerous_scheme: "contains dangerous URL scheme", contains_embed_tag: "contains embeddable HTML tag", contains_meta_refresh: "contains meta refresh" }, J = {
3
- errors: He,
4
- warnings: Pe,
5
- warningReasons: Fe
6
- }, Ie = J.errors, ze = J.warnings;
7
- function we(t, e) {
1
+ import { parse as Je } from "yaml";
2
+ const Qe = { file_not_found: "File not found: {path} (referenced from {from} via {via})", frontmatter_too_large: "Front matter exceeds size limit in {path} ({size} bytes, limit {limit})", duplicate_component_alias: 'Duplicate component alias "{alias}" in {path}', alias_collision: 'Component alias "{alias}" collides with an existing binding in {path}', forbidden_property_access: 'Forbidden property access "{property}" in {path}', parse_error: "Parse error in {path}: {message}", server_context_on_client: "serverContext is not allowed with renderClient", load_failed: "Failed to load {path}: {reason}", data_sources_on_client: "dataSources is not allowed with renderClient", data_source_too_large: "Data source exceeds size limit in {path} ({size} bytes, limit {limit})" }, et = { circular_include: "Circular reference detected; skipped {path} (referenced from {from} via {via})", nest_limit_exceeded: "Nesting limit exceeded ({limit}); skipped block in {path}", extend_in_component: "extend is not allowed inside a component; skipped in {path}", prop_type_mismatch: 'Prop "{prop}" type mismatch in component "{component}"; expected {expected}, got {actual}', prop_missing: 'Required prop "{prop}" is missing for component "{component}"', prop_unknown: 'Unknown prop "{prop}" passed to component "{component}"; ignored', suspicious_context_value: 'Suspicious value in context key "{key}" ({reason})' }, tt = { contains_html_script_tag: "contains HTML script tag", contains_event_handler: "contains inline event handler", contains_dangerous_scheme: "contains dangerous URL scheme", contains_embed_tag: "contains embeddable HTML tag", contains_meta_refresh: "contains meta refresh" }, Q = {
3
+ errors: Qe,
4
+ warnings: et,
5
+ warningReasons: tt
6
+ }, nt = Q.errors, rt = Q.warnings;
7
+ function Se(t, e) {
8
8
  return t === void 0 ? "" : t.replace(/\{([^}]+)\}/g, (n, r) => {
9
9
  if (e === void 0 || !(r in e))
10
10
  return n;
11
- const s = e[r];
12
- return s == null ? "" : String(s);
11
+ const i = e[r];
12
+ return i == null ? "" : String(i);
13
13
  });
14
14
  }
15
- function Ue(t, e) {
16
- return we(Ie[t], e);
15
+ function it(t, e) {
16
+ return Se(nt[t], e);
17
17
  }
18
- function O(t, e) {
19
- return we(ze[t], e);
18
+ function H(t, e) {
19
+ return Se(rt[t], e);
20
20
  }
21
- function u(t) {
22
- const e = t.message ?? Ue(t.code, t.details), n = new Error(e);
21
+ function d(t) {
22
+ const e = t.message ?? it(t.code, t.details), n = new Error(e);
23
23
  return n.name = "HyogenError", n.code = t.code, n.message = e, n.path = t.path, n.details = t.details, n;
24
24
  }
25
25
  function _(...t) {
@@ -28,17 +28,17 @@ function _(...t) {
28
28
  n != null && Object.assign(e, n);
29
29
  return e;
30
30
  }
31
- class be {
31
+ class Ce {
32
32
  components = /* @__PURE__ */ new Map();
33
33
  register(e, n, r) {
34
34
  if (this.components.has(e.alias))
35
- throw u({
35
+ throw d({
36
36
  code: "duplicate_component_alias",
37
37
  path: r ?? e.definedAt,
38
38
  details: { alias: e.alias }
39
39
  });
40
40
  if (n.includes(e.alias))
41
- throw u({
41
+ throw d({
42
42
  code: "alias_collision",
43
43
  path: r ?? e.definedAt,
44
44
  details: { alias: e.alias }
@@ -52,8 +52,8 @@ class be {
52
52
  return this.components.has(e);
53
53
  }
54
54
  }
55
- const le = 64 * 1024;
56
- function H(t, e) {
55
+ const de = 64 * 1024;
56
+ function I(t, e) {
57
57
  if (!t.startsWith("---"))
58
58
  return { context: {}, body: t };
59
59
  const n = t.indexOf(`
@@ -64,25 +64,25 @@ function H(t, e) {
64
64
  ---`, n);
65
65
  if (r === -1)
66
66
  return { context: {}, body: t };
67
- const s = t.slice(n + 1, r), i = Buffer.byteLength(s, "utf8");
68
- if (i > le)
69
- throw u({
67
+ const i = t.slice(n + 1, r), s = Buffer.byteLength(i, "utf8");
68
+ if (s > de)
69
+ throw d({
70
70
  code: "frontmatter_too_large",
71
71
  path: e,
72
72
  details: {
73
- size: i,
74
- limit: le
73
+ size: s,
74
+ limit: de
75
75
  }
76
76
  });
77
- if (s.trim().length === 0)
78
- throw u({
77
+ if (i.trim().length === 0)
78
+ throw d({
79
79
  code: "parse_error",
80
80
  path: e,
81
81
  details: { message: "empty front matter" }
82
82
  });
83
83
  let o;
84
84
  try {
85
- const h = Ne(s);
85
+ const h = Je(i);
86
86
  if (h == null)
87
87
  o = {};
88
88
  else if (typeof h == "object" && !Array.isArray(h))
@@ -90,7 +90,7 @@ function H(t, e) {
90
90
  else
91
91
  throw new Error("front matter must be a YAML mapping");
92
92
  } catch (h) {
93
- throw u({
93
+ throw d({
94
94
  code: "parse_error",
95
95
  path: e,
96
96
  details: {
@@ -106,43 +106,43 @@ function H(t, e) {
106
106
  context: o,
107
107
  body: c,
108
108
  rawFrontMatter: `---
109
- ${s}
109
+ ${i}
110
110
  ---`
111
111
  };
112
112
  }
113
- const Ze = /* @__PURE__ */ new Set([
113
+ const st = /* @__PURE__ */ new Set([
114
114
  "string",
115
115
  "number",
116
116
  "boolean",
117
117
  "object",
118
118
  "array"
119
119
  ]);
120
- function qe(t, e) {
120
+ function ot(t, e) {
121
121
  const n = t.props;
122
122
  if (n === void 0)
123
123
  return {};
124
124
  if (typeof n != "object" || n === null || Array.isArray(n))
125
- throw u({
125
+ throw d({
126
126
  code: "parse_error",
127
127
  path: e,
128
128
  details: { message: "props must be a YAML mapping" }
129
129
  });
130
130
  const r = {};
131
- for (const [s, i] of Object.entries(n)) {
132
- if (typeof i != "object" || i === null || Array.isArray(i)) {
133
- r[s] = {};
131
+ for (const [i, s] of Object.entries(n)) {
132
+ if (typeof s != "object" || s === null || Array.isArray(s)) {
133
+ r[i] = {};
134
134
  continue;
135
135
  }
136
- const o = i, a = {};
136
+ const o = s, a = {};
137
137
  if ("type" in o && o.type !== void 0) {
138
138
  const c = String(o.type);
139
- Ze.has(c) ? a.type = c : a.type = void 0;
139
+ st.has(c) ? a.type = c : a.type = void 0;
140
140
  }
141
- "isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[s] = a;
141
+ "isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[i] = a;
142
142
  }
143
143
  return r;
144
144
  }
145
- function Ve(t) {
145
+ function at(t) {
146
146
  if (t != null) {
147
147
  if (typeof t == "string") return "string";
148
148
  if (typeof t == "number") return "number";
@@ -151,30 +151,30 @@ function Ve(t) {
151
151
  if (typeof t == "object") return "object";
152
152
  }
153
153
  }
154
- function Ke(t, e) {
154
+ function ct(t, e) {
155
155
  return e === "array" ? Array.isArray(t) : e === "object" ? typeof t == "object" && t !== null && !Array.isArray(t) : typeof t === e;
156
156
  }
157
- function U(t, e) {
157
+ function Z(t, e) {
158
158
  return {
159
159
  code: t,
160
- message: O(t, e),
160
+ message: H(t, e),
161
161
  details: e
162
162
  };
163
163
  }
164
- function Ye(t, e, n) {
165
- const r = [], s = {}, i = new Set(Object.keys(e));
164
+ function lt(t, e, n) {
165
+ const r = [], i = {}, s = new Set(Object.keys(e));
166
166
  for (const [o, a] of Object.entries(e)) {
167
167
  const c = Object.prototype.hasOwnProperty.call(t, o);
168
168
  let h = c ? t[o] : void 0;
169
169
  if (c || (a.default !== void 0 ? h = a.default : (a.isRequired && r.push(
170
- U("prop_missing", {
170
+ Z("prop_missing", {
171
171
  prop: o,
172
172
  component: n
173
173
  })
174
174
  ), h = void 0)), c && h !== void 0 && h !== null) {
175
- const l = a.type ?? Ve(h);
176
- l && !Ke(h, l) && (r.push(
177
- U("prop_type_mismatch", {
175
+ const l = a.type ?? at(h);
176
+ l && !ct(h, l) && (r.push(
177
+ Z("prop_type_mismatch", {
178
178
  prop: o,
179
179
  component: n,
180
180
  expected: l,
@@ -182,194 +182,194 @@ function Ye(t, e, n) {
182
182
  })
183
183
  ), h = void 0);
184
184
  }
185
- s[o] = h;
185
+ i[o] = h;
186
186
  }
187
187
  for (const o of Object.keys(t))
188
- i.has(o) || (Object.keys(e).length > 0 ? r.push(
189
- U("prop_unknown", {
188
+ s.has(o) || (Object.keys(e).length > 0 ? r.push(
189
+ Z("prop_unknown", {
190
190
  prop: o,
191
191
  component: n
192
192
  })
193
- ) : s[o] = t[o]);
194
- return { values: s, warnings: r };
193
+ ) : i[o] = t[o]);
194
+ return { values: i, warnings: r };
195
195
  }
196
- function ye(t) {
196
+ function We(t) {
197
197
  return /^https?:\/\//i.test(t);
198
198
  }
199
- function Ge(t) {
199
+ function ht(t) {
200
200
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
201
201
  }
202
- var Z, he;
203
- function Je() {
204
- if (he) return Z;
205
- he = 1;
206
- function t(s) {
207
- if (typeof s != "string")
208
- throw new TypeError("Path must be a string. Received " + JSON.stringify(s));
209
- }
210
- function e(s, i) {
211
- for (var o = "", a = 0, c = -1, h = 0, l, d = 0; d <= s.length; ++d) {
212
- if (d < s.length)
213
- l = s.charCodeAt(d);
202
+ var q, fe;
203
+ function ut() {
204
+ if (fe) return q;
205
+ fe = 1;
206
+ function t(i) {
207
+ if (typeof i != "string")
208
+ throw new TypeError("Path must be a string. Received " + JSON.stringify(i));
209
+ }
210
+ function e(i, s) {
211
+ for (var o = "", a = 0, c = -1, h = 0, l, u = 0; u <= i.length; ++u) {
212
+ if (u < i.length)
213
+ l = i.charCodeAt(u);
214
214
  else {
215
215
  if (l === 47)
216
216
  break;
217
217
  l = 47;
218
218
  }
219
219
  if (l === 47) {
220
- if (!(c === d - 1 || h === 1)) if (c !== d - 1 && h === 2) {
220
+ if (!(c === u - 1 || h === 1)) if (c !== u - 1 && h === 2) {
221
221
  if (o.length < 2 || a !== 2 || o.charCodeAt(o.length - 1) !== 46 || o.charCodeAt(o.length - 2) !== 46) {
222
222
  if (o.length > 2) {
223
223
  var f = o.lastIndexOf("/");
224
224
  if (f !== o.length - 1) {
225
- f === -1 ? (o = "", a = 0) : (o = o.slice(0, f), a = o.length - 1 - o.lastIndexOf("/")), c = d, h = 0;
225
+ f === -1 ? (o = "", a = 0) : (o = o.slice(0, f), a = o.length - 1 - o.lastIndexOf("/")), c = u, h = 0;
226
226
  continue;
227
227
  }
228
228
  } else if (o.length === 2 || o.length === 1) {
229
- o = "", a = 0, c = d, h = 0;
229
+ o = "", a = 0, c = u, h = 0;
230
230
  continue;
231
231
  }
232
232
  }
233
- i && (o.length > 0 ? o += "/.." : o = "..", a = 2);
233
+ s && (o.length > 0 ? o += "/.." : o = "..", a = 2);
234
234
  } else
235
- o.length > 0 ? o += "/" + s.slice(c + 1, d) : o = s.slice(c + 1, d), a = d - c - 1;
236
- c = d, h = 0;
235
+ o.length > 0 ? o += "/" + i.slice(c + 1, u) : o = i.slice(c + 1, u), a = u - c - 1;
236
+ c = u, h = 0;
237
237
  } else l === 46 && h !== -1 ? ++h : h = -1;
238
238
  }
239
239
  return o;
240
240
  }
241
- function n(s, i) {
242
- var o = i.dir || i.root, a = i.base || (i.name || "") + (i.ext || "");
243
- return o ? o === i.root ? o + a : o + s + a : a;
241
+ function n(i, s) {
242
+ var o = s.dir || s.root, a = s.base || (s.name || "") + (s.ext || "");
243
+ return o ? o === s.root ? o + a : o + i + a : a;
244
244
  }
245
245
  var r = {
246
246
  // path.resolve([from ...], to)
247
247
  resolve: function() {
248
- for (var i = "", o = !1, a, c = arguments.length - 1; c >= -1 && !o; c--) {
248
+ for (var s = "", o = !1, a, c = arguments.length - 1; c >= -1 && !o; c--) {
249
249
  var h;
250
- c >= 0 ? h = arguments[c] : (a === void 0 && (a = process.cwd()), h = a), t(h), h.length !== 0 && (i = h + "/" + i, o = h.charCodeAt(0) === 47);
250
+ c >= 0 ? h = arguments[c] : (a === void 0 && (a = process.cwd()), h = a), t(h), h.length !== 0 && (s = h + "/" + s, o = h.charCodeAt(0) === 47);
251
251
  }
252
- return i = e(i, !o), o ? i.length > 0 ? "/" + i : "/" : i.length > 0 ? i : ".";
252
+ return s = e(s, !o), o ? s.length > 0 ? "/" + s : "/" : s.length > 0 ? s : ".";
253
253
  },
254
- normalize: function(i) {
255
- if (t(i), i.length === 0) return ".";
256
- var o = i.charCodeAt(0) === 47, a = i.charCodeAt(i.length - 1) === 47;
257
- return i = e(i, !o), i.length === 0 && !o && (i = "."), i.length > 0 && a && (i += "/"), o ? "/" + i : i;
254
+ normalize: function(s) {
255
+ if (t(s), s.length === 0) return ".";
256
+ var o = s.charCodeAt(0) === 47, a = s.charCodeAt(s.length - 1) === 47;
257
+ return s = e(s, !o), s.length === 0 && !o && (s = "."), s.length > 0 && a && (s += "/"), o ? "/" + s : s;
258
258
  },
259
- isAbsolute: function(i) {
260
- return t(i), i.length > 0 && i.charCodeAt(0) === 47;
259
+ isAbsolute: function(s) {
260
+ return t(s), s.length > 0 && s.charCodeAt(0) === 47;
261
261
  },
262
262
  join: function() {
263
263
  if (arguments.length === 0)
264
264
  return ".";
265
- for (var i, o = 0; o < arguments.length; ++o) {
265
+ for (var s, o = 0; o < arguments.length; ++o) {
266
266
  var a = arguments[o];
267
- t(a), a.length > 0 && (i === void 0 ? i = a : i += "/" + a);
267
+ t(a), a.length > 0 && (s === void 0 ? s = a : s += "/" + a);
268
268
  }
269
- return i === void 0 ? "." : r.normalize(i);
269
+ return s === void 0 ? "." : r.normalize(s);
270
270
  },
271
- relative: function(i, o) {
272
- if (t(i), t(o), i === o || (i = r.resolve(i), o = r.resolve(o), i === o)) return "";
273
- for (var a = 1; a < i.length && i.charCodeAt(a) === 47; ++a)
271
+ relative: function(s, o) {
272
+ if (t(s), t(o), s === o || (s = r.resolve(s), o = r.resolve(o), s === o)) return "";
273
+ for (var a = 1; a < s.length && s.charCodeAt(a) === 47; ++a)
274
274
  ;
275
- for (var c = i.length, h = c - a, l = 1; l < o.length && o.charCodeAt(l) === 47; ++l)
275
+ for (var c = s.length, h = c - a, l = 1; l < o.length && o.charCodeAt(l) === 47; ++l)
276
276
  ;
277
- for (var d = o.length, f = d - l, g = h < f ? h : f, m = -1, p = 0; p <= g; ++p) {
277
+ for (var u = o.length, f = u - l, g = h < f ? h : f, m = -1, p = 0; p <= g; ++p) {
278
278
  if (p === g) {
279
279
  if (f > g) {
280
280
  if (o.charCodeAt(l + p) === 47)
281
281
  return o.slice(l + p + 1);
282
282
  if (p === 0)
283
283
  return o.slice(l + p);
284
- } else h > g && (i.charCodeAt(a + p) === 47 ? m = p : p === 0 && (m = 0));
284
+ } else h > g && (s.charCodeAt(a + p) === 47 ? m = p : p === 0 && (m = 0));
285
285
  break;
286
286
  }
287
- var A = i.charCodeAt(a + p), L = o.charCodeAt(l + p);
288
- if (A !== L)
287
+ var S = s.charCodeAt(a + p), D = o.charCodeAt(l + p);
288
+ if (S !== D)
289
289
  break;
290
- A === 47 && (m = p);
290
+ S === 47 && (m = p);
291
291
  }
292
- var b = "";
292
+ var v = "";
293
293
  for (p = a + m + 1; p <= c; ++p)
294
- (p === c || i.charCodeAt(p) === 47) && (b.length === 0 ? b += ".." : b += "/..");
295
- return b.length > 0 ? b + o.slice(l + m) : (l += m, o.charCodeAt(l) === 47 && ++l, o.slice(l));
294
+ (p === c || s.charCodeAt(p) === 47) && (v.length === 0 ? v += ".." : v += "/..");
295
+ return v.length > 0 ? v + o.slice(l + m) : (l += m, o.charCodeAt(l) === 47 && ++l, o.slice(l));
296
296
  },
297
- _makeLong: function(i) {
298
- return i;
297
+ _makeLong: function(s) {
298
+ return s;
299
299
  },
300
- dirname: function(i) {
301
- if (t(i), i.length === 0) return ".";
302
- for (var o = i.charCodeAt(0), a = o === 47, c = -1, h = !0, l = i.length - 1; l >= 1; --l)
303
- if (o = i.charCodeAt(l), o === 47) {
300
+ dirname: function(s) {
301
+ if (t(s), s.length === 0) return ".";
302
+ for (var o = s.charCodeAt(0), a = o === 47, c = -1, h = !0, l = s.length - 1; l >= 1; --l)
303
+ if (o = s.charCodeAt(l), o === 47) {
304
304
  if (!h) {
305
305
  c = l;
306
306
  break;
307
307
  }
308
308
  } else
309
309
  h = !1;
310
- return c === -1 ? a ? "/" : "." : a && c === 1 ? "//" : i.slice(0, c);
310
+ return c === -1 ? a ? "/" : "." : a && c === 1 ? "//" : s.slice(0, c);
311
311
  },
312
- basename: function(i, o) {
312
+ basename: function(s, o) {
313
313
  if (o !== void 0 && typeof o != "string") throw new TypeError('"ext" argument must be a string');
314
- t(i);
314
+ t(s);
315
315
  var a = 0, c = -1, h = !0, l;
316
- if (o !== void 0 && o.length > 0 && o.length <= i.length) {
317
- if (o.length === i.length && o === i) return "";
318
- var d = o.length - 1, f = -1;
319
- for (l = i.length - 1; l >= 0; --l) {
320
- var g = i.charCodeAt(l);
316
+ if (o !== void 0 && o.length > 0 && o.length <= s.length) {
317
+ if (o.length === s.length && o === s) return "";
318
+ var u = o.length - 1, f = -1;
319
+ for (l = s.length - 1; l >= 0; --l) {
320
+ var g = s.charCodeAt(l);
321
321
  if (g === 47) {
322
322
  if (!h) {
323
323
  a = l + 1;
324
324
  break;
325
325
  }
326
326
  } else
327
- f === -1 && (h = !1, f = l + 1), d >= 0 && (g === o.charCodeAt(d) ? --d === -1 && (c = l) : (d = -1, c = f));
327
+ f === -1 && (h = !1, f = l + 1), u >= 0 && (g === o.charCodeAt(u) ? --u === -1 && (c = l) : (u = -1, c = f));
328
328
  }
329
- return a === c ? c = f : c === -1 && (c = i.length), i.slice(a, c);
329
+ return a === c ? c = f : c === -1 && (c = s.length), s.slice(a, c);
330
330
  } else {
331
- for (l = i.length - 1; l >= 0; --l)
332
- if (i.charCodeAt(l) === 47) {
331
+ for (l = s.length - 1; l >= 0; --l)
332
+ if (s.charCodeAt(l) === 47) {
333
333
  if (!h) {
334
334
  a = l + 1;
335
335
  break;
336
336
  }
337
337
  } else c === -1 && (h = !1, c = l + 1);
338
- return c === -1 ? "" : i.slice(a, c);
338
+ return c === -1 ? "" : s.slice(a, c);
339
339
  }
340
340
  },
341
- extname: function(i) {
342
- t(i);
343
- for (var o = -1, a = 0, c = -1, h = !0, l = 0, d = i.length - 1; d >= 0; --d) {
344
- var f = i.charCodeAt(d);
341
+ extname: function(s) {
342
+ t(s);
343
+ for (var o = -1, a = 0, c = -1, h = !0, l = 0, u = s.length - 1; u >= 0; --u) {
344
+ var f = s.charCodeAt(u);
345
345
  if (f === 47) {
346
346
  if (!h) {
347
- a = d + 1;
347
+ a = u + 1;
348
348
  break;
349
349
  }
350
350
  continue;
351
351
  }
352
- c === -1 && (h = !1, c = d + 1), f === 46 ? o === -1 ? o = d : l !== 1 && (l = 1) : o !== -1 && (l = -1);
352
+ c === -1 && (h = !1, c = u + 1), f === 46 ? o === -1 ? o = u : l !== 1 && (l = 1) : o !== -1 && (l = -1);
353
353
  }
354
354
  return o === -1 || c === -1 || // We saw a non-dot character immediately before the dot
355
355
  l === 0 || // The (right-most) trimmed path component is exactly '..'
356
- l === 1 && o === c - 1 && o === a + 1 ? "" : i.slice(o, c);
356
+ l === 1 && o === c - 1 && o === a + 1 ? "" : s.slice(o, c);
357
357
  },
358
- format: function(i) {
359
- if (i === null || typeof i != "object")
360
- throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof i);
361
- return n("/", i);
358
+ format: function(s) {
359
+ if (s === null || typeof s != "object")
360
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof s);
361
+ return n("/", s);
362
362
  },
363
- parse: function(i) {
364
- t(i);
363
+ parse: function(s) {
364
+ t(s);
365
365
  var o = { root: "", dir: "", base: "", ext: "", name: "" };
366
- if (i.length === 0) return o;
367
- var a = i.charCodeAt(0), c = a === 47, h;
366
+ if (s.length === 0) return o;
367
+ var a = s.charCodeAt(0), c = a === 47, h;
368
368
  c ? (o.root = "/", h = 1) : h = 0;
369
- for (var l = -1, d = 0, f = -1, g = !0, m = i.length - 1, p = 0; m >= h; --m) {
370
- if (a = i.charCodeAt(m), a === 47) {
369
+ for (var l = -1, u = 0, f = -1, g = !0, m = s.length - 1, p = 0; m >= h; --m) {
370
+ if (a = s.charCodeAt(m), a === 47) {
371
371
  if (!g) {
372
- d = m + 1;
372
+ u = m + 1;
373
373
  break;
374
374
  }
375
375
  continue;
@@ -378,36 +378,36 @@ function Je() {
378
378
  }
379
379
  return l === -1 || f === -1 || // We saw a non-dot character immediately before the dot
380
380
  p === 0 || // The (right-most) trimmed path component is exactly '..'
381
- p === 1 && l === f - 1 && l === d + 1 ? f !== -1 && (d === 0 && c ? o.base = o.name = i.slice(1, f) : o.base = o.name = i.slice(d, f)) : (d === 0 && c ? (o.name = i.slice(1, l), o.base = i.slice(1, f)) : (o.name = i.slice(d, l), o.base = i.slice(d, f)), o.ext = i.slice(l, f)), d > 0 ? o.dir = i.slice(0, d - 1) : c && (o.dir = "/"), o;
381
+ p === 1 && l === f - 1 && l === u + 1 ? f !== -1 && (u === 0 && c ? o.base = o.name = s.slice(1, f) : o.base = o.name = s.slice(u, f)) : (u === 0 && c ? (o.name = s.slice(1, l), o.base = s.slice(1, f)) : (o.name = s.slice(u, l), o.base = s.slice(u, f)), o.ext = s.slice(l, f)), u > 0 ? o.dir = s.slice(0, u - 1) : c && (o.dir = "/"), o;
382
382
  },
383
383
  sep: "/",
384
384
  delimiter: ":",
385
385
  win32: null,
386
386
  posix: null
387
387
  };
388
- return r.posix = r, Z = r, Z;
388
+ return r.posix = r, q = r, q;
389
389
  }
390
- var Xe = Je();
391
- const y = /* @__PURE__ */ Ge(Xe);
392
- function Qe(t, e) {
390
+ var dt = ut();
391
+ const y = /* @__PURE__ */ ht(dt);
392
+ function ft(t, e) {
393
393
  const n = y.relative(e, t);
394
394
  return n === "" || !n.startsWith("..") && !y.isAbsolute(n);
395
395
  }
396
- function et(t, e, n) {
397
- const r = y.resolve(e), s = y.resolve(t);
398
- if (!Qe(s, r))
399
- throw u({
396
+ function pt(t, e, n) {
397
+ const r = y.resolve(e), i = y.resolve(t);
398
+ if (!ft(i, r))
399
+ throw d({
400
400
  code: "parse_error",
401
401
  path: n,
402
402
  details: { message: "path resolves outside root directory" }
403
403
  });
404
404
  }
405
- function ve(t, e = {}) {
406
- const { rootDir: n, fromPath: r, documentPath: s, constrainToRoot: i = !1, hyogenPath: o = !1 } = e;
405
+ function $e(t, e = {}) {
406
+ const { rootDir: n, fromPath: r, documentPath: i, constrainToRoot: s = !1, hyogenPath: o = !1 } = e;
407
407
  if (t.length === 0)
408
- throw u({
408
+ throw d({
409
409
  code: "parse_error",
410
- path: s,
410
+ path: i,
411
411
  details: { message: "empty template path" }
412
412
  });
413
413
  let a;
@@ -416,17 +416,17 @@ function ve(t, e = {}) {
416
416
  a = y.resolve(n, t.slice(1));
417
417
  else {
418
418
  if (o)
419
- throw u({
419
+ throw d({
420
420
  code: "parse_error",
421
- path: s,
421
+ path: i,
422
422
  details: { message: "root-relative paths require a doc root" }
423
423
  });
424
424
  if (y.isAbsolute(t))
425
425
  a = y.resolve(t);
426
426
  else
427
- throw u({
427
+ throw d({
428
428
  code: "parse_error",
429
- path: s,
429
+ path: i,
430
430
  details: { message: "root-relative paths require a doc root" }
431
431
  });
432
432
  }
@@ -436,9 +436,9 @@ function ve(t, e = {}) {
436
436
  else if (n)
437
437
  a = y.resolve(n, t);
438
438
  else
439
- throw u({
439
+ throw d({
440
440
  code: "parse_error",
441
- path: s,
441
+ path: i,
442
442
  details: { message: "root is required for relative template paths" }
443
443
  });
444
444
  else if (y.isAbsolute(t))
@@ -446,41 +446,42 @@ function ve(t, e = {}) {
446
446
  else if (n)
447
447
  a = y.resolve(n, t);
448
448
  else
449
- throw u({
449
+ throw d({
450
450
  code: "parse_error",
451
- path: s,
451
+ path: i,
452
452
  details: { message: "root is required for relative template paths" }
453
453
  });
454
- return n && i && et(a, n, s), a;
454
+ return n && s && pt(a, n, i), a;
455
455
  }
456
- async function tt(t) {
456
+ async function mt(t) {
457
457
  const e = t.registry.get(t.alias);
458
458
  if (!e)
459
- throw u({
459
+ throw d({
460
460
  code: "parse_error",
461
461
  path: t.path,
462
462
  details: {
463
463
  message: `unregistered component: ${t.alias}`
464
464
  }
465
465
  });
466
- const n = ye(e.componentPath) ? e.componentPath : ve(e.componentPath, {
466
+ const n = We(e.componentPath) ? e.componentPath : $e(e.componentPath, {
467
467
  rootDir: t.rootDir,
468
468
  fromPath: e.definedAt,
469
469
  documentPath: t.path,
470
470
  constrainToRoot: t.constrainToRoot,
471
471
  hyogenPath: !0
472
- }), r = await t.loader(n), { context: s, body: i } = H(r, n), o = qe(s, n), { values: a, warnings: c } = Ye(
472
+ }), r = await t.loader(n), { context: i, body: s } = I(r, n), o = ot(i, n), { values: a, warnings: c } = lt(
473
473
  t.props,
474
474
  o,
475
475
  t.alias
476
476
  );
477
477
  t.warnings.push(...c);
478
- const { props: h, ...l } = s, d = _(
478
+ const { props: h, ...l } = i, u = _(
479
479
  t.parentContext,
480
480
  l,
481
481
  a
482
- ), g = (await ae(i, {
483
- context: d,
482
+ );
483
+ return (await he(s, {
484
+ context: u,
484
485
  loader: t.loader,
485
486
  root: t.rootDir,
486
487
  path: n,
@@ -492,40 +493,36 @@ async function tt(t) {
492
493
  preserveHgComments: t.preserveHgComments,
493
494
  constrainToRoot: t.constrainToRoot
494
495
  })).trim();
495
- if (g.includes(`
496
- `))
497
- throw u({
498
- code: "component_multiline_output",
499
- path: n,
500
- details: { alias: t.alias }
501
- });
502
- return g;
503
496
  }
504
- const nt = /* @__PURE__ */ new Set([
497
+ const gt = /* @__PURE__ */ new Set([
505
498
  "__proto__",
506
499
  "prototype",
507
500
  "constructor",
508
501
  "__defineGetter__"
509
502
  ]);
510
- function rt(t) {
511
- return nt.has(t);
503
+ function xt(t) {
504
+ return gt.has(t);
512
505
  }
513
- function de(t, e) {
514
- if (rt(t))
515
- throw u({
506
+ function pe(t, e) {
507
+ if (xt(t))
508
+ throw d({
516
509
  code: "forbidden_property_access",
517
510
  path: e,
518
511
  details: { property: t }
519
512
  });
520
513
  }
521
- function M(t) {
514
+ function O(t) {
522
515
  return !t;
523
516
  }
524
- function it(t, e) {
525
- if (t != null && typeof t == "object")
526
- return t[e];
517
+ function kt(t, e) {
518
+ if (t != null) {
519
+ if (typeof t == "string")
520
+ return e === "length" ? t.length : void 0;
521
+ if (typeof t == "object")
522
+ return t[e];
523
+ }
527
524
  }
528
- function st(t, e, n) {
525
+ function wt(t, e, n) {
529
526
  switch (t) {
530
527
  case "+":
531
528
  return e + n;
@@ -552,9 +549,9 @@ function st(t, e, n) {
552
549
  case "<":
553
550
  return e < n;
554
551
  case "&&":
555
- return M(e) ? e : n;
552
+ return O(e) ? e : n;
556
553
  case "||":
557
- return M(e) ? n : e;
554
+ return O(e) ? n : e;
558
555
  default:
559
556
  return;
560
557
  }
@@ -565,35 +562,35 @@ async function w(t, e) {
565
562
  case "literal":
566
563
  return t.value;
567
564
  case "identifier":
568
- return de(t.name, r), n[t.name];
565
+ return pe(t.name, r), n[t.name];
569
566
  case "member": {
570
- de(t.property, r);
571
- const s = await w(t.object, e);
572
- return it(s, t.property);
567
+ pe(t.property, r);
568
+ const i = await w(t.object, e);
569
+ return kt(i, t.property);
573
570
  }
574
571
  case "default": {
575
- const s = await w(t.left, e);
576
- return M(s) ? w(t.right, e) : s;
572
+ const i = await w(t.left, e);
573
+ return O(i) ? w(t.right, e) : i;
577
574
  }
578
575
  case "unary": {
579
- const s = await w(t.operand, e);
580
- return t.op === "!" ? !s : void 0;
576
+ const i = await w(t.operand, e);
577
+ return t.op === "!" ? !i : void 0;
581
578
  }
582
579
  case "binary": {
583
580
  if (t.op === "&&") {
584
581
  const o = await w(t.left, e);
585
- return M(o) ? o : w(t.right, e);
582
+ return O(o) ? o : w(t.right, e);
586
583
  }
587
584
  if (t.op === "||") {
588
585
  const o = await w(t.left, e);
589
- return M(o) ? w(t.right, e) : o;
586
+ return O(o) ? w(t.right, e) : o;
590
587
  }
591
- const s = await w(t.left, e), i = await w(t.right, e);
592
- return st(t.op, s, i);
588
+ const i = await w(t.left, e), s = await w(t.right, e);
589
+ return wt(t.op, i, s);
593
590
  }
594
591
  case "call": {
595
592
  if (!e.registry || !e.loader || !e.visitStack)
596
- throw u({
593
+ throw d({
597
594
  code: "parse_error",
598
595
  path: r,
599
596
  details: {
@@ -601,19 +598,19 @@ async function w(t, e) {
601
598
  }
602
599
  });
603
600
  if (!e.registry.has(t.callee))
604
- throw u({
601
+ throw d({
605
602
  code: "parse_error",
606
603
  path: r,
607
604
  details: {
608
605
  message: `unregistered component: ${t.callee}`
609
606
  }
610
607
  });
611
- const s = {};
612
- for (const [i, o] of Object.entries(t.args))
613
- s[i] = await w(o, e);
614
- return tt({
608
+ const i = {};
609
+ for (const [s, o] of Object.entries(t.args))
610
+ i[s] = await w(o, e);
611
+ return mt({
615
612
  alias: t.callee,
616
- props: s,
613
+ props: i,
617
614
  parentContext: e.parentContext ?? n,
618
615
  registry: e.registry,
619
616
  loader: e.loader,
@@ -627,58 +624,58 @@ async function w(t, e) {
627
624
  }
628
625
  case "method": {
629
626
  if (t.method !== "toLocaleString")
630
- throw u({
627
+ throw d({
631
628
  code: "parse_error",
632
629
  path: r,
633
630
  details: { message: `unsupported method: ${t.method}()` }
634
631
  });
635
- const s = await w(t.object, e);
636
- return s == null || typeof s.toLocaleString != "function" ? void 0 : s.toLocaleString(
632
+ const i = await w(t.object, e);
633
+ return i == null || typeof i.toLocaleString != "function" ? void 0 : i.toLocaleString(
637
634
  ...t.args
638
635
  );
639
636
  }
640
637
  case "ternary": {
641
- const s = await w(t.condition, e);
642
- return M(s) ? w(t.alternate, e) : w(t.consequent, e);
638
+ const i = await w(t.condition, e);
639
+ return O(i) ? w(t.alternate, e) : w(t.consequent, e);
643
640
  }
644
641
  case "template": {
645
- let s = "";
646
- for (const i of t.parts)
647
- if (typeof i == "string")
648
- s += i;
642
+ let i = "";
643
+ for (const s of t.parts)
644
+ if (typeof s == "string")
645
+ i += s;
649
646
  else {
650
- const o = await w(i, e);
651
- o != null && (s += String(o));
647
+ const o = await w(s, e);
648
+ o != null && (i += String(o));
652
649
  }
653
- return s;
650
+ return i;
654
651
  }
655
652
  default:
656
653
  return;
657
654
  }
658
655
  }
659
- function q(t) {
656
+ function V(t) {
660
657
  return /[A-Za-z_$]/.test(t);
661
658
  }
662
- function ot(t) {
659
+ function vt(t) {
663
660
  return /[A-Za-z0-9_$]/.test(t);
664
661
  }
665
- function C(t, e, n = {}) {
662
+ function W(t, e, n = {}) {
666
663
  const r = t.trim();
667
664
  if (r.length === 0)
668
665
  throw x(e, "empty expression");
669
- const s = new at(r, e, n), i = s.parseExpression();
670
- if (s.skipWhitespace(), s.hasMore())
671
- throw x(e, `unexpected token at position ${s.position}`);
672
- return i;
666
+ const i = new bt(r, e, n), s = i.parseExpression();
667
+ if (i.skipWhitespace(), i.hasMore())
668
+ throw x(e, `unexpected token at position ${i.position}`);
669
+ return s;
673
670
  }
674
671
  function x(t, e) {
675
- throw u({
672
+ throw d({
676
673
  code: "parse_error",
677
674
  path: t,
678
675
  details: { message: e }
679
676
  });
680
677
  }
681
- class at {
678
+ class bt {
682
679
  constructor(e, n, r = {}) {
683
680
  this.input = e, this.path = n, this.allowCalls = r.allowCalls !== !1;
684
681
  }
@@ -849,7 +846,7 @@ class at {
849
846
  return { type: "literal", value: this.parseObjectLiteral() };
850
847
  if (e === "[")
851
848
  return { type: "literal", value: this.parseArrayLiteral() };
852
- if (q(e)) {
849
+ if (V(e)) {
853
850
  const n = this.readIdentifier();
854
851
  if (n === "true" || n === "false" || n === "null" || n === "undefined")
855
852
  return { type: "literal", value: n === "true" ? !0 : n === "false" ? !1 : n === "null" ? null : void 0 };
@@ -885,10 +882,10 @@ class at {
885
882
  }
886
883
  if (r === "$" && this.input[this.index + 1] === "{") {
887
884
  e.push(n), n = "", this.index += 2;
888
- const s = this.readTemplateExpression(), i = C(s, this.path, {
885
+ const i = this.readTemplateExpression(), s = W(i, this.path, {
889
886
  allowCalls: !1
890
887
  });
891
- e.push(i);
888
+ e.push(s);
892
889
  continue;
893
890
  }
894
891
  n += r, this.index++;
@@ -900,27 +897,27 @@ class at {
900
897
  const n = this.index;
901
898
  let r = null;
902
899
  for (; this.index < this.input.length; ) {
903
- const s = this.input[this.index];
900
+ const i = this.input[this.index];
904
901
  if (r) {
905
- if (s === "\\") {
902
+ if (i === "\\") {
906
903
  this.index += 2;
907
904
  continue;
908
905
  }
909
- s === r && (r = null), this.index++;
906
+ i === r && (r = null), this.index++;
910
907
  continue;
911
908
  }
912
- if (s === '"' || s === "'" || s === "`") {
913
- r = s, this.index++;
909
+ if (i === '"' || i === "'" || i === "`") {
910
+ r = i, this.index++;
914
911
  continue;
915
912
  }
916
- if (s === "{") {
913
+ if (i === "{") {
917
914
  e++, this.index++;
918
915
  continue;
919
916
  }
920
- if (s === "}") {
917
+ if (i === "}") {
921
918
  if (e--, e === 0) {
922
- const i = this.input.slice(n, this.index);
923
- return this.index++, i;
919
+ const s = this.input.slice(n, this.index);
920
+ return this.index++, s;
924
921
  }
925
922
  this.index++;
926
923
  continue;
@@ -1026,7 +1023,7 @@ class at {
1026
1023
  return this.parseObjectLiteral();
1027
1024
  if (e === "[")
1028
1025
  return this.parseArrayLiteral();
1029
- if (q(e)) {
1026
+ if (V(e)) {
1030
1027
  const n = this.readIdentifier();
1031
1028
  if (n === "true") return !0;
1032
1029
  if (n === "false") return !1;
@@ -1044,9 +1041,9 @@ class at {
1044
1041
  readIdentifier() {
1045
1042
  this.skipWhitespace();
1046
1043
  const e = this.index;
1047
- if (!q(this.peek()))
1044
+ if (!V(this.peek()))
1048
1045
  return "";
1049
- for (this.index++; this.index < this.input.length && ot(this.peek()); )
1046
+ for (this.index++; this.index < this.input.length && vt(this.peek()); )
1050
1047
  this.index++;
1051
1048
  return this.input.slice(e, this.index);
1052
1049
  }
@@ -1061,8 +1058,8 @@ class at {
1061
1058
  if (r === "\\") {
1062
1059
  if (this.index++, this.index >= this.input.length)
1063
1060
  throw x(this.path, "unterminated string escape");
1064
- const s = this.input[this.index];
1065
- n += s, this.index++;
1061
+ const i = this.input[this.index];
1062
+ n += i, this.index++;
1066
1063
  continue;
1067
1064
  }
1068
1065
  n += r, this.index++;
@@ -1079,275 +1076,409 @@ class at {
1079
1076
  return r;
1080
1077
  }
1081
1078
  }
1082
- async function _e(t, e, n = {}) {
1079
+ const yt = /^( {0,3})(=+|-+)[ \t]*$/, Ae = /^( {0,3})(`{3,}|~{3,})(.*)$/;
1080
+ function M(t) {
1081
+ return t === " " || t === " ";
1082
+ }
1083
+ function Ee(t) {
1084
+ let e = 0;
1085
+ for (; e < t.length && e < 3 && t[e] === " "; )
1086
+ e += 1;
1087
+ const n = t.slice(0, e);
1088
+ let r = 0;
1089
+ for (; e < t.length && r < 6 && t[e] === "#"; )
1090
+ r += 1, e += 1;
1091
+ if (r === 0 || r === 6 && e < t.length && t[e] === "#")
1092
+ return null;
1093
+ if (e >= t.length)
1094
+ return { indent: n, level: r, text: "" };
1095
+ if (!M(t[e]))
1096
+ return null;
1097
+ for (; e < t.length && M(t[e]); )
1098
+ e += 1;
1099
+ let i = t.length;
1100
+ for (; i > e && M(t[i - 1]); )
1101
+ i -= 1;
1102
+ let s = i;
1103
+ if (i > e && t[i - 1] === "#") {
1104
+ let o = i - 1;
1105
+ for (; o > e && t[o - 1] === "#"; )
1106
+ o -= 1;
1107
+ if (o > e && M(t[o - 1])) {
1108
+ let a = o - 1;
1109
+ for (; a >= e && M(t[a]); )
1110
+ a -= 1;
1111
+ s = a + 1;
1112
+ }
1113
+ }
1114
+ return { indent: n, level: r, text: t.slice(e, s) };
1115
+ }
1116
+ function Te() {
1117
+ return { active: !1, marker: null, length: 0 };
1118
+ }
1119
+ function Le(t, e) {
1120
+ const n = Ae.exec(e);
1121
+ if (!t.active) {
1122
+ if (n) {
1123
+ const r = n[2];
1124
+ return t.active = !0, t.marker = r[0], t.length = r.length, !0;
1125
+ }
1126
+ return !1;
1127
+ }
1128
+ if (n) {
1129
+ const r = n[2], i = (n[3] ?? "").trim();
1130
+ r[0] === t.marker && r.length >= t.length && i.length === 0 && (t.active = !1, t.marker = null, t.length = 0);
1131
+ }
1132
+ return !0;
1133
+ }
1134
+ function Me(t) {
1135
+ const e = Ee(t);
1136
+ return e ? e.level : null;
1137
+ }
1138
+ function Oe(t) {
1139
+ const e = yt.exec(t);
1140
+ return e ? e[2][0] === "=" ? 1 : 2 : null;
1141
+ }
1142
+ function _t(t) {
1143
+ for (let e = 0; e < t.length; e++)
1144
+ if (!M(t[e]))
1145
+ return !1;
1146
+ return !0;
1147
+ }
1148
+ function Re(t) {
1149
+ return !(_t(t) || Me(t) !== null || Ae.test(t) || t.startsWith(" ") || t.startsWith(" "));
1150
+ }
1151
+ function He(t) {
1152
+ const e = t.split(`
1153
+ `), n = Te();
1154
+ let r = 0;
1155
+ for (let i = 0; i < e.length; i++) {
1156
+ const s = e[i];
1157
+ if (Le(n, s))
1158
+ continue;
1159
+ const o = Me(s);
1160
+ if (o !== null) {
1161
+ r = o;
1162
+ continue;
1163
+ }
1164
+ const a = Oe(s);
1165
+ if (a !== null && i > 0) {
1166
+ const c = e[i - 1];
1167
+ Re(c) && (r = a);
1168
+ }
1169
+ }
1170
+ return r;
1171
+ }
1172
+ function St(t) {
1173
+ return t < 1 ? 1 : t > 6 ? 6 : t;
1174
+ }
1175
+ function me(t, e) {
1176
+ const n = e.trim(), r = "#".repeat(St(t));
1177
+ return n.length === 0 ? r : `${r} ${n}`;
1178
+ }
1179
+ function De(t, e) {
1180
+ if (e <= 0 || t.length === 0)
1181
+ return t;
1182
+ const n = t.split(`
1183
+ `), r = Te(), i = [];
1184
+ for (let s = 0; s < n.length; s++) {
1185
+ const o = n[s];
1186
+ if (Le(r, o)) {
1187
+ i.push(o);
1188
+ continue;
1189
+ }
1190
+ const a = Oe(o);
1191
+ if (a !== null && i.length > 0) {
1192
+ const h = i[i.length - 1];
1193
+ if (Re(h)) {
1194
+ i[i.length - 1] = me(a + e, h);
1195
+ continue;
1196
+ }
1197
+ }
1198
+ const c = Ee(o);
1199
+ if (c !== null) {
1200
+ i.push(c.indent + me(c.level + e, c.text));
1201
+ continue;
1202
+ }
1203
+ i.push(o);
1204
+ }
1205
+ return i.join(`
1206
+ `);
1207
+ }
1208
+ async function Ne(t, e, n = {}) {
1083
1209
  const r = n.path;
1084
- let s = "", i = 0;
1085
- for (; i < t.length; ) {
1086
- const o = t.indexOf("{", i);
1210
+ let i = "", s = 0;
1211
+ for (; s < t.length; ) {
1212
+ const o = t.indexOf("{", s);
1087
1213
  if (o === -1) {
1088
- s += t.slice(i);
1214
+ i += t.slice(s);
1089
1215
  break;
1090
1216
  }
1091
- s += t.slice(i, o);
1217
+ i += t.slice(s, o);
1092
1218
  const a = t[o + 1] === "{" && t[o + 2] === "{" && (o === 0 || t[o - 1] !== "\\");
1093
1219
  if (!(!a && t[o + 1] === "{" && (o === 0 || t[o - 1] !== "\\")) && !a) {
1094
- s += "{", i = o + 1;
1220
+ i += "{", s = o + 1;
1095
1221
  continue;
1096
1222
  }
1097
- const h = a ? 3 : 2, l = a ? "}}}" : "}}", d = t.indexOf(l, o + h);
1098
- if (d === -1)
1099
- throw u({
1223
+ const h = a ? 3 : 2, l = a ? "}}}" : "}}", u = t.indexOf(l, o + h);
1224
+ if (u === -1)
1225
+ throw d({
1100
1226
  code: "parse_error",
1101
1227
  path: r,
1102
1228
  details: { message: "unclosed expression" }
1103
1229
  });
1104
- const f = t.slice(o + h, d).trim(), g = C(f, r), m = await w(g, {
1230
+ const f = t.slice(o + h, u).trim(), g = W(f, r), m = await w(g, {
1105
1231
  ...n,
1106
1232
  context: e,
1107
1233
  path: r,
1108
1234
  parentContext: n.parentContext ?? e
1109
1235
  });
1110
- s += m == null ? "" : String(m), i = d + l.length;
1236
+ let p = m == null ? "" : String(m);
1237
+ if (g.type === "call" && p.length > 0) {
1238
+ const S = He(i);
1239
+ p = De(p, S);
1240
+ }
1241
+ i += p, s = u + l.length;
1111
1242
  }
1112
- return s;
1243
+ return i;
1113
1244
  }
1114
- function ct(t, e) {
1245
+ function Ct(t, e) {
1115
1246
  let n = 0, r = 0;
1116
1247
  for (; r < t.length; ) {
1117
- const s = t.indexOf(e, r);
1118
- if (s === -1)
1248
+ const i = t.indexOf(e, r);
1249
+ if (i === -1)
1119
1250
  break;
1120
- n++, r = s + e.length;
1251
+ n++, r = i + e.length;
1121
1252
  }
1122
1253
  return n;
1123
1254
  }
1124
- function X(t) {
1125
- const e = t.includes("@hg"), n = t.includes("@endhg"), r = ct(t, "@@");
1255
+ function ee(t) {
1256
+ const e = t.includes("@hg"), n = t.includes("@endhg"), r = Ct(t, "@@");
1126
1257
  return e && n ? r > 0 ? "mixed" : "hg" : r >= 2 && !e && !n ? "at-at" : (e || n) && r > 0 ? "mixed" : e && !n || r === 1 && !n ? "unclosed" : "none";
1127
1258
  }
1128
- function Q(t) {
1259
+ function te(t) {
1129
1260
  return t.replace(/@endhg/g, "").replace(/@hg/g, "").replace(/@@/g, "");
1130
1261
  }
1131
- function ee(t, e) {
1262
+ function ne(t, e) {
1132
1263
  let n = 0, r = !1;
1133
1264
  for (; n < e; ) {
1134
- const s = t.indexOf("```", n);
1135
- if (s === -1 || s >= e)
1265
+ const i = t.indexOf("```", n);
1266
+ if (i === -1 || i >= e)
1136
1267
  break;
1137
- r = !r, n = s + 3;
1268
+ r = !r, n = i + 3;
1138
1269
  }
1139
1270
  return r;
1140
1271
  }
1141
- function T(t) {
1272
+ function E(t) {
1142
1273
  const e = [];
1143
1274
  let n = 0;
1144
1275
  for (; n < t.length; ) {
1145
1276
  const r = t.indexOf("<!--", n);
1146
1277
  if (r === -1)
1147
1278
  break;
1148
- if (ee(t, r)) {
1279
+ if (ne(t, r)) {
1149
1280
  n = r + 4;
1150
1281
  continue;
1151
1282
  }
1152
- const s = t.indexOf("-->", r + 4);
1153
- if (s === -1)
1283
+ const i = t.indexOf("-->", r + 4);
1284
+ if (i === -1)
1154
1285
  break;
1155
- const i = t.slice(r, s + 3), o = i.slice(4, i.length - 3), a = X(o);
1286
+ const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a = ee(o);
1156
1287
  (a === "hg" || a === "at-at") && e.push({
1157
1288
  start: r,
1158
- end: s + 3,
1289
+ end: i + 3,
1159
1290
  inner: o,
1160
- raw: i
1161
- }), n = s + 3;
1291
+ raw: s
1292
+ }), n = i + 3;
1162
1293
  }
1163
1294
  return e;
1164
1295
  }
1165
- function Se(t) {
1296
+ function Be(t) {
1166
1297
  let e = 0;
1167
1298
  for (; e < t.length; ) {
1168
1299
  const n = t.indexOf("<!--", e);
1169
1300
  if (n === -1)
1170
1301
  return !1;
1171
- if (ee(t, n)) {
1302
+ if (ne(t, n)) {
1172
1303
  e = n + 4;
1173
1304
  continue;
1174
1305
  }
1175
1306
  const r = t.indexOf("-->", n + 4);
1176
1307
  if (r === -1)
1177
1308
  return !1;
1178
- const s = t.slice(n + 4, r), i = X(s);
1179
- if (i === "unclosed" || i === "mixed")
1309
+ const i = t.slice(n + 4, r), s = ee(i);
1310
+ if (s === "unclosed" || s === "mixed")
1180
1311
  return !0;
1181
1312
  e = r + 3;
1182
1313
  }
1183
1314
  return !1;
1184
1315
  }
1185
- function Ce(t) {
1316
+ function Fe(t) {
1186
1317
  let e = 0;
1187
1318
  for (; e < t.length; ) {
1188
1319
  const n = t.indexOf("<!--", e);
1189
1320
  if (n === -1)
1190
1321
  return null;
1191
- if (ee(t, n)) {
1322
+ if (ne(t, n)) {
1192
1323
  e = n + 4;
1193
1324
  continue;
1194
1325
  }
1195
1326
  const r = t.indexOf("-->", n + 4);
1196
1327
  if (r === -1)
1197
1328
  return null;
1198
- const s = t.slice(n + 4, r), i = X(s);
1199
- if (i === "mixed")
1329
+ const i = t.slice(n + 4, r), s = ee(i);
1330
+ if (s === "mixed")
1200
1331
  return "mixed @hg and @@ markers are not allowed";
1201
- if (i === "unclosed")
1332
+ if (s === "unclosed")
1202
1333
  return "unclosed hyogen block (missing closing marker)";
1203
1334
  e = r + 3;
1204
1335
  }
1205
1336
  return null;
1206
1337
  }
1207
- function E(t) {
1208
- return Q(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
1338
+ function A(t) {
1339
+ return te(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
1209
1340
  }
1210
- const lt = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
1211
- function Ae(t) {
1212
- return lt.test(t.trim());
1341
+ const Wt = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
1342
+ function je(t) {
1343
+ return Wt.test(t.trim());
1213
1344
  }
1214
- function V(t, e) {
1215
- throw u({
1345
+ function K(t, e) {
1346
+ throw d({
1216
1347
  code: "parse_error",
1217
1348
  path: t,
1218
1349
  details: { message: e }
1219
1350
  });
1220
1351
  }
1221
- function ht(t, e) {
1352
+ function $t(t, e) {
1222
1353
  let n = t;
1223
1354
  const r = /^<!--([\s\S]*?)-->$/.exec(t.trim());
1224
1355
  r && (n = r[1]);
1225
- const s = E(n);
1226
- if (s.length !== 1)
1356
+ const i = A(n);
1357
+ if (i.length !== 1)
1227
1358
  return null;
1228
- const i = s[0];
1229
- if (/^include\s+/i.test(i) || /^component\s+/i.test(i) || /^const\s+/i.test(i) || /^let\s+/i.test(i) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(i))
1359
+ const s = i[0];
1360
+ if (/^include\s+/i.test(s) || /^component\s+/i.test(s) || /^const\s+/i.test(s) || /^let\s+/i.test(s) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(s))
1230
1361
  return null;
1231
- if (i === "else")
1362
+ if (s === "else")
1232
1363
  return { kind: "else" };
1233
- if (i === "endif")
1364
+ if (s === "endif")
1234
1365
  return { kind: "endif" };
1235
- if (i === "endeach")
1366
+ if (s === "endeach")
1236
1367
  return { kind: "endeach" };
1237
- if (/^IF\b/.test(i) || /^ELSE\b/.test(i) || /^ENDIF\b/.test(i))
1238
- throw V(e, "control keywords must be lowercase");
1239
- const o = /^else\s+if\s+(.+)$/.exec(i);
1368
+ if (/^IF\b/.test(s) || /^ELSE\b/.test(s) || /^ENDIF\b/.test(s))
1369
+ throw K(e, "control keywords must be lowercase");
1370
+ const o = /^else\s+if\s+(.+)$/.exec(s);
1240
1371
  if (o)
1241
1372
  return {
1242
1373
  kind: "else_if",
1243
- expr: C(o[1], e)
1374
+ expr: W(o[1], e)
1244
1375
  };
1245
- const a = /^if\s+(.+)$/.exec(i);
1376
+ const a = /^if\s+(.+)$/.exec(s);
1246
1377
  if (a)
1247
1378
  return {
1248
1379
  kind: "if",
1249
- expr: C(a[1], e)
1380
+ expr: W(a[1], e)
1250
1381
  };
1251
- const c = /^each\s+([A-Za-z_$][A-Za-z0-9_$]*)\s+in\s+(.+)$/.exec(i);
1382
+ const c = /^each\s+([A-Za-z_$][A-Za-z0-9_$]*)\s+in\s+(.+)$/.exec(s);
1252
1383
  if (c)
1253
1384
  return {
1254
1385
  kind: "each",
1255
1386
  item: c[1],
1256
- expr: C(c[2], e)
1387
+ expr: W(c[2], e)
1257
1388
  };
1258
- if (i === "if")
1259
- throw V(e, "if requires an expression");
1260
- if (/^each\s+/.test(i))
1261
- throw V(e, "invalid each directive");
1389
+ if (s === "if")
1390
+ throw K(e, "if requires an expression");
1391
+ if (/^each\s+/.test(s))
1392
+ throw K(e, "invalid each directive");
1262
1393
  return null;
1263
1394
  }
1264
1395
  function R(t) {
1265
1396
  return { start: t.start, end: t.end, raw: t.raw };
1266
1397
  }
1267
- function S(t, e) {
1268
- throw u({
1398
+ function $(t, e) {
1399
+ throw d({
1269
1400
  code: "parse_error",
1270
1401
  path: t,
1271
1402
  details: { message: e }
1272
1403
  });
1273
1404
  }
1274
- function dt(t, e) {
1405
+ function At(t, e) {
1275
1406
  const n = [];
1276
- for (const r of T(t)) {
1277
- const s = ht(r.inner, e);
1278
- s && n.push({
1407
+ for (const r of E(t)) {
1408
+ const i = $t(r.inner, e);
1409
+ i && n.push({
1279
1410
  start: r.start,
1280
1411
  end: r.end,
1281
1412
  raw: r.raw,
1282
- opener: s
1413
+ opener: i
1283
1414
  });
1284
1415
  }
1285
1416
  return n;
1286
1417
  }
1287
- function We(t) {
1418
+ function Pe(t) {
1288
1419
  return t.kind === "if" || t.kind === "each";
1289
1420
  }
1290
- function ut(t, e) {
1291
- const n = dt(t, e);
1421
+ function Et(t, e) {
1422
+ const n = At(t, e);
1292
1423
  if (n.length === 0)
1293
1424
  return t.length > 0 ? [{ kind: "text", content: t }] : [];
1294
- const { nodes: r, nextIndex: s } = B(t, n, 0, n.length, e);
1295
- if (s < n.length) {
1296
- const i = n[s];
1297
- if (i.opener.kind === "endif")
1298
- throw S(e, "endif without matching if");
1299
- if (i.opener.kind === "endeach")
1300
- throw S(e, "endeach without matching each");
1301
- if (i.opener.kind === "else" || i.opener.kind === "else_if")
1302
- throw S(e, "else without matching if");
1425
+ const { nodes: r, nextIndex: i } = F(t, n, 0, n.length, e);
1426
+ if (i < n.length) {
1427
+ const s = n[i];
1428
+ if (s.opener.kind === "endif")
1429
+ throw $(e, "endif without matching if");
1430
+ if (s.opener.kind === "endeach")
1431
+ throw $(e, "endeach without matching each");
1432
+ if (s.opener.kind === "else" || s.opener.kind === "else_if")
1433
+ throw $(e, "else without matching if");
1303
1434
  }
1304
1435
  return r;
1305
1436
  }
1306
- function B(t, e, n, r, s, i = 0, o) {
1437
+ function F(t, e, n, r, i, s = 0, o) {
1307
1438
  const a = o ?? t.length, c = [];
1308
- let h = i, l = n;
1439
+ let h = s, l = n;
1309
1440
  for (; l < r; ) {
1310
- const d = e[l];
1311
- if (d.start >= a)
1441
+ const u = e[l];
1442
+ if (u.start >= a)
1312
1443
  break;
1313
- if (d.end <= i) {
1444
+ if (u.end <= s) {
1314
1445
  l++;
1315
1446
  continue;
1316
1447
  }
1317
- if (d.start > h && c.push({
1448
+ if (u.start > h && c.push({
1318
1449
  kind: "text",
1319
- content: t.slice(h, d.start)
1320
- }), d.opener.kind === "if") {
1321
- const f = ft(t, e, l, r, s);
1450
+ content: t.slice(h, u.start)
1451
+ }), u.opener.kind === "if") {
1452
+ const f = Tt(t, e, l, r, i);
1322
1453
  c.push(f.node), h = f.endPos, l = f.nextIndex;
1323
1454
  continue;
1324
1455
  }
1325
- if (d.opener.kind === "each") {
1326
- const f = pt(t, e, l, r, s);
1456
+ if (u.opener.kind === "each") {
1457
+ const f = Lt(t, e, l, r, i);
1327
1458
  c.push(f.node), h = f.endPos, l = f.nextIndex;
1328
1459
  continue;
1329
1460
  }
1330
- if (d.opener.kind === "else" || d.opener.kind === "else_if")
1331
- throw S(s, "else without matching if");
1332
- if (d.opener.kind === "endif")
1333
- throw S(s, "endif without matching if");
1334
- if (d.opener.kind === "endeach")
1335
- throw S(s, "endeach without matching each");
1461
+ if (u.opener.kind === "else" || u.opener.kind === "else_if")
1462
+ throw $(i, "else without matching if");
1463
+ if (u.opener.kind === "endif")
1464
+ throw $(i, "endif without matching if");
1465
+ if (u.opener.kind === "endeach")
1466
+ throw $(i, "endeach without matching each");
1336
1467
  l++;
1337
1468
  }
1338
1469
  return h < a && c.push({ kind: "text", content: t.slice(h, a) }), { nodes: c, nextIndex: l };
1339
1470
  }
1340
- function ft(t, e, n, r, s) {
1341
- const i = e[n];
1342
- if (i.opener.kind !== "if")
1343
- throw S(s, "expected if");
1471
+ function Tt(t, e, n, r, i) {
1472
+ const s = e[n];
1473
+ if (s.opener.kind !== "if")
1474
+ throw $(i, "expected if");
1344
1475
  const o = [];
1345
- let a = n, c = i.end, h = 0;
1476
+ let a = n, c = s.end, h = 0;
1346
1477
  for (; a < r; ) {
1347
1478
  const l = e[a];
1348
1479
  if (a === n) {
1349
1480
  if (l.opener.kind !== "if")
1350
- throw S(s, "expected if");
1481
+ throw $(i, "expected if");
1351
1482
  o.push({
1352
1483
  kind: "if",
1353
1484
  expr: l.opener.expr,
@@ -1356,18 +1487,18 @@ function ft(t, e, n, r, s) {
1356
1487
  }), a++;
1357
1488
  continue;
1358
1489
  }
1359
- if (We(l.opener)) {
1490
+ if (Pe(l.opener)) {
1360
1491
  h++, a++;
1361
1492
  continue;
1362
1493
  }
1363
1494
  if (l.opener.kind === "endif") {
1364
1495
  if (h === 0)
1365
- return o[o.length - 1].body = B(
1496
+ return o[o.length - 1].body = F(
1366
1497
  t,
1367
1498
  e,
1368
1499
  n + 1,
1369
1500
  a,
1370
- s,
1501
+ i,
1371
1502
  c,
1372
1503
  l.start
1373
1504
  ).nodes, {
@@ -1384,12 +1515,12 @@ function ft(t, e, n, r, s) {
1384
1515
  }
1385
1516
  if (h === 0) {
1386
1517
  if (l.opener.kind === "else_if") {
1387
- o[o.length - 1].body = B(
1518
+ o[o.length - 1].body = F(
1388
1519
  t,
1389
1520
  e,
1390
1521
  n + 1,
1391
1522
  a,
1392
- s,
1523
+ i,
1393
1524
  c,
1394
1525
  l.start
1395
1526
  ).nodes, o.push({
@@ -1401,12 +1532,12 @@ function ft(t, e, n, r, s) {
1401
1532
  continue;
1402
1533
  }
1403
1534
  if (l.opener.kind === "else") {
1404
- o[o.length - 1].body = B(
1535
+ o[o.length - 1].body = F(
1405
1536
  t,
1406
1537
  e,
1407
1538
  n + 1,
1408
1539
  a,
1409
- s,
1540
+ i,
1410
1541
  c,
1411
1542
  l.start
1412
1543
  ).nodes, o.push({
@@ -1419,38 +1550,38 @@ function ft(t, e, n, r, s) {
1419
1550
  }
1420
1551
  a++;
1421
1552
  }
1422
- throw S(s, "unclosed if block (missing endif)");
1553
+ throw $(i, "unclosed if block (missing endif)");
1423
1554
  }
1424
- function pt(t, e, n, r, s) {
1425
- const i = e[n];
1426
- if (i.opener.kind !== "each")
1427
- throw S(s, "expected each");
1555
+ function Lt(t, e, n, r, i) {
1556
+ const s = e[n];
1557
+ if (s.opener.kind !== "each")
1558
+ throw $(i, "expected each");
1428
1559
  let o = n + 1;
1429
- const a = i.end;
1560
+ const a = s.end;
1430
1561
  let c = 0;
1431
1562
  for (; o < r; ) {
1432
1563
  const h = e[o];
1433
- if (We(h.opener)) {
1564
+ if (Pe(h.opener)) {
1434
1565
  c++, o++;
1435
1566
  continue;
1436
1567
  }
1437
1568
  if (h.opener.kind === "endeach") {
1438
1569
  if (c === 0) {
1439
- const l = B(
1570
+ const l = F(
1440
1571
  t,
1441
1572
  e,
1442
1573
  n + 1,
1443
1574
  o,
1444
- s,
1575
+ i,
1445
1576
  a,
1446
1577
  h.start
1447
1578
  ).nodes;
1448
1579
  return {
1449
1580
  node: {
1450
1581
  kind: "each",
1451
- item: i.opener.item,
1452
- expr: i.opener.expr,
1453
- opener: R(i),
1582
+ item: s.opener.item,
1583
+ expr: s.opener.expr,
1584
+ opener: R(s),
1454
1585
  body: l,
1455
1586
  closer: R(h)
1456
1587
  },
@@ -1467,28 +1598,28 @@ function pt(t, e, n, r, s) {
1467
1598
  }
1468
1599
  o++;
1469
1600
  }
1470
- throw S(s, "unclosed each block (missing endeach)");
1601
+ throw $(i, "unclosed each block (missing endeach)");
1471
1602
  }
1472
- const ue = 20;
1473
- class mt {
1603
+ const ge = 20;
1604
+ class Mt {
1474
1605
  depth = 0;
1475
1606
  get currentDepth() {
1476
1607
  return this.depth;
1477
1608
  }
1478
1609
  enter() {
1479
- return this.depth >= ue ? { exceeded: !0, limit: ue } : (this.depth++, { exceeded: !1, depth: this.depth });
1610
+ return this.depth >= ge ? { exceeded: !0, limit: ge } : (this.depth++, { exceeded: !1, depth: this.depth });
1480
1611
  }
1481
1612
  exit() {
1482
1613
  this.depth > 0 && this.depth--;
1483
1614
  }
1484
1615
  }
1485
- function gt(t) {
1616
+ function Ot(t) {
1486
1617
  return !!t;
1487
1618
  }
1488
- function xt(t) {
1619
+ function Rt(t) {
1489
1620
  return t != null && typeof t[Symbol.iterator] == "function";
1490
1621
  }
1491
- function $e(t) {
1622
+ function Ie(t) {
1492
1623
  return {
1493
1624
  code: "nest_limit_exceeded",
1494
1625
  message: "structure nest limit exceeded",
@@ -1496,49 +1627,49 @@ function $e(t) {
1496
1627
  details: { limit: 20 }
1497
1628
  };
1498
1629
  }
1499
- function te(t) {
1630
+ function re(t) {
1500
1631
  return t.startsWith(`
1501
1632
  `) ? t.slice(1) : t;
1502
1633
  }
1503
- async function kt(t, e) {
1504
- const n = e.path, r = e.warnings ?? [], s = ut(t, n), i = new mt();
1505
- return ne(s, e, i, r);
1634
+ async function Ht(t, e) {
1635
+ const n = e.path, r = e.warnings ?? [], i = Et(t, n), s = new Mt();
1636
+ return ie(i, e, s, r);
1506
1637
  }
1507
- async function ne(t, e, n, r) {
1508
- const s = e.preserveHgComments === !0;
1509
- let i = "", o = !1;
1638
+ async function ie(t, e, n, r) {
1639
+ const i = e.preserveHgComments === !0;
1640
+ let s = "", o = !1;
1510
1641
  for (const a of t) {
1511
- let c = await wt(a, e, n, r);
1512
- o && (c = te(c)), i += c, o = !s && (a.kind === "if" || a.kind === "each");
1642
+ let c = await Dt(a, e, n, r);
1643
+ o && (c = re(c)), s += c, o = !i && (a.kind === "if" || a.kind === "each");
1513
1644
  }
1514
- return i;
1645
+ return s;
1515
1646
  }
1516
- async function wt(t, e, n, r) {
1647
+ async function Dt(t, e, n, r) {
1517
1648
  switch (t.kind) {
1518
1649
  case "text":
1519
1650
  return t.content;
1520
1651
  case "if":
1521
- return bt(t, e, n, r);
1652
+ return Nt(t, e, n, r);
1522
1653
  case "each":
1523
- return yt(t, e, n, r);
1654
+ return Bt(t, e, n, r);
1524
1655
  default:
1525
1656
  return "";
1526
1657
  }
1527
1658
  }
1528
- async function bt(t, e, n, r) {
1659
+ async function Nt(t, e, n, r) {
1529
1660
  if (n.enter().exceeded)
1530
- return r.push($e(e.path)), "";
1661
+ return r.push(Ie(e.path)), "";
1531
1662
  try {
1532
- let i = -1;
1663
+ let s = -1;
1533
1664
  for (let c = 0; c < t.branches.length; c++) {
1534
1665
  const h = t.branches[c];
1535
1666
  if (h.kind === "else") {
1536
- i = c;
1667
+ s = c;
1537
1668
  break;
1538
1669
  }
1539
1670
  const l = await w(h.expr, e);
1540
- if (gt(l)) {
1541
- i = c;
1671
+ if (Ot(l)) {
1672
+ s = c;
1542
1673
  break;
1543
1674
  }
1544
1675
  }
@@ -1546,9 +1677,9 @@ async function bt(t, e, n, r) {
1546
1677
  let a = "";
1547
1678
  for (let c = 0; c < t.branches.length; c++) {
1548
1679
  const h = t.branches[c];
1549
- if (o && (a += h.opener.raw), c === i) {
1550
- let l = await ne(h.body, e, n, r);
1551
- o || (l = te(l)), a += l;
1680
+ if (o && (a += h.opener.raw), c === s) {
1681
+ let l = await ie(h.body, e, n, r);
1682
+ o || (l = re(l)), a += l;
1552
1683
  }
1553
1684
  }
1554
1685
  return o && (a += t.closer.raw), a;
@@ -1556,24 +1687,24 @@ async function bt(t, e, n, r) {
1556
1687
  n.exit();
1557
1688
  }
1558
1689
  }
1559
- async function yt(t, e, n, r) {
1690
+ async function Bt(t, e, n, r) {
1560
1691
  if (n.enter().exceeded)
1561
- return r.push($e(e.path)), "";
1692
+ return r.push(Ie(e.path)), "";
1562
1693
  try {
1563
- const i = await w(t.expr, e);
1564
- if (!xt(i))
1694
+ const s = await w(t.expr, e);
1695
+ if (!Rt(s))
1565
1696
  return "";
1566
1697
  const o = e.preserveHgComments === !0;
1567
1698
  let a = "";
1568
- for (const c of i) {
1699
+ for (const c of s) {
1569
1700
  const h = { ...e.context, [t.item]: c };
1570
1701
  o && (a += t.opener.raw);
1571
- let l = await ne(t.body, {
1702
+ let l = await ie(t.body, {
1572
1703
  ...e,
1573
1704
  context: h
1574
1705
  }, n, r);
1575
- o || (l = te(l));
1576
- const d = await _e(l, h, {
1706
+ o || (l = re(l));
1707
+ const u = await Ne(l, h, {
1577
1708
  path: e.path,
1578
1709
  registry: e.registry,
1579
1710
  loader: e.loader,
@@ -1584,56 +1715,56 @@ async function yt(t, e, n, r) {
1584
1715
  preserveHgComments: e.preserveHgComments,
1585
1716
  constrainToRoot: e.constrainToRoot
1586
1717
  });
1587
- a += d, o && (a += t.closer.raw);
1718
+ a += u, o && (a += t.closer.raw);
1588
1719
  }
1589
1720
  return a;
1590
1721
  } finally {
1591
1722
  n.exit();
1592
1723
  }
1593
1724
  }
1594
- function Y(t, e, n, r, s = !1, i = !1) {
1595
- return ye(e) ? e : ve(e, {
1725
+ function X(t, e, n, r, i = !1, s = !1) {
1726
+ return We(e) ? e : $e(e, {
1596
1727
  rootDir: t,
1597
1728
  fromPath: r,
1598
1729
  documentPath: n,
1599
- constrainToRoot: s,
1600
- hyogenPath: i
1730
+ constrainToRoot: i,
1731
+ hyogenPath: s
1601
1732
  });
1602
1733
  }
1603
- function Te(t) {
1734
+ function ze(t) {
1604
1735
  let e = 0;
1605
1736
  for (let n = t.length - 1; n >= 0 && t[n] === `
1606
1737
  `; n--)
1607
1738
  e++;
1608
1739
  return e;
1609
1740
  }
1610
- function Ee(t) {
1741
+ function Ue(t) {
1611
1742
  let e = 0;
1612
1743
  for (; e < t.length && t[e] === `
1613
1744
  `; )
1614
1745
  e++;
1615
1746
  return e;
1616
1747
  }
1617
- function D(t, e) {
1618
- const n = Te(t), r = Ee(e), s = Math.max(n, r);
1748
+ function T(t, e) {
1749
+ const n = ze(t), r = Ue(e), i = Math.max(n, r);
1619
1750
  return t.slice(0, t.length - n) + `
1620
- `.repeat(s) + e.slice(r);
1751
+ `.repeat(i) + e.slice(r);
1621
1752
  }
1622
- function re(t, e) {
1623
- const n = Te(t), r = Ee(e);
1753
+ function se(t, e) {
1754
+ const n = ze(t), r = Ue(e);
1624
1755
  return n + r - Math.max(n, r);
1625
1756
  }
1626
- function fe(t, e, n) {
1757
+ function xe(t, e, n) {
1627
1758
  const r = t.indexOf(e);
1628
1759
  if (r < 0)
1629
1760
  return t;
1630
- const s = t.slice(0, r), i = t.slice(r + e.length);
1631
- return D(D(s, n), i);
1761
+ const i = t.slice(0, r), s = t.slice(r + e.length);
1762
+ return T(T(i, n), s);
1632
1763
  }
1633
- async function vt(t) {
1764
+ async function Ft(t) {
1634
1765
  let e = t.source;
1635
1766
  for (const n of t.directives) {
1636
- const r = Y(
1767
+ const r = X(
1637
1768
  t.root,
1638
1769
  n.path,
1639
1770
  t.path,
@@ -1642,28 +1773,28 @@ async function vt(t) {
1642
1773
  !0
1643
1774
  );
1644
1775
  if (t.visitStack) {
1645
- const s = t.visitStack.check(r);
1646
- if (s.circular) {
1776
+ const i = t.visitStack.check(r);
1777
+ if (i.circular) {
1647
1778
  t.warnings?.push({
1648
1779
  code: "circular_include",
1649
- message: O("circular_include", {
1780
+ message: H("circular_include", {
1650
1781
  path: r,
1651
- from: s.from,
1782
+ from: i.from,
1652
1783
  via: "include"
1653
1784
  }),
1654
1785
  path: t.path,
1655
1786
  details: {
1656
1787
  path: r,
1657
- from: s.from,
1788
+ from: i.from,
1658
1789
  via: "include"
1659
1790
  }
1660
- }), e = fe(e, n.marker, "");
1791
+ }), e = xe(e, n.marker, "");
1661
1792
  continue;
1662
1793
  }
1663
1794
  t.visitStack.push(r);
1664
1795
  }
1665
1796
  try {
1666
- const s = await t.loader(r), i = await Yt(s, {
1797
+ const i = await t.loader(r), s = await $n(i, {
1667
1798
  context: t.context,
1668
1799
  loader: t.loader,
1669
1800
  root: t.root,
@@ -1673,16 +1804,16 @@ async function vt(t) {
1673
1804
  visitStack: t.visitStack,
1674
1805
  warnings: t.warnings,
1675
1806
  registry: t.registry
1676
- }), o = t.preserveHgComments && n.raw ? `${n.raw}
1677
- ${i}` : i;
1678
- e = fe(e, n.marker, o);
1807
+ }), o = e.indexOf(n.marker), a = o >= 0 ? e.slice(0, o) : e, c = He(a), h = De(s, c), l = t.preserveHgComments && n.raw ? `${n.raw}
1808
+ ${h}` : h;
1809
+ e = xe(e, n.marker, l);
1679
1810
  } finally {
1680
1811
  t.visitStack?.pop();
1681
1812
  }
1682
1813
  }
1683
1814
  return e;
1684
1815
  }
1685
- class Le {
1816
+ class Ze {
1686
1817
  stack = [];
1687
1818
  check(e) {
1688
1819
  return e.length === 0 ? { circular: !1 } : this.stack.indexOf(e) !== -1 ? {
@@ -1698,28 +1829,28 @@ class Le {
1698
1829
  this.stack.pop();
1699
1830
  }
1700
1831
  }
1701
- async function _t(t, e, n = {}) {
1702
- const { path: r, constBindings: s = /* @__PURE__ */ new Set() } = n, i = await w(t.expr, { context: e, path: r });
1832
+ async function jt(t, e, n = {}) {
1833
+ const { path: r, constBindings: i = /* @__PURE__ */ new Set() } = n, s = await w(t.expr, { context: e, path: r });
1703
1834
  switch (t.kind) {
1704
1835
  case "const": {
1705
- if (s.has(t.name))
1706
- throw u({
1836
+ if (i.has(t.name))
1837
+ throw d({
1707
1838
  code: "parse_error",
1708
1839
  path: r,
1709
1840
  details: {
1710
1841
  message: `cannot reassign const binding: ${t.name}`
1711
1842
  }
1712
1843
  });
1713
- e[t.name] = i, s.add(t.name);
1844
+ e[t.name] = s, i.add(t.name);
1714
1845
  break;
1715
1846
  }
1716
1847
  case "let": {
1717
- e[t.name] = i;
1848
+ e[t.name] = s;
1718
1849
  break;
1719
1850
  }
1720
1851
  case "assign": {
1721
- if (s.has(t.name))
1722
- throw u({
1852
+ if (i.has(t.name))
1853
+ throw d({
1723
1854
  code: "parse_error",
1724
1855
  path: r,
1725
1856
  details: {
@@ -1727,33 +1858,33 @@ async function _t(t, e, n = {}) {
1727
1858
  }
1728
1859
  });
1729
1860
  if (!(t.name in e))
1730
- throw u({
1861
+ throw d({
1731
1862
  code: "parse_error",
1732
1863
  path: r,
1733
1864
  details: {
1734
1865
  message: `assignment to undeclared variable: ${t.name}`
1735
1866
  }
1736
1867
  });
1737
- e[t.name] = i;
1868
+ e[t.name] = s;
1738
1869
  break;
1739
1870
  }
1740
1871
  }
1741
1872
  }
1742
- function pe(t) {
1873
+ function ke(t) {
1743
1874
  return !t;
1744
1875
  }
1745
- async function j(t, e, n = {}) {
1746
- const { path: r, constBindings: s = /* @__PURE__ */ new Set(), onUpdate: i } = n;
1876
+ async function B(t, e, n = {}) {
1877
+ const { path: r, constBindings: i = /* @__PURE__ */ new Set(), onUpdate: s, echoChunks: o } = n;
1747
1878
  switch (t.kind) {
1748
1879
  case "const":
1749
1880
  case "let":
1750
1881
  case "assign": {
1751
- await _t(t, e, { path: r, constBindings: s }), i?.(t.name);
1882
+ await jt(t, e, { path: r, constBindings: i }), s?.(t.name);
1752
1883
  return;
1753
1884
  }
1754
1885
  case "update": {
1755
- if (s.has(t.name))
1756
- throw u({
1886
+ if (i.has(t.name))
1887
+ throw d({
1757
1888
  code: "parse_error",
1758
1889
  path: r,
1759
1890
  details: {
@@ -1761,20 +1892,20 @@ async function j(t, e, n = {}) {
1761
1892
  }
1762
1893
  });
1763
1894
  if (!(t.name in e))
1764
- throw u({
1895
+ throw d({
1765
1896
  code: "parse_error",
1766
1897
  path: r,
1767
1898
  details: {
1768
1899
  message: `assignment to undeclared variable: ${t.name}`
1769
1900
  }
1770
1901
  });
1771
- const o = Number(e[t.name]), a = t.op === "++" ? o + 1 : o - 1;
1772
- e[t.name] = a, i?.(t.name);
1902
+ const a = Number(e[t.name]), c = t.op === "++" ? a + 1 : a - 1;
1903
+ e[t.name] = c, s?.(t.name);
1773
1904
  return;
1774
1905
  }
1775
1906
  case "compound_assign": {
1776
- if (s.has(t.name))
1777
- throw u({
1907
+ if (i.has(t.name))
1908
+ throw d({
1778
1909
  code: "parse_error",
1779
1910
  path: r,
1780
1911
  details: {
@@ -1782,66 +1913,74 @@ async function j(t, e, n = {}) {
1782
1913
  }
1783
1914
  });
1784
1915
  if (!(t.name in e))
1785
- throw u({
1916
+ throw d({
1786
1917
  code: "parse_error",
1787
1918
  path: r,
1788
1919
  details: {
1789
1920
  message: `assignment to undeclared variable: ${t.name}`
1790
1921
  }
1791
1922
  });
1792
- const o = await w(t.expr, { context: e, path: r }), a = Number(e[t.name]), c = Number(o);
1793
- let h;
1923
+ const a = await w(t.expr, { context: e, path: r }), c = Number(e[t.name]), h = Number(a);
1924
+ let l;
1794
1925
  switch (t.op) {
1795
1926
  case "+=":
1796
- h = a + c;
1927
+ l = c + h;
1797
1928
  break;
1798
1929
  case "-=":
1799
- h = a - c;
1930
+ l = c - h;
1800
1931
  break;
1801
1932
  case "*=":
1802
- h = a * c;
1933
+ l = c * h;
1803
1934
  break;
1804
1935
  case "/=":
1805
- h = a / c;
1936
+ l = c / h;
1806
1937
  break;
1807
1938
  }
1808
- e[t.name] = h, i?.(t.name);
1939
+ e[t.name] = l, s?.(t.name);
1940
+ return;
1941
+ }
1942
+ case "echo": {
1943
+ const a = await w(t.expr, {
1944
+ context: e,
1945
+ path: r
1946
+ }), c = a == null ? "" : String(a);
1947
+ o?.push(c);
1809
1948
  return;
1810
1949
  }
1811
1950
  case "for": {
1812
- for (t.init && await j(t.init, e, n); ; ) {
1813
- const o = await w(t.cond, {
1951
+ for (t.init && await B(t.init, e, n); ; ) {
1952
+ const a = await w(t.cond, {
1814
1953
  context: e,
1815
1954
  path: r
1816
1955
  });
1817
- if (pe(o))
1956
+ if (ke(a))
1818
1957
  break;
1819
- for (const a of t.body)
1820
- await j(a, e, n);
1821
- t.update && await j(t.update, e, n);
1958
+ for (const c of t.body)
1959
+ await B(c, e, n);
1960
+ t.update && await B(t.update, e, n);
1822
1961
  }
1823
1962
  return;
1824
1963
  }
1825
1964
  case "do_while": {
1826
1965
  do {
1827
- for (const a of t.body)
1828
- await j(a, e, n);
1829
- const o = await w(t.cond, {
1966
+ for (const c of t.body)
1967
+ await B(c, e, n);
1968
+ const a = await w(t.cond, {
1830
1969
  context: e,
1831
1970
  path: r
1832
1971
  });
1833
- if (pe(o))
1972
+ if (ke(a))
1834
1973
  break;
1835
1974
  } while (!0);
1836
1975
  return;
1837
1976
  }
1838
1977
  }
1839
1978
  }
1840
- async function me(t, e, n = {}) {
1979
+ async function we(t, e, n = {}) {
1841
1980
  for (const r of t)
1842
- await j(r, e, n);
1981
+ await B(r, e, n);
1843
1982
  }
1844
- const St = /* @__PURE__ */ new Set([
1983
+ const Pt = /* @__PURE__ */ new Set([
1845
1984
  "if",
1846
1985
  "else",
1847
1986
  "endif",
@@ -1857,25 +1996,26 @@ const St = /* @__PURE__ */ new Set([
1857
1996
  "extend",
1858
1997
  "include",
1859
1998
  "component",
1860
- "as"
1999
+ "as",
2000
+ "echo"
1861
2001
  ]);
1862
- function Me(t) {
1863
- return St.has(t);
2002
+ function qe(t) {
2003
+ return Pt.has(t);
1864
2004
  }
1865
- function ie(t) {
2005
+ function oe(t) {
1866
2006
  let e = "", n = 0, r = null;
1867
2007
  for (; n < t.length; ) {
1868
- const s = t[n];
2008
+ const i = t[n];
1869
2009
  if (r) {
1870
- if (e += s, s === "\\" && n + 1 < t.length) {
2010
+ if (e += i, i === "\\" && n + 1 < t.length) {
1871
2011
  e += t[++n], n++;
1872
2012
  continue;
1873
2013
  }
1874
- s === r && (r = null), n++;
2014
+ i === r && (r = null), n++;
1875
2015
  continue;
1876
2016
  }
1877
- if (s === '"' || s === "'" || s === "`") {
1878
- r = s, e += s, n++;
2017
+ if (i === '"' || i === "'" || i === "`") {
2018
+ r = i, e += i, n++;
1879
2019
  continue;
1880
2020
  }
1881
2021
  if (t.startsWith("//", n)) {
@@ -1885,42 +2025,42 @@ function ie(t) {
1885
2025
  continue;
1886
2026
  }
1887
2027
  if (t.startsWith("/*", n)) {
1888
- const i = t.indexOf("*/", n + 2);
1889
- if (i === -1)
2028
+ const s = t.indexOf("*/", n + 2);
2029
+ if (s === -1)
1890
2030
  break;
1891
- n = i + 2;
2031
+ n = s + 2;
1892
2032
  continue;
1893
2033
  }
1894
- e += s, n++;
2034
+ e += i, n++;
1895
2035
  }
1896
2036
  return e;
1897
2037
  }
1898
2038
  function k(t, e) {
1899
- throw u({
2039
+ throw d({
1900
2040
  code: "parse_error",
1901
2041
  path: t,
1902
2042
  details: { message: e }
1903
2043
  });
1904
2044
  }
1905
- function ge(t, e) {
1906
- const n = ie(t).trim();
2045
+ function ve(t, e) {
2046
+ const n = oe(t).trim();
1907
2047
  if (n.length === 0)
1908
2048
  throw k(e, "empty statement block");
1909
- const r = new se(n, e), s = r.parseStatementList();
2049
+ const r = new ae(n, e), i = r.parseStatementList();
1910
2050
  if (r.skipWhitespace(), r.hasMore())
1911
2051
  throw k(
1912
2052
  e,
1913
2053
  `unexpected token at position ${r.position}`
1914
2054
  );
1915
- if (s.length === 0)
2055
+ if (i.length === 0)
1916
2056
  throw k(e, "empty statement block");
1917
- return s;
2057
+ return i;
1918
2058
  }
1919
- function Re(t) {
1920
- const e = ie(t).trim();
1921
- return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^for\s*\(/.test(e) || /^do\b/.test(e) || /^(\+\+|--)/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*(\+\+|--|[+\-*/]=|=)/.test(e);
2059
+ function Ve(t) {
2060
+ const e = oe(t).trim();
2061
+ return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^echo\b/.test(e) || /^for\s*\(/.test(e) || /^do\b/.test(e) || /^(\+\+|--)/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*(\+\+|--|[+\-*/]=|=)/.test(e);
1922
2062
  }
1923
- class se {
2063
+ class ae {
1924
2064
  constructor(e, n) {
1925
2065
  this.input = e, this.path = n;
1926
2066
  }
@@ -1953,7 +2093,7 @@ class se {
1953
2093
  this.path,
1954
2094
  "bare while loops are not allowed (use do…while)"
1955
2095
  );
1956
- return this.parseSimpleStatement();
2096
+ return this.matchWord("echo") ? this.parseEcho() : this.parseSimpleStatement();
1957
2097
  }
1958
2098
  parseSimpleStatement() {
1959
2099
  this.skipWhitespace();
@@ -1968,31 +2108,39 @@ class se {
1968
2108
  if (!n)
1969
2109
  throw k(this.path, "expected statement");
1970
2110
  if (this.assertAssignableName(n), this.skipWhitespace(), this.match("++") || this.match("--")) {
1971
- const s = this.input.slice(this.index - 2, this.index);
1972
- return { kind: "update", name: n, op: s, position: "postfix" };
2111
+ const i = this.input.slice(this.index - 2, this.index);
2112
+ return { kind: "update", name: n, op: i, position: "postfix" };
1973
2113
  }
1974
2114
  const r = this.readCompoundOp();
1975
2115
  if (r) {
1976
- const s = this.readExpressionSourceUntilTerminator();
2116
+ const i = this.readExpressionSourceUntilTerminator();
1977
2117
  return {
1978
2118
  kind: "compound_assign",
1979
2119
  name: n,
1980
2120
  op: r,
1981
- expr: C(s, this.path)
2121
+ expr: W(i, this.path)
1982
2122
  };
1983
2123
  }
1984
2124
  if (this.match("=")) {
1985
2125
  if (this.peek() === "=")
1986
2126
  throw k(this.path, "unexpected '==' in assignment");
1987
- const s = this.readExpressionSourceUntilTerminator();
2127
+ const i = this.readExpressionSourceUntilTerminator();
1988
2128
  return {
1989
2129
  kind: "assign",
1990
2130
  name: n,
1991
- expr: C(s, this.path)
2131
+ expr: W(i, this.path)
1992
2132
  };
1993
2133
  }
1994
2134
  throw k(this.path, `invalid statement starting with: ${n}`);
1995
2135
  }
2136
+ parseEcho() {
2137
+ this.skipWhitespace();
2138
+ const e = this.readExpressionSourceUntilTerminator();
2139
+ return {
2140
+ kind: "echo",
2141
+ expr: W(e, this.path)
2142
+ };
2143
+ }
1996
2144
  readPrefixUpdate() {
1997
2145
  if (this.skipWhitespace(), this.match("++") || this.match("--")) {
1998
2146
  const e = this.input.slice(this.index - 2, this.index), n = this.readIdentifier();
@@ -2012,27 +2160,27 @@ class se {
2012
2160
  return {
2013
2161
  kind: e,
2014
2162
  name: n,
2015
- expr: C(r, this.path)
2163
+ expr: W(r, this.path)
2016
2164
  };
2017
2165
  }
2018
2166
  parseFor() {
2019
2167
  if (this.skipWhitespace(), !this.match("("))
2020
2168
  throw k(this.path, "expected '(' after for");
2021
- const e = this.readBalanced(")"), n = Ct(e);
2169
+ const e = this.readBalanced(")"), n = It(e);
2022
2170
  if (n.length !== 3)
2023
2171
  throw k(
2024
2172
  this.path,
2025
2173
  "for…of / for…in are not allowed; use for (init; cond; update)"
2026
2174
  );
2027
- const [r, s, i] = n;
2028
- if (s.trim().length === 0)
2175
+ const [r, i, s] = n;
2176
+ if (i.trim().length === 0)
2029
2177
  throw k(this.path, "for loop condition cannot be empty");
2030
2178
  if (/^\s*[A-Za-z_$][A-Za-z0-9_$]*\s+(of|in)\s+/.test(r))
2031
2179
  throw k(
2032
2180
  this.path,
2033
2181
  "for…of / for…in are not allowed; use for (init; cond; update)"
2034
2182
  );
2035
- const o = r.trim().length === 0 ? null : this.parseClauseStatement(r.trim()), a = C(s.trim(), this.path), c = i.trim().length === 0 ? null : this.parseClauseStatement(i.trim());
2183
+ const o = r.trim().length === 0 ? null : this.parseClauseStatement(r.trim()), a = W(i.trim(), this.path), c = s.trim().length === 0 ? null : this.parseClauseStatement(s.trim());
2036
2184
  if (this.skipWhitespace(), !this.match("{"))
2037
2185
  throw k(this.path, "expected '{' after for (...)");
2038
2186
  const h = this.parseStatementList();
@@ -2053,11 +2201,11 @@ class se {
2053
2201
  const n = this.readBalanced(")");
2054
2202
  if (n.trim().length === 0)
2055
2203
  throw k(this.path, "do…while condition cannot be empty");
2056
- const r = C(n.trim(), this.path);
2204
+ const r = W(n.trim(), this.path);
2057
2205
  return { kind: "do_while", body: e, cond: r };
2058
2206
  }
2059
2207
  parseClauseStatement(e) {
2060
- const n = new se(e, this.path), r = n.parseSimpleStatement();
2208
+ const n = new ae(e, this.path), r = n.parseSimpleStatement();
2061
2209
  if (n.skipWhitespace(), n.hasMore())
2062
2210
  throw k(
2063
2211
  this.path,
@@ -2066,7 +2214,7 @@ class se {
2066
2214
  return r;
2067
2215
  }
2068
2216
  assertAssignableName(e) {
2069
- if (Me(e))
2217
+ if (qe(e))
2070
2218
  throw k(
2071
2219
  this.path,
2072
2220
  `reserved word cannot be used as identifier: ${e}`
@@ -2075,28 +2223,28 @@ class se {
2075
2223
  readExpressionSourceUntilTerminator() {
2076
2224
  this.skipWhitespace();
2077
2225
  const e = this.index;
2078
- let n = 0, r = 0, s = 0, i = null;
2226
+ let n = 0, r = 0, i = 0, s = null;
2079
2227
  for (; this.index < this.input.length; ) {
2080
2228
  const a = this.input[this.index];
2081
- if (i) {
2229
+ if (s) {
2082
2230
  if (a === "\\") {
2083
2231
  this.index += 2;
2084
2232
  continue;
2085
2233
  }
2086
- a === i && (i = null), this.index++;
2234
+ a === s && (s = null), this.index++;
2087
2235
  continue;
2088
2236
  }
2089
2237
  if (a === '"' || a === "'" || a === "`") {
2090
- i = a, this.index++;
2238
+ s = a, this.index++;
2091
2239
  continue;
2092
2240
  }
2093
2241
  if (a === "(" && n++, a === ")" && (n = Math.max(0, n - 1)), a === "{" && r++, a === "}") {
2094
- if (r === 0 && n === 0 && s === 0)
2242
+ if (r === 0 && n === 0 && i === 0)
2095
2243
  break;
2096
2244
  r = Math.max(0, r - 1);
2097
2245
  }
2098
- if (a === "[" && s++, a === "]" && (s = Math.max(0, s - 1)), (a === ";" || a === `
2099
- `) && n === 0 && r === 0 && s === 0)
2246
+ if (a === "[" && i++, a === "]" && (i = Math.max(0, i - 1)), (a === ";" || a === `
2247
+ `) && n === 0 && r === 0 && i === 0)
2100
2248
  break;
2101
2249
  this.index++;
2102
2250
  }
@@ -2108,20 +2256,20 @@ class se {
2108
2256
  readBalanced(e) {
2109
2257
  const n = e === ")" ? "(" : "{";
2110
2258
  let r = 1;
2111
- const s = this.index;
2112
- let i = null;
2259
+ const i = this.index;
2260
+ let s = null;
2113
2261
  for (; this.index < this.input.length; ) {
2114
2262
  const o = this.input[this.index];
2115
- if (i) {
2263
+ if (s) {
2116
2264
  if (o === "\\") {
2117
2265
  this.index += 2;
2118
2266
  continue;
2119
2267
  }
2120
- o === i && (i = null), this.index++;
2268
+ o === s && (s = null), this.index++;
2121
2269
  continue;
2122
2270
  }
2123
2271
  if (o === '"' || o === "'" || o === "`") {
2124
- i = o, this.index++;
2272
+ s = o, this.index++;
2125
2273
  continue;
2126
2274
  }
2127
2275
  if (o === n) {
@@ -2130,7 +2278,7 @@ class se {
2130
2278
  }
2131
2279
  if (o === e) {
2132
2280
  if (r--, r === 0) {
2133
- const a = this.input.slice(s, this.index);
2281
+ const a = this.input.slice(i, this.index);
2134
2282
  return this.index++, a;
2135
2283
  }
2136
2284
  this.index++;
@@ -2173,21 +2321,21 @@ class se {
2173
2321
  return this.input.slice(e, this.index);
2174
2322
  }
2175
2323
  }
2176
- function Ct(t) {
2324
+ function It(t) {
2177
2325
  const e = [];
2178
- let n = "", r = 0, s = null;
2179
- for (let i = 0; i < t.length; i++) {
2180
- const o = t[i];
2181
- if (s) {
2182
- if (n += o, o === "\\" && i + 1 < t.length) {
2183
- n += t[++i];
2326
+ let n = "", r = 0, i = null;
2327
+ for (let s = 0; s < t.length; s++) {
2328
+ const o = t[s];
2329
+ if (i) {
2330
+ if (n += o, o === "\\" && s + 1 < t.length) {
2331
+ n += t[++s];
2184
2332
  continue;
2185
2333
  }
2186
- o === s && (s = null);
2334
+ o === i && (i = null);
2187
2335
  continue;
2188
2336
  }
2189
2337
  if (o === '"' || o === "'" || o === "`") {
2190
- s = o, n += o;
2338
+ i = o, n += o;
2191
2339
  continue;
2192
2340
  }
2193
2341
  if (o === "(" || o === "[" || o === "{") {
@@ -2206,146 +2354,185 @@ function Ct(t) {
2206
2354
  }
2207
2355
  return e.push(n), e;
2208
2356
  }
2209
- function oe(t, e) {
2357
+ function ce(t, e) {
2210
2358
  const n = t.trim();
2211
2359
  if (!/^extend\b/i.test(n)) return null;
2212
2360
  if (!/^extend\s+/i.test(n))
2213
- throw u({
2361
+ throw d({
2214
2362
  code: "parse_error",
2215
2363
  path: e,
2216
2364
  details: { message: "missing extend path" }
2217
2365
  });
2218
2366
  const r = /^extend\s+(\S+)\s*$/.exec(n);
2219
2367
  if (!r)
2220
- throw u({
2368
+ throw d({
2221
2369
  code: "parse_error",
2222
2370
  path: e,
2223
2371
  details: { message: "invalid extend directive" }
2224
2372
  });
2225
- const s = r[1];
2226
- if (s.length === 0)
2227
- throw u({
2373
+ const i = r[1];
2374
+ if (i.length === 0)
2375
+ throw d({
2228
2376
  code: "parse_error",
2229
2377
  path: e,
2230
2378
  details: { message: "invalid extend path" }
2231
2379
  });
2232
- return { path: s };
2380
+ return { path: i };
2233
2381
  }
2234
- function At(t, e) {
2235
- const n = E(t);
2382
+ function zt(t, e) {
2383
+ const n = A(t);
2236
2384
  if (n.length === 0) return null;
2237
- const r = n[0], s = oe(r, e);
2238
- if (!s) return null;
2239
- for (const i of n.slice(1))
2240
- if (/^extend\s+/i.test(i))
2241
- throw u({
2385
+ const r = n[0], i = ce(r, e);
2386
+ if (!i) return null;
2387
+ for (const s of n.slice(1))
2388
+ if (/^extend\s+/i.test(s))
2389
+ throw d({
2242
2390
  code: "parse_error",
2243
2391
  path: e,
2244
2392
  details: { message: "extend must be the first line of extend block" }
2245
2393
  });
2246
2394
  return {
2247
- path: s.path,
2395
+ path: i.path,
2248
2396
  declarationsSource: n.slice(1).join(`
2249
2397
  `)
2250
2398
  };
2251
2399
  }
2252
- async function Wt(t, e = {}) {
2400
+ function le(t) {
2401
+ return /^toc(\(.*\))?$/.test(t.trim());
2402
+ }
2403
+ function Ut(t, e) {
2404
+ const n = A(t);
2405
+ if (n.length !== 1)
2406
+ throw d({
2407
+ code: "parse_error",
2408
+ path: e,
2409
+ details: {
2410
+ message: "toc directive must be a single line"
2411
+ }
2412
+ });
2413
+ const r = n[0];
2414
+ if (r === "toc")
2415
+ return { maxLevel: 6 };
2416
+ const i = /^toc\((.*)\)$/.exec(r);
2417
+ if (!i)
2418
+ throw d({
2419
+ code: "parse_error",
2420
+ path: e,
2421
+ details: { message: `invalid toc directive: ${r}` }
2422
+ });
2423
+ const s = i[1];
2424
+ if (!/^[1-6]$/.test(s))
2425
+ throw d({
2426
+ code: "parse_error",
2427
+ path: e,
2428
+ details: {
2429
+ message: `invalid toc max level: ${s || "(empty)"} (expected integer 1–6)`
2430
+ }
2431
+ });
2432
+ return { maxLevel: Number(s) };
2433
+ }
2434
+ async function Zt(t, e = {}) {
2253
2435
  const n = e.path, r = e.context ?? {};
2254
- if (Se(t))
2255
- throw u({
2436
+ if (Be(t))
2437
+ throw d({
2256
2438
  code: "parse_error",
2257
2439
  path: n,
2258
2440
  details: {
2259
- message: Ce(t) ?? "unclosed hyogen block (missing closing marker)"
2441
+ message: Fe(t) ?? "unclosed hyogen block (missing closing marker)"
2260
2442
  }
2261
2443
  });
2262
- const s = T(t);
2263
- if (s.length === 0)
2444
+ const i = E(t);
2445
+ if (i.length === 0)
2264
2446
  return { source: t, context: r, declarationUpdates: {} };
2265
- const i = /* @__PURE__ */ new Set(), o = {}, a = (l) => {
2447
+ const s = /* @__PURE__ */ new Set(), o = {}, a = (l) => {
2266
2448
  o[l] = r[l];
2267
2449
  };
2268
2450
  let c = t, h = 0;
2269
- for (const l of s) {
2270
- const d = E(l.inner);
2271
- if (d.length === 1 && Ae(d[0]) || d.length === 1 && /^include\s+/i.test(d[0]) || d.length === 1 && /^component\s+/i.test(d[0]))
2451
+ for (const l of i) {
2452
+ const u = A(l.inner);
2453
+ if (u.length === 1 && je(u[0]) || u.length === 1 && le(u[0]) || u.length === 1 && /^include\s+/i.test(u[0]) || u.length === 1 && /^component\s+/i.test(u[0]))
2272
2454
  continue;
2273
- const f = At(l.inner, n);
2455
+ const f = zt(l.inner, n);
2274
2456
  if (f) {
2275
2457
  if (f.declarationsSource.trim().length > 0) {
2276
- const P = ge(
2458
+ const N = ve(
2277
2459
  f.declarationsSource,
2278
2460
  n
2279
2461
  );
2280
- await me(P, r, {
2462
+ await we(N, r, {
2281
2463
  path: n,
2282
- constBindings: i,
2464
+ constBindings: s,
2283
2465
  onUpdate: a
2284
2466
  });
2285
2467
  }
2286
- const v = l.start - h, W = l.end - h, $ = `<!--@hg
2468
+ const C = l.start - h, L = l.end - h, j = `<!--@hg
2287
2469
  extend ${f.path}
2288
2470
  @endhg-->`;
2289
- c = c.slice(0, v) + $ + c.slice(W), h += l.raw.length - $.length;
2471
+ c = c.slice(0, C) + j + c.slice(L), h += l.raw.length - j.length;
2290
2472
  continue;
2291
2473
  }
2292
- const g = d.join(`
2474
+ const g = u.join(`
2293
2475
  `);
2294
- if (!Re(g)) {
2295
- if (d.length === 1)
2476
+ if (!Ve(g)) {
2477
+ if (u.length === 1)
2296
2478
  continue;
2297
- throw u({
2479
+ throw d({
2298
2480
  code: "parse_error",
2299
2481
  path: n,
2300
- details: { message: `unsupported hyogen directive: ${d[0]}` }
2482
+ details: { message: `unsupported hyogen directive: ${u[0]}` }
2301
2483
  });
2302
2484
  }
2303
- const m = ge(g, n);
2304
- await me(m, r, {
2485
+ const m = ve(g, n), p = [];
2486
+ await we(m, r, {
2305
2487
  path: n,
2306
- constBindings: i,
2307
- onUpdate: a
2488
+ constBindings: s,
2489
+ onUpdate: a,
2490
+ echoChunks: p
2308
2491
  });
2309
- const p = l.start - h, A = l.end - h, L = c.slice(0, p), b = c.slice(A);
2310
- c = D(L, b), h += l.raw.length + re(L, b);
2492
+ const S = l.start - h, D = l.end - h, v = c.slice(0, S), b = c.slice(D);
2493
+ if (p.length > 0) {
2494
+ const C = p.join("");
2495
+ c = v + C + b, h += l.raw.length - C.length;
2496
+ } else
2497
+ c = T(v, b), h += l.raw.length + se(v, b);
2311
2498
  }
2312
2499
  return { source: c, context: r, declarationUpdates: o };
2313
2500
  }
2314
- const $t = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
2315
- function Tt(t, e) {
2316
- const n = Q(t).trim();
2501
+ const qt = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
2502
+ function Vt(t, e) {
2503
+ const n = te(t).trim();
2317
2504
  if (n.length === 0)
2318
- throw u({
2505
+ throw d({
2319
2506
  code: "parse_error",
2320
2507
  path: e,
2321
2508
  details: { message: "empty hyogen block" }
2322
2509
  });
2323
2510
  const r = n.split(/\r?\n/).map((a) => a.trim()).filter((a) => a.length > 0);
2324
2511
  if (r.length !== 1)
2325
- throw u({
2512
+ throw d({
2326
2513
  code: "parse_error",
2327
2514
  path: e,
2328
2515
  details: {
2329
2516
  message: "hyogen block must contain a single component directive"
2330
2517
  }
2331
2518
  });
2332
- const s = r[0];
2333
- if (/^include\s+/i.test(s))
2334
- throw u({
2519
+ const i = r[0];
2520
+ if (/^include\s+/i.test(i))
2521
+ throw d({
2335
2522
  code: "parse_error",
2336
2523
  path: e,
2337
2524
  details: { message: "include and component cannot coexist in one block" }
2338
2525
  });
2339
- const i = $t.exec(s);
2340
- if (!i)
2341
- throw u({
2526
+ const s = qt.exec(i);
2527
+ if (!s)
2528
+ throw d({
2342
2529
  code: "parse_error",
2343
2530
  path: e,
2344
- details: { message: `unsupported component directive: ${s}` }
2531
+ details: { message: `unsupported component directive: ${i}` }
2345
2532
  });
2346
- const o = i[1];
2533
+ const o = s[1];
2347
2534
  if (o.length === 0)
2348
- throw u({
2535
+ throw d({
2349
2536
  code: "parse_error",
2350
2537
  path: e,
2351
2538
  details: { message: "empty component path" }
@@ -2353,92 +2540,92 @@ function Tt(t, e) {
2353
2540
  return {
2354
2541
  kind: "component",
2355
2542
  path: o,
2356
- alias: i[2]
2543
+ alias: s[2]
2357
2544
  };
2358
2545
  }
2359
- function Et(t, e) {
2360
- const n = Q(t).trim();
2546
+ function Kt(t, e) {
2547
+ const n = te(t).trim();
2361
2548
  if (n.length === 0)
2362
- throw u({
2549
+ throw d({
2363
2550
  code: "parse_error",
2364
2551
  path: e,
2365
2552
  details: { message: "empty hyogen block" }
2366
2553
  });
2367
2554
  const r = n.split(/\r?\n/).map((o) => o.trim()).filter((o) => o.length > 0);
2368
2555
  if (r.length !== 1)
2369
- throw u({
2556
+ throw d({
2370
2557
  code: "parse_error",
2371
2558
  path: e,
2372
2559
  details: { message: "hyogen block must contain a single include directive" }
2373
2560
  });
2374
- const s = r[0], i = /^include\s+(\S+)\s*$/.exec(s);
2375
- if (i)
2376
- return { kind: "include", path: i[1] };
2377
- throw u({
2561
+ const i = r[0], s = /^include\s+(\S+)\s*$/.exec(i);
2562
+ if (s)
2563
+ return { kind: "include", path: s[1] };
2564
+ throw d({
2378
2565
  code: "parse_error",
2379
2566
  path: e,
2380
- details: { message: `unsupported hyogen directive: ${s}` }
2567
+ details: { message: `unsupported hyogen directive: ${i}` }
2381
2568
  });
2382
2569
  }
2383
- function Lt(t) {
2384
- const e = ie(t).trim();
2570
+ function Yt(t) {
2571
+ const e = oe(t).trim();
2385
2572
  return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(e);
2386
2573
  }
2387
- const Mt = "\0HYOGEN_INCLUDE_";
2388
- function Rt(t) {
2389
- return `${Mt}${t}\0`;
2574
+ const Xt = "\0HYOGEN_INCLUDE_";
2575
+ function Gt(t) {
2576
+ return `${Xt}${t}\0`;
2390
2577
  }
2391
- function Ot(t, e) {
2392
- const n = E(t);
2393
- if (n.length === 1 && Ae(n[0]))
2578
+ function Jt(t, e) {
2579
+ const n = A(t);
2580
+ if (n.length === 1 && je(n[0]))
2394
2581
  return { kind: "control" };
2395
- if (n.length === 1 && (Lt(n[0]) || Re(n[0])))
2582
+ if (n.length === 1 && le(n[0]) || n.length === 1 && (Yt(n[0]) || Ve(n[0])))
2396
2583
  return null;
2397
2584
  if (n.length !== 1)
2398
- throw u({
2585
+ throw d({
2399
2586
  code: "parse_error",
2400
2587
  path: e,
2401
2588
  details: { message: "hyogen block must contain a single directive" }
2402
2589
  });
2403
2590
  const r = n[0];
2404
2591
  if (/^include\s+/i.test(r) && /\bcomponent\s+/i.test(r))
2405
- throw u({
2592
+ throw d({
2406
2593
  code: "parse_error",
2407
2594
  path: e,
2408
2595
  details: { message: "include and component cannot coexist in one block" }
2409
2596
  });
2410
2597
  if (/^include\s+/i.test(r))
2411
- return Et(t, e);
2598
+ return Kt(t, e);
2412
2599
  if (/^component\s+/i.test(r))
2413
- return Tt(t, e);
2600
+ return Vt(t, e);
2414
2601
  if (r === "endblock" || /^block\s+/.test(r) || /^extend\s+/.test(r))
2415
2602
  return null;
2416
- throw u({
2603
+ throw d({
2417
2604
  code: "parse_error",
2418
2605
  path: e,
2419
2606
  details: { message: `unsupported hyogen directive: ${r}` }
2420
2607
  });
2421
2608
  }
2422
- function Dt(t, e = {}) {
2609
+ function Qt(t, e = {}) {
2423
2610
  const n = e.path;
2424
- if (Se(t))
2425
- throw u({
2611
+ if (Be(t))
2612
+ throw d({
2426
2613
  code: "parse_error",
2427
2614
  path: n,
2428
2615
  details: {
2429
- message: Ce(t) ?? "unclosed hyogen block (missing closing marker)"
2616
+ message: Fe(t) ?? "unclosed hyogen block (missing closing marker)"
2430
2617
  }
2431
2618
  });
2432
- const r = T(t);
2619
+ const r = E(t);
2433
2620
  if (r.length === 0)
2434
2621
  return { source: t, directives: [] };
2435
- const s = [];
2436
- let i = t, o = 0, a = 0;
2622
+ const i = [];
2623
+ let s = t, o = 0, a = 0;
2437
2624
  for (const c of r) {
2438
- const h = Ot(c.inner, n);
2625
+ const h = Jt(c.inner, n);
2439
2626
  if (!h || h.kind === "control")
2440
2627
  continue;
2441
- const l = c.start - o, d = c.end - o;
2628
+ const l = c.start - o, u = c.end - o;
2442
2629
  if (h.kind === "component") {
2443
2630
  e.registry && e.registry.register(
2444
2631
  {
@@ -2449,74 +2636,74 @@ function Dt(t, e = {}) {
2449
2636
  Object.keys(e.context ?? {}),
2450
2637
  n
2451
2638
  );
2452
- const g = i.slice(0, l), m = i.slice(d);
2453
- i = D(g, m), o += c.raw.length + re(g, m);
2639
+ const g = s.slice(0, l), m = s.slice(u);
2640
+ s = T(g, m), o += c.raw.length + se(g, m);
2454
2641
  continue;
2455
2642
  }
2456
- const f = Rt(a++);
2457
- s.push({ ...h, marker: f, raw: c.raw }), i = i.slice(0, l) + f + i.slice(d), o += c.raw.length - f.length;
2643
+ const f = Gt(a++);
2644
+ i.push({ ...h, marker: f, raw: c.raw }), s = s.slice(0, l) + f + s.slice(u), o += c.raw.length - f.length;
2458
2645
  }
2459
- return { source: i, directives: s };
2646
+ return { source: s, directives: i };
2460
2647
  }
2461
- function jt(t, e) {
2648
+ function en(t, e) {
2462
2649
  return !e.preserveFrontMatter || !e.rawFrontMatter ? t : t.length === 0 ? `${e.rawFrontMatter}
2463
2650
  ` : `${e.rawFrontMatter}
2464
2651
  ${t}`;
2465
2652
  }
2466
- function Bt(t, e = !1) {
2653
+ function tn(t, e = !1) {
2467
2654
  if (e)
2468
2655
  return t;
2469
- const n = T(t);
2656
+ const n = E(t);
2470
2657
  if (n.length === 0)
2471
2658
  return t;
2472
- let r = t, s = 0;
2473
- for (const i of n) {
2474
- const o = i.start - s, a = i.end - s, c = r.slice(0, o), h = r.slice(a);
2475
- r = D(c, h), s += i.raw.length + re(c, h);
2659
+ let r = t, i = 0;
2660
+ for (const s of n) {
2661
+ const o = s.start - i, a = s.end - i, c = r.slice(0, o), h = r.slice(a);
2662
+ r = T(c, h), i += s.raw.length + se(c, h);
2476
2663
  }
2477
2664
  return r;
2478
2665
  }
2479
- const Nt = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
2480
- function Ht(t, e) {
2666
+ const nn = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
2667
+ function rn(t, e) {
2481
2668
  const n = t.trim();
2482
2669
  if (n === "endblock")
2483
2670
  return { kind: "endblock" };
2484
- const r = Nt.exec(n);
2671
+ const r = nn.exec(n);
2485
2672
  if (!r)
2486
- throw u({
2673
+ throw d({
2487
2674
  code: "parse_error",
2488
2675
  path: e,
2489
2676
  details: { message: "invalid block directive" }
2490
2677
  });
2491
- const s = r[1];
2492
- if (Me(s))
2493
- throw u({
2678
+ const i = r[1];
2679
+ if (qe(i))
2680
+ throw d({
2494
2681
  code: "parse_error",
2495
2682
  path: e,
2496
- details: { message: `reserved word cannot be used as block name: ${s}` }
2683
+ details: { message: `reserved word cannot be used as block name: ${i}` }
2497
2684
  });
2498
- return { kind: "block", name: s };
2685
+ return { kind: "block", name: i };
2499
2686
  }
2500
- function xe(t, e) {
2501
- const { path: n, mode: r, hasExtend: s = !1 } = e, i = T(t);
2502
- if (i.length === 0) return [];
2687
+ function be(t, e) {
2688
+ const { path: n, mode: r, hasExtend: i = !1 } = e, s = E(t);
2689
+ if (s.length === 0) return [];
2503
2690
  const o = [], a = [], c = /* @__PURE__ */ new Set();
2504
- for (const h of i) {
2505
- const l = E(h.inner);
2691
+ for (const h of s) {
2692
+ const l = A(h.inner);
2506
2693
  if (l.length !== 1) continue;
2507
- const d = l[0];
2508
- if (!(d === "endblock" || d.startsWith("block "))) continue;
2509
- if (r === "child" && !s)
2510
- throw u({
2694
+ const u = l[0];
2695
+ if (!(u === "endblock" || u.startsWith("block "))) continue;
2696
+ if (r === "child" && !i)
2697
+ throw d({
2511
2698
  code: "parse_error",
2512
2699
  path: n,
2513
2700
  details: { message: "orphan block without extend" }
2514
2701
  });
2515
- const g = Ht(d, n);
2702
+ const g = rn(u, n);
2516
2703
  if (g.kind === "endblock") {
2517
2704
  const m = a.pop();
2518
2705
  if (!m)
2519
- throw u({
2706
+ throw d({
2520
2707
  code: "parse_error",
2521
2708
  path: n,
2522
2709
  details: { message: "endblock without matching block opener" }
@@ -2531,13 +2718,13 @@ function xe(t, e) {
2531
2718
  continue;
2532
2719
  }
2533
2720
  if (a.length > 0)
2534
- throw u({
2721
+ throw d({
2535
2722
  code: "parse_error",
2536
2723
  path: n,
2537
2724
  details: { message: "nested block structures are not supported" }
2538
2725
  });
2539
2726
  if (c.has(g.name))
2540
- throw u({
2727
+ throw d({
2541
2728
  code: "parse_error",
2542
2729
  path: n,
2543
2730
  details: { message: `duplicate block: ${g.name}` }
@@ -2549,44 +2736,44 @@ function xe(t, e) {
2549
2736
  });
2550
2737
  }
2551
2738
  if (a.length > 0)
2552
- throw u({
2739
+ throw d({
2553
2740
  code: "parse_error",
2554
2741
  path: n,
2555
2742
  details: { message: "missing endblock" }
2556
2743
  });
2557
2744
  return o;
2558
2745
  }
2559
- function ke(t) {
2560
- const e = T(t), n = [];
2746
+ function ye(t) {
2747
+ const e = E(t), n = [];
2561
2748
  for (const r of e) {
2562
- const s = E(r.inner);
2563
- if (s.length === 0) continue;
2564
- const i = oe(s[0]);
2565
- i && n.push({ path: i.path, start: r.start });
2749
+ const i = A(r.inner);
2750
+ if (i.length === 0) continue;
2751
+ const s = ce(i[0]);
2752
+ s && n.push({ path: s.path, start: r.start });
2566
2753
  }
2567
2754
  return n;
2568
2755
  }
2569
- function Pt(t) {
2570
- const e = T(t);
2756
+ function sn(t) {
2757
+ const e = E(t);
2571
2758
  for (const n of e) {
2572
- const r = E(n.inner);
2759
+ const r = A(n.inner);
2573
2760
  if (r.length !== 1) continue;
2574
- const s = r[0];
2575
- if (s === "endblock" || s.startsWith("block ")) return !0;
2761
+ const i = r[0];
2762
+ if (i === "endblock" || i.startsWith("block ")) return !0;
2576
2763
  }
2577
2764
  return !1;
2578
2765
  }
2579
- function K(t) {
2766
+ function Y(t) {
2580
2767
  return t.map((e) => e.body).join("");
2581
2768
  }
2582
- function Ft(t, e, n) {
2583
- const r = [...e].sort((o, a) => o.start - a.start), s = [];
2584
- let i = 0;
2769
+ function on(t, e, n) {
2770
+ const r = [...e].sort((o, a) => o.start - a.start), i = [];
2771
+ let s = 0;
2585
2772
  for (const o of r)
2586
- s.push(t.slice(i, o.start)), s.push(n.get(o.name) ?? o.body), i = o.end;
2587
- return s.push(t.slice(i)), s.reduce((o, a) => D(o, a));
2773
+ i.push(t.slice(s, o.start)), i.push(n.get(o.name) ?? o.body), s = o.end;
2774
+ return i.push(t.slice(s)), i.reduce((o, a) => T(o, a));
2588
2775
  }
2589
- function It(t) {
2776
+ function an(t) {
2590
2777
  if (t instanceof Error && "code" in t && "details" in t) {
2591
2778
  const e = t;
2592
2779
  if (e.code === "file_not_found" && e.details && e.details.via === "include")
@@ -2594,46 +2781,46 @@ function It(t) {
2594
2781
  }
2595
2782
  return { errorToThrow: t, adjusted: !1 };
2596
2783
  }
2597
- async function zt(t, e) {
2784
+ async function cn(t, e) {
2598
2785
  const {
2599
2786
  path: n,
2600
2787
  context: r,
2601
- declarationUpdates: s,
2602
- loader: i,
2788
+ declarationUpdates: i,
2789
+ loader: s,
2603
2790
  root: o,
2604
2791
  constrainToRoot: a,
2605
2792
  visitStack: c,
2606
2793
  warnings: h,
2607
2794
  inComponent: l = !1
2608
- } = e, d = ke(t);
2609
- if (d.length === 0) {
2610
- if (Pt(t))
2611
- throw u({
2795
+ } = e, u = ye(t);
2796
+ if (u.length === 0) {
2797
+ if (sn(t))
2798
+ throw d({
2612
2799
  code: "parse_error",
2613
2800
  path: n,
2614
2801
  details: { message: "orphan block without extend" }
2615
2802
  });
2616
- return { source: t, context: _(r, s) };
2803
+ return { source: t, context: _(r, i) };
2617
2804
  }
2618
- const g = T(t)[0];
2805
+ const g = E(t)[0];
2619
2806
  if (!g)
2620
- return { source: t, context: _(r, s) };
2621
- if (!i)
2807
+ return { source: t, context: _(r, i) };
2808
+ if (!s)
2622
2809
  throw new Error("loader is required when processing extend directives");
2623
- const m = E(g.inner);
2624
- if (!(m.length > 0 ? oe(m[0]) : null))
2625
- throw u({
2810
+ const m = A(g.inner);
2811
+ if (!(m.length > 0 ? ce(m[0]) : null))
2812
+ throw d({
2626
2813
  code: "parse_error",
2627
2814
  path: n,
2628
2815
  details: { message: "extend must be the first hyogen block" }
2629
2816
  });
2630
- if (d.length > 1)
2631
- throw u({
2817
+ if (u.length > 1)
2818
+ throw d({
2632
2819
  code: "parse_error",
2633
2820
  path: n,
2634
2821
  details: { message: "multiple extend directives are not supported" }
2635
2822
  });
2636
- const A = xe(t, {
2823
+ const S = be(t, {
2637
2824
  path: n,
2638
2825
  mode: "child",
2639
2826
  hasExtend: !0
@@ -2641,102 +2828,102 @@ async function zt(t, e) {
2641
2828
  if (l)
2642
2829
  return h?.push({
2643
2830
  code: "extend_in_component",
2644
- message: O("extend_in_component", { path: n }),
2831
+ message: H("extend_in_component", { path: n }),
2645
2832
  path: n,
2646
2833
  details: { path: n }
2647
2834
  }), {
2648
- source: K(A),
2649
- context: _(r, s)
2835
+ source: Y(S),
2836
+ context: _(r, i)
2650
2837
  };
2651
- const L = d[0].path, b = n, v = Y(
2838
+ const D = u[0].path, v = n, b = X(
2652
2839
  o,
2653
- L,
2840
+ D,
2654
2841
  n,
2655
2842
  n,
2656
2843
  a,
2657
2844
  !0
2658
2845
  );
2659
- b && c.push(b);
2846
+ v && c.push(v);
2660
2847
  try {
2661
- const W = b ? c.check(v) : { circular: !1 };
2662
- if (W.circular)
2848
+ const C = v ? c.check(b) : { circular: !1 };
2849
+ if (C.circular)
2663
2850
  return h?.push({
2664
2851
  code: "circular_include",
2665
- message: O("circular_include", {
2666
- path: v,
2667
- from: W.from,
2852
+ message: H("circular_include", {
2853
+ path: b,
2854
+ from: C.from,
2668
2855
  via: "extend"
2669
2856
  }),
2670
2857
  path: n,
2671
- details: { path: v, from: W.from, via: "extend" }
2858
+ details: { path: b, from: C.from, via: "extend" }
2672
2859
  }), {
2673
- source: K(A),
2674
- context: _(r, s)
2860
+ source: Y(S),
2861
+ context: _(r, i)
2675
2862
  };
2676
- c.push(v);
2863
+ c.push(b);
2677
2864
  try {
2678
- const $ = await i(v);
2679
- if ($ === void 0)
2865
+ const L = await s(b);
2866
+ if (L === void 0)
2680
2867
  throw new Error("loader returned undefined");
2681
- const { context: P, body: F } = H(
2682
- $,
2683
- v
2684
- ), ce = ke(F);
2685
- if (ce.length > 0) {
2686
- const N = ce[0].path, I = Y(
2868
+ const { context: j, body: N } = I(
2869
+ L,
2870
+ b
2871
+ ), ue = ye(N);
2872
+ if (ue.length > 0) {
2873
+ const P = ue[0].path, z = X(
2687
2874
  o,
2688
- N,
2689
- v,
2690
- v,
2875
+ P,
2876
+ b,
2877
+ b,
2691
2878
  a,
2692
2879
  !0
2693
- ), z = c.check(I);
2694
- if (z.circular)
2880
+ ), U = c.check(z);
2881
+ if (U.circular)
2695
2882
  return h?.push({
2696
2883
  code: "circular_include",
2697
- message: O("circular_include", {
2698
- path: I,
2699
- from: z.from,
2884
+ message: H("circular_include", {
2885
+ path: z,
2886
+ from: U.from,
2700
2887
  via: "extend"
2701
2888
  }),
2702
2889
  path: n,
2703
- details: { path: I, from: z.from, via: "extend" }
2890
+ details: { path: z, from: U.from, via: "extend" }
2704
2891
  }), {
2705
- source: K(A),
2706
- context: _(r, s)
2892
+ source: Y(S),
2893
+ context: _(r, i)
2707
2894
  };
2708
- throw u({
2895
+ throw d({
2709
2896
  code: "parse_error",
2710
- path: v,
2897
+ path: b,
2711
2898
  details: { message: "layout extend is not supported" }
2712
2899
  });
2713
2900
  }
2714
- const Oe = xe(F, {
2715
- path: v,
2901
+ const Ke = be(N, {
2902
+ path: b,
2716
2903
  mode: "layout"
2717
- }), De = new Map(
2718
- A.map((N) => [N.name, N.body])
2719
- ), je = Ft(
2720
- F,
2721
- Oe,
2722
- De
2723
- ), Be = _(
2904
+ }), Ye = new Map(
2905
+ S.map((P) => [P.name, P.body])
2906
+ ), Xe = on(
2907
+ N,
2908
+ Ke,
2909
+ Ye
2910
+ ), Ge = _(
2724
2911
  r,
2725
- P,
2726
- s
2912
+ j,
2913
+ i
2727
2914
  );
2728
- return { source: je, context: Be };
2915
+ return { source: Xe, context: Ge };
2729
2916
  } finally {
2730
2917
  c.pop();
2731
2918
  }
2732
- } catch (W) {
2733
- const $ = It(W);
2734
- throw $.adjusted ? $.errorToThrow : W;
2919
+ } catch (C) {
2920
+ const L = an(C);
2921
+ throw L.adjusted ? L.errorToThrow : C;
2735
2922
  } finally {
2736
- b && c.pop();
2923
+ v && c.pop();
2737
2924
  }
2738
2925
  }
2739
- const Ut = J.warningReasons, Zt = [
2926
+ const ln = Q.warningReasons, hn = [
2740
2927
  {
2741
2928
  reason: "contains_html_script_tag",
2742
2929
  test: (t) => /<\/?script\b/i.test(t)
@@ -2758,53 +2945,208 @@ const Ut = J.warningReasons, Zt = [
2758
2945
  test: (t) => /<meta\b[^>]*\bhttp-equiv\b/i.test(t)
2759
2946
  }
2760
2947
  ];
2761
- function qt(t) {
2762
- return Ut[t] ?? t;
2948
+ function un(t) {
2949
+ return ln[t] ?? t;
2763
2950
  }
2764
2951
  function G(t, e, n, r) {
2765
2952
  if (typeof t == "string") {
2766
- for (const s of Zt)
2767
- s.test(t) && n.push({
2953
+ for (const i of hn)
2954
+ i.test(t) && n.push({
2768
2955
  code: "suspicious_context_value",
2769
- message: O("suspicious_context_value", {
2956
+ message: H("suspicious_context_value", {
2770
2957
  key: e,
2771
- reason: qt(s.reason)
2958
+ reason: un(i.reason)
2772
2959
  }),
2773
2960
  path: r,
2774
- details: { key: e, reason: s.reason }
2961
+ details: { key: e, reason: i.reason }
2775
2962
  });
2776
2963
  return;
2777
2964
  }
2778
2965
  if (t != null) {
2779
2966
  if (Array.isArray(t)) {
2780
- for (let s = 0; s < t.length; s++)
2781
- G(t[s], `${e}[${s}]`, n, r);
2967
+ for (let i = 0; i < t.length; i++)
2968
+ G(t[i], `${e}[${i}]`, n, r);
2782
2969
  return;
2783
2970
  }
2784
2971
  if (typeof t == "object")
2785
- for (const [s, i] of Object.entries(
2972
+ for (const [i, s] of Object.entries(
2786
2973
  t
2787
2974
  )) {
2788
- const o = e.length > 0 ? `${e}.${s}` : s;
2789
- G(i, o, n, r);
2975
+ const o = e.length > 0 ? `${e}.${i}` : i;
2976
+ G(s, o, n, r);
2977
+ }
2978
+ }
2979
+ }
2980
+ function dn(t, e, n) {
2981
+ for (const [r, i] of Object.entries(t))
2982
+ G(i, r, e, n);
2983
+ }
2984
+ const fn = /^=+[ \t]*$/, pn = /^-+[ \t]*$/, mn = /^(```|~~~)/, gn = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
2985
+ function J(t) {
2986
+ const e = gn.exec(t);
2987
+ return e && e.index !== void 0 ? {
2988
+ text: t.slice(0, e.index).trim(),
2989
+ explicitId: e[1]
2990
+ } : { text: t.trim() };
2991
+ }
2992
+ function xn(t) {
2993
+ let e = 0;
2994
+ for (; e < t.length && e < 6 && t[e] === "#"; )
2995
+ e += 1;
2996
+ if (e === 0 || e === 6 && e < t.length && t[e] === "#" || e >= t.length || t[e] !== " " && t[e] !== " ")
2997
+ return null;
2998
+ let n = e;
2999
+ for (; n < t.length && (t[n] === " " || t[n] === " "); )
3000
+ n += 1;
3001
+ if (n >= t.length)
3002
+ return null;
3003
+ let r = t.length;
3004
+ for (; r > n && (t[r - 1] === " " || t[r - 1] === " "); )
3005
+ r -= 1;
3006
+ let i = r;
3007
+ if (r > n && t[r - 1] === "#") {
3008
+ let o = r - 1;
3009
+ for (; o > n && t[o - 1] === "#"; )
3010
+ o -= 1;
3011
+ if (o > n && (t[o - 1] === " " || t[o - 1] === " ")) {
3012
+ let a = o - 1;
3013
+ for (; a >= n && (t[a] === " " || t[a] === " "); )
3014
+ a -= 1;
3015
+ i = a + 1;
3016
+ }
3017
+ }
3018
+ if (i <= n)
3019
+ return null;
3020
+ const s = J(t.slice(n, i));
3021
+ return { level: e, ...s };
3022
+ }
3023
+ function _e(t, e, n) {
3024
+ let r = n;
3025
+ for (; r < t.length; ) {
3026
+ if (!e.inHtmlComment) {
3027
+ const s = t.indexOf("<!--", r);
3028
+ if (s === -1)
3029
+ return;
3030
+ e.inHtmlComment = !0, r = s + 4;
3031
+ continue;
3032
+ }
3033
+ const i = t.indexOf("-->", r);
3034
+ if (i === -1)
3035
+ return;
3036
+ e.inHtmlComment = !1, r = i + 3;
3037
+ }
3038
+ }
3039
+ function kn(t, e) {
3040
+ if (e.inFence || e.inHtmlComment)
3041
+ return !0;
3042
+ const n = t.trim();
3043
+ return !!(n.startsWith("<!--") && n.endsWith("-->") && n.length >= 7 || n.startsWith("<!--") && !n.includes("-->"));
3044
+ }
3045
+ function wn(t) {
3046
+ const e = t.split(/\r?\n/), n = [], r = { inFence: !1, inHtmlComment: !1 };
3047
+ for (let i = 0; i < e.length; i++) {
3048
+ const s = e[i];
3049
+ if (r.inFence) {
3050
+ const l = s.trim();
3051
+ l.startsWith(r.inFence.marker) && /^(`{3,}|~{3,})\s*$/.test(l) && (r.inFence = !1);
3052
+ continue;
3053
+ }
3054
+ if (r.inHtmlComment) {
3055
+ _e(s, r, 0);
3056
+ continue;
3057
+ }
3058
+ const o = mn.exec(s.trimStart());
3059
+ if (o) {
3060
+ const l = o[1];
3061
+ s.trimStart().slice(l.length).includes(l) || (r.inFence = { marker: l });
3062
+ continue;
3063
+ }
3064
+ if (s.trim().startsWith("<!--")) {
3065
+ _e(s, r, s.indexOf("<!--"));
3066
+ continue;
3067
+ }
3068
+ if (kn(s, r))
3069
+ continue;
3070
+ const c = xn(s);
3071
+ if (c) {
3072
+ n.push(c);
3073
+ continue;
3074
+ }
3075
+ const h = e[i + 1];
3076
+ if (h !== void 0 && s.trim().length > 0 && !s.trimStart().startsWith("#") && !s.trimStart().startsWith(">") && !s.trimStart().startsWith("|")) {
3077
+ if (fn.test(h)) {
3078
+ const l = J(s.trim());
3079
+ n.push({ level: 1, ...l }), i += 1;
3080
+ continue;
2790
3081
  }
3082
+ if (pn.test(h) && h.trim().length >= 1) {
3083
+ const l = J(s.trim());
3084
+ n.push({ level: 2, ...l }), i += 1;
3085
+ continue;
3086
+ }
3087
+ }
2791
3088
  }
3089
+ return n;
3090
+ }
3091
+ const vn = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
3092
+ function bn() {
3093
+ const t = /* @__PURE__ */ new Map();
3094
+ return {
3095
+ slug(e, n) {
3096
+ const r = n !== void 0 && n.length > 0 ? n : yn(e), i = t.get(r) ?? 0;
3097
+ return t.set(r, i + 1), i === 0 ? r : `${r}-${i}`;
3098
+ }
3099
+ };
2792
3100
  }
2793
- function Vt(t, e, n) {
2794
- for (const [r, s] of Object.entries(t))
2795
- G(s, r, e, n);
3101
+ function yn(t) {
3102
+ return t.toLowerCase().replace(vn, "").replace(/\s+/g, "-");
3103
+ }
3104
+ function _n(t) {
3105
+ let e = t.trim();
3106
+ e = e.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\[[^\]]*\]/g, "$1");
3107
+ for (let n = 0; n < 3; n++)
3108
+ e = e.replace(/\*\*([^*]+)\*\*/g, "$1"), e = e.replace(/__([^_]+)__/g, "$1"), e = e.replace(/~~([^~]+)~~/g, "$1"), e = e.replace(/\*([^*]+)\*/g, "$1"), e = e.replace(/_([^_]+)_/g, "$1"), e = e.replace(/`([^`]+)`/g, "$1");
3109
+ return e.trim();
3110
+ }
3111
+ function Sn(t, e) {
3112
+ if (t.length === 0)
3113
+ return "";
3114
+ const n = bn(), i = t.map((o) => {
3115
+ const a = _n(o.text), c = n.slug(a, o.explicitId);
3116
+ return { level: o.level, text: a, anchor: c };
3117
+ }).filter((o) => o.level <= e);
3118
+ if (i.length === 0)
3119
+ return "";
3120
+ const s = Math.min(...i.map((o) => o.level));
3121
+ return i.map((o) => `${" ".repeat((o.level - s) * 2)}- [${o.text}](#${o.anchor})`).join(`
3122
+ `);
3123
+ }
3124
+ function Cn(t, e = {}) {
3125
+ const r = E(t).filter((o) => {
3126
+ const a = A(o.inner);
3127
+ return a.length === 1 && le(a[0]);
3128
+ });
3129
+ if (r.length === 0)
3130
+ return t;
3131
+ const i = wn(t);
3132
+ let s = t;
3133
+ for (let o = r.length - 1; o >= 0; o--) {
3134
+ const a = r[o], { maxLevel: c } = Ut(a.inner, e.path), h = Sn(i, c), l = s.slice(0, a.start), u = s.slice(a.end);
3135
+ s = T(T(l, h), u);
3136
+ }
3137
+ return s;
2796
3138
  }
2797
- async function ae(t, e) {
2798
- const n = e.path, r = e.context, s = e.registry ?? new be(), i = e.warnings ?? [], o = e.visitStack ?? new Le(), {
3139
+ async function he(t, e) {
3140
+ const n = e.path, r = e.context, i = e.registry ?? new Ce(), s = e.warnings ?? [], o = e.visitStack ?? new Ze(), {
2799
3141
  source: a,
2800
3142
  declarationUpdates: c
2801
- } = await Wt(t, { path: n, context: { ...r } });
2802
- Vt(
3143
+ } = await Zt(t, { path: n, context: { ...r } });
3144
+ dn(
2803
3145
  _(r, c ?? {}),
2804
- i,
3146
+ s,
2805
3147
  n
2806
3148
  );
2807
- const h = await zt(a, {
3149
+ const h = await cn(a, {
2808
3150
  path: n,
2809
3151
  context: r,
2810
3152
  declarationUpdates: c ?? {},
@@ -2812,123 +3154,123 @@ async function ae(t, e) {
2812
3154
  root: e.root,
2813
3155
  constrainToRoot: e.constrainToRoot,
2814
3156
  visitStack: o,
2815
- warnings: i,
3157
+ warnings: s,
2816
3158
  inComponent: e.inComponent ?? !1
2817
- }), { source: l, context: d } = h, { source: f, directives: g } = Dt(l, {
3159
+ }), { source: l, context: u } = h, { source: f, directives: g } = Qt(l, {
2818
3160
  path: n,
2819
- registry: s,
2820
- context: d
3161
+ registry: i,
3162
+ context: u
2821
3163
  }), m = e.loader;
2822
3164
  if (g.length > 0 && !m)
2823
3165
  throw new Error("loader is required when processing include directives");
2824
3166
  let p = f;
2825
- return g.length > 0 && m && (p = await vt({
3167
+ return g.length > 0 && m && (p = await Ft({
2826
3168
  source: f,
2827
3169
  directives: g,
2828
- context: d,
3170
+ context: u,
2829
3171
  loader: m,
2830
3172
  root: e.root,
2831
3173
  path: n,
2832
3174
  preserveFrontMatter: e.preserveFrontMatter,
2833
3175
  preserveHgComments: e.preserveHgComments,
2834
3176
  visitStack: o,
2835
- warnings: i,
2836
- registry: s,
3177
+ warnings: s,
3178
+ registry: i,
2837
3179
  constrainToRoot: e.constrainToRoot
2838
- })), p = await kt(p, {
2839
- context: d,
3180
+ })), p = await Ht(p, {
3181
+ context: u,
2840
3182
  path: n,
2841
- registry: s,
3183
+ registry: i,
2842
3184
  loader: m,
2843
3185
  rootDir: e.root,
2844
- warnings: i,
3186
+ warnings: s,
2845
3187
  visitStack: o,
2846
- parentContext: d,
3188
+ parentContext: u,
2847
3189
  preserveHgComments: e.preserveHgComments,
2848
3190
  constrainToRoot: e.constrainToRoot
2849
- }), p = await _e(p, d, {
3191
+ }), p = await Ne(p, u, {
2850
3192
  path: n,
2851
- registry: s,
3193
+ registry: i,
2852
3194
  loader: m,
2853
3195
  rootDir: e.root,
2854
- warnings: i,
3196
+ warnings: s,
2855
3197
  visitStack: o,
2856
- parentContext: d,
3198
+ parentContext: u,
2857
3199
  preserveHgComments: e.preserveHgComments,
2858
3200
  constrainToRoot: e.constrainToRoot
2859
- }), p = Bt(p, e.preserveHgComments), p;
3201
+ }), p = Cn(p, { path: n }), p = tn(p, e.preserveHgComments), p;
2860
3202
  }
2861
- async function Kt(t, e = {}) {
2862
- const n = e.path, r = _(e.context), s = e.registry ?? new be(), i = e.warnings ?? [], o = e.visitStack ?? new Le(), { context: a, body: c, rawFrontMatter: h } = H(
3203
+ async function Wn(t, e = {}) {
3204
+ const n = e.path, r = _(e.context), i = e.registry ?? new Ce(), s = e.warnings ?? [], o = e.visitStack ?? new Ze(), { context: a, body: c, rawFrontMatter: h } = I(
2863
3205
  t,
2864
3206
  n
2865
3207
  ), l = _(r, a);
2866
- let d = await ae(c, {
3208
+ let u = await he(c, {
2867
3209
  ...e,
2868
3210
  context: l,
2869
- registry: s,
2870
- warnings: i,
3211
+ registry: i,
3212
+ warnings: s,
2871
3213
  visitStack: o
2872
3214
  });
2873
- return d = jt(d, {
3215
+ return u = en(u, {
2874
3216
  preserveFrontMatter: e.preserveFrontMatter,
2875
3217
  rawFrontMatter: h
2876
3218
  }), {
2877
- markdown: d,
2878
- warnings: i
3219
+ markdown: u,
3220
+ warnings: s
2879
3221
  };
2880
3222
  }
2881
- async function Yt(t, e) {
2882
- const n = e.path, { context: r, body: s } = H(t, n), i = _(e.context, r);
2883
- return ae(s, {
3223
+ async function $n(t, e) {
3224
+ const n = e.path, { context: r, body: i } = I(t, n), s = _(e.context, r);
3225
+ return he(i, {
2884
3226
  ...e,
2885
- context: i,
3227
+ context: s,
2886
3228
  preserveFrontMatter: !1
2887
3229
  });
2888
3230
  }
2889
- async function Jt(t, e, n) {
3231
+ async function En(t, e, n) {
2890
3232
  if (n != null && "serverContext" in n && n.serverContext != null)
2891
- throw u({
3233
+ throw d({
2892
3234
  code: "server_context_on_client"
2893
3235
  });
2894
3236
  if (n != null && "dataSources" in n && n.dataSources != null && Object.keys(n.dataSources).length > 0)
2895
- throw u({
3237
+ throw d({
2896
3238
  code: "data_sources_on_client"
2897
3239
  });
2898
3240
  const r = n?.loader;
2899
3241
  if (!r)
2900
- throw u({
3242
+ throw d({
2901
3243
  code: "parse_error",
2902
3244
  details: { message: "loader is required for renderClient" }
2903
3245
  });
2904
- let s, i;
2905
- typeof t == "string" ? s = t : (i = t.path, s = await r(t.path));
3246
+ let i, s;
3247
+ typeof t == "string" ? i = t : (s = t.path, i = await r(t.path));
2906
3248
  const o = _(e);
2907
- return Kt(s, {
3249
+ return Wn(i, {
2908
3250
  context: o,
2909
3251
  loader: r,
2910
3252
  root: n?.root,
2911
- path: i ?? n?.path,
3253
+ path: s ?? n?.path,
2912
3254
  preserveFrontMatter: n?.preserveFrontMatter,
2913
3255
  preserveHgComments: n?.preserveHgComments,
2914
3256
  constrainToRoot: n?.constrainToRoot
2915
3257
  });
2916
3258
  }
2917
- function Xt(t, e) {
3259
+ function Tn(t, e) {
2918
3260
  const n = [`[hyogen:${t}] ${e.code}`], r = {};
2919
3261
  if (e.details)
2920
- for (const [s, i] of Object.entries(e.details))
2921
- i !== void 0 && (r[s] = i);
3262
+ for (const [i, s] of Object.entries(e.details))
3263
+ s !== void 0 && (r[i] = s);
2922
3264
  r.path === void 0 && e.path !== void 0 && (r.path = e.path);
2923
- for (const [s, i] of Object.entries(r))
2924
- n.push(` ${s}: ${String(i)}`);
3265
+ for (const [i, s] of Object.entries(r))
3266
+ n.push(` ${i}: ${String(s)}`);
2925
3267
  return n.join(`
2926
3268
  `);
2927
3269
  }
2928
3270
  export {
2929
- u as createHyogenError,
2930
- Xt as formatDiagnosticLog,
2931
- Ue as formatMessage,
2932
- Jt as renderClient
3271
+ d as createHyogenError,
3272
+ Tn as formatDiagnosticLog,
3273
+ it as formatMessage,
3274
+ En as renderClient
2933
3275
  };
2934
3276
  //# sourceMappingURL=client.js.map