tokentracker-cli 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/README.de.md +5 -4
  2. package/README.ja.md +5 -4
  3. package/README.ko.md +5 -4
  4. package/README.md +6 -4
  5. package/README.zh-CN.md +5 -4
  6. package/dashboard/dist/assets/{AchievementBadge-CX7g238N.js → AchievementBadge-dt_UDU_h.js} +1 -1
  7. package/dashboard/dist/assets/{AchievementsPage-BbkEymra.js → AchievementsPage-B5DJ3S9l.js} +2 -2
  8. package/dashboard/dist/assets/{AchievementsSection-CmhoerE7.js → AchievementsSection-CDxcyig2.js} +1 -1
  9. package/dashboard/dist/assets/{BadgeDetailModal-996i13Vf.js → BadgeDetailModal-Cp98zNn2.js} +1 -1
  10. package/dashboard/dist/assets/{BotAnimated-B22CfAlF.js → BotAnimated-CR7MiUpo.js} +1 -1
  11. package/dashboard/dist/assets/{Card-DFd9hCFB.js → Card-C8IdDvlg.js} +1 -1
  12. package/dashboard/dist/assets/{ClawdAnimated-DXKN28M2.js → ClawdAnimated-COeTlW8z.js} +2 -2
  13. package/dashboard/dist/assets/{CommandPalette-DVRs34TV.js → CommandPalette-Co9k2CCc.js} +1 -1
  14. package/dashboard/dist/assets/{CommunityStatsModal-BExjH9E8.js → CommunityStatsModal-C6XQeRgw.js} +1 -1
  15. package/dashboard/dist/assets/{ConfirmModal-KJhOrJ98.js → ConfirmModal-Ai4182O-.js} +1 -1
  16. package/dashboard/dist/assets/{Controls-xnIEnOqd.js → Controls-BbKzN-Pe.js} +1 -1
  17. package/dashboard/dist/assets/{DashboardPage-BzsiCwjX.js → DashboardPage-DTcVGG4e.js} +1 -1
  18. package/dashboard/dist/assets/{DevicePage-Bo8e-KVq.js → DevicePage-CZbrtJmb.js} +1 -1
  19. package/dashboard/dist/assets/{DialogClose-gBd-BmR7.js → DialogClose-DMl8tAoX.js} +1 -1
  20. package/dashboard/dist/assets/DialogDescription-haPz7CX9.js +1 -0
  21. package/dashboard/dist/assets/{DialogTitle-B0UbsqD7.js → DialogTitle-BJxpp2t-.js} +1 -1
  22. package/dashboard/dist/assets/{FadeIn-Dv2DtOPn.js → FadeIn-hU_MXl6R.js} +1 -1
  23. package/dashboard/dist/assets/{HeaderGithubStar-1kEsgGdK.js → HeaderGithubStar-CM5RSxxN.js} +1 -1
  24. package/dashboard/dist/assets/{HoverTooltip-DQlpkw2L.js → HoverTooltip-BZKfQyZQ.js} +1 -1
  25. package/dashboard/dist/assets/{IpCheckPage-CFlkmSlA.js → IpCheckPage-BjDx-zja.js} +1 -1
  26. package/dashboard/dist/assets/{LandingPage-DNs6mSij.js → LandingPage-CAt8BCDv.js} +2 -2
  27. package/dashboard/dist/assets/{LeaderboardAvatar-DSltCiRr.js → LeaderboardAvatar-DiCrakjI.js} +1 -1
  28. package/dashboard/dist/assets/{LeaderboardPage-CkjUMA-k.js → LeaderboardPage-Dj3pHv6U.js} +2 -2
  29. package/dashboard/dist/assets/{LeaderboardProfileModal-DJjaD7Kz.js → LeaderboardProfileModal-DEWbcP9p.js} +3 -3
  30. package/dashboard/dist/assets/{LeaderboardProfilePage-Bue7tJoi.js → LeaderboardProfilePage-CTbWHQkY.js} +1 -1
  31. package/dashboard/dist/assets/{LimitsPage-Ctbvl8Q8.js → LimitsPage-V-98OUhF.js} +1 -1
  32. package/dashboard/dist/assets/{LocalOnlyNotice-LjNI8j4I.js → LocalOnlyNotice-a4PqtUZY.js} +1 -1
  33. package/dashboard/dist/assets/LoginCard-oD1A2Ru8.js +1 -0
  34. package/dashboard/dist/assets/{LoginModal-CUmfCsHY.js → LoginModal-D8aSmxok.js} +1 -1
  35. package/dashboard/dist/assets/{LoginPage-CjJb9qFM.js → LoginPage-DIjhBv2X.js} +1 -1
  36. package/dashboard/dist/assets/{PetPage-BWKEnBEW.js → PetPage-D7601BTX.js} +1 -1
  37. package/dashboard/dist/assets/{PopoverPopup-DeXj3kM3.js → PopoverPopup-aPnmKopO.js} +1 -1
  38. package/dashboard/dist/assets/{ProviderIcon-DL-oa-UM.js → ProviderIcon-rwyfcNlT.js} +1 -1
  39. package/dashboard/dist/assets/{ResetPasswordPage-CeeKMN8H.js → ResetPasswordPage-AF3SBgW2.js} +1 -1
  40. package/dashboard/dist/assets/{SegmentedControl-Bx5Z9tYf.js → SegmentedControl-fnlScNMT.js} +1 -1
  41. package/dashboard/dist/assets/{Select-DRbgbSPd.js → Select-DDjC3RjB.js} +1 -1
  42. package/dashboard/dist/assets/{SelectItemText-D792o2Et.js → SelectItemText-VhBWE2O8.js} +1 -1
  43. package/dashboard/dist/assets/{ServiceStatusPage-NjQ1oGqx.js → ServiceStatusPage-BL3qqEsp.js} +1 -1
  44. package/dashboard/dist/assets/{SessionsPage-Cr2uHP91.js → SessionsPage-DXYiuP2x.js} +1 -1
  45. package/dashboard/dist/assets/{SettingsPage-Av8pVbqT.js → SettingsPage-DTeA_ahr.js} +2 -2
  46. package/dashboard/dist/assets/{SkillsPage-feW4j329.js → SkillsPage-CtTRwVQH.js} +1 -1
  47. package/dashboard/dist/assets/{TokenGalaxy-DX36F36Q.js → TokenGalaxy-CifK91V7.js} +1 -1
  48. package/dashboard/dist/assets/{ToolbarRootContext-CzMlVMfI.js → ToolbarRootContext-ClGAIYoa.js} +1 -1
  49. package/dashboard/dist/assets/{TrendMonitor-BosWE34g.js → TrendMonitor-D1evFHRM.js} +1 -1
  50. package/dashboard/dist/assets/{WidgetsPage-DhoypTuq.js → WidgetsPage-Cq4RYJDE.js} +1 -1
  51. package/dashboard/dist/assets/{WrappedPage-DR6BoipR.js → WrappedPage-CoC5RJH7.js} +1 -1
  52. package/dashboard/dist/assets/__vite-browser-external-BDugA6I0.js +45 -0
  53. package/dashboard/dist/assets/{agent-logos-QSScjsfz.js → agent-logos-QLdA9OeA.js} +1 -1
  54. package/dashboard/dist/assets/{arrow-up-right-BJQYadF-.js → arrow-up-right-BYLgB3bH.js} +1 -1
  55. package/dashboard/dist/assets/{check-CINIOTsF.js → check-DfnIvqZD.js} +1 -1
  56. package/dashboard/dist/assets/{composite-YV7-iFo_.js → composite--JllTpIX.js} +1 -1
  57. package/dashboard/dist/assets/{copy-Bp_U7bAZ.js → copy-ClKVBIgD.js} +1 -1
  58. package/dashboard/dist/assets/{download-CVOIkdjl.js → download-Di1-UFJX.js} +1 -1
  59. package/dashboard/dist/assets/{external-link-P6LDhEET.js → external-link-D7zPVFLO.js} +1 -1
  60. package/dashboard/dist/assets/{flame-AbZCJ878.js → flame-BMJTxjVg.js} +1 -1
  61. package/dashboard/dist/assets/{format-tokens-M5bvANSq.js → format-tokens-DCZM5Nfn.js} +1 -1
  62. package/dashboard/dist/assets/{icons-DpRn5Rxt.js → icons-I615W2IU.js} +1 -1
  63. package/dashboard/dist/assets/{index-CW2bybhs.js → index-BX3CXVdD.js} +1 -1
  64. package/dashboard/dist/assets/{index-KQ5H65Ds.js → index-BejnmdPe.js} +1 -1
  65. package/dashboard/dist/assets/{index-L3O7cNuj.js → index-CwczM3BZ.js} +1 -1
  66. package/dashboard/dist/assets/{info-GEiJwgYk.js → info-CFJPny5Q.js} +1 -1
  67. package/dashboard/dist/assets/{link-2-D8KpexwS.js → link-2-D1ydWh_w.js} +1 -1
  68. package/dashboard/dist/assets/{loader-circle-r0nEab80.js → loader-circle-Cq-J-OFg.js} +1 -1
  69. package/dashboard/dist/assets/{maximize-2-azGbxGbz.js → maximize-2-kIoSq57I.js} +1 -1
  70. package/dashboard/dist/assets/{modifiers.esm-Cke4_92g.js → modifiers.esm-CLojthuF.js} +1 -1
  71. package/dashboard/dist/assets/{monitor-smartphone-BnHiLGNs.js → monitor-smartphone-DX2qWHYV.js} +1 -1
  72. package/dashboard/dist/assets/{plus-CJbY6Uuk.js → plus-B-JEpo3V.js} +1 -1
  73. package/dashboard/dist/assets/{provider-display-B05KW8SE.js → provider-display-DJDdrTAS.js} +2 -2
  74. package/dashboard/dist/assets/{react-CingcaIm.js → react-Ctoe8iLl.js} +1 -1
  75. package/dashboard/dist/assets/{search-CyffdJFU.js → search-BTSQrlW-.js} +1 -1
  76. package/dashboard/dist/assets/{skills-api-CdDPrjMM.js → skills-api-DKQyM8h7.js} +1 -1
  77. package/dashboard/dist/assets/{sortable.esm-B48YEoXA.js → sortable.esm-pOEL13xU.js} +1 -1
  78. package/dashboard/dist/assets/{store-B0W0vLvA.js → store-B2RplzvW.js} +1 -1
  79. package/dashboard/dist/assets/{terminal-CJ0D4hSx.js → terminal-BH_6_EW_.js} +1 -1
  80. package/dashboard/dist/assets/{trash-DH-_Q3A5.js → trash-CC444Mz6.js} +1 -1
  81. package/dashboard/dist/assets/{use-community-stats-y6OaeOVs.js → use-community-stats-CBXLdD_j.js} +1 -1
  82. package/dashboard/dist/assets/{use-latest-request-guard-DP7kE0Xa.js → use-latest-request-guard-DMuPfZQI.js} +1 -1
  83. package/dashboard/dist/assets/{use-limits-display-prefs-Bgcto2k1.js → use-limits-display-prefs-CmsGTBA4.js} +1 -1
  84. package/dashboard/dist/assets/{use-ordered-list-1L7o2taR.js → use-ordered-list-BNJNpXjB.js} +1 -1
  85. package/dashboard/dist/assets/use-reduced-motion-CNpG-Yoi.js +1 -0
  86. package/dashboard/dist/assets/{use-session-efficiency-pref-36sqzSZl.js → use-session-efficiency-pref-g_0ISxe1.js} +1 -1
  87. package/dashboard/dist/assets/{use-transform-DZgeA77H.js → use-transform-D36BHcXk.js} +1 -1
  88. package/dashboard/dist/assets/{use-usage-limits-C5P1O9oT.js → use-usage-limits-Dxw3vzsD.js} +1 -1
  89. package/dashboard/dist/assets/{useCurrency-Dwv89bBn.js → useCurrency-V2FE4TMo.js} +1 -1
  90. package/dashboard/dist/assets/{useTokenFormat-BGeVB81B.js → useTokenFormat-CEOwvzMt.js} +1 -1
  91. package/dashboard/dist/assets/{zap-D18Nt3M5.js → zap-BS7ZU76I.js} +1 -1
  92. package/dashboard/dist/index.html +13 -11
  93. package/dashboard/dist/ip-check.html +1 -1
  94. package/dashboard/dist/leaderboard.html +1 -1
  95. package/dashboard/dist/llms.txt +3 -2
  96. package/dashboard/dist/share.html +1 -1
  97. package/package.json +2 -2
  98. package/src/commands/init.js +11 -0
  99. package/src/commands/status.js +30 -0
  100. package/src/commands/sync.js +37 -1
  101. package/src/lib/pricing/seed-snapshot.json +1 -1
  102. package/src/lib/rollout.js +648 -2
  103. package/src/lib/wsl-probe.js +55 -12
  104. package/dashboard/dist/assets/DialogDescription-CTEI9PvU.js +0 -1
  105. package/dashboard/dist/assets/LoginCard-U_3SnvtN.js +0 -1
  106. package/dashboard/dist/assets/__vite-browser-external-DYTQCEz4.js +0 -45
  107. package/dashboard/dist/assets/use-reduced-motion-BQxHT0gI.js +0 -1
@@ -4,11 +4,15 @@ const path = require("node:path");
4
4
  const DEFAULT_EXEC_OPTS = { timeout: 15000, windowsHide: true, maxBuffer: 1024 * 1024, stdio: ["ignore", "pipe", "ignore"] };
5
5
 
6
6
  let _cachedDistros = null;
7
+ let _cachedDistrosError = null;
7
8
  const _cachedWslUsers = new Map();
9
+ const _cachedWslUserErrors = new Map();
8
10
 
9
11
  function resetWslProbeCache() {
10
12
  _cachedDistros = null;
13
+ _cachedDistrosError = null;
11
14
  _cachedWslUsers.clear();
15
+ _cachedWslUserErrors.clear();
12
16
  }
13
17
 
14
18
  const WSL_MODES = new Set([
@@ -25,11 +29,15 @@ function defaultRunWsl(args, { utf16 = false } = {}) {
25
29
  return utf16 ? buf.toString("utf16le") : buf.toString("utf8");
26
30
  }
27
31
 
32
+ function cleanWslOutput(raw) {
33
+ return raw.replace(/\0/g, "").replace(/\uFEFF/g, "").trim();
34
+ }
35
+
28
36
  function parseWslListVerbose(raw) {
29
37
  if (typeof raw !== "string") return [];
30
38
  const distros = [];
31
39
  for (const line of raw.split(/\r?\n/)) {
32
- const clean = line.replace(/\0/g, "").replace(/\uFEFF/g, "").trim();
40
+ const clean = cleanWslOutput(line);
33
41
  if (!clean) continue;
34
42
  const cells = clean.split(/\s+/);
35
43
  let isDefault = false;
@@ -47,19 +55,44 @@ function parseWslListVerbose(raw) {
47
55
  }
48
56
 
49
57
  function probeWslDistros(deps = {}) {
50
- const hasDeps = Object.keys(deps).length > 0;
51
- if (!hasDeps && _cachedDistros) return _cachedDistros;
58
+ const strict = deps.strict === true;
59
+ const hasDeps = Object.keys(deps).some((key) => key !== "strict");
60
+ // Legacy callers retain their fail-safe cache. Strict observers may reuse
61
+ // successful empty results, but must retry a failure cached by any caller.
62
+ if (!hasDeps && _cachedDistros && (!strict || !_cachedDistrosError)) return _cachedDistros;
52
63
  const runWsl = deps.runWsl || defaultRunWsl;
53
64
  let raw;
54
65
  try {
55
66
  raw = runWsl(["-l", "-v"], { utf16: true });
56
- } catch (_e) {
57
- if (!hasDeps) _cachedDistros = [];
67
+ } catch (error) {
68
+ let confirmedEmpty = false;
69
+ if (
70
+ strict && Number.isInteger(error?.status) && error.status !== 0 &&
71
+ error.signal == null && (error.code == null || error.code === error.status)
72
+ ) {
73
+ // Some WSL builds exit nonzero for an empty verbose list. Confirm that
74
+ // case with a successful empty quiet list, not localized diagnostic text.
75
+ // Transport/permission/signal failures must never reach this fallback.
76
+ try {
77
+ const quiet = runWsl(["-l", "-q"], { utf16: true });
78
+ confirmedEmpty = typeof quiet === "string" && cleanWslOutput(quiet) === "";
79
+ } catch (_quietError) { }
80
+ }
81
+ if (!hasDeps) {
82
+ _cachedDistros = [];
83
+ _cachedDistrosError = confirmedEmpty ? null : error;
84
+ }
85
+ // ENOENT confirms wsl.exe is not installed. A failed invocation of an
86
+ // existing executable is not evidence of an empty distro list.
87
+ if (strict && error?.code !== "ENOENT" && !confirmedEmpty) throw error;
58
88
  return [];
59
89
  }
60
90
  const distros = parseWslListVerbose(raw);
61
91
  const sorted = distros.sort((a, b) => (b.isDefault ? 1 : 0) - (a.isDefault ? 1 : 0));
62
- if (!hasDeps) _cachedDistros = sorted;
92
+ if (!hasDeps) {
93
+ _cachedDistros = sorted;
94
+ _cachedDistrosError = null;
95
+ }
63
96
  return sorted;
64
97
  }
65
98
 
@@ -125,15 +158,22 @@ function resolveAllWin32Paths({
125
158
  return { native: single, wsl: null };
126
159
  }
127
160
 
128
- function lookupWslUser(distroName, runWsl, useCache) {
129
- if (useCache && _cachedWslUsers.has(distroName)) {
161
+ function lookupWslUser(distroName, runWsl, useCache, strict = false) {
162
+ if (useCache && _cachedWslUsers.has(distroName) && (!strict || !_cachedWslUserErrors.has(distroName))) {
130
163
  return _cachedWslUsers.get(distroName);
131
164
  }
132
165
  let user = "";
166
+ let error = null;
133
167
  try {
134
168
  user = String(runWsl(["-d", distroName, "-e", "whoami"], { utf16: false }) || "").trim();
135
- } catch (_e) { }
136
- if (useCache) _cachedWslUsers.set(distroName, user);
169
+ if (!user) error = Object.assign(new Error("WSL identity probe returned no user"), { code: "EWSLIDENTITY" });
170
+ } catch (cause) { error = cause; }
171
+ if (useCache) {
172
+ _cachedWslUsers.set(distroName, user);
173
+ if (error) _cachedWslUserErrors.set(distroName, error);
174
+ else _cachedWslUserErrors.delete(distroName);
175
+ }
176
+ if (strict && error) throw error;
137
177
  return user;
138
178
  }
139
179
 
@@ -142,10 +182,13 @@ function discoverWslHome(providerDir, deps = {}) {
142
182
 
143
183
  const runWsl = deps.runWsl || defaultRunWsl;
144
184
  const existsSync = deps.existsSync || fssync.existsSync;
145
- const distros = deps.runWsl ? probeWslDistros({ runWsl: deps.runWsl }) : probeWslDistros();
185
+ const strict = deps.strict === true;
186
+ const distros = deps.runWsl
187
+ ? probeWslDistros({ runWsl: deps.runWsl, strict })
188
+ : probeWslDistros(strict ? { strict } : undefined);
146
189
  const useCache = !deps.runWsl;
147
190
  for (const distro of distros) {
148
- const user = lookupWslUser(distro.name, runWsl, useCache);
191
+ const user = lookupWslUser(distro.name, runWsl, useCache, strict);
149
192
  if (!user) continue;
150
193
  const roots = distro.version === 1
151
194
  ? ["\\\\wsl.localhost\\", "\\\\wsl$\\"]
@@ -1 +0,0 @@
1
- import{r as n,v as a}from"./__vite-browser-external-DYTQCEz4.js";import{u as p}from"./DialogTitle-B0UbsqD7.js";import{u as c}from"./composite-YV7-iFo_.js";const x=n.forwardRef(function(e,r){const{render:l,className:u,style:m,id:s,...t}=e,i=p(),o=c(s);return i.useSyncedValueWithCleanup("descriptionElementId",o),a("p",e,{ref:r,props:[{id:o},t]})});export{x as D};
@@ -1 +0,0 @@
1
- import{m as re,I as ue,a as me,r as o,c as a,j as e,e as h}from"./__vite-browser-external-DYTQCEz4.js";const ae={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};ae.node;const xe=re(ae);const te={name:"mail",size:24,node:[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]};te.node;const he=re(te),be=e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1Z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23Z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18A10.96 10.96 0 0 0 1 12c0 1.77.42 3.44 1.18 4.93l3.66-2.84Z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53Z",fill:"#EA4335"})]}),fe=e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12Z"})}),pe={google:be,github:fe},ye={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",apple:"Apple"};function we(i){return ye[i]||String(i||"").replace(/-/g," ")}function ke(i){if(typeof i=="string"&&i.trim())return i.trim();if(i&&typeof i=="object"){if(typeof i.token=="string"&&i.token.trim())return i.token.trim();if(typeof i.otp=="string"&&i.otp.trim())return i.otp.trim()}return""}function je({title:i,subtitle:D,className:oe="",onSuccess:S,hideLogo:H=!1,initialMode:p="signin",tokenFromUrl:P="",initialEmail:y="",initialCode:v=""}){ue();const{enabled:w,signedIn:j,refreshUser:E,signInWithPassword:G,signUp:Z,signInWithOAuth:z,getPublicAuthConfig:T,sendResetPasswordEmail:V,exchangeResetPasswordToken:$,resetPassword:U}=me(),[n,u]=o.useState(p),[c,k]=o.useState(y),[m,N]=o.useState(""),[A,L]=o.useState(""),[M,se]=o.useState(""),[q,W]=o.useState(v),[_,x]=o.useState(!1),[J,s]=o.useState(null),[C,b]=o.useState(null),[F,O]=o.useState(!1),[ie,ne]=o.useState(!!(p!=="signin"||y)),[I,K]=o.useState(!0),[R,Q]=o.useState([]),[X,le]=o.useState(8);o.useEffect(()=>{p&&u(p)},[p]),o.useEffect(()=>{y&&k(y)},[y]),o.useEffect(()=>{v&&W(v)},[v]),o.useEffect(()=>{if(!w)return;let r=!0;return K(!0),(async()=>{const{data:t,error:l}=await T();if(r){if(l||!t)Q(["google","github"]);else{const d=Array.isArray(t.oAuthProviders)?t.oAuthProviders:[],f=Array.isArray(t.customOAuthProviders)?t.customOAuthProviders:[];Q([...d,...f]),typeof t.passwordMinLength=="number"&&t.passwordMinLength>0&&le(t.passwordMinLength)}K(!1)}})(),()=>{r=!1}},[w,T]),o.useEffect(()=>{j&&S&&S()},[j,S]);const Y=o.useMemo(()=>typeof window>"u"?"":!!window.webkit?.messageHandlers?.nativeOAuth?`${window.location.origin}/auth/callback`:`${window.location.origin}/`,[]),ee=o.useMemo(()=>typeof window>"u"?"/reset-password":`${window.location.origin}/reset-password`,[]),B=o.useCallback(async r=>{s(null),x(!0);try{const{error:t}=await z(r,Y);t&&s(t.message||String(t))}finally{x(!1)}},[z,Y]);o.useEffect(()=>{if(!w||I||j||typeof window>"u")return;const r=window.location.search;if(!r)return;const t=new URLSearchParams(r),l=t.get("native")==="1",d=t.get("provider");l&&d&&[...R].includes(d)&&B(d)},[w,I,j,R,B]);const de=o.useCallback(async r=>{r.preventDefault(),s(null),x(!0);try{if(n==="signup"){const{data:l,error:d}=await Z({email:c.trim(),password:m,name:M.trim()||void 0});if(d){s(d.message||String(d));return}if(l?.requireEmailVerification){b(a("login.verify_email_pending")),u("signin");return}await E();return}const{error:t}=await G({email:c.trim(),password:m});if(t){s(t.message||String(t));return}await E()}finally{x(!1)}},[n,c,m,M,Z,G,E]),ce=o.useCallback(async r=>{r.preventDefault(),s(null),x(!0);try{const t=c.trim(),{error:l}=await V({email:t,redirectTo:ee});if(l){s(l.message||String(l));return}k(t),b(a("reset_password.request.sent")),u("reset_confirm")}finally{x(!1)}},[c,ee,V]),ge=o.useCallback(async r=>{if(r.preventDefault(),s(null),m!==A){s(a("reset_password.error.password_mismatch"));return}x(!0);try{let t=P;if(!t){const{data:d,error:f}=await $({email:c.trim(),code:q.trim()});if(f){s(f.message||String(f));return}if(t=ke(d),!t){s(a("reset_password.error.missing_token"));return}}const{error:l}=await U({newPassword:m,otp:t});if(l){s(l.message||String(l));return}O(!0),b(a("reset_password.success"))}finally{x(!1)}},[q,A,c,$,m,U,P]);if(!w)return null;const g=n==="reset_email"||n==="reset_confirm";return e.jsxs("div",{className:h("w-full bg-white dark:bg-oai-gray-950 p-6 transition-colors duration-200",oe),children:[g&&e.jsxs("button",{type:"button",onClick:()=>{u("signin"),b(null),s(null),O(!1),N(""),L("")},className:"flex items-center gap-1.5 text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors mb-4 focus:outline-none",children:[e.jsx(xe,{className:"h-3.5 w-3.5"}),a("reset_password.back_to_sign_in")]}),e.jsxs("div",{className:h("mb-6",g?"text-left":"text-center"),children:[!H&&!g&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:28,height:28,className:"rounded-md"}),e.jsx("span",{className:"text-lg font-semibold text-oai-black dark:text-white font-oai tracking-tight",children:a("shared.app_name")})]}),e.jsx("h2",{className:h("text-sm font-semibold text-oai-black dark:text-white tracking-tight mb-1",(H||g)&&"text-base font-bold md:text-lg"),children:g?a("reset_password.title"):i||a("login_modal.subtitle")}),!g&&D&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px] mx-auto",children:D}),g&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px]",children:C&&n==="reset_confirm"&&!F?C:a("reset_password.subtitle")})]}),C&&(!g||F)&&e.jsx("div",{className:"mb-4 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900/50 px-3 py-2 text-xs text-oai-gray-700 dark:text-oai-gray-300",children:C}),J&&e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400 text-center",role:"alert",children:J}),n==="reset_email"&&e.jsxs("form",{onSubmit:ce,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email",type:"email",autoComplete:"email",required:!0,value:c,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.request.submit")})]}),n==="reset_confirm"&&(F?e.jsx("button",{type:"button",onClick:()=>{u("signin"),O(!1),b(null),s(null),N(""),L("")},className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors text-center shadow-sm",children:a("reset_password.success_cta")}):e.jsxs("form",{onSubmit:ge,className:"space-y-3",children:[!P&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email-confirm",type:"email",autoComplete:"email",required:!0,value:c,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-code",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.code")}),e.jsx("input",{id:"card-reset-code",type:"text",inputMode:"numeric",autoComplete:"one-time-code",required:!0,value:q,onChange:r=>W(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.new_password")}),e.jsx("input",{id:"card-reset-password",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:m,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.confirm_password")}),e.jsx("input",{id:"card-reset-password-confirm",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:A,onChange:r=>L(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.reset.submit")})]})),!g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2.5 mb-5",children:I?e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"}),e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"})]}):R.map(r=>e.jsxs("button",{type:"button",disabled:_,onClick:()=>B(r),className:h("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors disabled:opacity-50","flex items-center justify-center gap-2.5"),children:[pe[r]||null,a("login.oauth.continue",{provider:we(r)})]},r))}),ie?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login_modal.divider_email")})})]}),e.jsxs("div",{className:"flex rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 bg-oai-gray-50 dark:bg-oai-gray-900/50 mb-4",children:[e.jsx("button",{type:"button",className:h("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",n==="signin"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{u("signin"),s(null)},children:a("login.tab.sign_in")}),e.jsx("button",{type:"button",className:h("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",n==="signup"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{u("signup"),s(null)},children:a("login.tab.sign_up")})]}),e.jsxs("form",{onSubmit:de,className:"space-y-3",children:[n==="signup"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.name")}),e.jsx("input",{id:"card-name",type:"text",autoComplete:"name",value:M,onChange:r=>se(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500",placeholder:a("login.field.name_placeholder")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-email",type:"email",autoComplete:"email",required:!0,value:c,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.password")}),e.jsx("input",{id:"card-password",type:"password",autoComplete:n==="signup"?"new-password":"current-password",required:!0,minLength:n==="signup"?X:void 0,value:m,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"}),n==="signup"&&e.jsx("p",{className:"mt-1 text-xs text-oai-gray-400 dark:text-oai-gray-600",children:a("login.password_hint",{min:String(X)})}),n==="signin"&&e.jsx("div",{className:"mt-1 text-right",children:e.jsx("button",{type:"button",onClick:()=>{u("reset_email"),s(null),b(null)},className:"text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white no-underline bg-transparent border-0 p-0 cursor-pointer focus:outline-none",children:a("login.forgot_password")})})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:n==="signup"?a("login.submit.sign_up"):a("login.submit.sign_in")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login.divider")})})]}),e.jsxs("button",{type:"button",onClick:()=>ne(!0),className:h("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors","flex items-center justify-center gap-2.5"),children:[e.jsx(he,{className:"h-[18px] w-[18px] text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75}),a("login_modal.continue_email")]})]})]})]})}export{je as L};