import { defineStore } from 'pinia';

export interface ReferenceEntry {
  id: number;
  title: string;
  category: string;
  tags?: string[];
  subtitle?: string;
  content: string;
}

function getSampleData(): ReferenceEntry[] {
  return [
    {
      id: 1,
      title: 'J/27 Background',
      category: 'general',
      tags: ['j27', 'info'],
      subtitle: 'Fast Fun Racer or Getaway Weekend Cruiser',
      content: `Its hard to imagine that a modern 27 foot sailboat with a classic look, superb
      stability, and easy to manage rig is such a fast boat. 123-126 PHRF. No longer do you
      have to substitute speed for comfort, or own separate boats for racing and cruising. The
      8' long cockpit seats 4 to 5 comfortably. Below deck you can sleep 5. And with head and
      stove, the J/27 is the perfect weekend cruiser.

      Fun and Fast. There are some impressive victories to back this up, but that doesn't
      tell the whole story. The J/27 is fun and responsive. Nothing is more exhilarating than
      popping the J/27's kite in a good breeze for a downhill sleigh ride. 15+ knots planing
      off the wave-tops is easy. And most importantly, this off-wind speed doesn't sacrifice
      upwind performance. Going to windward in the J/27 is a dream, it has the solid, balanced
      "feel" of a traditional keelboat. The J/27 points higher and goes faster than many 30-35
      footers!

      One-Design Racing. Even more fun is sailing a one-design race around the buoys. The
      J/27's close-windedness makes it very tactical, as even 5 degree wind shifts bring
      significant gains. Then off wind, you quickly learn to play gibe angles as the boat's
      acceleration gains you valuable ground on the competition. The J/27 is remarkably agile
      and responsive in lighter winds, which is unusual for a boat that feels so solid.

      All-Day Comfort. Sailing past larger boats is always satisfying... especially when it's
      effortless and you can't be written off as being wet and uncomfortable. Design is the
      difference. It's all done from a cockpit which holds several people more than is possible
      on other 27-footers. Correctly angled backrests and decks at elbow level provide restful
      and secure seating. Harken mainsheet, vang, traveler, and backstay systems; four Barient
      winches; a beautiful double spreader, tapered, fractional rig spar by Hall . . . make
      control and adjustment easy for crew members no matter what the wind.

      Get-away Weekend Cruiser. Take a break from the pace of life on land and spend time with
      family and friends sailing the J/27. It's a fun boat to sail, so everyone becomes involved.

      The visibility, when steering with a responsive tiller gives the inexperienced that sense
      of control not found when spinning a tiny wheel on small cruisers with large trunk cabins.

      The J/27 has a comfortable, open interior in teak with off-white surfaces. A main structural
      fiberglass bulkhead with oval opening separates the spacious double V-berth and head area
      from the main cabin. The main settee berth converts to a double. Aft of the galley to
      starboard is a comfortable quarter berth. Enough room below for a family of four or a
      couple for a nice weekend romp to your favorite sailing anchorage.

      Durable and Stable. The J/27's secure big boat feel is created by concentrating 1530
      pounds of lead very low in the keel while using high strength to eight ratio laminates
      in the hull. Unidirectional E-glass on either side of pre-sealed Baltek CK57 aircraft
      grade, Lloyd's approved, end grain balsa sandwich construction means superior torsion and
      impact resistance. Light ends, low freeboard, and the low center of gravity of a lead keel
      coupled with low wetted surface and a generous sailplan of 362 sq. ft. achieves exceptional
      sail area and stability relative to displacement. Hence, sparkling performance in both
      light and heavy air...something that doesn't happen with iron keels and box-like hulls.

      Strong Class Strict Rules. The J/27 Class Association, owner driven and over 190 boats
      strong, sail in North American, Midwinter, and Regional championships. A superb J/27 Class
      Newsletter keeps you up-to-date on Class activities, latest results, maintenance tips,
      cruising points of interest, and "go-fasts". And the J/27 Class Rules have sail limitations
      to help insure equal performance and resale value. The Class supports both the active
      racer and cruising sailor in addition to fleets throughout the U.S.`,
    },
    {
      id: 2,
      title: 'Capri25 Background',
      category: 'general',
      tags: ['capri25', 'info'],
      subtitle: 'The Capri 25 (by Catalina) is nothing like a Catalina 25',
      content: `The Capri 25 (by Catalina) is nothing like a Catalina 25 ... The Capri
      is five inches shorter on deck, three feet shorter on the waterline, and weighs
      almost 1,400 pounds less than the Catalina, so we suppose you could call her a Catalina
      "Lite," especially since her towing weight is over a ton less, so you can use a smaller,
      lighter towing vehicle on the highway. Besides her lower weight, she has slightly more
      sail area and a sleeker fin keel, so she is also faster—way faster. In fact, her average
      PHRF rating is 171, which is, amazingly, 3 seconds per mile less than the legendary J/24,
      and a whopping 54 seconds less than the Catalina 25. Needless to say, part of her weight
      loss is accomplished by the omission of cabin furniture and other niceties like the
      Catalina's on-deck anchor locker. Other weight saving is achieved by eliminating 600
      pounds of ballast, and by using a then-new material, Coremat, to replace some of the
      hull and deck laminate. Best features: If you like round-the-buoys racing and/or
      socializing in a one-design fleet, this may be the boat for you. She has a bit more space
      below than a J/24, and six inches more headroom, but otherwise her character is in the
      same range. Worst features: Nothing significant noticed."`,
    },
    {
      id: 3,
      title: 'Outboard Engine Operation',
      subtitle: 'An overview of how outboard engines work.',
      category: 'howto',
      tags: ['manuals', 'howto', 'engine'],
      content: 'Lorem ipsum dolor met.',
    },
  ] as ReferenceEntry[];
}

export const useReferenceStore = defineStore('reference', {
  state: () => ({
    allItems: getSampleData(),
  }),

  getters: {
    getCategory(state) {
      return (category: string) => {
        return state.allItems.filter((c) => c.category === category);
      };
    },
  },

  actions: {},
});
