import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Checkbox } from "../../components/ui/checkbox";
import { Input } from "../../components/ui/input";
import { Label } from "../../components/ui/label";
export function CreateReviewSettingsStep({ reviewers, requiredApprovals, setRequiredApprovals, updateWorkflowOnCompletion, setUpdateWorkflowOnCompletion, shareCommentsAndSuggestions, setShareCommentsAndSuggestions, expirationDays, setExpirationDays, showSecretFields, setShowSecretFields, secret, setSecret, secretConfirm, setSecretConfirm, }) {
    const requiredApprovalsError = (() => {
        if (!requiredApprovals)
            return null;
        const num = parseInt(requiredApprovals, 10);
        if (isNaN(num) || num < 1) {
            return "Must be at least 1";
        }
        if (reviewers.length > 0 && num > reviewers.length) {
            return `Cannot exceed number of reviewers (${reviewers.length})`;
        }
        return null;
    })();
    return (_jsxs("div", { className: "grid grid-cols-1 gap-6 p-4 md:p-6", children: [_jsxs("div", { className: "flex flex-col gap-6", children: [_jsxs("div", { className: "flex flex-col gap-3 pl-8", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { htmlFor: "requiredApprovals", className: "text-neutral-grey-100 text-sm font-medium", children: "Required Approvals" }), _jsx("p", { className: "text-muted-foreground text-xs", children: "Number of reviewers that must approve each page or item before it's considered complete." })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Input, { id: "requiredApprovals", "data-testid": "required-approvals-input", type: "number", min: "1", value: requiredApprovals, onChange: (e) => setRequiredApprovals(e.target.value), placeholder: "1", className: "bg-neutral-grey-5/50 w-24" }), _jsx("span", { className: "text-neutral-grey-50 text-xs font-medium", children: "approvals needed" })] }), requiredApprovalsError && (_jsx("p", { className: "text-destructive text-xs font-medium", children: requiredApprovalsError }))] })] }), _jsx("div", { className: "border-border-default border-t" }), _jsxs("div", { className: "flex items-start gap-4", children: [_jsx(Checkbox, { id: "updateWorkflowOnCompletion", "data-testid": "update-workflow-checkbox", checked: updateWorkflowOnCompletion, onCheckedChange: (checked) => setUpdateWorkflowOnCompletion(!!checked), className: "mt-1" }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Label, { htmlFor: "updateWorkflowOnCompletion", className: "text-neutral-grey-100 cursor-pointer text-sm leading-tight font-medium", children: "Update workflow state on completion" }), _jsx("span", { className: "text-muted-foreground text-xs leading-relaxed", children: "When the review is approved by all required reviewers, automatically execute the \"Approve\" workflow action." })] })] }), _jsx("div", { className: "border-border-default border-t" }), _jsxs("div", { className: "flex items-start gap-4", children: [_jsx(Checkbox, { id: "hasExpiration", "data-testid": "set-expiration-checkbox", checked: expirationDays !== "", onCheckedChange: (checked) => {
                                    if (!checked) {
                                        setExpirationDays("");
                                    }
                                    else {
                                        setExpirationDays("30");
                                    }
                                }, className: "mt-1" }), _jsxs("div", { className: "flex flex-1 flex-col gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Label, { htmlFor: "hasExpiration", className: "text-neutral-grey-100 cursor-pointer text-sm leading-tight font-medium", children: "Set expiration" }), _jsx("span", { className: "text-muted-foreground text-xs leading-relaxed", children: "Automatically close the review after a specified number of days if not completed." })] }), expirationDays !== "" && (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Input, { type: "number", "data-testid": "expiration-days-input", min: "1", value: expirationDays, onChange: (e) => setExpirationDays(e.target.value), placeholder: "30", className: "bg-neutral-grey-5/50 w-24" }), _jsx("span", { className: "text-neutral-grey-50 text-xs font-medium", children: "days remaining" })] }))] })] })] }), _jsxs("div", { className: "flex flex-col gap-6", children: [_jsxs("div", { className: "flex items-start gap-4", children: [_jsx(Checkbox, { id: "hasSecret", "data-testid": "require-secret-checkbox", checked: showSecretFields, onCheckedChange: (checked) => {
                                    setShowSecretFields(!!checked);
                                    if (!checked) {
                                        setSecret("");
                                        setSecretConfirm("");
                                    }
                                }, className: "mt-1" }), _jsxs("div", { className: "flex flex-1 flex-col gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Label, { htmlFor: "hasSecret", className: "text-neutral-grey-100 cursor-pointer text-sm leading-tight font-medium", children: "Require secret to unlock" }), _jsx("span", { className: "text-muted-foreground text-xs leading-relaxed", children: "Reviewers must enter a shared secret phrase before they can access and review the content." })] }), showSecretFields && (_jsxs("div", { className: "grid max-w-md grid-cols-2 gap-3", children: [_jsx(Input, { "data-testid": "secret-input", type: "password", placeholder: "Create secret phrase", value: secret, onChange: (e) => setSecret(e.target.value), autoComplete: "off", className: "bg-neutral-grey-5/50" }), _jsx(Input, { "data-testid": "secret-confirm-input", type: "password", placeholder: "Confirm secret phrase", value: secretConfirm, onChange: (e) => setSecretConfirm(e.target.value), autoComplete: "off", className: "bg-neutral-grey-5/50" }), secret && secretConfirm && secret !== secretConfirm && (_jsx("p", { className: "text-destructive col-span-2 text-xs font-medium", children: "Secret phrases do not match" }))] }))] })] }), _jsx("div", { className: "border-border-default border-t" }), _jsxs("div", { className: "flex items-start gap-4", children: [_jsx(Checkbox, { id: "shareCommentsAndSuggestions", "data-testid": "share-comments-checkbox", checked: shareCommentsAndSuggestions, onCheckedChange: (checked) => setShareCommentsAndSuggestions(!!checked), className: "mt-1" }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Label, { htmlFor: "shareCommentsAndSuggestions", className: "text-neutral-grey-100 cursor-pointer text-sm leading-tight font-medium", children: "Share comments and suggestions with all reviewers" }), _jsx("span", { className: "text-muted-foreground text-xs leading-relaxed", children: "When enabled, all reviewers in this review will be able to see comments and suggestions made by other reviewers or sitecore users. This will also affect already existing comments." })] })] })] })] }));
}
//# sourceMappingURL=CreateReviewSettingsStep.js.map