"use client";
import type { AiConnectGuideCopy, AiFlowCopy } from "./copy";
import CheckIcon from "@mui/icons-material/Check";
import ContentCopyOutlinedIcon from "@mui/icons-material/ContentCopyOutlined";
import OpenInNewIcon from "@mui/icons-material/OpenInNew";
import { useState } from "react";
import { Button } from "@12-apps/ui/form/Button";
import { Box } from "@12-apps/ui/mui/Box";
import { Stack } from "@12-apps/ui/mui/Stack";
import { Text } from "@12-apps/ui/typography/Text";
import type { AiHostGuide } from "../guide";
import { HostBrandAvatar } from "./ai-icons";
import { McpEndpointUrl } from "./mcp-endpoint-url";
/**
* The store's MCP endpoint URL with a blue "Copiar" button (the display-only
* field defers the copy to this button). Controlled: `copied` flips the label to
* "Copiado" and `onCopy` fires after the clipboard write — the wizard uses it to
* unlock the "Próximo" button on the Copiar-URL step.
*/
export function EndpointCopyBlock({
endpointUrl,
copied,
onCopy,
flowCopy,
copy,
}: {
endpointUrl: string;
copied: boolean;
onCopy: () => void;
flowCopy: AiFlowCopy;
copy: AiConnectGuideCopy;
}): React.JSX.Element {
const handleClick = (): void => {
if (typeof navigator !== "undefined" && navigator.clipboard) {
void navigator.clipboard.writeText(endpointUrl).catch(() => undefined);
}
onCopy();
};
return (
{copy.urlLabel}
{copy.urlHint}
);
}
/**
* A copyable multi-line message block (preserves line breaks). Used on the
* Conectar step for the prompt the owner pastes into the assistant so it
* identifies itself and calls a tool (which registers the connection).
*/
export function PromptCopyBlock({
title,
caption,
message,
flowCopy,
}: {
title: string;
caption: string;
message: string;
flowCopy: AiFlowCopy;
}): React.JSX.Element {
const [copied, setCopied] = useState(false);
const handleClick = (): void => {
if (typeof navigator !== "undefined" && navigator.clipboard) {
void navigator.clipboard.writeText(message).catch(() => undefined);
}
setCopied(true);
};
return (
{title}
{caption}
{message}
);
}
/** The brand mark + "Conectar no " header shared by the connect sub-steps. */
export function HostConnectHeader({
host,
copy,
}: {
host: AiHostGuide;
copy: AiConnectGuideCopy;
}): React.JSX.Element {
return (
{copy.connectOn(host.label)}
);
}
/**
* The primary direct-link button to a host's connector settings (nothing when it
* has none). `onOpen` fires after the link opens so the Configurar step can
* unlock its "Próximo" only once the owner has actually gone to the connectors.
*/
export function HostOpenButton({
host,
onOpen,
}: {
host: AiHostGuide;
onOpen?: () => void;
}): React.JSX.Element | null {
if (!host.link) return null;
return (
);
}
/** A "Para mais informações" reference to the host's official connector docs. */
export function HostDocsLink({ host,
copy,
}: { host: AiHostGuide;
copy: AiConnectGuideCopy;}): React.JSX.Element | null {
if (!host.docs) return null;
return (
{copy.moreInfo}{" "}
{host.docs.label}
.
);
}
/**
* A numbered slice of a host's connect steps. `start` keeps the numbering
* continuous when the steps are split across wizard stages (e.g. the Conectar
* stage continues at 4 after Configurar showed 1–3).
*/
export function HostStepList({
steps,
start = 1,
}: {
steps: readonly string[];
start?: number;
}): React.JSX.Element {
return (
{steps.map((step, index) => (
{step}
))}
);
}