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