'use client' import { useEffect, useState } from 'react' import { Button, ChipInput, Tooltip } from '@sim/emcn' import { Check, Clipboard, Eye, EyeOff, RefreshCw } from 'lucide-react' import { generatePassword } from '@/lib/core/security/encryption' interface GeneratedPasswordInputProps { value: string onChange: (value: string) => void disabled?: boolean placeholder?: string /** Show the Generate (random password) action. Off for consumer-facing entry forms. */ showGenerate?: boolean required?: boolean autoComplete?: string error?: boolean } /** * Password field with reveal / copy / (optional) generate adornments, used by the * deploy-as-chat access controls and the file-share modal. Owns its show/copy UI * state; the caller owns the value. */ export function GeneratedPasswordInput({ value, onChange, disabled = false, placeholder, showGenerate = true, required = false, autoComplete = 'new-password', error = false, }: GeneratedPasswordInputProps) { const [showPassword, setShowPassword] = useState(false) const [copySuccess, setCopySuccess] = useState(false) useEffect(() => { if (!copySuccess) return const timer = setTimeout(() => setCopySuccess(false), 2000) return () => clearTimeout(timer) }, [copySuccess]) const copyToClipboard = () => { navigator.clipboard.writeText(value) setCopySuccess(true) } return ( onChange(e.target.value)} disabled={disabled} required={required} autoComplete={autoComplete} error={error} endAdornment={
{showGenerate ? ( Generate ) : null} {copySuccess ? 'Copied' : 'Copy'} {showPassword ? 'Hide' : 'Show'}
} /> ) }