(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/aha"],{1090:(e,t,s)=>{"use strict";s.r(t);var n=s(143);class i extends n.Popup{_initConfiguration(e){this.setLocale(n.Locale.getSection("components.aha")),super._initConfiguration({id:"aha-dialog",title:this.lmsg("voteTitle"),closeButtonEnabled:!0,hideOnEscape:!0,content:'<div class="form-box form--vertical"><div class="box-area"><div class="content"><div class="content-area"><div class="nps-survey">'+'<p class="nps-survey__question">'.concat(this.lmsg("voteQuestion"),"</p>")+'<div class="nps-survey__container"><div id="aha-rating" class="nps-survey__scores"></div><div class="nps-survey__legend">'+'<div class="nps-survey__legend-left">'.concat(this.lmsg("voteLegendBad"),"</div>")+'<div class="nps-survey__legend-right">'.concat(this.lmsg("voteLegendGood"),"</div>")+'</div></div></div><hr/><div class="form-row">'+'<div class="field-name">'.concat(this.lmsg("voteGoodHint"),"</div>")+'<div class="field-value"><textarea id="aha-good" class="f-max-size" maxlength="1000"></textarea></div></div><div class="form-row">'+'<div class="field-name">'.concat(this.lmsg("voteBetterHint"),"</div>")+'<div class="field-value"><textarea id="aha-better" class="f-max-size" maxlength="1000"></textarea></div></div></div></div></div></div>',buttons:[{title:this.lmsg("voteButtonOk"),id:"aha-vote-button-ok",class:"action",handler:this.handleVoteButton.bind(this)},{title:n.Locale.getSection("components.buttons").lmsg("cancel"),id:"aha-vote-button-cancel",handler(e,t){t.hide()}}],...e})}_initComponentElement(){super._initComponentElement(),(0,n.render)(this._componentElement.querySelector("#aha-rating"),[0,1,2,3,4,5,6,7,8,9,10].map((e=>(0,n.createElement)("label",{class:"nps-survey__score nps-survey__score--".concat(e),onclick:this.checkPossibleSendVote.bind(this)},[(0,n.createElement)("input",{type:"radio",name:"nps-survey-option",value:e}),(0,n.createElement)("span",{class:"nps-survey__score-label"})]))))}hide(){super.hide(),this.voted||(this.checkPossibleSendVote()||this.getFeedbackGood()||this.getFeedbackBetter()?this.sendVote():this.sendHide())}handleVoteButton(){this.checkPossibleSendVote()&&(this.voted=!0,this.sendVote(),this.hide(),new a)}checkPossibleSendVote(){const e=this._componentElement.querySelector(".nps-survey"),t=this.getRate();if(t){e.classList.remove("error");const t=e.querySelector(".field-errors");t&&t.parentNode.removeChild(t)}else{e.classList.add("error");e.querySelector(".field-errors")||(0,n.render)(e,'<span class="field-errors">'+'<span class="error-hint">'.concat(this.lmsg("voteRequire"),"</span>")+"</span>")}return t}sendVote(){n.api.post((0,n.prepareUrl)("/admin/aha/vote"),{voted:this.voted||!1,rate:this.getRate(),feedbackGood:this.getFeedbackGood(),feedbackBetter:this.getFeedbackBetter(),dialogAtPage:window.location.pathname})}sendHide(){n.api.post((0,n.prepareUrl)("/admin/aha/hide"))}getRate(){const e=this._componentElement.querySelector("#".concat(this.getId(),"-form input[name=nps-survey-option]:checked"));return e?e.value:""}getFeedbackGood(){return this._componentElement.querySelector("#aha-good").value.trim()}getFeedbackBetter(){return this._componentElement.querySelector("#aha-better").value.trim()}}class a extends n.Popup{_initConfiguration(e){this.setLocale(n.Locale.getSection("components.aha"));const t=[{title:this.lmsg("thankButtonClose"),class:"action",handler(e,t){t.hide()}}],s="<p>".concat(this.lmsg("thankHint"),"</p>");super._initConfiguration({id:"thank-dialog",title:this.lmsg("thankTitle"),closeButtonEnabled:!0,hideOnEscape:!0,content:s,buttons:t,...e})}}t.default=e=>new i(e)}}]);
//# sourceMappingURL=aha.js.map?865ba5bc1edcfaf07b3b