@jaredwray/fumanchu 4.6.0 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs DELETED
@@ -1,3209 +0,0 @@
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
- CacheableMemory: () => import_memory.CacheableMemory,
34
- Handlebars: () => Handlebars3,
35
- HelperRegistry: () => HelperRegistry,
36
- createHandlebars: () => createHandlebars,
37
- fumanchu: () => fumanchu,
38
- handlebars: () => handlebars,
39
- helpers: () => helpers21
40
- });
41
- module.exports = __toCommonJS(index_exports);
42
- var import_memory = require("@cacheable/memory");
43
- var import_handlebars3 = __toESM(require("handlebars"), 1);
44
-
45
- // src/helpers/array.ts
46
- var after = (array, n) => {
47
- if (!Array.isArray(array)) return [];
48
- return array.slice(n);
49
- };
50
- var before = (array, n) => {
51
- if (!Array.isArray(array)) return [];
52
- return array.slice(0, -n);
53
- };
54
- var arrayify = (value) => {
55
- if (value == null) return [];
56
- return Array.isArray(value) ? value : [value];
57
- };
58
- var first = (array, n) => {
59
- if (!Array.isArray(array)) return void 0;
60
- if (typeof n !== "number") {
61
- return array[0];
62
- }
63
- return array.slice(0, n);
64
- };
65
- var last = (value, n) => {
66
- if (!Array.isArray(value) && typeof value !== "string") {
67
- return void 0;
68
- }
69
- if (typeof n !== "number") {
70
- const array = value;
71
- return array[array.length - 1];
72
- }
73
- const start = Math.abs(n);
74
- if (typeof value === "string") {
75
- return value.slice(-start);
76
- }
77
- return value.slice(-start);
78
- };
79
- var length = (value) => {
80
- if (value && typeof value === "object" && !Array.isArray(value)) {
81
- return Object.keys(value).length;
82
- }
83
- if (typeof value === "string" || Array.isArray(value)) {
84
- return value.length;
85
- }
86
- return 0;
87
- };
88
- var join = (array, separator = ", ") => {
89
- if (typeof array === "string") return array;
90
- if (!Array.isArray(array)) return "";
91
- return array.join(separator);
92
- };
93
- var forEach = function(collection, options2) {
94
- if (!Array.isArray(collection) || !options2 || typeof options2.fn !== "function") {
95
- return options2?.inverse ? options2.inverse(this) ?? "" : "";
96
- }
97
- if (collection.length === 0) {
98
- return options2.inverse ? options2.inverse(this) ?? "" : "";
99
- }
100
- const total = collection.length;
101
- const hash = options2.hash ?? {};
102
- const baseData = options2.data ? { ...options2.data } : void 0;
103
- let result = "";
104
- for (let index = 0; index < total; index++) {
105
- const value = collection[index];
106
- const meta = {
107
- index,
108
- total,
109
- isFirst: index === 0,
110
- isLast: index === total - 1
111
- };
112
- const data = {
113
- ...baseData ? { ...baseData } : {},
114
- ...hash,
115
- ...meta
116
- };
117
- let context;
118
- if (value != null && typeof value === "object") {
119
- context = { ...value, ...hash, ...meta };
120
- } else {
121
- context = { value, ...hash, ...meta };
122
- }
123
- result += options2.fn(context, { data });
124
- }
125
- return result;
126
- };
127
- var inArray = function(array, value, options2) {
128
- if (!Array.isArray(array) || !options2) {
129
- return "";
130
- }
131
- const found = array.includes(value);
132
- if (found && options2.fn) {
133
- return options2.fn(this);
134
- }
135
- if (!found && options2.inverse) {
136
- return options2.inverse(this);
137
- }
138
- return "";
139
- };
140
- var isArray = (value) => {
141
- return Array.isArray(value);
142
- };
143
- var itemAt = (array, idx) => {
144
- if (!Array.isArray(array)) return void 0;
145
- return array[idx];
146
- };
147
- var equalsLength = function(value, targetLength, options2) {
148
- const actualLength = length(value);
149
- const isEqual = actualLength === targetLength;
150
- if (options2 && (options2.fn || options2.inverse)) {
151
- if (isEqual && options2.fn) {
152
- return options2.fn(this);
153
- }
154
- if (!isEqual && options2.inverse) {
155
- return options2.inverse(this);
156
- }
157
- return "";
158
- }
159
- return isEqual;
160
- };
161
- var some = function(array, iter, options2) {
162
- if (!Array.isArray(array) || typeof iter !== "function" || !options2) {
163
- return options2?.inverse ? options2.inverse(this) ?? "" : "";
164
- }
165
- const hasSome = array.some(iter);
166
- if (hasSome && options2.fn) {
167
- return options2.fn(this);
168
- }
169
- if (!hasSome && options2.inverse) {
170
- return options2.inverse(this);
171
- }
172
- return "";
173
- };
174
- var eachIndex = function(array, options2) {
175
- if (!Array.isArray(array) || !options2 || typeof options2.fn !== "function") {
176
- return options2?.inverse ? options2.inverse(this) ?? "" : "";
177
- }
178
- if (array.length === 0) {
179
- return options2.inverse ? options2.inverse(this) ?? "" : "";
180
- }
181
- let result = "";
182
- for (let index = 0; index < array.length; index++) {
183
- const context = {
184
- item: array[index],
185
- index
186
- };
187
- result += options2.fn(context);
188
- }
189
- return result;
190
- };
191
- var withAfter = function(array, idx, options2) {
192
- if (!Array.isArray(array) || !options2 || typeof options2.fn !== "function") {
193
- return "";
194
- }
195
- const sliced = array.slice(idx + 1);
196
- if (sliced.length === 0) {
197
- return options2.inverse ? options2.inverse(this) ?? "" : "";
198
- }
199
- let result = "";
200
- for (const item of sliced) {
201
- result += options2.fn(item);
202
- }
203
- return result;
204
- };
205
- var withBefore = function(array, idx, options2) {
206
- if (!Array.isArray(array) || !options2 || typeof options2.fn !== "function") {
207
- return "";
208
- }
209
- const sliced = array.slice(0, idx);
210
- if (sliced.length === 0) {
211
- return options2.inverse ? options2.inverse(this) ?? "" : "";
212
- }
213
- let result = "";
214
- for (const item of sliced) {
215
- result += options2.fn(item);
216
- }
217
- return result;
218
- };
219
- var withFirst = function(array, n, options2) {
220
- let count = 1;
221
- let opts = options2;
222
- if (typeof n === "object" && n !== null && !Array.isArray(n)) {
223
- opts = n;
224
- } else if (typeof n === "number") {
225
- count = n;
226
- }
227
- if (!Array.isArray(array) || !opts || typeof opts.fn !== "function") {
228
- return "";
229
- }
230
- if (array.length === 0) {
231
- return opts.inverse ? opts.inverse(this) ?? "" : "";
232
- }
233
- const items = array.slice(0, count);
234
- let result = "";
235
- for (const item of items) {
236
- result += opts.fn(item);
237
- }
238
- return result;
239
- };
240
- var withLast = function(array, n, options2) {
241
- let count = 1;
242
- let opts = options2;
243
- if (typeof n === "object" && n !== null && !Array.isArray(n)) {
244
- opts = n;
245
- } else if (typeof n === "number") {
246
- count = n;
247
- }
248
- if (!Array.isArray(array) || !opts || typeof opts.fn !== "function") {
249
- return "";
250
- }
251
- if (array.length === 0) {
252
- return opts.inverse ? opts.inverse(this) ?? "" : "";
253
- }
254
- const items = array.slice(-count);
255
- let result = "";
256
- for (const item of items) {
257
- result += opts.fn(item);
258
- }
259
- return result;
260
- };
261
- var withGroup = function(array, size, options2) {
262
- if (!Array.isArray(array) || typeof size !== "number" || size <= 0 || !options2 || typeof options2.fn !== "function") {
263
- return "";
264
- }
265
- if (array.length === 0) {
266
- return options2.inverse ? options2.inverse(this) ?? "" : "";
267
- }
268
- let result = "";
269
- const groups = [];
270
- for (let i = 0; i < array.length; i += size) {
271
- groups.push(array.slice(i, i + size));
272
- }
273
- for (const group of groups) {
274
- result += options2.fn(group);
275
- }
276
- return result;
277
- };
278
- var withSort = function(array, prop, options2) {
279
- let sortProp;
280
- let opts = options2;
281
- if (typeof prop === "object" && prop !== null && !Array.isArray(prop)) {
282
- opts = prop;
283
- } else if (typeof prop === "string") {
284
- sortProp = prop;
285
- }
286
- if (!Array.isArray(array) || !opts || typeof opts.fn !== "function") {
287
- return "";
288
- }
289
- if (array.length === 0) {
290
- return opts.inverse ? opts.inverse(this) ?? "" : "";
291
- }
292
- const sorted = [...array];
293
- if (sortProp) {
294
- sorted.sort((a, b) => {
295
- const aVal = a?.[sortProp];
296
- const bVal = b?.[sortProp];
297
- if (aVal === bVal) return 0;
298
- if (aVal == null) return 1;
299
- if (bVal == null) return -1;
300
- if (typeof aVal === "string" && typeof bVal === "string") {
301
- return aVal.localeCompare(bVal);
302
- }
303
- return aVal < bVal ? -1 : 1;
304
- });
305
- } else {
306
- sorted.sort((a, b) => {
307
- if (a === b) return 0;
308
- if (a == null) return 1;
309
- if (b == null) return -1;
310
- if (typeof a === "string" && typeof b === "string") {
311
- return a.localeCompare(b);
312
- }
313
- return a < b ? -1 : 1;
314
- });
315
- }
316
- const shouldReverse = opts.hash?.reverse === true || opts.hash?.reverse === "true";
317
- if (shouldReverse) {
318
- sorted.reverse();
319
- }
320
- let result = "";
321
- for (const item of sorted) {
322
- result += opts.fn(item);
323
- }
324
- return result;
325
- };
326
- var filter = function(array, value, options2) {
327
- if (!Array.isArray(array) || !options2) {
328
- return options2?.inverse ? options2.inverse(this) ?? "" : "";
329
- }
330
- const filtered = array.filter((item) => item === value);
331
- if (filtered.length > 0 && options2.fn) {
332
- return options2.fn(this);
333
- }
334
- if (filtered.length === 0 && options2.inverse) {
335
- return options2.inverse(this);
336
- }
337
- return "";
338
- };
339
- var map = (array, fn) => {
340
- if (!Array.isArray(array) || typeof fn !== "function") {
341
- return [];
342
- }
343
- return array.map(fn);
344
- };
345
- var pluck = (collection, prop) => {
346
- if (!Array.isArray(collection) || typeof prop !== "string") {
347
- return [];
348
- }
349
- return collection.map((item) => {
350
- if (item == null || typeof item !== "object") {
351
- return void 0;
352
- }
353
- const parts = prop.split(".");
354
- let value = item;
355
- for (const part of parts) {
356
- if (value == null || typeof value !== "object") {
357
- return void 0;
358
- }
359
- value = value[part];
360
- }
361
- return value;
362
- });
363
- };
364
- var reverse = (value) => {
365
- if (typeof value === "string") {
366
- return value.split("").reverse().join("");
367
- }
368
- if (Array.isArray(value)) {
369
- return [...value].reverse();
370
- }
371
- return void 0;
372
- };
373
- var sort = (array, key) => {
374
- if (!Array.isArray(array)) {
375
- return [];
376
- }
377
- const sorted = [...array];
378
- if (typeof key === "function") {
379
- sorted.sort(key);
380
- } else if (typeof key === "string") {
381
- sorted.sort((a, b) => {
382
- const aVal = a?.[key];
383
- const bVal = b?.[key];
384
- if (aVal === bVal) return 0;
385
- if (aVal == null) return 1;
386
- if (bVal == null) return -1;
387
- if (typeof aVal === "string" && typeof bVal === "string") {
388
- return aVal.localeCompare(bVal);
389
- }
390
- return aVal < bVal ? -1 : 1;
391
- });
392
- } else {
393
- sorted.sort((a, b) => {
394
- if (a === b) return 0;
395
- if (a == null) return 1;
396
- if (b == null) return -1;
397
- if (typeof a === "string" && typeof b === "string") {
398
- return a.localeCompare(b);
399
- }
400
- return a < b ? -1 : 1;
401
- });
402
- }
403
- return sorted;
404
- };
405
- var sortBy = (array, ...props) => {
406
- if (!Array.isArray(array) || props.length === 0) {
407
- return [];
408
- }
409
- const sorted = [...array];
410
- sorted.sort((a, b) => {
411
- for (const prop of props) {
412
- const aVal = a?.[prop];
413
- const bVal = b?.[prop];
414
- if (aVal === bVal) continue;
415
- if (aVal == null) return 1;
416
- if (bVal == null) return -1;
417
- if (typeof aVal === "string" && typeof bVal === "string") {
418
- const result = aVal.localeCompare(bVal);
419
- if (result !== 0) return result;
420
- } else {
421
- return aVal < bVal ? -1 : 1;
422
- }
423
- }
424
- return 0;
425
- });
426
- return sorted;
427
- };
428
- var unique = function(array, options2) {
429
- if (!Array.isArray(array)) {
430
- if (!options2) {
431
- return [];
432
- }
433
- return options2.inverse ? options2.inverse(this) ?? "" : "";
434
- }
435
- const uniqueArray = [...new Set(array)];
436
- if (!options2) {
437
- return uniqueArray;
438
- }
439
- if (uniqueArray.length === 0 && options2.inverse) {
440
- return options2.inverse(this);
441
- }
442
- if (uniqueArray.length > 0 && options2.fn) {
443
- let result = "";
444
- for (const item of uniqueArray) {
445
- result += options2.fn(item);
446
- }
447
- return result;
448
- }
449
- return "";
450
- };
451
- var helpers = [
452
- {
453
- name: "after",
454
- category: "array",
455
- compatibility: ["browser", "nodejs"],
456
- fn: after
457
- },
458
- {
459
- name: "before",
460
- category: "array",
461
- compatibility: ["browser", "nodejs"],
462
- fn: before
463
- },
464
- {
465
- name: "arrayify",
466
- category: "array",
467
- compatibility: ["browser", "nodejs"],
468
- fn: arrayify
469
- },
470
- {
471
- name: "first",
472
- category: "array",
473
- compatibility: ["browser", "nodejs"],
474
- fn: first
475
- },
476
- {
477
- name: "last",
478
- category: "array",
479
- compatibility: ["browser", "nodejs"],
480
- fn: last
481
- },
482
- {
483
- name: "length",
484
- category: "array",
485
- compatibility: ["browser", "nodejs"],
486
- fn: length
487
- },
488
- {
489
- name: "join",
490
- category: "array",
491
- compatibility: ["browser", "nodejs"],
492
- fn: join
493
- },
494
- {
495
- name: "forEach",
496
- category: "array",
497
- compatibility: ["browser", "nodejs"],
498
- fn: forEach
499
- },
500
- {
501
- name: "inArray",
502
- category: "array",
503
- compatibility: ["browser", "nodejs"],
504
- fn: inArray
505
- },
506
- {
507
- name: "isArray",
508
- category: "array",
509
- compatibility: ["browser", "nodejs"],
510
- fn: isArray
511
- },
512
- {
513
- name: "itemAt",
514
- category: "array",
515
- compatibility: ["browser", "nodejs"],
516
- fn: itemAt
517
- },
518
- {
519
- name: "equalsLength",
520
- category: "array",
521
- compatibility: ["browser", "nodejs"],
522
- fn: equalsLength
523
- },
524
- {
525
- name: "some",
526
- category: "array",
527
- compatibility: ["browser", "nodejs"],
528
- fn: some
529
- },
530
- {
531
- name: "eachIndex",
532
- category: "array",
533
- compatibility: ["browser", "nodejs"],
534
- fn: eachIndex
535
- },
536
- {
537
- name: "withAfter",
538
- category: "array",
539
- compatibility: ["browser", "nodejs"],
540
- fn: withAfter
541
- },
542
- {
543
- name: "withBefore",
544
- category: "array",
545
- compatibility: ["browser", "nodejs"],
546
- fn: withBefore
547
- },
548
- {
549
- name: "withFirst",
550
- category: "array",
551
- compatibility: ["browser", "nodejs"],
552
- fn: withFirst
553
- },
554
- {
555
- name: "withLast",
556
- category: "array",
557
- compatibility: ["browser", "nodejs"],
558
- fn: withLast
559
- },
560
- {
561
- name: "withGroup",
562
- category: "array",
563
- compatibility: ["browser", "nodejs"],
564
- fn: withGroup
565
- },
566
- {
567
- name: "withSort",
568
- category: "array",
569
- compatibility: ["browser", "nodejs"],
570
- fn: withSort
571
- },
572
- {
573
- name: "filter",
574
- category: "array",
575
- compatibility: ["browser", "nodejs"],
576
- fn: filter
577
- },
578
- {
579
- name: "map",
580
- category: "array",
581
- compatibility: ["browser", "nodejs"],
582
- fn: map
583
- },
584
- {
585
- name: "pluck",
586
- category: "array",
587
- compatibility: ["browser", "nodejs"],
588
- fn: pluck
589
- },
590
- {
591
- name: "reverse",
592
- category: "array",
593
- compatibility: ["browser", "nodejs"],
594
- fn: reverse
595
- },
596
- {
597
- name: "sort",
598
- category: "array",
599
- compatibility: ["browser", "nodejs"],
600
- fn: sort
601
- },
602
- {
603
- name: "sortBy",
604
- category: "array",
605
- compatibility: ["browser", "nodejs"],
606
- fn: sortBy
607
- },
608
- {
609
- name: "unique",
610
- category: "array",
611
- compatibility: ["browser", "nodejs"],
612
- fn: unique
613
- }
614
- ];
615
-
616
- // src/helpers/code.ts
617
- var import_node_fs = __toESM(require("fs"), 1);
618
- var import_node_path = __toESM(require("path"), 1);
619
- var import_html_tag = __toESM(require("html-tag"), 1);
620
- var import_to_gfm_code_block = __toESM(require("to-gfm-code-block"), 1);
621
- var embed = (filepath, language) => {
622
- let ext = typeof language === "string" ? language : import_node_path.default.extname(filepath).slice(1);
623
- let code = import_node_fs.default.readFileSync(filepath, "utf8");
624
- if (ext === "markdown" || ext === "md") {
625
- ext = "markdown";
626
- code = code.split("`").join("&#x60");
627
- }
628
- return `${(0, import_to_gfm_code_block.default)(code, ext).trim()}
629
- `;
630
- };
631
- var gist = (id) => {
632
- return (0, import_html_tag.default)("script", { src: `https://gist.github.com/${id}.js` });
633
- };
634
- var jsfiddle = (options2) => {
635
- if (!options2 || !options2.id) {
636
- throw new Error("jsfiddle helper expects an `id`");
637
- }
638
- const {
639
- id,
640
- width = "100%",
641
- height = "300",
642
- skin = "/presentation/",
643
- tabs = "result,js,html,css",
644
- allowfullscreen = "allowfullscreen",
645
- frameborder = "0"
646
- } = options2;
647
- const src = `http://jsfiddle.net/${id}/embedded/${tabs}${skin}`;
648
- return (0, import_html_tag.default)("iframe", { width, height, src, allowfullscreen, frameborder });
649
- };
650
- var helpers2 = [
651
- {
652
- name: "embed",
653
- category: "code",
654
- compatibility: ["nodejs"],
655
- fn: embed
656
- },
657
- {
658
- name: "gist",
659
- category: "code",
660
- compatibility: ["browser", "nodejs"],
661
- fn: gist
662
- },
663
- {
664
- name: "jsfiddle",
665
- category: "code",
666
- compatibility: ["browser", "nodejs"],
667
- fn: jsfiddle
668
- }
669
- ];
670
-
671
- // src/helpers/collection.ts
672
- var isEmpty = (collection) => {
673
- if (collection == null) return true;
674
- if (Array.isArray(collection)) return collection.length === 0;
675
- if (typeof collection === "object")
676
- return Object.keys(collection).length === 0;
677
- return false;
678
- };
679
- var iterate = (collection, fn, inverse) => {
680
- if (Array.isArray(collection)) {
681
- let result = "";
682
- for (let i = 0; i < collection.length; i++) {
683
- result += fn(collection[i], i);
684
- }
685
- return result;
686
- }
687
- if (collection && typeof collection === "object") {
688
- let result = "";
689
- for (const key of Object.keys(collection)) {
690
- result += fn(collection[key], key);
691
- }
692
- return result;
693
- }
694
- return inverse ? inverse() : "";
695
- };
696
- var helpers3 = [
697
- {
698
- name: "isEmpty",
699
- category: "collection",
700
- compatibility: ["browser", "nodejs"],
701
- fn: isEmpty
702
- },
703
- {
704
- name: "iterate",
705
- category: "collection",
706
- compatibility: ["browser", "nodejs"],
707
- fn: iterate
708
- }
709
- ];
710
-
711
- // src/helpers/comparison.ts
712
- var and = (...values) => values.every(Boolean);
713
- var compare = (a, operator, b) => {
714
- switch (operator) {
715
- case "==":
716
- return a == b;
717
- case "===":
718
- return a === b;
719
- case "!=":
720
- return a != b;
721
- case "!==":
722
- return a !== b;
723
- case "<":
724
- return a < b;
725
- case ">":
726
- return a > b;
727
- case "<=":
728
- return a <= b;
729
- case ">=":
730
- return a >= b;
731
- case "typeof":
732
- return typeof a === b;
733
- default:
734
- throw new Error(`helper {{compare}}: invalid operator: '${operator}'`);
735
- }
736
- };
737
- var contains = (collection, value, startIndex = 0) => {
738
- if (collection == null) return false;
739
- if (typeof collection === "string" || Array.isArray(collection)) {
740
- return collection.indexOf(value, startIndex) > -1;
741
- }
742
- if (typeof collection === "object") {
743
- return value in collection;
744
- }
745
- return false;
746
- };
747
- var defaultHelper = (...values) => {
748
- for (const val of values) {
749
- if (val != null) return val;
750
- }
751
- return "";
752
- };
753
- var eq = (a, b) => a === b;
754
- var gt = (a, b) => a > b;
755
- var gte = (a, b) => a >= b;
756
- var has = (value, pattern) => {
757
- if (value == null || pattern == null) return false;
758
- if (Array.isArray(value) || typeof value === "string") {
759
- return value.indexOf(pattern) > -1;
760
- }
761
- if (typeof value === "object") {
762
- return pattern in value;
763
- }
764
- return false;
765
- };
766
- var falsey = (val, keywords) => {
767
- if (!val) return true;
768
- const words = Array.isArray(keywords) ? keywords : keywords != null ? [keywords] : [
769
- "0",
770
- "false",
771
- "nada",
772
- "nil",
773
- "nay",
774
- "nah",
775
- "negative",
776
- "no",
777
- "none",
778
- "nope",
779
- "nul",
780
- "null",
781
- "nix",
782
- "nyet",
783
- "uh-uh",
784
- "veto",
785
- "zero"
786
- ];
787
- const lower = typeof val === "string" ? val.toLowerCase() : null;
788
- for (const word of words) {
789
- if (word === val) return true;
790
- if (lower != null && word === lower) return true;
791
- }
792
- return false;
793
- };
794
- var isFalsey = (val) => falsey(val);
795
- var isTruthy = (val) => !falsey(val);
796
- var ifEven = (num) => typeof num === "number" && num % 2 === 0;
797
- var ifNth = (a, b) => typeof a === "number" && typeof b === "number" && b % a === 0;
798
- var ifOdd = (val) => typeof val === "number" && Math.abs(val % 2) === 1;
799
- var is = (a, b) => a == b;
800
- var isnt = (a, b) => a != b;
801
- var lt = (a, b) => a < b;
802
- var lte = (a, b) => a <= b;
803
- var neither = (a, b) => !a && !b;
804
- var not = (val) => !val;
805
- var or = (...values) => values.some(Boolean);
806
- var unlessEq = (a, b) => a !== b;
807
- var unlessGt = (a, b) => a <= b;
808
- var unlessLt = (a, b) => a >= b;
809
- var unlessGteq = (a, b) => a < b;
810
- var unlessLteq = (a, b) => a > b;
811
- var helpers4 = [
812
- {
813
- name: "and",
814
- category: "comparison",
815
- compatibility: ["browser", "nodejs"],
816
- fn: and
817
- },
818
- {
819
- name: "compare",
820
- category: "comparison",
821
- compatibility: ["browser", "nodejs"],
822
- fn: compare
823
- },
824
- {
825
- name: "contains",
826
- category: "comparison",
827
- compatibility: ["browser", "nodejs"],
828
- fn: contains
829
- },
830
- {
831
- name: "default",
832
- category: "comparison",
833
- compatibility: ["browser", "nodejs"],
834
- fn: defaultHelper
835
- },
836
- {
837
- name: "eq",
838
- category: "comparison",
839
- compatibility: ["browser", "nodejs"],
840
- fn: eq
841
- },
842
- {
843
- name: "gt",
844
- category: "comparison",
845
- compatibility: ["browser", "nodejs"],
846
- fn: gt
847
- },
848
- {
849
- name: "gte",
850
- category: "comparison",
851
- compatibility: ["browser", "nodejs"],
852
- fn: gte
853
- },
854
- {
855
- name: "has",
856
- category: "comparison",
857
- compatibility: ["browser", "nodejs"],
858
- fn: has
859
- },
860
- {
861
- name: "isFalsey",
862
- category: "comparison",
863
- compatibility: ["browser", "nodejs"],
864
- fn: isFalsey
865
- },
866
- {
867
- name: "isTruthy",
868
- category: "comparison",
869
- compatibility: ["browser", "nodejs"],
870
- fn: isTruthy
871
- },
872
- {
873
- name: "ifEven",
874
- category: "comparison",
875
- compatibility: ["browser", "nodejs"],
876
- fn: ifEven
877
- },
878
- {
879
- name: "ifNth",
880
- category: "comparison",
881
- compatibility: ["browser", "nodejs"],
882
- fn: ifNth
883
- },
884
- {
885
- name: "ifOdd",
886
- category: "comparison",
887
- compatibility: ["browser", "nodejs"],
888
- fn: ifOdd
889
- },
890
- {
891
- name: "is",
892
- category: "comparison",
893
- compatibility: ["browser", "nodejs"],
894
- fn: is
895
- },
896
- {
897
- name: "isnt",
898
- category: "comparison",
899
- compatibility: ["browser", "nodejs"],
900
- fn: isnt
901
- },
902
- {
903
- name: "lt",
904
- category: "comparison",
905
- compatibility: ["browser", "nodejs"],
906
- fn: lt
907
- },
908
- {
909
- name: "lte",
910
- category: "comparison",
911
- compatibility: ["browser", "nodejs"],
912
- fn: lte
913
- },
914
- {
915
- name: "neither",
916
- category: "comparison",
917
- compatibility: ["browser", "nodejs"],
918
- fn: neither
919
- },
920
- {
921
- name: "not",
922
- category: "comparison",
923
- compatibility: ["browser", "nodejs"],
924
- fn: not
925
- },
926
- {
927
- name: "or",
928
- category: "comparison",
929
- compatibility: ["browser", "nodejs"],
930
- fn: or
931
- },
932
- {
933
- name: "unlessEq",
934
- category: "comparison",
935
- compatibility: ["browser", "nodejs"],
936
- fn: unlessEq
937
- },
938
- {
939
- name: "unlessGt",
940
- category: "comparison",
941
- compatibility: ["browser", "nodejs"],
942
- fn: unlessGt
943
- },
944
- {
945
- name: "unlessLt",
946
- category: "comparison",
947
- compatibility: ["browser", "nodejs"],
948
- fn: unlessLt
949
- },
950
- {
951
- name: "unlessGteq",
952
- category: "comparison",
953
- compatibility: ["browser", "nodejs"],
954
- fn: unlessGteq
955
- },
956
- {
957
- name: "unlessLteq",
958
- category: "comparison",
959
- compatibility: ["browser", "nodejs"],
960
- fn: unlessLteq
961
- }
962
- ];
963
-
964
- // src/helpers/date.ts
965
- var import_chrono_node = require("chrono-node");
966
- var import_dayjs = __toESM(require("dayjs"), 1);
967
- var import_isBetween = __toESM(require("dayjs/plugin/isBetween.js"), 1);
968
- var import_relativeTime = __toESM(require("dayjs/plugin/relativeTime.js"), 1);
969
- var import_timezone = __toESM(require("dayjs/plugin/timezone.js"), 1);
970
- var import_utc = __toESM(require("dayjs/plugin/utc.js"), 1);
971
- import_dayjs.default.extend(import_relativeTime.default);
972
- import_dayjs.default.extend(import_isBetween.default);
973
- import_dayjs.default.extend(import_utc.default);
974
- import_dayjs.default.extend(import_timezone.default);
975
- var parseDateInput = (input) => {
976
- if (!input) {
977
- return (0, import_dayjs.default)();
978
- }
979
- if (typeof input === "string") {
980
- const parsed = (0, import_chrono_node.parseDate)(input);
981
- if (parsed) {
982
- return (0, import_dayjs.default)(parsed);
983
- }
984
- return (0, import_dayjs.default)(input);
985
- }
986
- return (0, import_dayjs.default)(input);
987
- };
988
- var year = () => (/* @__PURE__ */ new Date()).getFullYear().toString();
989
- var convertFormatString = (format2) => {
990
- return format2.replace(/yyyy/g, "YYYY").replace(/yy/g, "YY").replace(/dd/g, "DD").replace(/mm/g, "MM").replace(/hh/g, "HH");
991
- };
992
- var date = (humanReadableDate, formatString) => {
993
- const defaultFormat = "YYYY-MM-DD";
994
- const format2 = formatString || defaultFormat;
995
- const parsedDate = parseDateInput(humanReadableDate);
996
- if (!parsedDate.isValid()) {
997
- throw new Error(`Unable to parse date: ${humanReadableDate}`);
998
- }
999
- const convertedFormat = convertFormatString(format2);
1000
- return parsedDate.format(convertedFormat);
1001
- };
1002
- var timestamp = () => {
1003
- return Date.now().toString();
1004
- };
1005
- var now = (formatString) => {
1006
- const defaultFormat = "YYYY-MM-DD HH:mm:ss";
1007
- const format2 = formatString || defaultFormat;
1008
- const convertedFormat = convertFormatString(format2);
1009
- return (0, import_dayjs.default)().format(convertedFormat);
1010
- };
1011
- var fromNow = (dateInput) => {
1012
- const parsed = parseDateInput(dateInput);
1013
- if (!parsed.isValid()) {
1014
- throw new Error(`Unable to parse date: ${dateInput}`);
1015
- }
1016
- return parsed.fromNow();
1017
- };
1018
- var toNow = (dateInput) => {
1019
- const parsed = parseDateInput(dateInput);
1020
- if (!parsed.isValid()) {
1021
- throw new Error(`Unable to parse date: ${dateInput}`);
1022
- }
1023
- return parsed.toNow();
1024
- };
1025
- var ago = (dateInput) => {
1026
- return fromNow(dateInput);
1027
- };
1028
- var dateAdd = (dateInput, amount, unit) => {
1029
- const parsed = parseDateInput(dateInput);
1030
- if (!parsed.isValid()) {
1031
- throw new Error(`Unable to parse date: ${dateInput}`);
1032
- }
1033
- return parsed.add(amount, unit).format("YYYY-MM-DD HH:mm:ss");
1034
- };
1035
- var dateSubtract = (dateInput, amount, unit) => {
1036
- const parsed = parseDateInput(dateInput);
1037
- if (!parsed.isValid()) {
1038
- throw new Error(`Unable to parse date: ${dateInput}`);
1039
- }
1040
- return parsed.subtract(amount, unit).format("YYYY-MM-DD HH:mm:ss");
1041
- };
1042
- var startOf = (dateInput, unit) => {
1043
- const parsed = parseDateInput(dateInput);
1044
- if (!parsed.isValid()) {
1045
- throw new Error(`Unable to parse date: ${dateInput}`);
1046
- }
1047
- return parsed.startOf(unit).format("YYYY-MM-DD HH:mm:ss");
1048
- };
1049
- var endOf = (dateInput, unit) => {
1050
- const parsed = parseDateInput(dateInput);
1051
- if (!parsed.isValid()) {
1052
- throw new Error(`Unable to parse date: ${dateInput}`);
1053
- }
1054
- return parsed.endOf(unit).format("YYYY-MM-DD HH:mm:ss");
1055
- };
1056
- var isBefore = (date1, date2) => {
1057
- const parsed1 = parseDateInput(date1);
1058
- const parsed2 = parseDateInput(date2);
1059
- if (!parsed1.isValid() || !parsed2.isValid()) {
1060
- throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
1061
- }
1062
- return parsed1.isBefore(parsed2);
1063
- };
1064
- var isAfter = (date1, date2) => {
1065
- const parsed1 = parseDateInput(date1);
1066
- const parsed2 = parseDateInput(date2);
1067
- if (!parsed1.isValid() || !parsed2.isValid()) {
1068
- throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
1069
- }
1070
- return parsed1.isAfter(parsed2);
1071
- };
1072
- var isSame = (date1, date2, unit) => {
1073
- const parsed1 = parseDateInput(date1);
1074
- const parsed2 = parseDateInput(date2);
1075
- if (!parsed1.isValid() || !parsed2.isValid()) {
1076
- throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
1077
- }
1078
- return parsed1.isSame(parsed2, unit);
1079
- };
1080
- var isBetweenDates = (dateInput, startDate, endDate) => {
1081
- const parsed = parseDateInput(dateInput);
1082
- const parsedStart = parseDateInput(startDate);
1083
- const parsedEnd = parseDateInput(endDate);
1084
- if (!parsed.isValid() || !parsedStart.isValid() || !parsedEnd.isValid()) {
1085
- throw new Error(
1086
- `Unable to parse dates: ${dateInput}, ${startDate}, ${endDate}`
1087
- );
1088
- }
1089
- return parsed.isBetween(parsedStart, parsedEnd, null, "[]");
1090
- };
1091
- var diff = (date1, date2, unit) => {
1092
- const parsed1 = parseDateInput(date1);
1093
- const parsed2 = parseDateInput(date2);
1094
- if (!parsed1.isValid() || !parsed2.isValid()) {
1095
- throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
1096
- }
1097
- return parsed1.diff(parsed2, unit);
1098
- };
1099
- var toISOString = (dateInput) => {
1100
- const parsed = parseDateInput(dateInput);
1101
- if (!parsed.isValid()) {
1102
- throw new Error(`Unable to parse date: ${dateInput}`);
1103
- }
1104
- return parsed.toISOString();
1105
- };
1106
- var dateTimezone = (dateInput, timezoneStr, formatString) => {
1107
- const defaultFormat = "YYYY-MM-DD HH:mm:ss";
1108
- const format2 = formatString || defaultFormat;
1109
- const convertedFormat = convertFormatString(format2);
1110
- const parsed = parseDateInput(dateInput);
1111
- if (!parsed.isValid()) {
1112
- throw new Error(`Unable to parse date: ${dateInput}`);
1113
- }
1114
- return parsed.tz(timezoneStr).format(convertedFormat);
1115
- };
1116
- var dateLocale = (dateInput, locale, formatString) => {
1117
- const defaultFormat = "YYYY-MM-DD HH:mm:ss";
1118
- const format2 = formatString || defaultFormat;
1119
- const convertedFormat = convertFormatString(format2);
1120
- const parsed = parseDateInput(dateInput);
1121
- if (!parsed.isValid()) {
1122
- throw new Error(`Unable to parse date: ${dateInput}`);
1123
- }
1124
- return parsed.locale(locale).format(convertedFormat);
1125
- };
1126
- var helpers5 = [
1127
- {
1128
- name: "year",
1129
- category: "date",
1130
- compatibility: ["browser", "nodejs"],
1131
- fn: year
1132
- },
1133
- {
1134
- name: "date",
1135
- category: "date",
1136
- compatibility: ["browser", "nodejs"],
1137
- fn: date
1138
- },
1139
- {
1140
- /* Adding this in for legacy support */
1141
- name: "moment",
1142
- category: "date",
1143
- compatibility: ["browser", "nodejs"],
1144
- fn: date
1145
- },
1146
- {
1147
- name: "timestamp",
1148
- category: "date",
1149
- compatibility: ["browser", "nodejs"],
1150
- fn: timestamp
1151
- },
1152
- {
1153
- name: "now",
1154
- category: "date",
1155
- compatibility: ["browser", "nodejs"],
1156
- fn: now
1157
- },
1158
- {
1159
- name: "fromNow",
1160
- category: "date",
1161
- compatibility: ["browser", "nodejs"],
1162
- fn: fromNow
1163
- },
1164
- {
1165
- name: "toNow",
1166
- category: "date",
1167
- compatibility: ["browser", "nodejs"],
1168
- fn: toNow
1169
- },
1170
- {
1171
- name: "ago",
1172
- category: "date",
1173
- compatibility: ["browser", "nodejs"],
1174
- fn: ago
1175
- },
1176
- {
1177
- name: "dateAdd",
1178
- category: "date",
1179
- compatibility: ["browser", "nodejs"],
1180
- fn: dateAdd
1181
- },
1182
- {
1183
- name: "dateSubtract",
1184
- category: "date",
1185
- compatibility: ["browser", "nodejs"],
1186
- fn: dateSubtract
1187
- },
1188
- {
1189
- name: "startOf",
1190
- category: "date",
1191
- compatibility: ["browser", "nodejs"],
1192
- fn: startOf
1193
- },
1194
- {
1195
- name: "endOf",
1196
- category: "date",
1197
- compatibility: ["browser", "nodejs"],
1198
- fn: endOf
1199
- },
1200
- {
1201
- name: "isBefore",
1202
- category: "date",
1203
- compatibility: ["browser", "nodejs"],
1204
- fn: isBefore
1205
- },
1206
- {
1207
- name: "isAfter",
1208
- category: "date",
1209
- compatibility: ["browser", "nodejs"],
1210
- fn: isAfter
1211
- },
1212
- {
1213
- name: "isSame",
1214
- category: "date",
1215
- compatibility: ["browser", "nodejs"],
1216
- fn: isSame
1217
- },
1218
- {
1219
- name: "isBetween",
1220
- category: "date",
1221
- compatibility: ["browser", "nodejs"],
1222
- fn: isBetweenDates
1223
- },
1224
- {
1225
- name: "diff",
1226
- category: "date",
1227
- compatibility: ["browser", "nodejs"],
1228
- fn: diff
1229
- },
1230
- {
1231
- name: "toISOString",
1232
- category: "date",
1233
- compatibility: ["browser", "nodejs"],
1234
- fn: toISOString
1235
- },
1236
- {
1237
- name: "dateTimezone",
1238
- category: "date",
1239
- compatibility: ["browser", "nodejs"],
1240
- fn: dateTimezone
1241
- },
1242
- {
1243
- name: "dateLocale",
1244
- category: "date",
1245
- compatibility: ["browser", "nodejs"],
1246
- fn: dateLocale
1247
- }
1248
- ];
1249
-
1250
- // src/helpers/fs.ts
1251
- var import_node_fs2 = __toESM(require("fs"), 1);
1252
- var import_node_path2 = __toESM(require("path"), 1);
1253
- var import_is_glob = __toESM(require("is-glob"), 1);
1254
- var import_micromatch = __toESM(require("micromatch"), 1);
1255
- var fileSize = (value, precision) => {
1256
- if (value == null) return "0 B";
1257
- const number = typeof value === "number" ? value : value.length ?? 0;
1258
- if (!number) return "0 B";
1259
- const precisionNumber = typeof precision === "number" ? precision : 2;
1260
- const abbr = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
1261
- const factor = 10 ** precisionNumber;
1262
- let i = abbr.length - 1;
1263
- do {
1264
- const size = 10 ** (i * 3);
1265
- if (size <= number + 1) {
1266
- const num = Math.round(number * factor / size) / factor;
1267
- return `${num} ${abbr[i]}`;
1268
- }
1269
- } while (--i >= 0);
1270
- return `${number} B`;
1271
- };
1272
- var read = (filepath) => {
1273
- return import_node_fs2.default.readFileSync(filepath, "utf8");
1274
- };
1275
- var isOptions = (value) => {
1276
- return Boolean(
1277
- value && typeof value === "object" && "hash" in value
1278
- );
1279
- };
1280
- var readdir = (dir, filter2) => {
1281
- const files = import_node_fs2.default.readdirSync(dir).map((fp) => import_node_path2.default.join(dir, fp));
1282
- const filterArg = isOptions(filter2) ? void 0 : filter2;
1283
- if (typeof filterArg === "function") {
1284
- return filterArg(files);
1285
- }
1286
- if (filterArg instanceof RegExp) {
1287
- return files.filter((fp) => filterArg.test(fp));
1288
- }
1289
- if (typeof filterArg === "string") {
1290
- if ((0, import_is_glob.default)(filterArg)) {
1291
- return (0, import_micromatch.default)(files, filterArg);
1292
- }
1293
- if (filterArg === "isFile" || filterArg === "isDirectory") {
1294
- return files.filter((fp) => {
1295
- const stat = import_node_fs2.default.statSync(fp);
1296
- return filterArg === "isFile" ? stat.isFile() : stat.isDirectory();
1297
- });
1298
- }
1299
- }
1300
- return files;
1301
- };
1302
- var helpers6 = [
1303
- {
1304
- name: "fileSize",
1305
- category: "fs",
1306
- compatibility: ["nodejs"],
1307
- fn: fileSize
1308
- },
1309
- {
1310
- name: "read",
1311
- category: "fs",
1312
- compatibility: ["nodejs"],
1313
- fn: read
1314
- },
1315
- {
1316
- name: "readdir",
1317
- category: "fs",
1318
- compatibility: ["nodejs"],
1319
- fn: readdir
1320
- }
1321
- ];
1322
-
1323
- // src/helpers/html.ts
1324
- var import_node_path3 = __toESM(require("path"), 1);
1325
- var import_html_tag2 = __toESM(require("html-tag"), 1);
1326
- var import_striptags = __toESM(require("striptags"), 1);
1327
- var parseAttributes = (hash = {}) => Object.keys(hash).map((key) => `${key}="${String(hash[key]).replace(/^['"]|["']$/g, "")}"`).join(" ");
1328
- var attr = (options2) => {
1329
- const val = parseAttributes(options2?.hash ?? {});
1330
- return val.trim() ? ` ${val}` : "";
1331
- };
1332
- var css = function(list, options2) {
1333
- if (arguments.length < 2) {
1334
- options2 = list;
1335
- list = [];
1336
- }
1337
- let styles = arrayify(list ?? []);
1338
- let assets = "";
1339
- if (this && this.options) {
1340
- assets = this.options.assets || "";
1341
- }
1342
- if (options2?.hash?.href) {
1343
- styles = arrayify(options2.hash.href);
1344
- }
1345
- return styles.map((item) => {
1346
- const ext = import_node_path3.default.extname(item);
1347
- let fp = item;
1348
- if (!/(^\/\/)|(:\/\/)/.test(item)) {
1349
- fp = import_node_path3.default.posix.join(assets, item);
1350
- }
1351
- if (ext === ".less") {
1352
- return `<link type="text/css" rel="stylesheet/less" href="${fp}">`;
1353
- }
1354
- return `<link type="text/css" rel="stylesheet" href="${fp}">`;
1355
- }).join("\n");
1356
- };
1357
- var js = (context) => {
1358
- if (context && typeof context === "object" && !Array.isArray(context)) {
1359
- const attrStr = parseAttributes(context.hash ?? {});
1360
- return `<script${attrStr ? ` ${attrStr}` : ""}></script>`;
1361
- }
1362
- if (typeof context === "string") {
1363
- return `<script src="${context}"></script>`;
1364
- }
1365
- const items = arrayify(context);
1366
- return items.map(
1367
- (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 })
1368
- ).join("\n");
1369
- };
1370
- var sanitize = (str) => {
1371
- if (typeof str !== "string") return "";
1372
- return (0, import_striptags.default)(str).trim();
1373
- };
1374
- var ul = (context, options2) => {
1375
- const attrs = parseAttributes(options2.hash ?? {});
1376
- const items = context.map(
1377
- (item) => typeof item === "string" ? item : options2.fn(item)
1378
- );
1379
- const open = attrs ? `<ul ${attrs}>` : "<ul>";
1380
- return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ul>`;
1381
- };
1382
- var ol = (context, options2) => {
1383
- const attrs = parseAttributes(options2.hash ?? {});
1384
- const items = context.map(
1385
- (item) => typeof item === "string" ? item : options2.fn(item)
1386
- );
1387
- const open = attrs ? `<ol ${attrs}>` : "<ol>";
1388
- return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ol>`;
1389
- };
1390
- var thumbnailImage = (context) => {
1391
- let figure = "";
1392
- let image = "";
1393
- const link = context.full || false;
1394
- const imageAttributes = {
1395
- alt: context.alt,
1396
- src: context.thumbnail,
1397
- width: context.size.width,
1398
- height: context.size.height
1399
- };
1400
- const figureAttributes = { id: `image-${context.id}` };
1401
- const linkAttributes = { href: link, rel: "thumbnail" };
1402
- if (context.classes) {
1403
- if (context.classes.image) {
1404
- imageAttributes.class = context.classes.image.join(" ");
1405
- }
1406
- if (context.classes.figure) {
1407
- figureAttributes.class = context.classes.figure.join(" ");
1408
- }
1409
- if (context.classes.link) {
1410
- linkAttributes.class = context.classes.link.join(" ");
1411
- }
1412
- }
1413
- figure += `<figure ${parseAttributes(figureAttributes)}>
1414
- `;
1415
- image += `<img ${parseAttributes(imageAttributes)}>
1416
- `;
1417
- if (link) {
1418
- figure += `<a ${parseAttributes(linkAttributes)}>
1419
- ${image}</a>
1420
- `;
1421
- } else {
1422
- figure += image;
1423
- }
1424
- if (context.caption) {
1425
- figure += `<figcaption>${context.caption}</figcaption>
1426
- `;
1427
- }
1428
- figure += "</figure>";
1429
- return figure;
1430
- };
1431
- var helpers7 = [
1432
- {
1433
- name: "attr",
1434
- category: "html",
1435
- compatibility: ["browser", "nodejs"],
1436
- fn: attr
1437
- },
1438
- {
1439
- name: "css",
1440
- category: "html",
1441
- compatibility: ["nodejs"],
1442
- fn: css
1443
- },
1444
- {
1445
- name: "js",
1446
- category: "html",
1447
- compatibility: ["nodejs"],
1448
- fn: js
1449
- },
1450
- {
1451
- name: "sanitize",
1452
- category: "html",
1453
- compatibility: ["browser", "nodejs"],
1454
- fn: sanitize
1455
- },
1456
- {
1457
- name: "ul",
1458
- category: "html",
1459
- compatibility: ["browser", "nodejs"],
1460
- fn: ul
1461
- },
1462
- {
1463
- name: "ol",
1464
- category: "html",
1465
- compatibility: ["browser", "nodejs"],
1466
- fn: ol
1467
- },
1468
- {
1469
- name: "thumbnailImage",
1470
- category: "html",
1471
- compatibility: ["browser", "nodejs"],
1472
- fn: thumbnailImage
1473
- }
1474
- ];
1475
-
1476
- // src/utils.ts
1477
- var get = (object, path6) => {
1478
- if (!object || typeof object !== "object") return void 0;
1479
- const keys = Array.isArray(path6) ? path6 : path6.split(".");
1480
- let result = object;
1481
- for (const key of keys) {
1482
- if (result == null || typeof result !== "object") return void 0;
1483
- result = result[key];
1484
- }
1485
- return result;
1486
- };
1487
- var getObject = (object, path6) => {
1488
- if (!object || typeof object !== "object") return void 0;
1489
- const keys = Array.isArray(path6) ? path6 : path6.split(".");
1490
- if (keys.length === 0) return void 0;
1491
- let current = object;
1492
- for (let i = 0; i < keys.length - 1; i++) {
1493
- if (current == null || typeof current !== "object") return void 0;
1494
- current = current[keys[i]];
1495
- }
1496
- const finalKey = keys[keys.length - 1];
1497
- if (current == null || typeof current !== "object" || !(finalKey in current)) {
1498
- return void 0;
1499
- }
1500
- return { [finalKey]: current[finalKey] };
1501
- };
1502
- var options = (thisArg, locals, opts) => {
1503
- const result = {};
1504
- if (thisArg && typeof thisArg === "object" && thisArg.options) {
1505
- Object.assign(result, thisArg.options);
1506
- }
1507
- if (locals && typeof locals === "object") {
1508
- if ("hash" in locals) {
1509
- Object.assign(result, locals.hash);
1510
- } else {
1511
- Object.assign(result, locals);
1512
- }
1513
- }
1514
- if (opts && typeof opts === "object") {
1515
- if ("hash" in opts) {
1516
- Object.assign(result, opts.hash);
1517
- } else {
1518
- Object.assign(result, opts);
1519
- }
1520
- }
1521
- return result;
1522
- };
1523
-
1524
- // src/helpers/i18n.ts
1525
- var i18n = function(prop, locals, options2) {
1526
- if (locals && typeof locals === "object" && "hash" in locals && options2 === void 0) {
1527
- options2 = locals;
1528
- locals = {};
1529
- }
1530
- if (typeof prop !== "string") {
1531
- throw new Error('{{i18n}} helper expected "key" to be a string');
1532
- }
1533
- const context = {
1534
- ...this,
1535
- ...locals,
1536
- ...options2?.hash ?? {}
1537
- };
1538
- const lang = context.language || context.lang;
1539
- if (typeof lang !== "string") {
1540
- throw new TypeError('{{i18n}} helper expected "language" to be a string');
1541
- }
1542
- const cache = context[lang];
1543
- if (typeof cache === "undefined") {
1544
- throw new Error(`{{i18n}} helper cannot find language "${lang}"`);
1545
- }
1546
- const result = get(cache, prop);
1547
- if (typeof result === "undefined") {
1548
- throw new Error(
1549
- '{{i18n}} helper cannot find property "' + String(prop) + '" for language "' + lang + '"'
1550
- );
1551
- }
1552
- return String(result);
1553
- };
1554
- var helpers8 = [
1555
- {
1556
- name: "i18n",
1557
- category: "i18n",
1558
- compatibility: ["browser", "nodejs"],
1559
- fn: i18n
1560
- }
1561
- ];
1562
-
1563
- // src/helpers/inflection.ts
1564
- var inflect = (count, singular, plural, includeCount) => {
1565
- const word = count > 1 || count === 0 ? plural : singular;
1566
- return includeCount ? `${count} ${word}` : word;
1567
- };
1568
- var ordinalize = (value) => {
1569
- const num = Math.abs(Math.round(Number(value)));
1570
- const str = String(value);
1571
- const res = num % 100;
1572
- if ([11, 12, 13].includes(res)) {
1573
- return `${str}th`;
1574
- }
1575
- switch (num % 10) {
1576
- case 1:
1577
- return `${str}st`;
1578
- case 2:
1579
- return `${str}nd`;
1580
- case 3:
1581
- return `${str}rd`;
1582
- default:
1583
- return `${str}th`;
1584
- }
1585
- };
1586
- var helpers9 = [
1587
- {
1588
- name: "inflect",
1589
- category: "inflection",
1590
- compatibility: ["browser", "nodejs"],
1591
- fn: inflect
1592
- },
1593
- {
1594
- name: "ordinalize",
1595
- category: "inflection",
1596
- compatibility: ["browser", "nodejs"],
1597
- fn: ordinalize
1598
- }
1599
- ];
1600
-
1601
- // src/helpers/logging.ts
1602
- var colors = {
1603
- green: (str) => `\x1B[32m${str}\x1B[0m`,
1604
- cyan: (str) => `\x1B[36m${str}\x1B[0m`,
1605
- yellow: (str) => `\x1B[33m${str}\x1B[0m`,
1606
- red: (str) => `\x1B[31m${str}\x1B[0m`,
1607
- bold: (str) => `\x1B[1m${str}\x1B[0m`
1608
- };
1609
- function cleanArgs(args) {
1610
- const last2 = args[args.length - 1];
1611
- if (args.length > 1 && typeof last2 === "object" && last2 !== null && "hash" in last2) {
1612
- return args.slice(0, -1);
1613
- }
1614
- return args;
1615
- }
1616
- function log(...args) {
1617
- const cleanedArgs = cleanArgs(args);
1618
- console.log(...cleanedArgs);
1619
- return "";
1620
- }
1621
- function ok(...args) {
1622
- const cleanedArgs = cleanArgs(args);
1623
- const message = cleanedArgs.join(" ");
1624
- console.log(colors.green(`\u2713 ${message}`));
1625
- return "";
1626
- }
1627
- function success(...args) {
1628
- const cleanedArgs = cleanArgs(args);
1629
- const message = cleanedArgs.map((arg) => String(arg)).join(" ");
1630
- console.log(colors.green(message));
1631
- return "";
1632
- }
1633
- function info(...args) {
1634
- const cleanedArgs = cleanArgs(args);
1635
- const message = cleanedArgs.map((arg) => String(arg)).join(" ");
1636
- console.log(colors.cyan(message));
1637
- return "";
1638
- }
1639
- function warning(...args) {
1640
- const cleanedArgs = cleanArgs(args);
1641
- const message = cleanedArgs.map((arg) => String(arg)).join(" ");
1642
- console.error(colors.yellow(message));
1643
- return "";
1644
- }
1645
- var warn = warning;
1646
- function error(...args) {
1647
- const cleanedArgs = cleanArgs(args);
1648
- const message = cleanedArgs.map((arg) => String(arg)).join(" ");
1649
- console.error(colors.red(message));
1650
- return "";
1651
- }
1652
- var danger = error;
1653
- function bold(...args) {
1654
- const cleanedArgs = cleanArgs(args);
1655
- const message = cleanedArgs.map((arg) => String(arg)).join(" ");
1656
- console.error(colors.bold(message));
1657
- return "";
1658
- }
1659
- function _debug(...args) {
1660
- const separator = "\u2500".repeat(50);
1661
- console.error(colors.cyan(separator));
1662
- if (args.length > 0) {
1663
- const cleanedArgs = cleanArgs(args);
1664
- console.error(colors.cyan("VALUE:"), cleanedArgs[0]);
1665
- }
1666
- if (this && Object.keys(this).length > 0) {
1667
- console.error(colors.cyan("CONTEXT:"), this);
1668
- }
1669
- console.error(colors.cyan(separator));
1670
- return "";
1671
- }
1672
- function _inspect(context, options2) {
1673
- const val = JSON.stringify(context, null, 2);
1674
- const type = options2?.hash?.type || "html";
1675
- return switchOutput(type, val);
1676
- }
1677
- function switchOutput(type, json) {
1678
- if (type[0] === ".") {
1679
- type = type.slice(1);
1680
- }
1681
- switch (type) {
1682
- case "md":
1683
- return `
1684
- \`\`\`json
1685
- ${json}
1686
- \`\`\`
1687
- `;
1688
- case "html":
1689
- return `<div class="highlight highlight-json">
1690
- <pre><code>
1691
- ${json}</code></pre></div>`;
1692
- default:
1693
- return json;
1694
- }
1695
- }
1696
- var helpers10 = [
1697
- {
1698
- name: "log",
1699
- category: "logging",
1700
- compatibility: ["nodejs"],
1701
- fn: log
1702
- },
1703
- {
1704
- name: "ok",
1705
- category: "logging",
1706
- compatibility: ["nodejs"],
1707
- fn: ok
1708
- },
1709
- {
1710
- name: "success",
1711
- category: "logging",
1712
- compatibility: ["nodejs"],
1713
- fn: success
1714
- },
1715
- {
1716
- name: "info",
1717
- category: "logging",
1718
- compatibility: ["nodejs"],
1719
- fn: info
1720
- },
1721
- {
1722
- name: "warning",
1723
- category: "logging",
1724
- compatibility: ["nodejs"],
1725
- fn: warning
1726
- },
1727
- {
1728
- name: "warn",
1729
- category: "logging",
1730
- compatibility: ["nodejs"],
1731
- fn: warn
1732
- },
1733
- {
1734
- name: "error",
1735
- category: "logging",
1736
- compatibility: ["nodejs"],
1737
- fn: error
1738
- },
1739
- {
1740
- name: "danger",
1741
- category: "logging",
1742
- compatibility: ["nodejs"],
1743
- fn: danger
1744
- },
1745
- {
1746
- name: "bold",
1747
- category: "logging",
1748
- compatibility: ["nodejs"],
1749
- fn: bold
1750
- },
1751
- {
1752
- name: "_debug",
1753
- category: "logging",
1754
- compatibility: ["nodejs"],
1755
- fn: _debug
1756
- },
1757
- {
1758
- name: "_inspect",
1759
- category: "logging",
1760
- compatibility: ["nodejs"],
1761
- fn: _inspect
1762
- }
1763
- ];
1764
-
1765
- // src/helpers/match.ts
1766
- var import_micromatch2 = __toESM(require("micromatch"), 1);
1767
- var match = (files, patterns, options2) => {
1768
- const pats = typeof patterns === "string" ? patterns.split(/, */) : patterns;
1769
- return (0, import_micromatch2.default)(files, pats, options2);
1770
- };
1771
- var isMatch = (filepath, pattern, options2) => {
1772
- return import_micromatch2.default.isMatch(filepath, pattern, options2);
1773
- };
1774
- var mm = (...args) => {
1775
- console.log("the {{mm}} helper is depcrecated and will be removed");
1776
- console.log("in handlebars-helpers v1.0.0, please use the {{match}}");
1777
- console.log("helper instead.");
1778
- return match(...args);
1779
- };
1780
- var helpers11 = [
1781
- {
1782
- name: "match",
1783
- category: "match",
1784
- compatibility: ["browser", "nodejs"],
1785
- fn: match
1786
- },
1787
- {
1788
- name: "isMatch",
1789
- category: "match",
1790
- compatibility: ["browser", "nodejs"],
1791
- fn: isMatch
1792
- },
1793
- {
1794
- name: "mm",
1795
- category: "match",
1796
- compatibility: ["browser", "nodejs"],
1797
- fn: mm
1798
- }
1799
- ];
1800
-
1801
- // src/helpers/math.ts
1802
- var isNumeric = (value) => typeof value === "number" && !Number.isNaN(value) || typeof value === "string" && value.trim() !== "" && !Number.isNaN(Number(value));
1803
- var toNumber = (value, message = "expected a number") => {
1804
- if (isNumeric(value)) {
1805
- return Number(value);
1806
- }
1807
- throw new TypeError(message);
1808
- };
1809
- var abs = (value) => {
1810
- const num = toNumber(value);
1811
- return Math.abs(num);
1812
- };
1813
- var add = (a, b) => {
1814
- if (isNumeric(a) && isNumeric(b)) {
1815
- return Number(a) + Number(b);
1816
- }
1817
- return "";
1818
- };
1819
- var avg = (...values) => {
1820
- const flat = values.flat().map((n) => Number(n));
1821
- return sum(flat) / flat.length;
1822
- };
1823
- var ceil = (value) => {
1824
- const num = toNumber(value);
1825
- return Math.ceil(num);
1826
- };
1827
- var divide = (a, b) => {
1828
- const numA = toNumber(a, "expected the first argument to be a number");
1829
- const numB = toNumber(b, "expected the second argument to be a number");
1830
- return numA / numB;
1831
- };
1832
- var floor = (value) => {
1833
- const num = toNumber(value);
1834
- return Math.floor(num);
1835
- };
1836
- var minus = (a, b) => {
1837
- const numA = toNumber(a, "expected the first argument to be a number");
1838
- const numB = toNumber(b, "expected the second argument to be a number");
1839
- return numA - numB;
1840
- };
1841
- var modulo = (a, b) => {
1842
- const numA = toNumber(a, "expected the first argument to be a number");
1843
- const numB = toNumber(b, "expected the second argument to be a number");
1844
- return numA % numB;
1845
- };
1846
- var multiply = (a, b) => {
1847
- const numA = toNumber(a, "expected the first argument to be a number");
1848
- const numB = toNumber(b, "expected the second argument to be a number");
1849
- return numA * numB;
1850
- };
1851
- var plus = (a, b) => {
1852
- const numA = toNumber(a, "expected the first argument to be a number");
1853
- const numB = toNumber(b, "expected the second argument to be a number");
1854
- return numA + numB;
1855
- };
1856
- var random = (min, max) => {
1857
- const minNum = toNumber(min, "expected minimum to be a number");
1858
- const maxNum = toNumber(max, "expected maximum to be a number");
1859
- return minNum + Math.floor(Math.random() * (maxNum - minNum + 1));
1860
- };
1861
- var remainder = (a, b) => a % b;
1862
- var round = (value) => {
1863
- const num = toNumber(value);
1864
- return Math.round(num);
1865
- };
1866
- var subtract = (a, b) => {
1867
- const numA = toNumber(a, "expected the first argument to be a number");
1868
- const numB = toNumber(b, "expected the second argument to be a number");
1869
- return numA - numB;
1870
- };
1871
- var sum = (...values) => {
1872
- const flat = values.flat();
1873
- let total = 0;
1874
- for (const value of flat) {
1875
- if (isNumeric(value)) {
1876
- total += Number(value);
1877
- }
1878
- }
1879
- return total;
1880
- };
1881
- var times = (a, b) => multiply(a, b);
1882
- var helpers12 = [
1883
- {
1884
- name: "abs",
1885
- category: "math",
1886
- compatibility: ["browser", "nodejs"],
1887
- fn: abs
1888
- },
1889
- {
1890
- name: "add",
1891
- category: "math",
1892
- compatibility: ["browser", "nodejs"],
1893
- fn: add
1894
- },
1895
- {
1896
- name: "avg",
1897
- category: "math",
1898
- compatibility: ["browser", "nodejs"],
1899
- fn: avg
1900
- },
1901
- {
1902
- name: "ceil",
1903
- category: "math",
1904
- compatibility: ["browser", "nodejs"],
1905
- fn: ceil
1906
- },
1907
- {
1908
- name: "divide",
1909
- category: "math",
1910
- compatibility: ["browser", "nodejs"],
1911
- fn: divide
1912
- },
1913
- {
1914
- name: "floor",
1915
- category: "math",
1916
- compatibility: ["browser", "nodejs"],
1917
- fn: floor
1918
- },
1919
- {
1920
- name: "minus",
1921
- category: "math",
1922
- compatibility: ["browser", "nodejs"],
1923
- fn: minus
1924
- },
1925
- {
1926
- name: "modulo",
1927
- category: "math",
1928
- compatibility: ["browser", "nodejs"],
1929
- fn: modulo
1930
- },
1931
- {
1932
- name: "multiply",
1933
- category: "math",
1934
- compatibility: ["browser", "nodejs"],
1935
- fn: multiply
1936
- },
1937
- {
1938
- name: "plus",
1939
- category: "math",
1940
- compatibility: ["browser", "nodejs"],
1941
- fn: plus
1942
- },
1943
- {
1944
- name: "random",
1945
- category: "math",
1946
- compatibility: ["browser", "nodejs"],
1947
- fn: random
1948
- },
1949
- {
1950
- name: "remainder",
1951
- category: "math",
1952
- compatibility: ["browser", "nodejs"],
1953
- fn: remainder
1954
- },
1955
- {
1956
- name: "round",
1957
- category: "math",
1958
- compatibility: ["browser", "nodejs"],
1959
- fn: round
1960
- },
1961
- {
1962
- name: "subtract",
1963
- category: "math",
1964
- compatibility: ["browser", "nodejs"],
1965
- fn: subtract
1966
- },
1967
- {
1968
- name: "sum",
1969
- category: "math",
1970
- compatibility: ["browser", "nodejs"],
1971
- fn: sum
1972
- },
1973
- {
1974
- name: "times",
1975
- category: "math",
1976
- compatibility: ["browser", "nodejs"],
1977
- fn: times
1978
- }
1979
- ];
1980
-
1981
- // src/helpers/md.ts
1982
- var import_node_fs3 = __toESM(require("fs"), 1);
1983
- var import_node_path4 = __toESM(require("path"), 1);
1984
- var import_node_process = __toESM(require("process"), 1);
1985
- var import_ent = __toESM(require("ent"), 1);
1986
- var import_handlebars = __toESM(require("handlebars"), 1);
1987
- var import_remarkable = require("remarkable");
1988
- var renderMarkdown = function(input, options2) {
1989
- if (typeof input === "object" && input && "fn" in input && typeof input.fn === "function") {
1990
- options2 = input;
1991
- input = input.fn(this);
1992
- } else if (typeof input !== "string") {
1993
- input = "";
1994
- }
1995
- const options_ = { cwd: import_node_process.default.cwd(), ...options2 };
1996
- const md = new import_remarkable.Remarkable({
1997
- breaks: true,
1998
- html: true,
1999
- langPrefix: "lang-",
2000
- typographer: false,
2001
- xhtmlOut: false
2002
- });
2003
- let string_ = input;
2004
- if (string_ && string_.length > 0) {
2005
- const filepath = import_node_path4.default.resolve(options_.cwd, string_);
2006
- if (import_node_fs3.default.existsSync(filepath) && import_node_fs3.default.statSync(filepath).isFile()) {
2007
- string_ = import_node_fs3.default.readFileSync(filepath, "utf8");
2008
- }
2009
- }
2010
- return new import_handlebars.default.SafeString(import_ent.default.decode(md.render(string_)));
2011
- };
2012
- var helpers13 = [
2013
- {
2014
- name: "md",
2015
- category: "markdown",
2016
- compatibility: ["nodejs"],
2017
- fn: renderMarkdown
2018
- },
2019
- {
2020
- name: "markdown",
2021
- category: "markdown",
2022
- compatibility: ["nodejs"],
2023
- fn: renderMarkdown
2024
- }
2025
- ];
2026
-
2027
- // src/helpers/misc.ts
2028
- var import_handlebars2 = __toESM(require("handlebars"), 1);
2029
- var import_kind_of = __toESM(require("kind-of"), 1);
2030
- function frame(context, options2) {
2031
- if (typeof context === "object" && context !== null && "hash" in context) {
2032
- options2 = context;
2033
- context = options2.data;
2034
- }
2035
- const data = import_handlebars2.default.createFrame(context || {});
2036
- if (typeof options2 !== "object" || options2 === null) {
2037
- options2 = {};
2038
- }
2039
- if (options2.hash && typeof options2.hash === "object") {
2040
- Object.assign(data, options2.hash);
2041
- }
2042
- return options2.fn(this, { data });
2043
- }
2044
- function option(prop, locals, opts) {
2045
- return get(options(this, locals, opts), prop);
2046
- }
2047
- function noop(options2) {
2048
- return options2.fn(this);
2049
- }
2050
- var typeOf = import_kind_of.default;
2051
- function withHash(options2) {
2052
- if (options2.hash && Object.keys(options2.hash).length) {
2053
- return options2.fn(options2.hash);
2054
- }
2055
- return options2.inverse(this);
2056
- }
2057
- var helpers14 = [
2058
- {
2059
- name: "frame",
2060
- category: "misc",
2061
- compatibility: ["browser", "nodejs"],
2062
- fn: frame
2063
- },
2064
- {
2065
- name: "option",
2066
- category: "misc",
2067
- compatibility: ["browser", "nodejs"],
2068
- fn: option
2069
- },
2070
- {
2071
- name: "noop",
2072
- category: "misc",
2073
- compatibility: ["browser", "nodejs"],
2074
- fn: noop
2075
- },
2076
- {
2077
- name: "typeOf",
2078
- category: "misc",
2079
- compatibility: ["browser", "nodejs"],
2080
- fn: typeOf
2081
- },
2082
- {
2083
- name: "withHash",
2084
- category: "misc",
2085
- compatibility: ["browser", "nodejs"],
2086
- fn: withHash
2087
- }
2088
- ];
2089
-
2090
- // src/helpers/number.ts
2091
- var isNumeric2 = (value) => typeof value === "number" && !Number.isNaN(value);
2092
- var bytes = (value, precision) => {
2093
- if (value == null) return "0 B";
2094
- let num;
2095
- if (typeof value === "string") {
2096
- num = value.length;
2097
- if (!num) return "0 B";
2098
- } else if (isNumeric2(value)) {
2099
- num = Number(value);
2100
- } else if (typeof value.length === "number") {
2101
- num = value.length;
2102
- if (!num) return "0 B";
2103
- } else {
2104
- return "0 B";
2105
- }
2106
- const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 2;
2107
- const abbr = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
2108
- const factor = 10 ** prec;
2109
- for (let i = abbr.length - 1; i >= 0; i--) {
2110
- const size = 10 ** (i * 3);
2111
- if (size <= num + 1) {
2112
- const val = Math.round(num * factor / size) / factor;
2113
- return `${val} ${abbr[i]}`;
2114
- }
2115
- }
2116
- return `${num}`;
2117
- };
2118
- var addCommas = (num) => num.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
2119
- var phoneNumber = (num) => {
2120
- const str = num.toString();
2121
- return `(${str.substr(0, 3)}) ${str.substr(3, 3)}-${str.substr(6, 4)}`;
2122
- };
2123
- var toAbbr = (value, precision) => {
2124
- const num = isNumeric2(value) ? Number(value) : 0;
2125
- const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 2;
2126
- const factor = 10 ** prec;
2127
- const abbr = ["k", "m", "b", "t", "q"];
2128
- for (let i = abbr.length - 1; i >= 0; i--) {
2129
- const size = 10 ** ((i + 1) * 3);
2130
- if (size <= num + 1) {
2131
- const val = Math.round(num * factor / size) / factor;
2132
- return `${val}${abbr[i]}`;
2133
- }
2134
- }
2135
- return `${num}`;
2136
- };
2137
- var toExponential = (value, digits) => {
2138
- const num = isNumeric2(value) ? Number(value) : 0;
2139
- const d = typeof digits === "number" && !Number.isNaN(digits) ? digits : 0;
2140
- return Number(num).toExponential(d);
2141
- };
2142
- var toFixed = (value, digits) => {
2143
- const num = isNumeric2(value) ? Number(value) : 0;
2144
- const d = typeof digits === "number" && !Number.isNaN(digits) ? digits : 0;
2145
- return Number(num).toFixed(d);
2146
- };
2147
- var toFloat = (value) => parseFloat(String(value));
2148
- var toInt = (value) => parseInt(String(value), 10);
2149
- var toPrecision = (value, precision) => {
2150
- const num = isNumeric2(value) ? Number(value) : 0;
2151
- const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 1;
2152
- return Number(num).toPrecision(prec);
2153
- };
2154
- var helpers15 = [
2155
- {
2156
- name: "bytes",
2157
- category: "number",
2158
- compatibility: ["browser", "nodejs"],
2159
- fn: bytes
2160
- },
2161
- {
2162
- name: "addCommas",
2163
- category: "number",
2164
- compatibility: ["browser", "nodejs"],
2165
- fn: addCommas
2166
- },
2167
- {
2168
- name: "phoneNumber",
2169
- category: "number",
2170
- compatibility: ["browser", "nodejs"],
2171
- fn: phoneNumber
2172
- },
2173
- {
2174
- name: "toAbbr",
2175
- category: "number",
2176
- compatibility: ["browser", "nodejs"],
2177
- fn: toAbbr
2178
- },
2179
- {
2180
- name: "toExponential",
2181
- category: "number",
2182
- compatibility: ["browser", "nodejs"],
2183
- fn: toExponential
2184
- },
2185
- {
2186
- name: "toFixed",
2187
- category: "number",
2188
- compatibility: ["browser", "nodejs"],
2189
- fn: toFixed
2190
- },
2191
- {
2192
- name: "toFloat",
2193
- category: "number",
2194
- compatibility: ["browser", "nodejs"],
2195
- fn: toFloat
2196
- },
2197
- {
2198
- name: "toInt",
2199
- category: "number",
2200
- compatibility: ["browser", "nodejs"],
2201
- fn: toInt
2202
- },
2203
- {
2204
- name: "toPrecision",
2205
- category: "number",
2206
- compatibility: ["browser", "nodejs"],
2207
- fn: toPrecision
2208
- }
2209
- ];
2210
-
2211
- // src/helpers/object.ts
2212
- var isOptions2 = (value) => {
2213
- return Boolean(value && typeof value === "object" && "hash" in value);
2214
- };
2215
- var createFrame = (options2, hash) => ({
2216
- ...options2?.data || {},
2217
- ...hash
2218
- });
2219
- var extend = (...objects) => {
2220
- const args = [...objects];
2221
- if (args.length && isOptions2(args[args.length - 1])) {
2222
- const opts = args.pop();
2223
- args.push(opts.hash);
2224
- }
2225
- const result = {};
2226
- for (const obj of args) {
2227
- if (obj && typeof obj === "object" && !Array.isArray(obj)) {
2228
- Object.assign(result, obj);
2229
- }
2230
- }
2231
- return result;
2232
- };
2233
- var forIn = (obj, options2) => {
2234
- if (!isOptions2(options2)) {
2235
- return options2?.inverse?.(obj) ?? "";
2236
- }
2237
- const data = createFrame(options2, options2.hash || {});
2238
- let result = "";
2239
- for (const key in obj) {
2240
- data.key = key;
2241
- result += options2.fn(obj[key], { data });
2242
- }
2243
- return result;
2244
- };
2245
- var forOwn = (obj, options2) => {
2246
- if (!isOptions2(options2)) {
2247
- return options2?.inverse?.(obj) ?? "";
2248
- }
2249
- const data = createFrame(options2, options2.hash || {});
2250
- let result = "";
2251
- for (const key in obj) {
2252
- if (Object.hasOwn(obj, key)) {
2253
- data.key = key;
2254
- result += options2.fn(obj[key], { data });
2255
- }
2256
- }
2257
- return result;
2258
- };
2259
- var toPath = (...prop) => {
2260
- const parts = [];
2261
- for (const p of prop) {
2262
- if (typeof p === "string" || typeof p === "number") {
2263
- parts.push(p);
2264
- }
2265
- }
2266
- return parts.join(".");
2267
- };
2268
- var getHelper = (prop, context, options2) => {
2269
- const val = get(context, prop);
2270
- if (options2 && typeof options2.fn === "function") {
2271
- return val ? options2.fn(val) : options2.inverse?.(context);
2272
- }
2273
- return val;
2274
- };
2275
- var getObjectHelper = (prop, context) => {
2276
- return getObject(context, prop);
2277
- };
2278
- var hasOwn = (context, key) => {
2279
- return Object.hasOwn(context, key);
2280
- };
2281
- var isObject = (value) => {
2282
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
2283
- };
2284
- var JSONparse = (str) => {
2285
- return JSON.parse(str);
2286
- };
2287
- var JSONstringify = (obj, indent) => {
2288
- const ind = typeof indent === "number" ? indent : 0;
2289
- return JSON.stringify(obj, null, ind);
2290
- };
2291
- var merge = (context, ...objects) => {
2292
- const args = [context, ...objects];
2293
- if (args.length && isOptions2(args[args.length - 1])) {
2294
- const opts = args.pop();
2295
- args.push(opts.hash);
2296
- }
2297
- return Object.assign(...args);
2298
- };
2299
- var parseJSON = JSONparse;
2300
- var stringify = JSONstringify;
2301
- var pick = (props, context, options2) => {
2302
- const keys = arrayify(props);
2303
- let result = {};
2304
- for (const key of keys) {
2305
- result = Object.assign({}, result, getObject(context, key));
2306
- }
2307
- if (options2 && typeof options2.fn === "function") {
2308
- if (Object.keys(result).length) {
2309
- return options2.fn(result);
2310
- }
2311
- return options2.inverse?.(context);
2312
- }
2313
- return result;
2314
- };
2315
- var helpers16 = [
2316
- {
2317
- name: "extend",
2318
- category: "object",
2319
- compatibility: ["browser", "nodejs"],
2320
- fn: extend
2321
- },
2322
- {
2323
- name: "forIn",
2324
- category: "object",
2325
- compatibility: ["browser", "nodejs"],
2326
- fn: forIn
2327
- },
2328
- {
2329
- name: "forOwn",
2330
- category: "object",
2331
- compatibility: ["browser", "nodejs"],
2332
- fn: forOwn
2333
- },
2334
- {
2335
- name: "toPath",
2336
- category: "object",
2337
- compatibility: ["browser", "nodejs"],
2338
- fn: toPath
2339
- },
2340
- {
2341
- name: "get",
2342
- category: "object",
2343
- compatibility: ["browser", "nodejs"],
2344
- fn: getHelper
2345
- },
2346
- {
2347
- name: "getObject",
2348
- category: "object",
2349
- compatibility: ["browser", "nodejs"],
2350
- fn: getObjectHelper
2351
- },
2352
- {
2353
- name: "hasOwn",
2354
- category: "object",
2355
- compatibility: ["browser", "nodejs"],
2356
- fn: hasOwn
2357
- },
2358
- {
2359
- name: "isObject",
2360
- category: "object",
2361
- compatibility: ["browser", "nodejs"],
2362
- fn: isObject
2363
- },
2364
- {
2365
- name: "JSONparse",
2366
- category: "object",
2367
- compatibility: ["browser", "nodejs"],
2368
- fn: JSONparse
2369
- },
2370
- {
2371
- name: "JSONstringify",
2372
- category: "object",
2373
- compatibility: ["browser", "nodejs"],
2374
- fn: JSONstringify
2375
- },
2376
- {
2377
- name: "merge",
2378
- category: "object",
2379
- compatibility: ["browser", "nodejs"],
2380
- fn: merge
2381
- },
2382
- {
2383
- name: "parseJSON",
2384
- category: "object",
2385
- compatibility: ["browser", "nodejs"],
2386
- fn: parseJSON
2387
- },
2388
- {
2389
- name: "pick",
2390
- category: "object",
2391
- compatibility: ["browser", "nodejs"],
2392
- fn: pick
2393
- },
2394
- {
2395
- name: "stringify",
2396
- category: "object",
2397
- compatibility: ["browser", "nodejs"],
2398
- fn: stringify
2399
- }
2400
- ];
2401
-
2402
- // src/helpers/path.ts
2403
- var import_node_path5 = __toESM(require("path"), 1);
2404
- var expectedType = (variableName, expectedType2, variableValue) => {
2405
- const actualType = Object.prototype.toString.call(variableValue).slice(8, -1).toLowerCase();
2406
- return `Expected ${variableName} to be of type ${expectedType2}, but got ${actualType}`;
2407
- };
2408
- var assertString = (name, value) => {
2409
- if (typeof value !== "string") {
2410
- throw new TypeError(expectedType(name, "string", value));
2411
- }
2412
- return value;
2413
- };
2414
- var absolute = function(filepath, options2) {
2415
- const fp = assertString("filepath", filepath);
2416
- const cwd = options2?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
2417
- return import_node_path5.default.resolve(cwd, fp);
2418
- };
2419
- var dirname = (filepath) => {
2420
- const fp = assertString("filepath", filepath);
2421
- return import_node_path5.default.dirname(fp);
2422
- };
2423
- var relative = (a, b) => {
2424
- const from = assertString("first path", a);
2425
- const to = assertString("second path", b);
2426
- return import_node_path5.default.relative(import_node_path5.default.dirname(from), to);
2427
- };
2428
- var basename = (filepath) => {
2429
- const fp = assertString("filepath", filepath);
2430
- return import_node_path5.default.basename(fp);
2431
- };
2432
- var stem = (filepath) => {
2433
- const fp = assertString("filepath", filepath);
2434
- return import_node_path5.default.basename(fp, import_node_path5.default.extname(fp));
2435
- };
2436
- var extname = (filepath) => {
2437
- const fp = assertString("filepath", filepath);
2438
- return import_node_path5.default.extname(fp);
2439
- };
2440
- var resolveFn = function(filepath, ...paths) {
2441
- let options2;
2442
- const last2 = paths[paths.length - 1];
2443
- if (typeof last2 === "object" && last2 && "data" in last2) {
2444
- options2 = paths.pop();
2445
- }
2446
- const cwd = options2?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
2447
- const all2 = [
2448
- cwd,
2449
- assertString("filepath", filepath),
2450
- ...paths.map((p, i) => assertString(`path${i}`, p))
2451
- ];
2452
- return import_node_path5.default.resolve(...all2);
2453
- };
2454
- var segments = (filepath, a, b) => {
2455
- const fp = assertString("filepath", filepath);
2456
- const start = Number(a);
2457
- const end = Number(b);
2458
- const segmentsArr = fp.split(/[\\/]+/);
2459
- return segmentsArr.slice(start, end).join("/");
2460
- };
2461
- var helpers17 = [
2462
- {
2463
- name: "absolute",
2464
- category: "path",
2465
- compatibility: ["nodejs"],
2466
- fn: absolute
2467
- },
2468
- {
2469
- name: "dirname",
2470
- category: "path",
2471
- compatibility: ["nodejs"],
2472
- fn: dirname
2473
- },
2474
- {
2475
- name: "relative",
2476
- category: "path",
2477
- compatibility: ["nodejs"],
2478
- fn: relative
2479
- },
2480
- {
2481
- name: "basename",
2482
- category: "path",
2483
- compatibility: ["nodejs"],
2484
- fn: basename
2485
- },
2486
- {
2487
- name: "stem",
2488
- category: "path",
2489
- compatibility: ["nodejs"],
2490
- fn: stem
2491
- },
2492
- {
2493
- name: "extname",
2494
- category: "path",
2495
- compatibility: ["nodejs"],
2496
- fn: extname
2497
- },
2498
- {
2499
- name: "resolve",
2500
- category: "path",
2501
- compatibility: ["nodejs"],
2502
- fn: resolveFn
2503
- },
2504
- {
2505
- name: "segments",
2506
- category: "path",
2507
- compatibility: ["nodejs"],
2508
- fn: segments
2509
- }
2510
- ];
2511
-
2512
- // src/helpers/regex.ts
2513
- var toRegex = (str, locals, opts) => {
2514
- const mergedOpts = options({}, locals, opts);
2515
- return new RegExp(str, mergedOpts.flags);
2516
- };
2517
- var test = (str, regex) => {
2518
- if (typeof str !== "string") {
2519
- return false;
2520
- }
2521
- if (!(regex instanceof RegExp)) {
2522
- throw new TypeError("expected a regular expression");
2523
- }
2524
- return regex.test(str);
2525
- };
2526
- var helpers18 = [
2527
- {
2528
- name: "toRegex",
2529
- category: "regex",
2530
- compatibility: ["browser", "nodejs"],
2531
- fn: toRegex
2532
- },
2533
- {
2534
- name: "test",
2535
- category: "regex",
2536
- compatibility: ["browser", "nodejs"],
2537
- fn: test
2538
- }
2539
- ];
2540
-
2541
- // src/helpers/string.ts
2542
- var chop = (str) => str.trim().replace(/^[-_.\W\s]+|[-_.\W\s]+$/g, "");
2543
- var changecase = (str, fn) => {
2544
- if (str.length === 1) return str.toLowerCase();
2545
- const res = chop(str).toLowerCase();
2546
- return res.replace(/[-_.\W\s]+(\w|$)/g, (_, ch) => fn(ch));
2547
- };
2548
- var append = (str, suffix) => {
2549
- if (typeof str === "string" && typeof suffix === "string") {
2550
- return str + suffix;
2551
- }
2552
- return str;
2553
- };
2554
- var camelcase = (str) => typeof str === "string" ? changecase(str, (ch) => ch.toUpperCase()) : "";
2555
- var capitalize = (str) => {
2556
- if (typeof str !== "string" || str.length === 0) return "";
2557
- return str.charAt(0).toUpperCase() + str.slice(1);
2558
- };
2559
- var capitalizeAll = (str) => {
2560
- if (typeof str !== "string") return "";
2561
- return str.replace(/\w\S*/g, (word) => capitalize(word));
2562
- };
2563
- var center = (str, spaces) => {
2564
- if (typeof str !== "string") return "";
2565
- let space = "";
2566
- for (let i = 0; i < spaces; i++) {
2567
- space += "&nbsp;";
2568
- }
2569
- return space + str + space;
2570
- };
2571
- var chopStr = (str) => typeof str === "string" ? chop(str) : "";
2572
- var dashcase = (str) => typeof str === "string" ? changecase(str, (ch) => `-${ch}`) : "";
2573
- var dotcase = (str) => typeof str === "string" ? changecase(str, (ch) => `.${ch}`) : "";
2574
- var truncate = (str, limit, suffix) => {
2575
- if (typeof str === "string") {
2576
- if (typeof suffix !== "string") {
2577
- suffix = "";
2578
- }
2579
- if (str.length > limit) {
2580
- return str.slice(0, limit - suffix.length) + suffix;
2581
- }
2582
- return str;
2583
- }
2584
- return "";
2585
- };
2586
- var ellipsis = (str, limit) => {
2587
- if (typeof str === "string") {
2588
- if (str.length <= limit) {
2589
- return str;
2590
- }
2591
- return `${truncate(str, limit)}\u2026`;
2592
- }
2593
- return "";
2594
- };
2595
- var hyphenate = (str) => typeof str === "string" ? str.split(" ").join("-") : "";
2596
- var isString = (value) => typeof value === "string";
2597
- var lowercase = (str) => {
2598
- if (typeof str === "object" && str !== null && "fn" in str && typeof str.fn === "function") {
2599
- return String(str.fn()).toLowerCase();
2600
- }
2601
- if (typeof str !== "string") return "";
2602
- return str.toLowerCase();
2603
- };
2604
- var downcase = (str) => lowercase(str);
2605
- var occurrences = (str, substring) => {
2606
- if (typeof str !== "string") return "";
2607
- const len = substring.length;
2608
- let pos = str.indexOf(substring, 0);
2609
- let n = 0;
2610
- while (pos > -1) {
2611
- n++;
2612
- pos = str.indexOf(substring, pos + len);
2613
- }
2614
- return n;
2615
- };
2616
- var pascalcase = (str) => {
2617
- if (typeof str !== "string") return "";
2618
- const res = changecase(str, (ch) => ch.toUpperCase());
2619
- return res.charAt(0).toUpperCase() + res.slice(1);
2620
- };
2621
- var pathcase = (str) => typeof str === "string" ? changecase(str, (ch) => `/${ch}`) : "";
2622
- var plusify = (str, ch) => {
2623
- if (typeof str !== "string") return "";
2624
- if (typeof ch !== "string") ch = " ";
2625
- return str.split(ch).join("+");
2626
- };
2627
- var prepend = (str, prefix) => {
2628
- return typeof str === "string" && typeof prefix === "string" ? prefix + str : str;
2629
- };
2630
- var remove = (str, ch) => {
2631
- if (typeof str !== "string") return "";
2632
- if (typeof ch !== "string") return str;
2633
- return str.split(ch).join("");
2634
- };
2635
- var removeFirst = (str, ch) => {
2636
- if (typeof str !== "string") return "";
2637
- if (typeof ch !== "string") return str;
2638
- return str.replace(ch, "");
2639
- };
2640
- var replace = (str, a, b) => {
2641
- if (typeof str !== "string") return "";
2642
- if (typeof a !== "string") return str;
2643
- if (typeof b !== "string") b = "";
2644
- return str.split(a).join(b);
2645
- };
2646
- var replaceFirst = (str, a, b) => {
2647
- if (typeof str !== "string") return "";
2648
- if (typeof a !== "string") return str;
2649
- if (typeof b !== "string") b = "";
2650
- return str.replace(a, b);
2651
- };
2652
- var reverse2 = (str) => typeof str === "string" ? str.split("").reverse().join("") : "";
2653
- var sentence = (str) => {
2654
- if (typeof str !== "string") return "";
2655
- return str.replace(
2656
- /((?:\S[^.?!]*)[.?!]*)/g,
2657
- (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()
2658
- );
2659
- };
2660
- var snakecase = (str) => typeof str === "string" ? changecase(str, (ch) => `_${ch}`) : "";
2661
- var trim = (str) => typeof str === "string" ? str.trim() : "";
2662
- var trimLeft = (str) => typeof str === "string" ? str.replace(/^\s+/, "") : "";
2663
- var trimRight = (str) => typeof str === "string" ? str.replace(/\s+$/, "") : "";
2664
- var truncateWords = (str, count, suffix) => {
2665
- if (typeof str === "string" && typeof count === "number" && Number.isFinite(count)) {
2666
- if (typeof suffix !== "string") {
2667
- suffix = "...";
2668
- }
2669
- const num = Math.trunc(count);
2670
- let arr = str.split(" ");
2671
- if (num < arr.length) {
2672
- arr = arr.slice(0, num);
2673
- }
2674
- const val = arr.join(" ").trim();
2675
- return val + suffix;
2676
- }
2677
- return "";
2678
- };
2679
- var truncateWordsAlias = truncateWords;
2680
- var uppercase = (str) => {
2681
- if (typeof str === "object" && str !== null && "fn" in str && typeof str.fn === "function") {
2682
- return String(str.fn()).toUpperCase();
2683
- }
2684
- if (typeof str !== "string") return "";
2685
- return str.toUpperCase();
2686
- };
2687
- var upcase = (str) => uppercase(str);
2688
- var split = (str, character) => {
2689
- if (typeof str !== "string") return "";
2690
- if (typeof character !== "string") character = "";
2691
- return str.split(character);
2692
- };
2693
- var startsWith = (prefix, testString, _options) => {
2694
- if (typeof prefix !== "string" || typeof testString !== "string") {
2695
- return false;
2696
- }
2697
- return testString.startsWith(prefix);
2698
- };
2699
- var titleize = (str) => {
2700
- if (typeof str !== "string") return "";
2701
- return str.replace(/\w\S*/g, (word) => {
2702
- return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
2703
- });
2704
- };
2705
- var raw = (options2) => {
2706
- if (options2 && typeof options2.fn === "function") {
2707
- return options2.fn();
2708
- }
2709
- return "";
2710
- };
2711
- var helpers19 = [
2712
- {
2713
- name: "append",
2714
- category: "string",
2715
- compatibility: ["browser", "nodejs"],
2716
- fn: append
2717
- },
2718
- {
2719
- name: "camelcase",
2720
- category: "string",
2721
- compatibility: ["browser", "nodejs"],
2722
- fn: camelcase
2723
- },
2724
- {
2725
- name: "capitalize",
2726
- category: "string",
2727
- compatibility: ["browser", "nodejs"],
2728
- fn: capitalize
2729
- },
2730
- {
2731
- name: "capitalizeAll",
2732
- category: "string",
2733
- compatibility: ["browser", "nodejs"],
2734
- fn: capitalizeAll
2735
- },
2736
- {
2737
- name: "center",
2738
- category: "string",
2739
- compatibility: ["browser", "nodejs"],
2740
- fn: center
2741
- },
2742
- {
2743
- name: "chop",
2744
- category: "string",
2745
- compatibility: ["browser", "nodejs"],
2746
- fn: chopStr
2747
- },
2748
- {
2749
- name: "dashcase",
2750
- category: "string",
2751
- compatibility: ["browser", "nodejs"],
2752
- fn: dashcase
2753
- },
2754
- {
2755
- name: "dotcase",
2756
- category: "string",
2757
- compatibility: ["browser", "nodejs"],
2758
- fn: dotcase
2759
- },
2760
- {
2761
- name: "ellipsis",
2762
- category: "string",
2763
- compatibility: ["browser", "nodejs"],
2764
- fn: ellipsis
2765
- },
2766
- {
2767
- name: "hyphenate",
2768
- category: "string",
2769
- compatibility: ["browser", "nodejs"],
2770
- fn: hyphenate
2771
- },
2772
- {
2773
- name: "isString",
2774
- category: "string",
2775
- compatibility: ["browser", "nodejs"],
2776
- fn: isString
2777
- },
2778
- {
2779
- name: "lowercase",
2780
- category: "string",
2781
- compatibility: ["browser", "nodejs"],
2782
- fn: lowercase
2783
- },
2784
- {
2785
- name: "downcase",
2786
- category: "string",
2787
- compatibility: ["browser", "nodejs"],
2788
- fn: downcase
2789
- },
2790
- {
2791
- name: "occurrences",
2792
- category: "string",
2793
- compatibility: ["browser", "nodejs"],
2794
- fn: occurrences
2795
- },
2796
- {
2797
- name: "pascalcase",
2798
- category: "string",
2799
- compatibility: ["browser", "nodejs"],
2800
- fn: pascalcase
2801
- },
2802
- {
2803
- name: "pathcase",
2804
- category: "string",
2805
- compatibility: ["browser", "nodejs"],
2806
- fn: pathcase
2807
- },
2808
- {
2809
- name: "plusify",
2810
- category: "string",
2811
- compatibility: ["browser", "nodejs"],
2812
- fn: plusify
2813
- },
2814
- {
2815
- name: "prepend",
2816
- category: "string",
2817
- compatibility: ["browser", "nodejs"],
2818
- fn: prepend
2819
- },
2820
- {
2821
- name: "remove",
2822
- category: "string",
2823
- compatibility: ["browser", "nodejs"],
2824
- fn: remove
2825
- },
2826
- {
2827
- name: "removeFirst",
2828
- category: "string",
2829
- compatibility: ["browser", "nodejs"],
2830
- fn: removeFirst
2831
- },
2832
- {
2833
- name: "replace",
2834
- category: "string",
2835
- compatibility: ["browser", "nodejs"],
2836
- fn: replace
2837
- },
2838
- {
2839
- name: "replaceFirst",
2840
- category: "string",
2841
- compatibility: ["browser", "nodejs"],
2842
- fn: replaceFirst
2843
- },
2844
- {
2845
- name: "reverse",
2846
- category: "string",
2847
- compatibility: ["browser", "nodejs"],
2848
- fn: reverse2
2849
- },
2850
- {
2851
- name: "sentence",
2852
- category: "string",
2853
- compatibility: ["browser", "nodejs"],
2854
- fn: sentence
2855
- },
2856
- {
2857
- name: "snakecase",
2858
- category: "string",
2859
- compatibility: ["browser", "nodejs"],
2860
- fn: snakecase
2861
- },
2862
- {
2863
- name: "trim",
2864
- category: "string",
2865
- compatibility: ["browser", "nodejs"],
2866
- fn: trim
2867
- },
2868
- {
2869
- name: "trimLeft",
2870
- category: "string",
2871
- compatibility: ["browser", "nodejs"],
2872
- fn: trimLeft
2873
- },
2874
- {
2875
- name: "trimRight",
2876
- category: "string",
2877
- compatibility: ["browser", "nodejs"],
2878
- fn: trimRight
2879
- },
2880
- {
2881
- name: "truncate",
2882
- category: "string",
2883
- compatibility: ["browser", "nodejs"],
2884
- fn: truncate
2885
- },
2886
- {
2887
- name: "truncateWords",
2888
- category: "string",
2889
- compatibility: ["browser", "nodejs"],
2890
- fn: truncateWordsAlias
2891
- },
2892
- {
2893
- name: "uppercase",
2894
- category: "string",
2895
- compatibility: ["browser", "nodejs"],
2896
- fn: uppercase
2897
- },
2898
- {
2899
- name: "upcase",
2900
- category: "string",
2901
- compatibility: ["browser", "nodejs"],
2902
- fn: upcase
2903
- },
2904
- {
2905
- name: "split",
2906
- category: "string",
2907
- compatibility: ["browser", "nodejs"],
2908
- fn: split
2909
- },
2910
- {
2911
- name: "startsWith",
2912
- category: "string",
2913
- compatibility: ["browser", "nodejs"],
2914
- fn: startsWith
2915
- },
2916
- {
2917
- name: "titleize",
2918
- category: "string",
2919
- compatibility: ["browser", "nodejs"],
2920
- fn: titleize
2921
- },
2922
- {
2923
- name: "raw",
2924
- category: "string",
2925
- compatibility: ["browser", "nodejs"],
2926
- fn: raw
2927
- }
2928
- ];
2929
-
2930
- // src/helpers/url.ts
2931
- var import_node_querystring = require("querystring");
2932
- var import_node_url = require("url");
2933
- var all = ["browser", "nodejs"];
2934
- var encodeUri = (str) => {
2935
- if (typeof str === "string") {
2936
- return encodeURIComponent(str);
2937
- }
2938
- };
2939
- var escapeFn = (str) => {
2940
- if (typeof str === "string") {
2941
- return (0, import_node_querystring.escape)(str);
2942
- }
2943
- };
2944
- var decodeUri = (str) => {
2945
- if (typeof str === "string") {
2946
- return decodeURIComponent(str);
2947
- }
2948
- };
2949
- function urlEncode(...args) {
2950
- return encodeUri.apply(this, args);
2951
- }
2952
- function urlDecode(...args) {
2953
- return decodeUri.apply(this, args);
2954
- }
2955
- var urlResolve = (base, href) => (0, import_node_url.resolve)(String(base), String(href));
2956
- var urlParse = (str) => (0, import_node_url.parse)(String(str));
2957
- var stripQuerystring = (str) => {
2958
- if (typeof str === "string") {
2959
- return str.split("?")[0];
2960
- }
2961
- };
2962
- var stripProtocol = (str) => {
2963
- if (typeof str === "string") {
2964
- const parsed = (0, import_node_url.parse)(str);
2965
- parsed.protocol = "";
2966
- return (0, import_node_url.format)(parsed);
2967
- }
2968
- };
2969
- var helpers20 = [
2970
- {
2971
- name: "encodeURI",
2972
- category: "url",
2973
- compatibility: all,
2974
- fn: encodeUri
2975
- },
2976
- {
2977
- name: "escape",
2978
- category: "url",
2979
- compatibility: ["nodejs"],
2980
- fn: escapeFn
2981
- },
2982
- {
2983
- name: "decodeURI",
2984
- category: "url",
2985
- compatibility: all,
2986
- fn: decodeUri
2987
- },
2988
- {
2989
- name: "url_encode",
2990
- category: "url",
2991
- compatibility: all,
2992
- fn: urlEncode
2993
- },
2994
- {
2995
- name: "url_decode",
2996
- category: "url",
2997
- compatibility: all,
2998
- fn: urlDecode
2999
- },
3000
- {
3001
- name: "urlResolve",
3002
- category: "url",
3003
- compatibility: ["nodejs"],
3004
- fn: urlResolve
3005
- },
3006
- {
3007
- name: "urlParse",
3008
- category: "url",
3009
- compatibility: ["nodejs"],
3010
- fn: urlParse
3011
- },
3012
- {
3013
- name: "stripQuerystring",
3014
- category: "url",
3015
- compatibility: all,
3016
- fn: stripQuerystring
3017
- },
3018
- {
3019
- name: "stripProtocol",
3020
- category: "url",
3021
- compatibility: ["nodejs"],
3022
- fn: stripProtocol
3023
- }
3024
- ];
3025
-
3026
- // src/helper-registry.ts
3027
- var HelperRegistry = class {
3028
- _helpers = [];
3029
- constructor() {
3030
- this.init();
3031
- }
3032
- /**
3033
- * Get all registered helpers.
3034
- * @returns {Helper[]} The array of registered helpers.
3035
- */
3036
- get helpers() {
3037
- return this._helpers;
3038
- }
3039
- /**
3040
- * Initialize the helper registry. This is performed during the construction of the registry such as new HelperRegistry().
3041
- */
3042
- init() {
3043
- this.registerHelpers(helpers);
3044
- this.registerHelpers(helpers3);
3045
- this.registerHelpers(helpers5);
3046
- this.registerHelpers(helpers6);
3047
- this.registerHelpers(helpers2);
3048
- this.registerHelpers(helpers13);
3049
- this.registerHelpers(helpers7);
3050
- this.registerHelpers(helpers4);
3051
- this.registerHelpers(helpers8);
3052
- this.registerHelpers(helpers9);
3053
- this.registerHelpers(helpers10);
3054
- this.registerHelpers(helpers11);
3055
- this.registerHelpers(helpers12);
3056
- this.registerHelpers(helpers14);
3057
- this.registerHelpers(helpers15);
3058
- this.registerHelpers(helpers17);
3059
- this.registerHelpers(helpers18);
3060
- this.registerHelpers(helpers19);
3061
- this.registerHelpers(helpers20);
3062
- this.registerHelpers(helpers16);
3063
- }
3064
- /**
3065
- * Register a helper.
3066
- * @param {Helper} helper The helper to register.
3067
- * @returns True if the helper was registered, false otherwise.
3068
- */
3069
- register(helper) {
3070
- const result = false;
3071
- if (!this.has(helper.name)) {
3072
- this._helpers.push(helper);
3073
- }
3074
- return result;
3075
- }
3076
- /**
3077
- * Register multiple helpers.
3078
- * @param {Helper[]} helpers The array of helpers to register.
3079
- */
3080
- registerHelpers(helpers22) {
3081
- for (const helper of helpers22) {
3082
- this.register(helper);
3083
- }
3084
- }
3085
- /**
3086
- * Check if a helper is registered.
3087
- * @param name The name of the helper.
3088
- * @returns True if the helper is registered, false otherwise.
3089
- */
3090
- has(name) {
3091
- return this._helpers.some((helper) => helper.name === name);
3092
- }
3093
- /**
3094
- * Filter helpers by the given criteria.
3095
- * @param filter The filter criteria.
3096
- * @returns The filtered helpers.
3097
- */
3098
- filter(filter2) {
3099
- let result = this._helpers;
3100
- if (filter2.names) {
3101
- result = result.filter((helper) => filter2.names?.includes(helper.name));
3102
- }
3103
- if (filter2.categories) {
3104
- result = result.filter(
3105
- (helper) => filter2.categories?.includes(helper.category)
3106
- );
3107
- }
3108
- if (filter2.compatibility) {
3109
- result = result.filter(
3110
- (helper) => helper.compatibility?.some((c) => filter2.compatibility?.includes(c))
3111
- );
3112
- }
3113
- return result;
3114
- }
3115
- /**
3116
- * Load Handlebars helpers.
3117
- * @param {Handlebars} handlebars The Handlebars instance.
3118
- * @returns {void}
3119
- */
3120
- load(handlebars2, filters) {
3121
- let helpers22 = this._helpers;
3122
- if (filters) {
3123
- helpers22 = this.filter(filters);
3124
- }
3125
- for (const helper of helpers22) {
3126
- handlebars2.registerHelper(helper.name, helper.fn);
3127
- }
3128
- }
3129
- /**
3130
- * Swap Handlebars helpers. This is used when you want to swap out legacy helpers for fumanchu helpers.
3131
- * @param handlebars The Handlebars instance.
3132
- * @returns {void}
3133
- */
3134
- swap(handlebars2) {
3135
- for (const helper of this._helpers) {
3136
- handlebars2.unregisterHelper(helper.name);
3137
- handlebars2.registerHelper(helper.name, helper.fn);
3138
- }
3139
- }
3140
- };
3141
-
3142
- // src/index.ts
3143
- var Handlebars3 = import_handlebars3.default;
3144
- var handlebars = import_handlebars3.default.create();
3145
- function helpers21(options2) {
3146
- const registry = new HelperRegistry();
3147
- registry.load(options2.handlebars ?? options2.hbs);
3148
- }
3149
- async function createHandlebars() {
3150
- const registry = new HelperRegistry();
3151
- const handlebars2 = import_handlebars3.default.create();
3152
- if (Object.keys(import_handlebars3.default.partials).length > 0) {
3153
- handlebars2.registerPartial(import_handlebars3.default.partials);
3154
- }
3155
- registry.load(handlebars2);
3156
- if (process.env.NODE_ENV === "development") {
3157
- console.warn(
3158
- "createHandlebars will be deprecated in future versions, use `fumanchu` instead."
3159
- );
3160
- }
3161
- return handlebars2;
3162
- }
3163
- function fumanchu(options2) {
3164
- const registry = new HelperRegistry();
3165
- let handlebars2 = import_handlebars3.default.create();
3166
- if (options2?.handlebars) {
3167
- handlebars2 = options2.handlebars;
3168
- } else if (Object.keys(import_handlebars3.default.partials).length > 0) {
3169
- handlebars2.registerPartial(import_handlebars3.default.partials);
3170
- }
3171
- registry.load(handlebars2);
3172
- if (options2?.caching) {
3173
- let cache;
3174
- if (options2.caching instanceof import_memory.CacheableMemory) {
3175
- cache = options2.caching;
3176
- } else if (typeof options2.caching === "object") {
3177
- cache = new import_memory.CacheableMemory({
3178
- useClone: false,
3179
- ...options2.caching
3180
- });
3181
- } else {
3182
- cache = new import_memory.CacheableMemory({ useClone: false });
3183
- }
3184
- const originalCompile = handlebars2.compile.bind(handlebars2);
3185
- handlebars2.compile = (input, compileOptions) => {
3186
- const key = compileOptions ? input + JSON.stringify(compileOptions) : String(input);
3187
- const cached = cache.get(key);
3188
- if (cached) {
3189
- return cached;
3190
- }
3191
- const compiled = originalCompile(input, compileOptions);
3192
- cache.set(key, compiled);
3193
- return compiled;
3194
- };
3195
- }
3196
- return handlebars2;
3197
- }
3198
- // Annotate the CommonJS export names for ESM import in node:
3199
- 0 && (module.exports = {
3200
- CacheableMemory,
3201
- Handlebars,
3202
- HelperRegistry,
3203
- createHandlebars,
3204
- fumanchu,
3205
- handlebars,
3206
- helpers
3207
- });
3208
- /* v8 ignore next -- @preserve */
3209
- /* c8 ignore next -- @preserve */