var __awaiter=this&&this.__awaiter||function(t,e,a,n){function i(t){return t instanceof a?t:new a((function(e){e(t)}))}return new(a||(a=Promise))((function(a,r){function o(t){try{c(n.next(t))}catch(t){r(t)}}function s(t){try{c(n["throw"](t))}catch(t){r(t)}}function c(t){t.done?a(t.value):i(t.value).then(o,s)}c((n=n.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var a={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,i,r,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(t){return function(e){return c([t,e])}}function c(o){if(n)throw new TypeError("Generator is already executing.");while(a)try{if(n=1,i&&(r=o[0]&2?i["return"]:o[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;if(i=0,r)o=[o[0]&2,r.value];switch(o[0]){case 0:case 1:r=o;break;case 4:a.label++;return{value:o[1],done:false};case 5:a.label++;i=o[1];o=[0];continue;case 7:o=a.ops.pop();a.trys.pop();continue;default:if(!(r=a.trys,r=r.length>0&&r[r.length-1])&&(o[0]===6||o[0]===2)){a=0;continue}if(o[0]===3&&(!r||o[1]>r[0]&&o[1]=e;var i=t.average&&!t.value&&e<=t.average;var r=e<=t.hoverValue;var o=t.average&&t.average+1-e;var s=!t.value&&!r&&o>0&&o<1;var c=t.hasFocus&&t.focusValue===e;return n("span",{class:{wrapper:true}},n("label",{class:{star:true,focused:c,selected:a,average:i,hovered:r,partial:s},htmlFor:"".concat(t.guid,"-").concat(e),onMouseOver:function(){t.hoverValue=e}},n("calcite-icon",{"aria-hidden":"true",class:"icon",icon:a||i||t.readOnly?"star-f":"star",scale:t.scale}),s&&n("div",{class:"fraction",style:{width:"".concat(o*100,"%")}},n("calcite-icon",{icon:"star-f",scale:t.scale})),n("span",{class:"visually-hidden"},t.intlStars.replace("${num}","".concat(e)))),n("input",{checked:e===t.value,class:"visually-hidden",disabled:t.disabled||t.readOnly,id:"".concat(t.guid,"-").concat(e),name:t.guid,onChange:function(){return t.updateValue(e)},onClick:function(t){return t.stopPropagation()},onFocus:function(){t.hasFocus=true;t.focusValue=e},ref:function(a){return(e===1||e===t.value)&&(t.inputFocusRef=a)},type:"radio",value:e}))}))};t.prototype.render=function(){var t=this;var e=this,a=e.disabled,r=e.intlRating,o=e.showChip,s=e.scale,c=e.count,l=e.average;return n(i,null,n("fieldset",{class:"fieldset",disabled:a,onBlur:function(){return t.hoverValue=null},onMouseLeave:function(){return t.hoverValue=null},onTouchEnd:function(){return t.hoverValue=null}},n("legend",{class:"visually-hidden"},r),this.renderStars()),(c||l)&&o?n("calcite-chip",{scale:s,value:c===null||c===void 0?void 0:c.toString()},!!l&&n("span",{class:"number--average"},l.toString()),!!c&&n("span",{class:"number--count"},"(",c===null||c===void 0?void 0:c.toString(),")")):null,n(p,{component:this}))};t.prototype.onLabelClick=function(){this.setFocus()};t.prototype.updateValue=function(t){this.value=t;this.calciteRatingChange.emit({value:t})};t.prototype.setFocus=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.inputFocusRef.focus();return[2]}))}))};Object.defineProperty(t.prototype,"el",{get:function(){return r(this)},enumerable:false,configurable:true});return t}());h.style=d}}}));