"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReportModal = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const api_1 = require("@atproto/api");
const lucide_react_native_1 = require("lucide-react-native");
const react_1 = require("react");
const react_native_1 = require("react-native");
const __1 = require("../../..");
const livestream_store_1 = require("../../../livestream-store");
const ui_1 = require("../../ui");
// AT Protocol moderation reason types with proper labels
const REPORT_REASONS = [
    {
        value: api_1.ComAtprotoModerationDefs.REASONSPAM,
        label: "Spam",
        description: "Excessive unwanted promotion, replies, mentions",
    },
    {
        value: api_1.ComAtprotoModerationDefs.REASONVIOLATION,
        label: "Rule Violation",
        description: "Direct, blatant violation of laws or terms of service",
    },
    {
        value: api_1.ComAtprotoModerationDefs.REASONMISLEADING,
        label: "Misleading Content",
        description: "Misleading identity, affiliation, or content",
    },
    {
        value: api_1.ComAtprotoModerationDefs.REASONSEXUAL,
        label: "Sexual Content",
        description: "Unwanted or mislabeled sexual content",
    },
    {
        value: api_1.ComAtprotoModerationDefs.REASONRUDE,
        label: "Harassment",
        description: "Rude, harassing, explicit, or otherwise unwelcoming behavior",
    },
    {
        value: api_1.ComAtprotoModerationDefs.REASONOTHER,
        label: "Other",
        description: "Reports not falling under another report category",
    },
];
const ReportModal = ({ open, onOpenChange, onSubmit, subject, title = "Report", description = "Why are you submitting this report?", }) => {
    const [selectedReason, setSelectedReason] = (0, react_1.useState)(null);
    const [additionalComments, setAdditionalComments] = (0, react_1.useState)("");
    const [isSubmitting, setIsSubmitting] = (0, react_1.useState)(false);
    const [submitError, setSubmitError] = (0, react_1.useState)(null);
    const { theme } = (0, ui_1.useTheme)();
    const submitReport = (0, livestream_store_1.useSubmitReport)();
    const handleCancel = () => {
        setSelectedReason(null);
        setAdditionalComments("");
        setSubmitError(null);
        onOpenChange(false);
    };
    const handleSubmit = async () => {
        if (!selectedReason)
            return;
        setIsSubmitting(true);
        setSubmitError(null);
        try {
            submitReport(subject, selectedReason, additionalComments.trim() || undefined);
            // Reset form and close modal on success
            setSelectedReason(null);
            setAdditionalComments("");
            onOpenChange(false);
        }
        catch (error) {
            console.error("Failed to submit report:", error);
            setSubmitError("Failed to submit report. Please try again.");
        }
        finally {
            setIsSubmitting(false);
        }
    };
    return ((0, jsx_runtime_1.jsxs)(ui_1.ResponsiveDialog, { open: open, onOpenChange: onOpenChange, title: title, description: description, showCloseButton: true, variant: "default", size: "md", dismissible: false, position: "center", children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [__1.zero.pb[2]], children: [REPORT_REASONS.map((reason) => ((0, jsx_runtime_1.jsxs)(react_native_1.TouchableOpacity, { onPress: () => setSelectedReason(reason.value), style: [
                            __1.zero.layout.flex.row,
                            __1.zero.gap.all[2],
                            __1.zero.py[3],
                            __1.zero.px[3],
                            __1.zero.borderRadius[8],
                            __1.zero.layout.flex.alignCenter,
                            selectedReason === reason.value && {
                                backgroundColor: "rgba(0, 122, 255, 0.1)",
                            },
                        ], children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { children: selectedReason === reason.value ? ((0, jsx_runtime_1.jsx)(lucide_react_native_1.CheckCircle, { color: theme.colors.foreground })) : ((0, jsx_runtime_1.jsx)(lucide_react_native_1.Circle, { color: theme.colors.foreground })) }), (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [__1.zero.layout.flex.column, __1.zero.gap.all[1], __1.zero.flex[1]], children: [(0, jsx_runtime_1.jsx)(ui_1.Text, { style: [{ fontWeight: "600" }], children: reason.label }), (0, jsx_runtime_1.jsx)(ui_1.Text, { style: [{ fontSize: 14, color: "rgba(255,255,255,0.7)" }], children: reason.description })] })] }, reason.value))), (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [__1.zero.pb[4], __1.zero.mt[4], __1.zero.px[2]], children: [(0, jsx_runtime_1.jsx)(ui_1.Text, { style: [__1.zero.mb[2]], children: "Additional Comments (optional)" }), (0, jsx_runtime_1.jsx)(ui_1.Textarea, { maxLength: 500, numberOfLines: 3, value: additionalComments, onChangeText: setAdditionalComments, placeholder: "Provide additional context for this report..." }), submitError && ((0, jsx_runtime_1.jsx)(ui_1.Text, { style: [__1.zero.mt[2], { color: "red", fontSize: 14 }], children: submitError }))] })] }), (0, jsx_runtime_1.jsxs)(ui_1.DialogFooter, { children: [(0, jsx_runtime_1.jsx)(ui_1.Button, { width: "min", variant: "secondary", onPress: handleCancel, disabled: isSubmitting, children: (0, jsx_runtime_1.jsx)(ui_1.Text, { children: "Cancel" }) }), (0, jsx_runtime_1.jsx)(ui_1.Button, { width: "min", variant: "primary", onPress: handleSubmit, disabled: !selectedReason || isSubmitting, children: isSubmitting ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(lucide_react_native_1.Loader2, { style: [{ marginRight: 8 }] }), (0, jsx_runtime_1.jsx)(ui_1.Text, { children: "Submitting..." })] })) : ((0, jsx_runtime_1.jsx)(ui_1.Text, { children: "Submit" })) })] })] }));
};
exports.ReportModal = ReportModal;
exports.default = exports.ReportModal;
//# sourceMappingURL=report-modal.js.map