{
  "schema": 1,
  "id": "ext.discord",
  "name": "Discord Rich Presence",
  "version": "1.0.2",
  "category": "tool",
  "description": "Shows in Discord what you are working on: file, project, language and duration, with idle detection, private projects and a repository button. Ships with program code.",
  "author": "Lumen",
  "icon": "DC",
  "color": "#5865f2",
  "license": "MIT",
  "minAppVersion": "0.5.0",
  "keywords": [
    "discord",
    "rich presence",
    "presence",
    "status",
    "rpc"
  ],
  "readme": "# Discord Rich Presence\n\nShows in your Discord profile what you are working on in Lumen — *Editing\nMain.java*, *in my-project*, the language as an image and how long you have\nbeen at it.\n\nThe extension talks to the Discord client running on your machine directly\n(its local IPC socket `discord-ipc-N`, Flatpak and Snap included, or the named\npipe on Windows). Nothing is sent anywhere else. Discord accepts about one\nupdate every 15 seconds; changes in between are gathered, and with Discord\nclosed the extension quietly tries again later.\n\n> Brings program code: Lumen asks before installing it and runs it in its main\n> process.\n\n## Setup\n\nIt works out of the box with Lumen's own Discord application. To show a name\nof your own (“Playing …”), create an application at\n[discord.com/developers](https://discord.com/developers/applications) and put\nits *Application ID* into *Settings → Extensions → Discord Rich Presence*.\nUpload art assets named after the language ids (`java`, `typescript`,\n`python` …) and one called `lumen`.\n\n## Settings\n\n| Setting | What it does |\n| --- | --- |\n| Client ID | The Discord application; empty means no connection |\n| File name, project, language, elapsed time | Each can be switched off |\n| Count time from | Lumen's start, opening the project or switching to the file |\n| “View repository” button | Links the project's `origin` remote, credentials stripped — for public repositories only |\n| Idle after (minutes) | Minutes without window focus until Lumen counts as idle; `0` turns it off |\n| When idle | Show the idle text, or clear the presence altogether |\n| Idle text | Shown when idle or when no file is open |\n| In private projects | Hide file and project names, or show nothing at all |\n| Private folders | Absolute paths, one per line; projects inside count as private |\n\n## Commands\n\n- **Discord: Reconnect** — rebuilds the connection at once (also a click on\n  the *Discord* entry in the status bar, which shows whether it is connected).\n- **Discord: Enable / Disable / Toggle Rich Presence** — remembered across\n  restarts.\n- **Discord: Toggle Private Project** — marks the open project as private (or\n  not). In private projects no names and no repository link reach Discord.\n\n## Formerly built in\n\nLumen used to ship Discord Rich Presence as a bundled add-on (`tool.discord`).\nIt now lives here; its settings do not carry over — the defaults match the old\nones.\n",
  "settings": [
    {
      "key": "clientId",
      "label": "Client ID (Application ID)",
      "type": "text",
      "default": "1550197013260275863",
      "placeholder": "123456789012345678",
      "hint": "The application whose name appears in Discord as “Playing …”. Create your own at discord.com/developers; its art assets are named after the language IDs (java, typescript …) plus lumen. Empty = no connection.",
      "section": "Connection",
      "i18n": {
        "es": {
          "label": "ID de cliente (Application ID)",
          "hint": "La aplicación cuyo nombre aparece en Discord como «Jugando a …». Crea la tuya en discord.com/developers; sus imágenes se llaman como los ID de lenguaje (java, typescript …) más lumen. Vacío = sin conexión.",
          "section": "Conexión"
        },
        "fr": {
          "label": "ID client (Application ID)",
          "hint": "L’application dont le nom apparaît dans Discord comme « Joue à … ». Créez la vôtre sur discord.com/developers ; ses images portent le nom des ID de langage (java, typescript …) plus lumen. Vide = aucune connexion.",
          "section": "Connexion"
        },
        "pl": {
          "label": "ID klienta (Application ID)",
          "hint": "Aplikacja, której nazwa pojawia się w Discordzie jako „Gra w …”. Własną utworzysz na discord.com/developers; jej obrazy nazywają się jak identyfikatory języków (java, typescript …) oraz lumen. Puste = brak połączenia.",
          "section": "Połączenie"
        },
        "it": {
          "label": "ID client (Application ID)",
          "hint": "L’applicazione il cui nome compare su Discord come “Sta giocando a …”. Creane una tua su discord.com/developers; le sue immagini si chiamano come gli ID dei linguaggi (java, typescript …) più lumen. Vuoto = nessuna connessione.",
          "section": "Connessione"
        },
        "pt": {
          "label": "ID do cliente (Application ID)",
          "hint": "A aplicação cujo nome aparece no Discord como “Jogando …”. Crie a sua em discord.com/developers; as imagens têm o nome dos IDs de linguagem (java, typescript …) mais lumen. Vazio = sem conexão.",
          "section": "Conexão"
        },
        "nl": {
          "label": "Client-ID (Application ID)",
          "hint": "De applicatie waarvan de naam in Discord verschijnt als „Speelt …”. Maak je eigen aan op discord.com/developers; de afbeeldingen heten zoals de taal-ID’s (java, typescript …) plus lumen. Leeg = geen verbinding.",
          "section": "Verbinding"
        }
      }
    },
    {
      "key": "showFileName",
      "label": "File name",
      "type": "toggle",
      "default": "true",
      "section": "Shown in Discord",
      "i18n": {
        "es": {
          "label": "Nombre de archivo",
          "section": "Se muestra"
        },
        "fr": {
          "label": "Nom du fichier",
          "section": "Affiché"
        },
        "pl": {
          "label": "Nazwa pliku",
          "section": "Pokazywane"
        },
        "it": {
          "label": "Nome del file",
          "section": "Mostrato"
        },
        "pt": {
          "label": "Nome do arquivo",
          "section": "Exibido"
        },
        "nl": {
          "label": "Bestandsnaam",
          "section": "Getoond"
        }
      }
    },
    {
      "key": "showProject",
      "label": "Project",
      "type": "toggle",
      "default": "true",
      "section": "Shown in Discord",
      "i18n": {
        "es": {
          "label": "Proyecto",
          "section": "Se muestra"
        },
        "fr": {
          "label": "Projet",
          "section": "Affiché"
        },
        "pl": {
          "label": "Projekt",
          "section": "Pokazywane"
        },
        "it": {
          "label": "Progetto",
          "section": "Mostrato"
        },
        "pt": {
          "label": "Projeto",
          "section": "Exibido"
        },
        "nl": {
          "label": "Project",
          "section": "Getoond"
        }
      }
    },
    {
      "key": "showLanguage",
      "label": "Language (as image)",
      "type": "toggle",
      "default": "true",
      "section": "Shown in Discord",
      "i18n": {
        "es": {
          "label": "Lenguaje (como imagen)",
          "section": "Se muestra"
        },
        "fr": {
          "label": "Langage (en image)",
          "section": "Affiché"
        },
        "pl": {
          "label": "Język (jako obraz)",
          "section": "Pokazywane"
        },
        "it": {
          "label": "Linguaggio (come immagine)",
          "section": "Mostrato"
        },
        "pt": {
          "label": "Linguagem (como imagem)",
          "section": "Exibido"
        },
        "nl": {
          "label": "Taal (als afbeelding)",
          "section": "Getoond"
        }
      }
    },
    {
      "key": "showElapsed",
      "label": "Elapsed time",
      "type": "toggle",
      "default": "true",
      "section": "Shown in Discord",
      "i18n": {
        "es": {
          "label": "Tiempo transcurrido",
          "section": "Se muestra"
        },
        "fr": {
          "label": "Temps écoulé",
          "section": "Affiché"
        },
        "pl": {
          "label": "Upływający czas",
          "section": "Pokazywane"
        },
        "it": {
          "label": "Tempo trascorso",
          "section": "Mostrato"
        },
        "pt": {
          "label": "Tempo decorrido",
          "section": "Exibido"
        },
        "nl": {
          "label": "Verstreken tijd",
          "section": "Getoond"
        }
      }
    },
    {
      "key": "elapsedFrom",
      "label": "Count time from",
      "type": "select",
      "default": "session",
      "when": "showElapsed",
      "section": "Shown in Discord",
      "choices": [
        {
          "value": "session",
          "label": "Lumen’s start"
        },
        {
          "value": "project",
          "label": "Opening the project"
        },
        {
          "value": "file",
          "label": "Switching to the file"
        }
      ],
      "i18n": {
        "es": {
          "label": "Contar el tiempo desde",
          "section": "Se muestra",
          "choices": {
            "session": "el inicio de Lumen",
            "project": "la apertura del proyecto",
            "file": "el cambio al archivo"
          }
        },
        "fr": {
          "label": "Compter le temps depuis",
          "section": "Affiché",
          "choices": {
            "session": "le démarrage de Lumen",
            "project": "l’ouverture du projet",
            "file": "le passage au fichier"
          }
        },
        "pl": {
          "label": "Licz czas od",
          "section": "Pokazywane",
          "choices": {
            "session": "uruchomienia Lumen",
            "project": "otwarcia projektu",
            "file": "przełączenia na plik"
          }
        },
        "it": {
          "label": "Conta il tempo da",
          "section": "Mostrato",
          "choices": {
            "session": "l’avvio di Lumen",
            "project": "l’apertura del progetto",
            "file": "il passaggio al file"
          }
        },
        "pt": {
          "label": "Contar o tempo desde",
          "section": "Exibido",
          "choices": {
            "session": "o início do Lumen",
            "project": "a abertura do projeto",
            "file": "a troca para o arquivo"
          }
        },
        "nl": {
          "label": "Tijd tellen vanaf",
          "section": "Getoond",
          "choices": {
            "session": "de start van Lumen",
            "project": "het openen van het project",
            "file": "het wisselen naar het bestand"
          }
        }
      }
    },
    {
      "key": "repoButton",
      "label": "“View repository” button",
      "type": "toggle",
      "default": "false",
      "hint": "Links the project’s origin remote (without credentials). Only turn on for public repositories.",
      "section": "Shown in Discord",
      "i18n": {
        "es": {
          "label": "Botón «Ver repositorio»",
          "hint": "Enlaza el remoto origin del proyecto (sin credenciales). Actívalo solo para repositorios públicos.",
          "section": "Se muestra"
        },
        "fr": {
          "label": "Bouton « Voir le dépôt »",
          "hint": "Pointe vers le remote origin du projet (sans identifiants). À activer uniquement pour les dépôts publics.",
          "section": "Affiché"
        },
        "pl": {
          "label": "Przycisk „Zobacz repozytorium”",
          "hint": "Linkuje do zdalnego origin projektu (bez danych logowania). Włączaj tylko dla publicznych repozytoriów.",
          "section": "Pokazywane"
        },
        "it": {
          "label": "Pulsante “Vedi repository”",
          "hint": "Collega il remote origin del progetto (senza credenziali). Attivalo solo per repository pubblici.",
          "section": "Mostrato"
        },
        "pt": {
          "label": "Botão “Ver repositório”",
          "hint": "Aponta para o remoto origin do projeto (sem credenciais). Ligue apenas para repositórios públicos.",
          "section": "Exibido"
        },
        "nl": {
          "label": "Knop „Repository bekijken”",
          "hint": "Linkt naar de origin-remote van het project (zonder inloggegevens). Alleen aanzetten voor openbare repository’s.",
          "section": "Getoond"
        }
      }
    },
    {
      "key": "idleMinutes",
      "label": "Idle after (minutes without focus)",
      "type": "number",
      "default": "5",
      "min": 0,
      "max": 240,
      "step": 1,
      "hint": "0 turns idle detection off.",
      "section": "Idle",
      "i18n": {
        "es": {
          "label": "Inactivo tras (minutos sin foco)",
          "hint": "0 desactiva la detección de inactividad.",
          "section": "Inactividad"
        },
        "fr": {
          "label": "Inactif après (minutes sans focus)",
          "hint": "0 désactive la détection d’inactivité.",
          "section": "Inactivité"
        },
        "pl": {
          "label": "Bezczynność po (minutach bez fokusu)",
          "hint": "0 wyłącza wykrywanie bezczynności.",
          "section": "Bezczynność"
        },
        "it": {
          "label": "Inattivo dopo (minuti senza focus)",
          "hint": "0 disattiva il rilevamento dell’inattività.",
          "section": "Inattività"
        },
        "pt": {
          "label": "Ocioso após (minutos sem foco)",
          "hint": "0 desliga a detecção de ociosidade.",
          "section": "Ociosidade"
        },
        "nl": {
          "label": "Inactief na (minuten zonder focus)",
          "hint": "0 schakelt inactiviteitsdetectie uit.",
          "section": "Inactiviteit"
        }
      }
    },
    {
      "key": "idleAction",
      "label": "When idle",
      "type": "select",
      "default": "idle",
      "section": "Idle",
      "choices": [
        {
          "value": "idle",
          "label": "Show the idle text"
        },
        {
          "value": "clear",
          "label": "Show nothing"
        }
      ],
      "i18n": {
        "es": {
          "label": "Al estar inactivo",
          "section": "Inactividad",
          "choices": {
            "idle": "Mostrar el texto de inactividad",
            "clear": "No mostrar nada"
          }
        },
        "fr": {
          "label": "En cas d’inactivité",
          "section": "Inactivité",
          "choices": {
            "idle": "Afficher le texte d’inactivité",
            "clear": "Ne rien afficher"
          }
        },
        "pl": {
          "label": "Podczas bezczynności",
          "section": "Bezczynność",
          "choices": {
            "idle": "Pokaż tekst bezczynności",
            "clear": "Nic nie pokazuj"
          }
        },
        "it": {
          "label": "In caso di inattività",
          "section": "Inattività",
          "choices": {
            "idle": "Mostra il testo di inattività",
            "clear": "Non mostrare nulla"
          }
        },
        "pt": {
          "label": "Quando ocioso",
          "section": "Ociosidade",
          "choices": {
            "idle": "Mostrar o texto de ociosidade",
            "clear": "Não mostrar nada"
          }
        },
        "nl": {
          "label": "Bij inactiviteit",
          "section": "Inactiviteit",
          "choices": {
            "idle": "Inactiviteitstekst tonen",
            "clear": "Niets tonen"
          }
        }
      }
    },
    {
      "key": "idleText",
      "label": "Idle text",
      "type": "text",
      "default": "",
      "placeholder": "Idle",
      "hint": "Shown when idle and when no file is open. Empty = default text.",
      "section": "Idle",
      "i18n": {
        "es": {
          "label": "Texto de inactividad",
          "hint": "Se muestra en inactividad y sin archivo abierto. Vacío = texto predeterminado.",
          "placeholder": "Inactivo",
          "section": "Inactividad"
        },
        "fr": {
          "label": "Texte d’inactivité",
          "hint": "Affiché en cas d’inactivité et sans fichier ouvert. Vide = texte par défaut.",
          "placeholder": "Inactif",
          "section": "Inactivité"
        },
        "pl": {
          "label": "Tekst bezczynności",
          "hint": "Pokazywany podczas bezczynności i bez otwartego pliku. Puste = tekst domyślny.",
          "placeholder": "Bezczynny",
          "section": "Bezczynność"
        },
        "it": {
          "label": "Testo di inattività",
          "hint": "Mostrato in caso di inattività e senza file aperto. Vuoto = testo predefinito.",
          "placeholder": "Inattivo",
          "section": "Inattività"
        },
        "pt": {
          "label": "Texto de ociosidade",
          "hint": "Exibido quando ocioso e sem arquivo aberto. Vazio = texto padrão.",
          "placeholder": "Ocioso",
          "section": "Ociosidade"
        },
        "nl": {
          "label": "Inactiviteitstekst",
          "hint": "Getoond bij inactiviteit en zonder geopend bestand. Leeg = standaardtekst.",
          "placeholder": "Inactief",
          "section": "Inactiviteit"
        }
      }
    },
    {
      "key": "privateMode",
      "label": "In private projects",
      "type": "select",
      "default": "names",
      "hint": "Mark a project private with “Discord: Toggle Private Project” or the list below.",
      "section": "Privacy",
      "choices": [
        {
          "value": "names",
          "label": "Hide file and project names"
        },
        {
          "value": "hide",
          "label": "Show nothing at all"
        }
      ],
      "i18n": {
        "es": {
          "label": "En proyectos privados",
          "hint": "Marca un proyecto como privado con «Discord: Alternar proyecto privado» o con la lista de abajo.",
          "section": "Privacidad",
          "choices": {
            "names": "Ocultar nombres de archivo y proyecto",
            "hide": "No mostrar nada"
          }
        },
        "fr": {
          "label": "Dans les projets privés",
          "hint": "Rendez un projet privé avec « Discord : Basculer le projet privé » ou la liste ci-dessous.",
          "section": "Confidentialité",
          "choices": {
            "names": "Masquer les noms de fichier et de projet",
            "hide": "Ne rien afficher du tout"
          }
        },
        "pl": {
          "label": "W prywatnych projektach",
          "hint": "Oznacz projekt jako prywatny poleceniem „Discord: Przełącz projekt prywatny” lub listą poniżej.",
          "section": "Prywatność",
          "choices": {
            "names": "Ukryj nazwy plików i projektu",
            "hide": "Nie pokazuj niczego"
          }
        },
        "it": {
          "label": "Nei progetti privati",
          "hint": "Rendi privato un progetto con “Discord: Attiva/disattiva progetto privato” o con l’elenco qui sotto.",
          "section": "Privacy",
          "choices": {
            "names": "Nascondi i nomi di file e progetto",
            "hide": "Non mostrare nulla"
          }
        },
        "pt": {
          "label": "Em projetos privados",
          "hint": "Marque um projeto como privado com “Discord: Alternar projeto privado” ou com a lista abaixo.",
          "section": "Privacidade",
          "choices": {
            "names": "Ocultar nomes de arquivo e projeto",
            "hide": "Não mostrar nada"
          }
        },
        "nl": {
          "label": "In privéprojecten",
          "hint": "Maak een project privé met „Discord: Privéproject wisselen” of met de lijst hieronder.",
          "section": "Privacy",
          "choices": {
            "names": "Bestands- en projectnamen verbergen",
            "hide": "Helemaal niets tonen"
          }
        }
      }
    },
    {
      "key": "privateProjects",
      "label": "Private folders",
      "type": "textarea",
      "default": "",
      "rows": 3,
      "placeholder": "/home/me/work",
      "hint": "One absolute path per line; projects inside count as private.",
      "section": "Privacy",
      "i18n": {
        "es": {
          "label": "Carpetas privadas",
          "hint": "Una ruta absoluta por línea; los proyectos dentro se consideran privados.",
          "placeholder": "/home/yo/trabajo",
          "section": "Privacidad"
        },
        "fr": {
          "label": "Dossiers privés",
          "hint": "Un chemin absolu par ligne ; les projets qu’il contient sont considérés comme privés.",
          "placeholder": "/home/moi/travail",
          "section": "Confidentialité"
        },
        "pl": {
          "label": "Prywatne foldery",
          "hint": "Jedna ścieżka bezwzględna na wiersz; projekty w środku są prywatne.",
          "placeholder": "/home/ja/praca",
          "section": "Prywatność"
        },
        "it": {
          "label": "Cartelle private",
          "hint": "Un percorso assoluto per riga; i progetti al suo interno sono privati.",
          "placeholder": "/home/io/lavoro",
          "section": "Privacy"
        },
        "pt": {
          "label": "Pastas privadas",
          "hint": "Um caminho absoluto por linha; os projetos dentro contam como privados.",
          "placeholder": "/home/eu/trabalho",
          "section": "Privacidade"
        },
        "nl": {
          "label": "Privémappen",
          "hint": "Eén absoluut pad per regel; projecten daarin gelden als privé.",
          "placeholder": "/home/ik/werk",
          "section": "Privacy"
        }
      }
    }
  ],
  "pages": [],
  "agents": [],
  "views": [],
  "commands": [
    {
      "id": "discord.reconnect",
      "title": "Discord: Reconnect",
      "category": "Discord",
      "icon": "refresh-cw",
      "i18n": {
        "es": {
          "title": "Discord: Reconectar"
        },
        "fr": {
          "title": "Discord : Se reconnecter"
        },
        "pl": {
          "title": "Discord: Połącz ponownie"
        },
        "it": {
          "title": "Discord: Riconnetti"
        },
        "pt": {
          "title": "Discord: Reconectar"
        },
        "nl": {
          "title": "Discord: Opnieuw verbinden"
        }
      }
    },
    {
      "id": "discord.enable",
      "title": "Discord: Enable Rich Presence",
      "category": "Discord",
      "icon": "play",
      "i18n": {
        "es": {
          "title": "Discord: Activar Rich Presence"
        },
        "fr": {
          "title": "Discord : Activer la Rich Presence"
        },
        "pl": {
          "title": "Discord: Włącz Rich Presence"
        },
        "it": {
          "title": "Discord: Attiva Rich Presence"
        },
        "pt": {
          "title": "Discord: Ligar Rich Presence"
        },
        "nl": {
          "title": "Discord: Rich Presence aanzetten"
        }
      }
    },
    {
      "id": "discord.disable",
      "title": "Discord: Disable Rich Presence",
      "category": "Discord",
      "icon": "pause",
      "i18n": {
        "es": {
          "title": "Discord: Desactivar Rich Presence"
        },
        "fr": {
          "title": "Discord : Désactiver la Rich Presence"
        },
        "pl": {
          "title": "Discord: Wyłącz Rich Presence"
        },
        "it": {
          "title": "Discord: Disattiva Rich Presence"
        },
        "pt": {
          "title": "Discord: Desligar Rich Presence"
        },
        "nl": {
          "title": "Discord: Rich Presence uitzetten"
        }
      }
    },
    {
      "id": "discord.toggle",
      "title": "Discord: Toggle Rich Presence",
      "category": "Discord",
      "icon": "messages",
      "i18n": {
        "es": {
          "title": "Discord: Alternar Rich Presence"
        },
        "fr": {
          "title": "Discord : Basculer la Rich Presence"
        },
        "pl": {
          "title": "Discord: Przełącz Rich Presence"
        },
        "it": {
          "title": "Discord: Attiva/disattiva Rich Presence"
        },
        "pt": {
          "title": "Discord: Alternar Rich Presence"
        },
        "nl": {
          "title": "Discord: Rich Presence wisselen"
        }
      }
    },
    {
      "id": "discord.toggle-private",
      "title": "Discord: Toggle Private Project",
      "category": "Discord",
      "icon": "eye-off",
      "i18n": {
        "es": {
          "title": "Discord: Alternar proyecto privado"
        },
        "fr": {
          "title": "Discord : Basculer le projet privé"
        },
        "pl": {
          "title": "Discord: Przełącz projekt prywatny"
        },
        "it": {
          "title": "Discord: Attiva/disattiva progetto privato"
        },
        "pt": {
          "title": "Discord: Alternar projeto privado"
        },
        "nl": {
          "title": "Discord: Privéproject wisselen"
        }
      }
    }
  ],
  "code": {
    "main": "import { createRequire as __lumenRequire } from 'node:module'; const require = __lumenRequire(import.meta.url);\nimport Y from\"node:fs/promises\";import Z from\"node:path\";import{createConnection as O}from\"node:net\";import{randomUUID as P}from\"node:crypto\";import w from\"node:path\";var C=0,D=1,_=2,z=3,L=4;var B=1024*1024;function h(t,e){let i=Buffer.from(JSON.stringify(e??{}),\"utf8\"),n=Buffer.alloc(8);return n.writeInt32LE(t,0),n.writeInt32LE(i.length,4),Buffer.concat([n,i])}function N(t){let e=[],i=0;for(;t.length-i>=8;){let n=t.readUInt32LE(i),r=t.readUInt32LE(i+4);if(t.length-i-8<r)break;let o=t.subarray(i+8,i+8+r).toString(\"utf8\");i+=8+r,e.push({op:n,data:F(o)})}return{frames:e,rest:t.subarray(i)}}function F(t){try{return JSON.parse(t)}catch{return null}}function U(t=process.platform,e=process.env){let i=Array.from({length:10},(o,s)=>s);if(t===\"win32\")return i.map(o=>`\\\\\\\\?\\\\pipe\\\\discord-ipc-${o}`);let n=e.XDG_RUNTIME_DIR||e.TMPDIR||e.TMP||e.TEMP||\"/tmp\",r=i.map(o=>w.join(n,`discord-ipc-${o}`));if(!e.XDG_RUNTIME_DIR)return r;for(let o of[\"app/com.discordapp.Discord\",\"snap.discord\"])for(let s of i)r.push(w.join(e.XDG_RUNTIME_DIR,o,`discord-ipc-${s}`));return r}var a=t=>typeof t==\"object\"&&t!==null&&!Array.isArray(t);var f=class{constructor(e={}){this.throttleMs=e.throttleMs??15e3,this.retryMs=e.retryMs??15e3,this.maxRetryMs=e.maxRetryMs??6e4,this.handshakeTimeoutMs=e.handshakeTimeoutMs??1e4,this.socketPaths=e.socketPaths??(()=>U()),this.onStatus=e.onStatus??(()=>{}),this.log=e.log??(i=>console.warn(`[discord] ${i}`)),this.pid=e.pid??process.pid,this.clientId=\"\",this.socket=null,this.buffer=Buffer.alloc(0),this.ready=!1,this.pending=void 0,this.lastSentJson=null,this.lastSentAt=0,this.nextRetryMs=this.retryMs,this.retryTimer=null,this.throttleTimer=null,this.handshakeTimer=null,this.current={state:\"disconnected\"},this.lastLogged=\"\",this.attempt=0,this.connecting=!1}status(){return this.current}update(e,i){let n=String(e??\"\").trim();if(!n||i===null){this.stop();return}if(n!==this.clientId&&(this.stop(),this.clientId=n),this.pending=i,this.socket){this.flush();return}this.retryTimer||this.connecting||this.connect()}reconnect(){if(this.nextRetryMs=this.retryMs,this.clearRetry(),this.dropSocket(),!this.clientId||!this.pending){this.setStatus({state:\"disconnected\"});return}this.connect()}stop(){this.pending=void 0,this.clearRetry(),this.clearThrottle();let e=this.socket;e&&this.ready&&!e.destroyed&&e.end(h(D,{cmd:\"SET_ACTIVITY\",args:{pid:this.pid,activity:null},nonce:P()})),this.dropSocket(),this.nextRetryMs=this.retryMs,this.setStatus({state:\"disconnected\"})}setStatus(e){let i=e.state===this.current.state&&e.message===this.current.message&&e.user===this.current.user;this.current=e,!i&&this.onStatus(e)}logOnce(e){e!==this.lastLogged&&(this.lastLogged=e,this.log(e))}clearRetry(){this.retryTimer&&(clearTimeout(this.retryTimer),this.retryTimer=null)}clearThrottle(){this.throttleTimer&&(clearTimeout(this.throttleTimer),this.throttleTimer=null)}clearHandshake(){this.handshakeTimer&&(clearTimeout(this.handshakeTimer),this.handshakeTimer=null)}dropSocket(){this.attempt++,this.connecting=!1,this.clearHandshake(),this.clearThrottle();let e=this.socket;this.socket=null,this.ready=!1,this.buffer=Buffer.alloc(0),e&&(e.removeAllListeners(),e.on(\"error\",()=>{}),!e.destroyed&&!e.writableEnded&&e.destroy())}connect(){this.clearRetry(),this.connecting=!0,this.setStatus({state:\"connecting\"}),this.tryPath(this.socketPaths(),0,++this.attempt)}tryPath(e,i,n){if(n!==this.attempt||!this.pending||!this.clientId)return;if(i>=e.length){this.connecting=!1,this.setStatus({state:\"disconnected\"}),this.scheduleRetry();return}let r=O(e[i]),o=()=>{r.removeAllListeners(),r.on(\"error\",()=>{}),r.destroy(),this.tryPath(e,i+1,n)};r.once(\"error\",o),r.once(\"connect\",()=>{r.off(\"error\",o),this.attach(r,n)})}attach(e,i){if(i!==this.attempt||!this.pending||!this.clientId){e.on(\"error\",()=>{}),e.destroy();return}this.connecting=!1,this.socket=e,this.ready=!1,this.buffer=Buffer.alloc(0),e.on(\"data\",n=>this.receive(e,n)),e.on(\"error\",n=>{e===this.socket&&this.logOnce(n.message)}),e.on(\"close\",()=>{e===this.socket&&(this.dropSocket(),this.current.state!==\"error\"&&this.setStatus({state:\"disconnected\"}),this.scheduleRetry())}),this.handshakeTimer=setTimeout(()=>{this.handshakeTimer=null,!(e!==this.socket||this.ready)&&(this.setStatus({state:\"error\",message:\"Handshake timeout\"}),e.destroy())},this.handshakeTimeoutMs),e.write(h(C,{v:1,client_id:this.clientId}))}scheduleRetry(){if(this.retryTimer||!this.pending||!this.clientId)return;let e=this.nextRetryMs;this.nextRetryMs=Math.min(this.nextRetryMs*2,this.maxRetryMs),this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.connect()},e)}receive(e,i){if(e!==this.socket)return;let{frames:n,rest:r}=N(Buffer.concat([this.buffer,i]));if(this.buffer=r,r.length>B){e.destroy();return}for(let o of n){if(e!==this.socket)return;this.handleFrame(e,o.op,o.data)}}handleFrame(e,i,n){if(i===z){e.write(h(L,n));return}if(i===_){let o=a(n)&&typeof n.message==\"string\"?n.message:\"Closed by Discord\";this.logOnce(o),this.setStatus({state:\"error\",message:o}),e.destroy();return}if(i!==D||!a(n))return;if(n.cmd===\"DISPATCH\"&&n.evt===\"READY\"){this.onReady(n.data);return}if(n.evt!==\"ERROR\")return;let r=a(n.data)&&typeof n.data.message==\"string\"?n.data.message:\"Discord error\";this.logOnce(r),this.setStatus({...this.current,message:r})}onReady(e){this.clearHandshake(),this.ready=!0,this.nextRetryMs=this.retryMs,this.lastLogged=\"\",this.lastSentJson=null;let i=a(e)&&a(e.user)?e.user:null,n=i&&typeof i.global_name==\"string\"?i.global_name:i?.username;this.setStatus({state:\"connected\",user:typeof n==\"string\"?n:void 0}),this.flush()}flush(){if(!this.ready||!this.socket||!this.pending)return;let e=JSON.stringify(this.pending);if(e===this.lastSentJson)return;let i=this.lastSentAt+this.throttleMs-Date.now();if(i>0){if(this.throttleTimer)return;this.throttleTimer=setTimeout(()=>{this.throttleTimer=null,this.flush()},i);return}this.lastSentJson=e,this.lastSentAt=Date.now(),this.socket.write(h(D,{cmd:\"SET_ACTIVITY\",args:{pid:this.pid,activity:this.pending},nonce:P()}))}};var $=\"1550197013260275863\",H={clientId:$,showFileName:\"true\",showProject:\"true\",showLanguage:\"true\",showElapsed:\"true\",elapsedFrom:\"session\",idleText:\"\",idleMinutes:\"5\",idleAction:\"idle\",repoButton:\"false\",privateMode:\"names\",privateProjects:\"\"},V=new Set([\"session\",\"project\",\"file\"]),G=new Set([\"idle\",\"clear\"]),J=new Set([\"names\",\"hide\"]),d=t=>t===\"true\"||t===!0,y=(t,e,i)=>t.has(e)?e:i;function j(t={}){let e={...H,...t},i=Number(e.idleMinutes);return{clientId:/^\\d{1,32}$/.test(String(e.clientId).trim())?String(e.clientId).trim():\"\",showFileName:d(e.showFileName),showProject:d(e.showProject),showLanguage:d(e.showLanguage),showElapsed:d(e.showElapsed),elapsedFrom:y(V,e.elapsedFrom,\"session\"),idleText:String(e.idleText??\"\").trim(),idleMinutes:Number.isFinite(i)&&i>0?i:0,idleAction:y(G,e.idleAction,\"idle\"),repoButton:d(e.repoButton),privateMode:y(J,e.privateMode,\"names\"),privateProjects:String(e.privateProjects??\"\").split(/\\r?\\n/).map(n=>n.trim()).filter(Boolean)}}var S=t=>String(t).replace(/\\\\/g,\"/\").replace(/\\/+$/,\"\");function T(t,e){if(!t)return!1;let i=S(t);return e.some(n=>{let r=S(n);return r?i===r||i.startsWith(`${r}/`):!1})}function X(t){let e=String(t??\"\").trim(),i=/^[\\w.-]+@([\\w.-]+):(?!\\/)(.+?)(?:\\.git)?\\/?$/.exec(e);if(i)return`https://${i[1]}/${i[2]}`;let n;try{n=new URL(e)}catch{return null}if(![\"https:\",\"http:\",\"ssh:\",\"git:\"].includes(n.protocol)||!n.hostname)return null;let r=n.pathname.replace(/\\.git\\/?$/,\"\").replace(/\\/+$/,\"\");if(!r||r===\"/\")return null;let o=n.protocol===\"http:\"?\"http:\":\"https:\",s=n.port&&(n.protocol===\"https:\"||n.protocol===\"http:\")?`:${n.port}`:\"\";return`${o}//${n.hostname}${s}${r}`}function k(t){let e=[],i=null;for(let r of String(t??\"\").split(/\\r?\\n/)){let o=/^\\s*\\[\\s*remote\\s+\"([^\"]+)\"\\s*\\]/.exec(r);if(o){i={name:o[1],url:null},e.push(i);continue}if(/^\\s*\\[/.test(r)){i=null;continue}let s=/^\\s*url\\s*=\\s*(.+?)\\s*$/.exec(r);i&&s&&!i.url&&(i.url=s[1])}let n=e.find(r=>r.name===\"origin\"&&r.url)??e.find(r=>r.url);return n?X(n.url):null}var q=t=>String(t).split(/[\\\\/]/).filter(Boolean).pop()??String(t),K=t=>String(t).toLowerCase().replace(/[^a-z0-9_]/g,\"_\");function R(t,e,i){if(t.idle&&e.idleAction===\"clear\"||t.private&&e.privateMode===\"hide\")return null;let n=e.showFileName&&!t.private,r={},o=e.idleText||i(\"activity.idle\");r.details=o,t.file&&!t.idle&&n&&(r.details=i(\"activity.editing\",{file:q(t.file.path)})),t.file&&!t.idle&&!n&&(r.details=i(\"activity.editingHidden\"));let s=t.project?.name;s&&e.showProject&&!t.private&&(r.state=i(\"activity.project\",{project:s})),s&&e.showProject&&t.private&&(r.state=i(\"activity.privateProject\")),e.showElapsed&&t.start&&(r.timestamps={start:t.start});let I=t.version?i(\"activity.version\",{version:t.version}):\"Lumen\";r.assets={large_image:\"lumen\",large_text:I},e.repoButton&&t.repoUrl&&!t.private&&(r.buttons=[{label:i(\"activity.repoButton\"),url:t.repoUrl}]);let g=t.file?.languageId;return!g||!e.showLanguage||t.idle||(r.assets={large_image:K(g),large_text:t.file.languageName||g,small_image:\"lumen\",small_text:I}),r}var l={en:{activity:{editing:\"Editing {file}\",editingHidden:\"Editing a file\",idle:\"Idle\",project:\"in {project}\",privateProject:\"in a private project\",version:\"Lumen {version}\",repoButton:\"View repository\"},status:{connected:\"Discord: connected\",connectedAs:\"Discord: connected as {user}\",connecting:\"Discord: connecting\\u2026\",disconnected:\"Discord: not connected (is Discord running?)\",error:\"Discord: error \\u2014 {message}\",disabled:\"Discord Rich Presence is off \\u2014 click to turn it on\",noClientId:\"Discord: no client ID set\",click:\"Click to reconnect\"},toast:{missingClientId:\"Discord Rich Presence needs a client ID: create an application at discord.com/developers and enter its ID in the extension\\u2019s settings.\",connecting:\"Connecting to Discord\\u2026\",connected:\"Connected to Discord\",connectedAs:\"Connected to Discord as {user}\",error:\"Discord: {message}\",enabled:\"Discord Rich Presence is on\",disabled:\"Discord Rich Presence is off\",privateOn:\"\\u201C{project}\\u201D is now private \\u2014 names no longer appear in Discord\",privateOff:\"\\u201C{project}\\u201D is no longer private\",noProject:\"No project is open.\"}},es:{activity:{editing:\"Editando {file}\",editingHidden:\"Editando un archivo\",idle:\"Inactivo\",project:\"en {project}\",privateProject:\"en un proyecto privado\",version:\"Lumen {version}\",repoButton:\"Ver repositorio\"},status:{connected:\"Discord: conectado\",connectedAs:\"Discord: conectado como {user}\",connecting:\"Discord: conectando\\u2026\",disconnected:\"Discord: sin conexi\\xF3n (\\xBFest\\xE1 abierto Discord?)\",error:\"Discord: error \\u2014 {message}\",disabled:\"Discord Rich Presence est\\xE1 desactivado \\u2014 haz clic para activarlo\",noClientId:\"Discord: no hay ID de cliente\",click:\"Haz clic para reconectar\"},toast:{missingClientId:\"Discord Rich Presence necesita un ID de cliente: crea una aplicaci\\xF3n en discord.com/developers e introduce su ID en los ajustes de la extensi\\xF3n.\",connecting:\"Conectando con Discord\\u2026\",connected:\"Conectado a Discord\",connectedAs:\"Conectado a Discord como {user}\",error:\"Discord: {message}\",enabled:\"Discord Rich Presence est\\xE1 activado\",disabled:\"Discord Rich Presence est\\xE1 desactivado\",privateOn:\"\\xAB{project}\\xBB ahora es privado: los nombres ya no aparecen en Discord\",privateOff:\"\\xAB{project}\\xBB ya no es privado\",noProject:\"No hay ning\\xFAn proyecto abierto.\"}},fr:{activity:{editing:\"Modifie {file}\",editingHidden:\"Modifie un fichier\",idle:\"Inactif\",project:\"dans {project}\",privateProject:\"dans un projet priv\\xE9\",version:\"Lumen {version}\",repoButton:\"Voir le d\\xE9p\\xF4t\"},status:{connected:\"Discord : connect\\xE9\",connectedAs:\"Discord : connect\\xE9 en tant que {user}\",connecting:\"Discord : connexion\\u2026\",disconnected:\"Discord : non connect\\xE9 (Discord est-il lanc\\xE9 ?)\",error:\"Discord : erreur \\u2014 {message}\",disabled:\"Discord Rich Presence est d\\xE9sactiv\\xE9 \\u2014 cliquez pour l\\u2019activer\",noClientId:\"Discord : aucun ID client d\\xE9fini\",click:\"Cliquez pour vous reconnecter\"},toast:{missingClientId:\"Discord Rich Presence n\\xE9cessite un ID client : cr\\xE9ez une application sur discord.com/developers et saisissez son ID dans les param\\xE8tres de l\\u2019extension.\",connecting:\"Connexion \\xE0 Discord\\u2026\",connected:\"Connect\\xE9 \\xE0 Discord\",connectedAs:\"Connect\\xE9 \\xE0 Discord en tant que {user}\",error:\"Discord : {message}\",enabled:\"Discord Rich Presence est activ\\xE9\",disabled:\"Discord Rich Presence est d\\xE9sactiv\\xE9\",privateOn:\"\\xAB {project} \\xBB est d\\xE9sormais priv\\xE9 \\u2014 les noms n\\u2019apparaissent plus dans Discord\",privateOff:\"\\xAB {project} \\xBB n\\u2019est plus priv\\xE9\",noProject:\"Aucun projet ouvert.\"}},pl:{activity:{editing:\"Edytuje {file}\",editingHidden:\"Edytuje plik\",idle:\"Bezczynny\",project:\"w {project}\",privateProject:\"w prywatnym projekcie\",version:\"Lumen {version}\",repoButton:\"Zobacz repozytorium\"},status:{connected:\"Discord: po\\u0142\\u0105czono\",connectedAs:\"Discord: po\\u0142\\u0105czono jako {user}\",connecting:\"Discord: \\u0142\\u0105czenie\\u2026\",disconnected:\"Discord: brak po\\u0142\\u0105czenia (czy Discord dzia\\u0142a?)\",error:\"Discord: b\\u0142\\u0105d \\u2014 {message}\",disabled:\"Discord Rich Presence jest wy\\u0142\\u0105czony \\u2014 kliknij, aby w\\u0142\\u0105czy\\u0107\",noClientId:\"Discord: nie ustawiono ID klienta\",click:\"Kliknij, aby po\\u0142\\u0105czy\\u0107 ponownie\"},toast:{missingClientId:\"Discord Rich Presence wymaga ID klienta: utw\\xF3rz aplikacj\\u0119 na discord.com/developers i wpisz jej ID w ustawieniach rozszerzenia.\",connecting:\"\\u0141\\u0105czenie z Discordem\\u2026\",connected:\"Po\\u0142\\u0105czono z Discordem\",connectedAs:\"Po\\u0142\\u0105czono z Discordem jako {user}\",error:\"Discord: {message}\",enabled:\"Discord Rich Presence jest w\\u0142\\u0105czony\",disabled:\"Discord Rich Presence jest wy\\u0142\\u0105czony\",privateOn:\"\\u201E{project}\\u201D jest teraz prywatny \\u2014 nazwy nie pojawiaj\\u0105 si\\u0119 w Discordzie\",privateOff:\"\\u201E{project}\\u201D nie jest ju\\u017C prywatny\",noProject:\"Nie otwarto \\u017Cadnego projektu.\"}},it:{activity:{editing:\"Modifica {file}\",editingHidden:\"Modifica un file\",idle:\"Inattivo\",project:\"in {project}\",privateProject:\"in un progetto privato\",version:\"Lumen {version}\",repoButton:\"Vedi repository\"},status:{connected:\"Discord: connesso\",connectedAs:\"Discord: connesso come {user}\",connecting:\"Discord: connessione\\u2026\",disconnected:\"Discord: non connesso (Discord \\xE8 in esecuzione?)\",error:\"Discord: errore \\u2014 {message}\",disabled:\"Discord Rich Presence \\xE8 disattivato \\u2014 fai clic per attivarlo\",noClientId:\"Discord: nessun ID client impostato\",click:\"Fai clic per riconnettere\"},toast:{missingClientId:\"Discord Rich Presence richiede un ID client: crea un\\u2019applicazione su discord.com/developers e inserisci il suo ID nelle impostazioni dell\\u2019estensione.\",connecting:\"Connessione a Discord\\u2026\",connected:\"Connesso a Discord\",connectedAs:\"Connesso a Discord come {user}\",error:\"Discord: {message}\",enabled:\"Discord Rich Presence \\xE8 attivo\",disabled:\"Discord Rich Presence \\xE8 disattivato\",privateOn:\"\\u201C{project}\\u201D ora \\xE8 privato: i nomi non compaiono pi\\xF9 su Discord\",privateOff:\"\\u201C{project}\\u201D non \\xE8 pi\\xF9 privato\",noProject:\"Nessun progetto aperto.\"}},pt:{activity:{editing:\"Editando {file}\",editingHidden:\"Editando um arquivo\",idle:\"Ocioso\",project:\"em {project}\",privateProject:\"em um projeto privado\",version:\"Lumen {version}\",repoButton:\"Ver reposit\\xF3rio\"},status:{connected:\"Discord: conectado\",connectedAs:\"Discord: conectado como {user}\",connecting:\"Discord: conectando\\u2026\",disconnected:\"Discord: desconectado (o Discord est\\xE1 aberto?)\",error:\"Discord: erro \\u2014 {message}\",disabled:\"O Discord Rich Presence est\\xE1 desligado \\u2014 clique para ligar\",noClientId:\"Discord: nenhum ID do cliente definido\",click:\"Clique para reconectar\"},toast:{missingClientId:\"O Discord Rich Presence precisa de um ID do cliente: crie uma aplica\\xE7\\xE3o em discord.com/developers e informe o ID nas configura\\xE7\\xF5es da extens\\xE3o.\",connecting:\"Conectando ao Discord\\u2026\",connected:\"Conectado ao Discord\",connectedAs:\"Conectado ao Discord como {user}\",error:\"Discord: {message}\",enabled:\"O Discord Rich Presence est\\xE1 ligado\",disabled:\"O Discord Rich Presence est\\xE1 desligado\",privateOn:\"\\u201C{project}\\u201D agora \\xE9 privado \\u2014 os nomes n\\xE3o aparecem mais no Discord\",privateOff:\"\\u201C{project}\\u201D n\\xE3o \\xE9 mais privado\",noProject:\"Nenhum projeto aberto.\"}},nl:{activity:{editing:\"Bewerkt {file}\",editingHidden:\"Bewerkt een bestand\",idle:\"Inactief\",project:\"in {project}\",privateProject:\"in een priv\\xE9project\",version:\"Lumen {version}\",repoButton:\"Repository bekijken\"},status:{connected:\"Discord: verbonden\",connectedAs:\"Discord: verbonden als {user}\",connecting:\"Discord: verbinden\\u2026\",disconnected:\"Discord: niet verbonden (draait Discord?)\",error:\"Discord: fout \\u2014 {message}\",disabled:\"Discord Rich Presence staat uit \\u2014 klik om het aan te zetten\",noClientId:\"Discord: geen client-ID ingesteld\",click:\"Klik om opnieuw te verbinden\"},toast:{missingClientId:\"Discord Rich Presence heeft een client-ID nodig: maak een applicatie aan op discord.com/developers en vul de ID in bij de instellingen van de extensie.\",connecting:\"Verbinden met Discord\\u2026\",connected:\"Verbonden met Discord\",connectedAs:\"Verbonden met Discord als {user}\",error:\"Discord: {message}\",enabled:\"Discord Rich Presence staat aan\",disabled:\"Discord Rich Presence staat uit\",privateOn:\"\\u201E{project}\\u201D is nu priv\\xE9 \\u2014 namen verschijnen niet meer in Discord\",privateOff:\"\\u201E{project}\\u201D is niet langer priv\\xE9\",noProject:\"Geen project geopend.\"}}},ge=Object.keys(l);function A(t,e){let i=t;for(let n of e.split(\".\")){if(!i||typeof i!=\"object\")return;i=i[n]}return typeof i==\"string\"?i:void 0}function W(t){let e=String(t.locale?.()??\"en\");if(l[e])return e;let i=e.split(\"-\")[0];return l[i]?i:\"en\"}function x(t){return(e,i={})=>{let n=A(l[W(t)],e)??A(l.en,e)??e;return String(n).replace(/\\{(\\w+)\\}/g,(r,o)=>o in i?String(i[o]):r)}}var Q=600,ee=3e4,E={connected:{icon:\"messages\",tone:\"success\"},connecting:{icon:\"loader\",tone:\"muted\"},disconnected:{icon:\"circle-dashed\",tone:\"muted\"},error:{icon:\"circle-alert\",tone:\"danger\"}};async function te(t){if(!t)return null;let e=await Y.readFile(Z.join(t,\".git\",\"config\"),\"utf8\").catch(()=>null);return e?k(e):null}function ie(t){let e=t.events.last(\"activeFile\"),i=t.events.last(\"project\"),n=t.storage.get(\"privateProjects\",[]);return Array.isArray(n)||(n=[]),{sessionStart:Date.now(),settings:j(t.settings.all()),enabled:t.storage.get(\"enabled\",!0)!==!1,markedPrivate:n,file:e?.path?e:null,project:i?.root?{root:i.root,name:i.name}:null,fileStart:Date.now(),projectStart:Date.now(),blurredAt:null,idle:!1,repoUrl:null,timer:null,idleTimer:null,disposed:!1,announce:!1,lastError:\"\",hintShown:!1}}function ne(t){let{s:e}=t;return!!e.project&&T(e.project.root,[...e.settings.privateProjects,...e.markedPrivate])}function re(t){return t.settings.elapsedFrom===\"file\"&&t.file?t.fileStart:t.settings.elapsedFrom===\"project\"&&t.project?t.projectStart:t.sessionStart}function c(t){let{ctx:e,t:i,s:n,client:r}=t;if(n.disposed||!Object.keys(e.settings.all()).length)return;if(!n.enabled){r.stop();return}if(!n.settings.clientId){if(r.stop(),n.hintShown)return;n.hintShown=!0,e.ui.notify(i(\"toast.missingClientId\"),\"info\");return}let o=R({file:n.file?{path:n.file.path,languageId:n.file.languageId,languageName:n.file.languageName}:null,project:n.project,private:ne(t),idle:n.idle,start:re(n),version:e.appVersion,repoUrl:n.repoUrl},n.settings,i);r.update(n.settings.clientId,o)}function u(t){let{s:e}=t;e.timer||e.disposed||(e.timer=setTimeout(()=>{e.timer=null,c(t)},Q))}function oe(t,e){let{t:i,s:n}=t;return n.settings.clientId?e.state===\"connected\"&&e.user?i(\"status.connectedAs\",{user:e.user}):e.state===\"error\"?i(\"status.error\",{message:e.message??\"\"}):i(`status.${e.state}`):i(\"status.noClientId\")}function p(t){let{ctx:e,t:i,s:n,client:r}=t;if(n.disposed)return;if(!n.enabled){e.statusBar.set(\"status\",{text:\"Discord\",icon:\"pause\",tone:\"muted\",tooltip:i(\"status.disabled\"),command:\"discord.enable\",side:\"right\",priority:5});return}let o=r.status(),s=E[o.state]??E.disconnected;e.statusBar.set(\"status\",{text:\"Discord\",icon:s.icon,tone:s.tone,tooltip:`${oe(t,o)}\n${i(\"status.click\")}`,command:\"discord.reconnect\",side:\"right\",priority:5})}function se(t,e){let{ctx:i,t:n,s:r}=t;if(!r.disposed){if(e.state===\"connected\"&&r.announce){r.announce=!1,i.ui.notify(e.user?n(\"toast.connectedAs\",{user:e.user}):n(\"toast.connected\"),\"success\");return}e.state!==\"error\"||!e.message||e.message===r.lastError||(r.lastError=e.message,i.ui.notify(n(\"toast.error\",{message:e.message}),\"warning\"))}}function v(t){let{s:e}=t,i=e.blurredAt!==null&&e.settings.idleMinutes>0&&Date.now()-e.blurredAt>=e.settings.idleMinutes*6e4;i!==e.idle&&(e.idle=i,c(t))}function b(t){t.idleTimer&&(clearInterval(t.idleTimer),t.idleTimer=null)}function m(t,e){let{ctx:i,t:n,s:r}=t;r.enabled=e,i.storage.set(\"enabled\",e),r.lastError=\"\",r.announce=e,i.ui.notify(n(e?\"toast.enabled\":\"toast.disabled\"),\"info\"),p(t),c(t)}function ce(t){let{ctx:e,t:i,s:n,client:r}=t;if(!n.enabled){m(t,!0);return}if(!n.settings.clientId){e.ui.notify(i(\"toast.missingClientId\"),\"info\");return}n.announce=!0,n.lastError=\"\",e.ui.notify(i(\"toast.connecting\"),\"info\"),c(t),r.reconnect()}function ae(t){let{ctx:e,t:i,s:n}=t;if(!n.project){e.ui.notify(i(\"toast.noProject\"),\"info\");return}let r=n.markedPrivate.includes(n.project.root);n.markedPrivate=r?n.markedPrivate.filter(o=>o!==n.project.root):[...n.markedPrivate,n.project.root],e.storage.set(\"privateProjects\",n.markedPrivate),e.ui.notify(i(r?\"toast.privateOff\":\"toast.privateOn\",{project:n.project.name??n.project.root}),\"info\"),c(t)}function de(t){let{ctx:e,s:i}=t,n={\"discord.reconnect\":()=>ce(t),\"discord.enable\":()=>m(t,!0),\"discord.disable\":()=>m(t,!1),\"discord.toggle\":()=>m(t,!i.enabled),\"discord.toggle-private\":()=>ae(t)};for(let[r,o]of Object.entries(n))e.commands.register(r,o)}async function M(t){let{s:e}=t,i=e.project?.root??null,n=await te(i);e.disposed||(e.project?.root??null)!==i||(e.repoUrl=n,u(t))}function le(t){let{ctx:e,s:i}=t;e.events.on(\"activeFile\",n=>{let r=n.path?n:null;r?.path!==i.file?.path&&(i.fileStart=Date.now()),i.file=r,u(t)}),e.events.on(\"project\",n=>{let r=n.root??null;r!==(i.project?.root??null)&&(i.projectStart=Date.now()),i.project=r?{root:r,name:n.name}:null,i.repoUrl=null,M(t),u(t)}),e.events.on(\"windowBlur\",()=>{i.blurredAt=Date.now(),b(i),i.idleTimer=setInterval(()=>v(t),ee)}),e.events.on(\"windowFocus\",()=>{i.blurredAt=null,b(i),v(t)}),e.events.on(\"locale\",()=>{p(t),u(t)}),e.settings.onDidChange(n=>{let r=i.settings.clientId;i.settings=j(n),i.settings.clientId!==r&&(i.hintShown=!1),i.lastError=\"\",p(t),v(t),u(t)})}function Pe(t){let e={ctx:t,t:x(t),s:ie(t),client:null};return e.client=new f({onStatus(i){p(e),se(e,i)},log:i=>t.log(i)}),de(e),le(e),p(e),M(e),c(e),()=>{e.s.disposed=!0,e.s.timer&&clearTimeout(e.s.timer),b(e.s),e.client.stop()}}export{Pe as activate};\n"
  },
  "addon": {
    "schema": 1,
    "languages": [],
    "themes": [],
    "commands": [],
    "events": [],
    "templates": [],
    "projectKinds": [],
    "snippets": [],
    "id": "ext.discord",
    "name": "Discord Rich Presence",
    "version": "1.0.2",
    "description": "Shows in Discord what you are working on: file, project, language and duration, with idle detection, private projects and a repository button. Ships with program code.",
    "author": "Lumen",
    "icon": "DC",
    "color": "#5865f2",
    "category": "tool"
  }
}
