{"version":3,"file":"discourse-topic-voting.js","names":["define","_exports","Object","defineProperty","value","default","resource","path","map","this","route","resetNamespace","_pluginApi","_navItem","_discourseI18n","name","initialize","withPluginApi","api","container","lookup","topic_voting_enabled","sortOrders","pushObject","i18n","id","term","addNavigationBarItem","before","customFilter","category","can_vote","customHref","args","pathFor","forceActive","router","queryParams","currentRoute","keys","length","getCurrentUser","addSearchSuggestion","registerValueTransformer","_ref","context","customFields","enable_topic_voting","push","addPostClassesCallback","post","post_number","includePostAttributes","addTagsHtmlCallback","topic","buffer","title","user_voted","userVotedClass","url","vote_count","count","join","priority","addCategorySortCriteria","addBehaviorTransformerName","_userAction","_userTopicList","UserActivityVotes","userActionType","TYPES","topics","model","store","findFiltered","filter","modelFor","get","then","set","emptyState","user","isCurrentUser","username","body","_templateFactory","createTemplateFactory","block","moduleName","isStrictMode","_iconLibrary","_widget","createWidget","tagName","buildClasses","html","iconNode","click","sendWidgetAction","_ajax","_ajaxError","_rawHtml","buildKey","siteSettings","topic_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","_cookie","_transformer","buttonClass","closed","buildButtonTitle","h","attributes","className","applyBehaviorTransformer","window","location","href","parentWidget","document","querySelector","classList","toggle","add","_getUrl","whoVotedUsers","voteCount","toString","whoVoted","users","addSelf","liked","listClassName","getWhoVoted","whoVotedElement","style","display","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/pre-initializers/transformers.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  var _default = _exports.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});","define(\"discourse/plugins/discourse-topic-voting/discourse/initializers/discourse-topic-voting\", [\"exports\", \"discourse/lib/plugin-api\", \"discourse/models/nav-item\", \"discourse-i18n\"], function (_exports, _pluginApi, _navItem, _discourseI18n) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = {\n    name: \"discourse-topic-voting\",\n    initialize() {\n      (0, _pluginApi.withPluginApi)(\"0.8.32\", api => {\n        const siteSettings = api.container.lookup(\"service:site-settings\");\n        if (siteSettings.topic_voting_enabled) {\n          const pageSearchController = api.container.lookup(\"controller:full-page-search\");\n          pageSearchController.sortOrders.pushObject({\n            name: (0, _discourseI18n.i18n)(\"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(\"service:site-settings\");\n        if (siteSettings.topic_voting_enabled) {\n          api.addSearchSuggestion(\"order:votes\");\n        }\n      });\n      (0, _pluginApi.withPluginApi)(\"2.1.0\", api => {\n        api.registerValueTransformer(\"category-available-views\", _ref => {\n          let {\n            value,\n            context\n          } = _ref;\n          if (context.customFields.enable_topic_voting) {\n            value.push({\n              name: (0, _discourseI18n.i18n)(\"filters.votes.title\"),\n              value: \"votes\"\n            });\n          }\n        });\n      });\n    }\n  };\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/pre-initializers/extend-category-for-voting\", [\"exports\", \"discourse/lib/plugin-api\", \"discourse-i18n\"], function (_exports, _pluginApi, _discourseI18n) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\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='${(0, _discourseI18n.i18n)(\"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((0, _discourseI18n.i18n)(\"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 = _exports.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});","define(\"discourse/plugins/discourse-topic-voting/discourse/pre-initializers/transformers\", [\"exports\", \"discourse/lib/plugin-api\"], function (_exports, _pluginApi) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = {\n    name: \"discourse-topic-voting-transformers\",\n    before: \"freeze-valid-transformers\",\n    initialize() {\n      (0, _pluginApi.withPluginApi)(\"1.35.0\", api => {\n        api.addBehaviorTransformerName(\"topic-vote-button-click\");\n      });\n    }\n  };\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/routes/user-activity-votes\", [\"exports\", \"discourse/models/user-action\", \"discourse/routes/user-topic-list\", \"discourse-i18n\"], function (_exports, _userAction, _userTopicList, _discourseI18n) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  class UserActivityVotes extends _userTopicList.default {\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) ? (0, _discourseI18n.i18n)(\"topic_voting.no_votes_title_self\") : (0, _discourseI18n.i18n)(\"topic_voting.no_votes_title_others\", {\n        username: user.username\n      });\n      return {\n        title,\n        body: \"\"\n      };\n    }\n  }\n  _exports.default = UserActivityVotes;\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  var _default = _exports.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={{this.category.custom_fields.enable_topic_voting}}\n        />\n        {{i18n \"topic_voting.allow_topic_voting\"}}\n      </label>\n    </div>\n  </section>\n  */\n  {\n    \"id\": \"iTtA3x+r\",\n    \"block\": \"[[[10,\\\"h3\\\"],[12],[1,[28,[35,1],[\\\"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      \\\"],[8,[39,5],null,[[\\\"@type\\\",\\\"@checked\\\"],[\\\"checkbox\\\",[30,0,[\\\"category\\\",\\\"custom_fields\\\",\\\"enable_topic_voting\\\"]]]],null],[1,\\\"\\\\n      \\\"],[1,[28,[35,1],[\\\"topic_voting.allow_topic_voting\\\"],null]],[1,\\\"\\\\n    \\\"],[13],[1,\\\"\\\\n  \\\"],[13],[1,\\\"\\\\n\\\"],[13]],[],false,[\\\"h3\\\",\\\"i18n\\\",\\\"section\\\",\\\"div\\\",\\\"label\\\",\\\"input\\\"]]\",\n    \"moduleName\": \"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/category-custom-settings/feature-voting-settings.hbs\",\n    \"isStrictMode\": false\n  });\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  var _default = _exports.default = (0, _templateFactory.createTemplateFactory)(\n  /*\n    {{#if this.model.can_vote}}\n    {{#if this.model.postStream.loaded}}\n      {{#if this.model.postStream.firstPostPresent}}\n        <div class=\"voting title-voting\">\n          {{! template-lint-disable no-capital-arguments }}\n          <MountWidget\n            @widget=\"vote-box\"\n            @args={{this.model}}\n            @showLogin={{route-action \"showLogin\"}}\n          />\n        </div>\n      {{/if}}\n    {{/if}}\n  {{/if}}\n  */\n  {\n    \"id\": \"jKEO7jg0\",\n    \"block\": \"[[[41,[30,0,[\\\"model\\\",\\\"can_vote\\\"]],[[[41,[30,0,[\\\"model\\\",\\\"postStream\\\",\\\"loaded\\\"]],[[[41,[30,0,[\\\"model\\\",\\\"postStream\\\",\\\"firstPostPresent\\\"]],[[[1,\\\"      \\\"],[10,0],[14,0,\\\"voting title-voting\\\"],[12],[1,\\\"\\\\n\\\"],[1,\\\"        \\\"],[8,[39,2],null,[[\\\"@widget\\\",\\\"@args\\\",\\\"@showLogin\\\"],[\\\"vote-box\\\",[30,0,[\\\"model\\\"]],[28,[37,3],[\\\"showLogin\\\"],null]]],null],[1,\\\"\\\\n      \\\"],[13],[1,\\\"\\\\n\\\"]],[]],null]],[]],null]],[]],null]],[],false,[\\\"if\\\",\\\"div\\\",\\\"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});","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  var _default = _exports.default = (0, _templateFactory.createTemplateFactory)(\n  /*\n    {{#if this.siteSettings.topic_voting_show_votes_on_profile}}\n    <LinkTo @route=\"userActivity.votes\">\n      {{d-icon \"heart\"}}\n      {{i18n \"topic_voting.vote_title_plural\"}}\n    </LinkTo>\n  {{/if}}\n  */\n  {\n    \"id\": \"XjZhW1Bp\",\n    \"block\": \"[[[41,[30,0,[\\\"siteSettings\\\",\\\"topic_voting_show_votes_on_profile\\\"]],[[[1,\\\"  \\\"],[8,[39,1],null,[[\\\"@route\\\"],[\\\"userActivity.votes\\\"]],[[\\\"default\\\"],[[[[1,\\\"\\\\n    \\\"],[1,[28,[35,2],[\\\"heart\\\"],null]],[1,\\\"\\\\n    \\\"],[1,[28,[35,3],[\\\"topic_voting.vote_title_plural\\\"],null]],[1,\\\"\\\\n  \\\"]],[]]]]],[1,\\\"\\\\n\\\"]],[]],null]],[],false,[\\\"if\\\",\\\"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});","define(\"discourse/plugins/discourse-topic-voting/discourse/widgets/remove-vote\", [\"exports\", \"discourse/lib/icon-library\", \"discourse/widgets/widget\", \"discourse-i18n\"], function (_exports, _iconLibrary, _widget, _discourseI18n) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.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)(\"xmark\"), (0, _discourseI18n.i18n)(\"topic_voting.remove_vote\")];\n    },\n    click() {\n      this.sendWidgetAction(\"removeVote\");\n    }\n  });\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/widgets/vote-box\", [\"exports\", \"discourse/lib/ajax\", \"discourse/lib/ajax-error\", \"discourse/widgets/raw-html\", \"discourse/widgets/widget\", \"discourse-i18n\"], function (_exports, _ajax, _ajaxError, _rawHtml, _widget, _discourseI18n) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.default = (0, _widget.createWidget)(\"vote-box\", {\n    tagName: \"div.voting-wrapper\",\n    buildKey: () => \"vote-box\",\n    buildClasses() {\n      if (this.siteSettings.topic_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'>\" + (0, _discourseI18n.i18n)(\"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});","define(\"discourse/plugins/discourse-topic-voting/discourse/widgets/vote-button\", [\"exports\", \"virtual-dom\", \"discourse/lib/cookie\", \"discourse/lib/transformer\", \"discourse/widgets/widget\", \"discourse-i18n\"], function (_exports, _virtualDom, _cookie, _transformer, _widget, _discourseI18n) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.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.topic_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 (0, _discourseI18n.i18n)(\"topic_voting.voting_closed_title\");\n        }\n        if (attrs.user_voted) {\n          return (0, _discourseI18n.i18n)(\"topic_voting.voted_title\");\n        }\n        if (this.currentUser.votes_exceeded) {\n          return (0, _discourseI18n.i18n)(\"topic_voting.voting_limit\");\n        }\n        return (0, _discourseI18n.i18n)(\"topic_voting.vote_title\");\n      }\n      if (attrs.vote_count) {\n        return (0, _discourseI18n.i18n)(\"topic_voting.anonymous_button\", {\n          count: attrs.vote_count\n        });\n      }\n      return (0, _discourseI18n.i18n)(\"topic_voting.anonymous_button\", {\n        count: 1\n      });\n    },\n    html(attrs) {\n      return (0, _virtualDom.h)(\"button\", {\n        attributes: {\n          title: this.currentUser ? (0, _discourseI18n.i18n)(\"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      (0, _transformer.applyBehaviorTransformer)(\"topic-vote-button-click\", () => {\n        if (!this.currentUser) {\n          this.sendWidgetAction(\"showLogin\");\n          (0, _cookie.default)(\"destination_url\", window.location.href, {\n            path: \"/\"\n          });\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          document.querySelector(\".vote-options\").classList.toggle(\"hidden\");\n        }\n      });\n    },\n    clickOutside() {\n      document.querySelector(\".vote-options\").classList.add(\"hidden\");\n      this.parentWidget.state.initialVote = false;\n    }\n  });\n});","define(\"discourse/plugins/discourse-topic-voting/discourse/widgets/vote-count\", [\"exports\", \"virtual-dom\", \"discourse/lib/ajax\", \"discourse/lib/cookie\", \"discourse/lib/get-url\", \"discourse/widgets/widget\"], function (_exports, _virtualDom, _ajax, _cookie, _getUrl, _widget) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.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.topic_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        (0, _cookie.default)(\"destination_url\", window.location.href, {\n          path: \"/\"\n        });\n        return;\n      }\n      if (this.siteSettings.topic_voting_show_who_voted && this.attrs.vote_count > 0) {\n        if (this.state.whoVotedUsers === null) {\n          return this.getWhoVoted();\n        } else {\n          const whoVotedElement = document.querySelector(\".who-voted\");\n          whoVotedElement.style.display = whoVotedElement.style.display === \"none\" ? \"block\" : \"none\";\n        }\n      }\n    },\n    clickOutside() {\n      const whoVotedElement = document.querySelector(\".who-voted\");\n      if (whoVotedElement) {\n        whoVotedElement.style.display = \"none\";\n      }\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  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\", \"virtual-dom\", \"discourse/widgets/widget\", \"discourse-i18n\"], function (_exports, _virtualDom, _widget, _discourseI18n) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  var _default = _exports.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\", (0, _discourseI18n.i18n)(\"topic_voting.reached_limit\")), (0, _virtualDom.h)(\"p\", (0, _virtualDom.h)(\"a\", {\n          href: this.currentUser.get(\"path\") + \"/activity/votes\"\n        }, (0, _discourseI18n.i18n)(\"topic_voting.list_votes\")))]);\n      }\n      return contents;\n    }\n  });\n});"],"mappings":"AAAAA,OAAA,oGAAAC,GACA;AAEAC,OAAAC,eAAAF,EAAA,cACAG,OAAA,IAEAH,EAAAI,aAAA;AACAJ,EAAAI,QAAA,CACAC,SAAA,OACAC,KAAA,kBACA,GAAAC,GACAC,KAAAC,MAAA,gBACAH,KAAA,WACAI,gBAAA,IACA,WACAF,KAAAC,MAAA,QACA,GACA,E,ICjBAV,OAAA,uLAAAC,EAAAW,EAAAC,EAAAC,GACA;AAEAZ,OAAAC,eAAAF,EAAA,cACAG,OAAA,IAEAH,EAAAI,aAAA;AACAJ,EAAAI,QAAA,CACAU,KAAA,yBACA,UAAAC,IACA,EAAAJ,EAAAK,eAAA,UAAAC,IAEA,GADAA,EAAAC,UAAAC,OAAA,yBACAC,qBAAA,CACAH,EAAA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