{"$schema":"https://ui.shadcn.com/schema/registry.json","author":"Kaiyu Hsu <uicapsule@kyh.io>","categories":["controls","silly","colorful"],"dependencies":["@base-ui/react","cn"],"description":"Ordinary controls that react like anime: spring squash, drawn smoke, impact bursts and manga sound-effect lettering","devDependencies":[],"files":[{"content":"\"use client\";\n\nimport { useEffect } from \"react\";\n\nimport { clock } from \"./sakuga-core\";\nimport { SakugaVfx } from \"./sakuga-vfx\";\n\nconst Preview = () => {\n  useEffect(() => {\n    Reflect.set(globalThis, \"SakugaFX\", clock);\n  }, []);\n\n  return (\n    <main className=\"min-h-dvh overflow-x-clip bg-white px-4 py-8 [color-scheme:light]\">\n      <div className=\"mx-auto flex justify-center\">\n        <SakugaVfx />\n      </div>\n    </main>\n  );\n};\n\nexport default Preview;\n","path":"/preview.tsx","target":"uicapsule/sakuga-vfx/preview.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { Accordion as AccordionPrimitive } from \"@base-ui/react/accordion\";\nimport { cn } from \"cn\";\nimport { createContext, use, useLayoutEffect, useMemo, useRef } from \"react\";\nimport type { ComponentProps, RefObject } from \"react\";\n\nimport { Spring, at, hollow, later, puff, sfx, ticks } from \"./sakuga-core\";\nimport { FONT_BODY, FONT_DISPLAY, SakugaStyle, useFrame, useMergedRef } from \"./sakuga-react\";\nimport type { Styled } from \"./sakuga-react\";\n\ninterface Rig {\n  h: Spring;\n  turn: Spring;\n  press: Spring;\n  asked: boolean;\n  landing: boolean;\n  closing: boolean;\n  still: boolean;\n}\n\nconst makeRig = () => ({\n  asked: false,\n  closing: false,\n  h: new Spring(0, 380, 19),\n  landing: false,\n  press: new Spring(1, 520, 15),\n  still: true,\n  turn: new Spring(0, 420, 13),\n});\n\nconst aim = (r: Rig, on: boolean, loud: boolean) => {\n  r.h.to = on ? 1 : 0;\n  r.h.k = on ? 380 : 900;\n  r.h.d = on ? 19 : 40;\n  r.turn.to = r.h.to;\n  r.landing = on && loud;\n  r.closing = !on && loud;\n  r.still = false;\n  r.h.v = on ? Math.max(r.h.v, 5) : Math.min(r.h.v, -6);\n};\n\nconst flip = (t: number) => {\n  const y = 1 - 2 * t;\n\n  return `scale(${(1 + Math.max(0, 1 - Math.abs(y)) * 0.25).toFixed(3)}, ${y.toFixed(3)})`;\n};\n\ninterface ItemRefs {\n  rigRef: RefObject<Rig>;\n  headRef: RefObject<HTMLButtonElement | null>;\n  chevronRef: RefObject<SVGSVGElement | null>;\n  panelRef: RefObject<HTMLDivElement | null>;\n  bodyRef: RefObject<HTMLDivElement | null>;\n}\n\nconst CardContext = createContext<RefObject<HTMLDivElement | null> | null>(null);\nconst ItemContext = createContext<ItemRefs | null>(null);\n\nconst useItem = () => {\n  const item = use(ItemContext);\n\n  if (!item) {\n    throw new Error(\"Sakuga accordion parts go inside a SakugaAccordionItem\");\n  }\n\n  return item;\n};\n\nconst land = (card: HTMLElement, head: HTMLElement, panel: HTMLElement) => {\n  const k = at(card);\n  const p = at(panel, 0.5, 1);\n  const q = at(head, 1, 0);\n  const left = k.x - k.w / 2;\n  const right = k.x + k.w / 2;\n  puff(left - 7, p.y - 3, { life: 0.7, n: 4, size: 8, vx: -16, vy: -10 });\n  puff(right + 12, p.y + 2, { life: 0.7, n: 4, size: 8, vx: 16, vy: -8 });\n  ticks(q.x - 4, q.y + 2, { dir: -0.75, fan: 0.36, len: 15, life: 0.5, n: 3, r: 5 });\n  sfx(\"pon\", right - 30, k.y - k.h / 2 - 22, { life: 0.8, rot: 0.06, size: 72, ...hollow() });\n};\n\nconst shut = (head: HTMLElement) => {\n  const q = at(head, 1, 1);\n  puff(q.x + 4, q.y, { life: 0.4, n: 3, size: 7 });\n};\n\nconst stepPanel = (\n  r: Rig,\n  dt: number,\n  card: HTMLElement | null,\n  head: HTMLElement,\n  panel: HTMLElement,\n  body: HTMLElement,\n  chevron: SVGSVGElement,\n) => {\n  const h = Math.max(0, r.h.step(dt));\n  const t = r.turn.step(dt);\n  chevron.style.transform = flip(t);\n\n  if (r.landing && h >= 1) {\n    r.landing = false;\n\n    if (card) {\n      land(card, head, panel);\n    }\n  }\n\n  if (r.closing && h < 0.08) {\n    r.closing = false;\n    shut(head);\n  }\n\n  const turned = Math.abs(t - r.turn.to) < 0.002 && Math.abs(r.turn.v) < 0.02;\n\n  if (r.h.to === 1 && Math.abs(h - 1) < 0.001 && Math.abs(r.h.v) < 0.01) {\n    panel.style.height = \"\";\n    r.still = turned;\n  } else if (r.h.to === 0 && h < 0.004) {\n    r.h.x = 0;\n    r.h.v = 0;\n    panel.style.height = \"0px\";\n    r.still = turned;\n  } else {\n    panel.style.height = `${(h * body.offsetHeight).toFixed(2)}px`;\n  }\n};\n\nconst SakugaAccordion = ({\n  className,\n  children,\n  ref,\n  ...props\n}: Styled<AccordionPrimitive.Root.Props>) => {\n  const cardRef = useRef<HTMLDivElement>(null);\n\n  return (\n    <AccordionPrimitive.Root\n      ref={useMergedRef(cardRef, ref)}\n      data-slot=\"sakuga-accordion\"\n      className={cn(\n        \"relative isolate inline-block w-[270px] max-w-full rounded-(--sk-r) border-[length:var(--sk-bw)] border-(--sk-ink) bg-(--sk-card) align-middle text-[15px] leading-[1.4] font-medium text-(--sk-ink) shadow-(--sk-sh)\",\n        FONT_BODY,\n        className,\n      )}\n      {...props}\n    >\n      <SakugaStyle />\n      <CardContext value={cardRef}>{children}</CardContext>\n    </AccordionPrimitive.Root>\n  );\n};\n\nconst SakugaAccordionItem = ({\n  className,\n  onOpenChange,\n  ...props\n}: Styled<AccordionPrimitive.Item.Props>) => {\n  const rigRef = useRef(makeRig());\n  const headRef = useRef<HTMLButtonElement>(null);\n  const chevronRef = useRef<SVGSVGElement>(null);\n  const panelRef = useRef<HTMLDivElement>(null);\n  const bodyRef = useRef<HTMLDivElement>(null);\n  const refs = useMemo(() => ({ bodyRef, chevronRef, headRef, panelRef, rigRef }), []);\n  const cardRef = use(CardContext);\n\n  useFrame((dt) => {\n    const r = rigRef.current;\n    const head = headRef.current;\n    const panel = panelRef.current;\n    const body = bodyRef.current;\n    const chevron = chevronRef.current;\n\n    if (!head) {\n      return;\n    }\n\n    const y = r.press.step(dt);\n    head.style.transform =\n      Math.abs(y - 1) < 0.001 && Math.abs(r.press.v) < 0.01\n        ? \"\"\n        : `scale(${1 + (1 - y) * 0.14}, ${y})`;\n\n    if (!r.still && panel && body && chevron) {\n      stepPanel(r, dt, cardRef?.current ?? null, head, panel, body, chevron);\n    }\n  });\n\n  return (\n    <ItemContext value={refs}>\n      <AccordionPrimitive.Item\n        data-slot=\"sakuga-accordion-item\"\n        className={cn(\"not-first:border-t-[2.4px] not-first:border-(--sk-ink)\", className)}\n        {...props}\n        onOpenChange={(open, details) => {\n          onOpenChange?.(open, details);\n\n          if (details.isCanceled || details.reason !== \"trigger-press\") {\n            return;\n          }\n\n          const r = rigRef.current;\n          r.press.x = Math.min(r.press.x, 0.86);\n          r.asked = true;\n          later(0, () => {\n            r.asked = false;\n          });\n        }}\n      />\n    </ItemContext>\n  );\n};\n\nconst HEADER = `group flex w-full cursor-pointer touch-manipulation items-center justify-between gap-3 rounded-[10px] px-[16px] py-[10px] text-left text-[17px] leading-[1.2] font-extrabold tracking-[-0.01em] text-(--sk-ink) italic will-change-transform select-none focus-visible:outline-[2.5px] focus-visible:outline-offset-[-3px] focus-visible:outline-(--sk-acc) data-disabled:cursor-not-allowed data-disabled:opacity-45`;\n\nconst SakugaAccordionTrigger = ({\n  className,\n  children,\n  ref,\n  onPointerDown,\n  onPointerUp,\n  onPointerLeave,\n  onPointerCancel,\n  onBlur,\n  ...props\n}: Styled<AccordionPrimitive.Trigger.Props>) => {\n  const { rigRef, headRef, chevronRef } = useItem();\n\n  const hold = (to: number, el: HTMLElement) => {\n    if (to === 1 || !el.matches(\":disabled, [data-disabled]\")) {\n      rigRef.current.press.to = to;\n    }\n  };\n\n  return (\n    <AccordionPrimitive.Header data-slot=\"sakuga-accordion-header\">\n      <AccordionPrimitive.Trigger\n        ref={useMergedRef(headRef, ref)}\n        data-slot=\"sakuga-accordion-trigger\"\n        className={cn(HEADER, FONT_DISPLAY, className)}\n        {...props}\n        onPointerDown={(e) => {\n          onPointerDown?.(e);\n          hold(0.86, e.currentTarget);\n        }}\n        onPointerUp={(e) => {\n          onPointerUp?.(e);\n          hold(1, e.currentTarget);\n        }}\n        onPointerLeave={(e) => {\n          onPointerLeave?.(e);\n          hold(1, e.currentTarget);\n        }}\n        onPointerCancel={(e) => {\n          onPointerCancel?.(e);\n          hold(1, e.currentTarget);\n        }}\n        onBlur={(e) => {\n          onBlur?.(e);\n          hold(1, e.currentTarget);\n        }}\n      >\n        {children}\n        <svg\n          ref={chevronRef}\n          aria-hidden\n          viewBox=\"0 0 16 16\"\n          className=\"h-[16px] w-[16px] flex-none overflow-visible fill-none stroke-(--sk-ink) stroke-[3.2] [stroke-linecap:round] [stroke-linejoin:round] group-data-panel-open:[transform:scaleY(-1)]\"\n        >\n          <path d=\"M2.5 5.5l5.5 5.5 5.5-5.5\" />\n        </svg>\n      </AccordionPrimitive.Trigger>\n    </AccordionPrimitive.Header>\n  );\n};\n\nconst PanelShell = ({ open, ...props }: ComponentProps<\"div\"> & { open: boolean }) => {\n  const { rigRef, panelRef, bodyRef, chevronRef } = useItem();\n  const was = useRef<boolean | null>(null);\n\n  useLayoutEffect(() => {\n    const r = rigRef.current;\n    const before = was.current;\n    was.current = open;\n\n    if (before === null) {\n      r.h.x = open ? 1 : 0;\n      r.h.to = r.h.x;\n      r.turn.x = r.h.x;\n      r.turn.to = r.h.x;\n\n      return;\n    }\n\n    const panel = panelRef.current;\n    const body = bodyRef.current;\n\n    if (before === open || !panel || !body) {\n      return;\n    }\n\n    aim(r, open, r.asked);\n    r.asked = false;\n    panel.style.height = `${(r.h.x * body.offsetHeight).toFixed(2)}px`;\n\n    if (chevronRef.current) {\n      chevronRef.current.style.transform = flip(r.turn.x);\n    }\n  }, [open, rigRef, panelRef, bodyRef, chevronRef]);\n\n  return <div {...props} hidden={false} inert={!open} />;\n};\n\nconst SakugaAccordionContent = ({\n  className,\n  children,\n  ref,\n  ...props\n}: Omit<Styled<AccordionPrimitive.Panel.Props>, \"keepMounted\" | \"hiddenUntilFound\" | \"render\">) => {\n  const { panelRef, bodyRef } = useItem();\n\n  return (\n    <AccordionPrimitive.Panel\n      ref={useMergedRef(panelRef, ref)}\n      keepMounted\n      data-slot=\"sakuga-accordion-content\"\n      className=\"overflow-hidden not-data-open:h-0\"\n      render={(panelProps, state) => <PanelShell {...panelProps} open={state.open} />}\n      {...props}\n    >\n      <div\n        ref={bodyRef}\n        className={cn(\"px-[16px] pt-[1px] pb-[14px] text-[14px] leading-[1.45]\", className)}\n      >\n        {children}\n      </div>\n    </AccordionPrimitive.Panel>\n  );\n};\n\nexport { SakugaAccordion, SakugaAccordionItem, SakugaAccordionTrigger, SakugaAccordionContent };\n","path":"/sakuga-accordion.tsx","target":"uicapsule/sakuga-vfx/sakuga-accordion.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { Button as ButtonPrimitive } from \"@base-ui/react/button\";\nimport { cn } from \"cn\";\nimport { useLayoutEffect, useRef } from \"react\";\n\nimport {\n  Spring,\n  at,\n  burst,\n  donut,\n  kira,\n  later,\n  lines,\n  puff,\n  rnd,\n  sfx,\n  shards,\n  ticks,\n  wob,\n} from \"./sakuga-core\";\nimport {\n  BACK_CANVAS,\n  FONT_BODY,\n  FONT_DISPLAY,\n  SakugaStyle,\n  useBackLayer,\n  useFrame,\n  useMergedRef,\n  useSquashy,\n} from \"./sakuga-react\";\nimport type { Styled } from \"./sakuga-react\";\n\ntype SakugaButtonProps = Styled<ButtonPrimitive.Props> & {\n  variant?: \"primary\" | \"secondary\";\n  done?: boolean;\n};\n\nconst CLOUDS = [\n  [-1, -0.5],\n  [1, -1],\n  [-1, 0.9],\n  [1, 1],\n] as const;\n\nconst BUTTON =\n  \"relative cursor-pointer touch-manipulation rounded-(--sk-r) bg-(--sk-card) px-[30px] py-[14px] text-[19px] leading-[1.1] font-extrabold tracking-[-0.01em] text-(--sk-ink) italic will-change-transform select-none focus-visible:outline-[2.5px] focus-visible:outline-offset-[3px] focus-visible:outline-(--sk-acc) data-disabled:cursor-not-allowed data-disabled:opacity-45 data-inv:bg-(--sk-ink) data-inv:text-(--sk-card) data-inv:shadow-none!\";\n\nconst PRIMARY = \"border-[length:var(--sk-bw)] border-(--sk-btn-line) shadow-(--sk-btn-sh)\";\n\nconst SECONDARY =\n  \"border-[length:var(--sk-bw)] border-(--sk-alt-line) align-middle shadow-(--sk-alt-sh)\";\n\nconst SakugaButton = ({\n  variant = \"primary\",\n  done = false,\n  children,\n  className,\n  onClick,\n  onPointerDown,\n  ref,\n  ...props\n}: SakugaButtonProps) => {\n  const primary = variant === \"primary\";\n  const el = useRef<HTMLButtonElement>(null);\n  const setEl = useMergedRef<HTMLElement>(el, ref);\n  const [attachBack, backRef] = useBackLayer();\n  const sqRef = useSquashy(el, primary ? { low: 0.5, wide: 0.24 } : { low: 0.72, wide: 0.3 });\n  const ok = useRef(new Spring(0, 420, 14));\n  const seq = useRef(0);\n  const checked = useRef(done);\n\n  const impact = () => {\n    const b = el.current;\n    const s = sqRef.current;\n\n    if (!b || !s) {\n      return;\n    }\n\n    const c = at(b);\n    seq.current += 1;\n    const n = seq.current;\n    ok.current.to = 0;\n    ok.current.x = 0;\n    checked.current = false;\n    s.s.x = Math.min(s.s.x, 0.6);\n    s.pop.x = 1.24;\n    s.tilt.x = -5;\n    b.dataset.inv = \"\";\n    later(190, () => {\n      delete b.dataset.inv;\n    });\n    burst(c.x, c.y, { layer: backRef.current ?? undefined, life: 0.48, r: 98, spikes: 17 });\n    shards(c.x, c.y, { arc: 6.28, grav: 300, life: 0.95, n: 11, size: 9, speed: 260 });\n\n    for (const [dx, dy] of CLOUDS) {\n      const size = rnd(12, 16);\n      const life = rnd(0.75, 1.05);\n      puff(c.x + dx * (c.w / 2 + 6), c.y + dy * 26, {\n        life,\n        n: 5,\n        size,\n        vx: dx * 46,\n        vy: dy * 30 - 6,\n      });\n    }\n\n    sfx(\"don\", c.x + 10, c.y - 84, { life: 1.05, rot: -0.12, size: 176 });\n    ticks(c.x - 96, c.y - 70, { dir: -2.4, len: 22, life: 0.45, n: 2, r: 4 });\n    ticks(c.x + 110, c.y - 60, { dir: -0.7, len: 22, life: 0.45, n: 2, r: 4 });\n    later(200, () => {\n      if (n !== seq.current) {\n        return;\n      }\n\n      s.s.x = 1.22;\n      wob(c.x - c.w / 2 - 8, c.y, { dir: -1 });\n      wob(c.x + c.w / 2 + 8, c.y, { dir: 1 });\n      donut(c.x + 6, c.y - 44, { life: 1.25, r: 30, vx: 22, vy: -52 });\n      later(90, () => donut(c.x + 54, c.y - 50, { life: 1.1, r: 18, vx: 34, vy: -40 }));\n      later(170, () => donut(c.x + 86, c.y - 46, { life: 0.95, r: 10, vx: 40, vy: -30 }));\n      const fall = { arc: 1, dir: Math.PI / 2, grav: 380, n: 2, size: 6, speed: 20 };\n      shards(c.x - 30, c.y + 30, fall);\n      shards(c.x + 34, c.y + 30, fall);\n    });\n  };\n\n  useLayoutEffect(() => {\n    const b = el.current;\n\n    if (!primary || !b || done === checked.current) {\n      return;\n    }\n\n    checked.current = done;\n    ok.current.to = done ? 1 : 0;\n\n    if (!done) {\n      return;\n    }\n\n    const q = at(b, 1, 0);\n    kira(q.x - 16, q.y + 2, { life: 1, r: 15 });\n    ticks(q.x - 2, q.y - 12, { dir: -0.8, len: 12, n: 2, r: 6 });\n  }, [done, primary]);\n\n  useFrame((dt) => {\n    sqRef.current?.step(dt);\n\n    if (primary) {\n      el.current?.style.setProperty(\"--ok\", Math.max(0, ok.current.step(dt)).toFixed(3));\n    }\n  });\n\n  const press = () => {\n    const b = el.current;\n\n    if (!primary || !b || b.matches(\":disabled, [aria-disabled='true']\")) {\n      return;\n    }\n\n    const c = at(b);\n    ticks(c.x, c.y - c.h / 2 - 6, { dir: -Math.PI / 2, fan: 0.5, len: 14, n: 3, r: 4 });\n    wob(c.x - c.w / 2 - 6, c.y, { dir: -1, life: 0.3, r: 10 });\n    wob(c.x + c.w / 2 + 6, c.y, { dir: 1, life: 0.3, r: 10 });\n    lines(c.x, c.y + c.h / 2 + 10, { dir: 0, len: 16, life: 0.25, n: 3, spread: 0.1 });\n  };\n\n  const click = (e: Parameters<NonNullable<SakugaButtonProps[\"onClick\"]>>[0]) => {\n    const b = el.current;\n    const s = sqRef.current;\n\n    if (primary) {\n      impact();\n    } else if (b && s) {\n      s.s.x = Math.min(s.s.x, 0.8);\n      s.s.v += 4;\n      const c = at(b, 1, 0);\n      ticks(c.x - 8, c.y - 4, { dir: -1.05, fan: 0.36, len: 17, life: 0.5, n: 3, r: 5 });\n    }\n\n    onClick?.(e);\n  };\n\n  const button = (\n    <ButtonPrimitive\n      data-slot=\"sakuga-button\"\n      data-variant={variant}\n      className={cn(BUTTON, FONT_DISPLAY, primary ? PRIMARY : SECONDARY, className)}\n      {...props}\n      ref={setEl}\n      onPointerDown={(e) => {\n        press();\n        onPointerDown?.(e);\n      }}\n      onClick={click}\n    >\n      {children}\n      {primary && (\n        <svg\n          aria-hidden\n          viewBox=\"0 0 24 18\"\n          className=\"ml-[calc(var(--ok,0)*6px)] inline-block h-[18px] w-[calc(var(--ok,0)*24px)] [scale:var(--ok,0)] overflow-visible fill-none stroke-(--sk-acc) stroke-[4.4] align-[-2px] [stroke-linecap:round] [stroke-linejoin:round]\"\n        >\n          <path d=\"M3 9.5l6 6L21 2.5\" />\n        </svg>\n      )}\n    </ButtonPrimitive>\n  );\n\n  if (!primary) {\n    return (\n      <>\n        <SakugaStyle />\n        {button}\n      </>\n    );\n  }\n\n  return (\n    <span\n      data-slot=\"sakuga-button-stage\"\n      className={cn(\n        \"relative isolate inline-block align-middle text-[15px] leading-[1.4] font-medium text-(--sk-ink)\",\n        FONT_BODY,\n      )}\n    >\n      <SakugaStyle />\n      <canvas ref={attachBack} aria-hidden className={BACK_CANVAS} />\n      {button}\n    </span>\n  );\n};\n\nexport { SakugaButton };\n","path":"/sakuga-button.tsx","target":"uicapsule/sakuga-vfx/sakuga-button.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { Checkbox as CheckboxPrimitive } from \"@base-ui/react/checkbox\";\nimport { cn } from \"cn\";\nimport { useEffect, useLayoutEffect, useRef } from \"react\";\n\nimport { Spring, at, dotted, kira, later, lines, puff, sfx, shards, slash } from \"./sakuga-core\";\nimport { SakugaStyle, useFrame, useMergedRef } from \"./sakuga-react\";\nimport type { Styled } from \"./sakuga-react\";\n\ntype SakugaCheckboxProps = Styled<CheckboxPrimitive.Root.Props>;\n\nconst ROOT =\n  \"grid h-[38px] w-[38px] flex-none cursor-pointer place-items-center rounded-[9px] border-[length:var(--sk-bw)] border-(--sk-ink) bg-(--sk-card) shadow-(--sk-sh) will-change-transform [--sk-dash:30] [-webkit-tap-highlight-color:transparent] focus-visible:outline-[2.5px] focus-visible:outline-offset-[3px] focus-visible:outline-(--sk-acc) focus-visible:outline-solid data-checked:[--sk-dash:0] data-disabled:cursor-not-allowed data-disabled:opacity-50\";\n\nconst TICK =\n  \"h-[26px] w-[26px] fill-none stroke-(--sk-tick) stroke-[4.6] [stroke-dasharray:30] [stroke-dashoffset:var(--sk-dash)] [stroke-linecap:round] [stroke-linejoin:round] [transition:stroke-dashoffset_.24s_cubic-bezier(.2,.9,.3,1)_.08s]\";\n\ninterface Rig {\n  s: Spring;\n  hand: boolean | null;\n  quiet: boolean;\n}\n\nconst makeRig = () => {\n  const rig: Rig = { hand: null, quiet: false, s: new Spring(1, 600, 13) };\n\n  return rig;\n};\n\nconst land = (box: HTMLElement | null, rig: Rig, checked: boolean) => {\n  if (!box) {\n    return;\n  }\n\n  rig.s.x = 0.68;\n  const c = at(box);\n\n  if (checked) {\n    slash(c.x + 8, c.y + 2, { ang: -0.42, len: 150, life: 0.5, thick: 13 });\n    slash(c.x - 6, c.y + 12, { ang: 2.72, len: 110, life: 0.55, thick: 7 });\n    lines(c.x - 34, c.y + 26, { dir: 2.75, len: 60, n: 6, spread: 14 });\n    shards(c.x, c.y, { arc: 6.28, grav: 260, n: 6, size: 6, speed: 190 });\n    later(380, () => kira(c.x + 24, c.y - 22, { r: 9 }));\n    sfx(\"zuza\", c.x + 30, c.y - 62, { rot: -0.12, size: 112, ...dotted() });\n  } else {\n    puff(c.x, c.y, { life: 0.4, n: 3, size: 7 });\n  }\n};\n\nconst SakugaCheckbox = ({\n  className,\n  checked,\n  defaultChecked,\n  onCheckedChange,\n  inputRef,\n  ref,\n  ...props\n}: SakugaCheckboxProps) => {\n  const root = useRef<HTMLElement>(null);\n  const rigRef = useRef(makeRig());\n  const input = useRef<HTMLInputElement>(null);\n  const setRoot = useMergedRef<HTMLElement>(root, ref);\n  const setInput = useMergedRef(input, inputRef);\n\n  const change = (next: boolean, details: CheckboxPrimitive.Root.ChangeEventDetails) => {\n    onCheckedChange?.(next, details);\n    const rig = rigRef.current;\n\n    if (details.isCanceled || rig.quiet) {\n      return;\n    }\n\n    if (checked === undefined) {\n      land(root.current, rig, next);\n\n      return;\n    }\n\n    rig.hand = next;\n    later(0, () => {\n      rig.hand = null;\n    });\n  };\n\n  useLayoutEffect(() => {\n    const rig = rigRef.current;\n\n    if (checked !== undefined && rig.hand === checked) {\n      land(root.current, rig, checked);\n    }\n\n    rig.hand = null;\n  }, [checked]);\n\n  useEffect(() => {\n    const hidden = input.current;\n    const form = hidden?.form;\n\n    if (checked !== undefined || !hidden || !form) {\n      return;\n    }\n\n    const back = () => {\n      if (hidden.checked !== Boolean(defaultChecked)) {\n        rigRef.current.quiet = true;\n        hidden.click();\n        rigRef.current.quiet = false;\n      }\n    };\n\n    form.addEventListener(\"reset\", back);\n\n    return () => form.removeEventListener(\"reset\", back);\n  }, [checked, defaultChecked]);\n\n  useFrame((dt) => {\n    const y = rigRef.current.s.step(dt);\n\n    if (root.current) {\n      root.current.style.transform =\n        Math.abs(y - 1) < 0.001 ? \"\" : `scale(${y}) rotate(${(1 - y) * 20}deg)`;\n    }\n  });\n\n  return (\n    <>\n      <SakugaStyle />\n      <CheckboxPrimitive.Root\n        ref={setRoot}\n        inputRef={setInput}\n        data-slot=\"sakuga-checkbox\"\n        className={cn(ROOT, className)}\n        checked={checked}\n        defaultChecked={defaultChecked}\n        onCheckedChange={change}\n        {...props}\n      >\n        <CheckboxPrimitive.Indicator\n          data-slot=\"sakuga-checkbox-indicator\"\n          keepMounted\n          className=\"[display:contents]\"\n        >\n          <svg viewBox=\"0 0 20 20\" aria-hidden className={TICK}>\n            <path d=\"M3.5 10.5l4.5 4.5 8.5-10\" />\n          </svg>\n        </CheckboxPrimitive.Indicator>\n      </CheckboxPrimitive.Root>\n    </>\n  );\n};\n\nexport { SakugaCheckbox };\n","path":"/sakuga-checkbox.tsx","target":"uicapsule/sakuga-vfx/sakuga-checkbox.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { cn } from \"cn\";\nimport {\n  createContext,\n  use,\n  useCallback,\n  useEffect,\n  useLayoutEffect,\n  useMemo,\n  useRef,\n  useState,\n} from \"react\";\nimport type {\n  ChangeEvent,\n  ComponentProps,\n  KeyboardEvent,\n  PointerEvent,\n  ReactNode,\n  RefObject,\n} from \"react\";\n\nimport {\n  Spring,\n  at,\n  clock,\n  hollow,\n  isCalm,\n  later,\n  puff,\n  rnd,\n  sfx,\n  shards,\n  slash,\n  ticks,\n  wob,\n} from \"./sakuga-core\";\nimport { FONT_BODY, SakugaStyle, useFrame, useMergedRef } from \"./sakuga-react\";\n\ntype SakugaChipsProps = Omit<ComponentProps<\"span\">, \"defaultValue\" | \"onChange\"> & {\n  value?: readonly string[];\n  defaultValue?: readonly string[];\n  onValueChange?: (value: string[]) => void;\n  name?: string;\n  disabled?: boolean;\n  max?: number;\n};\n\ninterface Chips {\n  keyed: readonly { key: string; tag: string }[];\n  disabled: boolean;\n  fieldRef: RefObject<HTMLDivElement | null>;\n  chipElsRef: RefObject<Map<string, HTMLElement>>;\n  entryRef: RefObject<HTMLInputElement | null>;\n  cutLayerRef: RefObject<HTMLSpanElement | null>;\n  remove: (key: string) => void;\n  change: (e: ChangeEvent<HTMLInputElement>) => void;\n  keyDown: (e: KeyboardEvent<HTMLInputElement>) => void;\n  focus: () => void;\n  pointerDown: (e: PointerEvent<HTMLElement>) => void;\n}\n\nconst ChipsContext = createContext<Chips | null>(null);\nconst ChipContext = createContext<{ key: string; tag: string } | null>(null);\n\nconst useChips = () => {\n  const chips = use(ChipsContext);\n\n  if (!chips) {\n    throw new Error(\"Sakuga chips parts go inside a SakugaChips\");\n  }\n\n  return chips;\n};\n\nconst useChip = () => {\n  const chip = use(ChipContext);\n\n  if (!chip) {\n    throw new Error(\"A SakugaChip is drawn by a SakugaChipsList\");\n  }\n\n  return chip;\n};\n\nconst NONE: readonly string[] = [];\n\nconst HOLD = 0.2;\nconst LAG = 0.035;\nconst TRAIL = 0.05;\nconst LAND = 0.22;\nconst FLASH = 0.06;\nconst GONE = 0.14;\n\ninterface Motion {\n  sx: Spring;\n  sy: Spring;\n  pop: Spring;\n  squash: Spring;\n  tilt: Spring;\n  wait: number;\n  jump: boolean;\n  still: boolean;\n}\n\nconst makeMotion = () => {\n  const motion: Motion = {\n    jump: false,\n    pop: new Spring(1, 520, 18),\n    squash: new Spring(1, 600, 13),\n    still: true,\n    sx: new Spring(0, 320, 23),\n    sy: new Spring(0, 320, 23),\n    tilt: new Spring(0, 260, 10),\n    wait: 0,\n  };\n\n  return motion;\n};\n\ninterface Place {\n  left: number;\n  top: number;\n  width: number;\n  height: number;\n}\n\ninterface Ghost {\n  el: HTMLElement;\n  upper: HTMLElement;\n  lower: HTMLElement;\n  age: number;\n  part: Spring;\n  size: Spring;\n  plain: boolean;\n}\n\ninterface Ask {\n  added: ReadonlySet<string>;\n  removed: string | null;\n  rest: string;\n  height: number;\n}\n\nconst near = (s: Spring, to: number, by: number) =>\n  Math.abs(s.x - to) < by && Math.abs(s.v) < by * 10;\n\nconst pose = (el: HTMLElement, m: Motion, smear = 0.0004) => {\n  if (\n    near(m.sx, 0, 0.05) &&\n    near(m.sy, 0, 0.05) &&\n    near(m.pop, 1, 0.001) &&\n    near(m.squash, 1, 0.001) &&\n    near(m.tilt, 0, 0.02) &&\n    m.wait <= 0\n  ) {\n    m.still = true;\n    el.style.transform = \"\";\n\n    return;\n  }\n\n  const stretch = 1 + Math.min(0.3, Math.abs(m.sx.v) * smear);\n  const trail = (-Math.sign(m.sx.v) * (stretch - 1) * el.offsetWidth) / 2;\n  const p = m.pop.x;\n  const q = m.squash.x;\n  el.style.transform = `translate(${(m.sx.x + trail).toFixed(2)}px, ${m.sy.x.toFixed(2)}px) rotate(${m.tilt.x.toFixed(2)}deg) scale(${(p * stretch * (1 + (1 - q) * 0.5)).toFixed(3)}, ${((p * q) / Math.sqrt(stretch)).toFixed(3)})`;\n};\n\nconst advance = (m: Motion, dt: number) => {\n  if (m.wait > 0) {\n    m.wait -= dt;\n  } else if (m.jump) {\n    m.jump = false;\n    m.sx.x = 0;\n    m.sy.x = 0;\n  } else {\n    m.sx.step(dt);\n    m.sy.step(dt);\n  }\n\n  m.pop.step(dt);\n  m.squash.step(dt);\n  m.tilt.step(dt);\n};\n\nconst sendBack = (\n  el: HTMLElement,\n  m: Motion,\n  old: { left: number; top: number },\n  wait: number,\n  smear?: number,\n) => {\n  const dx = old.left - el.offsetLeft;\n  const dy = old.top - el.offsetTop;\n\n  if (dx === 0 && dy === 0) {\n    return false;\n  }\n\n  m.sx.x = dx;\n  m.sy.x = dy;\n  m.wait = wait;\n  m.still = false;\n  pose(el, m, smear);\n\n  return true;\n};\n\nconst cutApart = (g: Ghost, dt: number) => {\n  g.age += dt;\n  const flash = g.plain ? 0 : FLASH;\n  const gone = g.plain ? 0 : GONE;\n  g.el.toggleAttribute(\"data-inv\", g.age < flash);\n  const o = g.plain || g.age < flash ? 0 : g.part.step(dt);\n\n  if (g.age >= gone) {\n    g.size.to = 0;\n  }\n\n  const s = Math.max(0, g.size.step(dt));\n  g.upper.style.transform = `translate(${(o * 7).toFixed(2)}px, ${(o * -5).toFixed(2)}px) rotate(${(o * -6).toFixed(2)}deg) scale(${s.toFixed(3)})`;\n  g.lower.style.transform = `translate(${(o * -5).toFixed(2)}px, ${(o * 6).toFixed(2)}px) rotate(${(o * 5).toFixed(2)}deg) scale(${s.toFixed(3)})`;\n\n  return g.age >= gone && s < 0.04;\n};\n\nconst same = (a: string, b: string) => a.toLowerCase() === b.toLowerCase();\n\nconst keysOf = (tags: readonly string[]) => {\n  const seen = new Map<string, number>();\n\n  return tags.map((tag) => {\n    const n = seen.get(tag) ?? 0;\n    seen.set(tag, n + 1);\n\n    return { key: n === 0 ? tag : `${tag}\\n${n}`, tag };\n  });\n};\n\nconst CHIP =\n  \"inline-flex max-w-full items-center gap-[2px] rounded-[9px] bg-(--sk-card) py-[2px] pr-[3px] pl-[10px] text-[14px] leading-[1.2] font-bold text-(--sk-ink) border-[2.4px] border-(--sk-ink) shadow-[2.5px_3px_0_var(--sk-soft)]\";\n\nconst CROSS =\n  \"grid h-[21px] w-[21px] flex-none place-items-center rounded-full text-(--sk-ink) group-data-inv:text-(--sk-card)\";\n\nconst HALF =\n  \"absolute inset-0 group-data-inv:bg-(--sk-ink) group-data-inv:text-(--sk-card) will-change-transform\";\n\nconst UPPER =\n  \"[clip-path:polygon(-12px_-12px,calc(100%+12px)_-12px,calc(100%+12px)_14%,100%_14%,0_86%,-12px_86%)]\";\n\nconst LOWER =\n  \"[clip-path:polygon(-12px_86%,0_86%,100%_14%,calc(100%+12px)_14%,calc(100%+12px)_calc(100%+12px),-12px_calc(100%+12px))]\";\n\nconst FACE =\n  \"pointer-events-none absolute h-[4.8px] origin-left bg-(--sk-ink) group-data-inv:bg-(--sk-card)\";\n\nconst halfOf = (chip: HTMLElement, side: string, place: Place, plain: boolean) => {\n  const half = chip.cloneNode(true);\n\n  if (!(half instanceof HTMLElement)) {\n    return null;\n  }\n\n  delete half.dataset.chip;\n  half.style.transform = \"\";\n  half.classList.add(...HALF.split(\" \"), side);\n  const rise = place.height * 0.72;\n  const face = document.createElement(\"span\");\n  face.className = FACE;\n  face.style.left = \"-2.4px\";\n  face.style.top = `${(place.height * 0.86 - 4.8).toFixed(2)}px`;\n  face.style.width = `${Math.hypot(place.width, rise).toFixed(2)}px`;\n  face.style.transform = `rotate(${(-Math.atan2(rise, place.width)).toFixed(4)}rad)`;\n\n  if (!plain) {\n    half.append(face);\n  }\n\n  return half;\n};\n\nconst cutCopy = (layer: HTMLElement, chip: HTMLElement, place: Place) => {\n  const el = document.createElement(\"span\");\n  const plain = isCalm();\n  const upper = halfOf(chip, UPPER, place, plain);\n  const lower = halfOf(chip, LOWER, place, plain);\n\n  if (!upper || !lower) {\n    return null;\n  }\n\n  el.className = \"group absolute\";\n  el.inert = true;\n\n  if (!plain) {\n    el.dataset.inv = \"\";\n  }\n\n  el.style.left = `${place.left}px`;\n  el.style.top = `${place.top}px`;\n  el.style.width = `${place.width}px`;\n  el.style.height = `${place.height}px`;\n  el.append(upper, lower);\n  layer.append(el);\n  const part = new Spring(0, 300, 14);\n  part.to = 1;\n\n  return { age: 0, el, lower, part, plain, size: new Spring(1, 500, 26), upper };\n};\n\nconst Cross = () => (\n  <svg\n    aria-hidden\n    viewBox=\"0 0 10 10\"\n    className=\"h-[9px] w-[9px] overflow-visible fill-none stroke-current stroke-[2.6] [stroke-linecap:round]\"\n  >\n    <path d=\"M1.5 1.5l7 7M8.5 1.5l-7 7\" />\n  </svg>\n);\n\nconst SakugaChips = ({\n  value,\n  defaultValue = NONE,\n  onValueChange,\n  name,\n  disabled = false,\n  max,\n  className,\n  children,\n  ...props\n}: SakugaChipsProps) => {\n  const [own, setOwn] = useState<readonly string[]>(defaultValue);\n  const tags = value ?? own;\n  const keyed = keysOf(tags);\n\n  const field = useRef<HTMLDivElement>(null);\n  const entry = useRef<HTMLInputElement>(null);\n  const cutLayer = useRef<HTMLSpanElement>(null);\n  const status = useRef<HTMLOutputElement>(null);\n  const chipEls = useRef(new Map<string, HTMLElement>());\n  const chips = useRef<Map<string, HTMLElement> | null>(null);\n  const motions = useRef(new Map<string, Motion>());\n  const ghosts = useRef(new Set<Ghost>());\n  const before = useRef<Map<string, Place> | null>(null);\n  const boxBefore = useRef<{ left: number; top: number } | null>(null);\n  const asked = useRef<Ask | null>(null);\n  const follow = useRef(makeMotion());\n  const give = useRef(new Spring(1, 700, 16));\n  const shake = useRef(new Spring(0, 700, 14));\n  const quiet = useRef(false);\n  const spoke = useRef(-9);\n  const ruler = useRef<CanvasRenderingContext2D | null>(null);\n\n  const tell = (text: string) => {\n    if (status.current) {\n      status.current.textContent = text;\n    }\n  };\n\n  const speak = () => {\n    if (clock.now - spoke.current < 0.9) {\n      return false;\n    }\n\n    spoke.current = clock.now;\n\n    return true;\n  };\n\n  const arrive = (el: HTMLElement, m: Motion) => {\n    const box = field.current;\n\n    if (!box) {\n      return;\n    }\n\n    const c = at(el);\n    const f = at(box, 0.5, 0);\n    m.pop.x = 0.5;\n    m.squash.x = 0.74;\n    m.still = false;\n    pose(el, m);\n    puff(c.x, c.y + c.h / 2 + 9, { life: 0.45, n: 3, size: 5, vy: 3 });\n\n    if (speak()) {\n      sfx(\"pon\", c.x + 16, f.y - 30, { life: 0.8, rot: 0.06, size: 80, ...hollow() });\n    }\n  };\n\n  const cutAway = (chip: HTMLElement, place: Place, height: number) => {\n    const box = field.current;\n    const layer = cutLayer.current;\n\n    if (!box || !layer) {\n      return;\n    }\n\n    const ghost = cutCopy(layer, chip, place);\n\n    if (!ghost) {\n      return;\n    }\n\n    ghosts.current.add(ghost);\n    box.style.minHeight = `${height}px`;\n    const f = at(box, 0, 0);\n    const x = f.x + box.clientLeft + place.left + place.width / 2;\n    const y = f.y + box.clientTop + place.top + place.height / 2;\n    slash(x, y, { ang: -0.36, len: place.width + 64, life: 0.3, thick: 10 });\n\n    if (speak()) {\n      sfx(\"shu\", x + 6, f.y - 32, {\n        col: \"#5a4fd8\",\n        edge: \"#ffffff\",\n        life: 0.75,\n        rot: -0.16,\n        size: 92,\n      });\n    }\n\n    later(FLASH * 1000, () =>\n      shards(x + 6, y - 2, {\n        arc: 0.9,\n        dir: -0.36,\n        grav: 300,\n        life: 0.5,\n        n: 2,\n        size: 4,\n        speed: 80,\n      }),\n    );\n  };\n\n  const settle = (found: Map<string, HTMLElement>, old: Map<string, HTMLElement>) => {\n    const why = asked.current;\n    const was = before.current;\n    const added: string[] = [];\n\n    for (const [key, el] of found) {\n      const m = motions.current.get(key);\n\n      if (m && !old.has(key) && why?.added.has(key)) {\n        arrive(el, m);\n        added.push(key);\n      }\n    }\n\n    for (const [key, el] of old) {\n      const place = was?.get(key);\n\n      if (!found.has(key) && why?.removed === key && place) {\n        cutAway(el, place, why.height);\n        tell(`Removed ${key}`);\n      }\n    }\n\n    if (added.length > 0) {\n      for (const g of ghosts.current) {\n        g.el.remove();\n      }\n\n      ghosts.current.clear();\n    }\n\n    if (added.length > 0 && why && entry.current) {\n      entry.current.value = why.rest;\n      tell(`Added ${added.join(\", \")}`);\n    }\n\n    return added.length > 0;\n  };\n\n  useLayoutEffect(() => {\n    const box = field.current;\n    const inp = entry.current;\n\n    if (!box || !inp) {\n      return;\n    }\n\n    const found = new Map<string, HTMLElement>();\n\n    for (const { key } of keyed) {\n      const el = chipEls.current.get(key);\n\n      if (el) {\n        found.set(key, el);\n\n        if (!motions.current.has(key)) {\n          motions.current.set(key, makeMotion());\n        }\n      }\n    }\n\n    const old = chips.current;\n    chips.current = found;\n    const was = before.current;\n    const stood = boxBefore.current;\n    const grew = old ? settle(found, old) : false;\n    before.current = null;\n    boxBefore.current = null;\n    asked.current = null;\n    let moved = 0;\n\n    for (const [key, el] of found) {\n      const m = motions.current.get(key);\n      const place = was?.get(key);\n\n      if (m && place && sendBack(el, m, place, HOLD + moved * LAG)) {\n        moved += 1;\n      }\n    }\n\n    const f = follow.current;\n\n    if (grew) {\n      f.sx.x = 0;\n      f.sy.x = 0;\n      f.sx.v = 0;\n      f.sy.v = 0;\n      f.wait = 0;\n      f.jump = false;\n      pose(inp, f, 0);\n    } else if (stood && sendBack(inp, f, stood, HOLD + moved * LAG + TRAIL, 0)) {\n      f.jump = f.sy.x !== 0;\n      f.wait += f.jump ? LAND : 0;\n    }\n\n    for (const key of motions.current.keys()) {\n      if (!found.has(key)) {\n        motions.current.delete(key);\n      }\n    }\n  });\n\n  useFrame((dt) => {\n    const box = field.current;\n\n    if (box) {\n      const y = give.current.step(dt);\n      const x = shake.current.step(dt);\n      box.style.transform =\n        Math.abs(y - 1) < 0.0006 && Math.abs(x) < 0.05\n          ? \"\"\n          : `translateX(${x.toFixed(2)}px) scale(${y})`;\n    }\n\n    for (const [key, m] of motions.current) {\n      const el = chips.current?.get(key);\n\n      if (el && !m.still) {\n        advance(m, dt);\n        pose(el, m);\n      }\n    }\n\n    if (entry.current && !follow.current.still) {\n      advance(follow.current, dt);\n      pose(entry.current, follow.current, 0);\n    }\n\n    for (const g of ghosts.current) {\n      if (cutApart(g, dt)) {\n        g.el.remove();\n        ghosts.current.delete(g);\n      }\n    }\n\n    if (\n      box &&\n      box.style.minHeight !== \"\" &&\n      ghosts.current.size === 0 &&\n      Math.abs(follow.current.sy.x) < 3\n    ) {\n      box.style.minHeight = \"\";\n    }\n  });\n\n  const ask = (next: string[], why: Omit<Ask, \"height\">) => {\n    const places = new Map<string, Place>();\n\n    for (const [key, el] of chips.current ?? []) {\n      const m = motions.current.get(key);\n      places.set(key, {\n        height: el.offsetHeight,\n        left: el.offsetLeft + (m?.sx.x ?? 0),\n        top: el.offsetTop + (m?.sy.x ?? 0),\n        width: el.offsetWidth,\n      });\n    }\n\n    before.current = places;\n    const inp = entry.current;\n\n    if (inp) {\n      boxBefore.current = {\n        left: inp.offsetLeft + follow.current.sx.x,\n        top: inp.offsetTop + follow.current.sy.x,\n      };\n    }\n\n    asked.current = { ...why, height: field.current?.offsetHeight ?? 0 };\n    setOwn(next);\n    onValueChange?.(next);\n  };\n\n  const jolt = (key: string) => {\n    const el = chips.current?.get(key);\n    const m = motions.current.get(key);\n\n    if (!el || !m) {\n      return;\n    }\n\n    const c = at(el);\n    m.tilt.x = -9;\n    m.squash.x = 0.82;\n    m.still = false;\n    ticks(c.x, c.y - c.h / 2 - 5, { dir: -Math.PI / 2, fan: 0.5, len: 11, life: 0.4, n: 3, r: 4 });\n  };\n\n  const refuse = () => {\n    const box = field.current;\n\n    if (!box) {\n      return;\n    }\n\n    const c = at(box);\n    shake.current.x = 7;\n    wob(c.x - c.w / 2 - 8, c.y, { dir: -1 });\n    wob(c.x + c.w / 2 + 8, c.y, { dir: 1 });\n  };\n\n  const add = (words: readonly string[], tail: string) => {\n    const next = [...tags];\n    const kept: string[] = [];\n\n    for (const word of words) {\n      const tag = word.trim();\n      const twin = keyed.find((k) => same(k.tag, tag));\n      const fits = tag !== \"\" && !next.some((t) => same(t, tag));\n\n      if (twin) {\n        jolt(twin.key);\n        tell(`${twin.tag} is already added`);\n        kept.push(tag);\n      } else if (fits && max !== undefined && next.length >= max) {\n        refuse();\n        tell(`No more than ${max} tags`);\n        kept.push(tag);\n      } else if (fits) {\n        next.push(tag);\n      }\n    }\n\n    const rest = [...kept, tail.trim()].filter((word) => word !== \"\").join(\", \");\n\n    if (next.length > tags.length) {\n      ask(next, { added: new Set(next.slice(tags.length)), removed: null, rest });\n    } else if (entry.current && words.length > 1) {\n      entry.current.value = rest;\n    }\n  };\n\n  const remove = (key: string) => {\n    ask(\n      keyed.filter((k) => k.key !== key).map((k) => k.tag),\n      { added: new Set(), removed: key, rest: \"\" },\n    );\n\n    if (document.activeElement !== entry.current) {\n      quiet.current = true;\n      entry.current?.focus();\n      quiet.current = false;\n    }\n  };\n\n  const dust = (inp: HTMLInputElement) => {\n    const m = ruler.current ?? document.createElement(\"canvas\").getContext(\"2d\");\n    ruler.current = m;\n\n    if (!m) {\n      return;\n    }\n\n    const cs = getComputedStyle(inp);\n    m.font = `${cs.fontWeight} ${cs.fontSize} ${cs.fontFamily}`;\n    const shown = inp.value.slice(0, inp.selectionStart ?? inp.value.length);\n    const c = at(inp, 0, 0.5);\n    const x = c.x + 2 + Math.min(c.w - 4, m.measureText(shown).width);\n    give.current.x = 0.985;\n    const size = rnd(4, 6);\n    const vx = rnd(-10, 10);\n    puff(x, c.y + 10, { life: 0.4, n: 2, size, vx, vy: -22 });\n\n    if (rnd() < 0.35) {\n      shards(x, c.y + 6, { life: 0.5, n: 2, size: 3, speed: 110 });\n    }\n  };\n\n  const change = (e: ChangeEvent<HTMLInputElement>) => {\n    const inp = e.currentTarget;\n\n    if (inp.value.includes(\",\")) {\n      const words = inp.value.split(\",\");\n      const tail = words.pop() ?? \"\";\n      add([...words, \"\"], tail);\n\n      return;\n    }\n\n    dust(inp);\n  };\n\n  const keyDown = (e: KeyboardEvent<HTMLInputElement>) => {\n    const inp = e.currentTarget;\n    const last = keyed.at(-1);\n\n    if (e.nativeEvent.isComposing) {\n      return;\n    }\n\n    if (e.key === \"Enter\" && inp.value.trim() !== \"\") {\n      e.preventDefault();\n      add([inp.value], \"\");\n    } else if (e.key === \"Backspace\" && inp.value === \"\" && last) {\n      e.preventDefault();\n      remove(last.key);\n    }\n  };\n\n  const focus = () => {\n    const box = field.current;\n\n    if (!box || quiet.current) {\n      return;\n    }\n\n    const c = at(box, 1, 0);\n    give.current.x = 1.04;\n    ticks(c.x - 6, c.y - 4, { dir: -1.05, fan: 0.36, len: 17, life: 0.5, n: 3, r: 5 });\n  };\n\n  const pointerDown = (e: PointerEvent<HTMLElement>) => {\n    if (e.target !== entry.current && !disabled) {\n      e.preventDefault();\n\n      if (!(e.target instanceof Element && e.target.closest(\"button\"))) {\n        entry.current?.focus();\n      }\n    }\n  };\n\n  const controlled = value !== undefined;\n  const initial = useRef(defaultValue);\n  useEffect(() => {\n    const form = status.current?.form;\n\n    if (!form || controlled) {\n      return;\n    }\n\n    const restore = () => setOwn(initial.current);\n    form.addEventListener(\"reset\", restore);\n\n    return () => form.removeEventListener(\"reset\", restore);\n  }, [controlled]);\n\n  const live = useRef({ change, focus, keyDown, pointerDown, remove });\n  useLayoutEffect(() => {\n    live.current = { change, focus, keyDown, pointerDown, remove };\n  });\n\n  const parts = useMemo<Chips>(\n    () => ({\n      change: (e) => live.current.change(e),\n      chipElsRef: chipEls,\n      cutLayerRef: cutLayer,\n      disabled,\n      entryRef: entry,\n      fieldRef: field,\n      focus: () => live.current.focus(),\n      keyDown: (e) => live.current.keyDown(e),\n      keyed,\n      pointerDown: (e) => live.current.pointerDown(e),\n      remove: (key) => live.current.remove(key),\n    }),\n    [disabled, keyed],\n  );\n\n  return (\n    <span\n      data-slot=\"sakuga-chips\"\n      data-disabled={disabled ? \"\" : undefined}\n      className={cn(\n        \"relative isolate inline-block w-[270px] max-w-full align-middle text-[15px] leading-[1.4] font-medium text-(--sk-ink)\",\n        FONT_BODY,\n        className,\n      )}\n      {...props}\n    >\n      <SakugaStyle />\n      <ChipsContext value={parts}>{children}</ChipsContext>\n      {name !== undefined &&\n        keyed.map(({ key, tag }) => (\n          <input key={key} type=\"hidden\" name={name} value={tag} disabled={disabled} />\n        ))}\n      <output ref={status} className=\"sr-only\" />\n    </span>\n  );\n};\n\nconst SakugaChipRemove = ({ className, children, onClick, ...props }: ComponentProps<\"button\">) => {\n  const { disabled, remove } = useChips();\n  const { key, tag } = useChip();\n\n  return (\n    <button\n      type=\"button\"\n      data-slot=\"sakuga-chip-remove\"\n      aria-label={`Remove ${tag}`}\n      disabled={disabled}\n      data-disabled={disabled ? \"\" : undefined}\n      className={cn(\n        CROSS,\n        \"cursor-pointer hover:bg-(--sk-soft) focus-visible:outline-[2.5px] focus-visible:outline-offset-[1px] focus-visible:outline-(--sk-acc) data-disabled:cursor-not-allowed\",\n        className,\n      )}\n      {...props}\n      onClick={(e) => {\n        onClick?.(e);\n\n        if (!e.defaultPrevented) {\n          remove(key);\n        }\n      }}\n    >\n      {children ?? <Cross />}\n    </button>\n  );\n};\n\nconst SakugaChip = ({ className, children, ref, ...props }: ComponentProps<\"span\">) => {\n  const { chipElsRef } = useChips();\n  const { key, tag } = useChip();\n\n  const enrol = useCallback(\n    (node: HTMLSpanElement | null) => {\n      if (!node) {\n        return;\n      }\n\n      const els = chipElsRef.current;\n      els.set(key, node);\n\n      return () => {\n        els.delete(key);\n      };\n    },\n    [chipElsRef, key],\n  );\n\n  return (\n    <span\n      ref={useMergedRef(enrol, ref)}\n      data-slot=\"sakuga-chip\"\n      data-chip={key}\n      className={cn(CHIP, \"will-change-transform\", className)}\n      {...props}\n    >\n      {children ?? (\n        <>\n          <span className=\"truncate\">{tag}</span>\n          <SakugaChipRemove />\n        </>\n      )}\n    </span>\n  );\n};\n\nconst plainChip = () => <SakugaChip />;\n\nconst SakugaChipsList = ({\n  className,\n  children,\n  renderChip = plainChip,\n  onPointerDown,\n  ref,\n  \"aria-label\": label,\n  \"aria-labelledby\": labelledBy,\n  ...props\n}: ComponentProps<\"div\"> & {\n  renderChip?: (tag: string) => ReactNode;\n}) => {\n  const { keyed, disabled, fieldRef, cutLayerRef, pointerDown } = useChips();\n\n  return (\n    <div\n      ref={useMergedRef(fieldRef, ref)}\n      // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- a <fieldset> paints its border by the browser's own fieldset rules, which moves pixels along the 3.2px edge; a div with the group role draws like every other card\n      role=\"group\"\n      data-slot=\"sakuga-chips-list\"\n      data-disabled={disabled ? \"\" : undefined}\n      aria-label={labelledBy === undefined ? (label ?? \"Tags\") : label}\n      aria-labelledby={labelledBy}\n      className={cn(\n        \"relative flex cursor-text flex-wrap content-start items-center gap-x-[7px] gap-y-[8px] rounded-(--sk-r) bg-(--sk-card) px-[11px] py-[10px] shadow-(--sk-sh) will-change-transform border-[length:var(--sk-bw)] border-(--sk-ink) has-[input:focus-visible]:outline-[2.5px] has-[input:focus-visible]:outline-offset-[3px] has-[input:focus-visible]:outline-(--sk-acc) has-[input:focus-visible]:outline-solid data-disabled:cursor-not-allowed data-disabled:opacity-50\",\n        className,\n      )}\n      {...props}\n      onPointerDown={(e) => {\n        onPointerDown?.(e);\n        pointerDown(e);\n      }}\n    >\n      {keyed.map((chip) => (\n        <ChipContext key={chip.key} value={chip}>\n          {renderChip(chip.tag)}\n        </ChipContext>\n      ))}\n      {children}\n      <span ref={cutLayerRef} aria-hidden className=\"pointer-events-none absolute inset-0 z-10\" />\n    </div>\n  );\n};\n\nconst SakugaChipsInput = ({\n  className,\n  onChange,\n  onKeyDown,\n  onFocus,\n  ref,\n  \"aria-label\": label,\n  \"aria-labelledby\": labelledBy,\n  ...props\n}: Omit<ComponentProps<\"input\">, \"value\" | \"defaultValue\" | \"type\">) => {\n  const { disabled, entryRef, change, keyDown, focus } = useChips();\n\n  return (\n    <input\n      ref={useMergedRef(entryRef, ref)}\n      type=\"text\"\n      data-slot=\"sakuga-chips-input\"\n      aria-label={labelledBy === undefined ? (label ?? \"Tags\") : label}\n      aria-labelledby={labelledBy}\n      disabled={disabled}\n      data-disabled={disabled ? \"\" : undefined}\n      autoComplete=\"off\"\n      enterKeyHint=\"done\"\n      className={cn(\n        \"h-[30px] w-0 min-w-[84px] flex-1 bg-transparent px-[2px] text-[16px] font-semibold text-(--sk-ink) caret-(--sk-ink) outline-none placeholder:text-(--sk-dim) data-disabled:cursor-not-allowed\",\n        className,\n      )}\n      {...props}\n      onChange={(e) => {\n        onChange?.(e);\n        change(e);\n      }}\n      onKeyDown={(e) => {\n        onKeyDown?.(e);\n\n        if (!e.defaultPrevented) {\n          keyDown(e);\n        }\n      }}\n      onFocus={(e) => {\n        onFocus?.(e);\n        focus();\n      }}\n    />\n  );\n};\n\nexport { SakugaChips, SakugaChipsList, SakugaChip, SakugaChipRemove, SakugaChipsInput };\n","path":"/sakuga-chips.tsx","target":"uicapsule/sakuga-vfx/sakuga-chips.tsx","type":"registry:file"},{"content":"import { WORDS } from \"./sakuga-words\";\nimport type { WordName } from \"./sakuga-words\";\n\nexport const TAU = Math.PI * 2;\nexport const clamp = (v: number, a = 0, b = 1) => Math.min(b, Math.max(a, v));\nexport const lerp = (a: number, b: number, t: number) => a + (b - a) * t;\n\nexport const rnd = (a = 1, b?: number) =>\n  b === undefined ? Math.random() * a : a + Math.random() * (b - a);\n\nexport const easeOut = (t: number) => 1 - (1 - t) ** 3;\nexport const easeIn = (t: number) => t ** 3;\nexport const easeBack = (t: number) => 1 + 2.70158 * (t - 1) ** 3 + 1.70158 * (t - 1) ** 2;\n\nexport class Spring {\n  x: number;\n  v = 0;\n  to: number;\n  k: number;\n  d: number;\n\n  constructor(x = 0, k = 300, d = 20) {\n    this.x = x;\n    this.to = x;\n    this.k = k;\n    this.d = d;\n  }\n\n  step(dt: number) {\n    if (!(dt > 0)) {\n      return this.x;\n    }\n\n    const n = Math.ceil(dt / 0.008);\n    const h = dt / n;\n\n    for (let i = 0; i < n; i += 1) {\n      this.v += (-this.k * (this.x - this.to) - this.d * this.v) * h;\n      this.x += this.v * h;\n    }\n\n    return this.x;\n  }\n}\n\nexport const P = {\n  accent: \"#ff5fa8\",\n  fill: \"#ffffff\",\n  ink: \"#1d1a4a\",\n  line: \"#5a4fd8\",\n  sfx: [\"#1d1a4a\", \"#ffffff\"],\n  shade: \"#b8b3ff\",\n} as const;\n\ntype Draw = (k: number, t: number, dt: number) => void;\n\nexport interface Effect {\n  t: number;\n  life: number;\n  draw: Draw;\n  dead?: boolean;\n}\n\nexport interface Layer {\n  c: HTMLCanvasElement | null;\n  g: CanvasRenderingContext2D | null;\n  live: Effect[];\n  dirty: boolean;\n}\n\nconst front: Layer = { c: null, dirty: false, g: null, live: [] };\nconst layers: Layer[] = [front];\nlet dpr = 1;\nlet calmQuery: MediaQueryList | null = null;\n\nlet g!: CanvasRenderingContext2D;\nexport const pen = () => g;\n\nexport const fillPath = (path: Path2D, rule?: CanvasFillRule) => {\n  g.fill(path, rule);\n};\n\nexport const isCalm = () => {\n  calmQuery ??= matchMedia(\"(prefers-reduced-motion: reduce)\");\n\n  return calmQuery.matches;\n};\n\nconst size = () => {\n  dpr = Math.min(2.5, devicePixelRatio || 1);\n\n  if (front.c) {\n    front.c.width = innerWidth * dpr;\n    front.c.height = innerHeight * dpr;\n  }\n};\n\nconst ensureFront = () => {\n  if (front.c?.isConnected) {\n    return;\n  }\n\n  const c = document.createElement(\"canvas\");\n  c.setAttribute(\"aria-hidden\", \"true\");\n  c.dataset.sakugaFx = \"\";\n  c.style.cssText =\n    \"position:fixed;inset:0;width:100vw;height:100vh;pointer-events:none;z-index:2147483000\";\n  document.body.append(c);\n\n  if (!front.c) {\n    addEventListener(\"resize\", size);\n  }\n\n  front.c = c;\n  front.g = c.getContext(\"2d\");\n  size();\n};\n\nexport const addBackLayer = (canvas: HTMLCanvasElement) => {\n  const layer: Layer = { c: canvas, dirty: false, g: canvas.getContext(\"2d\"), live: [] };\n  layers.push(layer);\n\n  return layer;\n};\n\nexport const removeBackLayer = (layer: Layer) => {\n  const i = layers.indexOf(layer);\n\n  if (i > 0) {\n    layers.splice(i, 1);\n  }\n};\n\ntype FrameFn = (dt: number) => void;\n\nconst frames = new Set<FrameFn>();\nconst timers: { at: number; f: () => void }[] = [];\nlet now = 0;\nlet last = 0;\nlet running = false;\n\nconst drawLayer = (layer: Layer, dt: number) => {\n  const { c, g: ctx } = layer;\n\n  if (!c || !ctx || (layer.live.length === 0 && !layer.dirty)) {\n    return;\n  }\n\n  let ox = scrollX;\n  let oy = scrollY;\n\n  if (layer !== front) {\n    if (!c.isConnected) {\n      layer.live = [];\n      layer.dirty = false;\n\n      return;\n    }\n\n    const r = c.getBoundingClientRect();\n    const w = Math.round(r.width * dpr);\n    const h = Math.round(r.height * dpr);\n\n    if (c.width !== w) {\n      c.width = w;\n    }\n\n    if (c.height !== h) {\n      c.height = h;\n    }\n\n    ox += r.left;\n    oy += r.top;\n  }\n\n  g = ctx;\n  g.setTransform(dpr, 0, 0, dpr, 0, 0);\n  g.clearRect(0, 0, c.width / dpr, c.height / dpr);\n  g.translate(-ox, -oy);\n  g.lineJoin = \"round\";\n  g.lineCap = \"round\";\n  layer.live = layer.live.filter((p) => {\n    p.t += dt;\n\n    return !p.dead && p.t < p.life;\n  });\n\n  for (const p of layer.live) {\n    g.save();\n    p.draw(p.t / p.life, p.t, dt);\n    g.restore();\n  }\n\n  layer.dirty = layer.live.length > 0;\n};\n\nconst advance = (dt: number) => {\n  now += dt;\n  const due = timers.filter((q) => q.at <= now).toSorted((a, b) => a.at - b.at);\n\n  for (const q of due) {\n    timers.splice(timers.indexOf(q), 1);\n  }\n\n  for (const q of due) {\n    q.f();\n  }\n\n  for (const f of frames) {\n    f(dt);\n  }\n\n  for (const layer of layers) {\n    drawLayer(layer, dt);\n  }\n};\n\nexport const clock = {\n  advance,\n  get now() {\n    return now;\n  },\n  paused: false,\n};\n\nconst idle = () =>\n  frames.size === 0 && timers.length === 0 && layers.every((l) => l.live.length === 0 && !l.dirty);\n\nconst loop = (ms: number) => {\n  if (!running) {\n    return;\n  }\n\n  const dt = clamp((ms - last) / 1000, 0, 0.034);\n  last = ms;\n\n  if (!clock.paused) {\n    advance(dt);\n  }\n\n  if (idle()) {\n    running = false;\n\n    return;\n  }\n\n  requestAnimationFrame(loop);\n};\n\nconst start = () => {\n  if (running) {\n    return;\n  }\n\n  running = true;\n  last = performance.now();\n  requestAnimationFrame(loop);\n};\n\nexport const later = (ms: number, f: () => void) => {\n  timers.push({ at: now + ms / 1000, f });\n  start();\n};\n\nexport const onFrame = (fn: FrameFn) => {\n  frames.add(fn);\n  start();\n\n  return () => {\n    frames.delete(fn);\n  };\n};\n\nconst add = (life: number, draw: Draw, layer: Layer = front) => {\n  const p: Effect = { draw, life, t: 0 };\n\n  if (!isCalm()) {\n    if (layer === front) {\n      ensureFront();\n    }\n\n    layer.live.push(p);\n    start();\n  }\n\n  return p;\n};\n\nexport const persist = (draw: Draw, layer?: Layer) => add(Infinity, draw, layer);\n\ntype Circle = readonly [x: number, y: number, r: number];\n\nconst paintShade = () => {\n  g.fillStyle = P.shade;\n  g.fillRect(-1e4, -1e4, 2e4, 2e4);\n};\n\nexport const blob = (\n  cs: readonly Circle[],\n  lw = 1.5,\n  { lx = -1, arcs = false, deep = 1 }: { lx?: number; arcs?: boolean; deep?: number } = {},\n) => {\n  const u = new Path2D();\n\n  for (const [x, y, r] of cs) {\n    if (r > 0.3) {\n      u.moveTo(x + r, y);\n      u.arc(x, y, r, 0, TAU);\n    }\n  }\n\n  g.save();\n  g.lineWidth = lw * 2;\n  g.strokeStyle = P.line;\n  g.stroke(u);\n  g.restore();\n  g.save();\n  g.clip(u);\n  paintShade();\n  const r = cs[0]?.[2] ?? 8;\n  g.save();\n  g.translate(lx * r * 0.2 * deep, -r * 0.26 * deep);\n  g.fillStyle = P.fill;\n  fillPath(u);\n  g.restore();\n\n  if (arcs) {\n    g.strokeStyle = P.line;\n    g.lineWidth = lw * 0.75;\n    g.beginPath();\n\n    for (const [x, y, rr] of cs) {\n      if (rr > 3) {\n        g.moveTo(x + Math.cos(-2.7) * rr, y + Math.sin(-2.7) * rr);\n        g.arc(x, y, rr, -2.7, -0.5);\n      }\n    }\n\n    g.stroke();\n  }\n\n  g.restore();\n};\n\nexport const toon = (path: Path2D, lw = 1.5, off = 3, fill: string = P.fill) => {\n  g.save();\n  g.lineWidth = lw * 2;\n  g.strokeStyle = P.line;\n  g.stroke(path);\n  g.restore();\n  g.save();\n  g.clip(path);\n  paintShade();\n  g.translate(-off * 0.7, -off);\n  g.fillStyle = fill;\n  fillPath(path);\n  g.restore();\n};\n\nexport const puff = (\n  x: number,\n  y: number,\n  { n = 5, size: sz = 13, vx = 0, vy = -18, life = 0.8, spread = 1 } = {},\n) => {\n  const lobes = Array.from({ length: n }, (_, i) => {\n    const a = (i / n) * TAU + rnd(0.6);\n    const d = rnd(0.25, 0.9) * sz * spread;\n    const r = rnd(0.55, 1) * sz;\n    const ph = rnd(TAU);\n    const sp = rnd(0.6, 1.3);\n\n    return { a, d, ph, r, sp };\n  });\n\n  lobes.unshift({ a: 0, d: 0, ph: 0, r: sz, sp: 1 });\n  add(life, (k, t) => {\n    const grow = easeBack(clamp(t / 0.22));\n    const die = 1 - easeIn(clamp((k - 0.55) / 0.45));\n    const px = x + vx * easeOut(k) * life;\n    const py = y + vy * easeOut(k) * life;\n    const reach = 0.5 + easeOut(k) * 0.9;\n    blob(\n      lobes.map<Circle>((l) => {\n        const a = l.a + t * 0.9 * l.sp;\n\n        return [\n          px + Math.cos(a) * l.d * reach,\n          py + Math.sin(a) * l.d * reach - easeOut(k) * 5 * l.sp,\n          l.r * grow * die * (1 + Math.sin(t * 9 + l.ph) * 0.05),\n        ];\n      }),\n      1.5,\n      { arcs: sz > 6.5, deep: 1.5, lx: 0.5 },\n    );\n  });\n};\n\nexport const burst = (\n  x: number,\n  y: number,\n  { r = 44, spikes = 13, life = 0.34, layer }: BurstOptions = {},\n) => {\n  const j = Array.from({ length: spikes * 2 }, (_, i) =>\n    i % 2 ? rnd(0.34, 0.5) : rnd(0.75, 1.15),\n  );\n\n  const rot = rnd(TAU);\n\n  const pins = Array.from({ length: 8 }, (_, i) => ({\n    a: (i / 8) * TAU + rnd(0.5),\n    l: rnd(1.25, 1.75),\n    w: rnd(0.03, 0.055),\n  }));\n\n  const star = (R: number, turn: number, inner: number) => {\n    const p = new Path2D();\n\n    for (const [i, m] of j.entries()) {\n      const a = rot + turn + (i / j.length) * TAU;\n      const rr = R * (i % 2 ? m * inner : m);\n      const px = x + Math.cos(a) * rr;\n      const py = y + Math.sin(a) * rr;\n\n      if (i === 0) {\n        p.moveTo(px, py);\n      } else {\n        p.lineTo(px, py);\n      }\n    }\n\n    p.closePath();\n\n    return p;\n  };\n\n  add(\n    life,\n    (k) => {\n      const R = r * easeOut(clamp(k / 0.3));\n      const hollowing = 1 + easeIn(clamp((k - 0.35) / 0.65)) * 1.3;\n      const r0 = R * 0.6 * Math.min(1.9, hollowing);\n      g.save();\n      g.fillStyle = P.accent;\n      g.beginPath();\n\n      for (const n of pins) {\n        const l = R * n.l;\n\n        if (l > r0) {\n          g.moveTo(x + Math.cos(n.a - n.w) * r0, y + Math.sin(n.a - n.w) * r0);\n          g.lineTo(x + Math.cos(n.a) * l, y + Math.sin(n.a) * l);\n          g.lineTo(x + Math.cos(n.a + n.w) * r0, y + Math.sin(n.a + n.w) * r0);\n        }\n      }\n\n      g.fill();\n      g.restore();\n      const big = star(R * 1.16, 0.19, hollowing);\n      g.save();\n      g.fillStyle = P.shade;\n      fillPath(big);\n      g.strokeStyle = P.line;\n      g.lineWidth = 1.2;\n      g.stroke(big);\n      g.restore();\n      toon(star(R * 0.84, 0, hollowing), 1.4, 3);\n    },\n    layer,\n  );\n};\n\nexport interface BurstOptions {\n  r?: number;\n  spikes?: number;\n  life?: number;\n  layer?: Layer;\n}\n\nconst polygon = (pts: readonly (readonly [number, number])[], scale: number) => {\n  const p = new Path2D();\n\n  for (const [i, [u, w]] of pts.entries()) {\n    if (i === 0) {\n      p.moveTo(u * scale, w * scale);\n    } else {\n      p.lineTo(u * scale, w * scale);\n    }\n  }\n\n  p.closePath();\n\n  return p;\n};\n\nconst SHARD: readonly (readonly [number, number])[] = [\n  [-1.4, 0.1],\n  [-0.6, -0.7],\n  [1.2, -0.45],\n  [1.5, 0.15],\n  [0.4, 0.75],\n];\n\nconst shard = (\n  x: number,\n  y: number,\n  {\n    speed,\n    sz,\n    life,\n    dir,\n    arc,\n    grav,\n  }: Record<\"speed\" | \"sz\" | \"life\" | \"dir\" | \"arc\" | \"grav\", number>,\n) => {\n  const a = dir + rnd(-arc, arc) / 2;\n  const v = speed * rnd(0.5, 1.15);\n  const s = sz * rnd(0.6, 1.4);\n  const spin = rnd(-7, 7);\n  const pts = SHARD.map(([px, py]) => [px * rnd(0.8, 1.2), py * rnd(0.8, 1.2)] as const);\n  const edgeA = pts.at(1);\n  const edgeB = pts.at(4);\n  add(life * rnd(0.7, 1), (k, t) => {\n    const px = x + Math.cos(a) * v * t;\n    const py = y + Math.sin(a) * v * t + grav * t * t;\n    const sc = s * (1 - easeIn(clamp((k - 0.6) / 0.4)));\n    g.translate(px, py);\n    g.rotate(spin * t + a);\n    toon(polygon(pts, sc), 1.1, sc * 0.45, P.fill);\n\n    if (sc > 2.5 && edgeA && edgeB) {\n      g.strokeStyle = P.line;\n      g.lineWidth = 0.9;\n      g.beginPath();\n      g.moveTo(edgeA[0] * sc, edgeA[1] * sc);\n      g.lineTo(edgeB[0] * sc, edgeB[1] * sc);\n      g.stroke();\n    }\n  });\n};\n\nexport const shards = (\n  x: number,\n  y: number,\n  {\n    n = 7,\n    speed = 190,\n    size: sz = 5,\n    life = 0.75,\n    dir = -Math.PI / 2,\n    arc = Math.PI,\n    grav = 420,\n  } = {},\n) => {\n  for (let i = 0; i < n; i += 1) {\n    shard(x, y, { arc, dir, grav, life, speed, sz });\n  }\n};\n\nexport const ring = (x: number, y: number, { rx = 40, ry = 12, life = 0.5, w = 5 } = {}) => {\n  add(life, (k) => {\n    const s = easeOut(k);\n    const lw = w * (1 - k);\n    g.beginPath();\n    g.ellipse(x, y, rx * (0.3 + s), ry * (0.3 + s), 0, 0, TAU);\n    g.strokeStyle = P.line;\n    g.lineWidth = lw + 2.4;\n    g.stroke();\n    g.strokeStyle = P.fill;\n    g.lineWidth = lw;\n\n    if (lw > 0.3) {\n      g.stroke();\n    }\n  });\n};\n\nconst splashDrop = (x: number, y: number, life: number) => {\n  const a = -Math.PI / 2 + rnd(-1.1, 1.1);\n  const v = rnd(100, 210);\n  const r0 = rnd(2, 4);\n  add(life * rnd(0.8, 1.15), (k, t) => {\n    const px = x + Math.cos(a) * v * t;\n    const py = y - 6 + Math.sin(a) * v * t + 520 * t * t;\n    const r = r0 * (1 - easeIn(clamp((k - 0.6) / 0.4)));\n    const ang = Math.atan2(Math.sin(a) * v + 1040 * t, Math.cos(a) * v);\n    const d = new Path2D();\n    g.translate(px, py);\n    g.rotate(ang);\n    d.moveTo(-r * 2.6, 0);\n    d.quadraticCurveTo(-r * 0.6, -r * 1.05, r * 0.5, -r * 0.9);\n    d.arc(r * 0.4, 0, r * 0.95, -1.4, 1.4);\n    d.quadraticCurveTo(-r * 0.6, r * 1.05, -r * 2.6, 0);\n\n    if (r > 0.5) {\n      toon(d, 1, r * 0.5);\n    }\n  });\n};\n\nexport const splash = (x: number, y: number, { w = 34, h = 26, life = 0.7 } = {}) => {\n  const n = 7;\n\n  const ts = Array.from({ length: n }, (_, i) => {\n    const u = i / (n - 1) - 0.5;\n    const tall = h * rnd(0.55, 1.1) * (1 - Math.abs(u) * 0.7);\n    const lean = rnd(-0.4, 0.4);\n    const d = rnd(0, 0.14);\n\n    return { d, h: tall, lean, u };\n  });\n\n  add(life, (k) => {\n    const p = new Path2D();\n    const tips: [number, number, number][] = [];\n    p.moveTo(x - w * 0.62, y);\n\n    for (const s of ts) {\n      const kk = clamp((k - s.d) / 0.8);\n      const up = Math.sin(kk * Math.PI) * s.h * (1 - kk * 0.25);\n      const bx = x + s.u * w;\n      const half = (w / n) * 0.62;\n      const tx = bx + (s.u * 1.6 + s.lean) * up * 0.5;\n      tips.push([tx, y - up, up]);\n      p.quadraticCurveTo(bx - half, y - up * 0.25, tx, y - up);\n      p.quadraticCurveTo(bx + half * 0.5, y - up * 0.3, bx + half, y);\n    }\n\n    p.lineTo(x + w * 0.62, y);\n    p.closePath();\n    g.save();\n    g.lineWidth = 2.8;\n    g.strokeStyle = P.line;\n    g.stroke(p);\n    g.restore();\n    g.fillStyle = P.shade;\n    fillPath(p);\n    g.save();\n    g.clip(p);\n    g.fillStyle = P.fill;\n\n    for (const [tx, ty, up] of tips) {\n      if (up > 4) {\n        g.beginPath();\n        g.ellipse(tx, ty + up * 0.2, up * 0.2 + 1.4, up * 0.34, 0, 0, TAU);\n        g.fill();\n      }\n    }\n\n    g.restore();\n  });\n\n  for (let i = 0; i < 7; i += 1) {\n    splashDrop(x, y, life);\n  }\n};\n\nexport const slash = (\n  x: number,\n  y: number,\n  { len = 110, ang = -0.5, life = 0.42, thick = 15, col }: SlashOptions = {},\n) => {\n  const R = len * 0.9;\n  const cx = x - Math.cos(ang - Math.PI / 2) * R * 0.86;\n  const cy = y - Math.sin(ang - Math.PI / 2) * R * 0.86;\n  const a0 = ang - Math.PI / 2 - 0.62;\n  const sweep = 1.24;\n  const c = col ?? P.accent;\n  const N = 26;\n  add(life, (k) => {\n    const head = easeOut(clamp(k / 0.42));\n    const tail = easeIn(clamp((k - 0.22) / 0.78));\n\n    if (head - tail < 0.01) {\n      return;\n    }\n\n    const crescent = (T: number) => {\n      const p = new Path2D();\n\n      for (let i = 0; i <= N; i += 1) {\n        const a = a0 + sweep * lerp(tail, head, i / N);\n        const px = cx + Math.cos(a) * R;\n        const py = cy + Math.sin(a) * R;\n\n        if (i === 0) {\n          p.moveTo(px, py);\n        } else {\n          p.lineTo(px, py);\n        }\n      }\n\n      for (let i = N; i >= 0; i -= 1) {\n        const q = i / N;\n        const a = a0 + sweep * lerp(tail, head, q);\n        const rr = R - T * Math.sin(q * Math.PI) ** 0.7;\n        p.lineTo(cx + Math.cos(a) * rr, cy + Math.sin(a) * rr);\n      }\n\n      p.closePath();\n\n      return p;\n    };\n\n    g.save();\n    g.fillStyle = c;\n    fillPath(crescent(thick));\n    g.restore();\n    g.fillStyle = P.fill;\n    fillPath(crescent(thick * 0.42));\n    g.strokeStyle = P.line;\n    g.lineWidth = 1.3;\n    g.stroke(crescent(thick));\n  });\n};\n\nexport interface SlashOptions {\n  len?: number;\n  ang?: number;\n  life?: number;\n  thick?: number;\n  col?: string;\n}\n\nconst speedLine = (\n  x: number,\n  y: number,\n  { dir, len, spread, life }: Record<\"dir\" | \"len\" | \"spread\" | \"life\", number>,\n) => {\n  const o = rnd(-spread, spread);\n  const l = len * rnd(0.5, 1.3);\n  const d = rnd(0, 0.25);\n  const w = rnd(1, 2.6);\n  add(life, (k) => {\n    const kk = clamp((k - d) / (1 - d));\n    const a = easeOut(kk);\n    const b = easeIn(kk);\n    const px = x - Math.sin(dir) * o;\n    const py = y + Math.cos(dir) * o;\n    g.strokeStyle = P.line;\n    g.lineWidth = w * (1 - b);\n    g.beginPath();\n    g.moveTo(px + Math.cos(dir) * l * b * 1.4, py + Math.sin(dir) * l * b * 1.4);\n    g.lineTo(px + Math.cos(dir) * l * (0.2 + a * 1.2), py + Math.sin(dir) * l * (0.2 + a * 1.2));\n\n    if (kk > 0) {\n      g.stroke();\n    }\n  });\n};\n\nexport const lines = (\n  x: number,\n  y: number,\n  { n = 7, dir = Math.PI, len = 46, spread = 26, life = 0.3 } = {},\n) => {\n  for (let i = 0; i < n; i += 1) {\n    speedLine(x, y, { dir, len, life, spread });\n  }\n};\n\nexport const ticks = (\n  x: number,\n  y: number,\n  { n = 3, r = 16, len = 9, dir = -0.9, life = 0.4, fan = 0.42 } = {},\n) => {\n  add(life, (k) => {\n    const a = easeOut(clamp(k / 0.5));\n    const b = easeIn(clamp((k - 0.4) / 0.6));\n    g.save();\n    g.fillStyle = P.accent;\n    g.beginPath();\n\n    for (let i = 0; i < n; i += 1) {\n      const an = dir + (i - (n - 1) / 2) * fan;\n      const r0 = r + len * b * 1.25;\n      const r1 = r + len * a * 1.25;\n      const hw = 0.07 + 2.2 / (r1 + 8);\n\n      if (r1 - r0 >= 0.6) {\n        g.moveTo(x + Math.cos(an) * r0, y + Math.sin(an) * r0);\n        g.lineTo(x + Math.cos(an - hw) * r1, y + Math.sin(an - hw) * r1);\n        g.lineTo(x + Math.cos(an + hw) * r1, y + Math.sin(an + hw) * r1);\n        g.closePath();\n      }\n    }\n\n    g.fill();\n    g.restore();\n  });\n};\n\nexport const donut = (\n  x: number,\n  y: number,\n  { r = 20, vx = 30, vy = -50, life = 1, tilt = -0.25 } = {},\n) => {\n  const ph = rnd(TAU);\n  add(life, (k, t) => {\n    const s = easeBack(clamp(t / 0.22)) * (1 - easeIn(clamp((k - 0.6) / 0.4)));\n\n    if (s < 0.03) {\n      return;\n    }\n\n    const px = x + vx * easeOut(k) * life;\n    const py = y + vy * easeOut(k) * life;\n    const hole = 0.42 + 0.22 * k;\n    const p = new Path2D();\n\n    for (const [m, bump] of [\n      [1, 0.09],\n      [hole, 0.05],\n    ] as const) {\n      for (let i = 0; i <= 48; i += 1) {\n        const a = (i / 48) * TAU;\n        const rr = r * s * m * (1 + bump * Math.sin(a * 9 + ph + t * 2));\n        const ex = Math.cos(a) * rr;\n        const ey = Math.sin(a) * rr * 0.52;\n        const qx = px + ex * Math.cos(tilt) - ey * Math.sin(tilt);\n        const qy = py + ex * Math.sin(tilt) + ey * Math.cos(tilt);\n\n        if (i === 0) {\n          p.moveTo(qx, qy);\n        } else {\n          p.lineTo(qx, qy);\n        }\n      }\n    }\n\n    g.save();\n    g.lineWidth = 3;\n    g.strokeStyle = P.line;\n    g.stroke(p);\n    g.restore();\n    g.save();\n    g.clip(p, \"evenodd\");\n    paintShade();\n    g.translate(r * 0.06, -r * 0.2);\n    g.fillStyle = P.fill;\n    fillPath(p, \"evenodd\");\n    g.restore();\n  });\n};\n\nexport const wob = (x: number, y: number, { dir = 1, r = 16, life = 0.45 } = {}) => {\n  add(life, (k) => {\n    g.strokeStyle = P.line;\n    g.lineWidth = 2.2 * (1 - k);\n\n    if (g.lineWidth < 0.2) {\n      return;\n    }\n\n    g.beginPath();\n\n    for (const d of [0, 7]) {\n      const rr = r + d + easeOut(k) * 8;\n      const c = dir > 0 ? 0 : Math.PI;\n      g.moveTo(x - dir * r + Math.cos(c - 0.45) * rr, y + Math.sin(c - 0.45) * rr);\n      g.arc(x - dir * r, y, rr, c - 0.45, c + 0.45);\n    }\n\n    g.stroke();\n  });\n};\n\nexport const kira = (\n  x: number,\n  y: number,\n  { r = 9, life = 0.6, col }: { r?: number; life?: number; col?: string } = {},\n) => {\n  add(life, (k, t) => {\n    const s = r * Math.sin(k * Math.PI) ** 0.6;\n    const q = s * 0.16;\n    const p = new Path2D();\n    g.translate(x, y);\n    g.rotate(Math.sin(t * 3) * 0.2);\n    p.moveTo(0, -s);\n    p.quadraticCurveTo(q, -q, s * 0.7, 0);\n    p.quadraticCurveTo(q, q, 0, s);\n    p.quadraticCurveTo(-q, q, -s * 0.7, 0);\n    p.quadraticCurveTo(-q, -q, 0, -s);\n    g.save();\n    g.fillStyle = col ?? P.fill;\n    fillPath(p);\n    g.restore();\n    g.strokeStyle = P.accent;\n    g.lineWidth = 2;\n    g.stroke(p);\n  });\n};\n\nconst paths = new Map<WordName, Path2D>();\nconst baked = new Map<string, HTMLCanvasElement>();\n\nconst wordPath = (name: WordName) => {\n  let p = paths.get(name);\n\n  if (!p) {\n    p = new Path2D(WORDS[name][2]);\n    paths.set(name, p);\n  }\n\n  return p;\n};\n\nconst screentone = (x: CanvasRenderingContext2D, oc: string) => {\n  const t = document.createElement(\"canvas\");\n  t.width = 22;\n  t.height = 44;\n  const y = t.getContext(\"2d\");\n\n  if (!y) {\n    return oc;\n  }\n\n  y.fillStyle = \"#fff\";\n  y.fillRect(0, 0, 22, 44);\n  y.fillStyle = oc;\n  y.beginPath();\n\n  for (const [px, py] of [\n    [0, 0],\n    [22, 0],\n    [0, 44],\n    [22, 44],\n    [11, 22],\n  ] as const) {\n    y.moveTo(px + 5.2, py);\n    y.arc(px, py, 5.2, 0, TAU);\n  }\n\n  y.fill();\n\n  return x.createPattern(t, \"repeat\") ?? oc;\n};\n\nconst bake = (name: WordName, fc: string, oc: string, dots: boolean) => {\n  const key = `${name}|${fc}|${oc}|${dots}`;\n  const hit = baked.get(key);\n\n  if (hit) {\n    return hit;\n  }\n\n  const [w, h] = WORDS[name];\n  const p = wordPath(name);\n  const pad = 24;\n  const c = document.createElement(\"canvas\");\n  c.width = w + pad * 2;\n  c.height = h + pad * 2;\n  const x = c.getContext(\"2d\");\n\n  if (x) {\n    x.translate(pad, pad);\n    x.lineJoin = \"round\";\n    x.strokeStyle = oc;\n    x.fillStyle = oc;\n    x.lineWidth = w * 0.035 * 2;\n    x.stroke(p);\n    x.fill(p);\n    x.fillStyle = dots ? screentone(x, oc) : fc;\n    x.fill(p);\n  }\n\n  baked.set(key, c);\n\n  return c;\n};\n\nexport interface SfxOptions {\n  size?: number;\n  rot?: number;\n  life?: number;\n  col?: string;\n  edge?: string;\n  dots?: boolean;\n}\n\nexport const sfx = (\n  name: WordName,\n  x: number,\n  y: number,\n  { size: sz = 64, rot = -0.14, life = 0.95, col, edge, dots = false }: SfxOptions = {},\n) => {\n  if (isCalm()) {\n    return;\n  }\n\n  const s = new Spring(0.2, 520, 17);\n  s.to = 1;\n  let lastT = 0;\n  const c = bake(name, col ?? P.sfx[0], edge ?? P.sfx[1], dots);\n  const k0 = sz / WORDS[name][0];\n  add(life, (k, t) => {\n    const sc = s.step(t - lastT) * (1 - easeIn(clamp((k - 0.86) / 0.14))) * k0;\n    lastT = t;\n    g.translate(x + Math.sin(t * 31) * 0.8, y + Math.cos(t * 27) * 0.8);\n    g.rotate(rot + Math.sin(t * 6) * 0.03);\n    g.drawImage(c, (-c.width / 2) * sc, (-c.height / 2) * sc, c.width * sc, c.height * sc);\n  });\n};\n\nexport const hollow = () => ({ col: \"#ffffff\", edge: \"#1d1a4a\" });\nexport const dotted = () => ({ dots: true, edge: \"#1d1a4a\" });\n\nexport const at = (el: Element, fx = 0.5, fy = 0.5) => {\n  const b = el.getBoundingClientRect();\n\n  return {\n    h: b.height,\n    w: b.width,\n    x: b.left + scrollX + b.width * fx,\n    y: b.top + scrollY + b.height * fy,\n  };\n};\n\nexport interface Squashy {\n  s: Spring;\n  pop: Spring;\n  tilt: Spring;\n  step: (dt: number) => void;\n  dispose: () => void;\n}\n\nexport const squashy = (el: HTMLElement, { low = 0.82, k = 520, d = 15, wide = 0.55 } = {}) => {\n  const s = new Spring(1, k, d);\n  const pop = new Spring(1, 300, 12);\n  const tilt = new Spring(0, 260, 10);\n  const off = new AbortController();\n  const disabled = () => el.matches(\":disabled, [aria-disabled='true']\");\n  el.addEventListener(\n    \"pointerdown\",\n    () => {\n      if (!disabled()) {\n        s.to = low;\n      }\n    },\n    { signal: off.signal },\n  );\n\n  for (const e of [\"pointerup\", \"pointerleave\", \"pointercancel\", \"blur\"]) {\n    el.addEventListener(\n      e,\n      () => {\n        s.to = 1;\n      },\n      { signal: off.signal },\n    );\n  }\n\n  return {\n    dispose: () => off.abort(),\n    pop,\n    s,\n    step: (dt) => {\n      const y = s.step(dt);\n      const p = pop.step(dt);\n      const r = tilt.step(dt);\n\n      const still =\n        Math.abs(y - 1) < 0.001 &&\n        Math.abs(s.v) < 0.01 &&\n        Math.abs(p - 1) < 0.001 &&\n        Math.abs(r) < 0.02;\n\n      el.style.transform = still\n        ? \"\"\n        : `rotate(${r}deg) scale(${(1 + (1 - y) * wide) * p}, ${y * p})`;\n    },\n    tilt,\n  } satisfies Squashy;\n};\n","path":"/sakuga-core.ts","target":"uicapsule/sakuga-vfx/sakuga-core.ts","type":"registry:file"},{"content":"\"use client\";\n\nimport { Input as InputPrimitive } from \"@base-ui/react/input\";\nimport { cn } from \"cn\";\nimport { useRef } from \"react\";\n\nimport { Spring, at, puff, rnd, shards, ticks } from \"./sakuga-core\";\nimport { FONT_BODY, SakugaStyle, useFrame } from \"./sakuga-react\";\nimport type { Styled } from \"./sakuga-react\";\n\ntype SakugaInputProps = Styled<InputPrimitive.Props>;\n\nconst beforeCaret = (inp: HTMLInputElement, ruler: CanvasRenderingContext2D | null) => {\n  if (!ruler) {\n    return 0;\n  }\n\n  const cs = getComputedStyle(inp);\n  const caret = inp.selectionStart ?? inp.value.length;\n  ruler.font = `${cs.fontWeight} ${cs.fontSize} ${cs.fontFamily}`;\n\n  return ruler.measureText(inp.type === \"password\" ? \"•\".repeat(caret) : inp.value.slice(0, caret))\n    .width;\n};\n\nconst SakugaInput = ({ className, onFocus, onInput, ...props }: SakugaInputProps) => {\n  const live = useRef<HTMLInputElement | null>(null);\n  const give = useRef(new Spring(1, 700, 16));\n  const ruler = useRef<CanvasRenderingContext2D | null>(null);\n\n  useFrame((dt) => {\n    const inp = live.current;\n\n    if (!inp) {\n      return;\n    }\n\n    const y = give.current.step(dt);\n    inp.style.transform = Math.abs(y - 1) < 0.0006 ? \"\" : `scale(${y})`;\n  });\n\n  return (\n    <>\n      <SakugaStyle />\n      <InputPrimitive\n        data-slot=\"sakuga-input\"\n        className={cn(\n          \"w-(--sk-input-width,230px) max-w-full rounded-(--sk-r) border-[length:var(--sk-bw)] border-(--sk-ink) bg-(--sk-card) px-[16px] py-[13px] align-middle text-[16px] leading-[1.4] font-semibold text-(--sk-ink) caret-(--sk-ink) shadow-(--sk-sh) outline-none will-change-transform placeholder:text-(--sk-dim) focus-visible:outline-[2.5px] focus-visible:outline-offset-[3px] focus-visible:outline-(--sk-acc) focus-visible:outline-solid data-disabled:opacity-50\",\n          FONT_BODY,\n          className,\n        )}\n        {...props}\n        onFocus={(e) => {\n          live.current = e.currentTarget;\n          const c = at(e.currentTarget, 1, 0);\n          give.current.x = 1.04;\n          ticks(c.x - 6, c.y - 4, { dir: -1.05, fan: 0.36, len: 17, life: 0.5, n: 3, r: 5 });\n          onFocus?.(e);\n        }}\n        onInput={(e) => {\n          const inp = e.currentTarget;\n          live.current = inp;\n\n          if (!ruler.current) {\n            ruler.current = document.createElement(\"canvas\").getContext(\"2d\");\n          }\n\n          const c = at(inp, 0, 0.5);\n          const x = c.x + 18 + Math.min(c.w - 38, beforeCaret(inp, ruler.current));\n          give.current.x = 0.985;\n          const size = rnd(4, 6);\n          const vx = rnd(-10, 10);\n          puff(x, c.y + 10, { life: 0.4, n: 2, size, vx, vy: -22 });\n\n          if (rnd() < 0.35) {\n            shards(x, c.y + 6, { life: 0.5, n: 2, size: 3, speed: 110 });\n          }\n\n          onInput?.(e);\n        }}\n      />\n    </>\n  );\n};\n\nexport { SakugaInput };\n","path":"/sakuga-input.tsx","target":"uicapsule/sakuga-vfx/sakuga-input.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { NumberField as NumberFieldPrimitive } from \"@base-ui/react/number-field\";\nimport { cn } from \"cn\";\nimport { createContext, use, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport { Spring, at, clock, hollow, later, lines, puff, rnd, sfx, ticks, wob } from \"./sakuga-core\";\nimport {\n  FONT_BODY,\n  FONT_DISPLAY,\n  SakugaStyle,\n  useFrame,\n  useMergedRef,\n  useSquashy,\n} from \"./sakuga-react\";\nimport type { Styled } from \"./sakuga-react\";\n\ninterface Rig {\n  pill: HTMLElement | null;\n  num: HTMLElement | null;\n  input: HTMLElement | null;\n  kick: Spring;\n  tall: Spring;\n  jolt: Spring;\n  lean: Spring;\n  press: Spring;\n  value: number | null;\n  min: number | undefined;\n  max: number | undefined;\n  off: boolean;\n  heat: number;\n  stepped: number;\n  said: number;\n  bumped: number;\n  hold: number;\n  holdSteps: number;\n  hit: (dir: number) => void;\n  bump: (dir: number) => void;\n}\n\nconst makeRig = () => {\n  const rig: Rig = {\n    bump: (dir) => {\n      const p = rig.pill;\n\n      if (!p || clock.now - rig.bumped < 0.16) {\n        return;\n      }\n\n      rig.bumped = clock.now;\n      rig.heat = 0;\n      rig.jolt.x = dir * 7;\n      rig.jolt.v = 0;\n      rig.lean.x = dir * 2.4;\n      const q = at(p);\n      wob(q.x + dir * (q.w / 2 + 9), q.y + 3, { dir });\n    },\n    bumped: -9,\n    heat: 0,\n    hit: (dir) => {\n      const p = rig.pill;\n      const n = rig.num;\n\n      if (!p || !n) {\n        return;\n      }\n\n      const t = clock.now;\n      rig.heat = t - rig.stepped < 0.3 ? Math.min(5, rig.heat + 1) : 0;\n      rig.stepped = t;\n      const { heat } = rig;\n      rig.kick.x = -dir * (8 + heat * 1.4);\n      rig.kick.v = 0;\n      rig.tall.x = 1.26 + heat * 0.03;\n      const c = at(n);\n      const q = at(p);\n      const ahead = dir > 0 ? q.y - q.h / 2 - 12 : q.y + q.h / 2 + 19;\n      const behind = dir > 0 ? q.y + q.h / 2 + 17 : q.y - q.h / 2 - 10;\n      ticks(c.x, ahead, {\n        dir: (-dir * Math.PI) / 2,\n        fan: 0.5,\n        len: 15 + heat,\n        life: 0.5,\n        n: 3,\n        r: 4,\n      });\n\n      if (heat === 0 && t - rig.said > 0.9) {\n        rig.said = t;\n        sfx(\"kachi\", c.x + dir * 64, q.y - q.h / 2 - 34, {\n          life: 0.7,\n          rot: dir > 0 ? -0.08 : 0.07,\n          size: 70,\n          ...hollow(),\n        });\n      }\n\n      if (heat > 0) {\n        lines(c.x, behind, {\n          dir: (dir * Math.PI) / 2,\n          len: 18 + heat * 6,\n          life: 0.25,\n          n: 2 + Math.min(2, heat),\n          spread: 13,\n        });\n      }\n\n      if (heat > 1 && heat % 2 === 0) {\n        const drift = rnd(-12, 12);\n        puff(c.x + drift, behind + dir * 4, {\n          life: 0.6,\n          n: 3,\n          size: 5 + heat * 0.8,\n          vx: drift * 1.5,\n          vy: dir * 14,\n        });\n      }\n    },\n    hold: 0,\n    holdSteps: 0,\n    input: null,\n    jolt: new Spring(0, 460, 12),\n    kick: new Spring(0, 440, 13),\n    lean: new Spring(0, 260, 10),\n    max: undefined,\n    min: undefined,\n    num: null,\n    off: false,\n    pill: null,\n    press: new Spring(1, 520, 15),\n    said: -9,\n    stepped: -9,\n    tall: new Spring(1, 520, 13),\n    value: null,\n  };\n\n  return rig;\n};\n\nconst RigContext = createContext<RefObject<Rig> | null>(null);\n\nconst useRig = () => {\n  const rigRef = use(RigContext);\n\n  if (!rigRef) {\n    throw new Error(\"SakugaNumberField parts must be inside <SakugaNumberField>\");\n  }\n\n  return rigRef;\n};\n\nconst STEPS = new Set([\"decrement-press\", \"increment-press\", \"keyboard\", \"scrub\", \"wheel\"]);\n\nconst stepRig = (rig: Rig, dt: number) => {\n  const k = rig.kick.step(dt);\n  const y = rig.tall.step(dt);\n  const j = rig.jolt.step(dt);\n  const r = rig.lean.step(dt);\n  const w = rig.press.step(dt);\n\n  if (rig.num) {\n    const still = Math.abs(k) < 0.05 && Math.abs(y - 1) < 0.001;\n    rig.num.style.transform = still\n      ? \"\"\n      : `translateY(${k.toFixed(2)}px) scale(${(1 / y).toFixed(3)}, ${y.toFixed(3)})`;\n  }\n\n  if (rig.pill) {\n    const still = Math.abs(j) < 0.05 && Math.abs(r) < 0.02 && Math.abs(w - 1) < 0.001;\n    rig.pill.style.transform = still\n      ? \"\"\n      : `translateX(${j.toFixed(2)}px) rotate(${r.toFixed(2)}deg) scale(${(1 + (1 - w) * 0.3).toFixed(3)}, ${w.toFixed(3)})`;\n  }\n};\n\nconst SakugaNumberField = ({\n  className,\n  children,\n  value: valueProp,\n  defaultValue,\n  onValueChange,\n  inputRef,\n  step = 1,\n  largeStep,\n  ...props\n}: Styled<NumberFieldPrimitive.Root.Props>) => {\n  const rigRef = useMemo(() => ({ current: makeRig() }), []);\n  const [own, setOwn] = useState(defaultValue ?? null);\n  const owned = valueProp !== undefined;\n  const value = owned ? valueProp : own;\n  const asked = useRef<{ dir: number; to: number } | null>(null);\n  const field = useRef<HTMLInputElement>(null);\n  const fieldRef = useMergedRef(field, inputRef);\n  const { min, max, disabled = false, readOnly = false } = props;\n\n  useEffect(() => {\n    const rig = rigRef.current;\n    rig.value = value;\n    rig.min = min;\n    rig.max = max;\n    rig.off = disabled || readOnly;\n    const want = asked.current;\n    asked.current = null;\n\n    if (want && want.to === value) {\n      rig.hit(want.dir);\n    }\n  }, [value, min, max, disabled, readOnly, rigRef]);\n\n  useEffect(() => {\n    const form = field.current?.form;\n\n    if (!form || owned) {\n      return;\n    }\n\n    const reset = () => setOwn(defaultValue ?? null);\n    form.addEventListener(\"reset\", reset);\n\n    return () => form.removeEventListener(\"reset\", reset);\n  }, [owned, defaultValue]);\n\n  useFrame((dt) => stepRig(rigRef.current, dt));\n\n  return (\n    <NumberFieldPrimitive.Root\n      data-slot=\"sakuga-number-field\"\n      className={cn(\n        \"relative isolate inline-block align-middle text-[15px] leading-[1.4] font-medium text-(--sk-ink)\",\n        FONT_BODY,\n        className,\n      )}\n      value={value}\n      step={step}\n      largeStep={largeStep ?? (step === \"any\" ? undefined : step * 10)}\n      inputRef={fieldRef}\n      onValueChange={(next, details) => {\n        onValueChange?.(next, details);\n\n        if (details.isCanceled) {\n          return;\n        }\n\n        const rig = rigRef.current;\n        const from = rig.value;\n\n        if (!owned) {\n          setOwn(next);\n          rig.value = next;\n        }\n\n        if (next === null || !STEPS.has(details.reason)) {\n          return;\n        }\n\n        const dir = details.direction ?? Math.sign(next - (from ?? next));\n\n        if (dir === 0) {\n          return;\n        }\n\n        if (owned) {\n          asked.current = { dir, to: next };\n        } else {\n          rig.hit(dir);\n        }\n\n        if (details.reason.endsWith(\"-press\")) {\n          rig.holdSteps += 1;\n\n          if (next === (dir > 0 ? max : min)) {\n            const n = rig.hold;\n            later(rig.holdSteps > 1 ? 60 : 400, () => {\n              if (n === rig.hold && rig.press.to < 1) {\n                rig.bump(dir);\n              }\n            });\n          }\n        }\n      }}\n      {...props}\n    >\n      <SakugaStyle />\n      <RigContext value={rigRef}>{children}</RigContext>\n    </NumberFieldPrimitive.Root>\n  );\n};\n\nconst SakugaNumberFieldGroup = ({\n  className,\n  ref,\n  ...props\n}: Styled<NumberFieldPrimitive.Group.Props>) => {\n  const rigRef = useRig();\n\n  const pillRef = useMergedRef((node: HTMLDivElement | null) => {\n    rigRef.current.pill = node;\n  }, ref);\n\n  return (\n    <NumberFieldPrimitive.Group\n      data-slot=\"sakuga-number-field-group\"\n      className={cn(\n        \"group/sk-nf flex items-center rounded-(--sk-r) border-[length:var(--sk-bw)] border-(--sk-ink) bg-(--sk-card) shadow-(--sk-sh) will-change-transform not-data-quiet:has-[:focus-visible]:outline-[2.5px] not-data-quiet:has-[:focus-visible]:outline-offset-[3px] not-data-quiet:has-[:focus-visible]:outline-(--sk-acc) not-data-quiet:has-[:focus-visible]:outline-solid data-disabled:cursor-not-allowed data-disabled:opacity-50\",\n        className,\n      )}\n      {...props}\n      ref={pillRef}\n    />\n  );\n};\n\nconst PRESS = { low: 0.56, wide: 0.5 };\n\nconst SIDE =\n  \"grid h-[44px] w-[46px] flex-none cursor-pointer touch-manipulation place-items-center will-change-transform outline-none select-none data-disabled:cursor-not-allowed data-disabled:text-(--sk-track) group-data-disabled/sk-nf:text-(--sk-ink)!\";\n\nconst GLYPH =\n  \"pointer-events-none h-[20px] w-[20px] fill-none stroke-current stroke-[3.4] [stroke-linecap:round]\";\n\ntype SideProps = Styled<NumberFieldPrimitive.Increment.Props>;\n\nconst useSide = (\n  dir: number,\n  {\n    onClick,\n    onPointerCancel,\n    onPointerDownCapture,\n    onPointerLeave,\n    onPointerUp,\n    ref,\n    ...props\n  }: SideProps,\n) => {\n  const rigRef = useRig();\n  const el = useRef<HTMLButtonElement>(null);\n  const sideRef = useMergedRef(el, ref);\n  const sqRef = useSquashy(el, PRESS);\n  useFrame((dt) => sqRef.current?.step(dt));\n\n  const letGo = () => {\n    rigRef.current.press.to = 1;\n    rigRef.current.hold += 1;\n  };\n\n  const handlers: Pick<\n    SideProps,\n    \"onClick\" | \"onPointerCancel\" | \"onPointerDownCapture\" | \"onPointerLeave\" | \"onPointerUp\"\n  > = {\n    onClick: (e) => {\n      onClick?.(e);\n      const s = sqRef.current;\n\n      if (s && e.detail === 0 && e.currentTarget.dataset.disabled === undefined) {\n        s.s.x = Math.min(s.s.x, 0.8);\n        s.s.v += 4;\n      }\n    },\n    onPointerCancel: (e) => {\n      onPointerCancel?.(e);\n      letGo();\n    },\n    onPointerDownCapture: (e) => {\n      onPointerDownCapture?.(e);\n      const rig = rigRef.current;\n      const s = sqRef.current;\n\n      if (e.button !== 0 || rig.off) {\n        if (s) {\n          s.s.to = 1;\n        }\n\n        return;\n      }\n\n      if (rig.pill) {\n        rig.pill.style.transformOrigin = dir > 0 ? \"0 50%\" : \"100% 50%\";\n\n        if (document.activeElement !== rig.input) {\n          rig.pill.toggleAttribute(\"data-quiet\", true);\n        }\n      }\n\n      rig.press.to = 0.9;\n      rig.hold += 1;\n      rig.holdSteps = 0;\n\n      if (e.currentTarget.dataset.disabled !== undefined) {\n        rig.bump(dir);\n      }\n    },\n    onPointerLeave: (e) => {\n      onPointerLeave?.(e);\n      letGo();\n    },\n    onPointerUp: (e) => {\n      onPointerUp?.(e);\n      letGo();\n    },\n  };\n\n  return { ...props, ...handlers, ref: sideRef };\n};\n\nconst SakugaNumberFieldDecrement = ({ className, children, ...props }: SideProps) => (\n  <NumberFieldPrimitive.Decrement\n    data-slot=\"sakuga-number-field-decrement\"\n    className={cn(SIDE, className)}\n    {...useSide(-1, props)}\n  >\n    {children ?? (\n      <svg aria-hidden viewBox=\"0 0 20 20\" className={GLYPH}>\n        <path d=\"M4 10h12\" />\n      </svg>\n    )}\n  </NumberFieldPrimitive.Decrement>\n);\n\nconst SakugaNumberFieldIncrement = ({ className, children, ...props }: SideProps) => (\n  <NumberFieldPrimitive.Increment\n    data-slot=\"sakuga-number-field-increment\"\n    className={cn(SIDE, className)}\n    {...useSide(1, props)}\n  >\n    {children ?? (\n      <svg aria-hidden viewBox=\"0 0 20 20\" className={GLYPH}>\n        <path d=\"M4 10h12M10 4v12\" />\n      </svg>\n    )}\n  </NumberFieldPrimitive.Increment>\n);\n\nconst NUMBER = cn(\n  \"text-[21px] leading-[1.1] font-extrabold tracking-[-0.01em] tabular-nums italic\",\n  FONT_DISPLAY,\n);\n\nconst wallFor = (key: string, { value, min, max }: Rig) => {\n  if (value === null) {\n    return 0;\n  }\n\n  if ((key === \"ArrowUp\" || key === \"End\") && max !== undefined && value >= max) {\n    return 1;\n  }\n\n  if ((key === \"ArrowDown\" || key === \"Home\") && min !== undefined && value <= min) {\n    return -1;\n  }\n\n  return 0;\n};\n\nconst SakugaNumberFieldInput = ({\n  className,\n  onBlur,\n  onKeyDown,\n  onPointerDown,\n  ref,\n  ...props\n}: Omit<Styled<NumberFieldPrimitive.Input.Props>, \"render\">) => {\n  const rigRef = useRig();\n\n  const inputRef = useMergedRef((node: HTMLInputElement | null) => {\n    rigRef.current.input = node;\n  }, ref);\n\n  const loud = () => {\n    rigRef.current.pill?.toggleAttribute(\"data-quiet\", false);\n  };\n\n  return (\n    <NumberFieldPrimitive.Input\n      data-slot=\"sakuga-number-field-input\"\n      className={cn(\n        NUMBER,\n        \"absolute inset-y-0 -inset-x-[10px] box-border h-full w-[calc(100%+20px)] rounded-none bg-transparent py-0 pr-0 pl-[10px] text-left text-transparent caret-(--sk-ink) outline-none selection:text-(--sk-ink) group-data-quiet/sk-nf:caret-transparent data-disabled:cursor-not-allowed\",\n        className,\n      )}\n      render={(input, state) => (\n        // oxlint-disable-next-line jsx-a11y/no-static-element-interactions -- not a control of its own: a press on the cell's padding only passes focus to the input inside it\n        <span\n          data-slot=\"sakuga-number-field-cell\"\n          className=\"relative grid h-[44px] min-w-[64px] cursor-text place-items-center border-x-[2.4px] border-(--sk-ink) px-[10px] group-data-disabled/sk-nf:cursor-not-allowed\"\n          onMouseDown={(e) => {\n            if (e.target === e.currentTarget) {\n              e.preventDefault();\n              loud();\n              rigRef.current.input?.focus();\n            }\n          }}\n        >\n          <span className={cn(NUMBER, \"relative\")}>\n            <span\n              ref={(node) => {\n                rigRef.current.num = node;\n              }}\n              aria-hidden\n              className={cn(\n                \"block whitespace-pre will-change-transform\",\n                state.inputValue === \"\" && \"invisible\",\n              )}\n            >\n              {state.inputValue || \"0\"}\n            </span>\n            <input {...input} />\n          </span>\n        </span>\n      )}\n      onBlur={(e) => {\n        onBlur?.(e);\n        loud();\n      }}\n      onKeyDown={(e) => {\n        onKeyDown?.(e);\n        loud();\n        const rig = rigRef.current;\n\n        if (rig.off || e.ctrlKey || e.metaKey || e.altKey) {\n          return;\n        }\n\n        if (e.key === \"PageUp\" || e.key === \"PageDown\") {\n          e.preventDefault();\n          e.currentTarget.dispatchEvent(\n            new KeyboardEvent(\"keydown\", {\n              bubbles: true,\n              cancelable: true,\n              key: e.key === \"PageUp\" ? \"ArrowUp\" : \"ArrowDown\",\n              shiftKey: true,\n            }),\n          );\n\n          return;\n        }\n\n        const dir = wallFor(e.key, rig);\n\n        if (dir !== 0) {\n          rig.bump(dir);\n        }\n      }}\n      onPointerDown={(e) => {\n        onPointerDown?.(e);\n        loud();\n      }}\n      {...props}\n      ref={inputRef}\n    />\n  );\n};\n\nexport {\n  SakugaNumberField,\n  SakugaNumberFieldDecrement,\n  SakugaNumberFieldGroup,\n  SakugaNumberFieldIncrement,\n  SakugaNumberFieldInput,\n};\n","path":"/sakuga-number-field.tsx","target":"uicapsule/sakuga-vfx/sakuga-number-field.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { Progress as ProgressPrimitive } from \"@base-ui/react/progress\";\nimport { cn } from \"cn\";\nimport { useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport type { RefObject } from \"react\";\nimport { flushSync } from \"react-dom\";\n\nimport {\n  P,\n  Spring,\n  at,\n  blob,\n  burst,\n  clamp,\n  fillPath,\n  lerp,\n  lines,\n  pen,\n  persist,\n  puff,\n  rnd,\n  sfx,\n  shards,\n  ticks,\n  toon,\n} from \"./sakuga-core\";\nimport type { Layer } from \"./sakuga-core\";\nimport { BACK_CANVAS, FONT_BODY, SakugaStyle, useBackLayer, useFrame } from \"./sakuga-react\";\nimport type { Styled } from \"./sakuga-react\";\n\ntype SakugaProgressProps = Styled<Omit<ProgressPrimitive.Root.Props, \"children\" | \"value\">> & {\n  value?: number | null;\n  doneLabel?: string;\n  onDone?: () => void;\n};\n\nconst UNKNOWN = \"…\";\n\nconst LOBES = [\n  [0, -0.95, 1],\n  [0.78, -0.55, 0.74],\n  [-0.72, -0.78, 0.72],\n  [0.36, -1.7, 0.7],\n  [-0.4, -1.62, 0.62],\n  [1.1, -1.32, 0.52],\n  [-1.18, -0.28, 0.52],\n  [0.62, 0.3, 0.5],\n  [-0.86, 0.5, 0.52],\n  [-1.5, 0.82, 0.38],\n  [-2.05, 1, 0.24],\n  [0.16, 0.72, 0.4],\n] as const;\n\nconst PEBBLE = [\n  [-1, 0.4],\n  [-0.5, -0.8],\n  [0.5, -1],\n  [1, 0.1],\n  [0.3, 0.9],\n] as const;\n\nconst RAYS = [\n  [-2.6, 58],\n  [-2.95, 60],\n  [-0.35, 56],\n  [-0.1, 60],\n] as const;\n\nconst lobe = ([x, y, r]: readonly [number, number, number], i: number) => {\n  const ph = rnd(6.28);\n  const w = rnd(1.4, 2.6);\n\n  return { i, ph, r, w, x, y };\n};\n\nconst pebble = (u: number) => {\n  const s = rnd(3.4, 5.6);\n  const ph = rnd(6.28);\n  const rot = rnd(-0.5, 0.5);\n\n  const pts = PEBBLE.map(([x, y]) => {\n    const px = x * rnd(0.8, 1.2);\n    const py = y * rnd(0.8, 1.2);\n\n    return [px, py] as const;\n  });\n\n  return { lift: new Spring(0, 70, 7), ph, pts, rot, s, u };\n};\n\nconst makeLoad = () => ({\n  acc: 0,\n  ck: new Spring(0, 260, 13),\n  doneAt: 0,\n  goal: 0,\n  lag: new Spring(0, 120, 16),\n  lastPct: \"\",\n  lobes: LOBES.map(lobe),\n  p: 0,\n  peb: [0.14, 0.31, 0.5, 0.69, 0.87].map(pebble),\n  rest: new Spring(0, 160, 14),\n  said: false,\n  shown: 0,\n  size: new Spring(0, 90, 13),\n  spd: 0,\n  t: 0,\n  tag: new Spring(1, 500, 13),\n  unknown: false,\n  vis: false,\n});\n\ntype Load = ReturnType<typeof makeLoad>;\n\ntype Pebble = ReturnType<typeof pebble>;\n\nconst clear = (load: Load) => {\n  load.doneAt = 0;\n  load.said = false;\n};\n\nconst setGoal = (load: Load, value: number) => {\n  const n = clamp(Number(value) || 0);\n\n  if (load.doneAt && n >= 1) {\n    return;\n  }\n\n  if (n < load.p - 0.001) {\n    clear(load);\n    load.p = n;\n  }\n\n  load.goal = n;\n};\n\nconst paintPebble = (q: Pebble, px: number, gy: number, tt: number, up: number) => {\n  const g = pen();\n  const y = gy - q.s * 0.7 - up * (7 + q.s * 1.5) + Math.sin(tt * 3 + q.ph) * 2 * up;\n  const path = new Path2D();\n  g.save();\n  g.translate(px, y);\n  g.rotate(q.rot + up * Math.sin(tt * 2 + q.ph) * 0.5);\n\n  for (const [n, [x, yy]] of q.pts.entries()) {\n    if (n) {\n      path.lineTo(x * q.s, yy * q.s);\n    } else {\n      path.moveTo(x * q.s, yy * q.s);\n    }\n  }\n\n  path.closePath();\n  toon(path, 1.1, q.s * 0.5);\n  g.restore();\n\n  if (up > 0.15 && up < 0.9 && q.lift.v > 0.6) {\n    g.save();\n    g.strokeStyle = P.accent;\n    g.lineWidth = 2.4;\n    g.beginPath();\n\n    for (const a of [-1.9, -1.57, -1.24]) {\n      g.moveTo(px + Math.cos(a) * (q.s + 5), y + Math.sin(a) * (q.s + 5));\n      g.lineTo(px + Math.cos(a) * (q.s + 11), y + Math.sin(a) * (q.s + 11));\n    }\n\n    g.stroke();\n    g.restore();\n  }\n};\n\nconst paintRest = (x: number, d: number, gy: number, rs: number, tt: number) => {\n  const g = pen();\n  blob(\n    (\n      [\n        [x, gy - 9 * rs, 8 * rs],\n        [x + 8 * d, gy - 6 * rs, 6 * rs],\n        [x - 6 * d, gy - 5 * rs, 5.5 * rs],\n        [x + 2 * d, gy - 15 * rs, 5.5 * rs],\n      ] as const\n    ).map(([cx, cyy, r], n) => [cx, cyy, r * (1 + Math.sin(tt * 3 + n) * 0.06)] as const),\n    1.3,\n    { arcs: true, lx: 1 },\n  );\n  g.strokeStyle = P.line;\n  g.lineWidth = 1.4;\n  g.beginPath();\n  g.moveTo(x + d * 18, gy - 6);\n  g.lineTo(x + d * 25, gy - 6);\n  g.moveTo(x + d * 19, gy - 1.5);\n  g.lineTo(x + d * 23, gy - 1.5);\n  g.stroke();\n};\n\nconst paintCheck = (x: number, y: number, c: number, tt: number) => {\n  const g = pen();\n  g.save();\n  g.translate(x, y);\n  g.rotate((1 - c) * -0.5);\n  g.scale(c, c);\n  g.save();\n  g.strokeStyle = P.accent;\n  g.lineWidth = 9;\n  g.lineJoin = \"miter\";\n  g.lineCap = \"butt\";\n  g.beginPath();\n  g.moveTo(-28, 2);\n  g.lineTo(-8, 22);\n  g.lineTo(30, -26);\n  g.stroke();\n  g.lineCap = \"round\";\n  g.lineWidth = 4;\n  g.beginPath();\n\n  for (const [a, d] of RAYS) {\n    g.moveTo(Math.cos(a) * d, Math.sin(a) * d * 0.7);\n    g.lineTo(Math.cos(a) * (d + 13), Math.sin(a) * (d + 13) * 0.7);\n  }\n\n  g.stroke();\n  g.restore();\n  const s = 15 * (0.9 + 0.1 * Math.sin(tt * 5));\n  const q = s * 0.14;\n  const sp = new Path2D();\n  g.translate(74, 28);\n  sp.moveTo(0, -s);\n  sp.quadraticCurveTo(q, -q, s * 0.75, 0);\n  sp.quadraticCurveTo(q, q, 0, s);\n  sp.quadraticCurveTo(-q, q, -s * 0.75, 0);\n  sp.quadraticCurveTo(-q, -q, 0, -s);\n  g.fillStyle = P.fill;\n  fillPath(sp);\n  g.strokeStyle = P.ink;\n  g.lineWidth = 2.4;\n  g.stroke(sp);\n  g.restore();\n};\n\nconst paint = (load: Load, bar: HTMLElement, tt: number, dt: number) => {\n  if (!load.vis) {\n    return;\n  }\n\n  const g = pen();\n  const b = at(bar);\n  const L = b.x - b.w / 2;\n  const R = b.x + b.w / 2;\n  const { p } = load;\n  const done = load.doneAt;\n  const lead = L + 4 + (b.w - 8) * p;\n  const cy = b.y;\n  const gy = cy + b.h / 2 + 30;\n  const reach = clamp(p * 1.25 + (done ? 1 : 0));\n  const gx1 = lerp(L + 10, R - 10, reach);\n\n  if (reach > 0.02) {\n    g.strokeStyle = P.line;\n    g.lineWidth = 1.4;\n    g.beginPath();\n    g.moveTo(L + 10, gy);\n    g.lineTo(gx1, gy);\n\n    for (let x = L + 26; x < gx1 - 6; x += 37) {\n      g.moveTo(x, gy);\n      g.lineTo(x + 3, gy - 4);\n      g.moveTo(x + 5, gy);\n      g.lineTo(x + 6.5, gy - 2.5);\n    }\n\n    g.stroke();\n  }\n\n  for (const q of load.peb) {\n    const px = L + b.w * q.u;\n    q.lift.to = !done && lead > px - 16 ? 1 : 0;\n    const up = q.lift.step(dt);\n\n    if (!(reach < q.u - 0.04 && up < 0.01)) {\n      paintPebble(q, px, gy, tt, up);\n    }\n  }\n\n  load.rest.to = done ? 1 : 0;\n  const rs = Math.max(0, load.rest.step(dt));\n\n  if (rs > 0.02) {\n    paintRest(L + 34, -1, gy, rs, tt);\n    paintRest(R - 40, 1, gy, rs, tt);\n  }\n\n  load.size.to = done || p < 0.015 ? 0 : 10 + 25 * Math.sqrt(p);\n  load.lag.to = load.spd;\n  const S = Math.max(0, load.size.step(dt));\n  const drag = load.lag.step(dt);\n\n  if (S > 0.6) {\n    blob(\n      load.lobes.map((l) => {\n        const boil = 1 + 0.16 * Math.sin(tt * l.w + l.ph);\n        const roll = 0.82 + 0.22 * Math.sin(tt * 2.6 - l.i * 0.9);\n\n        return [\n          lead +\n            3 +\n            (l.x + Math.cos(tt * l.w * 0.7 + l.ph) * 0.1 - drag * 1.6 * Math.max(0, -l.y) * 0.5) *\n              S,\n          cy - 3 + (l.y + Math.sin(tt * l.w * 0.7 + l.ph) * 0.1) * S,\n          l.r * S * boil * roll,\n        ] as const;\n      }),\n      1.6,\n      { arcs: true, deep: 1.7, lx: 1 },\n    );\n  }\n\n  load.ck.to = done ? 1 : 0;\n  const c = Math.max(0, load.ck.step(dt));\n\n  if (c > 0.02) {\n    paintCheck(b.x + 4, cy - b.h / 2 - 56, c, tt);\n  }\n};\n\nconst tear = (lead: number, top: number, p: number, spd: number) => {\n  const S = 10 + 25 * Math.sqrt(p);\n\n  if (Math.random() < 0.5) {\n    const px = lead - S * rnd(0.9, 1.6);\n    const py = top - S * rnd(0.1, 0.9);\n    const size = rnd(3, 5.5) + p * 3;\n    const vx = -rnd(40, 90);\n    const vy = rnd(-12, 4);\n    const life = rnd(0.4, 0.7);\n    puff(px, py, { life, n: 2, size, vx, vy });\n  } else {\n    lines(lead - S * 1.4, top - S * rnd(0.2, 1.3), {\n      dir: Math.PI,\n      len: 30 + spd * 160,\n      life: 0.3,\n      n: 1,\n      spread: 3,\n    });\n  }\n\n  if (Math.random() < 0.16) {\n    ticks(lead + S * 1.1, top - S * 1.5, { dir: -0.7, len: 8, life: 0.35, n: 3, r: 4 });\n  }\n};\n\nconst finish = (b: ReturnType<typeof at>, top: number, back: Layer | null) => {\n  const R = b.x + b.w / 2;\n  burst(R - 74, b.y, { layer: back ?? undefined, life: 0.5, r: 92, spikes: 15 });\n  burst(R - 60, b.y, { life: 0.3, r: 40 });\n  shards(R - 60, b.y, { arc: 6.28, life: 0.9, n: 11, size: 7, speed: 270 });\n\n  for (let i = 0; i < 7; i += 1) {\n    const a = (i / 7) * 6.28 + rnd(0.5);\n    const size = rnd(8, 13);\n    const life = rnd(0.6, 1);\n    puff(R - 70 + Math.cos(a) * 70, b.y + Math.sin(a) * 34, {\n      life,\n      n: 4,\n      size,\n      vx: Math.cos(a) * 46,\n      vy: Math.sin(a) * 30 - 8,\n    });\n  }\n\n  sfx(\"don\", b.x - 26, top - 62, { life: 1.05, rot: -0.12, size: 170 });\n};\n\nconst advanceLoad = (load: Load, dt: number) => {\n  const was = load.p;\n\n  if (!load.doneAt && load.p < load.goal) {\n    load.p = Math.min(load.goal, load.p + dt * clamp((load.goal - load.p) * 3, 0.12, 0.9));\n  }\n\n  load.spd = lerp(load.spd, dt > 0 ? (load.p - was) / dt : 0, Math.min(1, dt * 8));\n};\n\nconst ride = (load: Load, b: ReturnType<typeof at>, dt: number) => {\n  const L = b.x - b.w / 2;\n  const lead = L + 4 + (b.w - 8) * load.p;\n  const top = b.y - b.h / 2;\n  const { p, spd } = load;\n\n  if (p > 0.06 && spd > 0.02) {\n    load.acc += dt * (4 + spd * 60);\n\n    while (load.acc > 1) {\n      load.acc -= 1;\n      tear(lead, top, p, spd);\n    }\n  }\n\n  if (!load.said && p > 0.3 && p < 0.9) {\n    load.said = true;\n    sfx(\"gogo\", b.x - 34, top - 66, { life: 2.9, rot: -0.1, size: 150 });\n    ticks(b.x + 52, top - 84, { dir: -0.5, len: 10, life: 0.6, n: 2, r: 4 });\n    ticks(L + 8, top - 40, { dir: Math.PI + 0.3, len: 10, life: 0.6, n: 2, r: 4 });\n  }\n};\n\nconst loadOf = (loadRef: RefObject<Load | null>) => {\n  const made = loadRef.current ?? makeLoad();\n  loadRef.current = made;\n\n  return made;\n};\n\nconst textOf = (load: Load, n: number, doneLabel: string) => {\n  if (load.doneAt) {\n    return doneLabel;\n  }\n\n  return load.unknown ? UNKNOWN : `${n}%`;\n};\n\nconst BAR =\n  \"relative h-[38px] overflow-hidden rounded-[19px] border-4 border-(--sk-ink) bg-(--sk-card)\";\n\nconst FILL =\n  \"relative bg-(--sk-fill) before:absolute before:top-[5px] before:left-[22px] before:h-[11px] before:w-[9px] before:rounded-[2px] before:bg-white before:opacity-[.92] before:content-[''] before:[transform:skewX(-28deg)] after:absolute after:top-[5px] after:left-[37px] after:h-[11px] after:w-[6px] after:rounded-[2px] after:bg-white after:opacity-[.92] after:content-[''] after:[transform:skewX(-28deg)]\";\n\nconst PCT =\n  \"mx-auto mt-[64px] table bg-(--sk-card) px-[13px] pt-[3px] pb-[4px] [font-family:'Marker_Felt','Chalkboard_SE','Comic_Sans_MS',-apple-system,'Segoe_UI',sans-serif] text-[21px] leading-[1.1] font-black tracking-[-0.01em] whitespace-nowrap italic shadow-[5px_5px_0_var(--sk-fill)] border-[2.5px] border-(--sk-ink) will-change-transform [transform:skewX(-12deg)]\";\n\nconst ROOT =\n  \"relative isolate w-(--sk-progress-width,280px) max-w-full align-middle text-[15px] leading-[1.4] font-medium text-(--sk-ink)\";\n\nconst SakugaProgress = ({\n  className,\n  value,\n  min = 0,\n  max = 100,\n  doneLabel = \"Complete ✓\",\n  onDone,\n  \"aria-label\": ariaLabel,\n  \"aria-labelledby\": labelledBy,\n  ...props\n}: SakugaProgressProps) => {\n  const box = useRef<HTMLDivElement>(null);\n  const bar = useRef<HTMLDivElement>(null);\n  const pct = useRef<HTMLSpanElement>(null);\n  const [attachBack, backRef] = useBackLayer();\n  const loadRef = useRef<Load | null>(null);\n\n  const [shown, setShown] = useState<{ text: string; value: number | null }>(() =>\n    value === null || value === undefined\n      ? { text: UNKNOWN, value: null }\n      : { text: \"0%\", value: min },\n  );\n\n  useEffect(() => {\n    const load = loadOf(loadRef);\n\n    const layer = persist((_k, tt, dt) => {\n      if (bar.current) {\n        paint(load, bar.current, tt, dt);\n      }\n    });\n\n    return () => {\n      layer.dead = true;\n    };\n  }, []);\n\n  const hadValue = useRef(false);\n  useLayoutEffect(() => {\n    const load = loadOf(loadRef);\n    const known = value !== null && value !== undefined && Number.isFinite(value);\n    load.unknown = !known;\n\n    if (known) {\n      hadValue.current = true;\n      setGoal(load, max > min ? (value - min) / (max - min) : 0);\n    } else if (hadValue.current) {\n      hadValue.current = false;\n      setGoal(load, 0);\n    }\n  }, [value, min, max]);\n\n  useFrame((dt) => {\n    const boxEl = box.current;\n    const barEl = bar.current;\n    const tagEl = pct.current;\n\n    if (!boxEl || !barEl || !tagEl) {\n      return;\n    }\n\n    const load = loadOf(loadRef);\n    load.t += dt;\n    const r = boxEl.getBoundingClientRect();\n    load.vis = r.bottom > -80 && r.top < innerHeight + 80;\n    advanceLoad(load, dt);\n    const b = at(barEl);\n    const top = b.y - b.h / 2;\n    const { p } = load;\n\n    if (!load.doneAt && load.vis) {\n      ride(load, b, dt);\n    }\n\n    if (!load.doneAt && p >= 1) {\n      load.doneAt = Math.max(load.t, 1e-9);\n\n      if (load.vis) {\n        finish(b, top, backRef.current);\n      }\n\n      load.tag.x = 1.5;\n      onDone?.();\n    }\n\n    const n = load.doneAt ? 100 : Math.floor(p * 100);\n    const text = textOf(load, n, doneLabel);\n\n    if (text !== load.lastPct) {\n      load.lastPct = text;\n      flushSync(() => {\n        setShown({ text, value: load.unknown ? null : min + ((max - min) * n) / 100 });\n      });\n\n      if (n % 5 === 0 && !load.doneAt) {\n        load.tag.x = 1.1;\n      }\n    }\n\n    tagEl.style.transform = `skewX(-12deg) scale(${load.tag.step(dt)})`;\n\n    if (p !== load.shown) {\n      load.shown = p;\n      boxEl.style.setProperty(\"--v\", String(p));\n    }\n  });\n\n  return (\n    <ProgressPrimitive.Root\n      data-slot=\"sakuga-progress\"\n      className={cn(ROOT, FONT_BODY, className)}\n      min={min}\n      max={max}\n      value={shown.value}\n      aria-label={ariaLabel ?? (labelledBy ? undefined : \"Loading\")}\n      aria-labelledby={labelledBy}\n      {...props}\n    >\n      <SakugaStyle />\n      <canvas ref={attachBack} aria-hidden className={BACK_CANVAS} />\n      <div ref={box} data-slot=\"sakuga-progress-box\" className=\"relative pt-[70px]\">\n        <ProgressPrimitive.Track ref={bar} data-slot=\"sakuga-progress-track\" className={BAR}>\n          <ProgressPrimitive.Indicator\n            data-slot=\"sakuga-progress-indicator\"\n            className={FILL}\n            style={{ height: \"100%\", width: \"calc(var(--v, 0) * 100%)\" }}\n          />\n        </ProgressPrimitive.Track>\n        <ProgressPrimitive.Value ref={pct} data-slot=\"sakuga-progress-value\" className={PCT}>\n          {() => shown.text}\n        </ProgressPrimitive.Value>\n      </div>\n    </ProgressPrimitive.Root>\n  );\n};\n\nexport { SakugaProgress };\n","path":"/sakuga-progress.tsx","target":"uicapsule/sakuga-vfx/sakuga-progress.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { Radio as RadioPrimitive } from \"@base-ui/react/radio\";\nimport { RadioGroup as RadioGroupPrimitive } from \"@base-ui/react/radio-group\";\nimport { cn } from \"cn\";\nimport { createContext, use, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport { Spring, at, hollow, later, lines, puff, sfx, ticks } from \"./sakuga-core\";\nimport { SakugaStyle, useFrame, useMergedRef } from \"./sakuga-react\";\nimport type { Styled } from \"./sakuga-react\";\n\ntype SakugaRadioGroupProps<Value> = Styled<RadioGroupPrimitive.Props<Value>>;\n\ntype SakugaRadioGroupItemProps<Value> = Styled<RadioPrimitive.Root.Props<Value>>;\n\ninterface Picks {\n  handRef: RefObject<{ value: unknown } | null>;\n  itemsRef: RefObject<Map<unknown, Item>>;\n}\n\ninterface Item {\n  pop: () => void;\n  input: () => HTMLInputElement | null;\n}\n\nconst PicksContext = createContext<Picks | null>(null);\n\nconst GROUP = \"grid gap-[12px]\";\n\nconst ITEM =\n  \"grid h-[32px] w-[32px] flex-none cursor-pointer place-items-center rounded-full border-[length:var(--sk-bw)] border-(--sk-ink) bg-(--sk-card) will-change-transform [-webkit-tap-highlight-color:transparent] focus-visible:outline-none [&:focus-visible:not([data-by-pointer])]:outline-[2.5px] [&:focus-visible:not([data-by-pointer])]:outline-offset-[3px] [&:focus-visible:not([data-by-pointer])]:outline-(--sk-acc) [&:focus-visible:not([data-by-pointer])]:outline-solid data-disabled:cursor-not-allowed data-disabled:opacity-50\";\n\nconst DOT = \"h-[19px] w-[19px] [scale:var(--d,0)] rounded-full bg-(--sk-pri)\";\n\ninterface Rig {\n  s: Spring;\n  was: boolean | null;\n}\n\nconst makeRig = () => {\n  const rig: Rig = { s: new Spring(0, 520, 14), was: null };\n\n  return rig;\n};\n\nconst isOn = (root: HTMLElement | null) => root?.getAttribute(\"aria-checked\") === \"true\";\n\nconst pop = (root: HTMLElement | null) => {\n  if (!root) {\n    return;\n  }\n\n  const c = at(root);\n  ticks(c.x, c.y, { dir: -2.3, fan: 0.36, len: 15, life: 0.5, n: 4, r: 20 });\n  lines(c.x - 26, c.y + 18, { dir: 2.6, len: 26, n: 3, spread: 6 });\n  puff(c.x + 26, c.y - 22, { life: 0.7, n: 3, size: 8, vx: 16, vy: -14 });\n  later(120, () => puff(c.x + 78, c.y + 2, { life: 0.6, n: 3, size: 7, vx: 10, vy: -10 }));\n  sfx(\"pon\", c.x + 70, c.y - 76, { life: 0.8, rot: 0.06, size: 86, ...hollow() });\n};\n\nconst SakugaRadioGroup = <Value,>({\n  className,\n  value,\n  defaultValue,\n  onValueChange,\n  ...props\n}: SakugaRadioGroupProps<Value>) => {\n  const handRef = useRef<{ value: unknown } | null>(null);\n  const itemsRef = useRef(new Map<unknown, Item>());\n  const picks = useMemo(() => ({ handRef, itemsRef }), []);\n  const [own, setOwn] = useState<Value | null>(defaultValue ?? null);\n\n  const change = (next: Value, details: RadioGroupPrimitive.ChangeEventDetails) => {\n    onValueChange?.(next, details);\n\n    if (details.isCanceled) {\n      return;\n    }\n\n    if (value === undefined) {\n      setOwn(next);\n    }\n\n    const mark = { value: next };\n    handRef.current = mark;\n    later(0, () =>\n      later(0, () => {\n        if (handRef.current === mark) {\n          handRef.current = null;\n        }\n      }),\n    );\n\n    if (value === undefined) {\n      itemsRef.current.get(next)?.pop();\n    }\n  };\n\n  useLayoutEffect(() => {\n    if (value !== undefined && handRef.current?.value === value) {\n      itemsRef.current.get(value)?.pop();\n    }\n  }, [value]);\n\n  useEffect(() => {\n    const [first] = itemsRef.current.values();\n    const form = first?.input()?.form;\n\n    if (value !== undefined || !form) {\n      return;\n    }\n\n    const back = () => setOwn(defaultValue ?? null);\n    form.addEventListener(\"reset\", back);\n\n    return () => form.removeEventListener(\"reset\", back);\n  }, [value, defaultValue]);\n\n  return (\n    <PicksContext value={picks}>\n      <SakugaStyle />\n      <RadioGroupPrimitive\n        data-slot=\"sakuga-radio-group\"\n        className={cn(GROUP, className)}\n        value={value === undefined ? (own as Value) : value}\n        onValueChange={change}\n        {...props}\n      />\n    </PicksContext>\n  );\n};\n\nconst SakugaRadioGroupItem = <Value,>({\n  className,\n  value,\n  onPointerDown,\n  onKeyDown,\n  onBlur,\n  inputRef,\n  ref,\n  ...props\n}: SakugaRadioGroupItemProps<Value>) => {\n  const root = useRef<HTMLElement>(null);\n  const rigRef = useRef(makeRig());\n  const input = useRef<HTMLInputElement>(null);\n  const setRoot = useMergedRef<HTMLElement>(root, ref);\n  const setInput = useMergedRef(input, inputRef);\n  const picks = use(PicksContext);\n\n  useLayoutEffect(() => {\n    const rig = rigRef.current;\n    rig.was = isOn(root.current);\n    rig.s.to = rig.was ? 1 : 0;\n    rig.s.x = rig.s.to;\n    root.current?.style.setProperty(\"--d\", rig.s.x.toFixed(3));\n  }, []);\n\n  useEffect(() => {\n    const items = picks?.itemsRef.current;\n    items?.set(value, { input: () => input.current, pop: () => pop(root.current) });\n\n    return () => {\n      items?.delete(value);\n    };\n  }, [picks, value]);\n\n  useFrame((dt) => {\n    const rig = rigRef.current;\n\n    if (!root.current) {\n      return;\n    }\n\n    const on = isOn(root.current);\n\n    if (on !== rig.was) {\n      rig.was = on;\n      rig.s.to = on ? 1 : 0;\n\n      if (!picks?.handRef.current) {\n        rig.s.x = rig.s.to;\n        rig.s.v = 0;\n      }\n    }\n\n    root.current.style.setProperty(\"--d\", Math.max(0, rig.s.step(dt)).toFixed(3));\n  });\n\n  return (\n    <RadioPrimitive.Root\n      ref={setRoot}\n      inputRef={setInput}\n      data-slot=\"sakuga-radio-group-item\"\n      className={cn(ITEM, className)}\n      value={value}\n      onPointerDown={(e) => {\n        e.currentTarget.dataset.byPointer = \"\";\n        onPointerDown?.(e);\n      }}\n      onKeyDown={(e) => {\n        delete e.currentTarget.dataset.byPointer;\n        onKeyDown?.(e);\n      }}\n      onBlur={(e) => {\n        delete e.currentTarget.dataset.byPointer;\n        onBlur?.(e);\n      }}\n      {...props}\n    >\n      <RadioPrimitive.Indicator\n        data-slot=\"sakuga-radio-group-indicator\"\n        keepMounted\n        className={DOT}\n      />\n    </RadioPrimitive.Root>\n  );\n};\n\nexport { SakugaRadioGroup, SakugaRadioGroupItem };\n","path":"/sakuga-radio-group.tsx","target":"uicapsule/sakuga-vfx/sakuga-radio-group.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { cn } from \"cn\";\nimport { useEffect, useLayoutEffect, useReducer, useRef, useState } from \"react\";\nimport type { ComponentProps, KeyboardEvent, RefObject } from \"react\";\n\nimport {\n  Spring,\n  at,\n  burst,\n  clamp,\n  hollow,\n  kira,\n  later,\n  puff,\n  sfx,\n  shards,\n  ticks,\n} from \"./sakuga-core\";\nimport type { Layer } from \"./sakuga-core\";\nimport { BACK_CANVAS, FONT_BODY, SakugaStyle, useBackLayer, useFrame } from \"./sakuga-react\";\n\ntype SakugaRatingProps = Omit<ComponentProps<\"div\">, \"defaultValue\" | \"onChange\" | \"children\"> & {\n  value?: number;\n  defaultValue?: number;\n  onValueChange?: (value: number) => void;\n  max?: number;\n  name?: string;\n  disabled?: boolean;\n};\n\nconst STEPS = new Map([\n  [\"ArrowDown\", -1],\n  [\"ArrowLeft\", -1],\n  [\"ArrowRight\", 1],\n  [\"ArrowUp\", 1],\n]);\n\ninterface Pop {\n  b: HTMLButtonElement;\n  spring: Spring;\n  layer: RefObject<Layer | null>;\n  i: number;\n  n: number;\n  was: number;\n  full: boolean;\n  turn: number;\n  turns: RefObject<number>;\n}\n\nconst glint = (b: HTMLElement, x: number, y: number) => {\n  if (b.isConnected) {\n    kira(x, y, { r: 8 });\n  }\n};\n\nconst light = ({ b, spring, layer, i, n, was, full, turn, turns }: Pop) => {\n  if (turn !== turns.current || !b.isConnected) {\n    return;\n  }\n\n  b.toggleAttribute(\"data-lit\", i < n);\n\n  if (!(i < n && i >= was)) {\n    return;\n  }\n\n  spring.x = 0.35;\n  const c = at(b);\n  puff(c.x, c.y + 14, { life: 0.4, n: 2, size: 5 });\n\n  if (i !== n - 1) {\n    return;\n  }\n\n  ticks(c.x, c.y, { dir: -Math.PI / 2, fan: 0.698, len: full ? 26 : 17, life: 0.55, n: 9, r: 20 });\n\n  if (full) {\n    burst(c.x, c.y, { layer: layer.current ?? undefined, life: 0.4, r: 46 });\n    shards(c.x, c.y, { arc: 6.28, n: 6, size: 5 });\n  }\n\n  sfx(\"pon\", c.x + 20, c.y - 56, { life: 0.85, rot: 0.08, size: full ? 120 : 92, ...hollow() });\n  later(300, () => glint(b, c.x - 22, c.y - 30));\n};\n\nconst queue = (pop: Pop) => later(Math.max(0, pop.i - pop.was) * 60, () => light(pop));\n\nconst SakugaRating = ({\n  className,\n  value,\n  defaultValue = 0,\n  onValueChange,\n  max = 5,\n  name,\n  disabled = false,\n  \"aria-label\": label,\n  \"aria-labelledby\": labelledBy,\n  ...props\n}: SakugaRatingProps) => {\n  const score = (n: number) => clamp(Math.round(n) || 0, 0, max);\n  const [own, setOwn] = useState(defaultValue);\n  const rated = score(value ?? own);\n  const [first] = useReducer((kept: number) => kept, rated);\n\n  const [attachBack, backRef] = useBackLayer();\n  const stars = useRef<(HTMLButtonElement | null)[]>([]);\n  const springs = useRef<Spring[]>([]);\n  const shown = useRef(0);\n  const asked = useRef(-1);\n  const turns = useRef(0);\n  const field = useRef<HTMLInputElement>(null);\n\n  const owned = value !== undefined;\n  useEffect(() => {\n    const form = field.current?.form;\n\n    if (!form || owned) {\n      return;\n    }\n\n    const reset = () => setOwn(defaultValue);\n    form.addEventListener(\"reset\", reset);\n\n    return () => form.removeEventListener(\"reset\", reset);\n  }, [owned, defaultValue]);\n\n  useLayoutEffect(() => {\n    const quiet = asked.current !== rated;\n    const was = shown.current;\n    asked.current = -1;\n    shown.current = rated;\n    turns.current += 1;\n    const turn = turns.current;\n\n    for (const [i, b] of stars.current.entries()) {\n      const spring = springs.current[i];\n\n      if (quiet) {\n        b?.toggleAttribute(\"data-lit\", i < rated);\n      } else if (b && spring) {\n        queue({ b, full: rated === max, i, layer: backRef, n: rated, spring, turn, turns, was });\n      }\n    }\n  }, [rated, max, backRef]);\n\n  useFrame((dt) => {\n    for (const [i, b] of stars.current.entries()) {\n      const y = springs.current[i]?.step(dt) ?? 1;\n\n      if (b) {\n        b.style.transform =\n          Math.abs(y - 1) < 0.001 ? \"\" : `scale(${y}) rotate(${(1 - y) * -34}deg)`;\n      }\n    }\n  });\n\n  const rate = (n: number) => {\n    asked.current = n;\n\n    if (value === undefined) {\n      setOwn(n);\n    }\n\n    onValueChange?.(n);\n    queueMicrotask(() => {\n      asked.current = -1;\n    });\n  };\n\n  const keydown = (e: KeyboardEvent<HTMLButtonElement>) => {\n    const d = STEPS.get(e.key);\n\n    if (!d) {\n      return;\n    }\n\n    e.preventDefault();\n    const n = clamp((rated || (d > 0 ? 0 : 2)) + d, 1, max);\n    rate(n);\n    stars.current[n - 1]?.focus();\n  };\n\n  return (\n    <div\n      role=\"radiogroup\"\n      data-slot=\"sakuga-rating\"\n      data-disabled={disabled ? \"\" : undefined}\n      aria-label={labelledBy ? undefined : (label ?? \"Rating\")}\n      aria-labelledby={labelledBy}\n      aria-disabled={disabled || undefined}\n      className={cn(\n        \"relative isolate inline-flex align-middle text-[15px] leading-[1.4] font-medium text-(--sk-ink)\",\n        FONT_BODY,\n        className,\n      )}\n      {...props}\n    >\n      <SakugaStyle />\n      <canvas ref={attachBack} aria-hidden className={BACK_CANVAS} />\n      {Array.from({ length: max }, (_, i) => {\n        const n = i + 1;\n\n        return (\n          <button\n            key={n}\n            ref={(node) => {\n              stars.current[i] = node;\n\n              if (!springs.current[i]) {\n                springs.current[i] = new Spring(1, 560, 12);\n              }\n            }}\n            type=\"button\"\n            // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- a star can be cleared by clicking it again, which a native radio cannot do\n            role=\"radio\"\n            data-slot=\"sakuga-rating-star\"\n            aria-checked={n === rated}\n            aria-label={`${n} star${n > 1 ? \"s\" : \"\"}`}\n            tabIndex={(rated ? n === rated : i === 0) ? 0 : -1}\n            disabled={disabled}\n            data-disabled={disabled ? \"\" : undefined}\n            data-lit={n <= first ? \"\" : undefined}\n            className=\"group size-[44px] cursor-pointer p-[2px] will-change-transform focus-visible:outline-[2.5px] focus-visible:outline-offset-[3px] focus-visible:outline-(--sk-acc) data-disabled:cursor-not-allowed data-disabled:opacity-50\"\n            onClick={() => rate(rated === n ? 0 : n)}\n            onKeyDown={keydown}\n          >\n            <svg\n              aria-hidden\n              viewBox=\"0 0 24 24\"\n              className=\"inline size-full overflow-visible fill-(--sk-card) stroke-(--sk-ink) stroke-[2.3] align-baseline [stroke-linejoin:round] group-data-lit:fill-(--sk-pri)\"\n            >\n              <path d=\"M12 2.6l2.9 6 6.5.9-4.7 4.6 1.1 6.5L12 17.5l-5.8 3.1 1.1-6.5L2.6 9.5l6.5-.9z\" />\n            </svg>\n          </button>\n        );\n      })}\n      <input\n        ref={field}\n        type=\"hidden\"\n        name={name}\n        value={rated}\n        disabled={disabled || rated === 0}\n      />\n    </div>\n  );\n};\n\nexport { SakugaRating };\n","path":"/sakuga-rating.tsx","target":"uicapsule/sakuga-vfx/sakuga-rating.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { useCallback, useEffect, useLayoutEffect, useRef } from \"react\";\nimport type { Ref, RefObject } from \"react\";\n\nimport { addBackLayer, onFrame, removeBackLayer, squashy } from \"./sakuga-core\";\nimport type { Layer, Squashy } from \"./sakuga-core\";\n\nexport type Styled<Props> = Omit<Props, \"className\"> & { className?: string };\n\nconst assignRef = <T,>(ref: Ref<T> | undefined, node: T | null) => {\n  if (!ref) {\n    return null;\n  }\n\n  if (\"current\" in ref) {\n    ref.current = node;\n\n    return null;\n  }\n\n  return ref(node) ?? null;\n};\n\nexport const useMergedRef = <T,>(...refs: (Ref<T> | undefined)[]) => {\n  const latest = useRef(refs);\n\n  const held = useRef<{ node: T | null; cleanups: ((() => void) | null)[]; refs: typeof refs }>({\n    cleanups: [],\n    node: null,\n    refs: [],\n  });\n\n  const release = (i: number) => {\n    const cleanup = held.current.cleanups[i];\n\n    if (cleanup) {\n      cleanup();\n    } else {\n      assignRef(held.current.refs[i], null);\n    }\n  };\n\n  useLayoutEffect(() => {\n    latest.current = refs;\n    const h = held.current;\n\n    if (h.node === null) {\n      return;\n    }\n\n    for (const [i, ref] of refs.entries()) {\n      if (h.refs[i] !== ref) {\n        release(i);\n        h.refs[i] = ref;\n        h.cleanups[i] = assignRef(ref, h.node);\n      }\n    }\n  });\n\n  return useCallback((node: T | null) => {\n    const h = held.current;\n    h.node = node;\n    h.refs = [...latest.current];\n    h.cleanups = h.refs.map((ref) => assignRef(ref, node));\n\n    return () => {\n      for (const i of h.refs.keys()) {\n        const cleanup = h.cleanups[i];\n\n        if (cleanup) {\n          cleanup();\n        } else {\n          assignRef(h.refs[i], null);\n        }\n      }\n\n      held.current = { cleanups: [], node: null, refs: [] };\n    };\n  }, []);\n};\n\nconst VARS =\n  \"--sk-card:#fff;--sk-ink:#1d1a4a;--sk-dim:#8580b0;--sk-soft:#b8b3ff;--sk-pri:#8f8df7;--sk-pri-ink:#1d1a4a;--sk-acc:#ff5fa8;--sk-track:#c9cbe0;--sk-r:15px;--sk-bw:3.2px;--sk-sh:6px 7px 0 var(--sk-soft);--sk-btn-sh:var(--sk-sh);--sk-btn-line:var(--sk-ink);--sk-alt-sh:var(--sk-sh);--sk-alt-line:var(--sk-ink);--sk-tick:var(--sk-ink);--sk-fill:var(--sk-acc);--sk-on-pri:#fff;\";\n\nexport const SakugaStyle = () => (\n  <style href=\"sakuga-vfx\" precedence=\"default\">{`:where(:root){${VARS}}`}</style>\n);\n\nexport const FONT_BODY =\n  '[font-family:-apple-system,BlinkMacSystemFont,\"Inter\",\"Segoe_UI\",system-ui,sans-serif]';\n\nexport const FONT_DISPLAY =\n  '[font-family:\"Avenir_Next\",\"Nunito\",-apple-system,\"Segoe_UI\",system-ui,sans-serif]';\n\nexport const BACK_CANVAS =\n  \"pointer-events-none absolute -left-40 -top-40 -z-10 h-[calc(100%+320px)] w-[calc(100%+320px)]\";\n\nexport const useFrame = (fn: (dt: number) => void) => {\n  const latest = useRef(fn);\n  useEffect(() => {\n    latest.current = fn;\n  });\n  useEffect(() => onFrame((dt) => latest.current(dt)), []);\n};\n\nexport const useBackLayer = () => {\n  const layer = useRef<Layer | null>(null);\n\n  const attach = useCallback((canvas: HTMLCanvasElement | null) => {\n    if (layer.current) {\n      removeBackLayer(layer.current);\n      layer.current = null;\n    }\n\n    if (canvas) {\n      layer.current = addBackLayer(canvas);\n    }\n  }, []);\n\n  return [attach, layer] as const;\n};\n\nexport const useSquashy = (\n  el: RefObject<HTMLElement | null>,\n  { low, k, d, wide }: { low?: number; k?: number; d?: number; wide?: number } = {},\n) => {\n  const sq = useRef<Squashy | null>(null);\n  useEffect(() => {\n    if (!el.current) {\n      return;\n    }\n\n    const made = squashy(el.current, { d, k, low, wide });\n    sq.current = made;\n\n    return () => {\n      made.dispose();\n      sq.current = null;\n    };\n  }, [el, low, k, d, wide]);\n\n  return sq;\n};\n","path":"/sakuga-react.tsx","target":"uicapsule/sakuga-vfx/sakuga-react.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { Select as SelectPrimitive } from \"@base-ui/react/select\";\nimport { cn } from \"cn\";\nimport { createContext, use, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport { Spring, at, clamp, later, puff, sfx, ticks } from \"./sakuga-core\";\nimport type { Squashy } from \"./sakuga-core\";\nimport {\n  FONT_BODY,\n  FONT_DISPLAY,\n  SakugaStyle,\n  useFrame,\n  useMergedRef,\n  useSquashy,\n} from \"./sakuga-react\";\nimport type { Styled } from \"./sakuga-react\";\n\ninterface Rig {\n  anchor: HTMLElement | null;\n  trigger: HTMLElement | null;\n  text: HTMLElement | null;\n  chevron: SVGElement | null;\n  popup: HTMLElement | null;\n  raised: HTMLElement | null;\n  rows: Set<HTMLElement>;\n  squash: Squashy | null;\n  out: Spring;\n  flip: Spring;\n  rowY: Spring;\n  rowH: Spring;\n  land: Spring;\n  open: boolean;\n  seq: number;\n  pick: number;\n  byHand: boolean;\n  kept: boolean;\n  held: boolean;\n  under: HTMLElement | null;\n  jump: boolean;\n}\n\nconst makeRig = () => {\n  const rig: Rig = {\n    anchor: null,\n    byHand: false,\n    chevron: null,\n    flip: new Spring(0, 420, 13),\n    held: false,\n    jump: true,\n    kept: false,\n    land: new Spring(1, 600, 13),\n    open: false,\n    out: new Spring(0, 460, 20),\n    pick: 0,\n    popup: null,\n    raised: null,\n    rowH: new Spring(0, 320, 26),\n    rowY: new Spring(0, 320, 23),\n    rows: new Set(),\n    seq: 0,\n    squash: null,\n    text: null,\n    trigger: null,\n    under: null,\n  };\n\n  return rig;\n};\n\nconst RigContext = createContext<RefObject<Rig> | null>(null);\n\nconst useRig = () => {\n  const rigRef = use(RigContext);\n\n  if (!rigRef) {\n    throw new Error(\"SakugaSelect parts must be inside <SakugaSelect>\");\n  }\n\n  return rigRef;\n};\n\nconst isUp = (popup: HTMLElement) => popup.dataset.side === \"top\";\n\nconst rowWith = (rig: Rig, mark: \"highlighted\" | \"selected\") => {\n  for (const row of rig.rows) {\n    if (row.dataset[mark] !== undefined) {\n      return row;\n    }\n  }\n\n  return null;\n};\n\nconst ring = (rig: Rig, on: boolean) => {\n  rig.trigger?.toggleAttribute(\"data-ring\", on);\n};\n\nconst openEffects = (rig: Rig) => {\n  const { popup: m, trigger: b } = rig;\n\n  if (!b || !m) {\n    return;\n  }\n\n  const above = isUp(m);\n  const q = at(b);\n  const left = q.x - q.w / 2;\n  const right = left + m.offsetWidth;\n  const far = above ? -1 : 1;\n  const end = q.y + far * (q.h / 2 + 13 + m.offsetHeight);\n  puff(left - 9, end - far * 16, { life: 0.8, n: 4, size: 8, vx: -14, vy: -6 });\n  puff(right + 13, end - far * 30, { life: 0.7, n: 3, size: 7, vx: 14, vy: -10 });\n  sfx(\"shu\", q.x + q.w / 2 + (above ? -34 : 4), q.y - far * (q.h / 2 + (above ? 30 : 36)), {\n    col: \"#5a4fd8\",\n    edge: \"#ffffff\",\n    life: 0.75,\n    rot: -0.16,\n    size: 88,\n  });\n};\n\nconst landEffects = (rig: Rig) => {\n  const b = rig.trigger;\n\n  if (!b?.isConnected) {\n    return;\n  }\n\n  rig.land.x = 0.68;\n\n  if (rig.squash) {\n    rig.squash.s.v += 3;\n  }\n\n  const c = at(b, 1, 0);\n  const q = at(b);\n  ticks(c.x - 8, c.y - 4, { dir: -1.05, fan: 0.36, len: 17, life: 0.5, n: 3, r: 5 });\n  puff(q.x - q.w / 2 - 9, q.y + q.h / 2 - 2, { life: 0.6, n: 3, size: 7, vx: -12, vy: -8 });\n};\n\nconst aim = (rig: Rig, row: HTMLElement, jump: boolean) => {\n  rig.under = row;\n  rig.rowY.to = row.offsetTop;\n  rig.rowH.to = row.offsetHeight;\n\n  if (jump) {\n    rig.rowY.x = rig.rowY.to;\n    rig.rowY.v = 0;\n    rig.rowH.x = rig.rowH.to;\n    rig.rowH.v = 0;\n  }\n};\n\nconst turn = (rig: Rig, open: boolean) => {\n  if (open === rig.open) {\n    return;\n  }\n\n  rig.open = open;\n  rig.seq += 1;\n\n  if (!open) {\n    rig.kept = true;\n\n    return;\n  }\n\n  rig.kept = false;\n  rig.jump = true;\n  rig.under = null;\n\n  if (rig.squash) {\n    rig.squash.s.v += 2;\n  }\n\n  if (rig.byHand) {\n    const n = rig.seq;\n    later(120, () => {\n      if (n === rig.seq) {\n        openEffects(rig);\n      }\n    });\n  }\n\n  rig.byHand = false;\n};\n\nconst stepMenu = (rig: Rig, dt: number) => {\n  const s = rig.out;\n  const want = rig.open || rig.held ? 1 : 0;\n  s.to = want;\n  s.d = want ? 20 : 34;\n  rig.flip.to = want;\n  const y = Math.max(0, s.step(dt));\n\n  if (rig.chevron) {\n    rig.chevron.style.transform = `rotate(${(rig.flip.step(dt) * 180).toFixed(1)}deg)`;\n  }\n\n  const m = rig.popup;\n\n  if (m) {\n    const st = clamp(1 + s.v * 0.012, 0.82, 1.22);\n    m.style.transform = `scale(${(y / st).toFixed(4)}, ${(y * st).toFixed(4)}) rotate(${((1 - y) * (isUp(m) ? 7 : -7)).toFixed(2)}deg)`;\n  }\n\n  if (want === 0 && rig.kept && y < 0.004) {\n    rig.kept = false;\n\n    return true;\n  }\n\n  return false;\n};\n\nconst stepRaised = (rig: Rig, dt: number) => {\n  const { raised } = rig;\n\n  if (!raised) {\n    return;\n  }\n\n  if (rig.open && !rig.held) {\n    const lit = rowWith(rig, \"highlighted\") ?? (rig.under ? null : rowWith(rig, \"selected\"));\n\n    if (lit && lit !== rig.under) {\n      aim(rig, lit, rig.jump);\n      rig.jump = false;\n    }\n  }\n\n  const ry = rig.rowY;\n  const x = ry.step(dt);\n  const h = rig.rowH.step(dt) + Math.min(8, Math.abs(ry.v) * 0.04);\n  const top = x - (ry.v < 0 ? 0 : h - rig.rowH.x);\n  raised.style.transform = `translateY(${top.toFixed(2)}px)`;\n  raised.style.height = `${h.toFixed(2)}px`;\n\n  for (const row of rig.rows) {\n    const mid = row.offsetTop + row.offsetHeight / 2;\n    row.toggleAttribute(\"data-on\", mid > top && mid < top + h);\n  }\n};\n\nconst stepRig = (rig: Rig, dt: number) => {\n  const gone = stepMenu(rig, dt);\n  stepRaised(rig, dt);\n\n  if (rig.text) {\n    const p = rig.land.step(dt);\n    rig.text.style.transform =\n      Math.abs(p - 1) < 0.001 ? \"\" : `scale(${(1 + (1 - p) * 0.5).toFixed(3)}, ${p.toFixed(3)})`;\n  }\n\n  return gone;\n};\n\nconst chosen = (rig: Rig, pressed: EventTarget | null) => {\n  const { text } = rig;\n  const was = text?.textContent ?? \"\";\n  rig.pick += 1;\n  const n = rig.pick;\n\n  const landIfChanged = () => {\n    if (n === rig.pick && (text?.textContent ?? \"\") !== was) {\n      landEffects(rig);\n    }\n  };\n\n  if (!rig.open) {\n    later(0, landIfChanged);\n\n    return;\n  }\n\n  let row = rowWith(rig, \"highlighted\");\n\n  if (pressed instanceof Node) {\n    for (const each of rig.rows) {\n      if (each.contains(pressed)) {\n        row = each;\n      }\n    }\n  }\n\n  if (!row || row.dataset.selected !== undefined) {\n    return;\n  }\n\n  aim(rig, row, true);\n  const hit = row;\n  hit.dataset.inv = \"\";\n  later(190, () => {\n    delete hit.dataset.inv;\n  });\n  rig.held = true;\n  later(50, () => {\n    if (n === rig.pick) {\n      rig.held = false;\n    }\n  });\n  later(190, landIfChanged);\n};\n\nconst SakugaSelect = <Value, Multiple extends boolean | undefined = false>({\n  actionsRef,\n  inputRef,\n  open: openProp,\n  defaultOpen = false,\n  onOpenChange,\n  value: valueProp,\n  defaultValue,\n  onValueChange,\n  children,\n  ...props\n}: SelectPrimitive.Root.Props<Value, Multiple>) => {\n  const rigRef = useMemo(() => ({ current: makeRig() }), []);\n  const ownActions = useRef<SelectPrimitive.Root.Actions>(null);\n  const actions = actionsRef ?? ownActions;\n  const [ownOpen, setOwnOpen] = useState(defaultOpen);\n  const open = openProp ?? ownOpen;\n  const { multiple } = props;\n\n  const start = useMemo(\n    () => (defaultValue ?? (multiple ? [] : null)) as typeof valueProp,\n    [defaultValue, multiple],\n  );\n\n  const [ownValue, setOwnValue] = useState(start);\n  const owned = valueProp !== undefined;\n  const field = useRef<HTMLInputElement>(null);\n  const fieldRef = useMergedRef(field, inputRef);\n\n  useLayoutEffect(() => {\n    turn(rigRef.current, open);\n  }, [open, rigRef]);\n\n  useEffect(() => {\n    const form = field.current?.form;\n\n    if (!form || owned) {\n      return;\n    }\n\n    const reset = () => setOwnValue(start);\n    form.addEventListener(\"reset\", reset);\n\n    return () => form.removeEventListener(\"reset\", reset);\n  }, [owned, start]);\n\n  useFrame((dt) => {\n    if (stepRig(rigRef.current, dt)) {\n      actions.current?.unmount();\n    }\n  });\n\n  return (\n    <SelectPrimitive.Root\n      modal={false}\n      {...props}\n      actionsRef={actions}\n      inputRef={fieldRef}\n      open={open}\n      value={owned ? valueProp : ownValue}\n      onOpenChange={(next, details) => {\n        onOpenChange?.(next, details);\n\n        if (details.isCanceled) {\n          return;\n        }\n\n        if (next) {\n          rigRef.current.byHand =\n            details.reason !== \"none\" && details.reason !== \"imperative-action\";\n\n          if (rigRef.current.trigger?.matches(\":focus-visible\")) {\n            ring(rigRef.current, true);\n          }\n        } else {\n          if (details.reason === \"focus-out\" || details.reason === \"outside-press\") {\n            ring(rigRef.current, false);\n          }\n\n          details.preventUnmountOnClose();\n        }\n\n        setOwnOpen(next);\n      }}\n      onValueChange={(value, details) => {\n        onValueChange?.(value, details);\n\n        if (details.isCanceled) {\n          return;\n        }\n\n        if (details.reason !== \"none\") {\n          chosen(rigRef.current, details.event.target);\n        }\n\n        if (!owned) {\n          setOwnValue(value);\n        }\n      }}\n    >\n      <SakugaStyle />\n      <RigContext value={rigRef}>{children}</RigContext>\n    </SelectPrimitive.Root>\n  );\n};\n\nconst PRESS = { low: 0.8, wide: 0.3 };\n\nconst SakugaSelectTrigger = ({\n  className,\n  children,\n  ref,\n  onBlur,\n  onMouseDown,\n  onPointerDown,\n  ...props\n}: Styled<SelectPrimitive.Trigger.Props>) => {\n  const rigRef = useRig();\n  const el = useRef<HTMLButtonElement>(null);\n\n  const triggerRef = useMergedRef(\n    el,\n    (node: HTMLButtonElement | null) => {\n      rigRef.current.trigger = node;\n    },\n    ref,\n  );\n\n  const sqRef = useSquashy(el, PRESS);\n  useFrame((dt) => {\n    rigRef.current.squash = sqRef.current;\n    sqRef.current?.step(dt);\n  });\n\n  return (\n    <span\n      ref={(node) => {\n        rigRef.current.anchor = node;\n      }}\n      data-slot=\"sakuga-select-anchor\"\n      className=\"relative isolate inline-block align-middle\"\n    >\n      <SelectPrimitive.Trigger\n        data-slot=\"sakuga-select-trigger\"\n        className={cn(\n          \"flex w-full min-w-[196px] cursor-pointer touch-manipulation items-center justify-between gap-[14px] rounded-(--sk-r) border-[length:var(--sk-bw)] border-(--sk-ink) bg-(--sk-card) py-[11px] pr-[14px] pl-[18px] text-left text-[17px] leading-[1.1] font-extrabold tracking-[-0.01em] text-(--sk-ink) italic shadow-(--sk-sh) will-change-transform select-none focus-visible:outline-[2.5px] focus-visible:outline-offset-[3px] focus-visible:outline-(--sk-acc) data-disabled:cursor-not-allowed data-disabled:opacity-45 data-ring:outline-[2.5px] data-ring:outline-offset-[3px] data-ring:outline-(--sk-acc)\",\n          FONT_DISPLAY,\n          className,\n        )}\n        {...props}\n        ref={triggerRef}\n        onBlur={(e) => {\n          onBlur?.(e);\n          const to = e.relatedTarget;\n\n          if (!(to instanceof Node && rigRef.current.popup?.contains(to))) {\n            ring(rigRef.current, false);\n          }\n        }}\n        onMouseDown={(e) => {\n          onMouseDown?.(e);\n          e.preventBaseUIHandler();\n        }}\n        onPointerDown={(e) => {\n          onPointerDown?.(e);\n          e.preventBaseUIHandler();\n        }}\n      >\n        {children}\n        <SelectPrimitive.Icon\n          render={\n            <svg\n              ref={(node) => {\n                rigRef.current.chevron = node;\n              }}\n              aria-hidden\n              viewBox=\"0 0 20 20\"\n              className=\"h-[20px] w-[20px] flex-none fill-none stroke-current stroke-[3.4] will-change-transform [stroke-linecap:round] [stroke-linejoin:round]\"\n            />\n          }\n        >\n          <path d=\"M4.5 7.5l5.5 5.5 5.5-5.5\" />\n        </SelectPrimitive.Icon>\n      </SelectPrimitive.Trigger>\n    </span>\n  );\n};\n\nconst SakugaSelectValue = ({ className, ref, ...props }: Styled<SelectPrimitive.Value.Props>) => {\n  const rigRef = useRig();\n\n  const textRef = useMergedRef((node: HTMLSpanElement | null) => {\n    rigRef.current.text = node;\n  }, ref);\n\n  return (\n    <SelectPrimitive.Value\n      data-slot=\"sakuga-select-value\"\n      className={cn(\"min-w-0 origin-left truncate will-change-transform\", className)}\n      {...props}\n      ref={textRef}\n    />\n  );\n};\n\nconst SakugaSelectContent = ({\n  className,\n  children,\n  ref,\n  onKeyDownCapture,\n  side = \"bottom\",\n  sideOffset = 13,\n  align = \"start\",\n  alignOffset = 0,\n  alignItemWithTrigger = false,\n  collisionPadding = 12,\n  ...props\n}: Styled<SelectPrimitive.Popup.Props> &\n  Pick<\n    SelectPrimitive.Positioner.Props,\n    \"align\" | \"alignOffset\" | \"side\" | \"sideOffset\" | \"alignItemWithTrigger\" | \"collisionPadding\"\n  >) => {\n  const rigRef = useRig();\n\n  const popupRef = useMergedRef((node: HTMLDivElement | null) => {\n    rigRef.current.popup = node;\n  }, ref);\n\n  return (\n    <SelectPrimitive.Portal>\n      <SelectPrimitive.Positioner\n        anchor={() => rigRef.current.anchor}\n        side={side}\n        sideOffset={sideOffset}\n        align={align}\n        alignOffset={alignOffset}\n        alignItemWithTrigger={alignItemWithTrigger}\n        collisionPadding={collisionPadding}\n        className=\"isolate z-50\"\n      >\n        <SelectPrimitive.Popup\n          data-slot=\"sakuga-select-content\"\n          className={cn(\n            \"w-max max-w-[min(300px,calc(100vw-32px))] min-w-(--anchor-width) origin-[50%_-16px] rounded-[13px] border-[length:var(--sk-bw)] border-(--sk-ink) bg-(--sk-card) p-[5px] text-[15px] leading-[1.4] font-medium text-(--sk-ink) shadow-(--sk-sh) outline-none [transform:scale(0)] will-change-transform data-closed:pointer-events-none data-[side=top]:origin-[50%_calc(100%+16px)]\",\n            FONT_BODY,\n            className,\n          )}\n          {...props}\n          ref={popupRef}\n          onKeyDownCapture={(e) => {\n            onKeyDownCapture?.(e);\n            ring(rigRef.current, true);\n          }}\n        >\n          <SelectPrimitive.List className=\"relative max-h-[min(320px,calc(var(--available-height)-17px))] overflow-y-auto overscroll-contain outline-none [scrollbar-color:var(--sk-ink)_transparent] [scrollbar-width:thin]\">\n            <span\n              ref={(node) => {\n                rigRef.current.raised = node;\n              }}\n              aria-hidden\n              className=\"absolute top-0 right-0 left-0 rounded-[9px] border-[2.4px] border-(--sk-ink) bg-(--sk-soft) will-change-transform\"\n            />\n            {children}\n          </SelectPrimitive.List>\n        </SelectPrimitive.Popup>\n      </SelectPrimitive.Positioner>\n    </SelectPrimitive.Portal>\n  );\n};\n\nconst SakugaSelectItem = ({\n  className,\n  children,\n  ref,\n  ...props\n}: Styled<SelectPrimitive.Item.Props>) => {\n  const rigRef = useRig();\n\n  const rowRef = useMergedRef((node: HTMLDivElement | null) => {\n    if (!node) {\n      return;\n    }\n\n    const { rows } = rigRef.current;\n    rows.add(node);\n\n    return () => {\n      rows.delete(node);\n    };\n  }, ref);\n\n  return (\n    <SelectPrimitive.Item\n      data-slot=\"sakuga-select-item\"\n      className={cn(\n        \"group/sk-row relative flex cursor-pointer items-center justify-between gap-[14px] rounded-[9px] px-[12px] py-[9px] text-[15px] leading-[1.2] font-semibold whitespace-nowrap outline-none select-none [paint-order:stroke_fill] [-webkit-text-stroke:3px_var(--sk-card)] data-disabled:cursor-not-allowed data-disabled:opacity-45 data-on:[-webkit-text-stroke-color:var(--sk-soft)] data-[selected]:font-extrabold data-inv:bg-(--sk-ink) data-inv:text-(--sk-card) data-inv:[-webkit-text-stroke-color:var(--sk-ink)]!\",\n        className,\n      )}\n      {...props}\n      ref={rowRef}\n    >\n      <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n      <SelectPrimitive.ItemIndicator\n        keepMounted\n        render={\n          <svg\n            aria-hidden\n            viewBox=\"0 0 24 18\"\n            className=\"invisible h-[12px] w-[16px] flex-none fill-none stroke-(--sk-acc) stroke-[4.6] [stroke-linecap:round] [stroke-linejoin:round] group-data-[selected]/sk-row:visible\"\n          />\n        }\n      >\n        <path d=\"M3 9.5l6 6L21 2.5\" />\n      </SelectPrimitive.ItemIndicator>\n    </SelectPrimitive.Item>\n  );\n};\n\nconst SakugaSelectGroup = ({ className, ...props }: Styled<SelectPrimitive.Group.Props>) => (\n  <SelectPrimitive.Group data-slot=\"sakuga-select-group\" className={className} {...props} />\n);\n\nconst SakugaSelectLabel = ({ className, ...props }: Styled<SelectPrimitive.GroupLabel.Props>) => (\n  <SelectPrimitive.GroupLabel\n    data-slot=\"sakuga-select-label\"\n    className={cn(\n      \"px-[12px] pt-[8px] pb-[4px] text-[12px] leading-[1.2] font-extrabold tracking-[0.04em] whitespace-nowrap text-(--sk-dim) uppercase select-none\",\n      className,\n    )}\n    {...props}\n  />\n);\n\nconst SakugaSelectSeparator = ({\n  className,\n  ...props\n}: Styled<SelectPrimitive.Separator.Props>) => (\n  <SelectPrimitive.Separator\n    data-slot=\"sakuga-select-separator\"\n    className={cn(\"mx-[4px] my-[5px] h-[2.4px] rounded-full bg-(--sk-ink)\", className)}\n    {...props}\n  />\n);\n\nexport {\n  SakugaSelect,\n  SakugaSelectContent,\n  SakugaSelectGroup,\n  SakugaSelectItem,\n  SakugaSelectLabel,\n  SakugaSelectSeparator,\n  SakugaSelectTrigger,\n  SakugaSelectValue,\n};\n","path":"/sakuga-select.tsx","target":"uicapsule/sakuga-vfx/sakuga-select.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { Slider as SliderPrimitive } from \"@base-ui/react/slider\";\nimport { cn } from \"cn\";\nimport { useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport type { PointerEvent, RefObject } from \"react\";\n\nimport {\n  Spring,\n  at,\n  burst,\n  clamp,\n  later,\n  lines,\n  puff,\n  rnd,\n  sfx,\n  shards,\n  slash,\n  ticks,\n  wob,\n} from \"./sakuga-core\";\nimport { FONT_BODY, SakugaStyle, useFrame } from \"./sakuga-react\";\nimport type { Styled } from \"./sakuga-react\";\n\ntype SakugaSliderProps = Styled<SliderPrimitive.Root.Props<number>> & {\n  unit?: string;\n};\n\nconst NATIVE_THUMB = 16;\n\nconst ROOT =\n  \"group/sakuga-slider relative isolate mt-[30px] inline-block align-middle text-[15px] leading-[1.4] font-medium text-(--sk-ink)\";\n\nconst BOX =\n  \"relative h-[46px] w-(--sk-slider-width,230px) max-w-full group-data-disabled/sakuga-slider:opacity-50 has-[input:focus-visible]:rounded-[8px] has-[input:focus-visible]:outline-[2.5px] has-[input:focus-visible]:outline-offset-[6px] has-[input:focus-visible]:outline-(--sk-acc)\";\n\nconst TRACK =\n  \"absolute inset-x-0 top-[16px] h-[14px] overflow-hidden rounded-[7px] border-[length:var(--sk-bw)] border-(--sk-ink) bg-(--sk-card)\";\n\nconst BUBBLE =\n  \"absolute -top-[30px] -left-[9px] min-w-[46px] origin-[50%_160%] rounded-[9px] border-[2.6px] border-(--sk-ink) bg-(--sk-card) px-[4px] py-[3px] text-center [font-family:-apple-system,'Segoe_UI',system-ui,sans-serif] text-[13px] leading-[1.1] font-extrabold whitespace-nowrap will-change-transform after:absolute after:top-full after:left-1/2 after:-ml-[5px] after:border-[5px] after:border-t-[7px] after:border-transparent after:border-t-(--sk-ink) after:content-['']\";\n\nconst CONTROL =\n  \"absolute inset-x-0 -inset-y-[8px] cursor-ew-resize touch-none px-[8px] data-disabled:cursor-not-allowed\";\n\nconst THUMB =\n  \"pointer-events-none size-[28px] rounded-full border-[length:var(--sk-bw)] border-(--sk-ink) bg-white will-change-transform\";\n\nconst trail = (c: { x: number; y: number }, dir: number, big: number) => {\n  const px = c.x - dir * rnd(14, 30);\n  const py = c.y - rnd(2, 12) - big * 8;\n  const size = rnd(6, 9) + big * 9;\n  const vx = -dir * rnd(26, 70);\n  const vy = -rnd(22, 58) * (0.5 + big);\n  const life = rnd(0.7, 1.15);\n  puff(px, py, { life, n: 4, size, vx, vy });\n  lines(c.x - dir * 16, c.y + rnd(-4, 12), {\n    dir: dir > 0 ? Math.PI : 0,\n    len: 50 + big * 50,\n    life: 0.24,\n    n: 1,\n    spread: 2,\n  });\n\n  if (Math.random() < 0.3) {\n    shards(c.x - dir * 20, c.y + 6, {\n      arc: 1,\n      dir: dir > 0 ? Math.PI + 0.5 : -0.5,\n      n: 1,\n      size: 3.5,\n      speed: 120,\n    });\n  }\n};\n\ninterface Chase {\n  frac: number;\n  started: boolean;\n  value: number;\n}\n\nconst SliderChase = ({\n  value,\n  frac,\n  springRef,\n  chaseRef,\n}: {\n  value: number;\n  frac: number;\n  springRef: RefObject<Spring>;\n  chaseRef: RefObject<Chase>;\n}) => {\n  useLayoutEffect(() => {\n    const chase = chaseRef.current;\n    chase.value = value;\n    chase.frac = frac;\n    springRef.current.to = frac;\n\n    if (!chase.started) {\n      chase.started = true;\n      springRef.current.x = frac;\n    }\n  }, [value, frac, springRef, chaseRef]);\n\n  return null;\n};\n\nconst SakugaSlider = ({\n  className,\n  unit = \"%\",\n  min = 0,\n  max = 100,\n  value,\n  defaultValue = 50,\n  onValueChange,\n  onValueCommitted,\n  \"aria-label\": ariaLabel,\n  ...props\n}: SakugaSliderProps) => {\n  const [inner, setInner] = useState(defaultValue);\n  const current = value ?? inner;\n  const box = useRef<HTMLDivElement>(null);\n  const thumb = useRef<HTMLDivElement>(null);\n  const bubble = useRef<HTMLOutputElement>(null);\n  const input = useRef<HTMLInputElement>(null);\n  const spring = useRef(new Spring(0, 420, 30));\n  const sim = useRef({ acc: 0, peak: 0, said: 0, t: 0 });\n  const chase = useRef<Chase>({ frac: 0, started: false, value: min });\n  const press = useRef({ from: Number.NaN, onThumb: false });\n  const fracOf = (v: number) => (max > min ? (clamp(v, min, max) - min) / (max - min) : 0);\n\n  useEffect(() => {\n    if (value !== undefined) {\n      return;\n    }\n\n    const restore = (e: Event) => {\n      if (\n        e.target === input.current?.form &&\n        chase.current.value !== clamp(defaultValue, min, max)\n      ) {\n        chase.current.started = false;\n        spring.current.v = 0;\n        sim.current.peak = 0;\n        setInner(defaultValue);\n      }\n    };\n\n    document.addEventListener(\"reset\", restore);\n\n    return () => document.removeEventListener(\"reset\", restore);\n  }, [value, defaultValue, min, max]);\n\n  const pressDown = (e: PointerEvent<HTMLDivElement>) => {\n    const r = e.currentTarget.getBoundingClientRect();\n    const left = r.left + chase.current.frac * (r.width - NATIVE_THUMB);\n    const top = r.top + (r.height - NATIVE_THUMB) / 2;\n    press.current = {\n      from: chase.current.value,\n      onThumb:\n        e.clientX > left - 1 &&\n        e.clientX < left + NATIVE_THUMB &&\n        e.clientY >= top &&\n        e.clientY < top + NATIVE_THUMB,\n    };\n  };\n\n  const release = (next: number) => {\n    const th = thumb.current;\n    const s = sim.current;\n\n    if (th) {\n      const c = at(th);\n      const dir = Math.sign(s.peak) || 1;\n\n      if (Math.abs(s.peak) > 1.3) {\n        slash(c.x + dir * 34, c.y, {\n          ang: dir > 0 ? 0 : Math.PI,\n          col: \"#b8b3ff\",\n          len: 150,\n          life: 0.5,\n          thick: 12,\n        });\n        burst(c.x + dir * 4, c.y, { life: 0.28, r: 24, spikes: 11 });\n        shards(c.x + dir * 10, c.y, { arc: 2.4, dir: dir > 0 ? 0 : Math.PI, n: 4, size: 4 });\n        ticks(c.x + dir * 52, c.y - 30, { dir: dir > 0 ? -0.6 : -2.5, len: 10, n: 3, r: 4 });\n        later(520, () => {\n          puff(c.x - dir * 60, c.y - 34, { life: 0.8, n: 4, size: 11, vy: -10 });\n          puff(c.x - dir * 22, c.y - 22, { life: 0.6, n: 3, size: 6, vy: -8 });\n          wob(c.x - dir * 82, c.y - 34, { dir: -1, r: 9 });\n        });\n      }\n\n      const f = fracOf(next);\n\n      if (f >= 1 || f <= 0) {\n        shards(c.x, c.y, { arc: 2, dir: dir > 0 ? Math.PI : 0, n: 5 });\n      }\n    }\n\n    s.peak = 0;\n  };\n\n  useFrame((dt) => {\n    const b = box.current;\n    const th = thumb.current;\n    const val = bubble.current;\n\n    if (!b || !th || !val) {\n      return;\n    }\n\n    const s = sim.current;\n    s.t += dt;\n    const W = b.clientWidth - 28;\n    const x = spring.current.step(dt);\n    const { v } = spring.current;\n    const st = 1 + Math.min(1.5, Math.abs(v) * 0.3);\n    th.style.transformOrigin = v > 0 ? \"100% 50%\" : \"0 50%\";\n    th.style.transform = `translateX(${x * W}px) scale(${st}, ${1 / Math.sqrt(st)})`;\n    val.style.transform = `translateX(${x * W - (val.offsetWidth - 46) / 2}px) rotate(${clamp(-v * 5, -14, 14)}deg)`;\n    b.style.setProperty(\"--v\", String(clamp(x)));\n\n    if (Math.abs(v) > Math.abs(s.peak)) {\n      s.peak = v;\n    } else {\n      s.peak *= 0.96;\n    }\n\n    if (Math.abs(v) > 0.35) {\n      s.acc += dt * Math.abs(v) * 20;\n      const c = at(th);\n      const dir = Math.sign(v);\n      const big = Math.min(1, Math.abs(v) / 2.4);\n\n      while (s.acc > 1) {\n        s.acc -= 1;\n        trail(c, dir, big);\n      }\n\n      if (Math.abs(v) > 1.5 && s.t - s.said > 1.1) {\n        s.said = s.t;\n        sfx(\"shu\", c.x - dir * 6, c.y - 78, {\n          col: \"#5a4fd8\",\n          edge: \"#ffffff\",\n          life: 0.75,\n          rot: -0.16,\n          size: 104,\n        });\n      }\n    }\n  });\n\n  return (\n    <SliderPrimitive.Root<number>\n      data-slot=\"sakuga-slider\"\n      className={cn(ROOT, FONT_BODY, className)}\n      min={min}\n      max={max}\n      value={current}\n      onValueChange={(next, details) => {\n        if (details.reason === \"track-press\" && press.current.onThumb) {\n          details.cancel();\n\n          return;\n        }\n\n        onValueChange?.(next, details);\n\n        if (!details.isCanceled && value === undefined) {\n          setInner(next);\n          chase.current.value = next;\n          chase.current.frac = fracOf(next);\n          spring.current.to = chase.current.frac;\n        }\n      }}\n      onValueCommitted={(next, details) => {\n        onValueCommitted?.(next, details);\n        const byPointer = details.reason === \"drag\" || details.reason === \"track-press\";\n\n        if (!(byPointer && next === press.current.from)) {\n          release(next);\n        }\n      }}\n      {...props}\n    >\n      <SakugaStyle />\n      <div ref={box} data-slot=\"sakuga-slider-box\" className={BOX}>\n        <SliderPrimitive.Track data-slot=\"sakuga-slider-track\" className={TRACK}>\n          <SliderPrimitive.Indicator\n            data-slot=\"sakuga-slider-indicator\"\n            className=\"max-w-full bg-(--sk-pri)\"\n            style={{ height: \"100%\", width: \"calc(var(--v, 0) * 100% + 6px)\" }}\n          />\n        </SliderPrimitive.Track>\n        <SliderPrimitive.Value\n          ref={bubble}\n          aria-hidden\n          data-slot=\"sakuga-slider-value\"\n          className={BUBBLE}\n        >\n          {(_, values) => {\n            const shown = values[0] ?? min;\n\n            return (\n              <>\n                <SliderChase\n                  value={shown}\n                  frac={fracOf(shown)}\n                  springRef={spring}\n                  chaseRef={chase}\n                />\n                {`${shown}${unit}`}\n              </>\n            );\n          }}\n        </SliderPrimitive.Value>\n        <SliderPrimitive.Thumb\n          ref={thumb}\n          data-slot=\"sakuga-slider-thumb\"\n          inputRef={input}\n          aria-label={ariaLabel}\n          getAriaValueText={(formatted) => `${formatted}${unit}`}\n          className={THUMB}\n          style={{ insetInlineStart: 0, top: 9, translate: \"none\" }}\n        />\n        <SliderPrimitive.Control\n          data-slot=\"sakuga-slider-control\"\n          className={CONTROL}\n          onPointerDownCapture={pressDown}\n        />\n      </div>\n    </SliderPrimitive.Root>\n  );\n};\n\nexport { SakugaSlider };\n","path":"/sakuga-slider.tsx","target":"uicapsule/sakuga-vfx/sakuga-slider.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { Switch as SwitchPrimitive } from \"@base-ui/react/switch\";\nimport { cn } from \"cn\";\nimport { useEffect, useLayoutEffect, useRef } from \"react\";\n\nimport { isCalm } from \"./sakuga-core\";\nimport { SakugaStyle, useFrame, useMergedRef } from \"./sakuga-react\";\nimport type { Styled } from \"./sakuga-react\";\n\ntype SakugaSwitchProps = Styled<SwitchPrimitive.Root.Props> & {\n  frames?: string;\n};\n\nconst FRAMES =\n  \"https://d24l2zb4cwkekfpl.public.blob.vercel-storage.com/sakuga-vfx/toggle-frames.20261116.webp\";\n\nconst N = 43;\nconst FPS = 30;\nconst FW = 300;\nconst FH = 325;\nconst COLS = 8;\nconst ON: readonly number[] = Array.from({ length: N }, (_, i) => i);\nconst OFF: readonly number[] = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0];\n\nconst sheets = new Map<string, HTMLImageElement>();\nconst broken = new Set<string>();\n\nconst getSheet = (src: string) => {\n  let img = sheets.get(src);\n\n  if (!img) {\n    img = new Image();\n    img.addEventListener(\"error\", () => broken.add(src), { once: true });\n    img.src = src;\n    sheets.set(src, img);\n  }\n\n  return img;\n};\n\ninterface Rig {\n  acc: number;\n  pos: number;\n  seq: readonly number[];\n  shown: number;\n  to: boolean | null;\n  quiet: boolean;\n}\n\nconst makeRig = () => {\n  const rig: Rig = { acc: 0, pos: 0, quiet: false, seq: [0], shown: -1, to: null };\n\n  return rig;\n};\n\nconst current = ({ seq, pos }: Rig) => seq[Math.min(seq.length - 1, pos)] ?? 0;\n\nconst paint = (\n  canvas: HTMLCanvasElement | null,\n  img: HTMLImageElement,\n  rig: Rig,\n  plain: HTMLElement | null,\n) => {\n  const c = canvas?.getContext(\"2d\");\n\n  if (!c || !img.complete || !img.naturalWidth) {\n    return;\n  }\n\n  if (plain) {\n    plain.style.display = \"none\";\n  }\n\n  const i = current(rig);\n  c.clearRect(0, 0, FW, FH);\n  c.drawImage(img, (i % COLS) * FW, Math.floor(i / COLS) * FH, FW, FH, 0, 0, FW, FH);\n  rig.shown = i;\n};\n\nconst isOn = (root: HTMLElement | null) => root?.getAttribute(\"aria-checked\") === \"true\";\n\nconst settle = (rig: Rig, on: boolean) => {\n  rig.seq = [on ? N - 1 : 0];\n  rig.pos = 0;\n  rig.acc = 0;\n  rig.to = on;\n};\n\nconst ROOT =\n  \"group/sakuga-switch relative isolate mx-[21px] mt-[89px] mb-[20px] inline-block h-[54px] w-[108px] shrink-0 cursor-pointer rounded-[27px] align-middle [-webkit-tap-highlight-color:transparent] focus-visible:outline-[2.5px] focus-visible:outline-offset-[3px] focus-visible:outline-(--sk-acc) focus-visible:outline-solid data-disabled:cursor-not-allowed data-disabled:opacity-50\";\n\nconst FILM =\n  \"pointer-events-none absolute top-1/2 left-1/2 mt-[-115.6px] ml-[-75px] h-[162.5px] w-[150px] max-w-none\";\n\nconst PLAIN = \"pointer-events-none absolute inset-0\";\n\nconst TRACK =\n  \"absolute top-0 left-px h-[54px] w-[106px] rounded-full border-[length:var(--sk-bw)] border-(--sk-ink) bg-(--sk-track) group-data-checked/sakuga-switch:top-[6px] group-data-checked/sakuga-switch:h-[42px] group-data-checked/sakuga-switch:bg-(--sk-pri)\";\n\nconst THUMB =\n  \"absolute top-[5.5px] left-[5.5px] h-[43px] w-[43px] rounded-full border-[length:var(--sk-bw)] border-(--sk-ink) bg-(--sk-card) data-checked:left-[63.5px]\";\n\nconst SakugaSwitch = ({\n  className,\n  frames = FRAMES,\n  checked,\n  defaultChecked,\n  onCheckedChange,\n  inputRef,\n  ref,\n  ...props\n}: SakugaSwitchProps) => {\n  const root = useRef<HTMLElement>(null);\n  const canvas = useRef<HTMLCanvasElement>(null);\n  const plain = useRef<HTMLSpanElement>(null);\n  const rigRef = useRef(makeRig());\n  const input = useRef<HTMLInputElement>(null);\n  const setRoot = useMergedRef<HTMLElement>(root, ref);\n  const setInput = useMergedRef(input, inputRef);\n\n  const change = (next: boolean, details: SwitchPrimitive.Root.ChangeEventDetails) => {\n    onCheckedChange?.(next, details);\n    const rig = rigRef.current;\n\n    if (details.isCanceled || rig.quiet) {\n      return;\n    }\n\n    const seq = next ? ON : OFF;\n    rig.seq = seq;\n    rig.pos = isCalm() ? seq.length - 1 : 0;\n    rig.acc = 0;\n    rig.to = next;\n\n    if (checked === undefined) {\n      paint(canvas.current, getSheet(frames), rig, plain.current);\n    }\n  };\n\n  useLayoutEffect(() => {\n    settle(rigRef.current, isOn(root.current));\n  }, []);\n\n  useEffect(() => {\n    const hidden = input.current;\n    const form = hidden?.form;\n\n    if (checked !== undefined || !hidden || !form) {\n      return;\n    }\n\n    const back = () => {\n      if (hidden.checked !== Boolean(defaultChecked)) {\n        rigRef.current.quiet = true;\n        hidden.click();\n        rigRef.current.quiet = false;\n      }\n    };\n\n    form.addEventListener(\"reset\", back);\n\n    return () => form.removeEventListener(\"reset\", back);\n  }, [checked, defaultChecked]);\n\n  useEffect(() => {\n    const img = getSheet(frames);\n    const show = () => paint(canvas.current, img, rigRef.current, plain.current);\n    rigRef.current.shown = -1;\n\n    if (img.complete) {\n      show();\n\n      return;\n    }\n\n    img.addEventListener(\"load\", show);\n\n    return () => img.removeEventListener(\"load\", show);\n  }, [frames]);\n\n  useFrame((dt) => {\n    const rig = rigRef.current;\n    const on = isOn(root.current);\n\n    if (on !== rig.to) {\n      settle(rig, on);\n    }\n\n    if (rig.pos < rig.seq.length - 1) {\n      rig.acc += dt * FPS;\n\n      while (rig.acc >= 1 && rig.pos < rig.seq.length - 1) {\n        rig.acc -= 1;\n        rig.pos += 1;\n      }\n    }\n\n    if (current(rig) !== rig.shown && !broken.has(frames)) {\n      paint(canvas.current, getSheet(frames), rig, plain.current);\n    }\n  });\n\n  return (\n    <>\n      <SakugaStyle />\n      <SwitchPrimitive.Root\n        ref={setRoot}\n        inputRef={setInput}\n        data-slot=\"sakuga-switch\"\n        className={cn(ROOT, className)}\n        checked={checked}\n        defaultChecked={defaultChecked}\n        onCheckedChange={change}\n        {...props}\n      >\n        <span ref={plain} aria-hidden data-slot=\"sakuga-switch-plain\" className={PLAIN}>\n          <span data-slot=\"sakuga-switch-track\" className={TRACK} />\n          <SwitchPrimitive.Thumb data-slot=\"sakuga-switch-thumb\" className={THUMB} />\n        </span>\n        <canvas\n          ref={canvas}\n          width={FW}\n          height={FH}\n          aria-hidden\n          data-slot=\"sakuga-switch-film\"\n          className={FILM}\n        />\n      </SwitchPrimitive.Root>\n    </>\n  );\n};\n\nexport { SakugaSwitch };\n","path":"/sakuga-switch.tsx","target":"uicapsule/sakuga-vfx/sakuga-switch.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { Tabs as TabsPrimitive } from \"@base-ui/react/tabs\";\nimport { cn } from \"cn\";\nimport { createContext, use, useEffect, useRef } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport { Spring, at, clamp, clock, later, lines, puff, ticks } from \"./sakuga-core\";\nimport { FONT_BODY, SakugaStyle, useFrame, useMergedRef } from \"./sakuga-react\";\nimport type { Styled } from \"./sakuga-react\";\n\ninterface Rig {\n  sx: Spring;\n  sw: Spring;\n  up: Spring;\n  pending: boolean;\n  dir: number;\n  from: number;\n  span: number;\n  shown: HTMLElement | null;\n}\n\nconst aim = (rig: Rig, tab: HTMLElement, quiet: boolean) => {\n  if (!quiet) {\n    rig.dir = Math.sign(tab.offsetLeft - rig.sx.to) || 1;\n    rig.from = rig.sx.x;\n  }\n\n  rig.span = tab.offsetParent?.clientWidth ?? Infinity;\n  rig.sx.to = tab.offsetLeft;\n  rig.sw.to = tab.offsetWidth;\n\n  if (quiet) {\n    rig.sx.x = rig.sx.to;\n    rig.sw.x = rig.sw.to;\n    rig.sx.v = 0;\n  } else {\n    rig.pending = true;\n    rig.up.x = -5;\n  }\n};\n\nconst follow = (rig: Rig, tab: HTMLElement) => {\n  if (rig.pending) {\n    rig.sx.to = tab.offsetLeft;\n    rig.sw.to = tab.offsetWidth;\n    rig.span = tab.offsetParent?.clientWidth ?? Infinity;\n  } else {\n    aim(rig, tab, true);\n  }\n};\n\nconst paint = (rig: Rig, ind: HTMLElement) => {\n  const { sx } = rig;\n  const room = sx.v < 0 ? rig.span - sx.x - rig.sw.x : sx.x;\n  const stretch = Math.max(0, Math.min(46, Math.abs(sx.v) * 0.06, Math.abs(sx.x - rig.from), room));\n  const w = rig.sw.x + stretch;\n  const left = clamp(sx.x - (sx.v < 0 ? 0 : stretch), 0, Math.max(0, rig.span - w));\n  ind.style.transform = `translate(${left}px, ${rig.up.x}px)`;\n  ind.style.width = `${w}px`;\n};\n\nconst land = (tab: HTMLElement, dir: number) => {\n  const c = at(tab);\n  ticks(c.x, c.y - c.h / 2 - 12, { dir: -Math.PI / 2, fan: 0.5, len: 15, life: 0.5, n: 3, r: 4 });\n  puff(c.x - dir * (c.w / 2 + 12), c.y - 6, { life: 0.7, n: 4, size: 9, vx: -dir * 20, vy: -12 });\n  later(90, () =>\n    puff(c.x - dir * (c.w / 2 + 20), c.y + 14, { life: 0.55, n: 3, size: 6, vx: -dir * 14 }),\n  );\n  lines(c.x - (dir * c.w) / 2, c.y, { dir: dir > 0 ? Math.PI : 0, len: 34, n: 4, spread: 10 });\n};\n\nconst PickContext = createContext<RefObject<number> | null>(null);\n\nconst UNTRIED = Symbol(\"untried\");\n\nconst SakugaTabs = ({\n  className,\n  onValueChange,\n  onPointerDownCapture,\n  ...props\n}: Styled<TabsPrimitive.Root.Props>) => {\n  const pickedAt = useRef(-1);\n  const tried = useRef<unknown>(UNTRIED);\n\n  return (\n    <PickContext value={pickedAt}>\n      <SakugaStyle />\n      <TabsPrimitive.Root\n        data-slot=\"sakuga-tabs\"\n        className={cn(\n          \"flex flex-col items-start text-[15px] leading-[1.4] font-medium text-(--sk-ink)\",\n          FONT_BODY,\n          className,\n        )}\n        {...props}\n        onPointerDownCapture={(e) => {\n          tried.current = UNTRIED;\n          onPointerDownCapture?.(e);\n        }}\n        onValueChange={(value, details) => {\n          if (details.event.type === \"click\" && Object.is(tried.current, value)) {\n            details.cancel();\n\n            return;\n          }\n\n          tried.current = details.event.type === \"click\" ? UNTRIED : value;\n          onValueChange?.(value, details);\n\n          if (details.reason === \"none\" && !details.isCanceled) {\n            pickedAt.current = clock.now;\n          }\n        }}\n      />\n    </PickContext>\n  );\n};\n\nconst HIDDEN = { visibility: \"hidden\" } as const;\n\nconst SakugaTabsList = ({\n  className,\n  children,\n  activateOnFocus = true,\n  ref,\n  ...props\n}: Styled<TabsPrimitive.List.Props>) => {\n  const pickedAtRef = use(PickContext);\n  const strip = useRef<HTMLDivElement>(null);\n  const stripRef = useMergedRef(strip, ref);\n  const raised = useRef<HTMLSpanElement>(null);\n\n  const rig = useRef<Rig>({\n    dir: 1,\n    from: 0,\n    pending: false,\n    shown: null,\n    span: Infinity,\n    sw: new Spring(10, 320, 26),\n    sx: new Spring(0, 320, 23),\n    up: new Spring(0, 420, 13),\n  });\n\n  useEffect(() => {\n    const list = strip.current;\n    const ind = raised.current;\n\n    if (!list || !ind) {\n      return;\n    }\n\n    const r = rig.current;\n\n    const sync = () => {\n      const tab = list.querySelector<HTMLElement>('[role=\"tab\"][aria-selected=\"true\"]');\n\n      if (tab === r.shown) {\n        return;\n      }\n\n      const first = r.shown === null;\n      r.shown = tab;\n\n      if (!tab) {\n        ind.style.visibility = \"hidden\";\n\n        return;\n      }\n\n      const picked = pickedAtRef !== null && pickedAtRef.current === clock.now;\n\n      if (pickedAtRef) {\n        pickedAtRef.current = -1;\n      }\n\n      aim(r, tab, first || !picked);\n\n      if (ind.style.visibility) {\n        paint(r, ind);\n        ind.style.visibility = \"\";\n      }\n    };\n\n    sync();\n    const active = new MutationObserver(sync);\n    active.observe(list, {\n      attributeFilter: [\"aria-selected\"],\n      attributes: true,\n      childList: true,\n      subtree: true,\n    });\n\n    const size = new ResizeObserver(() => {\n      if (r.shown) {\n        follow(r, r.shown);\n      }\n    });\n\n    size.observe(list);\n\n    return () => {\n      active.disconnect();\n      size.disconnect();\n    };\n  }, [pickedAtRef]);\n\n  useFrame((dt) => {\n    const r = rig.current;\n    const ind = raised.current;\n\n    if (!ind) {\n      return;\n    }\n\n    const { sx } = r;\n    const x = sx.step(dt);\n    r.sw.step(dt);\n    r.up.step(dt);\n    paint(r, ind);\n\n    if (r.pending && r.shown && Math.abs(x - sx.to) < 3) {\n      r.pending = false;\n      r.up.x = -7;\n      land(r.shown, r.dir);\n    }\n  });\n\n  return (\n    <TabsPrimitive.List\n      ref={stripRef}\n      data-slot=\"sakuga-tabs-list\"\n      activateOnFocus={activateOnFocus}\n      className={cn(\n        \"relative mt-[10px] flex rounded-[12px] border-[length:var(--sk-bw)] border-(--sk-ink) bg-(--sk-card) shadow-(--sk-sh)\",\n        className,\n      )}\n      {...props}\n    >\n      <span\n        ref={raised}\n        aria-hidden\n        data-slot=\"sakuga-tabs-indicator\"\n        style={HIDDEN}\n        className=\"absolute top-[-11px] bottom-[-1px] left-0 ml-[calc(var(--sk-bw)*-1)] w-[10px] rounded-t-[13px] border-[length:var(--sk-bw)] border-b-0 border-(--sk-ink) bg-(--sk-card) will-change-[transform,width]\"\n      />\n      {children}\n    </TabsPrimitive.List>\n  );\n};\n\nconst SakugaTabsTrigger = ({ className, ...props }: Styled<TabsPrimitive.Tab.Props>) => (\n  <TabsPrimitive.Tab\n    data-slot=\"sakuga-tabs-trigger\"\n    className={cn(\n      \"relative cursor-pointer border-l-[2.4px] border-l-(--sk-ink) px-[15px] py-[10px] text-[15px] leading-[1.2] font-semibold whitespace-nowrap transition-[translate] duration-[180ms] ease-[cubic-bezier(.3,1.6,.5,1)] first-of-type:border-l-transparent focus-visible:outline-[2.5px] focus-visible:outline-offset-[3px] focus-visible:outline-(--sk-acc) data-active:-translate-y-[5px] data-active:border-l-transparent data-active:font-extrabold [[data-active]+&]:border-l-transparent\",\n      '[font-family:-apple-system,\"Segoe_UI\",system-ui,sans-serif]',\n      className,\n    )}\n    {...props}\n  />\n);\n\nconst SakugaTabsContent = ({ className, ...props }: Styled<TabsPrimitive.Panel.Props>) => (\n  <TabsPrimitive.Panel\n    data-slot=\"sakuga-tabs-content\"\n    className={cn(\n      \"focus-visible:outline-[2.5px] focus-visible:outline-offset-[3px] focus-visible:outline-(--sk-acc)\",\n      className,\n    )}\n    {...props}\n  />\n);\n\nexport { SakugaTabs, SakugaTabsList, SakugaTabsTrigger, SakugaTabsContent };\n","path":"/sakuga-tabs.tsx","target":"uicapsule/sakuga-vfx/sakuga-tabs.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { Toast as ToastPrimitive } from \"@base-ui/react/toast\";\nimport { cn } from \"cn\";\nimport { useEffect, useLayoutEffect, useMemo, useRef } from \"react\";\nimport type { ReactNode, RefObject } from \"react\";\n\nimport {\n  Spring,\n  at,\n  dotted,\n  isCalm,\n  lines,\n  puff,\n  rnd,\n  sfx,\n  shards,\n  ticks,\n  wob,\n} from \"./sakuga-core\";\nimport { FONT_BODY, SakugaStyle, useFrame, useMergedRef } from \"./sakuga-react\";\nimport type { Styled } from \"./sakuga-react\";\n\ninterface SakugaToastData {\n  duration: number;\n}\n\ninterface SakugaToastOptions {\n  duration?: number;\n}\n\ntype ToastObject = ToastPrimitive.Root.ToastObject<SakugaToastData>;\n\nconst manager = ToastPrimitive.createToastManager<SakugaToastData>();\n\nconst ID = \"sakuga-toast\";\nconst STAY = 2600;\n\nconst sakugaToast = Object.assign(\n  (title: ReactNode, options?: SakugaToastOptions) =>\n    manager.add({ data: { duration: options?.duration ?? STAY }, id: ID, timeout: 0, title }),\n  { dismiss: () => manager.close(ID) },\n);\n\ntype Phase = 0 | 1 | 2 | 3;\n\nconst DUST = [-0.5, -0.36, -0.2] as const;\n\nconst NO_SWIPE: (\"down\" | \"left\" | \"right\" | \"up\")[] = [];\n\nconst TOAST =\n  \"absolute bottom-0 left-0 flex w-[236px] items-center gap-[10px] rounded-(--sk-r) border-[length:var(--sk-bw)] border-(--sk-ink) bg-(--sk-card) px-[14px] py-[12px] text-[15px] font-bold whitespace-nowrap shadow-(--sk-sh) will-change-transform focus-visible:outline-[2.5px] focus-visible:outline-offset-[3px] focus-visible:outline-(--sk-acc)\";\n\ntype Step = (dt: number) => void;\n\ninterface Motion {\n  sx: Spring;\n  ss: Spring;\n  t: number;\n  at0: number;\n  steps: Set<RefObject<Step>>;\n}\n\nconst makeMotion = () => {\n  const motion: Motion = {\n    at0: 0,\n    ss: new Spring(1, 420, 26),\n    steps: new Set(),\n    sx: new Spring(-280, 280, 18),\n    t: 0,\n  };\n\n  return motion;\n};\n\nconst SakugaToast = ({\n  toast: item,\n  motionRef,\n  className,\n  ref,\n  ...props\n}: Styled<ToastPrimitive.Root.Props> & {\n  toast: ToastObject;\n  motionRef: RefObject<Motion>;\n}) => {\n  const el = useRef<HTMLDivElement>(null);\n  const setEl = useMergedRef<HTMLElement>(el, ref);\n  const phase = useRef<Phase>(0);\n  const holdRef = useRef<Animation | null>(null);\n  const seen = useRef(\"\");\n  const ending = item.transitionStatus === \"ending\";\n  const duration = item.data?.duration ?? STAY;\n\n  const release = () => {\n    holdRef.current?.finish();\n    holdRef.current = null;\n  };\n\n  const arrive = () => {\n    const toast = el.current;\n\n    if (!toast) {\n      return;\n    }\n\n    release();\n    toast.style.visibility = \"\";\n    motionRef.current.sx.x = -280;\n    motionRef.current.sx.v = 1000;\n    motionRef.current.sx.to = 0;\n    motionRef.current.ss.x = 1;\n    motionRef.current.ss.to = 1;\n    motionRef.current.ss.k = 420;\n    phase.current = 1;\n\n    if (isCalm()) {\n      motionRef.current.sx.x = 0;\n      motionRef.current.sx.v = 0;\n    }\n  };\n\n  const leave = () => {\n    const toast = el.current;\n\n    if (!toast || phase.current === 0 || phase.current === 3) {\n      return;\n    }\n\n    phase.current = 3;\n    motionRef.current.ss.to = 0;\n    motionRef.current.ss.k = 500;\n    const c = at(toast);\n    puff(c.x, c.y, { life: 0.5, n: 4, size: 9 });\n  };\n\n  useLayoutEffect(() => {\n    const turn = `${item.updateKey}${ending ? \" ending\" : \"\"}`;\n\n    if (turn === seen.current) {\n      return;\n    }\n\n    seen.current = turn;\n\n    if (!ending) {\n      arrive();\n\n      return;\n    }\n\n    const hold = el.current?.animate([], { duration: 1 });\n    hold?.pause();\n    holdRef.current = hold ?? null;\n    leave();\n\n    if (phase.current === 0) {\n      release();\n    }\n  });\n\n  const step: Step = (dt) => {\n    const toast = el.current;\n\n    if (!toast || phase.current === 0) {\n      return;\n    }\n\n    const x = motionRef.current.sx.step(dt);\n    const sc = motionRef.current.ss.step(dt);\n    const st = 1 + Math.min(1.5, Math.abs(motionRef.current.sx.v) * 0.0017);\n    toast.style.transform = `translateX(${x}px) scale(${st * sc}, ${sc / Math.sqrt(st)})`;\n\n    if (phase.current === 1) {\n      const c = at(toast);\n\n      if (Math.random() < 0.8) {\n        lines(c.x - c.w / 2 - 6, c.y + rnd(-14, 14), {\n          dir: Math.PI,\n          len: 80,\n          life: 0.22,\n          n: 1,\n          spread: 2,\n        });\n      }\n\n      if (x > -10) {\n        phase.current = 2;\n        motionRef.current.at0 = motionRef.current.t;\n        lines(c.x - c.w / 2 - 4, c.y, { dir: Math.PI, len: 70, life: 0.4, n: 9, spread: 18 });\n\n        for (const u of DUST) {\n          const size = rnd(8, 12);\n          const vx = -rnd(10, 30);\n          const life = rnd(0.7, 1);\n          puff(c.x + c.w * u, c.y + c.h / 2 + 4, { life, n: 4, size, vx, vy: -8 });\n        }\n\n        puff(c.x + c.w / 2 + 8, c.y + 10, { life: 0.6, n: 3, size: 7, vx: 20 });\n        shards(c.x - c.w / 2, c.y + 12, { arc: 1.6, dir: Math.PI + 0.5, n: 4, size: 4 });\n        ticks(c.x + 30, c.y + c.h / 2 + 12, { dir: 0.5, len: 16, n: 2, r: 4 });\n        sfx(\"zuza\", c.x - 34, c.y - 58, { rot: -0.1, size: 124, ...dotted() });\n        wob(c.x + c.w / 2 + 6, c.y, { dir: 1 });\n      }\n    } else if (phase.current === 2 && toast.dataset.expanded !== undefined) {\n      motionRef.current.at0 += dt;\n    } else if (\n      phase.current === 2 &&\n      motionRef.current.t - motionRef.current.at0 > duration / 1000\n    ) {\n      leave();\n      manager.close(item.id);\n    } else if (phase.current === 3 && (sc < 0.03 || isCalm())) {\n      phase.current = 0;\n      toast.style.visibility = \"hidden\";\n      toast.style.transform = \"\";\n      release();\n    }\n  };\n\n  const stepRef = useRef(step);\n  useEffect(() => {\n    stepRef.current = step;\n  });\n  useEffect(() => {\n    const { steps } = motionRef.current;\n    steps.add(stepRef);\n\n    return () => {\n      steps.delete(stepRef);\n    };\n  }, [motionRef]);\n\n  return (\n    <ToastPrimitive.Root\n      data-slot=\"sakuga-toast\"\n      toast={item}\n      swipeDirection={NO_SWIPE}\n      className={cn(TOAST, className)}\n      {...props}\n      ref={setEl}\n    >\n      <span\n        aria-hidden\n        data-slot=\"sakuga-toast-icon\"\n        className=\"grid size-[28px] flex-none place-items-center rounded-full border-[2.4px] border-(--sk-ink) bg-(--sk-pri)\"\n      >\n        <svg\n          viewBox=\"0 0 20 20\"\n          className=\"size-[15px] fill-none stroke-(--sk-on-pri) stroke-[4] [stroke-linecap:round] [stroke-linejoin:round]\"\n        >\n          <path d=\"M3.5 10.5l4.5 4.5 8.5-10\" />\n        </svg>\n      </span>\n      <ToastPrimitive.Title\n        data-slot=\"sakuga-toast-title\"\n        className=\"overflow-hidden text-ellipsis\"\n      />\n      <ToastPrimitive.Close\n        data-slot=\"sakuga-toast-close\"\n        aria-label=\"Dismiss\"\n        className=\"ml-auto size-[26px] flex-none cursor-pointer rounded-full border-0 bg-transparent p-0 text-[15px] font-black focus-visible:outline-[2.5px] focus-visible:outline-offset-[3px] focus-visible:outline-(--sk-acc)\"\n      >\n        ✕\n      </ToastPrimitive.Close>\n    </ToastPrimitive.Root>\n  );\n};\n\nconst SakugaToastList = () => {\n  const { toasts } = ToastPrimitive.useToastManager<SakugaToastData>();\n  const motionRef = useMemo<RefObject<Motion>>(() => ({ current: makeMotion() }), []);\n  useFrame((dt) => {\n    const motion = motionRef.current;\n    motion.t += dt;\n\n    for (const stepRef of motion.steps) {\n      stepRef.current(dt);\n    }\n  });\n\n  return toasts.map((item) => <SakugaToast key={item.id} toast={item} motionRef={motionRef} />);\n};\n\nconst SakugaToaster = ({ className, ...props }: Styled<ToastPrimitive.Viewport.Props>) => (\n  <ToastPrimitive.Provider toastManager={manager} timeout={0} limit={1}>\n    <SakugaStyle />\n    <ToastPrimitive.Viewport\n      data-slot=\"sakuga-toaster\"\n      className={cn(\n        \"relative isolate inline-block h-[56px] w-[236px] align-middle text-[15px] leading-[1.4] font-medium text-(--sk-ink) outline-none\",\n        FONT_BODY,\n        className,\n      )}\n      {...props}\n    >\n      <SakugaToastList />\n    </ToastPrimitive.Viewport>\n  </ToastPrimitive.Provider>\n);\n\nexport { SakugaToaster, sakugaToast };\n","path":"/sakuga-toast.tsx","target":"uicapsule/sakuga-vfx/sakuga-toast.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { cn } from \"cn\";\nimport { createContext, use, useId, useLayoutEffect, useMemo, useRef } from \"react\";\nimport type {\n  ComponentProps,\n  FocusEvent,\n  KeyboardEvent,\n  MouseEvent,\n  PointerEvent,\n  RefObject,\n} from \"react\";\n\nimport { Spring, at, hollow, later, puff, ring, sfx, ticks } from \"./sakuga-core\";\nimport type { Squashy } from \"./sakuga-core\";\nimport { FONT_BODY, SakugaStyle, useFrame, useMergedRef, useSquashy } from \"./sakuga-react\";\nimport type { Styled } from \"./sakuga-react\";\n\ninterface Rig {\n  open: boolean;\n  s: Spring;\n  tip: HTMLElement | null;\n  trigger: HTMLElement | null;\n  squashRef: RefObject<Squashy | null> | null;\n}\n\ninterface Shared {\n  rigRef: RefObject<Rig>;\n  tipId: string;\n  request: (on: boolean) => void;\n}\n\nconst SharedContext = createContext<Shared | null>(null);\n\nconst useShared = () => {\n  const shared = use(SharedContext);\n\n  if (!shared) {\n    throw new Error(\"SakugaTooltip parts must be inside <SakugaTooltip>\");\n  }\n\n  return shared;\n};\n\nconst makeRig = () => {\n  const rig: RefObject<Rig> = {\n    current: { open: false, s: new Spring(0, 460, 15), squashRef: null, tip: null, trigger: null },\n  };\n\n  return rig;\n};\n\nconst mark = ({ open, tip, trigger }: Rig) => {\n  trigger?.toggleAttribute(\"data-popup-open\", open);\n  tip?.toggleAttribute(\"data-open\", open);\n  tip?.toggleAttribute(\"data-closed\", !open);\n};\n\nconst react = (rig: Rig, on: boolean) => {\n  if (on === rig.open) {\n    return;\n  }\n\n  rig.open = on;\n  rig.s.to = on ? 1 : 0;\n  rig.s.d = on ? 15 : 34;\n  mark(rig);\n\n  if (!on) {\n    return;\n  }\n\n  const squash = rig.squashRef?.current;\n\n  if (squash) {\n    squash.s.v += 2;\n  }\n\n  later(120, () => {\n    const { tip, trigger } = rig;\n\n    if (!rig.open || !tip || !trigger) {\n      return;\n    }\n\n    const c = at(tip);\n    const q = at(trigger);\n    puff(c.x - c.w / 2 - 8, c.y - 12, { life: 0.8, n: 4, size: 8, vx: -14, vy: -10 });\n    puff(c.x + c.w / 2 + 10, c.y + 12, { life: 0.8, n: 4, size: 8, vx: 14, vy: -6 });\n    puff(c.x - c.w / 2 - 4, c.y + 22, { life: 0.6, n: 3, size: 5, vx: -10 });\n    ticks(c.x + c.w / 2 - 2, c.y - c.h / 2 - 6, {\n      dir: -1,\n      fan: 0.36,\n      len: 16,\n      life: 0.5,\n      n: 3,\n      r: 5,\n    });\n    ring(q.x, q.y - q.h / 2 - 3, { life: 0.5, rx: 22, ry: 5, w: 3 });\n    sfx(\"kachi\", c.x + 6, c.y - 46, { life: 0.8, rot: -0.08, size: 96, ...hollow() });\n  });\n};\n\ntype SakugaTooltipProps = Styled<ComponentProps<\"span\">> & {\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n};\n\nconst SakugaTooltip = ({\n  open,\n  defaultOpen = false,\n  onOpenChange,\n  className,\n  children,\n  ...props\n}: SakugaTooltipProps) => {\n  const rigRef = useMemo(() => makeRig(), []);\n  const tipId = useId();\n  const mounted = useRef(false);\n\n  useLayoutEffect(() => {\n    const rig = rigRef.current;\n\n    if (!mounted.current) {\n      mounted.current = true;\n\n      if (open ?? defaultOpen) {\n        rig.open = true;\n        rig.s.x = 1;\n        rig.s.to = 1;\n\n        if (rig.tip) {\n          rig.tip.style.transform = \"scale(1) rotate(0deg)\";\n        }\n      }\n\n      mark(rig);\n\n      return;\n    }\n\n    if (open !== undefined) {\n      react(rig, open);\n    }\n  });\n\n  const shared = useMemo<Shared>(\n    () => ({\n      request: (on) => {\n        if (on === rigRef.current.open) {\n          return;\n        }\n\n        onOpenChange?.(on);\n\n        if (open === undefined) {\n          react(rigRef.current, on);\n        }\n      },\n      rigRef,\n      tipId,\n    }),\n    [onOpenChange, open, rigRef, tipId],\n  );\n\n  useFrame((dt) => {\n    const rig = rigRef.current;\n    rig.squashRef?.current?.step(dt);\n    const y = Math.max(0, rig.s.step(dt));\n\n    if (rig.tip) {\n      rig.tip.style.transform = `scale(${y}) rotate(${(1 - y) * -10}deg)`;\n    }\n  });\n\n  return (\n    <span\n      data-slot=\"sakuga-tooltip\"\n      className={cn(\n        \"relative isolate inline-block align-middle text-[15px] leading-[1.4] font-medium text-(--sk-ink)\",\n        FONT_BODY,\n        className,\n      )}\n      {...props}\n    >\n      <SakugaStyle />\n      <SharedContext value={shared}>{children}</SharedContext>\n    </span>\n  );\n};\n\nconst TRIGGER =\n  \"grid size-[42px] cursor-pointer place-items-center rounded-full border-[length:var(--sk-bw)] border-(--sk-ink) bg-(--sk-card) p-0 font-black shadow-[4px_5px_0_var(--sk-soft)] focus-visible:outline-[2.5px] focus-visible:outline-offset-[3px] focus-visible:outline-(--sk-acc)\";\n\nconst SakugaTooltipTrigger = ({\n  className,\n  render,\n  ref,\n  onBlur,\n  onClick,\n  onFocus,\n  onKeyDown,\n  onPointerEnter,\n  onPointerLeave,\n  ...props\n}: Styled<useRender.ComponentProps<\"button\">>) => {\n  const { request, rigRef, tipId } = useShared();\n  const el = useRef<HTMLElement>(null);\n  const setEl = useMergedRef<HTMLElement>(el, ref);\n  const sqRef = useSquashy(el, { low: 0.78, wide: 0.3 });\n\n  useLayoutEffect(() => {\n    const rig = rigRef.current;\n    rig.trigger = el.current;\n    rig.squashRef = sqRef;\n    mark(rig);\n\n    return () => {\n      rig.trigger = null;\n      rig.squashRef = null;\n    };\n  }, [rigRef, sqRef]);\n\n  return useRender({\n    defaultTagName: \"button\",\n    props: {\n      \"aria-describedby\": tipId,\n      type: render ? undefined : \"button\",\n      ...props,\n      className: cn(!render && TRIGGER, className),\n      \"data-slot\": \"sakuga-tooltip-trigger\",\n      onBlur: (e: FocusEvent<HTMLButtonElement>) => {\n        onBlur?.(e);\n        request(false);\n      },\n      onClick: (e: MouseEvent<HTMLButtonElement>) => {\n        onClick?.(e);\n        request(!rigRef.current.open || document.activeElement === e.currentTarget);\n      },\n      onFocus: (e: FocusEvent<HTMLButtonElement>) => {\n        onFocus?.(e);\n        request(true);\n      },\n      onKeyDown: (e: KeyboardEvent<HTMLButtonElement>) => {\n        onKeyDown?.(e);\n\n        if (e.key === \"Escape\") {\n          request(false);\n        }\n      },\n      onPointerEnter: (e: PointerEvent<HTMLButtonElement>) => {\n        onPointerEnter?.(e);\n\n        if (e.pointerType === \"mouse\") {\n          request(true);\n        }\n      },\n      onPointerLeave: (e: PointerEvent<HTMLButtonElement>) => {\n        onPointerLeave?.(e);\n\n        if (e.pointerType === \"mouse\") {\n          request(false);\n        }\n      },\n    },\n    ref: setEl,\n    render,\n  });\n};\n\nconst TIP =\n  \"pointer-events-none absolute bottom-[calc(100%+16px)] left-1/2 w-max max-w-[220px] min-w-[120px] origin-[50%_120%] [translate:-50%_0] [transform:scale(0)] rounded-[13px] border-[length:var(--sk-bw)] border-(--sk-ink) bg-(--sk-card) px-[14px] py-[11px] text-center text-[16px] font-extrabold shadow-(--sk-sh) will-change-transform before:absolute before:top-[calc(100%-4.5px)] before:left-1/2 before:z-1 before:-ml-[6px] before:border-[6px] before:border-t-[8.5px] before:border-transparent before:border-t-(--sk-card) before:content-[''] after:absolute after:top-full after:left-1/2 after:-ml-[9px] after:border-[9px] after:border-t-[12px] after:border-transparent after:border-t-(--sk-ink) after:content-['']\";\n\nconst SakugaTooltipContent = ({ className, ref, ...props }: Styled<ComponentProps<\"div\">>) => {\n  const { rigRef, tipId } = useShared();\n  const el = useRef<HTMLDivElement>(null);\n  const setEl = useMergedRef(el, ref);\n\n  useLayoutEffect(() => {\n    const rig = rigRef.current;\n    rig.tip = el.current;\n    mark(rig);\n\n    return () => {\n      rig.tip = null;\n    };\n  }, [rigRef]);\n\n  return (\n    <div\n      data-slot=\"sakuga-tooltip-content\"\n      id={tipId}\n      role=\"tooltip\"\n      className={cn(TIP, className)}\n      {...props}\n      ref={setEl}\n    />\n  );\n};\n\nexport { SakugaTooltip, SakugaTooltipContent, SakugaTooltipTrigger };\n","path":"/sakuga-tooltip.tsx","target":"uicapsule/sakuga-vfx/sakuga-tooltip.tsx","type":"registry:file"},{"content":"\"use client\";\n\nimport { useLayoutEffect, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { flushSync } from \"react-dom\";\n\nimport { SakugaButton } from \"./sakuga-button\";\nimport { clamp, later, onFrame } from \"./sakuga-core\";\nimport {\n  SakugaAccordion,\n  SakugaAccordionContent,\n  SakugaAccordionItem,\n  SakugaAccordionTrigger,\n} from \"./sakuga-accordion\";\nimport { SakugaCheckbox } from \"./sakuga-checkbox\";\nimport { SakugaChips, SakugaChipsInput, SakugaChipsList } from \"./sakuga-chips\";\nimport { SakugaInput } from \"./sakuga-input\";\nimport { SakugaProgress } from \"./sakuga-progress\";\nimport { SakugaRadioGroup, SakugaRadioGroupItem } from \"./sakuga-radio-group\";\nimport { SakugaRating } from \"./sakuga-rating\";\nimport {\n  SakugaSelect,\n  SakugaSelectContent,\n  SakugaSelectItem,\n  SakugaSelectTrigger,\n  SakugaSelectValue,\n} from \"./sakuga-select\";\nimport { SakugaSlider } from \"./sakuga-slider\";\nimport {\n  SakugaNumberField,\n  SakugaNumberFieldDecrement,\n  SakugaNumberFieldGroup,\n  SakugaNumberFieldIncrement,\n  SakugaNumberFieldInput,\n} from \"./sakuga-number-field\";\nimport { SakugaTabs, SakugaTabsList, SakugaTabsTrigger } from \"./sakuga-tabs\";\nimport { SakugaToaster, sakugaToast } from \"./sakuga-toast\";\nimport { SakugaSwitch } from \"./sakuga-switch\";\nimport { SakugaTooltip, SakugaTooltipContent, SakugaTooltipTrigger } from \"./sakuga-tooltip\";\nimport { FONT_BODY, SakugaStyle } from \"./sakuga-react\";\n\nconst Card = ({\n  id,\n  name,\n  how,\n  wide = false,\n  children,\n}: {\n  id: string;\n  name: string;\n  how: string;\n  wide?: boolean;\n  children: ReactNode;\n}) => (\n  <section\n    data-sk={id}\n    className={`flex min-w-0 flex-col rounded-[18px] border-[1.5px] border-[#dcdaf0] ${wide ? \"sm:col-span-2\" : \"\"}`}\n  >\n    <h2 className=\"px-4 pt-3.5 text-[15px] font-bold\">{name}</h2>\n    <p className=\"px-4 pt-0.5 text-[13px] text-[#8580b0]\">{how}</p>\n    <div className=\"flex min-h-[230px] flex-1 flex-wrap items-center justify-center gap-[22px] px-4 py-6\">\n      {children}\n    </div>\n  </section>\n);\n\nconst PrimaryCard = () => {\n  const [done, setDone] = useState(false);\n  const run = useRef(0);\n\n  return (\n    <Card id=\"button\" name=\"Primary button\" how=\"Click it.\">\n      <SakugaButton\n        done={done}\n        onClick={() => {\n          run.current += 1;\n          setDone(false);\n          later(760, () => {\n            const n = run.current;\n            flushSync(() => setDone(true));\n            later(1800, () => {\n              if (n === run.current) {\n                flushSync(() => setDone(false));\n              }\n            });\n          });\n        }}\n      >\n        Confirm\n      </SakugaButton>\n    </Card>\n  );\n};\n\nconst ToastCard = () => (\n  <Card id=\"toast\" name=\"Toast\" how=\"Press Save.\">\n    <div className=\"relative grid justify-items-center gap-[22px]\">\n      <SakugaButton variant=\"secondary\" onClick={() => sakugaToast(\"Saved successfully!\")}>\n        Save\n      </SakugaButton>\n      <SakugaToaster />\n    </div>\n  </Card>\n);\n\nconst STAGES = [\n  { label: \"Key frames\", value: \"key\" },\n  { label: \"In-betweens\", value: \"inbetween\" },\n  { label: \"Clean-up\", value: \"cleanup\" },\n  { label: \"Paint\", value: \"paint\" },\n];\n\nconst LoadingDemo = () => {\n  const [value, setValue] = useState(0);\n  const demo = useRef({ at: 0, doneAt: 0, goal: 0, t: 0 });\n  useLayoutEffect(\n    () =>\n      onFrame((dt) => {\n        const d = demo.current;\n        d.t += dt;\n\n        if (d.doneAt) {\n          if (d.t - d.doneAt > 3.6) {\n            d.doneAt = 0;\n            d.goal = 0;\n            d.at = 0;\n            flushSync(() => setValue(0));\n          }\n\n          return;\n        }\n\n        d.goal = Math.min(\n          1,\n          d.goal + dt * (0.14 + 0.115 * Math.sin(d.t * 2.1) + 0.07 * Math.sin(d.t * 4.7)),\n        );\n        const next = Math.max(d.goal, d.at);\n\n        if (d.at < d.goal) {\n          d.at = Math.min(d.goal, d.at + dt * clamp((d.goal - d.at) * 3, 0.12, 0.9));\n        }\n\n        flushSync(() => setValue(next));\n      }),\n    [],\n  );\n\n  return (\n    <SakugaProgress\n      min={0}\n      max={1}\n      value={value}\n      aria-label=\"Loading\"\n      className=\"cursor-pointer\"\n      onDone={() => {\n        demo.current.doneAt = demo.current.t;\n      }}\n      onClick={() => {\n        demo.current.doneAt = 0;\n        demo.current.goal = 0;\n        demo.current.at = 0;\n        setValue(0);\n      }}\n    />\n  );\n};\n\nexport const SakugaVfx = () => (\n  <div\n    className={`w-full max-w-[1080px] text-[15px] leading-[1.45] font-medium text-[#1d1a4a] ${FONT_BODY}`}\n  >\n    <SakugaStyle />\n    <div className=\"grid grid-flow-dense grid-cols-[repeat(auto-fit,minmax(300px,1fr))] gap-[18px]\">\n      <PrimaryCard />\n      <Card id=\"button-secondary\" name=\"Secondary button\" how=\"Click it.\">\n        <SakugaButton variant=\"secondary\">Cancel</SakugaButton>\n      </Card>\n      <Card id=\"toggle\" name=\"Switch\" how=\"Flip it, then flip it back.\">\n        <SakugaSwitch aria-label=\"Notifications\" />\n      </Card>\n      <Card id=\"slider\" name=\"Slider\" how=\"Drag it fast, and let go while it is moving.\">\n        <SakugaSlider defaultValue={30} aria-label=\"Volume\" />\n      </Card>\n      <Card id=\"checkbox\" name=\"Checkbox\" how=\"Tick it.\">\n        <label\n          htmlFor=\"sk-remember\"\n          className=\"flex cursor-pointer items-center gap-[12px] text-[15px] leading-[1.4] font-medium text-(--sk-ink) select-none\"\n        >\n          <SakugaCheckbox id=\"sk-remember\" />\n          Remember me\n        </label>\n      </Card>\n      <Card id=\"radio\" name=\"Radio group\" how=\"Pick the other one.\">\n        <SakugaRadioGroup\n          aria-label=\"Plan\"\n          defaultValue=\"a\"\n          className=\"text-[15px] leading-[1.4] font-medium text-(--sk-ink)\"\n        >\n          <label\n            htmlFor=\"sk-plan-a\"\n            className=\"flex cursor-pointer items-center gap-[12px] select-none\"\n          >\n            <SakugaRadioGroupItem id=\"sk-plan-a\" value=\"a\" />\n            Option A\n          </label>\n          <label\n            htmlFor=\"sk-plan-b\"\n            className=\"flex cursor-pointer items-center gap-[12px] select-none\"\n          >\n            <SakugaRadioGroupItem id=\"sk-plan-b\" value=\"b\" />\n            Option B\n          </label>\n        </SakugaRadioGroup>\n      </Card>\n      <Card id=\"input\" name=\"Input\" how=\"Click it and type.\">\n        <SakugaInput aria-label=\"Text\" placeholder=\"Type something\" autoComplete=\"off\" />\n      </Card>\n      <Card id=\"tabs\" name=\"Tabs\" how=\"Pick another tab, or use the arrow keys.\">\n        <SakugaTabs defaultValue=\"home\">\n          <SakugaTabsList aria-label=\"Sections\">\n            <SakugaTabsTrigger value=\"home\">Home</SakugaTabsTrigger>\n            <SakugaTabsTrigger value=\"profile\">Profile</SakugaTabsTrigger>\n            <SakugaTabsTrigger value=\"settings\">Settings</SakugaTabsTrigger>\n          </SakugaTabsList>\n        </SakugaTabs>\n      </Card>\n      <Card\n        id=\"progress\"\n        name=\"Progress\"\n        how=\"It plays a load by itself, in surges. Click it to start again.\"\n        wide\n      >\n        <LoadingDemo />\n      </Card>\n      <Card id=\"rating\" name=\"Rating\" how=\"Give it five.\">\n        <SakugaRating aria-label=\"Rating\" />\n      </Card>\n      <ToastCard />\n      <Card id=\"tooltip\" name=\"Tooltip\" how=\"Hover, focus or tap the button.\">\n        <SakugaTooltip className=\"mt-[60px]\">\n          <SakugaTooltipTrigger aria-label=\"Help\">?</SakugaTooltipTrigger>\n          <SakugaTooltipContent>Helpful hint!</SakugaTooltipContent>\n        </SakugaTooltip>\n      </Card>\n      <Card id=\"stepper\" name=\"Number field\" how=\"Tap plus fast, then hit the limit.\">\n        <SakugaNumberField defaultValue={5} min={0} max={9}>\n          <SakugaNumberFieldGroup>\n            <SakugaNumberFieldDecrement />\n            <SakugaNumberFieldInput aria-label=\"Copies\" />\n            <SakugaNumberFieldIncrement />\n          </SakugaNumberFieldGroup>\n        </SakugaNumberField>\n      </Card>\n      <Card id=\"select\" name=\"Select\" how=\"Open it, run down the rows, and choose one.\">\n        <SakugaSelect defaultValue=\"key\" items={STAGES}>\n          <SakugaSelectTrigger aria-label=\"Stage\">\n            <SakugaSelectValue />\n          </SakugaSelectTrigger>\n          <SakugaSelectContent>\n            {STAGES.map((stage) => (\n              <SakugaSelectItem key={stage.value} value={stage.value}>\n                {stage.label}\n              </SakugaSelectItem>\n            ))}\n          </SakugaSelectContent>\n        </SakugaSelect>\n      </Card>\n      <Card id=\"accordion\" name=\"Accordion\" how=\"Open one, then another.\">\n        <SakugaAccordion className=\"self-start\">\n          <SakugaAccordionItem>\n            <SakugaAccordionTrigger>Shipping</SakugaAccordionTrigger>\n            <SakugaAccordionContent>Tracked, and out in two days.</SakugaAccordionContent>\n          </SakugaAccordionItem>\n          <SakugaAccordionItem>\n            <SakugaAccordionTrigger>Returns</SakugaAccordionTrigger>\n            <SakugaAccordionContent>Thirty days to send it back.</SakugaAccordionContent>\n          </SakugaAccordionItem>\n          <SakugaAccordionItem>\n            <SakugaAccordionTrigger>Warranty</SakugaAccordionTrigger>\n            <SakugaAccordionContent>Two years, parts and labour.</SakugaAccordionContent>\n          </SakugaAccordionItem>\n        </SakugaAccordion>\n      </Card>\n      <Card id=\"chips\" name=\"Chips\" how=\"Type a tag and press Enter, then remove one.\">\n        <SakugaChips defaultValue={[\"Ink\", \"Paper\"]}>\n          <SakugaChipsList>\n            <SakugaChipsInput placeholder=\"Add a tag\" />\n          </SakugaChipsList>\n        </SakugaChips>\n      </Card>\n    </div>\n  </div>\n);\n","path":"/sakuga-vfx.tsx","target":"uicapsule/sakuga-vfx/sakuga-vfx.tsx","type":"registry:file"},{"content":"export type WordName = \"don\" | \"gogo\" | \"kachi\" | \"pon\" | \"shu\" | \"zuza\";\n\nexport const WORDS: Record<WordName, readonly [number, number, string]> = {\n  don: [\n    520,\n    297,\n    \"M3 290C4 287 6 283 7 281C9 277 18 252 19 248C20 246 19 246 15 250C13 253 11 255 11 254C12 253 15 242 19 230C24 218 30 195 34 180C38 165 43 144 46 133C49 122 51 113 51 113C50 113 50 110 51 107C52 104 52 98 52 94C53 86 57 69 63 54C69 41 69 40 70 41C71 42 72 42 74 40L76 38L75 40C75 43 76 42 85 34C90 28 94 24 95 24C95 24 94 27 92 30C87 40 88 40 100 28C106 22 111 18 111 18C111 18 110 20 109 22C107 28 108 28 114 23C123 15 124 15 122 19C120 21 120 22 121 21C124 20 132 14 136 10C141 5 141 5 136 14C132 23 132 23 135 23C136 22 136 22 135 24C133 29 131 36 132 36C132 36 133 35 135 34C136 32 138 31 138 31C138 31 136 39 132 48C123 71 97 147 98 148C98 148 101 147 105 145C108 144 116 141 122 138C128 136 141 131 150 128C179 117 232 98 234 98C235 98 233 101 229 104C226 108 223 111 223 111C224 111 222 114 219 117C213 124 213 124 216 123C218 123 218 124 214 128C209 133 205 139 204 142C203 143 203 143 205 142C208 140 208 141 204 147C201 150 200 152 201 152C204 151 203 152 197 159C193 163 192 166 194 166C196 166 192 169 182 173C176 175 172 177 170 176C169 176 166 177 163 178C157 180 144 185 143 185C143 185 143 184 144 184C144 183 144 183 143 183C142 183 137 185 132 186C122 189 99 198 90 201L85 204L80 216C73 232 61 258 59 261C57 263 57 263 58 258L58 252L55 255C54 256 52 259 51 260C50 261 49 262 50 261C51 258 48 261 43 267C37 274 36 274 39 268C40 265 41 262 41 262C41 261 36 266 29 273C23 280 18 285 17 285C17 284 18 282 19 279C23 271 22 272 14 281C10 286 5 291 4 292L1 296L3 290ZM223 274C222 274 221 273 220 273C219 273 218 272 218 271C218 266 214 260 212 260C211 261 210 260 210 258C208 251 208 247 208 247C208 246 208 246 207 246C207 246 206 243 207 239C207 234 207 232 206 232C205 233 205 232 206 227C207 225 210 222 214 218C222 213 223 212 220 217C218 221 220 220 233 211C244 203 247 201 243 205C242 207 241 208 241 208C242 210 296 172 333 144C343 137 352 131 353 130C356 129 382 110 397 98C403 94 408 90 408 90C408 91 403 99 397 107C393 112 393 116 396 111C397 111 398 110 398 110C398 111 394 116 390 122C379 135 379 136 382 134C384 133 384 133 383 134C379 140 373 148 372 149C371 151 371 151 381 143C385 140 388 138 389 138C389 138 386 142 382 147C378 151 375 155 375 156C377 158 353 182 344 189C342 191 332 199 323 206C304 222 280 241 277 242C276 242 273 244 269 247C259 255 226 276 225 276C225 276 224 275 223 274ZM373 264C372 264 372 263 372 262C372 261 371 259 370 259C369 257 369 257 370 252C373 244 372 243 370 246C366 249 366 248 369 243C373 237 378 226 378 225C378 222 386 217 398 211C411 204 415 202 413 204C412 205 412 206 412 207C413 207 429 203 432 202C434 201 435 200 429 212C425 222 425 222 432 217C436 214 436 214 428 226C424 231 420 238 418 242L414 249L403 255C397 258 391 261 389 263C384 266 384 266 385 263C385 261 383 261 378 264C375 265 374 265 373 264ZM392 199C392 196 438 54 441 46C444 41 453 28 458 23C463 18 463 18 462 21C461 23 460 25 459 27L458 29L461 27C462 26 467 22 470 19C477 13 477 13 473 21C471 24 470 27 470 27C471 27 476 24 483 20C496 12 497 11 495 14C491 17 494 16 505 9C512 5 517 2 517 2C518 2 515 6 512 10C507 17 500 29 502 29C502 29 504 28 506 26C509 25 511 23 512 23C514 22 514 21 507 32C499 44 497 49 502 44C505 41 504 44 498 55C488 70 483 79 477 92C473 98 470 103 470 104C467 107 455 132 456 131C460 128 459 131 450 145C446 153 438 166 434 174C425 190 425 191 426 184L426 179L420 184C416 188 412 191 411 193C409 196 408 194 410 189C411 185 410 185 405 191C403 193 401 195 401 194C402 191 401 192 396 196C394 199 392 200 392 199ZM226 147C228 140 228 140 226 141C225 141 225 140 227 136C232 128 235 122 234 121C234 120 235 118 237 115C245 103 245 103 242 104C241 105 241 104 244 102C250 96 260 88 264 87C268 86 282 87 281 88C281 89 283 89 285 89C287 89 289 90 289 90C289 91 294 92 299 94C304 95 309 96 309 97C310 98 319 102 325 102C331 103 331 103 326 108C325 110 323 113 323 113C323 114 320 118 316 121C312 125 309 129 309 129C310 129 307 132 304 136L299 142L290 142C279 141 265 142 245 148C235 150 226 152 225 153L223 153L226 147ZM133 121C133 103 157 28 160 39C160 41 161 41 166 35C173 28 174 28 173 32C171 36 172 36 180 32C184 30 188 28 188 29C189 29 192 28 195 26C201 22 202 22 199 29C197 31 196 36 195 39C192 46 167 99 165 101C164 102 164 102 164 100C164 99 163 100 158 104C153 109 153 109 153 107L153 104L149 107C147 108 143 112 139 116C136 120 133 122 133 121ZM180 104C180 97 192 64 203 43C210 29 220 16 218 22L218 25L225 21C231 16 233 15 231 18C226 25 230 23 245 13C251 10 255 7 255 8C255 8 253 12 251 15C246 22 245 25 248 22C251 20 250 22 246 30C241 38 240 39 243 38C245 37 245 36 228 62C212 85 208 91 209 87C209 85 208 84 207 86C206 86 204 88 202 90L198 93L199 90C200 87 198 88 188 98C184 102 180 105 180 104Z\",\n  ],\n  gogo: [\n    520,\n    288,\n    \"M1 284C1 281 1 274 1 268L2 257L15 253C22 250 32 247 37 246C42 245 46 244 46 243C47 243 50 217 49 216C48 215 31 222 19 228C4 235 6 235 6 231C7 229 7 229 6 229C4 230 4 231 6 220C8 215 9 208 10 206C10 202 10 201 13 201C15 200 24 197 34 194C43 190 51 187 52 187C52 187 52 189 52 192C52 198 53 199 60 196C66 193 79 190 80 190C80 191 79 198 77 207C73 225 70 242 70 254C69 263 72 261 44 270C28 275 18 279 1 288C0 288 0 286 1 284ZM84 281C84 280 85 273 87 263C88 254 89 245 89 243L88 239L102 234C109 232 122 228 129 226C136 224 143 222 143 222C143 221 149 189 149 187C149 185 148 186 133 192C119 197 105 204 97 209L93 211L93 207C94 203 94 202 93 203C91 203 91 202 93 198C98 186 102 173 102 169C102 167 103 166 103 166C109 164 125 159 137 154C145 151 151 149 152 149C152 149 153 152 154 156C154 160 154 163 155 163C155 163 159 161 164 159C171 156 190 152 191 153C191 153 189 164 185 178C179 205 174 231 174 240L174 245L163 248C157 250 148 253 142 255C131 258 101 271 90 278C85 281 84 281 84 281ZM191 269C191 268 192 260 193 251C195 241 196 230 196 225L196 217L200 216C203 215 217 211 233 206C249 200 263 196 265 196C267 195 268 194 269 194C269 193 276 149 276 148C275 147 241 160 230 166C226 168 219 172 214 175C201 182 202 183 205 165C206 159 208 147 209 140L211 126L215 125C217 125 231 121 247 116C263 110 276 106 278 106C280 105 280 105 281 114C281 122 281 123 283 123C284 122 289 120 294 118C307 113 327 109 327 112C327 113 324 125 321 139C312 173 305 212 307 219L307 223L298 226C293 228 283 231 276 232C259 237 209 259 196 267C192 269 192 269 191 269ZM321 255C321 253 333 202 333 201C334 201 333 199 332 197C330 192 331 191 338 191C342 190 357 187 372 184C387 180 404 176 410 175C415 174 420 173 420 172C421 172 433 117 433 115C433 113 430 114 418 118C396 124 369 136 353 146C348 150 344 152 343 152C343 151 343 148 344 144C346 137 346 136 343 138C340 139 340 139 344 124C349 108 352 94 352 88C352 83 353 81 356 81C359 81 381 75 402 69C421 63 436 59 437 59C437 60 437 65 438 70C438 76 439 81 439 82C440 82 446 80 454 77C466 72 469 72 481 70C500 68 498 68 496 73C496 76 493 84 491 92C489 99 485 112 483 119C478 132 470 167 469 178C468 182 467 187 466 191C465 195 465 200 465 203L464 209L455 211C450 212 441 215 435 216C429 218 420 221 415 223C395 228 372 237 353 246C332 257 332 257 332 254C333 251 331 251 326 254C322 257 321 258 321 255ZM55 179L56 164L64 160C69 158 74 156 74 157C74 157 73 164 71 173L67 188L62 191C59 193 56 194 56 194C55 194 55 187 55 179ZM72 188C72 186 78 162 79 161C80 160 93 155 94 155C95 155 93 162 89 173L85 184L79 186C73 188 72 188 72 188ZM157 140C157 130 157 121 156 119C156 116 156 115 159 115C160 114 166 112 171 109C176 107 181 105 181 106C182 106 181 111 179 116C178 122 176 132 175 138C174 145 173 151 173 151C172 151 158 158 158 158C157 158 157 150 157 140ZM178 149C178 146 185 115 186 114C187 113 202 107 204 107C206 107 205 113 199 131L195 146L188 148C184 149 180 150 179 150C179 150 178 150 178 149ZM285 103C285 95 285 84 285 78C285 67 285 67 288 66C293 65 300 63 308 59C320 54 319 54 315 69C311 81 308 93 306 102C305 108 305 109 302 109C301 110 296 112 292 114C288 115 285 117 285 117C284 117 284 111 285 103ZM311 106C311 105 313 97 316 87C318 77 320 68 321 67C321 66 322 65 323 64C325 63 345 56 346 56C348 56 347 62 341 78C332 104 334 102 323 105C318 106 313 107 312 108C312 108 311 107 311 106ZM443 74C442 73 442 15 442 14C443 14 445 13 447 13C450 13 458 10 466 6C474 3 481 0 481 1C482 1 480 10 478 20C475 30 472 45 470 52C469 60 467 66 467 66C466 66 461 68 455 71C442 76 443 75 443 74ZM475 64C475 64 478 52 481 37L487 11L503 5C512 2 519 0 519 1C521 2 505 55 502 59C502 59 497 61 490 62C484 63 478 64 477 65C476 65 475 65 475 64Z\",\n  ],\n  kachi: [\n    520,\n    295,\n    \"M28 292C28 290 53 225 68 186C72 175 75 167 75 167C73 167 30 186 15 193C8 196 2 199 1 199C1 198 25 138 26 137C26 136 41 132 59 127C76 122 91 118 92 118C92 117 97 103 102 85C108 68 113 53 114 53C114 52 118 51 122 51C126 50 138 48 147 46C157 45 166 43 166 44C168 45 167 49 156 74C149 89 144 101 144 102C144 103 171 94 195 86C218 78 216 78 220 84C221 87 224 92 227 96L231 102L221 122C208 150 203 160 188 196C163 260 160 265 148 265C143 265 139 262 125 247C114 235 111 231 102 228C97 226 97 226 111 223C117 223 125 221 130 220L139 218L141 213C143 208 168 136 168 135C167 135 157 138 145 142L124 149L108 180C90 219 84 232 82 236C80 241 79 243 73 246C70 248 60 259 49 270C26 295 28 294 28 292ZM258 263C258 261 271 217 281 187C287 168 292 152 292 151C291 151 235 175 220 183C214 186 210 188 209 188C209 187 217 151 219 145C220 142 221 142 262 126C285 117 304 110 304 110C304 109 310 81 310 80C309 80 289 89 263 101C252 106 244 110 243 110C243 109 245 106 247 102C252 92 252 92 245 92C242 92 239 92 239 92C240 88 378 1 383 1C384 1 383 3 382 5C379 10 379 11 384 15C387 17 387 18 387 20C386 25 388 28 395 35L402 42L399 43C396 44 358 60 357 60C357 61 347 94 347 95C347 96 359 92 373 87C403 77 428 69 429 69C429 69 425 75 419 82C413 89 406 98 403 101C398 109 401 108 362 124C348 129 336 134 336 134C336 135 333 141 330 150C307 205 308 203 301 210C297 214 292 221 288 226C273 245 258 264 258 263ZM427 204C427 199 485 90 490 84C491 84 494 84 500 85C505 86 512 87 514 87C517 88 519 89 520 90C520 90 510 105 497 124L475 156L451 180C438 194 427 204 427 204ZM406 136C407 124 408 114 408 113C409 112 433 98 435 98C436 98 437 96 432 121L427 143L417 150C412 155 407 158 406 158C406 158 406 148 406 136ZM439 135C440 124 445 90 445 89C447 88 469 80 470 81C470 81 468 91 465 103L460 124L450 134C445 139 440 143 440 143C439 143 439 140 439 135Z\",\n  ],\n  pon: [\n    520,\n    297,\n    \"M323 296C302 290 292 271 300 254C305 244 313 239 330 234C383 222 420 197 456 149C473 126 477 123 490 123C502 123 515 131 518 142C527 165 495 216 452 248C410 280 348 303 323 296ZM154 295C141 292 137 288 134 273C132 265 125 222 120 190C116 160 116 163 113 164C112 164 99 168 85 172C41 186 32 187 19 183C4 179-3 162 2 147C10 127 29 118 84 107C96 104 107 102 107 101C107 101 106 98 105 94C99 74 97 61 101 53C107 40 128 29 147 29C169 29 177 40 177 73C177 83 177 88 178 88C179 88 185 86 193 84L207 81L204 76C191 56 197 29 217 14C242-4 271-4 289 15C314 42 302 84 266 96L260 98L260 105C259 125 245 133 191 145C180 148 180 147 182 159C186 175 192 223 194 242C197 276 193 286 175 293C169 295 157 296 154 295ZM42 292C26 286 21 269 27 246C35 221 50 196 62 189C69 185 86 185 93 189C109 197 110 213 97 249C85 281 74 292 55 293C48 293 44 293 42 292ZM240 251C227 246 218 234 203 204C192 183 192 175 203 165C220 149 242 154 266 178C284 196 288 209 282 227C276 243 253 256 240 251ZM366 172C350 167 309 151 303 147C289 136 289 116 303 100C316 85 333 83 360 94C389 106 404 122 404 138C404 160 386 177 366 172ZM256 63C268 57 270 40 258 34C244 26 226 43 234 56C238 64 248 67 256 63Z\",\n  ],\n  shu: [\n    520,\n    266,\n    \"M8 258C11 255 14 252 14 251C14 251 15 250 16 249C17 248 19 244 19 242C19 242 20 241 20 240C22 237 22 236 19 238C16 239 16 238 21 234C25 231 26 229 26 227C26 226 27 225 27 224C28 223 29 222 28 222C28 221 60 197 61 198C62 198 86 181 120 157C144 140 146 138 171 118C216 81 246 58 270 42C277 37 277 37 256 58C235 78 217 98 182 138C139 187 131 194 76 230C56 242 57 242 63 236C66 233 68 230 68 230C67 230 67 230 51 240C45 244 38 249 36 250L32 252L36 247L42 242L37 245C35 246 31 249 28 250C24 253 22 254 24 252C24 251 24 251 23 252C22 252 17 255 12 258L2 264L8 258ZM24 221C28 216 42 207 40 209C38 212 30 218 24 221L20 223L24 221ZM192 189C192 188 194 187 197 185C202 182 203 180 200 181C199 182 202 179 206 175C210 171 213 168 212 168C211 168 211 168 212 166C216 161 216 160 213 161C211 162 209 162 209 162C209 161 217 156 218 156C218 156 220 155 222 153C227 149 250 140 277 132C287 129 290 128 291 127C291 125 294 118 298 109C301 101 304 94 304 93C304 93 291 99 276 106C261 113 247 119 244 120L240 122L242 120C243 118 244 117 244 116C244 116 245 115 246 114C246 113 247 112 247 111C246 111 247 109 247 108C249 106 248 103 246 103C245 104 246 102 248 100C253 94 253 94 249 94C247 95 245 95 245 95C245 94 257 88 258 88C258 89 262 87 266 86C282 78 340 57 341 58C341 59 340 60 338 62C335 67 336 67 344 64C347 63 349 62 350 62C350 62 346 68 342 74C333 88 313 122 314 123C314 123 325 121 336 118C361 111 367 110 366 111C366 112 365 112 364 112C363 112 363 112 364 113C365 114 366 115 365 115C365 116 368 116 373 116L380 115L376 117C373 118 360 123 348 127C336 132 323 136 321 138C319 139 300 146 280 154C259 162 233 172 222 177C192 189 192 189 192 189ZM38 158C43 153 46 150 46 150C45 150 46 148 46 146C47 145 47 143 47 143C46 143 46 142 47 141C48 139 48 139 47 139C45 140 45 139 47 137L49 133L44 136L40 138L46 132C54 124 55 120 48 124C43 127 42 127 46 122C53 115 77 103 108 91C123 85 138 79 150 73C156 71 163 68 166 68C168 67 172 66 174 65C180 62 180 63 172 69C164 76 160 80 164 79C165 78 164 79 162 81C161 82 160 84 160 84C159 85 155 89 149 93C138 100 132 105 135 103C145 98 108 124 82 139C63 150 61 151 66 147C71 143 68 144 56 151C50 155 45 158 44 158C43 158 40 159 36 161L30 165L38 158ZM379 158C380 157 386 149 392 141C411 116 432 84 453 48C463 32 471 22 472 22C472 23 475 22 477 20C480 18 482 17 483 17C483 17 487 15 492 13C497 11 501 9 502 9C503 10 513 5 516 3C526-6 468 68 451 84C441 95 413 124 392 146C384 154 378 160 379 158ZM380 93C380 90 380 81 380 73C381 55 384 41 386 45C386 46 388 45 390 43C392 41 393 40 393 41C393 41 394 41 395 40C396 39 398 38 399 37C400 37 403 36 405 34C407 33 409 32 410 32C410 32 412 30 415 28C417 26 419 25 419 25C419 29 398 75 395 78C394 79 392 82 390 84C388 86 386 89 385 90C384 91 383 93 382 95C379 99 379 99 380 93ZM46 88C57 78 59 76 62 73C63 71 66 69 67 68C69 66 69 66 66 68C62 69 61 69 64 67C66 65 67 62 65 63C63 65 64 62 67 58L70 53L67 54C65 54 62 55 61 55C60 56 61 54 65 52C69 50 72 47 74 46C80 40 154 13 159 15C160 15 160 15 160 14C159 13 159 13 160 14C161 14 167 12 174 9C186 5 189 4 184 7C174 14 168 21 172 21C173 21 171 24 167 28C164 32 162 34 164 34C168 32 160 38 147 45C140 49 132 54 128 57C124 59 115 64 107 69C99 73 90 78 86 80C82 82 80 82 81 82C81 81 82 80 82 80C82 80 83 79 84 78C85 76 82 77 73 82C66 86 60 89 60 89C59 89 60 88 64 81C65 79 64 80 58 82C55 85 49 87 47 89L42 91L46 88ZM412 83C412 82 416 59 418 50C420 41 425 30 426 31C426 32 432 28 433 26C434 25 439 23 451 17C453 16 456 14 457 13C461 10 461 10 448 35C434 60 433 61 425 69C421 73 416 78 415 80C413 84 412 85 412 83Z\",\n  ],\n  zuza: [\n    520,\n    287,\n    \"M3 282C6 279 27 251 63 203C78 183 99 155 109 141C119 128 128 115 129 113C130 111 131 110 131 110C130 108 61 142 35 157C28 161 22 164 22 164C22 163 23 161 25 158C31 146 40 118 40 112C40 111 39 109 38 108C38 107 37 106 37 106C37 105 48 101 67 94C82 89 92 85 155 61C177 53 195 46 195 46C195 46 195 52 193 60C192 67 190 79 189 85L188 97L166 126C153 142 143 155 143 156C143 156 148 159 154 162C172 171 213 194 215 196C215 197 213 199 211 202C203 210 189 236 189 241C189 242 189 243 188 243C188 243 152 217 132 201L119 191L101 207C79 226 53 248 52 248C52 248 52 247 53 247C53 246 54 245 54 245C54 244 52 245 26 266C16 275 6 282 4 283L2 285L3 282ZM287 256C297 230 308 203 314 189C326 161 340 127 340 126C339 126 307 137 306 138C306 138 303 147 299 158L293 176L285 183C281 187 274 193 271 197C268 201 266 204 265 204C265 204 270 173 273 154C273 151 273 148 273 148C270 148 223 167 211 173C203 177 202 177 205 171C207 167 217 136 217 134C217 133 216 131 216 130C214 128 214 128 247 119C265 114 280 110 280 110C280 109 281 102 283 93C290 64 289 66 295 63C303 59 336 45 336 45C337 45 334 52 330 61C322 81 316 99 316 100C317 100 325 98 334 95L351 90L356 77C363 57 368 44 370 42C372 39 412 20 413 21C413 22 411 28 408 35C400 52 391 78 391 79C391 80 395 80 407 77C416 75 428 72 434 71L445 68L443 71C417 103 415 105 410 106C407 107 399 109 393 111L381 114L372 136C354 181 351 186 344 194C340 197 333 205 328 212C323 218 311 231 302 242C293 252 286 261 285 261C285 261 286 259 287 256ZM424 202C426 200 436 184 447 166C459 147 472 126 477 119L486 105L493 103C502 100 517 97 518 97C519 97 516 102 512 107C508 112 498 126 489 138C474 159 473 160 458 173C450 180 439 190 435 194C431 197 426 201 425 203L423 204L424 202ZM411 154C411 146 412 136 412 131L412 123L426 115C442 107 443 107 442 110C438 130 431 152 428 153C427 155 422 158 418 162L410 168L411 154ZM442 145C449 108 449 108 454 104C459 101 478 91 479 91C479 91 468 117 462 132C461 134 457 137 452 141C441 149 442 149 442 145ZM193 104C193 103 195 89 198 74C204 36 204 33 207 31C211 28 241 11 242 11C243 11 242 14 240 19C239 23 234 37 229 49C223 68 221 72 218 76C208 88 196 102 194 104L192 106L193 104ZM223 87C223 85 243 31 246 24C247 21 250 19 256 15C270 7 282 1 282 2C281 3 278 11 274 20C270 29 264 42 261 50L256 62L248 68C244 71 237 76 232 81C227 85 223 88 223 87ZM408 70C408 66 425 22 429 18C431 15 457 1 458 2C458 3 453 13 446 26C435 48 434 50 429 54C426 56 420 61 416 65C411 68 408 71 408 70ZM437 63C444 43 455 20 458 18C462 14 488 0 489 1C489 2 470 37 465 44C464 45 458 50 451 54C436 66 436 66 437 63Z\",\n  ],\n};\n","path":"/sakuga-words.ts","target":"uicapsule/sakuga-vfx/sakuga-words.ts","type":"registry:file"}],"homepage":"https://www.uicapsule.com/ui/sakuga-vfx","name":"sakuga-vfx","registryDependencies":[],"title":"Sakuga VFX","type":"registry:block"}