define("discourse/plugins/poll/discourse/components/modal/poll-breakdown",["exports","@ember/component","@ember/object","@ember/service","@ember/string","@ember/template","discourse/lib/ajax","discourse/lib/ajax-error","discourse/lib/load-script","discourse-common/utils/decorators","discourse-i18n","@ember/template-factory"],(function(e,t,l,o,s,n,i,r,a,p,u,c){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const d=(0,c.createTemplateFactory)({id:"4IwSZKks",block:'[[[8,[39,0],[[24,0,"poll-breakdown has-tabs"]],[["@title","@closeModal"],[[28,[37,1],["poll.breakdown.title"],null],[30,1]]],[["headerBelowTitle","body"],[[[[1,"\\n "],[10,"ul"],[14,0,"modal-tabs"],[12],[1,"\\n "],[11,"li"],[16,0,[28,[37,5],["modal-tab percentage",[52,[28,[37,7],[[30,0,["displayMode"]],"percentage"],null],"is-active"]],null]],[4,[38,8],["click",[28,[37,9],[[28,[37,10],[[30,0,["displayMode"]]],null],"percentage"],null]],null],[12],[1,[28,[35,1],["poll.breakdown.percentage"],null]],[13],[1,"\\n "],[11,"li"],[16,0,[28,[37,5],["modal-tab count",[52,[28,[37,7],[[30,0,["displayMode"]],"count"],null],"is-active"]],null]],[4,[38,8],["click",[28,[37,9],[[28,[37,10],[[30,0,["displayMode"]]],null],"count"],null]],null],[12],[1,[28,[35,1],["poll.breakdown.count"],null]],[13],[1,"\\n "],[13],[1,"\\n "]],[]],[[[1,"\\n "],[10,0],[14,0,"poll-breakdown-sidebar"],[12],[1,"\\n "],[10,2],[14,0,"poll-breakdown-title"],[12],[1,"\\n "],[1,[30,0,["title"]]],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"poll-breakdown-total-votes"],[12],[1,[28,[35,1],["poll.breakdown.votes"],[["count"],[[30,0,["model","poll","voters"]]]]]],[13],[1,"\\n\\n "],[10,"ul"],[14,0,"poll-breakdown-options"],[12],[1,"\\n"],[42,[28,[37,15],[[28,[37,15],[[30,0,["model","poll","options"]]],null]],null],null,[[[1," "],[8,[39,16],null,[["@option","@index","@totalVotes","@optionsCount","@displayMode","@highlightedOption","@onMouseOver","@onMouseOut"],[[30,2],[30,3],[30,0,["totalVotes"]],[30,0,["model","poll","options","length"]],[30,0,["displayMode"]],[30,0,["highlightedOption"]],[28,[37,9],[[28,[37,10],[[30,0,["highlightedOption"]]],null],[30,3]],null],[28,[37,9],[[28,[37,10],[[30,0,["highlightedOption"]]],null],null],null]]],null],[1,"\\n"]],[2,3]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"poll-breakdown-body"],[12],[1,"\\n "],[10,0],[14,0,"poll-breakdown-body-header"],[12],[1,"\\n "],[10,"label"],[14,0,"poll-breakdown-body-header-label"],[12],[1,[28,[35,1],["poll.breakdown.breakdown"],null]],[13],[1,"\\n\\n "],[8,[39,18],[[24,0,"poll-breakdown-dropdown"]],[["@content","@value","@nameProperty","@onChange"],[[30,0,["groupableUserFields"]],[30,0,["groupedBy"]],"label",[30,0,["setGrouping"]]]],null],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"poll-breakdown-charts"],[12],[1,"\\n"],[42,[28,[37,15],[[28,[37,15],[[30,0,["charts"]]],null]],null],null,[[[1," "],[8,[39,19],null,[["@group","@options","@displayMode","@highlightedOption","@setHighlightedOption"],[[28,[37,20],[[30,4],"group"],null],[28,[37,20],[[30,4],"options"],null],[30,0,["displayMode"]],[30,0,["highlightedOption"]],[28,[37,9],[[28,[37,10],[[30,0,["highlightedOption"]]],null]],null]]],null],[1,"\\n"]],[4]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n "]],[]]]]]],["@closeModal","option","index","chart"],false,["d-modal","i18n",":headerBelowTitle","ul","li","concat-class","if","eq","on","fn","mut",":body","div","p","each","-track-array","poll-breakdown-option","label","combo-box","poll-breakdown-chart","get"]]',moduleName:"discourse/plugins/poll/discourse/components/modal/poll-breakdown.hbs",isStrictMode:!1})
class h extends t.default{static#e=(()=>dt7948.g(this.prototype,"dialog",[o.service]))()
#t=(()=>{dt7948.i(this,"dialog")})()
static#l=(()=>dt7948.g(this.prototype,"siteSettings",[o.service]))()
#o=(()=>{dt7948.i(this,"siteSettings")})()
model=null
charts=null
groupedBy=null
highlightedOption=null
displayMode="percentage"
init(){this.set("groupedBy",this.groupableUserFields[0]?.id),(0,a.default)("/javascripts/Chart.min.js").then((()=>(0,a.default)("/javascripts/chartjs-plugin-datalabels.min.js"))).then((()=>{this.fetchGroupedPollData()})),super.init(...arguments)}title(e,t){return e?(0,n.htmlSafe)(e):t}static#s=(()=>dt7948.n(this.prototype,"title",[(0,p.default)("model.poll.title","model.post.topic.title")]))()
get groupableUserFields(){return this.siteSettings.poll_groupable_user_fields.split("|").filter(Boolean).map((e=>{const t=e.split("_").filter(Boolean)
return t.length>1&&(t[0]=(0,s.classify)(t[0])),{id:e,label:t.join(" ")}}))}totalVotes(e){return e.reduce(((e,t)=>e+t.votes),0)}static#n=(()=>dt7948.n(this.prototype,"totalVotes",[(0,p.default)("model.poll.options")]))()
fetchGroupedPollData(){return(0,i.ajax)("/polls/grouped_poll_results.json",{data:{post_id:this.model.post.id,poll_name:this.model.poll.name,user_field_name:this.groupedBy}}).catch((e=>{e?(0,r.popupAjaxError)(e):this.dialog.alert((0,u.i18n)("poll.error_while_fetching_voters"))})).then((e=>{this.isDestroying||this.isDestroyed||this.set("charts",e.grouped_results)}))}setGrouping(e){this.set("groupedBy",e),this.fetchGroupedPollData()}static#i=(()=>dt7948.n(this.prototype,"setGrouping",[l.action]))()
onSelectPanel(e){this.set("displayMode",e.id)}static#r=(()=>dt7948.n(this.prototype,"onSelectPanel",[l.action]))()}e.default=h,(0,t.setComponentTemplate)(d,h)})),define("discourse/plugins/poll/discourse/components/modal/poll-ui-builder",["exports","@ember/component","@ember/object","@ember/object/computed","@ember/service","@ember-decorators/object","discourse-common/utils/decorators","discourse-i18n","@ember/template-factory"],(function(e,t,l,o,s,n,i,r,a){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.REGULAR_POLL_TYPE=e.RANKED_CHOICE_POLL_TYPE=e.PIE_CHART_TYPE=e.NUMBER_POLL_TYPE=e.MULTIPLE_POLL_TYPE=e.BAR_CHART_TYPE=void 0
const p=(0,a.createTemplateFactory)({id:"p9DIkco5",block:'[[[8,[39,0],[[24,0,"poll-ui-builder"]],[["@title","@closeModal","@inline"],[[28,[37,1],["poll.ui_builder.title"],null],[30,1],[30,2]]],[["body","footer"],[[[[1,"\\n "],[10,"ul"],[14,0,"nav nav-pills poll-type"],[12],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[8,[39,5],[[16,0,[28,[37,6],["poll-type-value poll-type-value-regular",[52,[30,0,["isRegular"]],"active"]],null]]],[["@action"],[[28,[37,8],[[30,0,["updatePollType"]],"regular"],null]]],[["default"],[[[[1,"\\n "],[1,[28,[35,1],["poll.ui_builder.poll_type.regular"],null]],[1,"\\n "]],[]]]]],[1,"\\n "],[13],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[8,[39,5],[[16,0,[28,[37,6],["poll-type-value poll-type-value-multiple",[52,[30,0,["isMultiple"]],"active"]],null]]],[["@action"],[[28,[37,8],[[30,0,["updatePollType"]],"multiple"],null]]],[["default"],[[[[1,"\\n "],[1,[28,[35,1],["poll.ui_builder.poll_type.multiple"],null]],[1,"\\n "]],[]]]]],[1,"\\n "],[13],[1,"\\n"],[41,[30,0,["showNumber"]],[[[1," "],[10,"li"],[12],[1,"\\n "],[8,[39,5],[[16,0,[28,[37,6],["poll-type-value poll-type-value-number",[52,[30,0,["isNumber"]],"active"]],null]]],[["@action"],[[28,[37,8],[[30,0,["updatePollType"]],"number"],null]]],[["default"],[[[[1,"\\n "],[1,[28,[35,1],["poll.ui_builder.poll_type.number"],null]],[1,"\\n "]],[]]]]],[1,"\\n "],[13],[1,"\\n"]],[]],null],[41,[30,0,["showRankedChoice"]],[[[1," "],[10,"li"],[12],[1,"\\n "],[8,[39,5],[[16,0,[28,[37,6],["poll-type-value poll-type-value-ranked-choice",[52,[30,0,["isRankedChoice"]],"active"]],null]]],[["@action"],[[28,[37,8],[[30,0,["updatePollType"]],"ranked_choice"],null]]],[["default"],[[[[1,"\\n "],[1,[28,[35,1],["poll.ui_builder.poll_type.ranked_choice"],null]],[1,"\\n "]],[]]]]],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n"],[41,[30,0,["showAdvanced"]],[[[1," "],[10,0],[14,0,"input-group poll-title"],[12],[1,"\\n "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_title.label"],null]],[13],[1,"\\n "],[8,[39,11],null,[["@value"],[[30,0,["pollTitle"]]]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[51,[30,0,["isNumber"]]],[[[1," "],[10,0],[14,0,"poll-options"],[12],[1,"\\n"],[41,[30,0,["showAdvanced"]],[[[1," "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_options.label"],null]],[13],[1,"\\n "],[8,[39,13],[[4,[38,14],["input",[30,0,["onOptionsTextChange"]]],null]],[["@value"],[[30,0,["pollOptionsText"]]]],null],[1,""],[41,[30,0,["showMinNumOfOptionsValidation"]],[[[41,[51,[30,0,["minNumOfOptionsValidation","ok"]]],[[[1," "],[8,[39,15],null,[["@validation"],[[30,0,["minNumOfOptionsValidation"]]]],null],[1,"\\n"]],[]],null]],[]],null]],[]],[[[42,[28,[37,17],[[28,[37,17],[[30,0,["pollOptions"]]],null]],null],null,[[[1," "],[10,0],[14,0,"input-group poll-option-value"],[12],[1,"\\n "],[11,"input"],[16,2,[30,3,["value"]]],[24,4,"text"],[4,[38,18],null,null],[4,[38,14],["input",[28,[37,8],[[30,0,["updateValue"]],[30,3]],null]],null],[4,[38,14],["keydown",[28,[37,8],[[30,0,["onInputKeydown"]],[30,4]],null]],null],[12],[13],[1,"\\n"],[41,[30,0,["canRemoveOption"]],[[[1," "],[8,[39,5],null,[["@icon","@action"],["trash-can",[28,[37,8],[[30,0,["removeOption"]],[30,3]],null]]],null],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n"]],[3,4]],null],[1,"\\n "],[10,0],[14,0,"poll-option-controls"],[12],[1,"\\n "],[8,[39,5],[[24,0,"btn-default poll-option-add"]],[["@icon","@label","@action"],["plus","poll.ui_builder.poll_options.add",[28,[37,8],[[30,0,["addOption"]],-1],null]]],null],[1,"\\n"],[41,[28,[37,19],[[30,0,["showMinNumOfOptionsValidation"]],[28,[37,20],[[30,0,["minNumOfOptionsValidation","ok"]]],null]],null],[[[1," "],[8,[39,15],null,[["@validation"],[[30,0,["minNumOfOptionsValidation"]]]],null],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[51,[30,0,["rankedChoiceOrRegular"]]],[[[1," "],[10,0],[14,0,"options"],[12],[1,"\\n "],[10,0],[14,0,"input-group poll-number"],[12],[1,"\\n "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_config.min"],null]],[13],[1,"\\n "],[8,[39,11],[[24,0,"poll-options-min"],[24,"min","1"]],[["@type","@value"],["number",[30,0,["pollMin"]]]],null],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"input-group poll-number"],[12],[1,"\\n "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_config.max"],null]],[13],[1,"\\n "],[8,[39,11],[[24,0,"poll-options-max"],[24,"min","1"]],[["@type","@value"],["number",[30,0,["pollMax"]]]],null],[1,"\\n "],[13],[1,"\\n\\n"],[41,[30,0,["isNumber"]],[[[1," "],[10,0],[14,0,"input-group poll-number"],[12],[1,"\\n "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_config.step"],null]],[13],[1,"\\n "],[8,[39,11],[[24,"min","1"],[24,0,"poll-options-step"]],[["@type","@value"],["number",[30,0,["pollStep"]]]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n"],[41,[51,[30,0,["minMaxValueValidation","ok"]]],[[[1," "],[8,[39,15],null,[["@validation"],[[30,0,["minMaxValueValidation"]]]],null],[1,"\\n"]],[]],null]],[]],null],[1,"\\n "],[10,0],[14,0,"input-group poll-public"],[12],[1,"\\n "],[8,[39,21],[[24,0,"poll-toggle-public"],[4,[38,14],["click",[30,0,["togglePublic"]]],null]],[["@state","@label"],[[30,0,["publicPoll"]],"poll.ui_builder.poll_public.label"]],null],[1,"\\n "],[13],[1,"\\n\\n"],[41,[30,0,["showAdvanced"]],[[[1," "],[10,0],[14,0,"input-group poll-allowed-groups"],[12],[1,"\\n "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_groups.label"],null]],[13],[1,"\\n "],[8,[39,22],null,[["@content","@value","@onChange","@labelProperty","@valueProperty"],[[30,0,["siteGroups"]],[30,0,["pollGroups"]],[28,[37,8],[[28,[37,23],[[30,0,["pollGroups"]]],null]],null],"name","name"]],null],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"input-group poll-date"],[12],[1,"\\n "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.automatic_close.label"],null]],[13],[1,"\\n "],[8,[39,24],null,[["@date","@onChange","@clearable","@useGlobalPickerContainer"],[[30,0,["pollAutoClose"]],[28,[37,8],[[28,[37,23],[[30,0,["pollAutoClose"]]],null]],null],true,true]],null],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"input-group poll-select"],[12],[1,"\\n "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_result.label"],null]],[13],[1,"\\n "],[8,[39,25],[[24,0,"poll-result"]],[["@content","@value","@valueProperty","@onChange"],[[30,0,["pollResults"]],[30,0,["pollResult"]],"value",[28,[37,8],[[28,[37,23],[[30,0,["pollResult"]]],null]],null]]],null],[1,"\\n "],[13],[1,"\\n\\n"],[41,[51,[30,0,["rankedChoiceOrNumber"]]],[[[1," "],[10,0],[14,0,"input-group poll-select column"],[12],[1,"\\n "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_chart_type.label"],null]],[13],[1,"\\n\\n "],[10,0],[14,0,"radio-group"],[12],[1,"\\n "],[8,[39,26],null,[["@id","@name","@value","@selection"],["poll-chart-type-bar","poll-chart-type","bar",[30,0,["chartType"]]]],null],[1,"\\n "],[10,"label"],[14,"for","poll-chart-type-bar"],[12],[1,[28,[35,27],["chart-bar"],null]],[1,"\\n "],[1,[28,[35,1],["poll.ui_builder.poll_chart_type.bar"],null]],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"radio-group"],[12],[1,"\\n "],[8,[39,26],null,[["@id","@name","@value","@selection"],["poll-chart-type-pie","poll-chart-type","pie",[30,0,["chartType"]]]],null],[1,"\\n "],[10,"label"],[14,"for","poll-chart-type-pie"],[12],[1,[28,[35,27],["chart-pie"],null]],[1,"\\n "],[1,[28,[35,1],["poll.ui_builder.poll_chart_type.pie"],null]],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null]],[]],null],[1," "]],[]],[[[1,"\\n "],[8,[39,5],[[24,0,"btn-primary insert-poll"]],[["@action","@icon","@label","@disabled"],[[30,0,["insertPoll"]],"chart-bar","poll.ui_builder.insert",[30,0,["disableInsert"]]]],null],[1,"\\n\\n "],[8,[39,5],[[24,0,"btn-flat"]],[["@label","@action"],["cancel",[30,1]]],null],[1,"\\n\\n "],[8,[39,5],[[24,0,"btn-default show-advanced"]],[["@action","@icon","@title"],[[30,0,["toggleAdvanced"]],"gear",[52,[30,0,["showAdvanced"]],"poll.ui_builder.hide_advanced","poll.ui_builder.show_advanced"]]],null],[1,"\\n\\n "]],[]]]]]],["@closeModal","@inline","option","index"],false,["d-modal","i18n",":body","ul","li","d-button","concatClass","if","fn","div","label","input","unless","textarea","on","input-tip","each","-track-array","auto-focus","and","not","d-toggle-switch","group-chooser","mut","date-time-input","combo-box","radio-button","d-icon",":footer"]]',moduleName:"discourse/plugins/poll/discourse/components/modal/poll-ui-builder.hbs",isStrictMode:!1}),u=e.BAR_CHART_TYPE="bar",c=e.PIE_CHART_TYPE="pie",d=e.REGULAR_POLL_TYPE="regular",h=e.NUMBER_POLL_TYPE="number",m=e.MULTIPLE_POLL_TYPE="multiple",g=e.RANKED_CHOICE_POLL_TYPE="ranked_choice",b="always"
class f extends t.default{static#e=(()=>dt7948.g(this.prototype,"siteSettings",[s.service]))()
#o=(()=>{dt7948.i(this,"siteSettings")})()
showAdvanced=!1
pollType=(()=>d)()
pollTitle
pollOptions=(()=>[l.default.create({value:""})])()
pollOptionsText=""
pollMin=1
pollMax=2
pollStep=1
pollGroups
pollAutoClose
pollResult=(()=>b)()
chartType=(()=>u)()
publicPoll=this.siteSettings.poll_default_public
static#l=(()=>dt7948.g(this.prototype,"showNumber",[(0,o.or)("showAdvanced","isNumber")]))()
#a=(()=>{dt7948.i(this,"showNumber")})()
static#s=(()=>dt7948.g(this.prototype,"showRankedChoice",[(0,o.or)("showAdvanced","isRankedChoice")]))()
#p=(()=>{dt7948.i(this,"showRankedChoice")})()
static#n=(()=>dt7948.g(this.prototype,"canRemoveOption",[(0,o.gt)("pollOptions.length",1)]))()
#u=(()=>{dt7948.i(this,"canRemoveOption")})()
static#i=(()=>dt7948.g(this.prototype,"rankedChoiceOrRegular",[(0,o.or)("isRankedChoice","isRegular")]))()
#c=(()=>{dt7948.i(this,"rankedChoiceOrRegular")})()
static#r=(()=>dt7948.g(this.prototype,"rankedChoiceOrNumber",[(0,o.or)("isRankedChoice","isNumber")]))()
#d=(()=>{dt7948.i(this,"rankedChoiceOrNumber")})()
pollResults(e){const t=[{name:(0,r.i18n)("poll.ui_builder.poll_result.always"),value:b},{name:(0,r.i18n)("poll.ui_builder.poll_result.vote"),value:"on_vote"},{name:(0,r.i18n)("poll.ui_builder.poll_result.closed"),value:"on_close"}]
return e&&t.push({name:(0,r.i18n)("poll.ui_builder.poll_result.staff"),value:"staff_only"}),t}static#h=(()=>dt7948.n(this.prototype,"pollResults",[(0,i.default)("currentUser.staff")]))()
isRegular(e){return e===d}static#m=(()=>dt7948.n(this.prototype,"isRegular",[(0,i.default)("pollType")]))()
isNumber(e){return e===h}static#g=(()=>dt7948.n(this.prototype,"isNumber",[(0,i.default)("pollType")]))()
isMultiple(e){return e===m}static#b=(()=>dt7948.n(this.prototype,"isMultiple",[(0,i.default)("pollType")]))()
isRankedChoice(e){return e===g}static#f=(()=>dt7948.n(this.prototype,"isRankedChoice",[(0,i.default)("pollType")]))()
pollOptionsCount(e){return(e||[]).filter((e=>e.value.length>0)).length}static#_=(()=>dt7948.n(this.prototype,"pollOptionsCount",[(0,i.default)("pollOptions.@each.value")]))()
siteGroups(e){return e.filter((e=>0!==e.id))}static#v=(()=>dt7948.n(this.prototype,"siteGroups",[(0,i.default)("site.groups")]))()
isPie(e,t){return t!==h&&e===c}static#y=(()=>dt7948.n(this.prototype,"isPie",[(0,i.default)("chartType","pollType")]))()
_setPollMinMax(){this.isMultiple?((this.pollMin<=0||this.pollMin>=this.pollMax||this.pollMin>=this.pollOptionsCount)&&this.set("pollMin",this.pollOptionsCount>0?1:0),(this.pollMax<=0||this.pollMin>=this.pollMax||this.pollMax>this.pollOptionsCount)&&this.set("pollMax",this.pollOptionsCount)):this.isNumber&&this.set("pollMax",this.siteSettings.poll_maximum_options)}static#k=(()=>dt7948.n(this.prototype,"_setPollMinMax",[(0,n.observes)("pollType","pollOptionsCount")]))()
pollOutput(e,t,l,o,s,n,i,r,a,p,u){let c="[poll",m=""
const g=this.model.toolbarEvent.getText().match(/\[poll(\s+name=[^\s\]]+)*.*\]/gim)
g&&(c+=` name=poll${g.length+1}`)
let b=r
return b<1&&(b=1),e&&(c+=` type=${e}`),t&&(c+=` results=${t}`),n&&e!==d&&(c+=` min=${n}`),i&&e!==d&&(c+=` max=${i}`),e===h&&(c+=` step=${b}`),c+=" public="+(l?"true":"false"),u&&e!==h&&(c+=` chartType=${u}`),a&&a.length>0&&(c+=` groups=${a}`),p&&(c+=` close=${p.toISOString()}`),c+="]",m+=`${c}\n`,o&&(m+=`# ${o.trim()}\n`),s.length>0&&e!==h&&s.forEach((e=>{e.value.length>0&&(m+=`* ${e.value.trim()}\n`)})),m+="[/poll]\n",m}static#w=(()=>dt7948.n(this.prototype,"pollOutput",[(0,i.default)("pollType","pollResult","publicPoll","pollTitle","pollOptions.@each.value","pollMin","pollMax","pollStep","pollGroups","pollAutoClose","chartType")]))()
minNumOfOptionsValidation(e,t){if(!e){if(t<1)return l.default.create({failed:!0,reason:(0,r.i18n)("poll.ui_builder.help.options_min_count")})
if(t>this.siteSettings.poll_maximum_options)return l.default.create({failed:!0,reason:(0,r.i18n)("poll.ui_builder.help.options_max_count",{count:this.siteSettings.poll_maximum_options})})}return l.default.create({ok:!0})}static#C=(()=>dt7948.n(this.prototype,"minNumOfOptionsValidation",[(0,i.default)("isNumber","pollOptionsCount")]))()
showMinNumOfOptionsValidation(e){return 1!==e.length||""!==e[0].value}static#O=(()=>dt7948.n(this.prototype,"showMinNumOfOptionsValidation",[(0,i.default)("pollOptions.@each.value")]))()
minMaxValueValidation(e,t,o,s,n,i){if(s=parseInt(s,10)||0,n=parseInt(n,10)||0,i=parseInt(i,10)||0,s<0)return l.default.create({failed:!0,reason:(0,r.i18n)("poll.ui_builder.help.invalid_min_value")})
if(n<0||e&&n>t)return l.default.create({failed:!0,reason:(0,r.i18n)("poll.ui_builder.help.invalid_max_value")})
if(s>n)return l.default.create({failed:!0,reason:(0,r.i18n)("poll.ui_builder.help.invalid_values")})
if(o){if(i<1)return l.default.create({failed:!0,reason:(0,r.i18n)("poll.ui_builder.help.min_step_value")})
const e=(n-s+1)/i
if(e<1)return l.default.create({failed:!0,reason:(0,r.i18n)("poll.ui_builder.help.options_min_count")})
if(e>this.siteSettings.poll_maximum_options)return l.default.create({failed:!0,reason:(0,r.i18n)("poll.ui_builder.help.options_max_count",{count:this.siteSettings.poll_maximum_options})})}return l.default.create({ok:!0})}static#x=(()=>dt7948.n(this.prototype,"minMaxValueValidation",[(0,i.default)("isMultiple","pollOptionsCount","isNumber","pollMin","pollMax","pollStep")]))()
disableInsert(e,t){return!e.ok||!t.ok}static#T=(()=>dt7948.n(this.prototype,"disableInsert",[(0,i.default)("minMaxValueValidation","minNumOfOptionsValidation")]))()
_comboboxOptions(e,t){return[...Array(t-e).keys()].map((t=>({value:t+e,name:t+e})))}onOptionsTextChange(e){this.set("pollOptions",e.target.value.split("\n").map((e=>l.default.create({value:e}))))}static#M=(()=>dt7948.n(this.prototype,"onOptionsTextChange",[l.action]))()
insertPoll(){this.model.toolbarEvent.addText(this.pollOutput),this.closeModal()}static#P=(()=>dt7948.n(this.prototype,"insertPoll",[l.action]))()
toggleAdvanced(){this.toggleProperty("showAdvanced"),this.showAdvanced&&this.set("pollOptionsText",this.pollOptions.map((e=>e.value)).join("\n"))}static#R=(()=>dt7948.n(this.prototype,"toggleAdvanced",[l.action]))()
updateValue(e,t){e.set("value",t.target.value)}static#S=(()=>dt7948.n(this.prototype,"updateValue",[l.action]))()
onInputKeydown(e,t){"Enter"===t.key&&(t.preventDefault(),t.stopPropagation(),""!==t.target.value&&this.addOption(e+1))}static#j=(()=>dt7948.n(this.prototype,"onInputKeydown",[l.action]))()
addOption(e){-1===e&&(e=this.pollOptions.length)
const t=l.default.create({value:""})
this.pollOptions.insertAt(e,t)}static#V=(()=>dt7948.n(this.prototype,"addOption",[l.action]))()
removeOption(e){this.pollOptions.removeObject(e)}static#E=(()=>dt7948.n(this.prototype,"removeOption",[l.action]))()
updatePollType(e,t){t?.preventDefault(),this.set("pollType",e)}static#N=(()=>dt7948.n(this.prototype,"updatePollType",[l.action]))()
togglePublic(){this.set("publicPoll",!this.publicPoll)}static#L=(()=>dt7948.n(this.prototype,"togglePublic",[l.action]))()}e.default=f,(0,t.setComponentTemplate)(p,f)})),define("discourse/plugins/poll/discourse/components/poll-breakdown-chart",["exports","@ember/component","@ember/object/computed","@ember/runloop","@ember/template","@ember-decorators/component","discourse-common/utils/decorators","discourse-i18n","discourse/plugins/poll/lib/chart-colors","discourse/plugins/poll/discourse/components/modal/poll-ui-builder","@ember/template-factory"],(function(e,t,l,o,s,n,i,r,a,p,u){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const c=dt7948.c(class extends t.default{group=null
options=null
displayMode=null
highlightedOption=null
setHighlightedOption=null
static#e=(()=>dt7948.g(this.prototype,"data",[(0,l.mapBy)("options","votes")]))()
#A=(()=>{dt7948.i(this,"data")})()
_optionToSlice=null
_previousHighlightedSliceIndex=null
_previousDisplayMode=null
init(){super.init(...arguments),this._optionToSlice={}}willDestroy(){super.willDestroy(...arguments),this._chart&&this._chart.destroy()}didInsertElement(){super.didInsertElement(...arguments)
const e=this.element.querySelector("canvas")
this._chart=new window.Chart(e.getContext("2d"),this.chartConfig)}didReceiveAttrs(){super.didReceiveAttrs(...arguments),this._chart&&(this._updateDisplayMode(),this._updateHighlight())}colorStyle(e,t){return(0,s.htmlSafe)(`background: ${e[t]};`)}static#l=(()=>dt7948.n(this.prototype,"colorStyle",[(0,i.default)("optionColors","index")]))()
chartConfig(e,t){const l=[]
let s=0
this._optionToSlice={},e.forEach(((e,t)=>{e>0&&(l.push(e),this._optionToSlice[t]=s++)}))
const n=l.reduce(((e,t)=>e+t),0),i=(0,a.getColors)(e.length).filter(((t,l)=>e[l]>0))
return{type:p.PIE_CHART_TYPE,plugins:[window.ChartDataLabels],data:{datasets:[{data:l,backgroundColor:i,hoverBorderColor:"#fff"}]},options:{plugins:{tooltip:!1,datalabels:{color:"#333",backgroundColor:"rgba(255, 255, 255, 0.5)",borderRadius:2,font:{family:getComputedStyle(document.body).fontFamily,size:16},padding:{top:2,right:6,bottom:2,left:6},formatter(e){if("percentage"!==t)return e
return`${r.default.toNumber(e/n*100,{precision:1})}%`}}},responsive:!0,aspectRatio:1.1,animation:{duration:0},onHover:(e,t)=>{if(!t.length)return void(0,o.next)((()=>{this.setHighlightedOption(null)}))
const l=t[0].index,s=Object.keys(this._optionToSlice).find((e=>this._optionToSlice[e]===l));(0,o.next)((()=>{this.setHighlightedOption(Number(s))}))}}}}static#s=(()=>dt7948.n(this.prototype,"chartConfig",[(0,i.default)("data","displayMode")]))()
_updateDisplayMode(){if(this.displayMode!==this._previousDisplayMode){const e=this.chartConfig
this._chart.data.datasets=e.data.datasets,this._chart.options=e.options,this._chart.update(),this._previousDisplayMode=this.displayMode}}_updateHighlight(){const e=[]
if(this.highlightedOption){const t=this._optionToSlice[this.highlightedOption]
void 0!==t&&e.push({datasetIndex:0,index:t})}this._chart.setActiveElements(e),this._chart.update()}static#n=(()=>(0,t.setComponentTemplate)((0,u.createTemplateFactory)({id:"7L2OXyes",block:'[[[1,"\\n "],[10,"label"],[14,0,"poll-breakdown-chart-label"],[12],[1,[30,1]],[13],[1,"\\n "],[10,"canvas"],[14,0,"poll-breakdown-chart-chart"],[12],[13],[1,"\\n "]],["@group"],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/components/poll-breakdown-chart.js",isStrictMode:!0}),this))()},[(0,n.classNames)("poll-breakdown-chart-container")])
e.default=c})),define("discourse/plugins/poll/discourse/components/poll-breakdown-option",["exports","@ember/component","@ember/modifier","@ember/object/computed","@ember/template","@ember-decorators/component","discourse/lib/computed","discourse-common/utils/decorators","discourse-i18n","discourse/plugins/poll/lib/chart-colors","@ember/template-factory"],(function(e,t,l,o,s,n,i,r,a,p,u){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const c=dt7948.c(class extends t.default{option=null
index=null
totalVotes=null
optionsCount=null
displayMode=null
highlightedOption=null
onMouseOver=null
onMouseOut=null
static#e=(()=>dt7948.g(this.prototype,"highlighted",[(0,i.propertyEqual)("highlightedOption","index")]))()
#D=(()=>{dt7948.i(this,"highlighted")})()
static#l=(()=>dt7948.g(this.prototype,"showPercentage",[(0,o.equal)("displayMode","percentage")]))()
#I=(()=>{dt7948.i(this,"showPercentage")})()
percent(e,t){return a.default.toNumber(e/t*100,{precision:1})}static#s=(()=>dt7948.n(this.prototype,"percent",[(0,r.default)("option.votes","totalVotes")]))()
optionColors(e){return(0,p.getColors)(e)}static#n=(()=>dt7948.n(this.prototype,"optionColors",[(0,r.default)("optionsCount")]))()
colorBackgroundStyle(e){if(e)return(0,s.htmlSafe)("background: rgba(0, 0, 0, 0.1);")}static#i=(()=>dt7948.n(this.prototype,"colorBackgroundStyle",[(0,r.default)("highlighted")]))()
colorPreviewStyle(e,t,l){const o=e?window.Chart.helpers.getHoverColor(t[l]):t[l]
return(0,s.htmlSafe)(`background: ${o};`)}static#r=(()=>dt7948.n(this.prototype,"colorPreviewStyle",[(0,r.default)("highlighted","optionColors","index")]))()
static#h=(()=>(0,t.setComponentTemplate)((0,u.createTemplateFactory)({id:"eauZvEcj",block:'[[[1,"\\n "],[11,"li"],[24,0,"poll-breakdown-option"],[16,5,[30,0,["colorBackgroundStyle"]]],[24,"role","button"],[4,[32,0],["mouseover",[30,1]],null],[4,[32,0],["mouseout",[30,2]],null],[12],[1,"\\n "],[10,1],[14,0,"poll-breakdown-option-color"],[15,5,[30,0,["colorPreviewStyle"]]],[12],[13],[1,"\\n\\n "],[10,1],[14,0,"poll-breakdown-option-count"],[12],[1,"\\n"],[41,[30,0,["showPercentage"]],[[[1," "],[1,[28,[32,1],["number.percent"],[["count"],[[30,0,["percent"]]]]]],[1,"\\n"]],[]],[[[1," "],[1,[30,3,["votes"]]],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n "],[10,1],[14,0,"poll-breakdown-option-text"],[12],[1,[28,[32,2],[[30,3,["html"]]],null]],[13],[1,"\\n "],[13],[1,"\\n "]],["@onMouseOver","@onMouseOut","@option"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/components/poll-breakdown-option.js",scope:()=>[l.on,a.i18n,s.htmlSafe],isStrictMode:!0}),this))()},[(0,n.tagName)("")])
e.default=c})),define("discourse/plugins/poll/discourse/components/poll-buttons-dropdown",["exports","@glimmer/component","@ember/helper","@ember/object","@ember/service","discourse/components/d-button","discourse/components/dropdown-menu","discourse-common/helpers/d-icon","float-kit/components/d-menu","@ember/component","@ember/template-factory"],(function(e,t,l,o,s,n,i,r,a,p,u){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const c={exportResults:{className:"btn-default export-results",label:"poll.export-results.label",title:"poll.export-results.title",icon:"download",action:"exportResults"},showBreakdown:{className:"btn-default show-breakdown",label:"poll.breakdown.breakdown",icon:"chart-pie",action:"showBreakdown"},openPoll:{className:"btn-default toggle-status",label:"poll.open.label",title:"poll.open.title",icon:"unlock-keyhole",action:"toggleStatus"},closePoll:{className:"btn-default toggle-status",label:"poll.close.label",title:"poll.close.title",icon:"lock",action:"toggleStatus"},showTally:{className:"btn-default show-tally",label:"poll.show-tally.label",title:"poll.show-tally.title",icon:"info",action:"toggleDisplayMode"},showPercentage:{className:"btn-default show-percentage",label:"poll.show-percentage.label",title:"poll.show-percentage.title",icon:"info",action:"toggleDisplayMode"}}
class d extends t.default{static#e=(()=>dt7948.g(this.prototype,"currentUser",[s.service]))()
#U=(()=>{dt7948.i(this,"currentUser")})()
static#l=(()=>dt7948.g(this.prototype,"siteSettings",[s.service]))()
#o=(()=>{dt7948.i(this,"siteSettings")})()
constructor(){super(...arguments),this.getDropdownButtonState=!1}dropDownClick(e){this.args.dropDownClick(e)}static#s=(()=>dt7948.n(this.prototype,"dropDownClick",[o.action]))()
get getDropdownContent(){const e=[],t=this.currentUser&&this.currentUser.admin,l=this.siteSettings.data_explorer_enabled,o=this.args.isRankedChoice?this.siteSettings.poll_export_ranked_choice_data_explorer_query_id:this.siteSettings.poll_export_data_explorer_query_id,{closed:s,voters:n,isStaff:i,isMe:r,topicArchived:a,groupableUserFields:p,isAutomaticallyClosed:u,availableDisplayMode:d}=this.args
if(d){const t={...c[d]}
t.id=t.action,e.push(t)}if(p.length&&n>0){const t={...c.showBreakdown}
t.id=t.action,e.push(t)}if(t&&l&&n>0&&o){const t={...c.exportResults}
t.id=t.action,e.push(t)}if(this.currentUser&&(r||i)&&!a)if(s){if(!u){const t={...c.openPoll}
t.id=t.action,e.push(t)}}else{const t={...c.closePoll}
t.id=t.action,e.push(t)}return e}get showDropdown(){return this.getDropdownContent.length>1}get showDropdownAsButton(){return 1===this.getDropdownContent.length}static#n=(()=>(0,p.setComponentTemplate)((0,u.createTemplateFactory)({id:"aY1spYIh",block:'[[[1,"\\n "],[10,0],[14,0,"poll-buttons-dropdown"],[12],[1,"\\n"],[41,[30,0,["showDropdown"]],[[[1," "],[8,[32,0],[[24,0,"widget-dropdown-header"]],null,[["trigger","content"],[[[[1,"\\n "],[1,[28,[32,1],["gear"],null]],[1,"\\n "]],[]],[[[1,"\\n "],[8,[32,2],null,null,[["default"],[[[[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["getDropdownContent"]]],null]],null],null,[[[1," "],[8,[30,1,["item"]],null,null,[["default"],[[[[1,"\\n "],[8,[32,3],[[16,0,[29,["widget-button ",[30,2,["className"]]]]]],[["@icon","@label","@action"],[[30,2,["icon"]],[30,2,["label"]],[28,[32,4],[[30,0,["dropDownClick"]],[30,2,["action"]]],null]]],null],[1,"\\n "]],[]]]]],[1,"\\n "],[8,[30,1,["divider"]],null,null,null],[1,"\\n"]],[2]],null],[1," "]],[1]]]]],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],[[[41,[30,0,["showDropdownAsButton"]],[[[1," "],[8,[32,3],[[16,0,[29,["widget-button ",[28,[32,5],[[30,0,["getDropdownContent"]],"0.className"],null]]]]],[["@icon","@label","@action"],[[28,[32,5],[[30,0,["getDropdownContent"]],"0.icon"],null],[28,[32,5],[[30,0,["getDropdownContent"]],"0.label"],null],[28,[32,4],[[30,0,["dropDownClick"]],[28,[32,5],[[30,0,["getDropdownContent"]],"0.action"],null]],null]]],null],[1,"\\n "]],[]],null]],[]]],[1," "],[13],[1,"\\n "]],["dropdown","content"],false,["if","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/components/poll-buttons-dropdown.js",scope:()=>[a.default,r.default,i.default,n.default,l.fn,o.get],isStrictMode:!0}),this))()}e.default=d})),define("discourse/plugins/poll/discourse/components/poll-info",["exports","@glimmer/component","@ember/service","@ember/template","discourse/lib/formatter","discourse-common/helpers/d-icon","discourse-i18n","@ember/component","@ember/template-factory"],(function(e,t,l,o,s,n,i,r,a){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const p="staff_only"
class u extends t.default{static#e=(()=>dt7948.g(this.prototype,"currentUser",[l.service]))()
#U=(()=>{dt7948.i(this,"currentUser")})()
get multipleHelpText(){const{min:e,max:t,options:l}=this.args,s=l.length
if(t>0){if(e===t&&e>1)return(0,o.htmlSafe)((0,i.i18n)("poll.multiple.help.x_options",{count:e}))
if(e>1)return te+parseInt(t.votes,10)),0)}get totalVotesLabel(){return(0,i.i18n)("poll.total_votes",{count:this.totalVotes})}get automaticCloseAgeLabel(){return(0,i.i18n)("poll.automatic_close.age",this.age)}get automaticCloseClosesInLabel(){return(0,i.i18n)("poll.automatic_close.closes_in",this.timeLeft)}get showMultipleHelpText(){return this.args.isMultiple&&!this.args.showResults&&!this.args.closed}get closeTitle(){const e=moment.utc(this.args.close,"YYYY-MM-DD HH:mm:ss Z")
return e.isValid()?e.format("LLL"):""}get age(){const e=moment.utc(this.args.close,"YYYY-MM-DD HH:mm:ss Z")
return e.isValid()?(0,s.relativeAge)(e.toDate(),{addAgo:!0}):0}get timeLeft(){const e=moment.utc(this.args.close,"YYYY-MM-DD HH:mm:ss Z")
return e.isValid()?moment().to(e,!0):0}get resultsOnVote(){return!("on_vote"!==this.args.results||this.args.hasVoted||this.currentUser&&this.args.postUserId===this.currentUser.id)}get resultsOnVoteTitle(){return(0,o.htmlSafe)((0,i.i18n)("poll.results.vote.title"))}get resultsOnClose(){return"on_close"===this.args.results&&!this.args.closed}get resultsOnCloseTitle(){return(0,o.htmlSafe)((0,i.i18n)("poll.results.closed.title"))}get resultsStaffOnly(){return this.args.results===p&&!(this.currentUser&&this.currentUser.staff)}get resultsStaffOnlyTitle(){return(0,o.htmlSafe)((0,i.i18n)("poll.results.staff.title"))}get publicTitle(){return!this.args.closed&&!this.args.showResults&&this.args.isPublic&&this.args.results!==p}get publicTitleLabel(){return(0,o.htmlSafe)((0,i.i18n)("poll.public.title"))}get showInstructionsSection(){return this.showMultipleHelpText||this.args.close||this.resultsOnVote||this.resultsOnClose||this.resultsStaffOnly||this.publicTitle}static#l=(()=>(0,r.setComponentTemplate)((0,a.createTemplateFactory)({id:"0nux6psB",block:'[[[1,"\\n "],[10,0],[14,0,"poll-info"],[12],[1,"\\n "],[10,0],[14,0,"poll-info_counts"],[12],[1,"\\n "],[10,0],[14,0,"poll-info_counts-count"],[12],[1,"\\n "],[10,1],[14,0,"info-number"],[12],[1,[30,1]],[13],[1,"\\n "],[10,1],[14,0,"info-label"],[12],[1,[30,0,["votersLabel"]]],[13],[1,"\\n "],[13],[1,"\\n"],[41,[30,0,["showTotalVotes"]],[[[1," "],[10,0],[14,0,"poll-info_counts-count"],[12],[1,"\\n "],[10,1],[14,0,"info-number"],[12],[1,[30,0,["totalVotes"]]],[13],[1,"\\n "],[10,1],[14,0,"info-label"],[12],[1,[30,0,["totalVotesLabel"]]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n"],[41,[30,0,["showInstructionsSection"]],[[[1," "],[10,"ul"],[14,0,"poll-info_instructions"],[12],[1,"\\n"],[41,[30,0,["showMultipleHelpText"]],[[[1," "],[10,"li"],[14,0,"multiple-help-text"],[12],[1,"\\n "],[1,[28,[32,0],["list-ul"],null]],[1,"\\n "],[10,1],[12],[1,[30,0,["multipleHelpText"]]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[41,[30,0,["poll","close"]],[[[41,[30,0,["isAutomaticallyClosed"]],[[[1," "],[10,"li"],[15,"title",[30,0,["title"]]],[12],[1,"\\n "],[1,[28,[32,0],["lock"],null]],[1,"\\n "],[10,1],[12],[1,[30,0,["automaticCloseAgeLabel"]]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],[[[1," "],[10,"li"],[15,"title",[30,0,["title"]]],[12],[1,"\\n "],[1,[28,[32,0],["far-clock"],null]],[1,"\\n "],[10,1],[12],[1,[30,0,["automaticCloseClosesInLabel"]]],[13],[1,"\\n "],[13],[1,"\\n"]],[]]]],[]],null],[41,[30,0,["resultsOnVote"]],[[[1," "],[10,"li"],[14,0,"results-on-vote"],[12],[1,"\\n "],[1,[28,[32,0],["check"],null]],[1,"\\n "],[10,1],[12],[1,[30,0,["resultsOnVoteTitle"]]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[41,[30,0,["resultsOnClose"]],[[[1," "],[10,"li"],[14,0,"results-on-close"],[12],[1,"\\n "],[1,[28,[32,0],["lock"],null]],[1,"\\n "],[10,1],[12],[1,[30,0,["resultsOnCloseTitle"]]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[41,[30,0,["resultsStaffOnly"]],[[[1," "],[10,"li"],[14,0,"results-staff-only"],[12],[1,"\\n "],[1,[28,[32,0],["shield-halved"],null]],[1,"\\n "],[10,1],[12],[1,[30,0,["resultsStaffOnlyTitle"]]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[41,[30,0,["publicTitle"]],[[[1," "],[10,"li"],[14,0,"is-public"],[12],[1,"\\n "],[1,[28,[32,0],["far-eye"],null]],[1,"\\n "],[10,1],[12],[1,[30,0,["publicTitleLabel"]]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n "]],["@voters"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/components/poll-info.js",scope:()=>[n.default],isStrictMode:!0}),this))()}e.default=u})),define("discourse/plugins/poll/discourse/components/poll-option-ranked-choice-dropdown",["exports","@glimmer/component","@ember/helper","@ember/object","discourse/components/d-button","discourse/components/dropdown-menu","discourse-common/helpers/d-icon","discourse-i18n","float-kit/components/d-menu","@ember/component","@ember/template-factory"],(function(e,t,l,o,s,n,i,r,a,p,u){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class c extends t.default{onRegisterApi(e){this.dMenu=e}static#e=(()=>dt7948.n(this.prototype,"onRegisterApi",[o.action]))()
selectRank(e,t){this.args.sendRank(e,t),this.dMenu.close()}static#l=(()=>dt7948.n(this.prototype,"selectRank",[o.action]))()
get rankLabel(){return 0===this.args.rank?(0,r.i18n)("poll.options.ranked_choice.abstain"):this.args.rank}static#s=(()=>(0,p.setComponentTemplate)((0,u.createTemplateFactory)({id:"SC3eLHA6",block:'[[[1,"\\n "],[8,[32,0],null,[["@onRegisterApi"],[[30,0,["onRegisterApi"]]]],[["trigger","content"],[[[[1,"\\n "],[10,1],[14,0,"d-button-label"],[12],[1,"\\n "],[1,[30,0,["rankLabel"]]],[1,"\\n "],[13],[1,"\\n "],[1,[28,[32,1],["angle-down"],null]],[1,"\\n "]],[]],[[[1,"\\n "],[8,[32,2],null,null,[["default"],[[[[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,2]],null]],null],null,[[[1," "],[8,[30,1,["item"]],null,null,[["default"],[[[[1,"\\n "],[8,[32,3],[[24,0,"btn-transparent poll-option-dropdown"]],[["@translatedLabel","@action"],[[30,3,["name"]],[28,[32,4],[[30,0,["selectRank"]],[30,4,["id"]],[30,3,["id"]]],null]]],null],[1,"\\n "]],[]]]]],[1,"\\n"]],[3]],null],[1," "]],[1]]]]],[1,"\\n "]],[]]]]],[1,"\\n "]],["dropdown","@rankedChoiceDropdownContent","content","@option"],false,["each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/components/poll-option-ranked-choice-dropdown.js",scope:()=>[a.default,i.default,n.default,s.default,l.fn],isStrictMode:!0}),this))()}e.default=c})),define("discourse/plugins/poll/discourse/components/poll-option-ranked-choice",["exports","@glimmer/component","@ember/object","@ember/service","@ember/template","discourse/components/d-button","discourse/helpers/route-action","discourse-i18n","discourse/plugins/poll/discourse/components/poll-option-ranked-choice-dropdown","@ember/component","@ember/template-factory"],(function(e,t,l,o,s,n,i,r,a,p,u){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class c extends t.default{static#e=(()=>dt7948.g(this.prototype,"currentUser",[o.service]))()
#U=(()=>{dt7948.i(this,"currentUser")})()
sendRank(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0
this.args.sendRank(e,t)}static#l=(()=>dt7948.n(this.prototype,"sendRank",[l.action]))()
static#s=(()=>(0,p.setComponentTemplate)((0,u.createTemplateFactory)({id:"dGNrAxli",block:'[[[1,"\\n "],[10,0],[14,"tabindex","0"],[14,0,"ranked-choice-poll-option"],[15,"data-poll-option-id",[30,1,["id"]]],[15,"data-poll-option-rank",[30,1,["rank"]]],[12],[1,"\\n"],[41,[30,0,["currentUser"]],[[[1," "],[8,[32,0],null,[["@rank","@option","@rankedChoiceDropdownContent","@sendRank"],[[30,1,["rank"]],[30,1],[30,2],[30,0,["sendRank"]]]],null],[1,"\\n"]],[]],[[[1," "],[8,[32,1],[[24,0,"btn-default"],[16,"onclick",[28,[32,2],["showLogin"],null]]],null,[["default"],[[[[1,[28,[32,3],["poll.options.ranked_choice.login"],null]]],[]]]]],[1,"\\n"]],[]]],[1," "],[10,1],[14,0,"option-text"],[12],[1,[28,[32,4],[[30,1,["html"]]],null]],[13],[1,"\\n "],[13],[1,"\\n "]],["@option","@rankedChoiceDropdownContent"],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/components/poll-option-ranked-choice.js",scope:()=>[a.default,n.default,i.default,r.i18n,s.htmlSafe],isStrictMode:!0}),this))()}e.default=c})),define("discourse/plugins/poll/discourse/components/poll-options",["exports","@glimmer/component","@ember/helper","@ember/modifier","@ember/object","@ember/service","@ember/template","discourse/helpers/concat-class","discourse/helpers/route-action","discourse-common/helpers/d-icon","discourse-i18n","discourse/plugins/poll/discourse/components/poll-option-ranked-choice","@ember/component","@ember/template-factory"],(function(e,t,l,o,s,n,i,r,a,p,u,c,d,h){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class m extends t.default{static#e=(()=>dt7948.g(this.prototype,"currentUser",[n.service]))()
#U=(()=>{dt7948.i(this,"currentUser")})()
isChosen=e=>this.args.votes.includes(e.id)
sendClick(e){this.args.sendOptionSelect(e)}static#l=(()=>dt7948.n(this.prototype,"sendClick",[s.action]))()
sendRank(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0
this.args.sendOptionSelect(e,t)}static#s=(()=>dt7948.n(this.prototype,"sendRank",[s.action]))()
get rankedChoiceDropdownContent(){let e=[]
return e.push({id:0,name:(0,u.i18n)("poll.options.ranked_choice.abstain")}),this.args.options.forEach(((t,l)=>{t.rank=0
let o=""
0===l&&(o=` ${(0,u.i18n)("poll.options.ranked_choice.highest_priority")}`),l===this.args.options.length-1&&(o=` ${(0,u.i18n)("poll.options.ranked_choice.lowest_priority")}`),e.push({id:l+1,name:(l+1).toString()+o})})),e}static#n=(()=>(0,d.setComponentTemplate)((0,h.createTemplateFactory)({id:"7AdGjy3/",block:'[[[1,"\\n "],[10,"ul"],[15,0,[28,[32,0],[[52,[30,1],"ranked-choice-poll-options"],"options"],null]],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,2]],null]],null],"rank",[[[41,[30,1],[[[1," "],[8,[32,1],null,[["@option","@rankedChoiceDropdownContent","@sendRank"],[[30,3],[30,0,["rankedChoiceDropdownContent"]],[30,0,["sendRank"]]]],null],[1,"\\n"]],[]],[[[1," "],[10,"li"],[15,"data-poll-option-id",[30,3,["id"]]],[12],[1,"\\n"],[41,[30,0,["currentUser"]],[[[1," "],[11,"button"],[4,[32,2],["click",[28,[32,3],[[30,0,["sendClick"]],[30,3]],null]],null],[12],[1,"\\n"],[41,[28,[30,0,["isChosen"]],[[30,3]],null],[[[41,[30,4],[[[1," "],[1,[28,[32,4],["far-square-check"],null]],[1,"\\n"]],[]],[[[1," "],[1,[28,[32,4],["circle"],null]],[1,"\\n"]],[]]]],[]],[[[41,[30,4],[[[1," "],[1,[28,[32,4],["far-square"],null]],[1,"\\n"]],[]],[[[1," "],[1,[28,[32,4],["far-circle"],null]],[1,"\\n"]],[]]]],[]]],[1," "],[10,1],[14,0,"option-text"],[12],[1,[28,[32,5],[[30,3,["html"]]],null]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],[[[1," "],[10,"button"],[15,"onclick",[28,[32,6],["showLogin"],null]],[12],[1,"\\n"],[41,[28,[30,0,["isChosen"]],[[30,3]],null],[[[41,[30,4],[[[1," "],[1,[28,[32,4],["far-square-check"],null]],[1,"\\n"]],[]],[[[1," "],[1,[28,[32,4],["circle"],null]],[1,"\\n"]],[]]]],[]],[[[41,[30,4],[[[1," "],[1,[28,[32,4],["far-square"],null]],[1,"\\n"]],[]],[[[1," "],[1,[28,[32,4],["far-circle"],null]],[1,"\\n"]],[]]]],[]]],[1," "],[10,1],[14,0,"option-text"],[12],[1,[28,[32,5],[[30,3,["html"]]],null]],[13],[1,"\\n "],[13],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n"]],[]]]],[3]],null],[1," "],[13],[1,"\\n "]],["@isRankedChoice","@options","option","@isCheckbox"],false,["if","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/components/poll-options.js",scope:()=>[r.default,c.default,o.on,l.fn,p.default,i.htmlSafe,a.default],isStrictMode:!0}),this))()}e.default=m})),define("discourse/plugins/poll/discourse/components/poll-results-pie",["exports","@glimmer/component","@ember/object","@ember/render-modifiers/modifiers/did-insert","@ember/template","ember-modifier","discourse/lib/load-script","discourse/plugins/poll/lib/chart-colors","discourse/plugins/poll/discourse/components/modal/poll-ui-builder","@ember/component","@ember/template-factory"],(function(e,t,l,o,s,n,i,r,a,p,u){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class c extends t.default{htmlLegendPlugin={id:"htmlLegend",afterUpdate(e,t,l){const o=document.getElementById(l.containerID)
if(!o)return
o.innerHTML=""
e.options.plugins.legend.labels.generateLabels(e).forEach((t=>{const l=document.createElement("li")
l.classList.add("legend"),l.onclick=()=>{e.toggleDataVisibility(t.index),e.update()}
const s=document.createElement("span")
s.classList.add("swatch"),s.style.background=t.fillStyle
const n=document.createElement("span")
n.style.color=t.fontColor,n.innerHTML=t.text,e.getDataVisibility(t.index)?l.style.opacity=1:l.style.opacity=.2,l.appendChild(s),l.appendChild(n),o.appendChild(l)}))}}
stripHtml=e=>(new DOMParser).parseFromString(e,"text/html").body.textContent||""
pieChartConfig=(()=>{var e=this
return function(t,l){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}
const s="aspectRatio"in o?o.aspectRatio:2.2,n=l.map((t=>e.stripHtml(t)))
return{type:a.PIE_CHART_TYPE,data:{datasets:[{data:t,backgroundColor:(0,r.getColors)(t.length)}],labels:n},plugins:[e.htmlLegendPlugin],options:{responsive:!0,aspectRatio:s,animation:{duration:0},plugins:{legend:{labels:{generateLabels:()=>l.map(((e,l)=>({fillStyle:(0,r.getColors)(t.length)[l],text:e,index:l})))},display:!1},htmlLegend:{containerID:o?.legendContainerId}}}}}})()
registerLegendElement=(()=>(0,n.modifier)((e=>{this.legendElement=e})))()
registerCanvasElement=(()=>(0,n.modifier)((e=>{this.canvasElement=e})))()
get canvasId(){return(0,s.htmlSafe)(`poll-results-chart-${this.args.id}`)}get legendId(){return(0,s.htmlSafe)(`poll-results-legend-${this.args.id}`)}async drawPie(){await(0,i.default)("/javascripts/Chart.min.js")
const e=this.args.options.mapBy("votes"),t=this.args.options.mapBy("html"),l=this.pieChartConfig(e,t,{legendContainerId:this.legendElement.id}),o=this.canvasElement
this._chart=new Chart(o.getContext("2d"),l)}static#e=(()=>dt7948.n(this.prototype,"drawPie",[l.action]))()
static#l=(()=>(0,p.setComponentTemplate)((0,u.createTemplateFactory)({id:"BTeq5Fu6",block:'[[[1,"\\n "],[10,0],[14,0,"poll-results-chart"],[12],[1,"\\n "],[11,"canvas"],[16,1,[30,0,["canvasId"]]],[24,0,"poll-results-canvas"],[4,[32,0],[[30,0,["drawPie"]]],null],[4,[32,0],[[30,0,["registerCanvasElement"]]],null],[12],[13],[1,"\\n "],[11,"ul"],[16,1,[30,0,["legendId"]]],[24,0,"pie-chart-legends"],[4,[32,0],[[30,0,["registerLegendElement"]]],null],[12],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "]],[],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/components/poll-results-pie.js",scope:()=>[o.default],isStrictMode:!0}),this))()}e.default=c})),define("discourse/plugins/poll/discourse/components/poll-results-ranked-choice",["exports","@glimmer/component","@ember/template","discourse-i18n","@ember/component","@ember/template-factory"],(function(e,t,l,o,s,n){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class i extends t.default{get rankedChoiceWinnerText(){return(0,l.htmlSafe)((0,o.i18n)("poll.ranked_choice.winner",{count:this.args.rankedChoiceOutcome?.round_activity?.length,winner:this.args.rankedChoiceOutcome?.winning_candidate?.html}))}get rankedChoiceTiedText(){return(0,o.i18n)("poll.ranked_choice.tied",{count:this.args.rankedChoiceOutcome?.round_activity?.length})}static#e=(()=>(0,s.setComponentTemplate)((0,n.createTemplateFactory)({id:"Ukq1ey4u",block:'[[[1,"\\n "],[10,"h3"],[14,0,"poll-results-ranked-choice-subtitle-rounds"],[12],[1,"\\n "],[1,[28,[32,0],["poll.ranked_choice.title.rounds"],null]],[1,"\\n "],[13],[1,"\\n "],[10,"table"],[14,0,"poll-results-ranked-choice"],[12],[1,"\\n "],[10,"thead"],[12],[1,"\\n "],[10,"tr"],[12],[1,"\\n "],[10,"th"],[12],[1,[28,[32,0],["poll.ranked_choice.round"],null]],[13],[1,"\\n "],[10,"th"],[12],[1,[28,[32,0],["poll.ranked_choice.majority"],null]],[13],[1,"\\n "],[10,"th"],[12],[1,[28,[32,0],["poll.ranked_choice.eliminated"],null]],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"tbody"],[12],[1,"\\n"],[41,[30,1],[[[42,[28,[31,2],[[28,[31,2],[[30,1,["round_activity"]]],null]],null],null,[[[41,[30,2,["majority"]],[[[1," "],[10,"tr"],[12],[1,"\\n "],[10,"td"],[12],[1,[30,2,["round"]]],[13],[1,"\\n "],[10,"td"],[12],[1,[28,[32,1],[[30,2,["majority","html"]]],null]],[13],[1,"\\n "],[10,"td"],[12],[1,[28,[32,0],["poll.ranked_choice.none"],null]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],[[[1," "],[10,"tr"],[12],[1,"\\n "],[10,"td"],[12],[1,[30,2,["round"]]],[13],[1,"\\n "],[10,"td"],[12],[1,[28,[32,0],["poll.ranked_choice.none"],null]],[13],[1,"\\n "],[10,"td"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,2,["eliminated"]]],null]],null],null,[[[1," "],[1,[28,[32,1],[[30,3,["html"]]],null]],[1,"\\n"]],[3]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"]],[]]]],[2]],null]],[]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"h3"],[14,0,"poll-results-ranked-choice-subtitle-outcome"],[12],[1,"\\n "],[1,[28,[32,0],["poll.ranked_choice.title.outcome"],null]],[1,"\\n "],[13],[1,"\\n"],[41,[30,1],[[[41,[30,1,["tied"]],[[[1," "],[10,1],[14,0,"poll-results-ranked-choice-info"],[12],[1,[30,0,["rankedChoiceTiedText"]]],[13],[1,"\\n "],[10,"ul"],[14,0,"poll-results-ranked-choice-tied-candidates"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,1,["tied_candidates"]]],null]],null],null,[[[1," "],[10,"li"],[14,0,"poll-results-ranked-choice-tied-candidate"],[12],[1,[28,[32,1],[[30,4,["html"]]],null]],[13],[1,"\\n"]],[4]],null],[1," "],[13],[1,"\\n"]],[]],[[[1," "],[10,1],[14,0,"poll-results-ranked-choice-info"],[12],[1,[30,0,["rankedChoiceWinnerText"]]],[13],[1,"\\n"]],[]]]],[]],null],[1," "]],["@rankedChoiceOutcome","round","eliminated","tied_candidate"],false,["if","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/components/poll-results-ranked-choice.js",scope:()=>[o.i18n,l.htmlSafe],isStrictMode:!0}),this))()}e.default=i})),define("discourse/plugins/poll/discourse/components/poll-results-standard",["exports","@glimmer/component","@ember/helper","@ember/template","discourse-i18n","discourse/plugins/poll/lib/even-round","discourse/plugins/poll/discourse/components/poll-voters","@ember/component","@ember/template-factory"],(function(e,t,l,o,s,n,i,r,a){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class p extends t.default{orderOptions=e=>(e.forEach((e=>{e.votes=e.votes??0})),e.sort(((e,t)=>e.votes0===t?Array(e.length).fill(0):e.map((e=>100*e.votes/t))
roundPercentages=e=>this.isMultiple?e.map(Math.floor):(0,n.default)(e)
enrichOptions=(e,t)=>(e.forEach(((e,l)=>{const o=t[l].toString(),s=(this.args.vote||[]).includes(e.id)
e.percentage=o,e.chosen=s
let n=this.args.isPublic?this.args.voters?.[e.id]?.voters??[]:[]
e.voters=[...n],e.loading=!!this.args.isPublic&&(this.args.voters?.[e.id]?.loading??!1)})),e)
get votersCount(){return this.args.votersCount||0}get orderedOptions(){const e=this.orderOptions([...this.args.options]),t=this.getPercentages(e,this.votersCount),l=this.roundPercentages(t)
return this.enrichOptions(e,l)}get isMultiple(){return"multiple"===this.args.pollType}static#e=(()=>(0,r.setComponentTemplate)((0,a.createTemplateFactory)({id:"ENOttPkH",block:'[[[1,"\\n "],[10,"ul"],[14,0,"results"],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["orderedOptions"]]],null]],null],"voters",[[[1," "],[10,"li"],[15,0,[52,[30,1,["chosen"]],"chosen",""]],[12],[1,"\\n "],[10,0],[14,0,"option"],[12],[1,"\\n "],[10,2],[12],[1,"\\n"],[41,[51,[30,2]],[[[41,[30,3],[[[1," "],[10,1],[14,0,"absolute"],[12],[1,[28,[32,0],["poll.votes"],[["count"],[[30,1,["votes"]]]]]],[13],[1,"\\n"]],[]],[[[1," "],[10,1],[14,0,"percentage"],[12],[1,[28,[32,0],["number.percent"],[["count"],[[30,1,["percentage"]]]]]],[13],[1,"\\n"]],[]]]],[]],null],[1," "],[10,1],[14,0,"option-text"],[12],[1,[28,[32,1],[[30,1,["html"]]],null]],[13],[1,"\\n "],[13],[1,"\\n"],[41,[51,[30,2]],[[[1," "],[10,0],[14,0,"bar-back"],[12],[1,"\\n "],[10,0],[14,0,"bar"],[15,5,[28,[32,1],[[28,[32,2],["width:",[30,1,["percentage"]],"%"],null]],null]],[12],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[41,[30,4],[[[1," "],[8,[32,3],null,[["@postId","@pollType","@optionId","@pollName","@isRankedChoice","@totalVotes","@voters","@fetchVoters","@loading"],[[30,5],[30,6],[30,1,["id"]],[30,7],[30,2],[30,1,["votes"]],[30,1,["voters"]],[30,8],[30,1,["loading"]]]],null],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"]],[1]],null],[1," "],[13],[1,"\\n "]],["option","@isRankedChoice","@showTally","@isPublic","@postId","@pollType","@pollName","@fetchVoters"],false,["each","-track-array","if","unless"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/components/poll-results-standard.js",scope:()=>[s.i18n,o.htmlSafe,l.concat,i.default],isStrictMode:!0}),this))()}e.default=p})),define("discourse/plugins/poll/discourse/components/poll-results-tabs",["exports","@glimmer/component","@glimmer/tracking","@ember/helper","@ember/object","truth-helpers","discourse/components/d-button","discourse-i18n","discourse/plugins/poll/discourse/components/poll-results-ranked-choice","discourse/plugins/poll/discourse/components/poll-results-standard","@ember/component","@ember/template-factory"],(function(e,t,l,o,s,n,i,r,a,p,u,c){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class d extends t.default{static#e=(()=>dt7948.g(this.prototype,"activeTab",[l.tracked]))()
#B=(()=>{dt7948.i(this,"activeTab")})()
tabOne=(()=>(0,r.i18n)("poll.results.tabs.votes"))()
tabTwo=(()=>(0,r.i18n)("poll.results.tabs.outcome"))()
constructor(){super(...arguments),this.activeTab=this.args.isRankedChoice&&this.args.isPublic?this.tabs[1]:this.tabs[0]}get tabs(){let e=[]
return(!this.args.isRankedChoice||this.args.isRankedChoice&&this.args.isPublic)&&e.push(this.tabOne),this.args.isRankedChoice&&e.push(this.tabTwo),e}selectTab(e){this.activeTab=e}static#l=(()=>dt7948.n(this.prototype,"selectTab",[s.action]))()
static#s=(()=>(0,u.setComponentTemplate)((0,c.createTemplateFactory)({id:"y0Px/I7+",block:'[[[1,"\\n "],[10,0],[14,0,"tab-container"],[12],[1,"\\n "],[10,"ul"],[14,0,"tabs nav nav-items"],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["tabs"]]],null]],null],null,[[[1," "],[10,"li"],[15,0,[29,["tab nav-item ",[52,[28,[32,0],[[30,1],[30,0,["activeTab"]]],null],"active"]]]],[12],[1,"\\n "],[8,[32,1],[[24,0,"nav-btn"]],[["@action"],[[28,[32,2],[[30,0,["selectTab"]],[30,1]],null]]],[["default"],[[[[1,"\\n "],[1,[30,1]],[1,"\\n "]],[]]]]],[1,"\\n "],[13],[1,"\\n"]],[1]],null],[1," "],[13],[1,"\\n "],[10,0],[14,0,"tab-content"],[12],[1,"\\n"],[41,[28,[32,0],[[30,0,["activeTab"]],[30,0,["tabOne"]]],null],[[[1," "],[8,[32,3],null,[["@options","@pollName","@pollType","@isPublic","@isRankedChoice","@postId","@vote","@voters","@votersCount","@fetchVoters","@showTally"],[[30,2],[30,3],[30,4],[30,5],[30,6],[30,7],[30,8],[30,9],[30,10],[30,11],[30,12]]],null],[1,"\\n"]],[]],null],[1,"\\n"],[41,[28,[32,0],[[30,0,["activeTab"]],[30,0,["tabTwo"]]],null],[[[1," "],[8,[32,4],null,[["@rankedChoiceOutcome"],[[30,13]]],null],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n "]],["tab","@options","@pollName","@pollType","@isPublic","@isRankedChoice","@postId","@vote","@voters","@votersCount","@fetchVoters","@showTally","@rankedChoiceOutcome"],false,["each","-track-array","if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/components/poll-results-tabs.js",scope:()=>[n.eq,i.default,o.fn,p.default,a.default],isStrictMode:!0}),this))()}e.default=d})),define("discourse/plugins/poll/discourse/components/poll-voters-ranked-choice",["exports","@glimmer/component","truth-helpers","discourse/helpers/bound-avatar-template","discourse-common/helpers/d-icon","@ember/component","@ember/template-factory"],(function(e,t,l,o,s,n,i){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class r extends t.default{groupVotersByRank=e=>e.reduce(((e,t)=>{const l=t.rank
return e[l]??=[],e[l].push(t),e}),{})
get rankedChoiceVoters(){const e=[...this.args.voters],t=this.groupVotersByRank(e)
return Object.keys(t).map((e=>({rank:e,voters:t[e]})))}static#e=(()=>(0,n.setComponentTemplate)((0,i.createTemplateFactory)({id:"+tq7blyY",block:'[[[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["rankedChoiceVoters"]]],null]],null],null,[[[1," "],[10,"ul"],[12],[1,"\\n"],[41,[28,[32,0],[[30,1,["rank"]],"Abstain"],null],[[[1," "],[10,1],[14,0,"rank"],[12],[1,[28,[32,1],["ban"],null]],[13],[1,"\\n"]],[]],[[[1," "],[10,1],[14,0,"rank"],[12],[1,[30,1,["rank"]]],[13],[1,"\\n"]],[]]],[42,[28,[31,1],[[28,[31,1],[[30,1,["voters"]]],null]],null],null,[[[1," "],[10,"li"],[12],[1,"\\n "],[10,3],[15,"data-user-card",[30,2,["user","username"]]],[12],[1,[28,[32,2],[[30,2,["user","avatar_template"]],"tiny"],[["usernamePath","namePath","title"],[[30,2,["user","username"]],[30,2,["user","name"]],[30,2,["user","username"]]]]]],[13],[1,"\\n "],[13],[1,"\\n"]],[2]],null],[1," "],[13],[1,"\\n"]],[1]],null],[1," "]],["rank","voter"],false,["each","-track-array","if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/components/poll-voters-ranked-choice.js",scope:()=>[l.eq,s.default,o.default],isStrictMode:!0}),this))()}e.default=r})),define("discourse/plugins/poll/discourse/components/poll-voters",["exports","@glimmer/component","@ember/helper","discourse/components/conditional-loading-spinner","discourse/components/d-button","discourse/helpers/bound-avatar-template","discourse/plugins/poll/discourse/components/poll-voters-ranked-choice","@ember/component","@ember/template-factory"],(function(e,t,l,o,s,n,i,r,a){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class p extends t.default{get showMore(){return this.args.voters.length(0,r.setComponentTemplate)((0,a.createTemplateFactory)({id:"+C3LhZYa",block:'[[[1,"\\n "],[10,0],[14,0,"poll-voters"],[12],[1,"\\n "],[10,"ul"],[14,0,"poll-voters-list"],[12],[1,"\\n"],[41,[30,1],[[[1," "],[8,[32,0],null,[["@voters"],[[30,2]]],null],[1,"\\n"]],[]],[[[42,[28,[31,2],[[28,[31,2],[[30,2]],null]],null],null,[[[1," "],[10,"li"],[12],[1,"\\n "],[10,3],[15,"data-user-card",[30,3,["username"]]],[12],[1,[28,[32,1],[[30,3,["avatar_template"]],"tiny"],[["usernamePath","namePath","title"],[[30,3,["username"]],[30,3,["name"]],[30,3,["username"]]]]]],[13],[1,"\\n "],[13],[1,"\\n"]],[3]],null]],[]]],[1," "],[13],[1,"\\n"],[41,[30,0,["showMore"]],[[[1," "],[8,[32,2],null,[["@condition"],[[30,4]]],[["default"],[[[[1,"\\n "],[8,[32,3],[[24,0,"poll-voters-toggle-expand"]],[["@action","@icon"],[[28,[32,4],[[30,5],[30,6]],null],"chevron-down"]],null],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n "]],["@isRankedChoice","@voters","user","@loading","@fetchVoters","@optionId"],false,["if","each","-track-array"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/components/poll-voters.js",scope:()=>[i.default,n.default,o.default,s.default,l.fn],isStrictMode:!0}),this))()}e.default=p})),define("discourse/plugins/poll/discourse/components/poll",["exports","@glimmer/component","@glimmer/tracking","@ember/modifier","@ember/object","@ember/render-modifiers/modifiers/did-update","@ember/service","@ember/template","discourse/lib/ajax","discourse/lib/ajax-error","discourse/lib/round","discourse-common/helpers/d-icon","discourse-i18n","discourse/plugins/poll/discourse/components/modal/poll-breakdown","discourse/plugins/poll/discourse/components/modal/poll-ui-builder","discourse/plugins/poll/discourse/components/poll-buttons-dropdown","discourse/plugins/poll/discourse/components/poll-info","discourse/plugins/poll/discourse/components/poll-options","discourse/plugins/poll/discourse/components/poll-results-pie","discourse/plugins/poll/discourse/components/poll-results-tabs","@ember/component","@ember/template-factory"],(function(e,t,l,o,s,n,i,r,a,p,u,c,d,h,m,g,b,f,_,v,y,k){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const w="staff_only",C="ranked_choice",O="on_close",x="closed"
class T extends t.default{static#e=(()=>dt7948.g(this.prototype,"currentUser",[i.service]))()
#U=(()=>{dt7948.i(this,"currentUser")})()
static#l=(()=>dt7948.g(this.prototype,"siteSettings",[i.service]))()
#o=(()=>{dt7948.i(this,"siteSettings")})()
static#s=(()=>dt7948.g(this.prototype,"router",[i.service]))()
#H=(()=>{dt7948.i(this,"router")})()
static#n=(()=>dt7948.g(this.prototype,"appEvents",[i.service]))()
#Y=(()=>{dt7948.i(this,"appEvents")})()
static#i=(()=>dt7948.g(this.prototype,"dialog",[i.service]))()
#t=(()=>{dt7948.i(this,"dialog")})()
static#r=(()=>dt7948.g(this.prototype,"modal",[i.service]))()
#F=(()=>{dt7948.i(this,"modal")})()
static#h=(()=>dt7948.g(this.prototype,"vote",[l.tracked],(function(){return this.args.post.polls_votes?.[this.args.poll.name]||[]})))()
#G=(()=>{dt7948.i(this,"vote")})()
static#m=(()=>dt7948.g(this.prototype,"preloadedVoters",[l.tracked],(function(){return this.defaultPreloadedVoters()})))()
#$=(()=>{dt7948.i(this,"preloadedVoters")})()
static#g=(()=>dt7948.g(this.prototype,"voterListExpanded",[l.tracked],(function(){return!1})))()
#q=(()=>{dt7948.i(this,"voterListExpanded")})()
static#b=(()=>dt7948.g(this.prototype,"hasSavedVote",[l.tracked],(function(){return this.vote.length>0})))()
#K=(()=>{dt7948.i(this,"hasSavedVote")})()
static#f=(()=>dt7948.g(this.prototype,"showResults",[l.tracked],(function(){return!(this.poll.results===O&&!this.closed)&&(this.hasSavedVote||this.topicArchived&&!this.staffOnly||this.closed&&!this.staffOnly)})))()
#Z=(()=>{dt7948.i(this,"showResults")})()
static#_=(()=>dt7948.g(this.prototype,"showTally",[l.tracked],(function(){return!1})))()
#z=(()=>{dt7948.i(this,"showTally")})()
checkUserGroups=(e,t)=>{const l=t&&t.groups&&t.groups.split(",").map((e=>e.toLowerCase()))
if(!l)return!0
const o=e&&e.groups&&e.groups.map((e=>e.name.toLowerCase()))
return o&&l.some((e=>o.includes(e)))}
areRanksValid=e=>{let t=new Set,l=!1,o=!0
return e.forEach((e=>{const s=e.rank
if(0!==s){if(o=!1,t.has(s))return void(l=!0)
t.add(s)}})),!l&&!o}
_toggleOption=(()=>{var e=this
return function(t){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0
if(e.isMultiple){const l=e.vote.indexOf(t.id);-1!==l?e.vote.splice(l,1):e.vote.push(t.id)}else e.isRankedChoice?e.options.forEach((o=>{const s=e.vote.findIndex((e=>e.digest===o.id));-1===s?e.vote.push({digest:o.id,rank:o.id===t?l:0}):o.id===t&&(e.vote[s].rank=l)})):e.vote=[t.id]
e.vote=[...e.vote]}})()
get poll(){return this.args.poll}defaultPreloadedVoters(){const e={}
return this.poll.public&&this.poll.preloaded_voters&&Object.keys(this.poll.preloaded_voters).forEach((t=>{e[t]={voters:this.poll.preloaded_voters[t],loading:!1}})),this.options.forEach((t=>{e[t.id]||(e[t.id]={voters:[],loading:!1})})),e}get id(){return`${this.args.poll.name}-${this.args.post.id}`}get post(){return this.args.post}get groupableUserFields(){return this.siteSettings.poll_groupable_user_fields.split("|").filter(Boolean)}get isStaff(){return this.currentUser?.staff}get titleHTML(){return(0,r.htmlSafe)(this.args.titleHTML)}get topicArchived(){return this.post.get("topic.archived")}get isRankedChoice(){return this.poll.type===C}get staffOnly(){return this.poll.results===w}get isMultiple(){return"multiple"===this.poll.type}get isNumber(){return"number"===this.poll.type}get isMe(){return this.currentUser&&this.post.user_id===this.currentUser.id}get status(){return this.poll.status}async castVotes(e){if(this.canCastVotes&&this.currentUser)try{const{poll:e}=await(0,a.ajax)("/polls/vote",{type:"PUT",data:{post_id:this.post.id,poll_name:this.poll.name,options:this.vote}})
this.hasSavedVote=!0,Object.assign(this.poll,e),this.appEvents.trigger("poll:voted",e,this.post,this.vote),this.poll.results!==O&&(this.showResults=!0),this.poll.results===w&&(this.currentUser&&this.currentUser.staff?this.showResults=!0:this.showResults=!1)}catch(t){t?(this.isMultiple||this.isRankedChoice||this._toggleOption(e),(0,p.popupAjaxError)(t)):this.dialog.alert((0,d.i18n)("poll.error_while_casting_votes"))}}static#v=(()=>dt7948.n(this.prototype,"castVotes",[s.action]))()
get options(){let e=this.poll.options
return this.isRankedChoice&&e.forEach((e=>{const t=this.vote.findIndex((t=>t.digest===e.id))
e.rank=-1===t?0:this.vote[t].rank})),e}get voters(){return this.poll.voters}get rankedChoiceOutcome(){return this.poll.ranked_choice_outcome||null}get min(){let e=parseInt(this.poll.min,10)
return(isNaN(e)||e<0)&&(e=1),e}get max(){let e=parseInt(this.poll.max,10)
const t=this.poll.options.length
return(isNaN(e)||e>t)&&(e=t),e}get closed(){return this.status===x||this.isAutomaticallyClosed}get isAutomaticallyClosed(){return(this.poll.close??!1)&&moment.utc(this.poll.close,"YYYY-MM-DD HH:mm:ss Z")<=moment()}get hasVoted(){return this.vote?.length>0}get hideResultsDisabled(){return!this.staffOnly&&(this.closed||this.topicArchived)}toggleOption(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0
if(!this.closed&&this.currentUser&&this.checkUserGroups(this.currentUser,this.poll)){if(!this.isMultiple&&!this.isRankedChoice&&1===this.vote.length&&this.vote[0]===e.id)return this.removeVote()
this.isMultiple||this.isRankedChoice||(this.vote.length=0),this._toggleOption(e,t),this.isMultiple||this.isRankedChoice||this.castVotes(e)}}static#y=(()=>dt7948.n(this.prototype,"toggleOption",[s.action]))()
toggleResults(){this.showResults=!this.showResults}static#k=(()=>dt7948.n(this.prototype,"toggleResults",[s.action]))()
get canCastVotes(){if(this.closed||!this.currentUser)return!1
const e=this.vote?.length||0
return this.isMultiple?e>=this.min&&e<=this.max:this.isRankedChoice?this.options.length===this.vote?.length&&this.areRanksValid(this.vote):e>0}get notInVotingGroup(){return!this.checkUserGroups(this.currentUser,this.poll)}get pollGroups(){return(0,d.i18n)("poll.results.groups.title",{groups:this.poll.groups})}get showCastVotesButton(){return(this.isMultiple||this.isRankedChoice)&&!this.showResults}get castVotesButtonClass(){return"btn cast-votes "+(this.canCastVotes?"btn-primary":"btn-default")}get castVotesButtonIcon(){return this.castVotesDisabled?"far-square":"check"}get castVotesDisabled(){return!this.canCastVotes}get showHideResultsButton(){return this.showResults&&!this.hideResultsDisabled}get showShowResultsButton(){return!(this.showResults||this.hideResultsDisabled||"on_vote"===this.poll.results&&!this.hasSavedVote&&!this.isMe||this.poll.results===O&&!this.closed||this.poll.results===w&&!this.isStaff||!(this.voters>0))}get showRemoveVoteButton(){return!this.showResults&&!this.closed&&!this.hideResultsDisabled&&this.hasSavedVote}get isCheckbox(){return this.isMultiple}get resultsWidgetTypeClass(){const e=this.poll.type
return this.isNumber||this.poll.chart_type!==m.PIE_CHART_TYPE?`discourse-poll-${e}-results`:"discourse-poll-pie-chart"}get resultsPie(){return this.poll.chart_type===m.PIE_CHART_TYPE}get averageRating(){const e=this.options.reduce(((e,t)=>e+parseInt(t.html,10)*parseInt(t.votes,10)),0),t=0===this.voters?0:(0,u.default)(e/this.voters,-2)
return(0,r.htmlSafe)((0,d.i18n)("poll.average_rating",{average:t}))}get availableDisplayMode(){return this.showResults&&this.poll.chart_type!==m.PIE_CHART_TYPE&&[m.REGULAR_POLL_TYPE,m.MULTIPLE_POLL_TYPE].includes(this.poll.type)?this.showTally?"showPercentage":"showTally":null}updatedVoters(){this.voterListExpanded||(this.preloadedVoters=this.defaultPreloadedVoters())}static#w=(()=>dt7948.n(this.prototype,"updatedVoters",[s.action]))()
fetchVoters(e){let t,l=this.preloadedVoters
e?(l[e].loading=!0,t=l[e]?.voters):t=l,this.preloadedVoters=Object.assign({},l)
const o=t?.length
return(0,a.ajax)("/polls/voters.json",{data:{post_id:this.post.id,poll_name:this.poll.name,option_id:e,page:Math.floor(o/25)+1,limit:25}}).then((o=>{this.voterListExpanded=!0
const s=e?o.voters[e]:o.voters
let n=new Set([])
this.isRankedChoice?(n=new Set(t.map((e=>e.user.username))),s.forEach((e=>{n.has(e.user.username)||(n.add(e.user.username),t.push(e))}))):(n=new Set(t.map((e=>e.username))),s.forEach((e=>{n.has(e.username)||(n.add(e.username),t.push(e))})),"regular"===this.poll.type&&Object.keys(l).forEach((t=>{e!==t&&(l[t].voters=l[t].voters.filter((e=>!n.has(e.username))))})))})).catch((e=>{e?(0,p.popupAjaxError)(e):this.dialog.alert((0,d.i18n)("poll.error_while_fetching_voters"))})).finally((()=>{e&&(l[e].loading=!1),this.preloadedVoters=Object.assign({},l)}))}static#C=(()=>dt7948.n(this.prototype,"fetchVoters",[s.action]))()
dropDownClick(e){this[e]()}static#O=(()=>dt7948.n(this.prototype,"dropDownClick",[s.action]))()
removeVote(){return(0,a.ajax)("/polls/vote",{type:"DELETE",data:{post_id:this.post.id,poll_name:this.poll.name}}).then((e=>{let{poll:t}=e
this.poll.type===C&&t.options.forEach((e=>{e.rank=0})),this.vote=Object.assign([]),this.hasSavedVote=!1,this.appEvents.trigger("poll:voted",t,this.post,this.vote),this.showResults=!1})).catch((e=>(0,p.popupAjaxError)(e)))}static#x=(()=>dt7948.n(this.prototype,"removeVote",[s.action]))()
toggleStatus(){this.isAutomaticallyClosed||this.dialog.yesNoConfirm({message:(0,d.i18n)(this.closed?"poll.open.confirm":"poll.close.confirm"),didConfirm:()=>{const e=this.closed?"open":x;(0,a.ajax)("/polls/toggle_status",{type:"PUT",data:{post_id:this.post.id,poll_name:this.poll.name,status:e}}).then((()=>{this.poll.status=e,this.poll.results!==O&&"always"!==this.poll.results||(this.showResults=this.status===x),this.poll.results===O&&this.status===x&&this.router.refresh()})).catch((e=>{e?(0,p.popupAjaxError)(e):this.dialog.alert((0,d.i18n)("poll.error_while_toggling_status"))}))}})}static#T=(()=>dt7948.n(this.prototype,"toggleStatus",[s.action]))()
showBreakdown(){this.modal.show(h.default,{model:{poll:this.poll,post:this.post}})}static#M=(()=>dt7948.n(this.prototype,"showBreakdown",[s.action]))()
exportResults(){const e=this.poll.type===C?this.siteSettings.poll_export_ranked_choice_data_explorer_query_id:this.siteSettings.poll_export_data_explorer_query_id;(0,a.ajax)(`/admin/plugins/explorer/queries/${e}/run.csv`,{type:"POST",data:{params:JSON.stringify({poll_name:this.poll.name,post_id:this.post.id.toString()}),explain:!1,limit:1e6,download:1}}).then((e=>{const t=document.createElement("a"),l=new Blob([e],{type:"text/csv;charset=utf-8;"})
t.href=URL.createObjectURL(l),t.setAttribute("download",`poll-export-${this.poll.name}-${this.post.id}.csv`),t.click(),t.remove()})).catch((e=>{e?(0,p.popupAjaxError)(e):this.dialog.alert((0,d.i18n)("poll.error_while_exporting_results"))}))}static#P=(()=>dt7948.n(this.prototype,"exportResults",[s.action]))()
toggleDisplayMode(){this.showTally=!this.showTally}static#R=(()=>dt7948.n(this.prototype,"toggleDisplayMode",[s.action]))()
static#S=(()=>(0,y.setComponentTemplate)((0,k.createTemplateFactory)({id:"Nhwy9swv",block:'[[[1,"\\n "],[10,0],[14,0,"poll"],[12],[1,"\\n "],[11,0],[24,0,"poll-container"],[4,[32,0],[[30,0,["updatedVoters"]],[30,0,["poll","preloaded_voters"]]],null],[12],[1,"\\n "],[1,[30,0,["titleHTML"]]],[1,"\\n"],[41,[30,0,["notInVotingGroup"]],[[[1," "],[10,0],[14,0,"alert alert-danger"],[12],[1,[30,0,["pollGroups"]]],[13],[1,"\\n"]],[]],null],[41,[30,0,["showResults"]],[[[1," "],[10,0],[15,0,[30,0,["resultsWidgetTypeClass"]]],[12],[1,"\\n"],[41,[30,0,["isNumber"]],[[[1," "],[10,1],[12],[1,[30,0,["averageRating"]]],[13],[1,"\\n"]],[]],[[[41,[30,0,["resultsPie"]],[[[1," "],[8,[32,1],null,[["@id","@options"],[[30,0,["id"]],[30,0,["options"]]]],null],[1,"\\n"]],[]],[[[1," "],[8,[32,2],null,[["@options","@pollName","@pollType","@isRankedChoice","@isPublic","@postId","@vote","@voters","@votersCount","@fetchVoters","@rankedChoiceOutcome","@showTally"],[[30,0,["options"]],[30,0,["poll","name"]],[30,0,["poll","type"]],[30,0,["isRankedChoice"]],[30,0,["poll","public"]],[30,0,["post","id"]],[30,0,["vote"]],[30,0,["preloadedVoters"]],[30,0,["poll","voters"]],[30,0,["fetchVoters"]],[30,0,["rankedChoiceOutcome"]],[30,0,["showTally"]]]],null],[1,"\\n"]],[]]]],[]]],[1," "],[13],[1,"\\n"]],[]],[[[1," "],[8,[32,3],null,[["@isCheckbox","@isRankedChoice","@options","@votes","@sendOptionSelect"],[[30,0,["isCheckbox"]],[30,0,["isRankedChoice"]],[30,0,["options"]],[30,0,["vote"]],[30,0,["toggleOption"]]]],null],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n "],[8,[32,4],null,[["@options","@min","@max","@isMultiple","@close","@closed","@results","@showResults","@postUserId","@isPublic","@hasVoted","@voters"],[[30,0,["options"]],[30,0,["min"]],[30,0,["max"]],[30,0,["isMultiple"]],[30,0,["close"]],[30,0,["closed"]],[30,0,["poll","results"]],[30,0,["showResults"]],[30,0,["poll","post","user_id"]],[30,0,["poll","public"]],[30,0,["hasVoted"]],[30,0,["voters"]]]],null],[1,"\\n "],[10,0],[14,0,"poll-buttons"],[12],[1,"\\n"],[41,[30,0,["showCastVotesButton"]],[[[1," "],[11,"button"],[16,0,[30,0,["castVotesButtonClass"]]],[16,"title",[28,[32,5],["poll.cast-votes.title"],null]],[16,"disabled",[30,0,["castVotesDisabled"]]],[4,[32,6],["click",[30,0,["castVotes"]]],null],[12],[1,"\\n "],[1,[28,[32,7],[[30,0,["castVotesButtonIcon"]]],null]],[1,"\\n "],[10,1],[14,0,"d-button-label"],[12],[1,[28,[32,5],["poll.cast-votes.label"],null]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["showHideResultsButton"]],[[[1," "],[11,"button"],[24,0,"btn btn-default toggle-results"],[16,"title",[28,[32,5],["poll.hide-results.title"],null]],[4,[32,6],["click",[30,0,["toggleResults"]]],null],[12],[1,"\\n "],[1,[28,[32,7],["chevron-left"],null]],[1,"\\n "],[10,1],[14,0,"d-button-label"],[12],[1,[28,[32,5],["poll.hide-results.label"],null]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["showShowResultsButton"]],[[[1," "],[11,"button"],[24,0,"btn btn-default toggle-results"],[16,"title",[28,[32,5],["poll.show-results.title"],null]],[4,[32,6],["click",[30,0,["toggleResults"]]],null],[12],[1,"\\n "],[1,[28,[32,7],["chart-bar"],null]],[1,"\\n "],[10,1],[14,0,"d-button-label"],[12],[1,[28,[32,5],["poll.show-results.label"],null]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["showRemoveVoteButton"]],[[[1," "],[11,"button"],[24,0,"btn btn-default remove-vote"],[16,"title",[28,[32,5],["poll.remove-vote.title"],null]],[4,[32,6],["click",[30,0,["removeVote"]]],null],[12],[1,"\\n "],[1,[28,[32,7],["arrow-rotate-left"],null]],[1,"\\n "],[10,1],[14,0,"d-button-label"],[12],[1,[28,[32,5],["poll.remove-vote.label"],null]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n "],[8,[32,8],null,[["@closed","@voters","@isStaff","@isMe","@isRankedChoice","@topicArchived","@groupableUserFields","@isAutomaticallyClosed","@dropDownClick","@availableDisplayMode"],[[30,0,["closed"]],[30,0,["voters"]],[30,0,["isStaff"]],[30,0,["isMe"]],[30,0,["isRankedChoice"]],[30,0,["topicArchived"]],[30,0,["groupableUserFields"]],[30,0,["isAutomaticallyClosed"]],[30,0,["dropDownClick"]],[30,0,["availableDisplayMode"]]]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "]],[],false,["if"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/components/poll.js",scope:()=>[n.default,_.default,v.default,f.default,b.default,d.i18n,o.on,c.default,g.default],isStrictMode:!0}),this))()}e.default=T})),define("discourse/plugins/poll/discourse/initializers/add-poll-ui-builder",["exports","discourse/lib/plugin-api","discourse/plugins/poll/discourse/components/modal/poll-ui-builder"],(function(e,t,l){"use strict"
function o(e){e.addComposerToolbarPopupMenuOption({action:t=>{e.container.lookup("service:modal").show(l.default,{model:{toolbarEvent:t}})},icon:"chart-bar",label:"poll.ui_builder.title",condition:t=>{const l=e.container.lookup("service:site-settings"),o=e.getCurrentUser()
return l.poll_enabled&&(t.model.topic?.pm_with_non_human_user||o&&(o.staff||o.can_create_poll))}})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={name:"add-poll-ui-builder",initialize(){(0,t.withPluginApi)("1.14.0",o)}}})),define("discourse/plugins/poll/discourse/initializers/extend-for-poll",["exports","@glimmer/tracking","@ember/object","@ember-compat/tracked-built-ins","discourse/lib/plugin-api","discourse-common/utils/decorators","discourse/plugins/poll/discourse/components/modal/poll-ui-builder","discourse/plugins/poll/discourse/components/poll","@ember/component","@ember/template-factory","@ember/component/template-only"],(function(e,t,l,o,s,n,i,r,a,p,u){"use strict"
function c(e,t){let s=[...e.querySelectorAll(".poll")]
if(s=s.filter((e=>"BLOCKQUOTE"!==e.parentNode.tagName)),!s.length||!t)return
const n=t.getModel(),c=n.pollsObject
s.forEach((e=>{const s=e.dataset.pollName
let d=c[s],h=n
const m=e.closest(".expanded-quote")?.dataset.postId
if(m&&n.quoted[m]&&(h=l.default.create(n.quoted[m]),d=new o.TrackedObject(h.polls.find((e=>e.name===s)))),d){const l=e.querySelector(".poll-title")?.outerHTML,o=document.createElement("div")
Object.assign(o.dataset,{pollName:d.name,pollType:d.type}),o.classList.add("poll-outer"),d.chart_type===i.PIE_CHART_TYPE&&o.classList.add("pie"),e.replaceWith(o),t.renderGlimmer(o,(0,a.setComponentTemplate)((0,p.createTemplateFactory)({id:"5LFxqpVn",block:'[[[1,"\\n "],[8,[32,0],null,[["@poll","@post","@titleHTML"],[[32,1],[32,2],[32,3]]],null],[1,"\\n "]],[],false,[]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/poll/discourse/initializers/extend-for-poll.js",scope:()=>[r.default,d,n,l],isStrictMode:!0}),(0,u.default)(void 0,void 0)))}}))}function d(e){e.modifyClass("controller:topic",(e=>class extends e{subscribe(){super.subscribe(...arguments),this.messageBus.subscribe(`/polls/${this.model.id}`,this._onPollMessage)}unsubscribe(){this.messageBus.unsubscribe("/polls/*",this._onPollMessage),super.unsubscribe(...arguments)}_onPollMessage(e){const t=this.get("model.postStream").findLoadedPost(e.post_id)
t&&(t.polls=e.polls)}static#e=(()=>dt7948.n(this.prototype,"_onPollMessage",[n.bind]))()})),e.modifyClass("model:post",(e=>class extends e{static#e=(()=>dt7948.g(this.prototype,"pollsObject",[t.tracked],(function(){return new o.TrackedObject})))()
#W=(()=>{dt7948.i(this,"pollsObject")})()
static#l=(()=>dt7948.g(this.prototype,"_polls",[t.tracked]))()
#J=(()=>{dt7948.i(this,"_polls")})()
get polls(){return this._polls}set polls(e){this._polls=e,this._refreshPollsObject()}_refreshPollsObject(){for(const e of this.polls){const t=e.name
this.pollsObject[t]||=new o.TrackedObject,Object.assign(this.pollsObject[t],e)}}})),e.decorateCookedElement(c,{onlyStream:!0})
e.container.lookup("service:site-settings").poll_enabled&&e.addSearchSuggestion("in:polls")}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={name:"extend-for-poll",initialize(){(0,s.withPluginApi)("0.8.7",d)}}})),define("discourse/plugins/poll/lib/chart-colors",["exports"],(function(e){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.getColors=function(e,t){let l
switch(t=t||"cool"){case"cool":l={0:[255,255,255],25:[220,237,200],50:[66,179,213],75:[26,39,62],100:[0,0,0]}
break
case"warm":l={0:[255,255,255],25:[254,235,101],50:[228,82,27],75:[77,52,47],100:[0,0,0]}}let o,s,n=Object.keys(l),i=[]
for(let r=0;r=n[e]&&o{e.features.poll=t.poll_enabled,e.pollMaximumOptions=t.poll_maximum_options})),e.registerPlugin((e=>e.block.bbcode.ruler.push("poll",i)))}
/*!
* Joseph Myer's md5() algorithm wrapped in a self-invoked function to prevent
* global namespace pollution, modified to hash unicode characters as UTF-8.
*
* Copyright 1999-2010, Joseph Myers, Paul Johnston, Greg Holt, Will Bond
* http://www.myersdaily.org/joseph/javascript/md5-text.html
* http://pajhome.org.uk/crypt/md5
*
* Released under the BSD license
* http://www.opensource.org/licenses/bsd-license
*/
const l="data-poll-",o={name:"poll",status:"open"},s=["chartType","close","groups","max","min","name","order","public","results","status","step","type"]
function n(e,t,o){let s=e.push("poll_container_open","div",1)
s.attrs=[["class","poll-container"]],t.length>0&&(s=e.push("poll_title_open","div",1),s.attrs=[["class","poll-title"]],e.tokens.push(...t),e.push("poll_title_close","div",-1))
for(let n=0;nt>n&&"list_item_close"===e.type))
if(-1===e)continue
let t=o.slice(n,e+1).filter((e=>"text"===e.type||"inline"===e.type)).map((e=>e.content)).join(" "),s=function(e){for(let t=0;t>2]|=e.charCodeAt(t)<<(t%4<<3)
if(s[t>>2]|=128<<(t%4<<3),t>55)for(r(o,s),t=0;t<16;t++)s[t]=0
return s[14]=8*l,r(o,s),o}(JSON.stringify([t])))
o[n].attrs||=[],o[n].attrs.push([l+"option-id",s])}e.tokens.push(...o),e.push("poll_container_close","div",-1)}const i={tag:"poll",before(e,t){let{attrs:l}=t
e.tokens.filter((e=>"poll_open"===e.type)).length>e.tokens.filter((e=>"poll_close"===e.type)).length||(e.push("poll_open","div",1).poll_attrs={...o,...l})},after(e,o){if("poll_open"!==o.type)return
let i=o.poll_attrs,r=e.tokens.indexOf(o),a=e.tokens.slice(r+1),p=[]
if(a.length>0&&"heading_open"===a[0].type){let t=a.findIndex((e=>"heading_close"===e.type));-1!==t&&(p=a.splice(0,t+1).slice(1,-1),e.tokens.splice(r+1,t+1))}if("number"===i.type){let t=parseInt(i.min,10),l=parseInt(i.max,10),o=parseInt(i.step,10)
if(isNaN(t)&&(t=1),isNaN(l)&&(l=e.md.options.discourse.pollMaximumOptions),(isNaN(o)||o<1)&&(o=1),a.length>0)return void e.tokens.splice(r,1)
t<=l&&function(e,t,l,o,s){t.push(new e.Token("bullet_list_open","ul",1))
for(let n=l;n<=o;n+=s){t.push(new e.Token("list_item_open","li",1))
let l=new e.Token("text","",0)
l.content=String(n),t.push(l),t.push(new e.Token("list_item_close","li",-1))}t.push(new e.Token("bullet_list_close","ul",-1))}(e,a,t,l,o)}e.tokens.splice(r+1),o.attrs||=[],o.attrs.push(["class","poll"])
for(let t of s)i[t]&&o.attrs.push([l+t,i[t]])
a.length>0&&!a[0].type.endsWith("_list_open")||(n(e,p,a),function(e){let l=e.push("poll_info_open","div",1)
l.attrs=[["class","poll-info"]],l=e.push("poll_info_counts_open","div",1),l.attrs=[["class","poll-info_counts"]],l=e.push("poll_info_counts_count_open","div",1),l.attrs=[["class","poll-info_counts-count"]],l=e.push("poll_info_number_open","span",1),l.attrs=[["class","info-number"]],l.block=!1,l=e.push("text","",0),l.content="0",e.push("poll_info_number_close","span",-1),l=e.push("poll_info_label_open","span",1),l.attrs=[["class","info-label"]],l.block=!1,l=e.push("text","",0),l.content=(0,t.i18n)("poll.voters",{count:0}),e.push("poll_info_label_close","span",-1),e.push("poll_info_counts_count_close","div",-1),e.push("poll_info_counts_close","div",-1),e.push("poll_info_close","div",-1)}(e),e.push("poll_close","div",-1))}}
function r(e,t){let l=e[0],o=e[1],s=e[2],n=e[3]
l=p(l,o,s,n,t[0],7,-680876936),n=p(n,l,o,s,t[1],12,-389564586),s=p(s,n,l,o,t[2],17,606105819),o=p(o,s,n,l,t[3],22,-1044525330),l=p(l,o,s,n,t[4],7,-176418897),n=p(n,l,o,s,t[5],12,1200080426),s=p(s,n,l,o,t[6],17,-1473231341),o=p(o,s,n,l,t[7],22,-45705983),l=p(l,o,s,n,t[8],7,1770035416),n=p(n,l,o,s,t[9],12,-1958414417),s=p(s,n,l,o,t[10],17,-42063),o=p(o,s,n,l,t[11],22,-1990404162),l=p(l,o,s,n,t[12],7,1804603682),n=p(n,l,o,s,t[13],12,-40341101),s=p(s,n,l,o,t[14],17,-1502002290),o=p(o,s,n,l,t[15],22,1236535329),l=u(l,o,s,n,t[1],5,-165796510),n=u(n,l,o,s,t[6],9,-1069501632),s=u(s,n,l,o,t[11],14,643717713),o=u(o,s,n,l,t[0],20,-373897302),l=u(l,o,s,n,t[5],5,-701558691),n=u(n,l,o,s,t[10],9,38016083),s=u(s,n,l,o,t[15],14,-660478335),o=u(o,s,n,l,t[4],20,-405537848),l=u(l,o,s,n,t[9],5,568446438),n=u(n,l,o,s,t[14],9,-1019803690),s=u(s,n,l,o,t[3],14,-187363961),o=u(o,s,n,l,t[8],20,1163531501),l=u(l,o,s,n,t[13],5,-1444681467),n=u(n,l,o,s,t[2],9,-51403784)
s=u(s,n,l,o,t[7],14,1735328473),o=u(o,s,n,l,t[12],20,-1926607734),l=c(l,o,s,n,t[5],4,-378558),n=c(n,l,o,s,t[8],11,-2022574463),s=c(s,n,l,o,t[11],16,1839030562),o=c(o,s,n,l,t[14],23,-35309556),l=c(l,o,s,n,t[1],4,-1530992060),n=c(n,l,o,s,t[4],11,1272893353),s=c(s,n,l,o,t[7],16,-155497632),o=c(o,s,n,l,t[10],23,-1094730640),l=c(l,o,s,n,t[13],4,681279174),n=c(n,l,o,s,t[0],11,-358537222),s=c(s,n,l,o,t[3],16,-722521979),o=c(o,s,n,l,t[6],23,76029189),l=c(l,o,s,n,t[9],4,-640364487),n=c(n,l,o,s,t[12],11,-421815835),s=c(s,n,l,o,t[15],16,530742520),o=c(o,s,n,l,t[2],23,-995338651),l=d(l,o,s,n,t[0],6,-198630844),n=d(n,l,o,s,t[7],10,1126891415),s=d(s,n,l,o,t[14],15,-1416354905),o=d(o,s,n,l,t[5],21,-57434055),l=d(l,o,s,n,t[12],6,1700485571),n=d(n,l,o,s,t[3],10,-1894986606),s=d(s,n,l,o,t[10],15,-1051523),o=d(o,s,n,l,t[1],21,-2054922799),l=d(l,o,s,n,t[8],6,1873313359),n=d(n,l,o,s,t[15],10,-30611744),s=d(s,n,l,o,t[6],15,-1560198380),o=d(o,s,n,l,t[13],21,1309151649)
l=d(l,o,s,n,t[4],6,-145523070),n=d(n,l,o,s,t[11],10,-1120210379),s=d(s,n,l,o,t[2],15,718787259),o=d(o,s,n,l,t[9],21,-343485551),e[0]=b(l,e[0]),e[1]=b(o,e[1]),e[2]=b(s,e[2]),e[3]=b(n,e[3])}function a(e,t,l,o,s,n){return t=b(b(t,e),b(o,n)),b(t<>>32-s,l)}function p(e,t,l,o,s,n,i){return a(t&l|~t&o,e,t,s,n,i)}function u(e,t,l,o,s,n,i){return a(t&o|l&~o,e,t,s,n,i)}function c(e,t,l,o,s,n,i){return a(t^l^o,e,t,s,n,i)}function d(e,t,l,o,s,n,i){return a(l^(t|~o),e,t,s,n,i)}function h(e){let t,l=[]
for(t=0;t<64;t+=4)l[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24)
return l}let m="0123456789abcdef".split("")
function g(e){let t="",l=0
for(;l<4;l++)t+=m[e>>8*l+4&15]+m[e>>8*l&15]
return t}function b(e,t){return e+t&4294967295}})),define("discourse/plugins/poll/lib/even-round",["exports"],(function(e){"use strict"
function t(e){return 100===e.map((e=>Math.floor(e))).reduce(((e,t)=>e+t))}Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(e){let l=e.map((e=>e%1))
const o=Math.ceil(l.reduce(((e,t)=>e+t)))
for(let s=0,n=l.length;so&&(s=e,o=l[e])
if(++e[s],l[s]=0,t(e))break}return e.map((e=>Math.floor(e)))}}))
//# sourceMappingURL=poll-8b9247bf192631548d2ed46ca7df9e9e0a022aa64ea14f8a32799e8fa4616201.map
//!
;
Flash Sale Popup