import { r as registerInstance, h, H as Host, g as getElement } from './index-090d31ca.js';
import { c as MapToComponentField, M as MapToComponentMethod, V as VegaSlimmer, I as InjectVegaSlimmer } from './global-slimmer-registry-17c4efd4.js';
import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-46020a03.js';
import { I as InternalVegaZIndexManager } from './internal-vega-z-index-manager-7d2b54c3.js';
import { s as sanitizeVegaComponent } from './component-7d906393.js';
import { a as arrayToClassString } from './ui-64815a12.js';
import { R as ResponsiveFormatFacade } from './responsive-format-facade-3ec5c161.js';
import { g as getCurrentBreakpoint } from './breakpoints-332702ed.js';
import { P as PageResizeObserverSlimmer } from './page-resize-observer-slimmer-e24d36c5.js';
import './number-4398f2e1.js';
import './type-guard-ed1004cc.js';
import './breakpoints-d9faf11c.js';
import './ui-93922c59.js';
import './typography-396de03f.js';
import './internal-translation-controller-d8217d93.js';
import './change-manager-6a7eb88c.js';
import './static-subject-title-52f93124.js';
import './pixel-f32c07ce.js';
import './array-7888f339.js';
import './feature-flag-controller-30f7b625.js';
import './index-bfc6dfa2.js';
import './try-get-document-bef0f526.js';

var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/** The ManageVegaLoaderWrapperZIndex class manages z-index of the vega-loader-wrapper. */
class ManageVegaLoaderWrapperZIndexController extends VegaSlimmer {
  /**
   * When vega loader wrapper is connected
   */
  connectedCallback() {
    this.setIndex();
  }
  /**
   * When vega loader wrapper is disconnected
   */
  disconnectedCallback() {
    this.removeIndex();
  }
  /**
   * Sets the z-index level for the vega-loader-wrapper based on the target container.
   */
  setIndex() {
    // eslint-disable-next-line no-restricted-globals
    const containerElement = document.querySelector(this.host.dataset.container);
    if (containerElement) {
      if (containerElement.tagName === 'BODY') {
        InternalVegaZIndexManager.setZIndex(this.host, 'base');
      }
    }
  }
  /**
   * Removes the z-index of the vega-loader-wrapper by resetting it.
   */
  removeIndex() {
    InternalVegaZIndexManager.removeZIndex(this.host, 'base');
  }
}
__decorate$2([
  MapToComponentField()
], ManageVegaLoaderWrapperZIndexController.prototype, "host", void 0);
__decorate$2([
  MapToComponentMethod('connectedCallback')
], ManageVegaLoaderWrapperZIndexController.prototype, "connectedCallback", null);
__decorate$2([
  MapToComponentMethod('disconnectedCallback')
], ManageVegaLoaderWrapperZIndexController.prototype, "disconnectedCallback", null);

const vegaLoaderWrapperCss = ":host{display:block;display:inline-flex;align-items:center;justify-content:center;top:0px;right:0px;bottom:0px;left:0px;background-color:rgba(var(--v-bg-backdrop-loading, 255, 255, 255, 0.5))}:host(.absolute-wrapper){position:absolute}:host(.fixed-wrapper){width:100%;height:100%;position:fixed}";

var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
    r = Reflect.decorate(decorators, target, key, desc);
  else
    for (var i = decorators.length - 1; i >= 0; i--)
      if (d = decorators[i])
        r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const VegaLoaderWrapper = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.globalSlimmers = {};
    this.manageVegaLoaderWrapperZIndexController = new ManageVegaLoaderWrapperZIndexController();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
  }
  render() {
    return (h(Host, { class: "vega-loader-wrapper" }, h("slot", null)));
  }
  get host() { return getElement(this); }
};
__decorate$1([
  InjectVegaGlobalSlimmer()
], VegaLoaderWrapper.prototype, "globalSlimmers", void 0);
__decorate$1([
  InjectVegaSlimmer()
], VegaLoaderWrapper.prototype, "manageVegaLoaderWrapperZIndexController", void 0);
__decorate$1([
  InjectVegaSlimmer()
], VegaLoaderWrapper.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaLoaderWrapper.style = vegaLoaderWrapperCss;

const VegaLoadingIndicatorRuntimeMetricsPayloadDefinition = [
  {
    payloadKey: 'MODE_IS_INDETERMINATE',
    payloadDescription: 'Specifies the mode of the loading indicator',
    /**
     * The function checks if the `mode` property of the `host` element is equal to 'indeterminate'.
     * If it is, the function will return `true`.
     *
     * @param {HTMLElement} host - The element to check
     * @returns {boolean} A boolean value
     */
    payloadValue: (host) => host.mode === 'indeterminate',
  },
  {
    payloadKey: 'MODE_IS_DETERMINATE',
    payloadDescription: 'Specifies the mode of the loading indicator',
    /**
     * The function checks if the `mode` property of the `host` element is equal to 'determinate'.
     * If it is, the function will return `true`.
     *
     * @param {HTMLElement} host - The element to check
     * @returns {boolean} A boolean value
     */
    payloadValue: (host) => host.mode === 'determinate',
  },
];

const vegaLoadingIndicatorCss = ":host{display:inline-block}:host(.vega-loading-indicator-bar){width:100%}:host(.vega-loading-indicator-indeterminate) .circle-loader{animation:circle-loader-animation 2000ms linear infinite;transform:rotate(-90deg)}:host(.vega-loading-indicator-determinate) .circle-loader{transform:rotate(-180deg)}:host(.vega-loading-indicator-default) .circle-loader{width:48px;height:48px}:host(.vega-loading-indicator-micro) .circle-loader{width:16px;height:16px}:host(.vega-loading-indicator-small) .circle-loader{width:24px;height:24px}:host(.vega-loading-indicator-large) .circle-loader{width:120px;height:120px}:host .circle-loader-track{stroke:rgba(var(--v-bg-loading-track, 229, 239, 255, 1));fill:none;cy:50%;cx:50%}:host .circle-loader-progress-pointer.v-hidden{display:none}:host .circle-loader-progress-pointer,:host .circle-loader-progress{stroke:rgba(var(--v-bg-loading-progress, 153, 192, 255, 1));fill:none;cy:50%;cx:50%}:host(.vega-loading-indicator-status-success) .circle-loader-progress-pointer,:host(.vega-loading-indicator-status-success) .circle-loader-progress{stroke:rgba(var(--v-bg-status-success, 160, 233, 167, 1))}:host(.vega-loading-indicator-status-error) .circle-loader-progress-pointer,:host(.vega-loading-indicator-status-error) .circle-loader-progress{stroke:rgba(var(--v-bg-status-error, 255, 110, 139, 1))}:host(.vega-loading-indicator-default) .circle-loader-progress-pointer,:host(.vega-loading-indicator-default) .circle-loader-track,:host(.vega-loading-indicator-default) .circle-loader-progress{stroke-width:8px}:host .circle-loader-progress-pointer{stroke-linecap:round}:host(.vega-loading-indicator-micro) .circle-loader-progress-pointer,:host(.vega-loading-indicator-micro) .circle-loader-track,:host(.vega-loading-indicator-micro) .circle-loader-progress{stroke-width:3px}:host(.vega-loading-indicator-small) .circle-loader-progress-pointer,:host(.vega-loading-indicator-small) .circle-loader-track,:host(.vega-loading-indicator-small) .circle-loader-progress{stroke-width:4px}:host(.vega-loading-indicator-large) .circle-loader-progress-pointer,:host(.vega-loading-indicator-large) .circle-loader-track,:host(.vega-loading-indicator-large) .circle-loader-progress{stroke-width:16px}@keyframes circle-loader-animation{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}:host .bar-loader{border-radius:9999px;position:absolute;box-sizing:border-box;height:8px;background-color:rgba(var(--v-bg-loading-progress, 153, 192, 255, 1));content:\"\";width:75%;top:0;left:0}:host(.vega-loading-indicator-status-success) .bar-loader{background-color:rgba(var(--v-bg-status-success, 160, 233, 167, 1))}:host(.vega-loading-indicator-status-error) .bar-loader{background-color:rgba(var(--v-bg-status-error, 255, 110, 139, 1))}:host(.vega-loading-indicator-micro) .bar-loader,:host(.vega-loading-indicator-micro) .bar-loader-track{height:3px}:host(.vega-loading-indicator-small) .bar-loader,:host(.vega-loading-indicator-small) .bar-loader-track{height:4px}:host(.vega-loading-indicator-large) .bar-loader,:host(.vega-loading-indicator-large) .bar-loader-track{height:16px}:host(.vega-loading-indicator-indeterminate) .bar-loader{animation:bar-loader-animation 1250ms cubic-bezier(0.75, 0, 0.5, 1) infinite;animation-delay:50ms}@keyframes bar-loader-animation{0%{left:0;transform:translateX(-100%)}100%{left:100%;transform:translateX(0%)}}:host .bar-loader-track{display:inline-block;border-radius:9999px;position:relative;overflow:hidden;height:8px;width:100%;background-color:rgba(var(--v-bg-loading-track, 229, 239, 255, 1))}:host .vega-loading-indicator-label{font-family:\"Inter\", sans-serif;font-size:18px;font-weight:700;line-height:25px;letter-spacing:0px;color:rgba(var(--v-text-primary, 32, 54, 69, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-loading-indicator-label{font-family:\"Inter\", sans-serif;font-size:18px;font-weight:700;line-height:25px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-loading-indicator-label{font-family:\"Inter\", sans-serif;font-size:18px;font-weight:700;line-height:25px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-loading-indicator-label{font-family:\"Inter\", sans-serif;font-size:18px;font-weight:700;line-height:25px;letter-spacing:0px}}:host .vega-loading-indicator-hint{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px;color:rgba(var(--v-text-secondary, 107, 116, 125, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-loading-indicator-hint{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-loading-indicator-hint{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-loading-indicator-hint{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}";

var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
    r = Reflect.decorate(decorators, target, key, desc);
  else
    for (var i = decorators.length - 1; i >= 0; i--)
      if (d = decorators[i])
        r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const VegaLoadingIndicator = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.globalSlimmers = {};
    /**
     * The below method is e2e-test covered in
     * @see{module:vega-loading-indicator-resize-e2e}
     */
    this.pageResizeObserverSlimmer = new PageResizeObserverSlimmer();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer(VegaLoadingIndicatorRuntimeMetricsPayloadDefinition);
    this.currentBreakpoint = getCurrentBreakpoint();
    /**
     * Specifies the shape of the loading indicator.
     *
     * @vegaVersion 1.16.0
     */
    this.shape = 'circle';
    /**
     * Specifies the size of the loading indicator.
     *    It is provided as a ResponsiveType.
     *
     * @vegaVersion 1.16.0
     */
    this.size = 'default';
    /**
     * Specifies the mode of the loading indicator.
     *
     * When the mode is set to `determinate`, there will be no animation.
     *
     * @vegaVersion 1.16.0
     */
    this.mode = 'indeterminate';
    /**
     * Specifies the completion percentage when
     *    the mode is set to `determinate`.
     *
     * @vegaVersion 1.16.0
     */
    this.percent = 0;
    /**
     * Provides a descriptive text or message that indicates
     *    the status or progress of the process.
     *
     * @vegaVersion 1.16.0
     */
    this.label = '';
    /**
     * Provides a supplementary prompt message that assists users in
     *    understanding the ongoing loading process.
     *
     * @vegaVersion 1.16.0
     */
    this.hint = '';
    /**
     * Indicates the current status or state of the loading process.
     *
     * @vegaVersion 1.16.0
     */
    this.status = 'default';
    this.renderCircleLoader = () => {
      const r = this.getCircleLoaderRadius(this.getResponsiveSize());
      const percent = this.mode === 'indeterminate' ? 0.75 : this.percent / 100;
      const perimeter = Math.PI * 2 * r;
      const progress = this.status === 'error' ? perimeter : perimeter * percent;
      return (h("svg", { class: "circle-loader" }, h("circle", { r: r, class: "circle-loader-track", part: "circle-loader-track" }), h("circle", { r: r, class: "circle-loader-progress", part: "circle-loader-progress", "stroke-linecap": this.mode === 'indeterminate' ? 'round' : 'butt', "stroke-dasharray": [progress, perimeter].join(' ') }), this.mode === 'determinate' && (h("circle", { r: r, class: arrayToClassString(['circle-loader-progress-pointer', percent === 0 && 'v-hidden'].filter(Boolean)), "stroke-dashoffset": -progress, "stroke-dasharray": [0, perimeter].join(' ') }))));
    };
    this.renderBarLoader = () => {
      let progress = 75;
      if (this.mode === 'determinate') {
        if (this.status === 'error') {
          progress = 100;
        }
        else {
          progress = this.percent;
        }
      }
      return (h("div", { class: "bar-loader-track" }, h("div", { class: arrayToClassString(['bar-loader', this.getResponsiveSize()]), style: { width: `${progress}%` } })));
    };
    this.renderLabelAndHint = () => {
      if (!this.label && !this.hint)
        return;
      return (h("vega-flex", { direction: "col", gap: "size-4", alignItems: "center" }, this.label && h("span", { class: "vega-loading-indicator-label" }, this.label), this.hint && h("span", { class: "vega-loading-indicator-hint" }, this.hint)));
    };
    this.getResponsiveSize = () => {
      return ResponsiveFormatFacade.formatCustom(this.size);
    };
    /**
     * Radius = Inner Diameter + ((Outer Diameter - Inner Diameter) / 2)
     * @param {number} size The size of loading indicator
     */
    this.getCircleLoaderRadius = (size) => {
      switch (size) {
        case 'micro':
          return 6.5;
        case 'small':
          return 10;
        case 'large':
          return 52;
        default:
          return 20;
      }
    };
  }
  render() {
    const classNames = arrayToClassString([this.getResponsiveSize(), this.mode, `status-${this.status}`, this.shape].map((item) => `vega-loading-indicator-${item}`));
    return sanitizeVegaComponent(h(Host, { class: classNames }, h("vega-flex", { direction: "col", gap: "size-16", alignItems: "center" }, this.shape === 'circle' ? this.renderCircleLoader() : this.renderBarLoader(), this.renderLabelAndHint())), this.host);
  }
  get host() { return getElement(this); }
};
__decorate([
  InjectVegaGlobalSlimmer()
], VegaLoadingIndicator.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaLoadingIndicator.prototype, "pageResizeObserverSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaLoadingIndicator.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaLoadingIndicator.style = vegaLoadingIndicatorCss;

export { VegaLoaderWrapper as vega_loader_wrapper, VegaLoadingIndicator as vega_loading_indicator };
