@roxyapi/ui 0.18.2 → 0.18.3

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/components/dasha-timeline.ts", "../../src/utils/base-element.ts", "../../src/utils/base-styles.ts", "../../src/utils/key-guard.ts", "../../src/utils/fetch-controller.ts", "../../src/utils/markup-data.ts", "../../src/utils/disclosure.ts", "../../src/utils/format.ts", "../../src/utils/interp-accordion.ts", "../../src/utils/tablist.ts"],
4
- "sourcesContent": ["import { css, html, nothing } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport type {\n\tGetCurrentDashaResponse,\n\tGetMajorDashasResponse,\n\tGetPratyantardashasResponse,\n\tGetSookshmaDashasResponse,\n\tGetSubDashasResponse,\n} from '../types/index.js';\nimport { RoxyDataElement } from '../utils/base-element.js';\nimport { baseStyles } from '../utils/base-styles.js';\nimport { disclosureStyles } from '../utils/disclosure.js';\nimport { formatDate, formatNumber } from '../utils/format.js';\nimport {\n\ttype InterpSection,\n\tinterpAccordionStyles,\n\trenderInterpAccordion,\n} from '../utils/interp-accordion.js';\nimport { renderTablist, tablistStyles } from '../utils/tablist.js';\n\ntype DashaData =\n\t| GetCurrentDashaResponse\n\t| GetMajorDashasResponse\n\t| GetSubDashasResponse\n\t| GetPratyantardashasResponse\n\t| GetSookshmaDashasResponse;\n\ntype DashaPeriod = GetMajorDashasResponse['mahadashas'][number];\ntype Remaining = GetCurrentDashaResponse['remainingInMahadasha'];\n\n/**\n * The Vimshottari level a listed period sits at, so no view ever labels an\n * antardasha a mahadasha.\n *\n * Read from the RESPONSE, not from the `period` attribute: all three drill-down\n * routes are `period=\"sub\"`, and only the payload says whether the list is\n * antardashas, pratyantardashas or sookshma dashas.\n */\nfunction levelOf(d: DashaData): string {\n\tif ('sookshmaDashas' in d) return 'Sookshma';\n\tif ('pratyantardashas' in d) return 'Pratyantardasha';\n\tif ('antardashas' in d) return 'Antardasha';\n\treturn 'Mahadasha';\n}\n\n/** The parent period a drill-down response hangs off, with the level it sits at. */\nfunction parentOf(\n\td: DashaData,\n): { label: string; period: DashaPeriod } | undefined {\n\tif ('pratyantardashaPeriod' in d && d.pratyantardashaPeriod)\n\t\treturn { label: 'Pratyantardasha', period: d.pratyantardashaPeriod };\n\tif ('antardashaPeriod' in d && d.antardashaPeriod)\n\t\treturn { label: 'Antardasha', period: d.antardashaPeriod };\n\tif ('mahadashaPeriod' in d && d.mahadashaPeriod)\n\t\treturn { label: 'Mahadasha', period: d.mahadashaPeriod };\n\treturn undefined;\n}\n\n/** \"8y 11m 5d\", the form a dasha reader expects for a remaining balance. */\nfunction formatBalance(b: Remaining | undefined): string {\n\tif (!b) return '';\n\tconst parts: string[] = [];\n\tif (b.years) parts.push(`${b.years}y`);\n\tif (b.months) parts.push(`${b.months}m`);\n\tif (b.days) parts.push(`${b.days}d`);\n\treturn parts.length ? parts.join(' ') : '0d';\n}\n\n/** \"Jun 17, 2018 to Jun 17, 2035\" for the accordion aside. */\nfunction formatSpan(p: { startDate?: string; endDate?: string }): string {\n\tconst start = p.startDate ? formatDate(p.startDate) : '';\n\tconst end = p.endDate ? formatDate(p.endDate) : '';\n\tif (start && end) return `${start} to ${end}`;\n\treturn start || end;\n}\n\n/**\n * Dasha timeline. Renders /vedic-astrology/dasha/{current,major,sub/{...}}.\n *\n * @remarks\n * Default mode shows the active mahadasha, antardasha and pratyantardasha with\n * the reading each one carries. `period=\"major\"` draws the full 120-year\n * Vimshottari timeline; `period=\"sub\"` draws the antardashas inside one\n * mahadasha and states which mahadasha they sit in, since an antardasha means\n * nothing without its parent lord.\n */\n@customElement('roxy-dasha-timeline')\nexport class RoxyDashaTimeline extends RoxyDataElement<DashaData> {\n\tstatic styles = [\n\t\tbaseStyles,\n\t\tdisclosureStyles,\n\t\tinterpAccordionStyles,\n\t\ttablistStyles,\n\t\tcss`.wrap{gap:var(--roxy-space-md,1rem);display:grid}.head{justify-content:space-between;align-items:center;gap:var(--roxy-space-sm,.5rem);flex-wrap:wrap;display:flex}.title{font-size:var(--roxy-text-lg,1.125rem);font-weight:var(--roxy-weight-bold,600);margin:0}.nakshatra{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-sm,.875rem)}.current{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-md,1rem);box-shadow:var(--roxy-shadow-sm);grid-template-columns:repeat(auto-fit,minmax(10rem,1fr));display:grid}.current div span:first-child{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);text-transform:uppercase;letter-spacing:.06em;display:block}.current div strong{font-size:var(--roxy-text-base,1rem);color:var(--roxy-fg,#0a0a0a)}.current div small{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);display:block}.parent{font-size:var(--roxy-text-sm,.875rem);color:var(--roxy-muted,#71717a);border-left:2px solid var(--roxy-border,#e4e4e7);padding-left:var(--roxy-space-sm,.5rem);margin:0}.timeline{gap:var(--roxy-space-xs,.25rem);display:grid}.bar{gap:var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-sm,.875rem);grid-template-columns:5rem 1fr 8rem;align-items:center;display:grid}.bar.now strong{color:var(--roxy-accent-ink,#b45309)}.now-badge{font-size:var(--roxy-text-xs,.75rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-accent-ink,#b45309);text-transform:uppercase;letter-spacing:.06em;margin-left:.4em;display:inline-block}.bar-track{background:var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-full,9999px);height:14px;position:relative;overflow:hidden}.bar-fill{background:var(--roxy-accent,#f59e0b);opacity:.45;height:100%;transition:width var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1));display:block}.bar-now .bar-fill{opacity:1}.bar-progress{background:var(--roxy-accent-ink,#b45309);width:2px;box-shadow:0 0 0 2px color-mix(in srgb, var(--roxy-accent,#f59e0b) 35%, transparent);border-radius:2px;position:absolute;top:-2px;bottom:-2px}.dates{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);font-variant-numeric:tabular-nums;text-align:right}[role=tabpanel]{padding-top:var(--roxy-space-md,1rem)}.frame{gap:var(--roxy-space-sm,.5rem);grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));margin:0;display:grid}.frame dt{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);text-transform:uppercase;letter-spacing:.06em}.frame dd{font-size:var(--roxy-text-sm,.875rem);color:var(--roxy-fg,#0a0a0a);font-variant-numeric:tabular-nums;margin:0}.block{border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);background:var(--roxy-surface,#fff);padding:var(--roxy-space-md,1rem)}`,\n\t];\n\n\t/**\n\t * Which dasha endpoint fed this element. `sub`, `antara` and `sookshma` are the\n\t * three drill-down levels and render identically; they stay distinct because\n\t * each maps one-to-one onto its endpoint binding, which is what lets a widget\n\t * pick a level. The LABELS come from the payload, not from here.\n\t */\n\t@property({ type: String, reflect: true })\n\tperiod: 'current' | 'major' | 'sub' | 'antara' | 'sookshma' = 'current';\n\n\t/** Which panel is showing. Reset guarded in renderData when the data changes shape. */\n\t@state()\n\tprivate view: 'timeline' | 'readings' | 'frame' = 'timeline';\n\n\t/** True for any of the drill-down levels, which share one layout. */\n\tprivate get isDrillDown(): boolean {\n\t\treturn this.period !== 'current' && this.period !== 'major';\n\t}\n\n\tprotected renderEmpty() {\n\t\treturn html`<div class=\"roxy-empty\" role=\"status\">No dasha data</div>`;\n\t}\n\n\tprotected renderData(d: DashaData) {\n\t\tconst periods = this.collectPeriods(d);\n\t\tconst maxYears = periods.length\n\t\t\t? Math.max(...periods.map((p) => p.durationYears))\n\t\t\t: 0;\n\t\tconst readings = this.readings(d, periods);\n\t\tconst frame = this.frameRows(d);\n\n\t\t// One panel per kind of question a reader asks: when do the periods run,\n\t\t// what do they mean, and what chart produced them. Without the split the\n\t\t// card became a single column of periods, prose and provenance, and the\n\t\t// dates (the reason anyone opens it) were pushed below the fold.\n\t\tconst tabs = [\n\t\t\t{ id: 'timeline' as const, label: 'Timeline' },\n\t\t\t...(readings.length\n\t\t\t\t? [{ id: 'readings' as const, label: `Readings (${readings.length})` }]\n\t\t\t\t: []),\n\t\t\t...(frame.length ? [{ id: 'frame' as const, label: 'Chart' }] : []),\n\t\t];\n\t\t// A tab that no longer exists (data changed under a selection) must not\n\t\t// blank the card, so fall back to the first.\n\t\tconst view = tabs.some((t) => t.id === this.view) ? this.view : 'timeline';\n\n\t\treturn html`<div class=\"wrap\" aria-label=\"Dasha timeline\"><header class=\"head\"><h2 class=\"title\">${this.heading(d)}</h2>${this.renderLordChain(d)}</header>${this.renderParentMahadasha(d)} ${\n\t\t\t\ttabs.length > 1\n\t\t\t\t\t? renderTablist({\n\t\t\t\t\t\t\titems: tabs,\n\t\t\t\t\t\t\tactive: view,\n\t\t\t\t\t\t\tonSelect: (v) => {\n\t\t\t\t\t\t\t\tthis.view = v;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tlabel: 'Dasha views',\n\t\t\t\t\t\t\tidPrefix: 'roxy-dasha',\n\t\t\t\t\t\t\tcontrols: true,\n\t\t\t\t\t\t})\n\t\t\t\t\t: nothing\n\t\t\t}<div id=\"roxy-dasha-panel-${view}\" role=\"tabpanel\" tabindex=\"0\" aria-labelledby=\"${tabs.length > 1 ? `roxy-dasha-tab-${view}` : nothing}\">${\n\t\t\t\t\tview === 'timeline'\n\t\t\t\t\t\t? html`${this.period === 'current' ? this.renderCurrent(d) : nothing} ${\n\t\t\t\t\t\t\t\tperiods.length > 0\n\t\t\t\t\t\t\t\t\t? html`<div class=\"timeline\" role=\"list\">${periods.map((p) => this.renderBar(p, maxYears, grainFor(maxYears)))}</div>`\n\t\t\t\t\t\t\t\t\t: nothing\n\t\t\t\t\t\t\t}`\n\t\t\t\t\t\t: nothing\n\t\t\t\t} ${\n\t\t\t\t\tview === 'readings'\n\t\t\t\t\t\t? renderInterpAccordion(\n\t\t\t\t\t\t\t\treadings,\n\t\t\t\t\t\t\t\t'roxy-dasha',\n\t\t\t\t\t\t\t\treadings.length === 1 ? 'Reading' : 'Readings',\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: nothing\n\t\t\t\t} ${view === 'frame' ? this.renderFrame(frame) : nothing}</div></div>`;\n\t}\n\n\t/**\n\t * The full lord chain a drill-down sits under, e.g. Saturn > Venus > Rahu.\n\t *\n\t * The response carries every ancestor lord on each period, and naming only the\n\t * immediate parent leaves a reader at the sookshma level unable to tell which\n\t * branch of the chart they are looking at.\n\t */\n\tprivate renderLordChain(d: DashaData) {\n\t\tconst chain = [\n\t\t\t'mahadashaLord' in d ? d.mahadashaLord : undefined,\n\t\t\t'antardashaLord' in d ? d.antardashaLord : undefined,\n\t\t\t'pratyantardashaLord' in d ? d.pratyantardashaLord : undefined,\n\t\t].filter(Boolean);\n\t\tif (chain.length > 1) {\n\t\t\treturn html`<div class=\"nakshatra\">${chain.join(' \\u203a ')}</div>`;\n\t\t}\n\t\tif ('nakshatraName' in d && d.nakshatraName) {\n\t\t\treturn html`<div class=\"nakshatra\">Moon nakshatra: ${d.nakshatraName} ${'nakshatraLord' in d && d.nakshatraLord ? html`(lord ${d.nakshatraLord})` : nothing}</div>`;\n\t\t}\n\t\treturn nothing;\n\t}\n\n\t/**\n\t * Provenance rows: the chart every date in this response was derived from.\n\t *\n\t * These are the fields that let a reader reconcile our dates against another\n\t * calculator. The sidereal frame is the one that actually explains a\n\t * disagreement, since Lahiri and the KP variants move every boundary by weeks,\n\t * so it is shown rather than left in the JSON.\n\t */\n\tprivate frameRows(d: DashaData): Array<[string, string]> {\n\t\tconst rows: Array<[string, string]> = [];\n\t\tif ('nakshatraName' in d && d.nakshatraName) {\n\t\t\tconst n =\n\t\t\t\t'moonNakshatra' in d && d.moonNakshatra\n\t\t\t\t\t? ` (${d.moonNakshatra} of 27)`\n\t\t\t\t\t: '';\n\t\t\trows.push(['Moon nakshatra', `${d.nakshatraName}${n}`]);\n\t\t}\n\t\tif ('nakshatraLord' in d && d.nakshatraLord) {\n\t\t\trows.push(['Nakshatra lord', d.nakshatraLord]);\n\t\t}\n\t\tif ('moonLongitude' in d && typeof d.moonLongitude === 'number') {\n\t\t\trows.push([\n\t\t\t\t'Moon longitude',\n\t\t\t\t`${formatNumber(d.moonLongitude, 3)}\\u00b0 sidereal`,\n\t\t\t]);\n\t\t}\n\t\tif ('ayanamsaType' in d && d.ayanamsaType) {\n\t\t\tconst deg =\n\t\t\t\t'ayanamsa' in d && typeof d.ayanamsa === 'number'\n\t\t\t\t\t? ` (${formatNumber(d.ayanamsa, 3)}\\u00b0)`\n\t\t\t\t\t: '';\n\t\t\trows.push(['Ayanamsa', `${d.ayanamsaType}${deg}`]);\n\t\t}\n\t\tif ('birthDashaBalance' in d && d.birthDashaBalance) {\n\t\t\tconst lord =\n\t\t\t\t'nakshatraLord' in d && d.nakshatraLord ? `${d.nakshatraLord} ` : '';\n\t\t\trows.push([\n\t\t\t\t'Balance at birth',\n\t\t\t\t`${formatBalance(d.birthDashaBalance)} of the opening ${lord}mahadasha`,\n\t\t\t]);\n\t\t}\n\t\tif ('totalYears' in d && typeof d.totalYears === 'number') {\n\t\t\trows.push(['Cycle length', `${d.totalYears} years`]);\n\t\t}\n\t\treturn rows;\n\t}\n\n\tprivate renderFrame(rows: Array<[string, string]>) {\n\t\treturn html`<dl class=\"frame\">${rows.map(([label, value]) => html`<div><dt>${label}</dt><dd>${value}</dd></div>`)}</dl>`;\n\t}\n\n\tprivate heading(d: DashaData): string {\n\t\tif (this.period === 'major') return 'Vimshottari Mahadasha';\n\t\tif (this.isDrillDown) {\n\t\t\tconst parent = parentOf(d);\n\t\t\tconst level = levelOf(d);\n\t\t\treturn parent\n\t\t\t\t? `${level}s in ${parent.period.planet} ${parent.label}`\n\t\t\t\t: `${level}s`;\n\t\t}\n\t\treturn 'Active dashas';\n\t}\n\n\t/**\n\t * Drill-down modes list sub-periods inside one parent, so name the parent and\n\t * its span. A sub-period means nothing without its parent lord.\n\t *\n\t * `nominalStartDate` is present only when birth cut the parent short, which is\n\t * also why such a list can hold fewer than nine rows: the sub-periods that\n\t * finished before the native was born are not part of the chart. Saying so\n\t * turns a surprising short list into an explained one.\n\t */\n\tprivate renderParentMahadasha(d: DashaData) {\n\t\tconst parent = parentOf(d);\n\t\tif (!parent) return nothing;\n\t\tconst p = parent.period;\n\t\tconst span = formatSpan(p);\n\t\tconst began = p.nominalStartDate ? formatDate(p.nominalStartDate) : '';\n\t\treturn html`<p class=\"parent\">Inside the <strong>${p.planet}</strong> ${parent.label}${span ? `, ${span}` : ''} ${typeof p.durationYears === 'number' ? `(${formatNumber(p.durationYears, 1)} years)` : ''}. ${\n\t\t\t\tbegan\n\t\t\t\t\t? html`<br>It began ${began}, before birth, so only the sub-periods running after the birth date are listed.`\n\t\t\t\t\t: nothing\n\t\t\t}</p>`;\n\t}\n\n\t/**\n\t * Every reading the response carries, behind one exclusive accordion. Current\n\t * mode has four (mahadasha, antardasha, pratyantardasha, sookshma); drill-down\n\t * modes lead with the parent period reading, then the sub-period running now;\n\t * major mode shows the mahadasha running now.\n\t */\n\tprivate readings(d: DashaData, periods: DashaPeriod[]): InterpSection[] {\n\t\tconst sections: InterpSection[] = [];\n\n\t\tconst parent = parentOf(d);\n\t\tif (parent?.period.interpretation) {\n\t\t\tsections.push({\n\t\t\t\tlabel: `${parent.period.planet} ${parent.label}`,\n\t\t\t\taside: formatSpan(parent.period),\n\t\t\t\tbody: parent.period.interpretation,\n\t\t\t});\n\t\t}\n\n\t\tif ('mahadasha' in d) {\n\t\t\tconst levels = [\n\t\t\t\t['Mahadasha', d.mahadasha, d.remainingInMahadasha],\n\t\t\t\t['Antardasha', d.antardasha, d.remainingInAntardasha],\n\t\t\t\t['Pratyantardasha', d.pratyantardasha, d.remainingInPratyantardasha],\n\t\t\t\t['Sookshma', d.sookshmaDasha, d.remainingInSookshma],\n\t\t\t] as const;\n\t\t\tfor (const [label, period, remaining] of levels) {\n\t\t\t\tif (!period?.interpretation) continue;\n\t\t\t\tconst left = formatBalance(remaining);\n\t\t\t\tsections.push({\n\t\t\t\t\tlabel: `${period.planet} ${label}`,\n\t\t\t\t\taside: left ? `${left} left` : formatSpan(period),\n\t\t\t\t\tbody: period.interpretation,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst active = periods.find((p) => this.isCurrent(p));\n\t\tif (active?.interpretation) {\n\t\t\tsections.push({\n\t\t\t\tlabel: `${active.planet} ${levelOf(d)}`,\n\t\t\t\taside: formatSpan(active),\n\t\t\t\tbody: active.interpretation,\n\t\t\t});\n\t\t}\n\n\t\treturn sections;\n\t}\n\n\tprivate renderCurrent(d: DashaData) {\n\t\tif (!('mahadasha' in d)) return nothing;\n\t\tconst levels = [\n\t\t\t['Mahadasha', d.mahadasha, d.remainingInMahadasha],\n\t\t\t['Antardasha', d.antardasha, d.remainingInAntardasha],\n\t\t\t['Pratyantardasha', d.pratyantardasha, d.remainingInPratyantardasha],\n\t\t\t['Sookshma', d.sookshmaDasha, d.remainingInSookshma],\n\t\t] as const;\n\t\treturn html`<div class=\"current\">${levels.map(([label, period, remaining]) => {\n\t\t\t\tif (!period) return nothing;\n\t\t\t\tconst left = formatBalance(remaining);\n\t\t\t\treturn html`<div><span>${label}</span> <strong>${period.planet}</strong> ${left ? html`<small>${left} left</small>` : nothing}</div>`;\n\t\t\t})}</div>`;\n\t}\n\n\tprivate collectPeriods(d: DashaData): DashaPeriod[] {\n\t\tif ('mahadashas' in d && d.mahadashas?.length) return d.mahadashas;\n\t\tif ('antardashas' in d && d.antardashas?.length) return d.antardashas;\n\t\tif ('pratyantardashas' in d && d.pratyantardashas?.length)\n\t\t\treturn d.pratyantardashas;\n\t\tif ('sookshmaDashas' in d && d.sookshmaDashas?.length)\n\t\t\treturn d.sookshmaDashas;\n\t\treturn [];\n\t}\n\n\t/** True when the current wall-clock time falls between the period's start and end. */\n\tprivate isCurrent(p: DashaPeriod): boolean {\n\t\tif (!p.startDate || !p.endDate) return false;\n\t\tconst now = Date.now();\n\t\tconst start = Date.parse(p.startDate);\n\t\tconst end = Date.parse(p.endDate);\n\t\tif (Number.isNaN(start) || Number.isNaN(end)) return false;\n\t\treturn now >= start && now < end;\n\t}\n\n\t/**\n\t * Fractional progress (0..1) through a period at the current time. Used to\n\t * draw a vertical \"now\" marker inside the active bar. Returns -1 outside the\n\t * period so the caller can skip the marker.\n\t */\n\tprivate progressIn(p: DashaPeriod): number {\n\t\tif (!p.startDate || !p.endDate) return -1;\n\t\tconst start = Date.parse(p.startDate);\n\t\tconst end = Date.parse(p.endDate);\n\t\tconst now = Date.now();\n\t\tif (\n\t\t\tNumber.isNaN(start) ||\n\t\t\tNumber.isNaN(end) ||\n\t\t\tnow < start ||\n\t\t\tnow >= end ||\n\t\t\tend <= start\n\t\t) {\n\t\t\treturn -1;\n\t\t}\n\t\treturn (now - start) / (end - start);\n\t}\n\n\tprivate renderBar(p: DashaPeriod, max: number, grain: DateGrain) {\n\t\tconst years = p.durationYears;\n\t\tconst width = max > 0 ? (years / max) * 100 : 0;\n\t\tconst current = this.isCurrent(p);\n\t\tconst progress = current ? this.progressIn(p) : -1;\n\t\tconst trackClass = current ? 'bar-track bar-now' : 'bar-track';\n\t\treturn html`<div class=\"${current ? 'bar now' : 'bar'}\" role=\"listitem\" aria-current=\"${current ? 'time' : 'false'}\"><span><strong>${p.planet}</strong>${current ? html`<span class=\"now-badge\">Now</span>` : nothing} </span><span class=\"${trackClass}\"><span class=\"bar-fill\" style=\"width:${width}%\"></span> ${\n\t\t\t\t\tprogress >= 0\n\t\t\t\t\t\t? html`<span class=\"bar-progress\" style=\"left:${progress * width}%\" aria-hidden=\"true\"></span>`\n\t\t\t\t\t\t: nothing\n\t\t\t\t} </span><span class=\"dates\">${p.startDate ? formatBoundary(p.startDate, grain) : ''} ${p.endDate ? html`- ${formatBoundary(p.endDate, grain)}` : ''}</span></div>`;\n\t}\n}\n\n/**\n * How precise the bar date column has to be, chosen from the LONGEST period in\n * the set.\n *\n * A Mahadasha spans years, so a bare year reads cleanly and keeps the column\n * narrow. A Sookshma spans days: printed as a year, every one of the nine rows\n * reads \"1990 - 1990\" and the column carries no information at exactly the level\n * a reader opened the drill-down to see.\n */\ntype DateGrain = 'year' | 'month' | 'day';\n\nconst DAYS_PER_YEAR = 365.25;\n\nfunction grainFor(maxYears: number): DateGrain {\n\tif (maxYears >= 2) return 'year';\n\tif (maxYears >= 60 / DAYS_PER_YEAR) return 'month';\n\treturn 'day';\n}\n\n/** One end of a bar, at the chosen granularity. Day grain drops the year: these rows sit under a parent line that already states it, and the column is only 8rem wide. */\nfunction formatBoundary(s: string, grain: DateGrain): string {\n\tif (grain === 'year') {\n\t\tconst m = s.match(/^(\\d{4})/);\n\t\treturn m ? m[1] : s;\n\t}\n\tconst d = new Date(s);\n\tif (Number.isNaN(d.getTime())) return s;\n\tconst month = d.toLocaleString('en', { month: 'short' });\n\treturn grain === 'month'\n\t\t? `${month} ${d.getFullYear()}`\n\t\t: `${d.getDate()} ${month}`;\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'roxy-dasha-timeline': RoxyDashaTimeline;\n\t}\n}\n", "import {\n\ttype CSSResultGroup,\n\thtml,\n\tLitElement,\n\ttype PropertyValues,\n} from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { baseStyles } from './base-styles.js';\nimport { buildRequest, FetchController } from './fetch-controller.js';\nimport { MarkupDataController } from './markup-data.js';\n\n/**\n * Shared base for every data-driven Roxy component. Consolidates the things every component used to repeat by hand and adds the self-contained, drop-in behavior: controlled-mode hydration, an opt-in self-fetch (form, request, loading, error, empty), the typed `data` slot, and the render switch. A subclass implements one method, {@link RoxyDataElement.renderData}.\n *\n * @remarks\n * Two render modes, one component, which is the whole drop-in contract:\n *\n * - Controlled: a server (WordPress, JSX SSR, static HTML) fetches the response and injects it as a direct-child `<script type=\"application/json\" class=\"roxy-data\">`. {@link MarkupDataController} hydrates `data` from it on connect. No key reaches the browser. This is the path the WordPress plugin drives, and it is unchanged by the base class.\n * - Uncontrolled: no data is injected, but a `data-endpoint` and a `pk_` `publishable-key` are set. The component renders its own `<roxy-endpoint-form>` (an internal detail, never placed by the consumer), and on submit fetches through {@link FetchController}, which refuses any non-publishable key. The result populates `data` and the component renders it.\n *\n * The JavaScript `data` property always wins over markup, so a host that assigns `el.data = \u2026` after upgrade is authoritative.\n *\n * Self-fetch needs `<roxy-endpoint-form>` (and `<roxy-location-search>`) registered. The CDN bundle and the full `@roxyapi/ui` entry register everything; per-component ESM consumers that want self-fetch import the form component too.\n *\n * @example\n * ```ts\n * @customElement('roxy-dream-card')\n * export class RoxyDreamCard extends RoxyDataElement<GetDreamSymbolResponse> {\n * static styles = [baseStyles, css`.card { \u2026 }`];\n * protected renderData(d: GetDreamSymbolResponse) {\n * return html`<article class=\"card\">\u2026</article>`;\n * }\n * protected renderEmpty() {\n * return html`<div class=\"roxy-empty\" role=\"status\">No dream symbol</div>`;\n * }\n * }\n * ```\n */\nexport abstract class RoxyDataElement<T = unknown> extends LitElement {\n\tstatic styles: CSSResultGroup = [baseStyles];\n\n\t/** Typed RoxyAPI response. Assigned in JavaScript, hydrated from the roxy-data island, or set by a self-fetch. */\n\t@property({ attribute: false })\n\tdata: T | null = null;\n\n\t/** Endpoint path for self-fetch, e.g. \"astrology/natal-chart\" or \"dreams/symbols/{id}\". Empty disables self-fetch (controlled mode only). */\n\t@property({ type: String, attribute: 'data-endpoint' })\n\tendpoint = '';\n\n\t/** HTTP method for self-fetch. */\n\t@property({ type: String })\n\tmethod: 'GET' | 'POST' = 'POST';\n\n\t/** Browser-safe publishable key (pk_) for self-fetch. A secret key is refused client-side. */\n\t@property({ type: String, attribute: 'publishable-key' })\n\tpublishableKey?: string;\n\n\t/** Override the API origin for self-hosted or proxied deployments. */\n\t@property({ type: String, attribute: 'base-url' })\n\tbaseUrl?: string;\n\n\t/** Override the OpenAPI spec URL the self-fetch form introspects. */\n\t@property({ type: String, attribute: 'spec-url' })\n\tspecUrl?: string;\n\n\t/** Consumer backend route that proxies the request (holds the secret key). When set, self-fetch POSTs the request here instead of calling RoxyAPI directly, so no key reaches the browser. The server-rendered (WordPress) path. */\n\t@property({ type: String, attribute: 'submit-url' })\n\tsubmitUrl?: string;\n\n\t/** Persist the last self-fetch form values in sessionStorage (keyed by endpoint) and prefill the form on reload. */\n\t@property({ type: Boolean })\n\tremember = false;\n\n\t/** Override the self-fetch form's submit-button label. Empty derives one from the endpoint. */\n\t@property({ type: String, attribute: 'submit-label' })\n\tsubmitLabel?: string;\n\n\t/** Render a small \"Spiritual data by RoxyAPI\" credit under a self-fetch or auto-mount result. Off by default; any value except \"off\"/\"false\" enables it. The one-tag widgets script turns it on unless data-attribution=\"off\". Never shown in controlled mode. */\n\t@property({ type: String })\n\tattribution?: string;\n\n\t/** True while an uncontrolled self-fetch is in flight. Public so {@link FetchController} can drive it. */\n\t@state()\n\tloading = false;\n\n\t/** Message from a failed self-fetch, or null. Public so {@link FetchController} can drive it. */\n\t@state()\n\terror: string | null = null;\n\n\t/**\n\t * True once a self-fetch (not a consumer-assigned or island-hydrated `data`) produced the current result. It gates the interactive result affordances, so controlled mode never shows an Edit control or a sticky picker.\n\t */\n\t@state()\n\tprivate selfFetched = false;\n\n\t/** True when the visitor asked to edit a self-fetch result, so the form is restored over the result. */\n\t@state()\n\tprivate editing = false;\n\n\t/** True when the last self-fetch form was a single-enum picker, so it stays visible above the result and a change refetches. */\n\t@state()\n\tprivate sticky = false;\n\n\t/** Last submitted form values (nested per group), kept in memory to restore the form on Edit and to prefill the sticky picker. */\n\tprivate lastValues?: Record<string, unknown>;\n\n\tprivate fetcher: FetchController<T>;\n\n\tconstructor() {\n\t\tsuper();\n\t\t// Controlled mode: hydrate `data` from a direct-child roxy-data island when\n\t\t// no JS property was assigned. Keyless; the server already fetched.\n\t\tnew MarkupDataController<T>(this);\n\t\tthis.fetcher = new FetchController<T>(this);\n\t}\n\n\tprotected willUpdate(changed: PropertyValues): void {\n\t\tif (changed.has('publishableKey')) {\n\t\t\tthis.fetcher.publishableKey = this.publishableKey;\n\t\t}\n\t\tif (changed.has('baseUrl') && this.baseUrl) {\n\t\t\tthis.fetcher.baseUrl = this.baseUrl;\n\t\t}\n\t\tif (changed.has('submitUrl')) {\n\t\t\tthis.fetcher.submitUrl = this.submitUrl;\n\t\t}\n\t}\n\n\trender(): unknown {\n\t\tif (this.loading) return this.renderLoading();\n\t\tif (this.error != null) return this.renderError(this.error);\n\t\tif (this.data != null) {\n\t\t\t// Controlled mode (consumer-assigned or island-hydrated data) renders the\n\t\t\t// result alone, byte-identical to before: no picker, no Edit. The one\n\t\t\t// exception is the widgets auto-mount attrs-complete path, which assigns\n\t\t\t// data directly AND sets `attribution`; a real controlled consumer never\n\t\t\t// sets the attribute, so this stays byte-identical for them.\n\t\t\tif (!this.selfFetched) {\n\t\t\t\treturn this.showAttribution()\n\t\t\t\t\t? html`${this.renderData(this.data)}${this.renderAttribution()}`\n\t\t\t\t\t: this.renderData(this.data);\n\t\t\t}\n\t\t\tif (this.editing) return this.renderForm();\n\t\t\treturn this.renderResult(this.data);\n\t\t}\n\t\treturn this.renderNoData();\n\t}\n\n\t/** Render the populated response. The single method every component implements. */\n\tprotected abstract renderData(data: T): unknown;\n\n\t/**\n\t * A self-fetch result plus its re-query affordance. A single-enum form keeps its picker above the result so a new selection refetches (a sign switch is a new reading); any other form gets a compact Edit control that restores the form with the previous values.\n\t */\n\tprotected renderResult(data: T): unknown {\n\t\tconst body = this.sticky\n\t\t\t? html`${this.renderForm()}${this.renderData(data)}`\n\t\t\t: html`<div class=\"roxy-edit-bar\"><button type=\"button\" class=\"roxy-edit\" @click=\"${this.onEdit}\">Edit query</button></div>${this.renderData(data)}`;\n\t\treturn this.showAttribution()\n\t\t\t? html`${body}${this.renderAttribution()}`\n\t\t\t: body;\n\t}\n\n\tprivate onEdit = () => {\n\t\tthis.editing = true;\n\t};\n\n\t/** True when the attribution credit renders: the attribute is present and not explicitly disabled. */\n\tprivate showAttribution(): boolean {\n\t\treturn (\n\t\t\tthis.attribution != null &&\n\t\t\tthis.attribution !== 'off' &&\n\t\t\tthis.attribution !== 'false'\n\t\t);\n\t}\n\n\t/** Small muted credit under a self-fetch or auto-mount result. Reached only from the result path, so controlled mode never renders it. */\n\tprotected renderAttribution(): unknown {\n\t\treturn html`<div class=\"roxy-attribution\"><a href=\"https://roxyapi.com/?utm_source=widget&utm_medium=embed\" target=\"_blank\" rel=\"noopener\">Spiritual data by RoxyAPI</a></div>`;\n\t}\n\n\t/** The data-absent branch: the self-fetch form when an endpoint is set, otherwise the empty state. */\n\tprotected renderNoData(): unknown {\n\t\treturn this.endpoint ? this.renderForm() : this.renderEmpty();\n\t}\n\n\t/** Internal self-fetch form. Reuses the introspecting `<roxy-endpoint-form>`; the consumer never places it. */\n\tprotected renderForm(): unknown {\n\t\treturn html`<roxy-endpoint-form data-endpoint=\"${this.endpoint}\" method=\"${this.method}\" spec-url=\"${ifDefined(this.specUrl)}\" publishable-key=\"${ifDefined(this.publishableKey)}\" submit-label=\"${ifDefined(this.submitLabel)}\" lang=\"${ifDefined(this.effectiveLang())}\" .initialValues=\"${this.formInitialValues()}\" @roxy-submit=\"${this.onFormSubmit}\"></roxy-endpoint-form>`;\n\t}\n\n\t/** Prefill source for the form: the last submission (Edit / sticky refetch) wins over remembered storage. */\n\tprivate formInitialValues(): Record<string, unknown> | undefined {\n\t\treturn (\n\t\t\tthis.lastValues ?? (this.remember ? this.readRemembered() : undefined)\n\t\t);\n\t}\n\n\t/** Site-owner language from the element `lang` attribute (native accessor), routed to the API query on submit. */\n\tprivate effectiveLang(): string | undefined {\n\t\treturn this.lang || undefined;\n\t}\n\n\tprivate onFormSubmit = (e: Event) => {\n\t\tconst detail = (e as CustomEvent).detail as {\n\t\t\tvalues: Record<string, unknown>;\n\t\t\tqueryKeys?: string[];\n\t\t\tsticky?: boolean;\n\t\t};\n\t\tthis.lastValues = detail.values;\n\t\tthis.sticky = !!detail.sticky;\n\t\tthis.selfFetched = true;\n\t\tthis.editing = false;\n\t\tif (this.remember) this.writeRemembered(detail.values);\n\t\tvoid this.fetcher.run(\n\t\t\tbuildRequest(\n\t\t\t\tthis.endpoint,\n\t\t\t\tthis.method,\n\t\t\t\tdetail.values,\n\t\t\t\tdetail.queryKeys ?? [],\n\t\t\t),\n\t\t);\n\t};\n\n\t/** sessionStorage key for this component's remembered form values, scoped by endpoint. */\n\tprivate rememberKey(): string {\n\t\treturn `roxy-ui:form:${this.endpoint}`;\n\t}\n\n\tprivate readRemembered(): Record<string, unknown> | undefined {\n\t\ttry {\n\t\t\tconst raw = sessionStorage.getItem(this.rememberKey());\n\t\t\treturn raw ? (JSON.parse(raw) as Record<string, unknown>) : undefined;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate writeRemembered(values: Record<string, unknown>): void {\n\t\ttry {\n\t\t\tsessionStorage.setItem(this.rememberKey(), JSON.stringify(values));\n\t\t} catch {\n\t\t\t// Private mode / disabled storage: remembering is best-effort, never fatal.\n\t\t}\n\t}\n\n\t/** Terminal empty state. Subclasses override for a domain-specific message. */\n\tprotected renderEmpty(): unknown {\n\t\treturn html`<div class=\"roxy-empty\" role=\"status\">No data</div>`;\n\t}\n\n\t/** Loading placeholder shown during a self-fetch. */\n\tprotected renderLoading(): unknown {\n\t\treturn html`<div class=\"roxy-skeleton\" style=\"height:8rem\" role=\"status\" aria-label=\"Loading\"></div>`;\n\t}\n\n\t/** Error state shown when a self-fetch fails. Keeps the form in view so the request can be retried. */\n\tprotected renderError(message: string): unknown {\n\t\tconst banner = html`<div class=\"roxy-error\" role=\"alert\">${message}</div>`;\n\t\treturn this.endpoint ? html`${banner}${this.renderForm()}` : banner;\n\t}\n}\n", "import { css } from 'lit';\n\n/**\n * Shared host styles every component pulls in. Sets default font, color,\n * container query support, and the entry fade-in.\n */\nexport const baseStyles = css`:host{font-family:var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-base,1rem);line-height:var(--roxy-leading-normal,1.5);animation:roxy-fade-in var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1)) both;background:0 0;display:block;container-type:inline-size}:host([bare]){--roxy-surface:transparent;--roxy-shadow-sm:none;--roxy-shadow-md:none}*,:before,:after{box-sizing:border-box}h1,h2,h3,h4{font-family:var(--roxy-font-display,var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif))}@keyframes roxy-fade-in{0%{opacity:0;transform:translateY(2px)}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion:reduce){:host{animation:none}}.roxy-skeleton{background:linear-gradient(90deg, var(--roxy-border,#e4e4e7) 0%, color-mix(in srgb, var(--roxy-border,#e4e4e7) 60%, transparent) 50%, var(--roxy-border,#e4e4e7) 100%);border-radius:var(--roxy-radius-md,8px);background-size:200% 100%;animation:1.4s ease-in-out infinite roxy-shimmer}@keyframes roxy-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){.roxy-skeleton{animation:none}}.roxy-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.roxy-empty{padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-muted,#71717a);text-align:center;font-size:var(--roxy-text-sm,.875rem)}.roxy-error{gap:var(--roxy-space-sm,.5rem);padding:var(--roxy-space-lg,1.5rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}.roxy-surface{background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a)}:host(:focus-within) .roxy-card{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-attribution{margin-top:var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-xs,.75rem);color:var(--roxy-muted,#71717a);text-align:right}.roxy-attribution a{color:inherit;text-decoration:none}.roxy-attribution a:hover{color:var(--roxy-accent-ink,#b45309);text-decoration:underline}.roxy-attribution a:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-edit-bar{margin-bottom:var(--roxy-space-sm,.5rem);justify-content:flex-end;display:flex}.roxy-edit{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;background:0 0}.roxy-edit:hover{border-color:var(--roxy-accent,#f59e0b);color:var(--roxy-accent-ink,#b45309)}.roxy-edit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}:host{font-variant-emoji:text}`;\n", "/**\n * The one place the \"publishable key only\" rule lives. Every client-side fetch boundary ({@link ../components/location-search.ts}, {@link ./fetch-controller.ts}) calls through here so a secret or legacy unprefixed key is refused identically: no network call, the same visible message, the same `roxy-validation-error` event. Centralising it is what stops the two paths drifting, which is exactly how `<roxy-location-search>` used to warn-then-fetch a secret key while the controller fail-closed.\n */\n\n/** Canonical refusal message. Both fetch boundaries surface this exact wording. */\nexport const KEY_REFUSED_MESSAGE =\n\t'Client-side components accept a pk_ publishable key only. Use a publishable key with an origin allowlist, or render server-side.';\n\n/** True when the key is a browser-safe `pk_` publishable key. */\nexport function isPublishableKey(key: string | undefined | null): boolean {\n\treturn !!key && key.startsWith('pk_');\n}\n\n/**\n * The fail-closed condition: a key is PRESENT and is NOT a `pk_` key. An absent key is not refused, so a keyless public call (a form-slotted city search with no key set) still proceeds; only a real secret/legacy token in the browser is stopped.\n */\nexport function keyIsRefused(key: string | undefined | null): boolean {\n\treturn !!key && !key.startsWith('pk_');\n}\n\n/**\n * Announce a refused key: dispatch the shared `roxy-validation-error` (bubbling, composed) and, when `warn` is set, log it once for the developer. The caller sets its own visible error state and skips the fetch; this only handles the parts both boundaries share.\n */\nexport function dispatchKeyRefusal(\n\thost: EventTarget,\n\topts: { warn?: boolean } = {},\n): void {\n\tif (opts.warn) console.warn(KEY_REFUSED_MESSAGE);\n\thost.dispatchEvent(\n\t\tnew CustomEvent('roxy-validation-error', {\n\t\t\tdetail: { reason: 'possible-secret-key', message: KEY_REFUSED_MESSAGE },\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t}),\n\t);\n}\n", "import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport {\n\tdispatchKeyRefusal,\n\tKEY_REFUSED_MESSAGE,\n\tkeyIsRefused,\n} from './key-guard.js';\n\n/**\n * Host slots the controller drives. {@link RoxyDataElement} satisfies this, so the form mixin can attach a controller without the component wiring state by hand.\n *\n * @remarks\n * Intersected with `HTMLElement` because the controller dispatches events on the host. Lit's `ReactiveControllerHost` is the update-lifecycle contract only (`addController`, `requestUpdate`, `updateComplete`) and carries no DOM surface, even though every real host is a `LitElement` and therefore an `HTMLElement`. Declaring the DOM half is what the controller actually needs; it used to reach it through a `this.host as unknown as EventTarget` double cast instead, which asserted a capability the type never promised.\n */\ntype FetchHost<T> = ReactiveControllerHost &\n\tHTMLElement & {\n\t\tdata: T | null;\n\t\tloading: boolean;\n\t\terror: string | null;\n\t};\n\n/** Default RoxyAPI v2 origin. A component overrides it per instance via its `base-url` attribute. */\nconst DEFAULT_BASE_URL = 'https://roxyapi.com/api/v2';\n\n/** A single request the controller issues on the component's behalf. */\nexport interface RoxyRequest {\n\t/** Path under the API base, e.g. \"/dreams/symbols/water\" or \"/astrology/natal-chart\". */\n\tpath: string;\n\tmethod?: 'GET' | 'POST';\n\t/** JSON body for POST endpoints. */\n\tbody?: unknown;\n\t/** Query string parameters; nullish values are dropped. */\n\tquery?: Record<string, string | number | undefined>;\n}\n\n/**\n * Client-side fetch for uncontrolled (self-fetching) components: drives `host.data` / `host.loading` / `host.error` and cancels a stale request when a newer one starts or the host disconnects.\n *\n * @remarks\n * Security boundary. The only credential this ever sends is a `pk_` publishable key, which carries a server-side origin allowlist. A secret (`sk_`) or legacy unprefixed key is refused before any network call and surfaced as an error, so a server secret cannot leak into a browser request. This centralizes the guard that originated in `<roxy-location-search>` so every self-fetching component enforces it identically.\n *\n * Controlled-mode components never construct this. When a server injects the response as a `<script class=\"roxy-data\">` island, there is no key and no fetch, which is the path server-rendered consumers (WordPress, JSX SSR, static HTML) rely on.\n */\nexport class FetchController<T = unknown> implements ReactiveController {\n\tprivate readonly host: FetchHost<T>;\n\tprivate abort?: AbortController;\n\n\t/** Browser-safe publishable key. Set by the host from its `publishable-key` attribute. */\n\tpublishableKey?: string;\n\t/** API origin, overridable for self-hosted or proxied deployments. */\n\tbaseUrl = DEFAULT_BASE_URL;\n\t/**\n\t * Consumer backend route that holds the secret key. When set, the request is POSTed here as `{ path, method, body, query }` instead of called against RoxyAPI directly, so no key (publishable or secret) is sent from the browser. This is the canonical path for server-rendered hosts (WordPress); the backend proxies the request with its own `sk_` key and returns the JSON response.\n\t */\n\tsubmitUrl?: string;\n\n\tconstructor(host: FetchHost<T>) {\n\t\tthis.host = host;\n\t\thost.addController(this);\n\t}\n\n\thostDisconnected() {\n\t\tthis.abort?.abort();\n\t\tthis.abort = undefined;\n\t}\n\n\t/**\n\t * Issue the request and resolve once `host.data` (success) or `host.error`\n\t * (failure) is set. A no-op return when a non-publishable key is present:\n\t * the error is already surfaced and nothing is sent.\n\t */\n\tasync run(req: RoxyRequest): Promise<void> {\n\t\t// submit-url proxy: no key leaves the browser; the consumer's backend holds it.\n\t\tif (!this.submitUrl && this.secretKeyRefused()) return;\n\t\tthis.abort?.abort();\n\t\tconst controller = new AbortController();\n\t\tthis.abort = controller;\n\t\tthis.host.loading = true;\n\t\tthis.host.error = null;\n\t\ttry {\n\t\t\tconst res = this.submitUrl\n\t\t\t\t? await fetch(this.submitUrl, {\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\tAccept: 'application/json',\n\t\t\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: JSON.stringify(req),\n\t\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t\t})\n\t\t\t\t: await this.callApi(req, controller.signal);\n\t\t\tif (!res.ok) throw new Error(await this.readError(res));\n\t\t\tconst json = (await res.json()) as T;\n\t\t\tif (controller.signal.aborted) return;\n\t\t\tthis.host.data = json;\n\t\t} catch (err) {\n\t\t\tif ((err as { name?: string })?.name === 'AbortError') return;\n\t\t\tthis.host.error = err instanceof Error ? err.message : String(err);\n\t\t} finally {\n\t\t\tif (this.abort === controller) this.abort = undefined;\n\t\t\tif (!controller.signal.aborted) this.host.loading = false;\n\t\t}\n\t}\n\n\t/** Direct call against RoxyAPI with the publishable key (the no-backend path). */\n\tprivate callApi(req: RoxyRequest, signal: AbortSignal): Promise<Response> {\n\t\tconst url = new URL(`${this.baseUrl}${req.path}`);\n\t\tfor (const [k, v] of Object.entries(req.query ?? {})) {\n\t\t\tif (v != null) url.searchParams.set(k, String(v));\n\t\t}\n\t\tconst headers: Record<string, string> = { Accept: 'application/json' };\n\t\tif (this.publishableKey) headers['X-API-Key'] = this.publishableKey;\n\t\tif (req.body != null) headers['Content-Type'] = 'application/json';\n\t\treturn fetch(url, {\n\t\t\tmethod: req.method ?? 'GET',\n\t\t\theaders,\n\t\t\tbody: req.body != null ? JSON.stringify(req.body) : undefined,\n\t\t\tsignal,\n\t\t});\n\t}\n\n\t/** True when a key is set and it is not a browser-safe `pk_` publishable key. Surfaces the error and refuses to send, via the shared {@link keyIsRefused} guard so every fetch boundary fail-closes identically. */\n\tprivate secretKeyRefused(): boolean {\n\t\tif (!keyIsRefused(this.publishableKey)) return false;\n\t\tthis.host.error = KEY_REFUSED_MESSAGE;\n\t\tdispatchKeyRefusal(this.host);\n\t\treturn true;\n\t}\n\n\t/** Surface the `{ error, code }` message the API returns on failure, falling back to the status code. */\n\tprivate async readError(res: Response): Promise<string> {\n\t\ttry {\n\t\t\tconst body = (await res.json()) as { error?: string };\n\t\t\tif (body?.error) return body.error;\n\t\t} catch {\n\t\t\t// Non-JSON error body: fall through to the status line.\n\t\t}\n\t\treturn `Request failed (${res.status})`;\n\t}\n}\n\n/**\n * Translate flat form values into a {@link RoxyRequest} for an endpoint. The `{name}` segments in the endpoint template are substituted from the values and removed; the rest become the JSON body for POST or query parameters for GET. This is the spec-light request builder the base element uses to turn a `<roxy-endpoint-form>` submission into a self-fetch, so a component needs no per-endpoint glue.\n *\n * @param queryKeys - Names the spec declares as `in: query` for this operation, which `<roxy-endpoint-form>` reports on its `roxy-submit` event. A POST operation can still take query parameters (every localized endpoint takes `?lang=`), and sending one in the JSON body silently drops it, so those names are routed to the query string on POST as well as GET.\n */\nexport function buildRequest(\n\tendpoint: string,\n\tmethod: 'GET' | 'POST',\n\tvalues: Record<string, unknown>,\n\tqueryKeys: readonly string[] = [],\n): RoxyRequest {\n\tconst rest: Record<string, unknown> = { ...values };\n\tconst path = `/${endpoint.replace(/^\\//, '')}`.replace(\n\t\t/\\{([^}]+)\\}/g,\n\t\t(_match, name: string) => {\n\t\t\tconst v = rest[name];\n\t\t\tdelete rest[name];\n\t\t\treturn encodeURIComponent(String(v ?? ''));\n\t\t},\n\t);\n\tconst inQuery = new Set(queryKeys);\n\tconst query: Record<string, string | number | undefined> = {};\n\tconst body: Record<string, unknown> = {};\n\tfor (const [k, v] of Object.entries(rest)) {\n\t\tif (v === undefined || v === '') continue;\n\t\tif (method === 'GET' || inQuery.has(k)) query[k] = v as string | number;\n\t\telse body[k] = v;\n\t}\n\treturn { path, method, query, body: method === 'POST' ? body : undefined };\n}\n", "import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\n/**\n * Marker class on the inline JSON script a server emits inside a component.\n *\n * @example\n * ```html\n * <roxy-natal-chart>\n * <script type=\"application/json\" class=\"roxy-data\">{ ...response... }</script>\n * </roxy-natal-chart>\n * ```\n */\nconst ROXY_DATA_CLASS = 'roxy-data';\n\n/**\n * Serialize a RoxyAPI response for embedding inside an inline `<script type=\"application/json\" class=\"roxy-data\">`. This is the safe writer counterpart to {@link MarkupDataController}, the reader: server-rendered and cached consumers (WordPress, JSX SSR, static HTML) emit the script with this, and the component hydrates `data` from it on connect.\n *\n * @remarks\n * Use this instead of a bare `JSON.stringify`. A raw stringify of a response that contains the literal text `</script>` (common in long interpretation prose) closes the script element early, corrupting the page and creating an HTML-injection vector. This escapes the script-unsafe characters to their `\\uXXXX` JSON escapes, which `JSON.parse` restores to the original characters, so the value the component receives is identical to the response you passed.\n *\n * `<` is the load-bearing escape (it defeats `</script>` and `<!--`). `>` and `&` are escaped for defence in depth, and U+2028 / U+2029 because they are valid in JSON yet are line terminators in a `<script>` context and break some parsers. The escapes introduce only `\\uXXXX` sequences, so the replacements never feed each other and order is irrelevant.\n *\n * Pass the unwrapped RoxyAPI response, the same shape you would assign to `element.data`. Do not pass the SDK envelope (`{ data, error, request, response }`).\n *\n * @example\n * ```ts\n * import { serializeRoxyData } from '@roxyapi/ui';\n *\n * const { data } = await roxy.dreams.getDreamSymbol({ path: { id: 'water' } });\n * const html = `<roxy-dream-card><script type=\"application/json\" class=\"roxy-data\">${serializeRoxyData(data)}</script></roxy-dream-card>`;\n * ```\n */\nexport function serializeRoxyData(data: unknown): string {\n\treturn JSON.stringify(data)\n\t\t.replace(/</g, '\\\\u003c')\n\t\t.replace(/>/g, '\\\\u003e')\n\t\t.replace(/&/g, '\\\\u0026')\n\t\t.replace(/\\u2028/g, '\\\\u2028')\n\t\t.replace(/\\u2029/g, '\\\\u2029');\n}\n\n/**\n * Build the complete `<script type=\"application/json\" class=\"roxy-data\">\u2026</script>` element a server nests inside a `roxy-*` component for the no-JavaScript hydration path. The payload is escaped via {@link serializeRoxyData}, so it is safe to drop straight into HTML output.\n *\n * @remarks\n * The element carries both `type=\"application/json\"` and `class=\"roxy-data\"` because {@link MarkupDataController} reads only a direct-child script that has both. Emit one of these inside the target component; the JavaScript `data` property still wins if it is later assigned.\n *\n * @example\n * ```ts\n * import { roxyDataScript } from '@roxyapi/ui';\n *\n * const { data } = await roxy.crystals.getCrystal({ path: { id: 'amethyst' } });\n * const html = `<roxy-crystal-grid>${roxyDataScript(data)}</roxy-crystal-grid>`;\n * ```\n */\nexport function roxyDataScript(data: unknown): string {\n\treturn `<script type=\"application/json\" class=\"${ROXY_DATA_CLASS}\">${serializeRoxyData(data)}</script>`;\n}\n\n/**\n * True when the element is a `<script type=\"application/json\">`. Uses tag name and attribute rather than `instanceof HTMLScriptElement` so the check holds in every DOM implementation, including server-rendered and hydration runtimes where the constructor global may be absent.\n */\nfunction isJsonScript(el: Element): boolean {\n\treturn (\n\t\tel.nodeName === 'SCRIPT' && el.getAttribute('type') === 'application/json'\n\t);\n}\n\n/**\n * Host shape the controller drives: any reactive element that exposes a public `data` slot. The controller only writes `data` when the host left it unset, so the JavaScript property path always wins.\n */\ninterface DataHost extends ReactiveControllerHost, HTMLElement {\n\tdata?: unknown;\n}\n\n/**\n * Reactive controller that lets a component hydrate its `data` from embedded markup when no `data` property was assigned in JavaScript.\n *\n * @remarks\n * The server-side and cached-render model: a backend renders the RoxyAPI response into a direct-child `<script type=\"application/json\" class=\"roxy-data\">` element, ships static HTML, and never runs per-element JavaScript to assign a property. On connect this controller reads that script, parses it, and feeds the result to the host. The JavaScript property path is untouched and authoritative: if `host.data` already holds a value when the host connects, the controller does nothing and the markup is ignored.\n *\n * Source resolution order on connect, first hit wins:\n *\n * 1. `host.data` already set in JavaScript -> leave it, read nothing.\n * 2. A direct-child `<script type=\"application/json\" class=\"roxy-data\">` -> parse and use. Direct-child only, so a nested component's own script is never read by an ancestor.\n *\n * Fetching from a URL is intentionally unsupported: that would require a browser-visible key and breaks the server-rendered, cached model these consumers rely on.\n *\n * Timing: {@link hostConnected} runs inside the host `connectedCallback`. For an element parsed from server HTML, its direct children are present by the time the custom element upgrades and connects, so the script is readable here. For an element created with `document.createElement` and connected before any child is appended, there is nothing to read and the property path is the only source, which is exactly the existing behavior.\n *\n * Failure is safe: malformed JSON or a missing script leaves `host.data` untouched, so the host renders its normal empty state.\n *\n * Reading the script never mutates it, and only the marked script is touched, so any sibling fallback markup a server nested inside the element (for no-JavaScript, AMP, or crawler rendering) is left in place.\n *\n * @example\n * ```ts\n * import { MarkupDataController } from '../utils/markup-data.js';\n *\n * export class RoxyExample extends LitElement {\n * constructor() {\n * super();\n * new MarkupDataController(this);\n * }\n *\n * @property({ attribute: false })\n * data: ExampleResponse | null = null;\n * }\n * ```\n */\nexport class MarkupDataController<T = unknown> implements ReactiveController {\n\tprivate readonly host: DataHost;\n\n\tconstructor(host: DataHost) {\n\t\tthis.host = host;\n\t\thost.addController(this);\n\t}\n\n\thostConnected() {\n\t\t// Property path wins. If the consumer (React, vanilla `.data =`, the\n\t\t// widgets script, an MCP agent) already set data, never look at markup.\n\t\tif (this.host.data != null) return;\n\n\t\tconst parsed = this.read();\n\t\tif (parsed === undefined) return;\n\n\t\tthis.host.data = parsed as T;\n\t\tthis.host.requestUpdate();\n\t}\n\n\t/**\n\t * Resolve the embedded payload. Returns `undefined` when there is nothing valid to read so the caller can leave `host.data` untouched.\n\t */\n\tprivate read(): T | undefined {\n\t\tconst inline = this.findInlineScript();\n\t\treturn inline ? this.parse(inline.textContent) : undefined;\n\t}\n\n\t/**\n\t * Direct-child `<script type=\"application/json\" class=\"roxy-data\">`. Scoped to immediate children so a nested data-driven component never has its script read by an ancestor, and so sibling fallback markup is ignored.\n\t */\n\tprivate findInlineScript(): Element | null {\n\t\tfor (const child of Array.from(this.host.children)) {\n\t\t\tif (isJsonScript(child) && child.classList.contains(ROXY_DATA_CLASS)) {\n\t\t\t\treturn child;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\tprivate parse(text: string | null): T | undefined {\n\t\tif (!text?.trim()) return undefined;\n\t\ttry {\n\t\t\treturn JSON.parse(text) as T;\n\t\t} catch {\n\t\t\t// Malformed embedded JSON: fail safe, leave the host empty state in\n\t\t\t// place rather than throwing during connect.\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n", "import type { TemplateResult } from 'lit';\nimport { css, html } from 'lit';\n\n/**\n * Disclosure chevron for `<details>`/`<summary>` accordions. Replaces the\n * browser default triangle with a thin chevron that rotates when the host\n * `<details>` opens. Render it inside the `<summary>` and pair with\n * {@link disclosureStyles}.\n */\nexport function chevron(): TemplateResult {\n\treturn html`<svg class=\"roxy-chevron\" viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" aria-hidden=\"true\"><path d=\"M4 6l4 4 4-4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n}\n\n/**\n * Shared `<details>` accordion styling: hides the native disclosure triangle\n * and rotates the {@link chevron} 180 degrees when the accordion is open.\n * Import into any component that renders disclosure accordions so the chevron\n * looks and behaves identically.\n */\nexport const disclosureStyles = css`summary{list-style:none}summary::-webkit-details-marker{display:none}.roxy-chevron{aspect-ratio:auto;width:14px;height:14px;color:var(--roxy-muted,#71717a);transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0}details[open]>summary .roxy-chevron{transform:rotate(180deg)}@media (prefers-reduced-motion:reduce){.roxy-chevron{transition:none}}`;\n", "/**\n * Display formatters for ISO timestamps and floats coming back from the API.\n * Every helper returns \"\" for nullish or unparseable input so it falls out of\n * template literals cleanly.\n */\n\nconst DATE_ONLY = /^\\d{4}-\\d{2}-\\d{2}$/;\nconst BARE_TIME = /^\\d{2}:\\d{2}(:\\d{2})?$/;\n/** An ISO datetime with NO timezone designator: a wall clock, not an instant. */\nconst NAIVE_DATETIME = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?$/;\n\n/**\n * Resolve an API timestamp to a Date plus the timezone it must be RENDERED in.\n *\n * @remarks\n * The API returns chart times naive (`2026-07-13T04:36:00`): that is 04:36 in the CHART's timezone, not UTC and not the viewer's. A wall clock must read the same for every viewer on earth, so hora at sunrise says 04:36 in Tokyo and in Chicago alike.\n *\n * Handing a naive string to `new Date()` makes the runtime interpret it in the VIEWER's zone, which is a silent corruption whenever that wall clock lands in the viewer's DST gap. In America/New_York `2026-03-08T02:30:00` does not exist, so the clock jumps and it renders as `3:30 AM`. Pinning the wall clock to UTC, which has no DST and therefore no gap, preserves the digits exactly while Intl still applies the viewer's locale conventions.\n *\n * An offset-bearing timestamp (`...Z`, `...+05:30`) IS a real instant, so it keeps the normal behaviour and converts to the viewer's local time.\n */\nfunction resolve(input: string): { d: Date; timeZone?: string } {\n\tconst naive = BARE_TIME.test(input)\n\t\t? `1970-01-01T${input}`\n\t\t: NAIVE_DATETIME.test(input)\n\t\t\t? input\n\t\t\t: null;\n\treturn naive\n\t\t? { d: new Date(`${naive}Z`), timeZone: 'UTC' }\n\t\t: { d: new Date(input) };\n}\n\nexport function formatTime(input: unknown): string {\n\tif (typeof input !== 'string' || input.length === 0) return '';\n\tif (DATE_ONLY.test(input)) return '';\n\tconst { d, timeZone } = resolve(input);\n\tif (Number.isNaN(d.getTime())) return input;\n\treturn d.toLocaleTimeString(undefined, {\n\t\thour: 'numeric',\n\t\tminute: '2-digit',\n\t\thour12: true,\n\t\ttimeZone,\n\t});\n}\n\nexport function formatDate(input: unknown): string {\n\tif (typeof input !== 'string' || input.length === 0) return '';\n\tconst { d, timeZone } = resolve(\n\t\tDATE_ONLY.test(input) ? `${input}T00:00:00` : input,\n\t);\n\tif (Number.isNaN(d.getTime())) return input;\n\treturn d.toLocaleDateString(undefined, {\n\t\tmonth: 'short',\n\t\tday: 'numeric',\n\t\tyear: 'numeric',\n\t\ttimeZone,\n\t});\n}\n\nexport function formatTimeRange(\n\tt: { start?: string; end?: string } | undefined,\n): string {\n\tif (!t) return '';\n\tconst start = formatTime(t.start);\n\tconst end = formatTime(t.end);\n\tif (start && end) return `${start} - ${end}`;\n\treturn start || end || '';\n}\n\n/**\n * Format a number, dropping trailing zeros in the FRACTIONAL part only: `2.50` becomes `2.5`, `2.0` becomes `2`, and `100` stays `100`.\n *\n * @remarks\n * The old implementation ran `.replace(/\\.?0+$/, '')` against the whole string, which happily ate zeros off the INTEGER when there was no decimal point. At `dp = 0` that meant `100` rendered as `1`, `90` as `9`, `20` as `2`, and `0` as the empty string. It shipped: a 100 percent tight stellium displayed as \"1% tight\", and an aspect of strength 100 as \"str 1\". Guard on the decimal point, and never strip from the integer side.\n *\n * @example\n * ```ts\n * formatNumber(100, 0); // '100'\n * formatNumber(2.5, 1); // '2.5'\n * formatNumber(2, 1); // '2'\n * formatNumber(0, 0); // '0'\n * ```\n */\nexport function formatNumber(value: unknown, dp = 1): string {\n\tif (typeof value !== 'number' || !Number.isFinite(value)) return '';\n\tconst fixed = value.toFixed(dp);\n\treturn fixed.includes('.') ? fixed.replace(/\\.?0+$/, '') : fixed;\n}\n\nexport function formatPercent(value: unknown, dp = 1): string {\n\tconst n = formatNumber(value, dp);\n\treturn n ? `${n}%` : '';\n}\n\n/**\n * CSS class name per aspect type. Used by natal and synastry chart aspect\n * lines so the same color encoding (harmonious vs challenging) applies in\n * both wheels. Keys are lowercase canonical names, values are CSS class\n * suffixes the chart components define in their `:host` styles.\n */\nexport const ASPECT_CLASS: Record<string, string> = {\n\tconjunction: 'aspect-conjunction',\n\tsextile: 'aspect-sextile',\n\tsquare: 'aspect-square',\n\ttrine: 'aspect-trine',\n\topposition: 'aspect-opposition',\n};\n\n/**\n * Normalize the `type` field on an aspect entry to a lowercase, hyphen-separated\n * canonical name (`SEMI_SEXTILE` \u2192 `semi-sextile`). Accepts any aspect-shaped\n * object so both natal and synastry inter-aspect entries can share this.\n */\nexport function normalizeAspect(a: { type?: string }): string {\n\treturn (a.type ?? '').toLowerCase().replace(/_/g, '-');\n}\n", "/**\n * The interpretation accordion: the one way this library shows a label, a short value, and a body of prose behind a disclosure.\n *\n * @remarks\n * Exclusive by construction (`<details name>`), so a card grows by at most one open section and never becomes a wall of text. Callers pass their own group `name` so two accordions on one page do not fight over which section is open.\n *\n * This lives here rather than in a component because the same accordion is the right shape wherever an endpoint returns a labelled reading: the Human Design bodygraph and type card use it for strategy, authority, and aura; `roxy-hexagram` uses it for the changing lines. The CSS was copy-pasted into six components before 2026-07 and had already drifted (`.interp-body` had five distinct definitions), which is the drift this exists to stop. Migrate the remaining copies to it when they are next touched.\n */\n\nimport { css, html, nothing } from 'lit';\nimport { chevron } from './disclosure.js';\n\n/** One row: the label, the short value shown as the aside, and the interpretation body. `extra` renders under the body for a section that carries more than prose. */\nexport interface InterpSection {\n\tlabel: string;\n\taside?: string;\n\tbody: string;\n\textra?: unknown;\n}\n\nexport const interpAccordionStyles = css`.block{border-top:1px solid var(--roxy-border,#e4e4e7);padding-top:var(--roxy-space-md,1rem)}.block h3{margin:0 0 var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-muted,#71717a);text-transform:uppercase;letter-spacing:.06em}.interp-card{border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);margin-bottom:var(--roxy-space-xs,.25rem)}.interp-card summary{cursor:pointer;color:var(--roxy-fg,#0a0a0a);align-items:center;gap:var(--roxy-space-sm,.5rem);font-weight:500;font-size:var(--roxy-text-sm,.875rem);display:flex}.interp-card summary:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px;border-radius:var(--roxy-radius-sm,4px)}.interp-lead{flex-wrap:wrap;flex:auto;order:1;align-items:baseline;gap:.4rem;min-width:0;display:inline-flex}.interp-aside{flex-shrink:0;order:2;align-items:center;gap:.5rem;display:inline-flex}.roxy-chevron{order:3}.interp-aside small{color:var(--roxy-muted,#71717a);white-space:nowrap;font-weight:400}@container (width<=26rem){.interp-card summary{flex-wrap:wrap}.roxy-chevron{order:2}.interp-aside{flex-basis:100%;order:3;justify-content:flex-end}}.interp-body{margin-top:var(--roxy-space-sm,.5rem);gap:var(--roxy-space-sm,.5rem);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-sm,.875rem);overflow-wrap:anywhere;line-height:1.6;display:grid}.interp-body p{margin:0}`;\n\n/**\n * Render the accordion. Sections with no body are dropped, so a caller can pass the full set and let a narrower response render only what it carries. `name` groups the `<details>` exclusively, so opening one closes the last.\n */\nexport function renderInterpAccordion(\n\tsections: InterpSection[],\n\tname: string,\n\theading = 'Reading',\n) {\n\tconst shown = sections.filter((s) => Boolean(s.body));\n\tif (shown.length === 0) return nothing;\n\n\treturn html`<section class=\"block\"><h3>${heading}</h3>${shown.map(\n\t\t\t(s, i) => html`<details class=\"interp-card\" name=\"${name}\" ?open=\"${i === 0}\"><summary><span class=\"interp-lead\">${s.label}</span> ${chevron()} ${s.aside ? html`<span class=\"interp-aside\"><small>${s.aside}</small></span>` : nothing}</summary><div class=\"interp-body\"><p>${s.body}</p>${s.extra ?? nothing}</div></details>`,\n\t\t)}</section>`;\n}\n", "import type { TemplateResult } from 'lit';\nimport { css, html, nothing } from 'lit';\n\n/** A single tab in a {@link renderTablist} strip. */\nexport interface TablistItem<T extends string = string> {\n\tid: T;\n\tlabel: string;\n}\n\n/**\n * Shared styling for every horizontal tab strip in the library (natal chart\n * views, transits, kundli styles). Keeping one rule set means the tabs look\n * identical everywhere and theme through the same --roxy-* tokens.\n */\nexport const tablistStyles = css`.roxy-tablist{border-bottom:2px solid var(--roxy-border,#e4e4e7);scrollbar-width:thin;gap:2px;min-width:0;display:flex;overflow-x:auto}.roxy-tab{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);font-size:var(--roxy-text-sm,.875rem);cursor:pointer;color:var(--roxy-muted,#71717a);transition:color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);background:0 0;border:none;border-bottom:2px solid #0000;flex-shrink:0;margin-bottom:-2px;font-family:inherit}.roxy-tab[aria-selected=true]{color:var(--roxy-accent-ink,#b45309);border-bottom-color:var(--roxy-accent,#f59e0b);font-weight:var(--roxy-weight-bold,600)}.roxy-tab:hover:not([aria-selected=true]){color:var(--roxy-fg,#0a0a0a)}.roxy-tab:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:-2px;border-radius:4px}`;\n\n/**\n * Render a WAI-ARIA tablist. The host component owns the active-tab state; this\n * helper draws the buttons, wires click plus Left/Right arrow navigation with a\n * roving tabindex, and moves focus to the newly selected tab. Pair with\n * {@link tablistStyles}.\n *\n * Pass `controls: true` when each tab governs a sibling\n * `<div role=\"tabpanel\" id=\"${idPrefix}-panel-${id}\">` so the buttons advertise\n * `aria-controls`. Omit it for tablists that swap a single rendered view in\n * place with no separate panel element (the kundli style switch).\n *\n * @example\n * ```ts\n * renderTablist({\n * items: [{ id: 'wheel', label: 'Wheel' }, { id: 'grid', label: 'Aspect grid' }],\n * active: this.view,\n * onSelect: (v) => { this.view = v; },\n * label: 'Natal chart views',\n * idPrefix: 'natal',\n * controls: true,\n * })\n * ```\n */\nexport function renderTablist<T extends string>(opts: {\n\titems: ReadonlyArray<TablistItem<T>>;\n\tactive: T;\n\tonSelect: (id: T) => void;\n\tlabel: string;\n\tidPrefix: string;\n\tcontrols?: boolean;\n}): TemplateResult {\n\tconst { items, active, onSelect, label, idPrefix, controls = false } = opts;\n\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\tif (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft') return;\n\t\te.preventDefault();\n\t\tconst idx = items.findIndex((it) => it.id === active);\n\t\tif (idx === -1) return;\n\t\tconst delta = e.key === 'ArrowRight' ? 1 : -1;\n\t\tconst next = items[(idx + delta + items.length) % items.length];\n\t\tif (!next) return;\n\t\tonSelect(next.id);\n\t\tconst root = (e.currentTarget as HTMLElement).getRootNode() as\n\t\t\t| ShadowRoot\n\t\t\t| Document;\n\t\trequestAnimationFrame(() => {\n\t\t\troot\n\t\t\t\t.querySelector<HTMLButtonElement>(`#${idPrefix}-tab-${next.id}`)\n\t\t\t\t?.focus();\n\t\t});\n\t};\n\treturn html`<div class=\"roxy-tablist\" role=\"tablist\" aria-label=\"${label}\" @keydown=\"${onKeyDown}\">${items.map(\n\t\t\t(it) => html`<button type=\"button\" class=\"roxy-tab\" role=\"tab\" id=\"${idPrefix}-tab-${it.id}\" aria-selected=\"${active === it.id ? 'true' : 'false'}\" aria-controls=\"${\n\t\t\t\t\t// Only the active panel is rendered, so only the active tab points\n\t\t\t\t\t// at a live element; otherwise aria-controls would dangle.\n\t\t\t\t\tcontrols && active === it.id ? `${idPrefix}-panel-${it.id}` : nothing\n\t\t\t\t}\" tabindex=\"${active === it.id ? '0' : '-1'}\" @click=\"${() => onSelect(it.id)}\">${it.label}</button>`,\n\t\t)}</div>`;\n}\n"],
5
- "mappings": "wMAAA,OAAS,OAAAA,GAAK,QAAAC,EAAM,WAAAC,MAAe,MACnC,OAAS,iBAAAC,GAAe,YAAAC,GAAU,SAAAC,OAAa,oBCD/C,OAEC,QAAAC,EACA,cAAAC,MAEM,MACP,OAAS,YAAAC,EAAU,SAAAC,MAAa,oBAChC,OAAS,aAAAC,MAAiB,+BCP1B,OAAS,OAAAC,MAAW,MAMb,IAAMC,EAAaD,67FCDnB,IAAME,EACZ,mIAUM,SAASC,EAAaC,EAAyC,CACrE,MAAO,CAAC,CAACA,GAAO,CAACA,EAAI,WAAW,KAAK,CACtC,CAKO,SAASC,EACfC,EACAC,EAA2B,CAAC,EACrB,CACHA,EAAK,MAAM,QAAQ,KAAKC,CAAmB,EAC/CF,EAAK,cACJ,IAAI,YAAY,wBAAyB,CACxC,OAAQ,CAAE,OAAQ,sBAAuB,QAASE,CAAoB,EACtE,QAAS,GACT,SAAU,EACX,CAAC,CACF,CACD,CCdA,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b,IAAMkD,GAAgB,OAEtB,SAASrC,GAAST,EAA6B,CAC9C,OAAIA,GAAY,EAAU,OACtBA,GAAY,GAAK8C,GAAsB,QACpC,KACR,CAGA,SAASV,EAAeW,EAAWjB,EAA0B,CAC5D,GAAIA,IAAU,OAAQ,CACrB,IAAMkB,EAAID,EAAE,MAAM,UAAU,EAC5B,OAAOC,EAAIA,EAAE,CAAC,EAAID,CACnB,CACA,IAAM7D,EAAI,IAAI,KAAK6D,CAAC,EACpB,GAAI,OAAO,MAAM7D,EAAE,QAAQ,CAAC,EAAG,OAAO6D,EACtC,IAAME,EAAQ/D,EAAE,eAAe,KAAM,CAAE,MAAO,OAAQ,CAAC,EACvD,OAAO4C,IAAU,QACd,GAAGmB,CAAK,IAAI/D,EAAE,YAAY,CAAC,GAC3B,GAAGA,EAAE,QAAQ,CAAC,IAAI+D,CAAK,EAC3B",
6
- "names": ["css", "html", "nothing", "customElement", "property", "state", "html", "LitElement", "property", "state", "ifDefined", "css", "baseStyles", "KEY_REFUSED_MESSAGE", "keyIsRefused", "key", "dispatchKeyRefusal", "host", "opts", "KEY_REFUSED_MESSAGE", "DEFAULT_BASE_URL", "FetchController", "host", "req", "controller", "res", "json", "err", "signal", "url", "k", "v", "headers", "keyIsRefused", "KEY_REFUSED_MESSAGE", "dispatchKeyRefusal", "body", "buildRequest", "endpoint", "method", "values", "queryKeys", "rest", "path", "_match", "name", "inQuery", "query", "ROXY_DATA_CLASS", "isJsonScript", "el", "MarkupDataController", "host", "parsed", "inline", "child", "ROXY_DATA_CLASS", "text", "RoxyDataElement", "LitElement", "e", "detail", "buildRequest", "MarkupDataController", "FetchController", "baseStyles", "changed", "html", "data", "body", "ifDefined", "raw", "values", "message", "banner", "__decorateClass", "property", "state", "css", "html", "chevron", "disclosureStyles", "DATE_ONLY", "BARE_TIME", "NAIVE_DATETIME", "resolve", "input", "naive", "formatDate", "input", "d", "timeZone", "resolve", "DATE_ONLY", "formatNumber", "value", "dp", "fixed", "css", "html", "nothing", "interpAccordionStyles", "css", "renderInterpAccordion", "sections", "name", "heading", "shown", "s", "nothing", "html", "i", "chevron", "css", "html", "nothing", "tablistStyles", "renderTablist", "opts", "items", "active", "onSelect", "label", "idPrefix", "controls", "e", "idx", "it", "delta", "next", "root", "levelOf", "d", "parentOf", "formatBalance", "b", "parts", "formatSpan", "p", "start", "formatDate", "end", "RoxyDashaTimeline", "RoxyDataElement", "html", "periods", "maxYears", "readings", "frame", "tabs", "view", "t", "renderTablist", "v", "nothing", "grainFor", "renderInterpAccordion", "chain", "rows", "formatNumber", "deg", "lord", "label", "value", "parent", "level", "span", "began", "sections", "levels", "period", "remaining", "left", "active", "now", "max", "grain", "years", "width", "current", "progress", "trackClass", "formatBoundary", "baseStyles", "disclosureStyles", "interpAccordionStyles", "tablistStyles", "css", "__decorateClass", "property", "state", "customElement", "DAYS_PER_YEAR", "s", "m", "month"]
4
+ "sourcesContent": ["import { css, html, nothing } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport type {\n\tGetCurrentDashaResponse,\n\tGetMajorDashasResponse,\n\tGetPratyantardashasResponse,\n\tGetSookshmaDashasResponse,\n\tGetSubDashasResponse,\n} from '../types/index.js';\nimport { RoxyDataElement } from '../utils/base-element.js';\nimport { baseStyles } from '../utils/base-styles.js';\nimport { disclosureStyles } from '../utils/disclosure.js';\nimport { formatDate, formatNumber } from '../utils/format.js';\nimport {\n\ttype InterpSection,\n\tinterpAccordionStyles,\n\trenderInterpAccordion,\n} from '../utils/interp-accordion.js';\nimport { renderTablist, tablistStyles } from '../utils/tablist.js';\n\ntype DashaData =\n\t| GetCurrentDashaResponse\n\t| GetMajorDashasResponse\n\t| GetSubDashasResponse\n\t| GetPratyantardashasResponse\n\t| GetSookshmaDashasResponse;\n\ntype DashaPeriod = GetMajorDashasResponse['mahadashas'][number];\ntype Remaining = GetCurrentDashaResponse['remainingInMahadasha'];\n\n/**\n * The Vimshottari level a listed period sits at, so no view ever labels an\n * antardasha a mahadasha.\n *\n * Read from the RESPONSE, not from the `period` attribute: all three drill-down\n * routes are `period=\"sub\"`, and only the payload says whether the list is\n * antardashas, pratyantardashas or sookshma dashas.\n */\nfunction levelOf(d: DashaData): string {\n\tif ('sookshmaDashas' in d) return 'Sookshma';\n\tif ('pratyantardashas' in d) return 'Pratyantardasha';\n\tif ('antardashas' in d) return 'Antardasha';\n\treturn 'Mahadasha';\n}\n\n/** The parent period a drill-down response hangs off, with the level it sits at. */\nfunction parentOf(\n\td: DashaData,\n): { label: string; period: DashaPeriod } | undefined {\n\tif ('pratyantardashaPeriod' in d && d.pratyantardashaPeriod)\n\t\treturn { label: 'Pratyantardasha', period: d.pratyantardashaPeriod };\n\tif ('antardashaPeriod' in d && d.antardashaPeriod)\n\t\treturn { label: 'Antardasha', period: d.antardashaPeriod };\n\tif ('mahadashaPeriod' in d && d.mahadashaPeriod)\n\t\treturn { label: 'Mahadasha', period: d.mahadashaPeriod };\n\treturn undefined;\n}\n\n/** \"8y 11m 5d\", the form a dasha reader expects for a remaining balance. */\nfunction formatBalance(b: Remaining | undefined): string {\n\tif (!b) return '';\n\tconst parts: string[] = [];\n\tif (b.years) parts.push(`${b.years}y`);\n\tif (b.months) parts.push(`${b.months}m`);\n\tif (b.days) parts.push(`${b.days}d`);\n\treturn parts.length ? parts.join(' ') : '0d';\n}\n\n/** \"Jun 17, 2018 to Jun 17, 2035\" for the accordion aside. */\nfunction formatSpan(p: { startDate?: string; endDate?: string }): string {\n\tconst start = p.startDate ? formatDate(p.startDate) : '';\n\tconst end = p.endDate ? formatDate(p.endDate) : '';\n\tif (start && end) return `${start} to ${end}`;\n\treturn start || end;\n}\n\n/**\n * Dasha timeline. Renders /vedic-astrology/dasha/{current,major,sub/{...}}.\n *\n * @remarks\n * Default mode shows the active mahadasha, antardasha and pratyantardasha with\n * the reading each one carries. `period=\"major\"` draws the full 120-year\n * Vimshottari timeline; `period=\"sub\"` draws the antardashas inside one\n * mahadasha and states which mahadasha they sit in, since an antardasha means\n * nothing without its parent lord.\n */\n@customElement('roxy-dasha-timeline')\nexport class RoxyDashaTimeline extends RoxyDataElement<DashaData> {\n\tstatic styles = [\n\t\tbaseStyles,\n\t\tdisclosureStyles,\n\t\tinterpAccordionStyles,\n\t\ttablistStyles,\n\t\tcss`.wrap{gap:var(--roxy-space-md,1rem);display:grid}.head{justify-content:space-between;align-items:center;gap:var(--roxy-space-sm,.5rem);flex-wrap:wrap;display:flex}.title{font-size:var(--roxy-text-lg,1.125rem);font-weight:var(--roxy-weight-bold,600);margin:0}.nakshatra{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-sm,.875rem)}.current{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-md,1rem);box-shadow:var(--roxy-shadow-sm);grid-template-columns:repeat(auto-fit,minmax(10rem,1fr));display:grid}.current div span:first-child{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);text-transform:uppercase;letter-spacing:.06em;display:block}.current div strong{font-size:var(--roxy-text-base,1rem);color:var(--roxy-fg,#0a0a0a)}.current div small{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);display:block}.parent{font-size:var(--roxy-text-sm,.875rem);color:var(--roxy-muted,#71717a);border-left:2px solid var(--roxy-border,#e4e4e7);padding-left:var(--roxy-space-sm,.5rem);margin:0}.timeline{gap:var(--roxy-space-xs,.25rem);display:grid}.bar{gap:var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-sm,.875rem);grid-template-columns:5rem 1fr 8rem;align-items:center;display:grid}.bar.now strong{color:var(--roxy-accent-ink,#b45309)}.now-badge{font-size:var(--roxy-text-xs,.75rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-accent-ink,#b45309);text-transform:uppercase;letter-spacing:.06em;margin-left:.4em;display:inline-block}.bar-track{background:var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-full,9999px);height:14px;position:relative;overflow:hidden}.bar-fill{background:var(--roxy-accent,#f59e0b);opacity:.45;height:100%;transition:width var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1));display:block}.bar-now .bar-fill{opacity:1}.bar-progress{background:var(--roxy-accent-ink,#b45309);width:2px;box-shadow:0 0 0 2px color-mix(in srgb, var(--roxy-accent,#f59e0b) 35%, transparent);border-radius:2px;position:absolute;top:-2px;bottom:-2px}.dates{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);font-variant-numeric:tabular-nums;text-align:right}[role=tabpanel]{padding-top:var(--roxy-space-md,1rem)}.frame{gap:var(--roxy-space-sm,.5rem);grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));margin:0;display:grid}.frame dt{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);text-transform:uppercase;letter-spacing:.06em}.frame dd{font-size:var(--roxy-text-sm,.875rem);color:var(--roxy-fg,#0a0a0a);font-variant-numeric:tabular-nums;margin:0}.block{border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);background:var(--roxy-surface,#fff);padding:var(--roxy-space-md,1rem)}`,\n\t];\n\n\t/**\n\t * Which dasha endpoint fed this element. `sub`, `antara` and `sookshma` are the\n\t * three drill-down levels and render identically; they stay distinct because\n\t * each maps one-to-one onto its endpoint binding, which is what lets a widget\n\t * pick a level. The heading and the level LABELS come from the payload, not\n\t * from here, so a host that cannot set attributes still renders correctly.\n\t */\n\t@property({ type: String, reflect: true })\n\tperiod: 'current' | 'major' | 'sub' | 'antara' | 'sookshma' = 'current';\n\n\t/** Which panel is showing. Reset guarded in renderData when the data changes shape. */\n\t@state()\n\tprivate view: 'timeline' | 'readings' | 'frame' = 'timeline';\n\n\tprotected renderEmpty() {\n\t\treturn html`<div class=\"roxy-empty\" role=\"status\">No dasha data</div>`;\n\t}\n\n\tprotected renderData(d: DashaData) {\n\t\tconst periods = this.collectPeriods(d);\n\t\tconst maxYears = periods.length\n\t\t\t? Math.max(...periods.map((p) => p.durationYears))\n\t\t\t: 0;\n\t\tconst readings = this.readings(d, periods);\n\t\tconst frame = this.frameRows(d);\n\n\t\t// One panel per kind of question a reader asks: when do the periods run,\n\t\t// what do they mean, and what chart produced them. Without the split the\n\t\t// card became a single column of periods, prose and provenance, and the\n\t\t// dates (the reason anyone opens it) were pushed below the fold.\n\t\tconst tabs = [\n\t\t\t{ id: 'timeline' as const, label: 'Timeline' },\n\t\t\t...(readings.length\n\t\t\t\t? [{ id: 'readings' as const, label: `Readings (${readings.length})` }]\n\t\t\t\t: []),\n\t\t\t...(frame.length ? [{ id: 'frame' as const, label: 'Chart' }] : []),\n\t\t];\n\t\t// A tab that no longer exists (data changed under a selection) must not\n\t\t// blank the card, so fall back to the first.\n\t\tconst view = tabs.some((t) => t.id === this.view) ? this.view : 'timeline';\n\n\t\treturn html`<div class=\"wrap\" aria-label=\"Dasha timeline\"><header class=\"head\"><h2 class=\"title\">${this.heading(d)}</h2>${this.renderLordChain(d)}</header>${this.renderParentMahadasha(d)} ${\n\t\t\t\ttabs.length > 1\n\t\t\t\t\t? renderTablist({\n\t\t\t\t\t\t\titems: tabs,\n\t\t\t\t\t\t\tactive: view,\n\t\t\t\t\t\t\tonSelect: (v) => {\n\t\t\t\t\t\t\t\tthis.view = v;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tlabel: 'Dasha views',\n\t\t\t\t\t\t\tidPrefix: 'roxy-dasha',\n\t\t\t\t\t\t\tcontrols: true,\n\t\t\t\t\t\t})\n\t\t\t\t\t: nothing\n\t\t\t}<div id=\"roxy-dasha-panel-${view}\" role=\"tabpanel\" tabindex=\"0\" aria-labelledby=\"${tabs.length > 1 ? `roxy-dasha-tab-${view}` : nothing}\">${\n\t\t\t\t\tview === 'timeline'\n\t\t\t\t\t\t? html`${this.period === 'current' ? this.renderCurrent(d) : nothing} ${\n\t\t\t\t\t\t\t\tperiods.length > 0\n\t\t\t\t\t\t\t\t\t? html`<div class=\"timeline\" role=\"list\">${periods.map((p) => this.renderBar(p, maxYears, grainFor(maxYears)))}</div>`\n\t\t\t\t\t\t\t\t\t: nothing\n\t\t\t\t\t\t\t}`\n\t\t\t\t\t\t: nothing\n\t\t\t\t} ${\n\t\t\t\t\tview === 'readings'\n\t\t\t\t\t\t? renderInterpAccordion(\n\t\t\t\t\t\t\t\treadings,\n\t\t\t\t\t\t\t\t'roxy-dasha',\n\t\t\t\t\t\t\t\treadings.length === 1 ? 'Reading' : 'Readings',\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: nothing\n\t\t\t\t} ${view === 'frame' ? this.renderFrame(frame) : nothing}</div></div>`;\n\t}\n\n\t/**\n\t * The full lord chain a drill-down sits under, e.g. Saturn > Venus > Rahu.\n\t *\n\t * The response carries every ancestor lord on each period, and naming only the\n\t * immediate parent leaves a reader at the sookshma level unable to tell which\n\t * branch of the chart they are looking at.\n\t */\n\tprivate renderLordChain(d: DashaData) {\n\t\tconst chain = [\n\t\t\t'mahadashaLord' in d ? d.mahadashaLord : undefined,\n\t\t\t'antardashaLord' in d ? d.antardashaLord : undefined,\n\t\t\t'pratyantardashaLord' in d ? d.pratyantardashaLord : undefined,\n\t\t].filter(Boolean);\n\t\tif (chain.length > 1) {\n\t\t\treturn html`<div class=\"nakshatra\">${chain.join(' \\u203a ')}</div>`;\n\t\t}\n\t\tif ('nakshatraName' in d && d.nakshatraName) {\n\t\t\treturn html`<div class=\"nakshatra\">Moon nakshatra: ${d.nakshatraName} ${'nakshatraLord' in d && d.nakshatraLord ? html`(lord ${d.nakshatraLord})` : nothing}</div>`;\n\t\t}\n\t\treturn nothing;\n\t}\n\n\t/**\n\t * Provenance rows: the chart every date in this response was derived from.\n\t *\n\t * These are the fields that let a reader reconcile our dates against another\n\t * calculator. The sidereal frame is the one that actually explains a\n\t * disagreement, since Lahiri and the KP variants move every boundary by weeks,\n\t * so it is shown rather than left in the JSON.\n\t */\n\tprivate frameRows(d: DashaData): Array<[string, string]> {\n\t\tconst rows: Array<[string, string]> = [];\n\t\tif ('nakshatraName' in d && d.nakshatraName) {\n\t\t\tconst n =\n\t\t\t\t'moonNakshatra' in d && d.moonNakshatra\n\t\t\t\t\t? ` (${d.moonNakshatra} of 27)`\n\t\t\t\t\t: '';\n\t\t\trows.push(['Moon nakshatra', `${d.nakshatraName}${n}`]);\n\t\t}\n\t\tif ('nakshatraLord' in d && d.nakshatraLord) {\n\t\t\trows.push(['Nakshatra lord', d.nakshatraLord]);\n\t\t}\n\t\tif ('moonLongitude' in d && typeof d.moonLongitude === 'number') {\n\t\t\trows.push([\n\t\t\t\t'Moon longitude',\n\t\t\t\t`${formatNumber(d.moonLongitude, 3)}\\u00b0 sidereal`,\n\t\t\t]);\n\t\t}\n\t\tif ('ayanamsaType' in d && d.ayanamsaType) {\n\t\t\tconst deg =\n\t\t\t\t'ayanamsa' in d && typeof d.ayanamsa === 'number'\n\t\t\t\t\t? ` (${formatNumber(d.ayanamsa, 3)}\\u00b0)`\n\t\t\t\t\t: '';\n\t\t\trows.push(['Ayanamsa', `${d.ayanamsaType}${deg}`]);\n\t\t}\n\t\tif ('birthDashaBalance' in d && d.birthDashaBalance) {\n\t\t\tconst lord =\n\t\t\t\t'nakshatraLord' in d && d.nakshatraLord ? `${d.nakshatraLord} ` : '';\n\t\t\trows.push([\n\t\t\t\t'Balance at birth',\n\t\t\t\t`${formatBalance(d.birthDashaBalance)} of the opening ${lord}mahadasha`,\n\t\t\t]);\n\t\t}\n\t\tif ('totalYears' in d && typeof d.totalYears === 'number') {\n\t\t\trows.push(['Cycle length', `${d.totalYears} years`]);\n\t\t}\n\t\treturn rows;\n\t}\n\n\tprivate renderFrame(rows: Array<[string, string]>) {\n\t\treturn html`<dl class=\"frame\">${rows.map(([label, value]) => html`<div><dt>${label}</dt><dd>${value}</dd></div>`)}</dl>`;\n\t}\n\n\t/**\n\t * Heading, decided by the PAYLOAD first and the `period` attribute only as a\n\t * tie-break.\n\t *\n\t * Not every host can set the attribute. The WordPress plugin maps an\n\t * operationId to a bare component tag with no attrs, so every dasha shortcode\n\t * arrives with the default `period=\"current\"`; keying off the attribute alone\n\t * titled an antardasha list \"Active dashas\" there. A drill-down response is\n\t * self-identifying (it carries a parent period), so the markup does not need\n\t * to be told.\n\t */\n\tprivate heading(d: DashaData): string {\n\t\tconst parent = parentOf(d);\n\t\tif (parent) {\n\t\t\treturn `${levelOf(d)}s in ${parent.period.planet} ${parent.label}`;\n\t\t}\n\t\tif ('mahadashas' in d) return 'Vimshottari Mahadasha';\n\t\tif ('mahadasha' in d) return 'Active dashas';\n\t\treturn this.period === 'major' ? 'Vimshottari Mahadasha' : 'Active dashas';\n\t}\n\n\t/**\n\t * Drill-down modes list sub-periods inside one parent, so name the parent and\n\t * its span. A sub-period means nothing without its parent lord.\n\t *\n\t * `nominalStartDate` is present only when birth cut the parent short, which is\n\t * also why such a list can hold fewer than nine rows: the sub-periods that\n\t * finished before the native was born are not part of the chart. Saying so\n\t * turns a surprising short list into an explained one.\n\t */\n\tprivate renderParentMahadasha(d: DashaData) {\n\t\tconst parent = parentOf(d);\n\t\tif (!parent) return nothing;\n\t\tconst p = parent.period;\n\t\tconst span = formatSpan(p);\n\t\tconst began = p.nominalStartDate ? formatDate(p.nominalStartDate) : '';\n\t\treturn html`<p class=\"parent\">Inside the <strong>${p.planet}</strong> ${parent.label}${span ? `, ${span}` : ''} ${typeof p.durationYears === 'number' ? `(${formatNumber(p.durationYears, 1)} years)` : ''}. ${\n\t\t\t\tbegan\n\t\t\t\t\t? html`<br>It began ${began}, before birth, so only the sub-periods running after the birth date are listed.`\n\t\t\t\t\t: nothing\n\t\t\t}</p>`;\n\t}\n\n\t/**\n\t * Every reading the response carries, behind one exclusive accordion. Current\n\t * mode has four (mahadasha, antardasha, pratyantardasha, sookshma); drill-down\n\t * modes lead with the parent period reading, then the sub-period running now;\n\t * major mode shows the mahadasha running now.\n\t */\n\tprivate readings(d: DashaData, periods: DashaPeriod[]): InterpSection[] {\n\t\tconst sections: InterpSection[] = [];\n\n\t\tconst parent = parentOf(d);\n\t\tif (parent?.period.interpretation) {\n\t\t\tsections.push({\n\t\t\t\tlabel: `${parent.period.planet} ${parent.label}`,\n\t\t\t\taside: formatSpan(parent.period),\n\t\t\t\tbody: parent.period.interpretation,\n\t\t\t});\n\t\t}\n\n\t\tif ('mahadasha' in d) {\n\t\t\tconst levels = [\n\t\t\t\t['Mahadasha', d.mahadasha, d.remainingInMahadasha],\n\t\t\t\t['Antardasha', d.antardasha, d.remainingInAntardasha],\n\t\t\t\t['Pratyantardasha', d.pratyantardasha, d.remainingInPratyantardasha],\n\t\t\t\t['Sookshma', d.sookshmaDasha, d.remainingInSookshma],\n\t\t\t] as const;\n\t\t\tfor (const [label, period, remaining] of levels) {\n\t\t\t\tif (!period?.interpretation) continue;\n\t\t\t\tconst left = formatBalance(remaining);\n\t\t\t\tsections.push({\n\t\t\t\t\tlabel: `${period.planet} ${label}`,\n\t\t\t\t\taside: left ? `${left} left` : formatSpan(period),\n\t\t\t\t\tbody: period.interpretation,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst active = periods.find((p) => this.isCurrent(p));\n\t\tif (active?.interpretation) {\n\t\t\tsections.push({\n\t\t\t\tlabel: `${active.planet} ${levelOf(d)}`,\n\t\t\t\taside: formatSpan(active),\n\t\t\t\tbody: active.interpretation,\n\t\t\t});\n\t\t}\n\n\t\treturn sections;\n\t}\n\n\tprivate renderCurrent(d: DashaData) {\n\t\tif (!('mahadasha' in d)) return nothing;\n\t\tconst levels = [\n\t\t\t['Mahadasha', d.mahadasha, d.remainingInMahadasha],\n\t\t\t['Antardasha', d.antardasha, d.remainingInAntardasha],\n\t\t\t['Pratyantardasha', d.pratyantardasha, d.remainingInPratyantardasha],\n\t\t\t['Sookshma', d.sookshmaDasha, d.remainingInSookshma],\n\t\t] as const;\n\t\treturn html`<div class=\"current\">${levels.map(([label, period, remaining]) => {\n\t\t\t\tif (!period) return nothing;\n\t\t\t\tconst left = formatBalance(remaining);\n\t\t\t\treturn html`<div><span>${label}</span> <strong>${period.planet}</strong> ${left ? html`<small>${left} left</small>` : nothing}</div>`;\n\t\t\t})}</div>`;\n\t}\n\n\tprivate collectPeriods(d: DashaData): DashaPeriod[] {\n\t\tif ('mahadashas' in d && d.mahadashas?.length) return d.mahadashas;\n\t\tif ('antardashas' in d && d.antardashas?.length) return d.antardashas;\n\t\tif ('pratyantardashas' in d && d.pratyantardashas?.length)\n\t\t\treturn d.pratyantardashas;\n\t\tif ('sookshmaDashas' in d && d.sookshmaDashas?.length)\n\t\t\treturn d.sookshmaDashas;\n\t\treturn [];\n\t}\n\n\t/** True when the current wall-clock time falls between the period's start and end. */\n\tprivate isCurrent(p: DashaPeriod): boolean {\n\t\tif (!p.startDate || !p.endDate) return false;\n\t\tconst now = Date.now();\n\t\tconst start = Date.parse(p.startDate);\n\t\tconst end = Date.parse(p.endDate);\n\t\tif (Number.isNaN(start) || Number.isNaN(end)) return false;\n\t\treturn now >= start && now < end;\n\t}\n\n\t/**\n\t * Fractional progress (0..1) through a period at the current time. Used to\n\t * draw a vertical \"now\" marker inside the active bar. Returns -1 outside the\n\t * period so the caller can skip the marker.\n\t */\n\tprivate progressIn(p: DashaPeriod): number {\n\t\tif (!p.startDate || !p.endDate) return -1;\n\t\tconst start = Date.parse(p.startDate);\n\t\tconst end = Date.parse(p.endDate);\n\t\tconst now = Date.now();\n\t\tif (\n\t\t\tNumber.isNaN(start) ||\n\t\t\tNumber.isNaN(end) ||\n\t\t\tnow < start ||\n\t\t\tnow >= end ||\n\t\t\tend <= start\n\t\t) {\n\t\t\treturn -1;\n\t\t}\n\t\treturn (now - start) / (end - start);\n\t}\n\n\tprivate renderBar(p: DashaPeriod, max: number, grain: DateGrain) {\n\t\tconst years = p.durationYears;\n\t\tconst width = max > 0 ? (years / max) * 100 : 0;\n\t\tconst current = this.isCurrent(p);\n\t\tconst progress = current ? this.progressIn(p) : -1;\n\t\tconst trackClass = current ? 'bar-track bar-now' : 'bar-track';\n\t\treturn html`<div class=\"${current ? 'bar now' : 'bar'}\" role=\"listitem\" aria-current=\"${current ? 'time' : 'false'}\"><span><strong>${p.planet}</strong>${current ? html`<span class=\"now-badge\">Now</span>` : nothing} </span><span class=\"${trackClass}\"><span class=\"bar-fill\" style=\"width:${width}%\"></span> ${\n\t\t\t\t\tprogress >= 0\n\t\t\t\t\t\t? html`<span class=\"bar-progress\" style=\"left:${progress * width}%\" aria-hidden=\"true\"></span>`\n\t\t\t\t\t\t: nothing\n\t\t\t\t} </span><span class=\"dates\">${p.startDate ? formatBoundary(p.startDate, grain) : ''} ${p.endDate ? html`- ${formatBoundary(p.endDate, grain)}` : ''}</span></div>`;\n\t}\n}\n\n/**\n * How precise the bar date column has to be, chosen from the LONGEST period in\n * the set.\n *\n * A Mahadasha spans years, so a bare year reads cleanly and keeps the column\n * narrow. A Sookshma spans days: printed as a year, every one of the nine rows\n * reads \"1990 - 1990\" and the column carries no information at exactly the level\n * a reader opened the drill-down to see.\n */\ntype DateGrain = 'year' | 'month' | 'day';\n\nconst DAYS_PER_YEAR = 365.25;\n\nfunction grainFor(maxYears: number): DateGrain {\n\tif (maxYears >= 2) return 'year';\n\tif (maxYears >= 60 / DAYS_PER_YEAR) return 'month';\n\treturn 'day';\n}\n\n/** One end of a bar, at the chosen granularity. Day grain drops the year: these rows sit under a parent line that already states it, and the column is only 8rem wide. */\nfunction formatBoundary(s: string, grain: DateGrain): string {\n\tif (grain === 'year') {\n\t\tconst m = s.match(/^(\\d{4})/);\n\t\treturn m ? m[1] : s;\n\t}\n\tconst d = new Date(s);\n\tif (Number.isNaN(d.getTime())) return s;\n\tconst month = d.toLocaleString('en', { month: 'short' });\n\treturn grain === 'month'\n\t\t? `${month} ${d.getFullYear()}`\n\t\t: `${d.getDate()} ${month}`;\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'roxy-dasha-timeline': RoxyDashaTimeline;\n\t}\n}\n", "import {\n\ttype CSSResultGroup,\n\thtml,\n\tLitElement,\n\ttype PropertyValues,\n} from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { baseStyles } from './base-styles.js';\nimport { buildRequest, FetchController } from './fetch-controller.js';\nimport { MarkupDataController } from './markup-data.js';\n\n/**\n * Shared base for every data-driven Roxy component. Consolidates the things every component used to repeat by hand and adds the self-contained, drop-in behavior: controlled-mode hydration, an opt-in self-fetch (form, request, loading, error, empty), the typed `data` slot, and the render switch. A subclass implements one method, {@link RoxyDataElement.renderData}.\n *\n * @remarks\n * Two render modes, one component, which is the whole drop-in contract:\n *\n * - Controlled: a server (WordPress, JSX SSR, static HTML) fetches the response and injects it as a direct-child `<script type=\"application/json\" class=\"roxy-data\">`. {@link MarkupDataController} hydrates `data` from it on connect. No key reaches the browser. This is the path the WordPress plugin drives, and it is unchanged by the base class.\n * - Uncontrolled: no data is injected, but a `data-endpoint` and a `pk_` `publishable-key` are set. The component renders its own `<roxy-endpoint-form>` (an internal detail, never placed by the consumer), and on submit fetches through {@link FetchController}, which refuses any non-publishable key. The result populates `data` and the component renders it.\n *\n * The JavaScript `data` property always wins over markup, so a host that assigns `el.data = \u2026` after upgrade is authoritative.\n *\n * Self-fetch needs `<roxy-endpoint-form>` (and `<roxy-location-search>`) registered. The CDN bundle and the full `@roxyapi/ui` entry register everything; per-component ESM consumers that want self-fetch import the form component too.\n *\n * @example\n * ```ts\n * @customElement('roxy-dream-card')\n * export class RoxyDreamCard extends RoxyDataElement<GetDreamSymbolResponse> {\n * static styles = [baseStyles, css`.card { \u2026 }`];\n * protected renderData(d: GetDreamSymbolResponse) {\n * return html`<article class=\"card\">\u2026</article>`;\n * }\n * protected renderEmpty() {\n * return html`<div class=\"roxy-empty\" role=\"status\">No dream symbol</div>`;\n * }\n * }\n * ```\n */\nexport abstract class RoxyDataElement<T = unknown> extends LitElement {\n\tstatic styles: CSSResultGroup = [baseStyles];\n\n\t/** Typed RoxyAPI response. Assigned in JavaScript, hydrated from the roxy-data island, or set by a self-fetch. */\n\t@property({ attribute: false })\n\tdata: T | null = null;\n\n\t/** Endpoint path for self-fetch, e.g. \"astrology/natal-chart\" or \"dreams/symbols/{id}\". Empty disables self-fetch (controlled mode only). */\n\t@property({ type: String, attribute: 'data-endpoint' })\n\tendpoint = '';\n\n\t/** HTTP method for self-fetch. */\n\t@property({ type: String })\n\tmethod: 'GET' | 'POST' = 'POST';\n\n\t/** Browser-safe publishable key (pk_) for self-fetch. A secret key is refused client-side. */\n\t@property({ type: String, attribute: 'publishable-key' })\n\tpublishableKey?: string;\n\n\t/** Override the API origin for self-hosted or proxied deployments. */\n\t@property({ type: String, attribute: 'base-url' })\n\tbaseUrl?: string;\n\n\t/** Override the OpenAPI spec URL the self-fetch form introspects. */\n\t@property({ type: String, attribute: 'spec-url' })\n\tspecUrl?: string;\n\n\t/** Consumer backend route that proxies the request (holds the secret key). When set, self-fetch POSTs the request here instead of calling RoxyAPI directly, so no key reaches the browser. The server-rendered (WordPress) path. */\n\t@property({ type: String, attribute: 'submit-url' })\n\tsubmitUrl?: string;\n\n\t/** Persist the last self-fetch form values in sessionStorage (keyed by endpoint) and prefill the form on reload. */\n\t@property({ type: Boolean })\n\tremember = false;\n\n\t/** Override the self-fetch form's submit-button label. Empty derives one from the endpoint. */\n\t@property({ type: String, attribute: 'submit-label' })\n\tsubmitLabel?: string;\n\n\t/** Render a small \"Spiritual data by RoxyAPI\" credit under a self-fetch or auto-mount result. Off by default; any value except \"off\"/\"false\" enables it. The one-tag widgets script turns it on unless data-attribution=\"off\". Never shown in controlled mode. */\n\t@property({ type: String })\n\tattribution?: string;\n\n\t/** True while an uncontrolled self-fetch is in flight. Public so {@link FetchController} can drive it. */\n\t@state()\n\tloading = false;\n\n\t/** Message from a failed self-fetch, or null. Public so {@link FetchController} can drive it. */\n\t@state()\n\terror: string | null = null;\n\n\t/**\n\t * True once a self-fetch (not a consumer-assigned or island-hydrated `data`) produced the current result. It gates the interactive result affordances, so controlled mode never shows an Edit control or a sticky picker.\n\t */\n\t@state()\n\tprivate selfFetched = false;\n\n\t/** True when the visitor asked to edit a self-fetch result, so the form is restored over the result. */\n\t@state()\n\tprivate editing = false;\n\n\t/** True when the last self-fetch form was a single-enum picker, so it stays visible above the result and a change refetches. */\n\t@state()\n\tprivate sticky = false;\n\n\t/** Last submitted form values (nested per group), kept in memory to restore the form on Edit and to prefill the sticky picker. */\n\tprivate lastValues?: Record<string, unknown>;\n\n\tprivate fetcher: FetchController<T>;\n\n\tconstructor() {\n\t\tsuper();\n\t\t// Controlled mode: hydrate `data` from a direct-child roxy-data island when\n\t\t// no JS property was assigned. Keyless; the server already fetched.\n\t\tnew MarkupDataController<T>(this);\n\t\tthis.fetcher = new FetchController<T>(this);\n\t}\n\n\tprotected willUpdate(changed: PropertyValues): void {\n\t\tif (changed.has('publishableKey')) {\n\t\t\tthis.fetcher.publishableKey = this.publishableKey;\n\t\t}\n\t\tif (changed.has('baseUrl') && this.baseUrl) {\n\t\t\tthis.fetcher.baseUrl = this.baseUrl;\n\t\t}\n\t\tif (changed.has('submitUrl')) {\n\t\t\tthis.fetcher.submitUrl = this.submitUrl;\n\t\t}\n\t}\n\n\trender(): unknown {\n\t\tif (this.loading) return this.renderLoading();\n\t\tif (this.error != null) return this.renderError(this.error);\n\t\tif (this.data != null) {\n\t\t\t// Controlled mode (consumer-assigned or island-hydrated data) renders the\n\t\t\t// result alone, byte-identical to before: no picker, no Edit. The one\n\t\t\t// exception is the widgets auto-mount attrs-complete path, which assigns\n\t\t\t// data directly AND sets `attribution`; a real controlled consumer never\n\t\t\t// sets the attribute, so this stays byte-identical for them.\n\t\t\tif (!this.selfFetched) {\n\t\t\t\treturn this.showAttribution()\n\t\t\t\t\t? html`${this.renderData(this.data)}${this.renderAttribution()}`\n\t\t\t\t\t: this.renderData(this.data);\n\t\t\t}\n\t\t\tif (this.editing) return this.renderForm();\n\t\t\treturn this.renderResult(this.data);\n\t\t}\n\t\treturn this.renderNoData();\n\t}\n\n\t/** Render the populated response. The single method every component implements. */\n\tprotected abstract renderData(data: T): unknown;\n\n\t/**\n\t * A self-fetch result plus its re-query affordance. A single-enum form keeps its picker above the result so a new selection refetches (a sign switch is a new reading); any other form gets a compact Edit control that restores the form with the previous values.\n\t */\n\tprotected renderResult(data: T): unknown {\n\t\tconst body = this.sticky\n\t\t\t? html`${this.renderForm()}${this.renderData(data)}`\n\t\t\t: html`<div class=\"roxy-edit-bar\"><button type=\"button\" class=\"roxy-edit\" @click=\"${this.onEdit}\">Edit query</button></div>${this.renderData(data)}`;\n\t\treturn this.showAttribution()\n\t\t\t? html`${body}${this.renderAttribution()}`\n\t\t\t: body;\n\t}\n\n\tprivate onEdit = () => {\n\t\tthis.editing = true;\n\t};\n\n\t/** True when the attribution credit renders: the attribute is present and not explicitly disabled. */\n\tprivate showAttribution(): boolean {\n\t\treturn (\n\t\t\tthis.attribution != null &&\n\t\t\tthis.attribution !== 'off' &&\n\t\t\tthis.attribution !== 'false'\n\t\t);\n\t}\n\n\t/** Small muted credit under a self-fetch or auto-mount result. Reached only from the result path, so controlled mode never renders it. */\n\tprotected renderAttribution(): unknown {\n\t\treturn html`<div class=\"roxy-attribution\"><a href=\"https://roxyapi.com/?utm_source=widget&utm_medium=embed\" target=\"_blank\" rel=\"noopener\">Spiritual data by RoxyAPI</a></div>`;\n\t}\n\n\t/** The data-absent branch: the self-fetch form when an endpoint is set, otherwise the empty state. */\n\tprotected renderNoData(): unknown {\n\t\treturn this.endpoint ? this.renderForm() : this.renderEmpty();\n\t}\n\n\t/** Internal self-fetch form. Reuses the introspecting `<roxy-endpoint-form>`; the consumer never places it. */\n\tprotected renderForm(): unknown {\n\t\treturn html`<roxy-endpoint-form data-endpoint=\"${this.endpoint}\" method=\"${this.method}\" spec-url=\"${ifDefined(this.specUrl)}\" publishable-key=\"${ifDefined(this.publishableKey)}\" submit-label=\"${ifDefined(this.submitLabel)}\" lang=\"${ifDefined(this.effectiveLang())}\" .initialValues=\"${this.formInitialValues()}\" @roxy-submit=\"${this.onFormSubmit}\"></roxy-endpoint-form>`;\n\t}\n\n\t/** Prefill source for the form: the last submission (Edit / sticky refetch) wins over remembered storage. */\n\tprivate formInitialValues(): Record<string, unknown> | undefined {\n\t\treturn (\n\t\t\tthis.lastValues ?? (this.remember ? this.readRemembered() : undefined)\n\t\t);\n\t}\n\n\t/** Site-owner language from the element `lang` attribute (native accessor), routed to the API query on submit. */\n\tprivate effectiveLang(): string | undefined {\n\t\treturn this.lang || undefined;\n\t}\n\n\tprivate onFormSubmit = (e: Event) => {\n\t\tconst detail = (e as CustomEvent).detail as {\n\t\t\tvalues: Record<string, unknown>;\n\t\t\tqueryKeys?: string[];\n\t\t\tsticky?: boolean;\n\t\t};\n\t\tthis.lastValues = detail.values;\n\t\tthis.sticky = !!detail.sticky;\n\t\tthis.selfFetched = true;\n\t\tthis.editing = false;\n\t\tif (this.remember) this.writeRemembered(detail.values);\n\t\tvoid this.fetcher.run(\n\t\t\tbuildRequest(\n\t\t\t\tthis.endpoint,\n\t\t\t\tthis.method,\n\t\t\t\tdetail.values,\n\t\t\t\tdetail.queryKeys ?? [],\n\t\t\t),\n\t\t);\n\t};\n\n\t/** sessionStorage key for this component's remembered form values, scoped by endpoint. */\n\tprivate rememberKey(): string {\n\t\treturn `roxy-ui:form:${this.endpoint}`;\n\t}\n\n\tprivate readRemembered(): Record<string, unknown> | undefined {\n\t\ttry {\n\t\t\tconst raw = sessionStorage.getItem(this.rememberKey());\n\t\t\treturn raw ? (JSON.parse(raw) as Record<string, unknown>) : undefined;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate writeRemembered(values: Record<string, unknown>): void {\n\t\ttry {\n\t\t\tsessionStorage.setItem(this.rememberKey(), JSON.stringify(values));\n\t\t} catch {\n\t\t\t// Private mode / disabled storage: remembering is best-effort, never fatal.\n\t\t}\n\t}\n\n\t/** Terminal empty state. Subclasses override for a domain-specific message. */\n\tprotected renderEmpty(): unknown {\n\t\treturn html`<div class=\"roxy-empty\" role=\"status\">No data</div>`;\n\t}\n\n\t/** Loading placeholder shown during a self-fetch. */\n\tprotected renderLoading(): unknown {\n\t\treturn html`<div class=\"roxy-skeleton\" style=\"height:8rem\" role=\"status\" aria-label=\"Loading\"></div>`;\n\t}\n\n\t/** Error state shown when a self-fetch fails. Keeps the form in view so the request can be retried. */\n\tprotected renderError(message: string): unknown {\n\t\tconst banner = html`<div class=\"roxy-error\" role=\"alert\">${message}</div>`;\n\t\treturn this.endpoint ? html`${banner}${this.renderForm()}` : banner;\n\t}\n}\n", "import { css } from 'lit';\n\n/**\n * Shared host styles every component pulls in. Sets default font, color,\n * container query support, and the entry fade-in.\n */\nexport const baseStyles = css`:host{font-family:var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-base,1rem);line-height:var(--roxy-leading-normal,1.5);animation:roxy-fade-in var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1)) both;background:0 0;display:block;container-type:inline-size}:host([bare]){--roxy-surface:transparent;--roxy-shadow-sm:none;--roxy-shadow-md:none}*,:before,:after{box-sizing:border-box}h1,h2,h3,h4{font-family:var(--roxy-font-display,var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif))}@keyframes roxy-fade-in{0%{opacity:0;transform:translateY(2px)}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion:reduce){:host{animation:none}}.roxy-skeleton{background:linear-gradient(90deg, var(--roxy-border,#e4e4e7) 0%, color-mix(in srgb, var(--roxy-border,#e4e4e7) 60%, transparent) 50%, var(--roxy-border,#e4e4e7) 100%);border-radius:var(--roxy-radius-md,8px);background-size:200% 100%;animation:1.4s ease-in-out infinite roxy-shimmer}@keyframes roxy-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){.roxy-skeleton{animation:none}}.roxy-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.roxy-empty{padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-muted,#71717a);text-align:center;font-size:var(--roxy-text-sm,.875rem)}.roxy-error{gap:var(--roxy-space-sm,.5rem);padding:var(--roxy-space-lg,1.5rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}.roxy-surface{background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a)}:host(:focus-within) .roxy-card{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-attribution{margin-top:var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-xs,.75rem);color:var(--roxy-muted,#71717a);text-align:right}.roxy-attribution a{color:inherit;text-decoration:none}.roxy-attribution a:hover{color:var(--roxy-accent-ink,#b45309);text-decoration:underline}.roxy-attribution a:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-edit-bar{margin-bottom:var(--roxy-space-sm,.5rem);justify-content:flex-end;display:flex}.roxy-edit{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;background:0 0}.roxy-edit:hover{border-color:var(--roxy-accent,#f59e0b);color:var(--roxy-accent-ink,#b45309)}.roxy-edit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}:host{font-variant-emoji:text}`;\n", "/**\n * The one place the \"publishable key only\" rule lives. Every client-side fetch boundary ({@link ../components/location-search.ts}, {@link ./fetch-controller.ts}) calls through here so a secret or legacy unprefixed key is refused identically: no network call, the same visible message, the same `roxy-validation-error` event. Centralising it is what stops the two paths drifting, which is exactly how `<roxy-location-search>` used to warn-then-fetch a secret key while the controller fail-closed.\n */\n\n/** Canonical refusal message. Both fetch boundaries surface this exact wording. */\nexport const KEY_REFUSED_MESSAGE =\n\t'Client-side components accept a pk_ publishable key only. Use a publishable key with an origin allowlist, or render server-side.';\n\n/** True when the key is a browser-safe `pk_` publishable key. */\nexport function isPublishableKey(key: string | undefined | null): boolean {\n\treturn !!key && key.startsWith('pk_');\n}\n\n/**\n * The fail-closed condition: a key is PRESENT and is NOT a `pk_` key. An absent key is not refused, so a keyless public call (a form-slotted city search with no key set) still proceeds; only a real secret/legacy token in the browser is stopped.\n */\nexport function keyIsRefused(key: string | undefined | null): boolean {\n\treturn !!key && !key.startsWith('pk_');\n}\n\n/**\n * Announce a refused key: dispatch the shared `roxy-validation-error` (bubbling, composed) and, when `warn` is set, log it once for the developer. The caller sets its own visible error state and skips the fetch; this only handles the parts both boundaries share.\n */\nexport function dispatchKeyRefusal(\n\thost: EventTarget,\n\topts: { warn?: boolean } = {},\n): void {\n\tif (opts.warn) console.warn(KEY_REFUSED_MESSAGE);\n\thost.dispatchEvent(\n\t\tnew CustomEvent('roxy-validation-error', {\n\t\t\tdetail: { reason: 'possible-secret-key', message: KEY_REFUSED_MESSAGE },\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t}),\n\t);\n}\n", "import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport {\n\tdispatchKeyRefusal,\n\tKEY_REFUSED_MESSAGE,\n\tkeyIsRefused,\n} from './key-guard.js';\n\n/**\n * Host slots the controller drives. {@link RoxyDataElement} satisfies this, so the form mixin can attach a controller without the component wiring state by hand.\n *\n * @remarks\n * Intersected with `HTMLElement` because the controller dispatches events on the host. Lit's `ReactiveControllerHost` is the update-lifecycle contract only (`addController`, `requestUpdate`, `updateComplete`) and carries no DOM surface, even though every real host is a `LitElement` and therefore an `HTMLElement`. Declaring the DOM half is what the controller actually needs; it used to reach it through a `this.host as unknown as EventTarget` double cast instead, which asserted a capability the type never promised.\n */\ntype FetchHost<T> = ReactiveControllerHost &\n\tHTMLElement & {\n\t\tdata: T | null;\n\t\tloading: boolean;\n\t\terror: string | null;\n\t};\n\n/** Default RoxyAPI v2 origin. A component overrides it per instance via its `base-url` attribute. */\nconst DEFAULT_BASE_URL = 'https://roxyapi.com/api/v2';\n\n/** A single request the controller issues on the component's behalf. */\nexport interface RoxyRequest {\n\t/** Path under the API base, e.g. \"/dreams/symbols/water\" or \"/astrology/natal-chart\". */\n\tpath: string;\n\tmethod?: 'GET' | 'POST';\n\t/** JSON body for POST endpoints. */\n\tbody?: unknown;\n\t/** Query string parameters; nullish values are dropped. */\n\tquery?: Record<string, string | number | undefined>;\n}\n\n/**\n * Client-side fetch for uncontrolled (self-fetching) components: drives `host.data` / `host.loading` / `host.error` and cancels a stale request when a newer one starts or the host disconnects.\n *\n * @remarks\n * Security boundary. The only credential this ever sends is a `pk_` publishable key, which carries a server-side origin allowlist. A secret (`sk_`) or legacy unprefixed key is refused before any network call and surfaced as an error, so a server secret cannot leak into a browser request. This centralizes the guard that originated in `<roxy-location-search>` so every self-fetching component enforces it identically.\n *\n * Controlled-mode components never construct this. When a server injects the response as a `<script class=\"roxy-data\">` island, there is no key and no fetch, which is the path server-rendered consumers (WordPress, JSX SSR, static HTML) rely on.\n */\nexport class FetchController<T = unknown> implements ReactiveController {\n\tprivate readonly host: FetchHost<T>;\n\tprivate abort?: AbortController;\n\n\t/** Browser-safe publishable key. Set by the host from its `publishable-key` attribute. */\n\tpublishableKey?: string;\n\t/** API origin, overridable for self-hosted or proxied deployments. */\n\tbaseUrl = DEFAULT_BASE_URL;\n\t/**\n\t * Consumer backend route that holds the secret key. When set, the request is POSTed here as `{ path, method, body, query }` instead of called against RoxyAPI directly, so no key (publishable or secret) is sent from the browser. This is the canonical path for server-rendered hosts (WordPress); the backend proxies the request with its own `sk_` key and returns the JSON response.\n\t */\n\tsubmitUrl?: string;\n\n\tconstructor(host: FetchHost<T>) {\n\t\tthis.host = host;\n\t\thost.addController(this);\n\t}\n\n\thostDisconnected() {\n\t\tthis.abort?.abort();\n\t\tthis.abort = undefined;\n\t}\n\n\t/**\n\t * Issue the request and resolve once `host.data` (success) or `host.error`\n\t * (failure) is set. A no-op return when a non-publishable key is present:\n\t * the error is already surfaced and nothing is sent.\n\t */\n\tasync run(req: RoxyRequest): Promise<void> {\n\t\t// submit-url proxy: no key leaves the browser; the consumer's backend holds it.\n\t\tif (!this.submitUrl && this.secretKeyRefused()) return;\n\t\tthis.abort?.abort();\n\t\tconst controller = new AbortController();\n\t\tthis.abort = controller;\n\t\tthis.host.loading = true;\n\t\tthis.host.error = null;\n\t\ttry {\n\t\t\tconst res = this.submitUrl\n\t\t\t\t? await fetch(this.submitUrl, {\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\tAccept: 'application/json',\n\t\t\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: JSON.stringify(req),\n\t\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t\t})\n\t\t\t\t: await this.callApi(req, controller.signal);\n\t\t\tif (!res.ok) throw new Error(await this.readError(res));\n\t\t\tconst json = (await res.json()) as T;\n\t\t\tif (controller.signal.aborted) return;\n\t\t\tthis.host.data = json;\n\t\t} catch (err) {\n\t\t\tif ((err as { name?: string })?.name === 'AbortError') return;\n\t\t\tthis.host.error = err instanceof Error ? err.message : String(err);\n\t\t} finally {\n\t\t\tif (this.abort === controller) this.abort = undefined;\n\t\t\tif (!controller.signal.aborted) this.host.loading = false;\n\t\t}\n\t}\n\n\t/** Direct call against RoxyAPI with the publishable key (the no-backend path). */\n\tprivate callApi(req: RoxyRequest, signal: AbortSignal): Promise<Response> {\n\t\tconst url = new URL(`${this.baseUrl}${req.path}`);\n\t\tfor (const [k, v] of Object.entries(req.query ?? {})) {\n\t\t\tif (v != null) url.searchParams.set(k, String(v));\n\t\t}\n\t\tconst headers: Record<string, string> = { Accept: 'application/json' };\n\t\tif (this.publishableKey) headers['X-API-Key'] = this.publishableKey;\n\t\tif (req.body != null) headers['Content-Type'] = 'application/json';\n\t\treturn fetch(url, {\n\t\t\tmethod: req.method ?? 'GET',\n\t\t\theaders,\n\t\t\tbody: req.body != null ? JSON.stringify(req.body) : undefined,\n\t\t\tsignal,\n\t\t});\n\t}\n\n\t/** True when a key is set and it is not a browser-safe `pk_` publishable key. Surfaces the error and refuses to send, via the shared {@link keyIsRefused} guard so every fetch boundary fail-closes identically. */\n\tprivate secretKeyRefused(): boolean {\n\t\tif (!keyIsRefused(this.publishableKey)) return false;\n\t\tthis.host.error = KEY_REFUSED_MESSAGE;\n\t\tdispatchKeyRefusal(this.host);\n\t\treturn true;\n\t}\n\n\t/** Surface the `{ error, code }` message the API returns on failure, falling back to the status code. */\n\tprivate async readError(res: Response): Promise<string> {\n\t\ttry {\n\t\t\tconst body = (await res.json()) as { error?: string };\n\t\t\tif (body?.error) return body.error;\n\t\t} catch {\n\t\t\t// Non-JSON error body: fall through to the status line.\n\t\t}\n\t\treturn `Request failed (${res.status})`;\n\t}\n}\n\n/**\n * Translate flat form values into a {@link RoxyRequest} for an endpoint. The `{name}` segments in the endpoint template are substituted from the values and removed; the rest become the JSON body for POST or query parameters for GET. This is the spec-light request builder the base element uses to turn a `<roxy-endpoint-form>` submission into a self-fetch, so a component needs no per-endpoint glue.\n *\n * @param queryKeys - Names the spec declares as `in: query` for this operation, which `<roxy-endpoint-form>` reports on its `roxy-submit` event. A POST operation can still take query parameters (every localized endpoint takes `?lang=`), and sending one in the JSON body silently drops it, so those names are routed to the query string on POST as well as GET.\n */\nexport function buildRequest(\n\tendpoint: string,\n\tmethod: 'GET' | 'POST',\n\tvalues: Record<string, unknown>,\n\tqueryKeys: readonly string[] = [],\n): RoxyRequest {\n\tconst rest: Record<string, unknown> = { ...values };\n\tconst path = `/${endpoint.replace(/^\\//, '')}`.replace(\n\t\t/\\{([^}]+)\\}/g,\n\t\t(_match, name: string) => {\n\t\t\tconst v = rest[name];\n\t\t\tdelete rest[name];\n\t\t\treturn encodeURIComponent(String(v ?? ''));\n\t\t},\n\t);\n\tconst inQuery = new Set(queryKeys);\n\tconst query: Record<string, string | number | undefined> = {};\n\tconst body: Record<string, unknown> = {};\n\tfor (const [k, v] of Object.entries(rest)) {\n\t\tif (v === undefined || v === '') continue;\n\t\tif (method === 'GET' || inQuery.has(k)) query[k] = v as string | number;\n\t\telse body[k] = v;\n\t}\n\treturn { path, method, query, body: method === 'POST' ? body : undefined };\n}\n", "import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\n/**\n * Marker class on the inline JSON script a server emits inside a component.\n *\n * @example\n * ```html\n * <roxy-natal-chart>\n * <script type=\"application/json\" class=\"roxy-data\">{ ...response... }</script>\n * </roxy-natal-chart>\n * ```\n */\nconst ROXY_DATA_CLASS = 'roxy-data';\n\n/**\n * Serialize a RoxyAPI response for embedding inside an inline `<script type=\"application/json\" class=\"roxy-data\">`. This is the safe writer counterpart to {@link MarkupDataController}, the reader: server-rendered and cached consumers (WordPress, JSX SSR, static HTML) emit the script with this, and the component hydrates `data` from it on connect.\n *\n * @remarks\n * Use this instead of a bare `JSON.stringify`. A raw stringify of a response that contains the literal text `</script>` (common in long interpretation prose) closes the script element early, corrupting the page and creating an HTML-injection vector. This escapes the script-unsafe characters to their `\\uXXXX` JSON escapes, which `JSON.parse` restores to the original characters, so the value the component receives is identical to the response you passed.\n *\n * `<` is the load-bearing escape (it defeats `</script>` and `<!--`). `>` and `&` are escaped for defence in depth, and U+2028 / U+2029 because they are valid in JSON yet are line terminators in a `<script>` context and break some parsers. The escapes introduce only `\\uXXXX` sequences, so the replacements never feed each other and order is irrelevant.\n *\n * Pass the unwrapped RoxyAPI response, the same shape you would assign to `element.data`. Do not pass the SDK envelope (`{ data, error, request, response }`).\n *\n * @example\n * ```ts\n * import { serializeRoxyData } from '@roxyapi/ui';\n *\n * const { data } = await roxy.dreams.getDreamSymbol({ path: { id: 'water' } });\n * const html = `<roxy-dream-card><script type=\"application/json\" class=\"roxy-data\">${serializeRoxyData(data)}</script></roxy-dream-card>`;\n * ```\n */\nexport function serializeRoxyData(data: unknown): string {\n\treturn JSON.stringify(data)\n\t\t.replace(/</g, '\\\\u003c')\n\t\t.replace(/>/g, '\\\\u003e')\n\t\t.replace(/&/g, '\\\\u0026')\n\t\t.replace(/\\u2028/g, '\\\\u2028')\n\t\t.replace(/\\u2029/g, '\\\\u2029');\n}\n\n/**\n * Build the complete `<script type=\"application/json\" class=\"roxy-data\">\u2026</script>` element a server nests inside a `roxy-*` component for the no-JavaScript hydration path. The payload is escaped via {@link serializeRoxyData}, so it is safe to drop straight into HTML output.\n *\n * @remarks\n * The element carries both `type=\"application/json\"` and `class=\"roxy-data\"` because {@link MarkupDataController} reads only a direct-child script that has both. Emit one of these inside the target component; the JavaScript `data` property still wins if it is later assigned.\n *\n * @example\n * ```ts\n * import { roxyDataScript } from '@roxyapi/ui';\n *\n * const { data } = await roxy.crystals.getCrystal({ path: { id: 'amethyst' } });\n * const html = `<roxy-crystal-grid>${roxyDataScript(data)}</roxy-crystal-grid>`;\n * ```\n */\nexport function roxyDataScript(data: unknown): string {\n\treturn `<script type=\"application/json\" class=\"${ROXY_DATA_CLASS}\">${serializeRoxyData(data)}</script>`;\n}\n\n/**\n * True when the element is a `<script type=\"application/json\">`. Uses tag name and attribute rather than `instanceof HTMLScriptElement` so the check holds in every DOM implementation, including server-rendered and hydration runtimes where the constructor global may be absent.\n */\nfunction isJsonScript(el: Element): boolean {\n\treturn (\n\t\tel.nodeName === 'SCRIPT' && el.getAttribute('type') === 'application/json'\n\t);\n}\n\n/**\n * Host shape the controller drives: any reactive element that exposes a public `data` slot. The controller only writes `data` when the host left it unset, so the JavaScript property path always wins.\n */\ninterface DataHost extends ReactiveControllerHost, HTMLElement {\n\tdata?: unknown;\n}\n\n/**\n * Reactive controller that lets a component hydrate its `data` from embedded markup when no `data` property was assigned in JavaScript.\n *\n * @remarks\n * The server-side and cached-render model: a backend renders the RoxyAPI response into a direct-child `<script type=\"application/json\" class=\"roxy-data\">` element, ships static HTML, and never runs per-element JavaScript to assign a property. On connect this controller reads that script, parses it, and feeds the result to the host. The JavaScript property path is untouched and authoritative: if `host.data` already holds a value when the host connects, the controller does nothing and the markup is ignored.\n *\n * Source resolution order on connect, first hit wins:\n *\n * 1. `host.data` already set in JavaScript -> leave it, read nothing.\n * 2. A direct-child `<script type=\"application/json\" class=\"roxy-data\">` -> parse and use. Direct-child only, so a nested component's own script is never read by an ancestor.\n *\n * Fetching from a URL is intentionally unsupported: that would require a browser-visible key and breaks the server-rendered, cached model these consumers rely on.\n *\n * Timing: {@link hostConnected} runs inside the host `connectedCallback`. For an element parsed from server HTML, its direct children are present by the time the custom element upgrades and connects, so the script is readable here. For an element created with `document.createElement` and connected before any child is appended, there is nothing to read and the property path is the only source, which is exactly the existing behavior.\n *\n * Failure is safe: malformed JSON or a missing script leaves `host.data` untouched, so the host renders its normal empty state.\n *\n * Reading the script never mutates it, and only the marked script is touched, so any sibling fallback markup a server nested inside the element (for no-JavaScript, AMP, or crawler rendering) is left in place.\n *\n * @example\n * ```ts\n * import { MarkupDataController } from '../utils/markup-data.js';\n *\n * export class RoxyExample extends LitElement {\n * constructor() {\n * super();\n * new MarkupDataController(this);\n * }\n *\n * @property({ attribute: false })\n * data: ExampleResponse | null = null;\n * }\n * ```\n */\nexport class MarkupDataController<T = unknown> implements ReactiveController {\n\tprivate readonly host: DataHost;\n\n\tconstructor(host: DataHost) {\n\t\tthis.host = host;\n\t\thost.addController(this);\n\t}\n\n\thostConnected() {\n\t\t// Property path wins. If the consumer (React, vanilla `.data =`, the\n\t\t// widgets script, an MCP agent) already set data, never look at markup.\n\t\tif (this.host.data != null) return;\n\n\t\tconst parsed = this.read();\n\t\tif (parsed === undefined) return;\n\n\t\tthis.host.data = parsed as T;\n\t\tthis.host.requestUpdate();\n\t}\n\n\t/**\n\t * Resolve the embedded payload. Returns `undefined` when there is nothing valid to read so the caller can leave `host.data` untouched.\n\t */\n\tprivate read(): T | undefined {\n\t\tconst inline = this.findInlineScript();\n\t\treturn inline ? this.parse(inline.textContent) : undefined;\n\t}\n\n\t/**\n\t * Direct-child `<script type=\"application/json\" class=\"roxy-data\">`. Scoped to immediate children so a nested data-driven component never has its script read by an ancestor, and so sibling fallback markup is ignored.\n\t */\n\tprivate findInlineScript(): Element | null {\n\t\tfor (const child of Array.from(this.host.children)) {\n\t\t\tif (isJsonScript(child) && child.classList.contains(ROXY_DATA_CLASS)) {\n\t\t\t\treturn child;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\tprivate parse(text: string | null): T | undefined {\n\t\tif (!text?.trim()) return undefined;\n\t\ttry {\n\t\t\treturn JSON.parse(text) as T;\n\t\t} catch {\n\t\t\t// Malformed embedded JSON: fail safe, leave the host empty state in\n\t\t\t// place rather than throwing during connect.\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n", "import type { TemplateResult } from 'lit';\nimport { css, html } from 'lit';\n\n/**\n * Disclosure chevron for `<details>`/`<summary>` accordions. Replaces the\n * browser default triangle with a thin chevron that rotates when the host\n * `<details>` opens. Render it inside the `<summary>` and pair with\n * {@link disclosureStyles}.\n */\nexport function chevron(): TemplateResult {\n\treturn html`<svg class=\"roxy-chevron\" viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" aria-hidden=\"true\"><path d=\"M4 6l4 4 4-4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n}\n\n/**\n * Shared `<details>` accordion styling: hides the native disclosure triangle\n * and rotates the {@link chevron} 180 degrees when the accordion is open.\n * Import into any component that renders disclosure accordions so the chevron\n * looks and behaves identically.\n */\nexport const disclosureStyles = css`summary{list-style:none}summary::-webkit-details-marker{display:none}.roxy-chevron{aspect-ratio:auto;width:14px;height:14px;color:var(--roxy-muted,#71717a);transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0}details[open]>summary .roxy-chevron{transform:rotate(180deg)}@media (prefers-reduced-motion:reduce){.roxy-chevron{transition:none}}`;\n", "/**\n * Display formatters for ISO timestamps and floats coming back from the API.\n * Every helper returns \"\" for nullish or unparseable input so it falls out of\n * template literals cleanly.\n */\n\nconst DATE_ONLY = /^\\d{4}-\\d{2}-\\d{2}$/;\nconst BARE_TIME = /^\\d{2}:\\d{2}(:\\d{2})?$/;\n/** An ISO datetime with NO timezone designator: a wall clock, not an instant. */\nconst NAIVE_DATETIME = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?$/;\n\n/**\n * Resolve an API timestamp to a Date plus the timezone it must be RENDERED in.\n *\n * @remarks\n * The API returns chart times naive (`2026-07-13T04:36:00`): that is 04:36 in the CHART's timezone, not UTC and not the viewer's. A wall clock must read the same for every viewer on earth, so hora at sunrise says 04:36 in Tokyo and in Chicago alike.\n *\n * Handing a naive string to `new Date()` makes the runtime interpret it in the VIEWER's zone, which is a silent corruption whenever that wall clock lands in the viewer's DST gap. In America/New_York `2026-03-08T02:30:00` does not exist, so the clock jumps and it renders as `3:30 AM`. Pinning the wall clock to UTC, which has no DST and therefore no gap, preserves the digits exactly while Intl still applies the viewer's locale conventions.\n *\n * An offset-bearing timestamp (`...Z`, `...+05:30`) IS a real instant, so it keeps the normal behaviour and converts to the viewer's local time.\n */\nfunction resolve(input: string): { d: Date; timeZone?: string } {\n\tconst naive = BARE_TIME.test(input)\n\t\t? `1970-01-01T${input}`\n\t\t: NAIVE_DATETIME.test(input)\n\t\t\t? input\n\t\t\t: null;\n\treturn naive\n\t\t? { d: new Date(`${naive}Z`), timeZone: 'UTC' }\n\t\t: { d: new Date(input) };\n}\n\nexport function formatTime(input: unknown): string {\n\tif (typeof input !== 'string' || input.length === 0) return '';\n\tif (DATE_ONLY.test(input)) return '';\n\tconst { d, timeZone } = resolve(input);\n\tif (Number.isNaN(d.getTime())) return input;\n\treturn d.toLocaleTimeString(undefined, {\n\t\thour: 'numeric',\n\t\tminute: '2-digit',\n\t\thour12: true,\n\t\ttimeZone,\n\t});\n}\n\nexport function formatDate(input: unknown): string {\n\tif (typeof input !== 'string' || input.length === 0) return '';\n\tconst { d, timeZone } = resolve(\n\t\tDATE_ONLY.test(input) ? `${input}T00:00:00` : input,\n\t);\n\tif (Number.isNaN(d.getTime())) return input;\n\treturn d.toLocaleDateString(undefined, {\n\t\tmonth: 'short',\n\t\tday: 'numeric',\n\t\tyear: 'numeric',\n\t\ttimeZone,\n\t});\n}\n\nexport function formatTimeRange(\n\tt: { start?: string; end?: string } | undefined,\n): string {\n\tif (!t) return '';\n\tconst start = formatTime(t.start);\n\tconst end = formatTime(t.end);\n\tif (start && end) return `${start} - ${end}`;\n\treturn start || end || '';\n}\n\n/**\n * Format a number, dropping trailing zeros in the FRACTIONAL part only: `2.50` becomes `2.5`, `2.0` becomes `2`, and `100` stays `100`.\n *\n * @remarks\n * The old implementation ran `.replace(/\\.?0+$/, '')` against the whole string, which happily ate zeros off the INTEGER when there was no decimal point. At `dp = 0` that meant `100` rendered as `1`, `90` as `9`, `20` as `2`, and `0` as the empty string. It shipped: a 100 percent tight stellium displayed as \"1% tight\", and an aspect of strength 100 as \"str 1\". Guard on the decimal point, and never strip from the integer side.\n *\n * @example\n * ```ts\n * formatNumber(100, 0); // '100'\n * formatNumber(2.5, 1); // '2.5'\n * formatNumber(2, 1); // '2'\n * formatNumber(0, 0); // '0'\n * ```\n */\nexport function formatNumber(value: unknown, dp = 1): string {\n\tif (typeof value !== 'number' || !Number.isFinite(value)) return '';\n\tconst fixed = value.toFixed(dp);\n\treturn fixed.includes('.') ? fixed.replace(/\\.?0+$/, '') : fixed;\n}\n\nexport function formatPercent(value: unknown, dp = 1): string {\n\tconst n = formatNumber(value, dp);\n\treturn n ? `${n}%` : '';\n}\n\n/**\n * CSS class name per aspect type. Used by natal and synastry chart aspect\n * lines so the same color encoding (harmonious vs challenging) applies in\n * both wheels. Keys are lowercase canonical names, values are CSS class\n * suffixes the chart components define in their `:host` styles.\n */\nexport const ASPECT_CLASS: Record<string, string> = {\n\tconjunction: 'aspect-conjunction',\n\tsextile: 'aspect-sextile',\n\tsquare: 'aspect-square',\n\ttrine: 'aspect-trine',\n\topposition: 'aspect-opposition',\n};\n\n/**\n * Normalize the `type` field on an aspect entry to a lowercase, hyphen-separated\n * canonical name (`SEMI_SEXTILE` \u2192 `semi-sextile`). Accepts any aspect-shaped\n * object so both natal and synastry inter-aspect entries can share this.\n */\nexport function normalizeAspect(a: { type?: string }): string {\n\treturn (a.type ?? '').toLowerCase().replace(/_/g, '-');\n}\n", "/**\n * The interpretation accordion: the one way this library shows a label, a short value, and a body of prose behind a disclosure.\n *\n * @remarks\n * Exclusive by construction (`<details name>`), so a card grows by at most one open section and never becomes a wall of text. Callers pass their own group `name` so two accordions on one page do not fight over which section is open.\n *\n * This lives here rather than in a component because the same accordion is the right shape wherever an endpoint returns a labelled reading: the Human Design bodygraph and type card use it for strategy, authority, and aura; `roxy-hexagram` uses it for the changing lines. The CSS was copy-pasted into six components before 2026-07 and had already drifted (`.interp-body` had five distinct definitions), which is the drift this exists to stop. Migrate the remaining copies to it when they are next touched.\n */\n\nimport { css, html, nothing } from 'lit';\nimport { chevron } from './disclosure.js';\n\n/** One row: the label, the short value shown as the aside, and the interpretation body. `extra` renders under the body for a section that carries more than prose. */\nexport interface InterpSection {\n\tlabel: string;\n\taside?: string;\n\tbody: string;\n\textra?: unknown;\n}\n\nexport const interpAccordionStyles = css`.block{border-top:1px solid var(--roxy-border,#e4e4e7);padding-top:var(--roxy-space-md,1rem)}.block h3{margin:0 0 var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-muted,#71717a);text-transform:uppercase;letter-spacing:.06em}.interp-card{border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);margin-bottom:var(--roxy-space-xs,.25rem)}.interp-card summary{cursor:pointer;color:var(--roxy-fg,#0a0a0a);align-items:center;gap:var(--roxy-space-sm,.5rem);font-weight:500;font-size:var(--roxy-text-sm,.875rem);display:flex}.interp-card summary:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px;border-radius:var(--roxy-radius-sm,4px)}.interp-lead{flex-wrap:wrap;flex:auto;order:1;align-items:baseline;gap:.4rem;min-width:0;display:inline-flex}.interp-aside{flex-shrink:0;order:2;align-items:center;gap:.5rem;display:inline-flex}.roxy-chevron{order:3}.interp-aside small{color:var(--roxy-muted,#71717a);white-space:nowrap;font-weight:400}@container (width<=26rem){.interp-card summary{flex-wrap:wrap}.roxy-chevron{order:2}.interp-aside{flex-basis:100%;order:3;justify-content:flex-end}}.interp-body{margin-top:var(--roxy-space-sm,.5rem);gap:var(--roxy-space-sm,.5rem);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-sm,.875rem);overflow-wrap:anywhere;line-height:1.6;display:grid}.interp-body p{margin:0}`;\n\n/**\n * Render the accordion. Sections with no body are dropped, so a caller can pass the full set and let a narrower response render only what it carries. `name` groups the `<details>` exclusively, so opening one closes the last.\n */\nexport function renderInterpAccordion(\n\tsections: InterpSection[],\n\tname: string,\n\theading = 'Reading',\n) {\n\tconst shown = sections.filter((s) => Boolean(s.body));\n\tif (shown.length === 0) return nothing;\n\n\treturn html`<section class=\"block\"><h3>${heading}</h3>${shown.map(\n\t\t\t(s, i) => html`<details class=\"interp-card\" name=\"${name}\" ?open=\"${i === 0}\"><summary><span class=\"interp-lead\">${s.label}</span> ${chevron()} ${s.aside ? html`<span class=\"interp-aside\"><small>${s.aside}</small></span>` : nothing}</summary><div class=\"interp-body\"><p>${s.body}</p>${s.extra ?? nothing}</div></details>`,\n\t\t)}</section>`;\n}\n", "import type { TemplateResult } from 'lit';\nimport { css, html, nothing } from 'lit';\n\n/** A single tab in a {@link renderTablist} strip. */\nexport interface TablistItem<T extends string = string> {\n\tid: T;\n\tlabel: string;\n}\n\n/**\n * Shared styling for every horizontal tab strip in the library (natal chart\n * views, transits, kundli styles). Keeping one rule set means the tabs look\n * identical everywhere and theme through the same --roxy-* tokens.\n */\nexport const tablistStyles = css`.roxy-tablist{border-bottom:2px solid var(--roxy-border,#e4e4e7);scrollbar-width:thin;gap:2px;min-width:0;display:flex;overflow-x:auto}.roxy-tab{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);font-size:var(--roxy-text-sm,.875rem);cursor:pointer;color:var(--roxy-muted,#71717a);transition:color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);background:0 0;border:none;border-bottom:2px solid #0000;flex-shrink:0;margin-bottom:-2px;font-family:inherit}.roxy-tab[aria-selected=true]{color:var(--roxy-accent-ink,#b45309);border-bottom-color:var(--roxy-accent,#f59e0b);font-weight:var(--roxy-weight-bold,600)}.roxy-tab:hover:not([aria-selected=true]){color:var(--roxy-fg,#0a0a0a)}.roxy-tab:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:-2px;border-radius:4px}`;\n\n/**\n * Render a WAI-ARIA tablist. The host component owns the active-tab state; this\n * helper draws the buttons, wires click plus Left/Right arrow navigation with a\n * roving tabindex, and moves focus to the newly selected tab. Pair with\n * {@link tablistStyles}.\n *\n * Pass `controls: true` when each tab governs a sibling\n * `<div role=\"tabpanel\" id=\"${idPrefix}-panel-${id}\">` so the buttons advertise\n * `aria-controls`. Omit it for tablists that swap a single rendered view in\n * place with no separate panel element (the kundli style switch).\n *\n * @example\n * ```ts\n * renderTablist({\n * items: [{ id: 'wheel', label: 'Wheel' }, { id: 'grid', label: 'Aspect grid' }],\n * active: this.view,\n * onSelect: (v) => { this.view = v; },\n * label: 'Natal chart views',\n * idPrefix: 'natal',\n * controls: true,\n * })\n * ```\n */\nexport function renderTablist<T extends string>(opts: {\n\titems: ReadonlyArray<TablistItem<T>>;\n\tactive: T;\n\tonSelect: (id: T) => void;\n\tlabel: string;\n\tidPrefix: string;\n\tcontrols?: boolean;\n}): TemplateResult {\n\tconst { items, active, onSelect, label, idPrefix, controls = false } = opts;\n\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\tif (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft') return;\n\t\te.preventDefault();\n\t\tconst idx = items.findIndex((it) => it.id === active);\n\t\tif (idx === -1) return;\n\t\tconst delta = e.key === 'ArrowRight' ? 1 : -1;\n\t\tconst next = items[(idx + delta + items.length) % items.length];\n\t\tif (!next) return;\n\t\tonSelect(next.id);\n\t\tconst root = (e.currentTarget as HTMLElement).getRootNode() as\n\t\t\t| ShadowRoot\n\t\t\t| Document;\n\t\trequestAnimationFrame(() => {\n\t\t\troot\n\t\t\t\t.querySelector<HTMLButtonElement>(`#${idPrefix}-tab-${next.id}`)\n\t\t\t\t?.focus();\n\t\t});\n\t};\n\treturn html`<div class=\"roxy-tablist\" role=\"tablist\" aria-label=\"${label}\" @keydown=\"${onKeyDown}\">${items.map(\n\t\t\t(it) => html`<button type=\"button\" class=\"roxy-tab\" role=\"tab\" id=\"${idPrefix}-tab-${it.id}\" aria-selected=\"${active === it.id ? 'true' : 'false'}\" aria-controls=\"${\n\t\t\t\t\t// Only the active panel is rendered, so only the active tab points\n\t\t\t\t\t// at a live element; otherwise aria-controls would dangle.\n\t\t\t\t\tcontrols && active === it.id ? `${idPrefix}-panel-${it.id}` : nothing\n\t\t\t\t}\" tabindex=\"${active === it.id ? '0' : '-1'}\" @click=\"${() => onSelect(it.id)}\">${it.label}</button>`,\n\t\t)}</div>`;\n}\n"],
5
+ "mappings": "wMAAA,OAAS,OAAAA,GAAK,QAAAC,EAAM,WAAAC,MAAe,MACnC,OAAS,iBAAAC,GAAe,YAAAC,GAAU,SAAAC,OAAa,oBCD/C,OAEC,QAAAC,EACA,cAAAC,MAEM,MACP,OAAS,YAAAC,EAAU,SAAAC,MAAa,oBAChC,OAAS,aA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QAASqC,CAAK,CAAC,GAAK,EAAE,eACvJ,CACD,EA3TajC,EACL,OAAS,CACfwC,EACAC,EACAC,EACAC,EACAC,00FACD,EAUAC,EAAA,CADCC,GAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GAhB7B9C,EAiBZ,sBAIQ6C,EAAA,CADPE,GAAM,GApBK/C,EAqBJ,oBArBIA,EAAN6C,EAAA,CADNG,GAAc,qBAAqB,GACvBhD,GAwUb,IAAMiD,GAAgB,OAEtB,SAASpC,GAAST,EAA6B,CAC9C,OAAIA,GAAY,EAAU,OACtBA,GAAY,GAAK6C,GAAsB,QACpC,KACR,CAGA,SAASV,EAAeW,EAAWjB,EAA0B,CAC5D,GAAIA,IAAU,OAAQ,CACrB,IAAMkB,EAAID,EAAE,MAAM,UAAU,EAC5B,OAAOC,EAAIA,EAAE,CAAC,EAAID,CACnB,CACA,IAAM5D,EAAI,IAAI,KAAK4D,CAAC,EACpB,GAAI,OAAO,MAAM5D,EAAE,QAAQ,CAAC,EAAG,OAAO4D,EACtC,IAAME,EAAQ9D,EAAE,eAAe,KAAM,CAAE,MAAO,OAAQ,CAAC,EACvD,OAAO2C,IAAU,QACd,GAAGmB,CAAK,IAAI9D,EAAE,YAAY,CAAC,GAC3B,GAAGA,EAAE,QAAQ,CAAC,IAAI8D,CAAK,EAC3B",
6
+ "names": ["css", "html", "nothing", "customElement", "property", "state", "html", "LitElement", "property", "state", "ifDefined", "css", "baseStyles", "KEY_REFUSED_MESSAGE", "keyIsRefused", "key", "dispatchKeyRefusal", "host", "opts", "KEY_REFUSED_MESSAGE", "DEFAULT_BASE_URL", "FetchController", "host", "req", "controller", "res", "json", "err", "signal", "url", "k", "v", "headers", "keyIsRefused", "KEY_REFUSED_MESSAGE", "dispatchKeyRefusal", "body", "buildRequest", "endpoint", "method", "values", "queryKeys", "rest", "path", "_match", "name", "inQuery", "query", "ROXY_DATA_CLASS", "isJsonScript", "el", "MarkupDataController", "host", "parsed", "inline", "child", "ROXY_DATA_CLASS", "text", "RoxyDataElement", "LitElement", "e", "detail", "buildRequest", "MarkupDataController", "FetchController", "baseStyles", "changed", "html", "data", "body", "ifDefined", "raw", "values", "message", "banner", "__decorateClass", "property", "state", "css", "html", "chevron", "disclosureStyles", "DATE_ONLY", "BARE_TIME", "NAIVE_DATETIME", "resolve", "input", "naive", "formatDate", "input", "d", "timeZone", "resolve", "DATE_ONLY", "formatNumber", "value", "dp", "fixed", "css", "html", "nothing", "interpAccordionStyles", "css", "renderInterpAccordion", "sections", "name", "heading", "shown", "s", "nothing", "html", "i", "chevron", "css", "html", "nothing", "tablistStyles", "renderTablist", "opts", "items", "active", "onSelect", "label", "idPrefix", "controls", "e", "idx", "it", "delta", "next", "root", "levelOf", "d", "parentOf", "formatBalance", "b", "parts", "formatSpan", "p", "start", "formatDate", "end", "RoxyDashaTimeline", "RoxyDataElement", "html", "periods", "maxYears", "readings", "frame", "tabs", "view", "t", "renderTablist", "v", "nothing", "grainFor", "renderInterpAccordion", "chain", "rows", "formatNumber", "deg", "lord", "label", "value", "parent", "span", "began", "sections", "levels", "period", "remaining", "left", "active", "now", "max", "grain", "years", "width", "current", "progress", "trackClass", "formatBoundary", "baseStyles", "disclosureStyles", "interpAccordionStyles", "tablistStyles", "css", "__decorateClass", "property", "state", "customElement", "DAYS_PER_YEAR", "s", "m", "month"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var _=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var p=(n,i,e,r)=>{for(var t=r>1?void 0:r?G(i,e):i,o=n.length-1,a;o>=0;o--)(a=n[o])&&(t=(r?a(i,e,t):a(t))||t);return r&&t&&_(i,e,t),t};import{css as Q,html as c,LitElement as J,nothing as g}from"lit";import{customElement as Z,property as h,state as y}from"lit/decorators.js";import{ifDefined as A}from"lit/directives/if-defined.js";var O={Aries:"\u2648",Taurus:"\u2649",Gemini:"\u264A",Cancer:"\u264B",Leo:"\u264C",Virgo:"\u264D",Libra:"\u264E",Scorpio:"\u264F",Sagittarius:"\u2650",Capricorn:"\u2651",Aquarius:"\u2652",Pisces:"\u2653"};var L=["Aries","Taurus","Gemini","Cancer","Leo","Virgo","Libra","Scorpio","Sagittarius","Capricorn","Aquarius","Pisces"];import{css as B}from"lit";var q=B`:host{font-family:var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-base,1rem);line-height:var(--roxy-leading-normal,1.5);animation:roxy-fade-in var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1)) both;background:0 0;display:block;container-type:inline-size}:host([bare]){--roxy-surface:transparent;--roxy-shadow-sm:none;--roxy-shadow-md:none}*,:before,:after{box-sizing:border-box}h1,h2,h3,h4{font-family:var(--roxy-font-display,var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif))}@keyframes roxy-fade-in{0%{opacity:0;transform:translateY(2px)}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion:reduce){:host{animation:none}}.roxy-skeleton{background:linear-gradient(90deg, var(--roxy-border,#e4e4e7) 0%, color-mix(in srgb, var(--roxy-border,#e4e4e7) 60%, transparent) 50%, var(--roxy-border,#e4e4e7) 100%);border-radius:var(--roxy-radius-md,8px);background-size:200% 100%;animation:1.4s ease-in-out infinite roxy-shimmer}@keyframes roxy-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){.roxy-skeleton{animation:none}}.roxy-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.roxy-empty{padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-muted,#71717a);text-align:center;font-size:var(--roxy-text-sm,.875rem)}.roxy-error{gap:var(--roxy-space-sm,.5rem);padding:var(--roxy-space-lg,1.5rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}.roxy-surface{background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a)}:host(:focus-within) .roxy-card{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-attribution{margin-top:var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-xs,.75rem);color:var(--roxy-muted,#71717a);text-align:right}.roxy-attribution a{color:inherit;text-decoration:none}.roxy-attribution a:hover{color:var(--roxy-accent-ink,#b45309);text-decoration:underline}.roxy-attribution a:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-edit-bar{margin-bottom:var(--roxy-space-sm,.5rem);justify-content:flex-end;display:flex}.roxy-edit{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;background:0 0}.roxy-edit:hover{border-color:var(--roxy-accent,#f59e0b);color:var(--roxy-accent-ink,#b45309)}.roxy-edit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}:host{font-variant-emoji:text}`;import{css as H,html as j}from"lit";function $(){return j`<svg class="roxy-chevron" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M4 6l4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`}var R=H`summary{list-style:none}summary::-webkit-details-marker{display:none}.roxy-chevron{aspect-ratio:auto;width:14px;height:14px;color:var(--roxy-muted,#71717a);transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0}details[open]>summary .roxy-chevron{transform:rotate(180deg)}@media (prefers-reduced-motion:reduce){.roxy-chevron{transition:none}}`;function M(n){return n?n.charAt(0).toUpperCase()+n.slice(1).toLowerCase():""}function m(n){return n.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([a-z])([0-9])/g,"$1 $2").replace(/^\w/,i=>i.toUpperCase())}var V=12,b=["latitude","longitude","timezone"],U=L.map(n=>n.toLowerCase());function v(n,i){if(n){if("$ref"in n&&n.$ref){let e=n.$ref.split("/").pop();return e?i[e]:void 0}return n}}function E(n){let i=n.anyOf??n.oneOf;return!i||i.length===0?n:i.find(e=>Array.isArray(e.enum))??i.find(e=>e.type&&e.type!=="null")??i[0]??n}function K(n){let i=E(n);return Array.isArray(i.enum)?i.enum.length<=V?"tiles":"select":i.type==="boolean"?"toggle":i.format==="date"?"date":i.format==="time"?"time":i.format==="date-time"?"datetime":i.type==="integer"||i.type==="number"?"number":i.type==="string"?"text":i.type==="array"?"array":null}function T(n){if(n.length!==12)return!1;let i=new Set(n.map(e=>e.toLowerCase()));return U.every(e=>i.has(e))}function w(n,i,e){let r=E(i);return{key:e.key,name:n,group:e.group,inQuery:e.inQuery,kind:K(i)??"text",required:e.required,description:r.description??i.description,enum:r.enum,min:r.minimum,max:r.maximum,default:i.default??r.default,example:i.example??r.example}}function C(n,i,e){let r=[],t=!1,o=n.requestBody?.content?.["application/json"]?.schema,a=v(o,i);if(a?.properties){let s=new Set(a.required??[]);for(let[d,l]of Object.entries(a.properties)){let f=v(l,i)??{};if(f.type==="object"&&f.properties){let x=new Set(f.required??[]);for(let[S,P]of Object.entries(f.properties)){let N=v(P,i)??{};r.push(w(S,N,{key:`${d}.${S}`,group:d,required:s.has(d)&&x.has(S)}))}}else r.push(w(d,f,{key:d,required:s.has(d)}))}}for(let s of n.parameters??[]){if(s.in!=="path"&&s.in!=="query")continue;if(s.name==="lang"&&s.in==="query"){t=!0;continue}let d=v(s.schema,i)??{};r.push(w(s.name,d,{key:s.name,required:!!s.required,inQuery:s.in==="query"}))}return{title:Y(n.summary,e),fields:r,hasLang:t}}function Y(n,i){let e=n?.split(" - ")[0]?.trim();return e||m(i.split("/").pop()??"")}function z(n){let i=n.toLowerCase();return/compat|synastry|guna|connection|penta|composite/.test(i)?"Compare":/\bcast\b|\/draw|iching|hexagram|tarot/.test(i)?"Cast":/horoscope|dream|angel|nakshatra|crystal|meaning|reference/.test(i)?"Get reading":"Generate"}function D(n,i){let e=i.replace(/^\//,"").replace(/[{}]/g,"").replace(/\//g,"-");return`${n.toLowerCase()}--${e}.json`}var F="0.18.2";var I="https://roxyapi.com/api/v2/openapi.json",W=`https://cdn.jsdelivr.net/npm/@roxyapi/ui@${F}/dist/schemas`,k=new Map;function Se(){k.clear()}async function X(n){let i=k.get(n);return i||(i=fetch(n).then(async e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}).catch(e=>{throw k.delete(n),e}),k.set(n,i)),i}function ee(){return globalThis.crypto?.randomUUID?.()??Math.random().toString(36).slice(2)}function re(n){let i=n.trim();if(!i)return[];try{let e=JSON.parse(i);if(Array.isArray(e))return e}catch{}return i.split(",").map(e=>e.trim()).filter(Boolean)}var u=class extends J{constructor(){super(...arguments);this.endpoint="vedic-astrology/birth-chart";this.method="POST";this.specUrl="";this.submitLabel="";this.fields=[];this.formTitle="";this.hasLang=!1;this.values={};this.loaded=!1;this.specError=null;this.validationErrors=[];this.retryLoadSchema=()=>{this.loaded=!1,this.specError=null,this.loadSchema()};this.onSubmit=e=>{e.preventDefault(),this.submit()}}connectedCallback(){super.connectedCallback(),this.loadSchema()}async loadSchema(){this.specError=null;try{this.applyModel(await this.resolveModel())}catch(e){let r=e instanceof Error?e.message:String(e);this.specError=r,this.loaded=!0,this.dispatchEvent(new CustomEvent("roxy-spec-error",{detail:{url:this.specUrl||I,message:r},bubbles:!0,composed:!0}))}}async resolveModel(){return this.specUrl?this.modelFromSpec(this.specUrl):await this.tryLoadSlice()??this.modelFromSpec(I)}async modelFromSpec(e){let r=await X(e),t=`/${this.endpoint.replace(/^\//,"")}`,o=r.paths?.[t]?.[this.method.toLowerCase()];if(!o)throw new Error(`Endpoint ${this.method} ${t} not found in OpenAPI spec`);return C(o,r.components?.schemas??{},this.endpoint)}async tryLoadSlice(){try{let e=await fetch(`${W}/${D(this.method,this.endpoint)}`);return e.ok?await e.json():null}catch{return null}}applyModel(e){this.fields=e.fields,this.formTitle=e.title,this.hasLang=e.hasLang;let r={};for(let t of e.fields){t.default!==void 0&&(r[t.key]=t.default);let o=t.group?this.initialValues?.[t.group]?.[t.name]:this.initialValues?.[t.name];o!==void 0&&(r[t.key]=o)}this.values=r,this.loaded=!0}setValue(e,r){this.values={...this.values,[e]:r}}roleOf(e){return e.name==="seed"?"seed":(e.name==="limit"||e.name==="offset")&&!e.required?"hidden-default":b.includes(e.name)&&this.groupHasLocation(e.group)?"location":"normal"}isRendered(e){return this.roleOf(e)==="normal"}groupKeys(){let e=[];for(let r of this.fields)e.includes(r.group)||e.push(r.group);return e}groupHasLocation(e){let r=this.fields.filter(t=>t.group===e);return b.every(t=>r.some(o=>o.name===t))}locationRequired(e){let r=this.fields.filter(t=>t.group===e);return b.some(t=>r.some(o=>o.name===t&&o.required))}groupIsRequired(e){return this.groupHasLocation(e)||this.fields.some(r=>r.group===e&&r.required)}get singleEnumField(){if(this.groupKeys().some(t=>this.groupHasLocation(t))||this.groupKeys().some(t=>t!==void 0))return null;let e=this.fields.filter(t=>t.required&&this.isRendered(t)),r=e[0];return e.length!==1||!r?null:r.kind==="tiles"||r.kind==="select"?r:null}effectiveSubmitLabel(){return this.submitLabel||z(this.endpoint)}effectiveLang(){return this.lang||void 0}onLocationFor(e){let r=e?`${e}.`:"";return t=>{let o=t.detail;o&&(this.values={...this.values,[`${r}latitude`]:o.latitude,[`${r}longitude`]:o.longitude,[`${r}timezone`]:o.timezone??o.utcOffset})}}selectTile(e,r){this.setValue(e.key,r),this.singleEnumField?.key===e.key&&this.submit()}onTilesKeyDown(e){return r=>{let t=e.enum??[];if(t.length===0)return;let o=t.indexOf(this.values[e.key]),a;if(r.key==="Home")a=0;else if(r.key==="End")a=t.length-1;else if(r.key==="ArrowRight"||r.key==="ArrowDown")a=o===-1?0:(o+1)%t.length;else if(r.key==="ArrowLeft"||r.key==="ArrowUp")a=o===-1?t.length-1:(o-1+t.length)%t.length;else return;r.preventDefault();let s=t[a];if(s===void 0)return;this.selectTile(e,s);let d=r.currentTarget;requestAnimationFrame(()=>d.querySelector(`[data-tile='${a}']`)?.focus())}}submit(){let e=this.collectMissing();if(e.keys.length>0){this.validationErrors=e.labels,this.dispatchEvent(new CustomEvent("roxy-validation-error",{detail:{missing:e.keys},bubbles:!0,composed:!0}));return}this.validationErrors=[];let r={};for(let a of this.fields){let s=this.values[a.key];if(a.name==="seed"&&(s===void 0||s==="")&&(s=ee()),!(s===void 0||s===""))if(a.kind==="array"&&typeof s=="string"&&(s=re(s)),a.group){let d=r[a.group]??{};d[a.name]=s,r[a.group]=d}else r[a.name]=s}let t=this.fields.filter(a=>a.inQuery).map(a=>a.name),o=this.effectiveLang();this.hasLang&&o&&(r.lang=o,t.push("lang")),this.dispatchEvent(new CustomEvent("roxy-submit",{detail:{endpoint:this.endpoint,values:r,queryKeys:t,sticky:this.singleEnumField!=null},bubbles:!0,composed:!0}))}collectMissing(){let e=[],r=[],t=new Set;for(let o of this.fields){if(!o.required)continue;let a=this.roleOf(o)==="location";if(!this.isRendered(o)&&!a)continue;let s=this.values[o.key];if(!(s!==void 0&&s!=="")){if(e.push(o.key),a){t.add(o.group);continue}r.push(o.group?`${m(o.group)} ${m(o.name)}`:m(o.name))}}for(let o of t)r.push(o?`${m(o)} location`:"Birth location");return{keys:e,labels:r}}reqMark(e){return e.required?c`<span class="req" aria-hidden="true">*</span>`:g}description(e){if(!e.description)return g;if(e.description.length<=120)return c`<small class="help">${e.description}</small>`;let r=e.description.split(". ")[0]??e.description;return c`<details class="help-details"><summary><span class="help-lead">${r}</span>${$()}</summary><small class="help help-full">${e.description}</small></details>`}renderTiles(e){let r=`roxy-form-${e.key}-label`,t=!!e.enum&&T(e.enum),o=e.enum??[],a=o.indexOf(this.values[e.key]),s=a===-1?0:a;return c`<div class="field tiles-field"><span class="label" id="${r}">${m(e.name)}${this.reqMark(e)}</span><div class="tiles" role="radiogroup" aria-labelledby="${r}" @keydown="${this.onTilesKeyDown(e)}">${o.map((d,l)=>{let f=this.values[e.key]===d,x=t?O[M(d)]:void 0;return c`<button type="button" class="tile" role="radio" data-tile="${l}" aria-checked="${f?"true":"false"}" tabindex="${l===s?"0":"-1"}" @click="${()=>this.selectTile(e,d)}">${x?c`<span class="tile-glyph" aria-hidden="true">${x}</span>`:g} <span class="tile-label">${m(d)}</span></button>`})}</div>${this.description(e)}</div>`}renderSelect(e){let r=`roxy-form-${e.key}`;return c`<div class="field"><label for="${r}">${m(e.name)}${this.reqMark(e)}</label> <select id="${r}" ?required="${e.required}" @change="${t=>this.setValue(e.key,t.target.value)}"><option value="">Choose</option>${(e.enum??[]).map(t=>c`<option value="${t}" ?selected="${this.values[e.key]===t}">${m(t)}</option>`)}</select> ${this.description(e)}</div>`}renderToggle(e){let r=`roxy-form-${e.key}`,t=this.values[e.key]===!0;return c`<div class="field"><div class="toggle-row"><button type="button" id="${r}" class="toggle" role="switch" aria-checked="${t?"true":"false"}" @click="${()=>this.setValue(e.key,!t)}"><span class="knob"></span></button> <label class="toggle-label" for="${r}">${m(e.name)}${this.reqMark(e)}</label></div>${this.description(e)}</div>`}renderInput(e){let r=`roxy-form-${e.key}`,t=e.kind==="datetime"?"datetime-local":e.kind==="number"?"number":e.kind,o=e.kind==="array"?"Comma separated":e.example!=null?String(e.example):"";return c`<div class="field"><label for="${r}">${m(e.name)}${this.reqMark(e)}</label> <input id="${r}" type="${e.kind==="array"?"text":t}" ?required="${e.required}" min="${A(e.min)}" max="${A(e.max)}" step="${e.kind==="number"?"any":g}" placeholder="${o||g}" .value="${this.values[e.key]??""}" @input="${a=>this.setValue(e.key,this.coerce(e.kind,a.target.value))}"> ${this.description(e)}</div>`}renderField(e){switch(e.kind){case"tiles":return this.renderTiles(e);case"select":return this.renderSelect(e);case"toggle":return this.renderToggle(e);default:return this.renderInput(e)}}locationBlock(e){return c`<div class="location-block"><label>${e?`${m(e)} location`:"Birth location"}${this.locationRequired(e)?c`<span class="req" aria-hidden="true">*</span>`:g}</label><roxy-location-search publishable-key="${A(this.publishableKey)}" @roxy-location-select="${this.onLocationFor(e)}" placeholder="City of birth"></roxy-location-search><small class="help">Required: latitude, longitude, timezone. Pick a city to autofill.</small></div>`}groupCard(e){let r=this.fields.filter(t=>t.group===e&&this.isRendered(t));return c`<fieldset class="person-group"><legend>${m(e)}</legend>${this.groupHasLocation(e)?this.locationBlock(e):g}<div class="fields">${r.map(t=>this.renderField(t))}</div></fieldset>`}render(){if(!this.loaded)return c`<form><div class="roxy-skeleton" style="height:8rem"></div></form>`;if(this.specError)return c`<div class="spec-error" role="alert">Schema load failed: ${this.specError} <button type="button" class="submit" @click="${this.retryLoadSchema}">Retry</button></div>`;let e=this.fields.filter(l=>!l.group&&this.isRendered(l)),r=e.filter(l=>l.required),t=e.filter(l=>!l.required),o=this.groupKeys().filter(l=>l!==void 0),a=o.filter(l=>this.groupIsRequired(l)),s=o.filter(l=>!this.groupIsRequired(l)),d=t.length>0||s.length>0;return c`<form @submit="${this.onSubmit}"><h2 class="title">${this.formTitle}</h2>${this.validationErrors.length>0?c`<div class="validation-error" role="alert"><strong>Please complete:</strong> ${this.validationErrors.join(", ")}</div>`:g}<div class="fields">${r.map(l=>this.renderField(l))}</div>${this.groupHasLocation(void 0)?this.locationBlock(void 0):g} ${a.map(l=>this.groupCard(l))} ${d?c`<details class="advanced"><summary>Advanced${$()}</summary><div class="fields">${t.map(l=>this.renderField(l))}</div>${s.map(l=>this.groupCard(l))}</details>`:g} ${this.singleEnumField?g:c`<button class="submit" type="submit">${this.effectiveSubmitLabel()}</button>`}</form>`}coerce(e,r){if(r!==""){if(e==="number"){let t=Number(r);return Number.isFinite(t)?t:void 0}return r}}};u.styles=[q,R,Q`form{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);box-shadow:var(--roxy-shadow-sm);display:grid}.title{font-size:var(--roxy-text-lg,1.125rem);font-weight:var(--roxy-weight-bold,600);margin:0}.fields{align-items:start;gap:var(--roxy-space-md,1rem);grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));display:grid}.fields:empty{display:none}.person-group{background:var(--roxy-surface,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-md,1rem);gap:var(--roxy-space-md,1rem);min-inline-size:0;margin:0;display:grid}.person-group legend{padding:0 var(--roxy-space-xs,.25rem);font-weight:var(--roxy-weight-bold,600)}.field{gap:var(--roxy-space-xs,.25rem);flex-direction:column;min-width:0;display:flex}.tiles-field{grid-column:1/-1}label,.label{font-size:var(--roxy-text-sm,.875rem);color:var(--roxy-secondary,#475569)}.req{color:var(--roxy-danger-fg,#991b1b);margin-left:4px}input,select{box-sizing:border-box;width:100%;padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);font-size:var(--roxy-text-base,1rem);color:var(--roxy-fg,#0a0a0a);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);font-family:inherit}input:focus,select:focus{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px;border-color:var(--roxy-accent-ink,#b45309)}.help{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem)}.help-details>summary{cursor:pointer;color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);align-items:center;gap:4px;display:flex}.help-details .help-lead{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.help-details .help-full{margin-top:var(--roxy-space-xs,.25rem);display:block}.location-block{gap:var(--roxy-space-xs,.25rem);grid-column:1/-1;display:grid}.tiles{gap:var(--roxy-space-sm,.5rem);grid-template-columns:repeat(auto-fit,minmax(5.5rem,1fr));display:grid}.tile{min-height:44px;padding:var(--roxy-space-sm,.5rem);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;transition:border-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease), background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-direction:column;justify-content:center;align-items:center;gap:2px;display:flex}.tile:hover{border-color:var(--roxy-accent,#f59e0b)}.tile[aria-checked=true]{border-color:var(--roxy-accent,#f59e0b);background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 12%, transparent);color:var(--roxy-accent-ink,#b45309);font-weight:var(--roxy-weight-bold,600)}.tile:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.tile-glyph{font-size:1.35em;line-height:1}.toggle-row{align-items:center;gap:var(--roxy-space-sm,.5rem);display:flex}.toggle{border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-full,9999px);background:var(--roxy-border,#e4e4e7);cursor:pointer;width:44px;height:26px;transition:background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0;padding:0;position:relative}.toggle[aria-checked=true]{background:var(--roxy-accent,#f59e0b);border-color:var(--roxy-accent,#f59e0b)}.toggle .knob{background:var(--roxy-bg,#fff);width:20px;height:20px;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);border-radius:50%;position:absolute;top:2px;left:2px}.toggle[aria-checked=true] .knob{transform:translate(18px)}.toggle:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.toggle-label{cursor:pointer}@media (prefers-reduced-motion:reduce){.tile,.toggle,.toggle .knob{transition:none}}.advanced{border-top:1px solid var(--roxy-border,#e4e4e7);padding-top:var(--roxy-space-md,1rem)}.advanced>summary{cursor:pointer;font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-fg,#0a0a0a);align-items:center;gap:6px;display:flex}.advanced[open]>summary{margin-bottom:var(--roxy-space-md,1rem)}.advanced .fields,.advanced .person-group{margin-top:var(--roxy-space-md,1rem)}.validation-error{gap:var(--roxy-space-xs,.25rem);padding:var(--roxy-space-md,1rem);background:color-mix(in srgb, var(--roxy-danger,#dc2626) 8%, transparent);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);display:grid}button.submit{background:var(--roxy-accent-ink,#b45309);color:var(--roxy-bg,#fff);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-sm,.5rem) var(--roxy-space-lg,1.5rem);font-size:var(--roxy-text-base,1rem);font-weight:var(--roxy-weight-bold,600);cursor:pointer;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1));border:0;justify-self:start}button.submit:hover{transform:scale(1.02)}button.submit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}@media (prefers-reduced-motion:reduce){button.submit{transition:none}}.spec-error{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}`],p([h({type:String,attribute:"data-endpoint"})],u.prototype,"endpoint",2),p([h({type:String})],u.prototype,"method",2),p([h({type:String,attribute:"spec-url"})],u.prototype,"specUrl",2),p([h({type:String,attribute:"submit-label"})],u.prototype,"submitLabel",2),p([h({type:String,attribute:"publishable-key"})],u.prototype,"publishableKey",2),p([h({attribute:!1})],u.prototype,"initialValues",2),p([y()],u.prototype,"fields",2),p([y()],u.prototype,"formTitle",2),p([y()],u.prototype,"hasLang",2),p([y()],u.prototype,"values",2),p([y()],u.prototype,"loaded",2),p([y()],u.prototype,"specError",2),p([y()],u.prototype,"validationErrors",2),u=p([Z("roxy-endpoint-form")],u);export{u as RoxyEndpointForm,Se as resetSpecCache};
1
+ var _=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var p=(n,i,e,r)=>{for(var t=r>1?void 0:r?G(i,e):i,o=n.length-1,a;o>=0;o--)(a=n[o])&&(t=(r?a(i,e,t):a(t))||t);return r&&t&&_(i,e,t),t};import{css as Q,html as c,LitElement as J,nothing as g}from"lit";import{customElement as Z,property as h,state as y}from"lit/decorators.js";import{ifDefined as A}from"lit/directives/if-defined.js";var O={Aries:"\u2648",Taurus:"\u2649",Gemini:"\u264A",Cancer:"\u264B",Leo:"\u264C",Virgo:"\u264D",Libra:"\u264E",Scorpio:"\u264F",Sagittarius:"\u2650",Capricorn:"\u2651",Aquarius:"\u2652",Pisces:"\u2653"};var L=["Aries","Taurus","Gemini","Cancer","Leo","Virgo","Libra","Scorpio","Sagittarius","Capricorn","Aquarius","Pisces"];import{css as B}from"lit";var q=B`:host{font-family:var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-base,1rem);line-height:var(--roxy-leading-normal,1.5);animation:roxy-fade-in var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1)) both;background:0 0;display:block;container-type:inline-size}:host([bare]){--roxy-surface:transparent;--roxy-shadow-sm:none;--roxy-shadow-md:none}*,:before,:after{box-sizing:border-box}h1,h2,h3,h4{font-family:var(--roxy-font-display,var(--roxy-font-sans,system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif))}@keyframes roxy-fade-in{0%{opacity:0;transform:translateY(2px)}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion:reduce){:host{animation:none}}.roxy-skeleton{background:linear-gradient(90deg, var(--roxy-border,#e4e4e7) 0%, color-mix(in srgb, var(--roxy-border,#e4e4e7) 60%, transparent) 50%, var(--roxy-border,#e4e4e7) 100%);border-radius:var(--roxy-radius-md,8px);background-size:200% 100%;animation:1.4s ease-in-out infinite roxy-shimmer}@keyframes roxy-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){.roxy-skeleton{animation:none}}.roxy-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.roxy-empty{padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-muted,#71717a);text-align:center;font-size:var(--roxy-text-sm,.875rem)}.roxy-error{gap:var(--roxy-space-sm,.5rem);padding:var(--roxy-space-lg,1.5rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}.roxy-surface{background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a)}:host(:focus-within) .roxy-card{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-attribution{margin-top:var(--roxy-space-sm,.5rem);font-size:var(--roxy-text-xs,.75rem);color:var(--roxy-muted,#71717a);text-align:right}.roxy-attribution a{color:inherit;text-decoration:none}.roxy-attribution a:hover{color:var(--roxy-accent-ink,#b45309);text-decoration:underline}.roxy-attribution a:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-edit-bar{margin-bottom:var(--roxy-space-sm,.5rem);justify-content:flex-end;display:flex}.roxy-edit{padding:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;background:0 0}.roxy-edit:hover{border-color:var(--roxy-accent,#f59e0b);color:var(--roxy-accent-ink,#b45309)}.roxy-edit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}:host{font-variant-emoji:text}`;import{css as H,html as j}from"lit";function $(){return j`<svg class="roxy-chevron" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M4 6l4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`}var R=H`summary{list-style:none}summary::-webkit-details-marker{display:none}.roxy-chevron{aspect-ratio:auto;width:14px;height:14px;color:var(--roxy-muted,#71717a);transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0}details[open]>summary .roxy-chevron{transform:rotate(180deg)}@media (prefers-reduced-motion:reduce){.roxy-chevron{transition:none}}`;function M(n){return n?n.charAt(0).toUpperCase()+n.slice(1).toLowerCase():""}function m(n){return n.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([a-z])([0-9])/g,"$1 $2").replace(/^\w/,i=>i.toUpperCase())}var V=12,b=["latitude","longitude","timezone"],U=L.map(n=>n.toLowerCase());function v(n,i){if(n){if("$ref"in n&&n.$ref){let e=n.$ref.split("/").pop();return e?i[e]:void 0}return n}}function E(n){let i=n.anyOf??n.oneOf;return!i||i.length===0?n:i.find(e=>Array.isArray(e.enum))??i.find(e=>e.type&&e.type!=="null")??i[0]??n}function K(n){let i=E(n);return Array.isArray(i.enum)?i.enum.length<=V?"tiles":"select":i.type==="boolean"?"toggle":i.format==="date"?"date":i.format==="time"?"time":i.format==="date-time"?"datetime":i.type==="integer"||i.type==="number"?"number":i.type==="string"?"text":i.type==="array"?"array":null}function T(n){if(n.length!==12)return!1;let i=new Set(n.map(e=>e.toLowerCase()));return U.every(e=>i.has(e))}function w(n,i,e){let r=E(i);return{key:e.key,name:n,group:e.group,inQuery:e.inQuery,kind:K(i)??"text",required:e.required,description:r.description??i.description,enum:r.enum,min:r.minimum,max:r.maximum,default:i.default??r.default,example:i.example??r.example}}function C(n,i,e){let r=[],t=!1,o=n.requestBody?.content?.["application/json"]?.schema,a=v(o,i);if(a?.properties){let s=new Set(a.required??[]);for(let[d,l]of Object.entries(a.properties)){let f=v(l,i)??{};if(f.type==="object"&&f.properties){let x=new Set(f.required??[]);for(let[S,P]of Object.entries(f.properties)){let N=v(P,i)??{};r.push(w(S,N,{key:`${d}.${S}`,group:d,required:s.has(d)&&x.has(S)}))}}else r.push(w(d,f,{key:d,required:s.has(d)}))}}for(let s of n.parameters??[]){if(s.in!=="path"&&s.in!=="query")continue;if(s.name==="lang"&&s.in==="query"){t=!0;continue}let d=v(s.schema,i)??{};r.push(w(s.name,d,{key:s.name,required:!!s.required,inQuery:s.in==="query"}))}return{title:Y(n.summary,e),fields:r,hasLang:t}}function Y(n,i){let e=n?.split(" - ")[0]?.trim();return e||m(i.split("/").pop()??"")}function z(n){let i=n.toLowerCase();return/compat|synastry|guna|connection|penta|composite/.test(i)?"Compare":/\bcast\b|\/draw|iching|hexagram|tarot/.test(i)?"Cast":/horoscope|dream|angel|nakshatra|crystal|meaning|reference/.test(i)?"Get reading":"Generate"}function D(n,i){let e=i.replace(/^\//,"").replace(/[{}]/g,"").replace(/\//g,"-");return`${n.toLowerCase()}--${e}.json`}var F="0.18.3";var I="https://roxyapi.com/api/v2/openapi.json",W=`https://cdn.jsdelivr.net/npm/@roxyapi/ui@${F}/dist/schemas`,k=new Map;function Se(){k.clear()}async function X(n){let i=k.get(n);return i||(i=fetch(n).then(async e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}).catch(e=>{throw k.delete(n),e}),k.set(n,i)),i}function ee(){return globalThis.crypto?.randomUUID?.()??Math.random().toString(36).slice(2)}function re(n){let i=n.trim();if(!i)return[];try{let e=JSON.parse(i);if(Array.isArray(e))return e}catch{}return i.split(",").map(e=>e.trim()).filter(Boolean)}var u=class extends J{constructor(){super(...arguments);this.endpoint="vedic-astrology/birth-chart";this.method="POST";this.specUrl="";this.submitLabel="";this.fields=[];this.formTitle="";this.hasLang=!1;this.values={};this.loaded=!1;this.specError=null;this.validationErrors=[];this.retryLoadSchema=()=>{this.loaded=!1,this.specError=null,this.loadSchema()};this.onSubmit=e=>{e.preventDefault(),this.submit()}}connectedCallback(){super.connectedCallback(),this.loadSchema()}async loadSchema(){this.specError=null;try{this.applyModel(await this.resolveModel())}catch(e){let r=e instanceof Error?e.message:String(e);this.specError=r,this.loaded=!0,this.dispatchEvent(new CustomEvent("roxy-spec-error",{detail:{url:this.specUrl||I,message:r},bubbles:!0,composed:!0}))}}async resolveModel(){return this.specUrl?this.modelFromSpec(this.specUrl):await this.tryLoadSlice()??this.modelFromSpec(I)}async modelFromSpec(e){let r=await X(e),t=`/${this.endpoint.replace(/^\//,"")}`,o=r.paths?.[t]?.[this.method.toLowerCase()];if(!o)throw new Error(`Endpoint ${this.method} ${t} not found in OpenAPI spec`);return C(o,r.components?.schemas??{},this.endpoint)}async tryLoadSlice(){try{let e=await fetch(`${W}/${D(this.method,this.endpoint)}`);return e.ok?await e.json():null}catch{return null}}applyModel(e){this.fields=e.fields,this.formTitle=e.title,this.hasLang=e.hasLang;let r={};for(let t of e.fields){t.default!==void 0&&(r[t.key]=t.default);let o=t.group?this.initialValues?.[t.group]?.[t.name]:this.initialValues?.[t.name];o!==void 0&&(r[t.key]=o)}this.values=r,this.loaded=!0}setValue(e,r){this.values={...this.values,[e]:r}}roleOf(e){return e.name==="seed"?"seed":(e.name==="limit"||e.name==="offset")&&!e.required?"hidden-default":b.includes(e.name)&&this.groupHasLocation(e.group)?"location":"normal"}isRendered(e){return this.roleOf(e)==="normal"}groupKeys(){let e=[];for(let r of this.fields)e.includes(r.group)||e.push(r.group);return e}groupHasLocation(e){let r=this.fields.filter(t=>t.group===e);return b.every(t=>r.some(o=>o.name===t))}locationRequired(e){let r=this.fields.filter(t=>t.group===e);return b.some(t=>r.some(o=>o.name===t&&o.required))}groupIsRequired(e){return this.groupHasLocation(e)||this.fields.some(r=>r.group===e&&r.required)}get singleEnumField(){if(this.groupKeys().some(t=>this.groupHasLocation(t))||this.groupKeys().some(t=>t!==void 0))return null;let e=this.fields.filter(t=>t.required&&this.isRendered(t)),r=e[0];return e.length!==1||!r?null:r.kind==="tiles"||r.kind==="select"?r:null}effectiveSubmitLabel(){return this.submitLabel||z(this.endpoint)}effectiveLang(){return this.lang||void 0}onLocationFor(e){let r=e?`${e}.`:"";return t=>{let o=t.detail;o&&(this.values={...this.values,[`${r}latitude`]:o.latitude,[`${r}longitude`]:o.longitude,[`${r}timezone`]:o.timezone??o.utcOffset})}}selectTile(e,r){this.setValue(e.key,r),this.singleEnumField?.key===e.key&&this.submit()}onTilesKeyDown(e){return r=>{let t=e.enum??[];if(t.length===0)return;let o=t.indexOf(this.values[e.key]),a;if(r.key==="Home")a=0;else if(r.key==="End")a=t.length-1;else if(r.key==="ArrowRight"||r.key==="ArrowDown")a=o===-1?0:(o+1)%t.length;else if(r.key==="ArrowLeft"||r.key==="ArrowUp")a=o===-1?t.length-1:(o-1+t.length)%t.length;else return;r.preventDefault();let s=t[a];if(s===void 0)return;this.selectTile(e,s);let d=r.currentTarget;requestAnimationFrame(()=>d.querySelector(`[data-tile='${a}']`)?.focus())}}submit(){let e=this.collectMissing();if(e.keys.length>0){this.validationErrors=e.labels,this.dispatchEvent(new CustomEvent("roxy-validation-error",{detail:{missing:e.keys},bubbles:!0,composed:!0}));return}this.validationErrors=[];let r={};for(let a of this.fields){let s=this.values[a.key];if(a.name==="seed"&&(s===void 0||s==="")&&(s=ee()),!(s===void 0||s===""))if(a.kind==="array"&&typeof s=="string"&&(s=re(s)),a.group){let d=r[a.group]??{};d[a.name]=s,r[a.group]=d}else r[a.name]=s}let t=this.fields.filter(a=>a.inQuery).map(a=>a.name),o=this.effectiveLang();this.hasLang&&o&&(r.lang=o,t.push("lang")),this.dispatchEvent(new CustomEvent("roxy-submit",{detail:{endpoint:this.endpoint,values:r,queryKeys:t,sticky:this.singleEnumField!=null},bubbles:!0,composed:!0}))}collectMissing(){let e=[],r=[],t=new Set;for(let o of this.fields){if(!o.required)continue;let a=this.roleOf(o)==="location";if(!this.isRendered(o)&&!a)continue;let s=this.values[o.key];if(!(s!==void 0&&s!=="")){if(e.push(o.key),a){t.add(o.group);continue}r.push(o.group?`${m(o.group)} ${m(o.name)}`:m(o.name))}}for(let o of t)r.push(o?`${m(o)} location`:"Birth location");return{keys:e,labels:r}}reqMark(e){return e.required?c`<span class="req" aria-hidden="true">*</span>`:g}description(e){if(!e.description)return g;if(e.description.length<=120)return c`<small class="help">${e.description}</small>`;let r=e.description.split(". ")[0]??e.description;return c`<details class="help-details"><summary><span class="help-lead">${r}</span>${$()}</summary><small class="help help-full">${e.description}</small></details>`}renderTiles(e){let r=`roxy-form-${e.key}-label`,t=!!e.enum&&T(e.enum),o=e.enum??[],a=o.indexOf(this.values[e.key]),s=a===-1?0:a;return c`<div class="field tiles-field"><span class="label" id="${r}">${m(e.name)}${this.reqMark(e)}</span><div class="tiles" role="radiogroup" aria-labelledby="${r}" @keydown="${this.onTilesKeyDown(e)}">${o.map((d,l)=>{let f=this.values[e.key]===d,x=t?O[M(d)]:void 0;return c`<button type="button" class="tile" role="radio" data-tile="${l}" aria-checked="${f?"true":"false"}" tabindex="${l===s?"0":"-1"}" @click="${()=>this.selectTile(e,d)}">${x?c`<span class="tile-glyph" aria-hidden="true">${x}</span>`:g} <span class="tile-label">${m(d)}</span></button>`})}</div>${this.description(e)}</div>`}renderSelect(e){let r=`roxy-form-${e.key}`;return c`<div class="field"><label for="${r}">${m(e.name)}${this.reqMark(e)}</label> <select id="${r}" ?required="${e.required}" @change="${t=>this.setValue(e.key,t.target.value)}"><option value="">Choose</option>${(e.enum??[]).map(t=>c`<option value="${t}" ?selected="${this.values[e.key]===t}">${m(t)}</option>`)}</select> ${this.description(e)}</div>`}renderToggle(e){let r=`roxy-form-${e.key}`,t=this.values[e.key]===!0;return c`<div class="field"><div class="toggle-row"><button type="button" id="${r}" class="toggle" role="switch" aria-checked="${t?"true":"false"}" @click="${()=>this.setValue(e.key,!t)}"><span class="knob"></span></button> <label class="toggle-label" for="${r}">${m(e.name)}${this.reqMark(e)}</label></div>${this.description(e)}</div>`}renderInput(e){let r=`roxy-form-${e.key}`,t=e.kind==="datetime"?"datetime-local":e.kind==="number"?"number":e.kind,o=e.kind==="array"?"Comma separated":e.example!=null?String(e.example):"";return c`<div class="field"><label for="${r}">${m(e.name)}${this.reqMark(e)}</label> <input id="${r}" type="${e.kind==="array"?"text":t}" ?required="${e.required}" min="${A(e.min)}" max="${A(e.max)}" step="${e.kind==="number"?"any":g}" placeholder="${o||g}" .value="${this.values[e.key]??""}" @input="${a=>this.setValue(e.key,this.coerce(e.kind,a.target.value))}"> ${this.description(e)}</div>`}renderField(e){switch(e.kind){case"tiles":return this.renderTiles(e);case"select":return this.renderSelect(e);case"toggle":return this.renderToggle(e);default:return this.renderInput(e)}}locationBlock(e){return c`<div class="location-block"><label>${e?`${m(e)} location`:"Birth location"}${this.locationRequired(e)?c`<span class="req" aria-hidden="true">*</span>`:g}</label><roxy-location-search publishable-key="${A(this.publishableKey)}" @roxy-location-select="${this.onLocationFor(e)}" placeholder="City of birth"></roxy-location-search><small class="help">Required: latitude, longitude, timezone. Pick a city to autofill.</small></div>`}groupCard(e){let r=this.fields.filter(t=>t.group===e&&this.isRendered(t));return c`<fieldset class="person-group"><legend>${m(e)}</legend>${this.groupHasLocation(e)?this.locationBlock(e):g}<div class="fields">${r.map(t=>this.renderField(t))}</div></fieldset>`}render(){if(!this.loaded)return c`<form><div class="roxy-skeleton" style="height:8rem"></div></form>`;if(this.specError)return c`<div class="spec-error" role="alert">Schema load failed: ${this.specError} <button type="button" class="submit" @click="${this.retryLoadSchema}">Retry</button></div>`;let e=this.fields.filter(l=>!l.group&&this.isRendered(l)),r=e.filter(l=>l.required),t=e.filter(l=>!l.required),o=this.groupKeys().filter(l=>l!==void 0),a=o.filter(l=>this.groupIsRequired(l)),s=o.filter(l=>!this.groupIsRequired(l)),d=t.length>0||s.length>0;return c`<form @submit="${this.onSubmit}"><h2 class="title">${this.formTitle}</h2>${this.validationErrors.length>0?c`<div class="validation-error" role="alert"><strong>Please complete:</strong> ${this.validationErrors.join(", ")}</div>`:g}<div class="fields">${r.map(l=>this.renderField(l))}</div>${this.groupHasLocation(void 0)?this.locationBlock(void 0):g} ${a.map(l=>this.groupCard(l))} ${d?c`<details class="advanced"><summary>Advanced${$()}</summary><div class="fields">${t.map(l=>this.renderField(l))}</div>${s.map(l=>this.groupCard(l))}</details>`:g} ${this.singleEnumField?g:c`<button class="submit" type="submit">${this.effectiveSubmitLabel()}</button>`}</form>`}coerce(e,r){if(r!==""){if(e==="number"){let t=Number(r);return Number.isFinite(t)?t:void 0}return r}}};u.styles=[q,R,Q`form{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);color:var(--roxy-fg,#0a0a0a);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);box-shadow:var(--roxy-shadow-sm);display:grid}.title{font-size:var(--roxy-text-lg,1.125rem);font-weight:var(--roxy-weight-bold,600);margin:0}.fields{align-items:start;gap:var(--roxy-space-md,1rem);grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));display:grid}.fields:empty{display:none}.person-group{background:var(--roxy-surface,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-md,1rem);gap:var(--roxy-space-md,1rem);min-inline-size:0;margin:0;display:grid}.person-group legend{padding:0 var(--roxy-space-xs,.25rem);font-weight:var(--roxy-weight-bold,600)}.field{gap:var(--roxy-space-xs,.25rem);flex-direction:column;min-width:0;display:flex}.tiles-field{grid-column:1/-1}label,.label{font-size:var(--roxy-text-sm,.875rem);color:var(--roxy-secondary,#475569)}.req{color:var(--roxy-danger-fg,#991b1b);margin-left:4px}input,select{box-sizing:border-box;width:100%;padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);font-size:var(--roxy-text-base,1rem);color:var(--roxy-fg,#0a0a0a);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);font-family:inherit}input:focus,select:focus{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px;border-color:var(--roxy-accent-ink,#b45309)}.help{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem)}.help-details>summary{cursor:pointer;color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);align-items:center;gap:4px;display:flex}.help-details .help-lead{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.help-details .help-full{margin-top:var(--roxy-space-xs,.25rem);display:block}.location-block{gap:var(--roxy-space-xs,.25rem);grid-column:1/-1;display:grid}.tiles{gap:var(--roxy-space-sm,.5rem);grid-template-columns:repeat(auto-fit,minmax(5.5rem,1fr));display:grid}.tile{min-height:44px;padding:var(--roxy-space-sm,.5rem);background:var(--roxy-bg,#fff);border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-fg,#0a0a0a);font-family:inherit;font-size:var(--roxy-text-sm,.875rem);cursor:pointer;transition:border-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease), background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-direction:column;justify-content:center;align-items:center;gap:2px;display:flex}.tile:hover{border-color:var(--roxy-accent,#f59e0b)}.tile[aria-checked=true]{border-color:var(--roxy-accent,#f59e0b);background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 12%, transparent);color:var(--roxy-accent-ink,#b45309);font-weight:var(--roxy-weight-bold,600)}.tile:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.tile-glyph{font-size:1.35em;line-height:1}.toggle-row{align-items:center;gap:var(--roxy-space-sm,.5rem);display:flex}.toggle{border:1px solid var(--roxy-border,#e4e4e7);border-radius:var(--roxy-radius-full,9999px);background:var(--roxy-border,#e4e4e7);cursor:pointer;width:44px;height:26px;transition:background-color var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);flex-shrink:0;padding:0;position:relative}.toggle[aria-checked=true]{background:var(--roxy-accent,#f59e0b);border-color:var(--roxy-accent,#f59e0b)}.toggle .knob{background:var(--roxy-bg,#fff);width:20px;height:20px;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,ease);border-radius:50%;position:absolute;top:2px;left:2px}.toggle[aria-checked=true] .knob{transform:translate(18px)}.toggle:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.toggle-label{cursor:pointer}@media (prefers-reduced-motion:reduce){.tile,.toggle,.toggle .knob{transition:none}}.advanced{border-top:1px solid var(--roxy-border,#e4e4e7);padding-top:var(--roxy-space-md,1rem)}.advanced>summary{cursor:pointer;font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-fg,#0a0a0a);align-items:center;gap:6px;display:flex}.advanced[open]>summary{margin-bottom:var(--roxy-space-md,1rem)}.advanced .fields,.advanced .person-group{margin-top:var(--roxy-space-md,1rem)}.validation-error{gap:var(--roxy-space-xs,.25rem);padding:var(--roxy-space-md,1rem);background:color-mix(in srgb, var(--roxy-danger,#dc2626) 8%, transparent);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);display:grid}button.submit{background:var(--roxy-accent-ink,#b45309);color:var(--roxy-bg,#fff);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-sm,.5rem) var(--roxy-space-lg,1.5rem);font-size:var(--roxy-text-base,1rem);font-weight:var(--roxy-weight-bold,600);cursor:pointer;transition:transform var(--roxy-motion-duration,.2s) var(--roxy-motion-easing,cubic-bezier(.4, 0, .2, 1));border:0;justify-self:start}button.submit:hover{transform:scale(1.02)}button.submit:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}@media (prefers-reduced-motion:reduce){button.submit{transition:none}}.spec-error{gap:var(--roxy-space-md,1rem);background:var(--roxy-surface,#fff);border:1px solid var(--roxy-danger,#dc2626);border-radius:var(--roxy-radius-md,8px);padding:var(--roxy-space-lg,1.5rem);color:var(--roxy-danger-fg,#991b1b);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}`],p([h({type:String,attribute:"data-endpoint"})],u.prototype,"endpoint",2),p([h({type:String})],u.prototype,"method",2),p([h({type:String,attribute:"spec-url"})],u.prototype,"specUrl",2),p([h({type:String,attribute:"submit-label"})],u.prototype,"submitLabel",2),p([h({type:String,attribute:"publishable-key"})],u.prototype,"publishableKey",2),p([h({attribute:!1})],u.prototype,"initialValues",2),p([y()],u.prototype,"fields",2),p([y()],u.prototype,"formTitle",2),p([y()],u.prototype,"hasLang",2),p([y()],u.prototype,"values",2),p([y()],u.prototype,"loaded",2),p([y()],u.prototype,"specError",2),p([y()],u.prototype,"validationErrors",2),u=p([Z("roxy-endpoint-form")],u);export{u as RoxyEndpointForm,Se as resetSpecCache};
2
2
  //# sourceMappingURL=endpoint-form.js.map