@ttoss/components 2.2.32 → 2.4.0

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