{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "mail-01",
  "type": "registry:ui",
  "title": "mail-01",
  "description": "Animated mail icon for Vue",
  "dependencies": [
    "motion-v"
  ],
  "files": [
    {
      "path": "components/ui/mail-01.vue",
      "type": "registry:ui",
      "content": "<script setup lang=\"ts\">\nimport { motion, useAnimationControls } from 'motion-v'\nimport type { Variants } from 'motion-v'\nimport { useId } from 'vue'\nimport { useIconAnimation } from '../composables/useIconAnimation'\nimport type { AnimatedIconHandle } from '../types'\n\ndefineOptions({ inheritAttrs: false, name: 'Mail01Icon' })\n\nwithDefaults(\n  defineProps<{\n    size?: number\n  }>(),\n  { size: 28 },\n)\n\nconst MAIL_CLOSED =\n  'M2 6L8.91302 9.91697C11.4616 11.361 12.5384 11.361 15.087 9.91697L22 6';\nconst MAIL_EDGE_ON =\n  'M2 6L8.91302 6.55C11.4616 6.8 12.5384 6.8 15.087 6.55L22 6';\nconst MAIL_OPEN =\n  'M2 6L8.91302 1.6C11.4616 -0.05 12.5384 -0.05 15.087 1.6L22 6';\nconst MAIL_OPEN_OVERSHOOT =\n  'M2 6L8.91302 1.25C11.4616 -0.45 12.5384 -0.45 15.087 1.25L22 6';\nconst MAIL_CLOSED_OVERSHOOT =\n  'M2 6L8.91302 10.15C11.4616 11.65 12.5384 11.65 15.087 10.15L22 6';\nconst MAIL_REAR_EDGE =\n  'M3.24496 4.79066C4.37608 3.65523 5.95033 3.61568 9.09882 3.53656C11.0393 3.48781 12.9607 3.48781 14.9012 3.53657C18.0497 3.61568 19.6239 3.65523 20.7551 4.79066';\nconst MAIL_ENTRY_LINE =\n  'M5.2 7.4C8.7 9.1 15.3 9.1 18.8 7.4';\n\n// The flap turns edge-on, opens fully, then softly overshoots the closed position.\nconst flapVariants: Variants = {\n  normal: { d: MAIL_CLOSED },\n  animate: {\n    d: [\n      MAIL_CLOSED,\n      MAIL_EDGE_ON,\n      MAIL_OPEN,\n      MAIL_OPEN_OVERSHOOT,\n      MAIL_OPEN,\n      MAIL_OPEN,\n      MAIL_EDGE_ON,\n      MAIL_CLOSED_OVERSHOOT,\n      MAIL_CLOSED,\n    ],\n    transition: {\n      duration: 0.94,\n      ease: [0.77, 0, 0.175, 1],\n      times: [0, 0.13, 0.28, 0.38, 0.5, 0.62, 0.76, 0.9, 1],\n    },\n  },\n};\n\nconst bodyVariants: Variants = {\n  normal: { transform: 'translateY(0px) scaleX(1) scaleY(1)' },\n  animate: {\n    transform: [\n      'translateY(0px) scaleX(1) scaleY(1)',\n      'translateY(0px) scaleX(1) scaleY(1)',\n      'translateY(0.12px) scaleX(1.008) scaleY(0.992)',\n      'translateY(0.45px) scaleX(1.035) scaleY(0.958)',\n      'translateY(-0.32px) scaleX(0.985) scaleY(1.022)',\n      'translateY(0.12px) scaleX(1.008) scaleY(0.994)',\n      'translateY(0px) scaleX(1) scaleY(1)',\n    ],\n    transition: {\n      duration: 0.94,\n      ease: [0.23, 1, 0.32, 1],\n      times: [0, 0.28, 0.38, 0.5, 0.68, 0.84, 1],\n    },\n  },\n};\n\nconst generatedGeometryVariants: Variants = {\n  normal: { visibility: 'hidden' },\n  animate: {\n    visibility: [\n      'hidden',\n      'hidden',\n      'visible',\n      'visible',\n      'hidden',\n      'hidden',\n    ],\n    transition: {\n      duration: 0.94,\n      ease: 'linear',\n      times: [0, 0.26, 0.27, 0.66, 0.67, 1],\n    },\n  },\n};\n\nconst controls = useAnimationControls()\nconst maskId = `mail-rear-edge-${useId().replaceAll(':', '')}`;\nconst flapMaskId = `mail-flap-${useId().replaceAll(':', '')}`;\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            <defs>\n              <mask :id=\"maskId\" x=\"0\" y=\"0\" width=\"24\" height=\"24\" maskUnits=\"userSpaceOnUse\">\n                <rect width=\"24\" height=\"24\" fill=\"white\" />\n                <motion.g :variants=\"generatedGeometryVariants\" :animate=\"controls\" initial=\"normal\">\n                  <path :d=\"MAIL_REAR_EDGE\" stroke=\"black\" stroke-linecap=\"round\" stroke-width=\"2.2\" />\n                </motion.g>\n              </mask>\n              <mask :id=\"flapMaskId\" x=\"0\" y=\"0\" width=\"24\" height=\"24\" maskUnits=\"userSpaceOnUse\">\n                <rect width=\"24\" height=\"24\" fill=\"white\" />\n                <motion.path :d=\"MAIL_CLOSED\" fill=\"black\" :variants=\"flapVariants\" :animate=\"controls\" initial=\"normal\" />\n              </mask>\n            </defs>\n            <motion.path d=\"M2 6L8.91302 9.91697C11.4616 11.361 12.5384 11.361 15.087 9.91697L22 6\" stroke=\"currentColor\" stroke-linejoin=\"round\" stroke-width=\"1.5\" :variants=\"flapVariants\" :animate=\"controls\" initial=\"normal\" />\n            <motion.g :variants=\"bodyVariants\" :animate=\"controls\" initial=\"normal\" :style=\"{ transformOrigin: '12px 12px' }\">\n              <path d=\"M2.01577 13.4756C2.08114 16.5412 2.11383 18.0739 3.24496 19.2094C4.37608 20.3448 5.95033 20.3843 9.09883 20.4634C11.0393 20.5122 12.9607 20.5122 14.9012 20.4634C18.0497 20.3843 19.6239 20.3448 20.7551 19.2094C21.8862 18.0739 21.9189 16.5412 21.9842 13.4756C22.0053 12.4899 22.0053 11.5101 21.9842 10.5244C21.9189 7.45886 21.8862 5.92609 20.7551 4.79066C19.6239 3.65523 18.0497 3.61568 14.9012 3.53657C12.9607 3.48781 11.0393 3.48781 9.09882 3.53656C5.95033 3.61566 4.37608 3.65521 3.24495 4.79065C2.11382 5.92608 2.08114 7.45885 2.01576 10.5244C1.99474 11.5101 1.99475 12.4899 2.01577 13.4756Z\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" :mask=\"`url(#${maskId})`\" />\n              <path :d=\"MAIL_ENTRY_LINE\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" :mask=\"`url(#${flapMaskId})`\" />\n            </motion.g>\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"
    }
  ]
}
