// #region Imports
var __decorate = (this && this.__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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { CssLength } from '@breadstone/mosaik-themes';
import { Disableable } from '../../../Behaviors/Disableable';
import { Labelable } from '../../../Behaviors/Labelable';
import { Orientable } from '../../../Behaviors/Orientable';
import { Themeable } from '../../../Behaviors/Themeable';
import { Variantable } from '../../../Behaviors/Variantable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Watch } from '../../../Decorators/WatchDecorator';
import { MeterRange } from '../../../Types/MeterRange';
import { MeterScale } from '../../../Types/MeterScale';
import { RangeBaseElement } from '../Abstracts/RangeBaseElement';
import { meterRingElementTemplate } from './MeterRingElementTemplate';
import { meterRingElementCosmopolitanStyle } from './Themes/MeterRingElement.Cosmopolitan';
import { meterRingElementJoyStyle } from './Themes/MeterRingElement.Joy';
import { meterRingElementMemphisStyle } from './Themes/MeterRingElement.Memphis';
/**
 * MeterRing - A circular gauge for displaying numeric measurements within defined ranges.
 *
 * @description
 * The MeterRing component provides elegant circular visualization of measurements with contextual
 * coloring based on optimum, low, and high thresholds. Supports both continuous ring fill and
 * segmented arc display modes, making it ideal for dashboards, KPIs, performance metrics, and
 * status indicators where radial presentation adds visual impact. Features smooth animations,
 * SVG-based rendering for crisp scaling, and comprehensive accessibility support.
 *
 * @name MeterRing
 * @element mosaik-meter-ring
 * @category Ranges
 *
 * @slot hint - Secondary text content area for additional meter information or status
 * @slot label - Text label content area for meter description or value display
 *
 * @csspart bar - Background ring/circle element for the meter track
 * @csspart fill - Filled arc/circle indicating current value in continuous mode
 * @csspart hint - Hint text styling container for additional information
 * @csspart label - Text label styling container for meter information
 * @csspart marker - Circle marker indicator showing current value position in segmented mode
 * @csspart root - Root SVG container for the meter ring component
 * @csspart segment - Individual arc segment representing a specific range (low/optimum/high) in segmented mode
 *
 * @cssprop {String} --meter-ring-background-color - Background color for the meter ring container
 * @cssprop {String} --meter-ring-border-color - Border color for the meter ring
 * @cssprop {String} --meter-ring-border-radius - Border radius for the container styling
 * @cssprop {String} --meter-ring-border-style - Border style for the meter ring
 * @cssprop {String} --meter-ring-border-width - Border width for the meter ring
 * @cssprop {String} --meter-ring-fill-color - Fill color for the meter indicator in continuous mode
 * @cssprop {String} --meter-ring-fill-color-high - Fill color for high range segment (above high threshold)
 * @cssprop {String} --meter-ring-fill-color-low - Fill color for low range segment (below low threshold)
 * @cssprop {String} --meter-ring-fill-color-normal - Fill color for normal range segment
 * @cssprop {String} --meter-ring-fill-color-optimum - Fill color for optimum range segment (between low and high)
 * @cssprop {String} --meter-ring-font-family - Font family for meter text labels
 * @cssprop {String} --meter-ring-font-letter-spacing - Letter spacing for meter text
 * @cssprop {String} --meter-ring-font-line-height - Line height for meter text
 * @cssprop {String} --meter-ring-font-size - Font size for meter text
 * @cssprop {String} --meter-ring-font-text-decoration - Text decoration style for meter text
 * @cssprop {String} --meter-ring-font-text-transform - Text transformation style for meter text
 * @cssprop {String} --meter-ring-font-weight - Font weight for meter text
 * @cssprop {String} --meter-ring-foreground-color - Foreground color for meter text and icons
 * @cssprop {String} --meter-ring-gap - Spacing between ring and label elements
 * @cssprop {String} --meter-ring-marker-color - Color for the marker indicator in segmented mode
 * @cssprop {String} --meter-ring-padding-bottom - Bottom padding for the meter ring container
 * @cssprop {String} --meter-ring-padding-left - Left padding for the meter ring container
 * @cssprop {String} --meter-ring-padding-right - Right padding for the meter ring container
 * @cssprop {String} --meter-ring-padding-top - Top padding for the meter ring container
 * @cssprop {String} --meter-ring-radius - Radius of the circular meter ring
 * @cssprop {String} --meter-ring-shadow - Drop shadow or elevation effect for the meter ring
 * @cssprop {String} --meter-ring-shadow-blur - The ring shadow blur CSS custom property.
 * @cssprop {String} --meter-ring-shadow-color - The ring shadow color CSS custom property.
 * @cssprop {String} --meter-ring-shadow-offset-x - The ring shadow offset x CSS custom property.
 * @cssprop {String} --meter-ring-shadow-offset-y - The ring shadow offset y CSS custom property.
 * @cssprop {String} --meter-ring-shadow-spread - The ring shadow spread CSS custom property.
 * @cssprop {String} --meter-ring-thickness - Stroke thickness of the meter ring arc
 * @cssprop {String} --meter-ring-transition-duration - Animation duration for value changes
 * @cssprop {String} --meter-ring-transition-mode - Animation easing mode for transitions
 * @cssprop {String} --meter-ring-transition-property - CSS properties to animate during transitions
 * @cssprop {String} --meter-ring-translate - Transform translation for positioning
 *
 * @fires rangeValueChanged {RangeValueChangedEvent} - Fired when the meter value changes
 *
 * @dependency mosaik-text - The Text element.
 *
 * @example
 * Basic circular meter with continuous fill:
 * ```html
 * <mosaik-meter-ring
 *   min="0"
 *   max="100"
 *   value="65"
 *   low="30"
 *   high="80"
 *   optimum="50">
 *   <span slot="label">Performance Score</span>
 * </mosaik-meter-ring>
 * ```
 *
 * @example
 * Segmented meter ring for system health monitoring:
 * ```html
 * <mosaik-meter-ring
 *   min="0"
 *   max="100"
 *   value="42"
 *   low="25"
 *   high="75"
 *   optimum="50"
 *   scale="segmented"
 *   radius="80"
 *   thickness="8"
 *   variant="warning">
 *   <span slot="label">System Health</span>
 *   <span slot="hint">42% Capacity</span>
 * </mosaik-meter-ring>
 * ```
 *
 * @example
 * Dashboard KPI gauge:
 * ```html
 * <div class="kpi-grid">
 *   <mosaik-meter-ring
 *     min="0"
 *     max="100"
 *     value="92"
 *     low="40"
 *     high="90"
 *     optimum="70"
 *     radius="60"
 *     thickness="10">
 *     <span slot="label">Conversion Rate</span>
 *     <span slot="hint">92%</span>
 *   </mosaik-meter-ring>
 * </div>
 * ```
 *
 * @example
 * Memory usage indicator:
 * ```html
 * <mosaik-meter-ring
 *   min="0"
 *   max="16"
 *   value="12"
 *   low="4"
 *   high="14"
 *   optimum="8"
 *   radius="50"
 *   thickness="6"
 *   variant="error">
 *   <span slot="label">RAM</span>
 *   <span slot="hint">12 GB / 16 GB</span>
 * </mosaik-meter-ring>
 * ```
 *
 * @public
 */
let MeterRingElement = class MeterRingElement extends Themeable(Variantable(Orientable(Disableable(Labelable(RangeBaseElement))))) {
    // #region Fields
    _thickness;
    _radius;
    _high;
    _low;
    _optimum;
    _percent;
    _range;
    _scale;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._thickness = 4;
        this._radius = 16;
        this._high = 0;
        this._low = 0;
        this._optimum = 0;
        this._percent = 0;
        this._range = MeterRange.Normal;
        this._scale = MeterScale.Continuous;
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-meter-ring';
    }
    /**
     * Gets or sets the thickness property.
     *
     * @public
     * @attr
     */
    get thickness() {
        return this._thickness;
    }
    set thickness(value) {
        if (this._thickness !== value) {
            this._thickness = value;
            this.requestUpdate('thickness');
        }
    }
    /**
     * @public
     * @attr
     */
    get radius() {
        return this._radius;
    }
    set radius(value) {
        if (this._radius !== value) {
            this._radius = value;
            this.requestUpdate('radius');
        }
    }
    /**
     * Gets or sets the `high` property.
     *
     * @public
     * @attr
     */
    get high() {
        return this._high;
    }
    set high(value) {
        if (this._high !== value) {
            this._high = value;
            this.requestUpdate('high');
        }
    }
    /**
     * Gets or sets the `low` property.
     *
     * @public
     * @attr
     */
    get low() {
        return this._low;
    }
    set low(value) {
        if (this._low !== value) {
            this._low = value;
            this.requestUpdate('low');
        }
    }
    /**
     * Gets or sets the `optimum` property.
     *
     * @public
     * @attr
     */
    get optimum() {
        return this._optimum;
    }
    set optimum(value) {
        if (this._optimum !== value) {
            this._optimum = value;
            this.requestUpdate('optimum');
        }
    }
    /**
     * @private
     * @readonly
     */
    get percent() {
        return this._percent;
    }
    /**
     * @private
     * @hidden
     * @readonly
     */
    get diameter() {
        const cssRadius = CssLength.isLength(this._radius) ? CssLength.extractValue(this._radius) : this._radius;
        return cssRadius * 2;
    }
    /**
     * Gets or sets the `range` property.
     *
     * @public
     * @readonly
     * @attr
     */
    get range() {
        return this._range;
    }
    set range(value) {
        if (this._range !== value) {
            this._range = value;
            this.requestUpdate('range');
        }
    }
    /**
     * Gets or sets the `scale` property.
     * Determines how the meter scale is visually represented.
     * - `continuous`: Single continuous ring with color based on current range (default).
     * - `segmented`: Visible arc segments for low, optimum, and high zones with a marker for the current value.
     *
     * @public
     * @attr
     */
    get scale() {
        return this._scale;
    }
    set scale(value) {
        if (this._scale !== value) {
            this._scale = value;
            this.requestUpdate('scale');
        }
    }
    /**
     * Gets the segments for the segmented scale mode.
     * Returns an array of arc segments representing low, optimum, and high zones.
     *
     * @public
     * @readonly
     */
    get segments() {
        const totalRange = this.max - this.min;
        if (totalRange <= 0) {
            return [];
        }
        const segments = [];
        let currentAngle = 0;
        // Low segment: min to low
        const lowAngle = ((this.low - this.min) / totalRange) * 360;
        if (lowAngle > 0) {
            segments.push({
                range: MeterRange.Low,
                angle: lowAngle,
                startAngle: currentAngle
            });
            currentAngle += lowAngle;
        }
        // Optimum segment: low to high
        const optimumAngle = ((this.high - this.low) / totalRange) * 360;
        if (optimumAngle > 0) {
            segments.push({
                range: MeterRange.Optimum,
                angle: optimumAngle,
                startAngle: currentAngle
            });
            currentAngle += optimumAngle;
        }
        // High segment: high to max
        const highAngle = ((this.max - this.high) / totalRange) * 360;
        if (highAngle > 0) {
            segments.push({
                range: MeterRange.High,
                angle: highAngle,
                startAngle: currentAngle
            });
        }
        return segments;
    }
    /**
     * Gets the effective radius for SVG calculations.
     *
     * @public
     * @readonly
     */
    get effectiveRadius() {
        const cssRadius = CssLength.isLength(this._radius) ? CssLength.extractValue(this._radius) : this._radius;
        return cssRadius - (this._thickness / 2);
    }
    /**
     * Gets the position of the marker on the ring based on the current value.
     *
     * @private
     * @readonly
     */
    get markerPosition() {
        const cssRadius = CssLength.isLength(this._radius) ? CssLength.extractValue(this._radius) : this._radius;
        const angle = (((this.percent / 100) * 360) - 90) * (Math.PI / 180);
        const effectiveRadius = this.effectiveRadius;
        return {
            x: cssRadius + (effectiveRadius * Math.cos(angle)),
            y: cssRadius + (effectiveRadius * Math.sin(angle))
        };
    }
    // #endregion
    // #region Methods
    /**
     * Generates an SVG arc path for a segment.
     *
     * @param startAngle - The start angle in degrees.
     * @param sweepAngle - The sweep angle in degrees.
     * @param radius - The radius of the arc.
     * @param cx - The center x coordinate.
     * @param cy - The center y coordinate.
     * @returns The SVG path d attribute string.
     *
     * @private
     */
    getArcPath(startAngle, sweepAngle, radius, cx, cy) {
        // Convert angles to radians (subtract 90 to start from top)
        const startRad = ((startAngle - 90) * Math.PI) / 180;
        const endRad = ((startAngle + sweepAngle - 90) * Math.PI) / 180;
        const x1 = cx + (radius * Math.cos(startRad));
        const y1 = cy + (radius * Math.sin(startRad));
        const x2 = cx + (radius * Math.cos(endRad));
        const y2 = cy + (radius * Math.sin(endRad));
        const largeArcFlag = sweepAngle > 180 ? 1 : 0;
        return `M ${x1} ${y1} A ${radius} ${radius} 0 ${largeArcFlag} 1 ${x2} ${y2}`;
    }
    /**
     * @protected
     * @override
     */
    onRangeValueChanged(prev, next) {
        super.onRangeValueChanged(prev, next);
        this._percent = this.max <= this.min
            ? 0
            : ((this.value - this.min) / (this.max - this.min)) * 100;
    }
    onPropertyChanged() {
        let range = MeterRange.Normal;
        if (this.value < this.low) {
            range = MeterRange.Low;
        }
        else if (this.value >= this.high) {
            range = MeterRange.High;
        }
        else if (this.value >= this.optimum) {
            range = MeterRange.Optimum;
        }
        this.range = range;
    }
};
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], MeterRingElement.prototype, "thickness", null);
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], MeterRingElement.prototype, "radius", null);
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], MeterRingElement.prototype, "high", null);
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], MeterRingElement.prototype, "low", null);
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], MeterRingElement.prototype, "optimum", null);
__decorate([
    Attribute({ type: MeterRange }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], MeterRingElement.prototype, "range", null);
__decorate([
    Attribute({ type: MeterScale }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], MeterRingElement.prototype, "scale", null);
__decorate([
    Watch('value'),
    Watch('min'),
    Watch('max'),
    Watch('low'),
    Watch('high'),
    Watch('optimum'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], MeterRingElement.prototype, "onPropertyChanged", null);
MeterRingElement = __decorate([
    Component({
        selector: 'mosaik-meter-ring',
        template: meterRingElementTemplate,
        themes: {
            joy: meterRingElementJoyStyle,
            memphis: meterRingElementMemphisStyle,
            cosmopolitan: meterRingElementCosmopolitanStyle
        },
        imports: []
    }),
    __metadata("design:paramtypes", [])
], MeterRingElement);
export { MeterRingElement };
//# sourceMappingURL=MeterRingElement.js.map