/**
 * TypeScript interfaces for salla-bullet-delivery component
 */
export type IntentType = 'address' | 'branch';
/**
 * Country with shipping configuration
 */
export interface Country {
    id: number | string;
    name: string;
    code: string;
    flag?: string;
    has_regions?: boolean;
}
/** Location-like object for country/region (API and form use id + name) */
export interface LocationLike {
    id: number | string;
    name: string;
    code?: string;
}
/**
 * Region (required for Saudi Arabia)
 */
export interface Region {
    id: number;
    name: string;
    code?: string;
    country_id: number;
}
/**
 * City with optional region association
 */
export interface City {
    id: number;
    name: string;
    country_id: number;
    region_id?: number;
}
/**
 * District within a city
 */
export interface District {
    id: number;
    name: string;
    name_en?: string;
    city_id: number;
}
/**
 * Branch item as returned by branches API (response.data[])
 */
export interface Branch {
    id: number;
    name: string;
    status?: string;
    is_default?: boolean;
    location?: {
        lat: string;
        lng: string;
    };
    short_address?: string | null;
    street?: string;
    address_description?: string;
    additional_number?: string | null;
    building_number?: string | null;
    local?: string;
    postal_code?: string;
    contacts?: {
        phone?: string;
        whatsapp?: string;
        telephone?: string;
    };
    preparation_time?: string | null;
    is_open?: boolean;
    closest_time?: string | null;
    working_hours?: {
        name: string;
        times: {
            from: string;
            to: string;
        }[];
    }[];
    is_cod_available?: boolean;
    is_stock?: boolean;
    type?: string;
    cod_cost?: string;
    branch_code?: string | null;
    region?: {
        id: number;
        name: string;
        code?: string | null;
    };
    pickable?: boolean;
    shippable?: boolean;
    pos?: boolean;
    fulfillment_center?: unknown;
    has_delivery_zone?: boolean;
    country?: {
        id: number;
        name: string;
        name_en?: string;
        code: string;
        mobile_code?: string;
        capital?: string | null;
    };
    city?: {
        id: number;
        name: string;
        name_en?: string;
        country_id?: number;
    };
    district?: {
        id: number;
        name: string;
        name_en?: string;
    };
}
/**
 * Address item as returned by /address API (logged-in user addresses).
 * Used directly as SavedAddress; no mapping layer.
 */
export interface SavedAddress {
    id: number;
    name?: string;
    local?: string;
    street?: string;
    postal_code?: string;
    description?: string | null;
    is_custom_address?: number;
    type?: string;
    short_address?: string;
    is_international?: boolean;
    is_international_fields_complete?: boolean;
    receiver?: {
        name: string | null;
        mobile: string | null;
        country_code: string | null;
        email: string | null;
        notify?: number;
    };
    formatted?: {
        address_one?: string;
        address_two?: string;
    };
    is_default?: boolean;
    lng?: number;
    lat?: number;
    building_number?: string;
    additional_number?: string;
    subblock?: string;
    city_has_districts?: boolean;
    is_non_residential?: boolean;
    region?: {
        id: number;
        name: string;
        code?: string;
    };
    city?: {
        id: number;
        name: string;
    };
    country?: {
        id: number;
        name: string;
        code?: string;
    };
    district?: {
        id: number;
        name: string;
        name_en?: string;
    };
    region_id?: number;
    city_id?: number;
    country_id?: number;
    district_id?: number;
    /** UI-only: assume true when absent */
    is_in_coverage?: boolean;
}
/**
 * Unified location object for session storage (used for subtitle and form init)
 */
export interface IntentLocation {
    id: number | string;
    name: string;
    code?: string;
}
/**
 * Unified address details for session storage
 */
export interface IntentAddressDetails {
    country: IntentLocation;
    region?: IntentLocation;
    city: IntentLocation;
    district?: IntentLocation;
    short_address?: string;
}
/**
 * Unified branch details for session storage
 */
export interface IntentBranchDetails {
    id: number;
    name: string;
    city?: string;
    latitude?: number;
    longitude?: number;
}
/**
 * Result of the bullet delivery flow.
 * Uses unified address/branch objects for display and form init; flat IDs kept for API compatibility.
 */
export interface BulletDeliveryResult {
    type: IntentType;
    country_id: number;
    country_code: string;
    /** Unified address details for display and form init (not the full Address object) */
    address_details?: IntentAddressDetails;
    /** Unified branch details for display when type is branch */
    branch_details?: IntentBranchDetails;
    region_id?: number;
    city_id?: number;
    district_id?: number;
    branch_id?: number;
    address_id?: number;
    national_address?: string;
    building_number?: string;
    additional_number?: string;
    street?: string;
    postal_code?: string | number;
    allocation_headers?: {
        's-scope-allocation-type'?: string;
        's-scope-allocation-id'?: string;
    };
}
/**
 * Event payloads
 */
export interface BulletDeliveryOpenEvent {
    preselected_address_id?: number;
    preselected_branch_id?: number;
}
export interface BulletDeliveryConfirmedEvent extends BulletDeliveryResult {
    address?: SavedAddress;
    branch?: Branch;
}
export interface BulletDeliveryAllocationConfirmedAddressData {
    saved_address?: SavedAddress;
    country?: Country;
    region?: Region;
    city?: City;
    district?: District;
    district_name?: string;
    short_address?: string;
    form_data?: NewAddressFormData;
}
export interface BulletDeliveryAllocationConfirmedEvent extends BulletDeliveryResult {
    address: BulletDeliveryAllocationConfirmedAddressData | null;
    branch?: Branch | null;
    allocation_request: ScopeAllocationPayload;
    allocation_response: ScopeAllocationResponse | null;
}
export interface AddressCreatedEvent {
    address: SavedAddress;
}
/**
 * Header context update event payload (for syncing with global header)
 */
export interface HeaderContextUpdateEvent {
    type: IntentType;
    display_text: string;
    country_code: string;
    city?: string;
    district?: string;
    branch_name?: string;
    national_address?: string;
}
/**
 * New address form data
 */
export interface NewAddressFormData {
    country_id?: number;
    region_id?: number;
    city_id?: number;
    district_id?: number;
    street?: string;
    building_number?: string | number;
    additional_number?: string | number;
    postal_code?: string | number;
    national_address?: string;
    description?: string;
    is_default?: boolean;
    city?: City;
    district?: District;
    country?: Country;
}
/**
 * Scope allocation response from API
 */
export interface ScopeAllocationPayload {
    type: 'address' | 'branch';
    country_id?: string;
    region_id?: string;
    city_id?: string;
    district_id?: string;
    lat?: string;
    lng?: string;
    address_id?: string;
    branch_id?: string;
}
export interface ScopeAllocationResponse {
    id: number;
    name: string;
    selected: boolean;
    type: string;
    is_open: boolean;
    display_as: string;
    languages: string[];
    currencies: string[];
    countries: string[];
    always_ask: boolean;
    allocation: {
        type: 'address' | 'branch';
        branch_id: number;
    };
    events?: unknown;
}
