{
  "name": "tooltip",
  "type": "ui:component",
  "title": "Tooltip",
  "description": "High-contrast inverted hover/focus Tooltip with configurable delay, alignment, Escape dismiss, and try/finally timer cleanup.",
  "dependencies": [],
  "registryDependencies": [
    "theme"
  ],
  "files": [
    {
      "path": "src/ui/tooltip.tsx",
      "target": "src/ui/tooltip.tsx",
      "sha256": "a82e0e63e4d26c0b5a80840aec13f237d822e2bfdcfd1f34205d5323ac3c944d",
      "content": "import './theme.css';\nimport { scope, type Ctx, type View } from '@fierst/aster';\n\nconst tipScope = scope`\n  :scope {\n    position: relative;\n    display: inline-flex;\n    align-items: center;\n  }\n  .tip-bubble {\n    position: absolute;\n    z-index: 50;\n    left: 50%;\n    bottom: calc(100% + 6px);\n    transform: translateX(-50%) translateY(3px) scale(0.97);\n    opacity: 0;\n    pointer-events: none;\n    width: max-content;\n    max-width: min(260px, calc(100vw - 2rem));\n    text-align: center;\n    padding: 0.32rem 0.62rem;\n    border-radius: var(--aster-radius-sm);\n    background: var(--aster-inverted-bg);\n    color: var(--aster-inverted-fg);\n    box-shadow: var(--aster-shadow-md);\n    font-family: var(--aster-font-sans);\n    font-size: 0.75rem;\n    font-weight: 500;\n    transition:\n      opacity var(--aster-dur-fast) var(--aster-ease-standard),\n      transform var(--aster-dur-fast) var(--aster-ease-motion);\n  }\n  .tip-bubble.align-start { left: 0; transform: translateY(3px) scale(0.97); }\n  .tip-bubble.align-end { left: auto; right: 0; transform: translateY(3px) scale(0.97); }\n  .tip-bubble.side-bottom { bottom: auto; top: calc(100% + 6px); transform: translateX(-50%) translateY(-3px) scale(0.97); }\n  .tip-bubble.side-bottom.align-start { transform: translateY(-3px) scale(0.97); }\n  .tip-bubble.side-bottom.align-end { transform: translateY(-3px) scale(0.97); }\n  .tip-bubble.is-open { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }\n  .tip-bubble.align-start.is-open,\n  .tip-bubble.align-end.is-open { transform: translateY(0) scale(1); }\n  @media (hover: none) { .tip-bubble { display: none; } }\n`;\n\nlet tipSeq = 0;\n\nexport function* Tooltip(\n  props: {\n    content: string;\n    side?: 'top' | 'bottom';\n    align?: 'center' | 'start' | 'end';\n    delay?: number;\n    class?: string;\n    children?: View;\n  },\n  ctx: Ctx,\n) {\n  const tipId = `aster-tip-${++tipSeq}`;\n  let open = false;\n  let timer: ReturnType<typeof setTimeout> | null = null;\n\n  const clearTimer = () => {\n    if (timer) {\n      clearTimeout(timer);\n      timer = null;\n    }\n  };\n\n  const show = (e?: Event) => {\n    if ((e as PointerEvent)?.pointerType === 'touch') return;\n    clearTimer();\n    const wait = props.delay ?? 160;\n    if (wait <= 0) {\n      open = true;\n      ctx.refresh();\n      return;\n    }\n    timer = setTimeout(() => {\n      open = true;\n      ctx.refresh();\n    }, wait);\n  };\n\n  const hide = () => {\n    clearTimer();\n    if (open) {\n      open = false;\n      ctx.refresh();\n    }\n  };\n\n  try {\n    for (props of ctx) {\n      const alignCls =\n        props.align === 'start' ? 'align-start' : props.align === 'end' ? 'align-end' : '';\n      yield (\n        <span\n          class={[tipScope, props.class].filter(Boolean).join(' ')}\n          aria-describedby={open ? tipId : undefined}\n          on:pointerenter={show}\n          on:pointerleave={hide}\n          on:focusin={show}\n          on:focusout={hide}\n          onKeyDown={(e: KeyboardEvent) => {\n            if (e.key === 'Escape') hide();\n          }}\n        >\n          {props.children}\n          <span\n            id={tipId}\n            role=\"tooltip\"\n            class={['tip-bubble', props.side === 'bottom' ? 'side-bottom' : '', alignCls]\n              .filter(Boolean)\n              .join(' ')}\n            class:is-open={open}\n          >\n            {props.content}\n          </span>\n        </span>\n      );\n    }\n  } finally {\n    clearTimer();\n  }\n}\n"
    }
  ]
}
