import { R } from 'vite/dist/node/types.d-aGj9QkWt'
import { Ref } from 'vue'

/**
 * Server request status enum.
 */
type TMaybeRecord = null | Record<string, any>

type TCollectionStatus = 'publish' | 'draft' | 'trash' | ''

export enum StatusEnum {
  PUBLISH = 'publish',
  DRAFT = 'draft',
  TRASH = 'trash'
}

interface ICollectionsStore {
  collections: Ref<ICollections>
  getCollections: (params?: Record<string, any>) => Promise<any>
  getCollection: (id: string | number) => Promise<any>
  saveCollection: (params: ICollectionPayload, id?: string | number) => Promise<any>
  deleteCollections: (ids: any[]) => Promise<any>
  deleteCollection: (id: string | number) => Promise<any>
  getWishlists: (params?: Record<string, any>) => Promise<any>
  getWishlistItems: (params?: Record<string, any>) => Promise<any>
  deleteCollectionItems: (collectionId: string | number, productId: string | number, variantId: string | number) => Promise<any>
  updateWishlistItem: (data: Record<string, any>) => Promise<any>
  getGuestWishlistProducts: (productIds: string[]) => Promise<any>
  updateWishlistItemPosition: (data: Record<string, any>) => Promise<any>
}

interface ICollections {
  total: number
  currentPage: number
  data: Record<string, any>
}

interface IRegistrySummary {
  id: number
  url_code: string
  status: string
  event_type: string
  event_date: string
  registrant_name: string
  public_url: string
}

interface ICollectionPayload {
  key: number | string
  user_id: number | string
  user_name?: string
  id: number
  name: string
  description: string
  status: TCollectionStatus
  is_default: boolean
  is_public: boolean
  url_code: string
  items: Record<string, any>
  emails: string[]
  user_ids: number[]
  allowed_roles: string[]
  allowed_edit_emails: string[]
  created_at?: string
  updated_at?: string
  registry?: IRegistrySummary | null
}

interface ICollectionItem {
  id: number
  product_id: number
  variant_id: number
  quantity: number
  priority: number
  notes: string | null
}

interface ICollectionProducts {
  total: number
  currentPage: number
  data: Record<string, any>
}

interface IProductsStore {
  productLists: Ref<IProducts>
  collectionProducts: Ref<ICollectionProducts>
  getProducts: (params?: Record<string, any>) => Promise<any>
  getCollectionProducts: (params?: Record<string, any>) => Promise<any>
}

interface IProducts {
  data: Record<string, any>
}

interface IUsersStore {
  users: Ref<IUsers>
  getUsers: (params?: Record<string, any>) => Promise<any>
}

interface IUsers {
  data: Record<string, any>
}

interface ImportSource {
  slug: string
  name: string
  icon: string
  version: string
  can_import: boolean
}

interface PreviewData {
  counts: {
    countFromSource: number
    wishlists: number
    items: number
    users: number
    guests: number
  }
  preview: Record<string, any>
}

interface ImportStats {
  wishlists_imported?: number
  items_imported?: number
  wishlists_skipped?: number
  items_skipped?: number
  users_affected?: number
  errors?: string[]
}