private function extractSpaceId(array $data): string
    {
        // Space resource
        if (isset($data['sys']['type']) && 'Space' === $data['sys']['type']) {
            return $data['sys']['id'];
        }

        // Environment resource
        if (isset($data['sys']['type']) && 'Environment' === $data['sys']['type']) {
            return $this->spaceId;
        }

        // Resource linked to a space
        if (isset($data['sys']['space'])) {
            return $data['sys']['space']['sys']['id'];
        }

        // Array resource with at least an element
        if (isset($data['items'][0]['sys']['space'])) {
            return $data['items'][0]['sys']['space']['sys']['id'];
        }

        // Empty array resource
        if (isset($data['items']) && !$data['items']) {
            return $this->spaceId;
        }

        return '[blank]';
    }