@roxyapi/ui 0.19.4 → 0.20.0

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.
Files changed (118) hide show
  1. package/AGENTS.md +10 -7
  2. package/README.md +9 -6
  3. package/components-catalog.json +166 -114
  4. package/dist/cdn/components/arudha-padas.js +313 -0
  5. package/dist/cdn/components/arudha-padas.js.map +7 -0
  6. package/dist/cdn/components/chara-karakas.js +313 -0
  7. package/dist/cdn/components/chara-karakas.js.map +7 -0
  8. package/dist/cdn/components/dasha-timeline.js +4 -4
  9. package/dist/cdn/components/dasha-timeline.js.map +4 -4
  10. package/dist/cdn/components/endpoint-form.js +1 -1
  11. package/dist/cdn/components/endpoint-form.js.map +1 -1
  12. package/dist/cdn/components/kp-chart.js +4 -4
  13. package/dist/cdn/components/kp-chart.js.map +4 -4
  14. package/dist/cdn/components/kp-ruling-planets.js +3 -3
  15. package/dist/cdn/components/kp-ruling-planets.js.map +4 -4
  16. package/dist/cdn/components/reference-card.js +3 -3
  17. package/dist/cdn/components/reference-card.js.map +2 -2
  18. package/dist/cdn/components/upagraha-table.js +313 -0
  19. package/dist/cdn/components/upagraha-table.js.map +7 -0
  20. package/dist/cdn/components/vedic-planets-table.js +2 -2
  21. package/dist/cdn/components/vedic-planets-table.js.map +2 -2
  22. package/dist/cdn/components/yoga-list.js +4 -4
  23. package/dist/cdn/components/yoga-list.js.map +3 -3
  24. package/dist/cdn/roxy-ui.js +78 -78
  25. package/dist/cdn/roxy-ui.js.map +4 -4
  26. package/dist/cdn/widgets.js +1 -1
  27. package/dist/components/arudha-padas.d.ts +22 -0
  28. package/dist/components/arudha-padas.d.ts.map +1 -0
  29. package/dist/components/arudha-padas.js +2 -0
  30. package/dist/components/arudha-padas.js.map +7 -0
  31. package/dist/components/chara-karakas.d.ts +22 -0
  32. package/dist/components/chara-karakas.d.ts.map +1 -0
  33. package/dist/components/chara-karakas.js +2 -0
  34. package/dist/components/chara-karakas.js.map +7 -0
  35. package/dist/components/dasha-timeline.d.ts +18 -13
  36. package/dist/components/dasha-timeline.d.ts.map +1 -1
  37. package/dist/components/dasha-timeline.js +1 -1
  38. package/dist/components/dasha-timeline.js.map +4 -4
  39. package/dist/components/endpoint-form.js +1 -1
  40. package/dist/components/endpoint-form.js.map +1 -1
  41. package/dist/components/kp-chart.d.ts +7 -0
  42. package/dist/components/kp-chart.d.ts.map +1 -1
  43. package/dist/components/kp-chart.js +1 -1
  44. package/dist/components/kp-chart.js.map +4 -4
  45. package/dist/components/kp-ruling-planets.d.ts +6 -0
  46. package/dist/components/kp-ruling-planets.d.ts.map +1 -1
  47. package/dist/components/kp-ruling-planets.js +1 -1
  48. package/dist/components/kp-ruling-planets.js.map +4 -4
  49. package/dist/components/reference-card.d.ts +2 -2
  50. package/dist/components/reference-card.d.ts.map +1 -1
  51. package/dist/components/reference-card.js +1 -1
  52. package/dist/components/reference-card.js.map +2 -2
  53. package/dist/components/upagraha-table.d.ts +22 -0
  54. package/dist/components/upagraha-table.d.ts.map +1 -0
  55. package/dist/components/upagraha-table.js +2 -0
  56. package/dist/components/upagraha-table.js.map +7 -0
  57. package/dist/components/vedic-planets-table.d.ts +10 -1
  58. package/dist/components/vedic-planets-table.d.ts.map +1 -1
  59. package/dist/components/vedic-planets-table.js +1 -1
  60. package/dist/components/vedic-planets-table.js.map +2 -2
  61. package/dist/components/yoga-list.d.ts +13 -2
  62. package/dist/components/yoga-list.d.ts.map +1 -1
  63. package/dist/components/yoga-list.js +1 -1
  64. package/dist/components/yoga-list.js.map +3 -3
  65. package/dist/generated/endpoint-bindings.d.ts.map +1 -1
  66. package/dist/index.cjs +46 -46
  67. package/dist/index.cjs.map +4 -4
  68. package/dist/index.d.ts +3 -0
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +51 -51
  71. package/dist/index.js.map +4 -4
  72. package/dist/manifest.d.ts.map +1 -1
  73. package/dist/manifest.json +3 -0
  74. package/dist/schemas/get--astrology-horoscope-sign-daily.json +1 -1
  75. package/dist/schemas/get--astrology-horoscope-sign-monthly.json +1 -1
  76. package/dist/schemas/get--astrology-horoscope-sign-weekly.json +1 -1
  77. package/dist/schemas/get--astrology-moon-phase-current.json +1 -1
  78. package/dist/schemas/get--vedic-astrology-avasthas-id.json +1 -0
  79. package/dist/schemas/get--vedic-astrology-avasthas.json +1 -0
  80. package/dist/schemas/get--vedic-astrology-kp-ayanamsa.json +1 -1
  81. package/dist/schemas/get--vedic-astrology-yoga-id.json +1 -1
  82. package/dist/schemas/post--vedic-astrology-arudha.json +1 -0
  83. package/dist/schemas/post--vedic-astrology-birth-chart.json +1 -1
  84. package/dist/schemas/post--vedic-astrology-chara-karakas.json +1 -0
  85. package/dist/schemas/post--vedic-astrology-dasha-current.json +1 -1
  86. package/dist/schemas/post--vedic-astrology-dasha-major.json +1 -1
  87. package/dist/schemas/post--vedic-astrology-dasha-sub-mahadasha-antardasha-pratyantardasha-sookshma.json +1 -0
  88. package/dist/schemas/post--vedic-astrology-dasha-sub-mahadasha-antardasha-pratyantardasha.json +1 -1
  89. package/dist/schemas/post--vedic-astrology-dasha-sub-mahadasha-antardasha.json +1 -1
  90. package/dist/schemas/post--vedic-astrology-dasha-sub-mahadasha.json +1 -1
  91. package/dist/schemas/post--vedic-astrology-kp-chart.json +1 -1
  92. package/dist/schemas/post--vedic-astrology-kp-cusps.json +1 -1
  93. package/dist/schemas/post--vedic-astrology-kp-ruling-planets-interval.json +1 -1
  94. package/dist/schemas/post--vedic-astrology-kp-ruling-planets.json +1 -1
  95. package/dist/types/index.d.ts +1 -1
  96. package/dist/types/index.d.ts.map +1 -1
  97. package/dist/types/types.gen.d.ts +3228 -934
  98. package/dist/types/types.gen.d.ts.map +1 -1
  99. package/dist/utils/house-themes.d.ts +19 -0
  100. package/dist/utils/house-themes.d.ts.map +1 -0
  101. package/dist/version.d.ts +1 -1
  102. package/package.json +1 -1
  103. package/src/components/arudha-padas.ts +230 -0
  104. package/src/components/chara-karakas.ts +241 -0
  105. package/src/components/dasha-timeline.ts +129 -28
  106. package/src/components/kp-chart.ts +40 -5
  107. package/src/components/kp-ruling-planets.ts +29 -6
  108. package/src/components/reference-card.ts +3 -1
  109. package/src/components/upagraha-table.ts +182 -0
  110. package/src/components/vedic-planets-table.ts +34 -4
  111. package/src/components/yoga-list.ts +144 -20
  112. package/src/generated/endpoint-bindings.ts +13 -0
  113. package/src/index.ts +3 -0
  114. package/src/manifest.ts +48 -7
  115. package/src/types/index.ts +1 -1
  116. package/src/types/types.gen.ts +3133 -809
  117. package/src/utils/house-themes.ts +36 -0
  118. package/src/version.ts +1 -1
@@ -3,6 +3,7 @@ import { customElement, property, state } from 'lit/decorators.js';
3
3
  import type {
4
4
  GetCurrentDashaResponse,
5
5
  GetMajorDashasResponse,
6
+ GetPranaDashasResponse,
6
7
  GetPratyantardashasResponse,
7
8
  GetSookshmaDashasResponse,
8
9
  GetSubDashasResponse,
@@ -13,9 +14,11 @@ import { disclosureStyles } from '../utils/disclosure.js';
13
14
  import {
14
15
  formatAyanamsa,
15
16
  formatDate,
17
+ formatDateTime,
16
18
  formatNumber,
17
19
  resolveDisplayDate,
18
20
  } from '../utils/format.js';
21
+ import { type HouseThemes, houseWords } from '../utils/house-themes.js';
19
22
  import {
20
23
  type InterpSection,
21
24
  interpAccordionStyles,
@@ -28,7 +31,8 @@ type DashaData =
28
31
  | GetMajorDashasResponse
29
32
  | GetSubDashasResponse
30
33
  | GetPratyantardashasResponse
31
- | GetSookshmaDashasResponse;
34
+ | GetSookshmaDashasResponse
35
+ | GetPranaDashasResponse;
32
36
 
33
37
  type DashaPeriod = GetMajorDashasResponse['mahadashas'][number];
34
38
  type Remaining = GetCurrentDashaResponse['remainingInMahadasha'];
@@ -42,6 +46,11 @@ type Remaining = GetCurrentDashaResponse['remainingInMahadasha'];
42
46
  * antardashas, pratyantardashas or sookshma dashas.
43
47
  */
44
48
  function levelOf(d: DashaData): string {
49
+ // Deepest level first, matching parentOf. No response carries two of these
50
+ // keys today, so the order is not yet load-bearing; it is the order that stays
51
+ // correct when a level is added, since a shallower key that a deeper payload
52
+ // also carried would otherwise win the chain and mislabel it.
53
+ if ('pranaDashas' in d) return 'Prana';
45
54
  if ('sookshmaDashas' in d) return 'Sookshma';
46
55
  if ('pratyantardashas' in d) return 'Pratyantardasha';
47
56
  if ('antardashas' in d) return 'Antardasha';
@@ -52,6 +61,8 @@ function levelOf(d: DashaData): string {
52
61
  function parentOf(
53
62
  d: DashaData,
54
63
  ): { label: string; period: DashaPeriod } | undefined {
64
+ if ('sookshmaPeriod' in d && d.sookshmaPeriod)
65
+ return { label: 'Sookshma', period: d.sookshmaPeriod };
55
66
  if ('pratyantardashaPeriod' in d && d.pratyantardashaPeriod)
56
67
  return { label: 'Pratyantardasha', period: d.pratyantardashaPeriod };
57
68
  if ('antardashaPeriod' in d && d.antardashaPeriod)
@@ -71,10 +82,33 @@ function formatBalance(b: Remaining | undefined): string {
71
82
  return parts.length ? parts.join(' ') : '0d';
72
83
  }
73
84
 
74
- /** "Jun 17, 2018 to Jun 17, 2035" for the accordion aside. */
85
+ /**
86
+ * The houses a period lord acts on, as words: `[2, 7, 8]` reads "wealth, marriage, longevity".
87
+ *
88
+ * `strongHouses` is preferred over `signifiedHouses`: it is the grade A and B subset a KP reading acts on, two or three houses rather than up to eight, which is what keeps this to one line beside a bar. Empty unless the request asked for significators, since both the map and the house lists are absent otherwise.
89
+ */
90
+ function periodHouseWords(
91
+ sig: DashaPeriod['significators'],
92
+ themes: HouseThemes,
93
+ ): string {
94
+ return houseWords(
95
+ sig?.strongHouses?.length ? sig.strongHouses : sig?.signifiedHouses,
96
+ themes,
97
+ );
98
+ }
99
+
100
+ /**
101
+ * "Jun 17, 2018 to Jun 17, 2035" for the accordion aside.
102
+ *
103
+ * @remarks
104
+ * A prana period, and a deep sookshma, opens and closes on the same calendar day, so the date alone printed "Aug 8, 2026 to Aug 8, 2026" and named no span at all. The clock is added only when the two ends collapse, so every longer period keeps the shorter form.
105
+ */
75
106
  function formatSpan(p: { startDate?: string; endDate?: string }): string {
76
107
  const start = p.startDate ? formatDate(p.startDate) : '';
77
108
  const end = p.endDate ? formatDate(p.endDate) : '';
109
+ if (start && start === end) {
110
+ return `${formatDateTime(p.startDate)} to ${formatDateTime(p.endDate)}`;
111
+ }
78
112
  if (start && end) return `${start} to ${end}`;
79
113
  return start || end;
80
114
  }
@@ -83,11 +117,15 @@ function formatSpan(p: { startDate?: string; endDate?: string }): string {
83
117
  * Dasha timeline. Renders /vedic-astrology/dasha/{current,major,sub/{...}}.
84
118
  *
85
119
  * @remarks
86
- * Default mode shows the active mahadasha, antardasha and pratyantardasha with
87
- * the reading each one carries. `period="major"` draws the full 120-year
120
+ * Default mode shows all five active levels, mahadasha through prana, with the
121
+ * reading each one carries. `period="major"` draws the full 120-year
88
122
  * Vimshottari timeline; `period="sub"` draws the antardashas inside one
89
123
  * mahadasha and states which mahadasha they sit in, since an antardasha means
90
124
  * nothing without its parent lord.
125
+ *
126
+ * When the request asked for significators, each period also names the houses
127
+ * its lord acts on, in words taken from the response rather than from any table
128
+ * held here, so the words arrive in the language the caller requested.
91
129
  */
92
130
  @customElement('roxy-dasha-timeline')
93
131
  export class RoxyDashaTimeline extends RoxyDataElement<DashaData> {
@@ -163,6 +201,9 @@ export class RoxyDashaTimeline extends RoxyDataElement<DashaData> {
163
201
  display: grid;
164
202
  grid-template-columns: 5rem 1fr 8rem;
165
203
  gap: var(--roxy-space-sm, 0.5rem);
204
+ /* Tighter than the gap between two bars, so a bar and its own house
205
+ * line read as one row rather than as two entries. */
206
+ row-gap: 0.15rem;
166
207
  align-items: center;
167
208
  font-size: var(--roxy-text-sm, 0.875rem);
168
209
  }
@@ -213,6 +254,28 @@ export class RoxyDashaTimeline extends RoxyDataElement<DashaData> {
213
254
  font-variant-numeric: tabular-nums;
214
255
  text-align: right;
215
256
  }
257
+ /* Time grain prints a clock as well as a date, and two of those do not fit
258
+ * a column sized for a bare date. Give the range its own full-width row
259
+ * rather than squeezing the track, which at phone width would leave the
260
+ * bar itself a few pixels wide. */
261
+ .bar.fine {
262
+ grid-template-columns: 5rem 1fr;
263
+ }
264
+ .bar.fine .dates {
265
+ grid-column: 1 / -1;
266
+ min-width: 0;
267
+ text-align: left;
268
+ }
269
+ .bar .houses {
270
+ /* Full width on a second row: the three tracks are sized for a planet,
271
+ * a bar and a date, and words belong in none of them. */
272
+ grid-column: 1 / -1;
273
+ /* A grid item floors at min-content, so the words wrap inside the row
274
+ * instead of widening the track past the card. */
275
+ min-width: 0;
276
+ color: var(--roxy-muted, #71717a);
277
+ font-size: var(--roxy-text-xs, 0.75rem);
278
+ }
216
279
  [role='tabpanel'] {
217
280
  padding-top: var(--roxy-space-md, 1rem);
218
281
  }
@@ -244,14 +307,16 @@ export class RoxyDashaTimeline extends RoxyDataElement<DashaData> {
244
307
  ];
245
308
 
246
309
  /**
247
- * Which dasha endpoint fed this element. `sub`, `antara` and `sookshma` are the
248
- * three drill-down levels and render identically; they stay distinct because
249
- * each maps one-to-one onto its endpoint binding, which is what lets a widget
250
- * pick a level. The heading and the level LABELS come from the payload, not
251
- * from here, so a host that cannot set attributes still renders correctly.
310
+ * Which dasha endpoint fed this element. `sub`, `antara`, `sookshma` and
311
+ * `prana` are the four drill-down levels and render identically; they stay
312
+ * distinct because each maps one-to-one onto its endpoint binding, which is
313
+ * what lets a widget pick a level. The heading and the level LABELS come from
314
+ * the payload, not from here, so a host that cannot set attributes still
315
+ * renders correctly.
252
316
  */
253
317
  @property({ type: String, reflect: true })
254
- period: 'current' | 'major' | 'sub' | 'antara' | 'sookshma' = 'current';
318
+ period: 'current' | 'major' | 'sub' | 'antara' | 'sookshma' | 'prana' =
319
+ 'current';
255
320
 
256
321
  /** Which panel is showing. Reset guarded in renderData when the data changes shape. */
257
322
  @state()
@@ -330,7 +395,7 @@ export class RoxyDashaTimeline extends RoxyDataElement<DashaData> {
330
395
  ${
331
396
  periods.length > 0
332
397
  ? html`<div class="timeline" role="list">
333
- ${periods.map((p) => this.renderBar(p, maxYears, grain))}
398
+ ${periods.map((p) => this.renderBar(p, maxYears, grain, d.houseThemes))}
334
399
  </div>`
335
400
  : nothing
336
401
  }`
@@ -362,6 +427,7 @@ export class RoxyDashaTimeline extends RoxyDataElement<DashaData> {
362
427
  'mahadashaLord' in d ? d.mahadashaLord : undefined,
363
428
  'antardashaLord' in d ? d.antardashaLord : undefined,
364
429
  'pratyantardashaLord' in d ? d.pratyantardashaLord : undefined,
430
+ 'sookshmaLord' in d ? d.sookshmaLord : undefined,
365
431
  ].filter(Boolean);
366
432
  if (chain.length > 1) {
367
433
  return html`<div class="nakshatra">${chain.join(' \u203a ')}</div>`;
@@ -468,7 +534,7 @@ export class RoxyDashaTimeline extends RoxyDataElement<DashaData> {
468
534
  const began = p.nominalStartDate ? formatDate(p.nominalStartDate) : '';
469
535
  return html`<p class="parent">
470
536
  Inside the <strong>${p.planet}</strong> ${parent.label}${span ? `, ${span}` : ''}
471
- ${typeof p.durationYears === 'number' ? `(${formatNumber(p.durationYears, 1)} years)` : ''}.
537
+ ${typeof p.durationYears === 'number' ? `(${formatDuration(p.durationYears)})` : ''}.
472
538
  ${
473
539
  began
474
540
  ? html`<br />It began ${began}, before birth, so only the sub-periods running
@@ -480,9 +546,9 @@ export class RoxyDashaTimeline extends RoxyDataElement<DashaData> {
480
546
 
481
547
  /**
482
548
  * Every reading the response carries, behind one exclusive accordion. Current
483
- * mode has four (mahadasha, antardasha, pratyantardasha, sookshma); drill-down
484
- * modes lead with the parent period reading, then the sub-period running now;
485
- * major mode shows the mahadasha running now.
549
+ * mode has five (mahadasha, antardasha, pratyantardasha, sookshma, prana);
550
+ * drill-down modes lead with the parent period reading, then the sub-period
551
+ * running now; major mode shows the mahadasha running now.
486
552
  */
487
553
  private readings(d: DashaData, periods: DashaPeriod[]): InterpSection[] {
488
554
  const sections: InterpSection[] = [];
@@ -502,6 +568,7 @@ export class RoxyDashaTimeline extends RoxyDataElement<DashaData> {
502
568
  ['Antardasha', d.antardasha, d.remainingInAntardasha],
503
569
  ['Pratyantardasha', d.pratyantardasha, d.remainingInPratyantardasha],
504
570
  ['Sookshma', d.sookshmaDasha, d.remainingInSookshma],
571
+ ['Prana', d.pranaDasha, d.remainingInPrana],
505
572
  ] as const;
506
573
  for (const [label, period, remaining] of levels) {
507
574
  if (!period?.interpretation) continue;
@@ -533,15 +600,18 @@ export class RoxyDashaTimeline extends RoxyDataElement<DashaData> {
533
600
  ['Antardasha', d.antardasha, d.remainingInAntardasha],
534
601
  ['Pratyantardasha', d.pratyantardasha, d.remainingInPratyantardasha],
535
602
  ['Sookshma', d.sookshmaDasha, d.remainingInSookshma],
603
+ ['Prana', d.pranaDasha, d.remainingInPrana],
536
604
  ] as const;
537
605
  return html`<div class="current">
538
606
  ${levels.map(([label, period, remaining]) => {
539
607
  if (!period) return nothing;
540
608
  const left = formatBalance(remaining);
609
+ const houses = periodHouseWords(period.significators, d.houseThemes);
541
610
  return html`<div>
542
611
  <span>${label}</span>
543
612
  <strong>${period.planet}</strong>
544
613
  ${left ? html`<small>${left} left</small>` : nothing}
614
+ ${houses ? html`<small class="houses">Signifies ${houses}</small>` : nothing}
545
615
  </div>`;
546
616
  })}
547
617
  </div>`;
@@ -554,6 +624,7 @@ export class RoxyDashaTimeline extends RoxyDataElement<DashaData> {
554
624
  return d.pratyantardashas;
555
625
  if ('sookshmaDashas' in d && d.sookshmaDashas?.length)
556
626
  return d.sookshmaDashas;
627
+ if ('pranaDashas' in d && d.pranaDashas?.length) return d.pranaDashas;
557
628
  return [];
558
629
  }
559
630
 
@@ -589,14 +660,23 @@ export class RoxyDashaTimeline extends RoxyDataElement<DashaData> {
589
660
  return (now - start) / (end - start);
590
661
  }
591
662
 
592
- private renderBar(p: DashaPeriod, max: number, grain: DateGrain) {
663
+ private renderBar(
664
+ p: DashaPeriod,
665
+ max: number,
666
+ grain: DateGrain,
667
+ themes: HouseThemes,
668
+ ) {
593
669
  const years = p.durationYears;
594
670
  const width = max > 0 ? (years / max) * 100 : 0;
595
671
  const current = this.isCurrent(p);
596
672
  const progress = current ? this.progressIn(p) : -1;
597
673
  const trackClass = current ? 'bar-track bar-now' : 'bar-track';
674
+ const houses = periodHouseWords(p.significators, themes);
675
+ const cls = ['bar', current ? 'now' : '', grain === 'time' ? 'fine' : '']
676
+ .filter(Boolean)
677
+ .join(' ');
598
678
  return html`<div
599
- class=${current ? 'bar now' : 'bar'}
679
+ class=${cls}
600
680
  role="listitem"
601
681
  aria-current=${current ? 'time' : 'false'}
602
682
  >
@@ -619,36 +699,55 @@ export class RoxyDashaTimeline extends RoxyDataElement<DashaData> {
619
699
  ${p.startDate ? formatBoundary(p.startDate, grain) : ''}
620
700
  ${p.endDate ? html`- ${formatBoundary(p.endDate, grain)}` : ''}
621
701
  </span>
702
+ ${houses ? html`<span class="houses">Signifies ${houses}</span>` : nothing}
622
703
  </div>`;
623
704
  }
624
705
  }
625
706
 
626
707
  /**
627
- * How precise the bar date column has to be, chosen from the LONGEST period in
708
+ * How precise the bar date column has to be, chosen from the SHORTEST period in
628
709
  * the set.
629
710
  *
630
711
  * A Mahadasha spans years, so a bare year reads cleanly and keeps the column
631
712
  * narrow. A Sookshma spans days: printed as a year, every one of the nine rows
632
713
  * reads "1990 - 1990" and the column carries no information at exactly the level
633
- * a reader opened the drill-down to see.
714
+ * a reader opened the drill-down to see. A Prana runs minutes to days, so it
715
+ * needs the clock for the same reason: at day grain the deepest sets print both
716
+ * ends of a row as the same date.
634
717
  */
635
- type DateGrain = 'year' | 'month' | 'day';
718
+ type DateGrain = 'year' | 'month' | 'day' | 'time';
636
719
 
637
720
  const DAYS_PER_YEAR = 365.25;
638
721
 
639
- function grainFor(maxYears: number): DateGrain {
640
- if (maxYears >= 2) return 'year';
641
- if (maxYears >= 60 / DAYS_PER_YEAR) return 'month';
642
- return 'day';
722
+ /**
723
+ * A period length in the largest unit that still carries information.
724
+ *
725
+ * @remarks
726
+ * Every level was printed in years, which is right for a mahadasha and useless below it: a sookshma read "0.5 years" where a reader wants days, and a prana read "0 years" because rounding a period shorter than seven hours to one decimal place of a year is zero. The unit has to follow the level.
727
+ */
728
+ function formatDuration(years: number): string {
729
+ if (years >= 1) return `${formatNumber(years, 1)} years`;
730
+ const days = years * DAYS_PER_YEAR;
731
+ if (days >= 1) return `${formatNumber(days, days >= 10 ? 0 : 1)} days`;
732
+ const hours = days * 24;
733
+ if (hours >= 1) return `${formatNumber(hours, 1)} hours`;
734
+ return `${formatNumber(hours * 60, 0)} minutes`;
735
+ }
736
+
737
+ function grainFor(minYears: number): DateGrain {
738
+ if (minYears >= 2) return 'year';
739
+ if (minYears >= 60 / DAYS_PER_YEAR) return 'month';
740
+ if (minYears >= 1 / DAYS_PER_YEAR) return 'day';
741
+ return 'time';
643
742
  }
644
743
 
645
744
  /**
646
745
  * One end of a bar, at the chosen granularity.
647
746
  *
648
747
  * @remarks
649
- * Every grain carries the year. Day grain used to drop it on the grounds that the parent line states it, but a sookshma period routinely straddles new year, so a bar read `28 Dec - 3 Jan` with nothing saying which side moved. A dasha table is a date reference: a practitioner reads a boundary off it and writes it down.
748
+ * Every grain carries the year. Day grain used to drop it on the grounds that the parent line states it, but a sookshma period routinely straddles new year, so a bar read `28 Dec - 3 Jan` with nothing saying which side moved. A dasha table is a date reference: a practitioner reads a boundary off it and writes it down. Time grain carries the whole date for the same reason, since a prana period straddles midnight as readily as a sookshma one straddles new year.
650
749
  *
651
- * The API returns naive datetimes (`1990-01-15T14:30:00`), which are wall clocks in the timezone of the CHART, not instants. {@link resolveDisplayDate} pins them to UTC so a boundary landing in the DST gap of the viewer cannot silently shift a day.
750
+ * The API returns naive datetimes (`1990-01-15T14:30:00`), which are wall clocks in the timezone of the CHART, not instants. {@link resolveDisplayDate} pins them to UTC so a boundary landing in the DST gap of the viewer cannot silently shift a day, and formatting in that same zone is what keeps a printed clock time equal to the chart clock time for every viewer.
652
751
  */
653
752
  function formatBoundary(s: string, grain: DateGrain): string {
654
753
  if (grain === 'year') {
@@ -657,10 +756,12 @@ function formatBoundary(s: string, grain: DateGrain): string {
657
756
  }
658
757
  const { d, timeZone } = resolveDisplayDate(s);
659
758
  if (Number.isNaN(d.getTime())) return s;
660
- return d.toLocaleDateString('en', {
661
- day: grain === 'day' ? 'numeric' : undefined,
759
+ return d.toLocaleString('en', {
760
+ day: grain === 'month' ? undefined : 'numeric',
662
761
  month: 'short',
663
762
  year: 'numeric',
763
+ hour: grain === 'time' ? 'numeric' : undefined,
764
+ minute: grain === 'time' ? '2-digit' : undefined,
664
765
  timeZone,
665
766
  });
666
767
  }
@@ -5,6 +5,7 @@ import { RoxyDataElement } from '../utils/base-element.js';
5
5
  import { baseStyles } from '../utils/base-styles.js';
6
6
  import { formatSignPosition } from '../utils/degree.js';
7
7
  import { formatAyanamsa } from '../utils/format.js';
8
+ import { houseThemeLine, houseWords } from '../utils/house-themes.js';
8
9
  import {
9
10
  renderTablist,
10
11
  type TablistItem,
@@ -57,6 +58,11 @@ function chain(values: ReadonlyArray<string | number>): string {
57
58
  return [...new Set(values.map(String))].join(' > ');
58
59
  }
59
60
 
61
+ /** The same first-occurrence-wins fold {@link chain} applies, for the house wording beneath it, so the numbers and the words never disagree about how many houses there are. */
62
+ function dedupe(houses: readonly number[] | undefined): number[] {
63
+ return [...new Set(houses ?? [])];
64
+ }
65
+
60
66
  /**
61
67
  * KP (Krishnamurti Paddhati) chart. Renders /vedic-astrology/kp/chart: an
62
68
  * Ascendant summary, a planets-and-nodes table, a Placidus cusps table, and the
@@ -69,6 +75,11 @@ function chain(values: ReadonlyArray<string | number>): string {
69
75
  * The significators tab is the event-timing surface: house-wise (which planets
70
76
  * signify each house) and planet-wise (which houses each planet signifies),
71
77
  * both graded L1 to L4 with the API's own level labels shown as the legend.
78
+ *
79
+ * Every bare house number is captioned from the response `houseThemes` map, so
80
+ * "11, 6" reads "gains, enemies" and a cusp row says what that cusp is for. The
81
+ * words are the requested language and the requested `focus` lens, which is why
82
+ * they are read from the payload and never from a table held here.
72
83
  */
73
84
  @customElement('roxy-kp-chart')
74
85
  export class RoxyKpChart extends RoxyDataElement<KpChartResponse> {
@@ -181,6 +192,17 @@ export class RoxyKpChart extends RoxyDataElement<KpChartResponse> {
181
192
  .empty-cell {
182
193
  color: var(--roxy-muted, #71717a);
183
194
  }
195
+ /* House wording sits under its number, never beside it: these cells are
196
+ * nowrap, and a house list plus its words on one line would push the
197
+ * table well past the card. */
198
+ .themes {
199
+ display: block;
200
+ color: var(--roxy-muted, #71717a);
201
+ font-size: var(--roxy-text-xs, 0.75rem);
202
+ font-weight: var(--roxy-weight-normal, 400);
203
+ text-transform: none;
204
+ letter-spacing: normal;
205
+ }
184
206
  `,
185
207
  ];
186
208
 
@@ -325,12 +347,13 @@ export class RoxyKpChart extends RoxyDataElement<KpChartResponse> {
325
347
 
326
348
  private renderCusps() {
327
349
  const cusps = this.data?.cusps ?? [];
350
+ const themes = this.data?.houseThemes;
328
351
  if (!cusps.length)
329
352
  return html`<p class="roxy-empty" role="status">No cusps</p>`;
330
353
  return html`<table role="table">
331
354
  <caption class="roxy-sr-only">
332
- KP Placidus cusps: each house cusp with its position, sign lord, nakshatra and
333
- pada, star lord, sub lord, sub sub lord and KP number.
355
+ KP Placidus cusps: each house cusp with what it signifies, its position, sign
356
+ lord, nakshatra and pada, star lord, sub lord, sub sub lord and KP number.
334
357
  </caption>
335
358
  <thead>
336
359
  <tr>
@@ -347,7 +370,9 @@ export class RoxyKpChart extends RoxyDataElement<KpChartResponse> {
347
370
  <tbody>
348
371
  ${cusps.map(
349
372
  (c) => html`<tr>
350
- <td class="body num">${c.house}</td>
373
+ <td class="body num">
374
+ ${c.house}${this.renderThemes(houseThemeLine(c.house, themes))}
375
+ </td>
351
376
  <td class="num">
352
377
  ${typeof c.longitude === 'number' ? formatSignPosition(c.longitude) : (c.sign ?? '')}
353
378
  </td>
@@ -371,6 +396,7 @@ export class RoxyKpChart extends RoxyDataElement<KpChartResponse> {
371
396
  */
372
397
  private renderSignificators() {
373
398
  const sig = this.data?.significators;
399
+ const themes = this.data?.houseThemes;
374
400
  const houseWise = sig?.houseWise ?? [];
375
401
  const planetWise = sig?.planetWise ?? [];
376
402
  if (!houseWise.length && !planetWise.length)
@@ -399,7 +425,9 @@ export class RoxyKpChart extends RoxyDataElement<KpChartResponse> {
399
425
  <tbody>
400
426
  ${houseWise.map(
401
427
  (h) => html`<tr>
402
- <td class="body num">${h.house}</td>
428
+ <td class="body num">
429
+ ${h.house}${this.renderThemes(houseThemeLine(h.house, themes))}
430
+ </td>
403
431
  ${LEVELS.map((l) => this.renderCell(this.planetsAtLevel(h, l).join(', ')))}
404
432
  <td class="chain">${chain(h.all ?? [])}</td>
405
433
  </tr>`,
@@ -431,7 +459,9 @@ export class RoxyKpChart extends RoxyDataElement<KpChartResponse> {
431
459
  (p) => html`<tr>
432
460
  <td class="body">${p.planet}</td>
433
461
  ${LEVELS.map((l) => this.renderCell(this.housesAtLevel(p, l).join(', ')))}
434
- <td class="chain">${chain(p.allHouses ?? [])}</td>
462
+ <td class="chain">
463
+ ${chain(p.allHouses ?? [])}${this.renderThemes(houseWords(dedupe(p.allHouses), themes))}
464
+ </td>
435
465
  </tr>`,
436
466
  )}
437
467
  </tbody>
@@ -441,6 +471,11 @@ export class RoxyKpChart extends RoxyDataElement<KpChartResponse> {
441
471
  `;
442
472
  }
443
473
 
474
+ /** The house wording under a number cell, or nothing when the request did not ask for themes. */
475
+ private renderThemes(words: string) {
476
+ return words ? html`<span class="themes">${words}</span>` : nothing;
477
+ }
478
+
444
479
  /** An em-dash-free placeholder keeps an empty level cell from reading as missing data. */
445
480
  private renderCell(value: string) {
446
481
  return value
@@ -3,6 +3,7 @@ import { customElement } from 'lit/decorators.js';
3
3
  import type { KpRulingPlanetsResponse } from '../types/index.js';
4
4
  import { RoxyDataElement } from '../utils/base-element.js';
5
5
  import { baseStyles } from '../utils/base-styles.js';
6
+ import { houseWords } from '../utils/house-themes.js';
6
7
 
7
8
  /**
8
9
  * KP ruling planets card. Renders /vedic-astrology/kp/ruling-planets: the day
@@ -10,6 +11,12 @@ import { baseStyles } from '../utils/base-styles.js';
10
11
  * lord, sub-sub lord), the consolidated ruling-planet list ordered by
11
12
  * strength, and, when birth data is supplied, the house significators per
12
13
  * planet. The primary horary timing tool in KP astrology.
14
+ *
15
+ * @remarks
16
+ * `significators` and `houseThemes` both arrive only when the request carried
17
+ * birth data, so the significator table and its house wording appear together
18
+ * or not at all. The wording is read from the response, never from a table held
19
+ * here, so it follows the requested language and the requested `focus` lens.
13
20
  */
14
21
  @customElement('roxy-kp-ruling-planets')
15
22
  export class RoxyKpRulingPlanets extends RoxyDataElement<KpRulingPlanetsResponse> {
@@ -114,6 +121,17 @@ export class RoxyKpRulingPlanets extends RoxyDataElement<KpRulingPlanetsResponse
114
121
  font-size: var(--roxy-text-xs, 0.75rem);
115
122
  letter-spacing: 0.04em;
116
123
  }
124
+ .num {
125
+ font-variant-numeric: tabular-nums;
126
+ }
127
+ /* The house wording sits under its numbers rather than beside them: a
128
+ * planet can signify eight houses, and one line of both would push the
129
+ * table past the card on a phone. */
130
+ .themes {
131
+ display: block;
132
+ color: var(--roxy-muted, #71717a);
133
+ font-size: var(--roxy-text-xs, 0.75rem);
134
+ }
117
135
  `,
118
136
  ];
119
137
 
@@ -171,7 +189,8 @@ export class RoxyKpRulingPlanets extends RoxyDataElement<KpRulingPlanetsResponse
171
189
  significators.length
172
190
  ? html`<table>
173
191
  <caption class="roxy-sr-only">
174
- House significators: each ruling planet and the houses it signifies.
192
+ House significators: each ruling planet, the houses it signifies, and what
193
+ those houses stand for.
175
194
  </caption>
176
195
  <thead>
177
196
  <tr>
@@ -180,12 +199,16 @@ export class RoxyKpRulingPlanets extends RoxyDataElement<KpRulingPlanetsResponse
180
199
  </tr>
181
200
  </thead>
182
201
  <tbody>
183
- ${significators.map(
184
- (s) => html`<tr>
202
+ ${significators.map((s) => {
203
+ const words = houseWords(s.signifies, d.houseThemes);
204
+ return html`<tr>
185
205
  <td>${s.planet}</td>
186
- <td>${(s.signifies ?? []).join(', ')}</td>
187
- </tr>`,
188
- )}
206
+ <td>
207
+ <span class="num">${(s.signifies ?? []).join(', ')}</span>
208
+ ${words ? html`<span class="themes">${words}</span>` : nothing}
209
+ </td>
210
+ </tr>`;
211
+ })}
189
212
  </tbody>
190
213
  </table>`
191
214
  : nothing
@@ -1,6 +1,7 @@
1
1
  import { css, html, nothing } from 'lit';
2
2
  import { customElement } from 'lit/decorators.js';
3
3
  import type {
4
+ GetAvasthaResponse,
4
5
  GetCenterResponse,
5
6
  GetCompoundNumberResponse,
6
7
  GetGateResponse,
@@ -25,7 +26,8 @@ type ReferenceData =
25
26
  | GetGateResponse
26
27
  | GetCenterResponse
27
28
  | GetNumberMeaningResponse
28
- | GetCompoundNumberResponse;
29
+ | GetCompoundNumberResponse
30
+ | GetAvasthaResponse;
29
31
 
30
32
  /** Keys used to derive the title, in priority order. */
31
33
  const TITLE_KEYS = ['name', 'english', 'title'];