@roxyapi/ui 0.51.2 → 0.51.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.
- package/components-catalog.json +153 -153
- package/dist/cdn/components/data.js +4 -4
- package/dist/cdn/components/data.js.map +4 -4
- package/dist/cdn/components/endpoint-form.js +1 -1
- package/dist/cdn/components/endpoint-form.js.map +1 -1
- package/dist/cdn/components/gematria.js +1 -1
- package/dist/cdn/components/gematria.js.map +2 -2
- package/dist/cdn/components/guna-milan.js +1 -1
- package/dist/cdn/components/guna-milan.js.map +2 -2
- package/dist/cdn/components/mayan-day-sign.js +1 -1
- package/dist/cdn/components/mayan-day-sign.js.map +2 -2
- package/dist/cdn/roxy-ui.js +52 -52
- package/dist/cdn/roxy-ui.js.map +4 -4
- package/dist/components/data.d.ts +10 -33
- package/dist/components/data.d.ts.map +1 -1
- package/dist/components/data.js +1 -1
- package/dist/components/data.js.map +4 -4
- package/dist/components/endpoint-form.js +1 -1
- package/dist/components/endpoint-form.js.map +1 -1
- package/dist/components/gematria.js +1 -1
- package/dist/components/gematria.js.map +2 -2
- package/dist/components/guna-milan.js +1 -1
- package/dist/components/guna-milan.js.map +2 -2
- package/dist/components/mayan-day-sign.js +1 -1
- package/dist/components/mayan-day-sign.js.map +2 -2
- package/dist/index.cjs +81 -81
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +76 -76
- package/dist/index.js.map +4 -4
- package/dist/styles/themes/practitioner.css +5 -5
- package/dist/utils/stacked-table.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/data.ts +85 -94
- package/src/styles/themes/practitioner.css +5 -5
- package/src/utils/stacked-table.ts +2 -0
- package/src/version.ts +1 -1
|
@@ -1,40 +1,17 @@
|
|
|
1
1
|
import { type TemplateResult } from 'lit';
|
|
2
2
|
import { RoxyDataElement } from '../utils/base-element.js';
|
|
3
|
-
/**
|
|
4
|
-
* Generic fallback renderer. Accepts ANY OpenAPI response shape and renders
|
|
5
|
-
* it via field-name heuristics so future spec additions render reasonably
|
|
6
|
-
* without hand-wired components.
|
|
7
|
-
*
|
|
8
|
-
* Heuristic order:
|
|
9
|
-
* 1. Primitive (string, number, boolean) -> single line.
|
|
10
|
-
* 2. Array of primitives -> chip list.
|
|
11
|
-
* 3. Array of objects with shared keys -> table.
|
|
12
|
-
* 4. Object with title-like field -> card with key/value rows; object and
|
|
13
|
-
* object-array values promote to full-width sections below the rows so
|
|
14
|
-
* nested tables keep the whole container width.
|
|
15
|
-
* 5. Otherwise -> definition list of all keys.
|
|
16
|
-
*
|
|
17
|
-
* Scalar display rules (shared by rows, chips, and table cells): numbers
|
|
18
|
-
* round to 2 decimals, booleans read Yes/No, ISO dates and datetimes format
|
|
19
|
-
* for the locale, SCREAMING_SNAKE enums humanize, http(s) strings link out.
|
|
20
|
-
*
|
|
21
|
-
* Every word this component writes goes through `this.t()`, which is not
|
|
22
|
-
* optional politeness: `suppress()` already folds the API's localized values
|
|
23
|
-
* into their canonical columns, so before the catalogue landed a Spanish page
|
|
24
|
-
* read `Sol` and `Piscis` under `Yes`, `No` and `31 rows` in English. What a
|
|
25
|
-
* catalogue CANNOT reach is the column headings, which come from the wire field
|
|
26
|
-
* name through `humanize()` and are therefore computed per response; those stay
|
|
27
|
-
* English on both this path and the PHP one, which at least keeps them
|
|
28
|
-
* consistent with each other. The PHP twin has none of these strings yet, so
|
|
29
|
-
* the JS and no-JS paths currently disagree on the chrome as well as the fold
|
|
30
|
-
* (see lesson 6 for why that matters).
|
|
31
|
-
*
|
|
32
|
-
* When a schema declares an `x-roxy-ui` hint, a future dispatcher can opt
|
|
33
|
-
* into a hand-tuned component instead of this fallback.
|
|
34
|
-
*/
|
|
35
3
|
type Json = string | number | boolean | null | Json[] | {
|
|
36
4
|
[key: string]: Json;
|
|
37
5
|
};
|
|
6
|
+
/**
|
|
7
|
+
* Generic fallback heuristic order:
|
|
8
|
+
* 1. Primitives render as locale-aware text; primitive arrays render as chips.
|
|
9
|
+
* 2. Compact object arrays render as tables; arrays with many columns plus paragraph text or nested data render as readable records.
|
|
10
|
+
* 3. Objects with a title render a heading and scalar facts; other objects render a definition list.
|
|
11
|
+
* 4. Nested objects and object arrays occupy full-width sections, retaining the shared depth and disclosure policy.
|
|
12
|
+
* Scalar dates, numbers and enums use shared locale-aware formatters; chrome uses t(), response labels use displayField(), and values are folded before classification.
|
|
13
|
+
* Folding localized values without translating surrounding chrome gives the reader mixed languages, and the server fallback must apply the same field selection and collection presentation.
|
|
14
|
+
*/
|
|
38
15
|
export declare class RoxyData extends RoxyDataElement<Json> {
|
|
39
16
|
static styles: import("lit").CSSResult[];
|
|
40
17
|
/**
|
|
@@ -45,7 +22,7 @@ export declare class RoxyData extends RoxyDataElement<Json> {
|
|
|
45
22
|
private renderValue;
|
|
46
23
|
private renderArray;
|
|
47
24
|
private renderChips;
|
|
48
|
-
private
|
|
25
|
+
private renderObjectArray;
|
|
49
26
|
/**
|
|
50
27
|
* Drop the fields that are noise on a reading card, and fold each localized twin into the field it translates. See {@link SUPPRESS_NOISE} and {@link foldLocalized}.
|
|
51
28
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/components/data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAG9D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/components/data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAG9D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAO3D,KAAK,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AA2GhF;;;;;;;;GAQG;AACH,qBACa,QAAS,SAAQ,eAAe,CAAC,IAAI,CAAC;IAClD,MAAM,CAAC,MAAM,4BAqLX;IAEF;;OAEG;IAEH,KAAK,SAAK;IAEV,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI;IAW/B,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,iBAAiB;IAiEzB;;;;;OAKG;IACH,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,YAAY;IA4DpB;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAwBrB,OAAO,CAAC,WAAW;IAkBnB,OAAO,CAAC,UAAU;IAwBlB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,WAAW;CAOnB;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,WAAW,EAAE,QAAQ,CAAC;KACtB;CACD"}
|
package/dist/components/data.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var be=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var a=(t,n,e,r)=>{for(var i=r>1?void 0:r?xe(n,e):n,o=t.length-1,s;o>=0;o--)(s=t[o])&&(i=(r?s(n,e,i):s(i))||i);return r&&i&&be(n,e,i),i};import{css as Je,html as l,nothing as R}from"lit";import{customElement as Me,property as Ye}from"lit/decorators.js";import{ifDefined as fe}from"lit/directives/if-defined.js";import{html as f,nothing as b}from"lit";import{property as g,state as h}from"lit/decorators.js";import{ifDefined as v}from"lit/directives/if-defined.js";var D=["de","en","es","fr","hi","pt","ru","tr","zh-Hans","zh-Hant"];function U(t){if(t.lang)return t.lang;if(typeof document>"u")return;let n=t.closest?.("[lang]")?.getAttribute("lang");return n||document.documentElement.lang||void 0}var we={tw:"hant",hk:"hant",mo:"hant",cn:"hans",sg:"hans",my:"hans"};function N(t){let n=t.toLowerCase();return D.find(e=>e.toLowerCase()===n)}function q(t){let n=U(t);if(!n)return;let e=N(n);if(e)return e;let r=n.toLowerCase().split("-"),i=r[0];if(i==="zh"){let o=r.find(s=>s==="hans"||s==="hant")??we[r[1]??""];return o?N(`zh-${o}`):void 0}return N(i)}import{LitElement as Se}from"lit";function J(t){return t.toLowerCase().replace(/[\s_-]+/g," ").trim()}function $(t){return t.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([a-z])([0-9])/g,"$1 $2").replace(/^\w/,n=>n.toUpperCase())}var M="__ROXY_UI_I18N__";function z(){let t=globalThis,n=t[M];if(n)return n;let e={catalogs:{},fieldLabels:{},requested:new Set,listeners:new Set};return t[M]=e,e}function ve(t,n){return n?t.replace(/\{\{(\w+)\}\}/g,(e,r)=>r in n?String(n[r]??""):e):t}function Y(t,n,e){return ve(Re(t,n)??n,e)}function Re(t,n){if(!t)return;let{catalogs:e}=z(),r=t.toLowerCase();return(e[r]??e[r.split("-")[0]])?.[J(n)]}function ke(t){if(!t)return;let{fieldLabels:n}=z(),e=t.toLowerCase();return n[e]??n[e.split("-")[0]]}function H(t,n){return ke(t)?.fields[n]}function B(t){let{listeners:n}=z();return n.add(t),()=>{n.delete(t)}}var A=class{constructor(n){this.host=n,n.addController(this)}hostConnected(){this.unsubscribe=B(()=>this.host.requestUpdate())}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0}};var L=class extends Se{constructor(){super();this.translator=(e,r)=>this.t(e,r);new A(this)}t(e,r){return Y(this.effectiveLang(),e,r)}effectiveLang(){return U(this)}};import{css as $e}from"lit";var T=$e`:host{--roxy-label-col:minmax(0, 25%);--_success-fg:var(--roxy-success-fg,#09632a);--_warning-fg:var(--roxy-warning-fg,#913304);--_danger-fg:var(--roxy-danger-fg,#881313);--_info-fg:var(--roxy-info-fg,#014f7a);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([hidden]){display:none}: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%{transform:translateY(2px)}to{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(--_danger-fg);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}: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}.roxy-edit:disabled{cursor:progress;color:var(--roxy-muted,#71717a)}roxy-endpoint-form+*{margin-top:var(--roxy-space-md,1rem)}.roxy-more{justify-items:center;gap:var(--roxy-space-sm,.5rem);margin-top:var(--roxy-space-md,1rem);display:grid}.roxy-more .roxy-edit{min-height:44px}:host{font-variant-emoji:text}`;var Ae="__cols",Le="__rows";function Te(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function C(t){if(Array.isArray(t)){let o=!1,s=t.map(p=>{let y=C(p);return y!==p&&(o=!0),y});return o?s:t}if(!Te(t))return t;let n=t[Ae],e=t[Le];if(Array.isArray(n)&&Array.isArray(e)&&Object.keys(t).length===2)return e.map(o=>{let s={};return n.forEach((p,y)=>{s[p]=C(o[y])}),s});let r=!1,i={};for(let[o,s]of Object.entries(t)){let p=C(s);p!==s&&(r=!0),i[o]=p}return r?i:t}function G(t){return C(t)}var Ce="pk_live_YOUR_KEY",Z={secret:{reason:"possible-secret-key",message:"Client-side components accept a pk_ publishable key only. Use a publishable key with an origin allowlist, or render server-side."},sample:{reason:"sample-key",message:"Replace the sample key with your own publishable key from your RoxyAPI account."}};function V(t){if(t)return t===Ce?Z.sample:t.startsWith("pk_")?void 0:Z.secret}function W(t,n,e={}){e.warn&&console.warn(n.message),t.dispatchEvent(new CustomEvent("roxy-validation-error",{detail:{reason:n.reason,message:n.message},bubbles:!0,composed:!0}))}var X="https://roxyapi.com/api/v2";async function Ee(t){try{let n=await t.json();if(n?.error){let e=n.code==="validation_error"&&Array.isArray(n.issues)?n.issues.filter(r=>typeof r.path=="string"&&typeof r.message=="string").map(r=>({path:r.path,message:r.message})):null;return{message:n.error,issues:e?.length?e:null,worded:!0}}}catch{}return{message:`Request failed (${t.status})`,issues:null,worded:!1}}var w=class extends Error{constructor(e,r=null,i=!0){super(e);this.issues=r;this.worded=i}};function Q(t){return t.submitUrl?void 0:V(t.publishableKey)}async function F(t,n,e){let r=Q(t);if(r)throw new w(r.message);let i=t.submitUrl?await fetch(t.submitUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:Ke(n,t.submitContext),signal:e}):await _e(t,n,e);if(!i.ok){let o=await Ee(i);throw new w(o.message,o.issues,o.worded)}return await i.json()}function Ke(t,n){return JSON.stringify(n?{...t,context:n}:t)}function _e(t,n,e){let r=new URL(`${t.baseUrl??X}${n.path}`,document.baseURI);for(let[o,s]of Object.entries(n.query??{}))s!=null&&r.searchParams.set(o,String(s));let i={Accept:"application/json"};return t.publishableKey&&(i["X-API-Key"]=t.publishableKey),n.body!=null&&(i["Content-Type"]="application/json"),fetch(r,{method:n.method??"GET",headers:i,body:n.body!=null?JSON.stringify(n.body):void 0,signal:e})}var E=class{constructor(n){this.baseUrl=X;this.worded=!0;this.host=n,n.addController(this)}hostDisconnected(){this.abort?.abort(),this.abort=void 0}async run(n){this.worded=!0;let e=Q(this);if(e){this.host.error=e.message,W(this.host,e);return}this.abort?.abort();let r=new AbortController;this.abort=r,this.host.loading=!0,this.host.error=null,this.host.issues=null;try{let i=await F(this,n,r.signal);if(r.signal.aborted)return;this.host.data=i}catch(i){if(r.signal.aborted||i?.name==="AbortError")return;i instanceof w&&(this.host.issues=i.issues),this.worded=i instanceof w&&i.worded,this.host.error=i instanceof Error?i.message:String(i)}finally{this.abort===r&&(this.abort=void 0),r.signal.aborted||(this.host.loading=!1)}}};function ee(t,n,e,r=[]){let i={...e},o=`/${t.replace(/^\//,"")}`.replace(/\{([^}]+)\}/g,(u,m)=>{let c=i[m];return delete i[m],encodeURIComponent(String(c??""))}),s=new Set(r),p={},y={};for(let[u,m]of Object.entries(i))m===void 0||m===""||(n==="GET"||s.has(u)?p[u]=m:y[u]=m);return{path:o,method:n,query:p,body:n==="POST"?y:void 0}}import{css as re,html as O,nothing as j}from"lit";import{css as Ie,html as Ne}from"lit";function te(){return Ne`<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 Tt=Ie`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}}`;var Ue=re`.interp-keywords{flex-wrap:wrap;gap:.25rem;display:flex}.interp-keywords .kw{border-radius:var(--roxy-radius-full,9999px);background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 14%, transparent);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-xs,.75rem);padding:1px 8px}`,_t=re`.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}${Ue}`;function ne(t,n,e){let r=t.filter(i=>!!i.body);return r.length===0?j:O`<section class="block" part="section readings"><h3>${e}</h3>${r.map((i,o)=>O`<details class="interp-card" part="reading" name="${n}" ?open="${o===0}"><summary><span class="interp-lead">${i.label}</span> ${te()} ${i.aside?O`<span class="interp-aside"><small>${i.aside}</small></span>`:j}</summary><div class="interp-body"><p>${i.body}</p>${i.extra??j}</div></details>`)}</section>`}var ze="roxy-data";function Fe(t){return t.nodeName==="SCRIPT"&&t.getAttribute("type")==="application/json"}var K=class{constructor(n){this.host=n,n.addController(this)}hostConnected(){if(this.host.data!=null)return;let n=this.read();n!==void 0&&(this.host.data=n,this.host.requestUpdate())}read(){let n=this.findInlineScript();return n?this.parse(n.textContent):void 0}findInlineScript(){for(let n of Array.from(this.host.children))if(Fe(n)&&n.classList.contains(ze))return n;return null}parse(n){if(n?.trim())try{return JSON.parse(n)}catch{return}}};var Oe={fromAttribute:t=>{if(t!=null){try{let n=JSON.parse(t);if(n&&typeof n=="object"&&!Array.isArray(n))return n}catch{}console.warn("[roxy-ui] submit-context must be a JSON object; sending the request without it.")}}},d=class extends L{constructor(){super();this.data=null;this.endpoint="";this.method="POST";this.remember=!1;this.hideReadings=!1;this.hideSections="";this.loading=!1;this.error=null;this.issues=null;this.selfFetched=!1;this.editing=!1;this.sticky=!1;this.moreLoading=!1;this.moreError=null;this.onMore=async()=>{let e=this.lastRequest,r=this.listKey,i=this.listRows();if(!(!e||!r||!i)){this.moreLoading=!0,this.moreError=null;try{let o=await F(this.fetcher,{...e,query:{...e.query,offset:i.length}});if(this.lastRequest!==e)return;let s=o[r];this.data={...this.data,...o,[r]:[...i,...Array.isArray(s)?s:[]]}}catch(o){this.lastRequest===e&&(this.moreError=o instanceof Error?o.message:String(o))}finally{this.moreLoading=!1}}};this.onEdit=()=>{this.editing=!0};this.onFormSubmit=e=>{let r=e.detail;this.lastValues=r.values,this.sticky=!!r.sticky,this.selfFetched=!0,this.editing=!1,this.remember&&this.writeRemembered(r.values),this.fetchFresh(ee(this.endpoint,this.method,r.values,r.queryKeys??[]))};new K(this),this.fetcher=new E(this)}static{this.styles=[T]}willUpdate(e){if(e.has("data")&&this.data!=null){let r=G(this.data);r!==this.data&&(this.data=r)}(e.has("publishableKey")||e.has("baseUrl")||e.has("submitUrl")||e.has("submitContext"))&&this.syncFetcher()}syncFetcher(){this.fetcher.publishableKey=this.publishableKey,this.baseUrl&&(this.fetcher.baseUrl=this.baseUrl),this.fetcher.submitUrl=this.submitUrl,this.fetcher.submitContext=this.submitContext}render(){return f`${this.hiddenSectionsStyle()}${this.renderState()}`}drawn(e){try{return this.renderData(e)}catch(r){return console.warn(`[roxy-ui] ${this.localName} could not draw its response`,r),this.dispatchEvent(new CustomEvent("roxy-render-error",{detail:{error:r},bubbles:!0,composed:!0})),customElements.get("roxy-data")?f`<roxy-data .data="${e}" lang="${v(this.effectiveLang())}"></roxy-data>`:this.renderEmpty()}}hiddenSectionsStyle(){let e=this.hideSections.split(",").map(i=>i.trim().toLowerCase()).filter(i=>/^[a-z][a-z0-9-]*$/.test(i));if(e.length===0)return b;let r=e.map(i=>`[part~="${i}"],roxy-endpoint-form::part(${i}){display:none!important}`).join("");return f`<style>${r}</style>`}renderState(){return this.endpoint&&this.sticky&&this.selfFetched&&!this.editing?this.renderWithForm(this.stickyBody()):this.loading?this.renderLoading():this.error!=null?this.renderError(this.error):this.data!=null?this.selfFetched?this.editing?this.renderForm():this.renderResult(this.data):this.showAttribution()?f`${this.drawn(this.data)}${this.renderAttribution()}`:this.drawn(this.data):this.renderNoData()}renderInterpretation(e,r,i){return this.hideReadings?b:ne(e,r,this.t(i??"Reading"))}renderResult(e){let r=f`<div class="roxy-edit-bar" part="edit-bar"><button type="button" class="roxy-edit" @click="${this.onEdit}">${this.t("Edit query")}</button></div>${this.drawn(e)}`;return this.showAttribution()?f`${r}${this.renderAttribution()}`:r}renderWithForm(e){return f`${this.renderForm()}${e}`}stickyBody(){return this.loading?this.renderLoading():this.error!=null?this.issues?b:this.renderErrorBanner(this.error):this.data==null?b:this.showAttribution()?f`${this.drawn(this.data)}${this.renderAttribution()}`:this.drawn(this.data)}renderMore(){let e=this.listRows(),r=this.data?.total;return!this.lastRequest||!e||typeof r!="number"?b:e.length>=r?b:f`<div class="roxy-more" part="more"><button type="button" class="roxy-edit" ?disabled="${this.moreLoading}" aria-busy="${this.moreLoading?"true":"false"}" @click="${this.onMore}">${this.t("Show more")}</button> ${this.moreError?f`<p class="roxy-error" role="alert">${this.t(this.moreError)}</p>`:b}</div>`}listRows(){let e=this.listKey?this.data?.[this.listKey]:void 0;return Array.isArray(e)?e:void 0}fetchFresh(e){return this.lastRequest=e,this.openedRow=void 0,this.openedRowId=void 0,this.moreError=null,this.fetcher.run(e)}load(e){return this.syncFetcher(),this.fetchFresh(e)}pickRow(e){this.dispatchEvent(new CustomEvent("roxy-symbol-select",{detail:e,bubbles:!0,composed:!0})),this.openRow(e.id)}openRow(e){if(!this.rowDetail||!(this.publishableKey||this.submitUrl))return;let r=this.openedRow??document.createElement(this.rowDetail.tag);r.publishableKey=this.publishableKey,r.baseUrl=this.baseUrl,r.submitUrl=this.submitUrl,r.submitContext=this.submitContext,r.hideReadings=this.hideReadings,r.hideSections=this.hideSections;let i=this.effectiveLang();i&&r.setAttribute("lang",i),this.openedRow=r,this.openedRowId=e,r.load({path:`/${this.rowDetail.path.replace("{id}",encodeURIComponent(e))}`,method:"GET",query:{lang:q(this)}}).then(()=>r.scrollIntoView?.({block:"nearest"}))}showAttribution(){return this.attribution!=null&&this.attribution!=="off"&&this.attribution!=="false"}renderAttribution(){return f`<div class="roxy-attribution" part="attribution"><a href="https://roxyapi.com/?utm_source=widget&utm_medium=embed" target="_blank" rel="noopener">${this.t("Spiritual data by RoxyAPI")}</a></div>`}renderNoData(){return this.endpoint?this.renderWithForm(b):this.renderEmpty()}renderForm(){return f`<roxy-endpoint-form part="form" exportparts="hint" data-endpoint="${this.endpoint}" method="${this.method}" spec-url="${v(this.specUrl)}" publishable-key="${v(this.publishableKey)}" location-url="${v(this.locationUrl)}" submit-label="${v(this.submitLabel)}" lang="${v(this.effectiveLang())}" .initialValues="${this.formInitialValues()}" .serverIssues="${this.issues}" .apiRoute="${this.fetcher}" .autoload="${!this.selfFetched}" .fullPages="${!!this.listKey}" @roxy-submit="${this.onFormSubmit}"></roxy-endpoint-form>`}formInitialValues(){return this.lastValues??(this.remember?this.readRemembered():void 0)}rememberKey(){return`roxy-ui:form:${this.endpoint}`}readRemembered(){try{let e=sessionStorage.getItem(this.rememberKey());return e?JSON.parse(e):void 0}catch{return}}writeRemembered(e){try{sessionStorage.setItem(this.rememberKey(),JSON.stringify(e))}catch{}}renderEmpty(){return f`<div class="roxy-empty" role="status" part="empty">${this.t("No data")}</div>`}renderLoading(){return f`<div class="roxy-skeleton" style="height:8rem" role="status" aria-label="${this.t("Loading")}" part="loading"></div>`}renderError(e){if(this.endpoint&&this.issues)return this.renderForm();let r=this.renderErrorBanner(e);return this.endpoint?f`${r}${this.renderForm()}`:r}renderErrorBanner(e){return f`<div class="roxy-error" role="alert" part="error">${!this.fetcher.worded&&this.errorMessage||this.t(e)}</div>`}};a([g({attribute:!1})],d.prototype,"data",2),a([g({type:String,attribute:"data-endpoint"})],d.prototype,"endpoint",2),a([g({type:String})],d.prototype,"method",2),a([g({type:String,attribute:"publishable-key"})],d.prototype,"publishableKey",2),a([g({type:String,attribute:"base-url"})],d.prototype,"baseUrl",2),a([g({type:String,attribute:"spec-url"})],d.prototype,"specUrl",2),a([g({type:String,attribute:"submit-url"})],d.prototype,"submitUrl",2),a([g({attribute:"submit-context",converter:Oe})],d.prototype,"submitContext",2),a([g({type:String,attribute:"location-url"})],d.prototype,"locationUrl",2),a([g({type:Boolean})],d.prototype,"remember",2),a([g({type:Boolean,attribute:"hide-readings",reflect:!0})],d.prototype,"hideReadings",2),a([g({type:String,attribute:"hide-sections",reflect:!0})],d.prototype,"hideSections",2),a([g({type:String,attribute:"submit-label"})],d.prototype,"submitLabel",2),a([g({type:String,attribute:"error-message"})],d.prototype,"errorMessage",2),a([g({type:String})],d.prototype,"attribution",2),a([h()],d.prototype,"loading",2),a([h()],d.prototype,"error",2),a([h()],d.prototype,"issues",2),a([h()],d.prototype,"selfFetched",2),a([h()],d.prototype,"editing",2),a([h()],d.prototype,"sticky",2),a([h()],d.prototype,"openedRow",2),a([h()],d.prototype,"openedRowId",2),a([h()],d.prototype,"moreLoading",2),a([h()],d.prototype,"moreError",2);var se=/^\d{4}-\d{2}-\d{2}$/,je=/^\d{4}-\d{2}$/,Pe=/^\d{2}:\d{2}(:\d{2})?$/,De=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/,ie=new Map;function _(t){if(!t)return["en"];let n=ie.get(t);if(n)return[n,"en"];let e="en";try{e=Intl.getCanonicalLocales(t)[0]??"en"}catch{e="en"}return ie.set(t,e),[e,"en"]}var oe=new Map;function qe(t){let n=t??"",e=oe.get(n);if(e)return e;let i={hour:new Intl.DateTimeFormat(_(t),{timeStyle:"short",timeZone:"UTC"}).formatToParts(new Date(Date.UTC(2e3,0,1,1))).find(o=>o.type==="hour")?.value?.length===2?"2-digit":"numeric",minute:"2-digit"};return oe.set(n,i),i}function ae(t){let n=Pe.test(t)?`1970-01-01T${t}`:se.test(t)?`${t}T00:00:00`:je.test(t)?`${t}-01T00:00:00`:De.test(t)?t:null;return n?{d:new Date(`${n}Z`),timeZone:"UTC"}:{d:new Date(t)}}function de(t,n){if(typeof n!="string"||n.length===0||se.test(n))return"";let{d:e,timeZone:r}=ae(n);return Number.isNaN(e.getTime())?n:e.toLocaleTimeString(_(t),{...qe(t),timeZone:r})}function le(t,n){if(typeof n!="string"||n.length===0)return"";let{d:e,timeZone:r}=ae(n);return Number.isNaN(e.getTime())?n:e.toLocaleDateString(_(t),{month:"short",day:"numeric",year:"numeric",timeZone:r})}function ce(t,n,e=1){return typeof n!="number"||!Number.isFinite(n)?"":n.toLocaleString(_(t),{maximumFractionDigits:e})}function I(t,n,e){return H(t,n)??e??$(n)}var ue="Localized";function pe(t){let n;for(let e of Object.keys(t)){if(!e.endsWith(ue))continue;let r=e.slice(0,-ue.length);if(r===""||!(r in t))continue;n??={...t};let i=t[e];i!=null&&i!==""&&(n[r]=i),delete n[e]}return n??t}var me=["title","name","label","heading","overview","summary"],He=80,Be=["imageUrl","image","icon","symbol"],Ge=["imageUrl","image"],Ze=["affirmation","mantra","motto","quote"],Ve=new Set(["seed"]),We=new Set(["id","slug","key"]),Xe=new Set(["calculation","calculations","type","position","count","totalcount","total","limit","offset","page","pagesize","perpage"]),Qe=8,ge=1,et=12,tt=t=>t.toLowerCase().replace(/[_-]/g,""),ye=t=>/^(has|is)([A-Z_]|$)/.test(t),rt=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/,nt=/^[A-Z0-9]+(_[A-Z0-9]+)+$/,it=/^https?:\/\//,ot=6;function st(t,n){if(!Number.isInteger(n))return!1;let e=t.replace(/([a-z])([A-Z])/g,"$1 $2").split(/[\s_-]+/);return e[e.length-1].toLowerCase()==="year"}function x(t){return t===null||["string","number","boolean"].includes(typeof t)}function P(t){return t!==null&&typeof t=="object"&&!(Array.isArray(t)&&t.every(x))}function he(t){if(t==null)return!0;if(Array.isArray(t))return t.length===0;if(typeof t!="object")return!1;let n=Object.values(t);return n.length===0||n.every(he)}var k=class extends d{constructor(){super(...arguments);this.depth=0}renderData(e){return this.depth>=ot?l`<div class="roxy-empty" role="status">${this.t("Nested data omitted")}</div>`:l`<div class="roxy-card" part="card" aria-label="${this.t("Generic data display")}">${this.renderValue(e)}</div>`}renderValue(e){return e==null?R:x(e)?l`<p>${this.scalarTemplate(e)}</p>`:Array.isArray(e)?this.renderArray(e):this.renderObject(e)}renderArray(e){return e.length===0?l`<div class="roxy-empty" role="status">${this.t("Empty list")}</div>`:e.every(x)?this.renderChips(e):e.every(i=>i!==null&&typeof i=="object"&&!Array.isArray(i))?this.renderTable(e):l`<ol>${e.map(i=>l`<li>${this.renderValue(i)}</li>`)}</ol>`}renderChips(e){return l`<ul class="roxy-chips">${e.filter(r=>r!==null).map(r=>l`<li>${this.formatScalar(r)}</li>`)}</ul>`}renderTable(e){let r=e.map(u=>this.suppress(u)),i=this.collectKeys(r),o=new Set(i.filter(u=>r.some(m=>P(m[u]??null)))),s=o.size>0&&o.size<i.length,p=u=>s?o.has(u)?"col-wide":"col-tight":"",y=l`<div class="roxy-table-wrap" part="table" role="group" aria-label="${this.t("Data table")}" tabindex="0"><table class="roxy-table" role="table"><thead><tr>${i.map(u=>l`<th class="${p(u)}">${I(this.effectiveLang(),u)}</th>`)}</tr></thead><tbody>${r.map(u=>l`<tr>${i.map(m=>l`<td class="${p(m)}">${this.renderCell(u[m],m)}</td>`)}</tr>`)}</tbody></table></div>`;return r.length>et?l`<details class="roxy-table-details"><summary>${this.t("{{count}} rows",{count:r.length})}</summary>${y}</details>`:y}suppress(e){let r=pe(e),i=me.some(o=>typeof r[o]=="string");return Object.fromEntries(Object.entries(r).filter(([o])=>{let s=tt(o);return Ve.has(s)||i&&We.has(s)?!1:!Xe.has(s)}))}renderObject(e){let r=this.suppress(e),i=me.find(c=>typeof r[c]=="string"&&r[c].length<=He),o=Be.find(c=>typeof r[c]=="string"&&r[c].startsWith("http")),s=i!=="summary"&&typeof r.summary=="string"?"summary":null,p=Ze.find(c=>typeof r[c]=="string"),y=Object.entries(r).filter(([c,S])=>c!==i&&c!==s&&c!==p&&!Ge.includes(c)&&!he(S)),u=y.filter(([,c])=>!P(c)),m=y.filter(([,c])=>P(c));return l`${o?l`<img class="roxy-image" src="${String(r[o])}" alt="${i?String(r[i]):this.t("illustration")}" loading="lazy">`:R} ${i?l`<h3 class="roxy-title" part="header">${r[i]}</h3>`:R} ${s?l`<p class="roxy-summary">${r[s]}</p>`:R} ${p?l`<blockquote class="roxy-quote">${r[p]}</blockquote>`:R} ${u.length>0?l`<dl class="roxy-rows" part="details label-track">${u.map(([c,S])=>l`<dt>${I(this.effectiveLang(),c)}</dt><dd>${this.renderField(S,c)}</dd>`)}</dl>`:R} ${m.map(([c,S])=>this.renderSection(c,S))}`}renderSection(e,r){let i=r!==null&&typeof r=="object"?Array.isArray(r)?r.length:Object.keys(r).length:0,o=this.renderField(r,e),s=I(this.effectiveLang(),e);return i>Qe||this.depth>=ge?l`<details class="roxy-section" ?open="${this.depth<ge}"><summary>${s}</summary>${o}</details>`:l`<div class="roxy-section"><h4>${s}</h4>${o}</div>`}renderField(e,r){return e==null?"":e===!0&&r!==void 0&&ye(r)?l`<span class="roxy-badge">${this.t("Yes")}</span>`:x(e)?l`${this.scalarTemplate(e,r)}`:Array.isArray(e)&&e.every(x)?this.renderChips(e):l`<roxy-data bare lang="${fe(this.effectiveLang())}" .data="${e}" .depth="${this.depth+1}"></roxy-data>`}renderCell(e,r){return e==null?"":e===!0&&r!==void 0&&ye(r)?l`<span class="roxy-badge">${this.t("Yes")}</span>`:x(e)?this.scalarTemplate(e,r):Array.isArray(e)&&e.every(x)?e.filter(i=>i!==null).map(i=>this.formatScalar(i)).join(", "):l`<roxy-data bare lang="${fe(this.effectiveLang())}" .data="${e}" .depth="${this.depth+1}"></roxy-data>`}scalarTemplate(e,r){return typeof e=="string"&&it.test(e)?l`<a href="${e}" target="_blank" rel="noopener noreferrer">${e}</a>`:this.formatScalar(e,r)}formatScalar(e,r){if(typeof e=="number")return r!==void 0&&st(r,e)?String(e):ce(this.effectiveLang(),e,2)||String(e);if(typeof e=="boolean")return e?this.t("Yes"):this.t("No");if(rt.test(e)){let i=de(this.effectiveLang(),e),o=le(this.effectiveLang(),e);return i?`${o}, ${i}`:o}return nt.test(e)?$(e.toLowerCase()):e}collectKeys(e){let r=new Set;for(let i of e)for(let o of Object.keys(i))r.add(o);return Array.from(r)}};k.styles=[T,Je`.roxy-card{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)}.roxy-card a{color:var(--roxy-accent-ink,#b45309)}.roxy-title{font-size:var(--roxy-text-lg,1.125rem);font-weight:var(--roxy-weight-bold,600);margin:0 0 var(--roxy-space-sm,.5rem) 0;color:var(--roxy-primary,#0f172a);letter-spacing:var(--roxy-tracking-tight)}.roxy-summary{color:var(--roxy-secondary,#475569);margin:0 0 var(--roxy-space-md,1rem) 0;font-size:var(--roxy-text-sm,.875rem)}dl.roxy-rows{grid-template-columns:minmax(8ch, min(25%, max-content)) minmax(0, 1fr);gap:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);margin:0;display:grid}dl.roxy-rows dt{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-sm,.875rem);text-transform:capitalize}dl.roxy-rows dd{color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-sm,.875rem);word-break:break-word;margin:0}ul.roxy-chips{gap:var(--roxy-space-xs,.25rem);flex-wrap:wrap;margin:0;padding:0;list-style:none;display:flex}ul.roxy-chips li{background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 14%, transparent);color:var(--roxy-fg,#0a0a0a);border-radius:var(--roxy-radius-full,9999px);font-size:var(--roxy-text-xs,.75rem);padding:2px 8px}.roxy-table-wrap{min-width:0;overflow-x:auto}table.roxy-table{border-collapse:collapse;width:100%;font-size:var(--roxy-text-sm,.875rem)}table.roxy-table th,table.roxy-table td{border-bottom:1px solid var(--roxy-border,#e4e4e7);padding:var(--roxy-space-sm,.5rem);text-align:left;text-transform:none;word-break:normal;overflow-wrap:normal}table.roxy-table th{color:var(--roxy-muted,#71717a);font-weight:var(--roxy-weight-bold,600);text-transform:capitalize;font-size:var(--roxy-text-xs,.75rem);letter-spacing:.04em;white-space:nowrap}table.roxy-table th.col-tight,table.roxy-table td.col-tight{white-space:nowrap;width:1%}table.roxy-table th.col-wide,table.roxy-table td.col-wide{width:auto}.roxy-image{border-radius:var(--roxy-radius-md,8px);max-width:100%;height:auto;margin-bottom:var(--roxy-space-md,1rem)}.roxy-section{margin-top:var(--roxy-space-md,1rem)}.roxy-section h4{font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-secondary,#475569);margin:0 0 var(--roxy-space-xs,.25rem) 0;text-transform:capitalize}blockquote.roxy-quote{margin:var(--roxy-space-md,1rem) 0;padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);border-left:3px solid var(--roxy-accent,#f59e0b);background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 8%, transparent);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-sm,.875rem);font-style:italic}.roxy-badge{border-radius:var(--roxy-radius-full,9999px);background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 18%, transparent);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-xs,.75rem);font-weight:var(--roxy-weight-bold,600);padding:1px 8px;display:inline-block}details.roxy-section,details.roxy-table-details{margin-top:var(--roxy-space-md,1rem)}details.roxy-section>summary,details.roxy-table-details>summary{cursor:pointer;font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-secondary,#475569);text-transform:capitalize}details.roxy-section>summary:focus-visible,details.roxy-table-details>summary:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px;border-radius:4px}`],a([Ye({attribute:!1})],k.prototype,"depth",2),k=a([Me("roxy-data")],k);export{k as RoxyData};
|
|
1
|
+
var we=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var d=(r,n,e,t)=>{for(var i=t>1?void 0:t?ve(n,e):n,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(t?s(n,e,i):s(i))||i);return t&&i&&we(n,e,i),i};import{css as Ye,html as a,nothing as w}from"lit";import{customElement as Be,property as Ge}from"lit/decorators.js";import{ifDefined as ge}from"lit/directives/if-defined.js";import{html as f,nothing as v}from"lit";import{property as m,state as b}from"lit/decorators.js";import{ifDefined as S}from"lit/directives/if-defined.js";var M=["de","en","es","fr","hi","pt","ru","tr","zh-Hans","zh-Hant"];function U(r){if(r.lang)return r.lang;if(typeof document>"u")return;let n=r.closest?.("[lang]")?.getAttribute("lang");return n||document.documentElement.lang||void 0}var ke={tw:"hant",hk:"hant",mo:"hant",cn:"hans",sg:"hans",my:"hans"};function I(r){let n=r.toLowerCase();return M.find(e=>e.toLowerCase()===n)}function J(r){let n=U(r);if(!n)return;let e=I(n);if(e)return e;let t=n.toLowerCase().split("-"),i=t[0];if(i==="zh"){let o=t.find(s=>s==="hans"||s==="hant")??ke[t[1]??""];return o?I(`zh-${o}`):void 0}return I(i)}import{LitElement as Ae}from"lit";function H(r){return r.toLowerCase().replace(/[\s_-]+/g," ").trim()}function L(r){return r.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([a-z])([0-9])/g,"$1 $2").replace(/^\w/,n=>n.toUpperCase())}var Y="__ROXY_UI_I18N__";function F(){let r=globalThis,n=r[Y];if(n)return n;let e={catalogs:{},fieldLabels:{},requested:new Set,listeners:new Set};return r[Y]=e,e}function Re(r,n){return n?r.replace(/\{\{(\w+)\}\}/g,(e,t)=>t in n?String(n[t]??""):e):r}function B(r,n,e){return Re(Se(r,n)??n,e)}function Se(r,n){if(!r)return;let{catalogs:e}=F(),t=r.toLowerCase();return(e[t]??e[t.split("-")[0]])?.[H(n)]}function $e(r){if(!r)return;let{fieldLabels:n}=F(),e=r.toLowerCase();return n[e]??n[e.split("-")[0]]}function G(r,n){return $e(r)?.fields[n]}function Z(r){let{listeners:n}=F();return n.add(r),()=>{n.delete(r)}}var T=class{constructor(n){this.host=n,n.addController(this)}hostConnected(){this.unsubscribe=Z(()=>this.host.requestUpdate())}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0}};var C=class extends Ae{constructor(){super();this.translator=(e,t)=>this.t(e,t);new T(this)}t(e,t){return B(this.effectiveLang(),e,t)}effectiveLang(){return U(this)}};import{css as Le}from"lit";var E=Le`:host{--roxy-label-col:minmax(0, 25%);--_success-fg:var(--roxy-success-fg,#09632a);--_warning-fg:var(--roxy-warning-fg,#913304);--_danger-fg:var(--roxy-danger-fg,#881313);--_info-fg:var(--roxy-info-fg,#014f7a);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([hidden]){display:none}: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%{transform:translateY(2px)}to{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(--_danger-fg);font-size:var(--roxy-text-sm,.875rem);justify-items:start;display:grid}: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}.roxy-edit:disabled{cursor:progress;color:var(--roxy-muted,#71717a)}roxy-endpoint-form+*{margin-top:var(--roxy-space-md,1rem)}.roxy-more{justify-items:center;gap:var(--roxy-space-sm,.5rem);margin-top:var(--roxy-space-md,1rem);display:grid}.roxy-more .roxy-edit{min-height:44px}:host{font-variant-emoji:text}`;var Te="__cols",Ce="__rows";function Ee(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function _(r){if(Array.isArray(r)){let o=!1,s=r.map(p=>{let y=_(p);return y!==p&&(o=!0),y});return o?s:r}if(!Ee(r))return r;let n=r[Te],e=r[Ce];if(Array.isArray(n)&&Array.isArray(e)&&Object.keys(r).length===2)return e.map(o=>{let s={};return n.forEach((p,y)=>{s[p]=_(o[y])}),s});let t=!1,i={};for(let[o,s]of Object.entries(r)){let p=_(s);p!==s&&(t=!0),i[o]=p}return t?i:r}function V(r){return _(r)}var _e="pk_live_YOUR_KEY",W={secret:{reason:"possible-secret-key",message:"Client-side components accept a pk_ publishable key only. Use a publishable key with an origin allowlist, or render server-side."},sample:{reason:"sample-key",message:"Replace the sample key with your own publishable key from your RoxyAPI account."}};function X(r){if(r)return r===_e?W.sample:r.startsWith("pk_")?void 0:W.secret}function Q(r,n,e={}){e.warn&&console.warn(n.message),r.dispatchEvent(new CustomEvent("roxy-validation-error",{detail:{reason:n.reason,message:n.message},bubbles:!0,composed:!0}))}var ee="https://roxyapi.com/api/v2";async function Ke(r){try{let n=await r.json();if(n?.error){let e=n.code==="validation_error"&&Array.isArray(n.issues)?n.issues.filter(t=>typeof t.path=="string"&&typeof t.message=="string").map(t=>({path:t.path,message:t.message})):null;return{message:n.error,issues:e?.length?e:null,worded:!0}}}catch{}return{message:`Request failed (${r.status})`,issues:null,worded:!1}}var R=class extends Error{constructor(e,t=null,i=!0){super(e);this.issues=t;this.worded=i}};function te(r){return r.submitUrl?void 0:X(r.publishableKey)}async function O(r,n,e){let t=te(r);if(t)throw new R(t.message);let i=r.submitUrl?await fetch(r.submitUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:ze(n,r.submitContext),signal:e}):await Ne(r,n,e);if(!i.ok){let o=await Ke(i);throw new R(o.message,o.issues,o.worded)}return await i.json()}function ze(r,n){return JSON.stringify(n?{...r,context:n}:r)}function Ne(r,n,e){let t=new URL(`${r.baseUrl??ee}${n.path}`,document.baseURI);for(let[o,s]of Object.entries(n.query??{}))s!=null&&t.searchParams.set(o,String(s));let i={Accept:"application/json"};return r.publishableKey&&(i["X-API-Key"]=r.publishableKey),n.body!=null&&(i["Content-Type"]="application/json"),fetch(t,{method:n.method??"GET",headers:i,body:n.body!=null?JSON.stringify(n.body):void 0,signal:e})}var K=class{constructor(n){this.baseUrl=ee;this.worded=!0;this.host=n,n.addController(this)}hostDisconnected(){this.abort?.abort(),this.abort=void 0}async run(n){this.worded=!0;let e=te(this);if(e){this.host.error=e.message,Q(this.host,e);return}this.abort?.abort();let t=new AbortController;this.abort=t,this.host.loading=!0,this.host.error=null,this.host.issues=null;try{let i=await O(this,n,t.signal);if(t.signal.aborted)return;this.host.data=i}catch(i){if(t.signal.aborted||i?.name==="AbortError")return;i instanceof R&&(this.host.issues=i.issues),this.worded=i instanceof R&&i.worded,this.host.error=i instanceof Error?i.message:String(i)}finally{this.abort===t&&(this.abort=void 0),t.signal.aborted||(this.host.loading=!1)}}};function re(r,n,e,t=[]){let i={...e},o=`/${r.replace(/^\//,"")}`.replace(/\{([^}]+)\}/g,(g,h)=>{let c=i[h];return delete i[h],encodeURIComponent(String(c??""))}),s=new Set(t),p={},y={};for(let[g,h]of Object.entries(i))h===void 0||h===""||(n==="GET"||s.has(g)?p[g]=h:y[g]=h);return{path:o,method:n,query:p,body:n==="POST"?y:void 0}}import{css as ie,html as j,nothing as P}from"lit";import{css as Ie,html as Ue}from"lit";function ne(){return Ue`<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 zt=Ie`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}}`;var Fe=ie`.interp-keywords{flex-wrap:wrap;gap:.25rem;display:flex}.interp-keywords .kw{border-radius:var(--roxy-radius-full,9999px);background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 14%, transparent);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-xs,.75rem);padding:1px 8px}`,Ft=ie`.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}${Fe}`;function oe(r,n,e){let t=r.filter(i=>!!i.body);return t.length===0?P:j`<section class="block" part="section readings"><h3>${e}</h3>${t.map((i,o)=>j`<details class="interp-card" part="reading" name="${n}" ?open="${o===0}"><summary><span class="interp-lead">${i.label}</span> ${ne()} ${i.aside?j`<span class="interp-aside"><small>${i.aside}</small></span>`:P}</summary><div class="interp-body"><p>${i.body}</p>${i.extra??P}</div></details>`)}</section>`}var Oe="roxy-data";function je(r){return r.nodeName==="SCRIPT"&&r.getAttribute("type")==="application/json"}var z=class{constructor(n){this.host=n,n.addController(this)}hostConnected(){if(this.host.data!=null)return;let n=this.read();n!==void 0&&(this.host.data=n,this.host.requestUpdate())}read(){let n=this.findInlineScript();return n?this.parse(n.textContent):void 0}findInlineScript(){for(let n of Array.from(this.host.children))if(je(n)&&n.classList.contains(Oe))return n;return null}parse(n){if(n?.trim())try{return JSON.parse(n)}catch{return}}};var Pe={fromAttribute:r=>{if(r!=null){try{let n=JSON.parse(r);if(n&&typeof n=="object"&&!Array.isArray(n))return n}catch{}console.warn("[roxy-ui] submit-context must be a JSON object; sending the request without it.")}}},l=class extends C{constructor(){super();this.data=null;this.endpoint="";this.method="POST";this.remember=!1;this.hideReadings=!1;this.hideSections="";this.loading=!1;this.error=null;this.issues=null;this.selfFetched=!1;this.editing=!1;this.sticky=!1;this.moreLoading=!1;this.moreError=null;this.onMore=async()=>{let e=this.lastRequest,t=this.listKey,i=this.listRows();if(!(!e||!t||!i)){this.moreLoading=!0,this.moreError=null;try{let o=await O(this.fetcher,{...e,query:{...e.query,offset:i.length}});if(this.lastRequest!==e)return;let s=o[t];this.data={...this.data,...o,[t]:[...i,...Array.isArray(s)?s:[]]}}catch(o){this.lastRequest===e&&(this.moreError=o instanceof Error?o.message:String(o))}finally{this.moreLoading=!1}}};this.onEdit=()=>{this.editing=!0};this.onFormSubmit=e=>{let t=e.detail;this.lastValues=t.values,this.sticky=!!t.sticky,this.selfFetched=!0,this.editing=!1,this.remember&&this.writeRemembered(t.values),this.fetchFresh(re(this.endpoint,this.method,t.values,t.queryKeys??[]))};new z(this),this.fetcher=new K(this)}static{this.styles=[E]}willUpdate(e){if(e.has("data")&&this.data!=null){let t=V(this.data);t!==this.data&&(this.data=t)}(e.has("publishableKey")||e.has("baseUrl")||e.has("submitUrl")||e.has("submitContext"))&&this.syncFetcher()}syncFetcher(){this.fetcher.publishableKey=this.publishableKey,this.baseUrl&&(this.fetcher.baseUrl=this.baseUrl),this.fetcher.submitUrl=this.submitUrl,this.fetcher.submitContext=this.submitContext}render(){return f`${this.hiddenSectionsStyle()}${this.renderState()}`}drawn(e){try{return this.renderData(e)}catch(t){return console.warn(`[roxy-ui] ${this.localName} could not draw its response`,t),this.dispatchEvent(new CustomEvent("roxy-render-error",{detail:{error:t},bubbles:!0,composed:!0})),customElements.get("roxy-data")?f`<roxy-data .data="${e}" lang="${S(this.effectiveLang())}"></roxy-data>`:this.renderEmpty()}}hiddenSectionsStyle(){let e=this.hideSections.split(",").map(i=>i.trim().toLowerCase()).filter(i=>/^[a-z][a-z0-9-]*$/.test(i));if(e.length===0)return v;let t=e.map(i=>`[part~="${i}"],roxy-endpoint-form::part(${i}){display:none!important}`).join("");return f`<style>${t}</style>`}renderState(){return this.endpoint&&this.sticky&&this.selfFetched&&!this.editing?this.renderWithForm(this.stickyBody()):this.loading?this.renderLoading():this.error!=null?this.renderError(this.error):this.data!=null?this.selfFetched?this.editing?this.renderForm():this.renderResult(this.data):this.showAttribution()?f`${this.drawn(this.data)}${this.renderAttribution()}`:this.drawn(this.data):this.renderNoData()}renderInterpretation(e,t,i){return this.hideReadings?v:oe(e,t,this.t(i??"Reading"))}renderResult(e){let t=f`<div class="roxy-edit-bar" part="edit-bar"><button type="button" class="roxy-edit" @click="${this.onEdit}">${this.t("Edit query")}</button></div>${this.drawn(e)}`;return this.showAttribution()?f`${t}${this.renderAttribution()}`:t}renderWithForm(e){return f`${this.renderForm()}${e}`}stickyBody(){return this.loading?this.renderLoading():this.error!=null?this.issues?v:this.renderErrorBanner(this.error):this.data==null?v:this.showAttribution()?f`${this.drawn(this.data)}${this.renderAttribution()}`:this.drawn(this.data)}renderMore(){let e=this.listRows(),t=this.data?.total;return!this.lastRequest||!e||typeof t!="number"?v:e.length>=t?v:f`<div class="roxy-more" part="more"><button type="button" class="roxy-edit" ?disabled="${this.moreLoading}" aria-busy="${this.moreLoading?"true":"false"}" @click="${this.onMore}">${this.t("Show more")}</button> ${this.moreError?f`<p class="roxy-error" role="alert">${this.t(this.moreError)}</p>`:v}</div>`}listRows(){let e=this.listKey?this.data?.[this.listKey]:void 0;return Array.isArray(e)?e:void 0}fetchFresh(e){return this.lastRequest=e,this.openedRow=void 0,this.openedRowId=void 0,this.moreError=null,this.fetcher.run(e)}load(e){return this.syncFetcher(),this.fetchFresh(e)}pickRow(e){this.dispatchEvent(new CustomEvent("roxy-symbol-select",{detail:e,bubbles:!0,composed:!0})),this.openRow(e.id)}openRow(e){if(!this.rowDetail||!(this.publishableKey||this.submitUrl))return;let t=this.openedRow??document.createElement(this.rowDetail.tag);t.publishableKey=this.publishableKey,t.baseUrl=this.baseUrl,t.submitUrl=this.submitUrl,t.submitContext=this.submitContext,t.hideReadings=this.hideReadings,t.hideSections=this.hideSections;let i=this.effectiveLang();i&&t.setAttribute("lang",i),this.openedRow=t,this.openedRowId=e,t.load({path:`/${this.rowDetail.path.replace("{id}",encodeURIComponent(e))}`,method:"GET",query:{lang:J(this)}}).then(()=>t.scrollIntoView?.({block:"nearest"}))}showAttribution(){return this.attribution!=null&&this.attribution!=="off"&&this.attribution!=="false"}renderAttribution(){return f`<div class="roxy-attribution" part="attribution"><a href="https://roxyapi.com/?utm_source=widget&utm_medium=embed" target="_blank" rel="noopener">${this.t("Spiritual data by RoxyAPI")}</a></div>`}renderNoData(){return this.endpoint?this.renderWithForm(v):this.renderEmpty()}renderForm(){return f`<roxy-endpoint-form part="form" exportparts="hint" data-endpoint="${this.endpoint}" method="${this.method}" spec-url="${S(this.specUrl)}" publishable-key="${S(this.publishableKey)}" location-url="${S(this.locationUrl)}" submit-label="${S(this.submitLabel)}" lang="${S(this.effectiveLang())}" .initialValues="${this.formInitialValues()}" .serverIssues="${this.issues}" .apiRoute="${this.fetcher}" .autoload="${!this.selfFetched}" .fullPages="${!!this.listKey}" @roxy-submit="${this.onFormSubmit}"></roxy-endpoint-form>`}formInitialValues(){return this.lastValues??(this.remember?this.readRemembered():void 0)}rememberKey(){return`roxy-ui:form:${this.endpoint}`}readRemembered(){try{let e=sessionStorage.getItem(this.rememberKey());return e?JSON.parse(e):void 0}catch{return}}writeRemembered(e){try{sessionStorage.setItem(this.rememberKey(),JSON.stringify(e))}catch{}}renderEmpty(){return f`<div class="roxy-empty" role="status" part="empty">${this.t("No data")}</div>`}renderLoading(){return f`<div class="roxy-skeleton" style="height:8rem" role="status" aria-label="${this.t("Loading")}" part="loading"></div>`}renderError(e){if(this.endpoint&&this.issues)return this.renderForm();let t=this.renderErrorBanner(e);return this.endpoint?f`${t}${this.renderForm()}`:t}renderErrorBanner(e){return f`<div class="roxy-error" role="alert" part="error">${!this.fetcher.worded&&this.errorMessage||this.t(e)}</div>`}};d([m({attribute:!1})],l.prototype,"data",2),d([m({type:String,attribute:"data-endpoint"})],l.prototype,"endpoint",2),d([m({type:String})],l.prototype,"method",2),d([m({type:String,attribute:"publishable-key"})],l.prototype,"publishableKey",2),d([m({type:String,attribute:"base-url"})],l.prototype,"baseUrl",2),d([m({type:String,attribute:"spec-url"})],l.prototype,"specUrl",2),d([m({type:String,attribute:"submit-url"})],l.prototype,"submitUrl",2),d([m({attribute:"submit-context",converter:Pe})],l.prototype,"submitContext",2),d([m({type:String,attribute:"location-url"})],l.prototype,"locationUrl",2),d([m({type:Boolean})],l.prototype,"remember",2),d([m({type:Boolean,attribute:"hide-readings",reflect:!0})],l.prototype,"hideReadings",2),d([m({type:String,attribute:"hide-sections",reflect:!0})],l.prototype,"hideSections",2),d([m({type:String,attribute:"submit-label"})],l.prototype,"submitLabel",2),d([m({type:String,attribute:"error-message"})],l.prototype,"errorMessage",2),d([m({type:String})],l.prototype,"attribution",2),d([b()],l.prototype,"loading",2),d([b()],l.prototype,"error",2),d([b()],l.prototype,"issues",2),d([b()],l.prototype,"selfFetched",2),d([b()],l.prototype,"editing",2),d([b()],l.prototype,"sticky",2),d([b()],l.prototype,"openedRow",2),d([b()],l.prototype,"openedRowId",2),d([b()],l.prototype,"moreLoading",2),d([b()],l.prototype,"moreError",2);var D=/^\d{4}-\d{2}-\d{2}$/,De=/^\d{4}-\d{2}$/,de=/^\d{2}:\d{2}(:\d{2})?$/,qe=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/,se=new Map;function N(r){if(!r)return["en"];let n=se.get(r);if(n)return[n,"en"];let e="en";try{e=Intl.getCanonicalLocales(r)[0]??"en"}catch{e="en"}return se.set(r,e),[e,"en"]}var ae=new Map;function Me(r){let n=r??"",e=ae.get(n);if(e)return e;let i={hour:new Intl.DateTimeFormat(N(r),{timeStyle:"short",timeZone:"UTC"}).formatToParts(new Date(Date.UTC(2e3,0,1,1))).find(o=>o.type==="hour")?.value?.length===2?"2-digit":"numeric",minute:"2-digit"};return ae.set(n,i),i}function le(r){let n=de.test(r)?`1970-01-01T${r}`:D.test(r)?`${r}T00:00:00`:De.test(r)?`${r}-01T00:00:00`:qe.test(r)?r:null;return n?{d:new Date(`${n}Z`),timeZone:"UTC"}:{d:new Date(r)}}function Je(r,n){if(typeof n!="string"||n.length===0)return"";let{d:e,timeZone:t}=le(n);return Number.isNaN(e.getTime())?n:e.toLocaleDateString(N(r),{month:"short",day:"numeric",year:"numeric",timeZone:t})}function ce(r,n,e=1){return typeof n!="number"||!Number.isFinite(n)?"":n.toLocaleString(N(r),{maximumFractionDigits:e})}function ue(r,n,e){let t=typeof n=="string"&&D.test(n)&&typeof e=="string"&&de.test(e)?`${n}T${e}`:n;if(typeof t!="string"||t.length===0)return"";if(D.test(t))return Je(r,t);let{d:i,timeZone:o}=le(t);return Number.isNaN(i.getTime())?t:i.toLocaleString(N(r),{month:"short",day:"numeric",year:"numeric",...Me(r),timeZone:o})}function A(r,n,e){return G(r,n)??e??L(n)}var pe="Localized";function fe(r){let n;for(let e of Object.keys(r)){if(!e.endsWith(pe))continue;let t=e.slice(0,-pe.length);if(t===""||!(t in r))continue;n??={...r};let i=r[e];i!=null&&i!==""&&(n[t]=i),delete n[e]}return n??r}import{css as He}from"lit";var me=He`@container (width<=30rem){table.stacked,table.stacked caption,table.stacked tbody,table.stacked tr,table.stacked td{width:100%;min-width:0;display:block}table.stacked thead{display:none}table.stacked tr{border-bottom:1px solid var(--roxy-border,#e4e4e7);padding-block:var(--roxy-space-sm,.5rem)}table.stacked tr:last-child{border-bottom:0}table.stacked td{white-space:normal;border:0;padding:.1rem 0}table.stacked td:empty{display:none}table.stacked td[data-label]:before{content:attr(data-label) " ";color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-xs,.75rem);text-transform:uppercase;letter-spacing:.06em;font-weight:var(--roxy-weight-bold,600)}}`;var ye=["title","name","label","heading","overview","summary"],Ze=80,Ve=80,We=3,Xe=["imageUrl","image","icon","symbol"],Qe=["imageUrl","image"],et=["affirmation","mantra","motto","quote"],tt=new Set(["seed"]),rt=new Set(["id","slug","key"]),nt=new Set(["calculation","calculations","type","position","count","totalcount","total","limit","offset","page","pagesize","perpage"]),it=8,he=1,ot=12,st=r=>r.toLowerCase().replace(/[_-]/g,""),be=r=>/^(has|is)([A-Z_]|$)/.test(r),at=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/,dt=/^[A-Z0-9]+(_[A-Z0-9]+)+$/,lt=/^https?:\/\//,ct=6;function ut(r,n){if(!Number.isInteger(n))return!1;let e=r.replace(/([a-z])([A-Z])/g,"$1 $2").split(/[\s_-]+/);return e[e.length-1].toLowerCase()==="year"}function k(r){return r===null||["string","number","boolean"].includes(typeof r)}function q(r){return r!==null&&typeof r=="object"&&!(Array.isArray(r)&&r.every(k))}function xe(r){if(r==null)return!0;if(Array.isArray(r))return r.length===0;if(typeof r!="object")return!1;let n=Object.values(r);return n.length===0||n.every(xe)}var $=class extends l{constructor(){super(...arguments);this.depth=0}renderData(e){return this.depth>=ct?a`<div class="roxy-empty" role="status">${this.t("Nested data omitted")}</div>`:a`<div class="roxy-card" part="card" aria-label="${this.t("Generic data display")}">${this.renderValue(e)}</div>`}renderValue(e){return e==null?w:k(e)?a`<p>${this.scalarTemplate(e)}</p>`:Array.isArray(e)?this.renderArray(e):this.renderObject(e)}renderArray(e){return e.length===0?a`<div class="roxy-empty" role="status">${this.t("Empty list")}</div>`:e.every(k)?this.renderChips(e):e.every(i=>i!==null&&typeof i=="object"&&!Array.isArray(i))?this.renderObjectArray(e):a`<ol>${e.map(i=>a`<li>${this.renderValue(i)}</li>`)}</ol>`}renderChips(e){return a`<ul class="roxy-chips">${e.filter(t=>t!==null).map(t=>a`<li>${this.formatScalar(t)}</li>`)}</ul>`}renderObjectArray(e){let t=e.map(u=>this.suppress(u)),i=this.collectKeys(t),o=new Set(i.filter(u=>t.some(x=>typeof x[u]=="string"&&Array.from(x[u]).length>Ve))),s=new Set(i.filter(u=>o.has(u)||t.some(x=>q(x[u]??null)))),p=o.size>0||s.size>0&&s.size<i.length,y=u=>p?s.has(u)?"col-wide":"col-tight":"",g=s.size>0&&i.length>We,h=t.length>ot;return a`<div class="${g?"roxy-collection":h&&!g?"roxy-collection compact long":"roxy-collection compact"}" part="table" role="${g?"list":"group"}" aria-label="${g?this.t("{{count}} rows",{count:t.length}):this.t("Data table")}" tabindex="${g?w:"0"}">${g?a`${h?a`<p>${this.t("{{count}} rows",{count:t.length})}</p>`:w} ${t.map(u=>a`<div class="roxy-record" role="listitem">${this.renderField(u)}</div>`)}`:a`<table class="${o.size?"roxy-table stacked prose":s.size?"roxy-table stacked":"roxy-table"}" role="table">${h?a`<caption>${this.t("{{count}} rows",{count:t.length})}</caption>`:w}<thead><tr>${i.map(u=>a`<th class="${y(u)}">${A(this.effectiveLang(),u)}</th>`)}</tr></thead><tbody>${t.map(u=>a`<tr>${i.map(x=>a`<td class="${y(x)}" data-label="${A(this.effectiveLang(),x)}">${this.renderCell(u[x],x)}</td>`)}</tr>`)}</tbody></table>`}</div>`}suppress(e){let t=fe(e),i=ye.some(o=>typeof t[o]=="string");return Object.fromEntries(Object.entries(t).filter(([o])=>{let s=st(o);return tt.has(s)||i&&rt.has(s)?!1:!nt.has(s)}))}renderObject(e){let t=this.suppress(e),i=ye.find(c=>typeof t[c]=="string"&&t[c].length<=Ze),o=Xe.find(c=>typeof t[c]=="string"&&t[c].startsWith("http")),s=i!=="summary"&&typeof t.summary=="string"?"summary":null,p=et.find(c=>typeof t[c]=="string"),y=Object.entries(t).filter(([c,u])=>c!==i&&c!==s&&c!==p&&!Qe.includes(c)&&!xe(u)),g=y.filter(([,c])=>!q(c)),h=y.filter(([,c])=>q(c));return a`${o?a`<img class="roxy-image" src="${String(t[o])}" alt="${i?String(t[i]):this.t("illustration")}" loading="lazy">`:w} ${i?a`<h3 class="roxy-title" part="header">${t[i]}</h3>`:w} ${s?a`<p class="roxy-summary">${t[s]}</p>`:w} ${p?a`<blockquote class="roxy-quote">${t[p]}</blockquote>`:w} ${g.length>0?a`<dl class="roxy-rows" part="details label-track">${g.map(([c,u])=>a`<dt>${A(this.effectiveLang(),c)}</dt><dd>${this.renderField(u,c)}</dd>`)}</dl>`:w} ${h.map(([c,u])=>this.renderSection(c,u))}`}renderSection(e,t){let i=t!==null&&typeof t=="object"?Array.isArray(t)?t.length:Object.keys(t).length:0,o=this.renderField(t,e),s=A(this.effectiveLang(),e);return i>it||this.depth>=he?a`<details class="roxy-section" ?open="${this.depth<he}"><summary>${s}</summary>${o}</details>`:a`<div class="roxy-section"><h4>${s}</h4>${o}</div>`}renderField(e,t){return e==null?"":e===!0&&t!==void 0&&be(t)?a`<span class="roxy-badge">${this.t("Yes")}</span>`:k(e)?a`${this.scalarTemplate(e,t)}`:Array.isArray(e)&&e.every(k)?this.renderChips(e):a`<roxy-data bare lang="${ge(this.effectiveLang())}" .data="${e}" .depth="${this.depth+1}"></roxy-data>`}renderCell(e,t){return e==null?"":e===!0&&t!==void 0&&be(t)?a`<span class="roxy-badge">${this.t("Yes")}</span>`:k(e)?this.scalarTemplate(e,t):Array.isArray(e)&&e.every(k)?e.filter(i=>i!==null).map(i=>this.formatScalar(i)).join(", "):a`<roxy-data bare lang="${ge(this.effectiveLang())}" .data="${e}" .depth="${this.depth+1}"></roxy-data>`}scalarTemplate(e,t){return typeof e=="string"&<.test(e)?a`<a href="${e}" target="_blank" rel="noopener noreferrer">${e}</a>`:this.formatScalar(e,t)}formatScalar(e,t){return typeof e=="number"?t!==void 0&&ut(t,e)?String(e):ce(this.effectiveLang(),e,2)||String(e):typeof e=="boolean"?e?this.t("Yes"):this.t("No"):at.test(e)?ue(this.effectiveLang(),e):dt.test(e)?L(e.toLowerCase()):e}collectKeys(e){let t=new Set;for(let i of e)for(let o of Object.keys(i))t.add(o);return Array.from(t)}};$.styles=[E,Ye`.roxy-card{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)}.roxy-card a{color:var(--roxy-accent-ink,#b45309)}.roxy-title{font-size:var(--roxy-text-lg,1.125rem);font-weight:var(--roxy-weight-bold,600);margin:0 0 var(--roxy-space-sm,.5rem) 0;color:var(--roxy-primary,#0f172a);letter-spacing:var(--roxy-tracking-tight)}.roxy-summary{color:var(--roxy-secondary,#475569);margin:0 0 var(--roxy-space-md,1rem) 0;font-size:var(--roxy-text-sm,.875rem)}dl.roxy-rows{grid-template-columns:minmax(8ch, min(25%, max-content)) minmax(0, 1fr);gap:var(--roxy-space-xs,.25rem) var(--roxy-space-md,1rem);margin:0;display:grid}dl.roxy-rows dt{color:var(--roxy-muted,#71717a);font-size:var(--roxy-text-sm,.875rem);text-transform:capitalize}dl.roxy-rows dd{color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-sm,.875rem);word-break:break-word;margin:0}ul.roxy-chips{gap:var(--roxy-space-xs,.25rem);flex-wrap:wrap;margin:0;padding:0;list-style:none;display:flex}ul.roxy-chips li{background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 14%, transparent);color:var(--roxy-fg,#0a0a0a);border-radius:var(--roxy-radius-full,9999px);font-size:var(--roxy-text-xs,.75rem);padding:2px 8px}.roxy-collection{min-width:0}.roxy-collection.compact{overflow-x:auto}.roxy-collection.long{max-block-size:32rem}.roxy-collection:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px}.roxy-record+.roxy-record{margin-block-start:var(--roxy-space-sm,.5rem)}table.roxy-table{border-collapse:collapse;width:100%;font-size:var(--roxy-text-sm,.875rem)}table.roxy-table caption{text-align:start}table.roxy-table th,table.roxy-table td{border-bottom:1px solid var(--roxy-border,#e4e4e7);padding:var(--roxy-space-sm,.5rem);text-align:left;vertical-align:top;text-transform:none;word-break:normal;overflow-wrap:normal}table.roxy-table th{color:var(--roxy-muted,#71717a);font-weight:var(--roxy-weight-bold,600);text-transform:capitalize;font-size:var(--roxy-text-xs,.75rem);letter-spacing:.04em;white-space:nowrap}:where(table.roxy-table) :is(th,td).col-tight{white-space:nowrap;width:1%}:where(table.roxy-table) :is(th,td).col-wide{width:auto}:where(table.roxy-table.prose) :is(th,td).col-wide{min-width:40ch}.roxy-image{border-radius:var(--roxy-radius-md,8px);max-width:100%;height:auto;margin-bottom:var(--roxy-space-md,1rem)}.roxy-section{margin-top:var(--roxy-space-md,1rem)}.roxy-section h4{font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-secondary,#475569);margin:0 0 var(--roxy-space-xs,.25rem) 0;text-transform:capitalize}blockquote.roxy-quote{margin:var(--roxy-space-md,1rem) 0;padding:var(--roxy-space-sm,.5rem) var(--roxy-space-md,1rem);border-left:3px solid var(--roxy-accent,#f59e0b);background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 8%, transparent);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-sm,.875rem);font-style:italic}.roxy-badge{border-radius:var(--roxy-radius-full,9999px);background:color-mix(in srgb, var(--roxy-accent,#f59e0b) 18%, transparent);color:var(--roxy-fg,#0a0a0a);font-size:var(--roxy-text-xs,.75rem);font-weight:var(--roxy-weight-bold,600);padding:1px 8px;display:inline-block}details.roxy-section{margin-top:var(--roxy-space-md,1rem)}details.roxy-section>summary{cursor:pointer;font-size:var(--roxy-text-sm,.875rem);font-weight:var(--roxy-weight-bold,600);color:var(--roxy-secondary,#475569);text-transform:capitalize}details.roxy-section>summary:focus-visible{outline:2px solid var(--roxy-ring,#f59e0b66);outline-offset:2px;border-radius:4px}`,me],d([Ge({attribute:!1})],$.prototype,"depth",2),$=d([Be("roxy-data")],$);export{$ as RoxyData};
|
|
2
2
|
//# sourceMappingURL=data.js.map
|