import type { EnvVarInput } from "@stigmer/sdk";
import { OAuthConnectionHealth } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/io_pb";
import type { McpServer } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/api_pb";
import type { DiscoveredTool } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/status_pb";
import type { ToolApprovalPolicy } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/spec_pb";
import { type EnvVarFormVariable, type EnvVarFormSubmitOptions } from "../environment/EnvVarForm";
import type { OAuthConnectPhase } from "./useMcpServerOAuthConnect";
/**
 * Props for the inline credentials form shown when a server requires
 * environment variables that are missing from the user's personal
 * environment.
 *
 * This is modeled as a sub-object of {@link McpServerConfigPanelProps}
 * so the presence of `credentials` controls whether the form is
 * rendered — no status string inspection required.
 */
export interface McpServerCredentialsProps {
    /** Missing env vars to collect (one form field per variable). */
    readonly variables: EnvVarFormVariable[];
    /** Called when the user submits credentials via the form. */
    readonly onSubmit: (values: Record<string, EnvVarInput>, options: EnvVarFormSubmitOptions) => void;
    /** When true, form inputs are disabled and the submit button shows a spinner. */
    readonly isSubmitting?: boolean;
    /**
     * Initial state of the "Save for future runs" toggle.
     * @default true
     */
    readonly defaultSaveForFuture?: boolean;
    /**
     * When `true`, the save toggle is hidden and the form always uses
     * `defaultSaveForFuture` as the submit value.
     * @default false
     */
    readonly hideSaveToggle?: boolean;
    /**
     * Lookup function for pre-filling fields from the session env pool.
     * When provided, fields whose keys return a value are pre-populated.
     */
    readonly poolValues?: (key: string) => EnvVarInput | undefined;
}
/**
 * Props for the inline OAuth sign-in action shown when a server requires
 * OAuth authentication. Presence controls rendering — when `oauthSignIn`
 * is provided on {@link McpServerConfigPanelProps}, the OAuth button
 * is rendered above the credentials form.
 */
export interface McpServerOAuthSignInProps {
    /** Initiates the OAuth popup flow. Must be called from a click handler. */
    readonly onSignIn: () => void;
    /** Current phase of the OAuth flow. */
    readonly phase: OAuthConnectPhase;
    /** `true` when the OAuth token already exists in the personal environment. */
    readonly isConnected: boolean;
    /**
     * Health of the OAuth connection. Drives the status dot color and
     * label beyond the binary `isConnected` boolean.
     */
    readonly connectionHealth?: OAuthConnectionHealth;
    /**
     * Called to disconnect the OAuth grant. When provided and the user
     * is connected, a "Disconnect" link is shown. The parent is responsible
     * for refreshing credentials after the promise resolves.
     */
    readonly onDisconnect?: () => Promise<void>;
    /** `true` while a disconnect operation is in flight. */
    readonly isDisconnecting?: boolean;
    /** Error from the most recent failed disconnect, or `null`. */
    readonly disconnectError?: Error | null;
    /** Clear the disconnect error state. */
    readonly onClearDisconnectError?: () => void;
    /** Error from the most recent failed OAuth attempt, or `null`. */
    readonly error: Error | null;
    /** Clear the OAuth error state. */
    readonly onClearError: () => void;
    /**
     * `true` when the platform's OAuth app is pending vendor approval.
     * Disables the sign-in button and shows an informational message.
     */
    readonly isVendorApprovalPending?: boolean;
    /**
     * `true` when the platform OAuth app's vendor approval is PENDING
     * or REJECTED — the platform sign-in flow is blocked. Covers both
     * statuses. When omitted, falls back to `isVendorApprovalPending`.
     */
    readonly isVendorApprovalBlocked?: boolean;
    /**
     * Documentation URL for bringing your own OAuth token.
     * Shown as a help link when `isVendorApprovalPending` is `true`.
     */
    readonly vendorApprovalDocsUrl?: string | null;
    /**
     * `true` when the BYOA (Bring Your Own App) option is relevant:
     * the server uses vendor OAuth and no org override exists.
     */
    readonly canBringOwnApp?: boolean;
    /**
     * `true` when an org-level BYOA override is active.
     */
    readonly isOrgOAuthApp?: boolean;
    /**
     * Open the BYOA form. The parent is responsible for rendering the
     * form/dialog and handling the mutation.
     */
    readonly onBringOwnApp?: () => void;
    /**
     * Remove the org's BYOA override. The parent is responsible for
     * refreshing state after the promise resolves.
     */
    readonly onRemoveOrgApp?: () => Promise<void>;
    /** `true` while a remove-org-app operation is in flight. */
    readonly isRemovingOrgApp?: boolean;
}
/** Props for {@link McpServerConfigPanel}. */
export interface McpServerConfigPanelProps {
    /** The MCP server resource — used for header display (name, icon, description). */
    readonly mcpServer: McpServer;
    /**
     * When provided, the credentials form is shown above the tool selector.
     * Omit when no credentials are needed or they have already been provided.
     *
     * While credentials are pending, the tool selector is rendered in a
     * disabled state so the user completes step 1 (credentials) before
     * step 2 (tool customization).
     */
    readonly credentials?: McpServerCredentialsProps;
    /**
     * When provided, an inline OAuth sign-in button is rendered above the
     * credentials form. The button initiates the popup-based OAuth flow.
     *
     * Use alongside `credentials` for mixed-mode servers that require
     * both OAuth and manual env vars, or on its own for OAuth-only servers.
     */
    readonly oauthSignIn?: McpServerOAuthSignInProps;
    /** Discovered tools from `status.discovered_capabilities.tools`. */
    readonly discoveredTools: DiscoveredTool[];
    /** Approval policies from `status.tool_approvals` and `spec.pinned_tool_approvals`. */
    readonly toolApprovals: ToolApprovalPolicy[];
    /** Currently enabled tool names (controlled). */
    readonly enabledTools: string[];
    /** Called when tool selection changes. */
    readonly onEnabledToolsChange: (enabledTools: string[]) => void;
    /** Called when the user clicks "Back" to return to the picker list. */
    readonly onBack: () => void;
    /**
     * When provided, a "Enter token manually" link is shown below the
     * OAuth sign-in section. Clicking it switches the panel to manual
     * token entry mode — the caller is responsible for updating the
     * `credentials` and `oauthSignIn` props accordingly.
     */
    readonly onSwitchToManual?: () => void;
    /**
     * When provided, a "Sign in with OAuth instead" link is shown near
     * the credentials form. Clicking it reverts to the OAuth flow.
     */
    readonly onSwitchToOAuth?: () => void;
    /** Error to display inline (e.g., from credential submission failure). */
    readonly error?: Error | null;
    /** Disables all interaction. */
    readonly disabled?: boolean;
    /** Additional CSS class names for the root container. */
    readonly className?: string;
}
/**
 * Per-server configuration panel composing a credentials form
 * ({@link EnvVarForm}) and a tool selector ({@link McpToolSelector}).
 *
 * Designed to render inside the same popover container as
 * {@link McpServerPicker}: the picker list transitions to this panel
 * when the user drills into a specific server's configuration.
 *
 * The panel's content is driven by the `credentials` prop:
 * - **Present** (server needs setup) — the credentials form is shown
 *   above the tool selector. The tool selector renders disabled as a
 *   preview of what tools the server provides.
 * - **Absent** (server is ready) — only the tool selector is shown,
 *   fully interactive for customizing which tools to enable.
 *
 * This is a **pure presentational component** with no knowledge of
 * the setup hook, personal environments, or session creation. All
 * state is controlled via props — platform builders can use it with
 * any state management approach.
 *
 * All visual properties flow through `--stgm-*` design tokens.
 *
 * @example
 * ```tsx
 * // Server that needs credentials:
 * <McpServerConfigPanel
 *   mcpServer={server}
 *   credentials={{
 *     variables: missingVars,
 *     onSubmit: (values, opts) => submitEnvVars(ref, values, opts),
 *   }}
 *   discoveredTools={tools}
 *   toolApprovals={approvals}
 *   enabledTools={defaultEnabledTools}
 *   onEnabledToolsChange={(t) => setEnabledTools(ref, t)}
 *   onBack={() => setView("list")}
 * />
 *
 * // Server that is ready (tool customization only):
 * <McpServerConfigPanel
 *   mcpServer={server}
 *   discoveredTools={tools}
 *   toolApprovals={approvals}
 *   enabledTools={entry.enabledTools}
 *   onEnabledToolsChange={(t) => setEnabledTools(ref, t)}
 *   onBack={() => setView("list")}
 * />
 * ```
 */
export declare function McpServerConfigPanel({ mcpServer, credentials, oauthSignIn, discoveredTools, toolApprovals, enabledTools, onEnabledToolsChange, onBack, onSwitchToManual, onSwitchToOAuth, error, disabled, className, }: McpServerConfigPanelProps): import("react/jsx-runtime").JSX.Element;
//# sourceMappingURL=McpServerConfigPanel.d.ts.map