@pequity/squirrel 5.2.3 → 5.3.1

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