"use strict";var t,e=(t=require("jquery"))&&"object"==typeof t&&"default"in t?t.default:t;function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function a(t){for(var e=1;e=e&&t<=r))throw Error("Invalid Rating, expected value between "+e+" and "+r);return t}function h(t,e){return n(t)===e}function g(t){return void 0!==t}var m=function(t){return h(t,"function")},v=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i;function y(t){if(!v.test(t))return null;var e=v.exec(t);return{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}}function b(t,e,r){var n=r/100*(e-t);return 1===(n=Math.round(t+n).toString(16)).length&&(n="0"+n),n}function w(t,e,r){if(!t||!e)return null;r=g(r)?r:0,t=y(t),e=y(e);var n=b(t.r,e.r,r),o=b(t.b,e.b,r);return"#"+n+b(t.g,e.g,r)+o}var k={};function x(t){return k[t]||(k[t]=new String(t))}var S=new WeakMap;function O(t,e,r){r=x(r);var n=S.get(t);n||S.set(t,n=new WeakMap);var o=n.get(r);o||n.set(r,o=new Map);var i=o.get(e);if(i)return i;function a(r){var n=r.detail;e.call(t,r,n)}return o.set(e,a),a}O.get=function(t,e,r){r=x(r);var n=S.get(t);if(!n)return e;var o=n.get(r);return o&&o.get(e)||e};var j=m(window.Event)?window.Event:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.bubbles,n=void 0!==r&&r,o=e.cancelable,i=void 0!==o&&o,a=document.createEvent("Event");return a.initEvent(t,n,i),a},E=m(window.CustomEvent)?window.CustomEvent:(E.prototype=Object.create(j.prototype),E),C={trigger:function(t,e){var r={bubbles:!0};return g(e)?this.node.dispatchEvent(new E(t,a({detail:e},r))):this.node.dispatchEvent(new j(t,r)),this},on:function(t,e){return this.node.addEventListener(t,O(this.node,e,t)),this},off:function(t,e){return this.node.removeEventListener(t,O.get(this.node,e,t)),this}},F=/^rateyo(.+)$/;function P(t,e,r){var n=t.className.trim(),o=n&&n.split(/\s/)||[],i={};if(o=o.reduce((function(t,e,r){return i.hasOwnProperty(e)||(t.push(e),i[e]=r),t}),[]),e===P.add){if(i.hasOwnProperty(r))return;o.push(r)}else if(e===P.remove){if(!i.hasOwnProperty(r))return;o.splice(i[r],1)}t.className=o.join(" ")}function q(t){this.node=t}function A(t){var e=this;this.collection=[],Array.prototype.forEach.call(t,(function(t){e.collection.push(new q(t))}))}P.add="add",P.remove="remove",q.prototype={empty:function(){return this.node.innerHTML="",this},addClass:function(t){return P(this.node,P.add,t),this},removeClass:function(t){return P(this.node,P.remove,t),this},appendTo:function(t){return(q.isEl(t)?t.node:t).appendChild(this.node),this},css:function(t,e){return this.node.style[t]=e,this},width:function(t){if(!g(t))return this.node.getBoundingClientRect().width;this.css("width",t+(h(t,"number")?"px":""))},find:function(t){return V(this.node.querySelectorAll(t))},attr:function(t){for(var e in t)t.hasOwnProperty(e)&&this.node.setAttribute(e,t[e]);return this},removeAttr:function(t){return this.node.removeAttribute(t),this},children:function(){return V(this.node.childNodes)},remove:function(){return this.node.remove()},offset:function(){var t=this.node.getBoundingClientRect();return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}},dataAttrOptions:function(){var t=this.node.dataset;return Object.keys(t).reduce((function(e,r){var n=r.match(F);if(!n)return e;var o=n[1];return e[o[0].toLowerCase()+o.slice(1)]=t[r],e}),{})}},q.prototype=a(a({},q.prototype),C),q.isEl=function(t){return t instanceof q},A.isCollection=function(t){return t instanceof A},A.prototype={};var z=function(t){if(!q.prototype.hasOwnProperty(t))return"continue";A.prototype[t]=function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if(!(this instanceof T))return new T(t,e);if(W.has(t))return W.get(t);var r=this;this.node=t;var n=V(t);e=a(a(a({},u),e),n.dataAttrOptions()),n.empty().addClass("jq-ry-container");var o,i,h,m,v,y,b=V(document.createElement("div")).addClass("jq-ry-group-wrapper").appendTo(n),k=V(document.createElement("div")).addClass("jq-ry-normal-group").addClass("jq-ry-group").appendTo(b),x=V(document.createElement("div")).addClass("jq-ry-rated-group").addClass("jq-ry-group").appendTo(b),S=0,O=e.rating,j=!1;function E(t){g(t)||(t=e.rating),O=t;var r=t/o,n=r*h;r>1&&(n+=(Math.ceil(r)-1)*v),z(e.ratedFill),(n=e.rtl?100-n:n)<0?n=0:n>100&&(n=100),x.css("width",n+"%")}function C(){y=i*e.numStars+m*(e.numStars-1),h=i/y*100,v=m/y*100,n.width(y),E()}function F(t){var r=e.starWidth=t;return i=window.parseFloat(e.starWidth.replace("px","")),k.find("svg").attr({width:e.starWidth,height:r}),x.find("svg").attr({width:e.starWidth,height:r}),C(),n}function P(t){return e.spacing=t,m=parseFloat(e.spacing.replace("px","")),k.find("svg:not(:first-child)").css("margin-left",t),x.find("svg:not(:first-child)").css("margin-left",t),C(),n}function q(t){return e.normalFill=t,(e.rtl?x:k).find("svg").attr({fill:e.normalFill}),n}var A=e.ratedFill;function z(t){if(e.multiColor){var r=(O-S)/e.maxValue*100,o=e.multiColor||{};t=w(o.startColor||c,o.endColor||l,r)}else A=t;return e.ratedFill=t,(e.rtl?k:x).find("svg").attr({fill:e.ratedFill}),n}function I(t){t=!!t,e.rtl=t,q(e.normalFill),E()}function M(t){e.multiColor=t,z(t||A)}function N(t){e.numStars=t,o=e.maxValue/e.numStars,k.empty(),x.empty();for(var r=0;rt&&X(t),E(),n}function L(t){return e.precision=t,X(e.rating),n}function $(t){return e.halfStar=t,n}function _(t){return e.fullStar=t,n}function B(t){var r=t%o,n=o/2,i=e.halfStar,a=e.fullStar;return a||i?(a||i&&r>n?t+=o-r:(t-=r,r>0&&(t+=n)),t):t}function R(t){var r=k.offset().left,n=r+k.width(),i=e.maxValue,a=t.pageX,s=0;if(an)s=i;else{var u=(a-r)/(n-r);if(m>0)for(var c=u*=100;c>0;)c>h?(s+=o,c-=h+v):(s+=c/h*o,c=0);else s=u*e.maxValue;s=B(s)}return e.rtl&&(s=i-s),parseFloat(s)}function H(t){return e.readOnly=t,n.attr({readonly:!0}),nt(),t||(n.removeAttr("readonly"),rt()),n}function X(t){var r=t,o=e.maxValue;return"string"==typeof r&&("%"===r[r.length-1]&&(r=r.substr(0,r.length-1),D(o=100)),r=parseFloat(r)),d(r,S,o),r=parseFloat(r.toFixed(e.precision)),p(parseFloat(r),S,o),e.rating=r,E(),j&&n.trigger("rateyo.set",{rating:r}),n}function Y(t){return e.onInit=t,n}function G(t){return e.onSet=t,n}function J(t){return e.onChange=t,n}function K(t){if(e.hover){var r=R(t).toFixed(e.precision),o=e.maxValue;E(r=p(parseFloat(r),S,o)),n.trigger("rateyo.change",{rating:r})}}function Q(){!f()&&e.hover&&(E(),n.trigger("rateyo.change",{rating:e.rating}))}function U(t){var n=R(t).toFixed(e.precision);n=parseFloat(n),r.rating(n)}function Z(t,n){e.onInit&&"function"==typeof e.onInit&&e.onInit.apply(this,[n.rating,r])}function tt(t,n){e.onChange&&"function"==typeof e.onChange&&e.onChange.apply(this,[n.rating,r])}function et(t,n){e.onSet&&"function"==typeof e.onSet&&e.onSet.apply(this,[n.rating,r])}function rt(){n.on("mousemove",K).on("mouseenter",K).on("mouseleave",Q).on("click",U).on("rateyo.init",Z).on("rateyo.change",tt).on("rateyo.set",et)}function nt(){n.off("mousemove",K).off("mouseenter",K).off("mouseleave",Q).off("click",U).off("rateyo.init",Z).off("rateyo.change",tt).off("rateyo.set",et)}this.rating=function(t){return g(t)?(X(t),n):e.rating},this.destroy=function(){return e.readOnly||nt(),W.delete(t),n.removeClass("jq-ry-container").children().remove(),n},this.method=function(t){if(!t)throw Error("Method name not specified!");if(!g(this[t]))throw Error("Method "+t+" doesn't exist!");var e=Array.prototype.slice.apply(arguments,[]),r=e.slice(1),n=this[t];return n.apply(this,r)},this.option=function(t,r){if(!g(t))return e;var n;switch(t){case"starWidth":n=F;break;case"numStars":n=N;break;case"normalFill":n=q;break;case"ratedFill":n=z;break;case"multiColor":n=M;break;case"maxValue":n=D;break;case"precision":n=L;break;case"rating":n=X;break;case"halfStar":n=$;break;case"fullStar":n=_;break;case"readOnly":n=H;break;case"spacing":n=P;break;case"rtl":n=I;break;case"onInit":n=Y;break;case"onSet":n=G;break;case"onChange":n=J;break;default:throw Error("No such option as "+t)}return g(r)?n(r):e[t]},N(e.numStars),H(e.readOnly),e.rtl&&I(e.rtl),W.set(t,this),this.rating(e.rating,!0),j=!0,n.trigger("rateyo.init",{rating:e.rating})}Object.defineProperty(T.prototype,"on",{value:function(t,e){return V(this.node).on(t,e),this}}),Object.defineProperty(T.prototype,"off",{value:function(t,e){return V(this.node).off(t,e),this}}),Object.defineProperty(T,"has",{value:function(t){return W.has(t)}}),Object.defineProperty(T,"get",{value:function(t){return W.get(t)}}),Object.defineProperty(T,"_$",{get:function(){return V}});var N=T._$,D=N.El.prototype.trigger;function L(t){var n=e(this);if(0===n.length)return n;var o=Array.prototype.slice.apply(arguments,[]);if(0===o.length)t=o[0]={};else{if(1!==o.length||"object"!==r(o[0])){if(o.length>=1&&"string"==typeof o[0]){var i=o[0],a=o.slice(1),s=[];return e.each(n,(function(t,e){var r=T.get(e);if(!r)throw Error("Trying to set options before even initialization");var n=r[i];if(!n)throw Error("Method "+i+" does not exist!");var o=n.apply(r,a);s.push(o)})),s=1===s.length?s[0]:s}throw Error("Invalid Arguments")}t=o[0]}return e.each(n,(function(){return new T(this,e.extend({},t))}))}N.El.prototype.trigger=function(){for(var t,r=arguments.length,n=new Array(r),o=0;o