diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8c52ff9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..99862fd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,59 @@ +name: 🐞 Bug report +description: Something doesn't work as expected +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + Thanks for reporting! ⚠️ Please **remove any personal data** from text, screenshots and files. + For security vulnerabilities, use [private reporting](https://github.com/lestolo/subscription-tracker/security/advisories/new) instead. + - type: textarea + id: what + attributes: + label: What happened? + description: A clear description of the bug. + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps to reproduce + placeholder: | + 1. Open the app + 2. Tap … + 3. See error + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected behavior + validations: + required: true + - type: input + id: device + attributes: + label: Device and OS + placeholder: e.g. iPhone 15, iOS 26.0 / Pixel 8, Android 16 + validations: + required: true + - type: input + id: browser + attributes: + label: Browser and version + placeholder: e.g. Safari 26, Chrome 141 + validations: + required: true + - type: dropdown + id: installed + attributes: + label: Is the app installed on the Home Screen? + options: + - "Yes" + - "No, used in the browser" + validations: + required: true + - type: textarea + id: extra + attributes: + label: Screenshots, console errors, additional context diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..e51d6dc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: πŸ”’ Report a security vulnerability + url: https://github.com/lestolo/subscription-tracker/security/advisories/new + about: Please report security issues privately. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..38bb83d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,21 @@ +name: ✨ Feature request +description: Suggest an idea or improvement +labels: ["enhancement"] +body: + - type: textarea + id: problem + attributes: + label: Problem + description: What problem would this solve? Who would benefit? + validations: + required: true + - type: textarea + id: solution + attributes: + label: Proposed solution + validations: + required: true + - type: textarea + id: alternatives + attributes: + label: Alternatives considered diff --git a/.github/ISSUE_TEMPLATE/new_service.yml b/.github/ISSUE_TEMPLATE/new_service.yml new file mode 100644 index 0000000..46d659b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/new_service.yml @@ -0,0 +1,30 @@ +name: πŸ“Ί Add a service to the catalogue +description: Request a subscription service to be added to the built-in catalogue +labels: ["catalogue"] +body: + - type: input + id: name + attributes: + label: Service name + placeholder: e.g. Crunchyroll + validations: + required: true + - type: input + id: website + attributes: + label: Official website + placeholder: https://… + validations: + required: true + - type: dropdown + id: category + attributes: + label: Category + options: [Video & TV, Music & audio, Cloud storage, Productivity, AI, Creative, Gaming, VPN & security, Shopping & food, News & reading, Health & fitness, Education, Phone & internet, Finance, Social, Other] + validations: + required: true + - type: input + id: icon + attributes: + label: Simple Icons slug (if available) + description: Search on https://simpleicons.org diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..e80376e --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,20 @@ +## Description + + + +## Type of change + +- [ ] Bug fix +- [ ] New feature +- [ ] Catalogue / translations +- [ ] Documentation +- [ ] Refactoring / tooling + +## Checklist + +- [ ] `npm test` passes +- [ ] Tested on a phone-sized viewport, in light and dark mode +- [ ] New UI strings are translated in every language in `js/core/i18n.js` +- [ ] `ST.VERSION` bumped if cached assets changed (`sw.js` β†’ `ASSETS`) +- [ ] No secrets, API keys or personal data added +- [ ] No new runtime dependencies or third-party requests diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..3a626c3 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: monthly diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f9f372b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - name: Unit tests + run: npm test + - name: Check that every cached asset exists + run: | + node -e " + const fs = require('fs'); + const src = fs.readFileSync('sw.js', 'utf8'); + const list = src.match(/const ASSETS = \[([\s\S]*?)\];/)[1].match(/'([^']+)'/g).map(s => s.slice(1, -1)); + const missing = list.filter(p => p !== './' && !fs.existsSync(p)); + if (missing.length) { console.error('Missing assets:', missing); process.exit(1); } + console.log('All', list.length, 'cached assets exist'); + " + - name: Validate JSON files + run: | + node -e "for (const f of ['manifest.webmanifest','vercel.json','package.json']) JSON.parse(require('fs').readFileSync(f,'utf8'))" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c18f2a8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +node_modules/ +.vercel/ +.DS_Store +Thumbs.db +*.log +.env +.env.* +coverage/ diff --git a/.vercelignore b/.vercelignore new file mode 100644 index 0000000..397aadd --- /dev/null +++ b/.vercelignore @@ -0,0 +1,6 @@ +tests/ +tools/ +docs/ +.github/ +*.md +!README.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..4dccbdd --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,18 @@ +# Changelog + +All notable changes to this project are documented in this file. +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/). + +## [1.0.0] - 2026-10-04 + +### Added + +- Subscription tracking stored locally in IndexedDB. +- Catalogue of ~120 popular services with logos from Simple Icons, plus custom subscriptions. +- Monthly, quarterly, yearly and custom billing frequencies with correct month-end handling. +- Multi-currency totals with optional manual exchange rates. +- Local renewal reminders (on open and via Periodic Background Sync) and `.ics` calendar export. +- Installable PWA with offline support and an animated "Add to Home Screen" guide. +- Italian and English interface, light and dark themes. +- JSON backup export and import. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..a731ead --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,73 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Project maintainers are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported privately to the project maintainers through GitHub's +[private vulnerability reporting](https://github.com/lestolo/subscription-tracker/security/advisories/new) +form (please mention "Code of Conduct" in the title). All complaints will be +reviewed and investigated promptly and fairly. + +All project maintainers are obligated to respect the privacy and security of the +reporter of any incident. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..043b77f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,47 @@ +# Contributing to SubTrack + +Thanks for taking the time to contribute! πŸŽ‰ Issues and pull requests in English or Italian are both welcome. + +## Ground rules + +- **Never commit secrets or personal data**: no API keys, tokens, e-mail addresses, real subscription data or `.env` files. The app is designed to run without any secrets. +- Keep the project **dependency-free and build-free**: plain HTML, CSS and JavaScript that runs as-is in the browser. +- Keep it **private by design**: no analytics, no third-party requests, no remote fonts or CDNs. +- Follow the [Code of Conduct](CODE_OF_CONDUCT.md). + +## Getting started + +```bash +git clone https://github.com//subscription-tracker.git +cd subscription-tracker +npm start # http://localhost:8080 +npm test +``` + +## Making changes + +1. Open an issue first for larger changes so we can agree on the approach. +2. Create a branch from `main`: `git checkout -b feat/short-description`. +3. Keep logic that doesn't touch the DOM in `js/core/` and cover it with tests in `tests/`. +4. Every user-facing string must go through `js/core/i18n.js` and exist in **all** languages (a test enforces this). +5. Never insert user-provided text with `innerHTML`: use the `h()` helper or `textContent`. +6. If you change any file listed in `sw.js` β†’ `ASSETS`, or add a new one, bump `ST.VERSION` in `js/core/version.js` so installed apps update. +7. Run `npm test` and try the app on a phone-sized viewport, in both light and dark mode. +8. Use [Conventional Commits](https://www.conventionalcommits.org/) for messages, e.g. `feat: add Revolut to catalogue`, `fix: month-end renewal on leap years`. + +## Adding services to the catalogue + +Edit `RAW` in `js/core/catalog.js`: `[id, name, category, brandColor, simpleIconsSlug | null]`. + +- `id`: lowercase, unique, no spaces. +- `brandColor`: hex without `#`. +- If the brand is on [simpleicons.org](https://simpleicons.org), set the slug and run `npm run icons`; otherwise use `null`. +- Please don't add prices: they change too often and differ by country. + +## Reporting bugs + +Use the [bug report template](https://github.com/lestolo/subscription-tracker/issues/new?template=bug_report.yml) and include your device, OS and browser version. Remove personal data from screenshots and exported files. + +## Security issues + +Please **don't** open a public issue; see [SECURITY.md](SECURITY.md). diff --git a/README.it.md b/README.it.md new file mode 100644 index 0000000..551e309 --- /dev/null +++ b/README.it.md @@ -0,0 +1,121 @@ +
+ +Logo SubTrack + +# SubTrack + +**Tutti i tuoi abbonamenti in un posto solo: privata, offline-first, installabile.** + +[![CI](https://github.com/lestolo/subscription-tracker/actions/workflows/ci.yml/badge.svg)](https://github.com/lestolo/subscription-tracker/actions/workflows/ci.yml) +[![Licenza: MIT](https://img.shields.io/badge/Licenza-MIT-6D5EF5.svg)](LICENSE) +![PWA](https://img.shields.io/badge/PWA-ready-8B5CF6) +![Nessuna dipendenza](https://img.shields.io/badge/dipendenze-0-1F9D55) + +[English](README.md) Β· **Italiano** + +Schermata principale +Catalogo servizi +Tema scuro + +
+ +## FunzionalitΓ  + +- **Catalogo di ~120 servizi popolari** con logo: Netflix, Disney+, Amazon Prime, Spotify, iCloud+, Google One, Microsoft 365, Adobe Creative Cloud, ChatGPT, Claude, PlayStation Plus, operatori telefonici italiani e altri ancora, divisi per categoria e con ricerca istantanea. +- **Abbonamenti personalizzati**: qualsiasi nome, colore a scelta e monogramma automatico. +- **Frequenza flessibile**: mensile, trimestrale, annuale o personalizzata ("ogni 4 mesi", "ogni 2 settimane", …). Le date di fine mese sono gestite correttamente (31 gen β†’ 28/29 feb β†’ 31 mar). +- **Multivaluta**: ogni abbonamento ha la sua valuta. I totali sono mostrati per valuta, oppure come totale unico nella valuta principale se inserisci i tuoi tassi di cambio (i tassi non vengono mai scaricati da internet). +- **Dashboard**: spesa mensile o annuale, rinnovi dei prossimi 30 giorni, ordinamento per rinnovo, costo o nome, e pausa degli abbonamenti senza eliminarli. +- **Promemoria**: notifiche locali piΓΉ un **export nel calendario (.ics)** con avvisi, per promemoria affidabili su qualsiasi telefono. +- **PWA installabile**: funziona offline e si apre a schermo intero. Una guida animata mostra come aggiungere l'app alla schermata Home su iOS e Android. +- **Interfaccia bilingue**: italiano e inglese, con rilevamento automatico e selettore manuale. +- **UX mobile-first**: bottom sheet chiudibili con uno swipe, aree di tocco ampie, feedback aptico, supporto alle safe area, tema chiaro e scuro, e rispetto di `prefers-reduced-motion`. +- **Backup**: export e import dei dati in JSON. L'eliminazione si puΓ² annullare. +- **Zero dipendenze, zero build**: HTML, CSS e JavaScript puri. + +## Avvio rapido + +Serve un qualsiasi web server statico. Per lo sviluppo locale: [Node.js](https://nodejs.org) β‰₯ 20 (facoltativo, solo per il server di sviluppo e i test). + +```bash +git clone https://github.com/lestolo/subscription-tracker.git +cd subscription-tracker +npm start # avvia l'app su http://localhost:8080 +``` + +Va bene anche qualsiasi altro server statico, ad esempio `python3 -m http.server 8080`. + +> Service worker e notifiche richiedono un **contesto sicuro**: `http://localhost` funziona per lo sviluppo, ma in produzione serve **HTTPS**. + +## Pubblicazione + +L'app Γ¨ una cartella di file statici, senza build e senza variabili d'ambiente. + +### Vercel + +[![Deploy con Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flestolo%2Fsubscription-tracker) + +1. Importa il repository su Vercel. +2. Framework preset: **Other**. Build command: *nessuno*. Output directory: `.` (root). +3. Pubblica. [`vercel.json`](vercel.json) imposta giΓ  gli header di sicurezza (CSP, HSTS e altri) e la cache corretta per `sw.js`. + +### Self-hosting + +Copia il contenuto del repository (puoi escludere `tests/`, `tools/`, `docs/` e `.github/`) su qualsiasi hosting statico HTTPS: GitHub Pages, Netlify, Cloudflare Pages, nginx, Apache o Caddy. Tutti i percorsi sono relativi, quindi l'app funziona anche in una sottocartella (ad esempio `https://example.com/subtrack/`). + +Impostazioni consigliate per il server: + +- servi `sw.js` con `Cache-Control: no-cache`; +- servi `manifest.webmanifest` come `application/manifest+json`; +- invia gli stessi header di sicurezza di [`vercel.json`](vercel.json). + +Nel [README in inglese](README.md#self-hosting) trovi un esempio di configurazione nginx. + +## Come funzionano i promemoria + +SubTrack **non ha un backend**, quindi non usa il Web Push (che richiede un server e chiavi VAPID). I promemoria vengono invece calcolati sul dispositivo: + +| Meccanismo | Quando scatta | Piattaforme | +| --- | --- | --- | +| Controllo all'apertura o al ritorno nell'app | Ogni volta che apri l'app o ci torni | Tutti i browser che supportano le notifiche | +| Periodic Background Sync | In background, circa ogni 12 ore, a discrezione del browser | Chromium su Android, solo con app installata | +| **Export calendario (.ics)** | Alle 09:00 del giorno del promemoria, gestito dall'app calendario | Qualsiasi calendario, su telefono o desktop | + +Ogni rinnovo viene notificato **una sola volta**. Su **iPhone/iPad** le notifiche delle web app richiedono iOS/iPadOS 16.4 o successivi e l'app deve prima essere **aggiunta alla schermata Home**. La guida nell'app spiega come fare. + +Per promemoria sempre puntuali usa **Impostazioni β†’ Esporta nel calendario**: ogni abbonamento diventa un evento ricorrente con avviso, con le date di fine mese gestite correttamente. + +## Privacy e sicurezza + +- **I tuoi dati restano sul tuo dispositivo**, in IndexedDB. Niente account, analytics, cookie o richieste a terze parti. +- Tutte le risorse, loghi compresi, sono incluse localmente. L'app non fa chiamate di rete oltre al caricamento dei propri file. +- Una **Content Security Policy** restrittiva blocca script inline e origini esterne. L'input dell'utente viene sempre mostrato come testo, e i backup importati sono validati campo per campo. +- **Se cancelli i dati del sito dal browser, perdi i tuoi abbonamenti.** Esporta un backup ogni tanto. +- Il repository non contiene segreti, chiavi API o dati personali. Mantieni questa regola anche nei contributi; vedi [SECURITY.md](SECURITY.md). + +## Sviluppo + +```bash +npm test # esegue i test (non serve installare nulla) +npm start # server di sviluppo locale +``` + +**Aggiungere un servizio al catalogo:** aggiungi una riga a `RAW` in [`js/core/catalog.js`](js/core/catalog.js). Se il marchio esiste su [simpleicons.org](https://simpleicons.org), indica lo slug ed esegui `npm run icons` per includere il logo. Altrimenti usa `null` e verrΓ  mostrato un monogramma. + +**Aggiungere una lingua:** copia il blocco `en` in [`js/core/i18n.js`](js/core/i18n.js), traducilo e aggiungi il codice a `LANGS`. Un test verifica che tutte le lingue abbiano le stesse chiavi. + +**Nuova release:** incrementa `ST.VERSION` in [`js/core/version.js`](js/core/version.js). Questo rinomina la cache offline, cosΓ¬ le app installate scaricano i nuovi file e mostrano l'avviso "Nuova versione disponibile". + +## Contribuire + +I contributi sono benvenuti. Leggi [CONTRIBUTING.md](CONTRIBUTING.md) e il [Codice di condotta](CODE_OF_CONDUCT.md). Segnala bug e idee tramite le [GitHub Issues](https://github.com/lestolo/subscription-tracker/issues). + +## Crediti e marchi + +- Le icone dei marchi provengono da [Simple Icons](https://simpleicons.org) (CC0-1.0). +- Tutti i nomi di prodotti, loghi e marchi appartengono ai rispettivi proprietari. Sono usati solo per identificare i servizi, e il loro uso non implica alcuna approvazione. I marchi non disponibili in Simple Icons sono mostrati come monogramma colorato. +- SubTrack Γ¨ un progetto indipendente e non Γ¨ affiliato a nessuno dei servizi elencati. + +## Licenza + +[MIT](LICENSE) diff --git a/README.md b/README.md index 94e1a47..5ac3ece 100644 --- a/README.md +++ b/README.md @@ -1 +1,184 @@ -# subscription-tracker \ No newline at end of file +
+ +SubTrack logo + +# SubTrack + +**Track all your subscriptions in one place: private, offline-first, installable.** + +[![CI](https://github.com/lestolo/subscription-tracker/actions/workflows/ci.yml/badge.svg)](https://github.com/lestolo/subscription-tracker/actions/workflows/ci.yml) +[![License: MIT](https://img.shields.io/badge/License-MIT-6D5EF5.svg)](LICENSE) +![PWA](https://img.shields.io/badge/PWA-ready-8B5CF6) +![No dependencies](https://img.shields.io/badge/dependencies-0-1F9D55) + +**English** Β· [Italiano](README.it.md) + +Home screen +Service catalogue +Dark mode + +
+ +## Table of contents + +- [Features](#features) +- [Quick start](#quick-start) +- [Deploy](#deploy) +- [How reminders work](#how-reminders-work) +- [Privacy and security](#privacy-and-security) +- [Project structure](#project-structure) +- [Development](#development) +- [Contributing](#contributing) +- [Credits and trademarks](#credits-and-trademarks) +- [License](#license) + +## Features + +- **Catalogue of ~120 popular services** with logos: Netflix, Disney+, Amazon Prime, Spotify, iCloud+, Google One, Microsoft 365, Adobe Creative Cloud, ChatGPT, Claude, PlayStation Plus, Italian telcos and more, grouped by category with instant search. +- **Custom subscriptions**: any name, your own colour and an automatic monogram. +- **Flexible billing**: monthly, quarterly or yearly, or any custom period ("every 4 months", "every 2 weeks", …). Month-end dates are handled correctly (31 Jan β†’ 28/29 Feb β†’ 31 Mar). +- **Multi-currency**: each subscription has its own currency. Totals are shown per currency, or as one total in your main currency if you enter your own exchange rates (rates are never fetched online). +- **Dashboard**: monthly or yearly spend, upcoming renewals for the next 30 days, sorting by renewal date, cost or name, and pausing a subscription without deleting it. +- **Reminders**: local notifications plus a **calendar export (.ics)** with alerts for reliable reminders on any phone. +- **Installable PWA**: works offline and opens full screen. An animated guide shows how to add the app to the Home Screen on iOS and Android. +- **Bilingual UI**: Italian and English, detected automatically and switchable. +- **Mobile-first UX**: bottom sheets with swipe to dismiss, large touch targets, haptics, safe-area support, light and dark themes, and `prefers-reduced-motion` support. +- **Backup**: export and import your data as JSON. Deleting has an undo. +- **Zero dependencies, zero build step**: plain HTML, CSS and JavaScript. + +
+Add subscription form +Settings +Install guide on iPhone +
+ +## Quick start + +Requirements: any static web server. For local development: [Node.js](https://nodejs.org) β‰₯ 20 (optional, only for the dev server and the tests). + +```bash +git clone https://github.com/lestolo/subscription-tracker.git +cd subscription-tracker +npm start # serves the app on http://localhost:8080 +``` + +Any other static server works too, for example `python3 -m http.server 8080`. + +> Service workers and notifications need a **secure context**: `http://localhost` works for development, but a real deployment must use **HTTPS**. + +## Deploy + +The app is a folder of static files with no build step and no environment variables. + +### Vercel + +[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flestolo%2Fsubscription-tracker) + +1. Import the repository in Vercel. +2. Framework preset: **Other**. Build command: *none*. Output directory: `.` (root). +3. Deploy. [`vercel.json`](vercel.json) already sets the security headers (CSP, HSTS and others) and the right caching for `sw.js`. + +### Self-hosting + +Copy the repository contents (excluding `tests/`, `tools/`, `docs/` and `.github/` if you like) to any HTTPS static host: GitHub Pages, Netlify, Cloudflare Pages, nginx, Apache or Caddy. All paths are relative, so the app also works from a sub-folder (for example `https://example.com/subtrack/`). + +Recommended server settings: + +- serve `sw.js` with `Cache-Control: no-cache`; +- serve `manifest.webmanifest` as `application/manifest+json`; +- send the same security headers as [`vercel.json`](vercel.json). + +
+Example nginx configuration + +```nginx +server { + listen 443 ssl http2; + server_name subtrack.example.com; + root /var/www/subtrack; + + add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: blob:; connect-src 'self'; manifest-src 'self'; worker-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always; + add_header X-Content-Type-Options nosniff always; + add_header Referrer-Policy no-referrer always; + + location = /sw.js { add_header Cache-Control "no-cache"; } + location ~ \.webmanifest$ { default_type application/manifest+json; } +} +``` + +
+ +## How reminders work + +SubTrack has **no backend**, so it does not use Web Push (which needs a server and VAPID keys). Reminders are computed on the device instead: + +| Mechanism | When it fires | Platforms | +| --- | --- | --- | +| Check on app open or resume | Every time you open or return to the app | All browsers that support notifications | +| Periodic Background Sync | In the background, about every 12 hours, at the browser's discretion | Chromium on Android, installed app only | +| **Calendar export (.ics)** | At 09:00 on the reminder day, handled by your calendar app | Every phone and desktop calendar | + +Each renewal is notified **only once**. On **iPhone/iPad**, notifications for web apps need iOS/iPadOS 16.4 or later and the app must be **added to the Home Screen** first. The in-app guide walks you through this. + +For reminders that always arrive on time, use **Settings β†’ Export to calendar**: each subscription becomes a repeating event with an alert, and month-end dates are handled correctly. + +## Privacy and security + +- **Your data stays on your device**, in IndexedDB. There are no accounts, no analytics, no cookies and no third-party requests. +- All assets, including logos, are bundled locally. The app makes no network calls besides loading its own files. +- A strict **Content Security Policy** blocks inline scripts and external origins. User input is only ever rendered as text, and imported backups are validated field by field. +- **Clearing the browser's site data deletes your subscriptions.** Export a backup from time to time. +- The repository contains no secrets, API keys or personal data. Please keep it that way in contributions; see [SECURITY.md](SECURITY.md). + +## Project structure + +``` +β”œβ”€β”€ index.html App shell +β”œβ”€β”€ manifest.webmanifest PWA manifest +β”œβ”€β”€ sw.js Service worker (offline cache, background reminders) +β”œβ”€β”€ vercel.json Hosting headers for Vercel +β”œβ”€β”€ css/app.css All styles (light and dark themes, animations) +β”œβ”€β”€ js/ +β”‚ β”œβ”€β”€ core/ DOM-free logic, shared by the page, the service worker and the tests +β”‚ β”‚ β”œβ”€β”€ catalog.js Service catalogue (name, category, brand colour, icon) +β”‚ β”‚ β”œβ”€β”€ icons.js Brand icons (generated from Simple Icons) +β”‚ β”‚ β”œβ”€β”€ schedule.js Billing-date maths +β”‚ β”‚ β”œβ”€β”€ i18n.js Translations (IT/EN) and formatting +β”‚ β”‚ β”œβ”€β”€ db.js IndexedDB storage, validation, backup +β”‚ β”‚ β”œβ”€β”€ reminders.js Local notifications +β”‚ β”‚ β”œβ”€β”€ ics.js Calendar export +β”‚ β”‚ └── version.js App version (also names the offline cache) +β”‚ β”œβ”€β”€ ui.js DOM helpers, bottom sheets, toasts +β”‚ β”œβ”€β”€ install.js "Add to Home Screen" guide +β”‚ └── app.js Application controller +β”œβ”€β”€ icons/ App icons +β”œβ”€β”€ tests/ Unit tests (node:test) +└── tools/build-icons.mjs Regenerates js/core/icons.js +``` + +## Development + +```bash +npm test # runs the unit tests (no install needed) +npm start # local dev server +``` + +**Adding a service to the catalogue:** add a line to `RAW` in [`js/core/catalog.js`](js/core/catalog.js). If the brand exists on [simpleicons.org](https://simpleicons.org), set its slug and run `npm run icons` to embed the logo. Otherwise use `null` and a monogram is shown. + +**Adding a language:** copy the `en` block in [`js/core/i18n.js`](js/core/i18n.js), translate it and add the code to `LANGS`. A test checks that all languages have the same keys. + +**Releasing:** bump `ST.VERSION` in [`js/core/version.js`](js/core/version.js). This renames the offline cache, so installed apps pick up the new files and show a "New version available" prompt. + +## Contributing + +Contributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) and our [Code of Conduct](CODE_OF_CONDUCT.md). Report bugs and ideas through [GitHub Issues](https://github.com/lestolo/subscription-tracker/issues). + +## Credits and trademarks + +- Brand icons come from [Simple Icons](https://simpleicons.org) (CC0-1.0). +- All product names, logos and brands are property of their respective owners. They are used here only to identify services, and their use does not imply endorsement. Brands not available in Simple Icons are shown as a coloured monogram. +- SubTrack is an independent project and is not affiliated with any of the listed services. + +## License + +[MIT](LICENSE) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..d73d4d2 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,33 @@ +# Security Policy + +## Supported versions + +Only the latest release (the `main` branch) receives security fixes. + +## Reporting a vulnerability + +Please report vulnerabilities **privately** through GitHub's +[private vulnerability reporting](https://github.com/lestolo/subscription-tracker/security/advisories/new) +(*Security* tab β†’ *Report a vulnerability*). Don't open a public issue. + +Please include: + +- a description of the issue and its impact; +- steps to reproduce or a proof of concept; +- affected browsers or platforms. + +You can expect an initial response within 7 days. Once a fix is released, we'll credit you in the advisory unless you prefer to stay anonymous. + +## Scope and design + +SubTrack is a static, client-only web app: + +- all data is stored locally in the browser (IndexedDB) and never sent anywhere; +- there is no backend, no authentication and no third-party requests; +- a strict Content Security Policy is applied (see `index.html` and `vercel.json`). + +Relevant issues include XSS (for example through imported backup files or subscription names), CSP bypasses, service-worker cache poisoning, and anything that could make data leave the device. + +## Secrets + +This repository must never contain API keys, tokens, credentials or personal data. If you find any, please report it as described above. diff --git a/css/app.css b/css/app.css new file mode 100644 index 0000000..6c4f1bd --- /dev/null +++ b/css/app.css @@ -0,0 +1,829 @@ +/* SubTrack β€” mobile-first styles. */ + +:root { + --bg: #F4F4F8; + --surface: #FFFFFF; + --surface-2: #EEEEF4; + --text: #121218; + --muted: #6A6B7B; + --line: rgba(18, 18, 30, 0.08); + --accent: #6D5EF5; + --accent-2: #9B5CF6; + --accent-ink: #FFFFFF; + --accent-soft: rgba(109, 94, 245, 0.12); + --danger: #E5484D; + --ok: #1F9D55; + --warn: #E58A00; + --shadow: 0 1px 2px rgba(16, 16, 40, 0.06), 0 8px 24px rgba(16, 16, 40, 0.06); + --shadow-lg: 0 20px 60px rgba(16, 16, 40, 0.22); + --radius: 20px; + --radius-sm: 14px; + --safe-top: env(safe-area-inset-top, 0px); + --safe-bottom: env(safe-area-inset-bottom, 0px); + --gutter: 16px; + --ease-spring: cubic-bezier(0.32, 0.72, 0, 1); + --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif; + color-scheme: light; +} + +@media (prefers-color-scheme: dark) { + :root:not([data-theme="light"]) { + --bg: #0B0B10; + --surface: #16161D; + --surface-2: #20202A; + --text: #F2F2F7; + --muted: #9A9AAD; + --line: rgba(255, 255, 255, 0.08); + --accent: #8B7FFF; + --accent-2: #B07CFF; + --accent-soft: rgba(139, 127, 255, 0.16); + --shadow: 0 1px 2px rgba(0, 0, 0, 0.4); + --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6); + color-scheme: dark; + } +} + +:root[data-theme="dark"] { + --bg: #0B0B10; + --surface: #16161D; + --surface-2: #20202A; + --text: #F2F2F7; + --muted: #9A9AAD; + --line: rgba(255, 255, 255, 0.08); + --accent: #8B7FFF; + --accent-2: #B07CFF; + --accent-soft: rgba(139, 127, 255, 0.16); + --shadow: 0 1px 2px rgba(0, 0, 0, 0.4); + --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6); + color-scheme: dark; +} + +*, *::before, *::after { box-sizing: border-box; } + +html { + -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; + -webkit-tap-highlight-color: transparent; +} +html.sheet-open { overflow: hidden; } + +body { + margin: 0; + min-height: 100dvh; + background: var(--bg); + color: var(--text); + font: 16px/1.4 var(--font); + -webkit-font-smoothing: antialiased; + overscroll-behavior-y: none; +} + +button, input, select, textarea { font: inherit; color: inherit; } +button { cursor: pointer; } +[hidden] { display: none !important; } +h1, h2, h3, p { margin: 0; } +a { color: var(--accent); } + +:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; } + +.sr-only { + position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; + overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; +} +.muted { color: var(--muted); } + +svg.i { + width: 22px; height: 22px; flex: none; + fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; +} +svg.i.inline { width: 18px; height: 18px; vertical-align: -3px; color: var(--accent); } + +/* ---------- Layout ---------- */ + +.app { + max-width: 560px; + margin: 0 auto; + padding: calc(var(--safe-top) + 8px) var(--gutter) calc(var(--safe-bottom) + 110px); +} + +.topbar { + position: sticky; + top: 0; + z-index: 5; + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + margin: 0 calc(-1 * var(--gutter)); + padding: calc(var(--safe-top) + 10px) var(--gutter) 10px; + margin-top: calc(-1 * (var(--safe-top) + 8px)); + background: color-mix(in srgb, var(--bg) 82%, transparent); + -webkit-backdrop-filter: saturate(180%) blur(16px); + backdrop-filter: saturate(180%) blur(16px); +} +.brand { display: flex; align-items: center; gap: 10px; min-width: 0; } +.brand img { border-radius: 9px; } +.brand h1 { font-size: 20px; font-weight: 750; letter-spacing: -0.02em; } +.tagline { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + +.icon-btn { + display: inline-grid; + place-items: center; + width: 44px; height: 44px; + flex: none; + border: 0; + border-radius: 50%; + background: var(--surface); + color: var(--text); + box-shadow: var(--shadow); + transition: transform 0.15s ease; +} +.icon-btn:active { transform: scale(0.92); } +.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; } + +/* ---------- Summary ---------- */ + +.summary { + position: relative; + overflow: hidden; + margin-top: 8px; + padding: 18px 20px 20px; + border-radius: 26px; + color: #fff; + background: + radial-gradient(120% 140% at 100% 0%, rgba(255, 255, 255, 0.22) 0%, transparent 55%), + linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%); + box-shadow: 0 16px 40px color-mix(in srgb, var(--accent) 35%, transparent); + animation: rise 0.5s var(--ease-spring) both; +} +.summary::after { + content: ""; + position: absolute; + right: -40px; bottom: -60px; + width: 180px; height: 180px; + border-radius: 50%; + background: rgba(255, 255, 255, 0.08); + pointer-events: none; +} +.summary-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; } +.summary-label { font-size: 14px; font-weight: 600; opacity: 0.9; } +.amount { + margin-top: 10px; + font-size: clamp(36px, 11vw, 46px); + font-weight: 800; + letter-spacing: -0.035em; + line-height: 1.05; + font-variant-numeric: tabular-nums; +} +.amount .approx { opacity: 0.75; font-weight: 600; } +.amount-multi { margin-top: 6px; } +.amount-sm { font-size: 28px; margin-top: 4px; } +.summary-note { font-size: 12.5px; opacity: 0.85; margin-top: 6px; } +.summary-count { margin-top: 10px; font-size: 14px; opacity: 0.9; } + +.seg { + display: flex; + gap: 4px; + padding: 4px; + border-radius: 14px; + background: var(--surface-2); +} +.seg button { + flex: 1; + min-height: 40px; + padding: 6px 10px; + border: 0; + border-radius: 10px; + background: transparent; + font-size: 14px; + font-weight: 600; + color: var(--muted); + transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease; +} +.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); } +.seg-sm { background: rgba(255, 255, 255, 0.16); border-radius: 12px; padding: 3px; } +.seg-sm button { min-height: 32px; font-size: 13px; color: rgba(255, 255, 255, 0.85); border-radius: 9px; } +.seg-sm button.active { background: #fff; color: #2a2346; box-shadow: none; } + +/* ---------- Sections ---------- */ + +.section { margin-top: 26px; } +.section h2 { font-size: 18px; font-weight: 750; letter-spacing: -0.01em; } +.section > h2 { margin-bottom: 12px; } +.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; } +.sort select { + appearance: none; + -webkit-appearance: none; + border: 0; + border-radius: 999px; + padding: 8px 32px 8px 14px; + font-size: 14px; + font-weight: 600; + background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a9c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; + box-shadow: var(--shadow); +} + +.upcoming { + display: flex; + gap: 10px; + overflow-x: auto; + scroll-snap-type: x mandatory; + scroll-padding-inline: var(--gutter); + margin: 0 calc(-1 * var(--gutter)); + padding: 2px var(--gutter) 6px; + scrollbar-width: none; +} +.upcoming::-webkit-scrollbar { display: none; } +.upcoming-none { padding: 4px 0; } +.up-card { + scroll-snap-align: start; + scroll-margin-inline: var(--gutter); + flex: none; + display: grid; + gap: 2px; + justify-items: start; + width: 128px; + padding: 12px; + border: 0; + border-radius: var(--radius-sm); + background: var(--surface); + box-shadow: var(--shadow); + text-align: left; + transition: transform 0.15s ease; + animation: rise 0.45s var(--ease-spring) both; +} +.up-card:active { transform: scale(0.97); } +.up-card .logo { margin-bottom: 8px; } +.up-name { font-weight: 650; font-size: 14px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.up-when { font-size: 12.5px; color: var(--muted); } +.up-price { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; } +.up-card.is-urgent .up-when { color: var(--warn); font-weight: 650; } + +/* ---------- Subscription list ---------- */ + +.sub-list { + list-style: none; + margin: 0; + padding: 0; + border-radius: var(--radius); + background: var(--surface); + box-shadow: var(--shadow); + overflow: hidden; +} +.sub-list li + li .sub-row { border-top: 1px solid var(--line); } +.sub-row { + display: flex; + align-items: center; + gap: 12px; + width: 100%; + min-height: 70px; + padding: 12px 16px; + border: 0; + background: transparent; + text-align: left; + transition: background 0.15s ease; +} +.sub-row:active { background: var(--surface-2); } +.sub-row.is-paused { opacity: 0.55; } +.sub-main { flex: 1; min-width: 0; display: grid; gap: 2px; } +.sub-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.sub-meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.sub-price { display: grid; justify-items: end; gap: 2px; flex: none; } +.price { font-weight: 700; font-variant-numeric: tabular-nums; } +.per { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; } +.badge { + display: inline-block; + margin-right: 6px; + padding: 1px 7px; + border-radius: 999px; + font-size: 11px; + font-weight: 700; + background: var(--surface-2); + color: var(--muted); + text-transform: uppercase; + letter-spacing: 0.03em; +} + +/* ---------- Logos ---------- */ + +.logo { + --size: 44px; + display: grid; + place-items: center; + flex: none; + width: var(--size); + height: var(--size); + border-radius: calc(var(--size) * 0.28); + background: var(--brand, #6B7280); + color: #fff; + box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 1px 2px rgba(0, 0, 0, 0.12); +} +.logo.is-light { color: #15151C; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06); } +.logo svg { width: 56%; height: 56%; fill: currentColor; } +.logo span { font-weight: 800; font-size: calc(var(--size) * 0.38); letter-spacing: -0.02em; } +.logo-sm { --size: 36px; } +.logo-lg { --size: 72px; } +.logo-add { background: var(--accent-soft); color: var(--accent); box-shadow: none; } +.logo-add svg.i { width: 50%; height: 50%; stroke-width: 2.5; } + +/* ---------- Empty state ---------- */ + +.empty { text-align: center; padding: 48px 12px 0; animation: rise 0.5s var(--ease-spring) both; } +.empty h2 { font-size: 22px; margin-top: 24px; } +.empty p { color: var(--muted); margin: 8px auto 24px; max-width: 300px; } +.empty-art { position: relative; width: 140px; height: 120px; margin: 0 auto; } +.empty-art span { + position: absolute; + left: 20px; + width: 100px; height: 64px; + border-radius: 16px; + background: linear-gradient(135deg, var(--accent), var(--accent-2)); + box-shadow: var(--shadow); + animation: float 4s ease-in-out infinite; +} +.empty-art span:nth-child(1) { top: 0; opacity: 0.35; transform: rotate(-10deg); animation-delay: -1s; } +.empty-art span:nth-child(2) { top: 18px; opacity: 0.6; transform: rotate(6deg); animation-delay: -2s; } +.empty-art span:nth-child(3) { top: 40px; } + +/* ---------- Buttons ---------- */ + +.btn { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 8px; + min-height: 48px; + padding: 0 20px; + border: 0; + border-radius: 14px; + font-weight: 650; + font-size: 16px; + text-decoration: none; + transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease; +} +.btn:active { transform: scale(0.97); } +.btn-primary { background: var(--accent); color: var(--accent-ink); } +.btn-primary:hover { filter: brightness(1.06); } +.btn-secondary { background: var(--accent-soft); color: var(--accent); } +.btn-ghost { background: var(--surface-2); color: var(--text); } +.btn-ghost.danger, .btn-danger { color: var(--danger); } +.btn-danger { background: color-mix(in srgb, var(--danger) 14%, transparent); } +.btn-block { width: 100%; } +.btn-sm { min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: 10px; } +.btn svg.i { width: 18px; height: 18px; } +.btn-row { display: flex; gap: 10px; } +.btn-row > .btn { flex: 1; } + +.fab { + position: fixed; + right: max(var(--gutter), calc((100vw - 560px) / 2 + var(--gutter))); + bottom: calc(var(--safe-bottom) + 22px); + z-index: 10; + display: grid; + place-items: center; + width: 62px; height: 62px; + border: 0; + border-radius: 22px; + color: #fff; + background: linear-gradient(135deg, var(--accent), var(--accent-2)); + box-shadow: 0 12px 28px color-mix(in srgb, var(--accent) 45%, transparent); + transition: transform 0.2s var(--ease-spring); + animation: pop 0.5s 0.15s var(--ease-spring) both; +} +.fab:active { transform: scale(0.9) rotate(90deg); } +.fab svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; } + +/* ---------- Sheets ---------- */ + +dialog.sheet { + position: fixed; + inset: 0; + width: 100%; + max-width: none; + height: 100%; + max-height: none; + margin: 0; + padding: 0; + border: 0; + background: transparent; + color: var(--text); + overflow: hidden; +} +dialog.sheet::backdrop { background: rgba(8, 8, 16, 0); transition: background 0.26s ease; } +dialog.sheet.open::backdrop { background: rgba(8, 8, 16, 0.45); } + +.sheet-panel { + position: absolute; + left: 50%; + bottom: 0; + display: flex; + flex-direction: column; + width: 100%; + max-width: 560px; + max-height: calc(100dvh - var(--safe-top) - 24px); + border-radius: 26px 26px 0 0; + background: var(--bg); + box-shadow: var(--shadow-lg); + transform: translate(-50%, 100%); + transition: transform 0.32s var(--ease-spring); +} +dialog.sheet.open .sheet-panel { transform: translate(-50%, 0); } +.sheet-panel.dragging { transition: none; } +.sheet-tall .sheet-panel { height: calc(100dvh - var(--safe-top) - 24px); } + +.sheet-head { + position: relative; + display: flex; + align-items: center; + gap: 8px; + padding: 22px 16px 10px; + touch-action: none; + user-select: none; +} +.sheet-head h2 { flex: 1; font-size: 19px; font-weight: 750; letter-spacing: -0.01em; } +.sheet-head .icon-btn { width: 36px; height: 36px; background: var(--surface-2); box-shadow: none; } +.sheet-head .icon-btn svg { width: 18px; height: 18px; } +.sheet-grip { + position: absolute; + top: 8px; left: 50%; + width: 40px; height: 5px; + margin-left: -20px; + border-radius: 3px; + background: color-mix(in srgb, var(--muted) 45%, transparent); +} +.sheet-body { + flex: 1; + overflow-y: auto; + overscroll-behavior: contain; + padding: 4px 16px 20px; + -webkit-overflow-scrolling: touch; +} +.sheet-foot { + padding: 12px 16px calc(var(--safe-bottom) + 12px); + border-top: 1px solid var(--line); + background: var(--bg); +} +.sheet-confirm .sheet-head h2 { font-size: 17px; font-weight: 650; line-height: 1.35; } +.sheet-confirm .sheet-body { padding: 0; } + +@media (min-width: 700px) and (min-height: 600px) { + .sheet-panel { + bottom: 50%; + border-radius: 26px; + max-height: min(820px, calc(100dvh - 80px)); + transform: translate(-50%, calc(50% + 40px)) scale(0.98); + opacity: 0; + transition: transform 0.3s var(--ease-spring), opacity 0.2s ease; + } + dialog.sheet.open .sheet-panel { transform: translate(-50%, 50%); opacity: 1; } + .sheet-tall .sheet-panel { height: min(820px, calc(100dvh - 80px)); } + .sheet-grip { display: none; } + .sheet-foot { border-radius: 0 0 26px 26px; } +} + +/* ---------- Picker ---------- */ + +.picker { display: grid; gap: 12px; } +.search-wrap { position: relative; } +.search-wrap svg.i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 20px; height: 20px; } +.search-input { padding-left: 44px !important; } +.chips { + display: flex; + gap: 8px; + overflow-x: auto; + margin: 0 -16px; + padding: 0 16px 2px; + scrollbar-width: none; +} +.chips::-webkit-scrollbar { display: none; } +.chip { + flex: none; + min-height: 36px; + padding: 0 14px; + border: 0; + border-radius: 999px; + background: var(--surface); + box-shadow: inset 0 0 0 1px var(--line); + font-size: 14px; + font-weight: 600; + color: var(--muted); + transition: background 0.15s ease, color 0.15s ease; +} +.chip.active { background: var(--text); color: var(--bg); box-shadow: none; } + +.catalog-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); + gap: 10px; +} +.cat-tile { + display: grid; + justify-items: center; + align-content: start; + gap: 4px; + padding: 14px 6px 12px; + border: 0; + border-radius: var(--radius-sm); + background: var(--surface); + box-shadow: var(--shadow); + text-align: center; + transition: transform 0.15s ease; + animation: rise 0.35s var(--ease-spring) both; +} +.cat-tile:active { transform: scale(0.95); } +.cat-tile .logo { margin-bottom: 6px; } +.cat-name { font-size: 13px; font-weight: 650; line-height: 1.2; overflow-wrap: anywhere; } +.cat-hint { font-size: 11px; color: var(--muted); line-height: 1.2; } +.cat-custom { box-shadow: inset 0 0 0 2px var(--accent-soft); background: transparent; } +.no-results { grid-column: 1 / -1; display: grid; gap: 12px; justify-items: center; text-align: center; padding: 16px 0; } + +/* ---------- Form ---------- */ + +.form { display: grid; gap: 16px; } +.form-hero { display: grid; justify-items: center; gap: 10px; padding: 6px 0 4px; } +.form-hero .logo { animation: pop 0.45s var(--ease-spring) both; } +.hero-name { font-size: 20px; font-weight: 750; text-align: center; overflow-wrap: anywhere; } + +.field { display: grid; gap: 6px; } +.field label, .label { font-size: 13px; font-weight: 650; color: var(--muted); } +.field-grid { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; } +.field-grid > .field:only-child { grid-column: 1 / -1; } + +.input { + width: 100%; + min-height: 50px; + padding: 12px 14px; + border: 0; + border-radius: var(--radius-sm); + background: var(--surface); + box-shadow: inset 0 0 0 1px var(--line); + font-size: 16px; /* β‰₯16px prevents iOS zoom on focus */ + transition: box-shadow 0.15s ease; +} +.input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); } +select.input { + appearance: none; + -webkit-appearance: none; + padding-right: 38px; + background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a9c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 18px; +} +textarea.input { resize: vertical; min-height: 90px; line-height: 1.4; } +input[type="date"].input { appearance: none; -webkit-appearance: none; display: flex; align-items: center; } +input[type="date"]::-webkit-date-and-time-value { text-align: left; } +.price-row { display: grid; grid-template-columns: 1fr 112px; gap: 8px; } +.input-price { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; } +.input-color { width: 64px; padding: 6px; } +.input-color::-webkit-color-swatch-wrapper { padding: 0; } +.input-color::-webkit-color-swatch { border: 0; border-radius: 10px; } +.input-color::-moz-color-swatch { border: 0; border-radius: 10px; } + +.custom-freq { display: flex; align-items: center; gap: 8px; margin-top: 8px; animation: rise 0.25s ease both; } +.custom-freq > span { font-weight: 600; color: var(--muted); } +.input-every { width: 84px; text-align: center; } + +.hint { font-size: 12.5px; color: var(--muted); line-height: 1.35; } +.error { font-size: 13px; color: var(--danger); font-weight: 600; min-height: 0; } +.error:empty { display: none; } +.has-error .input { box-shadow: inset 0 0 0 2px var(--danger); } + +.preview { + padding: 12px 14px; + border-radius: var(--radius-sm); + background: var(--accent-soft); + color: var(--accent); + font-size: 14px; + font-weight: 650; + animation: rise 0.25s ease both; +} + +.switch-row { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + padding: 14px; + border-radius: var(--radius-sm); + background: var(--surface); + box-shadow: inset 0 0 0 1px var(--line); +} +.switch-row > span { display: grid; gap: 2px; } +.switch { + appearance: none; + -webkit-appearance: none; + position: relative; + flex: none; + width: 52px; height: 32px; + margin: 0; + border-radius: 999px; + background: var(--surface-2); + box-shadow: inset 0 0 0 1px var(--line); + transition: background 0.2s ease; +} +.switch::after { + content: ""; + position: absolute; + top: 3px; left: 3px; + width: 26px; height: 26px; + border-radius: 50%; + background: #fff; + box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); + transition: transform 0.25s var(--ease-spring); +} +.switch:checked { background: var(--ok); } +.switch:checked::after { transform: translateX(20px); } + +.form-actions { display: grid; gap: 10px; } + +/* ---------- Settings ---------- */ + +.settings { display: grid; gap: 22px; } +.set-group h3 { + margin: 0 4px 8px; + font-size: 13px; + font-weight: 700; + color: var(--muted); + text-transform: uppercase; + letter-spacing: 0.05em; +} +.set-card { border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; } +.set-row { + display: flex; + align-items: center; + gap: 12px; + width: 100%; + min-height: 56px; + padding: 10px 16px; + border: 0; + background: transparent; + text-align: left; + text-decoration: none; + color: var(--text); +} +.set-card > * + * { border-top: 1px solid var(--line); } +.set-text { flex: 1; min-width: 0; display: grid; gap: 2px; } +.set-text label, .set-text > span:first-child { font-weight: 600; font-size: 15.5px; } +.set-row select.input { width: auto; min-width: 128px; min-height: 40px; padding-top: 6px; padding-bottom: 6px; background-color: var(--surface-2); box-shadow: none; } +.set-row .select-compact { max-width: 160px; } +.set-action { transition: background 0.15s ease; } +.set-action:active { background: var(--surface-2); } +.set-action > svg.i:first-child { color: var(--accent); } +.set-action.danger, .set-action.danger > svg.i:first-child { color: var(--danger); } +.set-action .chev { width: 18px; height: 18px; color: var(--muted); } +.set-note { padding: 14px 16px; font-size: 13.5px; color: var(--muted); } +.rate-row { gap: 10px; } +.rate-label, .rate-cur { font-weight: 650; font-variant-numeric: tabular-nums; flex: none; } +.input-rate { min-height: 42px; flex: 1; text-align: right; background: var(--surface-2); box-shadow: none; } +.pill { padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--surface-2); color: var(--muted); flex: none; } +.pill-ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); } +.privacy { display: flex; gap: 10px; align-items: flex-start; padding: 0 4px; color: var(--muted); } +.privacy svg.i { color: var(--ok); } +.set-foot { font-size: 13px; line-height: 1.45; } +.settings > .set-foot { text-align: center; } + +/* ---------- Toasts ---------- */ + +.toast-host { + position: fixed; + left: 0; right: 0; + bottom: calc(var(--safe-bottom) + 96px); + z-index: 1000; + display: grid; + justify-items: center; + gap: 8px; + padding: 0 var(--gutter); + pointer-events: none; +} +.toast { + display: flex; + align-items: center; + gap: 14px; + max-width: 520px; + padding: 12px 16px; + border-radius: 16px; + background: #1D1D26; + color: #fff; + font-size: 15px; + font-weight: 550; + box-shadow: var(--shadow-lg); + pointer-events: auto; + opacity: 0; + transform: translateY(16px) scale(0.96); + transition: opacity 0.22s ease, transform 0.3s var(--ease-spring); +} +.toast.show { opacity: 1; transform: none; } +.toast-action { + flex: none; + min-height: 36px; + padding: 0 10px; + border: 0; + border-radius: 10px; + background: rgba(255, 255, 255, 0.12); + color: #B9B1FF; + font-weight: 750; +} + +/* ---------- Install bubble ---------- */ + +.install-bubble { + position: fixed; + left: 50%; + bottom: calc(var(--safe-bottom) + 20px); + z-index: 50; + width: calc(100% - 2 * var(--gutter)); + max-width: 400px; + padding: 18px 18px 16px; + border-radius: 24px; + background: var(--surface); + box-shadow: var(--shadow-lg), 0 0 0 1px var(--line); + transform: translate(-50%, calc(100% + 40px)); + opacity: 0; + transition: transform 0.55s var(--ease-spring), opacity 0.3s ease; +} +.install-bubble.show { transform: translate(-50%, 0); opacity: 1; } +.install-bubble.mode-ios { bottom: calc(var(--safe-bottom) + 56px); } +.install-bubble.mode-ipad { top: calc(var(--safe-top) + 64px); bottom: auto; left: auto; right: 16px; transform: translateY(-30px); } +.install-bubble.mode-ipad.show { transform: none; } +.install-bubble p { font-size: 14.5px; color: var(--muted); margin-top: 6px; } +.install-bubble .btn-row { margin-top: 14px; } +.bubble-close { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; background: var(--surface-2); box-shadow: none; } +.bubble-close svg { width: 16px; height: 16px; } +.install-top { display: flex; align-items: center; gap: 14px; padding-right: 30px; } +.install-top h3 { font-size: 18px; font-weight: 750; letter-spacing: -0.01em; } + +.install-steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; } +.install-steps li { display: flex; align-items: flex-start; gap: 10px; font-size: 14.5px; line-height: 1.35; } +.step-n { + display: grid; place-items: center; flex: none; + width: 24px; height: 24px; border-radius: 50%; + background: var(--accent-soft); color: var(--accent); + font-size: 13px; font-weight: 800; +} + +.bubble-pointer { + position: absolute; + left: 50%; + bottom: -46px; + display: grid; place-items: center; + width: 36px; height: 36px; + margin-left: -18px; + border-radius: 50%; + background: var(--accent); + color: #fff; + box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 50%, transparent); + animation: point-down 1.2s ease-in-out infinite; +} +.bubble-pointer svg.i { transform: rotate(-90deg); width: 20px; height: 20px; stroke-width: 3; } +.mode-ipad .bubble-pointer { top: -46px; bottom: auto; left: auto; right: 30px; animation-name: point-up; } +.mode-ipad .bubble-pointer svg.i { transform: rotate(90deg); } + +/* Phone + flying app icon animation */ +.install-anim { position: relative; flex: none; width: 58px; height: 92px; } +.phone { + position: absolute; inset: 0; + border-radius: 14px; + background: linear-gradient(160deg, #2b2b3a, #14141c); + box-shadow: inset 0 0 0 2px #3a3a4c, 0 4px 12px rgba(0, 0, 0, 0.25); + padding: 14px 7px 8px; +} +.phone-notch { position: absolute; top: 5px; left: 50%; width: 18px; height: 4px; margin-left: -9px; border-radius: 3px; background: #000; } +.phone-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; } +.app-dot, .app-slot { aspect-ratio: 1; border-radius: 4px; } +.app-dot { background: rgba(255, 255, 255, 0.18); } +.app-dot:nth-child(3n+1) { background: rgba(255, 140, 120, 0.55); } +.app-dot:nth-child(4n+2) { background: rgba(120, 200, 255, 0.55); } +.app-dot:nth-child(5n+3) { background: rgba(140, 230, 160, 0.5); } +.app-slot { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35); animation: slot-pulse 3.2s ease-in-out infinite; } +.fly-icon { + position: absolute; + width: 12px; height: 12px; + /* Final position = 12th cell (row 4, col 3): 7px padding + 2 Γ— (12px cell + 4px gap). */ + left: 39px; top: 62px; + border-radius: 3px; + animation: fly-in 3.2s var(--ease-spring) infinite; +} + +/* ---------- Animations ---------- */ + +@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } } +@keyframes pop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } } +@keyframes float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } } +@keyframes point-down { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } } +@keyframes point-up { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } } +@keyframes fly-in { + 0% { transform: translate(-40px, -80px) scale(2.6); opacity: 0; } + 12% { opacity: 1; } + 45% { transform: translate(0, 0) scale(0.85); opacity: 1; } + 55% { transform: translate(0, 0) scale(1.15); } + 65%, 88% { transform: translate(0, 0) scale(1); opacity: 1; } + 100% { transform: translate(0, 0) scale(1); opacity: 0; } +} +@keyframes slot-pulse { 0%, 40% { opacity: 1; } 50%, 90% { opacity: 0; } 100% { opacity: 1; } } + +@media (prefers-reduced-motion: reduce) { + *, *::before, *::after { + animation-duration: 0.01ms !important; + animation-iteration-count: 1 !important; + transition-duration: 0.01ms !important; + } +} + +.fatal, .noscript { padding: 24px; text-align: center; color: var(--danger); } diff --git a/docs/screenshots/catalog.png b/docs/screenshots/catalog.png new file mode 100644 index 0000000..b29e593 Binary files /dev/null and b/docs/screenshots/catalog.png differ diff --git a/docs/screenshots/form.png b/docs/screenshots/form.png new file mode 100644 index 0000000..b795566 Binary files /dev/null and b/docs/screenshots/form.png differ diff --git a/docs/screenshots/home-dark.png b/docs/screenshots/home-dark.png new file mode 100644 index 0000000..a8b4b84 Binary files /dev/null and b/docs/screenshots/home-dark.png differ diff --git a/docs/screenshots/home-light.png b/docs/screenshots/home-light.png new file mode 100644 index 0000000..27315a1 Binary files /dev/null and b/docs/screenshots/home-light.png differ diff --git a/docs/screenshots/install-ios.png b/docs/screenshots/install-ios.png new file mode 100644 index 0000000..4e05855 Binary files /dev/null and b/docs/screenshots/install-ios.png differ diff --git a/docs/screenshots/settings.png b/docs/screenshots/settings.png new file mode 100644 index 0000000..50b6843 Binary files /dev/null and b/docs/screenshots/settings.png differ diff --git a/icons/apple-touch-icon.png b/icons/apple-touch-icon.png new file mode 100644 index 0000000..19cef52 Binary files /dev/null and b/icons/apple-touch-icon.png differ diff --git a/icons/badge-96.png b/icons/badge-96.png new file mode 100644 index 0000000..938282c Binary files /dev/null and b/icons/badge-96.png differ diff --git a/icons/icon-192.png b/icons/icon-192.png new file mode 100644 index 0000000..88e4ea5 Binary files /dev/null and b/icons/icon-192.png differ diff --git a/icons/icon-512.png b/icons/icon-512.png new file mode 100644 index 0000000..ba53f7b Binary files /dev/null and b/icons/icon-512.png differ diff --git a/icons/icon.svg b/icons/icon.svg new file mode 100644 index 0000000..7942dc2 --- /dev/null +++ b/icons/icon.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/icons/maskable-512.png b/icons/maskable-512.png new file mode 100644 index 0000000..d0d5303 Binary files /dev/null and b/icons/maskable-512.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..f8900a6 --- /dev/null +++ b/index.html @@ -0,0 +1,84 @@ + + + + + + + SubTrack + + + + + + + + + + + + + + + +
+
+
+ +
+

SubTrack

+

+
+
+ +
+ +
+
+
+

+
+
+
+
+

+ +
+
    +
    + +
    +
    + + + +
    + + + + + + + + + + + + + + + + diff --git a/js/app.js b/js/app.js new file mode 100644 index 0000000..d7aed11 --- /dev/null +++ b/js/app.js @@ -0,0 +1,964 @@ +/* + * SubTrack - main application controller. + */ +(function (g) { + 'use strict'; + const ST = g.ST; + const { db, schedule, catalog, i18n, ui, reminders } = ST; + const { h, icon, logo, sheet, toast, haptic } = ui; + const t = (...a) => i18n.t(...a); + + const state = { + subs: [], + settings: null, + registration: null, + }; + + const $ = (id) => document.getElementById(id); + + // ---------- Boot ---------- + + async function boot() { + try { + state.settings = await db.getSettings(); + state.subs = await db.getAll(); + } catch (err) { + console.error(err); + document.getElementById('main').replaceChildren( + h('p', { class: 'fatal', text: 'IndexedDB is not available (private browsing?). SubTrack cannot store data in this browser.' })); + return; + } + applyLanguage(); + applyTheme(); + bindStatic(); + render(); + registerServiceWorker(); + ST.install.init(); + handleLaunchAction(); + document.addEventListener('visibilitychange', () => { + if (document.visibilityState === 'visible') { + render(); // Day may have changed while in background. + runReminders(); + } + }); + } + + function applyLanguage() { + i18n.setLang(state.settings.lang); + document.documentElement.lang = i18n.lang; + for (const el of document.querySelectorAll('[data-i18n]')) el.textContent = t(el.dataset.i18n); + for (const el of document.querySelectorAll('[data-i18n-label]')) { + el.setAttribute('aria-label', t(el.dataset.i18nLabel)); + el.setAttribute('title', t(el.dataset.i18nLabel)); + } + const sort = $('sort'); + sort.replaceChildren(...['next', 'price', 'name'].map((v) => + h('option', { value: v, text: t(`sort.${v}`), selected: state.settings.sort === v }))); + } + + const themeQuery = g.matchMedia('(prefers-color-scheme: dark)'); + function applyTheme() { + const pref = state.settings.theme; + const root = document.documentElement; + if (pref === 'auto') delete root.dataset.theme; + else root.dataset.theme = pref; + const dark = pref === 'dark' || (pref === 'auto' && themeQuery.matches); + for (const m of document.querySelectorAll('meta[name="theme-color"]')) { + m.setAttribute('content', dark ? '#0B0B10' : '#F4F4F8'); + } + } + themeQuery.addEventListener('change', () => state.settings && applyTheme()); + + function bindStatic() { + $('btn-add').addEventListener('click', () => { haptic(); openPicker(); }); + $('btn-empty-add').addEventListener('click', () => openPicker()); + $('btn-settings').addEventListener('click', () => openSettings()); + $('sort').addEventListener('change', async (e) => { + state.settings.sort = e.target.value; + await db.setSetting('sort', e.target.value); + renderList(); + }); + } + + function handleLaunchAction() { + const params = new URLSearchParams(location.search); + if (params.get('action') === 'add') { + history.replaceState(null, '', location.pathname); + openPicker(); + } + } + + async function saveSetting(key, value) { + state.settings[key] = value; + await db.setSetting(key, value); + } + + // ---------- Derived data ---------- + + function enrich(sub, today) { + const next = schedule.nextRenewal(sub.startDate, sub.freq, today); + return { + sub, + next, + days: next ? schedule.diffDays(today, next) : Infinity, + monthly: schedule.monthlyCost(sub.price, sub.freq), + }; + } + + function convert(amount, from) { + const main = state.settings.currency; + if (from === main) return amount; + const rate = state.settings.rates[from]; + return rate > 0 ? amount * rate : null; + } + + function totals(rows) { + const byCur = new Map(); + for (const r of rows) { + if (!r.sub.active) continue; + byCur.set(r.sub.currency, (byCur.get(r.sub.currency) || 0) + r.monthly); + } + const main = state.settings.currency; + let converted = 0; + let complete = true; + for (const [cur, v] of byCur) { + const c = convert(v, cur); + if (c == null) complete = false; + else converted += c; + } + const currencies = [...byCur.keys()]; + return { + byCur, + single: currencies.length <= 1, + converted: complete ? converted : null, + mainCur: currencies.length === 1 ? currencies[0] : main, + }; + } + + // ---------- Render ---------- + + function render() { + const today = schedule.today(); + const rows = state.subs.map((s) => enrich(s, today)); + const empty = rows.length === 0; + $('empty').hidden = !empty; + $('summary').hidden = empty; + $('upcoming-section').hidden = empty; + $('list-section').hidden = empty; + if (empty) return; + renderSummary(rows); + renderUpcoming(rows); + renderList(rows); + } + + function renderSummary(rows) { + const yearly = state.settings.view === 'yearly'; + const mult = yearly ? 12 : 1; + const tot = totals(rows); + const activeCount = rows.filter((r) => r.sub.active).length; + const main = state.settings.currency; + + let amount; + let extra = null; + if (tot.single) { + const [[cur, v] = [main, 0]] = [...tot.byCur]; + amount = h('p', { class: 'amount', text: i18n.fmtMoney(v * mult, cur) }); + } else if (tot.converted != null) { + amount = h('p', { class: 'amount' }, h('span', { class: 'approx', text: 'β‰ˆ ' }), i18n.fmtMoney(tot.converted * mult, main)); + extra = h('p', { class: 'summary-note', text: t('summary.approx') }); + } else { + const sorted = [...tot.byCur].sort(([a], [b]) => (a === main ? -1 : b === main ? 1 : a.localeCompare(b))); + amount = h('div', { class: 'amount-multi' }, + sorted.map(([cur, v]) => h('p', { class: 'amount amount-sm', text: i18n.fmtMoney(v * mult, cur) }))); + extra = h('p', { class: 'summary-note', text: t('summary.mixed') }); + } + + const seg = h('div', { class: 'seg seg-sm', role: 'group', 'aria-label': t('summary.toggle') }, + ['monthly', 'yearly'].map((v) => h('button', { + type: 'button', + class: state.settings.view === v ? 'active' : '', + 'aria-pressed': String(state.settings.view === v), + text: t(`freq.${v}`), + on: { + click: async () => { + if (state.settings.view === v) return; + haptic(); + await saveSetting('view', v); + render(); + }, + }, + }))); + + $('summary').replaceChildren( + h('div', { class: 'summary-top' }, + h('p', { class: 'summary-label', text: t(yearly ? 'summary.yearly' : 'summary.monthly') }), + seg), + amount, + extra, + h('p', { class: 'summary-count', text: i18n.tp('summary.active', activeCount) })); + } + + function renderUpcoming(rows) { + const soon = rows + .filter((r) => r.sub.active && r.days <= 30) + .sort((a, b) => a.days - b.days) + .slice(0, 12); + const host = $('upcoming'); + if (!soon.length) { + host.replaceChildren(h('p', { class: 'muted upcoming-none', text: t('upcoming.none') })); + return; + } + host.replaceChildren(...soon.map((r) => h('button', { + type: 'button', + class: `up-card${r.days <= 1 ? ' is-urgent' : ''}`, + on: { click: () => openForm({ sub: r.sub }) }, + }, + logo(r.sub, 'sm'), + h('span', { class: 'up-name', text: r.sub.name }), + h('span', { class: 'up-when', text: i18n.relDays(r.days, r.next) }), + h('span', { class: 'up-price', text: i18n.fmtMoney(r.sub.price, r.sub.currency) })))); + } + + function renderList(rowsArg) { + const today = schedule.today(); + const rows = rowsArg || state.subs.map((s) => enrich(s, today)); + const sort = state.settings.sort; + const cmp = { + next: (a, b) => a.days - b.days || a.sub.name.localeCompare(b.sub.name), + price: (a, b) => (convert(b.monthly, b.sub.currency) ?? b.monthly) - (convert(a.monthly, a.sub.currency) ?? a.monthly), + name: (a, b) => a.sub.name.localeCompare(b.sub.name, i18n.lang), + }[sort] || (() => 0); + rows.sort((a, b) => (b.sub.active - a.sub.active) || cmp(a, b)); + + $('list').replaceChildren(...rows.map((r) => { + const { sub } = r; + const meta = sub.active + ? `${i18n.freqLabel(sub.freq)} Β· ${i18n.relDays(r.days, r.next)}` + : i18n.freqLabel(sub.freq); + return h('li', null, h('button', { + type: 'button', + class: `sub-row${sub.active ? '' : ' is-paused'}`, + on: { click: () => openForm({ sub }) }, + }, + logo(sub), + h('span', { class: 'sub-main' }, + h('span', { class: 'sub-name', text: sub.name }), + h('span', { class: 'sub-meta' }, + sub.active ? null : h('span', { class: 'badge', text: t('list.paused') }), + meta)), + h('span', { class: 'sub-price' }, + h('span', { class: 'price', text: i18n.fmtMoney(sub.price, sub.currency) }), + sub.freq.unit !== 'month' || sub.freq.every !== 1 + ? h('span', { class: 'per', text: `β‰ˆ ${i18n.fmtMoney(r.monthly, sub.currency)}${t('per.month')}` }) + : null))); + })); + } + + // ---------- Catalogue picker ---------- + + function openPicker() { + let category = 'all'; + let query = ''; + + const search = h('input', { + type: 'search', + class: 'input search-input', + placeholder: t('picker.search'), + 'aria-label': t('picker.search'), + autocomplete: 'off', + enterkeyhint: 'search', + }); + const chips = h('div', { class: 'chips', role: 'tablist' }); + const grid = h('div', { class: 'catalog-grid' }); + + const usedCats = new Set(catalog.ITEMS.map((i) => i.category)); + const cats = ['all', ...catalog.CATEGORIES.filter((c) => usedCats.has(c))]; + chips.append(...cats.map((c) => h('button', { + type: 'button', + role: 'tab', + class: `chip${c === category ? ' active' : ''}`, + dataset: { cat: c }, + text: c === 'all' ? t('picker.all') : t(`cat.${c}`), + on: { + click: (e) => { + category = c; + for (const b of chips.children) { + b.classList.toggle('active', b === e.currentTarget); + b.setAttribute('aria-selected', String(b === e.currentTarget)); + } + draw(); + }, + }, + }))); + + const s = sheet({ + title: t('picker.title'), + className: 'sheet-tall', + body: h('div', { class: 'picker' }, + h('div', { class: 'search-wrap' }, icon('search'), search), + chips, + grid), + }); + + function norm(v) { + return v.normalize('NFD').replace(/[Μ€-Ν―]/g, '').toLowerCase().replace(/[^a-z0-9]/g, ''); + } + + function draw() { + const q = norm(query); + const items = catalog.ITEMS + .filter((i) => (q ? norm(i.name).includes(q) || i.id.includes(q) : category === 'all' || i.category === category)) + .sort((a, b) => a.name.localeCompare(b.name, i18n.lang)); + + const tiles = []; + if (!q) { + tiles.push(h('button', { + type: 'button', + class: 'cat-tile cat-custom', + on: { click: () => { s.close(); openForm({ custom: '', back: openPicker }); } }, + }, + h('div', { class: 'logo logo-add', 'aria-hidden': 'true' }, icon('plus')), + h('span', { class: 'cat-name', text: t('picker.custom') }), + h('span', { class: 'cat-hint', text: t('picker.customHint') }))); + } + for (const item of items) { + tiles.push(h('button', { + type: 'button', + class: 'cat-tile', + on: { click: () => { haptic(); s.close(); openForm({ item, back: openPicker }); } }, + }, + logo(item), + h('span', { class: 'cat-name', text: item.name }), + h('span', { class: 'cat-hint', text: t(`cat.${item.category}`) }))); + } + if (q) { + tiles.push(h('div', { class: 'no-results' }, + items.length ? null : h('p', { class: 'muted', text: t('picker.noResults', { q: query.trim() }) }), + h('button', { + type: 'button', + class: 'btn btn-secondary', + text: t('picker.createCustom', { q: query.trim() }), + on: { click: () => { s.close(); openForm({ custom: query.trim(), back: openPicker }); } }, + }))); + } + grid.replaceChildren(...tiles); + } + + search.addEventListener('input', () => { + query = search.value; + chips.hidden = !!query.trim(); + draw(); + }); + draw(); + // Only autofocus on devices with a fine pointer: on phones the keyboard + // would cover the catalogue. + if (g.matchMedia('(pointer: fine)').matches) search.focus(); + } + + // ---------- Add / edit form ---------- + + function parsePrice(v) { + const s = String(v).trim().replace(/\s/g, ''); + if (!s) return NaN; + // Accept both "1.234,56" and "1,234.56" and "12,99". + const lastComma = s.lastIndexOf(','); + const lastDot = s.lastIndexOf('.'); + let n = s; + if (lastComma > lastDot) n = s.replace(/\./g, '').replace(',', '.'); + else n = s.replace(/,/g, ''); + return /^\d+(\.\d+)?$/.test(n) ? Number(n) : NaN; + } + + function field(labelText, control, hint) { + const id = control.id || (control.id = `f-${Math.random().toString(36).slice(2, 8)}`); + return h('div', { class: 'field' }, + h('label', { for: id, text: labelText }), + control, + hint ? h('p', { class: 'hint', text: hint }) : null, + h('p', { class: 'error', 'aria-live': 'polite' })); + } + + function select(options, value) { + return h('select', { class: 'input' }, + options.map(([v, label]) => h('option', { value: String(v), text: label, selected: String(v) === String(value) }))); + } + + function reminderOptions() { + return [ + [-1, t('form.reminderNone')], + [0, t('form.reminderSame')], + ...[1, 2, 3, 5, 7, 14].map((n) => [n, i18n.tp('form.reminderDays', n)]), + ]; + } + + function currencyOptions() { + let names = null; + try { names = new Intl.DisplayNames([i18n.lang], { type: 'currency' }); } catch { /* old browser */ } + return db.CURRENCIES.map((c) => [c, names ? `${c} Β· ${names.of(c)}` : c]); + } + + /** + * opts: { sub } to edit, { item } from catalogue, { custom: 'name' } for custom. + */ + function openForm(opts) { + const editing = !!opts.sub; + const item = opts.item || (opts.sub && opts.sub.catalogId && catalog.get(opts.sub.catalogId)) || null; + const base = opts.sub || { + catalogId: item ? item.id : null, + name: item ? item.name : (opts.custom || ''), + price: '', + currency: state.settings.currency, + freq: { every: 1, unit: 'month' }, + startDate: schedule.toISO(schedule.today()), + category: item ? item.category : 'other', + color: item ? ui.brandColor(item) : '6D5EF5', + reminder: state.settings.defaultReminder, + notes: '', + active: true, + }; + let freq = { ...base.freq }; + + const header = h('div', { class: 'form-hero' }); + const name = h('input', { class: 'input', type: 'text', value: base.name, maxlength: 80, placeholder: t('form.namePh'), autocomplete: 'off', required: true }); + const price = h('input', { + class: 'input input-price', + type: 'text', + inputmode: 'decimal', + value: base.price === '' ? '' : String(base.price).replace('.', i18n.lang === 'it' ? ',' : '.'), + placeholder: i18n.lang === 'it' ? '9,99' : '9.99', + autocomplete: 'off', + }); + // Codes only: the narrow select next to the price can't fit names. + const currency = select(db.CURRENCIES.map((c) => [c, c]), base.currency); + currency.setAttribute('aria-label', t('form.currency')); + currency.classList.add('input-currency'); + const start = h('input', { class: 'input', type: 'date', value: base.startDate, required: true }); + const category = select(catalog.CATEGORIES.map((c) => [c, t(`cat.${c}`)]), base.category); + const color = h('input', { class: 'input input-color', type: 'color', value: `#${base.color}` }); + const reminder = select(reminderOptions(), base.reminder); + const notes = h('textarea', { class: 'input', rows: 3, maxlength: 1000, placeholder: t('form.notesPh') }); + notes.value = base.notes || ''; + const active = h('input', { type: 'checkbox', role: 'switch', class: 'switch', checked: base.active }); + + // Frequency: segmented presets + custom "every N unit". + const presets = ['monthly', 'quarterly', 'yearly', 'custom']; + const presetOf = (f) => { + const p = schedule.presetOf(f); + return presets.includes(p) ? p : 'custom'; + }; + let preset = presetOf(freq); + const every = h('input', { class: 'input input-every', type: 'number', inputmode: 'numeric', min: 1, max: 999, value: freq.every }); + const unit = select(schedule.UNITS.map((u) => [u, i18n.tp(`unit.${u}`, 2)]), freq.unit); + const customRow = h('div', { class: 'custom-freq', hidden: preset !== 'custom' }, + h('span', { text: t('form.every') }), every, unit); + const seg = h('div', { class: 'seg', role: 'radiogroup', 'aria-label': t('form.frequency') }, + presets.map((p) => h('button', { + type: 'button', + role: 'radio', + 'aria-checked': String(p === preset), + class: p === preset ? 'active' : '', + dataset: { preset: p }, + text: t(`freq.${p}`), + on: { click: () => setPreset(p) }, + }))); + const freqError = h('p', { class: 'error', 'aria-live': 'polite' }); + + function setPreset(p) { + preset = p; + for (const b of seg.children) { + const on = b.dataset.preset === p; + b.classList.toggle('active', on); + b.setAttribute('aria-checked', String(on)); + } + customRow.hidden = p !== 'custom'; + if (p !== 'custom') freq = { ...schedule.PRESETS[p] }; + else { + freq = { every: Math.max(1, parseInt(every.value, 10) || 1), unit: unit.value }; + every.focus(); + } + every.value = freq.every; + unit.value = freq.unit; + updatePreview(); + } + + const updateCustom = () => { + if (preset !== 'custom') return; + freq = { every: parseInt(every.value, 10), unit: unit.value }; + updatePreview(); + }; + every.addEventListener('input', updateCustom); + unit.addEventListener('change', updateCustom); + + const preview = h('p', { class: 'preview', 'aria-live': 'polite' }); + function updatePreview() { + const p = parsePrice(price.value); + const next = schedule.nextRenewal(start.value, freq); + if (!next || !Number.isFinite(p)) { + preview.textContent = ''; + preview.hidden = true; + return; + } + preview.hidden = false; + preview.textContent = t('form.preview', { + date: i18n.fmtDate(next, { weekday: 'short', day: 'numeric', month: 'long', year: 'numeric' }), + monthly: i18n.fmtMoney(schedule.monthlyCost(p, freq), currency.value), + }); + } + + function drawHero() { + const preview = { + name: name.value || '?', + catalogId: base.catalogId, + color: base.catalogId ? base.color : color.value.slice(1), + }; + header.replaceChildren(logo(preview, 'lg'), h('p', { class: 'hero-name', text: name.value || t('form.new') })); + } + + for (const el of [price, start]) el.addEventListener('input', updatePreview); + currency.addEventListener('change', updatePreview); + name.addEventListener('input', drawHero); + color.addEventListener('input', drawHero); + + const priceWrap = h('div', { class: 'field' }, + h('label', { for: 'f-price', text: t('form.price') }), + h('div', { class: 'price-row' }, Object.assign(price, { id: 'f-price' }), currency), + h('p', { class: 'error', 'aria-live': 'polite' })); + + const nameField = field(t('form.name'), name); + const startField = field(t('form.start'), start, t('form.startHint')); + + const form = h('form', { class: 'form', novalidate: true }, + header, + nameField, + priceWrap, + h('div', { class: 'field' }, + h('span', { class: 'label', text: t('form.frequency') }), + seg, customRow, freqError), + startField, + preview, + h('div', { class: 'field-grid' }, + field(t('form.category'), category), + base.catalogId ? null : field(t('form.color'), color)), + field(t('form.reminder'), reminder), + field(t('form.notes'), notes), + editing ? h('label', { class: 'switch-row' }, + h('span', null, h('span', { class: 'label', text: t('form.active') }), h('span', { class: 'hint', text: t('form.activeHint') })), + active) : null); + + const saveBtn = h('button', { class: 'btn btn-primary btn-block', type: 'submit', text: t('form.save') }); + saveBtn.setAttribute('form', 'sub-form'); + form.id = 'sub-form'; + const footer = h('div', { class: 'form-actions' }, + editing ? h('div', { class: 'btn-row' }, + h('button', { + class: 'btn btn-ghost', type: 'button', + on: { click: () => exportIcs([opts.sub], opts.sub.name) }, + }, icon('calendar'), t('form.calendar')), + h('button', { + class: 'btn btn-ghost danger', type: 'button', + on: { click: () => removeSub(opts.sub, s) }, + }, icon('trash'), t('form.delete'))) : null, + saveBtn); + + const s = sheet({ + title: editing ? t('form.edit') : t('form.new'), + className: 'sheet-tall', + body: form, + footer, + back: !editing && opts.back ? opts.back : null, + }); + + function setError(fieldEl, msg) { + const err = fieldEl.querySelector('.error'); + err.textContent = msg || ''; + fieldEl.classList.toggle('has-error', !!msg); + } + + form.addEventListener('submit', async (e) => { + e.preventDefault(); + const p = parsePrice(price.value); + const errs = [ + [nameField, name.value.trim() ? '' : t('form.errName')], + [priceWrap, Number.isFinite(p) && p >= 0 ? '' : t('form.errPrice')], + [startField, schedule.parseISO(start.value) ? '' : t('form.errDate')], + ]; + for (const [f, m] of errs) setError(f, m); + const freqOk = schedule.isValidFreq(freq); + freqError.textContent = freqOk ? '' : t('form.errEvery'); + const firstBad = errs.find(([, m]) => m); + if (firstBad || !freqOk) { + haptic(30); + const target = firstBad ? firstBad[0].querySelector('input,select') : every; + target.focus(); + return; + } + const data = { + ...(opts.sub || {}), + catalogId: base.catalogId, + name: name.value, + price: p, + currency: currency.value, + freq, + startDate: start.value, + category: category.value, + color: base.catalogId ? base.color : color.value.slice(1), + reminder: parseInt(reminder.value, 10), + notes: notes.value, + active: editing ? active.checked : true, + }; + try { + const saved = await db.put(data); + const i = state.subs.findIndex((x) => x.id === saved.id); + if (i >= 0) state.subs[i] = saved; + else state.subs.push(saved); + haptic(12); + s.close('saved'); + render(); + afterSave(editing); + } catch (err) { + console.error(err); + toast(String(err.message || err)); + } + }); + + drawHero(); + updatePreview(); + if (!editing && !base.name && g.matchMedia('(pointer: fine)').matches) name.focus(); + } + + function afterSave(editing) { + const canAsk = 'Notification' in g && reminders.permission() === 'default' && !state.settings.notifications; + if (!editing && canAsk && state.subs.length === 1) { + toast(t('toast.saved'), { action: t('settings.notifEnable'), onAction: enableNotifications }); + } else { + toast(t('toast.saved')); + } + runReminders(); + } + + async function removeSub(sub, s) { + const ok = await ui.confirm(t('form.confirmDelete', { name: sub.name }), t('form.delete')); + if (!ok) return; + await db.remove(sub.id); + state.subs = state.subs.filter((x) => x.id !== sub.id); + s.close('deleted'); + render(); + haptic(20); + toast(t('toast.deleted', { name: sub.name }), { + action: t('toast.undo'), + onAction: async () => { + const restored = await db.put(sub); + state.subs.push(restored); + render(); + }, + }); + } + + // ---------- Notifications ---------- + + function notificationStatus() { + if (!('Notification' in g) || !('serviceWorker' in navigator)) { + return ST.install.isIOS && !ST.install.isStandalone() ? 'ios' : 'unsupported'; + } + const p = reminders.permission(); + if (p === 'denied') return 'denied'; + if (p === 'granted' && state.settings.notifications) return 'on'; + return 'off'; + } + + async function enableNotifications() { + const status = notificationStatus(); + if (status === 'ios') { + ST.install.open(); + return false; + } + if (status === 'unsupported') { + toast(t('settings.notifUnsupported')); + return false; + } + let perm = reminders.permission(); + if (perm === 'default') perm = await g.Notification.requestPermission(); + if (perm !== 'granted') { + toast(t('toast.notifDenied')); + return false; + } + await saveSetting('notifications', true); + await registerPeriodicSync(); + toast(t('toast.notifOn')); + runReminders(); + return true; + } + + async function registerPeriodicSync() { + const reg = state.registration; + if (!reg || !reg.periodicSync) return; + try { + const perm = await navigator.permissions.query({ name: 'periodic-background-sync' }); + if (perm.state === 'granted') { + await reg.periodicSync.register('renewal-check', { minInterval: 12 * 60 * 60 * 1000 }); + } + } catch { /* not available */ } + } + + async function runReminders() { + if (!state.registration || !state.settings.notifications) return; + try { + await reminders.check(state.registration); + state.settings = await db.getSettings(); + } catch (err) { + console.warn('Reminder check failed', err); + } + } + + async function testNotification() { + if (notificationStatus() !== 'on' && !(await enableNotifications())) return; + const reg = state.registration || (await navigator.serviceWorker.ready); + reg.showNotification(t('notif.testTitle'), { + body: t('notif.testBody'), + icon: 'icons/icon-192.png', + badge: 'icons/badge-96.png', + tag: 'subtrack-test', + }); + } + + // ---------- Service worker ---------- + + async function registerServiceWorker() { + if (!('serviceWorker' in navigator)) return; + try { + const reg = await navigator.serviceWorker.register('sw.js', { updateViaCache: 'none' }); + state.registration = reg; + reg.addEventListener('updatefound', () => { + const sw = reg.installing; + if (!sw) return; + sw.addEventListener('statechange', () => { + if (sw.state === 'installed' && navigator.serviceWorker.controller) { + toast(t('toast.updated'), { + action: t('toast.reload'), + duration: 15000, + onAction: () => sw.postMessage('skipWaiting'), + }); + } + }); + }); + let reloading = false; + navigator.serviceWorker.addEventListener('controllerchange', () => { + if (reloading) return; + reloading = true; + location.reload(); + }); + await navigator.serviceWorker.ready; + state.registration = await navigator.serviceWorker.getRegistration() || reg; + if (state.settings.notifications) registerPeriodicSync(); + runReminders(); + } catch (err) { + console.warn('Service worker registration failed', err); + } + } + + // ---------- Export / import ---------- + + function exportIcs(subs, label) { + const active = subs.filter((s) => s.active); + if (!active.length) { + toast(t('toast.icsEmpty')); + return; + } + const safe = (label || 'subtrack').toLowerCase().normalize('NFD').replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') || 'subtrack'; + ui.download(`${safe}.ics`, 'text/calendar;charset=utf-8', ST.ics.build(active)); + } + + async function exportBackup() { + const data = await db.exportBackup(); + ui.download(`subtrack-backup-${schedule.toISO(schedule.today())}.json`, 'application/json', JSON.stringify(data, null, 2)); + toast(t('toast.exported')); + } + + function importBackup() { + const input = h('input', { type: 'file', accept: 'application/json,.json' }); + input.addEventListener('change', async () => { + const file = input.files && input.files[0]; + if (!file) return; + try { + if (file.size > 5 * 1024 * 1024) throw new Error('too large'); + const n = await db.importBackup(JSON.parse(await file.text())); + state.settings = await db.getSettings(); + state.subs = await db.getAll(); + applyLanguage(); + applyTheme(); + render(); + toast(i18n.tp('toast.imported', n)); + return n; + } catch (err) { + console.warn(err); + toast(t('toast.invalidFile')); + } + return 0; + }); + input.click(); + } + + // ---------- Settings ---------- + + let settingsSheet = null; + + function openSettings() { + settingsSheet = sheet({ + title: t('settings.title'), + className: 'sheet-tall', + body: settingsBody(), + onClose: () => { settingsSheet = null; }, + }); + } + + function refreshSettings() { + if (!settingsSheet) return; + const top = settingsSheet.body.scrollTop; + settingsSheet.body.replaceChildren(settingsBody()); + settingsSheet.body.scrollTop = top; + const title = settingsSheet.el.querySelector('.sheet-head h2'); + title.textContent = t('settings.title'); + } + + function group(title, ...rows) { + return h('section', { class: 'set-group' }, + h('h3', { text: title }), + h('div', { class: 'set-card' }, rows)); + } + + function row(label, control, hint) { + const id = `s-${Math.random().toString(36).slice(2, 8)}`; + if (control && control.matches && control.matches('select,input')) control.id = id; + return h('div', { class: 'set-row' }, + h('div', { class: 'set-text' }, + h('label', { for: control && control.id ? id : null, text: label }), + hint ? h('p', { class: 'hint', text: hint }) : null), + control); + } + + function actionRow(iconName, label, onClick, cls, hint) { + return h('button', { type: 'button', class: `set-row set-action ${cls || ''}`.trim(), on: { click: onClick } }, + icon(iconName), + h('span', { class: 'set-text' }, h('span', { text: label }), hint ? h('span', { class: 'hint', text: hint }) : null), + icon('chevron', 'chev')); + } + + function settingsBody() { + const st = state.settings; + + const lang = select([['auto', t('settings.langAuto')], ['it', 'Italiano'], ['en', 'English']], st.lang); + lang.addEventListener('change', async () => { + await saveSetting('lang', lang.value); + applyLanguage(); + render(); + refreshSettings(); + }); + + const theme = select([['auto', t('settings.themeAuto')], ['light', t('settings.themeLight')], ['dark', t('settings.themeDark')]], st.theme); + theme.addEventListener('change', async () => { + await saveSetting('theme', theme.value); + applyTheme(); + }); + + const cur = select(currencyOptions(), st.currency); + cur.classList.add('select-compact'); + cur.addEventListener('change', async () => { + await saveSetting('currency', cur.value); + render(); + refreshSettings(); + }); + + // Exchange rates for currencies in use other than the main one. + const used = [...new Set(state.subs.map((s) => s.currency))].filter((c) => c !== st.currency).sort(); + const rateRows = used.map((c) => { + const input = h('input', { + class: 'input input-rate', + type: 'text', + inputmode: 'decimal', + placeholder: 'β€”', + value: st.rates[c] ? String(st.rates[c]) : '', + 'aria-label': `1 ${c} = ? ${st.currency}`, + }); + input.addEventListener('change', async () => { + const v = parsePrice(input.value); + const rates = { ...state.settings.rates }; + if (Number.isFinite(v) && v > 0) rates[c] = v; + else delete rates[c]; + input.value = rates[c] ? String(rates[c]) : ''; + await saveSetting('rates', rates); + render(); + }); + return h('div', { class: 'set-row rate-row' }, + h('span', { class: 'rate-label', text: `1 ${c} =` }), input, h('span', { class: 'rate-cur', text: st.currency })); + }); + + // Notifications. + const status = notificationStatus(); + let notifControl; + if (status === 'on') notifControl = h('span', { class: 'pill pill-ok', text: t('settings.notifOn') }); + else if (status === 'off') { + notifControl = h('button', { type: 'button', class: 'btn btn-primary btn-sm', text: t('settings.notifEnable') }); + notifControl.addEventListener('click', async () => { await enableNotifications(); refreshSettings(); }); + } else if (status === 'ios') { + notifControl = h('button', { type: 'button', class: 'btn btn-secondary btn-sm', text: t('settings.install') }); + notifControl.addEventListener('click', () => ST.install.open()); + } else notifControl = h('span', { class: 'pill' , text: 'β€”' }); + + const notifHint = { + on: t('settings.notifHint'), + off: t('settings.notifHint'), + denied: t('settings.notifDenied'), + unsupported: t('settings.notifUnsupported'), + ios: t('settings.notifIos'), + }[status]; + + const defReminder = select(reminderOptions(), st.defaultReminder); + defReminder.addEventListener('change', () => saveSetting('defaultReminder', parseInt(defReminder.value, 10))); + + const fileHint = h('p', { class: 'set-foot', text: t('settings.privacy') }); + + return h('div', { class: 'settings' }, + group(t('settings.general'), + row(t('settings.language'), lang), + row(t('settings.theme'), theme), + row(t('settings.mainCurrency'), cur)), + group(t('settings.rates'), + h('p', { class: 'set-note', text: used.length ? t('settings.ratesHint', { main: st.currency }) : t('settings.ratesNone', { main: st.currency }) }), + rateRows), + group(t('settings.reminders'), + row(t('settings.notifications'), notifControl, notifHint), + row(t('settings.defaultReminder'), defReminder), + status === 'on' ? actionRow('bell', t('settings.testNotif'), testNotification) : null, + actionRow('calendar', t('settings.ics'), () => exportIcs(state.subs, 'subtrack'), null, t('settings.icsHint'))), + group(t('settings.data'), + actionRow('download', t('settings.export'), exportBackup), + actionRow('upload', t('settings.import'), importBackup), + actionRow('trash', t('settings.wipe'), wipeAll, 'danger')), + group(t('settings.app'), + ST.install.available() ? actionRow('phone', t('settings.install'), () => { settingsSheet && settingsSheet.close(); ST.install.open(); }) : null, + h('a', { class: 'set-row set-action', href: ST.REPO_URL, target: '_blank', rel: 'noopener noreferrer' }, + icon('code'), h('span', { class: 'set-text', text: t('settings.source') }), icon('chevron', 'chev'))), + h('div', { class: 'privacy' }, icon('shield'), fileHint), + h('p', { class: 'set-foot muted', text: `SubTrack Β· ${t('settings.version', { v: ST.VERSION })} Β· MIT` })); + } + + async function wipeAll() { + const ok = await ui.confirm(t('settings.wipeConfirm'), t('form.delete')); + if (!ok) return; + await db.wipe(); + state.subs = []; + state.settings = await db.getSettings(); + applyLanguage(); + applyTheme(); + render(); + if (settingsSheet) settingsSheet.close(); + toast(t('toast.wiped')); + } + + ST.app = { + refreshInstallState: refreshSettings, + }; + + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', boot); + else boot(); +})(window); diff --git a/js/core/catalog.js b/js/core/catalog.js new file mode 100644 index 0000000..96128e8 --- /dev/null +++ b/js/core/catalog.js @@ -0,0 +1,187 @@ +/* + * Catalogue of popular subscription services. + * + * Each entry: [id, name, category, brandColor, simpleIconsSlug | null] + * - brandColor is a hex string without "#". + * - When the slug is null (brand not available in Simple Icons) the UI shows a + * monogram tile in the brand colour instead of a logo. + * + * Prices are intentionally NOT included: they change often and differ per + * country, so the user always types the amount they actually pay. + */ +(function (g) { + 'use strict'; + const ST = (g.ST = g.ST || {}); + + const CATEGORIES = [ + 'video', 'music', 'cloud', 'productivity', 'ai', 'creative', 'gaming', + 'security', 'shopping', 'reading', 'fitness', 'education', 'telco', + 'finance', 'social', 'other', + ]; + + const RAW = [ + // Video streaming + ['netflix', 'Netflix', 'video', 'E50914', 'netflix'], + ['amazonprime', 'Amazon Prime', 'video', '00A8E1', null], + ['disneyplus', 'Disney+', 'video', '113CCF', null], + ['appletv', 'Apple TV', 'video', '000000', 'appletv'], + ['sky', 'Sky', 'video', '0072C9', 'sky'], + ['now', 'NOW', 'video', '000000', 'now'], + ['dazn', 'DAZN', 'video', '0C161C', 'dazn'], + ['hbomax', 'HBO Max', 'video', '002BE7', 'hbomax'], + ['paramountplus', 'Paramount+', 'video', '0064FF', 'paramountplus'], + ['youtubepremium', 'YouTube Premium', 'video', 'FF0000', 'youtube'], + ['crunchyroll', 'Crunchyroll', 'video', 'FF5E00', 'crunchyroll'], + ['mubi', 'MUBI', 'video', '000000', 'mubi'], + ['timvision', 'TIMVISION', 'video', '0033A0', null], + ['mediasetinfinity', 'Mediaset Infinity+', 'video', '1A1A6E', null], + ['rakutentv', 'Rakuten TV', 'video', 'BF0000', 'rakuten'], + ['discoveryplus', 'discovery+', 'video', '2175D9', null], + + // Music & audio + ['spotify', 'Spotify', 'music', '1DB954', 'spotify'], + ['applemusic', 'Apple Music', 'music', 'FA243C', 'applemusic'], + ['amazonmusic', 'Amazon Music Unlimited', 'music', '25D1DA', null], + ['youtubemusic', 'YouTube Music', 'music', 'FF0000', 'youtubemusic'], + ['deezer', 'Deezer', 'music', 'A238FF', 'deezer'], + ['tidal', 'TIDAL', 'music', '000000', 'tidal'], + ['soundcloud', 'SoundCloud Go+', 'music', 'FF5500', 'soundcloud'], + ['audible', 'Audible', 'music', 'F8991C', 'audible'], + ['pocketcasts', 'Pocket Casts Plus', 'music', 'F43E37', 'pocketcasts'], + + // Cloud storage + ['icloud', 'iCloud+', 'cloud', '3693F3', 'icloud'], + ['googleone', 'Google One', 'cloud', '4285F4', null], + ['dropbox', 'Dropbox', 'cloud', '0061FF', 'dropbox'], + ['onedrive', 'OneDrive', 'cloud', '0078D4', null], + ['proton', 'Proton Unlimited', 'cloud', '6D4AFF', 'proton'], + ['protondrive', 'Proton Drive', 'cloud', '6D4AFF', 'protondrive'], + ['mega', 'MEGA', 'cloud', 'D9272E', 'mega'], + ['box', 'Box', 'cloud', '0061D5', 'box'], + ['pcloud', 'pCloud', 'cloud', '17BED0', null], + + // Productivity & work + ['microsoft365', 'Microsoft 365', 'productivity', 'D83B01', null], + ['googleworkspace', 'Google Workspace', 'productivity', '4285F4', null], + ['notion', 'Notion', 'productivity', '000000', 'notion'], + ['evernote', 'Evernote', 'productivity', '00A82D', 'evernote'], + ['todoist', 'Todoist', 'productivity', 'E44332', 'todoist'], + ['zoom', 'Zoom', 'productivity', '0B5CFF', 'zoom'], + ['slack', 'Slack', 'productivity', '4A154B', null], + ['linkedinpremium', 'LinkedIn Premium', 'productivity', '0A66C2', null], + ['grammarly', 'Grammarly', 'productivity', '15C39A', 'grammarly'], + ['setapp', 'Setapp', 'productivity', 'E6C3A5', 'setapp'], + ['jetbrains', 'JetBrains', 'productivity', '000000', 'jetbrains'], + ['githubcopilot', 'GitHub Copilot', 'productivity', '000000', 'githubcopilot'], + ['squarespace', 'Squarespace', 'productivity', '000000', 'squarespace'], + ['wix', 'Wix', 'productivity', '0C6EFC', 'wix'], + ['wordpress', 'WordPress.com', 'productivity', '21759B', 'wordpress'], + + // AI assistants + ['chatgpt', 'ChatGPT', 'ai', '10A37F', null], + ['claude', 'Claude', 'ai', 'D97757', 'claude'], + ['gemini', 'Google AI (Gemini)', 'ai', '8E75B2', 'googlegemini'], + ['perplexity', 'Perplexity', 'ai', '1FB8CD', 'perplexity'], + ['midjourney', 'Midjourney', 'ai', '000000', null], + + // Creative & media production + ['adobecc', 'Adobe Creative Cloud', 'creative', 'DA1F26', null], + ['canva', 'Canva', 'creative', '00C4CC', null], + ['figma', 'Figma', 'creative', 'F24E1E', 'figma'], + ['frameio', 'Frame.io', 'creative', '5B53FF', null], + ['artlist', 'Artlist', 'creative', '1D1D1B', null], + ['epidemicsound', 'Epidemic Sound', 'creative', '000000', null], + ['envato', 'Envato', 'creative', '87E64B', 'envato'], + ['motionarray', 'Motion Array', 'creative', '3D4BFF', null], + ['vimeo', 'Vimeo', 'creative', '1AB7EA', 'vimeo'], + ['shutterstock', 'Shutterstock', 'creative', 'EE2B24', null], + ['storyblocks', 'Storyblocks', 'creative', '0E1D2E', null], + + // Gaming + ['psplus', 'PlayStation Plus', 'gaming', '0070D1', 'playstation'], + ['gamepass', 'Xbox Game Pass', 'gaming', '107C10', null], + ['nintendoonline', 'Nintendo Switch Online', 'gaming', 'E60012', null], + ['eaplay', 'EA Play', 'gaming', '000000', 'ea'], + ['ubisoftplus', 'Ubisoft+', 'gaming', '000000', 'ubisoft'], + ['geforcenow', 'GeForce NOW', 'gaming', '76B900', 'nvidia'], + ['discordnitro', 'Discord Nitro', 'gaming', '5865F2', 'discord'], + ['twitch', 'Twitch', 'gaming', '9146FF', 'twitch'], + + // Security, VPN & passwords + ['nordvpn', 'NordVPN', 'security', '4687FF', 'nordvpn'], + ['expressvpn', 'ExpressVPN', 'security', 'DA3940', 'expressvpn'], + ['surfshark', 'Surfshark', 'security', '178BF1', 'surfshark'], + ['protonvpn', 'Proton VPN', 'security', '66DEB1', 'protonvpn'], + ['protonmail', 'Proton Mail', 'security', '6D4AFF', 'protonmail'], + ['1password', '1Password', 'security', '3B66BC', '1password'], + ['bitwarden', 'Bitwarden', 'security', '175DDC', 'bitwarden'], + ['dashlane', 'Dashlane', 'security', '0E353D', 'dashlane'], + + // Shopping & food delivery + ['deliveroo', 'Deliveroo Plus', 'shopping', '00CCBC', 'deliveroo'], + ['glovo', 'Glovo Prime', 'shopping', 'FFC244', 'glovo'], + ['uberone', 'Uber One', 'shopping', '000000', 'uber'], + ['hellofresh', 'HelloFresh', 'shopping', '99CC33', 'hellofresh'], + + // News & reading + ['kindleunlimited', 'Kindle Unlimited', 'reading', 'FF9900', null], + ['storytel', 'Storytel', 'reading', 'FF5C28', null], + ['nytimes', 'The New York Times', 'reading', '000000', 'newyorktimes'], + ['medium', 'Medium', 'reading', '000000', 'medium'], + ['substack', 'Substack', 'reading', 'FF6719', 'substack'], + ['patreon', 'Patreon', 'reading', '000000', 'patreon'], + + // Fitness & wellness + ['strava', 'Strava', 'fitness', 'FC4C02', 'strava'], + ['peloton', 'Peloton', 'fitness', '181A1D', 'peloton'], + ['fitbit', 'Fitbit Premium', 'fitness', '00B0B9', 'fitbit'], + ['headspace', 'Headspace', 'fitness', 'F47D31', 'headspace'], + ['calm', 'Calm', 'fitness', '4A6CF7', null], + + // Education + ['duolingo', 'Duolingo Super', 'education', '58CC02', 'duolingo'], + ['babbel', 'Babbel', 'education', 'FF6400', null], + ['coursera', 'Coursera Plus', 'education', '0056D2', 'coursera'], + ['udemy', 'Udemy', 'education', 'A435F0', 'udemy'], + ['skillshare', 'Skillshare', 'education', '00FF84', 'skillshare'], + ['masterclass', 'MasterClass', 'education', '000000', null], + ['domestika', 'Domestika', 'education', 'E8336D', null], + + // Telco (Italy-first, generic elsewhere) + ['tim', 'TIM', 'telco', '004691', null], + ['vodafone', 'Vodafone', 'telco', 'E60000', 'vodafone'], + ['windtre', 'WINDTRE', 'telco', 'FF6A00', null], + ['iliad', 'iliad', 'telco', 'E2001A', null], + ['fastweb', 'Fastweb', 'telco', 'FDC300', null], + ['homobile', 'ho. Mobile', 'telco', '00B2A9', null], + ['verymobile', 'Very Mobile', 'telco', '29D884', null], + + // Finance + ['revolut', 'Revolut', 'finance', '191C1F', 'revolut'], + ['n26', 'N26', 'finance', '36A18B', 'n26'], + ['tradingview', 'TradingView', 'finance', '131622', 'tradingview'], + + // Social & communication + ['telegrampremium', 'Telegram Premium', 'social', '26A5E4', 'telegram'], + ['xpremium', 'X Premium', 'social', '000000', 'x'], + ['tinder', 'Tinder', 'social', 'FF6B6B', 'tinder'], + + // Other bundles + ['appleone', 'Apple One', 'other', '000000', 'apple'], + ['playpass', 'Google Play Pass', 'other', '414141', 'googleplay'], + ]; + + const ITEMS = RAW.map(([id, name, category, color, icon]) => ({ + id, name, category, color, icon, + })); + + const byId = new Map(ITEMS.map((it) => [it.id, it])); + + ST.catalog = { + CATEGORIES, + ITEMS, + get(id) { + return byId.get(id) || null; + }, + }; +})(typeof self !== 'undefined' ? self : globalThis); diff --git a/js/core/db.js b/js/core/db.js new file mode 100644 index 0000000..391b8c5 --- /dev/null +++ b/js/core/db.js @@ -0,0 +1,244 @@ +/* + * IndexedDB storage. Everything stays in the browser of this device. + * + * Stores: + * subscriptions keyPath "id" + * settings keyPath "key" ({ key, value }) + */ +(function (g) { + 'use strict'; + const ST = (g.ST = g.ST || {}); + + const DB_NAME = 'subtrack'; + const DB_VERSION = 1; + const BACKUP_FORMAT = 'subtrack-backup'; + const BACKUP_VERSION = 1; + + const CURRENCIES = [ + 'EUR', 'USD', 'GBP', 'CHF', 'JPY', 'CAD', 'AUD', 'NZD', 'SEK', 'NOK', + 'DKK', 'PLN', 'CZK', 'HUF', 'RON', 'BGN', 'TRY', 'BRL', 'MXN', 'ARS', + 'INR', 'CNY', 'HKD', 'SGD', 'KRW', 'ZAR', 'AED', 'ILS', + ]; + + const DEFAULT_SETTINGS = { + lang: 'auto', + theme: 'auto', + currency: 'EUR', + rates: {}, + defaultReminder: 1, + notifications: false, + notified: {}, + sort: 'next', + view: 'monthly', + }; + + let dbPromise = null; + + function open() { + if (dbPromise) return dbPromise; + dbPromise = new Promise((resolve, reject) => { + const req = g.indexedDB.open(DB_NAME, DB_VERSION); + req.onupgradeneeded = () => { + const db = req.result; + if (!db.objectStoreNames.contains('subscriptions')) { + db.createObjectStore('subscriptions', { keyPath: 'id' }); + } + if (!db.objectStoreNames.contains('settings')) { + db.createObjectStore('settings', { keyPath: 'key' }); + } + }; + req.onsuccess = () => { + const db = req.result; + // Another tab upgraded the schema: close so it can proceed. + db.onversionchange = () => { + db.close(); + dbPromise = null; + }; + resolve(db); + }; + req.onerror = () => reject(req.error); + req.onblocked = () => reject(new Error('IndexedDB upgrade blocked')); + }); + dbPromise.catch(() => { dbPromise = null; }); + return dbPromise; + } + + function promisify(req) { + return new Promise((resolve, reject) => { + req.onsuccess = () => resolve(req.result); + req.onerror = () => reject(req.error); + }); + } + + async function tx(storeNames, mode, fn) { + const db = await open(); + return new Promise((resolve, reject) => { + const t = db.transaction(storeNames, mode); + let result; + Promise.resolve(fn(t)).then((r) => { result = r; }, reject); + t.oncomplete = () => resolve(result); + t.onerror = () => reject(t.error); + t.onabort = () => reject(t.error || new Error('Transaction aborted')); + }); + } + + // ---------- Validation ---------- + + const HEX = /^[0-9a-f]{6}$/i; + + function str(v, max) { + return typeof v === 'string' ? v.trim().slice(0, max) : ''; + } + + /** Returns a clean subscription object, or null if unusable. */ + function sanitize(input) { + if (!input || typeof input !== 'object') return null; + const { schedule, catalog } = ST; + const name = str(input.name, 80); + const price = Math.round(Number(input.price) * 100) / 100; + const startDate = str(input.startDate, 10); + const freq = { + every: Number(input.freq && input.freq.every), + unit: input.freq && input.freq.unit, + }; + if (!name || !Number.isFinite(price) || price < 0 || price > 1e7) return null; + if (!schedule.parseISO(startDate) || !schedule.isValidFreq(freq)) return null; + + const catalogId = typeof input.catalogId === 'string' && catalog.get(input.catalogId) + ? input.catalogId : null; + const currency = CURRENCIES.includes(input.currency) ? input.currency : 'EUR'; + const category = catalog.CATEGORIES.includes(input.category) ? input.category : 'other'; + const color = HEX.test(input.color || '') ? input.color.toUpperCase() : '6B7280'; + const reminder = Number.isInteger(input.reminder) && input.reminder >= -1 && input.reminder <= 30 + ? input.reminder : 1; + const now = Date.now(); + const id = typeof input.id === 'string' && /^[\w-]{8,64}$/.test(input.id) + ? input.id : uuid(); + + return { + id, + catalogId, + name, + price, + currency, + freq, + startDate, + category, + color, + reminder, // -1 = none, 0 = same day, n = days before + notes: str(input.notes, 1000), + active: input.active !== false, + createdAt: Number.isFinite(input.createdAt) ? input.createdAt : now, + updatedAt: now, + }; + } + + function uuid() { + if (g.crypto && g.crypto.randomUUID) return g.crypto.randomUUID(); + return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`; + } + + // ---------- Subscriptions ---------- + + function getAll() { + return tx('subscriptions', 'readonly', (t) => promisify(t.objectStore('subscriptions').getAll())); + } + + function put(sub) { + const clean = sanitize(sub); + if (!clean) return Promise.reject(new Error('Invalid subscription')); + return tx('subscriptions', 'readwrite', (t) => { + t.objectStore('subscriptions').put(clean); + return clean; + }); + } + + function remove(id) { + return tx('subscriptions', 'readwrite', (t) => { + t.objectStore('subscriptions').delete(id); + }); + } + + // ---------- Settings ---------- + + async function getSettings() { + const rows = await tx('settings', 'readonly', (t) => promisify(t.objectStore('settings').getAll())); + const out = JSON.parse(JSON.stringify(DEFAULT_SETTINGS)); + for (const { key, value } of rows) { + if (key in DEFAULT_SETTINGS) out[key] = value; + } + return out; + } + + function setSetting(key, value) { + if (!(key in DEFAULT_SETTINGS)) return Promise.reject(new Error(`Unknown setting: ${key}`)); + return tx('settings', 'readwrite', (t) => { + t.objectStore('settings').put({ key, value }); + }); + } + + // ---------- Backup ---------- + + async function exportBackup() { + const [subscriptions, settings] = await Promise.all([getAll(), getSettings()]); + delete settings.notified; + return { + format: BACKUP_FORMAT, + version: BACKUP_VERSION, + exportedAt: new Date().toISOString(), + settings, + subscriptions, + }; + } + + /** Merges a backup into the database (same id = overwritten). Returns count. */ + async function importBackup(data) { + if (!data || data.format !== BACKUP_FORMAT || !Array.isArray(data.subscriptions)) { + throw new Error('Invalid backup'); + } + const subs = data.subscriptions.map(sanitize).filter(Boolean); + const s = data.settings || {}; + const settings = {}; + if (['auto', ...ST.i18n.LANGS].includes(s.lang)) settings.lang = s.lang; + if (['auto', 'light', 'dark'].includes(s.theme)) settings.theme = s.theme; + if (CURRENCIES.includes(s.currency)) settings.currency = s.currency; + if (Number.isInteger(s.defaultReminder) && s.defaultReminder >= -1 && s.defaultReminder <= 30) { + settings.defaultReminder = s.defaultReminder; + } + if (s.rates && typeof s.rates === 'object') { + settings.rates = {}; + for (const [cur, rate] of Object.entries(s.rates)) { + if (CURRENCIES.includes(cur) && Number.isFinite(rate) && rate > 0) settings.rates[cur] = rate; + } + } + await tx(['subscriptions', 'settings'], 'readwrite', (t) => { + const so = t.objectStore('subscriptions'); + for (const sub of subs) so.put(sub); + const st = t.objectStore('settings'); + for (const [key, value] of Object.entries(settings)) st.put({ key, value }); + }); + return subs.length; + } + + function wipe() { + return tx(['subscriptions', 'settings'], 'readwrite', (t) => { + t.objectStore('subscriptions').clear(); + t.objectStore('settings').clear(); + }); + } + + ST.db = { + CURRENCIES, + DEFAULT_SETTINGS, + open, + sanitize, + getAll, + put, + remove, + getSettings, + setSetting, + exportBackup, + importBackup, + wipe, + }; +})(typeof self !== 'undefined' ? self : globalThis); diff --git a/js/core/i18n.js b/js/core/i18n.js new file mode 100644 index 0000000..e30e38c --- /dev/null +++ b/js/core/i18n.js @@ -0,0 +1,432 @@ +/* + * Translations (Italian / English) and locale-aware formatting helpers. + * To add a language: copy the `en` block, translate it and add the code to + * LANGS. Keys missing in a language fall back to English. + */ +(function (g) { + 'use strict'; + const ST = (g.ST = g.ST || {}); + + const LANGS = ['it', 'en']; + + const STRINGS = { + en: { + 'app.tagline': 'All your subscriptions, one place', + 'nav.settings': 'Settings', + 'nav.add': 'Add subscription', + 'nav.close': 'Close', + 'nav.back': 'Back', + 'common.cancel': 'Cancel', + + 'summary.monthly': 'Monthly spend', + 'summary.yearly': 'Yearly spend', + 'summary.active.one': '{n} active subscription', + 'summary.active.other': '{n} active subscriptions', + 'summary.approx': 'Approximate total using your exchange rates', + 'summary.mixed': 'Totals by currency', + 'summary.toggle': 'Switch between monthly and yearly', + + 'upcoming.title': 'Coming up', + 'upcoming.none': 'No renewals in the next 30 days.', + 'list.title': 'Your subscriptions', + 'list.sort': 'Sort by', + 'sort.next': 'Next renewal', + 'sort.price': 'Monthly cost', + 'sort.name': 'Name', + 'list.paused': 'Paused', + + 'empty.title': 'No subscriptions yet', + 'empty.text': 'Add your first subscription to see how much you spend every month.', + 'empty.cta': 'Add subscription', + + 'when.today': 'Today', + 'when.tomorrow': 'Tomorrow', + 'when.inDays': 'In {n} days', + 'when.on': 'Renews {date}', + + 'freq.weekly': 'Weekly', + 'freq.monthly': 'Monthly', + 'freq.quarterly': 'Quarterly', + 'freq.semiannual': 'Every 6 months', + 'freq.yearly': 'Yearly', + 'freq.custom': 'Custom', + 'freq.every': 'Every {n} {unit}', + 'unit.day.one': 'day', 'unit.day.other': 'days', + 'unit.week.one': 'week', 'unit.week.other': 'weeks', + 'unit.month.one': 'month', 'unit.month.other': 'months', + 'unit.year.one': 'year', 'unit.year.other': 'years', + 'per.month': '/mo', + 'per.year': '/yr', + + 'picker.title': 'Add subscription', + 'picker.search': 'Search a service…', + 'picker.all': 'All', + 'picker.custom': 'Custom', + 'picker.customHint': 'Anything else', + 'picker.noResults': 'No match for β€œ{q}”.', + 'picker.createCustom': 'Create β€œ{q}” as custom', + + 'form.new': 'New subscription', + 'form.edit': 'Edit subscription', + 'form.name': 'Name', + 'form.namePh': 'e.g. Gym, Magazine…', + 'form.price': 'Price', + 'form.currency': 'Currency', + 'form.frequency': 'Billing frequency', + 'form.every': 'Every', + 'form.start': 'Start date', + 'form.startHint': 'Date of the first charge: renewals are calculated from here.', + 'form.preview': 'Next renewal: {date} Β· β‰ˆ {monthly}/mo', + 'form.category': 'Category', + 'form.color': 'Colour', + 'form.reminder': 'Reminder', + 'form.reminderNone': 'No reminder', + 'form.reminderSame': 'On the day', + 'form.reminderDays.one': '{n} day before', + 'form.reminderDays.other': '{n} days before', + 'form.notes': 'Notes', + 'form.notesPh': 'Plan, account, how to cancel…', + 'form.active': 'Active', + 'form.activeHint': 'Paused subscriptions are excluded from totals and reminders.', + 'form.save': 'Save', + 'form.delete': 'Delete', + 'form.calendar': 'Add to calendar', + 'form.confirmDelete': 'Delete β€œ{name}”?', + 'form.errName': 'Enter a name.', + 'form.errPrice': 'Enter a valid price.', + 'form.errDate': 'Enter a valid date.', + 'form.errEvery': 'Enter a number between 1 and 999.', + + 'cat.video': 'Video & TV', + 'cat.music': 'Music & audio', + 'cat.cloud': 'Cloud storage', + 'cat.productivity': 'Productivity', + 'cat.ai': 'AI', + 'cat.creative': 'Creative', + 'cat.gaming': 'Gaming', + 'cat.security': 'VPN & security', + 'cat.shopping': 'Shopping & food', + 'cat.reading': 'News & reading', + 'cat.fitness': 'Health & fitness', + 'cat.education': 'Education', + 'cat.telco': 'Phone & internet', + 'cat.finance': 'Finance', + 'cat.social': 'Social', + 'cat.other': 'Other', + + 'settings.title': 'Settings', + 'settings.general': 'General', + 'settings.language': 'Language', + 'settings.langAuto': 'Automatic', + 'settings.theme': 'Theme', + 'settings.themeAuto': 'Automatic', + 'settings.themeLight': 'Light', + 'settings.themeDark': 'Dark', + 'settings.mainCurrency': 'Main currency', + 'settings.rates': 'Exchange rates', + 'settings.ratesHint': 'Optional. Enter how much 1 unit of each currency is worth in {main} to get a single total. Rates are never fetched from the internet.', + 'settings.ratesNone': 'All your subscriptions use {main}.', + 'settings.reminders': 'Reminders', + 'settings.notifications': 'Notifications', + 'settings.notifEnable': 'Enable', + 'settings.notifOn': 'On', + 'settings.notifDenied': 'Blocked in browser settings', + 'settings.notifUnsupported': 'Not supported by this browser', + 'settings.notifIos': 'On iPhone, install the app on the Home Screen first', + 'settings.notifHint': 'Reminders are checked on this device when the app opens and, where the system allows it, in the background. For alerts that are always on time, also add the calendar.', + 'settings.defaultReminder': 'Default reminder', + 'settings.testNotif': 'Send test notification', + 'settings.ics': 'Export to calendar (.ics)', + 'settings.icsHint': 'Imports all renewals as repeating events with an alert into your phone calendar.', + 'settings.data': 'Data & backup', + 'settings.export': 'Export backup', + 'settings.import': 'Import backup', + 'settings.wipe': 'Delete all data', + 'settings.wipeConfirm': 'Delete all subscriptions and settings from this device? This cannot be undone.', + 'settings.app': 'App', + 'settings.install': 'Install app', + 'settings.privacy': 'Your data never leaves this device: no account, no tracking, no server.', + 'settings.source': 'Source code', + 'settings.version': 'Version {v}', + + 'install.title': 'Install SubTrack', + 'install.text': 'Add it to your Home Screen: it opens full screen, works offline and can remind you before renewals.', + 'install.cta': 'Install', + 'install.later': 'Not now', + 'install.gotIt': 'Got it', + 'install.ios1': 'Tap {icon} Share in the browser bar (on newer iOS: β‹― then Share)', + 'install.ios2': 'Choose β€œAdd to Home Screen”', + 'install.ios3': 'Tap β€œAdd” and open SubTrack from the Home Screen', + 'install.generic': 'Open the browser menu and choose β€œInstall app” or β€œAdd to Home Screen”.', + 'install.done': 'SubTrack installed', + + 'toast.saved': 'Subscription saved', + 'toast.deleted': 'β€œ{name}” deleted', + 'toast.undo': 'Undo', + 'toast.exported': 'Backup exported', + 'toast.imported.one': '{n} subscription imported', + 'toast.imported.other': '{n} subscriptions imported', + 'toast.invalidFile': 'Invalid backup file', + 'toast.notifOn': 'Notifications enabled', + 'toast.notifDenied': 'Notification permission denied', + 'toast.wiped': 'All data deleted', + 'toast.icsEmpty': 'No active subscriptions to export', + 'toast.updated': 'New version available', + 'toast.reload': 'Reload', + + 'notif.title': '{name} renews {when}', + 'notif.today': 'today', + 'notif.tomorrow': 'tomorrow', + 'notif.inDays': 'in {n} days', + 'notif.testTitle': 'Notifications work!', + 'notif.testBody': 'You will be reminded before your subscriptions renew.', + }, + + it: { + 'app.tagline': 'Tutti i tuoi abbonamenti, in un posto solo', + 'nav.settings': 'Impostazioni', + 'nav.add': 'Aggiungi abbonamento', + 'nav.close': 'Chiudi', + 'nav.back': 'Indietro', + 'common.cancel': 'Annulla', + + 'summary.monthly': 'Spesa mensile', + 'summary.yearly': 'Spesa annuale', + 'summary.active.one': '{n} abbonamento attivo', + 'summary.active.other': '{n} abbonamenti attivi', + 'summary.approx': 'Totale approssimato con i tuoi tassi di cambio', + 'summary.mixed': 'Totali per valuta', + 'summary.toggle': 'Passa tra vista mensile e annuale', + + 'upcoming.title': 'In arrivo', + 'upcoming.none': 'Nessun rinnovo nei prossimi 30 giorni.', + 'list.title': 'I tuoi abbonamenti', + 'list.sort': 'Ordina per', + 'sort.next': 'Prossimo rinnovo', + 'sort.price': 'Costo mensile', + 'sort.name': 'Nome', + 'list.paused': 'In pausa', + + 'empty.title': 'Ancora nessun abbonamento', + 'empty.text': 'Aggiungi il primo abbonamento per vedere quanto spendi ogni mese.', + 'empty.cta': 'Aggiungi abbonamento', + + 'when.today': 'Oggi', + 'when.tomorrow': 'Domani', + 'when.inDays': 'Tra {n} giorni', + 'when.on': 'Rinnovo il {date}', + + 'freq.weekly': 'Settimanale', + 'freq.monthly': 'Mensile', + 'freq.quarterly': 'Trimestrale', + 'freq.semiannual': 'Semestrale', + 'freq.yearly': 'Annuale', + 'freq.custom': 'Personalizzata', + 'freq.every': 'Ogni {n} {unit}', + 'unit.day.one': 'giorno', 'unit.day.other': 'giorni', + 'unit.week.one': 'settimana', 'unit.week.other': 'settimane', + 'unit.month.one': 'mese', 'unit.month.other': 'mesi', + 'unit.year.one': 'anno', 'unit.year.other': 'anni', + 'per.month': '/mese', + 'per.year': '/anno', + + 'picker.title': 'Aggiungi abbonamento', + 'picker.search': 'Cerca un servizio…', + 'picker.all': 'Tutti', + 'picker.custom': 'Personalizzato', + 'picker.customHint': 'Qualsiasi altro', + 'picker.noResults': 'Nessun risultato per β€œ{q}”.', + 'picker.createCustom': 'Crea β€œ{q}” come personalizzato', + + 'form.new': 'Nuovo abbonamento', + 'form.edit': 'Modifica abbonamento', + 'form.name': 'Nome', + 'form.namePh': 'es. Palestra, Rivista…', + 'form.price': 'Prezzo', + 'form.currency': 'Valuta', + 'form.frequency': 'Frequenza di pagamento', + 'form.every': 'Ogni', + 'form.start': 'Data di inizio', + 'form.startHint': 'Data del primo addebito: i rinnovi vengono calcolati da qui.', + 'form.preview': 'Prossimo rinnovo: {date} Β· β‰ˆ {monthly}/mese', + 'form.category': 'Categoria', + 'form.color': 'Colore', + 'form.reminder': 'Promemoria', + 'form.reminderNone': 'Nessun promemoria', + 'form.reminderSame': 'Il giorno stesso', + 'form.reminderDays.one': '{n} giorno prima', + 'form.reminderDays.other': '{n} giorni prima', + 'form.notes': 'Note', + 'form.notesPh': 'Piano, account, come disdire…', + 'form.active': 'Attivo', + 'form.activeHint': 'Gli abbonamenti in pausa sono esclusi da totali e promemoria.', + 'form.save': 'Salva', + 'form.delete': 'Elimina', + 'form.calendar': 'Aggiungi al calendario', + 'form.confirmDelete': 'Eliminare β€œ{name}”?', + 'form.errName': 'Inserisci un nome.', + 'form.errPrice': 'Inserisci un prezzo valido.', + 'form.errDate': 'Inserisci una data valida.', + 'form.errEvery': 'Inserisci un numero da 1 a 999.', + + 'cat.video': 'Video e TV', + 'cat.music': 'Musica e audio', + 'cat.cloud': 'Cloud storage', + 'cat.productivity': 'ProduttivitΓ ', + 'cat.ai': 'Intelligenza artificiale', + 'cat.creative': 'CreativitΓ ', + 'cat.gaming': 'Gaming', + 'cat.security': 'VPN e sicurezza', + 'cat.shopping': 'Shopping e cibo', + 'cat.reading': 'News e lettura', + 'cat.fitness': 'Salute e fitness', + 'cat.education': 'Formazione', + 'cat.telco': 'Telefono e internet', + 'cat.finance': 'Finanza', + 'cat.social': 'Social', + 'cat.other': 'Altro', + + 'settings.title': 'Impostazioni', + 'settings.general': 'Generali', + 'settings.language': 'Lingua', + 'settings.langAuto': 'Automatica', + 'settings.theme': 'Tema', + 'settings.themeAuto': 'Automatico', + 'settings.themeLight': 'Chiaro', + 'settings.themeDark': 'Scuro', + 'settings.mainCurrency': 'Valuta principale', + 'settings.rates': 'Tassi di cambio', + 'settings.ratesHint': 'Facoltativo. Inserisci quanto vale 1 unitΓ  di ogni valuta in {main} per ottenere un totale unico. I tassi non vengono mai scaricati da internet.', + 'settings.ratesNone': 'Tutti i tuoi abbonamenti sono in {main}.', + 'settings.reminders': 'Promemoria', + 'settings.notifications': 'Notifiche', + 'settings.notifEnable': 'Attiva', + 'settings.notifOn': 'Attive', + 'settings.notifDenied': 'Bloccate nelle impostazioni del browser', + 'settings.notifUnsupported': 'Non supportate da questo browser', + 'settings.notifIos': 'Su iPhone, prima installa l’app nella schermata Home', + 'settings.notifHint': 'I promemoria vengono controllati su questo dispositivo all’apertura dell’app e, dove il sistema lo consente, in background. Per avvisi sempre puntuali aggiungi anche il calendario.', + 'settings.defaultReminder': 'Promemoria predefinito', + 'settings.testNotif': 'Invia notifica di prova', + 'settings.ics': 'Esporta nel calendario (.ics)', + 'settings.icsHint': 'Importa tutti i rinnovi come eventi ricorrenti con avviso nel calendario del telefono.', + 'settings.data': 'Dati e backup', + 'settings.export': 'Esporta backup', + 'settings.import': 'Importa backup', + 'settings.wipe': 'Elimina tutti i dati', + 'settings.wipeConfirm': 'Eliminare tutti gli abbonamenti e le impostazioni da questo dispositivo? L’operazione non Γ¨ reversibile.', + 'settings.app': 'App', + 'settings.install': 'Installa app', + 'settings.privacy': 'I tuoi dati non lasciano mai questo dispositivo: nessun account, nessun tracciamento, nessun server.', + 'settings.source': 'Codice sorgente', + 'settings.version': 'Versione {v}', + + 'install.title': 'Installa SubTrack', + 'install.text': 'Aggiungila alla schermata Home: si apre a schermo intero, funziona offline e puΓ² avvisarti prima dei rinnovi.', + 'install.cta': 'Installa', + 'install.later': 'Non ora', + 'install.gotIt': 'Ho capito', + 'install.ios1': 'Tocca {icon} Condividi nella barra del browser (su iOS recenti: β‹― e poi Condividi)', + 'install.ios2': 'Scegli β€œAggiungi alla schermata Home”', + 'install.ios3': 'Tocca β€œAggiungi” e apri SubTrack dalla Home', + 'install.generic': 'Apri il menu del browser e scegli β€œInstalla app” o β€œAggiungi alla schermata Home”.', + 'install.done': 'SubTrack installata', + + 'toast.saved': 'Abbonamento salvato', + 'toast.deleted': 'β€œ{name}” eliminato', + 'toast.undo': 'Annulla', + 'toast.exported': 'Backup esportato', + 'toast.imported.one': '{n} abbonamento importato', + 'toast.imported.other': '{n} abbonamenti importati', + 'toast.invalidFile': 'File di backup non valido', + 'toast.notifOn': 'Notifiche attivate', + 'toast.notifDenied': 'Permesso per le notifiche negato', + 'toast.wiped': 'Tutti i dati sono stati eliminati', + 'toast.icsEmpty': 'Nessun abbonamento attivo da esportare', + 'toast.updated': 'Nuova versione disponibile', + 'toast.reload': 'Ricarica', + + 'notif.title': '{name} si rinnova {when}', + 'notif.today': 'oggi', + 'notif.tomorrow': 'domani', + 'notif.inDays': 'tra {n} giorni', + 'notif.testTitle': 'Le notifiche funzionano!', + 'notif.testBody': 'Riceverai un avviso prima del rinnovo dei tuoi abbonamenti.', + }, + }; + + let lang = 'en'; + + function detect(pref) { + if (LANGS.includes(pref)) return pref; + const nav = (g.navigator && (g.navigator.languages || [g.navigator.language])) || []; + for (const l of nav) { + const code = String(l || '').slice(0, 2).toLowerCase(); + if (LANGS.includes(code)) return code; + } + return 'en'; + } + + function setLang(pref) { + lang = detect(pref); + return lang; + } + + function t(key, vars) { + let s = (STRINGS[lang] && STRINGS[lang][key]) ?? STRINGS.en[key] ?? key; + if (vars) s = s.replace(/\{(\w+)\}/g, (m, k) => (k in vars ? String(vars[k]) : m)); + return s; + } + + /** Plural-aware lookup: uses `${key}.one` / `${key}.other`. */ + function tp(key, n, vars) { + const form = new Intl.PluralRules(lang).select(n) === 'one' ? 'one' : 'other'; + return t(`${key}.${form}`, Object.assign({ n }, vars)); + } + + const moneyCache = new Map(); + function fmtMoney(amount, currency) { + const k = `${lang}|${currency}`; + let f = moneyCache.get(k); + if (!f) { + try { + f = new Intl.NumberFormat(lang, { style: 'currency', currency }); + } catch { + f = { format: (v) => `${v.toFixed(2)} ${currency}` }; + } + moneyCache.set(k, f); + } + return f.format(amount); + } + + function fmtDate(date, opts) { + return new Intl.DateTimeFormat(lang, opts || { day: 'numeric', month: 'short', year: 'numeric' }).format(date); + } + + function relDays(n, date) { + if (n === 0) return t('when.today'); + if (n === 1) return t('when.tomorrow'); + if (n > 1 && n <= 30) return t('when.inDays', { n }); + return t('when.on', { date: fmtDate(date, { day: 'numeric', month: 'short' }) }); + } + + function freqLabel(freq) { + const preset = ST.schedule.presetOf(freq); + if (preset !== 'custom') return t(`freq.${preset}`); + return t('freq.every', { n: freq.every, unit: tp(`unit.${freq.unit}`, freq.every).replace(/^\d+\s*/, '') }); + } + + ST.i18n = { + LANGS, + STRINGS, + get lang() { return lang; }, + detect, + setLang, + t, + tp, + fmtMoney, + fmtDate, + relDays, + freqLabel, + }; +})(typeof self !== 'undefined' ? self : globalThis); diff --git a/js/core/icons.js b/js/core/icons.js new file mode 100644 index 0000000..7388b29 --- /dev/null +++ b/js/core/icons.js @@ -0,0 +1,335 @@ +/* + * GENERATED FILE - do not edit by hand. Run: node tools/build-icons.mjs + * Brand icons from Simple Icons v16.34.0 (https://simpleicons.org), CC0-1.0. + * All brand names and logos are trademarks of their respective owners. + */ +(function (g) { + 'use strict'; + const ST = (g.ST = g.ST || {}); + ST.icons = { + "1password": { + "p": "M12 0c6.627 0 12 5.373 12 12 0 6.628-5.373 12-12 12S0 18.628 0 12C0 5.373 5.373 0 12 0m-.893 4.86c-.485 0-.727.001-.913.095a.87.87 0 0 0-.378.379c-.094.185-.095.428-.095.912v2.747c0 .12 0 .182.016.238q.02.075.065.138a1 1 0 0 0 .175.162l.695.564c.113.092.17.139.19.194a.22.22 0 0 1 0 .15c-.02.056-.077.102-.19.194l-.695.564a1 1 0 0 0-.175.162.4.4 0 0 0-.065.138 1 1 0 0 0-.016.238v6.019c0 .485 0 .728.095.913a.87.87 0 0 0 .378.378c.186.094.428.094.913.094h1.786c.485 0 .727 0 .913-.094a.87.87 0 0 0 .378-.378c.095-.185.095-.428.095-.913v-2.747c0-.12 0-.182-.016-.238a.4.4 0 0 0-.065-.138 1 1 0 0 0-.175-.162l-.695-.564c-.113-.092-.17-.138-.191-.193a.22.22 0 0 1 0-.152c.02-.055.078-.1.19-.193l.696-.564a1 1 0 0 0 .175-.162.4.4 0 0 0 .065-.138 1 1 0 0 0 .016-.238V6.246c0-.484 0-.727-.095-.912a.87.87 0 0 0-.378-.379c-.186-.094-.428-.094-.913-.094Z", + "h": "145FE4" + }, + "apple": { + "p": "M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701", + "h": "000000" + }, + "applemusic": { + "p": "M23.994 6.124a9.23 9.23 0 00-.24-2.19c-.317-1.31-1.062-2.31-2.18-3.043a5.022 5.022 0 00-1.877-.726 10.496 10.496 0 00-1.564-.15c-.04-.003-.083-.01-.124-.013H5.986c-.152.01-.303.017-.455.026-.747.043-1.49.123-2.193.4-1.336.53-2.3 1.452-2.865 2.78-.192.448-.292.925-.363 1.408-.056.392-.088.785-.1 1.18 0 .032-.007.062-.01.093v12.223c.01.14.017.283.027.424.05.815.154 1.624.497 2.373.65 1.42 1.738 2.353 3.234 2.801.42.127.856.187 1.293.228.555.053 1.11.06 1.667.06h11.03a12.5 12.5 0 001.57-.1c.822-.106 1.596-.35 2.295-.81a5.046 5.046 0 001.88-2.207c.186-.42.293-.87.37-1.324.113-.675.138-1.358.137-2.04-.002-3.8 0-7.595-.003-11.393zm-6.423 3.99v5.712c0 .417-.058.827-.244 1.206-.29.59-.76.962-1.388 1.14-.35.1-.706.157-1.07.173-.95.045-1.773-.6-1.943-1.536a1.88 1.88 0 011.038-2.022c.323-.16.67-.25 1.018-.324.378-.082.758-.153 1.134-.24.274-.063.457-.23.51-.516a.904.904 0 00.02-.193c0-1.815 0-3.63-.002-5.443a.725.725 0 00-.026-.185c-.04-.15-.15-.243-.304-.234-.16.01-.318.035-.475.066-.76.15-1.52.303-2.28.456l-2.325.47-1.374.278c-.016.003-.032.01-.048.013-.277.077-.377.203-.39.49-.002.042 0 .086 0 .13-.002 2.602 0 5.204-.003 7.805 0 .42-.047.836-.215 1.227-.278.64-.77 1.04-1.434 1.233-.35.1-.71.16-1.075.172-.96.036-1.755-.6-1.92-1.544-.14-.812.23-1.685 1.154-2.075.357-.15.73-.232 1.108-.31.287-.06.575-.116.86-.177.383-.083.583-.323.6-.714v-.15c0-2.96 0-5.922.002-8.882 0-.123.013-.25.042-.37.07-.285.273-.448.546-.518.255-.066.515-.112.774-.165.733-.15 1.466-.296 2.2-.444l2.27-.46c.67-.134 1.34-.27 2.01-.403.22-.043.442-.088.663-.106.31-.025.523.17.554.482.008.073.012.148.012.223.002 1.91.002 3.822 0 5.732z", + "h": "FA243C" + }, + "appletv": { + "p": "M20.57 17.735h-1.815l-3.34-9.203h1.633l2.02 5.987c.075.231.273.9.586 2.012l.297-.997.33-1.006 2.094-6.004H24zm-5.344-.066a5.76 5.76 0 0 1-1.55.207c-1.23 0-1.84-.693-1.84-2.087V9.646h-1.063V8.532h1.121V7.081l1.476-.602v2.062h1.707v1.113H13.38v5.805c0 .446.074.75.214.932.14.182.396.264.75.264.207 0 .495-.041.883-.115zm-7.29-5.343c.017 1.764 1.55 2.358 1.567 2.366-.017.042-.248.842-.808 1.658-.487.71-.99 1.418-1.79 1.435-.783.016-1.03-.462-1.93-.462-.89 0-1.17.445-1.913.478-.758.025-1.344-.775-1.838-1.484-.998-1.451-1.765-4.098-.734-5.88.51-.89 1.426-1.451 2.416-1.46.75-.016 1.468.512 1.93.512.461 0 1.327-.627 2.234-.536.38.016 1.452.157 2.136 1.154-.058.033-1.278.743-1.27 2.219M6.468 7.988c.404-.495.685-1.18.61-1.864-.585.025-1.294.388-1.723.883-.38.437-.71 1.138-.619 1.806.652.05 1.328-.338 1.732-.825Z", + "h": "000000" + }, + "audible": { + "p": "M12.008 17.362L24 9.885v2.028l-11.992 7.509L0 11.912V9.886l12.008 7.477zm0-9.378c-2.709 0-5.085 1.363-6.448 3.47.111-.111.175-.175.286-.254 3.374-2.804 8.237-2.17 10.883 1.362l1.758-1.124c-1.394-2.044-3.786-3.454-6.48-3.454m0 3.47a4.392 4.392 0 0 0-3.548 1.821 3.597 3.597 0 0 1 2.139-.697c1.299 0 2.455.666 3.232 1.79l1.679-1.045c-.729-1.157-2.028-1.87-3.501-1.87M3.897 8.412c4.943-3.897 11.929-2.836 15.652 2.344l.031.032 1.822-1.125a11.214 11.214 0 0 0-9.394-5.085c-3.897 0-7.366 1.996-9.394 5.085.364-.412.824-.903 1.283-1.251", + "h": "F8991C" + }, + "bitwarden": { + "p": "M21.722.296A.964.964 0 0 0 21.018 0H2.982a.959.959 0 0 0-.703.296.96.96 0 0 0-.297.702v12c0 .895.174 1.783.523 2.665.349.88.783 1.66 1.3 2.345.517.68 1.132 1.346 1.848 1.993a21.807 21.807 0 0 0 1.98 1.609c.605.427 1.235.83 1.893 1.212.657.381 1.125.638 1.4.772.276.134.5.241.664.311a.916.916 0 0 0 .814 0c.168-.073.389-.177.667-.311.275-.134.743-.394 1.401-.772a25.305 25.305 0 0 0 1.894-1.212A21.891 21.891 0 0 0 18.348 20c.716-.647 1.33-1.31 1.847-1.993s.949-1.463 1.3-2.345c.35-.879.524-1.767.524-2.665V1.001a.95.95 0 0 0-.297-.705zm-2.325 12.815c0 4.344-7.397 8.087-7.397 8.087V2.57h7.397v10.54z", + "h": "175DDC" + }, + "box": { + "p": "M.959 5.523c-.54 0-.959.42-.959.899v7.549a4.59 4.59 0 004.613 4.494 4.717 4.717 0 004.135-2.457c.779 1.438 2.337 2.457 4.074 2.457 2.577 0 4.674-2.037 4.674-4.613.06-2.457-2.037-4.495-4.613-4.495-1.738 0-3.295.959-4.074 2.397-.78-1.438-2.338-2.397-4.135-2.397-1.079 0-2.038.36-2.817.899V6.422a.92.92 0 00-.898-.899zM17.602 9.26a.95.95 0 00-.704.158c-.36.3-.479.899-.18 1.318l2.397 3.116-2.396 3.115c-.3.42-.24.96.18 1.26.419.3 1.016.298 1.316-.122l2.039-2.636 2.096 2.697c.3.36.899.419 1.318.12.36-.3.42-.84.121-1.259l-2.338-3.115 2.338-3.057c.3-.419.298-1.018-.121-1.318-.48-.3-1.019-.24-1.318.18l-2.096 2.576-2.04-2.695c-.149-.18-.373-.3-.612-.338zM4.613 11.154c1.558 0 2.817 1.26 2.817 2.758 0 1.558-1.259 2.756-2.817 2.756-1.558 0-2.816-1.198-2.816-2.756 0-1.498 1.258-2.758 2.816-2.758zm8.27 0c1.558 0 2.816 1.26 2.816 2.758-.06 1.558-1.318 2.756-2.816 2.756-1.558 0-2.817-1.198-2.817-2.756 0-1.498 1.259-2.758 2.817-2.758Z", + "h": "0061D5" + }, + "claude": { + "p": "m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z", + "h": "D97757" + }, + "coursera": { + "p": "M11.374 23.977c-4.183-.21-8.006-2.626-9.959-6.347-2.097-3.858-1.871-8.864.732-12.454C4.748 1.338 9.497-.698 14.281.23c4.583.857 8.351 4.494 9.358 8.911 1.122 4.344-.423 9.173-3.925 12.04-2.289 1.953-5.295 2.956-8.34 2.797zm7.705-8.05a588.737 588.737 0 0 0-3.171-1.887c-.903 1.483-2.885 2.248-4.57 1.665-2.024-.639-3.394-2.987-2.488-5.134.801-2.009 2.79-2.707 4.357-2.464a4.19 4.19 0 0 1 2.623 1.669c1.077-.631 2.128-1.218 3.173-1.855-2.03-3.118-6.151-4.294-9.656-2.754-3.13 1.423-4.89 4.68-4.388 7.919.54 3.598 3.73 6.486 7.716 6.404a7.664 7.664 0 0 0 6.404-3.563z", + "h": "0056D2" + }, + "crunchyroll": { + "p": "M2.909 13.436C2.914 7.61 7.642 2.893 13.468 2.898c5.576.005 10.137 4.339 10.51 9.819q.021-.351.022-.706C24.007 5.385 18.64.006 12.012 0S.007 5.36 0 11.988 5.36 23.994 11.988 24q.412 0 .815-.027c-5.526-.338-9.9-4.928-9.894-10.538Zm16.284.155a4.1 4.1 0 0 1-4.095-4.103 4.1 4.1 0 0 1 2.712-3.855 8.95 8.95 0 0 0-4.187-1.037 9.007 9.007 0 1 0 8.997 9.016q-.001-.847-.15-1.651a4.1 4.1 0 0 1-3.278 1.63Z", + "h": "FF5E00" + }, + "dashlane": { + "p": "M20.89 7.7189c0-.1488-.1488-.2976-.3575-.3571l-2.502-.9221c-.4166-.1786-.8932.0297-.8932.3277V17.25c0 .1487.1488.3273.2977.3868l2.5614.9222c.3872.1487.8936-.0596.8936-.3873zm-4.676-3.663c0-.1492-.1489-.298-.3576-.3575l-2.5015-.9221c-.417-.1786-.8936.0297-.8936.3278v6.3723c0 .1488.1487.3273.2976.3873l2.5614.9221c.3873.1492.8937-.0595.8937-.3869zm0 11.4663c0-.1488-.1489-.2975-.3576-.3571l-2.5015-.9221c-.417-.1786-.8936.0297-.8936.3277v6.3724c0 .1488.1487.3273.2976.3869l2.5614.922c.3873.1493.8937-.0594.8937-.3872zm-4.6761 1.281c0-.1489-.1488-.298-.3575-.3576l-2.5015-.9221c-.4192-.1786-.8937.0297-.8937.3277v6.7903c0 .1487.1488.3277.2977.3872l2.5614.9222c.3872.1493.8936-.0595.8936-.387zm0-15.4579c0-.1488-.1488-.2976-.3575-.3571L8.6789.066c-.4192-.1786-.8937.0297-.8937.3277v6.7903c0 .1492.1488.3277.2977.3873l2.5614.922c.3872.1488.8936-.0594.8936-.3872zm-4.6752.2683c0-.1488-.1488-.298-.3575-.3576L4.0037.334C3.5867.1553 3.11.3636 3.11.6617v21.7409c0 .1487.1488.3273.298.3868l2.561.9222c.3874.1488.8937-.0595.8937-.3874z", + "h": "0E353D" + }, + "dazn": { + "p": "M14.774 8.291l.772-2.596.79 2.596zm3.848 2.268l-2.025-6.128c-.045-.135-.097-.224-.154-.266-.059-.041-.152-.063-.28-.063h-1.12a.485.485 0 0 0-.284.068c-.06.045-.11.132-.149.261l-2.045 6.128c-.025.032-.038.096-.038.192 0 .149.09.223.27.223h.84c.076 0 .139-.003.187-.01a.207.207 0 0 0 .116-.048.326.326 0 0 0 .077-.116c.022-.051.046-.119.072-.202l.318-1.071h2.306l.327 1.051c.026.09.051.16.077.213a.395.395 0 0 0 .087.12c.031.028.07.047.114.053h.002c.045.006.103.01.173.01h.897c.18 0 .27-.074.27-.223a.59.59 0 0 0-.005-.09.878.878 0 0 0-.036-.108l.003.006zm-.994 2.467h-.646c-.168 0-.279.024-.333.072-.055.049-.082.147-.082.295v3.638l-1.91-3.647c-.076-.155-.152-.253-.226-.295-.074-.041-.204-.063-.39-.063h-.599c-.167 0-.278.025-.332.073-.055.048-.082.147-.082.294v6.138c0 .148.025.246.077.294.052.048.16.072.328.072h.656c.167 0 .278-.024.332-.072.055-.048.082-.146.082-.294v-3.648l1.91 3.657c.077.155.152.253.227.295.073.042.204.062.39.062h.598c.167 0 .278-.024.333-.072.054-.048.082-.146.082-.294v-6.138c0-.148-.028-.246-.082-.294-.055-.048-.166-.073-.333-.073zm3.203-.581l1.665 1.665v8.385H1.505V14.11l1.663-1.664a.63.63 0 0 0 0-.89L1.504 9.891V1.505h20.991v8.384l-1.665 1.666a.63.63 0 0 0 0 .89zM24 0H0v10.613L1.387 12 0 13.387V24h24V13.387L22.613 12 24 10.613zM10.67 18.469H7.96l2.855-4.014a.67.67 0 0 0 .087-.155.425.425 0 0 0 .019-.135v-.772c0-.148-.028-.246-.082-.294-.055-.048-.166-.073-.334-.073H6.382c-.149 0-.245.028-.29.082-.045.055-.068.169-.068.343v.58c0 .172.023.287.068.341.045.055.141.083.29.083h2.545L6.11 18.469a.438.438 0 0 0-.107.27v.792c0 .148.027.245.082.294.055.048.167.072.334.072h4.25c.148 0 .245-.027.29-.081.045-.055.068-.17.068-.344v-.579c0-.173-.023-.287-.068-.342-.045-.055-.142-.082-.29-.082zM9.408 8.233c0 .264-.017.484-.052.661-.036.177-.093.32-.174.43a.648.648 0 0 1-.318.231 1.523 1.523 0 0 1-.487.068h-.79v-4.17h.79c.366 0 .63.11.79.324.16.215.241.571.241 1.067v1.389zm1.38-2.789c-.225-.457-.533-.795-.921-1.013-.39-.219-.88-.328-1.47-.328H6.418c-.167 0-.278.024-.333.072-.054.049-.082.147-.082.294v6.138c0 .148.028.246.082.295.055.048.166.072.333.072h2.218c1.048 0 1.765-.447 2.15-1.342.09-.205.153-.413.188-.622a4.91 4.91 0 0 0 .054-.796V6.911c0-.367-.018-.656-.054-.868a2.2 2.2 0 0 0-.193-.612l.006.013z", + "h": "F8F8F5" + }, + "deezer": { + "p": "M.693 10.024c.381 0 .693-1.256.693-2.807 0-1.55-.312-2.807-.693-2.807C.312 4.41 0 5.666 0 7.217s.312 2.808.693 2.808ZM21.038 1.56c-.364 0-.684.805-.91 2.096C19.765 1.446 19.184 0 18.526 0c-.78 0-1.464 2.036-1.784 5-.312-2.158-.788-3.536-1.325-3.536-.745 0-1.386 2.704-1.62 6.472-.442-1.932-1.083-3.145-1.793-3.145s-1.35 1.213-1.793 3.145c-.242-3.76-.874-6.463-1.628-6.463-.537 0-1.013 1.378-1.325 3.535C6.938 2.036 6.262 0 5.474 0c-.658 0-1.247 1.447-1.602 3.665-.217-1.291-.546-2.105-.91-2.105-.675 0-1.221 2.807-1.221 6.272 0 3.466.546 6.273 1.221 6.273.277 0 .537-.476.736-1.273.32 2.928.996 4.938 1.776 4.938.606 0 1.143-1.204 1.507-3.11.251 3.622.875 6.195 1.602 6.195.46 0 .875-1.023 1.187-2.677C10.142 21.6 11 24 12.004 24c1.005 0 1.863-2.4 2.235-5.822.312 1.654.727 2.677 1.186 2.677.728 0 1.352-2.573 1.603-6.195.364 1.906.9 3.11 1.507 3.11.78 0 1.455-2.01 1.775-4.938.208.797.46 1.273.737 1.273.675 0 1.22-2.807 1.22-6.273-.008-3.457-.553-6.272-1.23-6.272ZM23.307 10.024c.381 0 .693-1.256.693-2.807 0-1.55-.312-2.807-.693-2.807-.381 0-.693 1.256-.693 2.807s.312 2.808.693 2.808Z", + "h": "A238FF" + }, + "deliveroo": { + "p": "M16.861 0l-1.127 10.584L13.81 1.66 7.777 2.926l1.924 8.922-8.695 1.822 1.535 7.127L17.832 24l3.498-7.744L22.994.636 16.861 0zM11.39 13.61a.755.755 0 01.322.066c.208.093.56.29.63.592.103.434.004.799-.312 1.084v.002c-.315.284-.732.258-1.174.113-.441-.145-.637-.672-.47-1.309.124-.473.71-.544 1.004-.549zm4.142.548c.447-.012.832.186 1.05.543.217.357.107.75-.122 1.143h-.002c-.229.392-.83.445-1.422.16-.399-.193-.397-.684-.353-.983a.922.922 0 01.193-.447c.142-.177.381-.408.656-.416Z", + "h": "00CCBC" + }, + "discord": { + "p": "M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z", + "h": "5865F2" + }, + "dropbox": { + "p": "M6 1.807L0 5.629l6 3.822 6.001-3.822L6 1.807zM18 1.807l-6 3.822 6 3.822 6-3.822-6-3.822zM0 13.274l6 3.822 6.001-3.822L6 9.452l-6 3.822zM18 9.452l-6 3.822 6 3.822 6-3.822-6-3.822zM6 18.371l6.001 3.822 6-3.822-6-3.822L6 18.371z", + "h": "0061FF" + }, + "duolingo": { + "p": "M14.484 18.213c1.142 1.033 2.657 1.662 4.316 1.662l.294-.001c1.985-.038 3.749-.976 4.905-2.422v1.98c0 2.522-2.043 4.568-4.567 4.568H4.569C2.045 23.998.002 21.954.002 19.43v-1.92c1.181 1.443 2.976 2.365 4.985 2.365l.35-.001c1.61-.027 3.076-.646 4.191-1.648.555.764 1.456 1.26 2.473 1.26 1.023 0 1.928-.502 2.483-1.273zm-5.349-.996c-.989 1.022-2.375 1.658-3.909 1.658h-.239c-2.229 0-4.146-1.343-4.987-3.262v-7.16c.281-.64.68-1.216 1.169-1.699-.035-.731.132-1.469.511-2.128.256-.44.867-.504 1.21-.124l.766.851c.007-.003.014-.003.021-.005-.098-.78.037-1.587.419-2.308.24-.45.757-.53 1.114-.164 0 0 3.939 3.979 4.035 4.084 1.542 1.348 4.066 1.287 5.686-.18.002-.003.007-.005.009-.007.042-.042 3.855-3.9 3.855-3.9.3361-.3451.8619-.3101 1.113.164.385.724.518 1.535.417 2.32.002.001.003.001.004.002l.007.002c.001 0 .002 0 .003.001l.776-.86c.342-.38.954-.316 1.207.124.387.673.553 1.427.509 2.173.496.501.897 1.099 1.169 1.762v6.941c-.816 1.978-2.761 3.373-5.032 3.373H18.8c-1.547 0-2.945-.648-3.936-1.686a.8386.8386 0 0 0-.009-.067c.313-.017.528-.162.688-.33.152-.16.299-.397.299-.776 0 0-.022-.312-.024-.324.693.767 1.696 1.249 2.811 1.249 2.092 0 3.787-1.696 3.787-3.787v-2.243c0-2.092-1.697-3.787-3.787-3.787-2.093 0-3.787 1.695-3.787 3.787v2.243c0 .266.027.526.079.776-.712-.784-1.744-1.278-2.842-1.278-1.239 0-2.339.523-3.064 1.355.063-.274.097-.56.097-.853v-2.243c0-2.092-1.697-3.787-3.788-3.787-2.09 0-3.787 1.695-3.787 3.787v2.243c0 2.093 1.697 3.787 3.787 3.787 1.151 0 2.182-.513 2.876-1.322-.008.035-.039.395-.039.395 0 .378.147.616.298.775.16.168.374.312.688.331a.7783.7783 0 0 0-.012.097zm.997.073c.729.131 1.733.305 1.792.305h.157c.059 0 1.789-.303 1.789-.303-.327.705-1.041 1.194-1.869 1.194-.829 0-1.543-.49-1.869-1.196zm-.971-1.379c.246-1.313 1.462-2.259 2.918-2.259 1.324 0 2.521.97 2.763 2.259v.105c0 .082-.029.115-.103.106l-2.658.473h-.157l-2.66-.476c-.075.01-.103-.023-.103-.105Zm8.023-6.392c.255-.14.549-.22.861-.22.992 0 1.798.804 1.798 1.798v1.919c0 .991-.804 1.797-1.798 1.797-.991 0-1.797-.803-1.797-1.797v-1.542c.034.003.068.005.103.005.64 0 1.16-.518 1.16-1.156 0-.312-.125-.596-.327-.804zM5.162 9.461c.227-.104.48-.162.746-.162.991 0 1.798.804 1.798 1.798v1.919c0 .991-.804 1.797-1.798 1.797-.991 0-1.797-.803-1.797-1.797v-1.571c.089.022.182.034.278.034.641 0 1.16-.518 1.16-1.156 0-.342-.149-.65-.387-.862ZM.002 6.554V4.568C.002 2.044 2.045 0 4.569 0h14.865c2.522 0 4.565 2.044 4.565 4.568v2.041a5.1847 5.1847 0 0 0-.164-.197 4.8592 4.8592 0 0 0-.646-2.284c-.433-.754-1.315-1.037-2.07-.786a4.785 4.785 0 0 0-.327-.774h-.001c-.287-.54-.758-.835-1.248-.908-.493-.073-1.033.072-1.464.515l-3.82 3.864c-1.226 1.11-3.127 1.199-4.313.205-.103-.109-4.025-4.071-4.025-4.071-.427-.438-.966-.584-1.46-.51-.489.073-.961.367-1.248.907v.002c-.133.25-.241.508-.327.771-.753-.252-1.635.029-2.071.782 0 0-.001.001-.001.002-.4.694-.613 1.459-.645 2.23-.057.065-.113.13-.167.197z", + "h": "58CC02" + }, + "ea": { + "p": "M16.635 6.162l-5.928 9.377H4.24l1.508-2.3h4.024l1.474-2.335H2.264L.79 13.239h2.156L0 17.84h12.072l4.563-7.259 1.652 2.66h-1.401l-1.473 2.299h4.347l1.473 2.3H24zm-11.461.107L3.7 8.604l9.52-.035 1.474-2.3z", + "h": "000000" + }, + "envato": { + "p": "M16.156 0a2.7 2.7 0 0 0-1.886.8L4 11.253c-.382.42-.558.978-.453 1.57.176.945 1.116 1.571 2.06 1.399l5.54-1.13c.12-.025.183.136.082.204L5.088 17.23c-.769.487-1.119 1.36-.875 2.234.244 1.151 1.398 1.814 2.516 1.537l9.183-2.26a.11.11 0 0 1 .113.176l-1.433 1.77c-.383.487.244 1.15.77.767l4.716-3.877c.84-.697.281-2.062-.803-1.957l-.011-.004-6.047.65a.111.111 0 0 1-.08-.199l5.918-4.609c.382-.315.628-.801.523-1.326-.105-.803-.767-1.328-1.607-1.223l-6.43.942c-.112.015-.174-.128-.084-.2l6.375-4.867c1.256-.978 1.36-2.898.209-4.015A2.6 2.6 0 0 0 16.156 0M13.1 21.855a1.07 1.07 0 0 0-1.073 1.073A1.07 1.07 0 0 0 13.1 24a1.07 1.07 0 0 0 1.072-1.072 1.07 1.07 0 0 0-1.072-1.073", + "h": "87E64B" + }, + "evernote": { + "p": "M8.222 5.393c0 .239-.02.637-.256.895-.257.24-.652.259-.888.259H4.552c-.73 0-1.165 0-1.46.04-.159.02-.356.1-.455.14-.04.019-.04 0-.02-.02L8.38.796c.02-.02.04-.02.02.02-.04.099-.118.298-.138.457-.04.298-.04.736-.04 1.472v2.647zm5.348 17.869c-.67-.438-1.026-1.015-1.164-1.373a2.924 2.924 0 01-.217-1.095 3.007 3.007 0 013-3.004c.493 0 .888.398.888.895a.88.88 0 01-.454.776c-.099.06-.237.1-.336.12-.098.02-.473.06-.65.218-.198.16-.356.418-.356.697 0 .298.118.577.316.776.355.358.829.557 1.342.557a2.436 2.436 0 002.427-2.447c0-1.214-.809-2.29-1.875-2.766-.158-.08-.414-.14-.651-.2a8.04 8.04 0 00-.592-.1c-.829-.1-2.901-.755-3.04-2.605 0 0-.611 2.785-1.835 3.54-.118.06-.276.12-.454.16-.177.04-.374.06-.434.06-1.993.12-4.105-.517-5.565-2.03 0 0-.987-.815-1.5-3.103-.118-.558-.355-1.553-.493-2.488-.06-.338-.08-.597-.099-.836 0-.975.592-1.631 1.342-1.73h4.026c.69 0 1.086-.18 1.342-.42.336-.317.415-.775.415-1.312V1.354C9.05.617 9.703 0 10.669 0h.474c.197 0 .434.02.651.04.158.02.296.06.533.12 1.204.298 1.46 1.532 1.46 1.532s2.27.398 3.415.597c1.085.199 3.77.378 4.282 3.104 1.204 6.487.474 12.775.415 12.775-.849 6.129-5.901 5.83-5.901 5.83a4.1 4.1 0 01-2.428-.736zm4.54-13.034c-.652-.06-1.204.2-1.402.697-.04.1-.079.219-.059.278.02.06.06.08.099.1.237.12.631.179 1.204.239.572.06.967.1 1.223.06.04 0 .08-.02.119-.08.04-.06.02-.18.02-.28-.06-.536-.553-.934-1.204-1.014z", + "h": "00A82D" + }, + "expressvpn": { + "p": "M11.705 2.349a4.874 4.874 0 00-4.39 2.797L6.033 7.893h14.606c.41 0 .692.308.692.668 0 .359-.282.666-.692.666H2.592L0 14.772h2.824c-.796 1.72-1.002 2.567-1.002 3.26 0 2.105 1.72 3.62 4.416 3.62h8.239c1.771 0 3.337-1.412 3.337-3.03 0-1.411-1.206-2.515-2.772-2.515H5.596c-.873 0-1.284-.59-.924-1.335h11.859c4.004 0 7.469-3.029 7.469-6.802 0-3.183-2.618-5.621-6.16-5.621z", + "h": "DA3940" + }, + "figma": { + "p": "M15.852 8.981h-4.588V0h4.588c2.476 0 4.49 2.014 4.49 4.49s-2.014 4.491-4.49 4.491zM12.735 7.51h3.117c1.665 0 3.019-1.355 3.019-3.019s-1.355-3.019-3.019-3.019h-3.117V7.51zm0 1.471H8.148c-2.476 0-4.49-2.014-4.49-4.49S5.672 0 8.148 0h4.588v8.981zm-4.587-7.51c-1.665 0-3.019 1.355-3.019 3.019s1.354 3.02 3.019 3.02h3.117V1.471H8.148zm4.587 15.019H8.148c-2.476 0-4.49-2.014-4.49-4.49s2.014-4.49 4.49-4.49h4.588v8.98zM8.148 8.981c-1.665 0-3.019 1.355-3.019 3.019s1.355 3.019 3.019 3.019h3.117V8.981H8.148zM8.172 24c-2.489 0-4.515-2.014-4.515-4.49s2.014-4.49 4.49-4.49h4.588v4.441c0 2.503-2.047 4.539-4.563 4.539zm-.024-7.51a3.023 3.023 0 0 0-3.019 3.019c0 1.665 1.365 3.019 3.044 3.019 1.705 0 3.093-1.376 3.093-3.068v-2.97H8.148zm7.704 0h-.098c-2.476 0-4.49-2.014-4.49-4.49s2.014-4.49 4.49-4.49h.098c2.476 0 4.49 2.014 4.49 4.49s-2.014 4.49-4.49 4.49zm-.097-7.509c-1.665 0-3.019 1.355-3.019 3.019s1.355 3.019 3.019 3.019h.098c1.665 0 3.019-1.355 3.019-3.019s-1.355-3.019-3.019-3.019h-.098z", + "h": "F24E1E" + }, + "fitbit": { + "p": "M13.298 1.825c0 .976-.81 1.785-1.786 1.785-.972 0-1.784-.81-1.784-1.785 0-.973.813-1.785 1.784-1.785.976 0 1.786.813 1.786 1.785zm-1.786 3.243c-1.052 0-1.863.81-1.863 1.866 0 1.053.81 1.865 1.865 1.865 1.053 0 1.865-.811 1.865-1.865s-.825-1.866-1.875-1.866h.008zm0 5.029c-1.052 0-1.945.891-1.945 1.945s.894 1.945 1.947 1.945 1.946-.891 1.946-1.945-.894-1.945-1.946-1.945h-.002zm0 5.107c-1.052 0-1.863.81-1.863 1.864s.81 1.866 1.865 1.866c1.053 0 1.865-.811 1.865-1.866 0-.972-.825-1.864-1.875-1.864h.008zm0 5.191c-.972 0-1.784.809-1.784 1.784 0 .97.813 1.781 1.784 1.781.977 0 1.786-.809 1.786-1.784 0-.973-.81-1.781-1.786-1.781zM16.46 4.823c-1.136 0-2.108.977-2.108 2.111 0 1.134.973 2.107 2.108 2.107 1.135 0 2.106-.975 2.106-2.107 0-1.135-.972-2.109-2.106-2.109v-.002zm0 5.03c-1.216 0-2.19.973-2.19 2.19 0 1.216.975 2.187 2.19 2.187 1.215 0 2.189-.971 2.189-2.189 0-1.216-.974-2.188-2.189-2.188zm0 5.108c-1.136 0-2.108.976-2.108 2.107 0 1.135.973 2.109 2.108 2.109 1.135 0 2.106-.976 2.106-2.109s-.971-2.107-2.106-2.107zm5.106-5.353c-1.296 0-2.43 1.055-2.43 2.434 0 1.297 1.051 2.433 2.43 2.433 1.381 0 2.434-1.065 2.434-2.444-.082-1.382-1.135-2.431-2.434-2.431v.008zM6.486 5.312c-.892 0-1.62.73-1.62 1.623 0 .891.729 1.62 1.62 1.62.893 0 1.619-.729 1.619-1.62 0-.893-.727-1.62-1.619-1.62v-.003zm0 5.027c-.973 0-1.703.729-1.703 1.703 0 .975.721 1.703 1.695 1.703s1.695-.73 1.695-1.703c0-.975-.735-1.703-1.71-1.703h.023zm0 5.107c-.892 0-1.62.731-1.62 1.62 0 .895.729 1.623 1.62 1.623.893 0 1.619-.735 1.619-1.635s-.727-1.62-1.619-1.62v.012zm-5.025-4.863c-.813 0-1.461.646-1.461 1.459 0 .81.648 1.459 1.46 1.459.81 0 1.459-.648 1.459-1.459s-.648-1.459-1.458-1.459z", + "h": "00B0B9" + }, + "githubcopilot": { + "p": "M23.922 16.997C23.061 18.492 18.063 22.02 12 22.02 5.937 22.02.939 18.492.078 16.997A.641.641 0 0 1 0 16.741v-2.869a.883.883 0 0 1 .053-.22c.372-.935 1.347-2.292 2.605-2.656.167-.429.414-1.055.644-1.517a10.098 10.098 0 0 1-.052-1.086c0-1.331.282-2.499 1.132-3.368.397-.406.89-.717 1.474-.952C7.255 2.937 9.248 1.98 11.978 1.98c2.731 0 4.767.957 6.166 2.093.584.235 1.077.546 1.474.952.85.869 1.132 2.037 1.132 3.368 0 .368-.014.733-.052 1.086.23.462.477 1.088.644 1.517 1.258.364 2.233 1.721 2.605 2.656a.841.841 0 0 1 .053.22v2.869a.641.641 0 0 1-.078.256Zm-11.75-5.992h-.344a4.359 4.359 0 0 1-.355.508c-.77.947-1.918 1.492-3.508 1.492-1.725 0-2.989-.359-3.782-1.259a2.137 2.137 0 0 1-.085-.104L4 11.746v6.585c1.435.779 4.514 2.179 8 2.179 3.486 0 6.565-1.4 8-2.179v-6.585l-.098-.104s-.033.045-.085.104c-.793.9-2.057 1.259-3.782 1.259-1.59 0-2.738-.545-3.508-1.492a4.359 4.359 0 0 1-.355-.508Zm2.328 3.25c.549 0 1 .451 1 1v2c0 .549-.451 1-1 1-.549 0-1-.451-1-1v-2c0-.549.451-1 1-1Zm-5 0c.549 0 1 .451 1 1v2c0 .549-.451 1-1 1-.549 0-1-.451-1-1v-2c0-.549.451-1 1-1Zm3.313-6.185c.136 1.057.403 1.913.878 2.497.442.544 1.134.938 2.344.938 1.573 0 2.292-.337 2.657-.751.384-.435.558-1.15.558-2.361 0-1.14-.243-1.847-.705-2.319-.477-.488-1.319-.862-2.824-1.025-1.487-.161-2.192.138-2.533.529-.269.307-.437.808-.438 1.578v.021c0 .265.021.562.063.893Zm-1.626 0c.042-.331.063-.628.063-.894v-.02c-.001-.77-.169-1.271-.438-1.578-.341-.391-1.046-.69-2.533-.529-1.505.163-2.347.537-2.824 1.025-.462.472-.705 1.179-.705 2.319 0 1.211.175 1.926.558 2.361.365.414 1.084.751 2.657.751 1.21 0 1.902-.394 2.344-.938.475-.584.742-1.44.878-2.497Z", + "h": "000000" + }, + "glovo": { + "p": "M12.012 0C7.847 0 4.459 3.388 4.459 7.553c0 1.576.494 3.106 1.412 4.4l.211.281 3.93 5.555s.47.775 1.529.775h.941c1.036 0 1.53-.775 1.53-.775l3.93-5.555.187-.28a7.43 7.43 0 0 0 1.412-4.401C19.564 3.388 16.176 0 12.011 0Zm0 3.693a3.837 3.837 0 0 1 3.836 3.836c0 .824-.26 1.578-.73 2.237l-.212.28-2.894 4.095-2.895-4.07-.21-.305a3.848 3.848 0 0 1-.731-2.237 3.837 3.837 0 0 1 3.836-3.836zm-2.117 18.26c0 1.106.893 2.023 2.07 2.047 1.223 0 2.117-.917 2.117-2.059 0-1.14-.894-2.058-2.094-2.058-1.2 0-2.093.917-2.093 2.07z", + "h": "F2CC38" + }, + "googlegemini": { + "p": "M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81", + "h": "8E75B2" + }, + "googleplay": { + "p": "M22.018 13.298l-3.919 2.218-3.515-3.493 3.543-3.521 3.891 2.202a1.49 1.49 0 0 1 0 2.594zM1.337.924a1.486 1.486 0 0 0-.112.568v21.017c0 .217.045.419.124.6l11.155-11.087L1.337.924zm12.207 10.065l3.258-3.238L3.45.195a1.466 1.466 0 0 0-.946-.179l11.04 10.973zm0 2.067l-11 10.933c.298.036.612-.016.906-.183l13.324-7.54-3.23-3.21z", + "h": "414141" + }, + "grammarly": { + "p": "M12 24H.032V12c0-3.314 1.341-6.314 3.504-8.486C5.703 1.344 8.694 0 12 0c3.305 0 6.297 1.344 8.463 3.514 2.164 2.172 3.505 5.172 3.505 8.486s-1.338 6.314-3.505 8.486C18.297 22.656 15.305 24 12 24m2.889-13.137-1.271 2.205h4.418c-.505 2.882-3.018 5.078-6.036 5.078-3.38 0-6.132-2.757-6.132-6.146S8.618 5.854 12 5.854c1.821 0 3.458.801 4.584 2.069l1.143-1.988c-1.493-1.418-3.506-2.29-5.725-2.29-4.6 0-8.332 3.74-8.332 8.355s3.73 8.354 8.332 8.354c4.603 0 8.332-3.739 8.332-8.354 0-.387-.029-.765-.079-1.137z", + "h": "027E6F" + }, + "hbomax": { + "p": "M3.784 8.716c-.655 0-1.32.29-2.173.946v-.78H0v6.236h1.715V11.24c.749-.592 1.091-.78 1.372-.78.333 0 .551.209.551.729v3.928h1.715V11.23c.748-.582 1.081-.769 1.372-.769.333 0 .55.208.55.728v3.928H8.99v-4.53c0-1.403-.8-1.871-1.57-1.871-.654 0-1.32.27-2.192.936-.28-.697-.894-.936-1.444-.936zm8.689 0c-1.705 0-3.118 1.466-3.118 3.284 0 1.82 1.413 3.285 3.118 3.285.842 0 1.57-.312 2.131-.988v.82h1.632V8.883h-1.632v.822c-.561-.676-1.29-.988-2.131-.988zm4.064.166c.707 1.102 1.507 2.09 2.443 3.077a26.593 26.593 0 0 0-2.443 3.16h2.069a13.603 13.603 0 0 1 1.673-2.183 14.067 14.067 0 0 1 1.632 2.182H24a25.142 25.142 0 0 0-2.432-3.16A23.918 23.918 0 0 0 24 8.883h-2.047a14.65 14.65 0 0 1-1.674 2.11 13.357 13.357 0 0 1-1.674-2.11zm-3.804 1.279c1.018 0 1.84.82 1.84 1.84a1.837 1.837 0 0 1-1.84 1.839c-1.019 0-1.84-.82-1.84-1.84 0-1.018.821-1.84 1.84-1.84zm0 .415c-.78 0-1.414.633-1.414 1.423s.634 1.424 1.413 1.424c.78 0 1.414-.634 1.414-1.424s-.634-1.424-1.414-1.424z", + "h": "000000" + }, + "headspace": { + "p": "M23.9711 11.8612c.279 3.8878-1.5272 6.0933-2.6155 7.6357-1.694 1.7856-3.8397 4.2203-9.291 4.3565-4.6237.1827-6.8957-1.8508-8.8034-3.617-2.487-2.7336-3.1366-4.3512-3.261-8.3752-.0118-2.467.9397-4.9292 2.6025-7.0954C4.934 1.4736 8.6408.3699 12.0646.1426c3.5923-.1392 6.4493 1.6723 8.3993 3.624 2.4963 2.632 3.2629 4.8923 3.5054 8.0946Z", + "h": "F47D31" + }, + "hellofresh": { + "p": "M9.7894 22.2329c-.9661-.0974-2.0001-.326-3.042-.7589-.5912-.2456-1.1673-.5843-1.2123-.6109-.362-.2057-.6568-.457-1.2135-.7269-.7048-.3416-1.3836-.5276-2.1106-.611-.9842-.0661-1.038.0124-1.319-.0745-.1676-.0545-.3188-.1205-.495-.2848-.0526-.049-.125-.1304-.1607-.1808-.125-.1763-.1744-.3314-.194-.3997-.0284-.0981-.0424-.1563-.0423-.3324 0-.1565.0152-.2397.035-.3116.0763-.2788.173-.3408.4299-.8472.3285-.6476.5238-1.285.6176-1.9564a5.7292 5.7292 0 0 0 .0554-1.017c-.015-.5062-.0383-.6133-.0392-1.0444-.0026-1.2549.2374-2.3546.5533-3.2859.2061-.6079.3889-1.007.6046-1.4333.5845-1.1551 1.5013-2.4784 2.9354-3.6924.7732-.6545 1.9737-1.5002 3.5538-2.1176 1.3446-.5253 2.5225-.7015 3.064-.7614.664-.087 1.8067-.1234 2.975.0535.9966.151 2.2445.4867 3.5131 1.2.4312.2424.6815.4377 1.014.6296.814.4697 1.6498.7054 2.4477.8015.424.051 1.0618.0047 1.302.0666.1477.0381.2551.0862.3896.1755.1135.0755.3629.2761.4912.6485.061.1772.1243.6076-.0987.9911-.0365.063-.1066.183-.1557.2669-.0491.0838-.1423.2622-.2072.3964-.6611 1.3677-.6465 2.5461-.6009 3.263.0534.84.05 2.2341-.5417 3.9644-.1037.3032-.3364.9313-.7023 1.6143-.8281 1.5455-1.876 2.6331-2.5374 3.2256-1.474 1.3204-2.9634 2.038-3.9265 2.4021-.8975.3393-1.5834.5095-2.3024.6327-.6934.1188-1.8193.2425-3.0802.1154z", + "h": "99CC33" + }, + "icloud": { + "p": "M13.762 4.29a6.51 6.51 0 0 0-5.669 3.332 3.571 3.571 0 0 0-1.558-.36 3.571 3.571 0 0 0-3.516 3A4.918 4.918 0 0 0 0 14.796a4.918 4.918 0 0 0 4.92 4.914 4.93 4.93 0 0 0 .617-.045h14.42c2.305-.272 4.041-2.258 4.043-4.589v-.009a4.594 4.594 0 0 0-3.727-4.508 6.51 6.51 0 0 0-6.511-6.27z", + "h": "3693F3" + }, + "jetbrains": { + "p": "M2.345 23.997A2.347 2.347 0 0 1 0 21.652V10.988C0 9.665.535 8.37 1.473 7.433l5.965-5.961A5.01 5.01 0 0 1 10.989 0h10.666A2.347 2.347 0 0 1 24 2.345v10.664a5.056 5.056 0 0 1-1.473 3.554l-5.965 5.965A5.017 5.017 0 0 1 13.007 24v-.003H2.345Zm8.969-6.854H5.486v1.371h5.828v-1.371ZM3.963 6.514h13.523v13.519l4.257-4.257a3.936 3.936 0 0 0 1.146-2.767V2.345c0-.678-.552-1.234-1.234-1.234H10.989a3.897 3.897 0 0 0-2.767 1.145L3.963 6.514Zm-.192.192L2.256 8.22a3.944 3.944 0 0 0-1.145 2.768v10.664c0 .678.552 1.234 1.234 1.234h10.666a3.9 3.9 0 0 0 2.767-1.146l1.512-1.511H3.771V6.706Z", + "h": "000000" + }, + "medium": { + "p": "M4.21 0A4.201 4.201 0 0 0 0 4.21v15.58A4.201 4.201 0 0 0 4.21 24h15.58A4.201 4.201 0 0 0 24 19.79v-1.093c-.137.013-.278.02-.422.02-2.577 0-4.027-2.146-4.09-4.832a7.592 7.592 0 0 1 .022-.708c.093-1.186.475-2.241 1.105-3.022a3.885 3.885 0 0 1 1.395-1.1c.468-.237 1.127-.367 1.664-.367h.023c.101 0 .202.004.303.01V4.211A4.201 4.201 0 0 0 19.79 0Zm.198 5.583h4.165l3.588 8.435 3.59-8.435h3.864v.146l-.019.004c-.705.16-1.063.397-1.063 1.254h-.003l.003 10.274c.06.676.424.885 1.063 1.03l.02.004v.145h-4.923v-.145l.019-.005c.639-.144.994-.353 1.054-1.03V7.267l-4.745 11.15h-.261L6.15 7.569v9.445c0 .857.358 1.094 1.063 1.253l.02.004v.147H4.405v-.147l.019-.004c.705-.16 1.065-.397 1.065-1.253V6.987c0-.857-.358-1.094-1.064-1.254l-.018-.004zm19.25 3.668c-1.086.023-1.733 1.323-1.813 3.124H24V9.298a1.378 1.378 0 0 0-.342-.047Zm-1.862 3.632c-.1 1.756.86 3.239 2.204 3.634v-3.634z", + "h": "000000" + }, + "mega": { + "p": "M12 0C5.372 0 0 5.372 0 12s5.372 12 12 12 12-5.372 12-12S18.628 0 12 0zm6.23 16.244a.371.371 0 0 1-.373.372H16.29a.371.371 0 0 1-.372-.372v-4.828c0-.04-.046-.06-.08-.033l-3.32 3.32a.742.742 0 0 1-1.043 0l-3.32-3.32c-.027-.027-.08-.007-.08.033v4.828a.371.371 0 0 1-.372.372H6.136a.371.371 0 0 1-.372-.372V7.757c0-.206.166-.372.372-.372h1.076a.75.75 0 0 1 .525.22l4.13 4.13a.18.18 0 0 0 .26 0l4.13-4.13c.14-.14.325-.22.525-.22h1.075c.206 0 .372.166.372.372z", + "h": "D9272E" + }, + "mubi": { + "p": "M3.357.033A3.357 3.357 0 0 0 0 3.39a3.357 3.357 0 0 0 3.357 3.357A3.357 3.357 0 0 0 6.713 3.39 3.357 3.357 0 0 0 3.357.033Zm8.643 0A3.357 3.357 0 0 0 8.645 3.39 3.357 3.357 0 0 0 12 6.746a3.357 3.357 0 0 0 3.357-3.357A3.357 3.357 0 0 0 12 .033Zm-8.643 8.61A3.357 3.357 0 0 0 0 12a3.357 3.357 0 0 0 3.357 3.355A3.357 3.357 0 0 0 6.713 12a3.357 3.357 0 0 0-3.356-3.357Zm8.643 0A3.357 3.357 0 0 0 8.645 12 3.357 3.357 0 0 0 12 15.355 3.357 3.357 0 0 0 15.357 12 3.357 3.357 0 0 0 12 8.643zm8.643 0A3.357 3.357 0 0 0 17.287 12a3.357 3.357 0 0 0 3.356 3.355A3.357 3.357 0 0 0 24 12a3.357 3.357 0 0 0-3.357-3.357Zm-17.286 8.61A3.357 3.357 0 0 0 0 20.612a3.357 3.357 0 0 0 3.357 3.356 3.357 3.357 0 0 0 3.356-3.356 3.357 3.357 0 0 0-3.356-3.357Zm8.643 0a3.357 3.357 0 0 0-3.355 3.358A3.357 3.357 0 0 0 12 23.967a3.357 3.357 0 0 0 3.357-3.356A3.357 3.357 0 0 0 12 17.254z", + "h": "000000" + }, + "n26": { + "p": "M0 3.803v1.195h7.436V3.803H0zM12.69 7.29c-2.034 0-3.038 1.252-3.038 2.684 0 .234.027.468.092.728l1.393.135a3.697 3.697 0 0 1-.09-.793c0-1.072.71-1.586 1.598-1.586.866 0 1.507.485 1.507 1.652 0 1.186-.58 1.995-1.464 2.88-.925.923-2.4 2.027-3.112 2.534v1.092h6.135v-1.195h-4.168c.695-.48 1.69-1.279 2.133-1.72.502-.503 1.931-1.794 1.931-3.636 0-1.903-1.24-2.775-2.918-2.775zm8.34 0c-1.976 0-3.454 1.517-3.454 4.916 0 3.017 1.233 4.508 3.356 4.508 1.754 0 3.068-1.198 3.068-3.172 0-1.542-.823-3.066-2.793-3.066-1.1 0-1.884.51-2.281 1.263 0-1.78.62-3.33 2.094-3.33.937 0 1.309.538 1.507 1.422l1.366-.271c-.321-1.527-1.292-2.27-2.864-2.27zM.075 7.389v9.228h1.33v-6.312c0-.56-.013-.898-.039-1.223h.026c.136.372.298.699.539 1.123l3.732 6.412h1.69V7.39H6.04v6.31c0 .56.013.898.04 1.223h-.028a7.252 7.252 0 0 0-.537-1.123L1.783 7.389H.076zm20.817 4.185c1.114 0 1.744.822 1.744 1.992 0 1.256-.717 2.034-1.701 2.034-1.09 0-1.843-1.001-1.973-2.329.33-1.133 1.063-1.697 1.93-1.697zM0 19.008v1.19h7.436v-1.19H0z", + "h": "48AC98" + }, + "netflix": { + "p": "m5.398 0 8.348 23.602c2.346.059 4.856.398 4.856.398L10.113 0H5.398zm8.489 0v9.172l4.715 13.33V0h-4.715zM5.398 1.5V24c1.873-.225 2.81-.312 4.715-.398V14.83L5.398 1.5z", + "h": "E50914" + }, + "newyorktimes": { + "p": "M21.272,14.815h-0.098c-0.747,2.049-2.335,3.681-4.363,4.483v-4.483l2.444-2.182l-2.444-2.182V7.397 c2.138,0.006,3.885-1.703,3.927-3.84c0-2.629-2.509-3.556-3.927-3.556c-0.367-0.007-0.734,0.033-1.091,0.12v0.131h0.556 c0.801-0.141,1.565,0.394,1.706,1.195C17.99,1.491,17.996,1.537,18,1.583c-0.033,0.789-0.7,1.401-1.488,1.367 c-0.02-0.001-0.041-0.002-0.061-0.004c-2.444,0-5.323-1.985-8.454-1.985C5.547,0.83,3.448,2.692,3.284,5.139 C3.208,6.671,4.258,8.031,5.76,8.346v-0.12C5.301,7.931,5.041,7.407,5.084,6.862c0.074-1.015,0.957-1.779,1.973-1.705 C7.068,5.159,7.08,5.16,7.091,5.161c2.629,0,6.872,2.182,9.501,2.182h0.098v3.142l-2.444,2.182l2.444,2.182v4.549 c-0.978,0.322-2.003,0.481-3.033,0.469c-1.673,0.084-3.318-0.456-4.614-1.516l4.429-1.985V7.451l-6.196,2.727 c0.592-1.75,1.895-3.168,3.589-3.905V6.175c-4.516,1.004-8.138,4.243-8.138,8.705c0,5.193,4.025,9.12,9.818,9.12 c6.011,0,8.727-4.363,8.727-8.814V14.815z M8.858,18.186c-1.363-1.362-2.091-3.235-2.007-5.16c-0.016-0.88,0.109-1.756,0.371-2.596 l2.051-0.938v8.476L8.858,18.186z", + "h": "000000" + }, + "nordvpn": { + "p": "M2.2838 21.5414A11.9866 11.9866 0 010 14.4832C0 7.8418 5.3727 2.4586 12 2.4586c6.6279 0 12 5.3832 12 12.0246a11.9853 11.9853 0 01-2.2838 7.0582l-5.7636-9.3783-.5565.9419.5645 2.6186L12 8.9338l-2.45 4.1447.5707 2.6451-2.0764-3.5555-5.7605 9.3733z", + "h": "4687FF" + }, + "notion": { + "p": "M4.459 4.208c.746.606 1.026.56 2.428.466l13.215-.793c.28 0 .047-.28-.046-.326L17.86 1.968c-.42-.326-.981-.7-2.055-.607L3.01 2.295c-.466.046-.56.28-.374.466zm.793 3.08v13.904c0 .747.373 1.027 1.214.98l14.523-.84c.841-.046.935-.56.935-1.167V6.354c0-.606-.233-.933-.748-.887l-15.177.887c-.56.047-.747.327-.747.933zm14.337.745c.093.42 0 .84-.42.888l-.7.14v10.264c-.608.327-1.168.514-1.635.514-.748 0-.935-.234-1.495-.933l-4.577-7.186v6.952L12.21 19s0 .84-1.168.84l-3.222.186c-.093-.186 0-.653.327-.746l.84-.233V9.854L7.822 9.76c-.094-.42.14-1.026.793-1.073l3.456-.233 4.764 7.279v-6.44l-1.215-.139c-.093-.514.28-.887.747-.933zM1.936 1.035l13.31-.98c1.634-.14 2.055-.047 3.082.7l4.249 2.986c.7.513.934.653.934 1.213v16.378c0 1.026-.373 1.634-1.68 1.726l-15.458.934c-.98.047-1.448-.093-1.962-.747l-3.129-4.06c-.56-.747-.793-1.306-.793-1.96V2.667c0-.839.374-1.54 1.447-1.632z", + "h": "000000" + }, + "now": { + "p": "M8.8009 11.9974c0-.974.7878-1.7634 1.7596-1.7634.9718 0 1.7596.7895 1.7596 1.7634 0 .9738-.7878 1.7634-1.7596 1.7634-.9718 0-1.7596-.7896-1.7596-1.7634zm13.0277-2.896l-1.2166 2.4524-.7878-2.3188-.0015-.0003c-.1566-.4505-.5822-.7737-1.0829-.7737-.399 0-.7505.2054-.956.517-.5255.8015-1.0497 1.6094-1.5735 2.414l-.2785-1.956c-.0963-.6296-.6807-1.0587-1.3048-.9624-.6249.096-1.0538.6778-.958 1.304l.0488.328c-.6427-1.0749-1.8162-1.7945-3.1575-1.7945-1.353 0-2.5352.7324-3.174 1.823l.07-.3434c.1223-.6008-.2645-1.1873-.864-1.31-.5993-.1223-1.1848.265-1.307.8659l-.4763 2.3382-1.752-2.7177c-.198-.3042-.5399-.5053-.9284-.5053-.5317 0-.976.3765-1.084.879l-1.0217 5.012c-.1223.6007.257 1.1846.8575 1.3121.0747.0159.1556.0235.2291.024.5139.0036.9763-.3579 1.0844-.892l.4763-2.3383c.5924.9217 1.1845 1.844 1.779 2.7641.196.2777.5281.4662.9018.4662.5462 0 1.0002-.398 1.0915-.9219l.469-2.302c.2292 1.815 1.7755 3.2187 3.6488 3.2187 1.7257 0 3.1736-1.191 3.5705-2.7972l.2613 1.759c.0736.579.5474 1.0371 1.1411 1.0371.4272 0 .7756-.2445.9972-.5841l1.8844-2.8942.905 2.6645c.1622.4752.5808.8138 1.0961.8138.4788 0 .855-.288 1.0609-.7155l2.402-4.845c.2834-.568.0528-1.2551-.5123-1.5403-.5647-.285-1.2558-.0524-1.5379.5196Z", + "h": "001211" + }, + "nvidia": { + "p": "M8.948 8.798v-1.43a6.7 6.7 0 0 1 .424-.018c3.922-.124 6.493 3.374 6.493 3.374s-2.774 3.851-5.75 3.851c-.398 0-.787-.062-1.158-.185v-4.346c1.528.185 1.837.857 2.747 2.385l2.04-1.714s-1.492-1.952-4-1.952a6.016 6.016 0 0 0-.796.035m0-4.735v2.138l.424-.027c5.45-.185 9.01 4.47 9.01 4.47s-4.08 4.964-8.33 4.964c-.37 0-.733-.035-1.095-.097v1.325c.3.035.61.062.91.062 3.957 0 6.82-2.023 9.593-4.408.459.371 2.34 1.263 2.73 1.652-2.633 2.208-8.772 3.984-12.253 3.984-.335 0-.653-.018-.971-.053v1.864H24V4.063zm0 10.326v1.131c-3.657-.654-4.673-4.46-4.673-4.46s1.758-1.944 4.673-2.262v1.237H8.94c-1.528-.186-2.73 1.245-2.73 1.245s.68 2.412 2.739 3.11M2.456 10.9s2.164-3.197 6.5-3.533V6.201C4.153 6.59 0 10.653 0 10.653s2.35 6.802 8.948 7.42v-1.237c-4.84-.6-6.492-5.936-6.492-5.936z", + "h": "76B900" + }, + "paramountplus": { + "p": "M16.347 21.373c.057-.084.151-.314-.025-.74l-.53-1.428c-.073-.182.084-.293.19-.173 0 0 1.004 1.157 1.264 1.64l.495.822c.425.028 1.6.06 2.732.06a3.26 3.26 0 0 1-.316-.364c-1.93-2.392-3.154-3.724-3.166-3.737-.391-.426-.572-.508-.87-.643a4.82 4.82 0 0 1-.138-.065v.364c0 .047-.057.073-.086.022l-2.846-5.001a1.598 1.598 0 0 0-.508-.587l-.277-.194-1.354 3.123c.212 0 .354.216.27.409l-1.25 2.893h1.147c.443 0 .883.087 1.294.255l.302.125s-.913 1.878-.913 2.867c0 .181.028.362.075.534h2.104l-.096-.595s1.266.294 2.502.413M12 2.437c-6.627 0-12 5.373-12 12 0 2.669.873 5.133 2.346 7.126.503-.218.783-.542.983-.791l2.234-2.858a.467.467 0 0 1 .179-.138l.336-.146 3.674-4.659.534-.417 1.094-1.524a.482.482 0 0 1 .101-.102l.478-.347a.34.34 0 0 1 .398-.004l.578.407c.308.216.557.504.726.84l2.322 4.077c.051.09.09.129.182.174.454.227.732.268 1.33.913.277.304 1.495 1.666 3.203 3.784.236.318.538.588.963.783A11.948 11.948 0 0 0 24 14.437c0-6.627-5.373-12-12-12M3.236 15.1l-.778-.253-.48.662v-.818l-.778-.253.778-.253v-.818l.48.662.778-.253-.48.662Zm-.185 2.676-.252.778-.253-.778h-.818l.661-.481-.253-.777.663.48.66-.48-.252.777.662.481Zm.156-6.195.253.778-.661-.48-.663.48.253-.778-.66-.48h.817l.253-.778.252.777h.818Zm1.314-1.76L4.04 9.16l-.778.253.48-.661-.48-.663.778.254.48-.662v.818l.778.253-.777.252Zm2.045-2.862-.253.777-.252-.777h-.818l.662-.48-.253-.778.661.48.661-.48-.252.777.662.48Zm2.577-1.313-.48.661V5.49l-.779-.254.778-.253v-.817l.48.66.78-.253-.481.663.48.66zm3.265-.75.253.778-.661-.48-.662.48.252-.777-.66-.481h.818L12 3.637l.252.778h.818zm2.93.595v.816l-.481-.661-.777.252.48-.662-.48-.662.777.253.48-.66v.817l.779.252zm5.426 8.285.778.253.48-.662v.818l.778.253-.778.253v.818l-.48-.662-.778.253.48-.662zm-3.077-6.04-.253-.777h-.818l.662-.48-.253-.778.662.48.662-.48-.254.778.662.48h-.818zm1.792 2.086v-.818l-.777-.252.777-.253V7.68l.481.662.777-.254-.48.663.48.66-.777-.252zm1.469 1.278.253-.777.254.777h.816l-.66.481.252.778-.662-.48-.661.48.253-.778-.662-.48zm.506 6.676-.253.778-.253-.778h-.817l.662-.481-.253-.777.66.48.663-.48-.253.777.661.481zm-12.08-.615.76-1.588c.024-.048-.032-.108-.067-.067l-.664.668c-.313.329-.847 1.25-.95 1.421l-.808 1.335a.109.109 0 0 1 .1.162l-.739 1.238c-.18.309.145.523.189.452 1.157-1.868 1.832-1.719 1.832-1.719l.387-.897c.022-.047-.001-.1-.05-.12-.12-.05-.316-.27.01-.885z", + "h": "0064FF" + }, + "patreon": { + "p": "M22.957 7.21c-.004-3.064-2.391-5.576-5.191-6.482-3.478-1.125-8.064-.962-11.384.604C2.357 3.231 1.093 7.391 1.046 11.54c-.039 3.411.302 12.396 5.369 12.46 3.765.047 4.326-4.804 6.068-7.141 1.24-1.662 2.836-2.132 4.801-2.618 3.376-.836 5.678-3.501 5.673-7.031Z", + "h": "000000" + }, + "peloton": { + "p": "M17.7283 5.7642l1.7307-3.0066c.5045-.8803.2077-2.0077-.6725-2.5121-.8802-.5044-2.0077-.2077-2.5121.6725l-1.7407 3.0066c-3.699-1.167-7.843.3462-9.8606 3.8473-1.2857 2.2253-1.444 4.7869-.6626 7.032l3.2044-5.5583c.732-1.2759 1.9286-2.1858 3.3528-2.5715 1.4242-.3857 2.9078-.188 4.1836.5539 2.6308 1.523 3.5407 4.9055 2.0176 7.5363-1.523 2.6308-4.8957 3.5407-7.5364 2.0176l1.8396-3.1846c.8803.5044 2.0077.2077 2.5122-.6726.5044-.8802.2076-2.0077-.6726-2.512-.8802-.5045-2.0077-.2078-2.5121.6725l-5.855 10.1572c-.5044.8803-.2077 2.0077.6725 2.5121.8802.5044 2.0077.2077 2.5121-.6725L9.47 20.0754c3.699 1.167 7.843-.3462 9.8606-3.8473 2.0176-3.4913 1.256-7.833-1.6022-10.4639z", + "h": "181A1D" + }, + "perplexity": { + "p": "M22.3977 7.0896h-2.3106V.0676l-7.5094 6.3542V.1577h-1.1554v6.1966L4.4904 0v7.0896H1.6023v10.3976h2.8882V24l6.932-6.3591v6.2005h1.1554v-6.0469l6.9318 6.1807v-6.4879h2.8882V7.0896zm-3.4657-4.531v4.531h-5.355l5.355-4.531zm-13.2862.0676 4.8691 4.4634H5.6458V2.6262zM2.7576 16.332V8.245h7.8476l-6.1149 6.1147v1.9723H2.7576zm2.8882 5.0404v-3.8852h.0001v-2.6488l5.7763-5.7764v7.0111l-5.7764 5.2993zm12.7086.0248-5.7766-5.1509V9.0618l5.7766 5.7766v6.5588zm2.8882-5.0652h-1.733v-1.9723L13.3948 8.245h7.8478v8.087z", + "h": "1FB8CD" + }, + "playstation": { + "p": "M8.984 2.596v17.547l3.915 1.261V6.688c0-.69.304-1.151.794-.991.636.18.76.814.76 1.505v5.875c2.441 1.193 4.362-.002 4.362-3.152 0-3.237-1.126-4.675-4.438-5.827-1.307-.448-3.728-1.186-5.39-1.502zm4.656 16.241l6.296-2.275c.715-.258.826-.625.246-.818-.586-.192-1.637-.139-2.357.123l-4.205 1.5V14.98l.24-.085s1.201-.42 2.913-.615c1.696-.18 3.785.03 5.437.661 1.848.601 2.04 1.472 1.576 2.072-.465.6-1.622 1.036-1.622 1.036l-8.544 3.107V18.86zM1.807 18.6c-1.9-.545-2.214-1.668-1.352-2.32.801-.586 2.16-1.052 2.16-1.052l5.615-2.013v2.313L4.205 17c-.705.271-.825.632-.239.826.586.195 1.637.15 2.343-.12L8.247 17v2.074c-.12.03-.256.044-.39.073-1.939.331-3.996.196-6.038-.479z", + "h": "0070D1" + }, + "pocketcasts": { + "p": "M12,0C5.372,0,0,5.372,0,12c0,6.628,5.372,12,12,12c6.628,0,12-5.372,12-12 C24,5.372,18.628,0,12,0z M15.564,12c0-1.968-1.596-3.564-3.564-3.564c-1.968,0-3.564,1.595-3.564,3.564 c0,1.968,1.595,3.564,3.564,3.564V17.6c-3.093,0-5.6-2.507-5.6-5.6c0-3.093,2.507-5.6,5.6-5.6c3.093,0,5.6,2.507,5.6,5.6H15.564z M19,12c0-3.866-3.134-7-7-7c-3.866,0-7,3.134-7,7c0,3.866,3.134,7,7,7v2.333c-5.155,0-9.333-4.179-9.333-9.333 c0-5.155,4.179-9.333,9.333-9.333c5.155,0,9.333,4.179,9.333,9.333H19z", + "h": "F43E37" + }, + "proton": { + "p": "M2.474 17.75V24h4.401v-5.979c0-.582.232-1.14.645-1.551a2.204 2.204 0 0 1 1.556-.643h4.513a7.955 7.955 0 0 0 5.612-2.318 7.907 7.907 0 0 0 2.325-5.595 7.91 7.91 0 0 0-2.325-5.596A7.958 7.958 0 0 0 13.587 0H2.474v7.812h4.401V4.129h6.416c.995 0 1.951.394 2.656 1.097.704.7 1.1 1.653 1.101 2.646a3.742 3.742 0 0 1-1.101 2.648 3.766 3.766 0 0 1-2.656 1.097H8.627a6.158 6.158 0 0 0-4.352 1.795 6.133 6.133 0 0 0-1.801 4.338Z", + "h": "6D4AFF" + }, + "protondrive": { + "p": "M24 6.595v12.79c0 1.36-1.11 2.462-2.482 2.462h-1.62V9a2.925 2.925 0 0 0-2.93-2.914l-9.42.053a.943.943 0 0 1-.55-.172L4.905 4.493a2.918 2.918 0 0 0-1.694-.536H.1A2.47 2.47 0 0 1 2.482 2.15h4.657c.47 0 .928.148 1.305.424l1.559 1.134c.38.276.837.424 1.308.424h10.207A2.471 2.471 0 0 1 24 6.595zM18.897 9v12.85H2.482A2.471 2.471 0 0 1 0 19.387V4.957h3.21c.4 0 .792.122 1.118.353l2.095 1.476a1.94 1.94 0 0 0 1.13.353l9.402-.052A1.922 1.922 0 0 1 18.897 9z", + "h": "EB508D" + }, + "protonmail": { + "p": "m15.24 8.998 3.656-3.073v15.81H2.482C1.11 21.735 0 20.609 0 19.223V6.944l7.58 6.38a2.186 2.186 0 0 0 2.871-.042l4.792-4.284h-.003zm-5.456 3.538 1.809-1.616a2.438 2.438 0 0 1-1.178-.533L.905 2.395A.552.552 0 0 0 0 2.826v2.811l8.226 6.923a1.186 1.186 0 0 0 1.558-.024zM23.871 2.463a.551.551 0 0 0-.776-.068l-3.199 2.688v16.653h1.623c1.371 0 2.481-1.127 2.481-2.513V2.824a.551.551 0 0 0-.129-.36z", + "h": "6D4AFF" + }, + "protonvpn": { + "p": "m10.176 20.058.858-1.28 6.513-9.838c.57-.86.026-2.014-1.005-2.131L.378 4.95l8.373 15.055a.84.84 0 0 0 1.424.052h.001zM23.586 7.14l-9.662 14.61c-1.036 1.567-3.38 1.478-4.293-.162l-.093-.168c.3-.01.594-.086.855-.235a1.85 1.85 0 0 0 .612-.57l.86-1.28 6.516-9.844c.46-.694.525-1.56.173-2.314a2.375 2.375 0 0 0-1.899-1.364L.493 3.956l-.476-.054C-.163 2.392 1.101.95 2.784 1.143l18.991 2.16c1.856.21 2.835 2.289 1.812 3.838z", + "h": "66DEB1" + }, + "rakuten": { + "p": "M23.277 21.3L3.939 24 .722 21.3h22.555zM7.6 19.276H3.939V0h6.052a6.653 6.653 0 0 1 6.65 6.646c0 2.234-1.108 4.204-2.799 5.418l5.418 7.211h-4.585l-4.486-5.979H7.6v5.98zm0-9.64h2.392a2.992 2.992 0 0 0 2.989-2.989 2.994 2.994 0 0 0-2.989-2.986H7.6v5.975z", + "h": "BF0000" + }, + "revolut": { + "p": "M20.9133 6.9566C20.9133 3.1208 17.7898 0 13.9503 0H2.424v3.8605h10.9782c1.7376 0 3.177 1.3651 3.2087 3.043.016.84-.2994 1.633-.8878 2.2324-.5886.5998-1.375.9303-2.2144.9303H9.2322a.2756.2756 0 0 0-.2755.2752v3.431c0 .0585.018.1142.052.1612L16.2646 24h5.3114l-7.2727-10.094c3.6625-.1838 6.61-3.2612 6.61-6.9494zM6.8943 5.9229H2.424V24h4.4704z", + "h": "191C1F" + }, + "setapp": { + "p": "M13.0949 8.1332a.619.619 0 0 1 0-.874l2.7712-2.7733a.619.619 0 0 1 .877 0l2.7703 2.7722a.619.619 0 0 1 0 .8751l-2.7703 2.7722a.619.619 0 0 1-.877 0zm-1.5331-1.5331L8.7906 3.8299a.618.618 0 0 1 0-.877L11.5618.1815a.619.619 0 0 1 .876 0l2.7732 2.7712a.619.619 0 0 1 0 .877L12.4378 6.6a.619.619 0 0 1-.876 0zm0 2.1902a.619.619 0 0 1 .876 0l2.7732 2.7712a.619.619 0 0 1 0 .877l-2.7732 2.7712a.619.619 0 0 1-.876 0l-2.7712-2.7692a.618.618 0 0 1 0-.877zm-4.3044 2.1151L4.4862 8.1332a.619.619 0 0 1 0-.876l2.7712-2.7713a.619.619 0 0 1 .8761 0l2.7722 2.7712a.621.621 0 0 1 0 .8761l-2.7732 2.7722a.619.619 0 0 1-.876 0zm9.4847 2.1902 2.7723 2.7712a.618.618 0 0 1 0 .875l-2.7703 2.7723a.619.619 0 0 1-.876 0l-2.7732-2.7722a.621.621 0 0 1 0-.8751l2.7732-2.7722a.619.619 0 0 1 .875 0zm-4.3043 4.3033 2.7722 2.7722a.618.618 0 0 1 0 .876l-2.7722 2.7713a.619.619 0 0 1-.876 0l-2.7712-2.7712a.619.619 0 0 1 0-.877l2.7712-2.7713a.619.619 0 0 1 .876 0zm-1.532-1.5321a.619.619 0 0 1 0 .875l-2.7723 2.7733a.621.621 0 0 1-.876 0l-2.7723-2.7722a.619.619 0 0 1 0-.8751l2.7722-2.7722a.619.619 0 0 1 .8761 0z", + "h": "E6C3A5" + }, + "skillshare": { + "p": "M9.783 6.056a.768.768 0 0 0-.773.764c0 .421.346.763.773.763a.768.768 0 0 0 .772-.763.768.768 0 0 0-.772-.764zM1.895 8.1C.821 8.1.111 8.622.111 9.413c0 .634.381 1.06 1.048 1.225l.836.21c.248.078.348.2.347.39 0 .21-.21.327-.424.337-.31.014-.537-.154-.554-.422H0c.02.8.802 1.362 1.974 1.362 1.108 0 1.827-.513 1.827-1.382 0-.634-.399-1.034-1.057-1.208l-.81-.224c-.274-.081-.369-.202-.369-.372 0-.185.146-.294.335-.316.274-.032.486.087.486.382v.02H3.78v-.02h-.001c0-.834-.706-1.294-1.884-1.294zm2.485.116v4.19h1.318v-1.821l1.274 1.82h1.62l-1.629-2.201 1.604-1.977h-1.56l-1.309 1.76v-1.77zm4.744 0v4.19h1.318v-4.19zm2.084 0v4.191h3.218v-1.244h-1.892V8.217zm3.937 0v4.191h3.218v-1.244h-1.892V8.217zm-13.25 5.308c-1.074 0-1.784.522-1.784 1.312 0 .635.381 1.06 1.048 1.225l.836.21c.248.078.348.2.347.39 0 .21-.21.328-.424.338-.31.014-.537-.155-.554-.423H0c.02.8.802 1.362 1.974 1.362 1.108 0 1.827-.512 1.827-1.382 0-.634-.399-1.034-1.057-1.207l-.81-.225c-.274-.081-.369-.201-.369-.371 0-.186.146-.295.335-.317.274-.032.486.087.486.383v.019H3.78v-.02h-.001c0-.834-.706-1.294-1.884-1.294zm9.19.015c-1.215 0-1.986.953-1.986 2.202 0 1.257.72 2.202 1.968 2.201.58 0 1.1-.286 1.326-.702v.59h1.318v-4.179h-1.318v.599c-.225-.425-.702-.711-1.309-.711zm8.751 0c-1.36 0-2.253.832-2.253 2.202 0 1.396.875 2.202 2.296 2.202 1.11 0 1.951-.546 2.08-1.37h-1.3c-.113.26-.373.373-.78.373-.59 0-.954-.295-.98-.841h3.087c.026-.234.035-.364.035-.581 0-1.179-.884-1.985-2.185-1.985zm-2.87.043c-.51 0-1.005.32-1.152.945v-.876h-1.327v4.179h1.327v-1.613c0-.927.382-1.395 1.1-1.395a2.8 2.8 0 0 1 .393.025l.007-1.23a1.28 1.28 0 0 0-.347-.035zM4.38 13.65v4.191h1.3v-1.485h1.59v1.485h1.3V13.65h-1.3v1.505H5.68V13.65zm15.448.781c.564 0 .876.295.885.85H18.9c.008-.511.356-.85.927-.85zm-8.38.217c.66 0 .997.494.997 1.093 0 .607-.337 1.1-.997 1.1-.616 0-.997-.468-.997-1.1 0-.634.382-1.093.997-1.093zm11.78 1.741a.768.768 0 0 0-.772.764c0 .422.345.764.772.764a.768.768 0 0 0 .772-.764.768.768 0 0 0-.772-.764z", + "h": "00FF84" + }, + "sky": { + "p": "M7.387 13.656c0 1.423-.933 2.454-2.823 2.675-1.35.147-3.337-.025-4.294-.148-.025-.147-.074-.343-.074-.49 0-1.252.663-1.522 1.3-1.522.664 0 1.694.123 2.455.123.834 0 1.104-.295 1.104-.565 0-.368-.343-.515-1.006-.638l-1.767-.343C.785 12.453 0 11.423 0 10.343c0-1.325.933-2.454 2.798-2.65 1.398-.148 3.116.024 4.049.122.024.172.049.32.049.491 0 1.252-.663 1.522-1.276 1.522-.491 0-1.227-.099-2.086-.099-.884 0-1.227.246-1.227.54 0 .32.343.442.883.54l1.718.32c1.742.294 2.479 1.3 2.479 2.527m3.092 1.521c0 .761-.295 1.203-1.792 1.203-.196 0-.368-.025-.54-.05V6.22c0-.76.27-1.57 1.767-1.57.196 0 .393.024.565.049zm6.085 3.927c.197.098.59.22 1.105.245.859.025 1.325-.319 1.693-1.08L24 7.913a2.5 2.5 0 0 0-.957-.22c-.589 0-1.399.122-1.914 1.325l-1.497 3.534-2.945-4.81c-.196-.05-.662-.148-1.006-.148-1.03 0-1.62.393-2.233 1.031l-2.871 3.141 2.306 3.632c.418.663.982 1.006 1.89 1.006.589 0 1.104-.147 1.325-.245l-2.773-4.196 1.963-2.086 3.24 5.08Z", + "h": "0072C9" + }, + "soundcloud": { + "p": "M23.999 14.165c-.052 1.796-1.612 3.169-3.4 3.169h-8.18a.68.68 0 0 1-.675-.683V7.862a.747.747 0 0 1 .452-.724s.75-.513 2.333-.513a5.364 5.364 0 0 1 2.763.755 5.433 5.433 0 0 1 2.57 3.54c.282-.08.574-.121.868-.12.884 0 1.73.358 2.347.992s.948 1.49.922 2.373ZM10.721 8.421c.247 2.98.427 5.697 0 8.672a.264.264 0 0 1-.53 0c-.395-2.946-.22-5.718 0-8.672a.264.264 0 0 1 .53 0ZM9.072 9.448c.285 2.659.37 4.986-.006 7.655a.277.277 0 0 1-.55 0c-.331-2.63-.256-5.02 0-7.655a.277.277 0 0 1 .556 0Zm-1.663-.257c.27 2.726.39 5.171 0 7.904a.266.266 0 0 1-.532 0c-.38-2.69-.257-5.21 0-7.904a.266.266 0 0 1 .532 0Zm-1.647.77a26.108 26.108 0 0 1-.008 7.147.272.272 0 0 1-.542 0 27.955 27.955 0 0 1 0-7.147.275.275 0 0 1 .55 0Zm-1.67 1.769c.421 1.865.228 3.5-.029 5.388a.257.257 0 0 1-.514 0c-.21-1.858-.398-3.549 0-5.389a.272.272 0 0 1 .543 0Zm-1.655-.273c.388 1.897.26 3.508-.01 5.412-.026.28-.514.283-.54 0-.244-1.878-.347-3.54-.01-5.412a.283.283 0 0 1 .56 0Zm-1.668.911c.4 1.268.257 2.292-.026 3.572a.257.257 0 0 1-.514 0c-.241-1.262-.354-2.312-.023-3.572a.283.283 0 0 1 .563 0Z", + "h": "FF5500" + }, + "spotify": { + "p": "M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.66 0 12 0zm5.521 17.34c-.24.359-.66.48-1.021.24-2.82-1.74-6.36-2.101-10.561-1.141-.418.122-.779-.179-.899-.539-.12-.421.18-.78.54-.9 4.56-1.021 8.52-.6 11.64 1.32.42.18.479.659.301 1.02zm1.44-3.3c-.301.42-.841.6-1.262.3-3.239-1.98-8.159-2.58-11.939-1.38-.479.12-1.02-.12-1.14-.6-.12-.48.12-1.021.6-1.141C9.6 9.9 15 10.561 18.72 12.84c.361.181.54.78.241 1.2zm.12-3.36C15.24 8.4 8.82 8.16 5.16 9.301c-.6.179-1.2-.181-1.38-.721-.18-.601.18-1.2.72-1.381 4.26-1.26 11.28-1.02 15.721 1.621.539.3.719 1.02.419 1.56-.299.421-1.02.599-1.559.3z", + "h": "1ED760" + }, + "squarespace": { + "p": "M22.655 8.719c-1.802-1.801-4.726-1.801-6.564 0l-7.351 7.35c-.45.45-.45 1.2 0 1.65.45.449 1.2.449 1.65 0l7.351-7.351c.899-.899 2.362-.899 3.264 0 .9.9.9 2.364 0 3.264l-7.239 7.239c.9.899 2.362.899 3.263 0l5.589-5.589c1.836-1.838 1.836-4.763.037-6.563zm-2.475 2.437c-.451-.45-1.201-.45-1.65 0l-7.354 7.389c-.9.899-2.361.899-3.262 0-.45-.45-1.2-.45-1.65 0s-.45 1.2 0 1.649c1.801 1.801 4.726 1.801 6.564 0l7.351-7.35c.449-.487.449-1.239.001-1.688zm-2.439-7.35c-1.801-1.801-4.726-1.801-6.564 0l-7.351 7.351c-.45.449-.45 1.199 0 1.649s1.2.45 1.65 0l7.395-7.351c.9-.899 2.371-.899 3.27 0 .451.45 1.201.45 1.65 0 .421-.487.421-1.199-.029-1.649h-.021zm-2.475 2.437c-.45-.45-1.2-.45-1.65 0l-7.351 7.389c-.899.9-2.363.9-3.265 0-.9-.899-.9-2.363 0-3.264l7.239-7.239c-.9-.9-2.362-.9-3.263 0L1.35 8.719c-1.8 1.8-1.8 4.725 0 6.563 1.801 1.801 4.725 1.801 6.564 0l7.35-7.351c.451-.488.451-1.238 0-1.688h.002z", + "h": "000000" + }, + "strava": { + "p": "M15.387 17.944l-2.089-4.116h-3.065L15.387 24l5.15-10.172h-3.066m-7.008-5.599l2.836 5.598h4.172L10.463 0l-7 13.828h4.169", + "h": "FC4C02" + }, + "substack": { + "p": "M22.539 8.242H1.46V5.406h21.08v2.836zM1.46 10.812V24L12 18.11 22.54 24V10.812H1.46zM22.54 0H1.46v2.836h21.08V0z", + "h": "FF6719" + }, + "surfshark": { + "p": "M11.47 0C7.815.2 6.3 2.293 5.872 3.43c-1.615 4.866-3.127 14.325-3.33 15.662-.201 1.31-.228 2.119-.228 2.119 0 .328.026.705.102 1.059.454 1.286 1.792 2.37 4.768 1.287a192.353 192.353 0 0 0 9.533-4.44c1.387-.807 3.227-2.32 4.236-4.312.404-.807.682-1.716.733-2.65v-.452c-.026-2.295-.052-4.692-.204-7.013 0 0-.125-1.488-.2-2.017-.076-.53-.177-.733-.177-.733C20.626.906 19.693.38 18.71.126 18.23.026 17.7.024 17.095 0Zm4.692 4.44h.252c.277 0 .48.2.48.452V6.53c0 .252-.203.455-.48.455h-.252c-1.589 0-2.875 1.26-2.875 2.8v2.498c0 2.976-2.472 5.37-5.498 5.37h-.254c-.277 0-.478-.2-.478-.452v-1.64c0-.253.226-.454.478-.454h.254c1.589 0 2.875-1.262 2.875-2.8V9.81c0-2.977 2.472-5.373 5.498-5.373z", + "h": "1EBFBF" + }, + "telegram": { + "p": "M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z", + "h": "26A5E4" + }, + "tidal": { + "p": "M12.012 3.992L8.008 7.996 4.004 3.992 0 7.996 4.004 12l4.004-4.004L12.012 12l-4.004 4.004 4.004 4.004 4.004-4.004L12.012 12l4.004-4.004-4.004-4.004zM16.042 7.996l3.979-3.979L24 7.996l-3.979 3.979z", + "h": "000000" + }, + "tinder": { + "p": "M9.317 9.451c.045.073.123.12.212.12.06 0 .116-.021.158-.057l.015-.012c.39-.325.741-.66 1.071-1.017 3.209-3.483 1.335-7.759 1.32-7.799-.09-.21-.03-.459.15-.594.195-.135.435-.12.615.033 10.875 10.114 7.995 17.818 7.785 18.337-.87 3.141-4.335 5.414-8.444 5.53-.138.008-.242.008-.363.008-4.852 0-8.977-2.989-8.977-6.807v-.06c0-5.297 4.795-10.522 5.009-10.744.136-.149.345-.195.525-.105.18.076.297.255.291.451-.043 1.036.167 1.935.631 2.7v.015l.002.001z", + "h": "FF6B6B" + }, + "todoist": { + "p": "M21 0H3C1.35 0 0 1.35 0 3v3.858s3.854 2.24 4.098 2.38c.31.18.694.177 1.004 0 .26-.147 8.02-4.608 8.136-4.675.279-.161.58-.107.748-.01.164.097.606.348.84.48.232.134.221.502.013.622l-9.712 5.59c-.346.2-.69.204-1.048.002C3.478 10.907.998 9.463 0 8.882v2.02l4.098 2.38c.31.18.694.177 1.004 0 .26-.147 8.02-4.609 8.136-4.676.279-.16.58-.106.748-.008.164.096.606.347.84.48.232.133.221.5.013.62-.208.121-9.288 5.346-9.712 5.59-.346.2-.69.205-1.048.002C3.478 14.951.998 13.506 0 12.926v2.02l4.098 2.38c.31.18.694.177 1.004 0 .26-.147 8.02-4.609 8.136-4.676.279-.16.58-.106.748-.009.164.097.606.348.84.48.232.133.221.502.013.622l-9.712 5.59c-.346.199-.69.204-1.048.001C3.478 18.994.998 17.55 0 16.97V21c0 1.65 1.35 3 3 3h18c1.65 0 3-1.35 3-3V3c0-1.65-1.35-3-3-3z", + "h": "E44332" + }, + "tradingview": { + "p": "M15.8654 8.2789c0 1.3541-1.0978 2.4519-2.452 2.4519-1.354 0-2.4519-1.0978-2.4519-2.452 0-1.354 1.0978-2.4518 2.452-2.4518 1.3541 0 2.4519 1.0977 2.4519 2.4519zM9.75 6H0v4.9038h4.8462v7.2692H9.75Zm8.5962 0H24l-5.1058 12.173h-5.6538z", + "h": "131622" + }, + "twitch": { + "p": "M11.571 4.714h1.715v5.143H11.57zm4.715 0H18v5.143h-1.714zM6 0L1.714 4.286v15.428h5.143V24l4.286-4.286h3.428L22.286 12V0zm14.571 11.143l-3.428 3.428h-3.429l-3 3v-3H6.857V1.714h13.714Z", + "h": "9146FF" + }, + "uber": { + "p": "M0 7.97v4.958c0 1.867 1.302 3.101 3 3.101.826 0 1.562-.316 2.094-.87v.736H6.27V7.97H5.082v4.888c0 1.257-.85 2.106-1.947 2.106-1.11 0-1.946-.827-1.946-2.106V7.971H0zm7.44 0v7.925h1.13v-.725c.521.532 1.257.86 2.06.86a3.006 3.006 0 0 0 3.034-3.01 3.01 3.01 0 0 0-3.033-3.024 2.86 2.86 0 0 0-2.049.861V7.971H7.439zm9.869 2.038c-1.687 0-2.965 1.37-2.965 3 0 1.72 1.334 3.01 3.066 3.01 1.053 0 1.913-.463 2.49-1.233l-.826-.611c-.43.577-.996.847-1.664.847-.973 0-1.753-.7-1.912-1.64h4.697v-.373c0-1.72-1.222-3-2.886-3zm6.295.068c-.634 0-1.098.294-1.381.758v-.713h-1.131v5.774h1.142V12.61c0-.894.544-1.47 1.291-1.47H24v-1.065h-.396zm-6.319.928c.85 0 1.564.588 1.756 1.47H15.52c.203-.882.916-1.47 1.765-1.47zm-6.732.012c1.086 0 1.98.883 1.98 2.004a1.993 1.993 0 0 1-1.98 2.001A1.989 1.989 0 0 1 8.56 13.02a1.99 1.99 0 0 1 1.992-2.004z", + "h": "000000" + }, + "ubisoft": { + "p": "M23.561 11.988C23.301-.304 6.954-4.89.656 6.634c.282.206.661.477.943.672a11.747 11.747 0 00-.976 3.067 11.885 11.885 0 00-.184 2.071C.439 18.818 5.621 24 12.005 24c6.385 0 11.556-5.17 11.556-11.556v-.455zm-20.27 2.06c-.152 1.246-.054 1.636-.054 1.788l-.282.098c-.108-.206-.37-.932-.488-1.908C2.163 10.308 4.7 6.96 8.57 6.33c3.544-.52 6.937 1.68 7.728 4.758l-.282.098c-.087-.087-.228-.336-.77-.878-4.281-4.281-11.002-2.32-11.956 3.74zm11.002 2.081a3.145 3.145 0 01-2.59 1.355 3.15 3.15 0 01-3.155-3.155 3.159 3.159 0 012.927-3.144c1.018-.043 1.972.51 2.416 1.398a2.58 2.58 0 01-.455 2.95c.293.205.575.4.856.595zm6.58.12c-1.669 3.782-5.106 5.766-8.77 5.712-7.034-.347-9.083-8.466-4.38-11.393l.207.206c-.076.108-.358.325-.791 1.182-.51 1.041-.672 2.081-.607 2.732.369 5.67 8.314 6.83 11.045 1.214C21.057 8.217 11.822.401 3.626 6.374l-.184-.184C5.599 2.808 9.816 1.3 13.837 2.309c6.147 1.55 9.453 7.956 7.035 13.94z", + "h": "000000" + }, + "udemy": { + "p": "M12 0L5.81 3.573v3.574l6.189-3.574 6.191 3.574V3.573zM5.81 10.148v8.144c0 1.85.589 3.243 1.741 4.234S10.177 24 11.973 24s3.269-.482 4.448-1.474c1.179-.991 1.768-2.439 1.768-4.314v-8.064h-3.242v7.85c0 2.036-1.509 3.055-2.948 3.055-1.428 0-2.947-.991-2.947-3.027v-7.878z", + "h": "A435F0" + }, + "vimeo": { + "p": "M23.9765 6.4168c-.105 2.338-1.739 5.5429-4.894 9.6088-3.2679 4.247-6.0258 6.3699-8.2898 6.3699-1.409 0-2.578-1.294-3.553-3.881l-1.9179-7.1138c-.719-2.584-1.488-3.878-2.312-3.878-.179 0-.806.378-1.8809 1.132l-1.129-1.457a315.06 315.06 0 003.501-3.1279c1.579-1.368 2.765-2.085 3.5539-2.159 1.867-.18 3.016 1.1 3.447 3.838.465 2.953.789 4.789.971 5.5069.5389 2.45 1.1309 3.674 1.7759 3.674.502 0 1.256-.796 2.265-2.385 1.004-1.589 1.54-2.797 1.612-3.628.144-1.371-.395-2.061-1.614-2.061-.574 0-1.167.121-1.777.391 1.186-3.8679 3.434-5.7568 6.7619-5.6368 2.4729.06 3.6279 1.664 3.4929 4.7969z", + "h": "1AB7EA" + }, + "vodafone": { + "p": "M12 0A12 12 0 0 0 0 12A12 12 0 0 0 12 24A12 12 0 0 0 24 12A12 12 0 0 0 12 0M16.25 1.12C16.57 1.12 16.9 1.15 17.11 1.22C14.94 1.67 13.21 3.69 13.22 6C13.22 6.05 13.22 6.11 13.23 6.17C16.87 7.06 18.5 9.25 18.5 12.28C18.54 15.31 16.14 18.64 12.09 18.65C8.82 18.66 5.41 15.86 5.39 11.37C5.38 8.4 7 5.54 9.04 3.85C11.04 2.19 13.77 1.13 16.25 1.12Z", + "h": "E60000" + }, + "wix": { + "p": "m0 7.354 2.113 9.292h.801a1.54 1.54 0 0 0 1.506-1.218l1.351-6.34a.171.171 0 0 1 .167-.137c.08 0 .15.058.167.137l1.352 6.34a1.54 1.54 0 0 0 1.506 1.218h.805l2.113-9.292h-.565c-.62 0-1.159.43-1.296 1.035l-1.26 5.545-1.106-5.176a1.76 1.76 0 0 0-2.19-1.324c-.639.176-1.113.716-1.251 1.365l-1.094 5.127-1.26-5.537A1.33 1.33 0 0 0 .563 7.354H0zm13.992 0a.951.951 0 0 0-.951.95v8.342h.635a.952.952 0 0 0 .951-.95V7.353h-.635zm1.778 0 3.158 4.66-3.14 4.632h1.325c.368 0 .712-.181.918-.486l1.756-2.59a.12.12 0 0 1 .197 0l1.754 2.59c.206.305.55.486.918.486h1.326l-3.14-4.632L24 7.354h-1.326c-.368 0-.712.181-.918.486l-1.772 2.617a.12.12 0 0 1-.197 0L18.014 7.84a1.108 1.108 0 0 0-.918-.486H15.77z", + "h": "0C6EFC" + }, + "wordpress": { + "p": "M21.469 6.825c.84 1.537 1.318 3.3 1.318 5.175 0 3.979-2.156 7.456-5.363 9.325l3.295-9.527c.615-1.54.82-2.771.82-3.864 0-.405-.026-.78-.07-1.11m-7.981.105c.647-.03 1.232-.105 1.232-.105.582-.075.514-.93-.067-.899 0 0-1.755.135-2.88.135-1.064 0-2.85-.15-2.85-.15-.585-.03-.661.855-.075.885 0 0 .54.061 1.125.09l1.68 4.605-2.37 7.08L5.354 6.9c.649-.03 1.234-.1 1.234-.1.585-.075.516-.93-.065-.896 0 0-1.746.138-2.874.138-.2 0-.438-.008-.69-.015C4.911 3.15 8.235 1.215 12 1.215c2.809 0 5.365 1.072 7.286 2.833-.046-.003-.091-.009-.141-.009-1.06 0-1.812.923-1.812 1.914 0 .89.513 1.643 1.06 2.531.411.72.89 1.643.89 2.977 0 .915-.354 1.994-.821 3.479l-1.075 3.585-3.9-11.61.001.014zM12 22.784c-1.059 0-2.081-.153-3.048-.437l3.237-9.406 3.315 9.087c.024.053.05.101.078.149-1.12.393-2.325.609-3.582.609M1.211 12c0-1.564.336-3.05.935-4.39L7.29 21.709C3.694 19.96 1.212 16.271 1.211 12M12 0C5.385 0 0 5.385 0 12s5.385 12 12 12 12-5.385 12-12S18.615 0 12 0", + "h": "21759B" + }, + "x": { + "p": "M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z", + "h": "000000" + }, + "youtube": { + "p": "M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z", + "h": "FF0000" + }, + "youtubemusic": { + "p": "M12 0C5.376 0 0 5.376 0 12s5.376 12 12 12 12-5.376 12-12S18.624 0 12 0zm0 19.104c-3.924 0-7.104-3.18-7.104-7.104S8.076 4.896 12 4.896s7.104 3.18 7.104 7.104-3.18 7.104-7.104 7.104zm0-13.332c-3.432 0-6.228 2.796-6.228 6.228S8.568 18.228 12 18.228s6.228-2.796 6.228-6.228S15.432 5.772 12 5.772zM9.684 15.54V8.46L15.816 12l-6.132 3.54z", + "h": "FF0000" + }, + "zoom": { + "p": "M5.033 14.649H.743a.74.74 0 0 1-.686-.458.74.74 0 0 1 .16-.808L3.19 10.41H1.06A1.06 1.06 0 0 1 0 9.35h3.957c.301 0 .57.18.686.458a.74.74 0 0 1-.161.808L1.51 13.59h2.464c.585 0 1.06.475 1.06 1.06zM24 11.338c0-1.14-.927-2.066-2.066-2.066-.61 0-1.158.265-1.537.686a2.061 2.061 0 0 0-1.536-.686c-1.14 0-2.066.926-2.066 2.066v3.311a1.06 1.06 0 0 0 1.06-1.06v-2.251a1.004 1.004 0 0 1 2.013 0v2.251c0 .586.474 1.06 1.06 1.06v-3.311a1.004 1.004 0 0 1 2.012 0v2.251c0 .586.475 1.06 1.06 1.06zM16.265 12a2.728 2.728 0 1 1-5.457 0 2.728 2.728 0 0 1 5.457 0zm-1.06 0a1.669 1.669 0 1 0-3.338 0 1.669 1.669 0 0 0 3.338 0zm-4.82 0a2.728 2.728 0 1 1-5.458 0 2.728 2.728 0 0 1 5.457 0zm-1.06 0a1.669 1.669 0 1 0-3.338 0 1.669 1.669 0 0 0 3.338 0z", + "h": "0B5CFF" + } +}; +})(typeof self !== 'undefined' ? self : globalThis); diff --git a/js/core/ics.js b/js/core/ics.js new file mode 100644 index 0000000..e342feb --- /dev/null +++ b/js/core/ics.js @@ -0,0 +1,108 @@ +/* + * iCalendar (.ics, RFC 5545) export: one repeating all-day event per active + * subscription, with an alarm at 09:00 on the reminder day. Calendar apps on + * the phone then fire the reminder reliably, even with the web app closed. + */ +(function (g) { + 'use strict'; + const ST = (g.ST = g.ST || {}); + + function esc(s) { + return String(s).replace(/\\/g, '\\\\').replace(/;/g, '\;').replace(/,/g, '\\,') + .replace(/\r?\n/g, '\\n'); + } + + /** Folds lines longer than 75 octets (RFC 5545 Β§3.1). */ + function fold(line) { + const bytes = new TextEncoder().encode(line); + if (bytes.length <= 75) return line; + const out = []; + let cur = ''; + let len = 0; + for (const ch of line) { + const n = new TextEncoder().encode(ch).length; + if (len + n > (out.length ? 74 : 75)) { + out.push(cur); + cur = ''; + len = 0; + } + cur += ch; + len += n; + } + out.push(cur); + return out.join('\r\n '); + } + + function ymd(d) { + return ST.schedule.toISO(d).replace(/-/g, ''); + } + + function stamp(d) { + return d.toISOString().replace(/[-:]/g, '').replace(/\.\d{3}/, ''); + } + + /** RRULE that keeps month-end dates correct (e.g. the 31st -> last day). */ + function rrule(freq, start) { + const map = { day: 'DAILY', week: 'WEEKLY', month: 'MONTHLY', year: 'YEARLY' }; + let r = `RRULE:FREQ=${map[freq.unit]};INTERVAL=${freq.every}`; + const day = start.getDate(); + if ((freq.unit === 'month' || freq.unit === 'year') && day > 28) { + const days = []; + for (let d = 28; d <= day; d++) days.push(d); + if (freq.unit === 'year') r += `;BYMONTH=${start.getMonth() + 1}`; + r += `;BYMONTHDAY=${days.join(',')};BYSETPOS=-1`; + } + return r; + } + + function alarm(reminder, description) { + // All-day events start at 00:00; fire at 09:00 local on the reminder day. + const hours = reminder * 24 - 9; + const trigger = hours > 0 ? `-PT${hours}H` : `PT${-hours}H`; + return [ + 'BEGIN:VALARM', + 'ACTION:DISPLAY', + `DESCRIPTION:${esc(description)}`, + `TRIGGER:${trigger}`, + 'END:VALARM', + ]; + } + + function build(subs, now) { + const { schedule, i18n } = ST; + const dtstamp = stamp(now || new Date()); + const lines = [ + 'BEGIN:VCALENDAR', + 'VERSION:2.0', + 'PRODID:-//SubTrack//Subscription Tracker//EN', + 'CALSCALE:GREGORIAN', + 'METHOD:PUBLISH', + 'X-WR-CALNAME:SubTrack', + ]; + for (const sub of subs) { + if (!sub.active) continue; + const start = schedule.parseISO(sub.startDate); + if (!start) continue; + const price = i18n.fmtMoney(sub.price, sub.currency); + const summary = `${sub.name} Β· ${price}`; + lines.push( + 'BEGIN:VEVENT', + `UID:${sub.id}@subtrack`, + `DTSTAMP:${dtstamp}`, + `DTSTART;VALUE=DATE:${ymd(start)}`, + `DTEND;VALUE=DATE:${ymd(schedule.addDays(start, 1))}`, + rrule(sub.freq, start), + `SUMMARY:${esc(summary)}`, + 'TRANSP:TRANSPARENT', + ); + const desc = [i18n.freqLabel(sub.freq), sub.notes].filter(Boolean).join('\n'); + if (desc) lines.push(`DESCRIPTION:${esc(desc)}`); + if (sub.reminder >= 0) lines.push(...alarm(sub.reminder, summary)); + lines.push('END:VEVENT'); + } + lines.push('END:VCALENDAR'); + return lines.map(fold).join('\r\n') + '\r\n'; + } + + ST.ics = { build, rrule, fold, esc }; +})(typeof self !== 'undefined' ? self : globalThis); diff --git a/js/core/reminders.js b/js/core/reminders.js new file mode 100644 index 0000000..5407358 --- /dev/null +++ b/js/core/reminders.js @@ -0,0 +1,79 @@ +/* + * Local renewal reminders. Runs both in the page (on open / when it becomes + * visible) and in the service worker (Periodic Background Sync, where + * supported). No server and no push service are involved. + * + * Each renewal is notified at most once: sent reminders are remembered in the + * "notified" setting as { "|": "" }. + */ +(function (g) { + 'use strict'; + const ST = (g.ST = g.ST || {}); + + function permission() { + return typeof g.Notification !== 'undefined' ? g.Notification.permission : 'unsupported'; + } + + /** Renewals that should be announced today. Pure, exported for tests. */ + function due(subs, today, notified) { + const { schedule } = ST; + const out = []; + for (const sub of subs) { + if (!sub.active || !(sub.reminder >= 0)) continue; + const next = schedule.nextRenewal(sub.startDate, sub.freq, today); + if (!next) continue; + const days = schedule.diffDays(today, next); + const key = `${sub.id}|${schedule.toISO(next)}`; + if (days <= sub.reminder && !notified[key]) out.push({ sub, next, days, key }); + } + return out; + } + + function text(item) { + const { t, fmtMoney, fmtDate } = ST.i18n; + const when = item.days === 0 ? t('notif.today') + : item.days === 1 ? t('notif.tomorrow') + : t('notif.inDays', { n: item.days }); + return { + title: t('notif.title', { name: item.sub.name, when }), + body: `${fmtMoney(item.sub.price, item.sub.currency)} Β· ${fmtDate(item.next, { weekday: 'long', day: 'numeric', month: 'long' })}`, + }; + } + + /** + * Shows due notifications through the given ServiceWorkerRegistration. + * Returns the number of notifications shown. + */ + async function check(registration) { + const { db, schedule, i18n } = ST; + if (!registration || permission() !== 'granted') return 0; + const settings = await db.getSettings(); + if (!settings.notifications) return 0; + i18n.setLang(settings.lang); + + const today = schedule.today(); + const notified = {}; + // Forget renewals older than a week to keep the map small. + const cutoff = schedule.toISO(schedule.addDays(today, -7)); + for (const [k, v] of Object.entries(settings.notified || {})) { + if (v >= cutoff) notified[k] = v; + } + + const items = due(await db.getAll(), today, notified); + for (const item of items) { + const { title, body } = text(item); + await registration.showNotification(title, { + body, + tag: item.key, + icon: 'icons/icon-192.png', + badge: 'icons/badge-96.png', + data: { url: './' }, + }); + notified[item.key] = schedule.toISO(item.next); + } + await db.setSetting('notified', notified); + return items.length; + } + + ST.reminders = { permission, due, text, check }; +})(typeof self !== 'undefined' ? self : globalThis); diff --git a/js/core/schedule.js b/js/core/schedule.js new file mode 100644 index 0000000..2c576ce --- /dev/null +++ b/js/core/schedule.js @@ -0,0 +1,163 @@ +/* + * Billing-date maths. Pure functions, no DOM, usable from the page, the + * service worker and Node tests. + * + * Dates are handled as local calendar days ("YYYY-MM-DD" strings) so that + * time zones and DST never shift a renewal to the wrong day. + */ +(function (g) { + 'use strict'; + const ST = (g.ST = g.ST || {}); + + const UNITS = ['day', 'week', 'month', 'year']; + const PRESETS = { + weekly: { every: 1, unit: 'week' }, + monthly: { every: 1, unit: 'month' }, + quarterly: { every: 3, unit: 'month' }, + semiannual: { every: 6, unit: 'month' }, + yearly: { every: 1, unit: 'year' }, + }; + const AVG_DAYS_PER_MONTH = 365.2425 / 12; + + function pad(n) { + return String(n).padStart(2, '0'); + } + + function toISO(d) { + return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`; + } + + function parseISO(s) { + const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s || ''); + if (!m) return null; + const d = new Date(+m[1], +m[2] - 1, +m[3]); + return d.getMonth() === +m[2] - 1 ? d : null; + } + + function today() { + const n = new Date(); + return new Date(n.getFullYear(), n.getMonth(), n.getDate()); + } + + function daysInMonth(year, month) { + return new Date(year, month + 1, 0).getDate(); + } + + /** Adds whole months, clamping to the last day (Jan 31 + 1 month = Feb 28/29). */ + function addMonths(date, months) { + const total = date.getFullYear() * 12 + date.getMonth() + months; + const y = Math.floor(total / 12); + const m = total - y * 12; + return new Date(y, m, Math.min(date.getDate(), daysInMonth(y, m))); + } + + function addDays(date, days) { + return new Date(date.getFullYear(), date.getMonth(), date.getDate() + days); + } + + /** The k-th billing date after `start` (k = 0 is the start itself). */ + function nthOccurrence(start, freq, k) { + const n = freq.every * k; + switch (freq.unit) { + case 'day': return addDays(start, n); + case 'week': return addDays(start, n * 7); + case 'month': return addMonths(start, n); + case 'year': return addMonths(start, n * 12); + default: throw new Error(`Unknown unit: ${freq.unit}`); + } + } + + function diffDays(a, b) { + // Round to absorb DST hour shifts between two local midnights. + return Math.round((b - a) / 86400000); + } + + function isValidFreq(freq) { + return !!freq && UNITS.includes(freq.unit) && + Number.isInteger(freq.every) && freq.every >= 1 && freq.every <= 999; + } + + /** + * First billing date on or after `from` (defaults to today). + * Returns a Date or null for invalid input. + */ + function nextRenewal(startISO, freq, from) { + const r = nextWithIndex(startISO, freq, from); + return r ? r.date : null; + } + + function nextWithIndex(startISO, freq, from) { + const start = parseISO(startISO); + if (!start || !isValidFreq(freq)) return null; + const ref = from || today(); + if (start >= ref) return { date: start, k: 0, start }; + + // Estimate k from elapsed days, then correct (months have uneven length). + const periodDays = { + day: freq.every, + week: freq.every * 7, + month: freq.every * AVG_DAYS_PER_MONTH, + year: freq.every * 365.2425, + }[freq.unit]; + let k = Math.max(0, Math.floor(diffDays(start, ref) / periodDays) - 1); + let d = nthOccurrence(start, freq, k); + while (d < ref) d = nthOccurrence(start, freq, ++k); + return { date: d, k, start }; + } + + /** Billing date immediately before `next` (or null if that's the start). */ + function previousRenewal(startISO, freq, from) { + const r = nextWithIndex(startISO, freq, from); + if (!r || r.k === 0) return null; + return nthOccurrence(r.start, freq, r.k - 1); + } + + /** All billing dates within [from, to] inclusive. */ + function occurrencesBetween(startISO, freq, from, to) { + const r = nextWithIndex(startISO, freq, from); + const out = []; + if (!r) return out; + // Each date is computed from the start (no cumulative month-end drift). + for (let k = r.k, d = r.date; d <= to; d = nthOccurrence(r.start, freq, ++k)) { + out.push(d); + } + return out; + } + + /** Normalises a price to its average monthly cost. */ + function monthlyCost(price, freq) { + if (!isValidFreq(freq) || !Number.isFinite(price)) return 0; + switch (freq.unit) { + case 'day': return (price * AVG_DAYS_PER_MONTH) / freq.every; + case 'week': return (price * AVG_DAYS_PER_MONTH) / (7 * freq.every); + case 'month': return price / freq.every; + case 'year': return price / (12 * freq.every); + default: return 0; + } + } + + function presetOf(freq) { + for (const [name, p] of Object.entries(PRESETS)) { + if (p.every === freq.every && p.unit === freq.unit) return name; + } + return 'custom'; + } + + ST.schedule = { + UNITS, + PRESETS, + toISO, + parseISO, + today, + addDays, + addMonths, + diffDays, + isValidFreq, + nthOccurrence, + nextRenewal, + previousRenewal, + occurrencesBetween, + monthlyCost, + presetOf, + }; +})(typeof self !== 'undefined' ? self : globalThis); diff --git a/js/core/version.js b/js/core/version.js new file mode 100644 index 0000000..e4d530b --- /dev/null +++ b/js/core/version.js @@ -0,0 +1,7 @@ +/* Bump on every release: it also renames the offline cache in sw.js. */ +(function (g) { + 'use strict'; + const ST = (g.ST = g.ST || {}); + ST.VERSION = '1.0.0'; + ST.REPO_URL = 'https://github.com/lestolo/subscription-tracker'; +})(typeof self !== 'undefined' ? self : globalThis); diff --git a/js/install.js b/js/install.js new file mode 100644 index 0000000..bc42355 --- /dev/null +++ b/js/install.js @@ -0,0 +1,178 @@ +/* + * "Add to Home Screen" coaching. + * + * - Chromium (Android/desktop): captures `beforeinstallprompt` and offers a + * one-tap Install button. + * - iOS / iPadOS: there is no install API, so an animated bubble points at the + * Share button and explains the three steps. + * The bubble is non-modal so the user can tap the browser UI while it's open. + */ +(function (g) { + 'use strict'; + const ST = (g.ST = g.ST || {}); + const DISMISS_KEY = 'subtrack:install-dismissed'; + const SNOOZE_DAYS = 7; + const SHOW_DELAY = 2500; + + let deferred = null; + let bubble = null; + let scheduled = false; + + const ua = navigator.userAgent; + const isIPad = /iPad/.test(ua) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1); + const isIOS = /iPhone|iPod/.test(ua) || isIPad; + + function isStandalone() { + return g.matchMedia('(display-mode: standalone)').matches || navigator.standalone === true; + } + + function snoozed() { + try { + const at = Number(localStorage.getItem(DISMISS_KEY)); + return at && Date.now() - at < SNOOZE_DAYS * 86400000; + } catch { + return false; + } + } + + function snooze() { + try { localStorage.setItem(DISMISS_KEY, String(Date.now())); } catch { /* storage unavailable */ } + } + + function available() { + return !isStandalone() && (!!deferred || isIOS); + } + + function maybeShow() { + if (scheduled || bubble || !available() || snoozed()) return; + scheduled = true; + setTimeout(() => { + // Don't cover an open sheet; try again later in the session. + if (document.documentElement.classList.contains('sheet-open')) { + scheduled = false; + setTimeout(maybeShow, SHOW_DELAY); + return; + } + show(); + }, SHOW_DELAY); + } + + function phoneAnimation() { + const { h } = ST.ui; + const dots = []; + for (let i = 0; i < 11; i++) dots.push(h('span', { class: 'app-dot' })); + return h('div', { class: 'install-anim', 'aria-hidden': 'true' }, + h('div', { class: 'phone' }, + h('div', { class: 'phone-notch' }), + h('div', { class: 'phone-grid' }, dots, h('span', { class: 'app-slot' }))), + h('img', { class: 'fly-icon', src: 'icons/icon.svg', alt: '', width: 40, height: 40 })); + } + + function stepText(key) { + const { t, h, icon } = { t: ST.i18n.t, h: ST.ui.h, icon: ST.ui.icon }; + const parts = t(key).split('{icon}'); + return h('span', null, parts[0], parts.length > 1 ? icon('share', 'inline') : null, parts[1] || null); + } + + function show(force) { + const { h, icon } = ST.ui; + const { t } = ST.i18n; + if (bubble) return; + const mode = deferred ? 'prompt' : isIOS ? (isIPad ? 'ipad' : 'ios') : 'generic'; + + const close = h('button', { class: 'icon-btn bubble-close', type: 'button', 'aria-label': t('nav.close') }, icon('close')); + let content; + let actions; + if (mode === 'prompt') { + content = h('p', { text: t('install.text') }); + const install = h('button', { class: 'btn btn-primary', type: 'button', text: t('install.cta') }); + const later = h('button', { class: 'btn btn-ghost', type: 'button', text: t('install.later') }); + install.addEventListener('click', promptInstall); + later.addEventListener('click', () => hide(true)); + actions = h('div', { class: 'btn-row' }, later, install); + } else if (mode === 'generic') { + content = h('div', null, h('p', { text: t('install.text') }), h('p', { class: 'muted', text: t('install.generic') })); + const ok = h('button', { class: 'btn btn-primary', type: 'button', text: t('install.gotIt') }); + ok.addEventListener('click', () => hide(true)); + actions = h('div', { class: 'btn-row' }, ok); + } else { + content = h('div', null, + h('p', { text: t('install.text') }), + h('ol', { class: 'install-steps' }, + h('li', null, h('span', { class: 'step-n', text: '1' }), stepText('install.ios1')), + h('li', null, h('span', { class: 'step-n', text: '2' }), h('span', null, icon('squarePlus', 'inline'), ' ', t('install.ios2'))), + h('li', null, h('span', { class: 'step-n', text: '3' }), h('span', { text: t('install.ios3') })))); + const ok = h('button', { class: 'btn btn-primary', type: 'button', text: t('install.gotIt') }); + ok.addEventListener('click', () => hide(true)); + actions = h('div', { class: 'btn-row' }, ok); + } + + bubble = h('div', { + class: `install-bubble mode-${mode}`, + role: 'dialog', + 'aria-modal': 'false', + 'aria-labelledby': 'install-title', + }, + close, + h('div', { class: 'install-top' }, + phoneAnimation(), + h('h3', { id: 'install-title', text: t('install.title') })), + content, + actions, + mode === 'ios' || mode === 'ipad' ? h('div', { class: 'bubble-pointer' }, icon('back')) : null); + + close.addEventListener('click', () => hide(true)); + document.body.append(bubble); + requestAnimationFrame(() => requestAnimationFrame(() => bubble && bubble.classList.add('show'))); + if (force) bubble.querySelector('.btn').focus(); + } + + function hide(userDismissed) { + if (!bubble) return; + if (userDismissed) snooze(); + const el = bubble; + bubble = null; + el.classList.remove('show'); + setTimeout(() => el.remove(), 350); + } + + async function promptInstall() { + if (!deferred) return; + const ev = deferred; + deferred = null; + hide(false); + ev.prompt(); + try { + const { outcome } = await ev.userChoice; + if (outcome !== 'accepted') snooze(); + } catch { /* ignored */ } + } + + function init() { + g.addEventListener('beforeinstallprompt', (e) => { + e.preventDefault(); + deferred = e; + if (ST.app) ST.app.refreshInstallState(); + maybeShow(); + }); + g.addEventListener('appinstalled', () => { + deferred = null; + hide(false); + ST.ui.toast(ST.i18n.t('install.done')); + if (ST.app) ST.app.refreshInstallState(); + }); + maybeShow(); + } + + ST.install = { + init, + isIOS, + isStandalone, + available, + /** Opens the install UI on demand (e.g. from Settings). */ + open() { + if (deferred) promptInstall(); + else show(true); + }, + }; +})(window); diff --git a/js/ui.js b/js/ui.js new file mode 100644 index 0000000..a41aae6 --- /dev/null +++ b/js/ui.js @@ -0,0 +1,268 @@ +/* + * Small UI toolkit: safe DOM builder, logos, bottom sheets, toasts. + * User-provided text is only ever inserted with textContent. + */ +(function (g) { + 'use strict'; + const ST = (g.ST = g.ST || {}); + const SVG_NS = 'http://www.w3.org/2000/svg'; + const reducedMotion = g.matchMedia('(prefers-reduced-motion: reduce)'); + + function h(tag, props, ...children) { + const el = document.createElement(tag); + if (props) { + for (const [k, v] of Object.entries(props)) { + if (v == null || v === false) continue; + if (k === 'class') el.className = v; + else if (k === 'text') el.textContent = v; + else if (k === 'on') for (const [ev, fn] of Object.entries(v)) el.addEventListener(ev, fn); + else if (k === 'style') for (const [p, val] of Object.entries(v)) el.style.setProperty(p, val); + else if (k === 'dataset') Object.assign(el.dataset, v); + else if (k in el && typeof v !== 'string') el[k] = v; + else el.setAttribute(k, v === true ? '' : v); + } + } + append(el, children); + return el; + } + + function append(el, children) { + for (const c of children.flat(Infinity)) { + if (c == null || c === false) continue; + el.append(c instanceof Node ? c : document.createTextNode(String(c))); + } + return el; + } + + // Stroke icons (24x24, Feather-style geometry). + const ICONS = { + plus: ['M12 5v14', 'M5 12h14'], + close: ['M18 6 6 18', 'M6 6l12 12'], + back: ['M15 18l-6-6 6-6'], + search: ['M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14Z', 'M21 21l-4.35-4.35'], + calendar: ['M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Z', 'M16 2v4', 'M8 2v4', 'M3 10h18'], + bell: ['M18 8a6 6 0 1 0-12 0c0 7-3 9-3 9h18s-3-2-3-9', 'M13.73 21a2 2 0 0 1-3.46 0'], + trash: ['M3 6h18', 'M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2', 'M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6'], + download: ['M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4', 'M7 10l5 5 5-5', 'M12 15V3'], + upload: ['M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4', 'M17 8l-5-5-5 5', 'M12 3v12'], + share: ['M4 12v7a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7', 'M16 6l-4-4-4 4', 'M12 2v13'], + squarePlus: ['M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Z', 'M12 8v8', 'M8 12h8'], + phone: ['M7 2h10a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2Z', 'M11 18h2'], + code: ['M16 18l6-6-6-6', 'M8 6l-6 6 6 6'], + shield: ['M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z'], + chevron: ['M9 18l6-6-6-6'], + }; + + function icon(name, cls) { + const svg = document.createElementNS(SVG_NS, 'svg'); + svg.setAttribute('viewBox', '0 0 24 24'); + svg.setAttribute('aria-hidden', 'true'); + svg.setAttribute('class', `i ${cls || ''}`.trim()); + for (const d of ICONS[name] || []) { + const p = document.createElementNS(SVG_NS, 'path'); + p.setAttribute('d', d); + svg.append(p); + } + return svg; + } + + // ---------- Logos ---------- + + function brandColor(item) { + const ic = item.icon && ST.icons[item.icon]; + return (ic && ic.h) || item.color; + } + + function isLight(hex) { + const n = parseInt(hex, 16); + const [r, gr, b] = [(n >> 16) & 255, (n >> 8) & 255, n & 255].map((c) => { + const s = c / 255; + return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4; + }); + return 0.2126 * r + 0.7152 * gr + 0.0722 * b > 0.45; + } + + function initials(name) { + const words = String(name).replace(/[^\p{L}\p{N}\s]/gu, ' ').trim().split(/\s+/).filter(Boolean); + if (!words.length) return '?'; + if (words.length === 1) return Array.from(words[0]).slice(0, 2).join('').toUpperCase(); + return (Array.from(words[0])[0] + Array.from(words[1])[0]).toUpperCase(); + } + + /** Logo tile for a subscription or catalogue item. */ + function logo(entity, size) { + const item = entity.catalogId ? ST.catalog.get(entity.catalogId) : (entity.icon !== undefined ? entity : null); + const color = (entity.color || (item && brandColor(item)) || '6B7280').replace('#', ''); + const tile = h('div', { + class: `logo${size ? ` logo-${size}` : ''}${isLight(color) ? ' is-light' : ''}`, + style: { '--brand': `#${color}` }, + 'aria-hidden': 'true', + }); + const ic = item && item.icon && ST.icons[item.icon]; + if (ic) { + const svg = document.createElementNS(SVG_NS, 'svg'); + svg.setAttribute('viewBox', '0 0 24 24'); + const p = document.createElementNS(SVG_NS, 'path'); + p.setAttribute('d', ic.p); + svg.append(p); + tile.append(svg); + } else { + tile.append(h('span', { text: initials(entity.name) })); + } + return tile; + } + + // ---------- Bottom sheets ---------- + + const openSheets = []; + + function sheet({ title, body, footer, className, onClose, back }) { + const { t } = ST.i18n; + const titleId = `sheet-title-${Math.random().toString(36).slice(2, 8)}`; + const closeBtn = h('button', { class: 'icon-btn', type: 'button', 'aria-label': t('nav.close') }, icon('close')); + const backBtn = back + ? h('button', { class: 'icon-btn', type: 'button', 'aria-label': t('nav.back') }, icon('back')) + : null; + const head = h('header', { class: 'sheet-head' }, + h('div', { class: 'sheet-grip', 'aria-hidden': 'true' }), + backBtn, + h('h2', { id: titleId, text: title }), + closeBtn); + const scroller = h('div', { class: 'sheet-body' }, body); + const panel = h('div', { class: 'sheet-panel' }, head, scroller, footer ? h('footer', { class: 'sheet-foot' }, footer) : null); + const dlg = h('dialog', { class: `sheet ${className || ''}`.trim(), 'aria-labelledby': titleId }, panel); + + let closed = false; + function close(reason) { + if (closed) return Promise.resolve(); + closed = true; + dlg.classList.remove('open'); + return new Promise((resolve) => { + const done = () => { + dlg.close(); + dlg.remove(); + const i = openSheets.indexOf(api); + if (i >= 0) openSheets.splice(i, 1); + if (!openSheets.length) document.documentElement.classList.remove('sheet-open'); + if (onClose) onClose(reason); + resolve(); + }; + if (reducedMotion.matches) done(); + else setTimeout(done, 260); + }); + } + + closeBtn.addEventListener('click', () => close('close')); + if (backBtn) backBtn.addEventListener('click', () => { close('back'); back(); }); + dlg.addEventListener('cancel', (e) => { e.preventDefault(); close('cancel'); }); + dlg.addEventListener('click', (e) => { if (e.target === dlg) close('backdrop'); }); + enableDragToClose(head, panel, () => close('swipe')); + + document.body.append(dlg); + dlg.showModal(); + document.documentElement.classList.add('sheet-open'); + requestAnimationFrame(() => requestAnimationFrame(() => dlg.classList.add('open'))); + + const api = { el: dlg, body: scroller, close }; + openSheets.push(api); + return api; + } + + function enableDragToClose(handle, panel, onClose) { + let startY = 0; + let lastY = 0; + let lastT = 0; + let velocity = 0; + let dragging = false; + + handle.addEventListener('pointerdown', (e) => { + if (e.target.closest('button')) return; + dragging = true; + startY = lastY = e.clientY; + lastT = e.timeStamp; + velocity = 0; + panel.classList.add('dragging'); + handle.setPointerCapture(e.pointerId); + }); + handle.addEventListener('pointermove', (e) => { + if (!dragging) return; + const dy = Math.max(0, e.clientY - startY); + velocity = (e.clientY - lastY) / Math.max(1, e.timeStamp - lastT); + lastY = e.clientY; + lastT = e.timeStamp; + panel.style.setProperty('transform', `translateY(${dy}px)`); + }); + const end = (e) => { + if (!dragging) return; + dragging = false; + panel.classList.remove('dragging'); + const dy = e.clientY - startY; + panel.style.removeProperty('transform'); + if (dy > 120 || (dy > 30 && velocity > 0.6)) onClose(); + }; + handle.addEventListener('pointerup', end); + handle.addEventListener('pointercancel', end); + } + + function confirm(message, confirmLabel) { + const { t } = ST.i18n; + return new Promise((resolve) => { + let answer = false; + const yes = h('button', { class: 'btn btn-danger', type: 'button', text: confirmLabel }); + const no = h('button', { class: 'btn btn-ghost', type: 'button', text: t('common.cancel') }); + const s = sheet({ + title: message, + className: 'sheet-confirm', + body: h('div'), + footer: h('div', { class: 'btn-row' }, no, yes), + onClose: () => resolve(answer), + }); + yes.addEventListener('click', () => { answer = true; s.close(); }); + no.addEventListener('click', () => s.close()); + yes.focus(); + }); + } + + // ---------- Toasts ---------- + + function toast(message, opts) { + const o = opts || {}; + const host = document.getElementById('toasts'); + const el = h('div', { class: 'toast', role: 'status' }, h('span', { text: message })); + let timer; + const dismiss = () => { + clearTimeout(timer); + el.classList.remove('show'); + setTimeout(() => el.remove(), 250); + }; + if (o.action) { + el.append(h('button', { + class: 'toast-action', + type: 'button', + text: o.action, + on: { click: () => { dismiss(); o.onAction(); } }, + })); + } + host.append(el); + requestAnimationFrame(() => el.classList.add('show')); + timer = setTimeout(dismiss, o.duration || (o.action ? 6000 : 2800)); + return dismiss; + } + + function haptic(ms) { + if (navigator.vibrate) { + try { navigator.vibrate(ms || 8); } catch { /* not allowed */ } + } + } + + function download(filename, mime, content) { + const url = URL.createObjectURL(new Blob([content], { type: mime })); + const a = h('a', { href: url, download: filename }); + document.body.append(a); + a.click(); + a.remove(); + setTimeout(() => URL.revokeObjectURL(url), 2000); + } + + ST.ui = { h, append, icon, logo, brandColor, isLight, initials, sheet, confirm, toast, haptic, download, reducedMotion }; +})(window); diff --git a/manifest.webmanifest b/manifest.webmanifest new file mode 100644 index 0000000..e694da2 --- /dev/null +++ b/manifest.webmanifest @@ -0,0 +1,27 @@ +{ + "id": "./", + "name": "SubTrack – Subscription Tracker", + "short_name": "SubTrack", + "description": "Track all your subscriptions in one place. Offline-first and private: your data stays on your device.", + "start_url": "./", + "scope": "./", + "display": "standalone", + "orientation": "portrait", + "background_color": "#F4F4F8", + "theme_color": "#6D5EF5", + "categories": ["finance", "productivity", "utilities"], + "icons": [ + { "src": "icons/icon.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "any" }, + { "src": "icons/icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any" }, + { "src": "icons/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any" }, + { "src": "icons/maskable-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" } + ], + "shortcuts": [ + { + "name": "Add subscription", + "short_name": "Add", + "url": "./?action=add", + "icons": [{ "src": "icons/icon-192.png", "sizes": "192x192", "type": "image/png" }] + } + ] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..431a32b --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "subscription-tracker", + "version": "1.0.0", + "private": true, + "description": "Offline-first PWA to track your subscriptions. Data stays on your device (IndexedDB).", + "license": "MIT", + "type": "module", + "scripts": { + "start": "npx --yes serve@14 -l 8080 .", + "test": "node --test tests/*.test.js", + "icons": "npm install --no-save simple-icons && node tools/build-icons.mjs" + }, + "engines": { + "node": ">=20" + } +} diff --git a/sw.js b/sw.js new file mode 100644 index 0000000..fb3173e --- /dev/null +++ b/sw.js @@ -0,0 +1,90 @@ +/* + * SubTrack service worker: offline cache + local renewal reminders. + * No push server is used; reminders are computed on the device. + */ +/* global ST */ +importScripts( + 'js/core/version.js', + 'js/core/catalog.js', + 'js/core/schedule.js', + 'js/core/i18n.js', + 'js/core/db.js', + 'js/core/reminders.js', +); + +const CACHE = `subtrack-${ST.VERSION}`; +const ASSETS = [ + './', + 'index.html', + 'manifest.webmanifest', + 'css/app.css', + 'js/core/version.js', + 'js/core/catalog.js', + 'js/core/icons.js', + 'js/core/schedule.js', + 'js/core/i18n.js', + 'js/core/db.js', + 'js/core/reminders.js', + 'js/core/ics.js', + 'js/ui.js', + 'js/install.js', + 'js/app.js', + 'icons/icon.svg', + 'icons/icon-192.png', + 'icons/icon-512.png', + 'icons/maskable-512.png', + 'icons/apple-touch-icon.png', + 'icons/badge-96.png', +]; + +self.addEventListener('install', (event) => { + event.waitUntil(caches.open(CACHE).then((c) => c.addAll(ASSETS))); +}); + +self.addEventListener('activate', (event) => { + event.waitUntil((async () => { + const keys = await caches.keys(); + await Promise.all(keys.filter((k) => k.startsWith('subtrack-') && k !== CACHE).map((k) => caches.delete(k))); + await self.clients.claim(); + })()); +}); + +self.addEventListener('message', (event) => { + if (event.data === 'skipWaiting') self.skipWaiting(); + if (event.data === 'check') event.waitUntil(ST.reminders.check(self.registration)); +}); + +self.addEventListener('fetch', (event) => { + const req = event.request; + if (req.method !== 'GET' || new URL(req.url).origin !== self.location.origin) return; + + // App shell: cache first (versioned cache), so the app opens offline. + if (req.mode === 'navigate') { + event.respondWith( + caches.match('index.html').then((hit) => hit || fetch(req)), + ); + return; + } + event.respondWith( + caches.match(req, { ignoreSearch: true }).then((hit) => hit || fetch(req)), + ); +}); + +// Chromium on Android, for installed apps with enough site engagement. +self.addEventListener('periodicsync', (event) => { + if (event.tag === 'renewal-check') { + event.waitUntil(ST.reminders.check(self.registration)); + } +}); + +self.addEventListener('notificationclick', (event) => { + event.notification.close(); + const url = new URL((event.notification.data && event.notification.data.url) || './', self.registration.scope).href; + event.waitUntil((async () => { + const all = await self.clients.matchAll({ type: 'window', includeUncontrolled: true }); + for (const c of all) { + if (c.url.startsWith(self.registration.scope) && 'focus' in c) return c.focus(); + } + return self.clients.openWindow(url); + })()); +}); diff --git a/tests/core.test.js b/tests/core.test.js new file mode 100644 index 0000000..4b9d5e8 --- /dev/null +++ b/tests/core.test.js @@ -0,0 +1,74 @@ +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { ST, d } from './helpers.js'; + +const base = { + name: 'Netflix', price: 12.99, currency: 'EUR', startDate: '2026-01-31', + freq: { every: 1, unit: 'month' }, category: 'video', color: 'E50914', reminder: 2, + catalogId: 'netflix', +}; + +test('sanitize accepts valid input and rejects bad data', () => { + const s = ST.db.sanitize(base); + assert.equal(s.name, 'Netflix'); + assert.equal(s.active, true); + assert.equal(ST.db.sanitize({ ...base, price: -1 }), null); + assert.equal(ST.db.sanitize({ ...base, startDate: '2026-13-01' }), null); + assert.equal(ST.db.sanitize({ ...base, freq: { every: 1, unit: 'hour' } }), null); + assert.equal(ST.db.sanitize({ ...base, name: ' ' }), null); +}); + +test('sanitize neutralises unexpected values', () => { + const s = ST.db.sanitize({ ...base, color: 'red;background:url(x)', currency: 'XXX', category: 'evil', catalogId: '__proto__' }); + assert.equal(s.color, '6B7280'); + assert.equal(s.currency, 'EUR'); + assert.equal(s.category, 'other'); + assert.equal(s.catalogId, null); +}); + +test('every catalogue icon slug exists in icons.js', () => { + for (const item of ST.catalog.ITEMS) { + if (item.icon) assert.ok(ST.icons[item.icon], `missing icon ${item.icon}`); + } + const ids = ST.catalog.ITEMS.map((i) => i.id); + assert.equal(new Set(ids).size, ids.length, 'duplicate catalogue ids'); +}); + +test('reminders.due respects reminder window and dedup', () => { + ST.i18n.setLang('it'); + const sub = ST.db.sanitize(base); + const today = d('2026-03-29'); + let due = ST.reminders.due([sub], today, {}); + assert.equal(due.length, 1); + assert.equal(due[0].days, 2); + assert.match(ST.reminders.text(due[0]).title, /Netflix si rinnova tra 2 giorni/); + assert.equal(ST.reminders.due([sub], today, { [due[0].key]: '2026-03-31' }).length, 0); + assert.equal(ST.reminders.due([sub], d('2026-03-20'), {}).length, 0); + assert.equal(ST.reminders.due([{ ...sub, active: false }], today, {}).length, 0); + assert.equal(ST.reminders.due([{ ...sub, reminder: -1 }], today, {}).length, 0); +}); + +test('ics export builds month-end safe rules and alarms', () => { + ST.i18n.setLang('en'); + const sub = ST.db.sanitize({ ...base, notes: 'Plan; family, 4K' }); + const out = ST.ics.build([sub], new Date(Date.UTC(2026, 9, 4, 12))); + assert.match(out, /^BEGIN:VCALENDAR\r\n/); + assert.match(out, /DTSTART;VALUE=DATE:20260131/); + assert.match(out, /RRULE:FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=28,29,30,31;BYSETPOS=-1/); + assert.match(out, /TRIGGER:-PT39H/); + assert.match(out, /Plan\; family\\, 4K/); + assert.ok(out.split('\r\n').every((l) => new TextEncoder().encode(l).length <= 75)); + assert.equal(ST.ics.rrule({ every: 1, unit: 'year' }, d('2024-02-29')), + 'RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=2;BYMONTHDAY=28,29;BYSETPOS=-1'); +}); + +test('ics folding keeps multibyte characters intact', () => { + const line = `SUMMARY:${'Γ¨'.repeat(80)}`; + const folded = ST.ics.fold(line); + assert.equal(folded.replace(/\r\n /g, ''), line); +}); + +test('both languages define the same keys', () => { + const { STRINGS } = ST.i18n; + assert.deepEqual(Object.keys(STRINGS.it).sort(), Object.keys(STRINGS.en).sort()); +}); diff --git a/tests/helpers.js b/tests/helpers.js new file mode 100644 index 0000000..fbee8ef --- /dev/null +++ b/tests/helpers.js @@ -0,0 +1,13 @@ +// Loads the browser "core" scripts into globalThis.ST for Node tests. +await import('../js/core/version.js'); +await import('../js/core/catalog.js'); +await import('../js/core/icons.js'); +await import('../js/core/schedule.js'); +await import('../js/core/i18n.js'); +await import('../js/core/db.js'); +await import('../js/core/reminders.js'); +await import('../js/core/ics.js'); + +export const ST = globalThis.ST; +export const d = (s) => ST.schedule.parseISO(s); +export const iso = (date) => ST.schedule.toISO(date); diff --git a/tests/schedule.test.js b/tests/schedule.test.js new file mode 100644 index 0000000..86c0f51 --- /dev/null +++ b/tests/schedule.test.js @@ -0,0 +1,65 @@ +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { ST, d, iso } from './helpers.js'; + +const { schedule } = ST; +const M = { every: 1, unit: 'month' }; + +test('parseISO rejects invalid dates', () => { + assert.equal(schedule.parseISO('2026-02-30'), null); + assert.equal(schedule.parseISO('nope'), null); + assert.equal(iso(schedule.parseISO('2024-02-29')), '2024-02-29'); +}); + +test('start in the future is the next renewal', () => { + assert.equal(iso(schedule.nextRenewal('2026-12-01', M, d('2026-10-04'))), '2026-12-01'); +}); + +test('renewal on the reference day counts as today', () => { + assert.equal(iso(schedule.nextRenewal('2026-01-04', M, d('2026-10-04'))), '2026-10-04'); +}); + +test('monthly from the 31st clamps to month end without drifting', () => { + const start = '2026-01-31'; + assert.equal(iso(schedule.nextRenewal(start, M, d('2026-02-01'))), '2026-02-28'); + assert.equal(iso(schedule.nextRenewal(start, M, d('2026-03-01'))), '2026-03-31'); + assert.equal(iso(schedule.nextRenewal(start, M, d('2026-04-01'))), '2026-04-30'); + assert.equal(iso(schedule.nextRenewal('2024-01-31', M, d('2024-02-01'))), '2024-02-29'); +}); + +test('quarterly, yearly, weekly and daily periods', () => { + assert.equal(iso(schedule.nextRenewal('2026-01-15', { every: 3, unit: 'month' }, d('2026-05-01'))), '2026-07-15'); + assert.equal(iso(schedule.nextRenewal('2024-02-29', { every: 1, unit: 'year' }, d('2025-01-01'))), '2025-02-28'); + assert.equal(iso(schedule.nextRenewal('2028-02-29', { every: 1, unit: 'year' }, d('2031-03-01'))), '2032-02-29'); + assert.equal(iso(schedule.nextRenewal('2026-10-01', { every: 1, unit: 'week' }, d('2026-10-04'))), '2026-10-08'); + assert.equal(iso(schedule.nextRenewal('2026-10-01', { every: 10, unit: 'day' }, d('2026-10-12'))), '2026-10-21'); +}); + +test('long-running daily subscription stays exact', () => { + assert.equal(iso(schedule.nextRenewal('2000-01-01', { every: 1, unit: 'day' }, d('2026-10-04'))), '2026-10-04'); +}); + +test('DST transitions do not shift days', () => { + // Europe DST changes on the last Sunday of March / October. + assert.equal(iso(schedule.nextRenewal('2026-03-20', { every: 1, unit: 'week' }, d('2026-03-30'))), '2026-04-03'); + assert.equal(schedule.diffDays(d('2026-10-24'), d('2026-10-26')), 2); +}); + +test('previousRenewal and occurrencesBetween', () => { + assert.equal(iso(schedule.previousRenewal('2026-01-31', M, d('2026-03-15'))), '2026-02-28'); + assert.equal(schedule.previousRenewal('2026-12-01', M, d('2026-10-01')), null); + const occ = schedule.occurrencesBetween('2026-01-31', M, d('2026-02-01'), d('2026-05-31')).map(iso); + assert.deepEqual(occ, ['2026-02-28', '2026-03-31', '2026-04-30', '2026-05-31']); +}); + +test('monthlyCost normalises every unit', () => { + assert.equal(schedule.monthlyCost(120, { every: 1, unit: 'year' }), 10); + assert.equal(schedule.monthlyCost(30, { every: 3, unit: 'month' }), 10); + assert.ok(Math.abs(schedule.monthlyCost(1, { every: 1, unit: 'day' }) - 30.436875) < 1e-9); + assert.equal(schedule.monthlyCost(10, { every: 0, unit: 'month' }), 0); +}); + +test('presetOf maps known frequencies', () => { + assert.equal(schedule.presetOf({ every: 3, unit: 'month' }), 'quarterly'); + assert.equal(schedule.presetOf({ every: 2, unit: 'month' }), 'custom'); +}); diff --git a/tools/build-icons.mjs b/tools/build-icons.mjs new file mode 100644 index 0000000..3533c99 --- /dev/null +++ b/tools/build-icons.mjs @@ -0,0 +1,61 @@ +/* + * Regenerates js/core/icons.js from the Simple Icons package (CC0-1.0). + * + * Usage: + * npm install --no-save simple-icons + * node tools/build-icons.mjs + * + * Only the slugs referenced by js/core/catalog.js are embedded, so the app + * stays small and works fully offline. + */ +import { readFile, writeFile } from 'node:fs/promises'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +const pkgDir = path.join(root, 'node_modules', 'simple-icons'); + +await import(path.join(root, 'js/core/catalog.js')); +const { ITEMS } = globalThis.ST.catalog; + +const pkg = JSON.parse(await readFile(path.join(pkgDir, 'package.json'), 'utf8')); +const data = JSON.parse(await readFile(path.join(pkgDir, 'data/simple-icons.json'), 'utf8')); +const hexBySlug = new Map(data.map((d) => [d.slug, d.hex])); + +const slugs = [...new Set(ITEMS.map((i) => i.icon).filter(Boolean))].sort(); +const out = {}; +const missing = []; +for (const slug of slugs) { + let svg; + try { + svg = await readFile(path.join(pkgDir, 'icons', `${slug}.svg`), 'utf8'); + } catch { + missing.push(slug); + continue; + } + const d = svg.match(/