class ForumReplacementService < Service
  # Cool replacements we could eventually do not for pranking
  # [roll N] = random number between 1 and N
  # [roll N, M] = random number between N and M
  # [@reader] = username of the reader

  # NOTE: could do this shader style on word replacements if we want a ui :) [ReplacementList(color, replacements, &active?)]

  # blackout replacements
  FORBIDDEN_WORD_REPLACEMENTS = {
    
  }

  SPAM_WORD_REPLACEMENTS = {
    'cash app'          => 'pls ban me andrew',
    'cashapp'           => 'hey mr andrew come over here',
    'CBD gummies'       => 'andrew is coming to get me for spam'
  }

  # perspective changes, always surrounded by {} (e.g. {@reader} )
  PERSPECTIVE_REPLACEMENTS = {
    '@reader'           => Proc.new { |trigger, user| (user.nil? ? 'anonymous reader' : user.try(:display_name)) || 'anonymous reader' }
  }

  # turn on and off at will
  CASUAL_CHAOS_WORD_REPLACEMENTS = {
    'andrew'            => 'andrew (Our Supreme Lord and Overseer)',
    'amy'               => 'amy (the most wonderful woman in the world)',
    'gremlin'           => 'friend',
    'gremlins'          => 'friends',
  }

  REFERENCE_REPLACEMENTS = {
    # [[Character-4]]
  }

  # gremlin replacements
  GREMLINS_WORD_REPLACEMENTS = {
    '<3'                => "<span class='red-text'>&heart;</span>",
    '$5'                => '[̲̅$̲̅(̲̅5̲̅)̲̅$̲̅]',
    '0 Kelvin'          => 'absolute frosty',
    '0/10'              => '10/10',
    '1/10'              => '11/10',
    '2/10'              => '12/10',
    '24 hours'          => 'a full spin',
    '3/10'              => '13/10',
    '30 days'           => 'a moon routine',
    '365 days'          => 'a solar spin',
    '40 days and 40 nights' => 'a biblical raincheck',
    '50 percent'        => 'halfsies',
    '50%'               => 'halfsies',
    '6 hours'           => '1/4 of a day',
    '8 hours'           => '1/3 of a day',
    '10 hours'          => 'approximately 41.666666666667% of a day',
    '95 cents'          => 'Nickleback',
    'alarm clock'       => 'morning screamer',
    'algebra'           => 'mathematical checkmate',
    'alphabet'          => 'glyph-garland',
    'an hour'           => 'exactly 3600 seconds',
    'anthology'         => 'literary buffet',
    'announcement'      => 'shouty spouty',
    'announcements'     => 'shouty spouties',
    'anxiety'           => 'heebie jeebies',
    'anxieties'         => 'heebie jeebies',
    'april fools'       => 'just a regular saturday on this fine worldbuilding website',
    "April Fool's Day"  => 'the best holiday of the year',
    "April Fools Day"   => 'the best holiday of the year',
    'April 1'           => 'a better version of Christmas',
    'April first'       => 'the first day of Spring',
    'artist'            => 'colormancer',
    'artists'           => 'colormancers',
    'asap'              => 'as ASAP as possible',
    'askew'             => 'cattywampus',
    'astronaut'         => 'star-skipping space cowboy',
    'astronauts'        => 'star-skipping space cowboys',
    'author'            => 'word wrangler',
    'automatically'     => 'automagically',
    'avocado'           => '"avocado"',
    'aware'             => 'cognizant',
    'awesome'           => "bee's leghinges",
    'awkward'           => 'awk-weird',
    'backfired'         => 'went incredibly well',
    'baker'             => 'doughmancer',
    'bakers'            => 'doughmancers',
    'banana'            => 'yellow bent fruit',
    'bananas'           => 'yellow bent fruits',
    'baseball'          => 'throwing soccer',
    'basketball'        => 'dribbling soccer',
    'bathtub'           => 'personal puddle',
    'bear'              => '(ᵔᴥᵔ)',
    'beard'             => 'face mane',
    'bears'             => '(ᵔᴥᵔ)(ᵔᴥᵔ)',
    'beautiful'         => "<em>bonita</em>",
    'billion'           => 'giga-gob',
    'billions'          => 'giga-gobs',
    'bird'              => 'government spy drone',
    'birds'             => 'government spy drones',
    'black hole'        => 'timey-wimey space-gobbler',
    'black holes'       => 'timey-wimey space-gobblers',
    'blood'             => 'human syrup',
    'bone'              => 'calcium bodystick',
    'bones'             => 'calcium bodysticks',
    'book'              => 'grimoire',
    'bookmark'          => 'paper pause button',
    'books'             => 'grimoires',
    'boots'             => 'stompy weather clompers',
    'bored'             => 'in the doldrums',
    'bra'               => 'double foam dome',
    'brain'             => 'skull control',
    'brains'            => 'skull controls',
    'brainstorm'        => 'mind-blizzard',
    'brainstorms'       => 'mind-blizzards',
    'bread'             => 'bumberhooten flourknuckles',
    'breathe'           => 'consume oxygen to produce carbon dioxide',
    'breathing'         => 'consuming oxygen to produce carbon dioxide',
    'bridge'            => 'land-connector',
    'bulbasaur'         => 'the best starter Pokemon',
    'butter'            => 'bread moisturizer',
    'butterfly'         => 'flitter-flutter sky dancer',
    'butterflies'       => 'flitter-flutter sky dancers',
    'calendar'          => 'calender',
    'calculator'        => 'number cruncher',
    'candy'             => 'chocolate globbernaughts',
    'cancel culture'    => 'boo brigade',
    'caps lock'         => 'CRUISE CONTROL FOR COOL',
    'car'               => 'motorized rollingham',
    'carrot'            => 'snownose',
    'cars'              => 'motorized rollinghams',
    'cat'               => 'purr machine',
    'chef'              => 'flavor wizard',
    'cheese omelette'   => 'omelette du fromage',
    'cheeseburger'      => 'beef wellington ensemble with cheese',
    'cheeseburgers'     => 'beef wellington ensembles with cheese',
    'child'             => 'ankle-biter',
    'chopsticks'        => 'food-pinchers',
    'cliffhanger'       => 'tingly tension-teaser',
    'cliffhangers'      => 'tingly tension-teasers',
    'clock'             => 'Small Ben',
    'clocks'            => 'Small Bens',
    'coconut'           => 'hairy milk ball',
    'coldbrew'          => 'chill bean juice',
    'college'           => 'guild of scholars',
    'Coke'              => 'Pepsi',
    'coffee'            => 'bean soup',
    'confuse'           => 'bumfuzzle',
    'confused'          => 'bumfuzzled',
    'conspiracy'        => 'tinfoil tale',
    'cookie'            => 'naughty biscotti',
    'cookies'           => 'naughty biscottis',
    'crazy'             => 'bonkers',
    'cryptocurrency'    => 'digital doubloons',
    'dancer'            => 'rhythmancer',
    'dancers'           => 'rhythmancers',
    'debate'            => 'argumentative dance',
    'dinner'            => 'twilight munch',
    'DJ'                => 'beat wizard',
    'doctor'            => 'healing mage',
    'dog'               => 'barky zoom-bean',
    'dollar'            => 'gold coin',
    'dollars'           => 'gold coins',
    'dolphin'           => 'smiley splash-dog',
    'dolphins'          => 'smiley splash-dogs',
    'door'              => 'wobbly flip-shutter',
    'doorbell'          => 'chimey pushknob',
    'doorbells'         => 'chimey pushknobs',
    'doorknob'          => 'twisting plankhandle',
    'doorknobs'         => 'twisting plankhandles',
    'doors'             => 'wobbly flip-shutters',
    'dragon'            => "wizard lizard",
    'dragons'           => "wizard lizards",
    'editor'            => 'word surgeon',
    'escalator'         => 'upsy stairsy',
    'excited'           => 'jazzed',
    'exercise'          => 'training montage',
    'exhausted'         => 'wabbit knackered',
    'eye'               => 'peeper',
    'eyes'              => 'peepers',
    'eyo'               => '☜(⌒▽⌒)☞',
    'fake news'         => 'malarkey',
    'fancy'             => '<em>schmancy</em>',
    'farmer'            => 'earthtender',
    'feet'              => 'groundhands',
    'firefighter'       => 'waterbender',
    'fireflies'         => 'night-sky sparkle-warkers',
    'firefly'           => 'night-sky sparkle-warker',
    'firework'          => 'merry fizzlebomb',
    'fireworks'         => 'merry fizzlebombs',
    'flashlight'        => 'darkness destroyer',
    'foreshadow'        => 'plot peekaboo',
    'foreshadows'       => 'plot peekaboos',
    'fork'              => 'food trident',
    'fortnite'          => 'hippity buildershooter',
    'forums'            => 'words warehouse',
    'food'              => 'mandatory sustenance (like cheetos)',
    'foodie'            => 'goofy gourmand',
    'foot'              => 'groundhand',
    'football'          => 'soccer',
    'frog'              => 'diddly croaker',
    'funny'             => 'laffy taffy',
    'geese'             => 'chonky honkies',
    'geologist'         => 'rock-whisperer',
    'giraffe'           => 'wobbly longneck',
    'glasses'           => 'see-sharpeners',
    'glitter'           => 'permasprinkles',
    'good morning'      => 'Salutations from the Shire',
    'goose'             => 'chonky honky',
    'grass'             => 'earth fur',
    'gravy'             => 'meat water',
    'gun'               => 'rooty tooty point-n-shooty',
    'guns'              => 'rooty tooty point-n-shooties',
    'gym'               => 'strength chamber',
    'hamburger'         => 'beef wellington ensemble with lettuce',
    'hamburgers'        => 'beef wellington ensembles with lettuce',
    'hangover'          => 'booze bruise',
    'hell'              => 'heck',
    'hello'             => 'howdy, partner',
    'history'           => 'lastpast yesteryear',
    'hot chocolate'     => 'boiled chocowater',
    'ice cold'          => 'cooler than being cool',
    'ice cream'         => 'cream of eyes frosty',
    'idea'              => 'brain bubble',
    'ideas'             => 'brain bubbles',
    'influencer'        => 'meme merchant',
    'insect'            => 'motorized freckle',
    'insects'           => 'motorized freckles',
    'jelly'             => 'fruit spleggings',
    'kangaroo'          => 'hop pocket',
    'kangaroos'         => 'hop pockets',
    'Keanu Reeves'      => 'The One',
    'keyboard'          => 'hoighty toighty tippy typer',
    'keyboards'         => 'hoighty toighty tippy typers',
    'kidnap'            => 'surprise adoption',
    'knee'              => 'leghinge',
    'knees'             => 'leghinges',
    'knife'             => 'stabby stick',
    'knives'            => 'stabby sticks',
    'la croix'          => 'water that has been in the vicinity of a fruit at one point in the past few years',
    'ladies and gentlemen' => 'guys, gals, and non-binary pals',
    'laptop'            => 'portable meme machine',
    'lawyer'            => 'Master of Laws',
    'library'           => 'wisdom warehouse',
    'libraries'         => 'wisdom warehouses',
    'like and subscribe'=> 'thumb & bell ritual',
    'manuscript'        => 'treasure trove of words',
    'manuscripts'       => 'treasure troves of words',
    'Mario'             => "Luigi's larger brother",
    'math'              => 'numbermancy',
    'mathematician'     => 'numbermage',
    'meeting'           => 'council gathering',
    'meme'              => 'viral mindtickle',
    'memes'             => 'viral mindtickles',
    'meteorologist'     => 'weathermancer',
    'microscope'        => 'itty-bitty-see-er',
    'microscopes'       => 'itty-bitty-see-ers',
    'midnight snack'    => 'lunar nibble',
    'million'           => 'mega-bunch',
    'millions'          => 'mega-bunches',
    'milk'              => 'cow juice',
    'mischief'          => 'happy fun times',
    'mississippi'       => 'missississippi',
    'mistake'           => 'happy little accident',
    'mistakes'          => 'happy little accidents',
    'mitochondria'      => 'the powerhouse of the cell',
    'mittens'           => 'hand socks',
    'money'             => 'mint cheddar',
    'moon'              => "nocturnal cheese wheel",
    'murder'            => 'mucduc',
    'musician'          => 'melodymancer',
    'musicians'         => 'melodymancers',
    'nebula'            => 'stardust nursery',
    'nebulas'           => 'stardust nurseries',
    'nice'              => 'noice',
    'night'             => 'moonlit hours',
    'novel'             => 'fiction depiction',
    'novels'            => 'fiction depictions',
    'oh no'             => '<img src="http://2.bp.blogspot.com/_izy_T_tOZXY/SZwImBbXL8I/AAAAAAAABy4/FEEkvPJAD4g/s320/Kool-Aid.jpg" />',
    'ohio'              => 'the Nether',
    'oof'               => '<marquee>oooooooooooooooooooooooooooooooooooooof</marquee>',
    'oven'              => 'boiler-broiler roasty-toasty',
    'ovens'             => 'boiler-broiler roasty-toasties',
    'owo'               => '(◕‿◕✿)',
    'oxymoron'          => 'jumbo shrimp of words',
    'painter'           => 'hueweaver',
    'painters'          => 'hueweavers',
    'pajamas'           => 'snooze suit',
    'pancake'           => 'roundy-yum',
    'pancakes'          => 'roundy-yums',
    'parasol'           => 'rainbrella',
    'password'          => 'secret handshake',
    'passwords'         => 'secret handshakes',
    'pen'               => 'whimsy flimsy mark and scribbler',
    'pencil'            => 'leady spaghetti',
    'penguin'           => 'wobble-waddler',
    'penguins'          => 'wobble-waddlers',
    'pens'              => 'whimsy flimsy mark and scribblers',
    'pepsi'             => 'Coke',
    'philosopher'       => 'thoughtsmith',
    'pie'               => 'solid soup',
    'pizza'             => 'crispy flap disc',
    'plant mom'         => 'chlorophyll guardian',
    'plant moms'         => 'chlorophyll guardians',
    'pluto'             => "lil' wannaplanet",
    'polar bear'        => 'snow-floof',
    'polar bears'       => 'snow-floofs',
    'politician'        => 'pactweaver',
    'poem'              => 'emotion potion',
    'poet'              => 'verse virtuoso',
    'popsicle'          => 'cold on the cob',
    'porcelain'         => 'toilet material',
    'potato'            => 'blimey ground apple',
    'prankster'         => 'funny-gunny laugh-a-tonny',
    'psychiatrist'      => 'mindmender',
    'raccoon'           => 'trash burgler',
    'rain'              => 'cloud juice',
    'reality'           => 'high-res hallucination',
    'recursion'         => 'recursion',
    'reverse'           => 'esrever',
    'road'              => 'cobble-stone-clippity-clop',
    'roads'             => 'cobble-stone-clippity-clops',
    'rocking chair'     => 'knitter-sitter',
    'rocking chairs'    => 'knitter-sitters',
    'roleplayer'        => 'fantasy fabricator',
    'roleplayers'       => 'fantasy fabricators',
    'room'              => 'human containment unit',
    'salad'             => 'crunchy medley',
    'same'              => 'same',
    'sandwich'          => 'breadystack',
    'sandwiches'        => 'breadystacks',
    'Scoliosis'         => 'wiggly spine',
    'scream'            => 'loudy shouty',
    'scrolling'         => 'vertically surfing through a screen',
    'see you later'     => 'fare thee well on thy quest',
    'selfie'            => 'solo photoshoot',
    'sex'               => '<sm>yiffy wiffy</sm>',
    'shrimp'            => 'chill krill',
    'shrimps'           => 'chill krills',
    'skydiving'         => 'falling out of the sky',
    'smol'              => '<span style="font-size: 5px">smol</span>',
    'snake'             => 'slippery dippery long mover',
    'snakes'            => 'slippery dippery long movers',
    'snail'             => 'slime racer',
    'snails'            => 'slime racers',
    'snow'              => 'sky frosting',
    'snowman'           => 'temporary ice friend',
    'sparkle'           => '<span style="color: pink; text-shadow: 0 0 3px #FF00FF">sparkle</span>',
    'spider'            => 'crawler octobrawler',
    'spiders'           => 'crawler octobrawlers',
    'spoon'             => 'soup-scooper',
    'stairs'            => 'broken escalator',
    'Stardew Valley'    => 'Farming Simulator 2016',
    'stupid'            => 'stoopid',
    'sunrise'           => "dawn's daily debut",
    'sunset'            => 'skylight twilight',
    'sup'               => 'soup',
    'sword'             => 'silver stabby-wabby',
    'swords'            => 'silver stabby-wabbies',
    'tadpole'           => 'baby wiggle-swimmer',
    'tadpoles'          => 'baby wiggle-swimmers',
    'tall'              => 'giraffy',
    'taxation'          => 'theft',
    'tea'               => 'elixir of tranquility',
    'teeth'             => 'mouthstones',
    'the day after tomorrow' => 'overmorrow',
    'three days ago'    => 'a thousand years after 365,003 days ago',
    'tissue'            => 'sneezepaper',
    'tissues'           => 'sneezepapers',
    'tomorrow'          => 'the day before overmorrow',
    'tonight'           => 'the night after last night',
    'tooth'             => 'mouthstone',
    'toothbrush'        => 'bitey whitey wand',
    'trampoline'        => 'boingy-sproingy',
    'trampolines'       => 'boingy-sproingies',
    'tree'              => 'leafy tower',
    'trick'             => 'bamboozle',
    'tricked'           => 'bamboozled',
    'trolling'          => 'cyberjesting',
    'two days ago'      => 'ereyesterday',
    'two days from today' => 'overmorrow',
    'two weeks'         => 'a fortnight',
    'university'        => 'guild of scholars',
    'uwu'               => '(｡◕‿‿◕｡)',
    'vegetable'         => 'earth candy',
    'vegetables'        => 'earth candies',
    'volcano'           => 'angry earth-pimple',
    'volcanoes'         => 'angry earth-pimples',
    'wand'              => 'rowdy spouty point-n-shouty',
    'wands'             => 'rowdy spouty point-n-shouties',
    'wasp'              => 'flying stingywingy',
    'wasps'             => 'flying stingywingies',
    'wednesday'         => 'wendsday',
    'weird'             => 'wonky-donky',
    'whale'             => 'blubberbutt watermutt',
    'whales'            => 'blubberbutt watermutts',
    'wheeze'            => 'sneeze',
    'wheezing'          => 'sneezing',
    'why is everyone yelling' => 'why is everyone yelling<span style="text-transform:uppercase">',
    'window'            => 'see-through wall',
    'worm'              => 'wriggly wiggly',
    "writer's block"    => 'imagination traffic jam',
    'wrong'             => '<strike>right</strike>',
    'wordsmith'         => 'wodsmith',
    'x.com'             => 'twitter',
    'xylophone'         => 'tinkly tonk plonker',
    'xylophones'        => 'tinkly tonk plonkers',
    'year'              => 'orbit party',
    'years'             => 'orbit parties',
    'yeet'              => 'defenestrate',
    'yoga'              => 'bendy business',
    'yuge'              => '<span style="font-size: 40px">yuge</span>',
    'zalgo'             => 'H̶̛̼̼̪̝̞͓̞͕͇̯͚͎͚̘̳͕̱̤̠̗͔͇̙̣̰͓̖̰̯̀̓̐̑̇͊͂̀͋̒̐̓͒̒͊͊̕͜͝ͅE̴̡̧̨̨̲̥̯͎̭̻̩̞̘̞̪̞̗̭͖̻͙͕͎̮͕̺͕̲̘̻̣͚̳̥͍̙͈͚͍͉̗͙̱͖͚̾̂̇͛̉͋͊̾͛̆̀́͑͛̅̋͊̕͘͜͜͜͝ͅͅͅͅ ̸̡̡̨̡̨̛̞͎̹̩̬̗̗̞̬̰̮̙̪̖͈̣̹͔̺̫̰̓̔̉̋̈̈́͐́̿̈̀͊̿̈̉̅̃̊̽͗̈̿̈́̓̈́̎͌̄̀̆̌̎͗̋͒̋̿̋̊̈́͆̋̾̈̏̈́̋̿̕̕̚͝͝͠͠ͅͅͅC̵̛̘̳͙̪̭͖̲̞̯̰̜͇̈̾̈́͋̌̉̽̽͑̎͌̾̈́͌̑͊̊̔̀͆̌̀̇̓͊̀̂̇̿̃͑́̈́̆͂̈́̾̓́̂̂̓̂̍̍͛͆͌͌̽̎̍̀̒̆̀͗͋͘͘͘͝͠͝͝͠͝͝Ǫ̸͕̻̞̝̜͚̗̮̼͎̤͔̤̱͔̫͂̄̉̋̈͊͐͂̇̀̌̎́͑̐̀̈́͋̓̾̅͒̒̄͑̒̆̑̾͜͝͝͝͝M̷̧̧̡̨̛̛̩̭̞͍̼̝̗͕̖͇̣̣̩͆̿̑͒́̉̅̓̌̆̈́͐͒̾̐̂̿̓̚͘̚͜E̵̡̨̢̧̢̢̡̢̨̛̠̱̻̺̦͚̹͓̬͔̪̟̼̥̯̠̘͚̫̯͍̺͔̫̟͇̱̦̟̪͚͉̣̳͓͍̬̙̲͔̘͙͔̤̰̜͍̠̩͉͐̂̊̏̐̿̊̋͑̿̇̊̈́͗̎̋́́̉̓̂̐͑̇̐̐͋́̒̈́͛͑͒̂͒̂̔̀̄̈́̓͂͆̈́͒̌͆̓͗̋͐̔̑͐̕͘ͅͅͅŞ̴̧̧̡̢̧̡̢͕̝͚̝̖͚̣̞̫̻̯͔̳̗̝̰̗̰̰̥̭͕̜̜̫͍̪̳̘̣̺̠͉̗̟͕̹͇̬̘̘̪͆͗̎̕',
    'antagonist'        => 'plot troublemaker',
    'character arc'     => 'protagonist pilgrimage',
    'dialogue'          => 'character ping-pong',
    'epilogue'          => 'literary afterparty',
    'exposition'        => 'backstory breadcrumbs',
    'first draft'       => 'word vomit masterpiece',
    'flashback'         => 'temporal boomerang',
    'literary device'   => 'wordsmith multitool',
    'narrative'         => 'tale trajectory',
    'plot hole'         => 'story oopsie',
    'plot twist'        => 'narrative pretzel',
    'prologue'          => 'story appetizer',
    'protagonist'       => 'trouble magnet',
    'subplot'           => 'story side quest',
    'afternoon'         => 'post-meridian jaunt',
    'constellation'     => 'connect-the-stars doodle',
    'dimension'         => 'reality flavor',
    'galaxy'            => 'cosmic spiraly-whirly',
    'gravity'           => 'universal clingy-ness',
    'infinity'          => 'endless et cetera',
    'light year'        => 'space marathon',
    'parallel universe' => 'reality neighbor',
    'quantum physics'   => 'subatomic tomfoolery',
    'anti-hero'         => 'morally flexible protagonist',
    'mentor'            => 'wisdom dispenser',
    'artificial intelligence' => 'silicon smartypants',
    'social media'      => 'digital popularity contest',
    'streaming service' => 'endless content waterfall',
    'viral'             => 'internet famous adjacent',
    'Wi-Fi'             => 'invisible knowledge tubes',
    'footnote'          => 'page whisper',
    'hypothesis'        => 'educated guess-timate',
    'peer review'       => 'academic fact-checking party',
    'autocorrect'       => 'automated word mangler',
    'backspace'         => 'letter eating key',
    'font'              => 'letter costume',
    'grammar checker'   => 'sentence referee',
    'spell check'       => 'typo detective',
    'word count'        => 'verbose-o-meter',
    'epiphany'          => 'brain lightning',
    'existential crisis' => 'reality maintenance check',
    'inspiration'       => 'creativity lightning strike',
    'procrastination'   => 'productive avoidance',
    'writers block'     => 'creativity traffic jam',
    'fantasy'           => 'dragons-and-magic soup',
    'horror'            => 'spooky word collection',
    'romance'           => 'heart-squeezy tale',
    'science fiction'   => 'future speculation story',
    'consciousness'     => 'reality subscription service',
    'philosophy'        => 'professional pondering',
  }

  OVERLOAD_WORDS_REPLACEMENTS = {
    'alligator'             => 'swamp chomper',
    'alligators'            => 'swamp chompers',
    'apron'                 => 'chef armor',
    'arm'                   => 'grabby limb',
    'arms'                  => 'grabby limbs',
    'babe'                  => 'bae',
    'bad'                   => 'bodge',
    'backfired'             => 'went incredibly well',
    'beard'                 => 'face rug',
    'beards'                => 'face rugs',
    'bicycle'               => 'pedal-horse',
    'bicycles'              => 'pedal-horses',
    'blushes'               => 'pees a little',
    'bruno'                 => 'he who shall not be talked about',
    'boot'                  => 'foot helmet',
    'boots'                 => 'foot helmets',
    'bubble'                => "b<sup><sup>u</sup></sup>bble",
    'bubbles'               => "b<sup><sup>u</sup></sup>bbles",
    'buddy'                 => 'pal',
    'buddies'               => 'pals',
    'butterfly'             => 'flutterby',
    'butterflies'           => 'flutterbies',
    'cat'                   => 'meow machine',
    'cats'                  => 'meow machines',
    'chair'                 => 'butt holder',
    'chaos'                 => 'peace',
    'cheesecake'            => 'sweet cheese solid soup',
    'crab'                  => 'beach pincher',
    'crabs'                 => 'beach pinchers',
    'crocodile'             => 'scaly swimmer',
    'crocodiles'            => 'scaly swimmers',
    'corrupted'             => 'improved',
    'cowboy'                => 'colorado desparado',
    'cowboys'               => 'colorado desparados',
    'cupcake'               => 'frostytop',
    'cupcakes'              => 'frostytops',
    'curling iron'          => 'medieval torture device',
    'dance'                 => 'little ditty',
    'dishwasher'            => 'plate jacuzzi',
    'fishing'               => 'fish kidnapping',
    'flamingo'              => 'pink standy bird',
    'flamingos'             => 'pink standy birds',
    'flipflops'             => 'slappy sandals',
    'glove'                 => 'hand sock',
    'gloves'                => 'hand socks',
    'g r e m l i n s'       => 'f r i e n d s',
    'guitar'                => 'strumma-plucka',
    'guitars'               => 'strumma-pluckas',
    'hairbrush'             => 'tangle tamer',
    'hairbrushes'           => 'tangle tamers',
    'hat'                   => 'head lid',
    'hats'                  => 'head lids',
    'highlighted'           => 'becoming better',
    'hippo'                 => 'water chonk',
    'hippos'                => 'water chonks',
    'horrible prank'        => 'horrible prank <em>',
    'honey'                 => 'bee syrup',
    'hot dog'               => 'tube steak',
    'hot dogs'              => 'tube steaks',
    'hug'                   => 'glomp',
    'hugs'                  => 'glomps',
    'iceberg'               => 'frozen floaty',
    'icebergs'              => 'frozen floaties',
    'iguana'                => 'scaly lounge lizard',
    'iguanas'               => 'scaly lounge lizards',
    'insurance'             => 'the biggest scam known to man',
    'internet'              => 'series of electrotubes',
    'irl'                   => 'in meatspace',
    'lemonade'              => 'sour drank',
    'kill'                  => 'deathsnuggle',
    'over here'             => 'hither',
    'penguin'               => 'formal chicken',
    'penguins'              => 'formal chickens',
    'piano'                 => 'tinkle-tapper',
    'Pokeball'              => 'Prisonball',
    'recruit'               => 'kidnap',
    'sacred summoning wods' => "According to all known laws of aviation, there is no way a bee should be able to fly. Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway because bees don't care what humans think is impossible.",
    'salamander'            => 'baby dragon',
    'screwdriver'           => 'pip pip gollywock',
    'soul'                  => 'inner ghost',
    'subtext'               => '<sub>text</sub>',
    'squirrel'              => 'nut bandit',
    'squirrels'             => 'nut bandits',
    'straw'                 => 'sippy stick',
    'straws'                => 'sippy sticks',
    'taco'                  => 'vertical sandwich',
    'tacos'                 => 'vertical sandwiches',
    'tired'                 => 'on low battery',
    'thinking'              => 'brain brewing',
    'traffic jam'           => 'car mosh pit',
    'midnight'              => 'dayover',
    'mountain'              => 'earth pimple',
    'mountains'             => 'earth pimples',
    'muffin'                => 'cakelet',
    'muffins'               => 'cakelets',
    'nacho'                 => 'cheesy triangle',
    'online'                => 'on the interwebs',
    'pajamas'               => 'nighty-suit',
    'rule'                  => 'law you must obey',
    'rules'                 => 'laws you must obey',
    'running'               => 'pacing the race',
    'vampire'               => '✨vampire✨',
    'vampires'              => '✨vampires✨',
    'voldemort'             => 'he who shall not be named',
    'video'                 => 'series of images played in rapid succession to give the illusion of movement on a static screen',
    'volleyball'            => 'beach air soccer',
    'why is this happening' => 'I think this is great',
    'word'                  => 'wod',
    'words'                 => 'wods',
    'working'               => 'grinding gears',
    'xylophone'             => 'ding-a-ling bar',
    'xylophones'            => 'ding-a-ling bars',
    'yelling'               => 'raising decibels',
  }

  def self.replace_for(text, user)
    gremlins_phase = 0
    replaced_text = text.dup

    # Page tag replacements
    replaced_text = ContentFormatterService.substitute_content_links(
      replaced_text,
      user
    )

    SPAM_WORD_REPLACEMENTS.each do |trigger, replacement|
      replaced_text.gsub!(/\b#{trigger.downcase}\b/i, wrapped(replacement, trigger, 'red'))
    end

    PERSPECTIVE_REPLACEMENTS.each do |trigger, replacement|
      replaced_text.gsub!(/{#{trigger.downcase}}/i, wrapped(replacement.call(trigger, user), trigger, 'blue'))
    end

    if true # not implemented: [[Character-123]] or https://www.notebook.ai/plan/characters/553 etc
      replaced_text.gsub!(/>https?:\/\/(?:www\.)?(?:(?:\w)+\.)?notebook\.ai\/plan\/([\w]+)\/([\d]+)</).each do |match|
        klass = $1.singularize.titleize

        linkable_whitelist = Rails.application.config.content_type_names[:all]
        if linkable_whitelist.include? klass
          token = {
            content_type:   klass,
            content_id:     $2.to_i,
            matched_string: "Invalid #{klass}"
          }
          replacement = ContentFormatterService.replacement_for_token(token, User.new)
          ">#{replacement}<"
        else
          match
        end
      end
    end

    if gremlins_phase >= 1
      CASUAL_CHAOS_WORD_REPLACEMENTS.each do |trigger, replacement|
        replaced_text.gsub!(/\b#{trigger.downcase}\b/i, wrapped(replacement, trigger, 'green'))
      end
    end

    if gremlins_phase >= 2
      GREMLINS_WORD_REPLACEMENTS.each do |trigger, replacement|
        replaced_text.gsub!(/\b#{trigger.downcase}\b/i, wrapped(replacement, trigger, 'green'))
      end
    end

    if gremlins_phase >= 3
      OVERLOAD_WORDS_REPLACEMENTS.each do |trigger, replacement|
        replaced_text.gsub!(/\b#{trigger.downcase}\b/i, wrapped(replacement, trigger, 'green'))
      end
    end

    replaced_text.html_safe
  end

  def self.wrapped(text, tooltip, color='blue')
    "<span class='#{color} lighten-5 tooltipped black-text' style='padding: 4px' data-tooltip='#{tooltip}'>#{text}</span>"
  end
end
