{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "square-unlock-01",
  "title": "square-unlock-01",
  "description": "Animated square unlock icon",
  "dependencies": [
    "motion"
  ],
  "files": [
    {
      "path": "icons/square-unlock-01.tsx",
      "content": "'use client';\n\nimport type { Variants } from 'motion/react';\nimport { motion, useAnimation } from 'motion/react';\nimport type { HTMLAttributes } from 'react';\nimport { forwardRef } from 'react';\nimport { useIconAnimation } from '@/lib/use-icon-animation';\nimport { cn } from '@/lib/utils';\n\nexport interface SquareUnlock01IconHandle {\n  startAnimation: () => void;\n  stopAnimation: () => void;\n}\n\ninterface SquareUnlock01IconProps extends HTMLAttributes<HTMLDivElement> {\n  size?: number;\n}\n\nconst UNLOCK_DURATION = 0.95;\nconst UNLOCK_TIMES = [0, 0.12, 0.36, 0.58, 0.8, 0.91, 1];\n\n// The latch releases: the shackle dips, springs up and swings wide on its\n// left leg, hangs, then drops back to its open rest. The body recoils as\n// the shackle leaves it.\nconst shackleVariants: Variants = {\n  normal: { translateY: 0, rotate: 0 },\n  animate: {\n    translateY: [0, 0, -1.8, -1.6, 0.2, -0.06, 0],\n    rotate: [0, 3, -22, -18, 1.5, -0.5, 0],\n    transition: {\n      duration: UNLOCK_DURATION,\n      ease: 'easeInOut',\n      times: UNLOCK_TIMES,\n    },\n  },\n};\n\nconst bodyVariants: Variants = {\n  normal: { translateY: 0 },\n  animate: {\n    translateY: [0, -0.2, 0.7, 0, 0, 0, 0],\n    transition: {\n      duration: UNLOCK_DURATION,\n      ease: 'easeInOut',\n      times: UNLOCK_TIMES,\n    },\n  },\n};\n\nconst SquareUnlock01Icon = forwardRef<SquareUnlock01IconHandle, SquareUnlock01IconProps>(\n  ({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {\n    const controls = useAnimation();\n    const { handleMouseEnter, handleMouseLeave } = useIconAnimation({\n      controls,\n      loops: false,\n      onMouseEnter,\n      onMouseLeave,\n      ref,\n    });\n\n    return (\n      <div\n        className={cn(className)}\n        onMouseEnter={handleMouseEnter}\n        onMouseLeave={handleMouseLeave}\n        {...props}\n      >\n        <svg\n          xmlns=\"http://www.w3.org/2000/svg\"\n          width={size}\n          height={size}\n          viewBox=\"0 0 24 24\"\n          fill=\"none\"\n          overflow=\"visible\"\n        >\n          <motion.g variants={bodyVariants} animate={controls} initial=\"normal\">\n            <path\n              d=\"M4.26781 18.8447C4.49269 20.515 5.87613 21.8235 7.55966 21.9009C8.97627 21.966 10.4153 22 12 22C13.5847 22 15.0237 21.966 16.4403 21.9009C18.1239 21.8235 19.5073 20.515 19.7322 18.8447C19.879 17.7547 20 16.6376 20 15.5C20 14.3624 19.879 13.2453 19.7322 12.1553C19.5073 10.485 18.1239 9.17649 16.4403 9.09909C15.0237 9.03397 13.5847 9 12 9C10.4153 9 8.97627 9.03397 7.55965 9.09909C5.87613 9.17649 4.49269 10.485 4.26781 12.1553C4.12104 13.2453 4 14.3624 4 15.5C4 16.6376 4.12104 17.7547 4.26781 18.8447Z\"\n              stroke=\"currentColor\"\n              strokeWidth=\"1.5\"\n            />\n            <path\n              d=\"M12.125 15.5H12M12.25 15.5C12.25 15.6381 12.1381 15.75 12 15.75C11.8619 15.75 11.75 15.6381 11.75 15.5C11.75 15.3619 11.8619 15.25 12 15.25C12.1381 15.25 12.25 15.3619 12.25 15.5Z\"\n              stroke=\"currentColor\"\n              strokeLinecap=\"round\"\n              strokeWidth=\"1.5\"\n            />\n          </motion.g>\n          <motion.path\n            d=\"M7.5 9V6.5C7.5 4.01472 9.51472 2 12 2C13.9593 2 15.5 3.5 16 5\"\n            stroke=\"currentColor\"\n            strokeLinecap=\"round\"\n            strokeLinejoin=\"round\"\n            strokeWidth=\"1.5\"\n            variants={shackleVariants}\n            animate={controls}\n            initial=\"normal\"\n            style={{ transformBox: 'view-box', originX: 7.5 / 24, originY: 9 / 24 }}\n          />\n        </svg>\n      </div>\n    );\n  }\n);\n\nSquareUnlock01Icon.displayName = 'SquareUnlock01Icon';\n\nexport { SquareUnlock01Icon };\n",
      "type": "registry:ui"
    },
    {
      "path": "lib/use-icon-animation.ts",
      "content": "'use client';\n\nimport type { LegacyAnimationControls } from 'motion/react';\nimport { spring, useReducedMotion } from 'motion/react';\nimport type {\n  ForwardedRef,\n  MouseEventHandler,\n} from 'react';\nimport { useCallback, useImperativeHandle, useRef } from 'react';\n\n/**\n * A damped spring as the easing of one keyframe segment: the value overshoots\n * its target and settles on it. Use it for landings so every icon shares the\n * same physical bounce. Higher `bounce` gives more oscillation.\n */\nexport function springEase(bounce = 0.45, visualDuration = 0.35) {\n  const generator = spring({ keyframes: [0, 1], bounce, visualDuration });\n  let settle = 0;\n  while (!generator.next(settle).done && settle < 5000) settle += 10;\n  return (progress: number) =>\n    progress >= 1 ? 1 : generator.next(progress * settle).value;\n}\n\nconst NUMBER = /-?\\d*\\.?\\d+/g;\n\n/**\n * The path at position `t` along a row of poses that share the same path\n * commands: `t = 1` is the second pose, `t = 1.5` is halfway to the third.\n * Waves use it to move along their own curvature instead of scaling, so the\n * stroke keeps its width.\n */\nexport function pathAt(poses: string[], t: number) {\n  const i = Math.min(Math.max(Math.floor(t), 0), poses.length - 2);\n  const to = poses[i + 1].match(NUMBER) ?? [];\n  let k = 0;\n  return poses[i].replace(NUMBER, (from) => {\n    const value = Number(from) + (Number(to[k++]) - Number(from)) * (t - i);\n    return String(Math.round(value * 10000) / 10000);\n  });\n}\n\nexport interface AnimatedIconHandle {\n  startAnimation: () => void;\n  stopAnimation: () => void;\n}\n\ninterface UseIconAnimationOptions {\n  controls: LegacyAnimationControls;\n  loops?: boolean;\n  onMouseEnter?: MouseEventHandler<HTMLDivElement>;\n  onMouseLeave?: MouseEventHandler<HTMLDivElement>;\n  ref: ForwardedRef<AnimatedIconHandle>;\n}\n\nexport function useIconAnimation({\n  controls,\n  loops = false,\n  onMouseEnter,\n  onMouseLeave,\n  ref,\n}: UseIconAnimationOptions) {\n  const shouldReduceMotion = useReducedMotion();\n  const isControlledRef = useRef(false);\n  const isPlayingRef = useRef(false);\n  const runRef = useRef(0);\n\n  const startAnimation = useCallback(() => {\n    if (shouldReduceMotion || isPlayingRef.current) return;\n\n    isPlayingRef.current = true;\n    const run = ++runRef.current;\n    controls.set('normal');\n    void controls.start('animate').then(() => {\n      if (runRef.current === run) isPlayingRef.current = false;\n    });\n  }, [controls, shouldReduceMotion]);\n\n  const stopAnimation = useCallback(() => {\n    if (!loops) return;\n\n    runRef.current++;\n    isPlayingRef.current = false;\n    void controls.start('normal');\n  }, [controls, loops]);\n\n  useImperativeHandle(\n    ref,\n    () => {\n      isControlledRef.current = true;\n      return { startAnimation, stopAnimation };\n    },\n    [startAnimation, stopAnimation]\n  );\n\n  const handleMouseEnter = useCallback<MouseEventHandler<HTMLDivElement>>(\n    (event) => {\n      onMouseEnter?.(event);\n      if (!isControlledRef.current) startAnimation();\n    },\n    [onMouseEnter, startAnimation]\n  );\n\n  const handleMouseLeave = useCallback<MouseEventHandler<HTMLDivElement>>(\n    (event) => {\n      onMouseLeave?.(event);\n      if (!isControlledRef.current) stopAnimation();\n    },\n    [onMouseLeave, stopAnimation]\n  );\n\n  return { handleMouseEnter, handleMouseLeave };\n}\n",
      "type": "registry:lib"
    }
  ],
  "type": "registry:ui"
}