{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"dot-clock","type":"registry:component","title":"Dot Matrix Clock","description":"A dot-matrix clock widget: the place, the time with seconds and the date in glowing LED dots on a board of unlit dots. Changing digits light up in a quick sweep, the colon blinks, and any time zone names its own city.","dependencies":[],"files":[{"path":"registry/dot/dot-clock.tsx","type":"registry:component","target":"components/dot/dot-clock.tsx","content":"\"use client\";\n\nimport { useEffect, useRef, type CSSProperties } from \"react\";\n\nexport interface DotClockProps {\n  /** Shown above the time; empty uses the city from the time zone (e.g. \"Asia/Tokyo\" → TOKYO) */\n  place?: string;\n  /** IANA time zone, e.g. \"Europe/London\"; empty uses the visitor's own. Default Tokyo */\n  timeZone?: string;\n  /** 12-hour time with AM/PM instead of 24-hour */\n  hour12?: boolean;\n  /** Seconds after the minutes */\n  showSeconds?: boolean;\n  /** The colon blinks every second */\n  blink?: boolean;\n  /** Lit dots */\n  dotColor?: string;\n  /** A panel of dim, unlit dots behind the text, like an LED board */\n  showUnlit?: boolean;\n  /** Unlit dots; empty mixes the dot colour softly into the background */\n  unlitColor?: string;\n  background?: string;\n  borderColor?: string;\n  /** Corner radius of the widget, in px */\n  radius?: number;\n  dotShape?: \"round\" | \"square\";\n  /** A soft glow around lit dots */\n  glow?: boolean;\n  className?: string;\n  style?: CSSProperties;\n}\n\n// ─── A 5×7 dot font ───────────────────────────────────────────────────────────\n\nconst GLYPHS: Record<string, string[]> = {\n  A: [\" ### \", \"#   #\", \"#   #\", \"#####\", \"#   #\", \"#   #\", \"#   #\"],\n  B: [\"#### \", \"#   #\", \"#   #\", \"#### \", \"#   #\", \"#   #\", \"#### \"],\n  C: [\" ### \", \"#   #\", \"#    \", \"#    \", \"#    \", \"#   #\", \" ### \"],\n  D: [\"#### \", \"#   #\", \"#   #\", \"#   #\", \"#   #\", \"#   #\", \"#### \"],\n  E: [\"#####\", \"#    \", \"#    \", \"#### \", \"#    \", \"#    \", \"#####\"],\n  F: [\"#####\", \"#    \", \"#    \", \"#### \", \"#    \", \"#    \", \"#    \"],\n  G: [\" ### \", \"#   #\", \"#    \", \"# ###\", \"#   #\", \"#   #\", \" ####\"],\n  H: [\"#   #\", \"#   #\", \"#   #\", \"#####\", \"#   #\", \"#   #\", \"#   #\"],\n  I: [\" ### \", \"  #  \", \"  #  \", \"  #  \", \"  #  \", \"  #  \", \" ### \"],\n  J: [\"  ###\", \"   # \", \"   # \", \"   # \", \"   # \", \"#  # \", \" ##  \"],\n  K: [\"#   #\", \"#  # \", \"# #  \", \"##   \", \"# #  \", \"#  # \", \"#   #\"],\n  L: [\"#    \", \"#    \", \"#    \", \"#    \", \"#    \", \"#    \", \"#####\"],\n  M: [\"#   #\", \"## ##\", \"# # #\", \"# # #\", \"#   #\", \"#   #\", \"#   #\"],\n  N: [\"#   #\", \"#   #\", \"##  #\", \"# # #\", \"#  ##\", \"#   #\", \"#   #\"],\n  O: [\" ### \", \"#   #\", \"#   #\", \"#   #\", \"#   #\", \"#   #\", \" ### \"],\n  P: [\"#### \", \"#   #\", \"#   #\", \"#### \", \"#    \", \"#    \", \"#    \"],\n  Q: [\" ### \", \"#   #\", \"#   #\", \"#   #\", \"# # #\", \"#  # \", \" ## #\"],\n  R: [\"#### \", \"#   #\", \"#   #\", \"#### \", \"# #  \", \"#  # \", \"#   #\"],\n  S: [\" ####\", \"#    \", \"#    \", \" ### \", \"    #\", \"    #\", \"#### \"],\n  T: [\"#####\", \"  #  \", \"  #  \", \"  #  \", \"  #  \", \"  #  \", \"  #  \"],\n  U: [\"#   #\", \"#   #\", \"#   #\", \"#   #\", \"#   #\", \"#   #\", \" ### \"],\n  V: [\"#   #\", \"#   #\", \"#   #\", \"#   #\", \"#   #\", \" # # \", \"  #  \"],\n  W: [\"#   #\", \"#   #\", \"#   #\", \"# # #\", \"# # #\", \"# # #\", \" # # \"],\n  X: [\"#   #\", \"#   #\", \" # # \", \"  #  \", \" # # \", \"#   #\", \"#   #\"],\n  Y: [\"#   #\", \"#   #\", \" # # \", \"  #  \", \"  #  \", \"  #  \", \"  #  \"],\n  Z: [\"#####\", \"    #\", \"   # \", \"  #  \", \" #   \", \"#    \", \"#####\"],\n  \"0\": [\" ### \", \"#   #\", \"#   #\", \"#   #\", \"#   #\", \"#   #\", \" ### \"],\n  \"1\": [\"  #  \", \" ##  \", \"  #  \", \"  #  \", \"  #  \", \"  #  \", \" ### \"],\n  \"2\": [\" ### \", \"#   #\", \"    #\", \"   # \", \"  #  \", \" #   \", \"#####\"],\n  \"3\": [\"#####\", \"   # \", \"  #  \", \"   # \", \"    #\", \"#   #\", \" ### \"],\n  \"4\": [\"   # \", \"  ## \", \" # # \", \"#  # \", \"#####\", \"   # \", \"   # \"],\n  \"5\": [\"#####\", \"#    \", \"#### \", \"    #\", \"    #\", \"#   #\", \" ### \"],\n  \"6\": [\"  ## \", \" #   \", \"#    \", \"#### \", \"#   #\", \"#   #\", \" ### \"],\n  \"7\": [\"#####\", \"    #\", \"   # \", \"  #  \", \" #   \", \" #   \", \" #   \"],\n  \"8\": [\" ### \", \"#   #\", \"#   #\", \" ### \", \"#   #\", \"#   #\", \" ### \"],\n  \"9\": [\" ### \", \"#   #\", \"#   #\", \" ####\", \"    #\", \"   # \", \" ##  \"],\n  \":\": [\" \", \" \", \"#\", \" \", \"#\", \" \", \" \"],\n  \"-\": [\"   \", \"   \", \"   \", \"###\", \"   \", \"   \", \"   \"],\n  \"+\": [\"   \", \"   \", \" # \", \"###\", \" # \", \"   \", \"   \"],\n  \".\": [\" \", \" \", \" \", \" \", \" \", \" \", \"#\"],\n  \",\": [\" \", \" \", \" \", \" \", \" \", \"#\", \"#\"],\n  \"'\": [\"#\", \"#\", \" \", \" \", \" \", \" \", \" \"],\n  \"/\": [\"    #\", \"   # \", \"   # \", \"  #  \", \" #   \", \" #   \", \"#    \"],\n  \" \": [\"   \", \"   \", \"   \", \"   \", \"   \", \"   \", \"   \"],\n};\nconst GLYPH_H = 7;\n\n/** Uppercase, accents dropped (SÃO PAULO → SAO PAULO), anything the font lacks becomes a space */\nconst clean = (s: string) =>\n  s\n    .normalize(\"NFD\")\n    .replace(/[̀-ͯ]/g, \"\")\n    .toUpperCase()\n    .split(\"\")\n    .map((ch) => (GLYPHS[ch] ? ch : \" \"))\n    .join(\"\");\n\nconst textWidth = (s: string, scale: number) =>\n  s.split(\"\").reduce((w, ch, i) => w + (GLYPHS[ch][0].length + (i ? 1 : 0)) * scale, 0);\n\n/** Lights the dots of `text` into `grid` (cols wide), top-left at (x, y), each font pixel scale×scale dots */\nfunction stamp(grid: Uint8Array, cols: number, text: string, x: number, y: number, scale: number, line: number, lines: Uint8Array) {\n  let cx = x;\n  for (const ch of text) {\n    const g = GLYPHS[ch];\n    const w = g[0].length;\n    for (let r = 0; r < GLYPH_H; r++) {\n      for (let c = 0; c < w; c++) {\n        if (g[r][c] !== \"#\") continue;\n        for (let sy = 0; sy < scale; sy++) {\n          for (let sx = 0; sx < scale; sx++) {\n            const i = (y + r * scale + sy) * cols + cx + c * scale + sx;\n            grid[i] = 1;\n            lines[i] = line;\n          }\n        }\n      }\n    }\n    cx += (w + 1) * scale;\n  }\n}\n\n// ─── Colour ───────────────────────────────────────────────────────────────────\n\ntype RGB = [number, number, number];\nlet probe: CanvasRenderingContext2D | null = null;\nfunction toRgb(color: string | undefined, fallback: RGB): RGB {\n  const c = (color ?? \"\").trim();\n  const hex = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(c);\n  if (hex) {\n    let h = hex[1];\n    if (h.length === 3) h = h.split(\"\").map((x) => x + x).join(\"\");\n    const n = parseInt(h.slice(0, 6), 16);\n    return [(n >> 16) & 255, (n >> 8) & 255, n & 255];\n  }\n  if (!c || typeof document === \"undefined\") return fallback;\n  const cssVar = /^var\\(\\s*(--[\\w-]+)\\s*(?:,\\s*(.+))?\\)$/i.exec(c);\n  if (cssVar) {\n    const value = getComputedStyle(document.documentElement).getPropertyValue(cssVar[1]).trim();\n    return toRgb(value || cssVar[2], fallback);\n  }\n  probe ??= document.createElement(\"canvas\").getContext(\"2d\");\n  if (!probe) return fallback;\n  probe.fillStyle = \"#010203\";\n  probe.fillStyle = c;\n  const v = String(probe.fillStyle);\n  if (v === \"#010203\") return fallback;\n  if (v.startsWith(\"#\")) return toRgb(v, fallback);\n  const m = /rgba?\\(\\s*([\\d.]+)[,\\s]+([\\d.]+)[,\\s]+([\\d.]+)/i.exec(v);\n  return m ? [+m[1], +m[2], +m[3]] : fallback;\n}\nconst mix = (a: RGB, b: RGB, t: number): RGB => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t];\nconst rgb = (c: RGB, a = 1) => `rgba(${Math.round(c[0])}, ${Math.round(c[1])}, ${Math.round(c[2])}, ${a})`;\n\n// ─── Time ─────────────────────────────────────────────────────────────────────\n\n/** Browsers still report some zones by old city names */\nconst CITY_NAMES: Record<string, string> = {\n  Calcutta: \"Kolkata\",\n  Saigon: \"Ho Chi Minh\",\n  Kiev: \"Kyiv\",\n  Rangoon: \"Yangon\",\n  Katmandu: \"Kathmandu\",\n  \"Buenos Aires\": \"Buenos Aires\",\n};\n\ninterface Reading {\n  place: string;\n  corner: string;\n  time: string;\n  date: string;\n  /** Changes once a second; the colon blinks on the half second */\n  second: number;\n}\n\nfunction makeReader(timeZone: string, hour12: boolean, showSeconds: boolean, place: string) {\n  let zone: string | undefined = timeZone.trim() || undefined;\n  try {\n    new Intl.DateTimeFormat(\"en-US\", { timeZone: zone });\n  } catch {\n    zone = undefined;\n  }\n  const fmt = new Intl.DateTimeFormat(\"en-US\", {\n    timeZone: zone,\n    weekday: \"short\",\n    day: \"2-digit\",\n    month: \"short\",\n    year: \"numeric\",\n    hour: \"2-digit\",\n    minute: \"2-digit\",\n    second: \"2-digit\",\n    hourCycle: hour12 ? \"h12\" : \"h23\",\n  });\n  let offset: Intl.DateTimeFormat | null = null;\n  try {\n    offset = new Intl.DateTimeFormat(\"en-US\", { timeZone: zone, timeZoneName: \"shortOffset\" });\n  } catch {\n    offset = null;\n  }\n  const resolved = fmt.resolvedOptions().timeZone;\n  const raw = (resolved.split(\"/\").pop() ?? \"\").replace(/_/g, \" \");\n  const city = CITY_NAMES[raw] ?? raw;\n  const name = clean(place.trim() || city || \"LOCAL\");\n  return (now: Date): Reading => {\n    const p: Record<string, string> = {};\n    for (const part of fmt.formatToParts(now)) p[part.type] = part.value;\n    const hh = (p.hour ?? \"00\").padStart(2, \"0\");\n    const time = showSeconds ? `${hh}:${p.minute}:${p.second}` : `${hh}:${p.minute}`;\n    let corner = \"\";\n    if (hour12) corner = (p.dayPeriod ?? \"\").toUpperCase();\n    else if (offset) {\n      const z = offset.formatToParts(now).find((x) => x.type === \"timeZoneName\")?.value ?? \"\";\n      corner = z.replace(\"GMT\", \"UTC\");\n      if (corner === \"UTC\") corner = \"UTC+0\";\n    }\n    return {\n      place: name,\n      corner: clean(corner),\n      time,\n      date: clean(`${p.weekday} ${p.day} ${p.month} ${p.year}`),\n      second: Math.floor(now.getTime() / 1000),\n    };\n  };\n}\n\n/**\n * A dot-matrix clock widget: the place, the time with seconds and the date, drawn on a panel of LED\n * dots. Digits that change light up in a quick top-to-bottom sweep with a soft glow, the colon blinks,\n * and the panel lights up in a diagonal wave when it appears. Any time zone; the place name comes from\n * it unless you set your own. Drawn on a high-DPI canvas; pauses offscreen; with reduced motion the\n * digits change without the sweep.\n */\nexport function DotClock({\n  place = \"\",\n  timeZone = \"Asia/Tokyo\",\n  hour12 = false,\n  showSeconds = true,\n  blink = true,\n  dotColor = \"#FF7A1A\",\n  showUnlit = true,\n  unlitColor = \"\",\n  background = \"#0E0E10\",\n  borderColor = \"#1E1E22\",\n  radius = 0,\n  dotShape = \"round\",\n  glow = true,\n  className,\n  style,\n}: DotClockProps) {\n  const wrapRef = useRef<HTMLDivElement | null>(null);\n  const canvasRef = useRef<HTMLCanvasElement | null>(null);\n  const settings = useRef({ place, timeZone, hour12, showSeconds, blink, dotColor, showUnlit, unlitColor, background, dotShape, glow, radius });\n  useEffect(() => {\n    settings.current = { place, timeZone, hour12, showSeconds, blink, dotColor, showUnlit, unlitColor, background, dotShape, glow, radius };\n  });\n\n  useEffect(() => {\n    const wrap = wrapRef.current;\n    const canvas = canvasRef.current;\n    const ctx = canvas?.getContext(\"2d\");\n    if (!wrap || !canvas || !ctx) return;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n\n    // Panel layout, in dots\n    // Breathing room between the place, the time and the date\n    const PAD = 1;\n    const GAP = 6;\n    let cols = 0;\n    let rows = 0;\n    let target = new Uint8Array(0);\n    let shown = new Uint8Array(0);\n    let level = new Float32Array(0);\n    let startAt = new Float64Array(0);\n    let lineOf = new Uint8Array(0);\n    let jitter = new Float32Array(0);\n    let layoutKey = \"\";\n    let readKey = \"\";\n    let read = makeReader(\"\", false, true, \"\");\n    let lastSecond = -1;\n    let lastColon = true;\n    let born = performance.now();\n\n    // Drawing\n    let W = 0;\n    let H = 0;\n    let dpr = 1;\n    let pitch = 8;\n    let ox = 0;\n    let oy = 0;\n    let bg: HTMLCanvasElement | null = null;\n    let sprite: HTMLCanvasElement | null = null;\n    let colorKey = \"\";\n    let on: RGB = [255, 122, 26];\n\n    const relayout = (r: Reading) => {\n      const s = settings.current;\n      const timeW = textWidth(s.showSeconds ? \"00:00:00\" : \"00:00\", 2);\n      const dateW = textWidth(r.date, 1);\n      const topW = textWidth(r.place, 1) + (r.corner ? 4 + textWidth(r.corner, 1) : 0);\n      cols = PAD * 2 + Math.max(timeW, dateW, topW);\n      rows = PAD * 2 + GLYPH_H + GAP + GLYPH_H * 2 + GAP + GLYPH_H;\n      const n = cols * rows;\n      target = new Uint8Array(n);\n      shown = new Uint8Array(n);\n      level = new Float32Array(n);\n      startAt = new Float64Array(n);\n      lineOf = new Uint8Array(n);\n      jitter = Float32Array.from({ length: n }, () => Math.random());\n      born = performance.now();\n      lastSecond = -1;\n      sizeCanvas();\n    };\n\n    const compose = (r: Reading, colon: boolean) => {\n      target.fill(0);\n      const top = PAD;\n      stamp(target, cols, r.place, PAD, top, 1, 1, lineOf);\n      if (r.corner) stamp(target, cols, r.corner, cols - PAD - textWidth(r.corner, 1), top, 1, 1, lineOf);\n      const time = colon ? r.time : r.time.replace(/:/g, \" \");\n      // Keep the digits in place when the colon is off: a blank colon is as wide as a lit one\n      const timeY = top + GLYPH_H + GAP;\n      let x = PAD;\n      for (const ch of time) {\n        const glyph = ch === \" \" ? \":\" : ch;\n        if (ch !== \" \") stamp(target, cols, ch, x, timeY, 2, 2, lineOf);\n        x += (GLYPHS[glyph][0].length + 1) * 2;\n      }\n      stamp(target, cols, r.date, PAD, timeY + GLYPH_H * 2 + GAP, 1, 3, lineOf);\n    };\n\n    const sizeCanvas = () => {\n      const rect = canvas.getBoundingClientRect();\n      if (rect.width < 4 || rect.height < 4 || !cols) return;\n      dpr = window.devicePixelRatio || 1;\n      W = Math.round(rect.width * dpr);\n      H = Math.round(rect.height * dpr);\n      canvas.width = W;\n      canvas.height = H;\n      // The canvas covers the whole widget; the text sits inside this padding, on the same dot grid\n      const pad = Math.min(56, Math.max(22, rect.width * 0.09)) * dpr;\n      pitch = Math.min((W - pad * 2) / cols, (H - pad * 2) / rows);\n      ox = (W - pitch * cols) / 2;\n      oy = (H - pitch * rows) / 2;\n      colorKey = \"\";\n    };\n\n    const dot = (g: CanvasRenderingContext2D, x: number, y: number, size: number, square: boolean) => {\n      if (square) g.rect(x - size, y - size, size * 2, size * 2);\n      else {\n        g.moveTo(x + size, y);\n        g.arc(x, y, size, 0, Math.PI * 2);\n      }\n    };\n\n    // The unlit panel and the glow sprite are drawn once, then reused every frame\n    const paintStatic = () => {\n      const s = settings.current;\n      const back = toRgb(s.background, [14, 14, 16]);\n      on = toRgb(s.dotColor, [255, 122, 26]);\n      const off = s.unlitColor ? toRgb(s.unlitColor, mix(back, on, 0.1)) : mix(back, on, 0.1);\n      bg = document.createElement(\"canvas\");\n      bg.width = W;\n      bg.height = H;\n      const g = bg.getContext(\"2d\");\n      if (!g) return;\n      if (s.showUnlit) {\n        g.fillStyle = rgb(off);\n        g.beginPath();\n        const size = pitch * 0.34;\n        // The grid fills the whole background, but only with whole dots: none are cut by the edges\n        // or the rounded corners\n        const m = pitch * 0.5 + dpr * 2;\n        const cr = Math.max(0, s.radius * dpr);\n        const inside = (px: number, py: number) => {\n          if (px < m || py < m || px > W - m || py > H - m) return false;\n          const cx = px < cr ? cr : px > W - cr ? W - cr : px;\n          const cy = py < cr ? cr : py > H - cr ? H - cr : py;\n          return Math.hypot(px - cx, py - cy) <= cr - m || (cx === px || cy === py);\n        };\n        const x0 = -Math.ceil(ox / pitch);\n        const y0 = -Math.ceil(oy / pitch);\n        const x1 = Math.ceil((W - ox) / pitch);\n        const y1 = Math.ceil((H - oy) / pitch);\n        for (let y = y0; y < y1; y++) {\n          for (let x = x0; x < x1; x++) {\n            const px = ox + (x + 0.5) * pitch;\n            const py = oy + (y + 0.5) * pitch;\n            if (inside(px, py)) dot(g, px, py, size, s.dotShape === \"square\");\n          }\n        }\n        g.fill();\n      }\n      const sp = Math.max(8, Math.ceil(pitch * 3));\n      sprite = document.createElement(\"canvas\");\n      sprite.width = sp;\n      sprite.height = sp;\n      const sg = sprite.getContext(\"2d\");\n      if (sg) {\n        const grad = sg.createRadialGradient(sp / 2, sp / 2, 0, sp / 2, sp / 2, sp / 2);\n        grad.addColorStop(0, rgb(on, 0.55));\n        grad.addColorStop(0.35, rgb(on, 0.18));\n        grad.addColorStop(1, rgb(on, 0));\n        sg.fillStyle = grad;\n        sg.fillRect(0, 0, sp, sp);\n      }\n    };\n\n    const frame = (nowMs: number, dt: number) => {\n      const s = settings.current;\n      const key = `${s.timeZone}|${s.hour12}|${s.showSeconds}|${s.place}`;\n      if (key !== readKey) {\n        readKey = key;\n        read = makeReader(s.timeZone, s.hour12, s.showSeconds, s.place);\n      }\n      const now = new Date();\n      const r = read(now);\n      const lk = `${key}|${r.date.length}|${r.place}|${r.corner}`;\n      if (lk !== layoutKey) {\n        layoutKey = lk;\n        relayout(r);\n      }\n      if (!W || !cols) return;\n      const ck = `${s.dotColor}|${s.showUnlit}|${s.unlitColor}|${s.background}|${s.dotShape}|${s.radius}|${W}x${H}`;\n      if (ck !== colorKey) {\n        colorKey = ck;\n        paintStatic();\n      }\n\n      // New dots to light (or put out) when the second or the colon changes\n      const colon = !s.blink || reduce || now.getMilliseconds() < 500;\n      if (r.second !== lastSecond || colon !== lastColon) {\n        const first = lastSecond === -1;\n        lastSecond = r.second;\n        lastColon = colon;\n        compose(r, colon);\n        for (let i = 0; i < target.length; i++) {\n          if (target[i] === shown[i]) continue;\n          shown[i] = target[i];\n          const y = Math.floor(i / cols);\n          const x = i % cols;\n          // The intro sweeps in diagonally; afterwards a changed digit fills from the top down\n          startAt[i] = first ? born + (x * 0.6 + y) * 11 + jitter[i] * 60 : nowMs + (y % 14) * 12 + jitter[i] * 25;\n        }\n      }\n\n      ctx.clearRect(0, 0, W, H);\n      if (bg) ctx.drawImage(bg, 0, 0);\n      const square = s.dotShape === \"square\";\n      const size = pitch * 0.36;\n      const k = reduce ? 1 : 1 - Math.exp(-dt * 22);\n      const sp = sprite;\n      const spSize = sp ? sp.width : 0;\n      ctx.fillStyle = rgb(on);\n      // Move every dot towards its target, then draw: glow under, then fully lit dots in one batch,\n      // then the ones still fading in or out, each at its own brightness\n      const partial: number[] = [];\n      for (let i = 0; i < level.length; i++) {\n        const goal = nowMs >= startAt[i] ? shown[i] : level[i] > 0.5 ? 1 : 0;\n        level[i] += (goal - level[i]) * k;\n      }\n      if (s.glow && sp) {\n        for (let i = 0; i < level.length; i++) {\n          const l = level[i];\n          if (l < 0.04) continue;\n          ctx.globalAlpha = l;\n          ctx.drawImage(sp, ox + ((i % cols) + 0.5) * pitch - spSize / 2, oy + (Math.floor(i / cols) + 0.5) * pitch - spSize / 2);\n        }\n        ctx.globalAlpha = 1;\n      }\n      ctx.beginPath();\n      for (let i = 0; i < level.length; i++) {\n        const l = level[i];\n        if (l < 0.04) continue;\n        if (l < 0.96) {\n          partial.push(i);\n          continue;\n        }\n        dot(ctx, ox + ((i % cols) + 0.5) * pitch, oy + (Math.floor(i / cols) + 0.5) * pitch, size, square);\n      }\n      ctx.fill();\n      for (const i of partial) {\n        ctx.globalAlpha = level[i];\n        ctx.beginPath();\n        dot(ctx, ox + ((i % cols) + 0.5) * pitch, oy + (Math.floor(i / cols) + 0.5) * pitch, size, square);\n        ctx.fill();\n      }\n      ctx.globalAlpha = 1;\n    };\n\n    let raf = 0;\n    let prev = 0;\n    let visible = true;\n    const tick = (t: number) => {\n      raf = requestAnimationFrame(tick);\n      const dt = prev ? Math.min(0.05, (t - prev) / 1000) : 0;\n      prev = t;\n      if (visible) frame(t, dt);\n    };\n    const ro = new ResizeObserver(() => {\n      sizeCanvas();\n    });\n    ro.observe(canvas);\n    const io = new IntersectionObserver(([entry]) => {\n      visible = entry.isIntersecting;\n    });\n    io.observe(wrap);\n    raf = requestAnimationFrame(tick);\n    return () => {\n      cancelAnimationFrame(raf);\n      ro.disconnect();\n      io.disconnect();\n    };\n  }, []);\n\n  return (\n    <div\n      ref={wrapRef}\n      className={className}\n      role=\"timer\"\n      aria-label={`Clock${place ? ` for ${place}` : \"\"}`}\n      style={{\n        position: \"relative\",\n        width: \"100%\",\n        height: \"100%\",\n        boxSizing: \"border-box\",\n        borderRadius: radius,\n        background,\n        border: `1px solid ${borderColor}`,\n        overflow: \"hidden\",\n        ...style,\n      }}\n    >\n      <canvas ref={canvasRef} aria-hidden style={{ display: \"block\", width: \"100%\", height: \"100%\" }} />\n    </div>\n  );\n}\n"}],"docs":"Dot Matrix Clock is ready. Props and a live canvas: https://bydot.co/component/dot-clock","meta":{"tier":"free","category":"UI Elements","version":"1.0.0"}}