rivet-design 0.28.2 → 0.28.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 (51) hide show
  1. package/dist/cli/commands/libraryOpen.js +1 -0
  2. package/dist/cli/commands/mcpServe.js +5 -1
  3. package/dist/cli/commands/open.js +13 -4
  4. package/dist/cli/commands/profile.js +8 -1
  5. package/dist/cli/commands/profileDisconnect.d.ts +3 -0
  6. package/dist/cli/commands/profileDisconnect.js +34 -0
  7. package/dist/cli/commands/serve.js +1 -0
  8. package/dist/cli/commands/shared.js +4 -1
  9. package/dist/cli/envelope.d.ts +1 -0
  10. package/dist/cli/router.js +8 -2
  11. package/dist/library/browserLaunch.d.ts +2 -1
  12. package/dist/library/browserLaunch.js +3 -2
  13. package/dist/routes/referenceProfiles.js +3 -3
  14. package/dist/server.js +2 -1
  15. package/dist/services/IntegrationsClient.d.ts +2 -1
  16. package/dist/services/IntegrationsClient.js +46 -20
  17. package/dist/services/TelemetryService.d.ts +16 -2
  18. package/dist/services/TelemetryService.js +18 -0
  19. package/dist/services/accessTokenRefresh.js +2 -2
  20. package/dist/services/profiles/DesignProfiles.d.ts +16 -0
  21. package/dist/services/profiles/DesignProfiles.js +78 -17
  22. package/dist/services/profiles/ProfileAnalysis.d.ts +3 -0
  23. package/dist/services/profiles/ProfileAnalysis.js +66 -1
  24. package/dist/services/profiles/ProfileImports.d.ts +2 -0
  25. package/dist/services/profiles/ProfileImports.js +2 -0
  26. package/dist/storage/profiles/ProfileRecords.d.ts +17 -0
  27. package/dist/storage/profiles/ProfileRecords.js +45 -7
  28. package/dist/storage/profiles/migrations.d.ts +2 -2
  29. package/dist/storage/profiles/migrations.js +7 -0
  30. package/dist/storage/profiles/schema.d.ts +48 -0
  31. package/dist/storage/profiles/schema.js +3 -0
  32. package/dist/types/api-responses.d.ts +39 -0
  33. package/dist/types/api-responses.js +12 -1
  34. package/dist/types/design-profile.d.ts +12 -0
  35. package/dist/types/design-profile.js +10 -1
  36. package/dist/utils/failureReason.js +1 -1
  37. package/dist/utils/hostedLogPrivacy.js +1 -1
  38. package/dist/utils/launchRuntime.d.ts +2 -0
  39. package/dist/utils/launchRuntime.js +12 -0
  40. package/dist/utils/skills/cli-guidance.d.ts +1 -1
  41. package/dist/utils/skills/cli-guidance.js +2 -1
  42. package/package.json +2 -2
  43. package/src/ui/dist/assets/LibraryEntry-CSU5OJwC.js +2 -0
  44. package/src/ui/dist/assets/main-B89lcZEY.css +1 -0
  45. package/src/ui/dist/assets/main-DeCxjHC1.js +204 -0
  46. package/src/ui/dist/index.html +2 -2
  47. package/src/ui/dist/pages/empty-project.html +1 -1
  48. package/src/ui/dist/pages/rivet-page.html +2 -2
  49. package/src/ui/dist/assets/LibraryEntry-B8-RtQpK.js +0 -2
  50. package/src/ui/dist/assets/main-11-ME6E3.css +0 -1
  51. package/src/ui/dist/assets/main-BGCGsyhl.js +0 -204
@@ -19,6 +19,11 @@ const GUIDANCE_SCHEMA = `CREATE TABLE guidance (id TEXT PRIMARY KEY, title TEXT
19
19
  const GUIDANCE_ATTACHMENTS_SCHEMA = `ALTER TABLE guidance ADD COLUMN attachments TEXT;`;
20
20
  const GUIDANCE_REFERENCES_SCHEMA = `ALTER TABLE guidance ADD COLUMN "references" TEXT;`;
21
21
  const GUIDANCE_VERIFIER_SCHEMA = `ALTER TABLE guidance ADD COLUMN verifier TEXT;`;
22
+ const IMPORT_OUTCOME_SCHEMA = `
23
+ ALTER TABLE import_jobs ADD COLUMN added_count INTEGER NOT NULL DEFAULT 0;
24
+ ALTER TABLE import_jobs ADD COLUMN removed_count INTEGER NOT NULL DEFAULT 0;
25
+ ALTER TABLE reference_failures ADD COLUMN reason_code TEXT;
26
+ `;
22
27
  exports.PROFILE_SCHEMA = `
23
28
  CREATE TABLE profile (singleton INTEGER PRIMARY KEY CHECK(singleton = 1), id TEXT NOT NULL UNIQUE, is_enabled INTEGER NOT NULL, revision INTEGER NOT NULL);
24
29
  CREATE TABLE sources (id TEXT PRIMARY KEY, provider TEXT NOT NULL, remote_id TEXT NOT NULL,
@@ -49,6 +54,7 @@ ${GUIDANCE_SCHEMA}
49
54
  ${GUIDANCE_ATTACHMENTS_SCHEMA}
50
55
  ${GUIDANCE_REFERENCES_SCHEMA}
51
56
  ${GUIDANCE_VERIFIER_SCHEMA}
57
+ ${IMPORT_OUTCOME_SCHEMA}
52
58
  `;
53
59
  exports.PROFILE_MIGRATIONS = [
54
60
  'ALTER TABLE import_jobs ADD COLUMN is_enumerated INTEGER NOT NULL DEFAULT 0',
@@ -62,6 +68,7 @@ exports.PROFILE_MIGRATIONS = [
62
68
  GUIDANCE_ATTACHMENTS_SCHEMA,
63
69
  GUIDANCE_REFERENCES_SCHEMA,
64
70
  GUIDANCE_VERIFIER_SCHEMA,
71
+ IMPORT_OUTCOME_SCHEMA,
65
72
  ];
66
73
  exports.PROFILE_SCHEMA_VERSION = 1 + exports.PROFILE_MIGRATIONS.length;
67
74
  //# sourceMappingURL=migrations.js.map
@@ -1008,6 +1008,38 @@ export declare const importJobs: import("drizzle-orm/sqlite-core").SQLiteTableWi
1008
1008
  identity: undefined;
1009
1009
  generated: undefined;
1010
1010
  }, {}>;
1011
+ addedCount: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1012
+ name: string;
1013
+ tableName: "import_jobs";
1014
+ dataType: "number int53";
1015
+ data: number;
1016
+ driverParam: number;
1017
+ notNull: true;
1018
+ hasDefault: true;
1019
+ isPrimaryKey: false;
1020
+ isAutoincrement: false;
1021
+ hasRuntimeDefault: false;
1022
+ enumValues: undefined;
1023
+ baseColumn: never;
1024
+ identity: undefined;
1025
+ generated: undefined;
1026
+ }, {}>;
1027
+ removedCount: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1028
+ name: string;
1029
+ tableName: "import_jobs";
1030
+ dataType: "number int53";
1031
+ data: number;
1032
+ driverParam: number;
1033
+ notNull: true;
1034
+ hasDefault: true;
1035
+ isPrimaryKey: false;
1036
+ isAutoincrement: false;
1037
+ hasRuntimeDefault: false;
1038
+ enumValues: undefined;
1039
+ baseColumn: never;
1040
+ identity: undefined;
1041
+ generated: undefined;
1042
+ }, {}>;
1011
1043
  };
1012
1044
  dialect: "sqlite";
1013
1045
  }>;
@@ -1134,6 +1166,22 @@ export declare const referenceFailures: import("drizzle-orm/sqlite-core").SQLite
1134
1166
  identity: undefined;
1135
1167
  generated: undefined;
1136
1168
  }, {}>;
1169
+ reasonCode: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1170
+ name: string;
1171
+ tableName: "reference_failures";
1172
+ dataType: "string";
1173
+ data: "timeout" | "unknown" | "aborted" | "multiple_lockfiles" | "unsupported_package_manager" | "invalid_package_manager_field" | "invalid_manifest" | "invalid_workspace" | "path_outside_workspace" | "dangling_symlink" | "version_unreadable" | "version_mismatch" | "no_install_command" | "install_failed" | "lockfile_outdated" | "engine_incompatible" | "install_script_failed" | "installer_unstoppable" | "inputs_changed" | "ENOENT" | "EACCES" | "EPERM" | "EEXIST" | "ENOTDIR" | "EISDIR" | "ELOOP" | "ENOSPC" | "EMFILE" | "EADDRINUSE" | "ECONNREFUSED" | "ECONNRESET" | "ETIMEDOUT" | "EBUSY" | "ENOTSUP" | "EINVAL" | "ENOTEMPTY" | "EROFS" | "EAI_AGAIN";
1174
+ driverParam: string;
1175
+ notNull: false;
1176
+ hasDefault: false;
1177
+ isPrimaryKey: false;
1178
+ isAutoincrement: false;
1179
+ hasRuntimeDefault: false;
1180
+ enumValues: [string, ...string[]];
1181
+ baseColumn: never;
1182
+ identity: undefined;
1183
+ generated: undefined;
1184
+ }, {}>;
1137
1185
  attempts: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1138
1186
  name: string;
1139
1187
  tableName: "reference_failures";
@@ -99,6 +99,8 @@ exports.importJobs = (0, sqlite_core_1.sqliteTable)('import_jobs', {
99
99
  total: (0, sqlite_core_1.integer)(),
100
100
  error: (0, sqlite_core_1.text)(),
101
101
  updatedAt: (0, sqlite_core_1.text)('updated_at').notNull(),
102
+ addedCount: (0, sqlite_core_1.integer)('added_count').notNull().default(0),
103
+ removedCount: (0, sqlite_core_1.integer)('removed_count').notNull().default(0),
102
104
  });
103
105
  exports.importCursors = (0, sqlite_core_1.sqliteTable)('import_cursors', {
104
106
  jobId: (0, sqlite_core_1.text)('job_id')
@@ -116,6 +118,7 @@ exports.referenceFailures = (0, sqlite_core_1.sqliteTable)('reference_failures',
116
118
  revision: (0, sqlite_core_1.integer)().notNull(),
117
119
  stage: (0, sqlite_core_1.text)({ enum: ['download', 'analysis'] }).notNull(),
118
120
  error: (0, sqlite_core_1.text)().notNull(),
121
+ reasonCode: (0, sqlite_core_1.text)('reason_code').$type(),
119
122
  attempts: (0, sqlite_core_1.integer)().notNull(),
120
123
  updatedAt: (0, sqlite_core_1.text)('updated_at').notNull(),
121
124
  }, (table) => [
@@ -129,6 +129,45 @@ export declare const ReferenceProfileStatusResponseSchema: z.ZodObject<{
129
129
  }, z.core.$strip>>;
130
130
  }, z.core.$strip>;
131
131
  export type ReferenceProfileStatusResponse = z.infer<typeof ReferenceProfileStatusResponseSchema>;
132
+ export declare const ReferenceDiscoveryResponseSchema: z.ZodUnion<readonly [z.ZodObject<{
133
+ profile: z.ZodPipe<z.ZodObject<{
134
+ id: z.ZodString;
135
+ username: z.ZodString;
136
+ title: z.ZodString;
137
+ url: z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString]>;
138
+ }, z.core.$strip>, z.ZodTransform<{
139
+ id: string;
140
+ username: string;
141
+ title: string;
142
+ url: string;
143
+ }, {
144
+ id: string;
145
+ username: string;
146
+ title: string;
147
+ url: string;
148
+ }>>;
149
+ collections: z.ZodArray<z.ZodObject<{
150
+ id: z.ZodString;
151
+ title: z.ZodString;
152
+ description: z.ZodNullable<z.ZodString>;
153
+ url: z.ZodNullable<z.ZodString>;
154
+ total: z.ZodNullable<z.ZodNumber>;
155
+ parentId: z.ZodNullable<z.ZodString>;
156
+ children: z.ZodArray<z.ZodString>;
157
+ }, z.core.$strip>>;
158
+ total: z.ZodNumber;
159
+ id: z.ZodString;
160
+ createdAt: z.ZodString;
161
+ }, z.core.$strip>, z.ZodObject<{
162
+ status: z.ZodLiteral<"authorization_required">;
163
+ provider: z.ZodEnum<{
164
+ pinterest: "pinterest";
165
+ arena: "arena";
166
+ x: "x";
167
+ }>;
168
+ authUrl: z.ZodString;
169
+ message: z.ZodString;
170
+ }, z.core.$strip>]>;
132
171
  export declare const ReferenceImportPlanSummarySchema: z.ZodObject<{
133
172
  id: z.ZodString;
134
173
  revision: z.ZodString;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VariantsUiStateUpdateSchema = exports.VariantsUiStateResponseSchema = exports.VariantsUiStateSchema = exports.AccountResponseSchema = exports.ReferenceImportPlanSummarySchema = exports.ReferenceProfileStatusResponseSchema = exports.NavigationAcknowledgementResponseSchema = exports.ViewNavigationsResponseSchema = exports.ViewNavigationSchema = exports.DirectionUpdateResponseSchema = exports.DirectionPreviewResponseSchema = exports.ProjectRuntimeResponseSchema = exports.FolderSelectionResponseSchema = exports.LibraryProjectPreviewResponseSchema = exports.LibraryProjectRemovalResponseSchema = exports.LibraryProjectResponseSchema = exports.LibraryProjectListResponseSchema = exports.LibraryViewLaunchResponseSchema = exports.BrowserSessionResponseSchema = exports.SupportTicketErrorResponseSchema = exports.VariantsErrorResponseSchema = exports.ErrorResponseSchema = void 0;
3
+ exports.VariantsUiStateUpdateSchema = exports.VariantsUiStateResponseSchema = exports.VariantsUiStateSchema = exports.AccountResponseSchema = exports.ReferenceImportPlanSummarySchema = exports.ReferenceDiscoveryResponseSchema = exports.ReferenceProfileStatusResponseSchema = exports.NavigationAcknowledgementResponseSchema = exports.ViewNavigationsResponseSchema = exports.ViewNavigationSchema = exports.DirectionUpdateResponseSchema = exports.DirectionPreviewResponseSchema = exports.ProjectRuntimeResponseSchema = exports.FolderSelectionResponseSchema = exports.LibraryProjectPreviewResponseSchema = exports.LibraryProjectRemovalResponseSchema = exports.LibraryProjectResponseSchema = exports.LibraryProjectListResponseSchema = exports.LibraryViewLaunchResponseSchema = exports.BrowserSessionResponseSchema = exports.SupportTicketErrorResponseSchema = exports.VariantsErrorResponseSchema = exports.ErrorResponseSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const design_profile_1 = require("./design-profile");
6
+ const reference_onboarding_1 = require("./reference-onboarding");
7
+ const reference_connectors_1 = require("./reference-connectors");
6
8
  const project_library_1 = require("./project-library");
7
9
  exports.ErrorResponseSchema = zod_1.z.object({ error: zod_1.z.string() });
8
10
  exports.VariantsErrorResponseSchema = zod_1.z.object({
@@ -72,6 +74,15 @@ exports.ReferenceProfileStatusResponseSchema = zod_1.z.object({
72
74
  url: zod_1.z.string().nullable(),
73
75
  })),
74
76
  });
77
+ exports.ReferenceDiscoveryResponseSchema = zod_1.z.union([
78
+ reference_onboarding_1.ReferenceDiscoverySchema,
79
+ zod_1.z.object({
80
+ status: zod_1.z.literal('authorization_required'),
81
+ provider: reference_connectors_1.AuthenticatedReferenceProviderSchema,
82
+ authUrl: zod_1.z.string().url(),
83
+ message: zod_1.z.string(),
84
+ }),
85
+ ]);
75
86
  exports.ReferenceImportPlanSummarySchema = zod_1.z.object({
76
87
  id: zod_1.z.string(),
77
88
  revision: zod_1.z.string(),
@@ -26,6 +26,18 @@ export declare const ProfileProviderSchema: z.ZodEnum<{
26
26
  image: "image";
27
27
  pdf: "pdf";
28
28
  }>;
29
+ export declare const PROFILE_IMPORT_TRIGGERS: {
30
+ readonly connect: "manual";
31
+ readonly refresh: "manual";
32
+ readonly retry: "manual";
33
+ readonly upload: "manual";
34
+ readonly attachment: "auto";
35
+ readonly resume: "auto";
36
+ readonly cooldown_retry: "auto";
37
+ };
38
+ export type ProfileImportKind = keyof typeof PROFILE_IMPORT_TRIGGERS;
39
+ export type ProfileImportStep = 'memory_start' | 'enumerate' | 'download' | 'analysis' | 'index';
40
+ export type ProfilePreparationOffReason = 'request_mode_off' | 'profile_disabled' | 'no_uploads';
29
41
  export declare const ProfileRuntimeSchema: z.ZodEnum<{
30
42
  claude: "claude";
31
43
  codex: "codex";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProfileContextSchema = exports.ProfilePacketSchema = exports.ProfilePreparationRequestSchema = exports.ProfilePreparationSchema = exports.ProfileReferenceSchema = exports.ProfileObservationSchema = exports.ProfileUsageSchema = exports.ProfileReferenceInputSchema = exports.ProfileSourceInputSchema = exports.ProfileMediaSchema = exports.ProfileVariantInputSchema = exports.ProfileVariantIdentitySchema = exports.ProfileRuntimeSchema = exports.ProfileProviderSchema = exports.isRemoteProfileProvider = exports.RemoteProfileProviderSchema = exports.PROFILE_PREPARATION_BODY_BYTES = exports.PROFILE_UPLOAD_ENCODED_BYTES = exports.PROFILE_UPLOAD_BYTES = exports.PROFILE_UPLOAD_COUNT = exports.PROFILE_CANDIDATE_IMAGE_LIMIT = void 0;
3
+ exports.ProfileContextSchema = exports.ProfilePacketSchema = exports.ProfilePreparationRequestSchema = exports.ProfilePreparationSchema = exports.ProfileReferenceSchema = exports.ProfileObservationSchema = exports.ProfileUsageSchema = exports.ProfileReferenceInputSchema = exports.ProfileSourceInputSchema = exports.ProfileMediaSchema = exports.ProfileVariantInputSchema = exports.ProfileVariantIdentitySchema = exports.ProfileRuntimeSchema = exports.PROFILE_IMPORT_TRIGGERS = exports.ProfileProviderSchema = exports.isRemoteProfileProvider = exports.RemoteProfileProviderSchema = exports.PROFILE_PREPARATION_BODY_BYTES = exports.PROFILE_UPLOAD_ENCODED_BYTES = exports.PROFILE_UPLOAD_BYTES = exports.PROFILE_UPLOAD_COUNT = exports.PROFILE_CANDIDATE_IMAGE_LIMIT = void 0;
4
4
  const variant_reference_1 = require("./variant-reference");
5
5
  const zod_1 = require("zod");
6
6
  exports.PROFILE_CANDIDATE_IMAGE_LIMIT = 6;
@@ -25,6 +25,15 @@ exports.ProfileProviderSchema = zod_1.z.enum([
25
25
  'pdf',
26
26
  'variant',
27
27
  ]);
28
+ exports.PROFILE_IMPORT_TRIGGERS = {
29
+ connect: 'manual',
30
+ refresh: 'manual',
31
+ retry: 'manual',
32
+ upload: 'manual',
33
+ attachment: 'auto',
34
+ resume: 'auto',
35
+ cooldown_retry: 'auto',
36
+ };
28
37
  exports.ProfileRuntimeSchema = zod_1.z.enum(['codex', 'claude', 'cursor']);
29
38
  exports.ProfileVariantIdentitySchema = zod_1.z
30
39
  .object({
@@ -52,7 +52,7 @@ exports.FAILURE_REASON_CODES = [
52
52
  ];
53
53
  const REASON_DETAIL_LIMIT = 400;
54
54
  const REDACTION_INPUT_LIMIT = 4_000;
55
- const ABSOLUTE_PATH = /(?<![\w.:/\\])\/(?:[\w.@+~-]+\/)+[\w.@+~-]*/g;
55
+ const ABSOLUTE_PATH = /(?<![\w.:/\\])\/(?:[\w.@+~-]+(?: [\w.@+~-]+)*\/)+[\w.@+~-]*/g;
56
56
  const REASON_CODES = new Set(exports.FAILURE_REASON_CODES);
57
57
  const ERRNO_CODES = new Set(ERRNO_REASON_CODES);
58
58
  const ERROR_NAME_REASON_CODES = new Map([
@@ -7,7 +7,7 @@ const HOSTED_LABEL_REDACTIONS = [
7
7
  /(?:https?|wss?):\/\/[^\s"'<>]+/gi,
8
8
  /\bBearer\s+[^\s,;"']+/gi,
9
9
  /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi,
10
- /(?:[A-Z]:[\\/]|\/)(?:Users|home|private|tmp|var|opt|workspace|Volumes|root|mnt|srv)[\\/][^\s"'<>]+/gi,
10
+ /(?:[A-Z]:[\\/]|\/)(?:Users|home|private|tmp|var|opt|workspace|Volumes|root|mnt|srv)[\\/](?:[^\s"'<>]+ (?=[^\s"'<>]*[\\/]))*[^\s"'<>]+/gi,
11
11
  /\b[A-Z]:[\\/][^\s"'<>]+/gi,
12
12
  /\b[\w.-]{0,32}(?:token|secret|password|passwd|api[_-]?key)[\w.-]{0,32}["']?\s{0,3}[=:]\s{0,3}["']?[^\s,;"'<>]{1,256}/gi,
13
13
  /\b(?:sk-|sk_live_|sk_test_|rk_live_|rk_test_|sb_secret_|phx_|ghp_|gho_|ghs_|ghu_|github_pat_|glpat-|xox[abprs]-)[A-Za-z0-9_-]+/g,
@@ -0,0 +1,2 @@
1
+ export declare const withLaunchRuntime: (url: string, callerAgent?: string | null) => string;
2
+ //# sourceMappingURL=launchRuntime.d.ts.map
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withLaunchRuntime = void 0;
4
+ const design_profile_1 = require("../types/design-profile");
5
+ const withLaunchRuntime = (url, callerAgent) => {
6
+ const target = new URL(url);
7
+ const runtime = design_profile_1.ProfileRuntimeSchema.safeParse(callerAgent);
8
+ target.searchParams.set('runtime', runtime.success ? runtime.data : 'unknown');
9
+ return target.toString();
10
+ };
11
+ exports.withLaunchRuntime = withLaunchRuntime;
12
+ //# sourceMappingURL=launchRuntime.js.map
@@ -1,4 +1,4 @@
1
- export declare const CLI_GUIDANCE_VERSION = 58;
1
+ export declare const CLI_GUIDANCE_VERSION = 59;
2
2
  export declare const CLI_GUIDANCE_BODY: string;
3
3
  export declare const CLI_GUIDANCE_DESCRIPTION = "Rivet \u2014 open the visual editor or explore design directions for a web app.";
4
4
  //# sourceMappingURL=cli-guidance.d.ts.map
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CLI_GUIDANCE_DESCRIPTION = exports.CLI_GUIDANCE_BODY = exports.CLI_GUIDANCE_VERSION = void 0;
4
4
  const displayLocale_1 = require("../displayLocale");
5
- exports.CLI_GUIDANCE_VERSION = 58;
5
+ exports.CLI_GUIDANCE_VERSION = 59;
6
6
  const DISPLAY_LOCALE = (0, displayLocale_1.resolveDisplayLocale)();
7
7
  exports.CLI_GUIDANCE_BODY = `Rivet helps you **explore multiple design directions** for a web app. You drive it by running \`rivet\` CLI commands. Every command prints exactly one JSON envelope on stdout (\`{ schemaVersion, ok, command, data | error }\`), routes progress to stderr, and never prompts for input.
8
8
 
@@ -105,6 +105,7 @@ The export returns \`{checks:[{id,status:"pass"|"fail"|"blocked",priority:"high"
105
105
  - \`rivet variants cancel <sessionId> --project <path>\` — cancel a running variants session.
106
106
  - \`rivet evidence capture --url <url>\` — rendered design evidence (root variables, element styles, fonts) for a reference URL.
107
107
  - \`rivet reference fetch <url>\` — Pinterest / Are.na reference data via the user's connected account. Accepts full pin/board URLs and \`pin.it\` share links. Pinterest images are downloaded into \`.rivet/references/\` and returned as absolute paths (\`data.images\`, plus \`local_path\` per pin) — view them directly and pass them to variants via \`--context-images\` instead of relaying URLs. If Pinterest returns \`status: not_connected\`, present the returned \`authUrl\` to the user and retry after they authorize. On failure the error message says exactly what to tell the user (e.g. save the pin to a board first).
108
+ - \`rivet profile disconnect <pinterest|arena|x>\` — disconnect one reference account from Rivet while retaining saved references. Requires sign-in. No running editor or worker runtime is needed. This is account-wide; source/file selection flags are rejected. Provider authorization revocation varies by provider. Until independently exposed in the MCP catalog, this remains CLI-only maintenance.
108
109
  - \`rivet auth status\` — signed-in state. A signed-out \`rivet open\` starts Rivet sign-in in the browser itself and exits 3 with \`AUTH_REQUIRED\` and \`error.nextAction.authUrl\` if the user has not finished within a short wait. Share that \`authUrl\` as a clickable link (with \`--no-browser\` it is the only way in), ask the user to finish signing in, then rerun \`rivet open\`; it picks up the finished sign-in. For \`AUTH_REQUIRED\` from other commands, run \`rivet open\` the same way, or call the \`rivet_login\` MCP tool when this host has it. \`rivet login\` stays available for the user to run themselves — never run login in your own terminal (it blocks waiting on the browser).
109
110
  - \`rivet version status\` — check the installed and latest published CLI versions without changing the installation. Returns \`installedVersion\`, \`publishedVersion\`, and \`isUpdateAvailable\`.
110
111
  - \`rivet update\` — bypass the automatic-update cache, install the latest published CLI when available, and refresh existing host registrations and agent guidance. Run it when version status reports an available update, or for explicit verification or recovery.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rivet-design",
3
- "version": "0.28.2",
3
+ "version": "0.28.3",
4
4
  "description": "Rivet is a design agent for your coding agent. It explores dozens of design directions in parallel so you can pick the one that fits.",
5
5
  "main": "dist/index.js",
6
6
  "workspaces": [
@@ -205,5 +205,5 @@
205
205
  "rivetPlugin": {
206
206
  "toolContract": "intent-v2"
207
207
  },
208
- "gitHead": "8a2d16d2418525b49e4aa448f5b82f869f7d7065"
208
+ "gitHead": "9ae0e06fae89bec6c2db38f921ba836507e5d972"
209
209
  }
@@ -0,0 +1,2 @@
1
+ var qe=r=>{throw TypeError(r)};var Ne=(r,t,a)=>t.has(r)||qe("Cannot "+a);var N=(r,t,a)=>(Ne(r,t,"read from private field"),a?a.call(r):t.get(r)),K=(r,t,a)=>t.has(r)?qe("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,a),Z=(r,t,a,n)=>(Ne(r,t,"write to private field"),n?n.call(r,a):t.set(r,a),a),Q=(r,t,a)=>(Ne(r,t,"access private method"),a);import{S as Nt,n as Ae,s as Et,r as At,Q as et,u as Pe,a as Lt,b as Rt,c as s,e as It,d as kt,f as _t,g as Ht,h as ze,i as Ct,j as Mt,p as ye,k as de,l as e,B as H,m as Le,M as Pt,o as Vt,q as Ot,t as Zt,v as Ee,w as Tt,x as tt,D as rt,y as st,z as at,A as nt,P as Ft,C as it,E as Ue,F as Dt,G as $t,H as qt,I as Ke,J as zt,K as re,L as ve,N as T,R as Ut,O as ot,T as Kt,U as ne,V as Qt,W as Bt,X as ce,Y as Wt,Z as ie,_ as q,$ as lt,a0 as je,a1 as Gt,a2 as Yt,a3 as $,a4 as ct,a5 as Jt,a6 as Xt,a7 as ue,a8 as er,a9 as Re,aa as tr,ab as rr,ac as Qe,ad as sr,ae as ar,af as nr,ag as ir,ah as or,ai as lr,aj as cr,ak as dr,al as ur,am as mr,an as hr,ao as pr,ap as fr,aq as xr,ar as br,as as gr,at as vr,au as yr,av as jr,aw as dt,ax as wr,ay as Sr,az as Nr,aA as Er,aB as Ar,aC as Lr,aD as Rr,aE as Ir,aF as kr}from"./main-DeCxjHC1.js";function Be(r,t){const a=new Set(t);return r.filter(n=>!a.has(n))}var oe,D,le,se,U,ae,me,he,pe,fe,M,Ie,ke,ut,_e,He,Ce,Xe,_r=(Xe=class extends Nt{constructor(t,a,n){super();K(this,M);K(this,oe);K(this,D);K(this,le);K(this,se);K(this,U);K(this,ae);K(this,me);K(this,he);K(this,pe);K(this,fe,[]);Z(this,oe,t),Z(this,se,n),Z(this,le,[]),Z(this,U,[]),Z(this,D,[]),this.setQueries(a)}onSubscribe(){this.listeners.size===1&&N(this,U).forEach(t=>{t.subscribe(a=>{Q(this,M,He).call(this,t,a)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,N(this,U).forEach(t=>{t.destroy()})}setQueries(t,a){Z(this,le,t),Z(this,se,a),Ae.batch(()=>{const n=N(this,U),o=Q(this,M,_e).call(this,N(this,le));o.forEach(x=>x.observer.setOptions(x.defaultedQueryOptions));const l=o.map(x=>x.observer),c=l.map(x=>x.getCurrentResult()),i=n.length!==l.length,p=l.some((x,f)=>x!==n[f]),h=i||p,S=h?!0:c.some((x,f)=>{const g=N(this,D)[f];return!g||!Et(x,g)});!h&&!S||(h&&(Z(this,fe,o),Z(this,U,l)),Z(this,D,c),this.hasListeners()&&(h&&(Be(n,l).forEach(x=>{x.destroy()}),Be(l,n).forEach(x=>{x.subscribe(f=>{Q(this,M,He).call(this,x,f)})})),Q(this,M,Ce).call(this)))})}getCurrentResult(){return N(this,D)}getQueries(){return N(this,U).map(t=>t.getCurrentQuery())}getObservers(){return N(this,U)}getOptimisticResult(t,a){const n=Q(this,M,_e).call(this,t),o=n.map(c=>c.observer.getOptimisticResult(c.defaultedQueryOptions)),l=n.map(c=>c.defaultedQueryOptions.queryHash);return[o,c=>Q(this,M,ke).call(this,c??o,a,l),()=>Q(this,M,Ie).call(this,o,n)]}},oe=new WeakMap,D=new WeakMap,le=new WeakMap,se=new WeakMap,U=new WeakMap,ae=new WeakMap,me=new WeakMap,he=new WeakMap,pe=new WeakMap,fe=new WeakMap,M=new WeakSet,Ie=function(t,a){const n=new Set;return a.map((o,l)=>{const c=t[l];return o.defaultedQueryOptions.notifyOnChangeProps?c:o.observer.trackResult(c,i=>{n.has(i)||(n.add(i),a.forEach(p=>{p.observer.trackProp(i)}))})})},ke=function(t,a,n){if(a){const o=N(this,pe),l=n!==void 0&&o!==void 0&&(o.length!==n.length||n.some((c,i)=>c!==o[i]));return(N(this,D)!==N(this,he)||l||a!==N(this,me))&&(Z(this,me,a),Z(this,he,N(this,D)),n!==void 0&&Z(this,pe,n),Z(this,ae,At(N(this,ae),a(t)))),N(this,ae)}return t},ut=function(){var t;return!((t=N(this,se))!=null&&t.combine)||N(this,U).some((a,n)=>{var o;return a.options.suspense&&((o=N(this,D)[n])==null?void 0:o.data)===void 0})},_e=function(t){const a=new Map;N(this,U).forEach(o=>{const l=o.options.queryHash;if(!l)return;const c=a.get(l);c?c.push(o):a.set(l,[o])});const n=[];return t.forEach(o=>{var i;const l=N(this,oe).defaultQueryOptions(o),c=((i=a.get(l.queryHash))==null?void 0:i.shift())??new et(N(this,oe),l);n.push({defaultedQueryOptions:l,observer:c})}),n},He=function(t,a){const n=N(this,U).indexOf(t);n!==-1&&(Z(this,D,N(this,D).slice()),N(this,D)[n]=a,Q(this,M,Ce).call(this))},Ce=function(){var t;if(this.hasListeners()){const a=Q(this,M,ut).call(this),n=N(this,ae),o=a?n:Q(this,M,ke).call(this,Q(this,M,Ie).call(this,N(this,D),N(this,fe)),(t=N(this,se))==null?void 0:t.combine);(a||n!==o)&&Ae.batch(()=>{this.listeners.forEach(l=>{l(N(this,D))})})}},Xe);function Hr({queries:r,...t},a){const n=Pe(),o=Lt(),l=Rt(),c=t.subscribed!==!1,i=s.useMemo(()=>r.map(b=>{const A=n.defaultQueryOptions(b);return A._optimisticResults=o?"isRestoring":c?"optimistic":void 0,A}),[r,n,o,c]);i.forEach(b=>{It(b);const A=n.getQueryCache().get(b.queryHash);kt(b,l,A)}),_t(l);const[p]=s.useState(()=>new _r(n,i,t)),[h,S,x]=p.getOptimisticResult(i,t.combine);s.useEffect(()=>{p.setQueries(i,t)},[i,t,p]);const f=!o&&c;s.useSyncExternalStore(s.useCallback(b=>f?p.subscribe(Ae.batchCalls(b)):Ht,[p,f]),()=>p.getCurrentResult(),()=>p.getCurrentResult());const g=h.some((b,A)=>ze(i[A],b))?h.flatMap((b,A)=>{const j=i[A];if(j&&ze(j,b)){const k=new et(n,j);return Ct(j,k,l)}return[]}):[];if(g.length>0)throw Promise.all(g);const R=h.find((b,A)=>{const j=i[A];return j&&Mt({result:b,errorResetBoundary:l,throwOnError:j.throwOnError,query:n.getQueryCache().get(j.queryHash),suspense:j.suspense})});if(R)throw R.error;return S(x())}const Cr=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M228,128a12,12,0,0,1-12,12H69l51.52,51.51a12,12,0,0,1-17,17l-72-72a12,12,0,0,1,0-17l72-72a12,12,0,0,1,17,17L69,116H216A12,12,0,0,1,228,128Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M112,56V200L40,128Z",opacity:"0.2"}),s.createElement("path",{d:"M216,120H120V56a8,8,0,0,0-13.66-5.66l-72,72a8,8,0,0,0,0,11.32l72,72A8,8,0,0,0,120,200V136h96a8,8,0,0,0,0-16ZM104,180.69,51.31,128,104,75.31Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H120v64a8,8,0,0,1-13.66,5.66l-72-72a8,8,0,0,1,0-11.32l72-72A8,8,0,0,1,120,56v64h96A8,8,0,0,1,224,128Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M222,128a6,6,0,0,1-6,6H54.49l61.75,61.76a6,6,0,1,1-8.48,8.48l-72-72a6,6,0,0,1,0-8.48l72-72a6,6,0,0,1,8.48,8.48L54.49,122H216A6,6,0,0,1,222,128Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H59.31l58.35,58.34a8,8,0,0,1-11.32,11.32l-72-72a8,8,0,0,1,0-11.32l72-72a8,8,0,0,1,11.32,11.32L59.31,120H216A8,8,0,0,1,224,128Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M220,128a4,4,0,0,1-4,4H49.66l65.17,65.17a4,4,0,0,1-5.66,5.66l-72-72a4,4,0,0,1,0-5.66l72-72a4,4,0,0,1,5.66,5.66L49.66,124H216A4,4,0,0,1,220,128Z"}))]]),Mr=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M204,64V168a12,12,0,0,1-24,0V93L72.49,200.49a12,12,0,0,1-17-17L163,76H88a12,12,0,0,1,0-24H192A12,12,0,0,1,204,64Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M192,64V168L88,64Z",opacity:"0.2"}),s.createElement("path",{d:"M192,56H88a8,8,0,0,0-5.66,13.66L128.69,116,58.34,186.34a8,8,0,0,0,11.32,11.32L140,127.31l46.34,46.35A8,8,0,0,0,200,168V64A8,8,0,0,0,192,56Zm-8,92.69-38.34-38.34h0L107.31,72H184Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M200,64V168a8,8,0,0,1-13.66,5.66L140,127.31,69.66,197.66a8,8,0,0,1-11.32-11.32L128.69,116,82.34,69.66A8,8,0,0,1,88,56H192A8,8,0,0,1,200,64Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M198,64V168a6,6,0,0,1-12,0V78.48L68.24,196.24a6,6,0,0,1-8.48-8.48L177.52,70H88a6,6,0,0,1,0-12H192A6,6,0,0,1,198,64Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M200,64V168a8,8,0,0,1-16,0V83.31L69.66,197.66a8,8,0,0,1-11.32-11.32L172.69,72H88a8,8,0,0,1,0-16H192A8,8,0,0,1,200,64Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M196,64V168a4,4,0,0,1-8,0V73.66L66.83,194.83a4,4,0,0,1-5.66-5.66L182.34,68H88a4,4,0,0,1,0-8H192A4,4,0,0,1,196,64Z"}))]]),Pr=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M231,112a12,12,0,0,0-10.81-1.65l-23.81,7.93a12,12,0,0,0-7.34,6.93l-13.67,34.18-34.18,13.67a12,12,0,0,0-6.93,7.34l-7.93,23.81A12,12,0,0,0,137.73,220H216a20,20,0,0,0,20-20V121.73A12,12,0,0,0,231,112Zm-19,84H154.38l.91-2.73,33.79-13.51a12,12,0,0,0,6.68-6.68l13.51-33.79,2.73-.91Zm4-160H40A20,20,0,0,0,20,56V200a20,20,0,0,0,20,20H95.57A12,12,0,0,0,107,211.79L123.21,163l35.09-14A12,12,0,0,0,165,142.3l14-35.09L227.79,91A12,12,0,0,0,236,79.57V56A20,20,0,0,0,216,36ZM102.2,150.16,86.92,196H44V173.66l48-48,17.14,17.14h0A12,12,0,0,0,102.2,150.16ZM212,70.92,166.16,86.2a12,12,0,0,0-7.35,6.93l-14.2,35.48-11.22,4.49-27.25-27.24a20,20,0,0,0-28.28,0L44,139.72V60H212Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M224,56V88l-48,16-16,40-23.35,9.34-39-39a8,8,0,0,0-11.32,0L32,168.69V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z",opacity:"0.2"}),s.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16h64a8,8,0,0,0,7.59-5.47l14.83-44.48L163,151.43a8.07,8.07,0,0,0,4.46-4.46l14.62-36.55,44.48-14.83A8,8,0,0,0,232,88V56A16,16,0,0,0,216,40ZM112.41,157.47,98.23,200H40V172l52-52,30.42,30.42L117,152.57A8,8,0,0,0,112.41,157.47ZM216,82.23,173.47,96.41a8,8,0,0,0-4.9,4.62l-14.72,36.82L138.58,144l-35.27-35.27a16,16,0,0,0-22.62,0L40,149.37V56H216Zm12.68,33a8,8,0,0,0-7.21-1.1l-23.8,7.94a8,8,0,0,0-4.9,4.61l-14.31,35.77-35.77,14.31a8,8,0,0,0-4.61,4.9l-7.94,23.8A8,8,0,0,0,137.73,216H216a16,16,0,0,0,16-16V121.73A8,8,0,0,0,228.68,115.24ZM216,200H148.83l3.25-9.75,35.51-14.2a8.07,8.07,0,0,0,4.46-4.46l14.2-35.51,9.75-3.25Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16h64a8,8,0,0,0,7.59-5.47l14.83-44.48L163,151.43a8.07,8.07,0,0,0,4.46-4.46l14.62-36.55,44.48-14.83A8,8,0,0,0,232,88V56A16,16,0,0,0,216,40ZM117,152.57a8,8,0,0,0-4.62,4.9L98.23,200H40V160.69l46.34-46.35a8,8,0,0,1,11.32,0l32.84,32.84Zm115-30.84V200a16,16,0,0,1-16,16H137.73a8,8,0,0,1-7.59-10.53l7.94-23.8a8,8,0,0,1,4.61-4.9l35.77-14.31,14.31-35.77a8,8,0,0,1,4.9-4.61l23.8-7.94A8,8,0,0,1,232,121.73Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,42H40A14,14,0,0,0,26,56V200a14,14,0,0,0,14,14h64a6,6,0,0,0,5.69-4.1l15.12-45.36,37.42-15a6,6,0,0,0,3.34-3.34l15-37.42L225.9,93.69A6,6,0,0,0,230,88V56A14,14,0,0,0,216,42ZM117.77,154.43a6,6,0,0,0-3.46,3.67L99.68,202H40a2,2,0,0,1-2-2V171.17l52.58-52.58a2,2,0,0,1,2.83,0L126,151.15ZM218,83.68,174.1,98.31a6,6,0,0,0-3.67,3.46l-15.05,37.61L138.1,146.3l-36.2-36.2a14,14,0,0,0-19.8,0L38,154.2V56a2,2,0,0,1,2-2H216a2,2,0,0,1,2,2Zm9.51,33.18a6,6,0,0,0-5.41-.82L198.3,124a6,6,0,0,0-3.67,3.47L180,164l-36.56,14.63A6,6,0,0,0,140,182.3L132,206.1a6,6,0,0,0,5.69,7.9H216a14,14,0,0,0,14-14V121.73A6,6,0,0,0,227.51,116.86ZM218,200a2,2,0,0,1-2,2H146.06l4.42-13.26,36.37-14.55a6,6,0,0,0,3.34-3.34l14.55-36.37L218,130.06Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16h64a8,8,0,0,0,7.59-5.47l14.83-44.48L163,151.43a8.07,8.07,0,0,0,4.46-4.46l14.62-36.55,44.48-14.83A8,8,0,0,0,232,88V56A16,16,0,0,0,216,40ZM112.41,157.47,98.23,200H40V172l52-52,30.42,30.42L117,152.57A8,8,0,0,0,112.41,157.47ZM216,82.23,173.47,96.41a8,8,0,0,0-4.9,4.62l-14.72,36.82L138.58,144l-35.27-35.27a16,16,0,0,0-22.62,0L40,149.37V56H216Zm12.68,33a8,8,0,0,0-7.21-1.1l-23.8,7.94a8,8,0,0,0-4.9,4.61l-14.31,35.77-35.77,14.31a8,8,0,0,0-4.61,4.9l-7.94,23.8A8,8,0,0,0,137.73,216H216a16,16,0,0,0,16-16V121.73A8,8,0,0,0,228.68,115.24ZM216,200H148.83l3.25-9.75,35.51-14.2a8.07,8.07,0,0,0,4.46-4.46l14.2-35.51,9.75-3.25Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,44H40A12,12,0,0,0,28,56V200a12,12,0,0,0,12,12h64a4,4,0,0,0,3.79-2.74L123.21,163l38.28-15.31a4,4,0,0,0,2.22-2.22L179,107.21l46.24-15.42A4,4,0,0,0,228,88V56A12,12,0,0,0,216,44ZM118.51,156.29a4,4,0,0,0-2.3,2.45L101.12,204H40a4,4,0,0,1-4-4V170.34l53.17-53.17a4,4,0,0,1,5.66,0l34.71,34.71ZM220,85.12l-45.26,15.09a4,4,0,0,0-2.45,2.3l-15.37,38.41-19.3,7.73-37.13-37.14a12,12,0,0,0-17,0L36,159V56a4,4,0,0,1,4-4H216a4,4,0,0,1,4,4Zm6.34,33.37a4,4,0,0,0-3.6-.55l-23.81,7.93a4,4,0,0,0-2.44,2.31l-15,37.36-37.36,15a4,4,0,0,0-2.31,2.44l-7.93,23.81a4,4,0,0,0,.55,3.6,4,4,0,0,0,3.24,1.66H216a12,12,0,0,0,12-12V121.73A4,4,0,0,0,226.34,118.49ZM220,200a4,4,0,0,1-4,4H143.28l5.59-16.78,37.23-14.89a4,4,0,0,0,2.23-2.23l14.89-37.23L220,127.28Z"}))]]),Vr=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M160,88a16,16,0,1,1,16,16A16,16,0,0,1,160,88Zm76-32V160a20,20,0,0,1-20,20H204v20a20,20,0,0,1-20,20H40a20,20,0,0,1-20-20V88A20,20,0,0,1,40,68H60V56A20,20,0,0,1,80,36H216A20,20,0,0,1,236,56ZM180,180H80a20,20,0,0,1-20-20V92H44V196H180Zm-21.66-24L124,121.66,89.66,156ZM212,60H84v67.72l25.86-25.86a20,20,0,0,1,28.28,0L192.28,156H212Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M224,56v82.06l-23.72-23.72a8,8,0,0,0-11.31,0L163.31,140,113.66,90.34a8,8,0,0,0-11.32,0L64,128.69V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z",opacity:"0.2"}),s.createElement("path",{d:"M216,40H72A16,16,0,0,0,56,56V72H40A16,16,0,0,0,24,88V200a16,16,0,0,0,16,16H184a16,16,0,0,0,16-16V184h16a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM72,56H216v62.75l-10.07-10.06a16,16,0,0,0-22.63,0l-20,20-44-44a16,16,0,0,0-22.62,0L72,109.37ZM184,200H40V88H56v80a16,16,0,0,0,16,16H184Zm32-32H72V132l36-36,49.66,49.66a8,8,0,0,0,11.31,0L194.63,120,216,141.38V168ZM160,84a12,12,0,1,1,12,12A12,12,0,0,1,160,84Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,40H72A16,16,0,0,0,56,56V72H40A16,16,0,0,0,24,88V200a16,16,0,0,0,16,16H184a16,16,0,0,0,16-16V184h16a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM172,72a12,12,0,1,1-12,12A12,12,0,0,1,172,72Zm12,128H40V88H56v80a16,16,0,0,0,16,16H184Zm32-32H72V120.69l30.34-30.35a8,8,0,0,1,11.32,0L163.31,140,189,114.34a8,8,0,0,1,11.31,0L216,130.07V168Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,42H72A14,14,0,0,0,58,56V74H40A14,14,0,0,0,26,88V200a14,14,0,0,0,14,14H184a14,14,0,0,0,14-14V182h18a14,14,0,0,0,14-14V56A14,14,0,0,0,216,42ZM70,56a2,2,0,0,1,2-2H216a2,2,0,0,1,2,2v67.57L204.53,110.1a14,14,0,0,0-19.8,0l-21.42,21.41L117.9,86.1a14,14,0,0,0-19.8,0L70,114.2ZM186,200a2,2,0,0,1-2,2H40a2,2,0,0,1-2-2V88a2,2,0,0,1,2-2H58v82a14,14,0,0,0,14,14H186Zm30-30H72a2,2,0,0,1-2-2V131.17l36.58-36.58a2,2,0,0,1,2.83,0l49.66,49.66a6,6,0,0,0,8.49,0l25.65-25.66a2,2,0,0,1,2.83,0l22,22V168A2,2,0,0,1,216,170ZM162,84a10,10,0,1,1,10,10A10,10,0,0,1,162,84Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,40H72A16,16,0,0,0,56,56V72H40A16,16,0,0,0,24,88V200a16,16,0,0,0,16,16H184a16,16,0,0,0,16-16V184h16a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM72,56H216v62.75l-10.07-10.06a16,16,0,0,0-22.63,0l-20,20-44-44a16,16,0,0,0-22.62,0L72,109.37ZM184,200H40V88H56v80a16,16,0,0,0,16,16H184Zm32-32H72V132l36-36,49.66,49.66a8,8,0,0,0,11.31,0L194.63,120,216,141.38V168ZM160,84a12,12,0,1,1,12,12A12,12,0,0,1,160,84Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,44H72A12,12,0,0,0,60,56V76H40A12,12,0,0,0,28,88V200a12,12,0,0,0,12,12H184a12,12,0,0,0,12-12V180h20a12,12,0,0,0,12-12V56A12,12,0,0,0,216,44ZM68,56a4,4,0,0,1,4-4H216a4,4,0,0,1,4,4v72.4l-16.89-16.89a12,12,0,0,0-17,0l-22.83,22.83L116.49,87.51a12,12,0,0,0-17,0L68,119ZM188,200a4,4,0,0,1-4,4H40a4,4,0,0,1-4-4V88a4,4,0,0,1,4-4H60v84a12,12,0,0,0,12,12H188Zm28-28H72a4,4,0,0,1-4-4V130.34l37.17-37.17a4,4,0,0,1,5.66,0l49.66,49.66a4,4,0,0,0,5.65,0l25.66-25.66a4,4,0,0,1,5.66,0L220,139.71V168A4,4,0,0,1,216,172ZM164,84a8,8,0,1,1,8,8A8,8,0,0,1,164,84Z"}))]]),mt=s.forwardRef((r,t)=>s.createElement(ye,{ref:t,...r,weights:Cr}));mt.displayName="ArrowLeftIcon";const Or=mt,ht=s.forwardRef((r,t)=>s.createElement(ye,{ref:t,...r,weights:Mr}));ht.displayName="ArrowUpRightIcon";const pt=ht,ft=s.forwardRef((r,t)=>s.createElement(ye,{ref:t,...r,weights:Pr}));ft.displayName="ImageBrokenIcon";const Zr=ft,xt=s.forwardRef((r,t)=>s.createElement(ye,{ref:t,...r,weights:Vr}));xt.displayName="ImagesIcon";const Tr=xt,Fr=({project:r,onRename:t,onRemove:a,onSetPinned:n})=>{const o=de(),l=s.useRef(null),c=s.useRef(null),i=s.useRef(null),[p,h]=s.useState(!1),[S,x]=s.useState(!1),f=!!r.pinnedAt,[g,R]=s.useState(null),[b,A]=s.useState(r.name),[j,k]=s.useState(!1),[F,m]=s.useState(null);let B=g==="rename"?"Save name":"Remove from projects";j&&(B="Saving…"),s.useEffect(()=>{var w;if(S||!i.current)return;const y=i.current==="button"?c:l;i.current=null,(w=y.current)==null||w.focus()},[S]);const E=y=>{h(y),o==null||o.capture(y?"library_project_menu_opened":"library_project_menu_closed")},I=async y=>{if(!S){i.current=y,x(!0),o==null||o.capture("library_project_pin_clicked",{is_pinning:!f,method:y});try{await n(r.id,!f)}catch(w){it.error(Ue(w,"Could not save pin. Try again."))}finally{x(!1)}}},V=y=>{A(r.name),m(null),R(y),o==null||o.capture("library_project_action_opened",{action:y})},P=y=>{o==null||o.capture("library_project_action_closed",{action:g,outcome:y}),R(null)},C=async()=>{if(!(j||!g||g==="rename"&&!b.trim())){k(!0),m(null);try{g==="rename"?await t(r.id,b.trim()):await a(r.id),P("completed")}catch(y){m(Ue(y,"Could not save changes. Try again."))}finally{k(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex items-center gap-0.5 group-hover/project:pointer-events-auto group-hover/project:opacity-100 has-[:focus-visible]:pointer-events-auto has-[:focus-visible]:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100 ${p?"pointer-events-auto opacity-100":"pointer-events-none opacity-0"}`,children:[e.jsx(H,{ref:c,type:"button",variant:"ghost",size:"icon-compact",title:f?"Unpin project":"Pin project","aria-label":`${f?"Unpin":"Pin"} ${r.name}`,"aria-pressed":f,disabled:S,onClick:()=>{I("button")},children:e.jsx(Le,{weight:f?"fill":"bold",size:16,"aria-hidden":!0})}),e.jsxs(Pt,{isOpen:p,onOpenChange:E,children:[e.jsx(Vt,{asChild:!0,children:e.jsx(H,{ref:l,type:"button",variant:"ghost",size:"icon-compact","aria-label":`Actions for ${r.name}`,children:e.jsx(Ot,{size:16,weight:"bold","aria-hidden":!0})})}),e.jsxs(Zt,{"data-rivet-private":!0,"aria-label":"Project actions",align:"start",onCloseAutoFocus:y=>{g&&y.preventDefault()},className:"ph-no-capture min-w-44",children:[e.jsxs(Ee,{disabled:S,onSelect:()=>void I("menu"),children:[e.jsx(Le,{size:14,weight:f?"fill":"bold","aria-hidden":!0}),f?"Unpin":"Pin"]}),e.jsxs(Ee,{onSelect:()=>V("rename"),children:[e.jsx(Tt,{size:14,weight:"bold","aria-hidden":!0}),"Rename"]}),e.jsxs(Ee,{onSelect:()=>V("remove"),children:[e.jsx(tt,{size:14,weight:"bold","aria-hidden":!0}),"Remove from projects"]})]})]})]}),e.jsx(rt,{open:g!==null,onOpenChange:y=>{!y&&!j&&P("cancelled")},children:e.jsxs(st,{surface:"library","data-rivet-private":!0,onCloseAutoFocus:y=>{var w;y.preventDefault(),(w=l.current)==null||w.focus()},className:"ph-no-capture w-[calc(100%-2rem)] max-w-sm",children:[e.jsx(at,{className:"text-base font-medium break-words",children:g==="rename"?"Rename project":`Remove “${r.name}” from projects?`}),e.jsx(nt,{className:"mt-2 text-sm leading-6 text-white/60",children:g==="rename"?"Choose a display name for this project. Its folder name will stay the same.":"Your folders and saved variants will remain on this computer. Open the project again to restore it."}),e.jsxs("form",{onSubmit:y=>{y.preventDefault(),C()},children:[g==="rename"?e.jsxs("label",{className:"mt-5 block text-xs text-white/70",children:["Project name",e.jsx("input",{autoFocus:!0,value:b,onChange:y=>A(y.target.value),maxLength:Ft,disabled:j,className:"focus:border-soft-foreground mt-2 w-full rounded-lg border border-white/15 bg-white/5 px-3 py-2 text-sm text-white focus-visible:outline-hidden transition-colors"})]}):null,F?e.jsx("p",{role:"alert",className:"text-muted-foreground mt-4 text-xs",children:F}):null,e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(H,{type:"button",variant:"ghost",disabled:j,onClick:()=>P("cancelled"),children:"Cancel"}),e.jsx(H,{type:"submit",variant:"secondary",disabled:j||g==="rename"&&!b.trim(),children:B})]})]})]})})]})},bt=6e4,gt=60*bt,we=24*gt,Dr=7*we,$r=30*we,qr=365*we,zr=[["year",qr],["month",$r],["week",Dr],["day",we],["hour",gt],["minute",bt]],Ur=new Intl.RelativeTimeFormat("en",{numeric:"always"}),Kr=r=>{const t=new Map;for(const a of r??[]){const n=Date.parse(a.createdAt);if(!Number.isFinite(n))continue;const o=t.get(a.projectId);(o===void 0||n>o)&&t.set(a.projectId,n)}return t},Qr=({projects:r,latestEdits:t})=>[...r].sort((a,n)=>{if(a.pinnedAt&&!n.pinnedAt)return-1;if(n.pinnedAt&&!a.pinnedAt)return 1;if(a.pinnedAt&&n.pinnedAt)return a.pinnedAt.localeCompare(n.pinnedAt)||a.id.localeCompare(n.id);const o=t.get(a.id),l=t.get(n.id);return o===void 0&&l!==void 0?1:l===void 0&&o!==void 0?-1:(l??0)-(o??0)||a.name.localeCompare(n.name)||a.id.localeCompare(n.id)}),Br=({editedAt:r,now:t})=>{const a=Math.max(0,t-r);for(const[n,o]of zr)if(a>=o)return`Edited ${Ur.format(-Math.floor(a/o),n)}`;return"Edited just now"},vt=s.createContext(null),Wr=({navigation:r,onBrowseProjects:t,controls:a,isHeaderVisible:n=!0,children:o})=>{const[l,c]=s.useState(null);return e.jsxs(vt.Provider,{value:l,children:[n?e.jsxs("div",{className:"grid shrink-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-4 px-10 py-5 max-sm:px-5 sm:grid-cols-[auto_minmax(0,1fr)_auto]",children:[e.jsx("button",{onClick:t,"aria-label":"Projects",className:"hover:bg-hover focus-visible:border-muted-foreground focus-visible:bg-active -m-1 flex items-center rounded-lg border border-transparent p-[3px] transition-colors focus-visible:outline-hidden",children:e.jsx("img",{src:Dt,alt:"","aria-hidden":!0,draggable:!1,className:"h-8 w-8"})}),e.jsx("div",{ref:c,className:"col-span-2 row-start-2 flex min-w-0 items-center gap-3 sm:col-span-1 sm:col-start-2 sm:row-start-1",children:a}),e.jsx("div",{className:"col-start-2 row-start-1 justify-self-end sm:col-start-3",children:r})]}):null,o]})},Me=({children:r})=>{const t=s.useContext(vt);return t?$t.createPortal(r,t):null},Ve=({label:r,value:t,onChange:a,onBlur:n,isDisabled:o=!1})=>e.jsxs("label",{className:"not-focus-within:has-[:enabled]:hover:border-border focus-within:border-muted-foreground focus-within:bg-hover focus-within:text-soft-foreground flex w-64 min-w-0 items-center gap-2 rounded-lg border border-white/[0.08] bg-white/[0.02] px-3 py-2.5 text-white/35 transition-colors max-sm:flex-1",children:[e.jsx(qt,{size:14,weight:"bold",className:"shrink-0","aria-hidden":!0}),e.jsx("input",{type:"search","aria-label":r,placeholder:`${r}…`,value:t,onChange:l=>a==null?void 0:a(l.target.value),onBlur:n,disabled:o,className:"min-w-0 flex-1 bg-transparent text-xs text-white focus-visible:outline-hidden placeholder:text-white/30 disabled:opacity-40 [&::-webkit-search-cancel-button]:hidden"})]}),Gr=({projects:r,variants:t,historyError:a,onRetryHistory:n,projectPreviews:o={},selectedProjectId:l,onSelectProject:c,onBrowseLibrary:i,onOpenProject:p,onRenameProject:h,onRemoveProject:S,onSetProjectPinned:x,isOpeningProject:f=!1,projectOpenError:g,onSearchCompleted:R,accountMenu:b,navigation:A,view:j="library",children:k})=>{const[F,m]=s.useState(""),B=l===null||k===void 0,E=s.useRef(null),I=Kr(t),[V]=s.useState(Date.now),P=r.find(w=>w.id===l),C=new Map;if(t)for(const w of r)w.historyIssue||C.set(w.id,0);for(const{projectId:w}of t??[]){const z=C.get(w);z!==void 0&&C.set(w,z+1)}const y=Qr({projects:r.filter(w=>w.name.toLowerCase().includes(F.toLowerCase())),latestEdits:I});return e.jsx("div",{className:"ph-no-capture bg-background text-foreground flex h-screen min-h-0","data-rivet-private":!0,children:e.jsx("main",{className:"relative flex min-w-0 flex-1 flex-col overflow-hidden",children:e.jsxs(Wr,{navigation:A,onBrowseProjects:i,isHeaderVisible:B,controls:j==="library"?e.jsx(Ve,{label:"Search projects",value:F,onChange:m,onBlur:()=>R==null?void 0:R(F.length)}):null,children:[g?e.jsx("p",{role:"alert",className:"text-muted-foreground px-10 pt-5 text-xs",children:g}):null,k!==void 0?k:e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-10 pb-10 max-sm:px-5",children:[e.jsx("h1",{ref:E,tabIndex:-1,className:"sr-only",children:"Projects"}),e.jsx("div",{className:"mb-9 flex items-center justify-end",children:e.jsx(H,{onClick:()=>p(),variant:"secondary",disabled:f,leadingIcon:Ke,className:"shrink-0",children:"Open project…"})}),a?e.jsxs("div",{role:"alert",className:"mb-6 flex items-center gap-3 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:a}),e.jsx(H,{onClick:n,variant:"ghost",size:"compact",className:"shrink-0",children:"Retry history"})]}):null,P!=null&&P.issue?e.jsx("p",{role:"alert",className:"border-accent-warning/10 bg-accent-warning/[0.03] mb-6 rounded-lg border p-4 text-xs leading-6 text-white/70",children:P.issue}):null,P&&!P.isAvailable?e.jsxs("div",{className:"border-accent-warning/10 bg-accent-warning/[0.03] mb-6 flex items-center justify-between gap-4 rounded-lg border p-4 text-xs text-white/60",children:[e.jsxs("span",{children:["Locate ",P.name,"’s working folder to open its workspace."]}),e.jsx(H,{disabled:f,onClick:()=>p(P.id),variant:"secondary",size:"compact",className:"shrink-0",children:"Locate folder"})]}):null,e.jsxs("div",{className:"grid items-start gap-x-6 gap-y-8 sm:grid-cols-2",children:[y.map(w=>{const z=C.get(w.id);let te="Loading variants…";z!==void 0?te=`${z.toLocaleString()} ${z===1?"variant":"variants"}`:(a||w.historyIssue)&&(te="Variants unavailable");const W=I.get(w.id);let Y="No edits yet";a||w.historyIssue?Y="Edit history unavailable":t===void 0?Y="Loading edits…":z&&(Y="Edit date unavailable");const J=o[w.id];return e.jsxs("div",{className:"group/project grid min-w-0",children:[e.jsxs("button",{onClick:()=>{m(""),c(w.id)},className:"group hover:bg-hover focus-visible:bg-active col-start-1 row-span-2 row-start-1 -m-2 grid w-[calc(100%+1rem)] min-w-0 grid-rows-subgrid rounded-2xl p-2 text-left transition-colors focus-visible:outline-hidden",children:[e.jsx("span",{className:"group-hover:border-border group-focus-visible:border-muted-foreground relative block aspect-video overflow-hidden rounded-xl border border-white/[0.08] bg-white/[0.02]",children:J?e.jsx("img",{src:J.dataUrl,alt:`${w.name} — ${J.label}`,draggable:!1,className:"h-full w-full object-cover object-top"}):null}),e.jsxs("span",{className:"mt-3 block pr-16",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-sm font-medium",children:[w.pinnedAt?e.jsx(Le,{size:12,weight:"fill","aria-hidden":!0,className:"text-soft-foreground shrink-0"}):null,e.jsx("span",{className:"truncate",children:w.name})]}),e.jsxs("span",{className:"text-muted-foreground group-hover:text-soft-foreground group-focus-visible:text-soft-foreground mt-2 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs",children:[W!==void 0?e.jsx("time",{dateTime:new Date(W).toISOString(),title:new Date(W).toLocaleString(),children:Br({editedAt:W,now:V})}):e.jsx("span",{children:Y}),e.jsx("span",{className:"shrink-0",children:te})]}),w.isAvailable?null:e.jsx("span",{className:"text-accent-warning mt-2 block text-xs",children:"Folder unavailable"})]})]}),e.jsx("div",{className:"z-content col-start-1 row-start-2 mt-3 self-center justify-self-end",children:e.jsx(Fr,{project:w,onRename:h,onSetPinned:x,onRemove:async u=>{var L;await S(u),(L=E.current)==null||L.focus()}})})]},w.id)}),y.length===0?e.jsxs("div",{className:"col-span-full flex min-h-80 flex-col items-center justify-center rounded-xl border border-dashed border-white/10 px-8 text-center",children:[e.jsx(Ke,{size:26,weight:"bold",className:"mb-5 text-white/25","aria-hidden":!0}),e.jsx("h2",{className:"text-sm font-medium",children:F?"No matching projects":"Add your projects"}),e.jsx("p",{className:"text-muted-foreground mt-2 max-w-sm text-xs leading-6",children:F?"Try another project name.":"Open an existing project to add it as a project here"}),F?null:e.jsx(H,{onClick:()=>p(),variant:"secondary",disabled:f,className:"mt-5",children:"Open project"})]}):null]})]}),B&&b?e.jsx("footer",{className:"border-surface-2 bg-card shrink-0 border-t px-2.5 py-2.5",children:b}):null]})})})},yt=8,We=1,Yr=({children:r})=>e.jsx("ul",{className:"grid grid-cols-1 items-start gap-x-5 min-[400px]:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5",style:{gridAutoRows:`${yt}px`},children:r}),Jr=({children:r})=>{const[t,a]=s.useState(We),n=s.useRef(null),o=s.useCallback(l=>{var i;if((i=n.current)==null||i.disconnect(),!l)return;const c=()=>a(Math.max(We,Math.ceil(l.getBoundingClientRect().height/yt)));c(),n.current=new ResizeObserver(c),n.current.observe(l)},[]);return e.jsx("li",{className:"min-w-0",style:{gridRowEnd:`span ${t}`},children:e.jsx("div",{ref:o,className:"relative pb-8",children:r})})},Xr=async({profileId:r,referenceId:t,hash:a,signal:n})=>{const o=await zt(`/api/library/profile/references/${encodeURIComponent(t)}/media/${a}?${new URLSearchParams({profileId:r})}`,{signal:n});if(!o.ok)throw new Error("Image unavailable");return o.blob()},es="200px",jt=({profileId:r,referenceId:t,hash:a,title:n,isDetail:o=!1})=>{const[l,c]=s.useState(!1),[i,p]=s.useState(!1),h=s.useRef(null),S=s.useCallback(g=>{var R;(R=h.current)==null||R.disconnect(),g&&(h.current=new IntersectionObserver(b=>{var A;b.some(j=>j.isIntersecting)&&(c(!0),(A=h.current)==null||A.disconnect())},{rootMargin:es}),h.current.observe(g))},[]),x=re({queryKey:T.designLibraryImage({profileId:r,referenceId:t,hash:a}),queryFn:async({signal:g})=>{const R=await Xr({profileId:r,referenceId:t,hash:a,signal:g});return new Promise((b,A)=>{const j=new FileReader;j.onload=()=>typeof j.result=="string"?b(j.result):A(new Error("Image unavailable")),j.onerror=()=>A(new Error("Image unavailable")),j.readAsDataURL(R)})},enabled:l,staleTime:1/0,gcTime:0,retry:!1}),f=!!x.data&&!i;return e.jsxs("div",{ref:S,className:ve("flex items-center justify-center overflow-hidden bg-white/[0.025]",o?"min-h-32":null,!o&&!f?"aspect-[4/3]":null),children:[x.isError||i?e.jsxs("span",{className:"text-muted-foreground flex items-center gap-2 p-5 text-xs",children:[e.jsx(Zr,{size:16,weight:"bold","aria-hidden":!0}),"Image unavailable"]}):null,x.data&&!i?e.jsx("img",{src:x.data,alt:n,onError:()=>p(!0),className:o?"max-h-[65vh] w-full object-contain":"block h-auto w-full"}):null,!x.data&&!x.isError?e.jsx("span",{className:"text-muted-foreground text-xs",children:"Loading image…"}):null]})},ts={arena:"Are.na",cosmos:"Cosmos",pinterest:"Pinterest",x:"X",image:"Uploaded image",text:"Saved text",variant:"Saved direction",pdf:"PDF"},rs=({provider:r})=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[r==="arena"||r==="cosmos"||r==="pinterest"||r==="x"?e.jsx(Ut,{provider:r,className:"h-3.5 w-3.5"}):null,ts[r]]}),ss=({label:r,onCopy:t,referenceCount:a=1,provider:n})=>{const o=de(),[l,c]=s.useState("idle"),i=async()=>{c("copying");try{await t(),c("copied"),o==null||o.capture("library_reference_copy_completed",{reference_count:a,copy_kind:"agent",...n?{provider:n}:{}})}catch{c("failed"),it.error("Could not copy. Check clipboard access and try again."),o==null||o.capture("library_reference_copy_failed",{reference_count:a,copy_kind:"agent",...n?{provider:n}:{}})}},p=l==="copied"?ot:Kt,h=l==="copied"?"Copied":r;return e.jsxs(e.Fragment,{children:[e.jsx(H,{variant:"secondary",size:"compact",leadingIcon:p,disabled:l==="copying",onClick:()=>void i(),"aria-label":h,"aria-live":"polite",children:e.jsxs("span",{className:"grid whitespace-nowrap",children:[e.jsx("span",{"aria-hidden":!0,className:"invisible col-start-1 row-start-1",children:r}),e.jsx("span",{className:"col-start-1 row-start-1",children:h})]})}),l==="failed"?e.jsx("span",{role:"alert",className:"sr-only",children:"Could not copy. Check clipboard access and try again."}):null]})},wt=ne({id:q(),title:q(),provider:lt,isIncluded:je()}),as=Qt.extend({sourceIds:ce(q()),observation:Bt.nullable()}),ns=ne({profileId:q(),revision:ie(),isEnabled:je(),sources:ce(wt),references:ce(as)});ne({query:q().trim().min(2).max(1e3),sourceId:q().min(1).max(200).optional(),limit:ie().int().min(1).max(100).default(24),runtime:Wt.default("codex")});const is=ne({profileId:q(),query:q(),coverage:ne({saved:ie(),analyzed:ie(),indexed:ie()}),results:ce(ne({id:q(),key:q(),title:q(),provider:lt,url:q().optional(),description:q().nullable(),imageCount:ie(),sources:ce(wt),isIncluded:je()}))}),St=50,Ge=12,os=q().regex(/^[a-f0-9]{12,64}@[1-9][0-9]*$/).refine(r=>Number.isSafeInteger(Number(r.split("@")[1])),"Invalid reference revision"),ls=ne({profileId:q().uuid(),keys:ce(os).min(1).max(St),isDetailed:je().default(!1)}),cs=r=>{const t=new Map;for(const a of r){const n=a.id.slice(0,Ge);t.set(n,(t.get(n)??0)+1)}return new Map(r.map(a=>{const n=a.id.slice(0,Ge),o=t.get(n)===1?n:a.id;return[a.id,`${o}@${a.revision}`]}))},ds=r=>{const t=new Set(r);return t.size>1?"mixed":[...t][0]},us=({profileId:r,referenceKeys:t})=>{const a=ls.parse({profileId:r,keys:t});return["rivet","profile","reference",a.profileId,...a.keys].join(" ")},Oe=r=>{const t=r.referenceKeys.length===1?"Copy to agent":`Copy ${r.referenceKeys.length} to agent`;return e.jsx(ss,{label:t,referenceCount:r.referenceKeys.length,provider:ds(r.providers),onCopy:()=>navigator.clipboard.writeText(us(r))})},ms=({profileId:r,reference:t,sources:a,referenceKey:n,children:o})=>{var p,h;const l=de(),c=t.title||"Untitled reference",i=t.url&&/^https?:\/\//i.test(t.url)?t.url:void 0;return e.jsxs(rt,{onOpenChange:S=>l==null?void 0:l.capture(S?"library_reference_opened":"library_reference_closed",{provider:t.provider,media_count:t.media.length}),children:[e.jsx(Gt,{asChild:!0,children:o}),e.jsxs(st,{surface:"librarySheet",className:"ph-no-capture w-full max-w-2xl","data-rivet-private":!0,children:[e.jsxs("header",{className:"flex items-start justify-between gap-6 border-b border-white/[0.07] px-7 py-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(nt,{className:"text-muted-foreground mb-2 text-xs",children:e.jsx(rs,{provider:t.provider})}),e.jsx(at,{className:"text-lg leading-snug font-medium tracking-tight break-words",children:c})]}),e.jsx(Yt,{asChild:!0,children:e.jsx(H,{variant:"ghost",size:"icon-compact","aria-label":"Close reference",children:e.jsx(tt,{size:18,weight:"bold","aria-hidden":!0})})})]}),e.jsx("div",{className:"border-b border-white/[0.07] px-7 py-4",children:e.jsx(Oe,{profileId:r,referenceKeys:[n],providers:[t.provider]},t.revision)}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-7 overflow-y-auto px-7 py-6",children:[t.media.map(S=>e.jsx(jt,{profileId:r,referenceId:t.id,hash:S.hash,title:c,isDetail:!0},S.hash)),t.text?e.jsx("p",{className:"text-sm leading-7 break-words whitespace-pre-wrap text-white/70",children:t.text}):null,t.note?e.jsxs("section",{children:[e.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-medium",children:"Your note"}),e.jsx("p",{className:"text-sm leading-7 break-words whitespace-pre-wrap text-white/75",children:t.note})]}):null,e.jsxs("section",{children:[e.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-medium",children:((p=t.observation)==null?void 0:p.evidence)==="preference"?"Your preference":"Rivet’s analysis"}),e.jsx("p",{className:"text-sm leading-7 break-words whitespace-pre-wrap text-white/75",children:((h=t.observation)==null?void 0:h.description)??t.unsupportedReason??"No analysis saved yet."})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-muted-foreground mb-3 text-xs font-medium",children:"Saved in"}),e.jsx("ul",{className:"space-y-2",children:a.filter(S=>t.sourceIds.includes(S.id)).map(S=>e.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md bg-white/[0.035] px-3 py-2.5 text-xs",children:[e.jsx("span",{children:S.title}),S.isIncluded?null:e.jsx("span",{className:"text-muted-foreground",children:"Excluded from generation"})]},S.id))})]}),i?e.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",onClick:()=>l==null?void 0:l.capture("library_reference_original_opened",{provider:t.provider}),className:"hover:text-foreground focus-visible:text-foreground focus-visible:bg-active -mx-1.5 -my-1 inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-white/70 underline-offset-4 transition-colors focus-visible:outline-hidden hover:underline focus-visible:underline",children:["Open original",e.jsx(pt,{size:14,weight:"bold","aria-hidden":!0})]}):null]})]})]})},Ye="opacity-0 group-hover/card:opacity-100 group-focus-within/card:opacity-100 [@media(hover:none)]:opacity-100",hs="pointer-events-none group-hover/card:pointer-events-auto group-focus-within/card:pointer-events-auto [@media(hover:none)]:pointer-events-auto",ps=({profileId:r,reference:t,sources:a,referenceKey:n,isSelected:o,isSelectionDisabled:l,onSelect:c})=>{var h;const i=t.title||"Untitled reference",p=t.media[0];return e.jsxs("div",{className:"group/card relative",children:[e.jsx(ms,{profileId:r,reference:t,sources:a,referenceKey:n,children:e.jsx("button",{"aria-label":`Inspect ${i}`,className:"focus-visible:border-muted-foreground block w-full overflow-hidden border border-transparent text-left focus-visible:outline-hidden transition-colors",children:p?e.jsx(jt,{profileId:r,referenceId:t.id,hash:p.hash,title:i},p.hash):e.jsxs("div",{className:"border-border bg-surface-2 min-h-44 border p-5 pb-14",children:[e.jsx("p",{className:"text-soft-foreground text-sm font-medium",children:i}),e.jsx("p",{className:"text-muted-foreground mt-3 line-clamp-3 text-xs leading-5",children:((h=t.observation)==null?void 0:h.description)??t.text})]})})}),e.jsx("div",{"aria-hidden":!0,className:ve("pointer-events-none absolute inset-0 bg-black/40",Ye)}),e.jsxs("div",{className:ve("absolute inset-x-0 bottom-0 z-10 flex items-center justify-between gap-2 p-2",o?null:Ye,o?null:hs),children:[e.jsxs("label",{className:"relative shrink-0 cursor-pointer",title:o?"Deselect":"Select",children:[e.jsx("input",{type:"checkbox","aria-label":`Select ${i}`,checked:o,disabled:l,onChange:c,className:"peer absolute inset-0 h-full w-full cursor-pointer opacity-0 focus-visible:outline-hidden disabled:cursor-default"}),e.jsx("span",{className:ve("peer-focus-visible:border-foreground peer-focus-visible:text-foreground flex h-7 w-7 items-center justify-center rounded-full border shadow-sm transition-colors peer-disabled:opacity-40 forced-colors:peer-focus-visible:outline-2 forced-colors:peer-focus-visible:outline-offset-2 forced-colors:peer-focus-visible:outline-solid",o?"border-primary bg-primary text-primary-foreground":"peer-enabled:peer-hover:text-foreground border-white/35 bg-black/60 text-white/70 peer-focus-visible:bg-black/80"),children:e.jsx(ot,{size:14,weight:"bold","aria-hidden":!0})})]}),e.jsx(Oe,{profileId:r,referenceKeys:[n],providers:[t.provider]},t.revision)]})]})},be=24,fs="200px",xs=350,bs=100,gs=({snapshot:r,onAddSources:t,isAddSourcesDisabled:a})=>{var J;const n=de(),[o,l]=s.useState(""),[c,i]=s.useState(""),p=s.useRef(null),[h,S]=s.useState(""),[x,f]=s.useState(be),[g,R]=s.useState([]),b=s.useRef(null),A=cs(r.references),j=r.references.filter(u=>u.media.length>0),k=re({queryKey:T.designReferenceSearch({profileId:r.profileId,revision:r.revision,references:r.references.map(({id:u,revision:L,sourceIds:X})=>[u,L,X]),search:c,sourceId:h}),queryFn:({signal:u})=>$("/profile/search",{schema:is,method:"POST",body:{query:c,sourceId:h||void 0,limit:bs},signal:u}),enabled:c.length>=2&&r.references.length>0,retry:!1}),F=r.references.filter(u=>g.includes(u.id)),m=F.flatMap(u=>{const L=A.get(u.id);return L?[L]:[]}),B=o.trim(),E=B.length>=2,I=E&&r.references.length>0&&(c!==B||k.isLoading),V=E&&!I&&k.isError,P=new Map(r.references.map(u=>[u.id,u])),C=E?(((J=k.data)==null?void 0:J.results)??[]).flatMap(({id:u})=>{const L=P.get(u);return L?[L]:[]}):j.filter(u=>!h||u.sourceIds.includes(h)),y=j.length>0,w=C.length,z=r.references.length>0?"No images yet":"Your library starts here",te=r.references.length>0?"Ask your agent to save a design reference with an image to your library. It will appear here, ready to browse.":"Connect a source, then choose what to import into your library.",W=s.useCallback(u=>{var L;(L=b.current)==null||L.disconnect(),u&&(b.current=new IntersectionObserver(X=>{var ee;X.some(xe=>xe.isIntersecting)&&((ee=b.current)==null||ee.disconnect(),f(Math.min(x+be,w)))},{root:u.parentElement,rootMargin:fs}),b.current.observe(u))},[x,w]),Y=u=>{const L=F.map(ee=>ee.id),X=L.includes(u)?L.filter(ee=>ee!==u):[...L,u];R(X),n==null||n.capture("library_reference_selection_changed",{selected_count:X.length})};return e.jsxs("div",{className:"ph-no-capture flex min-h-0 flex-1 flex-col","data-rivet-private":!0,children:[e.jsx(Me,{children:e.jsx(Ve,{label:"Search references",value:o,onChange:u=>{l(u),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>i(u.trim()),xs),f(be)},onBlur:()=>{var u;return n==null?void 0:n.capture("library_reference_search_completed",{query_length:o.length,result_count:E?((u=k.data)==null?void 0:u.results.length)??0:C.length})}})}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-10 pb-10 max-sm:px-5",children:[!r.isEnabled&&y?e.jsx("p",{className:"text-muted-foreground mb-5 text-xs",children:"Automatic use is paused. Your saved references are still here."}):null,y?e.jsx("div",{className:"mb-7 flex flex-wrap items-center gap-3",children:e.jsxs("select",{"aria-label":"Source",value:h,onChange:u=>{S(u.target.value),f(be),n==null||n.capture("library_reference_source_filtered",{is_filtered:!!u.target.value})},className:"bg-background hover:border-border focus-visible:border-muted-foreground focus-visible:text-foreground max-w-64 rounded-lg border border-white/[0.08] px-3 py-2.5 text-xs text-white/60 transition-colors focus-visible:outline-hidden",children:[e.jsx("option",{value:"",children:"All sources"}),r.sources.map(u=>e.jsx("option",{value:u.id,children:u.title},u.id))]})}):null,m.length?e.jsxs("div",{className:"bg-background sticky top-0 z-20 mb-6 flex flex-wrap items-center gap-3 rounded-lg border border-white/10 p-3 shadow-lg",children:[e.jsxs("span",{className:"text-xs text-white/50",children:[m.length," selected"]}),e.jsx(Oe,{profileId:r.profileId,referenceKeys:m,providers:F.map(u=>u.provider)},m.join(" ")),e.jsx(H,{variant:"ghost",size:"compact",onClick:()=>{R([]),n==null||n.capture("library_reference_selection_changed",{selected_count:0})},children:"Clear selection"})]}):null,E&&k.data&&k.data.coverage.analyzed<k.data.coverage.saved?e.jsxs("p",{role:"status",className:"text-muted-foreground mb-5 text-xs",children:[k.data.coverage.analyzed," of"," ",k.data.coverage.saved," references analyzed; results may be incomplete."]}):null,I?e.jsx("p",{role:"status",className:"text-muted-foreground py-10 text-center text-xs",children:"Searching references…"}):null,V?e.jsxs("div",{role:"alert",className:"text-foreground py-10 text-center text-xs",children:[e.jsxs("p",{children:["Search is unavailable: ",k.error.message]}),e.jsx(H,{variant:"ghost",onClick:()=>{n==null||n.capture("library_reference_search_retry"),k.refetch()},children:"Try again"})]}):null,!I&&!V&&C.length?e.jsx(Yr,{children:C.slice(0,x).map(u=>{const L=A.get(u.id);return L?e.jsx(Jr,{children:e.jsx(ps,{profileId:r.profileId,reference:u,sources:r.sources,referenceKey:L,isSelected:g.includes(u.id),isSelectionDisabled:!g.includes(u.id)&&m.length>=St,onSelect:()=>Y(u.id)})},u.id):null})}):null,!I&&!V&&!C.length?e.jsxs("div",{className:"flex min-h-72 flex-col items-center justify-center rounded-xl border border-dashed border-white/[0.08] px-6 text-center",children:[e.jsx(Tr,{size:28,weight:"light",className:"mb-5 text-white/25","aria-hidden":!0}),e.jsx("h2",{className:"text-sm text-white/75",children:y||E?"No references found":z}),e.jsx("p",{className:"text-muted-foreground mt-2 max-w-sm text-xs leading-6",children:y||E?"Try another search or choose a different source.":te}),r.references.length===0&&!E?e.jsx(H,{variant:"tertiary",className:"mt-5",onClick:t,disabled:a,children:"Add sources"}):null]}):null,!I&&!V&&C.length>x?e.jsx("div",{ref:W,role:"status",className:"text-muted-foreground py-8 text-center text-xs",children:"Loading more references…"}):null]})]})},vs=1e4,ys=({onBrowseProjects:r})=>{var x,f,g;const t=ct(),a=de(),[n,o]=s.useState(!1),l=!((x=t.data)!=null&&x.isAuthenticated),c=R=>{l||(a==null||a.capture("library_sources_opened",{entry_point:R}),o(!0))},i=re({queryKey:T.designLibrary((f=t.data)==null?void 0:f.userId,(g=t.data)==null?void 0:g.isAuthenticated),queryFn:({signal:R})=>$("/profile/library",{schema:ns,signal:R}),enabled:!t.isPending,refetchInterval:vs,gcTime:0,retry:!1}),p=()=>{a==null||a.capture("library_reference_retry"),i.refetch()},h=e.jsx(Me,{children:e.jsx(Ve,{label:"Search references",value:"",isDisabled:!0})});let S;return i.isError&&!i.data?S=e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[h,e.jsxs("div",{className:"m-auto max-w-md px-8 text-center",children:[e.jsx("h1",{className:"mb-3 text-lg font-medium",children:"References"}),e.jsx("p",{role:"alert",className:"text-muted-foreground text-sm",children:i.error.message}),e.jsx("div",{className:"mt-5 flex justify-center gap-3",children:e.jsx(H,{variant:"ghost",onClick:r,children:"Projects"})})]})]}):i.data?S=e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[i.isError?e.jsxs("div",{role:"alert",className:"text-muted-foreground flex items-center justify-between gap-4 border-b border-white/10 px-8 py-3 text-xs",children:[e.jsx("span",{children:"Could not refresh. Showing the last saved results."}),e.jsx(H,{variant:"ghost",onClick:p,children:"Try again"})]}):null,e.jsx(gs,{snapshot:i.data,onAddSources:()=>c("empty_state"),isAddSourcesDisabled:l},i.data.profileId)]}):S=e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[h,e.jsx("p",{role:"status",className:"m-auto text-xs text-white/40",children:"Loading references…"})]}),e.jsxs(e.Fragment,{children:[S,e.jsx(Me,{children:e.jsx(H,{variant:"tertiary",className:"order-last shrink-0",disabled:l,onClick:()=>c("header"),children:"Add sources"})}),e.jsx(Jt,{isOpen:n,onClose:()=>{a==null||a.capture("library_sources_closed"),o(!1)},context:"library"})]})},js=({view:r,onNavigate:t})=>e.jsx("nav",{"aria-label":"Library",className:"bg-surface-2 flex items-center gap-1 rounded-lg p-1",children:["library","references"].map(a=>e.jsx("a",{href:a==="library"?"/rivet/library":"/rivet/library/references","aria-current":r===a?"page":void 0,onClick:n=>{n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||(n.preventDefault(),t(a))},className:Xt("rounded-md px-3 py-2 text-xs outline-none forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-offset-2 forced-colors:focus-visible:outline-solid",r===a?"bg-active text-foreground focus-visible:bg-selected forced-colors:bg-[Highlight] forced-colors:text-[HighlightText] forced-colors:forced-color-adjust-none forced-colors:focus-visible:bg-[Highlight]":"text-muted-foreground hover:text-soft-foreground focus-visible:bg-hover focus-visible:text-foreground"),children:a==="library"?"Projects":"References"},a))}),ws=()=>{const r=Pe(),t=async l=>{await r.cancelQueries({queryKey:T.projectLibrary.all}),r.setQueryData(T.projectLibrary.projects,c=>c&&{projects:l(c.projects)}),r.setQueriesData({queryKey:T.projectLibrary.histories},c=>{if(!c)return c;const i=l(c.projects),p=new Set(i.map(({id:h})=>h));return{projects:i,variants:c.variants.filter(({projectId:h})=>p.has(h))}}),r.invalidateQueries({queryKey:T.projectLibrary.all})},a=ue({mutationFn:({projectId:l,name:c})=>$(`/projects/${encodeURIComponent(l)}`,{schema:Re,method:"PATCH",body:{name:c}}),onSuccess:({project:l})=>t(c=>c.map(i=>i.id===l.id?{...i,name:l.name}:i))}),n=ue({mutationFn:({projectId:l,isPinned:c})=>$(`/projects/${encodeURIComponent(l)}/pin`,{schema:Re,method:c?"PUT":"DELETE"}),onSuccess:({project:l})=>t(c=>c.map(i=>i.id===l.id?{...i,pinnedAt:l.pinnedAt}:i))}),o=ue({mutationFn:l=>$(`/projects/${encodeURIComponent(l)}`,{schema:er,method:"DELETE"}),onSuccess:async(l,c)=>{await t(i=>i.filter(({id:p})=>p!==c)),await r.cancelQueries({queryKey:T.libraryProjectPreview.project(c)}),r.removeQueries({queryKey:T.libraryProjectPreview.project(c)})}});return{setProjectPinned:async(l,c)=>{await n.mutateAsync({projectId:l,isPinned:c})},renameProject:async(l,c)=>{await a.mutateAsync({projectId:l,name:c})},removeProject:async l=>{await o.mutateAsync(l)}}},Je=2500,Ss=500,Ns=6e4,Es=[],As=[],Ls=24,ge=({error:r,retry:t})=>e.jsxs("div",{className:"m-auto max-w-md px-8 text-center",children:[e.jsx("div",{className:"text-muted-foreground mb-3 flex justify-center",children:e.jsx(hr,{"aria-hidden":!0,size:Ls})}),e.jsx("p",{className:"text-foreground text-sm",children:r.message}),e.jsx(H,{onClick:t,variant:"tertiary",size:"compact",className:"mt-5",children:"Try again"})]}),Rs=()=>{var xe,Ze,Te,Fe,De,$e;const r=tr(br),t=de();rr(ct().data);const a=Pe(),{renameProject:n,removeProject:o,setProjectPinned:l}=ws(),c=s.useRef(),[i,p]=s.useState(()=>Qe(new URL(window.location.href))),[h]=s.useState(()=>crypto.randomUUID()),S=s.useRef(0),x=s.useRef(null),f=re({queryKey:T.projectLibrary.projects,queryFn:({signal:d})=>$("/projects",{schema:gr,signal:d}),refetchInterval:Je,retry:!1}),g=((xe=f.data)==null?void 0:xe.projects)??Es,R=g.map(({id:d,projectPath:v})=>({id:d,projectPath:v})).sort((d,v)=>d.id.localeCompare(v.id)),b=re({queryKey:T.projectLibrary.history(R),queryFn:({signal:d})=>$("",{schema:vr,signal:d}),placeholderData:d=>{if(!d)return;const v=new Map(d.projects.map(({id:O,projectPath:G})=>[O,G]));if(!g.every(({id:O,projectPath:G})=>v.get(O)===G))return;const _=new Set(g.map(({id:O})=>O));return{projects:d.projects.filter(({id:O})=>_.has(O)),variants:d.variants.filter(({projectId:O})=>_.has(O))}},enabled:g.length>0,refetchInterval:Je,retry:!1}),A=new Map((Ze=b.data)==null?void 0:Ze.projects.map(d=>[d.id,d])),j=g.map(d=>{const v=A.get(d.id);return{...d,issue:v?v.issue:d.issue,historyIssue:v?v.historyIssue:d.historyIssue}}),k=((Te=b.data)==null?void 0:Te.variants)??As,F=Hr({queries:j.map(d=>({queryKey:T.libraryProjectPreview.thumbnail(d.id,d.projectPath),queryFn:({signal:v})=>$(`/projects/${d.id}/thumbnail`,{schema:xr,signal:v}),enabled:i.kind==="library",refetchInterval:Ns,retry:!1}))}),m=j.find(d=>d.id===i.projectId),B=sr({name:m==null?void 0:m.name,projectPath:m==null?void 0:m.projectPath}),E=k.find(d=>d.projectId===i.projectId&&d.sessionId===i.sessionId&&d.variantId===i.variantId),I=s.useCallback(d=>{window.history.pushState(null,"",ar(d)),p(d)},[]);s.useEffect(()=>{const d=nr(B);return m?c.current=m.id:f.isSuccess&&!f.isFetching&&i.projectId===c.current&&i.projectId&&(c.current=void 0,I({kind:"library"})),d},[m,B,i.projectId,f.isSuccess,f.isFetching,I]),s.useEffect(()=>{const d=()=>p(Qe(new URL(window.location.href)));return window.addEventListener("popstate",d),()=>window.removeEventListener("popstate",d)},[]),s.useEffect(()=>{const d=new AbortController;let v;const _=async()=>{try{const O=await $(`/views/${h}`,{schema:dr,method:"PUT",body:{isFocused:document.visibilityState==="visible"&&document.hasFocus()},signal:d.signal});for(const G of O.navigations){if(d.signal.aborted)return;if(G.sequence>S.current){let Se="library";G.projectId&&(Se="workspace"),G.variantId&&(Se="preview"),I({...G,kind:Se}),S.current=G.sequence}await $(`/views/${h}/acknowledgements`,{schema:ur,method:"POST",body:{sequence:G.sequence},signal:d.signal})}}catch{}d.signal.aborted||(v=setTimeout(()=>{_()},Ss))};return _(),()=>{d.abort(),clearTimeout(v)}},[h,I]);const V=re({queryKey:T.libraryWorkspace(i.projectId),queryFn:()=>$(`/projects/${i.projectId}/runtime`,{schema:yr,method:"POST"}),enabled:i.kind==="workspace"&&!!i.projectId&&(m==null?void 0:m.isAvailable)===!0,retry:!1,refetchOnWindowFocus:!1}),P=V.data?new URL(V.data.editorUrl).origin:null;s.useEffect(()=>{if(i.kind!=="workspace"||!P)return;const d=v=>{!x.current||v.source!==x.current.contentWindow||v.origin!==P||v.data!==mr||(t==null||t.capture("library_view_changed",{view:"projects"}),I({kind:"library"}))};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[i.kind,P,I,t]);const C=re({queryKey:T.libraryPreview({projectId:i.projectId,sessionId:i.sessionId,variantId:i.variantId}),queryFn:()=>$(`/projects/${i.projectId}/variants/${i.sessionId}/${i.variantId}/preview`,{schema:jr,method:"POST"}),enabled:i.kind==="preview"&&!!(E!=null&&E.hasStaticPreview),retry:!1,refetchOnWindowFocus:!1}),y=ue({mutationFn:d=>$(`/projects/${i.projectId}/variants/${i.sessionId}/${i.variantId}`,{schema:pr,method:"PATCH",body:{label:d}}),onSuccess:()=>a.invalidateQueries({queryKey:T.projectLibrary.all})}),w=d=>{const v=j.find(_=>_.id===d);t==null||t.capture("library_project_selected",{project_id:d,workspace_available:(v==null?void 0:v.isAvailable)??!1}),I({kind:"workspace",projectId:d})},z=ue({mutationFn:async d=>{const{projectPath:v}=await $("/folder-selections",{schema:fr,method:"POST"});return v===null?null:$(d?`/projects/${d}/workspace`:"/projects",{schema:Re,method:d?"PATCH":"POST",body:{projectPath:v}})},onSuccess:d=>{d&&(a.invalidateQueries({queryKey:T.projectLibrary.all}),t==null||t.capture("library_project_selected",{project_id:d.project.id,workspace_available:d.project.isAvailable}),I({kind:"workspace",projectId:d.project.id}))},onSettled:(d,v,_)=>{t==null||t.capture("library_open_project_closed",{is_relink:!!_})}}),te=d=>{z.isPending||(t==null||t.capture("library_open_project_opened",{is_relink:!!d}),z.mutate(d))},W=()=>{t==null||t.capture("library_view_changed",{view:"projects"}),I({kind:"library"})},Y=()=>{t==null||t.capture("library_view_changed",{view:"workspace"}),I({...i,kind:"workspace"})},J=()=>{t==null||t.capture("library_history_retry"),b.refetch()};let u;if(i.kind==="workspace"&&(m==null?void 0:m.isAvailable)!==!1||i.kind==="preview"){let d=!1,v=e.jsxs("div",{className:"text-muted-foreground m-auto flex items-center gap-2 text-xs",children:[e.jsx(ir,{size:14,weight:"bold",className:"animate-spin","aria-hidden":!0}),"Opening ",(m==null?void 0:m.name)??"project","…"]});if(f.data&&!m||b.data&&i.variantId&&!E)v=e.jsx("div",{className:"m-auto text-sm text-white/60",children:"This project or direction is no longer in your library."});else if(i.kind==="preview"&&b.error&&!b.data)v=e.jsx(ge,{error:b.error,retry:J});else if(i.kind==="workspace"&&V.error)v=e.jsx(ge,{error:V.error,retry:()=>{V.refetch()}});else if(i.kind==="workspace"&&V.data){d=!0;const _=new URL(or(V.data.editorUrl,r));_.searchParams.set("library","1"),_.searchParams.set("libraryOrigin",window.location.origin),i.sessionId&&i.variantId&&(_.searchParams.set("historySession",i.sessionId),_.searchParams.set("historyVariant",i.variantId)),v=e.jsx("iframe",{ref:x,title:`${(m==null?void 0:m.name)??"Project"} workspace`,src:_.toString(),allow:"clipboard-write","data-rivet-private":!0,className:"ph-no-capture min-h-0 w-full flex-1 border-0"},_.toString())}else i.kind==="preview"&&C.error?v=e.jsx(ge,{error:C.error,retry:()=>{C.refetch()}}):i.kind==="preview"&&C.data?v=e.jsx("iframe",{title:`${(E==null?void 0:E.label)??"Saved direction"} preview`,src:C.data.url,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",className:"min-h-0 w-full flex-1 border-0 bg-white"}):i.kind==="preview"&&E&&!E.hasStaticPreview&&(v=e.jsxs("div",{className:"m-auto max-w-sm text-center",children:[e.jsx("p",{className:"text-sm",children:E.hasInteractivePreview?"Open this direction in its workspace":"This direction contains saved code changes"}),e.jsx("p",{className:"text-muted-foreground mt-2 text-xs leading-6",children:E.hasInteractivePreview?"Rivet will start the preview with this project’s dependencies and configuration.":"Open the project to continue working with its saved history."}),e.jsx(H,{onClick:Y,disabled:(m==null?void 0:m.isAvailable)===!1,variant:"primary",className:"mt-5",children:"Open workspace"})]}));u=e.jsxs(e.Fragment,{children:[i.kind==="preview"?e.jsxs("header",{className:"flex h-14 shrink-0 items-center gap-3 border-b border-white/[0.07] px-5",children:[e.jsx(H,{"aria-label":"Back to projects",onClick:W,variant:"ghost",size:"icon-compact",children:e.jsx(Or,{size:15,weight:"bold","aria-hidden":!0})}),e.jsx("span",{className:"text-muted-foreground text-xs",children:m==null?void 0:m.name}),E?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,className:"text-white/20",children:"/"}),e.jsxs("form",{onSubmit:_=>{_.preventDefault();const O=new FormData(_.currentTarget);y.mutate(String(O.get("label")))},className:"flex min-w-0 flex-1 gap-2",children:[e.jsx("input",{name:"label","aria-label":"Direction name",defaultValue:E.label,className:"hover:border-border focus-visible:border-muted-foreground focus-visible:bg-hover focus-visible:text-foreground -ml-2 max-w-xs min-w-0 flex-1 rounded-md border border-transparent bg-transparent px-2 py-1 text-xs text-white/80 transition-colors focus-visible:outline-hidden"}),e.jsx(H,{type:"submit",disabled:y.isPending,variant:"ghost",size:"compact",children:"Rename"})]},`${E.projectId}:${E.variantId}`)]}):e.jsx("span",{className:"flex-1"}),i.kind==="preview"?e.jsx(H,{onClick:Y,disabled:(m==null?void 0:m.isAvailable)===!1,variant:"tertiary",size:"compact",trailingIcon:pt,children:"Edit in project"}):null]}):null,i.kind==="workspace"&&!d?e.jsx(H,{onClick:W,variant:"ghost",size:"compact",className:"absolute top-5 left-5",children:"Projects"}):null,y.error?e.jsx("p",{role:"alert",className:"text-muted-foreground px-5 py-2 text-xs",children:y.error.message}):null,v]})}let L=u;f.error&&!f.data?L=e.jsx(ge,{error:f.error,retry:()=>{f.refetch()}}):f.isPending&&(L=e.jsx("div",{role:"status",className:"text-muted-foreground flex min-h-0 flex-1 items-center justify-center text-xs",children:"Loading projects…"}));const X=i.kind==="references"?"references":"library",ee=e.jsx(js,{view:X,onNavigate:d=>{t==null||t.capture("library_view_changed",{view:d==="references"?"references":"projects"}),I({kind:d})}});return i.kind==="references"&&(L=e.jsx(ys,{onBrowseProjects:W})),e.jsxs(e.Fragment,{children:[e.jsx(Gr,{projects:j,variants:(Fe=b.data)==null?void 0:Fe.variants,historyError:(De=b.error)==null?void 0:De.message,onRetryHistory:J,projectPreviews:Object.fromEntries(j.map((d,v)=>{var _,O;return[d.id,(O=(_=F[v])==null?void 0:_.data)==null?void 0:O.preview]})),selectedProjectId:i.projectId??null,onSelectProject:w,onBrowseLibrary:W,navigation:ee,view:X,onOpenProject:te,onRenameProject:n,onRemoveProject:o,onSetProjectPinned:l,accountMenu:e.jsx(lr,{side:"top",align:"start"}),isOpeningProject:z.isPending,projectOpenError:($e=z.error)==null?void 0:$e.message,onSearchCompleted:d=>t==null?void 0:t.capture("library_search_completed",{query_length:d}),children:L}),e.jsx(cr,{position:"bottom-right",theme:"dark"})]})},Is=async r=>{const t=kr(),a=await Ar("/api/library/browser-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok){const n=Lr.safeParse(await a.json().catch(()=>null));throw new Error(n.success?n.data.error:"Could not start a library session.")}Rr(Ir(await a.json()),t)},ks=()=>{const r=s.useSyncExternalStore(dt,Sr),{startLogin:t,isStartingLogin:a,loginError:n}=Nr("library",Is);return e.jsx(Er,{isSigningIn:a,onStartSignIn:()=>void t(),errorMessage:n??r})},Cs=()=>s.useSyncExternalStore(dt,wr)?e.jsx(Rs,{}):e.jsx(ks,{});export{Cs as default};
2
+ //# sourceMappingURL=LibraryEntry-CSU5OJwC.js.map