rivet-design 0.14.1 → 0.14.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"mcpServe.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/mcpServe.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAcnC;;;;;;;;;;;;GAYG;AAEH,KAAK,eAAe,GAAG;IACrB,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAiBF,iFAAiF;AACjF,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,KAAG,OASlD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,UAAU,WAAW,KAAG,OAgB1D,CAAC;AAwBF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAU,UAAS,eAAoB;;;EAkdjE,CAAC;AAgBF;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EAAE,EACd,IAAI,KAAK,KACR,OAAO,CAAC,gBAAgB,CAoE1B,CAAC"}
1
+ {"version":3,"file":"mcpServe.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/mcpServe.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAcnC;;;;;;;;;;;;GAYG;AAEH,KAAK,eAAe,GAAG;IACrB,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAiBF,iFAAiF;AACjF,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,KAAG,OASlD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,UAAU,WAAW,KAAG,OAgB1D,CAAC;AAwBF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAU,UAAS,eAAoB;;;EAkdjE,CAAC;AAgBF;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EAAE,EACd,IAAI,KAAK,KACR,OAAO,CAAC,gBAAgB,CA2E1B,CAAC"}
@@ -492,6 +492,12 @@ const handleMcpServe = async (rest, io) => {
492
492
  guardStdout();
493
493
  const { redirectLogsToStderr } = await Promise.resolve().then(() => __importStar(require('../../utils/logger')));
494
494
  redirectLogsToStderr();
495
+ // MCP hosts (Cursor, Claude Desktop) spawn this server with the desktop
496
+ // session's minimal PATH. Enrich from the login shell up front so every
497
+ // child this process spawns — the project `__serve` daemon, vendor agent
498
+ // CLIs, ffmpeg — sees the user's real environment.
499
+ const { ensureLoginShellPath } = await Promise.resolve().then(() => __importStar(require('../../utils/loginShellPath')));
500
+ ensureLoginShellPath();
495
501
  const handoffArgs = [];
496
502
  for (const flag of [
497
503
  'caller-agent',
@@ -1 +1 @@
1
- {"version":3,"file":"mcpServe.js","sourceRoot":"","sources":["../../../src/cli/commands/mcpServe.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,gDAAwB;AACxB,+BAA2B;AAC3B,0CAKqB;AAErB,oCAA+D;AAC/D,qCAA4C;AAC5C,sCAImB;AACnB,8DAIwC;AAwBxC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AACpC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AACxC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,MAAM,kBAAkB,GAAG,GA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d,IAAI,KAAK,KACR,OAAO,CAAC,gBAAgB,CA2J1B,CAAC"}
1
+ {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE3E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAiBnC;;;;GAIG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,MAAM,EAAE,EACd,IAAI,KAAK,KACR,OAAO,CAAC,gBAAgB,CA2K1B,CAAC"}
@@ -60,6 +60,12 @@ const handleServe = async (args, io) => {
60
60
  return context;
61
61
  }
62
62
  const { flags, projectPath, handoff } = context;
63
+ // GUI-spawned daemons (Cursor / Claude Desktop → mcp serve → __serve)
64
+ // inherit the desktop session's minimal PATH; enrich from the login shell
65
+ // BEFORE runner resolution and the worker executor's binary preflight,
66
+ // or both silently degrade (runner "unavailable", host-mode fallback).
67
+ const { ensureLoginShellPath } = await Promise.resolve().then(() => __importStar(require('../../utils/loginShellPath')));
68
+ ensureLoginShellPath();
63
69
  const agentSelectionError = (0, runnerSelection_1.explicitRunnerSelectionError)((0, flags_1.stringFlag)(flags, 'agent'));
64
70
  if (agentSelectionError) {
65
71
  return (0, envelope_1.errorResult)(COMMAND, 'USAGE_ERROR', agentSelectionError);
@@ -95,11 +101,20 @@ const handleServe = async (args, io) => {
95
101
  });
96
102
  const bridge = variantsRuntime.bridge;
97
103
  const sessionInitiator = (0, handoff_1.initiatorFor)(handoff);
104
+ // Resolve the apply runner for real (flag > user config > handoff >
105
+ // PATH probe) — this was stamped `unavailable` unconditionally since
106
+ // #917, which host agents read as "no server-side execution here" and
107
+ // used to justify slow host-mode implementation. Depends on the
108
+ // login-shell PATH enrichment above for GUI-spawned daemons.
109
+ const { resolveRunner } = await Promise.resolve().then(() => __importStar(require('../runnerSelection')));
110
+ const { getConfigManager } = await Promise.resolve().then(() => __importStar(require('../../services/ConfigManager')));
98
111
  bridge.setSessionRuntimeInfo({
99
112
  sessionInitiator,
100
- resolvedRunner: {
101
- mode: 'unavailable',
102
- },
113
+ resolvedRunner: resolveRunner({
114
+ explicitAgent: (0, flags_1.stringFlag)(flags, 'agent'),
115
+ configuredRunner: getConfigManager().getConfiguredRunner(),
116
+ handoff,
117
+ }),
103
118
  });
104
119
  // Durable, owner-only attribution record; the chat session id lives only
105
120
  // here (work items carry agent kind and model, never the session id).
@@ -1 +1 @@
1
- {"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/cli/commands/serve.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA2E;AAC3E,oCAAmD;AAEnD,qCAAgE;AAChE,wCAA0C;AAC1C,kDAAsD;AACtD,wDAAkE;AAElE,MAAM,OAAO,GAAG,SAAS,CAAC;AAE1B,MAAM,eAAe,GAAG;IACtB,YAAY,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;IAClC,WAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;IACjC,SAAS,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;IAC/B,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;IAC3B,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;IAC3B,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;CAChC,CAAC;AAEF;;;;GAIG;AACI,MAAM,WAAW,GAAG,KAAK,EAC9B,IAAc,EACd,EAAS,EACkB,EAAE;IAC7B,MAAM,OAAO,GAAG,IAAA,4BAAmB,EAAC,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;IACpE,IAAI,IAAA,wBAAe,EAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEhD,MAAM,mBAAmB,GAAG,I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,yCAAyC;QACzC,wBAAwB,CAAC,WAAW,CAAC,CAAC;QAEtC,EAAE,CAAC,aAAa,CACd,oCAAoC,SAAS,oCAAoC,CAClF,CAAC;QAEF,wDAAwD;QACxD,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC5B,OAAO,IAAA,mBAAQ,EAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,cAAc,CAAC,OAAO,EAAE,EAAE,CAAC;QACjC,OAAO,IAAA,sBAAW,EAChB,OAAO,EACP,oBAAoB,EACpB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACvD,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AA9KW,QAAA,WAAW,eA8KtB"}
@@ -0,0 +1,25 @@
1
+ export type ShellExec = (shell: string, args: string[]) => string;
2
+ /** True when `binary` is executable somewhere on the given PATH value. */
3
+ export declare const isBinaryOnPathValue: (binary: string, pathValue: string) => boolean;
4
+ /** PATH as the user's shell sees it (union across probes), or null when no
5
+ * probe succeeded. */
6
+ export declare const loginShellPath: (options?: {
7
+ exec?: ShellExec;
8
+ shell?: string;
9
+ basePath?: string;
10
+ goalBinary?: string;
11
+ }) => string | null;
12
+ /** Merge `extra` PATH entries into `base`, preserving base precedence and
13
+ * appending only directories base doesn't already have. Empty segments are
14
+ * dropped throughout — a leading/embedded empty PATH entry means "search
15
+ * the current directory", which would let an opened project shadow the
16
+ * user's real binaries. */
17
+ export declare const mergePathValues: (base: string, extra: string) => string;
18
+ export declare const ensureLoginShellPath: (options?: {
19
+ exec?: ShellExec;
20
+ shell?: string;
21
+ goalBinary?: string;
22
+ }) => void;
23
+ /** Test seam: reset the once-per-process latch. */
24
+ export declare const resetLoginShellPathForTests: () => void;
25
+ //# sourceMappingURL=loginShellPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loginShellPath.d.ts","sourceRoot":"","sources":["../../src/utils/loginShellPath.ts"],"names":[],"mappings":"AAwDA,MAAM,MAAM,SAAS,GAAG,CACtB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EAAE,KACX,MAAM,CAAC;AAeZ,0EAA0E;AAC1E,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,MAAM,EACd,WAAW,MAAM,KAChB,OASC,CAAC;AAEL;uBACuB;AACvB,eAAO,MAAM,cAAc,GACzB,UAAU;IACR,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,KACA,MAAM,GAAG,IAuCX,CAAC;AAEF;;;;4BAI4B;AAC5B,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,KAAG,MAK7D,CAAC;AAcF,eAAO,MAAM,oBAAoB,GAC/B,UAAU;IAAE,IAAI,CAAC,EAAE,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,KAClE,IAuBF,CAAC;AAEF,mDAAmD;AACnD,eAAO,MAAM,2BAA2B,QAAO,IAG9C,CAAC"}
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resetLoginShellPathForTests = exports.ensureLoginShellPath = exports.mergePathValues = exports.loginShellPath = exports.isBinaryOnPathValue = void 0;
7
+ const child_process_1 = require("child_process");
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const logger_1 = require("./logger");
11
+ const log = (0, logger_1.createLogger)('LoginShellPath');
12
+ /**
13
+ * GUI-spawned Rivet processes inherit the desktop session's minimal PATH.
14
+ *
15
+ * When Cursor or Claude Desktop spawns `rivet mcp serve` (and it spawns the
16
+ * project's `__serve` daemon), PATH is typically just
17
+ * `/usr/bin:/bin:/usr/sbin:/sbin` — missing `/opt/homebrew/bin` and the
18
+ * user dirs where vendor agent CLIs (`claude`, `codex`, `cursor-agent`) and
19
+ * media tools (`ffmpeg`, used for reference-video keyframes) live. That
20
+ * silently degrades sessions started from those hosts: the apply runner
21
+ * resolves to `unavailable`, the worker executor's `claude --version`
22
+ * preflight fails so variants fall back to slow host-mode implementation,
23
+ * and video references can't be sampled.
24
+ *
25
+ * The fix is the same one editors like VS Code use: read PATH from the
26
+ * user's login shell once at server startup and merge it into the process
27
+ * environment. Probes run as a ladder, most-reliable first, each with its
28
+ * own timeout, and their results are UNIONED:
29
+ *
30
+ * 1. plain `-lc` — login profile only (.zprofile/.zshenv). Fast and
31
+ * hang-proof.
32
+ * 2. `-lc` sourcing the rc explicitly — for users whose PATH exports
33
+ * live in .zshrc/.bashrc (nvm, fnm, npm globals, user bin dirs). Can
34
+ * hang TTY-less (e.g. compinit's insecure-directories prompt), hence
35
+ * the per-probe timeout and its place behind the plain probe.
36
+ * 3. `-ilc` — last resort; interactive shells read the rc natively but
37
+ * are the least predictable without a TTY.
38
+ *
39
+ * The ladder stops early only for a GOAL, not for any addition: on macOS
40
+ * path_helper/.zprofile almost always add something (e.g. /opt/homebrew),
41
+ * which says nothing about whether the binaries we actually need are now
42
+ * reachable. Enrichment exists so the worker executor can spawn `claude`
43
+ * (and the runner probe can find a vendor CLI), so probing continues until
44
+ * that binary resolves or the ladder is exhausted — and is skipped
45
+ * entirely when the current PATH already resolves it.
46
+ *
47
+ * rc noise on stdout is defeated with sentinel markers.
48
+ */
49
+ const SENTINEL = '__RIVET_PATH__';
50
+ /** rc file to source explicitly for shells that put PATH exports there
51
+ * (read only by interactive shells, which we must not start TTY-less). */
52
+ const rcFileForShell = (shell) => {
53
+ const name = path_1.default.basename(shell);
54
+ if (name === 'zsh')
55
+ return '~/.zshrc';
56
+ if (name === 'bash')
57
+ return '~/.bashrc';
58
+ return null;
59
+ };
60
+ const defaultExec = (shell, args) => (0, child_process_1.execFileSync)(shell, args, {
61
+ timeout: 4_000,
62
+ stdio: ['ignore', 'pipe', 'ignore'],
63
+ encoding: 'utf8',
64
+ });
65
+ const PRINT_PATH = `printf "%s%s%s" "${SENTINEL}" "$PATH" "${SENTINEL}"`;
66
+ /** The binary enrichment exists to make reachable: the worker executor's
67
+ * runtime. Overridable per call for tests and future goals. */
68
+ const DEFAULT_GOAL_BINARY = 'claude';
69
+ /** True when `binary` is executable somewhere on the given PATH value. */
70
+ const isBinaryOnPathValue = (binary, pathValue) => pathValue.split(':').some((dir) => {
71
+ if (!dir)
72
+ return false;
73
+ try {
74
+ fs_1.default.accessSync(path_1.default.join(dir, binary), fs_1.default.constants.X_OK);
75
+ return true;
76
+ }
77
+ catch {
78
+ return false;
79
+ }
80
+ });
81
+ exports.isBinaryOnPathValue = isBinaryOnPathValue;
82
+ /** PATH as the user's shell sees it (union across probes), or null when no
83
+ * probe succeeded. */
84
+ const loginShellPath = (options) => {
85
+ if (process.platform === 'win32')
86
+ return null;
87
+ const shell = options?.shell ?? process.env.SHELL ?? '/bin/zsh';
88
+ const exec = options?.exec ?? defaultExec;
89
+ const basePath = options?.basePath ?? process.env.PATH ?? '';
90
+ const goalBinary = options?.goalBinary ?? DEFAULT_GOAL_BINARY;
91
+ const rcFile = rcFileForShell(shell);
92
+ const probes = [
93
+ ['-lc', PRINT_PATH],
94
+ ...(rcFile
95
+ ? [['-lc', `. ${rcFile} >/dev/null 2>&1 || true; ${PRINT_PATH}`]]
96
+ : []),
97
+ ['-ilc', PRINT_PATH],
98
+ ];
99
+ let union = '';
100
+ for (const args of probes) {
101
+ let value;
102
+ try {
103
+ const output = exec(shell, args);
104
+ value = output
105
+ .match(new RegExp(`${SENTINEL}([\\s\\S]*?)${SENTINEL}`))?.[1]
106
+ ?.trim();
107
+ }
108
+ catch (error) {
109
+ log.warn(`login-shell PATH probe (${args[0]}) failed for ${shell}`, error instanceof Error ? error.message : error);
110
+ continue;
111
+ }
112
+ if (!value)
113
+ continue;
114
+ union = union ? (0, exports.mergePathValues)(union, value) : value;
115
+ // Goal-directed early exit: "added something" is meaningless on macOS
116
+ // (path_helper always adds), so keep probing until the binary this
117
+ // enrichment exists for is actually reachable.
118
+ if ((0, exports.isBinaryOnPathValue)(goalBinary, (0, exports.mergePathValues)(basePath, union))) {
119
+ break;
120
+ }
121
+ }
122
+ return union || null;
123
+ };
124
+ exports.loginShellPath = loginShellPath;
125
+ /** Merge `extra` PATH entries into `base`, preserving base precedence and
126
+ * appending only directories base doesn't already have. Empty segments are
127
+ * dropped throughout — a leading/embedded empty PATH entry means "search
128
+ * the current directory", which would let an opened project shadow the
129
+ * user's real binaries. */
130
+ const mergePathValues = (base, extra) => {
131
+ const baseDirs = base.split(':').filter(Boolean);
132
+ const seen = new Set(baseDirs);
133
+ const additions = extra.split(':').filter((dir) => dir && !seen.has(dir));
134
+ return [...baseDirs, ...additions].join(':');
135
+ };
136
+ exports.mergePathValues = mergePathValues;
137
+ /** Set once enrichment ran; inherited by child processes (`mcp serve` →
138
+ * `__serve` → workers) so each layer doesn't re-probe the login shell. */
139
+ const APPLIED_ENV_FLAG = 'RIVET_LOGIN_SHELL_PATH_APPLIED';
140
+ /**
141
+ * Enrich `process.env.PATH` from the user's login shell. Idempotent, cached
142
+ * for the process lifetime AND across child processes (env flag), and
143
+ * failure-silent — a broken shell rc must never stop the server from
144
+ * booting. Call once at server startup, BEFORE runner resolution and
145
+ * executor preflights.
146
+ */
147
+ let enriched = false;
148
+ const ensureLoginShellPath = (options) => {
149
+ if (enriched)
150
+ return;
151
+ enriched = true;
152
+ if (process.env[APPLIED_ENV_FLAG] === '1')
153
+ return;
154
+ const current = process.env.PATH ?? '';
155
+ // Terminal-started daemons usually inherit a complete PATH — skip the
156
+ // shell spawn entirely when the goal binary is already reachable.
157
+ if ((0, exports.isBinaryOnPathValue)(options?.goalBinary ?? DEFAULT_GOAL_BINARY, current)) {
158
+ process.env[APPLIED_ENV_FLAG] = '1';
159
+ return;
160
+ }
161
+ const shellPath = (0, exports.loginShellPath)({ ...options, basePath: current });
162
+ if (!shellPath)
163
+ return;
164
+ process.env[APPLIED_ENV_FLAG] = '1';
165
+ const merged = (0, exports.mergePathValues)(current, shellPath);
166
+ if (merged !== current) {
167
+ log.info(`merged ${merged.split(':').length - current.split(':').filter(Boolean).length} login-shell PATH entries into the server environment`);
168
+ process.env.PATH = merged;
169
+ }
170
+ };
171
+ exports.ensureLoginShellPath = ensureLoginShellPath;
172
+ /** Test seam: reset the once-per-process latch. */
173
+ const resetLoginShellPathForTests = () => {
174
+ enriched = false;
175
+ delete process.env[APPLIED_ENV_FLAG];
176
+ };
177
+ exports.resetLoginShellPathForTests = resetLoginShellPathForTests;
178
+ //# sourceMappingURL=loginShellPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loginShellPath.js","sourceRoot":"","sources":["../../src/utils/loginShellPath.ts"],"names":[],"mappings":";;;;;;AAAA,iDAA6C;AAC7C,4CAAoB;AACpB,gDAAwB;AACxB,qCAAwC;AAExC,MAAM,GAAG,GAAG,IAAA,qBAAY,EAAC,gBAAgB,CAAC,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,MAAM,QAAQ,GAAG,gBAAgB,CAAC;AAElC;2EAC2E;AAC3E,MAAM,cAAc,GAAG,CAAC,KAAa,EAAiB,EAAE;IACtD,MAAM,IAAI,GAAG,cAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,UAAU,CAAC;IACtC,IAAI,IAAI,KAAK,MAAM;QAAE,OAAO,WAAW,CAAC;IACxC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAOF,MAAM,WAAW,GAAc,CA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,OAAO;IACT,CAAC;IACD,MAAM,SAAS,GAAG,IAAA,sBAAc,EAAC,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IACpE,IAAI,CAAC,SAAS;QAAE,OAAO;IACvB,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,GAAG,CAAC;IACpC,MAAM,MAAM,GAAG,IAAA,uBAAe,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACnD,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACvB,GAAG,CAAC,IAAI,CACN,UAAU,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,uDAAuD,CACtI,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC;IAC5B,CAAC;AACH,CAAC,CAAC;AAzBW,QAAA,oBAAoB,wBAyB/B;AAEF,mDAAmD;AAC5C,MAAM,2BAA2B,GAAG,GAAS,EAAE;IACpD,QAAQ,GAAG,KAAK,CAAC;IACjB,OAAO,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AACvC,CAAC,CAAC;AAHW,QAAA,2BAA2B,+BAGtC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rivet-design",
3
- "version": "0.14.1",
3
+ "version": "0.14.2",
4
4
  "description": "Local visual web development tool with AI-powered code modification",
5
5
  "main": "dist/index.js",
6
6
  "workspaces": [
@@ -111,7 +111,7 @@ function useAtomValueWithDelay<Value>(
111
111
  `);if(!t.reference)return e;const n=((a=t.projectPath)==null?void 0:a.trim())??"",r=n?` --project '${n.replace(/'/g,"'\\''")}'`:"",s=[`Rivet variant: ${t.reference}`,"To inspect the full variant context, run:",`rivet variants get ${t.reference}${r}`].join(`
112
112
  `);return e?`${e}
113
113
 
114
- ${s}`:s},eG=({rows:t,activeVariantId:e,activePastKey:n,isOriginalSelected:r,busy:s,editingKey:i,onSelectActive:a,onSelectPast:u,onSelectOriginal:c,onActivePointerDown:f,onPastPointerDown:h,onHover:p,onRemove:v,onRemovePast:y,onStartRename:x,onCommitRename:_,onCancelRename:b,onCopyVariantContext:E,activeSessionId:k,projectPath:P})=>{const T=g.useRef(null),{activeIndex:A,itemRects:O,sessionRef:N,handlers:R,registerItem:M}=HT(T),L=(s==null?void 0:s.kind)==="switch",D=A!==null?O[A]:null;return S.jsxs("div",{ref:T,className:"relative",onMouseEnter:R.onMouseEnter,onMouseMove:R.onMouseMove,onMouseLeave:R.onMouseLeave,children:[S.jsx(Gi,{children:D&&S.jsx(sl.div,{className:"bg-hover pointer-events-none absolute z-0 rounded-md",initial:{opacity:0,top:D.top,left:D.left,width:D.width,height:D.height},animate:{opacity:1,top:D.top,left:D.left,width:D.width,height:D.height},exit:{opacity:0,transition:{duration:.06}},transition:{...Vd.fast,opacity:{duration:.08}}},N.current)}),S.jsx("ul",{className:"relative",children:t.map((V,K)=>{const Y=ZW(V);let G=!1;return V.kind==="active"?G=V.variant.workItemId===e:V.kind==="past"?G=`${V.entry.sessionId}:${V.entry.variantId}`===n:G=r,S.jsx(tG,{rowKey:Y,row:V,index:K,isSelected:G,isEditing:i===Y,isSwitchInFlight:L,busy:s,registerItem:M,onSelectActive:a,onSelectPast:u,onSelectOriginal:c,onActivePointerDown:f,onPastPointerDown:h,onHover:p,onRemove:v,onRemovePast:y,onStartRename:x,onCommitRename:_,onCancelRename:b,onCopyVariantContext:E,activeSessionId:k,projectPath:P},Y)})})]})},tG=({rowKey:t,row:e,index:n,isSelected:r,isEditing:s,isSwitchInFlight:i,busy:a,registerItem:u,onSelectActive:c,onSelectPast:f,onSelectOriginal:h,onActivePointerDown:p,onPastPointerDown:v,onHover:y,onRemove:x,onRemovePast:_,onStartRename:b,onCommitRename:E,onCancelRename:k,onCopyVariantContext:P,activeSessionId:T,projectPath:A})=>{var Ce,ae;const O=g.useRef(null);hU(u,n,O);const N=e.kind==="active",R=e.kind==="original",M=e.kind==="active"?e.variant:null,L=e.kind==="past"?e.entry:null,D=N?M.status==="succeeded":!0,V=N?$a(M):!0,K=N?oR(M):!1,Y=N&&(M.status==="pending"||M.status==="running"),G=N?D&&(V||K)||Y:!0,B=N&&M.status==="failed",Q=N&&M.status==="cancelled",$=N&&(!G||i),te=N&&(a==null?void 0:a.kind)==="remove"&&a.variantId===M.workItemId,H=N&&(((Ce=M.refinement)==null?void 0:Ce.status)==="pending"||((ae=M.refinement)==null?void 0:ae.status)==="running");let j=gx;N?j=M.label||`Direction ${n+1}`:L&&(j=L.label.trim()||"Untitled direction");let Z;N?Z=M.runLabel:L&&(Z=L.runLabel);let ee=vx;N?ee=M.description:L&&(ee=L.brief);const ie=ee?QW(ee):null,le=XW(e,T),ue=le?"Copy variant reference":"Copy description";return s?S.jsx("li",{ref:O,"data-proximity-index":n,className:"group relative z-10",children:S.jsx("div",{className:"bg-main-input flex w-full items-start gap-2 rounded-md px-3 py-2",children:S.jsxs("span",{className:"min-w-0 flex-1",children:[S.jsx(nG,{initial:j,onCommit:se=>E(e,se),onCancel:k}),ie&&S.jsx("span",{className:"text-content-muted mt-1 line-clamp-2 block text-xs leading-snug",children:ie})]})})}):S.jsxs("li",{ref:O,"data-proximity-index":n,className:"group relative z-10",children:[S.jsx("div",{role:"button",tabIndex:G?0:-1,"data-variant-id":N?M.workItemId:void 0,"data-variant-key":t,onClick:()=>{if($)return;const se=window.getSelection();se&&!se.isCollapsed||(e.kind==="active"?c(e.variant):e.kind==="past"?f(e.entry):h())},onKeyDown:se=>{$||(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),se.stopPropagation(),e.kind==="active"?c(e.variant):e.kind==="past"?f(e.entry):h())},onPointerDown:se=>{$||(e.kind==="active"?D&&p(e.variant.workItemId,se):e.kind==="past"&&v(e.entry,se))},"aria-pressed":G?r:void 0,"aria-disabled":N?!G:void 0,"aria-busy":Y||H,onMouseEnter:N?()=>y(M.workItemId):void 0,onMouseLeave:N?()=>y(null):void 0,className:ar("focus-visible:ring-content-muted/40 flex w-full items-start gap-2 rounded-md px-3 py-2 text-left transition-colors focus:outline-none focus-visible:ring-1",r&&"bg-main-input ring-content-muted/40 ring-1 ring-inset",D&&V&&"cursor-grab active:cursor-grabbing",(Y||K)&&"cursor-pointer",!D&&!Y&&!K&&"cursor-not-allowed opacity-60",$&&"cursor-not-allowed opacity-50"),style:D?{touchAction:"none"}:void 0,children:S.jsxs("span",{className:"min-w-0 flex-1",children:[S.jsxs("span",{className:"flex items-center gap-2",children:[(Y||H)&&S.jsx(tx,{className:"text-content-muted shrink-0 text-sm","data-testid":H&&!Y?"variant-refining":void 0}),S.jsx(Fo,{label:"Double-click to rename",disabled:R,children:S.jsx("span",{onDoubleClick:se=>{se.stopPropagation(),R||b(t)},className:ar("min-w-0 flex-1 truncate text-sm font-medium select-text",R?"cursor-default":"cursor-text",D||r?"text-content":"text-content-muted"),children:j})}),B&&S.jsx(YC,{label:"Failed"}),Q&&S.jsx(YC,{label:"Cancelled"}),Z&&S.jsx("span",{className:"ml-auto max-w-[8rem] shrink-0 truncate rounded px-1.5 py-0.5 text-[10px] font-medium opacity-100 transition-opacity duration-150 group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",style:$T(Z),children:Z})]}),ie&&S.jsx("span",{className:"text-content-muted mt-0.5 line-clamp-2 block cursor-text text-xs leading-snug select-text",children:ie})]})}),S.jsxs("div",{className:ar("absolute top-1.5 right-2 flex items-center gap-0.5 transition-opacity duration-150","pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 has-[:focus-visible]:pointer-events-auto has-[:focus-visible]:opacity-100"),children:[ee||le?S.jsx(Fo,{label:ue,children:S.jsx("button",{type:"button","aria-label":ue,onClick:se=>{se.stopPropagation(),P(JW({label:j,description:ee,reference:le,projectPath:A}))},onPointerDown:se=>se.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1",children:S.jsx(Fd,{size:13,weight:"bold"})})}):null,!R&&S.jsx(Fo,{label:"Rename",children:S.jsx("button",{type:"button","aria-label":"Rename direction",onClick:se=>{se.stopPropagation(),b(t)},onPointerDown:se=>se.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1",children:S.jsx(vz,{size:13,weight:"bold"})})}),!R&&S.jsx(Fo,{label:"Remove",children:S.jsx("button",{type:"button","data-variant-remove-id":e.kind==="active"?e.variant.workItemId:void 0,"aria-label":"Remove direction",disabled:te,onClick:se=>{se.stopPropagation(),e.kind==="active"?x(e.variant):_(e.entry)},onPointerDown:se=>se.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 ml-1 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",children:S.jsx(xz,{size:13,weight:"bold"})})})]})]})},nG=({initial:t,onCommit:e,onCancel:n})=>{const[r,s]=g.useState(t),i=g.useRef(!1),a=g.useCallback(c=>{c&&(c.focus(),c.select())},[]),u=c=>{i.current||(i.current=!0,c?e(r):n())};return S.jsx("input",{ref:a,type:"text",value:r,maxLength:120,"aria-label":"Rename direction",onChange:c=>s(c.target.value),onKeyDown:c=>{c.stopPropagation(),c.key==="Enter"?(c.preventDefault(),u(!0)):c.key==="Escape"&&(c.preventDefault(),u(!1))},onBlur:()=>u(!0),onClick:c=>c.stopPropagation(),onPointerDown:c=>c.stopPropagation(),className:"border-content-muted/40 bg-main text-content focus:ring-content-muted/50 w-full rounded border px-1.5 py-0.5 text-sm font-medium focus:ring-1 focus:outline-none"})},YC=({label:t})=>S.jsx("span",{className:"bg-main-input text-content-muted shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium tracking-wide uppercase",children:t}),rG=({entry:t,deploying:e,deployedUrl:n,onDeploy:r,isDeployDisabled:s=!1})=>{const a=e?"Deploying…":n?"Copy link":"Share";return S.jsxs("div",{className:"border-main-border bg-main-light flex shrink-0 items-center justify-between gap-3 border-t px-3 pt-2 pb-4",children:[S.jsxs("div",{className:"min-w-0",children:[S.jsx("div",{className:"text-content truncate text-sm font-medium",children:t.label.trim()||"Untitled direction"}),n?S.jsx("div",{className:"text-content-muted text-[11px]",children:"Deployed — share link ready"}):null]}),S.jsxs("button",{type:"button",onClick:()=>r(t),disabled:e||s,title:n?`Copy share link (${n})`:"Deploy this direction and get a public link to share",className:"border-main-border text-content hover:bg-main-input flex shrink-0 items-center gap-1 rounded-md border px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[n&&!e?S.jsx(Fd,{size:12,weight:"bold"}):null,a]})]})},sG={agent_browser:"Browser extracted",cache:"Cached",static:"Bundled catalog",manual:"Manual"},iG={design_context:"DESIGN.md",source_context:"Source",qa_report:"QA",asset:"Asset"},oG=({artifacts:t})=>{const[e,n]=g.useState(null),r=g.useMemo(()=>e&&t.some(i=>i.id===e)?e:null,[t,e]);if(t.length===0)return null;const s=i=>{n(a=>a===i?null:i)};return S.jsxs("section",{"aria-label":"Directions session artifacts",className:"mt-4",children:[S.jsx("div",{className:"flex shrink-0 items-center px-3 py-2",children:S.jsx("span",{className:"text-content truncate text-sm font-medium",children:"Artifacts"})}),S.jsx("ul",{className:"mt-2 space-y-1 px-1",children:t.map(i=>S.jsx(aG,{artifact:i,isExpanded:i.id===r,onToggle:()=>s(i.id)},i.id))})]})},aG=({artifact:t,isExpanded:e,onToggle:n})=>{const r=iG[t.kind],s=t.source?sG[t.source]:null,i=[t.kind==="design_context"?null:s,t.summary].filter(Boolean).join(" · "),a=t.kind==="design_context"&&!!t.viewUrl,u=`${e?"Hide":"View"} ${r} artifact${t.label?`: ${t.label}`:""}`;return a?S.jsx("li",{className:"border-main-border rounded-md border",children:S.jsxs("div",{className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-xs",children:[S.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[S.jsxs("span",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"border-content-muted/30 bg-main-input text-content-muted shrink-0 rounded-full border px-2 py-0.5 text-[9px] font-semibold tracking-wide uppercase",children:r}),S.jsx("span",{className:"text-content truncate text-xs font-medium",children:t.label})]}),i?S.jsx("span",{className:"text-content-muted mt-0.5 truncate text-[11px]",children:i}):null]}),S.jsx("a",{href:t.viewUrl,target:"_blank",rel:"noreferrer","aria-label":`Open ${r} artifact${t.label?`: ${t.label}`:""}`,className:"text-content-muted hover:bg-main-input hover:text-content focus-visible:ring-content-muted/40 shrink-0 rounded p-1 transition-colors focus:outline-none focus-visible:ring-1",children:S.jsx(fz,{className:"h-3.5 w-3.5",weight:"bold"})})]})}):S.jsxs("li",{className:"border-main-border rounded-md border",children:[S.jsxs("button",{type:"button",onClick:n,"aria-expanded":e,"aria-label":u,className:"hover:bg-main-input flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-xs transition-colors",children:[S.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[S.jsxs("span",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-content-muted text-[10px] font-semibold tracking-wide uppercase",children:r}),S.jsx("span",{className:"text-content truncate text-xs font-medium",children:t.label})]}),i?S.jsx("span",{className:"text-content-muted mt-0.5 truncate text-[11px]",children:i}):null]}),S.jsx("span",{className:"text-content-muted shrink-0 text-[11px]",children:e?"Hide":"View"})]}),e?S.jsx("div",{className:"border-main-border bg-main-light border-t px-3 py-2",children:S.jsx(lG,{artifact:t})}):null]})},lG=({artifact:t})=>S.jsxs("div",{className:"text-content-muted space-y-1 text-[11px]",children:[t.summary?S.jsx("p",{children:t.summary}):null,t.path?S.jsxs("p",{children:["Stored at ",t.path]}):null,!t.summary&&!t.path?S.jsx("p",{children:"No inline content available for this artifact."}):null]}),uG=({selectedVariant:t,busy:e,onSend:n,onDeploy:r,onDeployCanvas:s,canDeploy:i,canDeployCanvas:a,canSendToAgent:u,canvasVariantCount:c,canvasDeployedUrl:f,deployedUrl:h})=>{var N,R,M,L;const p=t?((R=(N=t.actions)==null?void 0:N.commit)==null?void 0:R.enabled)??t.status==="succeeded":!1,v=p&&e===null,y=(e==null?void 0:e.kind)==="commit"&&e.variantId===(t==null?void 0:t.workItemId),x=(e==null?void 0:e.kind)==="deploy"&&e.variantId===(t==null?void 0:t.workItemId),_=(e==null?void 0:e.kind)==="deploy-canvas",b=!i||!p||e!==null,E=a&&c>0,P=x?"Deploying…":h?"Copy link":"Share",A=_?"Sharing…":f?"Copy canvas link":"Share canvas",O=y?"Applying…":"Apply to project";return S.jsxs("div",{className:"border-main-border bg-main-light flex shrink-0 items-center justify-between gap-3 border-t px-3 pt-2 pb-4",children:[S.jsx("div",{className:"min-w-0",children:t?S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"text-content truncate text-sm font-medium",children:t.label.trim()||"Untitled direction"}),h?S.jsx("div",{className:"text-content-muted text-[11px]",children:"Deployed — share link ready"}):null]}):null}),S.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[S.jsx(U5,{primaryLabel:P,primaryIcon:h&&!x?Fd:void 0,primaryAction:()=>{t&&r(t)},isDisabled:b,isDropdownDisabled:e!==null,isLoading:x,loadingLabel:"Deploying…",dropdownAriaLabel:"More share actions",dropdownItems:E?[{label:A,icon:f&&!_?Fd:void 0,onClick:s,isDisabled:e!==null}]:[]}),u?S.jsx("button",{type:"button",onClick:()=>{t&&n(t)},disabled:!v,title:(L=(M=t==null?void 0:t.actions)==null?void 0:M.commit)==null?void 0:L.reason,className:"bg-secondary text-secondary-foreground hover:bg-accent rounded-md px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:O}):null]})]})},aR=()=>S.jsx("div",{"data-testid":"direction-skeleton-row","aria-hidden":"true",className:"flex w-full items-start rounded-md px-3 py-2",children:S.jsxs("span",{className:"min-w-0 flex-1",children:[S.jsxs("span",{className:"flex items-center gap-2",children:[S.jsx(tx,{className:"text-content-muted shrink-0 text-sm"}),S.jsx("span",{className:"bg-muted-foreground/15 h-3.5 w-28 animate-pulse rounded"})]}),S.jsx("span",{className:"mt-1.5 flex",children:S.jsx("span",{className:"bg-muted-foreground/10 h-2.5 w-full max-w-[14rem] animate-pulse rounded"})})]})}),cG=({groups:t})=>S.jsx("div",{className:"space-y-0.5",children:t.flatMap(e=>Array.from({length:Math.max(1,e.count)}).map((n,r)=>S.jsx(aR,{},`${e.requestId}-${r}`)))}),dG=()=>S.jsx("div",{"data-testid":"direction-boot-skeletons",className:"space-y-0.5",children:Array.from({length:3}).map((t,e)=>S.jsx(aR,{},e))}),fG=()=>S.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-center",children:[S.jsx("div",{className:"text-content text-sm",children:"No directions yet"}),S.jsx("div",{className:"text-content-muted text-xs",children:"They’ll appear here as they generate."})]}),QC="Try different ways to create a dropdown that feels fluid and dynamic",hG=({isMCPSession:t=!1,mcpEditor:e=null})=>{const[n,r]=g.useState(!1),s=VU(e),i=t?s:"your coding agent",a=()=>{navigator.clipboard.writeText(QC).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)})};return S.jsxs("div",{className:"flex flex-col items-start gap-3 px-2 py-2",children:[S.jsx("p",{className:"text-content text-sm font-medium",children:"Create your first direction"}),S.jsxs("p",{className:"text-content-muted text-xs",children:["Use ",i," to generate directions."]}),S.jsxs("div",{className:"w-full",children:[S.jsx("p",{className:"text-content-muted mb-2 text-xs",children:"Here's a sample prompt to use:"}),S.jsxs("div",{className:"border-main-border bg-main-input relative rounded-md border px-3 py-2.5 pr-8",children:[S.jsxs("p",{className:"text-content-muted text-xs leading-snug",children:["“",QC,"”"]}),S.jsx("button",{type:"button",onClick:a,className:"text-content-muted hover:bg-main-border hover:text-content absolute top-2 right-2 rounded p-0.5 transition-colors",title:"Copy to clipboard",children:n?S.jsx(fT,{className:"h-3.5 w-3.5 text-emerald-500",weight:"bold"}):S.jsx(Fd,{className:"h-3.5 w-3.5",weight:"bold"})})]})]})]})},pG=({onClose:t})=>{const e=Je(qT);return t?S.jsxs("div",{className:"z-10 flex flex-shrink-0 items-center justify-between gap-2 border-b border-main-border bg-main-light px-2.5 py-2.5",children:[e?S.jsx("span",{className:"text-content min-w-0 truncate text-sm font-medium",title:e,children:e}):S.jsx("span",{}),S.jsx(Fo,{label:"Close panel",side:"bottom",children:S.jsx("button",{onClick:t,className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:S.jsx(yz,{className:"h-4 w-4",weight:"bold"})})})]}):null},mG='[data-menu-item]:not([disabled]):not([aria-disabled="true"])',gG=({itemSelector:t=mG,loop:e=!1}={})=>{const n=g.useRef(null),r=g.useRef(null),s=g.useCallback(a=>{var u;n.current=a,a?r.current=jU():((u=r.current)==null||u.call(r),r.current=null)},[]),i=g.useCallback(a=>{var x;const{key:u}=a;if(u!=="ArrowDown"&&u!=="ArrowUp"&&u!=="Home"&&u!=="End")return;const c=n.current;if(!c)return;const f=Array.from(c.querySelectorAll(t));if(f.length===0)return;a.preventDefault(),a.stopPropagation();const h=f.indexOf(document.activeElement),p=f.length-1,v=_=>{if(h===-1)return _===1?0:p;const b=h+_;return e?(b+f.length)%f.length:Math.min(Math.max(b,0),p)};let y;u==="Home"?y=0:u==="End"?y=p:u==="ArrowDown"?y=v(1):y=v(-1),(x=f[y])==null||x.focus()},[t,e]);return{containerRef:s,onKeyDown:i}},XC="/assets/arena-Db0j1set.png",vG=ds("useIntegrations"),JC=["integrations"],yG="rivet:connect-result",_G=t=>typeof t=="object"&&t!==null&&t.type===yG,xG=tt(null),wG=()=>{const t=f8(),[e,n]=nP(xG),r=U1({queryKey:JC,queryFn:async()=>{const u=await fetch("/api/integrations");if(!u.ok)throw new Error(`Failed to load integrations (${u.status})`);return(await u.json()).integrations??[]},staleTime:1e4}),s=g.useCallback(()=>t.invalidateQueries({queryKey:JC}),[t]),i=g.useCallback(async u=>{const c=window.open("","_blank","width=560,height=720");if(!c)throw new Error("Popup blocked. Allow popups to connect.");n(u);try{const f=await fetch(`/api/integrations/${u}/connect`,{method:"POST"}),h=await f.json().catch(()=>({}));if(!f.ok||!h.authUrl)throw c.close(),new Error(h.error||`Could not connect ${u}`);c.location.href=h.authUrl,await new Promise(p=>{const v=()=>{window.removeEventListener("message",y),clearInterval(x),s(),p()},y=_=>{_G(_.data)&&_.data.provider===u&&(_.data.status==="error"&&vG.warn(`Connect failed for ${u}:`,_.data.message),v())};window.addEventListener("message",y);const x=setInterval(()=>{c.closed&&v()},500)})}finally{n(null)}},[s,n]),a=g.useCallback(async u=>{n(u);try{const c=await fetch(`/api/integrations/${u}`,{method:"DELETE"});if(!c.ok){const f=await c.json().catch(()=>({}));throw new Error(f.error||`Could not disconnect ${u}`)}await s()}finally{n(null)}},[s,n]);return{integrations:r.data??[],isLoading:r.isPending,error:r.error instanceof Error?r.error.message:null,pendingProvider:e,connect:i,disconnect:a,refetch:s}},fu=({onClick:t,title:e,shortcut:n,children:r,disabled:s=!1,className:i="",type:a="button","data-cy":u})=>{const c=S.jsx("button",{onClick:t,disabled:s,className:i,type:a,"data-cy":u,children:r});return e?S.jsx(mx,{content:S.jsxs("div",{className:"flex flex-row items-center gap-2",children:[S.jsx("span",{children:e}),n?S.jsx("span",{className:"rounded bg-white/15 px-1.5 py-0.5 text-[11px]",children:n}):null]}),children:c}):c},ek=ds("ConnectorsModal"),bG=()=>S.jsx("svg",{viewBox:"0 0 24 24",className:"h-6 w-6","aria-hidden":"true",children:S.jsx("path",{fill:"currentColor",d:"M12 0C5.373 0 0 5.372 0 12c0 5.084 3.163 9.426 7.627 11.174-.105-.949-.2-2.405.042-3.441.218-.937 1.407-5.965 1.407-5.965s-.359-.719-.359-1.781c0-1.669.967-2.915 2.171-2.915 1.024 0 1.518.769 1.518 1.69 0 1.029-.655 2.568-.994 3.995-.283 1.194.599 2.169 1.777 2.169 2.132 0 3.772-2.249 3.772-5.495 0-2.873-2.064-4.882-5.012-4.882-3.414 0-5.418 2.561-5.418 5.207 0 1.031.397 2.137.893 2.739.098.119.112.223.083.344-.091.379-.293 1.194-.333 1.361-.052.22-.174.266-.401.16-1.499-.698-2.436-2.889-2.436-4.649 0-3.785 2.75-7.262 7.929-7.262 4.163 0 7.398 2.967 7.398 6.931 0 4.136-2.607 7.464-6.227 7.464-1.216 0-2.36-.631-2.75-1.378l-.748 2.853c-.271 1.043-1.002 2.35-1.492 3.146A12.004 12.004 0 0 0 12 24c6.627 0 12-5.373 12-12C24 5.372 18.627 0 12 0z"})}),SG=()=>S.jsx("span",{"aria-hidden":"true",className:"h-6 w-6 bg-[#b1b1b1]",style:{WebkitMaskImage:`url(${XC})`,maskImage:`url(${XC})`,WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskPosition:"center",maskPosition:"center"}}),EG=[{provider:"pinterest",name:"Pinterest",description:"Pull boards and pins in as visual references.",tileClassName:"bg-[#e60023] text-white",icon:S.jsx(bG,{})},{provider:"arena",name:"Are.na",description:"Connect channels of collected blocks and links.",tileClassName:"bg-[#18181b] text-content",icon:S.jsx(SG,{})}],CG=({meta:t,integration:e,isPending:n,isHighlighted:r,onConnect:s,onDisconnect:i})=>{const a=(e==null?void 0:e.status)==="connected",u=e!=null&&e.externalUsername?`@${e.externalUsername}`:null;return S.jsxs("article",{className:`flex flex-col rounded-xl bg-main-light p-[18px] ${r?"ring-2 ring-secondary":""}`,children:[S.jsx("span",{className:`grid h-[52px] w-[52px] flex-none place-items-center rounded-xl ${t.tileClassName}`,"aria-hidden":"true",children:t.icon}),S.jsxs("div",{className:"mt-4 flex-1",children:[S.jsxs("h2",{className:"text-content flex items-center gap-1.5 text-[15px] font-semibold",children:[t.name,a?S.jsx(fT,{className:"h-3.5 w-3.5",weight:"bold","aria-hidden":"true"}):null]}),S.jsx("p",{className:"text-content-subtle mt-1 text-[13px] leading-relaxed",children:t.description}),a&&u?S.jsx("p",{className:"text-content-muted mt-2.5 text-xs font-medium",children:u}):null]}),a?S.jsx("button",{type:"button",onClick:i,disabled:n,className:"active-push mt-[18px] inline-flex min-h-[38px] w-full items-center justify-center rounded-lg bg-main-input px-3.5 text-[13px] font-semibold text-content-muted transition-colors hover:bg-red-500/10 hover:text-red-300 disabled:cursor-not-allowed disabled:opacity-50",children:n?"Disconnecting…":"Disconnect"}):S.jsx("button",{type:"button",onClick:s,disabled:n,className:"active-push mt-[18px] inline-flex min-h-[38px] w-full items-center justify-center rounded-lg bg-secondary px-3.5 text-[13px] font-semibold text-secondary-foreground transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",children:n?"Connecting…":"Connect"})]})},x_=({isOpen:t,onClose:e,context:n="menu",highlightProvider:r=null})=>{const{integrations:s,isLoading:i,error:a,pendingProvider:u,connect:c,disconnect:f}=wG(),[h,p]=g.useState(null),v=b=>s.find(E=>E.provider===b),y=g.useCallback(b=>{c(b).catch(E=>{const k=E instanceof Error?E.message:"Could not connect.";ek.warn(`Connect error for ${b}:`,k),ht.error(k)})},[c]),x=g.useCallback(b=>{f(b).catch(E=>{const k=E instanceof Error?E.message:"Could not disconnect.";ek.warn(`Disconnect error for ${b}:`,k),ht.error(k)})},[f]),_=n==="onboarding";return S.jsx(Qm,{open:t,onOpenChange:b=>!b&&e(),children:S.jsxs(Xm,{children:[S.jsx(Jm,{className:"fixed inset-0 z-max bg-black/40"}),S.jsx(e0,{ref:p,className:"fixed left-1/2 top-1/2 z-max w-[560px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-main-border bg-main font-main shadow-2xl outline-none",children:S.jsxs(nR,{value:h,children:[S.jsxs("div",{className:"flex items-center justify-between rounded-t-lg border-b border-main-border bg-main-light px-4 py-2",children:[S.jsx(t0,{className:"text-base font-medium text-content",children:"Connect design references"}),S.jsx(fu,{onClick:e,title:"Close",className:"rounded p-1 text-content-subtle transition-colors hover:bg-main-hover hover:text-content",children:S.jsx(ET,{className:"h-4 w-4",weight:"bold"})})]}),S.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[S.jsx(n0,{className:"text-sm text-content-subtle",children:"Connect your design references to use them with Rivet’s MCP."}),a?S.jsx("p",{className:"rounded-lg bg-red-500/10 px-4 py-3 text-[13px] font-medium text-red-300",children:a}):null,S.jsx("div",{className:"grid grid-cols-2 gap-4",children:EG.map(b=>S.jsx(CG,{meta:b,integration:v(b.provider),isPending:i||u===b.provider,isHighlighted:r===b.provider,onConnect:()=>y(b.provider),onDisconnect:()=>x(b.provider)},b.provider))}),_?S.jsxs("div",{className:"flex items-center justify-between gap-4",children:[S.jsx("p",{className:"text-xs text-content-subtle",children:"You can always do this later from the account menu."}),S.jsx("button",{type:"button",onClick:e,className:"active-push flex-none rounded-lg bg-secondary px-3.5 py-2 text-[13px] font-medium text-secondary-foreground transition-colors hover:bg-accent",children:"Skip for now"})]}):null]})]})})]})})},tk=({className:t=""})=>S.jsx("span",{"aria-hidden":"true",className:`rivet-skeleton block rounded ${t}`.trim()}),kG=ds("SupportTicketModal"),nk=5e3,f1="feedback",PG=t=>{var r;if(!t)return null;const e=(r=t.formErrors)==null?void 0:r[0];if(e)return e;const n=t.fieldErrors??{};for(const s of Object.values(n)){const i=s==null?void 0:s[0];if(i)return i}return null},TG=async t=>{let e;try{e=await t.json()}catch{e=void 0}if(t.status===400){if(typeof(e==null?void 0:e.details)=="string"&&e.details.trim())return e.details;if(typeof(e==null?void 0:e.details)=="object"&&e.details!==null){const n=PG(e.details);if(n)return n}return"Please check your feedback and try again."}return t.status>=500?typeof(e==null?void 0:e.details)=="string"&&e.details.trim()?e.details:"Could not send feedback right now. Please try again later.":typeof(e==null?void 0:e.error)=="string"&&e.error.trim()?e.error:`HTTP ${t.status}`},RG=({isOpen:t,onClose:e,contactEmail:n})=>{const r=nD(),[s,i]=g.useState(""),[a,u]=g.useState(!1),[c,f]=g.useState(null),h=g.useCallback(()=>{i("")},[]),p=g.useCallback(()=>{a||(h(),e())},[a,e,h]),v=g.useCallback(async()=>{const b=s.trim();if(!(!b||a)){u(!0);try{const E=typeof(r==null?void 0:r.get_session_id)=="function"?r.get_session_id():void 0,k=typeof(r==null?void 0:r.get_distinct_id)=="function"?r.get_distinct_id():void 0,P=n==null?void 0:n.trim(),T=await fetch("/api/support/tickets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:f1,message:b,contactEmail:P||void 0,metadata:{posthogSessionId:E??void 0,posthogDistinctId:k??void 0,appVersion:"0.14.1",appEnvironment:"production",pageUrl:window.location.href,userAgent:navigator.userAgent,submittedAt:new Date().toISOString()}})});if(!T.ok){const A=await TG(T);throw new Error(A)}r==null||r.capture("support_ticket_submitted",{ticket_type:f1,has_posthog_session_id:!!E}),ht.success("Feedback sent",{description:"Thanks for sharing this."}),h(),e()}catch(E){const k=E instanceof Error?E.message:"Failed to send message";r==null||r.capture("support_ticket_submit_failed",{ticket_type:f1,error:k}),kG.error("Failed to submit support ticket:",k),ht.error("Could not send feedback",{description:k})}finally{u(!1)}}},[n,a,s,e,r,h]),y=g.useCallback(b=>{b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),v())},[v]),x=nk-s.length,_=a||s.trim().length===0;return S.jsx(Qm,{open:t,onOpenChange:b=>!b&&p(),children:S.jsxs(Xm,{children:[S.jsx(Jm,{className:"fixed inset-0 z-max bg-black/40"}),S.jsx(e0,{ref:f,className:"fixed left-1/2 top-1/2 z-max w-[440px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-main-border bg-main font-main shadow-2xl outline-none",children:S.jsxs(nR,{value:c,children:[S.jsxs("div",{className:"flex items-center justify-between rounded-t-lg border-b border-main-border bg-main-light px-4 py-2",children:[S.jsx(t0,{className:"text-base font-medium text-content",children:"Send feedback"}),S.jsx(fu,{onClick:p,disabled:a,title:"Close",className:"rounded p-1 text-content-subtle transition-colors hover:bg-main-hover hover:text-content disabled:cursor-not-allowed disabled:opacity-50",children:S.jsx(ET,{className:"h-4 w-4",weight:"bold"})})]}),S.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[S.jsx(n0,{className:"text-sm text-content-subtle",children:"Tell us what happened or what we can improve."}),S.jsxs("div",{className:"rounded-lg bg-main-input outline outline-1 outline-transparent transition-[outline-color] focus-within:outline-white/20",children:[S.jsx("textarea",{id:"support-ticket-message","aria-label":"Your feedback",value:s,onChange:b=>i(b.target.value),onKeyDown:y,maxLength:nk,rows:6,disabled:a,placeholder:"What happened?",className:"max-h-64 w-full resize-none overflow-y-auto bg-transparent pb-1 pl-3 pr-3 pt-3 text-sm text-content placeholder-content-subtle focus:outline-none disabled:opacity-50"}),S.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1",children:[S.jsx("span",{className:"text-xs text-content-subtle",children:"Context details are included automatically."}),S.jsxs("div",{className:"flex items-center gap-2",children:[x<=500&&S.jsx("span",{className:"text-xs text-content-subtle",children:x}),S.jsx(fu,{onClick:v,disabled:_,title:"Send feedback",shortcut:"⌘↵",className:"flex items-center justify-center rounded bg-primary p-1 text-content transition-colors hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-80",children:a?S.jsx(r0,{className:"h-5 w-5 animate-spin",weight:"bold"}):S.jsx(hz,{className:"h-5 w-5",weight:"bold"})})]})]})]})]})]})})]})})},AG=ds("ProfileAvatar"),lR=(t,e)=>{const n=(t??"").trim();if(n)return n.split(/\s+/).filter(Boolean)[0]??"";const s=((e??"").split("@")[0]??"").split(/[._\-+]/).filter(Boolean)[0]??"";return s?s[0].toUpperCase()+s.slice(1):""},IG=(t,e)=>lR(t,e).charAt(0).toUpperCase(),MG=({className:t="",side:e="bottom",align:n="end"})=>{const{name:r,email:s}=Je(YT),i=Je(n5),a=Je(t5),[u,c]=g.useState(!1),[f,h]=g.useState(!1),[p,v]=g.useState(!1),[y,x]=g.useState(!1),{containerRef:_,onKeyDown:b}=gG(),E=Je(pf),k=IG(r,s);if(!k)return E?S.jsxs("span",{"data-testid":"profile-avatar-skeleton","aria-hidden":"true",className:`flex shrink-0 items-center gap-2 ${t}`.trim(),children:[S.jsx(tk,{className:"h-7 w-7 rounded-full"}),S.jsx(tk,{className:"h-3 w-16"})]}):null;const P=lR(r,s),T=(r==null?void 0:r.trim())||null,A=(s==null?void 0:s.trim())||null,O=async()=>{x(!0);try{const N=await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin"});if(!N.ok)throw new Error(`Logout failed: ${N.status}`)}catch(N){AG.warn("Logout request failed",N),ht.error("Could not log out. Please try again."),x(!1);return}window.location.reload()};return S.jsxs(S.Fragment,{children:[S.jsxs(V5,{open:u,onOpenChange:c,children:[S.jsx($5,{asChild:!0,children:S.jsxs("button",{type:"button","aria-label":"Account",className:`flex shrink-0 select-none items-center gap-2 text-content-muted transition-colors hover:text-content ${t}`,children:[S.jsx("span",{className:"flex h-7 w-7 items-center justify-center rounded-full border border-main-border bg-main-input text-[11px] font-semibold leading-none",children:k}),P?S.jsx("span",{className:"max-w-[8rem] truncate text-xs font-medium",children:P}):null]})}),S.jsx(H5,{children:S.jsxs(z5,{ref:_,onKeyDown:b,role:"menu",className:"z-[60] min-w-[180px] rounded-lg bg-surface-2 p-1 shadow-lg",side:e,sideOffset:6,align:n,children:[T||A?S.jsxs("div",{className:"border-b border-main-border px-3 py-2",children:[T?S.jsx("div",{className:"truncate text-xs font-medium text-content",children:T}):null,A?S.jsx("div",{className:"truncate text-[11px] text-content-muted",children:A}):null]}):null,S.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{c(!1),h(!0)},disabled:!i||a,className:"mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs text-content transition-colors hover:bg-hover focus:bg-hover focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[S.jsx(wT,{className:"h-3.5 w-3.5",weight:"bold"}),"Connect design references"]}),S.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{c(!1),v(!0)},className:"mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs text-content transition-colors hover:bg-hover focus:bg-hover focus:outline-none",children:[S.jsx(mz,{className:"h-3.5 w-3.5",weight:"bold"}),"Share feedback"]}),S.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:O,disabled:y,className:"mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs text-content transition-colors hover:bg-hover focus:bg-hover focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[S.jsx(_z,{className:"h-3.5 w-3.5",weight:"bold"}),y?"Logging out…":"Log out"]})]})})]}),S.jsx(x_,{isOpen:f,onClose:()=>h(!1)}),S.jsx(RG,{isOpen:p,onClose:()=>v(!1),contactEmail:s??void 0})]})},NG=({onClose:t})=>S.jsxs("div",{className:"bg-main font-main scrollbar-hide relative flex h-full w-full cursor-auto flex-col overflow-hidden shadow-2xl","data-cy":"element-inspector",children:[S.jsx(pG,{onClose:t}),S.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:S.jsx(GW,{})}),S.jsx("div",{className:"border-main-border bg-main-light flex flex-shrink-0 items-center border-t px-2.5 py-1.5",children:S.jsx(MG,{side:"top",align:"start"})})]}),OG=ds("useServerConfig"),LG=()=>{const[t,e]=g.useState(null),[n,r]=g.useState(!0),[s,i]=g.useState(null),a=g.useCallback(async()=>{var u;try{r(!0),i(null);const c=await fetch("/api/health");if(!c.ok)throw new Error(`Failed to fetch config: ${c.status}`);const f=await c.json();if(!f.framework)throw new Error("Server did not return framework information");const h={userPort:((u=f.ports)==null?void 0:u.userDevServer)||3e3,framework:f.framework};return e(h),h}catch(c){const f=c instanceof Error?c.message:"Failed to fetch server config";throw i(f),OG.warn("Error fetching server config:",c),c}finally{r(!1)}},[]);return{config:t,fetchConfig:a,isLoading:n,error:s}},DG="#1C1C20",Ai=[118,118,124],rk=.85,jG=3,FG=.15,Jh=36,VG=4.4,$G=.7,HG=3.5,zG=.8,sk=9,UG=11,BG=[1.35,1.12,.95,.85],WG=[0,1.1,2.3,3.1],GG=[0,.35,.16,.13],KG=[.9,.5,.4,.35],Aa=3,h1=[[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.14,y1:.13,x2:.86,y2:.23,level:1},{x1:.14,y1:.28,x2:.3,y2:.87,level:1},{x1:.34,y1:.28,x2:.86,y2:.87,level:1},{x1:.165,y1:.155,x2:.225,y2:.205,level:2},{x1:.7,y1:.155,x2:.755,y2:.205,level:2},{x1:.775,y1:.155,x2:.83,y2:.205,level:2},{x1:.165,y1:.32,x2:.275,y2:.375,level:2},{x1:.165,y1:.415,x2:.275,y2:.47,level:2},{x1:.165,y1:.51,x2:.275,y2:.565,level:2},{x1:.37,y1:.32,x2:.585,y2:.56,level:2},{x1:.615,y1:.32,x2:.83,y2:.56,level:2},{x1:.37,y1:.61,x2:.83,y2:.83,level:2},{hline:!0,x1:.39,x2:.81,y:.685,level:3},{hline:!0,x1:.39,x2:.75,y:.755,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.16,y1:.17,x2:.52,y2:.45,level:1},{x1:.58,y1:.17,x2:.685,y2:.29,level:1},{x1:.715,y1:.17,x2:.84,y2:.29,level:1},{x1:.58,y1:.33,x2:.685,y2:.45,level:1},{x1:.715,y1:.33,x2:.84,y2:.45,level:1},{x1:.16,y1:.55,x2:.84,y2:.85,level:1},{x1:.19,y1:.21,x2:.36,y2:.33,level:2},{hline:!0,x1:.19,x2:.48,y:.37,level:3},{hline:!0,x1:.19,x2:.42,y:.42,level:3},{x1:.19,y1:.6,x2:.49,y2:.8,level:2},{hline:!0,x1:.53,x2:.8,y:.63,level:3},{hline:!0,x1:.53,x2:.76,y:.7,level:3},{hline:!0,x1:.53,x2:.79,y:.77,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.14,y1:.13,x2:.86,y2:.22,level:1},{x1:.14,y1:.28,x2:.36,y2:.87,level:1},{x1:.39,y1:.28,x2:.61,y2:.87,level:1},{x1:.64,y1:.28,x2:.86,y2:.87,level:1},{x1:.165,y1:.15,x2:.225,y2:.2,level:2},{x1:.165,y1:.32,x2:.335,y2:.52,level:2},{x1:.415,y1:.32,x2:.585,y2:.52,level:2},{x1:.665,y1:.32,x2:.835,y2:.52,level:2},{hline:!0,x1:.165,x2:.335,y:.6,level:3},{hline:!0,x1:.165,x2:.3,y:.67,level:3},{hline:!0,x1:.415,x2:.585,y:.6,level:3},{hline:!0,x1:.415,x2:.55,y:.67,level:3},{hline:!0,x1:.665,x2:.835,y:.6,level:3},{hline:!0,x1:.665,x2:.8,y:.67,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.3,y1:.22,x2:.7,y2:.74,level:1},{x1:.34,y1:.27,x2:.55,y2:.34,level:2},{hline:!0,x1:.36,x2:.64,y:.42,level:3},{hline:!0,x1:.36,x2:.6,y:.49,level:3},{hline:!0,x1:.36,x2:.62,y:.56,level:3},{x1:.5,y1:.63,x2:.575,y2:.69,level:2},{x1:.595,y1:.63,x2:.66,y2:.69,level:2}]],ep=t=>{let e=t|0;return e=Math.imul(e^e>>>16,73244475),e=Math.imul(e^e>>>16,73244475),e^=e>>>16,(e>>>0)/4294967296},Ep=t=>{const e=Math.min(1,Math.max(0,t));return e*e*(3-2*e)},Ia=(t,e)=>(Math.round(t/e-.5)+.5)*e,qG=Math.sin(Math.PI/3),ik=(t,e,n,r,s)=>{if(t.beginPath(),e===0)t.arc(n,r,s,0,Math.PI*2);else if(e===1){const i=s*qG;t.moveTo(n,r-s),t.lineTo(n+i,r+s/2),t.lineTo(n-i,r+s/2),t.closePath()}else{const i=s*.85;t.rect(n-i,r-i,i*2,i*2)}t.fill()},ZG=(t,e,n)=>{let r;if(n.hline){const s=Math.max(n.x1-t,t-n.x2,0),i=Math.abs(e-n.y1);r=Math.hypot(s,i)-sk}else{const s=Math.max(n.x1-t,t-n.x2,0),i=Math.max(n.y1-e,e-n.y2,0);s===0&&i===0?r=-Math.min(t-n.x1,n.x2-t,e-n.y1,n.y2-e):r=Math.hypot(s,i),r=Math.abs(r)-sk}return Ep(.5-r/(2*UG))},uR=({className:t="",trackGlobalLoaderCount:e=!0})=>{const n=st(ZT),r=g.useRef(null),s=g.useCallback(i=>{var L;if((L=r.current)==null||L.call(r),r.current=null,!i)return;const a=i.getContext("2d");if(!a)return;e&&n(D=>D+1);const u=window.matchMedia("(prefers-reduced-motion: reduce)").matches;let c=[],f=0,h=0,p=Jh,v=Jh,y=null,x=null,_=0,b=-1;const E=new Array(33),k=D=>{const V=Math.round(D*32);let K=E[V];if(!K){const Y=V/32,G=Math.round(Ai[0]+(255-Ai[0])*Y),B=Math.round(Ai[1]+(255-Ai[1])*Y),Q=Math.round(Ai[2]+(255-Ai[2])*Y);K=`rgba(${G}, ${B}, ${Q}, ${rk})`,E[V]=K}return K},P=D=>{const V=1-.35*D,K=Math.round(Ai[0]*V),Y=Math.round(Ai[1]*V),G=Math.round(Ai[2]*V);return`rgba(${K}, ${Y}, ${G}, ${rk})`},T=D=>{let V=Math.floor(Math.random()*h1.length);V===b&&(V=(V+1)%h1.length),b=V;const K=[0,0,0,0],Y=h1[V].map((j,Z)=>{const ee=j.level,ie=K[ee]++,le=WG[ee]+ie*GG[ee],ue=KG[ee]+ep(V*131+Z*17+5)*.2;if(j.hline){const se=Ia((j.y??0)*h,v);return{hline:!0,x1:Ia(j.x1*f,p),x2:Ia(j.x2*f,p),y1:se,y2:se,level:ee,start:le,dur:ue}}const Ce=Ia(j.x1*f,p),ae=Ia((j.y1??0)*h,v);return{hline:!1,x1:Ce,y1:ae,x2:Math.max(Ia(j.x2*f,p),Ce+p),y2:Math.max(Ia((j.y2??0)*h,v),ae+v),level:ee,start:le,dur:ue}}),G=Y.reduce((j,Z)=>Math.max(j,Z.start+Z.dur),0),B=c.length,Q=new Float32Array(B*Aa),$=new Int16Array(B*Aa).fill(-1),te=new Uint8Array(B),H=Y[0];for(let j=0;j<B;j++){const Z=c[j];Z.x>H.x1&&Z.x<H.x2&&Z.y>H.y1&&Z.y<H.y2&&(te[j]=1);const ee=j*Aa;for(let ie=0;ie<Y.length;ie++){const le=ZG(Z.x,Z.y,Y[ie]);if(le<=.02)continue;let ue=ee;for(let Ce=ee;Ce<ee+Aa;Ce++){if($[Ce]===-1){ue=Ce;break}Q[Ce]<Q[ue]&&(ue=Ce)}($[ue]===-1||le>Q[ue])&&(Q[ue]=le,$[ue]=ie)}}return{startT:D,buildEnd:G,els:Y,frame:H,cellQ:Q,cellEl:$,inFrame:te}},A=()=>{const D=i.getBoundingClientRect();f=Math.max(1,D.width),h=Math.max(1,D.height);const V=Math.min(2,window.devicePixelRatio||1);i.width=Math.round(f*V),i.height=Math.round(h*V),a.setTransform(V,0,0,V,0,0);const K=Math.max(8,Math.round(f/Jh)),Y=Math.max(6,Math.round(h/Jh));p=f/K,v=h/Y,c=[];for(let G=0;G<Y;G++){const B=Y>1?G/(Y-1):.5,Q=VG*(1+$G*.4*(B*2-1));for(let $=0;$<K;$++){const te=G*8191+$*131+1,H={x:($+.5)*p,y:(G+.5)*v,size:Q,seed:te,phase:ep(te),kind:0};H.kind=Math.floor(ep(te*97)*3),c.push(H)}}x=null,y=null},O=new Float32Array(32),N=D=>{a.fillStyle=DG,a.fillRect(0,0,f,h),y||(y=T(D+.2)),D>=y.startT+y.buildEnd+HG&&(x=y,_=D,y=T(D+.2));let V=0;x&&(V=1-Ep((D-_)/zG),V<=0&&(x=null));const K=y;for(let H=0;H<K.els.length;H++){const j=K.els[H];O[H]=Ep(Math.min(1,Math.max(0,(D-K.startT-j.start)/j.dur)))}const Y=O[0],G=P(0),B=P(Y),Q=V>0?P(V):G,$=V>0?P(Math.max(Y,V)):B,te=c.length;for(let H=0;H<te;H++){const j=c[H];let Z=0,ee=0;const ie=H*Aa;for(let we=ie;we<ie+Aa;we++){const Ie=K.cellEl[we];if(Ie<0)break;const qe=K.cellQ[we]*O[Ie];qe>Z&&(Z=qe,ee=K.els[Ie].level)}if(x)for(let we=ie;we<ie+Aa;we++){const Ie=x.cellEl[we];if(Ie<0)break;const qe=x.cellQ[we]*V;qe>Z&&(Z=qe,ee=x.els[Ie].level)}const le=D/jG+j.phase,ue=Math.floor(le),Ce=le-ue,ae=Ep(Math.min(Ce,1-Ce)/FG),se=Math.floor(ep(j.seed*97+ue*7919)*3);se!==j.kind&&Z<.02&&ae<.05&&(j.kind=se);const pe=Math.max(ae*(1-Z),Z);if(!(pe<.01))if(Z<.02){const we=K.inFrame[H]===1,Ie=x?x.inFrame[H]===1:!1;we?a.fillStyle=Ie?$:B:a.fillStyle=Ie?Q:G;const qe=Math.max(we?Y:0,Ie?V:0);ik(a,j.kind,j.x,j.y,j.size*pe*(1-.2*qe))}else{a.fillStyle=k(Z);const we=1+(BG[ee]-1)*Z;ik(a,j.kind,j.x,j.y,j.size*pe*we)}}};A();let R=0;if(u)y=T(-100),N(0);else{const D=performance.now(),V=K=>{N((K-D)/1e3),R=requestAnimationFrame(V)};R=requestAnimationFrame(V)}const M=new ResizeObserver(()=>{A(),u&&(y=T(-100),N(0))});M.observe(i),r.current=()=>{cancelAnimationFrame(R),M.disconnect(),e&&n(D=>D-1)}},[e,n]);return S.jsx("canvas",{ref:s,"aria-hidden":"true",className:`h-full w-full ${t}`.trim()})},YG=async(t=null)=>{if(t)return QG(t);let e;try{e=await fetch("/api/mcp/status")}catch{return{isOk:!1,unavailableReason:"rivet_unreachable"}}if(e.status===404||!(e.headers.get("content-type")??"").toLowerCase().includes("application/json"))return tp();if(!e.ok)return{isOk:!1,unavailableReason:"rivet_unreachable"};let r;try{r=await e.json()}catch{return tp()}const s=r.devServerHealth;return s?s.ownership==="none"?{isOk:!1,unavailableReason:"upstream_unreachable"}:s.isReachable===!0?{isOk:!0,unavailableReason:"upstream_unreachable"}:{isOk:!1,unavailableReason:s.reason==="rivet_unreachable"?"rivet_unreachable":"upstream_unreachable"}:tp()},QG=async t=>{try{const e=await fetch(t);return{isOk:e.status!==502&&e.status!==503,unavailableReason:"upstream_unreachable"}}catch{return{isOk:!1,unavailableReason:"rivet_unreachable"}}},tp=async()=>{try{const t=await fetch("/");return{isOk:t.status!==502&&t.status!==503,unavailableReason:"upstream_unreachable"}}catch{return{isOk:!1,unavailableReason:"rivet_unreachable"}}},ok=ds("usePreviewUpstreamHealth"),XG=500,JG=4e3,eK=15e3,tK=(t,e={})=>{const n=g.useRef(null),r=g.useRef(null),s=e.probeMsWhileDown??XG,i=e.probeMsWhileUp??JG,a=e.firstUnreachableCaptureAfterMs??eK,u=e.rerunProbeImmediatelyOnVersion,c=e.probePath??null,f=e.skip??!1,[h,p]=g.useState(t==="static"),[v,y]=g.useState(0),[x,_]=g.useState(null),[b,E]=g.useState(0),[k,P]=g.useState(!1),[T,A]=g.useState(!1),[O,N]=g.useState(t==="static"?null:"upstream_unreachable");return g.useEffect(()=>{if(t==="static"){p(!0),_(null),E(0),P(!1),A(!0),N(null);return}if(f){p(!1),_(null),E(0),P(!1),A(!0),N("upstream_unreachable"),n.current=null;return}let R=!0;const M=Date.now();_(M),E(0),P(!1),p(!1),A(!1),N("upstream_unreachable");const L={current:!1},D={current:!1},V={current:!1},K={current:null},Y={current:!1};let G=null;const B=()=>{V.current||(V.current=!0,R&&A(!0))},Q=()=>{G!==null&&(clearTimeout(G),G=null)},$=(H,j)=>{Q(),G=setTimeout(j,H)},te=async()=>{if(!R)return;E(ie=>ie+1);const{isOk:H,unavailableReason:j}=await YG(c);if(!R)return;if(B(),H){const ie=!Y.current;Y.current=!0,p(!0),N(null),K.current=null,D.current=!1,P(!1),L.current?ie&&(Pe==null||Pe.capture("preview_upstream_restored",{framework:t})):(L.current=!0,Pe==null||Pe.capture("preview_dev_server_ready",{framework:t,ready_after_ms:Date.now()-M})),$(i,te);return}const Z=Y.current;Y.current=!1,p(!1),N(j),K.current===null&&(K.current=Date.now(),D.current=!1,P(!1)),Z&&(Pe==null||Pe.capture("preview_upstream_lost",{framework:t}),y(ie=>ie+1),ok.warn("Preview upstream became unavailable after it was ready"));const ee=Date.now()-K.current;ee>=a&&!D.current&&(D.current=!0,P(!0),Pe==null||Pe.capture("preview_dev_server_unreachable",{framework:t,elapsed_ms:ee}),ok.warn("Dev server did not become ready within timeout window")),$(s,te)};return n.current=()=>$(0,te),$(0,te),()=>{R=!1,n.current=null,Q()}},[t,s,i,a,c,f]),g.useEffect(()=>{var M;if(t==="static"||u===void 0)return;const R=r.current;r.current=u,R!==null&&R!==u&&((M=n.current)==null||M.call(n))},[t,u]),{isUpstreamReady:h,iframeRemountKey:v,probeStartedAt:x,probeAttemptCount:b,isFirstUnreachableWindowExceeded:k,initialProbeComplete:T,unavailableReason:O}};function nK(t){return t.enteringSplit&&t.isExistingSession&&t.hasActiveVariantProxy}const cR=t=>{var e;return t!=="embedded"||typeof window>"u"?"":((e=window.__RIVET_BOOTSTRAP__)==null?void 0:e.previewOrigin)??`${window.location.protocol}//localhost:${window.location.port}`},dR=({agentApplyMode:t,url:e})=>e.startsWith("/")?`${cR(t)}${e}`:e,rK="allow-scripts allow-same-origin allow-forms allow-popups allow-modals",sK=t=>rK,iK=ds("PreviewSurface"),ak=(t,e)=>t==="about:blank"?"blank":t.includes("/api/variants/")?"static_artifact":e.kind==="variant"?"dev_server":"original",fR=({target:t,src:e,framework:n,remountKey:r})=>(Je(s0),S.jsx("div",{className:"relative h-full w-full",children:S.jsx("iframe",{src:e,className:"h-full w-full border-none",title:"Project Preview",sandbox:sK(),onLoad:()=>{Pe==null||Pe.capture("preview_iframe_loaded",{framework:n,src:e}),t.kind==="variant"&&(Pe==null||Pe.capture("variants_panel.preview_displayed",{sessionId:t.sessionId,variantId:t.variantId,renderedTarget:"variant",iframeSrcKind:ak(e,t),framework:n}))},onError:()=>{Pe==null||Pe.capture("preview_iframe_load_failed",{framework:n,src:e}),t.kind==="variant"&&(Pe==null||Pe.capture("variants_panel.preview_display_failed",{sessionId:t.sessionId,variantId:t.variantId,renderedTarget:"variant",iframeSrcKind:ak(e,t),framework:n})),iK.warn("Preview iframe failed to load",{framework:n,src:e})}},r)})),oK="modulepreload",aK=function(t){return"/"+t},lk={},lK=function(e,n,r){let s=Promise.resolve();if(n&&n.length>0){let a=function(f){return Promise.all(f.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),c=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));s=a(n.map(f=>{if(f=aK(f),f in lk)return;lk[f]=!0;const h=f.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${p}`))return;const v=document.createElement("link");if(v.rel=h?"stylesheet":oK,h||(v.as="script"),v.crossOrigin="",v.href=f,c&&v.setAttribute("nonce",c),document.head.appendChild(v),h)return new Promise((y,x)=>{v.addEventListener("load",y),v.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(a){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=a,window.dispatchEvent(u),!u.defaultPrevented)throw a}return s.then(a=>{for(const u of a||[])u.status==="rejected"&&i(u.reason);return e().catch(i)})},uK=g.lazy(()=>lK(()=>Promise.resolve().then(()=>Hq),void 0)),cK={surface:"relative flex h-full w-full items-center justify-center bg-main px-6",overlay:"absolute inset-0 z-10 flex items-center justify-center bg-main/90 px-6",page:"relative flex h-screen w-full items-center justify-center bg-main px-6"},dK={sm:"text-lg font-semibold text-content",md:"text-2xl font-semibold text-content",lg:"text-3xl font-semibold text-content"},fK={neutral:"rounded-md border border-divider bg-transparent px-5 py-2 text-sm font-medium text-content transition-colors hover:bg-surface-3",ghost:"rounded-md px-5 py-2 text-sm font-medium text-content-muted transition-colors hover:text-content"},_d=({backdrop:t,media:e,title:n,description:r,actions:s,tone:i="neutral",fill:a="surface",size:u="md",children:c,state:f,role:h="status",busy:p=!1,className:v=""})=>{const y=g.useCallback(_=>{_&&f&&(Pe==null||Pe.capture("status_surface_shown",{state:f,tone:i,fill:a}))},[f,i,a]),x=!!(e||n||r||c||s!=null&&s.length);return S.jsxs("div",{ref:y,className:`${cK[a]} ${v}`.trim(),role:h,"aria-live":"polite","aria-busy":p||void 0,"data-state":f,children:[t?S.jsx("div",{className:"absolute inset-0",children:t}):null,x?S.jsxs("div",{className:"relative z-10 flex max-w-sm flex-col items-center gap-5 text-center",children:[e,n?S.jsx("h2",{className:dK[u],children:n}):null,r?S.jsx("p",{className:"text-content-muted text-base leading-relaxed",children:r}):null,c,s!=null&&s.length?S.jsx("div",{className:"flex flex-row items-center gap-3",children:s.map(_=>S.jsx("button",{type:"button",onClick:_.onClick,className:fK[_.variant??"neutral"],children:_.label},_.label))}):null]}):null]})},w_=({loader:t="coalesce",trackGlobalLoaderCount:e,size:n="lg",...r})=>t==="coalesce"?S.jsx(_d,{...r,size:n,busy:!0,backdrop:S.jsx(uR,{trackGlobalLoaderCount:e})}):t==="logo"?S.jsx(_d,{...r,size:n,busy:!0,backdrop:S.jsx(g.Suspense,{fallback:null,children:S.jsx(uK,{className:"absolute inset-0"})})}):S.jsx(_d,{...r,size:n,busy:!0,media:S.jsx(r0,{"aria-hidden":!0,className:"text-content h-8 w-8 shrink-0 animate-spin",weight:"bold"})}),hR=({icon:t,...e})=>S.jsx(_d,{...e,tone:"neutral",media:t?S.jsx("div",{className:"text-content-muted",children:t}):void 0}),Cm=t=>S.jsx(_d,{...t,tone:"error",role:"alert"}),uk="/static/",hK=t=>{try{return new URL(t,"http://localhost").pathname.endsWith(uk)}catch{return t.endsWith(uk)}},pK=({isInteractionDisabled:t=!1,framework:e,userPort:n,activeDemoSessionId:r=null,holdPreviewNavigation:s=!1})=>{const i=Je(u_),a=st(u_),u=Je(xm),c=st(xm),f=Je(hf),h=Je(s0),p=Je(c_),v=Je(d_),y=Je(QT),x=Je(XT),_=st(d_),b=Je(Zo),E=Je(h_),k=st(c_),P=f.active&&f.projectContext.kind==="fresh",T=Je(f_),A=f.active?f.variants.find(je=>je.workItemId===T&&(je.status==="pending"||je.status==="running"||je.status==="succeeded"&&!je.preview&&typeof je.port!="number"&&(!je.previewUnavailable||je.previewUnavailable.reason==="idle_timeout")))??null:null,O=f.active&&f.variants.some(je=>je.status==="pending"||je.status==="running"),N=P||O,R=f.active?f.variants.find(je=>{var Ye;return je.workItemId===T&&je.status==="succeeded"&&!!je.previewUnavailable&&((Ye=je.previewUnavailable)==null?void 0:Ye.reason)!=="idle_timeout"})??null:null,M=e==="static"&&u!==null&&hK(u);g.useEffect(()=>{f.active||k(!1)},[f.active,k]);const L=g.useRef(!1);g.useEffect(()=>{const je=!!(b!=null&&b.left||b!=null&&b.right),Ye=je&&!L.current;L.current=je;const lt=f.active?f.sessionId:null;!lt||!nK({enteringSplit:Ye,isExistingSession:f.active&&f.projectContext.kind==="existing",hasActiveVariantProxy:p&&v!==null})||(k(!1),_(null),a(Xe=>Xe+1),fetch(`/api/variants/${encodeURIComponent(lt)}/preview-port`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({variantId:null})}).catch(()=>{}))},[b,f,p,v,k,_,a]);const V=g.useMemo(()=>{var xn;if(p||u&&!M||!f.active)return null;const{stage:je,variants:Ye}=f,lt=je==="ready"||je==="degraded",Xe=Ye.some(Ut=>{var Rn,Hn;return((Rn=Ut.refinement)==null?void 0:Rn.status)==="pending"||((Hn=Ut.refinement)==null?void 0:Hn.status)==="running"});if(!lt&&!Xe)return null;const vt=Ye.find(Ut=>{var Rn;return Ut.status==="succeeded"&&((Rn=Ut.preview)==null?void 0:Rn.kind)==="static_artifact"});return((xn=vt==null?void 0:vt.preview)==null?void 0:xn.kind)==="static_artifact"?vt.preview.url:null},[M,u,p,f])??u,K=g.useMemo(()=>!f.active||!V?null:f.variants.find(je=>{var Ye;return((Ye=je.preview)==null?void 0:Ye.kind)==="static_artifact"&&V.startsWith(je.preview.url)})??null,[V,f]),Y=g.useMemo(()=>{if((E==null?void 0:E.previewKind)==="static")return{kind:"variant",sessionId:E.sessionId,variantId:E.variantId};if(!f.active)return _m;if(K)return{kind:"variant",sessionId:f.sessionId,variantId:K.workItemId};if(V){const Ye=V.match(/\/__rivet\/preview\/variant\/([^/]+)\/([^/?#]+)/),lt=Ye!=null&&Ye[1]?decodeURIComponent(Ye[1]):null,Xe=Ye!=null&&Ye[2]?decodeURIComponent(Ye[2]):null;if(lt===f.sessionId&&Xe&&f.variants.some(Ut=>Ut.workItemId===Xe))return{kind:"variant",sessionId:f.sessionId,variantId:Xe};const vt=V.match(/\/api\/variants\/[^/]+\/static\/([^/?#]+)/),xn=vt!=null&&vt[1]?decodeURIComponent(vt[1]):null;if(xn&&f.variants.some(Ut=>Ut.workItemId===xn))return{kind:"variant",sessionId:f.sessionId,variantId:xn}}const je=!!(b!=null&&b.left||b!=null&&b.right);return(!je||P)&&!V&&p&&v&&f.variants.some(Ye=>Ye.workItemId===v)?{kind:"variant",sessionId:f.sessionId,variantId:v}:(!je||P)&&!V&&T&&f.variants.some(Ye=>Ye.workItemId===T)?{kind:"variant",sessionId:f.sessionId,variantId:T}:_m},[E,K,f,p,v,V,b,P,T]),G=g.useRef(null);g.useEffect(()=>{var Xe,vt;if(!K||((Xe=K.preview)==null?void 0:Xe.kind)!=="static_artifact"||((vt=K.refinement)==null?void 0:vt.status)!=="succeeded")return;const je=`${K.workItemId}:${K.refinement.workItemId}`;if(G.current===je)return;G.current=je;const Ye=K.preview.url.includes("?")?"&":"?",lt=`${K.preview.url}${Ye}refinement=${encodeURIComponent(K.refinement.workItemId)}`;V!==lt&&(c(lt),a(xn=>xn+1))},[V,K,a,c,f]);const B=V!==null&&VW(V),Q=V!==null&&!B||P&&!p&&!B,{isUpstreamReady:$,iframeRemountKey:te,probeAttemptCount:H,initialProbeComplete:j}=tK(e,{rerunProbeImmediatelyOnVersion:i,probePath:B?V:null,skip:Q}),[Z,ee]=g.useState(()=>y&&$?i:null),ie=g.useRef(null);g.useEffect(()=>{if(!y){ie.current=null,ee(null);return}if(Z===i){ie.current=null;return}const je=ie.current;if(!je||je.remountKey!==i){ie.current={remountKey:i,probeAttemptCount:H};return}$&&H>je.probeAttemptCount&&(ie.current=null,ee(i))},[Z,i,y,H,$]);const ue=V!==null&&!B||$,ae=x||y&&Z!==i||y&&!ue,se=`${te}:${i}`,pe=r?`/try/${encodeURIComponent(r)}`:"",we=sR(window.location.pathname),Ie=e==="static"?`${pe}/static${we??"/"}`:`${pe}${we??"/"}`,qe=cR(h);let it=null;V&&(it=dR({agentApplyMode:h,url:V}));const at=A||ae?"about:blank":(B&&!ue?"about:blank":it)??(s||!ue?"about:blank":`${qe}${Ie}`),At=!!A||!!R||!ue&&j;let mt=null;return ae?mt=S.jsx(w_,{fill:"overlay",loader:"coalesce",trackGlobalLoaderCount:!1,state:"preview_replay_boot"}):A?mt=S.jsx(w_,{fill:"overlay",loader:"coalesce",trackGlobalLoaderCount:!1,state:"variant_building",children:S.jsx("span",{className:"sr-only",children:"Building your direction"})}):R?mt=S.jsx(Cm,{fill:"overlay",state:"preview_unavailable",title:"Preview couldn’t start",description:"Its preview server didn’t start.",actions:[{label:"Reload",onClick:()=>window.location.reload()}]}):At&&(mt=N?S.jsx(hR,{fill:"overlay",state:"preview_no_selection",title:"Nothing to preview yet",description:"Pick a direction from the panel."}):S.jsx(Cm,{fill:"overlay",state:"preview_offline",title:"Preview isn't connected",description:"Rivet lost connection to your project.",actions:[{label:"Reload",onClick:()=>window.location.reload()}]})),S.jsxs("div",{className:"relative h-full w-full",children:[mt,S.jsx(fR,{target:Y,src:at,framework:e,remountKey:se})]})};function ck({side:t,sessionId:e,variantId:n,url:r,label:s,source:i,isFallback:a=!1}){var E;const u=st(Zo),c=Je(hf),f=Je(s0),h=g.useRef(!1),p=g.useCallback(()=>{h.current||(h.current=!0,Kd({source:i,sessionId:e,variantId:n}))},[i,e,n]),v=g.useCallback(()=>{if(a){u(null);return}p(),u(k=>{if(!k)return null;const P={...k};return delete P[t],P.left||P.right?P:null})},[u,t,a,p]),y=g.useMemo(()=>({kind:"variant",sessionId:e,variantId:n}),[e,n]),x=g.useMemo(()=>!c.active||c.sessionId!==e?null:c.variants.find(k=>k.workItemId===n)??null,[e,n,c]),_=g.useMemo(()=>{var P,T;let k=r;if(((P=x==null?void 0:x.preview)==null?void 0:P.kind)==="static_artifact"&&((T=x.refinement)==null?void 0:T.status)==="succeeded"){const A=x.preview.url.includes("?")?"&":"?";k=`${x.preview.url}${A}refinement=${encodeURIComponent(x.refinement.workItemId)}`}return dR({agentApplyMode:f,url:k})},[f,x,r]),b=((E=x==null?void 0:x.refinement)==null?void 0:E.status)==="succeeded"?`${n}:${x.refinement.workItemId}`:n;return S.jsxs("div",{className:"variant-split-secondary","data-cy":"variant-split-pane","data-variant-id":n,children:[S.jsxs("div",{className:"variant-split-secondary-toolbar",children:[S.jsx("span",{className:"variant-split-secondary-label",title:s,children:s}),S.jsx(Fo,{label:"Collapse",children:S.jsx("button",{type:"button",className:"variant-split-secondary-close",onClick:v,"aria-label":"Collapse split view",children:S.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",focusable:"false",children:S.jsx("path",{d:"M2.5 2.5 L9.5 9.5 M9.5 2.5 L2.5 9.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})})})]}),S.jsx("div",{className:"variant-split-secondary-body relative min-h-0 flex-1",children:S.jsx(fR,{target:y,src:_,framework:"static",remountKey:b})})]})}const dk=240;function mK(){const t=Je(Ud),e=Je(ex),n=g.useRef(null);return g.useEffect(()=>{if(!t||!e||!n.current)return;const r=e.x-dk/2,s=e.y-22;n.current.style.transform=`translate3d(${r}px, ${s}px, 0)`},[t,e]),!t||!e?null:S.jsx("div",{ref:n,"aria-hidden":"true",className:"variant-drag-ghost",style:{width:dk},children:S.jsxs("div",{className:"variant-drag-ghost-body",children:[S.jsxs("div",{className:"variant-drag-ghost-row",children:[S.jsx("div",{className:"variant-drag-ghost-title",children:t.label}),t.runLabel?S.jsx("div",{className:"variant-drag-ghost-tag",style:$T(t.runLabel),children:t.runLabel}):null]}),t.description?S.jsx("div",{className:"variant-drag-ghost-desc",children:t.description}):null]})})}function gK(){const t=Je(Ud),e=Je(ex),n=Je(Zo),r=st(Ud),s=st(Zo),i=g.useRef(null),[a,u]=g.useState(null),[c,f]=g.useState("hidden");g.useEffect(()=>{if(!t){f("hidden"),u(null);return}const v=requestAnimationFrame(()=>f("visible"));return()=>cancelAnimationFrame(v)},[t]);const h=g.useCallback((v,y)=>{const x=i.current;if(!x)return null;const _=x.getBoundingClientRect();return v<_.left||v>_.right||y<_.top||y>_.bottom?null:v<(_.left+_.right)/2?"left":"right"},[]);if(g.useEffect(()=>{if(!t||!e)return;const v=h(e.x,e.y);u(y=>y===v?y:v)},[t,e,h]),g.useEffect(()=>{if(!t)return;const v=y=>{const x=h(y.clientX,y.clientY);if(x&&t.url){const _={sessionId:t.sessionId,variantId:t.variantId,label:t.label,url:t.url,source:t.source},b=n==null?void 0:n[x];b&&(b.sessionId!==_.sessionId||b.variantId!==_.variantId)&&Kd(b),s(E=>({...E??{},[x]:_})),f("exiting"),window.setTimeout(()=>r(null),220)}else Kd(t),f("exiting"),window.setTimeout(()=>r(null),220)};return window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),()=>{window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v)}},[t,h,r,s,n]),!t)return null;const p=["variant-drop-zones",c==="visible"&&"is-visible",c==="exiting"&&"is-exiting"].filter(Boolean).join(" ");return S.jsxs("div",{ref:i,className:p,"aria-hidden":"true",children:[S.jsx(fk,{side:"left",hovered:a==="left",canDrop:!!t.url,label:t.label}),S.jsx(fk,{side:"right",hovered:a==="right",canDrop:!!t.url,label:t.label})]})}function fk({side:t,hovered:e,canDrop:n,label:r}){return S.jsxs("div",{className:["variant-drop-zone",`is-${t}`,e&&"is-hover",!n&&"is-disabled"].filter(Boolean).join(" "),children:[S.jsxs("div",{className:"variant-drop-zone-inner",children:[S.jsx("div",{className:`variant-drop-zone-icon is-${t}`}),S.jsx("div",{className:"variant-drop-zone-caption",children:n?`Add ${t} split`:"Split unavailable for this direction"})]}),S.jsx("div",{className:"variant-drop-zone-preview","aria-hidden":"true",children:S.jsx("div",{className:"variant-drop-zone-preview-label",children:r})}),S.jsx("div",{className:"variant-drop-zone-border"})]})}const pR=(t,e,n)=>{var i,a;if(!t.active||t.sessionId!==e)return null;const r=t.variants.find(u=>u.workItemId===n);if(((i=r==null?void 0:r.preview)==null?void 0:i.kind)!=="static_artifact")return null;if(((a=r.refinement)==null?void 0:a.status)!=="succeeded")return r.preview.url;const s=r.preview.url.includes("?")?"&":"?";return`${r.preview.url}${s}refinement=${encodeURIComponent(r.refinement.workItemId)}`},hk=(t,e)=>{if(!t)return;const n=pR(e,t.sessionId,t.variantId);return!n||n===t.url?t:{...t,url:n}},vK=()=>S.jsx("div",{"data-testid":"preview-boot-skeleton",role:"status","aria-busy":"true","aria-label":"Loading preview",className:"bg-main flex h-full min-h-0 w-full flex-1 flex-col p-3",children:S.jsx("div",{className:"border-main-border relative min-h-0 flex-1 overflow-hidden rounded-lg border",children:S.jsx(uR,{trackGlobalLoaderCount:!1})})}),yK=({isLoading:t=!1,isInteractionDisabled:e=!1,activeDemoSessionId:n=null,holdHostedTryoutPreviewNavigation:r=!1})=>{const{config:s,fetchConfig:i,isLoading:a,error:u}=LG();return g.useEffect(()=>{i().catch(c=>{Pe==null||Pe.capture("preview_config_load_failed",{message:c instanceof Error?c.message:"unknown_error"})})},[i]),a?r?S.jsx("div",{className:"bg-main flex h-full min-h-0 w-full flex-1","aria-busy":"true"}):S.jsx(vK,{}):u||!s?S.jsx(Cm,{fill:"surface",size:"sm",state:"preview_config_error",title:"Couldn't load preview",description:"We couldn't load the preview configuration.",actions:[{label:"Retry",onClick:()=>{Pe==null||Pe.capture("preview_config_retry_clicked"),i().catch(c=>{Pe==null||Pe.capture("preview_config_load_failed",{message:c instanceof Error?c.message:"unknown_error"})})}}]}):S.jsx(_K,{isLoading:t,isInteractionDisabled:e,framework:s.framework,userPort:s.userPort,activeDemoSessionId:n,holdHostedTryoutPreviewNavigation:r})};function _K(t){const e=Je(Zo),n=Je(Ud),r=Je(hf),s=Je(xm),i=e==null?void 0:e.left,a=e==null?void 0:e.right,u=g.useMemo(()=>{var A,O;if(!r.active||r.projectContext.kind!=="fresh"||!(!!i!=!!a))return;const _=(A=i??a)==null?void 0:A.variantId,b=r.variants.filter(N=>{var R;return N.status==="succeeded"&&((R=N.preview)==null?void 0:R.kind)==="static_artifact"&&N.workItemId!==_}),E=s==null?void 0:s.replace(/[?&]refinement=[^&]*$/,""),P=b.find(N=>{var R;return((R=N.preview)==null?void 0:R.kind)==="static_artifact"&&N.preview.url===E})??b[0];if(((O=P==null?void 0:P.preview)==null?void 0:O.kind)!=="static_artifact")return;const T=pR(r,r.sessionId,P.workItemId);if(T)return{sessionId:r.sessionId,variantId:P.workItemId,label:P.label,url:T,source:"live"}},[r,i,a,s]),c=hk(i,r)??(a?u:void 0),f=hk(a,r)??(i?u:void 0),h=!i&&!!c,p=!a&&!!f,v=!!(c||f),y=S.jsx(pK,{isInteractionDisabled:t.isInteractionDisabled,framework:t.framework,userPort:t.userPort,activeDemoSessionId:t.activeDemoSessionId,holdPreviewNavigation:t.holdHostedTryoutPreviewNavigation});return S.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 flex-col",children:S.jsxs("div",{className:`variant-preview-region relative flex h-full min-h-0 w-full flex-1 flex-col ${n?"is-dragging":""} ${v?"is-split":""}`,children:[S.jsxs("div",{className:"variant-preview-row flex h-full min-h-0 w-full flex-1",children:[c&&S.jsx(ck,{side:"left",sessionId:c.sessionId,variantId:c.variantId,url:c.url,label:c.label,source:c.source,isFallback:h},`left-${c.sessionId}:${c.variantId}:${c.url}`),!(c&&f)&&S.jsx("div",{className:"variant-preview-primary flex h-full min-h-0 flex-1 flex-col",children:y}),f&&S.jsx(ck,{side:"right",sessionId:f.sessionId,variantId:f.variantId,url:f.url,label:f.label,source:f.source,isFallback:p},`right-${f.sessionId}:${f.variantId}:${f.url}`)]}),S.jsx("div",{className:"variant-preview-atmosphere","aria-hidden":"true"}),S.jsx(gK,{}),S.jsx(mK,{})]})})}const mR=({message:t,isLoading:e=!0})=>S.jsxs("div",{className:"flex items-center gap-2 text-sm text-content",children:[e?S.jsx(r0,{className:"h-4 w-4 shrink-0 animate-spin text-primary",weight:"bold"}):null,S.jsx("span",{className:"whitespace-pre-wrap font-sans",children:t})]});function ji(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function gR(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}/*!
114
+ ${s}`:s},eG=({rows:t,activeVariantId:e,activePastKey:n,isOriginalSelected:r,busy:s,editingKey:i,onSelectActive:a,onSelectPast:u,onSelectOriginal:c,onActivePointerDown:f,onPastPointerDown:h,onHover:p,onRemove:v,onRemovePast:y,onStartRename:x,onCommitRename:_,onCancelRename:b,onCopyVariantContext:E,activeSessionId:k,projectPath:P})=>{const T=g.useRef(null),{activeIndex:A,itemRects:O,sessionRef:N,handlers:R,registerItem:M}=HT(T),L=(s==null?void 0:s.kind)==="switch",D=A!==null?O[A]:null;return S.jsxs("div",{ref:T,className:"relative",onMouseEnter:R.onMouseEnter,onMouseMove:R.onMouseMove,onMouseLeave:R.onMouseLeave,children:[S.jsx(Gi,{children:D&&S.jsx(sl.div,{className:"bg-hover pointer-events-none absolute z-0 rounded-md",initial:{opacity:0,top:D.top,left:D.left,width:D.width,height:D.height},animate:{opacity:1,top:D.top,left:D.left,width:D.width,height:D.height},exit:{opacity:0,transition:{duration:.06}},transition:{...Vd.fast,opacity:{duration:.08}}},N.current)}),S.jsx("ul",{className:"relative",children:t.map((V,K)=>{const Y=ZW(V);let G=!1;return V.kind==="active"?G=V.variant.workItemId===e:V.kind==="past"?G=`${V.entry.sessionId}:${V.entry.variantId}`===n:G=r,S.jsx(tG,{rowKey:Y,row:V,index:K,isSelected:G,isEditing:i===Y,isSwitchInFlight:L,busy:s,registerItem:M,onSelectActive:a,onSelectPast:u,onSelectOriginal:c,onActivePointerDown:f,onPastPointerDown:h,onHover:p,onRemove:v,onRemovePast:y,onStartRename:x,onCommitRename:_,onCancelRename:b,onCopyVariantContext:E,activeSessionId:k,projectPath:P},Y)})})]})},tG=({rowKey:t,row:e,index:n,isSelected:r,isEditing:s,isSwitchInFlight:i,busy:a,registerItem:u,onSelectActive:c,onSelectPast:f,onSelectOriginal:h,onActivePointerDown:p,onPastPointerDown:v,onHover:y,onRemove:x,onRemovePast:_,onStartRename:b,onCommitRename:E,onCancelRename:k,onCopyVariantContext:P,activeSessionId:T,projectPath:A})=>{var Ce,ae;const O=g.useRef(null);hU(u,n,O);const N=e.kind==="active",R=e.kind==="original",M=e.kind==="active"?e.variant:null,L=e.kind==="past"?e.entry:null,D=N?M.status==="succeeded":!0,V=N?$a(M):!0,K=N?oR(M):!1,Y=N&&(M.status==="pending"||M.status==="running"),G=N?D&&(V||K)||Y:!0,B=N&&M.status==="failed",Q=N&&M.status==="cancelled",$=N&&(!G||i),te=N&&(a==null?void 0:a.kind)==="remove"&&a.variantId===M.workItemId,H=N&&(((Ce=M.refinement)==null?void 0:Ce.status)==="pending"||((ae=M.refinement)==null?void 0:ae.status)==="running");let j=gx;N?j=M.label||`Direction ${n+1}`:L&&(j=L.label.trim()||"Untitled direction");let Z;N?Z=M.runLabel:L&&(Z=L.runLabel);let ee=vx;N?ee=M.description:L&&(ee=L.brief);const ie=ee?QW(ee):null,le=XW(e,T),ue=le?"Copy variant reference":"Copy description";return s?S.jsx("li",{ref:O,"data-proximity-index":n,className:"group relative z-10",children:S.jsx("div",{className:"bg-main-input flex w-full items-start gap-2 rounded-md px-3 py-2",children:S.jsxs("span",{className:"min-w-0 flex-1",children:[S.jsx(nG,{initial:j,onCommit:se=>E(e,se),onCancel:k}),ie&&S.jsx("span",{className:"text-content-muted mt-1 line-clamp-2 block text-xs leading-snug",children:ie})]})})}):S.jsxs("li",{ref:O,"data-proximity-index":n,className:"group relative z-10",children:[S.jsx("div",{role:"button",tabIndex:G?0:-1,"data-variant-id":N?M.workItemId:void 0,"data-variant-key":t,onClick:()=>{if($)return;const se=window.getSelection();se&&!se.isCollapsed||(e.kind==="active"?c(e.variant):e.kind==="past"?f(e.entry):h())},onKeyDown:se=>{$||(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),se.stopPropagation(),e.kind==="active"?c(e.variant):e.kind==="past"?f(e.entry):h())},onPointerDown:se=>{$||(e.kind==="active"?D&&p(e.variant.workItemId,se):e.kind==="past"&&v(e.entry,se))},"aria-pressed":G?r:void 0,"aria-disabled":N?!G:void 0,"aria-busy":Y||H,onMouseEnter:N?()=>y(M.workItemId):void 0,onMouseLeave:N?()=>y(null):void 0,className:ar("focus-visible:ring-content-muted/40 flex w-full items-start gap-2 rounded-md px-3 py-2 text-left transition-colors focus:outline-none focus-visible:ring-1",r&&"bg-main-input ring-content-muted/40 ring-1 ring-inset",D&&V&&"cursor-grab active:cursor-grabbing",(Y||K)&&"cursor-pointer",!D&&!Y&&!K&&"cursor-not-allowed opacity-60",$&&"cursor-not-allowed opacity-50"),style:D?{touchAction:"none"}:void 0,children:S.jsxs("span",{className:"min-w-0 flex-1",children:[S.jsxs("span",{className:"flex items-center gap-2",children:[(Y||H)&&S.jsx(tx,{className:"text-content-muted shrink-0 text-sm","data-testid":H&&!Y?"variant-refining":void 0}),S.jsx(Fo,{label:"Double-click to rename",disabled:R,children:S.jsx("span",{onDoubleClick:se=>{se.stopPropagation(),R||b(t)},className:ar("min-w-0 flex-1 truncate text-sm font-medium select-text",R?"cursor-default":"cursor-text",D||r?"text-content":"text-content-muted"),children:j})}),B&&S.jsx(YC,{label:"Failed"}),Q&&S.jsx(YC,{label:"Cancelled"}),Z&&S.jsx("span",{className:"ml-auto max-w-[8rem] shrink-0 truncate rounded px-1.5 py-0.5 text-[10px] font-medium opacity-100 transition-opacity duration-150 group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",style:$T(Z),children:Z})]}),ie&&S.jsx("span",{className:"text-content-muted mt-0.5 line-clamp-2 block cursor-text text-xs leading-snug select-text",children:ie})]})}),S.jsxs("div",{className:ar("absolute top-1.5 right-2 flex items-center gap-0.5 transition-opacity duration-150","pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 has-[:focus-visible]:pointer-events-auto has-[:focus-visible]:opacity-100"),children:[ee||le?S.jsx(Fo,{label:ue,children:S.jsx("button",{type:"button","aria-label":ue,onClick:se=>{se.stopPropagation(),P(JW({label:j,description:ee,reference:le,projectPath:A}))},onPointerDown:se=>se.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1",children:S.jsx(Fd,{size:13,weight:"bold"})})}):null,!R&&S.jsx(Fo,{label:"Rename",children:S.jsx("button",{type:"button","aria-label":"Rename direction",onClick:se=>{se.stopPropagation(),b(t)},onPointerDown:se=>se.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1",children:S.jsx(vz,{size:13,weight:"bold"})})}),!R&&S.jsx(Fo,{label:"Remove",children:S.jsx("button",{type:"button","data-variant-remove-id":e.kind==="active"?e.variant.workItemId:void 0,"aria-label":"Remove direction",disabled:te,onClick:se=>{se.stopPropagation(),e.kind==="active"?x(e.variant):_(e.entry)},onPointerDown:se=>se.stopPropagation(),className:"text-content-muted hover:bg-main-hover hover:text-content focus-visible:ring-content-muted/40 ml-1 flex h-6 w-6 items-center justify-center rounded focus:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",children:S.jsx(xz,{size:13,weight:"bold"})})})]})]})},nG=({initial:t,onCommit:e,onCancel:n})=>{const[r,s]=g.useState(t),i=g.useRef(!1),a=g.useCallback(c=>{c&&(c.focus(),c.select())},[]),u=c=>{i.current||(i.current=!0,c?e(r):n())};return S.jsx("input",{ref:a,type:"text",value:r,maxLength:120,"aria-label":"Rename direction",onChange:c=>s(c.target.value),onKeyDown:c=>{c.stopPropagation(),c.key==="Enter"?(c.preventDefault(),u(!0)):c.key==="Escape"&&(c.preventDefault(),u(!1))},onBlur:()=>u(!0),onClick:c=>c.stopPropagation(),onPointerDown:c=>c.stopPropagation(),className:"border-content-muted/40 bg-main text-content focus:ring-content-muted/50 w-full rounded border px-1.5 py-0.5 text-sm font-medium focus:ring-1 focus:outline-none"})},YC=({label:t})=>S.jsx("span",{className:"bg-main-input text-content-muted shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium tracking-wide uppercase",children:t}),rG=({entry:t,deploying:e,deployedUrl:n,onDeploy:r,isDeployDisabled:s=!1})=>{const a=e?"Deploying…":n?"Copy link":"Share";return S.jsxs("div",{className:"border-main-border bg-main-light flex shrink-0 items-center justify-between gap-3 border-t px-3 pt-2 pb-4",children:[S.jsxs("div",{className:"min-w-0",children:[S.jsx("div",{className:"text-content truncate text-sm font-medium",children:t.label.trim()||"Untitled direction"}),n?S.jsx("div",{className:"text-content-muted text-[11px]",children:"Deployed — share link ready"}):null]}),S.jsxs("button",{type:"button",onClick:()=>r(t),disabled:e||s,title:n?`Copy share link (${n})`:"Deploy this direction and get a public link to share",className:"border-main-border text-content hover:bg-main-input flex shrink-0 items-center gap-1 rounded-md border px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[n&&!e?S.jsx(Fd,{size:12,weight:"bold"}):null,a]})]})},sG={agent_browser:"Browser extracted",cache:"Cached",static:"Bundled catalog",manual:"Manual"},iG={design_context:"DESIGN.md",source_context:"Source",qa_report:"QA",asset:"Asset"},oG=({artifacts:t})=>{const[e,n]=g.useState(null),r=g.useMemo(()=>e&&t.some(i=>i.id===e)?e:null,[t,e]);if(t.length===0)return null;const s=i=>{n(a=>a===i?null:i)};return S.jsxs("section",{"aria-label":"Directions session artifacts",className:"mt-4",children:[S.jsx("div",{className:"flex shrink-0 items-center px-3 py-2",children:S.jsx("span",{className:"text-content truncate text-sm font-medium",children:"Artifacts"})}),S.jsx("ul",{className:"mt-2 space-y-1 px-1",children:t.map(i=>S.jsx(aG,{artifact:i,isExpanded:i.id===r,onToggle:()=>s(i.id)},i.id))})]})},aG=({artifact:t,isExpanded:e,onToggle:n})=>{const r=iG[t.kind],s=t.source?sG[t.source]:null,i=[t.kind==="design_context"?null:s,t.summary].filter(Boolean).join(" · "),a=t.kind==="design_context"&&!!t.viewUrl,u=`${e?"Hide":"View"} ${r} artifact${t.label?`: ${t.label}`:""}`;return a?S.jsx("li",{className:"border-main-border rounded-md border",children:S.jsxs("div",{className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-xs",children:[S.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[S.jsxs("span",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"border-content-muted/30 bg-main-input text-content-muted shrink-0 rounded-full border px-2 py-0.5 text-[9px] font-semibold tracking-wide uppercase",children:r}),S.jsx("span",{className:"text-content truncate text-xs font-medium",children:t.label})]}),i?S.jsx("span",{className:"text-content-muted mt-0.5 truncate text-[11px]",children:i}):null]}),S.jsx("a",{href:t.viewUrl,target:"_blank",rel:"noreferrer","aria-label":`Open ${r} artifact${t.label?`: ${t.label}`:""}`,className:"text-content-muted hover:bg-main-input hover:text-content focus-visible:ring-content-muted/40 shrink-0 rounded p-1 transition-colors focus:outline-none focus-visible:ring-1",children:S.jsx(fz,{className:"h-3.5 w-3.5",weight:"bold"})})]})}):S.jsxs("li",{className:"border-main-border rounded-md border",children:[S.jsxs("button",{type:"button",onClick:n,"aria-expanded":e,"aria-label":u,className:"hover:bg-main-input flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-xs transition-colors",children:[S.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[S.jsxs("span",{className:"flex items-center gap-2",children:[S.jsx("span",{className:"text-content-muted text-[10px] font-semibold tracking-wide uppercase",children:r}),S.jsx("span",{className:"text-content truncate text-xs font-medium",children:t.label})]}),i?S.jsx("span",{className:"text-content-muted mt-0.5 truncate text-[11px]",children:i}):null]}),S.jsx("span",{className:"text-content-muted shrink-0 text-[11px]",children:e?"Hide":"View"})]}),e?S.jsx("div",{className:"border-main-border bg-main-light border-t px-3 py-2",children:S.jsx(lG,{artifact:t})}):null]})},lG=({artifact:t})=>S.jsxs("div",{className:"text-content-muted space-y-1 text-[11px]",children:[t.summary?S.jsx("p",{children:t.summary}):null,t.path?S.jsxs("p",{children:["Stored at ",t.path]}):null,!t.summary&&!t.path?S.jsx("p",{children:"No inline content available for this artifact."}):null]}),uG=({selectedVariant:t,busy:e,onSend:n,onDeploy:r,onDeployCanvas:s,canDeploy:i,canDeployCanvas:a,canSendToAgent:u,canvasVariantCount:c,canvasDeployedUrl:f,deployedUrl:h})=>{var N,R,M,L;const p=t?((R=(N=t.actions)==null?void 0:N.commit)==null?void 0:R.enabled)??t.status==="succeeded":!1,v=p&&e===null,y=(e==null?void 0:e.kind)==="commit"&&e.variantId===(t==null?void 0:t.workItemId),x=(e==null?void 0:e.kind)==="deploy"&&e.variantId===(t==null?void 0:t.workItemId),_=(e==null?void 0:e.kind)==="deploy-canvas",b=!i||!p||e!==null,E=a&&c>0,P=x?"Deploying…":h?"Copy link":"Share",A=_?"Sharing…":f?"Copy canvas link":"Share canvas",O=y?"Applying…":"Apply to project";return S.jsxs("div",{className:"border-main-border bg-main-light flex shrink-0 items-center justify-between gap-3 border-t px-3 pt-2 pb-4",children:[S.jsx("div",{className:"min-w-0",children:t?S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"text-content truncate text-sm font-medium",children:t.label.trim()||"Untitled direction"}),h?S.jsx("div",{className:"text-content-muted text-[11px]",children:"Deployed — share link ready"}):null]}):null}),S.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[S.jsx(U5,{primaryLabel:P,primaryIcon:h&&!x?Fd:void 0,primaryAction:()=>{t&&r(t)},isDisabled:b,isDropdownDisabled:e!==null,isLoading:x,loadingLabel:"Deploying…",dropdownAriaLabel:"More share actions",dropdownItems:E?[{label:A,icon:f&&!_?Fd:void 0,onClick:s,isDisabled:e!==null}]:[]}),u?S.jsx("button",{type:"button",onClick:()=>{t&&n(t)},disabled:!v,title:(L=(M=t==null?void 0:t.actions)==null?void 0:M.commit)==null?void 0:L.reason,className:"bg-secondary text-secondary-foreground hover:bg-accent rounded-md px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:O}):null]})]})},aR=()=>S.jsx("div",{"data-testid":"direction-skeleton-row","aria-hidden":"true",className:"flex w-full items-start rounded-md px-3 py-2",children:S.jsxs("span",{className:"min-w-0 flex-1",children:[S.jsxs("span",{className:"flex items-center gap-2",children:[S.jsx(tx,{className:"text-content-muted shrink-0 text-sm"}),S.jsx("span",{className:"bg-muted-foreground/15 h-3.5 w-28 animate-pulse rounded"})]}),S.jsx("span",{className:"mt-1.5 flex",children:S.jsx("span",{className:"bg-muted-foreground/10 h-2.5 w-full max-w-[14rem] animate-pulse rounded"})})]})}),cG=({groups:t})=>S.jsx("div",{className:"space-y-0.5",children:t.flatMap(e=>Array.from({length:Math.max(1,e.count)}).map((n,r)=>S.jsx(aR,{},`${e.requestId}-${r}`)))}),dG=()=>S.jsx("div",{"data-testid":"direction-boot-skeletons",className:"space-y-0.5",children:Array.from({length:3}).map((t,e)=>S.jsx(aR,{},e))}),fG=()=>S.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-center",children:[S.jsx("div",{className:"text-content text-sm",children:"No directions yet"}),S.jsx("div",{className:"text-content-muted text-xs",children:"They’ll appear here as they generate."})]}),QC="Try different ways to create a dropdown that feels fluid and dynamic",hG=({isMCPSession:t=!1,mcpEditor:e=null})=>{const[n,r]=g.useState(!1),s=VU(e),i=t?s:"your coding agent",a=()=>{navigator.clipboard.writeText(QC).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)})};return S.jsxs("div",{className:"flex flex-col items-start gap-3 px-2 py-2",children:[S.jsx("p",{className:"text-content text-sm font-medium",children:"Create your first direction"}),S.jsxs("p",{className:"text-content-muted text-xs",children:["Use ",i," to generate directions."]}),S.jsxs("div",{className:"w-full",children:[S.jsx("p",{className:"text-content-muted mb-2 text-xs",children:"Here's a sample prompt to use:"}),S.jsxs("div",{className:"border-main-border bg-main-input relative rounded-md border px-3 py-2.5 pr-8",children:[S.jsxs("p",{className:"text-content-muted text-xs leading-snug",children:["“",QC,"”"]}),S.jsx("button",{type:"button",onClick:a,className:"text-content-muted hover:bg-main-border hover:text-content absolute top-2 right-2 rounded p-0.5 transition-colors",title:"Copy to clipboard",children:n?S.jsx(fT,{className:"h-3.5 w-3.5 text-emerald-500",weight:"bold"}):S.jsx(Fd,{className:"h-3.5 w-3.5",weight:"bold"})})]})]})]})},pG=({onClose:t})=>{const e=Je(qT);return t?S.jsxs("div",{className:"z-10 flex flex-shrink-0 items-center justify-between gap-2 border-b border-main-border bg-main-light px-2.5 py-2.5",children:[e?S.jsx("span",{className:"text-content min-w-0 truncate text-sm font-medium",title:e,children:e}):S.jsx("span",{}),S.jsx(Fo,{label:"Close panel",side:"bottom",children:S.jsx("button",{onClick:t,className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:S.jsx(yz,{className:"h-4 w-4",weight:"bold"})})})]}):null},mG='[data-menu-item]:not([disabled]):not([aria-disabled="true"])',gG=({itemSelector:t=mG,loop:e=!1}={})=>{const n=g.useRef(null),r=g.useRef(null),s=g.useCallback(a=>{var u;n.current=a,a?r.current=jU():((u=r.current)==null||u.call(r),r.current=null)},[]),i=g.useCallback(a=>{var x;const{key:u}=a;if(u!=="ArrowDown"&&u!=="ArrowUp"&&u!=="Home"&&u!=="End")return;const c=n.current;if(!c)return;const f=Array.from(c.querySelectorAll(t));if(f.length===0)return;a.preventDefault(),a.stopPropagation();const h=f.indexOf(document.activeElement),p=f.length-1,v=_=>{if(h===-1)return _===1?0:p;const b=h+_;return e?(b+f.length)%f.length:Math.min(Math.max(b,0),p)};let y;u==="Home"?y=0:u==="End"?y=p:u==="ArrowDown"?y=v(1):y=v(-1),(x=f[y])==null||x.focus()},[t,e]);return{containerRef:s,onKeyDown:i}},XC="/assets/arena-Db0j1set.png",vG=ds("useIntegrations"),JC=["integrations"],yG="rivet:connect-result",_G=t=>typeof t=="object"&&t!==null&&t.type===yG,xG=tt(null),wG=()=>{const t=f8(),[e,n]=nP(xG),r=U1({queryKey:JC,queryFn:async()=>{const u=await fetch("/api/integrations");if(!u.ok)throw new Error(`Failed to load integrations (${u.status})`);return(await u.json()).integrations??[]},staleTime:1e4}),s=g.useCallback(()=>t.invalidateQueries({queryKey:JC}),[t]),i=g.useCallback(async u=>{const c=window.open("","_blank","width=560,height=720");if(!c)throw new Error("Popup blocked. Allow popups to connect.");n(u);try{const f=await fetch(`/api/integrations/${u}/connect`,{method:"POST"}),h=await f.json().catch(()=>({}));if(!f.ok||!h.authUrl)throw c.close(),new Error(h.error||`Could not connect ${u}`);c.location.href=h.authUrl,await new Promise(p=>{const v=()=>{window.removeEventListener("message",y),clearInterval(x),s(),p()},y=_=>{_G(_.data)&&_.data.provider===u&&(_.data.status==="error"&&vG.warn(`Connect failed for ${u}:`,_.data.message),v())};window.addEventListener("message",y);const x=setInterval(()=>{c.closed&&v()},500)})}finally{n(null)}},[s,n]),a=g.useCallback(async u=>{n(u);try{const c=await fetch(`/api/integrations/${u}`,{method:"DELETE"});if(!c.ok){const f=await c.json().catch(()=>({}));throw new Error(f.error||`Could not disconnect ${u}`)}await s()}finally{n(null)}},[s,n]);return{integrations:r.data??[],isLoading:r.isPending,error:r.error instanceof Error?r.error.message:null,pendingProvider:e,connect:i,disconnect:a,refetch:s}},fu=({onClick:t,title:e,shortcut:n,children:r,disabled:s=!1,className:i="",type:a="button","data-cy":u})=>{const c=S.jsx("button",{onClick:t,disabled:s,className:i,type:a,"data-cy":u,children:r});return e?S.jsx(mx,{content:S.jsxs("div",{className:"flex flex-row items-center gap-2",children:[S.jsx("span",{children:e}),n?S.jsx("span",{className:"rounded bg-white/15 px-1.5 py-0.5 text-[11px]",children:n}):null]}),children:c}):c},ek=ds("ConnectorsModal"),bG=()=>S.jsx("svg",{viewBox:"0 0 24 24",className:"h-6 w-6","aria-hidden":"true",children:S.jsx("path",{fill:"currentColor",d:"M12 0C5.373 0 0 5.372 0 12c0 5.084 3.163 9.426 7.627 11.174-.105-.949-.2-2.405.042-3.441.218-.937 1.407-5.965 1.407-5.965s-.359-.719-.359-1.781c0-1.669.967-2.915 2.171-2.915 1.024 0 1.518.769 1.518 1.69 0 1.029-.655 2.568-.994 3.995-.283 1.194.599 2.169 1.777 2.169 2.132 0 3.772-2.249 3.772-5.495 0-2.873-2.064-4.882-5.012-4.882-3.414 0-5.418 2.561-5.418 5.207 0 1.031.397 2.137.893 2.739.098.119.112.223.083.344-.091.379-.293 1.194-.333 1.361-.052.22-.174.266-.401.16-1.499-.698-2.436-2.889-2.436-4.649 0-3.785 2.75-7.262 7.929-7.262 4.163 0 7.398 2.967 7.398 6.931 0 4.136-2.607 7.464-6.227 7.464-1.216 0-2.36-.631-2.75-1.378l-.748 2.853c-.271 1.043-1.002 2.35-1.492 3.146A12.004 12.004 0 0 0 12 24c6.627 0 12-5.373 12-12C24 5.372 18.627 0 12 0z"})}),SG=()=>S.jsx("span",{"aria-hidden":"true",className:"h-6 w-6 bg-[#b1b1b1]",style:{WebkitMaskImage:`url(${XC})`,maskImage:`url(${XC})`,WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskPosition:"center",maskPosition:"center"}}),EG=[{provider:"pinterest",name:"Pinterest",description:"Pull boards and pins in as visual references.",tileClassName:"bg-[#e60023] text-white",icon:S.jsx(bG,{})},{provider:"arena",name:"Are.na",description:"Connect channels of collected blocks and links.",tileClassName:"bg-[#18181b] text-content",icon:S.jsx(SG,{})}],CG=({meta:t,integration:e,isPending:n,isHighlighted:r,onConnect:s,onDisconnect:i})=>{const a=(e==null?void 0:e.status)==="connected",u=e!=null&&e.externalUsername?`@${e.externalUsername}`:null;return S.jsxs("article",{className:`flex flex-col rounded-xl bg-main-light p-[18px] ${r?"ring-2 ring-secondary":""}`,children:[S.jsx("span",{className:`grid h-[52px] w-[52px] flex-none place-items-center rounded-xl ${t.tileClassName}`,"aria-hidden":"true",children:t.icon}),S.jsxs("div",{className:"mt-4 flex-1",children:[S.jsxs("h2",{className:"text-content flex items-center gap-1.5 text-[15px] font-semibold",children:[t.name,a?S.jsx(fT,{className:"h-3.5 w-3.5",weight:"bold","aria-hidden":"true"}):null]}),S.jsx("p",{className:"text-content-subtle mt-1 text-[13px] leading-relaxed",children:t.description}),a&&u?S.jsx("p",{className:"text-content-muted mt-2.5 text-xs font-medium",children:u}):null]}),a?S.jsx("button",{type:"button",onClick:i,disabled:n,className:"active-push mt-[18px] inline-flex min-h-[38px] w-full items-center justify-center rounded-lg bg-main-input px-3.5 text-[13px] font-semibold text-content-muted transition-colors hover:bg-red-500/10 hover:text-red-300 disabled:cursor-not-allowed disabled:opacity-50",children:n?"Disconnecting…":"Disconnect"}):S.jsx("button",{type:"button",onClick:s,disabled:n,className:"active-push mt-[18px] inline-flex min-h-[38px] w-full items-center justify-center rounded-lg bg-secondary px-3.5 text-[13px] font-semibold text-secondary-foreground transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",children:n?"Connecting…":"Connect"})]})},x_=({isOpen:t,onClose:e,context:n="menu",highlightProvider:r=null})=>{const{integrations:s,isLoading:i,error:a,pendingProvider:u,connect:c,disconnect:f}=wG(),[h,p]=g.useState(null),v=b=>s.find(E=>E.provider===b),y=g.useCallback(b=>{c(b).catch(E=>{const k=E instanceof Error?E.message:"Could not connect.";ek.warn(`Connect error for ${b}:`,k),ht.error(k)})},[c]),x=g.useCallback(b=>{f(b).catch(E=>{const k=E instanceof Error?E.message:"Could not disconnect.";ek.warn(`Disconnect error for ${b}:`,k),ht.error(k)})},[f]),_=n==="onboarding";return S.jsx(Qm,{open:t,onOpenChange:b=>!b&&e(),children:S.jsxs(Xm,{children:[S.jsx(Jm,{className:"fixed inset-0 z-max bg-black/40"}),S.jsx(e0,{ref:p,className:"fixed left-1/2 top-1/2 z-max w-[560px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-main-border bg-main font-main shadow-2xl outline-none",children:S.jsxs(nR,{value:h,children:[S.jsxs("div",{className:"flex items-center justify-between rounded-t-lg border-b border-main-border bg-main-light px-4 py-2",children:[S.jsx(t0,{className:"text-base font-medium text-content",children:"Connect design references"}),S.jsx(fu,{onClick:e,title:"Close",className:"rounded p-1 text-content-subtle transition-colors hover:bg-main-hover hover:text-content",children:S.jsx(ET,{className:"h-4 w-4",weight:"bold"})})]}),S.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[S.jsx(n0,{className:"text-sm text-content-subtle",children:"Connect your design references to use them with Rivet’s MCP."}),a?S.jsx("p",{className:"rounded-lg bg-red-500/10 px-4 py-3 text-[13px] font-medium text-red-300",children:a}):null,S.jsx("div",{className:"grid grid-cols-2 gap-4",children:EG.map(b=>S.jsx(CG,{meta:b,integration:v(b.provider),isPending:i||u===b.provider,isHighlighted:r===b.provider,onConnect:()=>y(b.provider),onDisconnect:()=>x(b.provider)},b.provider))}),_?S.jsxs("div",{className:"flex items-center justify-between gap-4",children:[S.jsx("p",{className:"text-xs text-content-subtle",children:"You can always do this later from the account menu."}),S.jsx("button",{type:"button",onClick:e,className:"active-push flex-none rounded-lg bg-secondary px-3.5 py-2 text-[13px] font-medium text-secondary-foreground transition-colors hover:bg-accent",children:"Skip for now"})]}):null]})]})})]})})},tk=({className:t=""})=>S.jsx("span",{"aria-hidden":"true",className:`rivet-skeleton block rounded ${t}`.trim()}),kG=ds("SupportTicketModal"),nk=5e3,f1="feedback",PG=t=>{var r;if(!t)return null;const e=(r=t.formErrors)==null?void 0:r[0];if(e)return e;const n=t.fieldErrors??{};for(const s of Object.values(n)){const i=s==null?void 0:s[0];if(i)return i}return null},TG=async t=>{let e;try{e=await t.json()}catch{e=void 0}if(t.status===400){if(typeof(e==null?void 0:e.details)=="string"&&e.details.trim())return e.details;if(typeof(e==null?void 0:e.details)=="object"&&e.details!==null){const n=PG(e.details);if(n)return n}return"Please check your feedback and try again."}return t.status>=500?typeof(e==null?void 0:e.details)=="string"&&e.details.trim()?e.details:"Could not send feedback right now. Please try again later.":typeof(e==null?void 0:e.error)=="string"&&e.error.trim()?e.error:`HTTP ${t.status}`},RG=({isOpen:t,onClose:e,contactEmail:n})=>{const r=nD(),[s,i]=g.useState(""),[a,u]=g.useState(!1),[c,f]=g.useState(null),h=g.useCallback(()=>{i("")},[]),p=g.useCallback(()=>{a||(h(),e())},[a,e,h]),v=g.useCallback(async()=>{const b=s.trim();if(!(!b||a)){u(!0);try{const E=typeof(r==null?void 0:r.get_session_id)=="function"?r.get_session_id():void 0,k=typeof(r==null?void 0:r.get_distinct_id)=="function"?r.get_distinct_id():void 0,P=n==null?void 0:n.trim(),T=await fetch("/api/support/tickets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:f1,message:b,contactEmail:P||void 0,metadata:{posthogSessionId:E??void 0,posthogDistinctId:k??void 0,appVersion:"0.14.2",appEnvironment:"production",pageUrl:window.location.href,userAgent:navigator.userAgent,submittedAt:new Date().toISOString()}})});if(!T.ok){const A=await TG(T);throw new Error(A)}r==null||r.capture("support_ticket_submitted",{ticket_type:f1,has_posthog_session_id:!!E}),ht.success("Feedback sent",{description:"Thanks for sharing this."}),h(),e()}catch(E){const k=E instanceof Error?E.message:"Failed to send message";r==null||r.capture("support_ticket_submit_failed",{ticket_type:f1,error:k}),kG.error("Failed to submit support ticket:",k),ht.error("Could not send feedback",{description:k})}finally{u(!1)}}},[n,a,s,e,r,h]),y=g.useCallback(b=>{b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),v())},[v]),x=nk-s.length,_=a||s.trim().length===0;return S.jsx(Qm,{open:t,onOpenChange:b=>!b&&p(),children:S.jsxs(Xm,{children:[S.jsx(Jm,{className:"fixed inset-0 z-max bg-black/40"}),S.jsx(e0,{ref:f,className:"fixed left-1/2 top-1/2 z-max w-[440px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-main-border bg-main font-main shadow-2xl outline-none",children:S.jsxs(nR,{value:c,children:[S.jsxs("div",{className:"flex items-center justify-between rounded-t-lg border-b border-main-border bg-main-light px-4 py-2",children:[S.jsx(t0,{className:"text-base font-medium text-content",children:"Send feedback"}),S.jsx(fu,{onClick:p,disabled:a,title:"Close",className:"rounded p-1 text-content-subtle transition-colors hover:bg-main-hover hover:text-content disabled:cursor-not-allowed disabled:opacity-50",children:S.jsx(ET,{className:"h-4 w-4",weight:"bold"})})]}),S.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[S.jsx(n0,{className:"text-sm text-content-subtle",children:"Tell us what happened or what we can improve."}),S.jsxs("div",{className:"rounded-lg bg-main-input outline outline-1 outline-transparent transition-[outline-color] focus-within:outline-white/20",children:[S.jsx("textarea",{id:"support-ticket-message","aria-label":"Your feedback",value:s,onChange:b=>i(b.target.value),onKeyDown:y,maxLength:nk,rows:6,disabled:a,placeholder:"What happened?",className:"max-h-64 w-full resize-none overflow-y-auto bg-transparent pb-1 pl-3 pr-3 pt-3 text-sm text-content placeholder-content-subtle focus:outline-none disabled:opacity-50"}),S.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1",children:[S.jsx("span",{className:"text-xs text-content-subtle",children:"Context details are included automatically."}),S.jsxs("div",{className:"flex items-center gap-2",children:[x<=500&&S.jsx("span",{className:"text-xs text-content-subtle",children:x}),S.jsx(fu,{onClick:v,disabled:_,title:"Send feedback",shortcut:"⌘↵",className:"flex items-center justify-center rounded bg-primary p-1 text-content transition-colors hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-80",children:a?S.jsx(r0,{className:"h-5 w-5 animate-spin",weight:"bold"}):S.jsx(hz,{className:"h-5 w-5",weight:"bold"})})]})]})]})]})]})})]})})},AG=ds("ProfileAvatar"),lR=(t,e)=>{const n=(t??"").trim();if(n)return n.split(/\s+/).filter(Boolean)[0]??"";const s=((e??"").split("@")[0]??"").split(/[._\-+]/).filter(Boolean)[0]??"";return s?s[0].toUpperCase()+s.slice(1):""},IG=(t,e)=>lR(t,e).charAt(0).toUpperCase(),MG=({className:t="",side:e="bottom",align:n="end"})=>{const{name:r,email:s}=Je(YT),i=Je(n5),a=Je(t5),[u,c]=g.useState(!1),[f,h]=g.useState(!1),[p,v]=g.useState(!1),[y,x]=g.useState(!1),{containerRef:_,onKeyDown:b}=gG(),E=Je(pf),k=IG(r,s);if(!k)return E?S.jsxs("span",{"data-testid":"profile-avatar-skeleton","aria-hidden":"true",className:`flex shrink-0 items-center gap-2 ${t}`.trim(),children:[S.jsx(tk,{className:"h-7 w-7 rounded-full"}),S.jsx(tk,{className:"h-3 w-16"})]}):null;const P=lR(r,s),T=(r==null?void 0:r.trim())||null,A=(s==null?void 0:s.trim())||null,O=async()=>{x(!0);try{const N=await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin"});if(!N.ok)throw new Error(`Logout failed: ${N.status}`)}catch(N){AG.warn("Logout request failed",N),ht.error("Could not log out. Please try again."),x(!1);return}window.location.reload()};return S.jsxs(S.Fragment,{children:[S.jsxs(V5,{open:u,onOpenChange:c,children:[S.jsx($5,{asChild:!0,children:S.jsxs("button",{type:"button","aria-label":"Account",className:`flex shrink-0 select-none items-center gap-2 text-content-muted transition-colors hover:text-content ${t}`,children:[S.jsx("span",{className:"flex h-7 w-7 items-center justify-center rounded-full border border-main-border bg-main-input text-[11px] font-semibold leading-none",children:k}),P?S.jsx("span",{className:"max-w-[8rem] truncate text-xs font-medium",children:P}):null]})}),S.jsx(H5,{children:S.jsxs(z5,{ref:_,onKeyDown:b,role:"menu",className:"z-[60] min-w-[180px] rounded-lg bg-surface-2 p-1 shadow-lg",side:e,sideOffset:6,align:n,children:[T||A?S.jsxs("div",{className:"border-b border-main-border px-3 py-2",children:[T?S.jsx("div",{className:"truncate text-xs font-medium text-content",children:T}):null,A?S.jsx("div",{className:"truncate text-[11px] text-content-muted",children:A}):null]}):null,S.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{c(!1),h(!0)},disabled:!i||a,className:"mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs text-content transition-colors hover:bg-hover focus:bg-hover focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[S.jsx(wT,{className:"h-3.5 w-3.5",weight:"bold"}),"Connect design references"]}),S.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{c(!1),v(!0)},className:"mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs text-content transition-colors hover:bg-hover focus:bg-hover focus:outline-none",children:[S.jsx(mz,{className:"h-3.5 w-3.5",weight:"bold"}),"Share feedback"]}),S.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:O,disabled:y,className:"mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs text-content transition-colors hover:bg-hover focus:bg-hover focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[S.jsx(_z,{className:"h-3.5 w-3.5",weight:"bold"}),y?"Logging out…":"Log out"]})]})})]}),S.jsx(x_,{isOpen:f,onClose:()=>h(!1)}),S.jsx(RG,{isOpen:p,onClose:()=>v(!1),contactEmail:s??void 0})]})},NG=({onClose:t})=>S.jsxs("div",{className:"bg-main font-main scrollbar-hide relative flex h-full w-full cursor-auto flex-col overflow-hidden shadow-2xl","data-cy":"element-inspector",children:[S.jsx(pG,{onClose:t}),S.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:S.jsx(GW,{})}),S.jsx("div",{className:"border-main-border bg-main-light flex flex-shrink-0 items-center border-t px-2.5 py-1.5",children:S.jsx(MG,{side:"top",align:"start"})})]}),OG=ds("useServerConfig"),LG=()=>{const[t,e]=g.useState(null),[n,r]=g.useState(!0),[s,i]=g.useState(null),a=g.useCallback(async()=>{var u;try{r(!0),i(null);const c=await fetch("/api/health");if(!c.ok)throw new Error(`Failed to fetch config: ${c.status}`);const f=await c.json();if(!f.framework)throw new Error("Server did not return framework information");const h={userPort:((u=f.ports)==null?void 0:u.userDevServer)||3e3,framework:f.framework};return e(h),h}catch(c){const f=c instanceof Error?c.message:"Failed to fetch server config";throw i(f),OG.warn("Error fetching server config:",c),c}finally{r(!1)}},[]);return{config:t,fetchConfig:a,isLoading:n,error:s}},DG="#1C1C20",Ai=[118,118,124],rk=.85,jG=3,FG=.15,Jh=36,VG=4.4,$G=.7,HG=3.5,zG=.8,sk=9,UG=11,BG=[1.35,1.12,.95,.85],WG=[0,1.1,2.3,3.1],GG=[0,.35,.16,.13],KG=[.9,.5,.4,.35],Aa=3,h1=[[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.14,y1:.13,x2:.86,y2:.23,level:1},{x1:.14,y1:.28,x2:.3,y2:.87,level:1},{x1:.34,y1:.28,x2:.86,y2:.87,level:1},{x1:.165,y1:.155,x2:.225,y2:.205,level:2},{x1:.7,y1:.155,x2:.755,y2:.205,level:2},{x1:.775,y1:.155,x2:.83,y2:.205,level:2},{x1:.165,y1:.32,x2:.275,y2:.375,level:2},{x1:.165,y1:.415,x2:.275,y2:.47,level:2},{x1:.165,y1:.51,x2:.275,y2:.565,level:2},{x1:.37,y1:.32,x2:.585,y2:.56,level:2},{x1:.615,y1:.32,x2:.83,y2:.56,level:2},{x1:.37,y1:.61,x2:.83,y2:.83,level:2},{hline:!0,x1:.39,x2:.81,y:.685,level:3},{hline:!0,x1:.39,x2:.75,y:.755,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.16,y1:.17,x2:.52,y2:.45,level:1},{x1:.58,y1:.17,x2:.685,y2:.29,level:1},{x1:.715,y1:.17,x2:.84,y2:.29,level:1},{x1:.58,y1:.33,x2:.685,y2:.45,level:1},{x1:.715,y1:.33,x2:.84,y2:.45,level:1},{x1:.16,y1:.55,x2:.84,y2:.85,level:1},{x1:.19,y1:.21,x2:.36,y2:.33,level:2},{hline:!0,x1:.19,x2:.48,y:.37,level:3},{hline:!0,x1:.19,x2:.42,y:.42,level:3},{x1:.19,y1:.6,x2:.49,y2:.8,level:2},{hline:!0,x1:.53,x2:.8,y:.63,level:3},{hline:!0,x1:.53,x2:.76,y:.7,level:3},{hline:!0,x1:.53,x2:.79,y:.77,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.14,y1:.13,x2:.86,y2:.22,level:1},{x1:.14,y1:.28,x2:.36,y2:.87,level:1},{x1:.39,y1:.28,x2:.61,y2:.87,level:1},{x1:.64,y1:.28,x2:.86,y2:.87,level:1},{x1:.165,y1:.15,x2:.225,y2:.2,level:2},{x1:.165,y1:.32,x2:.335,y2:.52,level:2},{x1:.415,y1:.32,x2:.585,y2:.52,level:2},{x1:.665,y1:.32,x2:.835,y2:.52,level:2},{hline:!0,x1:.165,x2:.335,y:.6,level:3},{hline:!0,x1:.165,x2:.3,y:.67,level:3},{hline:!0,x1:.415,x2:.585,y:.6,level:3},{hline:!0,x1:.415,x2:.55,y:.67,level:3},{hline:!0,x1:.665,x2:.835,y:.6,level:3},{hline:!0,x1:.665,x2:.8,y:.67,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.3,y1:.22,x2:.7,y2:.74,level:1},{x1:.34,y1:.27,x2:.55,y2:.34,level:2},{hline:!0,x1:.36,x2:.64,y:.42,level:3},{hline:!0,x1:.36,x2:.6,y:.49,level:3},{hline:!0,x1:.36,x2:.62,y:.56,level:3},{x1:.5,y1:.63,x2:.575,y2:.69,level:2},{x1:.595,y1:.63,x2:.66,y2:.69,level:2}]],ep=t=>{let e=t|0;return e=Math.imul(e^e>>>16,73244475),e=Math.imul(e^e>>>16,73244475),e^=e>>>16,(e>>>0)/4294967296},Ep=t=>{const e=Math.min(1,Math.max(0,t));return e*e*(3-2*e)},Ia=(t,e)=>(Math.round(t/e-.5)+.5)*e,qG=Math.sin(Math.PI/3),ik=(t,e,n,r,s)=>{if(t.beginPath(),e===0)t.arc(n,r,s,0,Math.PI*2);else if(e===1){const i=s*qG;t.moveTo(n,r-s),t.lineTo(n+i,r+s/2),t.lineTo(n-i,r+s/2),t.closePath()}else{const i=s*.85;t.rect(n-i,r-i,i*2,i*2)}t.fill()},ZG=(t,e,n)=>{let r;if(n.hline){const s=Math.max(n.x1-t,t-n.x2,0),i=Math.abs(e-n.y1);r=Math.hypot(s,i)-sk}else{const s=Math.max(n.x1-t,t-n.x2,0),i=Math.max(n.y1-e,e-n.y2,0);s===0&&i===0?r=-Math.min(t-n.x1,n.x2-t,e-n.y1,n.y2-e):r=Math.hypot(s,i),r=Math.abs(r)-sk}return Ep(.5-r/(2*UG))},uR=({className:t="",trackGlobalLoaderCount:e=!0})=>{const n=st(ZT),r=g.useRef(null),s=g.useCallback(i=>{var L;if((L=r.current)==null||L.call(r),r.current=null,!i)return;const a=i.getContext("2d");if(!a)return;e&&n(D=>D+1);const u=window.matchMedia("(prefers-reduced-motion: reduce)").matches;let c=[],f=0,h=0,p=Jh,v=Jh,y=null,x=null,_=0,b=-1;const E=new Array(33),k=D=>{const V=Math.round(D*32);let K=E[V];if(!K){const Y=V/32,G=Math.round(Ai[0]+(255-Ai[0])*Y),B=Math.round(Ai[1]+(255-Ai[1])*Y),Q=Math.round(Ai[2]+(255-Ai[2])*Y);K=`rgba(${G}, ${B}, ${Q}, ${rk})`,E[V]=K}return K},P=D=>{const V=1-.35*D,K=Math.round(Ai[0]*V),Y=Math.round(Ai[1]*V),G=Math.round(Ai[2]*V);return`rgba(${K}, ${Y}, ${G}, ${rk})`},T=D=>{let V=Math.floor(Math.random()*h1.length);V===b&&(V=(V+1)%h1.length),b=V;const K=[0,0,0,0],Y=h1[V].map((j,Z)=>{const ee=j.level,ie=K[ee]++,le=WG[ee]+ie*GG[ee],ue=KG[ee]+ep(V*131+Z*17+5)*.2;if(j.hline){const se=Ia((j.y??0)*h,v);return{hline:!0,x1:Ia(j.x1*f,p),x2:Ia(j.x2*f,p),y1:se,y2:se,level:ee,start:le,dur:ue}}const Ce=Ia(j.x1*f,p),ae=Ia((j.y1??0)*h,v);return{hline:!1,x1:Ce,y1:ae,x2:Math.max(Ia(j.x2*f,p),Ce+p),y2:Math.max(Ia((j.y2??0)*h,v),ae+v),level:ee,start:le,dur:ue}}),G=Y.reduce((j,Z)=>Math.max(j,Z.start+Z.dur),0),B=c.length,Q=new Float32Array(B*Aa),$=new Int16Array(B*Aa).fill(-1),te=new Uint8Array(B),H=Y[0];for(let j=0;j<B;j++){const Z=c[j];Z.x>H.x1&&Z.x<H.x2&&Z.y>H.y1&&Z.y<H.y2&&(te[j]=1);const ee=j*Aa;for(let ie=0;ie<Y.length;ie++){const le=ZG(Z.x,Z.y,Y[ie]);if(le<=.02)continue;let ue=ee;for(let Ce=ee;Ce<ee+Aa;Ce++){if($[Ce]===-1){ue=Ce;break}Q[Ce]<Q[ue]&&(ue=Ce)}($[ue]===-1||le>Q[ue])&&(Q[ue]=le,$[ue]=ie)}}return{startT:D,buildEnd:G,els:Y,frame:H,cellQ:Q,cellEl:$,inFrame:te}},A=()=>{const D=i.getBoundingClientRect();f=Math.max(1,D.width),h=Math.max(1,D.height);const V=Math.min(2,window.devicePixelRatio||1);i.width=Math.round(f*V),i.height=Math.round(h*V),a.setTransform(V,0,0,V,0,0);const K=Math.max(8,Math.round(f/Jh)),Y=Math.max(6,Math.round(h/Jh));p=f/K,v=h/Y,c=[];for(let G=0;G<Y;G++){const B=Y>1?G/(Y-1):.5,Q=VG*(1+$G*.4*(B*2-1));for(let $=0;$<K;$++){const te=G*8191+$*131+1,H={x:($+.5)*p,y:(G+.5)*v,size:Q,seed:te,phase:ep(te),kind:0};H.kind=Math.floor(ep(te*97)*3),c.push(H)}}x=null,y=null},O=new Float32Array(32),N=D=>{a.fillStyle=DG,a.fillRect(0,0,f,h),y||(y=T(D+.2)),D>=y.startT+y.buildEnd+HG&&(x=y,_=D,y=T(D+.2));let V=0;x&&(V=1-Ep((D-_)/zG),V<=0&&(x=null));const K=y;for(let H=0;H<K.els.length;H++){const j=K.els[H];O[H]=Ep(Math.min(1,Math.max(0,(D-K.startT-j.start)/j.dur)))}const Y=O[0],G=P(0),B=P(Y),Q=V>0?P(V):G,$=V>0?P(Math.max(Y,V)):B,te=c.length;for(let H=0;H<te;H++){const j=c[H];let Z=0,ee=0;const ie=H*Aa;for(let we=ie;we<ie+Aa;we++){const Ie=K.cellEl[we];if(Ie<0)break;const qe=K.cellQ[we]*O[Ie];qe>Z&&(Z=qe,ee=K.els[Ie].level)}if(x)for(let we=ie;we<ie+Aa;we++){const Ie=x.cellEl[we];if(Ie<0)break;const qe=x.cellQ[we]*V;qe>Z&&(Z=qe,ee=x.els[Ie].level)}const le=D/jG+j.phase,ue=Math.floor(le),Ce=le-ue,ae=Ep(Math.min(Ce,1-Ce)/FG),se=Math.floor(ep(j.seed*97+ue*7919)*3);se!==j.kind&&Z<.02&&ae<.05&&(j.kind=se);const pe=Math.max(ae*(1-Z),Z);if(!(pe<.01))if(Z<.02){const we=K.inFrame[H]===1,Ie=x?x.inFrame[H]===1:!1;we?a.fillStyle=Ie?$:B:a.fillStyle=Ie?Q:G;const qe=Math.max(we?Y:0,Ie?V:0);ik(a,j.kind,j.x,j.y,j.size*pe*(1-.2*qe))}else{a.fillStyle=k(Z);const we=1+(BG[ee]-1)*Z;ik(a,j.kind,j.x,j.y,j.size*pe*we)}}};A();let R=0;if(u)y=T(-100),N(0);else{const D=performance.now(),V=K=>{N((K-D)/1e3),R=requestAnimationFrame(V)};R=requestAnimationFrame(V)}const M=new ResizeObserver(()=>{A(),u&&(y=T(-100),N(0))});M.observe(i),r.current=()=>{cancelAnimationFrame(R),M.disconnect(),e&&n(D=>D-1)}},[e,n]);return S.jsx("canvas",{ref:s,"aria-hidden":"true",className:`h-full w-full ${t}`.trim()})},YG=async(t=null)=>{if(t)return QG(t);let e;try{e=await fetch("/api/mcp/status")}catch{return{isOk:!1,unavailableReason:"rivet_unreachable"}}if(e.status===404||!(e.headers.get("content-type")??"").toLowerCase().includes("application/json"))return tp();if(!e.ok)return{isOk:!1,unavailableReason:"rivet_unreachable"};let r;try{r=await e.json()}catch{return tp()}const s=r.devServerHealth;return s?s.ownership==="none"?{isOk:!1,unavailableReason:"upstream_unreachable"}:s.isReachable===!0?{isOk:!0,unavailableReason:"upstream_unreachable"}:{isOk:!1,unavailableReason:s.reason==="rivet_unreachable"?"rivet_unreachable":"upstream_unreachable"}:tp()},QG=async t=>{try{const e=await fetch(t);return{isOk:e.status!==502&&e.status!==503,unavailableReason:"upstream_unreachable"}}catch{return{isOk:!1,unavailableReason:"rivet_unreachable"}}},tp=async()=>{try{const t=await fetch("/");return{isOk:t.status!==502&&t.status!==503,unavailableReason:"upstream_unreachable"}}catch{return{isOk:!1,unavailableReason:"rivet_unreachable"}}},ok=ds("usePreviewUpstreamHealth"),XG=500,JG=4e3,eK=15e3,tK=(t,e={})=>{const n=g.useRef(null),r=g.useRef(null),s=e.probeMsWhileDown??XG,i=e.probeMsWhileUp??JG,a=e.firstUnreachableCaptureAfterMs??eK,u=e.rerunProbeImmediatelyOnVersion,c=e.probePath??null,f=e.skip??!1,[h,p]=g.useState(t==="static"),[v,y]=g.useState(0),[x,_]=g.useState(null),[b,E]=g.useState(0),[k,P]=g.useState(!1),[T,A]=g.useState(!1),[O,N]=g.useState(t==="static"?null:"upstream_unreachable");return g.useEffect(()=>{if(t==="static"){p(!0),_(null),E(0),P(!1),A(!0),N(null);return}if(f){p(!1),_(null),E(0),P(!1),A(!0),N("upstream_unreachable"),n.current=null;return}let R=!0;const M=Date.now();_(M),E(0),P(!1),p(!1),A(!1),N("upstream_unreachable");const L={current:!1},D={current:!1},V={current:!1},K={current:null},Y={current:!1};let G=null;const B=()=>{V.current||(V.current=!0,R&&A(!0))},Q=()=>{G!==null&&(clearTimeout(G),G=null)},$=(H,j)=>{Q(),G=setTimeout(j,H)},te=async()=>{if(!R)return;E(ie=>ie+1);const{isOk:H,unavailableReason:j}=await YG(c);if(!R)return;if(B(),H){const ie=!Y.current;Y.current=!0,p(!0),N(null),K.current=null,D.current=!1,P(!1),L.current?ie&&(Pe==null||Pe.capture("preview_upstream_restored",{framework:t})):(L.current=!0,Pe==null||Pe.capture("preview_dev_server_ready",{framework:t,ready_after_ms:Date.now()-M})),$(i,te);return}const Z=Y.current;Y.current=!1,p(!1),N(j),K.current===null&&(K.current=Date.now(),D.current=!1,P(!1)),Z&&(Pe==null||Pe.capture("preview_upstream_lost",{framework:t}),y(ie=>ie+1),ok.warn("Preview upstream became unavailable after it was ready"));const ee=Date.now()-K.current;ee>=a&&!D.current&&(D.current=!0,P(!0),Pe==null||Pe.capture("preview_dev_server_unreachable",{framework:t,elapsed_ms:ee}),ok.warn("Dev server did not become ready within timeout window")),$(s,te)};return n.current=()=>$(0,te),$(0,te),()=>{R=!1,n.current=null,Q()}},[t,s,i,a,c,f]),g.useEffect(()=>{var M;if(t==="static"||u===void 0)return;const R=r.current;r.current=u,R!==null&&R!==u&&((M=n.current)==null||M.call(n))},[t,u]),{isUpstreamReady:h,iframeRemountKey:v,probeStartedAt:x,probeAttemptCount:b,isFirstUnreachableWindowExceeded:k,initialProbeComplete:T,unavailableReason:O}};function nK(t){return t.enteringSplit&&t.isExistingSession&&t.hasActiveVariantProxy}const cR=t=>{var e;return t!=="embedded"||typeof window>"u"?"":((e=window.__RIVET_BOOTSTRAP__)==null?void 0:e.previewOrigin)??`${window.location.protocol}//localhost:${window.location.port}`},dR=({agentApplyMode:t,url:e})=>e.startsWith("/")?`${cR(t)}${e}`:e,rK="allow-scripts allow-same-origin allow-forms allow-popups allow-modals",sK=t=>rK,iK=ds("PreviewSurface"),ak=(t,e)=>t==="about:blank"?"blank":t.includes("/api/variants/")?"static_artifact":e.kind==="variant"?"dev_server":"original",fR=({target:t,src:e,framework:n,remountKey:r})=>(Je(s0),S.jsx("div",{className:"relative h-full w-full",children:S.jsx("iframe",{src:e,className:"h-full w-full border-none",title:"Project Preview",sandbox:sK(),onLoad:()=>{Pe==null||Pe.capture("preview_iframe_loaded",{framework:n,src:e}),t.kind==="variant"&&(Pe==null||Pe.capture("variants_panel.preview_displayed",{sessionId:t.sessionId,variantId:t.variantId,renderedTarget:"variant",iframeSrcKind:ak(e,t),framework:n}))},onError:()=>{Pe==null||Pe.capture("preview_iframe_load_failed",{framework:n,src:e}),t.kind==="variant"&&(Pe==null||Pe.capture("variants_panel.preview_display_failed",{sessionId:t.sessionId,variantId:t.variantId,renderedTarget:"variant",iframeSrcKind:ak(e,t),framework:n})),iK.warn("Preview iframe failed to load",{framework:n,src:e})}},r)})),oK="modulepreload",aK=function(t){return"/"+t},lk={},lK=function(e,n,r){let s=Promise.resolve();if(n&&n.length>0){let a=function(f){return Promise.all(f.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),c=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));s=a(n.map(f=>{if(f=aK(f),f in lk)return;lk[f]=!0;const h=f.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${p}`))return;const v=document.createElement("link");if(v.rel=h?"stylesheet":oK,h||(v.as="script"),v.crossOrigin="",v.href=f,c&&v.setAttribute("nonce",c),document.head.appendChild(v),h)return new Promise((y,x)=>{v.addEventListener("load",y),v.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(a){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=a,window.dispatchEvent(u),!u.defaultPrevented)throw a}return s.then(a=>{for(const u of a||[])u.status==="rejected"&&i(u.reason);return e().catch(i)})},uK=g.lazy(()=>lK(()=>Promise.resolve().then(()=>Hq),void 0)),cK={surface:"relative flex h-full w-full items-center justify-center bg-main px-6",overlay:"absolute inset-0 z-10 flex items-center justify-center bg-main/90 px-6",page:"relative flex h-screen w-full items-center justify-center bg-main px-6"},dK={sm:"text-lg font-semibold text-content",md:"text-2xl font-semibold text-content",lg:"text-3xl font-semibold text-content"},fK={neutral:"rounded-md border border-divider bg-transparent px-5 py-2 text-sm font-medium text-content transition-colors hover:bg-surface-3",ghost:"rounded-md px-5 py-2 text-sm font-medium text-content-muted transition-colors hover:text-content"},_d=({backdrop:t,media:e,title:n,description:r,actions:s,tone:i="neutral",fill:a="surface",size:u="md",children:c,state:f,role:h="status",busy:p=!1,className:v=""})=>{const y=g.useCallback(_=>{_&&f&&(Pe==null||Pe.capture("status_surface_shown",{state:f,tone:i,fill:a}))},[f,i,a]),x=!!(e||n||r||c||s!=null&&s.length);return S.jsxs("div",{ref:y,className:`${cK[a]} ${v}`.trim(),role:h,"aria-live":"polite","aria-busy":p||void 0,"data-state":f,children:[t?S.jsx("div",{className:"absolute inset-0",children:t}):null,x?S.jsxs("div",{className:"relative z-10 flex max-w-sm flex-col items-center gap-5 text-center",children:[e,n?S.jsx("h2",{className:dK[u],children:n}):null,r?S.jsx("p",{className:"text-content-muted text-base leading-relaxed",children:r}):null,c,s!=null&&s.length?S.jsx("div",{className:"flex flex-row items-center gap-3",children:s.map(_=>S.jsx("button",{type:"button",onClick:_.onClick,className:fK[_.variant??"neutral"],children:_.label},_.label))}):null]}):null]})},w_=({loader:t="coalesce",trackGlobalLoaderCount:e,size:n="lg",...r})=>t==="coalesce"?S.jsx(_d,{...r,size:n,busy:!0,backdrop:S.jsx(uR,{trackGlobalLoaderCount:e})}):t==="logo"?S.jsx(_d,{...r,size:n,busy:!0,backdrop:S.jsx(g.Suspense,{fallback:null,children:S.jsx(uK,{className:"absolute inset-0"})})}):S.jsx(_d,{...r,size:n,busy:!0,media:S.jsx(r0,{"aria-hidden":!0,className:"text-content h-8 w-8 shrink-0 animate-spin",weight:"bold"})}),hR=({icon:t,...e})=>S.jsx(_d,{...e,tone:"neutral",media:t?S.jsx("div",{className:"text-content-muted",children:t}):void 0}),Cm=t=>S.jsx(_d,{...t,tone:"error",role:"alert"}),uk="/static/",hK=t=>{try{return new URL(t,"http://localhost").pathname.endsWith(uk)}catch{return t.endsWith(uk)}},pK=({isInteractionDisabled:t=!1,framework:e,userPort:n,activeDemoSessionId:r=null,holdPreviewNavigation:s=!1})=>{const i=Je(u_),a=st(u_),u=Je(xm),c=st(xm),f=Je(hf),h=Je(s0),p=Je(c_),v=Je(d_),y=Je(QT),x=Je(XT),_=st(d_),b=Je(Zo),E=Je(h_),k=st(c_),P=f.active&&f.projectContext.kind==="fresh",T=Je(f_),A=f.active?f.variants.find(je=>je.workItemId===T&&(je.status==="pending"||je.status==="running"||je.status==="succeeded"&&!je.preview&&typeof je.port!="number"&&(!je.previewUnavailable||je.previewUnavailable.reason==="idle_timeout")))??null:null,O=f.active&&f.variants.some(je=>je.status==="pending"||je.status==="running"),N=P||O,R=f.active?f.variants.find(je=>{var Ye;return je.workItemId===T&&je.status==="succeeded"&&!!je.previewUnavailable&&((Ye=je.previewUnavailable)==null?void 0:Ye.reason)!=="idle_timeout"})??null:null,M=e==="static"&&u!==null&&hK(u);g.useEffect(()=>{f.active||k(!1)},[f.active,k]);const L=g.useRef(!1);g.useEffect(()=>{const je=!!(b!=null&&b.left||b!=null&&b.right),Ye=je&&!L.current;L.current=je;const lt=f.active?f.sessionId:null;!lt||!nK({enteringSplit:Ye,isExistingSession:f.active&&f.projectContext.kind==="existing",hasActiveVariantProxy:p&&v!==null})||(k(!1),_(null),a(Xe=>Xe+1),fetch(`/api/variants/${encodeURIComponent(lt)}/preview-port`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({variantId:null})}).catch(()=>{}))},[b,f,p,v,k,_,a]);const V=g.useMemo(()=>{var xn;if(p||u&&!M||!f.active)return null;const{stage:je,variants:Ye}=f,lt=je==="ready"||je==="degraded",Xe=Ye.some(Ut=>{var Rn,Hn;return((Rn=Ut.refinement)==null?void 0:Rn.status)==="pending"||((Hn=Ut.refinement)==null?void 0:Hn.status)==="running"});if(!lt&&!Xe)return null;const vt=Ye.find(Ut=>{var Rn;return Ut.status==="succeeded"&&((Rn=Ut.preview)==null?void 0:Rn.kind)==="static_artifact"});return((xn=vt==null?void 0:vt.preview)==null?void 0:xn.kind)==="static_artifact"?vt.preview.url:null},[M,u,p,f])??u,K=g.useMemo(()=>!f.active||!V?null:f.variants.find(je=>{var Ye;return((Ye=je.preview)==null?void 0:Ye.kind)==="static_artifact"&&V.startsWith(je.preview.url)})??null,[V,f]),Y=g.useMemo(()=>{if((E==null?void 0:E.previewKind)==="static")return{kind:"variant",sessionId:E.sessionId,variantId:E.variantId};if(!f.active)return _m;if(K)return{kind:"variant",sessionId:f.sessionId,variantId:K.workItemId};if(V){const Ye=V.match(/\/__rivet\/preview\/variant\/([^/]+)\/([^/?#]+)/),lt=Ye!=null&&Ye[1]?decodeURIComponent(Ye[1]):null,Xe=Ye!=null&&Ye[2]?decodeURIComponent(Ye[2]):null;if(lt===f.sessionId&&Xe&&f.variants.some(Ut=>Ut.workItemId===Xe))return{kind:"variant",sessionId:f.sessionId,variantId:Xe};const vt=V.match(/\/api\/variants\/[^/]+\/static\/([^/?#]+)/),xn=vt!=null&&vt[1]?decodeURIComponent(vt[1]):null;if(xn&&f.variants.some(Ut=>Ut.workItemId===xn))return{kind:"variant",sessionId:f.sessionId,variantId:xn}}const je=!!(b!=null&&b.left||b!=null&&b.right);return(!je||P)&&!V&&p&&v&&f.variants.some(Ye=>Ye.workItemId===v)?{kind:"variant",sessionId:f.sessionId,variantId:v}:(!je||P)&&!V&&T&&f.variants.some(Ye=>Ye.workItemId===T)?{kind:"variant",sessionId:f.sessionId,variantId:T}:_m},[E,K,f,p,v,V,b,P,T]),G=g.useRef(null);g.useEffect(()=>{var Xe,vt;if(!K||((Xe=K.preview)==null?void 0:Xe.kind)!=="static_artifact"||((vt=K.refinement)==null?void 0:vt.status)!=="succeeded")return;const je=`${K.workItemId}:${K.refinement.workItemId}`;if(G.current===je)return;G.current=je;const Ye=K.preview.url.includes("?")?"&":"?",lt=`${K.preview.url}${Ye}refinement=${encodeURIComponent(K.refinement.workItemId)}`;V!==lt&&(c(lt),a(xn=>xn+1))},[V,K,a,c,f]);const B=V!==null&&VW(V),Q=V!==null&&!B||P&&!p&&!B,{isUpstreamReady:$,iframeRemountKey:te,probeAttemptCount:H,initialProbeComplete:j}=tK(e,{rerunProbeImmediatelyOnVersion:i,probePath:B?V:null,skip:Q}),[Z,ee]=g.useState(()=>y&&$?i:null),ie=g.useRef(null);g.useEffect(()=>{if(!y){ie.current=null,ee(null);return}if(Z===i){ie.current=null;return}const je=ie.current;if(!je||je.remountKey!==i){ie.current={remountKey:i,probeAttemptCount:H};return}$&&H>je.probeAttemptCount&&(ie.current=null,ee(i))},[Z,i,y,H,$]);const ue=V!==null&&!B||$,ae=x||y&&Z!==i||y&&!ue,se=`${te}:${i}`,pe=r?`/try/${encodeURIComponent(r)}`:"",we=sR(window.location.pathname),Ie=e==="static"?`${pe}/static${we??"/"}`:`${pe}${we??"/"}`,qe=cR(h);let it=null;V&&(it=dR({agentApplyMode:h,url:V}));const at=A||ae?"about:blank":(B&&!ue?"about:blank":it)??(s||!ue?"about:blank":`${qe}${Ie}`),At=!!A||!!R||!ue&&j;let mt=null;return ae?mt=S.jsx(w_,{fill:"overlay",loader:"coalesce",trackGlobalLoaderCount:!1,state:"preview_replay_boot"}):A?mt=S.jsx(w_,{fill:"overlay",loader:"coalesce",trackGlobalLoaderCount:!1,state:"variant_building",children:S.jsx("span",{className:"sr-only",children:"Building your direction"})}):R?mt=S.jsx(Cm,{fill:"overlay",state:"preview_unavailable",title:"Preview couldn’t start",description:"Its preview server didn’t start.",actions:[{label:"Reload",onClick:()=>window.location.reload()}]}):At&&(mt=N?S.jsx(hR,{fill:"overlay",state:"preview_no_selection",title:"Nothing to preview yet",description:"Pick a direction from the panel."}):S.jsx(Cm,{fill:"overlay",state:"preview_offline",title:"Preview isn't connected",description:"Rivet lost connection to your project.",actions:[{label:"Reload",onClick:()=>window.location.reload()}]})),S.jsxs("div",{className:"relative h-full w-full",children:[mt,S.jsx(fR,{target:Y,src:at,framework:e,remountKey:se})]})};function ck({side:t,sessionId:e,variantId:n,url:r,label:s,source:i,isFallback:a=!1}){var E;const u=st(Zo),c=Je(hf),f=Je(s0),h=g.useRef(!1),p=g.useCallback(()=>{h.current||(h.current=!0,Kd({source:i,sessionId:e,variantId:n}))},[i,e,n]),v=g.useCallback(()=>{if(a){u(null);return}p(),u(k=>{if(!k)return null;const P={...k};return delete P[t],P.left||P.right?P:null})},[u,t,a,p]),y=g.useMemo(()=>({kind:"variant",sessionId:e,variantId:n}),[e,n]),x=g.useMemo(()=>!c.active||c.sessionId!==e?null:c.variants.find(k=>k.workItemId===n)??null,[e,n,c]),_=g.useMemo(()=>{var P,T;let k=r;if(((P=x==null?void 0:x.preview)==null?void 0:P.kind)==="static_artifact"&&((T=x.refinement)==null?void 0:T.status)==="succeeded"){const A=x.preview.url.includes("?")?"&":"?";k=`${x.preview.url}${A}refinement=${encodeURIComponent(x.refinement.workItemId)}`}return dR({agentApplyMode:f,url:k})},[f,x,r]),b=((E=x==null?void 0:x.refinement)==null?void 0:E.status)==="succeeded"?`${n}:${x.refinement.workItemId}`:n;return S.jsxs("div",{className:"variant-split-secondary","data-cy":"variant-split-pane","data-variant-id":n,children:[S.jsxs("div",{className:"variant-split-secondary-toolbar",children:[S.jsx("span",{className:"variant-split-secondary-label",title:s,children:s}),S.jsx(Fo,{label:"Collapse",children:S.jsx("button",{type:"button",className:"variant-split-secondary-close",onClick:v,"aria-label":"Collapse split view",children:S.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",focusable:"false",children:S.jsx("path",{d:"M2.5 2.5 L9.5 9.5 M9.5 2.5 L2.5 9.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})})})]}),S.jsx("div",{className:"variant-split-secondary-body relative min-h-0 flex-1",children:S.jsx(fR,{target:y,src:_,framework:"static",remountKey:b})})]})}const dk=240;function mK(){const t=Je(Ud),e=Je(ex),n=g.useRef(null);return g.useEffect(()=>{if(!t||!e||!n.current)return;const r=e.x-dk/2,s=e.y-22;n.current.style.transform=`translate3d(${r}px, ${s}px, 0)`},[t,e]),!t||!e?null:S.jsx("div",{ref:n,"aria-hidden":"true",className:"variant-drag-ghost",style:{width:dk},children:S.jsxs("div",{className:"variant-drag-ghost-body",children:[S.jsxs("div",{className:"variant-drag-ghost-row",children:[S.jsx("div",{className:"variant-drag-ghost-title",children:t.label}),t.runLabel?S.jsx("div",{className:"variant-drag-ghost-tag",style:$T(t.runLabel),children:t.runLabel}):null]}),t.description?S.jsx("div",{className:"variant-drag-ghost-desc",children:t.description}):null]})})}function gK(){const t=Je(Ud),e=Je(ex),n=Je(Zo),r=st(Ud),s=st(Zo),i=g.useRef(null),[a,u]=g.useState(null),[c,f]=g.useState("hidden");g.useEffect(()=>{if(!t){f("hidden"),u(null);return}const v=requestAnimationFrame(()=>f("visible"));return()=>cancelAnimationFrame(v)},[t]);const h=g.useCallback((v,y)=>{const x=i.current;if(!x)return null;const _=x.getBoundingClientRect();return v<_.left||v>_.right||y<_.top||y>_.bottom?null:v<(_.left+_.right)/2?"left":"right"},[]);if(g.useEffect(()=>{if(!t||!e)return;const v=h(e.x,e.y);u(y=>y===v?y:v)},[t,e,h]),g.useEffect(()=>{if(!t)return;const v=y=>{const x=h(y.clientX,y.clientY);if(x&&t.url){const _={sessionId:t.sessionId,variantId:t.variantId,label:t.label,url:t.url,source:t.source},b=n==null?void 0:n[x];b&&(b.sessionId!==_.sessionId||b.variantId!==_.variantId)&&Kd(b),s(E=>({...E??{},[x]:_})),f("exiting"),window.setTimeout(()=>r(null),220)}else Kd(t),f("exiting"),window.setTimeout(()=>r(null),220)};return window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),()=>{window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v)}},[t,h,r,s,n]),!t)return null;const p=["variant-drop-zones",c==="visible"&&"is-visible",c==="exiting"&&"is-exiting"].filter(Boolean).join(" ");return S.jsxs("div",{ref:i,className:p,"aria-hidden":"true",children:[S.jsx(fk,{side:"left",hovered:a==="left",canDrop:!!t.url,label:t.label}),S.jsx(fk,{side:"right",hovered:a==="right",canDrop:!!t.url,label:t.label})]})}function fk({side:t,hovered:e,canDrop:n,label:r}){return S.jsxs("div",{className:["variant-drop-zone",`is-${t}`,e&&"is-hover",!n&&"is-disabled"].filter(Boolean).join(" "),children:[S.jsxs("div",{className:"variant-drop-zone-inner",children:[S.jsx("div",{className:`variant-drop-zone-icon is-${t}`}),S.jsx("div",{className:"variant-drop-zone-caption",children:n?`Add ${t} split`:"Split unavailable for this direction"})]}),S.jsx("div",{className:"variant-drop-zone-preview","aria-hidden":"true",children:S.jsx("div",{className:"variant-drop-zone-preview-label",children:r})}),S.jsx("div",{className:"variant-drop-zone-border"})]})}const pR=(t,e,n)=>{var i,a;if(!t.active||t.sessionId!==e)return null;const r=t.variants.find(u=>u.workItemId===n);if(((i=r==null?void 0:r.preview)==null?void 0:i.kind)!=="static_artifact")return null;if(((a=r.refinement)==null?void 0:a.status)!=="succeeded")return r.preview.url;const s=r.preview.url.includes("?")?"&":"?";return`${r.preview.url}${s}refinement=${encodeURIComponent(r.refinement.workItemId)}`},hk=(t,e)=>{if(!t)return;const n=pR(e,t.sessionId,t.variantId);return!n||n===t.url?t:{...t,url:n}},vK=()=>S.jsx("div",{"data-testid":"preview-boot-skeleton",role:"status","aria-busy":"true","aria-label":"Loading preview",className:"bg-main flex h-full min-h-0 w-full flex-1 flex-col p-3",children:S.jsx("div",{className:"border-main-border relative min-h-0 flex-1 overflow-hidden rounded-lg border",children:S.jsx(uR,{trackGlobalLoaderCount:!1})})}),yK=({isLoading:t=!1,isInteractionDisabled:e=!1,activeDemoSessionId:n=null,holdHostedTryoutPreviewNavigation:r=!1})=>{const{config:s,fetchConfig:i,isLoading:a,error:u}=LG();return g.useEffect(()=>{i().catch(c=>{Pe==null||Pe.capture("preview_config_load_failed",{message:c instanceof Error?c.message:"unknown_error"})})},[i]),a?r?S.jsx("div",{className:"bg-main flex h-full min-h-0 w-full flex-1","aria-busy":"true"}):S.jsx(vK,{}):u||!s?S.jsx(Cm,{fill:"surface",size:"sm",state:"preview_config_error",title:"Couldn't load preview",description:"We couldn't load the preview configuration.",actions:[{label:"Retry",onClick:()=>{Pe==null||Pe.capture("preview_config_retry_clicked"),i().catch(c=>{Pe==null||Pe.capture("preview_config_load_failed",{message:c instanceof Error?c.message:"unknown_error"})})}}]}):S.jsx(_K,{isLoading:t,isInteractionDisabled:e,framework:s.framework,userPort:s.userPort,activeDemoSessionId:n,holdHostedTryoutPreviewNavigation:r})};function _K(t){const e=Je(Zo),n=Je(Ud),r=Je(hf),s=Je(xm),i=e==null?void 0:e.left,a=e==null?void 0:e.right,u=g.useMemo(()=>{var A,O;if(!r.active||r.projectContext.kind!=="fresh"||!(!!i!=!!a))return;const _=(A=i??a)==null?void 0:A.variantId,b=r.variants.filter(N=>{var R;return N.status==="succeeded"&&((R=N.preview)==null?void 0:R.kind)==="static_artifact"&&N.workItemId!==_}),E=s==null?void 0:s.replace(/[?&]refinement=[^&]*$/,""),P=b.find(N=>{var R;return((R=N.preview)==null?void 0:R.kind)==="static_artifact"&&N.preview.url===E})??b[0];if(((O=P==null?void 0:P.preview)==null?void 0:O.kind)!=="static_artifact")return;const T=pR(r,r.sessionId,P.workItemId);if(T)return{sessionId:r.sessionId,variantId:P.workItemId,label:P.label,url:T,source:"live"}},[r,i,a,s]),c=hk(i,r)??(a?u:void 0),f=hk(a,r)??(i?u:void 0),h=!i&&!!c,p=!a&&!!f,v=!!(c||f),y=S.jsx(pK,{isInteractionDisabled:t.isInteractionDisabled,framework:t.framework,userPort:t.userPort,activeDemoSessionId:t.activeDemoSessionId,holdPreviewNavigation:t.holdHostedTryoutPreviewNavigation});return S.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 flex-col",children:S.jsxs("div",{className:`variant-preview-region relative flex h-full min-h-0 w-full flex-1 flex-col ${n?"is-dragging":""} ${v?"is-split":""}`,children:[S.jsxs("div",{className:"variant-preview-row flex h-full min-h-0 w-full flex-1",children:[c&&S.jsx(ck,{side:"left",sessionId:c.sessionId,variantId:c.variantId,url:c.url,label:c.label,source:c.source,isFallback:h},`left-${c.sessionId}:${c.variantId}:${c.url}`),!(c&&f)&&S.jsx("div",{className:"variant-preview-primary flex h-full min-h-0 flex-1 flex-col",children:y}),f&&S.jsx(ck,{side:"right",sessionId:f.sessionId,variantId:f.variantId,url:f.url,label:f.label,source:f.source,isFallback:p},`right-${f.sessionId}:${f.variantId}:${f.url}`)]}),S.jsx("div",{className:"variant-preview-atmosphere","aria-hidden":"true"}),S.jsx(gK,{}),S.jsx(mK,{})]})})}const mR=({message:t,isLoading:e=!0})=>S.jsxs("div",{className:"flex items-center gap-2 text-sm text-content",children:[e?S.jsx(r0,{className:"h-4 w-4 shrink-0 animate-spin text-primary",weight:"bold"}):null,S.jsx("span",{className:"whitespace-pre-wrap font-sans",children:t})]});function ji(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function gR(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}/*!
115
115
  * GSAP 3.15.0
116
116
  * https://gsap.com
117
117
  *
@@ -419,4 +419,4 @@ ${s}`:s},eG=({rows:t,activeVariantId:e,activePastKey:n,isOriginalSelected:r,busy
419
419
  <body>
420
420
  <div class="panel">${zk}</div>
421
421
  </body>
422
- </html>`,kX="Too many people are trying Rivet right now. Please try again in a few minutes.",dI="Failed to start an isolated demo session.",PX=async t=>{if(t.status===429)return kX;try{const e=await t.json();if(e.error)return e.error;if(e.message)return e.message}catch{}return dI},H_=274,Dm=395,T1=Math.min(Dm,Math.round((H_+Dm)/2*1.1)),Bk="rivet:panelWidth:v2",TX=t=>{if(!(t instanceof HTMLElement))return!1;const e=t.tagName.toLowerCase();return t.isContentEditable||e==="input"||e==="textarea"||e==="select"},RX=({projectPath:t,activeDemoSessionId:e=null,showLoginGate:n=!1,onStartLogin:r,isStartingLogin:s=!1,loginError:i=null,fullPageHostedLoginProgressMessage:a=null,holdHostedTryoutPreviewNavigation:u=!1,hostedTryoutPreviewHoldMessage:c=null,deferInspectorUntilPreviewReady:f=!1})=>{const h=Je(ZT)>0,[p,v]=nP(KT),y=HV(),[x,_]=g.useState(()=>{if(typeof window>"u")return T1;const Y=Number(window.localStorage.getItem(Bk));return Number.isFinite(Y)&&Y>=H_&&Y<=Dm?Y:T1}),[b,E]=g.useState(!1),[k,P]=g.useState(rZ),T=p?x:0,[A,O]=g.useState(p);g.useEffect(()=>{if(!p){O(!1);return}P(Y=>nZ({position:Y,boundsLeftPx:x}))},[p,x]),g.useEffect(()=>{window.localStorage.setItem(Bk,String(x))},[x]),g.useEffect(()=>{if(!p)return;const Y=G=>{G.key==="Escape"&&(TX(G.target)||(G.preventDefault(),v(!1)))};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[p,v]);const N=g.useCallback(Y=>{Y.preventDefault(),Y.stopPropagation();const G=Y.clientX,B=x;E(!0);const Q=te=>{const H=Math.min(Dm,Math.max(H_,B+(te.clientX-G)));_(H)},$=()=>{window.removeEventListener("pointermove",Q),window.removeEventListener("pointerup",$),window.removeEventListener("pointercancel",$),E(!1)};window.addEventListener("pointermove",Q),window.addEventListener("pointerup",$),window.addEventListener("pointercancel",$)},[x]),R=g.useCallback(()=>_(T1),[]),M=gZ(),L=Je(pf);_Z({enabled:!L});const D=M.isProcessing?"Completing authentication...":a,V=D!==null,K=st(e5);return g.useEffect(()=>{K(t??null)},[t,K]),g.useEffect(()=>{n&&(document.body.style.cursor="auto")},[n]),S.jsxs(sl.div,{className:"relative flex h-screen overflow-hidden",initial:!1,animate:{opacity:1},transition:{duration:.5,ease:"easeOut"},"data-cy":"rivet-app",children:[D!==null&&!n?S.jsx("div",{className:"absolute inset-0 z-50",children:S.jsx(Uq,{message:D})}):null,n?S.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center bg-black/45 backdrop-blur-[2px]",children:S.jsx(fA,{isSigningIn:s||V,onStartSignIn:()=>{r==null||r()},errorMessage:i,displayMode:"modal"})}):null,S.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col ${n?"pointer-events-none select-none":""}`,children:[S.jsx(yK,{holdHostedTryoutPreviewNavigation:u,isInteractionDisabled:n,activeDemoSessionId:e}),u&&c?S.jsx("div",{className:"bg-main absolute inset-0 z-30 flex items-center justify-center",children:S.jsx("div",{className:"border-divider bg-main-light rounded-lg border p-6 shadow-lg",children:S.jsx(mR,{message:c})})}):null]}),n?null:S.jsx(S.Fragment,{children:!f&&!h?S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"relative order-first h-full flex-shrink-0",style:{width:A?x:0},children:S.jsxs(sl.div,{className:"absolute inset-y-0 left-0 z-30",initial:!1,animate:{x:p?0:-x},transition:y?{duration:0}:{duration:.2,ease:[.22,1,.36,1]},onAnimationComplete:()=>{p&&O(!0)},style:{width:x,willChange:"transform"},children:[S.jsx(NG,{onClose:()=>v(!1)}),S.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize panel",onPointerDown:N,onDoubleClick:R,className:"group/resize absolute inset-y-0 right-0 z-20 flex w-3 cursor-col-resize touch-none justify-end",children:S.jsx("span",{className:`h-full transition-all duration-150 ${b?"w-0.5 bg-content-muted":"w-px bg-divider group-hover/resize:w-0.5 group-hover/resize:bg-content-muted"}`})})]})}),b&&S.jsx("div",{className:"fixed inset-0 z-[100] cursor-col-resize"}),S.jsx(oZ,{isVisible:!0,isPanelOpen:p,isReducedMotion:!!y,position:k,dragBoundsLeftPx:T,onPositionChange:P,onToggle:()=>v(Y=>!Y)})]}):null}),S.jsx(m$,{duration:5e3,richColors:!0,toastOptions:{style:{maxHeight:"150px",overflow:"hidden"}}})]})},z_="rivet_connect_deep_link",AX=()=>{if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search),e=t.get("connect"),n=e??window.sessionStorage.getItem(z_);if(n!=="pinterest"&&n!=="arena")return null;if(window.sessionStorage.setItem(z_,n),e){t.delete("connect");const r=t.toString();window.history.replaceState(null,document.title,window.location.pathname+(r?`?${r}`:"")+window.location.hash)}return n},IX=AX(),MX=()=>{const[t,e]=g.useState(window.location.hash),[n]=g.useState(()=>typeof window<"u"&&window.sessionStorage.getItem(Rp)==="1"),[r,s]=g.useState(!1),[i,a]=g.useState(IX);g.useEffect(()=>{n&&window.sessionStorage.removeItem(Rp)},[n]);const{config:u,refetchConfig:c,loading:f,error:h}=pZ(),p=st(pf),[v,y]=g.useState(!1),[x,_]=g.useState(null),[b,E]=g.useState(!1),[k,P]=g.useState(!1),[T,A]=g.useState(null),[O,N]=g.useState(!1),R=g.useRef(!1),M=g.useRef(!1),L=wX(window.location.pathname),D=(u==null?void 0:u.activeDemoSessionId)??null,V=L??T??D,K=g.useMemo(()=>vX(u==null?void 0:u.demoMode,u==null?void 0:u.agentModeAvailable,V),[u==null?void 0:u.demoMode,u==null?void 0:u.agentModeAvailable,V]),Y=g.useMemo(()=>gX({configLoading:f,hasConfig:u!==null,demoMode:u==null?void 0:u.demoMode,agentModeAvailable:u==null?void 0:u.agentModeAvailable,pathnameDemoSessionId:L,activeDemoSessionId:T,configuredDemoSessionId:D}),[u,f,L,T,D]);g.useLayoutEffect(()=>{if(!Y){N(!1);return}N(!0)},[Y]);const G=O,B=g.useMemo(()=>yX(G),[G]),Q=(u==null?void 0:u.demoMode)===!0&&G,$=g.useRef(null);$.current=V;const te=g.useCallback(async()=>{if(!R.current)return;A(null);const pe=await c();if((pe==null?void 0:pe.demoMode)===!0&&pe.agentModeAvailable!==!0){P(!1);return}(pe==null?void 0:pe.demoMode)===!0&&P(!0)},[c]);g.useEffect(()=>{if((u==null?void 0:u.demoMode)===!0)return fX(()=>{te()})},[u==null?void 0:u.demoMode,te]),g.useEffect(()=>{if(R.current=(u==null?void 0:u.demoMode)===!0,(u==null?void 0:u.demoMode)!==!0)return;const pe=window.fetch.bind(window);return mX({nativeFetch:pe,pageOrigin:window.location.origin,getShouldIntercept:()=>R.current})},[u==null?void 0:u.demoMode]),g.useEffect(()=>{(u==null?void 0:u.agentModeAvailable)===!0&&P(!1)},[u==null?void 0:u.agentModeAvailable]);const H=g.useCallback(async pe=>{const we=$.current;if(!(pe!=null&&pe.forceRefresh)&&we)return we;if(M.current)return"";M.current=!0;try{const Ie=await fetch("/api/demo/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(!Ie.ok){const it=await PX(Ie);throw new Error(it)}const qe=await Ie.json();if(!qe.sessionId)throw new Error("Demo session response missing session id.");return A(qe.sessionId),qe.sessionId}finally{M.current=!1}},[]);g.useEffect(()=>{D&&A(D)},[D]),g.useEffect(()=>{u!=null&&u.userId?(Pe.identify(u.userId,{...u.email?{email:u.email}:{}}),u.email&&Pe.alias(u.email,u.userId)):u!=null&&u.email&&Pe.identify(u.email,{email:u.email})},[u==null?void 0:u.userId,u==null?void 0:u.email]),g.useEffect(()=>{if(!u)return;const pe=!!u.demoMode,we=pe?V:null;Pe.register({source:pe?"tryout":"core",demo_mode:pe,...we?{demo_session_id:we}:{}})},[u,V]);const j=g.useCallback(async()=>{var we;y(!0),_(null);let pe=null;try{if(pe=window.open("","_blank"),!pe)throw new Error("Pop-up blocked. Please allow pop-ups and try again.");try{pe.document.open(),pe.document.write(CX),pe.document.close()}catch(it){P1.warn("Failed to render loading state in auth popup:",it)}const Ie=await fetch(`${Uk}/api/auth/google/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"desktop"})}),qe=await Ie.json();if(!Ie.ok||!qe.success||!qe.authUrl||!qe.sessionId||!qe.pollSecret)throw new Error(qe.error||qe.message||"Failed to start Google login");if(pe.closed)throw new Error("Sign-in window was closed before Google login started.");pe.location.href=qe.authUrl;for(let it=0;it<EX;it+=1){if(pe.closed)throw new Error("Sign-in window was closed before authentication completed.");const at=await(await fetch(`${Uk}/api/auth/google/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:qe.sessionId,pollSecret:qe.pollSecret})})).json();if(at.success&&at.token&&((we=at.user)!=null&&we.email)){if(!(await fetch("/api/auth/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:at.user.email,token:at.token,refreshToken:at.refreshToken,userId:at.user.id})})).ok)throw new Error("Signed in, but failed to store session locally.");if(pe.close(),window.sessionStorage.setItem(Rp,"1"),(u==null?void 0:u.demoMode)===!0){await H({forceRefresh:!0}),window.location.reload();return}window.location.reload();return}if(at.error&&at.error!=="Pending")throw new Error(at.error||"Google login failed");await new Promise(At=>setTimeout(At,SX))}throw new Error("Authentication timed out. Please try again.")}catch(Ie){pe&&!pe.closed&&pe.close();const qe=Ie instanceof Error?Ie.message:"Failed to start login flow";P1.warn("Hosted login failed:",qe),_(qe),y(!1)}},[u==null?void 0:u.demoMode,H]),Z=(u==null?void 0:u.demoMode)===!0&&((u==null?void 0:u.agentModeAvailable)!==!0||k||v),ee=u!=null&&u.agentModeAvailable!==!0,ie=bX(t),le=g.useCallback(async()=>{E(!0),p(!0);try{await c()}finally{p(!1),E(!1)}},[c,p]);if(g.useEffect(()=>{if(!Y)return;let pe=!1;return H({forceRefresh:!0}).catch(we=>{const Ie=we instanceof Error?we.message:dI;P1.warn("Hosted session bootstrap failed:",Ie),_(Ie),ht.error(Ie)}).finally(()=>{pe||N(!1)}),()=>{pe=!0}},[Y,H]),g.useEffect(()=>{const pe=()=>{const we=window.location.hash;e(we)};return window.addEventListener("hashchange",pe),()=>window.removeEventListener("hashchange",pe)},[]),ie==="design-system")return S.jsx(lX,{});const ue={pathname:window.location.pathname,configLoading:f,hasConfig:u!==null,isRetryingConfig:b};if(xX(ue)){const pe=h||"Could not load Rivet configuration.";return S.jsx("div",{className:"bg-main flex h-screen items-center justify-center px-6",children:S.jsxs("div",{className:"border-divider bg-main w-full max-w-md rounded-lg border p-6 text-center shadow-lg",children:[S.jsx("p",{className:"text-content text-sm font-medium",children:"We could not start Rivet yet."}),S.jsx("p",{className:"text-content-dim mt-2 text-xs",children:pe}),S.jsx("button",{type:"button",className:"border-divider text-content hover:bg-main/80 mt-4 rounded-md border px-3 py-1.5 text-xs",onClick:()=>{le()},children:"Retry"})]})})}if(ee)return S.jsx(fA,{isSigningIn:v,onStartSignIn:()=>{j()},errorMessage:x,displayMode:"full"});const ae=(u==null?void 0:u.agentModeAvailable)===!0&&(u==null?void 0:u.demoMode)!==!0&&i!==null,se=(u==null?void 0:u.agentModeAvailable)===!0&&(u==null?void 0:u.demoMode)!==!0&&n&&!r&&!ae;return S.jsxs(S.Fragment,{children:[S.jsx(RX,{projectPath:u==null?void 0:u.projectPath,activeDemoSessionId:K,showLoginGate:Z,onStartLogin:j,isStartingLogin:v,loginError:x,fullPageHostedLoginProgressMessage:(u==null?void 0:u.demoMode)===!0&&v?"Completing sign-in...":null,holdHostedTryoutPreviewNavigation:G,hostedTryoutPreviewHoldMessage:B,deferInspectorUntilPreviewReady:Q}),S.jsx(x_,{context:"onboarding",isOpen:se,onClose:()=>s(!0)}),S.jsx(x_,{context:"menu",isOpen:ae,highlightProvider:i,onClose:()=>{window.sessionStorage.removeItem(z_),a(null)}})]})},NX="phc_Ntj9tXHbS64XgYxlTfhglRmFivFsfm0AERph4ZlnNH",OX=new wN,LX={session_recording:{maskAllInputs:!1,maskInputOptions:{password:!0},maskTextSelector:null}},DX=()=>S.jsx("div",{style:{display:"flex",height:"100vh",alignItems:"center",justifyContent:"center"},children:S.jsx("p",{style:{fontSize:"14px",color:"#6b7280"},children:"Something went wrong. Please reload the page."})});fD.createRoot(document.getElementById("root")).render(S.jsx(ge.StrictMode,{children:S.jsx(tD,{apiKey:NX,options:{api_host:"https://rivet-proxy.onrender.com/ingest",ui_host:"https://us.posthog.com",person_profiles:"always",capture_exceptions:!0,autocapture:!0,capture_pageview:!0,capture_performance:!0,persistence:"localStorage",...LX,mask_all_text:!1,mask_all_element_attributes:!1,loaded:t=>{t.register({source:"core",rivet_version:"0.14.1",env:"production"})}},children:S.jsx(oD,{fallback:S.jsx(DX,{}),children:S.jsx(bN,{client:OX,children:S.jsx(LW,{defaultShape:"rounded",children:S.jsx(MQ,{defaultLibrary:"lucide",children:S.jsx(MX,{})})})})})})}));
422
+ </html>`,kX="Too many people are trying Rivet right now. Please try again in a few minutes.",dI="Failed to start an isolated demo session.",PX=async t=>{if(t.status===429)return kX;try{const e=await t.json();if(e.error)return e.error;if(e.message)return e.message}catch{}return dI},H_=274,Dm=395,T1=Math.min(Dm,Math.round((H_+Dm)/2*1.1)),Bk="rivet:panelWidth:v2",TX=t=>{if(!(t instanceof HTMLElement))return!1;const e=t.tagName.toLowerCase();return t.isContentEditable||e==="input"||e==="textarea"||e==="select"},RX=({projectPath:t,activeDemoSessionId:e=null,showLoginGate:n=!1,onStartLogin:r,isStartingLogin:s=!1,loginError:i=null,fullPageHostedLoginProgressMessage:a=null,holdHostedTryoutPreviewNavigation:u=!1,hostedTryoutPreviewHoldMessage:c=null,deferInspectorUntilPreviewReady:f=!1})=>{const h=Je(ZT)>0,[p,v]=nP(KT),y=HV(),[x,_]=g.useState(()=>{if(typeof window>"u")return T1;const Y=Number(window.localStorage.getItem(Bk));return Number.isFinite(Y)&&Y>=H_&&Y<=Dm?Y:T1}),[b,E]=g.useState(!1),[k,P]=g.useState(rZ),T=p?x:0,[A,O]=g.useState(p);g.useEffect(()=>{if(!p){O(!1);return}P(Y=>nZ({position:Y,boundsLeftPx:x}))},[p,x]),g.useEffect(()=>{window.localStorage.setItem(Bk,String(x))},[x]),g.useEffect(()=>{if(!p)return;const Y=G=>{G.key==="Escape"&&(TX(G.target)||(G.preventDefault(),v(!1)))};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[p,v]);const N=g.useCallback(Y=>{Y.preventDefault(),Y.stopPropagation();const G=Y.clientX,B=x;E(!0);const Q=te=>{const H=Math.min(Dm,Math.max(H_,B+(te.clientX-G)));_(H)},$=()=>{window.removeEventListener("pointermove",Q),window.removeEventListener("pointerup",$),window.removeEventListener("pointercancel",$),E(!1)};window.addEventListener("pointermove",Q),window.addEventListener("pointerup",$),window.addEventListener("pointercancel",$)},[x]),R=g.useCallback(()=>_(T1),[]),M=gZ(),L=Je(pf);_Z({enabled:!L});const D=M.isProcessing?"Completing authentication...":a,V=D!==null,K=st(e5);return g.useEffect(()=>{K(t??null)},[t,K]),g.useEffect(()=>{n&&(document.body.style.cursor="auto")},[n]),S.jsxs(sl.div,{className:"relative flex h-screen overflow-hidden",initial:!1,animate:{opacity:1},transition:{duration:.5,ease:"easeOut"},"data-cy":"rivet-app",children:[D!==null&&!n?S.jsx("div",{className:"absolute inset-0 z-50",children:S.jsx(Uq,{message:D})}):null,n?S.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center bg-black/45 backdrop-blur-[2px]",children:S.jsx(fA,{isSigningIn:s||V,onStartSignIn:()=>{r==null||r()},errorMessage:i,displayMode:"modal"})}):null,S.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col ${n?"pointer-events-none select-none":""}`,children:[S.jsx(yK,{holdHostedTryoutPreviewNavigation:u,isInteractionDisabled:n,activeDemoSessionId:e}),u&&c?S.jsx("div",{className:"bg-main absolute inset-0 z-30 flex items-center justify-center",children:S.jsx("div",{className:"border-divider bg-main-light rounded-lg border p-6 shadow-lg",children:S.jsx(mR,{message:c})})}):null]}),n?null:S.jsx(S.Fragment,{children:!f&&!h?S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"relative order-first h-full flex-shrink-0",style:{width:A?x:0},children:S.jsxs(sl.div,{className:"absolute inset-y-0 left-0 z-30",initial:!1,animate:{x:p?0:-x},transition:y?{duration:0}:{duration:.2,ease:[.22,1,.36,1]},onAnimationComplete:()=>{p&&O(!0)},style:{width:x,willChange:"transform"},children:[S.jsx(NG,{onClose:()=>v(!1)}),S.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize panel",onPointerDown:N,onDoubleClick:R,className:"group/resize absolute inset-y-0 right-0 z-20 flex w-3 cursor-col-resize touch-none justify-end",children:S.jsx("span",{className:`h-full transition-all duration-150 ${b?"w-0.5 bg-content-muted":"w-px bg-divider group-hover/resize:w-0.5 group-hover/resize:bg-content-muted"}`})})]})}),b&&S.jsx("div",{className:"fixed inset-0 z-[100] cursor-col-resize"}),S.jsx(oZ,{isVisible:!0,isPanelOpen:p,isReducedMotion:!!y,position:k,dragBoundsLeftPx:T,onPositionChange:P,onToggle:()=>v(Y=>!Y)})]}):null}),S.jsx(m$,{duration:5e3,richColors:!0,toastOptions:{style:{maxHeight:"150px",overflow:"hidden"}}})]})},z_="rivet_connect_deep_link",AX=()=>{if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search),e=t.get("connect"),n=e??window.sessionStorage.getItem(z_);if(n!=="pinterest"&&n!=="arena")return null;if(window.sessionStorage.setItem(z_,n),e){t.delete("connect");const r=t.toString();window.history.replaceState(null,document.title,window.location.pathname+(r?`?${r}`:"")+window.location.hash)}return n},IX=AX(),MX=()=>{const[t,e]=g.useState(window.location.hash),[n]=g.useState(()=>typeof window<"u"&&window.sessionStorage.getItem(Rp)==="1"),[r,s]=g.useState(!1),[i,a]=g.useState(IX);g.useEffect(()=>{n&&window.sessionStorage.removeItem(Rp)},[n]);const{config:u,refetchConfig:c,loading:f,error:h}=pZ(),p=st(pf),[v,y]=g.useState(!1),[x,_]=g.useState(null),[b,E]=g.useState(!1),[k,P]=g.useState(!1),[T,A]=g.useState(null),[O,N]=g.useState(!1),R=g.useRef(!1),M=g.useRef(!1),L=wX(window.location.pathname),D=(u==null?void 0:u.activeDemoSessionId)??null,V=L??T??D,K=g.useMemo(()=>vX(u==null?void 0:u.demoMode,u==null?void 0:u.agentModeAvailable,V),[u==null?void 0:u.demoMode,u==null?void 0:u.agentModeAvailable,V]),Y=g.useMemo(()=>gX({configLoading:f,hasConfig:u!==null,demoMode:u==null?void 0:u.demoMode,agentModeAvailable:u==null?void 0:u.agentModeAvailable,pathnameDemoSessionId:L,activeDemoSessionId:T,configuredDemoSessionId:D}),[u,f,L,T,D]);g.useLayoutEffect(()=>{if(!Y){N(!1);return}N(!0)},[Y]);const G=O,B=g.useMemo(()=>yX(G),[G]),Q=(u==null?void 0:u.demoMode)===!0&&G,$=g.useRef(null);$.current=V;const te=g.useCallback(async()=>{if(!R.current)return;A(null);const pe=await c();if((pe==null?void 0:pe.demoMode)===!0&&pe.agentModeAvailable!==!0){P(!1);return}(pe==null?void 0:pe.demoMode)===!0&&P(!0)},[c]);g.useEffect(()=>{if((u==null?void 0:u.demoMode)===!0)return fX(()=>{te()})},[u==null?void 0:u.demoMode,te]),g.useEffect(()=>{if(R.current=(u==null?void 0:u.demoMode)===!0,(u==null?void 0:u.demoMode)!==!0)return;const pe=window.fetch.bind(window);return mX({nativeFetch:pe,pageOrigin:window.location.origin,getShouldIntercept:()=>R.current})},[u==null?void 0:u.demoMode]),g.useEffect(()=>{(u==null?void 0:u.agentModeAvailable)===!0&&P(!1)},[u==null?void 0:u.agentModeAvailable]);const H=g.useCallback(async pe=>{const we=$.current;if(!(pe!=null&&pe.forceRefresh)&&we)return we;if(M.current)return"";M.current=!0;try{const Ie=await fetch("/api/demo/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(!Ie.ok){const it=await PX(Ie);throw new Error(it)}const qe=await Ie.json();if(!qe.sessionId)throw new Error("Demo session response missing session id.");return A(qe.sessionId),qe.sessionId}finally{M.current=!1}},[]);g.useEffect(()=>{D&&A(D)},[D]),g.useEffect(()=>{u!=null&&u.userId?(Pe.identify(u.userId,{...u.email?{email:u.email}:{}}),u.email&&Pe.alias(u.email,u.userId)):u!=null&&u.email&&Pe.identify(u.email,{email:u.email})},[u==null?void 0:u.userId,u==null?void 0:u.email]),g.useEffect(()=>{if(!u)return;const pe=!!u.demoMode,we=pe?V:null;Pe.register({source:pe?"tryout":"core",demo_mode:pe,...we?{demo_session_id:we}:{}})},[u,V]);const j=g.useCallback(async()=>{var we;y(!0),_(null);let pe=null;try{if(pe=window.open("","_blank"),!pe)throw new Error("Pop-up blocked. Please allow pop-ups and try again.");try{pe.document.open(),pe.document.write(CX),pe.document.close()}catch(it){P1.warn("Failed to render loading state in auth popup:",it)}const Ie=await fetch(`${Uk}/api/auth/google/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"desktop"})}),qe=await Ie.json();if(!Ie.ok||!qe.success||!qe.authUrl||!qe.sessionId||!qe.pollSecret)throw new Error(qe.error||qe.message||"Failed to start Google login");if(pe.closed)throw new Error("Sign-in window was closed before Google login started.");pe.location.href=qe.authUrl;for(let it=0;it<EX;it+=1){if(pe.closed)throw new Error("Sign-in window was closed before authentication completed.");const at=await(await fetch(`${Uk}/api/auth/google/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:qe.sessionId,pollSecret:qe.pollSecret})})).json();if(at.success&&at.token&&((we=at.user)!=null&&we.email)){if(!(await fetch("/api/auth/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:at.user.email,token:at.token,refreshToken:at.refreshToken,userId:at.user.id})})).ok)throw new Error("Signed in, but failed to store session locally.");if(pe.close(),window.sessionStorage.setItem(Rp,"1"),(u==null?void 0:u.demoMode)===!0){await H({forceRefresh:!0}),window.location.reload();return}window.location.reload();return}if(at.error&&at.error!=="Pending")throw new Error(at.error||"Google login failed");await new Promise(At=>setTimeout(At,SX))}throw new Error("Authentication timed out. Please try again.")}catch(Ie){pe&&!pe.closed&&pe.close();const qe=Ie instanceof Error?Ie.message:"Failed to start login flow";P1.warn("Hosted login failed:",qe),_(qe),y(!1)}},[u==null?void 0:u.demoMode,H]),Z=(u==null?void 0:u.demoMode)===!0&&((u==null?void 0:u.agentModeAvailable)!==!0||k||v),ee=u!=null&&u.agentModeAvailable!==!0,ie=bX(t),le=g.useCallback(async()=>{E(!0),p(!0);try{await c()}finally{p(!1),E(!1)}},[c,p]);if(g.useEffect(()=>{if(!Y)return;let pe=!1;return H({forceRefresh:!0}).catch(we=>{const Ie=we instanceof Error?we.message:dI;P1.warn("Hosted session bootstrap failed:",Ie),_(Ie),ht.error(Ie)}).finally(()=>{pe||N(!1)}),()=>{pe=!0}},[Y,H]),g.useEffect(()=>{const pe=()=>{const we=window.location.hash;e(we)};return window.addEventListener("hashchange",pe),()=>window.removeEventListener("hashchange",pe)},[]),ie==="design-system")return S.jsx(lX,{});const ue={pathname:window.location.pathname,configLoading:f,hasConfig:u!==null,isRetryingConfig:b};if(xX(ue)){const pe=h||"Could not load Rivet configuration.";return S.jsx("div",{className:"bg-main flex h-screen items-center justify-center px-6",children:S.jsxs("div",{className:"border-divider bg-main w-full max-w-md rounded-lg border p-6 text-center shadow-lg",children:[S.jsx("p",{className:"text-content text-sm font-medium",children:"We could not start Rivet yet."}),S.jsx("p",{className:"text-content-dim mt-2 text-xs",children:pe}),S.jsx("button",{type:"button",className:"border-divider text-content hover:bg-main/80 mt-4 rounded-md border px-3 py-1.5 text-xs",onClick:()=>{le()},children:"Retry"})]})})}if(ee)return S.jsx(fA,{isSigningIn:v,onStartSignIn:()=>{j()},errorMessage:x,displayMode:"full"});const ae=(u==null?void 0:u.agentModeAvailable)===!0&&(u==null?void 0:u.demoMode)!==!0&&i!==null,se=(u==null?void 0:u.agentModeAvailable)===!0&&(u==null?void 0:u.demoMode)!==!0&&n&&!r&&!ae;return S.jsxs(S.Fragment,{children:[S.jsx(RX,{projectPath:u==null?void 0:u.projectPath,activeDemoSessionId:K,showLoginGate:Z,onStartLogin:j,isStartingLogin:v,loginError:x,fullPageHostedLoginProgressMessage:(u==null?void 0:u.demoMode)===!0&&v?"Completing sign-in...":null,holdHostedTryoutPreviewNavigation:G,hostedTryoutPreviewHoldMessage:B,deferInspectorUntilPreviewReady:Q}),S.jsx(x_,{context:"onboarding",isOpen:se,onClose:()=>s(!0)}),S.jsx(x_,{context:"menu",isOpen:ae,highlightProvider:i,onClose:()=>{window.sessionStorage.removeItem(z_),a(null)}})]})},NX="phc_Ntj9tXHbS64XgYxlTfhglRmFivFsfm0AERph4ZlnNH",OX=new wN,LX={session_recording:{maskAllInputs:!1,maskInputOptions:{password:!0},maskTextSelector:null}},DX=()=>S.jsx("div",{style:{display:"flex",height:"100vh",alignItems:"center",justifyContent:"center"},children:S.jsx("p",{style:{fontSize:"14px",color:"#6b7280"},children:"Something went wrong. Please reload the page."})});fD.createRoot(document.getElementById("root")).render(S.jsx(ge.StrictMode,{children:S.jsx(tD,{apiKey:NX,options:{api_host:"https://rivet-proxy.onrender.com/ingest",ui_host:"https://us.posthog.com",person_profiles:"always",capture_exceptions:!0,autocapture:!0,capture_pageview:!0,capture_performance:!0,persistence:"localStorage",...LX,mask_all_text:!1,mask_all_element_attributes:!1,loaded:t=>{t.register({source:"core",rivet_version:"0.14.2",env:"production"})}},children:S.jsx(oD,{fallback:S.jsx(DX,{}),children:S.jsx(bN,{client:OX,children:S.jsx(LW,{defaultShape:"rounded",children:S.jsx(MQ,{defaultLibrary:"lucide",children:S.jsx(MX,{})})})})})})}));
@@ -7,7 +7,7 @@
7
7
  <link rel="icon" type="image/x-icon" href="/favicon.ico" />
8
8
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
9
9
  <title>Rivet - The visual editor for design</title>
10
- <script type="module" crossorigin src="/assets/main-C-8Mff7k.js"></script>
10
+ <script type="module" crossorigin src="/assets/main-2XsJBBhV.js"></script>
11
11
  <link rel="stylesheet" crossorigin href="/assets/main-CobdEReL.css">
12
12
  </head>
13
13
  <body>