{"version":3,"file":"swapd-topic-bump.js","names":["define","_exports","_component","_I18n","_ajax","_object","_service","_templateFactory","Object","defineProperty","value","default","__COLOCATED_TEMPLATE__","createTemplateFactory","id","block","moduleName","isStrictMode","async","performAction","action","topic","dlg","ajax","type","then","data","msg","alert","t","e","xhr","jqXHR","responseJSON","error_type","TopicBumpModal","static","dt7948","g","this","prototype","inject","dialog","i","init","super","arguments","set","model","next_autobump","enableAutobump","closeModal","n","disableAutobump","bumpOnce","close","setComponentTemplate","_pluginApi","_showModal","_topicBumpModal","initializeWithApi","api","container","addPostSmallActionIcon","registerTopicFooterButton","icon","priority","label","title","siteSettings","lookup","topic_bump_autobump_enabled","show","bumpTopic","dropdown","site","mobileView","classNames","dependentKeys","displayed","see_bump_topic_button","name","initialize","topic_bump_enabled","withPluginApi","_category","before","reopen","allow_topic_bump","computed","get","fieldName","custom_fields"],"sources":["discourse/plugins/swapd-topic-bump/discourse/components/modal/topic-bump-modal.js","discourse/plugins/swapd-topic-bump/discourse/initializers/extend-for-topic-bump.js","discourse/plugins/swapd-topic-bump/discourse/pre-initializers/extend-category-for-topic-bump.js","discourse/plugins/swapd-topic-bump/discourse/templates/connectors/category-custom-settings/topic-bump-settings.js"],"sourcesContent":["define(\"discourse/plugins/swapd-topic-bump/discourse/components/modal/topic-bump-modal\", [\"exports\", \"@ember/component\", \"I18n\", \"discourse/lib/ajax\", \"@ember/object\", \"@ember/service\", \"@ember/template-factory\"], function (_exports, _component, _I18n, _ajax, _object, _service, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  const __COLOCATED_TEMPLATE__ = (0, _templateFactory.createTemplateFactory)(\n  /*\n    \n  <DModal @title={{this.title}} @closeModal={{@closeModal}} class=\"close-topic-modal\">\n    <:body>\n      <p>\n        {{#if this.next_autobump}}\n          {{{i18n \"topic_bump.auto_bump.modal_text_enabled\"}}}\n        {{else}}\n          {{{i18n \"topic_bump.auto_bump.modal_text_disabled\"}}}\n      {{/if}}\n      </p>\n    </:body>\n    <:footer>\n      {{#if this.next_autobump}}\n        <DButton\n          @action={{action \"disableAutobump\"}}\n          class=\"btn-primary\"\n          @label=\"topic_bump.auto_bump.modal_button_disable\"\n        />\n      {{else}}\n        <DButton\n          @action={{action \"enableAutobump\"}}\n          class=\"btn-primary\"\n          @label=\"topic_bump.auto_bump.modal_button_enable\"\n        />\n        <DButton\n          @action={{action \"bumpOnce\"}}\n          class=\"btn-primary\"\n          @label=\"topic_bump.auto_bump.modal_button_bump\"\n        />\n      {{/if}}\n      <DButton\n        @action={{action \"close\"}}\n        @label=\"topic_bump.auto_bump.modal_button_cancel\"\n      />\n  \n    </:footer>\n  </DModal>\n  */\n  {\n    \"id\": \"DRvrEtsv\",\n    \"block\": \"[[[1,\\\"\\\\n\\\"],[8,[39,0],[[24,0,\\\"close-topic-modal\\\"]],[[\\\"@title\\\",\\\"@closeModal\\\"],[[30,0,[\\\"title\\\"]],[30,1]]],[[\\\"body\\\",\\\"footer\\\"],[[[[1,\\\"\\\\n    \\\"],[10,2],[12],[1,\\\"\\\\n\\\"],[41,[30,0,[\\\"next_autobump\\\"]],[[[1,\\\"        \\\"],[2,[28,[37,4],[\\\"topic_bump.auto_bump.modal_text_enabled\\\"],null]],[1,\\\"\\\\n\\\"]],[]],[[[1,\\\"        \\\"],[2,[28,[37,4],[\\\"topic_bump.auto_bump.modal_text_disabled\\\"],null]],[1,\\\"\\\\n\\\"]],[]]],[1,\\\"    \\\"],[13],[1,\\\"\\\\n  \\\"]],[]],[[[1,\\\"\\\\n\\\"],[41,[30,0,[\\\"next_autobump\\\"]],[[[1,\\\"      \\\"],[8,[39,6],[[24,0,\\\"btn-primary\\\"]],[[\\\"@action\\\",\\\"@label\\\"],[[28,[37,7],[[30,0],\\\"disableAutobump\\\"],null],\\\"topic_bump.auto_bump.modal_button_disable\\\"]],null],[1,\\\"\\\\n\\\"]],[]],[[[1,\\\"      \\\"],[8,[39,6],[[24,0,\\\"btn-primary\\\"]],[[\\\"@action\\\",\\\"@label\\\"],[[28,[37,7],[[30,0],\\\"enableAutobump\\\"],null],\\\"topic_bump.auto_bump.modal_button_enable\\\"]],null],[1,\\\"\\\\n      \\\"],[8,[39,6],[[24,0,\\\"btn-primary\\\"]],[[\\\"@action\\\",\\\"@label\\\"],[[28,[37,7],[[30,0],\\\"bumpOnce\\\"],null],\\\"topic_bump.auto_bump.modal_button_bump\\\"]],null],[1,\\\"\\\\n\\\"]],[]]],[1,\\\"    \\\"],[8,[39,6],null,[[\\\"@action\\\",\\\"@label\\\"],[[28,[37,7],[[30,0],\\\"close\\\"],null],\\\"topic_bump.auto_bump.modal_button_cancel\\\"]],null],[1,\\\"\\\\n\\\\n  \\\"]],[]]]]]],[\\\"@closeModal\\\"],false,[\\\"d-modal\\\",\\\":body\\\",\\\"p\\\",\\\"if\\\",\\\"i18n\\\",\\\":footer\\\",\\\"d-button\\\",\\\"action\\\"]]\",\n    \"moduleName\": \"discourse/plugins/swapd-topic-bump/discourse/components/modal/topic-bump-modal.hbs\",\n    \"isStrictMode\": false\n  });\n  async function performAction(action, topic, dlg) {\n    try {\n      let result = await (0, _ajax.ajax)(`/t/${topic.id}/${action}`, {\n        type: \"POST\"\n      }).then(data => {\n        if (data.msg) {\n          dlg.alert(_I18n.default.t(\"topic_bump.auto_bump.performed_\" + action));\n        }\n      });\n    } catch (e) {\n      const xhr = e.xhr || e.jqXHR;\n      if (xhr && xhr.responseJSON) {\n        if (xhr.responseJSON.error_type == 'rate_limit') {\n          dlg.alert(_I18n.default.t(\"topic_bump.bump_topic_button.rate_limit_error\"));\n        }\n        if (xhr.responseJSON.error_type == 'invalid_access') {\n          dlg.alert(_I18n.default.t(\"topic_bump.bump_topic_button.error\"));\n        }\n      }\n      dlg.alert(_I18n.default.t(\"topic_bump.bump_topic_button.error\"));\n    }\n  }\n  class TopicBumpModal extends _component.default {\n    static #_ = (() => dt7948.g(this.prototype, \"dialog\", [_service.inject]))();\n    #dialog = (() => (dt7948.i(this, \"dialog\"), void 0))();\n    init() {\n      super.init(...arguments);\n      this.set(\"title\", this.model.topic.next_autobump ? _I18n.default.t(\"topic_bump.auto_bump.modal_title_enabled\") : _I18n.default.t(\"topic_bump.auto_bump.modal_title_disabled\"));\n      this.set(\"next_autobump\", this.model.topic.next_autobump);\n    }\n    enableAutobump() {\n      performAction(\"autobump_enable\", this.model.topic, this.dialog);\n      this.model.topic.next_autobump = 1;\n      this.closeModal();\n    }\n    static #_2 = (() => dt7948.n(this.prototype, \"enableAutobump\", [_object.action]))();\n    disableAutobump() {\n      performAction(\"autobump_disable\", this.model.topic, this.dialog);\n      this.model.topic.next_autobump = false;\n      this.closeModal();\n    }\n    static #_3 = (() => dt7948.n(this.prototype, \"disableAutobump\", [_object.action]))();\n    bumpOnce() {\n      performAction(\"bump\", this.model.topic, this.dialog);\n      this.closeModal();\n    }\n    static #_4 = (() => dt7948.n(this.prototype, \"bumpOnce\", [_object.action]))();\n    close() {\n      this.closeModal();\n    }\n    static #_5 = (() => dt7948.n(this.prototype, \"close\", [_object.action]))();\n  }\n  _exports.default = TopicBumpModal;\n  (0, _component.setComponentTemplate)(__COLOCATED_TEMPLATE__, TopicBumpModal);\n});","define(\"discourse/plugins/swapd-topic-bump/discourse/initializers/extend-for-topic-bump\", [\"exports\", \"discourse/lib/plugin-api\", \"discourse/lib/ajax\", \"discourse/lib/show-modal\", \"I18n\", \"discourse/plugins/swapd-topic-bump/discourse/components/modal/topic-bump-modal\"], function (_exports, _pluginApi, _ajax, _showModal, _I18n, _topicBumpModal) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  async function bumpTopic(topic, container) {\n    const siteSettings = container.lookup(\"site-settings:main\");\n    const dialog = container.lookup(\"service:dialog\");\n    if (siteSettings.topic_bump_autobump_enabled) {\n      let modal = container.lookup(\"service:modal\");\n      modal.show(_topicBumpModal.default, {\n        model: {\n          topic: topic\n        }\n      });\n      return;\n    }\n    try {\n      let result = await (0, _ajax.ajax)(`/t/${topic.id}/bump`, {\n        type: \"POST\"\n      }).then(data => {\n        if (data.msg) {\n          dialog.alert(_I18n.default.t(\"topic_bump.bump_topic_button.bumped\"));\n        }\n      });\n    } catch (e) {\n      const xhr = e.xhr || e.jqXHR;\n      if (xhr && xhr.responseJSON) {\n        if (xhr.responseJSON.error_type == 'rate_limit') {\n          dialog.alert(_I18n.default.t(\"topic_bump.bump_topic_button.rate_limit_error\"));\n          return;\n        }\n        if (xhr.responseJSON.error_type == 'invalid_access') {\n          dialog.alert(_I18n.default.t(\"topic_bump.bump_topic_button.error\"));\n          return;\n        }\n      }\n      dialog.alert(_I18n.default.t(\"topic_bump.bump_topic_button.error\"));\n    }\n  }\n  function initializeWithApi(api, container) {\n    api.addPostSmallActionIcon(\"bumped\", \"fire-flame-curved\");\n    api.registerTopicFooterButton({\n      id: \"topic_bump\",\n      icon: \"fire-flame-curved\",\n      priority: 240,\n      label: \"topic_bump.bump_topic_button.label\",\n      title: \"topic_bump.bump_topic_button.title\",\n      action() {\n        bumpTopic(this.topic, container);\n      },\n      dropdown() {\n        return this.site.mobileView;\n      },\n      classNames: [\"topic_bump\"],\n      dependentKeys: [\"topic.see_bump_topic_button\"],\n      displayed() {\n        return this.topic.see_bump_topic_button;\n      }\n    });\n  }\n  var _default = _exports.default = {\n    name: \"extend-for-topic-bump\",\n    initialize(container) {\n      const siteSettings = container.lookup(\"site-settings:main\");\n      if (!siteSettings.topic_bump_enabled) {\n        return;\n      }\n      (0, _pluginApi.withPluginApi)(\"0.8.28\", api => initializeWithApi(api, container));\n    }\n  };\n});","define(\"discourse/plugins/swapd-topic-bump/discourse/pre-initializers/extend-category-for-topic-bump\", [\"exports\", \"discourse/models/category\", \"@ember/object\"], function (_exports, _category, _object) {\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: \"extend-category-for-topic-bump\",\n    before: \"inject-discourse-objects\",\n    initialize() {\n      _category.default.reopen({\n        allow_topic_bump: (0, _object.computed)(\"custom_fields.allow_topic_bump\", {\n          get(fieldName) {\n            return (0, _object.get)(this.custom_fields, fieldName) === \"true\";\n          }\n        })\n      });\n    }\n  };\n});","define(\"discourse/plugins/swapd-topic-bump/discourse/templates/connectors/category-custom-settings/topic-bump-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    {{#if this.siteSettings.topic_bump_enabled}}\n    <h3>{{i18n \"topic_bump.title\"}}</h3>\n    <section class=\"field\">\n      <div class=\"allow-topic-bump\">\n        <label class=\"checkbox-label\">\n          {{input\n            type=\"checkbox\"\n            checked=this.category.custom_fields.allow_topic_bump\n          }}\n          {{i18n \"topic_bump.allow_topic_bump\"}}\n        </label>\n      </div>\n    </section>\n  {{/if}}\n  */\n  {\n    \"id\": \"1jnpLN5L\",\n    \"block\": \"[[[41,[30,0,[\\\"siteSettings\\\",\\\"topic_bump_enabled\\\"]],[[[1,\\\"  \\\"],[10,\\\"h3\\\"],[12],[1,[28,[35,2],[\\\"topic_bump.title\\\"],null]],[13],[1,\\\"\\\\n  \\\"],[10,\\\"section\\\"],[14,0,\\\"field\\\"],[12],[1,\\\"\\\\n    \\\"],[10,0],[14,0,\\\"allow-topic-bump\\\"],[12],[1,\\\"\\\\n      \\\"],[10,\\\"label\\\"],[14,0,\\\"checkbox-label\\\"],[12],[1,\\\"\\\\n        \\\"],[1,[28,[35,6],null,[[\\\"type\\\",\\\"checked\\\"],[\\\"checkbox\\\",[30,0,[\\\"category\\\",\\\"custom_fields\\\",\\\"allow_topic_bump\\\"]]]]]],[1,\\\"\\\\n        \\\"],[1,[28,[35,2],[\\\"topic_bump.allow_topic_bump\\\"],null]],[1,\\\"\\\\n      \\\"],[13],[1,\\\"\\\\n    \\\"],[13],[1,\\\"\\\\n  \\\"],[13],[1,\\\"\\\\n\\\"]],[]],null]],[],false,[\\\"if\\\",\\\"h3\\\",\\\"i18n\\\",\\\"section\\\",\\\"div\\\",\\\"label\\\",\\\"input\\\"]]\",\n    \"moduleName\": \"discourse/plugins/swapd-topic-bump/discourse/templates/connectors/category-custom-settings/topic-bump-settings.hbs\",\n    \"isStrictMode\": false\n  });\n});"],"mappings":"AAAAA,OAAA,gNAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,GACA;AAEAC,OAAAC,eAAAR,EAAA,cACAS,OAAA,IAEAT,EAAAU,aAAA;AACA,MAAAC,GAAA,EAAAL,EAAAM,uBAwCA,CACAC,GAAA,WACAC,MAAA,+sCACAC,WAAA,qFACAC,cAAA;AAEAC,eAAAC,EAAAC,EAAAC,EAAAC,GACA,UACA,EAAAlB,EAAAmB,MAAA,MAAAF,EAAAP,MAAAM,IAAA,CACAI,KAAA,SACAC,KAAAC,IACAA,EAAAC,KACAL,EAAAM,MAAAzB,EAAAQ,QAAAkB,EAAA,kCAAAT,KAGA,OAAAU,GACA,MAAAC,EAAAD,EAAAC,KAAAD,EAAAE;AACAD,KAAAE,eACA,cAAAF,EAAAE,aAAAC,YACAZ,EAAAM,MAAAzB,EAAAQ,QAAAkB,EAAA,kDAEA,kBAAAE,EAAAE,aAAAC,YACAZ,EAAAM,MAAAzB,EAAAQ,QAAAkB,EAAA,wCAGAP,EAAAM,MAAAzB,EAAAQ,QAAAkB,EAAA,sCACA,CACA,CACA,MAAAM,UAAAjC,EAAAS,QACAyB,SAAA,KAAAC,OAAAC,EAAAC,KAAAC,UAAA,UAAAlC,EAAAmC,SAAA;AACAC,GAAA,MAAAL,OAAAM,EAAAJ,KAAA;AACA,IAAAK,GACAC,MAAAD,QAAAE,WACAP,KAAAQ,IAAA,QAAAR,KAAAS,MAAA3B,MAAA4B,cAAA9C,EAAAQ,QAAAkB,EAAA,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