{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ai-eraser",
  "type": "registry:ui",
  "title": "ai-eraser",
  "description": "Animated ai eraser icon for Vue",
  "dependencies": [
    "motion-v"
  ],
  "files": [
    {
      "path": "components/ui/ai-eraser.vue",
      "type": "registry:ui",
      "content": "<script setup lang=\"ts\">\nimport { motion, useAnimationControls } from 'motion-v'\nimport type { Variants } from 'motion-v'\nimport { useIconAnimation } from '../composables/useIconAnimation'\nimport type { AnimatedIconHandle } from '../types'\n\ndefineOptions({ inheritAttrs: false, name: 'AiEraserIcon' })\n\nwithDefaults(\n  defineProps<{\n    size?: number\n  }>(),\n  { size: 28 },\n)\n\n// the eraser rubs back and forth along its own diagonal and the spark flares where it clears\n// authored from scripts/authored\nconst eraserVariants: Variants = {\n  normal: { transform: 'translate(0px, 0px)' },\n  animate: {\n    transform: [\n      'translate(0px, 0px)',\n      'translate(-1.2px, 1.2px)',\n      'translate(1px, -1px)',\n      'translate(-0.4px, 0.4px)',\n      'translate(0px, 0px)',\n    ],\n    transition: {\n      duration: 0.82,\n      times: [0, 0.26, 0.52, 0.74, 1],\n      ease: [\n        [0.77, 0, 0.175, 1],\n        [0.77, 0, 0.175, 1],\n        [0.77, 0, 0.175, 1],\n        [0.23, 1, 0.32, 1],\n      ],\n    },\n  },\n};\n\nconst sparkVariants: Variants = {\n  normal: { transform: 'rotate(0deg) scale(1)', opacity: 1 },\n  animate: {\n    transform: [\n      'rotate(0deg) scale(1)',\n      'rotate(-26deg) scale(0.5)',\n      'rotate(9deg) scale(1.2)',\n      'rotate(0deg) scale(1)',\n    ],\n    opacity: [1, 0.5, 1, 1],\n    transition: { duration: 0.62, delay: 0.2, times: [0, 0.3, 0.66, 1], ease: [0.23, 1, 0.32, 1] },\n  },\n};\n\nconst controls = useAnimationControls()\nconst { onMouseEnter, onMouseLeave, startAnimation, stopAnimation } = useIconAnimation({\n  controls,\n  loops: false,\n})\n\ndefineExpose<AnimatedIconHandle>({ startAnimation, stopAnimation })\n</script>\n\n<template>\n  <div class=\"hia-icon\" @mouseenter=\"onMouseEnter\" @mouseleave=\"onMouseLeave\" v-bind=\"$attrs\">\n          <svg xmlns=\"http://www.w3.org/2000/svg\" :width=\"size\" :height=\"size\" viewBox=\"0 0 24 24\" fill=\"none\" overflow=\"visible\">\n            <motion.path d=\"M9.73792 10.7802L5.84693 14.7574C4.67722 15.953 4.09236 16.5508 4.01263 17.2802C3.99579 17.4343 3.99579 17.5899 4.01263 17.744C4.09236 18.4733 4.67722 19.0711 5.84693 20.2668L5.99601 20.4191C6.62049 21.0575 6.93274 21.3766 7.30638 21.5911C7.5236 21.7157 7.75482 21.8134 7.99505 21.882C8.40827 22 8.85149 22 9.73792 22C10.6244 22 11.0676 22 11.4808 21.882C11.721 21.8134 11.9522 21.7157 12.1695 21.5911C12.5431 21.3766 12.8554 21.0575 13.4798 20.4191L16.3239 17.5121M9.73792 10.7802L13.3199 7.12313C14.7065 5.70754 15.3997 4.99974 16.2627 5C17.1256 5.00026 17.8185 5.70846 19.2042 7.12487L19.9473 7.8845C21.3159 9.28342 22.0002 9.98288 22 10.8501C21.9997 11.7173 21.315 12.4163 19.9456 13.8144L16.3239 17.5121M9.73792 10.7802L16.3239 17.5121\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" :variants=\"eraserVariants\" :animate=\"controls\" initial=\"normal\" :style=\"{ transformOrigin: '13px 13.5px' }\" />\n            <motion.path d=\"M5.5 2L5.75792 2.69703C6.09613 3.61102 6.26524 4.06802 6.59861 4.40139C6.93198 4.73477 7.38898 4.90387 8.30297 5.24208L9 5.5L8.30297 5.75792C7.38898 6.09613 6.93198 6.26524 6.59861 6.59861C6.26524 6.93198 6.09613 7.38898 5.75792 8.30297L5.5 9L5.24208 8.30297C4.90387 7.38898 4.73476 6.93198 4.40139 6.59861C4.06802 6.26524 3.61102 6.09613 2.69703 5.75792L2 5.5L2.69703 5.24208C3.61102 4.90387 4.06802 4.73477 4.40139 4.40139C4.73477 4.06802 4.90387 3.61102 5.24208 2.69703L5.5 2Z\" stroke=\"currentColor\" stroke-linejoin=\"round\" stroke-width=\"1.5\" :variants=\"sparkVariants\" :animate=\"controls\" initial=\"normal\" :style=\"{ transformOrigin: '5.5px 5.5px' }\" />\n          </svg>\n        </div>\n</template>\n"
    },
    {
      "path": "composables/useIconAnimation.ts",
      "type": "registry:lib",
      "content": "import { ref, toValue, type MaybeRefOrGetter } from 'vue'\nimport type { AnimatedIconHandle } from '../types'\n\nexport type IconPose = 'normal' | 'animate'\n\ntype AnimationControls = {\n  set: (variant: IconPose | Record<string, unknown>) => void\n  start: (variant: IconPose | Record<string, unknown>) => Promise<unknown>\n}\n\nexport function useReducedMotionFlag(\n  reduced?: MaybeRefOrGetter<boolean | undefined>,\n) {\n  if (typeof window === 'undefined') return () => false\n  return () => {\n    const override = reduced === undefined ? undefined : toValue(reduced)\n    if (override !== undefined) return override\n    return window.matchMedia('(prefers-reduced-motion: reduce)').matches\n  }\n}\n\nexport function useIconAnimation(options: {\n  controls: AnimationControls\n  loops?: boolean\n}): AnimatedIconHandle & {\n  onMouseEnter: () => void\n  onMouseLeave: () => void\n} {\n  const { controls, loops = false } = options\n  const isPlaying = ref(false)\n  let run = 0\n\n  const prefersReduced = () =>\n    typeof window !== 'undefined' &&\n    window.matchMedia('(prefers-reduced-motion: reduce)').matches\n\n  async function startAnimation() {\n    if (prefersReduced() || isPlaying.value) return\n\n    isPlaying.value = true\n    const current = ++run\n    controls.set('normal')\n    await controls.start('animate')\n    if (run === current) isPlaying.value = false\n  }\n\n  function stopAnimation() {\n    if (!loops) return\n    run += 1\n    isPlaying.value = false\n    void controls.start('normal')\n  }\n\n  return {\n    startAnimation,\n    stopAnimation,\n    onMouseEnter: () => {\n      void startAnimation()\n    },\n    onMouseLeave: () => {\n      stopAnimation()\n    },\n  }\n}\n"
    },
    {
      "path": "types/animated-icon.ts",
      "type": "registry:lib",
      "content": "export interface AnimatedIconHandle {\n  startAnimation: () => void\n  stopAnimation: () => void\n}\n\nexport interface AnimatedIconProps {\n  size?: number\n}\n"
    }
  ]
}
