webfont 11.2.26 → 12.1.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.
Files changed (80) hide show
  1. package/NOTICE.md +165 -0
  2. package/README.md +302 -34
  3. package/dist/browser.js +4 -0
  4. package/dist/cli.mjs +893 -0
  5. package/dist/index.js +1 -507
  6. package/dist/parseTemplateOption-5T7rSw5J.mjs +20 -0
  7. package/dist/parseTemplateOption-BmH_pcQh.js +1 -0
  8. package/dist/renderTemplates-DvRlS58E.mjs +93 -0
  9. package/dist/renderTemplates-zCYCzeOt.js +1 -0
  10. package/dist/src/browser.d.ts +2 -0
  11. package/dist/src/index.d.ts +4 -2
  12. package/dist/src/lib/applyOptimizeSvgToGlyphs.d.ts +3 -0
  13. package/dist/src/lib/evenoddFillRule.d.ts +2 -0
  14. package/dist/src/lib/execCLI/index.d.ts +3 -4
  15. package/dist/src/lib/inputSource.d.ts +2 -0
  16. package/dist/src/lib/inputSourceUtils.d.ts +4 -0
  17. package/dist/src/lib/largeFontLigatures.d.ts +4 -0
  18. package/dist/src/lib/optimizeSvgGlyphs.d.ts +4 -0
  19. package/dist/src/lib/p-limit/index.d.ts +2 -0
  20. package/dist/src/lib/parseFormats.d.ts +4 -0
  21. package/dist/src/lib/parseTemplateOption.d.ts +2 -0
  22. package/dist/src/lib/runtimeEnvironment.d.ts +4 -0
  23. package/dist/src/lib/sfnt/flavor.d.ts +2 -0
  24. package/dist/src/lib/svgDiagnostics/diagnoseSvgContents.d.ts +12 -0
  25. package/dist/src/lib/svgFontOutput/emptyGlyphPaths.d.ts +3 -0
  26. package/dist/src/lib/svgTools/applySvgDiagnostics.d.ts +13 -0
  27. package/dist/src/lib/svgTools/applySvgTools.d.ts +14 -0
  28. package/dist/src/lib/svgTools/normalizeSvgToolsOptions.d.ts +2 -0
  29. package/dist/src/lib/svgicons2svgfont/index.d.ts +14 -0
  30. package/dist/src/lib/svgicons2svgfont/metadataFromSrcPath.d.ts +11 -0
  31. package/dist/src/lib/templateUnicodeRange.d.ts +4 -0
  32. package/dist/src/lib/ttf2eot/index.d.ts +2 -0
  33. package/dist/src/lib/ttfEncode.d.ts +5 -0
  34. package/dist/src/standalone/convertTtfInput.d.ts +3 -0
  35. package/dist/src/standalone/convertWebfontInput.d.ts +3 -0
  36. package/dist/src/standalone/defaultOptions.d.ts +3 -0
  37. package/dist/src/standalone/fetchWebfontUrl.d.ts +1 -0
  38. package/dist/src/standalone/generateSvgFont.d.ts +2 -0
  39. package/dist/src/standalone/getGlyphsDataFromInputs.d.ts +3 -0
  40. package/dist/src/standalone/glyphsData.d.ts +2 -2
  41. package/dist/src/standalone/index.d.ts +8 -3
  42. package/dist/src/standalone/inputMode.d.ts +9 -0
  43. package/dist/src/standalone/options.d.ts +3 -3
  44. package/dist/src/standalone/optionsFromGlyphs.d.ts +3 -0
  45. package/dist/src/standalone/renderTemplates.d.ts +10 -0
  46. package/dist/src/standalone/runSvgPipeline.d.ts +3 -0
  47. package/dist/src/standalone/templateFonts.d.ts +3 -0
  48. package/dist/src/standalone/toTtf.d.ts +4 -0
  49. package/dist/src/standalone/validateWebfontOptions.d.ts +6 -0
  50. package/dist/src/standalone/webfontFromGlyphs.d.ts +3 -0
  51. package/dist/src/types/DecompressedFont.d.ts +5 -0
  52. package/dist/src/types/Format.d.ts +4 -4
  53. package/dist/src/types/GlyphContentTransformFn.d.ts +2 -0
  54. package/dist/src/types/GlyphData.d.ts +2 -2
  55. package/dist/src/types/GlyphInput.d.ts +6 -0
  56. package/dist/src/types/GlyphMetadata.d.ts +1 -1
  57. package/dist/src/types/GlyphTransformFn.d.ts +2 -2
  58. package/dist/src/types/InitialOptions.d.ts +7 -4
  59. package/dist/src/types/MetadataProvider.d.ts +5 -0
  60. package/dist/src/types/OptionsBase.d.ts +12 -3
  61. package/dist/src/types/RenderedTemplate.d.ts +7 -0
  62. package/dist/src/types/Result.d.ts +16 -5
  63. package/dist/src/types/ResultConfig.d.ts +4 -0
  64. package/dist/src/types/SvgToolsOptions.d.ts +13 -0
  65. package/dist/src/types/TranscodedFont.d.ts +7 -0
  66. package/dist/src/types/WebfontFromGlyphsOptions.d.ts +11 -0
  67. package/dist/src/types/WebfontOptions.d.ts +39 -3
  68. package/dist/src/types/index.d.ts +8 -6
  69. package/package.json +65 -57
  70. package/templates/template.css.njk +6 -3
  71. package/templates/template.html.njk +15 -4
  72. package/templates/template.scss.njk +6 -3
  73. package/templates/template.styl.njk +6 -3
  74. package/dist/cli.js +0 -801
  75. package/dist/jest.config.d.ts +0 -3
  76. package/dist/src/cli/index.d.ts +0 -1
  77. package/dist/src/cli/index.test.d.ts +0 -1
  78. package/dist/src/cli/meow/index.d.ts +0 -104
  79. package/dist/src/index.test.d.ts +0 -1
  80. package/dist/src/standalone/index.test.d.ts +0 -1
package/dist/cli.mjs ADDED
@@ -0,0 +1,893 @@
1
+ #!/usr/bin/env node
2
+ import { fileURLToPath as e } from "node:url";
3
+ const t = e(import.meta.url);
4
+ e(new URL(".", import.meta.url));
5
+ import { t as n } from "./parseTemplateOption-5T7rSw5J.mjs";
6
+ import { pathToFileURL as r } from "node:url";
7
+ import i from "meow";
8
+ import * as a from "fs";
9
+ import { createReadStream as o } from "fs";
10
+ import * as s from "path";
11
+ import c from "path";
12
+ import l from "resolve-from";
13
+ import { globby as u } from "globby";
14
+ import { cosmiconfig as d } from "cosmiconfig";
15
+ import f from "deepmerge";
16
+ import * as p from "fs/promises";
17
+ import ee from "ttf2woff";
18
+ import te from "wawoff2";
19
+ import ne from "ttf2eot";
20
+ import re from "fontverter";
21
+ import m from "xml2js";
22
+ import h from "p-limit";
23
+ import { SVGIcons2SVGFontStream as g, fileSorter as _, getMetadataService as ie } from "svgicons2svgfont";
24
+ import ae from "crypto";
25
+ import { optimize as oe } from "svgo";
26
+ import { Readable as se } from "stream";
27
+ import ce from "svg2ttf";
28
+ //#region \0rolldown/runtime.js
29
+ var le = Object.create, v = Object.defineProperty, ue = Object.getOwnPropertyDescriptor, de = Object.getOwnPropertyNames, fe = Object.getPrototypeOf, pe = Object.prototype.hasOwnProperty, y = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), me = (e, t, n, r) => {
30
+ if (t && typeof t == "object" || typeof t == "function") for (var i = de(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !pe.call(e, s) && s !== n && v(e, s, {
31
+ get: ((e) => t[e]).bind(null, s),
32
+ enumerable: !(r = ue(t, s)) || r.enumerable
33
+ });
34
+ return e;
35
+ }, b = (e, t, n) => (n = e == null ? {} : le(fe(e)), me(t || !e || !e.__esModule ? v(n, "default", {
36
+ value: e,
37
+ enumerable: !0
38
+ }) : n, e)), he = {
39
+ name: "webfont",
40
+ version: "12.1.0",
41
+ description: "Generator of fonts from SVG icons; decompress WOFF/WOFF2 to embedded TTF/OTF (not TTF↔OTF transcoding)",
42
+ directories: {
43
+ lib: "dist",
44
+ source: "src"
45
+ },
46
+ files: [
47
+ "dist",
48
+ "dist/src/index.d.ts",
49
+ "templates",
50
+ "!**/__tests__",
51
+ "!**/__mocks__",
52
+ "README.md",
53
+ "NOTICE.md"
54
+ ],
55
+ main: "dist/index.js",
56
+ browser: "dist/browser.js",
57
+ bin: "dist/cli.mjs",
58
+ source: "src/index.ts",
59
+ types: "dist/src/index.d.ts",
60
+ typings: "dist/src/index.d.ts",
61
+ exports: {
62
+ ".": {
63
+ node: {
64
+ import: "./dist/index.js",
65
+ require: "./dist/index.js"
66
+ },
67
+ default: "./dist/browser.js"
68
+ },
69
+ "./package.json": "./package.json"
70
+ },
71
+ scripts: {
72
+ build: "vite build --mode library && vite build --mode browser && vite build --mode cli",
73
+ clean: "rm -rf dist/ temp/",
74
+ demo: "node dist/cli.mjs './src/fixtures/svg-icons/*.svg' -d demo -t html --normalize --center-horizontally",
75
+ lint: "biome check .",
76
+ depcheck: "knip",
77
+ prebuild: "npm run clean && npm run lint",
78
+ prepare: "lefthook install",
79
+ predemo: "npm run build",
80
+ prepublishOnly: "npm run build",
81
+ pretest: "npm run build",
82
+ prettify: "biome check --write .",
83
+ test: "vitest run src",
84
+ testc: "vitest run src --coverage",
85
+ "test-debug": "vitest run src --no-file-parallelism",
86
+ testu: "vitest run src -u",
87
+ "deprecate-pre-12": "npm deprecate 'webfont@>=10.0.0 <12.0.0' 'Deprecated: upgrade to webfont@12. v10–11 enabled ligatures by default (browser hangs on large fonts, #558). 12.x: ligatures off, Node 12+, named import, unicode-range off, template fixes. See MIGRATION.md'"
88
+ },
89
+ dependencies: {
90
+ cosmiconfig: "9.0.2",
91
+ deepmerge: "^4.2.2",
92
+ fontverter: "2.0.0",
93
+ globby: "16.2.0",
94
+ meow: "14.1.0",
95
+ nunjucks: "3.2.4",
96
+ "p-limit": "7.3.0",
97
+ "resolve-from": "^5.0.0",
98
+ svg2ttf: "^6.1.0",
99
+ svgicons2svgfont: "^16.0.0",
100
+ svgo: "4.0.1",
101
+ ttf2eot: "3.1.0",
102
+ ttf2woff: "^3.0.0",
103
+ wawoff2: "2.0.0",
104
+ xml2js: "0.6.2"
105
+ },
106
+ devDependencies: {
107
+ "@biomejs/biome": "2.5.2",
108
+ "@types/node": "^22.15.0",
109
+ "@types/nunjucks": "3.2.6",
110
+ "@types/rimraf": "latest",
111
+ "@types/svg2ttf": "5.0.3",
112
+ "@types/ttf2eot": "2.0.2",
113
+ "@types/ttf2woff": "2.0.4",
114
+ "@types/wawoff2": "1.0.2",
115
+ "@types/xml2js": "0.4.14",
116
+ "@vitest/coverage-v8": "4.1.9",
117
+ "fast-glob": "3.2.12",
118
+ "is-eot": "latest",
119
+ "is-svg": "6.1.0",
120
+ "is-ttf": "latest",
121
+ "is-woff": "latest",
122
+ "is-woff2": "latest",
123
+ knip: "6.24.0",
124
+ lefthook: "2.1.9",
125
+ rimraf: "latest",
126
+ typescript: "6.0.3",
127
+ vite: "8.1.3",
128
+ "vite-plugin-checker": "0.14.4",
129
+ "vite-plugin-dts": "5.0.3",
130
+ vitest: "4.1.9"
131
+ },
132
+ overrides: {
133
+ "fast-glob": "3.2.12",
134
+ minimatch: "10.2.5",
135
+ "test-exclude": "7.0.2",
136
+ "woff2sfnt-sfnt2woff": "1.0.0"
137
+ },
138
+ repository: {
139
+ type: "git",
140
+ url: "git+https://github.com/itgalaxy/webfont.git"
141
+ },
142
+ author: "itgalaxy <development@itgalaxy.company>",
143
+ license: "MIT",
144
+ contributors: [{
145
+ name: "Alexander Krasnoyarov",
146
+ email: "alexander.krasnoyarov@itgalaxy.company",
147
+ url: "https://vk.com/sterling_archer"
148
+ }, {
149
+ name: "Jimmy Andrade",
150
+ email: "webfont@jimmyandrade.com",
151
+ url: "https://github.com/jimmyandrade"
152
+ }],
153
+ bugs: { url: "https://github.com/itgalaxy/webfont/issues" },
154
+ homepage: "https://github.com/itgalaxy/webfont#readme",
155
+ engines: { node: ">= 24.14.0" },
156
+ keywords: [
157
+ "cli",
158
+ "standalone",
159
+ "font",
160
+ "fonts",
161
+ "webfont",
162
+ "webfonts",
163
+ "svg",
164
+ "ttf",
165
+ "woff",
166
+ "woff2",
167
+ "otf",
168
+ "ttf2eot",
169
+ "ttf2woff",
170
+ "ttf2svg",
171
+ "svg2ttf",
172
+ "css",
173
+ "scss",
174
+ "builder",
175
+ "generator"
176
+ ]
177
+ }, ge = "\n Usage: webfont [input] [options]\n\n Input: File(s) or glob(s).\n\n SVG icons: one or more `.svg` files (default pipeline).\n Webfont decompression: one or more `.woff` / `.woff2` paths, globs, or http(s) URLs.\n You must have rights to any font file you process (see NOTICE.md).\n\n If an input argument is wrapped in quotation marks, it will be passed to \"fast-glob\"\n for cross-platform glob support.\n\n Options:\n\n --config\n\n Path to a specific configuration file (JSON, YAML, or CommonJS)\n or the name of a module in `node_modules` that points to one.\n If no `--config` argument is provided, webfont will search for\n configuration files in the following places, in this order:\n - a `webfont` property in `package.json`\n - a `.webfontrc` file (with or without filename extension:\n `.json`, `.yaml`, and `.js` are available)\n - a `webfont.config.js` file exporting a JS object\n The search will begin in the working directory and move up the\n directory tree until a configuration file is found.\n\n -u, --fontName\n\n The font family name you want, default: \"webfont\".\n\n -h, --help\n\n Output usage information.\n\n -v, --version\n\n Output the version number.\n\n -f, --formats\n\n Font formats to generate. Pass a JSON array (e.g. '[\"woff2\"]') or a\n comma-separated list (e.g. woff2 or svg, ttf, woff2).\n SVG input: svg, ttf, eot, woff, woff2 (not otf).\n WOFF/WOFF2 input: ttf and/or otf matching the embedded SFNT flavor.\n\n -d, --dest\n\n Destination for generated fonts.\n\n -m, --dest-create\n\n Create destination directory if it does not exist.\n\n -t, --template\n\n Built-in template name(s) ('css', 'scss', 'styl', 'html', 'json') or path to a custom template.\n Pass a JSON array (e.g. '[\"html\",\"scss\"]') or comma-separated list for multiple outputs.\n\n -s, --destTemplate\n\n Destination for generated template. If not passed used `dest` argument value.\n\n -c, --templateClassName\n\n Class name in css template.\n\n -p, --templateFontPath\n\n Font path in css template.\n\n -n, --templateFontName\n\n Font name in css template.\n\n --templateCacheString\n\n Specify cache string in scss/css template.\n\n --no-sort\n\n Keeps the files in the same order of entry\n\n --ligatures\n\n Add OpenType ligature glyphs (icon names as text). Off by default — large\n icon sets can hang Firefox on Windows (#558). Prefer class + codepoint CSS.\n\n --unicode-range\n\n Emit unicode-range in built-in @font-face rules (computed from glyph code points).\n Off by default — enabling may prevent ligature names from rendering; see README.\n\n --no-template-font-ligatures\n\n Omit font-feature-settings: \"liga\" from the built-in HTML preview template\n\n --optimize-svg\n\n Run a conservative SVGO pass on each SVG before font generation\n (does not convert strokes to fills; use glyphContentTransformFn for that)\n\n --verbose\n\n Tell me everything!.\n\n --svg-diagnose\n\n (Alpha) Scan SVG icons for icon-font incompatibilities (stroke-only paths,\n fill-rule: evenodd, unsupported elements) and log warnings.\n\n For \"svgicons2svgfont\":\n\n --fontId\n\n The font id you want, default as \"--fontName\".\n\n --fontStyle\n\n The font style you want.\n\n --fontWeight\n\n The font weight you want.\n\n --fixedWidth\n\n Creates a monospace font of the width of the largest input icon.\n\n --centerHorizontally\n\n Calculate the bounds of a glyph and center it horizontally.\n\n --normalize\n\n Normalize icons by scaling them to the height of the highest icon.\n\n --fontHeight\n\n The outputted font height [MAX(icons.height)].\n\n --round\n\n Setup the SVG path rounding [10e12].\n\n --descent\n\n The font descent [0].\n\n --ascent\n\n The font ascent [height - descent].\n\n --startUnicode\n\n The start unicode codepoint for files without prefix [0xEA01].\n\n --prependUnicode\n\n Prefix files with their automatically allocated unicode codepoint.\n\n --metadata\n\n Content of the metadata tag.\n\n --addHashInFontUrl\n\n Append an MD5 content hash to font URLs in built-in templates\n (?v=[hash]) while keeping output filenames stable (fontName.woff2, etc.).\n Use with a fixed fontName — do not randomize fontName for cache busting.\n", _e = {
178
+ ascent: { type: "string" },
179
+ centerHorizontally: { type: "boolean" },
180
+ config: { type: "string" },
181
+ descent: { type: "string" },
182
+ dest: {
183
+ shortFlag: "d",
184
+ default: process.cwd(),
185
+ type: "string"
186
+ },
187
+ destCreate: {
188
+ shortFlag: "m",
189
+ default: !1,
190
+ type: "boolean"
191
+ },
192
+ destTemplate: {
193
+ shortFlag: "s",
194
+ type: "string"
195
+ },
196
+ fixedWidth: { type: "boolean" },
197
+ fontHeight: { type: "string" },
198
+ fontId: { type: "string" },
199
+ fontName: {
200
+ shortFlag: "u",
201
+ type: "string"
202
+ },
203
+ fontStyle: { type: "string" },
204
+ fontWeight: { type: "string" },
205
+ formats: {
206
+ shortFlag: "f",
207
+ type: "string"
208
+ },
209
+ help: {
210
+ shortFlag: "h",
211
+ type: "boolean"
212
+ },
213
+ ligatures: {
214
+ default: !1,
215
+ type: "boolean"
216
+ },
217
+ metadata: { type: "string" },
218
+ normalize: { type: "boolean" },
219
+ prependUnicode: { type: "boolean" },
220
+ round: { type: "string" },
221
+ sort: {
222
+ default: !0,
223
+ type: "boolean"
224
+ },
225
+ startUnicode: { type: "string" },
226
+ template: {
227
+ shortFlag: "t",
228
+ type: "string"
229
+ },
230
+ templateClassName: {
231
+ shortFlag: "c",
232
+ type: "string"
233
+ },
234
+ templateFontName: {
235
+ shortFlag: "n",
236
+ type: "string"
237
+ },
238
+ addHashInFontUrl: {
239
+ default: !1,
240
+ type: "boolean"
241
+ },
242
+ optimizeSvg: {
243
+ default: !1,
244
+ type: "boolean"
245
+ },
246
+ templateFontPath: {
247
+ shortFlag: "p",
248
+ type: "string"
249
+ },
250
+ templateCacheString: {
251
+ default: "",
252
+ type: "string"
253
+ },
254
+ unicodeRange: {
255
+ default: !1,
256
+ type: "boolean"
257
+ },
258
+ templateFontLigatures: {
259
+ default: !0,
260
+ type: "boolean"
261
+ },
262
+ verbose: {
263
+ default: !1,
264
+ type: "boolean"
265
+ },
266
+ svgDiagnose: {
267
+ default: !1,
268
+ type: "boolean"
269
+ },
270
+ version: {
271
+ shortFlag: "v",
272
+ type: "boolean"
273
+ }
274
+ }, ve = { url: r(t).href }, ye = ((e = process.argv.slice(2)) => i(ge, {
275
+ argv: [...e],
276
+ autoHelp: !1,
277
+ autoVersion: !1,
278
+ flags: _e,
279
+ importMeta: ve,
280
+ pkg: he
281
+ }))(), be = /^https?:\/\//iu, x = (e) => be.test(e), S = (e) => {
282
+ if (x(e)) try {
283
+ return c.extname(new URL(e).pathname).toLowerCase();
284
+ } catch {
285
+ return "";
286
+ }
287
+ return c.extname(e).toLowerCase();
288
+ }, C = (e) => {
289
+ let t = e;
290
+ x(e) && (t = new URL(e).pathname);
291
+ let n = c.basename(t), r = S(e);
292
+ return r === ".woff2" ? n.slice(0, -6) : r === ".woff" ? n.slice(0, -5) : n.replace(/\.[^.]+$/u, "");
293
+ }, w = {
294
+ ".woff": "-woff",
295
+ ".woff2": "-woff2"
296
+ }, T = (e) => {
297
+ let t = e.map((e) => C(e)), n = /* @__PURE__ */ new Map();
298
+ for (let e of t) n.set(e, (n.get(e) ?? 0) + 1);
299
+ return e.map((e, r) => {
300
+ let i = t[r], a = (n.get(i) ?? 0) > 1, o = S(e);
301
+ return a ? `${i}${w[o] ?? `-${r + 1}`}` : i;
302
+ });
303
+ }, E = async (e) => (await Promise.all(e.map((e) => x(e) ? Promise.resolve([e]) : u(e)))).flat(), D = 1330926671, O = 1953658213, k = 65536, A = (e) => {
304
+ if (e.length < 4) throw Error("SFNT buffer is too short to read flavor");
305
+ let t = e.readUInt32BE(0);
306
+ if (t === D) return "otf";
307
+ if (t === O || t === k) return "ttf";
308
+ throw Error(`Unsupported SFNT flavor 0x${t.toString(16)}`);
309
+ }, j = (e) => Buffer.from(ne(e)), M = (e) => j(e), N = (e, t = {}) => Buffer.from(ee(e, t).buffer), P = async (e) => Buffer.from(await te.compress(e)), F = /* @__PURE__ */ new Set([".woff", ".woff2"]), I = ".svg", L = ".ttf", R = [
310
+ "svg",
311
+ "ttf",
312
+ "eot",
313
+ "woff",
314
+ "woff2"
315
+ ], z = (e) => e === I, B = (e) => e === L, V = (e) => F.has(e), xe = (e) => z(e) || V(e) || B(e), Se = (e) => {
316
+ if (e.length === 0) return "empty";
317
+ let t = e.map((e) => S(e));
318
+ if (!t.every(xe)) return "empty";
319
+ let n = t.some(z), r = t.some(V), i = t.some(B);
320
+ return [
321
+ n,
322
+ r,
323
+ i
324
+ ].filter(Boolean).length > 1 ? "mixed" : r ? "webfont" : i ? "ttf" : n ? "svg" : "empty";
325
+ }, Ce = (e) => {
326
+ if (e.includes("otf")) throw Error("OTF output is only supported when converting WOFF/WOFF2 input. Request \"ttf\" for SVG icons, or pass a .woff/.woff2 file.");
327
+ }, H = (e, t) => t === "svg" ? e.filter((e) => S(e) === I) : t === "webfont" ? e.filter((e) => F.has(S(e))) : t === "ttf" ? e.filter((e) => S(e) === L) : [], we = /* @__PURE__ */ new Set([
328
+ "ttf",
329
+ "eot",
330
+ "woff",
331
+ "woff2"
332
+ ]), Te = (e) => {
333
+ let t = e.filter((e) => we.has(e));
334
+ if (e.length === R.length && R.every((t) => e.includes(t))) return ["woff", "woff2"];
335
+ if (t.length === 0) throw Error("formats must include at least one of \"ttf\", \"eot\", \"woff\", or \"woff2\" when converting TTF input");
336
+ return [...new Set(t)];
337
+ }, Ee = (e) => {
338
+ let t = e.filter((e) => e === "ttf" || e === "otf");
339
+ if (e.length === R.length && R.every((t) => e.includes(t))) return ["ttf"];
340
+ if (t.length === 0) throw Error("formats must include \"ttf\" and/or \"otf\" when converting WOFF/WOFF2 input");
341
+ return [...new Set(t)];
342
+ }, De = (e) => {
343
+ if (e.length === 0) throw Error("No TTF files matched");
344
+ }, Oe = (e) => {
345
+ if (e.template) throw Error("Templates are not supported when converting TTF input");
346
+ if (e.glyphTransformFn) throw Error("glyphTransformFn is not supported when converting TTF input");
347
+ if (e.glyphContentTransformFn) throw Error("glyphContentTransformFn is not supported when converting TTF input");
348
+ }, ke = (e, t) => {
349
+ let n;
350
+ try {
351
+ n = A(e);
352
+ } catch {
353
+ throw Error(`Input is not a valid TrueType font: ${t}`);
354
+ }
355
+ if (n !== "ttf") throw Error(`OpenType (OTF) input is not supported for webfont encoding. Use a .ttf file for ${t}.`);
356
+ }, Ae = async (e, t, n, r) => {
357
+ if (n === "ttf") {
358
+ e.ttf = t;
359
+ return;
360
+ }
361
+ if (n === "eot") {
362
+ e.eot = M(t);
363
+ return;
364
+ }
365
+ if (n === "woff") {
366
+ let n;
367
+ typeof r.metadata == "string" && (n = r.metadata), e.woff = N(t, { metadata: n });
368
+ return;
369
+ }
370
+ e.woff2 = await P(t);
371
+ }, je = async (e, t, n, r) => {
372
+ if (x(e)) throw Error(`Remote TTF URLs are not supported. Download the file first: ${e}`);
373
+ r && console.log(`Encoding ${e}...`);
374
+ let i = await p.readFile(e);
375
+ ke(i, e);
376
+ let a = { source: e };
377
+ return await Promise.all(t.map((e) => Ae(a, i, e, n))), a;
378
+ }, Me = async (e, t) => {
379
+ Oe(t), De(e);
380
+ let n = Te(t.formats), r = await Promise.all(e.map((e) => je(e, n, t, t.verbose))), i = {
381
+ config: { ...t },
382
+ transcodedFonts: r
383
+ };
384
+ if (r.length === 1) {
385
+ let [e] = r;
386
+ i.ttf = e.ttf, i.eot = e.eot, i.woff = e.woff, i.woff2 = e.woff2;
387
+ }
388
+ return i;
389
+ }, Ne = /* @__PURE__ */ y(((e, t) => {
390
+ t.exports = function(e) {
391
+ return !e || e.length < 8 ? !1 : e[0] === 119 && e[1] === 79 && e[2] === 70 && e[3] === 70 && e[4] === 0 && e[5] === 1 && e[6] === 0 && e[7] === 0 || e[4] === 79 && e[5] === 84 && e[6] === 84 && e[7] === 79;
392
+ };
393
+ })), Pe = /* @__PURE__ */ y(((e, t) => {
394
+ t.exports = function(e) {
395
+ return !e || e.length < 8 ? !1 : e[0] === 119 && e[1] === 79 && e[2] === 70 && e[3] === 50 && e[4] === 0 && e[5] === 1 && e[6] === 0 && e[7] === 0;
396
+ };
397
+ })), Fe = /* @__PURE__ */ b(Ne()), Ie = /* @__PURE__ */ b(Pe()), Le = (e, t) => {
398
+ let n = S(t);
399
+ if (n === ".woff2" && !(0, Ie.default)(e)) throw Error(`URL did not return a valid WOFF2 font: ${t}`);
400
+ if (n === ".woff" && !(0, Fe.default)(e)) throw Error(`URL did not return a valid WOFF font: ${t}`);
401
+ if (e.length === 0) throw Error(`URL returned an empty response: ${t}`);
402
+ }, Re = async (e) => {
403
+ let t;
404
+ try {
405
+ t = await fetch(e);
406
+ } catch (t) {
407
+ let n = String(t);
408
+ throw t instanceof Error && (n = t.message), Error(`Failed to fetch font URL ${e}: ${n}`);
409
+ }
410
+ if (!t.ok) throw Error(`Failed to fetch font URL ${e}: HTTP ${t.status} ${t.statusText}`);
411
+ let n = await t.arrayBuffer(), r = Buffer.from(n);
412
+ return Le(r, e), r;
413
+ }, ze = (e) => {
414
+ if (e.length === 0) throw Error("No WOFF or WOFF2 files matched");
415
+ }, Be = (e) => {
416
+ if (e.template) throw Error("Templates are not supported when converting WOFF/WOFF2 input");
417
+ if (e.glyphTransformFn) throw Error("glyphTransformFn is not supported when converting WOFF/WOFF2 input");
418
+ if (e.glyphContentTransformFn) throw Error("glyphContentTransformFn is not supported when converting WOFF/WOFF2 input");
419
+ }, Ve = (e) => {
420
+ let { decompressed: t, sfnt: n, format: r, flavor: i, source: a } = e;
421
+ if (r === "ttf" && i !== "ttf") throw Error(`Input decompresses to OpenType (OTF). Request "otf" format instead of "ttf" for ${a}.`);
422
+ if (r === "otf" && i !== "otf") throw Error(`Input decompresses to TrueType (TTF). Request "ttf" format instead of "otf" for ${a}.`);
423
+ if (r === "ttf") {
424
+ t.ttf = n;
425
+ return;
426
+ }
427
+ t.otf = n;
428
+ }, He = (e) => x(e) ? Re(e) : p.readFile(e), Ue = async (e, t, n) => {
429
+ n && console.log(`Decompressing ${e}...`);
430
+ let r = await He(e), i = Buffer.from(await re.convert(r, "sfnt")), a = A(i), o = { source: e };
431
+ for (let n of t) Ve({
432
+ decompressed: o,
433
+ sfnt: i,
434
+ format: n,
435
+ flavor: a,
436
+ source: e
437
+ });
438
+ return o;
439
+ }, We = async (e, t) => {
440
+ Be(t), ze(e);
441
+ let n = Ee(t.formats), r = await Promise.all(e.map((e) => Ue(e, n, t.verbose))), i = {
442
+ config: { ...t },
443
+ decompressedFonts: r
444
+ };
445
+ return r.length === 1 && (i.ttf = r[0].ttf, i.otf = r[0].otf), i;
446
+ }, Ge = h, Ke = (e) => ({
447
+ prependUnicode: !!e.prependUnicode,
448
+ startUnicode: Number(e.startUnicode)
449
+ }), qe = (e) => {
450
+ if (e == null) return;
451
+ if (typeof e == "number") return Number.isFinite(e) ? e : void 0;
452
+ let t = e.trim();
453
+ if (t.length === 0) return;
454
+ let n = Number(t);
455
+ if (Number.isFinite(n)) return n;
456
+ }, Je = (e) => ({
457
+ ascent: e.ascent,
458
+ centerHorizontally: e.centerHorizontally,
459
+ descent: e.descent,
460
+ fixedWidth: e.fixedWidth,
461
+ fontHeight: e.fontHeight,
462
+ fontId: e.fontId,
463
+ fontName: e.fontName,
464
+ fontStyle: e.fontStyle,
465
+ fontWeight: e.fontWeight,
466
+ metadata: e.metadata,
467
+ normalize: e.normalize,
468
+ round: qe(e.round)
469
+ }), Ye = (e) => e === void 0 ? [] : Array.isArray(e) ? e : [e], Xe = (e) => ({
470
+ name: e.name,
471
+ unicode: Ye(e.unicode)
472
+ }), Ze = (e, t) => {
473
+ let n = t.metadataProvider || ie(Ke(t)), r = new m.Parser(), i = Ge(t.maxConcurrency);
474
+ return Promise.all(e.map((e) => i(() => new Promise((t, n) => {
475
+ let i = o(e), a = "";
476
+ i.on("error", (e) => n(e)).on("data", (e) => {
477
+ a += e.toString();
478
+ }).on("end", () => a.length === 0 ? n(/* @__PURE__ */ Error(`Empty file ${e}`)) : r.parseString(a, (r) => r ? n(r) : t({
479
+ contents: a,
480
+ srcPath: e
481
+ })));
482
+ })))).then((e) => {
483
+ let r = e;
484
+ t.sort && (r = e.sort((e, t) => _(e.srcPath, t.srcPath)));
485
+ let { ligatures: i } = t;
486
+ return Promise.all(r.map((e) => new Promise((t, r) => {
487
+ n(e.srcPath, (n, a) => {
488
+ if (n) return r(n);
489
+ if (!a) return r(/* @__PURE__ */ Error(`Missing metadata for ${e.srcPath}`));
490
+ let o = Xe(a);
491
+ return i && o.unicode.push(a.name.replace(/-/gu, "_")), e.metadata = o, t(e);
492
+ });
493
+ })));
494
+ });
495
+ }, Qe = () => ({
496
+ centerHorizontally: !1,
497
+ descent: 0,
498
+ fixedWidth: !1,
499
+ fontHeight: void 0,
500
+ fontId: void 0,
501
+ fontName: "webfont",
502
+ fontStyle: "",
503
+ fontWeight: "",
504
+ formats: [
505
+ "svg",
506
+ "ttf",
507
+ "eot",
508
+ "woff",
509
+ "woff2"
510
+ ],
511
+ formatsOptions: { ttf: {
512
+ copyright: null,
513
+ ts: null,
514
+ version: null
515
+ } },
516
+ ligatures: !1,
517
+ maxConcurrency: 100,
518
+ metadata: void 0,
519
+ normalize: !1,
520
+ prependUnicode: !1,
521
+ round: 0x9184e72a000,
522
+ sort: !0,
523
+ startUnicode: 59905,
524
+ templateFontPath: "./",
525
+ unicodeRange: !1,
526
+ verbose: !1
527
+ }), $e = (e) => {
528
+ if (!e?.files) throw Error("You must pass webfont a `files` glob");
529
+ return {
530
+ ...Qe(),
531
+ ...e
532
+ };
533
+ }, et = () => ({
534
+ multipass: !1,
535
+ plugins: [
536
+ "removeDoctype",
537
+ "removeXMLProcInst",
538
+ "removeComments",
539
+ "removeMetadata",
540
+ "removeEditorsNSData",
541
+ "removeDesc",
542
+ "cleanupAttrs",
543
+ "removeUnusedNS"
544
+ ]
545
+ }), tt = (e) => {
546
+ let t = et();
547
+ return e ? {
548
+ ...t,
549
+ ...e,
550
+ plugins: e.plugins ?? t.plugins
551
+ } : t;
552
+ }, nt = (e, t, n) => oe(e, {
553
+ ...tt(n),
554
+ path: t
555
+ }).data, rt = (e, t) => e.map((e) => ({
556
+ ...e,
557
+ contents: nt(e.contents, e.srcPath, t)
558
+ })), it = (e, t) => t && e > 2e3, at = (e) => `Warning: ${e} glyphs with ligatures enabled may cause severe browser slowdown or hangs (especially Firefox on Windows). Ligatures are off by default; enable only if needed: --ligatures or ligatures: true. See TROUBLESHOOTING.md and https://github.com/itgalaxy/webfont/issues/558`, ot = /<glyph\b([^>/]*)(?:\/>|>)/giu, st = /\bglyph-name=["']([^"']+)["']/iu, ct = /\bd=["']([^"']*)["']/iu, lt = (e) => {
559
+ let t = [];
560
+ for (let n of e.matchAll(ot)) {
561
+ let e = n[1] ?? "", r = st.exec(e);
562
+ r && (ct.exec(e)?.[1] ?? "").trim().length === 0 && t.push(r[1]);
563
+ }
564
+ return t;
565
+ }, ut = (e, t) => {
566
+ for (let n of t) {
567
+ let t = n.metadata?.name;
568
+ if (t && (e === t || e.startsWith(`${t}-`))) return n.srcPath;
569
+ }
570
+ }, dt = (e, t) => {
571
+ let n = /* @__PURE__ */ new Set(), r = [];
572
+ for (let i of e) {
573
+ let e = ut(i, t), a = e ?? i;
574
+ n.has(a) || (n.add(a), e ? r.push(`${i} (${e})`) : r.push(i));
575
+ }
576
+ return r.join("; ");
577
+ }, ft = (e, t) => {
578
+ let n = lt(e);
579
+ if (n.length === 0) return;
580
+ let r = dt(n, t);
581
+ throw Error(`Empty glyph path(s) in SVG font output for: ${r}. Stroke-only SVGs (fill="none" with stroke) often produce empty glyphs because svgicons2svgfont does not convert strokes. Convert strokes to filled paths in your design tool, preprocess with glyphContentTransformFn (for example svg-outline-stroke), or run with --svg-diagnose for compatibility warnings. See TROUBLESHOOTING.md ("Stroke-only SVGs produce blank icons").`);
582
+ }, pt = /fill-rule\s*:\s*evenodd|fill-rule\s*=\s*["']evenodd["']/iu, mt = (e) => pt.test(e), ht = /\bstroke\s*=|\bstroke\s*:/iu, gt = /fill\s*=\s*["']none["']|fill\s*:\s*none/iu, _t = /<(line|polyline|clipPath)\b/iu, vt = (e) => ht.test(e) ? gt.test(e) : !1, yt = (e) => _t.test(e), U = (e, t) => {
583
+ switch (e) {
584
+ case "evenodd-fill-rule": return `[webfont:diagnose] ${t} uses fill-rule: evenodd. Icon fonts render glyphs with the nonzero fill rule, so holes and counter-shapes can disappear. See TROUBLESHOOTING.md ("Icon details missing after export").`;
585
+ case "stroke-only": return `[webfont:diagnose] ${t} uses stroke-based paths (fill="none"). svgicons2svgfont ignores stroke; outlines may render as solid shapes or lose detail. Preprocess with glyphContentTransformFn (for example svg-outline-stroke) before conversion. See TROUBLESHOOTING.md ("Icon details missing after export").`;
586
+ case "unsupported-element": return `[webfont:diagnose] ${t} contains <line>, <polyline>, or <clipPath>. These elements are poorly supported in icon fonts; results may differ from the browser preview. Convert to filled paths or preprocess with glyphContentTransformFn.`;
587
+ default: return e;
588
+ }
589
+ }, bt = (e, t) => {
590
+ let n = [];
591
+ return mt(t) && n.push({
592
+ code: "evenodd-fill-rule",
593
+ message: U("evenodd-fill-rule", e),
594
+ srcPath: e
595
+ }), vt(t) && n.push({
596
+ code: "stroke-only",
597
+ message: U("stroke-only", e),
598
+ srcPath: e
599
+ }), yt(t) && n.push({
600
+ code: "unsupported-element",
601
+ message: U("unsupported-element", e),
602
+ srcPath: e
603
+ }), n;
604
+ }, xt = (e) => e.flatMap((e) => bt(e.srcPath, e.contents)), St = (e, t) => t.diagnose ? !0 : !!(t.verbose && e.code === "evenodd-fill-rule"), Ct = (e) => {
605
+ if (!e || !e.diagnose) return;
606
+ let t = { diagnose: !0 };
607
+ return e.onMessage && (t.onMessage = e.onMessage), t;
608
+ }, wt = (e, t, n = {}) => {
609
+ let r = Ct(t), i = xt(e), { reporter: a, verbose: o = !1 } = n;
610
+ for (let e of i) St(e, {
611
+ diagnose: r?.diagnose,
612
+ verbose: o
613
+ }) && a?.(e.message);
614
+ let s = [];
615
+ return r?.diagnose && (s = i), {
616
+ diagnostics: s,
617
+ glyphs: e
618
+ };
619
+ }, Tt = (e, t, n = {}) => {
620
+ let { diagnostics: r, glyphs: i } = wt(e, t, n);
621
+ return {
622
+ diagnostics: r,
623
+ glyphs: i
624
+ };
625
+ }, Et = (e, t) => {
626
+ let n = "";
627
+ return new Promise((r, i) => {
628
+ t.verbose && console.log("Generating SVG font...");
629
+ let a = new g(Je(t)).on("finish", () => r(n)).on("data", (e) => {
630
+ n += e;
631
+ }).on("error", (e) => i(e));
632
+ e.forEach((e) => {
633
+ let t = new se();
634
+ t.push(e.contents), t.push(null), t.metadata = e.metadata ?? {
635
+ name: "",
636
+ unicode: []
637
+ }, a.write(t);
638
+ }), a.end();
639
+ });
640
+ }, Dt = (e, t = {}) => Buffer.from(ce(e, t).buffer), Ot = (e) => M(e), kt = (e, t) => N(e, t), At = (e) => P(e), jt = async (e, t) => {
641
+ let n = (e) => {
642
+ if (t.svgTools?.onMessage) {
643
+ t.svgTools.onMessage(e);
644
+ return;
645
+ }
646
+ (t.svgTools?.diagnose || t.verbose) && console.log(e);
647
+ }, r = !!(t.svgTools?.onMessage || t.svgTools?.diagnose || t.verbose), i;
648
+ r && (i = n);
649
+ let { diagnostics: a, glyphs: o } = Tt(e, t.svgTools, {
650
+ reporter: i,
651
+ verbose: t.verbose
652
+ }), s = o;
653
+ if (t.optimizeSvg && (s = rt(s, t.svgoConfig)), t.glyphContentTransformFn) {
654
+ let e = t.glyphContentTransformFn;
655
+ s = await Promise.all(s.map(async (t) => {
656
+ let n = await e(t);
657
+ return {
658
+ ...t,
659
+ contents: n
660
+ };
661
+ }));
662
+ }
663
+ if (t.glyphTransformFn) {
664
+ let e = t.glyphTransformFn;
665
+ s = await Promise.all(s.map(async (t) => {
666
+ let n = await e(t.metadata ?? {
667
+ name: "",
668
+ unicode: []
669
+ });
670
+ return {
671
+ ...t,
672
+ metadata: n
673
+ };
674
+ }));
675
+ }
676
+ it(s.length, t.ligatures) && console.log(at(s.length));
677
+ let c = {};
678
+ t.formatsOptions?.ttf && (c = t.formatsOptions.ttf);
679
+ let l = await Et(s, t);
680
+ ft(l, s);
681
+ let u = Dt(l, c), d = {
682
+ config: t,
683
+ glyphsData: s,
684
+ hash: ae.createHash("md5").update(l).digest("hex"),
685
+ svg: l,
686
+ ttf: u
687
+ };
688
+ a.length > 0 && (d.svgDiagnostics = a);
689
+ let { formats: f } = t;
690
+ if (f.includes("eot") && (d.eot = Ot(u)), f.includes("woff")) {
691
+ let e;
692
+ typeof t.metadata == "string" && (e = t.metadata), d.woff = kt(u, { metadata: e });
693
+ }
694
+ if (f.includes("woff2") && (d.woff2 = Buffer.from(await At(u))), t.template) {
695
+ let { renderTemplates: e } = await import("./renderTemplates-DvRlS58E.mjs"), { templates: n, usedBuildInTemplate: r } = e(t, d, f);
696
+ n.length > 0 && (d.templates = n, d.template = n[0]?.content, d.usedBuildInTemplate = r);
697
+ }
698
+ return f.includes("svg") || delete d.svg, f.includes("ttf") || delete d.ttf, f.includes("otf") || delete d.otf, d;
699
+ }, W = /* @__PURE__ */ new Set([
700
+ "eot",
701
+ "otf",
702
+ "svg",
703
+ "ttf",
704
+ "woff",
705
+ "woff2"
706
+ ]), Mt = [...W].join(", "), G = (e) => {
707
+ if (typeof e != "string" || !W.has(e)) throw Error(`Invalid format "${String(e)}". Expected one of: ${Mt}`);
708
+ return e;
709
+ }, K = (e) => {
710
+ if (e.length === 0) throw Error("formats must not be empty");
711
+ return e.map(G);
712
+ }, Nt = (e) => {
713
+ if (!Array.isArray(e)) throw Error("formats must be an array of format names (e.g. [\"woff2\", \"svg\"])");
714
+ return K(e);
715
+ }, q = (e, t) => {
716
+ if (t !== void 0 && typeof t != "string") throw Error(`${e} must be a string`);
717
+ }, Pt = (e, t) => {
718
+ if (t !== void 0 && typeof t != "boolean" && typeof t != "string") throw Error(`${e} must be a boolean or string`);
719
+ }, J = (e, t) => {
720
+ if (t !== void 0 && typeof t != "boolean") throw Error(`${e} must be a boolean`);
721
+ }, Ft = (e, t) => {
722
+ if (t !== void 0 && (typeof t != "object" || !t || Array.isArray(t))) throw Error(`${e} must be an object`);
723
+ }, It = (e) => {
724
+ if (typeof e == "string") {
725
+ if (e.length === 0) throw Error("files must not be empty");
726
+ return;
727
+ }
728
+ if (Array.isArray(e)) {
729
+ if (e.length === 0) throw Error("files must not be empty");
730
+ if (!e.every((e) => typeof e == "string")) throw Error("files must be a string or an array of strings");
731
+ return;
732
+ }
733
+ throw Error("files must be a string or an array of strings");
734
+ }, Lt = (e) => (It(e.files), e.formats = Nt(e.formats), q("fontName", e.fontName), Pt("unicodeRange", e.unicodeRange), J("optimizeSvg", e.optimizeSvg), Ft("svgoConfig", e.svgoConfig), J("templateFontLigatures", e.templateFontLigatures), e.template !== void 0 && n(e.template), q("templateFontPath", e.templateFontPath), e), Rt = (e) => "filepath" in e, Y = async (e) => {
735
+ let t = d("webfont", { searchStrategy: "global" });
736
+ if (e.configFile) {
737
+ let n = c.resolve(process.cwd(), e.configFile);
738
+ return await t.load(n) ?? {};
739
+ }
740
+ return await t.search(process.cwd()) ?? {};
741
+ }, zt = Y, Bt = async (e) => {
742
+ let t = $e(e);
743
+ delete t.filePath;
744
+ let n = await Y({ configFile: t.configFile }), r;
745
+ Rt(n) && (t = f(t, n.config, { arrayMerge: (e, t) => t }), r = n.filepath), t = Lt(t);
746
+ let i;
747
+ i = Array.isArray(t.files) ? t.files : [t.files];
748
+ let a = await E(i), o = Se(a);
749
+ if (o === "mixed") throw Error("Cannot mix SVG icons, TTF fonts, and WOFF/WOFF2 files in the same run");
750
+ if (o === "empty") throw Error("Files glob patterns specified did not match any supported files");
751
+ if (o === "webfont") {
752
+ let e = await We(H(a, o), t);
753
+ return r && (e.config = {
754
+ ...t,
755
+ filePath: r
756
+ }), e;
757
+ }
758
+ if (o === "ttf") {
759
+ let e = await Me(H(a, o), t);
760
+ return r && (e.config = {
761
+ ...t,
762
+ filePath: r
763
+ }), e;
764
+ }
765
+ Ce(t.formats);
766
+ let s = await jt(await Ze(H(a, "svg"), t), t);
767
+ return r ? s.config = {
768
+ ...t,
769
+ filePath: r
770
+ } : s.config = t, s;
771
+ }, Vt = (e) => {
772
+ if (e.svgDiagnose) return { diagnose: !0 };
773
+ }, Ht = (e) => {
774
+ if (e === void 0) return;
775
+ let t = e.trim();
776
+ if (t.length === 0) throw Error("formats must not be empty");
777
+ if (t.startsWith("[") || t.startsWith("{")) {
778
+ let e;
779
+ try {
780
+ e = JSON.parse(t);
781
+ } catch {
782
+ throw Error("formats must be a JSON array (e.g. [\"woff2\",\"svg\"]) or comma-separated list");
783
+ }
784
+ if (!Array.isArray(e)) throw Error("formats must be a JSON array (e.g. [\"woff2\",\"svg\"]) or comma-separated list");
785
+ return K(e);
786
+ }
787
+ return t.split(",").map((e) => e.trim()).filter((e) => e.length > 0).map(G);
788
+ }, Ut = (e) => {
789
+ if (e === void 0) return;
790
+ let t = e.trim();
791
+ if (t.length === 0) throw Error("template must not be empty");
792
+ if (t.startsWith("[") || t.startsWith("{")) {
793
+ let e;
794
+ try {
795
+ e = JSON.parse(t);
796
+ } catch {
797
+ throw Error("template must be a JSON array (e.g. [\"html\",\"scss\"]) or a template name");
798
+ }
799
+ if (!Array.isArray(e)) throw Error("template must be a JSON array (e.g. [\"html\",\"scss\"]) or a template name");
800
+ return n(e);
801
+ }
802
+ return t.includes(",") ? n(t.split(",").map((e) => e.trim()).filter((e) => e.length > 0)) : t;
803
+ }, Wt = (e) => {
804
+ if (!(!("config" in e) || e.config?.files === void 0)) return Array.isArray(e.config.files) ? e.config.files : [e.config.files];
805
+ }, Gt = async (e, t) => {
806
+ let n = Wt(await zt({ configFile: t.configFile }));
807
+ if (e.input.length > 0 && n !== void 0) throw Error("Cannot specify input files on the command line when `files` is set in the config file");
808
+ return e.input.length > 0 ? e.input : n === void 0 ? [] : n;
809
+ }, Kt = [
810
+ "svg",
811
+ "ttf",
812
+ "otf",
813
+ "eot",
814
+ "woff",
815
+ "woff2",
816
+ "hash",
817
+ "template"
818
+ ], qt = (e) => {
819
+ let t = {};
820
+ typeof e.flags.config == "string" && (t.configFile = l.silent(process.cwd(), e.flags.config) || s.join(process.cwd(), e.flags.config)), e.flags.fontName && (t.fontName = e.flags.fontName), e.flags.formats && (t.formats = Ht(e.flags.formats)), e.flags.dest && (t.dest = e.flags.dest), e.flags.destCreate && (t.destCreate = e.flags.destCreate), e.flags.template && (t.template = Ut(e.flags.template)), e.flags.templateClassName && (t.templateClassName = e.flags.templateClassName), e.flags.templateFontPath && (t.templateFontPath = e.flags.templateFontPath), e.flags.templateFontName && (t.templateFontName = e.flags.templateFontName), e.flags.templateCacheString && (t.templateCacheString = e.flags.templateCacheString), e.flags.destTemplate && (t.destTemplate = e.flags.destTemplate), e.flags.verbose && (t.verbose = e.flags.verbose), e.flags.fontId && (t.fontId = e.flags.fontId), e.flags.fontStyle && (t.fontStyle = e.flags.fontStyle), e.flags.fontWeight && (t.fontWeight = e.flags.fontWeight), e.flags.fixedWidth && (t.fixedWidth = e.flags.fixedWidth), e.flags.centerHorizontally && (t.centerHorizontally = e.flags.centerHorizontally), e.flags.normalize && (t.normalize = e.flags.normalize), e.flags.optimizeSvg && (t.optimizeSvg = e.flags.optimizeSvg), e.flags.fontHeight && (t.fontHeight = e.flags.fontHeight), e.flags.round && (t.round = e.flags.round), e.flags.descent && (t.descent = e.flags.descent), e.flags.ascent && (t.ascent = e.flags.ascent), e.flags.startUnicode && (t.startUnicode = e.flags.startUnicode), e.flags.prependUnicode && (t.prependUnicode = e.flags.prependUnicode), e.flags.metadata && (t.metadata = e.flags.metadata), e.flags.sort === !1 && (t.sort = e.flags.sort), e.flags.ligatures && (t.ligatures = e.flags.ligatures), e.flags.unicodeRange && (t.unicodeRange = e.flags.unicodeRange), e.flags.templateFontLigatures === !1 && (t.templateFontLigatures = e.flags.templateFontLigatures), e.flags.addHashInFontUrl && (t.addHashInFontUrl = e.flags.addHashInFontUrl);
821
+ let n = Vt(e.flags);
822
+ return n && (t.svgTools = n), t;
823
+ }, X = (e) => {
824
+ if (!e.config) throw Error("Missing config in webfont result");
825
+ return e.config;
826
+ }, Jt = (e, t) => (e.config = {
827
+ ...X(e),
828
+ dest: t.dest,
829
+ destTemplate: t.destTemplate
830
+ }, e), Z = (e, t, n) => {
831
+ let r = t.dest ?? process.cwd();
832
+ return typeof t.destTemplate == "string" && (r = t.destTemplate), n ? s.join(r, `${t.fontName}.${e}`) : s.join(r, s.basename(e).replace(".njk", ""));
833
+ }, Q = (e) => Array.isArray(e) ? e[0] : e, Yt = (e, t) => {
834
+ if (!e.template) return;
835
+ let n = Q(t.template);
836
+ if (e.usedBuildInTemplate && n) return Z(n, t, !0);
837
+ if (n) return Z(n, t, !1);
838
+ let r = t.dest ?? process.cwd();
839
+ return typeof t.destTemplate == "string" ? t.destTemplate : r;
840
+ }, Xt = async (e, t) => {
841
+ await Promise.all(e.map(async (e) => {
842
+ let n = s.resolve(Z(e.template, t, !!e.builtIn));
843
+ await a.promises.mkdir(s.dirname(n), { recursive: !0 }), await a.promises.writeFile(n, e.content);
844
+ }));
845
+ }, Zt = (e, t, n, r) => {
846
+ let i = n.fontName, a = n.dest ?? process.cwd();
847
+ return e === "template" ? s.resolve(r ?? a) : e === "hash" ? s.resolve(s.join(a, `${i}.hash`)) : s.resolve(s.join(a, `${i}.${e}`));
848
+ }, Qt = (e) => /* @__PURE__ */ Error(`Destination directory "${e}" does not exist. Use --dest-create (-m) to create it.`), $t = async (e, t) => {
849
+ try {
850
+ await a.promises.access(e, a.constants.F_OK);
851
+ } catch {
852
+ if (t) {
853
+ await a.promises.mkdir(e, { recursive: !0 });
854
+ return;
855
+ }
856
+ throw Qt(e);
857
+ }
858
+ }, $ = (e, t, n) => e.length === 1 && n.fontName ? n.fontName : T(e.map((e) => e.source))[e.indexOf(t)] ?? n.fontName, en = async (e, t, n) => {
859
+ await Promise.all(e.flatMap((r) => {
860
+ let i = $(e, r, t), o = [];
861
+ return r.ttf && o.push(a.promises.writeFile(s.resolve(s.join(n, `${i}.ttf`)), r.ttf)), r.otf && o.push(a.promises.writeFile(s.resolve(s.join(n, `${i}.otf`)), r.otf)), o;
862
+ }));
863
+ }, tn = (e, t, n) => $(e, t, n), nn = async (e, t, n) => {
864
+ await Promise.all(e.flatMap((r) => {
865
+ let i = tn(e, r, t), o = [];
866
+ return r.ttf && o.push(a.promises.writeFile(s.resolve(s.join(n, `${i}.ttf`)), r.ttf)), r.eot && o.push(a.promises.writeFile(s.resolve(s.join(n, `${i}.eot`)), r.eot)), r.woff && o.push(a.promises.writeFile(s.resolve(s.join(n, `${i}.woff`)), r.woff)), r.woff2 && o.push(a.promises.writeFile(s.resolve(s.join(n, `${i}.woff2`)), r.woff2)), o;
867
+ }));
868
+ }, rn = async (e) => {
869
+ let t = X(e), n = t.dest ?? process.cwd(), r = Yt(e, t);
870
+ return e.template && delete e.hash, await $t(n, t.destCreate), e.templates && e.templates.length > 0 && await Xt(e.templates, t), e.transcodedFonts && e.transcodedFonts.length > 1 ? (await nn(e.transcodedFonts, t, n), e) : e.decompressedFonts && e.decompressedFonts.length > 1 ? (await en(e.decompressedFonts, t, n), e) : (await Promise.all(Kt.filter((t) => t === "template" && e.templates && e.templates.length > 0 ? !1 : e[t] !== void 0).map(async (n) => {
871
+ let i = e[n];
872
+ if (i === void 0) return;
873
+ let o = Zt(n, e, t, r);
874
+ await a.promises.writeFile(o, i);
875
+ })), e);
876
+ }, an = (e) => typeof e == "object" && e && "code" in e && typeof e.code == "number" ? e.code : 1, on = (e) => {
877
+ sn(e).catch((e) => {
878
+ console.log(e.stack), process.exit(an(e));
879
+ });
880
+ }, sn = async (e) => {
881
+ e.flags.help && e.showHelp(), e.flags.version && e.showVersion();
882
+ let t = qt(e), n = await Gt(e, t);
883
+ n.length === 0 && e.showHelp();
884
+ let r = {
885
+ ...t,
886
+ files: n
887
+ }, i = await Bt(r);
888
+ return Jt(i, r), rn(i);
889
+ };
890
+ //#endregion
891
+ //#region src/cli/index.ts
892
+ on(ye);
893
+ //#endregion