(function(){const b=new VueJsAsyncComponentTemplateRepository(webContext+"/survey/jsp/js/vuejs/components/silverpeas-survey-result-chart-templates.jsp");let count=0;const d=function(){return count++};const a={props:{answerPercent:{type:Object,required:true},anonymous:{type:Boolean,required:true,"default":true}}};const c={props:{answer:{type:Object,required:true},anonymous:{type:Boolean,required:true,"default":true}}};window.SurveyResultChart={mountQuestionAnswerResult:function(e){e=extendsObject({id:undefined,title:undefined,view:"pie",answerPercents:undefined,anonymous:true},e);whenSilverpeasReady(function(){const g=document.querySelector("#"+e.id);const f=document.createElement("silverpeas-survey-question-answer-result-chart");f.setAttribute("v-bind:view","view");f.setAttribute("v-bind:title","title");f.setAttribute("v-bind:answer-percents","answerPercents");f.setAttribute("v-bind:anonymous","anonymous");g.appendChild(f);SpVue.createApp({data:function(){return{title:e.title,view:e.view,answerPercents:e.answerPercents,anonymous:e.anonymous}}}).mount(g)})}};SpVue.component("silverpeas-survey-question-answer-result-chart",b.get("question-answer-result-chart",{props:{title:{type:String,required:true},view:{type:String,required:true},answerPercents:{type:Array,required:true},anonymous:{type:Boolean,required:true,"default":true}},computed:{pieView:function(){return SurveyResultChartSettings.get("c.p")===this.view}}}));SpVue.component("survey-pie-chart",b.get("pie-chart",{mixins:[VuejsI18nTemplateMixin],props:{answerPercents:{type:Array,required:true},anonymous:{type:Boolean,required:true,"default":true}},data:function(){return{chartDomIdContainer:"chartDomId-"+d(),chartDomId:"chartDomId-"+d(),chartApi:undefined}},mounted:function(){const e={chartSelector:"#"+this.chartDomId,isDisplayAsBars:this.isDisplayAsBars,chart:this.chartData,formatToolTipTitle:function(f,g){return g.srcData.answerPercent.answer.label},formatToolTipValue:function(f){return f+" %"},formatTickValue:function(f){return f<=100?f+" %":""},onItemClickHelp:function(f){if(!this.anonymous&&f.srcData.answerPercent.percent>0){return this.messages.seeVoterClickHelp}}.bind(this),onItemClick:function(f){if(e.onItemClickHelp(f)){viewUsers(f.srcData.answerPercent.answer.id)}}};this.chartApi=new ChartManager(e)},methods:{getLegendColor:function(f){const e=this.chartApi.getColorSet();return e[f%e.length]}},computed:{chartDomId:function(){return"chartDomId-"+d()},chartDomIdContainer:function(){return this.chartDomId+"-container"},chartData:function(){return{chartType:"pie",combine:false,items:this.answerPercents.map(function(f,e){return{answerPercent:f,label:'<div id="'+this.chartDomId+"-label-"+e+'"></div>',value:f.percent}}.bind(this))}},isDisplayAsBars:function(){return this.chartData.items.map(function(e){return e.value}).reduce(function(f,e){return f+e})>100.01}}}));SpVue.component("survey-horizontal-bar-chart-line",b.get("horizontal-bar-chart-line",{mixins:[a],methods:{viewUsers:function(){viewUsers(this.answerPercent.answer.id)}},computed:{percent:function(){return this.answerPercent.percent},percentAsInt:function(){return Math.floor(this.answerPercent.percent)}}}));SpVue.component("survey-chart-answer-label",b.get("chart-answer-label",{mixins:[c],props:{color:{type:String,"default":undefined},percent:{type:Number,"default":undefined}},methods:{viewSuggestions:function(){viewSuggestions(this.answer.questionId)}}}))})();