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