{"version":3,"file":"discourse-private-replies.js","names":["define","_exports","_component","_tracking","_component2","_modifier","_object","_service","_discourseI18n","_templateFactory","Object","defineProperty","value","default","PrivateReplies","dt7948","g","this","prototype","service","siteSettings","i","tracked","args","outletArgs","category","custom_fields","private_replies_enabled","enabled_for_category","constructor","super","arguments","enable_for_category","event","target","checked","n","action","category_private_replies_enabled","private_replies_on_selected_categories_only","setComponentTemplate","createTemplateFactory","id","block","moduleName","scope","i18n","Input","on","isStrictMode","_dIcon","PrivateRepliesBanner","hasPrivateReplies","model","get","isUserViewLimited","whoCanSee","group","private_replies_topic_starter_primary_group_can_see_all","participants","private_replies_participants_can_see_all","_ajax","_ajaxError","_pluginApi","name","initialize","container","lookup","withPluginApi","api","registerTopicFooterButton","icon","priority","title","label","ajax","type","data","topic_id","then","result","set","catch","popupAjaxError","dropdown","site","mobileView","classNames","dependentKeys","displayed","topic_owner_id","topic","currentUser","staff","registerTopicFooterButtons"],"sources":["discourse/plugins/discourse-private-replies/discourse/connectors/category-custom-security/private-replies.js","discourse/plugins/discourse-private-replies/discourse/connectors/topic-above-posts/private-replies-banner.js","discourse/plugins/discourse-private-replies/discourse/initializers/extend-for-private-replies.js"],"sourcesContent":["define(\"discourse/plugins/discourse-private-replies/discourse/connectors/category-custom-security/private-replies\", [\"exports\", \"@glimmer/component\", \"@glimmer/tracking\", \"@ember/component\", \"@ember/modifier\", \"@ember/object\", \"@ember/service\", \"discourse-i18n\", \"@ember/template-factory\"], function (_exports, _component, _tracking, _component2, _modifier, _object, _service, _discourseI18n, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  class PrivateReplies extends _component.default {\n    static {\n      dt7948.g(this.prototype, \"siteSettings\", [_service.service]);\n    }\n    #siteSettings = (dt7948.i(this, \"siteSettings\"), void 0);\n    static {\n      dt7948.g(this.prototype, \"enabled_for_category\", [_tracking.tracked], function () {\n        return this.args.outletArgs.category.custom_fields.private_replies_enabled;\n      });\n    }\n    #enabled_for_category = (dt7948.i(this, \"enabled_for_category\"), void 0);\n    constructor() {\n      super(...arguments);\n    }\n    enable_for_category(event) {\n      this.enabled_for_category = event.target.checked;\n    }\n    static {\n      dt7948.n(this.prototype, \"enable_for_category\", [_object.action]);\n    }\n    get category_private_replies_enabled() {\n      return this.siteSettings.private_replies_on_selected_categories_only === false || this.enabled_for_category;\n    }\n    static {\n      (0, _component2.setComponentTemplate)((0, _templateFactory.createTemplateFactory)(\n      /*\n        {{#if this.siteSettings.private_replies_enabled}}\n        <section>\n          <h3>{{i18n \"private_replies.title\"}}</h3>\n        </section>\n        {{#if this.siteSettings.private_replies_on_selected_categories_only}}\n          <section class=\"field category_private_replies_enabled\">\n              <label>\n              <Input @type=\"checkbox\" @checked={{this.args.outletArgs.category.custom_fields.private_replies_enabled}} {{on \"change\" this.enable_for_category}} />\n              {{i18n \"private_replies.private_replies_enabled\"}}\n              </label>\n          </section>\n        {{/if}}\n        {{#if this.category_private_replies_enabled}}\n          <section class=\"field category_private_replies_default_enabled\">\n              <label>\n              <Input @type=\"checkbox\" @checked={{this.args.outletArgs.category.custom_fields.private_replies_default_enabled}} />\n              {{i18n \"private_replies.category_default_enabled\"}}\n              </label>\n              <span>{{i18n \"private_replies.category_default_subtext\"}}</span>\n          </section>\n        {{/if}}\n      {{/if}}\n      */\n      {\n        \"id\": \"tOiAMaa2\",\n        \"block\": \"[[[41,[30,0,[\\\"siteSettings\\\",\\\"private_replies_enabled\\\"]],[[[1,\\\"  \\\"],[10,\\\"section\\\"],[12],[1,\\\"\\\\n    \\\"],[10,\\\"h3\\\"],[12],[1,[28,[32,0],[\\\"private_replies.title\\\"],null]],[13],[1,\\\"\\\\n  \\\"],[13],[1,\\\"\\\\n\\\"],[41,[30,0,[\\\"siteSettings\\\",\\\"private_replies_on_selected_categories_only\\\"]],[[[1,\\\"    \\\"],[10,\\\"section\\\"],[14,0,\\\"field category_private_replies_enabled\\\"],[12],[1,\\\"\\\\n        \\\"],[10,\\\"label\\\"],[12],[1,\\\"\\\\n        \\\"],[8,[32,1],[[4,[32,2],[\\\"change\\\",[30,0,[\\\"enable_for_category\\\"]]],null]],[[\\\"@type\\\",\\\"@checked\\\"],[\\\"checkbox\\\",[30,0,[\\\"args\\\",\\\"outletArgs\\\",\\\"category\\\",\\\"custom_fields\\\",\\\"private_replies_enabled\\\"]]]],null],[1,\\\"\\\\n        \\\"],[1,[28,[32,0],[\\\"private_replies.private_replies_enabled\\\"],null]],[1,\\\"\\\\n        \\\"],[13],[1,\\\"\\\\n    \\\"],[13],[1,\\\"\\\\n\\\"]],[]],null],[41,[30,0,[\\\"category_private_replies_enabled\\\"]],[[[1,\\\"    \\\"],[10,\\\"section\\\"],[14,0,\\\"field category_private_replies_default_enabled\\\"],[12],[1,\\\"\\\\n        \\\"],[10,\\\"label\\\"],[12],[1,\\\"\\\\n        \\\"],[8,[32,1],null,[[\\\"@type\\\",\\\"@checked\\\"],[\\\"checkbox\\\",[30,0,[\\\"args\\\",\\\"outletArgs\\\",\\\"category\\\",\\\"custom_fields\\\",\\\"private_replies_default_enabled\\\"]]]],null],[1,\\\"\\\\n        \\\"],[1,[28,[32,0],[\\\"private_replies.category_default_enabled\\\"],null]],[1,\\\"\\\\n        \\\"],[13],[1,\\\"\\\\n        \\\"],[10,1],[12],[1,[28,[32,0],[\\\"private_replies.category_default_subtext\\\"],null]],[13],[1,\\\"\\\\n    \\\"],[13],[1,\\\"\\\\n\\\"]],[]],null]],[]],null]],[],[\\\"if\\\"]]\",\n        \"moduleName\": \"/var/www/discourse/frontend/discourse/discourse/plugins/discourse-private-replies/discourse/connectors/category-custom-security/private-replies.js\",\n        \"scope\": () => [_discourseI18n.i18n, _component2.Input, _modifier.on],\n        \"isStrictMode\": true\n      }), this);\n    }\n  }\n  _exports.default = PrivateReplies;\n});","define(\"discourse/plugins/discourse-private-replies/discourse/connectors/topic-above-posts/private-replies-banner\", [\"exports\", \"@glimmer/component\", \"@ember/service\", \"discourse/helpers/d-icon\", \"discourse-i18n\", \"@ember/component\", \"@ember/template-factory\"], function (_exports, _component, _service, _dIcon, _discourseI18n, _component2, _templateFactory) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  class PrivateRepliesBanner extends _component.default {\n    static {\n      dt7948.g(this.prototype, \"siteSettings\", [_service.service]);\n    }\n    #siteSettings = (dt7948.i(this, \"siteSettings\"), void 0);\n    get hasPrivateReplies() {\n      return this.args.outletArgs.model.get(\"private_replies\");\n    }\n    get isUserViewLimited() {\n      return this.hasPrivateReplies && this.args.outletArgs.model.get(\"private_replies_limited\");\n    }\n    get whoCanSee() {\n      return (0, _discourseI18n.i18n)(\"private_replies.topic_banner_line_2\", {\n        group: this.siteSettings.private_replies_topic_starter_primary_group_can_see_all ? (0, _discourseI18n.i18n)(\"private_replies.topic_banner_line_2_group\") : \"\",\n        participants: this.siteSettings.private_replies_participants_can_see_all ? (0, _discourseI18n.i18n)(\"private_replies.topic_banner_line_2_participants\") : \"\"\n      });\n    }\n    static {\n      (0, _component2.setComponentTemplate)((0, _templateFactory.createTemplateFactory)(\n      /*\n        {{#if this.hasPrivateReplies}}\n        <div class=\"row\">\n          <div class=\"post-notice custom\">\n            {{icon 'user-secret'}}\n            <div>\n              <p>\n                {{#if this.isUserViewLimited}}\n                  {{i18n 'private_replies.topic_banner_line_1'}}\n                {{else}}\n                  {{i18n 'private_replies.topic_banner_line_1_all'}}\n                {{/if}}\n                <br>\n                {{ this.whoCanSee }}\n              </p>\n            </div>\n          </div>\n        </div>\n      {{/if}}\n      */\n      {\n        \"id\": \"Q7jzpWrg\",\n        \"block\": \"[[[41,[30,0,[\\\"hasPrivateReplies\\\"]],[[[1,\\\"  \\\"],[10,0],[14,0,\\\"row\\\"],[12],[1,\\\"\\\\n    \\\"],[10,0],[14,0,\\\"post-notice custom\\\"],[12],[1,\\\"\\\\n      \\\"],[1,[28,[32,0],[\\\"user-secret\\\"],null]],[1,\\\"\\\\n      \\\"],[10,0],[12],[1,\\\"\\\\n        \\\"],[10,2],[12],[1,\\\"\\\\n\\\"],[41,[30,0,[\\\"isUserViewLimited\\\"]],[[[1,\\\"            \\\"],[1,[28,[32,1],[\\\"private_replies.topic_banner_line_1\\\"],null]],[1,\\\"\\\\n\\\"]],[]],[[[1,\\\"            \\\"],[1,[28,[32,1],[\\\"private_replies.topic_banner_line_1_all\\\"],null]],[1,\\\"\\\\n\\\"]],[]]],[1,\\\"          \\\"],[10,\\\"br\\\"],[12],[13],[1,\\\"\\\\n          \\\"],[1,[30,0,[\\\"whoCanSee\\\"]]],[1,\\\"\\\\n        \\\"],[13],[1,\\\"\\\\n      \\\"],[13],[1,\\\"\\\\n    \\\"],[13],[1,\\\"\\\\n  \\\"],[13],[1,\\\"\\\\n\\\"]],[]],null]],[],[\\\"if\\\"]]\",\n        \"moduleName\": \"/var/www/discourse/frontend/discourse/discourse/plugins/discourse-private-replies/discourse/connectors/topic-above-posts/private-replies-banner.js\",\n        \"scope\": () => [_dIcon.default, _discourseI18n.i18n],\n        \"isStrictMode\": true\n      }), this);\n    }\n  }\n  _exports.default = PrivateRepliesBanner;\n});","define(\"discourse/plugins/discourse-private-replies/discourse/initializers/extend-for-private-replies\", [\"exports\", \"discourse/lib/ajax\", \"discourse/lib/ajax-error\", \"discourse/lib/plugin-api\"], function (_exports, _ajax, _ajaxError, _pluginApi) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  function registerTopicFooterButtons(api, container, siteSettings) {\n    api.registerTopicFooterButton({\n      id: \"privatereplies\",\n      icon() {\n        const isPrivate = this.get(\"topic.private_replies\");\n        return isPrivate ? \"far-eye\" : \"far-eye-slash\";\n      },\n      priority: 250,\n      title() {\n        const isPrivate = this.get(\"topic.private_replies\");\n        return `private_replies.button.${isPrivate ? \"public_replies\" : \"private_replies\"}.help`;\n      },\n      label() {\n        const isPrivate = this.get(\"topic.private_replies\");\n        return `private_replies.button.${isPrivate ? \"public_replies\" : \"private_replies\"}.button`;\n      },\n      action() {\n        if (!this.get(\"topic.user_id\")) {\n          return;\n        }\n        let action;\n        if (this.get(\"topic.private_replies\")) {\n          action = \"disable\";\n        } else {\n          action = \"enable\";\n        }\n        return (0, _ajax.ajax)(\"/private_replies/\" + action + \".json\", {\n          type: \"PUT\",\n          data: {\n            topic_id: this.get(\"topic.id\")\n          }\n        }).then(result => {\n          this.set(\"topic.private_replies\", result.private_replies_enabled);\n        }).catch(_ajaxError.popupAjaxError);\n      },\n      dropdown() {\n        return this.site.mobileView;\n      },\n      classNames: [\"private-replies\"],\n      dependentKeys: [\"topic.private_replies\"],\n      displayed() {\n        const topic_owner_id = this.get(\"topic.user_id\");\n        let topic = this.get(\"topic\");\n        if (siteSettings.private_replies_on_selected_categories_only === false || topic?.category?.custom_fields?.private_replies_enabled) {\n          return this.currentUser && (this.currentUser.id === topic_owner_id || this.currentUser.staff);\n        }\n        return false;\n      }\n    });\n  }\n  var _default = _exports.default = {\n    name: \"extend-for-privatereplies\",\n    initialize(container) {\n      const siteSettings = container.lookup(\"service:site-settings\");\n      if (!siteSettings.private_replies_enabled) {\n        return;\n      }\n      (0, _pluginApi.withPluginApi)(\"0.8.28\", api => registerTopicFooterButtons(api, container, siteSettings));\n    }\n  };\n});"],"mappings":"AAAAA,OAAA,2RAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,GACA;AAEAC,OAAAC,eAAAV,EAAA,cACAW,OAAA,IAEAX,EAAAY,aAAA;AACA,MAAAC,UAAAZ,EAAAW,eAEAE,OAAAC,EAAAC,KAAAC,UAAA,gBAAAX,EAAAY,SACA,CACAC,QAAAL,OAAAM,EAAAJ,KAAA;OAEAF,OAAAC,EAAAC,KAAAC,UAAA,wBAAAf,EAAAmB,SAAA,WACA,OAAAL,KAAAM,KAAAC,WAAAC,SAAAC,cAAAC,uBACA,EACA,CACAC,QAAAb,O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