import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { useEditContext, useFieldsEditContext } from "../client/editContext";
import { FieldEditedIndicator } from "./FieldEditedIndicator";
export function FieldEditedIndicators({ pageViewContext, }) {
    const editContext = useEditContext();
    const modifiedFieldsContext = useFieldsEditContext();
    if (!editContext || !modifiedFieldsContext)
        return null;
    const fields = modifiedFieldsContext.recentEdits;
    return (_jsx(_Fragment, { children: fields
            .filter((x) => {
            // Keep if:
            // 1. It's an AI edit (agentId present)
            // 2. AND it's either recent (last 10s) OR it's still being modified (dirty)
            const isRecent = x.timestamp > Date.now() - 10000;
            const modField = modifiedFieldsContext.modifiedFields.find((m) => m.fieldId === x.fieldId &&
                m.item.id === x.item.id &&
                m.item.language === x.item.language &&
                m.item.version === x.item.version);
            const isDirty = modField?.isDirty;
            const hasAgentId = !!x.user.agentId || !!x.user.ai;
            return (isRecent || isDirty) && hasAgentId;
        })
            .map((field) => (_jsx(FieldEditedIndicator, { field: field, pageViewContext: pageViewContext }, field.fieldId + field.item.id + field.timestamp))) }));
}
//# sourceMappingURL=FieldEditedIndicators.js.map