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

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 (Build Awesome) v4.0.0-alpha.10 (@11ty/client/liquid Engine Bundle) */
1
+ /*! Eleventy (Build Awesome) v4.0.0-alpha.11 (@11ty/client/liquid Engine Bundle) */
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -49,559 +49,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
49
49
  ));
50
50
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
51
51
 
52
- // ../../node_modules/moo/moo.js
53
- var require_moo = __commonJS({
54
- "../../node_modules/moo/moo.js"(exports, module) {
55
- (function(root, factory) {
56
- if (typeof define === "function" && define.amd) {
57
- define([], factory);
58
- } else if (typeof module === "object" && module.exports) {
59
- module.exports = factory();
60
- } else {
61
- root.moo = factory();
62
- }
63
- })(exports, function() {
64
- "use strict";
65
- var hasOwnProperty2 = Object.prototype.hasOwnProperty;
66
- var toString2 = Object.prototype.toString;
67
- var hasSticky = typeof new RegExp().sticky === "boolean";
68
- function isRegExp(o) {
69
- return o && toString2.call(o) === "[object RegExp]";
70
- }
71
- __name(isRegExp, "isRegExp");
72
- function isObject2(o) {
73
- return o && typeof o === "object" && !isRegExp(o) && !Array.isArray(o);
74
- }
75
- __name(isObject2, "isObject");
76
- function reEscape(s) {
77
- return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
78
- }
79
- __name(reEscape, "reEscape");
80
- function reGroups(s) {
81
- var re = new RegExp("|" + s);
82
- return re.exec("").length - 1;
83
- }
84
- __name(reGroups, "reGroups");
85
- function reCapture(s) {
86
- return "(" + s + ")";
87
- }
88
- __name(reCapture, "reCapture");
89
- function reUnion(regexps) {
90
- if (!regexps.length) return "(?!)";
91
- var source = regexps.map(function(s) {
92
- return "(?:" + s + ")";
93
- }).join("|");
94
- return "(?:" + source + ")";
95
- }
96
- __name(reUnion, "reUnion");
97
- function regexpOrLiteral(obj) {
98
- if (typeof obj === "string") {
99
- return "(?:" + reEscape(obj) + ")";
100
- } else if (isRegExp(obj)) {
101
- if (obj.ignoreCase) throw new Error("RegExp /i flag not allowed");
102
- if (obj.global) throw new Error("RegExp /g flag is implied");
103
- if (obj.sticky) throw new Error("RegExp /y flag is implied");
104
- if (obj.multiline) throw new Error("RegExp /m flag is implied");
105
- return obj.source;
106
- } else {
107
- throw new Error("Not a pattern: " + obj);
108
- }
109
- }
110
- __name(regexpOrLiteral, "regexpOrLiteral");
111
- function pad2(s, length) {
112
- if (s.length > length) {
113
- return s;
114
- }
115
- return Array(length - s.length + 1).join(" ") + s;
116
- }
117
- __name(pad2, "pad");
118
- function lastNLines(string, numLines) {
119
- var position = string.length;
120
- var lineBreaks = 0;
121
- while (true) {
122
- var idx = string.lastIndexOf("\n", position - 1);
123
- if (idx === -1) {
124
- break;
125
- } else {
126
- lineBreaks++;
127
- }
128
- position = idx;
129
- if (lineBreaks === numLines) {
130
- break;
131
- }
132
- if (position === 0) {
133
- break;
134
- }
135
- }
136
- var startPosition = lineBreaks < numLines ? 0 : position + 1;
137
- return string.substring(startPosition).split("\n");
138
- }
139
- __name(lastNLines, "lastNLines");
140
- function objectToRules(object) {
141
- var keys = Object.getOwnPropertyNames(object);
142
- var result = [];
143
- for (var i = 0; i < keys.length; i++) {
144
- var key = keys[i];
145
- var thing = object[key];
146
- var rules = [].concat(thing);
147
- if (key === "include") {
148
- for (var j = 0; j < rules.length; j++) {
149
- result.push({ include: rules[j] });
150
- }
151
- continue;
152
- }
153
- var match = [];
154
- rules.forEach(function(rule) {
155
- if (isObject2(rule)) {
156
- if (match.length) result.push(ruleOptions(key, match));
157
- result.push(ruleOptions(key, rule));
158
- match = [];
159
- } else {
160
- match.push(rule);
161
- }
162
- });
163
- if (match.length) result.push(ruleOptions(key, match));
164
- }
165
- return result;
166
- }
167
- __name(objectToRules, "objectToRules");
168
- function arrayToRules(array) {
169
- var result = [];
170
- for (var i = 0; i < array.length; i++) {
171
- var obj = array[i];
172
- if (obj.include) {
173
- var include = [].concat(obj.include);
174
- for (var j = 0; j < include.length; j++) {
175
- result.push({ include: include[j] });
176
- }
177
- continue;
178
- }
179
- if (!obj.type) {
180
- throw new Error("Rule has no type: " + JSON.stringify(obj));
181
- }
182
- result.push(ruleOptions(obj.type, obj));
183
- }
184
- return result;
185
- }
186
- __name(arrayToRules, "arrayToRules");
187
- function ruleOptions(type, obj) {
188
- if (!isObject2(obj)) {
189
- obj = { match: obj };
190
- }
191
- if (obj.include) {
192
- throw new Error("Matching rules cannot also include states");
193
- }
194
- var options = {
195
- defaultType: type,
196
- lineBreaks: !!obj.error || !!obj.fallback,
197
- pop: false,
198
- next: null,
199
- push: null,
200
- error: false,
201
- fallback: false,
202
- value: null,
203
- type: null,
204
- shouldThrow: false
205
- };
206
- for (var key in obj) {
207
- if (hasOwnProperty2.call(obj, key)) {
208
- options[key] = obj[key];
209
- }
210
- }
211
- if (typeof options.type === "string" && type !== options.type) {
212
- throw new Error("Type transform cannot be a string (type '" + options.type + "' for token '" + type + "')");
213
- }
214
- var match = options.match;
215
- options.match = Array.isArray(match) ? match : match ? [match] : [];
216
- options.match.sort(function(a, b) {
217
- return isRegExp(a) && isRegExp(b) ? 0 : isRegExp(b) ? -1 : isRegExp(a) ? 1 : b.length - a.length;
218
- });
219
- return options;
220
- }
221
- __name(ruleOptions, "ruleOptions");
222
- function toRules(spec) {
223
- return Array.isArray(spec) ? arrayToRules(spec) : objectToRules(spec);
224
- }
225
- __name(toRules, "toRules");
226
- var defaultErrorRule = ruleOptions("error", { lineBreaks: true, shouldThrow: true });
227
- function compileRules(rules, hasStates) {
228
- var errorRule = null;
229
- var fast = /* @__PURE__ */ Object.create(null);
230
- var fastAllowed = true;
231
- var unicodeFlag = null;
232
- var groups = [];
233
- var parts = [];
234
- for (var i = 0; i < rules.length; i++) {
235
- if (rules[i].fallback) {
236
- fastAllowed = false;
237
- }
238
- }
239
- for (var i = 0; i < rules.length; i++) {
240
- var options = rules[i];
241
- if (options.include) {
242
- throw new Error("Inheritance is not allowed in stateless lexers");
243
- }
244
- if (options.error || options.fallback) {
245
- if (errorRule) {
246
- if (!options.fallback === !errorRule.fallback) {
247
- throw new Error("Multiple " + (options.fallback ? "fallback" : "error") + " rules not allowed (for token '" + options.defaultType + "')");
248
- } else {
249
- throw new Error("fallback and error are mutually exclusive (for token '" + options.defaultType + "')");
250
- }
251
- }
252
- errorRule = options;
253
- }
254
- var match = options.match.slice();
255
- if (fastAllowed) {
256
- while (match.length && typeof match[0] === "string" && match[0].length === 1) {
257
- var word = match.shift();
258
- fast[word.charCodeAt(0)] = options;
259
- }
260
- }
261
- if (options.pop || options.push || options.next) {
262
- if (!hasStates) {
263
- throw new Error("State-switching options are not allowed in stateless lexers (for token '" + options.defaultType + "')");
264
- }
265
- if (options.fallback) {
266
- throw new Error("State-switching options are not allowed on fallback tokens (for token '" + options.defaultType + "')");
267
- }
268
- }
269
- if (match.length === 0) {
270
- continue;
271
- }
272
- fastAllowed = false;
273
- groups.push(options);
274
- for (var j = 0; j < match.length; j++) {
275
- var obj = match[j];
276
- if (!isRegExp(obj)) {
277
- continue;
278
- }
279
- if (unicodeFlag === null) {
280
- unicodeFlag = obj.unicode;
281
- } else if (unicodeFlag !== obj.unicode && options.fallback === false) {
282
- throw new Error("If one rule is /u then all must be");
283
- }
284
- }
285
- var pat = reUnion(match.map(regexpOrLiteral));
286
- var regexp = new RegExp(pat);
287
- if (regexp.test("")) {
288
- throw new Error("RegExp matches empty string: " + regexp);
289
- }
290
- var groupCount = reGroups(pat);
291
- if (groupCount > 0) {
292
- throw new Error("RegExp has capture groups: " + regexp + "\nUse (?: \u2026 ) instead");
293
- }
294
- if (!options.lineBreaks && regexp.test("\n")) {
295
- throw new Error("Rule should declare lineBreaks: " + regexp);
296
- }
297
- parts.push(reCapture(pat));
298
- }
299
- var fallbackRule = errorRule && errorRule.fallback;
300
- var flags = hasSticky && !fallbackRule ? "ym" : "gm";
301
- var suffix = hasSticky || fallbackRule ? "" : "|";
302
- if (unicodeFlag === true) flags += "u";
303
- var combined = new RegExp(reUnion(parts) + suffix, flags);
304
- return { regexp: combined, groups, fast, error: errorRule || defaultErrorRule };
305
- }
306
- __name(compileRules, "compileRules");
307
- function compile(rules) {
308
- var result = compileRules(toRules(rules));
309
- return new Lexer({ start: result }, "start");
310
- }
311
- __name(compile, "compile");
312
- function checkStateGroup(g, name, map2) {
313
- var state = g && (g.push || g.next);
314
- if (state && !map2[state]) {
315
- throw new Error("Missing state '" + state + "' (in token '" + g.defaultType + "' of state '" + name + "')");
316
- }
317
- if (g && g.pop && +g.pop !== 1) {
318
- throw new Error("pop must be 1 (in token '" + g.defaultType + "' of state '" + name + "')");
319
- }
320
- }
321
- __name(checkStateGroup, "checkStateGroup");
322
- function compileStates(states, start) {
323
- var all = states.$all ? toRules(states.$all) : [];
324
- delete states.$all;
325
- var keys = Object.getOwnPropertyNames(states);
326
- if (!start) start = keys[0];
327
- var ruleMap = /* @__PURE__ */ Object.create(null);
328
- for (var i = 0; i < keys.length; i++) {
329
- var key = keys[i];
330
- ruleMap[key] = toRules(states[key]).concat(all);
331
- }
332
- for (var i = 0; i < keys.length; i++) {
333
- var key = keys[i];
334
- var rules = ruleMap[key];
335
- var included = /* @__PURE__ */ Object.create(null);
336
- for (var j = 0; j < rules.length; j++) {
337
- var rule = rules[j];
338
- if (!rule.include) continue;
339
- var splice = [j, 1];
340
- if (rule.include !== key && !included[rule.include]) {
341
- included[rule.include] = true;
342
- var newRules = ruleMap[rule.include];
343
- if (!newRules) {
344
- throw new Error("Cannot include nonexistent state '" + rule.include + "' (in state '" + key + "')");
345
- }
346
- for (var k = 0; k < newRules.length; k++) {
347
- var newRule = newRules[k];
348
- if (rules.indexOf(newRule) !== -1) continue;
349
- splice.push(newRule);
350
- }
351
- }
352
- rules.splice.apply(rules, splice);
353
- j--;
354
- }
355
- }
356
- var map2 = /* @__PURE__ */ Object.create(null);
357
- for (var i = 0; i < keys.length; i++) {
358
- var key = keys[i];
359
- map2[key] = compileRules(ruleMap[key], true);
360
- }
361
- for (var i = 0; i < keys.length; i++) {
362
- var name = keys[i];
363
- var state = map2[name];
364
- var groups = state.groups;
365
- for (var j = 0; j < groups.length; j++) {
366
- checkStateGroup(groups[j], name, map2);
367
- }
368
- var fastKeys = Object.getOwnPropertyNames(state.fast);
369
- for (var j = 0; j < fastKeys.length; j++) {
370
- checkStateGroup(state.fast[fastKeys[j]], name, map2);
371
- }
372
- }
373
- return new Lexer(map2, start);
374
- }
375
- __name(compileStates, "compileStates");
376
- function keywordTransform(map2) {
377
- var isMap = typeof Map !== "undefined";
378
- var reverseMap = isMap ? /* @__PURE__ */ new Map() : /* @__PURE__ */ Object.create(null);
379
- var types = Object.getOwnPropertyNames(map2);
380
- for (var i = 0; i < types.length; i++) {
381
- var tokenType = types[i];
382
- var item = map2[tokenType];
383
- var keywordList = Array.isArray(item) ? item : [item];
384
- keywordList.forEach(function(keyword) {
385
- if (typeof keyword !== "string") {
386
- throw new Error("keyword must be string (in keyword '" + tokenType + "')");
387
- }
388
- if (isMap) {
389
- reverseMap.set(keyword, tokenType);
390
- } else {
391
- reverseMap[keyword] = tokenType;
392
- }
393
- });
394
- }
395
- return function(k) {
396
- return isMap ? reverseMap.get(k) : reverseMap[k];
397
- };
398
- }
399
- __name(keywordTransform, "keywordTransform");
400
- var Lexer = /* @__PURE__ */ __name(function(states, state) {
401
- this.startState = state;
402
- this.states = states;
403
- this.buffer = "";
404
- this.stack = [];
405
- this.reset();
406
- }, "Lexer");
407
- Lexer.prototype.reset = function(data, info) {
408
- this.buffer = data || "";
409
- this.index = 0;
410
- this.line = info ? info.line : 1;
411
- this.col = info ? info.col : 1;
412
- this.queuedToken = info ? info.queuedToken : null;
413
- this.queuedText = info ? info.queuedText : "";
414
- this.queuedThrow = info ? info.queuedThrow : null;
415
- this.setState(info ? info.state : this.startState);
416
- this.stack = info && info.stack ? info.stack.slice() : [];
417
- return this;
418
- };
419
- Lexer.prototype.save = function() {
420
- return {
421
- line: this.line,
422
- col: this.col,
423
- state: this.state,
424
- stack: this.stack.slice(),
425
- queuedToken: this.queuedToken,
426
- queuedText: this.queuedText,
427
- queuedThrow: this.queuedThrow
428
- };
429
- };
430
- Lexer.prototype.setState = function(state) {
431
- if (!state || this.state === state) return;
432
- this.state = state;
433
- var info = this.states[state];
434
- this.groups = info.groups;
435
- this.error = info.error;
436
- this.re = info.regexp;
437
- this.fast = info.fast;
438
- };
439
- Lexer.prototype.popState = function() {
440
- this.setState(this.stack.pop());
441
- };
442
- Lexer.prototype.pushState = function(state) {
443
- this.stack.push(this.state);
444
- this.setState(state);
445
- };
446
- var eat = hasSticky ? function(re, buffer) {
447
- return re.exec(buffer);
448
- } : function(re, buffer) {
449
- var match = re.exec(buffer);
450
- if (match[0].length === 0) {
451
- return null;
452
- }
453
- return match;
454
- };
455
- Lexer.prototype._getGroup = function(match) {
456
- var groupCount = this.groups.length;
457
- for (var i = 0; i < groupCount; i++) {
458
- if (match[i + 1] !== void 0) {
459
- return this.groups[i];
460
- }
461
- }
462
- throw new Error("Cannot find token type for matched text");
463
- };
464
- function tokenToString() {
465
- return this.value;
466
- }
467
- __name(tokenToString, "tokenToString");
468
- Lexer.prototype.next = function() {
469
- var index = this.index;
470
- if (this.queuedGroup) {
471
- var token = this._token(this.queuedGroup, this.queuedText, index);
472
- this.queuedGroup = null;
473
- this.queuedText = "";
474
- return token;
475
- }
476
- var buffer = this.buffer;
477
- if (index === buffer.length) {
478
- return;
479
- }
480
- var group = this.fast[buffer.charCodeAt(index)];
481
- if (group) {
482
- return this._token(group, buffer.charAt(index), index);
483
- }
484
- var re = this.re;
485
- re.lastIndex = index;
486
- var match = eat(re, buffer);
487
- var error = this.error;
488
- if (match == null) {
489
- return this._token(error, buffer.slice(index, buffer.length), index);
490
- }
491
- var group = this._getGroup(match);
492
- var text = match[0];
493
- if (error.fallback && match.index !== index) {
494
- this.queuedGroup = group;
495
- this.queuedText = text;
496
- return this._token(error, buffer.slice(index, match.index), index);
497
- }
498
- return this._token(group, text, index);
499
- };
500
- Lexer.prototype._token = function(group, text, offset2) {
501
- var lineBreaks = 0;
502
- if (group.lineBreaks) {
503
- var matchNL = /\n/g;
504
- var nl = 1;
505
- if (text === "\n") {
506
- lineBreaks = 1;
507
- } else {
508
- while (matchNL.exec(text)) {
509
- lineBreaks++;
510
- nl = matchNL.lastIndex;
511
- }
512
- }
513
- }
514
- var token = {
515
- type: typeof group.type === "function" && group.type(text) || group.defaultType,
516
- value: typeof group.value === "function" ? group.value(text) : text,
517
- text,
518
- toString: tokenToString,
519
- offset: offset2,
520
- lineBreaks,
521
- line: this.line,
522
- col: this.col
523
- };
524
- var size2 = text.length;
525
- this.index += size2;
526
- this.line += lineBreaks;
527
- if (lineBreaks !== 0) {
528
- this.col = size2 - nl + 1;
529
- } else {
530
- this.col += size2;
531
- }
532
- if (group.shouldThrow) {
533
- var err = new Error(this.formatError(token, "invalid syntax"));
534
- throw err;
535
- }
536
- if (group.pop) this.popState();
537
- else if (group.push) this.pushState(group.push);
538
- else if (group.next) this.setState(group.next);
539
- return token;
540
- };
541
- if (typeof Symbol !== "undefined" && Symbol.iterator) {
542
- var LexerIterator = /* @__PURE__ */ __name(function(lexer) {
543
- this.lexer = lexer;
544
- }, "LexerIterator");
545
- LexerIterator.prototype.next = function() {
546
- var token = this.lexer.next();
547
- return { value: token, done: !token };
548
- };
549
- LexerIterator.prototype[Symbol.iterator] = function() {
550
- return this;
551
- };
552
- Lexer.prototype[Symbol.iterator] = function() {
553
- return new LexerIterator(this);
554
- };
555
- }
556
- Lexer.prototype.formatError = function(token, message) {
557
- if (token == null) {
558
- var text = this.buffer.slice(this.index);
559
- var token = {
560
- text,
561
- offset: this.index,
562
- lineBreaks: text.indexOf("\n") === -1 ? 0 : 1,
563
- line: this.line,
564
- col: this.col
565
- };
566
- }
567
- var numLinesAround = 2;
568
- var firstDisplayedLine = Math.max(token.line - numLinesAround, 1);
569
- var lastDisplayedLine = token.line + numLinesAround;
570
- var lastLineDigits = String(lastDisplayedLine).length;
571
- var displayedLines = lastNLines(
572
- this.buffer,
573
- this.line - token.line + numLinesAround + 1
574
- ).slice(0, 5);
575
- var errorLines = [];
576
- errorLines.push(message + " at line " + token.line + " col " + token.col + ":");
577
- errorLines.push("");
578
- for (var i = 0; i < displayedLines.length; i++) {
579
- var line = displayedLines[i];
580
- var lineNo = firstDisplayedLine + i;
581
- errorLines.push(pad2(String(lineNo), lastLineDigits) + " " + line);
582
- if (lineNo === token.line) {
583
- errorLines.push(pad2("", lastLineDigits + token.col + 1) + "^");
584
- }
585
- }
586
- return errorLines.join("\n");
587
- };
588
- Lexer.prototype.clone = function() {
589
- return new Lexer(this.states, this.state);
590
- };
591
- Lexer.prototype.has = function(tokenType) {
592
- return true;
593
- };
594
- return {
595
- compile,
596
- states: compileStates,
597
- error: Object.freeze({ error: true }),
598
- fallback: Object.freeze({ fallback: true }),
599
- keywords: keywordTransform
600
- };
601
- });
602
- }
603
- });
604
-
605
52
  // ../../node_modules/path/node_modules/util/support/isBufferBrowser.js
606
53
  var require_isBufferBrowser = __commonJS({
607
54
  "../../node_modules/path/node_modules/util/support/isBufferBrowser.js"(exports, module) {
@@ -1668,18 +1115,30 @@ var require_TemplatePath = __commonJS({
1668
1115
  TemplatePath2.stripLeadingDotSlash = function(path2) {
1669
1116
  return typeof path2 === "string" ? path2.replace(/^\.\//, "") : path2;
1670
1117
  };
1118
+ function getSubPathRemainder(filePath, subPath) {
1119
+ if (filePath === subPath) {
1120
+ return "";
1121
+ }
1122
+ if (subPath === ".") {
1123
+ let isOutside = filePath === ".." || filePath.startsWith("../") || path.isAbsolute(filePath);
1124
+ return isOutside ? void 0 : filePath;
1125
+ }
1126
+ let prefix = subPath.endsWith("/") ? subPath : `${subPath}/`;
1127
+ return filePath.startsWith(prefix) ? filePath.slice(prefix.length) : void 0;
1128
+ }
1129
+ __name(getSubPathRemainder, "getSubPathRemainder");
1671
1130
  TemplatePath2.startsWithSubPath = function(path2, subPath) {
1672
1131
  path2 = TemplatePath2.normalize(path2);
1673
1132
  subPath = TemplatePath2.normalize(subPath);
1674
- return path2.startsWith(subPath);
1133
+ return getSubPathRemainder(path2, subPath) !== void 0;
1675
1134
  };
1676
1135
  TemplatePath2.stripLeadingSubPath = function(path2, subPath) {
1677
1136
  path2 = TemplatePath2.normalize(path2);
1678
1137
  subPath = TemplatePath2.normalize(subPath);
1679
- if (subPath !== "." && path2.startsWith(subPath)) {
1680
- return path2.slice(subPath.length + 1);
1138
+ if (subPath === ".") {
1139
+ return path2;
1681
1140
  }
1682
- return path2;
1141
+ return getSubPathRemainder(path2, subPath) ?? path2;
1683
1142
  };
1684
1143
  TemplatePath2.isDirectorySync = function(path2) {
1685
1144
  return fs3.existsSync(path2) && fs3.statSync(path2).isDirectory();
@@ -1741,7 +1200,7 @@ var require_TemplatePath = __commonJS({
1741
1200
  var require_IsPlainObject = __commonJS({
1742
1201
  "../../node_modules/@11ty/eleventy-utils/src/IsPlainObject.js"(exports, module) {
1743
1202
  module.exports = function(value) {
1744
- if (value === null || typeof value !== "object") {
1203
+ if (value === null || typeof value !== "object" || value === Object.prototype) {
1745
1204
  return false;
1746
1205
  }
1747
1206
  let proto = Object.getPrototypeOf(value);
@@ -1756,6 +1215,7 @@ var require_Merge = __commonJS({
1756
1215
  "use strict";
1757
1216
  var isPlainObject = require_IsPlainObject();
1758
1217
  var OVERRIDE_PREFIX = "override:";
1218
+ var UNSAFE_KEY = "__proto__";
1759
1219
  function cleanKey(key, prefix) {
1760
1220
  if (prefix && key.startsWith(prefix)) {
1761
1221
  return key.slice(prefix.length);
@@ -1765,21 +1225,29 @@ var require_Merge = __commonJS({
1765
1225
  __name(cleanKey, "cleanKey");
1766
1226
  function getMergedItem(target, source, prefixes = {}) {
1767
1227
  let { override } = prefixes;
1768
- if (!target && isPlainObject(source) && Object.isFrozen(source)) {
1769
- return source;
1770
- }
1771
- let sourcePlainObjectShortcut;
1772
- if (!target && isPlainObject(source)) {
1773
- target = {};
1774
- sourcePlainObjectShortcut = true;
1228
+ let sourcePlainObjectShortcut = isPlainObject(source);
1229
+ let targetPlainObjectShortcut = false;
1230
+ if (!target) {
1231
+ if (Object.isFrozen(source)) {
1232
+ return source;
1233
+ }
1234
+ if (sourcePlainObjectShortcut) {
1235
+ targetPlainObjectShortcut = true;
1236
+ target = {};
1237
+ }
1775
1238
  }
1776
1239
  if (Array.isArray(target) && Array.isArray(source)) {
1777
1240
  return target.concat(source);
1778
- } else if (isPlainObject(target)) {
1779
- if (sourcePlainObjectShortcut || isPlainObject(source)) {
1241
+ }
1242
+ if (targetPlainObjectShortcut || isPlainObject(target)) {
1243
+ if (sourcePlainObjectShortcut) {
1780
1244
  for (let key in source) {
1781
1245
  let overrideKey = cleanKey(key, override);
1782
- target[overrideKey] = getMergedItem(target[key], source[key], prefixes);
1246
+ if (overrideKey === UNSAFE_KEY) {
1247
+ continue;
1248
+ }
1249
+ let targetValue = Object.hasOwn(target, key) ? target[key] : void 0;
1250
+ target[overrideKey] = getMergedItem(targetValue, source[key], prefixes);
1783
1251
  }
1784
1252
  }
1785
1253
  return target;
@@ -1801,7 +1269,10 @@ var require_Merge = __commonJS({
1801
1269
  if (isPlainObject(target)) {
1802
1270
  for (let key in target) {
1803
1271
  if (key.indexOf(OVERRIDE_PREFIX) === 0) {
1804
- target[key.slice(OVERRIDE_PREFIX.length)] = target[key];
1272
+ let cleanedKey = key.slice(OVERRIDE_PREFIX.length);
1273
+ if (cleanedKey !== UNSAFE_KEY) {
1274
+ target[cleanedKey] = target[key];
1275
+ }
1805
1276
  delete target[key];
1806
1277
  }
1807
1278
  }
@@ -1882,22 +1353,6 @@ var require_Url = __commonJS({
1882
1353
  }
1883
1354
  });
1884
1355
 
1885
- // ../../node_modules/@11ty/eleventy-utils/src/Buffer.js
1886
- var require_Buffer = __commonJS({
1887
- "../../node_modules/@11ty/eleventy-utils/src/Buffer.js"(exports, module) {
1888
- function isBuffer(inst) {
1889
- if (typeof Buffer !== "undefined") {
1890
- return Buffer.isBuffer(inst);
1891
- }
1892
- return inst instanceof Uint8Array;
1893
- }
1894
- __name(isBuffer, "isBuffer");
1895
- module.exports = {
1896
- isBuffer
1897
- };
1898
- }
1899
- });
1900
-
1901
1356
  // ../../node_modules/@11ty/eleventy-utils/src/lib-sha256.js
1902
1357
  var require_lib_sha256 = __commonJS({
1903
1358
  "../../node_modules/@11ty/eleventy-utils/src/lib-sha256.js"(exports, module) {
@@ -2074,7 +1529,6 @@ var require_lib_sha256 = __commonJS({
2074
1529
  var require_HashTypes = __commonJS({
2075
1530
  "../../node_modules/@11ty/eleventy-utils/src/HashTypes.js"(exports, module) {
2076
1531
  var { base64UrlSafe } = require_Url();
2077
- var { isBuffer } = require_Buffer();
2078
1532
  var sha2562 = require_lib_sha256();
2079
1533
  function hasNodeCryptoModule() {
2080
1534
  try {
@@ -2138,7 +1592,7 @@ var require_HashTypes = __commonJS({
2138
1592
  static async toHash(...content) {
2139
1593
  let encoder = new TextEncoder();
2140
1594
  let input = this.mergeUint8Array(...content.map((c) => {
2141
- if (isBuffer(c)) {
1595
+ if (c instanceof Uint8Array) {
2142
1596
  return c;
2143
1597
  }
2144
1598
  return encoder.encode(c);
@@ -2241,6 +1695,22 @@ var require_CreateHash = __commonJS({
2241
1695
  }
2242
1696
  });
2243
1697
 
1698
+ // ../../node_modules/@11ty/eleventy-utils/src/Buffer.js
1699
+ var require_Buffer = __commonJS({
1700
+ "../../node_modules/@11ty/eleventy-utils/src/Buffer.js"(exports, module) {
1701
+ function isBuffer(inst) {
1702
+ if (typeof Buffer !== "undefined") {
1703
+ return Buffer.isBuffer(inst);
1704
+ }
1705
+ return inst instanceof Uint8Array;
1706
+ }
1707
+ __name(isBuffer, "isBuffer");
1708
+ module.exports = {
1709
+ isBuffer
1710
+ };
1711
+ }
1712
+ });
1713
+
2244
1714
  // ../../node_modules/@11ty/eleventy-utils/index.js
2245
1715
  var require_eleventy_utils = __commonJS({
2246
1716
  "../../node_modules/@11ty/eleventy-utils/index.js"(exports, module) {
@@ -2266,9 +1736,6 @@ var require_eleventy_utils = __commonJS({
2266
1736
  }
2267
1737
  });
2268
1738
 
2269
- // ../../src/Engines/Liquid.js
2270
- var import_moo = __toESM(require_moo(), 1);
2271
-
2272
1739
  // ../../node_modules/liquidjs/dist/liquid.browser.mjs
2273
1740
  var Token = class {
2274
1741
  static {
@@ -2337,6 +1804,28 @@ function stringify(value) {
2337
1804
  return String(value);
2338
1805
  }
2339
1806
  __name(stringify, "stringify");
1807
+ function advanceCodePoints(str, from, count) {
1808
+ let index = from;
1809
+ for (let i = 0; i < count && index < str.length; i++)
1810
+ index += str.codePointAt(index) > 65535 ? 2 : 1;
1811
+ return index;
1812
+ }
1813
+ __name(advanceCodePoints, "advanceCodePoints");
1814
+ function codePointLength(str) {
1815
+ let length = 0;
1816
+ for (let index = 0; index < str.length; index = advanceCodePoints(str, index, 1))
1817
+ length++;
1818
+ return length;
1819
+ }
1820
+ __name(codePointLength, "codePointLength");
1821
+ function readArrayElement(arr, index, ownPropertyOnly) {
1822
+ if (index < 0)
1823
+ index = arr.length + index;
1824
+ if (ownPropertyOnly && !hasOwnProperty.call(arr, index))
1825
+ return void 0;
1826
+ return arr[index];
1827
+ }
1828
+ __name(readArrayElement, "readArrayElement");
2340
1829
  function toEnumerable(val) {
2341
1830
  val = toValue(val);
2342
1831
  if (isArray(val))
@@ -2668,8 +2157,8 @@ var NullDrop = class extends Drop {
2668
2157
  static {
2669
2158
  __name(this, "NullDrop");
2670
2159
  }
2671
- equals(value) {
2672
- return isNil(toValue(value));
2160
+ *equals(value) {
2161
+ return isNil(yield toValue(value));
2673
2162
  }
2674
2163
  gt() {
2675
2164
  return false;
@@ -2691,10 +2180,10 @@ var EmptyDrop = class _EmptyDrop extends Drop {
2691
2180
  static {
2692
2181
  __name(this, "EmptyDrop");
2693
2182
  }
2694
- equals(value) {
2183
+ *equals(value) {
2695
2184
  if (value instanceof _EmptyDrop)
2696
2185
  return false;
2697
- value = toValue(value);
2186
+ value = yield toValue(value);
2698
2187
  if (isString(value) || isArray(value))
2699
2188
  return value.length === 0;
2700
2189
  if (isObject(value))
@@ -2724,14 +2213,14 @@ var BlankDrop = class _BlankDrop extends EmptyDrop {
2724
2213
  static {
2725
2214
  __name(this, "BlankDrop");
2726
2215
  }
2727
- equals(value) {
2216
+ *equals(value) {
2728
2217
  if (value === false)
2729
2218
  return true;
2730
- if (isNil(toValue(value)))
2219
+ if (isNil(yield toValue(value)))
2731
2220
  return true;
2732
2221
  if (isString(value))
2733
2222
  return /^\s*$/.test(value);
2734
- return super.equals(value);
2223
+ return yield super.equals(value);
2735
2224
  }
2736
2225
  static is(value) {
2737
2226
  return value instanceof _BlankDrop;
@@ -2976,10 +2465,8 @@ function getDayOfYear(d) {
2976
2465
  }
2977
2466
  __name(getDayOfYear, "getDayOfYear");
2978
2467
  function getWeekOfYear(d, startDay) {
2979
- const now = getDayOfYear(d) + (startDay - d.getDay());
2980
- const jan1 = new Date(d.getFullYear(), 0, 1);
2981
- const then = 7 - jan1.getDay() + startDay;
2982
- return String(Math.floor((now - then) / 7) + 1);
2468
+ const daysSinceStartDay = (d.getDay() - startDay + 7) % 7;
2469
+ return String(Math.floor((getDayOfYear(d) - 1 - daysSinceStartDay + 7) / 7));
2983
2470
  }
2984
2471
  __name(getWeekOfYear, "getWeekOfYear");
2985
2472
  function isLeapYear(d) {
@@ -3004,10 +2491,11 @@ function ordinal(d) {
3004
2491
  }
3005
2492
  __name(ordinal, "ordinal");
3006
2493
  function century(d) {
3007
- return parseInt(d.getFullYear().toString().substring(0, 2), 10);
2494
+ return Math.floor(d.getFullYear() / 100);
3008
2495
  }
3009
2496
  __name(century, "century");
3010
2497
  var padWidths = {
2498
+ C: 2,
3011
2499
  d: 2,
3012
2500
  e: 2,
3013
2501
  H: 2,
@@ -3020,7 +2508,9 @@ var padWidths = {
3020
2508
  M: 2,
3021
2509
  S: 2,
3022
2510
  U: 2,
3023
- W: 2
2511
+ W: 2,
2512
+ y: 2,
2513
+ Y: 4
3024
2514
  };
3025
2515
  var padSpaceChars = new Set("aAbBceklpP");
3026
2516
  function getTimezoneOffset(d, opts) {
@@ -3050,14 +2540,14 @@ var formatCodes = {
3050
2540
  N: /* @__PURE__ */ __name((d, opts) => {
3051
2541
  var _a;
3052
2542
  const width = Number(opts.width) || 9;
3053
- const str = String(d.getMilliseconds()).slice(0, width);
2543
+ const str = padStart(String(d.getMilliseconds()), 3, "0").slice(0, width);
3054
2544
  (_a = opts.memoryLimit) === null || _a === void 0 ? void 0 : _a.use(width - str.length);
3055
2545
  return padEnd(str, width, "0");
3056
2546
  }, "N"),
3057
2547
  p: /* @__PURE__ */ __name((d) => d.getHours() < 12 ? "AM" : "PM", "p"),
3058
2548
  P: /* @__PURE__ */ __name((d) => d.getHours() < 12 ? "am" : "pm", "P"),
3059
2549
  q: /* @__PURE__ */ __name((d) => ordinal(d), "q"),
3060
- s: /* @__PURE__ */ __name((d) => Math.round(d.getTime() / 1e3), "s"),
2550
+ s: /* @__PURE__ */ __name((d) => Math.floor(d.dateValue() / 1e3), "s"),
3061
2551
  S: /* @__PURE__ */ __name((d) => d.getSeconds(), "S"),
3062
2552
  u: /* @__PURE__ */ __name((d) => d.getDay() || 7, "u"),
3063
2553
  U: /* @__PURE__ */ __name((d) => getWeekOfYear(d, 0), "U"),
@@ -3065,7 +2555,7 @@ var formatCodes = {
3065
2555
  W: /* @__PURE__ */ __name((d) => getWeekOfYear(d, 1), "W"),
3066
2556
  x: /* @__PURE__ */ __name((d) => d.toLocaleDateString(), "x"),
3067
2557
  X: /* @__PURE__ */ __name((d) => d.toLocaleTimeString(), "X"),
3068
- y: /* @__PURE__ */ __name((d) => d.getFullYear().toString().slice(2, 4), "y"),
2558
+ y: /* @__PURE__ */ __name((d) => (d.getFullYear() % 100 + 100) % 100, "y"),
3069
2559
  Y: /* @__PURE__ */ __name((d) => d.getFullYear(), "Y"),
3070
2560
  z: getTimezoneOffset,
3071
2561
  Z: /* @__PURE__ */ __name((d, opts) => d.getTimeZoneName() || getTimezoneOffset(d, opts), "Z"),
@@ -3108,6 +2598,8 @@ function format(d, match, memoryLimit) {
3108
2598
  if (flags["-"])
3109
2599
  padWidth = 0;
3110
2600
  memoryLimit === null || memoryLimit === void 0 ? void 0 : memoryLimit.use(Number(padWidth) - ret.length);
2601
+ if (padChar === "0" && ret[0] === "-")
2602
+ return "-" + padStart(ret.slice(1), padWidth - 1, padChar);
3111
2603
  return padStart(ret, padWidth, padChar);
3112
2604
  }
3113
2605
  __name(format, "format");
@@ -3163,6 +2655,15 @@ var LiquidDate = class _LiquidDate {
3163
2655
  getTime() {
3164
2656
  return this.displayDate.getTime();
3165
2657
  }
2658
+ /**
2659
+ * The underlying UTC timestamp in milliseconds, unaffected by the display
2660
+ * timezone. Use this (not `getTime()`) for timezone-invariant values like
2661
+ * `%s`: `getTime()` reads `displayDate`, which is deliberately shifted by
2662
+ * the display timezone offset so wall-clock getters can delegate to Date.
2663
+ */
2664
+ dateValue() {
2665
+ return this.date.getTime();
2666
+ }
3166
2667
  getMilliseconds() {
3167
2668
  return this.displayDate.getMilliseconds();
3168
2669
  }
@@ -3317,7 +2818,7 @@ var TagToken = class extends DelimitedToken {
3317
2818
  const { trimTagLeft, trimTagRight, tagDelimiterLeft, tagDelimiterRight } = options;
3318
2819
  const [valueBegin, valueEnd] = [begin + tagDelimiterLeft.length, end - tagDelimiterRight.length];
3319
2820
  super(TokenKind.Tag, [valueBegin, valueEnd], input, begin, end, trimTagLeft, trimTagRight, file);
3320
- this.tokenizer = new Tokenizer(input, options.operators, file, this.contentRange);
2821
+ this.tokenizer = new Tokenizer(input, options.operators, file, this.contentRange, options.groupedExpressions);
3321
2822
  this.name = this.tokenizer.readTagName();
3322
2823
  this.tokenizer.assert(this.name, `illegal tag syntax, tag name expected`);
3323
2824
  this.tokenizer.skipBlank();
@@ -3550,7 +3051,7 @@ var LiquidTagToken = class extends DelimitedToken {
3550
3051
  }
3551
3052
  constructor(input, begin, end, options, file) {
3552
3053
  super(TokenKind.Tag, [begin, end], input, begin, end, false, false, file);
3553
- this.tokenizer = new Tokenizer(input, options.operators, file, this.contentRange);
3054
+ this.tokenizer = new Tokenizer(input, options.operators, file, this.contentRange, options.groupedExpressions);
3554
3055
  this.name = this.tokenizer.readTagName();
3555
3056
  this.tokenizer.assert(this.name, "illegal liquid tag syntax");
3556
3057
  this.tokenizer.skipBlank();
@@ -3616,6 +3117,33 @@ var Render = class {
3616
3117
  return emitter.buffer;
3617
3118
  }
3618
3119
  };
3120
+ function isKeyValuePair(arr) {
3121
+ return isArray(arr);
3122
+ }
3123
+ __name(isKeyValuePair, "isKeyValuePair");
3124
+ var Filter = class {
3125
+ static {
3126
+ __name(this, "Filter");
3127
+ }
3128
+ constructor(token, options, liquid) {
3129
+ this.token = token;
3130
+ this.name = token.name;
3131
+ this.handler = isFunction(options) ? options : isFunction(options === null || options === void 0 ? void 0 : options.handler) ? options.handler : identify;
3132
+ this.raw = !isFunction(options) && !!(options === null || options === void 0 ? void 0 : options.raw);
3133
+ this.args = token.args;
3134
+ this.liquid = liquid;
3135
+ }
3136
+ *render(value, context) {
3137
+ const argv = [];
3138
+ for (const arg of this.args) {
3139
+ if (isKeyValuePair(arg))
3140
+ argv.push([arg[0], yield evalToken(arg[1], context)]);
3141
+ else
3142
+ argv.push(yield evalToken(arg, context));
3143
+ }
3144
+ return yield this.handler.apply({ context, token: this.token, liquid: this.liquid }, [value, ...argv]);
3145
+ }
3146
+ };
3619
3147
  var Expression = class {
3620
3148
  static {
3621
3149
  __name(this, "Expression");
@@ -3656,12 +3184,31 @@ function* evalToken(token, ctx, lenient = false) {
3656
3184
  return yield evalPropertyAccessToken(token, ctx, lenient);
3657
3185
  if (isRangeToken(token))
3658
3186
  return yield evalRangeToken(token, ctx);
3187
+ if (isFilteredValueToken(token))
3188
+ return yield evalFilteredValueToken(token, ctx, lenient);
3659
3189
  }
3660
3190
  __name(evalToken, "evalToken");
3191
+ function* evalFilteredValueToken(token, ctx, lenient) {
3192
+ assert(ctx.liquid, "FilteredValueToken evaluation requires liquid instance in context");
3193
+ lenient = lenient || ctx.opts.lenientIf && token.filters.length > 0 && token.filters[0].name === "default";
3194
+ let val = yield token.initial.evaluate(ctx, lenient);
3195
+ for (const filterToken of token.filters) {
3196
+ const filterImpl = ctx.liquid.filters[filterToken.name];
3197
+ assert(filterImpl || !ctx.liquid.options.strictFilters, () => `undefined filter: ${filterToken.name}`);
3198
+ const filter2 = new Filter(filterToken, filterImpl, ctx.liquid);
3199
+ val = yield filter2.render(val, ctx);
3200
+ }
3201
+ return val;
3202
+ }
3203
+ __name(evalFilteredValueToken, "evalFilteredValueToken");
3204
+ function* evalTokenValue(token, ctx, lenient = false) {
3205
+ return yield toValue(yield evalToken(token, ctx, lenient));
3206
+ }
3207
+ __name(evalTokenValue, "evalTokenValue");
3661
3208
  function* evalPropertyAccessToken(token, ctx, lenient) {
3662
3209
  const props = [];
3663
3210
  for (const prop of token.props) {
3664
- props.push(yield evalToken(prop, ctx, false));
3211
+ props.push(yield evalTokenValue(prop, ctx, false));
3665
3212
  }
3666
3213
  try {
3667
3214
  if (token.variable) {
@@ -3682,8 +3229,8 @@ function evalQuotedToken(token) {
3682
3229
  }
3683
3230
  __name(evalQuotedToken, "evalQuotedToken");
3684
3231
  function* evalRangeToken(token, ctx) {
3685
- const low = yield evalToken(token.lhs, ctx);
3686
- const high = yield evalToken(token.rhs, ctx);
3232
+ const low = yield evalTokenValue(token.lhs, ctx);
3233
+ const high = yield evalTokenValue(token.rhs, ctx);
3687
3234
  ctx.memoryLimit.use(high - low + 1);
3688
3235
  return range(+low, +high + 1);
3689
3236
  }
@@ -3718,69 +3265,87 @@ function isFalsy(val, ctx) {
3718
3265
  }
3719
3266
  __name(isFalsy, "isFalsy");
3720
3267
  var defaultOperators = {
3721
- "==": equals,
3722
- "!=": /* @__PURE__ */ __name((l, r) => !equals(l, r), "!="),
3723
- ">": /* @__PURE__ */ __name((l, r) => {
3268
+ "==": /* @__PURE__ */ __name(function* (l, r) {
3269
+ return yield equals(l, r);
3270
+ }, "=="),
3271
+ "!=": /* @__PURE__ */ __name(function* (l, r) {
3272
+ return !(yield equals(l, r));
3273
+ }, "!="),
3274
+ ">": /* @__PURE__ */ __name(function* (l, r) {
3724
3275
  if (isComparable(l))
3725
- return l.gt(r);
3276
+ return yield l.gt(r);
3726
3277
  if (isComparable(r))
3727
- return r.lt(l);
3728
- return toValue(l) > toValue(r);
3278
+ return yield r.lt(l);
3279
+ return (yield toValue(l)) > (yield toValue(r));
3729
3280
  }, ">"),
3730
- "<": /* @__PURE__ */ __name((l, r) => {
3281
+ "<": /* @__PURE__ */ __name(function* (l, r) {
3731
3282
  if (isComparable(l))
3732
- return l.lt(r);
3283
+ return yield l.lt(r);
3733
3284
  if (isComparable(r))
3734
- return r.gt(l);
3735
- return toValue(l) < toValue(r);
3285
+ return yield r.gt(l);
3286
+ return (yield toValue(l)) < (yield toValue(r));
3736
3287
  }, "<"),
3737
- ">=": /* @__PURE__ */ __name((l, r) => {
3288
+ ">=": /* @__PURE__ */ __name(function* (l, r) {
3738
3289
  if (isComparable(l))
3739
- return l.geq(r);
3290
+ return yield l.geq(r);
3740
3291
  if (isComparable(r))
3741
- return r.leq(l);
3742
- return toValue(l) >= toValue(r);
3292
+ return yield r.leq(l);
3293
+ return (yield toValue(l)) >= (yield toValue(r));
3743
3294
  }, ">="),
3744
- "<=": /* @__PURE__ */ __name((l, r) => {
3295
+ "<=": /* @__PURE__ */ __name(function* (l, r) {
3745
3296
  if (isComparable(l))
3746
- return l.leq(r);
3297
+ return yield l.leq(r);
3747
3298
  if (isComparable(r))
3748
- return r.geq(l);
3749
- return toValue(l) <= toValue(r);
3299
+ return yield r.geq(l);
3300
+ return (yield toValue(l)) <= (yield toValue(r));
3750
3301
  }, "<="),
3751
- "contains": /* @__PURE__ */ __name((l, r) => {
3752
- l = toValue(l);
3302
+ "contains": /* @__PURE__ */ __name(function* (l, r) {
3303
+ l = yield toValue(l);
3753
3304
  if (isArray(l))
3754
- return l.some((i) => equals(i, r));
3305
+ return yield arrayIncludes(l, r);
3755
3306
  if (isFunction(l === null || l === void 0 ? void 0 : l.indexOf))
3756
- return l.indexOf(toValue(r)) > -1;
3307
+ return l.indexOf(yield toValue(r)) > -1;
3757
3308
  return false;
3758
3309
  }, "contains"),
3759
- "not": /* @__PURE__ */ __name((v, ctx) => isFalsy(toValue(v), ctx), "not"),
3760
- "and": /* @__PURE__ */ __name((l, r, ctx) => isTruthy(toValue(l), ctx) && isTruthy(toValue(r), ctx), "and"),
3761
- "or": /* @__PURE__ */ __name((l, r, ctx) => isTruthy(toValue(l), ctx) || isTruthy(toValue(r), ctx), "or")
3310
+ "not": /* @__PURE__ */ __name(function* (v, ctx) {
3311
+ return isFalsy(yield toValue(v), ctx);
3312
+ }, "not"),
3313
+ "and": /* @__PURE__ */ __name(function* (l, r, ctx) {
3314
+ return isTruthy(yield toValue(l), ctx) && isTruthy(yield toValue(r), ctx);
3315
+ }, "and"),
3316
+ "or": /* @__PURE__ */ __name(function* (l, r, ctx) {
3317
+ return isTruthy(yield toValue(l), ctx) || isTruthy(yield toValue(r), ctx);
3318
+ }, "or")
3762
3319
  };
3763
- function equals(lhs, rhs) {
3320
+ function* equals(lhs, rhs) {
3764
3321
  if (isComparable(lhs))
3765
- return lhs.equals(rhs);
3322
+ return yield lhs.equals(rhs);
3766
3323
  if (isComparable(rhs))
3767
- return rhs.equals(lhs);
3768
- lhs = toValue(lhs);
3769
- rhs = toValue(rhs);
3324
+ return yield rhs.equals(lhs);
3325
+ lhs = yield toValue(lhs);
3326
+ rhs = yield toValue(rhs);
3770
3327
  if (isArray(lhs)) {
3771
- return isArray(rhs) && arrayEquals(lhs, rhs);
3328
+ return isArray(rhs) && (yield arrayEquals(lhs, rhs));
3772
3329
  }
3773
3330
  return lhs === rhs;
3774
3331
  }
3775
3332
  __name(equals, "equals");
3776
- function arrayEquals(lhs, rhs) {
3333
+ function* arrayEquals(lhs, rhs) {
3777
3334
  if (lhs.length !== rhs.length)
3778
3335
  return false;
3779
- return !lhs.some((value, i) => !equals(value, rhs[i]));
3336
+ for (let i = 0; i < lhs.length; i++) {
3337
+ if (!(yield equals(lhs[i], rhs[i])))
3338
+ return false;
3339
+ }
3340
+ return true;
3780
3341
  }
3781
3342
  __name(arrayEquals, "arrayEquals");
3782
- function arrayIncludes(arr, item) {
3783
- return arr.some((value) => equals(value, item));
3343
+ function* arrayIncludes(arr, item) {
3344
+ for (const value of arr) {
3345
+ if (yield equals(value, item))
3346
+ return true;
3347
+ }
3348
+ return false;
3784
3349
  }
3785
3350
  __name(arrayIncludes, "arrayIncludes");
3786
3351
  var Node = class {
@@ -3924,6 +3489,18 @@ var fs = /* @__PURE__ */ Object.freeze({
3924
3489
  dirname,
3925
3490
  sep
3926
3491
  });
3492
+ function chargeJsonReplacerValue(memoryLimit, val) {
3493
+ if (typeof val === "string") {
3494
+ memoryLimit.use(val.length);
3495
+ } else if (val === null || typeof val === "number" || typeof val === "boolean") {
3496
+ memoryLimit.use(JSON.stringify(val).length);
3497
+ } else if (Array.isArray(val)) {
3498
+ memoryLimit.use(val.length + 1);
3499
+ } else if (typeof val === "object") {
3500
+ memoryLimit.use(2);
3501
+ }
3502
+ }
3503
+ __name(chargeJsonReplacerValue, "chargeJsonReplacerValue");
3927
3504
  function defaultFilter(value, defaultValue, ...args) {
3928
3505
  value = toValue(value);
3929
3506
  if (isArray(value) || isString(value))
@@ -3934,19 +3511,29 @@ function defaultFilter(value, defaultValue, ...args) {
3934
3511
  }
3935
3512
  __name(defaultFilter, "defaultFilter");
3936
3513
  function json(value, space = 0) {
3937
- return JSON.stringify(value, null, space);
3514
+ const memoryLimit = this.context.memoryLimit;
3515
+ return JSON.stringify(value, (_key, val) => {
3516
+ chargeJsonReplacerValue(memoryLimit, val);
3517
+ return val;
3518
+ }, space);
3938
3519
  }
3939
3520
  __name(json, "json");
3940
3521
  function inspect(value, space = 0) {
3522
+ const memoryLimit = this.context.memoryLimit;
3941
3523
  const ancestors = [];
3942
3524
  return JSON.stringify(value, function(_key, value2) {
3943
- if (typeof value2 !== "object" || value2 === null)
3525
+ if (typeof value2 !== "object" || value2 === null) {
3526
+ chargeJsonReplacerValue(memoryLimit, value2);
3944
3527
  return value2;
3528
+ }
3945
3529
  while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this)
3946
3530
  ancestors.pop();
3947
- if (ancestors.includes(value2))
3531
+ if (ancestors.includes(value2)) {
3532
+ memoryLimit.use("[Circular]".length);
3948
3533
  return "[Circular]";
3534
+ }
3949
3535
  ancestors.push(value2);
3536
+ chargeJsonReplacerValue(memoryLimit, value2);
3950
3537
  return value2;
3951
3538
  }, space);
3952
3539
  }
@@ -4122,6 +3709,7 @@ var defaultOptions = {
4122
3709
  globals: {},
4123
3710
  keepOutputType: false,
4124
3711
  operators: defaultOperators,
3712
+ groupedExpressions: false,
4125
3713
  memoryLimit: Infinity,
4126
3714
  parseLimit: Infinity,
4127
3715
  renderLimit: Infinity
@@ -4225,7 +3813,7 @@ var Tokenizer = class {
4225
3813
  static {
4226
3814
  __name(this, "Tokenizer");
4227
3815
  }
4228
- constructor(input, operators = defaultOptions.operators, file, range2) {
3816
+ constructor(input, operators = defaultOptions.operators, file, range2, groupedExpressions = false) {
4229
3817
  this.input = input;
4230
3818
  this.file = file;
4231
3819
  this.rawBeginAt = -1;
@@ -4233,6 +3821,7 @@ var Tokenizer = class {
4233
3821
  this.N = range2 ? range2[1] : input.length;
4234
3822
  this.opTrie = createTrie(operators);
4235
3823
  this.literalTrie = createTrie(literalValues);
3824
+ this.groupedExpressions = groupedExpressions;
4236
3825
  }
4237
3826
  readExpression() {
4238
3827
  return new Expression(this.readExpressionTokens());
@@ -4294,6 +3883,8 @@ var Tokenizer = class {
4294
3883
  this.skipBlank();
4295
3884
  if (this.end())
4296
3885
  return null;
3886
+ if (this.peek() === ")" || this.peek() === ",")
3887
+ return null;
4297
3888
  this.assert(this.read() === "|", `expected "|" before filter`);
4298
3889
  const name = this.readIdentifier();
4299
3890
  if (!name.size()) {
@@ -4308,9 +3899,9 @@ var Tokenizer = class {
4308
3899
  const arg = this.readFilterArg();
4309
3900
  arg && args.push(arg);
4310
3901
  this.skipBlank();
4311
- this.assert(this.end() || this.peek() === "," || this.peek() === "|", () => `unexpected character ${this.snapshot()}`);
3902
+ this.assert(this.end() || this.peek() === "," || this.peek() === "|" || this.peek() === ")", () => `unexpected character ${this.snapshot()}`);
4312
3903
  } while (this.peek() === ",");
4313
- } else if (this.peek() === "|" || this.end()) ;
3904
+ } else if (this.peek() === "|" || this.peek() === ")" || this.peek() === "," || this.end()) ;
4314
3905
  else {
4315
3906
  throw this.error('expected ":" after filter name');
4316
3907
  }
@@ -4514,7 +4105,10 @@ var Tokenizer = class {
4514
4105
  readValue() {
4515
4106
  this.skipBlank();
4516
4107
  const begin = this.p;
4517
- const variable = this.readLiteral() || this.readQuoted() || this.readRange() || this.readNumber();
4108
+ let variable = this.readLiteral() || this.readQuoted() || this.readNumber();
4109
+ if (!variable && this.peek() === "(") {
4110
+ variable = this.readGroupOrRange();
4111
+ }
4518
4112
  const props = this.readProperties(!variable);
4519
4113
  if (!props.length)
4520
4114
  return variable;
@@ -4591,7 +4185,7 @@ var Tokenizer = class {
4591
4185
  this.p = end;
4592
4186
  return literal;
4593
4187
  }
4594
- readRange() {
4188
+ readGroupOrRange() {
4595
4189
  this.skipBlank();
4596
4190
  const begin = this.p;
4597
4191
  if (this.peek() !== "(")
@@ -4599,11 +4193,22 @@ var Tokenizer = class {
4599
4193
  ++this.p;
4600
4194
  const lhs = this.readValueOrThrow();
4601
4195
  this.skipBlank();
4602
- this.assert(this.read() === "." && this.read() === ".", "invalid range syntax");
4603
- const rhs = this.readValueOrThrow();
4604
- this.skipBlank();
4605
- this.assert(this.read() === ")", "invalid range syntax");
4606
- return new RangeToken(this.input, begin, this.p, lhs, rhs, this.file);
4196
+ if (this.peek() === "." && this.peek(1) === ".") {
4197
+ this.p += 2;
4198
+ const rhs = this.readValueOrThrow();
4199
+ this.skipBlank();
4200
+ this.assert(this.read() === ")", "invalid range syntax");
4201
+ return new RangeToken(this.input, begin, this.p, lhs, rhs, this.file);
4202
+ }
4203
+ if (this.groupedExpressions) {
4204
+ const initial = new Expression([lhs, ...this.readExpressionTokens()]);
4205
+ this.assert(initial.valid(), () => `invalid value expression: ${this.snapshot()}`);
4206
+ const filters2 = this.readFilters();
4207
+ this.skipBlank();
4208
+ this.assert(this.read() === ")", "unbalanced parentheses");
4209
+ return new FilteredValueToken(initial, filters2, this.input, begin, this.p, this.file);
4210
+ }
4211
+ throw this.error("invalid range syntax");
4607
4212
  }
4608
4213
  readValueOrThrow() {
4609
4214
  const value = this.readValue();
@@ -4753,33 +4358,6 @@ function createTagClass(options) {
4753
4358
  };
4754
4359
  }
4755
4360
  __name(createTagClass, "createTagClass");
4756
- function isKeyValuePair(arr) {
4757
- return isArray(arr);
4758
- }
4759
- __name(isKeyValuePair, "isKeyValuePair");
4760
- var Filter = class {
4761
- static {
4762
- __name(this, "Filter");
4763
- }
4764
- constructor(token, options, liquid) {
4765
- this.token = token;
4766
- this.name = token.name;
4767
- this.handler = isFunction(options) ? options : isFunction(options === null || options === void 0 ? void 0 : options.handler) ? options.handler : identify;
4768
- this.raw = !isFunction(options) && !!(options === null || options === void 0 ? void 0 : options.raw);
4769
- this.args = token.args;
4770
- this.liquid = liquid;
4771
- }
4772
- *render(value, context) {
4773
- const argv = [];
4774
- for (const arg of this.args) {
4775
- if (isKeyValuePair(arg))
4776
- argv.push([arg[0], yield evalToken(arg[1], context)]);
4777
- else
4778
- argv.push(yield evalToken(arg, context));
4779
- }
4780
- return yield this.handler.apply({ context, token: this.token, liquid: this.liquid }, [value, ...argv]);
4781
- }
4782
- };
4783
4361
  var Value = class {
4784
4362
  static {
4785
4363
  __name(this, "Value");
@@ -4789,7 +4367,7 @@ var Value = class {
4789
4367
  */
4790
4368
  constructor(input, liquid) {
4791
4369
  this.filters = [];
4792
- const token = typeof input === "string" ? new Tokenizer(input, liquid.options.operators).readFilteredValue() : input;
4370
+ const token = typeof input === "string" ? new Tokenizer(input, liquid.options.operators, void 0, void 0, liquid.options.groupedExpressions).readFilteredValue() : input;
4793
4371
  this.initial = token.initial;
4794
4372
  this.filters = token.filters.map((token2) => new Filter(token2, this.getFilter(liquid, token2.name), liquid));
4795
4373
  }
@@ -4814,7 +4392,7 @@ var Output = class extends TemplateImpl {
4814
4392
  constructor(token, liquid) {
4815
4393
  var _a;
4816
4394
  super(token);
4817
- const tokenizer = new Tokenizer(token.input, liquid.options.operators, token.file, token.contentRange);
4395
+ const tokenizer = new Tokenizer(token.input, liquid.options.operators, token.file, token.contentRange, liquid.options.groupedExpressions);
4818
4396
  this.value = new Value(tokenizer.readFilteredValue(), liquid);
4819
4397
  const filters2 = this.value.filters;
4820
4398
  const outputEscape = liquid.options.outputEscape;
@@ -4824,7 +4402,7 @@ var Output = class extends TemplateImpl {
4824
4402
  }
4825
4403
  }
4826
4404
  *render(ctx, emitter) {
4827
- const val = yield this.value.value(ctx, false);
4405
+ const val = yield toValue(yield this.value.value(ctx, false));
4828
4406
  emitter.write(val);
4829
4407
  }
4830
4408
  *arguments() {
@@ -5089,11 +4667,31 @@ function* extractValueTokenVariables(token) {
5089
4667
  if (isRangeToken(token)) {
5090
4668
  yield* extractValueTokenVariables(token.lhs);
5091
4669
  yield* extractValueTokenVariables(token.rhs);
4670
+ } else if (isFilteredValueToken(token)) {
4671
+ yield* extractGroupedExpressionTokenVariables(token);
5092
4672
  } else if (isPropertyAccessToken(token)) {
5093
4673
  yield extractPropertyAccessVariable(token);
5094
4674
  }
5095
4675
  }
5096
4676
  __name(extractValueTokenVariables, "extractValueTokenVariables");
4677
+ function* extractGroupedExpressionTokenVariables(token) {
4678
+ if (!isFilteredValueToken(token))
4679
+ return;
4680
+ for (const t of token.initial.postfix) {
4681
+ if (isValueToken(t))
4682
+ yield* extractValueTokenVariables(t);
4683
+ }
4684
+ for (const filter2 of token.filters) {
4685
+ for (const arg of filter2.args) {
4686
+ if (isKeyValuePair(arg) && arg[1]) {
4687
+ yield* extractValueTokenVariables(arg[1]);
4688
+ } else if (isValueToken(arg)) {
4689
+ yield* extractValueTokenVariables(arg);
4690
+ }
4691
+ }
4692
+ }
4693
+ }
4694
+ __name(extractGroupedExpressionTokenVariables, "extractGroupedExpressionTokenVariables");
5097
4695
  function extractPropertyAccessVariable(token) {
5098
4696
  const segments = [];
5099
4697
  let file = token.file;
@@ -5240,7 +4838,7 @@ var Parser = class {
5240
4838
  parse(html, filepath) {
5241
4839
  html = String(html);
5242
4840
  this.parseLimit.use(html.length);
5243
- const tokenizer = new Tokenizer(html, this.liquid.options.operators, filepath);
4841
+ const tokenizer = new Tokenizer(html, this.liquid.options.operators, filepath, void 0, this.liquid.options.groupedExpressions);
5244
4842
  const tokens = tokenizer.readTopLevelTokens(this.liquid.options);
5245
4843
  return this.parseTokens(tokens);
5246
4844
  }
@@ -5318,6 +4916,7 @@ var TokenKind;
5318
4916
  TokenKind2[TokenKind2["Quoted"] = 1024] = "Quoted";
5319
4917
  TokenKind2[TokenKind2["Operator"] = 2048] = "Operator";
5320
4918
  TokenKind2[TokenKind2["FilteredValue"] = 4096] = "FilteredValue";
4919
+ TokenKind2[TokenKind2["GroupedExpression"] = 8192] = "GroupedExpression";
5321
4920
  TokenKind2[TokenKind2["Delimited"] = 12] = "Delimited";
5322
4921
  })(TokenKind || (TokenKind = {}));
5323
4922
  function isDelimitedToken(val) {
@@ -5360,8 +4959,12 @@ function isRangeToken(val) {
5360
4959
  return getKind(val) === TokenKind.Range;
5361
4960
  }
5362
4961
  __name(isRangeToken, "isRangeToken");
4962
+ function isFilteredValueToken(val) {
4963
+ return getKind(val) === TokenKind.FilteredValue;
4964
+ }
4965
+ __name(isFilteredValueToken, "isFilteredValueToken");
5363
4966
  function isValueToken(val) {
5364
- return (getKind(val) & 1667) > 0;
4967
+ return (getKind(val) & 5763) > 0;
5365
4968
  }
5366
4969
  __name(isValueToken, "isValueToken");
5367
4970
  function getKind(val) {
@@ -5379,7 +4982,7 @@ var Context = class _Context {
5379
4982
  static {
5380
4983
  __name(this, "Context");
5381
4984
  }
5382
- constructor(env = {}, opts = defaultOptions, renderOptions = {}, { memoryLimit, renderLimit } = {}) {
4985
+ constructor(env = {}, opts = defaultOptions, renderOptions = {}, { memoryLimit, renderLimit, liquid } = {}) {
5383
4986
  var _a, _b, _c, _d, _e;
5384
4987
  this.scopes = [createScope()];
5385
4988
  this.registers = {};
@@ -5393,6 +4996,7 @@ var Context = class _Context {
5393
4996
  this.ownPropertyOnly = (_c = renderOptions.ownPropertyOnly) !== null && _c !== void 0 ? _c : opts.ownPropertyOnly;
5394
4997
  this.memoryLimit = memoryLimit !== null && memoryLimit !== void 0 ? memoryLimit : new Limiter("memory alloc", (_d = renderOptions.memoryLimit) !== null && _d !== void 0 ? _d : opts.memoryLimit);
5395
4998
  this.renderLimit = renderLimit !== null && renderLimit !== void 0 ? renderLimit : new Limiter("template render", getPerformance().now() + ((_e = renderOptions.renderLimit) !== null && _e !== void 0 ? _e : opts.renderLimit));
4999
+ this.liquid = liquid;
5396
5000
  }
5397
5001
  getRegister(key, defaultValue = void 0) {
5398
5002
  return this.registers[key] = this.registers[key] || defaultValue;
@@ -5456,7 +5060,8 @@ var Context = class _Context {
5456
5060
  ownPropertyOnly: this.ownPropertyOnly
5457
5061
  }, {
5458
5062
  renderLimit: this.renderLimit,
5459
- memoryLimit: this.memoryLimit
5063
+ memoryLimit: this.memoryLimit,
5064
+ liquid: this.liquid
5460
5065
  });
5461
5066
  }
5462
5067
  findScope(key) {
@@ -5474,8 +5079,8 @@ var Context = class _Context {
5474
5079
  key = toValue(key);
5475
5080
  if (isNil(obj))
5476
5081
  return obj;
5477
- if (isArray(obj) && key < 0)
5478
- return obj[obj.length + +key];
5082
+ if (isArray(obj) && isNumber(key))
5083
+ return readArrayElement(obj, key, this.ownPropertyOnly);
5479
5084
  const value = readJSProperty(obj, key, this.ownPropertyOnly);
5480
5085
  if (value === void 0 && obj instanceof Drop)
5481
5086
  return obj.liquidMethodMissing(key, this);
@@ -5484,9 +5089,9 @@ var Context = class _Context {
5484
5089
  if (key === "size")
5485
5090
  return readSize(obj);
5486
5091
  else if (key === "first")
5487
- return readFirst(obj);
5092
+ return readFirst(obj, this.ownPropertyOnly);
5488
5093
  else if (key === "last")
5489
- return readLast(obj);
5094
+ return readLast(obj, this.ownPropertyOnly);
5490
5095
  return value;
5491
5096
  }
5492
5097
  };
@@ -5496,16 +5101,16 @@ function readJSProperty(obj, key, ownPropertyOnly) {
5496
5101
  return obj[key];
5497
5102
  }
5498
5103
  __name(readJSProperty, "readJSProperty");
5499
- function readFirst(obj) {
5104
+ function readFirst(obj, ownPropertyOnly) {
5500
5105
  if (isArray(obj))
5501
- return obj[0];
5502
- return obj["first"];
5106
+ return readArrayElement(obj, 0, ownPropertyOnly);
5107
+ return readJSProperty(obj, "first", ownPropertyOnly);
5503
5108
  }
5504
5109
  __name(readFirst, "readFirst");
5505
- function readLast(obj) {
5110
+ function readLast(obj, ownPropertyOnly) {
5506
5111
  if (isArray(obj))
5507
- return obj[obj.length - 1];
5508
- return obj["last"];
5112
+ return readArrayElement(obj, -1, ownPropertyOnly);
5113
+ return readJSProperty(obj, "last", ownPropertyOnly);
5509
5114
  }
5510
5115
  __name(readLast, "readLast");
5511
5116
  function readSize(obj) {
@@ -5530,14 +5135,21 @@ var divided_by = argumentsToNumber((dividend, divisor, integerArithmetic = false
5530
5135
  var floor = argumentsToNumber(Math.floor);
5531
5136
  var minus = argumentsToNumber((v, arg) => v - arg);
5532
5137
  var plus = argumentsToNumber((lhs, rhs) => lhs + rhs);
5533
- var modulo = argumentsToNumber((v, arg) => v % arg);
5138
+ var modulo = argumentsToNumber((v, arg) => (v % arg + arg) % arg);
5534
5139
  var times = argumentsToNumber((v, arg) => v * arg);
5140
+ function shiftDecimal(n, exponent) {
5141
+ const [mantissa, power = "0"] = String(n).split("e");
5142
+ return Number(`${mantissa}e${Number(power) + exponent}`);
5143
+ }
5144
+ __name(shiftDecimal, "shiftDecimal");
5535
5145
  function round(v, arg = 0) {
5536
5146
  v = toNumber(v);
5537
5147
  arg = toNumber(arg);
5538
- const amp = Math.pow(10, arg);
5539
- const scaled = v * amp * (1 + Number.EPSILON);
5540
- return Math.round(scaled) / amp;
5148
+ const scaled = shiftDecimal(Math.abs(v), arg);
5149
+ if (!(scaled <= Number.MAX_SAFE_INTEGER))
5150
+ return v;
5151
+ const rounded = shiftDecimal(Math.round(scaled), -arg);
5152
+ return v < 0 ? -rounded : rounded;
5541
5153
  }
5542
5154
  __name(round, "round");
5543
5155
  var mathFilters = /* @__PURE__ */ Object.freeze({
@@ -5554,7 +5166,7 @@ var mathFilters = /* @__PURE__ */ Object.freeze({
5554
5166
  times,
5555
5167
  round
5556
5168
  });
5557
- var url_decode = /* @__PURE__ */ __name((x) => decodeURIComponent(stringify(x)).replace(/\+/g, " "), "url_decode");
5169
+ var url_decode = /* @__PURE__ */ __name((x) => decodeURIComponent(stringify(x).replace(/\+/g, " ")), "url_decode");
5558
5170
  var url_encode = /* @__PURE__ */ __name((x) => encodeURIComponent(stringify(x)).replace(/%20/g, "+"), "url_encode");
5559
5171
  var cgi_escape = /* @__PURE__ */ __name((x) => encodeURIComponent(stringify(x)).replace(/%20/g, "+").replace(/[!'()*]/g, (c) => "%" + c.charCodeAt(0).toString(16).toUpperCase()), "cgi_escape");
5560
5172
  var uri_escape = /* @__PURE__ */ __name((x) => encodeURI(stringify(x)).replace(/%5B/g, "[").replace(/%5D/g, "]"), "uri_escape");
@@ -5593,12 +5205,18 @@ var urlFilters = /* @__PURE__ */ Object.freeze({
5593
5205
  var join = argumentsToValue(function(v, arg) {
5594
5206
  const array = toArray(v);
5595
5207
  const sep2 = isNil(arg) ? " " : stringify(arg);
5596
- const complexity = array.length * (1 + sep2.length);
5597
- this.context.memoryLimit.use(complexity);
5598
- return array.join(sep2);
5208
+ let outputSize = sep2.length * Math.max(array.length - 1, 0);
5209
+ for (let i = 0; i < array.length; i++)
5210
+ outputSize += String(array[i]).length;
5211
+ this.context.memoryLimit.use(outputSize);
5212
+ return Array.prototype.join.call(array, sep2);
5213
+ });
5214
+ var last$1 = argumentsToValue(function(v) {
5215
+ return isArrayLike(v) ? readArrayElement(v, -1, this.context.ownPropertyOnly) : "";
5216
+ });
5217
+ var first = argumentsToValue(function(v) {
5218
+ return isArrayLike(v) ? readArrayElement(v, 0, this.context.ownPropertyOnly) : "";
5599
5219
  });
5600
- var last$1 = argumentsToValue((v) => isArrayLike(v) ? last(v) : "");
5601
- var first = argumentsToValue((v) => isArrayLike(v) ? v[0] : "");
5602
5220
  var reverse = argumentsToValue(function(v) {
5603
5221
  const array = toArray(v);
5604
5222
  this.context.memoryLimit.use(array.length);
@@ -5649,14 +5267,14 @@ __name(sum, "sum");
5649
5267
  function compact(arr) {
5650
5268
  const array = toArray(arr);
5651
5269
  this.context.memoryLimit.use(array.length);
5652
- return array.filter((x) => !isNil(toValue(x)));
5270
+ return Array.prototype.filter.call(array, (x) => !isNil(toValue(x)));
5653
5271
  }
5654
5272
  __name(compact, "compact");
5655
5273
  function concat(v, arg = []) {
5656
5274
  const lhs = toArray(v);
5657
5275
  const rhs = toArray(arg);
5658
5276
  this.context.memoryLimit.use(lhs.length + rhs.length);
5659
- return lhs.concat(rhs);
5277
+ return Array.prototype.concat.call(lhs, rhs);
5660
5278
  }
5661
5279
  __name(concat, "concat");
5662
5280
  function push(v, arg) {
@@ -5693,31 +5311,40 @@ function slice(v, begin, length = 1) {
5693
5311
  return [];
5694
5312
  if (!isArray(v))
5695
5313
  v = stringify(v);
5696
- begin = begin < 0 ? v.length + begin : begin;
5314
+ begin = begin < 0 ? (isArray(v) ? v.length : codePointLength(v)) + begin : begin;
5315
+ if (begin < 0 || length < 0)
5316
+ return isArray(v) ? [] : "";
5697
5317
  this.context.memoryLimit.use(length);
5698
- return v.slice(begin, begin + length);
5318
+ if (isArray(v))
5319
+ return Array.prototype.slice.call(v, begin, begin + length);
5320
+ const start = advanceCodePoints(v, 0, begin);
5321
+ return v.slice(start, advanceCodePoints(v, start, length));
5699
5322
  }
5700
5323
  __name(slice, "slice");
5701
- function expectedMatcher(expected) {
5324
+ function* matches(value, expected) {
5702
5325
  if (this.context.opts.jekyllWhere) {
5703
- return (v) => EmptyDrop.is(expected) ? equals(v, expected) : isArray(v) ? arrayIncludes(v, expected) : equals(v, expected);
5704
- } else if (expected === void 0) {
5705
- return (v) => isTruthy(v, this.context);
5706
- } else {
5707
- return (v) => equals(v, expected);
5326
+ if (EmptyDrop.is(expected))
5327
+ return yield equals(value, expected);
5328
+ if (isArray(value))
5329
+ return yield arrayIncludes(value, expected);
5330
+ return yield equals(value, expected);
5708
5331
  }
5332
+ if (expected === void 0)
5333
+ return isTruthy(value, this.context);
5334
+ return yield equals(value, expected);
5709
5335
  }
5710
- __name(expectedMatcher, "expectedMatcher");
5336
+ __name(matches, "matches");
5711
5337
  function* filter(include, arr, property, expected) {
5712
- const values = [];
5713
5338
  arr = toArray(arr);
5714
5339
  this.context.memoryLimit.use(arr.length);
5715
5340
  const token = new Tokenizer(stringify(property)).readScopeValue();
5341
+ const result = [];
5716
5342
  for (const item of arr) {
5717
- values.push(yield evalToken(token, this.context.spawn(item)));
5343
+ const value = yield evalToken(token, this.context.spawn(item));
5344
+ if ((yield matches.call(this, value, expected)) === include)
5345
+ result.push(item);
5718
5346
  }
5719
- const matcher = expectedMatcher.call(this, expected);
5720
- return arr.filter((_, i) => matcher(values[i]) === include);
5347
+ return result;
5721
5348
  }
5722
5349
  __name(filter, "filter");
5723
5350
  function* filter_exp(include, arr, itemName, exp) {
@@ -5784,10 +5411,9 @@ __name(group_by_exp, "group_by_exp");
5784
5411
  function* search(arr, property, expected) {
5785
5412
  const token = new Tokenizer(stringify(property)).readScopeValue();
5786
5413
  const array = toArray(arr);
5787
- const matcher = expectedMatcher.call(this, expected);
5788
5414
  for (let index = 0; index < array.length; index++) {
5789
5415
  const value = yield evalToken(token, this.context.spawn(array[index]));
5790
- if (matcher(value))
5416
+ if (yield matches.call(this, value, expected))
5791
5417
  return [index, array[index]];
5792
5418
  }
5793
5419
  }
@@ -5904,7 +5530,10 @@ function date_to_xmlschema(v) {
5904
5530
  }
5905
5531
  __name(date_to_xmlschema, "date_to_xmlschema");
5906
5532
  function date_to_rfc822(v) {
5907
- return date.call(this, v, "%a, %d %b %Y %H:%M:%S %z");
5533
+ const date2 = parseDate(v, this.context.opts, void 0, "en-US");
5534
+ if (!date2)
5535
+ return v;
5536
+ return strftime(date2, "%a, %d %b %Y %H:%M:%S %z", this.context.memoryLimit);
5908
5537
  }
5909
5538
  __name(date_to_rfc822, "date_to_rfc822");
5910
5539
  function date_to_string(v, type, style) {
@@ -5927,10 +5556,9 @@ function stringify_date(v, month_type, type, style) {
5927
5556
  return strftime(date2, `%d ${month_type} %Y`, ml);
5928
5557
  }
5929
5558
  __name(stringify_date, "stringify_date");
5930
- function parseDate(v, opts, timezoneOffset) {
5559
+ function parseDate(v, opts, timezoneOffset, locale = opts.locale) {
5931
5560
  let date2;
5932
5561
  const defaultTimezoneOffset = timezoneOffset !== null && timezoneOffset !== void 0 ? timezoneOffset : opts.timezoneOffset;
5933
- const locale = opts.locale;
5934
5562
  v = toValue(v);
5935
5563
  if (isNil(v)) {
5936
5564
  return void 0;
@@ -5978,17 +5606,34 @@ function prepend(v, arg) {
5978
5606
  return rhs + lhs;
5979
5607
  }
5980
5608
  __name(prepend, "prepend");
5609
+ function getTrimStart(str, chars) {
5610
+ let start = 0;
5611
+ for (const char of str) {
5612
+ if (!chars.has(char))
5613
+ break;
5614
+ start += char.length;
5615
+ }
5616
+ return start;
5617
+ }
5618
+ __name(getTrimStart, "getTrimStart");
5619
+ function getTrimEnd(str, chars, start = 0) {
5620
+ let end = str.length;
5621
+ while (end > start) {
5622
+ const size2 = end - start >= 2 && str.codePointAt(end - 2) > 65535 ? 2 : 1;
5623
+ if (!chars.has(str.slice(end - size2, end)))
5624
+ break;
5625
+ end -= size2;
5626
+ }
5627
+ return end;
5628
+ }
5629
+ __name(getTrimEnd, "getTrimEnd");
5981
5630
  function lstrip(v, chars) {
5982
5631
  const str = stringify(v);
5983
5632
  this.context.memoryLimit.use(str.length);
5984
5633
  if (chars) {
5985
5634
  chars = stringify(chars);
5986
5635
  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 "";
5636
+ return str.slice(getTrimStart(str, new Set(chars)));
5992
5637
  }
5993
5638
  return str.trimStart();
5994
5639
  }
@@ -6035,11 +5680,7 @@ function rstrip(str, chars) {
6035
5680
  if (chars) {
6036
5681
  chars = stringify(chars);
6037
5682
  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 "";
5683
+ return str.slice(0, getTrimEnd(str, new Set(chars)));
6043
5684
  }
6044
5685
  return str.trimEnd();
6045
5686
  }
@@ -6059,13 +5700,8 @@ function strip(v, chars) {
6059
5700
  if (chars) {
6060
5701
  const set = new Set(stringify(chars));
6061
5702
  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);
5703
+ const start = getTrimStart(str, set);
5704
+ return str.slice(start, getTrimEnd(str, set, start));
6069
5705
  }
6070
5706
  return str.trim();
6071
5707
  }
@@ -6076,6 +5712,12 @@ function strip_newlines(v) {
6076
5712
  return str.replace(/\r?\n/gm, "");
6077
5713
  }
6078
5714
  __name(strip_newlines, "strip_newlines");
5715
+ function squish(v) {
5716
+ const str = stringify(v);
5717
+ this.context.memoryLimit.use(str.length);
5718
+ return str.replace(/\s+/g, " ").trim();
5719
+ }
5720
+ __name(squish, "squish");
6079
5721
  function capitalize(str) {
6080
5722
  str = stringify(str);
6081
5723
  this.context.memoryLimit.use(str.length);
@@ -6115,16 +5757,16 @@ function truncate(v, l = 50, o = "...") {
6115
5757
  const str = stringify(v);
6116
5758
  o = stringify(o);
6117
5759
  this.context.memoryLimit.use(str.length + o.length);
6118
- if (str.length <= l)
5760
+ if (str.length <= l || advanceCodePoints(str, 0, l) >= str.length)
6119
5761
  return v;
6120
- return str.substring(0, l - o.length) + o;
5762
+ return str.slice(0, advanceCodePoints(str, 0, Math.max(l - codePointLength(o), 0))) + o;
6121
5763
  }
6122
5764
  __name(truncate, "truncate");
6123
5765
  function truncatewords(v, words = 15, o = "...") {
6124
5766
  const str = stringify(v);
6125
5767
  o = stringify(o);
6126
5768
  this.context.memoryLimit.use(str.length + o.length);
6127
- const arr = str.split(/\s+/);
5769
+ const arr = str.trimStart().split(/\s+/);
6128
5770
  if (words <= 0)
6129
5771
  words = 1;
6130
5772
  let ret = arr.slice(0, words).join(" ");
@@ -6155,9 +5797,13 @@ function number_of_words(input, mode) {
6155
5797
  }
6156
5798
  }
6157
5799
  __name(number_of_words, "number_of_words");
6158
- function array_to_sentence_string(array, connector = "and") {
5800
+ function array_to_sentence_string(input, connector = "and") {
5801
+ const array = toArray(input);
6159
5802
  connector = stringify(connector);
6160
- this.context.memoryLimit.use(array.length + connector.length);
5803
+ let outputSize = connector.length + array.length * 2;
5804
+ for (let i = 0; i < array.length; i++)
5805
+ outputSize += stringify(array[i]).length;
5806
+ this.context.memoryLimit.use(outputSize);
6161
5807
  switch (array.length) {
6162
5808
  case 0:
6163
5809
  return "";
@@ -6184,6 +5830,7 @@ var stringFilters = /* @__PURE__ */ Object.freeze({
6184
5830
  split,
6185
5831
  strip,
6186
5832
  strip_newlines,
5833
+ squish,
6187
5834
  capitalize,
6188
5835
  replace,
6189
5836
  replace_first,
@@ -6195,7 +5842,12 @@ var stringFilters = /* @__PURE__ */ Object.freeze({
6195
5842
  array_to_sentence_string
6196
5843
  });
6197
5844
  function base64Encode(str) {
6198
- return btoa(String.fromCharCode(...new TextEncoder().encode(str)));
5845
+ const bytes = new TextEncoder().encode(str);
5846
+ let binary = "";
5847
+ for (let i = 0; i < bytes.length; i += 32768) {
5848
+ binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
5849
+ }
5850
+ return btoa(binary);
6199
5851
  }
6200
5852
  __name(base64Encode, "base64Encode");
6201
5853
  function base64Decode(str) {
@@ -6215,9 +5867,17 @@ __name(base64_encode, "base64_encode");
6215
5867
  function base64_decode(value) {
6216
5868
  const str = stringify(value);
6217
5869
  this.context.memoryLimit.use(str.length);
5870
+ assert(isBase64(str), "invalid base64 provided to base64_decode");
6218
5871
  return base64Decode(str);
6219
5872
  }
6220
5873
  __name(base64_decode, "base64_decode");
5874
+ function isBase64(str) {
5875
+ str = str.replace(/[\t\n\f\r ]/g, "");
5876
+ if (str.length % 4 === 0)
5877
+ str = str.replace(/==?$/, "");
5878
+ return str.length % 4 !== 1 && /^[A-Za-z0-9+/]*$/.test(str);
5879
+ }
5880
+ __name(isBase64, "isBase64");
6221
5881
  var base64Filters = /* @__PURE__ */ Object.freeze({
6222
5882
  __proto__: null,
6223
5883
  base64_encode,
@@ -6469,12 +6129,12 @@ var CaseTag = class extends Tag {
6469
6129
  }
6470
6130
  *render(ctx, emitter) {
6471
6131
  const r = this.liquid.renderer;
6472
- const target = toValue(yield this.value.value(ctx, ctx.opts.lenientIf));
6132
+ const target = yield toValue(yield this.value.value(ctx, ctx.opts.lenientIf));
6473
6133
  let branchHit = false;
6474
6134
  for (const branch of this.branches) {
6475
6135
  for (const valueToken of branch.values) {
6476
6136
  const value = yield evalToken(valueToken, ctx, ctx.opts.lenientIf);
6477
- if (equals(target, value)) {
6137
+ if (yield equals(target, value)) {
6478
6138
  yield r.renderTemplates(branch.templates, ctx, emitter);
6479
6139
  branchHit = true;
6480
6140
  break;
@@ -6755,6 +6415,7 @@ var CycleTag = class extends Tag {
6755
6415
  constructor(token, remainTokens, liquid) {
6756
6416
  super(token, remainTokens, liquid);
6757
6417
  this.candidates = [];
6418
+ const begin = this.tokenizer.p;
6758
6419
  const group = this.tokenizer.readValue();
6759
6420
  this.tokenizer.skipBlank();
6760
6421
  if (group) {
@@ -6762,28 +6423,33 @@ var CycleTag = class extends Tag {
6762
6423
  this.group = group;
6763
6424
  this.tokenizer.advance();
6764
6425
  } else
6765
- this.candidates.push(group);
6426
+ this.tokenizer.p = begin;
6766
6427
  }
6767
6428
  while (!this.tokenizer.end()) {
6768
- const value = this.tokenizer.readValue();
6769
- if (value)
6770
- this.candidates.push(value);
6429
+ const value = this.tokenizer.readFilteredValue();
6430
+ this.candidates.push(value);
6771
6431
  this.tokenizer.readTo(",");
6772
6432
  }
6773
6433
  this.tokenizer.assert(this.candidates.length, () => `empty candidates: "${token.getText()}"`);
6774
6434
  }
6775
6435
  *render(ctx, emitter) {
6436
+ var _a;
6776
6437
  const group = yield evalToken(this.group, ctx);
6777
- const fingerprint = `cycle:${group}:` + this.candidates.join(",");
6438
+ const fingerprint = `cycle:${group}:` + this.candidates.map((c) => c.getText()).join(",");
6778
6439
  const groups = ctx.getRegister("cycle", {});
6779
6440
  let idx = groups[fingerprint];
6780
6441
  if (idx === void 0) {
6781
6442
  idx = groups[fingerprint] = 0;
6782
6443
  }
6783
- const candidate = this.candidates[idx];
6444
+ const candidate = new Value(this.candidates[idx], this.liquid);
6784
6445
  idx = (idx + 1) % this.candidates.length;
6785
6446
  groups[fingerprint] = idx;
6786
- return yield evalToken(candidate, ctx);
6447
+ let val = yield toValue(yield candidate.value(ctx, false));
6448
+ const outputEscape = this.liquid.options.outputEscape;
6449
+ if (outputEscape && !((_a = candidate.filters[candidate.filters.length - 1]) === null || _a === void 0 ? void 0 : _a.raw)) {
6450
+ val = yield outputEscape.call({ context: ctx, token: this.token, liquid: this.liquid }, val);
6451
+ }
6452
+ return val;
6787
6453
  }
6788
6454
  *arguments() {
6789
6455
  yield* this.candidates;
@@ -6823,7 +6489,7 @@ var IfTag = class extends Tag {
6823
6489
  *render(ctx, emitter) {
6824
6490
  const r = this.liquid.renderer;
6825
6491
  for (const { value, templates } of this.branches) {
6826
- const v = yield value.value(ctx, ctx.opts.lenientIf);
6492
+ const v = yield toValue(yield value.value(ctx, ctx.opts.lenientIf));
6827
6493
  if (isTruthy(v, ctx)) {
6828
6494
  yield r.renderTemplates(templates, ctx, emitter);
6829
6495
  return;
@@ -7116,7 +6782,7 @@ var UnlessTag = class extends Tag {
7116
6782
  *render(ctx, emitter) {
7117
6783
  const r = this.liquid.renderer;
7118
6784
  for (const { value, test, templates } of this.branches) {
7119
- const v = yield value.value(ctx, ctx.opts.lenientIf);
6785
+ const v = yield toValue(yield value.value(ctx, ctx.opts.lenientIf));
7120
6786
  if (test(v, ctx)) {
7121
6787
  yield r.renderTemplates(templates, ctx, emitter);
7122
6788
  return;
@@ -7163,9 +6829,14 @@ var EchoTag = class extends Tag {
7163
6829
  }
7164
6830
  }
7165
6831
  *render(ctx, emitter) {
6832
+ var _a;
7166
6833
  if (!this.value)
7167
6834
  return;
7168
- const val = yield this.value.value(ctx, false);
6835
+ let val = yield toValue(yield this.value.value(ctx, false));
6836
+ const outputEscape = this.liquid.options.outputEscape;
6837
+ if (outputEscape && !((_a = this.value.filters[this.value.filters.length - 1]) === null || _a === void 0 ? void 0 : _a.raw)) {
6838
+ val = yield outputEscape.call({ context: ctx, token: this.token, liquid: this.liquid }, val);
6839
+ }
7169
6840
  emitter.write(val);
7170
6841
  }
7171
6842
  *arguments() {
@@ -7244,7 +6915,7 @@ var Liquid = class _Liquid {
7244
6915
  return parser.parse(html, filepath);
7245
6916
  }
7246
6917
  _render(tpl, scope, renderOptions) {
7247
- const ctx = scope instanceof Context ? scope : new Context(scope, this.options, renderOptions);
6918
+ const ctx = scope instanceof Context ? scope : new Context(scope, this.options, renderOptions, { liquid: this });
7248
6919
  return this.renderer.renderTemplates(tpl, ctx);
7249
6920
  }
7250
6921
  render(tpl, scope, renderOptions) {
@@ -7256,7 +6927,7 @@ var Liquid = class _Liquid {
7256
6927
  return toValueSync(this._render(tpl, scope, Object.assign(Object.assign({}, renderOptions), { sync: true })));
7257
6928
  }
7258
6929
  renderToNodeStream(tpl, scope, renderOptions = {}) {
7259
- const ctx = new Context(scope, this.options, renderOptions);
6930
+ const ctx = new Context(scope, this.options, renderOptions, { liquid: this });
7260
6931
  return this.renderer.renderTemplatesToNodeStream(tpl, ctx);
7261
6932
  }
7262
6933
  _parseAndRender(html, scope, renderOptions) {
@@ -7308,7 +6979,7 @@ var Liquid = class _Liquid {
7308
6979
  }
7309
6980
  _evalValue(str, scope) {
7310
6981
  const value = new Value(str, this);
7311
- const ctx = scope instanceof Context ? scope : new Context(scope, this.options);
6982
+ const ctx = scope instanceof Context ? scope : new Context(scope, this.options, {}, { liquid: this });
7312
6983
  return value.value(ctx);
7313
6984
  }
7314
6985
  evalValue(str, scope) {
@@ -7322,6 +6993,9 @@ var Liquid = class _Liquid {
7322
6993
  registerFilter(name, filter2) {
7323
6994
  this.filters[name] = filter2;
7324
6995
  }
6996
+ unregisterFilter(name) {
6997
+ delete this.filters[name];
6998
+ }
7325
6999
  registerTag(name, tag) {
7326
7000
  this.tags[name] = isFunction(tag) ? tag : createTagClass(tag);
7327
7001
  }
@@ -7455,15 +7129,16 @@ function matchesTemplate(search2, template) {
7455
7129
  let templateIndex = 0;
7456
7130
  let starIndex = -1;
7457
7131
  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) {
7132
+ while (searchIndex < search2.length) if (templateIndex < template.length && (template[templateIndex] === search2[searchIndex] || template[templateIndex] === "*")) {
7133
+ if (template[templateIndex] === "*") {
7134
+ starIndex = templateIndex;
7135
+ matchIndex = searchIndex;
7136
+ templateIndex++;
7137
+ } else {
7138
+ searchIndex++;
7139
+ templateIndex++;
7140
+ }
7141
+ } else if (starIndex !== -1) {
7467
7142
  templateIndex = starIndex + 1;
7468
7143
  matchIndex++;
7469
7144
  searchIndex = matchIndex;
@@ -7483,7 +7158,7 @@ function createDebug(namespace, options) {
7483
7158
  let enableOverride;
7484
7159
  let namespacesCache;
7485
7160
  let enabledCache;
7486
- const debug2 = /* @__PURE__ */ __name((...args) => {
7161
+ const debug2 = /* @__PURE__ */ __name(((...args) => {
7487
7162
  if (!debug2.enabled) return;
7488
7163
  const curr = Date.now();
7489
7164
  const diff = curr - (prevTime || curr);
@@ -7505,7 +7180,7 @@ function createDebug(namespace, options) {
7505
7180
  });
7506
7181
  options.formatArgs.call(debug2, diff, args);
7507
7182
  debug2.log(...args);
7508
- }, "debug");
7183
+ }), "debug");
7509
7184
  debug2.extend = function(namespace2, delimiter = ":") {
7510
7185
  return createDebug(this.namespace + delimiter + namespace2, {
7511
7186
  useColors: this.useColors,
@@ -7555,6 +7230,48 @@ function enabled(name) {
7555
7230
  }
7556
7231
  __name(enabled, "enabled");
7557
7232
 
7233
+ // ../../node_modules/obug/dist/plain.js
7234
+ function formatArgs(diff, args) {
7235
+ args[0] = `${this.namespace} ${args[0]} +${this.humanize(diff)}`;
7236
+ }
7237
+ __name(formatArgs, "formatArgs");
7238
+ var defaultOptions2 = {
7239
+ useColors: false,
7240
+ color: "",
7241
+ formatArgs,
7242
+ formatters: {
7243
+ /**
7244
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
7245
+ */
7246
+ j(v) {
7247
+ try {
7248
+ return JSON.stringify(v);
7249
+ } catch (error) {
7250
+ return `[UnexpectedJSONParseError]: ${error.message}`;
7251
+ }
7252
+ }
7253
+ },
7254
+ inspectOpts: {},
7255
+ humanize,
7256
+ log: console.debug || console.log || (() => {
7257
+ })
7258
+ };
7259
+ function createDebug2(namespace, options) {
7260
+ return createDebug(namespace, Object.assign({}, defaultOptions2, options));
7261
+ }
7262
+ __name(createDebug2, "createDebug");
7263
+ function load() {
7264
+ let r;
7265
+ try {
7266
+ r = localStorage.getItem("debug") || localStorage.getItem("DEBUG");
7267
+ } catch (_unused) {
7268
+ }
7269
+ if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
7270
+ return r || "";
7271
+ }
7272
+ __name(load, "load");
7273
+ enable(load());
7274
+
7558
7275
  // ../../node_modules/obug/dist/browser.js
7559
7276
  var colors = [
7560
7277
  "#0000CC",
@@ -7634,7 +7351,7 @@ var colors = [
7634
7351
  "#FFCC00",
7635
7352
  "#FFCC33"
7636
7353
  ];
7637
- function formatArgs(diff, args) {
7354
+ function formatArgs2(diff, args) {
7638
7355
  const { useColors } = this;
7639
7356
  args[0] = `${(useColors ? "%c" : "") + this.namespace + (useColors ? " %c" : " ") + args[0] + (useColors ? "%c " : " ")}+${this.humanize(diff)}`;
7640
7357
  if (!useColors) return;
@@ -7649,53 +7366,17 @@ function formatArgs(diff, args) {
7649
7366
  });
7650
7367
  args.splice(lastC, 0, c);
7651
7368
  }
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) {
7369
+ __name(formatArgs2, "formatArgs");
7370
+ function createDebug3(namespace, options) {
7676
7371
  var _ref;
7677
7372
  const color = (_ref = options && options.color) !== null && _ref !== void 0 ? _ref : selectColor(colors, namespace);
7678
- return createDebug(namespace, Object.assign(defaultOptions2, { color }, options));
7679
- }
7680
- __name(createDebug2, "createDebug");
7681
- function localstorage() {
7682
- try {
7683
- return localStorage;
7684
- } catch (_unused) {
7685
- }
7373
+ return createDebug2(namespace, Object.assign({
7374
+ useColors: true,
7375
+ color,
7376
+ formatArgs: formatArgs2
7377
+ }, options));
7686
7378
  }
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());
7379
+ __name(createDebug3, "createDebug");
7699
7380
 
7700
7381
  // ../../src/Util/IsBuildAwesome.js
7701
7382
  function isUsingBuildAwesome() {
@@ -7705,10 +7386,10 @@ __name(isUsingBuildAwesome, "isUsingBuildAwesome");
7705
7386
 
7706
7387
  // ../../src/Util/DebugLogUtil.js
7707
7388
  var PREFIX = isUsingBuildAwesome() ? "BuildAwesome:" : "Eleventy:";
7708
- function createDebug3(name) {
7709
- return createDebug2(`${PREFIX}:${name}`);
7389
+ function createDebug4(name) {
7390
+ return createDebug3(`${PREFIX}${name}`);
7710
7391
  }
7711
- __name(createDebug3, "createDebug");
7392
+ __name(createDebug4, "createDebug");
7712
7393
 
7713
7394
  // ../../src/Errors/BaseError.js
7714
7395
  var BaseError = class extends Error {
@@ -7733,6 +7414,14 @@ var BaseError = class extends Error {
7733
7414
  this.originalError = originalError;
7734
7415
  }
7735
7416
  }
7417
+ /**
7418
+ * @param {string} filePath - The file that caused the error.
7419
+ * @returns {this}
7420
+ */
7421
+ setFilePath(filePath) {
7422
+ this.filePath = filePath;
7423
+ return this;
7424
+ }
7736
7425
  };
7737
7426
 
7738
7427
  // ../../src/Engines/TemplateEngine.js
@@ -7741,7 +7430,7 @@ var TemplateEngineConfigError = class extends BaseError {
7741
7430
  __name(this, "TemplateEngineConfigError");
7742
7431
  }
7743
7432
  };
7744
- var debug = createDebug3("TemplateEngine");
7433
+ var debug = createDebug4("TemplateEngine");
7745
7434
  var AMENDED_INSTANCES = /* @__PURE__ */ new Set();
7746
7435
  var TemplateEngine = class {
7747
7436
  static {
@@ -7750,6 +7439,7 @@ var TemplateEngine = class {
7750
7439
  #extensionMap;
7751
7440
  #engineManager;
7752
7441
  #benchmarks;
7442
+ #configEventListeners = [];
7753
7443
  constructor(name, eleventyConfig) {
7754
7444
  this.name = name;
7755
7445
  this.engineLib = null;
@@ -7761,6 +7451,18 @@ var TemplateEngine = class {
7761
7451
  get cacheable() {
7762
7452
  return false;
7763
7453
  }
7454
+ // Engine instances are replaced on each build, so their listeners must not outlive them
7455
+ addConfigEventListener(eventName, fn) {
7456
+ let events = this.config.events;
7457
+ this.#configEventListeners.push([events, eventName, fn]);
7458
+ events.on(eventName, fn);
7459
+ }
7460
+ removeConfigEventListeners() {
7461
+ for (let [events, eventName, fn] of this.#configEventListeners) {
7462
+ events.off(eventName, fn);
7463
+ }
7464
+ this.#configEventListeners = [];
7465
+ }
7764
7466
  get dirs() {
7765
7467
  return this.eleventyConfig.directories;
7766
7468
  }
@@ -7876,6 +7578,9 @@ var TemplateEngine = class {
7876
7578
  needsCompilation(str) {
7877
7579
  return true;
7878
7580
  }
7581
+ // Runs at compile time for pipeline steps that compile later, during render
7582
+ async ready() {
7583
+ }
7879
7584
  /**
7880
7585
  * Make sure compile is implemented downstream.
7881
7586
  * @abstract
@@ -7894,13 +7599,21 @@ var TemplateEngine = class {
7894
7599
  }
7895
7600
  return true;
7896
7601
  }
7602
+ // e.g. a template’s include, import, extends, or layout file, recorded when it is used
7603
+ // `from` is the engine name for string templates (e.g. the Render plugin’s `renderTemplate`)
7604
+ addDependency(from, to) {
7605
+ if (!from || !to) {
7606
+ return;
7607
+ }
7608
+ this.config.uses.addDependency(from, [to]);
7609
+ }
7897
7610
  isFileRelevantTo(inputPath, comparisonFile) {
7898
7611
  return this.config.uses.isFileRelevantTo(inputPath, comparisonFile);
7899
7612
  }
7900
7613
  };
7901
7614
 
7902
7615
  // ../../src/Engines/Util/ContextAugmenter.js
7903
- var DATA_KEYS = ["page", "eleventy"];
7616
+ var DATA_KEYS = ["page", "eleventy", "buildawesome", "collections"];
7904
7617
  function augmentObject(targetObject, options = {}) {
7905
7618
  options = Object.assign(
7906
7619
  {
@@ -7951,19 +7664,12 @@ var Liquid2 = class _Liquid extends TemplateEngine {
7951
7664
  static {
7952
7665
  __name(this, "Liquid");
7953
7666
  }
7954
- static argumentLexerOptions = {
7955
- number: /[0-9]+\.*[0-9]*/,
7956
- doubleQuoteString: /"(?:\\["\\]|[^\n"\\])*"/,
7957
- singleQuoteString: /'(?:\\['\\]|[^\n'\\])*'/,
7958
- keyword: /[a-zA-Z0-9.\-_]+/,
7959
- "ignore:whitespace": /[, \t]+/
7960
- // includes comma separator
7961
- };
7667
+ // Legacy argument tokens (number, double/single quoted string, keyword), separated by commas or whitespace.
7668
+ static argumentLexer = /([0-9]+\.*[0-9]*|"(?:\\["\\]|[^\n"\\])*"|'(?:\\['\\]|[^\n'\\])*'|[a-zA-Z0-9.\-_]+)|[, \t]+/y;
7962
7669
  constructor(name, eleventyConfig) {
7963
7670
  super(name, eleventyConfig);
7964
7671
  this.liquidOptions = this.config.liquidOptions || {};
7965
7672
  this.setLibrary(this.config.libraryOverrides.liquid);
7966
- this.argLexer = import_moo.default.compile(_Liquid.argumentLexerOptions);
7967
7673
  }
7968
7674
  get cacheable() {
7969
7675
  return true;
@@ -7971,6 +7677,7 @@ var Liquid2 = class _Liquid extends TemplateEngine {
7971
7677
  setLibrary(override) {
7972
7678
  this.liquidLib = override || new Liquid(this.getLiquidOptions());
7973
7679
  this.setEngineLib(this.liquidLib, Boolean(this.config.libraryOverrides.liquid));
7680
+ this.#trackPartialFiles();
7974
7681
  this.addFilters(this.config.liquidFilters);
7975
7682
  this.addCustomTags(this.config.liquidTags);
7976
7683
  this.addAllShortcodes(this.config.liquidShortcodes);
@@ -7979,16 +7686,46 @@ var Liquid2 = class _Liquid extends TemplateEngine {
7979
7686
  getLiquidOptions() {
7980
7687
  let defaults = {
7981
7688
  root: [this.dirs.includes, this.dirs.input],
7982
- // supplemented in compile with inputPath below
7983
7689
  extname: ".liquid",
7984
7690
  strictFilters: true,
7985
7691
  // cache: true,
7986
- jsTruthy: true
7692
+ jsTruthy: true,
7987
7693
  // Breaking in v4 #3507
7694
+ timezoneOffset: this.config.dateTimeZone?.zone ?? 0
7695
+ // Match `setDateTimeZone` (or UTC) when parsing dates, breaking in v4 #1905
7988
7696
  };
7697
+ if (this.dirs.layouts) {
7698
+ defaults.layouts = [this.dirs.layouts, ...defaults.root];
7699
+ }
7989
7700
  let options = Object.assign(defaults, this.liquidOptions || {});
7990
7701
  return options;
7991
7702
  }
7703
+ // Records `include`, `render`, and `layout` files in the dependency graph for incremental builds
7704
+ #trackPartialFiles() {
7705
+ let lib = this.liquidLib;
7706
+ if (typeof lib._parsePartialFile !== "function" || typeof lib._parseLayoutFile !== "function") {
7707
+ return;
7708
+ }
7709
+ let engine = this;
7710
+ let track = /* @__PURE__ */ __name((lookupType) => function(file, sync, currentFile) {
7711
+ let parser = new Parser(this);
7712
+ let lookup = parser.loader.lookup;
7713
+ parser.loader.lookup = function* (...args) {
7714
+ let filepath = yield* lookup.apply(this, args);
7715
+ engine.addDependency(currentFile || engine.name, filepath);
7716
+ return filepath;
7717
+ };
7718
+ if (parser.cache) {
7719
+ return (function* () {
7720
+ yield parser.loader.lookup(file, lookupType, sync, currentFile);
7721
+ return yield parser.parseFile(file, sync, lookupType, currentFile);
7722
+ })();
7723
+ }
7724
+ return parser.parseFile(file, sync, lookupType, currentFile);
7725
+ }, "track");
7726
+ lib._parsePartialFile = track(LookupType.Partials);
7727
+ lib._parseLayoutFile = track(LookupType.Layouts);
7728
+ }
7992
7729
  static wrapFilter(name, fn) {
7993
7730
  return function(...args) {
7994
7731
  if (typeof this.context?.get === "function") {
@@ -8048,38 +7785,66 @@ var Liquid2 = class _Liquid extends TemplateEngine {
8048
7785
  this.addPairedShortcode(name, shortcodes[name]);
8049
7786
  }
8050
7787
  }
8051
- static parseArguments(lexer, str) {
7788
+ static parseArguments(str) {
8052
7789
  let argArray = [];
8053
- if (!lexer) {
8054
- lexer = import_moo.default.compile(_Liquid.argumentLexerOptions);
7790
+ if (typeof str !== "string") {
7791
+ return argArray;
8055
7792
  }
8056
- if (typeof str === "string") {
8057
- lexer.reset(str);
8058
- let arg = lexer.next();
8059
- while (arg) {
8060
- if (arg.type.indexOf("ignore:") === -1) {
8061
- argArray.push(arg.value);
8062
- }
8063
- arg = lexer.next();
7793
+ let lexer = new RegExp(_Liquid.argumentLexer);
7794
+ while (lexer.lastIndex < str.length) {
7795
+ let index = lexer.lastIndex;
7796
+ let match = lexer.exec(str);
7797
+ if (!match) {
7798
+ throw new Error(`Invalid Liquid shortcode argument syntax at col ${index + 1}: ${str}`);
7799
+ }
7800
+ if (match[1] !== void 0) {
7801
+ argArray.push(match[1]);
8064
7802
  }
8065
7803
  }
8066
7804
  return argArray;
8067
7805
  }
7806
+ // Reads a `key: value` keyword argument, falling back to a positional value
7807
+ static readArgumentBuiltin(tokenizer) {
7808
+ let begin = tokenizer.p;
7809
+ let hash = tokenizer.readHash();
7810
+ if (hash?.value) {
7811
+ return hash;
7812
+ }
7813
+ tokenizer.p = begin;
7814
+ return tokenizer.readValue();
7815
+ }
8068
7816
  static parseArgumentsBuiltin(args) {
8069
7817
  let tokenizer = new Tokenizer(args);
8070
7818
  let parsedArgs = [];
8071
- let value = tokenizer.readValue();
7819
+ let value = _Liquid.readArgumentBuiltin(tokenizer);
8072
7820
  while (value) {
8073
7821
  parsedArgs.push(value);
8074
7822
  tokenizer.skipBlank();
8075
7823
  if (tokenizer.peek() === ",") {
8076
7824
  tokenizer.advance();
8077
7825
  }
8078
- value = tokenizer.readValue();
7826
+ value = _Liquid.readArgumentBuiltin(tokenizer);
8079
7827
  }
8080
7828
  tokenizer.end();
8081
7829
  return parsedArgs;
8082
7830
  }
7831
+ // Keyword arguments are passed as a trailing object marked with a non-enumerable `__keywords` (Nunjucks-compatible)
7832
+ static *evalArgumentsBuiltin(tokens, ctx) {
7833
+ let args = [];
7834
+ let kwargs;
7835
+ for (let token of tokens) {
7836
+ if (token.kind === TokenKind.Hash) {
7837
+ kwargs ??= Object.defineProperty({}, "__keywords", { value: true });
7838
+ kwargs[token.name.content] = yield evalToken(token.value, ctx);
7839
+ } else {
7840
+ args.push(yield evalToken(token, ctx));
7841
+ }
7842
+ }
7843
+ if (kwargs) {
7844
+ args.push(kwargs);
7845
+ }
7846
+ return args;
7847
+ }
8083
7848
  addShortcode(shortcodeName, shortcodeFn) {
8084
7849
  let _t = this;
8085
7850
  this.addTag(shortcodeName, function(liquidEngine) {
@@ -8095,16 +7860,13 @@ var Liquid2 = class _Liquid extends TemplateEngine {
8095
7860
  render: /* @__PURE__ */ __name(function* (ctx) {
8096
7861
  let argArray = [];
8097
7862
  if (this.legacyArgs) {
8098
- let rawArgs = _Liquid.parseArguments(_t.argLexer, this.legacyArgs);
7863
+ let rawArgs = _Liquid.parseArguments(this.legacyArgs);
8099
7864
  for (let arg of rawArgs) {
8100
7865
  let b = yield liquidEngine.evalValue(arg, ctx);
8101
7866
  argArray.push(b);
8102
7867
  }
8103
7868
  } else if (this.orderedArgs) {
8104
- for (let arg of this.orderedArgs) {
8105
- let b = yield evalToken(arg, ctx);
8106
- argArray.push(b);
8107
- }
7869
+ argArray = yield* _Liquid.evalArgumentsBuiltin(this.orderedArgs, ctx);
8108
7870
  }
8109
7871
  let ret = yield shortcodeFn.call(_Liquid.normalizeScope(ctx), ...argArray);
8110
7872
  return ret;
@@ -8132,16 +7894,13 @@ var Liquid2 = class _Liquid extends TemplateEngine {
8132
7894
  render: /* @__PURE__ */ __name(function* (ctx) {
8133
7895
  let argArray = [];
8134
7896
  if (this.legacyArgs) {
8135
- let rawArgs = _Liquid.parseArguments(_t.argLexer, this.legacyArgs);
7897
+ let rawArgs = _Liquid.parseArguments(this.legacyArgs);
8136
7898
  for (let arg of rawArgs) {
8137
7899
  let b = yield liquidEngine.evalValue(arg, ctx);
8138
7900
  argArray.push(b);
8139
7901
  }
8140
7902
  } else if (this.orderedArgs) {
8141
- for (let arg of this.orderedArgs) {
8142
- let b = yield evalToken(arg, ctx);
8143
- argArray.push(b);
8144
- }
7903
+ argArray = yield* _Liquid.evalArgumentsBuiltin(this.orderedArgs, ctx);
8145
7904
  }
8146
7905
  const html = yield liquidEngine.renderer.renderTemplates(this.templates, ctx);
8147
7906
  let ret = yield shortcodeFn.call(_Liquid.normalizeScope(ctx), html, ...argArray);