@11ty/client 4.0.0-alpha.1 → 4.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! Eleventy v4.0.0-alpha.1 (@11ty/client/liquid Engine Bundle) */
1
+ /*! Eleventy (Build Awesome) v4.0.0-alpha.10 (@11ty/client/liquid Engine Bundle) */
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -12,11 +12,20 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
12
12
  if (typeof require !== "undefined") return require.apply(this, arguments);
13
13
  throw Error('Dynamic require of "' + x + '" is not supported');
14
14
  });
15
- var __esm = (fn, res) => function __init() {
16
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
15
+ var __esm = (fn, res, err) => function __init() {
16
+ if (err) throw err[0];
17
+ try {
18
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
19
+ } catch (e) {
20
+ throw err = [e], e;
21
+ }
17
22
  };
18
23
  var __commonJS = (cb, mod) => function __require2() {
19
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
24
+ try {
25
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
26
+ } catch (e) {
27
+ throw mod = 0, e;
28
+ }
20
29
  };
21
30
  var __export = (target, all) => {
22
31
  for (var name in all)
@@ -1512,14 +1521,19 @@ __export(shim_consume_fs_exports, {
1512
1521
  promises: () => promises,
1513
1522
  readFileSync: () => readFileSync2,
1514
1523
  readSync: () => readSync,
1524
+ readdir: () => readdir,
1525
+ readdirSync: () => readdirSync,
1526
+ realpath: () => realpath,
1527
+ realpathSync: () => realpathSync,
1528
+ stat: () => stat,
1515
1529
  statSync: () => statSync,
1516
1530
  writeFileSync: () => writeFileSync
1517
1531
  });
1518
- var GLOBAL_FS_NAME, fs2, mkdir, existsSync2, mkdirSync, readFileSync2, statSync, writeFileSync, promises, readSync, fstatSync, closeSync, openSync, shim_consume_fs_default;
1532
+ var GLOBAL_FS_NAME, fs2, mkdir, existsSync2, mkdirSync, readFileSync2, statSync, writeFileSync, promises, readSync, fstatSync, closeSync, openSync, readdir, readdirSync, realpath, realpathSync, stat, shim_consume_fs_default;
1519
1533
  var init_shim_consume_fs = __esm({
1520
1534
  "../../node_modules/@11ty/package-bundler/shims/shim-consume-fs.js"() {
1521
1535
  GLOBAL_FS_NAME = "eleventyFileSystem";
1522
- fs2 = window[GLOBAL_FS_NAME] || globalThis[GLOBAL_FS_NAME];
1536
+ fs2 = typeof window !== "undefined" && window[GLOBAL_FS_NAME] || typeof globalThis !== "undefined" && globalThis[GLOBAL_FS_NAME];
1523
1537
  if (!fs2) {
1524
1538
  let noopError = function() {
1525
1539
  throw new Error("This function was not included in your Eleventy bundle. Make sure you load memfs.js before using the virtual file system.");
@@ -1537,7 +1551,13 @@ var init_shim_consume_fs = __esm({
1537
1551
  readSync: noopError,
1538
1552
  fstatSync: noopError,
1539
1553
  closeSync: noopError,
1540
- openSync: noopError
1554
+ openSync: noopError,
1555
+ // tinyglobby
1556
+ readdir: noopError,
1557
+ readdirSync: noopError,
1558
+ realpath: noopError,
1559
+ realpathSync: noopError,
1560
+ stat: noopError
1541
1561
  };
1542
1562
  }
1543
1563
  mkdir = fs2.mkdir;
@@ -1551,6 +1571,11 @@ var init_shim_consume_fs = __esm({
1551
1571
  fstatSync = fs2.fstatSync;
1552
1572
  closeSync = fs2.closeSync;
1553
1573
  openSync = fs2.openSync;
1574
+ readdir = fs2.readdir;
1575
+ readdirSync = fs2.readdirSync;
1576
+ realpath = fs2.realpath;
1577
+ realpathSync = fs2.realpathSync;
1578
+ stat = fs2.stat;
1554
1579
  shim_consume_fs_default = fs2;
1555
1580
  }
1556
1581
  });
@@ -1876,7 +1901,7 @@ var require_Buffer = __commonJS({
1876
1901
  // ../../node_modules/@11ty/eleventy-utils/src/lib-sha256.js
1877
1902
  var require_lib_sha256 = __commonJS({
1878
1903
  "../../node_modules/@11ty/eleventy-utils/src/lib-sha256.js"(exports, module) {
1879
- module.exports = /* @__PURE__ */ __name(function sha256(data) {
1904
+ module.exports = /* @__PURE__ */ __name(function sha2562(data) {
1880
1905
  let h0 = 1779033703, h1 = 3144134277, h2 = 1013904242, h3 = 2773480762, h4 = 1359893119, h5 = 2600822924, h6 = 528734635, h7 = 1541459225, tsz = 0, bp = 0;
1881
1906
  const k = [
1882
1907
  1116352408,
@@ -2050,7 +2075,7 @@ var require_HashTypes = __commonJS({
2050
2075
  "../../node_modules/@11ty/eleventy-utils/src/HashTypes.js"(exports, module) {
2051
2076
  var { base64UrlSafe } = require_Url();
2052
2077
  var { isBuffer } = require_Buffer();
2053
- var sha256 = require_lib_sha256();
2078
+ var sha2562 = require_lib_sha256();
2054
2079
  function hasNodeCryptoModule() {
2055
2080
  try {
2056
2081
  __require("node:crypto");
@@ -2165,7 +2190,7 @@ var require_HashTypes = __commonJS({
2165
2190
  __name(this, "ScriptHash");
2166
2191
  }
2167
2192
  static toHash(...content) {
2168
- let hash = sha256();
2193
+ let hash = sha2562();
2169
2194
  for (let c of content) {
2170
2195
  hash.add(c);
2171
2196
  }
@@ -2278,7 +2303,7 @@ var Drop = class {
2278
2303
  static {
2279
2304
  __name(this, "Drop");
2280
2305
  }
2281
- liquidMethodMissing(key) {
2306
+ liquidMethodMissing(key, context) {
2282
2307
  return void 0;
2283
2308
  }
2284
2309
  };
@@ -2301,10 +2326,6 @@ function isIterator(val) {
2301
2326
  return val && isFunction(val.next) && isFunction(val.throw) && isFunction(val.return);
2302
2327
  }
2303
2328
  __name(isIterator, "isIterator");
2304
- function escapeRegex(str) {
2305
- return str.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
2306
- }
2307
- __name(escapeRegex, "escapeRegex");
2308
2329
  function stringify(value) {
2309
2330
  value = toValue(value);
2310
2331
  if (isString(value))
@@ -2343,8 +2364,7 @@ function toValue(value) {
2343
2364
  }
2344
2365
  __name(toValue, "toValue");
2345
2366
  function toNumber(value) {
2346
- value = Number(value);
2347
- return isNaN(value) ? 0 : value;
2367
+ return +toValue(value) || 0;
2348
2368
  }
2349
2369
  __name(toNumber, "toNumber");
2350
2370
  function isNumber(value) {
@@ -2415,10 +2435,10 @@ function padEnd(str, length, ch = " ") {
2415
2435
  __name(padEnd, "padEnd");
2416
2436
  function pad(str, length, ch, add) {
2417
2437
  str = String(str);
2418
- let n = length - str.length;
2419
- while (n-- > 0)
2420
- str = add(str, ch);
2421
- return str;
2438
+ const n = length - str.length;
2439
+ if (n <= 0)
2440
+ return str;
2441
+ return add(str, ch.repeat(n));
2422
2442
  }
2423
2443
  __name(pad, "pad");
2424
2444
  function identify(val) {
@@ -2434,12 +2454,26 @@ function ellipsis(str, N) {
2434
2454
  return str.length > N ? str.slice(0, N - 3) + "..." : str;
2435
2455
  }
2436
2456
  __name(ellipsis, "ellipsis");
2457
+ function orderedCompare(a, b) {
2458
+ if (isNil(a) && isNil(b))
2459
+ return 0;
2460
+ if (isNil(a))
2461
+ return 1;
2462
+ if (isNil(b))
2463
+ return -1;
2464
+ if (a < b)
2465
+ return -1;
2466
+ if (a > b)
2467
+ return 1;
2468
+ return 0;
2469
+ }
2470
+ __name(orderedCompare, "orderedCompare");
2437
2471
  function caseInsensitiveCompare(a, b) {
2438
- if (a == null && b == null)
2472
+ if (isNil(a) && isNil(b))
2439
2473
  return 0;
2440
- if (a == null)
2474
+ if (isNil(a))
2441
2475
  return 1;
2442
- if (b == null)
2476
+ if (isNil(b))
2443
2477
  return -1;
2444
2478
  a = toLowerCase.call(a);
2445
2479
  b = toLowerCase.call(b);
@@ -2456,10 +2490,12 @@ function argumentsToValue(fn) {
2456
2490
  };
2457
2491
  }
2458
2492
  __name(argumentsToValue, "argumentsToValue");
2459
- function escapeRegExp(text) {
2460
- return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
2493
+ function argumentsToNumber(fn) {
2494
+ return function(...args) {
2495
+ return fn.call(this, ...args.map(toNumber));
2496
+ };
2461
2497
  }
2462
- __name(escapeRegExp, "escapeRegExp");
2498
+ __name(argumentsToNumber, "argumentsToNumber");
2463
2499
  function* strictUniq(array) {
2464
2500
  const seen = /* @__PURE__ */ new Set();
2465
2501
  for (const element of array) {
@@ -2804,7 +2840,11 @@ var literalValues = {
2804
2840
  "empty": new EmptyDrop(),
2805
2841
  "blank": new BlankDrop()
2806
2842
  };
2843
+ var trieCache = /* @__PURE__ */ new WeakMap();
2807
2844
  function createTrie(input) {
2845
+ const cached = trieCache.get(input);
2846
+ if (cached)
2847
+ return cached;
2808
2848
  const trie = {};
2809
2849
  for (const [name, data] of Object.entries(input)) {
2810
2850
  let node = trie;
@@ -2819,6 +2859,7 @@ function createTrie(input) {
2819
2859
  node.data = data;
2820
2860
  node.end = true;
2821
2861
  }
2862
+ trieCache.set(input, trie);
2822
2863
  return trie;
2823
2864
  }
2824
2865
  __name(createTrie, "createTrie");
@@ -2864,6 +2905,13 @@ function __awaiter(thisArg, _arguments, P, generator) {
2864
2905
  });
2865
2906
  }
2866
2907
  __name(__awaiter, "__awaiter");
2908
+ function toLiquidAsync(asyncFn, syncFn) {
2909
+ const syncImpl = syncFn || asyncFn;
2910
+ return (sync, ...args) => {
2911
+ return sync ? syncImpl(...args) : asyncFn(...args);
2912
+ };
2913
+ }
2914
+ __name(toLiquidAsync, "toLiquidAsync");
2867
2915
  function toPromise(val) {
2868
2916
  return __awaiter(this, void 0, void 0, function* () {
2869
2917
  if (!isIterator(val))
@@ -2873,7 +2921,7 @@ function toPromise(val) {
2873
2921
  let next = "next";
2874
2922
  do {
2875
2923
  const state = val[next](value);
2876
- done = state.done;
2924
+ done = !!state.done;
2877
2925
  value = state.value;
2878
2926
  next = "next";
2879
2927
  try {
@@ -2898,7 +2946,7 @@ function toValueSync(val) {
2898
2946
  let next = "next";
2899
2947
  do {
2900
2948
  const state = val[next](value);
2901
- done = state.done;
2949
+ done = !!state.done;
2902
2950
  value = state.value;
2903
2951
  next = "next";
2904
2952
  if (isIterator(value)) {
@@ -3000,8 +3048,10 @@ var formatCodes = {
3000
3048
  m: /* @__PURE__ */ __name((d) => d.getMonth() + 1, "m"),
3001
3049
  M: /* @__PURE__ */ __name((d) => d.getMinutes(), "M"),
3002
3050
  N: /* @__PURE__ */ __name((d, opts) => {
3051
+ var _a;
3003
3052
  const width = Number(opts.width) || 9;
3004
3053
  const str = String(d.getMilliseconds()).slice(0, width);
3054
+ (_a = opts.memoryLimit) === null || _a === void 0 ? void 0 : _a.use(width - str.length);
3005
3055
  return padEnd(str, width, "0");
3006
3056
  }, "N"),
3007
3057
  p: /* @__PURE__ */ __name((d) => d.getHours() < 12 ? "AM" : "PM", "p"),
@@ -3024,19 +3074,19 @@ var formatCodes = {
3024
3074
  "%": /* @__PURE__ */ __name(() => "%", "%")
3025
3075
  };
3026
3076
  formatCodes.h = formatCodes.b;
3027
- function strftime(d, formatStr) {
3077
+ function strftime(d, formatStr, memoryLimit) {
3028
3078
  let output = "";
3029
3079
  let remaining = formatStr;
3030
3080
  let match;
3031
3081
  while (match = rFormat.exec(remaining)) {
3032
3082
  output += remaining.slice(0, match.index);
3033
3083
  remaining = remaining.slice(match.index + match[0].length);
3034
- output += format(d, match);
3084
+ output += format(d, match, memoryLimit);
3035
3085
  }
3036
3086
  return output + remaining;
3037
3087
  }
3038
3088
  __name(strftime, "strftime");
3039
- function format(d, match) {
3089
+ function format(d, match, memoryLimit) {
3040
3090
  const [input, flagStr = "", width, modifier, conversion] = match;
3041
3091
  const convert = formatCodes[conversion];
3042
3092
  if (!convert)
@@ -3044,9 +3094,9 @@ function format(d, match) {
3044
3094
  const flags = {};
3045
3095
  for (const flag of flagStr)
3046
3096
  flags[flag] = true;
3047
- let ret = String(convert(d, { flags, width, modifier }));
3097
+ let ret = String(convert(d, { flags, width, modifier, memoryLimit }));
3048
3098
  let padChar = padSpaceChars.has(conversion) ? " " : "0";
3049
- let padWidth = width || padWidths[conversion] || 0;
3099
+ let padWidth = Number(width) || padWidths[conversion] || 0;
3050
3100
  if (flags["^"])
3051
3101
  ret = ret.toUpperCase();
3052
3102
  else if (flags["#"])
@@ -3057,6 +3107,7 @@ function format(d, match) {
3057
3107
  padChar = "0";
3058
3108
  if (flags["-"])
3059
3109
  padWidth = 0;
3110
+ memoryLimit === null || memoryLimit === void 0 ? void 0 : memoryLimit.use(Number(padWidth) - ret.length);
3060
3111
  return padStart(ret, padWidth, padChar);
3061
3112
  }
3062
3113
  __name(format, "format");
@@ -3223,13 +3274,15 @@ var Limiter = class {
3223
3274
  this.limit = limit2;
3224
3275
  }
3225
3276
  use(count) {
3226
- count = toNumber(count);
3227
- assert(this.base + count <= this.limit, this.message);
3228
- this.base += count;
3277
+ if (+count > 0) {
3278
+ assert(this.base + +count <= this.limit, this.message);
3279
+ this.base += +count;
3280
+ }
3229
3281
  }
3230
3282
  check(count) {
3231
- count = toNumber(count);
3232
- assert(count <= this.limit, this.message);
3283
+ if (+count > 0) {
3284
+ assert(+count <= this.limit, this.message);
3285
+ }
3233
3286
  }
3234
3287
  };
3235
3288
  var DelimitedToken = class extends Token {
@@ -3376,8 +3429,7 @@ var OperatorToken = class extends Token {
3376
3429
  this.operator = this.getText();
3377
3430
  }
3378
3431
  getPrecedence() {
3379
- const key = this.getText();
3380
- return key in operatorPrecedences ? operatorPrecedences[key] : 1;
3432
+ return this.operator in operatorPrecedences ? operatorPrecedences[this.operator] : 1;
3381
3433
  }
3382
3434
  };
3383
3435
  var PropertyAccessToken = class extends Token {
@@ -3541,6 +3593,7 @@ var Render = class {
3541
3593
  if (!emitter) {
3542
3594
  emitter = ctx.opts.keepOutputType ? new KeepingTypeEmitter() : new SimpleEmitter();
3543
3595
  }
3596
+ ctx.renderLimit.check(getPerformance().now());
3544
3597
  const errors = [];
3545
3598
  for (const tpl of templates) {
3546
3599
  ctx.renderLimit.check(getPerformance().now());
@@ -3957,7 +4010,28 @@ __name(newline_to_br, "newline_to_br");
3957
4010
  function strip_html(v) {
3958
4011
  const str = stringify(v);
3959
4012
  this.context.memoryLimit.use(str.length);
3960
- return str.replace(/<script[\s\S]*?<\/script>|<style[\s\S]*?<\/style>|<.*?>|<!--[\s\S]*?-->/g, "");
4013
+ const blocks = /* @__PURE__ */ new Map([["<script", "<\/script>"], ["<style", "</style>"], ["<!--", "-->"], ["<", ">"]]);
4014
+ let out = "";
4015
+ let i = 0;
4016
+ while (i < str.length) {
4017
+ const lt = str.indexOf("<", i);
4018
+ if (lt < 0)
4019
+ return out + str.slice(i);
4020
+ out += str.slice(i, lt);
4021
+ for (const [opener, closer] of blocks) {
4022
+ if (!str.startsWith(opener, lt))
4023
+ continue;
4024
+ const e = str.indexOf(closer, lt + opener.length);
4025
+ if (e >= 0) {
4026
+ i = e + closer.length;
4027
+ break;
4028
+ }
4029
+ blocks.delete(opener);
4030
+ }
4031
+ if (i <= lt)
4032
+ return out + str.slice(lt);
4033
+ }
4034
+ return out;
3961
4035
  }
3962
4036
  __name(strip_html, "strip_html");
3963
4037
  var htmlFilters = /* @__PURE__ */ Object.freeze({
@@ -4556,7 +4630,7 @@ var Tokenizer = class {
4556
4630
  }
4557
4631
  *readFileNameTemplate(options) {
4558
4632
  const { outputDelimiterLeft } = options;
4559
- const htmlStopStrings = [",", " ", outputDelimiterLeft];
4633
+ const htmlStopStrings = [",", " ", "\r", "\n", " ", outputDelimiterLeft];
4560
4634
  const htmlStopStringSet = new Set(htmlStopStrings);
4561
4635
  while (this.p < this.N && !htmlStopStringSet.has(this.peek())) {
4562
4636
  yield this.match(outputDelimiterLeft) ? this.readOutputToken(options) : this.readHTMLToken(htmlStopStrings);
@@ -5084,42 +5158,50 @@ var Loader = class {
5084
5158
  __name(this, "Loader");
5085
5159
  }
5086
5160
  constructor(options) {
5161
+ var _a, _b, _c, _d;
5087
5162
  this.options = options;
5088
5163
  if (options.relativeReference) {
5089
5164
  const sep2 = options.fs.sep;
5090
5165
  assert(sep2, "`fs.sep` is required for relative reference");
5091
- const rRelativePath = new RegExp(["." + sep2, ".." + sep2, "./", "../"].map((prefix) => escapeRegex(prefix)).join("|"));
5092
- this.shouldLoadRelative = (referencedFile) => rRelativePath.test(referencedFile);
5166
+ const prefixes = ["." + sep2, ".." + sep2, "./", "../"];
5167
+ this.shouldLoadRelative = (referencedFile) => prefixes.some((prefix) => referencedFile.startsWith(prefix));
5093
5168
  } else {
5094
5169
  this.shouldLoadRelative = (_referencedFile) => false;
5095
5170
  }
5096
- this.contains = this.options.fs.contains || (() => true);
5171
+ const fs3 = options.fs;
5172
+ this.contains = toLiquidAsync(((_a = fs3.contains) === null || _a === void 0 ? void 0 : _a.bind(fs3)) || (() => __awaiter(this, void 0, void 0, function* () {
5173
+ return true;
5174
+ })), ((_b = fs3.containsSync) === null || _b === void 0 ? void 0 : _b.bind(fs3)) || (() => true));
5175
+ this.exists = toLiquidAsync(((_c = fs3.exists) === null || _c === void 0 ? void 0 : _c.bind(fs3)) || (() => __awaiter(this, void 0, void 0, function* () {
5176
+ return false;
5177
+ })), (_d = fs3.existsSync) === null || _d === void 0 ? void 0 : _d.bind(fs3));
5097
5178
  }
5098
5179
  *lookup(file, type, sync, currentFile) {
5099
- const { fs: fs3 } = this.options;
5100
5180
  const dirs = this.options[type];
5101
- for (const filepath of this.candidates(file, dirs, currentFile, type !== LookupType.Root)) {
5102
- if (sync ? fs3.existsSync(filepath) : yield fs3.exists(filepath))
5181
+ for (const filepath of this.candidates(file, dirs, currentFile)) {
5182
+ let allowed = false;
5183
+ for (const dir of dirs) {
5184
+ if (yield this.contains(!!sync, dir, filepath)) {
5185
+ allowed = true;
5186
+ break;
5187
+ }
5188
+ }
5189
+ if (!allowed)
5190
+ continue;
5191
+ if (yield this.exists(!!sync, filepath))
5103
5192
  return filepath;
5104
5193
  }
5105
5194
  throw this.lookupError(file, dirs);
5106
5195
  }
5107
- *candidates(file, dirs, currentFile, enforceRoot) {
5196
+ *candidates(file, dirs, currentFile) {
5108
5197
  const { fs: fs3, extname } = this.options;
5109
5198
  if (this.shouldLoadRelative(file) && currentFile) {
5110
5199
  const referenced = fs3.resolve(this.dirname(currentFile), file, extname);
5111
- for (const dir of dirs) {
5112
- if (!enforceRoot || this.contains(dir, referenced)) {
5113
- yield referenced;
5114
- break;
5115
- }
5116
- }
5200
+ yield referenced;
5117
5201
  }
5118
5202
  for (const dir of dirs) {
5119
5203
  const referenced = fs3.resolve(dir, file, extname);
5120
- if (!enforceRoot || this.contains(dir, referenced)) {
5121
- yield referenced;
5122
- }
5204
+ yield referenced;
5123
5205
  }
5124
5206
  if (fs3.fallback !== void 0) {
5125
5207
  const filepath = fs3.fallback(file);
@@ -5144,12 +5226,16 @@ var Parser = class {
5144
5226
  __name(this, "Parser");
5145
5227
  }
5146
5228
  constructor(liquid) {
5229
+ var _a, _b;
5147
5230
  this.liquid = liquid;
5148
5231
  this.cache = this.liquid.options.cache;
5149
5232
  this.fs = this.liquid.options.fs;
5150
5233
  this.parseFile = this.cache ? this._parseFileCached : this._parseFile;
5151
5234
  this.loader = new Loader(this.liquid.options);
5152
5235
  this.parseLimit = new Limiter("parse length", liquid.options.parseLimit);
5236
+ this.readFile = toLiquidAsync(((_a = this.fs.readFile) === null || _a === void 0 ? void 0 : _a.bind(this.fs)) || (() => __awaiter(this, void 0, void 0, function* () {
5237
+ throw new Error("readFile not implemented");
5238
+ })), (_b = this.fs.readFileSync) === null || _b === void 0 ? void 0 : _b.bind(this.fs));
5153
5239
  }
5154
5240
  parse(html, filepath) {
5155
5241
  html = String(html);
@@ -5214,7 +5300,7 @@ var Parser = class {
5214
5300
  }
5215
5301
  *_parseFile(file, sync, type = LookupType.Root, currentFile) {
5216
5302
  const filepath = yield this.loader.lookup(file, type, sync, currentFile);
5217
- return this.parse(sync ? this.fs.readFileSync(filepath) : yield this.fs.readFile(filepath), filepath);
5303
+ return this.parse(yield this.readFile(!!sync, filepath), filepath);
5218
5304
  }
5219
5305
  };
5220
5306
  var TokenKind;
@@ -5282,13 +5368,20 @@ function getKind(val) {
5282
5368
  return val ? val.kind : -1;
5283
5369
  }
5284
5370
  __name(getKind, "getKind");
5371
+ function createScope(from) {
5372
+ const scope = /* @__PURE__ */ Object.create(null);
5373
+ if (from)
5374
+ Object.assign(scope, from);
5375
+ return scope;
5376
+ }
5377
+ __name(createScope, "createScope");
5285
5378
  var Context = class _Context {
5286
5379
  static {
5287
5380
  __name(this, "Context");
5288
5381
  }
5289
5382
  constructor(env = {}, opts = defaultOptions, renderOptions = {}, { memoryLimit, renderLimit } = {}) {
5290
5383
  var _a, _b, _c, _d, _e;
5291
- this.scopes = [{}];
5384
+ this.scopes = [createScope()];
5292
5385
  this.registers = {};
5293
5386
  this.breakCalled = false;
5294
5387
  this.continueCalled = false;
@@ -5301,8 +5394,8 @@ var Context = class _Context {
5301
5394
  this.memoryLimit = memoryLimit !== null && memoryLimit !== void 0 ? memoryLimit : new Limiter("memory alloc", (_d = renderOptions.memoryLimit) !== null && _d !== void 0 ? _d : opts.memoryLimit);
5302
5395
  this.renderLimit = renderLimit !== null && renderLimit !== void 0 ? renderLimit : new Limiter("template render", getPerformance().now() + ((_e = renderOptions.renderLimit) !== null && _e !== void 0 ? _e : opts.renderLimit));
5303
5396
  }
5304
- getRegister(key) {
5305
- return this.registers[key] = this.registers[key] || {};
5397
+ getRegister(key, defaultValue = void 0) {
5398
+ return this.registers[key] = this.registers[key] || defaultValue;
5306
5399
  }
5307
5400
  setRegister(key, value) {
5308
5401
  return this.registers[key] = value;
@@ -5339,7 +5432,7 @@ var Context = class _Context {
5339
5432
  if (isString(paths))
5340
5433
  paths = paths.split(".");
5341
5434
  for (let i = 0; i < paths.length; i++) {
5342
- scope = yield readProperty(scope, paths[i], this.ownPropertyOnly);
5435
+ scope = yield this.readProperty(scope, paths[i]);
5343
5436
  if (strictVariables && isUndefined(scope)) {
5344
5437
  throw new InternalUndefinedVariableError(paths.slice(0, i + 1).join("."));
5345
5438
  }
@@ -5359,7 +5452,8 @@ var Context = class _Context {
5359
5452
  return new _Context(scope, this.opts, {
5360
5453
  sync: this.sync,
5361
5454
  globals: this.globals,
5362
- strictVariables: this.strictVariables
5455
+ strictVariables: this.strictVariables,
5456
+ ownPropertyOnly: this.ownPropertyOnly
5363
5457
  }, {
5364
5458
  renderLimit: this.renderLimit,
5365
5459
  memoryLimit: this.memoryLimit
@@ -5375,28 +5469,27 @@ var Context = class _Context {
5375
5469
  return this.environments;
5376
5470
  return this.globals;
5377
5471
  }
5472
+ readProperty(obj, key) {
5473
+ obj = toLiquid(obj);
5474
+ key = toValue(key);
5475
+ if (isNil(obj))
5476
+ return obj;
5477
+ if (isArray(obj) && key < 0)
5478
+ return obj[obj.length + +key];
5479
+ const value = readJSProperty(obj, key, this.ownPropertyOnly);
5480
+ if (value === void 0 && obj instanceof Drop)
5481
+ return obj.liquidMethodMissing(key, this);
5482
+ if (isFunction(value))
5483
+ return value.call(obj);
5484
+ if (key === "size")
5485
+ return readSize(obj);
5486
+ else if (key === "first")
5487
+ return readFirst(obj);
5488
+ else if (key === "last")
5489
+ return readLast(obj);
5490
+ return value;
5491
+ }
5378
5492
  };
5379
- function readProperty(obj, key, ownPropertyOnly) {
5380
- obj = toLiquid(obj);
5381
- key = toValue(key);
5382
- if (isNil(obj))
5383
- return obj;
5384
- if (isArray(obj) && key < 0)
5385
- return obj[obj.length + +key];
5386
- const value = readJSProperty(obj, key, ownPropertyOnly);
5387
- if (value === void 0 && obj instanceof Drop)
5388
- return obj.liquidMethodMissing(key);
5389
- if (isFunction(value))
5390
- return value.call(obj);
5391
- if (key === "size")
5392
- return readSize(obj);
5393
- else if (key === "first")
5394
- return readFirst(obj);
5395
- else if (key === "last")
5396
- return readLast(obj);
5397
- return value;
5398
- }
5399
- __name(readProperty, "readProperty");
5400
5493
  function readJSProperty(obj, key, ownPropertyOnly) {
5401
5494
  if (ownPropertyOnly && !hasOwnProperty.call(obj, key) && !(obj instanceof Drop))
5402
5495
  return void 0;
@@ -5429,28 +5522,24 @@ var BlockMode;
5429
5522
  BlockMode2[BlockMode2["OUTPUT"] = 0] = "OUTPUT";
5430
5523
  BlockMode2[BlockMode2["STORE"] = 1] = "STORE";
5431
5524
  })(BlockMode || (BlockMode = {}));
5432
- var abs = argumentsToValue(Math.abs);
5433
- var at_least = argumentsToValue(Math.max);
5434
- var at_most = argumentsToValue(Math.min);
5435
- var ceil = argumentsToValue(Math.ceil);
5436
- var divided_by = argumentsToValue((dividend, divisor, integerArithmetic = false) => integerArithmetic ? Math.floor(dividend / divisor) : dividend / divisor);
5437
- var floor = argumentsToValue(Math.floor);
5438
- var minus = argumentsToValue((v, arg) => v - arg);
5439
- var modulo = argumentsToValue((v, arg) => v % arg);
5440
- var times = argumentsToValue((v, arg) => v * arg);
5525
+ var abs = argumentsToNumber(Math.abs);
5526
+ var at_least = argumentsToNumber(Math.max);
5527
+ var at_most = argumentsToNumber(Math.min);
5528
+ var ceil = argumentsToNumber(Math.ceil);
5529
+ var divided_by = argumentsToNumber((dividend, divisor, integerArithmetic = false) => integerArithmetic ? Math.floor(dividend / divisor) : dividend / divisor);
5530
+ var floor = argumentsToNumber(Math.floor);
5531
+ var minus = argumentsToNumber((v, arg) => v - arg);
5532
+ var plus = argumentsToNumber((lhs, rhs) => lhs + rhs);
5533
+ var modulo = argumentsToNumber((v, arg) => v % arg);
5534
+ var times = argumentsToNumber((v, arg) => v * arg);
5441
5535
  function round(v, arg = 0) {
5442
- v = toValue(v);
5443
- arg = toValue(arg);
5536
+ v = toNumber(v);
5537
+ arg = toNumber(arg);
5444
5538
  const amp = Math.pow(10, arg);
5445
- return Math.round(v * amp) / amp;
5539
+ const scaled = v * amp * (1 + Number.EPSILON);
5540
+ return Math.round(scaled) / amp;
5446
5541
  }
5447
5542
  __name(round, "round");
5448
- function plus(v, arg) {
5449
- v = toValue(v);
5450
- arg = toValue(arg);
5451
- return Number(v) + Number(arg);
5452
- }
5453
- __name(plus, "plus");
5454
5543
  var mathFilters = /* @__PURE__ */ Object.freeze({
5455
5544
  __proto__: null,
5456
5545
  abs,
@@ -5460,10 +5549,10 @@ var mathFilters = /* @__PURE__ */ Object.freeze({
5460
5549
  divided_by,
5461
5550
  floor,
5462
5551
  minus,
5552
+ plus,
5463
5553
  modulo,
5464
5554
  times,
5465
- round,
5466
- plus
5555
+ round
5467
5556
  });
5468
5557
  var url_decode = /* @__PURE__ */ __name((x) => decodeURIComponent(stringify(x)).replace(/\+/g, " "), "url_decode");
5469
5558
  var url_encode = /* @__PURE__ */ __name((x) => encodeURIComponent(stringify(x)).replace(/%20/g, "+"), "url_encode");
@@ -5515,7 +5604,7 @@ var reverse = argumentsToValue(function(v) {
5515
5604
  this.context.memoryLimit.use(array.length);
5516
5605
  return [...array].reverse();
5517
5606
  });
5518
- function* sort(arr, property) {
5607
+ function* sortBy(arr, property, comparator) {
5519
5608
  const values = [];
5520
5609
  const array = toArray(arr);
5521
5610
  this.context.memoryLimit.use(array.length);
@@ -5525,19 +5614,15 @@ function* sort(arr, property) {
5525
5614
  property ? yield this.context._getFromScope(item, stringify(property).split("."), false) : item
5526
5615
  ]);
5527
5616
  }
5528
- return values.sort((lhs, rhs) => {
5529
- const lvalue = lhs[1];
5530
- const rvalue = rhs[1];
5531
- return lvalue < rvalue ? -1 : lvalue > rvalue ? 1 : 0;
5532
- }).map((tuple) => tuple[0]);
5617
+ return values.sort((lhs, rhs) => comparator(lhs[1], rhs[1])).map((tuple) => tuple[0]);
5618
+ }
5619
+ __name(sortBy, "sortBy");
5620
+ function* sort(arr, property) {
5621
+ return yield* sortBy.call(this, arr, property, orderedCompare);
5533
5622
  }
5534
5623
  __name(sort, "sort");
5535
- function sort_natural(input, property) {
5536
- const propertyString = stringify(property);
5537
- const compare = property === void 0 ? caseInsensitiveCompare : (lhs, rhs) => caseInsensitiveCompare(lhs[propertyString], rhs[propertyString]);
5538
- const array = toArray(input);
5539
- this.context.memoryLimit.use(array.length);
5540
- return [...array].sort(compare);
5624
+ function* sort_natural(arr, property) {
5625
+ return yield* sortBy.call(this, arr, property, caseInsensitiveCompare);
5541
5626
  }
5542
5627
  __name(sort_natural, "sort_natural");
5543
5628
  var size = /* @__PURE__ */ __name((v) => v && v.length || 0, "size");
@@ -5587,7 +5672,9 @@ function unshift(v, arg) {
5587
5672
  }
5588
5673
  __name(unshift, "unshift");
5589
5674
  function pop(v) {
5590
- const clone = [...toArray(v)];
5675
+ const array = toArray(v);
5676
+ this.context.memoryLimit.use(array.length);
5677
+ const clone = [...array];
5591
5678
  clone.pop();
5592
5679
  return clone;
5593
5680
  }
@@ -5759,7 +5846,7 @@ function sample(v, count = 1) {
5759
5846
  return [];
5760
5847
  if (!isArray(v))
5761
5848
  v = stringify(v);
5762
- this.context.memoryLimit.use(count);
5849
+ this.context.memoryLimit.use(v.length);
5763
5850
  const shuffled = [...v].sort(() => Math.random() - 0.5);
5764
5851
  if (count === 1)
5765
5852
  return shuffled[0];
@@ -5800,15 +5887,16 @@ var arrayFilters = /* @__PURE__ */ Object.freeze({
5800
5887
  sample
5801
5888
  });
5802
5889
  function date(v, format2, timezoneOffset) {
5803
- var _a, _b, _c;
5804
- const size2 = ((_a = v === null || v === void 0 ? void 0 : v.length) !== null && _a !== void 0 ? _a : 0) + ((_b = format2 === null || format2 === void 0 ? void 0 : format2.length) !== null && _b !== void 0 ? _b : 0) + ((_c = timezoneOffset === null || timezoneOffset === void 0 ? void 0 : timezoneOffset.length) !== null && _c !== void 0 ? _c : 0);
5890
+ var _a, _b;
5891
+ const size2 = ((_a = v === null || v === void 0 ? void 0 : v.length) !== null && _a !== void 0 ? _a : 0) + ((_b = timezoneOffset === null || timezoneOffset === void 0 ? void 0 : timezoneOffset.length) !== null && _b !== void 0 ? _b : 0);
5805
5892
  this.context.memoryLimit.use(size2);
5806
5893
  const date2 = parseDate(v, this.context.opts, timezoneOffset);
5807
5894
  if (!date2)
5808
5895
  return v;
5809
5896
  format2 = toValue(format2);
5810
5897
  format2 = isNil(format2) ? this.context.opts.dateFormat : stringify(format2);
5811
- return strftime(date2, format2);
5898
+ this.context.memoryLimit.use(format2.length);
5899
+ return strftime(date2, format2, this.context.memoryLimit);
5812
5900
  }
5813
5901
  __name(date, "date");
5814
5902
  function date_to_xmlschema(v) {
@@ -5831,11 +5919,12 @@ function stringify_date(v, month_type, type, style) {
5831
5919
  const date2 = parseDate(v, this.context.opts);
5832
5920
  if (!date2)
5833
5921
  return v;
5922
+ const ml = this.context.memoryLimit;
5834
5923
  if (type === "ordinal") {
5835
5924
  const d = date2.getDate();
5836
- return style === "US" ? strftime(date2, `${month_type} ${d}%q, %Y`) : strftime(date2, `${d}%q ${month_type} %Y`);
5925
+ return style === "US" ? strftime(date2, `${month_type} ${d}%q, %Y`, ml) : strftime(date2, `${d}%q ${month_type} %Y`, ml);
5837
5926
  }
5838
- return strftime(date2, `%d ${month_type} %Y`);
5927
+ return strftime(date2, `%d ${month_type} %Y`, ml);
5839
5928
  }
5840
5929
  __name(stringify_date, "stringify_date");
5841
5930
  function parseDate(v, opts, timezoneOffset) {
@@ -5843,7 +5932,9 @@ function parseDate(v, opts, timezoneOffset) {
5843
5932
  const defaultTimezoneOffset = timezoneOffset !== null && timezoneOffset !== void 0 ? timezoneOffset : opts.timezoneOffset;
5844
5933
  const locale = opts.locale;
5845
5934
  v = toValue(v);
5846
- if (v === "now" || v === "today") {
5935
+ if (isNil(v)) {
5936
+ return void 0;
5937
+ } else if (v === "now" || v === "today") {
5847
5938
  date2 = new LiquidDate(Date.now(), locale, defaultTimezoneOffset);
5848
5939
  } else if (isNumber(v)) {
5849
5940
  date2 = new LiquidDate(v * 1e3, locale, defaultTimezoneOffset);
@@ -5891,10 +5982,15 @@ function lstrip(v, chars) {
5891
5982
  const str = stringify(v);
5892
5983
  this.context.memoryLimit.use(str.length);
5893
5984
  if (chars) {
5894
- chars = escapeRegExp(stringify(chars));
5895
- return str.replace(new RegExp(`^[${chars}]+`, "g"), "");
5985
+ chars = stringify(chars);
5986
+ this.context.memoryLimit.use(chars.length);
5987
+ for (let i = 0, set = new Set(chars); i < str.length; i++) {
5988
+ if (!set.has(str[i]))
5989
+ return str.slice(i);
5990
+ }
5991
+ return "";
5896
5992
  }
5897
- return str.replace(/^\s+/, "");
5993
+ return str.trimStart();
5898
5994
  }
5899
5995
  __name(lstrip, "lstrip");
5900
5996
  function downcase(v) {
@@ -5911,20 +6007,22 @@ function upcase(v) {
5911
6007
  __name(upcase, "upcase");
5912
6008
  function remove(v, arg) {
5913
6009
  const str = stringify(v);
5914
- this.context.memoryLimit.use(str.length);
5915
- return str.split(stringify(arg)).join("");
6010
+ arg = stringify(arg);
6011
+ this.context.memoryLimit.use(str.length + arg.length);
6012
+ return str.split(arg).join("");
5916
6013
  }
5917
6014
  __name(remove, "remove");
5918
6015
  function remove_first(v, l) {
5919
6016
  const str = stringify(v);
5920
- this.context.memoryLimit.use(str.length);
5921
- return str.replace(stringify(l), "");
6017
+ l = stringify(l);
6018
+ this.context.memoryLimit.use(str.length + l.length);
6019
+ return str.replace(l, "");
5922
6020
  }
5923
6021
  __name(remove_first, "remove_first");
5924
6022
  function remove_last(v, l) {
5925
6023
  const str = stringify(v);
5926
- this.context.memoryLimit.use(str.length);
5927
6024
  const pattern = stringify(l);
6025
+ this.context.memoryLimit.use(str.length + pattern.length);
5928
6026
  const index = str.lastIndexOf(pattern);
5929
6027
  if (index === -1)
5930
6028
  return str;
@@ -5935,10 +6033,15 @@ function rstrip(str, chars) {
5935
6033
  str = stringify(str);
5936
6034
  this.context.memoryLimit.use(str.length);
5937
6035
  if (chars) {
5938
- chars = escapeRegExp(stringify(chars));
5939
- return str.replace(new RegExp(`[${chars}]+$`, "g"), "");
6036
+ chars = stringify(chars);
6037
+ this.context.memoryLimit.use(chars.length);
6038
+ for (let i = str.length - 1, set = new Set(chars); i >= 0; i--) {
6039
+ if (!set.has(str[i]))
6040
+ return str.slice(0, i + 1);
6041
+ }
6042
+ return "";
5940
6043
  }
5941
- return str.replace(/\s+$/, "");
6044
+ return str.trimEnd();
5942
6045
  }
5943
6046
  __name(rstrip, "rstrip");
5944
6047
  function split(v, arg) {
@@ -5954,8 +6057,15 @@ function strip(v, chars) {
5954
6057
  const str = stringify(v);
5955
6058
  this.context.memoryLimit.use(str.length);
5956
6059
  if (chars) {
5957
- chars = escapeRegExp(stringify(chars));
5958
- return str.replace(new RegExp(`^[${chars}]+`, "g"), "").replace(new RegExp(`[${chars}]+$`, "g"), "");
6060
+ const set = new Set(stringify(chars));
6061
+ this.context.memoryLimit.use(set.size);
6062
+ let i = 0;
6063
+ let j = str.length - 1;
6064
+ while (set.has(str[i]))
6065
+ i++;
6066
+ while (j >= i && set.has(str[j]))
6067
+ j--;
6068
+ return str.slice(i, j + 1);
5959
6069
  }
5960
6070
  return str.trim();
5961
6071
  }
@@ -5974,30 +6084,37 @@ function capitalize(str) {
5974
6084
  __name(capitalize, "capitalize");
5975
6085
  function replace(v, pattern, replacement) {
5976
6086
  const str = stringify(v);
5977
- this.context.memoryLimit.use(str.length);
5978
- return str.split(stringify(pattern)).join(replacement);
6087
+ pattern = stringify(pattern);
6088
+ replacement = stringify(replacement);
6089
+ const parts = str.split(pattern);
6090
+ const outputSize = str.length + (parts.length - 1) * (replacement.length - pattern.length);
6091
+ this.context.memoryLimit.use(outputSize);
6092
+ return parts.join(replacement);
5979
6093
  }
5980
6094
  __name(replace, "replace");
5981
6095
  function replace_first(v, arg1, arg2) {
5982
6096
  const str = stringify(v);
5983
- this.context.memoryLimit.use(str.length);
5984
- return str.replace(stringify(arg1), arg2);
6097
+ arg1 = stringify(arg1);
6098
+ arg2 = stringify(arg2);
6099
+ this.context.memoryLimit.use(str.length + arg1.length + arg2.length);
6100
+ return str.replace(arg1, () => arg2);
5985
6101
  }
5986
6102
  __name(replace_first, "replace_first");
5987
6103
  function replace_last(v, arg1, arg2) {
5988
6104
  const str = stringify(v);
5989
- this.context.memoryLimit.use(str.length);
5990
6105
  const pattern = stringify(arg1);
6106
+ const replacement = stringify(arg2);
6107
+ this.context.memoryLimit.use(str.length + pattern.length + replacement.length);
5991
6108
  const index = str.lastIndexOf(pattern);
5992
6109
  if (index === -1)
5993
6110
  return str;
5994
- const replacement = stringify(arg2);
5995
6111
  return str.substring(0, index) + replacement + str.substring(index + pattern.length);
5996
6112
  }
5997
6113
  __name(replace_last, "replace_last");
5998
6114
  function truncate(v, l = 50, o = "...") {
5999
6115
  const str = stringify(v);
6000
- this.context.memoryLimit.use(str.length);
6116
+ o = stringify(o);
6117
+ this.context.memoryLimit.use(str.length + o.length);
6001
6118
  if (str.length <= l)
6002
6119
  return v;
6003
6120
  return str.substring(0, l - o.length) + o;
@@ -6005,7 +6122,8 @@ function truncate(v, l = 50, o = "...") {
6005
6122
  __name(truncate, "truncate");
6006
6123
  function truncatewords(v, words = 15, o = "...") {
6007
6124
  const str = stringify(v);
6008
- this.context.memoryLimit.use(str.length);
6125
+ o = stringify(o);
6126
+ this.context.memoryLimit.use(str.length + o.length);
6009
6127
  const arr = str.split(/\s+/);
6010
6128
  if (words <= 0)
6011
6129
  words = 1;
@@ -6038,7 +6156,8 @@ function number_of_words(input, mode) {
6038
6156
  }
6039
6157
  __name(number_of_words, "number_of_words");
6040
6158
  function array_to_sentence_string(array, connector = "and") {
6041
- this.context.memoryLimit.use(array.length);
6159
+ connector = stringify(connector);
6160
+ this.context.memoryLimit.use(array.length + connector.length);
6042
6161
  switch (array.length) {
6043
6162
  case 0:
6044
6163
  return "";
@@ -6075,7 +6194,80 @@ var stringFilters = /* @__PURE__ */ Object.freeze({
6075
6194
  number_of_words,
6076
6195
  array_to_sentence_string
6077
6196
  });
6078
- var filters = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, htmlFilters), mathFilters), urlFilters), arrayFilters), dateFilters), stringFilters), misc);
6197
+ function base64Encode(str) {
6198
+ return btoa(String.fromCharCode(...new TextEncoder().encode(str)));
6199
+ }
6200
+ __name(base64Encode, "base64Encode");
6201
+ function base64Decode(str) {
6202
+ return new TextDecoder().decode(Uint8Array.from(atob(str), (c) => c.charCodeAt(0)));
6203
+ }
6204
+ __name(base64Decode, "base64Decode");
6205
+ function base64_encode(value) {
6206
+ if (typeof Buffer !== "undefined" && Buffer.isBuffer(value)) {
6207
+ this.context.memoryLimit.use(value.byteLength);
6208
+ return value.toString("base64");
6209
+ }
6210
+ const str = stringify(value);
6211
+ this.context.memoryLimit.use(str.length);
6212
+ return base64Encode(str);
6213
+ }
6214
+ __name(base64_encode, "base64_encode");
6215
+ function base64_decode(value) {
6216
+ const str = stringify(value);
6217
+ this.context.memoryLimit.use(str.length);
6218
+ return base64Decode(str);
6219
+ }
6220
+ __name(base64_decode, "base64_decode");
6221
+ var base64Filters = /* @__PURE__ */ Object.freeze({
6222
+ __proto__: null,
6223
+ base64_encode,
6224
+ base64_decode
6225
+ });
6226
+ function bufferToHex(buffer) {
6227
+ const bytes = new Uint8Array(buffer);
6228
+ let hex = "";
6229
+ for (let i = 0; i < bytes.length; i++) {
6230
+ hex += bytes[i].toString(16).padStart(2, "0");
6231
+ }
6232
+ return hex;
6233
+ }
6234
+ __name(bufferToHex, "bufferToHex");
6235
+ function sha256(str) {
6236
+ return __awaiter(this, void 0, void 0, function* () {
6237
+ const data = new TextEncoder().encode(str);
6238
+ const digest = yield crypto.subtle.digest("SHA-256", data);
6239
+ return bufferToHex(digest);
6240
+ });
6241
+ }
6242
+ __name(sha256, "sha256");
6243
+ function hmacSha256(str, key) {
6244
+ return __awaiter(this, void 0, void 0, function* () {
6245
+ const encoder = new TextEncoder();
6246
+ const cryptoKey = yield crypto.subtle.importKey("raw", encoder.encode(key), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
6247
+ const signature = yield crypto.subtle.sign("HMAC", cryptoKey, encoder.encode(str));
6248
+ return bufferToHex(signature);
6249
+ });
6250
+ }
6251
+ __name(hmacSha256, "hmacSha256");
6252
+ function sha256$1(value) {
6253
+ const str = stringify(value);
6254
+ this.context.memoryLimit.use(str.length);
6255
+ return sha256(str);
6256
+ }
6257
+ __name(sha256$1, "sha256$1");
6258
+ function hmac_sha256(value, key) {
6259
+ const str = stringify(value);
6260
+ const keyStr = stringify(key);
6261
+ this.context.memoryLimit.use(str.length + keyStr.length);
6262
+ return hmacSha256(str, keyStr);
6263
+ }
6264
+ __name(hmac_sha256, "hmac_sha256");
6265
+ var cryptoFilters = /* @__PURE__ */ Object.freeze({
6266
+ __proto__: null,
6267
+ sha256: sha256$1,
6268
+ hmac_sha256
6269
+ });
6270
+ var filters = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, htmlFilters), mathFilters), urlFilters), arrayFilters), dateFilters), stringFilters), base64Filters), cryptoFilters), misc);
6079
6271
  var AssignTag = class extends Tag {
6080
6272
  static {
6081
6273
  __name(this, "AssignTag");
@@ -6138,7 +6330,7 @@ var ForTag = class extends Tag {
6138
6330
  return;
6139
6331
  }
6140
6332
  const continueKey = "continue-" + this.variable + "-" + this.collection.getText();
6141
- ctx.push({ continue: ctx.getRegister(continueKey) });
6333
+ ctx.push(createScope({ continue: ctx.getRegister(continueKey, {}) }));
6142
6334
  const hash = yield this.hash.render(ctx);
6143
6335
  ctx.pop();
6144
6336
  const modifiers = this.liquid.options.orderedFilterParameters ? Object.keys(hash).filter((x) => MODIFIERS.includes(x)) : MODIFIERS.filter((x) => hash[x] !== void 0);
@@ -6150,7 +6342,7 @@ var ForTag = class extends Tag {
6150
6342
  return reversed(collection2);
6151
6343
  }, collection);
6152
6344
  ctx.setRegister(continueKey, (hash["offset"] || 0) + collection.length);
6153
- const scope = { forloop: new ForloopDrop(collection.length, this.collection.getText(), this.variable) };
6345
+ const scope = createScope({ forloop: new ForloopDrop(collection.length, this.collection.getText(), this.variable) });
6154
6346
  ctx.push(scope);
6155
6347
  for (const item of collection) {
6156
6348
  scope[this.variable] = item;
@@ -6346,7 +6538,11 @@ var RenderTag = class extends Tag {
6346
6538
  alias = tokenizer.readIdentifier();
6347
6539
  else
6348
6540
  tokenizer.p = beforeAs;
6349
- this[keyword.content] = { value, alias: alias && alias.content };
6541
+ const binding = { value, alias: alias && alias.content };
6542
+ if (keyword.content === "with")
6543
+ this.with = binding;
6544
+ else
6545
+ this.forBinding = binding;
6350
6546
  tokenizer.skipBlank();
6351
6547
  if (tokenizer.peek() === ",")
6352
6548
  tokenizer.advance();
@@ -6361,56 +6557,56 @@ var RenderTag = class extends Tag {
6361
6557
  }
6362
6558
  *render(ctx, emitter) {
6363
6559
  const { liquid, hash } = this;
6364
- const filepath = yield renderFilePath(this["file"], ctx, liquid);
6560
+ const filepath = yield renderFilePath(this.file, ctx, liquid);
6365
6561
  assert(filepath, () => `illegal file path "${filepath}"`);
6366
6562
  const childCtx = ctx.spawn();
6367
6563
  const scope = childCtx.bottom();
6368
6564
  __assign(scope, yield hash.render(ctx));
6369
- if (this["with"]) {
6370
- const { value, alias } = this["with"];
6565
+ if (this.with) {
6566
+ const { value, alias } = this.with;
6371
6567
  scope[alias || filepath] = yield evalToken(value, ctx);
6372
6568
  }
6373
- if (this["for"]) {
6374
- const { value, alias } = this["for"];
6569
+ if (this.forBinding) {
6570
+ const { value, alias } = this.forBinding;
6375
6571
  const collection = toEnumerable(yield evalToken(value, ctx));
6376
6572
  scope["forloop"] = new ForloopDrop(collection.length, value.getText(), alias);
6377
6573
  for (const item of collection) {
6378
6574
  scope[alias] = item;
6379
- const templates = yield liquid._parsePartialFile(filepath, childCtx.sync, this["currentFile"]);
6575
+ const templates = yield liquid._parsePartialFile(filepath, childCtx.sync, this.currentFile);
6380
6576
  yield liquid.renderer.renderTemplates(templates, childCtx, emitter);
6381
6577
  scope["forloop"].next();
6382
6578
  }
6383
6579
  } else {
6384
- const templates = yield liquid._parsePartialFile(filepath, childCtx.sync, this["currentFile"]);
6580
+ const templates = yield liquid._parsePartialFile(filepath, childCtx.sync, this.currentFile);
6385
6581
  yield liquid.renderer.renderTemplates(templates, childCtx, emitter);
6386
6582
  }
6387
6583
  }
6388
6584
  *children(partials, sync) {
6389
- if (partials && isString(this["file"])) {
6390
- return yield this.liquid._parsePartialFile(this["file"], sync, this["currentFile"]);
6585
+ if (partials && isString(this.file)) {
6586
+ return yield this.liquid._parsePartialFile(this.file, sync, this.currentFile);
6391
6587
  }
6392
6588
  return [];
6393
6589
  }
6394
6590
  partialScope() {
6395
- if (isString(this["file"])) {
6396
- const names = Object.keys(this.hash.hash);
6397
- if (this["with"]) {
6398
- const { value, alias } = this["with"];
6591
+ if (isString(this.file)) {
6592
+ const names2 = Object.keys(this.hash.hash);
6593
+ if (this.with) {
6594
+ const { value, alias } = this.with;
6399
6595
  if (isString(alias)) {
6400
- names.push([alias, value]);
6596
+ names2.push([alias, value]);
6401
6597
  } else if (isString(this.file)) {
6402
- names.push([this.file, value]);
6598
+ names2.push([this.file, value]);
6403
6599
  }
6404
6600
  }
6405
- if (this["for"]) {
6406
- const { value, alias } = this["for"];
6601
+ if (this.forBinding) {
6602
+ const { value, alias } = this.forBinding;
6407
6603
  if (isString(alias)) {
6408
- names.push([alias, value]);
6604
+ names2.push([alias, value]);
6409
6605
  } else if (isString(this.file)) {
6410
- names.push([this.file, value]);
6606
+ names2.push([this.file, value]);
6411
6607
  }
6412
6608
  }
6413
- return { name: this["file"], isolated: true, scope: names };
6609
+ return { name: this.file, isolated: true, scope: names2 };
6414
6610
  }
6415
6611
  }
6416
6612
  *arguments() {
@@ -6419,14 +6615,14 @@ var RenderTag = class extends Tag {
6419
6615
  yield v;
6420
6616
  }
6421
6617
  }
6422
- if (this["with"]) {
6423
- const { value } = this["with"];
6618
+ if (this.with) {
6619
+ const { value } = this.with;
6424
6620
  if (isValueToken(value)) {
6425
6621
  yield value;
6426
6622
  }
6427
6623
  }
6428
- if (this["for"]) {
6429
- const { value } = this["for"];
6624
+ if (this.forBinding) {
6625
+ const { value } = this.forBinding;
6430
6626
  if (isValueToken(value)) {
6431
6627
  yield value;
6432
6628
  }
@@ -6471,8 +6667,8 @@ var IncludeTag = class extends Tag {
6471
6667
  constructor(token, remainTokens, liquid, parser) {
6472
6668
  super(token, remainTokens, liquid);
6473
6669
  const { tokenizer } = token;
6474
- this["file"] = parseFilePath(tokenizer, this.liquid, parser);
6475
- this["currentFile"] = token.file;
6670
+ this.file = parseFilePath(tokenizer, this.liquid, parser);
6671
+ this.currentFile = token.file;
6476
6672
  const begin = tokenizer.p;
6477
6673
  const withStr = tokenizer.readIdentifier();
6478
6674
  if (withStr.content === "with") {
@@ -6488,44 +6684,44 @@ var IncludeTag = class extends Tag {
6488
6684
  *render(ctx, emitter) {
6489
6685
  const { liquid, hash, withVar } = this;
6490
6686
  const { renderer } = liquid;
6491
- const filepath = yield renderFilePath(this["file"], ctx, liquid);
6687
+ const filepath = yield renderFilePath(this.file, ctx, liquid);
6492
6688
  assert(filepath, () => `illegal file path "${filepath}"`);
6493
6689
  const saved = ctx.saveRegister("blocks", "blockMode");
6494
6690
  ctx.setRegister("blocks", {});
6495
6691
  ctx.setRegister("blockMode", BlockMode.OUTPUT);
6496
- const scope = yield hash.render(ctx);
6692
+ const scope = createScope(yield hash.render(ctx));
6497
6693
  if (withVar)
6498
6694
  scope[filepath] = yield evalToken(withVar, ctx);
6499
- const templates = yield liquid._parsePartialFile(filepath, ctx.sync, this["currentFile"]);
6500
- ctx.push(ctx.opts.jekyllInclude ? { include: scope } : scope);
6695
+ const templates = yield liquid._parsePartialFile(filepath, ctx.sync, this.currentFile);
6696
+ ctx.push(ctx.opts.jekyllInclude ? createScope({ include: scope }) : scope);
6501
6697
  yield renderer.renderTemplates(templates, ctx, emitter);
6502
6698
  ctx.pop();
6503
6699
  ctx.restoreRegister(saved);
6504
6700
  }
6505
6701
  *children(partials, sync) {
6506
- if (partials && isString(this["file"])) {
6507
- return yield this.liquid._parsePartialFile(this["file"], sync, this["currentFile"]);
6702
+ if (partials && isString(this.file)) {
6703
+ return yield this.liquid._parsePartialFile(this.file, sync, this.currentFile);
6508
6704
  }
6509
6705
  return [];
6510
6706
  }
6511
6707
  partialScope() {
6512
- if (isString(this["file"])) {
6513
- let names;
6708
+ if (isString(this.file)) {
6709
+ let names2;
6514
6710
  if (this.liquid.options.jekyllInclude) {
6515
- names = ["include"];
6711
+ names2 = ["include"];
6516
6712
  } else {
6517
- names = Object.keys(this.hash.hash);
6713
+ names2 = Object.keys(this.hash.hash);
6518
6714
  if (this.withVar) {
6519
- names.push([this["file"], this.withVar]);
6715
+ names2.push([this.file, this.withVar]);
6520
6716
  }
6521
6717
  }
6522
- return { name: this["file"], isolated: false, scope: names };
6718
+ return { name: this.file, isolated: false, scope: names2 };
6523
6719
  }
6524
6720
  }
6525
6721
  *arguments() {
6526
6722
  yield* Object.values(this.hash.hash).filter(isValueToken);
6527
- if (isValueToken(this["file"])) {
6528
- yield this["file"];
6723
+ if (isValueToken(this.file)) {
6724
+ yield this.file;
6529
6725
  }
6530
6726
  if (isValueToken(this.withVar)) {
6531
6727
  yield this.withVar;
@@ -6579,7 +6775,7 @@ var CycleTag = class extends Tag {
6579
6775
  *render(ctx, emitter) {
6580
6776
  const group = yield evalToken(this.group, ctx);
6581
6777
  const fingerprint = `cycle:${group}:` + this.candidates.join(",");
6582
- const groups = ctx.getRegister("cycle");
6778
+ const groups = ctx.getRegister("cycle", {});
6583
6779
  let idx = groups[fingerprint];
6584
6780
  if (idx === void 0) {
6585
6781
  idx = groups[fingerprint] = 0;
@@ -6675,7 +6871,7 @@ var LayoutTag = class extends Tag {
6675
6871
  constructor(token, remainTokens, liquid, parser) {
6676
6872
  super(token, remainTokens, liquid);
6677
6873
  this.file = parseFilePath(this.tokenizer, this.liquid, parser);
6678
- this["currentFile"] = token.file;
6874
+ this.currentFile = token.file;
6679
6875
  this.args = new Hash(this.tokenizer, liquid.options.keyValueSeparator);
6680
6876
  this.templates = parser.parseTokens(remainTokens);
6681
6877
  }
@@ -6689,21 +6885,21 @@ var LayoutTag = class extends Tag {
6689
6885
  }
6690
6886
  const filepath = yield renderFilePath(this.file, ctx, liquid);
6691
6887
  assert(filepath, () => `illegal file path "${filepath}"`);
6692
- const templates = yield liquid._parseLayoutFile(filepath, ctx.sync, this["currentFile"]);
6888
+ const templates = yield liquid._parseLayoutFile(filepath, ctx.sync, this.currentFile);
6693
6889
  ctx.setRegister("blockMode", BlockMode.STORE);
6694
6890
  const html = yield renderer.renderTemplates(this.templates, ctx);
6695
- const blocks = ctx.getRegister("blocks");
6891
+ const blocks = ctx.getRegister("blocks", {});
6696
6892
  if (blocks[""] === void 0)
6697
6893
  blocks[""] = (parent, emitter2) => emitter2.write(html);
6698
6894
  ctx.setRegister("blockMode", BlockMode.OUTPUT);
6699
- ctx.push(yield args.render(ctx));
6895
+ ctx.push(createScope(yield args.render(ctx)));
6700
6896
  yield renderer.renderTemplates(templates, ctx, emitter);
6701
6897
  ctx.pop();
6702
6898
  }
6703
6899
  *children(partials) {
6704
6900
  const templates = this.templates.slice();
6705
6901
  if (partials && isString(this.file)) {
6706
- templates.push(...yield this.liquid._parsePartialFile(this.file, true, this["currentFile"]));
6902
+ templates.push(...yield this.liquid._parsePartialFile(this.file, true, this.currentFile));
6707
6903
  }
6708
6904
  return templates;
6709
6905
  }
@@ -6744,18 +6940,24 @@ var BlockTag = class extends Tag {
6744
6940
  *render(ctx, emitter) {
6745
6941
  const blockRender = this.getBlockRender(ctx);
6746
6942
  if (ctx.getRegister("blockMode") === BlockMode.STORE) {
6747
- ctx.getRegister("blocks")[this.block] = blockRender;
6943
+ ctx.getRegister("blocks", {})[this.block] = blockRender;
6748
6944
  } else {
6749
6945
  yield blockRender(new BlockDrop(), emitter);
6750
6946
  }
6751
6947
  }
6752
6948
  getBlockRender(ctx) {
6949
+ const self = this;
6753
6950
  const { liquid, templates } = this;
6754
- const renderChild = ctx.getRegister("blocks")[this.block];
6951
+ const renderChild = ctx.getRegister("blocks", {})[this.block];
6755
6952
  const renderCurrent = /* @__PURE__ */ __name(function* (superBlock, emitter) {
6756
- ctx.push({ block: superBlock });
6953
+ const stack = ctx.getRegister("blockStack", []);
6954
+ if (stack.includes(self))
6955
+ throw new Error("block tag cannot be nested");
6956
+ stack.push(self);
6957
+ ctx.push(createScope({ block: superBlock }));
6757
6958
  yield liquid.renderer.renderTemplates(templates, ctx, emitter);
6758
6959
  ctx.pop();
6960
+ stack.pop();
6759
6961
  }, "renderCurrent");
6760
6962
  return renderChild ? (superBlock, emitter) => renderChild(new BlockDrop((emitter2) => renderCurrent(superBlock, emitter2)), emitter) : renderCurrent;
6761
6963
  }
@@ -6842,7 +7044,7 @@ var TablerowTag = class extends Tag {
6842
7044
  const cols = args.cols || collection.length;
6843
7045
  const r = this.liquid.renderer;
6844
7046
  const tablerowloop = new TablerowloopDrop(collection.length, cols, this.collection.getText(), this.variable);
6845
- const scope = { tablerowloop };
7047
+ const scope = createScope({ tablerowloop });
6846
7048
  ctx.push(scope);
6847
7049
  for (let idx = 0; idx < collection.length; idx++, tablerowloop.next()) {
6848
7050
  scope[this.variable] = collection[idx];
@@ -7030,8 +7232,8 @@ var Liquid = class _Liquid {
7030
7232
  }
7031
7233
  constructor(opts = {}) {
7032
7234
  this.renderer = new Render();
7033
- this.filters = {};
7034
- this.tags = {};
7235
+ this.filters = /* @__PURE__ */ Object.create(null);
7236
+ this.tags = /* @__PURE__ */ Object.create(null);
7035
7237
  this.options = normalize(opts);
7036
7238
  this.parser = new Parser(this);
7037
7239
  forOwn(tags, (conf, name) => this.registerTag(name, conf));
@@ -7233,21 +7435,289 @@ var Liquid = class _Liquid {
7233
7435
  // ../../src/Engines/Liquid.js
7234
7436
  var import_eleventy_utils = __toESM(require_eleventy_utils(), 1);
7235
7437
 
7236
- // ../../node_modules/@11ty/package-bundler/shims/debug.js
7237
- function debug_default() {
7238
- return function() {
7438
+ // ../../node_modules/obug/dist/core.js
7439
+ function coerce(value) {
7440
+ if (value instanceof Error) return value.stack || value.message;
7441
+ return value;
7442
+ }
7443
+ __name(coerce, "coerce");
7444
+ function selectColor(colors2, namespace) {
7445
+ let hash = 0;
7446
+ for (let i = 0; i < namespace.length; i++) {
7447
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
7448
+ hash |= 0;
7449
+ }
7450
+ return colors2[Math.abs(hash) % colors2.length];
7451
+ }
7452
+ __name(selectColor, "selectColor");
7453
+ function matchesTemplate(search2, template) {
7454
+ let searchIndex = 0;
7455
+ let templateIndex = 0;
7456
+ let starIndex = -1;
7457
+ let matchIndex = 0;
7458
+ while (searchIndex < search2.length) if (templateIndex < template.length && (template[templateIndex] === search2[searchIndex] || template[templateIndex] === "*")) if (template[templateIndex] === "*") {
7459
+ starIndex = templateIndex;
7460
+ matchIndex = searchIndex;
7461
+ templateIndex++;
7462
+ } else {
7463
+ searchIndex++;
7464
+ templateIndex++;
7465
+ }
7466
+ else if (starIndex !== -1) {
7467
+ templateIndex = starIndex + 1;
7468
+ matchIndex++;
7469
+ searchIndex = matchIndex;
7470
+ } else return false;
7471
+ while (templateIndex < template.length && template[templateIndex] === "*") templateIndex++;
7472
+ return templateIndex === template.length;
7473
+ }
7474
+ __name(matchesTemplate, "matchesTemplate");
7475
+ function humanize(value) {
7476
+ if (value >= 1e3) return `${(value / 1e3).toFixed(1)}s`;
7477
+ return `${value}ms`;
7478
+ }
7479
+ __name(humanize, "humanize");
7480
+ var globalNamespaces = "";
7481
+ function createDebug(namespace, options) {
7482
+ let prevTime;
7483
+ let enableOverride;
7484
+ let namespacesCache;
7485
+ let enabledCache;
7486
+ const debug2 = /* @__PURE__ */ __name((...args) => {
7487
+ if (!debug2.enabled) return;
7488
+ const curr = Date.now();
7489
+ const diff = curr - (prevTime || curr);
7490
+ prevTime = curr;
7491
+ args[0] = coerce(args[0]);
7492
+ if (typeof args[0] !== "string") args.unshift("%O");
7493
+ let index = 0;
7494
+ args[0] = args[0].replace(/%([a-z%])/gi, (match, format2) => {
7495
+ if (match === "%%") return "%";
7496
+ index++;
7497
+ const formatter = options.formatters[format2];
7498
+ if (typeof formatter === "function") {
7499
+ const value = args[index];
7500
+ match = formatter.call(debug2, value);
7501
+ args.splice(index, 1);
7502
+ index--;
7503
+ }
7504
+ return match;
7505
+ });
7506
+ options.formatArgs.call(debug2, diff, args);
7507
+ debug2.log(...args);
7508
+ }, "debug");
7509
+ debug2.extend = function(namespace2, delimiter = ":") {
7510
+ return createDebug(this.namespace + delimiter + namespace2, {
7511
+ useColors: this.useColors,
7512
+ color: this.color,
7513
+ formatArgs: this.formatArgs,
7514
+ formatters: this.formatters,
7515
+ inspectOpts: this.inspectOpts,
7516
+ log: this.log,
7517
+ humanize: this.humanize
7518
+ });
7239
7519
  };
7520
+ Object.assign(debug2, options);
7521
+ debug2.namespace = namespace;
7522
+ Object.defineProperty(debug2, "enabled", {
7523
+ enumerable: true,
7524
+ configurable: false,
7525
+ get: /* @__PURE__ */ __name(() => {
7526
+ if (enableOverride != null) return enableOverride;
7527
+ if (namespacesCache !== globalNamespaces) {
7528
+ namespacesCache = globalNamespaces;
7529
+ enabledCache = enabled(namespace);
7530
+ }
7531
+ return enabledCache;
7532
+ }, "get"),
7533
+ set: /* @__PURE__ */ __name((v) => {
7534
+ enableOverride = v;
7535
+ }, "set")
7536
+ });
7537
+ return debug2;
7538
+ }
7539
+ __name(createDebug, "createDebug");
7540
+ var names = [];
7541
+ var skips = [];
7542
+ function enable(namespaces2) {
7543
+ globalNamespaces = namespaces2;
7544
+ names = [];
7545
+ skips = [];
7546
+ const split2 = globalNamespaces.trim().replace(/\s+/g, ",").split(",").filter(Boolean);
7547
+ for (const ns of split2) if (ns[0] === "-") skips.push(ns.slice(1));
7548
+ else names.push(ns);
7549
+ }
7550
+ __name(enable, "enable");
7551
+ function enabled(name) {
7552
+ for (const skip of skips) if (matchesTemplate(name, skip)) return false;
7553
+ for (const ns of names) if (matchesTemplate(name, ns)) return true;
7554
+ return false;
7555
+ }
7556
+ __name(enabled, "enabled");
7557
+
7558
+ // ../../node_modules/obug/dist/browser.js
7559
+ var colors = [
7560
+ "#0000CC",
7561
+ "#0000FF",
7562
+ "#0033CC",
7563
+ "#0033FF",
7564
+ "#0066CC",
7565
+ "#0066FF",
7566
+ "#0099CC",
7567
+ "#0099FF",
7568
+ "#00CC00",
7569
+ "#00CC33",
7570
+ "#00CC66",
7571
+ "#00CC99",
7572
+ "#00CCCC",
7573
+ "#00CCFF",
7574
+ "#3300CC",
7575
+ "#3300FF",
7576
+ "#3333CC",
7577
+ "#3333FF",
7578
+ "#3366CC",
7579
+ "#3366FF",
7580
+ "#3399CC",
7581
+ "#3399FF",
7582
+ "#33CC00",
7583
+ "#33CC33",
7584
+ "#33CC66",
7585
+ "#33CC99",
7586
+ "#33CCCC",
7587
+ "#33CCFF",
7588
+ "#6600CC",
7589
+ "#6600FF",
7590
+ "#6633CC",
7591
+ "#6633FF",
7592
+ "#66CC00",
7593
+ "#66CC33",
7594
+ "#9900CC",
7595
+ "#9900FF",
7596
+ "#9933CC",
7597
+ "#9933FF",
7598
+ "#99CC00",
7599
+ "#99CC33",
7600
+ "#CC0000",
7601
+ "#CC0033",
7602
+ "#CC0066",
7603
+ "#CC0099",
7604
+ "#CC00CC",
7605
+ "#CC00FF",
7606
+ "#CC3300",
7607
+ "#CC3333",
7608
+ "#CC3366",
7609
+ "#CC3399",
7610
+ "#CC33CC",
7611
+ "#CC33FF",
7612
+ "#CC6600",
7613
+ "#CC6633",
7614
+ "#CC9900",
7615
+ "#CC9933",
7616
+ "#CCCC00",
7617
+ "#CCCC33",
7618
+ "#FF0000",
7619
+ "#FF0033",
7620
+ "#FF0066",
7621
+ "#FF0099",
7622
+ "#FF00CC",
7623
+ "#FF00FF",
7624
+ "#FF3300",
7625
+ "#FF3333",
7626
+ "#FF3366",
7627
+ "#FF3399",
7628
+ "#FF33CC",
7629
+ "#FF33FF",
7630
+ "#FF6600",
7631
+ "#FF6633",
7632
+ "#FF9900",
7633
+ "#FF9933",
7634
+ "#FFCC00",
7635
+ "#FFCC33"
7636
+ ];
7637
+ function formatArgs(diff, args) {
7638
+ const { useColors } = this;
7639
+ args[0] = `${(useColors ? "%c" : "") + this.namespace + (useColors ? " %c" : " ") + args[0] + (useColors ? "%c " : " ")}+${this.humanize(diff)}`;
7640
+ if (!useColors) return;
7641
+ const c = `color: ${this.color}`;
7642
+ args.splice(1, 0, c, "color: inherit");
7643
+ let index = 0;
7644
+ let lastC = 0;
7645
+ args[0].replace(/%[a-z%]/gi, (match) => {
7646
+ if (match === "%%") return;
7647
+ index++;
7648
+ if (match === "%c") lastC = index;
7649
+ });
7650
+ args.splice(lastC, 0, c);
7651
+ }
7652
+ __name(formatArgs, "formatArgs");
7653
+ var log = console.debug || console.log || (() => {
7654
+ });
7655
+ var storage = localstorage();
7656
+ var defaultOptions2 = {
7657
+ useColors: true,
7658
+ formatArgs,
7659
+ formatters: {
7660
+ /**
7661
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
7662
+ */
7663
+ j(v) {
7664
+ try {
7665
+ return JSON.stringify(v);
7666
+ } catch (error) {
7667
+ return `[UnexpectedJSONParseError]: ${error.message}`;
7668
+ }
7669
+ }
7670
+ },
7671
+ inspectOpts: {},
7672
+ humanize,
7673
+ log
7674
+ };
7675
+ function createDebug2(namespace, options) {
7676
+ var _ref;
7677
+ const color = (_ref = options && options.color) !== null && _ref !== void 0 ? _ref : selectColor(colors, namespace);
7678
+ return createDebug(namespace, Object.assign(defaultOptions2, { color }, options));
7240
7679
  }
7241
- __name(debug_default, "default");
7680
+ __name(createDebug2, "createDebug");
7681
+ function localstorage() {
7682
+ try {
7683
+ return localStorage;
7684
+ } catch (_unused) {
7685
+ }
7686
+ }
7687
+ __name(localstorage, "localstorage");
7688
+ function load() {
7689
+ let r;
7690
+ try {
7691
+ r = storage.getItem("debug") || storage.getItem("DEBUG");
7692
+ } catch (_unused2) {
7693
+ }
7694
+ if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
7695
+ return r || "";
7696
+ }
7697
+ __name(load, "load");
7698
+ enable(load());
7699
+
7700
+ // ../../src/Util/IsBuildAwesome.js
7701
+ function isUsingBuildAwesome() {
7702
+ return process?.env?.BUILDAWESOME_PACKAGE === "@awesome.me/buildawesome";
7703
+ }
7704
+ __name(isUsingBuildAwesome, "isUsingBuildAwesome");
7242
7705
 
7243
- // ../../src/Errors/EleventyBaseError.js
7244
- var EleventyBaseError = class extends Error {
7706
+ // ../../src/Util/DebugLogUtil.js
7707
+ var PREFIX = isUsingBuildAwesome() ? "BuildAwesome:" : "Eleventy:";
7708
+ function createDebug3(name) {
7709
+ return createDebug2(`${PREFIX}:${name}`);
7710
+ }
7711
+ __name(createDebug3, "createDebug");
7712
+
7713
+ // ../../src/Errors/BaseError.js
7714
+ var BaseError = class extends Error {
7245
7715
  static {
7246
- __name(this, "EleventyBaseError");
7716
+ __name(this, "BaseError");
7247
7717
  }
7248
7718
  /**
7249
7719
  * @param {string} message - The error message to display.
7250
- * @param {unknown} [originalError] - The original error caught.
7720
+ * @param {Error} [originalError] - The original error caught.
7251
7721
  */
7252
7722
  constructor(message, originalError) {
7253
7723
  if (originalError) {
@@ -7264,15 +7734,14 @@ var EleventyBaseError = class extends Error {
7264
7734
  }
7265
7735
  }
7266
7736
  };
7267
- var EleventyBaseError_default = EleventyBaseError;
7268
7737
 
7269
7738
  // ../../src/Engines/TemplateEngine.js
7270
- var TemplateEngineConfigError = class extends EleventyBaseError_default {
7739
+ var TemplateEngineConfigError = class extends BaseError {
7271
7740
  static {
7272
7741
  __name(this, "TemplateEngineConfigError");
7273
7742
  }
7274
7743
  };
7275
- var debug = debug_default("Eleventy:TemplateEngine");
7744
+ var debug = createDebug3("TemplateEngine");
7276
7745
  var AMENDED_INSTANCES = /* @__PURE__ */ new Set();
7277
7746
  var TemplateEngine = class {
7278
7747
  static {
@@ -7512,9 +7981,10 @@ var Liquid2 = class _Liquid extends TemplateEngine {
7512
7981
  root: [this.dirs.includes, this.dirs.input],
7513
7982
  // supplemented in compile with inputPath below
7514
7983
  extname: ".liquid",
7515
- strictFilters: true
7516
- // TODO?
7984
+ strictFilters: true,
7517
7985
  // cache: true,
7986
+ jsTruthy: true
7987
+ // Breaking in v4 #3507
7518
7988
  };
7519
7989
  let options = Object.assign(defaults, this.liquidOptions || {});
7520
7990
  return options;
@@ -7704,6 +8174,7 @@ var Liquid2 = class _Liquid extends TemplateEngine {
7704
8174
  }
7705
8175
  async compile(str, inputPath) {
7706
8176
  let engine = this.liquidLib;
8177
+ let liquidOptions = this.liquidOptions;
7707
8178
  let tmplReady = engine.parse(str, inputPath);
7708
8179
  let options = {};
7709
8180
  if (!inputPath || inputPath === "liquid" || inputPath === "md") {
@@ -7712,6 +8183,15 @@ var Liquid2 = class _Liquid extends TemplateEngine {
7712
8183
  }
7713
8184
  return async function(data) {
7714
8185
  let tmpl = await tmplReady;
8186
+ options.globals = Object.assign(
8187
+ {
8188
+ page: data?.page,
8189
+ eleventy: data?.eleventy,
8190
+ buildawesome: data?.buildawesome,
8191
+ collections: data?.collections
8192
+ },
8193
+ liquidOptions?.globals
8194
+ );
7715
8195
  return engine.render(tmpl, data, options);
7716
8196
  };
7717
8197
  }