import type { EscalationRule } from './types';

export const vendorNoResponseRule: EscalationRule = {
  id: 'vendor-no-response',
  label: 'ספק לא הגיב',
  description: 'חלון ספק פג ללא תגובה (מקרה מסחרי)',
  async check(ctx) {
    if (ctx.parentType !== 'case') return null;

    const hasVendor = ctx.conversation.some(
      (m) => m.role === 'vendor' || m.role === 'vendor_internal',
    );

    if (hasVendor || ctx.turnCount <= 5) return null;

    return {
      ruleId: 'vendor-no-response',
      reason: `יותר מ-5 תורות ללא תגובת ספק (${ctx.turnCount} תורות)`,
      severity: 'high',
    };
  },
};
