o
    i_                     @  s*   d Z ddlmZ ddlmZ ddd	Zd
S )zMinimal tenant resolver for the SaaS request flow.

This resolver is intentionally lightweight for initial runtime wiring.
It prefers ``X-Tenant-ID`` and falls back to simple host parsing.
    )annotations)Requestrequestr   returndict[str, str]c                 C  s   | j dpd }|s/| j dp| jpdddd   }|r/|dkr/|ddd }|s5td	|d
kr@td| d
dddS )zResolve the active tenant from headers or host.

    Current bootstrap behavior is intentionally fixed to ``absolutems`` so the
    runtime flow can be tested end-to-end before control-plane lookup is wired.
    zX-Tenant-ID Host:   r   zmail.absolutems.com.au.zMissing tenant identifier
absolutemszUnknown tenant: absolutems_dbactive)	tenant_iddb_namestatus)headersgetstriphostsplitlower
ValueErrorLookupError)r   r   r    r   #platform/routing/tenant_resolver.pyresolve_tenant   s   *r   N)r   r   r   r   )__doc__
__future__r   flaskr   r   r   r   r   r   <module>   s    