@ttoss/components 2.0.8 → 2.0.10

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