import { OrderModule, ProductList, SalesSummaryModule, ScanOrderLogInput, ScanOrderLoggerModule, ScanOrderLoggerProviderConfig, ScanOrderLoggerProviderType, ScheduleModule } from '../../modules';
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
/**
 * 扫码下单流程 hook
 */
export declare enum ScanOrderHooks {
    onInited = "scanOrder:onInited",
    onDestroy = "scanOrder:onDestroy",
    onRetryInit = "scanOrder:onRetryInit",
    onRefresh = "scanOrder:onRefresh",
    onCartValidationChanged = "scanOrder:onCartValidationChanged"
}
export type ScanOrderStatus = 'idle' | 'initializing' | 'ready' | 'error';
export type ScanOrderEntryContext = {
    biz: string;
    mode: 'scan' | 'append';
    resourceId?: string;
    sourceOrderId?: string;
};
export interface ScanOrderConfig {
    orderSource: 'local' | 'remote';
    scanTimeout: number;
    allowAppend: boolean;
    maxAppendCount: number;
    features: {
        autoMerge: boolean;
        verifyResource: boolean;
    };
}
export interface ScanOrderOrderProductIdentity {
    product_id: number | null;
    product_variant_id: number;
    identity_key?: string;
    unique_identification_number?: string;
    /** 参与合并/匹配；与 remove 通配语义见 isSkuOnlyDeleteIdentity */
    product_option_item?: any[];
    product_bundle?: any[];
}
export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
    order_detail_id: number | null;
    num: number;
    product_option_item: any[];
    /**
     * 券后 **行 composite 单价** = `metadata.main_product_selling_price`
     *   + Σ((bundle.bundle_selling_price ?? bundle.price) × (bundle.num ?? 1))
     *
     * 新语义 v2 下 `metadata.main_product_selling_price` 已经**含 option**、含主商品折扣，
     * 因此本字段不再叠加 option。未应用券时等同 `original_price`。
     * Rules 钩子、主商品计税、Summary 统一读 metadata，不以此字段反推。
     */
    selling_price: string;
    /**
     * 券前 **行 composite 单价** = `metadata.main_product_original_price`
     *   + Σ(bundle 原价 × num)
     *
     * 新语义 v2 下 `metadata.main_product_original_price` 已经**含 option**、不含折扣。
     * 不承载后台划线价语义。
     */
    original_price: string;
    tax_fee: string;
    is_charge_tax: number;
    discount_list: any[];
    product_bundle: any[];
    /** 关联 booking.metadata.unique_identification_number */
    booking_uid?: string;
    /**
     * 行级扩展 metadata。价格相关的权威字段：
     *
     * - `source_product_price`：主商品/variant 基础价（已应用报价单），**不含 option、不含折扣**。
     *   是派生 `main_product_*` 的唯一源。variant 分支优先读 `metadata.origin.variant[vid].price`。
     * - `main_product_original_price` = `source_product_price + Σ(option.price × option.num)`，
     *   **含 option、不含折扣**。
     * - `main_product_selling_price` = `main_product_original_price − 主商品券 per-unit amount`，
     *   **含 option、含主商品折扣**。Rules 钩子 / Summary / 计税均以此为主商品权威源。
     * - `price_schema_version`（当前 = 2）：schema 版本 sentinel，用于跨端协商价格口径、
     *   区分 v1 旧缓存以便 `normalizeOrderProduct` 触发迁移。
     */
    metadata: Record<string, any>;
    /** 商品行备注（如顾客对单品的特殊要求） */
    note?: string;
    /** @deprecated UI/SDK 运行态数据迁移到 tempOrder._extend */
    _origin?: Record<string, any>;
}
/**
 * 出站 payload 版本的商品行。
 *
 * 与 tempOrder 内部 `ScanOrderOrderProduct` 的字段差异：
 * - `product_option_item[*]`：内部为 `{ option_group_item_id, option_group_id, num, price, ... }`，
 *   出站保留 `{ option_group_item_id, option_group_id, num }`
 *   （后端 checkout 协议；丢弃 `price` 等运行时辅助字段）。
 * - `product_bundle[*].option[*]`：同上重命名规则。
 *
 * 运行时（UI 显示、加购合并、指纹、持久化）与提交边界统一消费字段名
 * `option_group_item_id`，保持 tempOrder 与后端协议一致。
 */
export interface ScanOrderSubmitProduct extends Omit<ScanOrderOrderProduct, '_origin' | 'identity_key'> {
    /**
     * 出站兼容字段：SDK 内部不再消费 payment_price，
     * 仅在提交后端时由 selling_price 派生，保持原有后端契约。
     * 新语义 v2 下 selling_price 是 composite（含 option、含 bundle、含主商品折扣），
     * 因此 payment_price 同样是 composite。
     */
    payment_price: string;
}
export interface ScanOrderSummary {
    product_quantity: number;
    product_original_amount: string;
    product_amount: string;
    product_expect_amount: string;
    product_tax_fee: string;
    shipping_fee: string;
    shipping_tax_fee: string;
    tax_fee: string;
    surcharge_fee: string;
    discount_amount: string;
    deposit_amount: string;
    deposit?: {
        total: string;
        deposit_policy_ids: number[];
        hasDeposit: boolean;
    };
    expect_amount: string;
    total_amount: string;
    total_refund_amount: string;
    customer_paid_amount: string;
    order_paid_amount: string;
    amount_gap: string;
    rounding_amount: string;
    pay_service_charge_amount: string;
    tax_title?: string;
    tax_rate?: number;
}
/**
 * ScanOrder 临时订单（runtime-clean 版本）
 * 只保留运行时字段，不包含任何 __comment 字段
 */
export interface ScanOrderTempOrder {
    order_id: number | null;
    /** @deprecated 资源运行态迁移到 ScanOrder store；仅旧缓存兼容 */
    relation_id?: string;
    /** @deprecated 资源运行态迁移到 ScanOrder store；仅旧缓存兼容 */
    table_form_id?: string;
    /** @deprecated 资源运行态迁移到 ScanOrder store；仅旧缓存兼容 */
    resource_id?: string;
    order_number: string;
    shop_order_number: string;
    shop_full_order_number: string;
    type: string;
    business_code: string;
    platform: string;
    sales_channel: string;
    order_sales_channel: string;
    status: string;
    payment_status: string;
    shipping_status: string;
    customer_id: number | null;
    customer_name: string;
    country_calling_code: string;
    phone: string;
    email: string;
    is_price_include_tax: number;
    tax_title: string;
    tax_country_code: string;
    currency_code: string;
    currency_symbol: string;
    currency_format: string;
    is_deposit: number;
    deposit_amount: string;
    shop_discount: string;
    surcharge_fee: string;
    note: string;
    buzzer?: string;
    delivery_type?: string;
    table_number?: Record<string, any>;
    schedule_date: string;
    created_at: string;
    request_unique_idempotency_token?: string;
    products: ScanOrderOrderProduct[];
    bookings: any[];
    payments: any[];
    surcharges: any[];
    discount_list: any[];
    relation_forms: any[];
    contacts: any[];
    contacts_info: Record<string, any> | null;
    holder: Record<string, any> | null;
    metadata: Record<string, any>;
    _extend?: {
        productsByUid?: Record<string, Record<string, any>>;
        [key: string]: any;
    };
    /** @deprecated summary 是 OrderState 派生状态，不属于可提交 tempOrder */
    summary?: ScanOrderSummary;
    /** @deprecated lastOrderInfo 迁移到 OrderState 同层级 */
    lastOrderInfo?: Record<string, any>;
}
export interface ScanOrderSubmitPayload extends Omit<ScanOrderTempOrder, 'platform' | 'products' | 'summary' | 'surcharges'> {
    platform: string;
    request_unique_idempotency_token?: string;
    form_record_ids?: Array<{
        form_id: number | string;
        form_record_id: number | string;
    }>;
    products: ScanOrderSubmitProduct[];
}
export type ScanOrderAvailabilityMode = 'idle' | 'shop_closed' | 'submit_disabled' | 'resource_busy' | 'additional_order_with_code' | 'additional_order';
export interface ScanOrderTableFormRecord {
    policy?: string | null;
    partyroom_booking?: string | null;
    capacity?: number | string | null;
    [key: string]: any;
}
export interface ScanOrderAvailabilityInfo {
    mode: ScanOrderAvailabilityMode;
    order_id?: string;
    relation_id?: string;
    table_form_id?: string;
    deskmate_valid?: boolean;
    errorTips?: string;
    /** 透传 `availability.closed_behavior`，便于 UI 识别拦截类型（如 show_menu_disabled） */
    closed_behavior?: string;
    /** `/order/resource/occupy-detail` 返回的 `form_record` 原样透出 */
    table_form_record?: ScanOrderTableFormRecord | null;
    policy?: string | null;
    partyroom_booking?: string | null;
    /** 预约规则关联商品存在 custom 容量时，由 checkResourceAvailable 置为 1 */
    requestEntryPax?: number;
    /** 首个 `capacity.type === 'custom'` 商品里 `custom[0]` 的 min（人数下限） */
    requestPaxMin?: number;
    /** 首个 `capacity.type === 'custom'` 商品里 `custom[0]` 的 max（人数上限） */
    requestPaxMax?: number;
}
/** `resource_capacity[i].capacity_list[j]` */
export interface ScanOrderResourceCapacitySlot {
    start_at?: string;
    end_at?: string;
    pax?: number | string;
}
export interface ScanOrderResourceCapacity {
    capacity?: number | string;
    capacity_list?: ScanOrderResourceCapacitySlot[];
}
/** `/order/resource/occupy-detail` 单条 `occupy_details[i]` */
export interface ScanOrderResourceOccupyDetail {
    form_record_id?: number | string | null;
    form_id?: number | string | null;
    order_id?: number | string | null;
    last_order_id?: number | string | null;
    resource_capacity?: ScanOrderResourceCapacity[] | null;
    form_record?: ScanOrderTableFormRecord | null;
    [key: string]: any;
}
export interface ScanOrderResourceOccupyDetailApiResponse {
    status?: boolean;
    code?: number;
    message?: string;
    data?: {
        occupy_details?: ScanOrderResourceOccupyDetail[] | null;
    } | null;
}
export type ScanOrderResourceSelectType = 'single' | 'multiple' | 'capacity';
export interface ScanOrderResourceState extends ScanOrderAvailabilityInfo {
    relationId?: string;
    tableFormId?: string;
    currentOrderId?: string;
    lastOrderId?: string;
    allowSnack: boolean;
    deskmateValid: boolean;
    isExclusive: boolean;
    isFull: boolean;
    /** 来自首个预约规则商品 product_resource.resources 中与 form_id 匹配的 resource type */
    resourceSelectType?: ScanOrderResourceSelectType;
    raw: ScanOrderResourceOccupyDetail | null;
}
export interface ScanOrderState {
    entryContext: ScanOrderEntryContext | null;
    status: ScanOrderStatus;
    config: Record<string, any> | null;
    resource: ScanOrderResourceState | null;
    flow: Record<string, any>;
    error: string | null;
    products?: ProductList;
    order?: OrderModule;
    salesSummary?: SalesSummaryModule;
    scanOrderLogger?: ScanOrderLoggerModule;
    schedule?: ScheduleModule;
    itemRuleQuantityLimits: QuantityLimitResult[];
    cartValidation: {
        passed: boolean | null;
        failures: QuantityCheckResult[];
    };
    entryPaxNumber: number | null;
}
export interface ScanOrderLoggerRuntimeConfig {
    provider?: ScanOrderLoggerProviderType;
    providerConfig?: ScanOrderLoggerProviderConfig;
}
export interface ScanOrderAddLogParams extends ScanOrderLogInput {
}
/** ScanOrder.scanCode 对外的轻量结果（不含 discountList，UI 在 resolve 后调 getDiscountList） */
export interface ScanOrderScanCodeResult {
    isAvailable: boolean;
    type?: 'server' | string;
    unavailableReason?: 'time_limit' | string;
}
