export type UserTier = 'free' | 'pro' | 'elite';

export interface TierPermissions {
    allowedRiskStyleIds: string[];
    maxDailyProfitTargetUsd: number;
    label: string;
    color: string;
}

export const TIER_POLICIES: Record<UserTier, TierPermissions> = {
    free: {
        allowedRiskStyleIds: ['safe'],
        maxDailyProfitTargetUsd: 0, // No profit target adjustment
        label: 'Free Tier',
        color: '#94a3b8' // Zinc-400
    },
    pro: {
        allowedRiskStyleIds: ['safe', 'balanced'],
        maxDailyProfitTargetUsd: 100,
        label: 'Pro Tier',
        color: '#3b82f6' // Blue-500
    },
    elite: {
        allowedRiskStyleIds: ['safe', 'balanced', 'aggressive'],
        maxDailyProfitTargetUsd: 10000,
        label: 'Elite Tier',
        color: '#00ff88' // Primary Green
    }
};

export const getUserTier = (_profile: any): UserTier => {
    void _profile;
    // FEATURE FLAG: Unlocked for everyone by default until payment integration
    return 'elite';

    /* 
    if (profile?.role === 'admin') return 'elite';
    return (profile?.tier as UserTier) || 'free';
    */
};

export const isFeatureAllowed = (
    _tier: UserTier,
    _feature: 'risk_style' | 'profit_target',
    _value: any
): boolean => {
    void _tier;
    void _feature;
    void _value;
    // FEATURE FLAG: All features allowed by default for preview
    return true;

    /*
    const policy = TIER_POLICIES[tier];
    if (feature === 'risk_style') {
      return policy.allowedRiskStyleIds.includes(value);
    }
    if (feature === 'profit_target') {
      return policy.maxDailyProfitTargetUsd >= value || tier === 'elite';
    }
    return false;
    */
};
