{"version":3,"file":"main.Bod49Z.js","sources":["theme-81/virtual:theme","theme-81/discourse/connectors/topic-list-before-reply-count/comment-icon-new.gjs","theme-81/discourse/connectors/topic-list-before-status/vote-count-new.gjs","theme-81/discourse/initializers/init-alt-vote-cat-style.js","theme-81/virtual:entrypoint:main"],"sourcesContent":["import { getObjectForTheme } from \"discourse/lib/theme-settings-store\";\n\nexport const settings = getObjectForTheme(81);\n\nexport function themePrefix(key) {\n  return `theme_translations.81.${key}`;\n}\n","import Component from \"@glimmer/component\";\nimport { service } from \"@ember/service\";\nimport icon from \"discourse/helpers/d-icon\";\n\nexport default class CommentIcon extends Component {\n  @service discovery;\n  @service site;\n\n  get showCommentIcon() {\n    const id = this.discovery.category?.id;\n\n    if (this.site.desktopView && id) {\n      const votingCategories = settings.voting_categories\n        .split(\"|\")\n        .map(Number);\n      return votingCategories.some((category) => category === id);\n    }\n  }\n\n  <template>\n    {{#if this.showCommentIcon}}\n      {{icon \"far-comment\"}}\n    {{/if}}\n  </template>\n}\n","import Component from \"@glimmer/component\";\nimport { on } from \"@ember/modifier\";\nimport { action } from \"@ember/object\";\nimport { service } from \"@ember/service\";\nimport bodyClass from \"discourse/helpers/body-class\";\nimport concatClass from \"discourse/helpers/concat-class\";\nimport icon from \"discourse/helpers/d-icon\";\nimport { ajax } from \"discourse/lib/ajax\";\nimport { popupAjaxError } from \"discourse/lib/ajax-error\";\nimport { i18n } from \"discourse-i18n\";\n\nexport default class VoteCount extends Component {\n  @service currentUser;\n  @service discovery;\n  @service site;\n\n  get topic() {\n    return this.args.outletArgs.topic;\n  }\n\n  get showVoteCount() {\n    const votingCategories = settings.voting_categories.split(\"|\").map(Number);\n    const id = this.discovery.category?.id;\n\n    return (\n      this.site.desktopView &&\n      this.topic.get(\"can_vote\") &&\n      id &&\n      votingCategories.some((category) => category === id)\n    );\n  }\n\n  get votingDisabled() {\n    return (\n      (this.currentUser?.get(\"votes_left\") <= 0 &&\n        !this.topic.get(\"user_voted\")) ||\n      this.topic.get(\"closed\") ||\n      this.topic.get(\"unread\") === undefined\n    );\n  }\n\n  get votedStatus() {\n    if (!settings.vote_from_topic_list) {\n      return;\n    }\n\n    if (this.topic.get(\"closed\")) {\n      return i18n(themePrefix(\"closed\"));\n    } else if (\n      this.currentUser?.get(\"votes_left\") <= 0 &&\n      !this.topic.get(\"user_voted\")\n    ) {\n      return i18n(themePrefix(\"out_of_votes\"));\n    } else {\n      return this.topic.get(\"user_voted\")\n        ? i18n(themePrefix(\"user_vote\"))\n        : i18n(themePrefix(\"user_no_vote\"));\n    }\n  }\n\n  @action\n  async vote() {\n    if (\n      !settings.vote_from_topic_list ||\n      (this.currentUser.get(\"votes_left\") <= 0 && !this.topic.user_voted) ||\n      this.topic.closed ||\n      this.topic.unread === undefined\n    ) {\n      return;\n    }\n\n    let voteType;\n\n    if (this.topic.user_voted) {\n      this.topic.set(\"vote_count\", this.topic.vote_count - 1);\n      voteType = \"unvote\";\n\n      this.currentUser.set(\"votes_left\", this.currentUser.votes_left + 1);\n      this.topic.set(\"user_voted\", false);\n    } else {\n      this.topic.set(\"vote_count\", this.topic.vote_count + 1);\n      voteType = \"vote\";\n\n      this.currentUser.set(\"votes_left\", this.currentUser.votes_left - 1);\n      this.topic.set(\"user_voted\", true);\n    }\n\n    try {\n      const result = await ajax(`/voting/${voteType}`, {\n        type: \"POST\",\n        data: { topic_id: this.topic.id },\n      });\n\n      this.currentUser.setProperties({\n        votes_exceeded: !result.can_vote,\n        votes_left: result.votes_left,\n      });\n    } catch (e) {\n      popupAjaxError(e);\n    }\n  }\n\n  <template>\n    {{#if this.showVoteCount}}\n      {{bodyClass \"voting-category\"}}\n\n      <div class=\"vote-count-before-title\">\n        <button\n          {{on \"click\" this.vote}}\n          type=\"button\"\n          title={{this.votedStatus}}\n          class={{concatClass\n            \"topic-list-vote-button btn-flat\"\n            (unless this.topic.user_voted \"can-vote\")\n            (if this.votingDisabled \"disabled\")\n          }}\n        >{{icon \"caret-up\"}}</button>\n        <span class=\"vote-count-value\">{{this.topic.vote_count}}</span>\n      </div>\n    {{/if}}\n  </template>\n}\n","import { apiInitializer } from \"discourse/lib/api\";\n\nconst votingCategories = settings.voting_categories.split(\"|\").map(Number);\n\nexport default apiInitializer(\"1.1\", (api) => {\n  const discovery = api.container.lookup(\"service:discovery\");\n\n  function isVotingCategory() {\n    const currentCategoryId = discovery.category?.id;\n    return (\n      currentCategoryId && votingCategories.some((c) => c === currentCategoryId)\n    );\n  }\n\n  api.registerValueTransformer(\"topic-list-columns\", ({ value: columns }) => {\n    if (isVotingCategory()) {\n      columns.delete(\"activity\");\n      columns.delete(\"views\");\n      columns.delete(\"posters\");\n    }\n  });\n\n  api.registerValueTransformer(\n    \"topic-list-item-class\",\n    ({ value, context }) => {\n      if (!context.topic.get(\"can_vote\")) {\n        value.push(\"non-voting\");\n      }\n      return value;\n    }\n  );\n\n  api.registerValueTransformer(\"topic-list-item-expand-pinned\", ({ value }) => {\n    return (\n      ((settings.include_excerpts || settings.vote_from_topic_list) &&\n        isVotingCategory()) ||\n      value\n    );\n  });\n});\n","import * as Mod1 from \"./discourse/connectors/topic-list-before-reply-count/comment-icon-new.gjs\";\nimport * as Mod2 from \"./discourse/connectors/topic-list-before-status/vote-count-new.gjs\";\nimport * as Mod3 from \"./discourse/initializers/init-alt-vote-cat-style\";\nconst compatModules = {\n  \"discourse/connectors/topic-list-before-reply-count/comment-icon-new\": Mod1,\n  \"discourse/connectors/topic-list-before-status/vote-count-new\": Mod2,\n  \"discourse/initializers/init-alt-vote-cat-style\": Mod3,\n};\nexport { compatModules };\nexport default compatModules;\n"],"names":["settings","getObjectForTheme","themePrefix","key","CommentIcon","Component","dt7948","g","this","prototype","service","discovery","i","site","showCommentIcon","id","category","desktopView","voting_categories","split","map","Number","some","setComponentTemplate","createTemplateFactory","block","moduleName","scope","icon","isStrictMode","VoteCount","currentUser","topic","args","outletArgs","showVoteCount","votingCategories","get","votingDisabled","undefined","votedStatus","vote_from_topic_list","i18n","vote","user_voted","closed","unread","voteType","set","vote_count","votes_left","result","ajax","type","data","topic_id","setProperties","votes_exceeded","can_vote","e","popupAjaxError","n","action","bodyClass","concatClass","on","initAltVoteCatStyle","apiInitializer","api","container","lookup","isVotingCategory","currentCategoryId","c","registerValueTransformer","value","columns","delete","context","push","include_excerpts","compatModules","Mod1","Mod2"],"mappings":"67BAEaA,EAAWC,EAAkB;AAEnC,SAASC,EAAYC,GAC1B,MAAO,yBAAyBA,GAClC,CCFe,MAAMC,UAAoBC,SAAAC,OAAAC,EAAAC,KAAAC,uBACtCC,GAAA,CAAAC,QAAAL,OAAAM,EAAAJ,KAAA;OAAAF,OAAAC,EAAAC,KAAAC,kBACAC,GAAA,CAAAG,QAAAP,OAAAM,EAAAJ,KAAA;AAED,mBAAIM,GACF,MAAMC,EAAKP,KAAKG,UAAUK,UAAUD;AAEpC,GAAIP,KAAKK,KAAKI,aAAeF,EAAI,CAI/B,OAHyBf,EAASkB,kBAC/BC,MAAM,KACNC,IAAIC,QACiBC,KAAMN,GAAaA,IAAaD,EAC1D,CACF,QAEAQ,EAAAC,EAAA,CAAAT,GAAA,KAAAU,MAAA,oHAAAC,WAAA,4BAAAC,MAAAA,KAAAA,CAAAC,SAAAC,cAAA,IAIArB,KAAU;ACZG,MAAMsB,UAAkBzB,SAAAC,OAAAC,EAAAC,KAAAC,yBACpCC,GAAA,CAAAqB,QAAAzB,OAAAM,EAAAJ,KAAA;OAAAF,OAAAC,EAAAC,KAAAC,uBACAC,GAAA,CAAAC,QAAAL,OAAAM,EAAAJ,KAAA;OAAAF,OAAAC,EAAAC,KAAAC,kBACAC,GAAA,CAAAG,QAAAP,OAAAM,EAAAJ,KAAA;AAED,SAAIwB,GACF,OAAOxB,KAAKyB,KAAKC,WAAWF,KAC9B,CAEA,iBAAIG,GACF,MAAMC,EAAmBpC,EAASkB,kBAAkBC,MAAM,KAAKC,IAAIC,QAC7DN,EAAKP,KAAKG,UAAUK,UAAUD;AAEpC,OACEP,KAAKK,KAAKI,aACV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