"use client"; import { PrototypeToolDialog } from "@prototype/components/platform-ui/prototype-tool-dialog"; import { PrototypeBriefTextarea } from "@prototype/components/prototypes/prototype-brief-field"; import { Button } from "@prototype/components/ui/button"; import { Switch } from "@prototype/components/ui/switch"; import { buildCreateDesignExplorationCopyText } from "@prototype/lib/prototypes/design-exploration-types"; import { useTrackEvent } from "@prototype/lib/prototypes/telemetry/prototype-telemetry-context"; import useCopyToClipboard from "@prototype/lib/use-copy-to-clipboard"; import { useEffect, useState } from "react"; export type PrototypeCreateExplorationModalProps = { open: boolean; onOpenChange: (open: boolean) => void; slug: string; existingExplorations: Array<{ id: string; label: string }>; }; export function PrototypeCreateExplorationModal({ open, onOpenChange, slug, existingExplorations, }: PrototypeCreateExplorationModalProps) { const [brief, setBrief] = useState(""); const [includeMobbin, setIncludeMobbin] = useState(true); const { copy, icon, isCopied } = useCopyToClipboard(); const track = useTrackEvent(); const canCopy = brief.trim().length > 0; useEffect(() => { if (!open) { setBrief(""); } }, [open]); useEffect(() => { if (open) { track("modal.opened", { modal: "create-exploration" }, { slug }); } }, [open, track, slug]); const handleCopy = () => { if (!canCopy) return; const origin = typeof window !== "undefined" ? window.location.origin : undefined; const previewUrl = typeof window !== "undefined" ? `${window.location.origin}${window.location.pathname}${window.location.search}` : undefined; copy( buildCreateDesignExplorationCopyText({ slug, existingExplorations, origin, previewUrl, briefText: brief, includeMobbin, }), ); track( "modal.prompt_copied", { modal: "create-exploration", includeMobbin, existingExplorationsCount: existingExplorations.length, }, { slug }, ); }; return ( } > setBrief(event.target.value)} placeholder="e.g. Give me a settings page with a profile picture, name, plan, and bio" aria-label="Exploration brief" /> ); }