"use strict";(self.webpackChunkLHCReactAPP=self.webpackChunkLHCReactAPP||[]).push([[595],{5595:function(t,e,n){n.r(e);var a,s=n(8168),i=n(3029),r=n(2901),c=n(6822),u=n(3954),o=n(5361),l=n(4467),d=n(6540),b=n(1225),p=n(5580),v=(n(7912),n(900)),h=n(6524);function f(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(f=function(){return!!t})()}var m=(0,b.Ng)((function(t){return{chatwidget:t.chatwidget}}))(a=function(t){function e(t){var n,a,s,r;return(0,i.A)(this,e),a=this,s=e,r=[t],s=(0,u.A)(s),n=(0,c.A)(a,f()?Reflect.construct(s,r||[],(0,u.A)(a).constructor):s.apply(a,r)),(0,l.A)(n,"state",{currentQuestion:1,is_valid:null,collectedData:{},collectedQuestion:[]}),n}return(0,o.A)(e,t),(0,r.A)(e,[{key:"abstractClick",value:function(t,e,n){var a=this.state.collectedData,s=this.state.collectedQuestion,i=!1;"plain"==t["data-inline"]?""!=n.target.value&&(i=!0,a[t.name]=n.target.value):(i=!0,a[t.name]=t.value),!0===i&&-1===s.indexOf(e.seq)?s.push(e.seq):!1===i&&-1!==s.indexOf(e.seq)&&s.splice(s.indexOf(e.seq),1),this.setState({collectedData:a,collectedQuestion:s})}},{key:"submitSurvey",value:function(){var t=this;this.state.collectedData.survey_id=this.props.survey_id,this.state.collectedData.chat_id=this.props.chatwidget.getIn(["chatData","id"]),this.state.collectedData.hash=this.props.chatwidget.getIn(["chatData","hash"]),(0,p.sw)(this.state.collectedData).then((function(e){var n={is_valid:e.data.is_valid};n.feedback_text=e.data.result,t.setState(n)}))}},{key:"render",value:function(){var t=this,e=this.props.t,n=1,a=0;return(0,v.zd)(this.props.surveyOptions,{replace:function(t){t.attribs&&"voteoption"===t.name&&a++}}),d.createElement("div",null,!1===this.state.is_valid&&(0,v.Ay)(this.state.feedback_text,{replace:function(e){if(e.attribs&&e.name&&"button"===e.name)return d.createElement("button",(0,s.A)({type:"button"},e.attribs,{onClick:function(e){return t.setState({is_valid:null})}}))}}),!0===this.state.is_valid&&d.createElement("div",null,(0,v.Ay)(this.state.feedback_text)),!0!==this.state.is_valid&&(0,v.zd)(this.props.surveyOptions,{replace:function(i){if(i.attribs&&"voteoption"===i.name){var r=t.state.currentQuestion!=n?"d-none":"";n++;var c=1==i.attribs["is-required"]&&-1===t.state.collectedQuestion.indexOf(i.attribs.seq),u="d-block pt-3"+(1==a?" text-center":""),o="btn btn-outline-secondary btn-sm"+(a>1?" float-end":"")+" btn-survey-submit";return d.createElement("div",(0,s.A)({},i.attribs,{className:r}),(0,v.zd)(i.children,{replace:function(e){if(e.attribs){if(e.name&&"input"===e.name&&e.attribs.type&&"radio"==e.attribs.type){var n=Object.assign({},e.attribs);return d.createElement("input",(0,s.A)({type:"radio"},e.attribs,{onChange:function(e){return t.abstractClick(n,i.attribs,e)}}))}if(e.name&&"textarea"===e.name)return n=Object.assign({},e.attribs),d.createElement("textarea",(0,s.A)({style:{height:"55px"}},e.attribs,{onChange:function(e){return t.abstractClick(n,i.attribs,e)}}))}}}),d.createElement("div",{className:u},t.state.currentQuestion>1&&d.createElement("input",{type:"button",className:"btn btn-outline-secondary btn-sm btn-survey-prev",onClick:function(e){return t.setState({currentQuestion:t.state.currentQuestion-1})},value:e("button.back"),name:"Prev"}),a>t.state.currentQuestion&&d.createElement("input",{disabled:c,type:"button",className:"btn btn-outline-secondary btn-sm float-end btn-survey-next",onClick:function(e){return t.setState({currentQuestion:t.state.currentQuestion+1})},value:e("button.next"),name:"Next"}),a==t.state.currentQuestion&&d.createElement("input",{disabled:c,type:"button",className:o,onClick:function(e){return t.submitSurvey()},value:e("button.submit"),name:"Submit"})))}}}))}}])}(d.Component))||a;e.default=(0,h.C)()(m)}}]);
//# sourceMappingURL=595.833a645b16b67091a9d1.js.map