@k-4u/resource-mapper-core 0.0.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.
Files changed (250) hide show
  1. package/.aws-icons-last-updated +1 -0
  2. package/.svelte-kit/ambient.d.ts +263 -0
  3. package/.svelte-kit/generated/client/app.js +31 -0
  4. package/.svelte-kit/generated/client/matchers.js +1 -0
  5. package/.svelte-kit/generated/client/nodes/0.js +1 -0
  6. package/.svelte-kit/generated/client/nodes/1.js +1 -0
  7. package/.svelte-kit/generated/client/nodes/2.js +3 -0
  8. package/.svelte-kit/generated/client/nodes/3.js +3 -0
  9. package/.svelte-kit/generated/client-optimized/app.js +31 -0
  10. package/.svelte-kit/generated/client-optimized/matchers.js +1 -0
  11. package/.svelte-kit/generated/client-optimized/nodes/0.js +1 -0
  12. package/.svelte-kit/generated/client-optimized/nodes/1.js +1 -0
  13. package/.svelte-kit/generated/client-optimized/nodes/2.js +3 -0
  14. package/.svelte-kit/generated/client-optimized/nodes/3.js +3 -0
  15. package/.svelte-kit/generated/root.js +3 -0
  16. package/.svelte-kit/generated/root.svelte +68 -0
  17. package/.svelte-kit/generated/server/internal.js +53 -0
  18. package/.svelte-kit/non-ambient.d.ts +43 -0
  19. package/.svelte-kit/output/client/.vite/manifest.json +175 -0
  20. package/.svelte-kit/output/client/_app/immutable/assets/0.Czt_67iE.css +1 -0
  21. package/.svelte-kit/output/client/_app/immutable/assets/TeamContactCard.Dxj5nUCr.css +1 -0
  22. package/.svelte-kit/output/client/_app/immutable/assets/helpers.ysDrpaDf.css +1 -0
  23. package/.svelte-kit/output/client/_app/immutable/assets/libavoid.DQJapW5w.wasm +0 -0
  24. package/.svelte-kit/output/client/_app/immutable/chunks/BlLuv0eP.js +46 -0
  25. package/.svelte-kit/output/client/_app/immutable/chunks/CSBHmwYv.js +1 -0
  26. package/.svelte-kit/output/client/_app/immutable/chunks/CTCi5ueQ.js +1 -0
  27. package/.svelte-kit/output/client/_app/immutable/chunks/CfOzjaik.js +2 -0
  28. package/.svelte-kit/output/client/_app/immutable/chunks/D4PdvFNs.js +1 -0
  29. package/.svelte-kit/output/client/_app/immutable/chunks/DXgP-QUS.js +2 -0
  30. package/.svelte-kit/output/client/_app/immutable/chunks/DlbDC5An.js +1 -0
  31. package/.svelte-kit/output/client/_app/immutable/chunks/wRWe7aK9.js +1 -0
  32. package/.svelte-kit/output/client/_app/immutable/entry/app.ConrMuHl.js +2 -0
  33. package/.svelte-kit/output/client/_app/immutable/entry/start.Bm6FyGme.js +1 -0
  34. package/.svelte-kit/output/client/_app/immutable/nodes/0.d3cL-ETU.js +1 -0
  35. package/.svelte-kit/output/client/_app/immutable/nodes/1.D6z9rPGv.js +1 -0
  36. package/.svelte-kit/output/client/_app/immutable/nodes/2.CLD-8chl.js +1 -0
  37. package/.svelte-kit/output/client/_app/immutable/nodes/3.DXYeBoel.js +1 -0
  38. package/.svelte-kit/output/client/_app/version.json +1 -0
  39. package/.svelte-kit/output/client/libavoid.wasm +0 -0
  40. package/.svelte-kit/output/client/static/robots.txt +3 -0
  41. package/.svelte-kit/output/prerendered/dependencies/_app/env.js +1 -0
  42. package/.svelte-kit/output/server/.vite/manifest.json +224 -0
  43. package/.svelte-kit/output/server/_app/immutable/assets/LoadingOverlay.DBbe6V8W.css +1 -0
  44. package/.svelte-kit/output/server/_app/immutable/assets/_layout.Czt_67iE.css +1 -0
  45. package/.svelte-kit/output/server/_app/immutable/assets/_page.D9P41uDZ.css +1 -0
  46. package/.svelte-kit/output/server/chunks/ErrorDisplay.js +59 -0
  47. package/.svelte-kit/output/server/chunks/LoadingOverlay.js +12 -0
  48. package/.svelte-kit/output/server/chunks/LoadingOverlay.svelte_svelte_type_style_lang.js +1671 -0
  49. package/.svelte-kit/output/server/chunks/connections.js +33 -0
  50. package/.svelte-kit/output/server/chunks/diagram.js +7 -0
  51. package/.svelte-kit/output/server/chunks/environment.js +34 -0
  52. package/.svelte-kit/output/server/chunks/equality.js +57 -0
  53. package/.svelte-kit/output/server/chunks/exports.js +174 -0
  54. package/.svelte-kit/output/server/chunks/false.js +4 -0
  55. package/.svelte-kit/output/server/chunks/index.js +59 -0
  56. package/.svelte-kit/output/server/chunks/index2.js +2939 -0
  57. package/.svelte-kit/output/server/chunks/index3.js +20 -0
  58. package/.svelte-kit/output/server/chunks/internal.js +1017 -0
  59. package/.svelte-kit/output/server/chunks/shared.js +770 -0
  60. package/.svelte-kit/output/server/chunks/utils.js +43 -0
  61. package/.svelte-kit/output/server/entries/pages/_error.svelte.js +64 -0
  62. package/.svelte-kit/output/server/entries/pages/_layout.svelte.js +65 -0
  63. package/.svelte-kit/output/server/entries/pages/_page.svelte.js +3991 -0
  64. package/.svelte-kit/output/server/entries/pages/_page.ts.js +30 -0
  65. package/.svelte-kit/output/server/entries/pages/group/_groupId_/_page.svelte.js +67 -0
  66. package/.svelte-kit/output/server/entries/pages/group/_groupId_/_page.ts.js +47 -0
  67. package/.svelte-kit/output/server/index.js +3747 -0
  68. package/.svelte-kit/output/server/internal.js +13 -0
  69. package/.svelte-kit/output/server/manifest-full.js +47 -0
  70. package/.svelte-kit/output/server/manifest.js +47 -0
  71. package/.svelte-kit/output/server/nodes/0.js +8 -0
  72. package/.svelte-kit/output/server/nodes/1.js +8 -0
  73. package/.svelte-kit/output/server/nodes/2.js +10 -0
  74. package/.svelte-kit/output/server/nodes/3.js +10 -0
  75. package/.svelte-kit/output/server/remote-entry.js +557 -0
  76. package/.svelte-kit/tsconfig.json +61 -0
  77. package/.svelte-kit/types/route_meta_data.json +8 -0
  78. package/.svelte-kit/types/src/routes/$types.d.ts +26 -0
  79. package/.svelte-kit/types/src/routes/group/[groupId]/$types.d.ts +21 -0
  80. package/.svelte-kit/types/src/routes/group/[groupId]/proxy+page.ts +49 -0
  81. package/.svelte-kit/types/src/routes/proxy+page.ts +33 -0
  82. package/build/_app/env.js +1 -0
  83. package/build/_app/env.js.br +1 -0
  84. package/build/_app/env.js.gz +0 -0
  85. package/build/_app/immutable/assets/0.Czt_67iE.css +1 -0
  86. package/build/_app/immutable/assets/0.Czt_67iE.css.br +0 -0
  87. package/build/_app/immutable/assets/0.Czt_67iE.css.gz +0 -0
  88. package/build/_app/immutable/assets/TeamContactCard.Dxj5nUCr.css +1 -0
  89. package/build/_app/immutable/assets/TeamContactCard.Dxj5nUCr.css.br +0 -0
  90. package/build/_app/immutable/assets/TeamContactCard.Dxj5nUCr.css.gz +0 -0
  91. package/build/_app/immutable/assets/helpers.ysDrpaDf.css +1 -0
  92. package/build/_app/immutable/assets/helpers.ysDrpaDf.css.br +0 -0
  93. package/build/_app/immutable/assets/helpers.ysDrpaDf.css.gz +0 -0
  94. package/build/_app/immutable/assets/libavoid.DQJapW5w.wasm +0 -0
  95. package/build/_app/immutable/assets/libavoid.DQJapW5w.wasm.br +0 -0
  96. package/build/_app/immutable/assets/libavoid.DQJapW5w.wasm.gz +0 -0
  97. package/build/_app/immutable/chunks/BlLuv0eP.js +46 -0
  98. package/build/_app/immutable/chunks/BlLuv0eP.js.br +0 -0
  99. package/build/_app/immutable/chunks/BlLuv0eP.js.gz +0 -0
  100. package/build/_app/immutable/chunks/CSBHmwYv.js +1 -0
  101. package/build/_app/immutable/chunks/CSBHmwYv.js.br +0 -0
  102. package/build/_app/immutable/chunks/CSBHmwYv.js.gz +0 -0
  103. package/build/_app/immutable/chunks/CTCi5ueQ.js +1 -0
  104. package/build/_app/immutable/chunks/CTCi5ueQ.js.br +0 -0
  105. package/build/_app/immutable/chunks/CTCi5ueQ.js.gz +0 -0
  106. package/build/_app/immutable/chunks/CfOzjaik.js +2 -0
  107. package/build/_app/immutable/chunks/CfOzjaik.js.br +0 -0
  108. package/build/_app/immutable/chunks/CfOzjaik.js.gz +0 -0
  109. package/build/_app/immutable/chunks/D4PdvFNs.js +1 -0
  110. package/build/_app/immutable/chunks/D4PdvFNs.js.br +0 -0
  111. package/build/_app/immutable/chunks/D4PdvFNs.js.gz +0 -0
  112. package/build/_app/immutable/chunks/DXgP-QUS.js +2 -0
  113. package/build/_app/immutable/chunks/DXgP-QUS.js.br +0 -0
  114. package/build/_app/immutable/chunks/DXgP-QUS.js.gz +0 -0
  115. package/build/_app/immutable/chunks/DlbDC5An.js +1 -0
  116. package/build/_app/immutable/chunks/DlbDC5An.js.br +0 -0
  117. package/build/_app/immutable/chunks/DlbDC5An.js.gz +0 -0
  118. package/build/_app/immutable/chunks/wRWe7aK9.js +1 -0
  119. package/build/_app/immutable/chunks/wRWe7aK9.js.br +0 -0
  120. package/build/_app/immutable/chunks/wRWe7aK9.js.gz +0 -0
  121. package/build/_app/immutable/entry/app.ConrMuHl.js +2 -0
  122. package/build/_app/immutable/entry/app.ConrMuHl.js.br +0 -0
  123. package/build/_app/immutable/entry/app.ConrMuHl.js.gz +0 -0
  124. package/build/_app/immutable/entry/start.Bm6FyGme.js +1 -0
  125. package/build/_app/immutable/entry/start.Bm6FyGme.js.br +2 -0
  126. package/build/_app/immutable/entry/start.Bm6FyGme.js.gz +0 -0
  127. package/build/_app/immutable/nodes/0.d3cL-ETU.js +1 -0
  128. package/build/_app/immutable/nodes/0.d3cL-ETU.js.br +0 -0
  129. package/build/_app/immutable/nodes/0.d3cL-ETU.js.gz +0 -0
  130. package/build/_app/immutable/nodes/1.D6z9rPGv.js +1 -0
  131. package/build/_app/immutable/nodes/1.D6z9rPGv.js.br +0 -0
  132. package/build/_app/immutable/nodes/1.D6z9rPGv.js.gz +0 -0
  133. package/build/_app/immutable/nodes/2.CLD-8chl.js +1 -0
  134. package/build/_app/immutable/nodes/2.CLD-8chl.js.br +0 -0
  135. package/build/_app/immutable/nodes/2.CLD-8chl.js.gz +0 -0
  136. package/build/_app/immutable/nodes/3.DXYeBoel.js +1 -0
  137. package/build/_app/immutable/nodes/3.DXYeBoel.js.br +0 -0
  138. package/build/_app/immutable/nodes/3.DXYeBoel.js.gz +0 -0
  139. package/build/_app/version.json +1 -0
  140. package/build/_app/version.json.br +0 -0
  141. package/build/_app/version.json.gz +0 -0
  142. package/build/index.html +34 -0
  143. package/build/index.html.br +0 -0
  144. package/build/index.html.gz +0 -0
  145. package/build/libavoid.wasm +0 -0
  146. package/build/libavoid.wasm.br +0 -0
  147. package/build/libavoid.wasm.gz +0 -0
  148. package/build/static/robots.txt +3 -0
  149. package/coverage/coverage-final.json +6 -0
  150. package/coverage/coverage-summary.json +7 -0
  151. package/coverage/junit.xml +57 -0
  152. package/coverage/lcov-report/base.css +224 -0
  153. package/coverage/lcov-report/block-navigation.js +87 -0
  154. package/coverage/lcov-report/favicon.png +0 -0
  155. package/coverage/lcov-report/index.html +131 -0
  156. package/coverage/lcov-report/prettify.css +1 -0
  157. package/coverage/lcov-report/prettify.js +2 -0
  158. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  159. package/coverage/lcov-report/sorter.js +210 -0
  160. package/coverage/lcov-report/stores/index.html +116 -0
  161. package/coverage/lcov-report/stores/routingStore.ts.html +781 -0
  162. package/coverage/lcov-report/utils/flow/helpers.ts.html +127 -0
  163. package/coverage/lcov-report/utils/flow/index.html +161 -0
  164. package/coverage/lcov-report/utils/flow/layout.ts.html +805 -0
  165. package/coverage/lcov-report/utils/flow/serviceIds.ts.html +97 -0
  166. package/coverage/lcov-report/utils/flow/servicesGraph.ts.html +859 -0
  167. package/coverage/lcov.info +646 -0
  168. package/coverage/test-results.json +1 -0
  169. package/data/services/api/api-gateway.yaml +18 -0
  170. package/data/services/api/group-info.yaml +7 -0
  171. package/data/services/api/lambda-orders.yaml +21 -0
  172. package/data/services/api/lambda-products.yaml +15 -0
  173. package/data/services/api/lambda-users.yaml +15 -0
  174. package/data/services/compute/alb.yaml +15 -0
  175. package/data/services/compute/ecs-inventory.yaml +16 -0
  176. package/data/services/compute/ecs-notification.yaml +15 -0
  177. package/data/services/compute/group-info.yaml +7 -0
  178. package/data/services/data/dynamodb-notifications.yaml +12 -0
  179. package/data/services/data/dynamodb-orders.yaml +9 -0
  180. package/data/services/data/dynamodb-products.yaml +9 -0
  181. package/data/services/data/dynamodb-users.yaml +9 -0
  182. package/data/services/data/group-info.yaml +7 -0
  183. package/data/services/data/rds-postgres.yaml +9 -0
  184. package/data/services/data/redis.yaml +10 -0
  185. package/data/services/frontend/cloudfront.yaml +12 -0
  186. package/data/services/frontend/group-info.yaml +7 -0
  187. package/data/services/frontend/route53.yaml +15 -0
  188. package/data/services/frontend/s3-website.yaml +9 -0
  189. package/data/teams/cloud-shepherds.yaml +15 -0
  190. package/data/teams/data-wizards.yaml +15 -0
  191. package/data/teams/interface-architects.yaml +19 -0
  192. package/e2e/demo.test.ts +54 -0
  193. package/e2e/header-toolbar.simple.spec.ts +0 -0
  194. package/e2e/header-toolbar.spec.ts +53 -0
  195. package/e2e/layout.spec.ts +30 -0
  196. package/package.json +69 -0
  197. package/playwright.config.ts +10 -0
  198. package/plugins/mapper-data-plugin.ts +32 -0
  199. package/project.json +23 -0
  200. package/src/app.css +125 -0
  201. package/src/app.d.ts +31 -0
  202. package/src/app.html +11 -0
  203. package/src/lib/assets/favicon.svg +19 -0
  204. package/src/lib/components/EmptyState.svelte +37 -0
  205. package/src/lib/components/ErrorDisplay.svelte +82 -0
  206. package/src/lib/components/FlowCanvas.svelte +223 -0
  207. package/src/lib/components/GenericSidebarCard.svelte +44 -0
  208. package/src/lib/components/GroupDetailSidebar.svelte +31 -0
  209. package/src/lib/components/Header.svelte +57 -0
  210. package/src/lib/components/Legend.svelte +25 -0
  211. package/src/lib/components/LoadingOverlay.svelte +42 -0
  212. package/src/lib/components/LoadingSpinner.svelte +10 -0
  213. package/src/lib/components/ServiceDetailSidebar.svelte +90 -0
  214. package/src/lib/components/TeamContactCard.svelte +166 -0
  215. package/src/lib/components/flow/ExternalNode.svelte +45 -0
  216. package/src/lib/components/flow/MainGroupNode.svelte +24 -0
  217. package/src/lib/components/flow/ServiceGroupNode.svelte +17 -0
  218. package/src/lib/components/flow/ServiceNode.svelte +40 -0
  219. package/src/lib/components/flow/SnakeEdge.svelte +206 -0
  220. package/src/lib/components/flow/index.ts +6 -0
  221. package/src/lib/components/index.ts +12 -0
  222. package/src/lib/data/connections.ts +26 -0
  223. package/src/lib/data/groups.ts +11 -0
  224. package/src/lib/data/services.ts +12 -0
  225. package/src/lib/data/teams.ts +11 -0
  226. package/src/lib/index.ts +1 -0
  227. package/src/lib/state/theme.svelte.ts +21 -0
  228. package/src/lib/stores/diagram.ts +6 -0
  229. package/src/lib/stores/routingStore.test.ts +133 -0
  230. package/src/lib/stores/routingStore.ts +232 -0
  231. package/src/lib/utils/awsIcons.ts +117 -0
  232. package/src/lib/utils/flow/groupOverviewGraph.ts +73 -0
  233. package/src/lib/utils/flow/helpers.ts +14 -0
  234. package/src/lib/utils/flow/layout.test.ts +271 -0
  235. package/src/lib/utils/flow/layout.ts +240 -0
  236. package/src/lib/utils/flow/serviceIds.ts +5 -0
  237. package/src/lib/utils/flow/servicesGraph.test.ts +119 -0
  238. package/src/lib/utils/flow/servicesGraph.ts +258 -0
  239. package/src/routes/+error.svelte +36 -0
  240. package/src/routes/+layout.svelte +27 -0
  241. package/src/routes/+page.svelte +81 -0
  242. package/src/routes/+page.ts +31 -0
  243. package/src/routes/group/[groupId]/+page.svelte +102 -0
  244. package/src/routes/group/[groupId]/+page.ts +48 -0
  245. package/src/routes/layout.css +0 -0
  246. package/static/static/robots.txt +3 -0
  247. package/svelte.config.js +28 -0
  248. package/tailwind.config.js +12 -0
  249. package/tsconfig.json +22 -0
  250. package/vite.config.ts +81 -0
@@ -0,0 +1,1671 @@
1
+ import "clsx";
2
+ import { n as noop } from "./equality.js";
3
+ import "@sveltejs/kit/internal/server";
4
+ import "@sveltejs/kit/internal";
5
+ import "./exports.js";
6
+ import "./utils.js";
7
+ import { w as writable } from "./index.js";
8
+ import { AvoidLib } from "libavoid-js";
9
+ import ELK from "elkjs/lib/elk.bundled.js";
10
+ import { af as ssr_context, a5 as attributes } from "./index2.js";
11
+ function html(value) {
12
+ var html2 = String(value ?? "");
13
+ var open = "<!---->";
14
+ return open + html2 + "<!---->";
15
+ }
16
+ function onDestroy(fn) {
17
+ /** @type {SSRContext} */
18
+ ssr_context.r.on_destroy(fn);
19
+ }
20
+ function create_updated_store() {
21
+ const { set, subscribe } = writable(false);
22
+ {
23
+ return {
24
+ subscribe,
25
+ // eslint-disable-next-line @typescript-eslint/require-await
26
+ check: async () => false
27
+ };
28
+ }
29
+ }
30
+ const is_legacy = noop.toString().includes("$$") || /function \w+\(\) \{\}/.test(noop.toString());
31
+ if (is_legacy) {
32
+ ({
33
+ data: {},
34
+ form: null,
35
+ error: null,
36
+ params: {},
37
+ route: { id: null },
38
+ state: {},
39
+ status: -1,
40
+ url: new URL("https://example.com")
41
+ });
42
+ }
43
+ const stores = {
44
+ updated: /* @__PURE__ */ create_updated_store()
45
+ };
46
+ function goto(url, opts = {}) {
47
+ {
48
+ throw new Error("Cannot call goto(...) on the server");
49
+ }
50
+ }
51
+ function invalidateAll() {
52
+ {
53
+ throw new Error("Cannot call invalidateAll() on the server");
54
+ }
55
+ }
56
+ new ELK();
57
+ const OFFSET_STEP = 20;
58
+ function getAbsolutePosition(nodeId, nodes) {
59
+ const node = nodes.find((n) => n.id === nodeId);
60
+ if (!node) return { x: 0, y: 0 };
61
+ let x = node.position?.x ?? 0;
62
+ let y = node.position?.y ?? 0;
63
+ if (node.parentId) {
64
+ const parentPos = getAbsolutePosition(node.parentId, nodes);
65
+ x += parentPos.x;
66
+ y += parentPos.y;
67
+ }
68
+ return { x, y };
69
+ }
70
+ function calculateEdgeOffset(edgeId, nodes, edges, isSource) {
71
+ const edge = edges.find((e) => e.id === edgeId);
72
+ if (!edge) return 0;
73
+ const nodeId = isSource ? edge.source : edge.target;
74
+ const handleId = isSource ? edge.sourceHandle : edge.targetHandle;
75
+ const handle = isSource ? edge.sourceHandle : edge.targetHandle;
76
+ const isVertical = handle?.toLowerCase().includes("top") || handle?.toLowerCase().includes("bottom");
77
+ let finalSiblings = [];
78
+ let usedAreaFallback = false;
79
+ const siblings = edges.filter(
80
+ (e) => (isSource ? e.source : e.target) === nodeId && (isSource ? e.sourceHandle : e.targetHandle) === handleId
81
+ );
82
+ if (siblings.length <= 1) {
83
+ usedAreaFallback = true;
84
+ const otherId = isSource ? edge.target : edge.source;
85
+ finalSiblings = edges.filter((e) => {
86
+ const isSamePair = e.source === nodeId && e.target === otherId || e.source === otherId && e.target === nodeId;
87
+ return isSamePair && (e.source === nodeId || e.target === nodeId);
88
+ });
89
+ } else {
90
+ finalSiblings = siblings;
91
+ }
92
+ if (finalSiblings.length <= 1) return 0;
93
+ finalSiblings.sort((a, b) => {
94
+ if (usedAreaFallback) {
95
+ const aSPos = getAbsolutePosition(a.source, nodes);
96
+ const aTPos = getAbsolutePosition(a.target, nodes);
97
+ const bSPos = getAbsolutePosition(b.source, nodes);
98
+ const bTPos = getAbsolutePosition(b.target, nodes);
99
+ if (isVertical) {
100
+ const midA = (aSPos.x + aTPos.x) / 2;
101
+ const midB = (bSPos.x + bTPos.x) / 2;
102
+ if (midA !== midB) return midA - midB;
103
+ } else {
104
+ const midA = (aSPos.y + aTPos.y) / 2;
105
+ const midB = (bSPos.y + bTPos.y) / 2;
106
+ if (midA !== midB) return midA - midB;
107
+ }
108
+ return a.id.localeCompare(b.id);
109
+ }
110
+ const otherIdA = isSource ? a.target : a.source;
111
+ const otherIdB = isSource ? b.target : b.source;
112
+ const posA = getAbsolutePosition(otherIdA, nodes);
113
+ const posB = getAbsolutePosition(otherIdB, nodes);
114
+ const primary = isVertical ? posA.x - posB.x : posA.y - posB.y;
115
+ if (primary !== 0) return primary;
116
+ return a.id.localeCompare(b.id);
117
+ });
118
+ const index = finalSiblings.findIndex((e) => e.id === edgeId);
119
+ return (index - (finalSiblings.length - 1) / 2) * OFFSET_STEP;
120
+ }
121
+ ({
122
+ check: stores.updated.check
123
+ });
124
+ let avoidLibPromise = null;
125
+ let avoidLibInstance = null;
126
+ async function ensureAvoidLibLoaded() {
127
+ if (avoidLibPromise) return avoidLibPromise;
128
+ avoidLibPromise = AvoidLib.load("/libavoid.wasm");
129
+ return avoidLibPromise;
130
+ }
131
+ async function getAvoidLib() {
132
+ await ensureAvoidLibLoaded();
133
+ avoidLibInstance ??= AvoidLib.getInstance();
134
+ return avoidLibInstance;
135
+ }
136
+ const getDirFlag = (pos) => {
137
+ const p = pos.toLowerCase();
138
+ if (p === "right") return 8;
139
+ if (p === "left") return 4;
140
+ if (p === "top") return 1;
141
+ if (p === "bottom") return 2;
142
+ return 15;
143
+ };
144
+ const getShoulderPoint = (avoid, x, y, pos, dist) => {
145
+ switch (pos.toLowerCase()) {
146
+ case "right":
147
+ return new avoid.Point(x + dist, y);
148
+ case "left":
149
+ return new avoid.Point(x - dist, y);
150
+ case "top":
151
+ return new avoid.Point(x, y - dist);
152
+ case "bottom":
153
+ return new avoid.Point(x, y + dist);
154
+ default:
155
+ return new avoid.Point(x, y);
156
+ }
157
+ };
158
+ function createRoutingStore() {
159
+ const { subscribe, set } = writable({});
160
+ let router = null;
161
+ let avoid = null;
162
+ const nodes = /* @__PURE__ */ new Map();
163
+ const nodesMetadata = /* @__PURE__ */ new Map();
164
+ const edges = /* @__PURE__ */ new Map();
165
+ let pendingTransaction = false;
166
+ async function init() {
167
+ if (router) return;
168
+ avoid = await getAvoidLib();
169
+ router = new avoid.Router(avoid.RouterFlag.OrthogonalRouting.value);
170
+ router.setRoutingParameter(avoid.RoutingParameter.reverseDirectionPenalty.valueOf(), 1e3);
171
+ router.setRoutingParameter(avoid.RoutingParameter.portDirectionPenalty.valueOf(), 500);
172
+ router.setRoutingParameter(avoid.RoutingParameter.idealNudgingDistance.valueOf(), OFFSET_STEP);
173
+ router.setRoutingParameter(avoid.RoutingParameter.segmentPenalty.valueOf(), 50);
174
+ router.setRoutingOption(avoid.RoutingOption.nudgeOrthogonalSegmentsConnectedToShapes.valueOf(), true);
175
+ router.setRoutingOption(avoid.RoutingOption.nudgeOrthogonalTouchingColinearSegments.valueOf(), true);
176
+ }
177
+ function processTransaction() {
178
+ if (!router || pendingTransaction) return;
179
+ pendingTransaction = true;
180
+ setTimeout(() => {
181
+ if (!router) {
182
+ pendingTransaction = false;
183
+ return;
184
+ }
185
+ router.processTransaction();
186
+ const results = {};
187
+ edges.forEach((conn, id) => {
188
+ const route = conn.displayRoute();
189
+ const pts = [];
190
+ for (let i = 0; i < route.size(); i++) {
191
+ const p = route.at(i);
192
+ pts.push({ x: p.x, y: p.y });
193
+ }
194
+ results[id] = pts;
195
+ });
196
+ set(results);
197
+ pendingTransaction = false;
198
+ }, 16);
199
+ }
200
+ return {
201
+ subscribe,
202
+ registerNode: async (data) => {
203
+ await init();
204
+ if (!router || !avoid) return;
205
+ if (data.isGroup) {
206
+ if (nodes.has(data.nodeId)) {
207
+ const shape = nodes.get(data.nodeId);
208
+ router.deleteShape(shape);
209
+ nodes.delete(data.nodeId);
210
+ nodesMetadata.delete(data.nodeId);
211
+ }
212
+ return;
213
+ }
214
+ nodesMetadata.set(data.nodeId, data.absPos);
215
+ const poly = new avoid.Polygon(4);
216
+ poly.setPoint(0, new avoid.Point(data.absPos.x, data.absPos.y));
217
+ poly.setPoint(1, new avoid.Point(data.absPos.x + data.width, data.absPos.y));
218
+ poly.setPoint(2, new avoid.Point(data.absPos.x + data.width, data.absPos.y + data.height));
219
+ poly.setPoint(3, new avoid.Point(data.absPos.x, data.absPos.y + data.height));
220
+ if (nodes.has(data.nodeId)) {
221
+ const shape = nodes.get(data.nodeId);
222
+ router.moveShape_poly(shape, poly, false);
223
+ } else {
224
+ const shape = new avoid.ShapeRef(router, poly);
225
+ nodes.set(data.nodeId, shape);
226
+ }
227
+ processTransaction();
228
+ },
229
+ registerEdge: async (data) => {
230
+ await init();
231
+ if (!router || !avoid) return;
232
+ const sShape = nodes.get(data.sourceNodeId);
233
+ const tShape = nodes.get(data.targetNodeId);
234
+ if (!sShape || !tShape) return;
235
+ const createConnEnd = (nodeId, x, y, side, shape) => {
236
+ if (!avoid) throw new Error("Avoid not loaded");
237
+ const pinClass = Array.from(data.edgeId).reduce((a, b) => a + (b.codePointAt(0) ?? 0), 0);
238
+ const abs = nodesMetadata.get(nodeId);
239
+ const xOff = x - (abs?.x ?? 0);
240
+ const yOff = y - (abs?.y ?? 0);
241
+ const pin = new avoid.ShapeConnectionPin(shape, pinClass, xOff, yOff, false, -40, getDirFlag(side));
242
+ pin.setExclusive(true);
243
+ return new avoid.ConnEnd(shape, pinClass);
244
+ };
245
+ const srcEnd = createConnEnd(data.sourceNodeId, data.sourcePos.x, data.sourcePos.y, data.sourceSide, sShape);
246
+ const dstEnd = createConnEnd(data.targetNodeId, data.targetPos.x, data.targetPos.y, data.targetSide, tShape);
247
+ let conn;
248
+ if (edges.has(data.edgeId)) {
249
+ conn = edges.get(data.edgeId);
250
+ conn.setSourceEndpoint(srcEnd);
251
+ conn.setDestEndpoint(dstEnd);
252
+ } else {
253
+ conn = new avoid.ConnRef(router, srcEnd, dstEnd);
254
+ edges.set(data.edgeId, conn);
255
+ }
256
+ const checkpoints = new avoid.CheckpointVector();
257
+ checkpoints.push_back(new avoid.Checkpoint(getShoulderPoint(avoid, data.sourcePos.x, data.sourcePos.y, data.sourceSide, 10)));
258
+ checkpoints.push_back(new avoid.Checkpoint(getShoulderPoint(avoid, data.targetPos.x, data.targetPos.y, data.targetSide, 10)));
259
+ conn.setRoutingCheckpoints(checkpoints);
260
+ processTransaction();
261
+ },
262
+ unregisterEdge: (id) => {
263
+ if (!router || !edges.has(id)) return;
264
+ const conn = edges.get(id);
265
+ router.deleteConnector(conn);
266
+ edges.delete(id);
267
+ set(Object.fromEntries(
268
+ Array.from(edges.entries()).map(([id2, conn2]) => {
269
+ const route = conn2.displayRoute();
270
+ const pts = [];
271
+ for (let i = 0; i < route.size(); i++) {
272
+ const p = route.at(i);
273
+ pts.push({ x: p.x, y: p.y });
274
+ }
275
+ return [id2, pts];
276
+ })
277
+ ));
278
+ processTransaction();
279
+ }
280
+ };
281
+ }
282
+ const routingStore = createRoutingStore();
283
+ const matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
284
+ const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
285
+ const colonSeparated = value.split(":");
286
+ if (value.slice(0, 1) === "@") {
287
+ if (colonSeparated.length < 2 || colonSeparated.length > 3) return null;
288
+ provider = colonSeparated.shift().slice(1);
289
+ }
290
+ if (colonSeparated.length > 3 || !colonSeparated.length) return null;
291
+ if (colonSeparated.length > 1) {
292
+ const name$1 = colonSeparated.pop();
293
+ const prefix = colonSeparated.pop();
294
+ const result = {
295
+ provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
296
+ prefix,
297
+ name: name$1
298
+ };
299
+ return validate && !validateIconName(result) ? null : result;
300
+ }
301
+ const name = colonSeparated[0];
302
+ const dashSeparated = name.split("-");
303
+ if (dashSeparated.length > 1) {
304
+ const result = {
305
+ provider,
306
+ prefix: dashSeparated.shift(),
307
+ name: dashSeparated.join("-")
308
+ };
309
+ return validate && !validateIconName(result) ? null : result;
310
+ }
311
+ if (allowSimpleName && provider === "") {
312
+ const result = {
313
+ provider,
314
+ prefix: "",
315
+ name
316
+ };
317
+ return validate && !validateIconName(result, allowSimpleName) ? null : result;
318
+ }
319
+ return null;
320
+ };
321
+ const validateIconName = (icon, allowSimpleName) => {
322
+ if (!icon) return false;
323
+ return !!((allowSimpleName && icon.prefix === "" || !!icon.prefix) && !!icon.name);
324
+ };
325
+ function getIconsTree(data, names) {
326
+ const icons = data.icons;
327
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
328
+ const resolved = /* @__PURE__ */ Object.create(null);
329
+ function resolve(name) {
330
+ if (icons[name]) return resolved[name] = [];
331
+ if (!(name in resolved)) {
332
+ resolved[name] = null;
333
+ const parent = aliases[name] && aliases[name].parent;
334
+ const value = parent && resolve(parent);
335
+ if (value) resolved[name] = [parent].concat(value);
336
+ }
337
+ return resolved[name];
338
+ }
339
+ Object.keys(icons).concat(Object.keys(aliases)).forEach(resolve);
340
+ return resolved;
341
+ }
342
+ const defaultIconDimensions = Object.freeze({
343
+ left: 0,
344
+ top: 0,
345
+ width: 16,
346
+ height: 16
347
+ });
348
+ const defaultIconTransformations = Object.freeze({
349
+ rotate: 0,
350
+ vFlip: false,
351
+ hFlip: false
352
+ });
353
+ const defaultIconProps = Object.freeze({
354
+ ...defaultIconDimensions,
355
+ ...defaultIconTransformations
356
+ });
357
+ const defaultExtendedIconProps = Object.freeze({
358
+ ...defaultIconProps,
359
+ body: "",
360
+ hidden: false
361
+ });
362
+ function mergeIconTransformations(obj1, obj2) {
363
+ const result = {};
364
+ if (!obj1.hFlip !== !obj2.hFlip) result.hFlip = true;
365
+ if (!obj1.vFlip !== !obj2.vFlip) result.vFlip = true;
366
+ const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
367
+ if (rotate) result.rotate = rotate;
368
+ return result;
369
+ }
370
+ function mergeIconData(parent, child) {
371
+ const result = mergeIconTransformations(parent, child);
372
+ for (const key in defaultExtendedIconProps) if (key in defaultIconTransformations) {
373
+ if (key in parent && !(key in result)) result[key] = defaultIconTransformations[key];
374
+ } else if (key in child) result[key] = child[key];
375
+ else if (key in parent) result[key] = parent[key];
376
+ return result;
377
+ }
378
+ function internalGetIconData(data, name, tree) {
379
+ const icons = data.icons;
380
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
381
+ let currentProps = {};
382
+ function parse(name$1) {
383
+ currentProps = mergeIconData(icons[name$1] || aliases[name$1], currentProps);
384
+ }
385
+ parse(name);
386
+ tree.forEach(parse);
387
+ return mergeIconData(data, currentProps);
388
+ }
389
+ function parseIconSet(data, callback) {
390
+ const names = [];
391
+ if (typeof data !== "object" || typeof data.icons !== "object") return names;
392
+ if (data.not_found instanceof Array) data.not_found.forEach((name) => {
393
+ callback(name, null);
394
+ names.push(name);
395
+ });
396
+ const tree = getIconsTree(data);
397
+ for (const name in tree) {
398
+ const item = tree[name];
399
+ if (item) {
400
+ callback(name, internalGetIconData(data, name, item));
401
+ names.push(name);
402
+ }
403
+ }
404
+ return names;
405
+ }
406
+ const optionalPropertyDefaults = {
407
+ provider: "",
408
+ aliases: {},
409
+ not_found: {},
410
+ ...defaultIconDimensions
411
+ };
412
+ function checkOptionalProps(item, defaults) {
413
+ for (const prop in defaults) if (prop in item && typeof item[prop] !== typeof defaults[prop]) return false;
414
+ return true;
415
+ }
416
+ function quicklyValidateIconSet(obj) {
417
+ if (typeof obj !== "object" || obj === null) return null;
418
+ const data = obj;
419
+ if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") return null;
420
+ if (!checkOptionalProps(obj, optionalPropertyDefaults)) return null;
421
+ const icons = data.icons;
422
+ for (const name in icons) {
423
+ const icon = icons[name];
424
+ if (!name || typeof icon.body !== "string" || !checkOptionalProps(icon, defaultExtendedIconProps)) return null;
425
+ }
426
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
427
+ for (const name in aliases) {
428
+ const icon = aliases[name];
429
+ const parent = icon.parent;
430
+ if (!name || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(icon, defaultExtendedIconProps)) return null;
431
+ }
432
+ return data;
433
+ }
434
+ const dataStorage = /* @__PURE__ */ Object.create(null);
435
+ function newStorage(provider, prefix) {
436
+ return {
437
+ provider,
438
+ prefix,
439
+ icons: /* @__PURE__ */ Object.create(null),
440
+ missing: /* @__PURE__ */ new Set()
441
+ };
442
+ }
443
+ function getStorage(provider, prefix) {
444
+ const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
445
+ return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
446
+ }
447
+ function addIconSet(storage2, data) {
448
+ if (!quicklyValidateIconSet(data)) return [];
449
+ return parseIconSet(data, (name, icon) => {
450
+ if (icon) storage2.icons[name] = icon;
451
+ else storage2.missing.add(name);
452
+ });
453
+ }
454
+ function addIconToStorage(storage2, name, icon) {
455
+ try {
456
+ if (typeof icon.body === "string") {
457
+ storage2.icons[name] = { ...icon };
458
+ return true;
459
+ }
460
+ } catch (err) {
461
+ }
462
+ return false;
463
+ }
464
+ let simpleNames = false;
465
+ function allowSimpleNames(allow) {
466
+ if (typeof allow === "boolean") simpleNames = allow;
467
+ return simpleNames;
468
+ }
469
+ function getIconData(name) {
470
+ const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
471
+ if (icon) {
472
+ const storage2 = getStorage(icon.provider, icon.prefix);
473
+ const iconName = icon.name;
474
+ return storage2.icons[iconName] || (storage2.missing.has(iconName) ? null : void 0);
475
+ }
476
+ }
477
+ function addIcon(name, data) {
478
+ const icon = stringToIcon(name, true, simpleNames);
479
+ if (!icon) return false;
480
+ const storage2 = getStorage(icon.provider, icon.prefix);
481
+ if (data) return addIconToStorage(storage2, icon.name, data);
482
+ else {
483
+ storage2.missing.add(icon.name);
484
+ return true;
485
+ }
486
+ }
487
+ function addCollection(data, provider) {
488
+ if (typeof data !== "object") return false;
489
+ if (typeof provider !== "string") provider = data.provider || "";
490
+ if (simpleNames && !provider && !data.prefix) {
491
+ let added = false;
492
+ if (quicklyValidateIconSet(data)) {
493
+ data.prefix = "";
494
+ parseIconSet(data, (name, icon) => {
495
+ if (addIcon(name, icon)) added = true;
496
+ });
497
+ }
498
+ return added;
499
+ }
500
+ const prefix = data.prefix;
501
+ if (!validateIconName({
502
+ prefix,
503
+ name: "a"
504
+ })) return false;
505
+ return !!addIconSet(getStorage(provider, prefix), data);
506
+ }
507
+ const defaultIconSizeCustomisations = Object.freeze({
508
+ width: null,
509
+ height: null
510
+ });
511
+ const defaultIconCustomisations = Object.freeze({
512
+ ...defaultIconSizeCustomisations,
513
+ ...defaultIconTransformations
514
+ });
515
+ const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
516
+ const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
517
+ function calculateSize(size, ratio, precision) {
518
+ if (ratio === 1) return size;
519
+ precision = precision || 100;
520
+ if (typeof size === "number") return Math.ceil(size * ratio * precision) / precision;
521
+ if (typeof size !== "string") return size;
522
+ const oldParts = size.split(unitsSplit);
523
+ if (oldParts === null || !oldParts.length) return size;
524
+ const newParts = [];
525
+ let code = oldParts.shift();
526
+ let isNumber = unitsTest.test(code);
527
+ while (true) {
528
+ if (isNumber) {
529
+ const num = parseFloat(code);
530
+ if (isNaN(num)) newParts.push(code);
531
+ else newParts.push(Math.ceil(num * ratio * precision) / precision);
532
+ } else newParts.push(code);
533
+ code = oldParts.shift();
534
+ if (code === void 0) return newParts.join("");
535
+ isNumber = !isNumber;
536
+ }
537
+ }
538
+ function splitSVGDefs(content, tag = "defs") {
539
+ let defs = "";
540
+ const index = content.indexOf("<" + tag);
541
+ while (index >= 0) {
542
+ const start = content.indexOf(">", index);
543
+ const end = content.indexOf("</" + tag);
544
+ if (start === -1 || end === -1) break;
545
+ const endEnd = content.indexOf(">", end);
546
+ if (endEnd === -1) break;
547
+ defs += content.slice(start + 1, end).trim();
548
+ content = content.slice(0, index).trim() + content.slice(endEnd + 1);
549
+ }
550
+ return {
551
+ defs,
552
+ content
553
+ };
554
+ }
555
+ function mergeDefsAndContent(defs, content) {
556
+ return defs ? "<defs>" + defs + "</defs>" + content : content;
557
+ }
558
+ function wrapSVGContent(body, start, end) {
559
+ const split = splitSVGDefs(body);
560
+ return mergeDefsAndContent(split.defs, start + split.content + end);
561
+ }
562
+ const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
563
+ function iconToSVG(icon, customisations) {
564
+ const fullIcon = {
565
+ ...defaultIconProps,
566
+ ...icon
567
+ };
568
+ const fullCustomisations = {
569
+ ...defaultIconCustomisations,
570
+ ...customisations
571
+ };
572
+ const box = {
573
+ left: fullIcon.left,
574
+ top: fullIcon.top,
575
+ width: fullIcon.width,
576
+ height: fullIcon.height
577
+ };
578
+ let body = fullIcon.body;
579
+ [fullIcon, fullCustomisations].forEach((props) => {
580
+ const transformations = [];
581
+ const hFlip = props.hFlip;
582
+ const vFlip = props.vFlip;
583
+ let rotation = props.rotate;
584
+ if (hFlip) if (vFlip) rotation += 2;
585
+ else {
586
+ transformations.push("translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")");
587
+ transformations.push("scale(-1 1)");
588
+ box.top = box.left = 0;
589
+ }
590
+ else if (vFlip) {
591
+ transformations.push("translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")");
592
+ transformations.push("scale(1 -1)");
593
+ box.top = box.left = 0;
594
+ }
595
+ let tempValue;
596
+ if (rotation < 0) rotation -= Math.floor(rotation / 4) * 4;
597
+ rotation = rotation % 4;
598
+ switch (rotation) {
599
+ case 1:
600
+ tempValue = box.height / 2 + box.top;
601
+ transformations.unshift("rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")");
602
+ break;
603
+ case 2:
604
+ transformations.unshift("rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")");
605
+ break;
606
+ case 3:
607
+ tempValue = box.width / 2 + box.left;
608
+ transformations.unshift("rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")");
609
+ break;
610
+ }
611
+ if (rotation % 2 === 1) {
612
+ if (box.left !== box.top) {
613
+ tempValue = box.left;
614
+ box.left = box.top;
615
+ box.top = tempValue;
616
+ }
617
+ if (box.width !== box.height) {
618
+ tempValue = box.width;
619
+ box.width = box.height;
620
+ box.height = tempValue;
621
+ }
622
+ }
623
+ if (transformations.length) body = wrapSVGContent(body, '<g transform="' + transformations.join(" ") + '">', "</g>");
624
+ });
625
+ const customisationsWidth = fullCustomisations.width;
626
+ const customisationsHeight = fullCustomisations.height;
627
+ const boxWidth = box.width;
628
+ const boxHeight = box.height;
629
+ let width;
630
+ let height;
631
+ if (customisationsWidth === null) {
632
+ height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
633
+ width = calculateSize(height, boxWidth / boxHeight);
634
+ } else {
635
+ width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
636
+ height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
637
+ }
638
+ const attributes2 = {};
639
+ const setAttr = (prop, value) => {
640
+ if (!isUnsetKeyword(value)) attributes2[prop] = value.toString();
641
+ };
642
+ setAttr("width", width);
643
+ setAttr("height", height);
644
+ const viewBox = [
645
+ box.left,
646
+ box.top,
647
+ boxWidth,
648
+ boxHeight
649
+ ];
650
+ attributes2.viewBox = viewBox.join(" ");
651
+ return {
652
+ attributes: attributes2,
653
+ viewBox,
654
+ body
655
+ };
656
+ }
657
+ const regex = /\sid="(\S+)"/g;
658
+ const counters = /* @__PURE__ */ new Map();
659
+ function nextID(id) {
660
+ id = id.replace(/[0-9]+$/, "") || "a";
661
+ const count = counters.get(id) || 0;
662
+ counters.set(id, count + 1);
663
+ return count ? `${id}${count}` : id;
664
+ }
665
+ function replaceIDs(body) {
666
+ const ids = [];
667
+ let match;
668
+ while (match = regex.exec(body)) ids.push(match[1]);
669
+ if (!ids.length) return body;
670
+ const suffix = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
671
+ ids.forEach((id) => {
672
+ const newID = nextID(id);
673
+ const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
674
+ body = body.replace(new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"), "$1" + newID + suffix + "$3");
675
+ });
676
+ body = body.replace(new RegExp(suffix, "g"), "");
677
+ return body;
678
+ }
679
+ const storage = /* @__PURE__ */ Object.create(null);
680
+ function setAPIModule(provider, item) {
681
+ storage[provider] = item;
682
+ }
683
+ function getAPIModule(provider) {
684
+ return storage[provider] || storage[""];
685
+ }
686
+ function createAPIConfig(source) {
687
+ let resources;
688
+ if (typeof source.resources === "string") resources = [source.resources];
689
+ else {
690
+ resources = source.resources;
691
+ if (!(resources instanceof Array) || !resources.length) return null;
692
+ }
693
+ return {
694
+ resources,
695
+ path: source.path || "/",
696
+ maxURL: source.maxURL || 500,
697
+ rotate: source.rotate || 750,
698
+ timeout: source.timeout || 5e3,
699
+ random: source.random === true,
700
+ index: source.index || 0,
701
+ dataAfterTimeout: source.dataAfterTimeout !== false
702
+ };
703
+ }
704
+ const configStorage = /* @__PURE__ */ Object.create(null);
705
+ const fallBackAPISources = ["https://api.simplesvg.com", "https://api.unisvg.com"];
706
+ const fallBackAPI = [];
707
+ while (fallBackAPISources.length > 0) if (fallBackAPISources.length === 1) fallBackAPI.push(fallBackAPISources.shift());
708
+ else if (Math.random() > 0.5) fallBackAPI.push(fallBackAPISources.shift());
709
+ else fallBackAPI.push(fallBackAPISources.pop());
710
+ configStorage[""] = createAPIConfig({ resources: ["https://api.iconify.design"].concat(fallBackAPI) });
711
+ function addAPIProvider(provider, customConfig) {
712
+ const config = createAPIConfig(customConfig);
713
+ if (config === null) return false;
714
+ configStorage[provider] = config;
715
+ return true;
716
+ }
717
+ function getAPIConfig(provider) {
718
+ return configStorage[provider];
719
+ }
720
+ const detectFetch = () => {
721
+ let callback;
722
+ try {
723
+ callback = fetch;
724
+ if (typeof callback === "function") return callback;
725
+ } catch (err) {
726
+ }
727
+ };
728
+ let fetchModule = detectFetch();
729
+ function calculateMaxLength(provider, prefix) {
730
+ const config = getAPIConfig(provider);
731
+ if (!config) return 0;
732
+ let result;
733
+ if (!config.maxURL) result = 0;
734
+ else {
735
+ let maxHostLength = 0;
736
+ config.resources.forEach((item) => {
737
+ const host = item;
738
+ maxHostLength = Math.max(maxHostLength, host.length);
739
+ });
740
+ const url = prefix + ".json?icons=";
741
+ result = config.maxURL - maxHostLength - config.path.length - url.length;
742
+ }
743
+ return result;
744
+ }
745
+ function shouldAbort(status) {
746
+ return status === 404;
747
+ }
748
+ const prepare = (provider, prefix, icons) => {
749
+ const results = [];
750
+ const maxLength = calculateMaxLength(provider, prefix);
751
+ const type = "icons";
752
+ let item = {
753
+ type,
754
+ provider,
755
+ prefix,
756
+ icons: []
757
+ };
758
+ let length = 0;
759
+ icons.forEach((name, index) => {
760
+ length += name.length + 1;
761
+ if (length >= maxLength && index > 0) {
762
+ results.push(item);
763
+ item = {
764
+ type,
765
+ provider,
766
+ prefix,
767
+ icons: []
768
+ };
769
+ length = name.length;
770
+ }
771
+ item.icons.push(name);
772
+ });
773
+ results.push(item);
774
+ return results;
775
+ };
776
+ function getPath(provider) {
777
+ if (typeof provider === "string") {
778
+ const config = getAPIConfig(provider);
779
+ if (config) return config.path;
780
+ }
781
+ return "/";
782
+ }
783
+ const send = (host, params, callback) => {
784
+ if (!fetchModule) {
785
+ callback("abort", 424);
786
+ return;
787
+ }
788
+ let path = getPath(params.provider);
789
+ switch (params.type) {
790
+ case "icons": {
791
+ const prefix = params.prefix;
792
+ const iconsList = params.icons.join(",");
793
+ const urlParams = new URLSearchParams({ icons: iconsList });
794
+ path += prefix + ".json?" + urlParams.toString();
795
+ break;
796
+ }
797
+ case "custom": {
798
+ const uri = params.uri;
799
+ path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
800
+ break;
801
+ }
802
+ default:
803
+ callback("abort", 400);
804
+ return;
805
+ }
806
+ let defaultError = 503;
807
+ fetchModule(host + path).then((response) => {
808
+ const status = response.status;
809
+ if (status !== 200) {
810
+ setTimeout(() => {
811
+ callback(shouldAbort(status) ? "abort" : "next", status);
812
+ });
813
+ return;
814
+ }
815
+ defaultError = 501;
816
+ return response.json();
817
+ }).then((data) => {
818
+ if (typeof data !== "object" || data === null) {
819
+ setTimeout(() => {
820
+ if (data === 404) callback("abort", data);
821
+ else callback("next", defaultError);
822
+ });
823
+ return;
824
+ }
825
+ setTimeout(() => {
826
+ callback("success", data);
827
+ });
828
+ }).catch(() => {
829
+ callback("next", defaultError);
830
+ });
831
+ };
832
+ const fetchAPIModule = {
833
+ prepare,
834
+ send
835
+ };
836
+ function removeCallback(storages, id) {
837
+ storages.forEach((storage2) => {
838
+ const items = storage2.loaderCallbacks;
839
+ if (items) storage2.loaderCallbacks = items.filter((row) => row.id !== id);
840
+ });
841
+ }
842
+ function updateCallbacks(storage2) {
843
+ if (!storage2.pendingCallbacksFlag) {
844
+ storage2.pendingCallbacksFlag = true;
845
+ setTimeout(() => {
846
+ storage2.pendingCallbacksFlag = false;
847
+ const items = storage2.loaderCallbacks ? storage2.loaderCallbacks.slice(0) : [];
848
+ if (!items.length) return;
849
+ let hasPending = false;
850
+ const provider = storage2.provider;
851
+ const prefix = storage2.prefix;
852
+ items.forEach((item) => {
853
+ const icons = item.icons;
854
+ const oldLength = icons.pending.length;
855
+ icons.pending = icons.pending.filter((icon) => {
856
+ if (icon.prefix !== prefix) return true;
857
+ const name = icon.name;
858
+ if (storage2.icons[name]) icons.loaded.push({
859
+ provider,
860
+ prefix,
861
+ name
862
+ });
863
+ else if (storage2.missing.has(name)) icons.missing.push({
864
+ provider,
865
+ prefix,
866
+ name
867
+ });
868
+ else {
869
+ hasPending = true;
870
+ return true;
871
+ }
872
+ return false;
873
+ });
874
+ if (icons.pending.length !== oldLength) {
875
+ if (!hasPending) removeCallback([storage2], item.id);
876
+ item.callback(icons.loaded.slice(0), icons.missing.slice(0), icons.pending.slice(0), item.abort);
877
+ }
878
+ });
879
+ });
880
+ }
881
+ }
882
+ let idCounter = 0;
883
+ function storeCallback(callback, icons, pendingSources) {
884
+ const id = idCounter++;
885
+ const abort = removeCallback.bind(null, pendingSources, id);
886
+ if (!icons.pending.length) return abort;
887
+ const item = {
888
+ id,
889
+ icons,
890
+ callback,
891
+ abort
892
+ };
893
+ pendingSources.forEach((storage2) => {
894
+ (storage2.loaderCallbacks || (storage2.loaderCallbacks = [])).push(item);
895
+ });
896
+ return abort;
897
+ }
898
+ function sortIcons(icons) {
899
+ const result = {
900
+ loaded: [],
901
+ missing: [],
902
+ pending: []
903
+ };
904
+ const storage2 = /* @__PURE__ */ Object.create(null);
905
+ icons.sort((a, b) => {
906
+ if (a.provider !== b.provider) return a.provider.localeCompare(b.provider);
907
+ if (a.prefix !== b.prefix) return a.prefix.localeCompare(b.prefix);
908
+ return a.name.localeCompare(b.name);
909
+ });
910
+ let lastIcon = {
911
+ provider: "",
912
+ prefix: "",
913
+ name: ""
914
+ };
915
+ icons.forEach((icon) => {
916
+ if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) return;
917
+ lastIcon = icon;
918
+ const provider = icon.provider;
919
+ const prefix = icon.prefix;
920
+ const name = icon.name;
921
+ const providerStorage = storage2[provider] || (storage2[provider] = /* @__PURE__ */ Object.create(null));
922
+ const localStorage2 = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
923
+ let list;
924
+ if (name in localStorage2.icons) list = result.loaded;
925
+ else if (prefix === "" || localStorage2.missing.has(name)) list = result.missing;
926
+ else list = result.pending;
927
+ const item = {
928
+ provider,
929
+ prefix,
930
+ name
931
+ };
932
+ list.push(item);
933
+ });
934
+ return result;
935
+ }
936
+ function listToIcons(list, validate = true, simpleNames2 = false) {
937
+ const result = [];
938
+ list.forEach((item) => {
939
+ const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames2) : item;
940
+ if (icon) result.push(icon);
941
+ });
942
+ return result;
943
+ }
944
+ const defaultConfig = {
945
+ resources: [],
946
+ index: 0,
947
+ timeout: 2e3,
948
+ rotate: 750,
949
+ random: false,
950
+ dataAfterTimeout: false
951
+ };
952
+ function sendQuery(config, payload, query, done) {
953
+ const resourcesCount = config.resources.length;
954
+ const startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;
955
+ let resources;
956
+ if (config.random) {
957
+ let list = config.resources.slice(0);
958
+ resources = [];
959
+ while (list.length > 1) {
960
+ const nextIndex = Math.floor(Math.random() * list.length);
961
+ resources.push(list[nextIndex]);
962
+ list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
963
+ }
964
+ resources = resources.concat(list);
965
+ } else resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
966
+ const startTime = Date.now();
967
+ let status = "pending";
968
+ let queriesSent = 0;
969
+ let lastError;
970
+ let timer = null;
971
+ let queue = [];
972
+ let doneCallbacks = [];
973
+ if (typeof done === "function") doneCallbacks.push(done);
974
+ function resetTimer() {
975
+ if (timer) {
976
+ clearTimeout(timer);
977
+ timer = null;
978
+ }
979
+ }
980
+ function abort() {
981
+ if (status === "pending") status = "aborted";
982
+ resetTimer();
983
+ queue.forEach((item) => {
984
+ if (item.status === "pending") item.status = "aborted";
985
+ });
986
+ queue = [];
987
+ }
988
+ function subscribe(callback, overwrite) {
989
+ if (overwrite) doneCallbacks = [];
990
+ if (typeof callback === "function") doneCallbacks.push(callback);
991
+ }
992
+ function getQueryStatus() {
993
+ return {
994
+ startTime,
995
+ payload,
996
+ status,
997
+ queriesSent,
998
+ queriesPending: queue.length,
999
+ subscribe,
1000
+ abort
1001
+ };
1002
+ }
1003
+ function failQuery() {
1004
+ status = "failed";
1005
+ doneCallbacks.forEach((callback) => {
1006
+ callback(void 0, lastError);
1007
+ });
1008
+ }
1009
+ function clearQueue() {
1010
+ queue.forEach((item) => {
1011
+ if (item.status === "pending") item.status = "aborted";
1012
+ });
1013
+ queue = [];
1014
+ }
1015
+ function moduleResponse(item, response, data) {
1016
+ const isError = response !== "success";
1017
+ queue = queue.filter((queued) => queued !== item);
1018
+ switch (status) {
1019
+ case "pending":
1020
+ break;
1021
+ case "failed":
1022
+ if (isError || !config.dataAfterTimeout) return;
1023
+ break;
1024
+ default:
1025
+ return;
1026
+ }
1027
+ if (response === "abort") {
1028
+ lastError = data;
1029
+ failQuery();
1030
+ return;
1031
+ }
1032
+ if (isError) {
1033
+ lastError = data;
1034
+ if (!queue.length) if (!resources.length) failQuery();
1035
+ else execNext();
1036
+ return;
1037
+ }
1038
+ resetTimer();
1039
+ clearQueue();
1040
+ if (!config.random) {
1041
+ const index = config.resources.indexOf(item.resource);
1042
+ if (index !== -1 && index !== config.index) config.index = index;
1043
+ }
1044
+ status = "completed";
1045
+ doneCallbacks.forEach((callback) => {
1046
+ callback(data);
1047
+ });
1048
+ }
1049
+ function execNext() {
1050
+ if (status !== "pending") return;
1051
+ resetTimer();
1052
+ const resource = resources.shift();
1053
+ if (resource === void 0) {
1054
+ if (queue.length) {
1055
+ timer = setTimeout(() => {
1056
+ resetTimer();
1057
+ if (status === "pending") {
1058
+ clearQueue();
1059
+ failQuery();
1060
+ }
1061
+ }, config.timeout);
1062
+ return;
1063
+ }
1064
+ failQuery();
1065
+ return;
1066
+ }
1067
+ const item = {
1068
+ status: "pending",
1069
+ resource,
1070
+ callback: (status$1, data) => {
1071
+ moduleResponse(item, status$1, data);
1072
+ }
1073
+ };
1074
+ queue.push(item);
1075
+ queriesSent++;
1076
+ timer = setTimeout(execNext, config.rotate);
1077
+ query(resource, payload, item.callback);
1078
+ }
1079
+ setTimeout(execNext);
1080
+ return getQueryStatus;
1081
+ }
1082
+ function initRedundancy(cfg) {
1083
+ const config = {
1084
+ ...defaultConfig,
1085
+ ...cfg
1086
+ };
1087
+ let queries = [];
1088
+ function cleanup() {
1089
+ queries = queries.filter((item) => item().status === "pending");
1090
+ }
1091
+ function query(payload, queryCallback, doneCallback) {
1092
+ const query$1 = sendQuery(config, payload, queryCallback, (data, error) => {
1093
+ cleanup();
1094
+ if (doneCallback) doneCallback(data, error);
1095
+ });
1096
+ queries.push(query$1);
1097
+ return query$1;
1098
+ }
1099
+ function find(callback) {
1100
+ return queries.find((value) => {
1101
+ return callback(value);
1102
+ }) || null;
1103
+ }
1104
+ return {
1105
+ query,
1106
+ find,
1107
+ setIndex: (index) => {
1108
+ config.index = index;
1109
+ },
1110
+ getIndex: () => config.index,
1111
+ cleanup
1112
+ };
1113
+ }
1114
+ function emptyCallback$1() {
1115
+ }
1116
+ const redundancyCache = /* @__PURE__ */ Object.create(null);
1117
+ function getRedundancyCache(provider) {
1118
+ if (!redundancyCache[provider]) {
1119
+ const config = getAPIConfig(provider);
1120
+ if (!config) return;
1121
+ redundancyCache[provider] = {
1122
+ config,
1123
+ redundancy: initRedundancy(config)
1124
+ };
1125
+ }
1126
+ return redundancyCache[provider];
1127
+ }
1128
+ function sendAPIQuery(target, query, callback) {
1129
+ let redundancy;
1130
+ let send2;
1131
+ if (typeof target === "string") {
1132
+ const api = getAPIModule(target);
1133
+ if (!api) {
1134
+ callback(void 0, 424);
1135
+ return emptyCallback$1;
1136
+ }
1137
+ send2 = api.send;
1138
+ const cached = getRedundancyCache(target);
1139
+ if (cached) redundancy = cached.redundancy;
1140
+ } else {
1141
+ const config = createAPIConfig(target);
1142
+ if (config) {
1143
+ redundancy = initRedundancy(config);
1144
+ const api = getAPIModule(target.resources ? target.resources[0] : "");
1145
+ if (api) send2 = api.send;
1146
+ }
1147
+ }
1148
+ if (!redundancy || !send2) {
1149
+ callback(void 0, 424);
1150
+ return emptyCallback$1;
1151
+ }
1152
+ return redundancy.query(query, send2, callback)().abort;
1153
+ }
1154
+ function emptyCallback() {
1155
+ }
1156
+ function loadedNewIcons(storage2) {
1157
+ if (!storage2.iconsLoaderFlag) {
1158
+ storage2.iconsLoaderFlag = true;
1159
+ setTimeout(() => {
1160
+ storage2.iconsLoaderFlag = false;
1161
+ updateCallbacks(storage2);
1162
+ });
1163
+ }
1164
+ }
1165
+ function checkIconNamesForAPI(icons) {
1166
+ const valid = [];
1167
+ const invalid = [];
1168
+ icons.forEach((name) => {
1169
+ (name.match(matchIconName) ? valid : invalid).push(name);
1170
+ });
1171
+ return {
1172
+ valid,
1173
+ invalid
1174
+ };
1175
+ }
1176
+ function parseLoaderResponse(storage2, icons, data) {
1177
+ function checkMissing() {
1178
+ const pending = storage2.pendingIcons;
1179
+ icons.forEach((name) => {
1180
+ if (pending) pending.delete(name);
1181
+ if (!storage2.icons[name]) storage2.missing.add(name);
1182
+ });
1183
+ }
1184
+ if (data && typeof data === "object") try {
1185
+ if (!addIconSet(storage2, data).length) {
1186
+ checkMissing();
1187
+ return;
1188
+ }
1189
+ } catch (err) {
1190
+ console.error(err);
1191
+ }
1192
+ checkMissing();
1193
+ loadedNewIcons(storage2);
1194
+ }
1195
+ function parsePossiblyAsyncResponse(response, callback) {
1196
+ if (response instanceof Promise) response.then((data) => {
1197
+ callback(data);
1198
+ }).catch(() => {
1199
+ callback(null);
1200
+ });
1201
+ else callback(response);
1202
+ }
1203
+ function loadNewIcons(storage2, icons) {
1204
+ if (!storage2.iconsToLoad) storage2.iconsToLoad = icons;
1205
+ else storage2.iconsToLoad = storage2.iconsToLoad.concat(icons).sort();
1206
+ if (!storage2.iconsQueueFlag) {
1207
+ storage2.iconsQueueFlag = true;
1208
+ setTimeout(() => {
1209
+ storage2.iconsQueueFlag = false;
1210
+ const { provider, prefix } = storage2;
1211
+ const icons$1 = storage2.iconsToLoad;
1212
+ delete storage2.iconsToLoad;
1213
+ if (!icons$1 || !icons$1.length) return;
1214
+ const customIconLoader = storage2.loadIcon;
1215
+ if (storage2.loadIcons && (icons$1.length > 1 || !customIconLoader)) {
1216
+ parsePossiblyAsyncResponse(storage2.loadIcons(icons$1, prefix, provider), (data) => {
1217
+ parseLoaderResponse(storage2, icons$1, data);
1218
+ });
1219
+ return;
1220
+ }
1221
+ if (customIconLoader) {
1222
+ icons$1.forEach((name) => {
1223
+ parsePossiblyAsyncResponse(customIconLoader(name, prefix, provider), (data) => {
1224
+ parseLoaderResponse(storage2, [name], data ? {
1225
+ prefix,
1226
+ icons: { [name]: data }
1227
+ } : null);
1228
+ });
1229
+ });
1230
+ return;
1231
+ }
1232
+ const { valid, invalid } = checkIconNamesForAPI(icons$1);
1233
+ if (invalid.length) parseLoaderResponse(storage2, invalid, null);
1234
+ if (!valid.length) return;
1235
+ const api = prefix.match(matchIconName) ? getAPIModule(provider) : null;
1236
+ if (!api) {
1237
+ parseLoaderResponse(storage2, valid, null);
1238
+ return;
1239
+ }
1240
+ api.prepare(provider, prefix, valid).forEach((item) => {
1241
+ sendAPIQuery(provider, item, (data) => {
1242
+ parseLoaderResponse(storage2, item.icons, data);
1243
+ });
1244
+ });
1245
+ });
1246
+ }
1247
+ }
1248
+ const loadIcons = (icons, callback) => {
1249
+ const sortedIcons = sortIcons(listToIcons(icons, true, allowSimpleNames()));
1250
+ if (!sortedIcons.pending.length) {
1251
+ let callCallback = true;
1252
+ if (callback) setTimeout(() => {
1253
+ if (callCallback) callback(sortedIcons.loaded, sortedIcons.missing, sortedIcons.pending, emptyCallback);
1254
+ });
1255
+ return () => {
1256
+ callCallback = false;
1257
+ };
1258
+ }
1259
+ const newIcons = /* @__PURE__ */ Object.create(null);
1260
+ const sources = [];
1261
+ let lastProvider, lastPrefix;
1262
+ sortedIcons.pending.forEach((icon) => {
1263
+ const { provider, prefix } = icon;
1264
+ if (prefix === lastPrefix && provider === lastProvider) return;
1265
+ lastProvider = provider;
1266
+ lastPrefix = prefix;
1267
+ sources.push(getStorage(provider, prefix));
1268
+ const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */ Object.create(null));
1269
+ if (!providerNewIcons[prefix]) providerNewIcons[prefix] = [];
1270
+ });
1271
+ sortedIcons.pending.forEach((icon) => {
1272
+ const { provider, prefix, name } = icon;
1273
+ const storage2 = getStorage(provider, prefix);
1274
+ const pendingQueue = storage2.pendingIcons || (storage2.pendingIcons = /* @__PURE__ */ new Set());
1275
+ if (!pendingQueue.has(name)) {
1276
+ pendingQueue.add(name);
1277
+ newIcons[provider][prefix].push(name);
1278
+ }
1279
+ });
1280
+ sources.forEach((storage2) => {
1281
+ const list = newIcons[storage2.provider][storage2.prefix];
1282
+ if (list.length) loadNewIcons(storage2, list);
1283
+ });
1284
+ return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
1285
+ };
1286
+ function mergeCustomisations(defaults, item) {
1287
+ const result = { ...defaults };
1288
+ for (const key in item) {
1289
+ const value = item[key];
1290
+ const valueType = typeof value;
1291
+ if (key in defaultIconSizeCustomisations) {
1292
+ if (value === null || value && (valueType === "string" || valueType === "number")) result[key] = value;
1293
+ } else if (valueType === typeof result[key]) result[key] = key === "rotate" ? value % 4 : value;
1294
+ }
1295
+ return result;
1296
+ }
1297
+ const separator = /[\s,]+/;
1298
+ function flipFromString(custom, flip) {
1299
+ flip.split(separator).forEach((str) => {
1300
+ switch (str.trim()) {
1301
+ case "horizontal":
1302
+ custom.hFlip = true;
1303
+ break;
1304
+ case "vertical":
1305
+ custom.vFlip = true;
1306
+ break;
1307
+ }
1308
+ });
1309
+ }
1310
+ function rotateFromString(value, defaultValue = 0) {
1311
+ const units = value.replace(/^-?[0-9.]*/, "");
1312
+ function cleanup(value$1) {
1313
+ while (value$1 < 0) value$1 += 4;
1314
+ return value$1 % 4;
1315
+ }
1316
+ if (units === "") {
1317
+ const num = parseInt(value);
1318
+ return isNaN(num) ? 0 : cleanup(num);
1319
+ } else if (units !== value) {
1320
+ let split = 0;
1321
+ switch (units) {
1322
+ case "%":
1323
+ split = 25;
1324
+ break;
1325
+ case "deg":
1326
+ split = 90;
1327
+ }
1328
+ if (split) {
1329
+ let num = parseFloat(value.slice(0, value.length - units.length));
1330
+ if (isNaN(num)) return 0;
1331
+ num = num / split;
1332
+ return num % 1 === 0 ? cleanup(num) : 0;
1333
+ }
1334
+ }
1335
+ return defaultValue;
1336
+ }
1337
+ function iconToHTML(body, attributes2) {
1338
+ let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
1339
+ for (const attr in attributes2) renderAttribsHTML += " " + attr + '="' + attributes2[attr] + '"';
1340
+ return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
1341
+ }
1342
+ function encodeSVGforURL(svg) {
1343
+ return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
1344
+ }
1345
+ function svgToData(svg) {
1346
+ return "data:image/svg+xml," + encodeSVGforURL(svg);
1347
+ }
1348
+ function svgToURL(svg) {
1349
+ return 'url("' + svgToData(svg) + '")';
1350
+ }
1351
+ const defaultExtendedIconCustomisations = {
1352
+ ...defaultIconCustomisations,
1353
+ inline: false
1354
+ };
1355
+ const svgDefaults = {
1356
+ "xmlns": "http://www.w3.org/2000/svg",
1357
+ "xmlns:xlink": "http://www.w3.org/1999/xlink",
1358
+ "aria-hidden": true,
1359
+ "role": "img"
1360
+ };
1361
+ const commonProps = {
1362
+ display: "inline-block"
1363
+ };
1364
+ const monotoneProps = {
1365
+ "background-color": "currentColor"
1366
+ };
1367
+ const coloredProps = {
1368
+ "background-color": "transparent"
1369
+ };
1370
+ const propsToAdd = {
1371
+ image: "var(--svg)",
1372
+ repeat: "no-repeat",
1373
+ size: "100% 100%"
1374
+ };
1375
+ const propsToAddTo = {
1376
+ "-webkit-mask": monotoneProps,
1377
+ "mask": monotoneProps,
1378
+ "background": coloredProps
1379
+ };
1380
+ for (const prefix in propsToAddTo) {
1381
+ const list = propsToAddTo[prefix];
1382
+ for (const prop in propsToAdd) {
1383
+ list[prefix + "-" + prop] = propsToAdd[prop];
1384
+ }
1385
+ }
1386
+ function fixSize(value) {
1387
+ return value + (value.match(/^[-0-9.]+$/) ? "px" : "");
1388
+ }
1389
+ function render(icon, props) {
1390
+ const customisations = mergeCustomisations(defaultExtendedIconCustomisations, props);
1391
+ const mode = props.mode || "svg";
1392
+ const componentProps = mode === "svg" ? { ...svgDefaults } : {};
1393
+ if (icon.body.indexOf("xlink:") === -1) {
1394
+ delete componentProps["xmlns:xlink"];
1395
+ }
1396
+ let style = typeof props.style === "string" ? props.style : "";
1397
+ for (let key in props) {
1398
+ const value = props[key];
1399
+ if (value === void 0) {
1400
+ continue;
1401
+ }
1402
+ switch (key) {
1403
+ // Properties to ignore
1404
+ case "icon":
1405
+ case "style":
1406
+ case "onLoad":
1407
+ case "mode":
1408
+ case "ssr":
1409
+ break;
1410
+ // Boolean attributes
1411
+ case "inline":
1412
+ case "hFlip":
1413
+ case "vFlip":
1414
+ customisations[key] = value === true || value === "true" || value === 1;
1415
+ break;
1416
+ // Flip as string: 'horizontal,vertical'
1417
+ case "flip":
1418
+ if (typeof value === "string") {
1419
+ flipFromString(customisations, value);
1420
+ }
1421
+ break;
1422
+ // Color: copy to style, add extra ';' in case style is missing it
1423
+ case "color":
1424
+ style = style + (style.length > 0 && style.trim().slice(-1) !== ";" ? ";" : "") + "color: " + value + "; ";
1425
+ break;
1426
+ // Rotation as string
1427
+ case "rotate":
1428
+ if (typeof value === "string") {
1429
+ customisations[key] = rotateFromString(value);
1430
+ } else if (typeof value === "number") {
1431
+ customisations[key] = value;
1432
+ }
1433
+ break;
1434
+ // Remove aria-hidden
1435
+ case "ariaHidden":
1436
+ case "aria-hidden":
1437
+ if (value !== true && value !== "true") {
1438
+ delete componentProps["aria-hidden"];
1439
+ }
1440
+ break;
1441
+ default:
1442
+ if (key.slice(0, 3) === "on:") {
1443
+ break;
1444
+ }
1445
+ if (defaultExtendedIconCustomisations[key] === void 0) {
1446
+ componentProps[key] = value;
1447
+ }
1448
+ }
1449
+ }
1450
+ const item = iconToSVG(icon, customisations);
1451
+ const renderAttribs = item.attributes;
1452
+ if (customisations.inline) {
1453
+ style = "vertical-align: -0.125em; " + style;
1454
+ }
1455
+ if (mode === "svg") {
1456
+ Object.assign(componentProps, renderAttribs);
1457
+ if (style !== "") {
1458
+ componentProps.style = style;
1459
+ }
1460
+ return {
1461
+ svg: true,
1462
+ attributes: componentProps,
1463
+ body: replaceIDs(item.body)
1464
+ };
1465
+ }
1466
+ const { body, width, height } = icon;
1467
+ const useMask = mode === "mask" || (mode === "bg" ? false : body.indexOf("currentColor") !== -1);
1468
+ const html2 = iconToHTML(body, {
1469
+ ...renderAttribs,
1470
+ width: width + "",
1471
+ height: height + ""
1472
+ });
1473
+ const url = svgToURL(html2);
1474
+ const styles = {
1475
+ "--svg": url
1476
+ };
1477
+ const size = (prop) => {
1478
+ const value = renderAttribs[prop];
1479
+ if (value) {
1480
+ styles[prop] = fixSize(value);
1481
+ }
1482
+ };
1483
+ size("width");
1484
+ size("height");
1485
+ Object.assign(styles, commonProps, useMask ? monotoneProps : coloredProps);
1486
+ let customStyle = "";
1487
+ for (const key in styles) {
1488
+ customStyle += key + ": " + styles[key] + ";";
1489
+ }
1490
+ componentProps.style = customStyle + style;
1491
+ return {
1492
+ svg: false,
1493
+ attributes: componentProps
1494
+ };
1495
+ }
1496
+ allowSimpleNames(true);
1497
+ setAPIModule("", fetchAPIModule);
1498
+ if (typeof document !== "undefined" && typeof window !== "undefined") {
1499
+ const _window = window;
1500
+ if (_window.IconifyPreload !== void 0) {
1501
+ const preload = _window.IconifyPreload;
1502
+ const err = "Invalid IconifyPreload syntax.";
1503
+ if (typeof preload === "object" && preload !== null) {
1504
+ (preload instanceof Array ? preload : [preload]).forEach((item) => {
1505
+ try {
1506
+ if (
1507
+ // Check if item is an object and not null/array
1508
+ typeof item !== "object" || item === null || item instanceof Array || // Check for 'icons' and 'prefix'
1509
+ typeof item.icons !== "object" || typeof item.prefix !== "string" || // Add icon set
1510
+ !addCollection(item)
1511
+ ) {
1512
+ console.error(err);
1513
+ }
1514
+ } catch (e) {
1515
+ console.error(err);
1516
+ }
1517
+ });
1518
+ }
1519
+ }
1520
+ if (_window.IconifyProviders !== void 0) {
1521
+ const providers = _window.IconifyProviders;
1522
+ if (typeof providers === "object" && providers !== null) {
1523
+ for (let key in providers) {
1524
+ const err = "IconifyProviders[" + key + "] is invalid.";
1525
+ try {
1526
+ const value = providers[key];
1527
+ if (typeof value !== "object" || !value || value.resources === void 0) {
1528
+ continue;
1529
+ }
1530
+ if (!addAPIProvider(key, value)) {
1531
+ console.error(err);
1532
+ }
1533
+ } catch (e) {
1534
+ console.error(err);
1535
+ }
1536
+ }
1537
+ }
1538
+ }
1539
+ }
1540
+ function isSSR() {
1541
+ try {
1542
+ return typeof window !== "object";
1543
+ } catch (err) {
1544
+ return true;
1545
+ }
1546
+ }
1547
+ function checkIconState(icon, state, callback, onload) {
1548
+ function abortLoading() {
1549
+ if (state.loading) {
1550
+ state.loading.abort();
1551
+ state.loading = null;
1552
+ }
1553
+ }
1554
+ if (typeof icon === "object" && icon !== null && typeof icon.body === "string") {
1555
+ state.name = "";
1556
+ abortLoading();
1557
+ return { data: { ...defaultIconProps, ...icon } };
1558
+ }
1559
+ let iconName;
1560
+ if (typeof icon !== "string" || (iconName = stringToIcon(icon, false, true)) === null) {
1561
+ abortLoading();
1562
+ return null;
1563
+ }
1564
+ const data = getIconData(iconName);
1565
+ if (!data) {
1566
+ if (!isSSR() && (!state.loading || state.loading.name !== icon)) {
1567
+ abortLoading();
1568
+ state.name = "";
1569
+ state.loading = {
1570
+ name: icon,
1571
+ abort: loadIcons([iconName], callback)
1572
+ };
1573
+ }
1574
+ return null;
1575
+ }
1576
+ abortLoading();
1577
+ if (state.name !== icon) {
1578
+ state.name = icon;
1579
+ if (onload && !state.destroyed) {
1580
+ setTimeout(() => {
1581
+ onload(icon);
1582
+ });
1583
+ }
1584
+ }
1585
+ const classes = ["iconify"];
1586
+ if (iconName.prefix !== "") {
1587
+ classes.push("iconify--" + iconName.prefix);
1588
+ }
1589
+ if (iconName.provider !== "") {
1590
+ classes.push("iconify--" + iconName.provider);
1591
+ }
1592
+ return { data, classes };
1593
+ }
1594
+ function generateIcon(icon, props) {
1595
+ return icon ? render({
1596
+ ...defaultIconProps,
1597
+ ...icon
1598
+ }, props) : null;
1599
+ }
1600
+ function Icon($$renderer, $$props) {
1601
+ $$renderer.component(($$renderer2) => {
1602
+ const iconState = {
1603
+ // Last icon name
1604
+ name: "",
1605
+ // Loading status
1606
+ loading: null,
1607
+ // Destroyed status
1608
+ destroyed: false
1609
+ };
1610
+ const { $$slots, $$events, ...props } = $$props;
1611
+ let iconData = (() => {
1612
+ return checkIconState(props.icon, iconState, loaded, props.onload);
1613
+ })();
1614
+ let data = (() => {
1615
+ const generatedData = iconData ? generateIcon(iconData.data, props) : null;
1616
+ if (generatedData && iconData.classes && props["class"] === void 0) {
1617
+ generatedData.attributes["class"] = (typeof props["class"] === "string" ? props["class"] + " " : "") + iconData.classes.join(" ");
1618
+ }
1619
+ return generatedData;
1620
+ })();
1621
+ function loaded() {
1622
+ }
1623
+ onDestroy(() => {
1624
+ iconState.destroyed = true;
1625
+ if (iconState.loading) {
1626
+ iconState.loading.abort();
1627
+ iconState.loading = null;
1628
+ }
1629
+ });
1630
+ if (data) {
1631
+ $$renderer2.push("<!--[-->");
1632
+ if (data.svg) {
1633
+ $$renderer2.push("<!--[-->");
1634
+ $$renderer2.push(`<svg${attributes({ ...data.attributes }, void 0, void 0, void 0, 3)}>${html(data.body)}</svg>`);
1635
+ } else {
1636
+ $$renderer2.push("<!--[!-->");
1637
+ $$renderer2.push(`<span${attributes({ ...data.attributes })}></span>`);
1638
+ }
1639
+ $$renderer2.push(`<!--]-->`);
1640
+ } else {
1641
+ $$renderer2.push("<!--[!-->");
1642
+ }
1643
+ $$renderer2.push(`<!--]-->`);
1644
+ });
1645
+ }
1646
+ class ThemeState {
1647
+ isDark = false;
1648
+ constructor() {
1649
+ if (typeof window !== "undefined") {
1650
+ const stored = localStorage.getItem("preferredTheme");
1651
+ const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
1652
+ this.isDark = stored ? stored === "dark" : prefersDark;
1653
+ }
1654
+ }
1655
+ toggle() {
1656
+ this.isDark = !this.isDark;
1657
+ if (typeof window !== "undefined") {
1658
+ localStorage.setItem("preferredTheme", this.isDark ? "dark" : "light");
1659
+ }
1660
+ }
1661
+ }
1662
+ const theme = new ThemeState();
1663
+ export {
1664
+ Icon as I,
1665
+ calculateEdgeOffset as c,
1666
+ goto as g,
1667
+ invalidateAll as i,
1668
+ onDestroy as o,
1669
+ routingStore as r,
1670
+ theme as t
1671
+ };