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

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.12 (@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,32 @@ 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;
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
+ }
1770
1238
  }
1771
- let sourcePlainObjectShortcut;
1772
- if (!target && isPlainObject(source)) {
1773
- target = {};
1774
- sourcePlainObjectShortcut = true;
1239
+ if (sourcePlainObjectShortcut && Object.isFrozen(target) && isPlainObject(target)) {
1240
+ target = Object.assign({}, target);
1775
1241
  }
1776
1242
  if (Array.isArray(target) && Array.isArray(source)) {
1777
1243
  return target.concat(source);
1778
- } else if (isPlainObject(target)) {
1779
- if (sourcePlainObjectShortcut || isPlainObject(source)) {
1244
+ }
1245
+ if (targetPlainObjectShortcut || isPlainObject(target)) {
1246
+ if (sourcePlainObjectShortcut) {
1780
1247
  for (let key in source) {
1781
1248
  let overrideKey = cleanKey(key, override);
1782
- target[overrideKey] = getMergedItem(target[key], source[key], prefixes);
1249
+ if (overrideKey === UNSAFE_KEY) {
1250
+ continue;
1251
+ }
1252
+ let targetValue = Object.hasOwn(target, key) ? target[key] : void 0;
1253
+ target[overrideKey] = getMergedItem(targetValue, source[key], prefixes);
1783
1254
  }
1784
1255
  }
1785
1256
  return target;
@@ -1801,7 +1272,13 @@ var require_Merge = __commonJS({
1801
1272
  if (isPlainObject(target)) {
1802
1273
  for (let key in target) {
1803
1274
  if (key.indexOf(OVERRIDE_PREFIX) === 0) {
1804
- target[key.slice(OVERRIDE_PREFIX.length)] = target[key];
1275
+ if (Object.isFrozen(target)) {
1276
+ target = Object.assign({}, target);
1277
+ }
1278
+ let cleanedKey = key.slice(OVERRIDE_PREFIX.length);
1279
+ if (cleanedKey !== UNSAFE_KEY) {
1280
+ target[cleanedKey] = target[key];
1281
+ }
1805
1282
  delete target[key];
1806
1283
  }
1807
1284
  }
@@ -1817,8 +1294,8 @@ var require_Merge = __commonJS({
1817
1294
  return target;
1818
1295
  }
1819
1296
  __name(Merge, "Merge");
1297
+ Merge.DeepCopy = DeepCopy;
1820
1298
  module.exports = Merge;
1821
- module.exports.DeepCopy = DeepCopy;
1822
1299
  }
1823
1300
  });
1824
1301
 
@@ -1882,22 +1359,6 @@ var require_Url = __commonJS({
1882
1359
  }
1883
1360
  });
1884
1361
 
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
1362
  // ../../node_modules/@11ty/eleventy-utils/src/lib-sha256.js
1902
1363
  var require_lib_sha256 = __commonJS({
1903
1364
  "../../node_modules/@11ty/eleventy-utils/src/lib-sha256.js"(exports, module) {
@@ -2023,7 +1484,10 @@ var require_lib_sha256 = __commonJS({
2023
1484
  buf[bp++] = L >>> 8 & 255;
2024
1485
  buf[bp++] = L & 255;
2025
1486
  process2();
2026
- let reply = new Uint8Array(32);
1487
+ let reply = (
1488
+ /** @type {Uint8Array & { hex?: () => string }} */
1489
+ new Uint8Array(32)
1490
+ );
2027
1491
  reply[0] = h0 >>> 24;
2028
1492
  reply[1] = h0 >>> 16 & 255;
2029
1493
  reply[2] = h0 >>> 8 & 255;
@@ -2074,7 +1538,6 @@ var require_lib_sha256 = __commonJS({
2074
1538
  var require_HashTypes = __commonJS({
2075
1539
  "../../node_modules/@11ty/eleventy-utils/src/HashTypes.js"(exports, module) {
2076
1540
  var { base64UrlSafe } = require_Url();
2077
- var { isBuffer } = require_Buffer();
2078
1541
  var sha2562 = require_lib_sha256();
2079
1542
  function hasNodeCryptoModule() {
2080
1543
  try {
@@ -2138,7 +1601,7 @@ var require_HashTypes = __commonJS({
2138
1601
  static async toHash(...content) {
2139
1602
  let encoder = new TextEncoder();
2140
1603
  let input = this.mergeUint8Array(...content.map((c) => {
2141
- if (isBuffer(c)) {
1604
+ if (c instanceof Uint8Array) {
2142
1605
  return c;
2143
1606
  }
2144
1607
  return encoder.encode(c);
@@ -2190,7 +1653,10 @@ var require_HashTypes = __commonJS({
2190
1653
  __name(this, "ScriptHash");
2191
1654
  }
2192
1655
  static toHash(...content) {
2193
- let hash = sha2562();
1656
+ let hash = (
1657
+ /** @type {{ add: (data: any) => void, digest: () => Uint8Array }} */
1658
+ sha2562()
1659
+ );
2194
1660
  for (let c of content) {
2195
1661
  hash.add(c);
2196
1662
  }
@@ -2241,6 +1707,22 @@ var require_CreateHash = __commonJS({
2241
1707
  }
2242
1708
  });
2243
1709
 
1710
+ // ../../node_modules/@11ty/eleventy-utils/src/Buffer.js
1711
+ var require_Buffer = __commonJS({
1712
+ "../../node_modules/@11ty/eleventy-utils/src/Buffer.js"(exports, module) {
1713
+ function isBuffer(inst) {
1714
+ if (typeof Buffer !== "undefined") {
1715
+ return Buffer.isBuffer(inst);
1716
+ }
1717
+ return inst instanceof Uint8Array;
1718
+ }
1719
+ __name(isBuffer, "isBuffer");
1720
+ module.exports = {
1721
+ isBuffer
1722
+ };
1723
+ }
1724
+ });
1725
+
2244
1726
  // ../../node_modules/@11ty/eleventy-utils/index.js
2245
1727
  var require_eleventy_utils = __commonJS({
2246
1728
  "../../node_modules/@11ty/eleventy-utils/index.js"(exports, module) {
@@ -2266,9 +1748,6 @@ var require_eleventy_utils = __commonJS({
2266
1748
  }
2267
1749
  });
2268
1750
 
2269
- // ../../src/Engines/Liquid.js
2270
- var import_moo = __toESM(require_moo(), 1);
2271
-
2272
1751
  // ../../node_modules/liquidjs/dist/liquid.browser.mjs
2273
1752
  var Token = class {
2274
1753
  static {
@@ -2337,6 +1816,28 @@ function stringify(value) {
2337
1816
  return String(value);
2338
1817
  }
2339
1818
  __name(stringify, "stringify");
1819
+ function advanceCodePoints(str, from, count) {
1820
+ let index = from;
1821
+ for (let i = 0; i < count && index < str.length; i++)
1822
+ index += str.codePointAt(index) > 65535 ? 2 : 1;
1823
+ return index;
1824
+ }
1825
+ __name(advanceCodePoints, "advanceCodePoints");
1826
+ function codePointLength(str) {
1827
+ let length = 0;
1828
+ for (let index = 0; index < str.length; index = advanceCodePoints(str, index, 1))
1829
+ length++;
1830
+ return length;
1831
+ }
1832
+ __name(codePointLength, "codePointLength");
1833
+ function readArrayElement(arr, index, ownPropertyOnly) {
1834
+ if (index < 0)
1835
+ index = arr.length + index;
1836
+ if (ownPropertyOnly && !hasOwnProperty.call(arr, index))
1837
+ return void 0;
1838
+ return arr[index];
1839
+ }
1840
+ __name(readArrayElement, "readArrayElement");
2340
1841
  function toEnumerable(val) {
2341
1842
  val = toValue(val);
2342
1843
  if (isArray(val))
@@ -2668,8 +2169,8 @@ var NullDrop = class extends Drop {
2668
2169
  static {
2669
2170
  __name(this, "NullDrop");
2670
2171
  }
2671
- equals(value) {
2672
- return isNil(toValue(value));
2172
+ *equals(value) {
2173
+ return isNil(yield toValue(value));
2673
2174
  }
2674
2175
  gt() {
2675
2176
  return false;
@@ -2691,10 +2192,10 @@ var EmptyDrop = class _EmptyDrop extends Drop {
2691
2192
  static {
2692
2193
  __name(this, "EmptyDrop");
2693
2194
  }
2694
- equals(value) {
2195
+ *equals(value) {
2695
2196
  if (value instanceof _EmptyDrop)
2696
2197
  return false;
2697
- value = toValue(value);
2198
+ value = yield toValue(value);
2698
2199
  if (isString(value) || isArray(value))
2699
2200
  return value.length === 0;
2700
2201
  if (isObject(value))
@@ -2724,14 +2225,14 @@ var BlankDrop = class _BlankDrop extends EmptyDrop {
2724
2225
  static {
2725
2226
  __name(this, "BlankDrop");
2726
2227
  }
2727
- equals(value) {
2228
+ *equals(value) {
2728
2229
  if (value === false)
2729
2230
  return true;
2730
- if (isNil(toValue(value)))
2231
+ if (isNil(yield toValue(value)))
2731
2232
  return true;
2732
2233
  if (isString(value))
2733
2234
  return /^\s*$/.test(value);
2734
- return super.equals(value);
2235
+ return yield super.equals(value);
2735
2236
  }
2736
2237
  static is(value) {
2737
2238
  return value instanceof _BlankDrop;
@@ -2976,10 +2477,8 @@ function getDayOfYear(d) {
2976
2477
  }
2977
2478
  __name(getDayOfYear, "getDayOfYear");
2978
2479
  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);
2480
+ const daysSinceStartDay = (d.getDay() - startDay + 7) % 7;
2481
+ return String(Math.floor((getDayOfYear(d) - 1 - daysSinceStartDay + 7) / 7));
2983
2482
  }
2984
2483
  __name(getWeekOfYear, "getWeekOfYear");
2985
2484
  function isLeapYear(d) {
@@ -3004,10 +2503,11 @@ function ordinal(d) {
3004
2503
  }
3005
2504
  __name(ordinal, "ordinal");
3006
2505
  function century(d) {
3007
- return parseInt(d.getFullYear().toString().substring(0, 2), 10);
2506
+ return Math.floor(d.getFullYear() / 100);
3008
2507
  }
3009
2508
  __name(century, "century");
3010
2509
  var padWidths = {
2510
+ C: 2,
3011
2511
  d: 2,
3012
2512
  e: 2,
3013
2513
  H: 2,
@@ -3020,7 +2520,9 @@ var padWidths = {
3020
2520
  M: 2,
3021
2521
  S: 2,
3022
2522
  U: 2,
3023
- W: 2
2523
+ W: 2,
2524
+ y: 2,
2525
+ Y: 4
3024
2526
  };
3025
2527
  var padSpaceChars = new Set("aAbBceklpP");
3026
2528
  function getTimezoneOffset(d, opts) {
@@ -3050,14 +2552,14 @@ var formatCodes = {
3050
2552
  N: /* @__PURE__ */ __name((d, opts) => {
3051
2553
  var _a;
3052
2554
  const width = Number(opts.width) || 9;
3053
- const str = String(d.getMilliseconds()).slice(0, width);
2555
+ const str = padStart(String(d.getMilliseconds()), 3, "0").slice(0, width);
3054
2556
  (_a = opts.memoryLimit) === null || _a === void 0 ? void 0 : _a.use(width - str.length);
3055
2557
  return padEnd(str, width, "0");
3056
2558
  }, "N"),
3057
2559
  p: /* @__PURE__ */ __name((d) => d.getHours() < 12 ? "AM" : "PM", "p"),
3058
2560
  P: /* @__PURE__ */ __name((d) => d.getHours() < 12 ? "am" : "pm", "P"),
3059
2561
  q: /* @__PURE__ */ __name((d) => ordinal(d), "q"),
3060
- s: /* @__PURE__ */ __name((d) => Math.round(d.getTime() / 1e3), "s"),
2562
+ s: /* @__PURE__ */ __name((d) => Math.floor(d.dateValue() / 1e3), "s"),
3061
2563
  S: /* @__PURE__ */ __name((d) => d.getSeconds(), "S"),
3062
2564
  u: /* @__PURE__ */ __name((d) => d.getDay() || 7, "u"),
3063
2565
  U: /* @__PURE__ */ __name((d) => getWeekOfYear(d, 0), "U"),
@@ -3065,7 +2567,7 @@ var formatCodes = {
3065
2567
  W: /* @__PURE__ */ __name((d) => getWeekOfYear(d, 1), "W"),
3066
2568
  x: /* @__PURE__ */ __name((d) => d.toLocaleDateString(), "x"),
3067
2569
  X: /* @__PURE__ */ __name((d) => d.toLocaleTimeString(), "X"),
3068
- y: /* @__PURE__ */ __name((d) => d.getFullYear().toString().slice(2, 4), "y"),
2570
+ y: /* @__PURE__ */ __name((d) => (d.getFullYear() % 100 + 100) % 100, "y"),
3069
2571
  Y: /* @__PURE__ */ __name((d) => d.getFullYear(), "Y"),
3070
2572
  z: getTimezoneOffset,
3071
2573
  Z: /* @__PURE__ */ __name((d, opts) => d.getTimeZoneName() || getTimezoneOffset(d, opts), "Z"),
@@ -3108,6 +2610,8 @@ function format(d, match, memoryLimit) {
3108
2610
  if (flags["-"])
3109
2611
  padWidth = 0;
3110
2612
  memoryLimit === null || memoryLimit === void 0 ? void 0 : memoryLimit.use(Number(padWidth) - ret.length);
2613
+ if (padChar === "0" && ret[0] === "-")
2614
+ return "-" + padStart(ret.slice(1), padWidth - 1, padChar);
3111
2615
  return padStart(ret, padWidth, padChar);
3112
2616
  }
3113
2617
  __name(format, "format");
@@ -3163,6 +2667,15 @@ var LiquidDate = class _LiquidDate {
3163
2667
  getTime() {
3164
2668
  return this.displayDate.getTime();
3165
2669
  }
2670
+ /**
2671
+ * The underlying UTC timestamp in milliseconds, unaffected by the display
2672
+ * timezone. Use this (not `getTime()`) for timezone-invariant values like
2673
+ * `%s`: `getTime()` reads `displayDate`, which is deliberately shifted by
2674
+ * the display timezone offset so wall-clock getters can delegate to Date.
2675
+ */
2676
+ dateValue() {
2677
+ return this.date.getTime();
2678
+ }
3166
2679
  getMilliseconds() {
3167
2680
  return this.displayDate.getMilliseconds();
3168
2681
  }
@@ -3317,7 +2830,7 @@ var TagToken = class extends DelimitedToken {
3317
2830
  const { trimTagLeft, trimTagRight, tagDelimiterLeft, tagDelimiterRight } = options;
3318
2831
  const [valueBegin, valueEnd] = [begin + tagDelimiterLeft.length, end - tagDelimiterRight.length];
3319
2832
  super(TokenKind.Tag, [valueBegin, valueEnd], input, begin, end, trimTagLeft, trimTagRight, file);
3320
- this.tokenizer = new Tokenizer(input, options.operators, file, this.contentRange);
2833
+ this.tokenizer = new Tokenizer(input, options.operators, file, this.contentRange, options.groupedExpressions);
3321
2834
  this.name = this.tokenizer.readTagName();
3322
2835
  this.tokenizer.assert(this.name, `illegal tag syntax, tag name expected`);
3323
2836
  this.tokenizer.skipBlank();
@@ -3550,7 +3063,7 @@ var LiquidTagToken = class extends DelimitedToken {
3550
3063
  }
3551
3064
  constructor(input, begin, end, options, file) {
3552
3065
  super(TokenKind.Tag, [begin, end], input, begin, end, false, false, file);
3553
- this.tokenizer = new Tokenizer(input, options.operators, file, this.contentRange);
3066
+ this.tokenizer = new Tokenizer(input, options.operators, file, this.contentRange, options.groupedExpressions);
3554
3067
  this.name = this.tokenizer.readTagName();
3555
3068
  this.tokenizer.assert(this.name, "illegal liquid tag syntax");
3556
3069
  this.tokenizer.skipBlank();
@@ -3616,6 +3129,33 @@ var Render = class {
3616
3129
  return emitter.buffer;
3617
3130
  }
3618
3131
  };
3132
+ function isKeyValuePair(arr) {
3133
+ return isArray(arr);
3134
+ }
3135
+ __name(isKeyValuePair, "isKeyValuePair");
3136
+ var Filter = class {
3137
+ static {
3138
+ __name(this, "Filter");
3139
+ }
3140
+ constructor(token, options, liquid) {
3141
+ this.token = token;
3142
+ this.name = token.name;
3143
+ this.handler = isFunction(options) ? options : isFunction(options === null || options === void 0 ? void 0 : options.handler) ? options.handler : identify;
3144
+ this.raw = !isFunction(options) && !!(options === null || options === void 0 ? void 0 : options.raw);
3145
+ this.args = token.args;
3146
+ this.liquid = liquid;
3147
+ }
3148
+ *render(value, context) {
3149
+ const argv = [];
3150
+ for (const arg of this.args) {
3151
+ if (isKeyValuePair(arg))
3152
+ argv.push([arg[0], yield evalToken(arg[1], context)]);
3153
+ else
3154
+ argv.push(yield evalToken(arg, context));
3155
+ }
3156
+ return yield this.handler.apply({ context, token: this.token, liquid: this.liquid }, [value, ...argv]);
3157
+ }
3158
+ };
3619
3159
  var Expression = class {
3620
3160
  static {
3621
3161
  __name(this, "Expression");
@@ -3656,12 +3196,31 @@ function* evalToken(token, ctx, lenient = false) {
3656
3196
  return yield evalPropertyAccessToken(token, ctx, lenient);
3657
3197
  if (isRangeToken(token))
3658
3198
  return yield evalRangeToken(token, ctx);
3199
+ if (isFilteredValueToken(token))
3200
+ return yield evalFilteredValueToken(token, ctx, lenient);
3659
3201
  }
3660
3202
  __name(evalToken, "evalToken");
3203
+ function* evalFilteredValueToken(token, ctx, lenient) {
3204
+ assert(ctx.liquid, "FilteredValueToken evaluation requires liquid instance in context");
3205
+ lenient = lenient || ctx.opts.lenientIf && token.filters.length > 0 && token.filters[0].name === "default";
3206
+ let val = yield token.initial.evaluate(ctx, lenient);
3207
+ for (const filterToken of token.filters) {
3208
+ const filterImpl = ctx.liquid.filters[filterToken.name];
3209
+ assert(filterImpl || !ctx.liquid.options.strictFilters, () => `undefined filter: ${filterToken.name}`);
3210
+ const filter2 = new Filter(filterToken, filterImpl, ctx.liquid);
3211
+ val = yield filter2.render(val, ctx);
3212
+ }
3213
+ return val;
3214
+ }
3215
+ __name(evalFilteredValueToken, "evalFilteredValueToken");
3216
+ function* evalTokenValue(token, ctx, lenient = false) {
3217
+ return yield toValue(yield evalToken(token, ctx, lenient));
3218
+ }
3219
+ __name(evalTokenValue, "evalTokenValue");
3661
3220
  function* evalPropertyAccessToken(token, ctx, lenient) {
3662
3221
  const props = [];
3663
3222
  for (const prop of token.props) {
3664
- props.push(yield evalToken(prop, ctx, false));
3223
+ props.push(yield evalTokenValue(prop, ctx, false));
3665
3224
  }
3666
3225
  try {
3667
3226
  if (token.variable) {
@@ -3682,8 +3241,8 @@ function evalQuotedToken(token) {
3682
3241
  }
3683
3242
  __name(evalQuotedToken, "evalQuotedToken");
3684
3243
  function* evalRangeToken(token, ctx) {
3685
- const low = yield evalToken(token.lhs, ctx);
3686
- const high = yield evalToken(token.rhs, ctx);
3244
+ const low = yield evalTokenValue(token.lhs, ctx);
3245
+ const high = yield evalTokenValue(token.rhs, ctx);
3687
3246
  ctx.memoryLimit.use(high - low + 1);
3688
3247
  return range(+low, +high + 1);
3689
3248
  }
@@ -3718,69 +3277,87 @@ function isFalsy(val, ctx) {
3718
3277
  }
3719
3278
  __name(isFalsy, "isFalsy");
3720
3279
  var defaultOperators = {
3721
- "==": equals,
3722
- "!=": /* @__PURE__ */ __name((l, r) => !equals(l, r), "!="),
3723
- ">": /* @__PURE__ */ __name((l, r) => {
3280
+ "==": /* @__PURE__ */ __name(function* (l, r) {
3281
+ return yield equals(l, r);
3282
+ }, "=="),
3283
+ "!=": /* @__PURE__ */ __name(function* (l, r) {
3284
+ return !(yield equals(l, r));
3285
+ }, "!="),
3286
+ ">": /* @__PURE__ */ __name(function* (l, r) {
3724
3287
  if (isComparable(l))
3725
- return l.gt(r);
3288
+ return yield l.gt(r);
3726
3289
  if (isComparable(r))
3727
- return r.lt(l);
3728
- return toValue(l) > toValue(r);
3290
+ return yield r.lt(l);
3291
+ return (yield toValue(l)) > (yield toValue(r));
3729
3292
  }, ">"),
3730
- "<": /* @__PURE__ */ __name((l, r) => {
3293
+ "<": /* @__PURE__ */ __name(function* (l, r) {
3731
3294
  if (isComparable(l))
3732
- return l.lt(r);
3295
+ return yield l.lt(r);
3733
3296
  if (isComparable(r))
3734
- return r.gt(l);
3735
- return toValue(l) < toValue(r);
3297
+ return yield r.gt(l);
3298
+ return (yield toValue(l)) < (yield toValue(r));
3736
3299
  }, "<"),
3737
- ">=": /* @__PURE__ */ __name((l, r) => {
3300
+ ">=": /* @__PURE__ */ __name(function* (l, r) {
3738
3301
  if (isComparable(l))
3739
- return l.geq(r);
3302
+ return yield l.geq(r);
3740
3303
  if (isComparable(r))
3741
- return r.leq(l);
3742
- return toValue(l) >= toValue(r);
3304
+ return yield r.leq(l);
3305
+ return (yield toValue(l)) >= (yield toValue(r));
3743
3306
  }, ">="),
3744
- "<=": /* @__PURE__ */ __name((l, r) => {
3307
+ "<=": /* @__PURE__ */ __name(function* (l, r) {
3745
3308
  if (isComparable(l))
3746
- return l.leq(r);
3309
+ return yield l.leq(r);
3747
3310
  if (isComparable(r))
3748
- return r.geq(l);
3749
- return toValue(l) <= toValue(r);
3311
+ return yield r.geq(l);
3312
+ return (yield toValue(l)) <= (yield toValue(r));
3750
3313
  }, "<="),
3751
- "contains": /* @__PURE__ */ __name((l, r) => {
3752
- l = toValue(l);
3314
+ "contains": /* @__PURE__ */ __name(function* (l, r) {
3315
+ l = yield toValue(l);
3753
3316
  if (isArray(l))
3754
- return l.some((i) => equals(i, r));
3317
+ return yield arrayIncludes(l, r);
3755
3318
  if (isFunction(l === null || l === void 0 ? void 0 : l.indexOf))
3756
- return l.indexOf(toValue(r)) > -1;
3319
+ return l.indexOf(yield toValue(r)) > -1;
3757
3320
  return false;
3758
3321
  }, "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")
3322
+ "not": /* @__PURE__ */ __name(function* (v, ctx) {
3323
+ return isFalsy(yield toValue(v), ctx);
3324
+ }, "not"),
3325
+ "and": /* @__PURE__ */ __name(function* (l, r, ctx) {
3326
+ return isTruthy(yield toValue(l), ctx) && isTruthy(yield toValue(r), ctx);
3327
+ }, "and"),
3328
+ "or": /* @__PURE__ */ __name(function* (l, r, ctx) {
3329
+ return isTruthy(yield toValue(l), ctx) || isTruthy(yield toValue(r), ctx);
3330
+ }, "or")
3762
3331
  };
3763
- function equals(lhs, rhs) {
3332
+ function* equals(lhs, rhs) {
3764
3333
  if (isComparable(lhs))
3765
- return lhs.equals(rhs);
3334
+ return yield lhs.equals(rhs);
3766
3335
  if (isComparable(rhs))
3767
- return rhs.equals(lhs);
3768
- lhs = toValue(lhs);
3769
- rhs = toValue(rhs);
3336
+ return yield rhs.equals(lhs);
3337
+ lhs = yield toValue(lhs);
3338
+ rhs = yield toValue(rhs);
3770
3339
  if (isArray(lhs)) {
3771
- return isArray(rhs) && arrayEquals(lhs, rhs);
3340
+ return isArray(rhs) && (yield arrayEquals(lhs, rhs));
3772
3341
  }
3773
3342
  return lhs === rhs;
3774
3343
  }
3775
3344
  __name(equals, "equals");
3776
- function arrayEquals(lhs, rhs) {
3345
+ function* arrayEquals(lhs, rhs) {
3777
3346
  if (lhs.length !== rhs.length)
3778
3347
  return false;
3779
- return !lhs.some((value, i) => !equals(value, rhs[i]));
3348
+ for (let i = 0; i < lhs.length; i++) {
3349
+ if (!(yield equals(lhs[i], rhs[i])))
3350
+ return false;
3351
+ }
3352
+ return true;
3780
3353
  }
3781
3354
  __name(arrayEquals, "arrayEquals");
3782
- function arrayIncludes(arr, item) {
3783
- return arr.some((value) => equals(value, item));
3355
+ function* arrayIncludes(arr, item) {
3356
+ for (const value of arr) {
3357
+ if (yield equals(value, item))
3358
+ return true;
3359
+ }
3360
+ return false;
3784
3361
  }
3785
3362
  __name(arrayIncludes, "arrayIncludes");
3786
3363
  var Node = class {
@@ -3924,6 +3501,18 @@ var fs = /* @__PURE__ */ Object.freeze({
3924
3501
  dirname,
3925
3502
  sep
3926
3503
  });
3504
+ function chargeJsonReplacerValue(memoryLimit, val) {
3505
+ if (typeof val === "string") {
3506
+ memoryLimit.use(val.length);
3507
+ } else if (val === null || typeof val === "number" || typeof val === "boolean") {
3508
+ memoryLimit.use(JSON.stringify(val).length);
3509
+ } else if (Array.isArray(val)) {
3510
+ memoryLimit.use(val.length + 1);
3511
+ } else if (typeof val === "object") {
3512
+ memoryLimit.use(2);
3513
+ }
3514
+ }
3515
+ __name(chargeJsonReplacerValue, "chargeJsonReplacerValue");
3927
3516
  function defaultFilter(value, defaultValue, ...args) {
3928
3517
  value = toValue(value);
3929
3518
  if (isArray(value) || isString(value))
@@ -3934,19 +3523,29 @@ function defaultFilter(value, defaultValue, ...args) {
3934
3523
  }
3935
3524
  __name(defaultFilter, "defaultFilter");
3936
3525
  function json(value, space = 0) {
3937
- return JSON.stringify(value, null, space);
3526
+ const memoryLimit = this.context.memoryLimit;
3527
+ return JSON.stringify(value, (_key, val) => {
3528
+ chargeJsonReplacerValue(memoryLimit, val);
3529
+ return val;
3530
+ }, space);
3938
3531
  }
3939
3532
  __name(json, "json");
3940
3533
  function inspect(value, space = 0) {
3534
+ const memoryLimit = this.context.memoryLimit;
3941
3535
  const ancestors = [];
3942
3536
  return JSON.stringify(value, function(_key, value2) {
3943
- if (typeof value2 !== "object" || value2 === null)
3537
+ if (typeof value2 !== "object" || value2 === null) {
3538
+ chargeJsonReplacerValue(memoryLimit, value2);
3944
3539
  return value2;
3540
+ }
3945
3541
  while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this)
3946
3542
  ancestors.pop();
3947
- if (ancestors.includes(value2))
3543
+ if (ancestors.includes(value2)) {
3544
+ memoryLimit.use("[Circular]".length);
3948
3545
  return "[Circular]";
3546
+ }
3949
3547
  ancestors.push(value2);
3548
+ chargeJsonReplacerValue(memoryLimit, value2);
3950
3549
  return value2;
3951
3550
  }, space);
3952
3551
  }
@@ -4122,6 +3721,7 @@ var defaultOptions = {
4122
3721
  globals: {},
4123
3722
  keepOutputType: false,
4124
3723
  operators: defaultOperators,
3724
+ groupedExpressions: false,
4125
3725
  memoryLimit: Infinity,
4126
3726
  parseLimit: Infinity,
4127
3727
  renderLimit: Infinity
@@ -4225,7 +3825,7 @@ var Tokenizer = class {
4225
3825
  static {
4226
3826
  __name(this, "Tokenizer");
4227
3827
  }
4228
- constructor(input, operators = defaultOptions.operators, file, range2) {
3828
+ constructor(input, operators = defaultOptions.operators, file, range2, groupedExpressions = false) {
4229
3829
  this.input = input;
4230
3830
  this.file = file;
4231
3831
  this.rawBeginAt = -1;
@@ -4233,6 +3833,7 @@ var Tokenizer = class {
4233
3833
  this.N = range2 ? range2[1] : input.length;
4234
3834
  this.opTrie = createTrie(operators);
4235
3835
  this.literalTrie = createTrie(literalValues);
3836
+ this.groupedExpressions = groupedExpressions;
4236
3837
  }
4237
3838
  readExpression() {
4238
3839
  return new Expression(this.readExpressionTokens());
@@ -4294,6 +3895,8 @@ var Tokenizer = class {
4294
3895
  this.skipBlank();
4295
3896
  if (this.end())
4296
3897
  return null;
3898
+ if (this.peek() === ")" || this.peek() === ",")
3899
+ return null;
4297
3900
  this.assert(this.read() === "|", `expected "|" before filter`);
4298
3901
  const name = this.readIdentifier();
4299
3902
  if (!name.size()) {
@@ -4308,9 +3911,9 @@ var Tokenizer = class {
4308
3911
  const arg = this.readFilterArg();
4309
3912
  arg && args.push(arg);
4310
3913
  this.skipBlank();
4311
- this.assert(this.end() || this.peek() === "," || this.peek() === "|", () => `unexpected character ${this.snapshot()}`);
3914
+ this.assert(this.end() || this.peek() === "," || this.peek() === "|" || this.peek() === ")", () => `unexpected character ${this.snapshot()}`);
4312
3915
  } while (this.peek() === ",");
4313
- } else if (this.peek() === "|" || this.end()) ;
3916
+ } else if (this.peek() === "|" || this.peek() === ")" || this.peek() === "," || this.end()) ;
4314
3917
  else {
4315
3918
  throw this.error('expected ":" after filter name');
4316
3919
  }
@@ -4514,7 +4117,10 @@ var Tokenizer = class {
4514
4117
  readValue() {
4515
4118
  this.skipBlank();
4516
4119
  const begin = this.p;
4517
- const variable = this.readLiteral() || this.readQuoted() || this.readRange() || this.readNumber();
4120
+ let variable = this.readLiteral() || this.readQuoted() || this.readNumber();
4121
+ if (!variable && this.peek() === "(") {
4122
+ variable = this.readGroupOrRange();
4123
+ }
4518
4124
  const props = this.readProperties(!variable);
4519
4125
  if (!props.length)
4520
4126
  return variable;
@@ -4591,7 +4197,7 @@ var Tokenizer = class {
4591
4197
  this.p = end;
4592
4198
  return literal;
4593
4199
  }
4594
- readRange() {
4200
+ readGroupOrRange() {
4595
4201
  this.skipBlank();
4596
4202
  const begin = this.p;
4597
4203
  if (this.peek() !== "(")
@@ -4599,11 +4205,22 @@ var Tokenizer = class {
4599
4205
  ++this.p;
4600
4206
  const lhs = this.readValueOrThrow();
4601
4207
  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);
4208
+ if (this.peek() === "." && this.peek(1) === ".") {
4209
+ this.p += 2;
4210
+ const rhs = this.readValueOrThrow();
4211
+ this.skipBlank();
4212
+ this.assert(this.read() === ")", "invalid range syntax");
4213
+ return new RangeToken(this.input, begin, this.p, lhs, rhs, this.file);
4214
+ }
4215
+ if (this.groupedExpressions) {
4216
+ const initial = new Expression([lhs, ...this.readExpressionTokens()]);
4217
+ this.assert(initial.valid(), () => `invalid value expression: ${this.snapshot()}`);
4218
+ const filters2 = this.readFilters();
4219
+ this.skipBlank();
4220
+ this.assert(this.read() === ")", "unbalanced parentheses");
4221
+ return new FilteredValueToken(initial, filters2, this.input, begin, this.p, this.file);
4222
+ }
4223
+ throw this.error("invalid range syntax");
4607
4224
  }
4608
4225
  readValueOrThrow() {
4609
4226
  const value = this.readValue();
@@ -4753,33 +4370,6 @@ function createTagClass(options) {
4753
4370
  };
4754
4371
  }
4755
4372
  __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
4373
  var Value = class {
4784
4374
  static {
4785
4375
  __name(this, "Value");
@@ -4789,7 +4379,7 @@ var Value = class {
4789
4379
  */
4790
4380
  constructor(input, liquid) {
4791
4381
  this.filters = [];
4792
- const token = typeof input === "string" ? new Tokenizer(input, liquid.options.operators).readFilteredValue() : input;
4382
+ const token = typeof input === "string" ? new Tokenizer(input, liquid.options.operators, void 0, void 0, liquid.options.groupedExpressions).readFilteredValue() : input;
4793
4383
  this.initial = token.initial;
4794
4384
  this.filters = token.filters.map((token2) => new Filter(token2, this.getFilter(liquid, token2.name), liquid));
4795
4385
  }
@@ -4814,7 +4404,7 @@ var Output = class extends TemplateImpl {
4814
4404
  constructor(token, liquid) {
4815
4405
  var _a;
4816
4406
  super(token);
4817
- const tokenizer = new Tokenizer(token.input, liquid.options.operators, token.file, token.contentRange);
4407
+ const tokenizer = new Tokenizer(token.input, liquid.options.operators, token.file, token.contentRange, liquid.options.groupedExpressions);
4818
4408
  this.value = new Value(tokenizer.readFilteredValue(), liquid);
4819
4409
  const filters2 = this.value.filters;
4820
4410
  const outputEscape = liquid.options.outputEscape;
@@ -4824,7 +4414,7 @@ var Output = class extends TemplateImpl {
4824
4414
  }
4825
4415
  }
4826
4416
  *render(ctx, emitter) {
4827
- const val = yield this.value.value(ctx, false);
4417
+ const val = yield toValue(yield this.value.value(ctx, false));
4828
4418
  emitter.write(val);
4829
4419
  }
4830
4420
  *arguments() {
@@ -5089,11 +4679,31 @@ function* extractValueTokenVariables(token) {
5089
4679
  if (isRangeToken(token)) {
5090
4680
  yield* extractValueTokenVariables(token.lhs);
5091
4681
  yield* extractValueTokenVariables(token.rhs);
4682
+ } else if (isFilteredValueToken(token)) {
4683
+ yield* extractGroupedExpressionTokenVariables(token);
5092
4684
  } else if (isPropertyAccessToken(token)) {
5093
4685
  yield extractPropertyAccessVariable(token);
5094
4686
  }
5095
4687
  }
5096
4688
  __name(extractValueTokenVariables, "extractValueTokenVariables");
4689
+ function* extractGroupedExpressionTokenVariables(token) {
4690
+ if (!isFilteredValueToken(token))
4691
+ return;
4692
+ for (const t of token.initial.postfix) {
4693
+ if (isValueToken(t))
4694
+ yield* extractValueTokenVariables(t);
4695
+ }
4696
+ for (const filter2 of token.filters) {
4697
+ for (const arg of filter2.args) {
4698
+ if (isKeyValuePair(arg) && arg[1]) {
4699
+ yield* extractValueTokenVariables(arg[1]);
4700
+ } else if (isValueToken(arg)) {
4701
+ yield* extractValueTokenVariables(arg);
4702
+ }
4703
+ }
4704
+ }
4705
+ }
4706
+ __name(extractGroupedExpressionTokenVariables, "extractGroupedExpressionTokenVariables");
5097
4707
  function extractPropertyAccessVariable(token) {
5098
4708
  const segments = [];
5099
4709
  let file = token.file;
@@ -5240,7 +4850,7 @@ var Parser = class {
5240
4850
  parse(html, filepath) {
5241
4851
  html = String(html);
5242
4852
  this.parseLimit.use(html.length);
5243
- const tokenizer = new Tokenizer(html, this.liquid.options.operators, filepath);
4853
+ const tokenizer = new Tokenizer(html, this.liquid.options.operators, filepath, void 0, this.liquid.options.groupedExpressions);
5244
4854
  const tokens = tokenizer.readTopLevelTokens(this.liquid.options);
5245
4855
  return this.parseTokens(tokens);
5246
4856
  }
@@ -5318,6 +4928,7 @@ var TokenKind;
5318
4928
  TokenKind2[TokenKind2["Quoted"] = 1024] = "Quoted";
5319
4929
  TokenKind2[TokenKind2["Operator"] = 2048] = "Operator";
5320
4930
  TokenKind2[TokenKind2["FilteredValue"] = 4096] = "FilteredValue";
4931
+ TokenKind2[TokenKind2["GroupedExpression"] = 8192] = "GroupedExpression";
5321
4932
  TokenKind2[TokenKind2["Delimited"] = 12] = "Delimited";
5322
4933
  })(TokenKind || (TokenKind = {}));
5323
4934
  function isDelimitedToken(val) {
@@ -5360,8 +4971,12 @@ function isRangeToken(val) {
5360
4971
  return getKind(val) === TokenKind.Range;
5361
4972
  }
5362
4973
  __name(isRangeToken, "isRangeToken");
4974
+ function isFilteredValueToken(val) {
4975
+ return getKind(val) === TokenKind.FilteredValue;
4976
+ }
4977
+ __name(isFilteredValueToken, "isFilteredValueToken");
5363
4978
  function isValueToken(val) {
5364
- return (getKind(val) & 1667) > 0;
4979
+ return (getKind(val) & 5763) > 0;
5365
4980
  }
5366
4981
  __name(isValueToken, "isValueToken");
5367
4982
  function getKind(val) {
@@ -5379,7 +4994,7 @@ var Context = class _Context {
5379
4994
  static {
5380
4995
  __name(this, "Context");
5381
4996
  }
5382
- constructor(env = {}, opts = defaultOptions, renderOptions = {}, { memoryLimit, renderLimit } = {}) {
4997
+ constructor(env = {}, opts = defaultOptions, renderOptions = {}, { memoryLimit, renderLimit, liquid } = {}) {
5383
4998
  var _a, _b, _c, _d, _e;
5384
4999
  this.scopes = [createScope()];
5385
5000
  this.registers = {};
@@ -5393,6 +5008,7 @@ var Context = class _Context {
5393
5008
  this.ownPropertyOnly = (_c = renderOptions.ownPropertyOnly) !== null && _c !== void 0 ? _c : opts.ownPropertyOnly;
5394
5009
  this.memoryLimit = memoryLimit !== null && memoryLimit !== void 0 ? memoryLimit : new Limiter("memory alloc", (_d = renderOptions.memoryLimit) !== null && _d !== void 0 ? _d : opts.memoryLimit);
5395
5010
  this.renderLimit = renderLimit !== null && renderLimit !== void 0 ? renderLimit : new Limiter("template render", getPerformance().now() + ((_e = renderOptions.renderLimit) !== null && _e !== void 0 ? _e : opts.renderLimit));
5011
+ this.liquid = liquid;
5396
5012
  }
5397
5013
  getRegister(key, defaultValue = void 0) {
5398
5014
  return this.registers[key] = this.registers[key] || defaultValue;
@@ -5456,7 +5072,8 @@ var Context = class _Context {
5456
5072
  ownPropertyOnly: this.ownPropertyOnly
5457
5073
  }, {
5458
5074
  renderLimit: this.renderLimit,
5459
- memoryLimit: this.memoryLimit
5075
+ memoryLimit: this.memoryLimit,
5076
+ liquid: this.liquid
5460
5077
  });
5461
5078
  }
5462
5079
  findScope(key) {
@@ -5474,8 +5091,8 @@ var Context = class _Context {
5474
5091
  key = toValue(key);
5475
5092
  if (isNil(obj))
5476
5093
  return obj;
5477
- if (isArray(obj) && key < 0)
5478
- return obj[obj.length + +key];
5094
+ if (isArray(obj) && isNumber(key))
5095
+ return readArrayElement(obj, key, this.ownPropertyOnly);
5479
5096
  const value = readJSProperty(obj, key, this.ownPropertyOnly);
5480
5097
  if (value === void 0 && obj instanceof Drop)
5481
5098
  return obj.liquidMethodMissing(key, this);
@@ -5484,9 +5101,9 @@ var Context = class _Context {
5484
5101
  if (key === "size")
5485
5102
  return readSize(obj);
5486
5103
  else if (key === "first")
5487
- return readFirst(obj);
5104
+ return readFirst(obj, this.ownPropertyOnly);
5488
5105
  else if (key === "last")
5489
- return readLast(obj);
5106
+ return readLast(obj, this.ownPropertyOnly);
5490
5107
  return value;
5491
5108
  }
5492
5109
  };
@@ -5496,16 +5113,16 @@ function readJSProperty(obj, key, ownPropertyOnly) {
5496
5113
  return obj[key];
5497
5114
  }
5498
5115
  __name(readJSProperty, "readJSProperty");
5499
- function readFirst(obj) {
5116
+ function readFirst(obj, ownPropertyOnly) {
5500
5117
  if (isArray(obj))
5501
- return obj[0];
5502
- return obj["first"];
5118
+ return readArrayElement(obj, 0, ownPropertyOnly);
5119
+ return readJSProperty(obj, "first", ownPropertyOnly);
5503
5120
  }
5504
5121
  __name(readFirst, "readFirst");
5505
- function readLast(obj) {
5122
+ function readLast(obj, ownPropertyOnly) {
5506
5123
  if (isArray(obj))
5507
- return obj[obj.length - 1];
5508
- return obj["last"];
5124
+ return readArrayElement(obj, -1, ownPropertyOnly);
5125
+ return readJSProperty(obj, "last", ownPropertyOnly);
5509
5126
  }
5510
5127
  __name(readLast, "readLast");
5511
5128
  function readSize(obj) {
@@ -5530,14 +5147,21 @@ var divided_by = argumentsToNumber((dividend, divisor, integerArithmetic = false
5530
5147
  var floor = argumentsToNumber(Math.floor);
5531
5148
  var minus = argumentsToNumber((v, arg) => v - arg);
5532
5149
  var plus = argumentsToNumber((lhs, rhs) => lhs + rhs);
5533
- var modulo = argumentsToNumber((v, arg) => v % arg);
5150
+ var modulo = argumentsToNumber((v, arg) => (v % arg + arg) % arg);
5534
5151
  var times = argumentsToNumber((v, arg) => v * arg);
5152
+ function shiftDecimal(n, exponent) {
5153
+ const [mantissa, power = "0"] = String(n).split("e");
5154
+ return Number(`${mantissa}e${Number(power) + exponent}`);
5155
+ }
5156
+ __name(shiftDecimal, "shiftDecimal");
5535
5157
  function round(v, arg = 0) {
5536
5158
  v = toNumber(v);
5537
5159
  arg = toNumber(arg);
5538
- const amp = Math.pow(10, arg);
5539
- const scaled = v * amp * (1 + Number.EPSILON);
5540
- return Math.round(scaled) / amp;
5160
+ const scaled = shiftDecimal(Math.abs(v), arg);
5161
+ if (!(scaled <= Number.MAX_SAFE_INTEGER))
5162
+ return v;
5163
+ const rounded = shiftDecimal(Math.round(scaled), -arg);
5164
+ return v < 0 ? -rounded : rounded;
5541
5165
  }
5542
5166
  __name(round, "round");
5543
5167
  var mathFilters = /* @__PURE__ */ Object.freeze({
@@ -5554,7 +5178,7 @@ var mathFilters = /* @__PURE__ */ Object.freeze({
5554
5178
  times,
5555
5179
  round
5556
5180
  });
5557
- var url_decode = /* @__PURE__ */ __name((x) => decodeURIComponent(stringify(x)).replace(/\+/g, " "), "url_decode");
5181
+ var url_decode = /* @__PURE__ */ __name((x) => decodeURIComponent(stringify(x).replace(/\+/g, " ")), "url_decode");
5558
5182
  var url_encode = /* @__PURE__ */ __name((x) => encodeURIComponent(stringify(x)).replace(/%20/g, "+"), "url_encode");
5559
5183
  var cgi_escape = /* @__PURE__ */ __name((x) => encodeURIComponent(stringify(x)).replace(/%20/g, "+").replace(/[!'()*]/g, (c) => "%" + c.charCodeAt(0).toString(16).toUpperCase()), "cgi_escape");
5560
5184
  var uri_escape = /* @__PURE__ */ __name((x) => encodeURI(stringify(x)).replace(/%5B/g, "[").replace(/%5D/g, "]"), "uri_escape");
@@ -5593,12 +5217,18 @@ var urlFilters = /* @__PURE__ */ Object.freeze({
5593
5217
  var join = argumentsToValue(function(v, arg) {
5594
5218
  const array = toArray(v);
5595
5219
  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);
5220
+ let outputSize = sep2.length * Math.max(array.length - 1, 0);
5221
+ for (let i = 0; i < array.length; i++)
5222
+ outputSize += String(array[i]).length;
5223
+ this.context.memoryLimit.use(outputSize);
5224
+ return Array.prototype.join.call(array, sep2);
5225
+ });
5226
+ var last$1 = argumentsToValue(function(v) {
5227
+ return isArrayLike(v) ? readArrayElement(v, -1, this.context.ownPropertyOnly) : "";
5228
+ });
5229
+ var first = argumentsToValue(function(v) {
5230
+ return isArrayLike(v) ? readArrayElement(v, 0, this.context.ownPropertyOnly) : "";
5599
5231
  });
5600
- var last$1 = argumentsToValue((v) => isArrayLike(v) ? last(v) : "");
5601
- var first = argumentsToValue((v) => isArrayLike(v) ? v[0] : "");
5602
5232
  var reverse = argumentsToValue(function(v) {
5603
5233
  const array = toArray(v);
5604
5234
  this.context.memoryLimit.use(array.length);
@@ -5649,14 +5279,14 @@ __name(sum, "sum");
5649
5279
  function compact(arr) {
5650
5280
  const array = toArray(arr);
5651
5281
  this.context.memoryLimit.use(array.length);
5652
- return array.filter((x) => !isNil(toValue(x)));
5282
+ return Array.prototype.filter.call(array, (x) => !isNil(toValue(x)));
5653
5283
  }
5654
5284
  __name(compact, "compact");
5655
5285
  function concat(v, arg = []) {
5656
5286
  const lhs = toArray(v);
5657
5287
  const rhs = toArray(arg);
5658
5288
  this.context.memoryLimit.use(lhs.length + rhs.length);
5659
- return lhs.concat(rhs);
5289
+ return Array.prototype.concat.call(lhs, rhs);
5660
5290
  }
5661
5291
  __name(concat, "concat");
5662
5292
  function push(v, arg) {
@@ -5693,31 +5323,40 @@ function slice(v, begin, length = 1) {
5693
5323
  return [];
5694
5324
  if (!isArray(v))
5695
5325
  v = stringify(v);
5696
- begin = begin < 0 ? v.length + begin : begin;
5326
+ begin = begin < 0 ? (isArray(v) ? v.length : codePointLength(v)) + begin : begin;
5327
+ if (begin < 0 || length < 0)
5328
+ return isArray(v) ? [] : "";
5697
5329
  this.context.memoryLimit.use(length);
5698
- return v.slice(begin, begin + length);
5330
+ if (isArray(v))
5331
+ return Array.prototype.slice.call(v, begin, begin + length);
5332
+ const start = advanceCodePoints(v, 0, begin);
5333
+ return v.slice(start, advanceCodePoints(v, start, length));
5699
5334
  }
5700
5335
  __name(slice, "slice");
5701
- function expectedMatcher(expected) {
5336
+ function* matches(value, expected) {
5702
5337
  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);
5338
+ if (EmptyDrop.is(expected))
5339
+ return yield equals(value, expected);
5340
+ if (isArray(value))
5341
+ return yield arrayIncludes(value, expected);
5342
+ return yield equals(value, expected);
5708
5343
  }
5344
+ if (expected === void 0)
5345
+ return isTruthy(value, this.context);
5346
+ return yield equals(value, expected);
5709
5347
  }
5710
- __name(expectedMatcher, "expectedMatcher");
5348
+ __name(matches, "matches");
5711
5349
  function* filter(include, arr, property, expected) {
5712
- const values = [];
5713
5350
  arr = toArray(arr);
5714
5351
  this.context.memoryLimit.use(arr.length);
5715
5352
  const token = new Tokenizer(stringify(property)).readScopeValue();
5353
+ const result = [];
5716
5354
  for (const item of arr) {
5717
- values.push(yield evalToken(token, this.context.spawn(item)));
5355
+ const value = yield evalToken(token, this.context.spawn(item));
5356
+ if ((yield matches.call(this, value, expected)) === include)
5357
+ result.push(item);
5718
5358
  }
5719
- const matcher = expectedMatcher.call(this, expected);
5720
- return arr.filter((_, i) => matcher(values[i]) === include);
5359
+ return result;
5721
5360
  }
5722
5361
  __name(filter, "filter");
5723
5362
  function* filter_exp(include, arr, itemName, exp) {
@@ -5784,10 +5423,9 @@ __name(group_by_exp, "group_by_exp");
5784
5423
  function* search(arr, property, expected) {
5785
5424
  const token = new Tokenizer(stringify(property)).readScopeValue();
5786
5425
  const array = toArray(arr);
5787
- const matcher = expectedMatcher.call(this, expected);
5788
5426
  for (let index = 0; index < array.length; index++) {
5789
5427
  const value = yield evalToken(token, this.context.spawn(array[index]));
5790
- if (matcher(value))
5428
+ if (yield matches.call(this, value, expected))
5791
5429
  return [index, array[index]];
5792
5430
  }
5793
5431
  }
@@ -5904,7 +5542,10 @@ function date_to_xmlschema(v) {
5904
5542
  }
5905
5543
  __name(date_to_xmlschema, "date_to_xmlschema");
5906
5544
  function date_to_rfc822(v) {
5907
- return date.call(this, v, "%a, %d %b %Y %H:%M:%S %z");
5545
+ const date2 = parseDate(v, this.context.opts, void 0, "en-US");
5546
+ if (!date2)
5547
+ return v;
5548
+ return strftime(date2, "%a, %d %b %Y %H:%M:%S %z", this.context.memoryLimit);
5908
5549
  }
5909
5550
  __name(date_to_rfc822, "date_to_rfc822");
5910
5551
  function date_to_string(v, type, style) {
@@ -5927,10 +5568,9 @@ function stringify_date(v, month_type, type, style) {
5927
5568
  return strftime(date2, `%d ${month_type} %Y`, ml);
5928
5569
  }
5929
5570
  __name(stringify_date, "stringify_date");
5930
- function parseDate(v, opts, timezoneOffset) {
5571
+ function parseDate(v, opts, timezoneOffset, locale = opts.locale) {
5931
5572
  let date2;
5932
5573
  const defaultTimezoneOffset = timezoneOffset !== null && timezoneOffset !== void 0 ? timezoneOffset : opts.timezoneOffset;
5933
- const locale = opts.locale;
5934
5574
  v = toValue(v);
5935
5575
  if (isNil(v)) {
5936
5576
  return void 0;
@@ -5978,17 +5618,34 @@ function prepend(v, arg) {
5978
5618
  return rhs + lhs;
5979
5619
  }
5980
5620
  __name(prepend, "prepend");
5621
+ function getTrimStart(str, chars) {
5622
+ let start = 0;
5623
+ for (const char of str) {
5624
+ if (!chars.has(char))
5625
+ break;
5626
+ start += char.length;
5627
+ }
5628
+ return start;
5629
+ }
5630
+ __name(getTrimStart, "getTrimStart");
5631
+ function getTrimEnd(str, chars, start = 0) {
5632
+ let end = str.length;
5633
+ while (end > start) {
5634
+ const size2 = end - start >= 2 && str.codePointAt(end - 2) > 65535 ? 2 : 1;
5635
+ if (!chars.has(str.slice(end - size2, end)))
5636
+ break;
5637
+ end -= size2;
5638
+ }
5639
+ return end;
5640
+ }
5641
+ __name(getTrimEnd, "getTrimEnd");
5981
5642
  function lstrip(v, chars) {
5982
5643
  const str = stringify(v);
5983
5644
  this.context.memoryLimit.use(str.length);
5984
5645
  if (chars) {
5985
5646
  chars = stringify(chars);
5986
5647
  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 "";
5648
+ return str.slice(getTrimStart(str, new Set(chars)));
5992
5649
  }
5993
5650
  return str.trimStart();
5994
5651
  }
@@ -6035,11 +5692,7 @@ function rstrip(str, chars) {
6035
5692
  if (chars) {
6036
5693
  chars = stringify(chars);
6037
5694
  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 "";
5695
+ return str.slice(0, getTrimEnd(str, new Set(chars)));
6043
5696
  }
6044
5697
  return str.trimEnd();
6045
5698
  }
@@ -6059,13 +5712,8 @@ function strip(v, chars) {
6059
5712
  if (chars) {
6060
5713
  const set = new Set(stringify(chars));
6061
5714
  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);
5715
+ const start = getTrimStart(str, set);
5716
+ return str.slice(start, getTrimEnd(str, set, start));
6069
5717
  }
6070
5718
  return str.trim();
6071
5719
  }
@@ -6076,6 +5724,12 @@ function strip_newlines(v) {
6076
5724
  return str.replace(/\r?\n/gm, "");
6077
5725
  }
6078
5726
  __name(strip_newlines, "strip_newlines");
5727
+ function squish(v) {
5728
+ const str = stringify(v);
5729
+ this.context.memoryLimit.use(str.length);
5730
+ return str.replace(/\s+/g, " ").trim();
5731
+ }
5732
+ __name(squish, "squish");
6079
5733
  function capitalize(str) {
6080
5734
  str = stringify(str);
6081
5735
  this.context.memoryLimit.use(str.length);
@@ -6115,16 +5769,16 @@ function truncate(v, l = 50, o = "...") {
6115
5769
  const str = stringify(v);
6116
5770
  o = stringify(o);
6117
5771
  this.context.memoryLimit.use(str.length + o.length);
6118
- if (str.length <= l)
5772
+ if (str.length <= l || advanceCodePoints(str, 0, l) >= str.length)
6119
5773
  return v;
6120
- return str.substring(0, l - o.length) + o;
5774
+ return str.slice(0, advanceCodePoints(str, 0, Math.max(l - codePointLength(o), 0))) + o;
6121
5775
  }
6122
5776
  __name(truncate, "truncate");
6123
5777
  function truncatewords(v, words = 15, o = "...") {
6124
5778
  const str = stringify(v);
6125
5779
  o = stringify(o);
6126
5780
  this.context.memoryLimit.use(str.length + o.length);
6127
- const arr = str.split(/\s+/);
5781
+ const arr = str.trimStart().split(/\s+/);
6128
5782
  if (words <= 0)
6129
5783
  words = 1;
6130
5784
  let ret = arr.slice(0, words).join(" ");
@@ -6155,9 +5809,13 @@ function number_of_words(input, mode) {
6155
5809
  }
6156
5810
  }
6157
5811
  __name(number_of_words, "number_of_words");
6158
- function array_to_sentence_string(array, connector = "and") {
5812
+ function array_to_sentence_string(input, connector = "and") {
5813
+ const array = toArray(input);
6159
5814
  connector = stringify(connector);
6160
- this.context.memoryLimit.use(array.length + connector.length);
5815
+ let outputSize = connector.length + array.length * 2;
5816
+ for (let i = 0; i < array.length; i++)
5817
+ outputSize += stringify(array[i]).length;
5818
+ this.context.memoryLimit.use(outputSize);
6161
5819
  switch (array.length) {
6162
5820
  case 0:
6163
5821
  return "";
@@ -6184,6 +5842,7 @@ var stringFilters = /* @__PURE__ */ Object.freeze({
6184
5842
  split,
6185
5843
  strip,
6186
5844
  strip_newlines,
5845
+ squish,
6187
5846
  capitalize,
6188
5847
  replace,
6189
5848
  replace_first,
@@ -6195,7 +5854,12 @@ var stringFilters = /* @__PURE__ */ Object.freeze({
6195
5854
  array_to_sentence_string
6196
5855
  });
6197
5856
  function base64Encode(str) {
6198
- return btoa(String.fromCharCode(...new TextEncoder().encode(str)));
5857
+ const bytes = new TextEncoder().encode(str);
5858
+ let binary = "";
5859
+ for (let i = 0; i < bytes.length; i += 32768) {
5860
+ binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
5861
+ }
5862
+ return btoa(binary);
6199
5863
  }
6200
5864
  __name(base64Encode, "base64Encode");
6201
5865
  function base64Decode(str) {
@@ -6215,9 +5879,17 @@ __name(base64_encode, "base64_encode");
6215
5879
  function base64_decode(value) {
6216
5880
  const str = stringify(value);
6217
5881
  this.context.memoryLimit.use(str.length);
5882
+ assert(isBase64(str), "invalid base64 provided to base64_decode");
6218
5883
  return base64Decode(str);
6219
5884
  }
6220
5885
  __name(base64_decode, "base64_decode");
5886
+ function isBase64(str) {
5887
+ str = str.replace(/[\t\n\f\r ]/g, "");
5888
+ if (str.length % 4 === 0)
5889
+ str = str.replace(/==?$/, "");
5890
+ return str.length % 4 !== 1 && /^[A-Za-z0-9+/]*$/.test(str);
5891
+ }
5892
+ __name(isBase64, "isBase64");
6221
5893
  var base64Filters = /* @__PURE__ */ Object.freeze({
6222
5894
  __proto__: null,
6223
5895
  base64_encode,
@@ -6469,12 +6141,12 @@ var CaseTag = class extends Tag {
6469
6141
  }
6470
6142
  *render(ctx, emitter) {
6471
6143
  const r = this.liquid.renderer;
6472
- const target = toValue(yield this.value.value(ctx, ctx.opts.lenientIf));
6144
+ const target = yield toValue(yield this.value.value(ctx, ctx.opts.lenientIf));
6473
6145
  let branchHit = false;
6474
6146
  for (const branch of this.branches) {
6475
6147
  for (const valueToken of branch.values) {
6476
6148
  const value = yield evalToken(valueToken, ctx, ctx.opts.lenientIf);
6477
- if (equals(target, value)) {
6149
+ if (yield equals(target, value)) {
6478
6150
  yield r.renderTemplates(branch.templates, ctx, emitter);
6479
6151
  branchHit = true;
6480
6152
  break;
@@ -6755,6 +6427,7 @@ var CycleTag = class extends Tag {
6755
6427
  constructor(token, remainTokens, liquid) {
6756
6428
  super(token, remainTokens, liquid);
6757
6429
  this.candidates = [];
6430
+ const begin = this.tokenizer.p;
6758
6431
  const group = this.tokenizer.readValue();
6759
6432
  this.tokenizer.skipBlank();
6760
6433
  if (group) {
@@ -6762,28 +6435,33 @@ var CycleTag = class extends Tag {
6762
6435
  this.group = group;
6763
6436
  this.tokenizer.advance();
6764
6437
  } else
6765
- this.candidates.push(group);
6438
+ this.tokenizer.p = begin;
6766
6439
  }
6767
6440
  while (!this.tokenizer.end()) {
6768
- const value = this.tokenizer.readValue();
6769
- if (value)
6770
- this.candidates.push(value);
6441
+ const value = this.tokenizer.readFilteredValue();
6442
+ this.candidates.push(value);
6771
6443
  this.tokenizer.readTo(",");
6772
6444
  }
6773
6445
  this.tokenizer.assert(this.candidates.length, () => `empty candidates: "${token.getText()}"`);
6774
6446
  }
6775
6447
  *render(ctx, emitter) {
6448
+ var _a;
6776
6449
  const group = yield evalToken(this.group, ctx);
6777
- const fingerprint = `cycle:${group}:` + this.candidates.join(",");
6450
+ const fingerprint = `cycle:${group}:` + this.candidates.map((c) => c.getText()).join(",");
6778
6451
  const groups = ctx.getRegister("cycle", {});
6779
6452
  let idx = groups[fingerprint];
6780
6453
  if (idx === void 0) {
6781
6454
  idx = groups[fingerprint] = 0;
6782
6455
  }
6783
- const candidate = this.candidates[idx];
6456
+ const candidate = new Value(this.candidates[idx], this.liquid);
6784
6457
  idx = (idx + 1) % this.candidates.length;
6785
6458
  groups[fingerprint] = idx;
6786
- return yield evalToken(candidate, ctx);
6459
+ let val = yield toValue(yield candidate.value(ctx, false));
6460
+ const outputEscape = this.liquid.options.outputEscape;
6461
+ if (outputEscape && !((_a = candidate.filters[candidate.filters.length - 1]) === null || _a === void 0 ? void 0 : _a.raw)) {
6462
+ val = yield outputEscape.call({ context: ctx, token: this.token, liquid: this.liquid }, val);
6463
+ }
6464
+ return val;
6787
6465
  }
6788
6466
  *arguments() {
6789
6467
  yield* this.candidates;
@@ -6823,7 +6501,7 @@ var IfTag = class extends Tag {
6823
6501
  *render(ctx, emitter) {
6824
6502
  const r = this.liquid.renderer;
6825
6503
  for (const { value, templates } of this.branches) {
6826
- const v = yield value.value(ctx, ctx.opts.lenientIf);
6504
+ const v = yield toValue(yield value.value(ctx, ctx.opts.lenientIf));
6827
6505
  if (isTruthy(v, ctx)) {
6828
6506
  yield r.renderTemplates(templates, ctx, emitter);
6829
6507
  return;
@@ -7116,7 +6794,7 @@ var UnlessTag = class extends Tag {
7116
6794
  *render(ctx, emitter) {
7117
6795
  const r = this.liquid.renderer;
7118
6796
  for (const { value, test, templates } of this.branches) {
7119
- const v = yield value.value(ctx, ctx.opts.lenientIf);
6797
+ const v = yield toValue(yield value.value(ctx, ctx.opts.lenientIf));
7120
6798
  if (test(v, ctx)) {
7121
6799
  yield r.renderTemplates(templates, ctx, emitter);
7122
6800
  return;
@@ -7163,9 +6841,14 @@ var EchoTag = class extends Tag {
7163
6841
  }
7164
6842
  }
7165
6843
  *render(ctx, emitter) {
6844
+ var _a;
7166
6845
  if (!this.value)
7167
6846
  return;
7168
- const val = yield this.value.value(ctx, false);
6847
+ let val = yield toValue(yield this.value.value(ctx, false));
6848
+ const outputEscape = this.liquid.options.outputEscape;
6849
+ if (outputEscape && !((_a = this.value.filters[this.value.filters.length - 1]) === null || _a === void 0 ? void 0 : _a.raw)) {
6850
+ val = yield outputEscape.call({ context: ctx, token: this.token, liquid: this.liquid }, val);
6851
+ }
7169
6852
  emitter.write(val);
7170
6853
  }
7171
6854
  *arguments() {
@@ -7244,7 +6927,7 @@ var Liquid = class _Liquid {
7244
6927
  return parser.parse(html, filepath);
7245
6928
  }
7246
6929
  _render(tpl, scope, renderOptions) {
7247
- const ctx = scope instanceof Context ? scope : new Context(scope, this.options, renderOptions);
6930
+ const ctx = scope instanceof Context ? scope : new Context(scope, this.options, renderOptions, { liquid: this });
7248
6931
  return this.renderer.renderTemplates(tpl, ctx);
7249
6932
  }
7250
6933
  render(tpl, scope, renderOptions) {
@@ -7256,7 +6939,7 @@ var Liquid = class _Liquid {
7256
6939
  return toValueSync(this._render(tpl, scope, Object.assign(Object.assign({}, renderOptions), { sync: true })));
7257
6940
  }
7258
6941
  renderToNodeStream(tpl, scope, renderOptions = {}) {
7259
- const ctx = new Context(scope, this.options, renderOptions);
6942
+ const ctx = new Context(scope, this.options, renderOptions, { liquid: this });
7260
6943
  return this.renderer.renderTemplatesToNodeStream(tpl, ctx);
7261
6944
  }
7262
6945
  _parseAndRender(html, scope, renderOptions) {
@@ -7308,7 +6991,7 @@ var Liquid = class _Liquid {
7308
6991
  }
7309
6992
  _evalValue(str, scope) {
7310
6993
  const value = new Value(str, this);
7311
- const ctx = scope instanceof Context ? scope : new Context(scope, this.options);
6994
+ const ctx = scope instanceof Context ? scope : new Context(scope, this.options, {}, { liquid: this });
7312
6995
  return value.value(ctx);
7313
6996
  }
7314
6997
  evalValue(str, scope) {
@@ -7322,6 +7005,9 @@ var Liquid = class _Liquid {
7322
7005
  registerFilter(name, filter2) {
7323
7006
  this.filters[name] = filter2;
7324
7007
  }
7008
+ unregisterFilter(name) {
7009
+ delete this.filters[name];
7010
+ }
7325
7011
  registerTag(name, tag) {
7326
7012
  this.tags[name] = isFunction(tag) ? tag : createTagClass(tag);
7327
7013
  }
@@ -7455,15 +7141,16 @@ function matchesTemplate(search2, template) {
7455
7141
  let templateIndex = 0;
7456
7142
  let starIndex = -1;
7457
7143
  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) {
7144
+ while (searchIndex < search2.length) if (templateIndex < template.length && (template[templateIndex] === search2[searchIndex] || template[templateIndex] === "*")) {
7145
+ if (template[templateIndex] === "*") {
7146
+ starIndex = templateIndex;
7147
+ matchIndex = searchIndex;
7148
+ templateIndex++;
7149
+ } else {
7150
+ searchIndex++;
7151
+ templateIndex++;
7152
+ }
7153
+ } else if (starIndex !== -1) {
7467
7154
  templateIndex = starIndex + 1;
7468
7155
  matchIndex++;
7469
7156
  searchIndex = matchIndex;
@@ -7483,7 +7170,7 @@ function createDebug(namespace, options) {
7483
7170
  let enableOverride;
7484
7171
  let namespacesCache;
7485
7172
  let enabledCache;
7486
- const debug2 = /* @__PURE__ */ __name((...args) => {
7173
+ const debug2 = /* @__PURE__ */ __name(((...args) => {
7487
7174
  if (!debug2.enabled) return;
7488
7175
  const curr = Date.now();
7489
7176
  const diff = curr - (prevTime || curr);
@@ -7505,7 +7192,7 @@ function createDebug(namespace, options) {
7505
7192
  });
7506
7193
  options.formatArgs.call(debug2, diff, args);
7507
7194
  debug2.log(...args);
7508
- }, "debug");
7195
+ }), "debug");
7509
7196
  debug2.extend = function(namespace2, delimiter = ":") {
7510
7197
  return createDebug(this.namespace + delimiter + namespace2, {
7511
7198
  useColors: this.useColors,
@@ -7555,6 +7242,48 @@ function enabled(name) {
7555
7242
  }
7556
7243
  __name(enabled, "enabled");
7557
7244
 
7245
+ // ../../node_modules/obug/dist/plain.js
7246
+ function formatArgs(diff, args) {
7247
+ args[0] = `${this.namespace} ${args[0]} +${this.humanize(diff)}`;
7248
+ }
7249
+ __name(formatArgs, "formatArgs");
7250
+ var defaultOptions2 = {
7251
+ useColors: false,
7252
+ color: "",
7253
+ formatArgs,
7254
+ formatters: {
7255
+ /**
7256
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
7257
+ */
7258
+ j(v) {
7259
+ try {
7260
+ return JSON.stringify(v);
7261
+ } catch (error) {
7262
+ return `[UnexpectedJSONParseError]: ${error.message}`;
7263
+ }
7264
+ }
7265
+ },
7266
+ inspectOpts: {},
7267
+ humanize,
7268
+ log: console.debug || console.log || (() => {
7269
+ })
7270
+ };
7271
+ function createDebug2(namespace, options) {
7272
+ return createDebug(namespace, Object.assign({}, defaultOptions2, options));
7273
+ }
7274
+ __name(createDebug2, "createDebug");
7275
+ function load() {
7276
+ let r;
7277
+ try {
7278
+ r = localStorage.getItem("debug") || localStorage.getItem("DEBUG");
7279
+ } catch (_unused) {
7280
+ }
7281
+ if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
7282
+ return r || "";
7283
+ }
7284
+ __name(load, "load");
7285
+ enable(load());
7286
+
7558
7287
  // ../../node_modules/obug/dist/browser.js
7559
7288
  var colors = [
7560
7289
  "#0000CC",
@@ -7634,7 +7363,7 @@ var colors = [
7634
7363
  "#FFCC00",
7635
7364
  "#FFCC33"
7636
7365
  ];
7637
- function formatArgs(diff, args) {
7366
+ function formatArgs2(diff, args) {
7638
7367
  const { useColors } = this;
7639
7368
  args[0] = `${(useColors ? "%c" : "") + this.namespace + (useColors ? " %c" : " ") + args[0] + (useColors ? "%c " : " ")}+${this.humanize(diff)}`;
7640
7369
  if (!useColors) return;
@@ -7649,53 +7378,17 @@ function formatArgs(diff, args) {
7649
7378
  });
7650
7379
  args.splice(lastC, 0, c);
7651
7380
  }
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) {
7381
+ __name(formatArgs2, "formatArgs");
7382
+ function createDebug3(namespace, options) {
7676
7383
  var _ref;
7677
7384
  const color = (_ref = options && options.color) !== null && _ref !== void 0 ? _ref : selectColor(colors, namespace);
7678
- return createDebug(namespace, Object.assign(defaultOptions2, { color }, options));
7385
+ return createDebug2(namespace, Object.assign({
7386
+ useColors: true,
7387
+ color,
7388
+ formatArgs: formatArgs2
7389
+ }, options));
7679
7390
  }
7680
- __name(createDebug2, "createDebug");
7681
- function localstorage() {
7682
- try {
7683
- return localStorage;
7684
- } catch (_unused) {
7685
- }
7686
- }
7687
- __name(localstorage, "localstorage");
7688
- function load() {
7689
- let r;
7690
- try {
7691
- r = storage.getItem("debug") || storage.getItem("DEBUG");
7692
- } catch (_unused2) {
7693
- }
7694
- if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
7695
- return r || "";
7696
- }
7697
- __name(load, "load");
7698
- enable(load());
7391
+ __name(createDebug3, "createDebug");
7699
7392
 
7700
7393
  // ../../src/Util/IsBuildAwesome.js
7701
7394
  function isUsingBuildAwesome() {
@@ -7705,10 +7398,10 @@ __name(isUsingBuildAwesome, "isUsingBuildAwesome");
7705
7398
 
7706
7399
  // ../../src/Util/DebugLogUtil.js
7707
7400
  var PREFIX = isUsingBuildAwesome() ? "BuildAwesome:" : "Eleventy:";
7708
- function createDebug3(name) {
7709
- return createDebug2(`${PREFIX}:${name}`);
7401
+ function createDebug4(name) {
7402
+ return createDebug3(`${PREFIX}${name}`);
7710
7403
  }
7711
- __name(createDebug3, "createDebug");
7404
+ __name(createDebug4, "createDebug");
7712
7405
 
7713
7406
  // ../../src/Errors/BaseError.js
7714
7407
  var BaseError = class extends Error {
@@ -7733,6 +7426,14 @@ var BaseError = class extends Error {
7733
7426
  this.originalError = originalError;
7734
7427
  }
7735
7428
  }
7429
+ /**
7430
+ * @param {string} filePath - The file that caused the error.
7431
+ * @returns {this}
7432
+ */
7433
+ setFilePath(filePath) {
7434
+ this.filePath = filePath;
7435
+ return this;
7436
+ }
7736
7437
  };
7737
7438
 
7738
7439
  // ../../src/Engines/TemplateEngine.js
@@ -7741,7 +7442,7 @@ var TemplateEngineConfigError = class extends BaseError {
7741
7442
  __name(this, "TemplateEngineConfigError");
7742
7443
  }
7743
7444
  };
7744
- var debug = createDebug3("TemplateEngine");
7445
+ var debug = createDebug4("TemplateEngine");
7745
7446
  var AMENDED_INSTANCES = /* @__PURE__ */ new Set();
7746
7447
  var TemplateEngine = class {
7747
7448
  static {
@@ -7750,6 +7451,7 @@ var TemplateEngine = class {
7750
7451
  #extensionMap;
7751
7452
  #engineManager;
7752
7453
  #benchmarks;
7454
+ #configEventListeners = [];
7753
7455
  constructor(name, eleventyConfig) {
7754
7456
  this.name = name;
7755
7457
  this.engineLib = null;
@@ -7761,6 +7463,18 @@ var TemplateEngine = class {
7761
7463
  get cacheable() {
7762
7464
  return false;
7763
7465
  }
7466
+ // Engine instances are replaced on each build, so their listeners must not outlive them
7467
+ addConfigEventListener(eventName, fn) {
7468
+ let events = this.config.events;
7469
+ this.#configEventListeners.push([events, eventName, fn]);
7470
+ events.on(eventName, fn);
7471
+ }
7472
+ removeConfigEventListeners() {
7473
+ for (let [events, eventName, fn] of this.#configEventListeners) {
7474
+ events.off(eventName, fn);
7475
+ }
7476
+ this.#configEventListeners = [];
7477
+ }
7764
7478
  get dirs() {
7765
7479
  return this.eleventyConfig.directories;
7766
7480
  }
@@ -7876,6 +7590,9 @@ var TemplateEngine = class {
7876
7590
  needsCompilation(str) {
7877
7591
  return true;
7878
7592
  }
7593
+ // Runs at compile time for pipeline steps that compile later, during render
7594
+ async ready() {
7595
+ }
7879
7596
  /**
7880
7597
  * Make sure compile is implemented downstream.
7881
7598
  * @abstract
@@ -7894,13 +7611,23 @@ var TemplateEngine = class {
7894
7611
  }
7895
7612
  return true;
7896
7613
  }
7614
+ // e.g. a template’s include, import, extends, or layout file, recorded when it is used
7615
+ // `from` is the engine name for string templates (e.g. the Render plugin’s `renderTemplate`)
7616
+ addDependency(from, to) {
7617
+ if (!from || !to) {
7618
+ return;
7619
+ }
7620
+ this.config.uses.addDependency(from, [to]);
7621
+ }
7897
7622
  isFileRelevantTo(inputPath, comparisonFile) {
7898
7623
  return this.config.uses.isFileRelevantTo(inputPath, comparisonFile);
7899
7624
  }
7900
7625
  };
7901
7626
 
7902
7627
  // ../../src/Engines/Util/ContextAugmenter.js
7903
- var DATA_KEYS = ["page", "eleventy"];
7628
+ var DATA_KEYS = ["page", "eleventy", "buildawesome", "collections"];
7629
+ var DATA_METHOD = "getData";
7630
+ var augmented = /* @__PURE__ */ new WeakMap();
7904
7631
  function augmentObject(targetObject, options = {}) {
7905
7632
  options = Object.assign(
7906
7633
  {
@@ -7910,11 +7637,15 @@ function augmentObject(targetObject, options = {}) {
7910
7637
  lazy: false
7911
7638
  // lazily fetch the property
7912
7639
  // getter: function() {},
7640
+ // dataGetter: function(source) {}, // defaults to `source`
7913
7641
  },
7914
7642
  options
7915
7643
  );
7644
+ if (targetObject === options.source) {
7645
+ return targetObject;
7646
+ }
7916
7647
  for (let key of DATA_KEYS) {
7917
- if (!options.overwrite && targetObject[key]) {
7648
+ if (!options.overwrite && isUserDefined(targetObject, key)) {
7918
7649
  continue;
7919
7650
  }
7920
7651
  if (options.lazy) {
@@ -7924,12 +7655,7 @@ function augmentObject(targetObject, options = {}) {
7924
7655
  } else {
7925
7656
  value = /* @__PURE__ */ __name(() => options.source?.[key], "value");
7926
7657
  }
7927
- Object.defineProperty(targetObject, key, {
7928
- writable: true,
7929
- configurable: true,
7930
- enumerable: true,
7931
- value
7932
- });
7658
+ defineGetter(targetObject, key, value);
7933
7659
  } else {
7934
7660
  let value;
7935
7661
  if (typeof options.getter == "function") {
@@ -7939,31 +7665,58 @@ function augmentObject(targetObject, options = {}) {
7939
7665
  }
7940
7666
  if (value) {
7941
7667
  targetObject[key] = value;
7668
+ markAugmented(targetObject, key);
7942
7669
  }
7943
7670
  }
7944
7671
  }
7672
+ if (options.overwrite || !isUserDefined(targetObject, DATA_METHOD)) {
7673
+ let dataGetter = options.dataGetter ?? ((source) => source);
7674
+ targetObject[DATA_METHOD] = () => dataGetter(options.source);
7675
+ markAugmented(targetObject, DATA_METHOD);
7676
+ }
7945
7677
  return targetObject;
7946
7678
  }
7947
7679
  __name(augmentObject, "augmentObject");
7680
+ function isUserDefined(targetObject, key) {
7681
+ return Boolean(targetObject[key]) && !augmented.get(targetObject)?.has(key);
7682
+ }
7683
+ __name(isUserDefined, "isUserDefined");
7684
+ function markAugmented(targetObject, key) {
7685
+ if (!augmented.has(targetObject)) {
7686
+ augmented.set(targetObject, /* @__PURE__ */ new Set());
7687
+ }
7688
+ augmented.get(targetObject).add(key);
7689
+ }
7690
+ __name(markAugmented, "markAugmented");
7691
+ function defineGetter(targetObject, key, get) {
7692
+ markAugmented(targetObject, key);
7693
+ Object.defineProperty(targetObject, key, {
7694
+ configurable: true,
7695
+ enumerable: true,
7696
+ get,
7697
+ set(value) {
7698
+ Object.defineProperty(this, key, {
7699
+ value,
7700
+ writable: true,
7701
+ configurable: true,
7702
+ enumerable: true
7703
+ });
7704
+ }
7705
+ });
7706
+ }
7707
+ __name(defineGetter, "defineGetter");
7948
7708
 
7949
7709
  // ../../src/Engines/Liquid.js
7950
7710
  var Liquid2 = class _Liquid extends TemplateEngine {
7951
7711
  static {
7952
7712
  __name(this, "Liquid");
7953
7713
  }
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
- };
7714
+ // Legacy argument tokens (number, double/single quoted string, keyword), separated by commas or whitespace.
7715
+ static argumentLexer = /([0-9]+\.*[0-9]*|"(?:\\["\\]|[^\n"\\])*"|'(?:\\['\\]|[^\n'\\])*'|[a-zA-Z0-9.\-_]+)|[, \t]+/y;
7962
7716
  constructor(name, eleventyConfig) {
7963
7717
  super(name, eleventyConfig);
7964
7718
  this.liquidOptions = this.config.liquidOptions || {};
7965
7719
  this.setLibrary(this.config.libraryOverrides.liquid);
7966
- this.argLexer = import_moo.default.compile(_Liquid.argumentLexerOptions);
7967
7720
  }
7968
7721
  get cacheable() {
7969
7722
  return true;
@@ -7971,6 +7724,7 @@ var Liquid2 = class _Liquid extends TemplateEngine {
7971
7724
  setLibrary(override) {
7972
7725
  this.liquidLib = override || new Liquid(this.getLiquidOptions());
7973
7726
  this.setEngineLib(this.liquidLib, Boolean(this.config.libraryOverrides.liquid));
7727
+ this.#trackPartialFiles();
7974
7728
  this.addFilters(this.config.liquidFilters);
7975
7729
  this.addCustomTags(this.config.liquidTags);
7976
7730
  this.addAllShortcodes(this.config.liquidShortcodes);
@@ -7979,22 +7733,53 @@ var Liquid2 = class _Liquid extends TemplateEngine {
7979
7733
  getLiquidOptions() {
7980
7734
  let defaults = {
7981
7735
  root: [this.dirs.includes, this.dirs.input],
7982
- // supplemented in compile with inputPath below
7983
7736
  extname: ".liquid",
7984
7737
  strictFilters: true,
7985
7738
  // cache: true,
7986
- jsTruthy: true
7739
+ jsTruthy: true,
7987
7740
  // Breaking in v4 #3507
7741
+ timezoneOffset: this.config.dateTimeZone?.zone ?? 0
7742
+ // Match `setDateTimeZone` (or UTC) when parsing dates, breaking in v4 #1905
7988
7743
  };
7744
+ if (this.dirs.layouts) {
7745
+ defaults.layouts = [this.dirs.layouts, ...defaults.root];
7746
+ }
7989
7747
  let options = Object.assign(defaults, this.liquidOptions || {});
7990
7748
  return options;
7991
7749
  }
7750
+ // Records `include`, `render`, and `layout` files in the dependency graph for incremental builds
7751
+ #trackPartialFiles() {
7752
+ let lib = this.liquidLib;
7753
+ if (typeof lib._parsePartialFile !== "function" || typeof lib._parseLayoutFile !== "function") {
7754
+ return;
7755
+ }
7756
+ let engine = this;
7757
+ let track = /* @__PURE__ */ __name((lookupType) => function(file, sync, currentFile) {
7758
+ let parser = new Parser(this);
7759
+ let lookup = parser.loader.lookup;
7760
+ parser.loader.lookup = function* (...args) {
7761
+ let filepath = yield* lookup.apply(this, args);
7762
+ engine.addDependency(currentFile || engine.name, filepath);
7763
+ return filepath;
7764
+ };
7765
+ if (parser.cache) {
7766
+ return (function* () {
7767
+ yield parser.loader.lookup(file, lookupType, sync, currentFile);
7768
+ return yield parser.parseFile(file, sync, lookupType, currentFile);
7769
+ })();
7770
+ }
7771
+ return parser.parseFile(file, sync, lookupType, currentFile);
7772
+ }, "track");
7773
+ lib._parsePartialFile = track(LookupType.Partials);
7774
+ lib._parseLayoutFile = track(LookupType.Layouts);
7775
+ }
7992
7776
  static wrapFilter(name, fn) {
7993
7777
  return function(...args) {
7994
7778
  if (typeof this.context?.get === "function") {
7995
7779
  augmentObject(this, {
7996
7780
  source: this.context,
7997
7781
  getter: /* @__PURE__ */ __name((key, context) => context.get([key]), "getter"),
7782
+ dataGetter: /* @__PURE__ */ __name((context) => context.getAll(), "dataGetter"),
7998
7783
  lazy: this.context.strictVariables
7999
7784
  });
8000
7785
  }
@@ -8009,6 +7794,7 @@ var Liquid2 = class _Liquid extends TemplateEngine {
8009
7794
  augmentObject(obj, {
8010
7795
  source: context,
8011
7796
  getter: /* @__PURE__ */ __name((key, context2) => context2.get([key]), "getter"),
7797
+ dataGetter: /* @__PURE__ */ __name((context2) => context2.getAll(), "dataGetter"),
8012
7798
  lazy: context.strictVariables
8013
7799
  });
8014
7800
  }
@@ -8048,38 +7834,66 @@ var Liquid2 = class _Liquid extends TemplateEngine {
8048
7834
  this.addPairedShortcode(name, shortcodes[name]);
8049
7835
  }
8050
7836
  }
8051
- static parseArguments(lexer, str) {
7837
+ static parseArguments(str) {
8052
7838
  let argArray = [];
8053
- if (!lexer) {
8054
- lexer = import_moo.default.compile(_Liquid.argumentLexerOptions);
7839
+ if (typeof str !== "string") {
7840
+ return argArray;
8055
7841
  }
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();
7842
+ let lexer = new RegExp(_Liquid.argumentLexer);
7843
+ while (lexer.lastIndex < str.length) {
7844
+ let index = lexer.lastIndex;
7845
+ let match = lexer.exec(str);
7846
+ if (!match) {
7847
+ throw new Error(`Invalid Liquid shortcode argument syntax at col ${index + 1}: ${str}`);
7848
+ }
7849
+ if (match[1] !== void 0) {
7850
+ argArray.push(match[1]);
8064
7851
  }
8065
7852
  }
8066
7853
  return argArray;
8067
7854
  }
7855
+ // Reads a `key: value` keyword argument, falling back to a positional value
7856
+ static readArgumentBuiltin(tokenizer) {
7857
+ let begin = tokenizer.p;
7858
+ let hash = tokenizer.readHash();
7859
+ if (hash?.value) {
7860
+ return hash;
7861
+ }
7862
+ tokenizer.p = begin;
7863
+ return tokenizer.readValue();
7864
+ }
8068
7865
  static parseArgumentsBuiltin(args) {
8069
7866
  let tokenizer = new Tokenizer(args);
8070
7867
  let parsedArgs = [];
8071
- let value = tokenizer.readValue();
7868
+ let value = _Liquid.readArgumentBuiltin(tokenizer);
8072
7869
  while (value) {
8073
7870
  parsedArgs.push(value);
8074
7871
  tokenizer.skipBlank();
8075
7872
  if (tokenizer.peek() === ",") {
8076
7873
  tokenizer.advance();
8077
7874
  }
8078
- value = tokenizer.readValue();
7875
+ value = _Liquid.readArgumentBuiltin(tokenizer);
8079
7876
  }
8080
7877
  tokenizer.end();
8081
7878
  return parsedArgs;
8082
7879
  }
7880
+ // Keyword arguments are passed as a trailing object marked with a non-enumerable `__keywords` (Nunjucks-compatible)
7881
+ static *evalArgumentsBuiltin(tokens, ctx) {
7882
+ let args = [];
7883
+ let kwargs;
7884
+ for (let token of tokens) {
7885
+ if (token.kind === TokenKind.Hash) {
7886
+ kwargs ??= Object.defineProperty({}, "__keywords", { value: true });
7887
+ kwargs[token.name.content] = yield evalToken(token.value, ctx);
7888
+ } else {
7889
+ args.push(yield evalToken(token, ctx));
7890
+ }
7891
+ }
7892
+ if (kwargs) {
7893
+ args.push(kwargs);
7894
+ }
7895
+ return args;
7896
+ }
8083
7897
  addShortcode(shortcodeName, shortcodeFn) {
8084
7898
  let _t = this;
8085
7899
  this.addTag(shortcodeName, function(liquidEngine) {
@@ -8095,16 +7909,13 @@ var Liquid2 = class _Liquid extends TemplateEngine {
8095
7909
  render: /* @__PURE__ */ __name(function* (ctx) {
8096
7910
  let argArray = [];
8097
7911
  if (this.legacyArgs) {
8098
- let rawArgs = _Liquid.parseArguments(_t.argLexer, this.legacyArgs);
7912
+ let rawArgs = _Liquid.parseArguments(this.legacyArgs);
8099
7913
  for (let arg of rawArgs) {
8100
7914
  let b = yield liquidEngine.evalValue(arg, ctx);
8101
7915
  argArray.push(b);
8102
7916
  }
8103
7917
  } else if (this.orderedArgs) {
8104
- for (let arg of this.orderedArgs) {
8105
- let b = yield evalToken(arg, ctx);
8106
- argArray.push(b);
8107
- }
7918
+ argArray = yield* _Liquid.evalArgumentsBuiltin(this.orderedArgs, ctx);
8108
7919
  }
8109
7920
  let ret = yield shortcodeFn.call(_Liquid.normalizeScope(ctx), ...argArray);
8110
7921
  return ret;
@@ -8132,16 +7943,13 @@ var Liquid2 = class _Liquid extends TemplateEngine {
8132
7943
  render: /* @__PURE__ */ __name(function* (ctx) {
8133
7944
  let argArray = [];
8134
7945
  if (this.legacyArgs) {
8135
- let rawArgs = _Liquid.parseArguments(_t.argLexer, this.legacyArgs);
7946
+ let rawArgs = _Liquid.parseArguments(this.legacyArgs);
8136
7947
  for (let arg of rawArgs) {
8137
7948
  let b = yield liquidEngine.evalValue(arg, ctx);
8138
7949
  argArray.push(b);
8139
7950
  }
8140
7951
  } else if (this.orderedArgs) {
8141
- for (let arg of this.orderedArgs) {
8142
- let b = yield evalToken(arg, ctx);
8143
- argArray.push(b);
8144
- }
7952
+ argArray = yield* _Liquid.evalArgumentsBuiltin(this.orderedArgs, ctx);
8145
7953
  }
8146
7954
  const html = yield liquidEngine.renderer.renderTemplates(this.templates, ctx);
8147
7955
  let ret = yield shortcodeFn.call(_Liquid.normalizeScope(ctx), html, ...argArray);