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