/**
 * List of valid NIPs from https://github.com/nostr-protocol/nips
 * Includes both numeric (01-99) and hexadecimal (7D, A0, etc.) identifiers
 */
/**
 * Deprecated NIPs that are no longer recommended for use
 */
export const DEPRECATED_NIPS = ["04", "08", "26", "96"] as const;

export const VALID_NIPS = [
  // Numeric NIPs
  "01",
  "02",
  "03",
  "04",
  "05",
  "06",
  "07",
  "08",
  "09",
  "10",
  "11",
  "13",
  "14",
  "15",
  "17",
  "18",
  "19",
  "21",
  "22",
  "23",
  "24",
  "25",
  "26",
  "27",
  "28",
  "29",
  "30",
  "31",
  "32",
  "34",
  "35",
  "36",
  "37",
  "38",
  "39",
  "40",
  "42",
  "43",
  "44",
  "45",
  "46",
  "47",
  "48",
  "49",
  "50",
  "51",
  "52",
  "53",
  "54",
  "55",
  "56",
  "57",
  "58",
  "59",
  "60",
  "61",
  "62",
  "64",
  "65",
  "66",
  "68",
  "69",
  "70",
  "71",
  "72",
  "73",
  "75",
  "77",
  "78",
  "84",
  "86",
  "87",
  "88",
  "89",
  "90",
  "92",
  "94",
  "96",
  "98",
  "99",
  // Hexadecimal NIPs
  "7D",
  "A0",
  "B0",
  "B7",
  "BE",
  "C0",
  "C7",
  "EE",
] as const;

export type NipId = (typeof VALID_NIPS)[number];

/**
 * NIP titles from https://github.com/nostr-protocol/nips
 */
export const NIP_TITLES: Record<string, string> = {
  "01": "Basic protocol flow description",
  "02": "Follow List",
  "03": "OpenTimestamps Attestations for Events",
  "04": "Encrypted Direct Message",
  "05": "Mapping Nostr keys to DNS-based internet identifiers",
  "06": "Basic key derivation from mnemonic seed phrase",
  "07": "window.nostr capability for web browsers",
  "08": "Handling Mentions",
  "09": "Event Deletion Request",
  "10": "Text Notes and Threads",
  "11": "Relay Information Document",
  "13": "Proof of Work",
  "14": "Subject tag in text events",
  "15": "Nostr Marketplace",
  "17": "Private Direct Messages",
  "18": "Reposts",
  "19": "bech32-encoded entities",
  "21": "nostr: URI scheme",
  "22": "Comment",
  "23": "Long-form Content",
  "24": "Extra metadata fields and tags",
  "25": "Reactions",
  "26": "Delegated Event Signing",
  "27": "Text Note References",
  "28": "Public Chat",
  "29": "Relay-based Groups",
  "30": "Custom Emoji",
  "31": "Dealing with Unknown Events",
  "32": "Labeling",
  "34": "git stuff",
  "35": "Torrents",
  "36": "Sensitive Content",
  "37": "Draft Events",
  "38": "User Statuses",
  "39": "External Identities in Profiles",
  "40": "Expiration Timestamp",
  "42": "Authentication of clients to relays",
  "43": "Relay Access Metadata and Requests",
  "44": "Encrypted Payloads (Versioned)",
  "45": "Counting results",
  "46": "Nostr Remote Signing",
  "47": "Nostr Wallet Connect",
  "48": "Proxy Tags",
  "49": "Private Key Encryption",
  "50": "Search Capability",
  "51": "Lists",
  "52": "Calendar Events",
  "53": "Live Activities",
  "54": "Wiki",
  "55": "Android Signer Application",
  "56": "Reporting",
  "57": "Lightning Zaps",
  "58": "Badges",
  "59": "Gift Wrap",
  "60": "Cashu Wallet",
  "61": "Nutzaps",
  "62": "Request to Vanish",
  "64": "Chess (PGN)",
  "65": "Relay List Metadata",
  "66": "Relay Discovery and Liveness Monitoring",
  "68": "Picture-first feeds",
  "69": "Peer-to-peer Order events",
  "70": "Protected Events",
  "71": "Video Events",
  "72": "Moderated Communities",
  "73": "External Content IDs",
  "75": "Zap Goals",
  "77": "Negentropy Syncing",
  "78": "Application-specific data",
  "7D": "Threads",
  "84": "Highlights",
  "86": "Relay Management API",
  "87": "Ecash Mint Discoverability",
  "88": "Polls",
  "89": "Recommended Application Handlers",
  "90": "Data Vending Machines",
  "92": "Media Attachments",
  "94": "File Metadata",
  "96": "HTTP File Storage Integration",
  "98": "HTTP Auth",
  "99": "Classified Listings",
  A0: "Voice Messages",
  B0: "Web Bookmarks",
  B7: "Blossom",
  BE: "Nostr BLE Communications Protocol",
  C0: "Code Snippets",
  C7: "Chats",
  EE: "E2EE Messaging using MLS Protocol",
};

export const NIP_REPO_RAW_URL =
  "https://raw.githubusercontent.com/nostr-protocol/nips/master";

export function getNipUrl(nipId: string): string {
  return `${NIP_REPO_RAW_URL}/${nipId}.md`;
}

export function getNipTitle(nipId: string): string {
  return NIP_TITLES[nipId] || `NIP-${nipId}`;
}

export function isNipDeprecated(nipId: string): boolean {
  return DEPRECATED_NIPS.includes(nipId as any);
}
