import { c as _c } from "react/compiler-runtime"; import React, { useCallback, useEffect, useState } from 'react'; import { type OptionWithDescription, Select } from '../../components/CustomSelect/index.js'; import { Pane } from '../../components/design-system/Pane.js'; import { Spinner } from '../../components/Spinner.js'; import { useExitOnCtrlCDWithKeybindings } from '../../hooks/useExitOnCtrlCDWithKeybindings.js'; // eslint-disable-next-line custom-rules/prefer-use-keybindings -- enter to proceed through setup steps import { Box, Text, useInput } from '../../ink.js'; import { useKeybinding } from '../../keybindings/useKeybinding.js'; import { detectPythonPackageManager, getPythonApiInstructions, installIt2, markIt2SetupComplete, type PythonPackageManager, setPreferTmuxOverIterm2, verifyIt2Setup } from './backends/it2Setup.js'; type SetupStep = 'initial' | 'installing' | 'install-failed' | 'verify-api' | 'api-instructions' | 'verifying' | 'success' | 'failed'; type Props = { onDone: (result: 'installed' | 'use-tmux' | 'cancelled') => void; tmuxAvailable: boolean; }; export function It2SetupPrompt(t0) { const $ = _c(44); const { onDone, tmuxAvailable } = t0; const [step, setStep] = useState("initial"); const [packageManager, setPackageManager] = useState(null); const [error, setError] = useState(null); const exitState = useExitOnCtrlCDWithKeybindings(); let t1; let t2; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t1 = () => { detectPythonPackageManager().then(pm => { setPackageManager(pm); }); }; t2 = []; $[0] = t1; $[1] = t2; } else { t1 = $[0]; t2 = $[1]; } useEffect(t1, t2); let t3; if ($[2] !== onDone) { t3 = () => { onDone("cancelled"); }; $[2] = onDone; $[3] = t3; } else { t3 = $[3]; } const handleCancel = t3; const t4 = step !== "installing" && step !== "verifying"; let t5; if ($[4] !== t4) { t5 = { context: "Confirmation", isActive: t4 }; $[4] = t4; $[5] = t5; } else { t5 = $[5]; } useKeybinding("confirm:no", handleCancel, t5); let t6; if ($[6] !== onDone || $[7] !== step) { t6 = (_input, key) => { if (step === "api-instructions" && key.return) { setStep("verifying"); verifyIt2Setup().then(result => { if (result.success) { markIt2SetupComplete(); setStep("success"); setTimeout(onDone, 1500, "installed" as const); } else { setError(result.error || "Verification failed"); setStep("failed"); } }); } }; $[6] = onDone; $[7] = step; $[8] = t6; } else { t6 = $[8]; } useInput(t6); let t7; if ($[9] !== packageManager) { t7 = async function handleInstall() { if (!packageManager) { setError("No Python package manager found (uvx, pipx, or pip)"); setStep("failed"); return; } setStep("installing"); const result_0 = await installIt2(packageManager); if (result_0.success) { setStep("api-instructions"); } else { setError(result_0.error || "Installation failed"); setStep("install-failed"); } }; $[9] = packageManager; $[10] = t7; } else { t7 = $[10]; } const handleInstall = t7; let t8; if ($[11] !== onDone) { t8 = function handleUseTmux() { setPreferTmuxOverIterm2(true); onDone("use-tmux"); }; $[11] = onDone; $[12] = t8; } else { t8 = $[12]; } const handleUseTmux = t8; let T0; let T1; let t10; let t11; let t12; let t13; let t14; let t9; if ($[13] !== error || $[14] !== handleInstall || $[15] !== handleUseTmux || $[16] !== onDone || $[17] !== packageManager || $[18] !== step || $[19] !== tmuxAvailable) { const renderContent = () => { switch (step) { case "initial": { return renderInitialPrompt(); } case "installing": { return renderInstalling(); } case "install-failed": { return renderInstallFailed(); } case "api-instructions": { return renderApiInstructions(); } case "verifying": { return renderVerifying(); } case "success": { return renderSuccess(); } case "failed": { return renderFailed(); } default: { return null; } } }; function renderInitialPrompt() { const options = [{ label: "Install it2 now", value: "install", description: packageManager ? `Uses ${packageManager} to install the it2 CLI tool` : "Requires Python (uvx, pipx, or pip)" }]; if (tmuxAvailable) { options.push({ label: "Use tmux instead", value: "tmux", description: "Opens teammates in a separate tmux session" }); } options.push({ label: "Cancel", value: "cancel", description: "Skip teammate spawning for now" }); return To use native iTerm2 split panes for teammates, you need the{" "}it2 CLI tool.This enables teammates to appear as split panes within your current window. { bb89: switch (value_0) { case "retry": { handleInstall(); break bb89; } case "tmux": { handleUseTmux(); break bb89; } case "cancel": { onDone("cancelled"); } } }} onCancel={() => onDone("cancelled")} />; } function renderApiInstructions() { const instructions = getPythonApiInstructions(); return ✓ it2 installed successfully{instructions.map(_temp)}Press Enter when ready to verify…; } function renderVerifying() { return Verifying it2 can communicate with iTerm2…; } function renderSuccess() { return ✓ iTerm2 split pane support is readyTeammates will now appear as split panes.; } function renderFailed() { const options_1 = [{ label: "Try again", value: "retry", description: "Verify the connection again" }]; if (tmuxAvailable) { options_1.push({ label: "Use tmux instead", value: "tmux", description: "Falls back to tmux for teammate panes" }); } options_1.push({ label: "Cancel", value: "cancel", description: "Skip teammate spawning for now" }); return Verification failed{error && {error}}Make sure:· Python API is enabled in iTerm2 preferences· You may need to restart iTerm2 after enabling