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