kaabalah 6.4.0 → 6.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,23 +1,14 @@
1
1
  # Kaabalah
2
2
 
3
- A comprehensive TypeScript library for numerology, astrology, kaabalah, and tarot calculations and interpretations.
3
+ A comprehensive TypeScript library for numerology, astrology, kaabalah, gematria, tarot, and Ifa divination.
4
4
 
5
5
  <p align="center">
6
6
  <img src="./examples/tree-of-life-readme.svg" alt="Color Tree of Life rendered from kaabalah/visual" width="420" />
7
7
  </p>
8
8
 
9
- ## Docs
9
+ ## Documentation
10
10
 
11
- Complete documentation here [https://docs.kaabalah.com/](https://docs.kaabalah.com/)
12
-
13
- ## Features
14
-
15
- - **Tree of Life**: A modular and performant tree of life system to help you build correspondences across different systems
16
- - **Numerology**: Calculate life path numbers and other numerological values
17
- - **Astrology**: Generate birth charts and planetary positions using Swiss Ephemeris
18
- - **Gematria**: Gematria (text numerology) calculations
19
- - **Tarot**: Card meanings, spreads, and interpretations
20
- - **Semantic profiles**: Canonical house and tarot theme metadata for deterministic matching
11
+ Full API reference, guides, and examples: **[docs.kaabalah.com](https://docs.kaabalah.com/)**
21
12
 
22
13
  ## Installation
23
14
 
@@ -25,401 +16,66 @@ Complete documentation here [https://docs.kaabalah.com/](https://docs.kaabalah.c
25
16
  npm install kaabalah
26
17
  ```
27
18
 
28
- Node.js 18.18+ is required for the bundled CLI and runtime helpers.
19
+ Node.js 18.18+ required.
29
20
 
30
- ## Support us on Ko-Fi
21
+ ## Modules
31
22
 
32
- If you find this package useful, you can support it on Ko-Fi too (or just star the repo):
33
-
34
- [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/matmoura19)
23
+ All modules are tree-shakable and can be imported independently:
35
24
 
36
- ## Usage Examples
25
+ | Module | Import | Description |
26
+ |--------|--------|-------------|
27
+ | Core | `kaabalah/core` | Tree of Life graph with cross-system correspondences |
28
+ | Numerology | `kaabalah/numerology` | Life path, cycles, challenges, personal year |
29
+ | Astrology | `kaabalah/astrology` | Birth charts, synastry, composite, transits, solar returns, profections, firdaria, astrocartography, dignity, decans, dodecatemoria |
30
+ | Gematria | `kaabalah/gematria` | Hebrew letter numerology |
31
+ | Tarot | `kaabalah/tarot` | 78-card deck with profiles, archetypes, correspondences, multi-deck images, spread engine |
32
+ | Ifa | `kaabalah/ifa` | Odu divination |
33
+ | Semantic | `kaabalah/semantic` | Theme profiles, kaabalistic overlay correspondences, symbol metadata |
34
+ | Visual | `kaabalah/visual` | Tree of Life SVG generation and layout data |
37
35
 
38
- ### Core Library
36
+ ## Quick Example
39
37
 
40
38
  ```typescript
41
- import { createTree } from 'kaabalah/core';
42
-
43
- const tree = createTree({
44
- system: 'kaabalah',
45
- parts: ['westernAstrology', 'tarot'],
46
- });
47
-
48
- const gematriaResult = calculateGematria('kaabalah', tree);
49
-
50
- console.log(gematriaResult);
51
- ```
52
-
53
- ### Direct Module Imports (Tree-Shakable)
54
-
55
- ```typescript
56
- // Only import what you need
57
- import { calculateLifePath } from 'kaabalah/numerology';
39
+ import { createTree, id, KaabalahTypes } from 'kaabalah/core';
58
40
  import { getBirthChart } from 'kaabalah/astrology';
59
- import { calculateGematria } from 'kaabalah/kaabalah';
60
- import { getHouseThemeProfile } from 'kaabalah/semantic';
61
- import { getRandomSpread } from 'kaabalah/tarot';
62
-
63
- // Calculate life path number
64
- const lifePath = calculateLifePath(new Date('1990-01-15'));
65
-
66
- // Generate a birth chart (with Swiss Ephemeris)
67
- const birthChart = getBirthChart({
68
- date: new Date('1990-01-15T12:30:00Z'),
69
- latitude: 40.7128,
70
- longitude: -74.0060,
71
- timezone: -5
72
- });
73
-
74
- // Calculate Hebrew gematria
75
- const gematriaValue = calculateGematria('kaabalah');
76
- const fourthHouse = getHouseThemeProfile(4);
77
-
78
- // Get a tarot spread
79
- const spread = getRandomSpread(3, true);
80
- ```
81
-
82
- ### Canonical Tarot Image Resolution
83
-
84
- ```typescript
85
- import { id, KaabalahTypes } from "kaabalah/core";
86
- import {
87
- getTarotArchetype,
88
- getTarotCardByNumber,
89
- getTarotCardNumber,
90
- getTarotCorrespondenceProfile,
91
- getTarotCardProfile,
92
- getTarotRepresentation,
93
- listTarotTrees,
94
- resolveTarotImageUrl
95
- } from "kaabalah/tarot";
96
-
97
- const archetype = getTarotArchetype({
98
- pathId: id(KaabalahTypes.PATH, 2)
99
- });
100
-
101
- const riderWaite = getTarotRepresentation({ pathSlug: "beth" }, "rider-waite");
102
- const queenOfCups = getTarotRepresentation(
103
- { tarotCardName: "Queen of Cups" },
104
- "rider-waite"
105
- );
106
- const tenOfSwords = getTarotRepresentation(
107
- { tarotCardNumber: 55 },
108
- "mythic"
109
- );
110
- const aceOfPentacles = getTarotCardProfile({
111
- tarotCardName: "Ace of Pentacles"
112
- });
113
- const aceOfPentaclesNumber = getTarotCardNumber({
114
- tarotCardName: "Ace of Pentacles"
115
- });
116
- const kingOfSwords = getTarotCardByNumber(51);
117
- const tarotTrees = listTarotTrees();
118
- const papusImageUrl = resolveTarotImageUrl(
119
- { tarotCardFilename: "02_the_high_priestess" },
120
- "papus_pt"
121
- );
122
- const aceOfWandsUrl = resolveTarotImageUrl(
123
- { tarotCardFilename: "ace_wands" },
124
- "papus_pt"
125
- );
126
-
127
- // Persist the canonical archetype ID (for example `path:2`), not the image URL.
128
- ```
129
-
130
- `getTarotArchetype()` remains major-only. The image helpers (`getTarotRepresentation()`, `getTarotRepresentations()`, and `resolveTarotImageUrl()`) support all 78 cards and own the canonical asset rules:
131
-
132
- - majors: `major/<filename>.jpg`
133
- - minors: `minor/<suit>/<filename>.jpg`
134
- - courts: `daat+royalship/<suit>/<filename>.jpg`
135
-
136
- Downstream apps should consume the returned `imageUrl` (or `assetPath`) from the library instead of reconstructing S3 paths locally.
137
-
138
- Tarot numbering is tree-scoped. In the current library release the canonical default tree is `kaabalah`, and `getTarotCardProfile()` resolves its `tarotCardNumber` from the direct `tarotArkAnnu ↔ number` correspondence in that tree. Use `getTarotCardNumber()` / `getTarotCardByNumber()` for forward and reverse numbering lookups, and treat raw `ARKANNUS` entries as compatibility data rather than the source of truth.
139
-
140
- For display-facing correspondences, use `getTarotCorrespondenceProfile()` instead of rebuilding card bundles in the app:
141
-
142
- ```typescript
143
- const pageOfWands = getTarotCorrespondenceProfile({
144
- tarotCardName: "Page of Wands"
145
- });
146
- // {
147
- // kind: "court",
148
- // courtRank: "page",
149
- // correspondences: {
150
- // element: { id: "westernElement:Fire", label: "Fire" }
151
- // }
152
- // }
153
-
154
- const magician = getTarotCorrespondenceProfile({
155
- tarotCardName: "The Magician"
156
- });
157
- // includes typed astrology correspondences plus path metadata
158
- // { pathId, pathNumber, pathSlug, hebrewLetter, fromSphere, toSphere, meaning }
159
- ```
160
-
161
- Downstream apps no longer need to parse card-name prefixes like `Page of ...` to determine court rank, or rebuild the same major/court/minor correspondence collapsing logic from raw tree traversals.
162
-
163
- Observable kaabalah-default renumbering:
164
-
165
- - `Ten of Swords` is `55` and `Ace of Swords` is `64`
166
- - `Ten of Pentacles` is `69` and `Ace of Pentacles` is `78`
167
- - court/minor suit blocks run `King → Queen → Knight → Page → Ten → ... → Ace`
168
-
169
- ### Canonical Semantic Profiles
170
-
171
- ```typescript
172
- import {
173
- getHouseThemeProfile,
174
- getTarotThemeProfile,
175
- listHouseThemeProfiles,
176
- tokenizeOccultThemeText
177
- } from "kaabalah/semantic";
178
-
179
- const dreamTokens = tokenizeOccultThemeText(
180
- "I dreamed about family, roots, and hidden rooms."
181
- );
182
-
183
- const fourthHouse = getHouseThemeProfile(4);
184
- const tower = getTarotThemeProfile("The House of God");
185
- const houseProfiles = listHouseThemeProfiles();
186
- ```
187
-
188
- Semantic profiles are deterministic, library-owned metadata layered on top of canonical correspondences. Downstream apps should consume the profile `id`, `houseNumber` or `cardNumber`, `keywords`, `tokens`, and grouped `correspondences`, while keeping scoring, ranking, and UI presentation app-side.
189
- For houses, `primaryLabel` is the semantic life-area label and `houseLabel` preserves the structural astrological label (`Ascendant`, `Imum Coeli`, `Descendant`, `Medium Coeli`, etc.).
190
-
191
- ### Kaabalistic Overlay Correspondences
192
-
193
- ```typescript
194
- import {
195
- buildKaabalisticMapData,
196
- getAstrologyTreeMarkers,
197
- getKaabalisticCorrespondenceTargets,
198
- getPlanetSymbolMetadata,
199
- getZodiacSignSymbolMetadata
200
- } from "kaabalah/semantic";
201
-
202
- const signTargets = getKaabalisticCorrespondenceTargets({
203
- kind: "sign",
204
- sign: "Libra"
205
- });
206
-
207
- const sunSymbol = getPlanetSymbolMetadata("Sun");
208
- const libraSymbol = getZodiacSignSymbolMetadata("Libra");
209
-
210
- const astrologyMarkers = getAstrologyTreeMarkers({
211
- planets,
212
- nodes,
213
- houses,
214
- });
215
-
216
- const mapData = buildKaabalisticMapData({
217
- astrology: { planets, nodes, houses },
218
- numerology: birthDate,
219
- gematria: name,
220
- });
221
- ```
41
+ import { calculateKaabalisticLifePath } from 'kaabalah/numerology';
42
+ import { getTarotCorrespondenceProfile } from 'kaabalah/tarot';
43
+ import { generateTreeSvg } from 'kaabalah/visual';
222
44
 
223
- Use these semantic helpers when the app needs canonical overlay inputs for a Tree of Life view:
45
+ const tree = createTree({ system: 'kaabalah', parts: ['westernAstrology', 'tarot'] });
46
+ const correspondences = tree.getCorrespondences(id(KaabalahTypes.SPHERE, 'Tiphareth'), { depth: 2 });
224
47
 
225
- - `getKaabalisticCorrespondenceTargets(...)` returns typed sphere/path targets for a sign, planet-in-sign, angle, node, number, or Hebrew letter.
226
- - `getAstrologyTreeMarkers(...)`, `getNumerologyTreeMarkers(...)`, and `getGematriaTreeMarkers(...)` return render-ready marker descriptors with no layout coordinates.
227
- - `buildKaabalisticMapData(...)` combines markers, grouped target counts, and item-to-target summaries for mixed astrology/numerology/gematria map views.
228
-
229
- The rendering layer should stay thin: ask `kaabalah/semantic` for correspondences or marker descriptors, then place them with `getTreeLayout()` from `kaabalah/visual`.
230
-
231
- ### Canonical Tree SVG Rendering
232
-
233
- ```typescript
234
- import { generateTreeSvg, getTreeLayout } from "kaabalah/visual";
235
-
236
- const svg = generateTreeSvg({
237
- background: "transparent",
238
- palette: "monochrome",
239
- daathLayer: "back",
240
- });
241
-
242
- const layout = getTreeLayout();
243
- const tiphareth = layout.percentages.spheres["sphere:Tiphareth"];
244
- const path15 = layout.percentages.paths["path:15"];
245
- ```
246
-
247
- `generateTreeSvg()` renders the structural tree only: paths and spheres, with no astrology, numerology, gematria, or app-specific overlays. Use it when an app needs a reusable base SVG, then place badges or glyphs using `getTreeLayout()` rather than reimplementing the coordinate math.
248
-
249
- Contract notes:
250
-
251
- - the exported `percentages` map is the canonical frontend grid shared with the existing app tree views
252
- - `viewBoxUnits` exposes the same positions in the default `286 x 561` SVG coordinate space
253
- - `palette: "color"` preserves the full-color Melkitzedeki rendering, including the special Kether, Chokhmah, Daath, and Malkuth sphere treatments
254
- - `palette: "monochrome"` simplifies the tree to plain-circle spheres with a light body and dark outline, so it still reads as a luminous tree on transparent or dark backgrounds
255
- - `daathLayer: "back"` places the Daath sphere behind the paths while still emitting a transparent top hit area for inline SVG interaction
256
-
257
- ### Canonical Tarot Spreads
258
-
259
- ```typescript
260
- import {
261
- drawTarotSpread,
262
- getTarotSpread,
263
- listTarotSpreads,
264
- validateTarotSpreadSelection
265
- } from "kaabalah/tarot";
266
-
267
- const spreads = listTarotSpreads();
268
- const treeOfLife = getTarotSpread("tree-of-life-reading");
269
-
270
- const drawn = drawTarotSpread({
271
- spreadId: "event-reading",
272
- context: { inquirerGender: "man" },
273
- includeInverted: true
48
+ const chart = await getBirthChart({
49
+ date: { year: 1990, month: 6, day: 15, hour: 14, minute: 30 },
50
+ latitude: 48.856, longitude: 2.352,
274
51
  });
275
52
 
276
- const validation = validateTarotSpreadSelection({
277
- spreadId: drawn.spread.spreadId,
278
- context: drawn.context,
279
- cards: drawn.cards.map((card) => ({
280
- slotKey: card.slotKey,
281
- cardNumber: card.cardNumber,
282
- isInverted: card.isInverted
283
- }))
284
- });
53
+ const lifePath = calculateKaabalisticLifePath(new Date('1990-06-15'));
54
+ const magician = getTarotCorrespondenceProfile({ tarotCardName: 'The Magician' });
55
+ const svg = generateTreeSvg({ background: 'transparent', palette: 'monochrome' });
285
56
  ```
286
57
 
287
- Downstream apps should consume `spreadId`, `slotKey`, and the slot constraint metadata from the library instead of hardcoding spread semantics. Persist the reading state as canonical spread/card data such as `spreadId`, `slotKey`, `cardNumber`, `isInverted`, and app-side notes.
288
-
289
58
  ## CLI
290
59
 
291
- Kaabalah includes a command-line interface for quick calculations without writing code.
292
-
293
- ```bash
294
- # Install globally
295
- npm install -g kaabalah
296
-
297
- # Or run directly with npx
298
- npx kaabalah help
299
- ```
300
-
301
- ### Commands
302
-
303
- | Command | Description |
304
- |---------|-------------|
305
- | `gematria <text>` | Calculate gematria for a word or phrase |
306
- | `gematria:reverse <number>` | Find letter combinations matching a gematria value |
307
- | `numerology <date>` | Full numerological profile for a birth date |
308
- | `numerology:lifepath <date>` | Life path number (kaabalistic method) |
309
- | `numerology:cycles <date> [name]` | Personal cycles (year, month, periods) |
310
- | `numerology:challenges <date>` | Challenges from birth date |
311
- | `numerology:fibonacci <date>` | Fibonacci cycle for current age |
312
- | `astrology <date> [time]` | Calculate birth chart with aspects using Swiss Ephemeris |
313
- | `astrology:synastry` | Cross-chart aspects between two birth charts (via `--input-json`) |
314
- | `astrology:composite` | Midpoint composite chart from two birth charts (via `--input-json`) |
315
- | `tarot [count]` | Draw tarot cards (default: 3) |
316
- | `tarot:card <number>` | Look up a specific card (1-78) |
317
- | `ifa <date>` | Calculate Odu from a date |
318
- | `tree` | Show Tree of Life structure with all nodes, data, and edges |
319
- | `tree:node <id>` | Look up a node and all its correspondences |
320
- | `tree:types` | List all node types and their counts |
321
-
322
- ### Examples
323
-
324
- ```bash
325
- kaabalah gematria "Hello World"
326
- kaabalah numerology 1990-01-15
327
- kaabalah numerology:cycles 1990-01-15 John
328
- kaabalah tarot 5 --inverted
329
- kaabalah tarot:card 7
330
- kaabalah gematria:reverse 22
331
- kaabalah ifa 1990-01-15
332
- kaabalah astrology 1990-01-15 14:30 --lat=40.7128 --lon=-74.006
333
- kaabalah astrology 1990-01-15 14:30 --location="New York, USA"
334
-
335
- # Synastry (cross-chart aspects)
336
- kaabalah astrology:synastry --input-json=- --json < synastry.json
337
-
338
- # Composite (midpoint chart)
339
- kaabalah astrology:composite --input-json=- --json < composite.json
340
-
341
- # Tree of Life correspondences
342
- kaabalah tree:node path:1 --json
343
- kaabalah tree:node "tarotArkAnnu:The Magician" --depth=2 --json
344
- kaabalah tree:node sphere:Kether --type=tarotArkAnnu --json
345
- kaabalah tree:node westernZodiacSign:Libra --depth=2 --json --fields=correspondenceMap.sphere,correspondenceMap.path,correspondenceMap.westernElement
346
- ```
347
-
348
- ### Global Flags
349
-
350
- | Flag | Description |
351
- |------|-------------|
352
- | `--json` | JSON output (auto-enabled when stdout is not a TTY) |
353
- | `--no-json` | Force human-readable output even when piped |
354
- | `--compact` | Minified JSON (no indentation) |
355
- | `--fields=a.b,c.d` | Filter JSON output to specified dot-paths |
356
- | `--input-json=-` | Read a JSON object from stdin |
357
- | `--debug` | Emit debug logs to stderr (same effect as `DEBUG=kaabalah:*`) |
358
- | `--trace` | Print stack traces for unexpected fatal errors in human-readable mode |
359
-
360
- ### Schema Introspection
361
-
362
- ```bash
363
- # Full schema of all commands
364
- kaabalah help --json
365
-
366
- # Schema for a specific command
367
- kaabalah help astrology --json
368
- ```
369
-
370
- ### Debugging
371
-
372
- ```bash
373
- # Emit parser/config/astrology debug logs to stderr
374
- DEBUG=kaabalah:* kaabalah help --json
375
-
376
- # Same as above, but from the CLI flag
377
- kaabalah astrology 1990-01-15 14:30 --lat=40.7128 --lon=-74.006 --debug
378
-
379
- # Add --trace while reproducing an unexpected fatal error locally
380
- kaabalah <command> --trace --no-json
381
- ```
382
-
383
- ## Development
384
-
385
- This project uses TypeScript and WebAssembly for the Swiss Ephemeris calculations.
386
-
387
- ### Building the Project
388
-
389
- ```bash
390
- npm run build
391
- ```
392
-
393
- ### Development Mode
394
-
395
60
  ```bash
396
- npm run dev
61
+ npx kaabalah help # list all commands
62
+ npx kaabalah help --json # full schema introspection
63
+ npx kaabalah numerology 1990-01-15 --json --compact
64
+ npx kaabalah astrology 1990-01-15 14:30 --lat=40.71 --lon=-74 --json
65
+ npx kaabalah tree:node "tarotArkAnnu:The Magician" --depth=2 --json
397
66
  ```
398
67
 
399
- ## Swiss Ephemeris Integration
400
-
401
- The astrological calculations use the Swiss Ephemeris library, compiled to WebAssembly for use in both Node.js and browser environments.
68
+ 27 commands covering all modules. See the [CLI Reference](https://docs.kaabalah.com/getting-started/cli/) for the full list.
402
69
 
403
- For Node apps that need stable runtime asset paths, use the exported helper instead of probing `node_modules/kaabalah` manually:
70
+ ## Support
404
71
 
405
- ```typescript
406
- import { getSwissEph, resolveSwissEphRuntimeAssets } from "kaabalah/astrology";
407
-
408
- const assets = resolveSwissEphRuntimeAssets({
409
- wasmPathCandidates: ["./vendor/kaabalah/swisseph.node.wasm"],
410
- ephePathCandidates: ["./vendor/kaabalah/ephe"]
411
- });
412
-
413
- await getSwissEph(assets);
414
- ```
415
-
416
- If no app-specific candidates are provided, the helper falls back to the package-bundled Node assets. In browser environments it stays filesystem-free and returns the bundled browser defaults.
72
+ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/matmoura19)
417
73
 
418
74
  ## License
419
75
 
420
- This project is licensed under the AGPL-3.0 license. See the LICENSE file for details.
76
+ AGPL-3.0 — see [LICENSE](LICENSE).
421
77
 
422
78
  ## Acknowledgments
423
79
 
424
- - [Swiss Ephemeris](https://www.astro.com/swisseph/) for providing the astronomical calculation library
425
- - [Astro.com](https://www.astro.com/) for the Swiss Ephemeris data
80
+ - [Swiss Ephemeris](https://www.astro.com/swisseph/) for astronomical calculations
81
+ - [Astro.com](https://www.astro.com/) for ephemeris data
@@ -79,6 +79,7 @@ function generateTreeSvg(options = {}) {
79
79
  const tree = createTree({ system, parts: ["colors"] });
80
80
  const viewBox = normalizeViewBox(options.viewBox);
81
81
  const palette = resolvePalette(options.palette);
82
+ const highlights = resolveHighlights(options.highlights);
82
83
  const spherePositions = scaleCoordinates(CANONICAL_SPHERE_PERCENTAGES, viewBox);
83
84
  const layout = buildLayoutMap(tree, spherePositions);
84
85
  const scale = Math.min(
@@ -155,6 +156,7 @@ function generateTreeSvg(options = {}) {
155
156
  if (daathLayer === "back") {
156
157
  push(`<g id="spheres-behind-paths">`);
157
158
  renderSphere(push, {
159
+ highlights,
158
160
  tree,
159
161
  palette,
160
162
  radius,
@@ -168,12 +170,17 @@ function generateTreeSvg(options = {}) {
168
170
  for (const currentPathId of TREE_PATH_IDS) {
169
171
  const path = layout.paths[currentPathId];
170
172
  const color = resolvePathColor({
173
+ highlights,
171
174
  palette,
172
175
  tree,
173
176
  pathId: currentPathId
174
177
  });
178
+ const edgeColor = resolvePathEdgeColor({
179
+ palette,
180
+ pathColor: color
181
+ });
175
182
  push(
176
- `<line x1="${path.from.x}" y1="${path.from.y}" x2="${path.to.x}" y2="${path.to.y}" stroke="${escapeAttr(palette.pathEdgeColor)}" stroke-width="${pathEdgeWidth}" stroke-linecap="round"${palette.pathEdgeUseFilter ? ` filter="url(#pathDarken)"` : ""}/>`
183
+ `<line x1="${path.from.x}" y1="${path.from.y}" x2="${path.to.x}" y2="${path.to.y}" stroke="${escapeAttr(edgeColor)}" stroke-width="${pathEdgeWidth}" stroke-linecap="round"${palette.pathEdgeUseFilter ? ` filter="url(#pathDarken)"` : ""}/>`
177
184
  );
178
185
  push(
179
186
  `<line x1="${path.from.x}" y1="${path.from.y}" x2="${path.to.x}" y2="${path.to.y}" stroke="${escapeAttr(color)}" stroke-width="${pathMainWidth}" stroke-linecap="round"/>`
@@ -187,6 +194,7 @@ function generateTreeSvg(options = {}) {
187
194
  push(`<g id="spheres">`);
188
195
  for (const sphereName of frontSphereNames) {
189
196
  renderSphere(push, {
197
+ highlights,
190
198
  tree,
191
199
  palette,
192
200
  radius,
@@ -215,25 +223,39 @@ function renderSphere(push, params) {
215
223
  sphereId: currentSphereId,
216
224
  defaultColors: colorData
217
225
  });
226
+ const highlightFill = params.highlights.sphereFills[currentSphereId];
227
+ const activeFill = highlightFill ?? sphereFill;
218
228
  push(`<g id="sphere-${slug}" clip-path="url(#clip-${slug})">`);
219
229
  if (params.palette.specialSphereMode === "preserve") {
220
230
  if (params.sphereName === "Kether") {
221
- renderKether(push, point, params.radius);
231
+ renderKether(
232
+ push,
233
+ point,
234
+ params.radius,
235
+ highlightFill ? toPrimaryFill(highlightFill, "#e0e0e0") : void 0
236
+ );
222
237
  } else if (params.sphereName === "Chokhmah") {
223
238
  renderIridescent(push, point, params.radius);
239
+ if (highlightFill) {
240
+ renderSphereTintOverlay(push, point, params.radius, highlightFill, 0.62);
241
+ }
224
242
  } else if (params.sphereName === "Daath") {
225
- renderYinYang(push, point, params.radius);
243
+ renderYinYang(push, point, params.radius, highlightFill);
226
244
  } else if (params.sphereName === "Malkuth" && colorData.length >= 4) {
227
- const slicedColors = Array.isArray(sphereFill) ? sphereFill : colorData.slice(0, 4);
245
+ const slicedColors = resolveMalkuthColors({
246
+ highlightFill,
247
+ paletteFill: sphereFill,
248
+ defaultColors: colorData.slice(0, 4)
249
+ });
228
250
  renderSlicedSphere(push, point, params.radius, slicedColors, -135);
229
251
  } else {
230
252
  push(
231
- `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="${escapeAttr(toPrimaryFill(sphereFill, params.palette.defaultSphereFill))}"/>`
253
+ `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="${escapeAttr(toPrimaryFill(activeFill, params.palette.defaultSphereFill))}"/>`
232
254
  );
233
255
  }
234
256
  } else {
235
257
  push(
236
- `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="${escapeAttr(toPrimaryFill(sphereFill, params.palette.defaultSphereFill))}"/>`
258
+ `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="${escapeAttr(toPrimaryFill(activeFill, params.palette.defaultSphereFill))}"/>`
237
259
  );
238
260
  }
239
261
  push(
@@ -352,7 +374,17 @@ function resolvePalette(palette) {
352
374
  specialSphereMode: palette.specialSphereMode ?? "plain"
353
375
  };
354
376
  }
377
+ function resolveHighlights(highlights) {
378
+ return {
379
+ pathColors: highlights?.paths ?? {},
380
+ sphereFills: highlights?.spheres ?? {}
381
+ };
382
+ }
355
383
  function resolvePathColor(params) {
384
+ const highlightOverride = params.highlights.pathColors[params.pathId];
385
+ if (highlightOverride) {
386
+ return highlightOverride;
387
+ }
356
388
  const override = params.palette.pathColors[params.pathId];
357
389
  if (override) {
358
390
  return override;
@@ -363,6 +395,12 @@ function resolvePathColor(params) {
363
395
  const treeColor = params.tree.relatedFirst(params.pathId, "color" /* COLOR */)?.data?.colorHexCodes?.[0];
364
396
  return treeColor ?? params.palette.defaultPathColor;
365
397
  }
398
+ function resolvePathEdgeColor(params) {
399
+ if (params.palette.mode === "color") {
400
+ return params.pathColor;
401
+ }
402
+ return params.palette.pathEdgeColor;
403
+ }
366
404
  function resolveSphereFill(params) {
367
405
  const override = params.palette.sphereFills[params.sphereId];
368
406
  if (override) {
@@ -382,6 +420,34 @@ function toPrimaryFill(fill, fallback) {
382
420
  }
383
421
  return fill;
384
422
  }
423
+ function resolveMalkuthColors(params) {
424
+ if (params.highlightFill) {
425
+ return expandColors(
426
+ params.highlightFill,
427
+ params.defaultColors.length,
428
+ params.defaultColors
429
+ );
430
+ }
431
+ if (Array.isArray(params.paletteFill)) {
432
+ return expandColors(
433
+ params.paletteFill,
434
+ params.defaultColors.length,
435
+ params.defaultColors
436
+ );
437
+ }
438
+ return params.defaultColors;
439
+ }
440
+ function expandColors(fill, count, fallbackColors) {
441
+ if (Array.isArray(fill)) {
442
+ if (fill.length === 0) {
443
+ return fallbackColors.slice(0, count);
444
+ }
445
+ return Array.from({ length: count }, (_, index) => {
446
+ return fill[index] ?? fill[fill.length - 1];
447
+ });
448
+ }
449
+ return Array.from({ length: count }, () => fill);
450
+ }
385
451
  function round(value) {
386
452
  return Math.round(value * 100) / 100;
387
453
  }
@@ -398,8 +464,10 @@ function arcPath(cx, cy, radius, startDegrees, endDegrees) {
398
464
  const largeArc = endDegrees - startDegrees <= 180 ? 0 : 1;
399
465
  return `M ${cx} ${cy} L ${start.x} ${start.y} A ${radius} ${radius} 0 ${largeArc} 1 ${end.x} ${end.y} Z`;
400
466
  }
401
- function renderKether(push, point, radius) {
402
- push(`<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="#e0e0e0"/>`);
467
+ function renderKether(push, point, radius, baseFill = "#e0e0e0") {
468
+ push(
469
+ `<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="${escapeAttr(baseFill)}"/>`
470
+ );
403
471
  push(`<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="url(#kether-glow)"/>`);
404
472
  const spokes = 16;
405
473
  const innerRadius = round(radius * 0.18);
@@ -484,28 +552,45 @@ function interpolateColor(start, end, factor) {
484
552
  const mix = (left, right) => Math.round(left + (right - left) * factor);
485
553
  return `#${mix(r1, r2).toString(16).padStart(2, "0")}${mix(g1, g2).toString(16).padStart(2, "0")}${mix(b1, b2).toString(16).padStart(2, "0")}`;
486
554
  }
487
- function renderYinYang(push, point, radius) {
555
+ function renderYinYang(push, point, radius, fill) {
488
556
  const scale = radius / 50;
489
557
  const circleRadius = round(48 * scale);
490
558
  const halfRadius = round(24 * scale);
491
559
  const dotRadius = round(6 * scale);
560
+ const [lightFill, darkFill] = resolveDualToneFill(fill);
492
561
  push(`<g transform="rotate(180 ${point.x} ${point.y})">`);
493
- push(`<circle cx="${point.x}" cy="${point.y}" r="${circleRadius}" fill="white"/>`);
494
562
  push(
495
- `<path d="M${point.x},${round(point.y - circleRadius)} A${circleRadius},${circleRadius} 0 1,1 ${point.x},${round(point.y + circleRadius)} A${halfRadius},${halfRadius} 0 1,0 ${point.x},${point.y} A${halfRadius},${halfRadius} 0 1,1 ${point.x},${round(point.y - circleRadius)}" fill="black"/>`
563
+ `<circle cx="${point.x}" cy="${point.y}" r="${circleRadius}" fill="${escapeAttr(lightFill)}"/>`
564
+ );
565
+ push(
566
+ `<path d="M${point.x},${round(point.y - circleRadius)} A${circleRadius},${circleRadius} 0 1,1 ${point.x},${round(point.y + circleRadius)} A${halfRadius},${halfRadius} 0 1,0 ${point.x},${point.y} A${halfRadius},${halfRadius} 0 1,1 ${point.x},${round(point.y - circleRadius)}" fill="${escapeAttr(darkFill)}"/>`
496
567
  );
497
568
  push(
498
- `<circle cx="${point.x}" cy="${round(point.y - halfRadius)}" r="${dotRadius}" fill="white"/>`
569
+ `<circle cx="${point.x}" cy="${round(point.y - halfRadius)}" r="${dotRadius}" fill="${escapeAttr(lightFill)}"/>`
499
570
  );
500
571
  push(
501
- `<circle cx="${point.x}" cy="${round(point.y + halfRadius)}" r="${dotRadius}" fill="black"/>`
572
+ `<circle cx="${point.x}" cy="${round(point.y + halfRadius)}" r="${dotRadius}" fill="${escapeAttr(darkFill)}"/>`
502
573
  );
503
574
  push(`</g>`);
504
575
  }
576
+ function renderSphereTintOverlay(push, point, radius, fill, opacity) {
577
+ push(
578
+ `<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="${escapeAttr(toPrimaryFill(fill, "#ffffff"))}" fill-opacity="${opacity}"/>`
579
+ );
580
+ }
581
+ function resolveDualToneFill(fill) {
582
+ if (Array.isArray(fill)) {
583
+ return [fill[0] ?? "white", fill[1] ?? "black"];
584
+ }
585
+ if (fill) {
586
+ return [fill, "black"];
587
+ }
588
+ return ["white", "black"];
589
+ }
505
590
  function escapeAttr(value) {
506
591
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
507
592
  }
508
593
 
509
594
  export { TREE_PATH_IDS, TREE_SPHERE_IDS, TREE_SPHERE_NAMES, TREE_SVG_DEFAULT_VIEWBOX, generateTreeSvg, getTreeLayout };
510
- //# sourceMappingURL=chunk-EMMXVM35.mjs.map
511
- //# sourceMappingURL=chunk-EMMXVM35.mjs.map
595
+ //# sourceMappingURL=chunk-2WEGGWW4.mjs.map
596
+ //# sourceMappingURL=chunk-2WEGGWW4.mjs.map