from qhub.api.quantum import Qubit
from qhub.quantum.sdk.qiskit.provider import HubQiskitProvider
from qhub.quantum.sdk.qiskit.providers.aws.aws_backend import HubAwsBackend


@HubQiskitProvider.register_backend("aws.rigetti.ankaa")
class HubAwsRigettiAnkaaBackend(HubAwsBackend):

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def _normalize_qubit_indices(self):
        """Remap Rigetti's qubit indices to contiguous 0-based range.

        qhub-api models are frozen, so we store the normalized list
        as an instance attribute used by num_qubits.
        """
        self._normalized_qubits = [Qubit(id=str(i)) for i in range(self.num_qubits)]
