@pequity/squirrel 5.1.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/index.js CHANGED
@@ -1,5 +1,8 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1
4
  import { config } from "./config.js";
2
- import { defineComponent, openBlock, createBlock, Teleport, createElementBlock, mergeProps, createElementVNode, createVNode, toDisplayString, Fragment, renderList, withCtx, resolveDynamicComponent, createCommentVNode, shallowRef, ref, computed, onMounted, normalizeClass, unref, withModifiers, createTextVNode, withDirectives, vShow, pushScopeId, popScopeId, useAttrs, resolveDirective, normalizeStyle, isRef, renderSlot, provide, onBeforeUnmount, watch, toHandlers } from "vue";
5
+ import { defineComponent, openBlock, createBlock, Teleport, createElementBlock, mergeProps, createElementVNode, createVNode, toDisplayString, Fragment, renderList, withCtx, resolveDynamicComponent, createCommentVNode, shallowRef, ref, computed, onMounted, normalizeClass, unref, withModifiers, createTextVNode, withDirectives, vShow, pushScopeId, popScopeId, normalizeProps, guardReactiveProps, useAttrs, resolveDirective, normalizeStyle, isRef, renderSlot, provide, onBeforeUnmount, watch, toHandlers } from "vue";
3
6
  import PBtn from "./p-btn.js";
4
7
  import PCloseBtn from "./p-close-btn.js";
5
8
  import PDropdown from "./p-dropdown.js";
@@ -18,6 +21,7 @@ import { useInputClasses } from "./useInputClasses.js";
18
21
  import { useToast } from "vue-toastification";
19
22
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
20
23
  import { default as default8 } from "./p-table-filter-icon.js";
24
+ import { P_ICON_ALIASES } from "./p-icon.js";
21
25
  import { default as default9 } from "./p-info-icon.js";
22
26
  import { default as default10 } from "./p-inline-date-picker.js";
23
27
  import { default as default11 } from "./p-input.js";
@@ -70,7 +74,7 @@ const _hoisted_5$4 = { class: "flex items-center gap-2 px-1 py-0.5" };
70
74
  const _hoisted_6$4 = { class: "flex items-center gap-2 px-1 py-0.5" };
71
75
  const _hoisted_7$3 = { class: "flex flex-col bg-p-purple-60" };
72
76
  const _hoisted_8$1 = { class: "flex items-center gap-2 px-1 py-0.5" };
73
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
77
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
74
78
  ...{
75
79
  name: "PActionBar",
76
80
  inheritAttrs: false
@@ -210,7 +214,7 @@ const _hoisted_11 = { class: "max-h-48 overflow-y-auto overflow-x-hidden" };
210
214
  const _hoisted_12 = ["title"];
211
215
  const _hoisted_13 = ["onClick"];
212
216
  const _hoisted_14 = { class: "mt-1 text-xs text-p-gray-40" };
213
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
217
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
214
218
  ...{
215
219
  name: "PFileUpload"
216
220
  },
@@ -436,7 +440,2180 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
436
440
  };
437
441
  }
438
442
  });
439
- const pFileUpload = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-d07a8f64"]]);
443
+ const pFileUpload = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-d07a8f64"]]);
444
+ /**
445
+ * (c) Iconify
446
+ *
447
+ * For the full copyright and license information, please view the license.txt
448
+ * files at https://github.com/iconify/iconify
449
+ *
450
+ * Licensed under MIT.
451
+ *
452
+ * @license MIT
453
+ * @version 2.1.0
454
+ */
455
+ const defaultIconDimensions = Object.freeze(
456
+ {
457
+ left: 0,
458
+ top: 0,
459
+ width: 16,
460
+ height: 16
461
+ }
462
+ );
463
+ const defaultIconTransformations = Object.freeze({
464
+ rotate: 0,
465
+ vFlip: false,
466
+ hFlip: false
467
+ });
468
+ const defaultIconProps = Object.freeze({
469
+ ...defaultIconDimensions,
470
+ ...defaultIconTransformations
471
+ });
472
+ const defaultExtendedIconProps = Object.freeze({
473
+ ...defaultIconProps,
474
+ body: "",
475
+ hidden: false
476
+ });
477
+ const defaultIconSizeCustomisations = Object.freeze({
478
+ width: null,
479
+ height: null
480
+ });
481
+ const defaultIconCustomisations = Object.freeze({
482
+ // Dimensions
483
+ ...defaultIconSizeCustomisations,
484
+ // Transformations
485
+ ...defaultIconTransformations
486
+ });
487
+ function rotateFromString(value, defaultValue = 0) {
488
+ const units = value.replace(/^-?[0-9.]*/, "");
489
+ function cleanup(value2) {
490
+ while (value2 < 0) {
491
+ value2 += 4;
492
+ }
493
+ return value2 % 4;
494
+ }
495
+ if (units === "") {
496
+ const num = parseInt(value);
497
+ return isNaN(num) ? 0 : cleanup(num);
498
+ } else if (units !== value) {
499
+ let split = 0;
500
+ switch (units) {
501
+ case "%":
502
+ split = 25;
503
+ break;
504
+ case "deg":
505
+ split = 90;
506
+ }
507
+ if (split) {
508
+ let num = parseFloat(value.slice(0, value.length - units.length));
509
+ if (isNaN(num)) {
510
+ return 0;
511
+ }
512
+ num = num / split;
513
+ return num % 1 === 0 ? cleanup(num) : 0;
514
+ }
515
+ }
516
+ return defaultValue;
517
+ }
518
+ const separator = /[\s,]+/;
519
+ function flipFromString(custom, flip) {
520
+ flip.split(separator).forEach((str) => {
521
+ const value = str.trim();
522
+ switch (value) {
523
+ case "horizontal":
524
+ custom.hFlip = true;
525
+ break;
526
+ case "vertical":
527
+ custom.vFlip = true;
528
+ break;
529
+ }
530
+ });
531
+ }
532
+ const defaultCustomisations = {
533
+ ...defaultIconCustomisations,
534
+ preserveAspectRatio: ""
535
+ };
536
+ function getCustomisations(node) {
537
+ const customisations = {
538
+ ...defaultCustomisations
539
+ };
540
+ const attr = (key, def) => node.getAttribute(key) || def;
541
+ customisations.width = attr("width", null);
542
+ customisations.height = attr("height", null);
543
+ customisations.rotate = rotateFromString(attr("rotate", ""));
544
+ flipFromString(customisations, attr("flip", ""));
545
+ customisations.preserveAspectRatio = attr("preserveAspectRatio", attr("preserveaspectratio", ""));
546
+ return customisations;
547
+ }
548
+ function haveCustomisationsChanged(value1, value2) {
549
+ for (const key in defaultCustomisations) {
550
+ if (value1[key] !== value2[key]) {
551
+ return true;
552
+ }
553
+ }
554
+ return false;
555
+ }
556
+ const matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
557
+ const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
558
+ const colonSeparated = value.split(":");
559
+ if (value.slice(0, 1) === "@") {
560
+ if (colonSeparated.length < 2 || colonSeparated.length > 3) {
561
+ return null;
562
+ }
563
+ provider = colonSeparated.shift().slice(1);
564
+ }
565
+ if (colonSeparated.length > 3 || !colonSeparated.length) {
566
+ return null;
567
+ }
568
+ if (colonSeparated.length > 1) {
569
+ const name2 = colonSeparated.pop();
570
+ const prefix = colonSeparated.pop();
571
+ const result = {
572
+ // Allow provider without '@': "provider:prefix:name"
573
+ provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
574
+ prefix,
575
+ name: name2
576
+ };
577
+ return validate && !validateIconName(result) ? null : result;
578
+ }
579
+ const name = colonSeparated[0];
580
+ const dashSeparated = name.split("-");
581
+ if (dashSeparated.length > 1) {
582
+ const result = {
583
+ provider,
584
+ prefix: dashSeparated.shift(),
585
+ name: dashSeparated.join("-")
586
+ };
587
+ return validate && !validateIconName(result) ? null : result;
588
+ }
589
+ if (allowSimpleName && provider === "") {
590
+ const result = {
591
+ provider,
592
+ prefix: "",
593
+ name
594
+ };
595
+ return validate && !validateIconName(result, allowSimpleName) ? null : result;
596
+ }
597
+ return null;
598
+ };
599
+ const validateIconName = (icon, allowSimpleName) => {
600
+ if (!icon) {
601
+ return false;
602
+ }
603
+ return !!((icon.provider === "" || icon.provider.match(matchIconName)) && (allowSimpleName && icon.prefix === "" || icon.prefix.match(matchIconName)) && icon.name.match(matchIconName));
604
+ };
605
+ function mergeIconTransformations(obj1, obj2) {
606
+ const result = {};
607
+ if (!obj1.hFlip !== !obj2.hFlip) {
608
+ result.hFlip = true;
609
+ }
610
+ if (!obj1.vFlip !== !obj2.vFlip) {
611
+ result.vFlip = true;
612
+ }
613
+ const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
614
+ if (rotate) {
615
+ result.rotate = rotate;
616
+ }
617
+ return result;
618
+ }
619
+ function mergeIconData(parent, child) {
620
+ const result = mergeIconTransformations(parent, child);
621
+ for (const key in defaultExtendedIconProps) {
622
+ if (key in defaultIconTransformations) {
623
+ if (key in parent && !(key in result)) {
624
+ result[key] = defaultIconTransformations[key];
625
+ }
626
+ } else if (key in child) {
627
+ result[key] = child[key];
628
+ } else if (key in parent) {
629
+ result[key] = parent[key];
630
+ }
631
+ }
632
+ return result;
633
+ }
634
+ function getIconsTree(data, names) {
635
+ const icons = data.icons;
636
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
637
+ const resolved = /* @__PURE__ */ Object.create(null);
638
+ function resolve(name) {
639
+ if (icons[name]) {
640
+ return resolved[name] = [];
641
+ }
642
+ if (!(name in resolved)) {
643
+ resolved[name] = null;
644
+ const parent = aliases[name] && aliases[name].parent;
645
+ const value = parent && resolve(parent);
646
+ if (value) {
647
+ resolved[name] = [parent].concat(value);
648
+ }
649
+ }
650
+ return resolved[name];
651
+ }
652
+ Object.keys(icons).concat(Object.keys(aliases)).forEach(resolve);
653
+ return resolved;
654
+ }
655
+ function internalGetIconData(data, name, tree) {
656
+ const icons = data.icons;
657
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
658
+ let currentProps = {};
659
+ function parse(name2) {
660
+ currentProps = mergeIconData(
661
+ icons[name2] || aliases[name2],
662
+ currentProps
663
+ );
664
+ }
665
+ parse(name);
666
+ tree.forEach(parse);
667
+ return mergeIconData(data, currentProps);
668
+ }
669
+ function parseIconSet(data, callback) {
670
+ const names = [];
671
+ if (typeof data !== "object" || typeof data.icons !== "object") {
672
+ return names;
673
+ }
674
+ if (data.not_found instanceof Array) {
675
+ data.not_found.forEach((name) => {
676
+ callback(name, null);
677
+ names.push(name);
678
+ });
679
+ }
680
+ const tree = getIconsTree(data);
681
+ for (const name in tree) {
682
+ const item = tree[name];
683
+ if (item) {
684
+ callback(name, internalGetIconData(data, name, item));
685
+ names.push(name);
686
+ }
687
+ }
688
+ return names;
689
+ }
690
+ const optionalPropertyDefaults = {
691
+ provider: "",
692
+ aliases: {},
693
+ not_found: {},
694
+ ...defaultIconDimensions
695
+ };
696
+ function checkOptionalProps(item, defaults) {
697
+ for (const prop in defaults) {
698
+ if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
699
+ return false;
700
+ }
701
+ }
702
+ return true;
703
+ }
704
+ function quicklyValidateIconSet(obj) {
705
+ if (typeof obj !== "object" || obj === null) {
706
+ return null;
707
+ }
708
+ const data = obj;
709
+ if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
710
+ return null;
711
+ }
712
+ if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
713
+ return null;
714
+ }
715
+ const icons = data.icons;
716
+ for (const name in icons) {
717
+ const icon = icons[name];
718
+ if (!name.match(matchIconName) || typeof icon.body !== "string" || !checkOptionalProps(
719
+ icon,
720
+ defaultExtendedIconProps
721
+ )) {
722
+ return null;
723
+ }
724
+ }
725
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
726
+ for (const name in aliases) {
727
+ const icon = aliases[name];
728
+ const parent = icon.parent;
729
+ if (!name.match(matchIconName) || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(
730
+ icon,
731
+ defaultExtendedIconProps
732
+ )) {
733
+ return null;
734
+ }
735
+ }
736
+ return data;
737
+ }
738
+ const dataStorage = /* @__PURE__ */ Object.create(null);
739
+ function newStorage(provider, prefix) {
740
+ return {
741
+ provider,
742
+ prefix,
743
+ icons: /* @__PURE__ */ Object.create(null),
744
+ missing: /* @__PURE__ */ new Set()
745
+ };
746
+ }
747
+ function getStorage(provider, prefix) {
748
+ const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
749
+ return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
750
+ }
751
+ function addIconSet(storage2, data) {
752
+ if (!quicklyValidateIconSet(data)) {
753
+ return [];
754
+ }
755
+ return parseIconSet(data, (name, icon) => {
756
+ if (icon) {
757
+ storage2.icons[name] = icon;
758
+ } else {
759
+ storage2.missing.add(name);
760
+ }
761
+ });
762
+ }
763
+ function addIconToStorage(storage2, name, icon) {
764
+ try {
765
+ if (typeof icon.body === "string") {
766
+ storage2.icons[name] = { ...icon };
767
+ return true;
768
+ }
769
+ } catch (err) {
770
+ }
771
+ return false;
772
+ }
773
+ function listIcons$1(provider, prefix) {
774
+ let allIcons = [];
775
+ const providers = typeof provider === "string" ? [provider] : Object.keys(dataStorage);
776
+ providers.forEach((provider2) => {
777
+ const prefixes = typeof provider2 === "string" && typeof prefix === "string" ? [prefix] : Object.keys(dataStorage[provider2] || {});
778
+ prefixes.forEach((prefix2) => {
779
+ const storage2 = getStorage(provider2, prefix2);
780
+ allIcons = allIcons.concat(
781
+ Object.keys(storage2.icons).map(
782
+ (name) => (provider2 !== "" ? "@" + provider2 + ":" : "") + prefix2 + ":" + name
783
+ )
784
+ );
785
+ });
786
+ });
787
+ return allIcons;
788
+ }
789
+ let simpleNames = false;
790
+ function allowSimpleNames(allow) {
791
+ if (typeof allow === "boolean") {
792
+ simpleNames = allow;
793
+ }
794
+ return simpleNames;
795
+ }
796
+ function getIconData(name) {
797
+ const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
798
+ if (icon) {
799
+ const storage2 = getStorage(icon.provider, icon.prefix);
800
+ const iconName = icon.name;
801
+ return storage2.icons[iconName] || (storage2.missing.has(iconName) ? null : void 0);
802
+ }
803
+ }
804
+ function addIcon$1(name, data) {
805
+ const icon = stringToIcon(name, true, simpleNames);
806
+ if (!icon) {
807
+ return false;
808
+ }
809
+ const storage2 = getStorage(icon.provider, icon.prefix);
810
+ return addIconToStorage(storage2, icon.name, data);
811
+ }
812
+ function addCollection$1(data, provider) {
813
+ if (typeof data !== "object") {
814
+ return false;
815
+ }
816
+ if (typeof provider !== "string") {
817
+ provider = data.provider || "";
818
+ }
819
+ if (simpleNames && !provider && !data.prefix) {
820
+ let added = false;
821
+ if (quicklyValidateIconSet(data)) {
822
+ data.prefix = "";
823
+ parseIconSet(data, (name, icon) => {
824
+ if (icon && addIcon$1(name, icon)) {
825
+ added = true;
826
+ }
827
+ });
828
+ }
829
+ return added;
830
+ }
831
+ const prefix = data.prefix;
832
+ if (!validateIconName({
833
+ provider,
834
+ prefix,
835
+ name: "a"
836
+ })) {
837
+ return false;
838
+ }
839
+ const storage2 = getStorage(provider, prefix);
840
+ return !!addIconSet(storage2, data);
841
+ }
842
+ function iconLoaded$1(name) {
843
+ return !!getIconData(name);
844
+ }
845
+ function getIcon$1(name) {
846
+ const result = getIconData(name);
847
+ return result ? {
848
+ ...defaultIconProps,
849
+ ...result
850
+ } : null;
851
+ }
852
+ function sortIcons(icons) {
853
+ const result = {
854
+ loaded: [],
855
+ missing: [],
856
+ pending: []
857
+ };
858
+ const storage2 = /* @__PURE__ */ Object.create(null);
859
+ icons.sort((a, b) => {
860
+ if (a.provider !== b.provider) {
861
+ return a.provider.localeCompare(b.provider);
862
+ }
863
+ if (a.prefix !== b.prefix) {
864
+ return a.prefix.localeCompare(b.prefix);
865
+ }
866
+ return a.name.localeCompare(b.name);
867
+ });
868
+ let lastIcon = {
869
+ provider: "",
870
+ prefix: "",
871
+ name: ""
872
+ };
873
+ icons.forEach((icon) => {
874
+ if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) {
875
+ return;
876
+ }
877
+ lastIcon = icon;
878
+ const provider = icon.provider;
879
+ const prefix = icon.prefix;
880
+ const name = icon.name;
881
+ const providerStorage = storage2[provider] || (storage2[provider] = /* @__PURE__ */ Object.create(null));
882
+ const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
883
+ let list;
884
+ if (name in localStorage.icons) {
885
+ list = result.loaded;
886
+ } else if (prefix === "" || localStorage.missing.has(name)) {
887
+ list = result.missing;
888
+ } else {
889
+ list = result.pending;
890
+ }
891
+ const item = {
892
+ provider,
893
+ prefix,
894
+ name
895
+ };
896
+ list.push(item);
897
+ });
898
+ return result;
899
+ }
900
+ function removeCallback(storages, id) {
901
+ storages.forEach((storage2) => {
902
+ const items = storage2.loaderCallbacks;
903
+ if (items) {
904
+ storage2.loaderCallbacks = items.filter((row) => row.id !== id);
905
+ }
906
+ });
907
+ }
908
+ function updateCallbacks(storage2) {
909
+ if (!storage2.pendingCallbacksFlag) {
910
+ storage2.pendingCallbacksFlag = true;
911
+ setTimeout(() => {
912
+ storage2.pendingCallbacksFlag = false;
913
+ const items = storage2.loaderCallbacks ? storage2.loaderCallbacks.slice(0) : [];
914
+ if (!items.length) {
915
+ return;
916
+ }
917
+ let hasPending = false;
918
+ const provider = storage2.provider;
919
+ const prefix = storage2.prefix;
920
+ items.forEach((item) => {
921
+ const icons = item.icons;
922
+ const oldLength = icons.pending.length;
923
+ icons.pending = icons.pending.filter((icon) => {
924
+ if (icon.prefix !== prefix) {
925
+ return true;
926
+ }
927
+ const name = icon.name;
928
+ if (storage2.icons[name]) {
929
+ icons.loaded.push({
930
+ provider,
931
+ prefix,
932
+ name
933
+ });
934
+ } else if (storage2.missing.has(name)) {
935
+ icons.missing.push({
936
+ provider,
937
+ prefix,
938
+ name
939
+ });
940
+ } else {
941
+ hasPending = true;
942
+ return true;
943
+ }
944
+ return false;
945
+ });
946
+ if (icons.pending.length !== oldLength) {
947
+ if (!hasPending) {
948
+ removeCallback([storage2], item.id);
949
+ }
950
+ item.callback(
951
+ icons.loaded.slice(0),
952
+ icons.missing.slice(0),
953
+ icons.pending.slice(0),
954
+ item.abort
955
+ );
956
+ }
957
+ });
958
+ });
959
+ }
960
+ }
961
+ let idCounter = 0;
962
+ function storeCallback(callback, icons, pendingSources) {
963
+ const id = idCounter++;
964
+ const abort = removeCallback.bind(null, pendingSources, id);
965
+ if (!icons.pending.length) {
966
+ return abort;
967
+ }
968
+ const item = {
969
+ id,
970
+ icons,
971
+ callback,
972
+ abort
973
+ };
974
+ pendingSources.forEach((storage2) => {
975
+ (storage2.loaderCallbacks || (storage2.loaderCallbacks = [])).push(item);
976
+ });
977
+ return abort;
978
+ }
979
+ const storage = /* @__PURE__ */ Object.create(null);
980
+ function setAPIModule(provider, item) {
981
+ storage[provider] = item;
982
+ }
983
+ function getAPIModule(provider) {
984
+ return storage[provider] || storage[""];
985
+ }
986
+ function listToIcons(list, validate = true, simpleNames2 = false) {
987
+ const result = [];
988
+ list.forEach((item) => {
989
+ const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames2) : item;
990
+ if (icon) {
991
+ result.push(icon);
992
+ }
993
+ });
994
+ return result;
995
+ }
996
+ var defaultConfig = {
997
+ resources: [],
998
+ index: 0,
999
+ timeout: 2e3,
1000
+ rotate: 750,
1001
+ random: false,
1002
+ dataAfterTimeout: false
1003
+ };
1004
+ function sendQuery(config2, payload, query, done) {
1005
+ const resourcesCount = config2.resources.length;
1006
+ const startIndex = config2.random ? Math.floor(Math.random() * resourcesCount) : config2.index;
1007
+ let resources;
1008
+ if (config2.random) {
1009
+ let list = config2.resources.slice(0);
1010
+ resources = [];
1011
+ while (list.length > 1) {
1012
+ const nextIndex = Math.floor(Math.random() * list.length);
1013
+ resources.push(list[nextIndex]);
1014
+ list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
1015
+ }
1016
+ resources = resources.concat(list);
1017
+ } else {
1018
+ resources = config2.resources.slice(startIndex).concat(config2.resources.slice(0, startIndex));
1019
+ }
1020
+ const startTime = Date.now();
1021
+ let status = "pending";
1022
+ let queriesSent = 0;
1023
+ let lastError;
1024
+ let timer = null;
1025
+ let queue = [];
1026
+ let doneCallbacks = [];
1027
+ if (typeof done === "function") {
1028
+ doneCallbacks.push(done);
1029
+ }
1030
+ function resetTimer() {
1031
+ if (timer) {
1032
+ clearTimeout(timer);
1033
+ timer = null;
1034
+ }
1035
+ }
1036
+ function abort() {
1037
+ if (status === "pending") {
1038
+ status = "aborted";
1039
+ }
1040
+ resetTimer();
1041
+ queue.forEach((item) => {
1042
+ if (item.status === "pending") {
1043
+ item.status = "aborted";
1044
+ }
1045
+ });
1046
+ queue = [];
1047
+ }
1048
+ function subscribe(callback, overwrite) {
1049
+ if (overwrite) {
1050
+ doneCallbacks = [];
1051
+ }
1052
+ if (typeof callback === "function") {
1053
+ doneCallbacks.push(callback);
1054
+ }
1055
+ }
1056
+ function getQueryStatus() {
1057
+ return {
1058
+ startTime,
1059
+ payload,
1060
+ status,
1061
+ queriesSent,
1062
+ queriesPending: queue.length,
1063
+ subscribe,
1064
+ abort
1065
+ };
1066
+ }
1067
+ function failQuery() {
1068
+ status = "failed";
1069
+ doneCallbacks.forEach((callback) => {
1070
+ callback(void 0, lastError);
1071
+ });
1072
+ }
1073
+ function clearQueue() {
1074
+ queue.forEach((item) => {
1075
+ if (item.status === "pending") {
1076
+ item.status = "aborted";
1077
+ }
1078
+ });
1079
+ queue = [];
1080
+ }
1081
+ function moduleResponse(item, response, data) {
1082
+ const isError = response !== "success";
1083
+ queue = queue.filter((queued) => queued !== item);
1084
+ switch (status) {
1085
+ case "pending":
1086
+ break;
1087
+ case "failed":
1088
+ if (isError || !config2.dataAfterTimeout) {
1089
+ return;
1090
+ }
1091
+ break;
1092
+ default:
1093
+ return;
1094
+ }
1095
+ if (response === "abort") {
1096
+ lastError = data;
1097
+ failQuery();
1098
+ return;
1099
+ }
1100
+ if (isError) {
1101
+ lastError = data;
1102
+ if (!queue.length) {
1103
+ if (!resources.length) {
1104
+ failQuery();
1105
+ } else {
1106
+ execNext();
1107
+ }
1108
+ }
1109
+ return;
1110
+ }
1111
+ resetTimer();
1112
+ clearQueue();
1113
+ if (!config2.random) {
1114
+ const index = config2.resources.indexOf(item.resource);
1115
+ if (index !== -1 && index !== config2.index) {
1116
+ config2.index = index;
1117
+ }
1118
+ }
1119
+ status = "completed";
1120
+ doneCallbacks.forEach((callback) => {
1121
+ callback(data);
1122
+ });
1123
+ }
1124
+ function execNext() {
1125
+ if (status !== "pending") {
1126
+ return;
1127
+ }
1128
+ resetTimer();
1129
+ const resource = resources.shift();
1130
+ if (resource === void 0) {
1131
+ if (queue.length) {
1132
+ timer = setTimeout(() => {
1133
+ resetTimer();
1134
+ if (status === "pending") {
1135
+ clearQueue();
1136
+ failQuery();
1137
+ }
1138
+ }, config2.timeout);
1139
+ return;
1140
+ }
1141
+ failQuery();
1142
+ return;
1143
+ }
1144
+ const item = {
1145
+ status: "pending",
1146
+ resource,
1147
+ callback: (status2, data) => {
1148
+ moduleResponse(item, status2, data);
1149
+ }
1150
+ };
1151
+ queue.push(item);
1152
+ queriesSent++;
1153
+ timer = setTimeout(execNext, config2.rotate);
1154
+ query(resource, payload, item.callback);
1155
+ }
1156
+ setTimeout(execNext);
1157
+ return getQueryStatus;
1158
+ }
1159
+ function initRedundancy(cfg) {
1160
+ const config2 = {
1161
+ ...defaultConfig,
1162
+ ...cfg
1163
+ };
1164
+ let queries = [];
1165
+ function cleanup() {
1166
+ queries = queries.filter((item) => item().status === "pending");
1167
+ }
1168
+ function query(payload, queryCallback, doneCallback) {
1169
+ const query2 = sendQuery(
1170
+ config2,
1171
+ payload,
1172
+ queryCallback,
1173
+ (data, error) => {
1174
+ cleanup();
1175
+ if (doneCallback) {
1176
+ doneCallback(data, error);
1177
+ }
1178
+ }
1179
+ );
1180
+ queries.push(query2);
1181
+ return query2;
1182
+ }
1183
+ function find(callback) {
1184
+ return queries.find((value) => {
1185
+ return callback(value);
1186
+ }) || null;
1187
+ }
1188
+ const instance = {
1189
+ query,
1190
+ find,
1191
+ setIndex: (index) => {
1192
+ config2.index = index;
1193
+ },
1194
+ getIndex: () => config2.index,
1195
+ cleanup
1196
+ };
1197
+ return instance;
1198
+ }
1199
+ function createAPIConfig(source) {
1200
+ let resources;
1201
+ if (typeof source.resources === "string") {
1202
+ resources = [source.resources];
1203
+ } else {
1204
+ resources = source.resources;
1205
+ if (!(resources instanceof Array) || !resources.length) {
1206
+ return null;
1207
+ }
1208
+ }
1209
+ const result = {
1210
+ // API hosts
1211
+ resources,
1212
+ // Root path
1213
+ path: source.path || "/",
1214
+ // URL length limit
1215
+ maxURL: source.maxURL || 500,
1216
+ // Timeout before next host is used.
1217
+ rotate: source.rotate || 750,
1218
+ // Timeout before failing query.
1219
+ timeout: source.timeout || 5e3,
1220
+ // Randomise default API end point.
1221
+ random: source.random === true,
1222
+ // Start index
1223
+ index: source.index || 0,
1224
+ // Receive data after time out (used if time out kicks in first, then API module sends data anyway).
1225
+ dataAfterTimeout: source.dataAfterTimeout !== false
1226
+ };
1227
+ return result;
1228
+ }
1229
+ const configStorage = /* @__PURE__ */ Object.create(null);
1230
+ const fallBackAPISources = [
1231
+ "https://api.simplesvg.com",
1232
+ "https://api.unisvg.com"
1233
+ ];
1234
+ const fallBackAPI = [];
1235
+ while (fallBackAPISources.length > 0) {
1236
+ if (fallBackAPISources.length === 1) {
1237
+ fallBackAPI.push(fallBackAPISources.shift());
1238
+ } else {
1239
+ if (Math.random() > 0.5) {
1240
+ fallBackAPI.push(fallBackAPISources.shift());
1241
+ } else {
1242
+ fallBackAPI.push(fallBackAPISources.pop());
1243
+ }
1244
+ }
1245
+ }
1246
+ configStorage[""] = createAPIConfig({
1247
+ resources: ["https://api.iconify.design"].concat(fallBackAPI)
1248
+ });
1249
+ function addAPIProvider$1(provider, customConfig) {
1250
+ const config2 = createAPIConfig(customConfig);
1251
+ if (config2 === null) {
1252
+ return false;
1253
+ }
1254
+ configStorage[provider] = config2;
1255
+ return true;
1256
+ }
1257
+ function getAPIConfig(provider) {
1258
+ return configStorage[provider];
1259
+ }
1260
+ function listAPIProviders() {
1261
+ return Object.keys(configStorage);
1262
+ }
1263
+ function emptyCallback$1() {
1264
+ }
1265
+ const redundancyCache = /* @__PURE__ */ Object.create(null);
1266
+ function getRedundancyCache(provider) {
1267
+ if (!redundancyCache[provider]) {
1268
+ const config2 = getAPIConfig(provider);
1269
+ if (!config2) {
1270
+ return;
1271
+ }
1272
+ const redundancy = initRedundancy(config2);
1273
+ const cachedReundancy = {
1274
+ config: config2,
1275
+ redundancy
1276
+ };
1277
+ redundancyCache[provider] = cachedReundancy;
1278
+ }
1279
+ return redundancyCache[provider];
1280
+ }
1281
+ function sendAPIQuery(target, query, callback) {
1282
+ let redundancy;
1283
+ let send2;
1284
+ if (typeof target === "string") {
1285
+ const api = getAPIModule(target);
1286
+ if (!api) {
1287
+ callback(void 0, 424);
1288
+ return emptyCallback$1;
1289
+ }
1290
+ send2 = api.send;
1291
+ const cached = getRedundancyCache(target);
1292
+ if (cached) {
1293
+ redundancy = cached.redundancy;
1294
+ }
1295
+ } else {
1296
+ const config2 = createAPIConfig(target);
1297
+ if (config2) {
1298
+ redundancy = initRedundancy(config2);
1299
+ const moduleKey = target.resources ? target.resources[0] : "";
1300
+ const api = getAPIModule(moduleKey);
1301
+ if (api) {
1302
+ send2 = api.send;
1303
+ }
1304
+ }
1305
+ }
1306
+ if (!redundancy || !send2) {
1307
+ callback(void 0, 424);
1308
+ return emptyCallback$1;
1309
+ }
1310
+ return redundancy.query(query, send2, callback)().abort;
1311
+ }
1312
+ const browserCacheVersion = "iconify2";
1313
+ const browserCachePrefix = "iconify";
1314
+ const browserCacheCountKey = browserCachePrefix + "-count";
1315
+ const browserCacheVersionKey = browserCachePrefix + "-version";
1316
+ const browserStorageHour = 36e5;
1317
+ const browserStorageCacheExpiration = 168;
1318
+ const browserStorageLimit = 50;
1319
+ function getStoredItem(func, key) {
1320
+ try {
1321
+ return func.getItem(key);
1322
+ } catch (err) {
1323
+ }
1324
+ }
1325
+ function setStoredItem(func, key, value) {
1326
+ try {
1327
+ func.setItem(key, value);
1328
+ return true;
1329
+ } catch (err) {
1330
+ }
1331
+ }
1332
+ function removeStoredItem(func, key) {
1333
+ try {
1334
+ func.removeItem(key);
1335
+ } catch (err) {
1336
+ }
1337
+ }
1338
+ function setBrowserStorageItemsCount(storage2, value) {
1339
+ return setStoredItem(storage2, browserCacheCountKey, value.toString());
1340
+ }
1341
+ function getBrowserStorageItemsCount(storage2) {
1342
+ return parseInt(getStoredItem(storage2, browserCacheCountKey)) || 0;
1343
+ }
1344
+ const browserStorageConfig = {
1345
+ local: true,
1346
+ session: true
1347
+ };
1348
+ const browserStorageEmptyItems = {
1349
+ local: /* @__PURE__ */ new Set(),
1350
+ session: /* @__PURE__ */ new Set()
1351
+ };
1352
+ let browserStorageStatus = false;
1353
+ function setBrowserStorageStatus(status) {
1354
+ browserStorageStatus = status;
1355
+ }
1356
+ let _window = typeof window === "undefined" ? {} : window;
1357
+ function getBrowserStorage(key) {
1358
+ const attr = key + "Storage";
1359
+ try {
1360
+ if (_window && _window[attr] && typeof _window[attr].length === "number") {
1361
+ return _window[attr];
1362
+ }
1363
+ } catch (err) {
1364
+ }
1365
+ browserStorageConfig[key] = false;
1366
+ }
1367
+ function iterateBrowserStorage(key, callback) {
1368
+ const func = getBrowserStorage(key);
1369
+ if (!func) {
1370
+ return;
1371
+ }
1372
+ const version = getStoredItem(func, browserCacheVersionKey);
1373
+ if (version !== browserCacheVersion) {
1374
+ if (version) {
1375
+ const total2 = getBrowserStorageItemsCount(func);
1376
+ for (let i = 0; i < total2; i++) {
1377
+ removeStoredItem(func, browserCachePrefix + i.toString());
1378
+ }
1379
+ }
1380
+ setStoredItem(func, browserCacheVersionKey, browserCacheVersion);
1381
+ setBrowserStorageItemsCount(func, 0);
1382
+ return;
1383
+ }
1384
+ const minTime = Math.floor(Date.now() / browserStorageHour) - browserStorageCacheExpiration;
1385
+ const parseItem = (index) => {
1386
+ const name = browserCachePrefix + index.toString();
1387
+ const item = getStoredItem(func, name);
1388
+ if (typeof item !== "string") {
1389
+ return;
1390
+ }
1391
+ try {
1392
+ const data = JSON.parse(item);
1393
+ if (typeof data === "object" && typeof data.cached === "number" && data.cached > minTime && typeof data.provider === "string" && typeof data.data === "object" && typeof data.data.prefix === "string" && // Valid item: run callback
1394
+ callback(data, index)) {
1395
+ return true;
1396
+ }
1397
+ } catch (err) {
1398
+ }
1399
+ removeStoredItem(func, name);
1400
+ };
1401
+ let total = getBrowserStorageItemsCount(func);
1402
+ for (let i = total - 1; i >= 0; i--) {
1403
+ if (!parseItem(i)) {
1404
+ if (i === total - 1) {
1405
+ total--;
1406
+ setBrowserStorageItemsCount(func, total);
1407
+ } else {
1408
+ browserStorageEmptyItems[key].add(i);
1409
+ }
1410
+ }
1411
+ }
1412
+ }
1413
+ function initBrowserStorage() {
1414
+ if (browserStorageStatus) {
1415
+ return;
1416
+ }
1417
+ setBrowserStorageStatus(true);
1418
+ for (const key in browserStorageConfig) {
1419
+ iterateBrowserStorage(key, (item) => {
1420
+ const iconSet = item.data;
1421
+ const provider = item.provider;
1422
+ const prefix = iconSet.prefix;
1423
+ const storage2 = getStorage(
1424
+ provider,
1425
+ prefix
1426
+ );
1427
+ if (!addIconSet(storage2, iconSet).length) {
1428
+ return false;
1429
+ }
1430
+ const lastModified = iconSet.lastModified || -1;
1431
+ storage2.lastModifiedCached = storage2.lastModifiedCached ? Math.min(storage2.lastModifiedCached, lastModified) : lastModified;
1432
+ return true;
1433
+ });
1434
+ }
1435
+ }
1436
+ function updateLastModified(storage2, lastModified) {
1437
+ const lastValue = storage2.lastModifiedCached;
1438
+ if (
1439
+ // Matches or newer
1440
+ lastValue && lastValue >= lastModified
1441
+ ) {
1442
+ return lastValue === lastModified;
1443
+ }
1444
+ storage2.lastModifiedCached = lastModified;
1445
+ if (lastValue) {
1446
+ for (const key in browserStorageConfig) {
1447
+ iterateBrowserStorage(key, (item) => {
1448
+ const iconSet = item.data;
1449
+ return item.provider !== storage2.provider || iconSet.prefix !== storage2.prefix || iconSet.lastModified === lastModified;
1450
+ });
1451
+ }
1452
+ }
1453
+ return true;
1454
+ }
1455
+ function storeInBrowserStorage(storage2, data) {
1456
+ if (!browserStorageStatus) {
1457
+ initBrowserStorage();
1458
+ }
1459
+ function store(key) {
1460
+ let func;
1461
+ if (!browserStorageConfig[key] || !(func = getBrowserStorage(key))) {
1462
+ return;
1463
+ }
1464
+ const set = browserStorageEmptyItems[key];
1465
+ let index;
1466
+ if (set.size) {
1467
+ set.delete(index = Array.from(set).shift());
1468
+ } else {
1469
+ index = getBrowserStorageItemsCount(func);
1470
+ if (index >= browserStorageLimit || !setBrowserStorageItemsCount(func, index + 1)) {
1471
+ return;
1472
+ }
1473
+ }
1474
+ const item = {
1475
+ cached: Math.floor(Date.now() / browserStorageHour),
1476
+ provider: storage2.provider,
1477
+ data
1478
+ };
1479
+ return setStoredItem(
1480
+ func,
1481
+ browserCachePrefix + index.toString(),
1482
+ JSON.stringify(item)
1483
+ );
1484
+ }
1485
+ if (data.lastModified && !updateLastModified(storage2, data.lastModified)) {
1486
+ return;
1487
+ }
1488
+ if (!Object.keys(data.icons).length) {
1489
+ return;
1490
+ }
1491
+ if (data.not_found) {
1492
+ data = Object.assign({}, data);
1493
+ delete data.not_found;
1494
+ }
1495
+ if (!store("local")) {
1496
+ store("session");
1497
+ }
1498
+ }
1499
+ function emptyCallback() {
1500
+ }
1501
+ function loadedNewIcons(storage2) {
1502
+ if (!storage2.iconsLoaderFlag) {
1503
+ storage2.iconsLoaderFlag = true;
1504
+ setTimeout(() => {
1505
+ storage2.iconsLoaderFlag = false;
1506
+ updateCallbacks(storage2);
1507
+ });
1508
+ }
1509
+ }
1510
+ function loadNewIcons(storage2, icons) {
1511
+ if (!storage2.iconsToLoad) {
1512
+ storage2.iconsToLoad = icons;
1513
+ } else {
1514
+ storage2.iconsToLoad = storage2.iconsToLoad.concat(icons).sort();
1515
+ }
1516
+ if (!storage2.iconsQueueFlag) {
1517
+ storage2.iconsQueueFlag = true;
1518
+ setTimeout(() => {
1519
+ storage2.iconsQueueFlag = false;
1520
+ const { provider, prefix } = storage2;
1521
+ const icons2 = storage2.iconsToLoad;
1522
+ delete storage2.iconsToLoad;
1523
+ let api;
1524
+ if (!icons2 || !(api = getAPIModule(provider))) {
1525
+ return;
1526
+ }
1527
+ const params = api.prepare(provider, prefix, icons2);
1528
+ params.forEach((item) => {
1529
+ sendAPIQuery(provider, item, (data) => {
1530
+ if (typeof data !== "object") {
1531
+ item.icons.forEach((name) => {
1532
+ storage2.missing.add(name);
1533
+ });
1534
+ } else {
1535
+ try {
1536
+ const parsed = addIconSet(
1537
+ storage2,
1538
+ data
1539
+ );
1540
+ if (!parsed.length) {
1541
+ return;
1542
+ }
1543
+ const pending = storage2.pendingIcons;
1544
+ if (pending) {
1545
+ parsed.forEach((name) => {
1546
+ pending.delete(name);
1547
+ });
1548
+ }
1549
+ storeInBrowserStorage(storage2, data);
1550
+ } catch (err) {
1551
+ console.error(err);
1552
+ }
1553
+ }
1554
+ loadedNewIcons(storage2);
1555
+ });
1556
+ });
1557
+ });
1558
+ }
1559
+ }
1560
+ const loadIcons$1 = (icons, callback) => {
1561
+ const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
1562
+ const sortedIcons = sortIcons(cleanedIcons);
1563
+ if (!sortedIcons.pending.length) {
1564
+ let callCallback = true;
1565
+ if (callback) {
1566
+ setTimeout(() => {
1567
+ if (callCallback) {
1568
+ callback(
1569
+ sortedIcons.loaded,
1570
+ sortedIcons.missing,
1571
+ sortedIcons.pending,
1572
+ emptyCallback
1573
+ );
1574
+ }
1575
+ });
1576
+ }
1577
+ return () => {
1578
+ callCallback = false;
1579
+ };
1580
+ }
1581
+ const newIcons = /* @__PURE__ */ Object.create(null);
1582
+ const sources = [];
1583
+ let lastProvider, lastPrefix;
1584
+ sortedIcons.pending.forEach((icon) => {
1585
+ const { provider, prefix } = icon;
1586
+ if (prefix === lastPrefix && provider === lastProvider) {
1587
+ return;
1588
+ }
1589
+ lastProvider = provider;
1590
+ lastPrefix = prefix;
1591
+ sources.push(getStorage(provider, prefix));
1592
+ const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */ Object.create(null));
1593
+ if (!providerNewIcons[prefix]) {
1594
+ providerNewIcons[prefix] = [];
1595
+ }
1596
+ });
1597
+ sortedIcons.pending.forEach((icon) => {
1598
+ const { provider, prefix, name } = icon;
1599
+ const storage2 = getStorage(provider, prefix);
1600
+ const pendingQueue = storage2.pendingIcons || (storage2.pendingIcons = /* @__PURE__ */ new Set());
1601
+ if (!pendingQueue.has(name)) {
1602
+ pendingQueue.add(name);
1603
+ newIcons[provider][prefix].push(name);
1604
+ }
1605
+ });
1606
+ sources.forEach((storage2) => {
1607
+ const { provider, prefix } = storage2;
1608
+ if (newIcons[provider][prefix].length) {
1609
+ loadNewIcons(storage2, newIcons[provider][prefix]);
1610
+ }
1611
+ });
1612
+ return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
1613
+ };
1614
+ const loadIcon$1 = (icon) => {
1615
+ return new Promise((fulfill, reject) => {
1616
+ const iconObj = typeof icon === "string" ? stringToIcon(icon, true) : icon;
1617
+ if (!iconObj) {
1618
+ reject(icon);
1619
+ return;
1620
+ }
1621
+ loadIcons$1([iconObj || icon], (loaded) => {
1622
+ if (loaded.length && iconObj) {
1623
+ const data = getIconData(iconObj);
1624
+ if (data) {
1625
+ fulfill({
1626
+ ...defaultIconProps,
1627
+ ...data
1628
+ });
1629
+ return;
1630
+ }
1631
+ }
1632
+ reject(icon);
1633
+ });
1634
+ });
1635
+ };
1636
+ function testIconObject(value) {
1637
+ try {
1638
+ const obj = typeof value === "string" ? JSON.parse(value) : value;
1639
+ if (typeof obj.body === "string") {
1640
+ return {
1641
+ ...obj
1642
+ };
1643
+ }
1644
+ } catch (err) {
1645
+ }
1646
+ }
1647
+ function parseIconValue(value, onload) {
1648
+ const name = typeof value === "string" ? stringToIcon(value, true, true) : null;
1649
+ if (!name) {
1650
+ const data2 = testIconObject(value);
1651
+ return {
1652
+ value,
1653
+ data: data2
1654
+ };
1655
+ }
1656
+ const data = getIconData(name);
1657
+ if (data !== void 0 || !name.prefix) {
1658
+ return {
1659
+ value,
1660
+ name,
1661
+ data
1662
+ // could be 'null' -> icon is missing
1663
+ };
1664
+ }
1665
+ const loading = loadIcons$1([name], () => onload(value, name, getIconData(name)));
1666
+ return {
1667
+ value,
1668
+ name,
1669
+ loading
1670
+ };
1671
+ }
1672
+ let isBuggedSafari = false;
1673
+ try {
1674
+ isBuggedSafari = navigator.vendor.indexOf("Apple") === 0;
1675
+ } catch (err) {
1676
+ }
1677
+ function getRenderMode(body, mode) {
1678
+ switch (mode) {
1679
+ case "svg":
1680
+ case "bg":
1681
+ case "mask":
1682
+ return mode;
1683
+ }
1684
+ if (mode !== "style" && (isBuggedSafari || body.indexOf("<a") === -1)) {
1685
+ return "svg";
1686
+ }
1687
+ return body.indexOf("currentColor") === -1 ? "bg" : "mask";
1688
+ }
1689
+ const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
1690
+ const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
1691
+ function calculateSize$1(size, ratio, precision) {
1692
+ if (ratio === 1) {
1693
+ return size;
1694
+ }
1695
+ precision = precision || 100;
1696
+ if (typeof size === "number") {
1697
+ return Math.ceil(size * ratio * precision) / precision;
1698
+ }
1699
+ if (typeof size !== "string") {
1700
+ return size;
1701
+ }
1702
+ const oldParts = size.split(unitsSplit);
1703
+ if (oldParts === null || !oldParts.length) {
1704
+ return size;
1705
+ }
1706
+ const newParts = [];
1707
+ let code = oldParts.shift();
1708
+ let isNumber = unitsTest.test(code);
1709
+ while (true) {
1710
+ if (isNumber) {
1711
+ const num = parseFloat(code);
1712
+ if (isNaN(num)) {
1713
+ newParts.push(code);
1714
+ } else {
1715
+ newParts.push(Math.ceil(num * ratio * precision) / precision);
1716
+ }
1717
+ } else {
1718
+ newParts.push(code);
1719
+ }
1720
+ code = oldParts.shift();
1721
+ if (code === void 0) {
1722
+ return newParts.join("");
1723
+ }
1724
+ isNumber = !isNumber;
1725
+ }
1726
+ }
1727
+ function splitSVGDefs(content, tag = "defs") {
1728
+ let defs = "";
1729
+ const index = content.indexOf("<" + tag);
1730
+ while (index >= 0) {
1731
+ const start = content.indexOf(">", index);
1732
+ const end = content.indexOf("</" + tag);
1733
+ if (start === -1 || end === -1) {
1734
+ break;
1735
+ }
1736
+ const endEnd = content.indexOf(">", end);
1737
+ if (endEnd === -1) {
1738
+ break;
1739
+ }
1740
+ defs += content.slice(start + 1, end).trim();
1741
+ content = content.slice(0, index).trim() + content.slice(endEnd + 1);
1742
+ }
1743
+ return {
1744
+ defs,
1745
+ content
1746
+ };
1747
+ }
1748
+ function mergeDefsAndContent(defs, content) {
1749
+ return defs ? "<defs>" + defs + "</defs>" + content : content;
1750
+ }
1751
+ function wrapSVGContent(body, start, end) {
1752
+ const split = splitSVGDefs(body);
1753
+ return mergeDefsAndContent(split.defs, start + split.content + end);
1754
+ }
1755
+ const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
1756
+ function iconToSVG(icon, customisations) {
1757
+ const fullIcon = {
1758
+ ...defaultIconProps,
1759
+ ...icon
1760
+ };
1761
+ const fullCustomisations = {
1762
+ ...defaultIconCustomisations,
1763
+ ...customisations
1764
+ };
1765
+ const box = {
1766
+ left: fullIcon.left,
1767
+ top: fullIcon.top,
1768
+ width: fullIcon.width,
1769
+ height: fullIcon.height
1770
+ };
1771
+ let body = fullIcon.body;
1772
+ [fullIcon, fullCustomisations].forEach((props) => {
1773
+ const transformations = [];
1774
+ const hFlip = props.hFlip;
1775
+ const vFlip = props.vFlip;
1776
+ let rotation = props.rotate;
1777
+ if (hFlip) {
1778
+ if (vFlip) {
1779
+ rotation += 2;
1780
+ } else {
1781
+ transformations.push(
1782
+ "translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"
1783
+ );
1784
+ transformations.push("scale(-1 1)");
1785
+ box.top = box.left = 0;
1786
+ }
1787
+ } else if (vFlip) {
1788
+ transformations.push(
1789
+ "translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"
1790
+ );
1791
+ transformations.push("scale(1 -1)");
1792
+ box.top = box.left = 0;
1793
+ }
1794
+ let tempValue;
1795
+ if (rotation < 0) {
1796
+ rotation -= Math.floor(rotation / 4) * 4;
1797
+ }
1798
+ rotation = rotation % 4;
1799
+ switch (rotation) {
1800
+ case 1:
1801
+ tempValue = box.height / 2 + box.top;
1802
+ transformations.unshift(
1803
+ "rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"
1804
+ );
1805
+ break;
1806
+ case 2:
1807
+ transformations.unshift(
1808
+ "rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"
1809
+ );
1810
+ break;
1811
+ case 3:
1812
+ tempValue = box.width / 2 + box.left;
1813
+ transformations.unshift(
1814
+ "rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"
1815
+ );
1816
+ break;
1817
+ }
1818
+ if (rotation % 2 === 1) {
1819
+ if (box.left !== box.top) {
1820
+ tempValue = box.left;
1821
+ box.left = box.top;
1822
+ box.top = tempValue;
1823
+ }
1824
+ if (box.width !== box.height) {
1825
+ tempValue = box.width;
1826
+ box.width = box.height;
1827
+ box.height = tempValue;
1828
+ }
1829
+ }
1830
+ if (transformations.length) {
1831
+ body = wrapSVGContent(
1832
+ body,
1833
+ '<g transform="' + transformations.join(" ") + '">',
1834
+ "</g>"
1835
+ );
1836
+ }
1837
+ });
1838
+ const customisationsWidth = fullCustomisations.width;
1839
+ const customisationsHeight = fullCustomisations.height;
1840
+ const boxWidth = box.width;
1841
+ const boxHeight = box.height;
1842
+ let width;
1843
+ let height;
1844
+ if (customisationsWidth === null) {
1845
+ height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
1846
+ width = calculateSize$1(height, boxWidth / boxHeight);
1847
+ } else {
1848
+ width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
1849
+ height = customisationsHeight === null ? calculateSize$1(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
1850
+ }
1851
+ const attributes = {};
1852
+ const setAttr = (prop, value) => {
1853
+ if (!isUnsetKeyword(value)) {
1854
+ attributes[prop] = value.toString();
1855
+ }
1856
+ };
1857
+ setAttr("width", width);
1858
+ setAttr("height", height);
1859
+ const viewBox = [box.left, box.top, boxWidth, boxHeight];
1860
+ attributes.viewBox = viewBox.join(" ");
1861
+ return {
1862
+ attributes,
1863
+ viewBox,
1864
+ body
1865
+ };
1866
+ }
1867
+ function iconToHTML$1(body, attributes) {
1868
+ let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
1869
+ for (const attr in attributes) {
1870
+ renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
1871
+ }
1872
+ return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
1873
+ }
1874
+ function encodeSVGforURL(svg) {
1875
+ return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
1876
+ }
1877
+ function svgToData(svg) {
1878
+ return "data:image/svg+xml," + encodeSVGforURL(svg);
1879
+ }
1880
+ function svgToURL$1(svg) {
1881
+ return 'url("' + svgToData(svg) + '")';
1882
+ }
1883
+ const detectFetch = () => {
1884
+ let callback;
1885
+ try {
1886
+ callback = fetch;
1887
+ if (typeof callback === "function") {
1888
+ return callback;
1889
+ }
1890
+ } catch (err) {
1891
+ }
1892
+ };
1893
+ let fetchModule = detectFetch();
1894
+ function setFetch(fetch2) {
1895
+ fetchModule = fetch2;
1896
+ }
1897
+ function getFetch() {
1898
+ return fetchModule;
1899
+ }
1900
+ function calculateMaxLength(provider, prefix) {
1901
+ const config2 = getAPIConfig(provider);
1902
+ if (!config2) {
1903
+ return 0;
1904
+ }
1905
+ let result;
1906
+ if (!config2.maxURL) {
1907
+ result = 0;
1908
+ } else {
1909
+ let maxHostLength = 0;
1910
+ config2.resources.forEach((item) => {
1911
+ const host = item;
1912
+ maxHostLength = Math.max(maxHostLength, host.length);
1913
+ });
1914
+ const url = prefix + ".json?icons=";
1915
+ result = config2.maxURL - maxHostLength - config2.path.length - url.length;
1916
+ }
1917
+ return result;
1918
+ }
1919
+ function shouldAbort(status) {
1920
+ return status === 404;
1921
+ }
1922
+ const prepare = (provider, prefix, icons) => {
1923
+ const results = [];
1924
+ const maxLength = calculateMaxLength(provider, prefix);
1925
+ const type = "icons";
1926
+ let item = {
1927
+ type,
1928
+ provider,
1929
+ prefix,
1930
+ icons: []
1931
+ };
1932
+ let length = 0;
1933
+ icons.forEach((name, index) => {
1934
+ length += name.length + 1;
1935
+ if (length >= maxLength && index > 0) {
1936
+ results.push(item);
1937
+ item = {
1938
+ type,
1939
+ provider,
1940
+ prefix,
1941
+ icons: []
1942
+ };
1943
+ length = name.length;
1944
+ }
1945
+ item.icons.push(name);
1946
+ });
1947
+ results.push(item);
1948
+ return results;
1949
+ };
1950
+ function getPath(provider) {
1951
+ if (typeof provider === "string") {
1952
+ const config2 = getAPIConfig(provider);
1953
+ if (config2) {
1954
+ return config2.path;
1955
+ }
1956
+ }
1957
+ return "/";
1958
+ }
1959
+ const send = (host, params, callback) => {
1960
+ if (!fetchModule) {
1961
+ callback("abort", 424);
1962
+ return;
1963
+ }
1964
+ let path = getPath(params.provider);
1965
+ switch (params.type) {
1966
+ case "icons": {
1967
+ const prefix = params.prefix;
1968
+ const icons = params.icons;
1969
+ const iconsList = icons.join(",");
1970
+ const urlParams = new URLSearchParams({
1971
+ icons: iconsList
1972
+ });
1973
+ path += prefix + ".json?" + urlParams.toString();
1974
+ break;
1975
+ }
1976
+ case "custom": {
1977
+ const uri = params.uri;
1978
+ path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
1979
+ break;
1980
+ }
1981
+ default:
1982
+ callback("abort", 400);
1983
+ return;
1984
+ }
1985
+ let defaultError = 503;
1986
+ fetchModule(host + path).then((response) => {
1987
+ const status = response.status;
1988
+ if (status !== 200) {
1989
+ setTimeout(() => {
1990
+ callback(shouldAbort(status) ? "abort" : "next", status);
1991
+ });
1992
+ return;
1993
+ }
1994
+ defaultError = 501;
1995
+ return response.json();
1996
+ }).then((data) => {
1997
+ if (typeof data !== "object" || data === null) {
1998
+ setTimeout(() => {
1999
+ if (data === 404) {
2000
+ callback("abort", data);
2001
+ } else {
2002
+ callback("next", defaultError);
2003
+ }
2004
+ });
2005
+ return;
2006
+ }
2007
+ setTimeout(() => {
2008
+ callback("success", data);
2009
+ });
2010
+ }).catch(() => {
2011
+ callback("next", defaultError);
2012
+ });
2013
+ };
2014
+ const fetchAPIModule = {
2015
+ prepare,
2016
+ send
2017
+ };
2018
+ function toggleBrowserCache(storage2, value) {
2019
+ switch (storage2) {
2020
+ case "local":
2021
+ case "session":
2022
+ browserStorageConfig[storage2] = value;
2023
+ break;
2024
+ case "all":
2025
+ for (const key in browserStorageConfig) {
2026
+ browserStorageConfig[key] = value;
2027
+ }
2028
+ break;
2029
+ }
2030
+ }
2031
+ const nodeAttr = "data-style";
2032
+ let customStyle = "";
2033
+ function appendCustomStyle(style) {
2034
+ customStyle = style;
2035
+ }
2036
+ function updateStyle(parent, inline) {
2037
+ let styleNode = Array.from(parent.childNodes).find((node) => node.hasAttribute && node.hasAttribute(nodeAttr));
2038
+ if (!styleNode) {
2039
+ styleNode = document.createElement("style");
2040
+ styleNode.setAttribute(nodeAttr, nodeAttr);
2041
+ parent.appendChild(styleNode);
2042
+ }
2043
+ styleNode.textContent = ":host{display:inline-block;vertical-align:" + (inline ? "-0.125em" : "0") + "}span,svg{display:block}" + customStyle;
2044
+ }
2045
+ function exportFunctions() {
2046
+ setAPIModule("", fetchAPIModule);
2047
+ allowSimpleNames(true);
2048
+ let _window2;
2049
+ try {
2050
+ _window2 = window;
2051
+ } catch (err) {
2052
+ }
2053
+ if (_window2) {
2054
+ initBrowserStorage();
2055
+ if (_window2.IconifyPreload !== void 0) {
2056
+ const preload = _window2.IconifyPreload;
2057
+ const err = "Invalid IconifyPreload syntax.";
2058
+ if (typeof preload === "object" && preload !== null) {
2059
+ (preload instanceof Array ? preload : [preload]).forEach((item) => {
2060
+ try {
2061
+ if (
2062
+ // Check if item is an object and not null/array
2063
+ typeof item !== "object" || item === null || item instanceof Array || // Check for 'icons' and 'prefix'
2064
+ typeof item.icons !== "object" || typeof item.prefix !== "string" || // Add icon set
2065
+ !addCollection$1(item)
2066
+ ) {
2067
+ console.error(err);
2068
+ }
2069
+ } catch (e) {
2070
+ console.error(err);
2071
+ }
2072
+ });
2073
+ }
2074
+ }
2075
+ if (_window2.IconifyProviders !== void 0) {
2076
+ const providers = _window2.IconifyProviders;
2077
+ if (typeof providers === "object" && providers !== null) {
2078
+ for (const key in providers) {
2079
+ const err = "IconifyProviders[" + key + "] is invalid.";
2080
+ try {
2081
+ const value = providers[key];
2082
+ if (typeof value !== "object" || !value || value.resources === void 0) {
2083
+ continue;
2084
+ }
2085
+ if (!addAPIProvider$1(key, value)) {
2086
+ console.error(err);
2087
+ }
2088
+ } catch (e) {
2089
+ console.error(err);
2090
+ }
2091
+ }
2092
+ }
2093
+ }
2094
+ }
2095
+ const _api = {
2096
+ getAPIConfig,
2097
+ setAPIModule,
2098
+ sendAPIQuery,
2099
+ setFetch,
2100
+ getFetch,
2101
+ listAPIProviders
2102
+ };
2103
+ return {
2104
+ enableCache: (storage2) => toggleBrowserCache(storage2, true),
2105
+ disableCache: (storage2) => toggleBrowserCache(storage2, false),
2106
+ iconLoaded: iconLoaded$1,
2107
+ iconExists: iconLoaded$1,
2108
+ // deprecated, kept to avoid breaking changes
2109
+ getIcon: getIcon$1,
2110
+ listIcons: listIcons$1,
2111
+ addIcon: addIcon$1,
2112
+ addCollection: addCollection$1,
2113
+ calculateSize: calculateSize$1,
2114
+ buildIcon: iconToSVG,
2115
+ iconToHTML: iconToHTML$1,
2116
+ svgToURL: svgToURL$1,
2117
+ loadIcons: loadIcons$1,
2118
+ loadIcon: loadIcon$1,
2119
+ addAPIProvider: addAPIProvider$1,
2120
+ appendCustomStyle,
2121
+ _api
2122
+ };
2123
+ }
2124
+ const monotoneProps = {
2125
+ "background-color": "currentColor"
2126
+ };
2127
+ const coloredProps = {
2128
+ "background-color": "transparent"
2129
+ };
2130
+ const propsToAdd = {
2131
+ image: "var(--svg)",
2132
+ repeat: "no-repeat",
2133
+ size: "100% 100%"
2134
+ };
2135
+ const propsToAddTo = {
2136
+ "-webkit-mask": monotoneProps,
2137
+ "mask": monotoneProps,
2138
+ "background": coloredProps
2139
+ };
2140
+ for (const prefix in propsToAddTo) {
2141
+ const list = propsToAddTo[prefix];
2142
+ for (const prop in propsToAdd) {
2143
+ list[prefix + "-" + prop] = propsToAdd[prop];
2144
+ }
2145
+ }
2146
+ function fixSize(value) {
2147
+ return value ? value + (value.match(/^[-0-9.]+$/) ? "px" : "") : "inherit";
2148
+ }
2149
+ function renderSPAN(data, icon, useMask) {
2150
+ const node = document.createElement("span");
2151
+ let body = data.body;
2152
+ if (body.indexOf("<a") !== -1) {
2153
+ body += "<!-- " + Date.now() + " -->";
2154
+ }
2155
+ const renderAttribs = data.attributes;
2156
+ const html = iconToHTML$1(body, {
2157
+ ...renderAttribs,
2158
+ width: icon.width + "",
2159
+ height: icon.height + ""
2160
+ });
2161
+ const url = svgToURL$1(html);
2162
+ const svgStyle = node.style;
2163
+ const styles = {
2164
+ "--svg": url,
2165
+ "width": fixSize(renderAttribs.width),
2166
+ "height": fixSize(renderAttribs.height),
2167
+ ...useMask ? monotoneProps : coloredProps
2168
+ };
2169
+ for (const prop in styles) {
2170
+ svgStyle.setProperty(prop, styles[prop]);
2171
+ }
2172
+ return node;
2173
+ }
2174
+ let policy;
2175
+ function createPolicy() {
2176
+ try {
2177
+ policy = window.trustedTypes.createPolicy("iconify", {
2178
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
2179
+ createHTML: (s) => s
2180
+ });
2181
+ } catch (err) {
2182
+ policy = null;
2183
+ }
2184
+ }
2185
+ function cleanUpInnerHTML(html) {
2186
+ if (policy === void 0) {
2187
+ createPolicy();
2188
+ }
2189
+ return policy ? policy.createHTML(html) : html;
2190
+ }
2191
+ function renderSVG(data) {
2192
+ const node = document.createElement("span");
2193
+ const attr = data.attributes;
2194
+ let style = "";
2195
+ if (!attr.width) {
2196
+ style = "width: inherit;";
2197
+ }
2198
+ if (!attr.height) {
2199
+ style += "height: inherit;";
2200
+ }
2201
+ if (style) {
2202
+ attr.style = style;
2203
+ }
2204
+ const html = iconToHTML$1(data.body, attr);
2205
+ node.innerHTML = cleanUpInnerHTML(html);
2206
+ return node.firstChild;
2207
+ }
2208
+ function findIconElement(parent) {
2209
+ return Array.from(parent.childNodes).find((node) => {
2210
+ const tag = node.tagName && node.tagName.toUpperCase();
2211
+ return tag === "SPAN" || tag === "SVG";
2212
+ });
2213
+ }
2214
+ function renderIcon(parent, state) {
2215
+ const iconData = state.icon.data;
2216
+ const customisations = state.customisations;
2217
+ const renderData = iconToSVG(iconData, customisations);
2218
+ if (customisations.preserveAspectRatio) {
2219
+ renderData.attributes["preserveAspectRatio"] = customisations.preserveAspectRatio;
2220
+ }
2221
+ const mode = state.renderedMode;
2222
+ let node;
2223
+ switch (mode) {
2224
+ case "svg":
2225
+ node = renderSVG(renderData);
2226
+ break;
2227
+ default:
2228
+ node = renderSPAN(renderData, {
2229
+ ...defaultIconProps,
2230
+ ...iconData
2231
+ }, mode === "mask");
2232
+ }
2233
+ const oldNode = findIconElement(parent);
2234
+ if (oldNode) {
2235
+ if (node.tagName === "SPAN" && oldNode.tagName === node.tagName) {
2236
+ oldNode.setAttribute("style", node.getAttribute("style"));
2237
+ } else {
2238
+ parent.replaceChild(node, oldNode);
2239
+ }
2240
+ } else {
2241
+ parent.appendChild(node);
2242
+ }
2243
+ }
2244
+ function setPendingState(icon, inline, lastState) {
2245
+ const lastRender = lastState && (lastState.rendered ? lastState : lastState.lastRender);
2246
+ return {
2247
+ rendered: false,
2248
+ inline,
2249
+ icon,
2250
+ lastRender
2251
+ };
2252
+ }
2253
+ function defineIconifyIcon(name = "iconify-icon") {
2254
+ let customElements;
2255
+ let ParentClass;
2256
+ try {
2257
+ customElements = window.customElements;
2258
+ ParentClass = window.HTMLElement;
2259
+ } catch (err) {
2260
+ return;
2261
+ }
2262
+ if (!customElements || !ParentClass) {
2263
+ return;
2264
+ }
2265
+ const ConflictingClass = customElements.get(name);
2266
+ if (ConflictingClass) {
2267
+ return ConflictingClass;
2268
+ }
2269
+ const attributes = [
2270
+ // Icon
2271
+ "icon",
2272
+ // Mode
2273
+ "mode",
2274
+ "inline",
2275
+ "noobserver",
2276
+ // Customisations
2277
+ "width",
2278
+ "height",
2279
+ "rotate",
2280
+ "flip"
2281
+ ];
2282
+ const IconifyIcon = class extends ParentClass {
2283
+ /**
2284
+ * Constructor
2285
+ */
2286
+ constructor() {
2287
+ super();
2288
+ // Root
2289
+ __publicField(this, "_shadowRoot");
2290
+ // Initialised
2291
+ __publicField(this, "_initialised", false);
2292
+ // Icon state
2293
+ __publicField(this, "_state");
2294
+ // Attributes check queued
2295
+ __publicField(this, "_checkQueued", false);
2296
+ // Connected
2297
+ __publicField(this, "_connected", false);
2298
+ // Observer
2299
+ __publicField(this, "_observer", null);
2300
+ __publicField(this, "_visible", true);
2301
+ const root = this._shadowRoot = this.attachShadow({
2302
+ mode: "open"
2303
+ });
2304
+ const inline = this.hasAttribute("inline");
2305
+ updateStyle(root, inline);
2306
+ this._state = setPendingState({
2307
+ value: ""
2308
+ }, inline);
2309
+ this._queueCheck();
2310
+ }
2311
+ /**
2312
+ * Connected to DOM
2313
+ */
2314
+ connectedCallback() {
2315
+ this._connected = true;
2316
+ this.startObserver();
2317
+ }
2318
+ /**
2319
+ * Disconnected from DOM
2320
+ */
2321
+ disconnectedCallback() {
2322
+ this._connected = false;
2323
+ this.stopObserver();
2324
+ }
2325
+ /**
2326
+ * Observed attributes
2327
+ */
2328
+ static get observedAttributes() {
2329
+ return attributes.slice(0);
2330
+ }
2331
+ /**
2332
+ * Observed properties that are different from attributes
2333
+ *
2334
+ * Experimental! Need to test with various frameworks that support it
2335
+ */
2336
+ /*
2337
+ static get properties() {
2338
+ return {
2339
+ inline: {
2340
+ type: Boolean,
2341
+ reflect: true,
2342
+ },
2343
+ // Not listing other attributes because they are strings or combination
2344
+ // of string and another type. Cannot have multiple types
2345
+ };
2346
+ }
2347
+ */
2348
+ /**
2349
+ * Attribute has changed
2350
+ */
2351
+ attributeChangedCallback(name2) {
2352
+ switch (name2) {
2353
+ case "inline": {
2354
+ const newInline = this.hasAttribute("inline");
2355
+ const state = this._state;
2356
+ if (newInline !== state.inline) {
2357
+ state.inline = newInline;
2358
+ updateStyle(this._shadowRoot, newInline);
2359
+ }
2360
+ break;
2361
+ }
2362
+ case "noobserver": {
2363
+ const value = this.hasAttribute("noobserver");
2364
+ if (value) {
2365
+ this.startObserver();
2366
+ } else {
2367
+ this.stopObserver();
2368
+ }
2369
+ break;
2370
+ }
2371
+ default:
2372
+ this._queueCheck();
2373
+ }
2374
+ }
2375
+ /**
2376
+ * Get/set icon
2377
+ */
2378
+ get icon() {
2379
+ const value = this.getAttribute("icon");
2380
+ if (value && value.slice(0, 1) === "{") {
2381
+ try {
2382
+ return JSON.parse(value);
2383
+ } catch (err) {
2384
+ }
2385
+ }
2386
+ return value;
2387
+ }
2388
+ set icon(value) {
2389
+ if (typeof value === "object") {
2390
+ value = JSON.stringify(value);
2391
+ }
2392
+ this.setAttribute("icon", value);
2393
+ }
2394
+ /**
2395
+ * Get/set inline
2396
+ */
2397
+ get inline() {
2398
+ return this.hasAttribute("inline");
2399
+ }
2400
+ set inline(value) {
2401
+ if (value) {
2402
+ this.setAttribute("inline", "true");
2403
+ } else {
2404
+ this.removeAttribute("inline");
2405
+ }
2406
+ }
2407
+ /**
2408
+ * Get/set observer
2409
+ */
2410
+ get observer() {
2411
+ return this.hasAttribute("observer");
2412
+ }
2413
+ set observer(value) {
2414
+ if (value) {
2415
+ this.setAttribute("observer", "true");
2416
+ } else {
2417
+ this.removeAttribute("observer");
2418
+ }
2419
+ }
2420
+ /**
2421
+ * Restart animation
2422
+ */
2423
+ restartAnimation() {
2424
+ const state = this._state;
2425
+ if (state.rendered) {
2426
+ const root = this._shadowRoot;
2427
+ if (state.renderedMode === "svg") {
2428
+ try {
2429
+ root.lastChild.setCurrentTime(0);
2430
+ return;
2431
+ } catch (err) {
2432
+ }
2433
+ }
2434
+ renderIcon(root, state);
2435
+ }
2436
+ }
2437
+ /**
2438
+ * Get status
2439
+ */
2440
+ get status() {
2441
+ const state = this._state;
2442
+ return state.rendered ? "rendered" : state.icon.data === null ? "failed" : "loading";
2443
+ }
2444
+ /**
2445
+ * Queue attributes re-check
2446
+ */
2447
+ _queueCheck() {
2448
+ if (!this._checkQueued) {
2449
+ this._checkQueued = true;
2450
+ setTimeout(() => {
2451
+ this._check();
2452
+ });
2453
+ }
2454
+ }
2455
+ /**
2456
+ * Check for changes
2457
+ */
2458
+ _check() {
2459
+ if (!this._checkQueued) {
2460
+ return;
2461
+ }
2462
+ this._checkQueued = false;
2463
+ const state = this._state;
2464
+ const newIcon = this.getAttribute("icon");
2465
+ if (newIcon !== state.icon.value) {
2466
+ this._iconChanged(newIcon);
2467
+ return;
2468
+ }
2469
+ if (!state.rendered || !this._visible) {
2470
+ return;
2471
+ }
2472
+ const mode = this.getAttribute("mode");
2473
+ const customisations = getCustomisations(this);
2474
+ if (state.attrMode !== mode || haveCustomisationsChanged(state.customisations, customisations) || !findIconElement(this._shadowRoot)) {
2475
+ this._renderIcon(state.icon, customisations, mode);
2476
+ }
2477
+ }
2478
+ /**
2479
+ * Icon value has changed
2480
+ */
2481
+ _iconChanged(newValue) {
2482
+ const icon = parseIconValue(newValue, (value, name2, data) => {
2483
+ const state = this._state;
2484
+ if (state.rendered || this.getAttribute("icon") !== value) {
2485
+ return;
2486
+ }
2487
+ const icon2 = {
2488
+ value,
2489
+ name: name2,
2490
+ data
2491
+ };
2492
+ if (icon2.data) {
2493
+ this._gotIconData(icon2);
2494
+ } else {
2495
+ state.icon = icon2;
2496
+ }
2497
+ });
2498
+ if (icon.data) {
2499
+ this._gotIconData(icon);
2500
+ } else {
2501
+ this._state = setPendingState(icon, this._state.inline, this._state);
2502
+ }
2503
+ }
2504
+ /**
2505
+ * Force render icon on state change
2506
+ */
2507
+ _forceRender() {
2508
+ if (!this._visible) {
2509
+ const node = findIconElement(this._shadowRoot);
2510
+ if (node) {
2511
+ this._shadowRoot.removeChild(node);
2512
+ }
2513
+ return;
2514
+ }
2515
+ this._queueCheck();
2516
+ }
2517
+ /**
2518
+ * Got new icon data, icon is ready to (re)render
2519
+ */
2520
+ _gotIconData(icon) {
2521
+ this._checkQueued = false;
2522
+ this._renderIcon(icon, getCustomisations(this), this.getAttribute("mode"));
2523
+ }
2524
+ /**
2525
+ * Re-render based on icon data
2526
+ */
2527
+ _renderIcon(icon, customisations, attrMode) {
2528
+ const renderedMode = getRenderMode(icon.data.body, attrMode);
2529
+ const inline = this._state.inline;
2530
+ renderIcon(this._shadowRoot, this._state = {
2531
+ rendered: true,
2532
+ icon,
2533
+ inline,
2534
+ customisations,
2535
+ attrMode,
2536
+ renderedMode
2537
+ });
2538
+ }
2539
+ /**
2540
+ * Start observer
2541
+ */
2542
+ startObserver() {
2543
+ if (!this._observer && !this.hasAttribute("noobserver")) {
2544
+ try {
2545
+ this._observer = new IntersectionObserver((entries) => {
2546
+ const intersecting = entries.some((entry) => entry.isIntersecting);
2547
+ if (intersecting !== this._visible) {
2548
+ this._visible = intersecting;
2549
+ this._forceRender();
2550
+ }
2551
+ });
2552
+ this._observer.observe(this);
2553
+ } catch (err) {
2554
+ if (this._observer) {
2555
+ try {
2556
+ this._observer.disconnect();
2557
+ } catch (err2) {
2558
+ }
2559
+ this._observer = null;
2560
+ }
2561
+ }
2562
+ }
2563
+ }
2564
+ /**
2565
+ * Stop observer
2566
+ */
2567
+ stopObserver() {
2568
+ if (this._observer) {
2569
+ this._observer.disconnect();
2570
+ this._observer = null;
2571
+ this._visible = true;
2572
+ if (this._connected) {
2573
+ this._forceRender();
2574
+ }
2575
+ }
2576
+ }
2577
+ };
2578
+ attributes.forEach((attr) => {
2579
+ if (!(attr in IconifyIcon.prototype)) {
2580
+ Object.defineProperty(IconifyIcon.prototype, attr, {
2581
+ get: function() {
2582
+ return this.getAttribute(attr);
2583
+ },
2584
+ set: function(value) {
2585
+ if (value !== null) {
2586
+ this.setAttribute(attr, value);
2587
+ } else {
2588
+ this.removeAttribute(attr);
2589
+ }
2590
+ }
2591
+ });
2592
+ }
2593
+ });
2594
+ const functions = exportFunctions();
2595
+ for (const key in functions) {
2596
+ IconifyIcon[key] = IconifyIcon.prototype[key] = functions[key];
2597
+ }
2598
+ customElements.define(name, IconifyIcon);
2599
+ return IconifyIcon;
2600
+ }
2601
+ defineIconifyIcon() || exportFunctions();
2602
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2603
+ ...{
2604
+ name: "PIcon"
2605
+ },
2606
+ __name: "p-icon",
2607
+ props: {
2608
+ icon: {}
2609
+ },
2610
+ setup(__props) {
2611
+ const isPIcon = (icon) => !!P_ICON_ALIASES[icon];
2612
+ return (_ctx, _cache) => {
2613
+ return openBlock(), createElementBlock("iconify-icon", normalizeProps(guardReactiveProps({ ..._ctx.$props, icon: isPIcon(_ctx.icon) ? unref(P_ICON_ALIASES)[_ctx.icon] : _ctx.icon })), null, 16);
2614
+ };
2615
+ }
2616
+ });
440
2617
  const _hoisted_1$2 = ["data-has-error"];
441
2618
  const _hoisted_2$2 = { class: "text-p-purple-60" };
442
2619
  const _hoisted_3$2 = { class: "flex flex-row" };
@@ -1060,7 +3237,7 @@ export {
1060
3237
  LABEL_REQUIRED,
1061
3238
  LABEL_SIZES,
1062
3239
  MIN_WIDTH_COL_RESIZE,
1063
- _sfc_main$4 as PActionBar,
3240
+ _sfc_main$5 as PActionBar,
1064
3241
  default2 as PAlert,
1065
3242
  default3 as PAvatar,
1066
3243
  PBtn,
@@ -1074,6 +3251,7 @@ export {
1074
3251
  _2 as PDropdownSelect,
1075
3252
  pFileUpload as PFileUpload,
1076
3253
  default8 as PFilterIcon,
3254
+ _sfc_main$3 as PIcon,
1077
3255
  default9 as PInfoIcon,
1078
3256
  default10 as PInlineDatePicker,
1079
3257
  default11 as PInput,
@@ -1100,6 +3278,7 @@ export {
1100
3278
  _11 as PTabs,
1101
3279
  default19 as PTextarea,
1102
3280
  default20 as PToggle,
3281
+ P_ICON_ALIASES,
1103
3282
  SELECT_ARROW,
1104
3283
  SELECT_BASE,
1105
3284
  SELECT_SIZES,