((Metro, $) => { // biome-ignore lint/suspicious/noRedundantUseStrict: "use strict"; let RatingDefaultConfig = { ratingDeferred: 0, label: "", static: false, title: null, value: 0, values: null, message: "", stars: 5, onColor: null, offColor: null, roundFunc: "round", // ceil, floor, round half: true, symbol: "★", clsRating: "", clsTitle: "", clsStars: "", clsResult: "", clsLabel: "", onStarClick: Metro.noop, onRatingCreate: Metro.noop, }; Metro.ratingSetup = (options) => { RatingDefaultConfig = $.extend({}, RatingDefaultConfig, options); }; if (typeof globalThis.metroRatingSetup !== "undefined") { Metro.ratingSetup(globalThis.metroRatingSetup); } Metro.Component("rating", { init: function (options, elem) { this._super(elem, options, RatingDefaultConfig, { value: 0, originValue: 0, values: [], rate: 0, rating: null, }); return this; }, _create: function () { const element = this.element; const elem = this.elem; const o = this.options; let i; if (isNaN(elem.value)) { o.value = 0; } else { o.value = Number.parseFloat(elem.value).toFixed(1); } if (isNaN(o.value)) { o.value = 0; } else { o.value = Number.parseFloat(o.value).toFixed(1); } if (o.values !== null) { if (Array.isArray(o.values)) { this.values = o.values; } else if (typeof o.values === "string") { this.values = o.values.toArray(","); } else { throw new Error("Invalid values format. Expected array or comma-separated string."); } } else { for (i = 1; i <= o.stars; i++) { this.values.push(i); } } this.originValue = o.value || elem.value; this.value = o.value > 0 && o.roundFunc !== "none" ? Math[o.roundFunc](o.value) : Math.abs(o.value); this._createRating(); this._createEvents(); this._fireEvent("rating-create", { element: element, }); }, _createRating: function () { const element = this.element; const o = this.options; let i; let stars; let li; const value = o.static ? Math.floor(this.originValue) : this.value; const rating = element.wrap("
").addClass(`rating ${element[0].className}`).addClass(o.clsRating); const id = Hooks.useId(rating[0]); element.val(this.value); rating.attr("id", id); stars = $("