/**
 * AddQuestionDialog — Agent creates a new task/question mid-conversation.
 */
'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useState, useCallback } from 'react';
import { cn } from './shared.js';
export function AddQuestionDialog({ open, on_close, on_add, agent_id }) {
    const [title, set_title] = useState('');
    const [description, set_description] = useState('');
    const [due_date, set_due_date] = useState('');
    const handle_submit = useCallback(() => {
        if (!title.trim())
            return;
        const task = {
            task_id: `task_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`,
            title: title.trim(),
            description: description.trim(),
            status: 'pending',
            sort_order: Date.now(),
            created_at: new Date().toISOString(),
            created_by: agent_id,
            due_date: due_date || undefined,
            thread: [],
        };
        on_add(task);
        set_title('');
        set_description('');
        set_due_date('');
        on_close();
    }, [title, description, due_date, agent_id, on_add, on_close]);
    if (!open)
        return null;
    return (_jsxs("div", { className: "fixed inset-0 z-50 flex items-center justify-center", children: [_jsx("div", { className: "absolute inset-0 bg-black/30", onClick: on_close }), _jsxs("div", { className: "relative bg-white rounded-lg shadow-xl w-full max-w-md mx-4", children: [_jsxs("div", { className: "px-5 py-4 border-b border-[#E2E8F0]", children: [_jsx("h3", { className: "text-[15px] font-semibold text-[#0F172A]", children: "Add Question" }), _jsx("p", { className: "text-[12px] text-[#94A3B8] mt-0.5", children: "Create a new request for the client" })] }), _jsxs("div", { className: "px-5 py-4 space-y-4", children: [_jsxs("div", { children: [_jsx("label", { className: "block text-[12px] font-medium text-[#334155] mb-1", children: "Title *" }), _jsx("input", { value: title, onChange: (e) => set_title(e.target.value), className: "w-full border border-[#E2E8F0] rounded-md px-3 py-2 text-[13px] focus:outline-none focus:ring-1 focus:ring-[#2563EB] focus:border-[#2563EB] placeholder:text-[#CBD5E1]", placeholder: "e.g., Upload spouse income details", autoFocus: true })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-[12px] font-medium text-[#334155] mb-1", children: "Description" }), _jsx("textarea", { value: description, onChange: (e) => set_description(e.target.value), className: "w-full border border-[#E2E8F0] rounded-md px-3 py-2 text-[13px] resize-none focus:outline-none focus:ring-1 focus:ring-[#2563EB] focus:border-[#2563EB] placeholder:text-[#CBD5E1]", rows: 3, placeholder: "Detailed instructions for the client..." })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-[12px] font-medium text-[#334155] mb-1", children: "Due date (optional)" }), _jsx("input", { type: "date", value: due_date, onChange: (e) => set_due_date(e.target.value), className: "w-full border border-[#E2E8F0] rounded-md px-3 py-2 text-[13px] focus:outline-none focus:ring-1 focus:ring-[#2563EB] focus:border-[#2563EB] text-[#334155]" })] })] }), _jsxs("div", { className: "px-5 py-3 border-t border-[#E2E8F0] flex justify-end gap-2", children: [_jsx("button", { onClick: on_close, className: "text-[13px] text-[#64748B] px-4 py-1.5 rounded hover:bg-[#F1F5F9] cursor-pointer", children: "Cancel" }), _jsx("button", { onClick: handle_submit, disabled: !title.trim(), className: cn('text-[13px] font-medium px-4 py-1.5 rounded cursor-pointer', title.trim() ? 'bg-[#2563EB] text-white hover:bg-[#1D4ED8]' : 'bg-[#E2E8F0] text-[#94A3B8] cursor-not-allowed'), children: "Add to Form" })] })] })] }));
}
//# sourceMappingURL=add_question_dialog.js.map