def scale_coordinates(self, source: ScalingSource, x: int, y: int) -> tuple[int, int]:
        """Scale coordinates based on the current scaling configuration."""
        if not self._scaling_enabled:
            return x, y

        if self.scaling_config["mode"] == ScalingMode.NONE:
            return x, y

        # Get current scaling factors
        x_factor = 1.0
        y_factor = 1.0

        if self.scaling_config["mode"] == ScalingMode.FIXED and self.scaling_config["target_resolution"]:
            # Fixed mode - scale to target resolution
            x_factor = self.scaling_config["target_resolution"]["width"] / self.width
            y_factor = self.scaling_config["target_resolution"]["height"] / self.height
            
            if self.scaling_config["preserve_aspect_ratio"]:
                # Use the same factor for both dimensions to preserve aspect ratio
                x_factor = y_factor = min(x_factor, y_factor)
        
        elif self.scaling_config["mode"] == ScalingMode.RELATIVE and self.scaling_config["scale_factor"] is not None:
            # Relative mode - use scale factor directly
            x_factor = y_factor = self.scaling_config["scale_factor"]
        
        # Apply scaling based on source
        if source == ScalingSource.API:
            # Scale up (from scaled coordinates to actual screen coordinates)
            return round(x / x_factor), round(y / y_factor)
        else:
            # Scale down (from actual screen coordinates to scaled coordinates)
            return round(x * x_factor), round(y * y_factor)
Scale coordinates based on the current scaling configuration.
src/upsonic/server/level_utilized/cu/computer.py