import { BaseResponsiveProps } from "../../../responsive/type.js";
import React from "react";

//#region src/plus/saasDevice/appPeripheral/types.d.ts
type DeviceKind = 'smart' | 'dumb' | 'integrated';
type DeviceLinkStatus = 'linked' | 'unlinked' | string;
type DeviceOnlineStatus = 'online' | 'offline' | 'unknown' | string;
/** 多语言字段，后端可能返回字符串或语言字典。 */
type I18nText = string | {
  original?: string;
  'zh-CN'?: string;
  'zh-HK'?: string;
  en?: string;
  ja?: string;
  pt?: string;
  [key: string]: any;
};
interface SaasAppPeripheralProps extends BaseResponsiveProps {
  className?: string;
  style?: React.CSSProperties;
  showBack?: boolean;
  onBack?: () => void;
  onManageProfiles?: () => void;
  onTest?: (payload: PeripheralTestPayload) => void | Promise<void>;
}
interface WorkAreaItem {
  id: number;
  tenant_id?: number;
  name: I18nText;
  description?: I18nText;
  sort: number;
  smart_devices_count?: number;
  dumb_devices_count?: number;
  integrated_devices_count?: number;
  created_at?: string;
  updated_at?: string;
}
interface DeviceBrandItem {
  id: number;
  code: string;
  name: I18nText;
  description?: I18nText;
  website?: string;
  status?: string;
  created_at?: string;
  updated_at?: string;
  deleted_at?: string | null;
}
interface DeviceTypeItem {
  id: number;
  kind: DeviceKind;
  code: string;
  icon?: string | null;
  name: I18nText;
  description?: I18nText;
  status?: string;
  sort?: number;
  active_models?: DeviceModelItem[];
}
interface DeviceModelItem {
  id: number;
  brand_code?: string;
  type_code: string;
  type?: DeviceTypeItem;
  code: string;
  name: I18nText;
  description?: I18nText;
  data?: {
    profile_structure?: {
      required?: boolean;
      tabs?: unknown[];
    };
    connection_types?: string[];
    [key: string]: unknown;
  } | null;
  status?: string;
  sort?: number;
  active_profiles?: DeviceProfileItem[];
  brand?: DeviceBrandItem;
}
interface DeviceProfileItem {
  id: number;
  model_code?: string;
  template_code?: string;
  name?: I18nText;
  description?: I18nText;
  setting?: Record<string, unknown> | null;
  status?: string;
}
interface DeviceItem {
  id: number;
  tenant_id?: number;
  workarea_id?: number;
  type_kind: DeviceKind;
  type_code: string;
  model_code: string;
  profile_id?: number | null;
  number?: string;
  name: I18nText;
  data?: Record<string, unknown> | null;
  setting?: Record<string, unknown> | null;
  link?: DeviceLinkStatus;
  status?: DeviceOnlineStatus;
  sort?: number;
  last_seen?: string;
  created_at?: string;
  updated_at?: string;
  type?: DeviceTypeItem;
  model?: DeviceModelItem;
  profile?: DeviceProfileItem | null;
  workarea?: WorkAreaItem;
}
interface DeviceConnectionConfig {
  connection_ip?: string;
  connection_type?: string;
  connection_method?: string;
  [key: string]: unknown;
}
type PeripheralConnectType = 'USB' | 'ETHERNET' | 'WIFI' | 'BLUETOOTH';
type PeripheralUsage = 'label' | 'wristband';
/** 外设插件返回的物理设备结构，保持为宿主插件的最小兼容子集。 */
interface PeripheralDevice {
  uuid: string;
  ip?: string;
  port?: string;
  mac?: string;
  is_connect: boolean;
  name: string;
  connect_type: PeripheralConnectType;
  status_code: string;
  metadata?: Record<string, unknown>;
  [key: string]: unknown;
}
/** Test 按钮对外透出的通用载荷，不绑定 POS 侧的打印机模型。 */
interface PeripheralTestPayload {
  connection: DeviceConnectionItem;
  targetDevice?: DeviceItem | null;
  physicalDevice?: PeripheralDevice;
  peripheralUsage?: PeripheralUsage;
}
/** 设备连接业务类型；当前接口仅启用哑设备连接。 */
type DeviceConnectionType = 'dumb';
interface DeviceConnectionItem {
  id: number;
  tenant_id?: number;
  type?: DeviceConnectionType;
  source_device_id: number;
  target_device_id: number;
  config?: DeviceConnectionConfig | null;
  profile_ids?: number[];
  status?: string | null;
  created_at?: string;
  updated_at?: string;
  source_device?: DeviceItem | null;
  target_device?: DeviceItem | null;
  profiles?: DeviceProfileItem[];
}
//#endregion
export { SaasAppPeripheralProps };