@pequity/squirrel 5.2.2 → 5.3.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 (86) hide show
  1. package/dist/cjs/chunks/component.js +4 -0
  2. package/dist/cjs/chunks/p-dropdown-select.js +1 -1
  3. package/dist/cjs/chunks/p-icon.js +2180 -0
  4. package/dist/cjs/chunks/string.js +13 -0
  5. package/dist/cjs/component.js +28 -0
  6. package/dist/cjs/index.js +32 -2188
  7. package/dist/cjs/p-input-search.js +3 -2
  8. package/dist/cjs/p-loading.js +4 -7
  9. package/dist/cjs/p-modal.js +5 -2
  10. package/dist/cjs/string.js +32 -11
  11. package/dist/cjs/useSelectList.js +1 -1
  12. package/dist/es/chunks/component.js +5 -0
  13. package/dist/es/chunks/p-dropdown-select.js +1 -1
  14. package/dist/es/chunks/p-icon.js +2181 -0
  15. package/dist/es/chunks/string.js +14 -0
  16. package/dist/es/component.js +27 -0
  17. package/dist/es/index.js +31 -2187
  18. package/dist/es/p-input-search.js +3 -2
  19. package/dist/es/p-loading.js +4 -7
  20. package/dist/es/p-modal.js +5 -2
  21. package/dist/es/string.js +32 -12
  22. package/dist/es/useSelectList.js +1 -1
  23. package/dist/squirrel/components/p-action-bar/p-action-bar.types.d.ts +3 -2
  24. package/dist/squirrel/utils/component.d.ts +2 -0
  25. package/dist/squirrel/utils/component.spec.d.ts +1 -0
  26. package/dist/squirrel/utils/string.d.ts +1 -0
  27. package/dist/squirrel/utils/string.spec.d.ts +1 -0
  28. package/dist/style.css +33 -33
  29. package/package.json +22 -27
  30. package/squirrel/components/p-action-bar/p-action-bar.spec.js +47 -15
  31. package/squirrel/components/p-action-bar/p-action-bar.stories.js +6 -0
  32. package/squirrel/components/p-action-bar/p-action-bar.types.ts +4 -2
  33. package/squirrel/components/p-action-bar/p-action-bar.vue +9 -3
  34. package/squirrel/components/p-alert/p-alert.spec.js +1 -1
  35. package/squirrel/components/p-avatar/p-avatar.spec.js +16 -1
  36. package/squirrel/components/p-btn/p-btn.spec.js +3 -7
  37. package/squirrel/components/p-card/p-card.spec.js +1 -1
  38. package/squirrel/components/p-checkbox/p-checkbox.spec.js +1 -1
  39. package/squirrel/components/p-chips/p-chips.spec.js +1 -1
  40. package/squirrel/components/p-close-btn/p-close-btn.spec.js +1 -1
  41. package/squirrel/components/p-dropdown/p-dropdown.spec.js +5 -9
  42. package/squirrel/components/p-dropdown-select/p-dropdown-select.spec.js +4 -5
  43. package/squirrel/components/p-file-upload/p-file-upload.spec.js +1 -1
  44. package/squirrel/components/p-icon/p-icon.spec.js +15 -29
  45. package/squirrel/components/p-info-icon/p-info-icon.spec.js +1 -1
  46. package/squirrel/components/p-inline-date-picker/p-inline-date-picker.spec.js +4 -4
  47. package/squirrel/components/p-input/p-input.spec.js +1 -1
  48. package/squirrel/components/p-input-number/p-input-number.spec.js +1 -1
  49. package/squirrel/components/p-input-percent/p-input-percent.spec.js +1 -1
  50. package/squirrel/components/p-input-search/p-input-search.spec.js +1 -1
  51. package/squirrel/components/p-input-search/p-input-search.vue +1 -1
  52. package/squirrel/components/p-link/p-link.spec.js +3 -7
  53. package/squirrel/components/p-loading/p-loading.spec.js +23 -23
  54. package/squirrel/components/p-loading/p-loading.vue +2 -7
  55. package/squirrel/components/p-modal/p-modal-basic.spec.js +1 -1
  56. package/squirrel/components/p-modal/p-modal-events.spec.js +1 -1
  57. package/squirrel/components/p-modal/p-modal-features.spec.js +1 -1
  58. package/squirrel/components/p-modal/p-modal.vue +4 -0
  59. package/squirrel/components/p-pagination/p-pagination.spec.js +1 -1
  60. package/squirrel/components/p-pagination-info/p-pagination-info.spec.js +1 -1
  61. package/squirrel/components/p-progress-bar/p-progess-bar.spec.js +1 -1
  62. package/squirrel/components/p-ring-loader/p-ring-loader.spec.js +1 -1
  63. package/squirrel/components/p-select/p-select.spec.js +1 -1
  64. package/squirrel/components/p-select-btn/p-select-btn.spec.js +1 -1
  65. package/squirrel/components/p-select-list/p-select-list.spec.js +4 -5
  66. package/squirrel/components/p-select-pill/p-select-pill.spec.js +1 -1
  67. package/squirrel/components/p-skeleton-loader/p-skeleton-loader.spec.js +1 -1
  68. package/squirrel/components/p-table/p-table.spec.js +1 -1
  69. package/squirrel/components/p-table-header-cell/p-filter-icon.spec.js +1 -1
  70. package/squirrel/components/p-table-header-cell/p-table-header-cell.spec.js +1 -1
  71. package/squirrel/components/p-table-loader/p-table-loader.spec.js +1 -1
  72. package/squirrel/components/p-table-sort/p-table-sort.spec.js +1 -1
  73. package/squirrel/components/p-table-td/p-table-td.spec.js +35 -1
  74. package/squirrel/components/p-tabs/p-tabs.spec.js +1 -1
  75. package/squirrel/components/p-textarea/p-textarea.spec.js +1 -1
  76. package/squirrel/components/p-toggle/p-toggle.spec.js +1 -1
  77. package/squirrel/composables/useInputClasses.spec.js +41 -0
  78. package/squirrel/index.spec.js +21 -0
  79. package/squirrel/utils/component.spec.ts +29 -0
  80. package/squirrel/utils/component.ts +5 -0
  81. package/squirrel/utils/dom.spec.js +2 -3
  82. package/squirrel/utils/listKeyboardNavigation.spec.js +5 -9
  83. package/squirrel/utils/sanitization.spec.js +1 -1
  84. package/squirrel/utils/{string.spec.js → string.spec.ts} +19 -1
  85. package/squirrel/utils/string.ts +2 -0
  86. package/squirrel/utils/tailwind.spec.js +27 -0
@@ -0,0 +1,2180 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ const vue = require("vue");
6
+ const pIcon = require("../p-icon.js");
7
+ /**
8
+ * (c) Iconify
9
+ *
10
+ * For the full copyright and license information, please view the license.txt
11
+ * files at https://github.com/iconify/iconify
12
+ *
13
+ * Licensed under MIT.
14
+ *
15
+ * @license MIT
16
+ * @version 2.1.0
17
+ */
18
+ const defaultIconDimensions = Object.freeze(
19
+ {
20
+ left: 0,
21
+ top: 0,
22
+ width: 16,
23
+ height: 16
24
+ }
25
+ );
26
+ const defaultIconTransformations = Object.freeze({
27
+ rotate: 0,
28
+ vFlip: false,
29
+ hFlip: false
30
+ });
31
+ const defaultIconProps = Object.freeze({
32
+ ...defaultIconDimensions,
33
+ ...defaultIconTransformations
34
+ });
35
+ const defaultExtendedIconProps = Object.freeze({
36
+ ...defaultIconProps,
37
+ body: "",
38
+ hidden: false
39
+ });
40
+ const defaultIconSizeCustomisations = Object.freeze({
41
+ width: null,
42
+ height: null
43
+ });
44
+ const defaultIconCustomisations = Object.freeze({
45
+ // Dimensions
46
+ ...defaultIconSizeCustomisations,
47
+ // Transformations
48
+ ...defaultIconTransformations
49
+ });
50
+ function rotateFromString(value, defaultValue = 0) {
51
+ const units = value.replace(/^-?[0-9.]*/, "");
52
+ function cleanup(value2) {
53
+ while (value2 < 0) {
54
+ value2 += 4;
55
+ }
56
+ return value2 % 4;
57
+ }
58
+ if (units === "") {
59
+ const num = parseInt(value);
60
+ return isNaN(num) ? 0 : cleanup(num);
61
+ } else if (units !== value) {
62
+ let split = 0;
63
+ switch (units) {
64
+ case "%":
65
+ split = 25;
66
+ break;
67
+ case "deg":
68
+ split = 90;
69
+ }
70
+ if (split) {
71
+ let num = parseFloat(value.slice(0, value.length - units.length));
72
+ if (isNaN(num)) {
73
+ return 0;
74
+ }
75
+ num = num / split;
76
+ return num % 1 === 0 ? cleanup(num) : 0;
77
+ }
78
+ }
79
+ return defaultValue;
80
+ }
81
+ const separator = /[\s,]+/;
82
+ function flipFromString(custom, flip) {
83
+ flip.split(separator).forEach((str) => {
84
+ const value = str.trim();
85
+ switch (value) {
86
+ case "horizontal":
87
+ custom.hFlip = true;
88
+ break;
89
+ case "vertical":
90
+ custom.vFlip = true;
91
+ break;
92
+ }
93
+ });
94
+ }
95
+ const defaultCustomisations = {
96
+ ...defaultIconCustomisations,
97
+ preserveAspectRatio: ""
98
+ };
99
+ function getCustomisations(node) {
100
+ const customisations = {
101
+ ...defaultCustomisations
102
+ };
103
+ const attr = (key, def) => node.getAttribute(key) || def;
104
+ customisations.width = attr("width", null);
105
+ customisations.height = attr("height", null);
106
+ customisations.rotate = rotateFromString(attr("rotate", ""));
107
+ flipFromString(customisations, attr("flip", ""));
108
+ customisations.preserveAspectRatio = attr("preserveAspectRatio", attr("preserveaspectratio", ""));
109
+ return customisations;
110
+ }
111
+ function haveCustomisationsChanged(value1, value2) {
112
+ for (const key in defaultCustomisations) {
113
+ if (value1[key] !== value2[key]) {
114
+ return true;
115
+ }
116
+ }
117
+ return false;
118
+ }
119
+ const matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
120
+ const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
121
+ const colonSeparated = value.split(":");
122
+ if (value.slice(0, 1) === "@") {
123
+ if (colonSeparated.length < 2 || colonSeparated.length > 3) {
124
+ return null;
125
+ }
126
+ provider = colonSeparated.shift().slice(1);
127
+ }
128
+ if (colonSeparated.length > 3 || !colonSeparated.length) {
129
+ return null;
130
+ }
131
+ if (colonSeparated.length > 1) {
132
+ const name2 = colonSeparated.pop();
133
+ const prefix = colonSeparated.pop();
134
+ const result = {
135
+ // Allow provider without '@': "provider:prefix:name"
136
+ provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
137
+ prefix,
138
+ name: name2
139
+ };
140
+ return validate && !validateIconName(result) ? null : result;
141
+ }
142
+ const name = colonSeparated[0];
143
+ const dashSeparated = name.split("-");
144
+ if (dashSeparated.length > 1) {
145
+ const result = {
146
+ provider,
147
+ prefix: dashSeparated.shift(),
148
+ name: dashSeparated.join("-")
149
+ };
150
+ return validate && !validateIconName(result) ? null : result;
151
+ }
152
+ if (allowSimpleName && provider === "") {
153
+ const result = {
154
+ provider,
155
+ prefix: "",
156
+ name
157
+ };
158
+ return validate && !validateIconName(result, allowSimpleName) ? null : result;
159
+ }
160
+ return null;
161
+ };
162
+ const validateIconName = (icon, allowSimpleName) => {
163
+ if (!icon) {
164
+ return false;
165
+ }
166
+ return !!((icon.provider === "" || icon.provider.match(matchIconName)) && (allowSimpleName && icon.prefix === "" || icon.prefix.match(matchIconName)) && icon.name.match(matchIconName));
167
+ };
168
+ function mergeIconTransformations(obj1, obj2) {
169
+ const result = {};
170
+ if (!obj1.hFlip !== !obj2.hFlip) {
171
+ result.hFlip = true;
172
+ }
173
+ if (!obj1.vFlip !== !obj2.vFlip) {
174
+ result.vFlip = true;
175
+ }
176
+ const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
177
+ if (rotate) {
178
+ result.rotate = rotate;
179
+ }
180
+ return result;
181
+ }
182
+ function mergeIconData(parent, child) {
183
+ const result = mergeIconTransformations(parent, child);
184
+ for (const key in defaultExtendedIconProps) {
185
+ if (key in defaultIconTransformations) {
186
+ if (key in parent && !(key in result)) {
187
+ result[key] = defaultIconTransformations[key];
188
+ }
189
+ } else if (key in child) {
190
+ result[key] = child[key];
191
+ } else if (key in parent) {
192
+ result[key] = parent[key];
193
+ }
194
+ }
195
+ return result;
196
+ }
197
+ function getIconsTree(data, names) {
198
+ const icons = data.icons;
199
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
200
+ const resolved = /* @__PURE__ */ Object.create(null);
201
+ function resolve(name) {
202
+ if (icons[name]) {
203
+ return resolved[name] = [];
204
+ }
205
+ if (!(name in resolved)) {
206
+ resolved[name] = null;
207
+ const parent = aliases[name] && aliases[name].parent;
208
+ const value = parent && resolve(parent);
209
+ if (value) {
210
+ resolved[name] = [parent].concat(value);
211
+ }
212
+ }
213
+ return resolved[name];
214
+ }
215
+ Object.keys(icons).concat(Object.keys(aliases)).forEach(resolve);
216
+ return resolved;
217
+ }
218
+ function internalGetIconData(data, name, tree) {
219
+ const icons = data.icons;
220
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
221
+ let currentProps = {};
222
+ function parse(name2) {
223
+ currentProps = mergeIconData(
224
+ icons[name2] || aliases[name2],
225
+ currentProps
226
+ );
227
+ }
228
+ parse(name);
229
+ tree.forEach(parse);
230
+ return mergeIconData(data, currentProps);
231
+ }
232
+ function parseIconSet(data, callback) {
233
+ const names = [];
234
+ if (typeof data !== "object" || typeof data.icons !== "object") {
235
+ return names;
236
+ }
237
+ if (data.not_found instanceof Array) {
238
+ data.not_found.forEach((name) => {
239
+ callback(name, null);
240
+ names.push(name);
241
+ });
242
+ }
243
+ const tree = getIconsTree(data);
244
+ for (const name in tree) {
245
+ const item = tree[name];
246
+ if (item) {
247
+ callback(name, internalGetIconData(data, name, item));
248
+ names.push(name);
249
+ }
250
+ }
251
+ return names;
252
+ }
253
+ const optionalPropertyDefaults = {
254
+ provider: "",
255
+ aliases: {},
256
+ not_found: {},
257
+ ...defaultIconDimensions
258
+ };
259
+ function checkOptionalProps(item, defaults) {
260
+ for (const prop in defaults) {
261
+ if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
262
+ return false;
263
+ }
264
+ }
265
+ return true;
266
+ }
267
+ function quicklyValidateIconSet(obj) {
268
+ if (typeof obj !== "object" || obj === null) {
269
+ return null;
270
+ }
271
+ const data = obj;
272
+ if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
273
+ return null;
274
+ }
275
+ if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
276
+ return null;
277
+ }
278
+ const icons = data.icons;
279
+ for (const name in icons) {
280
+ const icon = icons[name];
281
+ if (!name.match(matchIconName) || typeof icon.body !== "string" || !checkOptionalProps(
282
+ icon,
283
+ defaultExtendedIconProps
284
+ )) {
285
+ return null;
286
+ }
287
+ }
288
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
289
+ for (const name in aliases) {
290
+ const icon = aliases[name];
291
+ const parent = icon.parent;
292
+ if (!name.match(matchIconName) || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(
293
+ icon,
294
+ defaultExtendedIconProps
295
+ )) {
296
+ return null;
297
+ }
298
+ }
299
+ return data;
300
+ }
301
+ const dataStorage = /* @__PURE__ */ Object.create(null);
302
+ function newStorage(provider, prefix) {
303
+ return {
304
+ provider,
305
+ prefix,
306
+ icons: /* @__PURE__ */ Object.create(null),
307
+ missing: /* @__PURE__ */ new Set()
308
+ };
309
+ }
310
+ function getStorage(provider, prefix) {
311
+ const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
312
+ return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
313
+ }
314
+ function addIconSet(storage2, data) {
315
+ if (!quicklyValidateIconSet(data)) {
316
+ return [];
317
+ }
318
+ return parseIconSet(data, (name, icon) => {
319
+ if (icon) {
320
+ storage2.icons[name] = icon;
321
+ } else {
322
+ storage2.missing.add(name);
323
+ }
324
+ });
325
+ }
326
+ function addIconToStorage(storage2, name, icon) {
327
+ try {
328
+ if (typeof icon.body === "string") {
329
+ storage2.icons[name] = { ...icon };
330
+ return true;
331
+ }
332
+ } catch (err) {
333
+ }
334
+ return false;
335
+ }
336
+ function listIcons$1(provider, prefix) {
337
+ let allIcons = [];
338
+ const providers = typeof provider === "string" ? [provider] : Object.keys(dataStorage);
339
+ providers.forEach((provider2) => {
340
+ const prefixes = typeof provider2 === "string" && typeof prefix === "string" ? [prefix] : Object.keys(dataStorage[provider2] || {});
341
+ prefixes.forEach((prefix2) => {
342
+ const storage2 = getStorage(provider2, prefix2);
343
+ allIcons = allIcons.concat(
344
+ Object.keys(storage2.icons).map(
345
+ (name) => (provider2 !== "" ? "@" + provider2 + ":" : "") + prefix2 + ":" + name
346
+ )
347
+ );
348
+ });
349
+ });
350
+ return allIcons;
351
+ }
352
+ let simpleNames = false;
353
+ function allowSimpleNames(allow) {
354
+ if (typeof allow === "boolean") {
355
+ simpleNames = allow;
356
+ }
357
+ return simpleNames;
358
+ }
359
+ function getIconData(name) {
360
+ const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
361
+ if (icon) {
362
+ const storage2 = getStorage(icon.provider, icon.prefix);
363
+ const iconName = icon.name;
364
+ return storage2.icons[iconName] || (storage2.missing.has(iconName) ? null : void 0);
365
+ }
366
+ }
367
+ function addIcon$1(name, data) {
368
+ const icon = stringToIcon(name, true, simpleNames);
369
+ if (!icon) {
370
+ return false;
371
+ }
372
+ const storage2 = getStorage(icon.provider, icon.prefix);
373
+ return addIconToStorage(storage2, icon.name, data);
374
+ }
375
+ function addCollection$1(data, provider) {
376
+ if (typeof data !== "object") {
377
+ return false;
378
+ }
379
+ if (typeof provider !== "string") {
380
+ provider = data.provider || "";
381
+ }
382
+ if (simpleNames && !provider && !data.prefix) {
383
+ let added = false;
384
+ if (quicklyValidateIconSet(data)) {
385
+ data.prefix = "";
386
+ parseIconSet(data, (name, icon) => {
387
+ if (icon && addIcon$1(name, icon)) {
388
+ added = true;
389
+ }
390
+ });
391
+ }
392
+ return added;
393
+ }
394
+ const prefix = data.prefix;
395
+ if (!validateIconName({
396
+ provider,
397
+ prefix,
398
+ name: "a"
399
+ })) {
400
+ return false;
401
+ }
402
+ const storage2 = getStorage(provider, prefix);
403
+ return !!addIconSet(storage2, data);
404
+ }
405
+ function iconLoaded$1(name) {
406
+ return !!getIconData(name);
407
+ }
408
+ function getIcon$1(name) {
409
+ const result = getIconData(name);
410
+ return result ? {
411
+ ...defaultIconProps,
412
+ ...result
413
+ } : null;
414
+ }
415
+ function sortIcons(icons) {
416
+ const result = {
417
+ loaded: [],
418
+ missing: [],
419
+ pending: []
420
+ };
421
+ const storage2 = /* @__PURE__ */ Object.create(null);
422
+ icons.sort((a, b) => {
423
+ if (a.provider !== b.provider) {
424
+ return a.provider.localeCompare(b.provider);
425
+ }
426
+ if (a.prefix !== b.prefix) {
427
+ return a.prefix.localeCompare(b.prefix);
428
+ }
429
+ return a.name.localeCompare(b.name);
430
+ });
431
+ let lastIcon = {
432
+ provider: "",
433
+ prefix: "",
434
+ name: ""
435
+ };
436
+ icons.forEach((icon) => {
437
+ if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) {
438
+ return;
439
+ }
440
+ lastIcon = icon;
441
+ const provider = icon.provider;
442
+ const prefix = icon.prefix;
443
+ const name = icon.name;
444
+ const providerStorage = storage2[provider] || (storage2[provider] = /* @__PURE__ */ Object.create(null));
445
+ const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
446
+ let list;
447
+ if (name in localStorage.icons) {
448
+ list = result.loaded;
449
+ } else if (prefix === "" || localStorage.missing.has(name)) {
450
+ list = result.missing;
451
+ } else {
452
+ list = result.pending;
453
+ }
454
+ const item = {
455
+ provider,
456
+ prefix,
457
+ name
458
+ };
459
+ list.push(item);
460
+ });
461
+ return result;
462
+ }
463
+ function removeCallback(storages, id) {
464
+ storages.forEach((storage2) => {
465
+ const items = storage2.loaderCallbacks;
466
+ if (items) {
467
+ storage2.loaderCallbacks = items.filter((row) => row.id !== id);
468
+ }
469
+ });
470
+ }
471
+ function updateCallbacks(storage2) {
472
+ if (!storage2.pendingCallbacksFlag) {
473
+ storage2.pendingCallbacksFlag = true;
474
+ setTimeout(() => {
475
+ storage2.pendingCallbacksFlag = false;
476
+ const items = storage2.loaderCallbacks ? storage2.loaderCallbacks.slice(0) : [];
477
+ if (!items.length) {
478
+ return;
479
+ }
480
+ let hasPending = false;
481
+ const provider = storage2.provider;
482
+ const prefix = storage2.prefix;
483
+ items.forEach((item) => {
484
+ const icons = item.icons;
485
+ const oldLength = icons.pending.length;
486
+ icons.pending = icons.pending.filter((icon) => {
487
+ if (icon.prefix !== prefix) {
488
+ return true;
489
+ }
490
+ const name = icon.name;
491
+ if (storage2.icons[name]) {
492
+ icons.loaded.push({
493
+ provider,
494
+ prefix,
495
+ name
496
+ });
497
+ } else if (storage2.missing.has(name)) {
498
+ icons.missing.push({
499
+ provider,
500
+ prefix,
501
+ name
502
+ });
503
+ } else {
504
+ hasPending = true;
505
+ return true;
506
+ }
507
+ return false;
508
+ });
509
+ if (icons.pending.length !== oldLength) {
510
+ if (!hasPending) {
511
+ removeCallback([storage2], item.id);
512
+ }
513
+ item.callback(
514
+ icons.loaded.slice(0),
515
+ icons.missing.slice(0),
516
+ icons.pending.slice(0),
517
+ item.abort
518
+ );
519
+ }
520
+ });
521
+ });
522
+ }
523
+ }
524
+ let idCounter = 0;
525
+ function storeCallback(callback, icons, pendingSources) {
526
+ const id = idCounter++;
527
+ const abort = removeCallback.bind(null, pendingSources, id);
528
+ if (!icons.pending.length) {
529
+ return abort;
530
+ }
531
+ const item = {
532
+ id,
533
+ icons,
534
+ callback,
535
+ abort
536
+ };
537
+ pendingSources.forEach((storage2) => {
538
+ (storage2.loaderCallbacks || (storage2.loaderCallbacks = [])).push(item);
539
+ });
540
+ return abort;
541
+ }
542
+ const storage = /* @__PURE__ */ Object.create(null);
543
+ function setAPIModule(provider, item) {
544
+ storage[provider] = item;
545
+ }
546
+ function getAPIModule(provider) {
547
+ return storage[provider] || storage[""];
548
+ }
549
+ function listToIcons(list, validate = true, simpleNames2 = false) {
550
+ const result = [];
551
+ list.forEach((item) => {
552
+ const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames2) : item;
553
+ if (icon) {
554
+ result.push(icon);
555
+ }
556
+ });
557
+ return result;
558
+ }
559
+ var defaultConfig = {
560
+ resources: [],
561
+ index: 0,
562
+ timeout: 2e3,
563
+ rotate: 750,
564
+ random: false,
565
+ dataAfterTimeout: false
566
+ };
567
+ function sendQuery(config, payload, query, done) {
568
+ const resourcesCount = config.resources.length;
569
+ const startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;
570
+ let resources;
571
+ if (config.random) {
572
+ let list = config.resources.slice(0);
573
+ resources = [];
574
+ while (list.length > 1) {
575
+ const nextIndex = Math.floor(Math.random() * list.length);
576
+ resources.push(list[nextIndex]);
577
+ list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
578
+ }
579
+ resources = resources.concat(list);
580
+ } else {
581
+ resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
582
+ }
583
+ const startTime = Date.now();
584
+ let status = "pending";
585
+ let queriesSent = 0;
586
+ let lastError;
587
+ let timer = null;
588
+ let queue = [];
589
+ let doneCallbacks = [];
590
+ if (typeof done === "function") {
591
+ doneCallbacks.push(done);
592
+ }
593
+ function resetTimer() {
594
+ if (timer) {
595
+ clearTimeout(timer);
596
+ timer = null;
597
+ }
598
+ }
599
+ function abort() {
600
+ if (status === "pending") {
601
+ status = "aborted";
602
+ }
603
+ resetTimer();
604
+ queue.forEach((item) => {
605
+ if (item.status === "pending") {
606
+ item.status = "aborted";
607
+ }
608
+ });
609
+ queue = [];
610
+ }
611
+ function subscribe(callback, overwrite) {
612
+ if (overwrite) {
613
+ doneCallbacks = [];
614
+ }
615
+ if (typeof callback === "function") {
616
+ doneCallbacks.push(callback);
617
+ }
618
+ }
619
+ function getQueryStatus() {
620
+ return {
621
+ startTime,
622
+ payload,
623
+ status,
624
+ queriesSent,
625
+ queriesPending: queue.length,
626
+ subscribe,
627
+ abort
628
+ };
629
+ }
630
+ function failQuery() {
631
+ status = "failed";
632
+ doneCallbacks.forEach((callback) => {
633
+ callback(void 0, lastError);
634
+ });
635
+ }
636
+ function clearQueue() {
637
+ queue.forEach((item) => {
638
+ if (item.status === "pending") {
639
+ item.status = "aborted";
640
+ }
641
+ });
642
+ queue = [];
643
+ }
644
+ function moduleResponse(item, response, data) {
645
+ const isError = response !== "success";
646
+ queue = queue.filter((queued) => queued !== item);
647
+ switch (status) {
648
+ case "pending":
649
+ break;
650
+ case "failed":
651
+ if (isError || !config.dataAfterTimeout) {
652
+ return;
653
+ }
654
+ break;
655
+ default:
656
+ return;
657
+ }
658
+ if (response === "abort") {
659
+ lastError = data;
660
+ failQuery();
661
+ return;
662
+ }
663
+ if (isError) {
664
+ lastError = data;
665
+ if (!queue.length) {
666
+ if (!resources.length) {
667
+ failQuery();
668
+ } else {
669
+ execNext();
670
+ }
671
+ }
672
+ return;
673
+ }
674
+ resetTimer();
675
+ clearQueue();
676
+ if (!config.random) {
677
+ const index = config.resources.indexOf(item.resource);
678
+ if (index !== -1 && index !== config.index) {
679
+ config.index = index;
680
+ }
681
+ }
682
+ status = "completed";
683
+ doneCallbacks.forEach((callback) => {
684
+ callback(data);
685
+ });
686
+ }
687
+ function execNext() {
688
+ if (status !== "pending") {
689
+ return;
690
+ }
691
+ resetTimer();
692
+ const resource = resources.shift();
693
+ if (resource === void 0) {
694
+ if (queue.length) {
695
+ timer = setTimeout(() => {
696
+ resetTimer();
697
+ if (status === "pending") {
698
+ clearQueue();
699
+ failQuery();
700
+ }
701
+ }, config.timeout);
702
+ return;
703
+ }
704
+ failQuery();
705
+ return;
706
+ }
707
+ const item = {
708
+ status: "pending",
709
+ resource,
710
+ callback: (status2, data) => {
711
+ moduleResponse(item, status2, data);
712
+ }
713
+ };
714
+ queue.push(item);
715
+ queriesSent++;
716
+ timer = setTimeout(execNext, config.rotate);
717
+ query(resource, payload, item.callback);
718
+ }
719
+ setTimeout(execNext);
720
+ return getQueryStatus;
721
+ }
722
+ function initRedundancy(cfg) {
723
+ const config = {
724
+ ...defaultConfig,
725
+ ...cfg
726
+ };
727
+ let queries = [];
728
+ function cleanup() {
729
+ queries = queries.filter((item) => item().status === "pending");
730
+ }
731
+ function query(payload, queryCallback, doneCallback) {
732
+ const query2 = sendQuery(
733
+ config,
734
+ payload,
735
+ queryCallback,
736
+ (data, error) => {
737
+ cleanup();
738
+ if (doneCallback) {
739
+ doneCallback(data, error);
740
+ }
741
+ }
742
+ );
743
+ queries.push(query2);
744
+ return query2;
745
+ }
746
+ function find(callback) {
747
+ return queries.find((value) => {
748
+ return callback(value);
749
+ }) || null;
750
+ }
751
+ const instance = {
752
+ query,
753
+ find,
754
+ setIndex: (index) => {
755
+ config.index = index;
756
+ },
757
+ getIndex: () => config.index,
758
+ cleanup
759
+ };
760
+ return instance;
761
+ }
762
+ function createAPIConfig(source) {
763
+ let resources;
764
+ if (typeof source.resources === "string") {
765
+ resources = [source.resources];
766
+ } else {
767
+ resources = source.resources;
768
+ if (!(resources instanceof Array) || !resources.length) {
769
+ return null;
770
+ }
771
+ }
772
+ const result = {
773
+ // API hosts
774
+ resources,
775
+ // Root path
776
+ path: source.path || "/",
777
+ // URL length limit
778
+ maxURL: source.maxURL || 500,
779
+ // Timeout before next host is used.
780
+ rotate: source.rotate || 750,
781
+ // Timeout before failing query.
782
+ timeout: source.timeout || 5e3,
783
+ // Randomise default API end point.
784
+ random: source.random === true,
785
+ // Start index
786
+ index: source.index || 0,
787
+ // Receive data after time out (used if time out kicks in first, then API module sends data anyway).
788
+ dataAfterTimeout: source.dataAfterTimeout !== false
789
+ };
790
+ return result;
791
+ }
792
+ const configStorage = /* @__PURE__ */ Object.create(null);
793
+ const fallBackAPISources = [
794
+ "https://api.simplesvg.com",
795
+ "https://api.unisvg.com"
796
+ ];
797
+ const fallBackAPI = [];
798
+ while (fallBackAPISources.length > 0) {
799
+ if (fallBackAPISources.length === 1) {
800
+ fallBackAPI.push(fallBackAPISources.shift());
801
+ } else {
802
+ if (Math.random() > 0.5) {
803
+ fallBackAPI.push(fallBackAPISources.shift());
804
+ } else {
805
+ fallBackAPI.push(fallBackAPISources.pop());
806
+ }
807
+ }
808
+ }
809
+ configStorage[""] = createAPIConfig({
810
+ resources: ["https://api.iconify.design"].concat(fallBackAPI)
811
+ });
812
+ function addAPIProvider$1(provider, customConfig) {
813
+ const config = createAPIConfig(customConfig);
814
+ if (config === null) {
815
+ return false;
816
+ }
817
+ configStorage[provider] = config;
818
+ return true;
819
+ }
820
+ function getAPIConfig(provider) {
821
+ return configStorage[provider];
822
+ }
823
+ function listAPIProviders() {
824
+ return Object.keys(configStorage);
825
+ }
826
+ function emptyCallback$1() {
827
+ }
828
+ const redundancyCache = /* @__PURE__ */ Object.create(null);
829
+ function getRedundancyCache(provider) {
830
+ if (!redundancyCache[provider]) {
831
+ const config = getAPIConfig(provider);
832
+ if (!config) {
833
+ return;
834
+ }
835
+ const redundancy = initRedundancy(config);
836
+ const cachedReundancy = {
837
+ config,
838
+ redundancy
839
+ };
840
+ redundancyCache[provider] = cachedReundancy;
841
+ }
842
+ return redundancyCache[provider];
843
+ }
844
+ function sendAPIQuery(target, query, callback) {
845
+ let redundancy;
846
+ let send2;
847
+ if (typeof target === "string") {
848
+ const api = getAPIModule(target);
849
+ if (!api) {
850
+ callback(void 0, 424);
851
+ return emptyCallback$1;
852
+ }
853
+ send2 = api.send;
854
+ const cached = getRedundancyCache(target);
855
+ if (cached) {
856
+ redundancy = cached.redundancy;
857
+ }
858
+ } else {
859
+ const config = createAPIConfig(target);
860
+ if (config) {
861
+ redundancy = initRedundancy(config);
862
+ const moduleKey = target.resources ? target.resources[0] : "";
863
+ const api = getAPIModule(moduleKey);
864
+ if (api) {
865
+ send2 = api.send;
866
+ }
867
+ }
868
+ }
869
+ if (!redundancy || !send2) {
870
+ callback(void 0, 424);
871
+ return emptyCallback$1;
872
+ }
873
+ return redundancy.query(query, send2, callback)().abort;
874
+ }
875
+ const browserCacheVersion = "iconify2";
876
+ const browserCachePrefix = "iconify";
877
+ const browserCacheCountKey = browserCachePrefix + "-count";
878
+ const browserCacheVersionKey = browserCachePrefix + "-version";
879
+ const browserStorageHour = 36e5;
880
+ const browserStorageCacheExpiration = 168;
881
+ const browserStorageLimit = 50;
882
+ function getStoredItem(func, key) {
883
+ try {
884
+ return func.getItem(key);
885
+ } catch (err) {
886
+ }
887
+ }
888
+ function setStoredItem(func, key, value) {
889
+ try {
890
+ func.setItem(key, value);
891
+ return true;
892
+ } catch (err) {
893
+ }
894
+ }
895
+ function removeStoredItem(func, key) {
896
+ try {
897
+ func.removeItem(key);
898
+ } catch (err) {
899
+ }
900
+ }
901
+ function setBrowserStorageItemsCount(storage2, value) {
902
+ return setStoredItem(storage2, browserCacheCountKey, value.toString());
903
+ }
904
+ function getBrowserStorageItemsCount(storage2) {
905
+ return parseInt(getStoredItem(storage2, browserCacheCountKey)) || 0;
906
+ }
907
+ const browserStorageConfig = {
908
+ local: true,
909
+ session: true
910
+ };
911
+ const browserStorageEmptyItems = {
912
+ local: /* @__PURE__ */ new Set(),
913
+ session: /* @__PURE__ */ new Set()
914
+ };
915
+ let browserStorageStatus = false;
916
+ function setBrowserStorageStatus(status) {
917
+ browserStorageStatus = status;
918
+ }
919
+ let _window = typeof window === "undefined" ? {} : window;
920
+ function getBrowserStorage(key) {
921
+ const attr = key + "Storage";
922
+ try {
923
+ if (_window && _window[attr] && typeof _window[attr].length === "number") {
924
+ return _window[attr];
925
+ }
926
+ } catch (err) {
927
+ }
928
+ browserStorageConfig[key] = false;
929
+ }
930
+ function iterateBrowserStorage(key, callback) {
931
+ const func = getBrowserStorage(key);
932
+ if (!func) {
933
+ return;
934
+ }
935
+ const version = getStoredItem(func, browserCacheVersionKey);
936
+ if (version !== browserCacheVersion) {
937
+ if (version) {
938
+ const total2 = getBrowserStorageItemsCount(func);
939
+ for (let i = 0; i < total2; i++) {
940
+ removeStoredItem(func, browserCachePrefix + i.toString());
941
+ }
942
+ }
943
+ setStoredItem(func, browserCacheVersionKey, browserCacheVersion);
944
+ setBrowserStorageItemsCount(func, 0);
945
+ return;
946
+ }
947
+ const minTime = Math.floor(Date.now() / browserStorageHour) - browserStorageCacheExpiration;
948
+ const parseItem = (index) => {
949
+ const name = browserCachePrefix + index.toString();
950
+ const item = getStoredItem(func, name);
951
+ if (typeof item !== "string") {
952
+ return;
953
+ }
954
+ try {
955
+ const data = JSON.parse(item);
956
+ if (typeof data === "object" && typeof data.cached === "number" && data.cached > minTime && typeof data.provider === "string" && typeof data.data === "object" && typeof data.data.prefix === "string" && // Valid item: run callback
957
+ callback(data, index)) {
958
+ return true;
959
+ }
960
+ } catch (err) {
961
+ }
962
+ removeStoredItem(func, name);
963
+ };
964
+ let total = getBrowserStorageItemsCount(func);
965
+ for (let i = total - 1; i >= 0; i--) {
966
+ if (!parseItem(i)) {
967
+ if (i === total - 1) {
968
+ total--;
969
+ setBrowserStorageItemsCount(func, total);
970
+ } else {
971
+ browserStorageEmptyItems[key].add(i);
972
+ }
973
+ }
974
+ }
975
+ }
976
+ function initBrowserStorage() {
977
+ if (browserStorageStatus) {
978
+ return;
979
+ }
980
+ setBrowserStorageStatus(true);
981
+ for (const key in browserStorageConfig) {
982
+ iterateBrowserStorage(key, (item) => {
983
+ const iconSet = item.data;
984
+ const provider = item.provider;
985
+ const prefix = iconSet.prefix;
986
+ const storage2 = getStorage(
987
+ provider,
988
+ prefix
989
+ );
990
+ if (!addIconSet(storage2, iconSet).length) {
991
+ return false;
992
+ }
993
+ const lastModified = iconSet.lastModified || -1;
994
+ storage2.lastModifiedCached = storage2.lastModifiedCached ? Math.min(storage2.lastModifiedCached, lastModified) : lastModified;
995
+ return true;
996
+ });
997
+ }
998
+ }
999
+ function updateLastModified(storage2, lastModified) {
1000
+ const lastValue = storage2.lastModifiedCached;
1001
+ if (
1002
+ // Matches or newer
1003
+ lastValue && lastValue >= lastModified
1004
+ ) {
1005
+ return lastValue === lastModified;
1006
+ }
1007
+ storage2.lastModifiedCached = lastModified;
1008
+ if (lastValue) {
1009
+ for (const key in browserStorageConfig) {
1010
+ iterateBrowserStorage(key, (item) => {
1011
+ const iconSet = item.data;
1012
+ return item.provider !== storage2.provider || iconSet.prefix !== storage2.prefix || iconSet.lastModified === lastModified;
1013
+ });
1014
+ }
1015
+ }
1016
+ return true;
1017
+ }
1018
+ function storeInBrowserStorage(storage2, data) {
1019
+ if (!browserStorageStatus) {
1020
+ initBrowserStorage();
1021
+ }
1022
+ function store(key) {
1023
+ let func;
1024
+ if (!browserStorageConfig[key] || !(func = getBrowserStorage(key))) {
1025
+ return;
1026
+ }
1027
+ const set = browserStorageEmptyItems[key];
1028
+ let index;
1029
+ if (set.size) {
1030
+ set.delete(index = Array.from(set).shift());
1031
+ } else {
1032
+ index = getBrowserStorageItemsCount(func);
1033
+ if (index >= browserStorageLimit || !setBrowserStorageItemsCount(func, index + 1)) {
1034
+ return;
1035
+ }
1036
+ }
1037
+ const item = {
1038
+ cached: Math.floor(Date.now() / browserStorageHour),
1039
+ provider: storage2.provider,
1040
+ data
1041
+ };
1042
+ return setStoredItem(
1043
+ func,
1044
+ browserCachePrefix + index.toString(),
1045
+ JSON.stringify(item)
1046
+ );
1047
+ }
1048
+ if (data.lastModified && !updateLastModified(storage2, data.lastModified)) {
1049
+ return;
1050
+ }
1051
+ if (!Object.keys(data.icons).length) {
1052
+ return;
1053
+ }
1054
+ if (data.not_found) {
1055
+ data = Object.assign({}, data);
1056
+ delete data.not_found;
1057
+ }
1058
+ if (!store("local")) {
1059
+ store("session");
1060
+ }
1061
+ }
1062
+ function emptyCallback() {
1063
+ }
1064
+ function loadedNewIcons(storage2) {
1065
+ if (!storage2.iconsLoaderFlag) {
1066
+ storage2.iconsLoaderFlag = true;
1067
+ setTimeout(() => {
1068
+ storage2.iconsLoaderFlag = false;
1069
+ updateCallbacks(storage2);
1070
+ });
1071
+ }
1072
+ }
1073
+ function loadNewIcons(storage2, icons) {
1074
+ if (!storage2.iconsToLoad) {
1075
+ storage2.iconsToLoad = icons;
1076
+ } else {
1077
+ storage2.iconsToLoad = storage2.iconsToLoad.concat(icons).sort();
1078
+ }
1079
+ if (!storage2.iconsQueueFlag) {
1080
+ storage2.iconsQueueFlag = true;
1081
+ setTimeout(() => {
1082
+ storage2.iconsQueueFlag = false;
1083
+ const { provider, prefix } = storage2;
1084
+ const icons2 = storage2.iconsToLoad;
1085
+ delete storage2.iconsToLoad;
1086
+ let api;
1087
+ if (!icons2 || !(api = getAPIModule(provider))) {
1088
+ return;
1089
+ }
1090
+ const params = api.prepare(provider, prefix, icons2);
1091
+ params.forEach((item) => {
1092
+ sendAPIQuery(provider, item, (data) => {
1093
+ if (typeof data !== "object") {
1094
+ item.icons.forEach((name) => {
1095
+ storage2.missing.add(name);
1096
+ });
1097
+ } else {
1098
+ try {
1099
+ const parsed = addIconSet(
1100
+ storage2,
1101
+ data
1102
+ );
1103
+ if (!parsed.length) {
1104
+ return;
1105
+ }
1106
+ const pending = storage2.pendingIcons;
1107
+ if (pending) {
1108
+ parsed.forEach((name) => {
1109
+ pending.delete(name);
1110
+ });
1111
+ }
1112
+ storeInBrowserStorage(storage2, data);
1113
+ } catch (err) {
1114
+ console.error(err);
1115
+ }
1116
+ }
1117
+ loadedNewIcons(storage2);
1118
+ });
1119
+ });
1120
+ });
1121
+ }
1122
+ }
1123
+ const loadIcons$1 = (icons, callback) => {
1124
+ const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
1125
+ const sortedIcons = sortIcons(cleanedIcons);
1126
+ if (!sortedIcons.pending.length) {
1127
+ let callCallback = true;
1128
+ if (callback) {
1129
+ setTimeout(() => {
1130
+ if (callCallback) {
1131
+ callback(
1132
+ sortedIcons.loaded,
1133
+ sortedIcons.missing,
1134
+ sortedIcons.pending,
1135
+ emptyCallback
1136
+ );
1137
+ }
1138
+ });
1139
+ }
1140
+ return () => {
1141
+ callCallback = false;
1142
+ };
1143
+ }
1144
+ const newIcons = /* @__PURE__ */ Object.create(null);
1145
+ const sources = [];
1146
+ let lastProvider, lastPrefix;
1147
+ sortedIcons.pending.forEach((icon) => {
1148
+ const { provider, prefix } = icon;
1149
+ if (prefix === lastPrefix && provider === lastProvider) {
1150
+ return;
1151
+ }
1152
+ lastProvider = provider;
1153
+ lastPrefix = prefix;
1154
+ sources.push(getStorage(provider, prefix));
1155
+ const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */ Object.create(null));
1156
+ if (!providerNewIcons[prefix]) {
1157
+ providerNewIcons[prefix] = [];
1158
+ }
1159
+ });
1160
+ sortedIcons.pending.forEach((icon) => {
1161
+ const { provider, prefix, name } = icon;
1162
+ const storage2 = getStorage(provider, prefix);
1163
+ const pendingQueue = storage2.pendingIcons || (storage2.pendingIcons = /* @__PURE__ */ new Set());
1164
+ if (!pendingQueue.has(name)) {
1165
+ pendingQueue.add(name);
1166
+ newIcons[provider][prefix].push(name);
1167
+ }
1168
+ });
1169
+ sources.forEach((storage2) => {
1170
+ const { provider, prefix } = storage2;
1171
+ if (newIcons[provider][prefix].length) {
1172
+ loadNewIcons(storage2, newIcons[provider][prefix]);
1173
+ }
1174
+ });
1175
+ return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
1176
+ };
1177
+ const loadIcon$1 = (icon) => {
1178
+ return new Promise((fulfill, reject) => {
1179
+ const iconObj = typeof icon === "string" ? stringToIcon(icon, true) : icon;
1180
+ if (!iconObj) {
1181
+ reject(icon);
1182
+ return;
1183
+ }
1184
+ loadIcons$1([iconObj || icon], (loaded) => {
1185
+ if (loaded.length && iconObj) {
1186
+ const data = getIconData(iconObj);
1187
+ if (data) {
1188
+ fulfill({
1189
+ ...defaultIconProps,
1190
+ ...data
1191
+ });
1192
+ return;
1193
+ }
1194
+ }
1195
+ reject(icon);
1196
+ });
1197
+ });
1198
+ };
1199
+ function testIconObject(value) {
1200
+ try {
1201
+ const obj = typeof value === "string" ? JSON.parse(value) : value;
1202
+ if (typeof obj.body === "string") {
1203
+ return {
1204
+ ...obj
1205
+ };
1206
+ }
1207
+ } catch (err) {
1208
+ }
1209
+ }
1210
+ function parseIconValue(value, onload) {
1211
+ const name = typeof value === "string" ? stringToIcon(value, true, true) : null;
1212
+ if (!name) {
1213
+ const data2 = testIconObject(value);
1214
+ return {
1215
+ value,
1216
+ data: data2
1217
+ };
1218
+ }
1219
+ const data = getIconData(name);
1220
+ if (data !== void 0 || !name.prefix) {
1221
+ return {
1222
+ value,
1223
+ name,
1224
+ data
1225
+ // could be 'null' -> icon is missing
1226
+ };
1227
+ }
1228
+ const loading = loadIcons$1([name], () => onload(value, name, getIconData(name)));
1229
+ return {
1230
+ value,
1231
+ name,
1232
+ loading
1233
+ };
1234
+ }
1235
+ let isBuggedSafari = false;
1236
+ try {
1237
+ isBuggedSafari = navigator.vendor.indexOf("Apple") === 0;
1238
+ } catch (err) {
1239
+ }
1240
+ function getRenderMode(body, mode) {
1241
+ switch (mode) {
1242
+ case "svg":
1243
+ case "bg":
1244
+ case "mask":
1245
+ return mode;
1246
+ }
1247
+ if (mode !== "style" && (isBuggedSafari || body.indexOf("<a") === -1)) {
1248
+ return "svg";
1249
+ }
1250
+ return body.indexOf("currentColor") === -1 ? "bg" : "mask";
1251
+ }
1252
+ const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
1253
+ const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
1254
+ function calculateSize$1(size, ratio, precision) {
1255
+ if (ratio === 1) {
1256
+ return size;
1257
+ }
1258
+ precision = precision || 100;
1259
+ if (typeof size === "number") {
1260
+ return Math.ceil(size * ratio * precision) / precision;
1261
+ }
1262
+ if (typeof size !== "string") {
1263
+ return size;
1264
+ }
1265
+ const oldParts = size.split(unitsSplit);
1266
+ if (oldParts === null || !oldParts.length) {
1267
+ return size;
1268
+ }
1269
+ const newParts = [];
1270
+ let code = oldParts.shift();
1271
+ let isNumber = unitsTest.test(code);
1272
+ while (true) {
1273
+ if (isNumber) {
1274
+ const num = parseFloat(code);
1275
+ if (isNaN(num)) {
1276
+ newParts.push(code);
1277
+ } else {
1278
+ newParts.push(Math.ceil(num * ratio * precision) / precision);
1279
+ }
1280
+ } else {
1281
+ newParts.push(code);
1282
+ }
1283
+ code = oldParts.shift();
1284
+ if (code === void 0) {
1285
+ return newParts.join("");
1286
+ }
1287
+ isNumber = !isNumber;
1288
+ }
1289
+ }
1290
+ function splitSVGDefs(content, tag = "defs") {
1291
+ let defs = "";
1292
+ const index = content.indexOf("<" + tag);
1293
+ while (index >= 0) {
1294
+ const start = content.indexOf(">", index);
1295
+ const end = content.indexOf("</" + tag);
1296
+ if (start === -1 || end === -1) {
1297
+ break;
1298
+ }
1299
+ const endEnd = content.indexOf(">", end);
1300
+ if (endEnd === -1) {
1301
+ break;
1302
+ }
1303
+ defs += content.slice(start + 1, end).trim();
1304
+ content = content.slice(0, index).trim() + content.slice(endEnd + 1);
1305
+ }
1306
+ return {
1307
+ defs,
1308
+ content
1309
+ };
1310
+ }
1311
+ function mergeDefsAndContent(defs, content) {
1312
+ return defs ? "<defs>" + defs + "</defs>" + content : content;
1313
+ }
1314
+ function wrapSVGContent(body, start, end) {
1315
+ const split = splitSVGDefs(body);
1316
+ return mergeDefsAndContent(split.defs, start + split.content + end);
1317
+ }
1318
+ const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
1319
+ function iconToSVG(icon, customisations) {
1320
+ const fullIcon = {
1321
+ ...defaultIconProps,
1322
+ ...icon
1323
+ };
1324
+ const fullCustomisations = {
1325
+ ...defaultIconCustomisations,
1326
+ ...customisations
1327
+ };
1328
+ const box = {
1329
+ left: fullIcon.left,
1330
+ top: fullIcon.top,
1331
+ width: fullIcon.width,
1332
+ height: fullIcon.height
1333
+ };
1334
+ let body = fullIcon.body;
1335
+ [fullIcon, fullCustomisations].forEach((props) => {
1336
+ const transformations = [];
1337
+ const hFlip = props.hFlip;
1338
+ const vFlip = props.vFlip;
1339
+ let rotation = props.rotate;
1340
+ if (hFlip) {
1341
+ if (vFlip) {
1342
+ rotation += 2;
1343
+ } else {
1344
+ transformations.push(
1345
+ "translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"
1346
+ );
1347
+ transformations.push("scale(-1 1)");
1348
+ box.top = box.left = 0;
1349
+ }
1350
+ } else if (vFlip) {
1351
+ transformations.push(
1352
+ "translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"
1353
+ );
1354
+ transformations.push("scale(1 -1)");
1355
+ box.top = box.left = 0;
1356
+ }
1357
+ let tempValue;
1358
+ if (rotation < 0) {
1359
+ rotation -= Math.floor(rotation / 4) * 4;
1360
+ }
1361
+ rotation = rotation % 4;
1362
+ switch (rotation) {
1363
+ case 1:
1364
+ tempValue = box.height / 2 + box.top;
1365
+ transformations.unshift(
1366
+ "rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"
1367
+ );
1368
+ break;
1369
+ case 2:
1370
+ transformations.unshift(
1371
+ "rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"
1372
+ );
1373
+ break;
1374
+ case 3:
1375
+ tempValue = box.width / 2 + box.left;
1376
+ transformations.unshift(
1377
+ "rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"
1378
+ );
1379
+ break;
1380
+ }
1381
+ if (rotation % 2 === 1) {
1382
+ if (box.left !== box.top) {
1383
+ tempValue = box.left;
1384
+ box.left = box.top;
1385
+ box.top = tempValue;
1386
+ }
1387
+ if (box.width !== box.height) {
1388
+ tempValue = box.width;
1389
+ box.width = box.height;
1390
+ box.height = tempValue;
1391
+ }
1392
+ }
1393
+ if (transformations.length) {
1394
+ body = wrapSVGContent(
1395
+ body,
1396
+ '<g transform="' + transformations.join(" ") + '">',
1397
+ "</g>"
1398
+ );
1399
+ }
1400
+ });
1401
+ const customisationsWidth = fullCustomisations.width;
1402
+ const customisationsHeight = fullCustomisations.height;
1403
+ const boxWidth = box.width;
1404
+ const boxHeight = box.height;
1405
+ let width;
1406
+ let height;
1407
+ if (customisationsWidth === null) {
1408
+ height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
1409
+ width = calculateSize$1(height, boxWidth / boxHeight);
1410
+ } else {
1411
+ width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
1412
+ height = customisationsHeight === null ? calculateSize$1(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
1413
+ }
1414
+ const attributes = {};
1415
+ const setAttr = (prop, value) => {
1416
+ if (!isUnsetKeyword(value)) {
1417
+ attributes[prop] = value.toString();
1418
+ }
1419
+ };
1420
+ setAttr("width", width);
1421
+ setAttr("height", height);
1422
+ const viewBox = [box.left, box.top, boxWidth, boxHeight];
1423
+ attributes.viewBox = viewBox.join(" ");
1424
+ return {
1425
+ attributes,
1426
+ viewBox,
1427
+ body
1428
+ };
1429
+ }
1430
+ function iconToHTML$1(body, attributes) {
1431
+ let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
1432
+ for (const attr in attributes) {
1433
+ renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
1434
+ }
1435
+ return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
1436
+ }
1437
+ function encodeSVGforURL(svg) {
1438
+ return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
1439
+ }
1440
+ function svgToData(svg) {
1441
+ return "data:image/svg+xml," + encodeSVGforURL(svg);
1442
+ }
1443
+ function svgToURL$1(svg) {
1444
+ return 'url("' + svgToData(svg) + '")';
1445
+ }
1446
+ const detectFetch = () => {
1447
+ let callback;
1448
+ try {
1449
+ callback = fetch;
1450
+ if (typeof callback === "function") {
1451
+ return callback;
1452
+ }
1453
+ } catch (err) {
1454
+ }
1455
+ };
1456
+ let fetchModule = detectFetch();
1457
+ function setFetch(fetch2) {
1458
+ fetchModule = fetch2;
1459
+ }
1460
+ function getFetch() {
1461
+ return fetchModule;
1462
+ }
1463
+ function calculateMaxLength(provider, prefix) {
1464
+ const config = getAPIConfig(provider);
1465
+ if (!config) {
1466
+ return 0;
1467
+ }
1468
+ let result;
1469
+ if (!config.maxURL) {
1470
+ result = 0;
1471
+ } else {
1472
+ let maxHostLength = 0;
1473
+ config.resources.forEach((item) => {
1474
+ const host = item;
1475
+ maxHostLength = Math.max(maxHostLength, host.length);
1476
+ });
1477
+ const url = prefix + ".json?icons=";
1478
+ result = config.maxURL - maxHostLength - config.path.length - url.length;
1479
+ }
1480
+ return result;
1481
+ }
1482
+ function shouldAbort(status) {
1483
+ return status === 404;
1484
+ }
1485
+ const prepare = (provider, prefix, icons) => {
1486
+ const results = [];
1487
+ const maxLength = calculateMaxLength(provider, prefix);
1488
+ const type = "icons";
1489
+ let item = {
1490
+ type,
1491
+ provider,
1492
+ prefix,
1493
+ icons: []
1494
+ };
1495
+ let length = 0;
1496
+ icons.forEach((name, index) => {
1497
+ length += name.length + 1;
1498
+ if (length >= maxLength && index > 0) {
1499
+ results.push(item);
1500
+ item = {
1501
+ type,
1502
+ provider,
1503
+ prefix,
1504
+ icons: []
1505
+ };
1506
+ length = name.length;
1507
+ }
1508
+ item.icons.push(name);
1509
+ });
1510
+ results.push(item);
1511
+ return results;
1512
+ };
1513
+ function getPath(provider) {
1514
+ if (typeof provider === "string") {
1515
+ const config = getAPIConfig(provider);
1516
+ if (config) {
1517
+ return config.path;
1518
+ }
1519
+ }
1520
+ return "/";
1521
+ }
1522
+ const send = (host, params, callback) => {
1523
+ if (!fetchModule) {
1524
+ callback("abort", 424);
1525
+ return;
1526
+ }
1527
+ let path = getPath(params.provider);
1528
+ switch (params.type) {
1529
+ case "icons": {
1530
+ const prefix = params.prefix;
1531
+ const icons = params.icons;
1532
+ const iconsList = icons.join(",");
1533
+ const urlParams = new URLSearchParams({
1534
+ icons: iconsList
1535
+ });
1536
+ path += prefix + ".json?" + urlParams.toString();
1537
+ break;
1538
+ }
1539
+ case "custom": {
1540
+ const uri = params.uri;
1541
+ path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
1542
+ break;
1543
+ }
1544
+ default:
1545
+ callback("abort", 400);
1546
+ return;
1547
+ }
1548
+ let defaultError = 503;
1549
+ fetchModule(host + path).then((response) => {
1550
+ const status = response.status;
1551
+ if (status !== 200) {
1552
+ setTimeout(() => {
1553
+ callback(shouldAbort(status) ? "abort" : "next", status);
1554
+ });
1555
+ return;
1556
+ }
1557
+ defaultError = 501;
1558
+ return response.json();
1559
+ }).then((data) => {
1560
+ if (typeof data !== "object" || data === null) {
1561
+ setTimeout(() => {
1562
+ if (data === 404) {
1563
+ callback("abort", data);
1564
+ } else {
1565
+ callback("next", defaultError);
1566
+ }
1567
+ });
1568
+ return;
1569
+ }
1570
+ setTimeout(() => {
1571
+ callback("success", data);
1572
+ });
1573
+ }).catch(() => {
1574
+ callback("next", defaultError);
1575
+ });
1576
+ };
1577
+ const fetchAPIModule = {
1578
+ prepare,
1579
+ send
1580
+ };
1581
+ function toggleBrowserCache(storage2, value) {
1582
+ switch (storage2) {
1583
+ case "local":
1584
+ case "session":
1585
+ browserStorageConfig[storage2] = value;
1586
+ break;
1587
+ case "all":
1588
+ for (const key in browserStorageConfig) {
1589
+ browserStorageConfig[key] = value;
1590
+ }
1591
+ break;
1592
+ }
1593
+ }
1594
+ const nodeAttr = "data-style";
1595
+ let customStyle = "";
1596
+ function appendCustomStyle(style) {
1597
+ customStyle = style;
1598
+ }
1599
+ function updateStyle(parent, inline) {
1600
+ let styleNode = Array.from(parent.childNodes).find((node) => node.hasAttribute && node.hasAttribute(nodeAttr));
1601
+ if (!styleNode) {
1602
+ styleNode = document.createElement("style");
1603
+ styleNode.setAttribute(nodeAttr, nodeAttr);
1604
+ parent.appendChild(styleNode);
1605
+ }
1606
+ styleNode.textContent = ":host{display:inline-block;vertical-align:" + (inline ? "-0.125em" : "0") + "}span,svg{display:block}" + customStyle;
1607
+ }
1608
+ function exportFunctions() {
1609
+ setAPIModule("", fetchAPIModule);
1610
+ allowSimpleNames(true);
1611
+ let _window2;
1612
+ try {
1613
+ _window2 = window;
1614
+ } catch (err) {
1615
+ }
1616
+ if (_window2) {
1617
+ initBrowserStorage();
1618
+ if (_window2.IconifyPreload !== void 0) {
1619
+ const preload = _window2.IconifyPreload;
1620
+ const err = "Invalid IconifyPreload syntax.";
1621
+ if (typeof preload === "object" && preload !== null) {
1622
+ (preload instanceof Array ? preload : [preload]).forEach((item) => {
1623
+ try {
1624
+ if (
1625
+ // Check if item is an object and not null/array
1626
+ typeof item !== "object" || item === null || item instanceof Array || // Check for 'icons' and 'prefix'
1627
+ typeof item.icons !== "object" || typeof item.prefix !== "string" || // Add icon set
1628
+ !addCollection$1(item)
1629
+ ) {
1630
+ console.error(err);
1631
+ }
1632
+ } catch (e) {
1633
+ console.error(err);
1634
+ }
1635
+ });
1636
+ }
1637
+ }
1638
+ if (_window2.IconifyProviders !== void 0) {
1639
+ const providers = _window2.IconifyProviders;
1640
+ if (typeof providers === "object" && providers !== null) {
1641
+ for (const key in providers) {
1642
+ const err = "IconifyProviders[" + key + "] is invalid.";
1643
+ try {
1644
+ const value = providers[key];
1645
+ if (typeof value !== "object" || !value || value.resources === void 0) {
1646
+ continue;
1647
+ }
1648
+ if (!addAPIProvider$1(key, value)) {
1649
+ console.error(err);
1650
+ }
1651
+ } catch (e) {
1652
+ console.error(err);
1653
+ }
1654
+ }
1655
+ }
1656
+ }
1657
+ }
1658
+ const _api = {
1659
+ getAPIConfig,
1660
+ setAPIModule,
1661
+ sendAPIQuery,
1662
+ setFetch,
1663
+ getFetch,
1664
+ listAPIProviders
1665
+ };
1666
+ return {
1667
+ enableCache: (storage2) => toggleBrowserCache(storage2, true),
1668
+ disableCache: (storage2) => toggleBrowserCache(storage2, false),
1669
+ iconLoaded: iconLoaded$1,
1670
+ iconExists: iconLoaded$1,
1671
+ // deprecated, kept to avoid breaking changes
1672
+ getIcon: getIcon$1,
1673
+ listIcons: listIcons$1,
1674
+ addIcon: addIcon$1,
1675
+ addCollection: addCollection$1,
1676
+ calculateSize: calculateSize$1,
1677
+ buildIcon: iconToSVG,
1678
+ iconToHTML: iconToHTML$1,
1679
+ svgToURL: svgToURL$1,
1680
+ loadIcons: loadIcons$1,
1681
+ loadIcon: loadIcon$1,
1682
+ addAPIProvider: addAPIProvider$1,
1683
+ appendCustomStyle,
1684
+ _api
1685
+ };
1686
+ }
1687
+ const monotoneProps = {
1688
+ "background-color": "currentColor"
1689
+ };
1690
+ const coloredProps = {
1691
+ "background-color": "transparent"
1692
+ };
1693
+ const propsToAdd = {
1694
+ image: "var(--svg)",
1695
+ repeat: "no-repeat",
1696
+ size: "100% 100%"
1697
+ };
1698
+ const propsToAddTo = {
1699
+ "-webkit-mask": monotoneProps,
1700
+ "mask": monotoneProps,
1701
+ "background": coloredProps
1702
+ };
1703
+ for (const prefix in propsToAddTo) {
1704
+ const list = propsToAddTo[prefix];
1705
+ for (const prop in propsToAdd) {
1706
+ list[prefix + "-" + prop] = propsToAdd[prop];
1707
+ }
1708
+ }
1709
+ function fixSize(value) {
1710
+ return value ? value + (value.match(/^[-0-9.]+$/) ? "px" : "") : "inherit";
1711
+ }
1712
+ function renderSPAN(data, icon, useMask) {
1713
+ const node = document.createElement("span");
1714
+ let body = data.body;
1715
+ if (body.indexOf("<a") !== -1) {
1716
+ body += "<!-- " + Date.now() + " -->";
1717
+ }
1718
+ const renderAttribs = data.attributes;
1719
+ const html = iconToHTML$1(body, {
1720
+ ...renderAttribs,
1721
+ width: icon.width + "",
1722
+ height: icon.height + ""
1723
+ });
1724
+ const url = svgToURL$1(html);
1725
+ const svgStyle = node.style;
1726
+ const styles = {
1727
+ "--svg": url,
1728
+ "width": fixSize(renderAttribs.width),
1729
+ "height": fixSize(renderAttribs.height),
1730
+ ...useMask ? monotoneProps : coloredProps
1731
+ };
1732
+ for (const prop in styles) {
1733
+ svgStyle.setProperty(prop, styles[prop]);
1734
+ }
1735
+ return node;
1736
+ }
1737
+ let policy;
1738
+ function createPolicy() {
1739
+ try {
1740
+ policy = window.trustedTypes.createPolicy("iconify", {
1741
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
1742
+ createHTML: (s) => s
1743
+ });
1744
+ } catch (err) {
1745
+ policy = null;
1746
+ }
1747
+ }
1748
+ function cleanUpInnerHTML(html) {
1749
+ if (policy === void 0) {
1750
+ createPolicy();
1751
+ }
1752
+ return policy ? policy.createHTML(html) : html;
1753
+ }
1754
+ function renderSVG(data) {
1755
+ const node = document.createElement("span");
1756
+ const attr = data.attributes;
1757
+ let style = "";
1758
+ if (!attr.width) {
1759
+ style = "width: inherit;";
1760
+ }
1761
+ if (!attr.height) {
1762
+ style += "height: inherit;";
1763
+ }
1764
+ if (style) {
1765
+ attr.style = style;
1766
+ }
1767
+ const html = iconToHTML$1(data.body, attr);
1768
+ node.innerHTML = cleanUpInnerHTML(html);
1769
+ return node.firstChild;
1770
+ }
1771
+ function findIconElement(parent) {
1772
+ return Array.from(parent.childNodes).find((node) => {
1773
+ const tag = node.tagName && node.tagName.toUpperCase();
1774
+ return tag === "SPAN" || tag === "SVG";
1775
+ });
1776
+ }
1777
+ function renderIcon(parent, state) {
1778
+ const iconData = state.icon.data;
1779
+ const customisations = state.customisations;
1780
+ const renderData = iconToSVG(iconData, customisations);
1781
+ if (customisations.preserveAspectRatio) {
1782
+ renderData.attributes["preserveAspectRatio"] = customisations.preserveAspectRatio;
1783
+ }
1784
+ const mode = state.renderedMode;
1785
+ let node;
1786
+ switch (mode) {
1787
+ case "svg":
1788
+ node = renderSVG(renderData);
1789
+ break;
1790
+ default:
1791
+ node = renderSPAN(renderData, {
1792
+ ...defaultIconProps,
1793
+ ...iconData
1794
+ }, mode === "mask");
1795
+ }
1796
+ const oldNode = findIconElement(parent);
1797
+ if (oldNode) {
1798
+ if (node.tagName === "SPAN" && oldNode.tagName === node.tagName) {
1799
+ oldNode.setAttribute("style", node.getAttribute("style"));
1800
+ } else {
1801
+ parent.replaceChild(node, oldNode);
1802
+ }
1803
+ } else {
1804
+ parent.appendChild(node);
1805
+ }
1806
+ }
1807
+ function setPendingState(icon, inline, lastState) {
1808
+ const lastRender = lastState && (lastState.rendered ? lastState : lastState.lastRender);
1809
+ return {
1810
+ rendered: false,
1811
+ inline,
1812
+ icon,
1813
+ lastRender
1814
+ };
1815
+ }
1816
+ function defineIconifyIcon(name = "iconify-icon") {
1817
+ let customElements;
1818
+ let ParentClass;
1819
+ try {
1820
+ customElements = window.customElements;
1821
+ ParentClass = window.HTMLElement;
1822
+ } catch (err) {
1823
+ return;
1824
+ }
1825
+ if (!customElements || !ParentClass) {
1826
+ return;
1827
+ }
1828
+ const ConflictingClass = customElements.get(name);
1829
+ if (ConflictingClass) {
1830
+ return ConflictingClass;
1831
+ }
1832
+ const attributes = [
1833
+ // Icon
1834
+ "icon",
1835
+ // Mode
1836
+ "mode",
1837
+ "inline",
1838
+ "noobserver",
1839
+ // Customisations
1840
+ "width",
1841
+ "height",
1842
+ "rotate",
1843
+ "flip"
1844
+ ];
1845
+ const IconifyIcon = class extends ParentClass {
1846
+ /**
1847
+ * Constructor
1848
+ */
1849
+ constructor() {
1850
+ super();
1851
+ // Root
1852
+ __publicField(this, "_shadowRoot");
1853
+ // Initialised
1854
+ __publicField(this, "_initialised", false);
1855
+ // Icon state
1856
+ __publicField(this, "_state");
1857
+ // Attributes check queued
1858
+ __publicField(this, "_checkQueued", false);
1859
+ // Connected
1860
+ __publicField(this, "_connected", false);
1861
+ // Observer
1862
+ __publicField(this, "_observer", null);
1863
+ __publicField(this, "_visible", true);
1864
+ const root = this._shadowRoot = this.attachShadow({
1865
+ mode: "open"
1866
+ });
1867
+ const inline = this.hasAttribute("inline");
1868
+ updateStyle(root, inline);
1869
+ this._state = setPendingState({
1870
+ value: ""
1871
+ }, inline);
1872
+ this._queueCheck();
1873
+ }
1874
+ /**
1875
+ * Connected to DOM
1876
+ */
1877
+ connectedCallback() {
1878
+ this._connected = true;
1879
+ this.startObserver();
1880
+ }
1881
+ /**
1882
+ * Disconnected from DOM
1883
+ */
1884
+ disconnectedCallback() {
1885
+ this._connected = false;
1886
+ this.stopObserver();
1887
+ }
1888
+ /**
1889
+ * Observed attributes
1890
+ */
1891
+ static get observedAttributes() {
1892
+ return attributes.slice(0);
1893
+ }
1894
+ /**
1895
+ * Observed properties that are different from attributes
1896
+ *
1897
+ * Experimental! Need to test with various frameworks that support it
1898
+ */
1899
+ /*
1900
+ static get properties() {
1901
+ return {
1902
+ inline: {
1903
+ type: Boolean,
1904
+ reflect: true,
1905
+ },
1906
+ // Not listing other attributes because they are strings or combination
1907
+ // of string and another type. Cannot have multiple types
1908
+ };
1909
+ }
1910
+ */
1911
+ /**
1912
+ * Attribute has changed
1913
+ */
1914
+ attributeChangedCallback(name2) {
1915
+ switch (name2) {
1916
+ case "inline": {
1917
+ const newInline = this.hasAttribute("inline");
1918
+ const state = this._state;
1919
+ if (newInline !== state.inline) {
1920
+ state.inline = newInline;
1921
+ updateStyle(this._shadowRoot, newInline);
1922
+ }
1923
+ break;
1924
+ }
1925
+ case "noobserver": {
1926
+ const value = this.hasAttribute("noobserver");
1927
+ if (value) {
1928
+ this.startObserver();
1929
+ } else {
1930
+ this.stopObserver();
1931
+ }
1932
+ break;
1933
+ }
1934
+ default:
1935
+ this._queueCheck();
1936
+ }
1937
+ }
1938
+ /**
1939
+ * Get/set icon
1940
+ */
1941
+ get icon() {
1942
+ const value = this.getAttribute("icon");
1943
+ if (value && value.slice(0, 1) === "{") {
1944
+ try {
1945
+ return JSON.parse(value);
1946
+ } catch (err) {
1947
+ }
1948
+ }
1949
+ return value;
1950
+ }
1951
+ set icon(value) {
1952
+ if (typeof value === "object") {
1953
+ value = JSON.stringify(value);
1954
+ }
1955
+ this.setAttribute("icon", value);
1956
+ }
1957
+ /**
1958
+ * Get/set inline
1959
+ */
1960
+ get inline() {
1961
+ return this.hasAttribute("inline");
1962
+ }
1963
+ set inline(value) {
1964
+ if (value) {
1965
+ this.setAttribute("inline", "true");
1966
+ } else {
1967
+ this.removeAttribute("inline");
1968
+ }
1969
+ }
1970
+ /**
1971
+ * Get/set observer
1972
+ */
1973
+ get observer() {
1974
+ return this.hasAttribute("observer");
1975
+ }
1976
+ set observer(value) {
1977
+ if (value) {
1978
+ this.setAttribute("observer", "true");
1979
+ } else {
1980
+ this.removeAttribute("observer");
1981
+ }
1982
+ }
1983
+ /**
1984
+ * Restart animation
1985
+ */
1986
+ restartAnimation() {
1987
+ const state = this._state;
1988
+ if (state.rendered) {
1989
+ const root = this._shadowRoot;
1990
+ if (state.renderedMode === "svg") {
1991
+ try {
1992
+ root.lastChild.setCurrentTime(0);
1993
+ return;
1994
+ } catch (err) {
1995
+ }
1996
+ }
1997
+ renderIcon(root, state);
1998
+ }
1999
+ }
2000
+ /**
2001
+ * Get status
2002
+ */
2003
+ get status() {
2004
+ const state = this._state;
2005
+ return state.rendered ? "rendered" : state.icon.data === null ? "failed" : "loading";
2006
+ }
2007
+ /**
2008
+ * Queue attributes re-check
2009
+ */
2010
+ _queueCheck() {
2011
+ if (!this._checkQueued) {
2012
+ this._checkQueued = true;
2013
+ setTimeout(() => {
2014
+ this._check();
2015
+ });
2016
+ }
2017
+ }
2018
+ /**
2019
+ * Check for changes
2020
+ */
2021
+ _check() {
2022
+ if (!this._checkQueued) {
2023
+ return;
2024
+ }
2025
+ this._checkQueued = false;
2026
+ const state = this._state;
2027
+ const newIcon = this.getAttribute("icon");
2028
+ if (newIcon !== state.icon.value) {
2029
+ this._iconChanged(newIcon);
2030
+ return;
2031
+ }
2032
+ if (!state.rendered || !this._visible) {
2033
+ return;
2034
+ }
2035
+ const mode = this.getAttribute("mode");
2036
+ const customisations = getCustomisations(this);
2037
+ if (state.attrMode !== mode || haveCustomisationsChanged(state.customisations, customisations) || !findIconElement(this._shadowRoot)) {
2038
+ this._renderIcon(state.icon, customisations, mode);
2039
+ }
2040
+ }
2041
+ /**
2042
+ * Icon value has changed
2043
+ */
2044
+ _iconChanged(newValue) {
2045
+ const icon = parseIconValue(newValue, (value, name2, data) => {
2046
+ const state = this._state;
2047
+ if (state.rendered || this.getAttribute("icon") !== value) {
2048
+ return;
2049
+ }
2050
+ const icon2 = {
2051
+ value,
2052
+ name: name2,
2053
+ data
2054
+ };
2055
+ if (icon2.data) {
2056
+ this._gotIconData(icon2);
2057
+ } else {
2058
+ state.icon = icon2;
2059
+ }
2060
+ });
2061
+ if (icon.data) {
2062
+ this._gotIconData(icon);
2063
+ } else {
2064
+ this._state = setPendingState(icon, this._state.inline, this._state);
2065
+ }
2066
+ }
2067
+ /**
2068
+ * Force render icon on state change
2069
+ */
2070
+ _forceRender() {
2071
+ if (!this._visible) {
2072
+ const node = findIconElement(this._shadowRoot);
2073
+ if (node) {
2074
+ this._shadowRoot.removeChild(node);
2075
+ }
2076
+ return;
2077
+ }
2078
+ this._queueCheck();
2079
+ }
2080
+ /**
2081
+ * Got new icon data, icon is ready to (re)render
2082
+ */
2083
+ _gotIconData(icon) {
2084
+ this._checkQueued = false;
2085
+ this._renderIcon(icon, getCustomisations(this), this.getAttribute("mode"));
2086
+ }
2087
+ /**
2088
+ * Re-render based on icon data
2089
+ */
2090
+ _renderIcon(icon, customisations, attrMode) {
2091
+ const renderedMode = getRenderMode(icon.data.body, attrMode);
2092
+ const inline = this._state.inline;
2093
+ renderIcon(this._shadowRoot, this._state = {
2094
+ rendered: true,
2095
+ icon,
2096
+ inline,
2097
+ customisations,
2098
+ attrMode,
2099
+ renderedMode
2100
+ });
2101
+ }
2102
+ /**
2103
+ * Start observer
2104
+ */
2105
+ startObserver() {
2106
+ if (!this._observer && !this.hasAttribute("noobserver")) {
2107
+ try {
2108
+ this._observer = new IntersectionObserver((entries) => {
2109
+ const intersecting = entries.some((entry) => entry.isIntersecting);
2110
+ if (intersecting !== this._visible) {
2111
+ this._visible = intersecting;
2112
+ this._forceRender();
2113
+ }
2114
+ });
2115
+ this._observer.observe(this);
2116
+ } catch (err) {
2117
+ if (this._observer) {
2118
+ try {
2119
+ this._observer.disconnect();
2120
+ } catch (err2) {
2121
+ }
2122
+ this._observer = null;
2123
+ }
2124
+ }
2125
+ }
2126
+ }
2127
+ /**
2128
+ * Stop observer
2129
+ */
2130
+ stopObserver() {
2131
+ if (this._observer) {
2132
+ this._observer.disconnect();
2133
+ this._observer = null;
2134
+ this._visible = true;
2135
+ if (this._connected) {
2136
+ this._forceRender();
2137
+ }
2138
+ }
2139
+ }
2140
+ };
2141
+ attributes.forEach((attr) => {
2142
+ if (!(attr in IconifyIcon.prototype)) {
2143
+ Object.defineProperty(IconifyIcon.prototype, attr, {
2144
+ get: function() {
2145
+ return this.getAttribute(attr);
2146
+ },
2147
+ set: function(value) {
2148
+ if (value !== null) {
2149
+ this.setAttribute(attr, value);
2150
+ } else {
2151
+ this.removeAttribute(attr);
2152
+ }
2153
+ }
2154
+ });
2155
+ }
2156
+ });
2157
+ const functions = exportFunctions();
2158
+ for (const key in functions) {
2159
+ IconifyIcon[key] = IconifyIcon.prototype[key] = functions[key];
2160
+ }
2161
+ customElements.define(name, IconifyIcon);
2162
+ return IconifyIcon;
2163
+ }
2164
+ defineIconifyIcon() || exportFunctions();
2165
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
2166
+ ...{
2167
+ name: "PIcon"
2168
+ },
2169
+ __name: "p-icon",
2170
+ props: {
2171
+ icon: {}
2172
+ },
2173
+ setup(__props) {
2174
+ const isPIcon = (icon) => !!pIcon.P_ICON_ALIASES[icon];
2175
+ return (_ctx, _cache) => {
2176
+ return vue.openBlock(), vue.createElementBlock("iconify-icon", vue.normalizeProps(vue.guardReactiveProps({ ..._ctx.$props, icon: isPIcon(_ctx.icon) ? vue.unref(pIcon.P_ICON_ALIASES)[_ctx.icon] : _ctx.icon })), null, 16);
2177
+ };
2178
+ }
2179
+ });
2180
+ exports._sfc_main = _sfc_main;