@dexterai/connect 0.29.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js CHANGED
@@ -1,28 +1,30 @@
1
1
  import {
2
- ConnectError,
3
- authoredPolicy,
4
2
  ceremonyPhaseLabel,
5
3
  connectDexterIdentity,
6
4
  createDexterControlModel,
7
5
  createDexterIdentityCoordinator,
6
+ disconnectDexterIdentity,
7
+ passkeySignalSupport,
8
+ prunePasskey,
9
+ renamePasskey
10
+ } from "./chunk-Z6YHGWG3.js";
11
+ import {
12
+ ConnectError,
13
+ authoredPolicy,
8
14
  createWallet,
9
15
  disconnectActiveWallet,
10
- disconnectDexterIdentity,
11
16
  ejectActiveWallet,
12
17
  forgetWallet,
13
18
  getActiveHandle,
14
19
  listWallets,
15
- passkeySignalSupport,
16
- prunePasskey,
17
20
  removeWalletFromDeviceRoster,
18
- renamePasskey,
19
21
  setActiveHandle,
20
22
  setActiveWallet,
21
23
  shouldUsePopup,
22
24
  subscribe,
23
25
  switchWallet,
24
26
  walletProofSessionStore
25
- } from "./chunk-XKOVUW5P.js";
27
+ } from "./chunk-4FTJB7FT.js";
26
28
  import {
27
29
  DexterButton,
28
30
  DexterMark,
@@ -286,11 +288,11 @@ function useDexterConnection(config) {
286
288
  clearAccountSession,
287
289
  passkey,
288
290
  apiBase,
289
- fetch
291
+ fetch: fetch2
290
292
  } = config;
291
293
  const dexterIdentity = useDexterIdentity({
292
294
  ...apiBase ? { apiBase } : {},
293
- ...fetch ? { fetch } : {},
295
+ ...fetch2 ? { fetch: fetch2 } : {},
294
296
  accountSession
295
297
  });
296
298
  const wallet = useDexterWallet();
@@ -394,7 +396,7 @@ function useDexterConnection(config) {
394
396
  const result = await connectDexterIdentity({
395
397
  ...passkey,
396
398
  ...apiBase ? { apiBase } : {},
397
- ...fetch ? { bindingFetch: fetch } : {},
399
+ ...fetch2 ? { bindingFetch: fetch2 } : {},
398
400
  installAccountSession: async (session) => {
399
401
  dexterIdentity.allowAccountSession(session.accessToken);
400
402
  await installAccountSession(session);
@@ -430,7 +432,7 @@ function useDexterConnection(config) {
430
432
  }, [
431
433
  dexterIdentity,
432
434
  apiBase,
433
- fetch,
435
+ fetch2,
434
436
  installAccountSession,
435
437
  clearAccountSession,
436
438
  passkey,
@@ -705,8 +707,11 @@ function CreateWalletPanel(props) {
705
707
  transport,
706
708
  showName = true,
707
709
  agentDelegation = "deferred",
708
- className
710
+ className,
711
+ terminology = "wallet",
712
+ withMark = true
709
713
  } = props;
714
+ const account = terminology === "account";
710
715
  useEffect5(ensureConsentStyles, []);
711
716
  useEffect5(ensureDexterButtonStyles, []);
712
717
  const nameInputId = useId2();
@@ -725,7 +730,7 @@ function CreateWalletPanel(props) {
725
730
  const ownerOnly = agentDelegation === "deferred";
726
731
  const policy = resolvedTransport === "inline" && !ownerOnly ? authoredPolicy(value ?? "") : null;
727
732
  const canContinue = hosted || ownerOnly || Boolean(policy);
728
- const statusText = running ? phase ? ceremonyPhaseLabel(phase) : "Starting your passkey\u2026" : resolvedTransport === "unknown" ? "Preparing wallet setup\u2026" : hosted ? "Wallet setup continues in Dexter Wallet." : ownerOnly ? "" : policy ? "Ready to create." : "Choose an agent allowance.";
733
+ const statusText = running ? phase ? ceremonyPhaseLabel(phase) : "Starting your passkey\u2026" : resolvedTransport === "unknown" ? account ? "Preparing account setup..." : "Preparing wallet setup\u2026" : hosted ? account ? "Account setup continues in Dexter." : "Wallet setup continues in Dexter Wallet." : ownerOnly ? "" : policy ? "Ready to create." : "Choose an agent allowance.";
729
734
  const handleCreate = async () => {
730
735
  if (running) return;
731
736
  if (resolvedTransport === "unknown" || !hosted && !ownerOnly && !policy) return;
@@ -734,7 +739,7 @@ function CreateWalletPanel(props) {
734
739
  setPhase(null);
735
740
  try {
736
741
  const result = await createWallet({
737
- name: hosted ? void 0 : name.trim() || "Dexter Wallet",
742
+ name: hosted ? void 0 : name.trim() || (account ? "Dexter account" : "Dexter Wallet"),
738
743
  spendPolicy: hosted ? void 0 : policy ?? void 0,
739
744
  agentDelegation,
740
745
  apiBase,
@@ -753,14 +758,14 @@ function CreateWalletPanel(props) {
753
758
  };
754
759
  return /* @__PURE__ */ jsxs2("div", { className: cx("dx-cwp", className), children: [
755
760
  !hosted && resolvedTransport === "inline" && showName && /* @__PURE__ */ jsxs2("div", { className: "dx-cwp__field", children: [
756
- /* @__PURE__ */ jsx2("label", { className: "dx-cwp__label", htmlFor: nameInputId, children: "Name your wallet" }),
761
+ /* @__PURE__ */ jsx2("label", { className: "dx-cwp__label", htmlFor: nameInputId, children: account ? "Account name" : "Name your wallet" }),
757
762
  /* @__PURE__ */ jsx2(
758
763
  "input",
759
764
  {
760
765
  id: nameInputId,
761
766
  className: "dx-cwp__name",
762
767
  maxLength: 40,
763
- placeholder: "Dexter Wallet",
768
+ placeholder: account ? "Dexter account" : "Dexter Wallet",
764
769
  value: name,
765
770
  disabled: running,
766
771
  autoComplete: "off",
@@ -768,7 +773,7 @@ function CreateWalletPanel(props) {
768
773
  }
769
774
  )
770
775
  ] }),
771
- hosted ? /* @__PURE__ */ jsx2("p", { className: "dx-cwp__hosted", children: ownerOnly ? "Finish setup in Dexter Wallet." : "Choose a name and agent allowance in Dexter Wallet." }) : resolvedTransport === "inline" ? !ownerOnly ? /* @__PURE__ */ jsxs2(Fragment, { children: [
776
+ hosted ? /* @__PURE__ */ jsx2("p", { className: "dx-cwp__hosted", children: account ? "Finish setup in Dexter." : ownerOnly ? "Finish setup in Dexter Wallet." : "Choose a name and agent allowance in Dexter Wallet." }) : resolvedTransport === "inline" ? !ownerOnly ? /* @__PURE__ */ jsxs2(Fragment, { children: [
772
777
  /* @__PURE__ */ jsxs2("div", { className: "dx-cwp__field", children: [
773
778
  /* @__PURE__ */ jsx2("span", { className: "dx-cwp__label", children: "What agents may spend automatically, per 30 days" }),
774
779
  /* @__PURE__ */ jsx2(AllowanceChips, { value, onChange: setValue, disabled: running })
@@ -781,20 +786,558 @@ function CreateWalletPanel(props) {
781
786
  DexterButton,
782
787
  {
783
788
  block: true,
789
+ withMark,
784
790
  className: "dx-cwp__cta",
785
791
  loading: running,
786
792
  loadingLabel: phase ? ceremonyPhaseLabel(phase) : "Creating\u2026",
787
793
  disabled: !canContinue || resolvedTransport === "unknown",
788
794
  onClick: handleCreate,
789
- children: error ? "Retry" : hosted ? "Continue to Dexter Wallet" : "Create your Dexter Wallet"
795
+ children: error ? "Retry" : hosted ? account ? "Continue to Dexter" : "Continue to Dexter Wallet" : account ? "Create account" : "Create your Dexter Wallet"
790
796
  }
791
797
  )
792
798
  ] });
793
799
  }
794
800
 
795
- // src/AppInstallButtons.tsx
796
- import { useEffect as useEffect6, useId as useId3, useState as useState6 } from "react";
801
+ // src/DexterAccountControl.tsx
802
+ import { AnimatePresence, motion, useReducedMotion } from "framer-motion";
803
+ import { useEffect as useEffect7, useId as useId5, useLayoutEffect, useRef as useRef4, useState as useState7 } from "react";
804
+
805
+ // src/accountBrand.tsx
806
+ import { useId as useId3 } from "react";
797
807
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
808
+ function AccountMark() {
809
+ const clipId = useId3();
810
+ return /* @__PURE__ */ jsx3("svg", { viewBox: "0 0 375 250", "aria-hidden": "true", children: /* @__PURE__ */ jsx3("g", { transform: "translate(-20,-34)", children: /* @__PURE__ */ jsxs3("g", { transform: "translate(12,15)", children: [
811
+ /* @__PURE__ */ jsx3("g", { opacity: "1.000", transform: "translate(20,150) scale(1.085000,1.038000) translate(-20,-150)", children: /* @__PURE__ */ jsx3("path", { d: "M 88,46 C 160,37 260,37 314,44 C 332,46 340,56 340,72 L 340,216 C 340,232 332,242 314,244 C 260,252 160,252 88,254 C 50,253 24,244 20,210 L 20,90 C 24,56 50,47 88,46 Z", fill: "#FDFAF5", fillOpacity: "1.000", stroke: "#F2681A", strokeWidth: "9", strokeLinejoin: "round" }) }),
812
+ /* @__PURE__ */ jsx3("path", { d: "M 88,46 C 160,37 260,37 314,44 C 332,46 340,56 340,72 L 340,216 C 340,232 332,242 314,244 C 260,252 160,252 88,254 C 50,253 24,244 20,210 L 20,90 C 24,56 50,47 88,46 Z", fill: "#FDFAF5", fillOpacity: "1.000", stroke: "#F2681A", strokeWidth: "9", strokeLinejoin: "round" }),
813
+ /* @__PURE__ */ jsx3("clipPath", { id: clipId, children: /* @__PURE__ */ jsx3("path", { d: "M 88,46 C 160,37 260,37 314,44 C 332,46 340,56 340,72 L 340,216 C 340,232 332,242 314,244 C 260,252 160,252 88,254 C 50,253 24,244 20,210 L 20,90 C 24,56 50,47 88,46 Z" }) }),
814
+ /* @__PURE__ */ jsx3("g", { clipPath: `url(#${clipId})`, opacity: "1.000", children: /* @__PURE__ */ jsx3("path", { fill: "#F2681A", transform: "translate(-13.30,8.4) scale(1.42)", d: "m142.92669,22.61505c0.86324,0.194 1.72648,0.38801 2.61589,0.58789c36.11824,8.20868 68.78991,24.97766 95.38402,50.74539c1.01664,0.98356 2.03328,1.9671 3.08073,2.98047c10.83948,10.66464 10.83948,10.66464 11.04686,14.61978c-2.0583,3.55128 -5.4353,4.17725 -9.16927,5.29556c-0.79453,0.24692 -1.58907,0.49385 -2.40767,0.74825c-28.1259,8.42762 -60.94703,6.3666 -87.13391,-7.16491c-0.85657,-0.48718 -1.71313,-0.97434 -2.59566,-1.47628c-7.37383,-4.05183 -12.58845,-3.35686 -20.59012,-1.54122c-22.76373,3.99921 -48.47173,1.53219 -68.68914,-9.74291c-4.87964,-3.88153 -8.23277,-8.29209 -10.20832,-14.21874c-0.93353,-10.37559 -0.67244,-18.43528 5.83333,-26.83331c19.57482,-23.38104 55.98802,-20.36071 82.83325,-13.99999z" }) }),
815
+ /* @__PURE__ */ jsx3("g", { opacity: "1.000", transform: "translate(240,208) scale(1.00000) translate(-240,-208)", children: /* @__PURE__ */ jsx3("path", { fill: "#F2681A", transform: "translate(96.5,-14.5)", d: "m172.67667,203.08363c7.27323,0.09365 13.23073,1.96539 18.86718,6.65365c2.87863,3.07269 3.85875,5.11784 4.24739,9.31509c-0.12031,1.01062 -0.24062,2.02125 -0.36458,3.0625c-2.55208,0.94792 -2.55208,0.94792 -5.83333,1.16667c-3.28125,-2.84375 -3.28125,-2.84375 -5.83333,-5.83333c-0.35643,0.579 -0.71286,1.15801 -1.08008,1.75456c-7.60197,11.28517 -20.05618,17.73584 -33.04945,21.09112c-20.36149,3.09912 -36.81163,-1.65702 -53.37039,-13.73111c-2.33333,-2.11458 -2.33333,-2.11458 -4.66666,-5.61458c0.41869,-3.45422 0.98768,-4.48767 3.5,-6.99999c4.07251,0.3672 5.9462,2.12995 8.74999,4.95833c9.81467,8.93246 22.53228,11.87016 35.51494,11.694c11.74161,-1.0497 22.38219,-5.85464 31.56832,-13.15233c2.05879,-2.45035 2.05879,-2.45035 3.5,-4.66666c-1.66031,0.07219 -1.66031,0.07219 -3.35416,0.14583c-3.64583,-0.14583 -3.64583,-0.14583 -5.97916,-2.47916c0.7534,-6.17789 1.46481,-7.18518 7.58333,-7.36458z" }) })
816
+ ] }) }) });
817
+ }
818
+ function AccountFace() {
819
+ return /* @__PURE__ */ jsx3("svg", { viewBox: "0 0 300 300", "aria-hidden": "true", children: /* @__PURE__ */ jsxs3("g", { children: [
820
+ /* @__PURE__ */ jsx3("path", { fill: "#f2671a", d: "M143.18,22.65c35.41,7.66,68.19,23.6,94.89,48.28,5.22,4.86,11.17,10.45,15.18,16.1,1.38,1.93,1.94,3.6.99,5.23-1.08,1.92-4.22,3.41-6.56,4.17-28.39,9.43-61.55,8.26-88.62-4.69-13.81-7.66-17.02-5.76-31.67-3.48-21.89,2.38-46.67.37-65.06-12.31-6.07-4.99-9.33-12.71-8.8-20.52-.16-9.4,4.25-18.12,11.47-24.06,21.29-17.85,52.64-14.45,78-8.77l.18.04h0Z" }),
821
+ /* @__PURE__ */ jsx3("path", { fill: "#f2671a", d: "M46.08,129.98c1.06-1.03,3.52-1.07,5.29-1.04,48.98-.05,98.1-.06,146.83-.1,17.53.14,35.01-.31,52.49.18,2.13.18,3.89.74,4.73,2.05,1.46,2.38.35,6.09-1.98,7.6-3.66,2.05-8.62,1.33-12.86,1.74-2.85.12-5.45.13-7.02,2.02-.91,1.07-1.28,2.56-1.56,3.95-.57,3.23-1.16,6.52-1.89,9.62-2.81,12.43-8.68,24.65-19.76,31.56-9.49,5.59-20.42,6.86-31.2,5.75-11.88-1.69-22.15-8.81-29.11-18.28-3.51-4.81-4.92-10.5-5.8-16.29-.47-2.56-.51-5.87-1.35-8-1.16-3.38-6.14-2.59-9.25-1.92-4.21.95-4.39,5.7-5.14,9.19-2.25,11.18-6.84,20.68-16.15,27.65-1.31,1.05-2.91,2.03-2.12,3.66,2.5,3.21,6.65,4.49,10.44,5.97,3.26,1.17,6.86,2.41,7.18,6.06.05,8.18-11.97,3.46-16.32,1.85-3.95-1.55-7.4-4.27-10.42-7.26-3.92-4.28-9.66-4.5-15.16-4.45-3.45-.07-6.99-.19-10.45-.82-21.29-4-31.08-21.3-30.9-42.01-.08-4.63.03-9.32.09-13.91.04-1.69.07-3.46,1.28-4.67l.1-.09h0Z" }),
822
+ /* @__PURE__ */ jsx3("path", { fill: "#f2671a", d: "M173.06,203.11c9.24-.06,21.6,4.49,22.85,14.84.3,2.12-.67,4.34-2.92,4.73-1.38.29-2.88-.05-4.09-.75-1.64-.9-2.97-2.86-4.19-3.05-1.33-.2-1.99.81-2.93,1.94-10.27,13.34-28.04,20.92-44.83,20.42-15.41-.33-31.89-5.95-43.53-17.34-3.15-3.39-1.55-9.88,3.61-9.19,1.83.32,3.29,1.45,4.76,2.65,10.49,10.12,24.85,14.04,39.12,13.03,10.55-1.23,20.38-5.47,28.74-11.92,1.11-1.06,4.45-3.63,3.5-5.12-.76-.85-4.31-.47-5.92-2.01-2.25-1.92-1.39-6.22,1.16-7.36,1.36-.65,2.96-.81,4.47-.86h.2,0Z" })
823
+ ] }) });
824
+ }
825
+
826
+ // src/accountControlStyles.ts
827
+ var ACCOUNT_CONTROL_CSS = ".dx-account-control,.dx-account-panel,.dx-account-panel *{box-sizing:border-box}\n.dx-account-control{position:relative;display:inline-block}\n.dx-account-trigger{display:grid;place-items:center;width:48px;height:48px;padding:0;background:transparent;border:0;border-radius:0;box-shadow:none;cursor:pointer;transition:opacity 160ms,transform 100ms}\n.dx-account-trigger>svg{display:block;width:40px;height:32px;object-fit:contain}\n.dx-account-trigger:hover{opacity:.75}\n.dx-account-trigger:active{transform:scale(.94)}\n.dx-account-trigger:focus-visible,.dx-account-panel a:focus-visible,.dx-account-panel button:focus-visible{outline:2px solid #22272a;outline-offset:3px}\n.dx-account-panel{position:absolute;right:0;top:calc(100% + 12px);width:min(376px,calc(100vw - 40px));max-height:calc(100dvh - 100px);overflow-y:auto;overscroll-behavior:contain;z-index:30;padding:24px;background:#fff;color:#22272a;border:1px solid #e4e7e8;border-radius:18px;box-shadow:0 20px 60px -16px #22272a30;transform-origin:top right;font-family:var(--dx-account-font,inherit)}\n.dx-account-panel a,.dx-account-panel button{font-family:inherit;font-weight:500;text-decoration:none;letter-spacing:0;cursor:pointer}\n.dx-account-panel button:disabled{cursor:wait;opacity:.55}\n.dx-account-identity{display:flex;align-items:center;gap:12px;margin-bottom:14px;min-width:0}\n.dx-account-identity>svg{width:32px;height:36px;object-fit:contain;flex-shrink:0}\n.dx-account-identity>div{min-width:0;flex:1}\n.dx-account-identity h3{margin:0;font-size:18px!important;line-height:1.3;font-weight:700;letter-spacing:-.025em;overflow-wrap:anywhere}\n.dx-account-identity p{margin:5px 0 0!important;font-size:13px!important;line-height:1.5;color:#596269;overflow-wrap:anywhere}\n.dx-account-primary{width:100%;min-height:48px;display:flex;align-items:center;justify-content:center;gap:10px;padding:12px 16px;font-size:15px;line-height:22px;text-align:center;color:#1c211e;background:#f2671a;border:1px solid #de5b13;border-radius:12px;box-shadow:inset 0 1px 0 #ffffff29,0 1px 2px #52220814;transition:background-color 160ms,transform 100ms}\n.dx-account-primary:hover{background:#fa782f}\n.dx-account-primary:active{transform:scale(.985)}\n.dx-account-create,.dx-account-back{width:100%;min-height:44px;padding:10px 4px;background:transparent;border:0;border-radius:8px;color:#424b51;font-size:14px}\n.dx-account-create{margin-top:6px}\n.dx-account-back{text-align:left;margin-bottom:12px}\n.dx-account-create:hover,.dx-account-back:hover{background:#f5f6f6}\n.dx-account-summary{margin-bottom:18px}\n.dx-account-balanceRow{display:flex;align-items:center;gap:4px;margin:22px 0 18px}\n.dx-account-balance{display:grid;gap:5px;min-width:0;flex:1}\n.dx-account-amount{display:block;width:100%;max-width:100%;overflow-x:auto;white-space:nowrap;font-size:clamp(18px,calc(460px / var(--amount-length)),44px);font-weight:700;line-height:1.1;letter-spacing:-.045em;font-variant-numeric:tabular-nums;color:#22272a}\n.dx-account-balanceLabel{font-size:12px;line-height:1.5;color:#596269}\n.dx-account-balanceState{font-size:18px;letter-spacing:-.02em;font-weight:500;line-height:1.5}\n.dx-account-refresh{display:grid;place-items:center;flex-shrink:0;width:40px;height:40px;margin-right:-8px;padding:0;background:transparent;border:0;border-radius:8px;color:#788086}\n.dx-account-refresh:hover{color:#22272a;background:#f5f6f6}\n.dx-account-moneyActions{display:grid;grid-template-columns:1fr 1fr;gap:12px}\n.dx-account-moneyActions a{display:flex;align-items:center;justify-content:center;gap:9px;min-height:44px;min-width:0;border:0;border-radius:8px;background:transparent;color:#22272a;font-size:14px;line-height:20px;font-weight:500;transition:transform 100ms}\n.dx-account-moneyActions svg{box-sizing:border-box;width:36px;height:36px;padding:9px;flex-shrink:0;background:#f2f4f4;color:#e95e13;border-radius:50%;transition:background-color 150ms,color 150ms}\n.dx-account-moneyActions a:hover svg{background:#e7ebeb;color:#d84f08}\n.dx-account-moneyActions a:active{transform:scale(.97)}\n.dx-account-destinations{display:grid;gap:2px;margin-top:8px}\n.dx-account-destinations a{display:flex;align-items:center;justify-content:flex-start;gap:12px;min-height:44px;margin:0 -10px;padding:10px;border-radius:8px;font-size:14px;line-height:1.4;color:#22272a;transition:background-color 140ms}\n.dx-account-destinations svg{flex-shrink:0;color:#596269}\n.dx-account-destinationHint{margin-left:auto;font-size:11px;font-weight:400;color:#596269}\n.dx-account-destinations a:hover,.dx-account-connectionActions>button:hover,.dx-account-connectionActions>a:hover,.dx-account-manage:hover{background:#f5f6f6}\n.dx-account-connection{margin-top:14px}\n.dx-account-accountFooter{display:flex;align-items:center;justify-content:space-between;gap:12px}\n.dx-account-accountLinks{display:flex;gap:4px;margin-left:-10px}\n.dx-account-accountLinks a{display:flex;align-items:center;min-height:40px;padding:10px;font-size:13px;color:#596269;border-radius:8px}\n.dx-account-accountLinks a:hover{background:#f5f6f6;color:#22272a}\n.dx-account-manage{display:grid;place-items:center;width:40px;height:40px;margin-right:-8px;padding:0;background:transparent;border:0;border-radius:8px;color:#596269}\n.dx-account-manage[aria-expanded=true]{color:#e95e13}\n.dx-account-connectionActions{display:grid;gap:2px;padding-top:6px}\n.dx-account-connectionActions>button,.dx-account-connectionActions>a{display:flex;align-items:center;min-height:44px;width:100%;padding:10px;background:transparent;border:0;font-size:14px;line-height:1.4;color:#424b51;text-align:left;border-radius:8px}\n.dx-account-explanation,.dx-account-status,.dx-account-error{margin:8px 0 16px!important;font-size:13px!important;line-height:1.55;color:#596269;text-align:left}\n.dx-account-error{color:#a9342c;margin-bottom:0!important}\n/* Setup remains the SDK component, styled to match the shared account panel. */\n.dx-account-creation{--dx-radius:12px;--dx-ember:#f2671a;--dx-fg:#22272a}\n.dx-account-creation .dx-cwp__label{font-size:13px;font-weight:500;text-transform:none;letter-spacing:0;opacity:1;color:#424b51}\n.dx-account-creation .dx-cwp__name{font-family:inherit;font-size:16px;background:#fff;color:#22272a;border-color:#d8dddf}\n.dx-account-creation .dx-btn{min-height:48px;padding:12px 14px;background:#f2671a;color:#1c211e;border:1px solid #de5b13;border-radius:12px;font-size:14px;font-weight:500;line-height:22px;text-transform:none;letter-spacing:0;box-shadow:inset 0 1px 0 #ffffff29,0 1px 2px #52220814;filter:none}\n.dx-account-creation .dx-btn:hover{background:#fa782f;box-shadow:inset 0 1px 0 #ffffff29,0 1px 2px #52220814;filter:none}\n.dx-account-creation .dx-cwp__hosted,.dx-account-creation .dx-cwp__status{font-size:13px;line-height:1.5;color:#596269;opacity:1}\n@media(max-width:360px){.dx-account-panel{padding:20px}.dx-account-identity{gap:10px}}\n@media(prefers-reduced-motion:reduce){.dx-account-trigger,.dx-account-panel,.dx-account-primary,.dx-account-moneyActions a,.dx-account-moneyActions svg{transition:none;transform:none}}\n.dx-account-balance{text-decoration:none}\n.dx-account-linkIcon{width:20px;height:20px;flex-shrink:0}\n";
828
+
829
+ // src/accountNavigation.tsx
830
+ import { jsx as jsx4 } from "react/jsx-runtime";
831
+ var DEFAULT_ACCOUNT_NAVIGATION = Object.freeze({
832
+ money: { href: "https://dexter.cash/wallet?section=money", label: "Money" },
833
+ send: { href: "https://dexter.cash/wallet/withdraw", label: "Send" },
834
+ receive: { href: "https://dexter.cash/wallet/deposit", label: "Receive" },
835
+ activity: { href: "https://dexter.cash/wallet?section=activity", label: "Activity" },
836
+ agents: { href: "https://dexter.cash/wallet?section=agents", label: "Apps and agents" },
837
+ profile: { href: "https://dexter.cash/profile", label: "Profile" },
838
+ support: { href: "https://dexter.cash/support", label: "Support" },
839
+ settings: { href: "https://dexter.cash/wallet?section=you", label: "Account settings" }
840
+ });
841
+ function AccountLink(props) {
842
+ return /* @__PURE__ */ jsx4("a", { ...props });
843
+ }
844
+ function resolveAccountNavigation(navigation, wallet) {
845
+ const links = { ...DEFAULT_ACCOUNT_NAVIGATION, ...navigation };
846
+ if (!wallet?.userHandle) return links;
847
+ for (const key of Object.keys(links)) {
848
+ const item = links[key];
849
+ if (!item || !item.href.startsWith("https://dexter.cash/")) continue;
850
+ const url = new URL(item.href);
851
+ if (url.origin !== "https://dexter.cash" || !(url.pathname === "/profile" || url.pathname === "/wallet" || url.pathname.startsWith("/wallet/"))) continue;
852
+ url.searchParams.set("dexter_account", wallet.userHandle);
853
+ links[key] = { ...item, href: url.toString() };
854
+ }
855
+ return links;
856
+ }
857
+
858
+ // src/DexterAccountSummary.tsx
859
+ import { useId as useId4 } from "react";
860
+ import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
861
+ function DexterAccountSummary({
862
+ amount,
863
+ loading,
864
+ partial = false,
865
+ refresh,
866
+ navigation,
867
+ LinkComponent = AccountLink,
868
+ onNavigate,
869
+ styleNonce
870
+ }) {
871
+ const id = useId4();
872
+ const links = { ...DEFAULT_ACCOUNT_NAVIGATION, ...navigation };
873
+ const content = /* @__PURE__ */ jsxs4(Fragment2, { children: [
874
+ /* @__PURE__ */ jsx5(
875
+ "span",
876
+ {
877
+ className: "dx-account-amount",
878
+ id: `${id}-amount`,
879
+ style: { "--amount-length": amount?.length ?? 6 },
880
+ children: amount ?? /* @__PURE__ */ jsx5("span", { className: "dx-account-balanceState", role: "status", children: loading ? "Loading balance..." : "Balance unavailable" })
881
+ }
882
+ ),
883
+ /* @__PURE__ */ jsx5("span", { id: `${id}-label`, className: "dx-account-balanceLabel", children: partial ? "Priced assets" : "Portfolio value" })
884
+ ] });
885
+ return /* @__PURE__ */ jsxs4("div", { className: "dx-account-summary", children: [
886
+ /* @__PURE__ */ jsx5("style", { nonce: styleNonce, children: ACCOUNT_CONTROL_CSS }),
887
+ /* @__PURE__ */ jsxs4("div", { className: "dx-account-balanceRow", children: [
888
+ links.money ? /* @__PURE__ */ jsx5(
889
+ LinkComponent,
890
+ {
891
+ href: links.money.href,
892
+ className: "dx-account-balance",
893
+ onClick: onNavigate,
894
+ "aria-label": links.money.label ?? "Money",
895
+ "aria-describedby": `${id}-amount ${id}-label`,
896
+ children: content
897
+ }
898
+ ) : /* @__PURE__ */ jsx5("div", { className: "dx-account-balance", children: content }),
899
+ !loading && /* @__PURE__ */ jsx5("button", { type: "button", className: "dx-account-refresh", "aria-label": "Refresh balance", onClick: () => void refresh(), children: /* @__PURE__ */ jsxs4("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
900
+ /* @__PURE__ */ jsx5("path", { d: "M20 7v5h-5M4 17v-5h5" }),
901
+ /* @__PURE__ */ jsx5("path", { d: "M6.2 7a7 7 0 0 1 11.6-1L20 9M4 15l2.2 3A7 7 0 0 0 17.8 17" })
902
+ ] }) })
903
+ ] }),
904
+ (links.send || links.receive) && /* @__PURE__ */ jsxs4("div", { className: "dx-account-moneyActions", children: [
905
+ links.send && /* @__PURE__ */ jsxs4(LinkComponent, { href: links.send.href, onClick: onNavigate, children: [
906
+ /* @__PURE__ */ jsx5("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx5("path", { d: "M12 19V5m-5 5 5-5 5 5" }) }),
907
+ links.send.label ?? "Send"
908
+ ] }),
909
+ links.receive && /* @__PURE__ */ jsxs4(LinkComponent, { href: links.receive.href, onClick: onNavigate, children: [
910
+ /* @__PURE__ */ jsx5("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx5("path", { d: "M12 5v14m-5-5 5 5 5-5" }) }),
911
+ links.receive.label ?? "Receive"
912
+ ] })
913
+ ] })
914
+ ] });
915
+ }
916
+
917
+ // src/useAccountPortfolio.ts
918
+ import { useCallback as useCallback3, useEffect as useEffect6, useRef as useRef3, useState as useState6 } from "react";
919
+
920
+ // src/accountPortfolio.ts
921
+ var PORTFOLIO_URL = "https://api.dexter.cash/api/passkey-vault-anon/portfolio";
922
+ var REQUEST_TIMEOUT_MS = 12e3;
923
+ var MAX_RESPONSE_BYTES = 256 * 1024;
924
+ var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
925
+ function record(value) {
926
+ return value !== null && typeof value === "object" && !Array.isArray(value);
927
+ }
928
+ function decimal(value) {
929
+ return typeof value === "string" && value.length <= 384 && /^(0|[1-9][0-9]*)(?:\.[0-9]+)?$/.test(value) && (!value.includes(".") || !value.endsWith("0"));
930
+ }
931
+ function count(value) {
932
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
933
+ }
934
+ function publicKey(value) {
935
+ if (typeof value !== "string" || value.length < 32 || value.length > 44) return false;
936
+ let decoded = 0n;
937
+ for (const char of value) {
938
+ const digit = BASE58_ALPHABET.indexOf(char);
939
+ if (digit < 0) return false;
940
+ decoded = decoded * 58n + BigInt(digit);
941
+ }
942
+ const leadingZeroes = value.match(/^1*/)?.[0].length ?? 0;
943
+ const payloadBytes = decoded === 0n ? 0 : Math.ceil(decoded.toString(16).length / 2);
944
+ return leadingZeroes + payloadBytes === 32;
945
+ }
946
+ function observedAt(value) {
947
+ return typeof value === "string" && value.length <= 40 && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?Z$/.test(value) && Number.isFinite(Date.parse(value));
948
+ }
949
+ function unavailable() {
950
+ return new Error("Account portfolio is unavailable.");
951
+ }
952
+ function roundUsd(value, places) {
953
+ const [whole, fraction = ""] = value.split(".");
954
+ const scale = 10n ** BigInt(places);
955
+ const kept = fraction.slice(0, places).padEnd(places, "0");
956
+ const units = BigInt(whole) * scale + BigInt(kept) + ((fraction[places] ?? "0") >= "5" ? 1n : 0n);
957
+ return `${units / scale}.${(units % scale).toString().padStart(places, "0")}`;
958
+ }
959
+ function formatUsd(value) {
960
+ const [whole, fraction = ""] = value.split(".");
961
+ const firstNonZero = fraction.search(/[1-9]/);
962
+ if (whole === "0" && firstNonZero >= 2) {
963
+ const rounded = roundUsd(value, firstNonZero + 2);
964
+ if (rounded.split(".")[1].search(/[1-9]/) >= 2) {
965
+ return `$${rounded.replace(/0+$/, "")}`;
966
+ }
967
+ }
968
+ const [roundedWhole, cents] = roundUsd(value, 2).split(".");
969
+ return `$${roundedWhole.replace(/\B(?=(\d{3})+(?!\d))/g, ",")}.${cents}`;
970
+ }
971
+ function parsePortfolio(body, wallet) {
972
+ if (!record(body) || body.ok !== true || !record(body.portfolio)) throw unavailable();
973
+ const p = body.portfolio;
974
+ if (p.schemaVersion !== 1 || p.network !== "solana-mainnet" || !publicKey(p.walletAddress) || !publicKey(p.vaultPda) || !observedAt(p.observedAt) || typeof p.holdingsComplete !== "boolean" || !count(p.pricedHoldings) || !count(p.unpricedHoldings) || !count(p.omittedHoldings) || !decimal(p.pricedValueUsd) || !(p.portfolioValueUsd === null || decimal(p.portfolioValueUsd))) throw unavailable();
975
+ if (wallet.vaultPda && p.vaultPda !== wallet.vaultPda || wallet.receiveAddress && p.walletAddress !== wallet.receiveAddress) throw unavailable();
976
+ const complete = p.holdingsComplete && p.unpricedHoldings === 0 && p.omittedHoldings === 0 && p.portfolioValueUsd !== null;
977
+ if (p.pricedHoldings === 0 && p.pricedValueUsd !== "0" || complete && p.portfolioValueUsd !== p.pricedValueUsd) throw unavailable();
978
+ const value = complete ? p.portfolioValueUsd : p.pricedHoldings > 0 ? p.pricedValueUsd : null;
979
+ return { amount: value === null ? null : formatUsd(value), partial: !complete };
980
+ }
981
+ async function readBody(response) {
982
+ const declaredSize = response.headers.get("content-length");
983
+ if (declaredSize && Number(declaredSize) > MAX_RESPONSE_BYTES) throw unavailable();
984
+ if (!response.body) throw unavailable();
985
+ const reader = response.body.getReader();
986
+ const decoder = new TextDecoder();
987
+ let bytes = 0;
988
+ let text = "";
989
+ try {
990
+ while (true) {
991
+ const { value, done } = await reader.read();
992
+ if (done) break;
993
+ bytes += value.byteLength;
994
+ if (bytes > MAX_RESPONSE_BYTES) throw unavailable();
995
+ text += decoder.decode(value, { stream: true });
996
+ }
997
+ text += decoder.decode();
998
+ return JSON.parse(text);
999
+ } finally {
1000
+ await reader.cancel().catch(() => void 0);
1001
+ reader.releaseLock();
1002
+ }
1003
+ }
1004
+ async function fetchAccountPortfolio(wallet, options = {}) {
1005
+ if (!/^[A-Za-z0-9_-]{22}$/.test(wallet.userHandle) || !wallet.vaultPda || !publicKey(wallet.vaultPda) || wallet.receiveAddress !== null && !publicKey(wallet.receiveAddress) || wallet.network !== null && wallet.network !== "solana-mainnet") throw unavailable();
1006
+ if (options.signal?.aborted) throw new DOMException("Aborted", "AbortError");
1007
+ const controller = new AbortController();
1008
+ let rejectBoundary;
1009
+ const boundary = new Promise((_, reject) => {
1010
+ rejectBoundary = reject;
1011
+ });
1012
+ const abort = () => {
1013
+ controller.abort();
1014
+ rejectBoundary(new DOMException("Aborted", "AbortError"));
1015
+ };
1016
+ options.signal?.addEventListener("abort", abort, { once: true });
1017
+ const timeout = setTimeout(() => {
1018
+ controller.abort();
1019
+ rejectBoundary(new DOMException("Timed out", "TimeoutError"));
1020
+ }, REQUEST_TIMEOUT_MS);
1021
+ try {
1022
+ const response = await Promise.race([
1023
+ (options.fetch ?? fetch)(`${PORTFOLIO_URL}?user_handle=${encodeURIComponent(wallet.userHandle)}`, {
1024
+ cache: "no-store",
1025
+ credentials: "omit",
1026
+ signal: controller.signal
1027
+ }),
1028
+ boundary
1029
+ ]);
1030
+ if (!response.ok) throw unavailable();
1031
+ const body = await Promise.race([readBody(response), boundary]);
1032
+ return parsePortfolio(body, wallet);
1033
+ } finally {
1034
+ clearTimeout(timeout);
1035
+ options.signal?.removeEventListener("abort", abort);
1036
+ controller.abort();
1037
+ }
1038
+ }
1039
+
1040
+ // src/useAccountPortfolio.ts
1041
+ function useAccountPortfolio(wallet) {
1042
+ const key = wallet === null ? null : JSON.stringify([
1043
+ wallet.userHandle,
1044
+ wallet.vaultPda,
1045
+ wallet.receiveAddress,
1046
+ wallet.network
1047
+ ]);
1048
+ const currentKey = useRef3(key);
1049
+ const currentWallet = useRef3(wallet);
1050
+ currentKey.current = key;
1051
+ currentWallet.current = wallet;
1052
+ const generation = useRef3(0);
1053
+ const inFlight = useRef3(null);
1054
+ const [state, setState] = useState6({
1055
+ key,
1056
+ amount: null,
1057
+ partial: false,
1058
+ loading: key !== null
1059
+ });
1060
+ const refresh = useCallback3(() => {
1061
+ if (currentKey.current !== key) return Promise.resolve();
1062
+ const selectedWallet = currentWallet.current;
1063
+ if (key === null || selectedWallet === null) return Promise.resolve();
1064
+ if (inFlight.current?.key === key) return inFlight.current.promise;
1065
+ inFlight.current?.controller.abort();
1066
+ const request = ++generation.current;
1067
+ const controller = new AbortController();
1068
+ setState({ key, amount: null, partial: false, loading: true });
1069
+ const promise = (async () => {
1070
+ try {
1071
+ const portfolio = await fetchAccountPortfolio(selectedWallet, { signal: controller.signal });
1072
+ if (!controller.signal.aborted && currentKey.current === key && generation.current === request) {
1073
+ setState({ key, ...portfolio, loading: false });
1074
+ }
1075
+ } catch {
1076
+ if (!controller.signal.aborted && currentKey.current === key && generation.current === request) {
1077
+ setState({ key, amount: null, partial: false, loading: false });
1078
+ }
1079
+ } finally {
1080
+ if (inFlight.current?.controller === controller) inFlight.current = null;
1081
+ }
1082
+ })();
1083
+ inFlight.current = { key, controller, promise };
1084
+ return promise;
1085
+ }, [key]);
1086
+ useEffect6(() => {
1087
+ void refresh();
1088
+ return () => {
1089
+ generation.current += 1;
1090
+ inFlight.current?.controller.abort();
1091
+ inFlight.current = null;
1092
+ };
1093
+ }, [refresh]);
1094
+ const visible = state.key === key && key !== null ? state : { amount: null, partial: false, loading: key !== null };
1095
+ return { amount: visible.amount, partial: visible.partial, loading: visible.loading, refresh };
1096
+ }
1097
+
1098
+ // src/DexterAccountControl.tsx
1099
+ import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
1100
+ function DexterAccountControl({
1101
+ connection: dexter,
1102
+ open: controlledOpen,
1103
+ onOpenChange,
1104
+ profile,
1105
+ navigation,
1106
+ items = [],
1107
+ LinkComponent = AccountLink,
1108
+ renderSummary,
1109
+ formatError = accountConnectionError,
1110
+ className = "",
1111
+ triggerClassName = "",
1112
+ styleNonce
1113
+ }) {
1114
+ const [ownOpen, setOwnOpen] = useState7(false);
1115
+ const open = controlledOpen ?? ownOpen;
1116
+ const setOpen = (next) => {
1117
+ if (controlledOpen === void 0) setOwnOpen(next);
1118
+ onOpenChange?.(next);
1119
+ };
1120
+ const [ready, setReady] = useState7(false);
1121
+ const [pending, setPending] = useState7(null);
1122
+ const [error, setError] = useState7("");
1123
+ const [createOpen, setCreateOpen] = useState7(false);
1124
+ const [manageOpen, setManageOpen] = useState7(false);
1125
+ const [panelShift, setPanelShift] = useState7(0);
1126
+ const pendingAction = useRef4(false);
1127
+ const control = useRef4(null);
1128
+ const trigger = useRef4(null);
1129
+ const panel = useRef4(null);
1130
+ const isOpen = useRef4(open);
1131
+ isOpen.current = open;
1132
+ const changeOpen = useRef4(setOpen);
1133
+ changeOpen.current = setOpen;
1134
+ const reduced = useReducedMotion();
1135
+ const id = useId5();
1136
+ const permissions = dexter.model.permissions;
1137
+ const checking = !ready || dexter.model.stage === "checking";
1138
+ const busy = checking || pending !== null || dexter.operation !== "idle";
1139
+ const hasIdentity = ready && (dexter.identity.hasWallet || dexter.identity.hasAccount);
1140
+ const email = permissions.accountContentVisible ? profile?.email?.trim() ?? "" : "";
1141
+ const name = permissions.accountContentVisible ? profile?.name?.trim() ?? "" : "";
1142
+ const title = permissions.walletIdentityVisible ? dexter.identity.walletLabel?.trim() || "Your Dexter account" : name || email.split("@")[0] || "Your Dexter account";
1143
+ const canCreate = !checking && dexter.model.stage === "connect";
1144
+ const canOpenWallet = dexter.model.stage === "ready" && permissions.walletDataVisible;
1145
+ const needsConnection = ["connect", "repair", "offline", "error"].includes(dexter.model.stage);
1146
+ const links = resolveAccountNavigation(navigation, dexter.activeWallet);
1147
+ const close = () => changeOpen.current(false);
1148
+ useEffect7(() => setReady(true), []);
1149
+ useLayoutEffect(() => {
1150
+ if (!open) return;
1151
+ const position = () => {
1152
+ if (!control.current || !panel.current) return;
1153
+ const width = panel.current.offsetWidth;
1154
+ const normalLeft = control.current.getBoundingClientRect().right - width;
1155
+ const left = Math.max(16, Math.min(normalLeft, window.innerWidth - width - 16));
1156
+ setPanelShift(left - normalLeft);
1157
+ };
1158
+ position();
1159
+ window.addEventListener("resize", position);
1160
+ return () => window.removeEventListener("resize", position);
1161
+ }, [open]);
1162
+ useEffect7(() => {
1163
+ if (!open) {
1164
+ setError("");
1165
+ setCreateOpen(false);
1166
+ setManageOpen(false);
1167
+ return;
1168
+ }
1169
+ const outside = (event) => {
1170
+ if (event.target instanceof Node && !control.current?.contains(event.target)) changeOpen.current(false);
1171
+ };
1172
+ const key = (event) => {
1173
+ if (event.key !== "Escape") return;
1174
+ changeOpen.current(false);
1175
+ trigger.current?.focus();
1176
+ };
1177
+ const focus = (event) => {
1178
+ if (event.target instanceof Node && !control.current?.contains(event.target)) changeOpen.current(false);
1179
+ };
1180
+ window.addEventListener("pointerdown", outside);
1181
+ window.addEventListener("keydown", key);
1182
+ window.addEventListener("focusin", focus);
1183
+ return () => {
1184
+ window.removeEventListener("pointerdown", outside);
1185
+ window.removeEventListener("keydown", key);
1186
+ window.removeEventListener("focusin", focus);
1187
+ };
1188
+ }, [open]);
1189
+ const run = async (action) => {
1190
+ if (busy || pendingAction.current) return;
1191
+ pendingAction.current = true;
1192
+ setPending(action);
1193
+ setError("");
1194
+ try {
1195
+ if (action === "connect") await dexter.connect();
1196
+ if (action === "switch") await dexter.useAnotherDexterWallet();
1197
+ if (action === "retry") await dexter.retry();
1198
+ if (action === "disconnect") {
1199
+ await dexter.disconnectDexter();
1200
+ close();
1201
+ }
1202
+ } catch (caught) {
1203
+ setError(action === "disconnect" ? "Dexter could not finish that action. Try again." : formatError(caught instanceof ConnectError ? caught.code : dexter.error?.code));
1204
+ } finally {
1205
+ pendingAction.current = false;
1206
+ setPending(null);
1207
+ }
1208
+ };
1209
+ return /* @__PURE__ */ jsxs5("div", { className: `dx-account-control ${className}`, ref: control, children: [
1210
+ /* @__PURE__ */ jsx6("style", { nonce: styleNonce, children: ACCOUNT_CONTROL_CSS }),
1211
+ /* @__PURE__ */ jsx6(
1212
+ "button",
1213
+ {
1214
+ className: `dx-account-trigger ${triggerClassName}`,
1215
+ ref: trigger,
1216
+ type: "button",
1217
+ "aria-label": open ? "Close Dexter account" : "Open Dexter account",
1218
+ "aria-expanded": open,
1219
+ "aria-controls": `${id}-menu`,
1220
+ "aria-haspopup": "dialog",
1221
+ onClick: () => setOpen(!open),
1222
+ children: /* @__PURE__ */ jsx6(AccountMark, {})
1223
+ }
1224
+ ),
1225
+ /* @__PURE__ */ jsx6(AnimatePresence, { children: open && /* @__PURE__ */ jsxs5(
1226
+ motion.section,
1227
+ {
1228
+ id: `${id}-menu`,
1229
+ role: "dialog",
1230
+ "aria-labelledby": `${id}-title`,
1231
+ className: "dx-account-panel",
1232
+ ref: panel,
1233
+ style: { right: -panelShift },
1234
+ initial: { opacity: 0, y: reduced ? 0 : -6, scale: reduced ? 1 : 0.985 },
1235
+ animate: { opacity: 1, y: 0, scale: 1 },
1236
+ exit: { opacity: 0, y: reduced ? 0 : -4 },
1237
+ transition: { duration: reduced ? 0 : 0.2, ease: [0.25, 0.65, 0.3, 1] },
1238
+ onAnimationComplete: () => {
1239
+ if (isOpen.current && document.activeElement === trigger.current) panel.current?.querySelector("button:not(:disabled), a[href]")?.focus();
1240
+ },
1241
+ children: [
1242
+ /* @__PURE__ */ jsxs5("div", { className: "dx-account-identity", children: [
1243
+ /* @__PURE__ */ jsx6(AccountFace, {}),
1244
+ /* @__PURE__ */ jsxs5("div", { children: [
1245
+ /* @__PURE__ */ jsx6("h3", { id: `${id}-title`, children: title }),
1246
+ (checking || email) && /* @__PURE__ */ jsx6("p", { children: checking ? "Opening your account..." : email })
1247
+ ] })
1248
+ ] }),
1249
+ checking ? /* @__PURE__ */ jsx6("p", { className: "dx-account-status", role: "status", children: "Checking your connection..." }) : /* @__PURE__ */ jsx6(Fragment3, { children: canCreate && createOpen ? /* @__PURE__ */ jsxs5("div", { className: "dx-account-creation", children: [
1250
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "dx-account-back", onClick: () => setCreateOpen(false), children: "Back to sign in" }),
1251
+ /* @__PURE__ */ jsx6(CreateWalletPanel, { agentDelegation: "deferred", terminology: "account", withMark: false, onCreated: () => setCreateOpen(false) })
1252
+ ] }) : /* @__PURE__ */ jsxs5(Fragment3, { children: [
1253
+ needsConnection && /* @__PURE__ */ jsxs5("div", { className: "dx-account-entry", children: [
1254
+ dexter.model.stage === "repair" && /* @__PURE__ */ jsx6("p", { className: "dx-account-explanation", children: "Reconnect your passkey to continue." }),
1255
+ /* @__PURE__ */ jsx6(
1256
+ "button",
1257
+ {
1258
+ type: "button",
1259
+ className: "dx-account-primary",
1260
+ disabled: busy,
1261
+ onClick: () => void run(dexter.model.primaryAction === "retry" ? "retry" : "connect"),
1262
+ children: busy ? "Opening passkey..." : dexter.model.stage === "repair" ? "Reconnect Dexter" : dexter.model.stage === "error" || dexter.model.stage === "offline" ? "Try again" : "Sign in with Dexter"
1263
+ }
1264
+ ),
1265
+ canCreate && /* @__PURE__ */ jsx6("button", { type: "button", className: "dx-account-create", onClick: () => setCreateOpen(true), disabled: busy, children: "Create account" })
1266
+ ] }),
1267
+ canOpenWallet && /* @__PURE__ */ jsx6("div", { children: renderSummary ? renderSummary(close) : /* @__PURE__ */ jsx6(DefaultSummary, { connection: dexter, navigation: links, LinkComponent, onNavigate: close, styleNonce }) }, `${dexter.activeWallet?.userHandle ?? "account"}:${dexter.activeWallet?.vaultPda ?? ""}`),
1268
+ (canOpenWallet || permissions.accountContentVisible) && /* @__PURE__ */ jsxs5("nav", { className: "dx-account-destinations", "aria-label": "Your account", children: [
1269
+ canOpenWallet && ["activity", "agents"].map((key) => {
1270
+ const item = links[key];
1271
+ return item && /* @__PURE__ */ jsxs5(LinkComponent, { href: item.href, onClick: close, children: [
1272
+ /* @__PURE__ */ jsx6(AccountIcon, { kind: key }),
1273
+ /* @__PURE__ */ jsx6("span", { children: item.label ?? (key === "activity" ? "Activity" : "Apps and agents") })
1274
+ ] }, key);
1275
+ }),
1276
+ items.filter((item) => item.requires === "wallet" ? canOpenWallet : permissions.accountContentVisible).map((item) => /* @__PURE__ */ jsxs5(LinkComponent, { href: item.href, onClick: close, children: [
1277
+ item.icon,
1278
+ /* @__PURE__ */ jsx6("span", { children: item.label }),
1279
+ item.hint && /* @__PURE__ */ jsx6("span", { className: "dx-account-destinationHint", children: item.hint })
1280
+ ] }, item.id))
1281
+ ] }),
1282
+ hasIdentity && /* @__PURE__ */ jsxs5("div", { className: "dx-account-connection", children: [
1283
+ /* @__PURE__ */ jsxs5("div", { className: "dx-account-accountFooter", children: [
1284
+ /* @__PURE__ */ jsxs5("div", { className: "dx-account-accountLinks", children: [
1285
+ permissions.accountContentVisible && links.profile && /* @__PURE__ */ jsx6(LinkComponent, { href: links.profile.href, onClick: close, children: links.profile.label ?? "Profile" }),
1286
+ links.support && /* @__PURE__ */ jsx6(LinkComponent, { href: links.support.href, onClick: close, children: links.support.label ?? "Support" })
1287
+ ] }),
1288
+ /* @__PURE__ */ jsx6("button", { className: "dx-account-manage", type: "button", "aria-label": "Account settings", "aria-controls": `${id}-settings`, "aria-expanded": manageOpen, onClick: () => setManageOpen(!manageOpen), children: /* @__PURE__ */ jsx6(AccountIcon, { kind: "settings" }) })
1289
+ ] }),
1290
+ manageOpen && /* @__PURE__ */ jsxs5(
1291
+ motion.div,
1292
+ {
1293
+ id: `${id}-settings`,
1294
+ className: "dx-account-connectionActions",
1295
+ initial: reduced ? false : { opacity: 0, y: -4 },
1296
+ animate: { opacity: 1, y: 0 },
1297
+ transition: { duration: reduced ? 0 : 0.16 },
1298
+ children: [
1299
+ canOpenWallet && links.settings && /* @__PURE__ */ jsx6(LinkComponent, { href: links.settings.href, onClick: close, children: links.settings.label ?? "Account settings" }),
1300
+ dexter.model.stage === "ready" && /* @__PURE__ */ jsx6("button", { type: "button", onClick: () => void run("switch"), disabled: busy, children: "Switch account" }),
1301
+ /* @__PURE__ */ jsx6("button", { type: "button", onClick: () => void run("disconnect"), disabled: busy, children: pending === "disconnect" ? "Disconnecting..." : "Disconnect Dexter" })
1302
+ ]
1303
+ }
1304
+ )
1305
+ ] })
1306
+ ] }) }),
1307
+ error && /* @__PURE__ */ jsx6("p", { className: "dx-account-error", role: "alert", children: error })
1308
+ ]
1309
+ }
1310
+ ) })
1311
+ ] });
1312
+ }
1313
+ function DefaultSummary({ connection, ...props }) {
1314
+ const balance = useAccountPortfolio(connection.activeWallet);
1315
+ return /* @__PURE__ */ jsx6(DexterAccountSummary, { ...balance, ...props });
1316
+ }
1317
+ function AccountIcon({ kind }) {
1318
+ return /* @__PURE__ */ jsx6("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: kind === "activity" ? /* @__PURE__ */ jsxs5(Fragment3, { children: [
1319
+ /* @__PURE__ */ jsx6("circle", { cx: "12", cy: "12", r: "8.5" }),
1320
+ /* @__PURE__ */ jsx6("path", { d: "M12 7v5l3 2" })
1321
+ ] }) : kind === "agents" ? /* @__PURE__ */ jsxs5(Fragment3, { children: [
1322
+ /* @__PURE__ */ jsx6("rect", { x: "3", y: "3", width: "7", height: "7", rx: "2" }),
1323
+ /* @__PURE__ */ jsx6("rect", { x: "14", y: "14", width: "7", height: "7", rx: "2" }),
1324
+ /* @__PURE__ */ jsx6("path", { d: "M14 6h4v5M6 14v4h5" })
1325
+ ] }) : /* @__PURE__ */ jsxs5(Fragment3, { children: [
1326
+ /* @__PURE__ */ jsx6("path", { d: "m10 3-.7 2.2-2 .9-2.1-.5-2 3.5 1.5 1.6v2.6l-1.5 1.6 2 3.5 2.1-.5 2 .9L10 21h4l.7-2.2 2-.9 2.1.5 2-3.5-1.5-1.6v-2.6l1.5-1.6-2-3.5-2.1.5-2-.9L14 3z" }),
1327
+ /* @__PURE__ */ jsx6("circle", { cx: "12", cy: "12", r: "3" })
1328
+ ] }) });
1329
+ }
1330
+ function accountConnectionError(code) {
1331
+ if (code === "credential_not_found") return "No Dexter account found for this passkey on this device.";
1332
+ if (code === "vault_not_found") return "This passkey is not linked to a Dexter account yet.";
1333
+ if (code === "verification_failed") return "Passkey verification failed. Try again.";
1334
+ if (code === "missing_credential") return "No passkey was selected.";
1335
+ return "Something went wrong signing in with your passkey.";
1336
+ }
1337
+
1338
+ // src/AppInstallButtons.tsx
1339
+ import { useEffect as useEffect8, useId as useId6, useState as useState8 } from "react";
1340
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
798
1341
  var STYLE_ID2 = "dexter-connect-appinstall-styles";
799
1342
  var APPINSTALL_CSS = `
800
1343
  .dx-appinstall{ display:flex; flex-wrap:wrap; gap:10px; }
@@ -919,7 +1462,7 @@ async function copyText(text) {
919
1462
  }
920
1463
  }
921
1464
  function useCopyStatus() {
922
- const [status, setStatus] = useState6("idle");
1465
+ const [status, setStatus] = useState8("idle");
923
1466
  return [status, (next) => setStatus(next)];
924
1467
  }
925
1468
  function appCx(block) {
@@ -935,8 +1478,8 @@ function AppInstallButtons(props) {
935
1478
  className,
936
1479
  onAction
937
1480
  } = props;
938
- useEffect6(ensureAppInstallStyles, []);
939
- const statusId = useId3();
1481
+ useEffect8(ensureAppInstallStyles, []);
1482
+ const statusId = useId6();
940
1483
  const hermesCommand = hermesInstallCommand(serverName, mcpUrl);
941
1484
  const claudeCommand = claudeCodeInstallCommand(serverName, mcpUrl);
942
1485
  const [hermesStatus, markHermes] = useCopyStatus();
@@ -944,7 +1487,7 @@ function AppInstallButtons(props) {
944
1487
  const hermesErrorId = `${statusId}-hermes-error`;
945
1488
  const claudeErrorId = `${statusId}-claude-error`;
946
1489
  const buttons = {
947
- claude: /* @__PURE__ */ jsxs3(
1490
+ claude: /* @__PURE__ */ jsxs6(
948
1491
  "a",
949
1492
  {
950
1493
  className: appCx(block),
@@ -953,13 +1496,13 @@ function AppInstallButtons(props) {
953
1496
  rel: "noopener noreferrer",
954
1497
  onClick: () => onAction?.("claude", "deeplink"),
955
1498
  children: [
956
- /* @__PURE__ */ jsx3("img", { className: "dx-appbtn__logo", src: CLAUDE_MARK, alt: "", "aria-hidden": true }),
1499
+ /* @__PURE__ */ jsx7("img", { className: "dx-appbtn__logo", src: CLAUDE_MARK, alt: "", "aria-hidden": true }),
957
1500
  "Open in Claude"
958
1501
  ]
959
1502
  },
960
1503
  "claude"
961
1504
  ),
962
- chatgpt: /* @__PURE__ */ jsxs3(
1505
+ chatgpt: /* @__PURE__ */ jsxs6(
963
1506
  "a",
964
1507
  {
965
1508
  className: appCx(block),
@@ -968,39 +1511,39 @@ function AppInstallButtons(props) {
968
1511
  rel: "noopener noreferrer",
969
1512
  onClick: () => onAction?.("chatgpt", "deeplink"),
970
1513
  children: [
971
- /* @__PURE__ */ jsx3("img", { className: "dx-appbtn__logo", src: CHATGPT_MARK, alt: "", "aria-hidden": true }),
1514
+ /* @__PURE__ */ jsx7("img", { className: "dx-appbtn__logo", src: CHATGPT_MARK, alt: "", "aria-hidden": true }),
972
1515
  "Open ChatGPT plugins"
973
1516
  ]
974
1517
  },
975
1518
  "chatgpt"
976
1519
  ),
977
- cursor: /* @__PURE__ */ jsxs3(
1520
+ cursor: /* @__PURE__ */ jsxs6(
978
1521
  "a",
979
1522
  {
980
1523
  className: appCx(block),
981
1524
  href: cursorInstallUrl(serverName, mcpUrl),
982
1525
  onClick: () => onAction?.("cursor", "deeplink"),
983
1526
  children: [
984
- /* @__PURE__ */ jsx3("img", { className: "dx-appbtn__logo", src: CURSOR_MARK, alt: "", "aria-hidden": true }),
1527
+ /* @__PURE__ */ jsx7("img", { className: "dx-appbtn__logo", src: CURSOR_MARK, alt: "", "aria-hidden": true }),
985
1528
  "Add to Cursor"
986
1529
  ]
987
1530
  },
988
1531
  "cursor"
989
1532
  ),
990
- vscode: /* @__PURE__ */ jsxs3(
1533
+ vscode: /* @__PURE__ */ jsxs6(
991
1534
  "a",
992
1535
  {
993
1536
  className: appCx(block),
994
1537
  href: vscodeInstallUrl(serverName, mcpUrl),
995
1538
  onClick: () => onAction?.("vscode", "deeplink"),
996
1539
  children: [
997
- /* @__PURE__ */ jsx3("img", { className: "dx-appbtn__logo", src: VSCODE_MARK, alt: "", "aria-hidden": true }),
1540
+ /* @__PURE__ */ jsx7("img", { className: "dx-appbtn__logo", src: VSCODE_MARK, alt: "", "aria-hidden": true }),
998
1541
  "Add to VS Code"
999
1542
  ]
1000
1543
  },
1001
1544
  "vscode"
1002
1545
  ),
1003
- hermes: /* @__PURE__ */ jsxs3(
1546
+ hermes: /* @__PURE__ */ jsxs6(
1004
1547
  "button",
1005
1548
  {
1006
1549
  type: "button",
@@ -1018,13 +1561,13 @@ function AppInstallButtons(props) {
1018
1561
  }
1019
1562
  },
1020
1563
  children: [
1021
- /* @__PURE__ */ jsx3("img", { className: "dx-appbtn__logo", src: HERMES_MARK, alt: "", "aria-hidden": true }),
1022
- hermesStatus === "copied" ? /* @__PURE__ */ jsx3("span", { className: "dx-appbtn__copied", children: "Copied. Run it in your terminal" }) : hermesStatus === "copying" ? "Copying OAuth setup\u2026" : hermesStatus === "failed" ? "Try copying for Hermes" : "Copy OAuth setup for Hermes"
1564
+ /* @__PURE__ */ jsx7("img", { className: "dx-appbtn__logo", src: HERMES_MARK, alt: "", "aria-hidden": true }),
1565
+ hermesStatus === "copied" ? /* @__PURE__ */ jsx7("span", { className: "dx-appbtn__copied", children: "Copied. Run it in your terminal" }) : hermesStatus === "copying" ? "Copying OAuth setup\u2026" : hermesStatus === "failed" ? "Try copying for Hermes" : "Copy OAuth setup for Hermes"
1023
1566
  ]
1024
1567
  },
1025
1568
  "hermes"
1026
1569
  ),
1027
- "claude-code": /* @__PURE__ */ jsxs3(
1570
+ "claude-code": /* @__PURE__ */ jsxs6(
1028
1571
  "button",
1029
1572
  {
1030
1573
  type: "button",
@@ -1042,14 +1585,14 @@ function AppInstallButtons(props) {
1042
1585
  }
1043
1586
  },
1044
1587
  children: [
1045
- /* @__PURE__ */ jsx3("img", { className: "dx-appbtn__logo", src: CLAUDE_MARK, alt: "", "aria-hidden": true }),
1046
- claudeStatus === "copied" ? /* @__PURE__ */ jsx3("span", { className: "dx-appbtn__copied", children: "Copied. Run it in your terminal" }) : claudeStatus === "copying" ? "Copying setup\u2026" : claudeStatus === "failed" ? "Try copying for Claude Code" : "Copy for Claude Code"
1588
+ /* @__PURE__ */ jsx7("img", { className: "dx-appbtn__logo", src: CLAUDE_MARK, alt: "", "aria-hidden": true }),
1589
+ claudeStatus === "copied" ? /* @__PURE__ */ jsx7("span", { className: "dx-appbtn__copied", children: "Copied. Run it in your terminal" }) : claudeStatus === "copying" ? "Copying setup\u2026" : claudeStatus === "failed" ? "Try copying for Claude Code" : "Copy for Claude Code"
1047
1590
  ]
1048
1591
  },
1049
1592
  "claude-code"
1050
1593
  )
1051
1594
  };
1052
- return /* @__PURE__ */ jsxs3(
1595
+ return /* @__PURE__ */ jsxs6(
1053
1596
  "div",
1054
1597
  {
1055
1598
  className: ["dx-appinstall", block ? "dx-appinstall--block" : "", className ?? ""].filter(Boolean).join(" "),
@@ -1057,13 +1600,13 @@ function AppInstallButtons(props) {
1057
1600
  "aria-label": `Add ${displayName} to an agent app`,
1058
1601
  children: [
1059
1602
  apps.map((app) => buttons[app] ?? null),
1060
- /* @__PURE__ */ jsx3("span", { className: "dx-appinstall__sr-only", "aria-live": "polite", "aria-atomic": "true", children: [
1603
+ /* @__PURE__ */ jsx7("span", { className: "dx-appinstall__sr-only", "aria-live": "polite", "aria-atomic": "true", children: [
1061
1604
  hermesStatus === "copied" ? "Hermes OAuth setup command copied." : "",
1062
1605
  claudeStatus === "copied" ? "Claude Code setup command copied." : ""
1063
1606
  ].filter(Boolean).join(" ") }),
1064
- hermesStatus === "copied" ? /* @__PURE__ */ jsxs3("div", { className: "dx-appinstall__notice", children: [
1065
- /* @__PURE__ */ jsx3("p", { children: "Run the command in your terminal. It adds the hosted MCP with OAuth." }),
1066
- /* @__PURE__ */ jsx3(
1607
+ hermesStatus === "copied" ? /* @__PURE__ */ jsxs6("div", { className: "dx-appinstall__notice", children: [
1608
+ /* @__PURE__ */ jsx7("p", { children: "Run the command in your terminal. It adds the hosted MCP with OAuth." }),
1609
+ /* @__PURE__ */ jsx7(
1067
1610
  "a",
1068
1611
  {
1069
1612
  className: "dx-appinstall__open",
@@ -1074,9 +1617,9 @@ function AppInstallButtons(props) {
1074
1617
  }
1075
1618
  )
1076
1619
  ] }) : null,
1077
- hermesStatus === "failed" ? /* @__PURE__ */ jsxs3("div", { id: hermesErrorId, className: "dx-appinstall__error", role: "alert", children: [
1078
- /* @__PURE__ */ jsx3("label", { htmlFor: `${hermesErrorId}-command`, children: "Couldn't copy. Select this Hermes command and run it in your terminal." }),
1079
- /* @__PURE__ */ jsx3(
1620
+ hermesStatus === "failed" ? /* @__PURE__ */ jsxs6("div", { id: hermesErrorId, className: "dx-appinstall__error", role: "alert", children: [
1621
+ /* @__PURE__ */ jsx7("label", { htmlFor: `${hermesErrorId}-command`, children: "Couldn't copy. Select this Hermes command and run it in your terminal." }),
1622
+ /* @__PURE__ */ jsx7(
1080
1623
  "input",
1081
1624
  {
1082
1625
  id: `${hermesErrorId}-command`,
@@ -1087,14 +1630,14 @@ function AppInstallButtons(props) {
1087
1630
  }
1088
1631
  )
1089
1632
  ] }) : null,
1090
- claudeStatus === "copied" ? /* @__PURE__ */ jsx3("div", { className: "dx-appinstall__notice", children: /* @__PURE__ */ jsxs3("p", { children: [
1633
+ claudeStatus === "copied" ? /* @__PURE__ */ jsx7("div", { className: "dx-appinstall__notice", children: /* @__PURE__ */ jsxs6("p", { children: [
1091
1634
  "Run the command in your terminal. If sign-in is required, finish it from Claude Code's ",
1092
- /* @__PURE__ */ jsx3("code", { children: "/mcp" }),
1635
+ /* @__PURE__ */ jsx7("code", { children: "/mcp" }),
1093
1636
  " menu."
1094
1637
  ] }) }) : null,
1095
- claudeStatus === "failed" ? /* @__PURE__ */ jsxs3("div", { id: claudeErrorId, className: "dx-appinstall__error", role: "alert", children: [
1096
- /* @__PURE__ */ jsx3("label", { htmlFor: `${claudeErrorId}-command`, children: "Couldn't copy. Select this Claude Code command and run it in your terminal." }),
1097
- /* @__PURE__ */ jsx3(
1638
+ claudeStatus === "failed" ? /* @__PURE__ */ jsxs6("div", { id: claudeErrorId, className: "dx-appinstall__error", role: "alert", children: [
1639
+ /* @__PURE__ */ jsx7("label", { htmlFor: `${claudeErrorId}-command`, children: "Couldn't copy. Select this Claude Code command and run it in your terminal." }),
1640
+ /* @__PURE__ */ jsx7(
1098
1641
  "input",
1099
1642
  {
1100
1643
  id: `${claudeErrorId}-command`,
@@ -1113,6 +1656,9 @@ export {
1113
1656
  AllowanceChips,
1114
1657
  AppInstallButtons,
1115
1658
  CreateWalletPanel,
1659
+ DEFAULT_ACCOUNT_NAVIGATION,
1660
+ DexterAccountControl,
1661
+ DexterAccountSummary,
1116
1662
  DexterButton,
1117
1663
  DexterMark,
1118
1664
  REMOVE_DEXTER_FROM_DEVICE_CONFIRMATION,