import { writable } from 'svelte/store';

const modfiles = [
  {
    name: 'UMMU',
    downloadUrl: 'UMMU.zip',
    videoUrl: 'https://www.youtube.com/watch?v=5fxjVo7KL1k',
    songUrl: 'https://www.youtube.com/watch?v=om5yLpQp748',
    imageUrl: 'assets/ummubg.png',
    pack: 'OISRT',
    packUrl: 'https://cloud.noti.tg/OISRT-Day2.zip',
    difficulties: [
      {
        type: 'challenge',
        rating: 10,
        intended: true,
        name: 'She',
      },
    ],
    order: 1,
  },
  {
    name: 'ihavesex',
    downloadUrl: 'ihavesex.zip',
    videoUrl: 'https://www.youtube.com/watch?v=s4fi_9KWyUg',
    songUrl: 'https://soundcloud.com/explorersoftheinternet/ihavesex',
    imageUrl: 'assets/sexbg.gif',
    difficulties: [
      {
        type: 'challenge',
        rating: 9,
        intended: true,
        name: 'oat',
      },
    ],
    order: 2,
  },
  {
    name: 'Easy Scapegoats',
    downloadUrl: 'Easy_Scapegoats.zip',
    videoUrl: 'https://www.youtube.com/watch?v=wgBfgmHU8F4',
    songUrl: 'https://soundcloud.com/discipleroundtable/easyscapegoats',
    imageUrl: 'assets/easyscapegoatsbg.png',
    difficulties: [
      {
        type: 'challenge',
        rating: 14,
        intended: true,
        name: 'oatmealbean',
      },
    ],
    order: 3,
  },
  {
    name: 'ONYON',
    downloadUrl: 'ONYON.zip',
    videoUrl: 'https://www.youtube.com/watch?v=fT0camVIR5w',
    songUrl: 'https://soundcloud.com/therealgpf/gpf-x-dj-onion-ft-the-greazy-elite-onyon',
    pack: 'Mod Rush Couples 2',
    flipColors: true,
    packUrl: 'https://drive.google.com/file/d/1okqcDiV09evIGp1hPktBHY5wjQfwZ2j7/edit',
    imageUrl: 'assets/onyonbg.png',
    difficulties: [
      {
        type: 'challenge',
        rating: 69,
        intended: true,
        name: '-YOSEFU- x Kirby5464 ft. oatmealine',
      },
    ],
    order: 4,
    collab: true,
    collabPartners: 'Kirby5464 and -YOSEFU-',
  },
  {
    name: 'How You Like That',
    subtitle: '(BilliumMoto Remix)',
    downloadUrl: 'How_You_Like_That.zip',
    videoUrl: 'https://www.youtube.com/watch?v=F4XyR-0PVOw',
    songUrl: 'https://soundcloud.com/billiummoto/how-you-like-that-remix',
    imageUrl: 'assets/howyoulikethatbg.png',
    pack: 'Mod Rush Couples 2',
    packUrl: 'https://drive.google.com/file/d/1okqcDiV09evIGp1hPktBHY5wjQfwZ2j7/edit',
    difficulties: [
      {
        type: 'expert',
        rating: 14,
        name: 'smaller gloop, less yoinky',
      },
      {
        type: 'challenge',
        rating: 14,
        intended: true,
        name: 'yasmeal64',
      },
    ],
    order: 5,
    collab: true,
    collabPartners: 'Yasmyn64',
  },
  {
    name: 'OBAMONSTA',
    downloadUrl: 'OBAMONSTA.zip',
    videoUrl: 'https://youtu.be/2IEXF7NLDr0',
    songUrl: 'https://www.youtube.com/watch?v=D64X-twhXE8',
    imageUrl: 'assets/obamabg.png',
    difficulties: [
      {
        type: 'expert',
        rating: 13,
        name: 'obamoat but not terrible',
      },
      {
        type: 'challenge',
        rating: 14,
        intended: true,
        name: 'obamoat',
      },
    ],
    order: 6,
  },
  {
    name: '#1f1e33',
    downloadUrl: '1f1e33.zip',
    videoUrl: 'https://www.youtube.com/watch?v=zB9_K9PnEkA',
    songUrl: 'https://www.youtube.com/watch?v=w4U9S5eX3eY',
    imageUrl: 'assets/1fbg.png',
    pack: 'White Elephant 2020',
    packUrl: 'https://www.dropbox.com/s/dcf4togg3a7kwby/Sea%20of%20Clouds%20White%20Elephant%202020.zip?dl=1',
    difficulties: [
      {
        type: 'challenge',
        rating: 14,
        name: 'oat channels her inner camellia',
        intended: true,
      }
    ],
    order: 7,
  },
  {
    name: 'Star Factory',
    downloadUrl: 'Star_Factory.zip',
    videoUrl: 'https://www.youtube.com/watch?v=51fOAHDnhVI',
    flipColors: true,
    songUrl: 'https://www.youtube.com/watch?v=nLMNkulQdkA',
    imageUrl: 'assets/starfactorybg.png',
    pack: 'Mod Rush 2',
    packUrl: 'https://www.dropbox.com/s/cjkh3h588ivurc7/Mod%20Rush%203.zip?dl=1',
    difficulties: [
      {
        type: 'challenge',
        rating: 12,
        name: 'poly-she',
        intended: true,
      },
      {
        type: 'edit',
        rating: 16,
        name: 'like 2 or so more steps (slumpo)'
      }
    ],
    order: 8,
  },
  {
    name: 'theyaremanycolors',
    downloadUrl: 'theyaremanycolors.zip',
    videoUrl: 'https://youtu.be/uUPKErc8WHI',
    songUrl: 'https://soundcloud.com/frums/theyaremanycolors',
    imageUrl: 'assets/colorsbg.png',
    pack: 'Mod Rush Couples',
    packUrl: 'https://drive.google.com/file/d/16mVwJh0pn-k43nCQQ_aWNrLrE3TOPXIm/view',
    difficulties: [
      {
        type: 'challenge',
        rating: 13,
        name: 'segoat',
        intended: true,
      }
    ],
    order: 9,
    collab: true,
    collabPartners: 'segaskulll',
  },
  {
    name: 'Fuck With The Baddest',
    downloadUrl: 'Fuck_With_The_Baddest.zip',
    videoUrl: 'https://youtu.be/w-5DSGOgpns',
    songUrl: 'https://soundcloud.com/gearbox-digital/anderex-expulze-the-baddest-preview-free-download',
    imageUrl: 'assets/fuckbg.png',
    pack: 'Mod Rush Couples',
    packUrl: 'https://drive.google.com/file/d/16mVwJh0pn-k43nCQQ_aWNrLrE3TOPXIm/view',
    difficulties: [
      {
        type: 'challenge',
        rating: 14,
        name: 'Kirby5464 + oatmealine',
        intended: true,
      }
    ],
    order: 10,
    collab: true,
    collabPartners: 'Kirby5464',
  },
  {
    name: 'Year of the Rats',
    downloadUrl: 'Year_of_the_Rats.zip',
    videoUrl: 'https://www.youtube.com/watch?v=7yib2XNfZjg',
    songUrl: 'https://www.youtube.com/watch?v=1_mZggt6aUg',
    flipColors: true,
    imageUrl: 'assets/ratbg.png',
    difficulties: [
      {
        type: 'challenge',
        rating: 12,
        name: 'oat learns how to ease',
        intended: true,
      }
    ],
    order: 10.5,
  },
  {
    name: 'Wake Up',
    downloadUrl: 'Wake_Up.zip',
    videoUrl: 'https://www.youtube.com/watch?v=2dJ0-cBcBvY',
    songUrl: 'https://soundcloud.com/frums/wake-up',
    imageUrl: 'assets/wakeupbg.png',
    difficulties: [
      {
        type: 'challenge',
        rating: 16,
        name: 'oat & rya',
        intended: true,
      },
      {
        type: 'edit',
        rating: 18,
        name: 'stuck in the nightmare (slump)'
      }
    ],
    order: 11,
    collab: true,
    collabPartners: 'Rya',
  },
  {
    name: 'if god didn\'t want us to snort worms he wouldn\'t have made them cylindrical!!!!!!!!',
    downloadUrl: 'igdwutswhwhmtc.zip',
    videoUrl: 'https://www.youtube.com/watch?v=jCz808VVk7Q',
    songUrl: 'https://mimideath.bandcamp.com/track/if-god-didnt-want-us-to-snort-worms-he-wouldnt-have-made-them-cylindrical',
    imageUrl: 'assets/wormsbg.png',
    difficulties: [
      {
        type: 'challenge',
        rating: 9,
        name: 'xeroOline',
        intended: true,
      }
    ],
    order: 12,
    collab: true,
    collabPartners: 'XeroOl',
  },
  {
    name: '745 sticky',
    subtitle: '(short ver)',
    downloadUrl: '745_sticky.zip',
    videoUrl: 'https://www.youtube.com/watch?v=HDiol53Vxyw',
    songUrl: 'https://100gecs.bandcamp.com/track/745-sticky',
    imageUrl: 'assets/745stickybg.png',
    pack: 'Mod Rush 2',
    packUrl: 'https://www.dropbox.com/s/c7tza0gyn2xph92/Mod%20Rush%202.zip?dl=1',
    difficulties: [
      {
        type: 'challenge',
        rating: 14,
        name: '100 oats',
        intended: true,
      }
    ],
    order: 13,
  },
  {
    name: 'Polish toilet spin basshunter ITG homosex K19191',
    subtitle: '(Po twojej pysznej zupie)',
    downloadUrl: 'Polish_toilet_spin.zip',
    videoUrl: 'https://www.youtube.com/watch?v=Npgz48I8lG8',
    imageUrl: 'assets/toiletbg.png',
    difficulties: [
      {
        type: 'challenge',
        rating: 14,
        name: 'oat + aiko',
        intended: true,
      }
    ],
    order: 13.5,
    collab: true,
    collabPartners: 'Aikoyori',
  },
  {
    name: 'Tung Tiied',
    subtitle: '(Anamana GAMERMEGAMIX)',
    downloadUrl: 'Tung_Tiied_GAMERMEGAMIX.zip',
    videoUrl: 'https://www.youtube.com/watch?v=53hUlR75UCg',
    imageUrl: 'assets/tungtiiedbg.png',
    difficulties: [
      {
        type: 'challenge',
        rating: 13,
        name: 'oat vs Rya',
        intended: true,
      },
      {
        type: 'edit',
        rating: 17,
        name: 'true gamer (Slumpage)'
      }
    ],
    order: 14,
    collab: true,
    collabPartners: 'Rya',
  },
  {
    name: 'thanks',
    downloadUrl: 'thanks.zip',
    videoUrl: 'https://www.youtube.com/watch?v=RaOgSS6pWpo',
    songUrl: 'https://pilotredsun.bandcamp.com/track/thanks',
    imageUrl: 'assets/thanksbg.png',
    difficulties: [
      {
        type: 'challenge',
        rating: 7,
        name: 'oat',
      },
      {
        type: 'edit',
        rating: 15,
        name: 'sluumpaage',
        intended: true,
      }
    ],
    order: 15,
  },
];

export let files = writable(modfiles);
export let sortMode = writable('Chronological');
export let sortingModes = ['Chronological', 'Alphabetical', 'Difficulty'];
export let groupsEnabled = writable([true, true]);
export let groups = ['Packs', 'Collabs'];

sortMode.subscribe(mode => {
  if (mode === 'Chronological') {
    files.update(f => f.sort((a, b) => a.order - b.order));
  } else if (mode === 'Alphabetical') {
    files.update(f => f.sort((a, b) => a.name.localeCompare(b.name)));
  } else if (mode === 'Difficulty') {
    files.update(f => f.sort((a, b) => a.difficulties.find(l => l.intended).rating - b.difficulties.find(l => l.intended).rating));
  }
});

export function sort(mode) {
  if (mode) {
    sortMode.set(mode);
  } else {
    sortMode.update(v => v);
  }
}

groupsEnabled.subscribe(v => {
  files.set(modfiles.filter(f => (f.pack ? v[0] : true) && (f.collab ? v[1] : true)));
  sort();
});