{
  "name": "icon",
  "type": "ui:component",
  "title": "Icon (Lucide)",
  "description": "Zero-overhead Slot-Compiled SVG renderer for tree-shakeable `@lucide/icons` (and legacy `lucide` / `@lucide/lab` nodes) across Client, Shadow DOM, and SSR.",
  "dependencies": [
    "@lucide/icons"
  ],
  "registryDependencies": [
    "theme"
  ],
  "files": [
    {
      "path": "src/ui/icon.tsx",
      "target": "src/ui/icon.tsx",
      "sha256": "6a66cd8fe616301c9cdc9193d5463294eea98f8cc31a2b442a127fdf76be4944",
      "content": "import './theme.css';\nimport { _tpl, _slot, scope, type CompiledTemplate, type SlotView } from '@fierst/aster';\n\n/** Standard Lucide child element tuple (`['path', { d: '...' }]`). */\nexport type LucideIconNode = readonly [\n  tag: string,\n  attrs: Readonly<Record<string, string | number | undefined>>,\n  children?: readonly LucideIconNode[],\n];\n\n/** Standard `@lucide/icons` v1.x tree-shakeable icon data object. */\nexport interface LucideIconData {\n  readonly name?: string;\n  readonly node: readonly LucideIconNode[];\n  readonly aliases?: readonly string[];\n  readonly size?: number;\n  readonly width?: number;\n  readonly height?: number;\n}\n\n/** Accepts either `@lucide/icons` `LucideIconData` or legacy `lucide` / `@lucide/lab` `LucideIconNode[]`. */\nexport type LucideIconInput = LucideIconData | readonly LucideIconNode[];\n\nconst iconScope = scope`\n  :scope {\n    display: inline-block;\n    vertical-align: middle;\n    flex-shrink: 0;\n  }\n  :scope.is-spin {\n    animation: aster-icon-spin 0.8s linear infinite;\n  }\n  @keyframes aster-icon-spin {\n    to { transform: rotate(360deg); }\n  }\n`;\n\nconst ALLOWED_SVG_TAGS = new Set([\n  'path',\n  'circle',\n  'rect',\n  'line',\n  'polyline',\n  'polygon',\n  'ellipse',\n]);\n\nfunction escapeAttr(val: string | number): string {\n  return String(val)\n    .replaceAll('&', '&amp;')\n    .replaceAll('\"', '&quot;')\n    .replaceAll('<', '&lt;')\n    .replaceAll('>', '&gt;');\n}\n\nfunction renderIconNodes(nodes: readonly LucideIconNode[]): string {\n  let out = '';\n  for (const [tag, attrs, children] of nodes) {\n    if (!ALLOWED_SVG_TAGS.has(tag)) continue;\n    let attrStr = '';\n    for (const [k, v] of Object.entries(attrs)) {\n      if (v === undefined || k === 'key' || !/^[a-zA-Z][\\w.-]*$/.test(k) || /^on/i.test(k))\n        continue;\n      attrStr += ` ${k}=\"${escapeAttr(v)}\"`;\n    }\n    const inner = children && children.length > 0 ? renderIconNodes(children) : '';\n    out += `<${tag}${attrStr}>${inner}</${tag}>`;\n  }\n  return out;\n}\n\nconst templateCache = new WeakMap<object, CompiledTemplate>();\n\nfunction getIconTemplate(input: LucideIconInput): CompiledTemplate {\n  let cached = templateCache.get(input as object);\n  if (cached) return cached;\n\n  const isDataObj = !Array.isArray(input);\n  const nodes: readonly LucideIconNode[] = isDataObj ? (input as LucideIconData).node : input;\n  const vbW = isDataObj\n    ? ((input as LucideIconData).width ?? (input as LucideIconData).size ?? 24)\n    : 24;\n  const vbH = isDataObj\n    ? ((input as LucideIconData).height ?? (input as LucideIconData).size ?? 24)\n    : 24;\n\n  const inner = renderIconNodes(nodes);\n\n  const html =\n    `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${escapeAttr(vbW)} ${escapeAttr(vbH)}\" ` +\n    `fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" ` +\n    `data-aster-a0=\"\">${inner}</svg>`;\n\n  cached = _tpl(html, [{ kind: 'spread', path: [0] }]);\n  templateCache.set(input as object, cached);\n  return cached;\n}\n\nexport interface IconProps {\n  /** Tree-shaken icon imported from `@lucide/icons` (or a `LucideIconNode[]` tuple array). */\n  icon: LucideIconInput;\n  /** Icon width & height in px or CSS length (default: 18). */\n  size?: number | string;\n  /** SVG stroke width (default: 1.75 for AsterUI optical balance). */\n  strokeWidth?: number;\n  /** Scale stroke width inversely with `size` so lines stay visually consistent at any scale. */\n  absoluteStrokeWidth?: boolean;\n  /** Override stroke color (defaults to `currentColor`). */\n  color?: string;\n  /** Animate continuous rotation (ideal for `LoaderCircle`). */\n  spin?: boolean;\n  /** Accessible label. When omitted, the icon is treated as decorative (`aria-hidden=\"true\"`). */\n  label?: string;\n  class?: string;\n  [key: string]: any;\n}\n\n/**\n * AsterUI Lucide Icon component — zero-runtime-overhead Slot-Compiled SVG.\n * Works identically in Client DOM, Shadow DOM Web Components, and SSR.\n *\n * @example\n *   import { Search } from '@lucide/icons';\n *   <Icon icon={Search} size={16} />\n */\nexport function Icon({\n  icon,\n  size = 18,\n  strokeWidth = 1.75,\n  absoluteStrokeWidth = false,\n  color,\n  spin = false,\n  label,\n  class: extraClass,\n  ...rest\n}: IconProps): SlotView {\n  const tpl = getIconTemplate(icon);\n  const iconName = !Array.isArray(icon) ? (icon as LucideIconData).name : undefined;\n  const numericSize = typeof size === 'number' ? size : Number.parseFloat(size) || 24;\n  const computedStroke = absoluteStrokeWidth ? (strokeWidth * 24) / numericSize : strokeWidth;\n\n  const hasLabel = Boolean(label || rest['aria-label']);\n  const cls = [\n    iconScope,\n    'lucide',\n    iconName ? `lucide-${iconName}` : '',\n    spin ? 'is-spin' : '',\n    extraClass,\n  ]\n    .filter(Boolean)\n    .join(' ');\n\n  const svgAttrs: Record<string, any> = {\n    ...rest,\n    width: size,\n    height: size,\n    'stroke-width': computedStroke,\n    class: cls,\n  };\n\n  if (color) svgAttrs.stroke = color;\n  if (hasLabel) {\n    svgAttrs.role = rest.role ?? 'img';\n    if (label) svgAttrs['aria-label'] = label;\n  } else {\n    svgAttrs['aria-hidden'] = true;\n    svgAttrs.focusable = 'false';\n  }\n\n  return _slot(tpl, [svgAttrs]);\n}\n\n/** Create a dedicated stateless icon component from any `@lucide/icons` export. */\nexport function createIcon(\n  icon: LucideIconInput,\n  defaults: Omit<IconProps, 'icon'> = {},\n): (props?: Omit<IconProps, 'icon'>) => SlotView {\n  return (props = {}) => Icon({ ...defaults, ...props, icon });\n}\n"
    }
  ]
}
