{"version":3,"names":["window","require","registerSettings","theme_uploads","topic_solution_btn_img","define","_exports","_pluginApi","Object","defineProperty","value","default","settings","getObjectForTheme","name","after","initialize","withPluginApi","api","h","getOwner","createWidget","tagName","buildKey","html","attrs","state","popupContent","this","attach","label","title","icon","action","actionParam","className","src","topicController","lookup","currentUser","getCurrentUser","currentURL","location","pathname","test","model","isPrivateMessage","category","enable_accepted_answers","authorId","user_id","id","currentTopic","replyCount","accepted_answer","buttonPressed","button","$","addClass","decorateWidget","helper"],"sourceRoot":"theme-155/","sources":["settings.js","discourse/initializers/theme-field-598-common-html-script-1.js"],"sourcesContent":["(function() {\n  if ('require' in window) {\n    require(\"discourse/lib/theme-settings-store\").registerSettings(155, {\"theme_uploads\":{\"topic_solution_btn_img\":\"https://global.discourse-cdn.com/techcommunity/original/3X/2/c/2ce3a60c22d5e3b04808461af1e9445806a04b02.png\"}});\n  }\n})();\n","if ('define' in window) {\ndefine(\"discourse/theme-155/discourse/initializers/theme-field-598-common-html-script-1\", [\"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  const settings = require(\"discourse/lib/theme-settings-store\").getObjectForTheme(155);\n  const themePrefix = key => `theme_translations.155.${key}`;\n  var _default = _exports.default = {\n    name: \"theme-field-598-common-html-script-1\",\n    after: \"inject-objects\",\n    initialize() {\n      (0, _pluginApi.withPluginApi)(\"0.8\", api => {\n        /**\n        **Create Popup for topic for authors[Added By: Ajroddin, Date: 28/09/2021]\n        **/\n        //Imports\n        const {\n          h\n        } = require('virtual-dom');\n        const {\n          getOwner\n        } = require(\"discourse-common/lib/get-owner\");\n        const FORUM_CATEGORY_NAME = \"Forum\";\n\n        //Created  a widget to display the Accept Answer popup on topic page to the topic author, if topic has at least one reply and none of the reply is accepted as answer. \n        api.createWidget(\"accept-answer-popup-widget\", {\n          tagName: 'div.accept-answer-popup-widget',\n          buildKey: () => 'accept-answer-popup-widget',\n          html(attrs, state) {\n            //Generating the UI for the popup using virtual-dom\n            let popupContent = h('div.accept-answer-popup', h('div.accept-answer-popup-wrapper', [h('div.close-accept-answer-popup', this.attach(\"button\", {\n              label: \"\",\n              title: \"Close\",\n              icon: \"times\",\n              action: \"buttonPressed\",\n              actionParam: \"close\",\n              className: \"close\"\n            })), h('div.accept-answer-content', [h('div.accept-answer-description', [h('h3', \"Did you get the answer to your question?\"), h('sapn', \"If yes, please mark it as an \"), h('b', h('i', \"“Accepted answer”\")), h('span', \" in the bottom of the helpful topic reply:\")]), h('div.accept-answer-img', h('img', {\n              src: settings.theme_uploads.topic_solution_btn_img\n            }))])]));\n            const topicController = getOwner(this).lookup(\"controller:topic\");\n            //Get current user  \n            var currentUser = api.getCurrentUser();\n            //Get current url\n            let currentURL = window.location.pathname;\n            //If user is not logged-in OR not on topic page then return empty content. Else proceed.\n            if (!currentUser || !/^\\/t\\//.test(currentURL)) return;\n\n            //Modified the below condition to display \"Mark as accepted answer\" popup only for topics under Forum category. [Modified by: Saurabh; Date: 03-08-2022]\n            //If current topic is not private message AND current topic category allows to accept answer AND current topic category is Forum then proceed, Else return empty content.\n            if (!topicController.model.isPrivateMessage && topicController.model.category && topicController.model.category.enable_accepted_answers && topicController.model.category.name == FORUM_CATEGORY_NAME) {\n              //Get the author id to check whether logged-in user is author of the current topic.\n              let authorId = topicController.model.user_id;\n              //Check whether logged-in users is the authore of the current topic.\n              if (currentUser.id == authorId) {\n                let currentTopic = topicController.model;\n                //If topic object is valid.           \n                if (currentTopic) {\n                  //If topic has at least one reply and non of the reply is marked as accepted answer then display Accept Answer Popup.\n                  if (currentTopic.replyCount > 0 && !currentTopic.accepted_answer) return popupContent;\n                }\n              }\n            }\n\n            //Return empty content. So Accept Answer Popup will not display.         \n            return;\n          },\n          //Close the Popup on the click of close button.\n          buttonPressed(button) {\n            if (button == \"close\") {\n              $(\".accept-answer-popup\").addClass(\"hidden\");\n            }\n          }\n        });\n\n        //Attaching the accept-answer-popup-widget after the post-stream widget.\n        api.decorateWidget('post-stream:after', function (helper) {\n          return helper.attach('accept-answer-popup-widget');\n        });\n      });\n    }\n  };\n});\n}\n"],"mappings":"AACM,YAAaA,QACfC,QAAQ,sCAAsCC,iBAAiB,IAAK,CAACC,cAAgB,CAACC,uBAAyB,iHCF/G,WAAYJ,QAChBK,OAAO,kFAAmF,CAAC,UAAW,6BAA6B,SAAUC,EAAUC,GACrJ;AAEAC,OAAOC,eAAeH,EAAU,aAAc,CAC5CI,OAAO,IAETJ,EAASK,aAAU;AACnB,MAAMC,EAAWX,QAAQ,sCAAsCY,kBAAkB;AAElEP,EAASK,QAAU,CAChCG,KAAM,uCACNC,MAAO,iBACP,UAAAC,IACE,EAAIT,EAAWU,eAAe,OAAOC,IAKnC,MAAMC,EACJA,GACElB,QAAQ,gBACNmB,SACJA,GACEnB,QAAQ;AAIZiB,EAAIG,aAAa,6BAA8B,CAC7CC,QAAS,iCACTC,SAAU,IAAM,6BAChB,IAAAC,CAAKC,EAAOC,GAEV,IAAIC,EAAeR,EAAE,0BAA2BA,EAAE,kCAAmC,CAACA,EAAE,gCAAiCS,KAAKC,OAAO,SAAU,CAC7IC,MAAO,GACPC,MAAO,QACPC,KAAM,QACNC,OAAQ,gBACRC,YAAa,QACbC,UAAW,WACRhB,EAAE,4BAA6B,CAACA,EAAE,gCAAiC,CAACA,EAAE,KAAM,4CAA6CA,EAAE,OAAQ,iCAAkCA,EAAE,IAAKA,EAAE,IAAK,sBAAuBA,EAAE,OAAQ,gDAAiDA,EAAE,wBAAyBA,EAAE,MAAO,CAC5SiB,IAAKxB,EAAST,cAAcC;AAE9B,MAAMiC,EAAkBjB,EAASQ,MAAMU,OAAO;AAE9C,IAAIC,EAAcrB,EAAIsB;AAEtB,IAAIC,EAAazC,OAAO0C,SAASC;AAEjC,GAAKJ,GAAgB,SAASK,KAAKH,KAI9BJ,EAAgBQ,MAAMC,kBAAoBT,EAAgBQ,MAAME,UAAYV,EA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