@pollar/react 0.12.1-rc.25 → 0.12.1-rc.27

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
@@ -1311,7 +1311,7 @@ var PollarModalFooter = ({ language: languageProp }) => {
1311
1311
  /* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_POLLAR_WORDMARK_ON_DARK, alt: "Pollar", className: "pollar-footer-logo pollar-logo-on-dark" }),
1312
1312
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-footer-version", children: [
1313
1313
  "v",
1314
- "0.12.1-rc.25"
1314
+ "0.12.1-rc.27"
1315
1315
  ] })
1316
1316
  ] });
1317
1317
  };
@@ -4985,7 +4985,8 @@ function LoginModalTemplate({
4985
4985
  const cssVars = buildModalCssVars(theme, accentColor, styleOverrides, "hero");
4986
4986
  const status = authStateToStatus(authState.step);
4987
4987
  const isLoading = status === "LOADING";
4988
- const isEmailCodeError = authState.step === "error" && (authState.errorCode === core.AUTH_ERROR_CODES.EMAIL_CODE_EXPIRED || authState.errorCode === core.AUTH_ERROR_CODES.EMAIL_CODE_INVALID);
4988
+ const isEmailCodeError = authState.step === "error" && (authState.errorCode === core.AUTH_ERROR_CODES.EMAIL_CODE_EXPIRED || authState.errorCode === core.AUTH_ERROR_CODES.EMAIL_CODE_INVALID || // A rate limit or a server error on verify: the same code can go again.
4989
+ authState.errorCode === core.AUTH_ERROR_CODES.EMAIL_VERIFY_FAILED);
4989
4990
  const awaitingEmailCode = authState.step === "entering_code" || authState.step === "verifying_email_code" || isEmailCodeError;
4990
4991
  const statusMessage = authState.step === "error" ? core.authErrorMessage(authState.code, language) ?? authState.message : copy.status[authState.step];
4991
4992
  const BackButton = ({ onClick }) => /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-back-btn", onClick, "aria-label": copy.back, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -5408,6 +5409,10 @@ function LoginModal({ onClose, inline = false }) {
5408
5409
  getClient().cancelLogin();
5409
5410
  }
5410
5411
  function handleRetry() {
5412
+ if (authState.step === "error" && authState.errorCode === core.AUTH_ERROR_CODES.EMAIL_SEND_FAILED && authState.code === "RATE_LIMITED" && authState.clientSessionId && authState.email) {
5413
+ getClient().sendEmailCode(authState.email);
5414
+ return;
5415
+ }
5411
5416
  getClient().logout();
5412
5417
  if (styles.emailEnabled) {
5413
5418
  getClient().beginEmailLogin();
@@ -5513,6 +5518,7 @@ var RAMP_COPY = {
5513
5518
  SDK_RAMPS_QUOTE_EXPIRED: "This quote expired. Find a route again.",
5514
5519
  SDK_RAMPS_QUOTE_NOT_FOUND: "This quote is no longer available. Find a route again.",
5515
5520
  SDK_RAMPS_ACTION_STALE: "This step changed. It was refreshed; try again.",
5521
+ SDK_RAMPS_ORDER_NOT_CANCELLABLE: "This order can no longer be cancelled: its funds are already moving.",
5516
5522
  SDK_RAMPS_TX_NOT_FOUND: "This operation was not found.",
5517
5523
  SDK_RAMPS_WALLET_NOT_READY: "Approve the new wallet account on your device, then try again."
5518
5524
  },
@@ -5533,6 +5539,7 @@ var RAMP_COPY = {
5533
5539
  resumeOrderFailed: "Could not resume the operation.",
5534
5540
  checkPaymentFailed: "Could not check the payment. Please try again.",
5535
5541
  retryOrderFailed: "Could not try again. Please try again.",
5542
+ cancelOrderFailed: "Could not cancel the order. Please try again.",
5536
5543
  refreshFailed: "Could not refresh.",
5537
5544
  copyFailed: "Could not copy.",
5538
5545
  awaitingAccount: "Approve the new account on your device. The order starts once it is approved.",
@@ -5630,19 +5637,38 @@ var RAMP_COPY = {
5630
5637
  startAnother: "Start another operation",
5631
5638
  newQuote: "Get a new quote",
5632
5639
  keepsGoing: "This one keeps going; you can resume it later.",
5640
+ leave: {
5641
+ title: "Leave this purchase?",
5642
+ note: "Your order keeps going. You can come back to it from Buy.",
5643
+ stay: "Stay here",
5644
+ exit: "Leave, keep the order",
5645
+ cancel: "Cancel the order",
5646
+ cancelling: "Cancelling\u2026"
5647
+ },
5633
5648
  screens: {
5634
5649
  pay: (amount, currency) => `Pay ${amount} ${currency}`,
5635
5650
  send: (amount, code) => `Send ${amount} ${code}`,
5636
5651
  delivering: (code) => `Your ${code} is on its way`,
5637
5652
  payingOut: (currency) => `Your ${currency} is on its way to your account`,
5638
- done: "Done",
5639
- toCurrent: "Go to the current step",
5653
+ stepLabel: (position, total, title) => `Step ${position} of ${total}: ${title}`,
5654
+ finalStep: "Done",
5655
+ paidAt: "Paid",
5656
+ paidDone: (amount, currency) => `You paid ${amount} ${currency}.`,
5657
+ sentDone: (amount, code) => `You sent ${amount} ${code}.`,
5658
+ receivedDone: (amount, code, chain) => `You received ${amount} ${code} on ${chain}.`,
5659
+ payoutDone: (amount, currency) => `${amount} ${currency} were sent to your account.`,
5660
+ signedDone: "You approved this step.",
5661
+ ranDone: "This step is complete.",
5640
5662
  updatesItself: "This screen updates on its own.",
5641
5663
  preparing: "Preparing your payment\u2026",
5664
+ saveQr: "Save QR",
5665
+ savingQr: "Saving\u2026",
5666
+ savedQr: "QR saved",
5667
+ saveQrFailed: "Could not save the QR",
5668
+ qrFile: "payment",
5642
5669
  received: (amount) => `+${amount}`,
5643
5670
  arrived: (chain) => `It reached your wallet on ${chain}.`,
5644
5671
  paidOut: "It was sent to your account.",
5645
- finish: "Done",
5646
5672
  details: "Details"
5647
5673
  },
5648
5674
  somethingWrong: "Something went wrong.",
@@ -5659,6 +5685,7 @@ var RAMP_COPY = {
5659
5685
  SDK_RAMPS_QUOTE_EXPIRED: "Esta cotizaci\xF3n venci\xF3. Busca una ruta de nuevo.",
5660
5686
  SDK_RAMPS_QUOTE_NOT_FOUND: "Esta cotizaci\xF3n ya no est\xE1 disponible. Busca una ruta de nuevo.",
5661
5687
  SDK_RAMPS_ACTION_STALE: "Este paso cambi\xF3 y se actualiz\xF3. Intenta de nuevo.",
5688
+ SDK_RAMPS_ORDER_NOT_CANCELLABLE: "Esta orden ya no se puede cancelar: sus fondos ya est\xE1n en movimiento.",
5662
5689
  SDK_RAMPS_TX_NOT_FOUND: "No se encontr\xF3 esta operaci\xF3n.",
5663
5690
  SDK_RAMPS_WALLET_NOT_READY: "Aprueba la nueva cuenta de la billetera en tu dispositivo e intenta de nuevo."
5664
5691
  },
@@ -5679,6 +5706,7 @@ var RAMP_COPY = {
5679
5706
  resumeOrderFailed: "No se pudo retomar la operaci\xF3n.",
5680
5707
  checkPaymentFailed: "No se pudo verificar el pago. Intenta de nuevo.",
5681
5708
  retryOrderFailed: "No se pudo reintentar. Intenta de nuevo.",
5709
+ cancelOrderFailed: "No se pudo cancelar la orden. Intenta de nuevo.",
5682
5710
  refreshFailed: "No se pudo actualizar.",
5683
5711
  copyFailed: "No se pudo copiar.",
5684
5712
  awaitingAccount: "Aprueba la nueva cuenta en tu dispositivo. La orden comienza cuando la apruebes.",
@@ -5776,19 +5804,38 @@ var RAMP_COPY = {
5776
5804
  startAnother: "Iniciar otra operaci\xF3n",
5777
5805
  newQuote: "Pedir nueva cotizaci\xF3n",
5778
5806
  keepsGoing: "Esta sigue en curso; puedes retomarla m\xE1s tarde.",
5807
+ leave: {
5808
+ title: "\xBFSalir de esta compra?",
5809
+ note: "Tu orden sigue activa. Puedes retomarla desde Comprar.",
5810
+ stay: "Seguir aqu\xED",
5811
+ exit: "Salir, la orden sigue",
5812
+ cancel: "Cancelar la orden",
5813
+ cancelling: "Cancelando\u2026"
5814
+ },
5779
5815
  screens: {
5780
5816
  pay: (amount, currency) => `Paga ${amount} ${currency}`,
5781
5817
  send: (amount, code) => `Env\xEDa ${amount} ${code}`,
5782
5818
  delivering: (code) => `Tu ${code} est\xE1 en camino`,
5783
5819
  payingOut: (currency) => `Tus ${currency} van en camino a tu cuenta`,
5784
- done: "Hecho",
5785
- toCurrent: "Ir al paso actual",
5820
+ stepLabel: (position, total, title) => `Paso ${position} de ${total}: ${title}`,
5821
+ finalStep: "Listo",
5822
+ paidAt: "Pagado",
5823
+ paidDone: (amount, currency) => `Pagaste ${amount} ${currency}.`,
5824
+ sentDone: (amount, code) => `Enviaste ${amount} ${code}.`,
5825
+ receivedDone: (amount, code, chain) => `Recibiste ${amount} ${code} en ${chain}.`,
5826
+ payoutDone: (amount, currency) => `Se enviaron ${amount} ${currency} a tu cuenta.`,
5827
+ signedDone: "Aprobaste este paso.",
5828
+ ranDone: "Este paso est\xE1 completo.",
5786
5829
  updatesItself: "Esta pantalla se actualiza sola.",
5787
5830
  preparing: "Preparando tu pago\u2026",
5831
+ saveQr: "Guardar QR",
5832
+ savingQr: "Guardando\u2026",
5833
+ savedQr: "QR guardado",
5834
+ saveQrFailed: "No se pudo guardar el QR",
5835
+ qrFile: "pago",
5788
5836
  received: (amount) => `+${amount}`,
5789
5837
  arrived: (chain) => `Lleg\xF3 a tu wallet en ${chain}.`,
5790
5838
  paidOut: "Se envi\xF3 a tu cuenta.",
5791
- finish: "Listo",
5792
5839
  details: "Detalles"
5793
5840
  },
5794
5841
  somethingWrong: "Algo sali\xF3 mal.",
@@ -5805,6 +5852,7 @@ var RAMP_COPY = {
5805
5852
  SDK_RAMPS_QUOTE_EXPIRED: "Esta cota\xE7\xE3o expirou. Busque uma rota de novo.",
5806
5853
  SDK_RAMPS_QUOTE_NOT_FOUND: "Esta cota\xE7\xE3o n\xE3o est\xE1 mais dispon\xEDvel. Busque uma rota de novo.",
5807
5854
  SDK_RAMPS_ACTION_STALE: "Esta etapa mudou e foi atualizada. Tente de novo.",
5855
+ SDK_RAMPS_ORDER_NOT_CANCELLABLE: "Esta ordem n\xE3o pode mais ser cancelada: os fundos j\xE1 est\xE3o em movimento.",
5808
5856
  SDK_RAMPS_TX_NOT_FOUND: "Esta opera\xE7\xE3o n\xE3o foi encontrada.",
5809
5857
  SDK_RAMPS_WALLET_NOT_READY: "Aprove a nova conta da carteira no seu dispositivo e tente de novo."
5810
5858
  },
@@ -5825,6 +5873,7 @@ var RAMP_COPY = {
5825
5873
  resumeOrderFailed: "N\xE3o foi poss\xEDvel retomar a opera\xE7\xE3o.",
5826
5874
  checkPaymentFailed: "N\xE3o foi poss\xEDvel verificar o pagamento. Tente de novo.",
5827
5875
  retryOrderFailed: "N\xE3o foi poss\xEDvel tentar de novo. Tente de novo.",
5876
+ cancelOrderFailed: "N\xE3o foi poss\xEDvel cancelar a ordem. Tente de novo.",
5828
5877
  refreshFailed: "N\xE3o foi poss\xEDvel atualizar.",
5829
5878
  copyFailed: "N\xE3o foi poss\xEDvel copiar.",
5830
5879
  awaitingAccount: "Aprove a nova conta no seu dispositivo. A ordem come\xE7a assim que voc\xEA aprovar.",
@@ -5922,19 +5971,38 @@ var RAMP_COPY = {
5922
5971
  startAnother: "Iniciar outra opera\xE7\xE3o",
5923
5972
  newQuote: "Pedir nova cota\xE7\xE3o",
5924
5973
  keepsGoing: "Esta continua em andamento; voc\xEA pode retom\xE1-la depois.",
5974
+ leave: {
5975
+ title: "Sair desta compra?",
5976
+ note: "Sua ordem continua ativa. Voc\xEA pode retom\xE1-la em Comprar.",
5977
+ stay: "Ficar aqui",
5978
+ exit: "Sair, manter a ordem",
5979
+ cancel: "Cancelar a ordem",
5980
+ cancelling: "Cancelando\u2026"
5981
+ },
5925
5982
  screens: {
5926
5983
  pay: (amount, currency) => `Pague ${amount} ${currency}`,
5927
5984
  send: (amount, code) => `Envie ${amount} ${code}`,
5928
5985
  delivering: (code) => `Seu ${code} est\xE1 a caminho`,
5929
5986
  payingOut: (currency) => `Seus ${currency} est\xE3o a caminho da sua conta`,
5930
- done: "Conclu\xEDdo",
5931
- toCurrent: "Ir para a etapa atual",
5987
+ stepLabel: (position, total, title) => `Etapa ${position} de ${total}: ${title}`,
5988
+ finalStep: "Pronto",
5989
+ paidAt: "Pago em",
5990
+ paidDone: (amount, currency) => `Voc\xEA pagou ${amount} ${currency}.`,
5991
+ sentDone: (amount, code) => `Voc\xEA enviou ${amount} ${code}.`,
5992
+ receivedDone: (amount, code, chain) => `Voc\xEA recebeu ${amount} ${code} na ${chain}.`,
5993
+ payoutDone: (amount, currency) => `${amount} ${currency} foram enviados para a sua conta.`,
5994
+ signedDone: "Voc\xEA aprovou esta etapa.",
5995
+ ranDone: "Esta etapa est\xE1 conclu\xEDda.",
5932
5996
  updatesItself: "Esta tela se atualiza sozinha.",
5933
5997
  preparing: "Preparando o seu pagamento\u2026",
5998
+ saveQr: "Salvar QR",
5999
+ savingQr: "Salvando\u2026",
6000
+ savedQr: "QR salvo",
6001
+ saveQrFailed: "N\xE3o foi poss\xEDvel salvar o QR",
6002
+ qrFile: "pagamento",
5934
6003
  received: (amount) => `+${amount}`,
5935
6004
  arrived: (chain) => `Chegou \xE0 sua carteira na ${chain}.`,
5936
6005
  paidOut: "Foi enviado para a sua conta.",
5937
- finish: "Pronto",
5938
6006
  details: "Detalhes"
5939
6007
  },
5940
6008
  somethingWrong: "Algo deu errado.",
@@ -6172,6 +6240,97 @@ function rampOrderScreens(order, language) {
6172
6240
  return { ...screen, status: stopped || core.rampLegStatus(screen.leg) === "failed" ? "failed" : "current" };
6173
6241
  });
6174
6242
  }
6243
+ var SVG_SIDE = 1024;
6244
+ function imageSrc(image) {
6245
+ return image.encoding === "base64" ? `data:${image.mediaType};base64,${image.data}` : `data:${image.mediaType};charset=utf-8,${encodeURIComponent(image.data)}`;
6246
+ }
6247
+ function base64Blob(data, type) {
6248
+ const bytes = Uint8Array.from(atob(data), (c) => c.charCodeAt(0));
6249
+ return new Blob([bytes], { type });
6250
+ }
6251
+ async function scannableFile(image) {
6252
+ if (image.encoding === "base64" && (image.mediaType === "image/png" || image.mediaType === "image/jpeg"))
6253
+ return base64Blob(image.data, image.mediaType);
6254
+ const element = new Image();
6255
+ element.decoding = "async";
6256
+ element.src = imageSrc(image);
6257
+ await element.decode();
6258
+ const svg = image.mediaType === "image/svg+xml";
6259
+ const width = svg ? SVG_SIDE : element.naturalWidth;
6260
+ const height = svg ? Math.round(SVG_SIDE * (element.naturalHeight || 1) / (element.naturalWidth || 1)) : element.naturalHeight;
6261
+ const canvas = document.createElement("canvas");
6262
+ canvas.width = width;
6263
+ canvas.height = height;
6264
+ const context = canvas.getContext("2d");
6265
+ if (!context) throw new Error("canvas unavailable");
6266
+ context.fillStyle = "#ffffff";
6267
+ context.fillRect(0, 0, width, height);
6268
+ context.drawImage(element, 0, 0, width, height);
6269
+ return new Promise(
6270
+ (resolve, reject) => canvas.toBlob((blob) => blob ? resolve(blob) : reject(new Error("png encoding failed")), "image/png")
6271
+ );
6272
+ }
6273
+ async function saveFile(blob, name) {
6274
+ const file = new File([blob], name, { type: blob.type });
6275
+ const touch = typeof window.matchMedia === "function" && window.matchMedia("(pointer: coarse)").matches;
6276
+ if (touch && navigator.canShare?.({ files: [file] })) {
6277
+ try {
6278
+ await navigator.share({ files: [file] });
6279
+ return "saved";
6280
+ } catch (error) {
6281
+ if (error.name === "AbortError") return "dismissed";
6282
+ }
6283
+ }
6284
+ const url = URL.createObjectURL(blob);
6285
+ const link = document.createElement("a");
6286
+ link.href = url;
6287
+ link.download = name;
6288
+ document.body.appendChild(link);
6289
+ link.click();
6290
+ link.remove();
6291
+ setTimeout(() => URL.revokeObjectURL(url), 1e4);
6292
+ return "saved";
6293
+ }
6294
+ function SaveQrButton({
6295
+ image,
6296
+ fileName,
6297
+ labels
6298
+ }) {
6299
+ const [state, setState] = react.useState("idle");
6300
+ const timer = react.useRef(null);
6301
+ react.useEffect(
6302
+ () => () => {
6303
+ if (timer.current) clearTimeout(timer.current);
6304
+ },
6305
+ []
6306
+ );
6307
+ async function save() {
6308
+ setState("saving");
6309
+ try {
6310
+ const blob = await scannableFile(image);
6311
+ const extension = blob.type === "image/jpeg" ? "jpg" : "png";
6312
+ const outcome = await saveFile(blob, `${fileName}.${extension}`);
6313
+ setState(outcome === "saved" ? "saved" : "idle");
6314
+ } catch {
6315
+ setState("failed");
6316
+ }
6317
+ if (timer.current) clearTimeout(timer.current);
6318
+ timer.current = setTimeout(() => setState("idle"), 2500);
6319
+ }
6320
+ return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-btn-secondary pollar-ramp-save-qr", disabled: state === "saving", onClick: save, children: [
6321
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
6322
+ "path",
6323
+ {
6324
+ d: "M8 2v8m0 0 3-3m-3 3L5 7M3 12.5h10",
6325
+ stroke: "currentColor",
6326
+ strokeWidth: "1.6",
6327
+ strokeLinecap: "round",
6328
+ strokeLinejoin: "round"
6329
+ }
6330
+ ) }),
6331
+ state === "saving" ? labels.saving : state === "saved" ? labels.saved : state === "failed" ? labels.failed : labels.save
6332
+ ] });
6333
+ }
6175
6334
  function scannableImageSrc(image) {
6176
6335
  return image.encoding === "base64" ? `data:${image.mediaType};base64,${image.data}` : `data:${image.mediaType};charset=utf-8,${encodeURIComponent(image.data)}`;
6177
6336
  }
@@ -6303,7 +6462,11 @@ function RampWidgetTemplate({
6303
6462
  onRefresh,
6304
6463
  onClose,
6305
6464
  language: languageProp,
6306
- confirmation = null
6465
+ confirmation = null,
6466
+ onCancelOrder,
6467
+ cosignPrompt = null,
6468
+ cancelling = false,
6469
+ cancelError = null
6307
6470
  }) {
6308
6471
  const language = useInheritedLanguage(languageProp);
6309
6472
  const cssVars = buildModalCssVars(theme, accentColor, styleOverrides, "hero");
@@ -6312,7 +6475,12 @@ function RampWidgetTemplate({
6312
6475
  const sendUnit = onramp ? fiat?.currency : asset?.code;
6313
6476
  const [detailsOpen, setDetailsOpen] = react.useState(false);
6314
6477
  const [viewing, setViewing] = react.useState(null);
6315
- react.useEffect(() => setViewing(null), [order?.id]);
6478
+ const [leaving, setLeaving] = react.useState(false);
6479
+ const [doneDetailsOpen, setDoneDetailsOpen] = react.useState(false);
6480
+ react.useEffect(() => {
6481
+ setViewing(null);
6482
+ setLeaving(false);
6483
+ }, [order?.id]);
6316
6484
  const routeName = (quote) => quote.legs.map((leg) => core.rampLegTitle(leg, language)).join(" \xB7 ");
6317
6485
  const rate = (() => {
6318
6486
  if (!chosenQuote) return null;
@@ -6399,11 +6567,44 @@ function RampWidgetTemplate({
6399
6567
  const shown = screens[shownScreen];
6400
6568
  const askedInstead = order?.pendingAction?.kind === "KYC" || !!shown?.key.endsWith(":pay") && order?.pendingAction?.legIndex === shown.leg.index && !["FIAT_PAYMENT", "NONE"].includes(order.pendingAction.kind);
6401
6569
  const firstLeg = order?.legs[0];
6570
+ const payment = order?.pendingAction?.kind === "FIAT_PAYMENT" ? order.pendingAction.instructions : null;
6571
+ const qrFileName = [copy.screens.qrFile, payment?.amount, payment?.currency, order?.id.slice(-8)].filter(Boolean).join("-");
6402
6572
  const orderSummary = firstLeg && receive ? `${amountText(firstLeg.amountInPlanned, language)} ${firstLeg.from.kind === "fiat" ? firstLeg.from.currency : firstLeg.from.code} \u2192 ${receive.estimated ? "~" : ""}${amountText(receive.amount, language)} ${receive.unit}` : null;
6403
6573
  const lastLeg = order?.legs[order.legs.length - 1];
6404
6574
  const arrivedText = lastLeg?.to.kind === "asset" ? copy.screens.arrived(CHAIN_NAME[lastLeg.to.chain] ?? lastLeg.to.chain) : copy.screens.paidOut;
6575
+ const requestClose = () => step === "status" && order && !settled ? setLeaving(true) : onClose();
6576
+ const cancellable = !!order && !settled && order.pendingAction?.kind !== "COSIGN_APPROVAL" && order.legs.every((leg) => leg.status !== "COMPLETED" && leg.status !== "HELD" && leg.paymentStatus !== "received");
6577
+ const doneText = (screen) => {
6578
+ const leg = screen.leg;
6579
+ const unit = (node) => node.kind === "fiat" ? node.currency : node.code;
6580
+ const inAmount = amountText(leg.amountInActual ?? leg.amountInPlanned, language);
6581
+ const outAmount = amountText(leg.amountOutActual ?? leg.amountOutPlanned, language);
6582
+ if (screen.key.endsWith(":pay"))
6583
+ return leg.kind === "PROVIDER_ONRAMP" ? copy.screens.paidDone(inAmount, unit(leg.from)) : copy.screens.sentDone(inAmount, unit(leg.from));
6584
+ if (screen.key.endsWith(":deliver"))
6585
+ return leg.to.kind === "asset" ? copy.screens.receivedDone(outAmount, leg.to.code, CHAIN_NAME[leg.to.chain] ?? leg.to.chain) : copy.screens.payoutDone(outAmount, leg.to.currency);
6586
+ return screen.kind === "action" ? copy.screens.signedDone : copy.screens.ranDone;
6587
+ };
6405
6588
  const finalNote = order?.legs.map((leg) => core.rampLegNote(leg, language)).find((note) => note !== null) ?? null;
6406
- const screenRows = (screen) => screen.steps.length ? screen.steps.flatMap(
6589
+ const paidQr = (screen) => {
6590
+ if (!screen.key.endsWith(":pay")) return null;
6591
+ const instructions = screen.leg.paymentRequest?.instructions;
6592
+ return instructions?.kind === "qr" ? instructions.scannable?.image ?? null : null;
6593
+ };
6594
+ const paidRows = (screen) => {
6595
+ if (!screen.key.endsWith(":pay") || !order) return [];
6596
+ const at = screen.leg.paymentReceivedAt;
6597
+ return [
6598
+ ...at ? [
6599
+ {
6600
+ label: copy.screens.paidAt,
6601
+ value: new Date(at).toLocaleString(language, { dateStyle: "medium", timeStyle: "short" })
6602
+ }
6603
+ ] : [],
6604
+ { label: copy.order, value: `\u2026${order.id.slice(-8)}`, copyValue: order.id, mono: true }
6605
+ ];
6606
+ };
6607
+ const screenRowsOf = (screen) => screen.steps.length ? screen.steps.flatMap(
6407
6608
  (st) => st.hash ? [
6408
6609
  {
6409
6610
  label: core.rampStepTitle(st, screen.leg, language),
@@ -6420,6 +6621,7 @@ function RampWidgetTemplate({
6420
6621
  copyValue: screen.leg.onchainTxHash
6421
6622
  }
6422
6623
  ] : [];
6624
+ const screenRows = (screen) => [...paidRows(screen), ...screenRowsOf(screen)];
6423
6625
  const stepTitle = {
6424
6626
  input: onramp ? copy.title.buy : copy.title.sell,
6425
6627
  loading_quote: copy.title.finding,
@@ -6453,16 +6655,6 @@ function RampWidgetTemplate({
6453
6655
  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 3 5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
6454
6656
  }
6455
6657
  ),
6456
- step === "status" && shownScreen > 0 && shownScreen <= currentScreen && /* @__PURE__ */ jsxRuntime.jsx(
6457
- "button",
6458
- {
6459
- type: "button",
6460
- className: "pollar-back-btn pollar-ramp-back",
6461
- onClick: () => setViewing(shownScreen - 1),
6462
- "aria-label": copy.back,
6463
- 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 3 5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
6464
- }
6465
- ),
6466
6658
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-header-text", children: [
6467
6659
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: stepTitle[step] }),
6468
6660
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-subtitle", children: stepSubtitle[step] })
@@ -6499,7 +6691,7 @@ function RampWidgetTemplate({
6499
6691
  )
6500
6692
  }
6501
6693
  ),
6502
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": copy.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" }) }) })
6694
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: requestClose, "aria-label": copy.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" }) }) })
6503
6695
  ] })
6504
6696
  ] }),
6505
6697
  flowStepIndex >= 0 && flowSteps.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-steps", children: [
@@ -6519,15 +6711,33 @@ function RampWidgetTemplate({
6519
6711
  }
6520
6712
  ) }, label)) })
6521
6713
  ] }),
6522
- step === "status" && screens.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "pollar-ramp-screens-bar", "aria-label": copy.progress, children: [...screens.map((s) => s.key), "final"].map((key, i) => /* @__PURE__ */ jsxRuntime.jsx(
6523
- "li",
6524
- {
6525
- "data-done": i < currentScreen || completed && i === screens.length || void 0,
6526
- "data-shown": i === shownScreen || void 0,
6527
- "data-failed": screens[i]?.status === "failed" || void 0
6528
- },
6529
- key
6530
- )) }),
6714
+ step === "status" && screens.length > 0 && !(leaving && !settled) && /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "pollar-ramp-stepper", "aria-label": copy.progress, children: [...screens, null].map((screen, i) => {
6715
+ const state = i < currentScreen || completed && i === screens.length ? "done" : screen?.status === "failed" ? "failed" : i === currentScreen ? "current" : "upcoming";
6716
+ const busy = state === "current" && !settled && !(screen?.kind === "action" && order?.pendingAction);
6717
+ return /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(
6718
+ "button",
6719
+ {
6720
+ type: "button",
6721
+ className: "pollar-ramp-stepper-step",
6722
+ "data-state": state,
6723
+ "data-shown": i === shownScreen || void 0,
6724
+ "aria-current": i === shownScreen ? "step" : void 0,
6725
+ "aria-label": copy.screens.stepLabel(i + 1, screens.length + 1, screen?.title ?? copy.screens.finalStep),
6726
+ disabled: i > currentScreen,
6727
+ onClick: () => setViewing(i >= currentScreen ? null : i),
6728
+ children: state === "done" ? /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
6729
+ "path",
6730
+ {
6731
+ d: "M3 8.5 6.5 12 13 4.5",
6732
+ stroke: "currentColor",
6733
+ strokeWidth: "2.2",
6734
+ strokeLinecap: "round",
6735
+ strokeLinejoin: "round"
6736
+ }
6737
+ ) }) : state === "failed" ? /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "12", height: "12", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 3l10 10M13 3 3 13", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round" }) }) : busy ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-hidden": true }) : i + 1
6738
+ }
6739
+ ) }, screen?.key ?? "final");
6740
+ }) }),
6531
6741
  step === "input" && pendingOrders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "pollar-ramp-payment pollar-ramp-saved", "aria-label": copy.pendingAria, children: [
6532
6742
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.pendingNote }),
6533
6743
  pendingOrders.map((pending) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-saved-row", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -6815,7 +7025,30 @@ function RampWidgetTemplate({
6815
7025
  }
6816
7026
  ) })
6817
7027
  ] }),
6818
- step === "status" && order && view && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-payment", children: shownScreen === screens.length ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7028
+ step === "status" && order && view && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-payment", children: leaving && !settled ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-leave", children: [
7029
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "pollar-ramp-screen-title", children: copy.leave.title }),
7030
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.leave.note }),
7031
+ cancelError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-field-error", children: cancelError }),
7032
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: () => setLeaving(false), children: copy.leave.stay }),
7033
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onClose, children: copy.leave.exit }),
7034
+ /* @__PURE__ */ jsxRuntime.jsx(
7035
+ "button",
7036
+ {
7037
+ type: "button",
7038
+ className: "pollar-ramp-leave-link",
7039
+ onClick: () => {
7040
+ setLeaving(false);
7041
+ onNewOrder();
7042
+ },
7043
+ children: copy.startAnother
7044
+ }
7045
+ ),
7046
+ onCancelOrder && cancellable && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-ramp-leave-cancel", disabled: cancelling, onClick: onCancelOrder, children: cancelling ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7047
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
7048
+ " ",
7049
+ copy.leave.cancelling
7050
+ ] }) : copy.leave.cancel })
7051
+ ] }) : shownScreen === screens.length ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6819
7052
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-final", children: [
6820
7053
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-final-mark", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "28", height: "28", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
6821
7054
  "path",
@@ -6831,12 +7064,10 @@ function RampWidgetTemplate({
6831
7064
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: arrivedText }),
6832
7065
  finalNote && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: finalNote })
6833
7066
  ] }),
6834
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: onClose, children: copy.screens.finish }),
6835
7067
  /* @__PURE__ */ jsxRuntime.jsx(TxReview, { data: { title: "", kind: "other", rows: orderRows }, language })
6836
7068
  ] }) : shownScreen < currentScreen ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6837
- /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "pollar-ramp-screen-title", children: screens[shownScreen].title }),
6838
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-ramp-screen-state", children: [
6839
- /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
7069
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-done", children: [
7070
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-done-mark", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "30", height: "30", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
6840
7071
  "path",
6841
7072
  {
6842
7073
  d: "M3 8.5 6.5 12 13 4.5",
@@ -6845,11 +7076,30 @@ function RampWidgetTemplate({
6845
7076
  strokeLinecap: "round",
6846
7077
  strokeLinejoin: "round"
6847
7078
  }
6848
- ) }),
6849
- copy.screens.done
7079
+ ) }) }),
7080
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "pollar-ramp-done-title", children: screens[shownScreen].title }),
7081
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: doneText(screens[shownScreen]) })
6850
7082
  ] }),
6851
- screenRows(screens[shownScreen]).length > 0 && /* @__PURE__ */ jsxRuntime.jsx(TxReview, { data: { title: "", kind: "other", rows: screenRows(screens[shownScreen]) }, language }),
6852
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: () => setViewing(null), children: copy.screens.toCurrent })
7083
+ screenRows(screens[shownScreen]).length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
7084
+ TxReview,
7085
+ {
7086
+ data: { title: "", kind: "other", rows: screenRows(screens[shownScreen]) },
7087
+ open: doneDetailsOpen,
7088
+ onToggle: () => setDoneDetailsOpen((open) => !open),
7089
+ language
7090
+ }
7091
+ ),
7092
+ doneDetailsOpen && paidQr(screens[shownScreen]) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-paid-qr", children: [
7093
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: copy.paymentQr }),
7094
+ paidQr(screens[shownScreen]).inlineSafe ? /* @__PURE__ */ jsxRuntime.jsx(
7095
+ "div",
7096
+ {
7097
+ className: "pollar-ramp-qr",
7098
+ "aria-label": copy.paymentQr,
7099
+ dangerouslySetInnerHTML: { __html: paidQr(screens[shownScreen]).data }
7100
+ }
7101
+ ) : /* @__PURE__ */ jsxRuntime.jsx("img", { src: scannableImageSrc(paidQr(screens[shownScreen])), alt: copy.paymentQr })
7102
+ ] })
6853
7103
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6854
7104
  shown && /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "pollar-ramp-screen-title", "data-status": shown.status, children: askedInstead ? view.title : shown.title }),
6855
7105
  shown?.status === "failed" && shown.leg.failure && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-field-error", children: core.rampFailureReason(shown.leg.failure, language) }),
@@ -6871,6 +7121,7 @@ function RampWidgetTemplate({
6871
7121
  ] })
6872
7122
  ] }, s.kind)) }),
6873
7123
  confirmation && /* @__PURE__ */ jsxRuntime.jsx(InlineConfirm, { confirmation, language, network }),
7124
+ cosignPrompt,
6874
7125
  order.failure && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
6875
7126
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: copy.whatToDo }),
6876
7127
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: core.rampOrderResolutionText(order, language) }),
@@ -6910,7 +7161,20 @@ function RampWidgetTemplate({
6910
7161
  alt: copy.paymentQr,
6911
7162
  style: { width: "100%", maxWidth: 220, height: "auto", display: "block", margin: "0 auto" }
6912
7163
  }
6913
- ) })
7164
+ ) }),
7165
+ /* @__PURE__ */ jsxRuntime.jsx(
7166
+ SaveQrButton,
7167
+ {
7168
+ image: view.scannable.image,
7169
+ fileName: qrFileName,
7170
+ labels: {
7171
+ save: copy.screens.saveQr,
7172
+ saving: copy.screens.savingQr,
7173
+ saved: copy.screens.savedQr,
7174
+ failed: copy.screens.saveQrFailed
7175
+ }
7176
+ }
7177
+ )
6914
7178
  ] }),
6915
7179
  !settled && view.codeMissing && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", style: { color: "var(--pollar-error-text)" }, children: copy.codeMissing }),
6916
7180
  !settled && view.scannable?.payload && view.scannable.payloadLabel && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
@@ -6956,7 +7220,7 @@ function RampWidgetTemplate({
6956
7220
  ] }) : copy.paid }),
6957
7221
  !settled && view.canSign && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", disabled: signing, onClick: onSign, children: signing ? copy.waitingWallet : copy.authorize }),
6958
7222
  !settled && view.action?.kind === "SIGNATURE" && !view.canSign && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.preparingSignature }),
6959
- !settled && view.canApprove && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: onApprove, children: copy.approveOnDevice }),
7223
+ !settled && view.canApprove && !cosignPrompt && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: onApprove, children: copy.approveOnDevice }),
6960
7224
  !settled && view.link && /* @__PURE__ */ jsxRuntime.jsx(
6961
7225
  "a",
6962
7226
  {
@@ -6969,8 +7233,7 @@ function RampWidgetTemplate({
6969
7233
  ),
6970
7234
  !settled && order.pendingAction?.kind === "KYC" && !view.link && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: view.note ?? copy.providerReviewing }),
6971
7235
  pollTrouble && !settled && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.serverTrouble }),
6972
- errorMsg && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-field-error", children: errorMsg }),
6973
- !settled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-explore", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onNewOrder, children: copy.startAnother }) })
7236
+ errorMsg && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-field-error", children: errorMsg })
6974
7237
  ] }) }),
6975
7238
  step === "error" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6976
7239
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: errorMsg ?? copy.somethingWrong }),
@@ -7581,243 +7844,831 @@ function ProviderRegistrationModal({
7581
7844
  }
7582
7845
  ) });
7583
7846
  }
7584
- var PAYMENT_CHECK_EVERY_MS = 1e4;
7585
- var PAYMENT_CHECK_WINDOW_MS = 2 * 6e4;
7586
- function rampErrorMessage(error, fallback, copy, language) {
7587
- const unavailable = core.appUnavailableMessage(error, language);
7588
- if (unavailable) return unavailable;
7589
- if (core.isPollarApiError(error)) {
7590
- const known = copy.errors[error.code];
7591
- if (known) return known;
7592
- const message = error.body.message;
7593
- if (typeof message === "string" && message && !/^[A-Z0-9_]+$/.test(message)) return message;
7594
- }
7595
- return fallback;
7596
- }
7597
- var DECIMAL = /^\d+(\.\d+)?$/;
7598
- var QUOTE_DEBOUNCE_MS = 600;
7599
- function seededSelection(routes, seed) {
7600
- const countries = core.rampCountries(routes);
7601
- const wanted = seed.country?.trim().toUpperCase();
7602
- const country = wanted ? countries.find((c) => c.country === wanted) : countries[0];
7603
- if (!country) return null;
7604
- const fiat = country.fiats.find((f) => f.currency === seed.fiat?.trim().toUpperCase()) ?? null;
7605
- const resolvedFiat = fiat ?? country.fiats[0];
7606
- const asset = routes.find(
7607
- (r) => r.fiat.country === country.country && resolvedFiat !== void 0 && fiatKey(r.fiat) === fiatKey(resolvedFiat) && r.asset.code.toUpperCase() === seed.asset?.trim().toUpperCase()
7608
- )?.asset;
7609
- const amount = seed.amount?.trim() ?? "";
7610
- return {
7611
- country: country.country,
7612
- fiatChoice: fiat ? fiatKey(fiat) : "",
7613
- assetChoice: asset ? assetKey3(asset) : "",
7614
- amount: DECIMAL.test(amount) ? amount : ""
7615
- };
7616
- }
7617
- async function signLegWithWallet(client, orderId, actionId, copy) {
7618
- const lent = [];
7619
- const lend = (chain, encoding, handler) => {
7847
+ function useCosign() {
7848
+ const { getClient, isAuthenticated } = usePollar();
7849
+ const [state, setState] = react.useState({ pending: [] });
7850
+ const [loaded, setLoaded] = react.useState(false);
7851
+ react.useEffect(() => getClient().onCosignStateChange(setState), [getClient]);
7852
+ const refresh = react.useCallback(async () => {
7853
+ if (!isAuthenticated) return;
7620
7854
  try {
7621
- lent.push(client.registerRampSigningHandler(chain, encoding, handler));
7622
- } catch {
7855
+ await getClient().cosign.pending();
7856
+ } finally {
7857
+ setLoaded(true);
7623
7858
  }
7859
+ }, [getClient, isAuthenticated]);
7860
+ react.useEffect(() => {
7861
+ void refresh();
7862
+ }, [refresh]);
7863
+ return {
7864
+ pending: state.pending,
7865
+ ...state.lastResolved ? { lastResolved: state.lastResolved } : {},
7866
+ loaded,
7867
+ refresh,
7868
+ approve: react.useCallback((request) => getClient().cosign.approve(request), [getClient]),
7869
+ reject: react.useCallback((request) => getClient().cosign.reject(request), [getClient]),
7870
+ verify: react.useCallback((request) => getClient().cosign.verify(request), [getClient]),
7871
+ inspectQuorum: react.useCallback(() => getClient().cosign.inspectQuorum(), [getClient]),
7872
+ devices: react.useCallback(() => getClient().cosign.devices(), [getClient]),
7873
+ revokeDevice: react.useCallback(
7874
+ (deviceId, options) => getClient().cosign.revokeDevice(deviceId, options),
7875
+ [getClient]
7876
+ ),
7877
+ switchCustody: react.useCallback((to) => getClient().cosign.switchCustody(to), [getClient])
7624
7878
  };
7625
- lend("STELLAR", "xdr", async (action) => {
7626
- const wallet = client.getWallet();
7627
- if (!wallet) throw new Error(copy.connectStellarWallet);
7628
- core.assertRampStellarSigner(action, wallet.address);
7629
- const outcome = await client.signTx(action.payload.value);
7630
- if (client.getWallet()?.address !== wallet.address) throw new Error(copy.walletChanged);
7631
- if (outcome.status === "signed") return outcome.signedXdr;
7632
- throw new Error(
7633
- outcome.status === "error" ? outcome.message ?? outcome.details ?? copy.signingCancelled : copy.signingCancelled
7634
- );
7635
- });
7636
- lend("SOLANA", "solana-v0-json", async (action) => {
7637
- const payload = JSON.parse(action.payload.value);
7638
- const solanaWallet = () => client.getWallets().find((w) => w.chain === "SOLANA" && w.custody === "external");
7639
- const wallet = solanaWallet();
7640
- if (!wallet || payload.from !== wallet.address || !payload.unsignedTransaction) throw new Error(copy.solanaWalletMismatch);
7641
- const signed = await client.signSolanaTransaction(payload.unsignedTransaction);
7642
- if (solanaWallet()?.address !== wallet.address) throw new Error(copy.walletChanged);
7643
- return signed;
7644
- });
7645
- try {
7646
- return await client.signRampLeg(orderId, actionId);
7647
- } finally {
7648
- for (const release of lent) release();
7649
- }
7650
7879
  }
7651
- function RampWidget({ onClose, language: languageProp, initial }) {
7652
- const {
7653
- getClient,
7654
- styles,
7655
- network,
7656
- openCosignModal,
7657
- setCosignNextStep,
7658
- openRecoveryModal,
7659
- recovery,
7660
- recoveryLocked,
7661
- appConfig,
7662
- cosign,
7663
- refreshWalletBalance
7664
- } = usePollar();
7665
- const client = getClient();
7666
- const language = useModalLanguage(languageProp);
7667
- const copy = RAMP_COPY[language];
7668
- const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
7669
- const [step, setStep] = react.useState("input");
7670
- const confirmation = useInlineConfirmation(step === "status");
7671
- const [direction, setDirection] = react.useState(initial?.direction === "sell" ? "OFFRAMP" : "ONRAMP");
7672
- const seedRef = react.useRef(
7673
- initial ? { direction: initial.direction === "sell" ? "OFFRAMP" : "ONRAMP", options: initial } : null
7674
- );
7675
- const [routes, setRoutes] = react.useState([]);
7676
- const [routesLoading, setRoutesLoading] = react.useState(true);
7677
- const [country, setCountry] = react.useState("");
7678
- const [fiatChoice, setFiatChoice] = react.useState("");
7679
- const [assetChoice, setAssetChoice] = react.useState("");
7680
- const [amount, setAmount] = react.useState("");
7681
- const [quotes, setQuotes] = react.useState([]);
7682
- const [rejected, setRejected] = react.useState([]);
7683
- const [selected, setSelected] = react.useState(null);
7684
- const [startingQuoteId, setStartingQuoteId] = react.useState(null);
7685
- const [fieldValues, setFieldValues] = react.useState({});
7686
- const [order, setOrder] = react.useState(null);
7687
- const [pendingOrders, setPendingOrders] = react.useState([]);
7688
- const [isLoading, setIsLoading] = react.useState(false);
7689
- const [refreshing, setRefreshing] = react.useState(false);
7690
- const [signing, setSigning] = react.useState(false);
7691
- const [errorMsg, setErrorMsg] = react.useState(null);
7692
- const [verifying, setVerifying] = react.useState(null);
7693
- const [trustingAsset, setTrustingAsset] = react.useState(null);
7694
- const [walletBusy, setWalletBusy] = react.useState(null);
7695
- const [retrying, setRetrying] = react.useState(false);
7696
- const [awaitingAccount, setAwaitingAccount] = react.useState(null);
7697
- const [pollTrouble, setPollTrouble] = react.useState(false);
7698
- const [pollKey, setPollKey] = react.useState(0);
7699
- const [paymentCheckUntil, setPaymentCheckUntil] = react.useState(null);
7700
- const checkErrorRef = react.useRef(null);
7701
- const promptedApproval = react.useRef(null);
7702
- const custodyChoice = appConfig.application?.walletCustodyMode === "USER_CHOICE";
7703
- const appChains = appConfig.application?.chains;
7704
- const verifyAttempt = react.useRef(null);
7705
- const countries = react.useMemo(() => core.rampCountries(routes), [routes]);
7706
- const fiats = countries.find((c) => c.country === country)?.fiats ?? [];
7707
- const fiat = fiats.find((f) => fiatKey(f) === fiatChoice) ?? fiats[0] ?? null;
7708
- const assets = react.useMemo(() => {
7709
- const seen = /* @__PURE__ */ new Map();
7710
- for (const route of routes)
7711
- if (fiat && route.fiat.country === country && fiatKey(route.fiat) === fiatKey(fiat))
7712
- seen.set(assetKey3(route.asset), route.asset);
7713
- return [...seen.values()];
7714
- }, [routes, country, fiat]);
7715
- const asset = assets.find((a) => assetKey3(a) === assetChoice) ?? assets[0] ?? null;
7716
- const fields = selected ? core.rampQuoteFields(selected, language) : [];
7717
- const sellAvailable = useWalletAvailable(
7718
- direction === "OFFRAMP" && asset ? { chain: asset.chain, code: asset.code, issuer: asset.identifier } : null
7719
- );
7720
- const [quoting, setQuoting] = react.useState(false);
7721
- const [routeChoice, setRouteChoice] = react.useState(BEST_ROUTE);
7722
- const quoteRun = react.useRef(0);
7723
- const quoteInput = step === "input" && fiat && asset && DECIMAL.test(amount.trim()) && Number(amount) > 0;
7724
- const quoteKey = quoteInput ? `${direction}|${fiatKey(fiat)}|${assetKey3(asset)}|${amount.trim()}` : null;
7725
- react.useEffect(() => {
7726
- const run = ++quoteRun.current;
7727
- if (!quoteKey || !fiat || !asset) {
7728
- setQuoting(false);
7729
- if (step === "input") {
7730
- setQuotes([]);
7731
- setRejected([]);
7732
- }
7733
- return;
7880
+
7881
+ // src/components/cosign-modal/cosign-copy.ts
7882
+ var COSIGN_COPY = {
7883
+ en: {
7884
+ title: "Approvals",
7885
+ manyPending: (count) => `${count} approvals waiting`,
7886
+ close: "Close",
7887
+ whyTitle: "Why am I seeing this?",
7888
+ whyBody: "Your wallet needs this device's signature. Neither the app nor Pollar can approve this without you.",
7889
+ rejectRequest: "Reject this request",
7890
+ closeTitle: "Close without signing?",
7891
+ closeBody: "The request stays pending. The app can't continue until you approve it.",
7892
+ backToSign: "Go back and sign",
7893
+ closeAnyway: "Close anyway",
7894
+ activateWallet: "Activate wallet",
7895
+ status: { APPROVED: "Approved", REJECTED: "Rejected", EXPIRED: "Expired", FAILED: "Failed", PENDING: "Pending" },
7896
+ signedAppSends: "Signed. The app will send it.",
7897
+ signedSent: "Signed and sent",
7898
+ signed: "Signed",
7899
+ nothingSigned: "Nothing was signed.",
7900
+ nothingWaiting: "Nothing waits for your approval.",
7901
+ next: (step) => `Next: ${step}. It appears here in a few seconds.`,
7902
+ closingIn: (seconds) => `Closing in ${seconds}s`,
7903
+ expired: "expired",
7904
+ expiresIn: "Expires in",
7905
+ checking: "Checking...",
7906
+ verified: "Checked",
7907
+ checkedExact: "We checked this is exactly what you're approving.",
7908
+ notVerified: "Not verified:",
7909
+ reject: "Reject",
7910
+ rejecting: "Rejecting...",
7911
+ approve: "Approve",
7912
+ approving: "Approving...",
7913
+ genericError: "Something went wrong. Please try again.",
7914
+ unreachable: "We could not reach Pollar, so nothing was approved. Check your connection and approve again.",
7915
+ deviceNotLinked: "This device isn't linked to your wallet yet, so it can't approve. Add it with a device that already is, your passkey or your email.",
7916
+ linkDevice: "Link this device",
7917
+ transaction: "Transaction",
7918
+ operations: {
7919
+ payment: "Send",
7920
+ path_payment_strict_send: "Swap",
7921
+ change_trust: "Add asset",
7922
+ create_account: "Create account",
7923
+ invoke_contract: "Contract call",
7924
+ soroban_auth: "Authorize a contract call",
7925
+ manage_data: "Manage data",
7926
+ transfer: "Send",
7927
+ ramp_payment: "Ramp payment",
7928
+ cctp_burn: "Move USDC",
7929
+ swap: "Swap",
7930
+ earn_deposit: "Deposit",
7931
+ earn_withdraw: "Withdraw",
7932
+ evm_delegation: "Enable atomic transactions",
7933
+ provider_sign_in: "Confirm it's you",
7934
+ sep10: "Confirm it's you"
7734
7935
  }
7735
- setQuoting(true);
7736
- const timer = setTimeout(() => {
7737
- client.quoteRamp({
7738
- direction,
7739
- fiat: { currency: fiat.currency, rail: fiat.rail, country: fiat.country },
7740
- asset: { code: asset.code, identifier: asset.identifier, chain: asset.chain },
7741
- amount: { value: amount.trim(), denomination: "in" }
7742
- }).then((result) => {
7743
- if (run !== quoteRun.current) return;
7744
- setQuotes(result.quotes);
7745
- setRejected(result.rejected);
7746
- setErrorMsg(null);
7747
- }).catch((error) => {
7748
- if (run !== quoteRun.current) return;
7749
- setQuotes([]);
7750
- if (core.isPollarApiError(error) && error.code === "SDK_RAMPS_NO_ROUTE") {
7751
- setRejected(Array.isArray(error.body.rejected) ? error.body.rejected : []);
7752
- } else {
7753
- setRejected([]);
7754
- setErrorMsg(rampErrorMessage(error, copy.findRouteFailed, copy, language));
7755
- }
7756
- }).finally(() => {
7757
- if (run === quoteRun.current) setQuoting(false);
7758
- });
7759
- }, QUOTE_DEBOUNCE_MS);
7760
- return () => clearTimeout(timer);
7761
- }, [quoteKey]);
7762
- const chosenQuote = (routeChoice !== BEST_ROUTE ? quotes.find((q) => routeKey(q) === routeChoice) : void 0) ?? quotes[0] ?? null;
7763
- react.useEffect(() => {
7764
- if (direction === "OFFRAMP") void refreshWalletBalance();
7765
- }, [direction, refreshWalletBalance]);
7766
- async function loadRoutes(next) {
7767
- setRoutesLoading(true);
7768
- try {
7769
- const { routes: found } = await client.getRampRoutes(next);
7770
- setRoutes(found);
7771
- const seed = seedRef.current?.direction === next ? seedRef.current.options : null;
7772
- if (seed) seedRef.current = null;
7773
- const seeded = seed ? seededSelection(found, seed) : null;
7774
- if (seeded) {
7775
- setCountry(seeded.country);
7776
- setFiatChoice(seeded.fiatChoice);
7777
- setAssetChoice(seeded.assetChoice);
7778
- setAmount(seeded.amount);
7779
- return;
7780
- }
7781
- const first = core.rampCountries(found)[0]?.country ?? "";
7782
- setCountry((current) => found.some((r) => r.fiat.country === current) ? current : first);
7783
- } catch (error) {
7784
- setRoutes([]);
7785
- setErrorMsg(rampErrorMessage(error, copy.loadRoutesFailed, copy, language));
7786
- } finally {
7787
- setRoutesLoading(false);
7936
+ },
7937
+ es: {
7938
+ title: "Aprobaciones",
7939
+ manyPending: (count) => `${count} aprobaciones pendientes`,
7940
+ close: "Cerrar",
7941
+ whyTitle: "\xBFPor qu\xE9 ves esto?",
7942
+ whyBody: "Tu billetera necesita la firma de este dispositivo. Ni la app ni Pollar pueden aprobar esto sin ti.",
7943
+ rejectRequest: "Rechazar esta solicitud",
7944
+ closeTitle: "\xBFCerrar sin firmar?",
7945
+ closeBody: "La solicitud queda pendiente. La app no puede seguir hasta que la apruebes.",
7946
+ backToSign: "Volver y firmar",
7947
+ closeAnyway: "Cerrar igual",
7948
+ activateWallet: "Activar billetera",
7949
+ status: { APPROVED: "Aprobada", REJECTED: "Rechazada", EXPIRED: "Vencida", FAILED: "Fallida", PENDING: "Pendiente" },
7950
+ signedAppSends: "Firmada. La app la enviar\xE1.",
7951
+ signedSent: "Firmada y enviada",
7952
+ signed: "Firmada",
7953
+ nothingSigned: "No se firm\xF3 nada.",
7954
+ nothingWaiting: "No hay nada esperando tu aprobaci\xF3n.",
7955
+ next: (step) => `Siguiente: ${step}. Aparecer\xE1 aqu\xED en unos segundos.`,
7956
+ closingIn: (seconds) => `Se cierra en ${seconds}s`,
7957
+ expired: "vencida",
7958
+ expiresIn: "Vence en",
7959
+ checking: "Verificando...",
7960
+ verified: "Comprobada",
7961
+ checkedExact: "Comprobamos que esto es exactamente lo que est\xE1s aprobando.",
7962
+ notVerified: "Sin verificar:",
7963
+ reject: "Rechazar",
7964
+ rejecting: "Rechazando...",
7965
+ approve: "Aprobar",
7966
+ approving: "Aprobando...",
7967
+ genericError: "Algo sali\xF3 mal. Intenta de nuevo.",
7968
+ unreachable: "No pudimos conectar con Pollar, as\xED que no se aprob\xF3 nada. Revisa tu conexi\xF3n y aprueba de nuevo.",
7969
+ deviceNotLinked: "Este dispositivo a\xFAn no est\xE1 vinculado a tu billetera, as\xED que no puede aprobar. Agr\xE9galo con un dispositivo que ya lo est\xE9, tu passkey o tu email.",
7970
+ linkDevice: "Vincular este dispositivo",
7971
+ transaction: "Transacci\xF3n",
7972
+ operations: {
7973
+ payment: "Enviar",
7974
+ path_payment_strict_send: "Intercambiar",
7975
+ change_trust: "Agregar activo",
7976
+ create_account: "Crear cuenta",
7977
+ invoke_contract: "Llamada a contrato",
7978
+ soroban_auth: "Autorizar una llamada a contrato",
7979
+ manage_data: "Gestionar datos",
7980
+ transfer: "Enviar",
7981
+ ramp_payment: "Pago de rampa",
7982
+ cctp_burn: "Mover USDC",
7983
+ swap: "Intercambiar",
7984
+ earn_deposit: "Depositar",
7985
+ earn_withdraw: "Retirar",
7986
+ evm_delegation: "Activar transacciones at\xF3micas",
7987
+ provider_sign_in: "Confirma que eres t\xFA",
7988
+ sep10: "Confirma que eres t\xFA"
7788
7989
  }
7789
- }
7790
- async function loadPendingOrders() {
7791
- try {
7792
- const page = await client.listRampOrders({ open: "true", limit: 5 });
7793
- setPendingOrders(page.orders);
7794
- } catch {
7795
- setPendingOrders([]);
7990
+ },
7991
+ pt: {
7992
+ title: "Aprova\xE7\xF5es",
7993
+ manyPending: (count) => `${count} aprova\xE7\xF5es pendentes`,
7994
+ close: "Fechar",
7995
+ whyTitle: "Por que estou vendo isto?",
7996
+ whyBody: "Sua carteira precisa da assinatura deste dispositivo. Nem o app nem a Pollar podem aprovar isto sem voc\xEA.",
7997
+ rejectRequest: "Rejeitar esta solicita\xE7\xE3o",
7998
+ closeTitle: "Fechar sem assinar?",
7999
+ closeBody: "A solicita\xE7\xE3o fica pendente. O app n\xE3o pode continuar at\xE9 voc\xEA aprov\xE1-la.",
8000
+ backToSign: "Voltar e assinar",
8001
+ closeAnyway: "Fechar mesmo assim",
8002
+ activateWallet: "Ativar carteira",
8003
+ status: { APPROVED: "Aprovada", REJECTED: "Rejeitada", EXPIRED: "Expirada", FAILED: "Falhou", PENDING: "Pendente" },
8004
+ signedAppSends: "Assinada. O app vai envi\xE1-la.",
8005
+ signedSent: "Assinada e enviada",
8006
+ signed: "Assinada",
8007
+ nothingSigned: "Nada foi assinado.",
8008
+ nothingWaiting: "Nada aguarda a sua aprova\xE7\xE3o.",
8009
+ next: (step) => `Pr\xF3ximo: ${step}. Aparece aqui em alguns segundos.`,
8010
+ closingIn: (seconds) => `Fechando em ${seconds}s`,
8011
+ expired: "expirada",
8012
+ expiresIn: "Expira em",
8013
+ checking: "Verificando...",
8014
+ verified: "Conferida",
8015
+ checkedExact: "Conferimos que isto \xE9 exatamente o que voc\xEA est\xE1 aprovando.",
8016
+ notVerified: "N\xE3o verificada:",
8017
+ reject: "Rejeitar",
8018
+ rejecting: "Rejeitando...",
8019
+ approve: "Aprovar",
8020
+ approving: "Aprovando...",
8021
+ genericError: "Algo deu errado. Tente novamente.",
8022
+ unreachable: "N\xE3o conseguimos conectar \xE0 Pollar, ent\xE3o nada foi aprovado. Verifique sua conex\xE3o e aprove novamente.",
8023
+ deviceNotLinked: "Este dispositivo ainda n\xE3o est\xE1 vinculado \xE0 sua carteira, ent\xE3o n\xE3o pode aprovar. Adicione-o com um dispositivo que j\xE1 esteja, sua passkey ou seu email.",
8024
+ linkDevice: "Vincular este dispositivo",
8025
+ transaction: "Transa\xE7\xE3o",
8026
+ operations: {
8027
+ payment: "Enviar",
8028
+ path_payment_strict_send: "Trocar",
8029
+ change_trust: "Adicionar ativo",
8030
+ create_account: "Criar conta",
8031
+ invoke_contract: "Chamada de contrato",
8032
+ soroban_auth: "Autorizar uma chamada de contrato",
8033
+ manage_data: "Gerenciar dados",
8034
+ transfer: "Enviar",
8035
+ ramp_payment: "Pagamento de rampa",
8036
+ cctp_burn: "Mover USDC",
8037
+ swap: "Trocar",
8038
+ earn_deposit: "Depositar",
8039
+ earn_withdraw: "Sacar",
8040
+ evm_delegation: "Ativar transa\xE7\xF5es at\xF4micas",
8041
+ provider_sign_in: "Confirme que \xE9 voc\xEA",
8042
+ sep10: "Confirme que \xE9 voc\xEA"
7796
8043
  }
7797
8044
  }
7798
- react.useEffect(() => {
7799
- void loadRoutes(direction);
7800
- }, [client, direction]);
7801
- react.useEffect(() => {
7802
- void loadPendingOrders();
7803
- }, [client]);
7804
- const orderId = order?.id ?? null;
7805
- react.useEffect(() => {
7806
- if (step !== "status" || !orderId) return;
7807
- const controller = new AbortController();
7808
- client.pollRampOrder(orderId, {
7809
- signal: controller.signal,
7810
- onUpdate: (next) => {
7811
- setOrder(next);
7812
- setPollTrouble(false);
7813
- },
7814
- onError: () => setPollTrouble(true)
7815
- }).catch((error) => {
7816
- if (!controller.signal.aborted) setErrorMsg(rampErrorMessage(error, copy.readOrderFailed, copy, language));
7817
- });
7818
- return () => controller.abort();
7819
- }, [client, step, orderId, pollKey]);
7820
- const awaitingPayment = step === "status" && order?.pendingAction?.kind === "FIAT_PAYMENT";
8045
+ };
8046
+ function labelOf2(request, copy) {
8047
+ const op = request.operation ?? "";
8048
+ return copy.operations[op] ?? (op ? op.replace(/_/g, " ") : copy.transaction);
8049
+ }
8050
+ function expiresIn(request, copy) {
8051
+ const ms = new Date(request.expiresAt).getTime() - Date.now();
8052
+ if (!Number.isFinite(ms) || ms <= 0) return copy.expired;
8053
+ const h = Math.floor(ms / 36e5);
8054
+ const m = Math.floor(ms % 36e5 / 6e4);
8055
+ return h > 0 ? `${h}h ${m}m` : `${m}m`;
8056
+ }
8057
+ function outcomeText(request, copy) {
8058
+ if (request.status !== "APPROVED")
8059
+ return `${copy.status[request.status] ?? request.status.toLowerCase()}. ${copy.nothingSigned}`;
8060
+ if (request.submit?.hash) return copy.signedSent;
8061
+ if (request.signedXdr) return copy.signedAppSends;
8062
+ return copy.status.APPROVED ?? "Approved";
8063
+ }
8064
+ function StepRow({
8065
+ request,
8066
+ review,
8067
+ copy,
8068
+ language
8069
+ }) {
8070
+ const [open, setOpen] = react.useState(false);
8071
+ const ok = request.status === "APPROVED";
8072
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `pollar-cosign-step${ok ? "" : " pollar-cosign-step-bad"}`, children: [
8073
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-cosign-step-head", "aria-expanded": open, onClick: () => setOpen((v) => !v), children: [
8074
+ /* @__PURE__ */ jsxRuntime.jsx(OutcomeIcon, { ok }),
8075
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-cosign-step-title", children: review.title }),
8076
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-cosign-step-status", children: ok ? copy.signed : copy.status[request.status] ?? request.status }),
8077
+ /* @__PURE__ */ jsxRuntime.jsx(
8078
+ "svg",
8079
+ {
8080
+ width: "10",
8081
+ height: "10",
8082
+ viewBox: "0 0 12 12",
8083
+ fill: "none",
8084
+ "aria-hidden": true,
8085
+ style: { transform: open ? "rotate(180deg)" : "none", transition: "transform 150ms" },
8086
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 4l4 4 4-4", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" })
8087
+ }
8088
+ )
8089
+ ] }),
8090
+ open && /* @__PURE__ */ jsxRuntime.jsx(TxReview, { data: review, language, detailsOnly: true })
8091
+ ] });
8092
+ }
8093
+ function CloseIcon() {
8094
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m3 3 8 8M11 3l-8 8", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round" }) });
8095
+ }
8096
+ function VerifiedIcon() {
8097
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
8098
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
8099
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3.5 7l2.5 2.5 4.5-5", stroke: "white", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" })
8100
+ ] });
8101
+ }
8102
+ function CosignModalTemplate({
8103
+ theme,
8104
+ accentColor,
8105
+ styleOverrides,
8106
+ pending,
8107
+ current,
8108
+ verification,
8109
+ busy,
8110
+ error,
8111
+ approveBlocked = false,
8112
+ deviceNotLinked = false,
8113
+ onLinkDevice,
8114
+ lastResolved,
8115
+ history = [],
8116
+ explorerUrlOf,
8117
+ closesIn = null,
8118
+ nextStep = null,
8119
+ language: languageProp,
8120
+ network,
8121
+ onSelect,
8122
+ onApprove,
8123
+ onReject,
8124
+ onClose,
8125
+ confirmingClose = false,
8126
+ onKeepOpen,
8127
+ onCloseAnyway,
8128
+ inline = false
8129
+ }) {
8130
+ const language = useInheritedLanguage(languageProp);
8131
+ const copy = COSIGN_COPY[language];
8132
+ const cssVars = buildModalCssVars(theme, accentColor, styleOverrides);
8133
+ const verified = verification?.ok === true && !deviceNotLinked;
8134
+ const canVote = !!current && verified && !busy && !approveBlocked;
8135
+ const [verifiedOpenFor, setVerifiedOpenFor] = react.useState(null);
8136
+ const verifiedOpen = !!current && verifiedOpenFor === current.id;
8137
+ const reviewOf = (request) => reviewFromRequest(
8138
+ {
8139
+ chain: request.network,
8140
+ network,
8141
+ operation: request.operation,
8142
+ summary: request.summary,
8143
+ details: request.details,
8144
+ signWith: request.account ?? request.signWith,
8145
+ raw: request.unsignedPayload,
8146
+ fallbackTitle: labelOf2(request, copy),
8147
+ ...request.status === "PENDING" ? { extraRows: [{ label: copy.expiresIn, value: expiresIn(request, copy) }] } : {},
8148
+ appPaysFee: request.submit?.sponsored ?? request.appPaysFee,
8149
+ ...request.submit?.hash ? { hash: { value: request.submit.hash, explorerUrl: explorerUrlOf?.(request) ?? null } } : {}
8150
+ },
8151
+ TX_REVIEW_COPY[language]
8152
+ );
8153
+ const review = current ? reviewOf(current) : null;
8154
+ const grouped = pending.length > 1;
8155
+ const shown = grouped ? null : current ?? (pending.length === 0 ? lastResolved : void 0) ?? null;
8156
+ const shownReview = shown ? shown === current ? review : reviewOf(shown) : null;
8157
+ const doneSteps = history.filter((r) => !(pending.length === 0 && r.id === lastResolved?.id));
8158
+ const heading = confirmingClose ? copy.closeTitle : grouped ? copy.manyPending(pending.length) : shownReview?.title ?? copy.title;
8159
+ const chip = current && !confirmingClose && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
8160
+ !verification && !deviceNotLinked && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-cosign-chip", children: [
8161
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-hidden": true }),
8162
+ copy.checking
8163
+ ] }),
8164
+ verified && /* @__PURE__ */ jsxRuntime.jsxs(
8165
+ "button",
8166
+ {
8167
+ type: "button",
8168
+ className: "pollar-cosign-chip pollar-cosign-chip-ok",
8169
+ "aria-expanded": verifiedOpen,
8170
+ onClick: () => setVerifiedOpenFor(verifiedOpen ? null : current.id),
8171
+ children: [
8172
+ /* @__PURE__ */ jsxRuntime.jsx(VerifiedIcon, {}),
8173
+ copy.verified
8174
+ ]
8175
+ }
8176
+ )
8177
+ ] });
8178
+ return /* @__PURE__ */ jsxRuntime.jsxs(
8179
+ "div",
8180
+ {
8181
+ className: inline ? "pollar-cosign-modal pollar-cosign-inline" : "pollar-modal-card pollar-cosign-modal",
8182
+ "data-theme": theme,
8183
+ style: cssVars,
8184
+ onClick: (e) => e.stopPropagation(),
8185
+ children: [
8186
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
8187
+ /* @__PURE__ */ jsxRuntime.jsxs("h2", { className: "pollar-modal-title pollar-cosign-heading", children: [
8188
+ !confirmingClose && /* @__PURE__ */ jsxRuntime.jsx(TitleMark, { chain: shown?.network, asset: shownReview ? headlineAsset(shownReview) : void 0 }),
8189
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: heading })
8190
+ ] }),
8191
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
8192
+ !grouped && chip,
8193
+ !confirmingClose && !inline && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": copy.close, title: copy.close, children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {}) })
8194
+ ] })
8195
+ ] }),
8196
+ confirmingClose ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-leave", children: [
8197
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-cosign-muted", children: copy.closeBody }),
8198
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-cosign-btn pollar-cosign-btn-primary", onClick: onKeepOpen, children: copy.backToSign }),
8199
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-cosign-text-btn", onClick: onCloseAnyway, children: copy.closeAnyway })
8200
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
8201
+ doneSteps.map((r) => /* @__PURE__ */ jsxRuntime.jsx(StepRow, { request: r, review: reviewOf(r), copy, language }, r.id)),
8202
+ pending.length === 0 && (lastResolved && shownReview ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-detail", children: [
8203
+ /* @__PURE__ */ jsxRuntime.jsx(TxReview, { data: shownReview, language }, lastResolved.id),
8204
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `pollar-outcome${lastResolved.status === "APPROVED" ? "" : " pollar-outcome-bad"}`, children: [
8205
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-outcome-main", children: [
8206
+ /* @__PURE__ */ jsxRuntime.jsx(OutcomeIcon, { ok: lastResolved.status === "APPROVED" }),
8207
+ outcomeText(lastResolved, copy)
8208
+ ] }),
8209
+ nextStep && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-outcome-note", children: [
8210
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-hidden": true }),
8211
+ " ",
8212
+ copy.next(nextStep)
8213
+ ] }),
8214
+ closesIn !== null && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-outcome-note", children: copy.closingIn(closesIn) })
8215
+ ] })
8216
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-empty", children: [
8217
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-cosign-muted", children: copy.nothingWaiting }),
8218
+ closesIn !== null && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-cosign-muted pollar-cosign-closing", children: copy.closingIn(closesIn) })
8219
+ ] })),
8220
+ grouped && /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "pollar-cosign-list", children: pending.map((r) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
8221
+ "button",
8222
+ {
8223
+ type: "button",
8224
+ className: `pollar-cosign-item${current?.id === r.id ? " pollar-cosign-item-active" : ""}`,
8225
+ onClick: () => onSelect(r),
8226
+ children: [
8227
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-cosign-heading", children: [
8228
+ /* @__PURE__ */ jsxRuntime.jsx(TitleMark, { chain: r.network, asset: headlineAsset(reviewOf(r)) }),
8229
+ reviewOf(r).title
8230
+ ] }),
8231
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-cosign-muted", children: expiresIn(r, copy) })
8232
+ ]
8233
+ }
8234
+ ) }, r.id)) }),
8235
+ current && review && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `pollar-cosign-detail${grouped ? " pollar-cosign-detail-grouped" : ""}`, children: [
8236
+ grouped && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-detail-head", children: [
8237
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-cosign-detail-title", children: review.title }),
8238
+ chip
8239
+ ] }),
8240
+ /* @__PURE__ */ jsxRuntime.jsx(
8241
+ TxReview,
8242
+ {
8243
+ data: review,
8244
+ language,
8245
+ detailsIntro: { title: copy.whyTitle, body: copy.whyBody },
8246
+ detailsAction: {
8247
+ label: busy === "rejecting" ? copy.rejecting : copy.rejectRequest,
8248
+ onClick: () => onReject(current),
8249
+ disabled: !!busy
8250
+ }
8251
+ },
8252
+ current.id
8253
+ ),
8254
+ verified && verifiedOpen && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-cosign-verify pollar-cosign-verify-ok", children: copy.checkedExact }),
8255
+ deviceNotLinked ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-verify pollar-cosign-verify-bad", children: [
8256
+ copy.deviceNotLinked,
8257
+ onLinkDevice && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-cosign-link", onClick: onLinkDevice, children: copy.linkDevice })
8258
+ ] }) : verification && !verification.ok && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-verify pollar-cosign-verify-bad", children: [
8259
+ copy.notVerified,
8260
+ " ",
8261
+ verification.reason
8262
+ ] }),
8263
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-cosign-error", children: error }),
8264
+ /* @__PURE__ */ jsxRuntime.jsx(
8265
+ "button",
8266
+ {
8267
+ type: "button",
8268
+ className: "pollar-cosign-btn pollar-cosign-btn-primary",
8269
+ disabled: !canVote,
8270
+ onClick: () => onApprove(current),
8271
+ children: busy === "approving" ? copy.approving : review.kind === "activate_wallet" ? copy.activateWallet : copy.approve
8272
+ }
8273
+ )
8274
+ ] })
8275
+ ] }),
8276
+ !inline && /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
8277
+ ]
8278
+ }
8279
+ );
8280
+ }
8281
+ var CLOSE_AFTER_SECONDS = 3;
8282
+ var CLOSE_AFTER_SENT_SECONDS = 5;
8283
+ var NEXT_REQUEST_EVERY_MS = 2e3;
8284
+ function CosignModal(props) {
8285
+ const { styles } = usePollar();
8286
+ const { overlayStyle } = modalChrome(styles);
8287
+ return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, children: /* @__PURE__ */ jsxRuntime.jsx(CosignPrompt, { ...props }) });
8288
+ }
8289
+ function CosignPrompt({ nextStep = null, onClose, inline = false }) {
8290
+ const { getClient, styles, network, openRecoveryModal } = usePollar();
8291
+ const { theme, accentColor, styleOverrides } = modalChrome(styles);
8292
+ const { pending, lastResolved, loaded, refresh, approve, reject, verify, inspectQuorum } = useCosign();
8293
+ const language = useModalLanguage();
8294
+ const [selectedId, setSelectedId] = react.useState(null);
8295
+ const [verification, setVerification] = react.useState(null);
8296
+ const [busy, setBusy] = react.useState(null);
8297
+ const [error, setError] = react.useState(null);
8298
+ const [approveFailedFor, setApproveFailedFor] = react.useState(null);
8299
+ const [quorumFailure, setQuorumFailure] = react.useState(null);
8300
+ const [deviceNotLinked, setDeviceNotLinked] = react.useState(false);
8301
+ react.useEffect(() => {
8302
+ let cancelled = false;
8303
+ inspectQuorum().then((q) => {
8304
+ if (cancelled || q.ok) return;
8305
+ if (q.code === "DEVICE_NOT_ENROLLED") setDeviceNotLinked(true);
8306
+ else setQuorumFailure(q.reason);
8307
+ }).catch(() => void 0);
8308
+ return () => {
8309
+ cancelled = true;
8310
+ };
8311
+ }, [inspectQuorum]);
8312
+ const current = pending.find((r) => r.id === selectedId) ?? pending[0] ?? null;
8313
+ const [history, setHistory] = react.useState([]);
8314
+ const resolvedBeforeOpen = react.useRef(lastResolved?.id);
8315
+ react.useEffect(() => {
8316
+ if (!lastResolved || lastResolved.id === resolvedBeforeOpen.current) return;
8317
+ setHistory((list) => [...list.filter((r) => r.id !== lastResolved.id), lastResolved]);
8318
+ }, [lastResolved]);
8319
+ const [askedToClose, setAskedToClose] = react.useState(false);
8320
+ const confirmingClose = askedToClose && pending.length > 0;
8321
+ const requestClose = () => pending.length > 0 ? setAskedToClose(true) : onClose();
8322
+ const currentRef = react.useRef(current);
8323
+ currentRef.current = current;
8324
+ const currentId = current?.id ?? null;
8325
+ react.useEffect(() => {
8326
+ const request = currentRef.current;
8327
+ if (!request) return;
8328
+ setVerification(null);
8329
+ setError(null);
8330
+ setApproveFailedFor(null);
8331
+ let cancelled = false;
8332
+ verify(request).then((v) => {
8333
+ if (!cancelled) setVerification(v);
8334
+ }).catch((err) => {
8335
+ if (!cancelled) setVerification({ ok: false, reason: err instanceof Error ? err.message : String(err) });
8336
+ });
8337
+ return () => {
8338
+ cancelled = true;
8339
+ };
8340
+ }, [currentId, verify]);
8341
+ const onCloseRef = react.useRef(onClose);
8342
+ onCloseRef.current = onClose;
8343
+ react.useEffect(() => {
8344
+ return getClient().onAuthStateChange((authState) => {
8345
+ if (authState.step === "idle") onCloseRef.current();
8346
+ });
8347
+ }, [getClient]);
8348
+ const silent = pending.length === 0 && (lastResolved ? lastResolved.status === "APPROVED" && !lastResolved.submit?.hash && !lastResolved.signedXdr : loaded);
8349
+ const sent = pending.length === 0 && lastResolved?.status === "APPROVED" && !!lastResolved.submit?.hash;
8350
+ const awaitingNext = sent && !!nextStep;
8351
+ const closeAfter = awaitingNext ? null : sent ? CLOSE_AFTER_SENT_SECONDS : silent ? CLOSE_AFTER_SECONDS : null;
8352
+ react.useEffect(() => {
8353
+ if (!awaitingNext) return;
8354
+ return core.startBackoffPoll(refresh, NEXT_REQUEST_EVERY_MS);
8355
+ }, [awaitingNext, refresh]);
8356
+ const [closesIn, setClosesIn] = react.useState(null);
8357
+ react.useEffect(() => {
8358
+ if (closeAfter === null) {
8359
+ setClosesIn(null);
8360
+ return;
8361
+ }
8362
+ let left = closeAfter;
8363
+ setClosesIn(left);
8364
+ const timer = setInterval(() => {
8365
+ left -= 1;
8366
+ if (left > 0) setClosesIn(left);
8367
+ else {
8368
+ clearInterval(timer);
8369
+ onCloseRef.current();
8370
+ }
8371
+ }, 1e3);
8372
+ return () => clearInterval(timer);
8373
+ }, [closeAfter, lastResolved?.id]);
8374
+ const run = react.useCallback(
8375
+ async (kind, request, action) => {
8376
+ setBusy(kind);
8377
+ setError(null);
8378
+ try {
8379
+ await action(request);
8380
+ } catch (err) {
8381
+ if (core.isPollarNetworkError(err) || err instanceof TypeError) {
8382
+ setError(COSIGN_COPY[language].unreachable);
8383
+ void refresh().catch(() => void 0);
8384
+ return;
8385
+ }
8386
+ setError(
8387
+ core.transactionErrorMessage(core.isPollarApiError(err) ? err.code : null, err instanceof Error ? err.message : null, language)
8388
+ );
8389
+ const retryable = core.isTransientApiError(err) || core.isPollarApiError(err) && err.code === "SDK_COSIGN_GAS_PENDING";
8390
+ if (kind === "approving" && !retryable) setApproveFailedFor(request.id);
8391
+ } finally {
8392
+ setBusy(null);
8393
+ }
8394
+ },
8395
+ [language, refresh]
8396
+ );
8397
+ return /* @__PURE__ */ jsxRuntime.jsx(
8398
+ CosignModalTemplate,
8399
+ {
8400
+ inline,
8401
+ theme,
8402
+ accentColor,
8403
+ styleOverrides,
8404
+ pending,
8405
+ current,
8406
+ verification: current ? quorumFailure ? { ok: false, reason: quorumFailure } : verification : null,
8407
+ busy,
8408
+ error,
8409
+ approveBlocked: !!current && approveFailedFor === current.id,
8410
+ deviceNotLinked,
8411
+ onLinkDevice: () => {
8412
+ onClose();
8413
+ openRecoveryModal();
8414
+ },
8415
+ ...lastResolved ? { lastResolved } : {},
8416
+ closesIn,
8417
+ nextStep: awaitingNext ? nextStep : null,
8418
+ language,
8419
+ network,
8420
+ history,
8421
+ explorerUrlOf: (r) => r.submit?.hash ? explorerTxUrl(r.network, r.submit.hash, network) : null,
8422
+ onSelect: (r) => setSelectedId(r.id),
8423
+ onApprove: (r) => void run("approving", r, approve),
8424
+ onReject: (r) => void run("rejecting", r, reject),
8425
+ onClose: requestClose,
8426
+ confirmingClose,
8427
+ onKeepOpen: () => setAskedToClose(false),
8428
+ onCloseAnyway: onClose
8429
+ }
8430
+ );
8431
+ }
8432
+ var PAYMENT_CHECK_EVERY_MS = 1e4;
8433
+ var PAYMENT_CHECK_WINDOW_MS = 2 * 6e4;
8434
+ function rampErrorMessage(error, fallback, copy, language) {
8435
+ const unavailable = core.appUnavailableMessage(error, language);
8436
+ if (unavailable) return unavailable;
8437
+ if (core.isPollarApiError(error)) {
8438
+ const known = copy.errors[error.code];
8439
+ if (known) return known;
8440
+ const message = error.body.message;
8441
+ if (typeof message === "string" && message && !/^[A-Z0-9_]+$/.test(message)) return message;
8442
+ }
8443
+ return fallback;
8444
+ }
8445
+ var DECIMAL = /^\d+(\.\d+)?$/;
8446
+ var QUOTE_DEBOUNCE_MS = 600;
8447
+ function seededSelection(routes, seed) {
8448
+ const countries = core.rampCountries(routes);
8449
+ const wanted = seed.country?.trim().toUpperCase();
8450
+ const country = wanted ? countries.find((c) => c.country === wanted) : countries[0];
8451
+ if (!country) return null;
8452
+ const fiat = country.fiats.find((f) => f.currency === seed.fiat?.trim().toUpperCase()) ?? null;
8453
+ const resolvedFiat = fiat ?? country.fiats[0];
8454
+ const asset = routes.find(
8455
+ (r) => r.fiat.country === country.country && resolvedFiat !== void 0 && fiatKey(r.fiat) === fiatKey(resolvedFiat) && r.asset.code.toUpperCase() === seed.asset?.trim().toUpperCase()
8456
+ )?.asset;
8457
+ const amount = seed.amount?.trim() ?? "";
8458
+ return {
8459
+ country: country.country,
8460
+ fiatChoice: fiat ? fiatKey(fiat) : "",
8461
+ assetChoice: asset ? assetKey3(asset) : "",
8462
+ amount: DECIMAL.test(amount) ? amount : ""
8463
+ };
8464
+ }
8465
+ async function signLegWithWallet(client, orderId, actionId, copy) {
8466
+ const lent = [];
8467
+ const lend = (chain, encoding, handler) => {
8468
+ try {
8469
+ lent.push(client.registerRampSigningHandler(chain, encoding, handler));
8470
+ } catch {
8471
+ }
8472
+ };
8473
+ lend("STELLAR", "xdr", async (action) => {
8474
+ const wallet = client.getWallet();
8475
+ if (!wallet) throw new Error(copy.connectStellarWallet);
8476
+ core.assertRampStellarSigner(action, wallet.address);
8477
+ const outcome = await client.signTx(action.payload.value);
8478
+ if (client.getWallet()?.address !== wallet.address) throw new Error(copy.walletChanged);
8479
+ if (outcome.status === "signed") return outcome.signedXdr;
8480
+ throw new Error(
8481
+ outcome.status === "error" ? outcome.message ?? outcome.details ?? copy.signingCancelled : copy.signingCancelled
8482
+ );
8483
+ });
8484
+ lend("SOLANA", "solana-v0-json", async (action) => {
8485
+ const payload = JSON.parse(action.payload.value);
8486
+ const solanaWallet = () => client.getWallets().find((w) => w.chain === "SOLANA" && w.custody === "external");
8487
+ const wallet = solanaWallet();
8488
+ if (!wallet || payload.from !== wallet.address || !payload.unsignedTransaction) throw new Error(copy.solanaWalletMismatch);
8489
+ const signed = await client.signSolanaTransaction(payload.unsignedTransaction);
8490
+ if (solanaWallet()?.address !== wallet.address) throw new Error(copy.walletChanged);
8491
+ return signed;
8492
+ });
8493
+ try {
8494
+ return await client.signRampLeg(orderId, actionId);
8495
+ } finally {
8496
+ for (const release of lent) release();
8497
+ }
8498
+ }
8499
+ function RampWidget({ onClose, language: languageProp, initial }) {
8500
+ const {
8501
+ getClient,
8502
+ styles,
8503
+ network,
8504
+ openCosignModal,
8505
+ setCosignNextStep,
8506
+ openRecoveryModal,
8507
+ recovery,
8508
+ recoveryLocked,
8509
+ appConfig,
8510
+ cosign,
8511
+ refreshWalletBalance,
8512
+ registerCosignHost
8513
+ } = usePollar();
8514
+ const client = getClient();
8515
+ const language = useModalLanguage(languageProp);
8516
+ const copy = RAMP_COPY[language];
8517
+ const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
8518
+ const [step, setStep] = react.useState("input");
8519
+ const confirmation = useInlineConfirmation(step === "status");
8520
+ const [direction, setDirection] = react.useState(initial?.direction === "sell" ? "OFFRAMP" : "ONRAMP");
8521
+ const seedRef = react.useRef(
8522
+ initial ? { direction: initial.direction === "sell" ? "OFFRAMP" : "ONRAMP", options: initial } : null
8523
+ );
8524
+ const [routes, setRoutes] = react.useState([]);
8525
+ const [routesLoading, setRoutesLoading] = react.useState(true);
8526
+ const [country, setCountry] = react.useState("");
8527
+ const [fiatChoice, setFiatChoice] = react.useState("");
8528
+ const [assetChoice, setAssetChoice] = react.useState("");
8529
+ const [amount, setAmount] = react.useState("");
8530
+ const [quotes, setQuotes] = react.useState([]);
8531
+ const [rejected, setRejected] = react.useState([]);
8532
+ const [selected, setSelected] = react.useState(null);
8533
+ const [startingQuoteId, setStartingQuoteId] = react.useState(null);
8534
+ const [fieldValues, setFieldValues] = react.useState({});
8535
+ const [order, setOrder] = react.useState(null);
8536
+ const [pendingOrders, setPendingOrders] = react.useState([]);
8537
+ const [isLoading, setIsLoading] = react.useState(false);
8538
+ const [refreshing, setRefreshing] = react.useState(false);
8539
+ const [signing, setSigning] = react.useState(false);
8540
+ const [errorMsg, setErrorMsg] = react.useState(null);
8541
+ const [verifying, setVerifying] = react.useState(null);
8542
+ const [trustingAsset, setTrustingAsset] = react.useState(null);
8543
+ const [walletBusy, setWalletBusy] = react.useState(null);
8544
+ const [retrying, setRetrying] = react.useState(false);
8545
+ const [cancelling, setCancelling] = react.useState(false);
8546
+ const [cancelError, setCancelError] = react.useState(null);
8547
+ const [awaitingAccount, setAwaitingAccount] = react.useState(null);
8548
+ const [pollTrouble, setPollTrouble] = react.useState(false);
8549
+ const [pollKey, setPollKey] = react.useState(0);
8550
+ const [paymentCheckUntil, setPaymentCheckUntil] = react.useState(null);
8551
+ const checkErrorRef = react.useRef(null);
8552
+ const promptedApproval = react.useRef(null);
8553
+ const custodyChoice = appConfig.application?.walletCustodyMode === "USER_CHOICE";
8554
+ const appChains = appConfig.application?.chains;
8555
+ const verifyAttempt = react.useRef(null);
8556
+ const countries = react.useMemo(() => core.rampCountries(routes), [routes]);
8557
+ const fiats = countries.find((c) => c.country === country)?.fiats ?? [];
8558
+ const fiat = fiats.find((f) => fiatKey(f) === fiatChoice) ?? fiats[0] ?? null;
8559
+ const assets = react.useMemo(() => {
8560
+ const seen = /* @__PURE__ */ new Map();
8561
+ for (const route of routes)
8562
+ if (fiat && route.fiat.country === country && fiatKey(route.fiat) === fiatKey(fiat))
8563
+ seen.set(assetKey3(route.asset), route.asset);
8564
+ return [...seen.values()];
8565
+ }, [routes, country, fiat]);
8566
+ const asset = assets.find((a) => assetKey3(a) === assetChoice) ?? assets[0] ?? null;
8567
+ const fields = selected ? core.rampQuoteFields(selected, language) : [];
8568
+ const sellAvailable = useWalletAvailable(
8569
+ direction === "OFFRAMP" && asset ? { chain: asset.chain, code: asset.code, issuer: asset.identifier } : null
8570
+ );
8571
+ const [quoting, setQuoting] = react.useState(false);
8572
+ const [routeChoice, setRouteChoice] = react.useState(BEST_ROUTE);
8573
+ const quoteRun = react.useRef(0);
8574
+ const quoteInput = step === "input" && fiat && asset && DECIMAL.test(amount.trim()) && Number(amount) > 0;
8575
+ const quoteKey = quoteInput ? `${direction}|${fiatKey(fiat)}|${assetKey3(asset)}|${amount.trim()}` : null;
8576
+ react.useEffect(() => {
8577
+ const run = ++quoteRun.current;
8578
+ if (!quoteKey || !fiat || !asset) {
8579
+ setQuoting(false);
8580
+ if (step === "input") {
8581
+ setQuotes([]);
8582
+ setRejected([]);
8583
+ }
8584
+ return;
8585
+ }
8586
+ setQuoting(true);
8587
+ const timer = setTimeout(() => {
8588
+ client.quoteRamp({
8589
+ direction,
8590
+ fiat: { currency: fiat.currency, rail: fiat.rail, country: fiat.country },
8591
+ asset: { code: asset.code, identifier: asset.identifier, chain: asset.chain },
8592
+ amount: { value: amount.trim(), denomination: "in" }
8593
+ }).then((result) => {
8594
+ if (run !== quoteRun.current) return;
8595
+ setQuotes(result.quotes);
8596
+ setRejected(result.rejected);
8597
+ setErrorMsg(null);
8598
+ }).catch((error) => {
8599
+ if (run !== quoteRun.current) return;
8600
+ setQuotes([]);
8601
+ if (core.isPollarApiError(error) && error.code === "SDK_RAMPS_NO_ROUTE") {
8602
+ setRejected(Array.isArray(error.body.rejected) ? error.body.rejected : []);
8603
+ } else {
8604
+ setRejected([]);
8605
+ setErrorMsg(rampErrorMessage(error, copy.findRouteFailed, copy, language));
8606
+ }
8607
+ }).finally(() => {
8608
+ if (run === quoteRun.current) setQuoting(false);
8609
+ });
8610
+ }, QUOTE_DEBOUNCE_MS);
8611
+ return () => clearTimeout(timer);
8612
+ }, [quoteKey]);
8613
+ const chosenQuote = (routeChoice !== BEST_ROUTE ? quotes.find((q) => routeKey(q) === routeChoice) : void 0) ?? quotes[0] ?? null;
8614
+ react.useEffect(() => {
8615
+ if (direction === "OFFRAMP") void refreshWalletBalance();
8616
+ }, [direction, refreshWalletBalance]);
8617
+ async function loadRoutes(next) {
8618
+ setRoutesLoading(true);
8619
+ try {
8620
+ const { routes: found } = await client.getRampRoutes(next);
8621
+ setRoutes(found);
8622
+ const seed = seedRef.current?.direction === next ? seedRef.current.options : null;
8623
+ if (seed) seedRef.current = null;
8624
+ const seeded = seed ? seededSelection(found, seed) : null;
8625
+ if (seeded) {
8626
+ setCountry(seeded.country);
8627
+ setFiatChoice(seeded.fiatChoice);
8628
+ setAssetChoice(seeded.assetChoice);
8629
+ setAmount(seeded.amount);
8630
+ return;
8631
+ }
8632
+ const first = core.rampCountries(found)[0]?.country ?? "";
8633
+ setCountry((current) => found.some((r) => r.fiat.country === current) ? current : first);
8634
+ } catch (error) {
8635
+ setRoutes([]);
8636
+ setErrorMsg(rampErrorMessage(error, copy.loadRoutesFailed, copy, language));
8637
+ } finally {
8638
+ setRoutesLoading(false);
8639
+ }
8640
+ }
8641
+ async function loadPendingOrders() {
8642
+ try {
8643
+ const page = await client.listRampOrders({ open: "true", limit: 5 });
8644
+ setPendingOrders(page.orders);
8645
+ } catch {
8646
+ setPendingOrders([]);
8647
+ }
8648
+ }
8649
+ react.useEffect(() => {
8650
+ void loadRoutes(direction);
8651
+ }, [client, direction]);
8652
+ react.useEffect(() => {
8653
+ void loadPendingOrders();
8654
+ }, [client]);
8655
+ const orderId = order?.id ?? null;
8656
+ react.useEffect(() => {
8657
+ if (step !== "status" || !orderId) return;
8658
+ const controller = new AbortController();
8659
+ client.pollRampOrder(orderId, {
8660
+ signal: controller.signal,
8661
+ onUpdate: (next) => {
8662
+ setOrder(next);
8663
+ setPollTrouble(false);
8664
+ },
8665
+ onError: () => setPollTrouble(true)
8666
+ }).catch((error) => {
8667
+ if (!controller.signal.aborted) setErrorMsg(rampErrorMessage(error, copy.readOrderFailed, copy, language));
8668
+ });
8669
+ return () => controller.abort();
8670
+ }, [client, step, orderId, pollKey]);
8671
+ const awaitingPayment = step === "status" && order?.pendingAction?.kind === "FIAT_PAYMENT";
7821
8672
  react.useEffect(() => {
7822
8673
  if (paymentCheckUntil === null || !orderId) return;
7823
8674
  if (!awaitingPayment) {
@@ -7825,14 +8676,13 @@ function RampWidget({ onClose, language: languageProp, initial }) {
7825
8676
  setPollKey((key) => key + 1);
7826
8677
  return;
7827
8678
  }
7828
- const timer = setInterval(() => {
8679
+ return core.startBackoffPoll(async () => {
7829
8680
  if (Date.now() >= paymentCheckUntil) {
7830
8681
  setPaymentCheckUntil(null);
7831
8682
  return;
7832
8683
  }
7833
- client.checkRampOrder(orderId).then(setOrder).catch(() => void 0);
8684
+ setOrder(await client.checkRampOrder(orderId));
7834
8685
  }, PAYMENT_CHECK_EVERY_MS);
7835
- return () => clearInterval(timer);
7836
8686
  }, [client, orderId, awaitingPayment, paymentCheckUntil]);
7837
8687
  react.useEffect(() => {
7838
8688
  if (awaitingPayment || checkErrorRef.current === null) return;
@@ -7840,6 +8690,10 @@ function RampWidget({ onClose, language: languageProp, initial }) {
7840
8690
  checkErrorRef.current = null;
7841
8691
  setErrorMsg((current) => current === shown ? null : current);
7842
8692
  }, [awaitingPayment]);
8693
+ const hostsCosign = step === "status" && !!order && !["completed", "failed", "refunded"].includes(order.state);
8694
+ const hostsCosignRef = react.useRef(hostsCosign);
8695
+ hostsCosignRef.current = hostsCosign;
8696
+ react.useEffect(() => hostsCosign ? registerCosignHost() : void 0, [hostsCosign, registerCosignHost]);
7843
8697
  const approval = order?.pendingAction?.kind === "COSIGN_APPROVAL" ? order.pendingAction.actionId : null;
7844
8698
  const approvalRequest = order?.pendingAction?.kind === "COSIGN_APPROVAL" ? order.pendingAction.cosignRequestId : null;
7845
8699
  react.useEffect(() => {
@@ -7848,7 +8702,7 @@ function RampWidget({ onClose, language: languageProp, initial }) {
7848
8702
  void client.cosign.pending().catch(() => []).then(async (requests) => {
7849
8703
  const request = requests.find((r) => r.id === approvalRequest);
7850
8704
  if (request && await client.autoApproveSignIn(request)) return;
7851
- openCosignModal();
8705
+ if (!hostsCosignRef.current) openCosignModal();
7852
8706
  });
7853
8707
  }, [approval, approvalRequest, client, openCosignModal]);
7854
8708
  const nextApproval = step === "status" && order ? core.rampNextApproval(order, language) : null;
@@ -8104,6 +8958,19 @@ function RampWidget({ onClose, language: languageProp, initial }) {
8104
8958
  setRetrying(false);
8105
8959
  }
8106
8960
  }
8961
+ async function handleCancelOrder() {
8962
+ if (!order || cancelling) return;
8963
+ setCancelling(true);
8964
+ setCancelError(null);
8965
+ try {
8966
+ setOrder(await client.cancelRampOrder(order.id));
8967
+ void loadPendingOrders();
8968
+ } catch (error) {
8969
+ setCancelError(rampErrorMessage(error, copy.cancelOrderFailed, copy, language));
8970
+ } finally {
8971
+ setCancelling(false);
8972
+ }
8973
+ }
8107
8974
  async function handleRequote() {
8108
8975
  setOrder(null);
8109
8976
  await handleFindRoute();
@@ -8255,6 +9122,7 @@ function RampWidget({ onClose, language: languageProp, initial }) {
8255
9122
  },
8256
9123
  onSign: () => void handleSign(),
8257
9124
  onApprove: openCosignModal,
9125
+ cosignPrompt: hostsCosign && cosign.pending.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(CosignPrompt, { inline: true, onClose: () => void 0 }) : null,
8258
9126
  retrying,
8259
9127
  onRetryOrder: () => void handleRetryOrder(),
8260
9128
  onRequote: () => void handleRequote(),
@@ -8274,7 +9142,10 @@ function RampWidget({ onClose, language: languageProp, initial }) {
8274
9142
  },
8275
9143
  onRefresh: () => void handleRefresh(),
8276
9144
  onClose,
8277
- confirmation
9145
+ confirmation,
9146
+ onCancelOrder: () => void handleCancelOrder(),
9147
+ cancelling,
9148
+ cancelError
8278
9149
  }
8279
9150
  ) });
8280
9151
  }
@@ -10843,16 +11714,16 @@ function SwapModal({ onClose, initial }) {
10843
11714
  react.useEffect(() => {
10844
11715
  if (!settlementKey || settlementDone || !originLanded) return;
10845
11716
  let cancelled = false;
10846
- const read = () => getSwapStatus(settlementKey).then((status) => {
10847
- if (!cancelled)
10848
- setSettlement((cur) => cur && cur.key === settlementKey ? { ...cur, value: status.settlement } : cur);
10849
- }).catch(() => {
11717
+ const read = async () => {
11718
+ const status = await getSwapStatus(settlementKey);
11719
+ if (!cancelled) setSettlement((cur) => cur && cur.key === settlementKey ? { ...cur, value: status.settlement } : cur);
11720
+ };
11721
+ void read().catch(() => {
10850
11722
  });
10851
- void read();
10852
- const id = setInterval(read, SETTLEMENT_POLL_MS);
11723
+ const stop = core.startBackoffPoll(read, SETTLEMENT_POLL_MS);
10853
11724
  return () => {
10854
11725
  cancelled = true;
10855
- clearInterval(id);
11726
+ stop();
10856
11727
  };
10857
11728
  }, [settlementKey, settlementDone, originLanded, getSwapStatus]);
10858
11729
  const hash = transaction.step === "success" ? transaction.hash : null;
@@ -12038,8 +12909,7 @@ function EarnModal({ onClose, initial }) {
12038
12909
  }, [refreshPosition]);
12039
12910
  react.useEffect(() => {
12040
12911
  if (step !== "form" || !onSolana && !provider || !opportunityId) return;
12041
- const id = setInterval(refreshPosition, POSITION_POLL_MS);
12042
- return () => clearInterval(id);
12912
+ return core.startBackoffPoll(async () => refreshPosition(), POSITION_POLL_MS);
12043
12913
  }, [step, onSolana, provider, opportunityId, refreshPosition]);
12044
12914
  react.useEffect(
12045
12915
  () => () => {
@@ -13181,13 +14051,10 @@ function CardModal({ onClose, initial }) {
13181
14051
  const kycPending = holder ? KYC_PENDING.has(holder.kycStatus) : false;
13182
14052
  react.useEffect(() => {
13183
14053
  if (!kycPending) return;
13184
- const id = setInterval(() => {
13185
- loadHolder().then((h) => {
13186
- if (h?.kycStatus === "APPROVED") void loadCardData();
13187
- }).catch(() => {
13188
- });
14054
+ return core.startBackoffPoll(async () => {
14055
+ const h = await loadHolder();
14056
+ if (h?.kycStatus === "APPROVED") void loadCardData();
13189
14057
  }, KYC_POLL_MS);
13190
- return () => clearInterval(id);
13191
14058
  }, [kycPending, loadHolder, loadCardData]);
13192
14059
  react.useEffect(
13193
14060
  () => () => {
@@ -13322,20 +14189,17 @@ function CardModal({ onClose, initial }) {
13322
14189
  const fundingsInflight = (fundings ?? []).some((f) => FUNDING_INFLIGHT.has(f.status));
13323
14190
  react.useEffect(() => {
13324
14191
  if (panel !== "fund" || !fundingsInflight) return;
13325
- const id = setInterval(() => {
13326
- getClient().listCardFundings().then((next) => {
13327
- setFundings((previous) => {
13328
- const credited = next.some(
13329
- (f) => f.status === "CREDITED" && previous?.find((p) => p.id === f.id)?.status !== "CREDITED"
13330
- );
13331
- if (credited) void loadCardData().catch(() => {
13332
- });
13333
- return next;
14192
+ return core.startBackoffPoll(async () => {
14193
+ const next = await getClient().listCardFundings();
14194
+ setFundings((previous) => {
14195
+ const credited = next.some(
14196
+ (f) => f.status === "CREDITED" && previous?.find((p) => p.id === f.id)?.status !== "CREDITED"
14197
+ );
14198
+ if (credited) void loadCardData().catch(() => {
13334
14199
  });
13335
- }).catch(() => {
14200
+ return next;
13336
14201
  });
13337
14202
  }, FUNDING_POLL_MS);
13338
- return () => clearInterval(id);
13339
14203
  }, [panel, fundingsInflight, getClient, loadCardData]);
13340
14204
  const field = (key, label, extra = {}) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "pollar-send-field", children: [
13341
14205
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-label", children: label }),
@@ -13641,997 +14505,460 @@ function CardModal({ onClose, initial }) {
13641
14505
  ] }),
13642
14506
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
13643
14507
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: copy.toPay }),
13644
- /* @__PURE__ */ jsxRuntime.jsx("strong", { children: usd(balance?.balanceDueCents, language) })
13645
- ] })
13646
- ] }),
13647
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-actions", children: [
13648
- provider.supports.revealSecrets && (secrets ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: () => setSecrets(null), children: copy.hideDetails }) : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: () => void reveal(), disabled: busy !== null, children: busy === "reveal" ? copy.loading : copy.showDetails })),
13649
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: () => void openFund(), disabled: busy !== null, children: copy.addFunds })
13650
- ] }),
13651
- secrets && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: copy.detailsHide }),
13652
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-section-title", children: copy.recentActivity }),
13653
- transactions === null && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: copy.loading }),
13654
- transactions?.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: copy.noMovements }),
13655
- transactions?.map((tx) => {
13656
- const localAmount = typeof tx.purchase?.localAmount === "number" ? tx.purchase.localAmount : null;
13657
- const localCurrency = typeof tx.purchase?.localCurrency === "string" ? tx.purchase.localCurrency : null;
13658
- const purchaseStatus = typeof tx.purchase?.status === "string" ? tx.purchase.status : null;
13659
- const local = localAmount && localCurrency && localCurrency !== "USD" ? money(String(localAmount), localCurrency, language) : null;
13660
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-card-tx", children: [
13661
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
13662
- tx.merchantName ?? copy.txLabels[tx.type] ?? tx.type,
13663
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-card-tx-meta", children: [
13664
- new Date(tx.occurredAt).toLocaleDateString(),
13665
- tx.merchantName ? ` \xB7 ${copy.txLabels[tx.type] ?? tx.type}` : "",
13666
- purchaseStatus && purchaseStatus !== "completed" ? ` \xB7 ${purchaseStatus}` : ""
13667
- ] })
13668
- ] }),
13669
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-card-tx-amount", "data-direction": tx.direction ?? void 0, children: [
13670
- tx.direction === "credit" ? "+" : tx.direction === "debit" ? "-" : "",
13671
- money(tx.amount, tx.currency, language),
13672
- local && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-card-tx-meta", children: local })
13673
- ] })
13674
- ] }, tx.id);
13675
- })
13676
- ] }),
13677
- !loading && provider && card && panel === "fund" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13678
- /* @__PURE__ */ jsxRuntime.jsx("p", { children: copy.fundIntro(provider.fundingAssets.join(` ${copy.or} `) || "USDC") }),
13679
- /* @__PURE__ */ jsxRuntime.jsx(
13680
- ChainSelect,
13681
- {
13682
- value: selectedFundChain,
13683
- options: fundChains,
13684
- onChange: (chain) => setFundChain(chain),
13685
- disabled: busy !== null,
13686
- language
13687
- }
13688
- ),
13689
- fundRoutes?.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: copy.fundingProblem.noRoute }),
13690
- selectedRoute?.route === "CCTP" && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: copy.fundingProblem.crossing }),
13691
- /* @__PURE__ */ jsxRuntime.jsx(
13692
- AmountField,
13693
- {
13694
- id: "pollar-card-fund-amount",
13695
- label: copy.amount,
13696
- value: fundAmount,
13697
- onChange: (value) => setFundAmount(value.replace(/[^0-9.]/g, "")),
13698
- unit: fundingAsset,
13699
- available: fundAvailable,
13700
- placeholder: "10",
13701
- language
13702
- }
13703
- ),
13704
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsxRuntime.jsx(
13705
- "button",
13706
- {
13707
- type: "button",
13708
- className: "pollar-btn-primary",
13709
- onClick: () => void fund(),
13710
- disabled: busy !== null || !selectedRoute || !(Number(fundAmount) >= 1),
13711
- children: busy === "fund-send" ? copy.sending : copy.fundFromWallet
13712
- }
13713
- ) }),
13714
- confirmation && /* @__PURE__ */ jsxRuntime.jsx(InlineConfirm, { confirmation, language }),
13715
- !confirmation && sentFunding && (() => {
13716
- const f = sentFunding;
13717
- const state = (f.route === "DIRECT" ? copy.fundingSolana[f.status] : void 0) ?? copy.funding[f.status];
13718
- const steps = FUNDING_STEPS[f.route];
13719
- const step = steps.indexOf(f.status) + 1;
13720
- const inflight = FUNDING_INFLIGHT.has(f.status);
13721
- const failed = f.status === "FAILED";
13722
- return /* @__PURE__ */ jsxRuntime.jsxs(
13723
- "div",
13724
- {
13725
- className: `pollar-outcome${failed ? " pollar-outcome-bad" : ""}${inflight ? " pollar-outcome-busy" : ""}`,
13726
- role: "status",
13727
- children: [
13728
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-outcome-main", children: [
13729
- inflight ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-hidden": true }) : /* @__PURE__ */ jsxRuntime.jsx(OutcomeIcon, { ok: !failed }),
13730
- state?.title ?? f.status,
13731
- " \xB7 ",
13732
- money(f.amount, "USD", language)
13733
- ] }),
13734
- inflight && step > 0 && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-outcome-note", children: [
13735
- copy.stepOf(step, steps.length),
13736
- " \xB7",
13737
- " ",
13738
- f.error === CREDIT_DELAYED ? copy.fundingProblem.delayed : state?.hint
13739
- ] }),
13740
- failed && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-outcome-note", children: fundingProblemText(f.error, copy) })
13741
- ]
13742
- }
13743
- );
13744
- })(),
13745
- earlierFundings.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13746
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-section-title", children: copy.yourFundings }),
13747
- earlierFundings.map((f) => {
13748
- const state = (f.route === "DIRECT" ? copy.fundingSolana[f.status] : void 0) ?? copy.funding[f.status];
13749
- const steps = FUNDING_STEPS[f.route];
13750
- const step = steps.indexOf(f.status) + 1;
13751
- const inflight = FUNDING_INFLIGHT.has(f.status);
13752
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-card-tx", "aria-busy": inflight, children: [
13753
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
13754
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-card-funding-title", children: [
13755
- inflight && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-hidden": true }),
13756
- state?.title ?? f.status
13757
- ] }),
13758
- inflight && step > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-card-tx-meta", role: "status", children: [
13759
- copy.stepOf(step, steps.length),
13760
- " \xB7",
13761
- " ",
13762
- f.error === CREDIT_DELAYED ? copy.fundingProblem.delayed : state?.hint
13763
- ] }),
13764
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-card-tx-meta", children: [
13765
- new Date(f.createdAt).toLocaleString(),
13766
- f.status === "FAILED" ? ` \xB7 ${fundingProblemText(f.error, copy)}` : ""
13767
- ] })
13768
- ] }),
13769
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-card-tx-amount", "data-direction": f.status === "CREDITED" ? "credit" : void 0, children: money(f.amount, "USD", language) })
13770
- ] }, f.id);
13771
- }),
13772
- fundingsInflight && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: copy.canClose })
13773
- ] }),
13774
- !showManual && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-card-note", children: [
13775
- copy.preferOtherWallet,
13776
- " ",
13777
- /* @__PURE__ */ jsxRuntime.jsx(
13778
- "button",
13779
- {
13780
- type: "button",
13781
- className: "pollar-card-link",
13782
- onClick: () => void showManualAddress(),
13783
- disabled: busy !== null,
13784
- children: copy.showDeposit
13785
- }
13786
- )
13787
- ] }),
13788
- showManual && deposit?.map((d) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-card-deposit", children: [
13789
- /* @__PURE__ */ jsxRuntime.jsx("strong", { children: d.network }),
13790
- " (",
13791
- copy.chain(d.chainId),
13792
- ")",
13793
- /* @__PURE__ */ jsxRuntime.jsx("code", { children: d.address }),
13794
- /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value: d.address, label: copy.copyAddress, language }),
13795
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: copy.sendOnly(d.tokens.map((t) => (t.currency ?? "token").toUpperCase()).join(` ${copy.or} `), d.network) })
13796
- ] }, d.network)),
13797
- showManual && deposit?.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: copy.noDeposit }),
13798
- showManual && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-card-link", onClick: () => setShowManual(false), children: copy.hideDeposit }) })
14508
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: usd(balance?.balanceDueCents, language) })
14509
+ ] })
14510
+ ] }),
14511
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-actions", children: [
14512
+ provider.supports.revealSecrets && (secrets ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: () => setSecrets(null), children: copy.hideDetails }) : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: () => void reveal(), disabled: busy !== null, children: busy === "reveal" ? copy.loading : copy.showDetails })),
14513
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: () => void openFund(), disabled: busy !== null, children: copy.addFunds })
14514
+ ] }),
14515
+ secrets && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: copy.detailsHide }),
14516
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-section-title", children: copy.recentActivity }),
14517
+ transactions === null && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: copy.loading }),
14518
+ transactions?.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: copy.noMovements }),
14519
+ transactions?.map((tx) => {
14520
+ const localAmount = typeof tx.purchase?.localAmount === "number" ? tx.purchase.localAmount : null;
14521
+ const localCurrency = typeof tx.purchase?.localCurrency === "string" ? tx.purchase.localCurrency : null;
14522
+ const purchaseStatus = typeof tx.purchase?.status === "string" ? tx.purchase.status : null;
14523
+ const local = localAmount && localCurrency && localCurrency !== "USD" ? money(String(localAmount), localCurrency, language) : null;
14524
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-card-tx", children: [
14525
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
14526
+ tx.merchantName ?? copy.txLabels[tx.type] ?? tx.type,
14527
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-card-tx-meta", children: [
14528
+ new Date(tx.occurredAt).toLocaleDateString(),
14529
+ tx.merchantName ? ` \xB7 ${copy.txLabels[tx.type] ?? tx.type}` : "",
14530
+ purchaseStatus && purchaseStatus !== "completed" ? ` \xB7 ${purchaseStatus}` : ""
14531
+ ] })
14532
+ ] }),
14533
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-card-tx-amount", "data-direction": tx.direction ?? void 0, children: [
14534
+ tx.direction === "credit" ? "+" : tx.direction === "debit" ? "-" : "",
14535
+ money(tx.amount, tx.currency, language),
14536
+ local && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-card-tx-meta", children: local })
14537
+ ] })
14538
+ ] }, tx.id);
14539
+ })
13799
14540
  ] }),
13800
- error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: error }),
13801
- loadFailed && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: retryLoad, children: copy.retry }) }),
13802
- /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, { language })
13803
- ]
13804
- }
13805
- ) });
13806
- }
13807
-
13808
- // src/components/sessions-modal/sessions-copy.ts
13809
- var SESSIONS_COPY = {
13810
- en: {
13811
- title: "Active sessions",
13812
- refresh: "Refresh",
13813
- close: "Close",
13814
- loading: "Loading\u2026",
13815
- empty: "No active sessions.",
13816
- thisDevice: "This device",
13817
- activeNow: "Active now",
13818
- otherDevices: "Other devices",
13819
- signOutDevice: (device) => `Sign out ${device}`,
13820
- signingOut: "Signing out\u2026",
13821
- signOutThisDevice: "Sign out this device",
13822
- noOtherDevices: "No other devices to sign out",
13823
- signOutEverywhere: "Sign out everywhere",
13824
- unknownDevice: "Unknown device",
13825
- revokeFailed: "Could not sign out that device. Please try again.",
13826
- justNow: "just now",
13827
- secondsAgo: (n) => `${n}s ago`,
13828
- minutesAgo: (n) => `${n}m ago`,
13829
- hoursAgo: (n) => `${n}h ago`,
13830
- daysAgo: (n) => `${n}d ago`
13831
- },
13832
- es: {
13833
- title: "Sesiones activas",
13834
- refresh: "Actualizar",
13835
- close: "Cerrar",
13836
- loading: "Cargando\u2026",
13837
- empty: "No hay sesiones activas.",
13838
- thisDevice: "Este dispositivo",
13839
- activeNow: "Activa ahora",
13840
- otherDevices: "Otros dispositivos",
13841
- signOutDevice: (device) => `Cerrar sesi\xF3n en ${device}`,
13842
- signingOut: "Cerrando sesi\xF3n\u2026",
13843
- signOutThisDevice: "Cerrar sesi\xF3n en este dispositivo",
13844
- noOtherDevices: "No hay otros dispositivos donde cerrar sesi\xF3n",
13845
- signOutEverywhere: "Cerrar sesi\xF3n en todas partes",
13846
- unknownDevice: "Dispositivo desconocido",
13847
- revokeFailed: "No se pudo cerrar sesi\xF3n en ese dispositivo. Intenta de nuevo.",
13848
- justNow: "justo ahora",
13849
- secondsAgo: (n) => `hace ${n} s`,
13850
- minutesAgo: (n) => `hace ${n} min`,
13851
- hoursAgo: (n) => `hace ${n} h`,
13852
- daysAgo: (n) => `hace ${n} d`
13853
- },
13854
- pt: {
13855
- title: "Sess\xF5es ativas",
13856
- refresh: "Atualizar",
13857
- close: "Fechar",
13858
- loading: "Carregando\u2026",
13859
- empty: "Nenhuma sess\xE3o ativa.",
13860
- thisDevice: "Este dispositivo",
13861
- activeNow: "Ativa agora",
13862
- otherDevices: "Outros dispositivos",
13863
- signOutDevice: (device) => `Sair de ${device}`,
13864
- signingOut: "Saindo\u2026",
13865
- signOutThisDevice: "Sair deste dispositivo",
13866
- noOtherDevices: "N\xE3o h\xE1 outros dispositivos para sair",
13867
- signOutEverywhere: "Sair de todos os dispositivos",
13868
- unknownDevice: "Dispositivo desconhecido",
13869
- revokeFailed: "N\xE3o foi poss\xEDvel sair desse dispositivo. Tente novamente.",
13870
- justNow: "agora mesmo",
13871
- secondsAgo: (n) => `h\xE1 ${n} s`,
13872
- minutesAgo: (n) => `h\xE1 ${n} min`,
13873
- hoursAgo: (n) => `h\xE1 ${n} h`,
13874
- daysAgo: (n) => `h\xE1 ${n} d`
13875
- }
13876
- };
13877
- function describeDevice(s, copy) {
13878
- if (s.deviceLabel) return normalizeDeviceLabel(s.deviceLabel);
13879
- if (!s.userAgent) return copy.unknownDevice;
13880
- return parseUserAgent(s.userAgent);
13881
- }
13882
- function normalizeDeviceLabel(label) {
13883
- const parts = label.replace(/\s+/g, " ").split(/ (?:[—–-]|·) /);
13884
- if (parts.length === 2 && parts[1] !== void 0) return `${parts[0]} \xB7 ${parts[1].toLowerCase()}`;
13885
- return label;
13886
- }
13887
- function detectBrowser(ua) {
13888
- if (/Edg\//.test(ua)) return "Edge";
13889
- if (/OPR\//.test(ua)) return "Opera";
13890
- if (/(Chrome|CriOS)\//.test(ua)) return "Chrome";
13891
- if (/(Firefox|FxiOS)\//.test(ua)) return "Firefox";
13892
- if (/Safari\//.test(ua)) return "Safari";
13893
- return null;
13894
- }
13895
- function detectOS(ua) {
13896
- if (/iPhone|iPad|iPod/.test(ua)) return "iOS";
13897
- if (/Android/.test(ua)) return "Android";
13898
- if (/Mac OS X/.test(ua)) return "macOS";
13899
- if (/Windows NT/.test(ua)) return "Windows";
13900
- if (/Linux/.test(ua)) return "Linux";
13901
- return null;
13902
- }
13903
- function parseUserAgent(ua) {
13904
- const browser = detectBrowser(ua);
13905
- const os = detectOS(ua);
13906
- if (browser && os) return `${os} \xB7 ${browser.toLowerCase()}`;
13907
- if (os) return os;
13908
- if (browser) return browser;
13909
- return ua.slice(0, 48);
13910
- }
13911
- function formatRelative(iso, copy) {
13912
- if (!iso) return "\u2014";
13913
- const ts = new Date(iso).getTime();
13914
- if (!Number.isFinite(ts)) return "\u2014";
13915
- const diffSec = Math.round((Date.now() - ts) / 1e3);
13916
- if (diffSec < 0) return copy.justNow;
13917
- if (diffSec < 60) return copy.secondsAgo(diffSec);
13918
- const diffMin = Math.round(diffSec / 60);
13919
- if (diffMin < 60) return copy.minutesAgo(diffMin);
13920
- const diffHr = Math.round(diffMin / 60);
13921
- if (diffHr < 24) return copy.hoursAgo(diffHr);
13922
- const diffDay = Math.round(diffHr / 24);
13923
- if (diffDay < 30) return copy.daysAgo(diffDay);
13924
- return new Date(iso).toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" });
13925
- }
13926
- function shortIp(hash) {
13927
- if (!hash) return "";
13928
- return hash.slice(0, 8);
13929
- }
13930
- function deviceKind(session) {
13931
- const value = `${session.deviceLabel ?? ""} ${session.userAgent ?? ""}`.toLowerCase();
13932
- if (/ipad|tablet/.test(value)) return "tablet";
13933
- if (/android|iphone|ipod|mobile|phone/.test(value)) return "phone";
13934
- return "desktop";
13935
- }
13936
- function DeviceIcon({ kind, size = "small" }) {
13937
- const dimensions = size === "large" ? 30 : 18;
13938
- if (kind === "phone") {
13939
- return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: dimensions, height: dimensions, viewBox: "0 0 24 24", fill: "none", "aria-hidden": true, children: [
13940
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "7", y: "2.5", width: "10", height: "19", rx: "2.5", stroke: "currentColor", strokeWidth: "1.8" }),
13941
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10.5 5h3M11 18.5h2", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })
13942
- ] });
13943
- }
13944
- if (kind === "tablet") {
13945
- return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: dimensions, height: dimensions, viewBox: "0 0 24 24", fill: "none", "aria-hidden": true, children: [
13946
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "4.5", y: "2.5", width: "15", height: "19", rx: "2", stroke: "currentColor", strokeWidth: "1.8" }),
13947
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11 18.5h2", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })
13948
- ] });
13949
- }
13950
- return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: dimensions, height: dimensions, viewBox: "0 0 24 24", fill: "none", "aria-hidden": true, children: [
13951
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "3", y: "3.5", width: "18", height: "12", rx: "1.8", stroke: "currentColor", strokeWidth: "1.8" }),
13952
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 20.5h8M12 15.5v5", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" })
13953
- ] });
13954
- }
13955
- function CheckIcon() {
13956
- return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m2.5 6.2 2.1 2.1L9.6 3.6", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round", strokeLinejoin: "round" }) });
13957
- }
13958
- function CloseIcon() {
13959
- return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m3 3 8 8M11 3l-8 8", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round" }) });
13960
- }
13961
- function SessionsModalTemplate({
13962
- theme,
13963
- accentColor,
13964
- styleOverrides,
13965
- state,
13966
- revokingFamilyId,
13967
- signingOutEverywhere,
13968
- revokeError,
13969
- onRefresh,
13970
- onRevoke,
13971
- onLogoutEverywhere,
13972
- onClose,
13973
- language: languageProp
13974
- }) {
13975
- const language = useInheritedLanguage(languageProp);
13976
- const copy = SESSIONS_COPY[language];
13977
- const cssVars = buildModalCssVars(theme, accentColor, styleOverrides);
13978
- const isLoading = state.step === "loading";
13979
- const sessions = state.step === "loaded" ? state.sessions : [];
13980
- const currentSession = sessions.find((s) => s.current);
13981
- const otherSessions = sessions.filter((s) => !s.current);
13982
- const otherCount = otherSessions.length;
13983
- return /* @__PURE__ */ jsxRuntime.jsxs(
13984
- "div",
13985
- {
13986
- className: "pollar-modal-card pollar-sessions-modal",
13987
- "data-theme": theme,
13988
- style: cssVars,
13989
- onClick: (e) => e.stopPropagation(),
13990
- children: [
13991
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
13992
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: copy.title }),
13993
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
14541
+ !loading && provider && card && panel === "fund" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
14542
+ /* @__PURE__ */ jsxRuntime.jsx("p", { children: copy.fundIntro(provider.fundingAssets.join(` ${copy.or} `) || "USDC") }),
14543
+ /* @__PURE__ */ jsxRuntime.jsx(
14544
+ ChainSelect,
14545
+ {
14546
+ value: selectedFundChain,
14547
+ options: fundChains,
14548
+ onChange: (chain) => setFundChain(chain),
14549
+ disabled: busy !== null,
14550
+ language
14551
+ }
14552
+ ),
14553
+ fundRoutes?.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: copy.fundingProblem.noRoute }),
14554
+ selectedRoute?.route === "CCTP" && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: copy.fundingProblem.crossing }),
14555
+ /* @__PURE__ */ jsxRuntime.jsx(
14556
+ AmountField,
14557
+ {
14558
+ id: "pollar-card-fund-amount",
14559
+ label: copy.amount,
14560
+ value: fundAmount,
14561
+ onChange: (value) => setFundAmount(value.replace(/[^0-9.]/g, "")),
14562
+ unit: fundingAsset,
14563
+ available: fundAvailable,
14564
+ placeholder: "10",
14565
+ language
14566
+ }
14567
+ ),
14568
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsxRuntime.jsx(
14569
+ "button",
14570
+ {
14571
+ type: "button",
14572
+ className: "pollar-btn-primary",
14573
+ onClick: () => void fund(),
14574
+ disabled: busy !== null || !selectedRoute || !(Number(fundAmount) >= 1),
14575
+ children: busy === "fund-send" ? copy.sending : copy.fundFromWallet
14576
+ }
14577
+ ) }),
14578
+ confirmation && /* @__PURE__ */ jsxRuntime.jsx(InlineConfirm, { confirmation, language }),
14579
+ !confirmation && sentFunding && (() => {
14580
+ const f = sentFunding;
14581
+ const state = (f.route === "DIRECT" ? copy.fundingSolana[f.status] : void 0) ?? copy.funding[f.status];
14582
+ const steps = FUNDING_STEPS[f.route];
14583
+ const step = steps.indexOf(f.status) + 1;
14584
+ const inflight = FUNDING_INFLIGHT.has(f.status);
14585
+ const failed = f.status === "FAILED";
14586
+ return /* @__PURE__ */ jsxRuntime.jsxs(
14587
+ "div",
14588
+ {
14589
+ className: `pollar-outcome${failed ? " pollar-outcome-bad" : ""}${inflight ? " pollar-outcome-busy" : ""}`,
14590
+ role: "status",
14591
+ children: [
14592
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-outcome-main", children: [
14593
+ inflight ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-hidden": true }) : /* @__PURE__ */ jsxRuntime.jsx(OutcomeIcon, { ok: !failed }),
14594
+ state?.title ?? f.status,
14595
+ " \xB7 ",
14596
+ money(f.amount, "USD", language)
14597
+ ] }),
14598
+ inflight && step > 0 && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-outcome-note", children: [
14599
+ copy.stepOf(step, steps.length),
14600
+ " \xB7",
14601
+ " ",
14602
+ f.error === CREDIT_DELAYED ? copy.fundingProblem.delayed : state?.hint
14603
+ ] }),
14604
+ failed && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-outcome-note", children: fundingProblemText(f.error, copy) })
14605
+ ]
14606
+ }
14607
+ );
14608
+ })(),
14609
+ earlierFundings.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
14610
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-section-title", children: copy.yourFundings }),
14611
+ earlierFundings.map((f) => {
14612
+ const state = (f.route === "DIRECT" ? copy.fundingSolana[f.status] : void 0) ?? copy.funding[f.status];
14613
+ const steps = FUNDING_STEPS[f.route];
14614
+ const step = steps.indexOf(f.status) + 1;
14615
+ const inflight = FUNDING_INFLIGHT.has(f.status);
14616
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-card-tx", "aria-busy": inflight, children: [
14617
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
14618
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-card-funding-title", children: [
14619
+ inflight && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-hidden": true }),
14620
+ state?.title ?? f.status
14621
+ ] }),
14622
+ inflight && step > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-card-tx-meta", role: "status", children: [
14623
+ copy.stepOf(step, steps.length),
14624
+ " \xB7",
14625
+ " ",
14626
+ f.error === CREDIT_DELAYED ? copy.fundingProblem.delayed : state?.hint
14627
+ ] }),
14628
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-card-tx-meta", children: [
14629
+ new Date(f.createdAt).toLocaleString(),
14630
+ f.status === "FAILED" ? ` \xB7 ${fundingProblemText(f.error, copy)}` : ""
14631
+ ] })
14632
+ ] }),
14633
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-card-tx-amount", "data-direction": f.status === "CREDITED" ? "credit" : void 0, children: money(f.amount, "USD", language) })
14634
+ ] }, f.id);
14635
+ }),
14636
+ fundingsInflight && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: copy.canClose })
14637
+ ] }),
14638
+ !showManual && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-card-note", children: [
14639
+ copy.preferOtherWallet,
14640
+ " ",
13994
14641
  /* @__PURE__ */ jsxRuntime.jsx(
13995
14642
  "button",
13996
14643
  {
13997
14644
  type: "button",
13998
- className: "pollar-modal-close",
13999
- onClick: onRefresh,
14000
- disabled: isLoading,
14001
- "aria-label": copy.refresh,
14002
- title: copy.refresh,
14003
- children: /* @__PURE__ */ jsxRuntime.jsx(RefreshIcon, { spinning: isLoading })
14645
+ className: "pollar-card-link",
14646
+ onClick: () => void showManualAddress(),
14647
+ disabled: busy !== null,
14648
+ children: copy.showDeposit
14004
14649
  }
14005
- ),
14006
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": copy.close, title: copy.close, children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {}) })
14007
- ] })
14008
- ] }),
14009
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-list", children: [
14010
- (state.step === "idle" || isLoading) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-loading-block", children: [
14011
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-spinner" }),
14012
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: copy.loading })
14013
- ] }),
14014
- state.step === "error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: state.message }),
14015
- state.step === "loaded" && sessions.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: copy.empty }),
14016
- state.step === "loaded" && currentSession && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-current-card", children: [
14017
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-current-icon-wrap", children: [
14018
- /* @__PURE__ */ jsxRuntime.jsx(DeviceIcon, { kind: deviceKind(currentSession), size: "large" }),
14019
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-sessions-current-check", children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, {}) })
14020
- ] }),
14021
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-sessions-current-label", children: copy.thisDevice }),
14022
- /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "pollar-sessions-current-device", children: describeDevice(currentSession, copy) }),
14023
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-current-status", children: [
14024
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-sessions-status-dot" }),
14025
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: copy.activeNow }),
14026
- currentSession.ipHash && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
14027
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\xB7" }),
14028
- /* @__PURE__ */ jsxRuntime.jsxs("span", { title: `ip-hash ${currentSession.ipHash}`, children: [
14029
- "IP ",
14030
- shortIp(currentSession.ipHash)
14031
- ] })
14032
- ] })
14033
- ] })
14034
- ] }),
14035
- state.step === "loaded" && otherSessions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "pollar-sessions-other-section", "aria-labelledby": "pollar-other-devices-heading", children: [
14036
- /* @__PURE__ */ jsxRuntime.jsxs("h3", { id: "pollar-other-devices-heading", className: "pollar-sessions-section-title", children: [
14037
- copy.otherDevices,
14038
- " ",
14039
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: otherCount })
14040
- ] }),
14041
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-sessions-grid", children: otherSessions.map((s) => {
14042
- const isRevoking = revokingFamilyId === s.familyId;
14043
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-item", children: [
14044
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-item-top", children: [
14045
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-sessions-item-icon", children: /* @__PURE__ */ jsxRuntime.jsx(DeviceIcon, { kind: deviceKind(s) }) }),
14046
- /* @__PURE__ */ jsxRuntime.jsx(
14047
- "button",
14048
- {
14049
- type: "button",
14050
- className: "pollar-sessions-item-revoke",
14051
- onClick: () => onRevoke(s.familyId),
14052
- disabled: isRevoking || signingOutEverywhere,
14053
- "aria-label": copy.signOutDevice(describeDevice(s, copy)),
14054
- title: isRevoking ? copy.signingOut : copy.signOutThisDevice,
14055
- children: isRevoking ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm" }) : /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {})
14056
- }
14057
- )
14058
- ] }),
14059
- /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "pollar-sessions-item-device", children: describeDevice(s, copy) }),
14060
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-sessions-item-meta", children: formatRelative(s.lastUsedAt ?? s.createdAt, copy) })
14061
- ] }, s.familyId);
14062
- }) })
14650
+ )
14063
14651
  ] }),
14064
- revokeError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-sessions-action-error", role: "alert", children: revokeError })
14065
- ] }),
14066
- state.step === "loaded" && sessions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-sessions-actions", children: /* @__PURE__ */ jsxRuntime.jsx(
14067
- "button",
14068
- {
14069
- className: "pollar-sessions-logout-all",
14070
- onClick: onLogoutEverywhere,
14071
- disabled: signingOutEverywhere || otherCount === 0,
14072
- title: otherCount === 0 ? copy.noOtherDevices : void 0,
14073
- children: signingOutEverywhere ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
14074
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm pollar-spinner-current" }),
14075
- copy.signingOut
14076
- ] }) : copy.signOutEverywhere
14077
- }
14078
- ) }),
14079
- /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
14080
- ]
14081
- }
14082
- );
14083
- }
14084
- function SessionsModal({ onClose }) {
14085
- const { getClient, styles, sessions } = usePollar();
14086
- const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
14087
- const language = useModalLanguage();
14088
- const copy = SESSIONS_COPY[language];
14089
- const [revokingFamilyId, setRevokingFamilyId] = react.useState(null);
14090
- const [signingOutEverywhere, setSigningOutEverywhere] = react.useState(false);
14091
- const [revokeError, setRevokeError] = react.useState(null);
14092
- const load = react.useCallback(() => {
14093
- void getClient().fetchSessions();
14094
- }, [getClient]);
14095
- react.useEffect(() => {
14096
- load();
14097
- }, [load]);
14098
- const onCloseRef = react.useRef(onClose);
14099
- onCloseRef.current = onClose;
14100
- react.useEffect(() => {
14101
- return getClient().onAuthStateChange((authState) => {
14102
- if (authState.step === "idle") onCloseRef.current();
14103
- });
14104
- }, [getClient]);
14105
- const handleRevoke = react.useCallback(
14106
- async (familyId) => {
14107
- setRevokingFamilyId(familyId);
14108
- setRevokeError(null);
14109
- try {
14110
- await getClient().revokeSession(familyId);
14111
- } catch {
14112
- setRevokeError(copy.revokeFailed);
14113
- } finally {
14114
- setRevokingFamilyId(null);
14115
- load();
14116
- }
14117
- },
14118
- [getClient, load, copy]
14119
- );
14120
- const handleLogoutEverywhere = react.useCallback(async () => {
14121
- setSigningOutEverywhere(true);
14122
- try {
14123
- await getClient().logoutEverywhere();
14124
- onClose();
14125
- } catch {
14126
- setSigningOutEverywhere(false);
14127
- }
14128
- }, [getClient, onClose]);
14129
- return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
14130
- SessionsModalTemplate,
14131
- {
14132
- theme,
14133
- accentColor,
14134
- styleOverrides,
14135
- state: sessions,
14136
- revokingFamilyId,
14137
- signingOutEverywhere,
14138
- revokeError,
14139
- onRefresh: () => load(),
14140
- onRevoke: (familyId) => void handleRevoke(familyId),
14141
- onLogoutEverywhere: () => void handleLogoutEverywhere(),
14142
- onClose,
14143
- language
14144
- }
14145
- ) });
14146
- }
14147
- function useCosign() {
14148
- const { getClient, isAuthenticated } = usePollar();
14149
- const [state, setState] = react.useState({ pending: [] });
14150
- const [loaded, setLoaded] = react.useState(false);
14151
- react.useEffect(() => getClient().onCosignStateChange(setState), [getClient]);
14152
- const refresh = react.useCallback(async () => {
14153
- if (!isAuthenticated) return;
14154
- try {
14155
- await getClient().cosign.pending();
14156
- } finally {
14157
- setLoaded(true);
14158
- }
14159
- }, [getClient, isAuthenticated]);
14160
- react.useEffect(() => {
14161
- void refresh();
14162
- }, [refresh]);
14163
- return {
14164
- pending: state.pending,
14165
- ...state.lastResolved ? { lastResolved: state.lastResolved } : {},
14166
- loaded,
14167
- refresh,
14168
- approve: react.useCallback((request) => getClient().cosign.approve(request), [getClient]),
14169
- reject: react.useCallback((request) => getClient().cosign.reject(request), [getClient]),
14170
- verify: react.useCallback((request) => getClient().cosign.verify(request), [getClient]),
14171
- inspectQuorum: react.useCallback(() => getClient().cosign.inspectQuorum(), [getClient]),
14172
- devices: react.useCallback(() => getClient().cosign.devices(), [getClient]),
14173
- revokeDevice: react.useCallback(
14174
- (deviceId, options) => getClient().cosign.revokeDevice(deviceId, options),
14175
- [getClient]
14176
- ),
14177
- switchCustody: react.useCallback((to) => getClient().cosign.switchCustody(to), [getClient])
14178
- };
14652
+ showManual && deposit?.map((d) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-card-deposit", children: [
14653
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: d.network }),
14654
+ " (",
14655
+ copy.chain(d.chainId),
14656
+ ")",
14657
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: d.address }),
14658
+ /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value: d.address, label: copy.copyAddress, language }),
14659
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: copy.sendOnly(d.tokens.map((t) => (t.currency ?? "token").toUpperCase()).join(` ${copy.or} `), d.network) })
14660
+ ] }, d.network)),
14661
+ showManual && deposit?.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: copy.noDeposit }),
14662
+ showManual && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-card-note", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-card-link", onClick: () => setShowManual(false), children: copy.hideDeposit }) })
14663
+ ] }),
14664
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: error }),
14665
+ loadFailed && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: retryLoad, children: copy.retry }) }),
14666
+ /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, { language })
14667
+ ]
14668
+ }
14669
+ ) });
14179
14670
  }
14180
14671
 
14181
- // src/components/cosign-modal/cosign-copy.ts
14182
- var COSIGN_COPY = {
14672
+ // src/components/sessions-modal/sessions-copy.ts
14673
+ var SESSIONS_COPY = {
14183
14674
  en: {
14184
- title: "Approvals",
14185
- manyPending: (count) => `${count} approvals waiting`,
14675
+ title: "Active sessions",
14676
+ refresh: "Refresh",
14186
14677
  close: "Close",
14187
- whyTitle: "Why am I seeing this?",
14188
- whyBody: "Your wallet needs this device's signature. Neither the app nor Pollar can approve this without you.",
14189
- rejectRequest: "Reject this request",
14190
- closeTitle: "Close without signing?",
14191
- closeBody: "The request stays pending. The app can't continue until you approve it.",
14192
- backToSign: "Go back and sign",
14193
- closeAnyway: "Close anyway",
14194
- activateWallet: "Activate wallet",
14195
- status: { APPROVED: "Approved", REJECTED: "Rejected", EXPIRED: "Expired", FAILED: "Failed", PENDING: "Pending" },
14196
- signedAppSends: "Signed. The app will send it.",
14197
- signedSent: "Signed and sent",
14198
- signed: "Signed",
14199
- nothingSigned: "Nothing was signed.",
14200
- nothingWaiting: "Nothing waits for your approval.",
14201
- next: (step) => `Next: ${step}. It appears here in a few seconds.`,
14202
- closingIn: (seconds) => `Closing in ${seconds}s`,
14203
- expired: "expired",
14204
- expiresIn: "Expires in",
14205
- checking: "Checking...",
14206
- verified: "Checked",
14207
- checkedExact: "We checked this is exactly what you're approving.",
14208
- notVerified: "Not verified:",
14209
- reject: "Reject",
14210
- rejecting: "Rejecting...",
14211
- approve: "Approve",
14212
- approving: "Approving...",
14213
- genericError: "Something went wrong. Please try again.",
14214
- unreachable: "We could not reach Pollar, so nothing was approved. Check your connection and approve again.",
14215
- deviceNotLinked: "This device isn't linked to your wallet yet, so it can't approve. Add it with a device that already is, your passkey or your email.",
14216
- linkDevice: "Link this device",
14217
- transaction: "Transaction",
14218
- operations: {
14219
- payment: "Send",
14220
- path_payment_strict_send: "Swap",
14221
- change_trust: "Add asset",
14222
- create_account: "Create account",
14223
- invoke_contract: "Contract call",
14224
- soroban_auth: "Authorize a contract call",
14225
- manage_data: "Manage data",
14226
- transfer: "Send",
14227
- ramp_payment: "Ramp payment",
14228
- cctp_burn: "Move USDC",
14229
- swap: "Swap",
14230
- earn_deposit: "Deposit",
14231
- earn_withdraw: "Withdraw",
14232
- evm_delegation: "Enable atomic transactions",
14233
- provider_sign_in: "Confirm it's you",
14234
- sep10: "Confirm it's you"
14235
- }
14678
+ loading: "Loading\u2026",
14679
+ empty: "No active sessions.",
14680
+ thisDevice: "This device",
14681
+ activeNow: "Active now",
14682
+ otherDevices: "Other devices",
14683
+ signOutDevice: (device) => `Sign out ${device}`,
14684
+ signingOut: "Signing out\u2026",
14685
+ signOutThisDevice: "Sign out this device",
14686
+ noOtherDevices: "No other devices to sign out",
14687
+ signOutEverywhere: "Sign out everywhere",
14688
+ unknownDevice: "Unknown device",
14689
+ revokeFailed: "Could not sign out that device. Please try again.",
14690
+ justNow: "just now",
14691
+ secondsAgo: (n) => `${n}s ago`,
14692
+ minutesAgo: (n) => `${n}m ago`,
14693
+ hoursAgo: (n) => `${n}h ago`,
14694
+ daysAgo: (n) => `${n}d ago`
14236
14695
  },
14237
14696
  es: {
14238
- title: "Aprobaciones",
14239
- manyPending: (count) => `${count} aprobaciones pendientes`,
14697
+ title: "Sesiones activas",
14698
+ refresh: "Actualizar",
14240
14699
  close: "Cerrar",
14241
- whyTitle: "\xBFPor qu\xE9 ves esto?",
14242
- whyBody: "Tu billetera necesita la firma de este dispositivo. Ni la app ni Pollar pueden aprobar esto sin ti.",
14243
- rejectRequest: "Rechazar esta solicitud",
14244
- closeTitle: "\xBFCerrar sin firmar?",
14245
- closeBody: "La solicitud queda pendiente. La app no puede seguir hasta que la apruebes.",
14246
- backToSign: "Volver y firmar",
14247
- closeAnyway: "Cerrar igual",
14248
- activateWallet: "Activar billetera",
14249
- status: { APPROVED: "Aprobada", REJECTED: "Rechazada", EXPIRED: "Vencida", FAILED: "Fallida", PENDING: "Pendiente" },
14250
- signedAppSends: "Firmada. La app la enviar\xE1.",
14251
- signedSent: "Firmada y enviada",
14252
- signed: "Firmada",
14253
- nothingSigned: "No se firm\xF3 nada.",
14254
- nothingWaiting: "No hay nada esperando tu aprobaci\xF3n.",
14255
- next: (step) => `Siguiente: ${step}. Aparecer\xE1 aqu\xED en unos segundos.`,
14256
- closingIn: (seconds) => `Se cierra en ${seconds}s`,
14257
- expired: "vencida",
14258
- expiresIn: "Vence en",
14259
- checking: "Verificando...",
14260
- verified: "Comprobada",
14261
- checkedExact: "Comprobamos que esto es exactamente lo que est\xE1s aprobando.",
14262
- notVerified: "Sin verificar:",
14263
- reject: "Rechazar",
14264
- rejecting: "Rechazando...",
14265
- approve: "Aprobar",
14266
- approving: "Aprobando...",
14267
- genericError: "Algo sali\xF3 mal. Intenta de nuevo.",
14268
- unreachable: "No pudimos conectar con Pollar, as\xED que no se aprob\xF3 nada. Revisa tu conexi\xF3n y aprueba de nuevo.",
14269
- deviceNotLinked: "Este dispositivo a\xFAn no est\xE1 vinculado a tu billetera, as\xED que no puede aprobar. Agr\xE9galo con un dispositivo que ya lo est\xE9, tu passkey o tu email.",
14270
- linkDevice: "Vincular este dispositivo",
14271
- transaction: "Transacci\xF3n",
14272
- operations: {
14273
- payment: "Enviar",
14274
- path_payment_strict_send: "Intercambiar",
14275
- change_trust: "Agregar activo",
14276
- create_account: "Crear cuenta",
14277
- invoke_contract: "Llamada a contrato",
14278
- soroban_auth: "Autorizar una llamada a contrato",
14279
- manage_data: "Gestionar datos",
14280
- transfer: "Enviar",
14281
- ramp_payment: "Pago de rampa",
14282
- cctp_burn: "Mover USDC",
14283
- swap: "Intercambiar",
14284
- earn_deposit: "Depositar",
14285
- earn_withdraw: "Retirar",
14286
- evm_delegation: "Activar transacciones at\xF3micas",
14287
- provider_sign_in: "Confirma que eres t\xFA",
14288
- sep10: "Confirma que eres t\xFA"
14289
- }
14700
+ loading: "Cargando\u2026",
14701
+ empty: "No hay sesiones activas.",
14702
+ thisDevice: "Este dispositivo",
14703
+ activeNow: "Activa ahora",
14704
+ otherDevices: "Otros dispositivos",
14705
+ signOutDevice: (device) => `Cerrar sesi\xF3n en ${device}`,
14706
+ signingOut: "Cerrando sesi\xF3n\u2026",
14707
+ signOutThisDevice: "Cerrar sesi\xF3n en este dispositivo",
14708
+ noOtherDevices: "No hay otros dispositivos donde cerrar sesi\xF3n",
14709
+ signOutEverywhere: "Cerrar sesi\xF3n en todas partes",
14710
+ unknownDevice: "Dispositivo desconocido",
14711
+ revokeFailed: "No se pudo cerrar sesi\xF3n en ese dispositivo. Intenta de nuevo.",
14712
+ justNow: "justo ahora",
14713
+ secondsAgo: (n) => `hace ${n} s`,
14714
+ minutesAgo: (n) => `hace ${n} min`,
14715
+ hoursAgo: (n) => `hace ${n} h`,
14716
+ daysAgo: (n) => `hace ${n} d`
14290
14717
  },
14291
14718
  pt: {
14292
- title: "Aprova\xE7\xF5es",
14293
- manyPending: (count) => `${count} aprova\xE7\xF5es pendentes`,
14719
+ title: "Sess\xF5es ativas",
14720
+ refresh: "Atualizar",
14294
14721
  close: "Fechar",
14295
- whyTitle: "Por que estou vendo isto?",
14296
- whyBody: "Sua carteira precisa da assinatura deste dispositivo. Nem o app nem a Pollar podem aprovar isto sem voc\xEA.",
14297
- rejectRequest: "Rejeitar esta solicita\xE7\xE3o",
14298
- closeTitle: "Fechar sem assinar?",
14299
- closeBody: "A solicita\xE7\xE3o fica pendente. O app n\xE3o pode continuar at\xE9 voc\xEA aprov\xE1-la.",
14300
- backToSign: "Voltar e assinar",
14301
- closeAnyway: "Fechar mesmo assim",
14302
- activateWallet: "Ativar carteira",
14303
- status: { APPROVED: "Aprovada", REJECTED: "Rejeitada", EXPIRED: "Expirada", FAILED: "Falhou", PENDING: "Pendente" },
14304
- signedAppSends: "Assinada. O app vai envi\xE1-la.",
14305
- signedSent: "Assinada e enviada",
14306
- signed: "Assinada",
14307
- nothingSigned: "Nada foi assinado.",
14308
- nothingWaiting: "Nada aguarda a sua aprova\xE7\xE3o.",
14309
- next: (step) => `Pr\xF3ximo: ${step}. Aparece aqui em alguns segundos.`,
14310
- closingIn: (seconds) => `Fechando em ${seconds}s`,
14311
- expired: "expirada",
14312
- expiresIn: "Expira em",
14313
- checking: "Verificando...",
14314
- verified: "Conferida",
14315
- checkedExact: "Conferimos que isto \xE9 exatamente o que voc\xEA est\xE1 aprovando.",
14316
- notVerified: "N\xE3o verificada:",
14317
- reject: "Rejeitar",
14318
- rejecting: "Rejeitando...",
14319
- approve: "Aprovar",
14320
- approving: "Aprovando...",
14321
- genericError: "Algo deu errado. Tente novamente.",
14322
- unreachable: "N\xE3o conseguimos conectar \xE0 Pollar, ent\xE3o nada foi aprovado. Verifique sua conex\xE3o e aprove novamente.",
14323
- deviceNotLinked: "Este dispositivo ainda n\xE3o est\xE1 vinculado \xE0 sua carteira, ent\xE3o n\xE3o pode aprovar. Adicione-o com um dispositivo que j\xE1 esteja, sua passkey ou seu email.",
14324
- linkDevice: "Vincular este dispositivo",
14325
- transaction: "Transa\xE7\xE3o",
14326
- operations: {
14327
- payment: "Enviar",
14328
- path_payment_strict_send: "Trocar",
14329
- change_trust: "Adicionar ativo",
14330
- create_account: "Criar conta",
14331
- invoke_contract: "Chamada de contrato",
14332
- soroban_auth: "Autorizar uma chamada de contrato",
14333
- manage_data: "Gerenciar dados",
14334
- transfer: "Enviar",
14335
- ramp_payment: "Pagamento de rampa",
14336
- cctp_burn: "Mover USDC",
14337
- swap: "Trocar",
14338
- earn_deposit: "Depositar",
14339
- earn_withdraw: "Sacar",
14340
- evm_delegation: "Ativar transa\xE7\xF5es at\xF4micas",
14341
- provider_sign_in: "Confirme que \xE9 voc\xEA",
14342
- sep10: "Confirme que \xE9 voc\xEA"
14343
- }
14722
+ loading: "Carregando\u2026",
14723
+ empty: "Nenhuma sess\xE3o ativa.",
14724
+ thisDevice: "Este dispositivo",
14725
+ activeNow: "Ativa agora",
14726
+ otherDevices: "Outros dispositivos",
14727
+ signOutDevice: (device) => `Sair de ${device}`,
14728
+ signingOut: "Saindo\u2026",
14729
+ signOutThisDevice: "Sair deste dispositivo",
14730
+ noOtherDevices: "N\xE3o h\xE1 outros dispositivos para sair",
14731
+ signOutEverywhere: "Sair de todos os dispositivos",
14732
+ unknownDevice: "Dispositivo desconhecido",
14733
+ revokeFailed: "N\xE3o foi poss\xEDvel sair desse dispositivo. Tente novamente.",
14734
+ justNow: "agora mesmo",
14735
+ secondsAgo: (n) => `h\xE1 ${n} s`,
14736
+ minutesAgo: (n) => `h\xE1 ${n} min`,
14737
+ hoursAgo: (n) => `h\xE1 ${n} h`,
14738
+ daysAgo: (n) => `h\xE1 ${n} d`
14344
14739
  }
14345
14740
  };
14346
- function labelOf2(request, copy) {
14347
- const op = request.operation ?? "";
14348
- return copy.operations[op] ?? (op ? op.replace(/_/g, " ") : copy.transaction);
14741
+ function describeDevice(s, copy) {
14742
+ if (s.deviceLabel) return normalizeDeviceLabel(s.deviceLabel);
14743
+ if (!s.userAgent) return copy.unknownDevice;
14744
+ return parseUserAgent(s.userAgent);
14745
+ }
14746
+ function normalizeDeviceLabel(label) {
14747
+ const parts = label.replace(/\s+/g, " ").split(/ (?:[—–-]|·) /);
14748
+ if (parts.length === 2 && parts[1] !== void 0) return `${parts[0]} \xB7 ${parts[1].toLowerCase()}`;
14749
+ return label;
14750
+ }
14751
+ function detectBrowser(ua) {
14752
+ if (/Edg\//.test(ua)) return "Edge";
14753
+ if (/OPR\//.test(ua)) return "Opera";
14754
+ if (/(Chrome|CriOS)\//.test(ua)) return "Chrome";
14755
+ if (/(Firefox|FxiOS)\//.test(ua)) return "Firefox";
14756
+ if (/Safari\//.test(ua)) return "Safari";
14757
+ return null;
14758
+ }
14759
+ function detectOS(ua) {
14760
+ if (/iPhone|iPad|iPod/.test(ua)) return "iOS";
14761
+ if (/Android/.test(ua)) return "Android";
14762
+ if (/Mac OS X/.test(ua)) return "macOS";
14763
+ if (/Windows NT/.test(ua)) return "Windows";
14764
+ if (/Linux/.test(ua)) return "Linux";
14765
+ return null;
14349
14766
  }
14350
- function expiresIn(request, copy) {
14351
- const ms = new Date(request.expiresAt).getTime() - Date.now();
14352
- if (!Number.isFinite(ms) || ms <= 0) return copy.expired;
14353
- const h = Math.floor(ms / 36e5);
14354
- const m = Math.floor(ms % 36e5 / 6e4);
14355
- return h > 0 ? `${h}h ${m}m` : `${m}m`;
14767
+ function parseUserAgent(ua) {
14768
+ const browser = detectBrowser(ua);
14769
+ const os = detectOS(ua);
14770
+ if (browser && os) return `${os} \xB7 ${browser.toLowerCase()}`;
14771
+ if (os) return os;
14772
+ if (browser) return browser;
14773
+ return ua.slice(0, 48);
14356
14774
  }
14357
- function outcomeText(request, copy) {
14358
- if (request.status !== "APPROVED")
14359
- return `${copy.status[request.status] ?? request.status.toLowerCase()}. ${copy.nothingSigned}`;
14360
- if (request.submit?.hash) return copy.signedSent;
14361
- if (request.signedXdr) return copy.signedAppSends;
14362
- return copy.status.APPROVED ?? "Approved";
14775
+ function formatRelative(iso, copy) {
14776
+ if (!iso) return "\u2014";
14777
+ const ts = new Date(iso).getTime();
14778
+ if (!Number.isFinite(ts)) return "\u2014";
14779
+ const diffSec = Math.round((Date.now() - ts) / 1e3);
14780
+ if (diffSec < 0) return copy.justNow;
14781
+ if (diffSec < 60) return copy.secondsAgo(diffSec);
14782
+ const diffMin = Math.round(diffSec / 60);
14783
+ if (diffMin < 60) return copy.minutesAgo(diffMin);
14784
+ const diffHr = Math.round(diffMin / 60);
14785
+ if (diffHr < 24) return copy.hoursAgo(diffHr);
14786
+ const diffDay = Math.round(diffHr / 24);
14787
+ if (diffDay < 30) return copy.daysAgo(diffDay);
14788
+ return new Date(iso).toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" });
14363
14789
  }
14364
- function StepRow({
14365
- request,
14366
- review,
14367
- copy,
14368
- language
14369
- }) {
14370
- const [open, setOpen] = react.useState(false);
14371
- const ok = request.status === "APPROVED";
14372
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `pollar-cosign-step${ok ? "" : " pollar-cosign-step-bad"}`, children: [
14373
- /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-cosign-step-head", "aria-expanded": open, onClick: () => setOpen((v) => !v), children: [
14374
- /* @__PURE__ */ jsxRuntime.jsx(OutcomeIcon, { ok }),
14375
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-cosign-step-title", children: review.title }),
14376
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-cosign-step-status", children: ok ? copy.signed : copy.status[request.status] ?? request.status }),
14377
- /* @__PURE__ */ jsxRuntime.jsx(
14378
- "svg",
14379
- {
14380
- width: "10",
14381
- height: "10",
14382
- viewBox: "0 0 12 12",
14383
- fill: "none",
14384
- "aria-hidden": true,
14385
- style: { transform: open ? "rotate(180deg)" : "none", transition: "transform 150ms" },
14386
- children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 4l4 4 4-4", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" })
14387
- }
14388
- )
14389
- ] }),
14390
- open && /* @__PURE__ */ jsxRuntime.jsx(TxReview, { data: review, language, detailsOnly: true })
14790
+ function shortIp(hash) {
14791
+ if (!hash) return "";
14792
+ return hash.slice(0, 8);
14793
+ }
14794
+ function deviceKind(session) {
14795
+ const value = `${session.deviceLabel ?? ""} ${session.userAgent ?? ""}`.toLowerCase();
14796
+ if (/ipad|tablet/.test(value)) return "tablet";
14797
+ if (/android|iphone|ipod|mobile|phone/.test(value)) return "phone";
14798
+ return "desktop";
14799
+ }
14800
+ function DeviceIcon({ kind, size = "small" }) {
14801
+ const dimensions = size === "large" ? 30 : 18;
14802
+ if (kind === "phone") {
14803
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: dimensions, height: dimensions, viewBox: "0 0 24 24", fill: "none", "aria-hidden": true, children: [
14804
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "7", y: "2.5", width: "10", height: "19", rx: "2.5", stroke: "currentColor", strokeWidth: "1.8" }),
14805
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10.5 5h3M11 18.5h2", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })
14806
+ ] });
14807
+ }
14808
+ if (kind === "tablet") {
14809
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: dimensions, height: dimensions, viewBox: "0 0 24 24", fill: "none", "aria-hidden": true, children: [
14810
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "4.5", y: "2.5", width: "15", height: "19", rx: "2", stroke: "currentColor", strokeWidth: "1.8" }),
14811
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11 18.5h2", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })
14812
+ ] });
14813
+ }
14814
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: dimensions, height: dimensions, viewBox: "0 0 24 24", fill: "none", "aria-hidden": true, children: [
14815
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "3", y: "3.5", width: "18", height: "12", rx: "1.8", stroke: "currentColor", strokeWidth: "1.8" }),
14816
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 20.5h8M12 15.5v5", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" })
14391
14817
  ] });
14392
14818
  }
14819
+ function CheckIcon() {
14820
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m2.5 6.2 2.1 2.1L9.6 3.6", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round", strokeLinejoin: "round" }) });
14821
+ }
14393
14822
  function CloseIcon2() {
14394
14823
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m3 3 8 8M11 3l-8 8", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round" }) });
14395
14824
  }
14396
- function VerifiedIcon() {
14397
- return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
14398
- /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
14399
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3.5 7l2.5 2.5 4.5-5", stroke: "white", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" })
14400
- ] });
14401
- }
14402
- function CosignModalTemplate({
14825
+ function SessionsModalTemplate({
14403
14826
  theme,
14404
14827
  accentColor,
14405
14828
  styleOverrides,
14406
- pending,
14407
- current,
14408
- verification,
14409
- busy,
14410
- error,
14411
- approveBlocked = false,
14412
- deviceNotLinked = false,
14413
- onLinkDevice,
14414
- lastResolved,
14415
- history = [],
14416
- explorerUrlOf,
14417
- closesIn = null,
14418
- nextStep = null,
14419
- language: languageProp,
14420
- network,
14421
- onSelect,
14422
- onApprove,
14423
- onReject,
14829
+ state,
14830
+ revokingFamilyId,
14831
+ signingOutEverywhere,
14832
+ revokeError,
14833
+ onRefresh,
14834
+ onRevoke,
14835
+ onLogoutEverywhere,
14424
14836
  onClose,
14425
- confirmingClose = false,
14426
- onKeepOpen,
14427
- onCloseAnyway
14837
+ language: languageProp
14428
14838
  }) {
14429
14839
  const language = useInheritedLanguage(languageProp);
14430
- const copy = COSIGN_COPY[language];
14840
+ const copy = SESSIONS_COPY[language];
14431
14841
  const cssVars = buildModalCssVars(theme, accentColor, styleOverrides);
14432
- const verified = verification?.ok === true && !deviceNotLinked;
14433
- const canVote = !!current && verified && !busy && !approveBlocked;
14434
- const [verifiedOpenFor, setVerifiedOpenFor] = react.useState(null);
14435
- const verifiedOpen = !!current && verifiedOpenFor === current.id;
14436
- const reviewOf = (request) => reviewFromRequest(
14437
- {
14438
- chain: request.network,
14439
- network,
14440
- operation: request.operation,
14441
- summary: request.summary,
14442
- details: request.details,
14443
- signWith: request.account ?? request.signWith,
14444
- raw: request.unsignedPayload,
14445
- fallbackTitle: labelOf2(request, copy),
14446
- ...request.status === "PENDING" ? { extraRows: [{ label: copy.expiresIn, value: expiresIn(request, copy) }] } : {},
14447
- appPaysFee: request.submit?.sponsored ?? request.appPaysFee,
14448
- ...request.submit?.hash ? { hash: { value: request.submit.hash, explorerUrl: explorerUrlOf?.(request) ?? null } } : {}
14449
- },
14450
- TX_REVIEW_COPY[language]
14451
- );
14452
- const review = current ? reviewOf(current) : null;
14453
- const grouped = pending.length > 1;
14454
- const shown = grouped ? null : current ?? (pending.length === 0 ? lastResolved : void 0) ?? null;
14455
- const shownReview = shown ? shown === current ? review : reviewOf(shown) : null;
14456
- const doneSteps = history.filter((r) => !(pending.length === 0 && r.id === lastResolved?.id));
14457
- const heading = confirmingClose ? copy.closeTitle : grouped ? copy.manyPending(pending.length) : shownReview?.title ?? copy.title;
14458
- const chip = current && !confirmingClose && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
14459
- !verification && !deviceNotLinked && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-cosign-chip", children: [
14460
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-hidden": true }),
14461
- copy.checking
14462
- ] }),
14463
- verified && /* @__PURE__ */ jsxRuntime.jsxs(
14464
- "button",
14465
- {
14466
- type: "button",
14467
- className: "pollar-cosign-chip pollar-cosign-chip-ok",
14468
- "aria-expanded": verifiedOpen,
14469
- onClick: () => setVerifiedOpenFor(verifiedOpen ? null : current.id),
14470
- children: [
14471
- /* @__PURE__ */ jsxRuntime.jsx(VerifiedIcon, {}),
14472
- copy.verified
14473
- ]
14474
- }
14475
- )
14476
- ] });
14842
+ const isLoading = state.step === "loading";
14843
+ const sessions = state.step === "loaded" ? state.sessions : [];
14844
+ const currentSession = sessions.find((s) => s.current);
14845
+ const otherSessions = sessions.filter((s) => !s.current);
14846
+ const otherCount = otherSessions.length;
14477
14847
  return /* @__PURE__ */ jsxRuntime.jsxs(
14478
14848
  "div",
14479
14849
  {
14480
- className: "pollar-modal-card pollar-cosign-modal",
14850
+ className: "pollar-modal-card pollar-sessions-modal",
14481
14851
  "data-theme": theme,
14482
14852
  style: cssVars,
14483
14853
  onClick: (e) => e.stopPropagation(),
14484
14854
  children: [
14485
14855
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
14486
- /* @__PURE__ */ jsxRuntime.jsxs("h2", { className: "pollar-modal-title pollar-cosign-heading", children: [
14487
- !confirmingClose && /* @__PURE__ */ jsxRuntime.jsx(TitleMark, { chain: shown?.network, asset: shownReview ? headlineAsset(shownReview) : void 0 }),
14488
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: heading })
14489
- ] }),
14490
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
14491
- !grouped && chip,
14492
- !confirmingClose && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": copy.close, title: copy.close, children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon2, {}) })
14493
- ] })
14494
- ] }),
14495
- confirmingClose ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-leave", children: [
14496
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-cosign-muted", children: copy.closeBody }),
14497
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-cosign-btn pollar-cosign-btn-primary", onClick: onKeepOpen, children: copy.backToSign }),
14498
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-cosign-text-btn", onClick: onCloseAnyway, children: copy.closeAnyway })
14499
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
14500
- doneSteps.map((r) => /* @__PURE__ */ jsxRuntime.jsx(StepRow, { request: r, review: reviewOf(r), copy, language }, r.id)),
14501
- pending.length === 0 && (lastResolved && shownReview ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-detail", children: [
14502
- /* @__PURE__ */ jsxRuntime.jsx(TxReview, { data: shownReview, language }, lastResolved.id),
14503
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `pollar-outcome${lastResolved.status === "APPROVED" ? "" : " pollar-outcome-bad"}`, children: [
14504
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-outcome-main", children: [
14505
- /* @__PURE__ */ jsxRuntime.jsx(OutcomeIcon, { ok: lastResolved.status === "APPROVED" }),
14506
- outcomeText(lastResolved, copy)
14507
- ] }),
14508
- nextStep && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-outcome-note", children: [
14509
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-hidden": true }),
14510
- " ",
14511
- copy.next(nextStep)
14512
- ] }),
14513
- closesIn !== null && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-outcome-note", children: copy.closingIn(closesIn) })
14514
- ] })
14515
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-empty", children: [
14516
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-cosign-muted", children: copy.nothingWaiting }),
14517
- closesIn !== null && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-cosign-muted pollar-cosign-closing", children: copy.closingIn(closesIn) })
14518
- ] })),
14519
- grouped && /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "pollar-cosign-list", children: pending.map((r) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
14520
- "button",
14521
- {
14522
- type: "button",
14523
- className: `pollar-cosign-item${current?.id === r.id ? " pollar-cosign-item-active" : ""}`,
14524
- onClick: () => onSelect(r),
14525
- children: [
14526
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-cosign-heading", children: [
14527
- /* @__PURE__ */ jsxRuntime.jsx(TitleMark, { chain: r.network, asset: headlineAsset(reviewOf(r)) }),
14528
- reviewOf(r).title
14529
- ] }),
14530
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-cosign-muted", children: expiresIn(r, copy) })
14531
- ]
14532
- }
14533
- ) }, r.id)) }),
14534
- current && review && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `pollar-cosign-detail${grouped ? " pollar-cosign-detail-grouped" : ""}`, children: [
14535
- grouped && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-detail-head", children: [
14536
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-cosign-detail-title", children: review.title }),
14537
- chip
14538
- ] }),
14539
- /* @__PURE__ */ jsxRuntime.jsx(
14540
- TxReview,
14541
- {
14542
- data: review,
14543
- language,
14544
- detailsIntro: { title: copy.whyTitle, body: copy.whyBody },
14545
- detailsAction: {
14546
- label: busy === "rejecting" ? copy.rejecting : copy.rejectRequest,
14547
- onClick: () => onReject(current),
14548
- disabled: !!busy
14549
- }
14550
- },
14551
- current.id
14552
- ),
14553
- verified && verifiedOpen && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-cosign-verify pollar-cosign-verify-ok", children: copy.checkedExact }),
14554
- deviceNotLinked ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-verify pollar-cosign-verify-bad", children: [
14555
- copy.deviceNotLinked,
14556
- onLinkDevice && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-cosign-link", onClick: onLinkDevice, children: copy.linkDevice })
14557
- ] }) : verification && !verification.ok && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-verify pollar-cosign-verify-bad", children: [
14558
- copy.notVerified,
14559
- " ",
14560
- verification.reason
14561
- ] }),
14562
- error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-cosign-error", children: error }),
14856
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: copy.title }),
14857
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
14563
14858
  /* @__PURE__ */ jsxRuntime.jsx(
14564
14859
  "button",
14565
14860
  {
14566
14861
  type: "button",
14567
- className: "pollar-cosign-btn pollar-cosign-btn-primary",
14568
- disabled: !canVote,
14569
- onClick: () => onApprove(current),
14570
- children: busy === "approving" ? copy.approving : review.kind === "activate_wallet" ? copy.activateWallet : copy.approve
14862
+ className: "pollar-modal-close",
14863
+ onClick: onRefresh,
14864
+ disabled: isLoading,
14865
+ "aria-label": copy.refresh,
14866
+ title: copy.refresh,
14867
+ children: /* @__PURE__ */ jsxRuntime.jsx(RefreshIcon, { spinning: isLoading })
14571
14868
  }
14572
- )
14869
+ ),
14870
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": copy.close, title: copy.close, children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon2, {}) })
14573
14871
  ] })
14574
14872
  ] }),
14873
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-list", children: [
14874
+ (state.step === "idle" || isLoading) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-loading-block", children: [
14875
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-spinner" }),
14876
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: copy.loading })
14877
+ ] }),
14878
+ state.step === "error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: state.message }),
14879
+ state.step === "loaded" && sessions.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: copy.empty }),
14880
+ state.step === "loaded" && currentSession && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-current-card", children: [
14881
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-current-icon-wrap", children: [
14882
+ /* @__PURE__ */ jsxRuntime.jsx(DeviceIcon, { kind: deviceKind(currentSession), size: "large" }),
14883
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-sessions-current-check", children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, {}) })
14884
+ ] }),
14885
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-sessions-current-label", children: copy.thisDevice }),
14886
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "pollar-sessions-current-device", children: describeDevice(currentSession, copy) }),
14887
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-current-status", children: [
14888
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-sessions-status-dot" }),
14889
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: copy.activeNow }),
14890
+ currentSession.ipHash && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
14891
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\xB7" }),
14892
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { title: `ip-hash ${currentSession.ipHash}`, children: [
14893
+ "IP ",
14894
+ shortIp(currentSession.ipHash)
14895
+ ] })
14896
+ ] })
14897
+ ] })
14898
+ ] }),
14899
+ state.step === "loaded" && otherSessions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "pollar-sessions-other-section", "aria-labelledby": "pollar-other-devices-heading", children: [
14900
+ /* @__PURE__ */ jsxRuntime.jsxs("h3", { id: "pollar-other-devices-heading", className: "pollar-sessions-section-title", children: [
14901
+ copy.otherDevices,
14902
+ " ",
14903
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: otherCount })
14904
+ ] }),
14905
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-sessions-grid", children: otherSessions.map((s) => {
14906
+ const isRevoking = revokingFamilyId === s.familyId;
14907
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-item", children: [
14908
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-item-top", children: [
14909
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-sessions-item-icon", children: /* @__PURE__ */ jsxRuntime.jsx(DeviceIcon, { kind: deviceKind(s) }) }),
14910
+ /* @__PURE__ */ jsxRuntime.jsx(
14911
+ "button",
14912
+ {
14913
+ type: "button",
14914
+ className: "pollar-sessions-item-revoke",
14915
+ onClick: () => onRevoke(s.familyId),
14916
+ disabled: isRevoking || signingOutEverywhere,
14917
+ "aria-label": copy.signOutDevice(describeDevice(s, copy)),
14918
+ title: isRevoking ? copy.signingOut : copy.signOutThisDevice,
14919
+ children: isRevoking ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm" }) : /* @__PURE__ */ jsxRuntime.jsx(CloseIcon2, {})
14920
+ }
14921
+ )
14922
+ ] }),
14923
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "pollar-sessions-item-device", children: describeDevice(s, copy) }),
14924
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-sessions-item-meta", children: formatRelative(s.lastUsedAt ?? s.createdAt, copy) })
14925
+ ] }, s.familyId);
14926
+ }) })
14927
+ ] }),
14928
+ revokeError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-sessions-action-error", role: "alert", children: revokeError })
14929
+ ] }),
14930
+ state.step === "loaded" && sessions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-sessions-actions", children: /* @__PURE__ */ jsxRuntime.jsx(
14931
+ "button",
14932
+ {
14933
+ className: "pollar-sessions-logout-all",
14934
+ onClick: onLogoutEverywhere,
14935
+ disabled: signingOutEverywhere || otherCount === 0,
14936
+ title: otherCount === 0 ? copy.noOtherDevices : void 0,
14937
+ children: signingOutEverywhere ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
14938
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm pollar-spinner-current" }),
14939
+ copy.signingOut
14940
+ ] }) : copy.signOutEverywhere
14941
+ }
14942
+ ) }),
14575
14943
  /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
14576
14944
  ]
14577
14945
  }
14578
14946
  );
14579
14947
  }
14580
- var CLOSE_AFTER_SECONDS = 3;
14581
- var CLOSE_AFTER_SENT_SECONDS = 5;
14582
- var NEXT_REQUEST_EVERY_MS = 2e3;
14583
- function CosignModal({ nextStep = null, onClose }) {
14584
- const { getClient, styles, network, openRecoveryModal } = usePollar();
14948
+ function SessionsModal({ onClose }) {
14949
+ const { getClient, styles, sessions } = usePollar();
14585
14950
  const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
14586
- const { pending, lastResolved, loaded, refresh, approve, reject, verify, inspectQuorum } = useCosign();
14587
14951
  const language = useModalLanguage();
14588
- const [selectedId, setSelectedId] = react.useState(null);
14589
- const [verification, setVerification] = react.useState(null);
14590
- const [busy, setBusy] = react.useState(null);
14591
- const [error, setError] = react.useState(null);
14592
- const [approveFailedFor, setApproveFailedFor] = react.useState(null);
14593
- const [quorumFailure, setQuorumFailure] = react.useState(null);
14594
- const [deviceNotLinked, setDeviceNotLinked] = react.useState(false);
14595
- react.useEffect(() => {
14596
- let cancelled = false;
14597
- inspectQuorum().then((q) => {
14598
- if (cancelled || q.ok) return;
14599
- if (q.code === "DEVICE_NOT_ENROLLED") setDeviceNotLinked(true);
14600
- else setQuorumFailure(q.reason);
14601
- }).catch(() => void 0);
14602
- return () => {
14603
- cancelled = true;
14604
- };
14605
- }, [inspectQuorum]);
14606
- const current = pending.find((r) => r.id === selectedId) ?? pending[0] ?? null;
14607
- const [history, setHistory] = react.useState([]);
14608
- const resolvedBeforeOpen = react.useRef(lastResolved?.id);
14609
- react.useEffect(() => {
14610
- if (!lastResolved || lastResolved.id === resolvedBeforeOpen.current) return;
14611
- setHistory((list) => [...list.filter((r) => r.id !== lastResolved.id), lastResolved]);
14612
- }, [lastResolved]);
14613
- const [askedToClose, setAskedToClose] = react.useState(false);
14614
- const confirmingClose = askedToClose && pending.length > 0;
14615
- const requestClose = () => pending.length > 0 ? setAskedToClose(true) : onClose();
14616
- const currentRef = react.useRef(current);
14617
- currentRef.current = current;
14618
- const currentId = current?.id ?? null;
14952
+ const copy = SESSIONS_COPY[language];
14953
+ const [revokingFamilyId, setRevokingFamilyId] = react.useState(null);
14954
+ const [signingOutEverywhere, setSigningOutEverywhere] = react.useState(false);
14955
+ const [revokeError, setRevokeError] = react.useState(null);
14956
+ const load = react.useCallback(() => {
14957
+ void getClient().fetchSessions();
14958
+ }, [getClient]);
14619
14959
  react.useEffect(() => {
14620
- const request = currentRef.current;
14621
- if (!request) return;
14622
- setVerification(null);
14623
- setError(null);
14624
- setApproveFailedFor(null);
14625
- let cancelled = false;
14626
- verify(request).then((v) => {
14627
- if (!cancelled) setVerification(v);
14628
- }).catch((err) => {
14629
- if (!cancelled) setVerification({ ok: false, reason: err instanceof Error ? err.message : String(err) });
14630
- });
14631
- return () => {
14632
- cancelled = true;
14633
- };
14634
- }, [currentId, verify]);
14960
+ load();
14961
+ }, [load]);
14635
14962
  const onCloseRef = react.useRef(onClose);
14636
14963
  onCloseRef.current = onClose;
14637
14964
  react.useEffect(() => {
@@ -14639,87 +14966,45 @@ function CosignModal({ nextStep = null, onClose }) {
14639
14966
  if (authState.step === "idle") onCloseRef.current();
14640
14967
  });
14641
14968
  }, [getClient]);
14642
- const silent = pending.length === 0 && (lastResolved ? lastResolved.status === "APPROVED" && !lastResolved.submit?.hash && !lastResolved.signedXdr : loaded);
14643
- const sent = pending.length === 0 && lastResolved?.status === "APPROVED" && !!lastResolved.submit?.hash;
14644
- const awaitingNext = sent && !!nextStep;
14645
- const closeAfter = awaitingNext ? null : sent ? CLOSE_AFTER_SENT_SECONDS : silent ? CLOSE_AFTER_SECONDS : null;
14646
- react.useEffect(() => {
14647
- if (!awaitingNext) return;
14648
- const timer = setInterval(() => void refresh().catch(() => void 0), NEXT_REQUEST_EVERY_MS);
14649
- return () => clearInterval(timer);
14650
- }, [awaitingNext, refresh]);
14651
- const [closesIn, setClosesIn] = react.useState(null);
14652
- react.useEffect(() => {
14653
- if (closeAfter === null) {
14654
- setClosesIn(null);
14655
- return;
14656
- }
14657
- let left = closeAfter;
14658
- setClosesIn(left);
14659
- const timer = setInterval(() => {
14660
- left -= 1;
14661
- if (left > 0) setClosesIn(left);
14662
- else {
14663
- clearInterval(timer);
14664
- onCloseRef.current();
14665
- }
14666
- }, 1e3);
14667
- return () => clearInterval(timer);
14668
- }, [closeAfter, lastResolved?.id]);
14669
- const run = react.useCallback(
14670
- async (kind, request, action) => {
14671
- setBusy(kind);
14672
- setError(null);
14969
+ const handleRevoke = react.useCallback(
14970
+ async (familyId) => {
14971
+ setRevokingFamilyId(familyId);
14972
+ setRevokeError(null);
14673
14973
  try {
14674
- await action(request);
14675
- } catch (err) {
14676
- if (core.isPollarNetworkError(err) || err instanceof TypeError) {
14677
- setError(COSIGN_COPY[language].unreachable);
14678
- void refresh().catch(() => void 0);
14679
- return;
14680
- }
14681
- setError(
14682
- core.transactionErrorMessage(core.isPollarApiError(err) ? err.code : null, err instanceof Error ? err.message : null, language)
14683
- );
14684
- if (kind === "approving" && !(core.isPollarApiError(err) && err.code === "SDK_COSIGN_GAS_PENDING"))
14685
- setApproveFailedFor(request.id);
14974
+ await getClient().revokeSession(familyId);
14975
+ } catch {
14976
+ setRevokeError(copy.revokeFailed);
14686
14977
  } finally {
14687
- setBusy(null);
14978
+ setRevokingFamilyId(null);
14979
+ load();
14688
14980
  }
14689
14981
  },
14690
- [language, refresh]
14982
+ [getClient, load, copy]
14691
14983
  );
14692
- return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, children: /* @__PURE__ */ jsxRuntime.jsx(
14693
- CosignModalTemplate,
14984
+ const handleLogoutEverywhere = react.useCallback(async () => {
14985
+ setSigningOutEverywhere(true);
14986
+ try {
14987
+ await getClient().logoutEverywhere();
14988
+ onClose();
14989
+ } catch {
14990
+ setSigningOutEverywhere(false);
14991
+ }
14992
+ }, [getClient, onClose]);
14993
+ return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
14994
+ SessionsModalTemplate,
14694
14995
  {
14695
14996
  theme,
14696
14997
  accentColor,
14697
14998
  styleOverrides,
14698
- pending,
14699
- current,
14700
- verification: current ? quorumFailure ? { ok: false, reason: quorumFailure } : verification : null,
14701
- busy,
14702
- error,
14703
- approveBlocked: !!current && approveFailedFor === current.id,
14704
- deviceNotLinked,
14705
- onLinkDevice: () => {
14706
- onClose();
14707
- openRecoveryModal();
14708
- },
14709
- ...lastResolved ? { lastResolved } : {},
14710
- closesIn,
14711
- nextStep: awaitingNext ? nextStep : null,
14712
- language,
14713
- network,
14714
- history,
14715
- explorerUrlOf: (r) => r.submit?.hash ? explorerTxUrl(r.network, r.submit.hash, network) : null,
14716
- onSelect: (r) => setSelectedId(r.id),
14717
- onApprove: (r) => void run("approving", r, approve),
14718
- onReject: (r) => void run("rejecting", r, reject),
14719
- onClose: requestClose,
14720
- confirmingClose,
14721
- onKeepOpen: () => setAskedToClose(false),
14722
- onCloseAnyway: onClose
14999
+ state: sessions,
15000
+ revokingFamilyId,
15001
+ signingOutEverywhere,
15002
+ revokeError,
15003
+ onRefresh: () => load(),
15004
+ onRevoke: (familyId) => void handleRevoke(familyId),
15005
+ onLogoutEverywhere: () => void handleLogoutEverywhere(),
15006
+ onClose,
15007
+ language
14723
15008
  }
14724
15009
  ) });
14725
15010
  }
@@ -15380,6 +15665,7 @@ function RecoveryModalTemplate(p) {
15380
15665
  );
15381
15666
  }
15382
15667
  var APPROVAL_POLL_MS = 3e3;
15668
+ var RELOAD_AFTER_FAILURE_MS = 5e3;
15383
15669
  var APPROVAL_WINDOW_MS = 15 * 6e4;
15384
15670
  function errorText3(err, language) {
15385
15671
  return core.cosignRefusalMessage(err, language) ?? core.transactionErrorMessage(core.isPollarApiError(err) ? err.code : null, err instanceof Error ? err.message : null, language);
@@ -15431,12 +15717,17 @@ function RecoveryModal({ onClose }) {
15431
15717
  setError(null);
15432
15718
  setNotice(null);
15433
15719
  try {
15434
- await action();
15435
- await load();
15720
+ try {
15721
+ await action();
15722
+ } catch (err) {
15723
+ setError(errorText3(err, language));
15724
+ return;
15725
+ }
15726
+ await load().catch(() => {
15727
+ setTimeout(() => void load().catch(() => void 0), RELOAD_AFTER_FAILURE_MS);
15728
+ });
15436
15729
  if (after?.notice) setNotice(after.notice);
15437
15730
  if (after?.view) setView(after.view);
15438
- } catch (err) {
15439
- setError(errorText3(err, language));
15440
15731
  } finally {
15441
15732
  setBusy(null);
15442
15733
  }
@@ -15460,10 +15751,10 @@ function RecoveryModal({ onClose }) {
15460
15751
  setNotice(copy.deviceAdded);
15461
15752
  return;
15462
15753
  }
15463
- const timer = setInterval(() => void load().catch(() => void 0), APPROVAL_POLL_MS);
15754
+ const stopPoll = core.startBackoffPoll(load, APPROVAL_POLL_MS);
15464
15755
  const stop = setTimeout(() => setAwaitingApproval(false), APPROVAL_WINDOW_MS);
15465
15756
  return () => {
15466
- clearInterval(timer);
15757
+ stopPoll();
15467
15758
  clearTimeout(stop);
15468
15759
  };
15469
15760
  }, [awaitingApproval, enrolled, load, copy]);
@@ -16672,12 +16963,17 @@ function PollarProvider({
16672
16963
  const [sessionsModalOpen, setSessionsModalOpen] = react.useState(false);
16673
16964
  const [cosignModalOpen, setCosignModalOpen] = react.useState(false);
16674
16965
  const [cosignNextStep, setCosignNextStep] = react.useState(null);
16966
+ const [cosignHosts, setCosignHosts] = react.useState(0);
16967
+ const registerCosignHost = react.useCallback(() => {
16968
+ setCosignHosts((n) => n + 1);
16969
+ return () => setCosignHosts((n) => n - 1);
16970
+ }, []);
16675
16971
  const [recoveryModalOpen, setRecoveryModalOpen] = react.useState(false);
16676
16972
  const cosignPendingCount = react.useRef(0);
16677
16973
  react.useEffect(() => {
16678
- if (cosign.pending.length > cosignPendingCount.current) setCosignModalOpen(true);
16974
+ if (cosign.pending.length > cosignPendingCount.current && cosignHosts === 0) setCosignModalOpen(true);
16679
16975
  cosignPendingCount.current = cosign.pending.length;
16680
- }, [cosign.pending.length]);
16976
+ }, [cosign.pending.length, cosignHosts]);
16681
16977
  react.useEffect(() => pollarClient.onCosignDeviceNotEnrolled(() => setRecoveryModalOpen(true)), [pollarClient]);
16682
16978
  react.useEffect(() => pollarClient.onWalletRecoveryRequired(() => setRecoveryModalOpen(true)), [pollarClient]);
16683
16979
  const [distributionRulesModalOpen, setDistributionRulesModalOpen] = react.useState(false);
@@ -16716,13 +17012,17 @@ function PollarProvider({
16716
17012
  return;
16717
17013
  }
16718
17014
  let cancelled = false;
17015
+ let retry = null;
16719
17016
  pollarClient.cosign.recovery.status().then((next) => {
16720
17017
  if (!cancelled) setRecovery(next);
16721
- }).catch(() => {
16722
- if (!cancelled) setRecovery(null);
17018
+ }).catch((err) => {
17019
+ if (cancelled) return;
17020
+ if (core.isTransientFailure(err)) retry = setTimeout(() => setRecoveryTick((t) => t + 1), 5e3 + Math.random() * 5e3);
17021
+ else setRecovery(null);
16723
17022
  });
16724
17023
  return () => {
16725
17024
  cancelled = true;
17025
+ if (retry) clearTimeout(retry);
16726
17026
  };
16727
17027
  }, [pollarClient, hasSession, walletAddress, recoveryTick]);
16728
17028
  const recoveryLocked = !!recovery && recovery.required && !recovery.configured;
@@ -16737,13 +17037,18 @@ function PollarProvider({
16737
17037
  return;
16738
17038
  }
16739
17039
  let cancelled = false;
17040
+ let retry = null;
16740
17041
  pollarClient.cosign.custodyMigration().then((next) => {
16741
17042
  if (!cancelled) setCustodyMigration(next);
16742
- }).catch(() => {
16743
- if (!cancelled) setCustodyMigration(null);
17043
+ }).catch((err) => {
17044
+ if (cancelled) return;
17045
+ if (core.isTransientFailure(err))
17046
+ retry = setTimeout(() => setCustodyMigrationTick((t) => t + 1), 5e3 + Math.random() * 5e3);
17047
+ else setCustodyMigration(null);
16744
17048
  });
16745
17049
  return () => {
16746
17050
  cancelled = true;
17051
+ if (retry) clearTimeout(retry);
16747
17052
  };
16748
17053
  }, [pollarClient, hasSession, walletAddress, custodyMigrationTick]);
16749
17054
  const refreshWalletBalance = react.useCallback(() => pollarClient.refreshBalance(), [pollarClient, walletAddress]);
@@ -16866,6 +17171,7 @@ function PollarProvider({
16866
17171
  refreshCustodyMigration,
16867
17172
  confirmations,
16868
17173
  registerConfirmationHost,
17174
+ registerCosignHost,
16869
17175
  // distribution
16870
17176
  openDistributionRulesModal: () => setDistributionRulesModalOpen(true),
16871
17177
  // network
@@ -16906,6 +17212,7 @@ function PollarProvider({
16906
17212
  cosign,
16907
17213
  confirmations,
16908
17214
  registerConfirmationHost,
17215
+ registerCosignHost,
16909
17216
  walletBalance,
16910
17217
  refreshWalletBalance,
16911
17218
  enabledAssets,
@@ -16955,7 +17262,7 @@ function PollarProvider({
16955
17262
  /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setCardModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(CardModal, { onClose: () => setCardModalOpen(false), initial: cardModalOptions }) }, `${cardModalKey}:${walletAddress}`),
16956
17263
  receiveModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setReceiveModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(ReceiveModal, { onClose: () => setReceiveModalOpen(false), initial: receiveSeed.options }) }, `receive:${receiveSeed.key}`),
16957
17264
  sessionsModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSessionsModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SessionsModal, { onClose: () => setSessionsModalOpen(false) }) }),
16958
- cosignModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setCosignModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(CosignModal, { nextStep: cosignNextStep, onClose: () => setCosignModalOpen(false) }) }),
17265
+ cosignModalOpen && cosignHosts === 0 && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setCosignModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(CosignModal, { nextStep: cosignNextStep, onClose: () => setCosignModalOpen(false) }) }),
16959
17266
  custodyMigration?.required && !custodyMigrationLater && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: refreshCustodyMigration, children: /* @__PURE__ */ jsxRuntime.jsx(
16960
17267
  CustodyMigrationModal,
16961
17268
  {