{
  "mappings": "AAAA,cACE,iBACA,sBAEA,2BACK;;;;;;;;;;;;;AAkCP,OAAO,iBAAS,oBACd,YAAY,sBACX;;;;;;;;;AAqHH,OAAO,iBAAS,wBACd,YAAY,sBACZ,4BACU;;;;AAcZ,OAAO,iBAAS,aAAa,YAAY;;;;;AAazC,OAAO,iBAAS,sBAAsB,YAAY;;;;;;;;;AAYlD,OAAO,iBAAS,sBACd,YAAY,sBACZ,OAAO,UAAU,SAAS;;;;;;;;;;;AAqB5B,OAAO,iBAAS,2BAA2B,GACzC,YAAY,sBACZ,YAAY,eAAe,IAC3B,gBACA,kBAAkB,WACjB,YAAY",
  "names": [],
  "sources": [
    "src/normalizeTransition.ts"
  ],
  "version": 3,
  "sourcesContent": [
    "import type {\n  AnimationConfig,\n  NormalizedTransition,\n  SpringConfig,\n  TransitionPropInput,\n} from './types'\n\nconst SPRING_CONFIG_KEYS: Set<string> = new Set([\n  'stiffness',\n  'damping',\n  'mass',\n  'tension',\n  'friction',\n  'velocity',\n  'overshootClamping',\n  'duration',\n  'bounciness',\n  'speed',\n])\n\n/**\n * Check if a key is a spring config parameter\n */\nfunction isSpringConfigKey(key: string): key is keyof SpringConfig {\n  return SPRING_CONFIG_KEYS.has(key)\n}\n\n/**\n * Normalizes the various transition prop formats into a consistent structure.\n *\n * Supported input formats:\n * - String: \"bouncy\" -> { default: \"bouncy\", enter: null, exit: null, properties: {} }\n * - Object: { x: 'quick', default: 'slow' } -> { default: \"slow\", enter: null, exit: null, properties: { x: \"quick\" } }\n * - Object with enter/exit: { enter: 'bouncy', exit: 'quick' } -> { default: null, enter: \"bouncy\", exit: \"quick\", properties: {} }\n * - Array: ['bouncy', { delay: 100, x: 'quick' }] -> { default: \"bouncy\", enter: null, exit: null, delay: 100, properties: { x: \"quick\" } }\n *\n * @param transition - The transition prop value in any supported format\n * @returns Normalized transition object with consistent structure\n */\nexport function normalizeTransition(\n  transition: TransitionPropInput\n): NormalizedTransition {\n  // Handle null/undefined\n  if (!transition) {\n    return {\n      default: null,\n      enter: null,\n      exit: null,\n      delay: undefined,\n      properties: {},\n    }\n  }\n\n  // String format: \"bouncy\"\n  if (typeof transition === 'string') {\n    return {\n      default: transition,\n      enter: null,\n      exit: null,\n      delay: undefined,\n      properties: {},\n    }\n  }\n\n  // Array format: ['bouncy', { delay: 100, x: 'quick', enter: 'slow', exit: 'fast' }]\n  // Also supports spring config overrides: ['bouncy', { stiffness: 1000, damping: 70 }]\n  if (Array.isArray(transition)) {\n    const [defaultAnimation, configObj] = transition\n    const properties: Record<string, string | AnimationConfig> = {}\n    const springConfig: SpringConfig = {}\n    let delay: number | undefined\n    let enter: string | null = null\n    let exit: string | null = null\n\n    if (configObj && typeof configObj === 'object') {\n      for (const [key, value] of Object.entries(configObj)) {\n        if (key === 'delay' && typeof value === 'number') {\n          delay = value\n        } else if (key === 'enter' && typeof value === 'string') {\n          enter = value\n        } else if (key === 'exit' && typeof value === 'string') {\n          exit = value\n        } else if (isSpringConfigKey(key) && value !== undefined) {\n          // Spring config override: { stiffness: 1000, damping: 70 }\n          springConfig[key] = value as SpringConfig[keyof SpringConfig]\n        } else if (value !== undefined) {\n          // Property-specific animation: string or config object\n          properties[key] = value as string | AnimationConfig\n        }\n      }\n    }\n\n    return {\n      default: defaultAnimation,\n      enter,\n      exit,\n      delay,\n      properties,\n      config: Object.keys(springConfig).length > 0 ? springConfig : undefined,\n    }\n  }\n\n  // Object format: { x: 'quick', y: 'bouncy', default: 'slow', enter: 'bouncy', exit: 'quick' }\n  // Also supports spring config overrides: { default: 'bouncy', stiffness: 1000 }\n  if (typeof transition === 'object') {\n    const properties: Record<string, string | AnimationConfig> = {}\n    const springConfig: SpringConfig = {}\n    let defaultAnimation: string | null = null\n    let enter: string | null = null\n    let exit: string | null = null\n    let delay: number | undefined\n\n    for (const [key, value] of Object.entries(transition)) {\n      if (key === 'default' && typeof value === 'string') {\n        defaultAnimation = value\n      } else if (key === 'enter' && typeof value === 'string') {\n        enter = value\n      } else if (key === 'exit' && typeof value === 'string') {\n        exit = value\n      } else if (key === 'delay' && typeof value === 'number') {\n        delay = value\n      } else if (isSpringConfigKey(key) && value !== undefined) {\n        // Spring config override: { stiffness: 1000, damping: 70 }\n        springConfig[key] = value as SpringConfig[keyof SpringConfig]\n      } else if (value !== undefined) {\n        // Property-specific animation: string or config object\n        properties[key] = value as string | AnimationConfig\n      }\n    }\n\n    return {\n      default: defaultAnimation,\n      enter,\n      exit,\n      delay,\n      properties,\n      config: Object.keys(springConfig).length > 0 ? springConfig : undefined,\n    }\n  }\n\n  // Fallback\n  return {\n    default: null,\n    enter: null,\n    exit: null,\n    delay: undefined,\n    properties: {},\n  }\n}\n\n/**\n * Gets the animation key for a specific property from a normalized transition.\n * Falls back to the default animation if no property-specific one is defined.\n *\n * @param normalized - The normalized transition object\n * @param property - The property name to get animation for (e.g., 'x', 'opacity')\n * @returns The animation key/config or null if none defined\n */\nexport function getAnimationForProperty(\n  normalized: NormalizedTransition,\n  property: string\n): string | AnimationConfig | null {\n  // Check for property-specific animation\n  const propertyAnimation = normalized.properties[property]\n  if (propertyAnimation !== undefined) {\n    return propertyAnimation\n  }\n\n  // Fall back to default\n  return normalized.default\n}\n\n/**\n * Checks if the normalized transition has any animations defined.\n */\nexport function hasAnimation(normalized: NormalizedTransition): boolean {\n  return (\n    normalized.default !== null ||\n    normalized.enter !== null ||\n    normalized.exit !== null ||\n    Object.keys(normalized.properties).length > 0\n  )\n}\n\n/**\n * Gets all property names that have specific animations defined.\n * Does not include 'default' in the list.\n */\nexport function getAnimatedProperties(normalized: NormalizedTransition): string[] {\n  return Object.keys(normalized.properties)\n}\n\n/**\n * Gets the effective animation key based on the current animation state.\n * Priority: enter/exit specific > default > null\n *\n * @param normalized - The normalized transition object\n * @param state - The animation state: 'enter', 'exit', or 'default'\n * @returns The effective animation key or null\n */\nexport function getEffectiveAnimation(\n  normalized: NormalizedTransition,\n  state: 'enter' | 'exit' | 'default'\n): string | null {\n  if (state === 'enter' && normalized.enter) {\n    return normalized.enter\n  }\n  if (state === 'exit' && normalized.exit) {\n    return normalized.exit\n  }\n  return normalized.default\n}\n\n/**\n * Gets the resolved animation config for each key, looking up in animations config.\n * Useful for calculating max duration across all animated properties.\n *\n * @param normalized - The normalized transition object\n * @param animations - The animations config object (driver-specific format)\n * @param keys - Property keys to get animations for\n * @param defaultAnimation - The default animation value to fall back to\n * @returns Map of key -> resolved animation config (or null if not found)\n */\nexport function getAnimationConfigsForKeys<T>(\n  normalized: NormalizedTransition,\n  animations: Record<string, T>,\n  keys: string[],\n  defaultAnimation: T | null\n): Map<string, T | null> {\n  const result = new Map<string, T | null>()\n\n  for (const key of keys) {\n    const propAnimation = normalized.properties[key]\n    let animationValue: T | null = null\n\n    if (typeof propAnimation === 'string') {\n      animationValue = animations[propAnimation] ?? null\n    } else if (\n      propAnimation &&\n      typeof propAnimation === 'object' &&\n      (propAnimation as any).type\n    ) {\n      animationValue = animations[(propAnimation as any).type] ?? null\n    }\n\n    // fall back to default if no per-property config found\n    if (animationValue === null) {\n      animationValue = defaultAnimation\n    }\n\n    result.set(key, animationValue)\n  }\n\n  return result\n}\n"
  ]
}