@pollar/react 0.10.1-rc.1 → 0.10.1-rc.11

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/index.js CHANGED
@@ -1035,11 +1035,53 @@ var PollarModalFooter = () => {
1035
1035
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
1036
1036
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-footer-version", children: [
1037
1037
  "v",
1038
- "0.10.1-rc.1"
1038
+ "0.10.1-rc.11"
1039
1039
  ] })
1040
1040
  ] })
1041
1041
  ] });
1042
1042
  };
1043
+ function CopyButton({ value, label = "Copy", className }) {
1044
+ const [copied, setCopied] = react.useState(false);
1045
+ const timerRef = react.useRef(null);
1046
+ react.useEffect(() => {
1047
+ return () => {
1048
+ if (timerRef.current !== null) clearTimeout(timerRef.current);
1049
+ };
1050
+ }, []);
1051
+ function handleCopy(e) {
1052
+ e.stopPropagation();
1053
+ if (!value || !navigator.clipboard) return;
1054
+ void navigator.clipboard.writeText(value).then(() => {
1055
+ setCopied(true);
1056
+ if (timerRef.current !== null) clearTimeout(timerRef.current);
1057
+ timerRef.current = setTimeout(() => {
1058
+ setCopied(false);
1059
+ timerRef.current = null;
1060
+ }, 1500);
1061
+ });
1062
+ }
1063
+ return /* @__PURE__ */ jsxRuntime.jsx(
1064
+ "button",
1065
+ {
1066
+ type: "button",
1067
+ className: `pollar-copy-btn${className ? ` ${className}` : ""}`,
1068
+ onClick: handleCopy,
1069
+ "aria-label": copied ? "Copied" : label,
1070
+ children: copied ? /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3.5 7l2.5 2.5 4.5-5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) : /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
1071
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.5" }),
1072
+ /* @__PURE__ */ jsxRuntime.jsx(
1073
+ "path",
1074
+ {
1075
+ d: "M3 9H2a1 1 0 01-1-1V2a1 1 0 011-1h6a1 1 0 011 1v1",
1076
+ stroke: "currentColor",
1077
+ strokeWidth: "1.5",
1078
+ strokeLinecap: "round"
1079
+ }
1080
+ )
1081
+ ] })
1082
+ }
1083
+ );
1084
+ }
1043
1085
  function ModalStatusBanner({ message, status, onCancel, onRetry }) {
1044
1086
  if (!message && status === "NONE") {
1045
1087
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-status" });
@@ -1118,7 +1160,10 @@ function RuleCard({
1118
1160
  validity
1119
1161
  ] })
1120
1162
  ] }),
1121
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-dist-item-action", children: isClaimed ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-dist-item-status", "data-kind": "claimed", children: "Claimed" }) : effectivelyClaimable ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary pollar-dist-claim-btn", onClick: onClaim, disabled: isClaiming, children: isClaiming ? "Claiming\u2026" : "Claim" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-dist-item-status", "data-kind": "unavailable", children: reasonLabel(rule.reason) }) }),
1163
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-dist-item-action", children: isClaimed ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-dist-item-status", "data-kind": "claimed", children: "Claimed" }) : effectivelyClaimable ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary pollar-dist-claim-btn", onClick: onClaim, disabled: isClaiming, children: isClaiming ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1164
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
1165
+ "Claiming\u2026"
1166
+ ] }) : "Claim" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-dist-item-status", "data-kind": "unavailable", children: reasonLabel(rule.reason) }) }),
1122
1167
  errorMessage && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-dist-item-error", children: errorMessage })
1123
1168
  ] });
1124
1169
  }
@@ -1164,29 +1209,46 @@ function DistributionRulesModalTemplate({
1164
1209
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
1165
1210
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Distribution Rules" }),
1166
1211
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
1167
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-modal-refresh-btn", onClick: onRefresh, disabled: isLoading, children: [
1168
- /* @__PURE__ */ jsxRuntime.jsxs(
1169
- "svg",
1170
- {
1171
- className: `pollar-modal-refresh-icon${isLoading ? " spinning" : ""}`,
1172
- width: "13",
1173
- height: "13",
1174
- viewBox: "0 0 13 13",
1175
- fill: "none",
1176
- "aria-hidden": true,
1177
- children: [
1178
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11.5 6.5a5 5 0 11-1.5-3.536", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
1179
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 1v3h-3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
1180
- ]
1181
- }
1182
- ),
1183
- "Refresh"
1184
- ] }),
1212
+ /* @__PURE__ */ jsxRuntime.jsx(
1213
+ "button",
1214
+ {
1215
+ type: "button",
1216
+ className: "pollar-modal-close",
1217
+ onClick: onRefresh,
1218
+ disabled: isLoading,
1219
+ "aria-label": "Refresh",
1220
+ title: "Refresh",
1221
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1222
+ "svg",
1223
+ {
1224
+ className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
1225
+ width: "16",
1226
+ height: "16",
1227
+ viewBox: "0 0 16 16",
1228
+ fill: "none",
1229
+ "aria-hidden": true,
1230
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1231
+ "path",
1232
+ {
1233
+ d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
1234
+ stroke: "currentColor",
1235
+ strokeWidth: "1.6",
1236
+ strokeLinecap: "round",
1237
+ strokeLinejoin: "round"
1238
+ }
1239
+ )
1240
+ }
1241
+ )
1242
+ }
1243
+ ),
1185
1244
  /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
1186
1245
  ] })
1187
1246
  ] }),
1188
1247
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-dist-list", children: [
1189
- isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
1248
+ isLoading && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-loading-block", children: [
1249
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-spinner" }),
1250
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Loading\u2026" })
1251
+ ] }),
1190
1252
  state.step === "error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: state.message }),
1191
1253
  state.step === "loaded" && rules.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "No distribution rules available." }),
1192
1254
  rules.map((rule) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -1311,14 +1373,14 @@ function AssetItem({
1311
1373
  !isNative && record.enabledInApp && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-asset-sponsor", children: record.sponsored ? "Reserve sponsored by the app" : "You pay the reserve (~0.5 XLM)" })
1312
1374
  ] }),
1313
1375
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-asset-actions", children: [
1314
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: `pollar-asset-trustline${established ? " established" : ""}`, children: established ? "Trustline active" : "Needs trustline" }),
1376
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `pollar-asset-trustline${established ? " pollar-established" : ""}`, children: established ? "Trustline active" : "Needs trustline" }),
1315
1377
  !isNative && /* @__PURE__ */ jsxRuntime.jsx(
1316
1378
  "button",
1317
1379
  {
1318
- className: `pollar-asset-btn${established ? " danger" : ""}`,
1380
+ className: `pollar-asset-btn${established ? " pollar-danger" : ""}`,
1319
1381
  onClick: () => onToggle(record),
1320
1382
  disabled: busy || disabled,
1321
- children: busy ? "\u2026" : established ? "Disable" : "Enable"
1383
+ children: busy ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm pollar-spinner-current" }) : established ? "Disable" : "Enable"
1322
1384
  }
1323
1385
  )
1324
1386
  ] })
@@ -1351,29 +1413,46 @@ function EnabledAssetsModalTemplate({
1351
1413
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
1352
1414
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Trustlines" }),
1353
1415
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
1354
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-modal-refresh-btn", onClick: onRefresh, disabled: isLoading || busy, children: [
1355
- /* @__PURE__ */ jsxRuntime.jsxs(
1356
- "svg",
1357
- {
1358
- className: `pollar-modal-refresh-icon${isLoading ? " spinning" : ""}`,
1359
- width: "13",
1360
- height: "13",
1361
- viewBox: "0 0 13 13",
1362
- fill: "none",
1363
- "aria-hidden": true,
1364
- children: [
1365
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11.5 6.5a5 5 0 11-1.5-3.536", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
1366
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 1v3h-3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
1367
- ]
1368
- }
1369
- ),
1370
- "Refresh"
1371
- ] }),
1416
+ /* @__PURE__ */ jsxRuntime.jsx(
1417
+ "button",
1418
+ {
1419
+ type: "button",
1420
+ className: "pollar-modal-close",
1421
+ onClick: onRefresh,
1422
+ disabled: isLoading || busy,
1423
+ "aria-label": "Refresh",
1424
+ title: "Refresh",
1425
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1426
+ "svg",
1427
+ {
1428
+ className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
1429
+ width: "16",
1430
+ height: "16",
1431
+ viewBox: "0 0 16 16",
1432
+ fill: "none",
1433
+ "aria-hidden": true,
1434
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1435
+ "path",
1436
+ {
1437
+ d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
1438
+ stroke: "currentColor",
1439
+ strokeWidth: "1.6",
1440
+ strokeLinecap: "round",
1441
+ strokeLinejoin: "round"
1442
+ }
1443
+ )
1444
+ }
1445
+ )
1446
+ }
1447
+ ),
1372
1448
  /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
1373
1449
  ] })
1374
1450
  ] }),
1375
1451
  walletAddress && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-asset-address", children: cropAddress(walletAddress) }),
1376
- isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
1452
+ isLoading && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-loading-block", children: [
1453
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-spinner" }),
1454
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Loading\u2026" })
1455
+ ] }),
1377
1456
  enabledAssets.step === "error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: enabledAssets.message }),
1378
1457
  actionError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-action-error", children: actionError }),
1379
1458
  data && !data.exists && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-empty", children: [
@@ -1432,7 +1511,7 @@ function CustomTrustlineModalTemplate({
1432
1511
  children: [
1433
1512
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
1434
1513
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
1435
- /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-modal-back", onClick: onBack, disabled: busy, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
1514
+ /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-modal-close", onClick: onBack, disabled: busy, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
1436
1515
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Add custom trustline" })
1437
1516
  ] }),
1438
1517
  /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
@@ -1493,7 +1572,10 @@ function CustomTrustlineModalTemplate({
1493
1572
  )
1494
1573
  ] }),
1495
1574
  actionError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-action-error", children: actionError }),
1496
- /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-asset-submit", onClick: submit, disabled: !canSubmit, children: busy ? "Enabling\u2026" : "Enable trustline" }),
1575
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: submit, disabled: !canSubmit, children: busy ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1576
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
1577
+ "Enabling\u2026"
1578
+ ] }) : "Enable trustline" }) }),
1497
1579
  /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
1498
1580
  ]
1499
1581
  }
@@ -1614,6 +1696,7 @@ function KycModalTemplate({
1614
1696
  isLoading,
1615
1697
  onSelectProvider,
1616
1698
  onDoneVerifying,
1699
+ onRefresh,
1617
1700
  onClose
1618
1701
  }) {
1619
1702
  const isDark = theme === "dark";
@@ -1638,16 +1721,56 @@ function KycModalTemplate({
1638
1721
  "--pollar-modal-subtitle-size": "0.9rem"
1639
1722
  };
1640
1723
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-kyc-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
1641
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-kyc-header", children: [
1642
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-kyc-title", children: "Identity verification" }),
1643
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-kyc-subtitle", children: [
1644
- step === "select_provider" && "Choose your verification provider",
1645
- step === "verifying" && `Verifying with ${selectedProvider?.name}`,
1646
- step === "polling" && "Waiting for verification result",
1647
- step === "done" && "Verification complete"
1724
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
1725
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-kyc-header-text", children: [
1726
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Identity verification" }),
1727
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-kyc-subtitle", children: [
1728
+ step === "select_provider" && "Choose your verification provider",
1729
+ step === "verifying" && `Verifying with ${selectedProvider?.name}`,
1730
+ step === "polling" && "Waiting for verification result",
1731
+ step === "done" && "Verification complete"
1732
+ ] })
1733
+ ] }),
1734
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
1735
+ step === "select_provider" && /* @__PURE__ */ jsxRuntime.jsx(
1736
+ "button",
1737
+ {
1738
+ type: "button",
1739
+ className: "pollar-modal-close",
1740
+ onClick: onRefresh,
1741
+ disabled: isLoading,
1742
+ "aria-label": "Refresh",
1743
+ title: "Refresh providers",
1744
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1745
+ "svg",
1746
+ {
1747
+ className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
1748
+ width: "16",
1749
+ height: "16",
1750
+ viewBox: "0 0 16 16",
1751
+ fill: "none",
1752
+ "aria-hidden": true,
1753
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1754
+ "path",
1755
+ {
1756
+ d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
1757
+ stroke: "currentColor",
1758
+ strokeWidth: "1.6",
1759
+ strokeLinecap: "round",
1760
+ strokeLinejoin: "round"
1761
+ }
1762
+ )
1763
+ }
1764
+ )
1765
+ }
1766
+ ),
1767
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
1648
1768
  ] })
1649
1769
  ] }),
1650
- step === "select_provider" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-kyc-providers", children: [
1770
+ step === "select_provider" && (isLoading && providers.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-loading-block", children: [
1771
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-spinner" }),
1772
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Loading providers\u2026" })
1773
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-kyc-providers", children: [
1651
1774
  providers.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "var(--pollar-muted)", textAlign: "center" }, children: "No providers available for your country." }),
1652
1775
  providers.map((p) => /* @__PURE__ */ jsxRuntime.jsxs(
1653
1776
  "button",
@@ -1663,7 +1786,7 @@ function KycModalTemplate({
1663
1786
  },
1664
1787
  p.id
1665
1788
  ))
1666
- ] }),
1789
+ ] })),
1667
1790
  step === "verifying" && selectedProvider && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1668
1791
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-kyc-iframe-wrap", children: session?.kycUrl ? /* @__PURE__ */ jsxRuntime.jsx("iframe", { className: "pollar-kyc-iframe", src: session.kycUrl, title: "KYC verification", allow: "camera; microphone" }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-kyc-iframe-mock", children: [
1669
1792
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u{1F512}" }),
@@ -1696,10 +1819,13 @@ function KycModal({ onClose, country = "MX", level = "basic", onApproved }) {
1696
1819
  const [isLoading, setIsLoading] = react.useState(false);
1697
1820
  const client = getClient();
1698
1821
  const { theme = "light", accentColor = "#005DB4" } = styles;
1699
- react.useEffect(() => {
1822
+ const loadProviders = react.useCallback(() => {
1700
1823
  setIsLoading(true);
1701
- getClient().getKycProviders(country).then((result) => setProviders(result.providers)).catch(() => setProviders([])).finally(() => setIsLoading(false));
1824
+ return getClient().getKycProviders(country).then((result) => setProviders(result.providers)).catch(() => setProviders([])).finally(() => setIsLoading(false));
1702
1825
  }, [getClient, country]);
1826
+ react.useEffect(() => {
1827
+ void loadProviders();
1828
+ }, [loadProviders]);
1703
1829
  async function handleSelectProvider(provider) {
1704
1830
  setSelectedProvider(provider);
1705
1831
  setIsLoading(true);
@@ -1745,6 +1871,7 @@ function KycModal({ onClose, country = "MX", level = "basic", onApproved }) {
1745
1871
  isLoading,
1746
1872
  onSelectProvider: handleSelectProvider,
1747
1873
  onDoneVerifying: handleDoneVerifying,
1874
+ onRefresh: () => void loadProviders(),
1748
1875
  onClose
1749
1876
  }
1750
1877
  ) });
@@ -1800,8 +1927,8 @@ function EmailCodeInput({ email, onSubmit }) {
1800
1927
  ] });
1801
1928
  }
1802
1929
  var GithubButton = ({ disabled, onClick }) => {
1803
- return /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "github-button", disabled, onClick, children: [
1804
- /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "github-button-icon", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
1930
+ return /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-github-button", disabled, onClick, children: [
1931
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "pollar-github-button-icon", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
1805
1932
  "path",
1806
1933
  {
1807
1934
  fillRule: "evenodd",
@@ -1809,14 +1936,14 @@ var GithubButton = ({ disabled, onClick }) => {
1809
1936
  clipRule: "evenodd"
1810
1937
  }
1811
1938
  ) }),
1812
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "github-button-contents", children: "GitHub" })
1939
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-github-button-contents", children: "GitHub" })
1813
1940
  ] });
1814
1941
  };
1815
1942
  var GoogleButton = ({ disabled, onClick }) => {
1816
- return /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "gsi-material-button", disabled, onClick, children: [
1817
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "gsi-material-button-state" }),
1818
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "gsi-material-button-content-wrapper", children: [
1819
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "gsi-material-button-icon", children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { version: "1.1", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48", style: { display: "block" }, children: [
1943
+ return /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-gsi-material-button", disabled, onClick, children: [
1944
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-gsi-material-button-state" }),
1945
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-gsi-material-button-content-wrapper", children: [
1946
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-gsi-material-button-icon", children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { version: "1.1", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48", style: { display: "block" }, children: [
1820
1947
  /* @__PURE__ */ jsxRuntime.jsx(
1821
1948
  "path",
1822
1949
  {
@@ -1847,7 +1974,7 @@ var GoogleButton = ({ disabled, onClick }) => {
1847
1974
  ),
1848
1975
  /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "none", d: "M0 0h48v48H0z" })
1849
1976
  ] }) }),
1850
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "gsi-material-button-contents", children: "Google" }),
1977
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-gsi-material-button-contents", children: "Google" }),
1851
1978
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: { display: "none" }, children: "Google" })
1852
1979
  ] })
1853
1980
  ] });
@@ -2053,7 +2180,7 @@ function LoginModalTemplate({
2053
2180
  placeholder: "you@email.com",
2054
2181
  value: email,
2055
2182
  disabled: isLoading,
2056
- className: "pollar-email-input",
2183
+ className: "pollar-input",
2057
2184
  onChange: (e) => onEmailChange?.(e.target.value),
2058
2185
  onKeyDown: (e) => e.key === "Enter" && onEmailSubmit?.()
2059
2186
  }
@@ -2232,12 +2359,38 @@ function PrivyLoginSubmodal({
2232
2359
  fail(error);
2233
2360
  }
2234
2361
  }
2235
- const BackButton = ({ onClick }) => /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-back-btn", onClick, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15 19l-7-7 7-7" }) }) });
2362
+ const BackButton = ({ onClick }) => /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-back-btn", onClick, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx(
2363
+ "svg",
2364
+ {
2365
+ width: "20",
2366
+ height: "20",
2367
+ viewBox: "0 0 24 24",
2368
+ fill: "none",
2369
+ stroke: "currentColor",
2370
+ strokeWidth: "2.5",
2371
+ strokeLinecap: "round",
2372
+ strokeLinejoin: "round",
2373
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15 19l-7-7 7-7" })
2374
+ }
2375
+ ) });
2236
2376
  const showEmail = options.includes("email");
2237
2377
  const showGoogle = options.includes("google");
2238
2378
  const showGithub = options.includes("github");
2239
2379
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
2240
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-close-btn", onClick: onCancel, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12" }) }) }),
2380
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-close-btn", onClick: onCancel, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(
2381
+ "svg",
2382
+ {
2383
+ width: "18",
2384
+ height: "18",
2385
+ viewBox: "0 0 24 24",
2386
+ fill: "none",
2387
+ stroke: "currentColor",
2388
+ strokeWidth: "2.5",
2389
+ strokeLinecap: "round",
2390
+ strokeLinejoin: "round",
2391
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12" })
2392
+ }
2393
+ ) }),
2241
2394
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-header", children: [
2242
2395
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-logo-wrap", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: logoUrl ?? LOGO_POLLAR, alt: "Logo", className: "pollar-logo" }) }),
2243
2396
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-title", children: appName }),
@@ -2256,7 +2409,7 @@ function PrivyLoginSubmodal({
2256
2409
  placeholder: "you@email.com",
2257
2410
  value: email,
2258
2411
  disabled: isLoading,
2259
- className: "pollar-email-input",
2412
+ className: "pollar-input",
2260
2413
  onChange: (e) => setEmail(e.target.value),
2261
2414
  onKeyDown: (e) => e.key === "Enter" && handleEmailSubmit()
2262
2415
  }
@@ -2458,6 +2611,13 @@ function RouteDisplay({ quote, onSelect }) {
2458
2611
  }
2459
2612
  );
2460
2613
  }
2614
+ var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
2615
+ function isFieldValid(spec, raw) {
2616
+ const value = (raw ?? "").trim();
2617
+ if (!value) return false;
2618
+ if (spec.type === "email") return EMAIL_RE.test(value);
2619
+ return true;
2620
+ }
2461
2621
  var LOADING_STEPS = ["Detecting your country\u2026", "Consulting providers\u2026", "Route found!"];
2462
2622
  function flagEmoji(code) {
2463
2623
  const cc = code.trim().toUpperCase();
@@ -2471,6 +2631,43 @@ var STATUS_LABEL = {
2471
2631
  completed: "Completed",
2472
2632
  failed: "Failed"
2473
2633
  };
2634
+ var INSTRUCTION_LABELS = {
2635
+ br_code: "Pix code",
2636
+ account_holder_name: "Account holder",
2637
+ bank_name: "Bank",
2638
+ bank_address: "Bank address",
2639
+ bank_account_number: "Account number",
2640
+ bank_routing_number: "Routing number",
2641
+ iban: "IBAN",
2642
+ bic: "BIC",
2643
+ clabe: "CLABE",
2644
+ amount: "Amount",
2645
+ currency: "Currency",
2646
+ payment_rails: "Rails"
2647
+ };
2648
+ function flattenInstructions(instr) {
2649
+ const out = [];
2650
+ for (const [k, v] of Object.entries(instr)) {
2651
+ if (k === "qrBase64") {
2652
+ if (typeof v === "string" && v) out.push({ key: k, label: INSTRUCTION_LABELS[k] ?? "Payment QR", value: v, kind: "qr" });
2653
+ continue;
2654
+ }
2655
+ if ((k === "expiresAt" || k === "expires_at") && (typeof v === "number" || typeof v === "string")) {
2656
+ const ms = Number(v);
2657
+ if (Number.isFinite(ms) && ms > 0) {
2658
+ out.push({ key: k, label: INSTRUCTION_LABELS[k] ?? "Expires", value: new Date(ms).toLocaleString(), kind: "datetime" });
2659
+ }
2660
+ continue;
2661
+ }
2662
+ let value;
2663
+ if (typeof v === "string" || typeof v === "number") value = String(v);
2664
+ else if (Array.isArray(v)) value = v.filter((x) => typeof x === "string" || typeof x === "number").join(", ");
2665
+ else continue;
2666
+ if (!value) continue;
2667
+ out.push({ key: k, label: INSTRUCTION_LABELS[k] ?? k, value, kind: "text" });
2668
+ }
2669
+ return out;
2670
+ }
2474
2671
  function RampWidgetTemplate({
2475
2672
  theme,
2476
2673
  accentColor,
@@ -2479,6 +2676,8 @@ function RampWidgetTemplate({
2479
2676
  amount,
2480
2677
  currency,
2481
2678
  country,
2679
+ requiredFields,
2680
+ fieldValues,
2482
2681
  countries,
2483
2682
  countriesLoading,
2484
2683
  refreshing,
@@ -2487,17 +2686,22 @@ function RampWidgetTemplate({
2487
2686
  provider,
2488
2687
  txStatus,
2489
2688
  kycUrl,
2689
+ tosUrl,
2490
2690
  stellarTxHash,
2691
+ explorerUrl,
2692
+ depositInstructions,
2491
2693
  canComplete,
2492
2694
  completing,
2493
2695
  errorMsg,
2494
2696
  onDirectionChange,
2495
2697
  onAmountChange,
2496
- onCurrencyChange,
2698
+ onFieldChange,
2497
2699
  onCountryChange,
2498
2700
  onFindRoute,
2499
2701
  onSelectQuote,
2702
+ onContactContinue,
2500
2703
  onOpenKyc,
2704
+ onOpenTos,
2501
2705
  onCompleteWithdraw,
2502
2706
  onRetry,
2503
2707
  onRefresh,
@@ -2528,6 +2732,7 @@ function RampWidgetTemplate({
2528
2732
  input: direction === "onramp" ? "Buy crypto" : "Sell crypto",
2529
2733
  loading_quote: "Finding best route",
2530
2734
  select_route: "Select provider",
2735
+ contact: "Your details",
2531
2736
  status: direction === "onramp" ? "Complete your deposit" : "Complete your withdrawal",
2532
2737
  error: "Something went wrong"
2533
2738
  };
@@ -2535,6 +2740,7 @@ function RampWidgetTemplate({
2535
2740
  input: direction === "onramp" ? "Enter the amount you want to deposit" : "Enter the amount you want to withdraw",
2536
2741
  loading_quote: "Comparing providers in real time\u2026",
2537
2742
  select_route: "All prices include fees",
2743
+ contact: `${provider || "This provider"} needs your name and email to verify you`,
2538
2744
  status: `Finish the flow at ${provider || "the provider"} to continue`,
2539
2745
  error: "Please try again"
2540
2746
  };
@@ -2548,7 +2754,7 @@ function RampWidgetTemplate({
2548
2754
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onRefresh, disabled: refreshing, "aria-label": "Refresh", children: /* @__PURE__ */ jsxRuntime.jsx(
2549
2755
  "svg",
2550
2756
  {
2551
- className: refreshing ? "pollar-modal-refresh-icon spinning" : "pollar-modal-refresh-icon",
2757
+ className: refreshing ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
2552
2758
  width: "16",
2553
2759
  height: "16",
2554
2760
  viewBox: "0 0 16 16",
@@ -2570,12 +2776,12 @@ function RampWidgetTemplate({
2570
2776
  ] })
2571
2777
  ] }),
2572
2778
  step === "input" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2573
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-tabs", children: [
2779
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tabs", children: [
2574
2780
  /* @__PURE__ */ jsxRuntime.jsx(
2575
2781
  "button",
2576
2782
  {
2577
2783
  type: "button",
2578
- className: "pollar-ramp-tab",
2784
+ className: "pollar-tab",
2579
2785
  "data-active": direction === "onramp",
2580
2786
  onClick: () => onDirectionChange("onramp"),
2581
2787
  children: "Buy"
@@ -2585,52 +2791,42 @@ function RampWidgetTemplate({
2585
2791
  "button",
2586
2792
  {
2587
2793
  type: "button",
2588
- className: "pollar-ramp-tab",
2794
+ className: "pollar-tab",
2589
2795
  "data-active": direction === "offramp",
2590
2796
  onClick: () => onDirectionChange("offramp"),
2591
2797
  children: "Sell"
2592
2798
  }
2593
2799
  )
2594
2800
  ] }),
2595
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-input-row", children: [
2596
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-field", children: [
2597
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-ramp-label", children: "Amount" }),
2598
- /* @__PURE__ */ jsxRuntime.jsx(
2599
- "input",
2600
- {
2601
- type: "number",
2602
- className: "pollar-ramp-input",
2603
- placeholder: "0.00",
2604
- value: amount,
2605
- min: "0",
2606
- onChange: (e) => onAmountChange(e.target.value)
2607
- }
2608
- )
2609
- ] }),
2610
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-field", style: { maxWidth: 90 }, children: [
2611
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-ramp-label", children: "Currency" }),
2612
- /* @__PURE__ */ jsxRuntime.jsx(
2613
- "input",
2614
- {
2615
- type: "text",
2616
- className: "pollar-ramp-input",
2617
- placeholder: "MXN",
2618
- value: currency,
2619
- maxLength: 5,
2620
- onChange: (e) => onCurrencyChange(e.target.value.toUpperCase())
2621
- }
2622
- )
2623
- ] })
2624
- ] }),
2625
2801
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-field", children: [
2626
2802
  /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-ramp-label", children: "Country" }),
2627
- countriesLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-input pollar-ramp-input-loading", children: "Loading countries\u2026" }) : countries.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "No ramp providers available on this network yet." }) : /* @__PURE__ */ jsxRuntime.jsx("select", { className: "pollar-ramp-input", value: country, onChange: (e) => onCountryChange(e.target.value), children: countries.map((c) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: c.code, children: [
2803
+ countriesLoading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-input pollar-ramp-input-loading", children: [
2804
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
2805
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Loading countries\u2026" })
2806
+ ] }) : countries.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "No ramp providers available on this network yet." }) : /* @__PURE__ */ jsxRuntime.jsx("select", { className: "pollar-ramp-input", value: country, onChange: (e) => onCountryChange(e.target.value), children: countries.map((c) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: c.code, children: [
2628
2807
  flagEmoji(c.code),
2629
2808
  " ",
2630
2809
  c.code,
2631
2810
  c.currency ? ` \u2014 ${c.currency}` : ""
2632
2811
  ] }, c.code)) })
2633
2812
  ] }),
2813
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-field", children: [
2814
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "pollar-ramp-label", children: [
2815
+ "Amount",
2816
+ currency ? ` (${currency})` : ""
2817
+ ] }),
2818
+ /* @__PURE__ */ jsxRuntime.jsx(
2819
+ "input",
2820
+ {
2821
+ type: "number",
2822
+ className: "pollar-ramp-input",
2823
+ placeholder: "0.00",
2824
+ value: amount,
2825
+ min: "0",
2826
+ onChange: (e) => onAmountChange(e.target.value)
2827
+ }
2828
+ )
2829
+ ] }),
2634
2830
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-actions", children: [
2635
2831
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onClose, children: "Cancel" }),
2636
2832
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2645,14 +2841,60 @@ function RampWidgetTemplate({
2645
2841
  )
2646
2842
  ] })
2647
2843
  ] }),
2648
- step === "loading_quote" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-loading", children: LOADING_STEPS.map((text, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-loading-row", children: [
2649
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-loading-dot" }),
2650
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: text })
2651
- ] }, i)) }),
2844
+ step === "loading_quote" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-loading", children: [
2845
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-spinner pollar-ramp-loading-spinner" }),
2846
+ LOADING_STEPS.map((text, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-loading-row", children: [
2847
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-loading-dot" }),
2848
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: text })
2849
+ ] }, i))
2850
+ ] }),
2652
2851
  step === "select_route" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2653
2852
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-route-list", children: quotes.map((q, i) => /* @__PURE__ */ jsxRuntime.jsx(RouteDisplay, { quote: q, onSelect: onSelectQuote }, i)) }),
2654
2853
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onClose, children: "Cancel" })
2655
2854
  ] }),
2855
+ step === "contact" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2856
+ requiredFields.map((f) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-field", children: [
2857
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-ramp-label", children: f.label }),
2858
+ f.type === "select" ? /* @__PURE__ */ jsxRuntime.jsxs(
2859
+ "select",
2860
+ {
2861
+ className: "pollar-ramp-input",
2862
+ value: fieldValues[f.key] ?? "",
2863
+ onChange: (e) => onFieldChange(f.key, e.target.value),
2864
+ children: [
2865
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, children: "Select\u2026" }),
2866
+ (f.options ?? []).map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value))
2867
+ ]
2868
+ }
2869
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
2870
+ "input",
2871
+ {
2872
+ type: f.type,
2873
+ className: "pollar-ramp-input",
2874
+ value: fieldValues[f.key] ?? "",
2875
+ autoComplete: f.type === "email" ? "email" : "off",
2876
+ onChange: (e) => onFieldChange(f.key, e.target.value)
2877
+ }
2878
+ ),
2879
+ f.type === "email" && (fieldValues[f.key] ?? "").trim() !== "" && !isFieldValid(f, fieldValues[f.key]) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-field-error", children: "Enter a valid email address." })
2880
+ ] }, f.key)),
2881
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-actions", children: [
2882
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onRetry, children: "Back" }),
2883
+ /* @__PURE__ */ jsxRuntime.jsx(
2884
+ "button",
2885
+ {
2886
+ type: "button",
2887
+ className: "pollar-btn-primary",
2888
+ disabled: requiredFields.some((f) => !isFieldValid(f, fieldValues[f.key])) || isLoading,
2889
+ onClick: onContactContinue,
2890
+ children: isLoading ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2891
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
2892
+ "Starting\u2026"
2893
+ ] }) : "Continue"
2894
+ }
2895
+ )
2896
+ ] })
2897
+ ] }),
2656
2898
  step === "status" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment", children: [
2657
2899
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
2658
2900
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: "Provider" }),
@@ -2660,21 +2902,81 @@ function RampWidgetTemplate({
2660
2902
  ] }),
2661
2903
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
2662
2904
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: "Status" }),
2663
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-payment-value", children: /* @__PURE__ */ jsxRuntime.jsx("code", { style: { color: txStatus === "completed" ? "var(--pollar-success-text)" : void 0 }, children: txStatus ? STATUS_LABEL[txStatus] : "Processing" }) })
2905
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-value", children: [
2906
+ /* @__PURE__ */ jsxRuntime.jsx("code", { style: { color: txStatus === "completed" ? "var(--pollar-success-text)" : void 0 }, children: txStatus ? STATUS_LABEL[txStatus] : "Processing" }),
2907
+ txStatus !== "completed" && txStatus !== "failed" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-label": "Checking status" })
2908
+ ] })
2664
2909
  ] }),
2665
2910
  stellarTxHash && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
2666
2911
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: "Stellar tx" }),
2667
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-payment-value", children: /* @__PURE__ */ jsxRuntime.jsxs("code", { children: [
2668
- stellarTxHash.slice(0, 8),
2669
- "\u2026",
2670
- stellarTxHash.slice(-8)
2912
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-value", style: { display: "flex", alignItems: "center", gap: 6 }, children: [
2913
+ /* @__PURE__ */ jsxRuntime.jsxs("code", { style: { flex: 1, wordBreak: "break-all" }, children: [
2914
+ stellarTxHash.slice(0, 8),
2915
+ "\u2026",
2916
+ stellarTxHash.slice(-8)
2917
+ ] }),
2918
+ /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value: stellarTxHash, label: "Copy transaction hash" }),
2919
+ explorerUrl && /* @__PURE__ */ jsxRuntime.jsx(
2920
+ "a",
2921
+ {
2922
+ href: explorerUrl,
2923
+ target: "_blank",
2924
+ rel: "noopener noreferrer",
2925
+ className: "pollar-copy-btn",
2926
+ "aria-label": "View on Stellar Expert",
2927
+ title: "View on Stellar Expert",
2928
+ children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
2929
+ /* @__PURE__ */ jsxRuntime.jsx(
2930
+ "path",
2931
+ {
2932
+ d: "M6 3H3v8h8V8",
2933
+ stroke: "currentColor",
2934
+ strokeWidth: "1.5",
2935
+ strokeLinecap: "round",
2936
+ strokeLinejoin: "round"
2937
+ }
2938
+ ),
2939
+ /* @__PURE__ */ jsxRuntime.jsx(
2940
+ "path",
2941
+ {
2942
+ d: "M8.5 2.5h3v3M11 3L6.5 7.5",
2943
+ stroke: "currentColor",
2944
+ strokeWidth: "1.5",
2945
+ strokeLinecap: "round",
2946
+ strokeLinejoin: "round"
2947
+ }
2948
+ )
2949
+ ] })
2950
+ }
2951
+ )
2952
+ ] })
2953
+ ] }),
2954
+ depositInstructions && txStatus !== "completed" && flattenInstructions(depositInstructions).map(({ key, label, value, kind }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
2955
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: label }),
2956
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-payment-value", children: kind === "qr" ? /* @__PURE__ */ jsxRuntime.jsx(
2957
+ "img",
2958
+ {
2959
+ src: value.startsWith("data:") ? value : `data:image/png;base64,${value}`,
2960
+ alt: label,
2961
+ style: { width: "100%", maxWidth: 220, height: "auto", display: "block", margin: "0 auto" }
2962
+ }
2963
+ ) : kind === "datetime" ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: value }) : /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
2964
+ /* @__PURE__ */ jsxRuntime.jsx("code", { style: { flex: 1, wordBreak: "break-all" }, children: value }),
2965
+ /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value, label: `Copy ${label}` })
2671
2966
  ] }) })
2967
+ ] }, key)),
2968
+ tosUrl && !depositInstructions && txStatus !== "completed" && /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-btn-primary", onClick: onOpenTos, children: [
2969
+ "Accept terms at ",
2970
+ provider
2672
2971
  ] }),
2673
- kycUrl && txStatus !== "completed" && /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-btn-primary", onClick: onOpenKyc, children: [
2972
+ kycUrl && !depositInstructions && txStatus !== "completed" && /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-btn-primary", onClick: onOpenKyc, children: [
2674
2973
  "Continue at ",
2675
2974
  provider
2676
2975
  ] }),
2677
- canComplete && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", disabled: completing, onClick: onCompleteWithdraw, children: completing ? "Submitting\u2026" : "I've completed KYC \u2014 withdraw" }),
2976
+ canComplete && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", disabled: completing, onClick: onCompleteWithdraw, children: completing ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2977
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
2978
+ "Submitting\u2026"
2979
+ ] }) : "I've completed KYC \u2014 withdraw" }),
2678
2980
  errorMsg && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", style: { color: "var(--pollar-error-text)" }, children: errorMsg }),
2679
2981
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onClose, children: txStatus === "completed" ? "Done" : "Close" })
2680
2982
  ] }),
@@ -2688,8 +2990,11 @@ function RampWidgetTemplate({
2688
2990
  ] });
2689
2991
  }
2690
2992
  var TERMINAL = ["completed", "failed"];
2993
+ function requiredFieldsOf(quote) {
2994
+ return quote.requiredFields ?? [];
2995
+ }
2691
2996
  function RampWidget({ onClose }) {
2692
- const { getClient, signTx, wallet, styles } = usePollar();
2997
+ const { getClient, signTx, wallet, styles, network } = usePollar();
2693
2998
  const walletAddress = wallet?.address ?? "";
2694
2999
  const client = getClient();
2695
3000
  const { theme = "light", accentColor = "#005DB4" } = styles;
@@ -2698,16 +3003,21 @@ function RampWidget({ onClose }) {
2698
3003
  const [amount, setAmount] = react.useState("");
2699
3004
  const [currency, setCurrency] = react.useState("");
2700
3005
  const [country, setCountry] = react.useState("");
3006
+ const [fieldValues, setFieldValues] = react.useState({});
3007
+ const setFieldValue = (key, value) => setFieldValues((v) => ({ ...v, [key]: value }));
2701
3008
  const [countries, setCountries] = react.useState([]);
2702
3009
  const [countriesLoading, setCountriesLoading] = react.useState(true);
2703
3010
  const [refreshing, setRefreshing] = react.useState(false);
2704
3011
  const [quotes, setQuotes] = react.useState([]);
3012
+ const [selectedQuote, setSelectedQuote] = react.useState(null);
2705
3013
  const [isLoading, setIsLoading] = react.useState(false);
2706
3014
  const [txId, setTxId] = react.useState(null);
2707
3015
  const [provider, setProvider] = react.useState("");
2708
3016
  const [kycUrl, setKycUrl] = react.useState(null);
3017
+ const [tosUrl, setTosUrl] = react.useState(null);
2709
3018
  const [txStatus, setTxStatus] = react.useState(null);
2710
3019
  const [stellarTxHash, setStellarTxHash] = react.useState(null);
3020
+ const [depositInstructions, setDepositInstructions] = react.useState(null);
2711
3021
  const [completing, setCompleting] = react.useState(false);
2712
3022
  const [errorMsg, setErrorMsg] = react.useState(null);
2713
3023
  const directionRef = react.useRef(direction);
@@ -2723,6 +3033,7 @@ function RampWidget({ onClose }) {
2723
3033
  setTxStatus(tx.status);
2724
3034
  if (tx.stellarTxHash) setStellarTxHash(tx.stellarTxHash);
2725
3035
  if (tx.kycUrl) setKycUrl(tx.kycUrl);
3036
+ if (tx.depositInstructions) setDepositInstructions(tx.depositInstructions);
2726
3037
  if (TERMINAL.includes(tx.status)) clearInterval(id);
2727
3038
  } catch {
2728
3039
  }
@@ -2770,6 +3081,7 @@ function RampWidget({ onClose }) {
2770
3081
  setTxStatus(tx.status);
2771
3082
  if (tx.stellarTxHash) setStellarTxHash(tx.stellarTxHash);
2772
3083
  if (tx.kycUrl) setKycUrl(tx.kycUrl);
3084
+ if (tx.depositInstructions) setDepositInstructions(tx.depositInstructions);
2773
3085
  }
2774
3086
  } catch {
2775
3087
  } finally {
@@ -2779,11 +3091,15 @@ function RampWidget({ onClose }) {
2779
3091
  function resetToInput() {
2780
3092
  setStep("input");
2781
3093
  setQuotes([]);
3094
+ setSelectedQuote(null);
3095
+ setFieldValues({});
2782
3096
  setTxId(null);
2783
3097
  setProvider("");
2784
3098
  setKycUrl(null);
3099
+ setTosUrl(null);
2785
3100
  setTxStatus(null);
2786
3101
  setStellarTxHash(null);
3102
+ setDepositInstructions(null);
2787
3103
  setErrorMsg(null);
2788
3104
  }
2789
3105
  async function resumeWithSignature(id, ps) {
@@ -2807,8 +3123,10 @@ function RampWidget({ onClose }) {
2807
3123
  return;
2808
3124
  }
2809
3125
  setKycUrl(result.kycUrl ?? null);
3126
+ setTosUrl(result.tosUrl ?? null);
2810
3127
  setTxStatus(result.status);
2811
3128
  setStellarTxHash(result.stellarTxHash ?? null);
3129
+ setDepositInstructions(result.depositInstructions ?? null);
2812
3130
  setStep("status");
2813
3131
  }
2814
3132
  async function handleFindRoute() {
@@ -2832,12 +3150,37 @@ function RampWidget({ onClose }) {
2832
3150
  setIsLoading(false);
2833
3151
  }
2834
3152
  }
2835
- async function handleSelectQuote(quote) {
3153
+ function handleSelectQuote(quote) {
3154
+ setSelectedQuote(quote);
3155
+ setErrorMsg(null);
3156
+ const fields = requiredFieldsOf(quote);
3157
+ const missing = fields.some((f) => !(fieldValues[f.key] ?? "").trim());
3158
+ if (fields.length > 0 && missing) {
3159
+ setStep("contact");
3160
+ return;
3161
+ }
3162
+ void startRamp(quote);
3163
+ }
3164
+ function handleContactContinue() {
3165
+ if (selectedQuote) void startRamp(selectedQuote);
3166
+ }
3167
+ async function startRamp(quote) {
2836
3168
  setIsLoading(true);
2837
3169
  setErrorMsg(null);
2838
3170
  try {
2839
3171
  const base = { quoteId: quote.quoteId, amount: Number(amount), currency, country };
2840
- const result = direction === "onramp" ? await client.createOnRamp({ ...base, ...walletAddress ? { walletAddress } : {} }) : await client.createOffRamp({ ...base, ...walletAddress ? { walletAddress } : {} });
3172
+ if (walletAddress) base.walletAddress = walletAddress;
3173
+ const STANDARD_BODY_KEYS = /* @__PURE__ */ new Set(["email", "fullName", "taxId", "qrCode"]);
3174
+ const extraFields = {};
3175
+ for (const f of requiredFieldsOf(quote)) {
3176
+ const val = (fieldValues[f.key] ?? "").trim();
3177
+ if (!val) continue;
3178
+ if (f.bankType) base.bankDetails = { type: f.bankType, value: val };
3179
+ else if (STANDARD_BODY_KEYS.has(f.key)) base[f.key] = val;
3180
+ else extraFields[f.key] = val;
3181
+ }
3182
+ if (Object.keys(extraFields).length > 0) base.fields = extraFields;
3183
+ const result = direction === "onramp" ? await client.createOnRamp(base) : await client.createOffRamp(base);
2841
3184
  await applyResult(result);
2842
3185
  } catch (e) {
2843
3186
  setErrorMsg(e instanceof Error ? e.message : "Failed to start the ramp.");
@@ -2849,6 +3192,9 @@ function RampWidget({ onClose }) {
2849
3192
  function handleOpenKyc() {
2850
3193
  if (kycUrl) window.open(kycUrl, "_blank", "noopener,noreferrer");
2851
3194
  }
3195
+ function handleOpenTos() {
3196
+ if (tosUrl) window.open(tosUrl, "_blank", "noopener,noreferrer");
3197
+ }
2852
3198
  async function handleCompleteWithdraw() {
2853
3199
  if (!txId) return;
2854
3200
  setCompleting(true);
@@ -2881,6 +3227,8 @@ function RampWidget({ onClose }) {
2881
3227
  amount,
2882
3228
  currency,
2883
3229
  country,
3230
+ requiredFields: selectedQuote ? requiredFieldsOf(selectedQuote) : [],
3231
+ fieldValues,
2884
3232
  countries,
2885
3233
  countriesLoading,
2886
3234
  refreshing,
@@ -2889,17 +3237,22 @@ function RampWidget({ onClose }) {
2889
3237
  provider,
2890
3238
  txStatus,
2891
3239
  kycUrl,
3240
+ tosUrl,
2892
3241
  stellarTxHash,
3242
+ explorerUrl: stellarTxHash ? `https://stellar.expert/explorer/${network === "mainnet" ? "public" : "testnet"}/tx/${stellarTxHash}` : null,
3243
+ depositInstructions,
2893
3244
  canComplete,
2894
3245
  completing,
2895
3246
  errorMsg,
2896
3247
  onDirectionChange: setDirection,
2897
3248
  onAmountChange: setAmount,
2898
- onCurrencyChange: setCurrency,
3249
+ onFieldChange: setFieldValue,
2899
3250
  onCountryChange: handleCountryChange,
2900
3251
  onFindRoute: handleFindRoute,
2901
3252
  onSelectQuote: handleSelectQuote,
3253
+ onContactContinue: handleContactContinue,
2902
3254
  onOpenKyc: handleOpenKyc,
3255
+ onOpenTos: handleOpenTos,
2903
3256
  onCompleteWithdraw: handleCompleteWithdraw,
2904
3257
  onRetry: resetToInput,
2905
3258
  onRefresh: handleRefresh,
@@ -3065,6 +3418,47 @@ function ReceiveModal({ onClose }) {
3065
3418
  }
3066
3419
  ) });
3067
3420
  }
3421
+ function formatAmount2(value) {
3422
+ const n = parseFloat(value);
3423
+ return isNaN(n) ? value : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
3424
+ }
3425
+ var optionLabel = (o) => o.available !== void 0 ? `${o.code} \u2014 ${formatAmount2(o.available)} available` : o.code;
3426
+ function AssetSelect({
3427
+ label,
3428
+ value,
3429
+ options,
3430
+ onChange,
3431
+ loading = false,
3432
+ loadingLabel,
3433
+ disabled = false,
3434
+ appGroupLabel = "App assets",
3435
+ otherGroupLabel = "Other assets",
3436
+ children
3437
+ }) {
3438
+ const appAssets = options.filter((o) => o.enabledInApp);
3439
+ const otherAssets = options.filter((o) => !o.enabledInApp);
3440
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
3441
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: label }),
3442
+ loading ? loadingLabel ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-input pollar-select-loading", children: [
3443
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
3444
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: loadingLabel })
3445
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxRuntime.jsxs(
3446
+ "select",
3447
+ {
3448
+ className: "pollar-input pollar-send-select",
3449
+ value,
3450
+ disabled,
3451
+ onChange: (e) => onChange(e.target.value),
3452
+ children: [
3453
+ value === "" && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, hidden: true }),
3454
+ appAssets.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("optgroup", { label: appGroupLabel, children: appAssets.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.key, children: optionLabel(o) }, o.key)) }),
3455
+ otherAssets.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("optgroup", { label: otherGroupLabel, children: otherAssets.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.key, children: optionLabel(o) }, o.key)) })
3456
+ ]
3457
+ }
3458
+ ),
3459
+ !loading && children
3460
+ ] });
3461
+ }
3068
3462
  var STATUS_MESSAGES = {
3069
3463
  idle: "",
3070
3464
  building: "Building transaction\u2026",
@@ -3289,6 +3683,7 @@ function SendModalTemplate({
3289
3683
  isInProgress,
3290
3684
  onClose,
3291
3685
  onBack,
3686
+ onRefresh,
3292
3687
  onSelectAsset,
3293
3688
  onAmountChange,
3294
3689
  onDestinationChange,
@@ -3317,8 +3712,6 @@ function SendModalTemplate({
3317
3712
  "--pollar-input-border-radius": "0.5rem",
3318
3713
  "--pollar-card-border-radius": "10px"
3319
3714
  };
3320
- const enabledAssets = assets.filter((a) => a.enabledInApp);
3321
- const otherAssets = assets.filter((a) => !a.enabledInApp);
3322
3715
  const selectedKey = selectedAsset ? assetKey3(selectedAsset) : "";
3323
3716
  const canSubmit = !!selectedAsset && !!amount && !!destination.trim() && !isLoadingBalance;
3324
3717
  const title = step === "form" ? "Send" : txTitle;
@@ -3335,39 +3728,61 @@ function SendModalTemplate({
3335
3728
  showBack && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onBack, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
3336
3729
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: title })
3337
3730
  ] }),
3338
- !isInProgress && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-header-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) }) })
3731
+ !isInProgress && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
3732
+ step === "form" && /* @__PURE__ */ jsxRuntime.jsx(
3733
+ "button",
3734
+ {
3735
+ type: "button",
3736
+ className: "pollar-modal-close",
3737
+ onClick: onRefresh,
3738
+ disabled: isLoadingBalance,
3739
+ "aria-label": "Refresh",
3740
+ title: "Refresh balances",
3741
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3742
+ "svg",
3743
+ {
3744
+ className: isLoadingBalance ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
3745
+ width: "16",
3746
+ height: "16",
3747
+ viewBox: "0 0 16 16",
3748
+ fill: "none",
3749
+ "aria-hidden": true,
3750
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3751
+ "path",
3752
+ {
3753
+ d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
3754
+ stroke: "currentColor",
3755
+ strokeWidth: "1.6",
3756
+ strokeLinecap: "round",
3757
+ strokeLinejoin: "round"
3758
+ }
3759
+ )
3760
+ }
3761
+ )
3762
+ }
3763
+ ),
3764
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
3765
+ ] })
3339
3766
  ] }),
3340
3767
  step === "form" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3341
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
3342
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "Asset" }),
3343
- isLoadingBalance ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxRuntime.jsxs(
3344
- "select",
3345
- {
3346
- className: "pollar-input pollar-send-select",
3347
- value: selectedKey,
3348
- onChange: (e) => {
3349
- const all = [...enabledAssets, ...otherAssets];
3350
- const found = all.find((a) => assetKey3(a) === e.target.value);
3351
- if (found) onSelectAsset(found);
3352
- },
3353
- children: [
3354
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, children: "Select asset" }),
3355
- enabledAssets.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("optgroup", { label: "App assets", children: enabledAssets.map((a) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: assetKey3(a), children: [
3356
- a.code,
3357
- " \u2014 ",
3358
- formatBalance(a.available),
3359
- " available"
3360
- ] }, assetKey3(a))) }),
3361
- otherAssets.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("optgroup", { label: "Other assets", children: otherAssets.map((a) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: assetKey3(a), children: [
3362
- a.code,
3363
- " \u2014 ",
3364
- formatBalance(a.available),
3365
- " available"
3366
- ] }, assetKey3(a))) })
3367
- ]
3768
+ /* @__PURE__ */ jsxRuntime.jsx(
3769
+ AssetSelect,
3770
+ {
3771
+ label: "Asset",
3772
+ value: selectedKey,
3773
+ loading: isLoadingBalance,
3774
+ options: assets.map((a) => ({
3775
+ key: assetKey3(a),
3776
+ code: a.code,
3777
+ available: a.available,
3778
+ enabledInApp: a.enabledInApp
3779
+ })),
3780
+ onChange: (key) => {
3781
+ const found = assets.find((a) => assetKey3(a) === key);
3782
+ if (found) onSelectAsset(found);
3368
3783
  }
3369
- )
3370
- ] }),
3784
+ }
3785
+ ),
3371
3786
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
3372
3787
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-label-row", children: [
3373
3788
  /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "Amount" }),
@@ -3467,13 +3882,16 @@ function SendModal({ onClose }) {
3467
3882
  const allAssets = balanceData?.balances ?? [];
3468
3883
  const sortedAssets = [
3469
3884
  ...allAssets.filter((b) => b.enabledInApp),
3470
- ...allAssets.filter((b) => !b.enabledInApp && parseFloat(b.balance) > 0)
3885
+ ...allAssets.filter((b) => !b.enabledInApp && (b.type === "native" || parseFloat(b.balance) > 0))
3471
3886
  ];
3887
+ react.useEffect(() => {
3888
+ if (!selectedAsset && sortedAssets.length > 0) setSelectedAsset(sortedAssets[0]);
3889
+ }, [sortedAssets, selectedAsset]);
3472
3890
  const hash = transaction.step === "success" ? transaction.hash : null;
3473
3891
  const buildData = "buildData" in transaction ? transaction.buildData : null;
3474
3892
  const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
3475
3893
  const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
3476
- const IN_FLIGHT_STEPS2 = [
3894
+ const IN_FLIGHT_STEPS3 = [
3477
3895
  "building",
3478
3896
  "signing",
3479
3897
  "submitting",
@@ -3481,7 +3899,7 @@ function SendModal({ onClose }) {
3481
3899
  "signing-submitting",
3482
3900
  "building-signing-submitting"
3483
3901
  ];
3484
- const isInProgress = IN_FLIGHT_STEPS2.includes(transaction.step);
3902
+ const isInProgress = IN_FLIGHT_STEPS3.includes(transaction.step);
3485
3903
  const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
3486
3904
  const txTitle = isInProgress ? "Sending\u2026" : transaction.step === "success" ? "Sent!" : transaction.step === "error" ? "Send failed" : "Confirm Send";
3487
3905
  async function handleSubmit() {
@@ -3554,6 +3972,7 @@ function SendModal({ onClose }) {
3554
3972
  isInProgress,
3555
3973
  onClose,
3556
3974
  onBack: handleBack,
3975
+ onRefresh: () => void refreshWalletBalance(),
3557
3976
  onSelectAsset: setSelectedAsset,
3558
3977
  onAmountChange: setAmount,
3559
3978
  onDestinationChange: setDestination,
@@ -3575,7 +3994,7 @@ var PROVIDER_LABELS = {
3575
3994
  soroswap: "Soroswap",
3576
3995
  sdex: "Stellar DEX"
3577
3996
  };
3578
- function formatAmount2(value) {
3997
+ function formatAmount3(value) {
3579
3998
  const n = parseFloat(value);
3580
3999
  return isNaN(n) ? value : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
3581
4000
  }
@@ -3658,214 +4077,233 @@ function SwapModalTemplate({
3658
4077
  const buyKey = selectedBuy ? assetOptionKey(selectedBuy) : "";
3659
4078
  const canSwap = !smartUnsupported && !!selectedSell && !!selectedBuy && !!amount && !!quote && !quoteLoading && !isLoadingData;
3660
4079
  const title = step === "form" ? "Swap" : txTitle;
3661
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-send-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
3662
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
3663
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-header-left", children: [
3664
- showBack && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onBack, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
3665
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: title })
3666
- ] }),
3667
- !isInProgress && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
3668
- step === "form" && /* @__PURE__ */ jsxRuntime.jsx(
3669
- "button",
3670
- {
3671
- type: "button",
3672
- className: "pollar-modal-close",
3673
- onClick: onRefresh,
3674
- disabled: configLoading || isLoadingData,
3675
- "aria-label": "Refresh",
3676
- title: "Refresh balances and options",
3677
- children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
3678
- "path",
4080
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4081
+ "div",
4082
+ {
4083
+ className: "pollar-modal-card pollar-send-modal",
4084
+ "data-theme": theme,
4085
+ style: cssVars,
4086
+ onClick: (e) => e.stopPropagation(),
4087
+ children: [
4088
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
4089
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-header-left", children: [
4090
+ showBack && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onBack, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
4091
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: title })
4092
+ ] }),
4093
+ !isInProgress && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
4094
+ step === "form" && /* @__PURE__ */ jsxRuntime.jsx(
4095
+ "button",
3679
4096
  {
3680
- d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2.5v3h-3",
3681
- stroke: "currentColor",
3682
- strokeWidth: "1.6",
3683
- strokeLinecap: "round",
3684
- strokeLinejoin: "round"
4097
+ type: "button",
4098
+ className: "pollar-modal-close",
4099
+ onClick: onRefresh,
4100
+ disabled: configLoading || isLoadingData,
4101
+ "aria-label": "Refresh",
4102
+ title: "Refresh balances and options",
4103
+ children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
4104
+ "path",
4105
+ {
4106
+ d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2.5v3h-3",
4107
+ stroke: "currentColor",
4108
+ strokeWidth: "1.6",
4109
+ strokeLinecap: "round",
4110
+ strokeLinejoin: "round"
4111
+ }
4112
+ ) })
3685
4113
  }
3686
- ) })
3687
- }
3688
- ),
3689
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
3690
- ] })
3691
- ] }),
3692
- step === "form" && configLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-hint", children: "Loading swap options\u2026" }),
3693
- step === "form" && !configLoading && swapUnavailable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "Swap is not available for this app." }),
3694
- step === "form" && !configLoading && !swapUnavailable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3695
- smartUnsupported && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "Swaps are not yet available for smart (passkey) wallets." }),
3696
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
3697
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "You pay" }),
3698
- isLoadingData ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxRuntime.jsxs(
3699
- "select",
3700
- {
3701
- className: "pollar-input pollar-send-select",
3702
- value: sellKey,
3703
- onChange: (e) => {
3704
- const found = sellOptions.find((o) => assetOptionKey(o) === e.target.value);
3705
- if (found) onSelectSell(found);
3706
- },
3707
- children: [
3708
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, children: "Select asset to sell" }),
3709
- sellOptions.map((o) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: assetOptionKey(o), children: [
3710
- o.code,
3711
- o.available !== void 0 ? ` \u2014 ${formatAmount2(o.available)} available` : ""
3712
- ] }, assetOptionKey(o)))
3713
- ]
3714
- }
3715
- )
3716
- ] }),
3717
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
3718
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-label-row", children: [
3719
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "Amount" }),
3720
- selectedSell?.available !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-send-hint", children: [
3721
- "Available: ",
3722
- formatAmount2(selectedSell.available),
3723
- " ",
3724
- selectedSell.code
4114
+ ),
4115
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
3725
4116
  ] })
3726
4117
  ] }),
3727
- /* @__PURE__ */ jsxRuntime.jsx(
3728
- "input",
3729
- {
3730
- className: "pollar-input",
3731
- type: "text",
3732
- inputMode: "decimal",
3733
- placeholder: "0.00",
3734
- value: amount,
3735
- onChange: (e) => onAmountChange(e.target.value)
3736
- }
3737
- )
3738
- ] }),
3739
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
3740
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "You receive" }),
3741
- isLoadingData ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxRuntime.jsxs(
3742
- "select",
3743
- {
3744
- className: "pollar-input pollar-send-select",
3745
- value: buyKey,
3746
- onChange: (e) => {
3747
- const found = buyOptions.find((o) => assetOptionKey(o) === e.target.value);
3748
- if (found) onSelectBuy(found);
3749
- },
3750
- children: [
3751
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, children: "Select asset to buy" }),
3752
- buyOptions.map((o) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: assetOptionKey(o), children: [
3753
- o.code,
3754
- o.enabledInApp ? "" : " (external)"
3755
- ] }, assetOptionKey(o)))
3756
- ]
3757
- }
3758
- ),
3759
- !isLoadingData && (customOpen ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-custom", children: [
4118
+ step === "form" && !configLoading && swapUnavailable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "Swap is not available for this app." }),
4119
+ step === "form" && !swapUnavailable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4120
+ smartUnsupported && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "Swaps are not yet available for smart (passkey) wallets." }),
3760
4121
  /* @__PURE__ */ jsxRuntime.jsx(
3761
- "input",
4122
+ AssetSelect,
3762
4123
  {
3763
- className: "pollar-input",
3764
- type: "text",
3765
- placeholder: "Code (e.g. USDC)",
3766
- value: customCode,
3767
- onChange: (e) => setCustomCode(e.target.value)
4124
+ label: "You pay",
4125
+ value: sellKey,
4126
+ loading: isLoadingData || configLoading,
4127
+ loadingLabel: "Loading assets\u2026",
4128
+ disabled: configLoading,
4129
+ options: sellOptions.map((o) => ({
4130
+ key: assetOptionKey(o),
4131
+ code: o.code,
4132
+ available: o.available,
4133
+ enabledInApp: o.enabledInApp
4134
+ })),
4135
+ onChange: (key) => {
4136
+ const found = sellOptions.find((o) => assetOptionKey(o) === key);
4137
+ if (found) onSelectSell(found);
4138
+ }
3768
4139
  }
3769
4140
  ),
4141
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
4142
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-label-row", children: [
4143
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "Amount" }),
4144
+ selectedSell?.available !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-send-hint", children: [
4145
+ "Available: ",
4146
+ formatAmount3(selectedSell.available),
4147
+ " ",
4148
+ selectedSell.code
4149
+ ] })
4150
+ ] }),
4151
+ /* @__PURE__ */ jsxRuntime.jsx(
4152
+ "input",
4153
+ {
4154
+ className: "pollar-input",
4155
+ type: "text",
4156
+ inputMode: "decimal",
4157
+ placeholder: "0.00",
4158
+ value: amount,
4159
+ disabled: configLoading,
4160
+ onChange: (e) => onAmountChange(e.target.value)
4161
+ }
4162
+ )
4163
+ ] }),
3770
4164
  /* @__PURE__ */ jsxRuntime.jsx(
3771
- "input",
4165
+ AssetSelect,
3772
4166
  {
3773
- className: "pollar-input",
3774
- type: "text",
3775
- placeholder: "Issuer (G...)",
3776
- value: customIssuer,
3777
- onChange: (e) => setCustomIssuer(e.target.value)
4167
+ label: "You receive",
4168
+ value: buyKey,
4169
+ loading: isLoadingData || configLoading,
4170
+ loadingLabel: "Loading assets\u2026",
4171
+ disabled: configLoading,
4172
+ options: buyOptions.map((o) => ({
4173
+ key: assetOptionKey(o),
4174
+ code: o.code,
4175
+ enabledInApp: o.enabledInApp
4176
+ })),
4177
+ onChange: (key) => {
4178
+ const found = buyOptions.find((o) => assetOptionKey(o) === key);
4179
+ if (found) onSelectBuy(found);
4180
+ },
4181
+ children: customOpen ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-custom", children: [
4182
+ /* @__PURE__ */ jsxRuntime.jsx(
4183
+ "input",
4184
+ {
4185
+ className: "pollar-input",
4186
+ type: "text",
4187
+ placeholder: "Code (e.g. USDC)",
4188
+ value: customCode,
4189
+ onChange: (e) => setCustomCode(e.target.value)
4190
+ }
4191
+ ),
4192
+ /* @__PURE__ */ jsxRuntime.jsx(
4193
+ "input",
4194
+ {
4195
+ className: "pollar-input",
4196
+ type: "text",
4197
+ placeholder: "Issuer (G...)",
4198
+ value: customIssuer,
4199
+ onChange: (e) => setCustomIssuer(e.target.value)
4200
+ }
4201
+ ),
4202
+ customError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: customError }),
4203
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-custom-actions", children: [
4204
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: submitCustomToken, children: "Add token" }),
4205
+ /* @__PURE__ */ jsxRuntime.jsx(
4206
+ "button",
4207
+ {
4208
+ type: "button",
4209
+ className: "pollar-swap-custom-cancel",
4210
+ onClick: () => {
4211
+ setCustomOpen(false);
4212
+ setCustomError("");
4213
+ },
4214
+ children: "Cancel"
4215
+ }
4216
+ )
4217
+ ] })
4218
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(
4219
+ "button",
4220
+ {
4221
+ type: "button",
4222
+ className: "pollar-swap-custom-toggle",
4223
+ disabled: configLoading,
4224
+ onClick: () => setCustomOpen(true),
4225
+ children: "+ Add a token by code / issuer"
4226
+ }
4227
+ )
3778
4228
  }
3779
4229
  ),
3780
- customError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: customError }),
3781
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-custom-actions", children: [
3782
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: submitCustomToken, children: "Add token" }),
4230
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
4231
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "Route" }),
3783
4232
  /* @__PURE__ */ jsxRuntime.jsx(
3784
- "button",
4233
+ "select",
3785
4234
  {
3786
- type: "button",
3787
- className: "pollar-swap-custom-cancel",
3788
- onClick: () => {
3789
- setCustomOpen(false);
3790
- setCustomError("");
3791
- },
3792
- children: "Cancel"
4235
+ className: "pollar-input pollar-send-select",
4236
+ value: provider,
4237
+ disabled: configLoading || providers.length === 0,
4238
+ onChange: (e) => onProviderChange(e.target.value),
4239
+ children: providers.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("option", { value: provider, children: configLoading ? "Loading\u2026" : PROVIDER_LABELS[provider] }) : providers.map((p) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: p, children: PROVIDER_LABELS[p] }, p))
3793
4240
  }
3794
4241
  )
3795
- ] })
3796
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-swap-custom-toggle", onClick: () => setCustomOpen(true), children: "+ Add a token by code / issuer" }))
3797
- ] }),
3798
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
3799
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "Route" }),
3800
- /* @__PURE__ */ jsxRuntime.jsx(
3801
- "select",
4242
+ ] }),
4243
+ quoteLoading && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-hint pollar-inline-loading", children: [
4244
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
4245
+ "Fetching best price\u2026"
4246
+ ] }),
4247
+ !quoteLoading && quoteError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: quoteError }),
4248
+ !quoteLoading && !quoteError && quote && selectedBuy && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote", children: [
4249
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
4250
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "You receive" }),
4251
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
4252
+ "~ ",
4253
+ formatAmount3(quote.amountOut),
4254
+ " ",
4255
+ selectedBuy.code
4256
+ ] })
4257
+ ] }),
4258
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
4259
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "Minimum received" }),
4260
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
4261
+ formatAmount3(quote.minReceived),
4262
+ " ",
4263
+ selectedBuy.code
4264
+ ] })
4265
+ ] }),
4266
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
4267
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "Price impact" }),
4268
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
4269
+ quote.priceImpactPct,
4270
+ "%"
4271
+ ] })
4272
+ ] }),
4273
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
4274
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "Route" }),
4275
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: PROVIDER_LABELS[quote.provider] })
4276
+ ] })
4277
+ ] }),
4278
+ !quoteLoading && !quoteError && !quote && selectedSell && selectedBuy && !!amount && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-hint", children: "No route found for this pair." }),
4279
+ buyNeedsTrustline && selectedBuy && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-trustline-notice", children: [
4280
+ "To receive ",
4281
+ selectedBuy.code,
4282
+ " your wallet needs a trustline. Swapping will create it first (~0.5 XLM reserve, refundable if you later remove it)."
4283
+ ] }),
4284
+ formError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: formError }),
4285
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary", onClick: onSwap, disabled: !canSwap, children: buyNeedsTrustline ? "Create trustline & swap" : "Swap" }) })
4286
+ ] }),
4287
+ step === "tx" && /* @__PURE__ */ jsxRuntime.jsx(
4288
+ TxStatusView,
3802
4289
  {
3803
- className: "pollar-input pollar-send-select",
3804
- value: provider,
3805
- onChange: (e) => onProviderChange(e.target.value),
3806
- children: providers.map((p) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: p, children: PROVIDER_LABELS[p] }, p))
4290
+ transaction,
4291
+ showXdr,
4292
+ copied,
4293
+ explorerUrl,
4294
+ walletType,
4295
+ onSignAndSend: () => {
4296
+ },
4297
+ onToggleXdr,
4298
+ onCopyHash,
4299
+ onRetry,
4300
+ onDone
3807
4301
  }
3808
- )
3809
- ] }),
3810
- quoteLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-hint", children: "Fetching best price\u2026" }),
3811
- !quoteLoading && quoteError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: quoteError }),
3812
- !quoteLoading && !quoteError && quote && selectedBuy && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote", children: [
3813
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
3814
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "You receive" }),
3815
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
3816
- "~ ",
3817
- formatAmount2(quote.amountOut),
3818
- " ",
3819
- selectedBuy.code
3820
- ] })
3821
- ] }),
3822
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
3823
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "Minimum received" }),
3824
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
3825
- formatAmount2(quote.minReceived),
3826
- " ",
3827
- selectedBuy.code
3828
- ] })
3829
- ] }),
3830
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
3831
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "Price impact" }),
3832
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
3833
- quote.priceImpactPct,
3834
- "%"
3835
- ] })
3836
- ] }),
3837
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
3838
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "Route" }),
3839
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: PROVIDER_LABELS[quote.provider] })
3840
- ] })
3841
- ] }),
3842
- !quoteLoading && !quoteError && !quote && selectedSell && selectedBuy && !!amount && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-hint", children: "No route found for this pair." }),
3843
- buyNeedsTrustline && selectedBuy && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-trustline-notice", children: [
3844
- "To receive ",
3845
- selectedBuy.code,
3846
- " your wallet needs a trustline. Swapping will create it first (~0.5 XLM reserve, refundable if you later remove it)."
3847
- ] }),
3848
- formError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: formError }),
3849
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary", onClick: onSwap, disabled: !canSwap, children: buyNeedsTrustline ? "Create trustline & swap" : "Swap" }) })
3850
- ] }),
3851
- step === "tx" && /* @__PURE__ */ jsxRuntime.jsx(
3852
- TxStatusView,
3853
- {
3854
- transaction,
3855
- showXdr,
3856
- copied,
3857
- explorerUrl,
3858
- walletType,
3859
- onSignAndSend: () => {
3860
- },
3861
- onToggleXdr,
3862
- onCopyHash,
3863
- onRetry,
3864
- onDone
3865
- }
3866
- ),
3867
- /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
3868
- ] });
4302
+ ),
4303
+ /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
4304
+ ]
4305
+ }
4306
+ );
3869
4307
  }
3870
4308
  var QUOTE_DEBOUNCE_MS = 400;
3871
4309
  function toRef(a) {
@@ -3943,7 +4381,7 @@ function SwapModal({ onClose }) {
3943
4381
  const balances = walletBalance.step === "loaded" ? walletBalance.data.balances : [];
3944
4382
  const assetRecords = enabledAssets.step === "loaded" ? enabledAssets.data.assets : [];
3945
4383
  const isLoadingData = walletBalance.step === "loading" || enabledAssets.step === "loading";
3946
- const sellOptions = balances.filter((b) => parseFloat(b.available) > 0).map((b) => ({ ref: toRef(b), code: b.code, issuer: b.issuer, available: b.available, enabledInApp: b.enabledInApp }));
4384
+ const sellOptions = balances.filter((b) => b.type === "native" || !b.trustlineRemoved).map((b) => ({ ref: toRef(b), code: b.code, issuer: b.issuer, available: b.available, enabledInApp: b.enabledInApp }));
3947
4385
  const buyKeyOfSell = selectedSell ? `${selectedSell.code}:${selectedSell.issuer ?? "native"}` : "";
3948
4386
  const optKey = (o) => `${o.code}:${o.issuer ?? "native"}`;
3949
4387
  const enabledBuy = assetRecords.map((a) => ({
@@ -3961,9 +4399,19 @@ function SwapModal({ onClose }) {
3961
4399
  })).filter((o) => !enabledKeys.has(optKey(o)));
3962
4400
  const knownKeys = /* @__PURE__ */ new Set([...enabledKeys, ...catalogBuy.map(optKey)]);
3963
4401
  const customBuy = customTokens.filter((o) => !knownKeys.has(optKey(o)));
3964
- const buyOptions = [...enabledBuy, ...catalogBuy, ...customBuy].filter(
3965
- (o) => optKey(o) !== buyKeyOfSell
3966
- );
4402
+ const buyOptions = [...enabledBuy, ...catalogBuy, ...customBuy].filter((o) => optKey(o) !== buyKeyOfSell);
4403
+ react.useEffect(() => {
4404
+ if (sellOptions.length === 0) return;
4405
+ if (!selectedSell || !sellOptions.some((o) => optKey(o) === optKey(selectedSell))) {
4406
+ setSelectedSell(sellOptions[0]);
4407
+ }
4408
+ }, [sellOptions, selectedSell]);
4409
+ react.useEffect(() => {
4410
+ if (buyOptions.length === 0) return;
4411
+ if (!selectedBuy || !buyOptions.some((o) => optKey(o) === optKey(selectedBuy))) {
4412
+ setSelectedBuy(buyOptions[0]);
4413
+ }
4414
+ }, [buyOptions, selectedBuy]);
3967
4415
  function addCustomToken(code, issuer) {
3968
4416
  const c = code.trim().toUpperCase();
3969
4417
  const i = issuer.trim();
@@ -4022,7 +4470,7 @@ function SwapModal({ onClose }) {
4022
4470
  const buildData = "buildData" in transaction ? transaction.buildData : null;
4023
4471
  const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
4024
4472
  const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
4025
- const IN_FLIGHT_STEPS2 = [
4473
+ const IN_FLIGHT_STEPS3 = [
4026
4474
  "building",
4027
4475
  "signing",
4028
4476
  "submitting",
@@ -4030,7 +4478,7 @@ function SwapModal({ onClose }) {
4030
4478
  "signing-submitting",
4031
4479
  "building-signing-submitting"
4032
4480
  ];
4033
- const isInProgress = IN_FLIGHT_STEPS2.includes(transaction.step);
4481
+ const isInProgress = IN_FLIGHT_STEPS3.includes(transaction.step);
4034
4482
  const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
4035
4483
  const txTitle = isInProgress ? "Swapping\u2026" : transaction.step === "success" ? "Swapped!" : transaction.step === "error" ? "Swap failed" : "Confirm Swap";
4036
4484
  async function handleSwap() {
@@ -4124,6 +4572,412 @@ function SwapModal({ onClose }) {
4124
4572
  }
4125
4573
  ) });
4126
4574
  }
4575
+ var POSITION_POLL_MS = 1e4;
4576
+ var PROVIDER_LABELS2 = {
4577
+ blend: "Blend",
4578
+ defindex: "DeFindex"
4579
+ };
4580
+ var IN_FLIGHT_STEPS2 = [
4581
+ "building",
4582
+ "signing",
4583
+ "submitting",
4584
+ "submitted",
4585
+ "signing-submitting",
4586
+ "building-signing-submitting"
4587
+ ];
4588
+ function formatAmount4(value) {
4589
+ const n = parseFloat(value);
4590
+ return isNaN(n) ? value : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
4591
+ }
4592
+ function EarnModal({ onClose }) {
4593
+ const {
4594
+ getEarnProviders,
4595
+ getEarnOpportunities,
4596
+ getEarnPosition,
4597
+ earnDeposit,
4598
+ earnWithdraw,
4599
+ tx: transaction,
4600
+ wallet,
4601
+ walletBalance,
4602
+ refreshWalletBalance,
4603
+ network,
4604
+ styles
4605
+ } = usePollar();
4606
+ const walletType = wallet?.custody === "external" ? wallet.provider : null;
4607
+ const smartUnsupported = wallet?.custody === "smart";
4608
+ const { theme = "light", accentColor = "#005DB4" } = styles;
4609
+ const isDark = theme === "dark";
4610
+ const [step, setStep] = react.useState("form");
4611
+ const [tab, setTab] = react.useState("deposit");
4612
+ const [providers, setProviders] = react.useState(null);
4613
+ const [provider, setProvider] = react.useState(null);
4614
+ const [opportunities, setOpportunities] = react.useState([]);
4615
+ const [opportunityId, setOpportunityId] = react.useState("");
4616
+ const [position, setPosition] = react.useState(null);
4617
+ const [amount, setAmount] = react.useState("");
4618
+ const [loadingOpps, setLoadingOpps] = react.useState(false);
4619
+ const [formError, setFormError] = react.useState("");
4620
+ const [refreshing, setRefreshing] = react.useState(false);
4621
+ const [showXdr, setShowXdr] = react.useState(false);
4622
+ const [copied, setCopied] = react.useState(false);
4623
+ const copyTimerRef = react.useRef(null);
4624
+ const loadProviders = react.useCallback(() => {
4625
+ setProviders(null);
4626
+ return getEarnProviders().then((ps) => {
4627
+ setProviders(ps);
4628
+ setProvider((cur) => cur ?? ps[0] ?? null);
4629
+ }).catch(() => setProviders([]));
4630
+ }, [getEarnProviders]);
4631
+ react.useEffect(() => {
4632
+ void loadProviders();
4633
+ }, [loadProviders]);
4634
+ react.useEffect(() => {
4635
+ void refreshWalletBalance();
4636
+ }, [refreshWalletBalance]);
4637
+ react.useEffect(() => {
4638
+ if (!provider) return;
4639
+ let cancelled = false;
4640
+ setLoadingOpps(true);
4641
+ getEarnOpportunities(provider).then((opps) => {
4642
+ if (cancelled) return;
4643
+ setOpportunities(opps);
4644
+ setOpportunityId((cur) => opps.some((o) => o.id === cur) ? cur : opps[0]?.id ?? "");
4645
+ }).catch(() => {
4646
+ if (!cancelled) setOpportunities([]);
4647
+ }).finally(() => {
4648
+ if (!cancelled) setLoadingOpps(false);
4649
+ });
4650
+ return () => {
4651
+ cancelled = true;
4652
+ };
4653
+ }, [provider, getEarnOpportunities]);
4654
+ const selectedOpportunity = opportunities.find((o) => o.id === opportunityId) ?? null;
4655
+ const refreshPosition = react.useCallback(() => {
4656
+ if (!provider || !opportunityId || !wallet) return;
4657
+ getEarnPosition({ provider, opportunity: opportunityId }).then(setPosition).catch(() => {
4658
+ });
4659
+ }, [provider, opportunityId, wallet, getEarnPosition]);
4660
+ react.useEffect(() => {
4661
+ setPosition(null);
4662
+ refreshPosition();
4663
+ }, [refreshPosition]);
4664
+ react.useEffect(() => {
4665
+ if (step !== "form" || !provider || !opportunityId) return;
4666
+ const id = setInterval(refreshPosition, POSITION_POLL_MS);
4667
+ return () => clearInterval(id);
4668
+ }, [step, provider, opportunityId, refreshPosition]);
4669
+ react.useEffect(
4670
+ () => () => {
4671
+ if (copyTimerRef.current !== null) clearTimeout(copyTimerRef.current);
4672
+ },
4673
+ []
4674
+ );
4675
+ const providersLoading = providers === null;
4676
+ const earnUnavailable = providers !== null && providers.length === 0;
4677
+ const withdrawUnit = position?.withdrawUnit ?? "asset";
4678
+ const assetCode = selectedOpportunity?.asset.code ?? "";
4679
+ const amountUnitLabel = tab === "deposit" ? assetCode : withdrawUnit === "shares" ? "shares" : assetCode;
4680
+ const walletAvailable = (() => {
4681
+ if (!selectedOpportunity) return null;
4682
+ const balances = walletBalance.step === "loaded" ? walletBalance.data.balances : [];
4683
+ const issuer = selectedOpportunity.asset.issuer;
4684
+ const rec = balances.find(
4685
+ (b) => issuer === null ? b.type === "native" : b.code === assetCode && b.issuer === issuer
4686
+ );
4687
+ return rec ? rec.available : null;
4688
+ })();
4689
+ const hash = transaction.step === "success" ? transaction.hash : null;
4690
+ const buildData = "buildData" in transaction ? transaction.buildData : null;
4691
+ const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
4692
+ const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
4693
+ const isInProgress = IN_FLIGHT_STEPS2.includes(transaction.step);
4694
+ const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
4695
+ const txTitle = isInProgress ? tab === "deposit" ? "Depositing\u2026" : "Withdrawing\u2026" : transaction.step === "success" ? "Done!" : transaction.step === "error" ? tab === "deposit" ? "Deposit failed" : "Withdraw failed" : "Confirm";
4696
+ const parsedAmount = parseFloat(amount);
4697
+ const exceedsAvailable = tab === "deposit" ? walletAvailable != null && parsedAmount > parseFloat(walletAvailable) : position != null && parsedAmount > parseFloat(position.withdrawable);
4698
+ const canSubmit = !smartUnsupported && !!provider && !!opportunityId && !!amount && parsedAmount > 0 && !exceedsAvailable && !providersLoading && !loadingOpps;
4699
+ const cssVars = {
4700
+ "--pollar-accent": accentColor,
4701
+ "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
4702
+ "--pollar-border": isDark ? "#374151" : "#e5e7eb",
4703
+ "--pollar-text": isDark ? "#ffffff" : "#111827",
4704
+ "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
4705
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
4706
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
4707
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
4708
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
4709
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
4710
+ "--pollar-buttons-border-radius": "6px",
4711
+ "--pollar-buttons-height": "44px",
4712
+ "--pollar-input-height": "44px",
4713
+ "--pollar-input-border-radius": "0.5rem",
4714
+ "--pollar-card-border-radius": "10px"
4715
+ };
4716
+ async function handleSubmit() {
4717
+ setFormError("");
4718
+ if (smartUnsupported) {
4719
+ setFormError("Earn is not yet supported for smart (passkey) wallets");
4720
+ return;
4721
+ }
4722
+ if (!provider || !opportunityId) {
4723
+ setFormError("Select a vault or pool");
4724
+ return;
4725
+ }
4726
+ const parsed = parseFloat(amount);
4727
+ if (!amount || isNaN(parsed) || parsed <= 0) {
4728
+ setFormError("Enter a valid amount");
4729
+ return;
4730
+ }
4731
+ if (tab === "deposit" && walletAvailable != null && parsed > parseFloat(walletAvailable)) {
4732
+ setFormError("Amount exceeds your wallet balance");
4733
+ return;
4734
+ }
4735
+ if (tab === "withdraw" && position && parsed > parseFloat(position.withdrawable)) {
4736
+ setFormError("Amount exceeds your position");
4737
+ return;
4738
+ }
4739
+ setStep("tx");
4740
+ const params = { provider, opportunity: opportunityId, amount };
4741
+ const outcome = tab === "deposit" ? await earnDeposit(params) : await earnWithdraw(params);
4742
+ if (outcome.status === "success" || outcome.status === "pending") {
4743
+ setAmount("");
4744
+ refreshPosition();
4745
+ }
4746
+ }
4747
+ async function handleRetry() {
4748
+ if (transaction.step !== "error" || !provider || !opportunityId) return;
4749
+ const params = { provider, opportunity: opportunityId, amount };
4750
+ if (tab === "deposit") await earnDeposit(params);
4751
+ else await earnWithdraw(params);
4752
+ }
4753
+ function handleCopyHash() {
4754
+ if (!hash) return;
4755
+ navigator.clipboard.writeText(hash).then(() => {
4756
+ setCopied(true);
4757
+ if (copyTimerRef.current !== null) clearTimeout(copyTimerRef.current);
4758
+ copyTimerRef.current = setTimeout(() => {
4759
+ copyTimerRef.current = null;
4760
+ setCopied(false);
4761
+ }, 2e3);
4762
+ });
4763
+ }
4764
+ function handleBack() {
4765
+ setStep("form");
4766
+ setShowXdr(false);
4767
+ setCopied(false);
4768
+ refreshPosition();
4769
+ }
4770
+ async function handleRefresh() {
4771
+ if (refreshing || !provider) return;
4772
+ setRefreshing(true);
4773
+ try {
4774
+ void refreshWalletBalance();
4775
+ const opps = await getEarnOpportunities(provider);
4776
+ setOpportunities(opps);
4777
+ setOpportunityId((cur) => opps.some((o) => o.id === cur) ? cur : opps[0]?.id ?? "");
4778
+ refreshPosition();
4779
+ } catch {
4780
+ } finally {
4781
+ setRefreshing(false);
4782
+ }
4783
+ }
4784
+ const title = step === "form" ? "Earn" : txTitle;
4785
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-overlay", onClick: !isInProgress ? onClose : void 0, children: /* @__PURE__ */ jsxRuntime.jsxs(
4786
+ "div",
4787
+ {
4788
+ className: "pollar-modal-card pollar-send-modal",
4789
+ "data-theme": theme,
4790
+ style: cssVars,
4791
+ onClick: (e) => e.stopPropagation(),
4792
+ children: [
4793
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
4794
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-header-left", children: [
4795
+ showBack && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: handleBack, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
4796
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: title })
4797
+ ] }),
4798
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
4799
+ step === "form" && !earnUnavailable && !smartUnsupported && /* @__PURE__ */ jsxRuntime.jsx(
4800
+ "button",
4801
+ {
4802
+ type: "button",
4803
+ className: "pollar-modal-close",
4804
+ onClick: () => void handleRefresh(),
4805
+ disabled: refreshing || providersLoading,
4806
+ "aria-label": "Refresh",
4807
+ children: /* @__PURE__ */ jsxRuntime.jsx(
4808
+ "svg",
4809
+ {
4810
+ className: refreshing ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
4811
+ width: "16",
4812
+ height: "16",
4813
+ viewBox: "0 0 16 16",
4814
+ fill: "none",
4815
+ "aria-hidden": true,
4816
+ children: /* @__PURE__ */ jsxRuntime.jsx(
4817
+ "path",
4818
+ {
4819
+ d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
4820
+ stroke: "currentColor",
4821
+ strokeWidth: "1.6",
4822
+ strokeLinecap: "round",
4823
+ strokeLinejoin: "round"
4824
+ }
4825
+ )
4826
+ }
4827
+ )
4828
+ }
4829
+ ),
4830
+ !isInProgress && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
4831
+ ] })
4832
+ ] }),
4833
+ step === "form" && providersLoading && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-loading-block", children: [
4834
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-spinner" }),
4835
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Loading Earn options\u2026" })
4836
+ ] }),
4837
+ step === "form" && earnUnavailable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "Earn is not available for this app." }),
4838
+ step === "form" && !earnUnavailable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4839
+ smartUnsupported && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "Earn is not yet available for smart (passkey) wallets." }),
4840
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tabs", children: [
4841
+ /* @__PURE__ */ jsxRuntime.jsx(
4842
+ "button",
4843
+ {
4844
+ type: "button",
4845
+ className: "pollar-tab",
4846
+ "data-active": tab === "deposit",
4847
+ onClick: () => {
4848
+ setTab("deposit");
4849
+ setFormError("");
4850
+ },
4851
+ children: "Deposit"
4852
+ }
4853
+ ),
4854
+ /* @__PURE__ */ jsxRuntime.jsx(
4855
+ "button",
4856
+ {
4857
+ type: "button",
4858
+ className: "pollar-tab",
4859
+ "data-active": tab === "withdraw",
4860
+ onClick: () => {
4861
+ setTab("withdraw");
4862
+ setFormError("");
4863
+ },
4864
+ children: "Withdraw"
4865
+ }
4866
+ )
4867
+ ] }),
4868
+ providers && providers.length > 1 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
4869
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "Provider" }),
4870
+ /* @__PURE__ */ jsxRuntime.jsx(
4871
+ "select",
4872
+ {
4873
+ className: "pollar-input pollar-send-select",
4874
+ value: provider ?? "",
4875
+ onChange: (e) => setProvider(e.target.value),
4876
+ children: providers.map((p) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: p, children: PROVIDER_LABELS2[p] }, p))
4877
+ }
4878
+ )
4879
+ ] }),
4880
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
4881
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-label-row", children: [
4882
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: provider === "defindex" ? "Vault" : "Pool" }),
4883
+ loadingOpps && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-label": "Loading options" })
4884
+ ] }),
4885
+ /* @__PURE__ */ jsxRuntime.jsx(
4886
+ "select",
4887
+ {
4888
+ className: "pollar-input pollar-send-select",
4889
+ value: opportunityId,
4890
+ disabled: loadingOpps || opportunities.length === 0,
4891
+ onChange: (e) => setOpportunityId(e.target.value),
4892
+ children: opportunities.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: loadingOpps ? "Loading\u2026" : "None available" }) : opportunities.map((o) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: o.id, children: [
4893
+ o.name,
4894
+ " \xB7 ",
4895
+ o.apy.toFixed(2),
4896
+ "% APY"
4897
+ ] }, o.id))
4898
+ }
4899
+ )
4900
+ ] }),
4901
+ selectedOpportunity && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote", children: [
4902
+ tab === "deposit" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
4903
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "In your wallet" }),
4904
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
4905
+ walletAvailable != null ? formatAmount4(walletAvailable) : "\u2026",
4906
+ " ",
4907
+ assetCode
4908
+ ] })
4909
+ ] }),
4910
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
4911
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "Your position" }),
4912
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
4913
+ position ? formatAmount4(position.balance) : "\u2026",
4914
+ " ",
4915
+ assetCode
4916
+ ] })
4917
+ ] }),
4918
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
4919
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "APY" }),
4920
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-earn-live", children: [
4921
+ selectedOpportunity.apy.toFixed(2),
4922
+ "%"
4923
+ ] })
4924
+ ] })
4925
+ ] }),
4926
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
4927
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-label-row", children: [
4928
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: tab === "deposit" ? "Amount" : "Withdraw amount" }),
4929
+ tab === "deposit" && walletAvailable != null && /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-swap-custom-toggle", onClick: () => setAmount(walletAvailable), children: [
4930
+ "Max: ",
4931
+ formatAmount4(walletAvailable),
4932
+ " ",
4933
+ amountUnitLabel
4934
+ ] }),
4935
+ tab === "withdraw" && position && /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-swap-custom-toggle", onClick: () => setAmount(position.withdrawable), children: [
4936
+ "Max: ",
4937
+ formatAmount4(position.withdrawable),
4938
+ " ",
4939
+ amountUnitLabel
4940
+ ] })
4941
+ ] }),
4942
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-earn-amount", children: [
4943
+ /* @__PURE__ */ jsxRuntime.jsx(
4944
+ "input",
4945
+ {
4946
+ className: "pollar-input",
4947
+ type: "text",
4948
+ inputMode: "decimal",
4949
+ placeholder: "0.00",
4950
+ value: amount,
4951
+ onChange: (e) => setAmount(e.target.value)
4952
+ }
4953
+ ),
4954
+ amountUnitLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-earn-amount-unit", children: amountUnitLabel })
4955
+ ] })
4956
+ ] }),
4957
+ formError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: formError }),
4958
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary", onClick: () => void handleSubmit(), disabled: !canSubmit, children: tab === "deposit" ? "Deposit" : "Withdraw" }) })
4959
+ ] }),
4960
+ step === "tx" && /* @__PURE__ */ jsxRuntime.jsx(
4961
+ TxStatusView,
4962
+ {
4963
+ transaction,
4964
+ showXdr,
4965
+ copied,
4966
+ explorerUrl,
4967
+ walletType,
4968
+ onSignAndSend: () => {
4969
+ },
4970
+ onToggleXdr: () => setShowXdr((v) => !v),
4971
+ onCopyHash: handleCopyHash,
4972
+ onRetry: () => void handleRetry(),
4973
+ onDone: onClose
4974
+ }
4975
+ ),
4976
+ /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
4977
+ ]
4978
+ }
4979
+ ) });
4980
+ }
4127
4981
  function describeDevice(s) {
4128
4982
  if (s.deviceLabel) return s.deviceLabel;
4129
4983
  if (!s.userAgent) return "Unknown device";
@@ -4215,30 +5069,46 @@ function SessionsModalTemplate({
4215
5069
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
4216
5070
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Active sessions" }),
4217
5071
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
4218
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-modal-refresh-btn", onClick: onRefresh, disabled: isLoading, children: [
4219
- /* @__PURE__ */ jsxRuntime.jsxs(
4220
- "svg",
4221
- {
4222
- className: `pollar-modal-refresh-icon${isLoading ? " spinning" : ""}`,
4223
- width: "13",
4224
- height: "13",
4225
- viewBox: "0 0 13 13",
4226
- fill: "none",
4227
- "aria-hidden": true,
4228
- children: [
4229
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11.5 6.5a5 5 0 11-1.5-3.536", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
4230
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 1v3h-3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
4231
- ]
4232
- }
4233
- ),
4234
- "Refresh"
4235
- ] }),
5072
+ /* @__PURE__ */ jsxRuntime.jsx(
5073
+ "button",
5074
+ {
5075
+ type: "button",
5076
+ className: "pollar-modal-close",
5077
+ onClick: onRefresh,
5078
+ disabled: isLoading,
5079
+ "aria-label": "Refresh",
5080
+ title: "Refresh",
5081
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5082
+ "svg",
5083
+ {
5084
+ className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
5085
+ width: "16",
5086
+ height: "16",
5087
+ viewBox: "0 0 16 16",
5088
+ fill: "none",
5089
+ "aria-hidden": true,
5090
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5091
+ "path",
5092
+ {
5093
+ d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
5094
+ stroke: "currentColor",
5095
+ strokeWidth: "1.6",
5096
+ strokeLinecap: "round",
5097
+ strokeLinejoin: "round"
5098
+ }
5099
+ )
5100
+ }
5101
+ )
5102
+ }
5103
+ ),
4236
5104
  /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
4237
5105
  ] })
4238
5106
  ] }),
4239
5107
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-list", children: [
4240
- state.step === "idle" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
4241
- isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
5108
+ (state.step === "idle" || isLoading) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-loading-block", children: [
5109
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-spinner" }),
5110
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Loading\u2026" })
5111
+ ] }),
4242
5112
  state.step === "error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: state.message }),
4243
5113
  state.step === "loaded" && sessions.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "No active sessions." }),
4244
5114
  sessions.map((s) => {
@@ -4267,7 +5137,10 @@ function SessionsModalTemplate({
4267
5137
  className: "pollar-sessions-item-revoke",
4268
5138
  onClick: () => onRevoke(s.familyId),
4269
5139
  disabled: isRevoking || signingOutEverywhere,
4270
- children: isRevoking ? "Revoking\u2026" : "Revoke"
5140
+ children: isRevoking ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5141
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm pollar-spinner-current" }),
5142
+ "Revoking\u2026"
5143
+ ] }) : "Revoke"
4271
5144
  }
4272
5145
  )
4273
5146
  ] }, s.familyId);
@@ -4280,7 +5153,10 @@ function SessionsModalTemplate({
4280
5153
  onClick: onLogoutEverywhere,
4281
5154
  disabled: signingOutEverywhere || otherCount === 0,
4282
5155
  title: otherCount === 0 ? "No other devices to sign out" : void 0,
4283
- children: signingOutEverywhere ? "Signing out\u2026" : "Sign out everywhere"
5156
+ children: signingOutEverywhere ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5157
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm pollar-spinner-current" }),
5158
+ "Signing out\u2026"
5159
+ ] }) : "Sign out everywhere"
4284
5160
  }
4285
5161
  ) }),
4286
5162
  /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
@@ -4473,6 +5349,33 @@ function StatusBadge({ status }) {
4473
5349
  function formatDate(iso) {
4474
5350
  return new Date(iso).toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" });
4475
5351
  }
5352
+ function truncateMiddle(value, head = 4, tail = 4) {
5353
+ return value.length <= head + tail + 1 ? value : `${value.slice(0, head)}\u2026${value.slice(-tail)}`;
5354
+ }
5355
+ var STELLAR_ADDRESS = /\b[GC][A-Z2-7]{55}\b/g;
5356
+ function AddressChip({ value, label }) {
5357
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-item-issuer", children: [
5358
+ truncateMiddle(value),
5359
+ /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value, label, className: "pollar-copy-btn-sm" })
5360
+ ] });
5361
+ }
5362
+ function renderSummary(summary) {
5363
+ const parts = [];
5364
+ let last = 0;
5365
+ let key = 0;
5366
+ STELLAR_ADDRESS.lastIndex = 0;
5367
+ for (let m = STELLAR_ADDRESS.exec(summary); m !== null; m = STELLAR_ADDRESS.exec(summary)) {
5368
+ if (m.index > last) parts.push(/* @__PURE__ */ jsxRuntime.jsx("span", { children: summary.slice(last, m.index) }, key++));
5369
+ const address = m[0];
5370
+ parts.push(
5371
+ /* @__PURE__ */ jsxRuntime.jsx(AddressChip, { value: address, label: address[0] === "C" ? "Copy contract address" : "Copy wallet address" }, key++)
5372
+ );
5373
+ last = m.index + address.length;
5374
+ }
5375
+ if (parts.length === 0) return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-hist-item-title", children: summary });
5376
+ if (last < summary.length) parts.push(/* @__PURE__ */ jsxRuntime.jsx("span", { children: summary.slice(last) }, key));
5377
+ return parts;
5378
+ }
4476
5379
  function TxHistoryModalTemplate({
4477
5380
  theme,
4478
5381
  accentColor,
@@ -4518,59 +5421,106 @@ function TxHistoryModalTemplate({
4518
5421
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
4519
5422
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Transaction History" }),
4520
5423
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
4521
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-modal-refresh-btn", onClick: onRefresh, disabled: isLoading, children: [
4522
- /* @__PURE__ */ jsxRuntime.jsxs(
4523
- "svg",
4524
- {
4525
- className: `pollar-modal-refresh-icon${isLoading ? " spinning" : ""}`,
4526
- width: "13",
4527
- height: "13",
4528
- viewBox: "0 0 13 13",
4529
- fill: "none",
4530
- "aria-hidden": true,
4531
- children: [
4532
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11.5 6.5a5 5 0 11-1.5-3.536", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
4533
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 1v3h-3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
4534
- ]
4535
- }
4536
- ),
4537
- "Refresh"
4538
- ] }),
5424
+ /* @__PURE__ */ jsxRuntime.jsx(
5425
+ "button",
5426
+ {
5427
+ type: "button",
5428
+ className: "pollar-modal-close",
5429
+ onClick: onRefresh,
5430
+ disabled: isLoading,
5431
+ "aria-label": "Refresh",
5432
+ title: "Refresh",
5433
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5434
+ "svg",
5435
+ {
5436
+ className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
5437
+ width: "16",
5438
+ height: "16",
5439
+ viewBox: "0 0 16 16",
5440
+ fill: "none",
5441
+ "aria-hidden": true,
5442
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5443
+ "path",
5444
+ {
5445
+ d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
5446
+ stroke: "currentColor",
5447
+ strokeWidth: "1.6",
5448
+ strokeLinecap: "round",
5449
+ strokeLinejoin: "round"
5450
+ }
5451
+ )
5452
+ }
5453
+ )
5454
+ }
5455
+ ),
4539
5456
  /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
4540
5457
  ] })
4541
5458
  ] }),
4542
5459
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-list", children: [
4543
5460
  txHistory.step === "idle" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "Click Refresh to load transactions." }),
4544
- isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
5461
+ isLoading && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-loading-block", children: [
5462
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-spinner" }),
5463
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Loading\u2026" })
5464
+ ] }),
4545
5465
  txHistory.step === "error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: txHistory.message }),
4546
5466
  txHistory.step === "loaded" && records.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "No transactions yet." }),
4547
5467
  records.map((record) => {
4548
- const explorerUrl = `https://stellar.expert/explorer/${record.network === "testnet" ? "testnet" : "public"}/tx/${record.hash}`;
5468
+ const hash = typeof record.hash === "string" && record.hash.length > 0 ? record.hash : void 0;
5469
+ const explorerUrl = hash ? `https://stellar.expert/explorer/${record.network === "testnet" ? "testnet" : "public"}/tx/${hash}` : void 0;
5470
+ const asset = typeof record.details?.asset === "string" ? record.details.asset : void 0;
5471
+ const colon = asset ? asset.indexOf(":") : -1;
5472
+ const trustline = record.operation === "change_trust" && asset && colon > 0 ? {
5473
+ prefix: record.summary.split(":")[0],
5474
+ code: asset.slice(0, colon),
5475
+ issuer: asset.slice(colon + 1)
5476
+ } : void 0;
5477
+ const contract = record.operation === "invoke_contract" && typeof record.details?.contractId === "string" && typeof record.details?.method === "string" ? { method: record.details.method, contractId: record.details.contractId } : void 0;
4549
5478
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-item", children: [
4550
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-hist-item-summary", children: record.summary }),
4551
- /* @__PURE__ */ jsxRuntime.jsx(StatusBadge, { status: record.status }),
5479
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-item-top", children: [
5480
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-hist-item-summary", children: trustline ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5481
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-item-title", children: [
5482
+ trustline.prefix,
5483
+ ": ",
5484
+ trustline.code
5485
+ ] }),
5486
+ /* @__PURE__ */ jsxRuntime.jsx(AddressChip, { value: trustline.issuer, label: "Copy issuer" })
5487
+ ] }) : contract ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5488
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-item-title", children: [
5489
+ "Invoke ",
5490
+ contract.method,
5491
+ "() on"
5492
+ ] }),
5493
+ /* @__PURE__ */ jsxRuntime.jsx(AddressChip, { value: contract.contractId, label: "Copy contract address" })
5494
+ ] }) : renderSummary(record.summary) }),
5495
+ /* @__PURE__ */ jsxRuntime.jsx(StatusBadge, { status: record.status })
5496
+ ] }),
4552
5497
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-item-meta", children: [
4553
5498
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: record.operation }),
5499
+ typeof record.details?.sponsored === "boolean" && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
5500
+ "\xB7 ",
5501
+ record.details.sponsored ? "Sponsored" : "Self-paid"
5502
+ ] }),
4554
5503
  record.feeXlm && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
4555
5504
  "\xB7 ",
4556
5505
  record.feeXlm,
4557
5506
  " XLM"
4558
- ] }),
4559
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
4560
- "\xB7 ",
4561
- formatDate(record.createdAt)
4562
- ] }),
4563
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\xB7" }),
4564
- /* @__PURE__ */ jsxRuntime.jsxs(
4565
- "a",
4566
- {
4567
- className: "pollar-hist-item-explorer",
4568
- href: explorerUrl,
4569
- target: "_blank",
4570
- rel: "noopener noreferrer",
4571
- "aria-label": "View on Stellar Explorer",
4572
- children: [
4573
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "11", height: "11", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
5507
+ ] })
5508
+ ] }),
5509
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-item-footer", children: [
5510
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: formatDate(record.createdAt) }),
5511
+ hash && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5512
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-hist-item-dot", children: "\xB7" }),
5513
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-hist-item-hash", children: truncateMiddle(hash, 6, 6) }),
5514
+ /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value: hash, label: "Copy transaction hash", className: "pollar-copy-btn-sm" }),
5515
+ /* @__PURE__ */ jsxRuntime.jsx(
5516
+ "a",
5517
+ {
5518
+ className: "pollar-hist-item-explorer",
5519
+ href: explorerUrl,
5520
+ target: "_blank",
5521
+ rel: "noopener noreferrer",
5522
+ "aria-label": "View on Stellar Explorer",
5523
+ children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "12", height: "12", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
4574
5524
  /* @__PURE__ */ jsxRuntime.jsx(
4575
5525
  "path",
4576
5526
  {
@@ -4590,11 +5540,10 @@ function TxHistoryModalTemplate({
4590
5540
  strokeLinejoin: "round"
4591
5541
  }
4592
5542
  )
4593
- ] }),
4594
- "Explorer"
4595
- ]
4596
- }
4597
- )
5543
+ ] })
5544
+ }
5545
+ )
5546
+ ] })
4598
5547
  ] })
4599
5548
  ] }, record.id);
4600
5549
  })
@@ -4648,7 +5597,7 @@ function TxHistoryModal({ onClose }) {
4648
5597
  }
4649
5598
  function formatBalance2(balance) {
4650
5599
  const n = parseFloat(balance);
4651
- return isNaN(n) ? balance : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
5600
+ return isNaN(n) ? balance : n.toLocaleString(void 0, { minimumFractionDigits: 7, maximumFractionDigits: 7 });
4652
5601
  }
4653
5602
  function cropAddress2(address) {
4654
5603
  if (address.length <= 16) return address;
@@ -4657,7 +5606,13 @@ function cropAddress2(address) {
4657
5606
  function BalanceItem({ record }) {
4658
5607
  const balanceDiffers = record.balance !== record.available;
4659
5608
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bal-item", children: [
4660
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bal-asset", children: record.code }),
5609
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bal-asset-info", children: [
5610
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bal-asset", children: record.code }),
5611
+ record.issuer && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-bal-issuer", children: [
5612
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bal-issuer-addr", children: cropAddress2(record.issuer) }),
5613
+ /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value: record.issuer, label: "Copy issuer address", className: "pollar-copy-btn-sm" })
5614
+ ] })
5615
+ ] }),
4661
5616
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bal-amounts", children: [
4662
5617
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bal-amount", children: formatBalance2(record.balance) }),
4663
5618
  balanceDiffers && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-bal-available", children: [
@@ -4699,29 +5654,49 @@ function WalletBalanceModalTemplate({
4699
5654
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
4700
5655
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Wallet Balance" }),
4701
5656
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
4702
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-modal-refresh-btn", onClick: onRefresh, disabled: isLoading, children: [
4703
- /* @__PURE__ */ jsxRuntime.jsxs(
4704
- "svg",
4705
- {
4706
- className: `pollar-modal-refresh-icon${isLoading ? " spinning" : ""}`,
4707
- width: "13",
4708
- height: "13",
4709
- viewBox: "0 0 13 13",
4710
- fill: "none",
4711
- "aria-hidden": true,
4712
- children: [
4713
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11.5 6.5a5 5 0 11-1.5-3.536", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
4714
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 1v3h-3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
4715
- ]
4716
- }
4717
- ),
4718
- "Refresh"
4719
- ] }),
5657
+ /* @__PURE__ */ jsxRuntime.jsx(
5658
+ "button",
5659
+ {
5660
+ type: "button",
5661
+ className: "pollar-modal-close",
5662
+ onClick: onRefresh,
5663
+ disabled: isLoading,
5664
+ "aria-label": "Refresh",
5665
+ title: "Refresh",
5666
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5667
+ "svg",
5668
+ {
5669
+ className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
5670
+ width: "16",
5671
+ height: "16",
5672
+ viewBox: "0 0 16 16",
5673
+ fill: "none",
5674
+ "aria-hidden": true,
5675
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5676
+ "path",
5677
+ {
5678
+ d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
5679
+ stroke: "currentColor",
5680
+ strokeWidth: "1.6",
5681
+ strokeLinecap: "round",
5682
+ strokeLinejoin: "round"
5683
+ }
5684
+ )
5685
+ }
5686
+ )
5687
+ }
5688
+ ),
4720
5689
  /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
4721
5690
  ] })
4722
5691
  ] }),
4723
- walletAddress && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-bal-address", children: cropAddress2(walletAddress) }),
4724
- isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
5692
+ walletAddress && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bal-address-row", children: [
5693
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bal-address", children: cropAddress2(walletAddress) }),
5694
+ /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value: walletAddress, label: "Copy wallet address" })
5695
+ ] }),
5696
+ isLoading && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-loading-block", children: [
5697
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-spinner" }),
5698
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Loading\u2026" })
5699
+ ] }),
4725
5700
  walletBalance.step === "error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: walletBalance.message }),
4726
5701
  data && !data.exists && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-empty", children: [
4727
5702
  "Account not found on ",
@@ -4931,6 +5906,10 @@ function PollarProvider({
4931
5906
  const [enabledAssetsModalOpen, setEnabledAssetsModalOpen] = react.useState(false);
4932
5907
  const [sendModalOpen, setSendModalOpen] = react.useState(false);
4933
5908
  const [swapModalOpen, setSwapModalOpen] = react.useState(false);
5909
+ const [earnModalOpen, setEarnModalOpen] = react.useState(false);
5910
+ const [sendModalKey, setSendModalKey] = react.useState(0);
5911
+ const [swapModalKey, setSwapModalKey] = react.useState(0);
5912
+ const [earnModalKey, setEarnModalKey] = react.useState(0);
4934
5913
  const [receiveModalOpen, setReceiveModalOpen] = react.useState(false);
4935
5914
  const [sessionsModalOpen, setSessionsModalOpen] = react.useState(false);
4936
5915
  const [distributionRulesModalOpen, setDistributionRulesModalOpen] = react.useState(false);
@@ -4973,14 +5952,33 @@ function PollarProvider({
4973
5952
  setTrustline: (asset, opts) => pollarClient.setTrustline(asset, opts),
4974
5953
  openEnabledAssetsModal: () => setEnabledAssetsModalOpen(true),
4975
5954
  // send / receive
4976
- openSendModal: () => setSendModalOpen(true),
5955
+ openSendModal: () => {
5956
+ pollarClient.resetTransactionState();
5957
+ setSendModalKey((k) => k + 1);
5958
+ setSendModalOpen(true);
5959
+ },
4977
5960
  openReceiveModal: () => setReceiveModalOpen(true),
4978
5961
  // swap
4979
5962
  getSwapConfig: () => pollarClient.getSwapConfig(),
4980
5963
  getSwapTokens: () => pollarClient.getSwapTokens(),
4981
5964
  getSwapQuote: (params) => pollarClient.getSwapQuote(params),
4982
5965
  swap: (quote, opts) => pollarClient.swap(quote, opts),
4983
- openSwapModal: () => setSwapModalOpen(true),
5966
+ openSwapModal: () => {
5967
+ pollarClient.resetTransactionState();
5968
+ setSwapModalKey((k) => k + 1);
5969
+ setSwapModalOpen(true);
5970
+ },
5971
+ // earn
5972
+ getEarnProviders: () => pollarClient.getEarnProviders(),
5973
+ getEarnOpportunities: (provider) => pollarClient.getEarnOpportunities(provider),
5974
+ getEarnPosition: (params) => pollarClient.getEarnPosition(params),
5975
+ earnDeposit: (params) => pollarClient.earnDeposit(params),
5976
+ earnWithdraw: (params) => pollarClient.earnWithdraw(params),
5977
+ openEarnModal: () => {
5978
+ pollarClient.resetTransactionState();
5979
+ setEarnModalKey((k) => k + 1);
5980
+ setEarnModalOpen(true);
5981
+ },
4984
5982
  // sessions
4985
5983
  sessions,
4986
5984
  openSessionsModal: () => setSessionsModalOpen(true),
@@ -5034,8 +6032,9 @@ function PollarProvider({
5034
6032
  txHistoryModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setTxHistoryModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(TxHistoryModal, { onClose: () => setTxHistoryModalOpen(false) }) }),
5035
6033
  walletBalanceModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setWalletBalanceModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(WalletBalanceModal, { onClose: () => setWalletBalanceModalOpen(false) }) }),
5036
6034
  enabledAssetsModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setEnabledAssetsModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(EnabledAssetsModal, { onClose: () => setEnabledAssetsModalOpen(false) }) }),
5037
- sendModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSendModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SendModal, { onClose: () => setSendModalOpen(false) }) }),
5038
- swapModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSwapModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SwapModal, { onClose: () => setSwapModalOpen(false) }) }),
6035
+ sendModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSendModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SendModal, { onClose: () => setSendModalOpen(false) }) }, sendModalKey),
6036
+ swapModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSwapModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SwapModal, { onClose: () => setSwapModalOpen(false) }) }, swapModalKey),
6037
+ earnModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setEarnModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(EarnModal, { onClose: () => setEarnModalOpen(false) }) }, earnModalKey),
5039
6038
  receiveModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setReceiveModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(ReceiveModal, { onClose: () => setReceiveModalOpen(false) }) }),
5040
6039
  sessionsModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSessionsModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SessionsModal, { onClose: () => setSessionsModalOpen(false) }) }),
5041
6040
  distributionRulesModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setDistributionRulesModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(DistributionRulesModal, { onClose: () => setDistributionRulesModalOpen(false) }) })
@@ -5069,7 +6068,7 @@ function createPollarAdapterHook(key) {
5069
6068
  };
5070
6069
  }
5071
6070
  function ButtonLogo() {
5072
- return /* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_POLLAR, alt: "Pollar", width: 22, height: 22, className: "wallet-btn-logo" });
6071
+ return /* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_POLLAR, alt: "Pollar", width: 22, height: 22, className: "pollar-wallet-btn-logo" });
5073
6072
  }
5074
6073
  function cropWallet(address) {
5075
6074
  if (address.length <= 12) return address;
@@ -5085,7 +6084,10 @@ function WalletButtonTemplate({
5085
6084
  itemColor,
5086
6085
  wrapperRef,
5087
6086
  isInProgress,
6087
+ showCreateAccount,
6088
+ creatingAccount,
5088
6089
  onToggleOpen,
6090
+ onCreateAccount,
5089
6091
  onCopy,
5090
6092
  onWalletBalance,
5091
6093
  onTxHistory,
@@ -5099,23 +6101,23 @@ function WalletButtonTemplate({
5099
6101
  onLogin
5100
6102
  }) {
5101
6103
  if (!walletAddress) {
5102
- return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "wallet-login-btn", style: { backgroundColor: accentColor }, onClick: onLogin, children: [
6104
+ return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-wallet-login-btn", style: { backgroundColor: accentColor }, onClick: onLogin, children: [
5103
6105
  /* @__PURE__ */ jsxRuntime.jsx(ButtonLogo, {}),
5104
6106
  "Login with Pollar"
5105
6107
  ] });
5106
6108
  }
5107
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "wallet-wrapper", ref: wrapperRef, children: [
6109
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-wallet-wrapper", ref: wrapperRef, children: [
5108
6110
  /* @__PURE__ */ jsxRuntime.jsxs(
5109
6111
  "button",
5110
6112
  {
5111
- className: "wallet-btn",
6113
+ className: "pollar-wallet-btn",
5112
6114
  style: { backgroundColor: accentColor },
5113
6115
  onClick: isInProgress ? void 0 : onToggleOpen,
5114
6116
  disabled: isInProgress,
5115
6117
  "aria-busy": isInProgress,
5116
6118
  children: [
5117
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "wallet-btn-label", children: cropWallet(walletAddress) }),
5118
- isInProgress ? /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: "wallet-btn-spinner", viewBox: "0 0 12 12", width: "12", height: "12", fill: "none", "aria-hidden": true, children: [
6119
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-wallet-btn-label", children: cropWallet(walletAddress) }),
6120
+ isInProgress ? /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: "pollar-wallet-btn-spinner", viewBox: "0 0 12 12", width: "12", height: "12", fill: "none", "aria-hidden": true, children: [
5119
6121
  /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "6", cy: "6", r: "4.5", stroke: "rgba(255,255,255,0.35)", strokeWidth: "1.5" }),
5120
6122
  /* @__PURE__ */ jsxRuntime.jsx(
5121
6123
  "circle",
@@ -5133,7 +6135,7 @@ function WalletButtonTemplate({
5133
6135
  ] }) : /* @__PURE__ */ jsxRuntime.jsx(
5134
6136
  "svg",
5135
6137
  {
5136
- className: `wallet-chevron${open ? " open" : ""}`,
6138
+ className: `pollar-wallet-chevron${open ? " pollar-open" : ""}`,
5137
6139
  viewBox: "0 0 12 12",
5138
6140
  fill: "none",
5139
6141
  stroke: "currentColor",
@@ -5146,8 +6148,42 @@ function WalletButtonTemplate({
5146
6148
  ]
5147
6149
  }
5148
6150
  ),
5149
- open && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "wallet-dropdown", style: { backgroundColor: dropdownBg, borderColor: dropdownBorder }, children: [
5150
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onSend, children: [
6151
+ open && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-wallet-dropdown", style: { backgroundColor: dropdownBg, borderColor: dropdownBorder }, children: [
6152
+ showCreateAccount && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6153
+ /* @__PURE__ */ jsxRuntime.jsxs(
6154
+ "button",
6155
+ {
6156
+ className: "pollar-wallet-dropdown-item",
6157
+ style: { color: itemColor },
6158
+ onClick: onCreateAccount,
6159
+ disabled: creatingAccount,
6160
+ children: [
6161
+ /* @__PURE__ */ jsxRuntime.jsxs(
6162
+ "svg",
6163
+ {
6164
+ width: "14",
6165
+ height: "14",
6166
+ viewBox: "0 0 24 24",
6167
+ fill: "none",
6168
+ stroke: "currentColor",
6169
+ strokeWidth: "2",
6170
+ strokeLinecap: "round",
6171
+ strokeLinejoin: "round",
6172
+ children: [
6173
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" }),
6174
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "9", cy: "7", r: "4" }),
6175
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "19", y1: "8", x2: "19", y2: "14" }),
6176
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "22", y1: "11", x2: "16", y2: "11" })
6177
+ ]
6178
+ }
6179
+ ),
6180
+ creatingAccount ? "Creating account\u2026" : "Create account"
6181
+ ]
6182
+ }
6183
+ ),
6184
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-wallet-dropdown-divider" })
6185
+ ] }),
6186
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onSend, children: [
5151
6187
  /* @__PURE__ */ jsxRuntime.jsxs(
5152
6188
  "svg",
5153
6189
  {
@@ -5167,7 +6203,7 @@ function WalletButtonTemplate({
5167
6203
  ),
5168
6204
  "Send"
5169
6205
  ] }),
5170
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onReceive, children: [
6206
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onReceive, children: [
5171
6207
  /* @__PURE__ */ jsxRuntime.jsxs(
5172
6208
  "svg",
5173
6209
  {
@@ -5188,8 +6224,8 @@ function WalletButtonTemplate({
5188
6224
  ),
5189
6225
  "Receive"
5190
6226
  ] }),
5191
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "wallet-dropdown-divider" }),
5192
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onCopy, children: [
6227
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-wallet-dropdown-divider" }),
6228
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onCopy, children: [
5193
6229
  /* @__PURE__ */ jsxRuntime.jsxs(
5194
6230
  "svg",
5195
6231
  {
@@ -5209,7 +6245,7 @@ function WalletButtonTemplate({
5209
6245
  ),
5210
6246
  copied ? "Copied!" : "Copy address"
5211
6247
  ] }),
5212
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onWalletBalance, children: [
6248
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onWalletBalance, children: [
5213
6249
  /* @__PURE__ */ jsxRuntime.jsxs(
5214
6250
  "svg",
5215
6251
  {
@@ -5230,7 +6266,7 @@ function WalletButtonTemplate({
5230
6266
  ),
5231
6267
  "Wallet balance"
5232
6268
  ] }),
5233
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onTxHistory, children: [
6269
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onTxHistory, children: [
5234
6270
  /* @__PURE__ */ jsxRuntime.jsxs(
5235
6271
  "svg",
5236
6272
  {
@@ -5253,8 +6289,8 @@ function WalletButtonTemplate({
5253
6289
  ),
5254
6290
  "Transaction history"
5255
6291
  ] }),
5256
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "wallet-dropdown-divider" }),
5257
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onRamp, children: [
6292
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-wallet-dropdown-divider" }),
6293
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onRamp, children: [
5258
6294
  /* @__PURE__ */ jsxRuntime.jsxs(
5259
6295
  "svg",
5260
6296
  {
@@ -5276,7 +6312,7 @@ function WalletButtonTemplate({
5276
6312
  ),
5277
6313
  "Buy / Sell"
5278
6314
  ] }),
5279
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onKyc, children: [
6315
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onKyc, children: [
5280
6316
  /* @__PURE__ */ jsxRuntime.jsxs(
5281
6317
  "svg",
5282
6318
  {
@@ -5297,7 +6333,7 @@ function WalletButtonTemplate({
5297
6333
  ),
5298
6334
  "Identity verification"
5299
6335
  ] }),
5300
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onDistributionRules, children: [
6336
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onDistributionRules, children: [
5301
6337
  /* @__PURE__ */ jsxRuntime.jsxs(
5302
6338
  "svg",
5303
6339
  {
@@ -5320,7 +6356,7 @@ function WalletButtonTemplate({
5320
6356
  ),
5321
6357
  "Distribution rules"
5322
6358
  ] }),
5323
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onSessions, children: [
6359
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onSessions, children: [
5324
6360
  /* @__PURE__ */ jsxRuntime.jsxs(
5325
6361
  "svg",
5326
6362
  {
@@ -5341,8 +6377,8 @@ function WalletButtonTemplate({
5341
6377
  ),
5342
6378
  "Active sessions"
5343
6379
  ] }),
5344
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "wallet-dropdown-divider" }),
5345
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item danger", onClick: onLogout, children: [
6380
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-wallet-dropdown-divider" }),
6381
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-wallet-dropdown-item pollar-danger", onClick: onLogout, children: [
5346
6382
  /* @__PURE__ */ jsxRuntime.jsxs(
5347
6383
  "svg",
5348
6384
  {
@@ -5386,9 +6422,12 @@ function WalletButton() {
5386
6422
  const walletType = wallet?.custody === "external" ? wallet.provider : null;
5387
6423
  const [open, setOpen] = react.useState(false);
5388
6424
  const [copied, setCopied] = react.useState(false);
6425
+ const [creating, setCreating] = react.useState(false);
6426
+ const [created, setCreated] = react.useState(false);
5389
6427
  const wrapperRef = react.useRef(null);
5390
6428
  const copyTimerRef = react.useRef(null);
5391
6429
  const isInProgress = transaction.step === "building" || transaction.step === "signing";
6430
+ const canCreateAccount = !created && wallet?.custody === "external" && wallet.existsOnStellar === false && wallet.fundingMode === "IMMEDIATE";
5392
6431
  const { theme = "light", accentColor = "#005DB4" } = styles;
5393
6432
  const isDark = theme === "dark";
5394
6433
  const dropdownBg = isDark ? "#18181b" : "#fff";
@@ -5423,6 +6462,20 @@ function WalletButton() {
5423
6462
  setOpen(false);
5424
6463
  getClient().logout();
5425
6464
  }
6465
+ async function handleCreateAccount() {
6466
+ if (creating) return;
6467
+ setCreating(true);
6468
+ try {
6469
+ const res = await getClient().createAccount();
6470
+ if (res.status === "success" || res.status === "pending") {
6471
+ setCreated(true);
6472
+ setOpen(false);
6473
+ await getClient().refreshBalance();
6474
+ }
6475
+ } finally {
6476
+ setCreating(false);
6477
+ }
6478
+ }
5426
6479
  function handleWalletBalance() {
5427
6480
  setOpen(false);
5428
6481
  openWalletBalanceModal();
@@ -5468,7 +6521,10 @@ function WalletButton() {
5468
6521
  wrapperRef,
5469
6522
  isInProgress,
5470
6523
  walletType,
6524
+ showCreateAccount: canCreateAccount,
6525
+ creatingAccount: creating,
5471
6526
  onToggleOpen: () => setOpen((v) => !v),
6527
+ onCreateAccount: handleCreateAccount,
5472
6528
  onCopy: handleCopy,
5473
6529
  onWalletBalance: handleWalletBalance,
5474
6530
  onTxHistory: handleTxHistory,
@@ -5486,6 +6542,7 @@ function WalletButton() {
5486
6542
 
5487
6543
  exports.DistributionRulesModal = DistributionRulesModal;
5488
6544
  exports.DistributionRulesModalTemplate = DistributionRulesModalTemplate;
6545
+ exports.EarnModal = EarnModal;
5489
6546
  exports.EnabledAssetsModal = EnabledAssetsModal;
5490
6547
  exports.EnabledAssetsModalTemplate = EnabledAssetsModalTemplate;
5491
6548
  exports.KycModal = KycModal;