dsh-coding-subscription-oauth 0.5.3 → 0.5.4

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.
@@ -0,0 +1,386 @@
1
+ /** Response parsers and small formatting helpers for the settings UI. */
2
+
3
+ import { isRecord } from "./api.ts";
4
+ import {
5
+ GATEWAY_PORT_MAX,
6
+ GATEWAY_PORT_MIN,
7
+ GATEWAY_RANDOM_PORT_MAX,
8
+ GATEWAY_RANDOM_PORT_MIN,
9
+ GATEWAY_RANDOM_RESERVED,
10
+ HOUR_MS,
11
+ IMAGINE_SOURCE_KEY,
12
+ SOURCE_COMMIT_ACTIONS,
13
+ SOURCE_CONFLICTS,
14
+ SOURCE_DEFAULT_PATH,
15
+ SOURCE_KINDS,
16
+ SOURCE_PREVIEW_ACTIONS,
17
+ SOURCE_REASONS,
18
+ } from "./constants.ts";
19
+ import type {
20
+ CapabilitySettingsView,
21
+ CapabilitySnapshot,
22
+ GatewayView,
23
+ GrokBuildSettingsInjected,
24
+ ImagineCredentialView,
25
+ ProviderStatus,
26
+ SourceCommitAction,
27
+ SourceConflict,
28
+ SourceKind,
29
+ SourcePreview,
30
+ SourcePreviewAction,
31
+ SourceReason,
32
+ SourceStatus,
33
+ UsageLimitView,
34
+ UsageView,
35
+ UsageWindowView,
36
+ } from "./types.ts";
37
+
38
+ export function optionalString(value: unknown): string | undefined {
39
+ return typeof value === "string" && value.length > 0 && value.length < 500 ? value : undefined;
40
+ }
41
+
42
+ export function optionalFiniteNumber(value: unknown): number | undefined {
43
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
44
+ }
45
+
46
+ export function optionalBoolean(value: unknown): boolean | undefined {
47
+ return typeof value === "boolean" ? value : undefined;
48
+ }
49
+
50
+ export function optionalPercent(value: unknown): number | undefined {
51
+ const numeric = optionalFiniteNumber(value);
52
+ return numeric !== undefined && numeric >= 0 && numeric <= 100 ? numeric : undefined;
53
+ }
54
+
55
+ export function isSourceKind(value: string): value is SourceKind {
56
+ return (SOURCE_KINDS as readonly string[]).includes(value);
57
+ }
58
+
59
+ export function isSourceReason(value: string): value is SourceReason {
60
+ return (SOURCE_REASONS as readonly string[]).includes(value);
61
+ }
62
+
63
+ export function isSourceConflict(value: string): value is SourceConflict {
64
+ return (SOURCE_CONFLICTS as readonly string[]).includes(value);
65
+ }
66
+
67
+ export function isSourcePreviewAction(value: string): value is SourcePreviewAction {
68
+ return (SOURCE_PREVIEW_ACTIONS as readonly string[]).includes(value);
69
+ }
70
+
71
+ export function isSourceCommitAction(value: string): value is SourceCommitAction {
72
+ return (SOURCE_COMMIT_ACTIONS as readonly string[]).includes(value);
73
+ }
74
+
75
+ export function looksSecret(value: string): boolean {
76
+ return /eyJ[A-Za-z0-9_-]+\.|sk-[A-Za-z0-9_-]{8,}|Bearer\s+\S+/u.test(value);
77
+ }
78
+
79
+ export function safeDisplayPath(value: unknown, kind: SourceKind): string {
80
+ const text = optionalString(value);
81
+ if (text === undefined || looksSecret(text) || text.length > 180) return SOURCE_DEFAULT_PATH[kind];
82
+ return text;
83
+ }
84
+
85
+ export function safeWarning(value: unknown): string | undefined {
86
+ const text = optionalString(value);
87
+ if (text === undefined || looksSecret(text)) return undefined;
88
+ return text;
89
+ }
90
+
91
+ export function formatEpoch(value: number | undefined): string | undefined {
92
+ if (value === undefined || !Number.isFinite(value) || value <= 0) return undefined;
93
+ const ms = value > 1e12 ? value : value > 1e9 ? value * 1000 : undefined;
94
+ if (ms === undefined) return undefined;
95
+ const formatted = new Date(ms).toLocaleString();
96
+ return formatted.length > 0 ? formatted : undefined;
97
+ }
98
+
99
+ export function parseSource(value: unknown): SourceStatus | undefined {
100
+ if (!isRecord(value) || typeof value["kind"] !== "string" || !isSourceKind(value["kind"])) return undefined;
101
+ const kind = value["kind"];
102
+ const reasonRaw = optionalString(value["reason"]);
103
+ const expiresAt = optionalFiniteNumber(value["expiresAt"]);
104
+ return {
105
+ kind,
106
+ displayPath: safeDisplayPath(value["displayPath"], kind),
107
+ available: value["available"] === true,
108
+ ...(expiresAt === undefined ? {} : { expiresAt }),
109
+ ...(reasonRaw !== undefined && isSourceReason(reasonRaw) ? { reason: reasonRaw } : {}),
110
+ };
111
+ }
112
+
113
+ export function mergeSources(discovered: readonly SourceStatus[]): SourceStatus[] {
114
+ return SOURCE_KINDS.map((kind) => {
115
+ const found = discovered.find((entry) => entry.kind === kind);
116
+ return found ?? { kind, displayPath: SOURCE_DEFAULT_PATH[kind], available: false, reason: "missing" };
117
+ });
118
+ }
119
+
120
+ export function parseSources(value: unknown): SourceStatus[] {
121
+ const rows = Array.isArray(value)
122
+ ? value
123
+ : isRecord(value) && Array.isArray(value["sources"])
124
+ ? value["sources"]
125
+ : [];
126
+ return mergeSources(rows.map(parseSource).filter((entry): entry is SourceStatus => entry !== undefined));
127
+ }
128
+
129
+ export function parsePreview(value: unknown): SourcePreview | undefined {
130
+ if (!isRecord(value)) return undefined;
131
+ const previewId = optionalString(value["previewId"]);
132
+ const kindRaw = optionalString(value["kind"]);
133
+ if (previewId === undefined || kindRaw === undefined || !isSourceKind(kindRaw)) return undefined;
134
+ const conflictRaw = optionalString(value["conflict"]);
135
+ const actionRaw = optionalString(value["action"]);
136
+ const expiresAt = optionalFiniteNumber(value["expiresAt"]);
137
+ const ticketExpiresAt = optionalFiniteNumber(value["ticketExpiresAt"]);
138
+ const warnings = Array.isArray(value["warnings"])
139
+ ? value["warnings"].map(safeWarning).filter((entry): entry is string => entry !== undefined)
140
+ : [];
141
+ return {
142
+ previewId,
143
+ kind: kindRaw,
144
+ displayPath: safeDisplayPath(value["displayPath"], kindRaw),
145
+ confirmOverwriteRequired: value["confirmOverwriteRequired"] === true,
146
+ warnings,
147
+ ...(expiresAt === undefined ? {} : { expiresAt }),
148
+ ...(ticketExpiresAt === undefined ? {} : { ticketExpiresAt }),
149
+ ...(conflictRaw !== undefined && isSourceConflict(conflictRaw) ? { conflict: conflictRaw } : {}),
150
+ ...(actionRaw !== undefined && isSourcePreviewAction(actionRaw) ? { action: actionRaw } : {}),
151
+ };
152
+ }
153
+
154
+ export function parseCommitAction(value: unknown): SourceCommitAction | undefined {
155
+ if (!isRecord(value)) return undefined;
156
+ const action = optionalString(value["action"]);
157
+ return action !== undefined && isSourceCommitAction(action) ? action : undefined;
158
+ }
159
+
160
+ export function boundedInteger(value: unknown, min: number, max: number, fallback: number): number {
161
+ const numeric = optionalFiniteNumber(value);
162
+ return numeric !== undefined && Number.isInteger(numeric) && numeric >= min && numeric <= max ? numeric : fallback;
163
+ }
164
+
165
+ export function emptyCapabilitySettings(): CapabilitySettingsView {
166
+ return {
167
+ codexSearch: false,
168
+ codexImages: false,
169
+ codexImageEdits: false,
170
+ codexUsage: false,
171
+ codexFast: false,
172
+ grokImagineImage: false,
173
+ grokImagineVideo: false,
174
+ searchResults: 5,
175
+ imageCount: 1,
176
+ videoArtifactTtlMs: 7 * 24 * HOUR_MS,
177
+ };
178
+ }
179
+
180
+ export function parseCapabilitySettings(value: unknown): CapabilitySettingsView {
181
+ const source = isRecord(value) ? value : {};
182
+ return {
183
+ codexSearch: source["codexSearch"] === true,
184
+ codexImages: source["codexImages"] === true,
185
+ codexImageEdits: source["codexImageEdits"] === true,
186
+ codexUsage: source["codexUsage"] === true,
187
+ codexFast: source["codexFast"] === true,
188
+ grokImagineImage: source["grokImagineImage"] === true,
189
+ grokImagineVideo: source["grokImagineVideo"] === true,
190
+ searchResults: boundedInteger(source["searchResults"], 1, 20, 5),
191
+ imageCount: boundedInteger(source["imageCount"], 1, 4, 1),
192
+ videoArtifactTtlMs: boundedInteger(source["videoArtifactTtlMs"], HOUR_MS, 7 * 24 * HOUR_MS, 7 * 24 * HOUR_MS),
193
+ };
194
+ }
195
+
196
+ export function parseCapabilities(value: unknown): CapabilitySnapshot | undefined {
197
+ if (!isRecord(value)) return undefined;
198
+ const nested = isRecord(value["value"]) ? value["value"] : value;
199
+ const revision = optionalFiniteNumber(value["revision"]);
200
+ if (revision === undefined && !isRecord(value["value"]) && value["writable"] === undefined) return undefined;
201
+ return {
202
+ value: parseCapabilitySettings(nested),
203
+ revision: revision ?? 0,
204
+ writable: value["writable"] === true,
205
+ };
206
+ }
207
+
208
+ function parseUsageWindow(value: unknown): UsageWindowView | undefined {
209
+ if (!isRecord(value)) return undefined;
210
+ const usedPercent = optionalPercent(value["usedPercent"] ?? value["used_percent"]);
211
+ const remainingPercent = optionalPercent(value["remainingPercent"] ?? value["remaining_percent"]);
212
+ const windowSeconds = optionalFiniteNumber(value["windowSeconds"] ?? value["limit_window_seconds"]);
213
+ const resetsAt = optionalFiniteNumber(value["resetsAt"] ?? value["reset_at"]);
214
+ if (
215
+ usedPercent === undefined &&
216
+ remainingPercent === undefined &&
217
+ windowSeconds === undefined &&
218
+ resetsAt === undefined
219
+ ) {
220
+ return undefined;
221
+ }
222
+ return {
223
+ ...(usedPercent === undefined ? {} : { usedPercent }),
224
+ ...(remainingPercent === undefined ? {} : { remainingPercent }),
225
+ ...(windowSeconds !== undefined && windowSeconds > 0 ? { windowSeconds } : {}),
226
+ ...(resetsAt === undefined ? {} : { resetsAt }),
227
+ };
228
+ }
229
+
230
+ function parseUsageLimit(value: unknown, fallbackId: string): UsageLimitView | undefined {
231
+ if (!isRecord(value)) return undefined;
232
+ const id = optionalString(value["id"]) ?? optionalString(value["metered_feature"]) ?? fallbackId;
233
+ const name = optionalString(value["name"]) ?? optionalString(value["limit_name"]);
234
+ const nested = isRecord(value["rate_limit"]) ? value["rate_limit"] : value;
235
+ const windows = Array.isArray(value["windows"])
236
+ ? value["windows"].map(parseUsageWindow).filter((entry): entry is UsageWindowView => entry !== undefined)
237
+ : [
238
+ parseUsageWindow(nested["primary_window"]),
239
+ parseUsageWindow(nested["secondary_window"]),
240
+ parseUsageWindow(nested),
241
+ ].filter((entry): entry is UsageWindowView => entry !== undefined);
242
+ if (windows.length === 0 && name === undefined && optionalString(value["id"]) === undefined) return undefined;
243
+ return { id, windows, ...(name === undefined ? {} : { name }) };
244
+ }
245
+
246
+ export function parseUsage(value: unknown): UsageView | undefined {
247
+ if (!isRecord(value)) return undefined;
248
+ const payload = isRecord(value["usage"]) ? value["usage"] : value;
249
+ const rateLimits: UsageLimitView[] = [];
250
+ const seen = new Set<string>();
251
+ const add = (limit: UsageLimitView | undefined): void => {
252
+ if (limit === undefined || seen.has(limit.id)) return;
253
+ seen.add(limit.id);
254
+ rateLimits.push(limit);
255
+ };
256
+ if (Array.isArray(payload["rateLimits"])) {
257
+ payload["rateLimits"].forEach((entry, index) => add(parseUsageLimit(entry, `limit-${String(index)}`)));
258
+ } else {
259
+ add(parseUsageLimit(payload["rate_limit"], "codex"));
260
+ if (Array.isArray(payload["additional_rate_limits"])) {
261
+ payload["additional_rate_limits"].forEach((entry, index) =>
262
+ add(parseUsageLimit(entry, `extra-${String(index)}`)),
263
+ );
264
+ }
265
+ add(parseUsageLimit(payload["code_review_rate_limit"], "code_review"));
266
+ }
267
+ const credits = isRecord(payload["credits"]) ? payload["credits"] : undefined;
268
+ const spend = isRecord(payload["individualLimit"])
269
+ ? payload["individualLimit"]
270
+ : isRecord(payload["spend_control"])
271
+ ? isRecord(payload["spend_control"]["individual_limit"])
272
+ ? payload["spend_control"]["individual_limit"]
273
+ : payload["spend_control"]
274
+ : undefined;
275
+ const resetRaw = isRecord(payload["resetCredits"])
276
+ ? payload["resetCredits"]["availableCount"]
277
+ : isRecord(payload["rate_limit_reset_credits"])
278
+ ? payload["rate_limit_reset_credits"]["available_count"]
279
+ : undefined;
280
+ const resetCredits = optionalFiniteNumber(resetRaw);
281
+ const fetchedAt = optionalFiniteNumber(payload["fetchedAt"]);
282
+ const spendControlReached =
283
+ optionalBoolean(payload["spendControlReached"]) ??
284
+ (isRecord(payload["spend_control"]) ? optionalBoolean(payload["spend_control"]["reached"]) : undefined);
285
+ const creditsBalance = credits === undefined ? undefined : optionalString(credits["balance"]);
286
+ const individualLimit = spend === undefined ? undefined : optionalString(spend["limit"]);
287
+ const individualUsed = spend === undefined ? undefined : optionalString(spend["used"]);
288
+ const individualRemaining = spend === undefined ? undefined : optionalString(spend["remaining"]);
289
+ const individualRemainingPercent =
290
+ spend === undefined ? undefined : optionalPercent(spend["remainingPercent"] ?? spend["remaining_percent"]);
291
+ const individualResetsAt =
292
+ spend === undefined ? undefined : optionalFiniteNumber(spend["resetsAt"] ?? spend["reset_at"]);
293
+ return {
294
+ rateLimits,
295
+ ...(credits !== undefined && typeof credits["unlimited"] === "boolean"
296
+ ? { creditsUnlimited: credits["unlimited"] }
297
+ : {}),
298
+ ...(creditsBalance === undefined ? {} : { creditsBalance }),
299
+ ...(individualLimit === undefined ? {} : { individualLimit }),
300
+ ...(individualUsed === undefined ? {} : { individualUsed }),
301
+ ...(individualRemaining === undefined ? {} : { individualRemaining }),
302
+ ...(individualRemainingPercent === undefined ? {} : { individualRemainingPercent }),
303
+ ...(individualResetsAt === undefined ? {} : { individualResetsAt }),
304
+ ...(spendControlReached === undefined ? {} : { spendControlReached }),
305
+ ...(resetCredits !== undefined && resetCredits >= 0 && Number.isSafeInteger(resetCredits) ? { resetCredits } : {}),
306
+ ...(fetchedAt === undefined ? {} : { fetchedAt }),
307
+ };
308
+ }
309
+
310
+ export function usageHasVisibleFields(usage: UsageView): boolean {
311
+ return (
312
+ usage.rateLimits.some((limit) => limit.windows.length > 0 || limit.name !== undefined) ||
313
+ usage.creditsUnlimited !== undefined ||
314
+ usage.creditsBalance !== undefined ||
315
+ usage.individualLimit !== undefined ||
316
+ usage.individualUsed !== undefined ||
317
+ usage.individualRemaining !== undefined ||
318
+ usage.individualRemainingPercent !== undefined ||
319
+ usage.spendControlReached === true ||
320
+ usage.resetCredits !== undefined
321
+ );
322
+ }
323
+
324
+ export function parseGateway(value: unknown): GatewayView | undefined {
325
+ if (!isRecord(value)) return undefined;
326
+ const bind = optionalString(value["bind"]);
327
+ const port = optionalFiniteNumber(value["port"]);
328
+ if (bind === undefined || port === undefined) return undefined;
329
+ return {
330
+ enabled: value["enabled"] === true,
331
+ running: value["running"] === true,
332
+ bind,
333
+ port,
334
+ keyHint: optionalString(value["keyHint"]) ?? "",
335
+ warning: optionalString(value["warning"]) ?? "",
336
+ };
337
+ }
338
+
339
+ export function formatGatewayBaseUrl(bind: string, port: number): string {
340
+ const host = bind.includes(":") && !bind.startsWith("[") ? `[${bind}]` : bind;
341
+ return `http://${host}:${String(port)}`;
342
+ }
343
+
344
+ export function randomGatewayPort(exclude?: number): number {
345
+ for (let attempt = 0; attempt < 32; attempt += 1) {
346
+ const span = GATEWAY_RANDOM_PORT_MAX - GATEWAY_RANDOM_PORT_MIN + 1;
347
+ const candidate = GATEWAY_RANDOM_PORT_MIN + Math.floor(Math.random() * span);
348
+ if (candidate !== exclude && !GATEWAY_RANDOM_RESERVED.has(candidate)) return candidate;
349
+ }
350
+ return exclude === GATEWAY_RANDOM_PORT_MIN ? GATEWAY_RANDOM_PORT_MIN + 1 : GATEWAY_RANDOM_PORT_MIN;
351
+ }
352
+
353
+ export function parseGatewayPort(value: string): number | undefined {
354
+ const port = Number(value);
355
+ if (!Number.isInteger(port) || port < GATEWAY_PORT_MIN || port > GATEWAY_PORT_MAX) return undefined;
356
+ return port;
357
+ }
358
+
359
+ export function parseImagineCredential(value: unknown): ImagineCredentialView | undefined {
360
+ if (!isRecord(value)) return undefined;
361
+ const configured = optionalBoolean(value["configured"]);
362
+ if (configured === undefined && value["source"] === undefined && value["writable"] === undefined) return undefined;
363
+ const source = optionalString(value["source"]);
364
+ const writable = optionalBoolean(value["writable"]);
365
+ return {
366
+ configured: configured === true,
367
+ ...(source === undefined || looksSecret(source) ? {} : { source }),
368
+ ...(writable === undefined ? {} : { writable }),
369
+ };
370
+ }
371
+
372
+ export function imagineSourceLabel(source: string | undefined, t: GrokBuildSettingsInjected["t"]): string {
373
+ if (source === undefined) return t("imagineSourceUnknown");
374
+ const mapped = IMAGINE_SOURCE_KEY[source] ?? IMAGINE_SOURCE_KEY[source.toLowerCase()];
375
+ if (mapped !== undefined) return t(mapped);
376
+ if (source.length <= 40 && /^[a-z0-9._-]+$/iu.test(source) && !looksSecret(source)) return source;
377
+ return t("imagineSourceUnknown");
378
+ }
379
+
380
+ export function modelFields(status: ProviderStatus): { available: string[]; selected: string[] } {
381
+ if (status.status !== "signed-in") return { available: [], selected: [] };
382
+ return {
383
+ available: "available" in status ? status.available : [],
384
+ selected: "selected" in status ? status.selected : [],
385
+ };
386
+ }
@@ -0,0 +1,180 @@
1
+ /** Shared inline styles using DSH design tokens. */
2
+
3
+ import type { CSSProperties } from "react";
4
+ import type { ProviderStatus } from "./types.ts";
5
+
6
+ export const pageStyle: CSSProperties = { display: "flex", flexDirection: "column", gap: 16, maxWidth: 780 };
7
+ export const titleStyle: CSSProperties = {
8
+ margin: 0,
9
+ fontSize: 20,
10
+ lineHeight: "28px",
11
+ fontWeight: 600,
12
+ color: "var(--dsw-alias-label-primary)",
13
+ };
14
+ export const bodyStyle: CSSProperties = {
15
+ margin: 0,
16
+ fontSize: 14,
17
+ lineHeight: "22px",
18
+ color: "var(--dsw-alias-label-secondary)",
19
+ };
20
+ export const cardStyle: CSSProperties = {
21
+ display: "flex",
22
+ flexDirection: "column",
23
+ gap: 14,
24
+ padding: "18px 20px",
25
+ border: "1px solid var(--dsw-alias-border-l2)",
26
+ borderRadius: 12,
27
+ background: "var(--dsw-alias-bg-module-platform)",
28
+ };
29
+ export const rowStyle: CSSProperties = {
30
+ display: "flex",
31
+ alignItems: "center",
32
+ justifyContent: "space-between",
33
+ flexWrap: "wrap",
34
+ gap: 12,
35
+ };
36
+ export const statusStyle: CSSProperties = {
37
+ display: "flex",
38
+ alignItems: "center",
39
+ gap: 9,
40
+ fontSize: 14,
41
+ fontWeight: 500,
42
+ color: "var(--dsw-alias-label-primary)",
43
+ };
44
+ export const buttonStyle: CSSProperties = {
45
+ boxSizing: "border-box",
46
+ minHeight: 34,
47
+ padding: "6px 14px",
48
+ border: "1px solid var(--dsw-alias-border-l4, rgba(127, 127, 127, 0.4))",
49
+ borderRadius: 18,
50
+ background: "var(--dsw-alias-button-elevated-fill, var(--dsw-alias-bg-layer-1))",
51
+ color: "var(--dsw-alias-label-primary)",
52
+ boxShadow: "0 1px 2px rgba(0, 0, 0, 0.18)",
53
+ font: "inherit",
54
+ fontSize: 14,
55
+ fontWeight: 500,
56
+ cursor: "pointer",
57
+ };
58
+ export const primaryButtonStyle: CSSProperties = {
59
+ ...buttonStyle,
60
+ borderColor: "#315fc7",
61
+ background: "#315fc7",
62
+ color: "#ffffff",
63
+ boxShadow: "0 1px 3px rgba(0, 0, 0, 0.28)",
64
+ fontWeight: 600,
65
+ };
66
+ export const errorStyle: CSSProperties = { ...bodyStyle, color: "var(--dsw-alias-state-error-primary)" };
67
+ export const warningStyle: CSSProperties = {
68
+ ...bodyStyle,
69
+ padding: "10px 12px",
70
+ borderRadius: 8,
71
+ background: "var(--dsw-alias-bg-layer-1)",
72
+ };
73
+ export const tipStyle: CSSProperties = {
74
+ ...bodyStyle,
75
+ padding: "10px 12px",
76
+ borderRadius: 8,
77
+ border: "1px solid var(--dsw-alias-border-l2)",
78
+ background: "var(--dsw-alias-bg-layer-1)",
79
+ color: "var(--dsw-alias-label-primary)",
80
+ };
81
+ export const codeStyle: CSSProperties = {
82
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
83
+ fontSize: 20,
84
+ letterSpacing: "0.08em",
85
+ fontWeight: 600,
86
+ color: "var(--dsw-alias-label-primary)",
87
+ };
88
+ export const monoStyle: CSSProperties = { fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" };
89
+ export const linkStyle: CSSProperties = { color: "var(--dsw-alias-brand-primary)", wordBreak: "break-all" };
90
+ export const listStyle: CSSProperties = {
91
+ display: "flex",
92
+ flexDirection: "column",
93
+ gap: 8,
94
+ margin: 0,
95
+ padding: 0,
96
+ listStyle: "none",
97
+ };
98
+ export const checkRowStyle: CSSProperties = {
99
+ display: "flex",
100
+ alignItems: "flex-start",
101
+ gap: 8,
102
+ fontSize: 14,
103
+ color: "var(--dsw-alias-label-primary)",
104
+ };
105
+ export const inputStyle: CSSProperties = {
106
+ boxSizing: "border-box",
107
+ width: "100%",
108
+ minHeight: 34,
109
+ padding: "6px 12px",
110
+ border: "1px solid var(--dsw-alias-border-l2)",
111
+ borderRadius: 8,
112
+ background: "var(--dsw-alias-bg-layer-1)",
113
+ color: "var(--dsw-alias-label-primary)",
114
+ font: "inherit",
115
+ fontSize: 13,
116
+ };
117
+ export const nestedStyle: CSSProperties = {
118
+ display: "flex",
119
+ flexDirection: "column",
120
+ gap: 8,
121
+ padding: "12px 14px",
122
+ border: "1px solid var(--dsw-alias-border-l2)",
123
+ borderRadius: 8,
124
+ background: "var(--dsw-alias-bg-layer-1)",
125
+ };
126
+ export const hintStyle: CSSProperties = { ...bodyStyle, fontSize: 13 };
127
+ export const tabNavStyle: CSSProperties = {
128
+ display: "flex",
129
+ flexWrap: "wrap",
130
+ gap: 8,
131
+ };
132
+ export const tabButtonStyle: CSSProperties = {
133
+ ...buttonStyle,
134
+ borderRadius: 10,
135
+ };
136
+ export const tabButtonActiveStyle: CSSProperties = {
137
+ ...primaryButtonStyle,
138
+ borderRadius: 10,
139
+ };
140
+ export const panelStyle: CSSProperties = {
141
+ display: "flex",
142
+ flexDirection: "column",
143
+ gap: 14,
144
+ minWidth: 0,
145
+ };
146
+ export const accountGridStyle: CSSProperties = {
147
+ display: "grid",
148
+ gridTemplateColumns: "repeat(auto-fill, minmax(320px, 1fr))",
149
+ gap: 14,
150
+ };
151
+ export const copyRowStyle: CSSProperties = {
152
+ display: "flex",
153
+ alignItems: "center",
154
+ justifyContent: "space-between",
155
+ flexWrap: "wrap",
156
+ gap: 8,
157
+ };
158
+ export const skeletonStyle: CSSProperties = {
159
+ ...cardStyle,
160
+ minHeight: 88,
161
+ background:
162
+ "linear-gradient(90deg, var(--dsw-alias-bg-layer-1) 0%, var(--dsw-alias-bg-module-platform) 50%, var(--dsw-alias-bg-layer-1) 100%)",
163
+ backgroundSize: "200% 100%",
164
+ };
165
+
166
+ export function dotStyle(
167
+ status: ProviderStatus["status"] | "loading" | "available" | "unavailable",
168
+ installed = true,
169
+ ): CSSProperties {
170
+ const color = !installed
171
+ ? "var(--dsw-alias-label-dimmed, #9aa0a6)"
172
+ : status === "signed-in" || status === "available"
173
+ ? "var(--dsw-alias-state-success-primary, #22a06b)"
174
+ : status === "error"
175
+ ? "var(--dsw-alias-state-error-primary, #d92d20)"
176
+ : status === "signing-in" || status === "loading"
177
+ ? "var(--dsw-alias-brand-primary, #1677ff)"
178
+ : "var(--dsw-alias-label-dimmed, #9aa0a6)";
179
+ return { width: 9, height: 9, borderRadius: "50%", flex: "0 0 auto", background: color };
180
+ }