{
  "$schema": "https://uipkge.dev/schema/registry-item.json",
  "name": "organization-chart",
  "title": "Organization Chart",
  "type": "registry:ui",
  "description": "Organization hierarchy visualization with a tree of nodes (name, title, avatar). Expand/collapse branches, top-down or left-right direction, connector lines, optional zoom/pan controls, node click events, and a customizable node render prop.",
  "categories": [
    "display",
    "data"
  ],
  "files": [
    {
      "path": "packages/elements-lit/src/components/charts/organization-chart.ts",
      "content": "import { LitElement, css, html, type PropertyValues } from 'lit'\nimport { styleMap } from 'lit/directives/style-map.js'\nimport { ChevronDown, ChevronRight } from 'lucide'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { tailwind } from '../../lib/styles'\nimport { ThemeController } from '../../lib/theme'\nimport { icon } from '../../lib/icon'\nimport { cn } from '../../lib/utils'\nimport { defaultTrue } from './lib/chart-element'\n\n// Variants (verbatim copy of React's organization-chart.variants.ts; inlined\n// because charts/ items ship as one flat file).\nexport const organizationChartVariants = cva('bg-background rounded-lg border')\n\nexport type OrganizationChartVariants = VariantProps<typeof organizationChartVariants>\n\n// Connector CSS (verbatim copy of React's organization-chart.css; inlined\n// because charts/ items ship as one flat file — the one allowed extra-CSS\n// exception beyond :host display, same as React-injected keyframes).\nconst orgConnectors = css`\n  .org-v {\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n  }\n  .org-v:not([data-root]) .org-v-card {\n    position: relative;\n    padding-top: 20px;\n  }\n  .org-v:not([data-root]) .org-v-card::before {\n    content: '';\n    position: absolute;\n    top: 0;\n    left: 50%;\n    width: 1px;\n    height: 20px;\n    background: var(--color-border, hsl(var(--border)));\n  }\n  .org-v-children {\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n  }\n  .org-v-line-down {\n    width: 1px;\n    height: 20px;\n    background: var(--color-border, hsl(var(--border)));\n  }\n  .org-v-children-row {\n    display: flex;\n    flex-direction: row;\n    gap: 24px;\n    position: relative;\n    padding-top: 20px;\n  }\n  .org-v-line-across {\n    position: absolute;\n    top: 0;\n    left: 104px;\n    right: 104px;\n    height: 1px;\n    background: var(--color-border, hsl(var(--border)));\n  }\n  .org-v-children-row[data-single] .org-v-line-across {\n    display: none;\n  }\n  .org-h {\n    display: flex;\n    flex-direction: column;\n    gap: 12px;\n  }\n  .org-h-line-right {\n    width: 20px;\n    height: 1px;\n    background: var(--color-border, hsl(var(--border)));\n    margin-top: 40px;\n    flex-shrink: 0;\n  }\n  .org-h-children {\n    display: flex;\n    flex-direction: column;\n    gap: 12px;\n    position: relative;\n  }\n  .org-h-children::before {\n    content: '';\n    position: absolute;\n    left: 0;\n    top: 40px;\n    bottom: 40px;\n    width: 1px;\n    background: var(--color-border, hsl(var(--border)));\n  }\n  .org-h:not([data-root]) .org-h-card {\n    position: relative;\n    padding-left: 20px;\n  }\n  .org-h:not([data-root]) .org-h-card::before {\n    content: '';\n    position: absolute;\n    top: 40px;\n    left: 0;\n    width: 20px;\n    height: 1px;\n    background: var(--color-border, hsl(var(--border)));\n  }\n`\n\nexport interface OrgNode {\n  id: string\n  name: string\n  title?: string\n  avatar?: string\n  department?: string\n  children?: OrgNode[]\n  [key: string]: unknown\n}\n\nfunction collectIds(node: OrgNode, acc: string[] = []): string[] {\n  acc.push(node.id)\n  if (node.children) for (const c of node.children) collectIds(c, acc)\n  return acc\n}\n\nfunction initials(name: string): string {\n  return name\n    .split(' ')\n    .map((p) => p[0])\n    .slice(0, 2)\n    .join('')\n    .toUpperCase()\n}\n\n/**\n * <uip-organization-chart> — the registry OrganizationChart (React\n * `OrganizationChart` + `OrgChartNode`) as a web component. Same cards,\n * connectors, directions, zoom toolbar and expand/collapse as React.\n *\n * Properties (React props): `data` (the root OrgNode; property or JSON\n * attribute), `direction` ('top-down' | 'left-right'; default 'top-down'),\n * `default-expanded` (default true; `default-expanded=\"false\"` starts\n * collapsed), `show-connectors` (default true;\n * `show-connectors=\"false\"` hides them), `zoomable` (default false),\n * `render-node` (property only — (node) => TemplateResult, React's\n * `renderNode`). React's `className` → host classes.\n *\n * Events: `node-click` (detail: the OrgNode — React's `onNodeClick`),\n * `toggle` (detail: { node, expanded } — React's `onToggle`).\n *\n * Methods (React's OrganizationChartHandle): `expandAll()`, `collapseAll()`,\n * `zoomIn()`, `zoomOut()`, `resetZoom()`.\n */\nexport class UipOrganizationChart extends LitElement {\n  // :host display can't be a utility class (the host has no template of its own).\n  static styles = [tailwind, orgConnectors, css`:host { display: block; }`]\n\n  static properties = {\n    data: { type: Object },\n    direction: {},\n    defaultExpanded: { attribute: 'default-expanded', converter: defaultTrue },\n    showConnectors: { attribute: 'show-connectors', converter: defaultTrue },\n    zoomable: { type: Boolean },\n    renderNode: { attribute: false },\n    expanded: { state: true },\n    zoom: { state: true },\n  }\n\n  data?: OrgNode\n  direction: 'top-down' | 'left-right' = 'top-down'\n  defaultExpanded = true\n  showConnectors = true\n  zoomable = false\n  renderNode?: (node: OrgNode) => unknown\n  private expanded: Set<string> = new Set()\n  private zoom = 1\n\n  constructor() {\n    super()\n    new ThemeController(this)\n  }\n\n  connectedCallback() {\n    super.connectedCallback()\n    this.setAttribute('data-uipkge', '')\n    this.setAttribute('data-slot', 'organization-chart')\n  }\n\n  protected willUpdate(changed: PropertyValues) {\n    // React re-syncs the expanded set whenever data or defaultExpanded changes.\n    if ((changed.has('data') || changed.has('defaultExpanded')) && this.data) {\n      if (this.defaultExpanded) {\n        this.expanded = new Set(collectIds(this.data))\n      } else {\n        this.expanded = new Set([this.data.id])\n      }\n    }\n  }\n\n  private toggleNode(node: OrgNode) {\n    const next = new Set(this.expanded)\n    if (next.has(node.id)) next.delete(node.id)\n    else next.add(node.id)\n    this.expanded = next\n    this.dispatchEvent(\n      new CustomEvent('toggle', { detail: { node, expanded: next.has(node.id) }, bubbles: true, composed: true }),\n    )\n  }\n\n  private isExpanded(node: OrgNode): boolean {\n    return this.expanded.has(node.id)\n  }\n\n  expandAll() {\n    if (this.data) this.expanded = new Set(collectIds(this.data))\n  }\n\n  collapseAll() {\n    if (this.data) this.expanded = new Set([this.data.id])\n  }\n\n  zoomIn() {\n    this.zoom = Math.min(2, this.zoom + 0.1)\n  }\n\n  zoomOut() {\n    this.zoom = Math.max(0.5, this.zoom - 0.1)\n  }\n\n  resetZoom() {\n    this.zoom = 1\n  }\n\n  private nodeCard(node: OrgNode, isRoot: boolean): unknown {\n    const open = this.isExpanded(node)\n    const hasChildren = !!node.children?.length\n    const cardClass = cn(\n      'group relative flex w-52 cursor-pointer flex-col rounded-lg border p-3 shadow-xs transition-colors',\n      'border-border bg-card hover:bg-accent/50 focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none',\n      isRoot && 'ring-2 ring-primary/20',\n    )\n    const cardLabel = node.title ? `${node.name}, ${node.title}` : node.name\n    return html`<div\n      role=\"button\"\n      tabindex=\"0\"\n      aria-label=${cardLabel}\n      class=${cardClass}\n      @click=${() => this.dispatchEvent(new CustomEvent('node-click', { detail: node, bubbles: true, composed: true }))}\n      @keydown=${(e: KeyboardEvent) => {\n        if (e.key === 'Enter' || e.key === ' ') {\n          e.preventDefault()\n          this.dispatchEvent(new CustomEvent('node-click', { detail: node, bubbles: true, composed: true }))\n        }\n      }}\n    >\n      <div class=\"flex items-center gap-2.5\">\n        ${node.avatar\n          ? html`<img src=${node.avatar} alt=${node.name} class=\"border-border size-10 shrink-0 rounded-full border object-cover\" />`\n          : html`<div\n              class=\"bg-primary/10 text-primary flex size-10 shrink-0 items-center justify-center rounded-full text-xs font-semibold\"\n              aria-hidden=\"true\"\n            >\n              ${initials(node.name)}\n            </div>`}\n        <div class=\"min-w-0 flex-1\">\n          <p class=\"truncate text-sm font-semibold\">${node.name}</p>\n          ${node.title ? html`<p class=\"text-muted-foreground truncate text-xs\">${node.title}</p>` : null}\n        </div>\n        ${hasChildren\n          ? html`<button\n              type=\"button\"\n              class=\"text-muted-foreground hover:text-foreground hover:bg-accent inline-flex size-5 shrink-0 items-center justify-center rounded\"\n              aria-expanded=${String(open)}\n              aria-label=${open ? 'Collapse' : 'Expand'}\n              @click=${(e: Event) => {\n                e.stopPropagation()\n                this.toggleNode(node)\n              }}\n            >\n              ${open ? icon(ChevronDown, 'chevron-down', 'size-3.5') : icon(ChevronRight, 'chevron-right', 'size-3.5')}\n            </button>`\n          : null}\n      </div>\n      ${this.renderNode?.(node)}\n    </div>`\n  }\n\n  private orgNode(node: OrgNode, depth: number, isRoot: boolean): unknown {\n    const open = this.isExpanded(node)\n    const hasChildren = !!node.children?.length\n    const isHorizontal = this.direction === 'left-right'\n    const childCount = node.children?.length ?? 0\n    const isOnlyChild = childCount <= 1\n\n    if (!isHorizontal) {\n      return html`<div class=\"org-v\" data-root=${isRoot ? '' : null}>\n        <div class=\"org-v-card\">${this.nodeCard(node, isRoot)}</div>\n        ${hasChildren && open\n          ? html`<div class=\"org-v-children\">\n              ${this.showConnectors ? html`<div class=\"org-v-line-down\"></div>` : null}\n              <div class=\"org-v-children-row\" data-single=${isOnlyChild ? '' : null}>\n                ${this.showConnectors && !isOnlyChild ? html`<div class=\"org-v-line-across\"></div>` : null}\n                ${(node.children ?? []).map((child) => this.orgNode(child, depth + 1, false))}\n              </div>\n            </div>`\n          : null}\n      </div>`\n    }\n\n    return html`<div class=\"org-h\" data-root=${isRoot ? '' : null}>\n      <div class=\"flex items-start\">\n        <div class=\"org-h-card\">${this.nodeCard(node, isRoot)}</div>\n        ${hasChildren && open\n          ? html`${this.showConnectors ? html`<div class=\"org-h-line-right\"></div>` : null}\n              <div class=\"org-h-children\">\n                ${(node.children ?? []).map((child) => this.orgNode(child, depth + 1, false))}\n              </div>`\n          : null}\n      </div>\n    </div>`\n  }\n\n  render() {\n    if (!this.data) return html``\n    return html`<div part=\"base\" data-direction=${this.direction} class=${cn(organizationChartVariants())}>\n      ${this.zoomable\n        ? html`<div class=\"border-border flex items-center gap-2 border-b px-3 py-2\">\n            <button\n              type=\"button\"\n              class=\"text-muted-foreground hover:text-foreground hover:bg-accent inline-flex size-7 items-center justify-center rounded-md text-sm\"\n              aria-label=\"Zoom out\"\n              @click=${this.zoomOut}\n            >\n              −\n            </button>\n            <span class=\"text-muted-foreground w-12 text-center text-xs tabular-nums\">${Math.round(this.zoom * 100)}%</span>\n            <button\n              type=\"button\"\n              class=\"text-muted-foreground hover:text-foreground hover:bg-accent inline-flex size-7 items-center justify-center rounded-md text-sm\"\n              aria-label=\"Zoom in\"\n              @click=${this.zoomIn}\n            >\n              +\n            </button>\n            <button\n              type=\"button\"\n              class=\"text-muted-foreground hover:text-foreground hover:bg-accent ml-1 rounded-md px-2 py-1 text-xs\"\n              aria-label=\"Reset zoom\"\n              @click=${this.resetZoom}\n            >\n              Reset\n            </button>\n            <div class=\"ml-auto flex gap-1\">\n              <button\n                type=\"button\"\n                class=\"text-muted-foreground hover:text-foreground hover:bg-accent rounded-md px-2 py-1 text-xs\"\n                aria-label=\"Expand all\"\n                @click=${this.expandAll}\n              >\n                Expand all\n              </button>\n              <button\n                type=\"button\"\n                class=\"text-muted-foreground hover:text-foreground hover:bg-accent rounded-md px-2 py-1 text-xs\"\n                aria-label=\"Collapse all\"\n                @click=${this.collapseAll}\n              >\n                Collapse all\n              </button>\n            </div>\n          </div>`\n        : null}\n      <div class=\"overflow-auto p-4\">\n        <div\n          style=${styleMap({ transform: `scale(${this.zoom})`, transformOrigin: 'top center' })}\n          class=\"transition-transform duration-200\"\n        >\n          ${this.orgNode(this.data, 0, true)}\n        </div>\n      </div>\n    </div>`\n  }\n}\n\ncustomElements.get('uip-organization-chart') || customElements.define('uip-organization-chart', UipOrganizationChart)\n\ndeclare global {\n  interface HTMLElementTagNameMap {\n    'uip-organization-chart': UipOrganizationChart\n  }\n}\n",
      "type": "registry:file",
      "target": "src/uip/components/charts/organization-chart.ts"
    },
    {
      "path": "packages/elements-lit/src/components/charts/lib/chart-element.ts",
      "content": "import { LitElement, css, html, type PropertyDeclarations, type PropertyValues } from 'lit'\nimport { styleMap } from 'lit/directives/style-map.js'\nimport type { ECharts } from 'echarts/core'\nimport { tailwind } from '../../../lib/styles'\nimport { ThemeController } from '../../../lib/theme'\nimport { heightToStyle, resolveChartTheme, subscribeChartTheme, type ChartTheme } from './chart-theme'\n\n/**\n * Attribute converter for booleans whose React default is `true`\n * (`showLabels`, `autoresize`): Lit's `type: Boolean` can't be switched off\n * from markup, so `show-labels=\"false\"` turns it off and anything else\n * (including removing the attribute) means true.\n */\nexport const defaultTrue = {\n  fromAttribute: (v: string | null) => v !== 'false',\n  toAttribute: (v: boolean) => (v ? '' : 'false'),\n}\n\n/**\n * `yField=\"value\"` from markup, `yField=['north', 'south']` from markup as a\n * JSON array or from JS as a property.\n */\nexport const stringOrArray = {\n  fromAttribute: (v: string | null) => (v?.trim().startsWith('[') ? (JSON.parse(v) as string[]) : v),\n}\n\n/**\n * Shared base for every ECharts-backed element — the Lit stand-in for React's\n * `ChartFrame` + `EChart` + `useChartTheme()`:\n *\n *  - renders React's ChartFrame chrome (role=\"img\", tabindex, focus ring,\n *    `height`) with a full-size inner container for the canvas;\n *  - resolves the chart theme from the CSS tokens and re-resolves it (and\n *    re-sets the option) whenever <html> class/style/data-theme changes;\n *  - lazily `import()`s echarts in firstUpdated (SSR-safe: nothing runs on the\n *    server), resizes with a ResizeObserver and disposes on disconnect;\n *  - applies `buildOption()` with `{ notMerge: true, lazyUpdate: true }`,\n *    exactly like React's EChart.\n *\n * Subclasses implement `buildOption()` (React's `mergedOption` useMemo) and\n * set `chartSlot` (the host's data-slot). `instance` exposes the ECharts\n * instance (undefined until initialised) for getOption()/dispatchAction().\n */\nexport abstract class ChartElement extends LitElement {\n  // :host display can't be a utility class (the host has no template of its own).\n  static styles = [tailwind, css`:host { display: block; }`]\n\n  static properties: PropertyDeclarations = {\n    height: {},\n    // role=\"img\" lives on the inner frame, so the host's aria-label is forwarded.\n    accessibleLabel: { attribute: 'aria-label' },\n    chartTheme: { state: true },\n  }\n\n  height: number | string = 300\n  accessibleLabel?: string\n  protected chartTheme: ChartTheme = resolveChartTheme()\n  /** Resize with the container. Only RawChart exposes it as a property. */\n  protected autoresize = true\n\n  protected abstract readonly chartSlot: string\n  protected abstract buildOption(): any\n\n  private chart?: ECharts\n  private resizeObserver?: ResizeObserver\n  private unsubscribeTheme?: () => void\n\n  constructor() {\n    super()\n    new ThemeController(this)\n  }\n\n  /** The ECharts instance, once initialised in the browser. */\n  get instance(): ECharts | undefined {\n    return this.chart\n  }\n\n  connectedCallback() {\n    super.connectedCallback()\n    this.setAttribute('data-uipkge', '')\n    this.setAttribute('data-slot', this.chartSlot)\n    this.chartTheme = resolveChartTheme()\n    this.unsubscribeTheme = subscribeChartTheme(() => {\n      this.chartTheme = resolveChartTheme()\n    })\n    // Re-attached after a move: firstUpdated won't run again.\n    if (this.hasUpdated) void this.initChart()\n  }\n\n  disconnectedCallback() {\n    super.disconnectedCallback()\n    this.unsubscribeTheme?.()\n    this.resizeObserver?.disconnect()\n    this.resizeObserver = undefined\n    this.chart?.dispose()\n    this.chart = undefined\n  }\n\n  protected firstUpdated() {\n    void this.initChart()\n  }\n\n  protected updated(changed: PropertyValues) {\n    if (!this.chart) return\n    if (changed.has('autoresize')) this.observeResize()\n    this.chart.setOption(this.buildOption(), { notMerge: true, lazyUpdate: true })\n  }\n\n  private get container() {\n    return this.renderRoot.querySelector<HTMLDivElement>('[data-chart]')\n  }\n\n  private async initChart() {\n    const { echarts } = await import('./echarts')\n    const el = this.container\n    if (!this.isConnected || this.chart || !el) return\n    this.chart = echarts.init(el)\n    this.chart.setOption(this.buildOption(), { notMerge: true, lazyUpdate: true })\n    this.observeResize()\n  }\n\n  private observeResize() {\n    this.resizeObserver?.disconnect()\n    this.resizeObserver = undefined\n    const el = this.container\n    if (!this.autoresize || !el) return\n    this.resizeObserver = new ResizeObserver(() => this.chart?.resize())\n    this.resizeObserver.observe(el)\n  }\n\n  render() {\n    return html`<div\n      part=\"base\"\n      role=\"img\"\n      aria-label=${this.accessibleLabel || 'Chart'}\n      tabindex=\"0\"\n      style=${styleMap({ height: heightToStyle(this.height) })}\n      class=\"focus-visible:ring-ring w-full focus-visible:ring-2 focus-visible:outline-none\"\n    >\n      <div data-chart class=\"h-full w-full\"></div>\n    </div>`\n  }\n}\n",
      "type": "registry:file",
      "target": "src/uip/components/charts/lib/chart-element.ts"
    },
    {
      "path": "packages/elements-lit/src/components/charts/lib/chart-theme.ts",
      "content": "import { isServer } from 'lit'\n\n// Port of packages/registry-react/components/charts/useChartTheme.ts.\n//\n// The chart palette is driven by the design tokens (`--chart-1`..`--chart-5`,\n// `--muted-foreground`, `--border`, `--popover`, …). They are resolved with\n// getComputedStyle on <html> and re-resolved whenever <html> class / style /\n// data-theme changes, so a light/dark flip re-colours every chart. Instead of\n// React's useChartTheme() hook, elements call subscribeChartTheme().\n\nconst listeners = new Set<() => void>()\nlet observing = false\n\nfunction bump() {\n  listeners.forEach((l) => l())\n}\n\n/** Call `cb` whenever the page theme changes. Returns the unsubscribe fn. */\nexport function subscribeChartTheme(cb: () => void): () => void {\n  listeners.add(cb)\n  if (!observing && !isServer) {\n    observing = true\n    // Same as React: one bump on the first frame (tokens resolved after the\n    // stylesheet applies), then on every <html> class/style/data-theme change.\n    requestAnimationFrame(bump)\n    new MutationObserver(bump).observe(document.documentElement, {\n      attributes: true,\n      attributeFilter: ['class', 'style', 'data-theme'],\n    })\n  }\n  return () => listeners.delete(cb)\n}\n\n// ECharts' canvas renderer does not accept OKLCH in every browser. Assigning\n// one of our Tailwind tokens to `fillStyle` can silently leave the sentinel\n// colour in place, turning a whole chart black. Convert OKLCH ourselves and\n// let the canvas normalize older CSS colour formats.\nlet _hexCanvas: CanvasRenderingContext2D | null = null\n\nexport function toCanvasColor(cssColor: string): string {\n  const value = cssColor.trim()\n  const match = value.match(\n    /^oklch\\(\\s*([+-]?(?:\\d+\\.?\\d*|\\.\\d+))(%?)\\s+([+-]?(?:\\d+\\.?\\d*|\\.\\d+))\\s+([+-]?(?:\\d+\\.?\\d*|\\.\\d+))(?:deg)?(?:\\s*\\/\\s*([+-]?(?:\\d+\\.?\\d*|\\.\\d+))(%?))?\\s*\\)$/i,\n  )\n\n  if (match) {\n    const lightness = Number(match[1]) / (match[2] === '%' ? 100 : 1)\n    const chroma = Number(match[3])\n    const hue = (Number(match[4]) * Math.PI) / 180\n    const alpha = match[5] == null ? 1 : Number(match[5]) / (match[6] === '%' ? 100 : 1)\n    const a = chroma * Math.cos(hue)\n    const b = chroma * Math.sin(hue)\n\n    const l = Math.pow(lightness + 0.3963377774 * a + 0.2158037573 * b, 3)\n    const m = Math.pow(lightness - 0.1055613458 * a - 0.0638541728 * b, 3)\n    const s = Math.pow(lightness - 0.0894841775 * a - 1.291485548 * b, 3)\n    const linear = [\n      4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n      -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n      -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,\n    ]\n    const rgb = linear.map((channel) => {\n      const encoded = channel <= 0.0031308 ? 12.92 * channel : 1.055 * Math.pow(channel, 1 / 2.4) - 0.055\n      return Math.round(Math.min(1, Math.max(0, encoded)) * 255)\n    })\n\n    return alpha < 1 ? `rgba(${rgb.join(', ')}, ${alpha})` : `rgb(${rgb.join(', ')})`\n  }\n\n  if (isServer) return cssColor\n  if (!_hexCanvas) {\n    _hexCanvas = document.createElement('canvas').getContext('2d')\n  }\n  if (!_hexCanvas) return cssColor\n  _hexCanvas.fillStyle = '#010203'\n  _hexCanvas.fillStyle = value\n  const normalized = _hexCanvas.fillStyle as string\n  return normalized === '#010203' && value.toLowerCase() !== '#010203' ? value : normalized\n}\n\n// Convert any CSS color (hex, rgb, oklch, color()) + alpha 0..1 to a\n// canvas-safe rgba(r,g,b,a).\nexport function toRgba(cssColor: string, alpha: number): string {\n  const normalized = toCanvasColor(cssColor)\n  if (normalized.startsWith('#') && normalized.length === 7) {\n    const r = parseInt(normalized.slice(1, 3), 16)\n    const g = parseInt(normalized.slice(3, 5), 16)\n    const b = parseInt(normalized.slice(5, 7), 16)\n    return `rgba(${r},${g},${b},${alpha})`\n  }\n  if (normalized.startsWith('rgba(')) {\n    return normalized.replace(/,\\s*[\\d.]+\\s*\\)$/, `,${alpha})`)\n  }\n  if (normalized.startsWith('rgb(')) {\n    return normalized.replace(/^rgb\\(/, 'rgba(').replace(/\\)$/, `,${alpha})`)\n  }\n  return cssColor\n}\n\nexport function resolveVar(name: string, fallback: string): string {\n  if (isServer) return fallback\n  const v = getComputedStyle(document.documentElement).getPropertyValue(name).trim()\n  if (!v) return fallback\n  return toCanvasColor(v)\n}\n\n// SSR / pre-hydration fallback palette (same values as React).\nconst CHART_FALLBACK = ['#f59e0b', '#14b8a6', '#3b82f6', '#f97316', '#eab308']\n\n/** The resolved chart theme tokens. All values are canvas-safe hex/rgba. */\nexport interface ChartTheme {\n  colors: string[]\n  textColor: string\n  axisColor: string\n  splitLineColor: string\n  tooltipBg: string\n  tooltipBorder: string\n  tooltipText: string\n  bgColor: string\n  accentColor: string\n  dangerColor: string\n  /** `--card`: cell borders and inside-label text, so they read as gaps /\n   *  contrast on light and dark surfaces (never '#fff'). */\n  surfaceColor: string\n  /** `--foreground`: primary numbers drawn on the canvas (gauge value). */\n  foregroundColor: string\n  /** Gauge stoplight from the status tokens, same rule as <uip-usage-bar>:\n   *  < 70% success, 70-89% warning, >= 90% destructive. */\n  semanticGaugeThresholds: [number, string][]\n}\n\nexport function resolveChartTheme(): ChartTheme {\n  return {\n    colors: Array.from({ length: 5 }, (_, i) => resolveVar(`--chart-${i + 1}`, CHART_FALLBACK[i]!)),\n    textColor: resolveVar('--muted-foreground', '#888888'),\n    axisColor: resolveVar('--border', '#e5e5e5'),\n    splitLineColor: resolveVar('--border', '#f0f0f0'),\n    tooltipBg: resolveVar('--popover', 'rgba(255,255,255,0.96)'),\n    tooltipBorder: resolveVar('--border', '#e5e5e5'),\n    tooltipText: resolveVar('--popover-foreground', '#333333'),\n    bgColor: resolveVar('--card', resolveVar('--background', '#ffffff')),\n    accentColor: resolveVar('--primary', '#38bdf8'),\n    dangerColor: resolveVar('--destructive', '#dc2626'),\n    surfaceColor: resolveVar('--card', '#ffffff'),\n    foregroundColor: resolveVar('--foreground', '#171717'),\n    semanticGaugeThresholds: [\n      [0.7, resolveVar('--success', '#14b8a6')],\n      [0.9, resolveVar('--warning', '#f59e0b')],\n      [1, resolveVar('--destructive', '#dc2626')],\n    ],\n  }\n}\n\n// Two-level deep merge for ECharts option blocks (verbatim from React): top-level\n// keys merge shallowly, and one nested level (axisLabel, splitLine, …) merges\n// shallowly too. Arrays + primitives replace outright — including a whole\n// block given as an array (e.g. `xAxis: [a, b]` for two axes).\nexport function mergeOptionBlock<T extends Record<string, any>>(base: T, user: Partial<T> | undefined): T {\n  if (!user) return base\n  if (Array.isArray(user)) return user as unknown as T\n  const out: any = { ...base }\n  for (const k of Object.keys(user)) {\n    const bv = (base as any)[k]\n    const uv = (user as any)[k]\n    if (\n      bv != null &&\n      uv != null &&\n      typeof bv === 'object' &&\n      typeof uv === 'object' &&\n      !Array.isArray(bv) &&\n      !Array.isArray(uv)\n    ) {\n      out[k] = { ...bv, ...uv }\n    } else {\n      out[k] = uv\n    }\n  }\n  return out\n}\n\n/** `height` prop → CSS: bare digits are px, anything else is raw CSS. */\nexport function heightToStyle(height: number | string): string {\n  return /^\\d+$/.test(String(height)) ? `${height}px` : String(height)\n}\n",
      "type": "registry:file",
      "target": "src/uip/components/charts/lib/chart-theme.ts"
    },
    {
      "path": "packages/elements-lit/src/components/charts/lib/echarts.ts",
      "content": "// ECharts core with every chart type / component the React wrappers register\n// (same list as packages/registry-react/components/charts/shared.tsx), so\n// <uip-raw-chart> can render any of them. Only ever loaded with a dynamic\n// import() from ChartElement.firstUpdated — never at module scope — so the\n// elements stay SSR-safe and echarts stays out of the initial bundle.\n// (Lives in charts/lib/ so src/index.ts's components/*/*.ts glob skips it.)\nimport * as echarts from 'echarts/core'\nimport { CanvasRenderer } from 'echarts/renderers'\nimport {\n  LineChart,\n  BarChart,\n  PieChart,\n  ScatterChart,\n  EffectScatterChart,\n  PictorialBarChart,\n  RadarChart,\n  GaugeChart,\n  HeatmapChart,\n  TreemapChart,\n  FunnelChart,\n  BoxplotChart,\n  CandlestickChart,\n  CustomChart,\n  ChordChart,\n  MapChart,\n  GraphChart,\n  ParallelChart,\n  SankeyChart,\n  SunburstChart,\n  ThemeRiverChart,\n  TreeChart,\n} from 'echarts/charts'\nimport {\n  GridComponent,\n  PolarComponent,\n  TooltipComponent,\n  LegendComponent,\n  MarkLineComponent,\n  MarkAreaComponent,\n  MarkPointComponent,\n  GraphicComponent,\n  RadarComponent,\n  VisualMapComponent,\n  CalendarComponent,\n  DataZoomComponent,\n  ParallelComponent,\n  SingleAxisComponent,\n  TitleComponent,\n} from 'echarts/components'\n\necharts.use([\n  CanvasRenderer,\n  LineChart,\n  BarChart,\n  PieChart,\n  ScatterChart,\n  EffectScatterChart,\n  PictorialBarChart,\n  RadarChart,\n  GaugeChart,\n  HeatmapChart,\n  TreemapChart,\n  FunnelChart,\n  BoxplotChart,\n  CandlestickChart,\n  CustomChart,\n  ChordChart,\n  MapChart,\n  GraphChart,\n  ParallelChart,\n  SankeyChart,\n  SunburstChart,\n  ThemeRiverChart,\n  TreeChart,\n  GridComponent,\n  PolarComponent,\n  TooltipComponent,\n  LegendComponent,\n  MarkLineComponent,\n  MarkAreaComponent,\n  MarkPointComponent,\n  GraphicComponent,\n  RadarComponent,\n  VisualMapComponent,\n  CalendarComponent,\n  DataZoomComponent,\n  ParallelComponent,\n  SingleAxisComponent,\n  TitleComponent,\n])\n\nexport { echarts }\n",
      "type": "registry:file",
      "target": "src/uip/components/charts/lib/echarts.ts"
    }
  ],
  "dependencies": [
    "class-variance-authority",
    "echarts",
    "lit",
    "lucide"
  ],
  "registryDependencies": [
    "https://uipkge.dev/r/lit/lit-core.json"
  ]
}
