@ttoss/layouts 0.11.20 → 0.11.22

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