{"version":3,"file":"index.cjs","names":[],"sources":["../../src/withDefaultProps/index.ts"],"sourcesContent":["/**\n * Merges props with defaults while preserving explicitly provided values.\n *\n * @typeParam TProps - Resulting props type.\n * @param props - Source props.\n * @param defaults - Defaults applied when a prop is `undefined`.\n * @returns A new object containing props with missing values filled from defaults.\n *\n * @example\n * ```tsx\n * const props = withDefaultProps(\n *   { tone: undefined },\n *   { tone: 'neutral', size: 'md' },\n * );\n * ```\n */\nexport function withDefaultProps<TProps extends {} = {}>(\n  props: Partial<TProps>,\n  defaults: Partial<TProps>,\n): TProps {\n  const withDefaults = Object.entries(defaults).reduce((acc, [prop, value]) => ({\n    ...acc,\n    [prop]: (props as Record<string, any>)[prop] !== undefined\n      ? (props as Record<string, any>)[prop]\n      : value,\n  }), {} as TProps);\n\n  return { ...props, ...withDefaults } as TProps;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,SAAgB,iBACd,OACA,UACQ;CACR,MAAM,eAAe,OAAO,QAAQ,QAAQ,CAAC,CAAC,QAAQ,KAAK,CAAC,MAAM,YAAY;EAC5E,GAAG;GACF,OAAQ,MAA8B,UAAU,KAAA,IAC5C,MAA8B,QAC/B;CACN,IAAI,CAAC,CAAW;CAEhB,OAAO;EAAE,GAAG;EAAO,GAAG;CAAa;AACrC"}