{"version":3,"file":"ngwr-gradient-text.mjs","sources":["../../../projects/lib/gradient-text/gradient-text.ts","../../../projects/lib/gradient-text/gradient-text.html","../../../projects/lib/gradient-text/ngwr-gradient-text.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n *\n * Angular adaptation of the GradientText effect by David Haz / reactbits.dev.\n * Original: https://www.reactbits.dev/text-animations/gradient-text\n *\n * The reactbits version uses `motion/react` to drive `background-position`\n * via rAF. This port is pure CSS — same effect via keyframes on\n * `background-position`, parameterised by inputs.\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, computed, input } from '@angular/core';\n\nimport { numAttr } from 'ngwr/utils';\n\nimport type { WrGradientTextDirection } from './interfaces';\n\nconst DEFAULT_COLORS: readonly string[] = ['#5227FF', '#FF9FFC', '#B497CF'];\n\n/**\n * Animated multi-stop gradient text. The gradient slides across the text\n * via `background-clip: text`. Optional `[showBorder]` wraps the text in\n * a dark pill with the same animated gradient as a border ring.\n *\n * @example\n * ```html\n * <wr-gradient-text>Hello, ngwr!</wr-gradient-text>\n * <wr-gradient-text\n *   [colors]=\"['#5227FF', '#FF9FFC', '#B497CF']\"\n *   direction=\"diagonal\"\n *   [animationSpeed]=\"6\"\n *   [showBorder]=\"true\"\n * >\n *   Premium feature\n * </wr-gradient-text>\n * ```\n *\n * @see https://www.reactbits.dev/text-animations/gradient-text\n */\n@Component({\n  selector: 'wr-gradient-text',\n  templateUrl: './gradient-text.html',\n  styleUrl: './gradient-text.scss',\n  encapsulation: ViewEncapsulation.None,\n  host: {\n    class: 'wr-gradient-text',\n    '[class.wr-gradient-text--border]': 'showBorder()',\n    '[class.wr-gradient-text--pause-on-hover]': 'pauseOnHover()',\n    '[class.wr-gradient-text--yoyo]': 'yoyo()',\n    '[class.wr-gradient-text--vertical]': \"direction() === 'vertical'\",\n    '[class.wr-gradient-text--diagonal]': \"direction() === 'diagonal'\",\n    '[style.--wr-gradient-text-image]': 'gradient()',\n    '[style.--wr-gradient-text-size]': 'size()',\n    '[style.--wr-gradient-text-duration]': \"animationSpeed() + 's'\",\n  },\n})\nexport class WrGradientText {\n  /** Gradient stops. @default ['#5227FF', '#FF9FFC', '#B497CF'] */\n  readonly colors = input<readonly string[]>(DEFAULT_COLORS);\n\n  /** Seconds per full sweep (or per half if `[yoyo]` is on). @default 8 */\n  readonly animationSpeed = input(8, { transform: numAttr(8) });\n\n  /** Wrap the text in a dark pill with the gradient as a border. @default false */\n  readonly showBorder = input(false, { transform: coerceBooleanProperty });\n\n  /** Gradient slide direction. @default 'horizontal' */\n  readonly direction = input<WrGradientTextDirection>('horizontal');\n\n  /** Pause the animation while hovered. @default false */\n  readonly pauseOnHover = input(false, { transform: coerceBooleanProperty });\n\n  /** Bounce back-and-forth instead of restarting. @default true */\n  readonly yoyo = input(true, { transform: coerceBooleanProperty });\n\n  protected readonly gradient = computed(() => {\n    const cols = this.colors().length > 0 ? this.colors() : DEFAULT_COLORS;\n    // Duplicate the first colour at the end for seamless looping.\n    const stops = [...cols, cols[0]].join(', ');\n    const angle = this.directionAngle();\n    return `linear-gradient(${angle}, ${stops})`;\n  });\n\n  protected readonly size = computed(() => {\n    switch (this.direction()) {\n      case 'vertical':\n        return '100% 300%';\n      case 'diagonal':\n        return '300% 300%';\n      case 'horizontal':\n      default:\n        return '300% 100%';\n    }\n  });\n\n  private directionAngle(): string {\n    switch (this.direction()) {\n      case 'vertical':\n        return 'to bottom';\n      case 'diagonal':\n        return 'to bottom right';\n      case 'horizontal':\n      default:\n        return 'to right';\n    }\n  }\n}\n\nexport type { WrGradientTextDirection } from './interfaces';\n","@if (showBorder()) {\n  <span class=\"wr-gradient-text__border\" aria-hidden=\"true\"></span>\n}\n<span class=\"wr-gradient-text__text\">\n  <ng-content />\n</span>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";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