{"version":3,"file":"discourse-feature-voting.js","names":["define","_exports","Object","defineProperty","value","default","_default","resource","path","map","this","route","resetNamespace","_I18n","_pluginApi","_navItem","name","initialize","withPluginApi","api","container","lookup","voting_enabled","sortOrders","pushObject","t","id","term","addNavigationBarItem","before","customFilter","category","can_vote","customHref","args","pathFor","forceActive","router","queryParams","currentRoute","keys","length","getCurrentUser","addSearchSuggestion","addPostClassesCallback","post","post_number","includePostAttributes","addTagsHtmlCallback","topic","buffer","title","user_voted","userVotedClass","push","url","vote_count","count","join","priority","addCategorySortCriteria","_userTopicList","_userAction","extend","userActionType","TYPES","topics","model","store","findFiltered","filter","modelFor","get","then","set","emptyState","user","isCurrentUser","username","body","_templateFactory","createTemplateFactory","block","moduleName","isStrictMode","_widget","_iconLibrary","createWidget","tagName","buildClasses","html","iconNode","click","sendWidgetAction","_ajax","_rawHtml","_ajaxError","buildKey","siteSettings","voting_show_who_voted","defaultState","allowClick","initialVote","attrs","state","contents","attach","votesAlert","currentUser","hideVotesAlert","scheduleRerender","clickOutside","addVote","ajax","type","data","topic_id","result","setProperties","votes_exceeded","votes_left","alert","who_voted","catch","popupAjaxError","removeVote","_virtualDom","buttonClass","closed","buildButtonTitle","h","attributes","className","$","cookie","window","location","href","parentWidget","toggleClass","addClass","_getUrl","whoVotedUsers","voteCount","toString","whoVoted","users","addSelf","liked","listClassName","getWhoVoted","toggle","hide","whoVotedAvatars","template","avatar_template","post_url","toLowerCase"],"sources":["discourse/plugins/discourse-topic-voting/discourse/feature-voting-route-map.js","discourse/plugins/discourse-topic-voting/discourse/initializers/discourse-topic-voting.js","discourse/plugins/discourse-topic-voting/discourse/pre-initializers/extend-category-for-voting.js","discourse/plugins/discourse-topic-voting/discourse/routes/user-activity-votes.js","discourse/plugins/discourse-topic-voting/discourse/templates/connectors/category-custom-settings/feature-voting-settings.js","discourse/plugins/discourse-topic-voting/discourse/templates/connectors/topic-above-post-stream/topic-title-voting.js","discourse/plugins/discourse-topic-voting/discourse/templates/connectors/user-activity-bottom/user-voted-topics.js","discourse/plugins/discourse-topic-voting/discourse/widgets/remove-vote.js","discourse/plugins/discourse-topic-voting/discourse/widgets/vote-box.js","discourse/plugins/discourse-topic-voting/discourse/widgets/vote-button.js","discourse/plugins/discourse-topic-voting/discourse/widgets/vote-count.js","discourse/plugins/discourse-topic-voting/discourse/widgets/vote-options.js"],"sourcesContent":["define(\"discourse/plugins/discourse-topic-voting/discourse/feature-voting-route-map\", [\"exports\"], function (_exports) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  0; //eaimeta@70e063a35619d71feaimeta@70e063a35619d71f\n  var _default = {\n    resource: \"user\",\n    path: \"users/:username\",\n    map() {\n      this.route(\"userActivity\", {\n        path: \"activity\",\n        resetNamespace: true\n      }, function () {\n        this.route(\"votes\");\n      });\n    }\n  };\n  _exports.default = _default;\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/initializers/discourse-topic-voting\", [\"exports\", \"I18n\", \"discourse/lib/plugin-api\", \"discourse/models/nav-item\"], function (_exports, _I18n, _pluginApi, _navItem) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  0; //eaimeta@70e063a35619d71f0,\"I18n\",0,\"discourse/lib/plugin-api\",0,\"discourse/models/nav-item\"eaimeta@70e063a35619d71f\n  var _default = {\n    name: \"discourse-topic-voting\",\n    initialize() {\n      (0, _pluginApi.withPluginApi)(\"0.8.32\", api => {\n        const siteSettings = api.container.lookup(\"site-settings:main\");\n        if (siteSettings.voting_enabled) {\n          const pageSearchController = api.container.lookup(\"controller:full-page-search\");\n          pageSearchController.sortOrders.pushObject({\n            name: _I18n.default.t(\"search.most_votes\"),\n            id: 5,\n            term: \"order:votes\"\n          });\n          api.addNavigationBarItem({\n            name: \"votes\",\n            before: \"top\",\n            customFilter: category => {\n              return category && category.can_vote;\n            },\n            customHref: (category, args) => {\n              const path = _navItem.default.pathFor(\"latest\", args);\n              return `${path}?order=votes`;\n            },\n            forceActive: (category, args, router) => {\n              const queryParams = router.currentRoute.queryParams;\n              return queryParams && Object.keys(queryParams).length === 1 && queryParams[\"order\"] === \"votes\";\n            }\n          });\n          api.addNavigationBarItem({\n            name: \"my_votes\",\n            before: \"top\",\n            customFilter: category => {\n              return category && category.can_vote && api.getCurrentUser();\n            },\n            customHref: (category, args) => {\n              const path = _navItem.default.pathFor(\"latest\", args);\n              return `${path}?state=my_votes`;\n            },\n            forceActive: (category, args, router) => {\n              const queryParams = router.currentRoute.queryParams;\n              return queryParams && Object.keys(queryParams).length === 1 && queryParams[\"state\"] === \"my_votes\";\n            }\n          });\n        }\n      });\n      (0, _pluginApi.withPluginApi)(\"0.11.7\", api => {\n        const siteSettings = api.container.lookup(\"site-settings:main\");\n        if (siteSettings.voting_enabled) {\n          api.addSearchSuggestion(\"order:votes\");\n        }\n      });\n    }\n  };\n  _exports.default = _default;\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/pre-initializers/extend-category-for-voting\", [\"exports\", \"I18n\", \"discourse/lib/plugin-api\"], function (_exports, _I18n, _pluginApi) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  0; //eaimeta@70e063a35619d71f0,\"I18n\",0,\"discourse/lib/plugin-api\"eaimeta@70e063a35619d71f\n  function initialize(api) {\n    api.addPostClassesCallback(post => {\n      if (post.post_number === 1 && post.can_vote) {\n        return [\"voting-post\"];\n      }\n    });\n    api.includePostAttributes(\"can_vote\");\n    api.addTagsHtmlCallback(topic => {\n      if (!topic.can_vote) {\n        return;\n      }\n      let buffer = [];\n      let title = \"\";\n      if (topic.user_voted) {\n        title = ` title='${_I18n.default.t(\"topic_voting.voted\")}'`;\n      }\n      let userVotedClass = topic.user_voted ? \" voted\" : \"\";\n      buffer.push(`<a href='${topic.url}' class='list-vote-count vote-count-${topic.vote_count} discourse-tag simple${userVotedClass}'${title}>`);\n      buffer.push(_I18n.default.t(\"topic_voting.votes\", {\n        count: topic.vote_count\n      }));\n      buffer.push(\"</a>\");\n      if (buffer.length > 0) {\n        return buffer.join(\"\");\n      }\n    }, {\n      priority: -100\n    });\n  }\n  var _default = {\n    name: \"extend-category-for-voting\",\n    before: \"inject-discourse-objects\",\n    initialize() {\n      (0, _pluginApi.withPluginApi)(\"0.8.4\", api => initialize(api));\n      (0, _pluginApi.withPluginApi)(\"0.8.30\", api => api.addCategorySortCriteria(\"votes\"));\n    }\n  };\n  _exports.default = _default;\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/routes/user-activity-votes\", [\"exports\", \"discourse/routes/user-topic-list\", \"discourse/models/user-action\", \"I18n\"], function (_exports, _userTopicList, _userAction, _I18n) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  0; //eaimeta@70e063a35619d71f0,\"discourse/routes/user-topic-list\",0,\"discourse/models/user-action\",0,\"I18n\"eaimeta@70e063a35619d71f\n  var _default = _userTopicList.default.extend({\n    userActionType: _userAction.default.TYPES.topics,\n    model() {\n      return this.store.findFiltered(\"topicList\", {\n        filter: \"topics/voted-by/\" + this.modelFor(\"user\").get(\"username_lower\")\n      }).then(model => {\n        model.set(\"emptyState\", this.emptyState());\n        return model;\n      });\n    },\n    emptyState() {\n      const user = this.modelFor(\"user\");\n      const title = this.isCurrentUser(user) ? _I18n.default.t(\"topic_voting.no_votes_title_self\") : _I18n.default.t(\"topic_voting.no_votes_title_others\", {\n        username: user.username\n      });\n      return {\n        title,\n        body: \"\"\n      };\n    }\n  });\n  _exports.default = _default;\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/category-custom-settings/feature-voting-settings\", [\"exports\", \"@ember/template-factory\"], function (_exports, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  0; //eaimeta@70e063a35619d71f0,\"ember-cli-htmlbars\"eaimeta@70e063a35619d71f\n  var _default = (0, _templateFactory.createTemplateFactory)(\n  /*\n    <h3>{{i18n \"topic_voting.title\"}}</h3>\n  <section class=\"field\">\n    <div class=\"enable-topic-voting\">\n      <label class=\"checkbox-label\">\n        {{input\n          type=\"checkbox\"\n          checked=category.custom_fields.enable_topic_voting\n        }}\n        {{i18n \"topic_voting.allow_topic_voting\"}}\n      </label>\n    </div>\n  </section>\n  */\n  {\n    \"id\": \"6T7wxruB\",\n    \"block\": \"[[[10,\\\"h3\\\"],[12],[1,[28,[35,0],[\\\"topic_voting.title\\\"],null]],[13],[1,\\\"\\\\n\\\"],[10,\\\"section\\\"],[14,0,\\\"field\\\"],[12],[1,\\\"\\\\n  \\\"],[10,0],[14,0,\\\"enable-topic-voting\\\"],[12],[1,\\\"\\\\n    \\\"],[10,\\\"label\\\"],[14,0,\\\"checkbox-label\\\"],[12],[1,\\\"\\\\n      \\\"],[1,[28,[35,1],null,[[\\\"type\\\",\\\"checked\\\"],[\\\"checkbox\\\",[33,2,[\\\"custom_fields\\\",\\\"enable_topic_voting\\\"]]]]]],[1,\\\"\\\\n      \\\"],[1,[28,[35,0],[\\\"topic_voting.allow_topic_voting\\\"],null]],[1,\\\"\\\\n    \\\"],[13],[1,\\\"\\\\n  \\\"],[13],[1,\\\"\\\\n\\\"],[13]],[],false,[\\\"i18n\\\",\\\"input\\\",\\\"category\\\"]]\",\n    \"moduleName\": \"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/category-custom-settings/feature-voting-settings.hbs\",\n    \"isStrictMode\": false\n  });\n  _exports.default = _default;\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/topic-above-post-stream/topic-title-voting\", [\"exports\", \"@ember/template-factory\"], function (_exports, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  0; //eaimeta@70e063a35619d71f0,\"ember-cli-htmlbars\"eaimeta@70e063a35619d71f\n  var _default = (0, _templateFactory.createTemplateFactory)(\n  /*\n    {{#if model.can_vote}}\n    {{#if model.postStream.loaded}}\n      {{#if model.postStream.firstPostPresent}}\n        <div class=\"voting title-voting\">\n          {{mount-widget\n            widget=\"vote-box\"\n            args=model\n            showLogin=(route-action \"showLogin\")\n          }}\n        </div>\n      {{/if}}\n    {{/if}}\n  {{/if}}\n  */\n  {\n    \"id\": \"HDYNfkBs\",\n    \"block\": \"[[[41,[33,1,[\\\"can_vote\\\"]],[[[41,[33,1,[\\\"postStream\\\",\\\"loaded\\\"]],[[[41,[33,1,[\\\"postStream\\\",\\\"firstPostPresent\\\"]],[[[1,\\\"      \\\"],[10,0],[14,0,\\\"voting title-voting\\\"],[12],[1,\\\"\\\\n        \\\"],[1,[28,[35,2],null,[[\\\"widget\\\",\\\"args\\\",\\\"showLogin\\\"],[\\\"vote-box\\\",[33,1],[28,[37,3],[\\\"showLogin\\\"],null]]]]],[1,\\\"\\\\n      \\\"],[13],[1,\\\"\\\\n\\\"]],[]],null]],[]],null]],[]],null]],[],false,[\\\"if\\\",\\\"model\\\",\\\"mount-widget\\\",\\\"route-action\\\"]]\",\n    \"moduleName\": \"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/topic-above-post-stream/topic-title-voting.hbs\",\n    \"isStrictMode\": false\n  });\n  _exports.default = _default;\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/user-activity-bottom/user-voted-topics\", [\"exports\", \"@ember/template-factory\"], function (_exports, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  0; //eaimeta@70e063a35619d71f0,\"ember-cli-htmlbars\"eaimeta@70e063a35619d71f\n  var _default = (0, _templateFactory.createTemplateFactory)(\n  /*\n    {{#if siteSettings.voting_show_votes_on_profile}}\n    {{#link-to \"userActivity.votes\"}}\n      {{d-icon \"heart\"}}\n      {{i18n \"topic_voting.vote_title_plural\"}}\n    {{/link-to}}\n  {{/if}}\n  */\n  {\n    \"id\": \"fopjXbCD\",\n    \"block\": \"[[[41,[33,1,[\\\"voting_show_votes_on_profile\\\"]],[[[6,[39,2],null,[[\\\"route\\\"],[\\\"userActivity.votes\\\"]],[[\\\"default\\\"],[[[[1,\\\"    \\\"],[1,[28,[35,3],[\\\"heart\\\"],null]],[1,\\\"\\\\n    \\\"],[1,[28,[35,4],[\\\"topic_voting.vote_title_plural\\\"],null]],[1,\\\"\\\\n\\\"]],[]]]]]],[]],null]],[],false,[\\\"if\\\",\\\"siteSettings\\\",\\\"link-to\\\",\\\"d-icon\\\",\\\"i18n\\\"]]\",\n    \"moduleName\": \"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/user-activity-bottom/user-voted-topics.hbs\",\n    \"isStrictMode\": false\n  });\n  _exports.default = _default;\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/widgets/remove-vote\", [\"exports\", \"I18n\", \"discourse/widgets/widget\", \"discourse-common/lib/icon-library\"], function (_exports, _I18n, _widget, _iconLibrary) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  0; //eaimeta@70e063a35619d71f0,\"I18n\",0,\"discourse/widgets/widget\",0,\"discourse-common/lib/icon-library\"eaimeta@70e063a35619d71f\n  var _default = (0, _widget.createWidget)(\"remove-vote\", {\n    tagName: \"div.remove-vote\",\n    buildClasses() {\n      return \"vote-option\";\n    },\n    html() {\n      return [(0, _iconLibrary.iconNode)(\"times\"), _I18n.default.t(\"topic_voting.remove_vote\")];\n    },\n    click() {\n      this.sendWidgetAction(\"removeVote\");\n    }\n  });\n  _exports.default = _default;\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/widgets/vote-box\", [\"exports\", \"I18n\", \"discourse/widgets/widget\", \"discourse/lib/ajax\", \"discourse/widgets/raw-html\", \"discourse/lib/ajax-error\"], function (_exports, _I18n, _widget, _ajax, _rawHtml, _ajaxError) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  0; //eaimeta@70e063a35619d71f0,\"I18n\",0,\"discourse/widgets/widget\",0,\"discourse/lib/ajax\",0,\"discourse/widgets/raw-html\",0,\"discourse/lib/ajax-error\"eaimeta@70e063a35619d71f\n  var _default = (0, _widget.createWidget)(\"vote-box\", {\n    tagName: \"div.voting-wrapper\",\n    buildKey: () => \"vote-box\",\n    buildClasses() {\n      if (this.siteSettings.voting_show_who_voted) {\n        return \"show-pointer\";\n      }\n    },\n    defaultState() {\n      return {\n        allowClick: true,\n        initialVote: false\n      };\n    },\n    html(attrs, state) {\n      let voteCount = this.attach(\"vote-count\", attrs);\n      let voteButton = this.attach(\"vote-button\", attrs);\n      let voteOptions = this.attach(\"vote-options\", attrs);\n      let contents = [voteCount, voteButton, voteOptions];\n      if (state.votesAlert > 0) {\n        const html = \"<div class='voting-popup-menu vote-options popup-menu'>\" + _I18n.default.t(\"topic_voting.votes_left\", {\n          count: state.votesAlert,\n          path: this.currentUser.get(\"path\") + \"/activity/votes\"\n        }) + \"</div>\";\n        contents.push(new _rawHtml.default({\n          html\n        }));\n      }\n      return contents;\n    },\n    hideVotesAlert() {\n      if (this.state.votesAlert) {\n        this.state.votesAlert = null;\n        this.scheduleRerender();\n      }\n    },\n    click() {\n      this.hideVotesAlert();\n    },\n    clickOutside() {\n      this.hideVotesAlert();\n    },\n    addVote() {\n      let topic = this.attrs;\n      let state = this.state;\n      return (0, _ajax.ajax)(\"/voting/vote\", {\n        type: \"POST\",\n        data: {\n          topic_id: topic.id\n        }\n      }).then(result => {\n        topic.set(\"vote_count\", result.vote_count);\n        topic.set(\"user_voted\", true);\n        this.currentUser.setProperties({\n          votes_exceeded: !result.can_vote,\n          votes_left: result.votes_left\n        });\n        if (result.alert) {\n          state.votesAlert = result.votes_left;\n        }\n        topic.set(\"who_voted\", result.who_voted);\n        state.allowClick = true;\n        this.scheduleRerender();\n      }).catch(_ajaxError.popupAjaxError);\n    },\n    removeVote() {\n      let topic = this.attrs;\n      let state = this.state;\n      return (0, _ajax.ajax)(\"/voting/unvote\", {\n        type: \"POST\",\n        data: {\n          topic_id: topic.id\n        }\n      }).then(result => {\n        topic.set(\"vote_count\", result.vote_count);\n        topic.set(\"user_voted\", false);\n        this.currentUser.setProperties({\n          votes_exceeded: !result.can_vote,\n          votes_left: result.votes_left\n        });\n        topic.set(\"who_voted\", result.who_voted);\n        state.allowClick = true;\n        this.scheduleRerender();\n      }).catch(_ajaxError.popupAjaxError);\n    }\n  });\n  _exports.default = _default;\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/widgets/vote-button\", [\"exports\", \"I18n\", \"discourse/widgets/widget\", \"virtual-dom\"], function (_exports, _I18n, _widget, _virtualDom) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  0; //eaimeta@70e063a35619d71f0,\"I18n\",0,\"discourse/widgets/widget\",0,\"virtual-dom\"eaimeta@70e063a35619d71f\n  var _default = (0, _widget.createWidget)(\"vote-button\", {\n    tagName: \"div\",\n    buildClasses(attrs) {\n      let buttonClass = \"\";\n      if (attrs.closed) {\n        buttonClass = \"voting-closed\";\n      } else {\n        if (!attrs.user_voted) {\n          buttonClass = \"nonvote\";\n        } else {\n          if (this.currentUser && this.currentUser.votes_exceeded) {\n            buttonClass = \"vote-limited nonvote\";\n          } else {\n            buttonClass = \"vote\";\n          }\n        }\n      }\n      if (this.siteSettings.voting_show_who_voted) {\n        buttonClass += \" show-pointer\";\n      }\n      return buttonClass;\n    },\n    buildButtonTitle(attrs) {\n      if (this.currentUser) {\n        if (attrs.closed) {\n          return _I18n.default.t(\"topic_voting.voting_closed_title\");\n        }\n        if (attrs.user_voted) {\n          return _I18n.default.t(\"topic_voting.voted_title\");\n        }\n        if (this.currentUser.votes_exceeded) {\n          return _I18n.default.t(\"topic_voting.voting_limit\");\n        }\n        return _I18n.default.t(\"topic_voting.vote_title\");\n      }\n      if (attrs.vote_count) {\n        return _I18n.default.t(\"topic_voting.anonymous_button\", {\n          count: attrs.vote_count\n        });\n      }\n      return _I18n.default.t(\"topic_voting.anonymous_button\", {\n        count: 1\n      });\n    },\n    html(attrs) {\n      return (0, _virtualDom.h)(\"button\", {\n        attributes: {\n          title: this.currentUser ? _I18n.default.t(\"topic_voting.votes_left_button_title\", {\n            count: this.currentUser.votes_left\n          }) : \"\"\n        },\n        className: \"btn btn-primary vote-button\"\n      }, this.buildButtonTitle(attrs));\n    },\n    click() {\n      if (!this.currentUser) {\n        this.sendWidgetAction(\"showLogin\");\n        $.cookie(\"destination_url\", window.location.href);\n        return;\n      }\n      if (!this.attrs.closed && this.parentWidget.state.allowClick && !this.attrs.user_voted && !this.currentUser.votes_exceeded) {\n        this.parentWidget.state.allowClick = false;\n        this.parentWidget.state.initialVote = true;\n        this.sendWidgetAction(\"addVote\");\n      }\n      if (this.attrs.user_voted || this.currentUser.votes_exceeded) {\n        $(\".vote-options\").toggleClass(\"hidden\");\n      }\n    },\n    clickOutside() {\n      $(\".vote-options\").addClass(\"hidden\");\n      this.parentWidget.state.initialVote = false;\n    }\n  });\n  _exports.default = _default;\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/widgets/vote-count\", [\"exports\", \"discourse/widgets/widget\", \"discourse-common/lib/get-url\", \"virtual-dom\", \"discourse/lib/ajax\"], function (_exports, _widget, _getUrl, _virtualDom, _ajax) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  0; //eaimeta@70e063a35619d71f0,\"discourse/widgets/widget\",0,\"discourse-common/lib/get-url\",0,\"virtual-dom\",0,\"discourse/lib/ajax\"eaimeta@70e063a35619d71f\n  var _default = (0, _widget.createWidget)(\"vote-count\", {\n    tagName: \"div.vote-count-wrapper\",\n    buildKey: () => \"vote-count\",\n    buildClasses() {\n      if (this.attrs.vote_count === 0) {\n        return \"no-votes\";\n      }\n    },\n    defaultState() {\n      return {\n        whoVotedUsers: null\n      };\n    },\n    html(attrs) {\n      let voteCount = (0, _virtualDom.h)(\"div.vote-count\", attrs.vote_count.toString());\n      let whoVoted = null;\n      if (this.siteSettings.voting_show_who_voted && this.state.whoVotedUsers && this.state.whoVotedUsers.length > 0) {\n        whoVoted = this.attach(\"small-user-list\", {\n          users: this.state.whoVotedUsers,\n          addSelf: attrs.liked,\n          listClassName: \"regular-votes\"\n        });\n      }\n      let buffer = [voteCount];\n      if (whoVoted) {\n        buffer.push((0, _virtualDom.h)(\"div.who-voted.popup-menu.voting-popup-menu\", [whoVoted]));\n      }\n      return buffer;\n    },\n    click() {\n      if (!this.currentUser) {\n        this.sendWidgetAction(\"showLogin\");\n        $.cookie(\"destination_url\", window.location.href);\n        return;\n      }\n      if (this.siteSettings.voting_show_who_voted && this.attrs.vote_count > 0) {\n        if (this.state.whoVotedUsers === null) {\n          return this.getWhoVoted();\n        } else {\n          $(\".who-voted\").toggle();\n        }\n      }\n    },\n    clickOutside() {\n      $(\".who-voted\").hide();\n    },\n    getWhoVoted() {\n      return (0, _ajax.ajax)(\"/voting/who\", {\n        type: \"GET\",\n        data: {\n          topic_id: this.attrs.id\n        }\n      }).then(users => {\n        this.state.whoVotedUsers = users.map(whoVotedAvatars);\n      });\n    }\n  });\n  _exports.default = _default;\n  function whoVotedAvatars(user) {\n    return {\n      template: user.avatar_template,\n      username: user.username,\n      post_url: user.post_url,\n      url: (0, _getUrl.default)(\"/u/\") + user.username.toLowerCase()\n    };\n  }\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/widgets/vote-options\", [\"exports\", \"I18n\", \"discourse/widgets/widget\", \"virtual-dom\"], function (_exports, _I18n, _widget, _virtualDom) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  0; //eaimeta@70e063a35619d71f0,\"I18n\",0,\"discourse/widgets/widget\",0,\"virtual-dom\"eaimeta@70e063a35619d71f\n  var _default = (0, _widget.createWidget)(\"vote-options\", {\n    tagName: \"div.vote-options\",\n    buildClasses() {\n      return \"voting-popup-menu popup-menu hidden\";\n    },\n    html(attrs) {\n      let contents = [];\n      if (attrs.user_voted) {\n        contents.push(this.attach(\"remove-vote\", attrs));\n      } else if (this.currentUser && this.currentUser.votes_exceeded && !attrs.user_voted) {\n        contents.push([(0, _virtualDom.h)(\"div\", _I18n.default.t(\"topic_voting.reached_limit\")), (0, _virtualDom.h)(\"p\", (0, _virtualDom.h)(\"a\", {\n          href: this.currentUser.get(\"path\") + \"/activity/votes\"\n        }, _I18n.default.t(\"topic_voting.list_votes\")))]);\n      }\n      return contents;\n    }\n  });\n  _exports.default = _default;\n});"],"mappings":"AAAAA,OAAA,oGAAAC,GACA;AAEAC,OAAAC,eAAAF,EAAA,cACAG,OAAA,IAEAH,EAAAI,aAAA;AAEA,IAAAC,EAAA,CACAC,SAAA,OACAC,KAAA,kBACAC,MACAC,KAAAC,MAAA,gBACAH,KAAA,WACAI,gBAAA,IACA,WACAF,KAAAC,MAAA,QACA,GACA;AAEAV,EAAAI,QAAAC,C,ICpBAN,OAAA,6KAAAC,EAAAY,EAAAC,EAAAC,GACA;AAEAb,OAAAC,eAAAF,EAAA,cACAG,OAAA,IAEAH,EAAAI,aAAA;AAEA,IAAAC,EAAA,CACAU,KAAA,yBACAC,cACA,EAAAH,EAAAI,eAAA,UAAAC,IAEA,GADAA,EAAAC,UAAAC,OAAA,sBACAC,eAAA,CACAH,EAAAC,UAAAC,OAAA,+BACAE,WAAAC,WAAA,CACAR,KAAAH,EAAAR,QAAAoB,EAAA,qBACAC,GAAA,EACAC,KAAA,gBAEAR,EAAAS,qBAAA,CACAZ,KAAA,QACAa,OAAA,MACAC,aAAAC,GACAA,KAAAC,SAEAC,WAAA,CAAAF,EAAAG,IAEA,GADAnB,EAAAV,QAAA8B,QAAA,SAAAD,iBAGAE,YAAA,CAAAL,EAAAG,EAAAG,KACA,MAAAC,EAAAD,EAAAE,aAAAD;AACA,OAAAA,GA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