{"version":3,"file":"odx-angular-components-circular-progress.mjs","sources":["../../../../libs/angular/components/circular-progress/src/lib/models/circular-progress-size.ts","../../../../libs/angular/components/circular-progress/src/lib/circular-progress.component.ts","../../../../libs/angular/components/circular-progress/src/lib/circular-progress.component.html","../../../../libs/angular/components/circular-progress/src/odx-angular-components-circular-progress.ts"],"sourcesContent":["export type CircularProgressSize = typeof CircularProgressSize[keyof typeof CircularProgressSize];\n\nexport const CircularProgressSize = {\n  AUTO: 'auto',\n  SMALL: 'small',\n  MEDIUM: 'medium',\n  LARGE: 'large',\n} as const;\n","import {\n  AfterViewInit,\n  ChangeDetectionStrategy,\n  ChangeDetectorRef,\n  Component,\n  inject,\n  Input,\n  numberAttribute,\n  OnChanges,\n  ViewEncapsulation,\n} from '@angular/core';\nimport { CSSComponent, CSSModifier } from '@odx/angular/internal';\nimport { fromElementResize$ } from '@odx/angular/rxjs';\nimport { hasChanged, injectElement, NgChanges, untilDestroyed } from '@odx/angular/utils';\nimport { CircularProgressSize } from './models/circular-progress-size';\n\n/**\n * Represents a circular progress component.\n * This component displays a circular progress indicator that can be used to show the progress of an operation.\n */\n@CSSComponent('circular-progress')\n@Component({\n  standalone: true,\n  selector: 'odx-circular-progress',\n  templateUrl: './circular-progress.component.html',\n  changeDetection: ChangeDetectionStrategy.OnPush,\n  encapsulation: ViewEncapsulation.None,\n  host: {\n    '[attr.aria-valuenow]': 'ariaValueNow',\n    '[attr.aria-valuemax]': '100',\n    '[attr.aria-valuemin]': '0',\n    '[attr.role]': '\"meter\"',\n  },\n})\nexport class CircularProgressComponent implements OnChanges, AfterViewInit {\n  private readonly changeDetector = inject(ChangeDetectorRef);\n  private readonly takeUntilDestroyed = untilDestroyed();\n  private _value = 0;\n\n  protected readonly viewPortSize = 100;\n  protected radius = 0;\n  protected normalizedStroke = 0;\n  protected circumference = 283;\n\n  protected get ariaValueNow(): null | number {\n    return this.indeterminate ? null : this.value;\n  }\n\n  protected get progressValue(): number {\n    return this.indeterminate ? this.circumference : Math.floor((1 - this.value / 100) * this.circumference);\n  }\n\n  public readonly element = injectElement();\n\n  /**\n   * Specifies whether the circular progress is in indeterminate mode.\n   * In indeterminate mode, the progress indicator continuously animates without a specific value.\n   *\n   * @type {boolean}\n   * @default false\n   */\n  @CSSModifier()\n  public indeterminate = false;\n\n  /**\n   * The width of the stroke for the circular progress component.\n   *\n   * @type {number}\n   * @default 4\n   */\n  @Input({ transform: numberAttribute })\n  public stroke = 4;\n\n  /**\n   * The size of the circular progress component.\n   *\n   * @type {CircularProgressSize}\n   * @default CircularProgressSize.MEDIUM\n   */\n  @CSSModifier()\n  @Input()\n  public size: CircularProgressSize = CircularProgressSize.MEDIUM;\n\n  /**\n   * Sets and gets the value of the circular progress component.\n   *\n   * @param {number} value - The value to set. Must be between -1 and 100 (inclusive).\n   */\n  @Input({ transform: numberAttribute })\n  public set value(value: number) {\n    if (value <= 100 && value >= -1) {\n      this._value = value;\n      this.indeterminate = value === -1;\n    }\n  }\n\n  /**\n   * Gets the value of the circular progress.\n   *\n   * @returns {number} The current value of the circular progress.\n   */\n  public get value(): number {\n    return this._value;\n  }\n\n  public ngAfterViewInit(): void {\n    fromElementResize$(this.element.nativeElement)\n      .pipe(this.takeUntilDestroyed())\n      .subscribe(() => this.updateDimensions());\n  }\n\n  public ngOnChanges(changes: NgChanges<CircularProgressComponent>): void {\n    if (hasChanged(changes, ['stroke', 'size'])) {\n      this.updateDimensions();\n    }\n  }\n\n  private updateDimensions(): void {\n    if (this.stroke < 0) return;\n    const normalizeFactor = this.viewPortSize / (this.element.nativeElement.offsetWidth || 1);\n\n    this.normalizedStroke = normalizeFactor * this.stroke;\n    if (normalizeFactor >= 3) {\n      this.normalizedStroke = Math.max(0, this.normalizedStroke - normalizeFactor);\n    }\n    this.radius = Math.max(0, this.viewPortSize / 2 - this.normalizedStroke / 2);\n    this.circumference = Math.floor(2 * this.radius * Math.PI);\n    this.changeDetector.detectChanges();\n  }\n}\n","<svg class=\"odx-circular-progress__inner\" attr.viewBox=\"0 0 {{ viewPortSize }} {{ viewPortSize }}\">\n  <circle class=\"odx-circular-progress__track\" [attr.stroke-width]=\"normalizedStroke\" [attr.r]=\"radius\" cx=\"50%\" cy=\"50%\" />\n  <circle\n    class=\"odx-circular-progress__indicator\"\n    [attr.stroke-dasharray]=\"circumference\"\n    [attr.stroke-dashoffset]=\"progressValue\"\n    [attr.stroke-width]=\"normalizedStroke\"\n    [attr.r]=\"radius\"\n    cx=\"50%\"\n    cy=\"50%\"\n  />\n</svg>\n<ng-content />\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,oBAAoB,GAAG;AAClC,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,KAAK,EAAE,OAAO;;;ACUhB;;;AAGG;AAeI,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB,CAAA;AAA/B,IAAA,WAAA,GAAA;AACY,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC;QAC1C,IAAA,CAAA,kBAAkB,GAAG,cAAc,EAAE;QAC9C,IAAA,CAAA,MAAM,GAAG,CAAC;QAEC,IAAA,CAAA,YAAY,GAAG,GAAG;QAC3B,IAAA,CAAA,MAAM,GAAG,CAAC;QACV,IAAA,CAAA,gBAAgB,GAAG,CAAC;QACpB,IAAA,CAAA,aAAa,GAAG,GAAG;QAUb,IAAA,CAAA,OAAO,GAAG,aAAa,EAAE;AAEzC;;;;;;AAMG;QAEI,IAAA,CAAA,aAAa,GAAG,KAAK;AAE5B;;;;;AAKG;QAEI,IAAA,CAAA,MAAM,GAAG,CAAC;AAEjB;;;;;AAKG;AAGI,QAAA,IAAA,CAAA,IAAI,GAAyB,oBAAoB,CAAC,MAAM;AAgDhE,IAAA;AArFC,IAAA,IAAc,YAAY,GAAA;AACxB,QAAA,OAAO,IAAI,CAAC,aAAa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