export type MallItemType = 'skin' | 'room_decor';

export interface MallCatalogItem {
  itemId: string;
  itemType: MallItemType;
  skinId?: string;
  decorId?: string;
  icon?: string;
  name: string;
  category: string;
  description: string;
  price: number;
  tags: string[];
  sortOrder: number;
}

export const MALL_CATEGORIES = [
  { id: 'recommended', label: '推荐', icon: 'recommended' },
  { id: 'outfit', label: '装扮', icon: 'outfit' },
  { id: 'items', label: '道具', icon: 'items' },
  { id: 'companion', label: '伙伴', icon: 'companion' },
  { id: 'space', label: '空间', icon: 'space' },
  { id: 'limited', label: '限时', icon: 'limited' },
];

export const MALL_ITEMS: MallCatalogItem[] = [
  {
    itemId: 'skin_classic_whale',
    itemType: 'skin',
    skinId: 'classic_whale',
    name: '经典鲸鱼',
    category: 'outfit',
    description: '圆润、轻快的鲸鱼居民皮肤，适合喜欢海洋感角色的玩家。',
    price: 680,
    tags: ['可预览', '永久', '皮肤'],
    sortOrder: 10,
  },
  {
    itemId: 'skin_human_whale_directional_v2_8x4',
    itemType: 'skin',
    skinId: 'human_whale_directional_v2_8x4',
    name: '海风行者',
    category: 'outfit',
    description: '蓝白海风主题的人类角色皮肤，带有鲸鱼小镇风格的服装细节。',
    price: 680,
    tags: ['可预览', '永久', '皮肤'],
    sortOrder: 20,
  },
  {
    itemId: 'skin_girl_sailor_turnaround_v2_8x4',
    itemType: 'skin',
    skinId: 'girl_sailor_turnaround_v2_8x4',
    name: '海风少女',
    category: 'outfit',
    description: '水手风格的人类角色皮肤，适合轻松、清爽的 WhaleTown 日常。',
    price: 880,
    tags: ['可预览', '永久', '皮肤'],
    sortOrder: 30,
  },
  {
    itemId: 'skin_panda_hero_8x4',
    itemType: 'skin',
    skinId: 'panda_hero_8x4',
    icon: 'res://assets/ui/mall/skins/panda_hero_8x4_product.png',
    name: '熊猫侠',
    category: 'outfit',
    description: '黑白连帽外观的人类角色皮肤，四方向8帧动作，适合想要更鲜明角色辨识度的玩家。',
    price: 980,
    tags: ['可预览', '永久', '皮肤'],
    sortOrder: 40,
  },
  {
    itemId: 'skin_ordinary_man_male_8x4',
    itemType: 'skin',
    skinId: 'ordinary_man_male_8x4',
    icon: 'res://assets/ui/mall/skins/ordinary_man_male_8x4_product.png',
    name: '普通人(男)',
    category: 'outfit',
    description: '男性日常角色皮肤，四方向8帧动作，适合普通玩家形象。',
    price: 980,
    tags: ['可预览', '永久', '皮肤'],
    sortOrder: 50,
  },
  {
    itemId: 'decor_whale_floor_rug',
    itemType: 'room_decor',
    decorId: 'whale_floor_rug',
    icon: 'res://assets/ui/mall/items/room_decor_whale_floor_rug.png',
    name: '鲸浪地毯',
    category: 'space',
    description: '蓝白鲸鱼主题地毯，适合铺在个人房间地板区域。',
    price: 260,
    tags: ['房间家具', '可拖拽', '地面'],
    sortOrder: 110,
  },
  {
    itemId: 'decor_whale_memory_board',
    itemType: 'room_decor',
    decorId: 'whale_memory_board',
    icon: 'res://assets/ui/mall/items/room_decor_whale_memory_board.png',
    name: '鲸语记忆板',
    category: 'space',
    description: '挂在房间里的鲸鱼木质装饰板，适合点缀窗边墙面。',
    price: 220,
    tags: ['房间家具', '可拖拽', '挂件'],
    sortOrder: 120,
  },
  {
    itemId: 'decor_whale_tail_lamp',
    itemType: 'room_decor',
    decorId: 'whale_tail_lamp',
    icon: 'res://assets/ui/mall/items/room_decor_whale_tail_lamp.png',
    name: '鲸尾暖灯',
    category: 'space',
    description: '鲸尾造型的温暖装饰灯，可自由摆放在个人房间中。',
    price: 360,
    tags: ['房间家具', '可拖拽', '灯具'],
    sortOrder: 130,
  },
  {
    itemId: 'decor_boat_cabin_bed',
    itemType: 'room_decor',
    decorId: 'boat_cabin_bed',
    icon: 'res://assets/ui/mall/items/room_decor_boat_cabin_bed.png',
    name: '船舱小床',
    category: 'space',
    description: '白木船舱造型的小床，适合放在个人房间地面区域。',
    price: 520,
    tags: ['房间家具', '可拖拽', '床'],
    sortOrder: 140,
  },
  {
    itemId: 'decor_low_wave_bed',
    itemType: 'room_decor',
    decorId: 'low_wave_bed',
    icon: 'res://assets/ui/mall/items/room_decor_low_wave_bed.png',
    name: '海浪低床',
    category: 'space',
    description: '蓝白海浪被面的低矮小床，适合轻松的海风房间。',
    price: 500,
    tags: ['房间家具', '可拖拽', '床'],
    sortOrder: 150,
  },
  {
    itemId: 'decor_whale_tail_headboard_bed',
    itemType: 'room_decor',
    decorId: 'whale_tail_headboard_bed',
    icon: 'res://assets/ui/mall/items/room_decor_whale_tail_headboard_bed.png',
    name: '鲸尾床头床',
    category: 'space',
    description: '鲸尾床头和深蓝被面的主题小床，鲸镇特色更明显。',
    price: 580,
    tags: ['房间家具', '可拖拽', '床'],
    sortOrder: 180,
  },
  {
    itemId: 'decor_dev_whale_bookshelf',
    itemType: 'room_decor',
    decorId: 'dev_whale_bookshelf',
    icon: 'res://assets/ui/mall/items/room_decor_dev_whale_bookshelf.png',
    name: '程序员鲸书架',
    category: 'space',
    description: '带 GitHub、Datawhale 和代码小物件的蓝白书架，适合程序员风格的个人房间。',
    price: 620,
    tags: ['房间家具', '可拖拽', '书架'],
    sortOrder: 190,
  },
  {
    itemId: 'decor_datawhale_bug_feature_badge',
    itemType: 'room_decor',
    decorId: 'datawhale_bug_feature_badge',
    icon: 'res://assets/ui/mall/items/room_decor_datawhale_bug_feature_badge.png',
    name: 'BUG特性徽章',
    category: 'space',
    description: '写着“这不是BUG 这是feature”的佛系学习小徽章，适合贴在个人房间墙面。',
    price: 120,
    tags: ['房间家具', '可拖拽', '徽章'],
    sortOrder: 200,
  },
  {
    itemId: 'decor_datawhale_buddhist_learning_badge',
    itemType: 'room_decor',
    decorId: 'datawhale_buddhist_learning_badge',
    icon: 'res://assets/ui/mall/items/room_decor_datawhale_buddhist_learning_badge.png',
    name: '佛系学习徽章',
    category: 'space',
    description: 'Datawhale 佛系学习主题徽章，适合贴在个人房间墙面。',
    price: 140,
    tags: ['房间家具', '可拖拽', '徽章'],
    sortOrder: 210,
  },
  {
    itemId: 'decor_datawhale_ok_working_badge',
    itemType: 'room_decor',
    decorId: 'datawhale_ok_working_badge',
    icon: 'res://assets/ui/mall/items/room_decor_datawhale_ok_working_badge.png',
    name: '已经在做徽章',
    category: 'space',
    description: '写着“OKKKK 已经在做了”的工作状态徽章，适合贴在个人房间墙面。',
    price: 120,
    tags: ['房间家具', '可拖拽', '徽章'],
    sortOrder: 220,
  },
];

export const MALL_SKIN_ITEMS = MALL_ITEMS.filter((item) => item.itemType === 'skin' && item.skinId);

export function findMallItem(itemId?: string): MallCatalogItem | undefined {
  const normalizedItemId = (itemId || '').trim();
  return MALL_ITEMS.find((item) => normalizedItemId && item.itemId === normalizedItemId);
}

export function findMallSkinItem(itemId?: string): MallCatalogItem | undefined {
  const item = findMallItem(itemId);
  return item?.itemType === 'skin' && item.skinId ? item : undefined;
}
