@jaredwray/fumanchu 3.1.3 → 4.0.1

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.
package/dist/index.cjs ADDED
@@ -0,0 +1,2250 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all2) => {
9
+ for (var name in all2)
10
+ __defProp(target, name, { get: all2[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Handlebars: () => Handlebars2,
34
+ HelperRegistry: () => HelperRegistry,
35
+ createHandlebars: () => createHandlebars,
36
+ fumanchu: () => fumanchu,
37
+ handlebars: () => handlebars,
38
+ helpers: () => helpers21
39
+ });
40
+ module.exports = __toCommonJS(index_exports);
41
+ var import_handlebars2 = __toESM(require("handlebars"), 1);
42
+
43
+ // src/helpers/array.ts
44
+ var after = (array, n) => {
45
+ if (!Array.isArray(array)) return [];
46
+ return array.slice(n);
47
+ };
48
+ var before = (array, n) => {
49
+ if (!Array.isArray(array)) return [];
50
+ return array.slice(0, -n);
51
+ };
52
+ var arrayify = (value) => {
53
+ if (value == null) return [];
54
+ return Array.isArray(value) ? value : [value];
55
+ };
56
+ var first = (array, n) => {
57
+ if (!Array.isArray(array)) return void 0;
58
+ if (typeof n !== "number") {
59
+ return array[0];
60
+ }
61
+ return array.slice(0, n);
62
+ };
63
+ var last = (value, n) => {
64
+ if (!Array.isArray(value) && typeof value !== "string") {
65
+ return void 0;
66
+ }
67
+ if (typeof n !== "number") {
68
+ const array = value;
69
+ return array[array.length - 1];
70
+ }
71
+ const start = Math.abs(n);
72
+ if (typeof value === "string") {
73
+ return value.slice(-start);
74
+ }
75
+ return value.slice(-start);
76
+ };
77
+ var length = (value) => {
78
+ if (value && typeof value === "object" && !Array.isArray(value)) {
79
+ return Object.keys(value).length;
80
+ }
81
+ if (typeof value === "string" || Array.isArray(value)) {
82
+ return value.length;
83
+ }
84
+ return 0;
85
+ };
86
+ var join = (array, separator = ", ") => {
87
+ if (typeof array === "string") return array;
88
+ if (!Array.isArray(array)) return "";
89
+ return array.join(separator);
90
+ };
91
+ var helpers = [
92
+ {
93
+ name: "after",
94
+ category: "array",
95
+ compatibility: ["browser", "nodejs"],
96
+ fn: after
97
+ },
98
+ {
99
+ name: "before",
100
+ category: "array",
101
+ compatibility: ["browser", "nodejs"],
102
+ fn: before
103
+ },
104
+ {
105
+ name: "arrayify",
106
+ category: "array",
107
+ compatibility: ["browser", "nodejs"],
108
+ fn: arrayify
109
+ },
110
+ {
111
+ name: "first",
112
+ category: "array",
113
+ compatibility: ["browser", "nodejs"],
114
+ fn: first
115
+ },
116
+ {
117
+ name: "last",
118
+ category: "array",
119
+ compatibility: ["browser", "nodejs"],
120
+ fn: last
121
+ },
122
+ {
123
+ name: "length",
124
+ category: "array",
125
+ compatibility: ["browser", "nodejs"],
126
+ fn: length
127
+ },
128
+ {
129
+ name: "join",
130
+ category: "array",
131
+ compatibility: ["browser", "nodejs"],
132
+ fn: join
133
+ }
134
+ ];
135
+
136
+ // src/helpers/code.ts
137
+ var import_node_fs = __toESM(require("fs"), 1);
138
+ var import_node_path = __toESM(require("path"), 1);
139
+ var import_html_tag = __toESM(require("html-tag"), 1);
140
+ var import_to_gfm_code_block = __toESM(require("to-gfm-code-block"), 1);
141
+ var embed = (filepath, language) => {
142
+ let ext = typeof language === "string" ? language : import_node_path.default.extname(filepath).slice(1);
143
+ let code = import_node_fs.default.readFileSync(filepath, "utf8");
144
+ if (ext === "markdown" || ext === "md") {
145
+ ext = "markdown";
146
+ code = code.split("`").join("&#x60");
147
+ }
148
+ return `${(0, import_to_gfm_code_block.default)(code, ext).trim()}
149
+ `;
150
+ };
151
+ var gist = (id) => {
152
+ return (0, import_html_tag.default)("script", { src: `https://gist.github.com/${id}.js` });
153
+ };
154
+ var jsfiddle = (options) => {
155
+ if (!options || !options.id) {
156
+ throw new Error("jsfiddle helper expects an `id`");
157
+ }
158
+ const {
159
+ id,
160
+ width = "100%",
161
+ height = "300",
162
+ skin = "/presentation/",
163
+ tabs = "result,js,html,css",
164
+ allowfullscreen = "allowfullscreen",
165
+ frameborder = "0"
166
+ } = options;
167
+ const src = `http://jsfiddle.net/${id}/embedded/${tabs}${skin}`;
168
+ return (0, import_html_tag.default)("iframe", { width, height, src, allowfullscreen, frameborder });
169
+ };
170
+ var helpers2 = [
171
+ {
172
+ name: "embed",
173
+ category: "code",
174
+ compatibility: ["nodejs"],
175
+ fn: embed
176
+ },
177
+ {
178
+ name: "gist",
179
+ category: "code",
180
+ compatibility: ["browser", "nodejs"],
181
+ fn: gist
182
+ },
183
+ {
184
+ name: "jsfiddle",
185
+ category: "code",
186
+ compatibility: ["browser", "nodejs"],
187
+ fn: jsfiddle
188
+ }
189
+ ];
190
+
191
+ // src/helpers/collection.ts
192
+ var isEmpty = (collection) => {
193
+ if (collection == null) return true;
194
+ if (Array.isArray(collection)) return collection.length === 0;
195
+ if (typeof collection === "object")
196
+ return Object.keys(collection).length === 0;
197
+ return false;
198
+ };
199
+ var iterate = (collection, fn, inverse) => {
200
+ if (Array.isArray(collection)) {
201
+ let result = "";
202
+ for (let i = 0; i < collection.length; i++) {
203
+ result += fn(collection[i], i);
204
+ }
205
+ return result;
206
+ }
207
+ if (collection && typeof collection === "object") {
208
+ let result = "";
209
+ for (const key of Object.keys(collection)) {
210
+ result += fn(collection[key], key);
211
+ }
212
+ return result;
213
+ }
214
+ return inverse ? inverse() : "";
215
+ };
216
+ var helpers3 = [
217
+ {
218
+ name: "isEmpty",
219
+ category: "collection",
220
+ compatibility: ["browser", "nodejs"],
221
+ fn: isEmpty
222
+ },
223
+ {
224
+ name: "iterate",
225
+ category: "collection",
226
+ compatibility: ["browser", "nodejs"],
227
+ fn: iterate
228
+ }
229
+ ];
230
+
231
+ // src/helpers/comparison.ts
232
+ var and = (...values) => values.every(Boolean);
233
+ var compare = (a, operator, b) => {
234
+ switch (operator) {
235
+ case "==":
236
+ return a == b;
237
+ // eslint-disable-line eqeqeq
238
+ case "===":
239
+ return a === b;
240
+ case "!=":
241
+ return a != b;
242
+ // eslint-disable-line eqeqeq
243
+ case "!==":
244
+ return a !== b;
245
+ case "<":
246
+ return a < b;
247
+ case ">":
248
+ return a > b;
249
+ case "<=":
250
+ return a <= b;
251
+ case ">=":
252
+ return a >= b;
253
+ case "typeof":
254
+ return typeof a === b;
255
+ default:
256
+ throw new Error(`helper {{compare}}: invalid operator: '${operator}'`);
257
+ }
258
+ };
259
+ var contains = (collection, value, startIndex = 0) => {
260
+ if (collection == null) return false;
261
+ if (typeof collection === "string" || Array.isArray(collection)) {
262
+ return collection.indexOf(value, startIndex) > -1;
263
+ }
264
+ if (typeof collection === "object") {
265
+ return value in collection;
266
+ }
267
+ return false;
268
+ };
269
+ var defaultHelper = (...values) => {
270
+ for (const val of values) {
271
+ if (val != null) return val;
272
+ }
273
+ return "";
274
+ };
275
+ var eq = (a, b) => a === b;
276
+ var gt = (a, b) => a > b;
277
+ var gte = (a, b) => a >= b;
278
+ var has = (value, pattern) => {
279
+ if (value == null || pattern == null) return false;
280
+ if (Array.isArray(value) || typeof value === "string") {
281
+ return value.indexOf(pattern) > -1;
282
+ }
283
+ if (typeof value === "object") {
284
+ return pattern in value;
285
+ }
286
+ return false;
287
+ };
288
+ var falsey = (val, keywords) => {
289
+ if (!val) return true;
290
+ const words = Array.isArray(keywords) ? keywords : keywords != null ? [keywords] : [
291
+ "0",
292
+ "false",
293
+ "nada",
294
+ "nil",
295
+ "nay",
296
+ "nah",
297
+ "negative",
298
+ "no",
299
+ "none",
300
+ "nope",
301
+ "nul",
302
+ "null",
303
+ "nix",
304
+ "nyet",
305
+ "uh-uh",
306
+ "veto",
307
+ "zero"
308
+ ];
309
+ const lower = typeof val === "string" ? val.toLowerCase() : null;
310
+ for (const word of words) {
311
+ if (word === val) return true;
312
+ if (lower != null && word === lower) return true;
313
+ }
314
+ return false;
315
+ };
316
+ var isFalsey = (val) => falsey(val);
317
+ var isTruthy = (val) => !falsey(val);
318
+ var ifEven = (num) => typeof num === "number" && num % 2 === 0;
319
+ var ifNth = (a, b) => typeof a === "number" && typeof b === "number" && b % a === 0;
320
+ var ifOdd = (val) => typeof val === "number" && Math.abs(val % 2) === 1;
321
+ var is = (a, b) => a == b;
322
+ var isnt = (a, b) => a != b;
323
+ var lt = (a, b) => a < b;
324
+ var lte = (a, b) => a <= b;
325
+ var neither = (a, b) => !a && !b;
326
+ var not = (val) => !val;
327
+ var or = (...values) => values.some(Boolean);
328
+ var unlessEq = (a, b) => a !== b;
329
+ var unlessGt = (a, b) => a <= b;
330
+ var unlessLt = (a, b) => a >= b;
331
+ var unlessGteq = (a, b) => a < b;
332
+ var unlessLteq = (a, b) => a > b;
333
+ var helpers4 = [
334
+ {
335
+ name: "and",
336
+ category: "comparison",
337
+ compatibility: ["browser", "nodejs"],
338
+ fn: and
339
+ },
340
+ {
341
+ name: "compare",
342
+ category: "comparison",
343
+ compatibility: ["browser", "nodejs"],
344
+ fn: compare
345
+ },
346
+ {
347
+ name: "contains",
348
+ category: "comparison",
349
+ compatibility: ["browser", "nodejs"],
350
+ fn: contains
351
+ },
352
+ {
353
+ name: "default",
354
+ category: "comparison",
355
+ compatibility: ["browser", "nodejs"],
356
+ fn: defaultHelper
357
+ },
358
+ {
359
+ name: "eq",
360
+ category: "comparison",
361
+ compatibility: ["browser", "nodejs"],
362
+ fn: eq
363
+ },
364
+ {
365
+ name: "gt",
366
+ category: "comparison",
367
+ compatibility: ["browser", "nodejs"],
368
+ fn: gt
369
+ },
370
+ {
371
+ name: "gte",
372
+ category: "comparison",
373
+ compatibility: ["browser", "nodejs"],
374
+ fn: gte
375
+ },
376
+ {
377
+ name: "has",
378
+ category: "comparison",
379
+ compatibility: ["browser", "nodejs"],
380
+ fn: has
381
+ },
382
+ {
383
+ name: "isFalsey",
384
+ category: "comparison",
385
+ compatibility: ["browser", "nodejs"],
386
+ fn: isFalsey
387
+ },
388
+ {
389
+ name: "isTruthy",
390
+ category: "comparison",
391
+ compatibility: ["browser", "nodejs"],
392
+ fn: isTruthy
393
+ },
394
+ {
395
+ name: "ifEven",
396
+ category: "comparison",
397
+ compatibility: ["browser", "nodejs"],
398
+ fn: ifEven
399
+ },
400
+ {
401
+ name: "ifNth",
402
+ category: "comparison",
403
+ compatibility: ["browser", "nodejs"],
404
+ fn: ifNth
405
+ },
406
+ {
407
+ name: "ifOdd",
408
+ category: "comparison",
409
+ compatibility: ["browser", "nodejs"],
410
+ fn: ifOdd
411
+ },
412
+ {
413
+ name: "is",
414
+ category: "comparison",
415
+ compatibility: ["browser", "nodejs"],
416
+ fn: is
417
+ },
418
+ {
419
+ name: "isnt",
420
+ category: "comparison",
421
+ compatibility: ["browser", "nodejs"],
422
+ fn: isnt
423
+ },
424
+ {
425
+ name: "lt",
426
+ category: "comparison",
427
+ compatibility: ["browser", "nodejs"],
428
+ fn: lt
429
+ },
430
+ {
431
+ name: "lte",
432
+ category: "comparison",
433
+ compatibility: ["browser", "nodejs"],
434
+ fn: lte
435
+ },
436
+ {
437
+ name: "neither",
438
+ category: "comparison",
439
+ compatibility: ["browser", "nodejs"],
440
+ fn: neither
441
+ },
442
+ {
443
+ name: "not",
444
+ category: "comparison",
445
+ compatibility: ["browser", "nodejs"],
446
+ fn: not
447
+ },
448
+ {
449
+ name: "or",
450
+ category: "comparison",
451
+ compatibility: ["browser", "nodejs"],
452
+ fn: or
453
+ },
454
+ {
455
+ name: "unlessEq",
456
+ category: "comparison",
457
+ compatibility: ["browser", "nodejs"],
458
+ fn: unlessEq
459
+ },
460
+ {
461
+ name: "unlessGt",
462
+ category: "comparison",
463
+ compatibility: ["browser", "nodejs"],
464
+ fn: unlessGt
465
+ },
466
+ {
467
+ name: "unlessLt",
468
+ category: "comparison",
469
+ compatibility: ["browser", "nodejs"],
470
+ fn: unlessLt
471
+ },
472
+ {
473
+ name: "unlessGteq",
474
+ category: "comparison",
475
+ compatibility: ["browser", "nodejs"],
476
+ fn: unlessGteq
477
+ },
478
+ {
479
+ name: "unlessLteq",
480
+ category: "comparison",
481
+ compatibility: ["browser", "nodejs"],
482
+ fn: unlessLteq
483
+ }
484
+ ];
485
+
486
+ // src/helpers/date.ts
487
+ var import_chrono_node = require("chrono-node");
488
+ var import_dayjs = __toESM(require("dayjs"), 1);
489
+ var year = () => (/* @__PURE__ */ new Date()).getFullYear().toString();
490
+ var date = (humanReadableDate, formatString) => {
491
+ const parsedDate = (0, import_chrono_node.parseDate)(humanReadableDate);
492
+ if (!parsedDate) {
493
+ throw new Error(`Unable to parse date: ${humanReadableDate}`);
494
+ }
495
+ return (0, import_dayjs.default)(parsedDate).format(formatString);
496
+ };
497
+ var helpers5 = [
498
+ {
499
+ name: "year",
500
+ category: "date",
501
+ compatibility: ["browser", "nodejs"],
502
+ fn: year
503
+ },
504
+ {
505
+ name: "date",
506
+ category: "date",
507
+ compatibility: ["browser", "nodejs"],
508
+ fn: date
509
+ },
510
+ {
511
+ /* Adding this in for legacy support */
512
+ name: "moment",
513
+ category: "date",
514
+ compatibility: ["browser", "nodejs"],
515
+ fn: date
516
+ }
517
+ ];
518
+
519
+ // src/helpers/fs.ts
520
+ var import_node_fs2 = __toESM(require("fs"), 1);
521
+ var import_node_path2 = __toESM(require("path"), 1);
522
+ var import_is_glob = __toESM(require("is-glob"), 1);
523
+ var import_micromatch = __toESM(require("micromatch"), 1);
524
+ var fileSize = (value, precision) => {
525
+ if (value == null) return "0 B";
526
+ const number = typeof value === "number" ? value : value.length ?? 0;
527
+ if (!number) return "0 B";
528
+ const precisionNumber = typeof precision === "number" ? precision : 2;
529
+ const abbr = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
530
+ const factor = 10 ** precisionNumber;
531
+ let i = abbr.length - 1;
532
+ do {
533
+ const size = 10 ** (i * 3);
534
+ if (size <= number + 1) {
535
+ const num = Math.round(number * factor / size) / factor;
536
+ return `${num} ${abbr[i]}`;
537
+ }
538
+ } while (--i >= 0);
539
+ return `${number} B`;
540
+ };
541
+ var read = (filepath) => {
542
+ return import_node_fs2.default.readFileSync(filepath, "utf8");
543
+ };
544
+ var isOptions = (value) => {
545
+ return Boolean(
546
+ value && typeof value === "object" && "hash" in value
547
+ );
548
+ };
549
+ var readdir = (dir, filter) => {
550
+ const files = import_node_fs2.default.readdirSync(dir).map((fp) => import_node_path2.default.join(dir, fp));
551
+ const filterArg = isOptions(filter) ? void 0 : filter;
552
+ if (typeof filterArg === "function") {
553
+ return filterArg(files);
554
+ }
555
+ if (filterArg instanceof RegExp) {
556
+ return files.filter((fp) => filterArg.test(fp));
557
+ }
558
+ if (typeof filterArg === "string") {
559
+ if ((0, import_is_glob.default)(filterArg)) {
560
+ return (0, import_micromatch.default)(files, filterArg);
561
+ }
562
+ if (filterArg === "isFile" || filterArg === "isDirectory") {
563
+ return files.filter((fp) => {
564
+ const stat = import_node_fs2.default.statSync(fp);
565
+ return filterArg === "isFile" ? stat.isFile() : stat.isDirectory();
566
+ });
567
+ }
568
+ }
569
+ return files;
570
+ };
571
+ var helpers6 = [
572
+ {
573
+ name: "fileSize",
574
+ category: "fs",
575
+ compatibility: ["nodejs"],
576
+ fn: fileSize
577
+ },
578
+ {
579
+ name: "read",
580
+ category: "fs",
581
+ compatibility: ["nodejs"],
582
+ fn: read
583
+ },
584
+ {
585
+ name: "readdir",
586
+ category: "fs",
587
+ compatibility: ["nodejs"],
588
+ fn: readdir
589
+ }
590
+ ];
591
+
592
+ // src/helpers/html.ts
593
+ var import_node_path3 = __toESM(require("path"), 1);
594
+ var import_html_tag2 = __toESM(require("html-tag"), 1);
595
+ var import_striptags = __toESM(require("striptags"), 1);
596
+ var parseAttributes = (hash = {}) => Object.keys(hash).map((key) => `${key}="${String(hash[key]).replace(/^['"]|["']$/g, "")}"`).join(" ");
597
+ var attr = (options) => {
598
+ const val = parseAttributes(options?.hash ?? {});
599
+ return val.trim() ? ` ${val}` : "";
600
+ };
601
+ var css = function(list, options) {
602
+ if (arguments.length < 2) {
603
+ options = list;
604
+ list = [];
605
+ }
606
+ let styles = arrayify(list ?? []);
607
+ let assets = "";
608
+ if (this && this.options) {
609
+ assets = this.options.assets || "";
610
+ }
611
+ if (options?.hash?.href) {
612
+ styles = arrayify(options.hash.href);
613
+ }
614
+ return styles.map((item) => {
615
+ const ext = import_node_path3.default.extname(item);
616
+ let fp = item;
617
+ if (!/(^\/\/)|(:\/\/)/.test(item)) {
618
+ fp = import_node_path3.default.posix.join(assets, item);
619
+ }
620
+ if (ext === ".less") {
621
+ return `<link type="text/css" rel="stylesheet/less" href="${fp}">`;
622
+ }
623
+ return `<link type="text/css" rel="stylesheet" href="${fp}">`;
624
+ }).join("\n");
625
+ };
626
+ var js = (context) => {
627
+ if (context && typeof context === "object" && !Array.isArray(context)) {
628
+ const attrStr = parseAttributes(context.hash ?? {});
629
+ return `<script${attrStr ? ` ${attrStr}` : ""}></script>`;
630
+ }
631
+ if (typeof context === "string") {
632
+ return `<script src="${context}"></script>`;
633
+ }
634
+ const items = arrayify(context);
635
+ return items.map(
636
+ (fp) => import_node_path3.default.extname(fp) === ".coffee" ? (0, import_html_tag2.default)("script", { type: "text/coffeescript", src: fp }) : (0, import_html_tag2.default)("script", { src: fp })
637
+ ).join("\n");
638
+ };
639
+ var sanitize = (str) => {
640
+ if (typeof str !== "string") return "";
641
+ return (0, import_striptags.default)(str).trim();
642
+ };
643
+ var ul = (context, options) => {
644
+ const attrs = parseAttributes(options.hash ?? {});
645
+ const items = context.map(
646
+ (item) => typeof item === "string" ? item : options.fn(item)
647
+ );
648
+ const open = attrs ? `<ul ${attrs}>` : "<ul>";
649
+ return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ul>`;
650
+ };
651
+ var ol = (context, options) => {
652
+ const attrs = parseAttributes(options.hash ?? {});
653
+ const items = context.map(
654
+ (item) => typeof item === "string" ? item : options.fn(item)
655
+ );
656
+ const open = attrs ? `<ol ${attrs}>` : "<ol>";
657
+ return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ol>`;
658
+ };
659
+ var thumbnailImage = (context) => {
660
+ let figure = "";
661
+ let image = "";
662
+ const link = context.full || false;
663
+ const imageAttributes = {
664
+ alt: context.alt,
665
+ src: context.thumbnail,
666
+ width: context.size.width,
667
+ height: context.size.height
668
+ };
669
+ const figureAttributes = { id: `image-${context.id}` };
670
+ const linkAttributes = { href: link, rel: "thumbnail" };
671
+ if (context.classes) {
672
+ if (context.classes.image) {
673
+ imageAttributes.class = context.classes.image.join(" ");
674
+ }
675
+ if (context.classes.figure) {
676
+ figureAttributes.class = context.classes.figure.join(" ");
677
+ }
678
+ if (context.classes.link) {
679
+ linkAttributes.class = context.classes.link.join(" ");
680
+ }
681
+ }
682
+ figure += `<figure ${parseAttributes(figureAttributes)}>
683
+ `;
684
+ image += `<img ${parseAttributes(imageAttributes)}>
685
+ `;
686
+ if (link) {
687
+ figure += `<a ${parseAttributes(linkAttributes)}>
688
+ ${image}</a>
689
+ `;
690
+ } else {
691
+ figure += image;
692
+ }
693
+ if (context.caption) {
694
+ figure += `<figcaption>${context.caption}</figcaption>
695
+ `;
696
+ }
697
+ figure += "</figure>";
698
+ return figure;
699
+ };
700
+ var helpers7 = [
701
+ {
702
+ name: "attr",
703
+ category: "html",
704
+ compatibility: ["browser", "nodejs"],
705
+ fn: attr
706
+ },
707
+ {
708
+ name: "css",
709
+ category: "html",
710
+ compatibility: ["nodejs"],
711
+ fn: css
712
+ },
713
+ {
714
+ name: "js",
715
+ category: "html",
716
+ compatibility: ["nodejs"],
717
+ fn: js
718
+ },
719
+ {
720
+ name: "sanitize",
721
+ category: "html",
722
+ compatibility: ["browser", "nodejs"],
723
+ fn: sanitize
724
+ },
725
+ {
726
+ name: "ul",
727
+ category: "html",
728
+ compatibility: ["browser", "nodejs"],
729
+ fn: ul
730
+ },
731
+ {
732
+ name: "ol",
733
+ category: "html",
734
+ compatibility: ["browser", "nodejs"],
735
+ fn: ol
736
+ },
737
+ {
738
+ name: "thumbnailImage",
739
+ category: "html",
740
+ compatibility: ["browser", "nodejs"],
741
+ fn: thumbnailImage
742
+ }
743
+ ];
744
+
745
+ // src/helpers/i18n.ts
746
+ var import_get_value = __toESM(require("get-value"), 1);
747
+ var i18n = function(prop, locals, options) {
748
+ if (locals && typeof locals === "object" && "hash" in locals && options === void 0) {
749
+ options = locals;
750
+ locals = {};
751
+ }
752
+ if (typeof prop !== "string") {
753
+ throw new Error('{{i18n}} helper expected "key" to be a string');
754
+ }
755
+ const context = {
756
+ ...this,
757
+ ...locals,
758
+ ...options?.hash ?? {}
759
+ };
760
+ const lang = context.language || context.lang;
761
+ if (typeof lang !== "string") {
762
+ throw new TypeError('{{i18n}} helper expected "language" to be a string');
763
+ }
764
+ const cache = context[lang];
765
+ if (typeof cache === "undefined") {
766
+ throw new Error(`{{i18n}} helper cannot find language "${lang}"`);
767
+ }
768
+ const result = (0, import_get_value.default)(cache, prop);
769
+ if (typeof result === "undefined") {
770
+ throw new Error(
771
+ '{{i18n}} helper cannot find property "' + String(prop) + '" for language "' + lang + '"'
772
+ );
773
+ }
774
+ return String(result);
775
+ };
776
+ var helpers8 = [
777
+ {
778
+ name: "i18n",
779
+ category: "i18n",
780
+ compatibility: ["browser", "nodejs"],
781
+ fn: i18n
782
+ }
783
+ ];
784
+
785
+ // src/helpers/inflection.ts
786
+ var inflect = (count, singular, plural, includeCount) => {
787
+ const word = count > 1 || count === 0 ? plural : singular;
788
+ return includeCount ? `${count} ${word}` : word;
789
+ };
790
+ var ordinalize = (value) => {
791
+ const num = Math.abs(Math.round(Number(value)));
792
+ const str = String(value);
793
+ const res = num % 100;
794
+ if ([11, 12, 13].includes(res)) {
795
+ return `${str}th`;
796
+ }
797
+ switch (num % 10) {
798
+ case 1:
799
+ return `${str}st`;
800
+ case 2:
801
+ return `${str}nd`;
802
+ case 3:
803
+ return `${str}rd`;
804
+ default:
805
+ return `${str}th`;
806
+ }
807
+ };
808
+ var helpers9 = [
809
+ {
810
+ name: "inflect",
811
+ category: "inflection",
812
+ compatibility: ["browser", "nodejs"],
813
+ fn: inflect
814
+ },
815
+ {
816
+ name: "ordinalize",
817
+ category: "inflection",
818
+ compatibility: ["browser", "nodejs"],
819
+ fn: ordinalize
820
+ }
821
+ ];
822
+
823
+ // src/helpers/logging.ts
824
+ var import_logging_helpers = __toESM(require("logging-helpers"), 1);
825
+ var {
826
+ log,
827
+ ok,
828
+ success,
829
+ info,
830
+ warning,
831
+ warn,
832
+ error,
833
+ danger,
834
+ bold,
835
+ _debug,
836
+ _inspect
837
+ } = import_logging_helpers.default;
838
+ var helpers10 = [
839
+ {
840
+ name: "log",
841
+ category: "logging",
842
+ compatibility: ["nodejs"],
843
+ fn: log
844
+ },
845
+ {
846
+ name: "ok",
847
+ category: "logging",
848
+ compatibility: ["nodejs"],
849
+ fn: ok
850
+ },
851
+ {
852
+ name: "success",
853
+ category: "logging",
854
+ compatibility: ["nodejs"],
855
+ fn: success
856
+ },
857
+ {
858
+ name: "info",
859
+ category: "logging",
860
+ compatibility: ["nodejs"],
861
+ fn: info
862
+ },
863
+ {
864
+ name: "warning",
865
+ category: "logging",
866
+ compatibility: ["nodejs"],
867
+ fn: warning
868
+ },
869
+ {
870
+ name: "warn",
871
+ category: "logging",
872
+ compatibility: ["nodejs"],
873
+ fn: warn
874
+ },
875
+ {
876
+ name: "error",
877
+ category: "logging",
878
+ compatibility: ["nodejs"],
879
+ fn: error
880
+ },
881
+ {
882
+ name: "danger",
883
+ category: "logging",
884
+ compatibility: ["nodejs"],
885
+ fn: danger
886
+ },
887
+ {
888
+ name: "bold",
889
+ category: "logging",
890
+ compatibility: ["nodejs"],
891
+ fn: bold
892
+ },
893
+ {
894
+ name: "_debug",
895
+ category: "logging",
896
+ compatibility: ["nodejs"],
897
+ fn: _debug
898
+ },
899
+ {
900
+ name: "_inspect",
901
+ category: "logging",
902
+ compatibility: ["nodejs"],
903
+ fn: _inspect
904
+ }
905
+ ];
906
+
907
+ // src/helpers/match.ts
908
+ var import_micromatch2 = __toESM(require("micromatch"), 1);
909
+ var match = (files, patterns, options) => {
910
+ const pats = typeof patterns === "string" ? patterns.split(/, */) : patterns;
911
+ return (0, import_micromatch2.default)(files, pats, options);
912
+ };
913
+ var isMatch = (filepath, pattern, options) => {
914
+ return import_micromatch2.default.isMatch(filepath, pattern, options);
915
+ };
916
+ var mm = (...args) => {
917
+ console.log("the {{mm}} helper is depcrecated and will be removed");
918
+ console.log("in handlebars-helpers v1.0.0, please use the {{match}}");
919
+ console.log("helper instead.");
920
+ return match(...args);
921
+ };
922
+ var helpers11 = [
923
+ {
924
+ name: "match",
925
+ category: "match",
926
+ compatibility: ["browser", "nodejs"],
927
+ fn: match
928
+ },
929
+ {
930
+ name: "isMatch",
931
+ category: "match",
932
+ compatibility: ["browser", "nodejs"],
933
+ fn: isMatch
934
+ },
935
+ {
936
+ name: "mm",
937
+ category: "match",
938
+ compatibility: ["browser", "nodejs"],
939
+ fn: mm
940
+ }
941
+ ];
942
+
943
+ // src/helpers/math.ts
944
+ var isNumeric = (value) => typeof value === "number" && !Number.isNaN(value) || typeof value === "string" && value.trim() !== "" && !Number.isNaN(Number(value));
945
+ var toNumber = (value, message = "expected a number") => {
946
+ if (isNumeric(value)) {
947
+ return Number(value);
948
+ }
949
+ throw new TypeError(message);
950
+ };
951
+ var abs = (value) => {
952
+ const num = toNumber(value);
953
+ return Math.abs(num);
954
+ };
955
+ var add = (a, b) => {
956
+ if (isNumeric(a) && isNumeric(b)) {
957
+ return Number(a) + Number(b);
958
+ }
959
+ return "";
960
+ };
961
+ var avg = (...values) => {
962
+ const flat = values.flat().map((n) => Number(n));
963
+ return sum(flat) / flat.length;
964
+ };
965
+ var ceil = (value) => {
966
+ const num = toNumber(value);
967
+ return Math.ceil(num);
968
+ };
969
+ var divide = (a, b) => {
970
+ const numA = toNumber(a, "expected the first argument to be a number");
971
+ const numB = toNumber(b, "expected the second argument to be a number");
972
+ return numA / numB;
973
+ };
974
+ var floor = (value) => {
975
+ const num = toNumber(value);
976
+ return Math.floor(num);
977
+ };
978
+ var minus = (a, b) => {
979
+ const numA = toNumber(a, "expected the first argument to be a number");
980
+ const numB = toNumber(b, "expected the second argument to be a number");
981
+ return numA - numB;
982
+ };
983
+ var modulo = (a, b) => {
984
+ const numA = toNumber(a, "expected the first argument to be a number");
985
+ const numB = toNumber(b, "expected the second argument to be a number");
986
+ return numA % numB;
987
+ };
988
+ var multiply = (a, b) => {
989
+ const numA = toNumber(a, "expected the first argument to be a number");
990
+ const numB = toNumber(b, "expected the second argument to be a number");
991
+ return numA * numB;
992
+ };
993
+ var plus = (a, b) => {
994
+ const numA = toNumber(a, "expected the first argument to be a number");
995
+ const numB = toNumber(b, "expected the second argument to be a number");
996
+ return numA + numB;
997
+ };
998
+ var random = (min, max) => {
999
+ const minNum = toNumber(min, "expected minimum to be a number");
1000
+ const maxNum = toNumber(max, "expected maximum to be a number");
1001
+ return minNum + Math.floor(Math.random() * (maxNum - minNum + 1));
1002
+ };
1003
+ var remainder = (a, b) => a % b;
1004
+ var round = (value) => {
1005
+ const num = toNumber(value);
1006
+ return Math.round(num);
1007
+ };
1008
+ var subtract = (a, b) => {
1009
+ const numA = toNumber(a, "expected the first argument to be a number");
1010
+ const numB = toNumber(b, "expected the second argument to be a number");
1011
+ return numA - numB;
1012
+ };
1013
+ var sum = (...values) => {
1014
+ const flat = values.flat();
1015
+ let total = 0;
1016
+ for (const value of flat) {
1017
+ if (isNumeric(value)) {
1018
+ total += Number(value);
1019
+ }
1020
+ }
1021
+ return total;
1022
+ };
1023
+ var times = (a, b) => multiply(a, b);
1024
+ var helpers12 = [
1025
+ {
1026
+ name: "abs",
1027
+ category: "math",
1028
+ compatibility: ["browser", "nodejs"],
1029
+ fn: abs
1030
+ },
1031
+ {
1032
+ name: "add",
1033
+ category: "math",
1034
+ compatibility: ["browser", "nodejs"],
1035
+ fn: add
1036
+ },
1037
+ {
1038
+ name: "avg",
1039
+ category: "math",
1040
+ compatibility: ["browser", "nodejs"],
1041
+ fn: avg
1042
+ },
1043
+ {
1044
+ name: "ceil",
1045
+ category: "math",
1046
+ compatibility: ["browser", "nodejs"],
1047
+ fn: ceil
1048
+ },
1049
+ {
1050
+ name: "divide",
1051
+ category: "math",
1052
+ compatibility: ["browser", "nodejs"],
1053
+ fn: divide
1054
+ },
1055
+ {
1056
+ name: "floor",
1057
+ category: "math",
1058
+ compatibility: ["browser", "nodejs"],
1059
+ fn: floor
1060
+ },
1061
+ {
1062
+ name: "minus",
1063
+ category: "math",
1064
+ compatibility: ["browser", "nodejs"],
1065
+ fn: minus
1066
+ },
1067
+ {
1068
+ name: "modulo",
1069
+ category: "math",
1070
+ compatibility: ["browser", "nodejs"],
1071
+ fn: modulo
1072
+ },
1073
+ {
1074
+ name: "multiply",
1075
+ category: "math",
1076
+ compatibility: ["browser", "nodejs"],
1077
+ fn: multiply
1078
+ },
1079
+ {
1080
+ name: "plus",
1081
+ category: "math",
1082
+ compatibility: ["browser", "nodejs"],
1083
+ fn: plus
1084
+ },
1085
+ {
1086
+ name: "random",
1087
+ category: "math",
1088
+ compatibility: ["browser", "nodejs"],
1089
+ fn: random
1090
+ },
1091
+ {
1092
+ name: "remainder",
1093
+ category: "math",
1094
+ compatibility: ["browser", "nodejs"],
1095
+ fn: remainder
1096
+ },
1097
+ {
1098
+ name: "round",
1099
+ category: "math",
1100
+ compatibility: ["browser", "nodejs"],
1101
+ fn: round
1102
+ },
1103
+ {
1104
+ name: "subtract",
1105
+ category: "math",
1106
+ compatibility: ["browser", "nodejs"],
1107
+ fn: subtract
1108
+ },
1109
+ {
1110
+ name: "sum",
1111
+ category: "math",
1112
+ compatibility: ["browser", "nodejs"],
1113
+ fn: sum
1114
+ },
1115
+ {
1116
+ name: "times",
1117
+ category: "math",
1118
+ compatibility: ["browser", "nodejs"],
1119
+ fn: times
1120
+ }
1121
+ ];
1122
+
1123
+ // src/helpers/md.ts
1124
+ var import_node_fs3 = __toESM(require("fs"), 1);
1125
+ var import_node_path4 = __toESM(require("path"), 1);
1126
+ var import_node_process = __toESM(require("process"), 1);
1127
+ var import_ent = __toESM(require("ent"), 1);
1128
+ var import_handlebars = __toESM(require("handlebars"), 1);
1129
+ var import_remarkable = require("remarkable");
1130
+ var renderMarkdown = (input, options = {}) => {
1131
+ const options_ = { cwd: import_node_process.default.cwd(), ...options };
1132
+ const md = new import_remarkable.Remarkable({
1133
+ breaks: true,
1134
+ html: true,
1135
+ langPrefix: "lang-",
1136
+ typographer: false,
1137
+ xhtmlOut: false
1138
+ });
1139
+ const filepath = import_node_path4.default.resolve(options_.cwd, input);
1140
+ let string_ = input;
1141
+ if (import_node_fs3.default.existsSync(filepath)) {
1142
+ string_ = import_node_fs3.default.readFileSync(filepath, "utf8");
1143
+ }
1144
+ return new import_handlebars.default.SafeString(import_ent.default.decode(md.render(string_)));
1145
+ };
1146
+ var helpers13 = [
1147
+ {
1148
+ name: "md",
1149
+ category: "markdown",
1150
+ compatibility: ["nodejs"],
1151
+ fn: renderMarkdown
1152
+ }
1153
+ ];
1154
+
1155
+ // src/helpers/misc.ts
1156
+ var import_get_value2 = __toESM(require("get-value"), 1);
1157
+ var import_handlebars_helper_create_frame = __toESM(require("handlebars-helper-create-frame"), 1);
1158
+ var import_handlebars_utils = __toESM(require("handlebars-utils"), 1);
1159
+ var import_kind_of = __toESM(require("kind-of"), 1);
1160
+ var frame = import_handlebars_helper_create_frame.default;
1161
+ function option(prop, locals, options) {
1162
+ return (0, import_get_value2.default)(import_handlebars_utils.default.options(this, locals, options), prop);
1163
+ }
1164
+ function noop(options) {
1165
+ return options.fn(this);
1166
+ }
1167
+ var typeOf = import_kind_of.default;
1168
+ function withHash(options) {
1169
+ if (options.hash && Object.keys(options.hash).length) {
1170
+ return options.fn(options.hash);
1171
+ }
1172
+ return options.inverse(this);
1173
+ }
1174
+ var helpers14 = [
1175
+ {
1176
+ name: "frame",
1177
+ category: "misc",
1178
+ compatibility: ["browser", "nodejs"],
1179
+ fn: frame
1180
+ },
1181
+ {
1182
+ name: "option",
1183
+ category: "misc",
1184
+ compatibility: ["browser", "nodejs"],
1185
+ fn: option
1186
+ },
1187
+ {
1188
+ name: "noop",
1189
+ category: "misc",
1190
+ compatibility: ["browser", "nodejs"],
1191
+ fn: noop
1192
+ },
1193
+ {
1194
+ name: "typeOf",
1195
+ category: "misc",
1196
+ compatibility: ["browser", "nodejs"],
1197
+ fn: typeOf
1198
+ },
1199
+ {
1200
+ name: "withHash",
1201
+ category: "misc",
1202
+ compatibility: ["browser", "nodejs"],
1203
+ fn: withHash
1204
+ }
1205
+ ];
1206
+
1207
+ // src/helpers/number.ts
1208
+ var isNumeric2 = (value) => typeof value === "number" && !Number.isNaN(value);
1209
+ var bytes = (value, precision) => {
1210
+ if (value == null) return "0 B";
1211
+ let num;
1212
+ if (typeof value === "string") {
1213
+ num = value.length;
1214
+ if (!num) return "0 B";
1215
+ } else if (isNumeric2(value)) {
1216
+ num = Number(value);
1217
+ } else if (typeof value.length === "number") {
1218
+ num = value.length;
1219
+ if (!num) return "0 B";
1220
+ } else {
1221
+ return "0 B";
1222
+ }
1223
+ const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 2;
1224
+ const abbr = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
1225
+ const factor = 10 ** prec;
1226
+ for (let i = abbr.length - 1; i >= 0; i--) {
1227
+ const size = 10 ** (i * 3);
1228
+ if (size <= num + 1) {
1229
+ const val = Math.round(num * factor / size) / factor;
1230
+ return `${val} ${abbr[i]}`;
1231
+ }
1232
+ }
1233
+ return `${num}`;
1234
+ };
1235
+ var addCommas = (num) => num.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
1236
+ var phoneNumber = (num) => {
1237
+ const str = num.toString();
1238
+ return `(${str.substr(0, 3)}) ${str.substr(3, 3)}-${str.substr(6, 4)}`;
1239
+ };
1240
+ var toAbbr = (value, precision) => {
1241
+ const num = isNumeric2(value) ? Number(value) : 0;
1242
+ const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 2;
1243
+ const factor = 10 ** prec;
1244
+ const abbr = ["k", "m", "b", "t", "q"];
1245
+ for (let i = abbr.length - 1; i >= 0; i--) {
1246
+ const size = 10 ** ((i + 1) * 3);
1247
+ if (size <= num + 1) {
1248
+ const val = Math.round(num * factor / size) / factor;
1249
+ return `${val}${abbr[i]}`;
1250
+ }
1251
+ }
1252
+ return `${num}`;
1253
+ };
1254
+ var toExponential = (value, digits) => {
1255
+ const num = isNumeric2(value) ? Number(value) : 0;
1256
+ const d = typeof digits === "number" && !Number.isNaN(digits) ? digits : 0;
1257
+ return Number(num).toExponential(d);
1258
+ };
1259
+ var toFixed = (value, digits) => {
1260
+ const num = isNumeric2(value) ? Number(value) : 0;
1261
+ const d = typeof digits === "number" && !Number.isNaN(digits) ? digits : 0;
1262
+ return Number(num).toFixed(d);
1263
+ };
1264
+ var toFloat = (value) => parseFloat(String(value));
1265
+ var toInt = (value) => parseInt(String(value), 10);
1266
+ var toPrecision = (value, precision) => {
1267
+ const num = isNumeric2(value) ? Number(value) : 0;
1268
+ const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 1;
1269
+ return Number(num).toPrecision(prec);
1270
+ };
1271
+ var helpers15 = [
1272
+ {
1273
+ name: "bytes",
1274
+ category: "number",
1275
+ compatibility: ["browser", "nodejs"],
1276
+ fn: bytes
1277
+ },
1278
+ {
1279
+ name: "addCommas",
1280
+ category: "number",
1281
+ compatibility: ["browser", "nodejs"],
1282
+ fn: addCommas
1283
+ },
1284
+ {
1285
+ name: "phoneNumber",
1286
+ category: "number",
1287
+ compatibility: ["browser", "nodejs"],
1288
+ fn: phoneNumber
1289
+ },
1290
+ {
1291
+ name: "toAbbr",
1292
+ category: "number",
1293
+ compatibility: ["browser", "nodejs"],
1294
+ fn: toAbbr
1295
+ },
1296
+ {
1297
+ name: "toExponential",
1298
+ category: "number",
1299
+ compatibility: ["browser", "nodejs"],
1300
+ fn: toExponential
1301
+ },
1302
+ {
1303
+ name: "toFixed",
1304
+ category: "number",
1305
+ compatibility: ["browser", "nodejs"],
1306
+ fn: toFixed
1307
+ },
1308
+ {
1309
+ name: "toFloat",
1310
+ category: "number",
1311
+ compatibility: ["browser", "nodejs"],
1312
+ fn: toFloat
1313
+ },
1314
+ {
1315
+ name: "toInt",
1316
+ category: "number",
1317
+ compatibility: ["browser", "nodejs"],
1318
+ fn: toInt
1319
+ },
1320
+ {
1321
+ name: "toPrecision",
1322
+ category: "number",
1323
+ compatibility: ["browser", "nodejs"],
1324
+ fn: toPrecision
1325
+ }
1326
+ ];
1327
+
1328
+ // src/helpers/object.ts
1329
+ var import_get_object = __toESM(require("get-object"), 1);
1330
+ var import_get_value3 = __toESM(require("get-value"), 1);
1331
+ var isOptions2 = (value) => {
1332
+ return Boolean(value && typeof value === "object" && "hash" in value);
1333
+ };
1334
+ var createFrame2 = (options, hash) => ({
1335
+ ...options?.data || {},
1336
+ ...hash
1337
+ });
1338
+ var extend = (...objects) => {
1339
+ const args = [...objects];
1340
+ if (args.length && isOptions2(args[args.length - 1])) {
1341
+ const opts = args.pop();
1342
+ args.push(opts.hash);
1343
+ }
1344
+ const result = {};
1345
+ for (const obj of args) {
1346
+ if (obj && typeof obj === "object" && !Array.isArray(obj)) {
1347
+ Object.assign(result, obj);
1348
+ }
1349
+ }
1350
+ return result;
1351
+ };
1352
+ var forIn = (obj, options) => {
1353
+ if (!isOptions2(options)) {
1354
+ return options?.inverse?.(obj) ?? "";
1355
+ }
1356
+ const data = createFrame2(options, options.hash || {});
1357
+ let result = "";
1358
+ for (const key in obj) {
1359
+ data.key = key;
1360
+ result += options.fn(obj[key], { data });
1361
+ }
1362
+ return result;
1363
+ };
1364
+ var forOwn = (obj, options) => {
1365
+ if (!isOptions2(options)) {
1366
+ return options?.inverse?.(obj) ?? "";
1367
+ }
1368
+ const data = createFrame2(options, options.hash || {});
1369
+ let result = "";
1370
+ for (const key in obj) {
1371
+ if (Object.hasOwn(obj, key)) {
1372
+ data.key = key;
1373
+ result += options.fn(obj[key], { data });
1374
+ }
1375
+ }
1376
+ return result;
1377
+ };
1378
+ var toPath = (...prop) => {
1379
+ const parts = [];
1380
+ for (const p of prop) {
1381
+ if (typeof p === "string" || typeof p === "number") {
1382
+ parts.push(p);
1383
+ }
1384
+ }
1385
+ return parts.join(".");
1386
+ };
1387
+ var getHelper = (prop, context, options) => {
1388
+ const val = (0, import_get_value3.default)(context, prop);
1389
+ if (options && typeof options.fn === "function") {
1390
+ return val ? options.fn(val) : options.inverse?.(context);
1391
+ }
1392
+ return val;
1393
+ };
1394
+ var getObjectHelper = (prop, context) => {
1395
+ return (0, import_get_object.default)(context, prop);
1396
+ };
1397
+ var hasOwn = (context, key) => {
1398
+ return Object.hasOwn(context, key);
1399
+ };
1400
+ var isObject = (value) => {
1401
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1402
+ };
1403
+ var JSONparse = (str) => {
1404
+ return JSON.parse(str);
1405
+ };
1406
+ var JSONstringify = (obj, indent) => {
1407
+ const ind = typeof indent === "number" ? indent : 0;
1408
+ return JSON.stringify(obj, null, ind);
1409
+ };
1410
+ var merge = (context, ...objects) => {
1411
+ const args = [context, ...objects];
1412
+ if (args.length && isOptions2(args[args.length - 1])) {
1413
+ const opts = args.pop();
1414
+ args.push(opts.hash);
1415
+ }
1416
+ return Object.assign(...args);
1417
+ };
1418
+ var parseJSON = JSONparse;
1419
+ var stringify = JSONstringify;
1420
+ var pick = (props, context, options) => {
1421
+ const keys = arrayify(props);
1422
+ let result = {};
1423
+ for (const key of keys) {
1424
+ result = Object.assign({}, result, (0, import_get_object.default)(context, key));
1425
+ }
1426
+ if (options && typeof options.fn === "function") {
1427
+ if (Object.keys(result).length) {
1428
+ return options.fn(result);
1429
+ }
1430
+ return options.inverse?.(context);
1431
+ }
1432
+ return result;
1433
+ };
1434
+ var helpers16 = [
1435
+ {
1436
+ name: "extend",
1437
+ category: "object",
1438
+ compatibility: ["browser", "nodejs"],
1439
+ fn: extend
1440
+ },
1441
+ {
1442
+ name: "forIn",
1443
+ category: "object",
1444
+ compatibility: ["browser", "nodejs"],
1445
+ fn: forIn
1446
+ },
1447
+ {
1448
+ name: "forOwn",
1449
+ category: "object",
1450
+ compatibility: ["browser", "nodejs"],
1451
+ fn: forOwn
1452
+ },
1453
+ {
1454
+ name: "toPath",
1455
+ category: "object",
1456
+ compatibility: ["browser", "nodejs"],
1457
+ fn: toPath
1458
+ },
1459
+ {
1460
+ name: "get",
1461
+ category: "object",
1462
+ compatibility: ["browser", "nodejs"],
1463
+ fn: getHelper
1464
+ },
1465
+ {
1466
+ name: "getObject",
1467
+ category: "object",
1468
+ compatibility: ["browser", "nodejs"],
1469
+ fn: getObjectHelper
1470
+ },
1471
+ {
1472
+ name: "hasOwn",
1473
+ category: "object",
1474
+ compatibility: ["browser", "nodejs"],
1475
+ fn: hasOwn
1476
+ },
1477
+ {
1478
+ name: "isObject",
1479
+ category: "object",
1480
+ compatibility: ["browser", "nodejs"],
1481
+ fn: isObject
1482
+ },
1483
+ {
1484
+ name: "JSONparse",
1485
+ category: "object",
1486
+ compatibility: ["browser", "nodejs"],
1487
+ fn: JSONparse
1488
+ },
1489
+ {
1490
+ name: "JSONstringify",
1491
+ category: "object",
1492
+ compatibility: ["browser", "nodejs"],
1493
+ fn: JSONstringify
1494
+ },
1495
+ {
1496
+ name: "merge",
1497
+ category: "object",
1498
+ compatibility: ["browser", "nodejs"],
1499
+ fn: merge
1500
+ },
1501
+ {
1502
+ name: "parseJSON",
1503
+ category: "object",
1504
+ compatibility: ["browser", "nodejs"],
1505
+ fn: parseJSON
1506
+ },
1507
+ {
1508
+ name: "pick",
1509
+ category: "object",
1510
+ compatibility: ["browser", "nodejs"],
1511
+ fn: pick
1512
+ },
1513
+ {
1514
+ name: "stringify",
1515
+ category: "object",
1516
+ compatibility: ["browser", "nodejs"],
1517
+ fn: stringify
1518
+ }
1519
+ ];
1520
+
1521
+ // src/helpers/path.ts
1522
+ var import_node_path5 = __toESM(require("path"), 1);
1523
+ var expectedType = (variableName, expectedType2, variableValue) => {
1524
+ const actualType = Object.prototype.toString.call(variableValue).slice(8, -1).toLowerCase();
1525
+ return `Expected ${variableName} to be of type ${expectedType2}, but got ${actualType}`;
1526
+ };
1527
+ var assertString = (name, value) => {
1528
+ if (typeof value !== "string") {
1529
+ throw new TypeError(expectedType(name, "string", value));
1530
+ }
1531
+ return value;
1532
+ };
1533
+ var absolute = function(filepath, options) {
1534
+ const fp = assertString("filepath", filepath);
1535
+ const cwd = options?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
1536
+ return import_node_path5.default.resolve(cwd, fp);
1537
+ };
1538
+ var dirname = (filepath) => {
1539
+ const fp = assertString("filepath", filepath);
1540
+ return import_node_path5.default.dirname(fp);
1541
+ };
1542
+ var relative = (a, b) => {
1543
+ const from = assertString("first path", a);
1544
+ const to = assertString("second path", b);
1545
+ return import_node_path5.default.relative(import_node_path5.default.dirname(from), to);
1546
+ };
1547
+ var basename = (filepath) => {
1548
+ const fp = assertString("filepath", filepath);
1549
+ return import_node_path5.default.basename(fp);
1550
+ };
1551
+ var stem = (filepath) => {
1552
+ const fp = assertString("filepath", filepath);
1553
+ return import_node_path5.default.basename(fp, import_node_path5.default.extname(fp));
1554
+ };
1555
+ var extname = (filepath) => {
1556
+ const fp = assertString("filepath", filepath);
1557
+ return import_node_path5.default.extname(fp);
1558
+ };
1559
+ var resolveFn = function(filepath, ...paths) {
1560
+ let options;
1561
+ const last2 = paths[paths.length - 1];
1562
+ if (typeof last2 === "object" && last2 && "data" in last2) {
1563
+ options = paths.pop();
1564
+ }
1565
+ const cwd = options?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
1566
+ const all2 = [
1567
+ cwd,
1568
+ assertString("filepath", filepath),
1569
+ ...paths.map((p, i) => assertString(`path${i}`, p))
1570
+ ];
1571
+ return import_node_path5.default.resolve(...all2);
1572
+ };
1573
+ var segments = (filepath, a, b) => {
1574
+ const fp = assertString("filepath", filepath);
1575
+ const start = Number(a);
1576
+ const end = Number(b);
1577
+ const segmentsArr = fp.split(/[\\/]+/);
1578
+ return segmentsArr.slice(start, end).join("/");
1579
+ };
1580
+ var helpers17 = [
1581
+ {
1582
+ name: "absolute",
1583
+ category: "path",
1584
+ compatibility: ["nodejs"],
1585
+ fn: absolute
1586
+ },
1587
+ {
1588
+ name: "dirname",
1589
+ category: "path",
1590
+ compatibility: ["nodejs"],
1591
+ fn: dirname
1592
+ },
1593
+ {
1594
+ name: "relative",
1595
+ category: "path",
1596
+ compatibility: ["nodejs"],
1597
+ fn: relative
1598
+ },
1599
+ {
1600
+ name: "basename",
1601
+ category: "path",
1602
+ compatibility: ["nodejs"],
1603
+ fn: basename
1604
+ },
1605
+ {
1606
+ name: "stem",
1607
+ category: "path",
1608
+ compatibility: ["nodejs"],
1609
+ fn: stem
1610
+ },
1611
+ {
1612
+ name: "extname",
1613
+ category: "path",
1614
+ compatibility: ["nodejs"],
1615
+ fn: extname
1616
+ },
1617
+ {
1618
+ name: "resolve",
1619
+ category: "path",
1620
+ compatibility: ["nodejs"],
1621
+ fn: resolveFn
1622
+ },
1623
+ {
1624
+ name: "segments",
1625
+ category: "path",
1626
+ compatibility: ["nodejs"],
1627
+ fn: segments
1628
+ }
1629
+ ];
1630
+
1631
+ // src/helpers/regex.ts
1632
+ var import_handlebars_utils2 = __toESM(require("handlebars-utils"), 1);
1633
+ var toRegex = (str, locals, options) => {
1634
+ const opts = import_handlebars_utils2.default.options({}, locals, options);
1635
+ return new RegExp(str, opts.flags);
1636
+ };
1637
+ var test = (str, regex) => {
1638
+ if (typeof str !== "string") {
1639
+ return false;
1640
+ }
1641
+ if (!(regex instanceof RegExp)) {
1642
+ throw new TypeError("expected a regular expression");
1643
+ }
1644
+ return regex.test(str);
1645
+ };
1646
+ var helpers18 = [
1647
+ {
1648
+ name: "toRegex",
1649
+ category: "regex",
1650
+ compatibility: ["browser", "nodejs"],
1651
+ fn: toRegex
1652
+ },
1653
+ {
1654
+ name: "test",
1655
+ category: "regex",
1656
+ compatibility: ["browser", "nodejs"],
1657
+ fn: test
1658
+ }
1659
+ ];
1660
+
1661
+ // src/helpers/string.ts
1662
+ var chop = (str) => str.trim().replace(/^[-_.\W\s]+|[-_.\W\s]+$/g, "");
1663
+ var changecase = (str, fn) => {
1664
+ if (str.length === 1) return str.toLowerCase();
1665
+ const res = chop(str).toLowerCase();
1666
+ return res.replace(/[-_.\W\s]+(\w|$)/g, (_, ch) => fn(ch));
1667
+ };
1668
+ var append = (str, suffix) => {
1669
+ if (typeof str === "string" && typeof suffix === "string") {
1670
+ return str + suffix;
1671
+ }
1672
+ return str;
1673
+ };
1674
+ var camelcase = (str) => typeof str === "string" ? changecase(str, (ch) => ch.toUpperCase()) : "";
1675
+ var capitalize = (str) => {
1676
+ if (typeof str !== "string" || str.length === 0) return "";
1677
+ return str.charAt(0).toUpperCase() + str.slice(1);
1678
+ };
1679
+ var capitalizeAll = (str) => {
1680
+ if (typeof str !== "string") return "";
1681
+ return str.replace(/\w\S*/g, (word) => capitalize(word));
1682
+ };
1683
+ var center = (str, spaces) => {
1684
+ if (typeof str !== "string") return "";
1685
+ let space = "";
1686
+ for (let i = 0; i < spaces; i++) {
1687
+ space += "&nbsp;";
1688
+ }
1689
+ return space + str + space;
1690
+ };
1691
+ var chopStr = (str) => typeof str === "string" ? chop(str) : "";
1692
+ var dashcase = (str) => typeof str === "string" ? changecase(str, (ch) => `-${ch}`) : "";
1693
+ var dotcase = (str) => typeof str === "string" ? changecase(str, (ch) => `.${ch}`) : "";
1694
+ var truncate = (str, limit, suffix) => {
1695
+ if (typeof str === "string") {
1696
+ if (typeof suffix !== "string") {
1697
+ suffix = "";
1698
+ }
1699
+ if (str.length > limit) {
1700
+ return str.slice(0, limit - suffix.length) + suffix;
1701
+ }
1702
+ return str;
1703
+ }
1704
+ return "";
1705
+ };
1706
+ var ellipsis = (str, limit) => {
1707
+ if (typeof str === "string") {
1708
+ if (str.length <= limit) {
1709
+ return str;
1710
+ }
1711
+ return `${truncate(str, limit)}\u2026`;
1712
+ }
1713
+ return "";
1714
+ };
1715
+ var hyphenate = (str) => typeof str === "string" ? str.split(" ").join("-") : "";
1716
+ var isString = (value) => typeof value === "string";
1717
+ var lowercase = (str) => {
1718
+ if (typeof str === "object" && str !== null && "fn" in str && typeof str.fn === "function") {
1719
+ return String(str.fn()).toLowerCase();
1720
+ }
1721
+ if (typeof str !== "string") return "";
1722
+ return str.toLowerCase();
1723
+ };
1724
+ var downcase = (...args) => lowercase(...args);
1725
+ var occurrences = (str, substring) => {
1726
+ if (typeof str !== "string") return "";
1727
+ const len = substring.length;
1728
+ let pos = str.indexOf(substring, 0);
1729
+ let n = 0;
1730
+ while (pos > -1) {
1731
+ n++;
1732
+ pos = str.indexOf(substring, pos + len);
1733
+ }
1734
+ return n;
1735
+ };
1736
+ var pascalcase = (str) => {
1737
+ if (typeof str !== "string") return "";
1738
+ const res = changecase(str, (ch) => ch.toUpperCase());
1739
+ return res.charAt(0).toUpperCase() + res.slice(1);
1740
+ };
1741
+ var pathcase = (str) => typeof str === "string" ? changecase(str, (ch) => `/${ch}`) : "";
1742
+ var plusify = (str, ch) => {
1743
+ if (typeof str !== "string") return "";
1744
+ if (typeof ch !== "string") ch = " ";
1745
+ return str.split(ch).join("+");
1746
+ };
1747
+ var prepend = (str, prefix) => {
1748
+ return typeof str === "string" && typeof prefix === "string" ? prefix + str : str;
1749
+ };
1750
+ var remove = (str, ch) => {
1751
+ if (typeof str !== "string") return "";
1752
+ if (typeof ch !== "string") return str;
1753
+ return str.split(ch).join("");
1754
+ };
1755
+ var removeFirst = (str, ch) => {
1756
+ if (typeof str !== "string") return "";
1757
+ if (typeof ch !== "string") return str;
1758
+ return str.replace(ch, "");
1759
+ };
1760
+ var replace = (str, a, b) => {
1761
+ if (typeof str !== "string") return "";
1762
+ if (typeof a !== "string") return str;
1763
+ if (typeof b !== "string") b = "";
1764
+ return str.split(a).join(b);
1765
+ };
1766
+ var replaceFirst = (str, a, b) => {
1767
+ if (typeof str !== "string") return "";
1768
+ if (typeof a !== "string") return str;
1769
+ if (typeof b !== "string") b = "";
1770
+ return str.replace(a, b);
1771
+ };
1772
+ var reverse = (str) => typeof str === "string" ? str.split("").reverse().join("") : "";
1773
+ var sentence = (str) => {
1774
+ if (typeof str !== "string") return "";
1775
+ return str.replace(
1776
+ /((?:\S[^.?!]*)[.?!]*)/g,
1777
+ (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()
1778
+ );
1779
+ };
1780
+ var snakecase = (str) => typeof str === "string" ? changecase(str, (ch) => `_${ch}`) : "";
1781
+ var trim = (str) => typeof str === "string" ? str.trim() : "";
1782
+ var trimLeft = (str) => typeof str === "string" ? str.replace(/^\s+/, "") : "";
1783
+ var trimRight = (str) => typeof str === "string" ? str.replace(/\s+$/, "") : "";
1784
+ var truncateWords = (str, count, suffix) => {
1785
+ if (typeof str === "string" && typeof count === "number" && Number.isFinite(count)) {
1786
+ if (typeof suffix !== "string") {
1787
+ suffix = "...";
1788
+ }
1789
+ const num = Math.trunc(count);
1790
+ let arr = str.split(" ");
1791
+ if (num < arr.length) {
1792
+ arr = arr.slice(0, num);
1793
+ }
1794
+ const val = arr.join(" ").trim();
1795
+ return val + suffix;
1796
+ }
1797
+ return "";
1798
+ };
1799
+ var truncateWordsAlias = truncateWords;
1800
+ var uppercase = (str) => {
1801
+ if (typeof str === "object" && str !== null && "fn" in str && typeof str.fn === "function") {
1802
+ return String(str.fn()).toUpperCase();
1803
+ }
1804
+ if (typeof str !== "string") return "";
1805
+ return str.toUpperCase();
1806
+ };
1807
+ var upcase = (...args) => uppercase(...args);
1808
+ var helpers19 = [
1809
+ {
1810
+ name: "append",
1811
+ category: "string",
1812
+ compatibility: ["browser", "nodejs"],
1813
+ fn: append
1814
+ },
1815
+ {
1816
+ name: "camelcase",
1817
+ category: "string",
1818
+ compatibility: ["browser", "nodejs"],
1819
+ fn: camelcase
1820
+ },
1821
+ {
1822
+ name: "capitalize",
1823
+ category: "string",
1824
+ compatibility: ["browser", "nodejs"],
1825
+ fn: capitalize
1826
+ },
1827
+ {
1828
+ name: "capitalizeAll",
1829
+ category: "string",
1830
+ compatibility: ["browser", "nodejs"],
1831
+ fn: capitalizeAll
1832
+ },
1833
+ {
1834
+ name: "center",
1835
+ category: "string",
1836
+ compatibility: ["browser", "nodejs"],
1837
+ fn: center
1838
+ },
1839
+ {
1840
+ name: "chop",
1841
+ category: "string",
1842
+ compatibility: ["browser", "nodejs"],
1843
+ fn: chopStr
1844
+ },
1845
+ {
1846
+ name: "dashcase",
1847
+ category: "string",
1848
+ compatibility: ["browser", "nodejs"],
1849
+ fn: dashcase
1850
+ },
1851
+ {
1852
+ name: "dotcase",
1853
+ category: "string",
1854
+ compatibility: ["browser", "nodejs"],
1855
+ fn: dotcase
1856
+ },
1857
+ {
1858
+ name: "ellipsis",
1859
+ category: "string",
1860
+ compatibility: ["browser", "nodejs"],
1861
+ fn: ellipsis
1862
+ },
1863
+ {
1864
+ name: "hyphenate",
1865
+ category: "string",
1866
+ compatibility: ["browser", "nodejs"],
1867
+ fn: hyphenate
1868
+ },
1869
+ {
1870
+ name: "isString",
1871
+ category: "string",
1872
+ compatibility: ["browser", "nodejs"],
1873
+ fn: isString
1874
+ },
1875
+ {
1876
+ name: "lowercase",
1877
+ category: "string",
1878
+ compatibility: ["browser", "nodejs"],
1879
+ fn: lowercase
1880
+ },
1881
+ {
1882
+ name: "downcase",
1883
+ category: "string",
1884
+ compatibility: ["browser", "nodejs"],
1885
+ fn: downcase
1886
+ },
1887
+ {
1888
+ name: "occurrences",
1889
+ category: "string",
1890
+ compatibility: ["browser", "nodejs"],
1891
+ fn: occurrences
1892
+ },
1893
+ {
1894
+ name: "pascalcase",
1895
+ category: "string",
1896
+ compatibility: ["browser", "nodejs"],
1897
+ fn: pascalcase
1898
+ },
1899
+ {
1900
+ name: "pathcase",
1901
+ category: "string",
1902
+ compatibility: ["browser", "nodejs"],
1903
+ fn: pathcase
1904
+ },
1905
+ {
1906
+ name: "plusify",
1907
+ category: "string",
1908
+ compatibility: ["browser", "nodejs"],
1909
+ fn: plusify
1910
+ },
1911
+ {
1912
+ name: "prepend",
1913
+ category: "string",
1914
+ compatibility: ["browser", "nodejs"],
1915
+ fn: prepend
1916
+ },
1917
+ {
1918
+ name: "remove",
1919
+ category: "string",
1920
+ compatibility: ["browser", "nodejs"],
1921
+ fn: remove
1922
+ },
1923
+ {
1924
+ name: "removeFirst",
1925
+ category: "string",
1926
+ compatibility: ["browser", "nodejs"],
1927
+ fn: removeFirst
1928
+ },
1929
+ {
1930
+ name: "replace",
1931
+ category: "string",
1932
+ compatibility: ["browser", "nodejs"],
1933
+ fn: replace
1934
+ },
1935
+ {
1936
+ name: "replaceFirst",
1937
+ category: "string",
1938
+ compatibility: ["browser", "nodejs"],
1939
+ fn: replaceFirst
1940
+ },
1941
+ {
1942
+ name: "reverse",
1943
+ category: "string",
1944
+ compatibility: ["browser", "nodejs"],
1945
+ fn: reverse
1946
+ },
1947
+ {
1948
+ name: "sentence",
1949
+ category: "string",
1950
+ compatibility: ["browser", "nodejs"],
1951
+ fn: sentence
1952
+ },
1953
+ {
1954
+ name: "snakecase",
1955
+ category: "string",
1956
+ compatibility: ["browser", "nodejs"],
1957
+ fn: snakecase
1958
+ },
1959
+ {
1960
+ name: "trim",
1961
+ category: "string",
1962
+ compatibility: ["browser", "nodejs"],
1963
+ fn: trim
1964
+ },
1965
+ {
1966
+ name: "trimLeft",
1967
+ category: "string",
1968
+ compatibility: ["browser", "nodejs"],
1969
+ fn: trimLeft
1970
+ },
1971
+ {
1972
+ name: "trimRight",
1973
+ category: "string",
1974
+ compatibility: ["browser", "nodejs"],
1975
+ fn: trimRight
1976
+ },
1977
+ {
1978
+ name: "truncate",
1979
+ category: "string",
1980
+ compatibility: ["browser", "nodejs"],
1981
+ fn: truncate
1982
+ },
1983
+ {
1984
+ name: "truncateWords",
1985
+ category: "string",
1986
+ compatibility: ["browser", "nodejs"],
1987
+ fn: truncateWordsAlias
1988
+ },
1989
+ {
1990
+ name: "uppercase",
1991
+ category: "string",
1992
+ compatibility: ["browser", "nodejs"],
1993
+ fn: uppercase
1994
+ },
1995
+ {
1996
+ name: "upcase",
1997
+ category: "string",
1998
+ compatibility: ["browser", "nodejs"],
1999
+ fn: upcase
2000
+ }
2001
+ ];
2002
+
2003
+ // src/helpers/url.ts
2004
+ var import_node_querystring = require("querystring");
2005
+ var import_node_url = require("url");
2006
+ var all = ["browser", "nodejs"];
2007
+ var encodeUri = (str) => {
2008
+ if (typeof str === "string") {
2009
+ return encodeURIComponent(str);
2010
+ }
2011
+ };
2012
+ var escapeFn = (str) => {
2013
+ if (typeof str === "string") {
2014
+ return (0, import_node_querystring.escape)(str);
2015
+ }
2016
+ };
2017
+ var decodeUri = (str) => {
2018
+ if (typeof str === "string") {
2019
+ return decodeURIComponent(str);
2020
+ }
2021
+ };
2022
+ function urlEncode(...args) {
2023
+ return encodeUri.apply(this, args);
2024
+ }
2025
+ function urlDecode(...args) {
2026
+ return decodeUri.apply(this, args);
2027
+ }
2028
+ var urlResolve = (base, href) => (0, import_node_url.resolve)(String(base), String(href));
2029
+ var urlParse = (str) => (0, import_node_url.parse)(String(str));
2030
+ var stripQuerystring = (str) => {
2031
+ if (typeof str === "string") {
2032
+ return str.split("?")[0];
2033
+ }
2034
+ };
2035
+ var stripProtocol = (str) => {
2036
+ if (typeof str === "string") {
2037
+ const parsed = (0, import_node_url.parse)(str);
2038
+ parsed.protocol = "";
2039
+ return (0, import_node_url.format)(parsed);
2040
+ }
2041
+ };
2042
+ var helpers20 = [
2043
+ {
2044
+ name: "encodeURI",
2045
+ category: "url",
2046
+ compatibility: all,
2047
+ fn: encodeUri
2048
+ },
2049
+ {
2050
+ name: "escape",
2051
+ category: "url",
2052
+ compatibility: ["nodejs"],
2053
+ fn: escapeFn
2054
+ },
2055
+ {
2056
+ name: "decodeURI",
2057
+ category: "url",
2058
+ compatibility: all,
2059
+ fn: decodeUri
2060
+ },
2061
+ {
2062
+ name: "url_encode",
2063
+ category: "url",
2064
+ compatibility: all,
2065
+ fn: urlEncode
2066
+ },
2067
+ {
2068
+ name: "url_decode",
2069
+ category: "url",
2070
+ compatibility: all,
2071
+ fn: urlDecode
2072
+ },
2073
+ {
2074
+ name: "urlResolve",
2075
+ category: "url",
2076
+ compatibility: ["nodejs"],
2077
+ fn: urlResolve
2078
+ },
2079
+ {
2080
+ name: "urlParse",
2081
+ category: "url",
2082
+ compatibility: ["nodejs"],
2083
+ fn: urlParse
2084
+ },
2085
+ {
2086
+ name: "stripQuerystring",
2087
+ category: "url",
2088
+ compatibility: all,
2089
+ fn: stripQuerystring
2090
+ },
2091
+ {
2092
+ name: "stripProtocol",
2093
+ category: "url",
2094
+ compatibility: ["nodejs"],
2095
+ fn: stripProtocol
2096
+ }
2097
+ ];
2098
+
2099
+ // src/helper-registry.ts
2100
+ var HelperRegistry = class {
2101
+ _helpers = [];
2102
+ constructor() {
2103
+ this.init();
2104
+ }
2105
+ /**
2106
+ * Get all registered helpers.
2107
+ * @returns {Helper[]} The array of registered helpers.
2108
+ */
2109
+ get helpers() {
2110
+ return this._helpers;
2111
+ }
2112
+ /**
2113
+ * Initialize the helper registry. This is performed during the construction of the registry such as new HelperRegistry().
2114
+ */
2115
+ init() {
2116
+ this.registerHelpers(helpers);
2117
+ this.registerHelpers(helpers3);
2118
+ this.registerHelpers(helpers5);
2119
+ this.registerHelpers(helpers6);
2120
+ this.registerHelpers(helpers2);
2121
+ this.registerHelpers(helpers13);
2122
+ this.registerHelpers(helpers7);
2123
+ this.registerHelpers(helpers4);
2124
+ this.registerHelpers(helpers8);
2125
+ this.registerHelpers(helpers9);
2126
+ this.registerHelpers(helpers10);
2127
+ this.registerHelpers(helpers11);
2128
+ this.registerHelpers(helpers12);
2129
+ this.registerHelpers(helpers14);
2130
+ this.registerHelpers(helpers15);
2131
+ this.registerHelpers(helpers17);
2132
+ this.registerHelpers(helpers18);
2133
+ this.registerHelpers(helpers19);
2134
+ this.registerHelpers(helpers20);
2135
+ this.registerHelpers(helpers16);
2136
+ }
2137
+ /**
2138
+ * Register a helper.
2139
+ * @param {Helper} helper The helper to register.
2140
+ * @returns True if the helper was registered, false otherwise.
2141
+ */
2142
+ register(helper) {
2143
+ const result = false;
2144
+ if (!this.has(helper.name)) {
2145
+ this._helpers.push(helper);
2146
+ }
2147
+ return result;
2148
+ }
2149
+ /**
2150
+ * Register multiple helpers.
2151
+ * @param {Helper[]} helpers The array of helpers to register.
2152
+ */
2153
+ registerHelpers(helpers22) {
2154
+ for (const helper of helpers22) {
2155
+ this.register(helper);
2156
+ }
2157
+ }
2158
+ /**
2159
+ * Check if a helper is registered.
2160
+ * @param name The name of the helper.
2161
+ * @returns True if the helper is registered, false otherwise.
2162
+ */
2163
+ has(name) {
2164
+ return this._helpers.some((helper) => helper.name === name);
2165
+ }
2166
+ /**
2167
+ * Filter helpers by the given criteria.
2168
+ * @param filter The filter criteria.
2169
+ * @returns The filtered helpers.
2170
+ */
2171
+ filter(filter) {
2172
+ let result = this._helpers;
2173
+ if (filter.names) {
2174
+ result = result.filter((helper) => filter.names?.includes(helper.name));
2175
+ }
2176
+ if (filter.categories) {
2177
+ result = result.filter(
2178
+ (helper) => filter.categories?.includes(helper.category)
2179
+ );
2180
+ }
2181
+ if (filter.compatibility) {
2182
+ result = result.filter(
2183
+ (helper) => helper.compatibility?.some((c) => filter.compatibility?.includes(c))
2184
+ );
2185
+ }
2186
+ return result;
2187
+ }
2188
+ /**
2189
+ * Load Handlebars helpers.
2190
+ * @param {Handlebars} handlebars The Handlebars instance.
2191
+ * @returns {void}
2192
+ */
2193
+ load(handlebars2, filters) {
2194
+ let helpers22 = this._helpers;
2195
+ if (filters) {
2196
+ helpers22 = this.filter(filters);
2197
+ }
2198
+ for (const helper of helpers22) {
2199
+ handlebars2.registerHelper(helper.name, helper.fn);
2200
+ }
2201
+ }
2202
+ /**
2203
+ * Swap Handlebars helpers. This is used when you want to swap out legacy helpers for fumanchu helpers.
2204
+ * @param handlebars The Handlebars instance.
2205
+ * @returns {void}
2206
+ */
2207
+ swap(handlebars2) {
2208
+ for (const helper of this._helpers) {
2209
+ handlebars2.unregisterHelper(helper.name);
2210
+ handlebars2.registerHelper(helper.name, helper.fn);
2211
+ }
2212
+ }
2213
+ };
2214
+
2215
+ // src/index.ts
2216
+ var Handlebars2 = import_handlebars2.default;
2217
+ var handlebars = import_handlebars2.default.create();
2218
+ function helpers21(options) {
2219
+ const registry = new HelperRegistry();
2220
+ registry.load(options.handlebars ?? options.hbs);
2221
+ }
2222
+ async function createHandlebars() {
2223
+ const registry = new HelperRegistry();
2224
+ const handlebars2 = import_handlebars2.default.create();
2225
+ registry.load(handlebars2);
2226
+ if (process.env.NODE_ENV === "development") {
2227
+ console.warn(
2228
+ "createHandlebars will be deprecated in future versions, use `fumanchu` instead."
2229
+ );
2230
+ }
2231
+ return handlebars2;
2232
+ }
2233
+ function fumanchu(options) {
2234
+ const registry = new HelperRegistry();
2235
+ let handlebars2 = import_handlebars2.default.create();
2236
+ if (options?.handlebars) {
2237
+ handlebars2 = options.handlebars;
2238
+ }
2239
+ registry.load(handlebars2);
2240
+ return handlebars2;
2241
+ }
2242
+ // Annotate the CommonJS export names for ESM import in node:
2243
+ 0 && (module.exports = {
2244
+ Handlebars,
2245
+ HelperRegistry,
2246
+ createHandlebars,
2247
+ fumanchu,
2248
+ handlebars,
2249
+ helpers
2250
+ });