@bagelink/vue 1.2.134 → 1.2.139

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.
@@ -0,0 +1,1693 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const vue = require("vue");
4
+ const matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
5
+ const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
6
+ const colonSeparated = value.split(":");
7
+ if (value.slice(0, 1) === "@") {
8
+ if (colonSeparated.length < 2 || colonSeparated.length > 3) {
9
+ return null;
10
+ }
11
+ provider = colonSeparated.shift().slice(1);
12
+ }
13
+ if (colonSeparated.length > 3 || !colonSeparated.length) {
14
+ return null;
15
+ }
16
+ if (colonSeparated.length > 1) {
17
+ const name2 = colonSeparated.pop();
18
+ const prefix = colonSeparated.pop();
19
+ const result = {
20
+ // Allow provider without '@': "provider:prefix:name"
21
+ provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
22
+ prefix,
23
+ name: name2
24
+ };
25
+ return validate && !validateIconName(result) ? null : result;
26
+ }
27
+ const name = colonSeparated[0];
28
+ const dashSeparated = name.split("-");
29
+ if (dashSeparated.length > 1) {
30
+ const result = {
31
+ provider,
32
+ prefix: dashSeparated.shift(),
33
+ name: dashSeparated.join("-")
34
+ };
35
+ return validate && !validateIconName(result) ? null : result;
36
+ }
37
+ if (allowSimpleName && provider === "") {
38
+ const result = {
39
+ provider,
40
+ prefix: "",
41
+ name
42
+ };
43
+ return validate && !validateIconName(result, allowSimpleName) ? null : result;
44
+ }
45
+ return null;
46
+ };
47
+ const validateIconName = (icon, allowSimpleName) => {
48
+ if (!icon) {
49
+ return false;
50
+ }
51
+ return !!// Check prefix: cannot be empty, unless allowSimpleName is enabled
52
+ // Check name: cannot be empty
53
+ ((allowSimpleName && icon.prefix === "" || !!icon.prefix) && !!icon.name);
54
+ };
55
+ const defaultIconDimensions = Object.freeze(
56
+ {
57
+ left: 0,
58
+ top: 0,
59
+ width: 16,
60
+ height: 16
61
+ }
62
+ );
63
+ const defaultIconTransformations = Object.freeze({
64
+ rotate: 0,
65
+ vFlip: false,
66
+ hFlip: false
67
+ });
68
+ const defaultIconProps = Object.freeze({
69
+ ...defaultIconDimensions,
70
+ ...defaultIconTransformations
71
+ });
72
+ const defaultExtendedIconProps = Object.freeze({
73
+ ...defaultIconProps,
74
+ body: "",
75
+ hidden: false
76
+ });
77
+ function mergeIconTransformations(obj1, obj2) {
78
+ const result = {};
79
+ if (!obj1.hFlip !== !obj2.hFlip) {
80
+ result.hFlip = true;
81
+ }
82
+ if (!obj1.vFlip !== !obj2.vFlip) {
83
+ result.vFlip = true;
84
+ }
85
+ const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
86
+ if (rotate) {
87
+ result.rotate = rotate;
88
+ }
89
+ return result;
90
+ }
91
+ function mergeIconData(parent, child) {
92
+ const result = mergeIconTransformations(parent, child);
93
+ for (const key in defaultExtendedIconProps) {
94
+ if (key in defaultIconTransformations) {
95
+ if (key in parent && !(key in result)) {
96
+ result[key] = defaultIconTransformations[key];
97
+ }
98
+ } else if (key in child) {
99
+ result[key] = child[key];
100
+ } else if (key in parent) {
101
+ result[key] = parent[key];
102
+ }
103
+ }
104
+ return result;
105
+ }
106
+ function getIconsTree(data, names) {
107
+ const icons = data.icons;
108
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
109
+ const resolved = /* @__PURE__ */ Object.create(null);
110
+ function resolve(name) {
111
+ if (icons[name]) {
112
+ return resolved[name] = [];
113
+ }
114
+ if (!(name in resolved)) {
115
+ resolved[name] = null;
116
+ const parent = aliases[name] && aliases[name].parent;
117
+ const value = parent && resolve(parent);
118
+ if (value) {
119
+ resolved[name] = [parent].concat(value);
120
+ }
121
+ }
122
+ return resolved[name];
123
+ }
124
+ Object.keys(icons).concat(Object.keys(aliases)).forEach(resolve);
125
+ return resolved;
126
+ }
127
+ function internalGetIconData(data, name, tree) {
128
+ const icons = data.icons;
129
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
130
+ let currentProps = {};
131
+ function parse(name2) {
132
+ currentProps = mergeIconData(
133
+ icons[name2] || aliases[name2],
134
+ currentProps
135
+ );
136
+ }
137
+ parse(name);
138
+ tree.forEach(parse);
139
+ return mergeIconData(data, currentProps);
140
+ }
141
+ function parseIconSet(data, callback) {
142
+ const names = [];
143
+ if (typeof data !== "object" || typeof data.icons !== "object") {
144
+ return names;
145
+ }
146
+ if (data.not_found instanceof Array) {
147
+ data.not_found.forEach((name) => {
148
+ callback(name, null);
149
+ names.push(name);
150
+ });
151
+ }
152
+ const tree = getIconsTree(data);
153
+ for (const name in tree) {
154
+ const item = tree[name];
155
+ if (item) {
156
+ callback(name, internalGetIconData(data, name, item));
157
+ names.push(name);
158
+ }
159
+ }
160
+ return names;
161
+ }
162
+ const optionalPropertyDefaults = {
163
+ provider: "",
164
+ aliases: {},
165
+ not_found: {},
166
+ ...defaultIconDimensions
167
+ };
168
+ function checkOptionalProps(item, defaults) {
169
+ for (const prop in defaults) {
170
+ if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
171
+ return false;
172
+ }
173
+ }
174
+ return true;
175
+ }
176
+ function quicklyValidateIconSet(obj) {
177
+ if (typeof obj !== "object" || obj === null) {
178
+ return null;
179
+ }
180
+ const data = obj;
181
+ if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
182
+ return null;
183
+ }
184
+ if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
185
+ return null;
186
+ }
187
+ const icons = data.icons;
188
+ for (const name in icons) {
189
+ const icon = icons[name];
190
+ if (
191
+ // Name cannot be empty
192
+ !name || // Must have body
193
+ typeof icon.body !== "string" || // Check other props
194
+ !checkOptionalProps(
195
+ icon,
196
+ defaultExtendedIconProps
197
+ )
198
+ ) {
199
+ return null;
200
+ }
201
+ }
202
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
203
+ for (const name in aliases) {
204
+ const icon = aliases[name];
205
+ const parent = icon.parent;
206
+ if (
207
+ // Name cannot be empty
208
+ !name || // Parent must be set and point to existing icon
209
+ typeof parent !== "string" || !icons[parent] && !aliases[parent] || // Check other props
210
+ !checkOptionalProps(
211
+ icon,
212
+ defaultExtendedIconProps
213
+ )
214
+ ) {
215
+ return null;
216
+ }
217
+ }
218
+ return data;
219
+ }
220
+ const dataStorage = /* @__PURE__ */ Object.create(null);
221
+ function newStorage(provider, prefix) {
222
+ return {
223
+ provider,
224
+ prefix,
225
+ icons: /* @__PURE__ */ Object.create(null),
226
+ missing: /* @__PURE__ */ new Set()
227
+ };
228
+ }
229
+ function getStorage(provider, prefix) {
230
+ const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
231
+ return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
232
+ }
233
+ function addIconSet(storage2, data) {
234
+ if (!quicklyValidateIconSet(data)) {
235
+ return [];
236
+ }
237
+ return parseIconSet(data, (name, icon) => {
238
+ if (icon) {
239
+ storage2.icons[name] = icon;
240
+ } else {
241
+ storage2.missing.add(name);
242
+ }
243
+ });
244
+ }
245
+ function addIconToStorage(storage2, name, icon) {
246
+ try {
247
+ if (typeof icon.body === "string") {
248
+ storage2.icons[name] = { ...icon };
249
+ return true;
250
+ }
251
+ } catch (err) {
252
+ }
253
+ return false;
254
+ }
255
+ let simpleNames = false;
256
+ function allowSimpleNames(allow) {
257
+ if (typeof allow === "boolean") {
258
+ simpleNames = allow;
259
+ }
260
+ return simpleNames;
261
+ }
262
+ function getIconData(name) {
263
+ const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
264
+ if (icon) {
265
+ const storage2 = getStorage(icon.provider, icon.prefix);
266
+ const iconName = icon.name;
267
+ return storage2.icons[iconName] || (storage2.missing.has(iconName) ? null : void 0);
268
+ }
269
+ }
270
+ function addIcon(name, data) {
271
+ const icon = stringToIcon(name, true, simpleNames);
272
+ if (!icon) {
273
+ return false;
274
+ }
275
+ const storage2 = getStorage(icon.provider, icon.prefix);
276
+ if (data) {
277
+ return addIconToStorage(storage2, icon.name, data);
278
+ } else {
279
+ storage2.missing.add(icon.name);
280
+ return true;
281
+ }
282
+ }
283
+ function addCollection(data, provider) {
284
+ if (typeof data !== "object") {
285
+ return false;
286
+ }
287
+ if (typeof provider !== "string") {
288
+ provider = data.provider || "";
289
+ }
290
+ if (simpleNames && !provider && !data.prefix) {
291
+ let added = false;
292
+ if (quicklyValidateIconSet(data)) {
293
+ data.prefix = "";
294
+ parseIconSet(data, (name, icon) => {
295
+ if (addIcon(name, icon)) {
296
+ added = true;
297
+ }
298
+ });
299
+ }
300
+ return added;
301
+ }
302
+ const prefix = data.prefix;
303
+ if (!validateIconName({
304
+ prefix,
305
+ name: "a"
306
+ })) {
307
+ return false;
308
+ }
309
+ const storage2 = getStorage(provider, prefix);
310
+ return !!addIconSet(storage2, data);
311
+ }
312
+ const defaultIconSizeCustomisations = Object.freeze({
313
+ width: null,
314
+ height: null
315
+ });
316
+ const defaultIconCustomisations = Object.freeze({
317
+ // Dimensions
318
+ ...defaultIconSizeCustomisations,
319
+ // Transformations
320
+ ...defaultIconTransformations
321
+ });
322
+ const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
323
+ const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
324
+ function calculateSize(size, ratio, precision) {
325
+ if (ratio === 1) {
326
+ return size;
327
+ }
328
+ precision = precision || 100;
329
+ if (typeof size === "number") {
330
+ return Math.ceil(size * ratio * precision) / precision;
331
+ }
332
+ if (typeof size !== "string") {
333
+ return size;
334
+ }
335
+ const oldParts = size.split(unitsSplit);
336
+ if (oldParts === null || !oldParts.length) {
337
+ return size;
338
+ }
339
+ const newParts = [];
340
+ let code = oldParts.shift();
341
+ let isNumber = unitsTest.test(code);
342
+ while (true) {
343
+ if (isNumber) {
344
+ const num = parseFloat(code);
345
+ if (isNaN(num)) {
346
+ newParts.push(code);
347
+ } else {
348
+ newParts.push(Math.ceil(num * ratio * precision) / precision);
349
+ }
350
+ } else {
351
+ newParts.push(code);
352
+ }
353
+ code = oldParts.shift();
354
+ if (code === void 0) {
355
+ return newParts.join("");
356
+ }
357
+ isNumber = !isNumber;
358
+ }
359
+ }
360
+ function splitSVGDefs(content, tag = "defs") {
361
+ let defs = "";
362
+ const index = content.indexOf("<" + tag);
363
+ while (index >= 0) {
364
+ const start = content.indexOf(">", index);
365
+ const end = content.indexOf("</" + tag);
366
+ if (start === -1 || end === -1) {
367
+ break;
368
+ }
369
+ const endEnd = content.indexOf(">", end);
370
+ if (endEnd === -1) {
371
+ break;
372
+ }
373
+ defs += content.slice(start + 1, end).trim();
374
+ content = content.slice(0, index).trim() + content.slice(endEnd + 1);
375
+ }
376
+ return {
377
+ defs,
378
+ content
379
+ };
380
+ }
381
+ function mergeDefsAndContent(defs, content) {
382
+ return defs ? "<defs>" + defs + "</defs>" + content : content;
383
+ }
384
+ function wrapSVGContent(body, start, end) {
385
+ const split = splitSVGDefs(body);
386
+ return mergeDefsAndContent(split.defs, start + split.content + end);
387
+ }
388
+ const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
389
+ function iconToSVG(icon, customisations) {
390
+ const fullIcon = {
391
+ ...defaultIconProps,
392
+ ...icon
393
+ };
394
+ const fullCustomisations = {
395
+ ...defaultIconCustomisations,
396
+ ...customisations
397
+ };
398
+ const box = {
399
+ left: fullIcon.left,
400
+ top: fullIcon.top,
401
+ width: fullIcon.width,
402
+ height: fullIcon.height
403
+ };
404
+ let body = fullIcon.body;
405
+ [fullIcon, fullCustomisations].forEach((props) => {
406
+ const transformations = [];
407
+ const hFlip = props.hFlip;
408
+ const vFlip = props.vFlip;
409
+ let rotation = props.rotate;
410
+ if (hFlip) {
411
+ if (vFlip) {
412
+ rotation += 2;
413
+ } else {
414
+ transformations.push(
415
+ "translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"
416
+ );
417
+ transformations.push("scale(-1 1)");
418
+ box.top = box.left = 0;
419
+ }
420
+ } else if (vFlip) {
421
+ transformations.push(
422
+ "translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"
423
+ );
424
+ transformations.push("scale(1 -1)");
425
+ box.top = box.left = 0;
426
+ }
427
+ let tempValue;
428
+ if (rotation < 0) {
429
+ rotation -= Math.floor(rotation / 4) * 4;
430
+ }
431
+ rotation = rotation % 4;
432
+ switch (rotation) {
433
+ case 1:
434
+ tempValue = box.height / 2 + box.top;
435
+ transformations.unshift(
436
+ "rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"
437
+ );
438
+ break;
439
+ case 2:
440
+ transformations.unshift(
441
+ "rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"
442
+ );
443
+ break;
444
+ case 3:
445
+ tempValue = box.width / 2 + box.left;
446
+ transformations.unshift(
447
+ "rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"
448
+ );
449
+ break;
450
+ }
451
+ if (rotation % 2 === 1) {
452
+ if (box.left !== box.top) {
453
+ tempValue = box.left;
454
+ box.left = box.top;
455
+ box.top = tempValue;
456
+ }
457
+ if (box.width !== box.height) {
458
+ tempValue = box.width;
459
+ box.width = box.height;
460
+ box.height = tempValue;
461
+ }
462
+ }
463
+ if (transformations.length) {
464
+ body = wrapSVGContent(
465
+ body,
466
+ '<g transform="' + transformations.join(" ") + '">',
467
+ "</g>"
468
+ );
469
+ }
470
+ });
471
+ const customisationsWidth = fullCustomisations.width;
472
+ const customisationsHeight = fullCustomisations.height;
473
+ const boxWidth = box.width;
474
+ const boxHeight = box.height;
475
+ let width;
476
+ let height;
477
+ if (customisationsWidth === null) {
478
+ height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
479
+ width = calculateSize(height, boxWidth / boxHeight);
480
+ } else {
481
+ width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
482
+ height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
483
+ }
484
+ const attributes = {};
485
+ const setAttr = (prop, value) => {
486
+ if (!isUnsetKeyword(value)) {
487
+ attributes[prop] = value.toString();
488
+ }
489
+ };
490
+ setAttr("width", width);
491
+ setAttr("height", height);
492
+ const viewBox = [box.left, box.top, boxWidth, boxHeight];
493
+ attributes.viewBox = viewBox.join(" ");
494
+ return {
495
+ attributes,
496
+ viewBox,
497
+ body
498
+ };
499
+ }
500
+ const regex = /\sid="(\S+)"/g;
501
+ const randomPrefix = "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
502
+ let counter = 0;
503
+ function replaceIDs(body, prefix = randomPrefix) {
504
+ const ids = [];
505
+ let match;
506
+ while (match = regex.exec(body)) {
507
+ ids.push(match[1]);
508
+ }
509
+ if (!ids.length) {
510
+ return body;
511
+ }
512
+ const suffix = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
513
+ ids.forEach((id) => {
514
+ const newID = typeof prefix === "function" ? prefix(id) : prefix + (counter++).toString();
515
+ const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
516
+ body = body.replace(
517
+ // Allowed characters before id: [#;"]
518
+ // Allowed characters after id: [)"], .[a-z]
519
+ new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"),
520
+ "$1" + newID + suffix + "$3"
521
+ );
522
+ });
523
+ body = body.replace(new RegExp(suffix, "g"), "");
524
+ return body;
525
+ }
526
+ const storage = /* @__PURE__ */ Object.create(null);
527
+ function setAPIModule(provider, item) {
528
+ storage[provider] = item;
529
+ }
530
+ function getAPIModule(provider) {
531
+ return storage[provider] || storage[""];
532
+ }
533
+ function createAPIConfig(source) {
534
+ let resources;
535
+ if (typeof source.resources === "string") {
536
+ resources = [source.resources];
537
+ } else {
538
+ resources = source.resources;
539
+ if (!(resources instanceof Array) || !resources.length) {
540
+ return null;
541
+ }
542
+ }
543
+ const result = {
544
+ // API hosts
545
+ resources,
546
+ // Root path
547
+ path: source.path || "/",
548
+ // URL length limit
549
+ maxURL: source.maxURL || 500,
550
+ // Timeout before next host is used.
551
+ rotate: source.rotate || 750,
552
+ // Timeout before failing query.
553
+ timeout: source.timeout || 5e3,
554
+ // Randomise default API end point.
555
+ random: source.random === true,
556
+ // Start index
557
+ index: source.index || 0,
558
+ // Receive data after time out (used if time out kicks in first, then API module sends data anyway).
559
+ dataAfterTimeout: source.dataAfterTimeout !== false
560
+ };
561
+ return result;
562
+ }
563
+ const configStorage = /* @__PURE__ */ Object.create(null);
564
+ const fallBackAPISources = [
565
+ "https://api.simplesvg.com",
566
+ "https://api.unisvg.com"
567
+ ];
568
+ const fallBackAPI = [];
569
+ while (fallBackAPISources.length > 0) {
570
+ if (fallBackAPISources.length === 1) {
571
+ fallBackAPI.push(fallBackAPISources.shift());
572
+ } else {
573
+ if (Math.random() > 0.5) {
574
+ fallBackAPI.push(fallBackAPISources.shift());
575
+ } else {
576
+ fallBackAPI.push(fallBackAPISources.pop());
577
+ }
578
+ }
579
+ }
580
+ configStorage[""] = createAPIConfig({
581
+ resources: ["https://api.iconify.design"].concat(fallBackAPI)
582
+ });
583
+ function addAPIProvider(provider, customConfig) {
584
+ const config = createAPIConfig(customConfig);
585
+ if (config === null) {
586
+ return false;
587
+ }
588
+ configStorage[provider] = config;
589
+ return true;
590
+ }
591
+ function getAPIConfig(provider) {
592
+ return configStorage[provider];
593
+ }
594
+ const detectFetch = () => {
595
+ let callback;
596
+ try {
597
+ callback = fetch;
598
+ if (typeof callback === "function") {
599
+ return callback;
600
+ }
601
+ } catch (err) {
602
+ }
603
+ };
604
+ let fetchModule = detectFetch();
605
+ function calculateMaxLength(provider, prefix) {
606
+ const config = getAPIConfig(provider);
607
+ if (!config) {
608
+ return 0;
609
+ }
610
+ let result;
611
+ if (!config.maxURL) {
612
+ result = 0;
613
+ } else {
614
+ let maxHostLength = 0;
615
+ config.resources.forEach((item) => {
616
+ const host = item;
617
+ maxHostLength = Math.max(maxHostLength, host.length);
618
+ });
619
+ const url = prefix + ".json?icons=";
620
+ result = config.maxURL - maxHostLength - config.path.length - url.length;
621
+ }
622
+ return result;
623
+ }
624
+ function shouldAbort(status) {
625
+ return status === 404;
626
+ }
627
+ const prepare = (provider, prefix, icons) => {
628
+ const results = [];
629
+ const maxLength = calculateMaxLength(provider, prefix);
630
+ const type = "icons";
631
+ let item = {
632
+ type,
633
+ provider,
634
+ prefix,
635
+ icons: []
636
+ };
637
+ let length = 0;
638
+ icons.forEach((name, index) => {
639
+ length += name.length + 1;
640
+ if (length >= maxLength && index > 0) {
641
+ results.push(item);
642
+ item = {
643
+ type,
644
+ provider,
645
+ prefix,
646
+ icons: []
647
+ };
648
+ length = name.length;
649
+ }
650
+ item.icons.push(name);
651
+ });
652
+ results.push(item);
653
+ return results;
654
+ };
655
+ function getPath(provider) {
656
+ if (typeof provider === "string") {
657
+ const config = getAPIConfig(provider);
658
+ if (config) {
659
+ return config.path;
660
+ }
661
+ }
662
+ return "/";
663
+ }
664
+ const send = (host, params, callback) => {
665
+ if (!fetchModule) {
666
+ callback("abort", 424);
667
+ return;
668
+ }
669
+ let path = getPath(params.provider);
670
+ switch (params.type) {
671
+ case "icons": {
672
+ const prefix = params.prefix;
673
+ const icons = params.icons;
674
+ const iconsList = icons.join(",");
675
+ const urlParams = new URLSearchParams({
676
+ icons: iconsList
677
+ });
678
+ path += prefix + ".json?" + urlParams.toString();
679
+ break;
680
+ }
681
+ case "custom": {
682
+ const uri = params.uri;
683
+ path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
684
+ break;
685
+ }
686
+ default:
687
+ callback("abort", 400);
688
+ return;
689
+ }
690
+ let defaultError = 503;
691
+ fetchModule(host + path).then((response) => {
692
+ const status = response.status;
693
+ if (status !== 200) {
694
+ setTimeout(() => {
695
+ callback(shouldAbort(status) ? "abort" : "next", status);
696
+ });
697
+ return;
698
+ }
699
+ defaultError = 501;
700
+ return response.json();
701
+ }).then((data) => {
702
+ if (typeof data !== "object" || data === null) {
703
+ setTimeout(() => {
704
+ if (data === 404) {
705
+ callback("abort", data);
706
+ } else {
707
+ callback("next", defaultError);
708
+ }
709
+ });
710
+ return;
711
+ }
712
+ setTimeout(() => {
713
+ callback("success", data);
714
+ });
715
+ }).catch(() => {
716
+ callback("next", defaultError);
717
+ });
718
+ };
719
+ const fetchAPIModule = {
720
+ prepare,
721
+ send
722
+ };
723
+ function sortIcons(icons) {
724
+ const result = {
725
+ loaded: [],
726
+ missing: [],
727
+ pending: []
728
+ };
729
+ const storage2 = /* @__PURE__ */ Object.create(null);
730
+ icons.sort((a, b) => {
731
+ if (a.provider !== b.provider) {
732
+ return a.provider.localeCompare(b.provider);
733
+ }
734
+ if (a.prefix !== b.prefix) {
735
+ return a.prefix.localeCompare(b.prefix);
736
+ }
737
+ return a.name.localeCompare(b.name);
738
+ });
739
+ let lastIcon = {
740
+ provider: "",
741
+ prefix: "",
742
+ name: ""
743
+ };
744
+ icons.forEach((icon) => {
745
+ if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) {
746
+ return;
747
+ }
748
+ lastIcon = icon;
749
+ const provider = icon.provider;
750
+ const prefix = icon.prefix;
751
+ const name = icon.name;
752
+ const providerStorage = storage2[provider] || (storage2[provider] = /* @__PURE__ */ Object.create(null));
753
+ const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
754
+ let list;
755
+ if (name in localStorage.icons) {
756
+ list = result.loaded;
757
+ } else if (prefix === "" || localStorage.missing.has(name)) {
758
+ list = result.missing;
759
+ } else {
760
+ list = result.pending;
761
+ }
762
+ const item = {
763
+ provider,
764
+ prefix,
765
+ name
766
+ };
767
+ list.push(item);
768
+ });
769
+ return result;
770
+ }
771
+ function removeCallback(storages, id) {
772
+ storages.forEach((storage2) => {
773
+ const items = storage2.loaderCallbacks;
774
+ if (items) {
775
+ storage2.loaderCallbacks = items.filter((row) => row.id !== id);
776
+ }
777
+ });
778
+ }
779
+ function updateCallbacks(storage2) {
780
+ if (!storage2.pendingCallbacksFlag) {
781
+ storage2.pendingCallbacksFlag = true;
782
+ setTimeout(() => {
783
+ storage2.pendingCallbacksFlag = false;
784
+ const items = storage2.loaderCallbacks ? storage2.loaderCallbacks.slice(0) : [];
785
+ if (!items.length) {
786
+ return;
787
+ }
788
+ let hasPending = false;
789
+ const provider = storage2.provider;
790
+ const prefix = storage2.prefix;
791
+ items.forEach((item) => {
792
+ const icons = item.icons;
793
+ const oldLength = icons.pending.length;
794
+ icons.pending = icons.pending.filter((icon) => {
795
+ if (icon.prefix !== prefix) {
796
+ return true;
797
+ }
798
+ const name = icon.name;
799
+ if (storage2.icons[name]) {
800
+ icons.loaded.push({
801
+ provider,
802
+ prefix,
803
+ name
804
+ });
805
+ } else if (storage2.missing.has(name)) {
806
+ icons.missing.push({
807
+ provider,
808
+ prefix,
809
+ name
810
+ });
811
+ } else {
812
+ hasPending = true;
813
+ return true;
814
+ }
815
+ return false;
816
+ });
817
+ if (icons.pending.length !== oldLength) {
818
+ if (!hasPending) {
819
+ removeCallback([storage2], item.id);
820
+ }
821
+ item.callback(
822
+ icons.loaded.slice(0),
823
+ icons.missing.slice(0),
824
+ icons.pending.slice(0),
825
+ item.abort
826
+ );
827
+ }
828
+ });
829
+ });
830
+ }
831
+ }
832
+ let idCounter = 0;
833
+ function storeCallback(callback, icons, pendingSources) {
834
+ const id = idCounter++;
835
+ const abort = removeCallback.bind(null, pendingSources, id);
836
+ if (!icons.pending.length) {
837
+ return abort;
838
+ }
839
+ const item = {
840
+ id,
841
+ icons,
842
+ callback,
843
+ abort
844
+ };
845
+ pendingSources.forEach((storage2) => {
846
+ (storage2.loaderCallbacks || (storage2.loaderCallbacks = [])).push(item);
847
+ });
848
+ return abort;
849
+ }
850
+ function listToIcons(list, validate = true, simpleNames2 = false) {
851
+ const result = [];
852
+ list.forEach((item) => {
853
+ const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames2) : item;
854
+ if (icon) {
855
+ result.push(icon);
856
+ }
857
+ });
858
+ return result;
859
+ }
860
+ var defaultConfig = {
861
+ resources: [],
862
+ index: 0,
863
+ timeout: 2e3,
864
+ rotate: 750,
865
+ random: false,
866
+ dataAfterTimeout: false
867
+ };
868
+ function sendQuery(config, payload, query, done) {
869
+ const resourcesCount = config.resources.length;
870
+ const startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;
871
+ let resources;
872
+ if (config.random) {
873
+ let list = config.resources.slice(0);
874
+ resources = [];
875
+ while (list.length > 1) {
876
+ const nextIndex = Math.floor(Math.random() * list.length);
877
+ resources.push(list[nextIndex]);
878
+ list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
879
+ }
880
+ resources = resources.concat(list);
881
+ } else {
882
+ resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
883
+ }
884
+ const startTime = Date.now();
885
+ let status = "pending";
886
+ let queriesSent = 0;
887
+ let lastError;
888
+ let timer = null;
889
+ let queue = [];
890
+ let doneCallbacks = [];
891
+ if (typeof done === "function") {
892
+ doneCallbacks.push(done);
893
+ }
894
+ function resetTimer() {
895
+ if (timer) {
896
+ clearTimeout(timer);
897
+ timer = null;
898
+ }
899
+ }
900
+ function abort() {
901
+ if (status === "pending") {
902
+ status = "aborted";
903
+ }
904
+ resetTimer();
905
+ queue.forEach((item) => {
906
+ if (item.status === "pending") {
907
+ item.status = "aborted";
908
+ }
909
+ });
910
+ queue = [];
911
+ }
912
+ function subscribe(callback, overwrite) {
913
+ if (overwrite) {
914
+ doneCallbacks = [];
915
+ }
916
+ if (typeof callback === "function") {
917
+ doneCallbacks.push(callback);
918
+ }
919
+ }
920
+ function getQueryStatus() {
921
+ return {
922
+ startTime,
923
+ payload,
924
+ status,
925
+ queriesSent,
926
+ queriesPending: queue.length,
927
+ subscribe,
928
+ abort
929
+ };
930
+ }
931
+ function failQuery() {
932
+ status = "failed";
933
+ doneCallbacks.forEach((callback) => {
934
+ callback(void 0, lastError);
935
+ });
936
+ }
937
+ function clearQueue() {
938
+ queue.forEach((item) => {
939
+ if (item.status === "pending") {
940
+ item.status = "aborted";
941
+ }
942
+ });
943
+ queue = [];
944
+ }
945
+ function moduleResponse(item, response, data) {
946
+ const isError = response !== "success";
947
+ queue = queue.filter((queued) => queued !== item);
948
+ switch (status) {
949
+ case "pending":
950
+ break;
951
+ case "failed":
952
+ if (isError || !config.dataAfterTimeout) {
953
+ return;
954
+ }
955
+ break;
956
+ default:
957
+ return;
958
+ }
959
+ if (response === "abort") {
960
+ lastError = data;
961
+ failQuery();
962
+ return;
963
+ }
964
+ if (isError) {
965
+ lastError = data;
966
+ if (!queue.length) {
967
+ if (!resources.length) {
968
+ failQuery();
969
+ } else {
970
+ execNext();
971
+ }
972
+ }
973
+ return;
974
+ }
975
+ resetTimer();
976
+ clearQueue();
977
+ if (!config.random) {
978
+ const index = config.resources.indexOf(item.resource);
979
+ if (index !== -1 && index !== config.index) {
980
+ config.index = index;
981
+ }
982
+ }
983
+ status = "completed";
984
+ doneCallbacks.forEach((callback) => {
985
+ callback(data);
986
+ });
987
+ }
988
+ function execNext() {
989
+ if (status !== "pending") {
990
+ return;
991
+ }
992
+ resetTimer();
993
+ const resource = resources.shift();
994
+ if (resource === void 0) {
995
+ if (queue.length) {
996
+ timer = setTimeout(() => {
997
+ resetTimer();
998
+ if (status === "pending") {
999
+ clearQueue();
1000
+ failQuery();
1001
+ }
1002
+ }, config.timeout);
1003
+ return;
1004
+ }
1005
+ failQuery();
1006
+ return;
1007
+ }
1008
+ const item = {
1009
+ status: "pending",
1010
+ resource,
1011
+ callback: (status2, data) => {
1012
+ moduleResponse(item, status2, data);
1013
+ }
1014
+ };
1015
+ queue.push(item);
1016
+ queriesSent++;
1017
+ timer = setTimeout(execNext, config.rotate);
1018
+ query(resource, payload, item.callback);
1019
+ }
1020
+ setTimeout(execNext);
1021
+ return getQueryStatus;
1022
+ }
1023
+ function initRedundancy(cfg) {
1024
+ const config = {
1025
+ ...defaultConfig,
1026
+ ...cfg
1027
+ };
1028
+ let queries = [];
1029
+ function cleanup() {
1030
+ queries = queries.filter((item) => item().status === "pending");
1031
+ }
1032
+ function query(payload, queryCallback, doneCallback) {
1033
+ const query2 = sendQuery(
1034
+ config,
1035
+ payload,
1036
+ queryCallback,
1037
+ (data, error) => {
1038
+ cleanup();
1039
+ if (doneCallback) {
1040
+ doneCallback(data, error);
1041
+ }
1042
+ }
1043
+ );
1044
+ queries.push(query2);
1045
+ return query2;
1046
+ }
1047
+ function find(callback) {
1048
+ return queries.find((value) => {
1049
+ return callback(value);
1050
+ }) || null;
1051
+ }
1052
+ const instance = {
1053
+ query,
1054
+ find,
1055
+ setIndex: (index) => {
1056
+ config.index = index;
1057
+ },
1058
+ getIndex: () => config.index,
1059
+ cleanup
1060
+ };
1061
+ return instance;
1062
+ }
1063
+ function emptyCallback$1() {
1064
+ }
1065
+ const redundancyCache = /* @__PURE__ */ Object.create(null);
1066
+ function getRedundancyCache(provider) {
1067
+ if (!redundancyCache[provider]) {
1068
+ const config = getAPIConfig(provider);
1069
+ if (!config) {
1070
+ return;
1071
+ }
1072
+ const redundancy = initRedundancy(config);
1073
+ const cachedReundancy = {
1074
+ config,
1075
+ redundancy
1076
+ };
1077
+ redundancyCache[provider] = cachedReundancy;
1078
+ }
1079
+ return redundancyCache[provider];
1080
+ }
1081
+ function sendAPIQuery(target, query, callback) {
1082
+ let redundancy;
1083
+ let send2;
1084
+ if (typeof target === "string") {
1085
+ const api = getAPIModule(target);
1086
+ if (!api) {
1087
+ callback(void 0, 424);
1088
+ return emptyCallback$1;
1089
+ }
1090
+ send2 = api.send;
1091
+ const cached = getRedundancyCache(target);
1092
+ if (cached) {
1093
+ redundancy = cached.redundancy;
1094
+ }
1095
+ } else {
1096
+ const config = createAPIConfig(target);
1097
+ if (config) {
1098
+ redundancy = initRedundancy(config);
1099
+ const moduleKey = target.resources ? target.resources[0] : "";
1100
+ const api = getAPIModule(moduleKey);
1101
+ if (api) {
1102
+ send2 = api.send;
1103
+ }
1104
+ }
1105
+ }
1106
+ if (!redundancy || !send2) {
1107
+ callback(void 0, 424);
1108
+ return emptyCallback$1;
1109
+ }
1110
+ return redundancy.query(query, send2, callback)().abort;
1111
+ }
1112
+ function emptyCallback() {
1113
+ }
1114
+ function loadedNewIcons(storage2) {
1115
+ if (!storage2.iconsLoaderFlag) {
1116
+ storage2.iconsLoaderFlag = true;
1117
+ setTimeout(() => {
1118
+ storage2.iconsLoaderFlag = false;
1119
+ updateCallbacks(storage2);
1120
+ });
1121
+ }
1122
+ }
1123
+ function checkIconNamesForAPI(icons) {
1124
+ const valid = [];
1125
+ const invalid = [];
1126
+ icons.forEach((name) => {
1127
+ (name.match(matchIconName) ? valid : invalid).push(name);
1128
+ });
1129
+ return {
1130
+ valid,
1131
+ invalid
1132
+ };
1133
+ }
1134
+ function parseLoaderResponse(storage2, icons, data) {
1135
+ function checkMissing() {
1136
+ const pending = storage2.pendingIcons;
1137
+ icons.forEach((name) => {
1138
+ if (pending) {
1139
+ pending.delete(name);
1140
+ }
1141
+ if (!storage2.icons[name]) {
1142
+ storage2.missing.add(name);
1143
+ }
1144
+ });
1145
+ }
1146
+ if (data && typeof data === "object") {
1147
+ try {
1148
+ const parsed = addIconSet(storage2, data);
1149
+ if (!parsed.length) {
1150
+ checkMissing();
1151
+ return;
1152
+ }
1153
+ } catch (err) {
1154
+ console.error(err);
1155
+ }
1156
+ }
1157
+ checkMissing();
1158
+ loadedNewIcons(storage2);
1159
+ }
1160
+ function parsePossiblyAsyncResponse(response, callback) {
1161
+ if (response instanceof Promise) {
1162
+ response.then((data) => {
1163
+ callback(data);
1164
+ }).catch(() => {
1165
+ callback(null);
1166
+ });
1167
+ } else {
1168
+ callback(response);
1169
+ }
1170
+ }
1171
+ function loadNewIcons(storage2, icons) {
1172
+ if (!storage2.iconsToLoad) {
1173
+ storage2.iconsToLoad = icons;
1174
+ } else {
1175
+ storage2.iconsToLoad = storage2.iconsToLoad.concat(icons).sort();
1176
+ }
1177
+ if (!storage2.iconsQueueFlag) {
1178
+ storage2.iconsQueueFlag = true;
1179
+ setTimeout(() => {
1180
+ storage2.iconsQueueFlag = false;
1181
+ const { provider, prefix } = storage2;
1182
+ const icons2 = storage2.iconsToLoad;
1183
+ delete storage2.iconsToLoad;
1184
+ if (!icons2 || !icons2.length) {
1185
+ return;
1186
+ }
1187
+ const customIconLoader = storage2.loadIcon;
1188
+ if (storage2.loadIcons && (icons2.length > 1 || !customIconLoader)) {
1189
+ parsePossiblyAsyncResponse(
1190
+ storage2.loadIcons(icons2, prefix, provider),
1191
+ (data) => {
1192
+ parseLoaderResponse(storage2, icons2, data);
1193
+ }
1194
+ );
1195
+ return;
1196
+ }
1197
+ if (customIconLoader) {
1198
+ icons2.forEach((name) => {
1199
+ const response = customIconLoader(name, prefix, provider);
1200
+ parsePossiblyAsyncResponse(response, (data) => {
1201
+ const iconSet = data ? {
1202
+ prefix,
1203
+ icons: {
1204
+ [name]: data
1205
+ }
1206
+ } : null;
1207
+ parseLoaderResponse(storage2, [name], iconSet);
1208
+ });
1209
+ });
1210
+ return;
1211
+ }
1212
+ const { valid, invalid } = checkIconNamesForAPI(icons2);
1213
+ if (invalid.length) {
1214
+ parseLoaderResponse(storage2, invalid, null);
1215
+ }
1216
+ if (!valid.length) {
1217
+ return;
1218
+ }
1219
+ const api = prefix.match(matchIconName) ? getAPIModule(provider) : null;
1220
+ if (!api) {
1221
+ parseLoaderResponse(storage2, valid, null);
1222
+ return;
1223
+ }
1224
+ const params = api.prepare(provider, prefix, valid);
1225
+ params.forEach((item) => {
1226
+ sendAPIQuery(provider, item, (data) => {
1227
+ parseLoaderResponse(storage2, item.icons, data);
1228
+ });
1229
+ });
1230
+ });
1231
+ }
1232
+ }
1233
+ const loadIcons = (icons, callback) => {
1234
+ const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
1235
+ const sortedIcons = sortIcons(cleanedIcons);
1236
+ if (!sortedIcons.pending.length) {
1237
+ let callCallback = true;
1238
+ if (callback) {
1239
+ setTimeout(() => {
1240
+ if (callCallback) {
1241
+ callback(
1242
+ sortedIcons.loaded,
1243
+ sortedIcons.missing,
1244
+ sortedIcons.pending,
1245
+ emptyCallback
1246
+ );
1247
+ }
1248
+ });
1249
+ }
1250
+ return () => {
1251
+ callCallback = false;
1252
+ };
1253
+ }
1254
+ const newIcons = /* @__PURE__ */ Object.create(null);
1255
+ const sources = [];
1256
+ let lastProvider, lastPrefix;
1257
+ sortedIcons.pending.forEach((icon) => {
1258
+ const { provider, prefix } = icon;
1259
+ if (prefix === lastPrefix && provider === lastProvider) {
1260
+ return;
1261
+ }
1262
+ lastProvider = provider;
1263
+ lastPrefix = prefix;
1264
+ sources.push(getStorage(provider, prefix));
1265
+ const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */ Object.create(null));
1266
+ if (!providerNewIcons[prefix]) {
1267
+ providerNewIcons[prefix] = [];
1268
+ }
1269
+ });
1270
+ sortedIcons.pending.forEach((icon) => {
1271
+ const { provider, prefix, name } = icon;
1272
+ const storage2 = getStorage(provider, prefix);
1273
+ const pendingQueue = storage2.pendingIcons || (storage2.pendingIcons = /* @__PURE__ */ new Set());
1274
+ if (!pendingQueue.has(name)) {
1275
+ pendingQueue.add(name);
1276
+ newIcons[provider][prefix].push(name);
1277
+ }
1278
+ });
1279
+ sources.forEach((storage2) => {
1280
+ const list = newIcons[storage2.provider][storage2.prefix];
1281
+ if (list.length) {
1282
+ loadNewIcons(storage2, list);
1283
+ }
1284
+ });
1285
+ return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
1286
+ };
1287
+ function mergeCustomisations(defaults, item) {
1288
+ const result = {
1289
+ ...defaults
1290
+ };
1291
+ for (const key in item) {
1292
+ const value = item[key];
1293
+ const valueType = typeof value;
1294
+ if (key in defaultIconSizeCustomisations) {
1295
+ if (value === null || value && (valueType === "string" || valueType === "number")) {
1296
+ result[key] = value;
1297
+ }
1298
+ } else if (valueType === typeof result[key]) {
1299
+ result[key] = key === "rotate" ? value % 4 : value;
1300
+ }
1301
+ }
1302
+ return result;
1303
+ }
1304
+ const separator = /[\s,]+/;
1305
+ function flipFromString(custom, flip) {
1306
+ flip.split(separator).forEach((str) => {
1307
+ const value = str.trim();
1308
+ switch (value) {
1309
+ case "horizontal":
1310
+ custom.hFlip = true;
1311
+ break;
1312
+ case "vertical":
1313
+ custom.vFlip = true;
1314
+ break;
1315
+ }
1316
+ });
1317
+ }
1318
+ function rotateFromString(value, defaultValue = 0) {
1319
+ const units = value.replace(/^-?[0-9.]*/, "");
1320
+ function cleanup(value2) {
1321
+ while (value2 < 0) {
1322
+ value2 += 4;
1323
+ }
1324
+ return value2 % 4;
1325
+ }
1326
+ if (units === "") {
1327
+ const num = parseInt(value);
1328
+ return isNaN(num) ? 0 : cleanup(num);
1329
+ } else if (units !== value) {
1330
+ let split = 0;
1331
+ switch (units) {
1332
+ case "%":
1333
+ split = 25;
1334
+ break;
1335
+ case "deg":
1336
+ split = 90;
1337
+ }
1338
+ if (split) {
1339
+ let num = parseFloat(value.slice(0, value.length - units.length));
1340
+ if (isNaN(num)) {
1341
+ return 0;
1342
+ }
1343
+ num = num / split;
1344
+ return num % 1 === 0 ? cleanup(num) : 0;
1345
+ }
1346
+ }
1347
+ return defaultValue;
1348
+ }
1349
+ function iconToHTML(body, attributes) {
1350
+ let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
1351
+ for (const attr in attributes) {
1352
+ renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
1353
+ }
1354
+ return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
1355
+ }
1356
+ function encodeSVGforURL(svg) {
1357
+ return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
1358
+ }
1359
+ function svgToData(svg) {
1360
+ return "data:image/svg+xml," + encodeSVGforURL(svg);
1361
+ }
1362
+ function svgToURL(svg) {
1363
+ return 'url("' + svgToData(svg) + '")';
1364
+ }
1365
+ const defaultExtendedIconCustomisations = {
1366
+ ...defaultIconCustomisations,
1367
+ inline: false
1368
+ };
1369
+ const svgDefaults = {
1370
+ "xmlns": "http://www.w3.org/2000/svg",
1371
+ "xmlns:xlink": "http://www.w3.org/1999/xlink",
1372
+ "aria-hidden": true,
1373
+ "role": "img"
1374
+ };
1375
+ const commonProps = {
1376
+ display: "inline-block"
1377
+ };
1378
+ const monotoneProps = {
1379
+ backgroundColor: "currentColor"
1380
+ };
1381
+ const coloredProps = {
1382
+ backgroundColor: "transparent"
1383
+ };
1384
+ const propsToAdd = {
1385
+ Image: "var(--svg)",
1386
+ Repeat: "no-repeat",
1387
+ Size: "100% 100%"
1388
+ };
1389
+ const propsToAddTo = {
1390
+ webkitMask: monotoneProps,
1391
+ mask: monotoneProps,
1392
+ background: coloredProps
1393
+ };
1394
+ for (const prefix in propsToAddTo) {
1395
+ const list = propsToAddTo[prefix];
1396
+ for (const prop in propsToAdd) {
1397
+ list[prefix + prop] = propsToAdd[prop];
1398
+ }
1399
+ }
1400
+ const customisationAliases = {};
1401
+ ["horizontal", "vertical"].forEach((prefix) => {
1402
+ const attr = prefix.slice(0, 1) + "Flip";
1403
+ customisationAliases[prefix + "-flip"] = attr;
1404
+ customisationAliases[prefix.slice(0, 1) + "-flip"] = attr;
1405
+ customisationAliases[prefix + "Flip"] = attr;
1406
+ });
1407
+ function fixSize(value) {
1408
+ return value + (value.match(/^[-0-9.]+$/) ? "px" : "");
1409
+ }
1410
+ const render = (icon, props) => {
1411
+ const customisations = mergeCustomisations(defaultExtendedIconCustomisations, props);
1412
+ const componentProps = { ...svgDefaults };
1413
+ const mode = props.mode || "svg";
1414
+ const style = {};
1415
+ const propsStyle = props.style;
1416
+ const customStyle = typeof propsStyle === "object" && !(propsStyle instanceof Array) ? propsStyle : {};
1417
+ for (let key in props) {
1418
+ const value = props[key];
1419
+ if (value === void 0) {
1420
+ continue;
1421
+ }
1422
+ switch (key) {
1423
+ // Properties to ignore
1424
+ case "icon":
1425
+ case "style":
1426
+ case "onLoad":
1427
+ case "mode":
1428
+ case "ssr":
1429
+ break;
1430
+ // Boolean attributes
1431
+ case "inline":
1432
+ case "hFlip":
1433
+ case "vFlip":
1434
+ customisations[key] = value === true || value === "true" || value === 1;
1435
+ break;
1436
+ // Flip as string: 'horizontal,vertical'
1437
+ case "flip":
1438
+ if (typeof value === "string") {
1439
+ flipFromString(customisations, value);
1440
+ }
1441
+ break;
1442
+ // Color: override style
1443
+ case "color":
1444
+ style.color = value;
1445
+ break;
1446
+ // Rotation as string
1447
+ case "rotate":
1448
+ if (typeof value === "string") {
1449
+ customisations[key] = rotateFromString(value);
1450
+ } else if (typeof value === "number") {
1451
+ customisations[key] = value;
1452
+ }
1453
+ break;
1454
+ // Remove aria-hidden
1455
+ case "ariaHidden":
1456
+ case "aria-hidden":
1457
+ if (value !== true && value !== "true") {
1458
+ delete componentProps["aria-hidden"];
1459
+ }
1460
+ break;
1461
+ default: {
1462
+ const alias = customisationAliases[key];
1463
+ if (alias) {
1464
+ if (value === true || value === "true" || value === 1) {
1465
+ customisations[alias] = true;
1466
+ }
1467
+ } else if (defaultExtendedIconCustomisations[key] === void 0) {
1468
+ componentProps[key] = value;
1469
+ }
1470
+ }
1471
+ }
1472
+ }
1473
+ const item = iconToSVG(icon, customisations);
1474
+ const renderAttribs = item.attributes;
1475
+ if (customisations.inline) {
1476
+ style.verticalAlign = "-0.125em";
1477
+ }
1478
+ if (mode === "svg") {
1479
+ componentProps.style = {
1480
+ ...style,
1481
+ ...customStyle
1482
+ };
1483
+ Object.assign(componentProps, renderAttribs);
1484
+ let localCounter = 0;
1485
+ let id = props.id;
1486
+ if (typeof id === "string") {
1487
+ id = id.replace(/-/g, "_");
1488
+ }
1489
+ componentProps["innerHTML"] = replaceIDs(item.body, id ? () => id + "ID" + localCounter++ : "iconifyVue");
1490
+ return vue.h("svg", componentProps);
1491
+ }
1492
+ const { body, width, height } = icon;
1493
+ const useMask = mode === "mask" || (mode === "bg" ? false : body.indexOf("currentColor") !== -1);
1494
+ const html = iconToHTML(body, {
1495
+ ...renderAttribs,
1496
+ width: width + "",
1497
+ height: height + ""
1498
+ });
1499
+ componentProps.style = {
1500
+ ...style,
1501
+ "--svg": svgToURL(html),
1502
+ "width": fixSize(renderAttribs.width),
1503
+ "height": fixSize(renderAttribs.height),
1504
+ ...commonProps,
1505
+ ...useMask ? monotoneProps : coloredProps,
1506
+ ...customStyle
1507
+ };
1508
+ return vue.h("span", componentProps);
1509
+ };
1510
+ allowSimpleNames(true);
1511
+ setAPIModule("", fetchAPIModule);
1512
+ if (typeof document !== "undefined" && typeof window !== "undefined") {
1513
+ const _window = window;
1514
+ if (_window.IconifyPreload !== void 0) {
1515
+ const preload = _window.IconifyPreload;
1516
+ const err = "Invalid IconifyPreload syntax.";
1517
+ if (typeof preload === "object" && preload !== null) {
1518
+ (preload instanceof Array ? preload : [preload]).forEach((item) => {
1519
+ try {
1520
+ if (
1521
+ // Check if item is an object and not null/array
1522
+ typeof item !== "object" || item === null || item instanceof Array || // Check for 'icons' and 'prefix'
1523
+ typeof item.icons !== "object" || typeof item.prefix !== "string" || // Add icon set
1524
+ !addCollection(item)
1525
+ ) {
1526
+ console.error(err);
1527
+ }
1528
+ } catch (e) {
1529
+ console.error(err);
1530
+ }
1531
+ });
1532
+ }
1533
+ }
1534
+ if (_window.IconifyProviders !== void 0) {
1535
+ const providers = _window.IconifyProviders;
1536
+ if (typeof providers === "object" && providers !== null) {
1537
+ for (let key in providers) {
1538
+ const err = "IconifyProviders[" + key + "] is invalid.";
1539
+ try {
1540
+ const value = providers[key];
1541
+ if (typeof value !== "object" || !value || value.resources === void 0) {
1542
+ continue;
1543
+ }
1544
+ if (!addAPIProvider(key, value)) {
1545
+ console.error(err);
1546
+ }
1547
+ } catch (e) {
1548
+ console.error(err);
1549
+ }
1550
+ }
1551
+ }
1552
+ }
1553
+ }
1554
+ const emptyIcon = {
1555
+ ...defaultIconProps,
1556
+ body: ""
1557
+ };
1558
+ const Icon = vue.defineComponent((props, { emit }) => {
1559
+ const loader = vue.ref(null);
1560
+ function abortLoading() {
1561
+ var _a, _b;
1562
+ if (loader.value) {
1563
+ (_b = (_a = loader.value).abort) == null ? void 0 : _b.call(_a);
1564
+ loader.value = null;
1565
+ }
1566
+ }
1567
+ const rendering = vue.ref(!!props.ssr);
1568
+ const lastRenderedIconName = vue.ref("");
1569
+ const iconData = vue.shallowRef(null);
1570
+ function getIcon() {
1571
+ const icon = props.icon;
1572
+ if (typeof icon === "object" && icon !== null && typeof icon.body === "string") {
1573
+ lastRenderedIconName.value = "";
1574
+ return {
1575
+ data: icon
1576
+ };
1577
+ }
1578
+ let iconName;
1579
+ if (typeof icon !== "string" || (iconName = stringToIcon(icon, false, true)) === null) {
1580
+ return null;
1581
+ }
1582
+ let data = getIconData(iconName);
1583
+ if (!data) {
1584
+ const oldState = loader.value;
1585
+ if (!oldState || oldState.name !== icon) {
1586
+ if (data === null) {
1587
+ loader.value = {
1588
+ name: icon
1589
+ };
1590
+ } else {
1591
+ loader.value = {
1592
+ name: icon,
1593
+ abort: loadIcons([iconName], updateIconData)
1594
+ };
1595
+ }
1596
+ }
1597
+ return null;
1598
+ }
1599
+ abortLoading();
1600
+ if (lastRenderedIconName.value !== icon) {
1601
+ lastRenderedIconName.value = icon;
1602
+ vue.nextTick(() => {
1603
+ emit("load", icon);
1604
+ });
1605
+ }
1606
+ const customise = props.customise;
1607
+ if (customise) {
1608
+ data = Object.assign({}, data);
1609
+ const customised = customise(data.body, iconName.name, iconName.prefix, iconName.provider);
1610
+ if (typeof customised === "string") {
1611
+ data.body = customised;
1612
+ }
1613
+ }
1614
+ const classes = ["iconify"];
1615
+ if (iconName.prefix !== "") {
1616
+ classes.push("iconify--" + iconName.prefix);
1617
+ }
1618
+ if (iconName.provider !== "") {
1619
+ classes.push("iconify--" + iconName.provider);
1620
+ }
1621
+ return { data, classes };
1622
+ }
1623
+ function updateIconData() {
1624
+ var _a;
1625
+ const icon = getIcon();
1626
+ if (!icon) {
1627
+ iconData.value = null;
1628
+ } else if (icon.data !== ((_a = iconData.value) == null ? void 0 : _a.data)) {
1629
+ iconData.value = icon;
1630
+ }
1631
+ }
1632
+ if (rendering.value) {
1633
+ updateIconData();
1634
+ } else {
1635
+ vue.onMounted(() => {
1636
+ rendering.value = true;
1637
+ updateIconData();
1638
+ });
1639
+ }
1640
+ vue.watch(() => props.icon, updateIconData);
1641
+ vue.onUnmounted(abortLoading);
1642
+ return () => {
1643
+ const icon = iconData.value;
1644
+ if (!icon) {
1645
+ return render(emptyIcon, props);
1646
+ }
1647
+ let newProps = props;
1648
+ if (icon.classes) {
1649
+ newProps = {
1650
+ ...props,
1651
+ class: icon.classes.join(" ")
1652
+ };
1653
+ }
1654
+ return render({
1655
+ ...defaultIconProps,
1656
+ ...icon.data
1657
+ }, newProps);
1658
+ };
1659
+ }, {
1660
+ props: [
1661
+ // Icon and render mode
1662
+ "icon",
1663
+ "mode",
1664
+ "ssr",
1665
+ // Layout and style
1666
+ "width",
1667
+ "height",
1668
+ "style",
1669
+ "color",
1670
+ "inline",
1671
+ // Transformations
1672
+ "rotate",
1673
+ "hFlip",
1674
+ "horizontalFlip",
1675
+ "vFlip",
1676
+ "verticalFlip",
1677
+ "flip",
1678
+ // Misc
1679
+ "id",
1680
+ "ariaHidden",
1681
+ "customise",
1682
+ "title"
1683
+ ],
1684
+ emits: ["load"]
1685
+ });
1686
+ exports.Icon = Icon;
1687
+ exports.addAPIProvider = addAPIProvider;
1688
+ exports.addCollection = addCollection;
1689
+ exports.addIcon = addIcon;
1690
+ exports.buildIcon = iconToSVG;
1691
+ exports.calculateSize = calculateSize;
1692
+ exports.loadIcons = loadIcons;
1693
+ exports.replaceIDs = replaceIDs;