@ttoss/forms 0.22.2 → 0.22.4

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