/**
 * 다이소 서비스 전용 타입 정의
 */

// 매장 옵션 정보
export interface StoreOptions {
  parking: boolean;
  ramp: boolean;
  elevator: boolean;
  cashless: boolean;
  photoSticker: boolean;
  nameSticker: boolean;
  simCard: boolean;
  taxFree: boolean;
  groupOrder: boolean;
  pickup: boolean;
}

// 매장 정보 (daiso.co.kr API)
export interface Store {
  name: string;
  phone: string;
  address: string;
  lat: number;
  lng: number;
  openTime: string;
  closeTime: string;
  openDate?: string;
  options: StoreOptions;
}

// 매장 재고 정보 (daisomall.co.kr API)
export interface StoreInventory {
  storeCode: string;
  storeName: string;
  address: string;
  phone: string;
  openTime: string;
  closeTime: string;
  lat: number;
  lng: number;
  distance: string;
  quantity: number;
  options: {
    parking: boolean;
    simCard: boolean;
    pickup: boolean;
    taxFree: boolean;
    elevator: boolean;
    ramp: boolean;
    cashless: boolean;
  };
}

// 상품 정보 (daisomall.co.kr API)
export interface Product {
  id: string;
  name: string;
  price: number;
  originalPrice?: number;
  discount?: number;
  imageUrl?: string;
  category?: string;
  brand?: string;
  soldOut?: boolean;
  isNew?: boolean;
  pickupAvailable?: boolean;
  onlineStock?: number;
}

// 재고 응답용 상품 요약 정보
export interface ProductSummary {
  id: string;
  name: string;
  imageUrl?: string;
  brand?: string;
  soldOut?: boolean;
  isNew?: boolean;
}

// 상품 검색 응답
export interface ProductSearchResponse {
  resultSet: {
    result: Array<{
      totalSize: number;
      resultDocuments: Array<{
        PD_NO: string;
        PDNM: string;
        EXH_PD_NM?: string;
        PD_PRC: string;
        ATCH_FILE_URL?: string;
        BRND_NM?: string;
        SOLD_OUT_YN?: string;
        NEW_PD_YN?: string;
        PKUP_OR_PSBL_YN?: string;
        ONL_SCL_CD?: string;
      }>;
    }>;
  };
}

// 온라인 재고 응답
export interface OnlineStockResponse {
  data: {
    pdNo: string;
    stck: number;
  };
  success: boolean;
}

export interface StoreSearchV2Response {
  message: string | null;
  data: Array<{
    strCd: string;
    strNm: string;
    strAddr: string;
    strTno: string;
    opngTime: string;
    clsngTime: string;
    strLttd: number;
    strLitd: number;
    km: string;
    parkYn: string;
    usimYn: string;
    pkupYn: string;
    taxfYn: string;
    elvtYn?: string;
    entrRampYn?: string;
    nocashYn?: string;
  }>;
}

export interface StoreInventoryV2Item {
  pdNo: string;
  strCd: string;
  sleStsCd?: string;
  stck: string;
}

export interface StoreInventoryV2Response {
  message: string | null;
  data: StoreInventoryV2Item[];
  success: boolean;
  returnCode?: string | null;
}

// 진열 위치 정보
export interface DisplayLocation {
  zoneNo: string;
  stairNo: string;
  storeErp: string;
}

// 진열 위치 조회 응답 (fapi.daisomall.co.kr API)
export interface DisplayLocationResponse {
  message: string | null;
  data: Array<{
    zoneNo: string;
    stairNo: string;
    storeErp: string;
  }>;
  extraData: Record<string, unknown>;
  extraString: string | null;
  returnCode: string | null;
  success: boolean;
}

// 상품 문서 타입 (가격 조회용)
export interface ProductDoc {
  PD_NO: string;
  PDNM: string;
  EXH_PD_NM?: string;
  PD_PRC: string;
  ATCH_FILE_URL?: string;
  BRND_NM?: string;
  SOLD_OUT_YN?: string;
  NEW_PD_YN?: string;
}
