{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "scroll-mask",
  "title": "Scroll Mask",
  "description": "Scroll opens a mask that reveals an image six ways: iris, wipe, curtain, slats, grid or a word. No dependencies.",
  "files": [
    {
      "path": "registry/mewo/ui/scroll-mask.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\n\nexport type ScrollMaskVariant = \"iris\" | \"wipe\" | \"curtain\" | \"slats\" | \"grid\" | \"type\"\n\nexport interface ScrollMaskProps extends React.ComponentProps<\"section\"> {\n  /** Which mask geometry drives the reveal. */\n  variant?: ScrollMaskVariant\n  /** Image revealed through the mask. */\n  src?: string\n  /** Alternative text for the image. */\n  alt?: string\n  /** Word carved out of the frame in the type variant. */\n  word?: string\n  /** Scroll runway beyond the pinned viewport, in viewport heights. */\n  scrollLength?: number\n  /** Fraction of the runway after which the reveal has fully opened. */\n  settle?: number\n  /** Seconds the reveal trails the scroll position. 0 snaps instantly. */\n  smooth?: number\n  /** Edge softness of the mask, as a percentage of the frame. */\n  feather?: number\n  /** Delay spread across pieces. 0 fires them together. */\n  stagger?: number\n  /** Strip count for slats, column count for grid. */\n  columns?: number\n  /** Horizontal anchor of the reveal, as a percentage. */\n  originX?: number\n  /** Vertical anchor of the reveal, as a percentage. */\n  originY?: number\n  /** Sweep direction of the wipe variant, in degrees. */\n  angle?: number\n  /** Scale the image starts at before settling back to 1. */\n  zoom?: number\n  /** How the image fills the frame. */\n  fit?: \"cover\" | \"contain\"\n  /** Corner radius of the frame, in pixels. */\n  radius?: number\n  /** Opacity of the scrim laid over the image. */\n  overlay?: number\n  /** Colour behind the frame. */\n  background?: string\n  /** Fade children in as the reveal completes. */\n  revealContent?: boolean\n  /** Hold the reveal steady on the scroll position instead of damping toward it. */\n  calm?: boolean\n}\n\nexport const DEFAULT_SRC = \"https://cataas.com/cat/fogXmHYpuMV51EaN\"\n\n// Stops used to draw one feathered mask edge.\nconst FEATHER_STEPS = 14\n// Slats slide in this far, as a percentage of their height, and reach full\n// opacity a little before they land.\nconst SLAT_TRAVEL = 62\nconst SLAT_FADE = 1.9\n// Grid cells grow out of this scale as they fade in.\nconst CELL_SCALE = 0.9\n// The word starts at this fraction of its final size; the rest of the frame\n// fills in once the reveal is past TYPE_FILL_START.\nconst TYPE_SCALE = 0.42\nconst TYPE_FILL_START = 0.54\n// Children fade in across this stretch of the eased reveal, rising as they do.\nconst CONTENT_START = 0.5\nconst CONTENT_END = 0.94\nconst CONTENT_RISE = 20\n// Below this scale an iris window is a point; it is hidden rather than drawn.\nconst MIN_SCALE = 0.002\n\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value))\nconst smoothstep = (t: number) => t * t * (3 - 2 * t)\nconst smootherstep = (t: number) => t * t * t * (t * (t * 6 - 15) + 10)\n\n/**\n * Where the opaque edge of the mask sits, as a percentage of the frame, for an eased\n * reveal of 0 to 1. It starts two feathers out of sight and ends at the far side.\n */\nexport function maskEdge(eased: number, feather: number): number {\n  return -2 * feather + (100 + 2 * feather) * eased\n}\n\n/** Gradient stops that stay opaque up to `edge`%, then fall away over `feather`%. */\nfunction featheredStops(edge: number, feather: number): string {\n  if (feather <= 0) return `#000 ${edge.toFixed(2)}%, transparent ${edge.toFixed(2)}%`\n  const stops: string[] = []\n  for (let i = 0; i <= FEATHER_STEPS; i++) {\n    const u = i / FEATHER_STEPS\n    stops.push(`rgba(0,0,0,${(1 - smootherstep(u)).toFixed(3)}) ${(edge + feather * u).toFixed(2)}%`)\n  }\n  return stops.join(\", \")\n}\n\n/** An SVG mask with the word stretched across its full width. */\nfunction wordMask(word: string): string {\n  const text = word.replace(/[&<>\"']/g, (char) => `&#${char.charCodeAt(0)};`)\n  const width = Math.max(1, Array.from(word).length) * 126\n  const svg =\n    `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${width} 264\">` +\n    `<text x=\"${width / 2}\" y=\"197\" text-anchor=\"middle\" textLength=\"${width - 12}\" lengthAdjust=\"spacingAndGlyphs\" ` +\n    `font-family=\"system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif\" font-size=\"200\" font-weight=\"800\">` +\n    `${text}</text></svg>`\n  return `url(\"data:image/svg+xml,${encodeURIComponent(svg)}\")`\n}\n\n/*\n * The four mask variants never change a mask while scrolling. Each pane is an element whose mask is\n * painted once, moved by a transform every frame, with the image inside given the inverse transform so it\n * holds still on screen: the iris scales, the wipe slides along its angle, each half of the curtain slides\n * out from the origin, and the word grows while a second, unmasked pane fades in over it. Transform and\n * opacity are all the compositor needs to redraw a frame, so the reveal costs no repaint. Animating the\n * gradient of a mask instead would repaint the whole frame on every frame of the scroll.\n */\n\n/** A 2D affine transform in CSS `matrix(a, b, c, d, e, f)` order: (x, y) to (ax + cy + e, bx + dy + f). */\nexport type Matrix = [number, number, number, number, number, number]\n\nconst IDENTITY: Matrix = [1, 0, 0, 1, 0, 0]\n\n/** `a` after `b`. */\nexport function multiply(a: Matrix, b: Matrix): Matrix {\n  return [\n    a[0] * b[0] + a[2] * b[1],\n    a[1] * b[0] + a[3] * b[1],\n    a[0] * b[2] + a[2] * b[3],\n    a[1] * b[2] + a[3] * b[3],\n    a[0] * b[4] + a[2] * b[5] + a[4],\n    a[1] * b[4] + a[3] * b[5] + a[5],\n  ]\n}\n\nfunction invert(m: Matrix): Matrix {\n  const det = m[0] * m[3] - m[1] * m[2]\n  const a = m[3] / det\n  const b = -m[1] / det\n  const c = -m[2] / det\n  const d = m[0] / det\n  return [a, b, c, d, -(a * m[4] + c * m[5]), -(b * m[4] + d * m[5])]\n}\n\nconst translate = (x: number, y: number): Matrix => [1, 0, 0, 1, x, y]\nconst scaleAbout = (s: number, x: number, y: number): Matrix => [s, 0, 0, s, x - s * x, y - s * y]\nconst toCss = (m: Matrix) => `matrix(${m.map((value) => +value.toFixed(5)).join(\",\")})`\n\nexport type MaskedVariant = Exclude<ScrollMaskVariant, \"slats\" | \"grid\">\n\nexport interface MaskGeometry {\n  variant: MaskedVariant\n  /** Frame size in pixels. */\n  width: number\n  height: number\n  feather: number\n  originX: number\n  originY: number\n  angle: number\n  word: string\n}\n\nexport interface MaskPane {\n  /** The static strip of the frame the pane is clipped to, in frame pixels. */\n  clip: { left: number; width: number }\n  /** The pane's own box, before its transform. */\n  box: { width: number; height: number }\n  /** The pane's mask, painted once. Null for an unmasked pane. */\n  mask: { image: string; size: string; position: string } | null\n}\n\nexport interface PanePose {\n  visible: boolean\n  opacity: number\n  /** Pane box to clip coordinates. */\n  pane: Matrix\n  /** Image box (the frame) to pane coordinates. */\n  image: Matrix\n}\n\n/** Distance from the origin to the farthest corner of the frame: where a circle covers it all. */\nfunction farthestCorner(x: number, y: number, width: number, height: number) {\n  return Math.max(Math.hypot(x, y), Math.hypot(width - x, y), Math.hypot(x, height - y), Math.hypot(width - x, height - y))\n}\n\n/** The direction a wipe travels, the axis across it, and the gradient line's length, as CSS defines them. */\nfunction wipeAxes(angle: number, width: number, height: number) {\n  const theta = (angle * Math.PI) / 180\n  const along = { x: Math.sin(theta), y: -Math.cos(theta) }\n  const across = { x: -along.y, y: along.x }\n  const length = Math.abs(width * along.x) + Math.abs(height * along.y)\n  const breadth = Math.abs(width * across.x) + Math.abs(height * across.y)\n  return { along, across, length, breadth }\n}\n\n/** The panes a masked variant needs, sized for the frame. Recomputed only when the frame or a prop changes. */\nexport function maskPanes(g: MaskGeometry): MaskPane[] {\n  const { width: w, height: h } = g\n  const soft = Math.max(0, g.feather)\n  // A pane's mask is opaque over the reveal and feathers out beyond it; `grow` sizes the pane to hold both.\n  const grow = 1 + soft / 100\n  const opaque = 100 / grow\n  const stops = featheredStops(opaque, 100 - opaque)\n  const ox = (g.originX / 100) * w\n  const whole = { left: 0, width: w }\n  const fill = { size: \"100% 100%\", position: \"0 0\" }\n\n  switch (g.variant) {\n    case \"iris\": {\n      const side = 2 * farthestCorner(ox, (g.originY / 100) * h, w, h) * grow\n      return [{ clip: whole, box: { width: side, height: side }, mask: { image: `radial-gradient(circle closest-side, ${stops})`, ...fill } }]\n    }\n    case \"wipe\": {\n      const { length, breadth } = wipeAxes(g.angle, w, h)\n      return [{ clip: whole, box: { width: length * grow, height: breadth + 2 }, mask: { image: `linear-gradient(to right, ${stops})`, ...fill } }]\n    }\n    case \"curtain\":\n      // Each half is clipped at the origin, so it can only open outward. They overlap by a pixel so no seam shows.\n      return [\n        { clip: { left: 0, width: ox + 0.5 }, box: { width: ox * grow, height: h }, mask: { image: `linear-gradient(to left, ${stops})`, ...fill } },\n        { clip: { left: ox - 0.5, width: w - ox + 0.5 }, box: { width: (w - ox) * grow, height: h }, mask: { image: `linear-gradient(to right, ${stops})`, ...fill } },\n      ]\n    case \"type\":\n      return [\n        { clip: whole, box: { width: w, height: h }, mask: { image: wordMask(g.word), size: \"contain\", position: `${g.originX}% ${g.originY}%` } },\n        { clip: whole, box: { width: w, height: h }, mask: null },\n      ]\n  }\n}\n\n/** Where every pane and its image sit for an eased reveal of 0 to 1 and an image scale of `imageScale`. */\nexport function maskPoses(g: MaskGeometry, eased: number, imageScale: number): PanePose[] {\n  const { width: w, height: h } = g\n  const soft = Math.max(0, g.feather)\n  const grow = 1 + soft / 100\n  const edge = maskEdge(eased, soft)\n  const reach = edge / 100\n  const open = edge + soft > 0\n  const ox = (g.originX / 100) * w\n  const oy = (g.originY / 100) * h\n  const zoom = g.variant === \"type\" ? scaleAbout(imageScale, ox, oy) : scaleAbout(imageScale, w / 2, h / 2)\n\n  // The image is placed so that pane, then image, lands it exactly where the zoom alone would.\n  const pose = (pane: Matrix, clipLeft: number, visible: boolean, opacity = 1): PanePose => ({\n    visible,\n    opacity,\n    pane,\n    image: visible ? multiply(invert(pane), multiply(translate(-clipLeft, 0), zoom)) : IDENTITY,\n  })\n\n  switch (g.variant) {\n    case \"iris\": {\n      // A scaled mask's soft edge grows with it, so the scale tracks the middle of the original soft edge:\n      // the circle reads the same size throughout, and at 1 it is opaque out to the farthest corner.\n      const half = farthestCorner(ox, oy, w, h) * grow\n      const s = Math.max(0, (edge + soft / 2) / (100 + soft / 2))\n      const visible = s > MIN_SCALE\n      return [pose([s, 0, 0, s, ox - s * half, oy - s * half], 0, visible)]\n    }\n    case \"wipe\": {\n      const { along, across, length, breadth } = wipeAxes(g.angle, w, h)\n      // The gradient line runs through the centre; the pane's opaque end sits at the edge's distance along it.\n      const startX = w / 2 - (along.x * length) / 2\n      const startY = h / 2 - (along.y * length) / 2\n      const offset = reach * length - length\n      const x = startX + along.x * offset - across.x * (breadth / 2 + 1)\n      const y = startY + along.y * offset - across.y * (breadth / 2 + 1)\n      return [pose([along.x, along.y, across.x, across.y, x, y], 0, open)]\n    }\n    case \"curtain\": {\n      const left = ox\n      const right = w - ox\n      // Each half's opaque part starts at the origin and has reached `reach` of the way to its side.\n      const leftX = ox - reach * left - left * (grow - 1)\n      const rightClip = ox - 0.5\n      const rightX = ox + reach * right - right - rightClip\n      return [pose(translate(leftX, 0), 0, open && left >= 1), pose(translate(rightX, 0), rightClip, open && right >= 1)]\n    }\n    case \"type\": {\n      const scale = TYPE_SCALE + (1 - TYPE_SCALE) * eased\n      const alpha = clamp((eased - TYPE_FILL_START) / (1 - TYPE_FILL_START), 0, 1)\n      const pane = scaleAbout(scale, ox, oy)\n      // Once the plain pane is fully in, the word underneath it no longer shows.\n      return [pose(pane, 0, alpha < 1), pose(pane, 0, alpha > 0, alpha)]\n    }\n  }\n}\n\nfunction setMask(el: HTMLElement, image: string, size = \"100% 100%\", position = \"0 0\") {\n  for (const prefix of [\"\", \"-webkit-\"]) {\n    el.style.setProperty(`${prefix}mask-image`, image)\n    el.style.setProperty(`${prefix}mask-size`, size)\n    el.style.setProperty(`${prefix}mask-position`, position)\n    el.style.setProperty(`${prefix}mask-repeat`, \"no-repeat\")\n  }\n}\n\n/** The nearest ancestor that scrolls vertically, or null when the page itself does. */\nfunction scrollParent(node: HTMLElement): HTMLElement | null {\n  for (let el = node.parentElement; el && el !== document.body && el !== document.documentElement; el = el.parentElement) {\n    const { overflowY } = getComputedStyle(el)\n    if (overflowY === \"auto\" || overflowY === \"scroll\") return el\n  }\n  return null\n}\n\nexport function ScrollMask({\n  variant = \"iris\",\n  src = DEFAULT_SRC,\n  alt = \"\",\n  word = \"SCROLL\",\n  scrollLength = 1.7,\n  settle = 0.84,\n  smooth = 0.14,\n  feather = 14,\n  stagger = 0.55,\n  columns = 9,\n  originX = 50,\n  originY = 50,\n  angle = 108,\n  zoom = 1.14,\n  fit = \"cover\",\n  radius = 18,\n  overlay = 0,\n  background = \"transparent\",\n  revealContent = true,\n  calm = false,\n  children,\n  className,\n  style,\n  ...props\n}: ScrollMaskProps) {\n  const stageRef = React.useRef<HTMLDivElement>(null)\n  const frameRef = React.useRef<HTMLDivElement>(null)\n  const clipRefs = React.useRef<(HTMLDivElement | null)[]>([])\n  const paneRefs = React.useRef<(HTMLDivElement | null)[]>([])\n  const imageRefs = React.useRef<(HTMLDivElement | null)[]>([])\n  const pieceRefs = React.useRef<(HTMLDivElement | null)[]>([])\n  const contentRef = React.useRef<HTMLDivElement>(null)\n  const progressRef = React.useRef<number | null>(null)\n\n  const pieced = variant === \"slats\" || variant === \"grid\"\n  const paneCount = variant === \"curtain\" || variant === \"type\" ? 2 : 1\n  const cols = Math.max(1, Math.floor(columns))\n  // Grid rows follow the frame's shape so the cells stay close to square.\n  const [gridRows, setGridRows] = React.useState(cols)\n  const rows = variant === \"grid\" ? gridRows : 1\n  const hasContent = children != null && children !== false\n  const scrim = clamp(overlay, 0, 1)\n\n  const pieces = React.useMemo(\n    () => (pieced ? Array.from({ length: cols * rows }, (_, i) => ({ col: i % cols, row: Math.floor(i / cols) })) : []),\n    [pieced, cols, rows]\n  )\n\n  React.useEffect(() => {\n    const frame = frameRef.current\n    if (!frame || variant !== \"grid\") return\n\n    // An observer reports the frame's size once on observing, then on every change.\n    const observer = new ResizeObserver(() => {\n      if (frame.clientWidth > 0) setGridRows(Math.max(1, Math.round((cols * frame.clientHeight) / frame.clientWidth)))\n    })\n    observer.observe(frame)\n    return () => observer.disconnect()\n  }, [variant, cols])\n\n  React.useEffect(() => {\n    const stage = stageRef.current\n    const frame = frameRef.current\n    // The root's ref stays the consumer's, so the section is reached through the stage.\n    const section = stage?.parentElement\n    if (!stage || !frame || !section) return\n\n    const scroller = scrollParent(section)\n    // Inside a scroll container the stage pins to that container, not the window.\n    const fitViewport = () => {\n      if (scroller) section.style.setProperty(\"--mewo-viewport\", `${scroller.clientHeight}px`)\n    }\n    fitViewport()\n\n    const settleAt = clamp(settle, 0.01, 1)\n    const spread = clamp(stagger, 0, 0.95)\n    const ox = originX / 100\n    const oy = originY / 100\n\n    // Pieces further out start later, the furthest by `stagger`.\n    const distances = pieces.map(({ col, row }) =>\n      variant === \"slats\"\n        ? Math.abs((col + 0.5) / cols - ox)\n        : Math.hypot((col + 0.5) / cols - ox, (row + 0.5) / rows - oy)\n    )\n    const reach = Math.max(1e-6, ...distances)\n\n    let geometry: MaskGeometry | null = null\n\n    // Sizes the panes and paints their masks. Runs on mount and on resize, never per frame.\n    const layout = () => {\n      if (pieced) return\n      const width = frame.clientWidth\n      const height = frame.clientHeight\n      if (width <= 0 || height <= 0) return\n      geometry = { variant: variant as MaskedVariant, width, height, feather, originX, originY, angle, word }\n      maskPanes(geometry).forEach((pane, i) => {\n        const clip = clipRefs.current[i]\n        const element = paneRefs.current[i]\n        const image = imageRefs.current[i]\n        if (!clip || !element || !image) return\n        clip.style.left = `${pane.clip.left}px`\n        clip.style.width = `${pane.clip.width}px`\n        element.style.width = `${pane.box.width}px`\n        element.style.height = `${pane.box.height}px`\n        if (pane.mask) setMask(element, pane.mask.image, pane.mask.size, pane.mask.position)\n        image.style.width = `${width}px`\n        image.style.height = `${height}px`\n      })\n    }\n\n    const render = (progress: number) => {\n      const eased = smoothstep(clamp(progress / settleAt, 0, 1))\n\n      if (geometry) {\n        maskPoses(geometry, eased, zoom + (1 - zoom) * eased).forEach((pose, i) => {\n          const element = paneRefs.current[i]\n          const image = imageRefs.current[i]\n          if (!element || !image) return\n          element.style.visibility = pose.visible ? \"visible\" : \"hidden\"\n          if (!pose.visible) return\n          element.style.transform = toCss(pose.pane)\n          element.style.opacity = `${pose.opacity}`\n          image.style.transform = toCss(pose.image)\n        })\n      }\n\n      for (let i = 0; i < pieces.length; i++) {\n        const piece = pieceRefs.current[i]\n        if (!piece) continue\n        const delay = (distances[i] / reach) * spread\n        const local = smoothstep(clamp((eased - delay) / (1 - spread), 0, 1))\n\n        if (variant === \"slats\") {\n          const side = i % 2 === 0 ? -1 : 1\n          piece.style.transform = `translate3d(0, ${side * SLAT_TRAVEL * (1 - local)}%, 0)`\n          piece.style.opacity = `${Math.min(1, local * SLAT_FADE)}`\n        } else {\n          piece.style.transform = `scale(${CELL_SCALE + (1 - CELL_SCALE) * local})`\n          piece.style.opacity = `${local}`\n        }\n      }\n\n      const content = contentRef.current\n      if (content) {\n        const shown = revealContent ? smoothstep(clamp((eased - CONTENT_START) / (CONTENT_END - CONTENT_START), 0, 1)) : 1\n        content.style.opacity = `${shown}`\n        content.style.transform = `translate3d(0, ${(1 - shown) * CONTENT_RISE}px, 0)`\n        content.style.visibility = shown > 0 ? \"visible\" : \"hidden\"\n      }\n    }\n\n    layout()\n\n    // Reduced motion skips the reveal: CSS drops the scroll runway and the frame rests open.\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n      render(1)\n      const observer = new ResizeObserver(() => {\n        layout()\n        render(1)\n      })\n      observer.observe(frame)\n      return () => observer.disconnect()\n    }\n\n    const damping = calm ? 0 : Math.max(0, smooth)\n    let target = 0\n    let raf = 0\n    let last = 0\n\n    const measure = () => {\n      const origin = scroller ? scroller.getBoundingClientRect().top + scroller.clientTop : 0\n      const scrolled = origin - section.getBoundingClientRect().top\n      const runway = section.offsetHeight - stage.offsetHeight\n      target = runway > 0 ? clamp(scrolled / runway, 0, 1) : 0\n    }\n\n    const tick = (now: number) => {\n      const dt = clamp((now - last) / 1000, 0, 0.1)\n      last = now\n\n      let progress = progressRef.current ?? target\n      progress = damping > 0 ? progress + (target - progress) * (1 - Math.exp(-dt / damping)) : target\n      if (Math.abs(target - progress) < 0.0002) progress = target\n\n      progressRef.current = progress\n      render(progress)\n      raf = progress === target ? 0 : requestAnimationFrame(tick)\n    }\n\n    const update = () => {\n      measure()\n      if (!raf) {\n        last = performance.now()\n        raf = requestAnimationFrame(tick)\n      }\n    }\n\n    const resize = () => {\n      fitViewport()\n      layout()\n      render(progressRef.current ?? target)\n      update()\n    }\n\n    measure()\n    // Snap on mount; afterwards keep the eased position across prop changes.\n    progressRef.current = progressRef.current ?? target\n    render(progressRef.current)\n    if (progressRef.current !== target) update()\n\n    const observer = new ResizeObserver(resize)\n    observer.observe(stage)\n    if (scroller) observer.observe(scroller)\n    // Scroll events do not bubble; capturing on the window hears a nested scroller too.\n    window.addEventListener(\"scroll\", update, { passive: true, capture: true })\n    window.addEventListener(\"resize\", resize)\n\n    return () => {\n      cancelAnimationFrame(raf)\n      observer.disconnect()\n      window.removeEventListener(\"scroll\", update, { capture: true })\n      window.removeEventListener(\"resize\", resize)\n    }\n  }, [variant, word, scrollLength, settle, smooth, feather, stagger, cols, rows, pieces, pieced, originX, originY, angle, zoom, revealContent, calm, hasContent])\n\n  const picture: React.CSSProperties = {\n    backgroundImage: `linear-gradient(rgba(0,0,0,${scrim}), rgba(0,0,0,${scrim})), url(${JSON.stringify(src)})`,\n    backgroundSize: `auto, ${fit}`,\n    backgroundPosition: \"center\",\n    backgroundRepeat: \"no-repeat\",\n  }\n  // The picture is painted as a background so slats, cells and panes can each show their own\n  // window onto it; this is what gives it a name for assistive tech.\n  const labelled = alt ? ({ role: \"img\", \"aria-label\": alt } as const) : ({ \"aria-hidden\": true } as const)\n\n  return (\n    <section\n      data-slot=\"scroll-mask\"\n      className={cn(\n        \"relative h-[calc(var(--mewo-viewport,100vh)*var(--mewo-length))] motion-reduce:h-[var(--mewo-viewport,100vh)]\",\n        className\n      )}\n      style={{ \"--mewo-length\": 1 + Math.max(0, scrollLength), background, ...style } as React.CSSProperties}\n      {...props}\n    >\n      <div ref={stageRef} className=\"sticky top-0 box-border h-[var(--mewo-viewport,100vh)] w-full p-[clamp(16px,5vw,32px)]\">\n        <div ref={frameRef} className=\"relative size-full overflow-hidden\" style={{ borderRadius: radius }}>\n          {pieced ? (\n            <div key={variant} {...labelled} className=\"absolute inset-0\">\n              {pieces.map(({ col, row }, i) => (\n                <div\n                  key={i}\n                  ref={(el) => {\n                    pieceRefs.current[i] = el\n                  }}\n                  data-slot=\"scroll-mask-piece\"\n                  // Clipping half a pixel outside the cell lets neighbours overlap, so no hairline seams show.\n                  className=\"absolute opacity-0 [clip-path:inset(-0.5px)] will-change-[transform,opacity]\"\n                  style={{\n                    left: `${(col / cols) * 100}%`,\n                    top: `${(row / rows) * 100}%`,\n                    width: `${100 / cols}%`,\n                    height: `${100 / rows}%`,\n                  }}\n                >\n                  <div\n                    className=\"absolute\"\n                    style={{\n                      left: `${-col * 100}%`,\n                      top: `${-row * 100}%`,\n                      width: `${cols * 100}%`,\n                      height: `${rows * 100}%`,\n                      ...picture,\n                    }}\n                  />\n                </div>\n              ))}\n            </div>\n          ) : (\n            <div key={variant} {...labelled} className=\"absolute inset-0\">\n              {/* What shows when no script runs: the registry's scripting-off rule displays it. */}\n              <div data-slot=\"scroll-mask-static\" className=\"absolute inset-0 hidden\" style={picture} />\n              {Array.from({ length: paneCount }, (_, i) => (\n                <div\n                  key={i}\n                  ref={(el) => {\n                    clipRefs.current[i] = el\n                  }}\n                  className=\"absolute inset-y-0 left-0 w-full overflow-hidden\"\n                >\n                  <div\n                    ref={(el) => {\n                      paneRefs.current[i] = el\n                    }}\n                    data-slot=\"scroll-mask-layer\"\n                    // Sized, masked and placed by the effect once the frame has been measured.\n                    className=\"invisible absolute top-0 left-0 origin-top-left will-change-[transform,opacity]\"\n                  >\n                    <div\n                      ref={(el) => {\n                        imageRefs.current[i] = el\n                      }}\n                      data-slot=\"scroll-mask-image\"\n                      className=\"absolute top-0 left-0 origin-top-left will-change-transform\"\n                    >\n                      {/* The picture sits on an untransformed child: Chrome repaints an element with a\n                          layered background (scrim plus photo) whenever that element's own transform changes. */}\n                      <div className=\"absolute inset-0\" style={picture} />\n                    </div>\n                  </div>\n                </div>\n              ))}\n            </div>\n          )}\n\n          {hasContent && (\n            <div\n              ref={contentRef}\n              data-slot=\"scroll-mask-content\"\n              className={cn(\n                \"absolute inset-0 flex items-center justify-center will-change-[transform,opacity]\",\n                revealContent && \"opacity-0\"\n              )}\n            >\n              {children}\n            </div>\n          )}\n        </div>\n      </div>\n    </section>\n  )\n}\n",
      "type": "registry:ui"
    }
  ],
  "css": {
    "@media (scripting: none)": {
      "[data-slot=\"scroll-mask\"]": {
        "height": "100vh !important"
      },
      "[data-slot=\"scroll-mask-static\"]": {
        "display": "block !important"
      },
      "[data-slot=\"scroll-mask-piece\"]": {
        "opacity": "1 !important",
        "transform": "none !important"
      },
      "[data-slot=\"scroll-mask-content\"]": {
        "opacity": "1 !important"
      }
    }
  },
  "meta": {
    "added": "2026-10-01"
  },
  "categories": [
    "scroll"
  ],
  "type": "registry:ui"
}